@harrylabsj/kiwi 0.12.26 → 0.12.28

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 (373) hide show
  1. package/README.md +9 -2
  2. package/contracts/kiwi-catalog/1.0/agent-record.schema.json +29 -0
  3. package/contracts/kiwi-contracts.lock.json +2 -2
  4. package/contracts/manifest.json +2 -2
  5. package/dist/a2a/admission.d.ts +35 -0
  6. package/dist/a2a/admission.js +75 -0
  7. package/dist/a2a/admission.js.map +1 -0
  8. package/dist/a2a/node.d.ts +11 -8
  9. package/dist/a2a/node.js +78 -35
  10. package/dist/a2a/node.js.map +1 -1
  11. package/dist/a2a/reception/agent-runtime.js +9 -3
  12. package/dist/a2a/reception/agent-runtime.js.map +1 -1
  13. package/dist/a2a/reception/engine.js +6 -1
  14. package/dist/a2a/reception/engine.js.map +1 -1
  15. package/dist/a2a/reception/reply-outbox.d.ts +6 -0
  16. package/dist/a2a/reception/reply-outbox.js +13 -0
  17. package/dist/a2a/reception/reply-outbox.js.map +1 -1
  18. package/dist/a2a/reception/retention.d.ts +1 -0
  19. package/dist/a2a/reception/retention.js +9 -1
  20. package/dist/a2a/reception/retention.js.map +1 -1
  21. package/dist/a2a/server/auth.js +22 -3
  22. package/dist/a2a/server/auth.js.map +1 -1
  23. package/dist/a2a/server/identity.d.ts +23 -0
  24. package/dist/a2a/server/identity.js +27 -0
  25. package/dist/a2a/server/identity.js.map +1 -0
  26. package/dist/a2a/server/merchant-handler.d.ts +0 -11
  27. package/dist/a2a/server/merchant-handler.js +34 -12
  28. package/dist/a2a/server/merchant-handler.js.map +1 -1
  29. package/dist/a2a/server/negotiation-advisor.js +3 -1
  30. package/dist/a2a/server/negotiation-advisor.js.map +1 -1
  31. package/dist/a2a/server/pipeline.d.ts +7 -1
  32. package/dist/a2a/server/pipeline.js +65 -35
  33. package/dist/a2a/server/pipeline.js.map +1 -1
  34. package/dist/a2a/server/server.d.ts +0 -17
  35. package/dist/a2a/server/server.js +23 -4
  36. package/dist/a2a/server/server.js.map +1 -1
  37. package/dist/a2a/server/task-registry.d.ts +3 -0
  38. package/dist/a2a/server/task-registry.js +33 -1
  39. package/dist/a2a/server/task-registry.js.map +1 -1
  40. package/dist/a2a/throttle-config.d.ts +24 -0
  41. package/dist/a2a/throttle-config.js +33 -0
  42. package/dist/a2a/throttle-config.js.map +1 -0
  43. package/dist/agent/buyer/buyer-tools.js +33 -19
  44. package/dist/agent/buyer/buyer-tools.js.map +1 -1
  45. package/dist/agent/buyer/ranker.js +32 -14
  46. package/dist/agent/buyer/ranker.js.map +1 -1
  47. package/dist/agent/buyer/scheduler.js +12 -3
  48. package/dist/agent/buyer/scheduler.js.map +1 -1
  49. package/dist/agent/buyer/types.d.ts +2 -1
  50. package/dist/agent/buyer/types.js.map +1 -1
  51. package/dist/agent/connector/types.d.ts +4 -2
  52. package/dist/agent/connector/types.js +8 -2
  53. package/dist/agent/connector/types.js.map +1 -1
  54. package/dist/agent/host/events.js +1 -1
  55. package/dist/agent/host/events.js.map +1 -1
  56. package/dist/agent/kernel-builder.d.ts +7 -1
  57. package/dist/agent/kernel-builder.js +8 -6
  58. package/dist/agent/kernel-builder.js.map +1 -1
  59. package/dist/agent/kernel.d.ts +10 -0
  60. package/dist/agent/kernel.js +27 -15
  61. package/dist/agent/kernel.js.map +1 -1
  62. package/dist/agent/merchant/merchant-tools.d.ts +5 -0
  63. package/dist/agent/merchant/merchant-tools.js +6 -2
  64. package/dist/agent/merchant/merchant-tools.js.map +1 -1
  65. package/dist/agent/merchant/read-only-tools.d.ts +17 -0
  66. package/dist/agent/merchant/read-only-tools.js +27 -0
  67. package/dist/agent/merchant/read-only-tools.js.map +1 -0
  68. package/dist/agent/negotiation-chat.js +6 -4
  69. package/dist/agent/negotiation-chat.js.map +1 -1
  70. package/dist/agent/presentation/sanitize.js +1 -1
  71. package/dist/agent/presentation/sanitize.js.map +1 -1
  72. package/dist/agent/supplier/scheduler.js.map +1 -1
  73. package/dist/auth/merchant-oauth.d.ts +10 -0
  74. package/dist/auth/merchant-oauth.js +53 -4
  75. package/dist/auth/merchant-oauth.js.map +1 -1
  76. package/dist/auth/merchant-pairing.js +5 -0
  77. package/dist/auth/merchant-pairing.js.map +1 -1
  78. package/dist/auth/merchant-scopes.d.ts +33 -0
  79. package/dist/auth/merchant-scopes.js +39 -0
  80. package/dist/auth/merchant-scopes.js.map +1 -0
  81. package/dist/auth/merchant-sessions.js +19 -4
  82. package/dist/auth/merchant-sessions.js.map +1 -1
  83. package/dist/buyer-core/a2a-negotiator.d.ts +7 -0
  84. package/dist/buyer-core/a2a-negotiator.js +17 -3
  85. package/dist/buyer-core/a2a-negotiator.js.map +1 -1
  86. package/dist/buyer-core/a2a-quote-fetcher.d.ts +22 -0
  87. package/dist/buyer-core/a2a-quote-fetcher.js +71 -3
  88. package/dist/buyer-core/a2a-quote-fetcher.js.map +1 -1
  89. package/dist/buyer-core/build-service.d.ts +7 -0
  90. package/dist/buyer-core/build-service.js +249 -22
  91. package/dist/buyer-core/build-service.js.map +1 -1
  92. package/dist/buyer-core/buyer-route-hint-store.d.ts +21 -0
  93. package/dist/buyer-core/buyer-route-hint-store.js +119 -0
  94. package/dist/buyer-core/buyer-route-hint-store.js.map +1 -0
  95. package/dist/buyer-core/merchant-index.js +7 -2
  96. package/dist/buyer-core/merchant-index.js.map +1 -1
  97. package/dist/buyer-core/service.d.ts +15 -0
  98. package/dist/buyer-core/service.js +34 -9
  99. package/dist/buyer-core/service.js.map +1 -1
  100. package/dist/buyer-core/stale-merchant-wake.d.ts +27 -0
  101. package/dist/buyer-core/stale-merchant-wake.js +117 -0
  102. package/dist/buyer-core/stale-merchant-wake.js.map +1 -0
  103. package/dist/buyer-core/store.d.ts +11 -0
  104. package/dist/buyer-core/store.js +68 -0
  105. package/dist/buyer-core/store.js.map +1 -1
  106. package/dist/cli.js +61 -8
  107. package/dist/cli.js.map +1 -1
  108. package/dist/cloud/access/access-mode.d.ts +56 -0
  109. package/dist/cloud/access/access-mode.js +129 -0
  110. package/dist/cloud/access/access-mode.js.map +1 -0
  111. package/dist/cloud/binding/enrollment-challenge.js +3 -2
  112. package/dist/cloud/binding/enrollment-challenge.js.map +1 -1
  113. package/dist/cloud/binding/runtime-challenge.js +3 -2
  114. package/dist/cloud/binding/runtime-challenge.js.map +1 -1
  115. package/dist/cloud/binding/store-lock.js +16 -7
  116. package/dist/cloud/binding/store-lock.js.map +1 -1
  117. package/dist/cloud/bootstrap.d.ts +1 -1
  118. package/dist/cloud/bootstrap.js +62 -8
  119. package/dist/cloud/bootstrap.js.map +1 -1
  120. package/dist/cloud/catalog-client.d.ts +25 -1
  121. package/dist/cloud/catalog-client.js +163 -4
  122. package/dist/cloud/catalog-client.js.map +1 -1
  123. package/dist/cloud/config.d.ts +14 -0
  124. package/dist/cloud/config.js +30 -0
  125. package/dist/cloud/config.js.map +1 -1
  126. package/dist/cloud/connect-service.d.ts +69 -0
  127. package/dist/cloud/connect-service.js +418 -50
  128. package/dist/cloud/connect-service.js.map +1 -1
  129. package/dist/cloud/file-listing-publication.d.ts +3 -0
  130. package/dist/cloud/file-listing-publication.js +2 -2
  131. package/dist/cloud/file-listing-publication.js.map +1 -1
  132. package/dist/cloud/owned-runtime.js +21 -2
  133. package/dist/cloud/owned-runtime.js.map +1 -1
  134. package/dist/cloud/product-import-tabular.d.ts +6 -2
  135. package/dist/cloud/product-import-tabular.js +57 -41
  136. package/dist/cloud/product-import-tabular.js.map +1 -1
  137. package/dist/cloud/product-source.d.ts +6 -3
  138. package/dist/cloud/product-source.js +8 -8
  139. package/dist/cloud/product-source.js.map +1 -1
  140. package/dist/cloud/trade-platforms-client.d.ts +8 -0
  141. package/dist/cloud/trade-platforms-client.js +28 -0
  142. package/dist/cloud/trade-platforms-client.js.map +1 -0
  143. package/dist/commerce/types.d.ts +6 -2
  144. package/dist/commerce/types.js +10 -3
  145. package/dist/commerce/types.js.map +1 -1
  146. package/dist/config/profile.d.ts +24 -0
  147. package/dist/config/profile.js +45 -3
  148. package/dist/config/profile.js.map +1 -1
  149. package/dist/counterparty/shopping-cli-hosted/index.js +20 -12
  150. package/dist/counterparty/shopping-cli-hosted/index.js.map +1 -1
  151. package/dist/discovery/catalog-source/kiwi-record.d.ts +23 -0
  152. package/dist/discovery/catalog-source/kiwi-record.js.map +1 -1
  153. package/dist/discovery/catalog-source/kiwi-source.js +4 -1
  154. package/dist/discovery/catalog-source/kiwi-source.js.map +1 -1
  155. package/dist/discovery/merchant-subscriptions.js +9 -0
  156. package/dist/discovery/merchant-subscriptions.js.map +1 -1
  157. package/dist/handoff/channel.js +3 -1
  158. package/dist/handoff/channel.js.map +1 -1
  159. package/dist/handoff/idempotency.d.ts +6 -0
  160. package/dist/handoff/idempotency.js +71 -18
  161. package/dist/handoff/idempotency.js.map +1 -1
  162. package/dist/handoff/launch-marketplace-policy.d.ts +1 -1
  163. package/dist/handoff/launch-marketplace-policy.js +9 -1
  164. package/dist/handoff/launch-marketplace-policy.js.map +1 -1
  165. package/dist/handoff/ledger.d.ts +6 -1
  166. package/dist/handoff/ledger.js +13 -2
  167. package/dist/handoff/ledger.js.map +1 -1
  168. package/dist/handoff/marketplace-product-link.d.ts +17 -6
  169. package/dist/handoff/marketplace-product-link.js +27 -37
  170. package/dist/handoff/marketplace-product-link.js.map +1 -1
  171. package/dist/handoff/operator-approval.d.ts +3 -0
  172. package/dist/handoff/operator-approval.js +34 -1
  173. package/dist/handoff/operator-approval.js.map +1 -1
  174. package/dist/handoff/trade-platform-rules.d.ts +26 -0
  175. package/dist/handoff/trade-platform-rules.js +95 -0
  176. package/dist/handoff/trade-platform-rules.js.map +1 -0
  177. package/dist/handoff/transaction.d.ts +5 -0
  178. package/dist/handoff/transaction.js +7 -1
  179. package/dist/handoff/transaction.js.map +1 -1
  180. package/dist/handoff/ucp-checkout/channel.d.ts +14 -0
  181. package/dist/handoff/ucp-checkout/channel.js +87 -1
  182. package/dist/handoff/ucp-checkout/channel.js.map +1 -1
  183. package/dist/handoff/ucp-checkout/types.d.ts +1 -1
  184. package/dist/handoff/ucp-checkout/types.js +3 -0
  185. package/dist/handoff/ucp-checkout/types.js.map +1 -1
  186. package/dist/handoff/url-safety.js +8 -1
  187. package/dist/handoff/url-safety.js.map +1 -1
  188. package/dist/http/bounded-ip-rate-limit.js +16 -2
  189. package/dist/http/bounded-ip-rate-limit.js.map +1 -1
  190. package/dist/http/merchant-management/api.d.ts +23 -0
  191. package/dist/http/merchant-management/api.js +132 -5
  192. package/dist/http/merchant-management/api.js.map +1 -1
  193. package/dist/http/merchant-management/page.js +274 -39
  194. package/dist/http/merchant-management/page.js.map +1 -1
  195. package/dist/http/merchant-management/trusted-page.js +5 -3
  196. package/dist/http/merchant-management/trusted-page.js.map +1 -1
  197. package/dist/http/merchant-privacy-api.js +24 -0
  198. package/dist/http/merchant-privacy-api.js.map +1 -1
  199. package/dist/http/merchant-server.js +13 -4
  200. package/dist/http/merchant-server.js.map +1 -1
  201. package/dist/http/server.js +25 -5
  202. package/dist/http/server.js.map +1 -1
  203. package/dist/mcp/cli.d.ts +2 -0
  204. package/dist/mcp/cli.js +11 -0
  205. package/dist/mcp/cli.js.map +1 -1
  206. package/dist/mcp/merchant-auth.d.ts +30 -0
  207. package/dist/mcp/merchant-auth.js +72 -0
  208. package/dist/mcp/merchant-auth.js.map +1 -1
  209. package/dist/mcp/merchant-conversation.d.ts +91 -0
  210. package/dist/mcp/merchant-conversation.js +207 -0
  211. package/dist/mcp/merchant-conversation.js.map +1 -0
  212. package/dist/mcp/merchant-runtime-assembly.d.ts +3 -1
  213. package/dist/mcp/merchant-runtime-assembly.js +74 -7
  214. package/dist/mcp/merchant-runtime-assembly.js.map +1 -1
  215. package/dist/mcp/merchant-server.d.ts +22 -2
  216. package/dist/mcp/merchant-server.js +53 -10
  217. package/dist/mcp/merchant-server.js.map +1 -1
  218. package/dist/mcp/merchant-tools.d.ts +6 -12
  219. package/dist/mcp/merchant-tools.js +129 -8
  220. package/dist/mcp/merchant-tools.js.map +1 -1
  221. package/dist/mcp/read-audit.d.ts +63 -0
  222. package/dist/mcp/read-audit.js +111 -0
  223. package/dist/mcp/read-audit.js.map +1 -0
  224. package/dist/merchant/ai-runtime/owner-sdk-tools.d.ts +1 -1
  225. package/dist/merchant/ai-runtime/owner-storage-admission.js +11 -7
  226. package/dist/merchant/ai-runtime/owner-storage-admission.js.map +1 -1
  227. package/dist/merchant/application/service.d.ts +2 -1
  228. package/dist/merchant/application/service.js.map +1 -1
  229. package/dist/merchant/decision-backend.js +24 -2
  230. package/dist/merchant/decision-backend.js.map +1 -1
  231. package/dist/merchant/negotiation-observer.js +12 -2
  232. package/dist/merchant/negotiation-observer.js.map +1 -1
  233. package/dist/merchant/operations-report.d.ts +12 -0
  234. package/dist/merchant/operations-report.js +17 -0
  235. package/dist/merchant/operations-report.js.map +1 -1
  236. package/dist/merchant/watch/detect.js +14 -0
  237. package/dist/merchant/watch/detect.js.map +1 -1
  238. package/dist/merchant/watch/weixin.js +7 -1
  239. package/dist/merchant/watch/weixin.js.map +1 -1
  240. package/dist/merchant/workbench-service.d.ts +45 -3
  241. package/dist/merchant/workbench-service.js +119 -4
  242. package/dist/merchant/workbench-service.js.map +1 -1
  243. package/dist/merchant-core/commands.d.ts +5 -0
  244. package/dist/merchant-core/commands.js +19 -0
  245. package/dist/merchant-core/commands.js.map +1 -1
  246. package/dist/merchant-core/executor.js +3 -2
  247. package/dist/merchant-core/executor.js.map +1 -1
  248. package/dist/merchant-core/operating/service.js +9 -0
  249. package/dist/merchant-core/operating/service.js.map +1 -1
  250. package/dist/merchant-core/operations.js +18 -4
  251. package/dist/merchant-core/operations.js.map +1 -1
  252. package/dist/merchant-core/opportunity/service.js +9 -0
  253. package/dist/merchant-core/opportunity/service.js.map +1 -1
  254. package/dist/merchant-core/orders/repository.js +8 -0
  255. package/dist/merchant-core/orders/repository.js.map +1 -1
  256. package/dist/merchant-core/product-import.d.ts +9 -0
  257. package/dist/merchant-core/product-import.js +17 -3
  258. package/dist/merchant-core/product-import.js.map +1 -1
  259. package/dist/merchant-core/proposal/service.js +9 -0
  260. package/dist/merchant-core/proposal/service.js.map +1 -1
  261. package/dist/merchant-core/rfq/delivery.js +1 -1
  262. package/dist/merchant-core/rfq/delivery.js.map +1 -1
  263. package/dist/merchant-core/rfq/handoff.js +2 -3
  264. package/dist/merchant-core/rfq/handoff.js.map +1 -1
  265. package/dist/merchant-core/rfq/policy.d.ts +0 -8
  266. package/dist/merchant-core/rfq/policy.js +6 -1
  267. package/dist/merchant-core/rfq/policy.js.map +1 -1
  268. package/dist/merchant-core/rfq/repository.d.ts +2 -0
  269. package/dist/merchant-core/rfq/repository.js +10 -1
  270. package/dist/merchant-core/rfq/repository.js.map +1 -1
  271. package/dist/merchant-core/service.d.ts +7 -0
  272. package/dist/merchant-core/service.js +33 -3
  273. package/dist/merchant-core/service.js.map +1 -1
  274. package/dist/merchant-core/storage/redact.js +3 -0
  275. package/dist/merchant-core/storage/redact.js.map +1 -1
  276. package/dist/merchant-gateway/cli.js +9 -1
  277. package/dist/merchant-gateway/cli.js.map +1 -1
  278. package/dist/merchant-gateway/credential-vault.d.ts +3 -0
  279. package/dist/merchant-gateway/credential-vault.js +54 -10
  280. package/dist/merchant-gateway/credential-vault.js.map +1 -1
  281. package/dist/merchant-gateway/entry-server.js +15 -4
  282. package/dist/merchant-gateway/entry-server.js.map +1 -1
  283. package/dist/merchant-gateway/instance-tool-policy.d.ts +23 -0
  284. package/dist/merchant-gateway/instance-tool-policy.js +26 -0
  285. package/dist/merchant-gateway/instance-tool-policy.js.map +1 -0
  286. package/dist/merchant-runtime/manager.d.ts +2 -0
  287. package/dist/merchant-runtime/manager.js +49 -1
  288. package/dist/merchant-runtime/manager.js.map +1 -1
  289. package/dist/negotiation/ledger/store.js +6 -3
  290. package/dist/negotiation/ledger/store.js.map +1 -1
  291. package/dist/net/client-ip.d.ts +29 -0
  292. package/dist/net/client-ip.js +39 -0
  293. package/dist/net/client-ip.js.map +1 -0
  294. package/dist/net/safe-http.d.ts +1 -1
  295. package/dist/net/safe-http.js +8 -0
  296. package/dist/net/safe-http.js.map +1 -1
  297. package/dist/operator/controller.js +3 -1
  298. package/dist/operator/controller.js.map +1 -1
  299. package/dist/operator/runner.js +1 -1
  300. package/dist/operator/runner.js.map +1 -1
  301. package/dist/operator/tui.js +10 -3
  302. package/dist/operator/tui.js.map +1 -1
  303. package/dist/product-buyer.js +1 -0
  304. package/dist/product-buyer.js.map +1 -1
  305. package/dist/product-cli.js +2 -1
  306. package/dist/product-cli.js.map +1 -1
  307. package/dist/protocol/legacy-shopping-negotiation/adapter.js +9 -0
  308. package/dist/protocol/legacy-shopping-negotiation/adapter.js.map +1 -1
  309. package/dist/runtime/bounded-memory.d.ts +25 -0
  310. package/dist/runtime/bounded-memory.js +60 -0
  311. package/dist/runtime/bounded-memory.js.map +1 -0
  312. package/dist/runtime/fake-model.js +7 -1
  313. package/dist/runtime/fake-model.js.map +1 -1
  314. package/dist/runtime/lock-owner.d.ts +36 -0
  315. package/dist/runtime/lock-owner.js +98 -0
  316. package/dist/runtime/lock-owner.js.map +1 -0
  317. package/dist/runtime/locks-cli.d.ts +21 -0
  318. package/dist/runtime/locks-cli.js +94 -0
  319. package/dist/runtime/locks-cli.js.map +1 -0
  320. package/dist/runtime/locks.d.ts +60 -0
  321. package/dist/runtime/locks.js +202 -0
  322. package/dist/runtime/locks.js.map +1 -0
  323. package/dist/runtime/negotiation-turn.js +1 -1
  324. package/dist/runtime/negotiation-turn.js.map +1 -1
  325. package/dist/runtime/tools.d.ts +1 -1
  326. package/dist/trust/identity/auth-verifier.d.ts +23 -21
  327. package/dist/trust/identity/auth-verifier.js +65 -1
  328. package/dist/trust/identity/auth-verifier.js.map +1 -1
  329. package/dist/trust/identity/jwk.d.ts +1 -0
  330. package/dist/trust/identity/signature-base.js +3 -1
  331. package/dist/trust/identity/signature-base.js.map +1 -1
  332. package/dist/trust/records/store.d.ts +7 -1
  333. package/dist/trust/records/store.js +44 -14
  334. package/dist/trust/records/store.js.map +1 -1
  335. package/dist/weixin/brand.d.ts +19 -0
  336. package/dist/weixin/brand.js +28 -0
  337. package/dist/weixin/brand.js.map +1 -0
  338. package/dist/weixin/channel.js +11 -1
  339. package/dist/weixin/channel.js.map +1 -1
  340. package/dist/weixin/ilink-client.d.ts +16 -3
  341. package/dist/weixin/ilink-client.js +39 -6
  342. package/dist/weixin/ilink-client.js.map +1 -1
  343. package/dist/weixin/login.d.ts +3 -1
  344. package/dist/weixin/login.js +82 -46
  345. package/dist/weixin/login.js.map +1 -1
  346. package/dist/weixin/types.d.ts +16 -1
  347. package/dist/weixin/types.js.map +1 -1
  348. package/dist/workbuddy-adapter/binding.d.ts +19 -0
  349. package/dist/workbuddy-adapter/binding.js +66 -0
  350. package/dist/workbuddy-adapter/binding.js.map +1 -0
  351. package/dist/workbuddy-adapter/cli.d.ts +31 -0
  352. package/dist/workbuddy-adapter/cli.js +754 -0
  353. package/dist/workbuddy-adapter/cli.js.map +1 -0
  354. package/dist/workbuddy-adapter/client-cache.d.ts +11 -0
  355. package/dist/workbuddy-adapter/client-cache.js +17 -0
  356. package/dist/workbuddy-adapter/client-cache.js.map +1 -0
  357. package/dist/workbuddy-adapter/index.d.ts +7 -0
  358. package/dist/workbuddy-adapter/index.js +8 -0
  359. package/dist/workbuddy-adapter/index.js.map +1 -0
  360. package/dist/workbuddy-adapter/mcp-client.d.ts +34 -0
  361. package/dist/workbuddy-adapter/mcp-client.js +167 -0
  362. package/dist/workbuddy-adapter/mcp-client.js.map +1 -0
  363. package/dist/workbuddy-adapter/oauth.d.ts +84 -0
  364. package/dist/workbuddy-adapter/oauth.js +327 -0
  365. package/dist/workbuddy-adapter/oauth.js.map +1 -0
  366. package/dist/workbuddy-adapter/token-store.d.ts +35 -0
  367. package/dist/workbuddy-adapter/token-store.js +137 -0
  368. package/dist/workbuddy-adapter/token-store.js.map +1 -0
  369. package/dist/workbuddy-adapter/write-lock.d.ts +19 -0
  370. package/dist/workbuddy-adapter/write-lock.js +90 -0
  371. package/dist/workbuddy-adapter/write-lock.js.map +1 -0
  372. package/package.json +21 -15
  373. package/skills/kiwi-buyer/SKILL.md +10 -2
