@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
|
@@ -48,15 +48,31 @@
|
|
|
48
48
|
* 持久化仍是 0600 `merchant-enrollments.json` 原子写;任何失败路径只改
|
|
49
49
|
* 目标会话的格,不删除其他会话。
|
|
50
50
|
*/
|
|
51
|
-
import { createHash } from "node:crypto";
|
|
51
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
52
52
|
import { isIP } from "node:net";
|
|
53
53
|
import { loadOrCreateA2aSigningIdentity, toJwsSigningIdentity } from "../a2a/signing-key.js";
|
|
54
|
+
import { withEnrollmentStoreLock, reserveEnrollmentCreation } from "./binding/store-lock.js";
|
|
54
55
|
import { writeFileAtomic } from "../fs/atomic-write.js";
|
|
56
|
+
import { ProductTableError } from "./product-source.js";
|
|
55
57
|
import { canonicalize } from "../negotiation/jcs.js";
|
|
56
58
|
import { validateAgentCard } from "../discovery/agent-card/validate.js";
|
|
57
59
|
import { isRedirectResponse, readJsonBody } from "../net/safe-http.js";
|
|
58
60
|
import { CatalogClient, CatalogClientError, normalizeOrigin, runtimePublicKey, } from "./catalog-client.js";
|
|
59
|
-
import { enrollmentStorePath, readEnrollmentStore, } from "./binding/enrollment-challenge.js";
|
|
61
|
+
import { enrollmentStorePath, readEnrollmentStore as readEnrollmentStoreRaw, } from "./binding/enrollment-challenge.js";
|
|
62
|
+
const observedSession = Symbol("connect-observed-session");
|
|
63
|
+
const sessionDigest = (item) => createHash("sha256")
|
|
64
|
+
.update(canonicalize(JSON.parse(JSON.stringify(item))))
|
|
65
|
+
.digest("hex");
|
|
66
|
+
function readEnrollmentStore(dataDir) {
|
|
67
|
+
const store = readEnrollmentStoreRaw(dataDir);
|
|
68
|
+
for (const item of store.sessions)
|
|
69
|
+
Object.defineProperty(item, observedSession, {
|
|
70
|
+
value: sessionDigest(item),
|
|
71
|
+
enumerable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
});
|
|
74
|
+
return store;
|
|
75
|
+
}
|
|
60
76
|
export class MerchantConnectError extends Error {
|
|
61
77
|
code;
|
|
62
78
|
constructor(code, message) {
|
|
@@ -71,17 +87,33 @@ export class MerchantConnectError extends Error {
|
|
|
71
87
|
* 白名单(CATALOG_CONNECTION_SAFE_CODES)以此单源扩展。
|
|
72
88
|
*/
|
|
73
89
|
export const CONNECTION_PAIRING_SAFE_CODES = new Set([
|
|
90
|
+
"PAIRING_DENIED",
|
|
91
|
+
"PUBLICATION_CHECK_FAILED",
|
|
92
|
+
"PRODUCT_TABLE_INVALID",
|
|
74
93
|
"PAIRING_WINDOW_EXPIRED", // 授权窗口(=Catalog grant 窗口)已过:需重新配对
|
|
75
94
|
"BIND_REJECTED", // Catalog 拒绝 bind 请求(grant 过期/不匹配/版本冲突)
|
|
76
95
|
"BIND_CLAIM_INVALID", // bind 已到达但签名声明未通过本地验真
|
|
77
96
|
"CARD_PUBLISH_REJECTED", // 名片发布/激活被 Catalog 拒绝
|
|
78
97
|
"CARD_PUBLISH_INVALID", // 发布/激活回执不完整或不合法
|
|
79
98
|
"PAIRING_COMMUNICATION_FAILED", // 与 Catalog 通信失败(网络/5xx,可重试)
|
|
99
|
+
"RUNTIME_UNREACHABLE",
|
|
100
|
+
"RUNTIME_NOT_READY",
|
|
101
|
+
"RUNTIME_IDENTITY_MISMATCH",
|
|
102
|
+
"CATALOG_RUNTIME_NOT_READY",
|
|
103
|
+
"STATE_CAS_CONFLICT",
|
|
104
|
+
"CONNECTION_OPERATION_PENDING",
|
|
105
|
+
"CONNECTION_OPERATION_UNKNOWN",
|
|
80
106
|
"CONNECT_STEP_FAILED", // 兜底:未归类步骤失败
|
|
81
|
-
"AUTHORIZED_MATERIAL_MISMATCH",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
107
|
+
"AUTHORIZED_MATERIAL_MISMATCH",
|
|
108
|
+
"GRANT_SCOPE_INVALID",
|
|
109
|
+
"STATE_INVALID",
|
|
110
|
+
"BINDING_KEY_MISMATCH",
|
|
111
|
+
"BINDING_CLAIM_INVALID",
|
|
112
|
+
"PREVIEW_CHANGED",
|
|
113
|
+
"PUBLICATION_RECEIPT_INVALID",
|
|
114
|
+
"ACTIVATION_RECEIPT_INVALID",
|
|
115
|
+
"BIND_CLAIM_CARD_URL_MISMATCH",
|
|
116
|
+
"BIND_CLAIM_FIELD_MISMATCH",
|
|
85
117
|
]);
|
|
86
118
|
/**
|
|
87
119
|
* 公网入口 host 白名单口径(CLI parsePublicOrigin 与服务构造器共用,
|
|
@@ -92,14 +124,31 @@ export function isPublicHostAllowed(hostname) {
|
|
|
92
124
|
const host = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
93
125
|
const ip = isIP(host);
|
|
94
126
|
const octets = ip === 4 ? host.split(".").map(Number) : [];
|
|
95
|
-
const privateIpv4 = ip === 4 &&
|
|
96
|
-
octets[0] ===
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
127
|
+
const privateIpv4 = ip === 4 &&
|
|
128
|
+
(octets[0] === 0 ||
|
|
129
|
+
octets[0] === 10 ||
|
|
130
|
+
octets[0] === 127 ||
|
|
131
|
+
(octets[0] === 169 && octets[1] === 254) ||
|
|
132
|
+
(octets[0] === 192 && octets[1] === 168) ||
|
|
133
|
+
(octets[0] === 172 && (octets[1] ?? 0) >= 16 && (octets[1] ?? 0) <= 31) ||
|
|
134
|
+
(octets[0] === 100 && (octets[1] ?? 0) >= 64 && (octets[1] ?? 0) <= 127) ||
|
|
135
|
+
(octets[0] ?? 0) >= 224);
|
|
136
|
+
const privateIpv6 = ip === 6 &&
|
|
137
|
+
(host === "::" ||
|
|
138
|
+
host === "::1" ||
|
|
139
|
+
host.startsWith("fc") ||
|
|
140
|
+
host.startsWith("fd") ||
|
|
141
|
+
host.startsWith("fe80:") ||
|
|
142
|
+
host.startsWith("::ffff:"));
|
|
143
|
+
return (host !== "localhost" &&
|
|
144
|
+
!host.endsWith(".localhost") &&
|
|
145
|
+
!host.endsWith(".local") &&
|
|
146
|
+
!host.endsWith(".internal") &&
|
|
147
|
+
!host.endsWith(".lan") &&
|
|
148
|
+
!host.endsWith(".home") &&
|
|
149
|
+
host.includes(".") &&
|
|
150
|
+
!privateIpv4 &&
|
|
151
|
+
!privateIpv6);
|
|
103
152
|
}
|
|
104
153
|
/**
|
|
105
154
|
* 纯 resume 选择:只有同 origin + 同公钥指纹 + 可续状态 + 未过期才复用。
|
|
@@ -112,7 +161,8 @@ export function isPublicHostAllowed(hostname) {
|
|
|
112
161
|
export function selectReusableEnrollment(sessions, input) {
|
|
113
162
|
return sessions.find((session) => {
|
|
114
163
|
const state = session;
|
|
115
|
-
if (state.runtime_origin !== input.runtimeOrigin ||
|
|
164
|
+
if (state.runtime_origin !== input.runtimeOrigin ||
|
|
165
|
+
state.key_thumbprint !== input.keyThumbprint)
|
|
116
166
|
return false;
|
|
117
167
|
if (!["preparing", "authorized", "bound", "published"].includes(state.status))
|
|
118
168
|
return false;
|
|
@@ -133,7 +183,9 @@ export function priorPublishedCatalogAgentId(sessions) {
|
|
|
133
183
|
return ids.values().next().value;
|
|
134
184
|
}
|
|
135
185
|
function cardDigest(card) {
|
|
136
|
-
return `sha256:${createHash("sha256")
|
|
186
|
+
return `sha256:${createHash("sha256")
|
|
187
|
+
.update(canonicalize(card), "utf8")
|
|
188
|
+
.digest("hex")}`;
|
|
137
189
|
}
|
|
138
190
|
/** 缺省公开卡加载:与 CLI verifyPublicRuntimeReady 同口径(匿名读 + 签名声明核对)。 */
|
|
139
191
|
async function fetchPublicCard(origin, expectedEndpoint, identity, fetchImpl) {
|
|
@@ -141,20 +193,28 @@ async function fetchPublicCard(origin, expectedEndpoint, identity, fetchImpl) {
|
|
|
141
193
|
const timer = setTimeout(() => controller.abort(), 8_000);
|
|
142
194
|
const url = `${origin}/.well-known/agent-card.json`;
|
|
143
195
|
try {
|
|
144
|
-
const response = await fetchImpl(url, {
|
|
196
|
+
const response = await fetchImpl(url, {
|
|
197
|
+
method: "GET",
|
|
198
|
+
redirect: "manual",
|
|
199
|
+
signal: controller.signal,
|
|
200
|
+
headers: { accept: "application/json" },
|
|
201
|
+
});
|
|
145
202
|
if (isRedirectResponse(response) || !response.ok) {
|
|
146
203
|
throw new MerchantConnectError("RUNTIME_UNREACHABLE", `暂时无法从外部读取商家服务的 Agent Card(HTTP ${response.status})。请确认服务已启动且公网入口可访问,然后重新运行 kiwi merchant connect。`);
|
|
147
204
|
}
|
|
148
205
|
const card = validateAgentCard(await readJsonBody(response, { signal: controller.signal }));
|
|
149
206
|
const urls = card.supportedInterfaces.map((entry) => entry.url);
|
|
150
|
-
if (typeof card.url !== "string" ||
|
|
207
|
+
if (typeof card.url !== "string" ||
|
|
208
|
+
new URL(card.url).origin !== origin ||
|
|
209
|
+
!urls.includes(expectedEndpoint)) {
|
|
151
210
|
throw new MerchantConnectError("RUNTIME_NOT_READY", "公网入口返回的 Agent Card 与当前 Runtime 地址不一致;未发布名片。请检查反向代理与服务配置后重试。");
|
|
152
211
|
}
|
|
153
212
|
const signatureScheme = card.securitySchemes?.["kiwi-signature"];
|
|
154
|
-
if (signatureScheme !== undefined &&
|
|
155
|
-
signatureScheme.
|
|
156
|
-
|
|
157
|
-
|
|
213
|
+
if (signatureScheme !== undefined &&
|
|
214
|
+
(signatureScheme.type !== "kiwi-http-message-signature" ||
|
|
215
|
+
signatureScheme.keyid !== identity.keyid ||
|
|
216
|
+
signatureScheme.publicKeyPem !== identity.publicKeyPem ||
|
|
217
|
+
signatureScheme.algorithm !== "ed25519")) {
|
|
158
218
|
throw new MerchantConnectError("RUNTIME_IDENTITY_MISMATCH", "公网服务的 A2A 签名声明与当前 Runtime 持久密钥不一致;未发布名片。请在实际承接请求的 Runtime 主机上运行连接命令。");
|
|
159
219
|
}
|
|
160
220
|
return card;
|
|
@@ -197,7 +257,9 @@ class ConnectionServiceImpl {
|
|
|
197
257
|
this.dataDir = options.dataDir;
|
|
198
258
|
this.generation = options.generation ?? 1;
|
|
199
259
|
this.serviceEpoch = options.serviceEpoch ?? 1;
|
|
200
|
-
const trimmed = String(options.publicOrigin ?? "")
|
|
260
|
+
const trimmed = String(options.publicOrigin ?? "")
|
|
261
|
+
.trim()
|
|
262
|
+
.replace(/\/+$/, "");
|
|
201
263
|
let parsed;
|
|
202
264
|
try {
|
|
203
265
|
parsed = new URL(trimmed);
|
|
@@ -205,8 +267,12 @@ class ConnectionServiceImpl {
|
|
|
205
267
|
catch {
|
|
206
268
|
throw new MerchantConnectError("PUBLIC_ORIGIN_INVALID", "公网入口不是合法 URL;请设置 KIWI_A2A_PUBLIC_URL=https://你的域名");
|
|
207
269
|
}
|
|
208
|
-
if (parsed.protocol !== "https:" ||
|
|
209
|
-
parsed.
|
|
270
|
+
if (parsed.protocol !== "https:" ||
|
|
271
|
+
parsed.username !== "" ||
|
|
272
|
+
parsed.password !== "" ||
|
|
273
|
+
parsed.search !== "" ||
|
|
274
|
+
parsed.hash !== "" ||
|
|
275
|
+
(parsed.pathname !== "/" && parsed.pathname !== "")) {
|
|
210
276
|
throw new MerchantConnectError("PUBLIC_ORIGIN_INVALID", "公网入口不是合法 URL;请设置 KIWI_A2A_PUBLIC_URL=https://你的域名");
|
|
211
277
|
}
|
|
212
278
|
// 与 CLI parsePublicOrigin 同一白名单口径:生产构造必须提供公网可达 host;
|
|
@@ -216,17 +282,25 @@ class ConnectionServiceImpl {
|
|
|
216
282
|
}
|
|
217
283
|
this.origin = normalizeOrigin(trimmed);
|
|
218
284
|
this.a2aEndpoint = `${this.origin}/a2a`;
|
|
219
|
-
this.client = new CatalogClient({
|
|
285
|
+
this.client = new CatalogClient({
|
|
286
|
+
baseUrl: options.catalogUrl,
|
|
287
|
+
...(options.now !== undefined ? { now: options.now } : {}),
|
|
288
|
+
...(options.fetchImpl !== undefined ? { fetchImpl: options.fetchImpl } : {}),
|
|
289
|
+
});
|
|
220
290
|
this.identityRaw = loadOrCreateA2aSigningIdentity(this.dataDir, this.origin);
|
|
221
|
-
this.identity = {
|
|
291
|
+
this.identity = {
|
|
292
|
+
signingIdentity: toJwsSigningIdentity(this.identityRaw),
|
|
293
|
+
keyId: this.identityRaw.keyid,
|
|
294
|
+
};
|
|
222
295
|
this.keyThumbprint = runtimePublicKey(this.identity).keyThumbprint;
|
|
223
296
|
this.now = options.now ?? (() => new Date());
|
|
224
297
|
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
225
|
-
this.loadPublicCard =
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
298
|
+
this.loadPublicCard =
|
|
299
|
+
options.loadPublicCard ??
|
|
300
|
+
(async () => await fetchPublicCard(this.origin, this.a2aEndpoint, {
|
|
301
|
+
keyid: this.identityRaw.keyid,
|
|
302
|
+
publicKeyPem: this.identityRaw.publicKeyPem,
|
|
303
|
+
}, fetchImpl));
|
|
230
304
|
this.beforePublish = options.beforePublish;
|
|
231
305
|
}
|
|
232
306
|
// ── 公开接口 ─────────────────────────────────────────────────────────
|
|
@@ -256,9 +330,10 @@ class ConnectionServiceImpl {
|
|
|
256
330
|
// 撤回/暂停如实留痕(summary fail-closed 为未发布)并继续向上抛;
|
|
257
331
|
// begin 是显式动作,保持与旧 CLI 一致的抛错语义。
|
|
258
332
|
this.publicationVerified = false;
|
|
259
|
-
this.availability =
|
|
260
|
-
|
|
261
|
-
|
|
333
|
+
this.availability =
|
|
334
|
+
err instanceof MerchantConnectError
|
|
335
|
+
? { code: err.code, detail: err.message }
|
|
336
|
+
: { code: "PUBLICATION_CHECK_FAILED", detail: String(err) };
|
|
262
337
|
throw err;
|
|
263
338
|
}
|
|
264
339
|
this.publicationVerified = true;
|
|
@@ -275,48 +350,78 @@ class ConnectionServiceImpl {
|
|
|
275
350
|
if (foreign !== undefined) {
|
|
276
351
|
throw new MerchantConnectError("CATALOG_MISMATCH", "待续办的接入任务属于另一个 Catalog;为防止许可串用,已停止。");
|
|
277
352
|
}
|
|
353
|
+
if (store.sessions.some((item) => {
|
|
354
|
+
const s = item;
|
|
355
|
+
return (s.runtime_origin === this.origin &&
|
|
356
|
+
s.key_thumbprint === this.keyThumbprint &&
|
|
357
|
+
s.operation_claim &&
|
|
358
|
+
s.operation_claim.stage !== "poll");
|
|
359
|
+
}))
|
|
360
|
+
throw new MerchantConnectError("CONNECTION_OPERATION_UNKNOWN", "Unresolved enrollment effect must be reconciled");
|
|
278
361
|
const expectedCatalogAgentId = priorPublishedCatalogAgentId(store.sessions);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
362
|
+
let creation;
|
|
363
|
+
try {
|
|
364
|
+
creation = reserveEnrollmentCreation(this.dataDir, `${this.origin}|${this.client.catalogOrigin}|${this.keyThumbprint}|${this.generation}`);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
throw new MerchantConnectError("CONNECTION_OPERATION_UNKNOWN", "Enrollment creation is claimed; reconcile before retrying");
|
|
368
|
+
}
|
|
369
|
+
let creationSettled = false;
|
|
370
|
+
try {
|
|
371
|
+
if (this.selectSession(readEnrollmentStore(this.dataDir)) !== undefined) {
|
|
372
|
+
creationSettled = true;
|
|
373
|
+
throw new MerchantConnectError("STATE_CAS_CONFLICT", "Enrollment was created by another instance");
|
|
374
|
+
}
|
|
375
|
+
const enrollment = await this.client.createDeviceEnrollment({
|
|
376
|
+
runtimeOrigin: this.origin,
|
|
377
|
+
a2aEndpoint: this.a2aEndpoint,
|
|
378
|
+
generation: this.generation,
|
|
379
|
+
serviceEpoch: this.serviceEpoch,
|
|
380
|
+
publicPreview: card,
|
|
381
|
+
publicProfileRevision: 1,
|
|
382
|
+
}, this.identity);
|
|
383
|
+
const next = {
|
|
384
|
+
enrollment_id: enrollment.enrollmentId,
|
|
385
|
+
runtime_origin: this.origin,
|
|
386
|
+
key_thumbprint: this.keyThumbprint,
|
|
387
|
+
catalog_origin: catalogOrigin,
|
|
388
|
+
preview_digest: currentDigest,
|
|
389
|
+
frozen_card: card,
|
|
390
|
+
generation: this.generation,
|
|
391
|
+
...(expectedCatalogAgentId !== undefined
|
|
392
|
+
? { expected_catalog_agent_id: expectedCatalogAgentId }
|
|
393
|
+
: {}),
|
|
394
|
+
expires_at: enrollment.expiresAt,
|
|
395
|
+
status: "preparing",
|
|
396
|
+
device_code: enrollment.deviceCode,
|
|
397
|
+
user_code: enrollment.userCode,
|
|
398
|
+
verification_uri: enrollment.verificationUri,
|
|
399
|
+
interval: enrollment.intervalSeconds,
|
|
400
|
+
};
|
|
401
|
+
// 同 origin+key 的旧 preparing 会话被本任务取代(标 canceled 留痕),
|
|
402
|
+
// 其余会话(含其他 origin/key、bound/published 历史)一律保留。
|
|
403
|
+
this.persist((fresh) => [
|
|
404
|
+
...fresh.sessions.map((item) => {
|
|
405
|
+
const old = item;
|
|
406
|
+
return old.enrollment_id !== next.enrollment_id &&
|
|
407
|
+
old.runtime_origin === this.origin &&
|
|
408
|
+
old.key_thumbprint === this.keyThumbprint &&
|
|
409
|
+
old.status === "preparing"
|
|
410
|
+
? { ...old, status: "canceled" }
|
|
411
|
+
: item;
|
|
412
|
+
}),
|
|
413
|
+
next,
|
|
414
|
+
]);
|
|
415
|
+
this.nextPollAtMs = 0;
|
|
416
|
+
this.publicationVerified = false;
|
|
417
|
+
this.availability = null;
|
|
418
|
+
creationSettled = true;
|
|
419
|
+
return this.toSummary(next);
|
|
420
|
+
}
|
|
421
|
+
finally {
|
|
422
|
+
if (creationSettled)
|
|
423
|
+
creation.complete();
|
|
424
|
+
}
|
|
320
425
|
});
|
|
321
426
|
}
|
|
322
427
|
async reconcile() {
|
|
@@ -353,24 +458,27 @@ class ConnectionServiceImpl {
|
|
|
353
458
|
// stage 跟随“即将执行的步骤”:失败码按真正抛错的阶段归类。
|
|
354
459
|
if (current.status === "preparing") {
|
|
355
460
|
stage = "preparing";
|
|
356
|
-
current = await this.stepPreparing(current);
|
|
461
|
+
current = await this.claimedStep(current, "poll", () => this.stepPreparing(current), true);
|
|
357
462
|
stage = current.status;
|
|
358
463
|
}
|
|
359
464
|
if (current.status === "authorized") {
|
|
360
465
|
stage = "authorized";
|
|
361
|
-
current = await this.stepAuthorized(current);
|
|
466
|
+
current = await this.claimedStep(current, "bind", () => this.stepAuthorized(current), false);
|
|
362
467
|
stage = current.status;
|
|
363
468
|
}
|
|
364
469
|
if (current.status === "bound") {
|
|
365
470
|
stage = "bound";
|
|
366
|
-
current = await this.stepBound(current);
|
|
471
|
+
current = await this.claimedStep(current, "publish", () => this.stepBound(current), false);
|
|
367
472
|
stage = current.status;
|
|
368
473
|
}
|
|
369
474
|
}
|
|
370
475
|
catch (err) {
|
|
371
476
|
// 阶段感知稳定码:绑定被拒 vs 签名声明验真失败 vs 通信失败可被 owner
|
|
372
477
|
// API/UI 辨别;码值恒在本文件导出的固定集合内。
|
|
373
|
-
this.availability = {
|
|
478
|
+
this.availability = {
|
|
479
|
+
code: this.stepFailureCode(stage, err),
|
|
480
|
+
detail: err instanceof ProductTableError ? "商品表绑定或校验失败,请检查商品表归属与格式。" : "",
|
|
481
|
+
};
|
|
374
482
|
throw err;
|
|
375
483
|
}
|
|
376
484
|
if (current.status === "published") {
|
|
@@ -381,9 +489,10 @@ class ConnectionServiceImpl {
|
|
|
381
489
|
// 撤回/暂停/网络不可达一律 fail-closed:summary 报未发布(paused/error),
|
|
382
490
|
// 绝不自动恢复营业、不发任何写请求;下趟 reconcile 会重新核对。
|
|
383
491
|
this.publicationVerified = false;
|
|
384
|
-
this.availability =
|
|
385
|
-
|
|
386
|
-
|
|
492
|
+
this.availability =
|
|
493
|
+
err instanceof MerchantConnectError
|
|
494
|
+
? { code: err.code, detail: err.message }
|
|
495
|
+
: { code: "PUBLICATION_CHECK_FAILED", detail: String(err) };
|
|
387
496
|
return this.toSummary(current);
|
|
388
497
|
}
|
|
389
498
|
this.publicationVerified = true;
|
|
@@ -420,10 +529,11 @@ class ConnectionServiceImpl {
|
|
|
420
529
|
latestExpiredSession(store) {
|
|
421
530
|
const candidates = store.sessions.filter((item) => {
|
|
422
531
|
const session = item;
|
|
423
|
-
return session.status === "expired" &&
|
|
532
|
+
return (session.status === "expired" &&
|
|
533
|
+
session.runtime_origin === this.origin &&
|
|
424
534
|
session.key_thumbprint === this.keyThumbprint &&
|
|
425
535
|
session.catalog_origin === this.client.catalogOrigin &&
|
|
426
|
-
(session.generation ?? 1) === this.generation;
|
|
536
|
+
(session.generation ?? 1) === this.generation);
|
|
427
537
|
});
|
|
428
538
|
return candidates.at(-1);
|
|
429
539
|
}
|
|
@@ -432,7 +542,11 @@ class ConnectionServiceImpl {
|
|
|
432
542
|
if (err instanceof MerchantConnectError) {
|
|
433
543
|
return CONNECTION_PAIRING_SAFE_CODES.has(err.code) ? err.code : "CONNECT_STEP_FAILED";
|
|
434
544
|
}
|
|
545
|
+
if (err instanceof ProductTableError)
|
|
546
|
+
return "PRODUCT_TABLE_INVALID";
|
|
435
547
|
if (err instanceof CatalogClientError) {
|
|
548
|
+
if (err.code === "AUTHORIZATION_DENIED")
|
|
549
|
+
return "PAIRING_DENIED";
|
|
436
550
|
if (err.code === "CATALOG_UNREACHABLE")
|
|
437
551
|
return "PAIRING_COMMUNICATION_FAILED";
|
|
438
552
|
if (stage === "authorized") {
|
|
@@ -442,7 +556,9 @@ class ConnectionServiceImpl {
|
|
|
442
556
|
return "BIND_CLAIM_INVALID";
|
|
443
557
|
if (err.code === "CLAIM_MISMATCH") {
|
|
444
558
|
const fields = err.claimFields ?? [];
|
|
445
|
-
return fields.includes("card_url")
|
|
559
|
+
return fields.includes("card_url")
|
|
560
|
+
? "BIND_CLAIM_CARD_URL_MISMATCH"
|
|
561
|
+
: "BIND_CLAIM_FIELD_MISMATCH";
|
|
446
562
|
}
|
|
447
563
|
}
|
|
448
564
|
if (stage === "bound") {
|
|
@@ -494,9 +610,13 @@ class ConnectionServiceImpl {
|
|
|
494
610
|
}
|
|
495
611
|
catch (err) {
|
|
496
612
|
this.publicationVerified = false;
|
|
497
|
-
this.availability =
|
|
498
|
-
|
|
499
|
-
|
|
613
|
+
this.availability =
|
|
614
|
+
err instanceof MerchantConnectError
|
|
615
|
+
? { code: err.code, detail: err.message }
|
|
616
|
+
: {
|
|
617
|
+
code: "PUBLICATION_CHECK_FAILED",
|
|
618
|
+
detail: "Catalog publication could not be verified",
|
|
619
|
+
};
|
|
500
620
|
return null;
|
|
501
621
|
}
|
|
502
622
|
}
|
|
@@ -508,7 +628,8 @@ class ConnectionServiceImpl {
|
|
|
508
628
|
}
|
|
509
629
|
async stepPreparing(session) {
|
|
510
630
|
const nowMs = this.now().getTime();
|
|
511
|
-
if (!Number.isFinite(Date.parse(session.expires_at)) ||
|
|
631
|
+
if (!Number.isFinite(Date.parse(session.expires_at)) ||
|
|
632
|
+
Date.parse(session.expires_at) <= nowMs) {
|
|
512
633
|
// 授权已过期:不再轮询,显式标记;下一次 begin() 会为同 origin+key 新建。
|
|
513
634
|
const expired = { ...session, status: "expired" };
|
|
514
635
|
this.persist((fresh) => fresh.sessions.map((item) => item.enrollment_id === session.enrollment_id ? expired : item));
|
|
@@ -543,13 +664,18 @@ class ConnectionServiceImpl {
|
|
|
543
664
|
return authorized;
|
|
544
665
|
}
|
|
545
666
|
verifyAuthorizedPoll(session, poll) {
|
|
546
|
-
if (poll.enrollmentId !== session.enrollment_id ||
|
|
667
|
+
if (poll.enrollmentId !== session.enrollment_id ||
|
|
668
|
+
poll.runtimeOrigin !== this.origin ||
|
|
669
|
+
poll.a2aEndpoint !== this.a2aEndpoint ||
|
|
547
670
|
poll.merchantId.trim() === "" ||
|
|
548
|
-
session.expected_catalog_agent_id !== undefined &&
|
|
671
|
+
(session.expected_catalog_agent_id !== undefined &&
|
|
672
|
+
poll.catalogAgentId !== session.expected_catalog_agent_id)) {
|
|
549
673
|
throw new MerchantConnectError("AUTHORIZED_MATERIAL_MISMATCH", "Catalog 授权材料与当前 Runtime 不一致,已停止连接。");
|
|
550
674
|
}
|
|
551
|
-
if (poll.authorizationEpoch < 1 ||
|
|
552
|
-
|
|
675
|
+
if (poll.authorizationEpoch < 1 ||
|
|
676
|
+
poll.approvedCardDigest !== session.preview_digest ||
|
|
677
|
+
!poll.scopes.includes("runtime:bind") ||
|
|
678
|
+
!poll.scopes.includes("card:publish") ||
|
|
553
679
|
!poll.scopes.includes("heartbeat")) {
|
|
554
680
|
throw new MerchantConnectError("GRANT_SCOPE_INVALID", "Catalog 接入许可缺少有效授权代次或必要范围,已停止。");
|
|
555
681
|
}
|
|
@@ -558,10 +684,13 @@ class ConnectionServiceImpl {
|
|
|
558
684
|
// 兼容旧 CLI 写入的会话(当时 merchant_id 存的是 poll 断言):优先
|
|
559
685
|
// offered_merchant_id,缺失时回落旧字段,语义相同(都只是 bind 入参)。
|
|
560
686
|
const offeredMerchantId = session.offered_merchant_id ?? session.merchant_id;
|
|
561
|
-
if (session.catalog_agent_id === undefined ||
|
|
562
|
-
session.
|
|
687
|
+
if (session.catalog_agent_id === undefined ||
|
|
688
|
+
session.grant === undefined ||
|
|
689
|
+
session.authorization_epoch === undefined ||
|
|
690
|
+
offeredMerchantId === undefined) {
|
|
563
691
|
throw new MerchantConnectError("STATE_INVALID", "本地授权状态缺少许可、授权代次、merchant_id或 catalog_agent_id");
|
|
564
692
|
}
|
|
693
|
+
this.effectStarted = true;
|
|
565
694
|
const binding = await this.client.bindEnrollment({
|
|
566
695
|
enrollmentId: session.enrollment_id,
|
|
567
696
|
grant: session.grant,
|
|
@@ -598,21 +727,24 @@ class ConnectionServiceImpl {
|
|
|
598
727
|
binding_expires_at: claimExpiry,
|
|
599
728
|
expected_card_revision: binding.activeCardRevision ?? 0,
|
|
600
729
|
};
|
|
601
|
-
this.persist((fresh) => fresh.sessions.map((item) => item.enrollment_id === session.enrollment_id ? bound : item));
|
|
730
|
+
this.persist((fresh) => fresh.sessions.map((item) => (item.enrollment_id === session.enrollment_id ? bound : item)));
|
|
602
731
|
// 绑定已持久化:发布交给 reconcile 的 bound 分支——失败阶段归类
|
|
603
732
|
// (CARD_PUBLISH_* + stage=publish)由该分支的阶段标记正确给出,
|
|
604
733
|
// 首配级联路径不再把发布失败误报成 BIND_REJECTED。
|
|
605
734
|
return bound;
|
|
606
735
|
}
|
|
607
736
|
async stepBound(session) {
|
|
608
|
-
if (session.catalog_agent_id === undefined ||
|
|
609
|
-
session.
|
|
737
|
+
if (session.catalog_agent_id === undefined ||
|
|
738
|
+
session.binding_id === undefined ||
|
|
739
|
+
session.binding_version === undefined ||
|
|
740
|
+
session.merchant_id === undefined ||
|
|
610
741
|
session.binding_expires_at === undefined) {
|
|
611
742
|
throw new MerchantConnectError("STATE_INVALID", "绑定状态缺少回执字段");
|
|
612
743
|
}
|
|
613
744
|
// 重启续办/长等待后重新验证:绑定授权已过期的绝不允许带过期绑定调
|
|
614
745
|
// beforePublish 钩子或发布名片;显式标记 expired,下一次 begin() 重开。
|
|
615
|
-
if (!Number.isFinite(Date.parse(session.binding_expires_at)) ||
|
|
746
|
+
if (!Number.isFinite(Date.parse(session.binding_expires_at)) ||
|
|
747
|
+
Date.parse(session.binding_expires_at) <= this.now().getTime()) {
|
|
616
748
|
const expired = { ...session, status: "expired" };
|
|
617
749
|
this.persist((fresh) => fresh.sessions.map((item) => item.enrollment_id === session.enrollment_id ? expired : item));
|
|
618
750
|
return expired;
|
|
@@ -635,11 +767,20 @@ class ConnectionServiceImpl {
|
|
|
635
767
|
expiresAt: session.binding_expires_at,
|
|
636
768
|
cardRevision: session.card_revision ?? null,
|
|
637
769
|
};
|
|
638
|
-
if (this.beforePublish !== undefined)
|
|
639
|
-
|
|
770
|
+
if (this.beforePublish !== undefined) {
|
|
771
|
+
try {
|
|
772
|
+
await this.beforePublish(verified);
|
|
773
|
+
}
|
|
774
|
+
catch (error) {
|
|
775
|
+
if (error instanceof MerchantConnectError && error.code === "CATALOG_RUNTIME_NOT_READY")
|
|
776
|
+
this.preEffectReadinessFailure = true;
|
|
777
|
+
throw error;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
640
780
|
const expectedRevision = session.expected_card_revision ?? 0;
|
|
641
781
|
let cardRevision = session.card_revision;
|
|
642
782
|
if (cardRevision === undefined) {
|
|
783
|
+
this.effectStarted = true;
|
|
643
784
|
const publication = await this.client.publishCard({
|
|
644
785
|
agentId: catalogAgentId,
|
|
645
786
|
bindingId,
|
|
@@ -657,6 +798,7 @@ class ConnectionServiceImpl {
|
|
|
657
798
|
this.persist((fresh) => fresh.sessions.map((item) => item.enrollment_id === session.enrollment_id ? publishedCard : item));
|
|
658
799
|
session = publishedCard;
|
|
659
800
|
}
|
|
801
|
+
this.effectStarted = true;
|
|
660
802
|
const activated = await this.client.activateCard({
|
|
661
803
|
agentId: catalogAgentId,
|
|
662
804
|
bindingId,
|
|
@@ -666,13 +808,18 @@ class ConnectionServiceImpl {
|
|
|
666
808
|
if (activated.revision === null) {
|
|
667
809
|
throw new MerchantConnectError("ACTIVATION_RECEIPT_INVALID", "Catalog 未确认名片激活;绑定已保留,重试可续办");
|
|
668
810
|
}
|
|
669
|
-
const published = {
|
|
811
|
+
const published = {
|
|
812
|
+
...session,
|
|
813
|
+
status: "published",
|
|
814
|
+
card_revision: activated.revision,
|
|
815
|
+
};
|
|
670
816
|
// 同 catalog agent 的旧 published 会话由新绑定取代(标 replaced);其余一律保留。
|
|
671
817
|
this.persist((fresh) => fresh.sessions.map((item) => {
|
|
672
818
|
if (item.enrollment_id === session.enrollment_id)
|
|
673
819
|
return published;
|
|
674
820
|
const old = item;
|
|
675
|
-
return old.status === "published" &&
|
|
821
|
+
return old.status === "published" &&
|
|
822
|
+
old.catalog_agent_id === published.catalog_agent_id &&
|
|
676
823
|
old.binding_id !== published.binding_id
|
|
677
824
|
? { ...old, status: "replaced" }
|
|
678
825
|
: item;
|
|
@@ -716,11 +863,13 @@ class ConnectionServiceImpl {
|
|
|
716
863
|
findStaleSession(store) {
|
|
717
864
|
const candidate = store.sessions.find((item) => {
|
|
718
865
|
const session = item;
|
|
719
|
-
return session.runtime_origin === this.origin &&
|
|
866
|
+
return (session.runtime_origin === this.origin &&
|
|
867
|
+
session.key_thumbprint === this.keyThumbprint &&
|
|
720
868
|
(session.generation ?? 1) === this.generation &&
|
|
721
869
|
session.catalog_origin === this.client.catalogOrigin &&
|
|
722
870
|
["preparing", "authorized"].includes(session.status) &&
|
|
723
|
-
(!Number.isFinite(Date.parse(session.expires_at)) ||
|
|
871
|
+
(!Number.isFinite(Date.parse(session.expires_at)) ||
|
|
872
|
+
Date.parse(session.expires_at) <= this.now().getTime()));
|
|
724
873
|
});
|
|
725
874
|
return candidate;
|
|
726
875
|
}
|
|
@@ -761,12 +910,18 @@ class ConnectionServiceImpl {
|
|
|
761
910
|
throw new MerchantConnectError("STATE_INVALID", "已发布接入缺少 Catalog/绑定信息。");
|
|
762
911
|
}
|
|
763
912
|
const active = await this.client.fetchPublicBinding(session.catalog_agent_id);
|
|
764
|
-
if (active === null ||
|
|
765
|
-
|
|
913
|
+
if (active === null ||
|
|
914
|
+
active.bindingId !== session.binding_id ||
|
|
915
|
+
session.binding_version === undefined ||
|
|
916
|
+
active.bindingVersion !== session.binding_version ||
|
|
766
917
|
active.keyThumbprint !== this.keyThumbprint ||
|
|
767
|
-
active.
|
|
918
|
+
active.keyId !== this.identity.keyId ||
|
|
919
|
+
active.serviceEpoch !== this.serviceEpoch ||
|
|
920
|
+
active.runtimeOrigin.replace(/\/+$/, "") !== this.origin ||
|
|
921
|
+
active.a2aEndpoint !== this.a2aEndpoint ||
|
|
768
922
|
active.cardRevision !== session.card_revision ||
|
|
769
|
-
!Number.isFinite(Date.parse(active.expiresAt)) ||
|
|
923
|
+
!Number.isFinite(Date.parse(active.expiresAt)) ||
|
|
924
|
+
Date.parse(active.expiresAt) <= this.now().getTime() ||
|
|
770
925
|
!["ACTIVE", "active"].includes(active.publicationState)) {
|
|
771
926
|
throw new MerchantConnectError("PUBLICATION_NOT_ACTIVE", "Catalog 当前没有返回这条绑定和已激活名片;服务可能已暂停或撤回。请到Catalog恢复服务后再检查,Runtime不会自动恢复营业。");
|
|
772
927
|
}
|
|
@@ -795,11 +950,14 @@ class ConnectionServiceImpl {
|
|
|
795
950
|
};
|
|
796
951
|
}
|
|
797
952
|
verifiedFromSession(session) {
|
|
798
|
-
if (session.catalog_agent_id === undefined ||
|
|
799
|
-
session.
|
|
953
|
+
if (session.catalog_agent_id === undefined ||
|
|
954
|
+
session.binding_id === undefined ||
|
|
955
|
+
session.binding_version === undefined ||
|
|
956
|
+
session.merchant_id === undefined ||
|
|
800
957
|
session.binding_expires_at === undefined)
|
|
801
958
|
return null;
|
|
802
|
-
if (!Number.isFinite(Date.parse(session.binding_expires_at)) ||
|
|
959
|
+
if (!Number.isFinite(Date.parse(session.binding_expires_at)) ||
|
|
960
|
+
Date.parse(session.binding_expires_at) <= this.now().getTime()) {
|
|
803
961
|
return null;
|
|
804
962
|
}
|
|
805
963
|
return {
|
|
@@ -830,11 +988,21 @@ class ConnectionServiceImpl {
|
|
|
830
988
|
}
|
|
831
989
|
toSummary(session) {
|
|
832
990
|
if (session === null) {
|
|
833
|
-
return {
|
|
991
|
+
return {
|
|
992
|
+
status: "idle",
|
|
993
|
+
stage: this.stageOf("idle"),
|
|
994
|
+
published: false,
|
|
995
|
+
agentId: null,
|
|
996
|
+
bindingId: null,
|
|
997
|
+
bindingExpiresAt: null,
|
|
998
|
+
cardRevision: null,
|
|
999
|
+
code: null,
|
|
1000
|
+
detail: null,
|
|
1001
|
+
};
|
|
834
1002
|
}
|
|
835
1003
|
if (session.status !== "published") {
|
|
836
1004
|
// 非 published 阶段也透出最近一次步骤失败的自有稳定码(availability 仅由
|
|
837
|
-
// reconcile
|
|
1005
|
+
// reconcile 的失败路径写入;已知本地类型可给固定说明,其余为空,绝不携带远端原文/凭据)。
|
|
838
1006
|
// availability 只在失败/发布核对路径写入:非 published 时非空即最近一次失败。
|
|
839
1007
|
const stepFailure = this.availability !== null
|
|
840
1008
|
? { code: this.availability.code, detail: this.availability.detail }
|
|
@@ -869,7 +1037,9 @@ class ConnectionServiceImpl {
|
|
|
869
1037
|
};
|
|
870
1038
|
}
|
|
871
1039
|
return {
|
|
872
|
-
status: "published",
|
|
1040
|
+
status: "published",
|
|
1041
|
+
stage: "publish",
|
|
1042
|
+
published: true,
|
|
873
1043
|
agentId: session.catalog_agent_id ?? null,
|
|
874
1044
|
bindingId: session.binding_id ?? null,
|
|
875
1045
|
bindingExpiresAt: session.binding_expires_at ?? null,
|
|
@@ -878,12 +1048,82 @@ class ConnectionServiceImpl {
|
|
|
878
1048
|
detail: null,
|
|
879
1049
|
};
|
|
880
1050
|
}
|
|
881
|
-
/** 0600 原子写;mutator 在**新鲜重读**的 store 上操作,保留 consumed 与其他会话。 */
|
|
882
1051
|
persist(mutate) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1052
|
+
withEnrollmentStoreLock(this.dataDir, () => {
|
|
1053
|
+
const fresh = readEnrollmentStore(this.dataDir), sessions = mutate(fresh), byId = new Map(fresh.sessions.map((s) => [s.enrollment_id, s]));
|
|
1054
|
+
for (const item of sessions) {
|
|
1055
|
+
const before = byId.get(item.enrollment_id);
|
|
1056
|
+
if (item === before)
|
|
1057
|
+
continue;
|
|
1058
|
+
const expected = item.store_revision ?? 0, current = before?.store_revision ?? 0;
|
|
1059
|
+
const observed = item[observedSession];
|
|
1060
|
+
if ((before && observed !== sessionDigest(before)) ||
|
|
1061
|
+
expected !== current ||
|
|
1062
|
+
!Number.isSafeInteger(current))
|
|
1063
|
+
throw new MerchantConnectError("STATE_CAS_CONFLICT", "Enrollment changed; reread before continuing");
|
|
1064
|
+
item.store_revision = current + 1;
|
|
1065
|
+
Object.defineProperty(item, observedSession, {
|
|
1066
|
+
value: sessionDigest(item),
|
|
1067
|
+
enumerable: true,
|
|
1068
|
+
writable: true,
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
writeFileAtomic(enrollmentStorePath(this.dataDir), JSON.stringify({ ...fresh, sessions }) + "\n", { mode: 0o600 });
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
async claimedStep(session, stage, step, readOnly) {
|
|
1075
|
+
const token = randomUUID();
|
|
1076
|
+
this.persist((fresh) => fresh.sessions.map((item) => {
|
|
1077
|
+
if (item.enrollment_id !== session.enrollment_id)
|
|
1078
|
+
return item;
|
|
1079
|
+
const live = item;
|
|
1080
|
+
if (live.operation_claim)
|
|
1081
|
+
throw new MerchantConnectError(live.operation_claim.state === "unknown" ||
|
|
1082
|
+
Date.parse(live.operation_claim.expires_at) <= this.now().getTime()
|
|
1083
|
+
? "CONNECTION_OPERATION_UNKNOWN"
|
|
1084
|
+
: "CONNECTION_OPERATION_PENDING", "Enrollment operation is already claimed");
|
|
1085
|
+
if (live.status !== session.status ||
|
|
1086
|
+
(live.store_revision ?? 0) !== (session.store_revision ?? 0))
|
|
1087
|
+
throw new MerchantConnectError("STATE_CAS_CONFLICT", "Enrollment changed");
|
|
1088
|
+
session.operation_claim = {
|
|
1089
|
+
token,
|
|
1090
|
+
stage,
|
|
1091
|
+
state: "active",
|
|
1092
|
+
expires_at: new Date(this.now().getTime() + 60000).toISOString(),
|
|
1093
|
+
};
|
|
1094
|
+
return session;
|
|
1095
|
+
}));
|
|
1096
|
+
let result;
|
|
1097
|
+
this.effectStarted = false;
|
|
1098
|
+
try {
|
|
1099
|
+
result = await step();
|
|
1100
|
+
return result;
|
|
1101
|
+
}
|
|
1102
|
+
finally {
|
|
1103
|
+
// Effect uncertainty is durable. Only read-only calls or known pre-effect
|
|
1104
|
+
// readiness failures release a claim automatically; no stale lease stealing.
|
|
1105
|
+
const safe = result !== undefined || readOnly || !this.effectStarted;
|
|
1106
|
+
this.preEffectReadinessFailure = false;
|
|
1107
|
+
this.persist((fresh) => fresh.sessions.map((item) => {
|
|
1108
|
+
const live = item;
|
|
1109
|
+
if (live.enrollment_id !== session.enrollment_id || live.operation_claim?.token !== token)
|
|
1110
|
+
return item;
|
|
1111
|
+
const updated = { ...live };
|
|
1112
|
+
if (safe)
|
|
1113
|
+
delete updated.operation_claim;
|
|
1114
|
+
else
|
|
1115
|
+
updated.operation_claim = { ...live.operation_claim, state: "unknown" };
|
|
1116
|
+
if (result) {
|
|
1117
|
+
if (safe)
|
|
1118
|
+
delete result.operation_claim;
|
|
1119
|
+
Object.assign(result, updated);
|
|
1120
|
+
}
|
|
1121
|
+
return result ?? updated;
|
|
1122
|
+
}));
|
|
1123
|
+
}
|
|
886
1124
|
}
|
|
1125
|
+
preEffectReadinessFailure = false;
|
|
1126
|
+
effectStarted = false;
|
|
887
1127
|
async withLock(fn) {
|
|
888
1128
|
const result = this.mutex.then(fn);
|
|
889
1129
|
this.mutex = result.then(() => undefined, () => undefined);
|