@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.
Files changed (368) 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/audit-export.d.ts +7 -0
  71. package/dist/cli/audit-export.js +120 -0
  72. package/dist/cli/automation.d.ts +25 -0
  73. package/dist/cli/automation.js +297 -0
  74. package/dist/cli/body.d.ts +7 -0
  75. package/dist/cli/body.js +22 -0
  76. package/dist/cli/color.d.ts +15 -0
  77. package/dist/cli/color.js +39 -0
  78. package/dist/cli/command-spec.d.ts +13 -0
  79. package/dist/cli/command-spec.js +611 -0
  80. package/dist/cli/commands/agent.d.ts +16 -0
  81. package/dist/cli/commands/agent.js +1135 -0
  82. package/dist/cli/commands/dev.d.ts +7 -0
  83. package/dist/cli/commands/dev.js +348 -0
  84. package/dist/cli/commands/discovery.d.ts +8 -0
  85. package/dist/cli/commands/discovery.js +194 -0
  86. package/dist/cli/commands/policy.d.ts +13 -0
  87. package/dist/cli/commands/policy.js +769 -0
  88. package/dist/cli/commands/setup.d.ts +18 -0
  89. package/dist/cli/commands/setup.js +513 -0
  90. package/dist/cli/commands/workflows.d.ts +7 -0
  91. package/dist/cli/commands/workflows.js +214 -0
  92. package/dist/cli/config.d.ts +16 -0
  93. package/dist/cli/config.js +98 -0
  94. package/dist/cli/context.d.ts +22 -0
  95. package/dist/cli/context.js +110 -0
  96. package/dist/cli/credentials.d.ts +21 -0
  97. package/dist/cli/credentials.js +141 -0
  98. package/dist/cli/doctor-agent-middleware.d.ts +5 -0
  99. package/dist/cli/doctor-agent-middleware.js +49 -0
  100. package/dist/cli/doctor-agent.d.ts +15 -0
  101. package/dist/cli/doctor-agent.js +311 -0
  102. package/dist/cli/envelope.d.ts +14 -0
  103. package/dist/cli/envelope.js +46 -0
  104. package/dist/cli/globals.d.ts +23 -0
  105. package/dist/cli/globals.js +248 -0
  106. package/dist/cli/help.d.ts +3 -0
  107. package/dist/cli/help.js +83 -0
  108. package/dist/cli/mcp-install.d.ts +41 -0
  109. package/dist/cli/mcp-install.js +95 -0
  110. package/dist/cli/mcp-policy.d.ts +26 -0
  111. package/dist/cli/mcp-policy.js +110 -0
  112. package/dist/cli/mcp-verify-config.d.ts +37 -0
  113. package/dist/cli/mcp-verify-config.js +172 -0
  114. package/dist/cli/redact.d.ts +4 -0
  115. package/dist/cli/redact.js +88 -0
  116. package/dist/cli/request-id.d.ts +2 -0
  117. package/dist/cli/request-id.js +5 -0
  118. package/dist/cli/router.d.ts +2 -0
  119. package/dist/cli/router.js +378 -0
  120. package/dist/cli/smoke-deep-links.d.ts +15 -0
  121. package/dist/cli/smoke-deep-links.js +63 -0
  122. package/dist/cli/suggest.d.ts +4 -0
  123. package/dist/cli/suggest.js +58 -0
  124. package/dist/cli/support-diagnostics.d.ts +19 -0
  125. package/dist/cli/support-diagnostics.js +47 -0
  126. package/dist/cli/telemetry.d.ts +17 -0
  127. package/dist/cli/telemetry.js +94 -0
  128. package/dist/cli/types.d.ts +72 -0
  129. package/dist/cli/types.js +60 -0
  130. package/dist/cli/ux.d.ts +8 -0
  131. package/dist/cli/ux.js +164 -0
  132. package/dist/cli.d.ts +2 -0
  133. package/dist/cli.js +38 -0
  134. package/dist/completion-catalog-digest.d.ts +2 -0
  135. package/dist/completion-catalog-digest.js +2 -0
  136. package/dist/completion-catalog-integrity.d.ts +2 -0
  137. package/dist/completion-catalog-integrity.js +17 -0
  138. package/dist/completion-catalog.d.ts +49 -0
  139. package/dist/completion-catalog.js +62 -0
  140. package/dist/completion-contract-digest.d.ts +37 -0
  141. package/dist/completion-contract-digest.js +73 -0
  142. package/dist/completion-forbidden-fields.d.ts +5 -0
  143. package/dist/completion-forbidden-fields.js +26 -0
  144. package/dist/completion-init.d.ts +8 -0
  145. package/dist/completion-init.js +334 -0
  146. package/dist/completion-resolve.d.ts +21 -0
  147. package/dist/completion-resolve.js +86 -0
  148. package/dist/completion-validate-evidence.d.ts +24 -0
  149. package/dist/completion-validate-evidence.js +145 -0
  150. package/dist/dev/offline-gateway.d.ts +24 -0
  151. package/dist/dev/offline-gateway.js +102 -0
  152. package/dist/dev/trace-buffer.d.ts +61 -0
  153. package/dist/dev/trace-buffer.js +330 -0
  154. package/dist/dev/trace-security-headers.d.ts +11 -0
  155. package/dist/dev/trace-security-headers.js +16 -0
  156. package/dist/dev/trace-server.d.ts +8 -0
  157. package/dist/dev/trace-server.js +38 -0
  158. package/dist/dev/trace-ui.d.ts +4 -0
  159. package/dist/dev/trace-ui.js +25 -0
  160. package/dist/dev/wiremock-up.d.ts +15 -0
  161. package/dist/dev/wiremock-up.js +118 -0
  162. package/dist/doctor-completion.d.ts +17 -0
  163. package/dist/doctor-completion.js +428 -0
  164. package/dist/gateway-url.d.ts +7 -0
  165. package/dist/gateway-url.js +69 -0
  166. package/dist/index.d.ts +119 -2
  167. package/dist/index.js +267 -6
  168. package/dist/init.js +380 -68
  169. package/dist/langgraph/awrap-tool-call.d.ts +25 -0
  170. package/dist/langgraph/awrap-tool-call.js +81 -0
  171. package/dist/langgraph/config.d.ts +13 -0
  172. package/dist/langgraph/config.js +11 -0
  173. package/dist/langgraph/index.d.ts +4 -0
  174. package/dist/langgraph/index.js +4 -0
  175. package/dist/langgraph/sandbox-demo.d.ts +40 -0
  176. package/dist/langgraph/sandbox-demo.js +96 -0
  177. package/dist/langgraph/tool-node.d.ts +10 -0
  178. package/dist/langgraph/tool-node.js +38 -0
  179. package/dist/login.d.ts +14 -1
  180. package/dist/login.js +130 -63
  181. package/dist/mcp/index.d.ts +1 -0
  182. package/dist/mcp/index.js +1 -0
  183. package/dist/mcp/tool-surface.d.ts +25 -0
  184. package/dist/mcp/tool-surface.js +17 -0
  185. package/dist/mcp-capability-token-cache.d.ts +24 -0
  186. package/dist/mcp-capability-token-cache.js +101 -0
  187. package/dist/mcp-evidence-policy.d.ts +48 -0
  188. package/dist/mcp-evidence-policy.js +117 -0
  189. package/dist/mcp-policy-reload.d.ts +79 -0
  190. package/dist/mcp-policy-reload.js +200 -0
  191. package/dist/mcp-sep2828-evidence.d.ts +36 -0
  192. package/dist/mcp-sep2828-evidence.js +65 -0
  193. package/dist/mcp-server.d.ts +10 -0
  194. package/dist/mcp-server.js +423 -115
  195. package/dist/openai-agents/index.d.ts +40 -0
  196. package/dist/openai-agents/index.js +151 -0
  197. package/dist/openai-agents/sandbox-demo.d.ts +34 -0
  198. package/dist/openai-agents/sandbox-demo.js +118 -0
  199. package/dist/payee-evidence.js +2 -29
  200. package/dist/policy/catalog.d.ts +31 -0
  201. package/dist/policy/catalog.js +48 -0
  202. package/dist/policy/compose-utils.d.ts +3 -0
  203. package/dist/policy/compose-utils.js +4 -0
  204. package/dist/policy/compose.d.ts +20 -0
  205. package/dist/policy/compose.js +240 -0
  206. package/dist/policy/digest.d.ts +7 -0
  207. package/dist/policy/digest.js +75 -0
  208. package/dist/policy/domain.d.ts +15 -0
  209. package/dist/policy/domain.js +28 -0
  210. package/dist/policy/guardrail-spec.d.ts +17 -0
  211. package/dist/policy/guardrail-spec.js +140 -0
  212. package/dist/policy/guardrails.d.ts +48 -0
  213. package/dist/policy/guardrails.js +72 -0
  214. package/dist/policy/index.d.ts +21 -0
  215. package/dist/policy/index.js +21 -0
  216. package/dist/policy/init.d.ts +102 -0
  217. package/dist/policy/init.js +351 -0
  218. package/dist/policy/intent-spec.d.ts +52 -0
  219. package/dist/policy/intent-spec.js +176 -0
  220. package/dist/policy/json-path.d.ts +4 -0
  221. package/dist/policy/json-path.js +23 -0
  222. package/dist/policy/layers-io.d.ts +7 -0
  223. package/dist/policy/layers-io.js +28 -0
  224. package/dist/policy/load-effective.d.ts +22 -0
  225. package/dist/policy/load-effective.js +77 -0
  226. package/dist/policy/load.d.ts +85 -0
  227. package/dist/policy/load.js +164 -0
  228. package/dist/policy/merge.d.ts +29 -0
  229. package/dist/policy/merge.js +297 -0
  230. package/dist/policy/parse-text.d.ts +2 -0
  231. package/dist/policy/parse-text.js +126 -0
  232. package/dist/policy/policy-api.d.ts +45 -0
  233. package/dist/policy/policy-api.js +61 -0
  234. package/dist/policy/presets.d.ts +19 -0
  235. package/dist/policy/presets.js +66 -0
  236. package/dist/policy/registry.d.ts +7 -0
  237. package/dist/policy/registry.js +33 -0
  238. package/dist/policy/reload.d.ts +86 -0
  239. package/dist/policy/reload.js +233 -0
  240. package/dist/policy/render-yaml.d.ts +3 -0
  241. package/dist/policy/render-yaml.js +69 -0
  242. package/dist/policy/sandbox-bootstrap.d.ts +19 -0
  243. package/dist/policy/sandbox-bootstrap.js +66 -0
  244. package/dist/policy/schema.d.ts +204 -0
  245. package/dist/policy/schema.js +255 -0
  246. package/dist/policy/snapshot.d.ts +33 -0
  247. package/dist/policy/snapshot.js +23 -0
  248. package/dist/policy/validate-remote.d.ts +43 -0
  249. package/dist/policy/validate-remote.js +104 -0
  250. package/dist/policy/validate.d.ts +36 -0
  251. package/dist/policy/validate.js +150 -0
  252. package/dist/policy/watcher.d.ts +29 -0
  253. package/dist/policy/watcher.js +112 -0
  254. package/dist/principal-intent.d.ts +52 -0
  255. package/dist/principal-intent.js +193 -37
  256. package/dist/project-init.d.ts +34 -0
  257. package/dist/project-init.js +898 -0
  258. package/dist/sep2828-signature.d.ts +10 -0
  259. package/dist/sep2828-signature.js +134 -0
  260. package/dist/solutions/api.d.ts +22 -0
  261. package/dist/solutions/api.js +40 -0
  262. package/dist/solutions/catalog.d.ts +34 -0
  263. package/dist/solutions/catalog.js +129 -0
  264. package/dist/solutions/index.d.ts +2 -0
  265. package/dist/solutions/index.js +2 -0
  266. package/dist/template-init.d.ts +54 -0
  267. package/dist/template-init.js +203 -0
  268. package/dist/vercel-ai/config.d.ts +15 -0
  269. package/dist/vercel-ai/config.js +13 -0
  270. package/dist/vercel-ai/index.d.ts +4 -0
  271. package/dist/vercel-ai/index.js +4 -0
  272. package/dist/vercel-ai/sandbox-demo.d.ts +44 -0
  273. package/dist/vercel-ai/sandbox-demo.js +153 -0
  274. package/dist/vercel-ai/tool-approval.d.ts +16 -0
  275. package/dist/vercel-ai/tool-approval.js +41 -0
  276. package/dist/vercel-ai/wrap-tools.d.ts +9 -0
  277. package/dist/vercel-ai/wrap-tools.js +40 -0
  278. package/dist/x402-receipt-evidence.d.ts +29 -0
  279. package/dist/x402-receipt-evidence.js +97 -0
  280. package/dist/x402-receipt-signature.d.ts +12 -0
  281. package/dist/x402-receipt-signature.js +211 -0
  282. package/package.json +79 -4
  283. package/solutions/aws.json +17 -0
  284. package/solutions/saas.json +17 -0
  285. package/solutions/shopping.json +17 -0
  286. package/solutions/travel.json +18 -0
  287. package/templates/manifest.json +169 -0
  288. package/templates/openai-shopping-agent/.env.example +3 -0
  289. package/templates/openai-shopping-agent/.github/workflows/smoke.yml +20 -0
  290. package/templates/openai-shopping-agent/LICENSE +201 -0
  291. package/templates/openai-shopping-agent/README.md +29 -0
  292. package/templates/openai-shopping-agent/package.json +22 -0
  293. package/templates/openai-shopping-agent/paybond.policy.yaml +22 -0
  294. package/templates/openai-shopping-agent/src/index.ts +22 -0
  295. package/templates/openai-shopping-agent/src/paybond.config.ts +51 -0
  296. package/templates/openai-shopping-agent/tsconfig.json +13 -0
  297. package/templates/paybond-aws-operator/.env.example +3 -0
  298. package/templates/paybond-aws-operator/.github/workflows/smoke.yml +20 -0
  299. package/templates/paybond-aws-operator/LICENSE +201 -0
  300. package/templates/paybond-aws-operator/README.md +29 -0
  301. package/templates/paybond-aws-operator/package.json +20 -0
  302. package/templates/paybond-aws-operator/paybond.policy.yaml +22 -0
  303. package/templates/paybond-aws-operator/src/index.ts +54 -0
  304. package/templates/paybond-aws-operator/src/paybond.config.ts +51 -0
  305. package/templates/paybond-aws-operator/tsconfig.json +13 -0
  306. package/templates/paybond-claude-agents-demo/.env.example +3 -0
  307. package/templates/paybond-claude-agents-demo/.github/workflows/smoke.yml +20 -0
  308. package/templates/paybond-claude-agents-demo/LICENSE +201 -0
  309. package/templates/paybond-claude-agents-demo/README.md +29 -0
  310. package/templates/paybond-claude-agents-demo/package.json +22 -0
  311. package/templates/paybond-claude-agents-demo/paybond.policy.yaml +22 -0
  312. package/templates/paybond-claude-agents-demo/src/index.ts +22 -0
  313. package/templates/paybond-claude-agents-demo/src/paybond.config.ts +51 -0
  314. package/templates/paybond-claude-agents-demo/tsconfig.json +13 -0
  315. package/templates/paybond-invoice-agent/.env.example +3 -0
  316. package/templates/paybond-invoice-agent/.github/workflows/smoke.yml +19 -0
  317. package/templates/paybond-invoice-agent/LICENSE +201 -0
  318. package/templates/paybond-invoice-agent/README.md +29 -0
  319. package/templates/paybond-invoice-agent/app.py +27 -0
  320. package/templates/paybond-invoice-agent/package.json +6 -0
  321. package/templates/paybond-invoice-agent/paybond.policy.yaml +22 -0
  322. package/templates/paybond-invoice-agent/paybond_config.py +45 -0
  323. package/templates/paybond-invoice-agent/requirements.txt +2 -0
  324. package/templates/paybond-mcp-coding-agent/.env.example +3 -0
  325. package/templates/paybond-mcp-coding-agent/.github/workflows/smoke.yml +20 -0
  326. package/templates/paybond-mcp-coding-agent/LICENSE +201 -0
  327. package/templates/paybond-mcp-coding-agent/README.md +39 -0
  328. package/templates/paybond-mcp-coding-agent/package.json +20 -0
  329. package/templates/paybond-mcp-coding-agent/paybond.policy.yaml +25 -0
  330. package/templates/paybond-mcp-coding-agent/src/index.ts +40 -0
  331. package/templates/paybond-mcp-coding-agent/src/paybond.config.ts +51 -0
  332. package/templates/paybond-mcp-coding-agent/tsconfig.json +13 -0
  333. package/templates/paybond-openai-agents-demo/.env.example +3 -0
  334. package/templates/paybond-openai-agents-demo/.github/workflows/smoke.yml +20 -0
  335. package/templates/paybond-openai-agents-demo/LICENSE +201 -0
  336. package/templates/paybond-openai-agents-demo/README.md +29 -0
  337. package/templates/paybond-openai-agents-demo/package.json +22 -0
  338. package/templates/paybond-openai-agents-demo/paybond.policy.yaml +22 -0
  339. package/templates/paybond-openai-agents-demo/src/index.ts +22 -0
  340. package/templates/paybond-openai-agents-demo/src/paybond.config.ts +51 -0
  341. package/templates/paybond-openai-agents-demo/tsconfig.json +13 -0
  342. package/templates/paybond-procurement-agent/.env.example +3 -0
  343. package/templates/paybond-procurement-agent/.github/workflows/smoke.yml +20 -0
  344. package/templates/paybond-procurement-agent/LICENSE +201 -0
  345. package/templates/paybond-procurement-agent/README.md +29 -0
  346. package/templates/paybond-procurement-agent/package.json +20 -0
  347. package/templates/paybond-procurement-agent/paybond.policy.yaml +25 -0
  348. package/templates/paybond-procurement-agent/src/index.ts +54 -0
  349. package/templates/paybond-procurement-agent/src/paybond.config.ts +51 -0
  350. package/templates/paybond-procurement-agent/tsconfig.json +13 -0
  351. package/templates/paybond-travel-agent/.env.example +3 -0
  352. package/templates/paybond-travel-agent/.github/workflows/smoke.yml +20 -0
  353. package/templates/paybond-travel-agent/LICENSE +201 -0
  354. package/templates/paybond-travel-agent/README.md +29 -0
  355. package/templates/paybond-travel-agent/package.json +23 -0
  356. package/templates/paybond-travel-agent/paybond.policy.yaml +22 -0
  357. package/templates/paybond-travel-agent/src/index.ts +22 -0
  358. package/templates/paybond-travel-agent/src/paybond.config.ts +51 -0
  359. package/templates/paybond-travel-agent/tsconfig.json +13 -0
  360. package/templates/paybond-vercel-shopping-agent/.env.example +3 -0
  361. package/templates/paybond-vercel-shopping-agent/.github/workflows/smoke.yml +20 -0
  362. package/templates/paybond-vercel-shopping-agent/LICENSE +201 -0
  363. package/templates/paybond-vercel-shopping-agent/README.md +29 -0
  364. package/templates/paybond-vercel-shopping-agent/package.json +22 -0
  365. package/templates/paybond-vercel-shopping-agent/paybond.policy.yaml +22 -0
  366. package/templates/paybond-vercel-shopping-agent/src/index.ts +22 -0
  367. package/templates/paybond-vercel-shopping-agent/src/paybond.config.ts +51 -0
  368. package/templates/paybond-vercel-shopping-agent/tsconfig.json +13 -0
