@paybond/kit 0.10.0 → 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.
Files changed (335) hide show
  1. package/completion-presets/catalog.json +1187 -0
  2. package/completion-presets/catalog.sha256 +1 -0
  3. package/dev/trace-ui/dashboard.html +617 -0
  4. package/dist/agent/adapter.d.ts +51 -0
  5. package/dist/agent/adapter.js +66 -0
  6. package/dist/agent/attach-bundle.d.ts +37 -0
  7. package/dist/agent/attach-bundle.js +118 -0
  8. package/dist/agent/authorization-cache.d.ts +22 -0
  9. package/dist/agent/authorization-cache.js +36 -0
  10. package/dist/agent/deferred-tools.d.ts +11 -0
  11. package/dist/agent/deferred-tools.js +62 -0
  12. package/dist/agent/discover.d.ts +41 -0
  13. package/dist/agent/discover.js +147 -0
  14. package/dist/agent/evidence.d.ts +9 -0
  15. package/dist/agent/evidence.js +28 -0
  16. package/dist/agent/facade.d.ts +48 -0
  17. package/dist/agent/facade.js +112 -0
  18. package/dist/agent/gateway-trace-reporter.d.ts +28 -0
  19. package/dist/agent/gateway-trace-reporter.js +49 -0
  20. package/dist/agent/generic-runner.d.ts +14 -0
  21. package/dist/agent/generic-runner.js +49 -0
  22. package/dist/agent/generic-sandbox-demo.d.ts +36 -0
  23. package/dist/agent/generic-sandbox-demo.js +82 -0
  24. package/dist/agent/guarded-agent.d.ts +49 -0
  25. package/dist/agent/guarded-agent.js +100 -0
  26. package/dist/agent/index.d.ts +13 -0
  27. package/dist/agent/index.js +13 -0
  28. package/dist/agent/instrument.d.ts +156 -0
  29. package/dist/agent/instrument.js +442 -0
  30. package/dist/agent/interceptor.d.ts +24 -0
  31. package/dist/agent/interceptor.js +440 -0
  32. package/dist/agent/lazy-context-tools.d.ts +15 -0
  33. package/dist/agent/lazy-context-tools.js +81 -0
  34. package/dist/agent/registry-file.d.ts +39 -0
  35. package/dist/agent/registry-file.js +219 -0
  36. package/dist/agent/registry.d.ts +37 -0
  37. package/dist/agent/registry.js +128 -0
  38. package/dist/agent/run.d.ts +124 -0
  39. package/dist/agent/run.js +301 -0
  40. package/dist/agent/types.d.ts +318 -0
  41. package/dist/agent/types.js +42 -0
  42. package/dist/agent-recognition.d.ts +72 -0
  43. package/dist/agent-recognition.js +165 -0
  44. package/dist/bincode-wire.d.ts +18 -0
  45. package/dist/bincode-wire.js +93 -0
  46. package/dist/claude-agents/config.d.ts +21 -0
  47. package/dist/claude-agents/config.js +145 -0
  48. package/dist/claude-agents/index.d.ts +2 -0
  49. package/dist/claude-agents/index.js +2 -0
  50. package/dist/claude-agents/sandbox-demo.d.ts +30 -0
  51. package/dist/claude-agents/sandbox-demo.js +91 -0
  52. package/dist/cli/agent/env-quote.d.ts +1 -0
  53. package/dist/cli/agent/env-quote.js +6 -0
  54. package/dist/cli/agent/env-write.d.ts +8 -0
  55. package/dist/cli/agent/env-write.js +47 -0
  56. package/dist/cli/agent/paybond.d.ts +16 -0
  57. package/dist/cli/agent/paybond.js +55 -0
  58. package/dist/cli/agent/policy-file.d.ts +29 -0
  59. package/dist/cli/agent/policy-file.js +61 -0
  60. package/dist/cli/agent/production-evidence.d.ts +24 -0
  61. package/dist/cli/agent/production-evidence.js +98 -0
  62. package/dist/cli/agent/run-store.d.ts +30 -0
  63. package/dist/cli/agent/run-store.js +42 -0
  64. package/dist/cli/agent/run-trace-store.d.ts +39 -0
  65. package/dist/cli/agent/run-trace-store.js +143 -0
  66. package/dist/cli/agent-run-trace-table.d.ts +9 -0
  67. package/dist/cli/agent-run-trace-table.js +24 -0
  68. package/dist/cli/agent-sandbox-smoke-checklist.d.ts +9 -0
  69. package/dist/cli/agent-sandbox-smoke-checklist.js +50 -0
  70. package/dist/cli/command-spec.d.ts +1 -0
  71. package/dist/cli/command-spec.js +286 -5
  72. package/dist/cli/commands/agent.d.ts +16 -0
  73. package/dist/cli/commands/agent.js +1135 -0
  74. package/dist/cli/commands/dev.d.ts +7 -0
  75. package/dist/cli/commands/dev.js +348 -0
  76. package/dist/cli/commands/discovery.js +3 -3
  77. package/dist/cli/commands/policy.d.ts +13 -0
  78. package/dist/cli/commands/policy.js +769 -0
  79. package/dist/cli/commands/setup.d.ts +3 -0
  80. package/dist/cli/commands/setup.js +124 -8
  81. package/dist/cli/commands/workflows.js +9 -4
  82. package/dist/cli/config.d.ts +2 -0
  83. package/dist/cli/config.js +4 -2
  84. package/dist/cli/context.js +2 -1
  85. package/dist/cli/credentials.js +2 -2
  86. package/dist/cli/doctor-agent-middleware.d.ts +5 -0
  87. package/dist/cli/doctor-agent-middleware.js +49 -0
  88. package/dist/cli/globals.d.ts +1 -0
  89. package/dist/cli/globals.js +11 -1
  90. package/dist/cli/help.d.ts +1 -1
  91. package/dist/cli/help.js +35 -3
  92. package/dist/cli/mcp-install.js +2 -2
  93. package/dist/cli/mcp-policy.d.ts +3 -0
  94. package/dist/cli/mcp-policy.js +19 -13
  95. package/dist/cli/mcp-verify-config.js +9 -11
  96. package/dist/cli/redact.js +29 -8
  97. package/dist/cli/router.js +105 -2
  98. package/dist/cli/smoke-deep-links.d.ts +15 -0
  99. package/dist/cli/smoke-deep-links.js +63 -0
  100. package/dist/cli/telemetry.d.ts +17 -0
  101. package/dist/cli/telemetry.js +94 -0
  102. package/dist/completion-catalog-digest.d.ts +2 -0
  103. package/dist/completion-catalog-digest.js +2 -0
  104. package/dist/completion-catalog-integrity.d.ts +2 -0
  105. package/dist/completion-catalog-integrity.js +17 -0
  106. package/dist/completion-catalog.d.ts +49 -0
  107. package/dist/completion-catalog.js +62 -0
  108. package/dist/completion-contract-digest.d.ts +37 -0
  109. package/dist/completion-contract-digest.js +73 -0
  110. package/dist/completion-forbidden-fields.d.ts +5 -0
  111. package/dist/completion-forbidden-fields.js +26 -0
  112. package/dist/completion-init.d.ts +8 -0
  113. package/dist/completion-init.js +334 -0
  114. package/dist/completion-resolve.d.ts +21 -0
  115. package/dist/completion-resolve.js +86 -0
  116. package/dist/completion-validate-evidence.d.ts +24 -0
  117. package/dist/completion-validate-evidence.js +145 -0
  118. package/dist/dev/offline-gateway.d.ts +24 -0
  119. package/dist/dev/offline-gateway.js +102 -0
  120. package/dist/dev/trace-buffer.d.ts +61 -0
  121. package/dist/dev/trace-buffer.js +330 -0
  122. package/dist/dev/trace-security-headers.d.ts +11 -0
  123. package/dist/dev/trace-security-headers.js +16 -0
  124. package/dist/dev/trace-server.d.ts +8 -0
  125. package/dist/dev/trace-server.js +38 -0
  126. package/dist/dev/trace-ui.d.ts +4 -0
  127. package/dist/dev/trace-ui.js +25 -0
  128. package/dist/dev/wiremock-up.d.ts +15 -0
  129. package/dist/dev/wiremock-up.js +118 -0
  130. package/dist/doctor-completion.d.ts +17 -0
  131. package/dist/doctor-completion.js +428 -0
  132. package/dist/gateway-url.d.ts +7 -0
  133. package/dist/gateway-url.js +69 -0
  134. package/dist/index.d.ts +119 -2
  135. package/dist/index.js +267 -6
  136. package/dist/init.js +374 -57
  137. package/dist/langgraph/awrap-tool-call.d.ts +25 -0
  138. package/dist/langgraph/awrap-tool-call.js +81 -0
  139. package/dist/langgraph/config.d.ts +13 -0
  140. package/dist/langgraph/config.js +11 -0
  141. package/dist/langgraph/index.d.ts +4 -0
  142. package/dist/langgraph/index.js +4 -0
  143. package/dist/langgraph/sandbox-demo.d.ts +40 -0
  144. package/dist/langgraph/sandbox-demo.js +96 -0
  145. package/dist/langgraph/tool-node.d.ts +10 -0
  146. package/dist/langgraph/tool-node.js +38 -0
  147. package/dist/login.js +7 -0
  148. package/dist/mcp/index.d.ts +1 -0
  149. package/dist/mcp/index.js +1 -0
  150. package/dist/mcp/tool-surface.d.ts +25 -0
  151. package/dist/mcp/tool-surface.js +17 -0
  152. package/dist/mcp-capability-token-cache.d.ts +24 -0
  153. package/dist/mcp-capability-token-cache.js +101 -0
  154. package/dist/mcp-evidence-policy.d.ts +48 -0
  155. package/dist/mcp-evidence-policy.js +117 -0
  156. package/dist/mcp-policy-reload.d.ts +79 -0
  157. package/dist/mcp-policy-reload.js +200 -0
  158. package/dist/mcp-sep2828-evidence.d.ts +36 -0
  159. package/dist/mcp-sep2828-evidence.js +65 -0
  160. package/dist/mcp-server.d.ts +6 -0
  161. package/dist/mcp-server.js +224 -44
  162. package/dist/openai-agents/index.d.ts +40 -0
  163. package/dist/openai-agents/index.js +151 -0
  164. package/dist/openai-agents/sandbox-demo.d.ts +34 -0
  165. package/dist/openai-agents/sandbox-demo.js +118 -0
  166. package/dist/payee-evidence.js +2 -29
  167. package/dist/policy/catalog.d.ts +31 -0
  168. package/dist/policy/catalog.js +48 -0
  169. package/dist/policy/compose-utils.d.ts +3 -0
  170. package/dist/policy/compose-utils.js +4 -0
  171. package/dist/policy/compose.d.ts +20 -0
  172. package/dist/policy/compose.js +240 -0
  173. package/dist/policy/digest.d.ts +7 -0
  174. package/dist/policy/digest.js +75 -0
  175. package/dist/policy/domain.d.ts +15 -0
  176. package/dist/policy/domain.js +28 -0
  177. package/dist/policy/guardrail-spec.d.ts +17 -0
  178. package/dist/policy/guardrail-spec.js +140 -0
  179. package/dist/policy/guardrails.d.ts +48 -0
  180. package/dist/policy/guardrails.js +72 -0
  181. package/dist/policy/index.d.ts +21 -0
  182. package/dist/policy/index.js +21 -0
  183. package/dist/policy/init.d.ts +102 -0
  184. package/dist/policy/init.js +351 -0
  185. package/dist/policy/intent-spec.d.ts +52 -0
  186. package/dist/policy/intent-spec.js +176 -0
  187. package/dist/policy/json-path.d.ts +4 -0
  188. package/dist/policy/json-path.js +23 -0
  189. package/dist/policy/layers-io.d.ts +7 -0
  190. package/dist/policy/layers-io.js +28 -0
  191. package/dist/policy/load-effective.d.ts +22 -0
  192. package/dist/policy/load-effective.js +77 -0
  193. package/dist/policy/load.d.ts +85 -0
  194. package/dist/policy/load.js +164 -0
  195. package/dist/policy/merge.d.ts +29 -0
  196. package/dist/policy/merge.js +297 -0
  197. package/dist/policy/parse-text.d.ts +2 -0
  198. package/dist/policy/parse-text.js +126 -0
  199. package/dist/policy/policy-api.d.ts +45 -0
  200. package/dist/policy/policy-api.js +61 -0
  201. package/dist/policy/presets.d.ts +19 -0
  202. package/dist/policy/presets.js +66 -0
  203. package/dist/policy/registry.d.ts +7 -0
  204. package/dist/policy/registry.js +33 -0
  205. package/dist/policy/reload.d.ts +86 -0
  206. package/dist/policy/reload.js +233 -0
  207. package/dist/policy/render-yaml.d.ts +3 -0
  208. package/dist/policy/render-yaml.js +69 -0
  209. package/dist/policy/sandbox-bootstrap.d.ts +19 -0
  210. package/dist/policy/sandbox-bootstrap.js +66 -0
  211. package/dist/policy/schema.d.ts +204 -0
  212. package/dist/policy/schema.js +255 -0
  213. package/dist/policy/snapshot.d.ts +33 -0
  214. package/dist/policy/snapshot.js +23 -0
  215. package/dist/policy/validate-remote.d.ts +43 -0
  216. package/dist/policy/validate-remote.js +104 -0
  217. package/dist/policy/validate.d.ts +36 -0
  218. package/dist/policy/validate.js +150 -0
  219. package/dist/policy/watcher.d.ts +29 -0
  220. package/dist/policy/watcher.js +112 -0
  221. package/dist/principal-intent.d.ts +52 -0
  222. package/dist/principal-intent.js +193 -37
  223. package/dist/project-init.d.ts +34 -0
  224. package/dist/project-init.js +898 -0
  225. package/dist/sep2828-signature.d.ts +10 -0
  226. package/dist/sep2828-signature.js +134 -0
  227. package/dist/solutions/api.d.ts +22 -0
  228. package/dist/solutions/api.js +40 -0
  229. package/dist/solutions/catalog.d.ts +34 -0
  230. package/dist/solutions/catalog.js +129 -0
  231. package/dist/solutions/index.d.ts +2 -0
  232. package/dist/solutions/index.js +2 -0
  233. package/dist/template-init.d.ts +54 -0
  234. package/dist/template-init.js +203 -0
  235. package/dist/vercel-ai/config.d.ts +15 -0
  236. package/dist/vercel-ai/config.js +13 -0
  237. package/dist/vercel-ai/index.d.ts +4 -0
  238. package/dist/vercel-ai/index.js +4 -0
  239. package/dist/vercel-ai/sandbox-demo.d.ts +44 -0
  240. package/dist/vercel-ai/sandbox-demo.js +153 -0
  241. package/dist/vercel-ai/tool-approval.d.ts +16 -0
  242. package/dist/vercel-ai/tool-approval.js +41 -0
  243. package/dist/vercel-ai/wrap-tools.d.ts +9 -0
  244. package/dist/vercel-ai/wrap-tools.js +40 -0
  245. package/dist/x402-receipt-evidence.d.ts +29 -0
  246. package/dist/x402-receipt-evidence.js +97 -0
  247. package/dist/x402-receipt-signature.d.ts +12 -0
  248. package/dist/x402-receipt-signature.js +211 -0
  249. package/package.json +75 -3
  250. package/solutions/aws.json +17 -0
  251. package/solutions/saas.json +17 -0
  252. package/solutions/shopping.json +17 -0
  253. package/solutions/travel.json +18 -0
  254. package/templates/manifest.json +169 -0
  255. package/templates/openai-shopping-agent/.env.example +3 -0
  256. package/templates/openai-shopping-agent/.github/workflows/smoke.yml +20 -0
  257. package/templates/openai-shopping-agent/LICENSE +201 -0
  258. package/templates/openai-shopping-agent/README.md +29 -0
  259. package/templates/openai-shopping-agent/package.json +22 -0
  260. package/templates/openai-shopping-agent/paybond.policy.yaml +22 -0
  261. package/templates/openai-shopping-agent/src/index.ts +22 -0
  262. package/templates/openai-shopping-agent/src/paybond.config.ts +51 -0
  263. package/templates/openai-shopping-agent/tsconfig.json +13 -0
  264. package/templates/paybond-aws-operator/.env.example +3 -0
  265. package/templates/paybond-aws-operator/.github/workflows/smoke.yml +20 -0
  266. package/templates/paybond-aws-operator/LICENSE +201 -0
  267. package/templates/paybond-aws-operator/README.md +29 -0
  268. package/templates/paybond-aws-operator/package.json +20 -0
  269. package/templates/paybond-aws-operator/paybond.policy.yaml +22 -0
  270. package/templates/paybond-aws-operator/src/index.ts +54 -0
  271. package/templates/paybond-aws-operator/src/paybond.config.ts +51 -0
  272. package/templates/paybond-aws-operator/tsconfig.json +13 -0
  273. package/templates/paybond-claude-agents-demo/.env.example +3 -0
  274. package/templates/paybond-claude-agents-demo/.github/workflows/smoke.yml +20 -0
  275. package/templates/paybond-claude-agents-demo/LICENSE +201 -0
  276. package/templates/paybond-claude-agents-demo/README.md +29 -0
  277. package/templates/paybond-claude-agents-demo/package.json +22 -0
  278. package/templates/paybond-claude-agents-demo/paybond.policy.yaml +22 -0
  279. package/templates/paybond-claude-agents-demo/src/index.ts +22 -0
  280. package/templates/paybond-claude-agents-demo/src/paybond.config.ts +51 -0
  281. package/templates/paybond-claude-agents-demo/tsconfig.json +13 -0
  282. package/templates/paybond-invoice-agent/.env.example +3 -0
  283. package/templates/paybond-invoice-agent/.github/workflows/smoke.yml +19 -0
  284. package/templates/paybond-invoice-agent/LICENSE +201 -0
  285. package/templates/paybond-invoice-agent/README.md +29 -0
  286. package/templates/paybond-invoice-agent/app.py +27 -0
  287. package/templates/paybond-invoice-agent/package.json +6 -0
  288. package/templates/paybond-invoice-agent/paybond.policy.yaml +22 -0
  289. package/templates/paybond-invoice-agent/paybond_config.py +45 -0
  290. package/templates/paybond-invoice-agent/requirements.txt +2 -0
  291. package/templates/paybond-mcp-coding-agent/.env.example +3 -0
  292. package/templates/paybond-mcp-coding-agent/.github/workflows/smoke.yml +20 -0
  293. package/templates/paybond-mcp-coding-agent/LICENSE +201 -0
  294. package/templates/paybond-mcp-coding-agent/README.md +39 -0
  295. package/templates/paybond-mcp-coding-agent/package.json +20 -0
  296. package/templates/paybond-mcp-coding-agent/paybond.policy.yaml +25 -0
  297. package/templates/paybond-mcp-coding-agent/src/index.ts +40 -0
  298. package/templates/paybond-mcp-coding-agent/src/paybond.config.ts +51 -0
  299. package/templates/paybond-mcp-coding-agent/tsconfig.json +13 -0
  300. package/templates/paybond-openai-agents-demo/.env.example +3 -0
  301. package/templates/paybond-openai-agents-demo/.github/workflows/smoke.yml +20 -0
  302. package/templates/paybond-openai-agents-demo/LICENSE +201 -0
  303. package/templates/paybond-openai-agents-demo/README.md +29 -0
  304. package/templates/paybond-openai-agents-demo/package.json +22 -0
  305. package/templates/paybond-openai-agents-demo/paybond.policy.yaml +22 -0
  306. package/templates/paybond-openai-agents-demo/src/index.ts +22 -0
  307. package/templates/paybond-openai-agents-demo/src/paybond.config.ts +51 -0
  308. package/templates/paybond-openai-agents-demo/tsconfig.json +13 -0
  309. package/templates/paybond-procurement-agent/.env.example +3 -0
  310. package/templates/paybond-procurement-agent/.github/workflows/smoke.yml +20 -0
  311. package/templates/paybond-procurement-agent/LICENSE +201 -0
  312. package/templates/paybond-procurement-agent/README.md +29 -0
  313. package/templates/paybond-procurement-agent/package.json +20 -0
  314. package/templates/paybond-procurement-agent/paybond.policy.yaml +25 -0
  315. package/templates/paybond-procurement-agent/src/index.ts +54 -0
  316. package/templates/paybond-procurement-agent/src/paybond.config.ts +51 -0
  317. package/templates/paybond-procurement-agent/tsconfig.json +13 -0
  318. package/templates/paybond-travel-agent/.env.example +3 -0
  319. package/templates/paybond-travel-agent/.github/workflows/smoke.yml +20 -0
  320. package/templates/paybond-travel-agent/LICENSE +201 -0
  321. package/templates/paybond-travel-agent/README.md +29 -0
  322. package/templates/paybond-travel-agent/package.json +23 -0
  323. package/templates/paybond-travel-agent/paybond.policy.yaml +22 -0
  324. package/templates/paybond-travel-agent/src/index.ts +22 -0
  325. package/templates/paybond-travel-agent/src/paybond.config.ts +51 -0
  326. package/templates/paybond-travel-agent/tsconfig.json +13 -0
  327. package/templates/paybond-vercel-shopping-agent/.env.example +3 -0
  328. package/templates/paybond-vercel-shopping-agent/.github/workflows/smoke.yml +20 -0
  329. package/templates/paybond-vercel-shopping-agent/LICENSE +201 -0
  330. package/templates/paybond-vercel-shopping-agent/README.md +29 -0
  331. package/templates/paybond-vercel-shopping-agent/package.json +22 -0
  332. package/templates/paybond-vercel-shopping-agent/paybond.policy.yaml +22 -0
  333. package/templates/paybond-vercel-shopping-agent/src/index.ts +22 -0
  334. package/templates/paybond-vercel-shopping-agent/src/paybond.config.ts +51 -0
  335. package/templates/paybond-vercel-shopping-agent/tsconfig.json +13 -0
