settld 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +32 -0
  2. package/SETTLD_VERSION +1 -1
  3. package/bin/settld.js +58 -0
  4. package/docs/CIRCLE_SANDBOX_E2E.md +12 -0
  5. package/docs/QUICKSTART_MCP.md +41 -1
  6. package/docs/QUICKSTART_MCP_HOSTS.md +156 -89
  7. package/docs/QUICKSTART_POLICY_PACKS.md +65 -0
  8. package/docs/QUICKSTART_PROFILES.md +198 -0
  9. package/docs/README.md +18 -0
  10. package/docs/RELEASE_CHECKLIST.md +26 -0
  11. package/docs/RELEASING.md +1 -0
  12. package/docs/SLO.md +62 -1
  13. package/docs/SUMMARY.md +1 -0
  14. package/docs/gitbook/README.md +13 -1
  15. package/docs/gitbook/quickstart.md +57 -58
  16. package/docs/integrations/README.md +1 -0
  17. package/docs/integrations/openclaw/PUBLIC_QUICKSTART.md +95 -0
  18. package/docs/ops/DISPUTE_FINANCE_RECONCILIATION_PACKET.md +56 -0
  19. package/docs/ops/KERNEL_V0_SHIP_GATE.md +3 -1
  20. package/docs/ops/MCP_COMPATIBILITY_MATRIX.md +8 -6
  21. package/docs/ops/PRODUCTION_DEPLOYMENT_CHECKLIST.md +46 -9
  22. package/docs/ops/TRUST_CONFIG_WIZARD.md +37 -24
  23. package/docs/plans/2026-02-20-trust-os-v1-jira-backlog.md +348 -0
  24. package/docs/plans/2026-02-21-agent-economic-actor-operating-model.md +169 -0
  25. package/docs/plans/2026-02-21-trust-os-v1-strategy.md +241 -0
  26. package/docs/research/2026-02-21-agent-spend-host-landscape.md +57 -0
  27. package/docs/spec/ArbitrationOutcomeMapping.v1.md +62 -0
  28. package/docs/spec/DisputeCaseLifecycle.v1.md +51 -0
  29. package/docs/spec/OperatorAction.v1.md +90 -0
  30. package/docs/spec/PolicyDecision.v1.md +83 -0
  31. package/docs/spec/README.md +5 -0
  32. package/docs/spec/SettlementDecisionRecord.v2.md +2 -0
  33. package/docs/spec/schemas/OperatorAction.v1.schema.json +113 -0
  34. package/docs/spec/schemas/PolicyDecision.v1.schema.json +74 -0
  35. package/docs/spec/schemas/SettlementDecisionRecord.v2.schema.json +1 -0
  36. package/docs/spec/x402-error-codes.v1.txt +14 -0
  37. package/package.json +14 -1
  38. package/scripts/ci/build-launch-cutover-packet.mjs +177 -21
  39. package/scripts/ci/run-10x-throughput-drill.mjs +76 -4
  40. package/scripts/ci/run-10x-throughput-incident-rehearsal.mjs +49 -6
  41. package/scripts/ci/run-mcp-host-cert-matrix.mjs +201 -0
  42. package/scripts/ci/run-mcp-host-smoke.mjs +203 -5
  43. package/scripts/ci/run-offline-verification-parity-gate.mjs +762 -0
  44. package/scripts/ci/run-onboarding-host-success-gate.mjs +516 -0
  45. package/scripts/ci/run-onboarding-policy-slo-gate.mjs +537 -0
  46. package/scripts/ci/run-production-cutover-gate.mjs +540 -0
  47. package/scripts/ci/run-public-openclaw-npx-smoke.mjs +148 -0
  48. package/scripts/ci/run-release-promotion-guard.mjs +756 -0
  49. package/scripts/doctor/mcp-host.mjs +120 -0
  50. package/scripts/mcp/settld-mcp-server.mjs +330 -20
  51. package/scripts/ops/dispute-finance-reconciliation-packet.mjs +313 -0
  52. package/scripts/ops/hosted-baseline-evidence.mjs +286 -77
  53. package/scripts/ops/run-x402-hitl-smoke.mjs +607 -0
  54. package/scripts/policy/cli.mjs +600 -0
  55. package/scripts/profile/cli.mjs +1324 -0
  56. package/scripts/register-entity-secret.mjs +102 -0
  57. package/scripts/setup/circle-bootstrap.mjs +310 -0
  58. package/scripts/setup/host-config.mjs +617 -0
  59. package/scripts/setup/onboard.mjs +1337 -0
  60. package/scripts/setup/openclaw-onboard.mjs +423 -0
  61. package/scripts/setup/wizard.mjs +986 -0
  62. package/scripts/slo/check.mjs +123 -62
  63. package/scripts/spec/generate-protocol-vectors.mjs +88 -0
  64. package/scripts/test/run.sh +23 -9
  65. package/services/x402-gateway/src/server.js +147 -36
  66. package/src/api/app.js +2345 -267
  67. package/src/api/middleware/trust-kernel.js +114 -0
  68. package/src/api/openapi.js +598 -3
  69. package/src/api/persistence.js +184 -0
  70. package/src/api/store.js +277 -0
  71. package/src/core/agent-wallets.js +134 -0
  72. package/src/core/event-policy.js +21 -2
  73. package/src/core/operator-action.js +303 -0
  74. package/src/core/policy-decision.js +322 -0
  75. package/src/core/policy-packs.js +207 -0
  76. package/src/core/profile-fingerprint.js +27 -0
  77. package/src/core/profile-simulation-reasons.js +84 -0
  78. package/src/core/profile-templates.js +242 -0
  79. package/src/core/settlement-kernel.js +27 -1
  80. package/src/core/wallet-assignment-resolver.js +129 -0
  81. package/src/core/wallet-provider-bootstrap.js +365 -0
  82. package/src/db/store-pg.js +631 -0
