stitchkit 0.93.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 +134 -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} +30 -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} +80 -919
- 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-3bmnp41g.js → index-n6hxg8as.js} +507 -419
- 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/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 +30 -4
- 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} +4 -4
- package/dist/tools/cli/command.d.ts.map +1 -0
- package/dist/tools/{cli.d.ts → cli/config.d.ts} +5 -9
- 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} +8 -8
- 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 +214 -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,115 +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 cliCommandReturnsResult(definition) {
|
|
673
|
-
return definition.output !== undefined;
|
|
674
|
-
}
|
|
675
|
-
function cliCommandSuccessExitCode(definition, data) {
|
|
676
|
-
const successExitCode = definition.exitCode?.(data) ?? 0;
|
|
677
|
-
if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
|
|
678
|
-
throw new Error("CLI success exit code must be an integer from 0 to 255");
|
|
679
|
-
}
|
|
680
|
-
return successExitCode;
|
|
681
|
-
}
|
|
682
|
-
function prepareCliCommandEmission(definition, result, options) {
|
|
683
|
-
if (!result.ok || definition.output === undefined) {
|
|
684
|
-
return { result, successExitCode: 0 };
|
|
685
|
-
}
|
|
686
|
-
try {
|
|
687
|
-
const successExitCode = cliCommandSuccessExitCode(definition, result.data);
|
|
688
|
-
const presentation = definition.present?.({ result: result.data, options });
|
|
689
|
-
if (presentation !== undefined && typeof presentation !== "string") {
|
|
690
|
-
throw new Error("CLI result presenter must return a string");
|
|
691
|
-
}
|
|
692
|
-
return { result, presentation, successExitCode };
|
|
693
|
-
} catch (error) {
|
|
694
|
-
return {
|
|
695
|
-
result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
|
|
696
|
-
successExitCode: 0
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
function cliCommandPresentationSchema(definition) {
|
|
701
|
-
return buildToolPresentationSchema({
|
|
702
|
-
inputSchema: definition.input,
|
|
703
|
-
unrepresentable: "any"
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
|
|
707
|
-
let parsed;
|
|
708
|
-
try {
|
|
709
|
-
parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs(rawArgs, definition.input) : rawArgs);
|
|
710
|
-
} catch (error) {
|
|
711
|
-
return toolResultFromError(error);
|
|
712
|
-
}
|
|
713
|
-
if (!parsed.success) {
|
|
714
|
-
return {
|
|
715
|
-
ok: false,
|
|
716
|
-
code: "VALIDATION_ERROR",
|
|
717
|
-
details: { message: `Invalid input: ${formatZodError(parsed.error)}` }
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
try {
|
|
721
|
-
const data = await definition.handler({
|
|
722
|
-
input: parsed.data,
|
|
723
|
-
options,
|
|
724
|
-
globals,
|
|
725
|
-
...writers
|
|
726
|
-
});
|
|
727
|
-
const checked = validateDeclaredOutput(definition.output, data);
|
|
728
|
-
if (!checked.ok) {
|
|
729
|
-
return {
|
|
730
|
-
ok: false,
|
|
731
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
732
|
-
details: { message: checked.message }
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
return { ok: true, data: checked.data };
|
|
736
|
-
} catch (error) {
|
|
737
|
-
return toolResultFromError(error);
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
// src/tools/cli-format.ts
|
|
742
|
-
var DEFAULT_EXIT_CODES = {
|
|
743
|
-
VALIDATION_ERROR: 1,
|
|
744
|
-
BAD_REQUEST: 1,
|
|
745
|
-
UNAUTHORIZED: 2,
|
|
746
|
-
FORBIDDEN: 3,
|
|
747
|
-
NOT_FOUND: 4,
|
|
748
|
-
CONFLICT: 5,
|
|
749
|
-
RATE_LIMITED: 6,
|
|
750
|
-
TIMEOUT: 7,
|
|
751
|
-
WAIT_FAILED: 1,
|
|
752
|
-
INTERNAL_SERVER_ERROR: 1
|
|
753
|
-
};
|
|
754
|
-
function cliExitCode(result, exitCodes) {
|
|
755
|
-
if (result.ok)
|
|
756
|
-
return 0;
|
|
757
|
-
const codes = { ...DEFAULT_EXIT_CODES, ...exitCodes };
|
|
758
|
-
return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
|
|
759
|
-
}
|
|
760
|
-
function emitResult(result, writers, opts) {
|
|
761
|
-
if (result.ok) {
|
|
762
|
-
if (result.data === undefined)
|
|
763
|
-
return 0;
|
|
764
|
-
const text2 = opts.json ? JSON.stringify(result.data) : JSON.stringify(result.data, null, 2);
|
|
765
|
-
writers.stdout(`${text2}
|
|
766
|
-
`);
|
|
767
|
-
return 0;
|
|
768
|
-
}
|
|
769
|
-
const error = formatToolError(result, opts.toolName, opts.errorHint);
|
|
770
|
-
const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
|
|
771
|
-
writers.stderr(`${text}
|
|
772
|
-
`);
|
|
773
|
-
return cliExitCode(result, opts.exitCodes);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// src/tools/cli-policy.ts
|
|
778
|
+
// src/tools/cli/policy.ts
|
|
777
779
|
var SHORT_ALIAS = /^[A-Za-z]$/;
|
|
778
780
|
var RESERVED_SHORT_OPTIONS = new Set(["h"]);
|
|
779
781
|
function fieldMap(descriptor) {
|
|
@@ -853,7 +855,7 @@ function assertCliPoliciesResolved(commands, config) {
|
|
|
853
855
|
}
|
|
854
856
|
}
|
|
855
857
|
|
|
856
|
-
// src/tools/cli
|
|
858
|
+
// src/tools/cli/invoke.ts
|
|
857
859
|
function parseCliGlobals(schema, globals) {
|
|
858
860
|
if (!schema)
|
|
859
861
|
return globals ?? {};
|
|
@@ -892,10 +894,10 @@ async function createCliInvoker(config, globals) {
|
|
|
892
894
|
const { tools, help } = buildCliSurface(config, auth, new Map, new Set);
|
|
893
895
|
const runTool = createToolRunner({
|
|
894
896
|
source: "cli",
|
|
897
|
+
toolSurface: true,
|
|
895
898
|
context: { ...config.context?.(auth, typedGlobals), signal: config.signal },
|
|
896
899
|
hooks: config.hooks,
|
|
897
900
|
lifecycle: config.lifecycle,
|
|
898
|
-
errorHint: config.errorHint,
|
|
899
901
|
coerceJsonArgs: config.coerceJsonArgs
|
|
900
902
|
});
|
|
901
903
|
return {
|
|
@@ -986,7 +988,7 @@ function managedCliDescriptor(tool) {
|
|
|
986
988
|
};
|
|
987
989
|
}
|
|
988
990
|
|
|
989
|
-
// src/tools/cli
|
|
991
|
+
// src/tools/cli/view.ts
|
|
990
992
|
var ABSENT = "(absent)";
|
|
991
993
|
function selectRecords(data) {
|
|
992
994
|
if (Array.isArray(data))
|
|
@@ -1133,7 +1135,7 @@ function renderCliView(data, view) {
|
|
|
1133
1135
|
return { kind: "json", data: ordered(totals, view.top) };
|
|
1134
1136
|
}
|
|
1135
1137
|
|
|
1136
|
-
// src/tools/wait-core.ts
|
|
1138
|
+
// src/tools/operations/wait-core.ts
|
|
1137
1139
|
var DEFAULT_BACKOFF = [2, 3, 5, 5, 8, 10];
|
|
1138
1140
|
var DEFAULT_TIMEOUT = 600;
|
|
1139
1141
|
|
|
@@ -1229,7 +1231,7 @@ function runWaitOperation(params) {
|
|
|
1229
1231
|
});
|
|
1230
1232
|
}
|
|
1231
1233
|
|
|
1232
|
-
// src/tools/cli
|
|
1234
|
+
// src/tools/cli/wait.ts
|
|
1233
1235
|
var DEFAULT_TIMEOUT2 = 600;
|
|
1234
1236
|
function waitFailure(tool, result) {
|
|
1235
1237
|
return {
|
|
@@ -1283,40 +1285,90 @@ async function pollUntilDone(params) {
|
|
|
1283
1285
|
return state;
|
|
1284
1286
|
}
|
|
1285
1287
|
|
|
1286
|
-
// src/tools/cli.ts
|
|
1288
|
+
// src/tools/cli/io.ts
|
|
1287
1289
|
import { writeSync } from "node:fs";
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
// src/internal/secure-fetch.ts
|
|
1291
|
-
import { lookup } from "node:dns/promises";
|
|
1292
|
-
import { request as httpRequest } from "node:http";
|
|
1293
|
-
import { request as httpsRequest } from "node:https";
|
|
1294
|
-
import { isIP } from "node:net";
|
|
1295
|
-
var NUMERIC_HOST = /^(0x[0-9a-f]+|[0-9.]+)$/i;
|
|
1296
|
-
var MAX_REDIRECTS = 5;
|
|
1297
|
-
function assertHttpUrl(url) {
|
|
1298
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
1299
|
-
throw new Error(`refusing to fetch a non-http(s) URL (${url.protocol})`);
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
function mappedIpv4FromIpv6(ip) {
|
|
1303
|
-
const rest = ip.startsWith("::ffff:") ? ip.slice("::ffff:".length) : ip.startsWith("0:0:0:0:0:ffff:") ? ip.slice("0:0:0:0:0:ffff:".length) : null;
|
|
1304
|
-
if (rest === null)
|
|
1305
|
-
return null;
|
|
1306
|
-
if (isIP(rest) === 4)
|
|
1307
|
-
return rest;
|
|
1308
|
-
const [hiRaw, loRaw, extra] = rest.split(":");
|
|
1309
|
-
if (hiRaw === undefined || loRaw === undefined || extra !== undefined)
|
|
1310
|
-
return null;
|
|
1311
|
-
if (!/^[0-9a-f]{1,4}$/i.test(hiRaw) || !/^[0-9a-f]{1,4}$/i.test(loRaw))
|
|
1290
|
+
async function readPipedStdin() {
|
|
1291
|
+
if (process.stdin.isTTY)
|
|
1312
1292
|
return null;
|
|
1313
|
-
const
|
|
1314
|
-
const
|
|
1315
|
-
|
|
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;
|
|
1316
1299
|
}
|
|
1317
|
-
function
|
|
1318
|
-
|
|
1319
|
-
|
|
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
|
|
1340
|
+
import { basename, resolve } from "node:path";
|
|
1341
|
+
|
|
1342
|
+
// src/internal/secure-fetch.ts
|
|
1343
|
+
import { lookup } from "node:dns/promises";
|
|
1344
|
+
import { request as httpRequest } from "node:http";
|
|
1345
|
+
import { request as httpsRequest } from "node:https";
|
|
1346
|
+
import { isIP } from "node:net";
|
|
1347
|
+
var NUMERIC_HOST = /^(0x[0-9a-f]+|[0-9.]+)$/i;
|
|
1348
|
+
var MAX_REDIRECTS = 5;
|
|
1349
|
+
function assertHttpUrl(url) {
|
|
1350
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
1351
|
+
throw new Error(`refusing to fetch a non-http(s) URL (${url.protocol})`);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
function mappedIpv4FromIpv6(ip) {
|
|
1355
|
+
const rest = ip.startsWith("::ffff:") ? ip.slice("::ffff:".length) : ip.startsWith("0:0:0:0:0:ffff:") ? ip.slice("0:0:0:0:0:ffff:".length) : null;
|
|
1356
|
+
if (rest === null)
|
|
1357
|
+
return null;
|
|
1358
|
+
if (isIP(rest) === 4)
|
|
1359
|
+
return rest;
|
|
1360
|
+
const [hiRaw, loRaw, extra] = rest.split(":");
|
|
1361
|
+
if (hiRaw === undefined || loRaw === undefined || extra !== undefined)
|
|
1362
|
+
return null;
|
|
1363
|
+
if (!/^[0-9a-f]{1,4}$/i.test(hiRaw) || !/^[0-9a-f]{1,4}$/i.test(loRaw))
|
|
1364
|
+
return null;
|
|
1365
|
+
const hi = Number.parseInt(hiRaw, 16);
|
|
1366
|
+
const lo = Number.parseInt(loRaw, 16);
|
|
1367
|
+
return [hi >> 8, hi & 255, lo >> 8, lo & 255].join(".");
|
|
1368
|
+
}
|
|
1369
|
+
function ipv6Words(ip) {
|
|
1370
|
+
const halves = ip.toLowerCase().split("::");
|
|
1371
|
+
if (halves.length > 2)
|
|
1320
1372
|
return null;
|
|
1321
1373
|
const head = halves[0] ? halves[0].split(":") : [];
|
|
1322
1374
|
const tail = halves[1] ? halves[1].split(":") : [];
|
|
@@ -1597,7 +1649,34 @@ async function writeDownload(root, target, data) {
|
|
|
1597
1649
|
await writeFile(target, data);
|
|
1598
1650
|
}
|
|
1599
1651
|
|
|
1600
|
-
// 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
|
|
1601
1680
|
var GLOBAL_OPTIONS = [
|
|
1602
1681
|
["--json", "Emit compact success/error JSON records (for scripts)"],
|
|
1603
1682
|
["--wait", "Block-poll an async result to a terminal state"],
|
|
@@ -1614,16 +1693,6 @@ var GLOBAL_OPTIONS = [
|
|
|
1614
1693
|
["--top <n>", "Keep the n leading entries of the view asked for"],
|
|
1615
1694
|
["--table <a,b>", "Render the named fields as an aligned table"]
|
|
1616
1695
|
];
|
|
1617
|
-
async function readPipedStdin() {
|
|
1618
|
-
if (process.stdin.isTTY)
|
|
1619
|
-
return null;
|
|
1620
|
-
const chunks = [];
|
|
1621
|
-
for await (const chunk of process.stdin) {
|
|
1622
|
-
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
1623
|
-
}
|
|
1624
|
-
const text = Buffer.concat(chunks).toString("utf8").trim();
|
|
1625
|
-
return text.length > 0 ? text : null;
|
|
1626
|
-
}
|
|
1627
1696
|
function typeLabel(schema) {
|
|
1628
1697
|
if (Array.isArray(schema.enum))
|
|
1629
1698
|
return schema.enum.join("|");
|
|
@@ -1643,44 +1712,6 @@ function summarize(desc) {
|
|
|
1643
1712
|
const max = 72;
|
|
1644
1713
|
return firstSentence.length > max ? `${firstSentence.slice(0, max - 1).trimEnd()}…` : firstSentence;
|
|
1645
1714
|
}
|
|
1646
|
-
function looseCoerceValue(value) {
|
|
1647
|
-
if (Array.isArray(value))
|
|
1648
|
-
return value.map(looseCoerceValue);
|
|
1649
|
-
if (typeof value !== "string")
|
|
1650
|
-
return value;
|
|
1651
|
-
if (value === "true")
|
|
1652
|
-
return true;
|
|
1653
|
-
if (value === "false")
|
|
1654
|
-
return false;
|
|
1655
|
-
const n = Number(value);
|
|
1656
|
-
return value.trim() !== "" && !Number.isNaN(n) ? n : value;
|
|
1657
|
-
}
|
|
1658
|
-
function passthroughBase(value) {
|
|
1659
|
-
if (isRecord(value))
|
|
1660
|
-
return value;
|
|
1661
|
-
if (typeof value === "string") {
|
|
1662
|
-
try {
|
|
1663
|
-
const parsed = safeJsonParse(value);
|
|
1664
|
-
if (isRecord(parsed))
|
|
1665
|
-
return parsed;
|
|
1666
|
-
} catch {}
|
|
1667
|
-
}
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
function collectPassthrough(toolArgs, field, knownKeys) {
|
|
1671
|
-
const known = new Set(knownKeys);
|
|
1672
|
-
const bag = {};
|
|
1673
|
-
for (const key of Object.keys(toolArgs)) {
|
|
1674
|
-
if (key === field || known.has(key))
|
|
1675
|
-
continue;
|
|
1676
|
-
bag[key] = looseCoerceValue(toolArgs[key]);
|
|
1677
|
-
delete toolArgs[key];
|
|
1678
|
-
}
|
|
1679
|
-
if (Object.keys(bag).length === 0)
|
|
1680
|
-
return;
|
|
1681
|
-
const base = passthroughBase(toolArgs[field]);
|
|
1682
|
-
toolArgs[field] = base ? { ...base, ...bag } : bag;
|
|
1683
|
-
}
|
|
1684
1715
|
function applicationOptionLines(fields) {
|
|
1685
1716
|
if (fields.length === 0)
|
|
1686
1717
|
return [];
|
|
@@ -1775,6 +1806,8 @@ function renderCommandHelp(name, command, descriptor, applicationOptions = []) {
|
|
|
1775
1806
|
`)}
|
|
1776
1807
|
`;
|
|
1777
1808
|
}
|
|
1809
|
+
|
|
1810
|
+
// src/tools/cli/session.ts
|
|
1778
1811
|
function nativeDescriptor(definition) {
|
|
1779
1812
|
return {
|
|
1780
1813
|
description: definition.description,
|
|
@@ -1800,101 +1833,7 @@ function assertCommandShape(name, descriptor, exists, passthroughField, applicat
|
|
|
1800
1833
|
throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
|
|
1801
1834
|
}
|
|
1802
1835
|
}
|
|
1803
|
-
|
|
1804
|
-
let parsed;
|
|
1805
|
-
try {
|
|
1806
|
-
parsed = parseCliArgs(commandArgv, descriptor.argumentSchema, {
|
|
1807
|
-
allowUnknown: config.passthrough?.[command] !== undefined,
|
|
1808
|
-
knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
|
|
1809
|
-
optionAliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
|
|
1810
|
-
positionals: descriptor.positionals
|
|
1811
|
-
});
|
|
1812
|
-
} catch (error) {
|
|
1813
|
-
if (!(error instanceof CliArgumentError))
|
|
1814
|
-
throw error;
|
|
1815
|
-
return { ok: false, message: error.message };
|
|
1816
|
-
}
|
|
1817
|
-
const { toolArgs, options } = parsed;
|
|
1818
|
-
const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
|
|
1819
|
-
if (firstUnset) {
|
|
1820
|
-
const piped = await readStdin();
|
|
1821
|
-
if (piped !== null) {
|
|
1822
|
-
if (descriptor.positionals === undefined) {
|
|
1823
|
-
toolArgs[firstUnset.name] = piped;
|
|
1824
|
-
} else {
|
|
1825
|
-
const stdinArgs = parseCliArgs([`--${firstUnset.name}`, piped], descriptor.argumentSchema);
|
|
1826
|
-
toolArgs[firstUnset.name] = stdinArgs.toolArgs[firstUnset.name];
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
const passthroughField = config.passthrough?.[command];
|
|
1831
|
-
if (passthroughField) {
|
|
1832
|
-
collectPassthrough(toolArgs, passthroughField, objectShapeKeys(descriptor.argumentSchema));
|
|
1833
|
-
}
|
|
1834
|
-
return { ok: true, toolArgs, options };
|
|
1835
|
-
}
|
|
1836
|
-
var DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
|
|
1837
|
-
async function downloadResults(files, dir, stderr, quiet, allowPrivate, maxBytes, timeoutMs) {
|
|
1838
|
-
const root = resolve(dir);
|
|
1839
|
-
let succeeded = true;
|
|
1840
|
-
for (const file of files) {
|
|
1841
|
-
try {
|
|
1842
|
-
const res = await fetchGuarded(new URL(file.url), allowPrivate, { timeoutMs });
|
|
1843
|
-
if (!res.ok)
|
|
1844
|
-
throw new Error(`HTTP ${res.status}`);
|
|
1845
|
-
const buffer = await readCapped(res, maxBytes);
|
|
1846
|
-
if (!buffer)
|
|
1847
|
-
throw new Error(`file exceeds the ${maxBytes}-byte cap`);
|
|
1848
|
-
const target = resolve(root, basename(file.name));
|
|
1849
|
-
await writeDownload(root, target, buffer);
|
|
1850
|
-
if (!quiet)
|
|
1851
|
-
stderr(`saved ${target} (${(buffer.length / 1024).toFixed(0)}KB)
|
|
1852
|
-
`);
|
|
1853
|
-
} catch (err) {
|
|
1854
|
-
succeeded = false;
|
|
1855
|
-
stderr(`failed to download ${file.url}: ${err instanceof Error ? err.message : String(err)}
|
|
1856
|
-
`);
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
return succeeded;
|
|
1860
|
-
}
|
|
1861
|
-
async function createCli(config) {
|
|
1862
|
-
let pendingWrite;
|
|
1863
|
-
let writeFailed = false;
|
|
1864
|
-
const writeFd = (fd, text) => {
|
|
1865
|
-
const bytes = Buffer.from(text, "utf8");
|
|
1866
|
-
let offset = 0;
|
|
1867
|
-
while (offset < bytes.length) {
|
|
1868
|
-
try {
|
|
1869
|
-
offset += writeSync(fd, bytes, offset, bytes.length - offset);
|
|
1870
|
-
} catch (error) {
|
|
1871
|
-
if (isRecord(error) && error.code === "EAGAIN") {
|
|
1872
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1);
|
|
1873
|
-
continue;
|
|
1874
|
-
}
|
|
1875
|
-
const stream = fd === 1 ? process.stdout : process.stderr;
|
|
1876
|
-
const rest = bytes.subarray(offset);
|
|
1877
|
-
pendingWrite = new Promise((resolve2) => {
|
|
1878
|
-
stream.write(rest, (failure) => {
|
|
1879
|
-
if (failure)
|
|
1880
|
-
writeFailed = true;
|
|
1881
|
-
resolve2();
|
|
1882
|
-
});
|
|
1883
|
-
});
|
|
1884
|
-
return;
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
};
|
|
1888
|
-
const stdout = config.stdout ?? ((text) => writeFd(1, text));
|
|
1889
|
-
const stderr = config.stderr ?? ((text) => writeFd(2, text));
|
|
1890
|
-
const exit = config.exit ?? ((code) => {
|
|
1891
|
-
if (pendingWrite === undefined)
|
|
1892
|
-
process.exit(code);
|
|
1893
|
-
else
|
|
1894
|
-
pendingWrite.then(() => process.exit(writeFailed ? 1 : code));
|
|
1895
|
-
});
|
|
1896
|
-
const argv = config.argv ?? process.argv.slice(2);
|
|
1897
|
-
const readStdin = config.stdin ?? readPipedStdin;
|
|
1836
|
+
function createCliSession(config, io) {
|
|
1898
1837
|
if (config.auth !== undefined && config.resolveAuth !== undefined) {
|
|
1899
1838
|
throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
|
|
1900
1839
|
}
|
|
@@ -1911,11 +1850,23 @@ async function createCli(config) {
|
|
|
1911
1850
|
const nativeCommands = new Map;
|
|
1912
1851
|
const nativeHelp = new Map;
|
|
1913
1852
|
for (const definition of config.commands ?? []) {
|
|
1914
|
-
const
|
|
1915
|
-
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);
|
|
1916
1855
|
nativeCommands.set(definition.name, definition);
|
|
1917
|
-
nativeHelp.set(definition.name,
|
|
1856
|
+
nativeHelp.set(definition.name, descriptor);
|
|
1918
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;
|
|
1919
1870
|
let globals;
|
|
1920
1871
|
let routableArgv;
|
|
1921
1872
|
try {
|
|
@@ -1927,135 +1878,188 @@ async function createCli(config) {
|
|
|
1927
1878
|
throw error;
|
|
1928
1879
|
stderr(`${error.message}
|
|
1929
1880
|
`);
|
|
1930
|
-
|
|
1881
|
+
exit(2);
|
|
1882
|
+
return;
|
|
1931
1883
|
}
|
|
1932
1884
|
const typedGlobals = globals;
|
|
1933
1885
|
const route = routeCliArgv(routableArgv, config.defaultCommand);
|
|
1934
1886
|
if (route.error) {
|
|
1935
1887
|
stderr(`${route.error}
|
|
1936
1888
|
`);
|
|
1937
|
-
|
|
1889
|
+
exit(2);
|
|
1890
|
+
return;
|
|
1938
1891
|
}
|
|
1939
1892
|
const { command, commandArgv } = route;
|
|
1940
1893
|
if (route.version || command === "--version" || command === "version") {
|
|
1941
1894
|
stdout(`${config.name} ${config.version}
|
|
1942
1895
|
`);
|
|
1943
|
-
|
|
1896
|
+
exit(0);
|
|
1897
|
+
return;
|
|
1944
1898
|
}
|
|
1945
1899
|
const beforeSeparator = commandArgv.indexOf("--") === -1 ? commandArgv : commandArgv.slice(0, commandArgv.indexOf("--"));
|
|
1946
1900
|
const helpRequested = beforeSeparator.includes("--help") || beforeSeparator.includes("-h");
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
`);
|
|
1970
|
-
return exit(2);
|
|
1971
|
-
}
|
|
1972
|
-
if (options2.waitTimeout !== undefined) {
|
|
1973
|
-
stderr(`--wait-timeout requires --wait
|
|
1974
|
-
`);
|
|
1975
|
-
return exit(2);
|
|
1976
|
-
}
|
|
1977
|
-
if (options2.outputDir !== undefined) {
|
|
1978
|
-
stderr(`--output-dir is not configured for native commands
|
|
1979
|
-
`);
|
|
1980
|
-
return exit(2);
|
|
1981
|
-
}
|
|
1982
|
-
if (options2.dryRun) {
|
|
1983
|
-
stdout(`${JSON.stringify({ command, args: toolArgs2 }, null, 2)}
|
|
1984
|
-
`);
|
|
1985
|
-
return exit(0);
|
|
1986
|
-
}
|
|
1987
|
-
const result2 = await executeCliCommand(native, toolArgs2, options2, { stdout, stderr }, config.coerceJsonArgs ?? true, globals);
|
|
1988
|
-
const emission = prepareCliCommandEmission(native, result2, options2);
|
|
1989
|
-
let emittedExitCode;
|
|
1990
|
-
if (emission.result.ok && emission.presentation !== undefined) {
|
|
1991
|
-
stdout(emission.presentation);
|
|
1992
|
-
emittedExitCode = 0;
|
|
1993
|
-
} else {
|
|
1994
|
-
emittedExitCode = emitResult(emission.result, { stdout, stderr }, {
|
|
1995
|
-
json: options2.json,
|
|
1996
|
-
toolName: command,
|
|
1997
|
-
errorHint: config.errorHint,
|
|
1998
|
-
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
return exit(emission.result.ok ? emission.successExitCode : emittedExitCode);
|
|
2002
|
-
}
|
|
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;
|
|
2003
1923
|
let authPromise;
|
|
2004
1924
|
const resolveIdentity = () => {
|
|
2005
1925
|
authPromise ??= (async () => config.resolveAuth ? await config.resolveAuth(typedGlobals) : await config.auth)();
|
|
2006
1926
|
return authPromise;
|
|
2007
1927
|
};
|
|
2008
1928
|
const dynamicSurface = typeof config.services === "function" || typeof config.runtimeTools === "function";
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
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];
|
|
2023
2011
|
}
|
|
2024
2012
|
}
|
|
2025
|
-
const { tools, help } = buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertCommandShape);
|
|
2026
|
-
return { resolved: true, auth, help, tools };
|
|
2027
|
-
};
|
|
2028
|
-
const topLevelHelp = route.topLevelHelp || command === undefined || command === "help" || command === "--help" || command === "-h" || command.startsWith("--help=") && !isReservedBoolWord(command.slice("--help=".length));
|
|
2029
|
-
const managed = await buildManagedSurface(!topLevelHelp && !helpRequested);
|
|
2030
|
-
if (topLevelHelp) {
|
|
2031
|
-
const helpFilter = route.helpFilter ?? (command !== undefined ? commandArgv[0] : undefined);
|
|
2032
|
-
const filter = helpFilter !== undefined && !helpFilter.startsWith("-") ? helpFilter : undefined;
|
|
2033
|
-
if (filter !== undefined && filterCommands(managed.help, filter).size === 0) {
|
|
2034
|
-
stderr(`no command matches "${filter}" (${managed.help.size} available)
|
|
2035
|
-
` + (managed.resolved ? "" : `Managed commands are unavailable: ${managed.reason}
|
|
2036
|
-
`));
|
|
2037
|
-
const codes = { ...DEFAULT_EXIT_CODES, ...config.exitCodes };
|
|
2038
|
-
return exit(codes.NOT_FOUND ?? 4);
|
|
2039
|
-
}
|
|
2040
|
-
stdout(renderTopHelp({
|
|
2041
|
-
name: config.name,
|
|
2042
|
-
version: config.version,
|
|
2043
|
-
commands: managed.help,
|
|
2044
|
-
defaultCommand: config.defaultCommand,
|
|
2045
|
-
applicationOptions,
|
|
2046
|
-
...filter !== undefined && { filter },
|
|
2047
|
-
...managed.resolved ? {} : { unavailable: managed.reason }
|
|
2048
|
-
}));
|
|
2049
|
-
return exit(0);
|
|
2050
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);
|
|
2051
2030
|
if (!managed.resolved) {
|
|
2052
|
-
return exit(emitResult(managed.failure, { stdout, stderr },
|
|
2053
|
-
json: beforeSeparator.includes("--json"),
|
|
2054
|
-
toolName: command ?? config.name,
|
|
2055
|
-
errorHint: config.errorHint,
|
|
2056
|
-
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
2057
|
-
}));
|
|
2031
|
+
return exit(emitResult(managed.failure, { stdout, stderr }, emitOptionsFor(config, beforeSeparator.includes("--json"), command ?? config.name)));
|
|
2058
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;
|
|
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;
|
|
2059
2063
|
const tool = managed.tools.get(command);
|
|
2060
2064
|
if (!tool) {
|
|
2061
2065
|
stderr(`Unknown command "${command}". Run "${config.name} --help" for the command list.
|
|
@@ -2065,11 +2069,11 @@ async function createCli(config) {
|
|
|
2065
2069
|
const descriptor = managed.help.get(command);
|
|
2066
2070
|
if (!descriptor)
|
|
2067
2071
|
throw new Error("[stitchkit] managed CLI descriptor invariant failed");
|
|
2068
|
-
if (helpRequested) {
|
|
2072
|
+
if (route.helpRequested) {
|
|
2069
2073
|
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
2070
2074
|
return exit(0);
|
|
2071
2075
|
}
|
|
2072
|
-
const prepared = await prepareInvocation(command, commandArgv, descriptor, config, readStdin);
|
|
2076
|
+
const prepared = await prepareInvocation(command, route.commandArgv, descriptor, config, readStdin);
|
|
2073
2077
|
if (!prepared.ok) {
|
|
2074
2078
|
stderr(`${prepared.message}
|
|
2075
2079
|
`);
|
|
@@ -2100,12 +2104,21 @@ async function createCli(config) {
|
|
|
2100
2104
|
`);
|
|
2101
2105
|
return exit(0);
|
|
2102
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;
|
|
2103
2116
|
const runTool = createToolRunner({
|
|
2104
2117
|
source: "cli",
|
|
2105
|
-
|
|
2118
|
+
toolSurface: true,
|
|
2119
|
+
context: { ...config.context?.(managed.auth, route.typedGlobals), signal: config.signal },
|
|
2106
2120
|
hooks: config.hooks,
|
|
2107
2121
|
lifecycle: config.lifecycle,
|
|
2108
|
-
errorHint: config.errorHint,
|
|
2109
2122
|
coerceJsonArgs: config.coerceJsonArgs
|
|
2110
2123
|
});
|
|
2111
2124
|
let result;
|
|
@@ -2136,6 +2149,12 @@ async function createCli(config) {
|
|
|
2136
2149
|
signal: config.signal
|
|
2137
2150
|
});
|
|
2138
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;
|
|
2139
2158
|
let downloadsOk = true;
|
|
2140
2159
|
if (options.outputDir && result.ok && config.download) {
|
|
2141
2160
|
downloadsOk = await downloadResults(config.download(result.data), options.outputDir, stderr, options.quiet, config.allowPrivateDownloadHosts ?? false, config.maxDownloadBytes ?? DEFAULT_DOWNLOAD_MAX_BYTES, config.downloadTimeoutMs);
|
|
@@ -2157,13 +2176,82 @@ async function createCli(config) {
|
|
|
2157
2176
|
}
|
|
2158
2177
|
result = { ...result, data: viewed.data };
|
|
2159
2178
|
}
|
|
2160
|
-
const exitCode = emitResult(result, { stdout, stderr },
|
|
2161
|
-
json: options.json,
|
|
2162
|
-
toolName: command,
|
|
2163
|
-
errorHint: config.errorHint,
|
|
2164
|
-
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
2165
|
-
});
|
|
2179
|
+
const exitCode = emitResult(result, { stdout, stderr }, emitOptionsFor(config, options.json, command));
|
|
2166
2180
|
return exit(downloadsOk ? exitCode : 1);
|
|
2167
2181
|
}
|
|
2168
2182
|
|
|
2169
|
-
|
|
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 };
|