@harrylabsj/kiwi 0.6.0
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/LICENSE +201 -0
- package/README.md +150 -0
- package/contracts/candidate-agent-dto-1.0.README.md +39 -0
- package/contracts/candidate-agent-dto-1.0.schema.json +172 -0
- package/contracts/interop/kiwi-buyer-message-send.json +43 -0
- package/contracts/interop/knp-data-part-examples.json +243 -0
- package/contracts/kiwi-catalog/1.0/agent-record.schema.json +78 -0
- package/contracts/kiwi-catalog/1.0/listing-record.schema.json +88 -0
- package/contracts/kiwi-catalog/1.0/listing-search-result.schema.json +60 -0
- package/contracts/negotiation/1.0/schema.json +501 -0
- package/contracts/shopping.negotiation/0.1/capabilities.schema.json +47 -0
- package/contracts/shopping.negotiation/0.1/decision.schema.json +120 -0
- package/contracts/shopping.negotiation/0.1/policy-result.schema.json +52 -0
- package/contracts/shopping.negotiation/0.1/snapshot.schema.json +172 -0
- package/dist/a2a/client/client.d.ts +33 -0
- package/dist/a2a/client/client.js +161 -0
- package/dist/a2a/client/client.js.map +1 -0
- package/dist/a2a/client/error.d.ts +35 -0
- package/dist/a2a/client/error.js +34 -0
- package/dist/a2a/client/error.js.map +1 -0
- package/dist/a2a/client/index.d.ts +29 -0
- package/dist/a2a/client/index.js +26 -0
- package/dist/a2a/client/index.js.map +1 -0
- package/dist/a2a/client/jsonrpc.d.ts +49 -0
- package/dist/a2a/client/jsonrpc.js +85 -0
- package/dist/a2a/client/jsonrpc.js.map +1 -0
- package/dist/a2a/client/parse.d.ts +18 -0
- package/dist/a2a/client/parse.js +134 -0
- package/dist/a2a/client/parse.js.map +1 -0
- package/dist/a2a/client/types.d.ts +102 -0
- package/dist/a2a/client/types.js +26 -0
- package/dist/a2a/client/types.js.map +1 -0
- package/dist/a2a/client/url-policy.d.ts +44 -0
- package/dist/a2a/client/url-policy.js +242 -0
- package/dist/a2a/client/url-policy.js.map +1 -0
- package/dist/a2a/negotiate.d.ts +68 -0
- package/dist/a2a/negotiate.js +288 -0
- package/dist/a2a/negotiate.js.map +1 -0
- package/dist/a2a/node.d.ts +37 -0
- package/dist/a2a/node.js +155 -0
- package/dist/a2a/node.js.map +1 -0
- package/dist/a2a/server/auth.d.ts +38 -0
- package/dist/a2a/server/auth.js +112 -0
- package/dist/a2a/server/auth.js.map +1 -0
- package/dist/a2a/server/card.d.ts +19 -0
- package/dist/a2a/server/card.js +81 -0
- package/dist/a2a/server/card.js.map +1 -0
- package/dist/a2a/server/errors.d.ts +109 -0
- package/dist/a2a/server/errors.js +178 -0
- package/dist/a2a/server/errors.js.map +1 -0
- package/dist/a2a/server/handler.d.ts +22 -0
- package/dist/a2a/server/handler.js +57 -0
- package/dist/a2a/server/handler.js.map +1 -0
- package/dist/a2a/server/inbound-message.d.ts +37 -0
- package/dist/a2a/server/inbound-message.js +104 -0
- package/dist/a2a/server/inbound-message.js.map +1 -0
- package/dist/a2a/server/index.d.ts +43 -0
- package/dist/a2a/server/index.js +42 -0
- package/dist/a2a/server/index.js.map +1 -0
- package/dist/a2a/server/merchant-handler.d.ts +69 -0
- package/dist/a2a/server/merchant-handler.js +316 -0
- package/dist/a2a/server/merchant-handler.js.map +1 -0
- package/dist/a2a/server/pipeline.d.ts +69 -0
- package/dist/a2a/server/pipeline.js +329 -0
- package/dist/a2a/server/pipeline.js.map +1 -0
- package/dist/a2a/server/server.d.ts +64 -0
- package/dist/a2a/server/server.js +420 -0
- package/dist/a2a/server/server.js.map +1 -0
- package/dist/a2a/server/task-registry.d.ts +31 -0
- package/dist/a2a/server/task-registry.js +67 -0
- package/dist/a2a/server/task-registry.js.map +1 -0
- package/dist/a2a/server/throttle.d.ts +154 -0
- package/dist/a2a/server/throttle.js +289 -0
- package/dist/a2a/server/throttle.js.map +1 -0
- package/dist/a2a/server/types.d.ts +191 -0
- package/dist/a2a/server/types.js +17 -0
- package/dist/a2a/server/types.js.map +1 -0
- package/dist/a2a/server/ucp.d.ts +49 -0
- package/dist/a2a/server/ucp.js +85 -0
- package/dist/a2a/server/ucp.js.map +1 -0
- package/dist/a2a/task/index.d.ts +24 -0
- package/dist/a2a/task/index.js +22 -0
- package/dist/a2a/task/index.js.map +1 -0
- package/dist/a2a/task/ledger.d.ts +48 -0
- package/dist/a2a/task/ledger.js +65 -0
- package/dist/a2a/task/ledger.js.map +1 -0
- package/dist/a2a/task/poller.d.ts +93 -0
- package/dist/a2a/task/poller.js +184 -0
- package/dist/a2a/task/poller.js.map +1 -0
- package/dist/a2a/task/state.d.ts +72 -0
- package/dist/a2a/task/state.js +119 -0
- package/dist/a2a/task/state.js.map +1 -0
- package/dist/a2a/ucp-agent.d.ts +49 -0
- package/dist/a2a/ucp-agent.js +78 -0
- package/dist/a2a/ucp-agent.js.map +1 -0
- package/dist/agent/agent-db.d.ts +31 -0
- package/dist/agent/agent-db.js +91 -0
- package/dist/agent/agent-db.js.map +1 -0
- package/dist/agent/buyer/buyer-tools.d.ts +70 -0
- package/dist/agent/buyer/buyer-tools.js +1353 -0
- package/dist/agent/buyer/buyer-tools.js.map +1 -0
- package/dist/agent/buyer/ranker.d.ts +53 -0
- package/dist/agent/buyer/ranker.js +153 -0
- package/dist/agent/buyer/ranker.js.map +1 -0
- package/dist/agent/buyer/scheduler.d.ts +58 -0
- package/dist/agent/buyer/scheduler.js +317 -0
- package/dist/agent/buyer/scheduler.js.map +1 -0
- package/dist/agent/buyer/search-loop.d.ts +42 -0
- package/dist/agent/buyer/search-loop.js +280 -0
- package/dist/agent/buyer/search-loop.js.map +1 -0
- package/dist/agent/buyer/task-store.d.ts +178 -0
- package/dist/agent/buyer/task-store.js +637 -0
- package/dist/agent/buyer/task-store.js.map +1 -0
- package/dist/agent/buyer/types.d.ts +222 -0
- package/dist/agent/buyer/types.js +124 -0
- package/dist/agent/buyer/types.js.map +1 -0
- package/dist/agent/chat-tools.d.ts +41 -0
- package/dist/agent/chat-tools.js +193 -0
- package/dist/agent/chat-tools.js.map +1 -0
- package/dist/agent/chat-tui.d.ts +49 -0
- package/dist/agent/chat-tui.js +314 -0
- package/dist/agent/chat-tui.js.map +1 -0
- package/dist/agent/connector/fake-connector.d.ts +50 -0
- package/dist/agent/connector/fake-connector.js +138 -0
- package/dist/agent/connector/fake-connector.js.map +1 -0
- package/dist/agent/connector/http-connector.d.ts +49 -0
- package/dist/agent/connector/http-connector.js +208 -0
- package/dist/agent/connector/http-connector.js.map +1 -0
- package/dist/agent/connector/types.d.ts +103 -0
- package/dist/agent/connector/types.js +97 -0
- package/dist/agent/connector/types.js.map +1 -0
- package/dist/agent/fake-chat-model.d.ts +22 -0
- package/dist/agent/fake-chat-model.js +134 -0
- package/dist/agent/fake-chat-model.js.map +1 -0
- package/dist/agent/kernel.d.ts +258 -0
- package/dist/agent/kernel.js +1099 -0
- package/dist/agent/kernel.js.map +1 -0
- package/dist/agent/memory/schema.d.ts +32 -0
- package/dist/agent/memory/schema.js +291 -0
- package/dist/agent/memory/schema.js.map +1 -0
- package/dist/agent/memory/store.d.ts +193 -0
- package/dist/agent/memory/store.js +881 -0
- package/dist/agent/memory/store.js.map +1 -0
- package/dist/agent/memory/types.d.ts +139 -0
- package/dist/agent/memory/types.js +119 -0
- package/dist/agent/memory/types.js.map +1 -0
- package/dist/agent/memory/vault.d.ts +49 -0
- package/dist/agent/memory/vault.js +125 -0
- package/dist/agent/memory/vault.js.map +1 -0
- package/dist/agent/merchant/action-candidate.d.ts +106 -0
- package/dist/agent/merchant/action-candidate.js +241 -0
- package/dist/agent/merchant/action-candidate.js.map +1 -0
- package/dist/agent/merchant/credential-broker.d.ts +67 -0
- package/dist/agent/merchant/credential-broker.js +76 -0
- package/dist/agent/merchant/credential-broker.js.map +1 -0
- package/dist/agent/merchant/fake-merchant-client.d.ts +47 -0
- package/dist/agent/merchant/fake-merchant-client.js +143 -0
- package/dist/agent/merchant/fake-merchant-client.js.map +1 -0
- package/dist/agent/merchant/merchant-client.d.ts +49 -0
- package/dist/agent/merchant/merchant-client.js +186 -0
- package/dist/agent/merchant/merchant-client.js.map +1 -0
- package/dist/agent/merchant/merchant-tools.d.ts +74 -0
- package/dist/agent/merchant/merchant-tools.js +582 -0
- package/dist/agent/merchant/merchant-tools.js.map +1 -0
- package/dist/agent/merchant/types.d.ts +119 -0
- package/dist/agent/merchant/types.js +133 -0
- package/dist/agent/merchant/types.js.map +1 -0
- package/dist/agent/mode.d.ts +32 -0
- package/dist/agent/mode.js +34 -0
- package/dist/agent/mode.js.map +1 -0
- package/dist/agent/negotiation-chat.d.ts +81 -0
- package/dist/agent/negotiation-chat.js +330 -0
- package/dist/agent/negotiation-chat.js.map +1 -0
- package/dist/agent/session.d.ts +22 -0
- package/dist/agent/session.js +164 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +26 -0
- package/dist/agent/system-prompt.js +77 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/agent/write-gate.d.ts +98 -0
- package/dist/agent/write-gate.js +76 -0
- package/dist/agent/write-gate.js.map +1 -0
- package/dist/cli.d.ts +18 -0
- package/dist/cli.js +1139 -0
- package/dist/cli.js.map +1 -0
- package/dist/commerce/data-source.d.ts +88 -0
- package/dist/commerce/data-source.js +25 -0
- package/dist/commerce/data-source.js.map +1 -0
- package/dist/commerce/erp-source.d.ts +51 -0
- package/dist/commerce/erp-source.js +184 -0
- package/dist/commerce/erp-source.js.map +1 -0
- package/dist/commerce/fake-client.d.ts +167 -0
- package/dist/commerce/fake-client.js +549 -0
- package/dist/commerce/fake-client.js.map +1 -0
- package/dist/commerce/http-client.d.ts +73 -0
- package/dist/commerce/http-client.js +284 -0
- package/dist/commerce/http-client.js.map +1 -0
- package/dist/commerce/local-db-source.d.ts +50 -0
- package/dist/commerce/local-db-source.js +162 -0
- package/dist/commerce/local-db-source.js.map +1 -0
- package/dist/commerce/shopping-cli-source.d.ts +57 -0
- package/dist/commerce/shopping-cli-source.js +206 -0
- package/dist/commerce/shopping-cli-source.js.map +1 -0
- package/dist/commerce/types.d.ts +146 -0
- package/dist/commerce/types.js +31 -0
- package/dist/commerce/types.js.map +1 -0
- package/dist/config/profile.d.ts +122 -0
- package/dist/config/profile.js +386 -0
- package/dist/config/profile.js.map +1 -0
- package/dist/contracts/negotiation-schema.d.ts +28 -0
- package/dist/contracts/negotiation-schema.js +101 -0
- package/dist/contracts/negotiation-schema.js.map +1 -0
- package/dist/contracts/schemas.d.ts +31 -0
- package/dist/contracts/schemas.js +122 -0
- package/dist/contracts/schemas.js.map +1 -0
- package/dist/counterparty/a2a-direct/index.d.ts +41 -0
- package/dist/counterparty/a2a-direct/index.js +330 -0
- package/dist/counterparty/a2a-direct/index.js.map +1 -0
- package/dist/counterparty/channel.d.ts +200 -0
- package/dist/counterparty/channel.js +61 -0
- package/dist/counterparty/channel.js.map +1 -0
- package/dist/counterparty/index.d.ts +28 -0
- package/dist/counterparty/index.js +24 -0
- package/dist/counterparty/index.js.map +1 -0
- package/dist/counterparty/platform-api/index.d.ts +41 -0
- package/dist/counterparty/platform-api/index.js +65 -0
- package/dist/counterparty/platform-api/index.js.map +1 -0
- package/dist/counterparty/registry.d.ts +51 -0
- package/dist/counterparty/registry.js +71 -0
- package/dist/counterparty/registry.js.map +1 -0
- package/dist/counterparty/shopping-cli-hosted/index.d.ts +36 -0
- package/dist/counterparty/shopping-cli-hosted/index.js +337 -0
- package/dist/counterparty/shopping-cli-hosted/index.js.map +1 -0
- package/dist/discovery/agent-card/error.d.ts +28 -0
- package/dist/discovery/agent-card/error.js +31 -0
- package/dist/discovery/agent-card/error.js.map +1 -0
- package/dist/discovery/agent-card/extensions.d.ts +20 -0
- package/dist/discovery/agent-card/extensions.js +59 -0
- package/dist/discovery/agent-card/extensions.js.map +1 -0
- package/dist/discovery/agent-card/index.d.ts +29 -0
- package/dist/discovery/agent-card/index.js +38 -0
- package/dist/discovery/agent-card/index.js.map +1 -0
- package/dist/discovery/agent-card/secrets.d.ts +30 -0
- package/dist/discovery/agent-card/secrets.js +240 -0
- package/dist/discovery/agent-card/secrets.js.map +1 -0
- package/dist/discovery/agent-card/types.d.ts +110 -0
- package/dist/discovery/agent-card/types.js +37 -0
- package/dist/discovery/agent-card/types.js.map +1 -0
- package/dist/discovery/agent-card/validate.d.ts +31 -0
- package/dist/discovery/agent-card/validate.js +210 -0
- package/dist/discovery/agent-card/validate.js.map +1 -0
- package/dist/discovery/capability/error.d.ts +23 -0
- package/dist/discovery/capability/error.js +28 -0
- package/dist/discovery/capability/error.js.map +1 -0
- package/dist/discovery/capability/index.d.ts +21 -0
- package/dist/discovery/capability/index.js +21 -0
- package/dist/discovery/capability/index.js.map +1 -0
- package/dist/discovery/capability/intersect.d.ts +56 -0
- package/dist/discovery/capability/intersect.js +137 -0
- package/dist/discovery/capability/intersect.js.map +1 -0
- package/dist/discovery/catalog-source/errors.d.ts +32 -0
- package/dist/discovery/catalog-source/errors.js +41 -0
- package/dist/discovery/catalog-source/errors.js.map +1 -0
- package/dist/discovery/catalog-source/index.d.ts +30 -0
- package/dist/discovery/catalog-source/index.js +29 -0
- package/dist/discovery/catalog-source/index.js.map +1 -0
- package/dist/discovery/catalog-source/kiwi-record.d.ts +183 -0
- package/dist/discovery/catalog-source/kiwi-record.js +72 -0
- package/dist/discovery/catalog-source/kiwi-record.js.map +1 -0
- package/dist/discovery/catalog-source/kiwi-schema.d.ts +33 -0
- package/dist/discovery/catalog-source/kiwi-schema.js +106 -0
- package/dist/discovery/catalog-source/kiwi-schema.js.map +1 -0
- package/dist/discovery/catalog-source/kiwi-source.d.ts +38 -0
- package/dist/discovery/catalog-source/kiwi-source.js +318 -0
- package/dist/discovery/catalog-source/kiwi-source.js.map +1 -0
- package/dist/discovery/catalog-source/register.d.ts +48 -0
- package/dist/discovery/catalog-source/register.js +83 -0
- package/dist/discovery/catalog-source/register.js.map +1 -0
- package/dist/discovery/catalog-source/schema.d.ts +21 -0
- package/dist/discovery/catalog-source/schema.js +63 -0
- package/dist/discovery/catalog-source/schema.js.map +1 -0
- package/dist/discovery/catalog-source/source.d.ts +45 -0
- package/dist/discovery/catalog-source/source.js +197 -0
- package/dist/discovery/catalog-source/source.js.map +1 -0
- package/dist/discovery/catalog-source/types.d.ts +122 -0
- package/dist/discovery/catalog-source/types.js +30 -0
- package/dist/discovery/catalog-source/types.js.map +1 -0
- package/dist/discovery/index.d.ts +25 -0
- package/dist/discovery/index.js +25 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/resolve.d.ts +175 -0
- package/dist/discovery/resolve.js +367 -0
- package/dist/discovery/resolve.js.map +1 -0
- package/dist/discovery/ucp/error.d.ts +25 -0
- package/dist/discovery/ucp/error.js +27 -0
- package/dist/discovery/ucp/error.js.map +1 -0
- package/dist/discovery/ucp/index.d.ts +33 -0
- package/dist/discovery/ucp/index.js +28 -0
- package/dist/discovery/ucp/index.js.map +1 -0
- package/dist/discovery/ucp/intersect.d.ts +148 -0
- package/dist/discovery/ucp/intersect.js +312 -0
- package/dist/discovery/ucp/intersect.js.map +1 -0
- package/dist/discovery/ucp/resolver.d.ts +62 -0
- package/dist/discovery/ucp/resolver.js +214 -0
- package/dist/discovery/ucp/resolver.js.map +1 -0
- package/dist/discovery/ucp/types.d.ts +97 -0
- package/dist/discovery/ucp/types.js +103 -0
- package/dist/discovery/ucp/types.js.map +1 -0
- package/dist/discovery/ucp/validate.d.ts +38 -0
- package/dist/discovery/ucp/validate.js +232 -0
- package/dist/discovery/ucp/validate.js.map +1 -0
- package/dist/discovery/ucp/vendor.d.ts +60 -0
- package/dist/discovery/ucp/vendor.js +61 -0
- package/dist/discovery/ucp/vendor.js.map +1 -0
- package/dist/doctor.d.ts +26 -0
- package/dist/doctor.js +113 -0
- package/dist/doctor.js.map +1 -0
- package/dist/exit-codes.d.ts +26 -0
- package/dist/exit-codes.js +27 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/fanout/disclosure.d.ts +138 -0
- package/dist/fanout/disclosure.js +188 -0
- package/dist/fanout/disclosure.js.map +1 -0
- package/dist/fanout/index.d.ts +32 -0
- package/dist/fanout/index.js +30 -0
- package/dist/fanout/index.js.map +1 -0
- package/dist/fanout/orchestrator.d.ts +153 -0
- package/dist/fanout/orchestrator.js +439 -0
- package/dist/fanout/orchestrator.js.map +1 -0
- package/dist/fanout/policy.d.ts +128 -0
- package/dist/fanout/policy.js +130 -0
- package/dist/fanout/policy.js.map +1 -0
- package/dist/handoff/acp-commerce.d.ts +58 -0
- package/dist/handoff/acp-commerce.js +69 -0
- package/dist/handoff/acp-commerce.js.map +1 -0
- package/dist/handoff/authorization.d.ts +127 -0
- package/dist/handoff/authorization.js +107 -0
- package/dist/handoff/authorization.js.map +1 -0
- package/dist/handoff/candidate.d.ts +94 -0
- package/dist/handoff/candidate.js +172 -0
- package/dist/handoff/candidate.js.map +1 -0
- package/dist/handoff/channel.d.ts +88 -0
- package/dist/handoff/channel.js +189 -0
- package/dist/handoff/channel.js.map +1 -0
- package/dist/handoff/completion.d.ts +44 -0
- package/dist/handoff/completion.js +136 -0
- package/dist/handoff/completion.js.map +1 -0
- package/dist/handoff/delivery.d.ts +59 -0
- package/dist/handoff/delivery.js +185 -0
- package/dist/handoff/delivery.js.map +1 -0
- package/dist/handoff/destination.d.ts +39 -0
- package/dist/handoff/destination.js +99 -0
- package/dist/handoff/destination.js.map +1 -0
- package/dist/handoff/errors.d.ts +34 -0
- package/dist/handoff/errors.js +47 -0
- package/dist/handoff/errors.js.map +1 -0
- package/dist/handoff/idempotency.d.ts +51 -0
- package/dist/handoff/idempotency.js +168 -0
- package/dist/handoff/idempotency.js.map +1 -0
- package/dist/handoff/index.d.ts +46 -0
- package/dist/handoff/index.js +48 -0
- package/dist/handoff/index.js.map +1 -0
- package/dist/handoff/ledger.d.ts +94 -0
- package/dist/handoff/ledger.js +195 -0
- package/dist/handoff/ledger.js.map +1 -0
- package/dist/handoff/lifecycle.d.ts +29 -0
- package/dist/handoff/lifecycle.js +102 -0
- package/dist/handoff/lifecycle.js.map +1 -0
- package/dist/handoff/metrics.d.ts +56 -0
- package/dist/handoff/metrics.js +78 -0
- package/dist/handoff/metrics.js.map +1 -0
- package/dist/handoff/operator-approval.d.ts +143 -0
- package/dist/handoff/operator-approval.js +287 -0
- package/dist/handoff/operator-approval.js.map +1 -0
- package/dist/handoff/order-record.d.ts +104 -0
- package/dist/handoff/order-record.js +235 -0
- package/dist/handoff/order-record.js.map +1 -0
- package/dist/handoff/package.d.ts +102 -0
- package/dist/handoff/package.js +132 -0
- package/dist/handoff/package.js.map +1 -0
- package/dist/handoff/transaction.d.ts +96 -0
- package/dist/handoff/transaction.js +263 -0
- package/dist/handoff/transaction.js.map +1 -0
- package/dist/handoff/ucp-checkout/cart-channel.d.ts +111 -0
- package/dist/handoff/ucp-checkout/cart-channel.js +370 -0
- package/dist/handoff/ucp-checkout/cart-channel.js.map +1 -0
- package/dist/handoff/ucp-checkout/cart-parse.d.ts +22 -0
- package/dist/handoff/ucp-checkout/cart-parse.js +102 -0
- package/dist/handoff/ucp-checkout/cart-parse.js.map +1 -0
- package/dist/handoff/ucp-checkout/cart-types.d.ts +93 -0
- package/dist/handoff/ucp-checkout/cart-types.js +38 -0
- package/dist/handoff/ucp-checkout/cart-types.js.map +1 -0
- package/dist/handoff/ucp-checkout/channel.d.ts +159 -0
- package/dist/handoff/ucp-checkout/channel.js +636 -0
- package/dist/handoff/ucp-checkout/channel.js.map +1 -0
- package/dist/handoff/ucp-checkout/client.d.ts +88 -0
- package/dist/handoff/ucp-checkout/client.js +228 -0
- package/dist/handoff/ucp-checkout/client.js.map +1 -0
- package/dist/handoff/ucp-checkout/endpoint.d.ts +36 -0
- package/dist/handoff/ucp-checkout/endpoint.js +145 -0
- package/dist/handoff/ucp-checkout/endpoint.js.map +1 -0
- package/dist/handoff/ucp-checkout/index.d.ts +35 -0
- package/dist/handoff/ucp-checkout/index.js +36 -0
- package/dist/handoff/ucp-checkout/index.js.map +1 -0
- package/dist/handoff/ucp-checkout/parse.d.ts +71 -0
- package/dist/handoff/ucp-checkout/parse.js +349 -0
- package/dist/handoff/ucp-checkout/parse.js.map +1 -0
- package/dist/handoff/ucp-checkout/totals.d.ts +41 -0
- package/dist/handoff/ucp-checkout/totals.js +36 -0
- package/dist/handoff/ucp-checkout/totals.js.map +1 -0
- package/dist/handoff/ucp-checkout/types.d.ts +149 -0
- package/dist/handoff/ucp-checkout/types.js +58 -0
- package/dist/handoff/ucp-checkout/types.js.map +1 -0
- package/dist/handoff/url-safety.d.ts +44 -0
- package/dist/handoff/url-safety.js +121 -0
- package/dist/handoff/url-safety.js.map +1 -0
- package/dist/i18n.d.ts +24 -0
- package/dist/i18n.js +27 -0
- package/dist/i18n.js.map +1 -0
- package/dist/negotiation/action-candidate.d.ts +97 -0
- package/dist/negotiation/action-candidate.js +160 -0
- package/dist/negotiation/action-candidate.js.map +1 -0
- package/dist/negotiation/condition/evaluator.d.ts +36 -0
- package/dist/negotiation/condition/evaluator.js +123 -0
- package/dist/negotiation/condition/evaluator.js.map +1 -0
- package/dist/negotiation/context-map/index.d.ts +23 -0
- package/dist/negotiation/context-map/index.js +22 -0
- package/dist/negotiation/context-map/index.js.map +1 -0
- package/dist/negotiation/context-map/store.d.ts +51 -0
- package/dist/negotiation/context-map/store.js +186 -0
- package/dist/negotiation/context-map/store.js.map +1 -0
- package/dist/negotiation/context-map/types.d.ts +29 -0
- package/dist/negotiation/context-map/types.js +57 -0
- package/dist/negotiation/context-map/types.js.map +1 -0
- package/dist/negotiation/domain/common.d.ts +95 -0
- package/dist/negotiation/domain/common.js +216 -0
- package/dist/negotiation/domain/common.js.map +1 -0
- package/dist/negotiation/domain/envelope.d.ts +55 -0
- package/dist/negotiation/domain/envelope.js +110 -0
- package/dist/negotiation/domain/envelope.js.map +1 -0
- package/dist/negotiation/domain/identifiers.d.ts +65 -0
- package/dist/negotiation/domain/identifiers.js +130 -0
- package/dist/negotiation/domain/identifiers.js.map +1 -0
- package/dist/negotiation/domain/objects.d.ts +149 -0
- package/dist/negotiation/domain/objects.js +335 -0
- package/dist/negotiation/domain/objects.js.map +1 -0
- package/dist/negotiation/idempotency/index.d.ts +26 -0
- package/dist/negotiation/idempotency/index.js +25 -0
- package/dist/negotiation/idempotency/index.js.map +1 -0
- package/dist/negotiation/idempotency/store.d.ts +52 -0
- package/dist/negotiation/idempotency/store.js +189 -0
- package/dist/negotiation/idempotency/store.js.map +1 -0
- package/dist/negotiation/idempotency/types.d.ts +102 -0
- package/dist/negotiation/idempotency/types.js +47 -0
- package/dist/negotiation/idempotency/types.js.map +1 -0
- package/dist/negotiation/jcs.d.ts +21 -0
- package/dist/negotiation/jcs.js +114 -0
- package/dist/negotiation/jcs.js.map +1 -0
- package/dist/negotiation/ledger/event.d.ts +142 -0
- package/dist/negotiation/ledger/event.js +206 -0
- package/dist/negotiation/ledger/event.js.map +1 -0
- package/dist/negotiation/ledger/index.d.ts +26 -0
- package/dist/negotiation/ledger/index.js +25 -0
- package/dist/negotiation/ledger/index.js.map +1 -0
- package/dist/negotiation/ledger/store.d.ts +97 -0
- package/dist/negotiation/ledger/store.js +338 -0
- package/dist/negotiation/ledger/store.js.map +1 -0
- package/dist/negotiation/prompt.d.ts +34 -0
- package/dist/negotiation/prompt.js +113 -0
- package/dist/negotiation/prompt.js.map +1 -0
- package/dist/negotiation/recovery/index.d.ts +26 -0
- package/dist/negotiation/recovery/index.js +24 -0
- package/dist/negotiation/recovery/index.js.map +1 -0
- package/dist/negotiation/recovery/outbound.d.ts +49 -0
- package/dist/negotiation/recovery/outbound.js +34 -0
- package/dist/negotiation/recovery/outbound.js.map +1 -0
- package/dist/negotiation/recovery/recover.d.ts +59 -0
- package/dist/negotiation/recovery/recover.js +486 -0
- package/dist/negotiation/recovery/recover.js.map +1 -0
- package/dist/negotiation/recovery/types.d.ts +85 -0
- package/dist/negotiation/recovery/types.js +17 -0
- package/dist/negotiation/recovery/types.js.map +1 -0
- package/dist/negotiation/state/phase.d.ts +70 -0
- package/dist/negotiation/state/phase.js +200 -0
- package/dist/negotiation/state/phase.js.map +1 -0
- package/dist/negotiation/types.d.ts +139 -0
- package/dist/negotiation/types.js +24 -0
- package/dist/negotiation/types.js.map +1 -0
- package/dist/net/safe-http.d.ts +54 -0
- package/dist/net/safe-http.js +116 -0
- package/dist/net/safe-http.js.map +1 -0
- package/dist/operator/controller.d.ts +181 -0
- package/dist/operator/controller.js +784 -0
- package/dist/operator/controller.js.map +1 -0
- package/dist/operator/runner.d.ts +128 -0
- package/dist/operator/runner.js +248 -0
- package/dist/operator/runner.js.map +1 -0
- package/dist/operator/store.d.ts +39 -0
- package/dist/operator/store.js +169 -0
- package/dist/operator/store.js.map +1 -0
- package/dist/operator/strategy.d.ts +54 -0
- package/dist/operator/strategy.js +249 -0
- package/dist/operator/strategy.js.map +1 -0
- package/dist/operator/tui.d.ts +27 -0
- package/dist/operator/tui.js +395 -0
- package/dist/operator/tui.js.map +1 -0
- package/dist/operator/types.d.ts +224 -0
- package/dist/operator/types.js +17 -0
- package/dist/operator/types.js.map +1 -0
- package/dist/product-buyer.d.ts +74 -0
- package/dist/product-buyer.js +161 -0
- package/dist/product-buyer.js.map +1 -0
- package/dist/product-cli.d.ts +56 -0
- package/dist/product-cli.js +175 -0
- package/dist/product-cli.js.map +1 -0
- package/dist/product-compat.d.ts +50 -0
- package/dist/product-compat.js +63 -0
- package/dist/product-compat.js.map +1 -0
- package/dist/product-init.d.ts +73 -0
- package/dist/product-init.js +203 -0
- package/dist/product-init.js.map +1 -0
- package/dist/product-publish.d.ts +85 -0
- package/dist/product-publish.js +216 -0
- package/dist/product-publish.js.map +1 -0
- package/dist/protocol/legacy-shopping-negotiation/adapter.d.ts +42 -0
- package/dist/protocol/legacy-shopping-negotiation/adapter.js +561 -0
- package/dist/protocol/legacy-shopping-negotiation/adapter.js.map +1 -0
- package/dist/protocol/legacy-shopping-negotiation/mapping.d.ts +78 -0
- package/dist/protocol/legacy-shopping-negotiation/mapping.js +321 -0
- package/dist/protocol/legacy-shopping-negotiation/mapping.js.map +1 -0
- package/dist/protocol/legacy-shopping-negotiation/money.d.ts +49 -0
- package/dist/protocol/legacy-shopping-negotiation/money.js +70 -0
- package/dist/protocol/legacy-shopping-negotiation/money.js.map +1 -0
- package/dist/protocol/legacy-shopping-negotiation/types.d.ts +107 -0
- package/dist/protocol/legacy-shopping-negotiation/types.js +34 -0
- package/dist/protocol/legacy-shopping-negotiation/types.js.map +1 -0
- package/dist/runtime/buyer-policy.d.ts +58 -0
- package/dist/runtime/buyer-policy.js +89 -0
- package/dist/runtime/buyer-policy.js.map +1 -0
- package/dist/runtime/fake-model.d.ts +77 -0
- package/dist/runtime/fake-model.js +307 -0
- package/dist/runtime/fake-model.js.map +1 -0
- package/dist/runtime/foreground.d.ts +56 -0
- package/dist/runtime/foreground.js +97 -0
- package/dist/runtime/foreground.js.map +1 -0
- package/dist/runtime/heartbeat.d.ts +36 -0
- package/dist/runtime/heartbeat.js +49 -0
- package/dist/runtime/heartbeat.js.map +1 -0
- package/dist/runtime/merchant-turn.d.ts +35 -0
- package/dist/runtime/merchant-turn.js +20 -0
- package/dist/runtime/merchant-turn.js.map +1 -0
- package/dist/runtime/model.d.ts +40 -0
- package/dist/runtime/model.js +86 -0
- package/dist/runtime/model.js.map +1 -0
- package/dist/runtime/negotiation-turn.d.ts +101 -0
- package/dist/runtime/negotiation-turn.js +317 -0
- package/dist/runtime/negotiation-turn.js.map +1 -0
- package/dist/runtime/tools.d.ts +64 -0
- package/dist/runtime/tools.js +236 -0
- package/dist/runtime/tools.js.map +1 -0
- package/dist/supervisor/init.d.ts +31 -0
- package/dist/supervisor/init.js +222 -0
- package/dist/supervisor/init.js.map +1 -0
- package/dist/supervisor/logs.d.ts +28 -0
- package/dist/supervisor/logs.js +101 -0
- package/dist/supervisor/logs.js.map +1 -0
- package/dist/supervisor/manage.d.ts +72 -0
- package/dist/supervisor/manage.js +419 -0
- package/dist/supervisor/manage.js.map +1 -0
- package/dist/supervisor/manifest.d.ts +69 -0
- package/dist/supervisor/manifest.js +209 -0
- package/dist/supervisor/manifest.js.map +1 -0
- package/dist/supervisor/stack-config.d.ts +79 -0
- package/dist/supervisor/stack-config.js +262 -0
- package/dist/supervisor/stack-config.js.map +1 -0
- package/dist/supervisor/wrapper.d.ts +17 -0
- package/dist/supervisor/wrapper.js +138 -0
- package/dist/supervisor/wrapper.js.map +1 -0
- package/dist/trust/identity/auth-verifier.d.ts +96 -0
- package/dist/trust/identity/auth-verifier.js +166 -0
- package/dist/trust/identity/auth-verifier.js.map +1 -0
- package/dist/trust/identity/identity-binding.d.ts +63 -0
- package/dist/trust/identity/identity-binding.js +59 -0
- package/dist/trust/identity/identity-binding.js.map +1 -0
- package/dist/trust/identity/index.d.ts +38 -0
- package/dist/trust/identity/index.js +31 -0
- package/dist/trust/identity/index.js.map +1 -0
- package/dist/trust/identity/jws.d.ts +64 -0
- package/dist/trust/identity/jws.js +178 -0
- package/dist/trust/identity/jws.js.map +1 -0
- package/dist/trust/identity/keys.d.ts +71 -0
- package/dist/trust/identity/keys.js +118 -0
- package/dist/trust/identity/keys.js.map +1 -0
- package/dist/trust/identity/message-signature.d.ts +105 -0
- package/dist/trust/identity/message-signature.js +297 -0
- package/dist/trust/identity/message-signature.js.map +1 -0
- package/dist/trust/identity/nonce.d.ts +45 -0
- package/dist/trust/identity/nonce.js +50 -0
- package/dist/trust/identity/nonce.js.map +1 -0
- package/dist/trust/identity/signature-base.d.ts +84 -0
- package/dist/trust/identity/signature-base.js +261 -0
- package/dist/trust/identity/signature-base.js.map +1 -0
- package/dist/trust/identity/trust-policy.d.ts +92 -0
- package/dist/trust/identity/trust-policy.js +95 -0
- package/dist/trust/identity/trust-policy.js.map +1 -0
- package/dist/trust/index.d.ts +21 -0
- package/dist/trust/index.js +22 -0
- package/dist/trust/index.js.map +1 -0
- package/dist/trust/records/evaluator.d.ts +76 -0
- package/dist/trust/records/evaluator.js +122 -0
- package/dist/trust/records/evaluator.js.map +1 -0
- package/dist/trust/records/index.d.ts +28 -0
- package/dist/trust/records/index.js +26 -0
- package/dist/trust/records/index.js.map +1 -0
- package/dist/trust/records/store.d.ts +75 -0
- package/dist/trust/records/store.js +339 -0
- package/dist/trust/records/store.js.map +1 -0
- package/dist/trust/records/types.d.ts +159 -0
- package/dist/trust/records/types.js +40 -0
- package/dist/trust/records/types.js.map +1 -0
- package/dist/tui/banner.d.ts +46 -0
- package/dist/tui/banner.js +99 -0
- package/dist/tui/banner.js.map +1 -0
- package/dist/tui/styles.d.ts +70 -0
- package/dist/tui/styles.js +197 -0
- package/dist/tui/styles.js.map +1 -0
- package/dist/tui/theme.d.ts +63 -0
- package/dist/tui/theme.js +136 -0
- package/dist/tui/theme.js.map +1 -0
- package/examples/profiles/buyer.deepseek.yaml +34 -0
- package/examples/profiles/buyer.fake.yaml +36 -0
- package/examples/profiles/buyer.local.yaml +40 -0
- package/examples/profiles/merchant.deepseek.yaml +32 -0
- package/examples/profiles/merchant.fake.yaml +31 -0
- package/examples/profiles/merchant.local.yaml +34 -0
- package/package.json +55 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* CounterpartyChannel 唯一接口(基线 §5 / §33 / §38 推荐结构)。
|
|
18
|
+
*
|
|
19
|
+
* 职责边界(§33):
|
|
20
|
+
* - AgentDiscovery 负责:domain → Agent Card → capability intersection →
|
|
21
|
+
* identity bootstrap → channel candidates;
|
|
22
|
+
* - CounterpartyChannel 负责:open / send / getState / subscribe / close。
|
|
23
|
+
*
|
|
24
|
+
* 本模块是三条通道(a2a-direct / shopping-cli-hosted / platform-api)与上层
|
|
25
|
+
* (recovery、未来 Negotiation Engine)之间的**唯一**接缝。WP3 recovery 的
|
|
26
|
+
* `CounterpartyChannel`(identity+url 二元组)在本 WP 收敛为此处定义的单接口,
|
|
27
|
+
* 不再有第二套契约。
|
|
28
|
+
*
|
|
29
|
+
* 不变量(基线 §4.6 Fail Closed / §36-21):
|
|
30
|
+
* - open 失败 / send 失败绝不由通道内部降级到权限更宽的通道;候选选择是
|
|
31
|
+
* 确定性的一次性决策(selectChannelCandidate),没有自动重试队列;
|
|
32
|
+
* - 未知状态 / 校验失败一律抛 ChannelError(fail-closed),不静默容错。
|
|
33
|
+
*/
|
|
34
|
+
import type { A2ATask, A2ATaskState } from "../a2a/client/index.js";
|
|
35
|
+
import type { NegotiationEnvelope } from "../negotiation/domain/envelope.js";
|
|
36
|
+
import type { PolicyResult } from "../negotiation/types.js";
|
|
37
|
+
import type { AgentCard } from "../discovery/agent-card/index.js";
|
|
38
|
+
import type { CapabilityIntersection } from "../discovery/capability/index.js";
|
|
39
|
+
import type { UcpIntersectionView } from "../discovery/ucp/intersect.js";
|
|
40
|
+
import type { UcpProfile } from "../discovery/ucp/types.js";
|
|
41
|
+
/** 通道种类(基线 §5 三个实现)。 */
|
|
42
|
+
export type ChannelKind = "a2a-direct" | "shopping-cli-hosted" | "platform-api";
|
|
43
|
+
/**
|
|
44
|
+
* 远端通道引用:negotiation + 该通道家族自己的锚点。
|
|
45
|
+
*
|
|
46
|
+
* direct 用 context_id/task_id;hosted 用 conversation_id/message_id。两组字段
|
|
47
|
+
* 分属两个通道家族,互不冲突。taskId 只是 transport/session 状态,不得替代
|
|
48
|
+
* negotiation_id(基线 §9.5)。
|
|
49
|
+
*/
|
|
50
|
+
export interface RemoteRef {
|
|
51
|
+
negotiation_id: string;
|
|
52
|
+
/** A2A contextId(direct,opaque,§9.2)。 */
|
|
53
|
+
context_id?: string;
|
|
54
|
+
/** A2A taskId(direct,§9.5)。 */
|
|
55
|
+
task_id?: string;
|
|
56
|
+
/** shopping-cli conversation_id(hosted)。 */
|
|
57
|
+
conversation_id?: string;
|
|
58
|
+
/** shopping-cli message_id(hosted)。 */
|
|
59
|
+
message_id?: number;
|
|
60
|
+
}
|
|
61
|
+
/** 打开通道的输入。open 把通道绑定到一个 negotiation 实例。 */
|
|
62
|
+
export interface ChannelOpenInput {
|
|
63
|
+
negotiation_id: string;
|
|
64
|
+
/** 本方(Kiwi)身份 —— Ledger identity 的 sender 侧。 */
|
|
65
|
+
sender_identity: string;
|
|
66
|
+
/** 对端身份 —— 协议幂等键的 counterparty 侧。 */
|
|
67
|
+
identity: string;
|
|
68
|
+
/** 初始远端锚点(可选;direct 首次 send 后获得 taskId;hosted 打开即绑定会话)。 */
|
|
69
|
+
remote?: {
|
|
70
|
+
context_id?: string;
|
|
71
|
+
task_id?: string;
|
|
72
|
+
conversation_id?: string;
|
|
73
|
+
message_id?: number;
|
|
74
|
+
};
|
|
75
|
+
/** 打开/请求超时 ms。 */
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
}
|
|
78
|
+
/** send 的输入:KNP envelope + 目标引用。 */
|
|
79
|
+
export interface ChannelSendInput {
|
|
80
|
+
envelope: NegotiationEnvelope;
|
|
81
|
+
ref?: RemoteRef;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* send 结果。成功返回结构化结果;硬失败(网络 / 校验 / 权限)一律抛 ChannelError。
|
|
85
|
+
* direct 通道带 `task`;hosted 通道带 `policy`。
|
|
86
|
+
*/
|
|
87
|
+
export interface ChannelSendResult {
|
|
88
|
+
channel: ChannelKind;
|
|
89
|
+
/** 发送后应更新的远端锚点。 */
|
|
90
|
+
ref: RemoteRef;
|
|
91
|
+
/** direct:message/send 的远端任务。 */
|
|
92
|
+
task?: A2ATask;
|
|
93
|
+
/** hosted:策略结果(accepted / rejected_retryable / human_required)。 */
|
|
94
|
+
policy?: PolicyResult;
|
|
95
|
+
/** 幂等重放:true 表示未重复发送,返回先前结果(§17 / §20)。 */
|
|
96
|
+
replayed?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 远端稳定观察点(getState)。`state` 是权威状态值:
|
|
100
|
+
* - direct:A2A task state(§18.3);
|
|
101
|
+
* - hosted:shopping-cli conversation status(§21 Authority Model:
|
|
102
|
+
* authoritative snapshot > local cache > reasoning state)。
|
|
103
|
+
*/
|
|
104
|
+
export interface RemoteState {
|
|
105
|
+
channel: ChannelKind;
|
|
106
|
+
/** 权威状态值。 */
|
|
107
|
+
state: string;
|
|
108
|
+
/** 是否为稳定观察点(终态或等待输入)。 */
|
|
109
|
+
stable: boolean;
|
|
110
|
+
/** direct:A2A Task 视图。 */
|
|
111
|
+
task?: A2ATask;
|
|
112
|
+
/** hosted:shopping-cli 权威快照(§21)。 */
|
|
113
|
+
snapshot?: import("../negotiation/types.js").NegotiationSnapshot;
|
|
114
|
+
/** 远端可见 messageId 集合(recovery 比对 acknowledged messages)。 */
|
|
115
|
+
message_ids: string[];
|
|
116
|
+
observed_at: string;
|
|
117
|
+
}
|
|
118
|
+
export type RemoteEventKind = "state_changed" | "message_received" | "error";
|
|
119
|
+
/** 异步推送/轮询事件(§33 subscribe)。 */
|
|
120
|
+
export interface RemoteEvent {
|
|
121
|
+
channel: ChannelKind;
|
|
122
|
+
kind: RemoteEventKind;
|
|
123
|
+
ref: RemoteRef;
|
|
124
|
+
state?: RemoteState;
|
|
125
|
+
message_id?: string;
|
|
126
|
+
error?: ChannelError;
|
|
127
|
+
}
|
|
128
|
+
export type ChannelEventHandler = (event: RemoteEvent) => void | Promise<void>;
|
|
129
|
+
export type Unsubscribe = () => void | Promise<void>;
|
|
130
|
+
/** 通道打开后的操作面。open 后持有该 handle 执行 send/getState/subscribe/close。 */
|
|
131
|
+
export interface ChannelHandle {
|
|
132
|
+
readonly kind: ChannelKind;
|
|
133
|
+
/** 对端身份(open 时绑定)。 */
|
|
134
|
+
readonly identity: string;
|
|
135
|
+
send(input: ChannelSendInput): Promise<ChannelSendResult>;
|
|
136
|
+
getState(ref: RemoteRef): Promise<RemoteState>;
|
|
137
|
+
/** 无 subscribe 的通道通过 getState 轮询(§33)。 */
|
|
138
|
+
subscribe?(ref: RemoteRef, handler: ChannelEventHandler): Promise<Unsubscribe>;
|
|
139
|
+
close(): Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
/** CounterpartyChannel 工厂接口:open 打开一条绑定到 negotiation 的通道。 */
|
|
142
|
+
export interface CounterpartyChannel {
|
|
143
|
+
readonly kind: ChannelKind;
|
|
144
|
+
open(input: ChannelOpenInput): Promise<ChannelHandle>;
|
|
145
|
+
}
|
|
146
|
+
export declare const CHANNEL_ERROR_CODES: readonly ["no_channel_candidate", "channel_closed", "invalid_envelope", "idempotency_conflict", "send_failed", "get_state_failed", "unsupported_action", "commerce_client_not_configured", "platform_not_configured", "not_implemented"];
|
|
147
|
+
export type ChannelErrorCode = (typeof CHANNEL_ERROR_CODES)[number];
|
|
148
|
+
/** 通道层失败。带通道 kind 与协议错误码;fail-closed,绝不静默降级。 */
|
|
149
|
+
export declare class ChannelError extends Error {
|
|
150
|
+
readonly channel: ChannelKind;
|
|
151
|
+
readonly code: ChannelErrorCode;
|
|
152
|
+
constructor(channel: ChannelKind, code: ChannelErrorCode, message: string);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 通道候选(§33 AgentDiscovery 产出)。数组顺序即优先序:
|
|
156
|
+
* a2a-direct → shopping-cli-hosted → platform-api。每个候选携带构造所需的最小配置。
|
|
157
|
+
*/
|
|
158
|
+
export interface ChannelCandidate {
|
|
159
|
+
kind: ChannelKind;
|
|
160
|
+
/** a2a-direct:capability intersection 选中的远端 endpoint URL。 */
|
|
161
|
+
url?: string;
|
|
162
|
+
/** shopping-cli-hosted:本地配置的 commerce 服务标识(供 deps.commerce 解析)。 */
|
|
163
|
+
config_id?: string;
|
|
164
|
+
/** platform-api:平台凭证引用(fail-closed,必须显式配置)。 */
|
|
165
|
+
credential_ref?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* 解析出的对端通道档案(§33 AgentDiscovery 第 1–5 步的产物)。
|
|
169
|
+
* resolveCounterparty(recovery)/ 未来 Negotiation Engine 只依赖此档案 + open。
|
|
170
|
+
*/
|
|
171
|
+
export interface CounterpartyProfile {
|
|
172
|
+
/** 对端身份(协议幂等键 counterparty 侧;来自 Agent Card provider/name)。 */
|
|
173
|
+
identity: string;
|
|
174
|
+
/** 解析来源:`domain:<host>` 或 `card:<url>`。 */
|
|
175
|
+
source: string;
|
|
176
|
+
/** 拉取并校验后的 Agent Card(结构校验 + secret 扫描,不变量 24)。 */
|
|
177
|
+
agent_card: AgentCard;
|
|
178
|
+
/** 双方 capability intersection(§33)。 */
|
|
179
|
+
intersection: CapabilityIntersection;
|
|
180
|
+
/** 按优先序排列的通道候选。 */
|
|
181
|
+
channel_candidates: ChannelCandidate[];
|
|
182
|
+
/**
|
|
183
|
+
* WP3:双方 UCP capability intersection(§3.2 / §25),与 A2A binding
|
|
184
|
+
* `intersection` 两个维度并存。UCP 优先路径成功且配置了 platform 侧
|
|
185
|
+
* localProfile 时存在。
|
|
186
|
+
*/
|
|
187
|
+
ucp_intersection?: UcpIntersectionView;
|
|
188
|
+
/** WP3:解析出的对端 UCP profile(UCP 优先路径成功时存在)。 */
|
|
189
|
+
ucp_profile?: UcpProfile;
|
|
190
|
+
/** WP3:UCP 优先路径失败时的回退原因(已回退到 well-known Agent Card)。 */
|
|
191
|
+
ucp_fallback_reason?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 确定性选择首选候选(§33 / 不变量 21):按 direct → hosted → platform 的固定
|
|
195
|
+
* 顺序取第一个可用候选。这是**一次性**决策——调用方不得在后续失败时自动退到
|
|
196
|
+
* 更宽的候选(不变量 21)。
|
|
197
|
+
*/
|
|
198
|
+
export declare function selectChannelCandidate(profile: CounterpartyProfile): ChannelCandidate | null;
|
|
199
|
+
/** 便捷断言:把 A2A task 状态归一化为 RemoteState(direct 通道内部用)。 */
|
|
200
|
+
export declare function isStableTaskState(state: A2ATaskState): boolean;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/** 通道候选的确定性优先序(§33:A2A 可用 → direct;否则 hosted;都没有 fail-closed)。 */
|
|
17
|
+
const CHANNEL_PREFERENCE = ["a2a-direct", "shopping-cli-hosted", "platform-api"];
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// ChannelError
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
export const CHANNEL_ERROR_CODES = [
|
|
22
|
+
"no_channel_candidate",
|
|
23
|
+
"channel_closed",
|
|
24
|
+
"invalid_envelope",
|
|
25
|
+
"idempotency_conflict",
|
|
26
|
+
"send_failed",
|
|
27
|
+
"get_state_failed",
|
|
28
|
+
"unsupported_action",
|
|
29
|
+
"commerce_client_not_configured",
|
|
30
|
+
"platform_not_configured",
|
|
31
|
+
"not_implemented",
|
|
32
|
+
];
|
|
33
|
+
/** 通道层失败。带通道 kind 与协议错误码;fail-closed,绝不静默降级。 */
|
|
34
|
+
export class ChannelError extends Error {
|
|
35
|
+
channel;
|
|
36
|
+
code;
|
|
37
|
+
constructor(channel, code, message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "ChannelError";
|
|
40
|
+
this.channel = channel;
|
|
41
|
+
this.code = code;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 确定性选择首选候选(§33 / 不变量 21):按 direct → hosted → platform 的固定
|
|
46
|
+
* 顺序取第一个可用候选。这是**一次性**决策——调用方不得在后续失败时自动退到
|
|
47
|
+
* 更宽的候选(不变量 21)。
|
|
48
|
+
*/
|
|
49
|
+
export function selectChannelCandidate(profile) {
|
|
50
|
+
const rank = new Map(CHANNEL_PREFERENCE.map((k, i) => [k, i]));
|
|
51
|
+
const ordered = [...profile.channel_candidates].sort((a, b) => (rank.get(a.kind) ?? Number.POSITIVE_INFINITY) - (rank.get(b.kind) ?? Number.POSITIVE_INFINITY));
|
|
52
|
+
return ordered[0] ?? null;
|
|
53
|
+
}
|
|
54
|
+
/** 便捷断言:把 A2A task 状态归一化为 RemoteState(direct 通道内部用)。 */
|
|
55
|
+
export function isStableTaskState(state) {
|
|
56
|
+
return (state === "completed" ||
|
|
57
|
+
state === "canceled" ||
|
|
58
|
+
state === "failed" ||
|
|
59
|
+
state === "input-required");
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/counterparty/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgCH,kEAAkE;AAClE,MAAM,kBAAkB,GAA2B,CAAC,YAAY,EAAE,qBAAqB,EAAE,cAAc,CAAC,CAAC;AAmHzG,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,sBAAsB;IACtB,gBAAgB;IAChB,kBAAkB;IAClB,sBAAsB;IACtB,aAAa;IACb,kBAAkB;IAClB,oBAAoB;IACpB,gCAAgC;IAChC,yBAAyB;IACzB,iBAAiB;CACT,CAAC;AAGX,gDAAgD;AAChD,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,OAAO,CAAc;IACrB,IAAI,CAAmB;IAChC,YAAY,OAAoB,EAAE,IAAsB,EAAE,OAAe;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AA+CD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA4B;IACjE,MAAM,IAAI,GAAG,IAAI,GAAG,CAAsB,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAClD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAC1G,CAAC;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACnD,OAAO,CACL,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,QAAQ;QAClB,KAAK,KAAK,gBAAgB,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* counterparty — CounterpartyChannel 唯一接口 + 三个实现(基线 §5 / §33 / §38)。
|
|
18
|
+
*/
|
|
19
|
+
export { CHANNEL_ERROR_CODES, ChannelError, isStableTaskState, selectChannelCandidate, } from "./channel.js";
|
|
20
|
+
export type { ChannelCandidate, ChannelErrorCode, ChannelEventHandler, ChannelHandle, ChannelKind, ChannelOpenInput, ChannelSendInput, ChannelSendResult, CounterpartyChannel, CounterpartyProfile, RemoteEvent, RemoteEventKind, RemoteRef, RemoteState, Unsubscribe, } from "./channel.js";
|
|
21
|
+
export { A2ADirectChannel } from "./a2a-direct/index.js";
|
|
22
|
+
export type { A2ADirectChannelOptions } from "./a2a-direct/index.js";
|
|
23
|
+
export { ShoppingCliHostedChannel } from "./shopping-cli-hosted/index.js";
|
|
24
|
+
export type { ShoppingCliHostedChannelOptions } from "./shopping-cli-hosted/index.js";
|
|
25
|
+
export { PlatformApiChannel } from "./platform-api/index.js";
|
|
26
|
+
export type { PlatformApiChannelOptions } from "./platform-api/index.js";
|
|
27
|
+
export { openChannel } from "./registry.js";
|
|
28
|
+
export type { ChannelRuntimeDeps } from "./registry.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* counterparty — CounterpartyChannel 唯一接口 + 三个实现(基线 §5 / §33 / §38)。
|
|
18
|
+
*/
|
|
19
|
+
export { CHANNEL_ERROR_CODES, ChannelError, isStableTaskState, selectChannelCandidate, } from "./channel.js";
|
|
20
|
+
export { A2ADirectChannel } from "./a2a-direct/index.js";
|
|
21
|
+
export { ShoppingCliHostedChannel } from "./shopping-cli-hosted/index.js";
|
|
22
|
+
export { PlatformApiChannel } from "./platform-api/index.js";
|
|
23
|
+
export { openChannel } from "./registry.js";
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/counterparty/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AAEH,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAmBtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* PlatformApiChannel — 平台 API 通道占位(基线 §5 / §33)。
|
|
18
|
+
*
|
|
19
|
+
* 本 WP 只落地接口占位 + fail-closed 默认实现(基线 §4.6 / §36):
|
|
20
|
+
*
|
|
21
|
+
* - 未配置平台凭证(configured=false)→ open 抛 ChannelError("platform_not_configured"),
|
|
22
|
+
* 绝不静默降级到 hosted/direct(不变量 21);
|
|
23
|
+
* - 已配置但实现尚未接线(未来 WP)→ send/getState 抛 ChannelError("not_implemented")。
|
|
24
|
+
*
|
|
25
|
+
* 平台 API 是权限最宽的通道(可能触碰平台侧订单/支付面),因此 fail-closed
|
|
26
|
+
* 语义最严格:宁可拒绝,不猜、不降级。
|
|
27
|
+
*/
|
|
28
|
+
import { type ChannelHandle, type ChannelOpenInput, type CounterpartyChannel } from "../channel.js";
|
|
29
|
+
export interface PlatformApiChannelOptions {
|
|
30
|
+
/** 是否已配置平台凭证。缺省 false(fail-closed)。 */
|
|
31
|
+
configured?: boolean;
|
|
32
|
+
/** 平台凭证引用(仅元数据,不承载 secret;不变量 24)。 */
|
|
33
|
+
credentialRef?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare class PlatformApiChannel implements CounterpartyChannel {
|
|
36
|
+
readonly kind: "platform-api";
|
|
37
|
+
private readonly configured;
|
|
38
|
+
private readonly credentialRef?;
|
|
39
|
+
constructor(options?: PlatformApiChannelOptions);
|
|
40
|
+
open(input: ChannelOpenInput): Promise<ChannelHandle>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* PlatformApiChannel — 平台 API 通道占位(基线 §5 / §33)。
|
|
18
|
+
*
|
|
19
|
+
* 本 WP 只落地接口占位 + fail-closed 默认实现(基线 §4.6 / §36):
|
|
20
|
+
*
|
|
21
|
+
* - 未配置平台凭证(configured=false)→ open 抛 ChannelError("platform_not_configured"),
|
|
22
|
+
* 绝不静默降级到 hosted/direct(不变量 21);
|
|
23
|
+
* - 已配置但实现尚未接线(未来 WP)→ send/getState 抛 ChannelError("not_implemented")。
|
|
24
|
+
*
|
|
25
|
+
* 平台 API 是权限最宽的通道(可能触碰平台侧订单/支付面),因此 fail-closed
|
|
26
|
+
* 语义最严格:宁可拒绝,不猜、不降级。
|
|
27
|
+
*/
|
|
28
|
+
import { ChannelError, } from "../channel.js";
|
|
29
|
+
export class PlatformApiChannel {
|
|
30
|
+
kind = "platform-api";
|
|
31
|
+
configured;
|
|
32
|
+
credentialRef;
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
this.configured = options.configured ?? false;
|
|
35
|
+
this.credentialRef = options.credentialRef;
|
|
36
|
+
}
|
|
37
|
+
async open(input) {
|
|
38
|
+
if (!this.configured) {
|
|
39
|
+
throw new ChannelError("platform-api", "platform_not_configured", "platform-api channel is not configured (no platform credentials); refusing to open (fail-closed, no silent downgrade)");
|
|
40
|
+
}
|
|
41
|
+
return new PlatformApiHandle(input.identity, this.credentialRef);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class PlatformApiHandle {
|
|
45
|
+
kind = "platform-api";
|
|
46
|
+
identity;
|
|
47
|
+
credentialRef;
|
|
48
|
+
constructor(identity, credentialRef) {
|
|
49
|
+
this.identity = identity;
|
|
50
|
+
this.credentialRef = credentialRef;
|
|
51
|
+
}
|
|
52
|
+
notImplemented() {
|
|
53
|
+
return new ChannelError("platform-api", "not_implemented", `platform-api integration is not implemented (credential_ref=${this.credentialRef ?? "none"}); fail-closed`);
|
|
54
|
+
}
|
|
55
|
+
async send() {
|
|
56
|
+
throw this.notImplemented();
|
|
57
|
+
}
|
|
58
|
+
async getState() {
|
|
59
|
+
throw this.notImplemented();
|
|
60
|
+
}
|
|
61
|
+
async close() {
|
|
62
|
+
// 占位:无资源需释放。
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/counterparty/platform-api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,YAAY,GAIb,MAAM,eAAe,CAAC;AASvB,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAG,cAAuB,CAAC;IACvB,UAAU,CAAU;IACpB,aAAa,CAAU;IAExC,YAAY,UAAqC,EAAE;QACjD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAuB;QAChC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,YAAY,CACpB,cAAc,EACd,yBAAyB,EACzB,uHAAuH,CACxH,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACnE,CAAC;CACF;AAED,MAAM,iBAAiB;IACZ,IAAI,GAAG,cAAuB,CAAC;IAC/B,QAAQ,CAAS;IACT,aAAa,CAAU;IAExC,YAAY,QAAgB,EAAE,aAAsB;QAClD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEO,cAAc;QACpB,OAAO,IAAI,YAAY,CACrB,cAAc,EACd,iBAAiB,EACjB,+DAA+D,IAAI,CAAC,aAAa,IAAI,MAAM,gBAAgB,CAC5G,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,aAAa;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* CounterpartyChannel 注册/装配:CounterpartyProfile → 具体通道实例。
|
|
18
|
+
*
|
|
19
|
+
* 候选选择是一次性确定性决策(selectChannelCandidate,§33):direct → hosted →
|
|
20
|
+
* platform。**不提供失败后自动退到更宽候选的机制**(不变量 21)——一旦选定
|
|
21
|
+
* direct,其 send/getState 失败就向上抛 ChannelError,绝不静默降级。
|
|
22
|
+
*/
|
|
23
|
+
import type { CommerceClient } from "../commerce/types.js";
|
|
24
|
+
import type { IdempotencyStore } from "../negotiation/idempotency/index.js";
|
|
25
|
+
import type { LedgerStore } from "../negotiation/ledger/index.js";
|
|
26
|
+
import { type ChannelHandle, type ChannelOpenInput, type CounterpartyProfile } from "./channel.js";
|
|
27
|
+
/** 装配通道所需的运行时依赖。 */
|
|
28
|
+
export interface ChannelRuntimeDeps {
|
|
29
|
+
ledger?: LedgerStore;
|
|
30
|
+
idempotency?: IdempotencyStore;
|
|
31
|
+
/** hosted commerce client 提供者(按 config_id 解析);返回 null 表示未配置。 */
|
|
32
|
+
commerce?: (configId: string | undefined) => CommerceClient | null;
|
|
33
|
+
/** platform 凭证状态(fail-closed)。 */
|
|
34
|
+
platform?: {
|
|
35
|
+
configured: boolean;
|
|
36
|
+
credentialRef?: string;
|
|
37
|
+
};
|
|
38
|
+
now?: () => string;
|
|
39
|
+
fetchImpl?: typeof fetch;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 从 profile 打开一条通道(确定性选择首选候选,失败不降级)。
|
|
44
|
+
*
|
|
45
|
+
* 失败路径抛 ChannelError:
|
|
46
|
+
* - 无可用候选 → no_channel_candidate;
|
|
47
|
+
* - a2a-direct 候选缺 url → no_channel_candidate;
|
|
48
|
+
* - hosted 候选但未配置 commerce client → commerce_client_not_configured;
|
|
49
|
+
* - platform 候选但未配置凭证 → platform_not_configured。
|
|
50
|
+
*/
|
|
51
|
+
export declare function openChannel(profile: CounterpartyProfile, deps: ChannelRuntimeDeps, input: ChannelOpenInput): Promise<ChannelHandle>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ChannelError, selectChannelCandidate, } from "./channel.js";
|
|
17
|
+
import { A2ADirectChannel } from "./a2a-direct/index.js";
|
|
18
|
+
import { ShoppingCliHostedChannel } from "./shopping-cli-hosted/index.js";
|
|
19
|
+
import { PlatformApiChannel } from "./platform-api/index.js";
|
|
20
|
+
/**
|
|
21
|
+
* 从 profile 打开一条通道(确定性选择首选候选,失败不降级)。
|
|
22
|
+
*
|
|
23
|
+
* 失败路径抛 ChannelError:
|
|
24
|
+
* - 无可用候选 → no_channel_candidate;
|
|
25
|
+
* - a2a-direct 候选缺 url → no_channel_candidate;
|
|
26
|
+
* - hosted 候选但未配置 commerce client → commerce_client_not_configured;
|
|
27
|
+
* - platform 候选但未配置凭证 → platform_not_configured。
|
|
28
|
+
*/
|
|
29
|
+
export async function openChannel(profile, deps, input) {
|
|
30
|
+
const candidate = selectChannelCandidate(profile);
|
|
31
|
+
if (candidate === null) {
|
|
32
|
+
throw new ChannelError("platform-api", "no_channel_candidate", `no usable channel candidate for counterparty ${profile.identity}`);
|
|
33
|
+
}
|
|
34
|
+
switch (candidate.kind) {
|
|
35
|
+
case "a2a-direct": {
|
|
36
|
+
if (candidate.url === undefined) {
|
|
37
|
+
throw new ChannelError("a2a-direct", "no_channel_candidate", "a2a-direct candidate is missing url");
|
|
38
|
+
}
|
|
39
|
+
const channel = new A2ADirectChannel({
|
|
40
|
+
url: candidate.url,
|
|
41
|
+
ledger: deps.ledger,
|
|
42
|
+
idempotency: deps.idempotency,
|
|
43
|
+
now: deps.now,
|
|
44
|
+
fetchImpl: deps.fetchImpl,
|
|
45
|
+
timeoutMs: deps.timeoutMs ?? input.timeoutMs,
|
|
46
|
+
});
|
|
47
|
+
return channel.open(input);
|
|
48
|
+
}
|
|
49
|
+
case "shopping-cli-hosted": {
|
|
50
|
+
const client = deps.commerce?.(candidate.config_id) ?? null;
|
|
51
|
+
if (client === null) {
|
|
52
|
+
throw new ChannelError("shopping-cli-hosted", "commerce_client_not_configured", "shopping-cli-hosted candidate selected but no commerce client is configured (config_id=" +
|
|
53
|
+
`${candidate.config_id ?? "default"})`);
|
|
54
|
+
}
|
|
55
|
+
const channel = new ShoppingCliHostedChannel({
|
|
56
|
+
client,
|
|
57
|
+
ledger: deps.ledger,
|
|
58
|
+
now: deps.now,
|
|
59
|
+
});
|
|
60
|
+
return channel.open(input);
|
|
61
|
+
}
|
|
62
|
+
case "platform-api": {
|
|
63
|
+
const channel = new PlatformApiChannel({
|
|
64
|
+
configured: deps.platform?.configured ?? false,
|
|
65
|
+
credentialRef: deps.platform?.credentialRef ?? candidate.credential_ref,
|
|
66
|
+
});
|
|
67
|
+
return channel.open(input);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/counterparty/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,EACL,YAAY,EACZ,sBAAsB,GAIvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAe7D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAA4B,EAC5B,IAAwB,EACxB,KAAuB;IAEvB,MAAM,SAAS,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,YAAY,CACpB,cAAc,EACd,sBAAsB,EACtB,gDAAgD,OAAO,CAAC,QAAQ,EAAE,CACnE,CAAC;IACJ,CAAC;IAED,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,YAAY,CAAC,CAAC,CAAC;YAClB,IAAI,SAAS,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,YAAY,CAAC,YAAY,EAAE,sBAAsB,EAAE,qCAAqC,CAAC,CAAC;YACtG,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;gBACnC,GAAG,EAAE,SAAS,CAAC,GAAG;gBAClB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS;aAC7C,CAAC,CAAC;YACH,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,qBAAqB,CAAC,CAAC,CAAC;YAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;YAC5D,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,MAAM,IAAI,YAAY,CACpB,qBAAqB,EACrB,gCAAgC,EAChC,yFAAyF;oBACvF,GAAG,SAAS,CAAC,SAAS,IAAI,SAAS,GAAG,CACzC,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,wBAAwB,CAAC;gBAC3C,MAAM;gBACN,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,EAAE,IAAI,CAAC,GAAG;aACd,CAAC,CAAC;YACH,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,cAAc,CAAC,CAAC,CAAC;YACpB,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC;gBACrC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,IAAI,KAAK;gBAC9C,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE,aAAa,IAAI,SAAS,CAAC,cAAc;aACxE,CAAC,CAAC;YACH,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { CommerceClient } from "../../commerce/types.js";
|
|
17
|
+
import type { LedgerStore } from "../../negotiation/ledger/index.js";
|
|
18
|
+
import { type ChannelHandle, type ChannelOpenInput, type CounterpartyChannel } from "../channel.js";
|
|
19
|
+
export interface ShoppingCliHostedChannelOptions {
|
|
20
|
+
/** shopping-cli 客户端(HttpCommerceClient / FakeCommerceClient)。 */
|
|
21
|
+
client: CommerceClient;
|
|
22
|
+
ledger?: LedgerStore;
|
|
23
|
+
now?: () => string;
|
|
24
|
+
/** 本方 agent 标识(幂等键前缀);缺省 "kiwi.hosted"。 */
|
|
25
|
+
agentId?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class ShoppingCliHostedChannel implements CounterpartyChannel {
|
|
28
|
+
readonly kind: "shopping-cli-hosted";
|
|
29
|
+
private readonly client;
|
|
30
|
+
private readonly ledger?;
|
|
31
|
+
private readonly now;
|
|
32
|
+
private readonly agentId;
|
|
33
|
+
private readonly adapter;
|
|
34
|
+
constructor(options: ShoppingCliHostedChannelOptions);
|
|
35
|
+
open(input: ChannelOpenInput): Promise<ChannelHandle>;
|
|
36
|
+
}
|