@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,36 @@
|
|
|
1
|
+
import type { PaybondPolicyLoadSource } from "./load.js";
|
|
2
|
+
import { type PaybondPolicyDocumentV1 } from "./schema.js";
|
|
3
|
+
export type PolicyValidatorError = {
|
|
4
|
+
path: string;
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export type PolicyValidatorToolCounts = {
|
|
9
|
+
side_effecting: number;
|
|
10
|
+
read_only: number;
|
|
11
|
+
};
|
|
12
|
+
export type PolicyValidatorResult = {
|
|
13
|
+
valid: boolean;
|
|
14
|
+
policy_name: string | null;
|
|
15
|
+
tools: PolicyValidatorToolCounts;
|
|
16
|
+
errors: PolicyValidatorError[];
|
|
17
|
+
};
|
|
18
|
+
export type PolicyGatewayTemplateLookup = {
|
|
19
|
+
listTemplateIds(): Promise<string[]>;
|
|
20
|
+
};
|
|
21
|
+
export type PolicyValidatorOptions = {
|
|
22
|
+
/** When true, side-effecting tools must appear in intent.allowed_tools when that list is set. */
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
/** Verify intent.policy_binding.template_id against the Harbor template catalog. */
|
|
25
|
+
checkGateway?: boolean;
|
|
26
|
+
gateway?: PolicyGatewayTemplateLookup;
|
|
27
|
+
};
|
|
28
|
+
/** Client-side policy alignment checks before deploy or agent bind. */
|
|
29
|
+
export declare class PolicyValidator {
|
|
30
|
+
/** True when `PAYBOND_POLICY_STRICT=1`. */
|
|
31
|
+
static isStrictFromEnv(): boolean;
|
|
32
|
+
/** Validate a loaded or raw policy source. */
|
|
33
|
+
static validate(source: PaybondPolicyLoadSource, options?: PolicyValidatorOptions): Promise<PolicyValidatorResult>;
|
|
34
|
+
/** Validate an already-parsed policy document (and optional gateway checks). */
|
|
35
|
+
static validateDocument(document: PaybondPolicyDocumentV1, options?: PolicyValidatorOptions): Promise<PolicyValidatorResult>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { getCompletionPreset, listCompletionPresetIds, } from "../completion-catalog.js";
|
|
2
|
+
import { isVendorPack } from "../completion-resolve.js";
|
|
3
|
+
import { PaybondPolicy } from "./load.js";
|
|
4
|
+
import { PaybondPolicyValidationError, } from "./schema.js";
|
|
5
|
+
function issueToError(issue) {
|
|
6
|
+
return {
|
|
7
|
+
path: issue.path,
|
|
8
|
+
code: issue.code,
|
|
9
|
+
message: issue.message,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function pushError(errors, path, code, message) {
|
|
13
|
+
errors.push({ path, code, message });
|
|
14
|
+
}
|
|
15
|
+
function countTools(document) {
|
|
16
|
+
let sideEffecting = 0;
|
|
17
|
+
let readOnly = 0;
|
|
18
|
+
for (const entry of Object.values(document.tools)) {
|
|
19
|
+
if (entry.side_effecting) {
|
|
20
|
+
sideEffecting += 1;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
readOnly += 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { side_effecting: sideEffecting, read_only: readOnly };
|
|
27
|
+
}
|
|
28
|
+
function catalogHasPreset(presetId) {
|
|
29
|
+
return listCompletionPresetIds().includes(presetId);
|
|
30
|
+
}
|
|
31
|
+
function validatePresetReference(errors, toolName, presetId) {
|
|
32
|
+
if (!catalogHasPreset(presetId)) {
|
|
33
|
+
pushError(errors, `tools.${toolName}.evidence_preset`, "policy.unknown_evidence_preset", `unknown completion preset: ${presetId}`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
getCompletionPreset(presetId);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
pushError(errors, `tools.${toolName}.evidence_preset`, "policy.unknown_evidence_preset", `unknown completion preset: ${presetId}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function validateVendorPackReference(errors, toolName, vendorPackId) {
|
|
44
|
+
let preset;
|
|
45
|
+
try {
|
|
46
|
+
preset = getCompletionPreset(vendorPackId);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
pushError(errors, `tools.${toolName}.vendor_pack`, "policy.unknown_vendor_pack", `unknown vendor pack preset: ${vendorPackId}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!isVendorPack(preset)) {
|
|
53
|
+
pushError(errors, `tools.${toolName}.vendor_pack`, "policy.invalid_vendor_pack", `preset ${vendorPackId} is not a vendor_pack entry`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function validateIntentAlignment(document, errors, strict) {
|
|
57
|
+
const allowedTools = document.intent?.allowed_tools;
|
|
58
|
+
if (!allowedTools || allowedTools.length === 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const registered = new Set(Object.keys(document.tools));
|
|
62
|
+
for (const toolName of allowedTools) {
|
|
63
|
+
if (!registered.has(toolName)) {
|
|
64
|
+
pushError(errors, `intent.allowed_tools`, "policy.allowed_tool_not_registered", `allowed tool "${toolName}" is not declared in tools`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!strict || !document.default_deny) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const allowed = new Set(allowedTools);
|
|
71
|
+
for (const [toolName, entry] of Object.entries(document.tools)) {
|
|
72
|
+
if (entry.side_effecting && !allowed.has(toolName)) {
|
|
73
|
+
pushError(errors, `tools.${toolName}`, "policy.side_effecting_not_allowed", `side-effecting tool "${toolName}" is missing from intent.allowed_tools (default_deny is true)`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function validateToolEntries(document, errors) {
|
|
78
|
+
for (const [toolName, entry] of Object.entries(document.tools)) {
|
|
79
|
+
if (entry.side_effecting) {
|
|
80
|
+
if (!entry.evidence_preset) {
|
|
81
|
+
pushError(errors, `tools.${toolName}.evidence_preset`, "policy.missing_evidence_preset", "side-effecting tools must declare evidence_preset");
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
validatePresetReference(errors, toolName, entry.evidence_preset);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (entry.evidence_preset) {
|
|
88
|
+
validatePresetReference(errors, toolName, entry.evidence_preset);
|
|
89
|
+
}
|
|
90
|
+
if (entry.vendor_pack) {
|
|
91
|
+
validateVendorPackReference(errors, toolName, entry.vendor_pack);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function validateGatewayTemplate(document, errors, gateway) {
|
|
96
|
+
const templateId = document.intent?.policy_binding?.template_id;
|
|
97
|
+
if (!templateId) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const templateIds = await gateway.listTemplateIds();
|
|
101
|
+
if (!templateIds.includes(templateId)) {
|
|
102
|
+
pushError(errors, "intent.policy_binding.template_id", "policy.unknown_policy_template", `policy template "${templateId}" was not found in the Harbor catalog`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function validateDocumentSync(document, options = {}) {
|
|
106
|
+
const strict = options.strict ?? PolicyValidator.isStrictFromEnv();
|
|
107
|
+
const errors = [];
|
|
108
|
+
validateToolEntries(document, errors);
|
|
109
|
+
validateIntentAlignment(document, errors, strict);
|
|
110
|
+
return {
|
|
111
|
+
valid: errors.length === 0,
|
|
112
|
+
policy_name: document.name,
|
|
113
|
+
tools: countTools(document),
|
|
114
|
+
errors,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Client-side policy alignment checks before deploy or agent bind. */
|
|
118
|
+
export class PolicyValidator {
|
|
119
|
+
/** True when `PAYBOND_POLICY_STRICT=1`. */
|
|
120
|
+
static isStrictFromEnv() {
|
|
121
|
+
return process.env.PAYBOND_POLICY_STRICT === "1";
|
|
122
|
+
}
|
|
123
|
+
/** Validate a loaded or raw policy source. */
|
|
124
|
+
static async validate(source, options = {}) {
|
|
125
|
+
try {
|
|
126
|
+
const policy = await PaybondPolicy.load(source);
|
|
127
|
+
return PolicyValidator.validateDocument(policy.document, options);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
if (err instanceof PaybondPolicyValidationError) {
|
|
131
|
+
return {
|
|
132
|
+
valid: false,
|
|
133
|
+
policy_name: null,
|
|
134
|
+
tools: { side_effecting: 0, read_only: 0 },
|
|
135
|
+
errors: err.issues.map(issueToError),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Validate an already-parsed policy document (and optional gateway checks). */
|
|
142
|
+
static async validateDocument(document, options = {}) {
|
|
143
|
+
const result = validateDocumentSync(document, options);
|
|
144
|
+
if (options.checkGateway && options.gateway) {
|
|
145
|
+
await validateGatewayTemplate(document, result.errors, options.gateway);
|
|
146
|
+
result.valid = result.errors.length === 0;
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type PaybondPolicyReloadBindConfig, type PaybondPolicyReloadOptions, type PaybondPolicyReloadResult } from "./reload.js";
|
|
2
|
+
/** Minimal reload surface for background watch/poll schedulers. */
|
|
3
|
+
export type PolicyReloadRunner = {
|
|
4
|
+
reloadPolicy(options?: PaybondPolicyReloadOptions): Promise<PaybondPolicyReloadResult>;
|
|
5
|
+
};
|
|
6
|
+
export type PaybondPolicyReloadControllerState = {
|
|
7
|
+
watch: boolean;
|
|
8
|
+
poll: boolean;
|
|
9
|
+
policyFilePath?: string;
|
|
10
|
+
lastReloadAt?: string;
|
|
11
|
+
lastReloadError?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Background file watcher and Gateway poll scheduler for policy hot-reload. */
|
|
14
|
+
export declare class PaybondPolicyReloadController {
|
|
15
|
+
private readonly runner;
|
|
16
|
+
private fileWatcher;
|
|
17
|
+
private pollTimer;
|
|
18
|
+
private debounceTimer;
|
|
19
|
+
private reloadInFlight;
|
|
20
|
+
private readonly policyFilePath;
|
|
21
|
+
private readonly reloadDefaults;
|
|
22
|
+
readonly state: PaybondPolicyReloadControllerState;
|
|
23
|
+
private constructor();
|
|
24
|
+
static start(runner: PolicyReloadRunner, config: PaybondPolicyReloadBindConfig, policyFilePath: string): PaybondPolicyReloadController | undefined;
|
|
25
|
+
private startFileWatch;
|
|
26
|
+
private startGatewayPoll;
|
|
27
|
+
private triggerReload;
|
|
28
|
+
stop(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { watch } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
const DEFAULT_WATCH_DEBOUNCE_MS = 500;
|
|
4
|
+
const DEFAULT_POLL_INTERVAL_MS = 60_000;
|
|
5
|
+
/** Background file watcher and Gateway poll scheduler for policy hot-reload. */
|
|
6
|
+
export class PaybondPolicyReloadController {
|
|
7
|
+
runner;
|
|
8
|
+
fileWatcher;
|
|
9
|
+
pollTimer;
|
|
10
|
+
debounceTimer;
|
|
11
|
+
reloadInFlight = false;
|
|
12
|
+
policyFilePath;
|
|
13
|
+
reloadDefaults;
|
|
14
|
+
state;
|
|
15
|
+
constructor(runner, options) {
|
|
16
|
+
this.runner = runner;
|
|
17
|
+
this.policyFilePath = options.policyFilePath;
|
|
18
|
+
this.reloadDefaults = options.reloadDefaults;
|
|
19
|
+
this.state = options.state;
|
|
20
|
+
}
|
|
21
|
+
static start(runner, config, policyFilePath) {
|
|
22
|
+
const watchEnabled = config.watch === true || typeof config.watch === "object";
|
|
23
|
+
const pollEnabled = config.poll !== undefined;
|
|
24
|
+
if (!watchEnabled && !pollEnabled) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const resolvedPath = resolve(policyFilePath);
|
|
28
|
+
const reloadDefaults = {
|
|
29
|
+
file: resolvedPath,
|
|
30
|
+
remote: config.poll?.remote,
|
|
31
|
+
resolveInheritance: config.poll?.resolveInheritance,
|
|
32
|
+
gateway: config.poll?.gateway,
|
|
33
|
+
};
|
|
34
|
+
const controller = new PaybondPolicyReloadController(runner, {
|
|
35
|
+
policyFilePath: resolvedPath,
|
|
36
|
+
reloadDefaults,
|
|
37
|
+
state: {
|
|
38
|
+
watch: watchEnabled,
|
|
39
|
+
poll: pollEnabled,
|
|
40
|
+
policyFilePath: resolvedPath,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
if (watchEnabled) {
|
|
44
|
+
controller.startFileWatch(config.watch);
|
|
45
|
+
}
|
|
46
|
+
if (pollEnabled) {
|
|
47
|
+
controller.startGatewayPoll(config.poll ?? {});
|
|
48
|
+
}
|
|
49
|
+
return controller;
|
|
50
|
+
}
|
|
51
|
+
startFileWatch(watchConfig) {
|
|
52
|
+
const debounceMs = typeof watchConfig === "object" && watchConfig.debounceMs !== undefined
|
|
53
|
+
? watchConfig.debounceMs
|
|
54
|
+
: DEFAULT_WATCH_DEBOUNCE_MS;
|
|
55
|
+
this.fileWatcher = watch(this.policyFilePath, () => {
|
|
56
|
+
if (this.debounceTimer) {
|
|
57
|
+
clearTimeout(this.debounceTimer);
|
|
58
|
+
}
|
|
59
|
+
this.debounceTimer = setTimeout(() => {
|
|
60
|
+
void this.triggerReload({ remote: false });
|
|
61
|
+
}, debounceMs);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
startGatewayPoll(pollConfig) {
|
|
65
|
+
const intervalMs = pollConfig.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
66
|
+
this.pollTimer = setInterval(() => {
|
|
67
|
+
void this.triggerReload({
|
|
68
|
+
remote: pollConfig.remote ?? true,
|
|
69
|
+
resolveInheritance: pollConfig.resolveInheritance ?? true,
|
|
70
|
+
gateway: pollConfig.gateway ?? this.reloadDefaults.gateway,
|
|
71
|
+
});
|
|
72
|
+
}, intervalMs);
|
|
73
|
+
}
|
|
74
|
+
async triggerReload(overrides) {
|
|
75
|
+
if (this.reloadInFlight) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.reloadInFlight = true;
|
|
79
|
+
try {
|
|
80
|
+
const result = await this.runner.reloadPolicy({
|
|
81
|
+
...this.reloadDefaults,
|
|
82
|
+
...overrides,
|
|
83
|
+
file: this.policyFilePath,
|
|
84
|
+
});
|
|
85
|
+
if (result.applied) {
|
|
86
|
+
this.state.lastReloadAt = new Date().toISOString();
|
|
87
|
+
this.state.lastReloadError = undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
92
|
+
this.state.lastReloadError = message;
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
this.reloadInFlight = false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
stop() {
|
|
99
|
+
if (this.fileWatcher) {
|
|
100
|
+
this.fileWatcher.close();
|
|
101
|
+
this.fileWatcher = undefined;
|
|
102
|
+
}
|
|
103
|
+
if (this.pollTimer) {
|
|
104
|
+
clearInterval(this.pollTimer);
|
|
105
|
+
this.pollTimer = undefined;
|
|
106
|
+
}
|
|
107
|
+
if (this.debounceTimer) {
|
|
108
|
+
clearTimeout(this.debounceTimer);
|
|
109
|
+
this.debounceTimer = undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -4,11 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Tenant-configured settlement rail names. Clients may request a rail, not a destination. */
|
|
6
6
|
export type SettlementRail = "stripe_connect" | "stripe_ach_debit" | "x402_usdc_base";
|
|
7
|
+
export type CompletionContractSnapshot = {
|
|
8
|
+
completionPresetId: string;
|
|
9
|
+
vendorContractProvider?: string;
|
|
10
|
+
vendorApiVersion?: string;
|
|
11
|
+
vendorSchemaDigestHex?: string;
|
|
12
|
+
canonicalSchemaDigestHex: string;
|
|
13
|
+
};
|
|
7
14
|
export declare function intentCreationSignBytesRaw(input: {
|
|
8
15
|
tenantId: string;
|
|
9
16
|
intentId: string;
|
|
10
17
|
principalDid: string;
|
|
11
18
|
payeeDid: string;
|
|
19
|
+
payeePubkeyBytes: Uint8Array;
|
|
12
20
|
amountCents: number;
|
|
13
21
|
currency: string;
|
|
14
22
|
deadlineRfc3339: string;
|
|
@@ -18,13 +26,55 @@ export declare function intentCreationSignBytesRaw(input: {
|
|
|
18
26
|
predicateRef: string;
|
|
19
27
|
allowedTools: string[];
|
|
20
28
|
settlementRail: SettlementRail;
|
|
29
|
+
completionContract?: CompletionContractSnapshot;
|
|
21
30
|
}): Uint8Array;
|
|
31
|
+
export type PolicyBindingRef = {
|
|
32
|
+
templateId: string;
|
|
33
|
+
versionSeq: number;
|
|
34
|
+
};
|
|
35
|
+
export type PublishedPolicyHead = {
|
|
36
|
+
templateId: string;
|
|
37
|
+
versionSeq: number;
|
|
38
|
+
materializedPredicate: Record<string, unknown>;
|
|
39
|
+
policyContentDigestHex: string;
|
|
40
|
+
};
|
|
41
|
+
/** Bincode payload for managed-policy intent creation (wire format revision byte `5`). */
|
|
42
|
+
export declare function intentCreationSignBytesWithPolicyBinding(input: {
|
|
43
|
+
tenantId: string;
|
|
44
|
+
intentId: string;
|
|
45
|
+
principalDid: string;
|
|
46
|
+
payeeDid: string;
|
|
47
|
+
payeePubkeyBytes: Uint8Array;
|
|
48
|
+
amountCents: number;
|
|
49
|
+
currency: string;
|
|
50
|
+
deadlineRfc3339: string;
|
|
51
|
+
budget: Record<string, unknown>;
|
|
52
|
+
evidenceSchema: Record<string, unknown>;
|
|
53
|
+
materializedPredicate: Record<string, unknown>;
|
|
54
|
+
predicateRef: string;
|
|
55
|
+
allowedTools: string[];
|
|
56
|
+
settlementRail: SettlementRail;
|
|
57
|
+
policyBinding: PolicyBindingRef;
|
|
58
|
+
policyContentDigestHex: string;
|
|
59
|
+
completionContract?: CompletionContractSnapshot;
|
|
60
|
+
}): Uint8Array;
|
|
61
|
+
export type BuildSignedCreateIntentWithPolicyBindingParams = Omit<BuildSignedCreateIntentParams, "predicate"> & {
|
|
62
|
+
policyBinding: PolicyBindingRef;
|
|
63
|
+
publishedPolicyHead: PublishedPolicyHead;
|
|
64
|
+
completionPresetId?: string;
|
|
65
|
+
completionContract?: CompletionContractSnapshot;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Build a Harbor `POST /intents` JSON body with signing v5 and a published managed-policy head.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildSignedCreateIntentBodyWithPolicyBinding(params: BuildSignedCreateIntentWithPolicyBindingParams): Record<string, unknown>;
|
|
22
71
|
export type BuildSignedCreateIntentParams = {
|
|
23
72
|
tenantId: string;
|
|
24
73
|
intentId: string;
|
|
25
74
|
principalDid: string;
|
|
26
75
|
principalSigningSeed: Uint8Array;
|
|
27
76
|
payeeDid: string;
|
|
77
|
+
payeeSigningSeed: Uint8Array;
|
|
28
78
|
budget: Record<string, unknown>;
|
|
29
79
|
predicate: Record<string, unknown>;
|
|
30
80
|
currency: string;
|
|
@@ -35,6 +85,8 @@ export type BuildSignedCreateIntentParams = {
|
|
|
35
85
|
predicateRef?: string;
|
|
36
86
|
/** Rail request for the new intent. Harbor resolves the destination server-side. */
|
|
37
87
|
settlementRail: SettlementRail;
|
|
88
|
+
completionPresetId?: string;
|
|
89
|
+
completionContract?: CompletionContractSnapshot;
|
|
38
90
|
};
|
|
39
91
|
/**
|
|
40
92
|
* Build a Harbor `POST /intents` JSON body with principal Ed25519 detached signature.
|