@paybond/kit 0.9.8 → 0.11.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.
- package/completion-presets/catalog.json +1187 -0
- package/completion-presets/catalog.sha256 +1 -0
- package/dev/trace-ui/dashboard.html +617 -0
- package/dist/agent/adapter.d.ts +51 -0
- package/dist/agent/adapter.js +66 -0
- package/dist/agent/attach-bundle.d.ts +37 -0
- package/dist/agent/attach-bundle.js +118 -0
- package/dist/agent/authorization-cache.d.ts +22 -0
- package/dist/agent/authorization-cache.js +36 -0
- package/dist/agent/deferred-tools.d.ts +11 -0
- package/dist/agent/deferred-tools.js +62 -0
- package/dist/agent/discover.d.ts +41 -0
- package/dist/agent/discover.js +147 -0
- package/dist/agent/evidence.d.ts +9 -0
- package/dist/agent/evidence.js +28 -0
- package/dist/agent/facade.d.ts +48 -0
- package/dist/agent/facade.js +112 -0
- package/dist/agent/gateway-trace-reporter.d.ts +28 -0
- package/dist/agent/gateway-trace-reporter.js +49 -0
- package/dist/agent/generic-runner.d.ts +14 -0
- package/dist/agent/generic-runner.js +49 -0
- package/dist/agent/generic-sandbox-demo.d.ts +36 -0
- package/dist/agent/generic-sandbox-demo.js +82 -0
- package/dist/agent/guarded-agent.d.ts +49 -0
- package/dist/agent/guarded-agent.js +100 -0
- package/dist/agent/index.d.ts +13 -0
- package/dist/agent/index.js +13 -0
- package/dist/agent/instrument.d.ts +156 -0
- package/dist/agent/instrument.js +442 -0
- package/dist/agent/interceptor.d.ts +24 -0
- package/dist/agent/interceptor.js +440 -0
- package/dist/agent/lazy-context-tools.d.ts +15 -0
- package/dist/agent/lazy-context-tools.js +81 -0
- package/dist/agent/registry-file.d.ts +39 -0
- package/dist/agent/registry-file.js +219 -0
- package/dist/agent/registry.d.ts +37 -0
- package/dist/agent/registry.js +128 -0
- package/dist/agent/run.d.ts +124 -0
- package/dist/agent/run.js +301 -0
- package/dist/agent/types.d.ts +318 -0
- package/dist/agent/types.js +42 -0
- package/dist/agent-recognition.d.ts +72 -0
- package/dist/agent-recognition.js +165 -0
- package/dist/bincode-wire.d.ts +18 -0
- package/dist/bincode-wire.js +93 -0
- package/dist/claude-agents/config.d.ts +21 -0
- package/dist/claude-agents/config.js +145 -0
- package/dist/claude-agents/index.d.ts +2 -0
- package/dist/claude-agents/index.js +2 -0
- package/dist/claude-agents/sandbox-demo.d.ts +30 -0
- package/dist/claude-agents/sandbox-demo.js +91 -0
- package/dist/cli/agent/env-quote.d.ts +1 -0
- package/dist/cli/agent/env-quote.js +6 -0
- package/dist/cli/agent/env-write.d.ts +8 -0
- package/dist/cli/agent/env-write.js +47 -0
- package/dist/cli/agent/paybond.d.ts +16 -0
- package/dist/cli/agent/paybond.js +55 -0
- package/dist/cli/agent/policy-file.d.ts +29 -0
- package/dist/cli/agent/policy-file.js +61 -0
- package/dist/cli/agent/production-evidence.d.ts +24 -0
- package/dist/cli/agent/production-evidence.js +98 -0
- package/dist/cli/agent/run-store.d.ts +30 -0
- package/dist/cli/agent/run-store.js +42 -0
- package/dist/cli/agent/run-trace-store.d.ts +39 -0
- package/dist/cli/agent/run-trace-store.js +143 -0
- package/dist/cli/agent-run-trace-table.d.ts +9 -0
- package/dist/cli/agent-run-trace-table.js +24 -0
- package/dist/cli/agent-sandbox-smoke-checklist.d.ts +9 -0
- package/dist/cli/agent-sandbox-smoke-checklist.js +50 -0
- package/dist/cli/audit-export.d.ts +7 -0
- package/dist/cli/audit-export.js +120 -0
- package/dist/cli/automation.d.ts +25 -0
- package/dist/cli/automation.js +297 -0
- package/dist/cli/body.d.ts +7 -0
- package/dist/cli/body.js +22 -0
- package/dist/cli/color.d.ts +15 -0
- package/dist/cli/color.js +39 -0
- package/dist/cli/command-spec.d.ts +13 -0
- package/dist/cli/command-spec.js +611 -0
- package/dist/cli/commands/agent.d.ts +16 -0
- package/dist/cli/commands/agent.js +1135 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.js +348 -0
- package/dist/cli/commands/discovery.d.ts +8 -0
- package/dist/cli/commands/discovery.js +194 -0
- package/dist/cli/commands/policy.d.ts +13 -0
- package/dist/cli/commands/policy.js +769 -0
- package/dist/cli/commands/setup.d.ts +18 -0
- package/dist/cli/commands/setup.js +513 -0
- package/dist/cli/commands/workflows.d.ts +7 -0
- package/dist/cli/commands/workflows.js +214 -0
- package/dist/cli/config.d.ts +16 -0
- package/dist/cli/config.js +98 -0
- package/dist/cli/context.d.ts +22 -0
- package/dist/cli/context.js +110 -0
- package/dist/cli/credentials.d.ts +21 -0
- package/dist/cli/credentials.js +141 -0
- package/dist/cli/doctor-agent-middleware.d.ts +5 -0
- package/dist/cli/doctor-agent-middleware.js +49 -0
- package/dist/cli/doctor-agent.d.ts +15 -0
- package/dist/cli/doctor-agent.js +311 -0
- package/dist/cli/envelope.d.ts +14 -0
- package/dist/cli/envelope.js +46 -0
- package/dist/cli/globals.d.ts +23 -0
- package/dist/cli/globals.js +248 -0
- package/dist/cli/help.d.ts +3 -0
- package/dist/cli/help.js +83 -0
- package/dist/cli/mcp-install.d.ts +41 -0
- package/dist/cli/mcp-install.js +95 -0
- package/dist/cli/mcp-policy.d.ts +26 -0
- package/dist/cli/mcp-policy.js +110 -0
- package/dist/cli/mcp-verify-config.d.ts +37 -0
- package/dist/cli/mcp-verify-config.js +172 -0
- package/dist/cli/redact.d.ts +4 -0
- package/dist/cli/redact.js +88 -0
- package/dist/cli/request-id.d.ts +2 -0
- package/dist/cli/request-id.js +5 -0
- package/dist/cli/router.d.ts +2 -0
- package/dist/cli/router.js +378 -0
- package/dist/cli/smoke-deep-links.d.ts +15 -0
- package/dist/cli/smoke-deep-links.js +63 -0
- package/dist/cli/suggest.d.ts +4 -0
- package/dist/cli/suggest.js +58 -0
- package/dist/cli/support-diagnostics.d.ts +19 -0
- package/dist/cli/support-diagnostics.js +47 -0
- package/dist/cli/telemetry.d.ts +17 -0
- package/dist/cli/telemetry.js +94 -0
- package/dist/cli/types.d.ts +72 -0
- package/dist/cli/types.js +60 -0
- package/dist/cli/ux.d.ts +8 -0
- package/dist/cli/ux.js +164 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +38 -0
- package/dist/completion-catalog-digest.d.ts +2 -0
- package/dist/completion-catalog-digest.js +2 -0
- package/dist/completion-catalog-integrity.d.ts +2 -0
- package/dist/completion-catalog-integrity.js +17 -0
- package/dist/completion-catalog.d.ts +49 -0
- package/dist/completion-catalog.js +62 -0
- package/dist/completion-contract-digest.d.ts +37 -0
- package/dist/completion-contract-digest.js +73 -0
- package/dist/completion-forbidden-fields.d.ts +5 -0
- package/dist/completion-forbidden-fields.js +26 -0
- package/dist/completion-init.d.ts +8 -0
- package/dist/completion-init.js +334 -0
- package/dist/completion-resolve.d.ts +21 -0
- package/dist/completion-resolve.js +86 -0
- package/dist/completion-validate-evidence.d.ts +24 -0
- package/dist/completion-validate-evidence.js +145 -0
- package/dist/dev/offline-gateway.d.ts +24 -0
- package/dist/dev/offline-gateway.js +102 -0
- package/dist/dev/trace-buffer.d.ts +61 -0
- package/dist/dev/trace-buffer.js +330 -0
- package/dist/dev/trace-security-headers.d.ts +11 -0
- package/dist/dev/trace-security-headers.js +16 -0
- package/dist/dev/trace-server.d.ts +8 -0
- package/dist/dev/trace-server.js +38 -0
- package/dist/dev/trace-ui.d.ts +4 -0
- package/dist/dev/trace-ui.js +25 -0
- package/dist/dev/wiremock-up.d.ts +15 -0
- package/dist/dev/wiremock-up.js +118 -0
- package/dist/doctor-completion.d.ts +17 -0
- package/dist/doctor-completion.js +428 -0
- package/dist/gateway-url.d.ts +7 -0
- package/dist/gateway-url.js +69 -0
- package/dist/index.d.ts +119 -2
- package/dist/index.js +267 -6
- package/dist/init.js +380 -68
- package/dist/langgraph/awrap-tool-call.d.ts +25 -0
- package/dist/langgraph/awrap-tool-call.js +81 -0
- package/dist/langgraph/config.d.ts +13 -0
- package/dist/langgraph/config.js +11 -0
- package/dist/langgraph/index.d.ts +4 -0
- package/dist/langgraph/index.js +4 -0
- package/dist/langgraph/sandbox-demo.d.ts +40 -0
- package/dist/langgraph/sandbox-demo.js +96 -0
- package/dist/langgraph/tool-node.d.ts +10 -0
- package/dist/langgraph/tool-node.js +38 -0
- package/dist/login.d.ts +14 -1
- package/dist/login.js +130 -63
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/tool-surface.d.ts +25 -0
- package/dist/mcp/tool-surface.js +17 -0
- package/dist/mcp-capability-token-cache.d.ts +24 -0
- package/dist/mcp-capability-token-cache.js +101 -0
- package/dist/mcp-evidence-policy.d.ts +48 -0
- package/dist/mcp-evidence-policy.js +117 -0
- package/dist/mcp-policy-reload.d.ts +79 -0
- package/dist/mcp-policy-reload.js +200 -0
- package/dist/mcp-sep2828-evidence.d.ts +36 -0
- package/dist/mcp-sep2828-evidence.js +65 -0
- package/dist/mcp-server.d.ts +10 -0
- package/dist/mcp-server.js +423 -115
- package/dist/openai-agents/index.d.ts +40 -0
- package/dist/openai-agents/index.js +151 -0
- package/dist/openai-agents/sandbox-demo.d.ts +34 -0
- package/dist/openai-agents/sandbox-demo.js +118 -0
- package/dist/payee-evidence.js +2 -29
- package/dist/policy/catalog.d.ts +31 -0
- package/dist/policy/catalog.js +48 -0
- package/dist/policy/compose-utils.d.ts +3 -0
- package/dist/policy/compose-utils.js +4 -0
- package/dist/policy/compose.d.ts +20 -0
- package/dist/policy/compose.js +240 -0
- package/dist/policy/digest.d.ts +7 -0
- package/dist/policy/digest.js +75 -0
- package/dist/policy/domain.d.ts +15 -0
- package/dist/policy/domain.js +28 -0
- package/dist/policy/guardrail-spec.d.ts +17 -0
- package/dist/policy/guardrail-spec.js +140 -0
- package/dist/policy/guardrails.d.ts +48 -0
- package/dist/policy/guardrails.js +72 -0
- package/dist/policy/index.d.ts +21 -0
- package/dist/policy/index.js +21 -0
- package/dist/policy/init.d.ts +102 -0
- package/dist/policy/init.js +351 -0
- package/dist/policy/intent-spec.d.ts +52 -0
- package/dist/policy/intent-spec.js +176 -0
- package/dist/policy/json-path.d.ts +4 -0
- package/dist/policy/json-path.js +23 -0
- package/dist/policy/layers-io.d.ts +7 -0
- package/dist/policy/layers-io.js +28 -0
- package/dist/policy/load-effective.d.ts +22 -0
- package/dist/policy/load-effective.js +77 -0
- package/dist/policy/load.d.ts +85 -0
- package/dist/policy/load.js +164 -0
- package/dist/policy/merge.d.ts +29 -0
- package/dist/policy/merge.js +297 -0
- package/dist/policy/parse-text.d.ts +2 -0
- package/dist/policy/parse-text.js +126 -0
- package/dist/policy/policy-api.d.ts +45 -0
- package/dist/policy/policy-api.js +61 -0
- package/dist/policy/presets.d.ts +19 -0
- package/dist/policy/presets.js +66 -0
- package/dist/policy/registry.d.ts +7 -0
- package/dist/policy/registry.js +33 -0
- package/dist/policy/reload.d.ts +86 -0
- package/dist/policy/reload.js +233 -0
- package/dist/policy/render-yaml.d.ts +3 -0
- package/dist/policy/render-yaml.js +69 -0
- package/dist/policy/sandbox-bootstrap.d.ts +19 -0
- package/dist/policy/sandbox-bootstrap.js +66 -0
- package/dist/policy/schema.d.ts +204 -0
- package/dist/policy/schema.js +255 -0
- package/dist/policy/snapshot.d.ts +33 -0
- package/dist/policy/snapshot.js +23 -0
- package/dist/policy/validate-remote.d.ts +43 -0
- package/dist/policy/validate-remote.js +104 -0
- package/dist/policy/validate.d.ts +36 -0
- package/dist/policy/validate.js +150 -0
- package/dist/policy/watcher.d.ts +29 -0
- package/dist/policy/watcher.js +112 -0
- package/dist/principal-intent.d.ts +52 -0
- package/dist/principal-intent.js +193 -37
- package/dist/project-init.d.ts +34 -0
- package/dist/project-init.js +898 -0
- package/dist/sep2828-signature.d.ts +10 -0
- package/dist/sep2828-signature.js +134 -0
- package/dist/solutions/api.d.ts +22 -0
- package/dist/solutions/api.js +40 -0
- package/dist/solutions/catalog.d.ts +34 -0
- package/dist/solutions/catalog.js +129 -0
- package/dist/solutions/index.d.ts +2 -0
- package/dist/solutions/index.js +2 -0
- package/dist/template-init.d.ts +54 -0
- package/dist/template-init.js +203 -0
- package/dist/vercel-ai/config.d.ts +15 -0
- package/dist/vercel-ai/config.js +13 -0
- package/dist/vercel-ai/index.d.ts +4 -0
- package/dist/vercel-ai/index.js +4 -0
- package/dist/vercel-ai/sandbox-demo.d.ts +44 -0
- package/dist/vercel-ai/sandbox-demo.js +153 -0
- package/dist/vercel-ai/tool-approval.d.ts +16 -0
- package/dist/vercel-ai/tool-approval.js +41 -0
- package/dist/vercel-ai/wrap-tools.d.ts +9 -0
- package/dist/vercel-ai/wrap-tools.js +40 -0
- package/dist/x402-receipt-evidence.d.ts +29 -0
- package/dist/x402-receipt-evidence.js +97 -0
- package/dist/x402-receipt-signature.d.ts +12 -0
- package/dist/x402-receipt-signature.js +211 -0
- package/package.json +79 -4
- package/solutions/aws.json +17 -0
- package/solutions/saas.json +17 -0
- package/solutions/shopping.json +17 -0
- package/solutions/travel.json +18 -0
- package/templates/manifest.json +169 -0
- package/templates/openai-shopping-agent/.env.example +3 -0
- package/templates/openai-shopping-agent/.github/workflows/smoke.yml +20 -0
- package/templates/openai-shopping-agent/LICENSE +201 -0
- package/templates/openai-shopping-agent/README.md +29 -0
- package/templates/openai-shopping-agent/package.json +22 -0
- package/templates/openai-shopping-agent/paybond.policy.yaml +22 -0
- package/templates/openai-shopping-agent/src/index.ts +22 -0
- package/templates/openai-shopping-agent/src/paybond.config.ts +51 -0
- package/templates/openai-shopping-agent/tsconfig.json +13 -0
- package/templates/paybond-aws-operator/.env.example +3 -0
- package/templates/paybond-aws-operator/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-aws-operator/LICENSE +201 -0
- package/templates/paybond-aws-operator/README.md +29 -0
- package/templates/paybond-aws-operator/package.json +20 -0
- package/templates/paybond-aws-operator/paybond.policy.yaml +22 -0
- package/templates/paybond-aws-operator/src/index.ts +54 -0
- package/templates/paybond-aws-operator/src/paybond.config.ts +51 -0
- package/templates/paybond-aws-operator/tsconfig.json +13 -0
- package/templates/paybond-claude-agents-demo/.env.example +3 -0
- package/templates/paybond-claude-agents-demo/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-claude-agents-demo/LICENSE +201 -0
- package/templates/paybond-claude-agents-demo/README.md +29 -0
- package/templates/paybond-claude-agents-demo/package.json +22 -0
- package/templates/paybond-claude-agents-demo/paybond.policy.yaml +22 -0
- package/templates/paybond-claude-agents-demo/src/index.ts +22 -0
- package/templates/paybond-claude-agents-demo/src/paybond.config.ts +51 -0
- package/templates/paybond-claude-agents-demo/tsconfig.json +13 -0
- package/templates/paybond-invoice-agent/.env.example +3 -0
- package/templates/paybond-invoice-agent/.github/workflows/smoke.yml +19 -0
- package/templates/paybond-invoice-agent/LICENSE +201 -0
- package/templates/paybond-invoice-agent/README.md +29 -0
- package/templates/paybond-invoice-agent/app.py +27 -0
- package/templates/paybond-invoice-agent/package.json +6 -0
- package/templates/paybond-invoice-agent/paybond.policy.yaml +22 -0
- package/templates/paybond-invoice-agent/paybond_config.py +45 -0
- package/templates/paybond-invoice-agent/requirements.txt +2 -0
- package/templates/paybond-mcp-coding-agent/.env.example +3 -0
- package/templates/paybond-mcp-coding-agent/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-mcp-coding-agent/LICENSE +201 -0
- package/templates/paybond-mcp-coding-agent/README.md +39 -0
- package/templates/paybond-mcp-coding-agent/package.json +20 -0
- package/templates/paybond-mcp-coding-agent/paybond.policy.yaml +25 -0
- package/templates/paybond-mcp-coding-agent/src/index.ts +40 -0
- package/templates/paybond-mcp-coding-agent/src/paybond.config.ts +51 -0
- package/templates/paybond-mcp-coding-agent/tsconfig.json +13 -0
- package/templates/paybond-openai-agents-demo/.env.example +3 -0
- package/templates/paybond-openai-agents-demo/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-openai-agents-demo/LICENSE +201 -0
- package/templates/paybond-openai-agents-demo/README.md +29 -0
- package/templates/paybond-openai-agents-demo/package.json +22 -0
- package/templates/paybond-openai-agents-demo/paybond.policy.yaml +22 -0
- package/templates/paybond-openai-agents-demo/src/index.ts +22 -0
- package/templates/paybond-openai-agents-demo/src/paybond.config.ts +51 -0
- package/templates/paybond-openai-agents-demo/tsconfig.json +13 -0
- package/templates/paybond-procurement-agent/.env.example +3 -0
- package/templates/paybond-procurement-agent/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-procurement-agent/LICENSE +201 -0
- package/templates/paybond-procurement-agent/README.md +29 -0
- package/templates/paybond-procurement-agent/package.json +20 -0
- package/templates/paybond-procurement-agent/paybond.policy.yaml +25 -0
- package/templates/paybond-procurement-agent/src/index.ts +54 -0
- package/templates/paybond-procurement-agent/src/paybond.config.ts +51 -0
- package/templates/paybond-procurement-agent/tsconfig.json +13 -0
- package/templates/paybond-travel-agent/.env.example +3 -0
- package/templates/paybond-travel-agent/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-travel-agent/LICENSE +201 -0
- package/templates/paybond-travel-agent/README.md +29 -0
- package/templates/paybond-travel-agent/package.json +23 -0
- package/templates/paybond-travel-agent/paybond.policy.yaml +22 -0
- package/templates/paybond-travel-agent/src/index.ts +22 -0
- package/templates/paybond-travel-agent/src/paybond.config.ts +51 -0
- package/templates/paybond-travel-agent/tsconfig.json +13 -0
- package/templates/paybond-vercel-shopping-agent/.env.example +3 -0
- package/templates/paybond-vercel-shopping-agent/.github/workflows/smoke.yml +20 -0
- package/templates/paybond-vercel-shopping-agent/LICENSE +201 -0
- package/templates/paybond-vercel-shopping-agent/README.md +29 -0
- package/templates/paybond-vercel-shopping-agent/package.json +22 -0
- package/templates/paybond-vercel-shopping-agent/paybond.policy.yaml +22 -0
- package/templates/paybond-vercel-shopping-agent/src/index.ts +22 -0
- package/templates/paybond-vercel-shopping-agent/src/paybond.config.ts +51 -0
- package/templates/paybond-vercel-shopping-agent/tsconfig.json +13 -0
package/dist/principal-intent.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Matches `crates/harbor-intent-escrow/src/signing.rs` (`intent_creation_sign_bytes_raw`).
|
|
4
4
|
*/
|
|
5
5
|
import { sign, getPublicKey } from "@noble/ed25519";
|
|
6
|
-
import { parse as parseUuid } from "uuid";
|
|
7
6
|
import { ensureEd25519Sha512Sync } from "./ed25519-sync.js";
|
|
8
7
|
import { jsonValueDigest } from "./json-digest.js";
|
|
8
|
+
import { COMPLETION_CONTRACT_SIGN_VERSION, concatBytes, encodeBincodeString, encodeBincodeUuid, encodeFixed32, encodeU8, encodeVarintI64, encodeVarintU32, } from "./bincode-wire.js";
|
|
9
9
|
const SETTLEMENT_RAIL_VALUES = new Set(["stripe_connect", "stripe_ach_debit", "x402_usdc_base"]);
|
|
10
10
|
function validateSettlementRail(value) {
|
|
11
11
|
if (!SETTLEMENT_RAIL_VALUES.has(value)) {
|
|
@@ -13,33 +13,6 @@ function validateSettlementRail(value) {
|
|
|
13
13
|
}
|
|
14
14
|
return value;
|
|
15
15
|
}
|
|
16
|
-
function concatBytes(...parts) {
|
|
17
|
-
const n = parts.reduce((a, p) => a + p.length, 0);
|
|
18
|
-
const out = new Uint8Array(n);
|
|
19
|
-
let o = 0;
|
|
20
|
-
for (const p of parts) {
|
|
21
|
-
out.set(p, o);
|
|
22
|
-
o += p.length;
|
|
23
|
-
}
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
function encodeU64(n) {
|
|
27
|
-
if (!Number.isInteger(n) || n < 0) {
|
|
28
|
-
throw new Error("encodeU64: expected non-negative integer");
|
|
29
|
-
}
|
|
30
|
-
const b = new Uint8Array(8);
|
|
31
|
-
new DataView(b.buffer).setBigUint64(0, BigInt(n), true);
|
|
32
|
-
return b;
|
|
33
|
-
}
|
|
34
|
-
function encodeI64(n) {
|
|
35
|
-
const b = new Uint8Array(8);
|
|
36
|
-
new DataView(b.buffer).setBigInt64(0, BigInt(n), true);
|
|
37
|
-
return b;
|
|
38
|
-
}
|
|
39
|
-
function encodeBincodeString(s) {
|
|
40
|
-
const utf8 = new TextEncoder().encode(s);
|
|
41
|
-
return concatBytes(encodeU64(utf8.length), utf8);
|
|
42
|
-
}
|
|
43
16
|
function dslDigest(predicate) {
|
|
44
17
|
return jsonValueDigest(predicate);
|
|
45
18
|
}
|
|
@@ -50,22 +23,75 @@ function allowedToolsDigest(tools) {
|
|
|
50
23
|
.filter((v, i, a) => a.indexOf(v) === i);
|
|
51
24
|
return jsonValueDigest(sorted);
|
|
52
25
|
}
|
|
53
|
-
|
|
26
|
+
function encodeU32(n) {
|
|
27
|
+
return encodeVarintU32(n);
|
|
28
|
+
}
|
|
29
|
+
function encodeBincodeFixed32(bytes) {
|
|
30
|
+
return encodeFixed32(bytes);
|
|
31
|
+
}
|
|
32
|
+
/** Bincode payload for optional completion contract tail (wire format revision byte `2`). */
|
|
33
|
+
function encodeCompletionContractSignV1(input) {
|
|
34
|
+
return concatBytes(encodeU8(COMPLETION_CONTRACT_SIGN_VERSION), encodeBincodeString(input.completionPresetId), encodeBincodeString(input.vendorContractProvider), encodeBincodeString(input.vendorApiVersion), encodeBincodeFixed32(input.vendorSchemaDigest), encodeBincodeFixed32(input.canonicalSchemaDigest));
|
|
35
|
+
}
|
|
36
|
+
function digestHexToBytes(hexValue) {
|
|
37
|
+
if (!hexValue || hexValue.trim() === "") {
|
|
38
|
+
return new Uint8Array(32);
|
|
39
|
+
}
|
|
40
|
+
const trimmed = hexValue.trim().toLowerCase().replace(/^0x/, "");
|
|
41
|
+
if (!/^[0-9a-f]{64}$/.test(trimmed)) {
|
|
42
|
+
throw new Error("digest hex must be a 64-character hex string");
|
|
43
|
+
}
|
|
44
|
+
const out = new Uint8Array(32);
|
|
45
|
+
for (let i = 0; i < 32; i += 1) {
|
|
46
|
+
out[i] = Number.parseInt(trimmed.slice(i * 2, i * 2 + 2), 16);
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
function appendCompletionContractSignExtension(base, snapshot) {
|
|
51
|
+
const extension = encodeCompletionContractSignV1({
|
|
52
|
+
completionPresetId: snapshot.completionPresetId,
|
|
53
|
+
vendorContractProvider: snapshot.vendorContractProvider ?? "",
|
|
54
|
+
vendorApiVersion: snapshot.vendorApiVersion ?? "",
|
|
55
|
+
vendorSchemaDigest: digestHexToBytes(snapshot.vendorSchemaDigestHex),
|
|
56
|
+
canonicalSchemaDigest: digestHexToBytes(snapshot.canonicalSchemaDigestHex),
|
|
57
|
+
});
|
|
58
|
+
return concatBytes(base, extension);
|
|
59
|
+
}
|
|
54
60
|
function encodeIntentCreationSign(input) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
const base = concatBytes(encodeU8(input.version), encodeBincodeString(input.tenantId), encodeBincodeUuid(input.intentId), encodeBincodeString(input.principalDid), encodeBincodeString(input.payeeDid), encodeVarintI64(input.amountCents), encodeBincodeString(input.currency), encodeBincodeString(input.deadlineRfc3339), input.budgetDigest, input.evidenceSchemaDigest, input.predicateDslDigest, encodeBincodeString(input.predicateRef), input.allowedToolsDigest, encodeBincodeString(input.settlementRail));
|
|
62
|
+
if (input.version === 4) {
|
|
63
|
+
return base;
|
|
64
|
+
}
|
|
65
|
+
if (input.version === 6) {
|
|
66
|
+
if (input.payeePubkey === undefined) {
|
|
67
|
+
throw new Error("payeePubkey is required for signing version 6");
|
|
68
|
+
}
|
|
69
|
+
return concatBytes(base, encodeBincodeFixed32(input.payeePubkey));
|
|
70
|
+
}
|
|
71
|
+
if (input.policyTemplateId === undefined ||
|
|
72
|
+
input.policyVersionSeq === undefined ||
|
|
73
|
+
input.policyContentDigest === undefined) {
|
|
74
|
+
throw new Error("policy binding fields are required for signing version 5 or 7");
|
|
59
75
|
}
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
const withPolicy = concatBytes(base, encodeBincodeString(input.policyTemplateId), encodeU32(input.policyVersionSeq), encodeBincodeFixed32(input.policyContentDigest));
|
|
77
|
+
if (input.version === 5) {
|
|
78
|
+
return withPolicy;
|
|
79
|
+
}
|
|
80
|
+
if (input.payeePubkey === undefined) {
|
|
81
|
+
throw new Error("payeePubkey is required for signing version 7");
|
|
82
|
+
}
|
|
83
|
+
return concatBytes(withPolicy, encodeBincodeFixed32(input.payeePubkey));
|
|
62
84
|
}
|
|
63
85
|
export function intentCreationSignBytesRaw(input) {
|
|
86
|
+
if (input.payeePubkeyBytes.length !== 32) {
|
|
87
|
+
throw new Error("payeePubkeyBytes must be 32 bytes");
|
|
88
|
+
}
|
|
64
89
|
const budgetDigest = jsonValueDigest(input.budget);
|
|
65
90
|
const evidenceSchemaDigest = jsonValueDigest(input.evidenceSchema);
|
|
66
91
|
const predicateDslDigest = dslDigest(input.predicate);
|
|
67
92
|
const allowedDigest = allowedToolsDigest(input.allowedTools);
|
|
68
|
-
|
|
93
|
+
const base = encodeIntentCreationSign({
|
|
94
|
+
version: 6,
|
|
69
95
|
tenantId: input.tenantId,
|
|
70
96
|
intentId: input.intentId,
|
|
71
97
|
principalDid: input.principalDid,
|
|
@@ -79,7 +105,127 @@ export function intentCreationSignBytesRaw(input) {
|
|
|
79
105
|
predicateRef: input.predicateRef,
|
|
80
106
|
allowedToolsDigest: allowedDigest,
|
|
81
107
|
settlementRail: input.settlementRail,
|
|
108
|
+
payeePubkey: input.payeePubkeyBytes,
|
|
82
109
|
});
|
|
110
|
+
if (!input.completionContract) {
|
|
111
|
+
return base;
|
|
112
|
+
}
|
|
113
|
+
return appendCompletionContractSignExtension(base, input.completionContract);
|
|
114
|
+
}
|
|
115
|
+
function parseDigestHex(hexValue) {
|
|
116
|
+
const trimmed = hexValue.trim().toLowerCase().replace(/^0x/, "");
|
|
117
|
+
if (!/^[0-9a-f]{64}$/.test(trimmed)) {
|
|
118
|
+
throw new Error("policyContentDigestHex must be a 64-character hex string");
|
|
119
|
+
}
|
|
120
|
+
const out = new Uint8Array(32);
|
|
121
|
+
for (let i = 0; i < 32; i += 1) {
|
|
122
|
+
out[i] = Number.parseInt(trimmed.slice(i * 2, i * 2 + 2), 16);
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
/** Bincode payload for managed-policy intent creation (wire format revision byte `5`). */
|
|
127
|
+
export function intentCreationSignBytesWithPolicyBinding(input) {
|
|
128
|
+
if (input.payeePubkeyBytes.length !== 32) {
|
|
129
|
+
throw new Error("payeePubkeyBytes must be 32 bytes");
|
|
130
|
+
}
|
|
131
|
+
const budgetDigest = jsonValueDigest(input.budget);
|
|
132
|
+
const evidenceSchemaDigest = jsonValueDigest(input.evidenceSchema);
|
|
133
|
+
const predicateDslDigest = dslDigest(input.materializedPredicate);
|
|
134
|
+
const allowedDigest = allowedToolsDigest(input.allowedTools);
|
|
135
|
+
const base = encodeIntentCreationSign({
|
|
136
|
+
version: 7,
|
|
137
|
+
tenantId: input.tenantId,
|
|
138
|
+
intentId: input.intentId,
|
|
139
|
+
principalDid: input.principalDid,
|
|
140
|
+
payeeDid: input.payeeDid,
|
|
141
|
+
amountCents: input.amountCents,
|
|
142
|
+
currency: input.currency,
|
|
143
|
+
deadlineRfc3339: input.deadlineRfc3339,
|
|
144
|
+
budgetDigest,
|
|
145
|
+
evidenceSchemaDigest,
|
|
146
|
+
predicateDslDigest,
|
|
147
|
+
predicateRef: input.predicateRef,
|
|
148
|
+
allowedToolsDigest: allowedDigest,
|
|
149
|
+
settlementRail: input.settlementRail,
|
|
150
|
+
policyTemplateId: input.policyBinding.templateId,
|
|
151
|
+
policyVersionSeq: input.policyBinding.versionSeq,
|
|
152
|
+
policyContentDigest: parseDigestHex(input.policyContentDigestHex),
|
|
153
|
+
payeePubkey: input.payeePubkeyBytes,
|
|
154
|
+
});
|
|
155
|
+
if (!input.completionContract) {
|
|
156
|
+
return base;
|
|
157
|
+
}
|
|
158
|
+
return appendCompletionContractSignExtension(base, input.completionContract);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Build a Harbor `POST /intents` JSON body with signing v5 and a published managed-policy head.
|
|
162
|
+
*/
|
|
163
|
+
export function buildSignedCreateIntentBodyWithPolicyBinding(params) {
|
|
164
|
+
if (params.principalSigningSeed.length !== 32) {
|
|
165
|
+
throw new Error("principalSigningSeed must be 32 bytes");
|
|
166
|
+
}
|
|
167
|
+
if (params.payeeSigningSeed.length !== 32) {
|
|
168
|
+
throw new Error("payeeSigningSeed must be 32 bytes");
|
|
169
|
+
}
|
|
170
|
+
if (params.allowedTools.length === 0) {
|
|
171
|
+
throw new Error("allowedTools must be non-empty");
|
|
172
|
+
}
|
|
173
|
+
const settlementRail = validateSettlementRail(params.settlementRail);
|
|
174
|
+
const predicateRef = params.predicateRef ?? "";
|
|
175
|
+
const head = params.publishedPolicyHead;
|
|
176
|
+
if (head.templateId !== params.policyBinding.templateId || head.versionSeq !== params.policyBinding.versionSeq) {
|
|
177
|
+
throw new Error("publishedPolicyHead must match policyBinding template_id and version_seq");
|
|
178
|
+
}
|
|
179
|
+
ensureEd25519Sha512Sync();
|
|
180
|
+
const payeePub = getPublicKey(params.payeeSigningSeed);
|
|
181
|
+
const msg = intentCreationSignBytesWithPolicyBinding({
|
|
182
|
+
tenantId: params.tenantId,
|
|
183
|
+
intentId: params.intentId,
|
|
184
|
+
principalDid: params.principalDid,
|
|
185
|
+
payeeDid: params.payeeDid,
|
|
186
|
+
payeePubkeyBytes: payeePub,
|
|
187
|
+
amountCents: params.amountCents,
|
|
188
|
+
currency: params.currency,
|
|
189
|
+
deadlineRfc3339: params.deadlineRfc3339,
|
|
190
|
+
budget: params.budget,
|
|
191
|
+
evidenceSchema: params.evidenceSchema,
|
|
192
|
+
materializedPredicate: head.materializedPredicate,
|
|
193
|
+
predicateRef,
|
|
194
|
+
allowedTools: params.allowedTools,
|
|
195
|
+
settlementRail,
|
|
196
|
+
policyBinding: params.policyBinding,
|
|
197
|
+
policyContentDigestHex: head.policyContentDigestHex,
|
|
198
|
+
completionContract: params.completionContract,
|
|
199
|
+
});
|
|
200
|
+
const sig = sign(msg, params.principalSigningSeed);
|
|
201
|
+
const pub = getPublicKey(params.principalSigningSeed);
|
|
202
|
+
const body = {
|
|
203
|
+
intent_id: params.intentId,
|
|
204
|
+
principal_did: params.principalDid,
|
|
205
|
+
principal_pubkey: bytesToBase64(pub),
|
|
206
|
+
principal_signature: bytesToBase64(sig),
|
|
207
|
+
payee_did: params.payeeDid,
|
|
208
|
+
payee_pubkey: bytesToBase64(payeePub),
|
|
209
|
+
budget: params.budget,
|
|
210
|
+
currency: params.currency,
|
|
211
|
+
amount_cents: params.amountCents,
|
|
212
|
+
evidence_schema: params.evidenceSchema,
|
|
213
|
+
deadline: params.deadlineRfc3339,
|
|
214
|
+
settlement_rail: settlementRail,
|
|
215
|
+
signing_version: 7,
|
|
216
|
+
policy_binding: {
|
|
217
|
+
template_id: params.policyBinding.templateId,
|
|
218
|
+
version_seq: params.policyBinding.versionSeq,
|
|
219
|
+
},
|
|
220
|
+
allowed_tools: params.allowedTools,
|
|
221
|
+
};
|
|
222
|
+
if (predicateRef.trim() !== "") {
|
|
223
|
+
body.predicate_ref = predicateRef;
|
|
224
|
+
}
|
|
225
|
+
if (params.completionPresetId?.trim()) {
|
|
226
|
+
body.completion_preset_id = params.completionPresetId.trim();
|
|
227
|
+
}
|
|
228
|
+
return body;
|
|
83
229
|
}
|
|
84
230
|
function bytesToBase64(bytes) {
|
|
85
231
|
let binary = "";
|
|
@@ -95,17 +241,22 @@ export function buildSignedCreateIntentBody(params) {
|
|
|
95
241
|
if (params.principalSigningSeed.length !== 32) {
|
|
96
242
|
throw new Error("principalSigningSeed must be 32 bytes");
|
|
97
243
|
}
|
|
244
|
+
if (params.payeeSigningSeed.length !== 32) {
|
|
245
|
+
throw new Error("payeeSigningSeed must be 32 bytes");
|
|
246
|
+
}
|
|
98
247
|
if (params.allowedTools.length === 0) {
|
|
99
248
|
throw new Error("allowedTools must be non-empty");
|
|
100
249
|
}
|
|
101
250
|
const settlementRail = validateSettlementRail(params.settlementRail);
|
|
102
251
|
const predicateRef = params.predicateRef ?? "";
|
|
103
252
|
ensureEd25519Sha512Sync();
|
|
253
|
+
const payeePub = getPublicKey(params.payeeSigningSeed);
|
|
104
254
|
const msg = intentCreationSignBytesRaw({
|
|
105
255
|
tenantId: params.tenantId,
|
|
106
256
|
intentId: params.intentId,
|
|
107
257
|
principalDid: params.principalDid,
|
|
108
258
|
payeeDid: params.payeeDid,
|
|
259
|
+
payeePubkeyBytes: payeePub,
|
|
109
260
|
amountCents: params.amountCents,
|
|
110
261
|
currency: params.currency,
|
|
111
262
|
deadlineRfc3339: params.deadlineRfc3339,
|
|
@@ -115,6 +266,7 @@ export function buildSignedCreateIntentBody(params) {
|
|
|
115
266
|
predicateRef,
|
|
116
267
|
allowedTools: params.allowedTools,
|
|
117
268
|
settlementRail,
|
|
269
|
+
completionContract: params.completionContract,
|
|
118
270
|
});
|
|
119
271
|
const sig = sign(msg, params.principalSigningSeed);
|
|
120
272
|
const pub = getPublicKey(params.principalSigningSeed);
|
|
@@ -124,6 +276,7 @@ export function buildSignedCreateIntentBody(params) {
|
|
|
124
276
|
principal_pubkey: bytesToBase64(pub),
|
|
125
277
|
principal_signature: bytesToBase64(sig),
|
|
126
278
|
payee_did: params.payeeDid,
|
|
279
|
+
payee_pubkey: bytesToBase64(payeePub),
|
|
127
280
|
budget: params.budget,
|
|
128
281
|
currency: params.currency,
|
|
129
282
|
amount_cents: params.amountCents,
|
|
@@ -131,12 +284,15 @@ export function buildSignedCreateIntentBody(params) {
|
|
|
131
284
|
deadline: params.deadlineRfc3339,
|
|
132
285
|
predicate_dsl: params.predicate,
|
|
133
286
|
settlement_rail: settlementRail,
|
|
134
|
-
signing_version:
|
|
287
|
+
signing_version: 6,
|
|
135
288
|
policy_binding: null,
|
|
136
289
|
allowed_tools: params.allowedTools,
|
|
137
290
|
};
|
|
138
291
|
if (predicateRef.trim() !== "") {
|
|
139
292
|
body.predicate_ref = predicateRef;
|
|
140
293
|
}
|
|
294
|
+
if (params.completionPresetId?.trim()) {
|
|
295
|
+
body.completion_preset_id = params.completionPresetId.trim();
|
|
296
|
+
}
|
|
141
297
|
return body;
|
|
142
298
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PolicyPresetId } from "./policy/presets.js";
|
|
2
|
+
import { type SolutionId } from "./solutions/catalog.js";
|
|
3
|
+
export type ProjectInitSolution = SolutionId | "mcp-server";
|
|
4
|
+
export type ProjectInitFramework = "openai" | "langgraph" | "mcp" | "generic";
|
|
5
|
+
export type ProjectInitLanguage = "typescript" | "python";
|
|
6
|
+
export type ProjectInitOptions = {
|
|
7
|
+
cwd: string;
|
|
8
|
+
solution?: ProjectInitSolution;
|
|
9
|
+
maxSpendUsd?: number;
|
|
10
|
+
framework?: ProjectInitFramework;
|
|
11
|
+
language?: ProjectInitLanguage;
|
|
12
|
+
nonInteractive?: boolean;
|
|
13
|
+
force?: boolean;
|
|
14
|
+
writeStdout?: (line: string) => void;
|
|
15
|
+
prompt?: (question: string) => Promise<string>;
|
|
16
|
+
};
|
|
17
|
+
export type ProjectInitResult = {
|
|
18
|
+
solution: ProjectInitSolution;
|
|
19
|
+
preset_id: PolicyPresetId;
|
|
20
|
+
max_spend_usd: number;
|
|
21
|
+
framework: ProjectInitFramework;
|
|
22
|
+
language: ProjectInitLanguage;
|
|
23
|
+
files: string[];
|
|
24
|
+
smoke_command: string;
|
|
25
|
+
};
|
|
26
|
+
declare function usage(): string;
|
|
27
|
+
export type ProjectInitArgv = Omit<ProjectInitOptions, "cwd"> & {
|
|
28
|
+
template?: string;
|
|
29
|
+
help?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare function parseProjectInitArgv(argv: string[]): ProjectInitArgv | "help";
|
|
32
|
+
/** Run the interactive or flag-driven project scaffold wizard. */
|
|
33
|
+
export declare function runProjectInit(options: ProjectInitOptions): Promise<ProjectInitResult>;
|
|
34
|
+
export { usage as projectInitUsage };
|