@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,420 @@
|
|
|
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
|
+
* A2A Server(入站侧,WP2)node:http 实现。零新增依赖。
|
|
18
|
+
*
|
|
19
|
+
* 端点面:
|
|
20
|
+
* GET {wellKnownPath} Agent Card(基线 §26 / 子规范 §24.1),默认
|
|
21
|
+
* `/.well-known/agent-card.json`;
|
|
22
|
+
* POST {a2aPath} JSON-RPC A2A endpoint(默认 "/"):message/send、
|
|
23
|
+
* tasks/get;其他 method → -32601。
|
|
24
|
+
*
|
|
25
|
+
* 请求路径顺序(全部 fail-closed):
|
|
26
|
+
* 1. 路由 → 2. 认证(AuthVerifier 接缝,缺省 loopback-only)→
|
|
27
|
+
* 3. body 大小上限(默认 1 MiB)→ 4. JSON 解析(失败 400)→
|
|
28
|
+
* 5. JSON-RPC 帧校验(失败 400)→ 6. method 分发 → 7. InboundPipeline。
|
|
29
|
+
*
|
|
30
|
+
* 内部异常一律收敛为通用 "internal error"(-32603),绝不把 handler / ledger 的
|
|
31
|
+
* 内部细节回显给远端(基线 §4.5 / §36-11)。
|
|
32
|
+
*/
|
|
33
|
+
import http from "node:http";
|
|
34
|
+
import { isJsonRpcRequest } from "../client/index.js";
|
|
35
|
+
import { NegotiationValidationError } from "../../negotiation/domain/common.js";
|
|
36
|
+
import { parseUcpAgentHeader, UCP_AGENT_HEADER } from "../ucp-agent.js";
|
|
37
|
+
import { buildAgentCard } from "./card.js";
|
|
38
|
+
import { buildUcpProfile, WELL_KNOWN_UCP_PATH } from "./ucp.js";
|
|
39
|
+
import { defaultAuthVerifier } from "./auth.js";
|
|
40
|
+
import { defaultHandler } from "./handler.js";
|
|
41
|
+
import { InboundPipeline } from "./pipeline.js";
|
|
42
|
+
import { TaskRegistry } from "./task-registry.js";
|
|
43
|
+
import { A2AServerThrottle, domainFromUcpProfile } from "./throttle.js";
|
|
44
|
+
import { authError, fromNegotiationError, internalServerError, JSONRPC_CODES, payloadTooLarge, rateLimited, ServerProtocolError, } from "./errors.js";
|
|
45
|
+
const DEFAULT_MAX_PAYLOAD_BYTES = 1024 * 1024;
|
|
46
|
+
const DEFAULT_WELL_KNOWN_PATH = "/.well-known/agent-card.json";
|
|
47
|
+
function normalizePath(p) {
|
|
48
|
+
if (p === undefined || p === "")
|
|
49
|
+
return "/";
|
|
50
|
+
return p.startsWith("/") ? p : `/${p}`;
|
|
51
|
+
}
|
|
52
|
+
function resolveCardConfig(provider) {
|
|
53
|
+
return typeof provider === "function" ? provider() : provider;
|
|
54
|
+
}
|
|
55
|
+
function pathOf(url) {
|
|
56
|
+
if (url === undefined)
|
|
57
|
+
return "/";
|
|
58
|
+
const queryIndex = url.indexOf("?");
|
|
59
|
+
return queryIndex >= 0 ? url.slice(0, queryIndex) : url;
|
|
60
|
+
}
|
|
61
|
+
function requireParamsObject(params) {
|
|
62
|
+
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
63
|
+
throw new ServerProtocolError({
|
|
64
|
+
code: JSONRPC_CODES.INVALID_PARAMS,
|
|
65
|
+
message: "params must be an object",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return params;
|
|
69
|
+
}
|
|
70
|
+
function readBody(req, maxBytes) {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
const contentLength = Number(req.headers["content-length"] ?? "0");
|
|
73
|
+
if (Number.isFinite(contentLength) && contentLength > maxBytes) {
|
|
74
|
+
req.resume();
|
|
75
|
+
resolve({ ok: false });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const chunks = [];
|
|
79
|
+
let total = 0;
|
|
80
|
+
let settled = false;
|
|
81
|
+
const finish = (result) => {
|
|
82
|
+
if (settled)
|
|
83
|
+
return;
|
|
84
|
+
settled = true;
|
|
85
|
+
resolve(result);
|
|
86
|
+
};
|
|
87
|
+
req.on("data", (chunk) => {
|
|
88
|
+
if (settled)
|
|
89
|
+
return;
|
|
90
|
+
total += chunk.length;
|
|
91
|
+
if (total > maxBytes) {
|
|
92
|
+
req.pause();
|
|
93
|
+
finish({ ok: false });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
chunks.push(chunk);
|
|
97
|
+
});
|
|
98
|
+
req.on("end", () => finish({ ok: true, body: Buffer.concat(chunks) }));
|
|
99
|
+
req.on("error", () => finish({ ok: false }));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function sendJson(res, status, body) {
|
|
103
|
+
const payload = JSON.stringify(body);
|
|
104
|
+
res.writeHead(status, {
|
|
105
|
+
"content-type": "application/json",
|
|
106
|
+
"content-length": Buffer.byteLength(payload),
|
|
107
|
+
});
|
|
108
|
+
res.end(payload);
|
|
109
|
+
}
|
|
110
|
+
function sendJsonError(res, id, status, error) {
|
|
111
|
+
sendJson(res, status, { jsonrpc: "2.0", id, error });
|
|
112
|
+
}
|
|
113
|
+
function sendText(res, status, text) {
|
|
114
|
+
res.writeHead(status, { "content-type": "text/plain; charset=utf-8" });
|
|
115
|
+
res.end(text);
|
|
116
|
+
}
|
|
117
|
+
export class A2AServer {
|
|
118
|
+
cardConfig;
|
|
119
|
+
authVerifier;
|
|
120
|
+
maxPayloadBytes;
|
|
121
|
+
now;
|
|
122
|
+
wellKnownPath;
|
|
123
|
+
ucpOptions;
|
|
124
|
+
pipeline;
|
|
125
|
+
throttle;
|
|
126
|
+
constructor(options) {
|
|
127
|
+
this.cardConfig = options.card;
|
|
128
|
+
this.authVerifier = options.authVerifier ?? defaultAuthVerifier();
|
|
129
|
+
this.maxPayloadBytes = options.maxPayloadBytes ?? DEFAULT_MAX_PAYLOAD_BYTES;
|
|
130
|
+
if (this.maxPayloadBytes <= 0) {
|
|
131
|
+
throw new Error("A2AServer: maxPayloadBytes must be positive");
|
|
132
|
+
}
|
|
133
|
+
this.now = options.now ?? (() => new Date().toISOString());
|
|
134
|
+
this.wellKnownPath = options.wellKnownPath ?? DEFAULT_WELL_KNOWN_PATH;
|
|
135
|
+
const ucpOpt = options.ucp;
|
|
136
|
+
if (ucpOpt === undefined ||
|
|
137
|
+
ucpOpt === false ||
|
|
138
|
+
(typeof ucpOpt === "object" && ucpOpt.enabled === false)) {
|
|
139
|
+
this.ucpOptions = undefined;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.ucpOptions = ucpOpt === true ? {} : ucpOpt;
|
|
143
|
+
}
|
|
144
|
+
const handler = options.handler ?? defaultHandler();
|
|
145
|
+
const tasks = new TaskRegistry();
|
|
146
|
+
this.throttle =
|
|
147
|
+
options.throttle === undefined
|
|
148
|
+
? undefined
|
|
149
|
+
: options.throttle instanceof A2AServerThrottle
|
|
150
|
+
? options.throttle
|
|
151
|
+
: new A2AServerThrottle(options.throttle);
|
|
152
|
+
this.pipeline = new InboundPipeline({
|
|
153
|
+
handler,
|
|
154
|
+
idempotency: options.idempotency,
|
|
155
|
+
ledger: options.ledger,
|
|
156
|
+
tasks,
|
|
157
|
+
now: this.now,
|
|
158
|
+
logError: this.logError,
|
|
159
|
+
throttle: this.throttle,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
logError = (message, err) => {
|
|
163
|
+
// 服务端日志;细节绝不回显给远端(§4.5)。
|
|
164
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
165
|
+
console.error(`[a2a-server] ${message}: ${detail}`);
|
|
166
|
+
};
|
|
167
|
+
/** 返回 node:http request listener。 */
|
|
168
|
+
handler() {
|
|
169
|
+
return (req, res) => {
|
|
170
|
+
void this.handleRequest(req, res);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** 创建并返回绑定本 handler 的 node:http server。 */
|
|
174
|
+
createServer() {
|
|
175
|
+
const server = http.createServer(this.handler());
|
|
176
|
+
server.on("clientError", () => {
|
|
177
|
+
// 忽略畸形客户端流量(中止的 socket 等),不让其崩溃 server。
|
|
178
|
+
});
|
|
179
|
+
return server;
|
|
180
|
+
}
|
|
181
|
+
async handleRequest(req, res) {
|
|
182
|
+
try {
|
|
183
|
+
const pathname = pathOf(req.url);
|
|
184
|
+
const cardConfig = resolveCardConfig(this.cardConfig);
|
|
185
|
+
const a2aPath = normalizePath(cardConfig.a2aPath);
|
|
186
|
+
if (pathname === this.wellKnownPath) {
|
|
187
|
+
await this.handleWellKnown(req, res);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
// WP3 §25:UCP Profile 标准发现入口(/.well-known/ucp)。未配置发布时 404。
|
|
191
|
+
if (pathname === WELL_KNOWN_UCP_PATH) {
|
|
192
|
+
if (this.ucpOptions === undefined) {
|
|
193
|
+
sendText(res, 404, "not found");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
await this.handleUcp(req, res);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (pathname === a2aPath) {
|
|
200
|
+
await this.handleA2a(req, res);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
sendText(res, 404, "not found");
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
this.logError("a2a request routing failed", err);
|
|
207
|
+
if (!res.headersSent) {
|
|
208
|
+
sendText(res, 500, "internal error");
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
res.end();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async authenticate(req, body) {
|
|
216
|
+
// node:http 的 IncomingMessage.socket 静态类型是 net.Socket;TLS 下实为
|
|
217
|
+
// TLSSocket(带 encrypted)。用类型守卫读取,HTTPS 部署下 scheme 才是 https。
|
|
218
|
+
const socketTls = req.socket;
|
|
219
|
+
const result = await this.authVerifier.verify({
|
|
220
|
+
remoteAddress: req.socket.remoteAddress,
|
|
221
|
+
authorizationHeader: req.headers.authorization,
|
|
222
|
+
method: req.method ?? "",
|
|
223
|
+
url: req.url ?? "",
|
|
224
|
+
// WP5 HTTP Message Signature 需要原始头、请求体与 scheme(@target-uri 重建)。
|
|
225
|
+
scheme: socketTls.encrypted === true ? "https" : "http",
|
|
226
|
+
headers: req.headers,
|
|
227
|
+
body,
|
|
228
|
+
});
|
|
229
|
+
if (!result.authenticated) {
|
|
230
|
+
const { httpStatus, body } = authError(result.protocolCode ?? "authorization_failed");
|
|
231
|
+
return { error: { httpStatus, body } };
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
identity: result.identity ?? "unknown",
|
|
235
|
+
remoteAddress: req.socket.remoteAddress,
|
|
236
|
+
trustLevel: result.trustLevel,
|
|
237
|
+
identityVerified: result.identityVerified,
|
|
238
|
+
fingerprintChanged: result.fingerprintChanged,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
async handleWellKnown(req, res) {
|
|
242
|
+
if (req.method !== "GET") {
|
|
243
|
+
sendText(res, 405, "method not allowed");
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const auth = await this.authenticate(req);
|
|
247
|
+
if ("error" in auth) {
|
|
248
|
+
sendJsonError(res, null, auth.error.httpStatus, auth.error.body);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
let card;
|
|
252
|
+
try {
|
|
253
|
+
card = buildAgentCard(resolveCardConfig(this.cardConfig));
|
|
254
|
+
}
|
|
255
|
+
catch (err) {
|
|
256
|
+
this.logError("failed to build agent card", err);
|
|
257
|
+
sendText(res, 500, "internal error");
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
sendJson(res, 200, card);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* UCP Profile 端点(WP3):GET /.well-known/ucp。
|
|
264
|
+
* 响应头 Cache-Control: public, max-age=N(N>=60,UCP 规范强制);
|
|
265
|
+
* 内容由 buildUcpProfile 强制过 validate 自洽(fail-closed)。
|
|
266
|
+
*/
|
|
267
|
+
async handleUcp(req, res) {
|
|
268
|
+
if (req.method !== "GET") {
|
|
269
|
+
sendText(res, 405, "method not allowed");
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const auth = await this.authenticate(req);
|
|
273
|
+
if ("error" in auth) {
|
|
274
|
+
sendJsonError(res, null, auth.error.httpStatus, auth.error.body);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
let built;
|
|
278
|
+
try {
|
|
279
|
+
built = buildUcpProfile(resolveCardConfig(this.cardConfig), {
|
|
280
|
+
wellKnownPath: this.wellKnownPath,
|
|
281
|
+
...this.ucpOptions,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
this.logError("failed to build UCP profile", err);
|
|
286
|
+
sendText(res, 500, "internal error");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const payload = JSON.stringify(built.profile);
|
|
290
|
+
res.writeHead(200, {
|
|
291
|
+
"content-type": "application/json",
|
|
292
|
+
"content-length": Buffer.byteLength(payload),
|
|
293
|
+
"cache-control": built.cacheControl,
|
|
294
|
+
});
|
|
295
|
+
res.end(payload);
|
|
296
|
+
}
|
|
297
|
+
async handleA2a(req, res) {
|
|
298
|
+
if (req.method !== "POST") {
|
|
299
|
+
sendText(res, 405, "method not allowed");
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
// 先读 body(有大小上限):WP5 content-digest 验签需要请求体;顺序调整对
|
|
303
|
+
// 既有认证语义无影响——认证失败仍返回 401/403,只是 body 先被读取。
|
|
304
|
+
const bodyResult = await readBody(req, this.maxPayloadBytes);
|
|
305
|
+
if (!bodyResult.ok) {
|
|
306
|
+
const { httpStatus, body } = payloadTooLarge(this.maxPayloadBytes);
|
|
307
|
+
sendJsonError(res, null, httpStatus, body);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const auth = await this.authenticate(req, bodyResult.body);
|
|
311
|
+
if ("error" in auth) {
|
|
312
|
+
sendJsonError(res, null, auth.error.httpStatus, auth.error.body);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// WP3 §25.1:解析对端 UCP-Agent 宣告(只读,不强制 —— 缺失/畸形不拒绝)。
|
|
316
|
+
const ucpAgentProfile = parseUcpAgentHeader(req.headers[UCP_AGENT_HEADER]);
|
|
317
|
+
let parsed;
|
|
318
|
+
try {
|
|
319
|
+
parsed = JSON.parse(bodyResult.body.toString("utf8"));
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
sendJsonError(res, null, 400, {
|
|
323
|
+
code: JSONRPC_CODES.PARSE_ERROR,
|
|
324
|
+
message: "request body is not valid JSON",
|
|
325
|
+
});
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (!isJsonRpcRequest(parsed)) {
|
|
329
|
+
sendJsonError(res, null, 400, {
|
|
330
|
+
code: JSONRPC_CODES.INVALID_REQUEST,
|
|
331
|
+
message: "invalid JSON-RPC request",
|
|
332
|
+
});
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const { id, method, params } = parsed;
|
|
336
|
+
try {
|
|
337
|
+
const result = await this.dispatch(method, params, auth, ucpAgentProfile);
|
|
338
|
+
sendJson(res, 200, { jsonrpc: "2.0", id, result });
|
|
339
|
+
}
|
|
340
|
+
catch (err) {
|
|
341
|
+
sendJsonError(res, id, 200, this.toJsonRpcErrorBody(err));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
toJsonRpcErrorBody(err) {
|
|
345
|
+
if (err instanceof ServerProtocolError)
|
|
346
|
+
return err.body;
|
|
347
|
+
if (err instanceof NegotiationValidationError)
|
|
348
|
+
return fromNegotiationError(err).body;
|
|
349
|
+
this.logError("a2a jsonrpc request failed", err);
|
|
350
|
+
return internalServerError().body;
|
|
351
|
+
}
|
|
352
|
+
async dispatch(method, params, caller, ucpAgentProfile) {
|
|
353
|
+
switch (method) {
|
|
354
|
+
case "message/send":
|
|
355
|
+
return this.handleMessageSend(params, caller, ucpAgentProfile);
|
|
356
|
+
case "tasks/get":
|
|
357
|
+
return this.handleTasksGet(params, caller, ucpAgentProfile);
|
|
358
|
+
default:
|
|
359
|
+
throw new ServerProtocolError({
|
|
360
|
+
code: JSONRPC_CODES.METHOD_NOT_FOUND,
|
|
361
|
+
message: `method ${method} not found`,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async handleMessageSend(params, caller, ucpAgentProfile) {
|
|
366
|
+
const p = requireParamsObject(params);
|
|
367
|
+
if (p.message === undefined) {
|
|
368
|
+
throw new ServerProtocolError({
|
|
369
|
+
code: JSONRPC_CODES.INVALID_PARAMS,
|
|
370
|
+
message: "params.message is required",
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
const result = await this.pipeline.sendMessage({ message: p.message, contextId: p.contextId }, {
|
|
374
|
+
senderIdentity: caller.identity,
|
|
375
|
+
remoteAddress: caller.remoteAddress,
|
|
376
|
+
ucpAgentProfile,
|
|
377
|
+
trustLevel: caller.trustLevel,
|
|
378
|
+
identityVerified: caller.identityVerified,
|
|
379
|
+
fingerprintChanged: caller.fingerprintChanged,
|
|
380
|
+
});
|
|
381
|
+
return { task: result.task };
|
|
382
|
+
}
|
|
383
|
+
async handleTasksGet(params, caller, ucpAgentProfile) {
|
|
384
|
+
const p = requireParamsObject(params);
|
|
385
|
+
const id = p.id;
|
|
386
|
+
if (typeof id !== "string" || id.length === 0) {
|
|
387
|
+
throw new ServerProtocolError({
|
|
388
|
+
code: JSONRPC_CODES.INVALID_PARAMS,
|
|
389
|
+
message: "params.id must be a non-empty string",
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
// 限流(评审项 B3):tasks/get 对未知 id 走全 Ledger 线性扫描且此前完全
|
|
393
|
+
// 不受限流(throttle 只挂在 message/send)——认证客户端可高频刷 CPU 且
|
|
394
|
+
// 开销随 Ledger 规模线性放大。与 message/send 同档位判定(identity/
|
|
395
|
+
// domain 窗口 + malformed budget)。
|
|
396
|
+
if (this.throttle !== undefined) {
|
|
397
|
+
const decision = this.throttle.check({
|
|
398
|
+
identity: caller.identity,
|
|
399
|
+
remoteAddress: caller.remoteAddress,
|
|
400
|
+
domain: domainFromUcpProfile(ucpAgentProfile),
|
|
401
|
+
identityVerified: caller.identityVerified,
|
|
402
|
+
trustLevel: caller.trustLevel,
|
|
403
|
+
fingerprintChanged: caller.fingerprintChanged,
|
|
404
|
+
});
|
|
405
|
+
if (!decision.allowed) {
|
|
406
|
+
throw rateLimited(decision.retryAfterSeconds, decision.reason);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const task = await this.pipeline.getTask(id);
|
|
410
|
+
if (task === null) {
|
|
411
|
+
throw new ServerProtocolError({
|
|
412
|
+
code: JSONRPC_CODES.TASK_NOT_FOUND,
|
|
413
|
+
message: `task ${id} not found`,
|
|
414
|
+
data: { taskId: id },
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
return { task };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/a2a/server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGxE,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,WAAW,EACX,mBAAmB,GACpB,MAAM,aAAa,CAAC;AASrB,MAAM,yBAAyB,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAE/D,SAAS,aAAa,CAAC,CAAqB;IAC1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C,cAAc;gBAClC,OAAO,EAAE,sCAAsC;aAChD,CAAC,CAAC;QACL,CAAC;QACD,kDAAkD;QAClD,mDAAmD;QACnD,mDAAmD;QACnD,iCAAiC;QACjC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gBACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,MAAM,EAAE,oBAAoB,CAAC,eAAe,CAAC;gBAC7C,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;aAC9C,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,WAAW,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC7C,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,mBAAmB,CAAC;gBAC5B,IAAI,EAAE,aAAa,CAAC,cAAc;gBAClC,OAAO,EAAE,QAAQ,EAAE,YAAY;gBAC/B,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;aACrB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -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
|
+
import type { A2ATask, A2ATaskState } from "../client/index.js";
|
|
17
|
+
import type { LedgerStore } from "../../negotiation/ledger/index.js";
|
|
18
|
+
export declare function newTaskId(): string;
|
|
19
|
+
export declare function newArtifactId(): string;
|
|
20
|
+
export declare function isKnownTaskState(value: unknown): value is A2ATaskState;
|
|
21
|
+
export declare class TaskRegistry {
|
|
22
|
+
private readonly tasks;
|
|
23
|
+
set(taskId: string, task: A2ATask): void;
|
|
24
|
+
get(taskId: string): A2ATask | null;
|
|
25
|
+
/**
|
|
26
|
+
* 从 Ledger 还原任务视图:扫描事件,命中 remote_task_id === taskId 的首条
|
|
27
|
+
* 记录,返回最小 A2ATask(id + status.state)。结果不依赖内存状态。
|
|
28
|
+
* 未命中返回 null。
|
|
29
|
+
*/
|
|
30
|
+
resolveFromLedger(ledger: LedgerStore, taskId: string): A2ATask | null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
* 任务注册表 + Ledger 视图映射(子规范 §23 A2A Message vs Task / §24.5 taskId)。
|
|
18
|
+
*
|
|
19
|
+
* message/send 会生成一个 A2A Task(task_<uuidv7>),状态记在内存注册表;
|
|
20
|
+
* tasks/get 优先查内存,miss 时回退到 Ledger 视图(§23 Recovery 第 4 步:
|
|
21
|
+
* "retrieve current remote A2A context/task state")—— ledger 事件携带
|
|
22
|
+
* remote_task_id / task_state,即使 server 重启(内存丢失、ledger 持久)也能
|
|
23
|
+
* 还原任务状态。
|
|
24
|
+
*/
|
|
25
|
+
import { uuidv7 } from "../../negotiation/domain/identifiers.js";
|
|
26
|
+
import { A2A_TASK_STATES } from "../client/index.js";
|
|
27
|
+
export function newTaskId() {
|
|
28
|
+
return `task_${uuidv7()}`;
|
|
29
|
+
}
|
|
30
|
+
export function newArtifactId() {
|
|
31
|
+
return `art_${uuidv7()}`;
|
|
32
|
+
}
|
|
33
|
+
export function isKnownTaskState(value) {
|
|
34
|
+
return typeof value === "string" && A2A_TASK_STATES.includes(value);
|
|
35
|
+
}
|
|
36
|
+
export class TaskRegistry {
|
|
37
|
+
tasks = new Map();
|
|
38
|
+
set(taskId, task) {
|
|
39
|
+
this.tasks.set(taskId, task);
|
|
40
|
+
}
|
|
41
|
+
get(taskId) {
|
|
42
|
+
const task = this.tasks.get(taskId);
|
|
43
|
+
return task === undefined ? null : task;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 从 Ledger 还原任务视图:扫描事件,命中 remote_task_id === taskId 的首条
|
|
47
|
+
* 记录,返回最小 A2ATask(id + status.state)。结果不依赖内存状态。
|
|
48
|
+
* 未命中返回 null。
|
|
49
|
+
*/
|
|
50
|
+
resolveFromLedger(ledger, taskId) {
|
|
51
|
+
for (const negotiationId of ledger.listNegotiations()) {
|
|
52
|
+
for (const event of ledger.events(negotiationId)) {
|
|
53
|
+
if (event.remote_task_id !== taskId)
|
|
54
|
+
continue;
|
|
55
|
+
const result = event.outcome.kind === "ok" ? event.outcome.result : undefined;
|
|
56
|
+
const state = result === undefined ? undefined : result["task_state"];
|
|
57
|
+
if (isKnownTaskState(state)) {
|
|
58
|
+
return { id: taskId, status: { state } };
|
|
59
|
+
}
|
|
60
|
+
// 记录存在但 task_state 不可识别 → fail-closed:不猜测状态。
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=task-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-registry.js","sourceRoot":"","sources":["../../../src/a2a/server/task-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,MAAM,UAAU,SAAS;IACvB,OAAO,QAAQ,MAAM,EAAE,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,MAAM,EAAE,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,eAAqC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7F,CAAC;AAED,MAAM,OAAO,YAAY;IACN,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEpD,GAAG,CAAC,MAAc,EAAE,IAAa;QAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAA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