package/README.md CHANGED
@@ -67,6 +67,31 @@ The core mental model in this repo:
67
67
 
68
68
  ## Quick start
69
69
 
70
+ Agent host onboarding (Codex / Claude / Cursor / OpenClaw), with guided wallet + policy setup:
71
+
72
+ ```sh
73
+ npx -y settld setup
74
+ ```
75
+
76
+ Preflight-only check (no host config write), with JSON report:
77
+
78
+ ```sh
79
+ npx -y settld setup --preflight-only --report-path ./.tmp/setup-preflight.json
80
+ ```
81
+
82
+ If you prefer global install:
83
+
84
+ ```sh
85
+ npm install -g settld
86
+ settld setup
87
+ ```
88
+
89
+ Legacy setup wizard (advanced / old flags):
90
+
91
+ ```sh
92
+ settld setup legacy
93
+ ```
94
+
70
95
  Start the API:
71
96
 
72
97
  ```sh
@@ -157,6 +182,12 @@ Run conformance (kernel control plane, disputes + holdback):
157
182
  ./bin/settld.js conformance kernel --ops-token tok_ops
158
183
  ```
159
184
 
185
+ Run local MCP host compatibility checks:
186
+
187
+ ```sh
188
+ ./bin/settld.js doctor
189
+ ```
190
+
160
191
  No-clone registry flow:
161
192
 
