@harrylabsj/kiwi 0.12.3 → 0.12.5
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.
- package/README.md +1 -1
- package/contracts/kiwi-contracts.lock.json +1 -1
- package/dist/a2a/client/client.d.ts +3 -1
- package/dist/a2a/client/client.js +23 -14
- package/dist/a2a/client/client.js.map +1 -1
- package/dist/a2a/client/types.d.ts +1 -1
- package/dist/a2a/client/url-policy.d.ts +2 -1
- package/dist/a2a/client/url-policy.js +5 -2
- package/dist/a2a/client/url-policy.js.map +1 -1
- package/dist/a2a/negotiate.js +68 -27
- package/dist/a2a/negotiate.js.map +1 -1
- package/dist/a2a/node.d.ts +5 -1
- package/dist/a2a/node.js +68 -30
- package/dist/a2a/node.js.map +1 -1
- package/dist/a2a/server/merchant-handler.d.ts +4 -6
- package/dist/a2a/server/merchant-handler.js +679 -484
- package/dist/a2a/server/merchant-handler.js.map +1 -1
- package/dist/a2a/server/merchant-product-facts.d.ts +32 -0
- package/dist/a2a/server/merchant-product-facts.js +57 -0
- package/dist/a2a/server/merchant-product-facts.js.map +1 -0
- package/dist/a2a/server/pipeline.d.ts +1 -0
- package/dist/a2a/server/pipeline.js +48 -10
- package/dist/a2a/server/pipeline.js.map +1 -1
- package/dist/a2a/task/poller.d.ts +3 -0
- package/dist/a2a/task/poller.js +3 -0
- package/dist/a2a/task/poller.js.map +1 -1
- package/dist/agent/buyer/buyer-tools.d.ts +1 -1
- package/dist/agent/buyer/buyer-tools.js +322 -4
- package/dist/agent/buyer/buyer-tools.js.map +1 -1
- package/dist/agent/buyer/scheduler.d.ts +3 -0
- package/dist/agent/buyer/scheduler.js +25 -5
- package/dist/agent/buyer/scheduler.js.map +1 -1
- package/dist/agent/buyer/search-loop.js +6 -2
- package/dist/agent/buyer/search-loop.js.map +1 -1
- package/dist/agent/buyer/task-store.d.ts +12 -0
- package/dist/agent/buyer/task-store.js +101 -14
- package/dist/agent/buyer/task-store.js.map +1 -1
- package/dist/agent/kernel.d.ts +11 -0
- package/dist/agent/kernel.js +345 -273
- package/dist/agent/kernel.js.map +1 -1
- package/dist/agent/kiwi-tool.d.ts +11 -12
- package/dist/agent/merchant/action-candidate.d.ts +7 -0
- package/dist/agent/merchant/action-candidate.js +54 -9
- package/dist/agent/merchant/action-candidate.js.map +1 -1
- package/dist/agent/merchant/types.d.ts +4 -9
- package/dist/agent/merchant/types.js +14 -0
- package/dist/agent/merchant/types.js.map +1 -1
- package/dist/agent/negotiation-chat.js +36 -8
- package/dist/agent/negotiation-chat.js.map +1 -1
- package/dist/agent/session.js +8 -0
- package/dist/agent/session.js.map +1 -1
- package/dist/agent/write-gate.d.ts +4 -0
- package/dist/agent/write-gate.js +22 -20
- package/dist/agent/write-gate.js.map +1 -1
- package/dist/buyer-core/a2a-knp.d.ts +2 -8
- package/dist/buyer-core/a2a-knp.js +16 -3
- package/dist/buyer-core/a2a-knp.js.map +1 -1
- package/dist/buyer-core/a2a-negotiator.d.ts +26 -19
- package/dist/buyer-core/a2a-negotiator.js +105 -38
- package/dist/buyer-core/a2a-negotiator.js.map +1 -1
- package/dist/buyer-core/a2a-quote-fetcher.d.ts +17 -3
- package/dist/buyer-core/a2a-quote-fetcher.js +141 -57
- package/dist/buyer-core/a2a-quote-fetcher.js.map +1 -1
- package/dist/buyer-core/build-service.d.ts +2 -0
- package/dist/buyer-core/build-service.js +28 -2
- package/dist/buyer-core/build-service.js.map +1 -1
- package/dist/buyer-core/errors.js +1 -1
- package/dist/buyer-core/negotiator.d.ts +0 -15
- package/dist/buyer-core/negotiator.js +3 -0
- package/dist/buyer-core/negotiator.js.map +1 -1
- package/dist/buyer-core/product-summary.d.ts +4 -0
- package/dist/buyer-core/product-summary.js +6 -0
- package/dist/buyer-core/product-summary.js.map +1 -1
- package/dist/buyer-core/protocol-recovery.d.ts +78 -0
- package/dist/buyer-core/protocol-recovery.js +368 -0
- package/dist/buyer-core/protocol-recovery.js.map +1 -0
- package/dist/buyer-core/receive-gate.d.ts +11 -0
- package/dist/buyer-core/receive-gate.js +107 -0
- package/dist/buyer-core/receive-gate.js.map +1 -0
- package/dist/buyer-core/service.d.ts +53 -2
- package/dist/buyer-core/service.js +584 -74
- package/dist/buyer-core/service.js.map +1 -1
- package/dist/buyer-core/store.d.ts +27 -2
- package/dist/buyer-core/store.js +131 -26
- package/dist/buyer-core/store.js.map +1 -1
- package/dist/cli.js +208 -21
- package/dist/cli.js.map +1 -1
- package/dist/cloud/binding/enrollment-challenge.d.ts +1 -0
- package/dist/cloud/binding/enrollment-challenge.js +84 -33
- package/dist/cloud/binding/enrollment-challenge.js.map +1 -1
- package/dist/cloud/binding/enrollment-heartbeat.d.ts +2 -0
- package/dist/cloud/binding/enrollment-heartbeat.js +6 -2
- package/dist/cloud/binding/enrollment-heartbeat.js.map +1 -1
- package/dist/cloud/binding/proofs.d.ts +5 -0
- package/dist/cloud/binding/proofs.js +14 -1
- package/dist/cloud/binding/proofs.js.map +1 -1
- package/dist/cloud/binding/runtime-challenge.d.ts +2 -0
- package/dist/cloud/binding/runtime-challenge.js +20 -8
- package/dist/cloud/binding/runtime-challenge.js.map +1 -1
- package/dist/cloud/binding/store-lock.d.ts +13 -0
- package/dist/cloud/binding/store-lock.js +77 -0
- package/dist/cloud/binding/store-lock.js.map +1 -0
- package/dist/cloud/bootstrap.d.ts +4 -0
- package/dist/cloud/bootstrap.js +74 -57
- package/dist/cloud/bootstrap.js.map +1 -1
- package/dist/cloud/catalog-client.d.ts +4 -0
- package/dist/cloud/catalog-client.js +106 -29
- package/dist/cloud/catalog-client.js.map +1 -1
- package/dist/cloud/connect-service.d.ts +6 -0
- package/dist/cloud/connect-service.js +360 -120
- package/dist/cloud/connect-service.js.map +1 -1
- package/dist/cloud/file-listing-publication.js +6 -0
- package/dist/cloud/file-listing-publication.js.map +1 -1
- package/dist/cloud/main.d.ts +3 -0
- package/dist/cloud/main.js +47 -11
- package/dist/cloud/main.js.map +1 -1
- package/dist/cloud/onboarding/catalog-pipeline.d.ts +32 -1
- package/dist/cloud/onboarding/catalog-pipeline.js +80 -19
- package/dist/cloud/onboarding/catalog-pipeline.js.map +1 -1
- package/dist/cloud/onboarding/store.js +12 -4
- package/dist/cloud/onboarding/store.js.map +1 -1
- package/dist/cloud/product-import-tabular.d.ts +1 -1
- package/dist/cloud/product-import-tabular.js +275 -36
- package/dist/cloud/product-import-tabular.js.map +1 -1
- package/dist/cloud/product-source.d.ts +6 -1
- package/dist/cloud/product-source.js +47 -15
- package/dist/cloud/product-source.js.map +1 -1
- package/dist/commerce/data-source.d.ts +4 -0
- package/dist/commerce/data-source.js.map +1 -1
- package/dist/commerce/http-client.d.ts +30 -1
- package/dist/commerce/http-client.js +11 -7
- package/dist/commerce/http-client.js.map +1 -1
- package/dist/commerce/shopping-cli-source.js +4 -0
- package/dist/commerce/shopping-cli-source.js.map +1 -1
- package/dist/commerce/types.d.ts +2 -1
- package/dist/commerce/types.js.map +1 -1
- package/dist/counterparty/a2a-direct/index.js +2 -20
- package/dist/counterparty/a2a-direct/index.js.map +1 -1
- package/dist/counterparty/channel.d.ts +2 -1
- package/dist/counterparty/channel.js.map +1 -1
- package/dist/counterparty/shopping-cli-hosted/index.js +2 -24
- package/dist/counterparty/shopping-cli-hosted/index.js.map +1 -1
- package/dist/demo/demo-runner.d.ts +1 -1
- package/dist/demo/demo-runner.js +3 -6
- package/dist/demo/demo-runner.js.map +1 -1
- package/dist/discovery/catalog-source/cloud-card.d.ts +4 -3
- package/dist/discovery/catalog-source/cloud-card.js +28 -25
- package/dist/discovery/catalog-source/cloud-card.js.map +1 -1
- package/dist/discovery/catalog-source/kiwi-source.d.ts +7 -19
- package/dist/discovery/catalog-source/kiwi-source.js +19 -12
- package/dist/discovery/catalog-source/kiwi-source.js.map +1 -1
- package/dist/discovery/catalog-source/register.js +22 -12
- package/dist/discovery/catalog-source/register.js.map +1 -1
- package/dist/discovery/catalog-source/source.d.ts +3 -17
- package/dist/discovery/catalog-source/source.js +11 -8
- package/dist/discovery/catalog-source/source.js.map +1 -1
- package/dist/discovery/catalog-source/types.d.ts +3 -2
- package/dist/discovery/catalog-source/types.js +0 -15
- package/dist/discovery/catalog-source/types.js.map +1 -1
- package/dist/discovery/merchant-subscriptions.d.ts +4 -0
- package/dist/discovery/merchant-subscriptions.js +72 -23
- package/dist/discovery/merchant-subscriptions.js.map +1 -1
- package/dist/discovery/resolve.d.ts +7 -3
- package/dist/discovery/resolve.js +62 -30
- package/dist/discovery/resolve.js.map +1 -1
- package/dist/discovery/ucp/resolver.d.ts +3 -17
- package/dist/discovery/ucp/resolver.js +9 -3
- package/dist/discovery/ucp/resolver.js.map +1 -1
- package/dist/fanout/disclosure.js +27 -10
- package/dist/fanout/disclosure.js.map +1 -1
- package/dist/fanout/orchestrator.js +38 -24
- package/dist/fanout/orchestrator.js.map +1 -1
- package/dist/fs/atomic-write.d.ts +11 -0
- package/dist/fs/atomic-write.js +67 -10
- package/dist/fs/atomic-write.js.map +1 -1
- package/dist/handoff/index.d.ts +2 -1
- package/dist/handoff/index.js +1 -0
- package/dist/handoff/index.js.map +1 -1
- package/dist/handoff/launch-marketplace-policy.d.ts +149 -0
- package/dist/handoff/launch-marketplace-policy.js +301 -0
- package/dist/handoff/launch-marketplace-policy.js.map +1 -0
- package/dist/handoff/marketplace-product-link.d.ts +18 -0
- package/dist/handoff/marketplace-product-link.js +71 -0
- package/dist/handoff/marketplace-product-link.js.map +1 -0
- package/dist/handoff/order-record.js +25 -3
- package/dist/handoff/order-record.js.map +1 -1
- package/dist/handoff/transaction.d.ts +30 -0
- package/dist/handoff/transaction.js +64 -0
- package/dist/handoff/transaction.js.map +1 -1
- package/dist/handoff/ucp-checkout/channel.js +2 -1
- package/dist/handoff/ucp-checkout/channel.js.map +1 -1
- package/dist/handoff/ucp-checkout/client.d.ts +1 -0
- package/dist/handoff/ucp-checkout/client.js +48 -37
- package/dist/handoff/ucp-checkout/client.js.map +1 -1
- package/dist/handoff/url-safety.d.ts +3 -0
- package/dist/handoff/url-safety.js +7 -0
- package/dist/handoff/url-safety.js.map +1 -1
- package/dist/http/bounded-ip-rate-limit.d.ts +10 -0
- package/dist/http/bounded-ip-rate-limit.js +37 -0
- package/dist/http/bounded-ip-rate-limit.js.map +1 -0
- package/dist/http/cli.js +23 -0
- package/dist/http/cli.js.map +1 -1
- package/dist/http/merchant-feed-api.js +8 -1
- package/dist/http/merchant-feed-api.js.map +1 -1
- package/dist/http/merchant-management/api.js +20 -1
- package/dist/http/merchant-management/api.js.map +1 -1
- package/dist/http/merchant-management/page.js +176 -45
- package/dist/http/merchant-management/page.js.map +1 -1
- package/dist/http/merchant-management/reconciliation-worker.js +5 -2
- package/dist/http/merchant-management/reconciliation-worker.js.map +1 -1
- package/dist/http/merchant-management/trusted-page.js +1 -1
- package/dist/http/merchant-management/trusted-page.js.map +1 -1
- package/dist/http/merchant-server.js +2 -1
- package/dist/http/merchant-server.js.map +1 -1
- package/dist/http/server.d.ts +15 -0
- package/dist/http/server.js +107 -9
- package/dist/http/server.js.map +1 -1
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +3 -0
- package/dist/i18n.js.map +1 -1
- package/dist/lifecycle/close.d.ts +24 -0
- package/dist/lifecycle/close.js +131 -0
- package/dist/lifecycle/close.js.map +1 -0
- package/dist/mcp/merchant-rfq-tools.d.ts +6 -4
- package/dist/mcp/merchant-rfq-tools.js +2 -0
- package/dist/mcp/merchant-rfq-tools.js.map +1 -1
- package/dist/mcp/merchant-runtime-assembly.js +7 -22
- package/dist/mcp/merchant-runtime-assembly.js.map +1 -1
- package/dist/mcp/merchant-server.d.ts +0 -22
- package/dist/mcp/merchant-server.js +25 -2
- package/dist/mcp/merchant-server.js.map +1 -1
- package/dist/mcp/tools.js +17 -16
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +1 -1
- package/dist/mcp/types.js +1 -1
- package/dist/merchant/ai-runtime/config.d.ts +99 -0
- package/dist/merchant/ai-runtime/config.js +187 -0
- package/dist/merchant/ai-runtime/config.js.map +1 -0
- package/dist/merchant/ai-runtime/gate.d.ts +142 -0
- package/dist/merchant/ai-runtime/gate.js +343 -0
- package/dist/merchant/ai-runtime/gate.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-authoritative-receipts.d.ts +5 -0
- package/dist/merchant/ai-runtime/owner-authoritative-receipts.js +53 -0
- package/dist/merchant/ai-runtime/owner-authoritative-receipts.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-budget-gate.d.ts +10 -0
- package/dist/merchant/ai-runtime/owner-budget-gate.js +37 -0
- package/dist/merchant/ai-runtime/owner-budget-gate.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-business-config.d.ts +33 -0
- package/dist/merchant/ai-runtime/owner-business-config.js +93 -0
- package/dist/merchant/ai-runtime/owner-business-config.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-business-host.d.ts +24 -0
- package/dist/merchant/ai-runtime/owner-business-host.js +114 -0
- package/dist/merchant/ai-runtime/owner-business-host.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-business-proof-contract.d.ts +26 -0
- package/dist/merchant/ai-runtime/owner-business-proof-contract.js +2 -0
- package/dist/merchant/ai-runtime/owner-business-proof-contract.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-committed-proof.d.ts +55 -0
- package/dist/merchant/ai-runtime/owner-committed-proof.js +141 -0
- package/dist/merchant/ai-runtime/owner-committed-proof.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-factory-config.d.ts +30 -0
- package/dist/merchant/ai-runtime/owner-factory-config.js +99 -0
- package/dist/merchant/ai-runtime/owner-factory-config.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-file-grant.d.ts +71 -0
- package/dist/merchant/ai-runtime/owner-file-grant.js +118 -0
- package/dist/merchant/ai-runtime/owner-file-grant.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-local-readonly-host.d.ts +17 -0
- package/dist/merchant/ai-runtime/owner-local-readonly-host.js +116 -0
- package/dist/merchant/ai-runtime/owner-local-readonly-host.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-operation-reader.d.ts +24 -0
- package/dist/merchant/ai-runtime/owner-operation-reader.js +62 -0
- package/dist/merchant/ai-runtime/owner-operation-reader.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-provider-guard.d.ts +9 -0
- package/dist/merchant/ai-runtime/owner-provider-guard.js +127 -0
- package/dist/merchant/ai-runtime/owner-provider-guard.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-readonly-facts.d.ts +26 -0
- package/dist/merchant/ai-runtime/owner-readonly-facts.js +72 -0
- package/dist/merchant/ai-runtime/owner-readonly-facts.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-sdk-tools.d.ts +43 -0
- package/dist/merchant/ai-runtime/owner-sdk-tools.js +83 -0
- package/dist/merchant/ai-runtime/owner-sdk-tools.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-session.d.ts +341 -0
- package/dist/merchant/ai-runtime/owner-session.js +1280 -0
- package/dist/merchant/ai-runtime/owner-session.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-storage-admission.d.ts +35 -0
- package/dist/merchant/ai-runtime/owner-storage-admission.js +324 -0
- package/dist/merchant/ai-runtime/owner-storage-admission.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-trusted-factory.d.ts +44 -0
- package/dist/merchant/ai-runtime/owner-trusted-factory.js +185 -0
- package/dist/merchant/ai-runtime/owner-trusted-factory.js.map +1 -0
- package/dist/merchant/ai-runtime/sqlite-budget-store.d.ts +68 -0
- package/dist/merchant/ai-runtime/sqlite-budget-store.js +335 -0
- package/dist/merchant/ai-runtime/sqlite-budget-store.js.map +1 -0
- package/dist/merchant/ai-runtime/status.d.ts +64 -0
- package/dist/merchant/ai-runtime/status.js +56 -0
- package/dist/merchant/ai-runtime/status.js.map +1 -0
- package/dist/merchant/application/service.d.ts +5 -1
- package/dist/merchant/application/service.js +7 -8
- package/dist/merchant/application/service.js.map +1 -1
- package/dist/merchant/grant-store.js +9 -4
- package/dist/merchant/grant-store.js.map +1 -1
- package/dist/merchant/promotion-store.js +1 -0
- package/dist/merchant/promotion-store.js.map +1 -1
- package/dist/merchant/stats-store.d.ts +3 -0
- package/dist/merchant/stats-store.js +28 -8
- package/dist/merchant/stats-store.js.map +1 -1
- package/dist/merchant/workbench-service.d.ts +1 -0
- package/dist/merchant/workbench-service.js +28 -11
- package/dist/merchant/workbench-service.js.map +1 -1
- package/dist/merchant-core/commands.d.ts +3 -0
- package/dist/merchant-core/commands.js +39 -2
- package/dist/merchant-core/commands.js.map +1 -1
- package/dist/merchant-core/executor.d.ts +2 -0
- package/dist/merchant-core/executor.js +1 -1
- package/dist/merchant-core/executor.js.map +1 -1
- package/dist/merchant-core/operations.d.ts +2 -2
- package/dist/merchant-core/operations.js +11 -9
- package/dist/merchant-core/operations.js.map +1 -1
- package/dist/merchant-core/product-import.js +1 -1
- package/dist/merchant-core/product-import.js.map +1 -1
- package/dist/merchant-core/rfq/data-source-adapter.d.ts +2 -10
- package/dist/merchant-core/rfq/data-source-adapter.js +21 -9
- package/dist/merchant-core/rfq/data-source-adapter.js.map +1 -1
- package/dist/merchant-core/rfq/pending-candidates.d.ts +14 -0
- package/dist/merchant-core/rfq/pending-candidates.js +11 -0
- package/dist/merchant-core/rfq/pending-candidates.js.map +1 -0
- package/dist/merchant-core/rfq/release-coordinator.d.ts +9 -2
- package/dist/merchant-core/rfq/release-coordinator.js +32 -14
- package/dist/merchant-core/rfq/release-coordinator.js.map +1 -1
- package/dist/merchant-core/rfq/repository.d.ts +4 -7
- package/dist/merchant-core/rfq/repository.js +10 -24
- package/dist/merchant-core/rfq/repository.js.map +1 -1
- package/dist/merchant-core/rfq/service.d.ts +5 -2
- package/dist/merchant-core/rfq/service.js +4 -3
- package/dist/merchant-core/rfq/service.js.map +1 -1
- package/dist/merchant-gateway/entry-server.js +25 -1
- package/dist/merchant-gateway/entry-server.js.map +1 -1
- package/dist/merchant-gateway/pinned-fetch.d.ts +9 -2
- package/dist/merchant-gateway/pinned-fetch.js +68 -29
- package/dist/merchant-gateway/pinned-fetch.js.map +1 -1
- package/dist/merchant-runtime/manager.d.ts +5 -2
- package/dist/merchant-runtime/manager.js +40 -11
- package/dist/merchant-runtime/manager.js.map +1 -1
- package/dist/negotiation/context-map/store.js +4 -13
- package/dist/negotiation/context-map/store.js.map +1 -1
- package/dist/negotiation/domain/common.js +33 -2
- package/dist/negotiation/domain/common.js.map +1 -1
- package/dist/negotiation/domain/envelope.d.ts +2 -5
- package/dist/negotiation/domain/envelope.js +36 -9
- package/dist/negotiation/domain/envelope.js.map +1 -1
- package/dist/negotiation/domain/objects.js +14 -0
- package/dist/negotiation/domain/objects.js.map +1 -1
- package/dist/negotiation/idempotency/store.d.ts +4 -1
- package/dist/negotiation/idempotency/store.js +80 -52
- package/dist/negotiation/idempotency/store.js.map +1 -1
- package/dist/negotiation/idempotency/types.d.ts +7 -1
- package/dist/negotiation/idempotency/types.js +1 -1
- package/dist/negotiation/idempotency/types.js.map +1 -1
- package/dist/negotiation/jcs.js +11 -16
- package/dist/negotiation/jcs.js.map +1 -1
- package/dist/negotiation/ledger/store.d.ts +15 -9
- package/dist/negotiation/ledger/store.js +201 -65
- package/dist/negotiation/ledger/store.js.map +1 -1
- package/dist/negotiation/recovery/recover.js +30 -30
- package/dist/negotiation/recovery/recover.js.map +1 -1
- package/dist/negotiation/recovery/types.d.ts +3 -3
- package/dist/net/request-budget.d.ts +17 -0
- package/dist/net/request-budget.js +63 -0
- package/dist/net/request-budget.js.map +1 -0
- package/dist/operator/controller.d.ts +1 -1
- package/dist/operator/controller.js +23 -12
- package/dist/operator/controller.js.map +1 -1
- package/dist/operator/runner.d.ts +69 -0
- package/dist/operator/runner.js +260 -39
- package/dist/operator/runner.js.map +1 -1
- package/dist/operator/strategy.d.ts +2 -0
- package/dist/operator/strategy.js +11 -0
- package/dist/operator/strategy.js.map +1 -1
- package/dist/privacy/workbench-retention.js +28 -10
- package/dist/privacy/workbench-retention.js.map +1 -1
- package/dist/product-init.js +25 -4
- package/dist/product-init.js.map +1 -1
- package/dist/product-publish.js +3 -102
- package/dist/product-publish.js.map +1 -1
- package/dist/runtime/foreground.d.ts +1 -1
- package/dist/runtime/foreground.js +3 -0
- package/dist/runtime/foreground.js.map +1 -1
- package/dist/runtime/model.js +4 -0
- package/dist/runtime/model.js.map +1 -1
- package/dist/supervisor/manage.js +109 -35
- package/dist/supervisor/manage.js.map +1 -1
- package/dist/trust/identity/jws.js +46 -5
- package/dist/trust/identity/jws.js.map +1 -1
- package/dist/trust/identity/message-signature.js +15 -2
- package/dist/trust/identity/message-signature.js.map +1 -1
- package/dist/trust/records/store.d.ts +8 -1
- package/dist/trust/records/store.js +68 -6
- package/dist/trust/records/store.js.map +1 -1
- package/dist/weixin/channel.d.ts +4 -0
- package/dist/weixin/channel.js +17 -3
- package/dist/weixin/channel.js.map +1 -1
- package/dist/weixin/cli-weixin.js +8 -2
- package/dist/weixin/cli-weixin.js.map +1 -1
- package/package.json +30 -7
- package/scripts/check-install-toolchain.mjs +93 -0
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
* idempotency); the model never touches SQL or tokens.
|
|
20
20
|
*/
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
|
-
import { HandoffIdempotencyStore, HandoffEventStore, createHandoffCandidate,
|
|
22
|
+
import { HandoffIdempotencyStore, HandoffEventStore, createHandoffCandidate, executeHandoff, validateDestination, validateExternalDestinationUrl, } from "../../handoff/index.js";
|
|
23
|
+
import { buildMarketplaceSourceBinding, MarketplaceLaunchPolicyError, parseMarketplaceTradeUrl, sameMarketplaceTarget, } from "../../handoff/launch-marketplace-policy.js";
|
|
24
|
+
import { isUrlDestinationType } from "../../handoff/destination.js";
|
|
25
|
+
import { CatalogSourceError } from "../../discovery/catalog-source/errors.js";
|
|
26
|
+
import { CommerceError } from "../../commerce/data-source.js";
|
|
23
27
|
import { toMinorUnits as losslessToMinorUnits } from "../../protocol/legacy-shopping-negotiation/money.js";
|
|
24
28
|
import { contentDigest } from "../../negotiation/jcs.js";
|
|
25
29
|
import { requireScopeCredential } from "../merchant/credential-broker.js";
|
|
@@ -27,6 +31,7 @@ import { NEGOTIATE_DEAL_PRICE_MINOR, defaultNegotiateDeliveryBefore, NEGOTIATE_S
|
|
|
27
31
|
import { buildNegotiationChatTools, writeGateText } from "../negotiation-chat.js";
|
|
28
32
|
import { routeWriteCandidate } from "../write-gate.js";
|
|
29
33
|
import { runSearchCycle } from "./search-loop.js";
|
|
34
|
+
import { assertTrackingRuleType } from "./task-store.js";
|
|
30
35
|
import { BuyerTaskError } from "./types.js";
|
|
31
36
|
import { uuidv7 } from "@earendil-works/pi-ai";
|
|
32
37
|
function textResult(text, details) {
|
|
@@ -850,6 +855,7 @@ export function buildBuyerTools(deps) {
|
|
|
850
855
|
return textResult(guard.reason);
|
|
851
856
|
try {
|
|
852
857
|
const p = params;
|
|
858
|
+
assertTrackingRuleType(p.rule_type);
|
|
853
859
|
const rule = store.addTrackingRule({
|
|
854
860
|
task_id: String(p.task_id),
|
|
855
861
|
...(typeof p.candidate_id === "string" ? { candidate_id: p.candidate_id } : {}),
|
|
@@ -1191,6 +1197,21 @@ export function buildBuyerTools(deps) {
|
|
|
1191
1197
|
if (!Number.isFinite(expiresInHours) || expiresInHours <= 0) {
|
|
1192
1198
|
return textResult("expires_in_hours 必须是正数(小时)。");
|
|
1193
1199
|
}
|
|
1200
|
+
// ── A651 包四:三平台市场形态 URL 目的地的可信交易来源门(创建期)──
|
|
1201
|
+
// 缺正常来源事实 → 固定 refusal,**不创建可交付候选**(fail-closed)。
|
|
1202
|
+
// listing_id 只取任务 shortlist 线索;权威以 configured CatalogSource
|
|
1203
|
+
// 新鲜重读为准,模型/搜索结果的 source 标签不自证。政策只覆盖三平台
|
|
1204
|
+
//(PACK4 §1):非市场形态 URL 保持原防钓鱼路径,不在此门内。
|
|
1205
|
+
if (isUrlDestinationType(destination.type) && marketplaceTradeRef(destination.ref) !== undefined) {
|
|
1206
|
+
const refusal = await resolveTradeSourceRefusal(deps, {
|
|
1207
|
+
taskId: p.task_id,
|
|
1208
|
+
agreement,
|
|
1209
|
+
destinationRef: destination.ref,
|
|
1210
|
+
nowMs: Date.parse(deps.now()),
|
|
1211
|
+
});
|
|
1212
|
+
if (refusal !== undefined)
|
|
1213
|
+
return textResult(refusal, { status: "needs_configuration" });
|
|
1214
|
+
}
|
|
1194
1215
|
// 审计链:stale 候选之后的新候选链接到被它取代的候选
|
|
1195
1216
|
//(supersedes_candidate_id;此前从不写入,stale 后的新候选是审计孤儿)。
|
|
1196
1217
|
const lastStale = [...handoff.ledger.events(agreement.negotiation_id).map((event) => handoff.ledger.resolvePayload(event))]
|
|
@@ -1217,6 +1238,35 @@ export function buildBuyerTools(deps) {
|
|
|
1217
1238
|
: {}),
|
|
1218
1239
|
requires_user_action: true,
|
|
1219
1240
|
});
|
|
1241
|
+
// ── A651 包四:可信来源 sidecar(批准证据与执行门输入)──────────
|
|
1242
|
+
// 在候选 digest 定型后构造,绑定 task/negotiation/agreement/terms/
|
|
1243
|
+
// candidate 与本次可信读取快照;随批准链持久化,执行期强制重核。
|
|
1244
|
+
// 仅三平台市场形态目的地需要 binding(政策范围)。
|
|
1245
|
+
let launchSourceBinding;
|
|
1246
|
+
if (isUrlDestinationType(destination.type) &&
|
|
1247
|
+
marketplaceTradeRef(destination.ref) !== undefined &&
|
|
1248
|
+
deps.catalogSource !== undefined) {
|
|
1249
|
+
const hintListingId = launchListingHint(deps, p.task_id, agreedTermsSku(agreement.agreed_terms), ownerAgentIdFromIdentity(agreement.merchant_identity_ref));
|
|
1250
|
+
if (hintListingId !== undefined) {
|
|
1251
|
+
try {
|
|
1252
|
+
launchSourceBinding = buildMarketplaceSourceBinding({
|
|
1253
|
+
catalogOrigin: deps.catalogSource.origin,
|
|
1254
|
+
listing: await readTrustedListing(deps, hintListingId),
|
|
1255
|
+
taskId: p.task_id,
|
|
1256
|
+
negotiationId: agreement.negotiation_id,
|
|
1257
|
+
agreementId: agreement.agreement_id,
|
|
1258
|
+
termsDigest: candidate.terms_digest,
|
|
1259
|
+
candidateDigest: candidate.candidate_digest,
|
|
1260
|
+
observedAt: deps.now(),
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
catch {
|
|
1264
|
+
// 第二次读取失败 = 创建与绑定之间来源已不可稳定重读:不进入
|
|
1265
|
+
// 审批链(fail-closed; refusal 语义与创建期门一致)。
|
|
1266
|
+
return textResult("可信交易来源在候选创建后无法稳定重读;未创建可交付候选,可稍后重试。", { status: "needs_configuration" });
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1220
1270
|
const outcome = await routeWriteCandidate({
|
|
1221
1271
|
mode: deps.mode,
|
|
1222
1272
|
approvals: deps.approvals,
|
|
@@ -1226,7 +1276,11 @@ export function buildBuyerTools(deps) {
|
|
|
1226
1276
|
}, {
|
|
1227
1277
|
tool: "handoff_agreement",
|
|
1228
1278
|
task_id: p.task_id,
|
|
1229
|
-
arguments: {
|
|
1279
|
+
arguments: {
|
|
1280
|
+
task_id: p.task_id,
|
|
1281
|
+
candidate,
|
|
1282
|
+
...(launchSourceBinding !== undefined ? { launch_source_binding: launchSourceBinding } : {}),
|
|
1283
|
+
},
|
|
1230
1284
|
preconditions: { agreement_bound: true },
|
|
1231
1285
|
risk: "handoff_delivery",
|
|
1232
1286
|
execute: (approvedArgs) => executeHandoffForCandidate(deps, approvedArgs),
|
|
@@ -1351,6 +1405,11 @@ export function buildBuyerTools(deps) {
|
|
|
1351
1405
|
additionalProperties: false,
|
|
1352
1406
|
},
|
|
1353
1407
|
execute: async (_id, params) => {
|
|
1408
|
+
// review 2-22:manual 模式下 shortlist(写入候选 + 改状态 + 落事件)
|
|
1409
|
+
// 与其他写工具同受「manual 只建议」守卫——此前是唯一绕过 §16 的写路径。
|
|
1410
|
+
const guard = manualAdvice(deps.mode);
|
|
1411
|
+
if (!guard.ok)
|
|
1412
|
+
return textResult(guard.reason);
|
|
1354
1413
|
try {
|
|
1355
1414
|
const p = params;
|
|
1356
1415
|
const task = store.getTask(p.task_id);
|
|
@@ -1412,7 +1471,36 @@ export function buildBuyerTools(deps) {
|
|
|
1412
1471
|
...(catalogFirst ? [searchListings, shortlistListing] : []),
|
|
1413
1472
|
...(deps.handoff !== undefined ? [handoffAgreement] : []),
|
|
1414
1473
|
...(catalogFirst ? [] : negotiationTools),
|
|
1415
|
-
]
|
|
1474
|
+
].map((tool) => {
|
|
1475
|
+
if (!["update_buyer_task_constraints", "add_tracking_rule", "shortlist_listing"].includes(tool.name))
|
|
1476
|
+
return tool;
|
|
1477
|
+
const execute = tool.execute.bind(tool);
|
|
1478
|
+
return { ...tool, execute: async (callId, params, onUpdate) => {
|
|
1479
|
+
const guard = manualAdvice(deps.mode);
|
|
1480
|
+
if (!guard.ok)
|
|
1481
|
+
return textResult(guard.reason);
|
|
1482
|
+
try {
|
|
1483
|
+
// Invalid rule types are rejected before claiming an operation or writing events.
|
|
1484
|
+
if (tool.name === "add_tracking_rule")
|
|
1485
|
+
assertTrackingRuleType(params.rule_type);
|
|
1486
|
+
const taskId = String(params.task_id ?? "");
|
|
1487
|
+
const call = store.beginToolCall(taskId, callId, tool.name, params);
|
|
1488
|
+
if (call.kind === "replay")
|
|
1489
|
+
return call.result;
|
|
1490
|
+
const output = await execute(callId, params, onUpdate);
|
|
1491
|
+
// Error messages may embed caller/private values. Persist only a fixed
|
|
1492
|
+
// diagnostic, and return exactly that same safe result on first/replay.
|
|
1493
|
+
const failed = output.content.some((part) => part.type === "text" &&
|
|
1494
|
+
(part.text.startsWith("任务操作被拒绝") || part.text.startsWith("任务操作失败")));
|
|
1495
|
+
const result = failed ? textResult("任务操作被拒绝,请核对参数后使用新的工具调用重试。") : output;
|
|
1496
|
+
store.finishToolCall(taskId, call.key, result);
|
|
1497
|
+
return result;
|
|
1498
|
+
}
|
|
1499
|
+
catch (err) {
|
|
1500
|
+
return textResult(errorText(err));
|
|
1501
|
+
}
|
|
1502
|
+
} };
|
|
1503
|
+
});
|
|
1416
1504
|
}
|
|
1417
1505
|
// ── v0.7.0 KTH:handoff_agreement ───────────────────────────────────────────
|
|
1418
1506
|
/**
|
|
@@ -1447,6 +1535,169 @@ function declaredHandoffHost(agreement, candidate) {
|
|
|
1447
1535
|
return undefined;
|
|
1448
1536
|
}
|
|
1449
1537
|
}
|
|
1538
|
+
/**
|
|
1539
|
+
* A651 包四:可信交易来源接线(launch-marketplace-policy 的 buyer 侧宿主依赖)。
|
|
1540
|
+
*
|
|
1541
|
+
* 职责边界(PACK4-READONLY-PLAN §2/§3/§5):
|
|
1542
|
+
* - listing_id 只作选择线索(任务 shortlist 候选行);权威事实以 configured
|
|
1543
|
+
* CatalogSource.getListing **新鲜重读**为准;模型 shortlist 的 source 标签、
|
|
1544
|
+
* URL、verified:true 一律不自证。
|
|
1545
|
+
* - sidecar(MarketplaceSourceBinding)由可信读取形成,绑定任务/磋商/协议/
|
|
1546
|
+
* 条款/候选 digest,随批准链持久化;执行期 executeHandoff 强制门以新鲜
|
|
1547
|
+
* 重读逐项重核——来源变更 → stale(原审批流程新确认),无证据 →
|
|
1548
|
+
* needs_configuration(不交付)。
|
|
1549
|
+
* - 证明边界:仅证明「本次正常 Catalog 声明的 SKU 对应协议交付一致的目的地
|
|
1550
|
+
* URI/平台ID」,不是平台商品真值/价格/库存/下单/支付/预留。
|
|
1551
|
+
*/
|
|
1552
|
+
/** agreement 首行 SKU(当前协议实际接受商品;无单一行 → undefined)。 */
|
|
1553
|
+
function agreedTermsSku(agreed_terms) {
|
|
1554
|
+
const items = agreed_terms?.items;
|
|
1555
|
+
if (!Array.isArray(items) || items.length !== 1)
|
|
1556
|
+
return undefined;
|
|
1557
|
+
const sku = items[0]?.sku;
|
|
1558
|
+
return typeof sku === "string" && sku !== "" ? sku : undefined;
|
|
1559
|
+
}
|
|
1560
|
+
/** merchant:{catalogAgentId} 形态的协议归属 → catalog owner agent id。 */
|
|
1561
|
+
function ownerAgentIdFromIdentity(identityRef) {
|
|
1562
|
+
const prefix = "merchant:";
|
|
1563
|
+
return identityRef.startsWith(prefix) && identityRef.length > prefix.length
|
|
1564
|
+
? identityRef.slice(prefix.length)
|
|
1565
|
+
: undefined;
|
|
1566
|
+
}
|
|
1567
|
+
/** ListingRecord → 受控快照投影(结构满足 MarketplaceListingSnapshot;不携带
|
|
1568
|
+
* cost/floor/私有库存等未列字段)。 */
|
|
1569
|
+
function listingSnapshot(listing) {
|
|
1570
|
+
return {
|
|
1571
|
+
listing_id: listing.listing_id,
|
|
1572
|
+
listing_type: listing.listing_type,
|
|
1573
|
+
owner_agent_id: listing.owner_agent_id,
|
|
1574
|
+
merchant_id: listing.merchant_id,
|
|
1575
|
+
...(listing.source_product_ref !== undefined ? { source_product_ref: listing.source_product_ref } : {}),
|
|
1576
|
+
...(listing.source_revision !== undefined ? { source_revision: listing.source_revision } : {}),
|
|
1577
|
+
...(listing.handoff_destination_ref !== undefined ? { handoff_destination_ref: listing.handoff_destination_ref } : {}),
|
|
1578
|
+
listing_digest: listing.listing_digest,
|
|
1579
|
+
publication_state: listing.publication_state,
|
|
1580
|
+
listing_freshness_state: listing.listing_freshness_state,
|
|
1581
|
+
fresh_until: listing.fresh_until,
|
|
1582
|
+
updated_at: listing.updated_at,
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
/** 批准链上带回的 sidecar 形状检查(不合法 = 无证据 → needs_configuration)。 */
|
|
1586
|
+
function extractSourceBinding(value) {
|
|
1587
|
+
if (typeof value !== "object" || value === null)
|
|
1588
|
+
return undefined;
|
|
1589
|
+
const b = value;
|
|
1590
|
+
if (b.binding_version !== "marketplace_source_binding/1")
|
|
1591
|
+
return undefined;
|
|
1592
|
+
if (typeof b.listing_id !== "string" || b.listing_id === "")
|
|
1593
|
+
return undefined;
|
|
1594
|
+
return value;
|
|
1595
|
+
}
|
|
1596
|
+
/** 三平台市场形态判定(吞掉分类错误;非市场形态 → undefined,保持原路径)。 */
|
|
1597
|
+
function marketplaceTradeRef(ref) {
|
|
1598
|
+
try {
|
|
1599
|
+
return parseMarketplaceTradeUrl(ref);
|
|
1600
|
+
}
|
|
1601
|
+
catch {
|
|
1602
|
+
return undefined;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* listing_id 选择线索(PACK4 §2:只作线索,权威以重读为准):优先与协议
|
|
1607
|
+
* SKU/商家归属一致的 shortlist 候选行,避免误拿无关连接器候选。
|
|
1608
|
+
*/
|
|
1609
|
+
function launchListingHint(deps, taskId, agreedSku, ownerAgentId) {
|
|
1610
|
+
const rows = deps.store
|
|
1611
|
+
.listCandidates(taskId)
|
|
1612
|
+
.filter((c) => c.external_product_id !== "");
|
|
1613
|
+
const matched = (agreedSku !== undefined ? rows.find((c) => c.sku === agreedSku) : undefined) ??
|
|
1614
|
+
(ownerAgentId !== undefined ? rows.find((c) => c.owner_agent_id === ownerAgentId) : undefined) ??
|
|
1615
|
+
rows[0];
|
|
1616
|
+
const hint = matched?.external_product_id;
|
|
1617
|
+
return hint !== undefined && hint !== "" ? hint : undefined;
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* CatalogSource 读取的瞬时/硬失败翻译:request_failed/request_timeout →
|
|
1621
|
+
* CommerceError("request_failed")(执行门按 probe_failed 可重试);其余原样
|
|
1622
|
+
* 传播(执行门按 needs_configuration 固定拒绝)。
|
|
1623
|
+
*/
|
|
1624
|
+
async function readTrustedListing(deps, listingId) {
|
|
1625
|
+
const catalogSource = deps.catalogSource;
|
|
1626
|
+
if (catalogSource === undefined) {
|
|
1627
|
+
throw new CommerceError("invalid_input", "kiwi-catalog listing source is not configured");
|
|
1628
|
+
}
|
|
1629
|
+
try {
|
|
1630
|
+
return listingSnapshot(await catalogSource.getListing(listingId));
|
|
1631
|
+
}
|
|
1632
|
+
catch (err) {
|
|
1633
|
+
if (err instanceof CatalogSourceError && (err.code === "request_failed" || err.code === "request_timeout")) {
|
|
1634
|
+
throw new CommerceError("request_failed", "trade source re-read temporarily unavailable");
|
|
1635
|
+
}
|
|
1636
|
+
throw err;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* 创建期可信来源解析与协议一致性核验。返回固定 refusal 文案(undefined =
|
|
1641
|
+
* 来源事实成立);调用方据此**不创建**可交付候选(经理裁定 2026-10-13)。
|
|
1642
|
+
*/
|
|
1643
|
+
async function resolveTradeSourceRefusal(deps, input) {
|
|
1644
|
+
const catalogSource = deps.catalogSource;
|
|
1645
|
+
if (catalogSource === undefined) {
|
|
1646
|
+
return "URL 交易目的地需要可信 catalog 来源验证(needs_configuration/unverified):当前环境未配置 kiwi-catalog listing 源,不创建交接候选。";
|
|
1647
|
+
}
|
|
1648
|
+
const sku = agreedTermsSku(input.agreement.agreed_terms);
|
|
1649
|
+
if (sku === undefined) {
|
|
1650
|
+
return "协议条款缺少单一商品 SKU,无法绑定可信交易来源(needs_configuration);不创建交接候选。";
|
|
1651
|
+
}
|
|
1652
|
+
const ownerAgentId = ownerAgentIdFromIdentity(input.agreement.merchant_identity_ref);
|
|
1653
|
+
if (ownerAgentId === undefined) {
|
|
1654
|
+
return "协议商家归属无法映射到 catalog owner(needs_configuration);不创建交接候选。";
|
|
1655
|
+
}
|
|
1656
|
+
// listing_id 只是选择线索;权威以重读为准。
|
|
1657
|
+
const hint = launchListingHint(deps, input.taskId, sku, ownerAgentId);
|
|
1658
|
+
if (hint === undefined) {
|
|
1659
|
+
return "任务没有 shortlist listing 线索,无法定位可信交易来源(needs_configuration);不创建交接候选。";
|
|
1660
|
+
}
|
|
1661
|
+
let listing;
|
|
1662
|
+
try {
|
|
1663
|
+
listing = await readTrustedListing(deps, hint);
|
|
1664
|
+
}
|
|
1665
|
+
catch (err) {
|
|
1666
|
+
if (err instanceof CommerceError && err.code === "request_failed") {
|
|
1667
|
+
return "可信交易来源暂时不可读(catalog 暂不可达);未创建交接候选,可稍后重试。";
|
|
1668
|
+
}
|
|
1669
|
+
return "可信交易来源读取失败(listing 不存在或响应不合法);不创建交接候选。";
|
|
1670
|
+
}
|
|
1671
|
+
// 权威事实 vs 协议声明——逐项精确匹配;模型线索不一致即拒。
|
|
1672
|
+
if (listing.listing_type !== "product" || listing.publication_state !== "ACTIVE" || listing.listing_freshness_state !== "FRESH") {
|
|
1673
|
+
return "可信交易来源不是 ACTIVE/FRESH 的 product listing;不创建交接候选。";
|
|
1674
|
+
}
|
|
1675
|
+
const freshUntilMs = Date.parse(listing.fresh_until);
|
|
1676
|
+
if (!Number.isFinite(freshUntilMs) || freshUntilMs <= input.nowMs) {
|
|
1677
|
+
return "可信交易来源新鲜度已过(fresh_until);不创建交接候选。";
|
|
1678
|
+
}
|
|
1679
|
+
if (listing.source_product_ref !== sku) {
|
|
1680
|
+
return "可信交易来源 SKU 与协议接受商品不一致;不创建交接候选。";
|
|
1681
|
+
}
|
|
1682
|
+
if (listing.owner_agent_id !== ownerAgentId) {
|
|
1683
|
+
return "可信交易来源 owner 与协议商家归属不一致;不创建交接候选。";
|
|
1684
|
+
}
|
|
1685
|
+
if (listing.handoff_destination_ref !== input.destinationRef) {
|
|
1686
|
+
return "可信交易来源声明的成交入口与协议目的地不一致;不创建交接候选。";
|
|
1687
|
+
}
|
|
1688
|
+
// URL 交易目的地必须是三平台确切形态(P4 校准:不做自有域 fallback)——
|
|
1689
|
+
// binding 只为可平台绑定的市场入口形成;错误 ID/额外 query/混淆形态在此拒。
|
|
1690
|
+
try {
|
|
1691
|
+
parseMarketplaceTradeUrl(input.destinationRef);
|
|
1692
|
+
}
|
|
1693
|
+
catch (err) {
|
|
1694
|
+
if (err instanceof MarketplaceLaunchPolicyError) {
|
|
1695
|
+
return "协议目的地不是受支持平台的确切交易形态(jd/taobao/tmall);不创建交接候选。";
|
|
1696
|
+
}
|
|
1697
|
+
return "协议目的地不是合法 https URL;不创建交接候选。";
|
|
1698
|
+
}
|
|
1699
|
+
return undefined;
|
|
1700
|
+
}
|
|
1450
1701
|
function agreementFromTask(events) {
|
|
1451
1702
|
let merchantDomain;
|
|
1452
1703
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
@@ -1515,6 +1766,10 @@ function handoffResultText(result) {
|
|
|
1515
1766
|
return textResult(`交接未执行:${result.reason}。`, { status: "rejected" });
|
|
1516
1767
|
case "expired":
|
|
1517
1768
|
return textResult(`交接未执行:候选已过期。`, { status: "expired" });
|
|
1769
|
+
case "needs_configuration":
|
|
1770
|
+
// A651 包四强制门:市场形态 URL 目的地缺可信交易来源上下文——固定
|
|
1771
|
+
// 拒绝、不交付;候选生命周期未动,补齐来源后可重试。
|
|
1772
|
+
return textResult(`交接未执行:${result.reason}。`, { status: "needs_configuration" });
|
|
1518
1773
|
}
|
|
1519
1774
|
}
|
|
1520
1775
|
/** 批准后的实际执行:agreementReader 从任务事件重读(§10 revalidation)。 */
|
|
@@ -1532,6 +1787,32 @@ async function executeHandoffForCandidate(deps, args) {
|
|
|
1532
1787
|
error: "任务记录缺少 agreement 快照,交接中止(fail-closed)",
|
|
1533
1788
|
};
|
|
1534
1789
|
}
|
|
1790
|
+
// ── A651 包四:三平台市场形态 URL 目的地的强制交易门输入 ─────────────
|
|
1791
|
+
// 审批链带回的 sidecar + 执行期 configured CatalogSource 新鲜重读;市场
|
|
1792
|
+
// 形态目的地无 sidecar(或不配置来源)→ executeHandoff 固定
|
|
1793
|
+
// needs_configuration,旧授权不迁移。readSource 是 normal host 依赖,不
|
|
1794
|
+
// 暴露给模型参数。非市场形态 URL 保持原防钓鱼路径(不走本门)。
|
|
1795
|
+
let launchContext;
|
|
1796
|
+
if (isUrlDestinationType(a.candidate.destination_type) && marketplaceTradeRef(a.candidate.destination_ref) !== undefined) {
|
|
1797
|
+
const binding = extractSourceBinding(a.launch_source_binding);
|
|
1798
|
+
if (binding === undefined || deps.catalogSource === undefined) {
|
|
1799
|
+
return {
|
|
1800
|
+
ok: false,
|
|
1801
|
+
status: "needs_configuration",
|
|
1802
|
+
error: "URL 交易目的地缺可信交易来源上下文(needs_configuration/unverified):不交付。",
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1805
|
+
const catalogSource = deps.catalogSource;
|
|
1806
|
+
const bindingListingId = binding.listing_id;
|
|
1807
|
+
launchContext = {
|
|
1808
|
+
binding,
|
|
1809
|
+
catalogOrigin: catalogSource.origin,
|
|
1810
|
+
taskId: a.task_id,
|
|
1811
|
+
agreedSku: agreedTermsSku(agreement.agreed_terms) ?? "",
|
|
1812
|
+
ownerAgentId: ownerAgentIdFromIdentity(agreement.merchant_identity_ref) ?? "",
|
|
1813
|
+
readSource: () => readTrustedListing(deps, bindingListingId),
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1535
1816
|
// created 事件在审批通过后才落链:被 /reject 的候选不在 Ledger 留下悬空的
|
|
1536
1817
|
// PROPOSED(此前先落链,/reject 后 /handoff 永远显示"从未获批"的候选,
|
|
1537
1818
|
// 且 LLM 重复调用会堆积无限候选事件与审批候选)。
|
|
@@ -1550,6 +1831,22 @@ async function executeHandoffForCandidate(deps, args) {
|
|
|
1550
1831
|
// 放行该外部主机(如 item.jd.com);LLM 现编的 destination_ref 仍限制在
|
|
1551
1832
|
// merchant 声明域(anti-phishing)。
|
|
1552
1833
|
const declaredHost = declaredHandoffHost(agreement, a.candidate);
|
|
1834
|
+
// A651 包四:三平台绑定时**每一跳**(首跳 + 全部重定向)强制「同平台同
|
|
1835
|
+
// opaque 商品 ID」——declaredHost OR 白名单只能证 host,不能证商品身份;
|
|
1836
|
+
// onHop 在既有 scheme/host/SSRF 守卫之后调用,只能抛错收紧,不能放行。
|
|
1837
|
+
const launchBinding = launchContext !== undefined ? extractSourceBinding(launchContext.binding) : undefined;
|
|
1838
|
+
const launchTarget = (() => {
|
|
1839
|
+
if (launchBinding === undefined)
|
|
1840
|
+
return undefined;
|
|
1841
|
+
try {
|
|
1842
|
+
return parseMarketplaceTradeUrl(a.candidate.destination_ref);
|
|
1843
|
+
}
|
|
1844
|
+
catch {
|
|
1845
|
+
// 正常接线不可达(binding 恒为三平台形态,verify 门先拒 ref 不等);
|
|
1846
|
+
// 防御:手造状态只落到 host 门,不放松 verify 强制门。
|
|
1847
|
+
return undefined;
|
|
1848
|
+
}
|
|
1849
|
+
})();
|
|
1553
1850
|
const result = await executeHandoff({
|
|
1554
1851
|
candidate: a.candidate,
|
|
1555
1852
|
ledger: handoff.ledger,
|
|
@@ -1569,7 +1866,28 @@ async function executeHandoffForCandidate(deps, args) {
|
|
|
1569
1866
|
negotiation_id: agreement.negotiation_id,
|
|
1570
1867
|
agreed_terms: agreement.agreed_terms,
|
|
1571
1868
|
}),
|
|
1572
|
-
urlSafety:
|
|
1869
|
+
urlSafety: (url) => validateExternalDestinationUrl(url, {
|
|
1870
|
+
...(agreement.merchant_domain !== undefined ? { expectedHost: agreement.merchant_domain } : {}),
|
|
1871
|
+
...(declaredHost !== undefined ? { allowlist: [declaredHost] } : {}),
|
|
1872
|
+
allowHttp: false,
|
|
1873
|
+
...(launchTarget !== undefined
|
|
1874
|
+
? {
|
|
1875
|
+
onHop: (hopUrl) => {
|
|
1876
|
+
let parsed;
|
|
1877
|
+
try {
|
|
1878
|
+
parsed = parseMarketplaceTradeUrl(hopUrl);
|
|
1879
|
+
}
|
|
1880
|
+
catch {
|
|
1881
|
+
throw new CommerceError("invalid_input", "destination hop left the marketplace trade form (same platform, same product id required)");
|
|
1882
|
+
}
|
|
1883
|
+
if (!sameMarketplaceTarget(parsed, launchTarget)) {
|
|
1884
|
+
throw new CommerceError("invalid_input", "destination redirect changed platform product identity");
|
|
1885
|
+
}
|
|
1886
|
+
},
|
|
1887
|
+
}
|
|
1888
|
+
: {}),
|
|
1889
|
+
}),
|
|
1890
|
+
...(launchContext !== undefined ? { launchContext } : {}),
|
|
1573
1891
|
now: deps.now,
|
|
1574
1892
|
});
|
|
1575
1893
|
const rendered = handoffResultText(result);
|