Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

- Separated VerifyAgent into its own public Commons/MIT repository. The SDK now focuses on receipt generation, canonicalization, hashing, signing, verification, ENS helpers, and agent-wrapping utilities. Public paste-and-verify UI is handled externally by VerifyAgent.

For public paste-and-verify receipt verification, use VerifyAgent:
https://github.com/commandlayer/verifyagent

## [1.1.0] - 2026-03-19

CommandLayer SDKs now align on the Commons-first Protocol-Commons v1.1.0 surface. This release replaces the mixed 1.0.0-era documentation and response assumptions with a single canonical receipt model shared by the TypeScript SDK, Python SDK, fixtures, and verification flow.
Expand Down
134 changes: 28 additions & 106 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# CommandLayer SDK Examples

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 Commons examples do not include payment metadata.
Examples in this repository focus on reusable SDK behavior:
- receipt creation,
- canonicalization,
- SHA-256 hashing,
- Ed25519 signing/verification,
- ENS key-resolution helpers, and
- wrapping agent execution in CommandLayer receipts.

All examples in this file target:
- Protocol-Commons v1.1.0,
- canonical signed receipts returned as `response.receipt`, and
- optional execution context returned as `response.runtime_metadata`.
For public paste-and-verify receipt verification, use VerifyAgent:
https://github.com/commandlayer/verifyagent

## Architecture boundaries

- SDK repo: programmatic receipt tooling.
- VerifyAgent repo: external public verifier UI.
- Commercial API: hosted runtime, x402/paid flows, indexing, dashboards.

## 1. Canonical response envelope

Expand Down Expand Up @@ -35,7 +45,7 @@ All examples in this file target:
}
```

## TypeScript
## 2. TypeScript

```ts
import { createClient, extractReceiptVerb, verifyReceipt } from "@commandlayer/sdk";
Expand All @@ -49,105 +59,13 @@ const response = await client.summarize({
console.log(extractReceiptVerb(response));
console.log(response.receipt.metadata.receipt_id);

```ts
const response = await client.clean({
content: " test@example.com ",
operations: ["trim", "redact_emails"]
});
```

### Convert

```ts
const response = await client.convert({
content: '{"a":1}',
from: "json",
to: "csv"
});
```

### Describe

```ts
const response = await client.describe({
subject: "receipt verification",
audience: "general",
detail: "medium"
});
```

### Explain

```ts
const response = await client.explain({
subject: "receipt verification",
audience: "novice",
style: "step-by-step"
});
```

### Format

```ts
const response = await client.format({
content: "a: 1\nb: 2",
to: "table"
});
```

### Parse

```ts
const response = await client.parse({
content: '{ "a": 1 }',
contentType: "json",
mode: "strict",
schema: "invoice.summary.v1"
});
```

### Fetch

```ts
const response = await client.fetch({
source: "https://example.com",
include_metadata: true
});
```

## 3. Python examples

```python
from commandlayer import create_client

client = create_client(actor="examples-py")

summary = client.summarize(content="CommandLayer defines semantic agent verbs.", style="bullet_points")
analysis = client.analyze(content="Invoice total: $1200", goal="detect finance intent")
classification = client.classify(content="Contact support@example.com")
cleaned = client.clean(content=" test@example.com ", operations=["trim", "redact_emails"])
converted = client.convert(content='{"a":1}', from_format="json", to_format="csv")
description = client.describe(subject="receipt verification")
explanation = client.explain(subject="receipt verification", style="step-by-step")
formatted = client.format(content="a: 1\nb: 2", to="table")
parsed = client.parse(content='{ "a": 1 }', content_type="json", mode="strict", schema="invoice.summary.v1")
fetched = client.fetch(source="https://example.com", include_metadata=True)
```

## 4. Verification examples

### TypeScript, explicit key

```ts
import { verifyReceipt } from "@commandlayer/sdk";

const result = await verifyReceipt(response.receipt, {
const verified = await verifyReceipt(response.receipt, {
publicKey: "ed25519:BASE64_PUBLIC_KEY"
});
console.log(verified.ok);
```

## Python
## 3. Python

```python
from commandlayer import create_client, verify_receipt
Expand All @@ -164,17 +82,21 @@ print(response["receipt"]["metadata"]["receipt_id"])
print(verify_receipt(response["receipt"], public_key="ed25519:BASE64_PUBLIC_KEY")["ok"])
```

## Explicit request building
## 4. Explicit request building

### Commons

```ts
import { buildCommonsRequest } from "@commandlayer/sdk";

const payload = buildCommonsRequest("parse", {
input: { content: '{"a":1}', content_type: "json", mode: "strict" },
limits: { max_output_tokens: 300 }
}, { actor: "examples-ts" });
const payload = buildCommonsRequest(
"parse",
{
input: { content: '{"a":1}', content_type: "json", mode: "strict" },
limits: { max_output_tokens: 300 }
},
{ actor: "examples-ts" }
);
```

```python
Expand All @@ -192,4 +114,4 @@ payload = build_commons_request(

### Commercial request shaping

Commercial request shaping is intentionally separate from Commons examples. Use the dedicated `buildCommercialRequest` / `build_commercial_request` helper only if you are integrating a payment-aware flow outside this repo's first-class runtime client surface.
Commercial request shaping is intentionally separate from Commons SDK examples in this repository.
60 changes: 24 additions & 36 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# CommandLayer SDK Quickstart

## What this quickstart covers

SDK-only receipt flow:
1. Install SDK
2. Wrap agent execution
3. Generate signed receipt
4. Verify with SDK locally or VerifyAgent publicly
5. Move to Commercial API for hosted/high-volume verification

For public paste-and-verify receipt verification, use VerifyAgent:
https://github.com/commandlayer/verifyagent

## 1. Install

```bash
npm install @commandlayer/sdk
pip install commandlayer
```

## 2. Make one call
## 2. Wrap agent execution

### TypeScript

Expand Down Expand Up @@ -39,36 +51,7 @@ print(response["receipt"]["result"]["summary"])
print(response["receipt"]["metadata"]["receipt_id"])
```

## 3. Inspect the response

Both SDKs return the same shape:

```json
{
"receipt": {
"status": "success",
"verb": "summarize",
"result": { "summary": "..." },
"metadata": {
"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
}
}
```

Use `response.receipt` as the durable protocol artifact. `runtime_metadata` is optional execution context. Commons responses should be treated as receipt-first and non-payment-aware; `x402` only appears in legacy or explicitly commercial payloads.

## 4. Verify the receipt
## 3. Verify locally with SDK

### TypeScript

Expand All @@ -77,14 +60,19 @@ import { verifyReceipt } from "@commandlayer/sdk";
await verifyReceipt(response.receipt, { publicKey: "ed25519:BASE64_PUBLIC_KEY" });
```

### Python

```python
from commandlayer import verify_receipt
verify_receipt(response["receipt"], public_key="ed25519:BASE64_PUBLIC_KEY")
```

## 4. Remember the contract
## 4. Verification options

- Local SDK verification: canonicalization + SHA-256 + Ed25519 signature checks.
- ENS-based key resolution: resolve signer keys via ENS helpers.
- Public verification UI: use external VerifyAgent repository.

## 5. Commercial upgrade path

- Persist `response.receipt`.
- Treat `response.runtime_metadata` as optional unsigned context.
- Treat `receipt.metadata.receipt_id` as the receipt hash identifier.
- Read the verb from `receipt.verb`. Legacy/commercial payloads may expose `receipt.x402.verb` as a fallback.
Use CommandLayer Commercial when you need hosted runtime integrations, paid API/x402 flows, or high-volume verification infrastructure.
Loading
Loading