@harrylabsj/kiwi 0.12.30 → 0.12.32

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 (330) hide show
  1. package/dist/a2a/node.d.ts +1 -0
  2. package/dist/a2a/node.js +170 -2
  3. package/dist/a2a/node.js.map +1 -1
  4. package/dist/a2a/reception/agent-runtime.d.ts +32 -1
  5. package/dist/a2a/reception/agent-runtime.js +420 -11
  6. package/dist/a2a/reception/agent-runtime.js.map +1 -1
  7. package/dist/a2a/reception/customer-memory-tools.d.ts +73 -0
  8. package/dist/a2a/reception/customer-memory-tools.js +17 -0
  9. package/dist/a2a/reception/customer-memory-tools.js.map +1 -0
  10. package/dist/a2a/reception/engine.d.ts +12 -0
  11. package/dist/a2a/reception/engine.js +42 -1
  12. package/dist/a2a/reception/engine.js.map +1 -1
  13. package/dist/a2a/reception/publish.d.ts +14 -1
  14. package/dist/a2a/reception/publish.js +62 -1
  15. package/dist/a2a/reception/publish.js.map +1 -1
  16. package/dist/a2a/reception/question-spec.d.ts +91 -0
  17. package/dist/a2a/reception/question-spec.js +260 -0
  18. package/dist/a2a/reception/question-spec.js.map +1 -0
  19. package/dist/a2a/reception/reply-outbox.d.ts +6 -0
  20. package/dist/a2a/reception/reply-outbox.js +44 -0
  21. package/dist/a2a/reception/reply-outbox.js.map +1 -1
  22. package/dist/a2a/reception/responder.d.ts +13 -1
  23. package/dist/a2a/reception/responder.js +26 -3
  24. package/dist/a2a/reception/responder.js.map +1 -1
  25. package/dist/a2a/reception/skill-catalog.d.ts +72 -0
  26. package/dist/a2a/reception/skill-catalog.js +85 -0
  27. package/dist/a2a/reception/skill-catalog.js.map +1 -0
  28. package/dist/a2a/reception/skill-contract.d.ts +70 -0
  29. package/dist/a2a/reception/skill-contract.js +183 -0
  30. package/dist/a2a/reception/skill-contract.js.map +1 -0
  31. package/dist/a2a/reception/types.d.ts +12 -0
  32. package/dist/a2a/server/customer-identity-gateway.d.ts +111 -0
  33. package/dist/a2a/server/customer-identity-gateway.js +441 -0
  34. package/dist/a2a/server/customer-identity-gateway.js.map +1 -0
  35. package/dist/a2a/server/merchant-handler.d.ts +56 -1
  36. package/dist/a2a/server/merchant-handler.js +659 -44
  37. package/dist/a2a/server/merchant-handler.js.map +1 -1
  38. package/dist/a2a/server/pipeline.js +74 -29
  39. package/dist/a2a/server/pipeline.js.map +1 -1
  40. package/dist/a2a/server/types.d.ts +2 -0
  41. package/dist/a2a/unit-alias.d.ts +3 -3
  42. package/dist/a2a/unit-alias.js +9 -5
  43. package/dist/a2a/unit-alias.js.map +1 -1
  44. package/dist/agent/buyer/buyer-tools.js +1 -2
  45. package/dist/agent/buyer/buyer-tools.js.map +1 -1
  46. package/dist/agent/buyer/search-loop.js +0 -1
  47. package/dist/agent/buyer/search-loop.js.map +1 -1
  48. package/dist/auth/merchant-sessions.d.ts +3 -0
  49. package/dist/auth/merchant-sessions.js +21 -5
  50. package/dist/auth/merchant-sessions.js.map +1 -1
  51. package/dist/buyer-core/a2a-knp.d.ts +4 -2
  52. package/dist/buyer-core/a2a-knp.js +5 -2
  53. package/dist/buyer-core/a2a-knp.js.map +1 -1
  54. package/dist/buyer-core/a2a-negotiator.d.ts +1 -0
  55. package/dist/buyer-core/a2a-negotiator.js +18 -11
  56. package/dist/buyer-core/a2a-negotiator.js.map +1 -1
  57. package/dist/buyer-core/a2a-quote-fetcher.d.ts +25 -0
  58. package/dist/buyer-core/a2a-quote-fetcher.js +82 -4
  59. package/dist/buyer-core/a2a-quote-fetcher.js.map +1 -1
  60. package/dist/buyer-core/a2a-quote-history.d.ts +94 -0
  61. package/dist/buyer-core/a2a-quote-history.js +149 -0
  62. package/dist/buyer-core/a2a-quote-history.js.map +1 -0
  63. package/dist/buyer-core/build-service.d.ts +19 -0
  64. package/dist/buyer-core/build-service.js +30 -1
  65. package/dist/buyer-core/build-service.js.map +1 -1
  66. package/dist/buyer-core/errors.d.ts +1 -1
  67. package/dist/buyer-core/errors.js +1 -0
  68. package/dist/buyer-core/errors.js.map +1 -1
  69. package/dist/buyer-core/merchant-index.js +0 -1
  70. package/dist/buyer-core/merchant-index.js.map +1 -1
  71. package/dist/buyer-core/open-inquiry-signer.d.ts +1 -0
  72. package/dist/buyer-core/open-inquiry-signer.js +5 -2
  73. package/dist/buyer-core/open-inquiry-signer.js.map +1 -1
  74. package/dist/buyer-core/protocol-recovery.d.ts +2 -1
  75. package/dist/buyer-core/protocol-recovery.js +14 -4
  76. package/dist/buyer-core/protocol-recovery.js.map +1 -1
  77. package/dist/buyer-core/service.d.ts +58 -5
  78. package/dist/buyer-core/service.js +279 -53
  79. package/dist/buyer-core/service.js.map +1 -1
  80. package/dist/buyer-core/store.d.ts +8 -0
  81. package/dist/buyer-core/store.js +37 -7
  82. package/dist/buyer-core/store.js.map +1 -1
  83. package/dist/cli.js +136 -34
  84. package/dist/cli.js.map +1 -1
  85. package/dist/cloud/bootstrap.d.ts +1 -1
  86. package/dist/cloud/bootstrap.js +162 -35
  87. package/dist/cloud/bootstrap.js.map +1 -1
  88. package/dist/cloud/product-import-tabular.js +13 -5
  89. package/dist/cloud/product-import-tabular.js.map +1 -1
  90. package/dist/cloud/trade-platforms-client.d.ts +30 -0
  91. package/dist/cloud/trade-platforms-client.js +34 -1
  92. package/dist/cloud/trade-platforms-client.js.map +1 -1
  93. package/dist/commerce/receipt/dispatcher.d.ts +42 -0
  94. package/dist/commerce/receipt/dispatcher.js +68 -0
  95. package/dist/commerce/receipt/dispatcher.js.map +1 -0
  96. package/dist/commerce/receipt/receipts.d.ts +140 -0
  97. package/dist/commerce/receipt/receipts.js +247 -0
  98. package/dist/commerce/receipt/receipts.js.map +1 -0
  99. package/dist/config/profile.d.ts +2 -2
  100. package/dist/handoff/order-receipts.d.ts +62 -0
  101. package/dist/handoff/order-receipts.js +71 -0
  102. package/dist/handoff/order-receipts.js.map +1 -0
  103. package/dist/handoff/trade-platform-rules.js +5 -2
  104. package/dist/handoff/trade-platform-rules.js.map +1 -1
  105. package/dist/handoff/ucp-checkout/cart-channel.d.ts +2 -1
  106. package/dist/handoff/ucp-checkout/cart-channel.js +1 -0
  107. package/dist/handoff/ucp-checkout/cart-channel.js.map +1 -1
  108. package/dist/handoff/ucp-checkout/channel.d.ts +6 -0
  109. package/dist/handoff/ucp-checkout/channel.js +44 -0
  110. package/dist/handoff/ucp-checkout/channel.js.map +1 -1
  111. package/dist/http/cli.js +6 -0
  112. package/dist/http/cli.js.map +1 -1
  113. package/dist/http/merchant-management/api.d.ts +11 -1
  114. package/dist/http/merchant-management/api.js +471 -3
  115. package/dist/http/merchant-management/api.js.map +1 -1
  116. package/dist/http/merchant-management/draft-store.js +8 -6
  117. package/dist/http/merchant-management/draft-store.js.map +1 -1
  118. package/dist/http/merchant-management/page.js +83 -22
  119. package/dist/http/merchant-management/page.js.map +1 -1
  120. package/dist/mcp/cli.js +6 -0
  121. package/dist/mcp/cli.js.map +1 -1
  122. package/dist/mcp/merchant-runtime-assembly.d.ts +20 -0
  123. package/dist/mcp/merchant-runtime-assembly.js +93 -3
  124. package/dist/mcp/merchant-runtime-assembly.js.map +1 -1
  125. package/dist/mcp/merchant-server.d.ts +5 -0
  126. package/dist/mcp/merchant-server.js +12 -0
  127. package/dist/mcp/merchant-server.js.map +1 -1
  128. package/dist/mcp/tools.js +12 -3
  129. package/dist/mcp/tools.js.map +1 -1
  130. package/dist/merchant/application/actor.d.ts +1 -1
  131. package/dist/merchant/application/actor.js +15 -0
  132. package/dist/merchant/application/actor.js.map +1 -1
  133. package/dist/merchant/workbench-server.d.ts +38 -0
  134. package/dist/merchant/workbench-server.js +428 -0
  135. package/dist/merchant/workbench-server.js.map +1 -0
  136. package/dist/merchant-core/budget/background-budget.d.ts +132 -0
  137. package/dist/merchant-core/budget/background-budget.js +308 -0
  138. package/dist/merchant-core/budget/background-budget.js.map +1 -0
  139. package/dist/merchant-core/context-governance/actor-context.d.ts +56 -0
  140. package/dist/merchant-core/context-governance/actor-context.js +76 -0
  141. package/dist/merchant-core/context-governance/actor-context.js.map +1 -0
  142. package/dist/merchant-core/context-governance/authority.d.ts +39 -0
  143. package/dist/merchant-core/context-governance/authority.js +28 -0
  144. package/dist/merchant-core/context-governance/authority.js.map +1 -0
  145. package/dist/merchant-core/context-governance/context-guard.d.ts +104 -0
  146. package/dist/merchant-core/context-governance/context-guard.js +194 -0
  147. package/dist/merchant-core/context-governance/context-guard.js.map +1 -0
  148. package/dist/merchant-core/context-governance/data-use-grant.d.ts +91 -0
  149. package/dist/merchant-core/context-governance/data-use-grant.js +211 -0
  150. package/dist/merchant-core/context-governance/data-use-grant.js.map +1 -0
  151. package/dist/merchant-core/context-governance/feature-flags.d.ts +32 -0
  152. package/dist/merchant-core/context-governance/feature-flags.js +83 -0
  153. package/dist/merchant-core/context-governance/feature-flags.js.map +1 -0
  154. package/dist/merchant-core/context-governance/pilot-readiness.d.ts +39 -0
  155. package/dist/merchant-core/context-governance/pilot-readiness.js +141 -0
  156. package/dist/merchant-core/context-governance/pilot-readiness.js.map +1 -0
  157. package/dist/merchant-core/context-governance/source-governance.d.ts +157 -0
  158. package/dist/merchant-core/context-governance/source-governance.js +492 -0
  159. package/dist/merchant-core/context-governance/source-governance.js.map +1 -0
  160. package/dist/merchant-core/context-governance/types.d.ts +62 -0
  161. package/dist/merchant-core/context-governance/types.js +92 -0
  162. package/dist/merchant-core/context-governance/types.js.map +1 -0
  163. package/dist/merchant-core/customer-delivery/binding.d.ts +55 -0
  164. package/dist/merchant-core/customer-delivery/binding.js +121 -0
  165. package/dist/merchant-core/customer-delivery/binding.js.map +1 -0
  166. package/dist/merchant-core/customer-delivery/channel.d.ts +75 -0
  167. package/dist/merchant-core/customer-delivery/channel.js +157 -0
  168. package/dist/merchant-core/customer-delivery/channel.js.map +1 -0
  169. package/dist/merchant-core/customer-delivery/consent-repository.d.ts +50 -0
  170. package/dist/merchant-core/customer-delivery/consent-repository.js +160 -0
  171. package/dist/merchant-core/customer-delivery/consent-repository.js.map +1 -0
  172. package/dist/merchant-core/customer-delivery/dispatcher-loop.d.ts +68 -0
  173. package/dist/merchant-core/customer-delivery/dispatcher-loop.js +132 -0
  174. package/dist/merchant-core/customer-delivery/dispatcher-loop.js.map +1 -0
  175. package/dist/merchant-core/customer-delivery/dispatcher.d.ts +118 -0
  176. package/dist/merchant-core/customer-delivery/dispatcher.js +166 -0
  177. package/dist/merchant-core/customer-delivery/dispatcher.js.map +1 -0
  178. package/dist/merchant-core/customer-delivery/email-adapter.d.ts +31 -0
  179. package/dist/merchant-core/customer-delivery/email-adapter.js +90 -0
  180. package/dist/merchant-core/customer-delivery/email-adapter.js.map +1 -0
  181. package/dist/merchant-core/customer-delivery/gate.d.ts +37 -0
  182. package/dist/merchant-core/customer-delivery/gate.js +196 -0
  183. package/dist/merchant-core/customer-delivery/gate.js.map +1 -0
  184. package/dist/merchant-core/customer-delivery/reconciliation.d.ts +13 -0
  185. package/dist/merchant-core/customer-delivery/reconciliation.js +70 -0
  186. package/dist/merchant-core/customer-delivery/reconciliation.js.map +1 -0
  187. package/dist/merchant-core/customer-delivery/repository.d.ts +55 -0
  188. package/dist/merchant-core/customer-delivery/repository.js +235 -0
  189. package/dist/merchant-core/customer-delivery/repository.js.map +1 -0
  190. package/dist/merchant-core/customer-delivery/smtp-adapter.d.ts +30 -0
  191. package/dist/merchant-core/customer-delivery/smtp-adapter.js +183 -0
  192. package/dist/merchant-core/customer-delivery/smtp-adapter.js.map +1 -0
  193. package/dist/merchant-core/customer-delivery/stream-gate.d.ts +45 -0
  194. package/dist/merchant-core/customer-delivery/stream-gate.js +123 -0
  195. package/dist/merchant-core/customer-delivery/stream-gate.js.map +1 -0
  196. package/dist/merchant-core/customer-delivery/types.d.ts +103 -0
  197. package/dist/merchant-core/customer-delivery/types.js +32 -0
  198. package/dist/merchant-core/customer-delivery/types.js.map +1 -0
  199. package/dist/merchant-core/customer-delivery/weixin-adapter.d.ts +35 -0
  200. package/dist/merchant-core/customer-delivery/weixin-adapter.js +56 -0
  201. package/dist/merchant-core/customer-delivery/weixin-adapter.js.map +1 -0
  202. package/dist/merchant-core/customer-memory/auto-identity.d.ts +43 -0
  203. package/dist/merchant-core/customer-memory/auto-identity.js +163 -0
  204. package/dist/merchant-core/customer-memory/auto-identity.js.map +1 -0
  205. package/dist/merchant-core/customer-memory/grants.d.ts +72 -0
  206. package/dist/merchant-core/customer-memory/grants.js +224 -0
  207. package/dist/merchant-core/customer-memory/grants.js.map +1 -0
  208. package/dist/merchant-core/customer-memory/history.d.ts +51 -0
  209. package/dist/merchant-core/customer-memory/history.js +252 -0
  210. package/dist/merchant-core/customer-memory/history.js.map +1 -0
  211. package/dist/merchant-core/customer-memory/identity.d.ts +66 -0
  212. package/dist/merchant-core/customer-memory/identity.js +249 -0
  213. package/dist/merchant-core/customer-memory/identity.js.map +1 -0
  214. package/dist/merchant-core/customer-memory/maintenance.d.ts +51 -0
  215. package/dist/merchant-core/customer-memory/maintenance.js +67 -0
  216. package/dist/merchant-core/customer-memory/maintenance.js.map +1 -0
  217. package/dist/merchant-core/customer-memory/memory.d.ts +119 -0
  218. package/dist/merchant-core/customer-memory/memory.js +502 -0
  219. package/dist/merchant-core/customer-memory/memory.js.map +1 -0
  220. package/dist/merchant-core/customer-memory/private-transport.d.ts +10 -0
  221. package/dist/merchant-core/customer-memory/private-transport.js +108 -0
  222. package/dist/merchant-core/customer-memory/private-transport.js.map +1 -0
  223. package/dist/merchant-core/customer-memory/quote-history.d.ts +160 -0
  224. package/dist/merchant-core/customer-memory/quote-history.js +392 -0
  225. package/dist/merchant-core/customer-memory/quote-history.js.map +1 -0
  226. package/dist/merchant-core/customer-memory/reception-provider.d.ts +69 -0
  227. package/dist/merchant-core/customer-memory/reception-provider.js +250 -0
  228. package/dist/merchant-core/customer-memory/reception-provider.js.map +1 -0
  229. package/dist/merchant-core/customer-memory/reception-writer.d.ts +19 -0
  230. package/dist/merchant-core/customer-memory/reception-writer.js +32 -0
  231. package/dist/merchant-core/customer-memory/reception-writer.js.map +1 -0
  232. package/dist/merchant-core/customer-memory/types.d.ts +111 -0
  233. package/dist/merchant-core/customer-memory/types.js +58 -0
  234. package/dist/merchant-core/customer-memory/types.js.map +1 -0
  235. package/dist/merchant-core/followup/repository.d.ts +2 -1
  236. package/dist/merchant-core/followup/repository.js +29 -23
  237. package/dist/merchant-core/followup/repository.js.map +1 -1
  238. package/dist/merchant-core/learning/evaluation-fixtures.d.ts +38 -0
  239. package/dist/merchant-core/learning/evaluation-fixtures.js +83 -0
  240. package/dist/merchant-core/learning/evaluation-fixtures.js.map +1 -0
  241. package/dist/merchant-core/learning/evaluation-suite-v1.d.ts +56 -0
  242. package/dist/merchant-core/learning/evaluation-suite-v1.js +129 -0
  243. package/dist/merchant-core/learning/evaluation-suite-v1.js.map +1 -0
  244. package/dist/merchant-core/learning/evaluation.d.ts +84 -0
  245. package/dist/merchant-core/learning/evaluation.js +581 -0
  246. package/dist/merchant-core/learning/evaluation.js.map +1 -0
  247. package/dist/merchant-core/learning/initial-skills.d.ts +36 -0
  248. package/dist/merchant-core/learning/initial-skills.js +67 -0
  249. package/dist/merchant-core/learning/initial-skills.js.map +1 -0
  250. package/dist/merchant-core/learning/precheck.d.ts +33 -0
  251. package/dist/merchant-core/learning/precheck.js +56 -0
  252. package/dist/merchant-core/learning/precheck.js.map +1 -0
  253. package/dist/merchant-core/learning/real-evaluation-runner.d.ts +52 -0
  254. package/dist/merchant-core/learning/real-evaluation-runner.js +167 -0
  255. package/dist/merchant-core/learning/real-evaluation-runner.js.map +1 -0
  256. package/dist/merchant-core/learning/reception-skill-catalog.d.ts +39 -0
  257. package/dist/merchant-core/learning/reception-skill-catalog.js +145 -0
  258. package/dist/merchant-core/learning/reception-skill-catalog.js.map +1 -0
  259. package/dist/merchant-core/learning/recovery-gateway.d.ts +27 -0
  260. package/dist/merchant-core/learning/recovery-gateway.js +106 -0
  261. package/dist/merchant-core/learning/recovery-gateway.js.map +1 -0
  262. package/dist/merchant-core/learning/repository.d.ts +130 -0
  263. package/dist/merchant-core/learning/repository.js +588 -0
  264. package/dist/merchant-core/learning/repository.js.map +1 -0
  265. package/dist/merchant-core/learning/service.d.ts +262 -0
  266. package/dist/merchant-core/learning/service.js +1498 -0
  267. package/dist/merchant-core/learning/service.js.map +1 -0
  268. package/dist/merchant-core/learning/test-dispatch-gateway.d.ts +43 -0
  269. package/dist/merchant-core/learning/test-dispatch-gateway.js +145 -0
  270. package/dist/merchant-core/learning/test-dispatch-gateway.js.map +1 -0
  271. package/dist/merchant-core/learning/types.d.ts +217 -0
  272. package/dist/merchant-core/learning/types.js +52 -0
  273. package/dist/merchant-core/learning/types.js.map +1 -0
  274. package/dist/merchant-core/migrations/ledgers.d.ts +40 -0
  275. package/dist/merchant-core/migrations/ledgers.js +824 -0
  276. package/dist/merchant-core/migrations/ledgers.js.map +1 -0
  277. package/dist/merchant-core/migrations/runner.d.ts +55 -0
  278. package/dist/merchant-core/migrations/runner.js +114 -0
  279. package/dist/merchant-core/migrations/runner.js.map +1 -0
  280. package/dist/merchant-core/operations-jobs/advice-runner.d.ts +63 -0
  281. package/dist/merchant-core/operations-jobs/advice-runner.js +199 -0
  282. package/dist/merchant-core/operations-jobs/advice-runner.js.map +1 -0
  283. package/dist/merchant-core/operations-jobs/pilot-evidence.d.ts +64 -0
  284. package/dist/merchant-core/operations-jobs/pilot-evidence.js +109 -0
  285. package/dist/merchant-core/operations-jobs/pilot-evidence.js.map +1 -0
  286. package/dist/merchant-core/operations-jobs/pilot-metrics.d.ts +70 -0
  287. package/dist/merchant-core/operations-jobs/pilot-metrics.js +98 -0
  288. package/dist/merchant-core/operations-jobs/pilot-metrics.js.map +1 -0
  289. package/dist/merchant-core/operations-jobs/projection.d.ts +41 -0
  290. package/dist/merchant-core/operations-jobs/projection.js +158 -0
  291. package/dist/merchant-core/operations-jobs/projection.js.map +1 -0
  292. package/dist/merchant-core/operations-jobs/scheduler.d.ts +68 -0
  293. package/dist/merchant-core/operations-jobs/scheduler.js +233 -0
  294. package/dist/merchant-core/operations-jobs/scheduler.js.map +1 -0
  295. package/dist/merchant-core/operations-jobs/service.d.ts +260 -0
  296. package/dist/merchant-core/operations-jobs/service.js +922 -0
  297. package/dist/merchant-core/operations-jobs/service.js.map +1 -0
  298. package/dist/merchant-core/ops/facade.d.ts +10 -0
  299. package/dist/merchant-core/ops/facade.js +52 -0
  300. package/dist/merchant-core/ops/facade.js.map +1 -1
  301. package/dist/merchant-core/ops/schema.d.ts +1 -1
  302. package/dist/merchant-core/ops/schema.js +119 -2
  303. package/dist/merchant-core/ops/schema.js.map +1 -1
  304. package/dist/merchant-core/ops/surface.d.ts +37 -0
  305. package/dist/merchant-core/ops/surface.js +240 -0
  306. package/dist/merchant-core/ops/surface.js.map +1 -1
  307. package/dist/merchant-core/ownership/instance-ownership.d.ts +122 -0
  308. package/dist/merchant-core/ownership/instance-ownership.js +236 -0
  309. package/dist/merchant-core/ownership/instance-ownership.js.map +1 -0
  310. package/dist/merchant-core/ownership/runtime.d.ts +175 -0
  311. package/dist/merchant-core/ownership/runtime.js +422 -0
  312. package/dist/merchant-core/ownership/runtime.js.map +1 -0
  313. package/dist/merchant-core/storage/transaction.d.ts +102 -7
  314. package/dist/merchant-core/storage/transaction.js +274 -3
  315. package/dist/merchant-core/storage/transaction.js.map +1 -1
  316. package/dist/merchant-credential-rotation.d.ts +4 -1
  317. package/dist/merchant-credential-rotation.js +12 -8
  318. package/dist/merchant-credential-rotation.js.map +1 -1
  319. package/dist/merchant-gateway/catalog-tools.js +4 -2
  320. package/dist/merchant-gateway/catalog-tools.js.map +1 -1
  321. package/dist/merchant-runtime/manager.d.ts +2 -0
  322. package/dist/merchant-runtime/manager.js +5 -0
  323. package/dist/merchant-runtime/manager.js.map +1 -1
  324. package/dist/product-buyer.d.ts +1 -0
  325. package/dist/product-buyer.js +0 -1
  326. package/dist/product-buyer.js.map +1 -1
  327. package/dist/product-cli.js +11 -1
  328. package/dist/product-cli.js.map +1 -1
  329. package/package.json +5 -3
  330. package/skills/kiwi-buyer/SKILL.md +1 -1
