Skip to content

Commit 4ec9dd1

Browse files
author
Your Name
committed
feat: add full commons JSON+TS examples for all verbs
1 parent 1257d2e commit 4ec9dd1

File tree

146 files changed

+3957
-1578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+3957
-1578
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"x402": {
3+
"verb": "summarize",
4+
"version": "1.0.0"
5+
},
6+
"input": {
7+
"content": "This should be a string, not an object."
8+
}
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"x402": {
3+
"verb": "analyze",
4+
"version": "1.0.0",
5+
"request_id": "req-analyze-2025-11-19-0002"
6+
},
7+
"trace": {
8+
"trace_id": "trace-analyze-0002",
9+
"started_at": "2025-11-19T20:35:00Z",
10+
"completed_at": "2025-11-19T20:35:01Z",
11+
"duration_ms": 870,
12+
"provider": "commandlayer-demo",
13+
"region": "us-east-1",
14+
"model": "analyze-large-001"
15+
},
16+
"status": "ok",
17+
"result": {
18+
"summary": "",
19+
"insights": [],
20+
"labels": []
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// INVALID analyze.receipt #1 — wrong status + empty summary
2+
3+
export const analyzeReceiptInvalid1: any = {
4+
x402: {
5+
verb: "analyze",
6+
version: "1.0.0",
7+
request_id: "req-analyze-2025-11-19-0002"
8+
},
9+
trace: {
10+
trace_id: "trace-analyze-0002",
11+
started_at: "2025-11-19T20:35:00Z",
12+
completed_at: "2025-11-19T20:35:01Z",
13+
duration_ms: 870,
14+
provider: "commandlayer-demo",
15+
region: "us-east-1",
16+
model: "analyze-large-001"
17+
},
18+
// ❌ status is not in enum
19+
status: "ok",
20+
result: {
21+
// ❌ summary should not be empty if required/minLength: 1
22+
summary: ""
23+
}
24+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// INVALID analyze.receipt #2 — missing trace + result
2+
3+
export const analyzeReceiptInvalid2: any = {
4+
x402: {
5+
verb: "analyze",
6+
version: "1.0.0"
7+
},
8+
// ❌ Missing trace
9+
// ❌ Missing result when status='success'
10+
status: "success"
11+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// INVALID analyze.request #1 — wrong verb + wrong input type
2+
3+
export const analyzeRequestInvalid1: any = {
4+
x402: {
5+
verb: "summarize",
6+
version: "1.0.0"
7+
},
8+
// ❌ input should be a string
9+
input: {
10+
content: "This should be a string, not an object."
11+
}
12+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// INVALID analyze.request #2 — missing required x402 + input
2+
3+
export const analyzeRequestInvalid2: any = {
4+
// ❌ missing x402
5+
// ❌ missing input
6+
goal: "This object intentionally violates the schema."
7+
};
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// VALID analyze.receipt #1 — aligns with analyze.receipt.schema.json (assumed)
2+
3+
export type AnalyzeReceiptStatus = "success" | "error" | "delegated";
4+
5+
export interface X402AnalyzeReceiptEnvelope {
6+
verb: "analyze";
7+
version: "1.0.0";
8+
request_id?: string;
9+
network?: string;
10+
tenant?: string;
11+
}
12+
13+
export interface AnalyzeTraceMetadata {
14+
trace_id: string;
15+
parent_trace_id?: string;
16+
started_at?: string;
17+
completed_at?: string;
18+
duration_ms?: number;
19+
provider?: string;
20+
region?: string;
21+
model?: string;
22+
tags?: string[];
23+
}
24+
25+
export interface AnalyzeResultPayload {
26+
summary: string;
27+
insights?: string[];
28+
labels?: string[];
29+
score?: number;
30+
}
31+
32+
export interface AnalyzeUsageMetrics {
33+
input_tokens?: number;
34+
output_tokens?: number;
35+
total_tokens?: number;
36+
cost?: number;
37+
}
38+
39+
export interface AnalyzeReceipt {
40+
x402: X402AnalyzeReceiptEnvelope;
41+
trace: AnalyzeTraceMetadata;
42+
status: AnalyzeReceiptStatus;
43+
result: AnalyzeResultPayload;
44+
usage?: AnalyzeUsageMetrics;
45+
}
46+
47+
export const analyzeReceiptValid1: AnalyzeReceipt = {
48+
x402: {
49+
verb: "analyze",
50+
version: "1.0.0",
51+
request_id: "req-analyze-2025-11-19-0001",
52+
network: "mainnet"
53+
},
54+
trace: {
55+
trace_id: "trace-analyze-0001",
56+
started_at: "2025-11-19T20:30:00Z",
57+
completed_at: "2025-11-19T20:30:01Z",
58+
duration_ms: 950,
59+
provider: "commandlayer-demo",
60+
region: "us-east-1",
61+
model: "analyze-large-001",
62+
tags: ["analyze", "example", "v1.0.0"]
63+
},
64+
status: "success",
65+
result: {
66+
summary:
67+
"The launch plan is sound but dependent on ecosystem awareness and clarity around ERC-8004/x402 alignment.",
68+
insights: [
69+
"Clarify messaging to standards authors.",
70+
"Secure 2–3 ecosystem design partners pre-launch."
71+
],
72+
labels: ["risk:medium", "ecosystem:critical"],
73+
score: 0.78
74+
},
75+
usage: {
76+
input_tokens: 1024,
77+
output_tokens: 220,
78+
total_tokens: 1244,
79+
cost: 0.0037
80+
}
81+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// VALID analyze.receipt #2 — same schema, different data
2+
3+
import type { AnalyzeReceipt } from "./analyze.receipt.valid.1";
4+
5+
export const analyzeReceiptValid2: AnalyzeReceipt = {
6+
x402: {
7+
verb: "analyze",
8+
version: "1.0.0",
9+
request_id: "req-analyze-2025-11-19-0003"
10+
},
11+
trace: {
12+
trace_id: "trace-analyze-0003",
13+
started_at: "2025-11-19T20:40:00Z",
14+
completed_at: "2025-11-19T20:40:01Z",
15+
duration_ms: 880,
16+
provider: "commandlayer-demo",
17+
region: "eu-west-1",
18+
model: "analyze-medium-001",
19+
tags: ["analyze", "example", "alt"]
20+
},
21+
status: "success",
22+
result: {
23+
summary:
24+
"Analysis highlights minor documentation gaps and recommends clarifying schema ownership and versioning guarantees.",
25+
insights: ["Clarify schema stewardship in README.", "Document versioning policy."],
26+
labels: ["docs:improvable"]
27+
}
28+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// VALID analyze.request #1 — aligned with analyze.request.schema.json (assumed)
2+
3+
export interface X402AnalyzeRequestEnvelope {
4+
verb: "analyze";
5+
version: "1.0.0";
6+
request_id?: string;
7+
network?: string;
8+
tenant?: string;
9+
}
10+
11+
export interface AnalyzeLimits {
12+
max_tokens?: number;
13+
timeout_ms?: number;
14+
}
15+
16+
export interface AnalyzeRequest {
17+
x402: X402AnalyzeRequestEnvelope;
18+
input: string;
19+
goal?: string;
20+
hints?: string[];
21+
limits?: AnalyzeLimits;
22+
metadata?: Record<string, unknown>;
23+
}
24+
25+
export const analyzeRequestValid1: AnalyzeRequest = {
26+
x402: {
27+
verb: "analyze",
28+
version: "1.0.0",
29+
request_id: "req-analyze-2025-11-19-0001"
30+
},
31+
input:
32+
"Review this plan and identify protocol, ecosystem, and execution risks for CommandLayer launch.",
33+
goal: "Surface top 5 risks and unknowns.",
34+
hints: [
35+
"Focus on external ecosystem dependencies.",
36+
"Call out assumptions about VC interest."
37+
],
38+
limits: {
39+
max_tokens: 512,
40+
timeout_ms: 4000
41+
},
42+
metadata: {
43+
project: "commandlayer",
44+
verb_set: "commons"
45+
}
46+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// VALID analyze.request #2 — same schema, different data
2+
3+
import type { AnalyzeRequest } from "./analyze.request.valid.1";
4+
5+
export const analyzeRequestValid2: AnalyzeRequest = {
6+
x402: {
7+
verb: "analyze",
8+
version: "1.0.0",
9+
request_id: "req-analyze-2025-11-19-0002",
10+
network: "base"
11+
},
12+
input:
13+
"Analyze this technical spec and highlight schema risks, ambiguous fields, and potential validation pitfalls.",
14+
goal: "Find schema-level risks and incompatibilities.",
15+
hints: ["Pay attention to allOf and additionalProperties usage."],
16+
limits: {
17+
max_tokens: 256
18+
}
19+
};

0 commit comments

Comments
 (0)