@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,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export interface InitOptions {
|
|
17
|
+
dir: string;
|
|
18
|
+
shoppingCliSrc?: string;
|
|
19
|
+
/** Demo/test mode: deterministic fake models, no model API key needed. */
|
|
20
|
+
fake?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface InitResult {
|
|
23
|
+
dir: string;
|
|
24
|
+
config_path: string;
|
|
25
|
+
instance_id: string;
|
|
26
|
+
base_url: string;
|
|
27
|
+
mode: "managed-local";
|
|
28
|
+
fake: boolean;
|
|
29
|
+
created: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function runInit(options: InitOptions): Promise<InitResult>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* `kiwi init` — create a self-contained managed-local instance.
|
|
18
|
+
*
|
|
19
|
+
* Creates exactly these known files/directories and nothing else:
|
|
20
|
+
* kiwi.stack.json (0600) stack config (no secrets)
|
|
21
|
+
* profiles/merchant.yaml merchant agent profile (env-var names only)
|
|
22
|
+
* profiles/buyer.yaml buyer agent profile (env-var names only)
|
|
23
|
+
* data/ gateway database location (created on demand)
|
|
24
|
+
* logs/ per-process logs
|
|
25
|
+
* run/ (0700) private manifest/exit-state dir
|
|
26
|
+
*
|
|
27
|
+
* Fail closed: an instance that already contains Kiwi state (config file or
|
|
28
|
+
* run dir) is rejected, and every file is created with O_EXCL so user files
|
|
29
|
+
* are never overwritten.
|
|
30
|
+
*/
|
|
31
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
32
|
+
import path from "node:path";
|
|
33
|
+
import { assertSafeInstanceDir, detectShoppingCliSrc, instancePaths, newInstanceId, pickFreePort, STACK_VERSION, StackConfigError, } from "./stack-config.js";
|
|
34
|
+
import { packageRoot } from "../contracts/schemas.js";
|
|
35
|
+
import { PROTOCOL_VERSION } from "../negotiation/types.js";
|
|
36
|
+
/** Write a file only if it does not exist; never overwrite user files. */
|
|
37
|
+
function writeExclusive(file, content, mode) {
|
|
38
|
+
try {
|
|
39
|
+
writeFileSync(file, content, { encoding: "utf-8", flag: "wx", mode });
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err.code === "EEXIST") {
|
|
43
|
+
throw new StackConfigError(`refusing to overwrite existing file: ${file}`);
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function merchantProfile(baseUrl, fake) {
|
|
49
|
+
const model = fake
|
|
50
|
+
? " provider: fake\n model: fake-merchant-model\n"
|
|
51
|
+
: " provider: openai\n model: gpt-4o-mini\n api_key_env: MODEL_API_KEY\n";
|
|
52
|
+
return `# Merchant agent profile — generated by kiwi init. Secrets stay in env vars.
|
|
53
|
+
runtime_version: 0.5.0
|
|
54
|
+
protocol_version: ${PROTOCOL_VERSION}
|
|
55
|
+
agent_id: merchant-agent:merchant-001
|
|
56
|
+
role: merchant
|
|
57
|
+
owner_id: merchant-001
|
|
58
|
+
commerce:
|
|
59
|
+
base_url: ${baseUrl}
|
|
60
|
+
token_env: SHOPPING_AGENT_TOKEN
|
|
61
|
+
backend: local_marketplace
|
|
62
|
+
model:
|
|
63
|
+
${model}runtime:
|
|
64
|
+
mode: foreground
|
|
65
|
+
poll_interval_seconds: 5
|
|
66
|
+
turn_timeout_seconds: 90
|
|
67
|
+
max_model_steps: 4
|
|
68
|
+
max_retries: 2
|
|
69
|
+
merchant_policy:
|
|
70
|
+
min_unit_price_private: 80.00
|
|
71
|
+
max_auto_discount_percent: 10
|
|
72
|
+
inventory_source: marketplace
|
|
73
|
+
quote_ttl_seconds: 300
|
|
74
|
+
auto_negotiate: true
|
|
75
|
+
human_review_on:
|
|
76
|
+
- below_floor
|
|
77
|
+
- exceptional_warranty
|
|
78
|
+
- suspicious_content
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
function buyerProfile(baseUrl, fake) {
|
|
82
|
+
const model = fake
|
|
83
|
+
? " provider: fake\n model: fake-buyer-model\n"
|
|
84
|
+
: " provider: openai\n model: gpt-4o-mini\n api_key_env: MODEL_API_KEY\n";
|
|
85
|
+
return `# Buyer agent profile — generated by kiwi init. Secrets stay in env vars.
|
|
86
|
+
runtime_version: 0.5.0
|
|
87
|
+
protocol_version: ${PROTOCOL_VERSION}
|
|
88
|
+
agent_id: buyer-agent:buyer-001
|
|
89
|
+
role: buyer
|
|
90
|
+
owner_id: buyer-001
|
|
91
|
+
commerce:
|
|
92
|
+
base_url: ${baseUrl}
|
|
93
|
+
token_env: SHOPPING_BUYER_TOKEN
|
|
94
|
+
backend: local_marketplace
|
|
95
|
+
model:
|
|
96
|
+
${model}runtime:
|
|
97
|
+
mode: foreground
|
|
98
|
+
poll_interval_seconds: 5
|
|
99
|
+
turn_timeout_seconds: 90
|
|
100
|
+
max_model_steps: 4
|
|
101
|
+
max_retries: 2
|
|
102
|
+
buyer_policy:
|
|
103
|
+
target_skus:
|
|
104
|
+
- sku-001
|
|
105
|
+
quantity: 2
|
|
106
|
+
max_total_price_private: 200.00
|
|
107
|
+
acceptable_eta_latest: "2099-12-31T23:59:59+08:00"
|
|
108
|
+
required_after_sales_terms:
|
|
109
|
+
- policy:return-7d
|
|
110
|
+
auto_negotiate: true
|
|
111
|
+
human_review_on:
|
|
112
|
+
- budget_exceeded
|
|
113
|
+
- ambiguous_after_sales
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
export async function runInit(options) {
|
|
117
|
+
const dir = assertSafeInstanceDir(options.dir);
|
|
118
|
+
const paths = instancePaths(dir);
|
|
119
|
+
// Fail closed: any existing Kiwi state means this is (or was) an instance.
|
|
120
|
+
if (existsSync(paths.config) || existsSync(paths.run)) {
|
|
121
|
+
throw new StackConfigError(`${dir} already contains Kiwi state (${path.basename(paths.config)} or run/); refusing to re-init`);
|
|
122
|
+
}
|
|
123
|
+
const fake = options.fake === true;
|
|
124
|
+
// Resolve the shopping-cli source for the managed gateway BEFORE creating
|
|
125
|
+
// anything.
|
|
126
|
+
const src = options.shoppingCliSrc !== undefined
|
|
127
|
+
? path.resolve(options.shoppingCliSrc)
|
|
128
|
+
: detectShoppingCliSrc(packageRoot());
|
|
129
|
+
if (src === undefined || !existsSync(path.join(src, "shopping_cli"))) {
|
|
130
|
+
throw new StackConfigError("shopping-cli source not found: pass --shopping-cli-src <path> (expected a repo containing shopping_cli/)");
|
|
131
|
+
}
|
|
132
|
+
const venvPython = path.join(src, ".venv", "bin", "python");
|
|
133
|
+
const useVenv = existsSync(venvPython);
|
|
134
|
+
const port = await pickFreePort();
|
|
135
|
+
const baseUrl = `http://127.0.0.1:${port}`;
|
|
136
|
+
const instanceId = newInstanceId();
|
|
137
|
+
const createdAt = new Date().toISOString();
|
|
138
|
+
const dbPath = path.join(paths.data, "shopping.sqlite");
|
|
139
|
+
const config = {
|
|
140
|
+
stack_version: STACK_VERSION,
|
|
141
|
+
instance_id: instanceId,
|
|
142
|
+
mode: "managed-local",
|
|
143
|
+
created_at: createdAt,
|
|
144
|
+
gateway: {
|
|
145
|
+
base_url: baseUrl,
|
|
146
|
+
command: [
|
|
147
|
+
useVenv ? venvPython : "python3",
|
|
148
|
+
"-m",
|
|
149
|
+
"shopping_cli.api.server",
|
|
150
|
+
"--db",
|
|
151
|
+
dbPath,
|
|
152
|
+
"--host",
|
|
153
|
+
"127.0.0.1",
|
|
154
|
+
"--port",
|
|
155
|
+
String(port),
|
|
156
|
+
],
|
|
157
|
+
env: useVenv ? {} : { PYTHONPATH: src },
|
|
158
|
+
},
|
|
159
|
+
agents: {
|
|
160
|
+
merchant: { enabled: true, profile: "profiles/merchant.yaml" },
|
|
161
|
+
buyer: { enabled: true, profile: "profiles/buyer.yaml" },
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
const files = [
|
|
165
|
+
[paths.config, `${JSON.stringify(config, null, 2)}\n`],
|
|
166
|
+
[path.join(paths.profiles, "merchant.yaml"), merchantProfile(baseUrl, fake)],
|
|
167
|
+
[path.join(paths.profiles, "buyer.yaml"), buyerProfile(baseUrl, fake)],
|
|
168
|
+
];
|
|
169
|
+
const dirs = [paths.profiles, paths.data, paths.logs, paths.run];
|
|
170
|
+
// Preflight EVERY known target before creating anything: no partial Kiwi
|
|
171
|
+
// state may be left behind when a user file is in the way.
|
|
172
|
+
for (const [file] of files) {
|
|
173
|
+
if (existsSync(file)) {
|
|
174
|
+
throw new StackConfigError(`refusing to overwrite existing file: ${file}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Transactional create: on any failure remove only what THIS invocation
|
|
178
|
+
// created (files it wrote; directories it made and only while empty).
|
|
179
|
+
const createdFiles = [];
|
|
180
|
+
const createdDirs = [];
|
|
181
|
+
try {
|
|
182
|
+
for (const d of dirs) {
|
|
183
|
+
if (!existsSync(d)) {
|
|
184
|
+
createdDirs.push(d);
|
|
185
|
+
}
|
|
186
|
+
// run/ holds manifests (pids, tokens-in-path); data/ holds the
|
|
187
|
+
// shopping SQLite database — both stay owner-only. profiles/ and
|
|
188
|
+
// logs/ carry 0600 files, so the dirs stay conventionally listable.
|
|
189
|
+
mkdirSync(d, { recursive: true, mode: d === paths.run || d === paths.data ? 0o700 : 0o755 });
|
|
190
|
+
}
|
|
191
|
+
for (const [file, content] of files) {
|
|
192
|
+
writeExclusive(file, content, 0o600);
|
|
193
|
+
createdFiles.push(file);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
for (const file of createdFiles.reverse()) {
|
|
198
|
+
rmSync(file, { force: true });
|
|
199
|
+
}
|
|
200
|
+
for (const d of createdDirs.reverse()) {
|
|
201
|
+
// rmdir (non-recursive) only succeeds on empty dirs we just made;
|
|
202
|
+
// anything containing user content is left untouched.
|
|
203
|
+
try {
|
|
204
|
+
rmSync(d, { recursive: false });
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
// not empty or already gone: leave it
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
throw err;
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
dir,
|
|
214
|
+
config_path: paths.config,
|
|
215
|
+
instance_id: instanceId,
|
|
216
|
+
base_url: baseUrl,
|
|
217
|
+
mode: "managed-local",
|
|
218
|
+
fake,
|
|
219
|
+
created: createdFiles,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/supervisor/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAmB3D,0EAA0E;AAC1E,SAAS,cAAc,CAAC,IAAY,EAAE,OAAe,EAAE,IAAY;IACjE,IAAI,CAAC;QACH,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAAyB,CAAC,IAAI,KA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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 ManagedRole } from "./stack-config.js";
|
|
17
|
+
export declare const DEFAULT_LOG_LINES = 100;
|
|
18
|
+
export declare const MAX_LOG_LINES = 10000;
|
|
19
|
+
/** Parse and bound the --lines option. Throws on anything invalid. */
|
|
20
|
+
export declare function parseLogLines(value: string | undefined): number;
|
|
21
|
+
/** Redact secret-looking tokens and private-policy numeric values in a line. */
|
|
22
|
+
export declare function redactLine(line: string): string;
|
|
23
|
+
export interface LogsResult {
|
|
24
|
+
instance_id: string;
|
|
25
|
+
lines: string[];
|
|
26
|
+
missing: ManagedRole[];
|
|
27
|
+
}
|
|
28
|
+
export declare function runLogs(dir: string, maxLines: number): LogsResult;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 harrylabsj
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* `kiwi logs` — bounded, redacted tail of manifest-owned log files.
|
|
18
|
+
*
|
|
19
|
+
* Only log files referenced by this instance's manifests are read, and only
|
|
20
|
+
* after path containment is proven (they must live inside the instance
|
|
21
|
+
* logs/ dir). Every line is labeled with its process role. Redaction
|
|
22
|
+
* removes bearer/token/API-key-like secrets and private-policy numeric
|
|
23
|
+
* lines; env values and private thresholds are never printed.
|
|
24
|
+
*/
|
|
25
|
+
import { readFileSync } from "node:fs";
|
|
26
|
+
import path from "node:path";
|
|
27
|
+
import { manifestPathFor, readManifest } from "./manifest.js";
|
|
28
|
+
import { loadInstance } from "./manage.js";
|
|
29
|
+
import { ProfileError } from "../config/profile.js";
|
|
30
|
+
import { MANAGED_ROLES } from "./stack-config.js";
|
|
31
|
+
export const DEFAULT_LOG_LINES = 100;
|
|
32
|
+
export const MAX_LOG_LINES = 10_000;
|
|
33
|
+
/** Parse and bound the --lines option. Throws on anything invalid. */
|
|
34
|
+
export function parseLogLines(value) {
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
return DEFAULT_LOG_LINES;
|
|
37
|
+
if (!/^\d+$/.test(value)) {
|
|
38
|
+
throw new ProfileError(`--lines must be a positive integer (got "${value}")`);
|
|
39
|
+
}
|
|
40
|
+
const n = Number(value);
|
|
41
|
+
if (n < 1 || n > MAX_LOG_LINES) {
|
|
42
|
+
throw new ProfileError(`--lines must be between 1 and ${MAX_LOG_LINES} (got ${n})`);
|
|
43
|
+
}
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
46
|
+
const SECRET_PATTERNS = [
|
|
47
|
+
// key=value-shaped secrets first, case-insensitive and `]`-tolerant (for
|
|
48
|
+
// `env[VAR]=value` lines): this must run before the bare-token patterns so
|
|
49
|
+
// they cannot consume the variable name and leave the value exposed.
|
|
50
|
+
[/([A-Za-z0-9_[\].-]*(?:token|api[-_]?key|secret|password)[\]]?\s*[:=]\s*)\S+/gi, "$1[REDACTED]"],
|
|
51
|
+
[/Bearer\s+\S+/gi, "Bearer [REDACTED]"],
|
|
52
|
+
[/shopping_(merchant|buyer|agent|admin)_[A-Za-z0-9_-]+/gi, "shopping_$1_[REDACTED]"],
|
|
53
|
+
[/sk-[A-Za-z0-9_-]{6,}/g, "[REDACTED]"],
|
|
54
|
+
];
|
|
55
|
+
const PRIVATE_NUMERIC_LINE = /(min_unit_price_private|max_total_price_private|最低可成交价|底价|最高预算|内部预算)/;
|
|
56
|
+
/** Redact secret-looking tokens and private-policy numeric values in a line. */
|
|
57
|
+
export function redactLine(line) {
|
|
58
|
+
let out = line;
|
|
59
|
+
for (const [pattern, replacement] of SECRET_PATTERNS) {
|
|
60
|
+
out = out.replace(pattern, replacement);
|
|
61
|
+
}
|
|
62
|
+
if (PRIVATE_NUMERIC_LINE.test(out)) {
|
|
63
|
+
out = out.replace(/\d+(?:\.\d+)?/g, "[REDACTED]");
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
export function runLogs(dir, maxLines) {
|
|
68
|
+
const ctx = loadInstance(dir);
|
|
69
|
+
const logsRoot = path.resolve(ctx.paths.logs);
|
|
70
|
+
const collected = [];
|
|
71
|
+
const missing = [];
|
|
72
|
+
for (const role of MANAGED_ROLES) {
|
|
73
|
+
const manifest = readManifest(manifestPathFor(ctx.paths.run, role));
|
|
74
|
+
const logPath = manifest?.log_path ?? path.join(ctx.paths.logs, `${role}.log`);
|
|
75
|
+
// Path containment: only files inside this instance's logs/ dir.
|
|
76
|
+
const resolved = path.resolve(logPath);
|
|
77
|
+
if (resolved !== path.join(logsRoot, `${role}.log`)) {
|
|
78
|
+
missing.push(role);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
let content;
|
|
82
|
+
try {
|
|
83
|
+
content = readFileSync(resolved, "utf-8");
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
missing.push(role);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
for (const line of content.split("\n")) {
|
|
90
|
+
if (line.length > 0)
|
|
91
|
+
collected.push({ role, line });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const tail = collected.slice(-maxLines);
|
|
95
|
+
return {
|
|
96
|
+
instance_id: ctx.config.instance_id,
|
|
97
|
+
lines: tail.map(({ role, line }) => `[${role}] ${redactLine(line)}`),
|
|
98
|
+
missing,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/supervisor/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAEpE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,iBAAiB,CAAC;IAClD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,YAAY,CAAC,4CAA4C,KAAK,IAAI,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,aAAa,EAAE,CAAC;QAC/B,MAAM,IAAI,YAAY,CAAC,iCAAi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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 ExitRecord, type ProcessManifest } from "./manifest.js";
|
|
17
|
+
import { instancePaths, type ManagedRole, type StackConfig } from "./stack-config.js";
|
|
18
|
+
export declare class SupervisorError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
export interface InstanceContext {
|
|
22
|
+
paths: ReturnType<typeof instancePaths>;
|
|
23
|
+
config: StackConfig;
|
|
24
|
+
}
|
|
25
|
+
export declare function loadInstance(dir: string): InstanceContext;
|
|
26
|
+
/** Spawn one managed process through the child-runner and write its manifest. */
|
|
27
|
+
export declare function spawnManaged(ctx: InstanceContext, role: ManagedRole, command: string[], env: Record<string, string>): Promise<ProcessManifest>;
|
|
28
|
+
export interface RoleState {
|
|
29
|
+
role: ManagedRole;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
verified: boolean;
|
|
32
|
+
running: boolean;
|
|
33
|
+
exited?: ExitRecord | undefined;
|
|
34
|
+
detail: string;
|
|
35
|
+
}
|
|
36
|
+
export interface UpResult {
|
|
37
|
+
instance_id: string;
|
|
38
|
+
started: ManagedRole[];
|
|
39
|
+
already_running: ManagedRole[];
|
|
40
|
+
disabled: ManagedRole[];
|
|
41
|
+
base_url: string;
|
|
42
|
+
}
|
|
43
|
+
export interface UpOptions {
|
|
44
|
+
/** Test hooks: shorten bounded waits. */
|
|
45
|
+
healthTimeoutMs?: number;
|
|
46
|
+
agentGraceMs?: number;
|
|
47
|
+
}
|
|
48
|
+
export declare function runUp(dir: string, options?: UpOptions): Promise<UpResult>;
|
|
49
|
+
export type StopOutcome = "stopped" | "killed" | "not_running" | "unverified";
|
|
50
|
+
/** Stop one manifest-owned process after verification. Never touches anything unverifiable. */
|
|
51
|
+
export declare function stopVerified(ctx: InstanceContext, manifest: ProcessManifest): Promise<StopOutcome>;
|
|
52
|
+
export interface DownResult {
|
|
53
|
+
instance_id: string;
|
|
54
|
+
results: {
|
|
55
|
+
role: ManagedRole;
|
|
56
|
+
outcome: StopOutcome | "not_started";
|
|
57
|
+
detail: string;
|
|
58
|
+
}[];
|
|
59
|
+
}
|
|
60
|
+
export declare function runDown(dir: string): Promise<DownResult>;
|
|
61
|
+
export interface StatusResult {
|
|
62
|
+
ok: boolean;
|
|
63
|
+
instance_id: string;
|
|
64
|
+
mode: StackConfig["mode"];
|
|
65
|
+
base_url: string;
|
|
66
|
+
gateway_health: {
|
|
67
|
+
ok: boolean;
|
|
68
|
+
version?: string;
|
|
69
|
+
} | undefined;
|
|
70
|
+
processes: RoleState[];
|
|
71
|
+
}
|
|
72
|
+
export declare function runStatus(dir: string): Promise<StatusResult>;
|