Skip to content

Commit 1257d2e

Browse files
author
Your Name
committed
feat: remove tag/translate; add analyze+fetch; fix receipt.base and summarize receipt layering
1 parent feaec2f commit 1257d2e

20 files changed

+885
-962
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export const summarizeRequestValid = {
2+
x402: {
3+
verb: "summarize",
4+
version: "1.0.0",
5+
request_id: "req-ts-001",
6+
idempotency_key: "idem-req-ts-001"
7+
},
8+
trace: {
9+
trace_id: "trace-ts-001",
10+
span_id: "span-ts-001",
11+
timestamp: "2025-11-19T22:55:00Z"
12+
},
13+
actor: {
14+
id: "user-ts-001",
15+
display_name: "TS Example User",
16+
role: "user"
17+
},
18+
channel: {
19+
type: "http",
20+
endpoint: "https://api.example.com/a2a/summarize"
21+
},
22+
modalities: ["text"],
23+
limits: {
24+
max_chars: 400
25+
},
26+
input: {
27+
content: "This is some example content we want to summarize programmatically from TypeScript.",
28+
format: "text",
29+
locale: "en-US"
30+
},
31+
instructions: "Summarize this content for a technical stakeholder.",
32+
metadata: {
33+
tenant: "ts-tenant-001",
34+
source: "ts-example"
35+
}
36+
} as const;
37+
38+
export const summarizeRequestInvalid = {
39+
x402: {
40+
verb: "summarize",
41+
version: "1.0.0"
42+
},
43+
trace: {
44+
trace_id: "trace-ts-001",
45+
span_id: "span-ts-001",
46+
timestamp: "2025-11-19T22:55:00Z"
47+
},
48+
actor: {
49+
id: "user-ts-001"
50+
},
51+
channel: {
52+
type: "invalid_channel"
53+
},
54+
modalities: [],
55+
input: {
56+
format: "text"
57+
}
58+
// missing required input.content, bad channel type, empty modalities
59+
} as const;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"x402": {
3+
"verb": "summarize",
4+
"version": "1.0.0"
5+
},
6+
"actor": "",
7+
"limits": {
8+
"max_output_tokens": 0
9+
},
10+
"input": {
11+
"content": ""
12+
},
13+
"channel": {
14+
"protocol": "invalid-protocol",
15+
"input_modalities": [],
16+
"output_modalities": []
17+
}
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"x402": {
3+
"verb": "summarize",
4+
"version": "1.0.0"
5+
},
6+
"trace": {
7+
"trace_id": "trace-001",
8+
"span_id": "span-002",
9+
"timestamp": "2025-11-19T22:50:05Z"
10+
},
11+
"status": "not_a_valid_status"
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"x402": {
3+
"verb": "translate",
4+
"version": "1.0.0",
5+
"idempotency_key": "summarize-2025-11-19-0002"
6+
},
7+
"trace": {
8+
"trace_id": "trace-summarize-0002",
9+
"span_id": "span-root-0002"
10+
},
11+
"status": {
12+
"code": "OK",
13+
"http_status": 200,
14+
"message": "This status looks fine, but the receipt is still invalid."
15+
},
16+
"debug": {
17+
"note": "This field should not exist if additionalProperties:false is enforced."
18+
}
19+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// examples/v1.0.0/commons/summarize/ts/summarize.receipt.examples.ts
2+
3+
export interface X402Envelope {
4+
verb: "summarize";
5+
version: "1.0.0";
6+
idempotency_key: string;
7+
}
8+
9+
export interface TraceMetadata {
10+
trace_id: string;
11+
span_id: string;
12+
parent_span_id?: string | null;
13+
}
14+
15+
export interface ReceiptStatus {
16+
code: "OK" | "ERROR";
17+
http_status: number;
18+
message: string;
19+
}
20+
21+
export interface TokenUsage {
22+
input: number;
23+
output: number;
24+
total: number;
25+
}
26+
27+
export interface SummarizeResult {
28+
summary: string;
29+
tokens_used: TokenUsage;
30+
model: string;
31+
provider: string;
32+
format?: "plain_text" | "markdown" | "html";
33+
}
34+
35+
export interface SummarizeReceipt {
36+
x402: X402Envelope;
37+
trace: TraceMetadata;
38+
status: ReceiptStatus;
39+
result: SummarizeResult;
40+
created_at: string; // ISO 8601
41+
duration_ms?: number;
42+
}
43+
44+
// ✅ Valid summarize receipt example (should pass Ajv)
45+
export const validSummarizeReceiptExample: SummarizeReceipt = {
46+
x402: {
47+
verb: "summarize",
48+
version: "1.0.0",
49+
idempotency_key: "summarize-2025-11-19-0001"
50+
},
51+
trace: {
52+
trace_id: "trace-summarize-0001",
53+
span_id: "span-root-0001"
54+
},
55+
status: {
56+
code: "OK",
57+
http_status: 200,
58+
message: "Summarization completed successfully."
59+
},
60+
result: {
61+
summary:
62+
"This document explains the CommandLayer commons, including canonical verbs, shared primitives, and the launch sequence for v1.0.0. The primary outcome is that the protocol-commons repo is ready for examples, checksums, IPFS pinning, ENS TXT anchoring, and public release.",
63+
tokens_used: {
64+
input: 1234,
65+
output: 180,
66+
total: 1414
67+
},
68+
model: "gpt-5.1",
69+
provider: "openai",
70+
format: "markdown"
71+
},
72+
created_at: "2025-11-19T19:45:00Z",
73+
duration_ms: 842
74+
};
75+
76+
// ❌ Invalid summarize receipt example (should fail Ajv)
77+
// Reasons:
78+
// - x402.verb is wrong ("translate")
79+
// - result is missing
80+
// - extra `debug` property not allowed by additionalProperties:false
81+
export const invalidSummarizeReceiptExample: any = {
82+
x402: {
83+
verb: "translate",
84+
version: "1.0.0",
85+
idempotency_key: "summarize-2025-11-19-0002"
86+
},
87+
trace: {
88+
trace_id: "trace-summarize-0002",
89+
span_id: "span-root-0002"
90+
},
91+
status: {
92+
code: "OK",
93+
http_status: 200,
94+
message: "Looks superficially OK, but the receipt is invalid."
95+
},
96+
debug: {
97+
note: "This field should not exist if additionalProperties:false is applied."
98+
}
99+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"x402": {
3+
"verb": "summarize",
4+
"version": "1.0.0",
5+
"request_id": "req-001",
6+
"idempotency_key": "idem-req-001"
7+
},
8+
"actor": "user-001",
9+
"limits": {
10+
"max_output_tokens": 512,
11+
"max_latency_ms": 30000,
12+
"max_cost_usd": 0.01
13+
},
14+
"input": {
15+
"content": "This is a long block of content that we want to summarize into a concise, useful form for a stakeholder.",
16+
"format_hint": "text",
17+
"summary_style": "exec_brief"
18+
},
19+
"channel": {
20+
"protocol": "https",
21+
"input_modalities": ["text"],
22+
"output_modalities": ["text"],
23+
"endpoint": "https://api.example.com/a2a/summarize"
24+
},
25+
"auth": {
26+
"scheme": "api_key",
27+
"api_key_id": "api-key-id-001"
28+
},
29+
"delegation": {
30+
"allowed": true,
31+
"targets": ["classifyagent.eth"],
32+
"policy": "auto",
33+
"reason": "Allow downstream classification after summarization if needed."
34+
},
35+
"context": {
36+
"conversation_id": "conv-001",
37+
"parent_task_id": "task-000",
38+
"thread": [
39+
{ "role": "user", "content": "Original conversation context placeholder." }
40+
]
41+
},
42+
"metadata": {
43+
"tenant": "tenant-001",
44+
"environment": "test"
45+
}
46+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"x402": {
3+
"verb": "summarize",
4+
"version": "1.0.0",
5+
"idempotency_key": "summarize-2025-11-19-0001"
6+
},
7+
"trace": {
8+
"trace_id": "trace-summarize-0001",
9+
"span_id": "span-root-0001"
10+
},
11+
"status": {
12+
"code": "OK",
13+
"http_status": 200,
14+
"message": "Summarization completed successfully."
15+
},
16+
"result": {
17+
"summary": "This document describes the current state of the CommandLayer protocol, including the canonical verbs, shared primitives, and launch checklist. The key outcome is that protocol-commons v1.0.0 is ready for examples, checksums, IPFS pinning, ENS TXT anchoring, and public release.",
18+
"tokens_used": {
19+
"input": 1234,
20+
"output": 180,
21+
"total": 1414
22+
},
23+
"model": "gpt-5.1",
24+
"provider": "openai",
25+
"format": "markdown"
26+
},
27+
"created_at": "2025-11-19T19:45:00Z",
28+
"duration_ms": 842
29+
}
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
{}
1+
{
2+
"x402": {
3+
"verb": "summarize",
4+
"version": "1.0.0",
5+
"request_id": "req-001",
6+
"idempotency_key": "idem-req-001"
7+
},
8+
"trace": {
9+
"trace_id": "trace-001",
10+
"span_id": "span-001"
11+
},
12+
"status": "ok",
13+
"provider": {
14+
"name": "summarizeagent.eth",
15+
"version": "1.0.0",
16+
"agent_ens": "summarizeagent.eth"
17+
},
18+
"result": {
19+
"summary": "This is a concise executive summary of the input content.",
20+
"format": "text",
21+
"compression_ratio": 4.2,
22+
"source_hash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
23+
},
24+
"usage": {
25+
"input_tokens": 2048,
26+
"output_tokens": 256,
27+
"total_tokens": 2304,
28+
"cost": 0.0012
29+
},
30+
"meta": {
31+
"environment": "test",
32+
"region": "us-east-1"
33+
}
34+
}

