@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,149 @@
|
|
|
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
|
+
* Kiwi v0.7.0 Transaction Handoff(WP2)— UCP Checkout 协议类型(UCP 2026-04-08
|
|
18
|
+
* checkout spec family,基线 §3.2 / §43)。
|
|
19
|
+
*
|
|
20
|
+
* UCP Checkout REST binding:`{endpoint}/checkout-sessions`(Create/Get/Update/
|
|
21
|
+
* Complete/Cancel)。响应判别走 `ucp.status`:
|
|
22
|
+
* - success:body 就是 checkout 资源本体(含 status/session_id/totals/messages…);
|
|
23
|
+
* - error:无资源本体,只有 messages + continue_url。
|
|
24
|
+
*
|
|
25
|
+
* 本模块只建模类型与常量;运行时解析在 parse.ts,网络面在 client.ts。
|
|
26
|
+
* 零新增依赖。
|
|
27
|
+
*/
|
|
28
|
+
import type { HandoffSession } from "../channel.js";
|
|
29
|
+
/** UCP checkout spec family 日期(§43 pin)。 */
|
|
30
|
+
export declare const UCP_CHECKOUT_SPEC_VERSION: "2026-04-08";
|
|
31
|
+
/** expires_at 缺省值:创建后 6 小时(spec 事实)。 */
|
|
32
|
+
export declare const DEFAULT_EXPIRY_MS: number;
|
|
33
|
+
export declare const UCP_CHECKOUT_STATUSES: readonly ["incomplete", "requires_escalation", "ready_for_complete", "complete_in_progress", "completed", "canceled"];
|
|
34
|
+
export type UcpCheckoutStatus = (typeof UCP_CHECKOUT_STATUSES)[number];
|
|
35
|
+
export declare const UCP_MESSAGE_TYPES: readonly ["error", "warning", "info"];
|
|
36
|
+
export type UcpMessageType = (typeof UCP_MESSAGE_TYPES)[number];
|
|
37
|
+
export declare const UCP_MESSAGE_SEVERITIES: readonly ["recoverable", "requires_buyer_input", "requires_buyer_review", "unrecoverable"];
|
|
38
|
+
export type UcpMessageSeverity = (typeof UCP_MESSAGE_SEVERITIES)[number];
|
|
39
|
+
/** checkout messages[](type + severity 是算法输入;requires_* 汇聚为 requires_escalation)。 */
|
|
40
|
+
export interface UcpCheckoutMessage {
|
|
41
|
+
type: UcpMessageType;
|
|
42
|
+
severity: UcpMessageSeverity;
|
|
43
|
+
/** 标准错误码(out_of_stock / item_unavailable / payment_failed / eligibility_invalid …)。 */
|
|
44
|
+
code?: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
/** forward-compat:未知字段保留。 */
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/** links[](privacy_policy / terms_of_service 等)——合规必需,解析保留。 */
|
|
50
|
+
export interface UcpCheckoutLink {
|
|
51
|
+
rel: string;
|
|
52
|
+
href: string;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* totals:business 权威,platform MUST NOT 自行计算替代;MAY 校验
|
|
57
|
+
* `非 total 各项之和 == total`(totals.ts)。金额一律整数 minor units。
|
|
58
|
+
*/
|
|
59
|
+
export interface UcpCheckoutTotals {
|
|
60
|
+
currency: string;
|
|
61
|
+
items_total?: number;
|
|
62
|
+
tax?: number;
|
|
63
|
+
shipping?: number;
|
|
64
|
+
discount?: number;
|
|
65
|
+
total: number;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
export interface UcpCheckoutLineItem {
|
|
69
|
+
sku: string;
|
|
70
|
+
quantity: number;
|
|
71
|
+
unit_price?: {
|
|
72
|
+
currency: string;
|
|
73
|
+
amount_minor: number;
|
|
74
|
+
};
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* UCP checkout 资源本体(success 响应)。payment 对象可选——本实现 complete
|
|
79
|
+
* 不构造任何支付凭据,只传 authorization 证据引用;payment/links 解析保留。
|
|
80
|
+
*/
|
|
81
|
+
export interface UcpCheckoutSession {
|
|
82
|
+
ucp: {
|
|
83
|
+
status: "success";
|
|
84
|
+
version: string;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
status: UcpCheckoutStatus;
|
|
88
|
+
session_id: string;
|
|
89
|
+
expires_at?: string;
|
|
90
|
+
line_items?: UcpCheckoutLineItem[];
|
|
91
|
+
totals?: UcpCheckoutTotals;
|
|
92
|
+
messages?: UcpCheckoutMessage[];
|
|
93
|
+
continue_url?: string;
|
|
94
|
+
payment?: Record<string, unknown>;
|
|
95
|
+
links?: UcpCheckoutLink[];
|
|
96
|
+
authorization_reference?: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
/** UCP error 响应:无资源本体,只有 messages + continue_url。 */
|
|
100
|
+
export interface UcpCheckoutErrorResponse {
|
|
101
|
+
ucp: {
|
|
102
|
+
status: "error";
|
|
103
|
+
version: string;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
};
|
|
106
|
+
messages: UcpCheckoutMessage[];
|
|
107
|
+
continue_url?: string;
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
/** 判别联合:`response.ucp.status === "success" | "error"`。 */
|
|
111
|
+
export type UcpCheckoutResponse = UcpCheckoutSession | UcpCheckoutErrorResponse;
|
|
112
|
+
/** fail_closed 结果的结构化上报码(tests 与上层据此分支,不回退到字符串匹配)。 */
|
|
113
|
+
export declare const UCP_CHECKOUT_FAILURE_CODES: readonly ["invalid_package", "invalid_terms", "invalid_quantity", "session_not_found", "session_not_actionable", "session_expired", "not_ready", "gate_denied", "totals_mismatch", "recoverable", "unrecoverable", "unsafe_target", "timeout", "network", "bad_status", "malformed", "cart_not_found", "cart_not_actionable", "cart_capability_unavailable"];
|
|
114
|
+
export type UcpCheckoutFailureCode = (typeof UCP_CHECKOUT_FAILURE_CODES)[number];
|
|
115
|
+
/**
|
|
116
|
+
* UcpCheckoutChannel 的结构化结果。兼容 HandoffChannel 三形态(HandoffResult),
|
|
117
|
+
* 每个成员都是对应 HandoffResult 成员的超集:
|
|
118
|
+
* ok —— 操作成功,携带本地 session 投影 + 远端 checkout;
|
|
119
|
+
* fail_closed —— 明确拒绝(retryable:true 表示「改输入重试」,不自动死循环);
|
|
120
|
+
* requires_user —— 需要用户介入外部 checkout(continue_url 指向可信 UI)。
|
|
121
|
+
*/
|
|
122
|
+
export type UcpCheckoutResult = {
|
|
123
|
+
status: "ok";
|
|
124
|
+
session_ref: string;
|
|
125
|
+
session: HandoffSession;
|
|
126
|
+
continue_url?: string;
|
|
127
|
+
checkout: UcpCheckoutSession;
|
|
128
|
+
checkout_status: UcpCheckoutStatus;
|
|
129
|
+
} | {
|
|
130
|
+
status: "fail_closed";
|
|
131
|
+
reason: string;
|
|
132
|
+
messages: UcpCheckoutMessage[];
|
|
133
|
+
/** 结构化上报码(totals_mismatch / session_expired / unsafe_target …)。 */
|
|
134
|
+
code?: UcpCheckoutFailureCode;
|
|
135
|
+
/** true=可改输入后重试(recoverable);缺省=终态/传输失败,重试无意义。 */
|
|
136
|
+
retryable?: boolean;
|
|
137
|
+
checkout_status?: UcpCheckoutStatus;
|
|
138
|
+
/** 服务器已创建 session 时携带,供上层 updateSession 修正。 */
|
|
139
|
+
session_ref?: string;
|
|
140
|
+
checkout?: UcpCheckoutSession;
|
|
141
|
+
} | {
|
|
142
|
+
status: "requires_user";
|
|
143
|
+
continue_url?: string;
|
|
144
|
+
reason: string;
|
|
145
|
+
messages: UcpCheckoutMessage[];
|
|
146
|
+
checkout_status?: UcpCheckoutStatus;
|
|
147
|
+
session_ref?: string;
|
|
148
|
+
checkout?: UcpCheckoutSession;
|
|
149
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
/** UCP checkout spec family 日期(§43 pin)。 */
|
|
17
|
+
export const UCP_CHECKOUT_SPEC_VERSION = "2026-04-08";
|
|
18
|
+
/** expires_at 缺省值:创建后 6 小时(spec 事实)。 */
|
|
19
|
+
export const DEFAULT_EXPIRY_MS = 6 * 60 * 60 * 1000;
|
|
20
|
+
export const UCP_CHECKOUT_STATUSES = [
|
|
21
|
+
"incomplete",
|
|
22
|
+
"requires_escalation",
|
|
23
|
+
"ready_for_complete",
|
|
24
|
+
"complete_in_progress",
|
|
25
|
+
"completed",
|
|
26
|
+
"canceled",
|
|
27
|
+
];
|
|
28
|
+
export const UCP_MESSAGE_TYPES = ["error", "warning", "info"];
|
|
29
|
+
export const UCP_MESSAGE_SEVERITIES = [
|
|
30
|
+
"recoverable",
|
|
31
|
+
"requires_buyer_input",
|
|
32
|
+
"requires_buyer_review",
|
|
33
|
+
"unrecoverable",
|
|
34
|
+
];
|
|
35
|
+
/** fail_closed 结果的结构化上报码(tests 与上层据此分支,不回退到字符串匹配)。 */
|
|
36
|
+
export const UCP_CHECKOUT_FAILURE_CODES = [
|
|
37
|
+
"invalid_package",
|
|
38
|
+
"invalid_terms",
|
|
39
|
+
"invalid_quantity",
|
|
40
|
+
"session_not_found",
|
|
41
|
+
"session_not_actionable",
|
|
42
|
+
"session_expired",
|
|
43
|
+
"not_ready",
|
|
44
|
+
"gate_denied",
|
|
45
|
+
"totals_mismatch",
|
|
46
|
+
"recoverable",
|
|
47
|
+
"unrecoverable",
|
|
48
|
+
"unsafe_target",
|
|
49
|
+
"timeout",
|
|
50
|
+
"network",
|
|
51
|
+
"bad_status",
|
|
52
|
+
"malformed",
|
|
53
|
+
// cart→checkout 路径的结构化码(cart_id 仅 business profile 宣告 cart capability 时可用)。
|
|
54
|
+
"cart_not_found",
|
|
55
|
+
"cart_not_actionable",
|
|
56
|
+
"cart_capability_unavailable",
|
|
57
|
+
];
|
|
58
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/handoff/ucp-checkout/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAqB,CAAC;AAE/D,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEpD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,YAAY;IACZ,qBAAqB;IACrB,oBAAoB;IACpB,sBAAsB;IACtB,WAAW;IACX,UAAU;CACF,CAAC;AAGX,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC;AAGvE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,aAAa;IACb,sBAAsB;IACtB,uBAAuB;IACvB,eAAe;CACP,CAAC;AAwEX,sDAAsD;AACtD,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,mBAAmB;IACnB,wBAAwB;IACxB,iBAAiB;IACjB,WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,aAAa;IACb,eAAe;IACf,eAAe;IACf,SAAS;IACT,SAAS;IACT,YAAY;IACZ,WAAW;IACX,4EAA4E;IAC5E,gBAAgB;IAChB,qBAAqB;IACrB,6BAA6B;CACrB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
export interface UrlSafetyOptions {
|
|
17
|
+
/** merchant 声明域(canonical host);目的地 host 必须与之同 authority。 */
|
|
18
|
+
expectedHost?: string;
|
|
19
|
+
/** 显式 allowlist(host 白名单;配置了 expectedHost 时仍要求命中其一)。 */
|
|
20
|
+
allowlist?: readonly string[];
|
|
21
|
+
/** 允许 http(非 https)?缺省 false;localhost 始终允许 http。 */
|
|
22
|
+
allowHttp?: boolean;
|
|
23
|
+
/** 最大重定向次数(缺省 5;超过 → fail-closed)。 */
|
|
24
|
+
maxRedirects?: number;
|
|
25
|
+
/** 注入 fetch(测试)。 */
|
|
26
|
+
fetchImpl?: typeof fetch;
|
|
27
|
+
/** 请求超时 ms(缺省 15000)。 */
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
/** SSRF DNS 复查的解析函数(缺省 node:dns lookup;受控/测试环境注入用)。 */
|
|
30
|
+
resolveIp?: (hostname: string) => Promise<string[]>;
|
|
31
|
+
/** 跳过 SSRF DNS 复查(仅测试/受控环境;生产缺省 false)。 */
|
|
32
|
+
skipDnsCheck?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface SafeDestinationUrl {
|
|
35
|
+
/** 展示给用户的最终 URL(重定向解析后)。 */
|
|
36
|
+
finalUrl: string;
|
|
37
|
+
/** 重定向链(原始 → 最终)。 */
|
|
38
|
+
redirects: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 校验并解析外部目的地 URL。重定向链上的每一跳都重新过 scheme / host /
|
|
42
|
+
* SSRF 检查(防跳转到 unsafe 目标)。返回最终 URL 供展示。
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateExternalDestinationUrl(value: string, options?: UrlSafetyOptions): Promise<SafeDestinationUrl>;
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
* KTH/0.1 目的地 URL 安全(rev0.3 §11.2;架构 rev1.4.1 §36-26/27)。
|
|
18
|
+
*
|
|
19
|
+
* 检查:
|
|
20
|
+
* - scheme 白名单:https 默认;http 仅 localhost / 显式配置允许;
|
|
21
|
+
* file:/javascript:/data: 等一律拒绝(fail-closed);
|
|
22
|
+
* - userinfo 拒绝(防钓鱼 URL 伪装 authority);
|
|
23
|
+
* - redirect 限制:fetch redirect:"manual" 跟随 ≤ maxRedirects(默认 5),
|
|
24
|
+
* 每次重定向后重新校验 scheme/host(防跳转到 unsafe scheme);
|
|
25
|
+
* - anti-phishing / allowlist:host 必须与 merchant 声明域一致(或命中
|
|
26
|
+
* 显式 allowlist);拒绝 IP 直连(复用 a2a client 的 SSRF 策略);
|
|
27
|
+
* - 返回最终 URL(供用户展示,完成定义 #17)。
|
|
28
|
+
*/
|
|
29
|
+
import { assertResolvableTargetUrl, assertSafeTargetUrl } from "../a2a/client/url-policy.js";
|
|
30
|
+
import { CommerceError } from "../commerce/data-source.js";
|
|
31
|
+
const DEFAULT_MAX_REDIRECTS = 5;
|
|
32
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
33
|
+
function assertScheme(url, options) {
|
|
34
|
+
if (url.protocol === "https:")
|
|
35
|
+
return;
|
|
36
|
+
if (url.protocol === "http:" && (options.allowHttp === true || isLocalHost(url.hostname)))
|
|
37
|
+
return;
|
|
38
|
+
throw new CommerceError("invalid_input", `unsafe destination scheme "${url.protocol}" (HTTPS required; http only for localhost or explicit allowHttp)`);
|
|
39
|
+
}
|
|
40
|
+
function isLocalHost(hostname) {
|
|
41
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
42
|
+
}
|
|
43
|
+
/** host 是否命中 allowlist / expectedHost(同 authority)。 */
|
|
44
|
+
function hostAllowed(hostname, options) {
|
|
45
|
+
if (options.expectedHost !== undefined && options.expectedHost === hostname)
|
|
46
|
+
return true;
|
|
47
|
+
if (options.allowlist !== undefined && options.allowlist.includes(hostname))
|
|
48
|
+
return true;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 校验并解析外部目的地 URL。重定向链上的每一跳都重新过 scheme / host /
|
|
53
|
+
* SSRF 检查(防跳转到 unsafe 目标)。返回最终 URL 供展示。
|
|
54
|
+
*/
|
|
55
|
+
export async function validateExternalDestinationUrl(value, options = {}) {
|
|
56
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
57
|
+
const maxRedirects = options.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
|
|
58
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
59
|
+
const redirects = [];
|
|
60
|
+
let current = value;
|
|
61
|
+
for (let hop = 0; hop <= maxRedirects; hop++) {
|
|
62
|
+
// 首跳必须命中 expectedHost / allowlist;重定向跳转目标同规则
|
|
63
|
+
// (SSRF 策略在 assertSafeTargetUrl:http(s) only / 无 userinfo /
|
|
64
|
+
// 保留网段拒绝 / loopback http 例外)。
|
|
65
|
+
const parsed = assertSafeTargetUrl(current);
|
|
66
|
+
assertScheme(parsed, options);
|
|
67
|
+
if (!hostAllowed(parsed.hostname, options)) {
|
|
68
|
+
throw new CommerceError("invalid_input", `destination host "${parsed.hostname}" is not allowed (expected ${options.expectedHost ?? "allowlist"})`);
|
|
69
|
+
}
|
|
70
|
+
// 请求前 DNS 复查:主机名解析的每个 IP 过保留网段判定(防 rebinding)。
|
|
71
|
+
// 此前只对字面 IP 生效——expectedHost 命中但解析到 169.254.169.254 等
|
|
72
|
+
// 内网地址的主机名会真实发出探测。
|
|
73
|
+
try {
|
|
74
|
+
await assertResolvableTargetUrl(parsed, {
|
|
75
|
+
skipDnsCheck: options.skipDnsCheck,
|
|
76
|
+
resolveIp: options.resolveIp,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
throw new CommerceError("invalid_input", `destination DNS rejected by safety policy: ${err instanceof Error ? err.message : String(err)}`);
|
|
81
|
+
}
|
|
82
|
+
const controller = new AbortController();
|
|
83
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
84
|
+
let response;
|
|
85
|
+
try {
|
|
86
|
+
// HEAD 探测重定向;2xx 即终点(不 HEAD 的服务器按不可达拒绝,绝不把
|
|
87
|
+
// 404/500/403 死链当"已验证目的地"交付给用户展示)。
|
|
88
|
+
response = await fetchImpl(current, {
|
|
89
|
+
method: "HEAD",
|
|
90
|
+
redirect: "manual",
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
const name = err?.name;
|
|
96
|
+
throw new CommerceError("request_failed", name === "AbortError"
|
|
97
|
+
? `destination probe timed out after ${timeoutMs}ms: ${current}`
|
|
98
|
+
: `destination probe failed: ${current} (${err instanceof Error ? err.message : String(err)})`);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
}
|
|
103
|
+
const location = response.headers.get("location");
|
|
104
|
+
if (location === null) {
|
|
105
|
+
if (response.status < 200 || response.status >= 300) {
|
|
106
|
+
throw new CommerceError("request_failed", `destination probe returned HTTP ${response.status} (not a reachable 2xx endpoint): ${current}`);
|
|
107
|
+
}
|
|
108
|
+
return { finalUrl: current, redirects };
|
|
109
|
+
}
|
|
110
|
+
if (response.status < 300 || response.status >= 400) {
|
|
111
|
+
throw new CommerceError("request_failed", `destination returned a redirect Location with non-3xx status (HTTP ${response.status}): ${current}`);
|
|
112
|
+
}
|
|
113
|
+
if (hop === maxRedirects) {
|
|
114
|
+
throw new CommerceError("invalid_input", `destination exceeded max redirects (${maxRedirects})`);
|
|
115
|
+
}
|
|
116
|
+
redirects.push(current);
|
|
117
|
+
current = new URL(location, current).href;
|
|
118
|
+
}
|
|
119
|
+
throw new CommerceError("invalid_input", `destination exceeded max redirects (${maxRedirects})`);
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=url-safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-safety.js","sourceRoot":"","sources":["../../src/handoff/url-safety.ts"],"names":[],"mappings":"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"}
|
package/dist/i18n.d.ts
ADDED
|
@@ -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
|
+
* 最小 i18n:自然语言报告(如 /negotiate 总结)跟随用户语言,不写死中文。
|
|
18
|
+
*
|
|
19
|
+
* 语言判定:
|
|
20
|
+
* 1. `KIWI_LANG` 显式覆盖(zh / en);
|
|
21
|
+
* 2. 否则读 `LANG` / `LC_ALL`:`zh*` → 中文,其余 → 英文(缺省)。
|
|
22
|
+
*/
|
|
23
|
+
export type KiwiLocale = "zh" | "en";
|
|
24
|
+
export declare function detectLocale(): KiwiLocale;
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
export function detectLocale() {
|
|
17
|
+
const explicit = process.env.KIWI_LANG?.trim().toLowerCase();
|
|
18
|
+
if (explicit === "zh" || explicit === "zh-cn" || explicit === "zh_cn" || explicit === "zh-hans") {
|
|
19
|
+
return "zh";
|
|
20
|
+
}
|
|
21
|
+
if (explicit === "en" || explicit === "en-us" || explicit === "en_us") {
|
|
22
|
+
return "en";
|
|
23
|
+
}
|
|
24
|
+
const lang = (process.env.LANG ?? process.env.LC_ALL ?? "").toLowerCase();
|
|
25
|
+
return lang.startsWith("zh") ? "zh" : "en";
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,MAAM,UAAU,YAAY;IAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7D,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1E,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { DecisionAction, NegotiationDecision } from "./types.js";
|
|
17
|
+
export declare const ACTION_CANDIDATE_KINDS: readonly ["negotiation"];
|
|
18
|
+
export type ActionCandidateKind = (typeof ACTION_CANDIDATE_KINDS)[number];
|
|
19
|
+
/** Risk levels bound to a candidate (mirrors the operator's strategy risk). */
|
|
20
|
+
export declare const CANDIDATE_RISK_LEVELS: readonly ["ok", "confirm", "blocked"];
|
|
21
|
+
export type CandidateRiskLevel = (typeof CANDIDATE_RISK_LEVELS)[number];
|
|
22
|
+
export interface CandidateRisk {
|
|
23
|
+
level: CandidateRiskLevel;
|
|
24
|
+
reason: string;
|
|
25
|
+
}
|
|
26
|
+
/** Base: a suggested, not-yet-executed external side-effectful action. */
|
|
27
|
+
export interface ActionCandidate {
|
|
28
|
+
/** Stable identifier; never reused for a different action. */
|
|
29
|
+
candidate_id: string;
|
|
30
|
+
/** Subtype discriminant for narrowing across candidate families. */
|
|
31
|
+
kind: ActionCandidateKind;
|
|
32
|
+
/** The proposed external side-effect action, as a stable action token. */
|
|
33
|
+
action: string;
|
|
34
|
+
/** The payload the action would be executed with. */
|
|
35
|
+
payload: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** Negotiation action candidate — an ActionCandidate bound to a negotiation. */
|
|
38
|
+
export interface NegotiationActionCandidate extends ActionCandidate {
|
|
39
|
+
kind: "negotiation";
|
|
40
|
+
action: DecisionAction;
|
|
41
|
+
payload: NegotiationDecision;
|
|
42
|
+
/** The business negotiation this candidate belongs to (v0.2 conversation_id). */
|
|
43
|
+
negotiation_id: string;
|
|
44
|
+
/** RFC 8785 JCS + SHA-256 content digest of the bound candidate fields. */
|
|
45
|
+
candidate_digest: string;
|
|
46
|
+
/** Remote revision the candidate was generated against (§19 re-validation). */
|
|
47
|
+
expected_remote_revision: string;
|
|
48
|
+
/** Policy version that produced/approved this candidate. */
|
|
49
|
+
policy_version: string;
|
|
50
|
+
/** Counterparty identity the candidate targets, as observed by us. */
|
|
51
|
+
counterparty_identity: string;
|
|
52
|
+
/** Public draft shown to the counterpart (never private reasoning). */
|
|
53
|
+
public_message: string;
|
|
54
|
+
reason_codes: string[];
|
|
55
|
+
risk: CandidateRisk;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* v0.2 compatibility term (docs §6/§7.3). The v0.2 operator control plane's
|
|
59
|
+
* `Candidate` (`src/operator/types.ts`) satisfies this shape. Only the bridge
|
|
60
|
+
* below still names it; new code consumes NegotiationActionCandidate.
|
|
61
|
+
*/
|
|
62
|
+
export interface DecisionCandidate {
|
|
63
|
+
candidate_id: string;
|
|
64
|
+
binding: {
|
|
65
|
+
conversation_id: string;
|
|
66
|
+
message_id: number;
|
|
67
|
+
};
|
|
68
|
+
decision: NegotiationDecision;
|
|
69
|
+
created_at: string;
|
|
70
|
+
}
|
|
71
|
+
/** Context bindings the v0.2 DecisionCandidate does not carry itself. */
|
|
72
|
+
export interface NegotiationActionCandidateContext {
|
|
73
|
+
expected_remote_revision: string;
|
|
74
|
+
policy_version: string;
|
|
75
|
+
counterparty_identity: string;
|
|
76
|
+
risk: CandidateRisk;
|
|
77
|
+
}
|
|
78
|
+
export declare class CandidateAdapterError extends Error {
|
|
79
|
+
readonly code: "missing_field" | "invalid_field";
|
|
80
|
+
readonly field?: string;
|
|
81
|
+
constructor(code: CandidateAdapterError["code"], message: string, field?: string);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Bridge the v0.2 DecisionCandidate into the v0.4 NegotiationActionCandidate.
|
|
85
|
+
* Missing or malformed binding fields fail closed (CandidateAdapterError); the
|
|
86
|
+
* digest is always recomputed from the mapped fields, never trusted from input.
|
|
87
|
+
*/
|
|
88
|
+
export declare function toNegotiationActionCandidate(decision: DecisionCandidate, context: NegotiationActionCandidateContext): NegotiationActionCandidate;
|
|
89
|
+
/**
|
|
90
|
+
* RFC 8785 JCS + SHA-256 digest over the bound candidate fields (docs §17).
|
|
91
|
+
* `candidate_digest` itself is excluded — content addressing never hashes its
|
|
92
|
+
* own envelope. Equal candidates always produce the same digest; any bound
|
|
93
|
+
* field change produces a different one.
|
|
94
|
+
*/
|
|
95
|
+
export declare function candidateDigest(input: Omit<NegotiationActionCandidate, "candidate_digest">): string;
|
|
96
|
+
/** Recomputed-digest check; false means the candidate is stale (§19). */
|
|
97
|
+
export declare function verifyCandidateDigest(candidate: NegotiationActionCandidate): boolean;
|