Skip to content

Commit e52df2e

Browse files
author
Your Name
committed
feat: update shared primitives, fix receipts, add clean+tag verbs, restore scripts
1 parent 37d9439 commit e52df2e

File tree

21 files changed

+1294
-455
lines changed

21 files changed

+1294
-455
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
package-lock.json
3+
NUL

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@commandlayer/protocol-commons",
3+
"version": "1.0.0",
4+
"description": "CommandLayer — canonical verb + schema layer for autonomous agents. A2A + x402 + ERC-8004 aligned.",
5+
"private": false,
6+
"type": "module",
7+
"license": "MIT",
8+
"engines": {
9+
"node": ">=20.0.0"
10+
},
11+
"devDependencies": {
12+
"ajv": "^8.17.1",
13+
"ajv-cli": "^5.0.0",
14+
"ajv-errors": "^3.0.0",
15+
"ajv-formats": "^3.0.1"
16+
},
17+
"scripts": {
18+
"validate:schema": "node scripts/ajv-run.mjs",
19+
"validate:schemas": "node scripts/validate-all.mjs",
20+
"validate:examples": "node scripts/validate-examples.mjs",
21+
"generate:checksums": "node scripts/generate-checksums.mjs schemas/v1.0.0 checksums.txt",
22+
"scan:unionTypes": "node scripts/find-union-types.mjs",
23+
"validate:all": "npm run validate:schemas && npm run validate:examples",
24+
"validate": "npm run validate:all"
25+
}
26+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$id": "https://commandlayer.org/schemas/v1.0.0/_shared/identity.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "identity",
5+
"description": "Shared logical identity envelope for actors in CommandLayer (humans, apps, or agents).",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"properties": {
9+
"id": {
10+
"description": "Opaque logical identifier for the actor (user ID, system ID, etc.).",
11+
"type": "string",
12+
"minLength": 1,
13+
"maxLength": 256
14+
},
15+
"display_name": {
16+
"description": "Optional human-readable display name.",
17+
"type": "string",
18+
"maxLength": 256
19+
},
20+
"wallet": {
21+
"description": "Optional EVM wallet address associated with this identity.",
22+
"type": "string",
23+
"pattern": "^0x[a-fA-F0-9]{40}$"
24+
},
25+
"ens": {
26+
"description": "Optional ENS name associated with this identity.",
27+
"type": "string",
28+
"minLength": 3,
29+
"maxLength": 253
30+
},
31+
"role": {
32+
"description": "Optional role of this actor in the interaction (e.g., user, system, agent).",
33+
"type": "string",
34+
"maxLength": 64
35+
},
36+
"metadata": {
37+
"description": "Optional additional metadata about the actor. Safe to log.",
38+
"type": "object",
39+
"additionalProperties": true
40+
}
41+
},
42+
"required": ["id"]
43+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$id": "https://commandlayer.org/schemas/v1.0.0/_shared/trace.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "trace",
5+
"description": "Shared trace envelope for correlating requests and receipts across agents, hops, and spans.",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"properties": {
9+
"trace_id": {
10+
"description": "Logical trace identifier for correlating all spans in a workflow.",
11+
"type": "string",
12+
"minLength": 1,
13+
"maxLength": 128
14+
},
15+
"span_id": {
16+
"description": "Identifier for this specific span within the trace.",
17+
"type": "string",
18+
"minLength": 1,
19+
"maxLength": 128
20+
},
21+
"parent_span_id": {
22+
"description": "Optional parent span identifier, if this span is a child of another.",
23+
"type": "string",
24+
"minLength": 1,
25+
"maxLength": 128
26+
},
27+
"timestamp": {
28+
"description": "ISO 8601 UTC timestamp for when this span was created.",
29+
"type": "string",
30+
"format": "date-time"
31+
},
32+
"tags": {
33+
"description": "Optional key-value tags for tracing and diagnostics.",
34+
"type": "object",
35+
"additionalProperties": {
36+
"type": "string",
37+
"maxLength": 512
38+
}
39+
}
40+
},
41+
"required": ["trace_id"]
42+
}