@@ -43,13 +43,15 @@ import { ADMIN_SESSION_COOKIE } from "../../auth/merchant-sessions.js";
43
43
  import { FileListingPublicationError, } from "../../cloud/file-listing-publication.js";
44
44
  import { parseProductTable, ProductTableError, productTableDigest, } from "../../cloud/product-source.js";
45
45
  import { convertTabularImport, renderImportTemplateCsv, renderImportTemplateXlsx, TABULAR_IMPORT_MAX_BYTES, } from "../../cloud/product-import-tabular.js";
46
+ import { normalizeTradePlatformRules, } from "../../handoff/trade-platform-rules.js";
46
47
  import { MerchantImportDraftStore } from "./draft-store.js";
47
48
  import { ActorContextError, assertVerifiedActor, createVerifiedActorContext, hasPermission, } from "../../merchant/application/actor.js";
48
49
  import { MANAGEMENT_API_MAJOR, MANAGEMENT_ERROR_STATUS, ManagementError, MerchantApplicationService, } from "../../merchant/application/service.js";
49
50
  import { managementRequestDigest, MerchantManagementOperationStore } from "./operation-store.js";
50
51
  import { OnboardingStore } from "../../cloud/onboarding/store.js";
51
52
  import { readEnrollmentStore } from "../../cloud/binding/enrollment-challenge.js";