162
193
  ```sh
@@ -194,6 +225,7 @@ Ops workspaces (HTML):
194
225
  - `docs/QUICKSTART_PRODUCE.md`
195
226
  - `docs/QUICKSTART_SDK.md`
196
227
  - `docs/QUICKSTART_SDK_PYTHON.md`
228
+ - `docs/QUICKSTART_POLICY_PACKS.md`
197
229
  - `docs/QUICKSTART_MCP.md`
198
230
  - `docs/QUICKSTART_MCP_HOSTS.md`
199
231
  - `docs/ADOPTION_CHECKLIST.md`
package/SETTLD_VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.2.0
package/bin/settld.js CHANGED
@@ -8,6 +8,12 @@ function usage() {
8
8
  // eslint-disable-next-line no-console
9
9
  console.error("usage:");
10
10
  console.error(" settld --version");
11
+ console.error(" settld onboard [--help]");
12
+ console.error(" settld setup [--help]");
13
+ console.error(" settld setup legacy [--help]");
14
+ console.error(" settld setup circle [--help]");
15
+ console.error(" settld setup openclaw [--help]");
16
+ console.error(" settld doctor [--help] [--report <path>]");
11
17
  console.error(" settld conformance test [--case <id>] [--bin settld-verify] [--node-bin <path/to/settld-verify.js>] [--keep-temp]");
12
18
  console.error(" settld conformance list");
13
19
  console.error(" settld conformance kernel --ops-token <tok_opsw> [--base-url http://127.0.0.1:3000] [--tenant-id tenant_default] [--protocol 1.0] [--case <id>]");
@@ -15,12 +21,34 @@ function usage() {
15
21
  console.error(" settld closepack export --agreement-hash <sha256> --out <path.zip> [--ops-token tok_ops] [--base-url http://127.0.0.1:3000] [--tenant-id tenant_default] [--protocol 1.0]");
16
22
  console.error(" settld closepack verify <path.zip> [--json-out <path.json>]");
17
23
  console.error(" settld x402 receipt verify <receipt.json|-> [--strict] [--format json|text] [--json-out <path>]");
24
+ console.error(" settld profile list [--format json|text] [--json-out <path>]");
25
+ console.error(" settld profile init <profile-id> [--out <path>] [--force] [--format json|text] [--json-out <path>]");
26
+ console.error(
27
+ " settld profile wizard [--template <profile-id>] [--non-interactive] [--profile-id <id>] [--name <text>] [--vertical <text>] [--description <text>] [--currency <code>] [--per-request-usd-cents <int>] [--monthly-usd-cents <int>] [--providers <csv>] [--tools <csv>] [--out <path>] [--force] [--format json|text] [--json-out <path>]"
28
+ );
29
+ console.error(" settld profile validate <profile.json|-> [--format json|text] [--json-out <path>]");
30
+ console.error(
31
+ " settld profile simulate <profile.json|-> [--scenario <scenario.json|->|--scenario-json <json>] [--format json|text] [--json-out <path>]"
32
+ );
33
+ console.error(" settld policy init <pack-id> [--out <path>] [--force] [--format json|text] [--json-out <path>]");
34
+ console.error(
35
+ " settld policy simulate <policy-pack.json|-> [--scenario <scenario.json|->|--scenario-json <json>] [--format json|text] [--json-out <path>]"
36
+ );
37
+ console.error(
38
+ " settld policy publish <policy-pack.json|-> [--out <path>] [--force] [--channel <name>] [--owner <id>] [--format json|text] [--json-out <path>]"
39
+ );
18
40
  console.error(" settld dev up [--no-build] [--foreground]");
19
41
  console.error(" settld dev down [--wipe]");
20
42
  console.error(" settld dev ps");
21
43
  console.error(" settld dev logs [--follow] [--service api]");
22
44
  console.error(" settld dev info");
23
45
  console.error(" settld init capability <name> [--out <dir>] [--force]");
46
+ console.error("");
47
+ console.error("onboarding:");
48
+ console.error(" settld onboard");
49
+ console.error(" settld setup");
50
+ console.error(" settld setup --help");
51
+ console.error(" settld dev up");
24
52
  }
25
53
 
26
54
  function repoRoot() {
@@ -92,6 +120,28 @@ function main() {
92
120
  process.exit(0);
93
121
  }
94
122
 
123
+ if (cmd === "setup") {
124
+ const setupSubcommand = String(argv[1] ?? "").trim();
125
+ if (setupSubcommand === "openclaw") {
126
+ return runNodeScript("scripts/setup/openclaw-onboard.mjs", argv.slice(2));
127
+ }
128
+ if (setupSubcommand === "circle") {
129
+ return runNodeScript("scripts/setup/circle-bootstrap.mjs", argv.slice(2));
130
+ }
131
+ if (setupSubcommand === "legacy") {
132
+ return runNodeScript("scripts/setup/wizard.mjs", argv.slice(2));
133
+ }
134
+ return runNodeScript("scripts/setup/onboard.mjs", argv.slice(1));
135
+ }
136
+
137
+ if (cmd === "onboard") {
138
+ return runNodeScript("scripts/setup/onboard.mjs", argv.slice(1));
139
+ }
140
+
141
+ if (cmd === "doctor") {
142
+ return runNodeScript("scripts/doctor/mcp-host.mjs", argv.slice(1));
143
+ }
144
+
95
145
  if (cmd === "conformance") {
96
146
  const sub = argv[1] ? String(argv[1]) : "test";
97
147
  if (sub === "test") return runNodeScript("conformance/v1/run.mjs", argv.slice(2));
@@ -216,6 +266,14 @@ function main() {
216
266
  process.exit(1);
217
267
  }
218
268
 
269
+ if (cmd === "profile") {
270
+ return runNodeScript("scripts/profile/cli.mjs", argv.slice(1));
271
+ }
272
+
273
+ if (cmd === "policy") {
274
+ return runNodeScript("scripts/policy/cli.mjs", argv.slice(1));
275
+ }
276
+
219
277
  usage();
220
278
  // eslint-disable-next-line no-console
221
279
  console.error(`unknown command: ${cmd}`);
@@ -34,6 +34,18 @@ Set these for sandbox runs:
34
34
  - `CIRCLE_WALLET_ID_ESCROW`
35
35
  - `CIRCLE_TOKEN_ID_USDC`
36
36
 
37
+ Fastest way to generate these from your Circle account:
38
+
39
+ ```bash
40
+ settld setup circle --api-key 'TEST_API_KEY:...' --mode auto --out-env ./.tmp/circle.env
41
+ ```
42
+
43
+ Then load them:
44
+
45
+ ```bash
46
+ set -a; source ./.tmp/circle.env; set +a
47
+ ```
48
+
37
49
  If your environment uses a different naming convention, map these into the adapter config before running tests.
38
50
 
39
51
  ## Suggested test flow
@@ -10,6 +10,22 @@ For host-specific setup (Claude, Cursor, Codex, OpenClaw), see `docs/QUICKSTART_
10
10
  - A Settld API key with appropriate scopes (`keyId.secret` format)