package.json

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,3 @@
1-
<<<<<<< HEAD
2-
{
3-
"name": "@commandlayer/protocol-commons",
4-
"version": "1.0.0",
5-
"description": "CommandLayer — canonical verb + schema layer for autonomous agents. A2A + x402 + ERC-8004 aligned.",
6-
"private": false,
7-
"type": "module",
8-
"license": "MIT",
9-
10-
"engines": {
11-
"node": ">=20.0.0"
12-
},
13-
14-
"devDependencies": {
15-
"ajv": "^8.17.1",
16-
"ajv-cli": "^5.0.0",
17-
"ajv-errors": "^3.0.0",
18-
"ajv-formats": "^3.0.1"
19-
},
20-
21-
"scripts": {
22-
"validate:schema": "node scripts/ajv-run.mjs",
23-
"validate:schemas": "node scripts/validate-all.mjs",
24-
"validate:examples": "node scripts/validate-examples.mjs",
25-
"generate:checksums": "node scripts/generate-checksums.mjs schemas/v1.0.0 checksums.txt",
26-
"scan:unionTypes": "node scripts/find-union-types.mjs",
27-
"validate:all": "npm run validate:schemas && npm run validate:examples",
28-
"validate": "npm run validate:all"
29-
}
30-
}
31-
=======
321
{
332
"name": "@commandlayer/protocol-commons",
343
"version": "1.0.0",
@@ -40,6 +9,7 @@
409
"node": ">=20.0.0"
4110
},
4211
"devDependencies": {
12+
"ajv": "^8.17.1",
4313
"ajv": "^8.17.1",
4414
"ajv-cli": "^5.0.0",
4515
"ajv-errors": "^3.0.0",
@@ -55,4 +25,3 @@
5525
"validate": "npm run validate:all"
5626
}
5727
}
58-
>>>>>>> e52df2e (feat: update shared primitives, fix receipts, add clean+tag verbs, restore scripts)

0 commit comments

Comments
 (0)