52
- import { MerchantConnectError } from "../../cloud/connect-service.js";
53
+ import { MerchantConnectError, } from "../../cloud/connect-service.js";
54
+ import { isMerchantAccessMode, } from "../../cloud/access/access-mode.js";
53
55
  import { requestsDisabledLocalImplementation } from "../../cloud/onboarding/local-fallback.js";
54
56
  import { checkStepSubmission, planWizard, WIZARD_STEPS } from "../../cloud/onboarding/steps.js";
55
57
  import { createWorkbenchProblem } from "./problem.js";
@@ -94,12 +96,23 @@ const CATALOG_CONNECTION_SAFE_CODES = new Set([
94
96
  */
95
97
  const CONNECT_BEGIN_PRE_EFFECT_CODES = new Set([
96
98
  "CATALOG_MISMATCH", "STATE_INVALID", "PREVIEW_CHANGED", "RUNTIME_CARD_CHANGED",
99
+ // 接入方式/公开名片读取发生在本机,且在任何 create enrollment 之前:
100
+ // 失败没有不确定的远端副作用,商家修正后可用同一幂等键重试。
101
+ "ACCESS_SHARE_LINK_REQUIRED", "ACCESS_MODE_UNCERTAIN",
97
102
  ]);
98
103
  const MAX_BODY_BYTES = 1_048_576;
99
104
  /** 非候选写命令确认引用的有效期(BD §7.3:短时、单次)。 */
100
105
  const CONFIRMATION_TTL_MS = 5 * 60 * 1000;
101
106
  class BodyTooLarge {
102
107
  }
108
+ async function resolvePlatformRules(options) {
109
+ try {
110
+ return normalizeTradePlatformRules(await options.marketplacePlatforms?.());
111
+ }
112
+ catch {
113
+ return normalizeTradePlatformRules(undefined);
114
+ }
115
+ }
103
116
  export function createMerchantManagementApiHandler(options) {
104
117
  const log = options.log ??
105
118
  ((line) => {
@@ -244,6 +257,17 @@ export function createMerchantManagementApiHandler(options) {
244
257
  await runAccessRoute(res, requestId, () => channel.getAccess());
245
258
  return;
246
259
  }
260
+ if (rest === "/catalog/bound-account") {
261
+ const auth = requireActor(req);
262
+ authorizeOrThrow(auth.ctx, "onboarding:manage");
263
+ if (auth.ctx.role !== "owner")
264
+ throw new ManagementError("forbidden", "only owner can view the bound account");
265
+ const read = options.catalogConnection?.readBoundAccount;
266
+ if (read === undefined)
267
+ throw new ManagementError("unavailable", "目录账户信息不可用");
268
+ writeJson(res, 200, { email: await read() }, { "x-request-id": requestId, "cache-control": "no-store" });
269
+ return;
270
+ }
247
271
  if (rest === "/catalog/connect" || rest === "/catalog/connect/pairing") {
248
272
  const auth = requireActor(req);
249
273
  authorizeOrThrow(auth.ctx, "onboarding:manage");
@@ -332,6 +356,13 @@ export function createMerchantManagementApiHandler(options) {
332
356
  }, { "x-request-id": requestId });
333
357
  return;
334
358
  }
359
+ if (rest === "/policy") {
360
+ // Workbench 页面(v1)与旧 v0 页面读取同一份脱敏策略投影;
361
+ // 此前 v1 缺少该路由,商家后台「报价规则」报 API 路由不存在。
362
+ const auth = requireActor(req);
363
+ writeJson(res, 200, await readService.getPolicy(auth.ctx), { "x-request-id": requestId });
364
+ return;
365
+ }
335
366
  if (rest === "/runtime/status") {
336
367
  const auth = requireActor(req);
337
368
  writeJson(res, 200, {
@@ -373,8 +404,9 @@ export function createMerchantManagementApiHandler(options) {
373
404
  res.end();
374
405
  return;
375
406
  }
407
+ const platforms = await resolvePlatformRules(options);
376
408
  if (format === "csv") {
377
- const body = renderImportTemplateCsv();
409
+ const body = renderImportTemplateCsv(platforms);
378
410
  res.writeHead(200, {
379
411
  "content-type": "text/csv; charset=utf-8",
380
412
  "content-disposition": 'attachment; filename="kiwi-product-import-template.csv"',
@@ -384,7 +416,7 @@ export function createMerchantManagementApiHandler(options) {
384
416
  res.end(body);
385
417
  return;
386
418
  }
387
- const bytes = renderImportTemplateXlsx();
419
+ const bytes = renderImportTemplateXlsx(platforms);
388
420
  res.writeHead(200, {
389
421
  "content-type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
390
422
  "content-disposition": 'attachment; filename="kiwi-product-import-template.xlsx"',
@@ -878,13 +910,47 @@ export function createMerchantManagementApiHandler(options) {
878
910
  }
879
911
  if (rest === "/catalog/access/refresh" ||
880
912
  rest === "/catalog/access/share-link" ||
881
- rest === "/catalog/access/revoke") {
913
+ rest === "/catalog/access/revoke" ||
914
+ rest === "/catalog/access/mode" ||
915
+ rest === "/catalog/access/detect") {
882
916
  const auth = requireActor(req);
883
917
  assertWriteGuards(req, auth.sessionId);
884
918
  authorizeOrThrow(auth.ctx, "onboarding:manage");
885
919
  if (auth.ctx.role !== "owner")
886
920
  throw new ManagementError("forbidden", "only owner can manage Catalog access");
887
921
  const channel = options.catalogConnection;
922
+ if (rest === "/catalog/access/mode") {
923
+ if (channel?.setAccessMode === undefined) {
924
+ throw new ManagementError("unavailable", "Catalog access configuration is not configured");
925
+ }
926
+ const fields = objectFields(await readJsonBody(req), ["mode"]);
927
+ const mode = fields["mode"];
928
+ if (!isMerchantAccessMode(mode)) {
929
+ throw new ManagementError("invalid_input", "接入方式必须是 auto、share_code 或 no_share_code");
930
+ }
931
+ await runAccessRoute(res, requestId, () => channel.setAccessMode(mode));
932
+ return;
933
+ }
934
+ if (rest === "/catalog/access/detect") {
935
+ if (channel?.detectAccess === undefined) {
936
+ throw new ManagementError("unavailable", "Catalog access configuration is not configured");
937
+ }
938
+ // 探测目标固定为运行时已验证的 publicOrigin;请求体不允许携带 URL、
939
+ // 分享码或任何目标,避免把公开探测变成任意 SSRF/凭据试探入口。
940
+ objectFields(await readJsonBody(req), []);
941
+ let detection;
942
+ try {
943
+ detection = await channel.detectAccess();
944
+ }
945
+ catch {
946
+ throw new ManagementError("unavailable", "接入方式检测未完成,请稍后重试。");
947
+ }
948
+ writeJson(res, 200, { detection }, {
949
+ "x-request-id": requestId,
950
+ "cache-control": "no-store",
951
+ });
952
+ return;
953
+ }
888
954
  if (rest === "/catalog/access/refresh") {
889
955
  if (channel?.refreshAccess === undefined) {
890
956
  throw new ManagementError("unavailable", "Catalog access configuration is not configured");
@@ -2885,7 +2951,11 @@ export function createMerchantManagementApiHandler(options) {
2885
2951
  const buffer = Buffer.concat(chunks);
2886
2952
  const result = convertTabularImport(format === "csv"
2887
2953
  ? { kind: "csv", text: buffer.toString("utf8") }
2888
- : { kind: "xlsx", bytes: new Uint8Array(buffer) }, { merchantId: options.merchantId, now: () => now() });
2954
+ : { kind: "xlsx", bytes: new Uint8Array(buffer) }, {
2955
+ merchantId: options.merchantId,
2956
+ platformRules: await resolvePlatformRules(options),
2957
+ now: () => now(),
2958
+ });
2889
2959
  writeJson(res, 200, {
2890
2960
  ok: result.ok,
2891
2961
  ...(result.table !== undefined ? { table: result.table } : {}),
@@ -3045,6 +3115,7 @@ export function createMerchantManagementApiHandler(options) {
3045
3115
  "lead_days",
3046
3116
  "ttl_seconds",
3047
3117
  "human_review",
3118
+ "sku_rules",
3048
3119
  ]);
3049
3120
  const patch = {};
3050
3121
  if (fields["auto"] !== undefined) {
@@ -3078,6 +3149,60 @@ export function createMerchantManagementApiHandler(options) {
3078
3149
  }
3079
3150
  patch["human_review_on"] = triggers;
3080
3151
  }
3152
+ if (fields["sku_rules"] !== undefined) {
3153
+ const rules = fields["sku_rules"];
3154
+ if (!Array.isArray(rules)) {
3155
+ throw new ManagementError("invalid_input", "sku_rules must be an array");
3156
+ }
3157
+ if (options.policyCurrent === undefined) {
3158
+ throw new ManagementError("unavailable", "per-SKU rules require a readable current policy");
3159
+ }
3160
+ const current = options.policyCurrent();
3161
+ const floors = { ...(current?.price_floors ?? {}) };
3162
+ const discounts = {
3163
+ ...(current?.sku_max_discount_percent ?? {}),
3164
+ };
3165
+ const seen = new Set();
3166
+ for (const raw of rules) {
3167
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
3168
+ throw new ManagementError("invalid_input", "sku_rules entries must be objects");
3169
+ }
3170
+ const entry = raw;
3171
+ const sku = typeof entry["sku"] === "string" ? entry["sku"].trim() : "";
3172
+ if (sku === "" || sku.length > 128) {
3173
+ throw new ManagementError("invalid_input", "sku_rules.sku must be a non-empty string (<=128)");
3174
+ }
3175
+ if (seen.has(sku)) {
3176
+ throw new ManagementError("invalid_input", `duplicate SKU in sku_rules: ${sku}`);
3177
+ }
3178
+ seen.add(sku);
3179
+ let touched = false;
3180
+ if (entry["floor"] !== undefined) {
3181
+ touched = true;
3182
+ if (entry["floor"] === null)
3183
+ delete floors[sku];
3184
+ else
3185
+ floors[sku] = requireNonNegativeNumber(entry["floor"], `sku_rules.${sku}.floor`);
3186
+ }
3187
+ if (entry["discount"] !== undefined) {
3188
+ touched = true;
3189
+ if (entry["discount"] === null)
3190
+ delete discounts[sku];
3191
+ else {
3192
+ const discount = requireNonNegativeNumber(entry["discount"], `sku_rules.${sku}.discount`);
3193
+ if (discount > 100) {
3194
+ throw new ManagementError("invalid_input", `sku_rules.${sku}.discount must be 0-100`);
3195
+ }
3196
+ discounts[sku] = discount;
3197
+ }
3198
+ }
3199
+ if (!touched) {
3200
+ throw new ManagementError("invalid_input", `sku_rules.${sku} must include floor or discount`);
3201
+ }
3202
+ }
3203
+ patch["price_floors"] = floors;
3204
+ patch["sku_max_discount_percent"] = discounts;
3205
+ }
3081
3206
  if (Object.keys(patch).length === 0) {
3082
3207
  throw new ManagementError("invalid_input", "form submitted no changes");
3083
3208
  }
@@ -3549,6 +3674,8 @@ async function runAccessRoute(res, requestId, run) {
3549
3674
  ACCESS_NOT_CONFIGURED: "VALIDATION_ERROR",
3550
3675
  ACCESS_NOT_FOUND: "RESOURCE_NOT_FOUND",
3551
3676
  ACCESS_UNAVAILABLE: "DEPENDENCY_UNAVAILABLE",
3677
+ ACCESS_MODE_UNCERTAIN: "DEPENDENCY_UNAVAILABLE",
3678
+ ACCESS_STATE_UNAVAILABLE: "DEPENDENCY_UNAVAILABLE",
3552
3679
  STATE_INVALID: "VALIDATION_ERROR",
3553
3680
  MALFORMED_URL: "VALIDATION_ERROR",
3554
3681
  NOT_HTTPS: "VALIDATION_ERROR",