Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.

Commit 3c60baf

Browse files
committed
Align Commons requests with v1.1.0 schemas
1 parent 30feaa0 commit 3c60baf

8 files changed

Lines changed: 234 additions & 351 deletions

File tree

EXAMPLES.md

Lines changed: 35 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
# CommandLayer SDK Examples
22

3-
Canonical examples for the CommandLayer SDK repo. These examples keep the Commons v1.1.0 story receipt-first: `receipt` is signed, `runtime_metadata` is optional and unsigned, and the `x402` object is protocol metadata rather than a commercial SDK surface.
3+
Canonical examples for the CommandLayer SDK repo. These examples keep the Commons v1.1.0 story aligned with the active request and receipt contracts: requests are flat top-level protocol objects, `receipt` is signed, `runtime_metadata` is optional and unsigned, and the `x402` object only appears inside receipts as protocol metadata.
44

55
All examples in this file target:
66
- Protocol-Commons v1.1.0,
7+
- flat request payloads shaped exactly like `schemas/v1.1.0/commons/<verb>/<verb>.request.schema.json`,
78
- canonical signed receipts returned as `response.receipt`, and
89
- optional execution context returned as `response.runtime_metadata`.
910

10-
## 1. Canonical response envelope
11+
## 1. Canonical summarize request
12+
13+
```json
14+
{
15+
"verb": "summarize",
16+
"version": "1.1.0",
17+
"input": "CommandLayer defines semantic agent verbs.",
18+
"mode": "brief"
19+
}
20+
```
21+
22+
## 2. Canonical response envelope
1123

1224
```json
1325
{
1426
"receipt": {
1527
"status": "success",
1628
"x402": {
1729
"verb": "summarize",
18-
"version": "1.1.0",
30+
"version": "1.1.0"
1931
},
2032
"result": {
2133
"summary": "..."
@@ -39,15 +51,14 @@ All examples in this file target:
3951
}
4052
```
4153

42-
## 2. TypeScript examples
54+
## 3. TypeScript examples
4355

4456
### Create client
4557