11
11
  - Settld API reachable (local `npm run dev:api` or hosted)
12
12
 
13
+ ## Fast Path (Recommended)
14
+
15
+ Run guided setup first:
16
+
17
+ ```bash
18
+ npx -y settld setup
19
+ ```
20
+
21
+ Then run a smoke probe:
22
+
23
+ ```bash
24
+ npm run mcp:probe
25
+ ```
26
+
27
+ If you prefer to wire everything manually, use the fallback steps in `Run The MCP Server` below.
28
+
13
29
  ## One-Command Local Demo (Paid MCP Exa Flow)
14
30
 
15
31
  Boots local API + provider wrapper + x402 gateway, runs MCP `settld.exa_search_paid`, verifies signatures/tokens, and writes an artifact bundle.
@@ -91,6 +107,23 @@ Artifact bundle includes:
91
107
  - `batch-worker-state.json` (when `SETTLD_DEMO_RUN_BATCH_SETTLEMENT=1`)
92
108
  - `batch-settlement.json` (when `SETTLD_DEMO_RUN_BATCH_SETTLEMENT=1`)
93
109
 
110
+ ## First verified receipt (keep this artifact)
111
+
112
+ The demo exports receipts to:
113
+
114
+ - `<artifactDir>/x402-receipts.export.jsonl`
115
+ - `<artifactDir>/x402-receipts.sample-verification.json`
116
+
117
+ Convert the first exported receipt row into a standalone JSON file and verify it:
118
+
119
+ ```bash
120
+ jq -c 'first' <artifactDir>/x402-receipts.export.jsonl > /tmp/settld-first-receipt.json
121
+ settld x402 receipt verify /tmp/settld-first-receipt.json --format json --json-out /tmp/settld-first-receipt.verify.json
122
+ ```
123
+
124
+ Keep `/tmp/settld-first-receipt.verify.json` (or check in an equivalent artifact path in CI). This is the deterministic
125
+ proof packet for the first paid action.
126
+
94
127
  ## Authority + Pinning Notes
95
128
 
96
129
  - Authority enforcement in this flow is API key scope + tenant-bound policy checks at Settld API/gateway surfaces.
@@ -107,7 +140,14 @@ Reference specs:
107
140
 
108
141
  ## Run The MCP Server
109
142
 
110
- Set environment variables:
143
+ Primary path:
144
+
145
+ ```bash
146
+ settld setup
147
+ npm run mcp:server
148
+ ```
149
+
150
+ Manual fallback (if you skip setup):
111
151
 
