@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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { canonicalPolicyDocumentDigest, policyDocumentToDict, policyVersionLabel, } from "./digest.js";
|
|
2
|
+
export { PaybondPolicy } from "./load.js";
|
|
3
|
+
export { isKnownPolicyPresetId, isLayeredPolicyPresetId, listPolicyPresetIds, readPolicyPresetYaml, resolveComposedPresetDocument, resolvePolicyPresetPath, } from "./presets.js";
|
|
4
|
+
export { assertLayeredPresetMatchesFlat, bundledDefaultGuardrails, composeBundledPresetDefault, composeLayeredPolicyPresetDocument, composePolicyLayers, composePolicyPresetLayers, isLayeredPolicyPreset, LAYERED_POLICY_PRESET_IDS, } from "./compose.js";
|
|
5
|
+
export { domain } from "./domain.js";
|
|
6
|
+
export { auditOnly, allowDryRun, defaultDeny, guardrailLayerFromDocument, guardrails, maxSpend, maxSpendUsd, readOnly, readOnlySearch, requireEvidence, strict, } from "./guardrails.js";
|
|
7
|
+
export { paybondPolicyPresets } from "./policy-api.js";
|
|
8
|
+
export { createPolicySnapshot, createPolicySnapshotFromEffective, } from "./snapshot.js";
|
|
9
|
+
export { parsePolicyExtendsRef, renderOrgBasePolicyYaml, renderPaybondPolicyYaml, renderTenantOverlayPolicyYaml, scaffoldOrgBasePolicy, scaffoldPaybondPolicy, scaffoldPolicyFromPreset, scaffoldTenantOverlayPolicy, } from "./init.js";
|
|
10
|
+
export { PaybondPolicyIntentSpecError, policyToIntentCreateInput, } from "./intent-spec.js";
|
|
11
|
+
export { PaybondPolicySandboxBootstrapError, policySandboxBootstrap, } from "./sandbox-bootstrap.js";
|
|
12
|
+
export { resolveJsonPath, resolveSpendCentsFromJsonPath } from "./json-path.js";
|
|
13
|
+
export { parsePolicyDocumentText } from "./parse-text.js";
|
|
14
|
+
export { policyDocumentToToolRegistryConfig, policyToToolRegistry, } from "./registry.js";
|
|
15
|
+
export { mergePaybondPolicies, toEffectivePolicyDocument, } from "./merge.js";
|
|
16
|
+
export { PAYBOND_POLICY_SCHEMA_VERSION, PAYBOND_POLICY_SCHEMA_VERSION_V2, PaybondPolicyValidationError, isPaybondPolicyDocumentV1, isPaybondPolicyDocumentV2, isPaybondPolicyOverlay, parsePaybondPolicyDocument, parsePaybondPolicyDocumentV1, parsePaybondPolicyDocumentV2, paybondPolicyDocumentV1Schema, paybondPolicyDocumentV2Schema, } from "./schema.js";
|
|
17
|
+
export { PolicyValidator, } from "./validate.js";
|
|
18
|
+
export { parsePolicyRemoteValidateResponse, policyRemoteValidateResultToDict, policyValidateQueryString, validatePolicyPayloadRemote, validatePolicyRemote, } from "./validate-remote.js";
|
|
19
|
+
export { parseMergeReport, parsePolicyEffectiveResolveResponse, resolvePolicyEffectiveRemote, } from "./load-effective.js";
|
|
20
|
+
export { PaybondPolicyReloadController, } from "./watcher.js";
|
|
21
|
+
export { PaybondPolicyReloadError, PaybondPolicyReloadUnchangedError, applyPolicySnapshotToRun, detectPolicyLoosening, loadPolicySnapshotFromEffectivePoll, loadPolicySnapshotFromFile, reloadPolicyOnHandle, reloadPolicyOnRun, requiresIntentRebind, } from "./reload.js";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type LayeredPolicyPresetId } from "./compose.js";
|
|
2
|
+
import { type PolicyPresetId } from "./presets.js";
|
|
3
|
+
export type ScaffoldPaybondPolicyOptions = {
|
|
4
|
+
out: string;
|
|
5
|
+
operation: string;
|
|
6
|
+
evidencePreset: string;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ScaffoldPolicyFromPresetOptions = {
|
|
10
|
+
out: string;
|
|
11
|
+
presetId: PolicyPresetId;
|
|
12
|
+
/** Intent budget and side-effecting tool cap override in USD. */
|
|
13
|
+
maxSpendUsd?: number;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type ScaffoldComposedPolicyOptions = {
|
|
17
|
+
out: string;
|
|
18
|
+
domainId: LayeredPolicyPresetId;
|
|
19
|
+
guardrails: string;
|
|
20
|
+
force?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type ScaffoldOrgBasePolicyOptions = {
|
|
23
|
+
out: string;
|
|
24
|
+
policyId: string;
|
|
25
|
+
operation: string;
|
|
26
|
+
evidencePreset: string;
|
|
27
|
+
maxSpendCents?: number;
|
|
28
|
+
force?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type ScaffoldTenantOverlayPolicyOptions = {
|
|
31
|
+
out: string;
|
|
32
|
+
extendsRef: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
operation?: string;
|
|
35
|
+
evidencePreset?: string;
|
|
36
|
+
basePolicy?: string;
|
|
37
|
+
force?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Parse `org_id/org_policy_id` extends reference used by CLI and docs. */
|
|
40
|
+
export declare function parsePolicyExtendsRef(ref: string): {
|
|
41
|
+
orgId: string;
|
|
42
|
+
orgPolicyId: string;
|
|
43
|
+
};
|
|
44
|
+
/** Render a starter paybond.policy.yaml document. */
|
|
45
|
+
export declare function renderPaybondPolicyYaml(options: ScaffoldPaybondPolicyOptions): string;
|
|
46
|
+
/** Render a v2 org base policy document (no extends). */
|
|
47
|
+
export declare function renderOrgBasePolicyYaml(options: ScaffoldOrgBasePolicyOptions): string;
|
|
48
|
+
/** Write a v2 org base policy file for platform operators. */
|
|
49
|
+
export declare function scaffoldOrgBasePolicy(options: ScaffoldOrgBasePolicyOptions): Promise<{
|
|
50
|
+
out: string;
|
|
51
|
+
policy_id: string;
|
|
52
|
+
operation: string;
|
|
53
|
+
evidence_preset: string;
|
|
54
|
+
bytes_written: number;
|
|
55
|
+
}>;
|
|
56
|
+
/** Render a v2 tenant overlay policy that extends an org base. */
|
|
57
|
+
export declare function renderTenantOverlayPolicyYaml(options: ScaffoldTenantOverlayPolicyOptions): string;
|
|
58
|
+
/** Write a v2 tenant overlay policy file extending an org base. */
|
|
59
|
+
export declare function scaffoldTenantOverlayPolicy(options: ScaffoldTenantOverlayPolicyOptions): Promise<{
|
|
60
|
+
out: string;
|
|
61
|
+
name: string;
|
|
62
|
+
org_id: string;
|
|
63
|
+
org_policy_id: string;
|
|
64
|
+
operation?: string;
|
|
65
|
+
evidence_preset?: string;
|
|
66
|
+
bytes_written: number;
|
|
67
|
+
}>;
|
|
68
|
+
/** Render a bundled preset as editable local YAML with a scaffold header comment. */
|
|
69
|
+
export declare function renderPolicyPresetScaffoldYaml(presetId: PolicyPresetId, options?: {
|
|
70
|
+
maxSpendUsd?: number;
|
|
71
|
+
}): string;
|
|
72
|
+
/** Render a composed domain + guardrails policy as editable local YAML. */
|
|
73
|
+
export declare function renderComposedPolicyScaffoldYaml(options: ScaffoldComposedPolicyOptions): string;
|
|
74
|
+
/** Preview composed domain + guardrails YAML for `paybond policy presets show`. */
|
|
75
|
+
export declare function renderComposedPolicyPreviewYaml(options: Pick<ScaffoldComposedPolicyOptions, "domainId" | "guardrails">): string;
|
|
76
|
+
/** Preview composed policy YAML for `paybond policy presets show`. */
|
|
77
|
+
export declare function renderPolicyPresetPreviewYaml(presetId: PolicyPresetId, options?: {
|
|
78
|
+
maxSpendUsd?: number;
|
|
79
|
+
}): string;
|
|
80
|
+
/** Write a bundled vertical preset to an owned local policy file. */
|
|
81
|
+
export declare function scaffoldPolicyFromPreset(options: ScaffoldPolicyFromPresetOptions): Promise<{
|
|
82
|
+
out: string;
|
|
83
|
+
preset: string;
|
|
84
|
+
name: string;
|
|
85
|
+
bytes_written: number;
|
|
86
|
+
}>;
|
|
87
|
+
/** Write a composed domain + guardrails policy file. */
|
|
88
|
+
export declare function scaffoldComposedPolicy(options: ScaffoldComposedPolicyOptions): Promise<{
|
|
89
|
+
out: string;
|
|
90
|
+
domain: string;
|
|
91
|
+
guardrails: string;
|
|
92
|
+
name: string;
|
|
93
|
+
bytes_written: number;
|
|
94
|
+
}>;
|
|
95
|
+
/** Write a starter paybond.policy.yaml file. */
|
|
96
|
+
export declare function scaffoldPaybondPolicy(options: ScaffoldPaybondPolicyOptions): Promise<{
|
|
97
|
+
out: string;
|
|
98
|
+
name: string;
|
|
99
|
+
operation: string;
|
|
100
|
+
evidence_preset: string;
|
|
101
|
+
bytes_written: number;
|
|
102
|
+
}>;
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { access, writeFile } from "node:fs/promises";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { getCompletionPreset } from "../completion-catalog.js";
|
|
4
|
+
import { composePolicyLayers } from "./compose.js";
|
|
5
|
+
import { domain } from "./domain.js";
|
|
6
|
+
import { parseGuardrailSpecs } from "./guardrail-spec.js";
|
|
7
|
+
import { resolveComposedPresetDocument } from "./presets.js";
|
|
8
|
+
import { renderPolicyDocumentYaml } from "./render-yaml.js";
|
|
9
|
+
import { PaybondPolicyValidationError } from "./schema.js";
|
|
10
|
+
import { parsePolicyDocumentText } from "./parse-text.js";
|
|
11
|
+
const ORG_ID_RE = /^org_[a-z][a-z0-9_]*$/;
|
|
12
|
+
const POLICY_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
13
|
+
function policyPresetScaffoldHeader(regenerateCommand) {
|
|
14
|
+
return `# Reference implementation — edit freely. Regenerate with:\n# ${regenerateCommand}\n\n`;
|
|
15
|
+
}
|
|
16
|
+
function applyMaxSpendUsdOverride(document, maxSpendUsdValue) {
|
|
17
|
+
const cents = Math.round(maxSpendUsdValue * 100);
|
|
18
|
+
const next = {
|
|
19
|
+
...document,
|
|
20
|
+
tools: Object.fromEntries(Object.entries(document.tools).map(([toolName, entry]) => [
|
|
21
|
+
toolName,
|
|
22
|
+
entry.side_effecting ? { ...entry, max_spend_cents: cents } : { ...entry },
|
|
23
|
+
])),
|
|
24
|
+
intent: document.intent
|
|
25
|
+
? {
|
|
26
|
+
...document.intent,
|
|
27
|
+
budget: {
|
|
28
|
+
...document.intent.budget,
|
|
29
|
+
currency: document.intent.budget?.currency ?? "usd",
|
|
30
|
+
max_spend_usd: maxSpendUsdValue,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
: {
|
|
34
|
+
budget: { currency: "usd", max_spend_usd: maxSpendUsdValue },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
return next;
|
|
38
|
+
}
|
|
39
|
+
function resolvePresetInitDocument(options) {
|
|
40
|
+
const document = resolveComposedPresetDocument(options.presetId);
|
|
41
|
+
if (options.maxSpendUsd === undefined) {
|
|
42
|
+
return document;
|
|
43
|
+
}
|
|
44
|
+
return applyMaxSpendUsdOverride(document, options.maxSpendUsd);
|
|
45
|
+
}
|
|
46
|
+
function resolveComposedInitDocument(options) {
|
|
47
|
+
const layers = parseGuardrailSpecs(options.guardrails);
|
|
48
|
+
return composePolicyLayers(domain[options.domainId](), ...layers);
|
|
49
|
+
}
|
|
50
|
+
/** Parse `org_id/org_policy_id` extends reference used by CLI and docs. */
|
|
51
|
+
export function parsePolicyExtendsRef(ref) {
|
|
52
|
+
const trimmed = ref.trim();
|
|
53
|
+
const slash = trimmed.indexOf("/");
|
|
54
|
+
if (slash <= 0 || slash === trimmed.length - 1) {
|
|
55
|
+
throw new PaybondPolicyValidationError("extends must be org_id/org_policy_id (example: org_acme_corp/acme-agent-spend-v1)");
|
|
56
|
+
}
|
|
57
|
+
const orgId = trimmed.slice(0, slash);
|
|
58
|
+
const orgPolicyId = trimmed.slice(slash + 1);
|
|
59
|
+
if (!ORG_ID_RE.test(orgId)) {
|
|
60
|
+
throw new PaybondPolicyValidationError(`org_id must match org_<snake_case>: ${orgId}`);
|
|
61
|
+
}
|
|
62
|
+
if (!POLICY_NAME_RE.test(orgPolicyId)) {
|
|
63
|
+
throw new PaybondPolicyValidationError(`org_policy_id must be a lowercase policy name: ${orgPolicyId}`);
|
|
64
|
+
}
|
|
65
|
+
return { orgId, orgPolicyId };
|
|
66
|
+
}
|
|
67
|
+
function overlayNameFromPolicyId(orgPolicyId, explicit) {
|
|
68
|
+
if (explicit?.trim()) {
|
|
69
|
+
return explicit.trim();
|
|
70
|
+
}
|
|
71
|
+
return orgPolicyId.endsWith("-overlay-v1") ? orgPolicyId : `${orgPolicyId}-overlay-v1`;
|
|
72
|
+
}
|
|
73
|
+
function policyNameFromOperation(operation) {
|
|
74
|
+
const slug = operation
|
|
75
|
+
.trim()
|
|
76
|
+
.toLowerCase()
|
|
77
|
+
.replace(/[._]+/g, "-")
|
|
78
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
79
|
+
.replace(/-+/g, "-")
|
|
80
|
+
.replace(/^-+|-+$/g, "");
|
|
81
|
+
const base = slug || "agent";
|
|
82
|
+
return base.endsWith("-v1") ? base : `${base}-v1`;
|
|
83
|
+
}
|
|
84
|
+
function templateIdStubForPreset(presetId) {
|
|
85
|
+
try {
|
|
86
|
+
return getCompletionPreset(presetId).harbor_template_id;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return "completion_v1";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Render a starter paybond.policy.yaml document. */
|
|
93
|
+
export function renderPaybondPolicyYaml(options) {
|
|
94
|
+
const operation = options.operation.trim();
|
|
95
|
+
const evidencePreset = options.evidencePreset.trim();
|
|
96
|
+
if (!operation) {
|
|
97
|
+
throw new PaybondPolicyValidationError("operation is required");
|
|
98
|
+
}
|
|
99
|
+
if (!evidencePreset) {
|
|
100
|
+
throw new PaybondPolicyValidationError("evidence preset is required");
|
|
101
|
+
}
|
|
102
|
+
getCompletionPreset(evidencePreset);
|
|
103
|
+
const name = policyNameFromOperation(operation);
|
|
104
|
+
const templateId = templateIdStubForPreset(evidencePreset);
|
|
105
|
+
return `version: 1
|
|
106
|
+
name: ${name}
|
|
107
|
+
default_deny: true
|
|
108
|
+
|
|
109
|
+
tools:
|
|
110
|
+
${operation}:
|
|
111
|
+
side_effecting: true
|
|
112
|
+
evidence_preset: ${evidencePreset}
|
|
113
|
+
operation: ${operation}
|
|
114
|
+
|
|
115
|
+
intent:
|
|
116
|
+
policy_binding:
|
|
117
|
+
template_id: ${templateId}
|
|
118
|
+
allowed_tools:
|
|
119
|
+
- ${operation}
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
/** Render a v2 org base policy document (no extends). */
|
|
123
|
+
export function renderOrgBasePolicyYaml(options) {
|
|
124
|
+
const policyId = options.policyId.trim();
|
|
125
|
+
const operation = options.operation.trim();
|
|
126
|
+
const evidencePreset = options.evidencePreset.trim();
|
|
127
|
+
if (!policyId) {
|
|
128
|
+
throw new PaybondPolicyValidationError("policy_id is required");
|
|
129
|
+
}
|
|
130
|
+
if (!POLICY_NAME_RE.test(policyId)) {
|
|
131
|
+
throw new PaybondPolicyValidationError("policy_id must be a lowercase policy name");
|
|
132
|
+
}
|
|
133
|
+
if (!operation) {
|
|
134
|
+
throw new PaybondPolicyValidationError("operation is required");
|
|
135
|
+
}
|
|
136
|
+
if (!evidencePreset) {
|
|
137
|
+
throw new PaybondPolicyValidationError("evidence preset is required");
|
|
138
|
+
}
|
|
139
|
+
getCompletionPreset(evidencePreset);
|
|
140
|
+
const templateId = templateIdStubForPreset(evidencePreset);
|
|
141
|
+
const maxSpendLine = options.maxSpendCents !== undefined ? `\n max_spend_cents: ${options.maxSpendCents}` : "";
|
|
142
|
+
return `version: 2
|
|
143
|
+
name: ${policyId}
|
|
144
|
+
default_deny: true
|
|
145
|
+
|
|
146
|
+
tools:
|
|
147
|
+
${operation}:
|
|
148
|
+
side_effecting: true
|
|
149
|
+
evidence_preset: ${evidencePreset}${maxSpendLine}
|
|
150
|
+
operation: ${operation}
|
|
151
|
+
|
|
152
|
+
intent:
|
|
153
|
+
policy_binding:
|
|
154
|
+
template_id: ${templateId}
|
|
155
|
+
allowed_tools:
|
|
156
|
+
- ${operation}
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
/** Write a v2 org base policy file for platform operators. */
|
|
160
|
+
export async function scaffoldOrgBasePolicy(options) {
|
|
161
|
+
if (!options.force) {
|
|
162
|
+
try {
|
|
163
|
+
await access(options.out, constants.F_OK);
|
|
164
|
+
throw new PaybondPolicyValidationError(`${options.out} already exists (pass --force to overwrite)`);
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
if (err instanceof PaybondPolicyValidationError) {
|
|
168
|
+
throw err;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const yaml = renderOrgBasePolicyYaml(options);
|
|
173
|
+
await writeFile(options.out, yaml, "utf8");
|
|
174
|
+
return {
|
|
175
|
+
out: options.out,
|
|
176
|
+
policy_id: options.policyId.trim(),
|
|
177
|
+
operation: options.operation.trim(),
|
|
178
|
+
evidence_preset: options.evidencePreset.trim(),
|
|
179
|
+
bytes_written: Buffer.byteLength(yaml, "utf8"),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/** Render a v2 tenant overlay policy that extends an org base. */
|
|
183
|
+
export function renderTenantOverlayPolicyYaml(options) {
|
|
184
|
+
const { orgId, orgPolicyId } = parsePolicyExtendsRef(options.extendsRef);
|
|
185
|
+
const name = overlayNameFromPolicyId(orgPolicyId, options.name);
|
|
186
|
+
if (!POLICY_NAME_RE.test(name)) {
|
|
187
|
+
throw new PaybondPolicyValidationError("overlay name must be a lowercase policy name");
|
|
188
|
+
}
|
|
189
|
+
const operation = options.operation?.trim();
|
|
190
|
+
const evidencePreset = options.evidencePreset?.trim();
|
|
191
|
+
if (operation && !evidencePreset) {
|
|
192
|
+
throw new PaybondPolicyValidationError("tenant-only tool requires --evidence-preset");
|
|
193
|
+
}
|
|
194
|
+
if (evidencePreset && !operation) {
|
|
195
|
+
throw new PaybondPolicyValidationError("--evidence-preset requires --operation for tenant-only tools");
|
|
196
|
+
}
|
|
197
|
+
if (evidencePreset) {
|
|
198
|
+
getCompletionPreset(evidencePreset);
|
|
199
|
+
}
|
|
200
|
+
const basePolicyLine = options.basePolicy?.trim()
|
|
201
|
+
? `\n base_policy: ${options.basePolicy.trim()}`
|
|
202
|
+
: "";
|
|
203
|
+
const toolsBlock = operation && evidencePreset
|
|
204
|
+
? `tools:
|
|
205
|
+
${operation}:
|
|
206
|
+
side_effecting: true
|
|
207
|
+
evidence_preset: ${evidencePreset}
|
|
208
|
+
operation: ${operation}
|
|
209
|
+
`
|
|
210
|
+
: "";
|
|
211
|
+
return `version: 2
|
|
212
|
+
name: ${name}
|
|
213
|
+
extends:
|
|
214
|
+
org_policy_id: ${orgPolicyId}
|
|
215
|
+
org_id: ${orgId}${basePolicyLine}
|
|
216
|
+
default_deny: true
|
|
217
|
+
|
|
218
|
+
${toolsBlock}`;
|
|
219
|
+
}
|
|
220
|
+
/** Write a v2 tenant overlay policy file extending an org base. */
|
|
221
|
+
export async function scaffoldTenantOverlayPolicy(options) {
|
|
222
|
+
const { orgId, orgPolicyId } = parsePolicyExtendsRef(options.extendsRef);
|
|
223
|
+
const name = overlayNameFromPolicyId(orgPolicyId, options.name);
|
|
224
|
+
if (!options.force) {
|
|
225
|
+
try {
|
|
226
|
+
await access(options.out, constants.F_OK);
|
|
227
|
+
throw new PaybondPolicyValidationError(`${options.out} already exists (pass --force to overwrite)`);
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
if (err instanceof PaybondPolicyValidationError) {
|
|
231
|
+
throw err;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const yaml = renderTenantOverlayPolicyYaml(options);
|
|
236
|
+
await writeFile(options.out, yaml, "utf8");
|
|
237
|
+
const operation = options.operation?.trim();
|
|
238
|
+
const evidencePreset = options.evidencePreset?.trim();
|
|
239
|
+
return {
|
|
240
|
+
out: options.out,
|
|
241
|
+
name,
|
|
242
|
+
org_id: orgId,
|
|
243
|
+
org_policy_id: orgPolicyId,
|
|
244
|
+
...(operation ? { operation } : {}),
|
|
245
|
+
...(evidencePreset ? { evidence_preset: evidencePreset } : {}),
|
|
246
|
+
bytes_written: Buffer.byteLength(yaml, "utf8"),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/** Render a bundled preset as editable local YAML with a scaffold header comment. */
|
|
250
|
+
export function renderPolicyPresetScaffoldYaml(presetId, options) {
|
|
251
|
+
const regenerate = options?.maxSpendUsd !== undefined
|
|
252
|
+
? `paybond policy init --preset ${presetId} --max-spend ${options.maxSpendUsd} --force`
|
|
253
|
+
: `paybond policy init --preset ${presetId} --force`;
|
|
254
|
+
const body = renderPolicyDocumentYaml(options?.maxSpendUsd !== undefined
|
|
255
|
+
? resolvePresetInitDocument({ out: "", presetId, maxSpendUsd: options.maxSpendUsd })
|
|
256
|
+
: resolveComposedPresetDocument(presetId)).trimEnd();
|
|
257
|
+
return `${policyPresetScaffoldHeader(regenerate)}${body}\n`;
|
|
258
|
+
}
|
|
259
|
+
/** Render a composed domain + guardrails policy as editable local YAML. */
|
|
260
|
+
export function renderComposedPolicyScaffoldYaml(options) {
|
|
261
|
+
const regenerate = `paybond policy init --domain ${options.domainId} --guardrails ${options.guardrails} --force`;
|
|
262
|
+
const body = renderPolicyDocumentYaml(resolveComposedInitDocument(options)).trimEnd();
|
|
263
|
+
return `${policyPresetScaffoldHeader(regenerate)}${body}\n`;
|
|
264
|
+
}
|
|
265
|
+
/** Preview composed domain + guardrails YAML for `paybond policy presets show`. */
|
|
266
|
+
export function renderComposedPolicyPreviewYaml(options) {
|
|
267
|
+
return renderPolicyDocumentYaml(resolveComposedInitDocument({ out: "", domainId: options.domainId, guardrails: options.guardrails }));
|
|
268
|
+
}
|
|
269
|
+
/** Preview composed policy YAML for `paybond policy presets show`. */
|
|
270
|
+
export function renderPolicyPresetPreviewYaml(presetId, options) {
|
|
271
|
+
const document = options?.maxSpendUsd !== undefined
|
|
272
|
+
? resolvePresetInitDocument({ out: "", presetId, maxSpendUsd: options.maxSpendUsd })
|
|
273
|
+
: resolveComposedPresetDocument(presetId);
|
|
274
|
+
return renderPolicyDocumentYaml(document);
|
|
275
|
+
}
|
|
276
|
+
/** Write a bundled vertical preset to an owned local policy file. */
|
|
277
|
+
export async function scaffoldPolicyFromPreset(options) {
|
|
278
|
+
if (!options.force) {
|
|
279
|
+
try {
|
|
280
|
+
await access(options.out, constants.F_OK);
|
|
281
|
+
throw new PaybondPolicyValidationError(`${options.out} already exists (pass --force to overwrite)`);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (err instanceof PaybondPolicyValidationError) {
|
|
285
|
+
throw err;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const yaml = renderPolicyPresetScaffoldYaml(options.presetId, {
|
|
290
|
+
maxSpendUsd: options.maxSpendUsd,
|
|
291
|
+
});
|
|
292
|
+
await writeFile(options.out, yaml, "utf8");
|
|
293
|
+
const parsed = parsePolicyDocumentText(yaml, options.out);
|
|
294
|
+
const name = typeof parsed.name === "string" ? parsed.name : options.presetId;
|
|
295
|
+
return {
|
|
296
|
+
out: options.out,
|
|
297
|
+
preset: options.presetId,
|
|
298
|
+
name,
|
|
299
|
+
...(options.maxSpendUsd !== undefined ? { max_spend_usd: options.maxSpendUsd } : {}),
|
|
300
|
+
bytes_written: Buffer.byteLength(yaml, "utf8"),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/** Write a composed domain + guardrails policy file. */
|
|
304
|
+
export async function scaffoldComposedPolicy(options) {
|
|
305
|
+
if (!options.force) {
|
|
306
|
+
try {
|
|
307
|
+
await access(options.out, constants.F_OK);
|
|
308
|
+
throw new PaybondPolicyValidationError(`${options.out} already exists (pass --force to overwrite)`);
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
if (err instanceof PaybondPolicyValidationError) {
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const yaml = renderComposedPolicyScaffoldYaml(options);
|
|
317
|
+
await writeFile(options.out, yaml, "utf8");
|
|
318
|
+
const parsed = parsePolicyDocumentText(yaml, options.out);
|
|
319
|
+
const name = typeof parsed.name === "string" ? parsed.name : options.domainId;
|
|
320
|
+
return {
|
|
321
|
+
out: options.out,
|
|
322
|
+
domain: options.domainId,
|
|
323
|
+
guardrails: options.guardrails,
|
|
324
|
+
name,
|
|
325
|
+
bytes_written: Buffer.byteLength(yaml, "utf8"),
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/** Write a starter paybond.policy.yaml file. */
|
|
329
|
+
export async function scaffoldPaybondPolicy(options) {
|
|
330
|
+
if (!options.force) {
|
|
331
|
+
try {
|
|
332
|
+
await access(options.out, constants.F_OK);
|
|
333
|
+
throw new PaybondPolicyValidationError(`${options.out} already exists (pass --force to overwrite)`);
|
|
334
|
+
}
|
|
335
|
+
catch (err) {
|
|
336
|
+
if (err instanceof PaybondPolicyValidationError) {
|
|
337
|
+
throw err;
|
|
338
|
+
}
|
|
339
|
+
// File does not exist — continue.
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const yaml = renderPaybondPolicyYaml(options);
|
|
343
|
+
await writeFile(options.out, yaml, "utf8");
|
|
344
|
+
return {
|
|
345
|
+
out: options.out,
|
|
346
|
+
name: policyNameFromOperation(options.operation),
|
|
347
|
+
operation: options.operation.trim(),
|
|
348
|
+
evidence_preset: options.evidencePreset.trim(),
|
|
349
|
+
bytes_written: Buffer.byteLength(yaml, "utf8"),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CompletionContractSnapshot, PolicyBindingRef, PublishedPolicyHead, SettlementRail } from "../principal-intent.js";
|
|
2
|
+
import { type PaybondPolicyDocumentV1 } from "./schema.js";
|
|
3
|
+
/** Raised when policy intent fields cannot be aligned to a Harbor create payload. */
|
|
4
|
+
export declare class PaybondPolicyIntentSpecError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/** Runtime fields required to build a production intent create payload from policy. */
|
|
8
|
+
export type PaybondPolicyIntentCreateOverrides = {
|
|
9
|
+
principalDid: string;
|
|
10
|
+
principalSigningSeed: Uint8Array;
|
|
11
|
+
payeeDid: string;
|
|
12
|
+
payeeSigningSeed: Uint8Array;
|
|
13
|
+
deadlineRfc3339: string;
|
|
14
|
+
settlementRail: SettlementRail;
|
|
15
|
+
recognitionProof: Record<string, unknown>;
|
|
16
|
+
publishedPolicyHead: PublishedPolicyHead;
|
|
17
|
+
intentId?: string;
|
|
18
|
+
predicateRef?: string;
|
|
19
|
+
amountCents?: number;
|
|
20
|
+
currency?: string;
|
|
21
|
+
budget?: Record<string, unknown>;
|
|
22
|
+
allowedTools?: string[];
|
|
23
|
+
completionPresetId?: string;
|
|
24
|
+
evidenceSchema?: Record<string, unknown>;
|
|
25
|
+
policyBinding?: PolicyBindingRef;
|
|
26
|
+
};
|
|
27
|
+
/** Params for {@link PaybondIntents.createWithPolicyBinding} derived from policy + runtime signing context. */
|
|
28
|
+
export type PaybondPolicyIntentCreateInput = {
|
|
29
|
+
principalDid: string;
|
|
30
|
+
principalSigningSeed: Uint8Array;
|
|
31
|
+
payeeDid: string;
|
|
32
|
+
payeeSigningSeed: Uint8Array;
|
|
33
|
+
budget: Record<string, unknown>;
|
|
34
|
+
currency: string;
|
|
35
|
+
amountCents: number;
|
|
36
|
+
evidenceSchema: Record<string, unknown>;
|
|
37
|
+
deadlineRfc3339: string;
|
|
38
|
+
allowedTools: string[];
|
|
39
|
+
settlementRail: SettlementRail;
|
|
40
|
+
policyBinding: PolicyBindingRef;
|
|
41
|
+
publishedPolicyHead: PublishedPolicyHead;
|
|
42
|
+
recognitionProof: Record<string, unknown>;
|
|
43
|
+
intentId?: string;
|
|
44
|
+
predicateRef?: string;
|
|
45
|
+
completionPresetId?: string;
|
|
46
|
+
completionContract?: CompletionContractSnapshot;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Build {@link PaybondIntents.createWithPolicyBinding} input from a validated policy document.
|
|
50
|
+
* Merges policy intent alignment (`allowed_tools`, `budget`, `policy_binding`) with caller signing context.
|
|
51
|
+
*/
|
|
52
|
+
export declare function policyToIntentCreateInput(document: PaybondPolicyDocumentV1, overrides: PaybondPolicyIntentCreateOverrides): PaybondPolicyIntentCreateInput;
|