@@ -0,0 +1,378 @@
1
+ import { commandPath, createContext } from "./context.js";
2
+ import { handleA2a, handleAuditExports, handleMandates, handleReceipts, handleSignal, } from "./commands/discovery.js";
3
+ import { handleConfig, handleDoctor, handleDiagnose, handleInitCompletion, handleInitAgentMiddleware, handleInitGuardrail, handleInitWizard, handleLogin, handleMcpInstall, handleMcpServe, handleMcpTools, handleMcpVerifyConfig, handleVersion, handleWhoami, } from "./commands/setup.js";
4
+ import { handlePolicyExtend, handlePolicyImportMcpReceipt, handlePolicyImportX402Receipt, handlePolicyInit, handlePolicyInitOrg, handlePolicyPresetsList, handlePolicyPresetsShow, handlePolicyPreview, handlePolicyTemplates, handlePolicyValidateEvidence, handlePolicyValidateTools, } from "./commands/policy.js";
5
+ import { handleAgent } from "./commands/agent.js";
6
+ import { handleDev } from "./commands/dev.js";
7
+ import { handleGuardrails, handleIntents, handleKeys, handleSpendAuthorize, } from "./commands/workflows.js";
8
+ import { failureEnvelope, prepareCommandOutput, successEnvelope, writeEnvelope, writeTableLines } from "./envelope.js";
9
+ import { defaultGlobalOptions, parseCliArgv } from "./globals.js";
10
+ import { deprecatedAliasWarning } from "./automation.js";
11
+ import { helpForCommand } from "./help.js";
12
+ import { generateRequestId } from "./request-id.js";
13
+ import { colorize, shouldUseColor } from "./color.js";
14
+ import { formatUnknownCommandMessage } from "./suggest.js";
15
+ import { handleCompletionCommand, handleExamplesCommand, handleHelpCommand, handleOnboarding, } from "./ux.js";
16
+ import { CliError, EXIT_SUCCESS, } from "./types.js";
17
+ function isHelp(argv) {
18
+ return argv.length === 0 || argv.includes("--help") || argv.includes("-h");
19
+ }
20
+ function renderTable(command, result, globals) {
21
+ const useColor = shouldUseColor(globals);
22
+ const lines = [colorize(`${command}: ok`, "green", useColor)];
23
+ for (const [key, value] of Object.entries(result.data)) {
24
+ if (value && typeof value === "object" && !Array.isArray(value)) {
25
+ lines.push(`${key}: ${JSON.stringify(value)}`);
26
+ }
27
+ else if (Array.isArray(value)) {
28
+ lines.push(`${key}: ${value.length} item(s)`);
29
+ }
30
+ else {
31
+ lines.push(`${key}: ${String(value)}`);
32
+ }
33
+ }
34
+ if (result.warnings?.length) {
35
+ lines.push(colorize(`warnings: ${result.warnings.join("; ")}`, "yellow", useColor));
36
+ }
37
+ return lines;
38
+ }
39
+ function toErrorShape(err) {
40
+ if (err instanceof CliError) {
41
+ if (err.message === "help") {
42
+ return {
43
+ shape: { category: "usage", code: "cli.help", message: "help" },
44
+ exitCode: EXIT_SUCCESS,
45
+ };
46
+ }
47
+ return {
48
+ shape: {
49
+ category: err.category,
50
+ code: err.code,
51
+ message: err.message,
52
+ details: err.details ?? {},
53
+ },
54
+ exitCode: err.exitCode,
55
+ };
56
+ }
57
+ return {
58
+ shape: {
59
+ category: "internal",
60
+ code: "cli.internal",
61
+ message: err instanceof Error ? err.message : String(err),
62
+ details: {},
63
+ },
64
+ exitCode: 1,
65
+ };
66
+ }
67
+ function outputFormatFromArgv(argv) {
68
+ for (let i = 0; i < argv.length; i += 1) {
69
+ const arg = argv[i];
70
+ if (arg === "--format" && argv[i + 1] === "json") {
71
+ return "json";
72
+ }
73
+ if (arg === "--format=json") {
74
+ return "json";
75
+ }
76
+ }
77
+ return "table";
78
+ }
79
+ function requestIdFromArgv(argv) {
80
+ for (let i = 0; i < argv.length; i += 1) {
81
+ const arg = argv[i];
82
+ if (arg === "--request-id" && argv[i + 1]) {
83
+ return argv[i + 1];
84
+ }
85
+ if (arg.startsWith("--request-id=")) {
86
+ return arg.slice("--request-id=".length);
87
+ }
88
+ }
89
+ return generateRequestId();
90
+ }
91
+ export async function runCli(argv, deps = {}) {
92
+ const stdout = deps.stdout ?? process.stdout;
93
+ const stderr = deps.stderr ?? process.stderr;
94
+ let globals;
95
+ let command;
96
+ try {
97
+ ({ globals, command } = parseCliArgv(argv));
98
+ }
99
+ catch (err) {
100
+ const { shape, exitCode } = toErrorShape(err);
101
+ if (shape.message === "help") {
102
+ stdout.write(`${helpForCommand("")}\n`);
103
+ return EXIT_SUCCESS;
104
+ }
105
+ if (outputFormatFromArgv(argv) === "json") {
106
+ writeEnvelope(stdout, failureEnvelope("paybond", { ...defaultGlobalOptions(), format: "json", requestId: requestIdFromArgv(argv) }, shape));
107
+ }
108
+ else {
109
+ stderr.write(`${shape.message}\n`);
110
+ }
111
+ return exitCode;
112
+ }
113
+ const ctx = createContext(globals, deps);
114
+ const aliasWarning = deprecatedAliasWarning(process.argv[1]);
115
+ if (aliasWarning) {
116
+ stderr.write(`${aliasWarning}\n`);
117
+ }
118
+ const helpPath = command.filter((part) => part !== "--help" && part !== "-h").join(" ");
119
+ if (isHelp(command)) {
120
+ const text = helpPath ? helpForCommand(helpPath) : helpForCommand("");
121
+ ctx.stdout.write(`${text}\n`);
122
+ return EXIT_SUCCESS;
123
+ }
124
+ let canonical = "";
125
+ let result;
126
+ try {
127
+ const [head, second, third] = command;
128
+ const tail = command.slice(2);
129
+ if (head === "help") {
130
+ canonical = "help";
131
+ result = handleHelpCommand(command.slice(1));
132
+ }
133
+ else if (head === "examples") {
134
+ canonical = "examples";
135
+ result = handleExamplesCommand(command.slice(1));
136
+ }
137
+ else if (head === "completion" && second) {
138
+ canonical = "completion";
139
+ result = handleCompletionCommand(command.slice(1));
140
+ }
141
+ else if (head === "onboarding") {
142
+ canonical = "onboarding";
143
+ result = await handleOnboarding(ctx, command.slice(1));
144
+ }
145
+ else if (head === "login") {
146
+ canonical = "login";
147
+ result = await handleLogin(ctx, command.slice(1));
148
+ }
149
+ else if (head === "init" && second === "guardrail") {
150
+ canonical = "init guardrail";
151
+ result = await handleInitGuardrail(ctx, command.slice(2));
152
+ }
153
+ else if (head === "init" && second === "agent-middleware") {
154
+ canonical = "init agent-middleware";
155
+ result = await handleInitAgentMiddleware(ctx, command.slice(2));
156
+ }
157
+ else if (head === "init" && second === "completion") {
158
+ canonical = "init completion";
159
+ result = await handleInitCompletion(ctx, command.slice(2));
160
+ }
161
+ else if (head === "init") {
162
+ canonical = "init";
163
+ result = await handleInitWizard(ctx, command.slice(1));
164
+ }
165
+ else if (head === "mcp" && second === "serve") {
166
+ canonical = "mcp serve";
167
+ result = await handleMcpServe(ctx, command.slice(2));
168
+ }
169
+ else if (head === "mcp" && second === "install") {
170
+ canonical = "mcp install";
171
+ result = await handleMcpInstall(ctx, command.slice(2));
172
+ }
173
+ else if (head === "mcp" && second === "tools") {
174
+ canonical = "mcp tools";
175
+ result = await handleMcpTools(ctx);
176
+ }
177
+ else if (head === "mcp" && second === "verify-config") {
178
+ canonical = "mcp verify-config";
179
+ result = await handleMcpVerifyConfig(ctx, command.slice(2));
180
+ }
181
+ else if (head === "doctor") {
182
+ canonical = "doctor";
183
+ result = await handleDoctor(ctx, command.slice(1));
184
+ }
185
+ else if (head === "dev" && second) {
186
+ canonical = commandPath(["dev", second]);
187
+ result = await handleDev(ctx, second, tail);
188
+ }
189
+ else if (head === "version") {
190
+ canonical = "version";
191
+ result = await handleVersion(ctx, command.slice(1));
192
+ }
193
+ else if (head === "diagnose") {
194
+ canonical = "diagnose";
195
+ result = await handleDiagnose(ctx, command.slice(1));
196
+ }
197
+ else if (head === "config" && second) {
198
+ canonical = commandPath(["config", second]);
199
+ result = await handleConfig(ctx, second, tail);
200
+ }
201
+ else if (head === "whoami") {
202
+ canonical = "whoami";
203
+ result = await handleWhoami(ctx);
204
+ }
205
+ else if (head === "keys" && second) {
206
+ canonical = commandPath(["keys", second]);
207
+ result = await handleKeys(ctx, second, tail);
208
+ }
209
+ else if (head === "intents" && second) {
210
+ canonical = commandPath(["intents", second]);
211
+ result = await handleIntents(ctx, second, tail);
212
+ }
213
+ else if (head === "guardrails" && second) {
214
+ canonical = commandPath(["guardrails", second]);
215
+ result = await handleGuardrails(ctx, second, tail);
216
+ }
217
+ else if (head === "spend" && second === "authorize") {
218
+ canonical = "spend authorize";
219
+ result = await handleSpendAuthorize(ctx, tail);
220
+ }
221
+ else if (head === "signal" && second) {
222
+ canonical = commandPath(["signal", second]);
223
+ result = await handleSignal(ctx, second, tail);
224
+ }
225
+ else if (head === "receipts" && second) {
226
+ canonical = commandPath(["receipts", second]);
227
+ result = await handleReceipts(ctx, second, tail);
228
+ }
229
+ else if (head === "mandates" && second) {
230
+ canonical = commandPath(["mandates", second]);
231
+ result = await handleMandates(ctx, second, tail);
232
+ }
233
+ else if (head === "a2a" && second) {
234
+ canonical = commandPath(["a2a", second]);
235
+ result = await handleA2a(ctx, second, tail);
236
+ }
237
+ else if (head === "audit" && second === "exports" && third) {
238
+ canonical = commandPath(["audit", "exports", third]);
239
+ result = await handleAuditExports(ctx, third, command.slice(3));
240
+ }
241
+ else if (head === "policy" && second === "presets" && third === "list") {
242
+ canonical = "policy presets list";
243
+ result = await handlePolicyPresetsList(ctx, command.slice(3));
244
+ }
245
+ else if (head === "policy" && second === "presets" && third === "show") {
246
+ canonical = "policy presets show";
247
+ result = await handlePolicyPresetsShow(ctx, command.slice(3));
248
+ }
249
+ else if (head === "policy" && second === "templates") {
250
+ canonical = "policy templates";
251
+ result = await handlePolicyTemplates(ctx, command.slice(2));
252
+ }
253
+ else if (head === "policy" && second === "preview") {
254
+ canonical = "policy preview";
255
+ result = await handlePolicyPreview(ctx, command.slice(2));
256
+ }
257
+ else if (head === "policy" && second === "import-mcp-receipt") {
258
+ canonical = "policy import-mcp-receipt";
259
+ result = await handlePolicyImportMcpReceipt(ctx, command.slice(2));
260
+ }
261
+ else if (head === "policy" && second === "import-x402-receipt") {
262
+ canonical = "policy import-x402-receipt";
263
+ result = await handlePolicyImportX402Receipt(ctx, command.slice(2));
264
+ }
265
+ else if (head === "policy" && second === "validate-evidence") {
266
+ canonical = "policy validate-evidence";
267
+ result = await handlePolicyValidateEvidence(ctx, command.slice(2));
268
+ }
269
+ else if (head === "policy" && second === "init-org") {
270
+ canonical = "policy init-org";
271
+ result = await handlePolicyInitOrg(ctx, command.slice(2));
272
+ }
273
+ else if (head === "policy" && second === "extend") {
274
+ canonical = "policy extend";
275
+ result = await handlePolicyExtend(ctx, command.slice(2));
276
+ }
277
+ else if (head === "policy" && second === "init") {
278
+ canonical = "policy init";
279
+ result = await handlePolicyInit(ctx, command.slice(2));
280
+ }
281
+ else if (head === "policy" && second === "validate-tools") {
282
+ canonical = "policy validate-tools";
283
+ result = await handlePolicyValidateTools(ctx, command.slice(2));
284
+ }
285
+ else if (head === "agent" && second && third) {
286
+ canonical = commandPath(["agent", second, third]);
287
+ result = await handleAgent(ctx, second, third, command.slice(3));
288
+ }
289
+ else {
290
+ throw new CliError(formatUnknownCommandMessage(command.join(" ")), {
291
+ category: "usage",
292
+ code: "cli.usage.unknown_command",
293
+ });
294
+ }
295
+ const output = prepareCommandOutput(canonical, globals, result);
296
+ if (globals.format === "json") {
297
+ writeEnvelope(ctx.stdout, successEnvelope(canonical, globals, { data: output.data, warnings: output.warnings }));
298
+ }
299
+ else if (output.automationPlain) {
300
+ ctx.stdout.write(`${JSON.stringify(output.data, null, 2)}\n`);
301
+ if (output.warnings.length) {
302
+ for (const warning of output.warnings) {
303
+ ctx.stderr.write(`${warning}\n`);
304
+ }
305
+ }
306
+ }
307
+ else if (canonical === "help" || canonical === "examples") {
308
+ ctx.stdout.write(`${String(result.data.text ?? "")}\n`);
309
+ }
310
+ else if (canonical === "completion") {
311
+ ctx.stdout.write(String(result.data.script ?? ""));
312
+ }
313
+ else if (canonical === "version" && !("package_name" in result.data)) {
314
+ ctx.stdout.write(`${String(result.data.version ?? "")}\n`);
315
+ }
316
+ else if (canonical === "diagnose") {
317
+ const lines = Array.isArray(result.data.lines) ? result.data.lines : [];
318
+ for (const line of lines) {
319
+ ctx.stdout.write(`${line}\n`);
320
+ }
321
+ }
322
+ else if (canonical === "agent sandbox smoke" && Array.isArray(result.data.checklist_lines)) {
323
+ writeTableLines(ctx.stdout, result.data.checklist_lines);
324
+ if (output.warnings.length) {
325
+ for (const warning of output.warnings) {
326
+ ctx.stderr.write(`${warning}\n`);
327
+ }
328
+ }
329
+ }
330
+ else if ((canonical === "dev smoke" || canonical === "dev loop") &&
331
+ Array.isArray(result.data.checklist_lines)) {
332
+ if (canonical === "dev loop" && Array.isArray(result.data.banner_lines)) {
333
+ writeTableLines(ctx.stdout, result.data.banner_lines);
334
+ }
335
+ writeTableLines(ctx.stdout, result.data.checklist_lines);
336
+ if (output.warnings.length) {
337
+ for (const warning of output.warnings) {
338
+ ctx.stderr.write(`${warning}\n`);
339
+ }
340
+ }
341
+ }
342
+ else if (canonical === "agent run trace" && Array.isArray(result.data.trace_lines)) {
343
+ writeTableLines(ctx.stdout, result.data.trace_lines);
344
+ if (output.warnings.length) {
345
+ for (const warning of output.warnings) {
346
+ ctx.stderr.write(`${warning}\n`);
347
+ }
348
+ }
349
+ }
350
+ else if (canonical === "policy presets show" && Array.isArray(result.data.yaml_lines)) {
351
+ writeTableLines(ctx.stdout, result.data.yaml_lines);
352
+ if (output.warnings.length) {
353
+ for (const warning of output.warnings) {
354
+ ctx.stderr.write(`${warning}\n`);
355
+ }
356
+ }
357
+ }
358
+ else if (canonical !== "login" && canonical !== "mcp serve" && canonical !== "dev trace") {
359
+ writeTableLines(ctx.stdout, renderTable(canonical, result, globals));
360
+ }
361
+ return EXIT_SUCCESS;
362
+ }
363
+ catch (err) {
364
+ const { shape, exitCode } = toErrorShape(err);
365
+ if (shape.message === "help") {
366
+ const text = helpPath ? helpForCommand(helpPath) : helpForCommand("");
367
+ ctx.stdout.write(`${text}\n`);
368
+ return EXIT_SUCCESS;
369
+ }
370
+ if (globals.format === "json") {
371
+ writeEnvelope(ctx.stdout, failureEnvelope(canonical || helpPath || "paybond", globals, shape));
372
+ }
373
+ else {
374
+ ctx.stderr.write(`${shape.message}\n`);
375
+ }
376
+ return exitCode;
377
+ }
378
+ }
@@ -0,0 +1,15 @@
1
+ import type { GlobalOptions } from "./types.js";
2
+ /** Deep links returned by `paybond agent sandbox smoke` for local trace and hosted replay. */
3
+ export type AgentSandboxSmokeDeepLinks = Readonly<{
4
+ trace_url: string;
5
+ console_url?: string;
6
+ agent_trace_url?: string;
7
+ }>;
8
+ /**
9
+ * Builds trace, console dossier, and hosted agent-trace replay URLs for sandbox smoke JSON.
10
+ */
11
+ export declare function buildAgentSandboxSmokeDeepLinks(input: {
12
+ bind: Record<string, unknown>;
13
+ }): AgentSandboxSmokeDeepLinks;
14
+ /** Inserts trace/console/replay checklist lines before the trailing Success row. */
15
+ export declare function appendSmokeDeepLinkChecklistLines(checklistLines: ReadonlyArray<string>, deepLinks: AgentSandboxSmokeDeepLinks, globals: GlobalOptions): string[];
@@ -0,0 +1,63 @@
1
+ import { devTraceUrl } from "../dev/trace-buffer.js";
2
+ import { colorize, shouldUseColor } from "./color.js";
3
+ const HARBOR_INTENT_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4
+ const DEFAULT_LOCAL_PUBLIC_ORIGIN = "http://127.0.0.1:3000";
5
+ function stripTrailingSlashes(value) {
6
+ return value.replace(/\/+$/, "");
7
+ }
8
+ function resolvePublicOrigin() {
9
+ const configured = process.env.PAYBOND_PUBLIC_BASE_URL?.trim() ||
10
+ process.env.PAYBOND_CONSOLE_BASE_URL?.trim();
11
+ return stripTrailingSlashes(configured && configured.length > 0 ? configured : DEFAULT_LOCAL_PUBLIC_ORIGIN);
12
+ }
13
+ function resolveConsoleOrigin() {
14
+ const configured = process.env.PAYBOND_CONSOLE_BASE_URL?.trim() ||
15
+ process.env.PAYBOND_PUBLIC_BASE_URL?.trim();
16
+ return stripTrailingSlashes(configured && configured.length > 0 ? configured : DEFAULT_LOCAL_PUBLIC_ORIGIN);
17
+ }
18
+ function harborIntentId(bind) {
19
+ const raw = bind.intent_id;
20
+ if (typeof raw !== "string") {
21
+ return undefined;
22
+ }
23
+ const trimmed = raw.trim();
24
+ return HARBOR_INTENT_UUID.test(trimmed) ? trimmed : undefined;
25
+ }
26
+ /**
27
+ * Builds trace, console dossier, and hosted agent-trace replay URLs for sandbox smoke JSON.
28
+ */
29
+ export function buildAgentSandboxSmokeDeepLinks(input) {
30
+ const runId = String(input.bind.run_id ?? "smoke-1");
31
+ const links = {
32
+ trace_url: devTraceUrl(undefined, runId),
33
+ };
34
+ const intentId = harborIntentId(input.bind);
35
+ if (!intentId) {
36
+ return links;
37
+ }
38
+ const consoleOrigin = resolveConsoleOrigin();
39
+ const publicOrigin = resolvePublicOrigin();
40
+ return {
41
+ ...links,
42
+ console_url: `${consoleOrigin}/console/operations/intents/${encodeURIComponent(intentId)}`,
43
+ agent_trace_url: `${publicOrigin}/demo/agent-trace?intent=${encodeURIComponent(intentId)}`,
44
+ };
45
+ }
46
+ /** Inserts trace/console/replay checklist lines before the trailing Success row. */
47
+ export function appendSmokeDeepLinkChecklistLines(checklistLines, deepLinks, globals) {
48
+ const useColor = shouldUseColor(globals);
49
+ const mark = (line) => colorize(line, "green", useColor);
50
+ const linkLines = [
51
+ mark(`✓ Trace → ${deepLinks.trace_url}`),
52
+ ...(deepLinks.console_url ? [mark(`✓ Console → ${deepLinks.console_url}`)] : []),
53
+ ...(deepLinks.agent_trace_url ? [mark(`✓ Replay → ${deepLinks.agent_trace_url}`)] : []),
54
+ ];
55
+ if (checklistLines.length === 0) {
56
+ return linkLines;
57
+ }
58
+ const last = checklistLines.at(-1);
59
+ if (last === "Success" || last === mark("Success")) {
60
+ return [...checklistLines.slice(0, -1), ...linkLines, last];
61
+ }
62
+ return [...checklistLines, ...linkLines];
63
+ }
@@ -0,0 +1,4 @@
1
+ export declare function suggestCommandPath(input: string): string | undefined;
2
+ export declare function suggestGlobalFlag(input: string): string | undefined;
3
+ export declare function formatUnknownCommandMessage(input: string): string;
4
+ export declare function formatUnknownGlobalFlagMessage(flag: string): string;
@@ -0,0 +1,58 @@
1
+ import { COMMAND_PATHS, GLOBAL_FLAG_NAMES } from "./command-spec.js";
2
+ function levenshtein(a, b) {
3
+ const rows = a.length + 1;
4
+ const cols = b.length + 1;
5
+ const matrix = Array.from({ length: rows }, () => Array(cols).fill(0));
6
+ for (let i = 0; i < rows; i += 1) {
7
+ matrix[i][0] = i;
8
+ }
9
+ for (let j = 0; j < cols; j += 1) {
10
+ matrix[0][j] = j;
11
+ }
12
+ for (let i = 1; i < rows; i += 1) {
13
+ for (let j = 1; j < cols; j += 1) {
14
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
15
+ matrix[i][j] = Math.min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j - 1] + cost);
16
+ }
17
+ }
18
+ return matrix[a.length][b.length];
19
+ }
20
+ function bestSuggestion(input, candidates) {
21
+ const needle = input.trim().toLowerCase();
22
+ if (!needle) {
23
+ return undefined;
24
+ }
25
+ let best;
26
+ for (const candidate of candidates) {
27
+ const distance = levenshtein(needle, candidate.toLowerCase());
28
+ const threshold = Math.max(2, Math.floor(candidate.length / 3));
29
+ if (distance > threshold) {
30
+ continue;
31
+ }
32
+ if (!best || distance < best.distance) {
33
+ best = { value: candidate, distance };
34
+ }
35
+ }
36
+ return best?.value;
37
+ }
38
+ export function suggestCommandPath(input) {
39
+ return bestSuggestion(input, COMMAND_PATHS);
40
+ }
41
+ export function suggestGlobalFlag(input) {
42
+ const normalized = input.split("=")[0] ?? input;
43
+ return bestSuggestion(normalized, GLOBAL_FLAG_NAMES);
44
+ }
45
+ export function formatUnknownCommandMessage(input) {
46
+ const suggestion = suggestCommandPath(input);
47
+ if (suggestion) {
48
+ return `unknown command: ${input} (did you mean "${suggestion}"?)`;
49
+ }
50
+ return `unknown command: ${input}`;
51
+ }
52
+ export function formatUnknownGlobalFlagMessage(flag) {
53
+ const suggestion = suggestGlobalFlag(flag);
54
+ if (suggestion) {
55
+ return `unknown global flag: ${flag} (did you mean ${suggestion}?)`;
56
+ }
57
+ return `unknown global flag: ${flag}`;
58
+ }
@@ -0,0 +1,19 @@
1
+ import { describeCredentialSource } from "./credentials.js";
2
+ import type { CliContext } from "./context.js";
3
+ export type SupportDiagnostics = {
4
+ package_name: string;
5
+ package_version: string;
6
+ runtime: string;
7
+ platform: {
8
+ os: string;
9
+ arch: string;
10
+ };
11
+ config_path: string;
12
+ env_file_path: string;
13
+ gateway_url: string;
14
+ request_id: string;
15
+ mcp_tool_count: number;
16
+ credential_source: Awaited<ReturnType<typeof describeCredentialSource>>;
17
+ };
18
+ export declare function buildSupportDiagnostics(ctx: CliContext): Promise<SupportDiagnostics>;
19
+ export declare function formatSupportDiagnosticsTable(diagnostics: SupportDiagnostics): string[];
@@ -0,0 +1,47 @@
1
+ import path from "node:path";
2
+ import { configFilePath } from "./config.js";
3
+ import { describeCredentialSource } from "./credentials.js";
4
+ import { packageVersion } from "./doctor-agent.js";
5
+ import { PaybondMCPServer } from "../mcp-server.js";
6
+ function resolvedEnvFilePath(ctx) {
7
+ const envFile = ctx.globals.envFile;
8
+ return path.isAbsolute(envFile) ? path.resolve(envFile) : path.resolve(ctx.cwd, envFile);
9
+ }
10
+ export async function buildSupportDiagnostics(ctx) {
11
+ const server = new PaybondMCPServer({
12
+ gatewayBaseUrl: ctx.globals.gateway,
13
+ apiKey: "paybond_sk_sandbox_redacted_redacted_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
+ });
15
+ return {
16
+ package_name: "@paybond/kit",
17
+ package_version: packageVersion(),
18
+ runtime: `node ${process.version}`,
19
+ platform: {
20
+ os: process.platform,
21
+ arch: process.arch,
22
+ },
23
+ config_path: configFilePath(),
24
+ env_file_path: resolvedEnvFilePath(ctx),
25
+ gateway_url: ctx.globals.gateway,
26
+ request_id: ctx.globals.requestId,
27
+ mcp_tool_count: server.listTools().length,
28
+ credential_source: await describeCredentialSource(ctx.globals, ctx.cwd),
29
+ };
30
+ }
31
+ export function formatSupportDiagnosticsTable(diagnostics) {
32
+ const lines = [
33
+ `package: ${diagnostics.package_name} ${diagnostics.package_version}`,
34
+ `runtime: ${diagnostics.runtime}`,
35
+ `platform: ${diagnostics.platform.os} ${diagnostics.platform.arch}`,
36
+ `config_path: ${diagnostics.config_path}`,
37
+ `env_file_path: ${diagnostics.env_file_path}`,
38
+ `gateway_url: ${diagnostics.gateway_url}`,
39
+ `request_id: ${diagnostics.request_id}`,
40
+ `mcp_tool_count: ${diagnostics.mcp_tool_count}`,
41
+ `credential_source: ${JSON.stringify(diagnostics.credential_source)}`,
42
+ ];
43
+ if (diagnostics.credential_source.profile) {
44
+ lines.push(`profile: ${diagnostics.credential_source.profile}`);
45
+ }
46
+ return lines;
47
+ }
@@ -0,0 +1,17 @@
1
+ import type { CliContext } from "./context.js";
2
+ export type CliTelemetryCommand = "dev loop" | "dev smoke";
3
+ export declare function hashCliInstallId(installId: string): string;
4
+ export declare function resolveCliInstallId(): Promise<string>;
5
+ export declare function cliTelemetryEnabled(gateway: string): Promise<boolean>;
6
+ /**
7
+ * Fire-and-forget adoption telemetry for successful local dev commands.
8
+ * Failures are swallowed so CLI workflows never depend on analytics.
9
+ */
10
+ export declare function reportCliCommandSuccess(ctx: CliContext, input: Readonly<{
11
+ commandPath: CliTelemetryCommand;
12
+ offline: boolean;
13
+ }>): Promise<void>;
14
+ export declare function scheduleCliCommandTelemetry(ctx: CliContext, input: Readonly<{
15
+ commandPath: CliTelemetryCommand;
16
+ offline: boolean;
17
+ }>): void;