← 返回
未分类 Key 中文

X5 Protocol Client

Send X5 protocol API requests from the terminal. Use this skill whenever the user wants to test, call, or send X5 API requests; parse .x5 files; generate X5...
在终端发送 X5 协议 API 请求。当用户想要测试、调用或发送 X5 API 请求、解析 .x5 文件或生成 X5 时使用此技能。
growingppp
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 318
下载
💾 0
安装
1
版本
#latest

概述

X5 Protocol Skill

Send X5 protocol requests directly from the terminal using scripts/x5_client.py.

Quick Start

# Send request from .x5 file
python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py --file request.x5 --json

# Inline request
python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py \
  --appid my_app --appkey my_key \
  --url http://localhost:8080/x5/api \
  --method createUser \
  --body '{"name":"test"}' \
  --json

X5 Protocol Specification

Signature Calculation

sign = md5(appid + JSON.stringify(body) + appkey).toUpperCase()

The body is serialized as compact JSON (no spaces), then concatenated with appid and appkey, MD5-hashed, and uppercased.

Request Encoding Steps

  1. Build the X5 envelope:
{
  "header": {
    "appid": "app_id",
    "sign": "MD5_SIGNATURE_UPPERCASE",
    "method": "X5_Method_Name"
  },
  "body": "{\"key\":\"value\"}"
}
  1. JSON-serialize the envelope (compact, no spaces)
  2. Base64-encode the JSON string
  3. Send as POST with Content-Type: application/x-www-form-urlencoded
  4. Body: data=

Response Format

X5 responses use the same envelope structure:

{
  "header": {
    "code": 0,
    "message": "success"
  },
  "body": { ... }
}

Success: HTTP 2xx AND X5 code 0 or 200.

.x5 File Format

### Request Description
@name = RequestName
@appid = my_app_id
@appkey = my_app_key
@url = http://localhost:8080/x5/api/endpoint

POST @url
X5-Method: methodName
X-Custom-Header: custom-value

{
  "key": "value"
}

Directives:

DirectiveDescription
------------------------
@nameRequest name (for multi-request files)
@appidApplication ID
@appkeyApplication secret key
@urlRequest URL (referenced by POST @url)
X5-Method:X5 API method name (overwrites HTTP method)

Key parsing rules:

  • ### separates multiple requests in one file
  • # lines are comments
  • POST @url sets URL via @url directive reference
  • X5-Method: overwrites the method from the POST line
  • Any Header-Name: value line becomes a custom HTTP header
  • JSON body starts with { or [

Multiple requests per file:

### Create Resource
@name = createResource
@appid = my_app
@appkey = my_key
@url = http://localhost:8080/x5/resource/create

POST @url
X5-Method: createResource
{"name": "test"}

### Query Resource
@name = queryResource
@appid = my_app
@appkey = my_key
@url = http://localhost:8080/x5/resource/query

POST @url
X5-Method: queryResource
{"resourceId": "123"}

CLI Reference

python3 x5_client.py [OPTIONS]

Options:
  --file FILE           Path to .x5 file
  --request-name NAME   Specific request name (for multi-request files)
  --list                List all requests in .x5 file (no send)
  --appid APPID         App ID (inline or override)
  --appkey APPKEY       App Key (inline or override)
  --url URL             Target URL (inline or override)
  --method METHOD       X5 method name (inline or override)
  --body BODY           JSON body string
  --body-file FILE      JSON body file path
  --header KEY=VALUE    Custom HTTP header (repeatable)
  --curl                Generate cURL command (no send)
  --dry-run             Show encoded request (no send)
  --json                Output in JSON format
  --timeout MS          Timeout in ms (default: 30000)

Usage Patterns

Pattern 1: Send from .x5 file

python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py --file /path/to/request.x5 --json

For multi-request files, use --request-name:

python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py --file /path/to/api.x5 --request-name createUser --json

Pattern 2: Inline request

Use when the user describes a request conversationally or provides parameters directly:

python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py \
  --appid VALUE --appkey VALUE --url VALUE --method VALUE \
  --body '{"key":"value"}' --json

Pattern 3: Generate cURL

python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py --file request.x5 --curl

Pattern 4: List requests in file

python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py --file request.x5 --list

Pattern 5: Debug / inspect encoded request

python3 ~/.claude/skills/x5-protocol/scripts/x5_client.py --file request.x5 --dry-run --json

Shows signature, Base64 payload, and full envelope without sending.

Important Notes

  • Always use --json for programmatic consumption — parse the JSON output to present results to the user
  • When a .x5 file has multiple requests and the user doesn't specify which one, list them and ask
  • CLI params (--appid, --appkey, etc.) override values from the .x5 file
  • The script uses Python stdlib only (zero dependencies)
  • Exit code 0 = success, 1 = error, 2 = argument error
  • On error with --json, output is {"success": false, "error": "message"}

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 12:39 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,358 📥 318,203
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 712 📥 243,765
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,466