4658
```ts
4759
import { createClient } from "@commandlayer/sdk";
4860

4961
const client = createClient({
50-
actor: "examples-ts",
5162
runtime: "https://runtime.commandlayer.org"
5263
});
5364
```
@@ -56,8 +67,8 @@ const client = createClient({
5667

5768
```ts
5869
const response = await client.summarize({
59-
content: "CommandLayer defines semantic agent verbs.",
60-
style: "bullet_points"
70+
input: "CommandLayer defines semantic agent verbs.",
71+
mode: "brief"
6172
});
6273

6374
console.log(response.receipt.result?.summary);
@@ -67,73 +78,70 @@ console.log(response.receipt.result?.summary);
6778

6879
```ts
6980
const response = await client.analyze({
70-
content: "Invoice total: $1200",
71-
goal: "detect finance intent"
81+
input: "Invoice total: $1200",
82+
mode: "deep"
7283
});
7384
```
7485

7586
### Classify
7687

7788
```ts
7889
const response = await client.classify({
79-
content: "Contact support@example.com"
90+
input: "Contact support@example.com",
91+
mode: "single"
8092
});
8193
```
8294

8395
### Clean
8496

8597
```ts
8698
const response = await client.clean({
87-
content: " test@example.com ",
88-
operations: ["trim", "redact_emails"]
99+
input: " test@example.com ",
100+
mode: "sanitize"
89101
});
90102
```
91103

92104
### Convert
93105

94106
```ts
95107
const response = await client.convert({
96-
content: '{"a":1}',
97-
from: "json",
98-
to: "csv"
108+
input: '{"a":1}',
109+
mode: "structured"
99110
});
100111
```
101112

102113
### Describe
103114

104115
```ts
105116
const response = await client.describe({
106-
subject: "receipt verification",
107-
audience: "general",
108-
detail: "medium"
117+
input: "receipt verification",
118+
mode: "detailed"
109119
});
110120
```
111121

112122
### Explain
113123

114124
```ts
115125
const response = await client.explain({
116-
subject: "receipt verification",
117-
audience: "novice",
118-
style: "step-by-step"
126+
input: "receipt verification",
127+
mode: "stepwise"
119128
});
120129
```
121130

122131
### Format
123132

124133
```ts
125134
const response = await client.format({
126-
content: "a: 1\nb: 2",
127-
to: "table"
135+
input: "a: 1\nb: 2",
136+
mode: "markdown"
128137
});
129138
```
130139

131140
### Parse
132141

133142
```ts
134143
const response = await client.parse({
135-
content: '{ "a": 1 }',
136-
contentType: "json",
144+
input: '{ "a": 1 }',
137145
mode: "strict"
138146
});
139147
```
@@ -142,154 +150,7 @@ const response = await client.parse({
142150

143151
```ts
144152
const response = await client.fetch({
145-
source: "https://example.com",
146-
include_metadata: true
147-
});
148-
```
149-
150-
## 3. Python examples
151-
152-
```python
153-
from commandlayer import create_client
154-
155-
client = create_client(actor="examples-py")
156-
157-
summary = client.summarize(content="CommandLayer defines semantic agent verbs.", style="bullet_points")
158-
analysis = client.analyze(content="Invoice total: $1200", goal="detect finance intent")
159-
classification = client.classify(content="Contact support@example.com")
160-
cleaned = client.clean(content=" test@example.com ", operations=["trim", "redact_emails"])
161-
converted = client.convert(content='{"a":1}', from_format="json", to_format="csv")
162-
description = client.describe(subject="receipt verification")
163-
explanation = client.explain(subject="receipt verification", style="step-by-step")
164-
formatted = client.format(content="a: 1\nb: 2", to="table")
165-
parsed = client.parse(content='{ "a": 1 }', content_type="json", mode="strict")
166-
fetched = client.fetch(source="https://example.com", include_metadata=True)
167-
```
168-
169-
## 4. Verification examples
170-
171-
### TypeScript, explicit key
172-
173-
```ts
174-
import { verifyReceipt } from "@commandlayer/sdk";
175-
176-
const result = await verifyReceipt(response.receipt, {
177-
publicKey: "ed25519:BASE64_PUBLIC_KEY"
178-
});
179-
```
180-
181-
### Python, explicit key
182-
183-
```python
184-
from commandlayer import verify_receipt
185-
186-
result = verify_receipt(response["receipt"], public_key="ed25519:BASE64_PUBLIC_KEY")
187-
```
188-
189-
### ENS-backed verification
190-
191-
```ts
192-
const result = await verifyReceipt(response.receipt, {
193-
ens: {
194-
name: "summarizeagent.eth",
195-
rpcUrl: process.env.MAINNET_RPC_URL!
196-
}
197-
});
198-
```
199-
200-
```python
201-
result = verify_receipt(
202-
response["receipt"],
203-
ens={"name": "summarizeagent.eth", "rpcUrl": "https://mainnet.infura.io/v3/YOUR_KEY"},
204-
)
205-
```
206-
207-
## 5. CLI examples
208-
209-
### Summarize
210-
211-
```bash
212-
commandlayer summarize \
213-
--content "CommandLayer defines semantic verbs." \
214-
--style bullet_points \
215-
--json
216-
```
217-
218-
### Analyze
219-
220-
```bash
221-
commandlayer analyze \
222-
--content "Invoice total: $500" \
223-
--goal "detect finance intent" \
224-
--json
225-
```
226-
227-
### Verify a saved receipt
228-
229-
```bash
230-
commandlayer verify \
231-
--file receipt.json \
232-
--public-key "ed25519:BASE64_PUBLIC_KEY"
233-
```
234-
235-
## 6. Runtime override
236-
237-
### TypeScript
238-
239-
```ts
240-
const client = createClient({
241-
actor: "override-example",
242-
runtime: "https://staging-runtime.commandlayer.org"
153+
input: "https://example.com",
154+
mode: "html"
243155
});
244156
```
245-
246-
### Python
247-
248-
```python
249-
client = create_client(
250-
actor="override-example",
251-
runtime="https://staging-runtime.commandlayer.org",
252-
)
253-
```
254-
255-
## 7. Persist the canonical receipt
256-
257-
```ts
258-
import { writeFile } from "node:fs/promises";
259-
260-
await writeFile("receipt.json", JSON.stringify(response.receipt, null, 2));
261-
```
262-
263-
```python
264-
import json
265-
from pathlib import Path
266-
267-
Path("receipt.json").write_text(json.dumps(response["receipt"], indent=2), encoding="utf-8")
268-
```
269-
270-
## 8. Error handling
271-
272-
### TypeScript
273-
274-
```ts
275-
import { CommandLayerError } from "@commandlayer/sdk";
276-
277-
try {
278-
await client.summarize({ content: "" });
279-
} catch (error) {
280-
if (error instanceof CommandLayerError) {
281-
console.error(error.statusCode, error.message, error.details);
282-
}
283-
}
284-
```
285-
286-
### Python
287-
288-
```python
289-
from commandlayer import CommandLayerError
290-
291-
try:
292-
client.summarize(content="")
293-
except CommandLayerError as error:
294-
print(error.status_code, error, error.details)
295-
```

QUICKSTART.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ npm install -g @commandlayer/sdk
3131
```ts
3232
import { createClient } from "@commandlayer/sdk";
3333

34-
const client = createClient({ actor: "quickstart-ts" });
34+
const client = createClient();
3535

3636
const response = await client.summarize({
37-
content: "CommandLayer makes agent execution verifiable.",
38-
style: "bullet_points"
37+
input: "CommandLayer makes agent execution verifiable.",
38+
mode: "brief"
3939
});
4040

4141
console.log(response.receipt.result?.summary);
@@ -55,7 +55,22 @@ response = client.summarize(
5555
print(response["receipt"]["result"]["summary"])
5656
```
5757

58-
## 3. Inspect the response
58+
## 3. Inspect the request contract
59+
60+
Protocol-Commons v1.1.0 Commons requests are flat top-level objects:
61+
62+
```json
63+
{
64+
"verb": "summarize",
65+
"version": "1.1.0",
66+
"input": "CommandLayer makes agent execution verifiable.",
67+
"mode": "brief"
68+
}
69+
```
70+
71+
Do not send nested `input` objects, `limits`, actor wrappers, or `x402` request metadata for Commons verbs.
72+
73+
## 4. Inspect the response
5974

6075
Both SDKs return the same shape:
6176

@@ -83,9 +98,9 @@ Both SDKs return the same shape:
8398
}
8499
```
85100

86-
Use `response.receipt` as the durable protocol artifact. `runtime_metadata` is optional execution context. The retained `x402` object carries Commons verb metadata and is not a commercial feature signal.
101+
Use `response.receipt` as the durable protocol artifact. `runtime_metadata` is optional execution context. The retained `x402` object carries Commons verb metadata in receipts and is not a request wrapper or commercial feature signal.
87102

88-
## 4. Verify the receipt
103+
## 5. Verify the receipt
89104

90105
### TypeScript
91106

@@ -118,12 +133,12 @@ Use the same signer-discovery model in both SDKs:
118133
- signer ENS TXT: `cl.sig.pub`
119134
- signer ENS TXT: `cl.sig.kid`
120135

121-
## 5. Try the CLI
136+
## 6. Try the CLI
122137

123138
```bash
124139
commandlayer summarize \
125-
--content "CommandLayer makes agent execution verifiable." \
126-
--style bullet_points \
140+
--input "CommandLayer makes agent execution verifiable." \
141+
--mode brief \
127142
--json
128143
```
129144

@@ -135,7 +150,7 @@ commandlayer verify \
135150
--public-key "ed25519:BASE64_PUBLIC_KEY"
136151
```
137152

138-
## 6. What is stable today?
153+
## 7. What is stable today?
139154

140155
Stable in this repo:
141156
- Protocol-Commons v1.1.0 verb surface,

0 commit comments

Comments
 (0)