112
152
  ```bash
113
153
  export SETTLD_BASE_URL='https://api.settld.work' # or http://127.0.0.1:3000
@@ -1,143 +1,210 @@
1
- # Quickstart: MCP Host Integrations (Claude, Cursor, Codex, OpenClaw)
1
+ # Quickstart: MCP Host Integrations (Codex, Claude, Cursor, OpenClaw)
2
2
 
3
- Use this when you want to connect a real agent host to Settld MCP in under 5 minutes.
3
+ This guide is the fastest path to wire Settld into an agent host and confirm a first verified paid action.
4
4
 
5
- For core MCP flow details and paid-tool artifacts, see `docs/QUICKSTART_MCP.md`.
5
+ Target outcome:
6
6
 
7
- ## 0) Prerequisites
7
+ 1. Host can call `settld.*` MCP tools.
8
+ 2. Wallet mode is configured (`managed`, `byo`, or `none`).
9
+ 3. Policy profile is applied.
10
+ 4. Smoke call and first paid receipt are green.
8
11
 
12
+ For deeper tool-level examples, see `docs/QUICKSTART_MCP.md`.
13
+
14
+ ## 1) Before you run `settld setup`
15
+
16
+ Required inputs:
17
+
18
+ - `SETTLD_BASE_URL` (local or hosted API URL)
19
+ - `SETTLD_TENANT_ID`
20
+ - `SETTLD_API_KEY` (`keyId.secret`)
9
21
  - Node.js 20+
10
- - Settld API reachable (`http://127.0.0.1:3000` for local or your hosted API)
11
- - A tenant-scoped Settld API key (`keyId.secret` format)
12
22
 
13
- Export env once in your shell:
23
+ Recommended non-interactive pattern:
14
24
 
15
25
  ```bash
16
- export SETTLD_BASE_URL='http://127.0.0.1:3000'
17
- export SETTLD_TENANT_ID='tenant_default'
18
- export SETTLD_API_KEY='sk_live_xxx.yyy'
19
- export SETTLD_PAID_TOOLS_BASE_URL='http://127.0.0.1:8402'
26
+ settld setup --non-interactive \
27
+ --host openclaw \
28
+ --base-url https://api.settld.work \
29
+ --tenant-id tenant_default \
30
+ --settld-api-key 'sk_live_xxx.yyy' \
31
+ --wallet-mode managed \
32
+ --wallet-bootstrap remote \
33
+ --profile-id engineering-spend \
34
+ --smoke \
35
+ --out-env ./.tmp/settld-openclaw.env
20
36
  ```
21
37
 
22
- Sanity check the server before wiring any host:
38
+ If you want validation only (no config writes):
23
39
 
24
40
  ```bash
25
- npm run mcp:probe
41
+ settld setup --non-interactive \
42
+ --host openclaw \
43
+ --base-url https://api.settld.work \
44
+ --tenant-id tenant_default \
45
+ --settld-api-key 'sk_live_xxx.yyy' \
46
+ --wallet-mode none \
47
+ --preflight-only \
48
+ --report-path ./.tmp/setup-preflight.json \
49
+ --format json
26
50
  ```
27
51
 
28
- ## 1) Canonical MCP Server Definition
29
-
30
- Most hosts that support MCP stdio need a command, args, and env.
31
- Use this as your default server config:
32
-
33
- ```json
34
- {
35
- "name": "settld",
36
- "command": "npx",
37
- "args": ["-y", "settld-mcp"],
38
- "env": {
39
- "SETTLD_BASE_URL": "http://127.0.0.1:3000",
40
- "SETTLD_TENANT_ID": "tenant_default",
41
- "SETTLD_API_KEY": "sk_live_xxx.yyy",
42
- "SETTLD_PAID_TOOLS_BASE_URL": "http://127.0.0.1:8402"
43
- }
44
- }
52
+ ## 2) Host setup flows
53
+
54
+ Unified setup command:
55
+
56
+ ```bash
57
+ settld setup
45
58
  ```
46
59
 
47
- If your host cannot spawn stdio commands, use HTTP bridge:
60
+ The wizard handles:
61
+
62
+ - host selection (`codex|claude|cursor|openclaw`)
63
+ - wallet mode selection (`managed|byo|none`)
64
+ - preflight checks (API health, tenant auth, profile baseline, host config path)
65
+ - policy apply + optional smoke
66
+ - interactive menus with arrow keys (Up/Down + Enter) for choice steps
67
+
68
+ Host-specific non-interactive examples:
48
69
 
49
70
  ```bash
