stitchkit 0.92.0 → 0.94.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/CHANGELOG.md +191 -0
- package/README.md +5 -2
- package/dist/agent-runtime/children-control.d.ts +6 -0
- package/dist/agent-runtime/children-control.d.ts.map +1 -0
- package/dist/agent-runtime/children-spawn.d.ts +6 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -0
- package/dist/agent-runtime/children-state.d.ts +46 -0
- package/dist/agent-runtime/children-state.d.ts.map +1 -0
- package/dist/agent-runtime/children-usage.d.ts +8 -0
- package/dist/agent-runtime/children-usage.d.ts.map +1 -0
- package/dist/agent-runtime/children.d.ts +11 -14
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/events.d.ts +1 -1
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +1 -1
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +1 -1
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/{agent-runtime-openrouter.d.ts → agent-runtime/openrouter.d.ts} +3 -3
- package/dist/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +1 -1
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +17 -0
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +133 -0
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution.d.ts +17 -33
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +18 -0
- package/dist/agent-runtime/run-failure.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
- package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +11 -0
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-control.d.ts +9 -0
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-state.d.ts +36 -0
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-submit.d.ts +5 -0
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +9 -4
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/{agent-runtime-sqlite-bun.d.ts → agent-runtime/sqlite-bun.d.ts} +5 -4
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-events.d.ts +5 -0
- package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-history.d.ts +7 -0
- package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
- package/dist/{agent-runtime-sqlite-node.d.ts → agent-runtime/sqlite-node.d.ts} +5 -4
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
- package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
- package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite.d.ts +10 -6
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts +16 -0
- package/dist/agent-runtime/store-archive.d.ts.map +1 -0
- package/dist/{testing/agent-store-conformance.d.ts → agent-runtime/store-conformance.d.ts} +2 -2
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
- package/dist/agent-runtime/store-create.d.ts +11 -0
- package/dist/agent-runtime/store-create.d.ts.map +1 -0
- package/dist/agent-runtime/{store-driver.d.ts → store-driver-contract.d.ts} +7 -7
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
- package/dist/agent-runtime/store-events.d.ts +7 -89
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +4 -0
- package/dist/agent-runtime/store-memory.d.ts.map +1 -0
- package/dist/agent-runtime/store-mutate.d.ts +13 -0
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
- package/dist/agent-runtime/store-purge.d.ts +1 -1
- package/dist/agent-runtime/store-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-reads.d.ts +29 -0
- package/dist/agent-runtime/store-reads.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
- package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
- package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-reducer.d.ts +24 -0
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
- package/dist/agent-runtime/store-snapshot.d.ts +19 -0
- package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +1 -1
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/application/admission.d.ts +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/events.d.ts +1 -1
- package/dist/application/events.d.ts.map +1 -1
- package/dist/{server → application}/file-state-store.d.ts +1 -1
- package/dist/application/file-state-store.d.ts.map +1 -0
- package/dist/application/health.d.ts +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts +8 -0
- package/dist/application/kernel-admission.d.ts.map +1 -0
- package/dist/application/kernel-contract.d.ts +142 -0
- package/dist/application/kernel-contract.d.ts.map +1 -0
- package/dist/application/kernel-resource-context.d.ts +24 -0
- package/dist/application/kernel-resource-context.d.ts.map +1 -0
- package/dist/application/kernel-restart.d.ts +5 -0
- package/dist/application/kernel-restart.d.ts.map +1 -0
- package/dist/application/kernel-rollback.d.ts +4 -0
- package/dist/application/kernel-rollback.d.ts.map +1 -0
- package/dist/application/kernel-shutdown.d.ts +6 -0
- package/dist/application/kernel-shutdown.d.ts.map +1 -0
- package/dist/application/kernel-start.d.ts +20 -0
- package/dist/application/kernel-start.d.ts.map +1 -0
- package/dist/application/kernel-state.d.ts +116 -0
- package/dist/application/kernel-state.d.ts.map +1 -0
- package/dist/application/kernel.d.ts +9 -140
- package/dist/application/kernel.d.ts.map +1 -1
- package/dist/application/latest-sink.d.ts +1 -1
- package/dist/application/latest-sink.d.ts.map +1 -1
- package/dist/application/opentelemetry.d.ts +1 -1
- package/dist/application/opentelemetry.d.ts.map +1 -1
- package/dist/application/watch-hub.d.ts +2 -2
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-multipart.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/client.d.ts +1 -1
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts +1 -1
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/browser/http.d.ts +1 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/resumable.d.ts +1 -28
- package/dist/browser/resumable.d.ts.map +1 -1
- package/dist/browser/retained.d.ts.map +1 -0
- package/dist/browser/socket-io.d.ts +23 -1
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +14 -2
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/contract/define.d.ts +72 -65
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/{internal/errors.d.ts → contract/normalize.d.ts} +3 -39
- package/dist/contract/normalize.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +135 -0
- package/dist/contract/tool-view.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-contract.d.ts → durability/contract.d.ts} +2 -2
- package/dist/durability/contract.d.ts.map +1 -0
- package/dist/{agent-runtime/durability.d.ts → durability/engine.d.ts} +4 -4
- package/dist/durability/engine.d.ts.map +1 -0
- package/dist/durability/events.d.ts +101 -0
- package/dist/durability/events.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-json.d.ts → durability/json.d.ts} +1 -1
- package/dist/durability/json.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-ledger.d.ts → durability/ledger.d.ts} +2 -2
- package/dist/durability/ledger.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-scheduler.d.ts → durability/scheduler.d.ts} +2 -2
- package/dist/durability/scheduler.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
- package/dist/{agent-runtime-browser.js → entrypoints/agent-runtime/browser.js} +3 -3
- package/dist/{agent-runtime-coding-tools.d.ts → entrypoints/agent-runtime/coding-tools.d.ts} +2 -2
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
- package/dist/{agent-runtime-harness.d.ts → entrypoints/agent-runtime/harness.d.ts} +2 -2
- package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
- package/dist/{agent-runtime-harness.js → entrypoints/agent-runtime/harness.js} +24 -25
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/{agent-runtime-openrouter.js → entrypoints/agent-runtime/openrouter.js} +3 -3
- package/dist/{agent-runtime-sandbox.d.ts → entrypoints/agent-runtime/sandbox.d.ts} +5 -5
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
- package/dist/{agent-runtime-sandbox.js → entrypoints/agent-runtime/sandbox.js} +11 -12
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
- package/dist/{agent-runtime-sqlite-bun.js → entrypoints/agent-runtime/sqlite/bun.js} +8 -6
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
- package/dist/{agent-runtime-sqlite-node.js → entrypoints/agent-runtime/sqlite/node.js} +8 -6
- package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/testing.js +1084 -0
- package/dist/{agent-runtime.d.ts → entrypoints/agent-runtime.d.ts} +41 -37
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
- package/dist/{agent-runtime.js → entrypoints/agent-runtime.js} +408 -366
- package/dist/{application-diagnostic-journal.d.ts → entrypoints/application/diagnostic-journal.d.ts} +2 -2
- package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
- package/dist/{application-diagnostic-journal.js → entrypoints/application/diagnostic-journal.js} +3 -3
- package/dist/{application-grammy.d.ts → entrypoints/application/grammy.d.ts} +2 -2
- package/dist/entrypoints/application/grammy.d.ts.map +1 -0
- package/dist/{application-grammy.js → entrypoints/application/grammy.js} +2 -2
- package/dist/{application-opentelemetry.d.ts → entrypoints/application/opentelemetry.d.ts} +2 -2
- package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
- package/dist/{application-opentelemetry.js → entrypoints/application/opentelemetry.js} +4 -4
- package/dist/{application-schemas.d.ts → entrypoints/application/schemas.d.ts} +2 -2
- package/dist/entrypoints/application/schemas.d.ts.map +1 -0
- package/dist/{application-schemas.js → entrypoints/application/schemas.js} +2 -2
- package/dist/{application.d.ts → entrypoints/application.d.ts} +22 -21
- package/dist/entrypoints/application.d.ts.map +1 -0
- package/dist/{application.js → entrypoints/application.js} +24 -22
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
- package/dist/{upgrade-cli.js → entrypoints/bin/upgrade-cli.js} +3 -3
- package/dist/{cli.d.ts → entrypoints/cli.d.ts} +15 -15
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/{cli.js → entrypoints/cli.js} +37 -32
- package/dist/entrypoints/contract.d.ts +9 -0
- package/dist/entrypoints/contract.d.ts.map +1 -0
- package/dist/{contract/index.js → entrypoints/contract.js} +14 -6
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -0
- package/dist/{declaration.js → entrypoints/declaration.js} +1 -1
- package/dist/{files.d.ts → entrypoints/files.d.ts} +2 -2
- package/dist/entrypoints/files.d.ts.map +1 -0
- package/dist/{files.js → entrypoints/files.js} +3 -3
- package/dist/{geo.d.ts → entrypoints/geo.d.ts} +1 -1
- package/dist/entrypoints/geo.d.ts.map +1 -0
- package/dist/{geo.js → entrypoints/geo.js} +4 -4
- package/dist/entrypoints/google.d.ts +2 -0
- package/dist/entrypoints/google.d.ts.map +1 -0
- package/dist/{google.js → entrypoints/google.js} +1 -1
- package/dist/{index.d.ts → entrypoints/index.d.ts} +14 -13
- package/dist/entrypoints/index.d.ts.map +1 -0
- package/dist/{index.js → entrypoints/index.js} +99 -33
- package/dist/{live.d.ts → entrypoints/live.d.ts} +4 -4
- package/dist/entrypoints/live.d.ts.map +1 -0
- package/dist/{live.js → entrypoints/live.js} +6 -4
- package/dist/{node.d.ts → entrypoints/node.d.ts} +11 -11
- package/dist/entrypoints/node.d.ts.map +1 -0
- package/dist/{node.js → entrypoints/node.js} +20 -16
- package/dist/entrypoints/oauth.d.ts +2 -0
- package/dist/entrypoints/oauth.d.ts.map +1 -0
- package/dist/{oauth.js → entrypoints/oauth.js} +3 -3
- package/dist/{observability/index.d.ts → entrypoints/observability.d.ts} +11 -11
- package/dist/entrypoints/observability.d.ts.map +1 -0
- package/dist/{observability/index.js → entrypoints/observability.js} +9 -11
- package/dist/entrypoints/primitives.d.ts +3 -0
- package/dist/entrypoints/primitives.d.ts.map +1 -0
- package/dist/{primitives.js → entrypoints/primitives.js} +1 -6
- package/dist/{react.d.ts → entrypoints/react.d.ts} +4 -4
- package/dist/entrypoints/react.d.ts.map +1 -0
- package/dist/{react.js → entrypoints/react.js} +3 -3
- package/dist/{release.d.ts → entrypoints/release.d.ts} +4 -4
- package/dist/entrypoints/release.d.ts.map +1 -0
- package/dist/{release.js → entrypoints/release.js} +1 -1
- package/dist/{remote.d.ts → entrypoints/remote.d.ts} +1 -1
- package/dist/entrypoints/remote.d.ts.map +1 -0
- package/dist/entrypoints/remote.js +66 -0
- package/dist/{server/index.d.ts → entrypoints/server.d.ts} +35 -34
- package/dist/entrypoints/server.d.ts.map +1 -0
- package/dist/{server/index.js → entrypoints/server.js} +294 -244
- package/dist/{telegram.d.ts → entrypoints/telegram.d.ts} +2 -2
- package/dist/entrypoints/telegram.d.ts.map +1 -0
- package/dist/{telegram.js → entrypoints/telegram.js} +1 -1
- package/dist/entrypoints/testing.d.ts +9 -0
- package/dist/entrypoints/testing.d.ts.map +1 -0
- package/dist/{testing.js → entrypoints/testing.js} +107 -926
- package/dist/{tools/connections/index.d.ts → entrypoints/tools/connections.d.ts} +6 -7
- package/dist/entrypoints/tools/connections.d.ts.map +1 -0
- package/dist/{tools/connections/index.js → entrypoints/tools/connections.js} +7 -4
- package/dist/{tools-contract.d.ts → entrypoints/tools/contract.d.ts} +5 -5
- package/dist/entrypoints/tools/contract.d.ts.map +1 -0
- package/dist/{tools-contract.js → entrypoints/tools/contract.js} +4 -4
- package/dist/{tool-invoker.d.ts → entrypoints/tools/invoker.d.ts} +2 -2
- package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
- package/dist/entrypoints/tools/invoker.js +20 -0
- package/dist/entrypoints/tools.d.ts +51 -0
- package/dist/entrypoints/tools.d.ts.map +1 -0
- package/dist/{tools.js → entrypoints/tools.js} +1787 -1751
- package/dist/{tracking-server.d.ts → entrypoints/tracking/server.d.ts} +8 -8
- package/dist/entrypoints/tracking/server.d.ts.map +1 -0
- package/dist/{tracking.d.ts → entrypoints/tracking.d.ts} +15 -15
- package/dist/entrypoints/tracking.d.ts.map +1 -0
- package/dist/{tracking.js → entrypoints/tracking.js} +5 -8
- package/dist/google/google.d.ts.map +1 -0
- package/dist/{index-a916km3r.js → index-0b1ess5e.js} +6 -13
- package/dist/{index-zwkgfq1s.js → index-1nd48tm9.js} +113 -118
- package/dist/{index-7zbps32p.js → index-1zbbzgfh.js} +2 -2
- package/dist/{index-mzvgxp0n.js → index-2cr1cqhn.js} +16 -4
- package/dist/{index-f9mb610r.js → index-35mh5bhj.js} +2 -2
- package/dist/index-48ffdxgk.js +6 -0
- package/dist/index-58k4fp34.js +1023 -0
- package/dist/{index-p13mwz16.js → index-83bdg97s.js} +1 -1
- package/dist/index-97ac4gph.js +3618 -0
- package/dist/{index-kw9t5ayn.js → index-cq4qfycf.js} +5 -5
- package/dist/{index-7gnkny4z.js → index-d9pk3td4.js} +1 -1
- package/dist/{index-e42wzzz5.js → index-dcpdvjsc.js} +7 -7
- package/dist/{index-h9etkkyk.js → index-dydjcp8z.js} +102 -25
- package/dist/{index-sr93cwf9.js → index-e2z3ahw9.js} +2 -2
- package/dist/{index-yewwh1w4.js → index-e87kakm4.js} +96 -11
- package/dist/{index-cby4ar3v.js → index-eqqvgdb3.js} +1 -1
- package/dist/index-fdp6hdxn.js +942 -0
- package/dist/{index-0a349c33.js → index-gyr48nzg.js} +125 -198
- package/dist/{index-wnfk50r0.js → index-h6eeys1v.js} +1 -1
- package/dist/{index-77fekveh.js → index-hffjpmq9.js} +1 -15
- package/dist/{index-yn8remb1.js → index-j05z5gn4.js} +50 -14
- package/dist/index-k5hsfc3j.js +31 -0
- package/dist/{index-fq77yfzc.js → index-kj2wbeta.js} +1 -1
- package/dist/index-kvj7f4hq.js +39 -0
- package/dist/{index-4fpa9dy2.js → index-m9zn6cpq.js} +2 -2
- package/dist/{index-2na0qrfn.js → index-mdzh02yc.js} +7 -7
- package/dist/{index-ywd0y6m1.js → index-mkm15s49.js} +1 -1
- package/dist/index-mp5sn43f.js +1084 -0
- package/dist/{index-7n145nbe.js → index-n6hxg8as.js} +530 -387
- package/dist/index-ngfhvfpd.js +30 -0
- package/dist/{index-e0znv5gn.js → index-p5r7qpdd.js} +2 -93
- package/dist/{index-n0f51dfn.js → index-p81267c2.js} +608 -549
- package/dist/{index-wc4x00bn.js → index-qwhynv6x.js} +1 -1
- package/dist/index-r7nmqpsg.js +154 -0
- package/dist/{index-bx75zwt7.js → index-rewkc2hj.js} +5 -4
- package/dist/{index-9f8ztey6.js → index-sees8yf8.js} +2 -2
- package/dist/{index-vjpvjqpn.js → index-v38qyerb.js} +16 -2
- package/dist/{index-2c2bjw3s.js → index-vcvkq30w.js} +3 -3
- package/dist/index-wqgjfstn.js +18 -0
- package/dist/{index-f477k430.js → index-x4799c19.js} +1 -1
- package/dist/{index-cxqhvq21.js → index-xnj9bgxe.js} +142 -129
- package/dist/index-xsqjkha9.js +281 -0
- package/dist/{index-6kyksz9y.js → index-yw4fzmdz.js} +1 -1
- package/dist/{index-3xwxfj4z.js → index-zeemqhqx.js} +1 -1
- package/dist/{index-tmwcrptx.js → index-zfrhfn82.js} +1 -1
- package/dist/index-znfs20ss.js +98 -0
- package/dist/internal/backoff.d.ts +29 -0
- package/dist/internal/backoff.d.ts.map +1 -0
- package/dist/internal/canonical-json.d.ts +21 -11
- package/dist/internal/canonical-json.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -0
- package/dist/internal/logger.d.ts.map +1 -0
- package/dist/internal/request.d.ts.map +1 -0
- package/dist/internal/secure-fetch.d.ts +12 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/internal/stable-digest.d.ts +0 -43
- package/dist/internal/stable-digest.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +0 -8
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/zod-issues.d.ts +38 -0
- package/dist/internal/zod-issues.d.ts.map +1 -0
- package/dist/{tools/json-schema-dialect.d.ts → json-schema/dialect.d.ts} +1 -1
- package/dist/json-schema/dialect.d.ts.map +1 -0
- package/dist/json-schema/json-schema.d.ts.map +1 -0
- package/dist/live/watch-delta.d.ts.map +1 -1
- package/dist/{oauth.d.ts → oauth/authorization-code.d.ts} +1 -1
- package/dist/oauth/authorization-code.d.ts.map +1 -0
- package/dist/observability/audit.d.ts +2 -2
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +1 -1
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/{internal/observability-sink.d.ts → observability/bounded-sink.d.ts} +2 -2
- package/dist/observability/bounded-sink.d.ts.map +1 -0
- package/dist/observability/context.d.ts +1 -1
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event.d.ts +1 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/work.d.ts +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/audit.d.ts +1 -1
- package/dist/primitives/audit.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +4 -2
- package/dist/primitives/export-operation.d.ts.map +1 -1
- package/dist/realtime/socket.d.ts +1 -1
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/context.d.ts +2 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts +15 -0
- package/dist/server/contract-method.d.ts.map +1 -0
- package/dist/server/contract-stream.d.ts +1 -1
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/create.d.ts +8 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts +10 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -0
- package/dist/server/endpoint-response.d.ts +18 -0
- package/dist/server/endpoint-response.d.ts.map +1 -0
- package/dist/server/error-dispatch.d.ts +17 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -2
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +44 -0
- package/dist/server/handler-state.d.ts.map +1 -0
- package/dist/server/implement.d.ts +1 -1
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -1
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +17 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/trust-fence.d.ts +1 -1
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/{tools/oauth-metadata.d.ts → server/oauth/metadata.d.ts} +2 -2
- package/dist/server/oauth/metadata.d.ts.map +1 -0
- package/dist/{tools/oauth-provider.d.ts → server/oauth/provider.d.ts} +2 -2
- package/dist/server/oauth/provider.d.ts.map +1 -0
- package/dist/server/realtime.d.ts +1 -1
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +16 -0
- package/dist/server/request-completion.d.ts.map +1 -0
- package/dist/server/response-metadata.d.ts +1 -1
- package/dist/server/response-metadata.d.ts.map +1 -1
- package/dist/server/route-table.d.ts +9 -0
- package/dist/server/route-table.d.ts.map +1 -0
- package/dist/server/stream.d.ts +0 -13
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/types.d.ts +7 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +31 -0
- package/dist/testing/handler-clients.d.ts.map +1 -0
- package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts +2 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +64 -5
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/{cli-args.d.ts → cli/args.d.ts} +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -0
- package/dist/tools/{cli-checkpoint.d.ts → cli/checkpoint.d.ts} +1 -1
- package/dist/tools/cli/checkpoint.d.ts.map +1 -0
- package/dist/tools/{cli-command.d.ts → cli/command.d.ts} +22 -4
- package/dist/tools/cli/command.d.ts.map +1 -0
- package/dist/tools/{cli.d.ts → cli/config.d.ts} +5 -12
- package/dist/tools/cli/config.d.ts.map +1 -0
- package/dist/tools/cli/create-cli.d.ts +36 -0
- package/dist/tools/cli/create-cli.d.ts.map +1 -0
- package/dist/tools/cli/download.d.ts +8 -0
- package/dist/tools/cli/download.d.ts.map +1 -0
- package/dist/tools/{cli-format.d.ts → cli/format.d.ts} +2 -2
- package/dist/tools/cli/format.d.ts.map +1 -0
- package/dist/tools/cli/help.d.ts +24 -0
- package/dist/tools/cli/help.d.ts.map +1 -0
- package/dist/tools/{cli-installer.d.ts → cli/installer.d.ts} +2 -2
- package/dist/tools/cli/installer.d.ts.map +1 -0
- package/dist/tools/{cli-invoke.d.ts → cli/invoke.d.ts} +35 -10
- package/dist/tools/cli/invoke.d.ts.map +1 -0
- package/dist/tools/cli/io.d.ts +10 -0
- package/dist/tools/cli/io.d.ts.map +1 -0
- package/dist/tools/cli/managed-surface.d.ts +30 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -0
- package/dist/tools/{cli-manifest.d.ts → cli/manifest.d.ts} +1 -1
- package/dist/tools/cli/manifest.d.ts.map +1 -0
- package/dist/tools/{cli-policy.d.ts → cli/policy.d.ts} +2 -2
- package/dist/tools/cli/policy.d.ts.map +1 -0
- package/dist/tools/cli/prepare.d.ts +14 -0
- package/dist/tools/cli/prepare.d.ts.map +1 -0
- package/dist/tools/{cli-profile.d.ts → cli/profile.d.ts} +2 -2
- package/dist/tools/cli/profile.d.ts.map +1 -0
- package/dist/tools/cli/run-managed.d.ts +5 -0
- package/dist/tools/cli/run-managed.d.ts.map +1 -0
- package/dist/tools/cli/run-native.d.ts +9 -0
- package/dist/tools/cli/run-native.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +40 -0
- package/dist/tools/cli/session.d.ts.map +1 -0
- package/dist/tools/{cli-signature.d.ts → cli/signature.d.ts} +2 -2
- package/dist/tools/cli/signature.d.ts.map +1 -0
- package/dist/tools/{cli-stream.d.ts → cli/stream.d.ts} +4 -4
- package/dist/tools/cli/stream.d.ts.map +1 -0
- package/dist/tools/{cli-update.d.ts → cli/update.d.ts} +3 -3
- package/dist/tools/cli/update.d.ts.map +1 -0
- package/dist/tools/{cli-view.d.ts → cli/view.d.ts} +2 -2
- package/dist/tools/cli/view.d.ts.map +1 -0
- package/dist/tools/{cli-wait.d.ts → cli/wait.d.ts} +2 -2
- package/dist/tools/cli/wait.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +3 -3
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/durability-context.d.ts +1 -1
- package/dist/tools/durability-context.d.ts.map +1 -1
- package/dist/tools/execute.d.ts +30 -3
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +8 -6
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/internal/tool-view.d.ts +41 -0
- package/dist/tools/internal/tool-view.d.ts.map +1 -0
- package/dist/tools/invoker.d.ts +11 -3
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +3 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -2
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/{mcp-app.d.ts → mcp/app.d.ts} +1 -1
- package/dist/tools/mcp/app.d.ts.map +1 -0
- package/dist/tools/{mcp-catalog.d.ts → mcp/catalog.d.ts} +2 -2
- package/dist/tools/mcp/catalog.d.ts.map +1 -0
- package/dist/tools/{mcp-handler.d.ts → mcp/handler.d.ts} +5 -5
- package/dist/tools/mcp/handler.d.ts.map +1 -0
- package/dist/tools/{mcp.d.ts → mcp/mount.d.ts} +9 -9
- package/dist/tools/mcp/mount.d.ts.map +1 -0
- package/dist/tools/{mcp-prepare.d.ts → mcp/prepare.d.ts} +9 -9
- package/dist/tools/mcp/prepare.d.ts.map +1 -0
- package/dist/tools/{mcp-progress.d.ts → mcp/progress.d.ts} +2 -2
- package/dist/tools/mcp/progress.d.ts.map +1 -0
- package/dist/tools/mcp/register.d.ts +35 -0
- package/dist/tools/mcp/register.d.ts.map +1 -0
- package/dist/tools/{mcp-round-policy.d.ts → mcp/round-policy.d.ts} +2 -2
- package/dist/tools/mcp/round-policy.d.ts.map +1 -0
- package/dist/tools/{mcp-round.d.ts → mcp/round.d.ts} +4 -4
- package/dist/tools/mcp/round.d.ts.map +1 -0
- package/dist/tools/mcp/runtime-tools.d.ts +24 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
- package/dist/tools/{mcp-stdio-signals.d.ts → mcp/stdio-signals.d.ts} +3 -3
- package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
- package/dist/tools/{mcp-stdio.d.ts → mcp/stdio.d.ts} +4 -4
- package/dist/tools/mcp/stdio.d.ts.map +1 -0
- package/dist/tools/{mcp-trace.d.ts → mcp/trace.d.ts} +1 -1
- package/dist/tools/mcp/trace.d.ts.map +1 -0
- package/dist/tools/mount.d.ts +12 -7
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +3 -3
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
- package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-binding.d.ts +28 -0
- package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
- package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-id.d.ts +23 -0
- package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +40 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts +68 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
- package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
- package/dist/tools/{define-wait-tool.d.ts → operations/define-wait-tool.d.ts} +2 -2
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
- package/dist/tools/operations/mount-wait.d.ts.map +1 -0
- package/dist/tools/operations/wait-core.d.ts.map +1 -0
- package/dist/tools/remote.d.ts +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +11 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -0
- package/dist/tools/schema/flatten-join.d.ts.map +1 -0
- package/dist/tools/schema/flatten.d.ts.map +1 -0
- package/dist/tools/schema/portable-formats.d.ts.map +1 -0
- package/dist/tools/{presentation.d.ts → schema/presentation.d.ts} +2 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -0
- package/dist/tools/schema/schema.d.ts.map +1 -0
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
- package/dist/tools/surface.d.ts +2 -3
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/{define-download-tool.d.ts → transfer/define-download-tool.d.ts} +4 -4
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
- package/dist/tools/{define-upload-tool.d.ts → transfer/define-upload-tool.d.ts} +3 -3
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
- package/dist/tools/{define-view-file-tool.d.ts → transfer/define-view-file-tool.d.ts} +2 -2
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
- package/dist/tools/{download-core.d.ts → transfer/download-core.d.ts} +2 -2
- package/dist/tools/transfer/download-core.d.ts.map +1 -0
- package/dist/tools/{managed-file-error.d.ts → transfer/managed-file-error.d.ts} +1 -1
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
- package/dist/tools/{mount-download.d.ts → transfer/mount-download.d.ts} +1 -1
- package/dist/tools/transfer/mount-download.d.ts.map +1 -0
- package/dist/tools/{mount-upload.d.ts → transfer/mount-upload.d.ts} +1 -1
- package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
- package/dist/tools/transfer/native-result.d.ts.map +1 -0
- package/dist/tools/{upload-core.d.ts → transfer/upload-core.d.ts} +1 -1
- package/dist/tools/transfer/upload-core.d.ts.map +1 -0
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
- package/dist/tools/{view-file.d.ts → transfer/view-file.d.ts} +1 -1
- package/dist/tools/transfer/view-file.d.ts.map +1 -0
- package/dist/tools/transports.d.ts +1 -1
- package/dist/tools/transports.d.ts.map +1 -1
- package/dist/tracking/contract.d.ts +1 -1
- package/dist/tracking/contract.d.ts.map +1 -1
- package/llms/agent-runtime-browser.txt +33 -0
- package/llms/agent-runtime-coding-tools.txt +58 -0
- package/llms/agent-runtime-harness.txt +45 -0
- package/llms/agent-runtime-openrouter.txt +22 -0
- package/llms/agent-runtime-sandbox.txt +159 -0
- package/llms/agent-runtime-sqlite-bun.txt +29 -0
- package/llms/agent-runtime-sqlite-node.txt +26 -0
- package/llms/agent-runtime-testing.txt +30 -0
- package/llms/agent-runtime.2.txt +550 -0
- package/llms/agent-runtime.3.txt +311 -0
- package/llms/agent-runtime.txt +893 -0
- package/llms/application-diagnostic-journal.txt +30 -0
- package/llms/application-grammy.txt +27 -0
- package/llms/application-opentelemetry.txt +27 -0
- package/llms/application-schemas.txt +42 -0
- package/llms/application.2.txt +223 -0
- package/llms/application.txt +1144 -0
- package/llms/cli.txt +977 -0
- package/llms/contract.txt +606 -0
- package/llms/declaration.txt +286 -0
- package/llms/files.txt +30 -0
- package/llms/geo.txt +114 -0
- package/llms/google.txt +27 -0
- package/llms/live.txt +471 -0
- package/llms/node.txt +43 -0
- package/llms/oauth.txt +136 -0
- package/llms/observability.txt +893 -0
- package/llms/primitives.txt +158 -0
- package/llms/react.txt +184 -0
- package/llms/release.txt +176 -0
- package/llms/remote.txt +25 -0
- package/llms/server.2.txt +361 -0
- package/llms/server.3.txt +1031 -0
- package/llms/server.4.txt +905 -0
- package/llms/server.5.txt +250 -0
- package/llms/server.txt +996 -0
- package/llms/stitchkit.2.txt +836 -0
- package/llms/stitchkit.3.txt +147 -0
- package/llms/stitchkit.txt +260 -0
- package/llms/telegram.txt +30 -0
- package/llms/testing.txt +676 -0
- package/llms/tools-connections.txt +45 -0
- package/llms/tools-contract.txt +9 -0
- package/llms/tools-invoker.txt +9 -0
- package/llms/tools.2.txt +838 -0
- package/llms/tools.txt +1004 -0
- package/llms/tracking-server.txt +32 -0
- package/llms/tracking.txt +263 -0
- package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
- package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
- package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
- package/llms/upgrading.txt +215 -0
- package/llms-full.txt +305 -75
- package/llms.txt +54 -5
- package/package.json +84 -83
- package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
- package/dist/agent-runtime/durability-json.d.ts.map +0 -1
- package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
- package/dist/agent-runtime/durability.d.ts.map +0 -1
- package/dist/agent-runtime/store-driver.d.ts.map +0 -1
- package/dist/agent-runtime-browser.d.ts +0 -5
- package/dist/agent-runtime-browser.d.ts.map +0 -1
- package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
- package/dist/agent-runtime-coding-tools.js +0 -23
- package/dist/agent-runtime-harness.d.ts.map +0 -1
- package/dist/agent-runtime-openrouter.d.ts.map +0 -1
- package/dist/agent-runtime-sandbox.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
- package/dist/agent-runtime-testing.d.ts +0 -3
- package/dist/agent-runtime-testing.d.ts.map +0 -1
- package/dist/agent-runtime-testing.js +0 -156
- package/dist/agent-runtime.d.ts.map +0 -1
- package/dist/application/channel.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.d.ts.map +0 -1
- package/dist/application-grammy.d.ts.map +0 -1
- package/dist/application-opentelemetry.d.ts.map +0 -1
- package/dist/application-schemas.d.ts.map +0 -1
- package/dist/application.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/contract/index.d.ts +0 -8
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/declaration.d.ts.map +0 -1
- package/dist/files.d.ts.map +0 -1
- package/dist/geo.d.ts.map +0 -1
- package/dist/google.d.ts.map +0 -1
- package/dist/index-0j3vcp5m.js +0 -28
- package/dist/index-a11g2kry.js +0 -866
- package/dist/index-cnyk6te3.js +0 -77
- package/dist/index-fadnxwna.js +0 -1046
- package/dist/index-hrbajay7.js +0 -1196
- package/dist/index-s8cnx02s.js +0 -90
- package/dist/index-v5573g1k.js +0 -142
- package/dist/index-vk3kq9sb.js +0 -3344
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/errors.d.ts.map +0 -1
- package/dist/internal/observability-sink.d.ts.map +0 -1
- package/dist/live.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/node.d.ts.map +0 -1
- package/dist/oauth.d.ts.map +0 -1
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -3
- package/dist/primitives.d.ts.map +0 -1
- package/dist/react.d.ts.map +0 -1
- package/dist/release.d.ts.map +0 -1
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -88
- package/dist/retained.d.ts.map +0 -1
- package/dist/server/file-state-store.d.ts.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/request.d.ts.map +0 -1
- package/dist/telegram.d.ts.map +0 -1
- package/dist/testing/agent-store-conformance.d.ts.map +0 -1
- package/dist/testing.d.ts +0 -39
- package/dist/testing.d.ts.map +0 -1
- package/dist/tool-invoker.d.ts.map +0 -1
- package/dist/tool-invoker.js +0 -21
- package/dist/tools/async-operation-contract.d.ts.map +0 -1
- package/dist/tools/async-operation.d.ts +0 -332
- package/dist/tools/async-operation.d.ts.map +0 -1
- package/dist/tools/cli-args.d.ts.map +0 -1
- package/dist/tools/cli-checkpoint.d.ts.map +0 -1
- package/dist/tools/cli-command.d.ts.map +0 -1
- package/dist/tools/cli-format.d.ts.map +0 -1
- package/dist/tools/cli-installer.d.ts.map +0 -1
- package/dist/tools/cli-invoke.d.ts.map +0 -1
- package/dist/tools/cli-manifest.d.ts.map +0 -1
- package/dist/tools/cli-policy.d.ts.map +0 -1
- package/dist/tools/cli-profile.d.ts.map +0 -1
- package/dist/tools/cli-signature.d.ts.map +0 -1
- package/dist/tools/cli-stream.d.ts.map +0 -1
- package/dist/tools/cli-update.d.ts.map +0 -1
- package/dist/tools/cli-view.d.ts.map +0 -1
- package/dist/tools/cli-wait.d.ts.map +0 -1
- package/dist/tools/cli.d.ts.map +0 -1
- package/dist/tools/coerce.d.ts.map +0 -1
- package/dist/tools/connections/index.d.ts.map +0 -1
- package/dist/tools/define-download-tool.d.ts.map +0 -1
- package/dist/tools/define-upload-tool.d.ts.map +0 -1
- package/dist/tools/define-view-file-tool.d.ts.map +0 -1
- package/dist/tools/define-wait-tool.d.ts.map +0 -1
- package/dist/tools/download-core.d.ts.map +0 -1
- package/dist/tools/flatten-join.d.ts.map +0 -1
- package/dist/tools/flatten.d.ts.map +0 -1
- package/dist/tools/json-schema-dialect.d.ts.map +0 -1
- package/dist/tools/json-schema.d.ts.map +0 -1
- package/dist/tools/managed-file-error.d.ts.map +0 -1
- package/dist/tools/mcp-app.d.ts.map +0 -1
- package/dist/tools/mcp-catalog.d.ts.map +0 -1
- package/dist/tools/mcp-handler.d.ts.map +0 -1
- package/dist/tools/mcp-prepare.d.ts.map +0 -1
- package/dist/tools/mcp-progress.d.ts.map +0 -1
- package/dist/tools/mcp-round-policy.d.ts.map +0 -1
- package/dist/tools/mcp-round.d.ts.map +0 -1
- package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
- package/dist/tools/mcp-stdio.d.ts.map +0 -1
- package/dist/tools/mcp-trace.d.ts.map +0 -1
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mount-download.d.ts.map +0 -1
- package/dist/tools/mount-upload.d.ts.map +0 -1
- package/dist/tools/mount-wait.d.ts.map +0 -1
- package/dist/tools/native-mcp.d.ts +0 -20
- package/dist/tools/native-mcp.d.ts.map +0 -1
- package/dist/tools/native-result.d.ts.map +0 -1
- package/dist/tools/oauth-metadata.d.ts.map +0 -1
- package/dist/tools/oauth-provider.d.ts.map +0 -1
- package/dist/tools/portable-formats.d.ts.map +0 -1
- package/dist/tools/presentation.d.ts.map +0 -1
- package/dist/tools/schema.d.ts.map +0 -1
- package/dist/tools/untyped-properties.d.ts.map +0 -1
- package/dist/tools/upload-core.d.ts.map +0 -1
- package/dist/tools/view-file-contract.d.ts.map +0 -1
- package/dist/tools/view-file.d.ts.map +0 -1
- package/dist/tools/wait-core.d.ts.map +0 -1
- package/dist/tools-contract.d.ts.map +0 -1
- package/dist/tools.d.ts +0 -50
- package/dist/tools.d.ts.map +0 -1
- package/dist/tracking-server.d.ts.map +0 -1
- package/dist/tracking.d.ts.map +0 -1
- package/dist/upgrade-cli.d.ts.map +0 -1
- package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
- package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
- package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
- package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
- package/dist/{google.d.ts → google/google.d.ts} +0 -0
- package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
- package/dist/{index-actkayzn.js → index-70yj2ebz.js} +3 -3
- /package/dist/{application → internal}/channel.d.ts +0 -0
- /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
- /package/dist/{server → internal}/request.d.ts +0 -0
- /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
- /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
- /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
- /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
- /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
- /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
- /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
- /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
- /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
- /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
- /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
- /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
|
@@ -3,39 +3,149 @@ import {
|
|
|
3
3
|
} from "./index-sbdmyz75.js";
|
|
4
4
|
import {
|
|
5
5
|
collectToolSurface
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-vcvkq30w.js";
|
|
7
7
|
import {
|
|
8
8
|
createToolRunner,
|
|
9
9
|
formatToolError
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-2cr1cqhn.js";
|
|
11
11
|
import {
|
|
12
12
|
toolErrorFromResult,
|
|
13
13
|
toolResultFromError
|
|
14
|
-
} from "./index-
|
|
15
|
-
import {
|
|
16
|
-
formatZodError,
|
|
17
|
-
validateDeclaredOutput
|
|
18
|
-
} from "./index-e0znv5gn.js";
|
|
14
|
+
} from "./index-j05z5gn4.js";
|
|
19
15
|
import {
|
|
20
16
|
coerceJsonArgs
|
|
21
|
-
} from "./index-
|
|
17
|
+
} from "./index-1zbbzgfh.js";
|
|
22
18
|
import {
|
|
23
19
|
assertUniqueToolName,
|
|
24
20
|
buildToolPresentationSchema,
|
|
25
21
|
objectShapeKeys
|
|
26
|
-
} from "./index-
|
|
22
|
+
} from "./index-dydjcp8z.js";
|
|
27
23
|
import {
|
|
28
24
|
jsonSchemaFields
|
|
29
|
-
} from "./index-
|
|
25
|
+
} from "./index-eqqvgdb3.js";
|
|
26
|
+
import {
|
|
27
|
+
validateDeclaredOutput
|
|
28
|
+
} from "./index-znfs20ss.js";
|
|
29
|
+
import {
|
|
30
|
+
formatZodError
|
|
31
|
+
} from "./index-p5r7qpdd.js";
|
|
30
32
|
import {
|
|
31
33
|
isUnsafeKey,
|
|
32
34
|
safeJsonParse
|
|
33
35
|
} from "./index-kzfs85xp.js";
|
|
34
36
|
import {
|
|
35
37
|
isRecord
|
|
36
|
-
} from "./index-
|
|
38
|
+
} from "./index-hffjpmq9.js";
|
|
39
|
+
|
|
40
|
+
// src/tools/cli/command.ts
|
|
41
|
+
function defineCliCommand(definition) {
|
|
42
|
+
return definition;
|
|
43
|
+
}
|
|
44
|
+
function cliCommandReturnsResult(definition) {
|
|
45
|
+
return definition.output !== undefined;
|
|
46
|
+
}
|
|
47
|
+
function cliCommandSuccessExitCode(definition, data) {
|
|
48
|
+
const successExitCode = definition.exitCode?.(data) ?? 0;
|
|
49
|
+
if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
|
|
50
|
+
throw new Error("CLI success exit code must be an integer from 0 to 255");
|
|
51
|
+
}
|
|
52
|
+
return successExitCode;
|
|
53
|
+
}
|
|
54
|
+
function prepareCliCommandEmission(definition, result, options) {
|
|
55
|
+
if (!result.ok || definition.output === undefined) {
|
|
56
|
+
return { result, successExitCode: 0 };
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const successExitCode = cliCommandSuccessExitCode(definition, result.data);
|
|
60
|
+
const presentation = definition.present?.({ result: result.data, options });
|
|
61
|
+
if (presentation !== undefined && typeof presentation !== "string") {
|
|
62
|
+
throw new Error("CLI result presenter must return a string");
|
|
63
|
+
}
|
|
64
|
+
return { result, presentation, successExitCode };
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
|
|
68
|
+
successExitCode: 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function cliCommandPresentationSchema(definition) {
|
|
73
|
+
return buildToolPresentationSchema({
|
|
74
|
+
inputSchema: definition.input,
|
|
75
|
+
unrepresentable: "any"
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
|
|
79
|
+
let parsed;
|
|
80
|
+
try {
|
|
81
|
+
parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs(rawArgs, definition.input) : rawArgs);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return toolResultFromError(error);
|
|
84
|
+
}
|
|
85
|
+
if (!parsed.success) {
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
code: "VALIDATION_ERROR",
|
|
89
|
+
details: { message: `Invalid input: ${formatZodError(parsed.error)}` }
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const data = await definition.handler({
|
|
94
|
+
input: parsed.data,
|
|
95
|
+
options,
|
|
96
|
+
globals,
|
|
97
|
+
...writers
|
|
98
|
+
});
|
|
99
|
+
const checked = validateDeclaredOutput(definition.output, data);
|
|
100
|
+
if (!checked.ok) {
|
|
101
|
+
return {
|
|
102
|
+
ok: false,
|
|
103
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
104
|
+
details: { message: checked.message }
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return { ok: true, data: checked.data };
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return toolResultFromError(error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/tools/cli/format.ts
|
|
114
|
+
var DEFAULT_EXIT_CODES = {
|
|
115
|
+
VALIDATION_ERROR: 1,
|
|
116
|
+
BAD_REQUEST: 1,
|
|
117
|
+
UNAUTHORIZED: 2,
|
|
118
|
+
FORBIDDEN: 3,
|
|
119
|
+
NOT_FOUND: 4,
|
|
120
|
+
CONFLICT: 5,
|
|
121
|
+
RATE_LIMITED: 6,
|
|
122
|
+
TIMEOUT: 7,
|
|
123
|
+
WAIT_FAILED: 1,
|
|
124
|
+
INTERNAL_SERVER_ERROR: 1
|
|
125
|
+
};
|
|
126
|
+
function cliExitCode(result, exitCodes) {
|
|
127
|
+
if (result.ok)
|
|
128
|
+
return 0;
|
|
129
|
+
const codes = { ...DEFAULT_EXIT_CODES, ...exitCodes };
|
|
130
|
+
return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
|
|
131
|
+
}
|
|
132
|
+
function emitResult(result, writers, opts) {
|
|
133
|
+
if (result.ok) {
|
|
134
|
+
if (result.data === undefined)
|
|
135
|
+
return 0;
|
|
136
|
+
const text2 = opts.json ? JSON.stringify(result.data) : JSON.stringify(result.data, null, 2);
|
|
137
|
+
writers.stdout(`${text2}
|
|
138
|
+
`);
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
const error = formatToolError(result, opts.toolName, opts.errorHint);
|
|
142
|
+
const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
|
|
143
|
+
writers.stderr(`${text}
|
|
144
|
+
`);
|
|
145
|
+
return cliExitCode(result, opts.exitCodes);
|
|
146
|
+
}
|
|
37
147
|
|
|
38
|
-
// src/tools/cli
|
|
148
|
+
// src/tools/cli/args.ts
|
|
39
149
|
import { z } from "zod";
|
|
40
150
|
var NUMERIC_VALUE = /^-(\d+\.?\d*|\.\d+)$/;
|
|
41
151
|
var BOOL_OPTIONS = new Set(["json", "wait", "quiet", "dry-run", "help", "ascending"]);
|
|
@@ -665,108 +775,7 @@ function resolveCliView(flags, ascending) {
|
|
|
665
775
|
throw new CliArgumentError("--top needs --sort, --by, --count-by or --sum to rank");
|
|
666
776
|
}
|
|
667
777
|
|
|
668
|
-
// src/tools/cli
|
|
669
|
-
function defineCliCommand(definition) {
|
|
670
|
-
return definition;
|
|
671
|
-
}
|
|
672
|
-
function prepareCliCommandEmission(definition, result, options) {
|
|
673
|
-
if (!result.ok || definition.output === undefined) {
|
|
674
|
-
return { result, successExitCode: 0 };
|
|
675
|
-
}
|
|
676
|
-
try {
|
|
677
|
-
const successExitCode = definition.exitCode?.(result.data) ?? 0;
|
|
678
|
-
if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
|
|
679
|
-
throw new Error("CLI success exit code must be an integer from 0 to 255");
|
|
680
|
-
}
|
|
681
|
-
const presentation = definition.present?.({ result: result.data, options });
|
|
682
|
-
if (presentation !== undefined && typeof presentation !== "string") {
|
|
683
|
-
throw new Error("CLI result presenter must return a string");
|
|
684
|
-
}
|
|
685
|
-
return { result, presentation, successExitCode };
|
|
686
|
-
} catch (error) {
|
|
687
|
-
return {
|
|
688
|
-
result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
|
|
689
|
-
successExitCode: 0
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
function cliCommandPresentationSchema(definition) {
|
|
694
|
-
return buildToolPresentationSchema({
|
|
695
|
-
inputSchema: definition.input,
|
|
696
|
-
unrepresentable: "any"
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
|
|
700
|
-
let parsed;
|
|
701
|
-
try {
|
|
702
|
-
parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs(rawArgs, definition.input) : rawArgs);
|
|
703
|
-
} catch (error) {
|
|
704
|
-
return toolResultFromError(error);
|
|
705
|
-
}
|
|
706
|
-
if (!parsed.success) {
|
|
707
|
-
return {
|
|
708
|
-
ok: false,
|
|
709
|
-
code: "VALIDATION_ERROR",
|
|
710
|
-
details: { message: `Invalid input: ${formatZodError(parsed.error)}` }
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
try {
|
|
714
|
-
const data = await definition.handler({
|
|
715
|
-
input: parsed.data,
|
|
716
|
-
options,
|
|
717
|
-
globals,
|
|
718
|
-
...writers
|
|
719
|
-
});
|
|
720
|
-
const checked = validateDeclaredOutput(definition.output, data);
|
|
721
|
-
if (!checked.ok) {
|
|
722
|
-
return {
|
|
723
|
-
ok: false,
|
|
724
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
725
|
-
details: { message: checked.message }
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
return { ok: true, data: checked.data };
|
|
729
|
-
} catch (error) {
|
|
730
|
-
return toolResultFromError(error);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// src/tools/cli-format.ts
|
|
735
|
-
var DEFAULT_EXIT_CODES = {
|
|
736
|
-
VALIDATION_ERROR: 1,
|
|
737
|
-
BAD_REQUEST: 1,
|
|
738
|
-
UNAUTHORIZED: 2,
|
|
739
|
-
FORBIDDEN: 3,
|
|
740
|
-
NOT_FOUND: 4,
|
|
741
|
-
CONFLICT: 5,
|
|
742
|
-
RATE_LIMITED: 6,
|
|
743
|
-
TIMEOUT: 7,
|
|
744
|
-
WAIT_FAILED: 1,
|
|
745
|
-
INTERNAL_SERVER_ERROR: 1
|
|
746
|
-
};
|
|
747
|
-
function cliExitCode(result, exitCodes) {
|
|
748
|
-
if (result.ok)
|
|
749
|
-
return 0;
|
|
750
|
-
const codes = { ...DEFAULT_EXIT_CODES, ...exitCodes };
|
|
751
|
-
return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
|
|
752
|
-
}
|
|
753
|
-
function emitResult(result, writers, opts) {
|
|
754
|
-
if (result.ok) {
|
|
755
|
-
if (result.data === undefined)
|
|
756
|
-
return 0;
|
|
757
|
-
const text2 = opts.json ? JSON.stringify(result.data) : JSON.stringify(result.data, null, 2);
|
|
758
|
-
writers.stdout(`${text2}
|
|
759
|
-
`);
|
|
760
|
-
return 0;
|
|
761
|
-
}
|
|
762
|
-
const error = formatToolError(result, opts.toolName, opts.errorHint);
|
|
763
|
-
const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
|
|
764
|
-
writers.stderr(`${text}
|
|
765
|
-
`);
|
|
766
|
-
return cliExitCode(result, opts.exitCodes);
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
// src/tools/cli-policy.ts
|
|
778
|
+
// src/tools/cli/policy.ts
|
|
770
779
|
var SHORT_ALIAS = /^[A-Za-z]$/;
|
|
771
780
|
var RESERVED_SHORT_OPTIONS = new Set(["h"]);
|
|
772
781
|
function fieldMap(descriptor) {
|
|
@@ -846,7 +855,7 @@ function assertCliPoliciesResolved(commands, config) {
|
|
|
846
855
|
}
|
|
847
856
|
}
|
|
848
857
|
|
|
849
|
-
// src/tools/cli
|
|
858
|
+
// src/tools/cli/invoke.ts
|
|
850
859
|
function parseCliGlobals(schema, globals) {
|
|
851
860
|
if (!schema)
|
|
852
861
|
return globals ?? {};
|
|
@@ -877,21 +886,29 @@ function cliInvocationResult(result, toolName, config) {
|
|
|
877
886
|
async function createCliInvoker(config, globals) {
|
|
878
887
|
const typedGlobals = parseCliGlobals(config.globalOptions, globals);
|
|
879
888
|
const auth = await (config.resolveAuth ? config.resolveAuth(typedGlobals) : config.auth);
|
|
889
|
+
const natives = new Map((config.commands ?? []).filter(cliCommandReturnsResult).map((definition) => [definition.name, definition]));
|
|
890
|
+
const nativeHelp = new Map([...natives].map(([name, definition]) => [
|
|
891
|
+
name,
|
|
892
|
+
{ description: definition.description, argumentSchema: {}, presentationSchema: {} }
|
|
893
|
+
]));
|
|
880
894
|
const { tools, help } = buildCliSurface(config, auth, new Map, new Set);
|
|
881
895
|
const runTool = createToolRunner({
|
|
882
896
|
source: "cli",
|
|
897
|
+
toolSurface: true,
|
|
883
898
|
context: { ...config.context?.(auth, typedGlobals), signal: config.signal },
|
|
884
899
|
hooks: config.hooks,
|
|
885
900
|
lifecycle: config.lifecycle,
|
|
886
|
-
errorHint: config.errorHint,
|
|
887
901
|
coerceJsonArgs: config.coerceJsonArgs
|
|
888
902
|
});
|
|
889
903
|
return {
|
|
890
|
-
commands: [...help].map(([name, presentation]) => ({
|
|
904
|
+
commands: [...nativeHelp, ...help].map(([name, presentation]) => ({
|
|
891
905
|
name,
|
|
892
906
|
description: presentation.description
|
|
893
907
|
})),
|
|
894
908
|
invoke: async (command, args) => {
|
|
909
|
+
const native = natives.get(command);
|
|
910
|
+
if (native)
|
|
911
|
+
return runNativeCommand(native, args, config, typedGlobals);
|
|
895
912
|
const tool = tools.get(command);
|
|
896
913
|
if (!tool) {
|
|
897
914
|
return cliInvocationResult({
|
|
@@ -910,6 +927,42 @@ async function createCliInvoker(config, globals) {
|
|
|
910
927
|
}
|
|
911
928
|
};
|
|
912
929
|
}
|
|
930
|
+
var IN_PROCESS_RUN_OPTIONS = Object.freeze({
|
|
931
|
+
json: false,
|
|
932
|
+
wait: false,
|
|
933
|
+
quiet: true,
|
|
934
|
+
dryRun: false,
|
|
935
|
+
help: false
|
|
936
|
+
});
|
|
937
|
+
async function runNativeCommand(definition, args, config, globals) {
|
|
938
|
+
let out = "";
|
|
939
|
+
let err = "";
|
|
940
|
+
const result = await executeCliCommand(definition, args, IN_PROCESS_RUN_OPTIONS, {
|
|
941
|
+
stdout: (text) => {
|
|
942
|
+
out += text;
|
|
943
|
+
},
|
|
944
|
+
stderr: (text) => {
|
|
945
|
+
err += text;
|
|
946
|
+
}
|
|
947
|
+
}, config.coerceJsonArgs ?? true, globals);
|
|
948
|
+
let invocation = cliInvocationResult(result, definition.name, config);
|
|
949
|
+
if (invocation.ok) {
|
|
950
|
+
try {
|
|
951
|
+
invocation = {
|
|
952
|
+
...invocation,
|
|
953
|
+
exitCode: cliCommandSuccessExitCode(definition, result.ok ? result.data : undefined)
|
|
954
|
+
};
|
|
955
|
+
} catch (error) {
|
|
956
|
+
invocation = cliInvocationResult(toolResultFromError(error), definition.name, config);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (out === "" && err === "")
|
|
960
|
+
return invocation;
|
|
961
|
+
return {
|
|
962
|
+
...invocation,
|
|
963
|
+
written: { ...out !== "" && { stdout: out }, ...err !== "" && { stderr: err } }
|
|
964
|
+
};
|
|
965
|
+
}
|
|
913
966
|
function buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertShape) {
|
|
914
967
|
const services = typeof config.services === "function" ? config.services(auth) : config.services ?? [];
|
|
915
968
|
const runtimeTools = typeof config.runtimeTools === "function" ? config.runtimeTools(auth) : config.runtimeTools ?? [];
|
|
@@ -935,7 +988,7 @@ function managedCliDescriptor(tool) {
|
|
|
935
988
|
};
|
|
936
989
|
}
|
|
937
990
|
|
|
938
|
-
// src/tools/cli
|
|
991
|
+
// src/tools/cli/view.ts
|
|
939
992
|
var ABSENT = "(absent)";
|
|
940
993
|
function selectRecords(data) {
|
|
941
994
|
if (Array.isArray(data))
|
|
@@ -1082,7 +1135,7 @@ function renderCliView(data, view) {
|
|
|
1082
1135
|
return { kind: "json", data: ordered(totals, view.top) };
|
|
1083
1136
|
}
|
|
1084
1137
|
|
|
1085
|
-
// src/tools/wait-core.ts
|
|
1138
|
+
// src/tools/operations/wait-core.ts
|
|
1086
1139
|
var DEFAULT_BACKOFF = [2, 3, 5, 5, 8, 10];
|
|
1087
1140
|
var DEFAULT_TIMEOUT = 600;
|
|
1088
1141
|
|
|
@@ -1178,7 +1231,7 @@ function runWaitOperation(params) {
|
|
|
1178
1231
|
});
|
|
1179
1232
|
}
|
|
1180
1233
|
|
|
1181
|
-
// src/tools/cli
|
|
1234
|
+
// src/tools/cli/wait.ts
|
|
1182
1235
|
var DEFAULT_TIMEOUT2 = 600;
|
|
1183
1236
|
function waitFailure(tool, result) {
|
|
1184
1237
|
return {
|
|
@@ -1232,8 +1285,58 @@ async function pollUntilDone(params) {
|
|
|
1232
1285
|
return state;
|
|
1233
1286
|
}
|
|
1234
1287
|
|
|
1235
|
-
// src/tools/cli.ts
|
|
1288
|
+
// src/tools/cli/io.ts
|
|
1236
1289
|
import { writeSync } from "node:fs";
|
|
1290
|
+
async function readPipedStdin() {
|
|
1291
|
+
if (process.stdin.isTTY)
|
|
1292
|
+
return null;
|
|
1293
|
+
const chunks = [];
|
|
1294
|
+
for await (const chunk of process.stdin) {
|
|
1295
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
1296
|
+
}
|
|
1297
|
+
const text = Buffer.concat(chunks).toString("utf8").trim();
|
|
1298
|
+
return text.length > 0 ? text : null;
|
|
1299
|
+
}
|
|
1300
|
+
function createCliIo(config) {
|
|
1301
|
+
let pendingWrite;
|
|
1302
|
+
let writeFailed = false;
|
|
1303
|
+
const writeFd = (fd, text) => {
|
|
1304
|
+
const bytes = Buffer.from(text, "utf8");
|
|
1305
|
+
let offset = 0;
|
|
1306
|
+
while (offset < bytes.length) {
|
|
1307
|
+
try {
|
|
1308
|
+
offset += writeSync(fd, bytes, offset, bytes.length - offset);
|
|
1309
|
+
} catch (error) {
|
|
1310
|
+
if (isRecord(error) && error.code === "EAGAIN") {
|
|
1311
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1);
|
|
1312
|
+
continue;
|
|
1313
|
+
}
|
|
1314
|
+
const stream = fd === 1 ? process.stdout : process.stderr;
|
|
1315
|
+
const rest = bytes.subarray(offset);
|
|
1316
|
+
pendingWrite = new Promise((resolve) => {
|
|
1317
|
+
stream.write(rest, (failure) => {
|
|
1318
|
+
if (failure)
|
|
1319
|
+
writeFailed = true;
|
|
1320
|
+
resolve();
|
|
1321
|
+
});
|
|
1322
|
+
});
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
const stdout = config.stdout ?? ((text) => writeFd(1, text));
|
|
1328
|
+
const stderr = config.stderr ?? ((text) => writeFd(2, text));
|
|
1329
|
+
const exit = config.exit ?? ((code) => {
|
|
1330
|
+
if (pendingWrite === undefined)
|
|
1331
|
+
process.exit(code);
|
|
1332
|
+
else
|
|
1333
|
+
pendingWrite.then(() => process.exit(writeFailed ? 1 : code));
|
|
1334
|
+
});
|
|
1335
|
+
const readStdin = config.stdin ?? readPipedStdin;
|
|
1336
|
+
return { stdout, stderr, exit, readStdin };
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
// src/tools/cli/download.ts
|
|
1237
1340
|
import { basename, resolve } from "node:path";
|
|
1238
1341
|
|
|
1239
1342
|
// src/internal/secure-fetch.ts
|
|
@@ -1398,6 +1501,10 @@ async function fetchGuarded(start, allowPrivate, options = {}) {
|
|
|
1398
1501
|
clearTimeout(headerTimer);
|
|
1399
1502
|
}
|
|
1400
1503
|
}
|
|
1504
|
+
|
|
1505
|
+
class PrivateAddressRefusal extends Error {
|
|
1506
|
+
name = "PrivateAddressRefusal";
|
|
1507
|
+
}
|
|
1401
1508
|
async function resolvePublicAddress(url, signal) {
|
|
1402
1509
|
assertHttpUrl(url);
|
|
1403
1510
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
@@ -1406,20 +1513,20 @@ async function resolvePublicAddress(url, signal) {
|
|
|
1406
1513
|
const ipFamily = isIP(host);
|
|
1407
1514
|
if (ipFamily) {
|
|
1408
1515
|
if (isPrivateIp(host))
|
|
1409
|
-
throw new
|
|
1516
|
+
throw new PrivateAddressRefusal("refusing to fetch a private address");
|
|
1410
1517
|
return { address: host, family: ipFamily === 6 ? 6 : 4 };
|
|
1411
1518
|
}
|
|
1412
1519
|
if (NUMERIC_HOST.test(host)) {
|
|
1413
|
-
throw new
|
|
1520
|
+
throw new PrivateAddressRefusal("refusing to fetch a non-canonical numeric host");
|
|
1414
1521
|
}
|
|
1415
1522
|
if (host === "localhost" || host.endsWith(".local") || host.endsWith(".internal")) {
|
|
1416
|
-
throw new
|
|
1523
|
+
throw new PrivateAddressRefusal("refusing to fetch an internal host");
|
|
1417
1524
|
}
|
|
1418
1525
|
const pending = lookup(host, { all: true });
|
|
1419
1526
|
const records = signal ? await raceWithAbort(pending, signal) : await pending;
|
|
1420
1527
|
for (const record2 of records) {
|
|
1421
1528
|
if (isPrivateIp(record2.address)) {
|
|
1422
|
-
throw new
|
|
1529
|
+
throw new PrivateAddressRefusal("refusing to fetch a host that resolves to a private address");
|
|
1423
1530
|
}
|
|
1424
1531
|
}
|
|
1425
1532
|
const record = records[0];
|
|
@@ -1542,7 +1649,34 @@ async function writeDownload(root, target, data) {
|
|
|
1542
1649
|
await writeFile(target, data);
|
|
1543
1650
|
}
|
|
1544
1651
|
|
|
1545
|
-
// src/tools/cli.ts
|
|
1652
|
+
// src/tools/cli/download.ts
|
|
1653
|
+
var DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
|
|
1654
|
+
async function downloadResults(files, dir, stderr, quiet, allowPrivate, maxBytes, timeoutMs) {
|
|
1655
|
+
const root = resolve(dir);
|
|
1656
|
+
let succeeded = true;
|
|
1657
|
+
for (const file of files) {
|
|
1658
|
+
try {
|
|
1659
|
+
const res = await fetchGuarded(new URL(file.url), allowPrivate, { timeoutMs });
|
|
1660
|
+
if (!res.ok)
|
|
1661
|
+
throw new Error(`HTTP ${res.status}`);
|
|
1662
|
+
const buffer = await readCapped(res, maxBytes);
|
|
1663
|
+
if (!buffer)
|
|
1664
|
+
throw new Error(`file exceeds the ${maxBytes}-byte cap`);
|
|
1665
|
+
const target = resolve(root, basename(file.name));
|
|
1666
|
+
await writeDownload(root, target, buffer);
|
|
1667
|
+
if (!quiet)
|
|
1668
|
+
stderr(`saved ${target} (${(buffer.length / 1024).toFixed(0)}KB)
|
|
1669
|
+
`);
|
|
1670
|
+
} catch (err) {
|
|
1671
|
+
succeeded = false;
|
|
1672
|
+
stderr(`failed to download ${file.url}: ${err instanceof Error ? err.message : String(err)}
|
|
1673
|
+
`);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return succeeded;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
// src/tools/cli/help.ts
|
|
1546
1680
|
var GLOBAL_OPTIONS = [
|
|
1547
1681
|
["--json", "Emit compact success/error JSON records (for scripts)"],
|
|
1548
1682
|
["--wait", "Block-poll an async result to a terminal state"],
|
|
@@ -1559,16 +1693,6 @@ var GLOBAL_OPTIONS = [
|
|
|
1559
1693
|
["--top <n>", "Keep the n leading entries of the view asked for"],
|
|
1560
1694
|
["--table <a,b>", "Render the named fields as an aligned table"]
|
|
1561
1695
|
];
|
|
1562
|
-
async function readPipedStdin() {
|
|
1563
|
-
if (process.stdin.isTTY)
|
|
1564
|
-
return null;
|
|
1565
|
-
const chunks = [];
|
|
1566
|
-
for await (const chunk of process.stdin) {
|
|
1567
|
-
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
1568
|
-
}
|
|
1569
|
-
const text = Buffer.concat(chunks).toString("utf8").trim();
|
|
1570
|
-
return text.length > 0 ? text : null;
|
|
1571
|
-
}
|
|
1572
1696
|
function typeLabel(schema) {
|
|
1573
1697
|
if (Array.isArray(schema.enum))
|
|
1574
1698
|
return schema.enum.join("|");
|
|
@@ -1588,44 +1712,6 @@ function summarize(desc) {
|
|
|
1588
1712
|
const max = 72;
|
|
1589
1713
|
return firstSentence.length > max ? `${firstSentence.slice(0, max - 1).trimEnd()}…` : firstSentence;
|
|
1590
1714
|
}
|
|
1591
|
-
function looseCoerceValue(value) {
|
|
1592
|
-
if (Array.isArray(value))
|
|
1593
|
-
return value.map(looseCoerceValue);
|
|
1594
|
-
if (typeof value !== "string")
|
|
1595
|
-
return value;
|
|
1596
|
-
if (value === "true")
|
|
1597
|
-
return true;
|
|
1598
|
-
if (value === "false")
|
|
1599
|
-
return false;
|
|
1600
|
-
const n = Number(value);
|
|
1601
|
-
return value.trim() !== "" && !Number.isNaN(n) ? n : value;
|
|
1602
|
-
}
|
|
1603
|
-
function passthroughBase(value) {
|
|
1604
|
-
if (isRecord(value))
|
|
1605
|
-
return value;
|
|
1606
|
-
if (typeof value === "string") {
|
|
1607
|
-
try {
|
|
1608
|
-
const parsed = safeJsonParse(value);
|
|
1609
|
-
if (isRecord(parsed))
|
|
1610
|
-
return parsed;
|
|
1611
|
-
} catch {}
|
|
1612
|
-
}
|
|
1613
|
-
return;
|
|
1614
|
-
}
|
|
1615
|
-
function collectPassthrough(toolArgs, field, knownKeys) {
|
|
1616
|
-
const known = new Set(knownKeys);
|
|
1617
|
-
const bag = {};
|
|
1618
|
-
for (const key of Object.keys(toolArgs)) {
|
|
1619
|
-
if (key === field || known.has(key))
|
|
1620
|
-
continue;
|
|
1621
|
-
bag[key] = looseCoerceValue(toolArgs[key]);
|
|
1622
|
-
delete toolArgs[key];
|
|
1623
|
-
}
|
|
1624
|
-
if (Object.keys(bag).length === 0)
|
|
1625
|
-
return;
|
|
1626
|
-
const base = passthroughBase(toolArgs[field]);
|
|
1627
|
-
toolArgs[field] = base ? { ...base, ...bag } : bag;
|
|
1628
|
-
}
|
|
1629
1715
|
function applicationOptionLines(fields) {
|
|
1630
1716
|
if (fields.length === 0)
|
|
1631
1717
|
return [];
|
|
@@ -1720,6 +1806,8 @@ function renderCommandHelp(name, command, descriptor, applicationOptions = []) {
|
|
|
1720
1806
|
`)}
|
|
1721
1807
|
`;
|
|
1722
1808
|
}
|
|
1809
|
+
|
|
1810
|
+
// src/tools/cli/session.ts
|
|
1723
1811
|
function nativeDescriptor(definition) {
|
|
1724
1812
|
return {
|
|
1725
1813
|
description: definition.description,
|
|
@@ -1745,101 +1833,7 @@ function assertCommandShape(name, descriptor, exists, passthroughField, applicat
|
|
|
1745
1833
|
throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
|
|
1746
1834
|
}
|
|
1747
1835
|
}
|
|
1748
|
-
|
|
1749
|
-
let parsed;
|
|
1750
|
-
try {
|
|
1751
|
-
parsed = parseCliArgs(commandArgv, descriptor.argumentSchema, {
|
|
1752
|
-
allowUnknown: config.passthrough?.[command] !== undefined,
|
|
1753
|
-
knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
|
|
1754
|
-
optionAliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
|
|
1755
|
-
positionals: descriptor.positionals
|
|
1756
|
-
});
|
|
1757
|
-
} catch (error) {
|
|
1758
|
-
if (!(error instanceof CliArgumentError))
|
|
1759
|
-
throw error;
|
|
1760
|
-
return { ok: false, message: error.message };
|
|
1761
|
-
}
|
|
1762
|
-
const { toolArgs, options } = parsed;
|
|
1763
|
-
const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
|
|
1764
|
-
if (firstUnset) {
|
|
1765
|
-
const piped = await readStdin();
|
|
1766
|
-
if (piped !== null) {
|
|
1767
|
-
if (descriptor.positionals === undefined) {
|
|
1768
|
-
toolArgs[firstUnset.name] = piped;
|
|
1769
|
-
} else {
|
|
1770
|
-
const stdinArgs = parseCliArgs([`--${firstUnset.name}`, piped], descriptor.argumentSchema);
|
|
1771
|
-
toolArgs[firstUnset.name] = stdinArgs.toolArgs[firstUnset.name];
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
const passthroughField = config.passthrough?.[command];
|
|
1776
|
-
if (passthroughField) {
|
|
1777
|
-
collectPassthrough(toolArgs, passthroughField, objectShapeKeys(descriptor.argumentSchema));
|
|
1778
|
-
}
|
|
1779
|
-
return { ok: true, toolArgs, options };
|
|
1780
|
-
}
|
|
1781
|
-
var DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
|
|
1782
|
-
async function downloadResults(files, dir, stderr, quiet, allowPrivate, maxBytes, timeoutMs) {
|
|
1783
|
-
const root = resolve(dir);
|
|
1784
|
-
let succeeded = true;
|
|
1785
|
-
for (const file of files) {
|
|
1786
|
-
try {
|
|
1787
|
-
const res = await fetchGuarded(new URL(file.url), allowPrivate, { timeoutMs });
|
|
1788
|
-
if (!res.ok)
|
|
1789
|
-
throw new Error(`HTTP ${res.status}`);
|
|
1790
|
-
const buffer = await readCapped(res, maxBytes);
|
|
1791
|
-
if (!buffer)
|
|
1792
|
-
throw new Error(`file exceeds the ${maxBytes}-byte cap`);
|
|
1793
|
-
const target = resolve(root, basename(file.name));
|
|
1794
|
-
await writeDownload(root, target, buffer);
|
|
1795
|
-
if (!quiet)
|
|
1796
|
-
stderr(`saved ${target} (${(buffer.length / 1024).toFixed(0)}KB)
|
|
1797
|
-
`);
|
|
1798
|
-
} catch (err) {
|
|
1799
|
-
succeeded = false;
|
|
1800
|
-
stderr(`failed to download ${file.url}: ${err instanceof Error ? err.message : String(err)}
|
|
1801
|
-
`);
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
return succeeded;
|
|
1805
|
-
}
|
|
1806
|
-
async function createCli(config) {
|
|
1807
|
-
let pendingWrite;
|
|
1808
|
-
let writeFailed = false;
|
|
1809
|
-
const writeFd = (fd, text) => {
|
|
1810
|
-
const bytes = Buffer.from(text, "utf8");
|
|
1811
|
-
let offset = 0;
|
|
1812
|
-
while (offset < bytes.length) {
|
|
1813
|
-
try {
|
|
1814
|
-
offset += writeSync(fd, bytes, offset, bytes.length - offset);
|
|
1815
|
-
} catch (error) {
|
|
1816
|
-
if (isRecord(error) && error.code === "EAGAIN") {
|
|
1817
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1);
|
|
1818
|
-
continue;
|
|
1819
|
-
}
|
|
1820
|
-
const stream = fd === 1 ? process.stdout : process.stderr;
|
|
1821
|
-
const rest = bytes.subarray(offset);
|
|
1822
|
-
pendingWrite = new Promise((resolve2) => {
|
|
1823
|
-
stream.write(rest, (failure) => {
|
|
1824
|
-
if (failure)
|
|
1825
|
-
writeFailed = true;
|
|
1826
|
-
resolve2();
|
|
1827
|
-
});
|
|
1828
|
-
});
|
|
1829
|
-
return;
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
};
|
|
1833
|
-
const stdout = config.stdout ?? ((text) => writeFd(1, text));
|
|
1834
|
-
const stderr = config.stderr ?? ((text) => writeFd(2, text));
|
|
1835
|
-
const exit = config.exit ?? ((code) => {
|
|
1836
|
-
if (pendingWrite === undefined)
|
|
1837
|
-
process.exit(code);
|
|
1838
|
-
else
|
|
1839
|
-
pendingWrite.then(() => process.exit(writeFailed ? 1 : code));
|
|
1840
|
-
});
|
|
1841
|
-
const argv = config.argv ?? process.argv.slice(2);
|
|
1842
|
-
const readStdin = config.stdin ?? readPipedStdin;
|
|
1836
|
+
function createCliSession(config, io) {
|
|
1843
1837
|
if (config.auth !== undefined && config.resolveAuth !== undefined) {
|
|
1844
1838
|
throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
|
|
1845
1839
|
}
|
|
@@ -1856,11 +1850,23 @@ async function createCli(config) {
|
|
|
1856
1850
|
const nativeCommands = new Map;
|
|
1857
1851
|
const nativeHelp = new Map;
|
|
1858
1852
|
for (const definition of config.commands ?? []) {
|
|
1859
|
-
const
|
|
1860
|
-
assertCommandShape(definition.name,
|
|
1853
|
+
const descriptor = applyCliPresentationPolicy(definition.name, nativeDescriptor(definition), config);
|
|
1854
|
+
assertCommandShape(definition.name, descriptor, nativeCommands.has(definition.name), config.passthrough?.[definition.name], applicationGlobalNames);
|
|
1861
1855
|
nativeCommands.set(definition.name, definition);
|
|
1862
|
-
nativeHelp.set(definition.name,
|
|
1856
|
+
nativeHelp.set(definition.name, descriptor);
|
|
1863
1857
|
}
|
|
1858
|
+
return {
|
|
1859
|
+
config,
|
|
1860
|
+
io,
|
|
1861
|
+
applicationOptions,
|
|
1862
|
+
applicationGlobalNames,
|
|
1863
|
+
nativeCommands,
|
|
1864
|
+
nativeHelp
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
function resolveCliRoute(session, argv) {
|
|
1868
|
+
const { config } = session;
|
|
1869
|
+
const { stdout, stderr, exit } = session.io;
|
|
1864
1870
|
let globals;
|
|
1865
1871
|
let routableArgv;
|
|
1866
1872
|
try {
|
|
@@ -1872,135 +1878,188 @@ async function createCli(config) {
|
|
|
1872
1878
|
throw error;
|
|
1873
1879
|
stderr(`${error.message}
|
|
1874
1880
|
`);
|
|
1875
|
-
|
|
1881
|
+
exit(2);
|
|
1882
|
+
return;
|
|
1876
1883
|
}
|
|
1877
1884
|
const typedGlobals = globals;
|
|
1878
1885
|
const route = routeCliArgv(routableArgv, config.defaultCommand);
|
|
1879
1886
|
if (route.error) {
|
|
1880
1887
|
stderr(`${route.error}
|
|
1881
1888
|
`);
|
|
1882
|
-
|
|
1889
|
+
exit(2);
|
|
1890
|
+
return;
|
|
1883
1891
|
}
|
|
1884
1892
|
const { command, commandArgv } = route;
|
|
1885
1893
|
if (route.version || command === "--version" || command === "version") {
|
|
1886
1894
|
stdout(`${config.name} ${config.version}
|
|
1887
1895
|
`);
|
|
1888
|
-
|
|
1896
|
+
exit(0);
|
|
1897
|
+
return;
|
|
1889
1898
|
}
|
|
1890
1899
|
const beforeSeparator = commandArgv.indexOf("--") === -1 ? commandArgv : commandArgv.slice(0, commandArgv.indexOf("--"));
|
|
1891
1900
|
const helpRequested = beforeSeparator.includes("--help") || beforeSeparator.includes("-h");
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
`);
|
|
1915
|
-
return exit(2);
|
|
1916
|
-
}
|
|
1917
|
-
if (options2.waitTimeout !== undefined) {
|
|
1918
|
-
stderr(`--wait-timeout requires --wait
|
|
1919
|
-
`);
|
|
1920
|
-
return exit(2);
|
|
1921
|
-
}
|
|
1922
|
-
if (options2.outputDir !== undefined) {
|
|
1923
|
-
stderr(`--output-dir is not configured for native commands
|
|
1924
|
-
`);
|
|
1925
|
-
return exit(2);
|
|
1926
|
-
}
|
|
1927
|
-
if (options2.dryRun) {
|
|
1928
|
-
stdout(`${JSON.stringify({ command, args: toolArgs2 }, null, 2)}
|
|
1929
|
-
`);
|
|
1930
|
-
return exit(0);
|
|
1931
|
-
}
|
|
1932
|
-
const result2 = await executeCliCommand(native, toolArgs2, options2, { stdout, stderr }, config.coerceJsonArgs ?? true, globals);
|
|
1933
|
-
const emission = prepareCliCommandEmission(native, result2, options2);
|
|
1934
|
-
let emittedExitCode;
|
|
1935
|
-
if (emission.result.ok && emission.presentation !== undefined) {
|
|
1936
|
-
stdout(emission.presentation);
|
|
1937
|
-
emittedExitCode = 0;
|
|
1938
|
-
} else {
|
|
1939
|
-
emittedExitCode = emitResult(emission.result, { stdout, stderr }, {
|
|
1940
|
-
json: options2.json,
|
|
1941
|
-
toolName: command,
|
|
1942
|
-
errorHint: config.errorHint,
|
|
1943
|
-
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
|
-
return exit(emission.result.ok ? emission.successExitCode : emittedExitCode);
|
|
1947
|
-
}
|
|
1901
|
+
return {
|
|
1902
|
+
globals,
|
|
1903
|
+
typedGlobals,
|
|
1904
|
+
route,
|
|
1905
|
+
command,
|
|
1906
|
+
commandArgv,
|
|
1907
|
+
beforeSeparator,
|
|
1908
|
+
helpRequested
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
function emitOptionsFor(config, json, toolName) {
|
|
1912
|
+
return {
|
|
1913
|
+
json,
|
|
1914
|
+
toolName,
|
|
1915
|
+
errorHint: config.errorHint,
|
|
1916
|
+
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
// src/tools/cli/managed-surface.ts
|
|
1921
|
+
async function buildManagedSurface(session, typedGlobals, forExecution) {
|
|
1922
|
+
const { config, nativeHelp, applicationGlobalNames } = session;
|
|
1948
1923
|
let authPromise;
|
|
1949
1924
|
const resolveIdentity = () => {
|
|
1950
1925
|
authPromise ??= (async () => config.resolveAuth ? await config.resolveAuth(typedGlobals) : await config.auth)();
|
|
1951
1926
|
return authPromise;
|
|
1952
1927
|
};
|
|
1953
1928
|
const dynamicSurface = typeof config.services === "function" || typeof config.runtimeTools === "function";
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1929
|
+
let auth;
|
|
1930
|
+
if (dynamicSurface || forExecution) {
|
|
1931
|
+
try {
|
|
1932
|
+
auth = await resolveIdentity();
|
|
1933
|
+
} catch (error) {
|
|
1934
|
+
const failure = toolResultFromError(error);
|
|
1935
|
+
const normalized = toolErrorFromResult(failure);
|
|
1936
|
+
return {
|
|
1937
|
+
resolved: false,
|
|
1938
|
+
failure,
|
|
1939
|
+
reason: `${normalized.code}: ${normalized.message}`,
|
|
1940
|
+
help: new Map(nativeHelp)
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
const { tools, help } = buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertCommandShape);
|
|
1945
|
+
return { resolved: true, auth, help, tools };
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
// src/tools/cli/prepare.ts
|
|
1949
|
+
function looseCoerceValue(value) {
|
|
1950
|
+
if (Array.isArray(value))
|
|
1951
|
+
return value.map(looseCoerceValue);
|
|
1952
|
+
if (typeof value !== "string")
|
|
1953
|
+
return value;
|
|
1954
|
+
if (value === "true")
|
|
1955
|
+
return true;
|
|
1956
|
+
if (value === "false")
|
|
1957
|
+
return false;
|
|
1958
|
+
const n = Number(value);
|
|
1959
|
+
return value.trim() !== "" && !Number.isNaN(n) ? n : value;
|
|
1960
|
+
}
|
|
1961
|
+
function passthroughBase(value) {
|
|
1962
|
+
if (isRecord(value))
|
|
1963
|
+
return value;
|
|
1964
|
+
if (typeof value === "string") {
|
|
1965
|
+
try {
|
|
1966
|
+
const parsed = safeJsonParse(value);
|
|
1967
|
+
if (isRecord(parsed))
|
|
1968
|
+
return parsed;
|
|
1969
|
+
} catch {}
|
|
1970
|
+
}
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
function collectPassthrough(toolArgs, field, knownKeys) {
|
|
1974
|
+
const known = new Set(knownKeys);
|
|
1975
|
+
const bag = {};
|
|
1976
|
+
for (const key of Object.keys(toolArgs)) {
|
|
1977
|
+
if (key === field || known.has(key))
|
|
1978
|
+
continue;
|
|
1979
|
+
bag[key] = looseCoerceValue(toolArgs[key]);
|
|
1980
|
+
delete toolArgs[key];
|
|
1981
|
+
}
|
|
1982
|
+
if (Object.keys(bag).length === 0)
|
|
1983
|
+
return;
|
|
1984
|
+
const base = passthroughBase(toolArgs[field]);
|
|
1985
|
+
toolArgs[field] = base ? { ...base, ...bag } : bag;
|
|
1986
|
+
}
|
|
1987
|
+
async function prepareInvocation(command, commandArgv, descriptor, config, readStdin) {
|
|
1988
|
+
let parsed;
|
|
1989
|
+
try {
|
|
1990
|
+
parsed = parseCliArgs(commandArgv, descriptor.argumentSchema, {
|
|
1991
|
+
allowUnknown: config.passthrough?.[command] !== undefined,
|
|
1992
|
+
knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
|
|
1993
|
+
optionAliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
|
|
1994
|
+
positionals: descriptor.positionals
|
|
1995
|
+
});
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
if (!(error instanceof CliArgumentError))
|
|
1998
|
+
throw error;
|
|
1999
|
+
return { ok: false, message: error.message };
|
|
2000
|
+
}
|
|
2001
|
+
const { toolArgs, options } = parsed;
|
|
2002
|
+
const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
|
|
2003
|
+
if (firstUnset) {
|
|
2004
|
+
const piped = await readStdin();
|
|
2005
|
+
if (piped !== null) {
|
|
2006
|
+
if (descriptor.positionals === undefined) {
|
|
2007
|
+
toolArgs[firstUnset.name] = piped;
|
|
2008
|
+
} else {
|
|
2009
|
+
const stdinArgs = parseCliArgs([`--${firstUnset.name}`, piped], descriptor.argumentSchema);
|
|
2010
|
+
toolArgs[firstUnset.name] = stdinArgs.toolArgs[firstUnset.name];
|
|
1968
2011
|
}
|
|
1969
2012
|
}
|
|
1970
|
-
const { tools, help } = buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertCommandShape);
|
|
1971
|
-
return { resolved: true, auth, help, tools };
|
|
1972
|
-
};
|
|
1973
|
-
const topLevelHelp = route.topLevelHelp || command === undefined || command === "help" || command === "--help" || command === "-h" || command.startsWith("--help=") && !isReservedBoolWord(command.slice("--help=".length));
|
|
1974
|
-
const managed = await buildManagedSurface(!topLevelHelp && !helpRequested);
|
|
1975
|
-
if (topLevelHelp) {
|
|
1976
|
-
const helpFilter = route.helpFilter ?? (command !== undefined ? commandArgv[0] : undefined);
|
|
1977
|
-
const filter = helpFilter !== undefined && !helpFilter.startsWith("-") ? helpFilter : undefined;
|
|
1978
|
-
if (filter !== undefined && filterCommands(managed.help, filter).size === 0) {
|
|
1979
|
-
stderr(`no command matches "${filter}" (${managed.help.size} available)
|
|
1980
|
-
` + (managed.resolved ? "" : `Managed commands are unavailable: ${managed.reason}
|
|
1981
|
-
`));
|
|
1982
|
-
const codes = { ...DEFAULT_EXIT_CODES, ...config.exitCodes };
|
|
1983
|
-
return exit(codes.NOT_FOUND ?? 4);
|
|
1984
|
-
}
|
|
1985
|
-
stdout(renderTopHelp({
|
|
1986
|
-
name: config.name,
|
|
1987
|
-
version: config.version,
|
|
1988
|
-
commands: managed.help,
|
|
1989
|
-
defaultCommand: config.defaultCommand,
|
|
1990
|
-
applicationOptions,
|
|
1991
|
-
...filter !== undefined && { filter },
|
|
1992
|
-
...managed.resolved ? {} : { unavailable: managed.reason }
|
|
1993
|
-
}));
|
|
1994
|
-
return exit(0);
|
|
1995
2013
|
}
|
|
2014
|
+
const passthroughField = config.passthrough?.[command];
|
|
2015
|
+
if (passthroughField) {
|
|
2016
|
+
collectPassthrough(toolArgs, passthroughField, objectShapeKeys(descriptor.argumentSchema));
|
|
2017
|
+
}
|
|
2018
|
+
return { ok: true, toolArgs, options };
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
// src/tools/cli/run-managed.ts
|
|
2022
|
+
async function runManagedInvocation(session, route) {
|
|
2023
|
+
const { config } = session;
|
|
2024
|
+
const { stdout, stderr, exit } = session.io;
|
|
2025
|
+
const { command, helpRequested, beforeSeparator } = route;
|
|
2026
|
+
const topLevelHelp = route.route.topLevelHelp || command === undefined || command === "help" || command === "--help" || command === "-h" || command.startsWith("--help=") && !isReservedBoolWord(command.slice("--help=".length));
|
|
2027
|
+
const managed = await buildManagedSurface(session, route.typedGlobals, !topLevelHelp && !helpRequested);
|
|
2028
|
+
if (topLevelHelp)
|
|
2029
|
+
return respondTopLevelHelp(session, route, managed);
|
|
1996
2030
|
if (!managed.resolved) {
|
|
1997
|
-
return exit(emitResult(managed.failure, { stdout, stderr },
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2031
|
+
return exit(emitResult(managed.failure, { stdout, stderr }, emitOptionsFor(config, beforeSeparator.includes("--json"), command ?? config.name)));
|
|
2032
|
+
}
|
|
2033
|
+
return runManagedCommand(session, route, command, managed);
|
|
2034
|
+
}
|
|
2035
|
+
function respondTopLevelHelp(session, route, managed) {
|
|
2036
|
+
const { config, applicationOptions } = session;
|
|
2037
|
+
const { stdout, stderr, exit } = session.io;
|
|
2038
|
+
const { command, commandArgv } = route;
|
|
2039
|
+
const helpFilter = route.route.helpFilter ?? (command !== undefined ? commandArgv[0] : undefined);
|
|
2040
|
+
const filter = helpFilter !== undefined && !helpFilter.startsWith("-") ? helpFilter : undefined;
|
|
2041
|
+
if (filter !== undefined && filterCommands(managed.help, filter).size === 0) {
|
|
2042
|
+
stderr(`no command matches "${filter}" (${managed.help.size} available)
|
|
2043
|
+
` + (managed.resolved ? "" : `Managed commands are unavailable: ${managed.reason}
|
|
2044
|
+
`));
|
|
2045
|
+
const codes = { ...DEFAULT_EXIT_CODES, ...config.exitCodes };
|
|
2046
|
+
exit(codes.NOT_FOUND ?? 4);
|
|
2047
|
+
return;
|
|
2003
2048
|
}
|
|
2049
|
+
stdout(renderTopHelp({
|
|
2050
|
+
name: config.name,
|
|
2051
|
+
version: config.version,
|
|
2052
|
+
commands: managed.help,
|
|
2053
|
+
defaultCommand: config.defaultCommand,
|
|
2054
|
+
applicationOptions,
|
|
2055
|
+
...filter !== undefined && { filter },
|
|
2056
|
+
...managed.resolved ? {} : { unavailable: managed.reason }
|
|
2057
|
+
}));
|
|
2058
|
+
exit(0);
|
|
2059
|
+
}
|
|
2060
|
+
async function runManagedCommand(session, route, command, managed) {
|
|
2061
|
+
const { config, applicationOptions } = session;
|
|
2062
|
+
const { stdout, stderr, exit, readStdin } = session.io;
|
|
2004
2063
|
const tool = managed.tools.get(command);
|
|
2005
2064
|
if (!tool) {
|
|
2006
2065
|
stderr(`Unknown command "${command}". Run "${config.name} --help" for the command list.
|
|
@@ -2010,11 +2069,11 @@ async function createCli(config) {
|
|
|
2010
2069
|
const descriptor = managed.help.get(command);
|
|
2011
2070
|
if (!descriptor)
|
|
2012
2071
|
throw new Error("[stitchkit] managed CLI descriptor invariant failed");
|
|
2013
|
-
if (helpRequested) {
|
|
2072
|
+
if (route.helpRequested) {
|
|
2014
2073
|
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
2015
2074
|
return exit(0);
|
|
2016
2075
|
}
|
|
2017
|
-
const prepared = await prepareInvocation(command, commandArgv, descriptor, config, readStdin);
|
|
2076
|
+
const prepared = await prepareInvocation(command, route.commandArgv, descriptor, config, readStdin);
|
|
2018
2077
|
if (!prepared.ok) {
|
|
2019
2078
|
stderr(`${prepared.message}
|
|
2020
2079
|
`);
|
|
@@ -2045,12 +2104,21 @@ async function createCli(config) {
|
|
|
2045
2104
|
`);
|
|
2046
2105
|
return exit(0);
|
|
2047
2106
|
}
|
|
2107
|
+
const result = await executeManagedTool(session, route, command, managed, tool, {
|
|
2108
|
+
toolArgs,
|
|
2109
|
+
options
|
|
2110
|
+
});
|
|
2111
|
+
return emitManagedResult(session, command, result, options);
|
|
2112
|
+
}
|
|
2113
|
+
async function executeManagedTool(session, route, command, managed, tool, { toolArgs, options }) {
|
|
2114
|
+
const { config } = session;
|
|
2115
|
+
const { stderr } = session.io;
|
|
2048
2116
|
const runTool = createToolRunner({
|
|
2049
2117
|
source: "cli",
|
|
2050
|
-
|
|
2118
|
+
toolSurface: true,
|
|
2119
|
+
context: { ...config.context?.(managed.auth, route.typedGlobals), signal: config.signal },
|
|
2051
2120
|
hooks: config.hooks,
|
|
2052
2121
|
lifecycle: config.lifecycle,
|
|
2053
|
-
errorHint: config.errorHint,
|
|
2054
2122
|
coerceJsonArgs: config.coerceJsonArgs
|
|
2055
2123
|
});
|
|
2056
2124
|
let result;
|
|
@@ -2081,6 +2149,12 @@ async function createCli(config) {
|
|
|
2081
2149
|
signal: config.signal
|
|
2082
2150
|
});
|
|
2083
2151
|
}
|
|
2152
|
+
return result;
|
|
2153
|
+
}
|
|
2154
|
+
async function emitManagedResult(session, command, initial, options) {
|
|
2155
|
+
const { config } = session;
|
|
2156
|
+
const { stdout, stderr, exit } = session.io;
|
|
2157
|
+
let result = initial;
|
|
2084
2158
|
let downloadsOk = true;
|
|
2085
2159
|
if (options.outputDir && result.ok && config.download) {
|
|
2086
2160
|
downloadsOk = await downloadResults(config.download(result.data), options.outputDir, stderr, options.quiet, config.allowPrivateDownloadHosts ?? false, config.maxDownloadBytes ?? DEFAULT_DOWNLOAD_MAX_BYTES, config.downloadTimeoutMs);
|
|
@@ -2102,13 +2176,82 @@ async function createCli(config) {
|
|
|
2102
2176
|
}
|
|
2103
2177
|
result = { ...result, data: viewed.data };
|
|
2104
2178
|
}
|
|
2105
|
-
const exitCode = emitResult(result, { stdout, stderr },
|
|
2106
|
-
json: options.json,
|
|
2107
|
-
toolName: command,
|
|
2108
|
-
errorHint: config.errorHint,
|
|
2109
|
-
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
2110
|
-
});
|
|
2179
|
+
const exitCode = emitResult(result, { stdout, stderr }, emitOptionsFor(config, options.json, command));
|
|
2111
2180
|
return exit(downloadsOk ? exitCode : 1);
|
|
2112
2181
|
}
|
|
2113
2182
|
|
|
2114
|
-
|
|
2183
|
+
// src/tools/cli/run-native.ts
|
|
2184
|
+
async function runNativeCommand2(session, route, command, native) {
|
|
2185
|
+
const { config, applicationOptions, nativeHelp } = session;
|
|
2186
|
+
const { stdout, stderr, exit, readStdin } = session.io;
|
|
2187
|
+
const { commandArgv, helpRequested, globals } = route;
|
|
2188
|
+
const descriptor = nativeHelp.get(command);
|
|
2189
|
+
if (!descriptor)
|
|
2190
|
+
throw new Error("[stitchkit] native CLI descriptor invariant failed");
|
|
2191
|
+
if (helpRequested) {
|
|
2192
|
+
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
2193
|
+
return exit(0);
|
|
2194
|
+
}
|
|
2195
|
+
const prepared = await prepareInvocation(command, commandArgv, descriptor, config, readStdin);
|
|
2196
|
+
if (!prepared.ok) {
|
|
2197
|
+
stderr(`${prepared.message}
|
|
2198
|
+
`);
|
|
2199
|
+
return exit(2);
|
|
2200
|
+
}
|
|
2201
|
+
const { toolArgs, options } = prepared;
|
|
2202
|
+
if (options.help) {
|
|
2203
|
+
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
2204
|
+
return exit(0);
|
|
2205
|
+
}
|
|
2206
|
+
if (options.wait) {
|
|
2207
|
+
stderr(`--wait is not configured for native command "${command}"
|
|
2208
|
+
`);
|
|
2209
|
+
return exit(2);
|
|
2210
|
+
}
|
|
2211
|
+
if (options.waitTimeout !== undefined) {
|
|
2212
|
+
stderr(`--wait-timeout requires --wait
|
|
2213
|
+
`);
|
|
2214
|
+
return exit(2);
|
|
2215
|
+
}
|
|
2216
|
+
if (options.outputDir !== undefined) {
|
|
2217
|
+
stderr(`--output-dir is not configured for native commands
|
|
2218
|
+
`);
|
|
2219
|
+
return exit(2);
|
|
2220
|
+
}
|
|
2221
|
+
if (options.dryRun) {
|
|
2222
|
+
stdout(`${JSON.stringify({ command, args: toolArgs }, null, 2)}
|
|
2223
|
+
`);
|
|
2224
|
+
return exit(0);
|
|
2225
|
+
}
|
|
2226
|
+
const result = await executeCliCommand(native, toolArgs, options, { stdout, stderr }, config.coerceJsonArgs ?? true, globals);
|
|
2227
|
+
const emission = prepareCliCommandEmission(native, result, options);
|
|
2228
|
+
let emittedExitCode;
|
|
2229
|
+
if (emission.result.ok && emission.presentation !== undefined) {
|
|
2230
|
+
stdout(emission.presentation);
|
|
2231
|
+
emittedExitCode = 0;
|
|
2232
|
+
} else {
|
|
2233
|
+
emittedExitCode = emitResult(emission.result, { stdout, stderr }, emitOptionsFor(config, options.json, command));
|
|
2234
|
+
}
|
|
2235
|
+
return exit(emission.result.ok ? emission.successExitCode : emittedExitCode);
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// src/tools/cli/create-cli.ts
|
|
2239
|
+
async function createCli(config) {
|
|
2240
|
+
const io = createCliIo(config);
|
|
2241
|
+
const argv = config.argv ?? process.argv.slice(2);
|
|
2242
|
+
if (config.auth !== undefined && config.resolveAuth !== undefined) {
|
|
2243
|
+
throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
|
|
2244
|
+
}
|
|
2245
|
+
const session = createCliSession(config, io);
|
|
2246
|
+
const route = resolveCliRoute(session, argv);
|
|
2247
|
+
if (route === undefined)
|
|
2248
|
+
return;
|
|
2249
|
+
const { command } = route;
|
|
2250
|
+
const native = command === undefined ? undefined : session.nativeCommands.get(command);
|
|
2251
|
+
if (native && command !== undefined) {
|
|
2252
|
+
return runNativeCommand2(session, route, command, native);
|
|
2253
|
+
}
|
|
2254
|
+
return runManagedInvocation(session, route);
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
export { fetchGuarded, PrivateAddressRefusal, fetchPinnedDocument, readCapped, WaitTimeoutError, runWaitOperation, defineCliCommand, DEFAULT_EXIT_CODES, cliExitCode, emitResult, routeCliArgv, CliArgumentError, parseCliArgs, extractCliGlobalOptions, cliInvocationResult, createCliInvoker, renderCliView, pollUntilDone, createCli };
|