@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-transport.js","sourceRoot":"","sources":["../../../src/merchant-core/customer-memory/private-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAe,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAKhD,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB,SAAS,YAAY,CAAC,UAAkB;IACtC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnH,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;QACvG,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,OAA8B,EAAE,KAAe;IACvG,YAAY,CAAC,UAAU,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,KAAK;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;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C,OAAO,EAAE,CAAC;YAAC,CAAC;YAC7E,OAAO,KAAK,EAAE,CAAC;gBAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,160 @@
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
+ * 企业一次委托与已发报价历史(买家识别与交易回执 · K2,设计 §2.3/§2.4)。
18
+ *
19
+ * 委托:买方经请求体签名覆盖的 A2A message metadata 附上声明(本店、用途、
20
+ * 版本、期限)。商家校验后在 `quote_history_delegations` 保存版本与状态,
21
+ * 并经既有 `DataUseGrantStore` 建立/续期 `history_recall` grant——授权本体
22
+ * 复用既有授权词表与 epoch 机制,撤销版本持久保存:旧版本重放、撤销后
23
+ * 重放一律拒绝。
24
+ *
25
+ * 报价历史:报价正式发布时把(本店客户、SKU、可溯源规格快照、价格、有效期)
26
+ * 索引到 `published_offers`;回访查询只读本表,读前复核绑定与授权,
27
+ * 返回前复核撤销版本。SKU 单独无法证明规格——spec_json 引用报价当时的
28
+ * 来源快照;找不到来源的字段留空,草稿不进入(只索引 message_sent 落账后的
29
+ * 正式报价)。
30
+ */
31
+ import type { DatabaseSync } from "node:sqlite";
32
+ export declare const QUOTE_HISTORY_PURPOSE: "quote_history";
33
+ export declare const DELEGATION_TYPE: "kiwi.quote-history-delegation";
34
+ export declare const DELEGATION_VERSION = 1;
35
+ /** 买方随已签名 A2A message metadata 附带的委托声明。 */
36
+ export interface QuoteHistoryDelegation {
37
+ type: typeof DELEGATION_TYPE;
38
+ version: number;
39
+ merchant_id: string;
40
+ purpose: typeof QUOTE_HISTORY_PURPOSE;
41
+ delegation_id: string;
42
+ issued_at: string;
43
+ expires_at: string;
44
+ buyer_agent_id?: string;
45
+ }
46
+ export type DelegationOutcome = {
47
+ status: "active";
48
+ grant_id: string;
49
+ grant_epoch: number;
50
+ subject_id: string;
51
+ }
52
+ /** 版本落后于已保存/已撤销版本:旧委托重放,拒绝(按未委托处理)。 */
53
+ | {
54
+ status: "stale";
55
+ } | {
56
+ status: "rejected";
57
+ reason: string;
58
+ };
59
+ export interface QuoteHistoryHit {
60
+ negotiation_id: string;
61
+ offer_id: string;
62
+ offer_version: number;
63
+ sku: string;
64
+ quantity: number;
65
+ unit: string;
66
+ currency: string;
67
+ unit_price_minor: number;
68
+ terms_digest: string;
69
+ spec: Record<string, unknown>;
70
+ valid_until?: string;
71
+ quoted_at: string;
72
+ }
73
+ /** 校验买方委托声明(形状 + 商家绑定 + 期限)。失败返回 rejected 原因。 */
74
+ export declare function validateDelegationShape(raw: unknown, merchantId: string, now: string): {
75
+ ok: true;
76
+ delegation: QuoteHistoryDelegation;
77
+ } | {
78
+ ok: false;
79
+ reason: string;
80
+ };
81
+ export declare class QuoteHistoryStore {
82
+ private readonly db;
83
+ private readonly now;
84
+ constructor(options: {
85
+ db: DatabaseSync;
86
+ now: () => string;
87
+ });
88
+ /**
89
+ * 建立或续期本店委托:版本单调(保存撤销版本);新版本过期时间生效前
90
+ * 旧版本仍然按已保存水位拒绝。同一版本幂等重入返回原结果。
91
+ */
92
+ applyDelegation(input: {
93
+ merchant_id: string;
94
+ buyer_actor: string;
95
+ subject_id: string;
96
+ delegation: QuoteHistoryDelegation;
97
+ }): DelegationOutcome;
98
+ /** Sweep quote snapshots and grants left active by pre-fix delegation versions. */
99
+ pruneForMerchant(merchantId: string): void;
100
+ /** 撤销当前委托(版本水位保留——旧委托重放不得恢复)。 */
101
+ revokeDelegation(input: {
102
+ merchant_id: string;
103
+ buyer_actor: string;
104
+ }): boolean;
105
+ private revokeUnderlyingGrant;
106
+ /**
107
+ * 读取前授权复核:委托 ACTIVE 且未过期、对应 history_recall grant 仍
108
+ * ACTIVE 且未过期。返回 subject_id(绑定关系随行),否则 undefined。
109
+ */
110
+ checkActive(input: {
111
+ merchant_id: string;
112
+ buyer_actor: string;
113
+ }): {
114
+ subject_id: string;
115
+ } | undefined;
116
+ /** 报价正式发布后的索引写入(message_sent 落账之后调用;幂等按 offer_id)。 */
117
+ indexOffer(input: {
118
+ merchant_id: string;
119
+ subject_id: string;
120
+ negotiation_id: string;
121
+ offer_id: string;
122
+ message_id: string;
123
+ sku: string;
124
+ quantity: number;
125
+ unit: string;
126
+ currency: string;
127
+ unit_price_minor: number;
128
+ terms_digest: string;
129
+ spec: Record<string, unknown>;
130
+ valid_until?: string;
131
+ quoted_at: string;
132
+ }): {
133
+ ok: boolean;
134
+ };
135
+ /**
136
+ * 历史查询(读前已复核 checkActive;本函数只做数据投影)。
137
+ * 只返回正式发布过的报价;spec_json 是报价当时的来源快照。
138
+ */
139
+ queryHistory(input: {
140
+ merchant_id: string;
141
+ subject_id: string;
142
+ skus?: string[];
143
+ limit?: number;
144
+ }): QuoteHistoryHit[];
145
+ }
146
+ /** 从 A2A message metadata 提取委托声明(未配置/形状不符返回 undefined)。 */
147
+ export declare function delegationFromMetadata(metadata: unknown): unknown;
148
+ /** KNP inquiry subject 内的历史查询扩展(双方显式支持的版本化扩展)。 */
149
+ export interface QuoteHistoryQueryExtension {
150
+ version: number;
151
+ skus?: string[];
152
+ limit?: number;
153
+ }
154
+ export declare function parseHistoryQueryExtension(subject: unknown): QuoteHistoryQueryExtension | undefined;
155
+ export declare function isQuoteHistoryRecall(text: string): boolean;
156
+ export declare function quoteHistoryNote(store: Pick<QuoteHistoryStore, "checkActive" | "queryHistory">, input: {
157
+ merchantId: string;
158
+ actor: string;
159
+ sku?: string;
160
+ }): string;
@@ -0,0 +1,392 @@
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 { DataUseGrantStore } from "../context-governance/data-use-grant.js";
17
+ import { inImmediateTransaction } from "../storage/transaction.js";
18
+ import { CustomerMemoryError } from "./types.js";
19
+ export const QUOTE_HISTORY_PURPOSE = "quote_history";
20
+ export const DELEGATION_TYPE = "kiwi.quote-history-delegation";
21
+ export const DELEGATION_VERSION = 1;
22
+ function requireText(value, field, max = 128) {
23
+ if (typeof value !== "string" || value.length === 0 || value.length > max) {
24
+ throw new CustomerMemoryError("validation", `${field}_invalid`, `${field} 必须是 1..${max} 字符`);
25
+ }
26
+ // eslint-disable-next-line no-control-regex
27
+ if (/[\u0000-\u001f\u007f]/.test(value)) {
28
+ throw new CustomerMemoryError("validation", `${field}_invalid`, `${field} 含控制字符`);
29
+ }
30
+ return value;
31
+ }
32
+ function isoOf(value, field) {
33
+ const text = requireText(value, field, 64);
34
+ const parsed = Date.parse(text);
35
+ if (!Number.isFinite(parsed)) {
36
+ throw new CustomerMemoryError("validation", `${field}_invalid`, `${field} 必须是 RFC3339 时间`);
37
+ }
38
+ return new Date(parsed).toISOString();
39
+ }
40
+ /** 校验买方委托声明(形状 + 商家绑定 + 期限)。失败返回 rejected 原因。 */
41
+ export function validateDelegationShape(raw, merchantId, now) {
42
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
43
+ return { ok: false, reason: "delegation_missing" };
44
+ }
45
+ const candidate = raw;
46
+ if (candidate["type"] !== DELEGATION_TYPE)
47
+ return { ok: false, reason: "delegation_type_unknown" };
48
+ const version = candidate["version"];
49
+ if (typeof version !== "number" || !Number.isSafeInteger(version) || version < 1) {
50
+ return { ok: false, reason: "delegation_version_invalid" };
51
+ }
52
+ if (candidate["purpose"] !== QUOTE_HISTORY_PURPOSE)
53
+ return { ok: false, reason: "delegation_purpose_unknown" };
54
+ if (candidate["merchant_id"] !== merchantId)
55
+ return { ok: false, reason: "delegation_merchant_mismatch" };
56
+ let delegation;
57
+ try {
58
+ delegation = {
59
+ type: DELEGATION_TYPE,
60
+ version,
61
+ merchant_id: merchantId,
62
+ purpose: QUOTE_HISTORY_PURPOSE,
63
+ delegation_id: requireText(candidate["delegation_id"], "delegation_id"),
64
+ issued_at: isoOf(candidate["issued_at"], "issued_at"),
65
+ expires_at: isoOf(candidate["expires_at"], "expires_at"),
66
+ ...(typeof candidate["buyer_agent_id"] === "string" && candidate["buyer_agent_id"] !== ""
67
+ ? { buyer_agent_id: requireText(candidate["buyer_agent_id"], "buyer_agent_id", 256) }
68
+ : {}),
69
+ };
70
+ }
71
+ catch {
72
+ return { ok: false, reason: "delegation_fields_invalid" };
73
+ }
74
+ if (Date.parse(delegation.expires_at) <= Date.parse(now)) {
75
+ return { ok: false, reason: "delegation_expired" };
76
+ }
77
+ const issuedAt = Date.parse(delegation.issued_at);
78
+ const expiresAt = Date.parse(delegation.expires_at);
79
+ if (issuedAt > Date.parse(now) + 5 * 60_000 || expiresAt - issuedAt > 90 * 86_400_000 || issuedAt >= expiresAt) {
80
+ return { ok: false, reason: "delegation_window_invalid" };
81
+ }
82
+ return { ok: true, delegation };
83
+ }
84
+ export class QuoteHistoryStore {
85
+ db;
86
+ now;
87
+ constructor(options) {
88
+ this.db = options.db;
89
+ this.now = options.now;
90
+ }
91
+ /**
92
+ * 建立或续期本店委托:版本单调(保存撤销版本);新版本过期时间生效前
93
+ * 旧版本仍然按已保存水位拒绝。同一版本幂等重入返回原结果。
94
+ */
95
+ applyDelegation(input) {
96
+ try {
97
+ const merchantId = requireText(input.merchant_id, "merchant_id");
98
+ const buyerActor = requireText(input.buyer_actor, "buyer_actor", 256);
99
+ const subjectId = requireText(input.subject_id, "subject_id");
100
+ const stamp = this.now();
101
+ return inImmediateTransaction(this.db, () => {
102
+ const existing = this.db
103
+ .prepare("SELECT version, status, grant_id, grant_epoch, subject_id FROM quote_history_delegations WHERE merchant_id = ? AND buyer_actor = ?")
104
+ .get(merchantId, buyerActor);
105
+ if (existing !== undefined &&
106
+ input.delegation.version < existing.version) {
107
+ return { status: "stale" };
108
+ }
109
+ if (existing !== undefined &&
110
+ input.delegation.version === existing.version &&
111
+ existing.status === "REVOKED") {
112
+ // 撤销版本水位:同版本重放(撤销后的重发/重放)不得恢复授权;
113
+ // 只有买方以新版本声明(新 consent,随新签名请求到达)才重新建立。
114
+ return { status: "stale" };
115
+ }
116
+ if (existing !== undefined &&
117
+ input.delegation.version === existing.version &&
118
+ existing.status === "ACTIVE" &&
119
+ existing.grant_id !== "") {
120
+ return {
121
+ status: "active",
122
+ grant_id: existing.grant_id,
123
+ grant_epoch: existing.grant_epoch,
124
+ subject_id: existing.subject_id,
125
+ };
126
+ }
127
+ // 委托生效 = 建立/续期 history_recall grant(复用既有授权本体)。
128
+ const grants = new DataUseGrantStore({ db: this.db, now: this.now });
129
+ if (existing?.grant_id)
130
+ this.revokeUnderlyingGrant(merchantId, existing.grant_id);
131
+ this.db
132
+ .prepare(`INSERT INTO data_scopes
133
+ (merchant_id, erase_scope_id, data_epoch, state, sealed_at, updated_at)
134
+ VALUES (?, ?, 1, 'ACTIVE', NULL, ?)
135
+ ON CONFLICT(merchant_id, erase_scope_id) DO NOTHING`)
136
+ .run(merchantId, `quote-history:${subjectId}`, stamp);
137
+ const grant = grants.createGrant({
138
+ merchant_id: merchantId,
139
+ subject_id: subjectId,
140
+ purpose: "history_recall",
141
+ resource_scope_id: `quote-history:${subjectId}`,
142
+ expires_at: input.delegation.expires_at,
143
+ });
144
+ this.db
145
+ .prepare(`INSERT INTO quote_history_delegations
146
+ (merchant_id, buyer_actor, subject_id, delegation_id, version, purpose,
147
+ grant_id, grant_epoch, issued_at, expires_at, status, source_ref,
148
+ created_at, updated_at)
149
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'ACTIVE', ?, ?, ?)
150
+ ON CONFLICT(merchant_id, buyer_actor) DO UPDATE SET
151
+ subject_id = excluded.subject_id,
152
+ delegation_id = excluded.delegation_id,
153
+ version = excluded.version,
154
+ grant_id = excluded.grant_id,
155
+ grant_epoch = excluded.grant_epoch,
156
+ issued_at = excluded.issued_at,
157
+ expires_at = excluded.expires_at,
158
+ status = 'ACTIVE',
159
+ source_ref = excluded.source_ref,
160
+ updated_at = excluded.updated_at`)
161
+ .run(merchantId, buyerActor, subjectId, input.delegation.delegation_id, input.delegation.version, QUOTE_HISTORY_PURPOSE, grant.grant_id, grant.grant_epoch, input.delegation.issued_at, input.delegation.expires_at, `delegation:${input.delegation.delegation_id}`, stamp, stamp);
162
+ return {
163
+ status: "active",
164
+ grant_id: grant.grant_id,
165
+ grant_epoch: grant.grant_epoch,
166
+ subject_id: subjectId,
167
+ };
168
+ });
169
+ }
170
+ catch (err) {
171
+ return {
172
+ status: "rejected",
173
+ reason: err instanceof CustomerMemoryError ? err.reason : "delegation_store_error",
174
+ };
175
+ }
176
+ }
177
+ /** Sweep quote snapshots and grants left active by pre-fix delegation versions. */
178
+ pruneForMerchant(merchantId) {
179
+ inImmediateTransaction(this.db, () => {
180
+ const now = this.now();
181
+ this.db.prepare("DELETE FROM published_offers WHERE merchant_id = ? AND julianday(quoted_at) <= julianday(?) - 90").run(merchantId, now);
182
+ this.db.prepare(`UPDATE quote_history_delegations SET status = 'REVOKED', updated_at = ?
183
+ WHERE merchant_id = ? AND status = 'ACTIVE'
184
+ AND julianday(issued_at) <= julianday(?) - 90
185
+ AND julianday(expires_at) > julianday(issued_at) + 90`).run(now, merchantId, now);
186
+ const abandoned = this.db.prepare(`SELECT g.grant_id FROM data_grants g
187
+ WHERE g.merchant_id = ? AND g.purpose = 'history_recall' AND g.status = 'ACTIVE'
188
+ AND g.resource_scope_id = 'quote-history:' || g.subject_id
189
+ AND EXISTS (SELECT 1 FROM quote_history_delegations d
190
+ WHERE d.merchant_id = g.merchant_id AND d.subject_id = g.subject_id)
191
+ AND NOT EXISTS (SELECT 1 FROM quote_history_delegations d
192
+ WHERE d.merchant_id = g.merchant_id AND d.grant_id = g.grant_id AND d.status = 'ACTIVE')
193
+ AND (
194
+ EXISTS (SELECT 1 FROM quote_history_delegations d
195
+ WHERE d.merchant_id = g.merchant_id AND d.grant_id = g.grant_id AND d.status = 'REVOKED')
196
+ OR NOT EXISTS (SELECT 1 FROM grant_requests r
197
+ WHERE r.merchant_id = g.merchant_id AND r.subject_id = g.subject_id
198
+ AND r.resource_scope_id = g.resource_scope_id AND r.purpose = g.purpose
199
+ AND r.consumed_at IS NOT NULL)
200
+ )
201
+ ORDER BY g.created_at, g.grant_id LIMIT 128`).all(merchantId);
202
+ for (const grant of abandoned)
203
+ this.revokeUnderlyingGrant(merchantId, grant.grant_id);
204
+ });
205
+ }
206
+ /** 撤销当前委托(版本水位保留——旧委托重放不得恢复)。 */
207
+ revokeDelegation(input) {
208
+ const merchantId = requireText(input.merchant_id, "merchant_id");
209
+ const buyerActor = requireText(input.buyer_actor, "buyer_actor", 256);
210
+ return inImmediateTransaction(this.db, () => {
211
+ const row = this.db.prepare("SELECT grant_id FROM quote_history_delegations WHERE merchant_id = ? AND buyer_actor = ? AND status = 'ACTIVE'").get(merchantId, buyerActor);
212
+ if (row === undefined)
213
+ return false;
214
+ this.revokeUnderlyingGrant(merchantId, row.grant_id);
215
+ this.db.prepare("UPDATE quote_history_delegations SET status = 'REVOKED', updated_at = ? WHERE merchant_id = ? AND buyer_actor = ?").run(this.now(), merchantId, buyerActor);
216
+ return true;
217
+ });
218
+ }
219
+ revokeUnderlyingGrant(merchantId, grantId) {
220
+ const grant = this.db.prepare("SELECT grant_epoch FROM data_grants WHERE merchant_id = ? AND grant_id = ? AND status = 'ACTIVE'").get(merchantId, grantId);
221
+ if (grant !== undefined) {
222
+ new DataUseGrantStore({ db: this.db, now: this.now }).revokeGrant({
223
+ merchant_id: merchantId, grant_id: grantId, expected_epoch: grant.grant_epoch,
224
+ });
225
+ }
226
+ }
227
+ /**
228
+ * 读取前授权复核:委托 ACTIVE 且未过期、对应 history_recall grant 仍
229
+ * ACTIVE 且未过期。返回 subject_id(绑定关系随行),否则 undefined。
230
+ */
231
+ checkActive(input) {
232
+ try {
233
+ const merchantId = requireText(input.merchant_id, "merchant_id");
234
+ const buyerActor = requireText(input.buyer_actor, "buyer_actor", 256);
235
+ const stamp = this.now();
236
+ const row = this.db
237
+ .prepare(`SELECT subject_id, issued_at, expires_at, grant_id, status FROM quote_history_delegations
238
+ WHERE merchant_id = ? AND buyer_actor = ?`)
239
+ .get(merchantId, buyerActor);
240
+ if (row === undefined || row.status !== "ACTIVE" || row.expires_at <= stamp ||
241
+ !(Date.parse(stamp) < Date.parse(row.issued_at) + 90 * 86_400_000))
242
+ return undefined;
243
+ const grant = this.db
244
+ .prepare(`SELECT g.status, g.expires_at
245
+ FROM data_grants g JOIN data_scopes scope
246
+ ON scope.merchant_id = g.merchant_id AND scope.erase_scope_id = g.resource_scope_id
247
+ JOIN customer_subjects s ON s.merchant_id = g.merchant_id AND s.subject_id = g.subject_id
248
+ WHERE g.grant_id = ? AND g.merchant_id = ? AND g.subject_id = ?
249
+ AND g.purpose = 'history_recall' AND g.resource_scope_id = ?
250
+ AND scope.state = 'ACTIVE' AND s.status = 'ACTIVE'
251
+ AND EXISTS (
252
+ SELECT 1 FROM verified_customer_identities v JOIN subject_bindings b
253
+ ON b.merchant_id = v.merchant_id AND b.actor_id = v.verified_actor
254
+ AND b.subject_id = v.subject_id AND b.binding_epoch = v.binding_epoch
255
+ WHERE v.merchant_id = g.merchant_id AND v.subject_id = g.subject_id
256
+ AND v.verified_actor = ? AND b.status = 'ACTIVE' AND b.expires_at > ?
257
+ )`)
258
+ .get(row.grant_id, merchantId, row.subject_id, `quote-history:${row.subject_id}`, buyerActor, stamp);
259
+ if (grant === undefined || grant.status !== "ACTIVE" || grant.expires_at <= stamp)
260
+ return undefined;
261
+ return { subject_id: row.subject_id };
262
+ }
263
+ catch {
264
+ return undefined;
265
+ }
266
+ }
267
+ /** 报价正式发布后的索引写入(message_sent 落账之后调用;幂等按 offer_id)。 */
268
+ indexOffer(input) {
269
+ try {
270
+ const stamp = this.now();
271
+ const versionRow = this.db
272
+ .prepare(`SELECT COALESCE(MAX(offer_version), 0) AS v FROM published_offers
273
+ WHERE merchant_id = ? AND negotiation_id = ?`)
274
+ .get(requireText(input.merchant_id, "merchant_id"), requireText(input.negotiation_id, "negotiation_id"));
275
+ this.db
276
+ .prepare(`INSERT INTO published_offers
277
+ (merchant_id, subject_id, negotiation_id, offer_id, message_id, sku, quantity, unit,
278
+ currency, unit_price_minor, terms_digest, spec_json, offer_version, valid_until,
279
+ quoted_at, created_at)
280
+ SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
281
+ WHERE NOT EXISTS (
282
+ SELECT 1 FROM data_scopes
283
+ WHERE merchant_id = ? AND erase_scope_id = ? AND state <> 'ACTIVE'
284
+ )
285
+ ON CONFLICT(merchant_id, negotiation_id, offer_id) DO NOTHING`)
286
+ .run(input.merchant_id, requireText(input.subject_id, "subject_id"), input.negotiation_id, requireText(input.offer_id, "offer_id"), requireText(input.message_id, "message_id"), requireText(input.sku, "sku"), input.quantity, requireText(input.unit, "unit", 64), requireText(input.currency, "currency", 16), input.unit_price_minor, requireText(input.terms_digest, "terms_digest"), JSON.stringify(input.spec ?? {}), Number(versionRow.v) + 1, input.valid_until !== undefined ? isoOf(input.valid_until, "valid_until") : null, isoOf(input.quoted_at, "quoted_at"), stamp, input.merchant_id, `quote-history:${input.subject_id}`);
287
+ return { ok: true };
288
+ }
289
+ catch {
290
+ return { ok: false };
291
+ }
292
+ }
293
+ /**
294
+ * 历史查询(读前已复核 checkActive;本函数只做数据投影)。
295
+ * 只返回正式发布过的报价;spec_json 是报价当时的来源快照。
296
+ */
297
+ queryHistory(input) {
298
+ try {
299
+ const merchantId = requireText(input.merchant_id, "merchant_id");
300
+ const subjectId = requireText(input.subject_id, "subject_id");
301
+ const limit = input.limit === undefined ? 5 : Math.max(1, Math.min(Math.floor(input.limit), 20));
302
+ const skus = (input.skus ?? []).filter((sku) => typeof sku === "string" && sku.trim() !== "");
303
+ const skuFilter = skus.length === 0 ? "" : ` AND sku IN (${skus.map(() => "?").join(",")})`;
304
+ const rows = this.db.prepare(`WITH latest AS (
305
+ SELECT *, row_number() OVER (PARTITION BY sku ORDER BY quoted_at DESC, offer_version DESC, offer_id DESC) AS rank
306
+ FROM published_offers WHERE merchant_id = ? AND subject_id = ? AND julianday(quoted_at) > julianday(?) - 90${skuFilter}
307
+ )
308
+ SELECT * FROM latest WHERE rank = 1 ORDER BY quoted_at DESC, sku LIMIT ?`).all(merchantId, subjectId, this.now(), ...skus, limit);
309
+ return rows.map((row) => ({
310
+ negotiation_id: row.negotiation_id,
311
+ offer_id: row.offer_id,
312
+ offer_version: Number(row.offer_version),
313
+ sku: row.sku,
314
+ quantity: Number(row.quantity),
315
+ unit: row.unit,
316
+ currency: row.currency,
317
+ unit_price_minor: Number(row.unit_price_minor),
318
+ terms_digest: row.terms_digest,
319
+ spec: safeParseObject(row.spec_json),
320
+ ...(row.valid_until !== null ? { valid_until: row.valid_until } : {}),
321
+ quoted_at: row.quoted_at,
322
+ }));
323
+ }
324
+ catch {
325
+ return [];
326
+ }
327
+ }
328
+ }
329
+ function safeParseObject(raw) {
330
+ try {
331
+ const parsed = JSON.parse(raw);
332
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)
333
+ ? parsed
334
+ : {};
335
+ }
336
+ catch {
337
+ return {};
338
+ }
339
+ }
340
+ /** 从 A2A message metadata 提取委托声明(未配置/形状不符返回 undefined)。 */
341
+ export function delegationFromMetadata(metadata) {
342
+ if (metadata === null || typeof metadata !== "object" || Array.isArray(metadata))
343
+ return undefined;
344
+ const candidate = metadata["kiwi_delegation"];
345
+ if (candidate === null || typeof candidate !== "object" || Array.isArray(candidate))
346
+ return undefined;
347
+ return candidate;
348
+ }
349
+ export function parseHistoryQueryExtension(subject) {
350
+ if (subject === null || typeof subject !== "object" || Array.isArray(subject))
351
+ return undefined;
352
+ const raw = subject["kiwi_history_query"];
353
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw))
354
+ return undefined;
355
+ const candidate = raw;
356
+ if (candidate["version"] !== 1)
357
+ return undefined;
358
+ const extension = { version: 1 };
359
+ if (Array.isArray(candidate["skus"])) {
360
+ const skus = candidate["skus"].filter((sku) => typeof sku === "string" && sku.trim() !== "");
361
+ if (skus.length > 0)
362
+ extension.skus = skus.slice(0, 20);
363
+ }
364
+ if (typeof candidate["limit"] === "number" && Number.isSafeInteger(candidate["limit"]) && candidate["limit"] > 0) {
365
+ extension.limit = Math.min(candidate["limit"], 20);
366
+ }
367
+ return extension;
368
+ }
369
+ export function isQuoteHistoryRecall(text) {
370
+ return /上次|之前那款|上回|last (?:quote|order|item)|same as last/i.test(text);
371
+ }
372
+ export function quoteHistoryNote(store, input) {
373
+ const actor = { merchant_id: input.merchantId, buyer_actor: input.actor };
374
+ const active = store.checkActive(actor);
375
+ if (active === undefined)
376
+ return "";
377
+ const hits = store.queryHistory({
378
+ merchant_id: input.merchantId, subject_id: active.subject_id,
379
+ ...(input.sku !== undefined ? { skus: [input.sku] } : {}),
380
+ limit: 2,
381
+ });
382
+ if (store.checkActive(actor)?.subject_id !== active.subject_id)
383
+ return "";
384
+ if (hits.length > 1)
385
+ return " 有多款历史商品,请指明要沿用的 SKU。";
386
+ const hit = hits[0];
387
+ if (hit === undefined)
388
+ return "";
389
+ const expiry = hit.valid_until === undefined ? "" : `,有效期至 ${hit.valid_until}`;
390
+ return ` 上次报价 ${hit.sku},数量 ${hit.quantity} ${hit.unit},单价 ${(hit.unit_price_minor / 100).toFixed(2)} ${hit.currency}(${hit.quoted_at}${expiry})。本次价格以正式 RFQ 为准。`;
391
+ }
392
+ //# sourceMappingURL=quote-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote-history.js","sourceRoot":"","sources":["../../../src/merchant-core/customer-memory/quote-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoBH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAwB,CAAC;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,+BAAwC,CAAC;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAmCpC,SAAS,WAAW,CAAC,KAAc,EAAE,KAAa,EAAE,GAAG,GAAG,GAAG;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QAC1E,MAAM,IAAI,mBAAmB,CAAC,YAAY,EAAE,GAAG,KAAK,UAAU,EAAE,GAAG,KAAK,WAAW,GAAG,KAAK,CAAC,CAAC;IAC/F,CAAC;IACD,4CAA4C;IAC5C,IAAI,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,mBAAmB,CAAC,YAAY,EAAE,GAAG,KAAK,UAAU,EAAE,GAAG,KAAK,QAAQ,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,KAAc,EAAE,KAAa;IAC1C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,KAAK,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAC1E,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,uBAAuB,CAAC;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,WAAW,EAAE,CAAC;IAC/E,OAAO,SAAS,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,SAAS,GAAG,MAAM,mBAAmB,CAAC;AACpK,CAAC"}
@@ -0,0 +1,69 @@
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 { CustomerMemoryToolProvider, CustomerRecallContext } from "../../a2a/reception/customer-memory-tools.js";
17
+ import type { HistorySearchResult, MemoryNamespace, MemorySourceKind } from "./types.js";
18
+ export declare class SqliteCustomerMemoryProvider implements CustomerMemoryToolProvider {
19
+ private readonly dbPath;
20
+ private readonly now;
21
+ /** 接待进程是否允许写候选记忆;单写者部署下 a2a 只读。 */
22
+ private readonly allowWrites;
23
+ private readonly socketPath;
24
+ private handle;
25
+ constructor(options: {
26
+ dbPath: string;
27
+ now?: () => string;
28
+ allowWrites?: boolean;
29
+ socketPath?: string;
30
+ });
31
+ private db;
32
+ private systemActor;
33
+ private services;
34
+ contextFor(merchantId: string, actorId: string): CustomerRecallContext | undefined;
35
+ currentBindingEpoch(merchantId: string, actorId: string): number | undefined;
36
+ currentGrantEpoch(merchantId: string, grantId: string): number | undefined;
37
+ currentDataScopeEpoch(merchantId: string, scopeKey: string): number | undefined;
38
+ currentMemorySetVersion(merchantId: string, subjectId: string): number | undefined;
39
+ recall(context: CustomerRecallContext): Array<{
40
+ memory_id: string;
41
+ namespace: MemoryNamespace;
42
+ key: string;
43
+ value_ref: string;
44
+ value_type: string;
45
+ version: number;
46
+ confirmed_at: string | null;
47
+ }>;
48
+ search(context: CustomerRecallContext, input: {
49
+ query: string;
50
+ cursor?: string;
51
+ limit?: number;
52
+ }): HistorySearchResult;
53
+ canPropose(context: CustomerRecallContext): boolean;
54
+ propose(context: CustomerRecallContext, input: {
55
+ namespace: MemoryNamespace;
56
+ key: string;
57
+ value_ref: string;
58
+ value_type: string;
59
+ source_kind: MemorySourceKind;
60
+ confidence?: number;
61
+ }): {
62
+ memory_id: string;
63
+ state: string;
64
+ } | Promise<{
65
+ memory_id: string;
66
+ state: string;
67
+ }>;
68
+ close(): void;
69
+ }