50
- MCP_HTTP_PORT=8787 npm run mcp:http
71
+ # Codex
72
+ settld setup --non-interactive --host codex --base-url http://127.0.0.1:3000 --tenant-id tenant_default --settld-api-key sk_live_xxx.yyy --wallet-mode none --profile-id engineering-spend --smoke
73
+
74
+ # Claude
75
+ settld setup --non-interactive --host claude --base-url http://127.0.0.1:3000 --tenant-id tenant_default --settld-api-key sk_live_xxx.yyy --wallet-mode none --profile-id engineering-spend --smoke
76
+
77
+ # Cursor
78
+ settld setup --non-interactive --host cursor --base-url http://127.0.0.1:3000 --tenant-id tenant_default --settld-api-key sk_live_xxx.yyy --wallet-mode none --profile-id engineering-spend --smoke
79
+
80
+ # OpenClaw
81
+ settld setup --non-interactive --host openclaw --base-url http://127.0.0.1:3000 --tenant-id tenant_default --settld-api-key sk_live_xxx.yyy --wallet-mode none --profile-id engineering-spend --smoke
51
82
  ```
52
83
 
53
- Then point the host at:
84
+ ## 3) Wallet modes: managed vs BYO
54
85
 
55
- - MCP endpoint: `http://127.0.0.1:8787/rpc`
56
- - Health endpoint: `http://127.0.0.1:8787/healthz`
86
+ ### Managed (`--wallet-mode managed`)
57
87
 
58
- ## 2) Claude
88
+ Managed is the default and recommended first path.
59
89
 
60
- 1. Open Claude MCP settings.
61
- 2. Add a new MCP server using the canonical config above.
62
- 3. Save and reconnect.
63
- 4. Ask Claude to call:
64
- - `settld.about`
65
- - `settld.exa_search_paid` with `{"query":"dentist near me chicago","numResults":3}`
90
+ `--wallet-bootstrap auto` behavior:
66
91
 
67
- Expected behavior:
92
+ - If `--circle-api-key` (or `CIRCLE_API_KEY`) is present: local Circle bootstrap.
93
+ - If not present: remote onboarding bootstrap (`/v1/tenants/{tenantId}/onboarding/wallet-bootstrap`).
68
94
 
69
- - First paid call triggers x402 challenge/authorize/retry automatically in the MCP wrapper.
70
- - Tool result includes Settld verification/settlement headers.
95
+ Force the path explicitly when needed:
71
96
 
72
- ## 3) Cursor
97
+ ```bash
98
+ # force remote wallet creation
99
+ settld setup --non-interactive --host openclaw --base-url https://api.settld.work --tenant-id tenant_default --settld-api-key 'sk_live_xxx.yyy' --wallet-mode managed --wallet-bootstrap remote --profile-id engineering-spend --smoke
73
100
 
74
- 1. Open Cursor MCP settings.
75
- 2. Add an MCP server using the same canonical stdio definition.
76
- 3. Reconnect tools.
77
- 4. Run:
78
- - `settld.about`
79
- - `settld.weather_current_paid` with `{"city":"Chicago","unit":"f"}`
101
+ # force local wallet creation with Circle credentials
102
+ settld setup --non-interactive --host openclaw --base-url https://api.settld.work --tenant-id tenant_default --settld-api-key 'sk_live_xxx.yyy' --wallet-mode managed --wallet-bootstrap local --circle-api-key 'TEST_API_KEY:...' --profile-id engineering-spend --smoke
103
+ ```
80
104
 
81
- Expected behavior:
105
+ ### BYO (`--wallet-mode byo`)
82
106
 
83
- - Paid tool returns response body plus `x-settld-*` headers captured by the tool bridge.
107
+ Provide your own existing wallet values. Required keys:
84
108
 
85
- ## 4) Codex
109
+ - `CIRCLE_BASE_URL`
110
+ - `CIRCLE_BLOCKCHAIN`
111
+ - `CIRCLE_WALLET_ID_SPEND`
112
+ - `CIRCLE_WALLET_ID_ESCROW`
113
+ - `CIRCLE_TOKEN_ID_USDC`
114
+ - `CIRCLE_ENTITY_SECRET_HEX`
86
115
 
87
- 1. Open Codex MCP/tooling configuration.
88
- 2. Register Settld with the canonical stdio definition.
89
- 3. Reload tool discovery.
90
- 4. Run:
91
- - `settld.about`
92
- - `settld.exa_search_paid`
116
+ Pass as env or repeated `--wallet-env KEY=VALUE` flags:
93
117
 
