@commandlayer/sdk
v1.1.0
Published
Official TypeScript/JavaScript SDK for CommandLayer Commons v1.1.0.
Downloads
11
Readme
CommandLayer TypeScript SDK
Official TypeScript/JavaScript SDK for CommandLayer Commons v1.1.0.
Use this package to:
- call CommandLayer Commons verbs,
- receive a canonical signed receipt,
- capture optional runtime metadata separately,
- verify receipts offline or through ENS, and
- reproduce calls from the CLI.
Install
npm install @commandlayer/sdkSupported runtime: Node.js 20+.
Quick start
import { createClient, verifyReceipt } from "@commandlayer/sdk";
const client = createClient({ actor: "docs-example" });
const response = await client.summarize({
content: "CommandLayer makes agent execution verifiable.",
style: "bullet_points"
});
console.log(response.receipt.result?.summary);
console.log(response.receipt.metadata?.receipt_id);
console.log(response.runtime_metadata?.duration_ms);
const verification = await verifyReceipt(response.receipt, {
publicKey: process.env.COMMANDLAYER_PUBLIC_KEY!
});
console.log(verification.ok);Return shape
Client methods return:
{
"receipt": {
"status": "success",
"x402": {
"verb": "summarize",
"version": "1.1.0"
},
"result": {},
"metadata": {
"receipt_id": "...",
"proof": {
"alg": "ed25519-sha256",
"canonical": "cl-stable-json-v1",
"signer_id": "runtime.commandlayer.eth",
"hash_sha256": "...",
"signature_b64": "..."
}
}
},
"runtime_metadata": {
"trace_id": "trace_123",
"duration_ms": 118,
"provider": "runtime.commandlayer.org"
}
}verifyReceipt() accepts the canonical receipt object. The SDK also accepts a whole response envelope for legacy compatibility, but new integrations should pass response.receipt explicitly.
Verification modes
Offline
const result = await verifyReceipt(response.receipt, {
publicKey: "ed25519:BASE64_PUBLIC_KEY"
});ENS-backed
const result = await verifyReceipt(response.receipt, {
ens: {
name: "summarizeagent.eth",
rpcUrl: process.env.MAINNET_RPC_URL!
}
});The ENS flow resolves:
cl.receipt.signeron the agent ENS name,cl.sig.pubon the signer ENS name,cl.sig.kidon the signer ENS name.
CLI
The package ships the commandlayer CLI.
commandlayer summarize --content "hello" --style bullet_points --json
commandlayer verify --file receipt.json --public-key "ed25519:BASE64_PUBLIC_KEY"Development
cd typescript-sdk
npm ci
npm run typecheck
npm test