schemas/v1.0.0/commons/classify/receipts/classify.receipt.schema.json

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$id": "https://commandlayer.org/schemas/v1.0.0/commons/classify/receipts/classify.receipt.schema.json",
33
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"title": "classify.receipt",
5-
"description": "Receipt for classify requests, extending the CommandLayer base receipt structure with classification-specific result and usage fields.",
5+
"description": "Receipt for a classify request, including labels and optional scores.",
66
"type": "object",
77
"allOf": [
88
{
@@ -13,7 +13,7 @@
1313
"additionalProperties": false,
1414
"properties": {
1515
"x402": {
16-
"description": "x402 envelope describing the classify verb and version for this receipt.",
16+
"description": "x402 envelope describing the verb and version for this receipt.",
1717
"allOf": [
1818
{
1919
"$ref": "https://commandlayer.org/schemas/v1.0.0/_shared/x402.schema.json"
@@ -30,57 +30,45 @@
3030
]
3131
},
3232
"result": {
33-
"description": "Classification result payload when status = 'success'.",
33+
"description": "Classification result payload.",
3434
"type": "object",
3535
"additionalProperties": false,
3636
"properties": {
3737
"labels": {
38-
"description": "Labels considered for this classification along with scores and explanations.",
38+
"description": "List of labels assigned to the input, optionally with scores.",
3939
"type": "array",
4040
"items": {
4141
"type": "object",
4242
"additionalProperties": false,
4343
"properties": {
4444
"label": {
45-
"description": "Label or category name.",
4645
"type": "string",
4746
"minLength": 1,
48-
"maxLength": 128
49-
},
50-
"selected": {
51-
"description": "Whether this label is considered true/active for the given input.",
52-
"type": "boolean"
47+
"maxLength": 256
5348
},
5449
"score": {
55-
"description": "Confidence score or probability associated with this label.",
50+
"description": "Confidence score in [0,1] if available.",
5651
"type": "number",
5752
"minimum": 0,
5853
"maximum": 1
5954
},
60-
"explanation": {
61-
"description": "Optional natural-language explanation for why this label was assigned or not.",
62-
"type": "string",
63-
"maxLength": 2048
55+
"primary": {
56+
"description": "Whether this label is considered the primary classification.",
57+
"type": "boolean"
6458
}
6559
},
6660
"required": ["label"]
67-
},
68-
"minItems": 1
69-
},
70-
"top_label": {
71-
"description": "Single best label chosen by the classifier, if applicable.",
72-
"type": "string",
73-
"maxLength": 128
61+
}
7462
},
75-
"schema_uri": {
76-
"description": "Optional URI of the taxonomy or schema actually used for classification.",
63+
"primary_label": {
64+
"description": "Primary label chosen for the input, if any.",
7765
"type": "string",
78-
"maxLength": 2048
66+
"minLength": 1,
67+
"maxLength": 256
7968
},
80-
"source_hash": {
81-
"description": "Optional hash of the input content (e.g., sha256 hex).",
69+
"taxonomy_version": {
70+
"description": "Optional taxonomy or label-set version identifier.",
8271
"type": "string",
83-
"minLength": 32,
8472
"maxLength": 128
8573
}
8674
},
@@ -91,35 +79,18 @@
9179
"type": "object",
9280
"additionalProperties": false,
9381
"properties": {
94-
"input_tokens": {
95-
"description": "Number of input tokens consumed.",
96-
"type": "integer",
97-
"minimum": 0
98-
},
99-
"output_tokens": {
100-
"description": "Number of output tokens produced.",
101-
"type": "integer",
102-
"minimum": 0
103-
},
104-
"total_tokens": {
105-
"description": "Total tokens used (input + output), if available.",
106-
"type": "integer",
107-
"minimum": 0
108-
},
109-
"cost_usd": {
110-
"description": "Optional cost for this call in USD (or equivalent fiat), if known.",
82+
"input_tokens": { "type": "integer", "minimum": 0 },
83+
"output_tokens": { "type": "integer", "minimum": 0 },
84+
"total_tokens": { "type": "integer", "minimum": 0 },
85+
"cost": {
86+
"description": "Optional cost for this call in provider-defined units.",
11187
"type": "number",
11288
"minimum": 0
113-
},
114-
"latency_ms": {
115-
"description": "Observed end-to-end latency for this invocation in milliseconds.",
116-
"type": "integer",
117-
"minimum": 0
11889
}
11990
}
12091
}
12192
},
122-
"required": ["x402", "trace", "status", "result"]
93+
"required": ["result"]
12394
}
12495
]
12596
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"$id": "https://commandlayer.org/schemas/v1.0.0/commons/clean/receipts/clean.receipt.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "clean.receipt",
5+
"description": "Receipt for a clean request, including cleaned content and policy outcome.",
6+
"type": "object",
7+
"allOf": [
8+
{
9+
"$ref": "https://commandlayer.org/schemas/v1.0.0/_shared/receipt.base.schema.json"
10+
},
11+
{
12+
"type": "object",
13+
"additionalProperties": false,
14+
"properties": {
15+
"x402": {
16+
"description": "x402 envelope describing the verb and version for this receipt.",
17+
"allOf": [
18+
{
19+
"$ref": "https://commandlayer.org/schemas/v1.0.0/_shared/x402.schema.json"
20+
},
21+
{
22+
"type": "object",
23+
"additionalProperties": false,
24+
"properties": {
25+
"verb": { "const": "clean" },
26+
"version": { "const": "1.0.0" }
27+
},
28+
"required": ["verb", "version"]
29+
}
30+
]
31+
},
32+
"result": {
33+
"description": "Cleaning result payload.",
34+
"type": "object",
35+
"additionalProperties": false,
36+
"properties": {
37+
"cleaned_content": {
38+
"description": "The cleaned/sanitized content.",
39+
"type": "string",
40+
"minLength": 1
41+
},
42+
"format": {
43+
"description": "Format of the cleaned content.",
44+
"type": "string",
45+
"enum": ["text", "markdown", "html", "json", "other"]
46+
},
47+
"changes_applied": {
48+
"description": "List of cleaning operations actually applied.",
49+
"type": "array",
50+
"items": {
51+
"type": "string",
52+
"minLength": 1,
53+
"maxLength": 128
54+
}
55+
},
56+
"redacted": {
57+
"description": "Whether any redaction occurred.",
58+
"type": "boolean"
59+
}
60+
},
61+
"required": ["cleaned_content"]
62+
},
63+
"usage": {
64+
"description": "Optional resource usage metrics for this invocation.",
65+
"type": "object",
66+
"additionalProperties": false,
67+
"properties": {
68+
"input_tokens": { "type": "integer", "minimum": 0 },
69+
"output_tokens": { "type": "integer", "minimum": 0 },
70+
"total_tokens": { "type": "integer", "minimum": 0 },
71+
"cost": {
72+
"description": "Optional cost for this call in provider-defined units.",
73+
"type": "number",
74+
"minimum": 0
75+
}
76+
}
77+
}
78+
},
79+
"required": ["result"]
80+
}
81+
]
82+
}

0 commit comments

Comments
 (0)