94
- Expected behavior:
118
+ ```bash
119
+ settld setup --non-interactive \
120
+ --host openclaw \
121
+ --base-url https://api.settld.work \
122
+ --tenant-id tenant_default \
123
+ --settld-api-key 'sk_live_xxx.yyy' \
124
+ --wallet-mode byo \
125
+ --wallet-env CIRCLE_BASE_URL=https://api-sandbox.circle.com \
126
+ --wallet-env CIRCLE_BLOCKCHAIN=BASE-SEPOLIA \
127
+ --wallet-env CIRCLE_WALLET_ID_SPEND=wid_spend \
128
+ --wallet-env CIRCLE_WALLET_ID_ESCROW=wid_escrow \
129
+ --wallet-env CIRCLE_TOKEN_ID_USDC=token_usdc \
130
+ --wallet-env CIRCLE_ENTITY_SECRET_HEX=$(openssl rand -hex 32) \
131
+ --profile-id engineering-spend \
132
+ --smoke
133
+ ```
95
134
 
96
- - Paid call resolves through the same x402 autopay flow.
135
+ ### None (`--wallet-mode none`)
97
136
 
98
- ## 5) OpenClaw
137
+ Use this for policy/tooling setup without payment rails yet.
99
138
 
100
- For OpenClaw, package Settld as a skill that declares MCP setup instructions.
101
- Reference skill payload:
139
+ ## 4) Activation after setup
102
140
 
103
- - `docs/integrations/openclaw/settld-mcp-skill/SKILL.md`
104
- - `docs/integrations/openclaw/settld-mcp-skill/mcp-server.example.json`
105
- - `docs/integrations/openclaw/CLAWHUB_PUBLISH_CHECKLIST.md`
141
+ `settld setup` writes host MCP config and prints `Combined exports`.
106
142
 
107
- Minimum skill payload should include:
143
+ If you used `--out-env`, source it before running tools:
108
144
 
109
- - Name/description
110
- - MCP server command (`npx -y settld-mcp`)
111
- - Required env vars (`SETTLD_BASE_URL`, `SETTLD_TENANT_ID`, `SETTLD_API_KEY`, optional `SETTLD_PAID_TOOLS_BASE_URL`)
112
- - A smoke prompt using `settld.about`
145
+ ```bash
146
+ source ./.tmp/settld-openclaw.env
147
+ ```
113
148
 
114
- You can test locally first with:
149
+ Then activate host-side:
150
+
151
+ - `codex`: restart Codex.
152
+ - `claude`: restart Claude Desktop.
153
+ - `cursor`: restart Cursor.
154
+ - `openclaw`: run `openclaw doctor`, ensure OpenClaw onboarding is complete (`openclaw onboard --install-daemon`), then run `openclaw tui`.
155
+
156
+ ## 5) How the agent uses Settld after activation
157
+
158
+ After host activation, the agent interacts with Settld through MCP `settld.*` tools.
159
+
160
+ Typical flow:
161
+
162
+ 1. Connectivity check: `settld.about`
163
+ 2. Paid action: `settld.exa_search_paid` or `settld.weather_current_paid`
164
+ 3. Policy gate + authorization happen server-side in Settld.
165
+ 4. Settld records evidence/decision/receipt artifacts.
166
+ 5. You can verify receipts offline (`settld x402 receipt verify`).
167
+
168
+ Quick local smoke:
115
169
 
116
170
  ```bash
117
171
  npm run mcp:probe -- --call settld.about '{}'
118
172
  ```
119
173
 
120
- ## 6) 5-Minute Validation Checklist
174
+ First paid run + artifacts:
175
+
176
+ ```bash
177
+ npm run demo:mcp-paid-exa
178
+ ```
179
+
180
+ Verify first receipt from artifacts:
181
+
182
+ ```bash
183
+ # replace <artifactDir> with the printed directory from demo output
184
+ settld x402 receipt verify <artifactDir>/x402-receipt.json --json-out /tmp/settld-first-receipt.json
185
+ ```
186
+
187
+ ## 6) Host config helper customization
188
+
189
+ Default host configuration logic is in:
190
+
191
+ - `scripts/setup/host-config.mjs`
121
192
 