@@ -0,0 +1,37 @@
1
+ /**
2
+ * BLAKE3 digests for completion preset vendor_contract schema pinning.
3
+ * Matches `paybond-evidence::json_value_digest` and Harbor signing digests.
4
+ */
5
+ import type { CompletionPreset } from "./completion-catalog.js";
6
+ export type VendorContract = {
7
+ provider: "stripe" | "x402" | "mcp" | "generic";
8
+ api_version: string;
9
+ contract_kind: "json_schema" | "openapi_fragment" | "mapper_version";
10
+ schema_digest_hex: string;
11
+ canonical_schema_digest_hex: string;
12
+ quality_fields: string[];
13
+ supersedes?: string;
14
+ migration_notes?: string;
15
+ };
16
+ export type VendorContractDigests = {
17
+ schema_digest_hex: string;
18
+ canonical_schema_digest_hex: string;
19
+ };
20
+ /** Hex-encode a 32-byte BLAKE3 digest. */
21
+ export declare function digestToHex(digest: Uint8Array): string;
22
+ /** BLAKE3 hex digest of JCS-canonical JSON for a completion evidence schema object. */
23
+ export declare function completionSchemaDigestHex(schema: Record<string, unknown>): string;
24
+ /** Compute vendor and canonical schema digests for a vendor_pack preset. */
25
+ export declare function computeVendorContractDigests(preset: {
26
+ vendor_evidence_schema: Record<string, unknown>;
27
+ evidence_schema: Record<string, unknown>;
28
+ }): VendorContractDigests;
29
+ /**
30
+ * Assert catalog-declared vendor_contract digests and quality_fields match computed values.
31
+ * @throws when a vendor_pack contract is missing, stale, or references unknown quality fields.
32
+ */
33
+ export declare function verifyVendorContract(preset: CompletionPreset): void;
34
+ /** Verify all vendor_pack presets in a catalog document. */
35
+ export declare function verifyCatalogVendorContracts(catalog: {
36
+ presets: CompletionPreset[];
37
+ }): void;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * BLAKE3 digests for completion preset vendor_contract schema pinning.
3
+ * Matches `paybond-evidence::json_value_digest` and Harbor signing digests.
4
+ */
5
+ import { jsonValueDigest } from "./json-digest.js";
6
+ /** Hex-encode a 32-byte BLAKE3 digest. */
7
+ export function digestToHex(digest) {
8
+ return Buffer.from(digest).toString("hex");
9
+ }
10
+ /** BLAKE3 hex digest of JCS-canonical JSON for a completion evidence schema object. */
11
+ export function completionSchemaDigestHex(schema) {
12
+ return digestToHex(jsonValueDigest(schema));
13
+ }
14
+ /** Compute vendor and canonical schema digests for a vendor_pack preset. */
15
+ export function computeVendorContractDigests(preset) {
16
+ return {
17
+ schema_digest_hex: completionSchemaDigestHex(preset.vendor_evidence_schema),
18
+ canonical_schema_digest_hex: completionSchemaDigestHex(preset.evidence_schema),
19
+ };
20
+ }
21
+ function vendorSchemaFieldNames(schema) {
22
+ const props = schema.properties;
23
+ if (!props || typeof props !== "object" || Array.isArray(props)) {
24
+ return new Set();
25
+ }
26
+ return new Set(Object.keys(props));
27
+ }
28
+ /**
29
+ * Assert catalog-declared vendor_contract digests and quality_fields match computed values.
30
+ * @throws when a vendor_pack contract is missing, stale, or references unknown quality fields.
31
+ */
32
+ export function verifyVendorContract(preset) {
33
+ if (preset.kind !== "vendor_pack") {
34
+ return;
35
+ }
36
+ const presetId = preset.preset_id;
37
+ const contract = preset.vendor_contract;
38
+ if (!contract) {
39
+ throw new Error(`${presetId}: vendor_pack missing vendor_contract`);
40
+ }
41
+ if (!preset.vendor_evidence_schema || !preset.evidence_schema) {
42
+ throw new Error(`${presetId}: vendor_pack missing evidence schemas`);
43
+ }
44
+ const computed = computeVendorContractDigests({
45
+ vendor_evidence_schema: preset.vendor_evidence_schema,
46
+ evidence_schema: preset.evidence_schema,
47
+ });
48
+ if (contract.schema_digest_hex !== computed.schema_digest_hex) {
49
+ throw new Error(`${presetId}: vendor_contract.schema_digest_hex mismatch (catalog=${contract.schema_digest_hex}, computed=${computed.schema_digest_hex})`);
50
+ }
51
+ if (contract.canonical_schema_digest_hex !== computed.canonical_schema_digest_hex) {
52
+ throw new Error(`${presetId}: vendor_contract.canonical_schema_digest_hex mismatch (catalog=${contract.canonical_schema_digest_hex}, computed=${computed.canonical_schema_digest_hex})`);
53
+ }
54
+ if (!contract.quality_fields?.length) {
55
+ throw new Error(`${presetId}: vendor_contract.quality_fields must be non-empty`);
56
+ }
57
+ const allowed = vendorSchemaFieldNames(preset.vendor_evidence_schema);
58
+ for (const field of contract.quality_fields) {
59
+ if (!allowed.has(field)) {
60
+ throw new Error(`${presetId}: quality_fields entry ${JSON.stringify(field)} is not a vendor_evidence_schema property`);
61
+ }
62
+ }
63
+ }
64
+ /** Verify all vendor_pack presets in a catalog document. */
65
+ export function verifyCatalogVendorContracts(catalog) {
66
+ const vendorPacks = catalog.presets.filter((preset) => preset.kind === "vendor_pack");
67
+ if (vendorPacks.length === 0) {
68
+ throw new Error("catalog must contain at least one vendor_pack preset");
69
+ }
70
+ for (const preset of vendorPacks) {
71
+ verifyVendorContract(preset);
72
+ }
73
+ }
@@ -0,0 +1,5 @@
1
+ import type { CompletionPreset } from "./completion-catalog.js";
2
+ /** Returns top-level evidence keys that intersect the preset forbidden list. */
3
+ export declare function forbiddenFieldsInEvidence(evidence: Record<string, unknown> | undefined, forbidden: string[] | undefined): string[];
4
+ /** Checks vendor keys and their mapped canonical names against forbidden fields. */
5
+ export declare function forbiddenFieldsInVendorPayload(preset: CompletionPreset, vendorPayload: Record<string, unknown> | undefined, forbidden: string[] | undefined): string[];
@@ -0,0 +1,26 @@
1
+ /** Returns top-level evidence keys that intersect the preset forbidden list. */
2
+ export function forbiddenFieldsInEvidence(evidence, forbidden) {
3
+ if (!evidence || !forbidden?.length) {
4
+ return [];
5
+ }
6
+ const blocked = new Set(forbidden);
7
+ return Object.keys(evidence).filter((key) => blocked.has(key));
8
+ }
9
+ /** Checks vendor keys and their mapped canonical names against forbidden fields. */
10
+ export function forbiddenFieldsInVendorPayload(preset, vendorPayload, forbidden) {
11
+ if (!vendorPayload || !forbidden?.length) {
12
+ return [];
13
+ }
14
+ const blocked = new Set(forbidden);
15
+ const fieldMap = preset.evidence_field_map ?? {};
16
+ const hits = [];
17
+ for (const vendorKey of Object.keys(vendorPayload)) {
18
+ const canonicalKey = fieldMap[vendorKey] ?? vendorKey;
19
+ if (blocked.has(vendorKey) || blocked.has(canonicalKey)) {
20
+ if (!hits.includes(vendorKey)) {
21
+ hits.push(vendorKey);
22
+ }
23
+ }
24
+ }
25
+ return hits;
26
+ }
@@ -0,0 +1,8 @@
1
+ export type CompletionInitOptions = {
2
+ preset: string;
3
+ out: string;
4
+ force: boolean;
5
+ };
6
+ export declare function parseCompletionInitArgs(argv: string[]): CompletionInitOptions | "help";
7
+ export declare function scaffoldCompletionInit(options: CompletionInitOptions): Promise<void>;
8
+ export declare function runCompletionInit(argv: string[]): Promise<number>;
@@ -0,0 +1,334 @@
1
+ import fs from "node:fs/promises";
2
+ import { getCompletionPreset, jsonLiteral, listCompletionPresetIds, } from "./completion-catalog.js";
3
+ import { isVendorPack, resolveCompletionPreset, vendorEvidenceSchema, } from "./completion-resolve.js";
4
+ function usage() {
5
+ const presets = listCompletionPresetIds().join("|");
6
+ return [
7
+ `Usage: paybond init completion --preset <${presets}> [--out <path>] [--force]`,
8
+ "",
9
+ "Scaffolds a completion evidence helper aligned with the shared preset catalog.",
10
+ ].join("\n");
11
+ }
12
+ export function parseCompletionInitArgs(argv) {
13
+ let preset = "";
14
+ let out = "";
15
+ let force = false;
16
+ for (let i = 0; i < argv.length; i += 1) {
17
+ const arg = argv[i];
18
+ if (arg === "--help" || arg === "-h") {
19
+ return "help";
20
+ }
21
+ if (arg === "--force") {
22
+ force = true;
23
+ continue;
24
+ }
25
+ if (arg === "--preset") {
26
+ const raw = argv[i + 1];
27
+ i += 1;
28
+ if (!raw || !listCompletionPresetIds().includes(raw)) {
29
+ throw new Error("invalid --preset");
30
+ }
31
+ preset = raw;
32
+ continue;
33
+ }
34
+ if (arg === "--out") {
35
+ const raw = argv[i + 1];
36
+ i += 1;
37
+ if (!raw || raw.startsWith("-")) {
38
+ throw new Error("invalid --out");
39
+ }
40
+ out = raw;
41
+ continue;
42
+ }
43
+ throw new Error(`unknown argument: ${arg}`);
44
+ }
45
+ if (!preset) {
46
+ throw new Error("missing --preset");
47
+ }
48
+ if (!out) {
49
+ out = preset === "cost_and_completion"
50
+ ? "paybond-paid-tool-guard.ts"
51
+ : `paybond-completion-${preset.replaceAll("_", "-")}.ts`;
52
+ }
53
+ return { preset, out, force };
54
+ }
55
+ function schemaPropertyToTsType(schema) {
56
+ const type = schema.type;
57
+ if (type === "integer" || type === "number") {
58
+ return "number";
59
+ }
60
+ if (type === "array") {
61
+ const items = schema.items;
62
+ if (items?.type === "string") {
63
+ return "string[]";
64
+ }
65
+ return "unknown[]";
66
+ }
67
+ return "string";
68
+ }
69
+ function buildTsFieldLines(schema) {
70
+ const properties = (schema.properties ?? {});
71
+ const required = Array.isArray(schema.required)
72
+ ? schema.required
73
+ : Object.keys(properties);
74
+ return required.map((field) => {
75
+ const prop = properties[field] ?? { type: "string" };
76
+ return ` ${field}: ${schemaPropertyToTsType(prop)};`;
77
+ });
78
+ }
79
+ function buildTsFieldLinesFromPreset(preset) {
80
+ const vendorSchema = vendorEvidenceSchema(preset);
81
+ if (isVendorPack(preset) && vendorSchema) {
82
+ return buildTsFieldLines(vendorSchema);
83
+ }
84
+ return buildTsFieldLines(preset.evidence_schema);
85
+ }
86
+ function evidenceFieldComments(preset) {
87
+ const vendorSchema = vendorEvidenceSchema(preset);
88
+ const schemaForRequired = vendorSchema ?? preset.evidence_schema;
89
+ const required = Array.isArray(schemaForRequired.required)
90
+ ? schemaForRequired.required
91
+ : [];
92
+ const lines = [
93
+ `// Preset: ${preset.preset_id} (${preset.title})`,
94
+ isVendorPack(preset)
95
+ ? `// Vendor pack over archetype: ${preset.archetype_preset_id}`
96
+ : `// Harbor template: ${preset.harbor_template_id}`,
97
+ `// ${preset.human_summary}`,
98
+ "// Map each paid-tool operation to the evidence fields below before submitSandboxEvidence(...).",
99
+ ];
100
+ if (required.length > 0) {
101
+ lines.push(`// Required evidence fields: ${required.join(", ")}`);
102
+ }
103
+ lines.push("// Sandbox: bootstrap with completionPreset to evaluate a strong Harbor predicate on evidence submit.", "// Production: publish the managed template head, then create intents with policy_binding (signing v5).", `// paybond policy templates`, `// paybond policy preview --template ${preset.harbor_template_id} --parameters-file parameters.json --evidence-file evidence.json`);
104
+ return lines;
105
+ }
106
+ function typescriptTemplate(preset) {
107
+ const resolved = resolveCompletionPreset(preset.preset_id);
108
+ const fieldLines = buildTsFieldLinesFromPreset(preset);
109
+ const comments = evidenceFieldComments(preset).join("\n");
110
+ const sampleEvidence = jsonLiteral(isVendorPack(preset) && preset.vendor_sample_evidence
111
+ ? preset.vendor_sample_evidence
112
+ : preset.sample_evidence, 2);
113
+ const evidenceSchema = jsonLiteral(preset.evidence_schema, 2);
114
+ const parameters = jsonLiteral(resolved.parameters, 2);
115
+ const vendorContractExports = isVendorPack(preset) && preset.vendor_contract
116
+ ? `
117
+ export const VENDOR_CONTRACT_API_VERSION = "${preset.vendor_contract.api_version}";
118
+ export const VENDOR_SCHEMA_DIGEST_HEX = "${preset.vendor_contract.schema_digest_hex}";
119
+ export const CANONICAL_SCHEMA_DIGEST_HEX = "${preset.vendor_contract.canonical_schema_digest_hex}";
120
+ export const VENDOR_QUALITY_FIELDS = ${jsonLiteral(preset.vendor_contract.quality_fields, 2)} as const;
121
+ `
122
+ : "";
123
+ const vendorPackHelpers = isVendorPack(preset)
124
+ ? `
125
+ export type VendorEvidence = {
126
+ ${fieldLines.join("\n")}
127
+ };
128
+
129
+ export function mapVendorEvidenceToCanonical(fields: VendorEvidence): CompletionEvidence {
130
+ return mapVendorEvidenceFields(fields) as CompletionEvidence;
131
+ }
132
+
133
+ function mapVendorEvidenceFields(fields: VendorEvidence): Record<string, unknown> {
134
+ const fieldMap: Record<string, string> = ${jsonLiteral(preset.evidence_field_map ?? {}, 2)};
135
+ const out: Record<string, unknown> = {};
136
+ for (const [vendorKey, value] of Object.entries(fields)) {
137
+ const canonicalKey = fieldMap[vendorKey] ?? vendorKey;
138
+ out[canonicalKey] = value;
139
+ }
140
+ return out;
141
+ }
142
+ `
143
+ : "";
144
+ const buildFn = isVendorPack(preset)
145
+ ? `export function buildCompletionEvidence(fields: VendorEvidence): Record<string, unknown> {
146
+ return mapVendorEvidenceToCanonical(fields);
147
+ }`
148
+ : `export function buildCompletionEvidence(fields: CompletionEvidence): Record<string, unknown> {
149
+ return { ...fields };
150
+ }`;
151
+ return `import fs from "node:fs/promises";
152
+ import {
153
+ Paybond,
154
+ type SandboxGuardrailBootstrapResult,
155
+ type SandboxGuardrailEvidenceResult,
156
+ } from "@paybond/kit";
157
+
158
+ declare const process: {
159
+ env: Record<string, string | undefined>;
160
+ };
161
+
162
+ ${comments}
163
+
164
+ export const COMPLETION_PRESET_ID = "${preset.preset_id}";
165
+ export const HARBOR_TEMPLATE_ID = "${resolved.harborTemplateId}";
166
+ ${isVendorPack(preset) ? `export const ARCHETYPE_PRESET_ID = "${preset.archetype_preset_id}";` : ""}
167
+ ${vendorContractExports}
168
+
169
+ export const completionEvidenceSchema = ${evidenceSchema} as const;
170
+
171
+ export const completionTemplateParameters = ${parameters} as const;
172
+
173
+ export const sampleCompletionEvidence = ${sampleEvidence} as const;
174
+
175
+ export type CompletionEvidence = {
176
+ ${buildTsFieldLines(preset.evidence_schema).join("\n")}
177
+ };
178
+ ${vendorPackHelpers}
179
+ ${buildFn}
180
+
181
+ // Production: use buildSignedCreateIntentBodyWithPolicyBinding from @paybond/kit after publishing ${preset.harbor_template_id}.
182
+ export const policyBindingStub = {
183
+ template_id: HARBOR_TEMPLATE_ID,
184
+ parameters: completionTemplateParameters,
185
+ // head_seq and digest_hex are assigned after: paybond policy publish ...
186
+ };
187
+
188
+ const DEFAULT_OPERATION = "paid_tool.operation";
189
+ const DEFAULT_REQUESTED_SPEND_CENTS = ${preset.recommended_amount_cents ?? 500};
190
+
191
+ export type SubmitCompletionEvidenceOptions = {
192
+ operation?: string;
193
+ requestedSpendCents?: number;
194
+ metadata?: Record<string, unknown>;
195
+ artifacts?: string[];
196
+ idempotencyKey?: string;
197
+ };
198
+
199
+ function readEnvValue(body: string, key: string): string | undefined {
200
+ const pattern = new RegExp("^\\\\s*(?:export\\\\s+)?" + key + "\\\\s*=\\\\s*(.*)$", "m");
201
+ const match = body.match(pattern);
202
+ if (!match) return undefined;
203
+ let value = (match[1] ?? "").trim();
204
+ if (value.startsWith('"') && value.endsWith('"')) {
205
+ try {
206
+ value = JSON.parse(value);
207
+ } catch {
208
+ value = value.slice(1, -1);
209
+ }
210
+ } else if (value.startsWith("'") && value.endsWith("'")) {
211
+ value = value.slice(1, -1);
212
+ }
213
+ return value.trim() || undefined;
214
+ }
215
+
216
+ async function readTextFile(envFile: string): Promise<string | undefined> {
217
+ try {
218
+ return await fs.readFile(envFile, "utf8");
219
+ } catch (err) {
220
+ if ((err as { code?: unknown })?.code === "ENOENT") return undefined;
221
+ throw err;
222
+ }
223
+ }
224
+
225
+ export async function loadPaybondEnvFile(envFile = ".env.local"): Promise<void> {
226
+ if (process.env.PAYBOND_API_KEY?.trim()) return;
227
+ const body = await readTextFile(envFile);
228
+ if (body === undefined) return;
229
+ const apiKey = readEnvValue(body, "PAYBOND_API_KEY");
230
+ if (apiKey) {
231
+ process.env.PAYBOND_API_KEY = apiKey;
232
+ }
233
+ }
234
+
235
+ export async function openPaybondFromEnv(envFile = ".env.local"): Promise<Paybond> {
236
+ await loadPaybondEnvFile(envFile);
237
+ const apiKey = process.env.PAYBOND_API_KEY?.trim();
238
+ if (!apiKey) {
239
+ throw new Error("PAYBOND_API_KEY is required; run paybond login or configure your agent host to pass it");
240
+ }
241
+ return Paybond.open({
242
+ apiKey,
243
+ gatewayBaseUrl: process.env.PAYBOND_GATEWAY_URL ?? process.env.PAYBOND_GATEWAY_BASE_URL,
244
+ expectedEnvironment: "sandbox",
245
+ });
246
+ }
247
+
248
+ export async function bootstrapSandboxGuardrailIntent(
249
+ paybond: Paybond,
250
+ options: {
251
+ operation?: string;
252
+ requestedSpendCents?: number;
253
+ currency?: string;
254
+ metadata?: Record<string, unknown>;
255
+ idempotencyKey?: string;
256
+ } = {},
257
+ ): Promise<SandboxGuardrailBootstrapResult> {
258
+ return paybond.guardrails.bootstrapSandbox({
259
+ operation: options.operation ?? DEFAULT_OPERATION,
260
+ requestedSpendCents: options.requestedSpendCents ?? DEFAULT_REQUESTED_SPEND_CENTS,
261
+ currency: options.currency ?? "usd",
262
+ evidenceSchema: completionEvidenceSchema,
263
+ completionPreset: "${preset.preset_id}",
264
+ metadata: options.metadata,
265
+ idempotencyKey: options.idempotencyKey,
266
+ });
267
+ }
268
+
269
+ export async function submitCompletionEvidence(
270
+ paybond: Paybond,
271
+ guardrail: Pick<SandboxGuardrailBootstrapResult, "intent_id" | "operation" | "requested_spend_cents">,
272
+ evidence: ${isVendorPack(preset) ? "VendorEvidence" : "CompletionEvidence"},
273
+ options: SubmitCompletionEvidenceOptions = {},
274
+ ): Promise<SandboxGuardrailEvidenceResult> {
275
+ return paybond.guardrails.submitSandboxEvidence({
276
+ intentId: guardrail.intent_id,
277
+ payload: buildCompletionEvidence(evidence),
278
+ ${isVendorPack(preset) ? "vendorPayload: { ...evidence }," : ""}
279
+ artifacts: options.artifacts,
280
+ operation: options.operation ?? guardrail.operation,
281
+ requestedSpendCents: options.requestedSpendCents ?? guardrail.requested_spend_cents,
282
+ metadata: options.metadata,
283
+ idempotencyKey: options.idempotencyKey,
284
+ });
285
+ }
286
+ `;
287
+ }
288
+ function renderTemplate(preset) {
289
+ return typescriptTemplate(preset);
290
+ }
291
+ async function writeScaffold(out, body, force) {
292
+ try {
293
+ await fs.stat(out);
294
+ if (!force) {
295
+ throw new Error(`${out} already exists; pass --force to overwrite`);
296
+ }
297
+ }
298
+ catch (err) {
299
+ if (!(err && typeof err === "object" && "code" in err && err.code === "ENOENT")) {
300
+ if (!force) {
301
+ throw err;
302
+ }
303
+ }
304
+ }
305
+ await fs.writeFile(out, body, "utf8");
306
+ }
307
+ export async function scaffoldCompletionInit(options) {
308
+ const preset = getCompletionPreset(options.preset);
309
+ await writeScaffold(options.out, renderTemplate(preset), options.force);
310
+ }
311
+ export async function runCompletionInit(argv) {
312
+ let parsed;
313
+ try {
314
+ const result = parseCompletionInitArgs(argv);
315
+ if (result === "help") {
316
+ process.stdout.write(`${usage()}\n`);
317
+ return 0;
318
+ }
319
+ parsed = result;
320
+ }
321
+ catch (err) {
322
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n\n${usage()}\n`);
323
+ return 1;
324
+ }
325
+ try {
326
+ await scaffoldCompletionInit(parsed);
327
+ }
328
+ catch (err) {
329
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
330
+ return 1;
331
+ }
332
+ process.stdout.write(`Created Paybond completion integration: ${parsed.out}\n`);
333
+ return 0;
334
+ }
@@ -0,0 +1,21 @@
1
+ import { type CompletionPreset } from "./completion-catalog.js";
2
+ export type CompletionPresetKind = "archetype" | "vendor_pack";
3
+ export type ResolvedCompletionPreset = {
4
+ preset: CompletionPreset;
5
+ archetype: CompletionPreset;
6
+ kind: CompletionPresetKind;
7
+ harborTemplateId: string;
8
+ parameters: Record<string, unknown>;
9
+ evidenceSchema: Record<string, unknown>;
10
+ };
11
+ export declare function presetKind(preset: CompletionPreset): CompletionPresetKind;
12
+ export declare function isVendorPack(preset: CompletionPreset): boolean;
13
+ /** Resolves vendor packs to their underlying archetype for Harbor materialization. */
14
+ export declare function resolveCompletionPreset(presetId: string): ResolvedCompletionPreset;
15
+ /** Maps vendor-facing evidence fields to catalog canonical names for Harbor submit. */
16
+ export declare function mapVendorEvidenceToCanonical(preset: CompletionPreset, vendorEvidence: Record<string, unknown>): Record<string, unknown>;
17
+ /** Frozen completion contract metadata for intent pinning at create time. */
18
+ export declare function contractSnapshotForPreset(presetId: string): import("./principal-intent.js").CompletionContractSnapshot;
19
+ export declare function completionPresetDeprecationWarning(presetId: string): string | undefined;
20
+ export declare function vendorEvidenceSchema(preset: CompletionPreset): Record<string, unknown> | undefined;
21
+ export declare function listArchetypePresetIds(): string[];
@@ -0,0 +1,86 @@
1
+ import { getCompletionPreset, loadCompletionCatalog, } from "./completion-catalog.js";
2
+ import { completionSchemaDigestHex } from "./completion-contract-digest.js";
3
+ export function presetKind(preset) {
4
+ return preset.kind === "vendor_pack" ? "vendor_pack" : "archetype";
5
+ }
6
+ export function isVendorPack(preset) {
7
+ return presetKind(preset) === "vendor_pack";
8
+ }
9
+ /** Resolves vendor packs to their underlying archetype for Harbor materialization. */
10
+ export function resolveCompletionPreset(presetId) {
11
+ const preset = getCompletionPreset(presetId);
12
+ if (!isVendorPack(preset)) {
13
+ return {
14
+ preset,
15
+ archetype: preset,
16
+ kind: "archetype",
17
+ harborTemplateId: preset.harbor_template_id,
18
+ parameters: preset.parameters,
19
+ evidenceSchema: preset.evidence_schema,
20
+ };
21
+ }
22
+ const archetypeId = preset.archetype_preset_id;
23
+ if (!archetypeId) {
24
+ throw new Error(`vendor pack ${presetId} missing archetype_preset_id`);
25
+ }
26
+ const archetype = getCompletionPreset(archetypeId);
27
+ return {
28
+ preset,
29
+ archetype,
30
+ kind: "vendor_pack",
31
+ harborTemplateId: archetype.harbor_template_id,
32
+ parameters: { ...archetype.parameters, ...preset.parameters },
33
+ evidenceSchema: preset.evidence_schema,
34
+ };
35
+ }
36
+ /** Maps vendor-facing evidence fields to catalog canonical names for Harbor submit. */
37
+ export function mapVendorEvidenceToCanonical(preset, vendorEvidence) {
38
+ const fieldMap = preset.evidence_field_map ?? {};
39
+ const out = {};
40
+ for (const [vendorKey, value] of Object.entries(vendorEvidence)) {
41
+ const canonicalKey = fieldMap[vendorKey] ?? vendorKey;
42
+ if (canonicalKey === "artifact_blake3_hex" && !Array.isArray(value)) {
43
+ out[canonicalKey] = [value];
44
+ continue;
45
+ }
46
+ out[canonicalKey] = value;
47
+ }
48
+ return out;
49
+ }
50
+ /** Frozen completion contract metadata for intent pinning at create time. */
51
+ export function contractSnapshotForPreset(presetId) {
52
+ const preset = getCompletionPreset(presetId);
53
+ const contract = preset.vendor_contract;
54
+ if (contract) {
55
+ return {
56
+ completionPresetId: preset.preset_id,
57
+ vendorContractProvider: contract.provider,
58
+ vendorApiVersion: contract.api_version,
59
+ vendorSchemaDigestHex: contract.schema_digest_hex,
60
+ canonicalSchemaDigestHex: contract.canonical_schema_digest_hex,
61
+ };
62
+ }
63
+ if (preset.kind === "vendor_pack") {
64
+ throw new Error(`vendor pack ${presetId} missing vendor_contract`);
65
+ }
66
+ return {
67
+ completionPresetId: preset.preset_id,
68
+ canonicalSchemaDigestHex: completionSchemaDigestHex(preset.evidence_schema),
69
+ };
70
+ }
71
+ export function completionPresetDeprecationWarning(presetId) {
72
+ const preset = getCompletionPreset(presetId);
73
+ if (!preset.deprecated) {
74
+ return undefined;
75
+ }
76
+ const replacement = preset.superseded_by ?? "a newer preset";
77
+ return `completion preset ${presetId} is deprecated; use ${replacement} instead`;
78
+ }
79
+ export function vendorEvidenceSchema(preset) {
80
+ return preset.vendor_evidence_schema;
81
+ }
82
+ export function listArchetypePresetIds() {
83
+ return loadCompletionCatalog()
84
+ .presets.filter((entry) => !isVendorPack(entry))
85
+ .map((entry) => entry.preset_id);
86
+ }
@@ -0,0 +1,24 @@
1
+ /** Local pre-validation report aligned with Harbor `SchemaValidationReport`. */
2
+ export type CompletionEvidenceValidationReport = {
3
+ preset_id: string;
4
+ vendor_schema_ok: boolean;
5
+ canonical_schema_ok: boolean;
6
+ quality_fields_missing: string[];
7
+ forbidden_fields_present: string[];
8
+ pack_stale: boolean;
9
+ drift_kinds: string[];
10
+ canonical_payload?: Record<string, unknown>;
11
+ };
12
+ /**
13
+ * Validates vendor and canonical completion evidence against catalog JSON Schemas.
14
+ * Signal-only: returns drift metadata without throwing on schema mismatch.
15
+ */
16
+ export declare function validateCompletionEvidence(input: {
17
+ presetId: string;
18
+ vendorPayload?: Record<string, unknown>;
19
+ canonicalPayload?: Record<string, unknown>;
20
+ /** When set, compares catalog contract digests to detect pack_stale (intent pin drift). */
21
+ frozenVendorApiVersion?: string;
22
+ frozenVendorSchemaDigestHex?: string;
23
+ frozenCanonicalSchemaDigestHex?: string;
24
+ }): CompletionEvidenceValidationReport;