@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,206 @@
|
|
|
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
|
+
* ShoppingCliCommerceDataSource —— shopping-cli 商品开放层 adapter
|
|
18
|
+
* (shopping-cli data hub v0.2.1 §3/#5:shopping-cli 可作为 Merchant
|
|
19
|
+
* CommerceDataSource,完成定义 #5)。
|
|
20
|
+
*
|
|
21
|
+
* 端点契约(shopping-cli 仓 route_registry):
|
|
22
|
+
* GET {baseUrl}/products/{sku} → {product: {...}}
|
|
23
|
+
* GET {baseUrl}/search/products?limit= → {results: [...]}
|
|
24
|
+
*
|
|
25
|
+
* 字段语义:
|
|
26
|
+
* - shopping-cli 的 `price` 以「元」为单位(float)→ 转换为
|
|
27
|
+
* `price_minor`(minor units,KNP Money 约定;两位小数假设,文档注明);
|
|
28
|
+
* - 权威语义 UPSTREAM_PROXY(数据权威在 shopping-cli 侧,Kiwi 只读)。
|
|
29
|
+
*/
|
|
30
|
+
import { CommerceError } from "./data-source.js";
|
|
31
|
+
import { isRedirectResponse, readJsonBody, SafeHttpError } from "../net/safe-http.js";
|
|
32
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
33
|
+
function validateBaseUrl(value) {
|
|
34
|
+
let url;
|
|
35
|
+
try {
|
|
36
|
+
url = new URL(value);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new CommerceError("invalid_input", `shopping-cli baseUrl is not a valid URL: "${value}"`);
|
|
40
|
+
}
|
|
41
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
42
|
+
throw new CommerceError("invalid_input", `shopping-cli baseUrl must use http or https (got ${url.protocol})`);
|
|
43
|
+
}
|
|
44
|
+
if (url.username !== "" || url.password !== "") {
|
|
45
|
+
throw new CommerceError("invalid_input", "shopping-cli baseUrl must not embed credentials (userinfo)");
|
|
46
|
+
}
|
|
47
|
+
if (url.search !== "" || url.hash !== "") {
|
|
48
|
+
throw new CommerceError("invalid_input", "shopping-cli baseUrl must not contain query or fragment (paths are appended to it)");
|
|
49
|
+
}
|
|
50
|
+
return value.replace(/\/+$/, "");
|
|
51
|
+
}
|
|
52
|
+
/** shopping-cli price(元)→ price_minor(minor units,两位小数假设)。 */
|
|
53
|
+
function toMinorUnits(price) {
|
|
54
|
+
if (typeof price !== "number" || !Number.isFinite(price) || price < 0)
|
|
55
|
+
return undefined;
|
|
56
|
+
return Math.round(price * 100);
|
|
57
|
+
}
|
|
58
|
+
function parseProduct(raw, path) {
|
|
59
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
60
|
+
throw new CommerceError("request_failed", `shopping-cli product at ${path} is not an object`);
|
|
61
|
+
}
|
|
62
|
+
const obj = raw;
|
|
63
|
+
const sku = obj.sku;
|
|
64
|
+
if (typeof sku !== "string" || sku.length === 0) {
|
|
65
|
+
throw new CommerceError("request_failed", `shopping-cli product at ${path} is missing sku`);
|
|
66
|
+
}
|
|
67
|
+
const priceMinor = toMinorUnits(obj.price);
|
|
68
|
+
return {
|
|
69
|
+
sku,
|
|
70
|
+
...(typeof obj.title === "string" && obj.title !== "" ? { title: obj.title } : {}),
|
|
71
|
+
...(priceMinor !== undefined ? { price_minor: priceMinor } : {}),
|
|
72
|
+
...(typeof obj.currency === "string" && obj.currency !== "" ? { currency: obj.currency } : {}),
|
|
73
|
+
...(typeof obj.stock === "number" && Number.isInteger(obj.stock) ? { stock: obj.stock } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** shopping-cli 商品开放层数据源(UPSTREAM_PROXY,source="shopping-cli")。 */
|
|
77
|
+
export class ShoppingCliCommerceDataSource {
|
|
78
|
+
baseUrl;
|
|
79
|
+
deps;
|
|
80
|
+
constructor(deps) {
|
|
81
|
+
this.baseUrl = validateBaseUrl(deps.baseUrl);
|
|
82
|
+
this.deps = deps;
|
|
83
|
+
}
|
|
84
|
+
async getJson(requestPath) {
|
|
85
|
+
const fetchImpl = this.deps.fetchImpl ?? globalThis.fetch;
|
|
86
|
+
const timeoutMs = this.deps.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
87
|
+
const url = `${this.baseUrl}${requestPath}`;
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
90
|
+
let response;
|
|
91
|
+
try {
|
|
92
|
+
response = await fetchImpl(url, {
|
|
93
|
+
// 出站加固:绝不跟随重定向(3xx 目标不经过校验,且可能转发 Bearer 头)。
|
|
94
|
+
redirect: "manual",
|
|
95
|
+
signal: controller.signal,
|
|
96
|
+
headers: {
|
|
97
|
+
accept: "application/json",
|
|
98
|
+
...(this.deps.authToken !== undefined
|
|
99
|
+
? { authorization: `Bearer ${this.deps.authToken}` }
|
|
100
|
+
: {}),
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
const name = err?.name;
|
|
106
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
107
|
+
throw new CommerceError("request_failed", name === "AbortError"
|
|
108
|
+
? `shopping-cli request timed out after ${timeoutMs}ms: ${url}`
|
|
109
|
+
: `shopping-cli request failed: ${url} (${detail})`);
|
|
110
|
+
}
|
|
111
|
+
if (isRedirectResponse(response)) {
|
|
112
|
+
throw new CommerceError("request_failed", `shopping-cli request must not follow redirects (HTTP ${response.status} from ${url})`);
|
|
113
|
+
}
|
|
114
|
+
if (response.status === 404) {
|
|
115
|
+
// 404 = 资源不存在:getProduct 的"未知 SKU → undefined"接口承诺
|
|
116
|
+
//(composite 次要源靠它跳过自身不收录的 SKU,而不是整体抛错)。
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
throw new CommerceError("request_failed", `shopping-cli request returned HTTP ${response.status} from ${url}`);
|
|
121
|
+
}
|
|
122
|
+
let raw;
|
|
123
|
+
try {
|
|
124
|
+
// 响应体读取在超时覆盖内 + 大小上限(出站加固)。
|
|
125
|
+
raw = await readJsonBody(response, { signal: controller.signal });
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (controller.signal.aborted) {
|
|
129
|
+
throw new CommerceError("request_failed", `shopping-cli request timed out after ${timeoutMs}ms while reading response: ${url}`);
|
|
130
|
+
}
|
|
131
|
+
throw new CommerceError("request_failed", err instanceof SafeHttpError && err.code === "response_too_large"
|
|
132
|
+
? `shopping-cli response from ${url}: ${err.message}`
|
|
133
|
+
: `shopping-cli response from ${url} is not valid JSON`);
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
}
|
|
138
|
+
return raw;
|
|
139
|
+
}
|
|
140
|
+
async getProduct(sku) {
|
|
141
|
+
if (typeof sku !== "string" || sku.length === 0) {
|
|
142
|
+
throw new CommerceError("invalid_input", "sku must be a non-empty string");
|
|
143
|
+
}
|
|
144
|
+
const raw = await this.getJson(`/products/${encodeURIComponent(sku)}`);
|
|
145
|
+
if (raw === null)
|
|
146
|
+
return undefined; // 404 → 未知 SKU(接口承诺)
|
|
147
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
148
|
+
throw new CommerceError("request_failed", "shopping-cli get product response must be an object");
|
|
149
|
+
}
|
|
150
|
+
const body = raw;
|
|
151
|
+
if (body.product === undefined) {
|
|
152
|
+
throw new CommerceError("request_failed", 'shopping-cli get product response is missing field "product"');
|
|
153
|
+
}
|
|
154
|
+
return parseProduct(body.product, `/products/${sku}`);
|
|
155
|
+
}
|
|
156
|
+
async getProducts(query = {}) {
|
|
157
|
+
const limit = Math.max(1, Math.min(Number(query.limit ?? 20) || 20, 100));
|
|
158
|
+
const params = new URLSearchParams();
|
|
159
|
+
params.set("limit", String(limit));
|
|
160
|
+
if (query.q !== undefined && query.q !== "")
|
|
161
|
+
params.set("q", query.q);
|
|
162
|
+
const raw = await this.getJson(`/search/products?${params.toString()}`);
|
|
163
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
164
|
+
throw new CommerceError("request_failed", "shopping-cli search products response must be an object");
|
|
165
|
+
}
|
|
166
|
+
const body = raw;
|
|
167
|
+
if (!Array.isArray(body.results)) {
|
|
168
|
+
throw new CommerceError("request_failed", 'shopping-cli search products response is missing array field "results"');
|
|
169
|
+
}
|
|
170
|
+
return body.results.map((element, i) => parseProduct(element, `/search/products/${i}`));
|
|
171
|
+
}
|
|
172
|
+
async getInventory(sku) {
|
|
173
|
+
const product = await this.getProduct(sku);
|
|
174
|
+
if (product?.stock === undefined)
|
|
175
|
+
return undefined;
|
|
176
|
+
return { value: product.stock, authority: "UPSTREAM_PROXY", source: "shopping-cli" };
|
|
177
|
+
}
|
|
178
|
+
async getPrice(sku) {
|
|
179
|
+
const product = await this.getProduct(sku);
|
|
180
|
+
if (product?.price_minor === undefined || product.currency === undefined)
|
|
181
|
+
return undefined;
|
|
182
|
+
return {
|
|
183
|
+
value: { currency: product.currency, amount_minor: product.price_minor },
|
|
184
|
+
authority: "UPSTREAM_PROXY",
|
|
185
|
+
source: "shopping-cli",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async getPublicListing() {
|
|
189
|
+
const products = await this.getProducts({ limit: 100 });
|
|
190
|
+
return { source: "shopping-cli", count: products.length, products };
|
|
191
|
+
}
|
|
192
|
+
async health() {
|
|
193
|
+
try {
|
|
194
|
+
await this.getJson("/health");
|
|
195
|
+
return { ok: true, service: "shopping-cli-commerce-data-source", version: "1" };
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
return {
|
|
199
|
+
ok: false,
|
|
200
|
+
service: "shopping-cli-commerce-data-source",
|
|
201
|
+
details: { error: err instanceof Error ? err.message : String(err) },
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=shopping-cli-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopping-cli-source.js","sourceRoot":"","sources":["../../src/commerce/shopping-cli-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAA0F,MAAM,kBAAkB,CAAC;AACzI,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AActF,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,SAAS,eA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AAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC3F,OAAO;YACL,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,WAAW,EAAE;YACxE,SAAS,EAAE,gBAAgB;YAC3B,MAAM,EAAE,cAAc;SACvB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACxD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC9B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,mCAAmC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;QAClF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,mCAAmC;gBAC5C,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;aACrE,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
* CommerceGateway / CommerceClient — the stable boundary between Kiwi and
|
|
18
|
+
* shopping-cli. All business access goes through this interface; Kiwi never
|
|
19
|
+
* touches Python modules, SQLite, or platform databases directly.
|
|
20
|
+
*
|
|
21
|
+
* Implementations:
|
|
22
|
+
* - HttpCommerceClient (commerce/http-client.ts) — shopping-cli 2.x HTTP API
|
|
23
|
+
* - FakeCommerceClient (commerce/fake-client.ts) — deterministic in-memory
|
|
24
|
+
* LocalMarketplace semantics for tests and offline development
|
|
25
|
+
*/
|
|
26
|
+
import type { CommerceCapabilities, NegotiationDecision, NegotiationSnapshot, PolicyResult, Role } from "../negotiation/types.js";
|
|
27
|
+
/** A conversation message that is waiting for this agent to act. */
|
|
28
|
+
export interface PendingMessage {
|
|
29
|
+
conversation_id: string;
|
|
30
|
+
message_id: number;
|
|
31
|
+
/** e.g. "waiting_merchant" — authoritative routing state. */
|
|
32
|
+
conversation_status: string;
|
|
33
|
+
sender_role: Role;
|
|
34
|
+
preview: string;
|
|
35
|
+
created_at: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ClaimResult {
|
|
38
|
+
claimed: boolean;
|
|
39
|
+
status: string;
|
|
40
|
+
attempts: number;
|
|
41
|
+
idempotency_key: string;
|
|
42
|
+
}
|
|
43
|
+
export type ProcessStatus = "processing" | "processed" | "failed" | "abandoned";
|
|
44
|
+
export interface ProcessResult {
|
|
45
|
+
status: ProcessStatus;
|
|
46
|
+
message_id: number;
|
|
47
|
+
last_error?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CommerceHealth {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
service?: string;
|
|
52
|
+
version?: string;
|
|
53
|
+
details?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface CommerceClient {
|
|
56
|
+
/** Service liveness/version. Used by `kiwi doctor`. */
|
|
57
|
+
health(): Promise<CommerceHealth>;
|
|
58
|
+
/**
|
|
59
|
+
* Protocol and capability advertisement. Kiwi fails closed when
|
|
60
|
+
* shopping.negotiation/0.1 or a required capability is missing.
|
|
61
|
+
*/
|
|
62
|
+
getCapabilities(): Promise<CommerceCapabilities>;
|
|
63
|
+
/**
|
|
64
|
+
* Messages routed to this agent and not yet replied to. The gateway
|
|
65
|
+
* derives role and owner from the Bearer token; the client never sends
|
|
66
|
+
* and never trusts a claimed role/owner_id.
|
|
67
|
+
*/
|
|
68
|
+
listPendingMessages(): Promise<PendingMessage[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Claim a message for processing. Idempotent: the same idempotency key
|
|
71
|
+
* returns the same outcome; a non-retryable existing claim returns
|
|
72
|
+
* claimed=false without an error.
|
|
73
|
+
*/
|
|
74
|
+
claimMessage(input: {
|
|
75
|
+
conversation_id: string;
|
|
76
|
+
message_id: number;
|
|
77
|
+
idempotency_key: string;
|
|
78
|
+
}): Promise<ClaimResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Authoritative, role-trimmed negotiation snapshot. Only available for a
|
|
81
|
+
* conversation/message this agent has claimed.
|
|
82
|
+
*/
|
|
83
|
+
getNegotiationSnapshot(input: {
|
|
84
|
+
conversation_id: string;
|
|
85
|
+
message_id: number;
|
|
86
|
+
}): Promise<NegotiationSnapshot>;
|
|
87
|
+
/**
|
|
88
|
+
* The single write intent. The server-side policy gate is authoritative:
|
|
89
|
+
* identity, turn (next_actor), claim binding, facts, private thresholds
|
|
90
|
+
* and privacy are all re-checked there.
|
|
91
|
+
*/
|
|
92
|
+
submitNegotiationDecision(input: {
|
|
93
|
+
decision: NegotiationDecision;
|
|
94
|
+
idempotency_key: string;
|
|
95
|
+
}): Promise<PolicyResult>;
|
|
96
|
+
completeClaim(input: {
|
|
97
|
+
message_id: number;
|
|
98
|
+
idempotency_key: string;
|
|
99
|
+
}): Promise<ProcessResult>;
|
|
100
|
+
failClaim(input: {
|
|
101
|
+
message_id: number;
|
|
102
|
+
idempotency_key: string;
|
|
103
|
+
error: string;
|
|
104
|
+
}): Promise<ProcessResult>;
|
|
105
|
+
abandonClaim(input: {
|
|
106
|
+
message_id: number;
|
|
107
|
+
idempotency_key: string;
|
|
108
|
+
error: string;
|
|
109
|
+
}): Promise<ProcessResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Liveness for this identity's own processing claims. With message_id,
|
|
112
|
+
* refreshes only that claim (and only while it is still processing);
|
|
113
|
+
* without, refreshes all of the actor's processing claims. Never touches
|
|
114
|
+
* settled or other identities' claims and never revives stale work.
|
|
115
|
+
*/
|
|
116
|
+
heartbeat(input?: {
|
|
117
|
+
message_id?: number;
|
|
118
|
+
}): Promise<HeartbeatResult>;
|
|
119
|
+
/**
|
|
120
|
+
* Crash recovery: abandon this identity's OWN stale processing claims
|
|
121
|
+
* (updated_at older than ttl_seconds). Must run before any heartbeat on a
|
|
122
|
+
* fresh runtime. Abandoned claims stay reclaimable.
|
|
123
|
+
*/
|
|
124
|
+
abandonStaleClaims(input?: {
|
|
125
|
+
ttl_seconds?: number;
|
|
126
|
+
}): Promise<StaleRecoveryResult>;
|
|
127
|
+
}
|
|
128
|
+
export interface HeartbeatResult {
|
|
129
|
+
status: string;
|
|
130
|
+
refreshed: number;
|
|
131
|
+
at: string;
|
|
132
|
+
}
|
|
133
|
+
export interface StaleRecoveryResult {
|
|
134
|
+
abandoned: number;
|
|
135
|
+
message_ids: number[];
|
|
136
|
+
ttl_seconds: number;
|
|
137
|
+
at: string;
|
|
138
|
+
}
|
|
139
|
+
export type CommerceErrorKind = "auth" | "not_found" | "conflict" | "rate_limit" | "validation" | "transient";
|
|
140
|
+
export declare class CommerceError extends Error {
|
|
141
|
+
readonly kind: CommerceErrorKind;
|
|
142
|
+
readonly status?: number;
|
|
143
|
+
constructor(kind: CommerceErrorKind, message: string, status?: number);
|
|
144
|
+
}
|
|
145
|
+
/** Idempotency key convention: agent_id + message_id + protocol version. */
|
|
146
|
+
export declare function idempotencyKey(agentId: string, messageId: number, protocolVersion: string): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 class CommerceError extends Error {
|
|
17
|
+
kind;
|
|
18
|
+
status;
|
|
19
|
+
constructor(kind, message, status) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "CommerceError";
|
|
22
|
+
this.kind = kind;
|
|
23
|
+
if (status !== undefined)
|
|
24
|
+
this.status = status;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Idempotency key convention: agent_id + message_id + protocol version. */
|
|
28
|
+
export function idempotencyKey(agentId, messageId, protocolVersion) {
|
|
29
|
+
return `${agentId}:${messageId}:${protocolVersion}`;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commerce/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiJH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAoB;IACxB,MAAM,CAAU;IAEzB,YAAY,IAAuB,EAAE,OAAe,EAAE,MAAe;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACjD,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAC5B,OAAe,EACf,SAAiB,EACjB,eAAuB;IAEvB,OAAO,GAAG,OAAO,IAAI,SAAS,IAAI,eAAe,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
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 Role } from "../negotiation/types.js";
|
|
17
|
+
export declare const RUNTIME_VERSION = "0.6.0";
|
|
18
|
+
export interface MerchantPolicy {
|
|
19
|
+
min_unit_price_private?: number;
|
|
20
|
+
max_auto_discount_percent?: number;
|
|
21
|
+
inventory_source?: string;
|
|
22
|
+
quote_ttl_seconds?: number;
|
|
23
|
+
auto_negotiate?: boolean;
|
|
24
|
+
human_review_on?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Buyer private policy (design §7.2). All fields are required: the local
|
|
28
|
+
* private-policy gate is a security boundary, so a half-specified policy
|
|
29
|
+
* fails closed at load time instead of silently disabling checks.
|
|
30
|
+
*
|
|
31
|
+
* PRIVATE: max_total_price_private never leaves this process — it is not
|
|
32
|
+
* sent to the gateway, not logged, and not shown to the counterpart.
|
|
33
|
+
*/
|
|
34
|
+
export interface BuyerPolicy {
|
|
35
|
+
target_skus: string[];
|
|
36
|
+
quantity: number;
|
|
37
|
+
max_total_price_private: number;
|
|
38
|
+
/** RFC 3339 date-time with an explicit timezone offset (or Z). */
|
|
39
|
+
acceptable_eta_latest: string;
|
|
40
|
+
required_after_sales_terms: string[];
|
|
41
|
+
auto_negotiate: boolean;
|
|
42
|
+
human_review_on: string[];
|
|
43
|
+
}
|
|
44
|
+
export declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high"];
|
|
45
|
+
export type ProfileThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
46
|
+
/** API ids supported by the pinned pi-ai 0.83.0 (its KnownApi union). */
|
|
47
|
+
export declare const SUPPORTED_MODEL_APIS: readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
* Commerce credential scopes (design §15.4). Credentials are held separately
|
|
50
|
+
* by scope; the model only ever sees tools, never tokens. When a scope has no
|
|
51
|
+
* credential configured, the corresponding write tools fail closed.
|
|
52
|
+
*/
|
|
53
|
+
export declare const COMMERCE_CREDENTIAL_SCOPES: readonly ["negotiation", "catalog", "inventory"];
|
|
54
|
+
export type CommerceCredentialScope = (typeof COMMERCE_CREDENTIAL_SCOPES)[number];
|
|
55
|
+
export interface AgentProfile {
|
|
56
|
+
runtime_version: string;
|
|
57
|
+
protocol_version: string;
|
|
58
|
+
agent_id: string;
|
|
59
|
+
role: Role;
|
|
60
|
+
owner_id: string;
|
|
61
|
+
commerce: {
|
|
62
|
+
base_url: string;
|
|
63
|
+
/** Name of the env var holding the commerce API token (negotiation scope). */
|
|
64
|
+
token_env: string;
|
|
65
|
+
backend: "local_marketplace" | "external_platform";
|
|
66
|
+
/**
|
|
67
|
+
* Optional per-scope token env refs. `token_env` remains the primary
|
|
68
|
+
* negotiation credential; catalog/inventory tokens must be configured
|
|
69
|
+
* separately or the corresponding merchant write tools fail closed.
|
|
70
|
+
*/
|
|
71
|
+
credentials?: Partial<Record<CommerceCredentialScope, {
|
|
72
|
+
token_env: string;
|
|
73
|
+
}>>;
|
|
74
|
+
};
|
|
75
|
+
model: {
|
|
76
|
+
provider: string;
|
|
77
|
+
model: string;
|
|
78
|
+
/** Name of the env var holding the model API key. */
|
|
79
|
+
api_key_env?: string;
|
|
80
|
+
/** Optional API id override (e.g. "openai-completions"). */
|
|
81
|
+
api?: string;
|
|
82
|
+
/** Optional base URL override for OpenAI-compatible endpoints. */
|
|
83
|
+
base_url?: string;
|
|
84
|
+
thinking_level?: ProfileThinkingLevel;
|
|
85
|
+
};
|
|
86
|
+
runtime: {
|
|
87
|
+
mode: "once" | "foreground";
|
|
88
|
+
poll_interval_seconds: number;
|
|
89
|
+
turn_timeout_seconds: number;
|
|
90
|
+
max_model_steps: number;
|
|
91
|
+
max_retries: number;
|
|
92
|
+
};
|
|
93
|
+
merchant_policy?: MerchantPolicy;
|
|
94
|
+
buyer_policy?: BuyerPolicy;
|
|
95
|
+
}
|
|
96
|
+
export declare class ProfileError extends Error {
|
|
97
|
+
constructor(message: string);
|
|
98
|
+
}
|
|
99
|
+
/** Hard upper bounds for runtime limits. */
|
|
100
|
+
export declare const RUNTIME_LIMITS: {
|
|
101
|
+
readonly max_model_steps: 20;
|
|
102
|
+
readonly max_retries: 5;
|
|
103
|
+
readonly turn_timeout_seconds: 3600;
|
|
104
|
+
readonly poll_interval_seconds: 3600;
|
|
105
|
+
};
|
|
106
|
+
/** Validate an RFC 3339 timestamp that must carry a timezone. */
|
|
107
|
+
export declare function isRfc3339WithTimezone(value: unknown): value is string;
|
|
108
|
+
/**
|
|
109
|
+
* Validate a base URL: http(s) only, no embedded credentials, and cleartext
|
|
110
|
+
* HTTP only for loopback hosts (localhost / 127.0.0.1 / ::1).
|
|
111
|
+
*/
|
|
112
|
+
export declare function assertSecureBaseUrl(value: unknown, field: string, source: string): string;
|
|
113
|
+
/** Load, parse and validate a profile file. Never reads secret env values. */
|
|
114
|
+
export declare function loadProfile(path: string): AgentProfile;
|
|
115
|
+
export declare function validateProfile(data: unknown, source: string): AgentProfile;
|
|
116
|
+
/**
|
|
117
|
+
* Resolve a secret from an environment variable reference. Throws
|
|
118
|
+
* ProfileError when unset — callers map this to the config exit code.
|
|
119
|
+
*/
|
|
120
|
+
export declare function resolveSecret(envName: string, what: string): string;
|
|
121
|
+
/** Scan loaded profile data for accidentally inlined secrets. */
|
|
122
|
+
export declare function findInlineSecrets(data: unknown): string[];
|