@@ -6,6 +6,8 @@
6
6
  * 兜底文案,绝不回显原文或泄露内部错误。
7
7
  */
8
8
  import { uuidv7 } from "../../negotiation/domain/identifiers.js";
9
+ import { StreamGateError } from "../../merchant-core/customer-delivery/stream-gate.js";
10
+ import { rateLimited } from "../server/errors.js";
9
11
  const FALLBACK_TEXT = "抱歉,当前无法处理这条消息,请稍后重试,或直接发送 RFQ(SKU、数量、单位)。";
10
12
  /** 从 1.0 wire parts 中取出文本(兼容 {text} 与 {kind:"text",text})。 */
11
13
  export function textPartsOf(message) {
@@ -31,7 +33,7 @@ function agentMessage(text) {
31
33
  },
32
34
  };
33
35
  }
34
- export function createReceptionResponder(engine, merchantId) {
36
+ export function createReceptionResponder(engine, merchantId, hooks) {
35
37
  return async (input) => {
36
38
  const text = textPartsOf(input.message);
37
39
  try {
@@ -46,9 +48,30 @@ export function createReceptionResponder(engine, merchantId) {
46
48
  ? { messageId: input.message.messageId }
47
49
  : {}),
48
50
  });
49
- return agentMessage(result.text);
51
+ // K1:判定为有效询价且身份已验签时通知业务边界(建档);
52
+ // 建档失败不影响回复(writer 内部已收敛并可靠重试)。
53
+ if (result.recognizedInquiry && input.identityVerified === true && hooks?.onVerifiedInquiry !== undefined) {
54
+ try {
55
+ hooks.onVerifiedInquiry({
56
+ identity: input.identity,
57
+ contextId: input.contextId,
58
+ ...(typeof input.message.messageId === "string"
59
+ ? { messageId: input.message.messageId }
60
+ : {}),
61
+ });
62
+ }
63
+ catch {
64
+ // 钩子异常不阻断接待回复。
65
+ }
66
+ }
67
+ const history = input.identityVerified === true && input.identity !== undefined
68
+ ? hooks?.historyNote?.({ identity: input.identity, text }) ?? ""
69
+ : "";
70
+ return agentMessage(result.text + history);
50
71
  }
51
- catch {
72
+ catch (error) {
73
+ if (error instanceof StreamGateError)
74
+ throw rateLimited(2, "reception_stream_busy");
52
75
  return agentMessage(FALLBACK_TEXT);
53
76
  }
54
77
  };
@@ -1 +1 @@
1
- {"version":3,"file":"responder.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AC,iBAAiB,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI,IAAI,KAAK,EAAE,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBAC1G,IAAI,CAAC;oBACH,KAAK,CAAC,iBAAiB,CAAC;wBACtB,QAAQ,EAAE,KAAK,CAAC,QAAkB;wBAClC,SAAS,EAAE,KAAK,CAAC,SAAS;wBAC1B,GAAG,CAAC,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,KAAK,QAAQ;4BAC7C,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE;4BACxC,CAAC,CAAC,EAAE,CAAC;qBACR,CAAC,CAAC;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,eAAe;gBACjB,CAAC;YACH,CAAC;YACD,MAAM,OAAO,GAAG,KAAK,CAAC,gBAAgB,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;gBAC7E,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;gBAChE,CAAC,CAAC,EAAE,CAAC;YACP,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,eAAe;gBAAE,MAAM,WAAW,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC;YACpF,OAAO,YAAY,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * 接待技能目录(设计 v1.1 §7.1 / D-M0-04 / M2-6)。
18
+ *
19
+ * 运行开始时固定 `skill_bindings`;`skill_summaries` 只含 skill_key、一句
20
+ * 触发条件与版本/hash,不含正文(最多 5 项、合计不超过 600 中文字符)。
21
+ * `load_reception_skill` 只能加载快照中的确切产物,不重新解析 ACTIVE 指针,
22
+ * 也不回退到 owner 目录;未绑定/已撤回/超限一律拒绝。
23
+ */
24
+ import type { CurrentSkillBinding } from "../../merchant-core/context-governance/context-guard.js";
25
+ import type { ReceptionSkillStep, ReceptionSkillTool } from "./skill-contract.js";
26
+ export declare const MAX_SKILL_SUMMARIES = 5;
27
+ export declare const MAX_SKILL_SUMMARY_CHARS = 600;
28
+ export declare const MAX_LOADED_SKILLS = 2;
29
+ export declare const MAX_LOADED_SKILL_CHARS = 3000;
30
+ export interface ReceptionSkillBinding {
31
+ readonly skill_key: string;
32
+ readonly release_id: string;
33
+ readonly compiled_artifact_hash: string;
34
+ readonly generation: number;
35
+ readonly revocation_epoch: number;
36
+ readonly trigger_text: string;
37
+ readonly question_schema_version: number;
38
+ readonly tool_contract_digest: string;
39
+ readonly body_text: string;
40
+ readonly steps: readonly ReceptionSkillStep[];
41
+ readonly required_tools: readonly ReceptionSkillTool[];
42
+ }
43
+ export interface ReceptionSkillSummary {
44
+ readonly skill_key: string;
45
+ readonly trigger: string;
46
+ readonly release_id: string;
47
+ readonly compiled_artifact_hash: string;
48
+ readonly generation: number;
49
+ readonly revocation_epoch: number;
50
+ readonly question_schema_version: number;
51
+ readonly tool_contract_digest: string;
52
+ }
53
+ export interface SkillSummaryResult {
54
+ readonly summaries: readonly ReceptionSkillSummary[];
55
+ /** 因 5 项/600 字上限截断(运行记录标注原因,不静默丢)。 */
56
+ readonly truncated: boolean;
57
+ }
58
+ export interface ReceptionSkillCatalog {
59
+ /** 当前生效版本(按 skill_key 稳定排序);撤回/退役后不再返回。 */
60
+ activeBindings(merchantId: string): ReceptionSkillBinding[];
61
+ /** 运行快照摘要(≤5 项 / ≤600 字,按 skill_key 排序)。 */
62
+ summaries(merchantId: string): SkillSummaryResult;
63
+ /** ContextGuard 权威值:当前 ACTIVE 绑定;undefined = 未绑定/已撤回。 */
64
+ currentBinding(merchantId: string, skillKey: string): CurrentSkillBinding | undefined;
65
+ /** 加载快照绑定的冻结产物;release 不再生效时返回 undefined。 */
66
+ loadArtifact(merchantId: string, skillKey: string, releaseId: string): ReceptionSkillBinding | undefined;
67
+ }
68
+ export declare function summarizeBindings(bindings: readonly ReceptionSkillBinding[]): SkillSummaryResult;
69
+ /** 模型 prompt 里的技能摘要(不含正文)。 */
70
+ /** 固定快照目录(评测/测试用):绑定列表不可变,load 只返回对应 release。 */
71
+ export declare function createStaticSkillCatalog(bindings: readonly ReceptionSkillBinding[]): ReceptionSkillCatalog;
72
+ export declare function skillSummaryPrompt(result: SkillSummaryResult): string;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export const MAX_SKILL_SUMMARIES = 5;
17
+ export const MAX_SKILL_SUMMARY_CHARS = 600;
18
+ export const MAX_LOADED_SKILLS = 2;
19
+ export const MAX_LOADED_SKILL_CHARS = 3_000;
20
+ function oneLine(value, max = 120) {
21
+ return value.replace(/\s+/g, " ").trim().slice(0, max);
22
+ }
23
+ export function summarizeBindings(bindings) {
24
+ const sorted = [...bindings].sort((a, b) => a.skill_key.localeCompare(b.skill_key));
25
+ const summaries = [];
26
+ let chars = 0;
27
+ let truncated = false;
28
+ for (const binding of sorted) {
29
+ if (summaries.length >= MAX_SKILL_SUMMARIES) {
30
+ truncated = true;
31
+ break;
32
+ }
33
+ const trigger = oneLine(binding.trigger_text);
34
+ const length = binding.skill_key.length + trigger.length;
35
+ if (chars + length > MAX_SKILL_SUMMARY_CHARS) {
36
+ truncated = true;
37
+ break;
38
+ }
39
+ chars += length;
40
+ summaries.push({
41
+ skill_key: binding.skill_key,
42
+ trigger,
43
+ release_id: binding.release_id,
44
+ compiled_artifact_hash: binding.compiled_artifact_hash,
45
+ generation: binding.generation,
46
+ revocation_epoch: binding.revocation_epoch,
47
+ question_schema_version: binding.question_schema_version,
48
+ tool_contract_digest: binding.tool_contract_digest,
49
+ });
50
+ }
51
+ return { summaries, truncated };
52
+ }
53
+ /** 模型 prompt 里的技能摘要(不含正文)。 */
54
+ /** 固定快照目录(评测/测试用):绑定列表不可变,load 只返回对应 release。 */
55
+ export function createStaticSkillCatalog(bindings) {
56
+ const byKey = new Map(bindings.map((binding) => [binding.skill_key, binding]));
57
+ return {
58
+ activeBindings: () => [...bindings],
59
+ summaries: () => summarizeBindings(bindings),
60
+ currentBinding: (_merchantId, skillKey) => {
61
+ const binding = byKey.get(skillKey);
62
+ return binding === undefined
63
+ ? undefined
64
+ : {
65
+ release_id: binding.release_id,
66
+ compiled_artifact_hash: binding.compiled_artifact_hash,
67
+ generation: binding.generation,
68
+ revocation_epoch: binding.revocation_epoch,
69
+ };
70
+ },
71
+ loadArtifact: (_merchantId, skillKey, releaseId) => {
72
+ const binding = byKey.get(skillKey);
73
+ return binding !== undefined && binding.release_id === releaseId ? binding : undefined;
74
+ },
75
+ };
76
+ }
77
+ export function skillSummaryPrompt(result) {
78
+ if (result.summaries.length === 0)
79
+ return "";
80
+ return [
81
+ "Published reception skills for this merchant (choose skill_key and call load_reception_skill; summaries contain no body):",
82
+ ...result.summaries.map((summary) => `- ${summary.skill_key}: ${summary.trigger}`),
83
+ ].join("\n");
84
+ }
85
+ //# sourceMappingURL=skill-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-catalog.js","sourceRoot":"","sources":["../../../src/a2a/reception/skill-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAgD5C,SAAS,OAAO,CAAC,KAAa,EAAE,GAAG,GAAG,GAAG;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,QAA0C;IAE1C,MAAM,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACpF,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAAC;QAC7B,IAAI,SAAS,CAAC,MAAM,IAAI,mBAAmB,EAAE,CAAC;YAC5C,SAAS,GAAG,IAAI,CAAC;YACjB,MAAM;QACR,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;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C9B,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;oBACtD,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;iBAC3C,CAAC;QACR,CAAC;QACD,YAAY,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;YACjD,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACpC,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QACzF,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC7C,OAAO;QACL,2HAA2H;QAC3H,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,SAAS,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;KACnF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { type QuestionSpecRegistry } from "./question-spec.js";
17
+ /** 技能步骤允许的动作(工具 + 受控问题/转人工/回复)。 */
18
+ export declare const RECEPTION_SKILL_ACTIONS: readonly ["search_products", "compare_products", "get_commercial_facts", "propose_need_patch", "ask_registered_question", "request_human_help", "propose_reply"];
19
+ export type ReceptionSkillAction = (typeof RECEPTION_SKILL_ACTIONS)[number];
20
+ /** 可声明为 required_tools 的工具子集(问题块与转人工不是工具)。 */
21
+ export declare const RECEPTION_SKILL_TOOLS: readonly ["search_products", "compare_products", "get_commercial_facts", "propose_need_patch", "propose_reply"];
22
+ export type ReceptionSkillTool = (typeof RECEPTION_SKILL_TOOLS)[number];
23
+ /** 固定守卫注册表:技能只能用这些已实现的槽位/事实守卫。 */
24
+ export declare const RECEPTION_SKILL_GUARDS: readonly ["sku_unresolved", "quantity_unresolved", "unit_unresolved", "facts_stale"];
25
+ export type ReceptionSkillGuard = (typeof RECEPTION_SKILL_GUARDS)[number];
26
+ /** 工具契约版本;工具/动作/守卫注册表变化必须递增并重新评测。 */
27
+ export declare const RECEPTION_TOOL_CONTRACT_VERSION = "reception-tools/1";
28
+ export declare const RECEPTION_SKILL_COMPILER_VERSION = "reception-skill-compiler/1";
29
+ export declare const MAX_SKILL_STEPS = 12;
30
+ export declare const MAX_SKILL_BODY_CHARS = 3000;
31
+ export type SkillContractErrorCode = "validation" | "unsupported_capability";
32
+ export declare class SkillContractError extends Error {
33
+ readonly code: SkillContractErrorCode;
34
+ readonly reason: string;
35
+ constructor(code: SkillContractErrorCode, reason: string, message: string);
36
+ }
37
+ export interface ReceptionSkillStep {
38
+ readonly action_ref: ReceptionSkillAction;
39
+ readonly question_id?: string;
40
+ readonly guard_ref?: ReceptionSkillGuard;
41
+ }
42
+ export interface CompiledReceptionSkill {
43
+ readonly schema_version: 1;
44
+ readonly skill_key: string;
45
+ readonly audience: "customer_reception";
46
+ readonly steps: readonly ReceptionSkillStep[];
47
+ readonly body_text: string;
48
+ readonly question_schema_version: number;
49
+ readonly required_tools: readonly ReceptionSkillTool[];
50
+ readonly tool_contract_version: string;
51
+ }
52
+ export interface CompiledArtifact {
53
+ readonly artifact: CompiledReceptionSkill;
54
+ readonly artifact_hash: string;
55
+ readonly compiler_version: string;
56
+ readonly tool_contract_digest: string;
57
+ }
58
+ /** 工具契约摘要:动作/工具/守卫/版本任何变化都会让旧评测与批准失效。 */
59
+ export declare function receptionToolContractDigest(): string;
60
+ export declare function isValidSkillKey(value: string): boolean;
61
+ /**
62
+ * 校验并编译技能步骤。调用方负责 trigger/reason/exclusions 的文本预检;
63
+ * 本函数只处理结构化步骤、问题 ID、工具与守卫注册表。
64
+ */
65
+ export declare function compileReceptionSkillArtifact(input: {
66
+ skill_key: string;
67
+ steps: readonly unknown[];
68
+ required_tools?: readonly string[];
69
+ questionRegistry?: QuestionSpecRegistry;
70
+ }): CompiledArtifact;
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * 接待技能编译契约(设计 v1.1 §5.2 / §7.1 / 附录 C1-C2 / M2-3)。
18
+ *
19
+ * 候选只能改接待流程与已批准的问题选择:步骤 action_ref 来自固定注册表,
20
+ * question_id 必须已注册,guard_ref 来自固定守卫表;不能注册工具、读取任意
21
+ * URL/脚本或改写 HardPolicy。编译产物在评测前冻结——评测、审核与发布都绑定
22
+ * 同一 `compiled_artifact_hash`,发布只核验并激活,不重新生成正文。
23
+ */
24
+ import { contentDigest } from "../../negotiation/jcs.js";
25
+ import { DEFAULT_QUESTION_SPEC_REGISTRY, QUESTION_SCHEMA_VERSION, } from "./question-spec.js";
26
+ /** 技能步骤允许的动作(工具 + 受控问题/转人工/回复)。 */
27
+ export const RECEPTION_SKILL_ACTIONS = [
28
+ "search_products",
29
+ "compare_products",
30
+ "get_commercial_facts",
31
+ "propose_need_patch",
32
+ "ask_registered_question",
33
+ "request_human_help",
34
+ "propose_reply",
35
+ ];
36
+ /** 可声明为 required_tools 的工具子集(问题块与转人工不是工具)。 */
37
+ export const RECEPTION_SKILL_TOOLS = [
38
+ "search_products",
39
+ "compare_products",
40
+ "get_commercial_facts",
41
+ "propose_need_patch",
42
+ "propose_reply",
43
+ ];
44
+ /** 固定守卫注册表:技能只能用这些已实现的槽位/事实守卫。 */
45
+ export const RECEPTION_SKILL_GUARDS = [
46
+ "sku_unresolved",
47
+ "quantity_unresolved",
48
+ "unit_unresolved",
49
+ "facts_stale",
50
+ ];
51
+ /** 工具契约版本;工具/动作/守卫注册表变化必须递增并重新评测。 */
52
+ export const RECEPTION_TOOL_CONTRACT_VERSION = "reception-tools/1";
53
+ export const RECEPTION_SKILL_COMPILER_VERSION = "reception-skill-compiler/1";
54
+ export const MAX_SKILL_STEPS = 12;
55
+ export const MAX_SKILL_BODY_CHARS = 3_000;
56
+ export class SkillContractError extends Error {
57
+ code;
58
+ reason;
59
+ constructor(code, reason, message) {
60
+ super(message);
61
+ this.name = "SkillContractError";
62
+ this.code = code;
63
+ this.reason = reason;
64
+ }
65
+ }
66
+ const SKILL_KEY_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
67
+ const STEP_KEYS = new Set(["action_ref", "question_id", "guard_ref"]);
68
+ function fail(code, reason, message) {
69
+ throw new SkillContractError(code, reason, message);
70
+ }
71
+ function isObject(value) {
72
+ return typeof value === "object" && value !== null && !Array.isArray(value);
73
+ }
74
+ /** 工具契约摘要:动作/工具/守卫/版本任何变化都会让旧评测与批准失效。 */
75
+ export function receptionToolContractDigest() {
76
+ return contentDigest({
77
+ version: RECEPTION_TOOL_CONTRACT_VERSION,
78
+ actions: [...RECEPTION_SKILL_ACTIONS],
79
+ tools: [...RECEPTION_SKILL_TOOLS],
80
+ guards: [...RECEPTION_SKILL_GUARDS],
81
+ });
82
+ }
83
+ export function isValidSkillKey(value) {
84
+ return SKILL_KEY_PATTERN.test(value);
85
+ }
86
+ /**
87
+ * 校验并编译技能步骤。调用方负责 trigger/reason/exclusions 的文本预检;
88
+ * 本函数只处理结构化步骤、问题 ID、工具与守卫注册表。
89
+ */
90
+ export function compileReceptionSkillArtifact(input) {
91
+ if (!isValidSkillKey(input.skill_key)) {
92
+ fail("validation", "skill_key_invalid", "skill_key 必须是 lowercase kebab-case(<=64)");
93
+ }
94
+ if (!Array.isArray(input.steps) || input.steps.length === 0 || input.steps.length > MAX_SKILL_STEPS) {
95
+ fail("validation", "steps_invalid", `steps 必须为 1..${MAX_SKILL_STEPS} 步`);
96
+ }
97
+ const questions = input.questionRegistry ?? DEFAULT_QUESTION_SPEC_REGISTRY;
98
+ const steps = [];
99
+ for (const [index, raw] of input.steps.entries()) {
100
+ if (!isObject(raw))
101
+ fail("validation", "step_invalid", `第 ${index + 1} 步必须是对象`);
102
+ for (const key of Object.keys(raw)) {
103
+ if (!STEP_KEYS.has(key)) {
104
+ fail("validation", "step_unknown_field", `第 ${index + 1} 步含未知字段 ${key}`);
105
+ }
106
+ }
107
+ const actionRef = raw.action_ref;
108
+ if (typeof actionRef !== "string" ||
109
+ !RECEPTION_SKILL_ACTIONS.includes(actionRef)) {
110
+ fail("unsupported_capability", "action_ref_unsupported", `第 ${index + 1} 步 action_ref 不在固定注册表中`);
111
+ }
112
+ const questionId = raw.question_id;
113
+ const guardRef = raw.guard_ref;
114
+ if (questionId !== undefined) {
115
+ if (actionRef !== "ask_registered_question") {
116
+ fail("validation", "question_id_not_allowed", "只有 ask_registered_question 步骤可带 question_id");
117
+ }
118
+ if (typeof questionId !== "string" || questions.resolve(questionId) === undefined) {
119
+ fail("unsupported_capability", "question_not_registered", `question_id ${String(questionId)} 未注册`);
120
+ }
121
+ }
122
+ if (actionRef === "ask_registered_question" && questionId === undefined) {
123
+ fail("validation", "question_id_required", "ask_registered_question 必须带已注册 question_id");
124
+ }
125
+ if (guardRef !== undefined) {
126
+ if (typeof guardRef !== "string" ||
127
+ !RECEPTION_SKILL_GUARDS.includes(guardRef)) {
128
+ fail("unsupported_capability", "guard_ref_unsupported", `guard_ref ${String(guardRef)} 未注册`);
129
+ }
130
+ }
131
+ steps.push({
132
+ action_ref: actionRef,
133
+ ...(questionId !== undefined ? { question_id: questionId } : {}),
134
+ ...(guardRef !== undefined ? { guard_ref: guardRef } : {}),
135
+ });
136
+ }
137
+ const usedTools = [...new Set(steps.map((step) => step.action_ref))]
138
+ .filter((action) => RECEPTION_SKILL_TOOLS.includes(action))
139
+ .sort();
140
+ const requiredTools = input.required_tools === undefined ? usedTools : input.required_tools;
141
+ if (!Array.isArray(requiredTools)) {
142
+ fail("validation", "required_tools_invalid", "required_tools 必须是字符串数组");
143
+ }
144
+ const normalizedTools = [...new Set(requiredTools)].sort();
145
+ for (const tool of normalizedTools) {
146
+ if (!RECEPTION_SKILL_TOOLS.includes(tool)) {
147
+ fail("unsupported_capability", "tool_not_registered", `required_tools 含未注册工具 ${tool}`);
148
+ }
149
+ if (!usedTools.includes(tool)) {
150
+ fail("validation", "tool_not_used", `required_tools 声明了步骤中未使用的工具 ${tool}`);
151
+ }
152
+ }
153
+ const bodyText = steps
154
+ .map((step, index) => {
155
+ const parts = [`${index + 1}. ${step.action_ref}`];
156
+ if (step.question_id !== undefined)
157
+ parts.push(`question=${step.question_id}`);
158
+ if (step.guard_ref !== undefined)
159
+ parts.push(`guard=${step.guard_ref}`);
160
+ return parts.join(" ");
161
+ })
162
+ .join("\n");
163
+ if (bodyText.length > MAX_SKILL_BODY_CHARS) {
164
+ fail("validation", "body_too_long", `技能正文超过 ${MAX_SKILL_BODY_CHARS} 字符`);
165
+ }
166
+ const artifact = {
167
+ schema_version: 1,
168
+ skill_key: input.skill_key,
169
+ audience: "customer_reception",
170
+ steps,
171
+ body_text: bodyText,
172
+ question_schema_version: QUESTION_SCHEMA_VERSION,
173
+ required_tools: normalizedTools,
174
+ tool_contract_version: RECEPTION_TOOL_CONTRACT_VERSION,
175
+ };
176
+ return {
177
+ artifact,
178
+ artifact_hash: contentDigest(artifact),
179
+ compiler_version: RECEPTION_SKILL_COMPILER_VERSION,
180
+ tool_contract_digest: receptionToolContractDigest(),
181
+ };
182
+ }
183
+ //# sourceMappingURL=skill-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-contract.js","sourceRoot":"","sources":["../../../src/a2a/reception/skill-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,8BAA8B,EAC9B,uBAAuB,GAExB,MAAM,oBAAoB,CAAC;AAE5B,mCAAmC;AACnC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB;IACjB,kBAAkB;IAClB,sBAAsB;IACtB,oBAAoB;IACpB,yBAAyB;IACzB,oBAAoB;IACpB,eAAe;CACP,CAAC;AAGX,8CAA8C;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,kBAAkB;IAClB,sBAAsB;IACtB,oBAAoB;IACpB,eAAe;CACP,CAAC;AAGX,kCAAkC;AAClC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,gBAAgB;IAChB,qBAAqB;IACrB,iBAAiB;IACjB,aAAa;CACL,CAAC;AAGX,qCAAqC;AACrC,MAAM,CAAC,MAAM,+BAA+B,GAAG,mBAAmB,CAAC;AACnE,MAAM,CAAC,MAAM,gCAAgC,GAAG,4BAA4B,CAAC;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAI1C,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAyB;IAC7B,MAAM,CAAS;IAExB,YAAY,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,CAAC,CAAC;QACxE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,IAAI,QAAQ,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;QAC3C,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,oBAAoB,KAAK,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,QAAQ,GAA2B;QACvC,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,oBAAoB;QAC9B,KAAK;QACL,SAAS,EAAE,QAAQ;QACnB,uBAAuB,EAAE,uBAAuB;QAChD,cAAc,EAAE,eAAe;QAC/B,qBAAqB,EAAE,+BAA+B;KACvD,CAAC;IACF,OAAO;QACL,QAAQ;QACR,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC;QACtC,gBAAgB,EAAE,gCAAgC;QAClD,oBAAoB,EAAE,2BAA2B,EAAE;KACpD,CAAC;AACJ,CAAC"}
@@ -94,6 +94,18 @@ export type ReceptionBlock = {
94
94
  supportedUnit?: string;
95
95
  /** multiple_skus:买家提到的 SKU 候选(请买家选择,不静默取第一项)。 */
96
96
  candidates?: string[];
97
+ } | {
98
+ /**
99
+ * 已注册问题(QuestionSpec v1):模型只选择 question_id,发布器按
100
+ * 注册模板确定性渲染;未知 ID / schema / slot / reason 失配一律拒绝。
101
+ */
102
+ kind: "ask_registered_question";
103
+ question_id: string;
104
+ schema_version: number;
105
+ slot: "sku" | "quantity" | "unit";
106
+ reason_code: string;
107
+ /** 已注册 SKU 候选(仅 candidate_type=sku_candidates 的问题允许)。 */
108
+ candidate_refs?: string[];
97
109
  } | {
98
110
  kind: "show_commercial_terms";
99
111
  /** 服务端事实引用;发布器校验存在性/版本/租户/可见性/有效期后渲染。 */
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Copyright 2026 harrylabsj
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { DatabaseSync } from "node:sqlite";
17
+ import type { QuoteHistoryAccess } from "./merchant-handler.js";
18
+ /** 建档请求:verified_actor 必须是服务端验签所得身份(不是正文自报)。 */
19
+ export interface IdentityRegistrationRequest {
20
+ merchant_id: string;
21
+ verified_actor: string;
22
+ source: "rfq" | "inquiry" | "reception-text";
23
+ negotiation_id?: string;
24
+ message_id?: string;
25
+ }
26
+ export type IdentityRegistrationOutcome = {
27
+ status: "registered";
28
+ subject_id: string;
29
+ created: boolean;
30
+ }
31
+ /** 写者不可用:普通询价继续,历史暂不可用;意图已入 spool 可靠重试。 */
32
+ | {
33
+ status: "unavailable";
34
+ reason: string;
35
+ };
36
+ /** 本店身份建档 Writer 接缝。实现必须幂等。 */
37
+ export interface CustomerIdentityWriter {
38
+ ensure(input: IdentityRegistrationRequest): Promise<IdentityRegistrationOutcome>;
39
+ drain?(): Promise<void>;
40
+ close?(): void;
41
+ }
42
+ export declare class LocalCustomerIdentityWriter implements CustomerIdentityWriter {
43
+ private readonly dbPath;
44
+ private readonly now;
45
+ private handle;
46
+ private readonly assertOwner?;
47
+ private readonly spool?;
48
+ constructor(options: {
49
+ dbPath: string;
50
+ now: () => string;
51
+ assertOwner?: () => void;
52
+ spoolFile?: string;
53
+ });
54
+ ensure(input: IdentityRegistrationRequest): Promise<IdentityRegistrationOutcome>;
55
+ drain(): Promise<void>;
56
+ private write;
57
+ close(): void;
58
+ private open;
59
+ }
60
+ export interface SpooledIdentityWriterOptions {
61
+ /** spool 文件绝对路径(a2a dir 内)。 */
62
+ spoolFile: string;
63
+ /** 写者进程内部端点;未配置时所有意图保持 pending(历史暂不可用)。 */
64
+ forwardUrl?: string;
65
+ /** 内部通道共享凭据(`x-kiwi-identity-channel-token`)。 */
66
+ forwardToken?: string;
67
+ now: () => string;
68
+ fetchImpl?: typeof fetch;
69
+ logError?: (message: string, err: unknown) => void;
70
+ }
71
+ export declare class SpooledCustomerIdentityWriter implements CustomerIdentityWriter {
72
+ private readonly spool;
73
+ private readonly forwardUrl;
74
+ private readonly forwardToken;
75
+ private readonly now;
76
+ private readonly fetchImpl;
77
+ private readonly logError;
78
+ private lastAttemptAt;
79
+ constructor(options: SpooledIdentityWriterOptions);
80
+ ensure(input: IdentityRegistrationRequest): Promise<IdentityRegistrationOutcome>;
81
+ /** drain:spool 中的历史意图可靠重试(启动时/定时调用)。 */
82
+ drain(): Promise<void>;
83
+ private forward;
84
+ }
85
+ /** 从环境装配 Writer(缺省 local)。 */
86
+ export declare function resolveCustomerIdentityWriter(options: {
87
+ dataDir: string;
88
+ a2aDir: string;
89
+ now: () => string;
90
+ logError?: (message: string, err: unknown) => void;
91
+ assertOwner?: () => void;
92
+ }): CustomerIdentityWriter;
93
+ export declare function createQuoteHistoryAccess(options: {
94
+ dbPath: string;
95
+ now: () => string;
96
+ assertOwner?: () => void;
97
+ }): {
98
+ store: QuoteHistoryAccess;
99
+ prune(merchantId: string): void;
100
+ close(): void;
101
+ };
102
+ /** Only the bound A2A process may ask the Workbench to register its verified actor. */
103
+ export declare function createCustomerIdentityReceiver(options: {
104
+ db: DatabaseSync;
105
+ merchantId: string;
106
+ now: () => string;
107
+ assertOwner?: () => void;
108
+ }): (token: unknown, readBody: () => Promise<unknown>) => Promise<{
109
+ status: number;
110
+ body: Record<string, unknown>;
111
+ }>;