122
- 0. (CI/local gate) run hosted-style smoke once:
193
+ If you need a custom resolver/writer, pass:
123
194
 
124
195
  ```bash
125
- npm run test:ci:mcp-host-smoke
196
+ settld setup --host-config ./path/to/custom-host-config.mjs
126
197
  ```
127
198
 
128
- 1. `npm run mcp:probe` passes locally.
129
- 2. Host discovers Settld tools (`tools/list` includes `settld.*`).
130
- 3. `settld.about` succeeds.
131
- 4. One paid tool call succeeds (`settld.exa_search_paid` or `settld.weather_current_paid`).
132
- 5. You can see a resulting artifact bundle from paid demo runs:
133
- - `artifacts/mcp-paid-exa/.../summary.json`
134
- - `artifacts/mcp-paid-weather/.../summary.json`
199
+ Your helper should provide resolver/setup exports compatible with `scripts/setup/wizard.mjs`.
135
200
 
136
201
  ## 7) Troubleshooting
137
202
 
203
+ - `BYO wallet mode missing required env keys`
204
+ - Provide all required Circle keys in section 3.
205
+ - `host config helper missing`
206
+ - Add `scripts/setup/host-config.mjs` or pass `--host-config`.
138
207
  - `SETTLD_API_KEY must be a non-empty string`
139
- - API key not injected into MCP server env.
208
+ - Ensure key is present in shell or setup flags.
140
209
  - Host cannot run `npx`
141
- - Install Node 20+ and ensure `npx` is on PATH, or run HTTP bridge mode.
142
- - Paid tool returns gateway/connectivity errors
143
- - Confirm `SETTLD_PAID_TOOLS_BASE_URL` points to a running gateway.
210
+ - Install Node.js 20+ and ensure `npx` is in `PATH`.
@@ -0,0 +1,65 @@
1
+ # Quickstart: Policy Packs CLI (v1)
2
+
3
+ Goal: initialize, simulate, and publish deterministic local policy pack artifacts with `settld policy`.
4
+
5
+ ## Starter policy packs
6
+
7
+ - `engineering-spend`
8
+ - `procurement-enterprise`
9
+ - `data-api-buyer`
10
+ - `support-automation`
11
+ - `finance-controls`
12
+
13
+ ## 1) Initialize a starter pack
14
+
15
+ Installed CLI:
16
+
17
+ ```bash
18
+ npx settld policy init engineering-spend --out ./policies/engineering.policy-pack.json
19
+ ```
20
+
21
+ Repo checkout:
22
+
23
+ ```bash
24
+ ./bin/settld.js policy init engineering-spend --out ./policies/engineering.policy-pack.json
25
+ ```
26
+
27
+ ## 2) Simulate a decision
28
+
29
+ Default scenario (first allowlisted provider/tool, zero spend):
30
+
31
+ ```bash
32
+ ./bin/settld.js policy simulate ./policies/engineering.policy-pack.json --format json
33
+ ```
34
+
35
+ Explicit scenario:
36
+
37
+ ```bash
38
+ ./bin/settld.js policy simulate ./policies/engineering.policy-pack.json \
39
+ --scenario-json '{"providerId":"openai","toolId":"llm.inference","amountUsdCents":25000,"monthToDateSpendUsdCents":100000,"approvalsProvided":1,"receiptSigned":true,"toolManifestHashPresent":true,"toolVersionKnown":true}' \
40
+ --format json
41
+ ```
42
+
43
+ ## 3) Publish locally (deterministic report artifact)
44
+
45
+ ```bash
46
+ ./bin/settld.js policy publish ./policies/engineering.policy-pack.json --format json
47
+ ```
48
+
49
+ `publish` has no remote dependency. It writes a local `SettldPolicyPublication.v1` artifact and returns a `SettldPolicyPublishReport.v1` with:
50
+
51
+ - deterministic `policyFingerprint` (canonical JSON SHA-256)
52
+ - deterministic `publicationRef` (`<channel>:<packId>:<fingerprint-prefix>`)
53
+ - `artifactPath` + `artifactSha256`
54
+
55
+ ## Output modes
56
+
57
+ All commands support:
58
+
59
+ - `--format text|json` (default `text`)
60
+ - `--json-out <path>` for machine output files
61
+
62
+ `init` and `publish` also support:
63
+
64
+ - `--out <path>`
65
+ - `--force` to overwrite an existing path