@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,138 @@
|
|
|
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
|
+
* fanout — 渐进披露构造器(基线 §30 / §29 / §4.4)。
|
|
18
|
+
*
|
|
19
|
+
* 同一 RFQ 意图(RfqIntent)按披露档位生成不同 payload:
|
|
20
|
+
* - anonymous(round 1 匿名首轮):SKU + 数量区间,不含精确数量 / 交期 /
|
|
21
|
+
* 任何身份线索;
|
|
22
|
+
* - detailed(round 2 Top N 后):精确数量 + 交期要求 +(策略允许的 §29 可选项)。
|
|
23
|
+
*
|
|
24
|
+
* 私有字段结构性不可能出现:构造器按档位白名单投影 intent —— 预算 / 急迫度 /
|
|
25
|
+
* 身份 / 联系方式在 AnonymousRfqPayload / DetailedRfqPayload 类型里没有承载字段,
|
|
26
|
+
* 构造路径也从不读取这些 intent 字段。是构造时排除,而非事后过滤(§30)。
|
|
27
|
+
*
|
|
28
|
+
* 每档生成后必须过 NetworkDisclosurePolicy 校验(validateNetworkDisclosure),
|
|
29
|
+
* 违反即抛 FanoutDisclosureError(fail-closed,§4.6)。校验器本身是纯函数,
|
|
30
|
+
* 供负向断言直接使用。
|
|
31
|
+
*/
|
|
32
|
+
import type { LineItem } from "../negotiation/domain/common.js";
|
|
33
|
+
import type { Rfq } from "../negotiation/domain/objects.js";
|
|
34
|
+
import type { DisclosureAttribute, DisclosureTier } from "./policy.js";
|
|
35
|
+
/** 单行 intent:精确数量(私有)+ 粗粒度数量区间(匿名档只投影区间)。 */
|
|
36
|
+
export interface RfqIntentItem {
|
|
37
|
+
sku: string;
|
|
38
|
+
/** 精确数量(私有,只投影到 detailed,且要求 purchase_quantity 被允许)。 */
|
|
39
|
+
quantity: number;
|
|
40
|
+
/** 匿名档披露的粗粒度区间。 */
|
|
41
|
+
quantity_range: {
|
|
42
|
+
min: number;
|
|
43
|
+
max: number;
|
|
44
|
+
};
|
|
45
|
+
unit: string;
|
|
46
|
+
}
|
|
47
|
+
/** 内部 RFQ 意图:含私有字段(§4.4 默认 private)。 */
|
|
48
|
+
export interface RfqIntent {
|
|
49
|
+
items: RfqIntentItem[];
|
|
50
|
+
/** 精确交期要求(RFC 3339;只进 detailed)。 */
|
|
51
|
+
delivery_before?: string;
|
|
52
|
+
/** 预算提示(私有,结构性排除,永不披露)。 */
|
|
53
|
+
budget?: {
|
|
54
|
+
currency: string;
|
|
55
|
+
amount_minor: number;
|
|
56
|
+
};
|
|
57
|
+
/** 急迫度(私有,结构性排除)。 */
|
|
58
|
+
urgency?: string;
|
|
59
|
+
/** 身份 / 联系方式(私有,结构性排除)。 */
|
|
60
|
+
contact?: {
|
|
61
|
+
organization?: string;
|
|
62
|
+
email?: string;
|
|
63
|
+
phone?: string;
|
|
64
|
+
};
|
|
65
|
+
/** 位置精度(可选披露项,需 disclosure_profile 允许)。 */
|
|
66
|
+
location_precision?: "city" | "district";
|
|
67
|
+
/** 客户段(可选披露项,需允许)。 */
|
|
68
|
+
customer_segment?: string;
|
|
69
|
+
/** 历史偏好(可选披露项,需允许)。 */
|
|
70
|
+
preferences?: string[];
|
|
71
|
+
/** 品类(供 category_sensitivity 判定;构造器不投影)。 */
|
|
72
|
+
category?: string;
|
|
73
|
+
}
|
|
74
|
+
/** 单 SKU 的数量区间(anonymous 档)。 */
|
|
75
|
+
export interface QuantityRange {
|
|
76
|
+
sku: string;
|
|
77
|
+
min: number;
|
|
78
|
+
max: number;
|
|
79
|
+
}
|
|
80
|
+
export interface AnonymousRfqPayload {
|
|
81
|
+
tier: "anonymous";
|
|
82
|
+
rfq: {
|
|
83
|
+
type: "rfq";
|
|
84
|
+
/** 区间中点数量(LineItem 要求有效数量;真实信号在 quantity_range)。 */
|
|
85
|
+
items: LineItem[];
|
|
86
|
+
requested_terms: {
|
|
87
|
+
quantity_range: QuantityRange[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface DetailedRfqPayload {
|
|
92
|
+
tier: "detailed";
|
|
93
|
+
rfq: Rfq;
|
|
94
|
+
}
|
|
95
|
+
export type DisclosedRfqPayload = AnonymousRfqPayload | DetailedRfqPayload;
|
|
96
|
+
/** 构造/校验失败。携带 NetworkDisclosurePolicy 拒绝原因列表。 */
|
|
97
|
+
export declare class FanoutDisclosureError extends Error {
|
|
98
|
+
readonly errors: string[];
|
|
99
|
+
constructor(errors: string[]);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 永远私有、结构性排除的 §29 属性:即使 disclosure_profile 显式允许也绝不投影
|
|
103
|
+
* (§4.4 默认 Private:预算 / 急迫度 / 身份 / 联系方式)。校验器同样按此名单拒绝
|
|
104
|
+
* —— 不在 allowlist 语义里,没有豁免路径。
|
|
105
|
+
*/
|
|
106
|
+
export declare const ALWAYS_PRIVATE_ATTRIBUTES: readonly DisclosureAttribute[];
|
|
107
|
+
/** 区间中点(匿名档的 LineItem quantity;真实信号是区间本身)。 */
|
|
108
|
+
export declare function rangeMidpoint(range: {
|
|
109
|
+
min: number;
|
|
110
|
+
max: number;
|
|
111
|
+
}): number;
|
|
112
|
+
export interface DisclosureValidationResult {
|
|
113
|
+
ok: boolean;
|
|
114
|
+
errors: string[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* NetworkDisclosurePolicy 校验(§29 / §30)。纯函数,供每档生成后 fail-closed
|
|
118
|
+
* 与测试负向断言共用。
|
|
119
|
+
*
|
|
120
|
+
* 检查:
|
|
121
|
+
* - 永远私有属性结构性缺席(budget/urgency/contact/organization,含子串兜底);
|
|
122
|
+
* - anonymous 档必须带 quantity_range,且不得带 delivery_before;
|
|
123
|
+
* - detailed 档可选披露项必须在 allowed_attributes 里;
|
|
124
|
+
* - detailed 档精确数量必须在 purchase_quantity 允许时出现,否则必须退回
|
|
125
|
+
* quantity_range(policy 门控,§29 purchase quantity)。
|
|
126
|
+
*/
|
|
127
|
+
export declare function validateNetworkDisclosure(payload: DisclosedRfqPayload, allowed: readonly DisclosureAttribute[]): DisclosureValidationResult;
|
|
128
|
+
export interface DisclosureBuildInput {
|
|
129
|
+
intent: RfqIntent;
|
|
130
|
+
tier: DisclosureTier;
|
|
131
|
+
/** §29 属性 allowlist(来自 FanoutPolicy.disclosure_profile.allowed_attributes)。 */
|
|
132
|
+
allowed_attributes: readonly DisclosureAttribute[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 按档位构造披露 payload。构造即排除(白名单投影,不读取私有 intent 字段);
|
|
136
|
+
* 生成后立即过 NetworkDisclosurePolicy 校验,失败即抛(fail-closed)。
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildDisclosedRfq(input: DisclosureBuildInput): DisclosedRfqPayload;
|
|
@@ -0,0 +1,188 @@
|
|
|
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 { validateRfq } from "../negotiation/domain/objects.js";
|
|
17
|
+
/** 构造/校验失败。携带 NetworkDisclosurePolicy 拒绝原因列表。 */
|
|
18
|
+
export class FanoutDisclosureError extends Error {
|
|
19
|
+
errors;
|
|
20
|
+
constructor(errors) {
|
|
21
|
+
super(`fan-out disclosure payload failed NetworkDisclosurePolicy validation: ${errors.join("; ")}`);
|
|
22
|
+
this.name = "FanoutDisclosureError";
|
|
23
|
+
this.errors = errors;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// 披露档位与 §29 属性映射
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* 永远私有、结构性排除的 §29 属性:即使 disclosure_profile 显式允许也绝不投影
|
|
31
|
+
* (§4.4 默认 Private:预算 / 急迫度 / 身份 / 联系方式)。校验器同样按此名单拒绝
|
|
32
|
+
* —— 不在 allowlist 语义里,没有豁免路径。
|
|
33
|
+
*/
|
|
34
|
+
export const ALWAYS_PRIVATE_ATTRIBUTES = [
|
|
35
|
+
"budget_hints",
|
|
36
|
+
"buyer_urgency",
|
|
37
|
+
"contact_information",
|
|
38
|
+
"organization_identity",
|
|
39
|
+
];
|
|
40
|
+
/** 子串级兜底(双保险):这些私钥名一旦出现在序列化 payload 里即拒绝。 */
|
|
41
|
+
const ALWAYS_PRIVATE_KEYS = ["budget", "urgency", "contact", "email", "phone", "organization"];
|
|
42
|
+
/**
|
|
43
|
+
* detailed 档可选披露项(受 disclosure_profile.allowed_attributes 门控)。
|
|
44
|
+
* 映射:§29 属性 → intent 读取器。预算/急迫度/身份/联系方式不在其中 ——
|
|
45
|
+
* 它们结构性排除,构造路径根本不读取。
|
|
46
|
+
*/
|
|
47
|
+
const OPTIONAL_EXTRACTORS = {
|
|
48
|
+
location_precision: (intent) => intent.location_precision,
|
|
49
|
+
customer_segment: (intent) => intent.customer_segment,
|
|
50
|
+
historical_preferences: (intent) => intent.preferences,
|
|
51
|
+
// 核心字段单独处理;永远私有字段的读取器不存在。
|
|
52
|
+
purchase_quantity: () => undefined,
|
|
53
|
+
organization_identity: () => undefined,
|
|
54
|
+
buyer_urgency: () => undefined,
|
|
55
|
+
contact_information: () => undefined,
|
|
56
|
+
budget_hints: () => undefined,
|
|
57
|
+
};
|
|
58
|
+
const OPTIONAL_DETAILED_ATTRIBUTES = [
|
|
59
|
+
"location_precision",
|
|
60
|
+
"customer_segment",
|
|
61
|
+
"historical_preferences",
|
|
62
|
+
];
|
|
63
|
+
function includes(list, value) {
|
|
64
|
+
return list.includes(value);
|
|
65
|
+
}
|
|
66
|
+
/** 区间中点(匿名档的 LineItem quantity;真实信号是区间本身)。 */
|
|
67
|
+
export function rangeMidpoint(range) {
|
|
68
|
+
return Math.round((range.min + range.max) / 2);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* NetworkDisclosurePolicy 校验(§29 / §30)。纯函数,供每档生成后 fail-closed
|
|
72
|
+
* 与测试负向断言共用。
|
|
73
|
+
*
|
|
74
|
+
* 检查:
|
|
75
|
+
* - 永远私有属性结构性缺席(budget/urgency/contact/organization,含子串兜底);
|
|
76
|
+
* - anonymous 档必须带 quantity_range,且不得带 delivery_before;
|
|
77
|
+
* - detailed 档可选披露项必须在 allowed_attributes 里;
|
|
78
|
+
* - detailed 档精确数量必须在 purchase_quantity 允许时出现,否则必须退回
|
|
79
|
+
* quantity_range(policy 门控,§29 purchase quantity)。
|
|
80
|
+
*/
|
|
81
|
+
export function validateNetworkDisclosure(payload, allowed) {
|
|
82
|
+
const errors = [];
|
|
83
|
+
const serialized = JSON.stringify(payload);
|
|
84
|
+
for (const attr of ALWAYS_PRIVATE_ATTRIBUTES) {
|
|
85
|
+
if (serialized.includes(`"${attr}"`)) {
|
|
86
|
+
errors.push(`payload MUST NOT contain always-private attribute "${attr}"`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const needle of ALWAYS_PRIVATE_KEYS) {
|
|
90
|
+
if (serialized.includes(`"${needle}`)) {
|
|
91
|
+
errors.push(`payload MUST NOT contain private field "${needle}"`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (payload.tier === "anonymous") {
|
|
95
|
+
const terms = payload.rfq.requested_terms;
|
|
96
|
+
if (terms.quantity_range === undefined || terms.quantity_range.length === 0) {
|
|
97
|
+
errors.push("anonymous tier MUST carry a non-empty quantity_range");
|
|
98
|
+
}
|
|
99
|
+
const asRecord = terms;
|
|
100
|
+
if (asRecord["delivery_before"] !== undefined) {
|
|
101
|
+
errors.push("anonymous tier MUST NOT carry delivery_before (exact delivery is private)");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const requested = payload.rfq.requested_terms ?? {};
|
|
106
|
+
for (const attr of OPTIONAL_DETAILED_ATTRIBUTES) {
|
|
107
|
+
if (requested[attr] !== undefined && !includes(allowed, attr)) {
|
|
108
|
+
errors.push(`detailed tier carries "${attr}" but disclosure_profile does not allow it`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// 精确数量门控:purchase_quantity 未允许时,detailed 必须退回 quantity_range。
|
|
112
|
+
const carriesRange = requested["quantity_range"] !== undefined;
|
|
113
|
+
if (!includes(allowed, "purchase_quantity") && !carriesRange) {
|
|
114
|
+
errors.push("detailed tier MUST fall back to quantity_range when purchase_quantity is not allowed");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return { ok: errors.length === 0, errors };
|
|
118
|
+
}
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// 构造器
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
function buildAnonymous(intent) {
|
|
123
|
+
const items = intent.items.map((item) => ({
|
|
124
|
+
sku: item.sku,
|
|
125
|
+
quantity: { value: rangeMidpoint(item.quantity_range), unit: item.unit },
|
|
126
|
+
}));
|
|
127
|
+
const quantity_range = intent.items.map((item) => ({
|
|
128
|
+
sku: item.sku,
|
|
129
|
+
min: item.quantity_range.min,
|
|
130
|
+
max: item.quantity_range.max,
|
|
131
|
+
}));
|
|
132
|
+
return {
|
|
133
|
+
tier: "anonymous",
|
|
134
|
+
rfq: { type: "rfq", items, requested_terms: { quantity_range } },
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function buildDetailed(intent, allowed) {
|
|
138
|
+
const allowPurchaseQuantity = includes(allowed, "purchase_quantity");
|
|
139
|
+
const items = intent.items.map((item) => ({
|
|
140
|
+
sku: item.sku,
|
|
141
|
+
// 精确数量只在 purchase_quantity 允许时投影;否则退回区间中点(不泄精确量)。
|
|
142
|
+
quantity: {
|
|
143
|
+
value: allowPurchaseQuantity ? item.quantity : rangeMidpoint(item.quantity_range),
|
|
144
|
+
unit: item.unit,
|
|
145
|
+
},
|
|
146
|
+
}));
|
|
147
|
+
const requested = {};
|
|
148
|
+
if (!allowPurchaseQuantity) {
|
|
149
|
+
requested["quantity_range"] = intent.items.map((item) => ({
|
|
150
|
+
sku: item.sku,
|
|
151
|
+
min: item.quantity_range.min,
|
|
152
|
+
max: item.quantity_range.max,
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
if (intent.delivery_before !== undefined) {
|
|
156
|
+
requested["delivery_before"] = intent.delivery_before;
|
|
157
|
+
}
|
|
158
|
+
for (const attr of OPTIONAL_DETAILED_ATTRIBUTES) {
|
|
159
|
+
if (!includes(allowed, attr))
|
|
160
|
+
continue;
|
|
161
|
+
const value = OPTIONAL_EXTRACTORS[attr](intent);
|
|
162
|
+
if (value !== undefined) {
|
|
163
|
+
requested[attr] = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const rfq = { type: "rfq", items };
|
|
167
|
+
if (Object.keys(requested).length > 0) {
|
|
168
|
+
rfq.requested_terms = requested;
|
|
169
|
+
}
|
|
170
|
+
return { tier: "detailed", rfq };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 按档位构造披露 payload。构造即排除(白名单投影,不读取私有 intent 字段);
|
|
174
|
+
* 生成后立即过 NetworkDisclosurePolicy 校验,失败即抛(fail-closed)。
|
|
175
|
+
*/
|
|
176
|
+
export function buildDisclosedRfq(input) {
|
|
177
|
+
const payload = input.tier === "anonymous"
|
|
178
|
+
? buildAnonymous(input.intent)
|
|
179
|
+
: buildDetailed(input.intent, input.allowed_attributes);
|
|
180
|
+
const check = validateNetworkDisclosure(payload, input.allowed_attributes);
|
|
181
|
+
if (!check.ok) {
|
|
182
|
+
throw new FanoutDisclosureError(check.errors);
|
|
183
|
+
}
|
|
184
|
+
// wire 结构保证:payload.rfq 必须是合法 KNP RFQ(fail-closed,§4.6)。
|
|
185
|
+
validateRfq(payload.rfq);
|
|
186
|
+
return payload;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=disclosure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disclosure.js","sourceRoot":"","sources":["../../src/fanout/disclosure.ts"],"names":[],"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
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
|
+
* fanout — WP2 RFQ Fan-out 隐私策略 + 多商家 RFQ 编排(基线 §30 / §29 / §4.4 / §16 / §19)。
|
|
18
|
+
*
|
|
19
|
+
* 子模块:
|
|
20
|
+
* - policy.ts FanoutPolicy 类型 + 确定性判定(max_recipients /
|
|
21
|
+
* minimum_trust / disclosure_profile /
|
|
22
|
+
* anonymous_first_round / category_sensitivity);
|
|
23
|
+
* - disclosure.ts 渐进披露构造器(anonymous / detailed 档,私有字段结构性排除);
|
|
24
|
+
* - orchestrator.ts 多商家并行 RFQ + 超时 Offer 收集 + 部分失败容忍 +
|
|
25
|
+
* 比较集聚合(每腿独立 Ledger 链与幂等键)。
|
|
26
|
+
*/
|
|
27
|
+
export { DEFAULT_DISCLOSURE_PROFILE, DEFAULT_FANOUT_POLICY, DISCLOSURE_ATTRIBUTES, DISCLOSURE_TIERS, judgeFanout, matchingCategorySensitivity, stricterTrust, } from "./policy.js";
|
|
28
|
+
export type { CategorySensitivity, DisclosureAttribute, DisclosureProfile, DisclosureTier, FanoutDecision, FanoutExcludeReason, FanoutExcluded, FanoutJudgeInput, FanoutPolicy, FanoutRecipient, FanoutTrustInput, FanoutTrustSignal, } from "./policy.js";
|
|
29
|
+
export { ALWAYS_PRIVATE_ATTRIBUTES, FanoutDisclosureError, buildDisclosedRfq, rangeMidpoint, validateNetworkDisclosure, } from "./disclosure.js";
|
|
30
|
+
export type { AnonymousRfqPayload, DetailedRfqPayload, DisclosedRfqPayload, DisclosureBuildInput, DisclosureValidationResult, QuantityRange, RfqIntent, RfqIntentItem, } from "./disclosure.js";
|
|
31
|
+
export { DEFAULT_FANOUT_CAPABILITY, DEFAULT_FANOUT_TIMEOUT_MS, DEFAULT_POLL_INTERVAL_MS, FanoutOrchestrator, buildComparisonSet, compareRows, extractDelivery, extractKnpEnvelopeFromState, extractUnitPrice, } from "./orchestrator.js";
|
|
32
|
+
export type { FanoutComparisonRow, FanoutLegResult, FanoutLegSpec, FanoutOrchestratorDeps, FanoutResult, LegOutcomeKind, } from "./orchestrator.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
* fanout — WP2 RFQ Fan-out 隐私策略 + 多商家 RFQ 编排(基线 §30 / §29 / §4.4 / §16 / §19)。
|
|
18
|
+
*
|
|
19
|
+
* 子模块:
|
|
20
|
+
* - policy.ts FanoutPolicy 类型 + 确定性判定(max_recipients /
|
|
21
|
+
* minimum_trust / disclosure_profile /
|
|
22
|
+
* anonymous_first_round / category_sensitivity);
|
|
23
|
+
* - disclosure.ts 渐进披露构造器(anonymous / detailed 档,私有字段结构性排除);
|
|
24
|
+
* - orchestrator.ts 多商家并行 RFQ + 超时 Offer 收集 + 部分失败容忍 +
|
|
25
|
+
* 比较集聚合(每腿独立 Ledger 链与幂等键)。
|
|
26
|
+
*/
|
|
27
|
+
export { DEFAULT_DISCLOSURE_PROFILE, DEFAULT_FANOUT_POLICY, DISCLOSURE_ATTRIBUTES, DISCLOSURE_TIERS, judgeFanout, matchingCategorySensitivity, stricterTrust, } from "./policy.js";
|
|
28
|
+
export { ALWAYS_PRIVATE_ATTRIBUTES, FanoutDisclosureError, buildDisclosedRfq, rangeMidpoint, validateNetworkDisclosure, } from "./disclosure.js";
|
|
29
|
+
export { DEFAULT_FANOUT_CAPABILITY, DEFAULT_FANOUT_TIMEOUT_MS, DEFAULT_POLL_INTERVAL_MS, FanoutOrchestrator, buildComparisonSet, compareRows, extractDelivery, extractKnpEnvelopeFromState, extractUnitPrice, } from "./orchestrator.js";
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fanout/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,2BAA2B,EAC3B,aAAa,GACd,MAAM,aAAa,CAAC;AAgBrB,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
* fanout — 多商家 RFQ 编排器(基线 §16 / §19 / §30)。
|
|
18
|
+
*
|
|
19
|
+
* 向 N 个通道并行发 RFQ(每个商家独立 negotiation_id,双边语义不混淆);
|
|
20
|
+
* 带超时的 Offer 收集;部分失败容忍(单个商家超时/拒绝不影响其他腿);
|
|
21
|
+
* 结果聚合为比较集(price / delivery / terms 维度结构化)。每腿独立 Ledger
|
|
22
|
+
* 链(以 per-leg negotiation_id 为键)与幂等键((sender_identity, message_id),
|
|
23
|
+
* 每腿 message_id 独立生成)。
|
|
24
|
+
*
|
|
25
|
+
* §16 selected_nonbinding:Buyer 可以同时持有多个不同 Merchant 的 Agreement,
|
|
26
|
+
* 在本地选择其中一个 —— Merchant 无需知道 Buyer 是否选择了其他 Merchant。
|
|
27
|
+
* 因此编排器对每腿独立开 negotiation,绝不把跨商家的比较集写回任何一腿。
|
|
28
|
+
*
|
|
29
|
+
* Fail-closed(§4.6 / §4.5):入站 envelope 在进入 Ledger 前必须过 schema 校验
|
|
30
|
+
* + digest 验签;任何一腿的通道/校验失败都以结构化 leg result 返回,不静默
|
|
31
|
+
* 吞掉,也不影响其他腿。
|
|
32
|
+
*/
|
|
33
|
+
import type { ChannelHandle, ChannelOpenInput, CounterpartyProfile, RemoteState } from "../counterparty/index.js";
|
|
34
|
+
import type { NegotiationEnvelope } from "../negotiation/domain/envelope.js";
|
|
35
|
+
import type { Offer } from "../negotiation/domain/objects.js";
|
|
36
|
+
import type { TermSet } from "../negotiation/domain/common.js";
|
|
37
|
+
import type { LedgerStore } from "../negotiation/ledger/index.js";
|
|
38
|
+
import type { DisclosedRfqPayload } from "./disclosure.js";
|
|
39
|
+
export declare const DEFAULT_FANOUT_TIMEOUT_MS = 30000;
|
|
40
|
+
export declare const DEFAULT_POLL_INTERVAL_MS = 100;
|
|
41
|
+
export declare const DEFAULT_FANOUT_CAPABILITY = "knp.a2a.direct";
|
|
42
|
+
/** 编排器依赖:唯一接缝是 ChannelHandle(§33),Ledger 每腿独立链。 */
|
|
43
|
+
export interface FanoutOrchestratorDeps {
|
|
44
|
+
/** 本方身份(Ledger identity 的 sender 侧 / 幂等键一半)。 */
|
|
45
|
+
sender_identity: string;
|
|
46
|
+
/** 打开一条绑定到 negotiation 的通道(缺省用 profile 首选候选,失败不降级)。 */
|
|
47
|
+
openChannel: (profile: CounterpartyProfile, input: ChannelOpenInput) => Promise<ChannelHandle>;
|
|
48
|
+
/** 每腿独立 Ledger 链(以 negotiation_id 为键);缺省不落账。 */
|
|
49
|
+
ledger?: LedgerStore;
|
|
50
|
+
/** envelope capability(缺省 knp.a2a.direct)。 */
|
|
51
|
+
capability?: string;
|
|
52
|
+
/** 从 RemoteState 提取远端最新 KNP envelope(缺省 direct 通道形状)。 */
|
|
53
|
+
extractEnvelope?: (state: RemoteState) => NegotiationEnvelope | null;
|
|
54
|
+
now?: () => string;
|
|
55
|
+
/** 时钟(超时测量;缺省 Date.now)。 */
|
|
56
|
+
clock?: () => number;
|
|
57
|
+
/** 轮询间隔 ms(缺省 100)。 */
|
|
58
|
+
pollIntervalMs?: number;
|
|
59
|
+
}
|
|
60
|
+
/** 单腿规格:同一 RFQ 意图的某档位 payload 发给一个商家。 */
|
|
61
|
+
export interface FanoutLegSpec {
|
|
62
|
+
profile: CounterpartyProfile;
|
|
63
|
+
/** 每腿独立 negotiation_id;缺省由编排器生成(§16:双边语义不混淆)。 */
|
|
64
|
+
negotiation_id?: string;
|
|
65
|
+
/** 该腿披露档位 payload。 */
|
|
66
|
+
payload: DisclosedRfqPayload;
|
|
67
|
+
/** 请求超时 ms(缺省 DEFAULT_FANOUT_TIMEOUT_MS)。 */
|
|
68
|
+
timeoutMs?: number;
|
|
69
|
+
}
|
|
70
|
+
export type LegOutcomeKind = "offer_received" | "no_offer" | "declined" | "timed_out" | "failed";
|
|
71
|
+
/** 单腿结果。部分失败容忍:失败腿以结构化 outcome 返回,不影响其他腿。 */
|
|
72
|
+
export interface FanoutLegResult {
|
|
73
|
+
identity: string;
|
|
74
|
+
negotiation_id: string;
|
|
75
|
+
/** 该腿出站 message_id(幂等键 (sender_identity, message_id) 的另一半)。 */
|
|
76
|
+
message_id: string;
|
|
77
|
+
outcome: LegOutcomeKind;
|
|
78
|
+
/** offer_received 时的 Offer(wire 校验通过)。 */
|
|
79
|
+
offer?: Offer;
|
|
80
|
+
/** failed / timed_out 的结构化错误。 */
|
|
81
|
+
error?: {
|
|
82
|
+
code: string;
|
|
83
|
+
message: string;
|
|
84
|
+
};
|
|
85
|
+
/** 消息往返耗时 ms。 */
|
|
86
|
+
elapsed_ms: number;
|
|
87
|
+
}
|
|
88
|
+
/** 比较集行:price / delivery / terms 结构化维度(§19 比较 → 对 Top N counter)。 */
|
|
89
|
+
export interface FanoutComparisonRow {
|
|
90
|
+
identity: string;
|
|
91
|
+
negotiation_id: string;
|
|
92
|
+
offer_id: string;
|
|
93
|
+
price: {
|
|
94
|
+
currency: string;
|
|
95
|
+
amount_minor: number;
|
|
96
|
+
} | null;
|
|
97
|
+
delivery_before?: string;
|
|
98
|
+
terms: Record<string, unknown>;
|
|
99
|
+
valid_until?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface FanoutResult {
|
|
102
|
+
/** 按价格升序(同货币内)排列的 Offer 比较集。 */
|
|
103
|
+
offers: FanoutComparisonRow[];
|
|
104
|
+
/** 每条腿的结果(含失败腿)。 */
|
|
105
|
+
legs: FanoutLegResult[];
|
|
106
|
+
offer_count: number;
|
|
107
|
+
started_at: string;
|
|
108
|
+
completed_at: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 缺省入站提取器:从 A2A task.status.message 的 data part 取 `knp_envelope`
|
|
112
|
+
* (§24.3 约定)。hosted 通道的调用方注入自己的 extractEnvelope。
|
|
113
|
+
*/
|
|
114
|
+
export declare function extractKnpEnvelopeFromState(state: RemoteState): NegotiationEnvelope | null;
|
|
115
|
+
/** 从 Offer terms 提取 unit price(items[0].unit_price 优先,其次 price_terms.unit_price)。 */
|
|
116
|
+
export declare function extractUnitPrice(terms: TermSet): {
|
|
117
|
+
currency: string;
|
|
118
|
+
amount_minor: number;
|
|
119
|
+
} | null;
|
|
120
|
+
/** 从 Offer terms 提取交期维度。 */
|
|
121
|
+
export declare function extractDelivery(terms: TermSet): {
|
|
122
|
+
delivery_before?: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* 比较集排序(确定性):
|
|
126
|
+
* 1. 有价格在前;2. 货币分组(不同货币不做数值比较,按货币码排序);
|
|
127
|
+
* 3. 同货币价格升序;4. 交期早优先(ISO 字符串排序 = 时间排序);
|
|
128
|
+
* 5. identity 升序 tie-break。
|
|
129
|
+
*/
|
|
130
|
+
export declare function compareRows(a: FanoutComparisonRow, b: FanoutComparisonRow): number;
|
|
131
|
+
/** 把各腿结果聚合为比较集(price / delivery / terms 结构化;无 Offer 的腿不进入)。 */
|
|
132
|
+
export declare function buildComparisonSet(legs: FanoutLegResult[]): FanoutComparisonRow[];
|
|
133
|
+
export declare class FanoutOrchestrator {
|
|
134
|
+
private readonly deps;
|
|
135
|
+
constructor(deps: FanoutOrchestratorDeps);
|
|
136
|
+
private clock;
|
|
137
|
+
private now;
|
|
138
|
+
private capability;
|
|
139
|
+
private identitySnapshot;
|
|
140
|
+
private capabilitySnapshot;
|
|
141
|
+
/** 每腿独立落账;缺省 Ledger 为 no-op。append 失败向上抛(audit trail 损坏 = fail-closed)。 */
|
|
142
|
+
private appendLedger;
|
|
143
|
+
/**
|
|
144
|
+
* 向 N 个通道并行发 RFQ。Promise.allSettled 保证单腿崩溃不吞掉其他腿结果
|
|
145
|
+
* (部分失败容忍,§19)。每腿独立 negotiation_id / message_id。
|
|
146
|
+
*/
|
|
147
|
+
fanout(legs: FanoutLegSpec[]): Promise<FanoutResult>;
|
|
148
|
+
private runLeg;
|
|
149
|
+
/** 带超时的 Offer 收集:轮询 getState 直到 deadline / 收到新 envelope / 终态。 */
|
|
150
|
+
private waitForOffer;
|
|
151
|
+
/** 把 wait 结果解析为 leg outcome,并落账该腿结果(fail-closed)。 */
|
|
152
|
+
private resolveWait;
|
|
153
|
+
}
|