stitchkit 0.126.0 → 0.128.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 +1767 -0
- package/README.md +12 -4
- package/dist/agent-executor/acp/scenarios.d.ts +4 -0
- package/dist/agent-executor/acp/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +97 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-driver.d.ts +37 -0
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +41 -0
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +270 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts +30 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-turn.d.ts +25 -0
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -0
- package/dist/agent-executor/claude/classify.d.ts +54 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -0
- package/dist/agent-executor/claude/cli-driver.d.ts +31 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +8 -0
- package/dist/agent-executor/claude/limits.d.ts.map +1 -0
- package/dist/agent-executor/claude/protocol.d.ts +206 -0
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -0
- package/dist/agent-executor/claude/scenarios.d.ts +4 -0
- package/dist/agent-executor/claude/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/claude/session.d.ts +23 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -0
- package/dist/agent-executor/claude/transcript.d.ts +36 -0
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +35 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts +10 -0
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +28 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +27 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts +4 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -0
- package/dist/agent-executor/codex/protocol.d.ts +176 -0
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -0
- package/dist/agent-executor/codex/scenarios.d.ts +4 -0
- package/dist/agent-executor/codex/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +43 -0
- package/dist/agent-executor/codex/session.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +454 -0
- package/dist/agent-executor/contract.d.ts.map +1 -0
- package/dist/agent-executor/dispatch.d.ts +41 -0
- package/dist/agent-executor/dispatch.d.ts.map +1 -0
- package/dist/agent-executor/engine-process.d.ts +45 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -0
- package/dist/agent-executor/engine-requests.d.ts +63 -0
- package/dist/agent-executor/engine-requests.d.ts.map +1 -0
- package/dist/agent-executor/engine.d.ts +64 -0
- package/dist/agent-executor/engine.d.ts.map +1 -0
- package/dist/agent-executor/executor-contract.d.ts +387 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -0
- package/dist/agent-executor/executor-machine.d.ts +50 -0
- package/dist/agent-executor/executor-machine.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +235 -0
- package/dist/agent-executor/hello.d.ts.map +1 -0
- package/dist/agent-executor/image-input.d.ts +71 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -0
- package/dist/agent-executor/json-rpc-peer.d.ts +48 -0
- package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -0
- package/dist/agent-executor/leases.d.ts +159 -0
- package/dist/agent-executor/leases.d.ts.map +1 -0
- package/dist/agent-executor/plan-limits.d.ts +25 -0
- package/dist/agent-executor/plan-limits.d.ts.map +1 -0
- package/dist/agent-executor/profile.d.ts +52 -0
- package/dist/agent-executor/profile.d.ts.map +1 -0
- package/dist/agent-executor/projection.d.ts +14 -0
- package/dist/agent-executor/projection.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +69 -0
- package/dist/agent-executor/session-primitives.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance.d.ts +55 -0
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts +18 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-engine.d.ts +52 -0
- package/dist/agent-executor/testing/fake-engine.d.ts.map +1 -0
- package/dist/agent-executor/turn-phases.d.ts +10 -0
- package/dist/agent-executor/turn-phases.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +353 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +160 -0
- package/dist/agent-parts/parts.d.ts.map +1 -0
- package/dist/agent-runtime/agent-tool.d.ts +22 -8
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/archive-projection.d.ts +5 -0
- package/dist/agent-runtime/archive-projection.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +60 -2
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-events.d.ts +7 -0
- package/dist/agent-runtime/branch-events.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +43 -6
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +11 -29
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +153 -30
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +43 -56
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-refusal.d.ts +60 -0
- package/dist/agent-runtime/branch-refusal.d.ts.map +1 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts +14 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts.map +1 -0
- package/dist/agent-runtime/branch-source.d.ts +19 -2
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/branch-transitions.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +2 -2
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-blocking.d.ts +17 -6
- package/dist/agent-runtime/child-blocking.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +4 -9
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +82 -7
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/children-contract.d.ts +84 -3
- package/dist/agent-runtime/children-contract.d.ts.map +1 -1
- package/dist/agent-runtime/children-control.d.ts +23 -2
- package/dist/agent-runtime/children-control.d.ts.map +1 -1
- package/dist/agent-runtime/children-spawn.d.ts +9 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -1
- package/dist/agent-runtime/children-state.d.ts +121 -19
- package/dist/agent-runtime/children-state.d.ts.map +1 -1
- package/dist/agent-runtime/children-usage.d.ts +10 -1
- package/dist/agent-runtime/children-usage.d.ts.map +1 -1
- package/dist/agent-runtime/children.d.ts +3 -3
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/{sandbox-coding.d.ts → coding-sandbox.d.ts} +2 -9
- package/dist/agent-runtime/coding-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime/coding-shell-process.d.ts +2 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +32 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/companion-host.d.ts +38 -0
- package/dist/agent-runtime/companion-host.d.ts.map +1 -0
- package/dist/agent-runtime/context-issue.d.ts +5 -0
- package/dist/agent-runtime/context-issue.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +2 -2
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/coordinator.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +17 -5
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +2 -0
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-durability.d.ts +8 -0
- package/dist/agent-runtime/event-durability.d.ts.map +1 -0
- package/dist/agent-runtime/event-schema.d.ts +13 -5
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-postgres.d.ts +38 -0
- package/dist/agent-runtime/event-search-postgres.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-terms.d.ts +37 -0
- package/dist/agent-runtime/event-search-terms.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-tools.d.ts +141 -4
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search.d.ts +16 -3
- package/dist/agent-runtime/event-search.d.ts.map +1 -1
- package/dist/agent-runtime/fault-bench.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +8 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts +0 -2
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +12 -0
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts +6 -3
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +70 -5
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-spend.d.ts +9 -0
- package/dist/agent-runtime/invocation-spend.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts +20 -9
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +2 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +42 -4
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-admission.d.ts +81 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +83 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-models.d.ts +66 -0
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-options.d.ts +106 -0
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-route.d.ts +50 -0
- package/dist/agent-runtime/openrouter-route.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-spend.d.ts +24 -0
- package/dist/agent-runtime/openrouter-spend.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +23 -2
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/postgres-schema.d.ts +34 -0
- package/dist/agent-runtime/postgres-schema.d.ts.map +1 -0
- package/dist/agent-runtime/postgres-transactions.d.ts +54 -0
- package/dist/agent-runtime/postgres-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/postgres.d.ts +72 -0
- package/dist/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +57 -17
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/provider-journal.d.ts +57 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/purge.d.ts.map +1 -1
- package/dist/agent-runtime/retry-policy.d.ts +6 -0
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution-state.d.ts +26 -2
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +2 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +72 -0
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +319 -0
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +2 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/{tool-progress.d.ts → run-tool-progress.d.ts} +1 -1
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +3 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-admission-gate.d.ts +0 -14
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +6 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +31 -2
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-binding.d.ts +10 -0
- package/dist/agent-runtime/sandbox-binding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox.d.ts +5 -0
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-contract.d.ts +3 -2
- package/dist/agent-runtime/schedule-contract.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-dispatch.d.ts +3 -2
- package/dist/agent-runtime/schedule-dispatch.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +6 -6
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +49 -8
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schedules.d.ts +13 -3
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-invocation-payload.d.ts +48 -0
- package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-message.d.ts +118 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-provider.d.ts +8 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-records.d.ts +5 -0
- package/dist/agent-runtime/schemas-records.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-run.d.ts +487 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +129 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -0
- package/dist/agent-runtime/schemas.d.ts +11 -886
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/spill.d.ts +9 -7
- package/dist/agent-runtime/spill.d.ts.map +1 -1
- package/dist/agent-runtime/sql-events.d.ts +6 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -0
- package/dist/agent-runtime/sql-history.d.ts +8 -0
- package/dist/agent-runtime/sql-history.d.ts.map +1 -0
- package/dist/agent-runtime/sql-ledger.d.ts +5 -0
- package/dist/agent-runtime/sql-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sql-purge.d.ts +13 -0
- package/dist/agent-runtime/sql-purge.d.ts.map +1 -0
- package/dist/agent-runtime/sql-reads.d.ts +16 -0
- package/dist/agent-runtime/sql-reads.d.ts.map +1 -0
- package/dist/agent-runtime/{sqlite-rows.d.ts → sql-rows.d.ts} +24 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sql-session.d.ts +82 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-bun.d.ts +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts +2 -3
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts +10 -6
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts +10 -29
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +63 -4
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts +6 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-capabilities.d.ts +42 -0
- package/dist/agent-runtime/store-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts +5 -2
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-capabilities.d.ts +6 -0
- package/dist/agent-runtime/store-conformance-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-seed.d.ts +8 -0
- package/dist/agent-runtime/store-conformance-seed.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/store-conformance.d.ts +31 -8
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +27 -8
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-event-once.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +114 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-archive.d.ts +2 -0
- package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +2 -2
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +2 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
- package/dist/agent-runtime/store-replay.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +22 -2
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/application/admission-run.d.ts.map +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/change-subscription.d.ts.map +1 -1
- package/dist/application/decisions.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock-format.d.ts +9 -0
- package/dist/application/diagnostic-journal-lock-format.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/directory-inbox-delivery.d.ts.map +1 -1
- package/dist/application/grammy-update-admission.d.ts.map +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts.map +1 -1
- package/dist/application/kernel-contract.d.ts.map +1 -1
- package/dist/application/kernel-restart.d.ts.map +1 -1
- package/dist/application/kernel-rollback.d.ts.map +1 -1
- package/dist/application/kernel-shutdown.d.ts.map +1 -1
- package/dist/application/kernel-state.d.ts.map +1 -1
- package/dist/application/notification-outbox-state.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/revision-signal.d.ts.map +1 -1
- package/dist/application/schedule-run.d.ts.map +1 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/sqlite-migrations.d.ts +104 -0
- package/dist/application/sqlite-migrations.d.ts.map +1 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/browser/bridge-errors.d.ts +24 -0
- package/dist/browser/bridge-errors.d.ts.map +1 -0
- package/dist/browser/bridge-fetch.d.ts +30 -0
- package/dist/browser/bridge-fetch.d.ts.map +1 -0
- package/dist/browser/bridge-inbound.d.ts +28 -0
- package/dist/browser/bridge-inbound.d.ts.map +1 -0
- package/dist/browser/cancellation.d.ts +10 -2
- package/dist/browser/cancellation.d.ts.map +1 -1
- package/dist/browser/chunked-upload.d.ts +1 -1
- package/dist/browser/chunked-upload.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.d.ts +31 -0
- package/dist/browser/client-call-arguments.d.ts.map +1 -0
- package/dist/browser/client-executors.d.ts +6 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client.d.ts +9 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +17 -2
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +0 -5
- package/dist/browser/realtime-client.d.ts.map +1 -1
- package/dist/browser/session-credentials-storage.d.ts +48 -0
- package/dist/browser/session-credentials-storage.d.ts.map +1 -0
- package/dist/browser/session-credentials.d.ts +26 -5
- package/dist/browser/session-credentials.d.ts.map +1 -1
- package/dist/browser/session-refresh-policy.d.ts +124 -0
- package/dist/browser/session-refresh-policy.d.ts.map +1 -0
- package/dist/browser/session-refresh-timer.d.ts +30 -0
- package/dist/browser/session-refresh-timer.d.ts.map +1 -0
- package/dist/browser/session.d.ts.map +1 -1
- package/dist/browser/socket-io-connection.d.ts.map +1 -1
- package/dist/browser/socket-io-explicit-peer.d.ts +0 -1
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +1 -1
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/browser/upload-progress.d.ts +3 -0
- package/dist/browser/upload-progress.d.ts.map +1 -1
- package/dist/contract/bridge-envelope.d.ts +155 -0
- package/dist/contract/bridge-envelope.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +2 -0
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -0
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -4
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +3 -1
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/operation-effect.d.ts +29 -0
- package/dist/contract/operation-effect.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +2 -0
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/contract/tool-options.d.ts +7 -0
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/declaration/command.d.ts +26 -0
- package/dist/declaration/command.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts +10 -25
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/declaration/machine-names.d.ts +11 -0
- package/dist/declaration/machine-names.d.ts.map +1 -0
- package/dist/durability/effect.d.ts.map +1 -1
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +5 -8
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +0 -5
- package/dist/durability/parks.d.ts.map +1 -1
- package/dist/durability/scheduler.d.ts +5 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -0
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.js +921 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +2 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude-sdk.js +325 -0
- package/dist/entrypoints/agent-executor/claude.d.ts +5 -0
- package/dist/entrypoints/agent-executor/claude.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude.js +422 -0
- package/dist/entrypoints/agent-executor/codex.d.ts +4 -0
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/codex.js +858 -0
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/testing.js +375 -0
- package/dist/entrypoints/agent-executor.d.ts +15 -0
- package/dist/entrypoints/agent-executor.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor.js +455 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +60 -30
- package/dist/entrypoints/agent-runtime/coding-tools.js +9 -12
- package/dist/entrypoints/agent-runtime/harness.js +34 -22
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +6 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +675 -45
- package/dist/entrypoints/agent-runtime/postgres.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/postgres.js +335 -0
- package/dist/entrypoints/agent-runtime/realtime.js +46 -49
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -1
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +74 -67
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +18 -18
- package/dist/entrypoints/agent-runtime/sqlite/node.js +18 -18
- package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +394 -95
- package/dist/entrypoints/agent-runtime.d.ts +26 -16
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1439 -1198
- package/dist/entrypoints/application/diagnostic-journal.js +16 -11
- package/dist/entrypoints/application/directory-inbox.js +20 -14
- package/dist/entrypoints/application/grammy.js +11 -8
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.d.ts +4 -2
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +409 -108
- package/dist/entrypoints/bin/upgrade-cli.d.ts +0 -12
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -1
- package/dist/entrypoints/bin/upgrade-cli.js +11 -7
- package/dist/entrypoints/cli/publish.js +10 -9
- package/dist/entrypoints/cli.d.ts +10 -3
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +92 -29
- package/dist/entrypoints/contract.d.ts +2 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -7
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -1
- package/dist/entrypoints/declaration.js +54 -44
- package/dist/entrypoints/files/packaging.js +8 -5
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +259 -47
- package/dist/entrypoints/geo.js +9 -4
- package/dist/entrypoints/google.js +14 -13
- package/dist/entrypoints/handler.d.ts +12 -0
- package/dist/entrypoints/handler.d.ts.map +1 -0
- package/dist/entrypoints/handler.js +350 -0
- package/dist/entrypoints/http.d.ts +4 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +411 -5
- package/dist/entrypoints/index.d.ts +2 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +664 -91
- package/dist/entrypoints/live.js +22 -12
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +34 -25
- package/dist/entrypoints/observability.d.ts +2 -0
- package/dist/entrypoints/observability.d.ts.map +1 -1
- package/dist/entrypoints/observability.js +205 -131
- package/dist/entrypoints/primitives.js +152 -14
- package/dist/entrypoints/process/owner-loss.js +2 -2
- package/dist/entrypoints/process.js +18 -92
- package/dist/entrypoints/react.js +6 -5
- package/dist/entrypoints/realtime.d.ts +1 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -1
- package/dist/entrypoints/realtime.js +6 -3
- package/dist/entrypoints/release.js +4 -0
- package/dist/entrypoints/remote.js +7 -6
- package/dist/entrypoints/server.d.ts +3 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +295 -194
- package/dist/entrypoints/service-host/macos.d.ts +16 -0
- package/dist/entrypoints/service-host/macos.d.ts.map +1 -0
- package/dist/entrypoints/service-host/macos.js +1998 -0
- package/dist/entrypoints/service-host.d.ts +26 -0
- package/dist/entrypoints/service-host.d.ts.map +1 -0
- package/dist/entrypoints/service-host.js +3155 -0
- package/dist/entrypoints/spend/testing.d.ts +2 -0
- package/dist/entrypoints/spend/testing.d.ts.map +1 -0
- package/dist/entrypoints/spend/testing.js +442 -0
- package/dist/entrypoints/spend.d.ts +8 -0
- package/dist/entrypoints/spend.d.ts.map +1 -0
- package/dist/entrypoints/spend.js +593 -0
- package/dist/entrypoints/sync/postgres.d.ts +12 -0
- package/dist/entrypoints/sync/postgres.d.ts.map +1 -0
- package/dist/entrypoints/sync/postgres.js +737 -0
- package/dist/entrypoints/sync.d.ts +12 -0
- package/dist/entrypoints/sync.d.ts.map +1 -0
- package/dist/entrypoints/sync.js +782 -0
- package/dist/entrypoints/telegram/grammy.js +5 -5
- package/dist/entrypoints/telegram/html.d.ts +2 -0
- package/dist/entrypoints/telegram/html.d.ts.map +1 -1
- package/dist/entrypoints/telegram/html.js +839 -2
- package/dist/entrypoints/telegram/screens.js +13 -15
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +286 -76
- package/dist/entrypoints/testing.js +33 -41
- package/dist/entrypoints/tools/agent.js +13 -9
- package/dist/entrypoints/tools/connections.js +664 -63
- package/dist/entrypoints/tools/contract.d.ts +2 -2
- package/dist/entrypoints/tools/contract.js +4 -1
- package/dist/entrypoints/tools/invoker.js +10 -7
- package/dist/entrypoints/tools/mcp.js +17 -13
- package/dist/entrypoints/tools/toolkit.js +22 -18
- package/dist/entrypoints/tools.d.ts +4 -2
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +105 -90
- package/dist/entrypoints/tracking/contract.js +2 -1
- package/dist/entrypoints/tracking/performance.js +4 -0
- package/dist/entrypoints/tracking.js +6 -1
- package/dist/entrypoints/voice.js +3 -3
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/chunk-spool.d.ts +27 -0
- package/dist/files/chunk-spool.d.ts.map +1 -1
- package/dist/files/directory-appearance.d.ts +55 -0
- package/dist/files/directory-appearance.d.ts.map +1 -0
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/file-stamp.d.ts +35 -0
- package/dist/files/file-stamp.d.ts.map +1 -0
- package/dist/files/json-file-reading.d.ts +37 -0
- package/dist/files/json-file-reading.d.ts.map +1 -0
- package/dist/files/native-packaging.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts +121 -0
- package/dist/files/polled-json.d.ts.map +1 -0
- package/dist/files/regular-file.d.ts +135 -0
- package/dist/files/regular-file.d.ts.map +1 -0
- package/dist/geo/index.d.ts +2 -1
- package/dist/geo/index.d.ts.map +1 -1
- package/dist/geo/resolver.d.ts.map +1 -1
- package/dist/geo/types.d.ts +0 -1
- package/dist/geo/types.d.ts.map +1 -1
- package/dist/google/google.d.ts +6 -0
- package/dist/google/google.d.ts.map +1 -1
- package/dist/{index-w0eqdhyd.js → index-09f7w2qq.js} +6 -1
- package/dist/index-0gqs8ght.js +558 -0
- package/dist/{index-t05a2ry4.js → index-0p0s5hrj.js} +8 -14
- package/dist/{index-1c945ten.js → index-0r15pkjq.js} +1 -1
- package/dist/{index-v1swr26p.js → index-0tyt97nk.js} +2 -2
- package/dist/{index-332d0m9g.js → index-0x4mnwg5.js} +4 -0
- package/dist/index-118aebbg.js +48 -0
- package/dist/index-13dnv6d0.js +296 -0
- package/dist/index-1q0n6zek.js +184 -0
- package/dist/index-1qwrczr1.js +405 -0
- package/dist/index-27hck3z2.js +307 -0
- package/dist/index-2c5w2d1d.js +107 -0
- package/dist/{index-fvd6pvw3.js → index-2nwvn7m2.js} +2 -2
- package/dist/index-2rf33y2h.js +77 -0
- package/dist/index-360j58vb.js +63 -0
- package/dist/{index-tt30h7mr.js → index-39n02e0q.js} +1 -1
- package/dist/{index-mfntvj58.js → index-3dq8466w.js} +1 -1
- package/dist/index-3tnwtz38.js +725 -0
- package/dist/{index-x2d51zay.js → index-3ypvpkwr.js} +309 -345
- package/dist/index-4gk6k3zc.js +248 -0
- package/dist/{index-kxff9e9w.js → index-4j8efqr3.js} +5 -4
- package/dist/index-4qvyhn23.js +40 -0
- package/dist/index-4ynw5ktx.js +78 -0
- package/dist/index-5awtbyns.js +19 -0
- package/dist/{index-nz06qw5a.js → index-5jyjb4s0.js} +1 -1
- package/dist/{index-7zksb1ty.js → index-5ptwb6ka.js} +1 -1
- package/dist/{index-w3nv6kr8.js → index-5q0qpw3v.js} +54 -9
- package/dist/{index-mm89hd8v.js → index-5t4fpdct.js} +1 -1
- package/dist/index-5v5vg85s.js +108 -0
- package/dist/{index-0v9xb8pz.js → index-5y7j383h.js} +5 -5
- package/dist/{index-bqzgaj57.js → index-673drwkn.js} +198 -61
- package/dist/{index-v62cpkx3.js → index-6g85s734.js} +1 -1
- package/dist/{index-sqc6ezrb.js → index-6kec3b14.js} +17 -4
- package/dist/{index-cvjddnvd.js → index-6wp4dn9d.js} +17 -8
- package/dist/{index-kqnd6a85.js → index-7416mhyh.js} +1 -1
- package/dist/{index-m0wsfmrc.js → index-7csn6pva.js} +37 -24
- package/dist/{index-dqpesdck.js → index-7grgs8cx.js} +25 -5
- package/dist/{index-jjvr9f15.js → index-7kfcb576.js} +129 -39
- package/dist/{index-ss67fxhj.js → index-877e9y8r.js} +7 -7
- package/dist/{index-aw6kx2e6.js → index-8gmmdz7k.js} +1 -1
- package/dist/index-8x22nprv.js +1461 -0
- package/dist/{index-rz3z13e9.js → index-97q9kykw.js} +1 -1
- package/dist/index-97rp94ff.js +8 -0
- package/dist/{index-0w0hxp7n.js → index-9pv126eh.js} +3 -9
- package/dist/{index-egg0yp2j.js → index-9xr44d2g.js} +86 -210
- package/dist/{index-b2sey031.js → index-9y0afd5f.js} +24 -23
- package/dist/{index-nmaqxdx7.js → index-ac5rj3d4.js} +203 -90
- package/dist/{index-wqzw3qg9.js → index-agy5fqgf.js} +32 -13
- package/dist/{index-ndjzbt2v.js → index-akf0xkrm.js} +4 -3
- package/dist/index-akfgymyr.js +8 -0
- package/dist/index-apv5xfef.js +13 -0
- package/dist/index-bh4pmtr9.js +317 -0
- package/dist/{index-fa53vygr.js → index-bmaz3jzy.js} +3 -3
- package/dist/{index-8kzct1d6.js → index-bn2baakz.js} +143 -143
- package/dist/{index-m8ddk770.js → index-brhhaygm.js} +1 -1
- package/dist/index-bz3gn6cs.js +407 -0
- package/dist/index-c5gp2gh6.js +51 -0
- package/dist/index-cbhxhma2.js +90 -0
- package/dist/index-cfnmvcq8.js +11 -0
- package/dist/index-cv9b7fz2.js +42 -0
- package/dist/index-d4svrknj.js +156 -0
- package/dist/{index-1szhrfsf.js → index-d54npte7.js} +7 -5
- package/dist/{index-ne4j9998.js → index-e06z0tkb.js} +123 -94
- package/dist/index-emgrmavr.js +1193 -0
- package/dist/{index-99nnsz39.js → index-en8e5zsj.js} +15 -135
- package/dist/{index-20hn8pbh.js → index-fmzg39a8.js} +1 -1
- package/dist/{index-ft2wvst5.js → index-g3e57qj6.js} +1928 -414
- package/dist/index-g56ht6qf.js +98 -0
- package/dist/{index-7cn66qdk.js → index-gf92hc87.js} +15 -7
- package/dist/{index-f56ct5gb.js → index-gj1rjf78.js} +4 -3
- package/dist/{index-g6a3na27.js → index-gnjgkecx.js} +7 -3
- package/dist/index-gzny6zsw.js +487 -0
- package/dist/{index-n6hvd1r2.js → index-hj1zq7mh.js} +26 -13
- package/dist/index-hy4653g4.js +345 -0
- package/dist/{index-t8jz0e20.js → index-j903yhp4.js} +30 -38
- package/dist/{index-9ypczvpj.js → index-jb4m241t.js} +2 -0
- package/dist/{index-wt6rw7rf.js → index-jfecdk1e.js} +29 -21
- package/dist/{index-cjzaj7ev.js → index-jxtg307y.js} +23 -21
- package/dist/{index-3ymcmpa9.js → index-ke02kxsr.js} +33 -163
- package/dist/{index-bz9cmnqq.js → index-kt6dh1n6.js} +4 -4
- package/dist/index-ky3ardqn.js +80 -0
- package/dist/index-kyejf658.js +14 -0
- package/dist/{index-zyc64nbh.js → index-kynwa08q.js} +52 -47
- package/dist/index-kzavdze2.js +15 -0
- package/dist/{index-48acz7z0.js → index-m18xm96h.js} +93 -46
- package/dist/{index-m200b8hs.js → index-mbd92r1w.js} +5 -3
- package/dist/index-mxt0wfjy.js +58 -0
- package/dist/{index-9cxxfkhb.js → index-n20tybgk.js} +14 -9
- package/dist/{index-1v3k5zgx.js → index-n7f89hjw.js} +610 -1168
- package/dist/index-ngwf1s3c.js +51 -0
- package/dist/{index-zfncctjp.js → index-nk0cy9g1.js} +5 -4
- package/dist/{index-hs76yzt7.js → index-paff5y0r.js} +17 -11
- package/dist/index-pn5b11ce.js +40 -0
- package/dist/{index-qaet40b2.js → index-prf6ayhf.js} +5 -7
- package/dist/{index-hkxgennw.js → index-ps3djm8d.js} +7 -1
- package/dist/index-pwskmywy.js +195 -0
- package/dist/{index-3bzk2645.js → index-r9kq5ark.js} +1 -1
- package/dist/{index-hkw233vx.js → index-rbd2rq3z.js} +2 -2
- package/dist/{index-r0xr7y4m.js → index-rhb33thr.js} +138 -33
- package/dist/{index-kffm4r8w.js → index-rj32hkkp.js} +2 -2
- package/dist/index-rptj3qnc.js +96 -0
- package/dist/{index-hqsbtvta.js → index-rpyn7geq.js} +11 -3
- package/dist/{index-x2rvpbtj.js → index-rxnyygke.js} +151 -17
- package/dist/index-rzeezh79.js +508 -0
- package/dist/index-s2e3h616.js +351 -0
- package/dist/{index-m9hb9wnk.js → index-sfzfd2m2.js} +2 -2
- package/dist/{index-sqkttz7z.js → index-sv5svtq7.js} +1 -1
- package/dist/{index-srs8hj9c.js → index-sx3g49y2.js} +5 -1
- package/dist/{index-9mjrnqxs.js → index-t1a2jrg7.js} +21 -91
- package/dist/index-t7wa7k12.js +221 -0
- package/dist/{index-a6w6mwda.js → index-tazm4dxf.js} +1 -1
- package/dist/{index-b51tzcgh.js → index-tf70nm22.js} +2 -2
- package/dist/index-ttexdtjj.js +28 -0
- package/dist/{index-btjwc7xr.js → index-v1mxss62.js} +15 -14
- package/dist/{index-103dp7fz.js → index-v37b2cd6.js} +1956 -3151
- package/dist/{index-0ndz5r8z.js → index-v59pxmf1.js} +17 -9
- package/dist/{index-rfkh44ss.js → index-vgytj9wp.js} +1 -1
- package/dist/index-vgzhw2zk.js +304 -0
- package/dist/index-vmbxj75t.js +177 -0
- package/dist/{index-tnnmekgb.js → index-wa6h4tz6.js} +3 -3
- package/dist/{index-pa9bhefy.js → index-waa6t4zx.js} +83 -10
- package/dist/{index-4efxzrht.js → index-wavv538x.js} +211 -196
- package/dist/index-werjqesf.js +43 -0
- package/dist/{index-7qyv50r4.js → index-wv8dqy7q.js} +2 -2
- package/dist/index-wz392jyz.js +10 -0
- package/dist/{index-1d7s7da0.js → index-x6sp5vpa.js} +36 -5
- package/dist/index-xgae0bn7.js +37 -0
- package/dist/index-xmr47znh.js +160 -0
- package/dist/{index-ftk3838x.js → index-xq4s9mka.js} +7 -2
- package/dist/{index-ww3gss55.js → index-xrgn784x.js} +1 -1
- package/dist/{index-fpwbskp2.js → index-xtby8rj3.js} +1 -1
- package/dist/index-xv9jb84s.js +929 -0
- package/dist/{index-v7rbjatr.js → index-y065r8g5.js} +1881 -1156
- package/dist/{index-yex7eg1v.js → index-y7sy1xdp.js} +6 -2
- package/dist/{index-a7ebd769.js → index-zwgwyvdt.js} +3 -3
- package/dist/internal/abort-error.d.ts +9 -0
- package/dist/internal/abort-error.d.ts.map +1 -0
- package/dist/internal/abort-race.d.ts +47 -4
- package/dist/internal/abort-race.d.ts.map +1 -1
- package/dist/internal/atomic-file.d.ts +19 -0
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts.map +1 -1
- package/dist/internal/bounded-body.d.ts +37 -1
- package/dist/internal/bounded-body.d.ts.map +1 -1
- package/dist/internal/bounded-file-confirm.d.ts +32 -0
- package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
- package/dist/internal/bounded-file-read.d.ts +34 -15
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/bun-command.d.ts +11 -0
- package/dist/internal/bun-command.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -1
- package/dist/internal/darwin-binding-error.d.ts.map +1 -1
- package/dist/internal/darwin-binding.d.ts +10 -0
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/internal/deadline.d.ts +22 -2
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-owner.d.ts +20 -1
- package/dist/internal/exclusive-lock-owner.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-read.d.ts +2 -0
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +26 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +53 -0
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/json-response.d.ts +10 -0
- package/dist/internal/json-response.d.ts.map +1 -0
- package/dist/internal/open-descriptors.d.ts +5 -0
- package/dist/internal/open-descriptors.d.ts.map +1 -1
- package/dist/internal/optional-peer.d.ts.map +1 -1
- package/dist/internal/pinned-http.d.ts.map +1 -1
- package/dist/internal/positive-integer.d.ts +14 -6
- package/dist/internal/positive-integer.d.ts.map +1 -1
- package/dist/internal/postgres-query.d.ts +16 -0
- package/dist/internal/postgres-query.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +21 -1
- package/dist/internal/process-identity.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +14 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/request.d.ts +4 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/secret-equal.d.ts +11 -0
- package/dist/internal/secret-equal.d.ts.map +1 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/internal/sqlite.d.ts +8 -0
- package/dist/internal/sqlite.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +20 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +11 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/unix-client-error.d.ts +21 -0
- package/dist/internal/unix-client-error.d.ts.map +1 -0
- package/dist/internal/unix-socket-lock.d.ts +23 -0
- package/dist/internal/unix-socket-lock.d.ts.map +1 -0
- package/dist/internal/unix-socket.d.ts +62 -0
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/internal/upgrade-affects.d.ts +3 -3
- package/dist/internal/upgrade-affects.d.ts.map +1 -1
- package/dist/internal/upgrade-plan.d.ts.map +1 -1
- package/dist/json-schema/dialect.d.ts +0 -6
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/keywords.d.ts +116 -0
- package/dist/json-schema/keywords.d.ts.map +1 -0
- package/dist/json-schema/string-format.d.ts.map +1 -1
- package/dist/live/events.d.ts.map +1 -1
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +3 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts.map +1 -1
- package/dist/observability/context.d.ts +12 -2
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event-loop-delay.d.ts +62 -0
- package/dist/observability/event-loop-delay.d.ts.map +1 -0
- package/dist/observability/json-logger.d.ts.map +1 -1
- package/dist/observability/log-repeat.d.ts +44 -0
- package/dist/observability/log-repeat.d.ts.map +1 -0
- package/dist/observability/spool-core.d.ts +95 -0
- package/dist/observability/spool-core.d.ts.map +1 -0
- package/dist/observability/spool-file.d.ts +46 -0
- package/dist/observability/spool-file.d.ts.map +1 -0
- package/dist/observability/spool.d.ts +14 -8
- package/dist/observability/spool.d.ts.map +1 -1
- package/dist/observability/trace.d.ts.map +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/order-key.d.ts +37 -0
- package/dist/primitives/order-key.d.ts.map +1 -0
- package/dist/process/bun-child.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/contract.d.ts +4 -3
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group-presence.d.ts.map +1 -1
- package/dist/process/group.d.ts +5 -1
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +5 -3
- package/dist/process/launch.d.ts.map +1 -1
- package/dist/process/owner-loss-guard.d.ts.map +1 -1
- package/dist/react/cache-bridge.d.ts.map +1 -1
- package/dist/release/watcher.d.ts.map +1 -1
- package/dist/server/bridge-host.d.ts +51 -0
- package/dist/server/bridge-host.d.ts.map +1 -0
- package/dist/server/bun.d.ts +4 -4
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/create.d.ts +1 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +2 -0
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -0
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +13 -2
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/implement.d.ts +1 -0
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/local-host.d.ts +47 -0
- package/dist/server/local-host.d.ts.map +1 -0
- package/dist/server/logger.d.ts +20 -3
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/logging.d.ts +2 -1
- package/dist/server/logging.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +1 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/signed-link.d.ts +42 -0
- package/dist/server/middleware/signed-link.d.ts.map +1 -0
- package/dist/server/multipart-reader.d.ts +3 -1
- package/dist/server/multipart-reader.d.ts.map +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts.map +1 -1
- package/dist/server/oauth/endpoints.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/protocol-outcome.d.ts +17 -0
- package/dist/server/protocol-outcome.d.ts.map +1 -0
- package/dist/server/raw.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +3 -1
- package/dist/server/request-completion.d.ts.map +1 -1
- package/dist/server/shutdown.d.ts.map +1 -1
- package/dist/server/socket-io-config.d.ts +1 -1
- package/dist/server/socket-io-config.d.ts.map +1 -1
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +13 -10
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-body.d.ts +4 -1
- package/dist/server/unix-client-body.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +8 -1
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/artifact-activation.d.ts +58 -0
- package/dist/service-host/artifact-activation.d.ts.map +1 -0
- package/dist/service-host/artifact-manifest.d.ts +68 -0
- package/dist/service-host/artifact-manifest.d.ts.map +1 -0
- package/dist/service-host/artifact.d.ts +43 -0
- package/dist/service-host/artifact.d.ts.map +1 -0
- package/dist/service-host/config-reloader-contract.d.ts +66 -0
- package/dist/service-host/config-reloader-contract.d.ts.map +1 -0
- package/dist/service-host/config-reloader-helpers.d.ts +32 -0
- package/dist/service-host/config-reloader-helpers.d.ts.map +1 -0
- package/dist/service-host/config-reloader-source.d.ts +47 -0
- package/dist/service-host/config-reloader-source.d.ts.map +1 -0
- package/dist/service-host/config-reloader.d.ts +6 -0
- package/dist/service-host/config-reloader.d.ts.map +1 -0
- package/dist/service-host/host-adapter.d.ts +72 -0
- package/dist/service-host/host-adapter.d.ts.map +1 -0
- package/dist/service-host/identity-unix-socket.d.ts +101 -0
- package/dist/service-host/identity-unix-socket.d.ts.map +1 -0
- package/dist/service-host/identity.d.ts +117 -0
- package/dist/service-host/identity.d.ts.map +1 -0
- package/dist/service-host/launchd-plist.d.ts +77 -0
- package/dist/service-host/launchd-plist.d.ts.map +1 -0
- package/dist/service-host/launchd-render.d.ts +91 -0
- package/dist/service-host/launchd-render.d.ts.map +1 -0
- package/dist/service-host/launchd.d.ts +82 -0
- package/dist/service-host/launchd.d.ts.map +1 -0
- package/dist/service-host/macos/bundle-plist.d.ts +50 -0
- package/dist/service-host/macos/bundle-plist.d.ts.map +1 -0
- package/dist/service-host/macos/bundle.d.ts +66 -0
- package/dist/service-host/macos/bundle.d.ts.map +1 -0
- package/dist/service-host/macos/codesign.d.ts +95 -0
- package/dist/service-host/macos/codesign.d.ts.map +1 -0
- package/dist/service-host/macos/icon.d.ts +93 -0
- package/dist/service-host/macos/icon.d.ts.map +1 -0
- package/dist/service-host/macos/launch-services.d.ts +88 -0
- package/dist/service-host/macos/launch-services.d.ts.map +1 -0
- package/dist/service-host/macos/launcher.d.ts +59 -0
- package/dist/service-host/macos/launcher.d.ts.map +1 -0
- package/dist/service-host/macos/responsibility.d.ts +90 -0
- package/dist/service-host/macos/responsibility.d.ts.map +1 -0
- package/dist/service-host/macos/runner.d.ts +69 -0
- package/dist/service-host/macos/runner.d.ts.map +1 -0
- package/dist/service-host/plist-xml.d.ts +48 -0
- package/dist/service-host/plist-xml.d.ts.map +1 -0
- package/dist/service-host/process-evidence.d.ts +17 -0
- package/dist/service-host/process-evidence.d.ts.map +1 -0
- package/dist/service-host/systemd-inspect.d.ts +128 -0
- package/dist/service-host/systemd-inspect.d.ts.map +1 -0
- package/dist/service-host/systemd-links.d.ts +23 -0
- package/dist/service-host/systemd-links.d.ts.map +1 -0
- package/dist/service-host/systemd-render-shared.d.ts +64 -0
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +98 -0
- package/dist/service-host/systemd-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-render.d.ts +31 -0
- package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
- package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
- package/dist/service-host/systemd-timer.d.ts +82 -0
- package/dist/service-host/systemd-timer.d.ts.map +1 -0
- package/dist/service-host/systemd-unit-ops.d.ts +26 -0
- package/dist/service-host/systemd-unit-ops.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +50 -0
- package/dist/service-host/systemd.d.ts.map +1 -0
- package/dist/spend/attribution.d.ts +17 -0
- package/dist/spend/attribution.d.ts.map +1 -0
- package/dist/spend/coverage-guard.d.ts +60 -0
- package/dist/spend/coverage-guard.d.ts.map +1 -0
- package/dist/spend/coverage-lexer.d.ts +20 -0
- package/dist/spend/coverage-lexer.d.ts.map +1 -0
- package/dist/spend/facts.d.ts +23 -0
- package/dist/spend/facts.d.ts.map +1 -0
- package/dist/spend/gateway-stream.d.ts +25 -0
- package/dist/spend/gateway-stream.d.ts.map +1 -0
- package/dist/spend/gateway.d.ts +64 -0
- package/dist/spend/gateway.d.ts.map +1 -0
- package/dist/spend/receipt-merge.d.ts +13 -0
- package/dist/spend/receipt-merge.d.ts.map +1 -0
- package/dist/spend/receipt-spool.d.ts +35 -0
- package/dist/spend/receipt-spool.d.ts.map +1 -0
- package/dist/spend/reconcile.d.ts +45 -0
- package/dist/spend/reconcile.d.ts.map +1 -0
- package/dist/spend/schemas.d.ts +249 -0
- package/dist/spend/schemas.d.ts.map +1 -0
- package/dist/sync/outbox.d.ts +131 -0
- package/dist/sync/outbox.d.ts.map +1 -0
- package/dist/sync/overlay.d.ts +59 -0
- package/dist/sync/overlay.d.ts.map +1 -0
- package/dist/sync/protocol.d.ts +132 -0
- package/dist/sync/protocol.d.ts.map +1 -0
- package/dist/sync/server-store-check.d.ts +10 -0
- package/dist/sync/server-store-check.d.ts.map +1 -0
- package/dist/sync/server-store-memory.d.ts +14 -0
- package/dist/sync/server-store-memory.d.ts.map +1 -0
- package/dist/sync/server-store-postgres.d.ts +25 -0
- package/dist/sync/server-store-postgres.d.ts.map +1 -0
- package/dist/sync/server-store.d.ts +139 -0
- package/dist/sync/server-store.d.ts.map +1 -0
- package/dist/sync/session-machine.d.ts +79 -0
- package/dist/sync/session-machine.d.ts.map +1 -0
- package/dist/sync/session-snapshot.d.ts +19 -0
- package/dist/sync/session-snapshot.d.ts.map +1 -0
- package/dist/sync/session-steps.d.ts +15 -0
- package/dist/sync/session-steps.d.ts.map +1 -0
- package/dist/sync/session.d.ts +142 -0
- package/dist/sync/session.d.ts.map +1 -0
- package/dist/sync/tombstones.d.ts +53 -0
- package/dist/sync/tombstones.d.ts.map +1 -0
- package/dist/telegram/bot-api.d.ts.map +1 -1
- package/dist/telegram/broadcast-failure.d.ts.map +1 -1
- package/dist/telegram/budget-transformer.d.ts.map +1 -1
- package/dist/telegram/crypto.d.ts +2 -10
- package/dist/telegram/crypto.d.ts.map +1 -1
- package/dist/telegram/html/markdown-inline.d.ts +19 -0
- package/dist/telegram/html/markdown-inline.d.ts.map +1 -0
- package/dist/telegram/html/markdown-lines.d.ts +51 -0
- package/dist/telegram/html/markdown-lines.d.ts.map +1 -0
- package/dist/telegram/html/markdown-split.d.ts +49 -0
- package/dist/telegram/html/markdown-split.d.ts.map +1 -0
- package/dist/telegram/html/markdown.d.ts +14 -0
- package/dist/telegram/html/markdown.d.ts.map +1 -0
- package/dist/telegram/html/nodes.d.ts +26 -4
- package/dist/telegram/html/nodes.d.ts.map +1 -1
- package/dist/telegram/html/parse.d.ts.map +1 -1
- package/dist/telegram/html/render.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/local-files.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts +15 -2
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/outbound-budget.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts +9 -1
- package/dist/telegram/outbound-cost.d.ts.map +1 -1
- package/dist/telegram/outbound-queue.d.ts +2 -1
- package/dist/telegram/outbound-queue.d.ts.map +1 -1
- package/dist/telegram/screens/outcome.d.ts.map +1 -1
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/transport-connect.d.ts.map +1 -1
- package/dist/telegram/transport.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts.map +1 -1
- package/dist/telegram/update-store-postgres.d.ts +2 -2
- package/dist/telegram/update-store-postgres.d.ts.map +1 -1
- package/dist/telegram/webhook.d.ts.map +1 -1
- package/dist/testing/managed-resource-conformance.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +2 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/access.d.ts +63 -0
- package/dist/tools/access.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +14 -6
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-classify.d.ts +154 -0
- package/dist/tools/cli/args-classify.d.ts.map +1 -0
- package/dist/tools/cli/args-fields.d.ts +14 -7
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args-json.d.ts +1 -1
- package/dist/tools/cli/args-json.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts +4 -48
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +75 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -0
- package/dist/tools/cli/args-tokens.d.ts +2 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +37 -19
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/command-shape.d.ts +5 -0
- package/dist/tools/cli/command-shape.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +57 -2
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +15 -58
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/create-cli.d.ts +7 -3
- package/dist/tools/cli/create-cli.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +71 -20
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/io.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +66 -10
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts +5 -4
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts.map +1 -1
- package/dist/tools/cli/runner.d.ts +28 -0
- package/dist/tools/cli/runner.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +12 -6
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/cli/unavailable.d.ts +2 -0
- package/dist/tools/cli/unavailable.d.ts.map +1 -1
- package/dist/tools/cli/unix-outcome.d.ts +8 -0
- package/dist/tools/cli/unix-outcome.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view-columns.d.ts +18 -0
- package/dist/tools/cli/view-columns.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts.map +1 -1
- package/dist/tools/connections/foreign-schema-join.d.ts +28 -0
- package/dist/tools/connections/foreign-schema-join.d.ts.map +1 -0
- package/dist/tools/connections/foreign-schema.d.ts +9 -0
- package/dist/tools/connections/foreign-schema.d.ts.map +1 -0
- package/dist/tools/connections/limits.d.ts +1 -1
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +18 -6
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +12 -2
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/expose.d.ts +6 -0
- package/dist/tools/internal/expose.d.ts.map +1 -0
- package/dist/tools/internal/json-projection.d.ts +17 -0
- package/dist/tools/internal/json-projection.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +18 -4
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +10 -2
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +8 -2
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +3 -4
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +4 -3
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +26 -14
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +7 -2
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +1 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -2
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
- package/dist/tools/operations/mount-wait.d.ts.map +1 -1
- package/dist/tools/operations/wait-core.d.ts.map +1 -1
- package/dist/tools/read-operation.d.ts +6 -4
- package/dist/tools/read-operation.d.ts.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/runtime-tool-declaration.d.ts +4 -1
- package/dist/tools/runtime-tool-declaration.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +6 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/inline-references.d.ts +7 -0
- package/dist/tools/schema/inline-references.d.ts.map +1 -0
- package/dist/tools/schema/json-schema-origin.d.ts +1 -1
- package/dist/tools/schema/json-schema-origin.d.ts.map +1 -1
- package/dist/tools/schema/presentation.d.ts +6 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tools/schema/schema.d.ts +2 -0
- package/dist/tools/schema/schema.d.ts.map +1 -1
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -1
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +6 -3
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts +2 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/dist/tools/transfer/mount-download.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts +2 -2
- package/dist/tools/transfer/view-file.d.ts +1 -2
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/dist/tracking/client.d.ts +0 -13
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/delivery.d.ts.map +1 -1
- package/dist/tracking/performance/collector.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +55 -0
- package/llms/agent-executor-claude-sdk.txt +31 -0
- package/llms/agent-executor-claude.txt +29 -0
- package/llms/agent-executor-codex.txt +25 -0
- package/llms/agent-executor-testing.txt +26 -0
- package/llms/agent-executor.txt +40 -0
- package/llms/agent-runtime-harness.txt +68 -5
- package/llms/agent-runtime-openrouter.txt +8 -2
- package/llms/agent-runtime-postgres.txt +30 -0
- package/llms/agent-runtime-react.txt +1 -1
- package/llms/agent-runtime-realtime.txt +1 -1
- package/llms/agent-runtime-sandbox.txt +5 -2
- package/llms/agent-runtime-sqlite-bun.txt +2 -2
- package/llms/agent-runtime-sqlite-node.txt +2 -2
- package/llms/agent-runtime-testing.txt +2 -1
- package/llms/agent-runtime.2.txt +450 -501
- package/llms/agent-runtime.3.txt +229 -267
- package/llms/agent-runtime.4.txt +39 -246
- package/llms/agent-runtime.5.txt +1 -1
- package/llms/agent-runtime.txt +551 -2
- package/llms/application-diagnostic-journal.txt +2 -0
- package/llms/application.2.txt +3 -0
- package/llms/application.3.txt +21 -4
- package/llms/application.txt +4 -1
- package/llms/cli.2.txt +259 -99
- package/llms/cli.3.txt +90 -0
- package/llms/cli.txt +96 -184
- package/llms/contract.txt +7 -6
- package/llms/declaration.txt +3 -3
- package/llms/files.txt +11 -0
- package/llms/handler.txt +25 -0
- package/llms/http.txt +18 -1
- package/llms/node.txt +5 -4
- package/llms/observability.2.txt +105 -0
- package/llms/observability.txt +14 -90
- package/llms/primitives.txt +27 -0
- package/llms/process.2.txt +2 -2
- package/llms/process.txt +10 -9
- package/llms/realtime.txt +11 -0
- package/llms/server.2.txt +355 -0
- package/llms/server.4.txt +45 -6
- package/llms/server.5.txt +8 -3
- package/llms/server.txt +143 -256
- package/llms/service-host-macos.txt +53 -0
- package/llms/service-host.txt +69 -0
- package/llms/spend-testing.txt +21 -0
- package/llms/spend.txt +173 -0
- package/llms/stitchkit.2.txt +368 -42
- package/llms/stitchkit.3.txt +164 -13
- package/llms/stitchkit.txt +99 -417
- package/llms/sync-postgres.txt +31 -0
- package/llms/sync.txt +396 -0
- package/llms/telegram-html.txt +4 -1
- package/llms/telegram.2.txt +4 -4
- package/llms/telegram.txt +105 -14
- package/llms/testing.txt +4 -3
- package/llms/tools-connections.txt +4 -4
- package/llms/tools.2.txt +78 -17
- package/llms/tools.3.txt +14 -9
- package/llms/tools.txt +85 -78
- package/llms/upgrading-0.127.0.txt +1059 -0
- package/llms/upgrading-0.128.0.txt +147 -0
- package/llms/upgrading.txt +2 -0
- package/llms-full.txt +3727 -542
- package/llms.txt +44 -27
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/native-assets.json +4 -4
- package/package.json +67 -9
- package/dist/agent-runtime/sandbox-coding.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-events.d.ts +0 -5
- package/dist/agent-runtime/sqlite-events.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-history.d.ts +0 -7
- package/dist/agent-runtime/sqlite-history.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-ledger.d.ts +0 -7
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-reads.d.ts +0 -14
- package/dist/agent-runtime/sqlite-reads.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-rows.d.ts.map +0 -1
- package/dist/agent-runtime/tool-progress.d.ts.map +0 -1
- package/dist/entrypoints/application/schemas.d.ts +0 -15
- package/dist/entrypoints/application/schemas.d.ts.map +0 -1
- package/dist/entrypoints/application/schemas.js +0 -27
- package/dist/index-0s4xebbg.js +0 -8
- package/dist/index-57ppvpw0.js +0 -1150
- package/dist/index-5dmk54h9.js +0 -256
- package/dist/index-8x0q6yfb.js +0 -247
- package/dist/index-a3z56mtn.js +0 -48
- package/dist/index-a5qr2rj6.js +0 -26
- package/dist/index-b0kddvzw.js +0 -35
- package/dist/index-drcjjhy1.js +0 -40
- package/dist/index-eemvahkc.js +0 -21
- package/dist/index-gfk7nrht.js +0 -0
- package/dist/index-jp2qd9jb.js +0 -108
- package/dist/index-nx6eazt0.js +0 -160
- package/dist/index-wxadzdb7.js +0 -55
- package/dist/internal/until-aborted.d.ts +0 -9
- package/dist/internal/until-aborted.d.ts.map +0 -1
- package/dist/server/unix-client-error.d.ts +0 -9
- package/dist/server/unix-client-error.d.ts.map +0 -1
- package/llms/application-schemas.txt +0 -42
|
@@ -1,37 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateDeclaredOutput
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-akf0xkrm.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
coerceJsonArgs2
|
|
9
|
-
} from "./index-t8jz0e20.js";
|
|
5
|
+
HELP_SHOWN_KEYWORDS,
|
|
6
|
+
STANDARD_STRING_FORMATS
|
|
7
|
+
} from "./index-27hck3z2.js";
|
|
10
8
|
import {
|
|
11
|
-
STANDARD_STRING_FORMATS,
|
|
12
9
|
toJsonSchema,
|
|
13
10
|
jsonSchemaFields
|
|
14
|
-
} from "./index-
|
|
11
|
+
} from "./index-ngwf1s3c.js";
|
|
15
12
|
import {
|
|
16
13
|
toolSurfaceOutputSchema,
|
|
17
|
-
objectShapeKeys,
|
|
18
|
-
mergeSchemas,
|
|
19
14
|
toToolName,
|
|
20
15
|
assertUniqueToolName,
|
|
21
16
|
buildToolPresentationSchema,
|
|
22
17
|
projectedContractToolName
|
|
23
|
-
} from "./index-
|
|
18
|
+
} from "./index-3ypvpkwr.js";
|
|
19
|
+
import {
|
|
20
|
+
unwrapZodWrappers,
|
|
21
|
+
objectShapeKeys,
|
|
22
|
+
mergeSchemas
|
|
23
|
+
} from "./index-360j58vb.js";
|
|
24
|
+
import {
|
|
25
|
+
jsonSchemaObjectCoercionMembers
|
|
26
|
+
} from "./index-dsa676h8.js";
|
|
27
|
+
import {
|
|
28
|
+
coerceJsonArgs2
|
|
29
|
+
} from "./index-j903yhp4.js";
|
|
24
30
|
import {
|
|
31
|
+
isInspectOnlyLifecycle,
|
|
32
|
+
inspectOnlyError,
|
|
33
|
+
resolveOptionalCliToolAccess,
|
|
25
34
|
toolResultFromError,
|
|
26
|
-
toolErrorFromResult
|
|
27
|
-
|
|
35
|
+
toolErrorFromResult,
|
|
36
|
+
toolCauseFromResult
|
|
37
|
+
} from "./index-rxnyygke.js";
|
|
28
38
|
import {
|
|
29
39
|
createToolRunner,
|
|
30
40
|
formatToolError
|
|
31
|
-
} from "./index-
|
|
41
|
+
} from "./index-gf92hc87.js";
|
|
32
42
|
import {
|
|
33
43
|
isRepeatableRead
|
|
34
|
-
} from "./index-
|
|
44
|
+
} from "./index-0x4mnwg5.js";
|
|
35
45
|
import {
|
|
36
46
|
MCP_FILE_NAME_META_KEY2,
|
|
37
47
|
McpImageContentSchema,
|
|
@@ -40,221 +50,60 @@ import {
|
|
|
40
50
|
import {
|
|
41
51
|
readContractStreamItems,
|
|
42
52
|
contractStreamLifetimeExceeded
|
|
43
|
-
} from "./index-
|
|
53
|
+
} from "./index-5y7j383h.js";
|
|
44
54
|
import {
|
|
45
55
|
writeContainedFile
|
|
46
|
-
} from "./index-
|
|
56
|
+
} from "./index-bmaz3jzy.js";
|
|
47
57
|
import {
|
|
48
58
|
openPinnedDirectory,
|
|
49
59
|
isSafeEntryName,
|
|
50
60
|
containedEntryMetadata
|
|
51
|
-
} from "./index-
|
|
61
|
+
} from "./index-xrgn784x.js";
|
|
62
|
+
import {
|
|
63
|
+
projectJsonSafe,
|
|
64
|
+
stringifyJsonSafe
|
|
65
|
+
} from "./index-5awtbyns.js";
|
|
66
|
+
import {
|
|
67
|
+
UNIX_CLIENT_TRANSPORT_ERROR_NAME,
|
|
68
|
+
UNIX_CLIENT_TRANSPORT_ERROR_CODES,
|
|
69
|
+
UNIX_CLIENT_DELIVERY_STATES
|
|
70
|
+
} from "./index-cv9b7fz2.js";
|
|
52
71
|
import {
|
|
53
72
|
pollUntil,
|
|
54
73
|
mediaExtension
|
|
55
|
-
} from "./index-
|
|
74
|
+
} from "./index-n20tybgk.js";
|
|
56
75
|
import {
|
|
57
76
|
collectToolSurface
|
|
58
|
-
} from "./index-
|
|
77
|
+
} from "./index-4j8efqr3.js";
|
|
78
|
+
import {
|
|
79
|
+
assertNoLegacyTransports
|
|
80
|
+
} from "./index-akfgymyr.js";
|
|
59
81
|
import {
|
|
60
82
|
fetchGuarded,
|
|
61
83
|
readCapped
|
|
62
|
-
} from "./index-
|
|
63
|
-
import {
|
|
64
|
-
errnoOf
|
|
65
|
-
} from "./index-jj9228tt.js";
|
|
84
|
+
} from "./index-9y0afd5f.js";
|
|
66
85
|
import {
|
|
67
86
|
isUnsafeKey,
|
|
68
87
|
safeJsonParse
|
|
69
88
|
} from "./index-zsarb5xp.js";
|
|
70
|
-
import {
|
|
71
|
-
assertPositiveSafeInteger
|
|
72
|
-
} from "./index-0s4xebbg.js";
|
|
73
89
|
import {
|
|
74
90
|
formatZodError2
|
|
75
91
|
} from "./index-1eeqpadm.js";
|
|
92
|
+
import {
|
|
93
|
+
errnoOf
|
|
94
|
+
} from "./index-jj9228tt.js";
|
|
76
95
|
import {
|
|
77
96
|
AppError2,
|
|
78
97
|
STITCH_ERROR_STATUS2
|
|
79
|
-
} from "./index-
|
|
98
|
+
} from "./index-9pv126eh.js";
|
|
99
|
+
import {
|
|
100
|
+
assertPositiveSafeInteger
|
|
101
|
+
} from "./index-kzavdze2.js";
|
|
80
102
|
import {
|
|
81
103
|
isRecord,
|
|
82
|
-
isAsyncIterable
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// src/tools/cli/format.ts
|
|
86
|
-
var DEFAULT_EXIT_CODES2 = {
|
|
87
|
-
VALIDATION_ERROR: 1,
|
|
88
|
-
BAD_REQUEST: 1,
|
|
89
|
-
UNAUTHORIZED: 2,
|
|
90
|
-
FORBIDDEN: 3,
|
|
91
|
-
NOT_FOUND: 4,
|
|
92
|
-
UNKNOWN_OPERATION: 4,
|
|
93
|
-
CONFLICT: 5,
|
|
94
|
-
RATE_LIMITED: 6,
|
|
95
|
-
TIMEOUT: 7,
|
|
96
|
-
REQUEST_ABORTED: 130,
|
|
97
|
-
REQUEST_TIMEOUT: 7,
|
|
98
|
-
CONNECTION_TIMEOUT: 7,
|
|
99
|
-
STREAM_LIFETIME_EXCEEDED: 7,
|
|
100
|
-
CONNECTION_RESPONSE_TOO_LARGE: 1,
|
|
101
|
-
CONNECTION_REQUEST_FAILED: 1,
|
|
102
|
-
UPSTREAM_TOOL_ERROR: 1,
|
|
103
|
-
WAIT_FAILED: 1,
|
|
104
|
-
CLI_COMMAND_UNAVAILABLE: 1,
|
|
105
|
-
CLI_PRESENTATION_FAILED: 8,
|
|
106
|
-
INTERNAL_SERVER_ERROR: 1
|
|
107
|
-
};
|
|
108
|
-
function cliExitCode2(result, exitCodes) {
|
|
109
|
-
if (result.ok)
|
|
110
|
-
return 0;
|
|
111
|
-
const codes = { ...DEFAULT_EXIT_CODES2, ...exitCodes };
|
|
112
|
-
return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
|
|
113
|
-
}
|
|
114
|
-
function emitResult2(result, writers, opts) {
|
|
115
|
-
if (result.ok) {
|
|
116
|
-
if (result.data === undefined)
|
|
117
|
-
return 0;
|
|
118
|
-
const text = opts.json ? JSON.stringify(result.data) : JSON.stringify(result.data, null, 2);
|
|
119
|
-
writers.stdout(`${text}
|
|
120
|
-
`);
|
|
121
|
-
return 0;
|
|
122
|
-
}
|
|
123
|
-
const error = formatToolError(result, opts.toolName, opts.errorHint);
|
|
124
|
-
const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
|
|
125
|
-
writers.stderr(`${text}
|
|
126
|
-
`);
|
|
127
|
-
return cliExitCode2(result, opts.exitCodes);
|
|
128
|
-
}
|
|
129
|
-
function presentationFailureHint(repeatable, printed) {
|
|
130
|
-
if (repeatable) {
|
|
131
|
-
return "The result was not printed: this command only reads. Repeat it with a corrected view.";
|
|
132
|
-
}
|
|
133
|
-
return printed ? "The complete, unformatted result is on stdout. Do not repeat the command to recover its result." : "The command returned no result. Do not repeat it.";
|
|
134
|
-
}
|
|
135
|
-
function emitPresentationFailure(result, failure, writers, opts) {
|
|
136
|
-
const printed = !opts.repeatable && result.data !== undefined;
|
|
137
|
-
if (printed)
|
|
138
|
-
emitResult2(result, writers, opts);
|
|
139
|
-
return emitResult2({
|
|
140
|
-
ok: false,
|
|
141
|
-
code: "CLI_PRESENTATION_FAILED",
|
|
142
|
-
retryable: false,
|
|
143
|
-
details: {
|
|
144
|
-
message: "The command completed successfully, but its result presentation failed.",
|
|
145
|
-
command: opts.toolName,
|
|
146
|
-
operationSucceeded: true,
|
|
147
|
-
resultOnStdout: printed,
|
|
148
|
-
cause: formatToolError(failure)
|
|
149
|
-
},
|
|
150
|
-
hint: presentationFailureHint(opts.repeatable, printed)
|
|
151
|
-
}, writers, { json: opts.json, toolName: opts.toolName, exitCodes: opts.exitCodes });
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// src/tools/cli/command.ts
|
|
155
|
-
function defineCliResult2(output, policy) {
|
|
156
|
-
return { ...policy, output };
|
|
157
|
-
}
|
|
158
|
-
function defineCliCommand2(definition) {
|
|
159
|
-
return definition;
|
|
160
|
-
}
|
|
161
|
-
function cliCommandReturnsResult(definition) {
|
|
162
|
-
return definition.output !== undefined;
|
|
163
|
-
}
|
|
164
|
-
function cliCommandSuccessExitCode(policy, data) {
|
|
165
|
-
const successExitCode = policy?.exitCode?.(data) ?? 0;
|
|
166
|
-
if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
|
|
167
|
-
throw new Error("CLI success exit code must be an integer from 0 to 255");
|
|
168
|
-
}
|
|
169
|
-
return successExitCode;
|
|
170
|
-
}
|
|
171
|
-
function cliCommandResultPolicy(definition) {
|
|
172
|
-
return cliCommandReturnsResult(definition) ? definition : undefined;
|
|
173
|
-
}
|
|
174
|
-
function prepareCliCommandEmission(policy, result, options) {
|
|
175
|
-
if (!result.ok || policy === undefined) {
|
|
176
|
-
return { result, successExitCode: 0 };
|
|
177
|
-
}
|
|
178
|
-
let successExitCode;
|
|
179
|
-
try {
|
|
180
|
-
successExitCode = cliCommandSuccessExitCode(policy, result.data);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
return {
|
|
183
|
-
result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
|
|
184
|
-
successExitCode: 0
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
if (policy.present === undefined)
|
|
189
|
-
return { result, successExitCode };
|
|
190
|
-
const presentation = policy.present({ result: result.data, options });
|
|
191
|
-
if (typeof presentation !== "string") {
|
|
192
|
-
throw new Error("CLI result presenter must return a string");
|
|
193
|
-
}
|
|
194
|
-
return { result, presentation, successExitCode };
|
|
195
|
-
} catch (error) {
|
|
196
|
-
return {
|
|
197
|
-
result,
|
|
198
|
-
presentationFailure: toolResultFromError(new Error("CLI result presentation failed", { cause: error })),
|
|
199
|
-
successExitCode
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function emitCliCommandResult(policy, result, options, writers, emit, shown) {
|
|
204
|
-
const emission = prepareCliCommandEmission(policy, result, options);
|
|
205
|
-
if (!emission.result.ok)
|
|
206
|
-
return emitResult2(emission.result, writers, emit);
|
|
207
|
-
if (emission.presentation !== undefined) {
|
|
208
|
-
writers.stdout(emission.presentation);
|
|
209
|
-
return emission.successExitCode;
|
|
210
|
-
}
|
|
211
|
-
const printed = shown ?? emission.result;
|
|
212
|
-
if (emission.presentationFailure !== undefined) {
|
|
213
|
-
return emitPresentationFailure(printed, emission.presentationFailure, writers, emit);
|
|
214
|
-
}
|
|
215
|
-
emitResult2(printed, writers, emit);
|
|
216
|
-
return emission.successExitCode;
|
|
217
|
-
}
|
|
218
|
-
function cliCommandPresentationSchema(definition) {
|
|
219
|
-
return buildToolPresentationSchema({
|
|
220
|
-
inputSchema: definition.input,
|
|
221
|
-
unrepresentable: "any"
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
|
|
225
|
-
let parsed;
|
|
226
|
-
try {
|
|
227
|
-
parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs2(rawArgs, definition.input) : rawArgs);
|
|
228
|
-
} catch (error) {
|
|
229
|
-
return toolResultFromError(error);
|
|
230
|
-
}
|
|
231
|
-
if (!parsed.success) {
|
|
232
|
-
return {
|
|
233
|
-
ok: false,
|
|
234
|
-
code: "VALIDATION_ERROR",
|
|
235
|
-
details: { message: `Invalid input: ${formatZodError2(parsed.error)}` }
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
try {
|
|
239
|
-
const data = await definition.handler({
|
|
240
|
-
input: parsed.data,
|
|
241
|
-
options,
|
|
242
|
-
globals,
|
|
243
|
-
...writers
|
|
244
|
-
});
|
|
245
|
-
const checked = validateDeclaredOutput(definition.output, data);
|
|
246
|
-
if (!checked.ok) {
|
|
247
|
-
return {
|
|
248
|
-
ok: false,
|
|
249
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
250
|
-
details: { message: checked.message }
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return { ok: true, data: checked.data };
|
|
254
|
-
} catch (error) {
|
|
255
|
-
return toolResultFromError(error);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
104
|
+
isAsyncIterable,
|
|
105
|
+
transportResult
|
|
106
|
+
} from "./index-ps3djm8d.js";
|
|
258
107
|
|
|
259
108
|
// src/tools/cli/args-fields.ts
|
|
260
109
|
import { z } from "zod";
|
|
@@ -277,14 +126,8 @@ function appendCliOptionValue(raw, name, value, info) {
|
|
|
277
126
|
raw.set(name, [value]);
|
|
278
127
|
}
|
|
279
128
|
}
|
|
280
|
-
function unwrap(field) {
|
|
281
|
-
if (field instanceof z.ZodOptional || field instanceof z.ZodNullable || field instanceof z.ZodDefault) {
|
|
282
|
-
return unwrap(field.unwrap());
|
|
283
|
-
}
|
|
284
|
-
return field;
|
|
285
|
-
}
|
|
286
129
|
function literalKind(field) {
|
|
287
|
-
const base =
|
|
130
|
+
const base = unwrapZodWrappers(field);
|
|
288
131
|
if (base instanceof z.ZodLiteral) {
|
|
289
132
|
const kinds = new Set;
|
|
290
133
|
for (const value of base.values) {
|
|
@@ -333,6 +176,8 @@ function mergeField(fields, name, info) {
|
|
|
333
176
|
if (existing.kind === info.kind) {
|
|
334
177
|
if (existing.kind === "array" && existing.elementKind !== info.elementKind) {
|
|
335
178
|
fields.set(name, { kind: "array", elementKind: "other" });
|
|
179
|
+
} else if (existing.kind === "boolean" && existing.pureBoolean !== info.pureBoolean) {
|
|
180
|
+
fields.set(name, { kind: "boolean" });
|
|
336
181
|
}
|
|
337
182
|
return;
|
|
338
183
|
}
|
|
@@ -342,21 +187,22 @@ function mergeField(fields, name, info) {
|
|
|
342
187
|
}
|
|
343
188
|
fields.set(name, { kind: "other" });
|
|
344
189
|
}
|
|
345
|
-
function collectSchemaFields(schema, fields) {
|
|
346
|
-
const base =
|
|
190
|
+
function collectSchemaFields(schema, fields, inUnion = false) {
|
|
191
|
+
const base = unwrapZodWrappers(schema);
|
|
347
192
|
if (base instanceof z.ZodObject) {
|
|
348
193
|
for (const [name, raw] of Object.entries(base.shape)) {
|
|
349
|
-
const fieldBase =
|
|
194
|
+
const fieldBase = unwrapZodWrappers(raw);
|
|
350
195
|
const kind = classify(fieldBase);
|
|
351
196
|
if (kind === "array" && fieldBase instanceof z.ZodArray) {
|
|
352
197
|
mergeField(fields, name, {
|
|
353
198
|
kind,
|
|
354
|
-
elementKind: classify(
|
|
199
|
+
elementKind: classify(unwrapZodWrappers(fieldBase.element))
|
|
355
200
|
});
|
|
356
201
|
} else {
|
|
357
202
|
mergeField(fields, name, {
|
|
358
203
|
kind,
|
|
359
|
-
...fieldBase instanceof z.ZodNumber && fieldBase.isInt && { integer: true }
|
|
204
|
+
...fieldBase instanceof z.ZodNumber && fieldBase.isInt && { integer: true },
|
|
205
|
+
...kind === "boolean" && !inUnion && { pureBoolean: true }
|
|
360
206
|
});
|
|
361
207
|
}
|
|
362
208
|
}
|
|
@@ -364,12 +210,12 @@ function collectSchemaFields(schema, fields) {
|
|
|
364
210
|
}
|
|
365
211
|
if (base instanceof z.ZodUnion) {
|
|
366
212
|
for (const option of base.def.options)
|
|
367
|
-
collectSchemaFields(option, fields);
|
|
213
|
+
collectSchemaFields(option, fields, true);
|
|
368
214
|
return;
|
|
369
215
|
}
|
|
370
216
|
if (base instanceof z.ZodIntersection) {
|
|
371
|
-
collectSchemaFields(base.def.left, fields);
|
|
372
|
-
collectSchemaFields(base.def.right, fields);
|
|
217
|
+
collectSchemaFields(base.def.left, fields, inUnion);
|
|
218
|
+
collectSchemaFields(base.def.right, fields, inUnion);
|
|
373
219
|
return;
|
|
374
220
|
}
|
|
375
221
|
}
|
|
@@ -380,14 +226,15 @@ function describeSchemaFields(schema) {
|
|
|
380
226
|
return fields;
|
|
381
227
|
}
|
|
382
228
|
function infoOf(field) {
|
|
383
|
-
const base =
|
|
229
|
+
const base = unwrapZodWrappers(field);
|
|
384
230
|
const kind = classify(base);
|
|
385
231
|
if (kind === "array" && base instanceof z.ZodArray) {
|
|
386
|
-
return { kind, elementKind: classify(
|
|
232
|
+
return { kind, elementKind: classify(unwrapZodWrappers(base.element)) };
|
|
387
233
|
}
|
|
388
234
|
return {
|
|
389
235
|
kind,
|
|
390
|
-
...base instanceof z.ZodNumber && base.isInt && { integer: true }
|
|
236
|
+
...base instanceof z.ZodNumber && base.isInt && { integer: true },
|
|
237
|
+
...kind === "boolean" && { pureBoolean: true }
|
|
391
238
|
};
|
|
392
239
|
}
|
|
393
240
|
function mergePathInfos(infos, composition) {
|
|
@@ -404,10 +251,12 @@ function mergePathInfos(infos, composition) {
|
|
|
404
251
|
return;
|
|
405
252
|
if (candidates.every((info) => info.kind === first.kind)) {
|
|
406
253
|
const elementKind = first.kind === "array" ? candidates.every((info) => info.elementKind === first.elementKind) ? first.elementKind : "other" : undefined;
|
|
254
|
+
const pureBoolean = first.kind === "boolean" && (composition === "intersection" ? candidates.some((info) => info.pureBoolean) : infos.every((info) => info?.pureBoolean));
|
|
407
255
|
return {
|
|
408
256
|
kind: first.kind,
|
|
409
257
|
...elementKind && { elementKind },
|
|
410
|
-
...first.integer && candidates.every((info) => info.integer) && { integer: true }
|
|
258
|
+
...first.integer && candidates.every((info) => info.integer) && { integer: true },
|
|
259
|
+
...pureBoolean && { pureBoolean: true }
|
|
411
260
|
};
|
|
412
261
|
}
|
|
413
262
|
return candidates.some((info) => info.kind === "boolean") ? { kind: "boolean" } : { kind: "other" };
|
|
@@ -417,7 +266,7 @@ function pathInfo(schema, path) {
|
|
|
417
266
|
if (guarded) {
|
|
418
267
|
return mergePathInfos(guarded.map((member) => pathInfo(member, path)), "intersection");
|
|
419
268
|
}
|
|
420
|
-
const base =
|
|
269
|
+
const base = unwrapZodWrappers(schema);
|
|
421
270
|
if (base !== schema)
|
|
422
271
|
return pathInfo(base, path);
|
|
423
272
|
if (base instanceof z.ZodUnion) {
|
|
@@ -444,37 +293,39 @@ function describeSchemaPath(schema, path) {
|
|
|
444
293
|
return;
|
|
445
294
|
return pathInfo(schema, path);
|
|
446
295
|
}
|
|
447
|
-
var
|
|
448
|
-
|
|
296
|
+
var BOOL_WORDS = {
|
|
297
|
+
true: { value: true, separate: true },
|
|
298
|
+
"1": { value: true, separate: false },
|
|
299
|
+
yes: { value: true, separate: false },
|
|
300
|
+
on: { value: true, separate: false },
|
|
301
|
+
false: { value: false, separate: true },
|
|
302
|
+
"0": { value: false, separate: false },
|
|
303
|
+
no: { value: false, separate: false },
|
|
304
|
+
off: { value: false, separate: false }
|
|
305
|
+
};
|
|
306
|
+
function lookupBoolWord(value) {
|
|
307
|
+
const key = value.toLowerCase();
|
|
308
|
+
return Object.hasOwn(BOOL_WORDS, key) ? BOOL_WORDS[key] : undefined;
|
|
309
|
+
}
|
|
449
310
|
function separateBoolValue(next) {
|
|
450
|
-
if (next ===
|
|
451
|
-
return
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return;
|
|
311
|
+
if (next === undefined)
|
|
312
|
+
return;
|
|
313
|
+
const row = lookupBoolWord(next);
|
|
314
|
+
return row?.separate ? row.value : undefined;
|
|
455
315
|
}
|
|
456
316
|
function isReservedBoolWord(value) {
|
|
457
|
-
|
|
458
|
-
return TRUE_WORDS.has(word) || FALSE_WORDS.has(word);
|
|
317
|
+
return lookupBoolWord(value) !== undefined;
|
|
459
318
|
}
|
|
460
319
|
function parseReservedBool(name, value) {
|
|
461
|
-
const
|
|
462
|
-
if (
|
|
463
|
-
return
|
|
464
|
-
if (FALSE_WORDS.has(v))
|
|
465
|
-
return false;
|
|
320
|
+
const row = lookupBoolWord(value);
|
|
321
|
+
if (row !== undefined)
|
|
322
|
+
return row.value;
|
|
466
323
|
throw new CliArgumentError2(`--${name} expects a boolean (true/false), got "${value}"`);
|
|
467
324
|
}
|
|
468
325
|
function coerceScalar(kind, value) {
|
|
469
326
|
switch (kind) {
|
|
470
|
-
case "boolean":
|
|
471
|
-
|
|
472
|
-
if (TRUE_WORDS.has(v))
|
|
473
|
-
return true;
|
|
474
|
-
if (FALSE_WORDS.has(v))
|
|
475
|
-
return false;
|
|
476
|
-
return value;
|
|
477
|
-
}
|
|
327
|
+
case "boolean":
|
|
328
|
+
return lookupBoolWord(value)?.value ?? value;
|
|
478
329
|
case "number": {
|
|
479
330
|
const n = Number(value);
|
|
480
331
|
return value.trim() !== "" && !Number.isNaN(n) ? n : value;
|
|
@@ -501,6 +352,28 @@ function looseCoerce(value) {
|
|
|
501
352
|
const number = Number(value);
|
|
502
353
|
return value.trim() !== "" && !Number.isNaN(number) ? number : value;
|
|
503
354
|
}
|
|
355
|
+
function refuseGlobalOption(issue) {
|
|
356
|
+
const field = issue?.path[0];
|
|
357
|
+
const where = typeof field === "string" ? `--${field}` : "application option";
|
|
358
|
+
throw new CliArgumentError2(`${where}: ${issue?.message ?? "invalid value"}`);
|
|
359
|
+
}
|
|
360
|
+
function parseCliGlobalValues(schema, raw) {
|
|
361
|
+
const base = raw ?? {};
|
|
362
|
+
if (schema === undefined)
|
|
363
|
+
return transportResult(base);
|
|
364
|
+
let coerced;
|
|
365
|
+
try {
|
|
366
|
+
coerced = coerceJsonArgs2(base, schema);
|
|
367
|
+
} catch (error) {
|
|
368
|
+
if (error instanceof z.ZodError)
|
|
369
|
+
refuseGlobalOption(error.issues[0]);
|
|
370
|
+
throw error;
|
|
371
|
+
}
|
|
372
|
+
const parsed = schema.safeParse(coerced);
|
|
373
|
+
if (!parsed.success)
|
|
374
|
+
refuseGlobalOption(parsed.error.issues[0]);
|
|
375
|
+
return parsed.data;
|
|
376
|
+
}
|
|
504
377
|
function looksLikeJson(value) {
|
|
505
378
|
const t = value.trim();
|
|
506
379
|
return t.startsWith("[") || t.startsWith("{");
|
|
@@ -562,34 +435,1112 @@ function setNested(target, path, value) {
|
|
|
562
435
|
node[leaf] = value;
|
|
563
436
|
}
|
|
564
437
|
|
|
565
|
-
// src/tools/cli/
|
|
566
|
-
var
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
438
|
+
// src/tools/cli/format.ts
|
|
439
|
+
var DEFAULT_EXIT_CODES2 = {
|
|
440
|
+
VALIDATION_ERROR: 1,
|
|
441
|
+
BAD_REQUEST: 1,
|
|
442
|
+
UNAUTHORIZED: 2,
|
|
443
|
+
FORBIDDEN: 3,
|
|
444
|
+
NOT_FOUND: 4,
|
|
445
|
+
UNKNOWN_OPERATION: 4,
|
|
446
|
+
CONFLICT: 5,
|
|
447
|
+
RATE_LIMITED: 6,
|
|
448
|
+
TIMEOUT: 7,
|
|
449
|
+
REQUEST_ABORTED: 130,
|
|
450
|
+
REQUEST_TIMEOUT: 7,
|
|
451
|
+
CONNECTION_TIMEOUT: 7,
|
|
452
|
+
STREAM_LIFETIME_EXCEEDED: 7,
|
|
453
|
+
CONNECTION_RESPONSE_TOO_LARGE: 1,
|
|
454
|
+
CONNECTION_REQUEST_FAILED: 1,
|
|
455
|
+
UPSTREAM_TOOL_ERROR: 1,
|
|
456
|
+
MCP_STRUCTURED_CONTENT_MISSING: 1,
|
|
457
|
+
WAIT_FAILED: 1,
|
|
458
|
+
CLI_COMMAND_UNAVAILABLE: 1,
|
|
459
|
+
CLI_PRESENTATION_FAILED: 8,
|
|
460
|
+
UNIX_CONNECT_FAILED: 9,
|
|
461
|
+
UNIX_TARGET_REFUSED: 9,
|
|
462
|
+
UNIX_CLIENT_CLOSED: 9,
|
|
463
|
+
UNIX_CONNECTION_LIMIT: 9,
|
|
464
|
+
UNIX_REQUEST_TOO_LARGE: 9,
|
|
465
|
+
UNIX_DELIVERY_UNCERTAIN: 10,
|
|
466
|
+
UNIX_HEADERS_TIMEOUT: 10,
|
|
467
|
+
INTERNAL_SERVER_ERROR: 1
|
|
468
|
+
};
|
|
469
|
+
function cliExitCode2(result, exitCodes) {
|
|
470
|
+
if (result.ok)
|
|
471
|
+
return 0;
|
|
472
|
+
const codes = { ...DEFAULT_EXIT_CODES2, ...exitCodes };
|
|
473
|
+
return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
|
|
474
|
+
}
|
|
475
|
+
function emitResult2(result, writers, opts) {
|
|
476
|
+
if (result.ok) {
|
|
477
|
+
if (result.data === undefined)
|
|
478
|
+
return 0;
|
|
479
|
+
const text = stringifyJsonSafe(result.data, opts.json ? undefined : 2);
|
|
480
|
+
writers.stdout(`${text}
|
|
481
|
+
`);
|
|
482
|
+
return 0;
|
|
483
|
+
}
|
|
484
|
+
const error = formatToolError(result, opts.toolName, opts.errorHint);
|
|
485
|
+
const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
|
|
486
|
+
writers.stderr(`${text}
|
|
487
|
+
`);
|
|
488
|
+
return cliExitCode2(result, opts.exitCodes);
|
|
489
|
+
}
|
|
490
|
+
function presentationFailureHint(repeatable, printed) {
|
|
491
|
+
if (repeatable) {
|
|
492
|
+
return "The result was not printed: this command only reads. Repeat it with a corrected view.";
|
|
493
|
+
}
|
|
494
|
+
return printed ? "The complete, unformatted result is on stdout. Do not repeat the command to recover its result." : "The command returned no result. Do not repeat it.";
|
|
495
|
+
}
|
|
496
|
+
function emitPresentationFailure(result, failure, writers, opts) {
|
|
497
|
+
const printed = !opts.repeatable && result.data !== undefined;
|
|
498
|
+
if (printed)
|
|
499
|
+
emitResult2(result, writers, opts);
|
|
500
|
+
return emitResult2({
|
|
501
|
+
ok: false,
|
|
502
|
+
code: "CLI_PRESENTATION_FAILED",
|
|
503
|
+
retryable: false,
|
|
504
|
+
details: {
|
|
505
|
+
message: "The command completed successfully, but its result presentation failed.",
|
|
506
|
+
command: opts.toolName,
|
|
507
|
+
operationSucceeded: true,
|
|
508
|
+
resultOnStdout: printed,
|
|
509
|
+
cause: formatToolError(failure)
|
|
510
|
+
},
|
|
511
|
+
hint: presentationFailureHint(opts.repeatable, printed)
|
|
512
|
+
}, writers, { json: opts.json, toolName: opts.toolName, exitCodes: opts.exitCodes });
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// src/tools/cli/view.ts
|
|
516
|
+
var ABSENT = "(absent)";
|
|
517
|
+
function selectRecords(data) {
|
|
518
|
+
if (Array.isArray(data))
|
|
519
|
+
return data;
|
|
520
|
+
if (isRecord(data)) {
|
|
521
|
+
const arrays = Object.entries(data).filter(([, value]) => Array.isArray(value));
|
|
522
|
+
const only = arrays[0];
|
|
523
|
+
if (arrays.length === 1 && only && Array.isArray(only[1]))
|
|
524
|
+
return only[1];
|
|
525
|
+
if (arrays.length > 1) {
|
|
526
|
+
throw new CliArgumentError2(`an aggregate needs one collection, but the result carries several: ${arrays.map(([key]) => key).join(", ")} — name the shape you want with jq instead`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
throw new CliArgumentError2("an aggregate needs a collection; this result is not one");
|
|
530
|
+
}
|
|
531
|
+
function isAbsent(value) {
|
|
532
|
+
return value === undefined || value === null;
|
|
533
|
+
}
|
|
534
|
+
function readField(record, path) {
|
|
535
|
+
let current = record;
|
|
536
|
+
for (const segment of path) {
|
|
537
|
+
if (!isRecord(current) || !Object.hasOwn(current, segment))
|
|
538
|
+
return;
|
|
539
|
+
current = current[segment];
|
|
540
|
+
}
|
|
541
|
+
return current;
|
|
542
|
+
}
|
|
543
|
+
function fieldPath(field) {
|
|
544
|
+
const path = field.split(".");
|
|
545
|
+
if (path.some((segment) => segment.length === 0 || isUnsafeKey(segment))) {
|
|
546
|
+
throw new CliArgumentError2(`"${field}" is not a readable field path`);
|
|
547
|
+
}
|
|
548
|
+
return path;
|
|
549
|
+
}
|
|
550
|
+
function availableFields(records) {
|
|
551
|
+
const keys = new Set;
|
|
552
|
+
for (const record of records) {
|
|
553
|
+
if (isRecord(record))
|
|
554
|
+
for (const key of Object.keys(record))
|
|
555
|
+
keys.add(key);
|
|
556
|
+
}
|
|
557
|
+
return [...keys].sort();
|
|
558
|
+
}
|
|
559
|
+
function assertFieldPresent(records, field) {
|
|
560
|
+
const path = fieldPath(field);
|
|
561
|
+
const present = records.some((record) => readField(record, path) !== undefined);
|
|
562
|
+
if (records.length > 0 && !present) {
|
|
563
|
+
const available = availableFields(records);
|
|
564
|
+
throw new CliArgumentError2(`no record carries the field "${field}"${available.length > 0 ? ` — available: ${available.join(", ")}` : ""}`);
|
|
565
|
+
}
|
|
566
|
+
return path;
|
|
567
|
+
}
|
|
568
|
+
function groupKey(value) {
|
|
569
|
+
if (value === undefined)
|
|
570
|
+
return ABSENT;
|
|
571
|
+
if (value === null)
|
|
572
|
+
return "null";
|
|
573
|
+
if (value === "null" || value === ABSENT)
|
|
574
|
+
return JSON.stringify(value);
|
|
575
|
+
if (typeof value === "object")
|
|
576
|
+
return stringifyJsonSafe(value);
|
|
577
|
+
return String(value);
|
|
578
|
+
}
|
|
579
|
+
function ordered(totals, top) {
|
|
580
|
+
const entries = [...totals].sort(([leftKey, left], [rightKey, right]) => right === left ? leftKey.localeCompare(rightKey) : right - left);
|
|
581
|
+
const sliced = top === undefined ? entries : entries.slice(0, top);
|
|
582
|
+
return {
|
|
583
|
+
kind: "json",
|
|
584
|
+
data: Object.fromEntries(sliced),
|
|
585
|
+
order: sliced.map(([key]) => key)
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
function stringifyGroups(data, order, compact) {
|
|
589
|
+
if (!isRecord(data) || order.length === 0)
|
|
590
|
+
return stringifyJsonSafe(data);
|
|
591
|
+
const lines = order.map((key) => `${JSON.stringify(key)}:${compact ? "" : " "}${stringifyJsonSafe(data[key])}`);
|
|
592
|
+
return compact ? `{${lines.join(",")}}` : `{
|
|
593
|
+
${lines.join(`,
|
|
594
|
+
`)}
|
|
595
|
+
}`;
|
|
596
|
+
}
|
|
597
|
+
function numericValue(value, field) {
|
|
598
|
+
if (isAbsent(value))
|
|
599
|
+
return;
|
|
600
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
601
|
+
return value;
|
|
602
|
+
if (typeof value === "bigint")
|
|
603
|
+
return Number(value);
|
|
604
|
+
throw new CliArgumentError2(`--sum ${field}: "${groupKey(value)}" is not a number`);
|
|
605
|
+
}
|
|
606
|
+
function renderTable(records, columns) {
|
|
607
|
+
const fields = columns.map(({ field }) => field);
|
|
608
|
+
const cell = (value) => {
|
|
609
|
+
if (value === undefined)
|
|
610
|
+
return "";
|
|
611
|
+
if (value === null)
|
|
612
|
+
return "null";
|
|
613
|
+
if (typeof value === "object")
|
|
614
|
+
return stringifyJsonSafe(value);
|
|
615
|
+
return String(value);
|
|
616
|
+
};
|
|
617
|
+
const rows = records.map((record) => columns.map(({ path }) => cell(readField(record, path))));
|
|
618
|
+
const widths = fields.map((field, column) => Math.max(field.length, ...rows.map((row) => row[column]?.length ?? 0)));
|
|
619
|
+
const line = (cells) => cells.map((value, column) => value.padEnd(widths[column] ?? value.length)).join(" ").trimEnd();
|
|
620
|
+
return `${[line(fields), line(widths.map((width) => "-".repeat(width))), ...rows.map(line)].join(`
|
|
621
|
+
`)}
|
|
622
|
+
`;
|
|
623
|
+
}
|
|
624
|
+
function compareFieldValues(left, right) {
|
|
625
|
+
if (isAbsent(left))
|
|
626
|
+
return isAbsent(right) ? 0 : 1;
|
|
627
|
+
if (isAbsent(right))
|
|
628
|
+
return -1;
|
|
629
|
+
if (typeof left === "number" && typeof right === "number")
|
|
630
|
+
return left - right;
|
|
631
|
+
if (typeof left === "bigint" || typeof right === "bigint") {
|
|
632
|
+
return Number(left) - Number(right);
|
|
633
|
+
}
|
|
634
|
+
return groupKey(left).localeCompare(groupKey(right));
|
|
635
|
+
}
|
|
636
|
+
function renderRecords(records, view) {
|
|
637
|
+
let selected = [...records];
|
|
638
|
+
if (view.sort !== undefined) {
|
|
639
|
+
const path = assertFieldPresent(records, view.sort);
|
|
640
|
+
const direction = view.ascending ? 1 : -1;
|
|
641
|
+
selected.sort((left, right) => {
|
|
642
|
+
const leftValue = readField(left, path);
|
|
643
|
+
const rightValue = readField(right, path);
|
|
644
|
+
const order = compareFieldValues(leftValue, rightValue);
|
|
645
|
+
return isAbsent(leftValue) || isAbsent(rightValue) ? order : order * direction;
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
const columns = view.table?.map((field) => ({
|
|
649
|
+
field,
|
|
650
|
+
path: assertFieldPresent(records, field)
|
|
651
|
+
}));
|
|
652
|
+
if (view.top !== undefined)
|
|
653
|
+
selected = selected.slice(0, view.top);
|
|
654
|
+
return columns ? { kind: "text", text: renderTable(selected, columns) } : { kind: "json", data: selected };
|
|
655
|
+
}
|
|
656
|
+
function refuseEnvelopeFields(data, view) {
|
|
657
|
+
if (!isRecord(data))
|
|
658
|
+
return;
|
|
659
|
+
const fields = view.kind === "records" ? [...view.sort === undefined ? [] : [view.sort], ...view.table ?? []] : [view.field, ...view.kind === "sum" && view.by !== undefined ? [view.by] : []];
|
|
660
|
+
for (const field of fields) {
|
|
661
|
+
const first = field.split(".")[0] ?? "";
|
|
662
|
+
if (Object.hasOwn(data, first) && !Array.isArray(data[first])) {
|
|
663
|
+
throw new CliArgumentError2(`"${field}" belongs to the result object, not to its empty collection`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
function renderCliView2(data, view) {
|
|
668
|
+
const records = selectRecords(data);
|
|
669
|
+
if (records.length === 0)
|
|
670
|
+
refuseEnvelopeFields(data, view);
|
|
671
|
+
if (view.kind === "records")
|
|
672
|
+
return renderRecords(records, view);
|
|
673
|
+
if (view.kind === "count") {
|
|
674
|
+
const path = assertFieldPresent(records, view.field);
|
|
675
|
+
const totals = new Map;
|
|
676
|
+
for (const record of records) {
|
|
677
|
+
const key = groupKey(readField(record, path));
|
|
678
|
+
totals.set(key, (totals.get(key) ?? 0) + 1);
|
|
679
|
+
}
|
|
680
|
+
return ordered(totals, view.top);
|
|
681
|
+
}
|
|
682
|
+
const path = assertFieldPresent(records, view.field);
|
|
683
|
+
if (view.by === undefined) {
|
|
684
|
+
let total = 0;
|
|
685
|
+
for (const record of records)
|
|
686
|
+
total += numericValue(readField(record, path), view.field) ?? 0;
|
|
687
|
+
return { kind: "json", data: total };
|
|
688
|
+
}
|
|
689
|
+
const byPath = assertFieldPresent(records, view.by);
|
|
690
|
+
const totals = new Map;
|
|
691
|
+
for (const record of records) {
|
|
692
|
+
const key = groupKey(readField(record, byPath));
|
|
693
|
+
totals.set(key, (totals.get(key) ?? 0) + (numericValue(readField(record, path), view.field) ?? 0));
|
|
694
|
+
}
|
|
695
|
+
return ordered(totals, view.top);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// src/tools/cli/view-columns.ts
|
|
699
|
+
import { z as z2 } from "zod";
|
|
700
|
+
function unwrapReadonly(schema) {
|
|
701
|
+
return schema instanceof z2.ZodReadonly ? unwrapReadonly(schema.unwrap()) : schema;
|
|
702
|
+
}
|
|
703
|
+
function hasOpenCatchall(objectSchema) {
|
|
704
|
+
const catchall = objectSchema.def.catchall;
|
|
705
|
+
return catchall !== undefined && !(catchall instanceof z2.ZodNever);
|
|
706
|
+
}
|
|
707
|
+
function couldBeArray(schema) {
|
|
708
|
+
const base = unwrapZodWrappers(schema);
|
|
709
|
+
if (base instanceof z2.ZodArray || base instanceof z2.ZodTuple)
|
|
710
|
+
return true;
|
|
711
|
+
if (base instanceof z2.ZodUnknown || base instanceof z2.ZodAny)
|
|
712
|
+
return true;
|
|
713
|
+
if (base instanceof z2.ZodUnion)
|
|
714
|
+
return base.def.options.some(couldBeArray);
|
|
715
|
+
if (base instanceof z2.ZodIntersection) {
|
|
716
|
+
return couldBeArray(base.def.left) || couldBeArray(base.def.right);
|
|
717
|
+
}
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
function resolveUnambiguousRecordSchema(outputSchema) {
|
|
721
|
+
if (outputSchema === undefined)
|
|
722
|
+
return;
|
|
723
|
+
const root = unwrapReadonly(outputSchema);
|
|
724
|
+
let element;
|
|
725
|
+
if (root instanceof z2.ZodArray) {
|
|
726
|
+
element = root.element;
|
|
727
|
+
} else if (root instanceof z2.ZodObject) {
|
|
728
|
+
if (hasOpenCatchall(root))
|
|
729
|
+
return;
|
|
730
|
+
let requiredArray;
|
|
731
|
+
for (const field of Object.values(root.shape)) {
|
|
732
|
+
const bare = unwrapReadonly(field);
|
|
733
|
+
if (bare instanceof z2.ZodArray) {
|
|
734
|
+
if (requiredArray !== undefined)
|
|
735
|
+
return;
|
|
736
|
+
requiredArray = bare;
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (couldBeArray(field))
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
element = requiredArray?.element;
|
|
743
|
+
}
|
|
744
|
+
if (element === undefined)
|
|
745
|
+
return;
|
|
746
|
+
const record = unwrapReadonly(element);
|
|
747
|
+
if (!(record instanceof z2.ZodObject) || hasOpenCatchall(record))
|
|
748
|
+
return;
|
|
749
|
+
return record;
|
|
750
|
+
}
|
|
751
|
+
function pathExistsOnSchema(schema, path) {
|
|
752
|
+
if (path.length === 0)
|
|
753
|
+
return true;
|
|
754
|
+
const base = unwrapZodWrappers(schema);
|
|
755
|
+
if (base instanceof z2.ZodUnknown || base instanceof z2.ZodAny)
|
|
756
|
+
return true;
|
|
757
|
+
if (base instanceof z2.ZodRecord)
|
|
758
|
+
return pathExistsOnSchema(base.valueType, path.slice(1));
|
|
759
|
+
if (base instanceof z2.ZodUnion) {
|
|
760
|
+
return base.def.options.some((branch) => pathExistsOnSchema(branch, path));
|
|
761
|
+
}
|
|
762
|
+
if (base instanceof z2.ZodIntersection) {
|
|
763
|
+
return pathExistsOnSchema(base.def.left, path) || pathExistsOnSchema(base.def.right, path);
|
|
764
|
+
}
|
|
765
|
+
if (base instanceof z2.ZodObject) {
|
|
766
|
+
const [head, ...rest] = path;
|
|
767
|
+
if (head === undefined)
|
|
768
|
+
return true;
|
|
769
|
+
if (Object.hasOwn(base.shape, head)) {
|
|
770
|
+
const child = base.shape[head];
|
|
771
|
+
return child !== undefined && pathExistsOnSchema(child, rest);
|
|
772
|
+
}
|
|
773
|
+
if (hasOpenCatchall(base) && base.def.catchall !== undefined) {
|
|
774
|
+
return pathExistsOnSchema(base.def.catchall, rest);
|
|
775
|
+
}
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
function requestedViewFields(view) {
|
|
781
|
+
if (view.kind === "records") {
|
|
782
|
+
return [...view.sort === undefined ? [] : [view.sort], ...view.table ?? []];
|
|
783
|
+
}
|
|
784
|
+
if (view.kind === "sum") {
|
|
785
|
+
return [view.field, ...view.by === undefined ? [] : [view.by]];
|
|
786
|
+
}
|
|
787
|
+
return [view.field];
|
|
788
|
+
}
|
|
789
|
+
function assertViewColumns(view, outputSchema) {
|
|
790
|
+
const record = resolveUnambiguousRecordSchema(outputSchema);
|
|
791
|
+
if (record === undefined)
|
|
792
|
+
return;
|
|
793
|
+
const available = Object.keys(record.shape).sort();
|
|
794
|
+
for (const field of requestedViewFields(view)) {
|
|
795
|
+
const path = field.split(".");
|
|
796
|
+
if (path.some((segment) => segment.length === 0 || isUnsafeKey(segment))) {
|
|
797
|
+
throw new CliArgumentError2(`"${field}" is not a readable field path`);
|
|
798
|
+
}
|
|
799
|
+
if (!pathExistsOnSchema(record, path)) {
|
|
800
|
+
throw new CliArgumentError2(`no record carries the field "${field}"${available.length > 0 ? ` — available: ${available.join(", ")}` : ""}`);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// src/tools/cli/command.ts
|
|
806
|
+
function defineCliResult2(output, policy) {
|
|
807
|
+
return { ...policy, output };
|
|
808
|
+
}
|
|
809
|
+
function defineCliCommand2(definition) {
|
|
810
|
+
return definition;
|
|
811
|
+
}
|
|
812
|
+
function cliCommandReturnsResult(definition) {
|
|
813
|
+
return definition.output !== undefined;
|
|
814
|
+
}
|
|
815
|
+
function cliCommandSuccessExitCode(policy, data) {
|
|
816
|
+
const successExitCode = policy?.exitCode?.(data) ?? 0;
|
|
817
|
+
if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
|
|
818
|
+
throw new Error("CLI success exit code must be an integer from 0 to 255");
|
|
819
|
+
}
|
|
820
|
+
return successExitCode;
|
|
821
|
+
}
|
|
822
|
+
function cliCommandResultPolicy(definition) {
|
|
823
|
+
return cliCommandReturnsResult(definition) ? definition : undefined;
|
|
824
|
+
}
|
|
825
|
+
function prepareCliCommandEmission(policy, result, options) {
|
|
826
|
+
if (!result.ok || policy === undefined) {
|
|
827
|
+
return { result, successExitCode: 0 };
|
|
828
|
+
}
|
|
829
|
+
let successExitCode;
|
|
830
|
+
try {
|
|
831
|
+
successExitCode = cliCommandSuccessExitCode(policy, result.data);
|
|
832
|
+
} catch (error) {
|
|
833
|
+
return {
|
|
834
|
+
result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
|
|
835
|
+
successExitCode: 0
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
try {
|
|
839
|
+
if (policy.present === undefined)
|
|
840
|
+
return { result, successExitCode };
|
|
841
|
+
const presentation = policy.present({ result: result.data, options });
|
|
842
|
+
if (typeof presentation !== "string") {
|
|
843
|
+
throw new Error("CLI result presenter must return a string");
|
|
844
|
+
}
|
|
845
|
+
return { result, presentation, successExitCode };
|
|
846
|
+
} catch (error) {
|
|
847
|
+
return {
|
|
848
|
+
result,
|
|
849
|
+
presentationFailure: toolResultFromError(new Error("CLI result presentation failed", { cause: error })),
|
|
850
|
+
successExitCode
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
function emitCliCommandResult(policy, result, options, writers, emit, shown) {
|
|
855
|
+
const emission = prepareCliCommandEmission(policy, result, options);
|
|
856
|
+
if (!emission.result.ok)
|
|
857
|
+
return emitResult2(emission.result, writers, emit);
|
|
858
|
+
if (emission.presentation !== undefined) {
|
|
859
|
+
writers.stdout(emission.presentation);
|
|
860
|
+
return emission.successExitCode;
|
|
861
|
+
}
|
|
862
|
+
const printed = shown ?? emission.result;
|
|
863
|
+
if (emission.presentationFailure !== undefined) {
|
|
864
|
+
return emitPresentationFailure(printed, emission.presentationFailure, writers, emit);
|
|
865
|
+
}
|
|
866
|
+
emitResult2(printed, writers, emit);
|
|
867
|
+
return emission.successExitCode;
|
|
868
|
+
}
|
|
869
|
+
function cliCommandPresentationSchema(definition) {
|
|
870
|
+
return buildToolPresentationSchema({
|
|
871
|
+
inputSchema: definition.input,
|
|
872
|
+
unrepresentable: "any"
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
|
|
876
|
+
let parsed;
|
|
877
|
+
try {
|
|
878
|
+
parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs2(rawArgs, definition.input) : rawArgs);
|
|
879
|
+
} catch (error) {
|
|
880
|
+
return toolResultFromError(error);
|
|
881
|
+
}
|
|
882
|
+
if (!parsed.success) {
|
|
883
|
+
return {
|
|
884
|
+
ok: false,
|
|
885
|
+
code: "VALIDATION_ERROR",
|
|
886
|
+
details: { message: `Invalid input: ${formatZodError2(parsed.error)}` }
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
try {
|
|
890
|
+
const data = await definition.handler({
|
|
891
|
+
input: parsed.data,
|
|
892
|
+
options,
|
|
893
|
+
globals,
|
|
894
|
+
...writers
|
|
895
|
+
});
|
|
896
|
+
const checked = validateDeclaredOutput(definition.output, data);
|
|
897
|
+
if (!checked.ok) {
|
|
898
|
+
return {
|
|
899
|
+
ok: false,
|
|
900
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
901
|
+
details: { message: checked.message }
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
return { ok: true, data: checked.data };
|
|
905
|
+
} catch (error) {
|
|
906
|
+
return toolResultFromError(error);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
function emitCliViewOrResult(policy, result, options, writers, emit, initialShown, mediaExitCode = 0) {
|
|
910
|
+
if (!result.ok)
|
|
911
|
+
return emitResult2(result, writers, emit);
|
|
912
|
+
let shown = initialShown ?? result;
|
|
913
|
+
if (options.view) {
|
|
914
|
+
let viewed;
|
|
915
|
+
try {
|
|
916
|
+
viewed = renderCliView2(shown.data, options.view);
|
|
917
|
+
} catch (error) {
|
|
918
|
+
const failure = error instanceof CliArgumentError2 ? { ok: false, code: "BAD_REQUEST", details: { message: error.message } } : toolResultFromError(error);
|
|
919
|
+
return emitPresentationFailure(shown, failure, writers, emit);
|
|
920
|
+
}
|
|
921
|
+
if (viewed.kind === "text") {
|
|
922
|
+
writers.stdout(viewed.text);
|
|
923
|
+
return mediaExitCode;
|
|
924
|
+
}
|
|
925
|
+
if (viewed.order) {
|
|
926
|
+
writers.stdout(`${stringifyGroups(viewed.data, viewed.order, options.json === true)}
|
|
927
|
+
`);
|
|
928
|
+
return mediaExitCode;
|
|
929
|
+
}
|
|
930
|
+
shown = { ...shown, data: viewed.data };
|
|
931
|
+
}
|
|
932
|
+
const activePolicy = options.view === undefined && !options.wait ? policy : undefined;
|
|
933
|
+
const exitCode = emitCliCommandResult(activePolicy, result, options, writers, emit, shown);
|
|
934
|
+
return mediaExitCode || exitCode;
|
|
935
|
+
}
|
|
936
|
+
var IN_PROCESS_RUN_OPTIONS = Object.freeze({
|
|
937
|
+
json: false,
|
|
938
|
+
wait: false,
|
|
939
|
+
quiet: true,
|
|
940
|
+
dryRun: false,
|
|
941
|
+
help: false,
|
|
942
|
+
schema: false
|
|
943
|
+
});
|
|
944
|
+
function shapeCliInvocationResult(result, toolName, config, policy) {
|
|
945
|
+
if (!result.ok) {
|
|
946
|
+
const normalized = toolErrorFromResult(result);
|
|
947
|
+
const hints = [];
|
|
948
|
+
if (result.hint)
|
|
949
|
+
hints.push(result.hint);
|
|
950
|
+
const global = config.errorHint?.(toolName, result.code);
|
|
951
|
+
if (global)
|
|
952
|
+
hints.push(global);
|
|
953
|
+
return {
|
|
954
|
+
ok: false,
|
|
955
|
+
exitCode: cliExitCode2(result, config.exitCodes),
|
|
956
|
+
error: {
|
|
957
|
+
code: result.code,
|
|
958
|
+
message: normalized.message,
|
|
959
|
+
...result.details !== undefined && { details: result.details },
|
|
960
|
+
...hints.length > 0 && { hint: hints.join(" ") },
|
|
961
|
+
...result.retryable !== undefined && { retryable: result.retryable }
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
const data = result.data === undefined ? undefined : projectJsonSafe(result.data).value;
|
|
966
|
+
if (policy === undefined)
|
|
967
|
+
return { ok: true, exitCode: 0, data };
|
|
968
|
+
try {
|
|
969
|
+
return {
|
|
970
|
+
ok: true,
|
|
971
|
+
exitCode: cliCommandSuccessExitCode(policy, result.data),
|
|
972
|
+
data
|
|
973
|
+
};
|
|
974
|
+
} catch (error) {
|
|
975
|
+
return shapeCliInvocationResult(toolResultFromError(new Error("CLI result policy failed", { cause: error })), toolName, config);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
async function executeNativeCommand(definition, rawArgs, coerceJson, globals, target) {
|
|
979
|
+
if (target.mode === "terminal") {
|
|
980
|
+
if (target.options.view !== undefined) {
|
|
981
|
+
if (!cliCommandReturnsResult(definition)) {
|
|
982
|
+
target.writers.stderr(`aggregate views do not apply to native command "${definition.name}" without an output schema
|
|
983
|
+
`);
|
|
984
|
+
return 2;
|
|
985
|
+
}
|
|
986
|
+
try {
|
|
987
|
+
assertViewColumns(target.options.view, definition.output);
|
|
988
|
+
} catch (error) {
|
|
989
|
+
if (!(error instanceof CliArgumentError2))
|
|
990
|
+
throw error;
|
|
991
|
+
target.writers.stderr(`${error.message}
|
|
992
|
+
`);
|
|
993
|
+
return 2;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
const result = await executeCliCommand(definition, rawArgs, target.options, target.writers, coerceJson, globals);
|
|
997
|
+
return emitCliViewOrResult(cliCommandResultPolicy(definition), result, target.options, target.writers, target.emit);
|
|
998
|
+
}
|
|
999
|
+
let out = "";
|
|
1000
|
+
let err = "";
|
|
1001
|
+
const result = await executeCliCommand(definition, rawArgs, IN_PROCESS_RUN_OPTIONS, {
|
|
1002
|
+
stdout: (text) => {
|
|
1003
|
+
out += text;
|
|
1004
|
+
},
|
|
1005
|
+
stderr: (text) => {
|
|
1006
|
+
err += text;
|
|
1007
|
+
}
|
|
1008
|
+
}, coerceJson, globals);
|
|
1009
|
+
const invocation = shapeCliInvocationResult(result, definition.name, target, cliCommandResultPolicy(definition));
|
|
1010
|
+
if (out === "" && err === "")
|
|
1011
|
+
return invocation;
|
|
1012
|
+
return {
|
|
1013
|
+
...invocation,
|
|
1014
|
+
written: { ...out !== "" && { stdout: out }, ...err !== "" && { stderr: err } }
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/tools/cli/args-json.ts
|
|
1019
|
+
function cliFieldOption(option, fields) {
|
|
1020
|
+
const json = option.inline && option.name.endsWith(":") && !fields.has(option.name);
|
|
1021
|
+
const name = json ? option.name.slice(0, -1) : option.name;
|
|
1022
|
+
return { name, json };
|
|
1023
|
+
}
|
|
1024
|
+
function appendCliFieldValue(raw, jsonFields, name, value, info, json) {
|
|
1025
|
+
appendCliOptionValue(raw, name, value, json || jsonFields.has(name) ? { kind: "other" } : info);
|
|
1026
|
+
if (json)
|
|
1027
|
+
jsonFields.add(name);
|
|
1028
|
+
}
|
|
1029
|
+
function coerceCliFieldValue(info, values, label, json) {
|
|
1030
|
+
if (!json)
|
|
1031
|
+
return coerceField(info, values, label);
|
|
1032
|
+
try {
|
|
1033
|
+
return safeJsonParse(values[0] ?? "");
|
|
1034
|
+
} catch (cause) {
|
|
1035
|
+
throw new CliArgumentError2(`${label} expects valid JSON`, { cause });
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// src/tools/cli/args-view.ts
|
|
1040
|
+
function resolveCliView(flags, ascending) {
|
|
1041
|
+
if (flags.size === 0) {
|
|
1042
|
+
if (ascending) {
|
|
1043
|
+
throw new CliArgumentError2("--ascending orders a record view; pass --sort with it");
|
|
1044
|
+
}
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
const countBy = flags.get("count-by");
|
|
1048
|
+
const sum = flags.get("sum");
|
|
1049
|
+
const table = flags.get("table");
|
|
1050
|
+
const by = flags.get("by");
|
|
1051
|
+
const rawTop = flags.get("top");
|
|
1052
|
+
const named = [
|
|
1053
|
+
["--count-by", countBy],
|
|
1054
|
+
["--sum", sum]
|
|
1055
|
+
].filter(([, value]) => value !== undefined);
|
|
1056
|
+
if (named.length > 1) {
|
|
1057
|
+
throw new CliArgumentError2(`${named.map(([flag]) => flag).join(" and ")} ask for different shapes — pass one`);
|
|
1058
|
+
}
|
|
1059
|
+
let top;
|
|
1060
|
+
if (rawTop !== undefined) {
|
|
1061
|
+
top = Number(rawTop);
|
|
1062
|
+
if (!Number.isInteger(top) || top <= 0) {
|
|
1063
|
+
throw new CliArgumentError2("--top must be a positive whole number");
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
const sort = flags.get("sort");
|
|
1067
|
+
if (table !== undefined || sort !== undefined) {
|
|
1068
|
+
if (countBy !== undefined || sum !== undefined) {
|
|
1069
|
+
throw new CliArgumentError2(`${table !== undefined ? "--table" : "--sort"} lists records; --count-by and --sum aggregate them — pass one`);
|
|
1070
|
+
}
|
|
1071
|
+
if (by !== undefined) {
|
|
1072
|
+
throw new CliArgumentError2("--by groups a view; a record view orders with --sort");
|
|
1073
|
+
}
|
|
1074
|
+
if (top !== undefined && sort === undefined) {
|
|
1075
|
+
throw new CliArgumentError2("--top needs --sort here: unordered records have no n largest");
|
|
1076
|
+
}
|
|
1077
|
+
let fields;
|
|
1078
|
+
if (table !== undefined) {
|
|
1079
|
+
fields = table.split(",").map((field) => field.trim()).filter(Boolean);
|
|
1080
|
+
if (fields.length === 0)
|
|
1081
|
+
throw new CliArgumentError2("--table needs at least one field");
|
|
1082
|
+
}
|
|
1083
|
+
return {
|
|
1084
|
+
kind: "records",
|
|
1085
|
+
...sort !== undefined && { sort },
|
|
1086
|
+
...ascending && { ascending },
|
|
1087
|
+
...top !== undefined && { top },
|
|
1088
|
+
...fields && { table: fields }
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
if (ascending) {
|
|
1092
|
+
throw new CliArgumentError2("--ascending orders a record view; pass --sort with it");
|
|
1093
|
+
}
|
|
1094
|
+
if (sum !== undefined) {
|
|
1095
|
+
if (top !== undefined && by === undefined) {
|
|
1096
|
+
throw new CliArgumentError2("--top needs --by: a single sum has nothing to rank");
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
kind: "sum",
|
|
1100
|
+
field: sum,
|
|
1101
|
+
...by !== undefined && { by },
|
|
1102
|
+
...top !== undefined && { top }
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
if (countBy !== undefined) {
|
|
1106
|
+
if (by !== undefined) {
|
|
1107
|
+
throw new CliArgumentError2("--count-by already names the grouping field; drop --by");
|
|
1108
|
+
}
|
|
1109
|
+
return { kind: "count", field: countBy, ...top !== undefined && { top } };
|
|
1110
|
+
}
|
|
1111
|
+
if (by !== undefined) {
|
|
1112
|
+
if (top === undefined) {
|
|
1113
|
+
throw new CliArgumentError2("--by groups a view; pass --count-by, --sum or --top with it");
|
|
1114
|
+
}
|
|
1115
|
+
return { kind: "count", field: by, top };
|
|
1116
|
+
}
|
|
1117
|
+
throw new CliArgumentError2("--top needs --sort, --by, --count-by or --sum to rank");
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// src/tools/cli/args-classify.ts
|
|
1121
|
+
function isOptionToken(token) {
|
|
1122
|
+
return token.startsWith("--") || /^-[A-Za-z](?:=|$)/.test(token);
|
|
1123
|
+
}
|
|
1124
|
+
function looksLikeOption(token) {
|
|
1125
|
+
return token.startsWith("--") || /^-[A-Za-z]/.test(token);
|
|
1126
|
+
}
|
|
1127
|
+
var BOOL_OPTIONS = new Set([
|
|
1128
|
+
"json",
|
|
1129
|
+
"wait",
|
|
1130
|
+
"quiet",
|
|
1131
|
+
"dry-run",
|
|
1132
|
+
"help",
|
|
1133
|
+
"schema",
|
|
1134
|
+
"ascending"
|
|
1135
|
+
]);
|
|
1136
|
+
var VIEW_OPTIONS = new Set(["count-by", "sum", "by", "top", "table", "sort"]);
|
|
1137
|
+
var VALUE_OPTIONS = new Set(["wait-timeout", "output-dir", ...VIEW_OPTIONS]);
|
|
1138
|
+
var RESERVED_CLI_OPTIONS = new Set([...BOOL_OPTIONS, ...VALUE_OPTIONS]);
|
|
1139
|
+
function classifyLongOptionToken(token) {
|
|
1140
|
+
if (!token.startsWith("--") || token === "--")
|
|
1141
|
+
return;
|
|
1142
|
+
const equals = token.indexOf("=");
|
|
1143
|
+
const name = equals >= 0 ? token.slice(2, equals) : token.slice(2);
|
|
1144
|
+
return {
|
|
1145
|
+
name,
|
|
1146
|
+
value: equals >= 0 ? token.slice(equals + 1) : undefined,
|
|
1147
|
+
inline: equals >= 0,
|
|
1148
|
+
globalKind: BOOL_OPTIONS.has(name) ? "boolean" : VALUE_OPTIONS.has(name) ? "value" : undefined
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
var HELP_TOKENS = new Set(["--help", "-h", "help"]);
|
|
1152
|
+
function isCliVersionToken(token) {
|
|
1153
|
+
return token === "--version" || token === "version";
|
|
1154
|
+
}
|
|
1155
|
+
function isOptionShapedToken(token) {
|
|
1156
|
+
return token.startsWith("-") && token !== "-";
|
|
1157
|
+
}
|
|
1158
|
+
function isReservedCliCommandName(name) {
|
|
1159
|
+
return isOptionShapedToken(name) || name === "--" || HELP_TOKENS.has(name) || isCliVersionToken(name) || classifyLongOptionToken(name)?.globalKind !== undefined;
|
|
1160
|
+
}
|
|
1161
|
+
function isTopHelpOption(token) {
|
|
1162
|
+
return token === "--help" || token === "-h" || token.startsWith("--help=") && !isReservedBoolWord(token.slice("--help=".length));
|
|
1163
|
+
}
|
|
1164
|
+
function isOwnLeadingToken(token, appFields) {
|
|
1165
|
+
if (token === undefined || token === "--" || isTopHelpOption(token) || isCliVersionToken(token))
|
|
1166
|
+
return true;
|
|
1167
|
+
const opt = classifyLongOptionToken(token);
|
|
1168
|
+
if (!opt)
|
|
1169
|
+
return false;
|
|
1170
|
+
return opt.globalKind !== undefined || appFields.has(cliFieldOption(opt, appFields).name);
|
|
1171
|
+
}
|
|
1172
|
+
function deferScanError(ctx, error) {
|
|
1173
|
+
ctx.deferredError ??= error;
|
|
1174
|
+
}
|
|
1175
|
+
function recordAppGlobalError(ctx, error) {
|
|
1176
|
+
ctx.appGlobalError ??= error;
|
|
1177
|
+
deferScanError(ctx, error);
|
|
1178
|
+
}
|
|
1179
|
+
function pushRestToken(ctx, token, index) {
|
|
1180
|
+
ctx.withoutGlobals.push(token);
|
|
1181
|
+
ctx.withoutCommand.push(token);
|
|
1182
|
+
ctx.withoutCommandFrom.push(index);
|
|
1183
|
+
}
|
|
1184
|
+
function pushCommandToken(ctx, token, index) {
|
|
1185
|
+
if ((ctx.removedAfterCmdToken || ctx.separatedInput.has(index)) && ctx.commandTokens.length > 0) {
|
|
1186
|
+
ctx.separatedBefore.add(ctx.commandTokens.length);
|
|
1187
|
+
}
|
|
1188
|
+
ctx.removedAfterCmdToken = false;
|
|
1189
|
+
ctx.commandTokens.push(token);
|
|
1190
|
+
pushRestToken(ctx, token, index);
|
|
1191
|
+
}
|
|
1192
|
+
function withoutCommandSeparations(ctx) {
|
|
1193
|
+
const separated = new Set;
|
|
1194
|
+
ctx.withoutCommandFrom.forEach((from, at) => {
|
|
1195
|
+
if (at > 0 && ctx.separatedInput.has(from))
|
|
1196
|
+
separated.add(at);
|
|
1197
|
+
});
|
|
1198
|
+
return separated;
|
|
1199
|
+
}
|
|
1200
|
+
function markCommandTokenRemoved(ctx) {
|
|
1201
|
+
if (ctx.commandFound)
|
|
1202
|
+
ctx.removedAfterCmdToken = true;
|
|
1203
|
+
}
|
|
1204
|
+
function tryReadAppGlobalToken(ctx, index, opt, raw, jsonFields) {
|
|
1205
|
+
if (!opt || opt.globalKind !== undefined)
|
|
1206
|
+
return -1;
|
|
1207
|
+
const appField = cliFieldOption(opt, ctx.appFields);
|
|
1208
|
+
const info = ctx.appFields.get(appField.name);
|
|
1209
|
+
if (!info)
|
|
1210
|
+
return -1;
|
|
1211
|
+
if (ctx.bareBool)
|
|
1212
|
+
ctx.bareBool.removedAfter = true;
|
|
1213
|
+
let { value } = opt;
|
|
1214
|
+
let nextIndex = index;
|
|
1215
|
+
if (value === undefined && info.kind === "boolean") {
|
|
1216
|
+
const sep = separateBoolValue(ctx.argv[index + 1]);
|
|
1217
|
+
if (sep !== undefined)
|
|
1218
|
+
nextIndex++;
|
|
1219
|
+
value = String(sep ?? true);
|
|
1220
|
+
} else if (value === undefined) {
|
|
1221
|
+
const next = ctx.argv[index + 1];
|
|
1222
|
+
if (next === undefined || isOptionToken(next)) {
|
|
1223
|
+
recordAppGlobalError(ctx, new CliArgumentError2(`--${opt.name} requires a value`));
|
|
1224
|
+
return nextIndex;
|
|
1225
|
+
}
|
|
1226
|
+
value = next;
|
|
1227
|
+
nextIndex++;
|
|
1228
|
+
} else if (info.kind === "boolean" && !appField.json) {
|
|
1229
|
+
if (raw.has(appField.name)) {
|
|
1230
|
+
appendCliFieldValue(raw, jsonFields, appField.name, value, info, appField.json);
|
|
1231
|
+
return nextIndex;
|
|
1232
|
+
}
|
|
1233
|
+
try {
|
|
1234
|
+
parseReservedBool(appField.name, value);
|
|
1235
|
+
} catch (error) {
|
|
1236
|
+
if (error instanceof CliArgumentError2)
|
|
1237
|
+
recordAppGlobalError(ctx, error);
|
|
1238
|
+
else
|
|
1239
|
+
throw error;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
appendCliFieldValue(raw, jsonFields, appField.name, value, info, appField.json);
|
|
1243
|
+
return nextIndex;
|
|
1244
|
+
}
|
|
1245
|
+
function reservedJsonTarget(opt) {
|
|
1246
|
+
if (!opt?.inline || !opt.name.endsWith(":"))
|
|
1247
|
+
return;
|
|
1248
|
+
const target = opt.name.slice(0, -1);
|
|
1249
|
+
return RESERVED_CLI_OPTIONS.has(target) ? target : undefined;
|
|
1250
|
+
}
|
|
1251
|
+
function consumeFrameworkOptionToken(argv, index, opt, state, callbacks) {
|
|
1252
|
+
const adjacent = callbacks.adjacent ?? (() => true);
|
|
1253
|
+
const report = (error) => {
|
|
1254
|
+
if (opt.name === "schema") {
|
|
1255
|
+
state.fw.schema = false;
|
|
1256
|
+
state.schemaInvalid = true;
|
|
1257
|
+
} else if (opt.name === "help")
|
|
1258
|
+
state.fw.help = false;
|
|
1259
|
+
callbacks.onError(error);
|
|
1260
|
+
};
|
|
1261
|
+
const record = (name, raw, kind) => {
|
|
1262
|
+
try {
|
|
1263
|
+
appendCliOptionValue(state.fwFlags, name, raw, { kind });
|
|
1264
|
+
return true;
|
|
1265
|
+
} catch (error) {
|
|
1266
|
+
if (error instanceof CliArgumentError2) {
|
|
1267
|
+
report(error);
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
throw error;
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
let nextIdx = index;
|
|
1274
|
+
if (opt.globalKind === "boolean") {
|
|
1275
|
+
const following = argv[index + 1];
|
|
1276
|
+
if (!opt.inline && !adjacent(index + 1) && following !== undefined && separateBoolValue(following) !== undefined) {
|
|
1277
|
+
report(brokenBooleanBoundaryError(opt.name, following));
|
|
1278
|
+
if (opt.name === "help" || opt.name === "schema")
|
|
1279
|
+
return nextIdx;
|
|
1280
|
+
}
|
|
1281
|
+
const nextTok = adjacent(index + 1) ? following : undefined;
|
|
1282
|
+
const sep = opt.inline ? undefined : separateBoolValue(nextTok);
|
|
1283
|
+
if (sep !== undefined && nextTok !== undefined) {
|
|
1284
|
+
nextIdx++;
|
|
1285
|
+
callbacks.onValueToken?.(nextTok);
|
|
1286
|
+
}
|
|
1287
|
+
const rawValue = opt.value ?? String(sep ?? true);
|
|
1288
|
+
if (opt.name !== "help" && !record(opt.name, rawValue, "boolean"))
|
|
1289
|
+
return nextIdx;
|
|
1290
|
+
let enabled;
|
|
1291
|
+
if (opt.inline) {
|
|
1292
|
+
try {
|
|
1293
|
+
enabled = parseReservedBool(opt.name, opt.value ?? "");
|
|
1294
|
+
} catch (error) {
|
|
1295
|
+
if (error instanceof CliArgumentError2) {
|
|
1296
|
+
report(error);
|
|
1297
|
+
return nextIdx;
|
|
1298
|
+
}
|
|
1299
|
+
throw error;
|
|
1300
|
+
}
|
|
1301
|
+
} else {
|
|
1302
|
+
enabled = sep ?? true;
|
|
1303
|
+
}
|
|
1304
|
+
if (!opt.inline && sep === undefined)
|
|
1305
|
+
callbacks.onBareBoolean?.(opt.name);
|
|
1306
|
+
if (opt.name === "dry-run")
|
|
1307
|
+
state.fw.dryRun = enabled;
|
|
1308
|
+
else if (opt.name === "json")
|
|
1309
|
+
state.fw.json = enabled;
|
|
1310
|
+
else if (opt.name === "wait")
|
|
1311
|
+
state.fw.wait = enabled;
|
|
1312
|
+
else if (opt.name === "quiet")
|
|
1313
|
+
state.fw.quiet = enabled;
|
|
1314
|
+
else if (opt.name === "ascending")
|
|
1315
|
+
state.ascending = enabled;
|
|
1316
|
+
else if (opt.name === "schema") {
|
|
1317
|
+
state.fw.schema = !state.schemaInvalid && (state.fw.schema || enabled);
|
|
1318
|
+
} else if (opt.name === "help")
|
|
1319
|
+
state.fw.help = state.fw.help || enabled;
|
|
1320
|
+
return nextIdx;
|
|
1321
|
+
}
|
|
1322
|
+
let value = opt.value;
|
|
1323
|
+
if (!opt.inline) {
|
|
1324
|
+
const next = adjacent(index + 1) ? argv[index + 1] : undefined;
|
|
1325
|
+
if (next === undefined || isOptionToken(next)) {
|
|
1326
|
+
report(new CliArgumentError2(`--${opt.name} requires a value`));
|
|
1327
|
+
if (callbacks.onMissingValue?.(next))
|
|
1328
|
+
nextIdx++;
|
|
1329
|
+
} else {
|
|
1330
|
+
value = next;
|
|
1331
|
+
nextIdx++;
|
|
1332
|
+
callbacks.onValueToken?.(next);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
if (value !== undefined) {
|
|
1336
|
+
if (!record(opt.name, value, "string"))
|
|
1337
|
+
return nextIdx;
|
|
1338
|
+
if (opt.name === "wait-timeout") {
|
|
1339
|
+
const n = Number(value);
|
|
1340
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
1341
|
+
report(new CliArgumentError2("--wait-timeout must be a positive number"));
|
|
1342
|
+
} else {
|
|
1343
|
+
state.fw.waitTimeout = n;
|
|
1344
|
+
}
|
|
1345
|
+
} else if (VIEW_OPTIONS.has(opt.name))
|
|
1346
|
+
state.viewFlags.set(opt.name, value);
|
|
1347
|
+
else
|
|
1348
|
+
state.fw.outputDir = value;
|
|
1349
|
+
}
|
|
1350
|
+
return nextIdx;
|
|
1351
|
+
}
|
|
1352
|
+
function readFrameworkOptionToken(ctx, index, token, opt) {
|
|
1353
|
+
ctx.bareBool = undefined;
|
|
1354
|
+
pushRestToken(ctx, token, index);
|
|
1355
|
+
return consumeFrameworkOptionToken(ctx.argv, index, opt, ctx, {
|
|
1356
|
+
adjacent: (at) => !ctx.separatedInput.has(at),
|
|
1357
|
+
onError: (error) => deferScanError(ctx, error),
|
|
1358
|
+
onValueToken: (valueToken) => pushRestToken(ctx, valueToken, index + 1),
|
|
1359
|
+
onBareBoolean: (name) => {
|
|
1360
|
+
ctx.bareBool = { name, removedAfter: false };
|
|
1361
|
+
},
|
|
1362
|
+
onMissingValue: (next) => {
|
|
1363
|
+
if (!ctx.commandFound && next !== undefined && !isOwnLeadingToken(next, ctx.appFields)) {
|
|
1364
|
+
pushRestToken(ctx, next, index + 1);
|
|
1365
|
+
return true;
|
|
1366
|
+
}
|
|
1367
|
+
return false;
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
function finalizeFrameworkView(ctx) {
|
|
1372
|
+
if (ctx.viewFlags.size === 0 && !ctx.ascending)
|
|
1373
|
+
return;
|
|
1374
|
+
try {
|
|
1375
|
+
ctx.fw.view = resolveCliView(ctx.viewFlags, ctx.ascending);
|
|
1376
|
+
} catch (error) {
|
|
1377
|
+
if (error instanceof CliArgumentError2)
|
|
1378
|
+
deferScanError(ctx, error);
|
|
1379
|
+
else
|
|
1380
|
+
throw error;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
function createFrameworkStepContext(argv, appFields, separatedInput = new Set) {
|
|
1384
|
+
return {
|
|
1385
|
+
argv,
|
|
1386
|
+
appFields,
|
|
1387
|
+
fwFlags: new Map,
|
|
1388
|
+
viewFlags: new Map,
|
|
1389
|
+
fw: { json: false, quiet: false, help: false, schema: false, dryRun: false, wait: false },
|
|
1390
|
+
ascending: false,
|
|
1391
|
+
commandFound: false,
|
|
1392
|
+
withoutGlobals: [],
|
|
1393
|
+
withoutCommand: [],
|
|
1394
|
+
withoutCommandFrom: [],
|
|
1395
|
+
commandTokens: [],
|
|
1396
|
+
separatedBefore: new Set,
|
|
1397
|
+
removedAfterCmdToken: false,
|
|
1398
|
+
separatedInput
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
function coerceAppGlobalMap(raw, fields, jsonFields) {
|
|
1402
|
+
const coerced = {};
|
|
1403
|
+
for (const [name, values] of raw) {
|
|
1404
|
+
coerced[name] = coerceCliFieldValue(fields.get(name), values, `--${name}`, jsonFields.has(name));
|
|
1405
|
+
}
|
|
1406
|
+
return coerced;
|
|
1407
|
+
}
|
|
1408
|
+
function brokenBooleanBoundaryError(flagName, word) {
|
|
1409
|
+
const flag = flagName.startsWith("-") ? flagName : `--${flagName}`;
|
|
1410
|
+
return new CliArgumentError2(`Bare ${flag} cannot be separated from "${word}" — use ${flag}=true, ${flag}=false or "-- ${word}"`);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// src/tools/cli/stream-surface.ts
|
|
1414
|
+
function cliStreamIdentity(serviceName, methodName, method) {
|
|
1415
|
+
if (!method.stream || !method.expose?.includes("CLI"))
|
|
1416
|
+
return;
|
|
1417
|
+
return { name: toToolName(serviceName, methodName), descriptor: method.stream };
|
|
1418
|
+
}
|
|
1419
|
+
function collectCliStreams(services) {
|
|
1420
|
+
const streams = new Map;
|
|
1421
|
+
for (const service of services) {
|
|
1422
|
+
for (const [methodName, method] of Object.entries(service.methods)) {
|
|
1423
|
+
const identity = cliStreamIdentity(service.name, methodName, method);
|
|
1424
|
+
if (identity === undefined)
|
|
1425
|
+
continue;
|
|
1426
|
+
const { name, descriptor } = identity;
|
|
1427
|
+
streams.set(name, {
|
|
1428
|
+
descriptor,
|
|
1429
|
+
tool: {
|
|
1430
|
+
method,
|
|
1431
|
+
name,
|
|
1432
|
+
argumentSchema: mergeSchemas(method.paramsSchema, method.inputSchema),
|
|
1433
|
+
presentationSchema: buildToolPresentationSchema({
|
|
1434
|
+
paramsSchema: method.paramsSchema,
|
|
1435
|
+
inputSchema: method.inputSchema,
|
|
1436
|
+
inputRecursionDepth: method.inputRecursionDepth,
|
|
1437
|
+
unrepresentable: "any"
|
|
1438
|
+
}),
|
|
1439
|
+
shouldExtend: false
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return streams;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// src/tools/cli/command-shape.ts
|
|
1448
|
+
function nativeCliDescriptor(definition) {
|
|
1449
|
+
return {
|
|
1450
|
+
description: definition.description,
|
|
1451
|
+
argumentSchema: definition.input,
|
|
1452
|
+
presentationSchema: cliCommandPresentationSchema(definition),
|
|
1453
|
+
outputSchema: definition.output
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
function assertNoPassthroughAlias(name, descriptor, passthroughField) {
|
|
1457
|
+
if (passthroughField !== undefined && descriptor.aliases.has(passthroughField)) {
|
|
1458
|
+
throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
function invokerCommandShapeIssue(name, descriptor, exists, passthroughField) {
|
|
1462
|
+
assertUniqueToolName(name, exists, "CLI command");
|
|
1463
|
+
assertNoPassthroughAlias(name, descriptor, passthroughField);
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
function assertCliCommandName(name) {
|
|
1467
|
+
if (isReservedCliCommandName(name)) {
|
|
1468
|
+
throw new Error(`[stitchkit] CLI command "${name}" is reserved. Rename the command to a word outside the option syntax.`);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
function assertStaticCliCommandNames(services, runtimeTools) {
|
|
1472
|
+
for (const tool of runtimeTools) {
|
|
1473
|
+
assertNoLegacyTransports(tool, `Runtime tool "${tool.name}"`);
|
|
1474
|
+
if (tool.expose?.includes("CLI"))
|
|
1475
|
+
assertCliCommandName(tool.name);
|
|
1476
|
+
}
|
|
1477
|
+
for (const service of services) {
|
|
1478
|
+
for (const [key, method] of Object.entries(service.methods)) {
|
|
1479
|
+
const name = projectedContractToolName(service.name, key, method, "CLI") ?? cliStreamIdentity(service.name, key, method)?.name;
|
|
1480
|
+
if (name !== undefined)
|
|
1481
|
+
assertCliCommandName(name);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
function commandShapeIssue(name, descriptor, exists, passthroughField, applicationGlobals = new Set) {
|
|
1486
|
+
assertUniqueToolName(name, exists, "CLI command");
|
|
1487
|
+
assertCliCommandName(name);
|
|
1488
|
+
assertNoPassthroughAlias(name, descriptor, passthroughField);
|
|
1489
|
+
const fieldNames = jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name);
|
|
1490
|
+
const conflicting = fieldNames.filter((field) => RESERVED_CLI_OPTIONS.has(field));
|
|
1491
|
+
if (conflicting.length > 0) {
|
|
1492
|
+
return `[stitchkit] CLI command "${name}" declares reserved option field(s): ${conflicting.join(", ")}`;
|
|
1493
|
+
}
|
|
1494
|
+
const shadowed = fieldNames.filter((field) => applicationGlobals.has(field));
|
|
1495
|
+
if (shadowed.length > 0) {
|
|
1496
|
+
return `[stitchkit] CLI command "${name}" declares field(s) shadowed by application global options: ${shadowed.join(", ")}`;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// src/tools/cli/policy.ts
|
|
1501
|
+
var REMOVED_TOP_LEVEL_KEYS = [
|
|
1502
|
+
"optionAliases",
|
|
1503
|
+
"positionals",
|
|
1504
|
+
"results",
|
|
1505
|
+
"passthrough",
|
|
1506
|
+
"wait"
|
|
1507
|
+
];
|
|
1508
|
+
function assertNoLegacyCliPolicyKeys(config) {
|
|
1509
|
+
if (typeof config !== "object" || config === null)
|
|
1510
|
+
return;
|
|
1511
|
+
for (const key of REMOVED_TOP_LEVEL_KEYS) {
|
|
1512
|
+
if (Object.hasOwn(config, key)) {
|
|
1513
|
+
throw new TypeError(`[stitchkit] CLI option "${key}" was moved into "commandSettings.<command>" — migrate to commandSettings`);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
var SHORT_ALIAS = /^[A-Za-z]$/;
|
|
1518
|
+
var RESERVED_SHORT_OPTIONS = new Set(["h"]);
|
|
1519
|
+
function fieldMap(descriptor) {
|
|
1520
|
+
return new Map(jsonSchemaFields(descriptor.presentationSchema).map((field) => [field.name, field]));
|
|
1521
|
+
}
|
|
1522
|
+
function resolveAliases(command, descriptor, configured) {
|
|
1523
|
+
if (!configured)
|
|
1524
|
+
return new Map;
|
|
1525
|
+
const fields = fieldMap(descriptor);
|
|
1526
|
+
const aliases = new Map;
|
|
1527
|
+
for (const [alias, target] of Object.entries(configured)) {
|
|
1528
|
+
if (!SHORT_ALIAS.test(alias)) {
|
|
1529
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "${alias}" must be one ASCII letter`);
|
|
1530
|
+
}
|
|
1531
|
+
if (RESERVED_SHORT_OPTIONS.has(alias)) {
|
|
1532
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" is reserved`);
|
|
1533
|
+
}
|
|
1534
|
+
if (isUnsafeKey(target) || !fields.has(target)) {
|
|
1535
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" targets unknown field "${target}"`);
|
|
1536
|
+
}
|
|
1537
|
+
const existing = aliases.get(target);
|
|
1538
|
+
if (existing !== undefined) {
|
|
1539
|
+
throw new Error(`[stitchkit] CLI command "${command}" field "${target}" has multiple aliases: -${existing}, -${alias}`);
|
|
1540
|
+
}
|
|
1541
|
+
aliases.set(target, alias);
|
|
1542
|
+
}
|
|
1543
|
+
return aliases;
|
|
593
1544
|
}
|
|
594
1545
|
function resolvePositionals(command, descriptor, configured) {
|
|
595
1546
|
if (configured === undefined)
|
|
@@ -618,25 +1569,29 @@ function resolvePositionals(command, descriptor, configured) {
|
|
|
618
1569
|
}
|
|
619
1570
|
return [...configured];
|
|
620
1571
|
}
|
|
1572
|
+
function cliCommandSettingsFor(config, command) {
|
|
1573
|
+
return config.commandSettings && Object.hasOwn(config.commandSettings, command) ? config.commandSettings[command] : undefined;
|
|
1574
|
+
}
|
|
621
1575
|
function cliResultPolicy(config, command) {
|
|
622
|
-
return
|
|
1576
|
+
return cliCommandSettingsFor(config, command)?.result;
|
|
1577
|
+
}
|
|
1578
|
+
function cliPassthroughField(config, command) {
|
|
1579
|
+
return cliCommandSettingsFor(config, command)?.passthrough;
|
|
1580
|
+
}
|
|
1581
|
+
function cliWaitConfig(config, command) {
|
|
1582
|
+
return cliCommandSettingsFor(config, command)?.wait;
|
|
623
1583
|
}
|
|
624
1584
|
function applyCliPresentationPolicy(command, descriptor, config) {
|
|
625
1585
|
const base = { ...descriptor, aliases: new Map };
|
|
626
|
-
const
|
|
627
|
-
const configuredPositionals = config.positionals && Object.hasOwn(config.positionals, command) ? config.positionals[command] : undefined;
|
|
1586
|
+
const settings = cliCommandSettingsFor(config, command);
|
|
628
1587
|
return {
|
|
629
1588
|
...base,
|
|
630
|
-
aliases: resolveAliases(command, base,
|
|
631
|
-
positionals: resolvePositionals(command, base,
|
|
1589
|
+
aliases: resolveAliases(command, base, settings?.aliases),
|
|
1590
|
+
positionals: resolvePositionals(command, base, settings?.positionals)
|
|
632
1591
|
};
|
|
633
1592
|
}
|
|
634
1593
|
function assertCliPoliciesResolved(commands, config) {
|
|
635
|
-
const configuredNames = new Set(
|
|
636
|
-
...Object.keys(config.optionAliases ?? {}),
|
|
637
|
-
...Object.keys(config.positionals ?? {}),
|
|
638
|
-
...Object.keys(config.results ?? {})
|
|
639
|
-
]);
|
|
1594
|
+
const configuredNames = new Set(Object.keys(config.commandSettings ?? {}));
|
|
640
1595
|
if (config.defaultCommand !== undefined)
|
|
641
1596
|
configuredNames.add(config.defaultCommand);
|
|
642
1597
|
for (const name of configuredNames) {
|
|
@@ -646,100 +1601,205 @@ function assertCliPoliciesResolved(commands, config) {
|
|
|
646
1601
|
}
|
|
647
1602
|
}
|
|
648
1603
|
|
|
649
|
-
// src/tools/cli/
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
1604
|
+
// src/tools/cli/unix-outcome.ts
|
|
1605
|
+
var MAX_CAUSE_DEPTH = 16;
|
|
1606
|
+
var UNIX_ERROR_CODES = new Set(UNIX_CLIENT_TRANSPORT_ERROR_CODES);
|
|
1607
|
+
var UNIX_DELIVERY_STATES = new Set(UNIX_CLIENT_DELIVERY_STATES);
|
|
1608
|
+
function ownString(value, key) {
|
|
1609
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
1610
|
+
return descriptor && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : undefined;
|
|
1611
|
+
}
|
|
1612
|
+
function isUnixErrorCode(value) {
|
|
1613
|
+
return value !== undefined && UNIX_ERROR_CODES.has(value);
|
|
1614
|
+
}
|
|
1615
|
+
function isUnixDeliveryState(value) {
|
|
1616
|
+
return value !== undefined && UNIX_DELIVERY_STATES.has(value);
|
|
1617
|
+
}
|
|
1618
|
+
function findUnixTransportError(root) {
|
|
1619
|
+
const visited = new Set;
|
|
1620
|
+
let current = root;
|
|
1621
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH && current !== undefined; depth += 1) {
|
|
1622
|
+
if (typeof current !== "object" || current === null || visited.has(current))
|
|
1623
|
+
return;
|
|
1624
|
+
visited.add(current);
|
|
1625
|
+
if (current instanceof Error && ownString(current, "name") === UNIX_CLIENT_TRANSPORT_ERROR_NAME) {
|
|
1626
|
+
const code = ownString(current, "code");
|
|
1627
|
+
const delivery = ownString(current, "delivery");
|
|
1628
|
+
if (isUnixErrorCode(code) && isUnixDeliveryState(delivery)) {
|
|
1629
|
+
const inner = current.cause;
|
|
1630
|
+
const causeCode = typeof inner === "object" && inner !== null ? ownString(inner, "code") : undefined;
|
|
1631
|
+
const causePath = typeof inner === "object" && inner !== null ? ownString(inner, "path") : undefined;
|
|
1632
|
+
const socketPath = ownString(current, "socketPath") ?? causePath;
|
|
1633
|
+
return {
|
|
1634
|
+
code,
|
|
1635
|
+
delivery,
|
|
1636
|
+
message: current.message,
|
|
1637
|
+
...causeCode !== undefined && { causeCode },
|
|
1638
|
+
...socketPath !== undefined && { socketPath }
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
677
1641
|
}
|
|
1642
|
+
current = "cause" in current ? Reflect.get(current, "cause") : undefined;
|
|
678
1643
|
}
|
|
679
|
-
return
|
|
1644
|
+
return;
|
|
680
1645
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
return
|
|
686
|
-
|
|
1646
|
+
function notDispatchedMessage(found) {
|
|
1647
|
+
if (found.code === "UNIX_CONNECT_FAILED") {
|
|
1648
|
+
const target = found.socketPath ? `"${found.socketPath}"` : "the unix socket";
|
|
1649
|
+
const suffix = found.causeCode ? ` (${found.causeCode})` : "";
|
|
1650
|
+
return `Not executed: application is not listening on ${target}${suffix}`;
|
|
1651
|
+
}
|
|
1652
|
+
if (found.code === "UNIX_TARGET_REFUSED") {
|
|
1653
|
+
return `Not executed: unix socket target refused — ${found.message}`;
|
|
1654
|
+
}
|
|
1655
|
+
return `Not executed: ${found.message}`;
|
|
687
1656
|
}
|
|
688
|
-
function
|
|
689
|
-
if (
|
|
690
|
-
return
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
1657
|
+
function notDispatchedHint(code) {
|
|
1658
|
+
if (code === "UNIX_CONNECT_FAILED") {
|
|
1659
|
+
return "The request was not executed because the application is not listening; start the application and retry.";
|
|
1660
|
+
}
|
|
1661
|
+
if (code === "UNIX_TARGET_REFUSED") {
|
|
1662
|
+
return "The request was not executed; check the unix socket path, owner and directory permissions.";
|
|
1663
|
+
}
|
|
1664
|
+
return "The request was not dispatched to the application.";
|
|
1665
|
+
}
|
|
1666
|
+
function projectCliUnixFailure(result) {
|
|
1667
|
+
const found = findUnixTransportError(toolCauseFromResult(result));
|
|
1668
|
+
if (!found)
|
|
1669
|
+
return result;
|
|
1670
|
+
if (found.delivery === "not-dispatched") {
|
|
1671
|
+
return {
|
|
1672
|
+
ok: false,
|
|
1673
|
+
code: found.code,
|
|
1674
|
+
details: {
|
|
1675
|
+
message: notDispatchedMessage(found),
|
|
1676
|
+
delivery: "not-dispatched",
|
|
1677
|
+
...found.socketPath !== undefined && { socketPath: found.socketPath },
|
|
1678
|
+
...found.causeCode !== undefined && { errno: found.causeCode }
|
|
1679
|
+
},
|
|
1680
|
+
hint: notDispatchedHint(found.code),
|
|
1681
|
+
retryable: found.code === "UNIX_CONNECT_FAILED"
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
if (found.delivery === "possibly-dispatched") {
|
|
1685
|
+
const code = found.code === "UNIX_HEADERS_TIMEOUT" ? "UNIX_HEADERS_TIMEOUT" : "UNIX_DELIVERY_UNCERTAIN";
|
|
1686
|
+
const message = found.code === "UNIX_HEADERS_TIMEOUT" ? `Outcome unknown, not retried: ${found.message}` : `Outcome unknown, not retried: connection closed after the request was sent (${found.message})`;
|
|
1687
|
+
return {
|
|
1688
|
+
ok: false,
|
|
1689
|
+
code,
|
|
1690
|
+
details: {
|
|
1691
|
+
message,
|
|
1692
|
+
delivery: "possibly-dispatched",
|
|
1693
|
+
...found.socketPath !== undefined && { socketPath: found.socketPath }
|
|
1694
|
+
},
|
|
1695
|
+
hint: "The request may have been executed by the application before the connection closed; inspect state before retrying.",
|
|
1696
|
+
retryable: false
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
698
1699
|
return {
|
|
699
1700
|
ok: false,
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
...result.retryable !== undefined && { retryable: result.retryable }
|
|
707
|
-
}
|
|
1701
|
+
code: found.code,
|
|
1702
|
+
details: {
|
|
1703
|
+
message: found.message,
|
|
1704
|
+
delivery: "response-received"
|
|
1705
|
+
},
|
|
1706
|
+
retryable: false
|
|
708
1707
|
};
|
|
709
1708
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
1709
|
+
|
|
1710
|
+
// src/tools/cli/runner.ts
|
|
1711
|
+
function assertCliAuthConfig(config) {
|
|
1712
|
+
if (config.auth !== undefined && config.resolveAuth !== undefined) {
|
|
1713
|
+
throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
function resolveCliIdentity(config, typedGlobals) {
|
|
1717
|
+
let authPromise;
|
|
1718
|
+
return () => {
|
|
1719
|
+
authPromise ??= (async () => config.resolveAuth ? await config.resolveAuth(typedGlobals) : await config.auth)();
|
|
1720
|
+
return authPromise;
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
function createCliToolRunner(config, lifecycle, auth, typedGlobals) {
|
|
1724
|
+
const run = createToolRunner({
|
|
720
1725
|
source: "cli",
|
|
721
1726
|
toolSurface: true,
|
|
722
1727
|
context: { ...config.context?.(auth, typedGlobals), signal: config.signal },
|
|
723
1728
|
hooks: config.hooks,
|
|
724
|
-
lifecycle
|
|
1729
|
+
lifecycle,
|
|
725
1730
|
coerceJsonArgs: config.coerceJsonArgs
|
|
726
1731
|
});
|
|
1732
|
+
return async (tool, rawArgs, context, call) => {
|
|
1733
|
+
const result = await run(tool, rawArgs, context, call);
|
|
1734
|
+
return result.ok ? result : projectCliUnixFailure(result);
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// src/tools/cli/unavailable.ts
|
|
1739
|
+
function unavailableCommand(reason) {
|
|
1740
|
+
return toolResultFromError(new AppError2("CLI_COMMAND_UNAVAILABLE", {
|
|
1741
|
+
message: reason,
|
|
1742
|
+
status: STITCH_ERROR_STATUS2.CLI_COMMAND_UNAVAILABLE,
|
|
1743
|
+
retryable: false
|
|
1744
|
+
}));
|
|
1745
|
+
}
|
|
1746
|
+
function unknownCliCommand(command) {
|
|
1747
|
+
return {
|
|
1748
|
+
ok: false,
|
|
1749
|
+
code: "UNKNOWN_OPERATION",
|
|
1750
|
+
details: { message: `Unknown command "${command}"`, operation: command }
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
// src/tools/cli/invoke.ts
|
|
1755
|
+
function cliInvocationResult2(result, toolName, config) {
|
|
1756
|
+
return shapeCliInvocationResult(result, toolName, config);
|
|
1757
|
+
}
|
|
1758
|
+
async function createCliInvoker2(config, globals) {
|
|
1759
|
+
const lifecycle = resolveOptionalCliToolAccess("createCliInvoker", config);
|
|
1760
|
+
assertNoLegacyCliPolicyKeys(config);
|
|
1761
|
+
assertCliAuthConfig(config);
|
|
1762
|
+
const typedGlobals = parseCliGlobalValues(config.globalOptions, globals);
|
|
1763
|
+
const hasManagedFactory = typeof config.services === "function" || typeof config.runtimeTools === "function";
|
|
1764
|
+
const auth = hasManagedFactory || !isInspectOnlyLifecycle(lifecycle) ? await resolveCliIdentity(config, typedGlobals)() : undefined;
|
|
1765
|
+
const natives = new Map;
|
|
1766
|
+
const allNativeHelp = new Map;
|
|
1767
|
+
for (const definition of config.commands ?? []) {
|
|
1768
|
+
const descriptor = applyCliPresentationPolicy(definition.name, nativeCliDescriptor(definition), config);
|
|
1769
|
+
invokerCommandShapeIssue(definition.name, descriptor, allNativeHelp.has(definition.name), cliPassthroughField(config, definition.name));
|
|
1770
|
+
allNativeHelp.set(definition.name, descriptor);
|
|
1771
|
+
if (cliCommandReturnsResult(definition))
|
|
1772
|
+
natives.set(definition.name, definition);
|
|
1773
|
+
}
|
|
1774
|
+
const { tools, help } = buildCliSurface(config, auth, typedGlobals, allNativeHelp, new Set, invokerCommandShapeIssue);
|
|
1775
|
+
const runTool = isInspectOnlyLifecycle(lifecycle) ? undefined : createCliToolRunner(config, lifecycle, auth, typedGlobals);
|
|
727
1776
|
return {
|
|
728
|
-
commands: [
|
|
729
|
-
name,
|
|
730
|
-
|
|
731
|
-
|
|
1777
|
+
commands: [
|
|
1778
|
+
...[...natives].map(([name, definition]) => ({
|
|
1779
|
+
name,
|
|
1780
|
+
description: definition.description
|
|
1781
|
+
})),
|
|
1782
|
+
...[...help].filter(([name, presentation]) => !allNativeHelp.has(name) && presentation.unavailableReason === undefined).map(([name, presentation]) => ({
|
|
1783
|
+
name,
|
|
1784
|
+
description: presentation.description
|
|
1785
|
+
}))
|
|
1786
|
+
],
|
|
732
1787
|
invoke: async (command, args) => {
|
|
733
1788
|
const native = natives.get(command);
|
|
734
|
-
if (native)
|
|
735
|
-
return
|
|
1789
|
+
if (native) {
|
|
1790
|
+
return executeNativeCommand(native, args, config.coerceJsonArgs ?? true, typedGlobals, {
|
|
1791
|
+
mode: "in-process",
|
|
1792
|
+
errorHint: config.errorHint,
|
|
1793
|
+
exitCodes: config.exitCodes
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
736
1796
|
const tool = tools.get(command);
|
|
737
1797
|
if (!tool) {
|
|
738
|
-
return cliInvocationResult2(
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
1798
|
+
return cliInvocationResult2(unknownCliCommand(command), command, config);
|
|
1799
|
+
}
|
|
1800
|
+
const inspectErr = inspectOnlyError(lifecycle);
|
|
1801
|
+
if (inspectErr || !runTool) {
|
|
1802
|
+
return shapeCliInvocationResult(toolResultFromError(inspectErr ?? new Error("Inspect-only surface refuses execution")), command, config, cliResultPolicy(config, command));
|
|
743
1803
|
}
|
|
744
1804
|
let result;
|
|
745
1805
|
try {
|
|
@@ -747,48 +1807,15 @@ async function createCliInvoker2(config, globals) {
|
|
|
747
1807
|
} catch (error) {
|
|
748
1808
|
result = toolResultFromError(error);
|
|
749
1809
|
}
|
|
750
|
-
return
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
function withSuccessExitCode(invocation, policy, result, command, config) {
|
|
755
|
-
if (!result.ok || policy === undefined)
|
|
756
|
-
return invocation;
|
|
757
|
-
try {
|
|
758
|
-
return { ...invocation, exitCode: cliCommandSuccessExitCode(policy, result.data) };
|
|
759
|
-
} catch (error) {
|
|
760
|
-
return cliInvocationResult2(toolResultFromError(new Error("CLI result policy failed", { cause: error })), command, config);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
var IN_PROCESS_RUN_OPTIONS = Object.freeze({
|
|
764
|
-
json: false,
|
|
765
|
-
wait: false,
|
|
766
|
-
quiet: true,
|
|
767
|
-
dryRun: false,
|
|
768
|
-
help: false
|
|
769
|
-
});
|
|
770
|
-
async function runNativeCommand(definition, args, config, globals) {
|
|
771
|
-
let out = "";
|
|
772
|
-
let err = "";
|
|
773
|
-
const result = await executeCliCommand(definition, args, IN_PROCESS_RUN_OPTIONS, {
|
|
774
|
-
stdout: (text) => {
|
|
775
|
-
out += text;
|
|
776
|
-
},
|
|
777
|
-
stderr: (text) => {
|
|
778
|
-
err += text;
|
|
1810
|
+
return shapeCliInvocationResult(result, command, config, cliResultPolicy(config, command));
|
|
779
1811
|
}
|
|
780
|
-
}, config.coerceJsonArgs ?? true, globals);
|
|
781
|
-
const invocation = withSuccessExitCode(cliInvocationResult2(result, definition.name, config), cliCommandResultPolicy(definition), result, definition.name, config);
|
|
782
|
-
if (out === "" && err === "")
|
|
783
|
-
return invocation;
|
|
784
|
-
return {
|
|
785
|
-
...invocation,
|
|
786
|
-
written: { ...out !== "" && { stdout: out }, ...err !== "" && { stderr: err } }
|
|
787
1812
|
};
|
|
788
1813
|
}
|
|
789
|
-
function buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, shapeIssue) {
|
|
790
|
-
|
|
791
|
-
|
|
1814
|
+
function buildCliSurface(config, auth, typedGlobals, nativeHelp, applicationGlobalNames, shapeIssue) {
|
|
1815
|
+
resolveOptionalCliToolAccess("buildCliSurface", config);
|
|
1816
|
+
assertNoLegacyCliPolicyKeys(config);
|
|
1817
|
+
const services = typeof config.services === "function" ? config.services(auth, typedGlobals) : config.services ?? [];
|
|
1818
|
+
const runtimeTools = typeof config.runtimeTools === "function" ? config.runtimeTools(auth, typedGlobals) : config.runtimeTools ?? [];
|
|
792
1819
|
const tools = new Map;
|
|
793
1820
|
const help = new Map(nativeHelp);
|
|
794
1821
|
for (const { kind, mountable } of collectToolSurface({
|
|
@@ -796,7 +1823,7 @@ function buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, shape
|
|
|
796
1823
|
transport: "CLI"
|
|
797
1824
|
})) {
|
|
798
1825
|
const descriptor = applyCliPresentationPolicy(mountable.name, managedCliDescriptor(mountable), config);
|
|
799
|
-
const issue = shapeIssue?.(mountable.name, descriptor, help.has(mountable.name), config
|
|
1826
|
+
const issue = shapeIssue?.(mountable.name, descriptor, help.has(mountable.name), cliPassthroughField(config, mountable.name), applicationGlobalNames);
|
|
800
1827
|
if (issue !== undefined) {
|
|
801
1828
|
if (kind !== "runtime")
|
|
802
1829
|
throw new Error(issue);
|
|
@@ -813,13 +1840,16 @@ function buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, shape
|
|
|
813
1840
|
outputSchema: stream.descriptor.item,
|
|
814
1841
|
stream: true
|
|
815
1842
|
}, config);
|
|
816
|
-
const issue = shapeIssue?.(name, descriptor, help.has(name), config
|
|
1843
|
+
const issue = shapeIssue?.(name, descriptor, help.has(name), cliPassthroughField(config, name), applicationGlobalNames);
|
|
817
1844
|
if (issue !== undefined)
|
|
818
1845
|
throw new Error(issue);
|
|
819
1846
|
help.set(name, descriptor);
|
|
820
1847
|
}
|
|
821
1848
|
assertCliPoliciesResolved(help, config);
|
|
822
|
-
for (const [name,
|
|
1849
|
+
for (const [name, settings] of Object.entries(config.commandSettings ?? {})) {
|
|
1850
|
+
const policy = settings?.result;
|
|
1851
|
+
if (!policy)
|
|
1852
|
+
continue;
|
|
823
1853
|
if (!tools.has(name) && !streams.has(name)) {
|
|
824
1854
|
throw new Error(`[stitchkit] CLI result policy "${name}" targets a command that is not managed; a native command declares present and exitCode on defineCliCommand`);
|
|
825
1855
|
}
|
|
@@ -890,7 +1920,8 @@ function readPipedStdin(input = process.stdin) {
|
|
|
890
1920
|
|
|
891
1921
|
// src/tools/cli/io.ts
|
|
892
1922
|
function isReaderGone(error) {
|
|
893
|
-
|
|
1923
|
+
const code = errnoOf(error);
|
|
1924
|
+
return code === "EPIPE" || code === "ERR_STREAM_DESTROYED";
|
|
894
1925
|
}
|
|
895
1926
|
function createCliIo(config) {
|
|
896
1927
|
let pendingWrite;
|
|
@@ -904,7 +1935,7 @@ function createCliIo(config) {
|
|
|
904
1935
|
} catch (error) {
|
|
905
1936
|
if (fd === 1 && isReaderGone(error))
|
|
906
1937
|
throw error;
|
|
907
|
-
if (
|
|
1938
|
+
if (errnoOf(error) === "EAGAIN") {
|
|
908
1939
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1);
|
|
909
1940
|
continue;
|
|
910
1941
|
}
|
|
@@ -953,159 +1984,259 @@ function createCliIo(config) {
|
|
|
953
1984
|
// src/tools/cli/notices.ts
|
|
954
1985
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
955
1986
|
|
|
956
|
-
// src/tools/cli/args-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
"json",
|
|
965
|
-
"wait",
|
|
966
|
-
"quiet",
|
|
967
|
-
"dry-run",
|
|
968
|
-
"help",
|
|
969
|
-
"schema",
|
|
970
|
-
"ascending"
|
|
971
|
-
]);
|
|
972
|
-
var VIEW_OPTIONS = new Set(["count-by", "sum", "by", "top", "table", "sort"]);
|
|
973
|
-
var VALUE_OPTIONS = new Set(["wait-timeout", "output-dir", ...VIEW_OPTIONS]);
|
|
974
|
-
var RESERVED_CLI_OPTIONS = new Set([...BOOL_OPTIONS, ...VALUE_OPTIONS]);
|
|
975
|
-
function classifyLongOptionToken(token) {
|
|
976
|
-
if (!token.startsWith("--") || token === "--")
|
|
1987
|
+
// src/tools/cli/args-scan.ts
|
|
1988
|
+
var EMPTY_FIELDS = new Map;
|
|
1989
|
+
function optionBeforeCommandError(token) {
|
|
1990
|
+
const name = token.split("=")[0] ?? token;
|
|
1991
|
+
return new CliArgumentError2(`${name} is an option of a command, not a command: put it after the command name (<command> ${token})`);
|
|
1992
|
+
}
|
|
1993
|
+
function bareOptionInfo(token) {
|
|
1994
|
+
if (token === undefined || token === "--" || token === "-h")
|
|
977
1995
|
return;
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
};
|
|
1996
|
+
const opt = classifyLongOptionToken(token);
|
|
1997
|
+
if (opt) {
|
|
1998
|
+
return opt.inline ? undefined : { name: opt.name, frameworkBool: opt.globalKind === "boolean" };
|
|
1999
|
+
}
|
|
2000
|
+
if (/^-[A-Za-z]$/.test(token))
|
|
2001
|
+
return { name: token, frameworkBool: false };
|
|
2002
|
+
return;
|
|
986
2003
|
}
|
|
987
|
-
function
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
2004
|
+
function withdrawBrokenRequest(ctx, name) {
|
|
2005
|
+
if (name === "schema") {
|
|
2006
|
+
ctx.fw.schema = false;
|
|
2007
|
+
ctx.schemaInvalid = true;
|
|
2008
|
+
} else if (name === "help")
|
|
2009
|
+
ctx.fw.help = false;
|
|
2010
|
+
}
|
|
2011
|
+
function scanCliArgv(argv, options = {}) {
|
|
2012
|
+
const { appGlobals, defaultCommand } = options;
|
|
2013
|
+
const appFields = appGlobals ? describeSchemaFields(appGlobals) : EMPTY_FIELDS;
|
|
2014
|
+
const ctx = createFrameworkStepContext(argv, appFields, options.separatedBefore);
|
|
2015
|
+
ctx.commandFound = options.afterCommand === true;
|
|
2016
|
+
const appRaw = new Map;
|
|
2017
|
+
const appJson = new Set;
|
|
2018
|
+
const separatedBeforeGlobals = new Set;
|
|
2019
|
+
let command;
|
|
2020
|
+
let topLevelHelp = false;
|
|
2021
|
+
let expectHelpFilter = false;
|
|
2022
|
+
let helpFilter;
|
|
2023
|
+
let version = false;
|
|
2024
|
+
let optionsEnded = false;
|
|
2025
|
+
let separatorBeforeCommand = false;
|
|
2026
|
+
let optionBeforeCommand;
|
|
2027
|
+
let leadingToken;
|
|
2028
|
+
let hadLeadingPrefix = false;
|
|
2029
|
+
let boundaryError;
|
|
2030
|
+
const boundarySeparatedBefore = new Set;
|
|
2031
|
+
let liftedBoundaryError;
|
|
2032
|
+
let liftedAfter;
|
|
2033
|
+
for (let i = 0;i < argv.length; i++) {
|
|
2034
|
+
const token = argv[i];
|
|
992
2035
|
if (token === undefined)
|
|
993
2036
|
continue;
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
2037
|
+
const bareBefore = liftedAfter;
|
|
2038
|
+
liftedAfter = undefined;
|
|
2039
|
+
if (optionsEnded) {
|
|
2040
|
+
pushCommandToken(ctx, token, i);
|
|
2041
|
+
continue;
|
|
2042
|
+
}
|
|
2043
|
+
if (token === "--") {
|
|
2044
|
+
ctx.bareBool = undefined;
|
|
2045
|
+
optionsEnded = true;
|
|
2046
|
+
if (!ctx.commandFound && !topLevelHelp && !version) {
|
|
2047
|
+
separatorBeforeCommand = true;
|
|
2048
|
+
deferScanError(ctx, new CliArgumentError2('A command is required before "--"'));
|
|
2049
|
+
pushRestToken(ctx, token, i);
|
|
2050
|
+
} else {
|
|
2051
|
+
pushCommandToken(ctx, token, i);
|
|
2052
|
+
}
|
|
2053
|
+
continue;
|
|
2054
|
+
}
|
|
2055
|
+
const opt = classifyLongOptionToken(token);
|
|
2056
|
+
const appNext = tryReadAppGlobalToken(ctx, i, opt, appRaw, appJson);
|
|
2057
|
+
if (appNext >= 0) {
|
|
2058
|
+
liftedAfter = bareBefore ?? bareOptionInfo(ctx.withoutGlobals.at(-1));
|
|
2059
|
+
markCommandTokenRemoved(ctx);
|
|
2060
|
+
i = appNext;
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
if (bareBefore !== undefined) {
|
|
2064
|
+
if (bareBefore.frameworkBool && separateBoolValue(token) !== undefined) {
|
|
2065
|
+
liftedBoundaryError ??= brokenBooleanBoundaryError(bareBefore.name, token);
|
|
2066
|
+
withdrawBrokenRequest(ctx, bareBefore.name);
|
|
2067
|
+
deferScanError(ctx, liftedBoundaryError);
|
|
2068
|
+
separatedBeforeGlobals.add(ctx.withoutGlobals.length);
|
|
2069
|
+
} else if (!bareBefore.frameworkBool && !isOptionToken(token)) {
|
|
2070
|
+
separatedBeforeGlobals.add(ctx.withoutGlobals.length);
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
if (!ctx.commandFound && !topLevelHelp && !version && (isTopHelpOption(token) || token === "help" || isCliVersionToken(token))) {
|
|
2074
|
+
ctx.bareBool = undefined;
|
|
2075
|
+
leadingToken = token;
|
|
2076
|
+
hadLeadingPrefix = ctx.withoutGlobals.length > 0;
|
|
2077
|
+
ctx.withoutGlobals.push(token);
|
|
2078
|
+
if (isCliVersionToken(token))
|
|
2079
|
+
version = true;
|
|
2080
|
+
else {
|
|
2081
|
+
topLevelHelp = true;
|
|
2082
|
+
if (token.startsWith("--help=")) {
|
|
2083
|
+
helpFilter = token.slice("--help=".length).trim() || undefined;
|
|
2084
|
+
} else
|
|
2085
|
+
expectHelpFilter = true;
|
|
2086
|
+
}
|
|
2087
|
+
continue;
|
|
2088
|
+
}
|
|
2089
|
+
if (token === "-h") {
|
|
2090
|
+
ctx.bareBool = undefined;
|
|
2091
|
+
ctx.fw.help = true;
|
|
2092
|
+
markCommandTokenRemoved(ctx);
|
|
2093
|
+
pushRestToken(ctx, token, i);
|
|
2094
|
+
continue;
|
|
2095
|
+
}
|
|
2096
|
+
const jsonTarget = reservedJsonTarget(opt);
|
|
2097
|
+
if (jsonTarget !== undefined) {
|
|
2098
|
+
ctx.bareBool = undefined;
|
|
2099
|
+
if (jsonTarget === "schema") {
|
|
2100
|
+
ctx.fw.schema = false;
|
|
2101
|
+
ctx.schemaInvalid = true;
|
|
2102
|
+
} else if (jsonTarget === "help")
|
|
2103
|
+
ctx.fw.help = false;
|
|
2104
|
+
deferScanError(ctx, new CliArgumentError2(`--${jsonTarget} is a framework option and does not accept :=JSON`));
|
|
2105
|
+
markCommandTokenRemoved(ctx);
|
|
2106
|
+
pushRestToken(ctx, token, i);
|
|
2107
|
+
continue;
|
|
2108
|
+
}
|
|
2109
|
+
if (opt?.globalKind !== undefined) {
|
|
2110
|
+
markCommandTokenRemoved(ctx);
|
|
2111
|
+
i = readFrameworkOptionToken(ctx, i, token, opt);
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
if (topLevelHelp || version) {
|
|
2115
|
+
if (topLevelHelp && expectHelpFilter) {
|
|
2116
|
+
expectHelpFilter = false;
|
|
2117
|
+
if (!token.startsWith("-"))
|
|
2118
|
+
helpFilter = token;
|
|
2119
|
+
}
|
|
2120
|
+
pushRestToken(ctx, token, i);
|
|
998
2121
|
continue;
|
|
999
|
-
|
|
1000
|
-
if (
|
|
1001
|
-
|
|
2122
|
+
}
|
|
2123
|
+
if (!ctx.commandFound) {
|
|
2124
|
+
if (defaultCommand !== undefined && isOptionShapedToken(token)) {
|
|
2125
|
+
command = defaultCommand;
|
|
2126
|
+
ctx.commandFound = true;
|
|
2127
|
+
} else if (isOptionShapedToken(token)) {
|
|
2128
|
+
optionBeforeCommand ??= optionBeforeCommandError(token);
|
|
2129
|
+
deferScanError(ctx, optionBeforeCommand);
|
|
2130
|
+
pushRestToken(ctx, token, i);
|
|
2131
|
+
continue;
|
|
2132
|
+
} else {
|
|
2133
|
+
command = token;
|
|
2134
|
+
ctx.commandFound = true;
|
|
2135
|
+
ctx.withoutGlobals.push(token);
|
|
2136
|
+
if (ctx.bareBool)
|
|
2137
|
+
ctx.bareBool.removedAfter = true;
|
|
2138
|
+
continue;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
if (ctx.bareBool?.removedAfter && separateBoolValue(token) !== undefined) {
|
|
2142
|
+
withdrawBrokenRequest(ctx, ctx.bareBool.name);
|
|
2143
|
+
boundaryError ??= brokenBooleanBoundaryError(ctx.bareBool.name, token);
|
|
2144
|
+
deferScanError(ctx, boundaryError);
|
|
2145
|
+
boundarySeparatedBefore.add(ctx.withoutCommand.length);
|
|
2146
|
+
}
|
|
2147
|
+
ctx.bareBool = undefined;
|
|
2148
|
+
pushCommandToken(ctx, token, i);
|
|
1002
2149
|
}
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
2150
|
+
finalizeFrameworkView(ctx);
|
|
2151
|
+
let globals = parseCliGlobalValues(undefined, {});
|
|
2152
|
+
try {
|
|
2153
|
+
const rawGlobals = coerceAppGlobalMap(appRaw, appFields, appJson);
|
|
2154
|
+
globals = parseCliGlobalValues(appGlobals, rawGlobals);
|
|
2155
|
+
} catch (error) {
|
|
2156
|
+
if (error instanceof CliArgumentError2)
|
|
2157
|
+
recordAppGlobalError(ctx, error);
|
|
2158
|
+
else
|
|
2159
|
+
throw error;
|
|
1012
2160
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
function isReservedCliCommandName(name) {
|
|
1019
|
-
return name === "--" || HELP_TOKENS.has(name) || isCliVersionToken(name) || classifyLongOptionToken(name)?.globalKind !== undefined;
|
|
1020
|
-
}
|
|
1021
|
-
function helpFilterFrom(token, rest) {
|
|
1022
|
-
if (token?.startsWith("--help=")) {
|
|
1023
|
-
const value = token.slice("--help=".length).trim();
|
|
1024
|
-
if (value.length === 0 || isReservedBoolWord(value))
|
|
1025
|
-
return;
|
|
1026
|
-
return value;
|
|
2161
|
+
if (!ctx.commandFound && !topLevelHelp && !version && !separatorBeforeCommand) {
|
|
2162
|
+
if (defaultCommand !== undefined)
|
|
2163
|
+
command = defaultCommand;
|
|
2164
|
+
else if (ctx.deferredError === undefined || ctx.fw.help)
|
|
2165
|
+
topLevelHelp = true;
|
|
1027
2166
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
2167
|
+
return {
|
|
2168
|
+
framework: ctx.fw,
|
|
2169
|
+
globals,
|
|
2170
|
+
...command !== undefined && { command },
|
|
2171
|
+
commandTokens: ctx.commandTokens,
|
|
2172
|
+
separatedBefore: ctx.separatedBefore,
|
|
2173
|
+
topLevelHelp,
|
|
2174
|
+
...helpFilter !== undefined && { helpFilter },
|
|
2175
|
+
version,
|
|
2176
|
+
withoutGlobals: ctx.withoutGlobals,
|
|
2177
|
+
withoutCommand: ctx.withoutCommand,
|
|
2178
|
+
withoutCommandSeparatedBefore: withoutCommandSeparations(ctx),
|
|
2179
|
+
separatedBeforeGlobals,
|
|
2180
|
+
...ctx.deferredError !== undefined && { deferredError: ctx.deferredError },
|
|
2181
|
+
...ctx.appGlobalError !== undefined && { appGlobalError: ctx.appGlobalError },
|
|
2182
|
+
...boundaryError !== undefined && { boundaryError },
|
|
2183
|
+
boundarySeparatedBefore,
|
|
2184
|
+
...liftedBoundaryError !== undefined && { liftedBoundaryError },
|
|
2185
|
+
separatorBeforeCommand,
|
|
2186
|
+
...optionBeforeCommand !== undefined && { optionBeforeCommand },
|
|
2187
|
+
...leadingToken !== undefined && { leadingToken },
|
|
2188
|
+
hadLeadingPrefix
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
function answersBeforeArguments(scan) {
|
|
2192
|
+
return scan.topLevelHelp || scan.version || scan.framework.help || scan.framework.schema;
|
|
2193
|
+
}
|
|
2194
|
+
function scanCliInvocation2(argv, options) {
|
|
2195
|
+
let res;
|
|
2196
|
+
try {
|
|
2197
|
+
res = scanCliArgv(argv, options);
|
|
2198
|
+
} catch (error) {
|
|
2199
|
+
if (error instanceof CliArgumentError2) {
|
|
2200
|
+
return {
|
|
2201
|
+
framework: {
|
|
2202
|
+
json: false,
|
|
2203
|
+
wait: false,
|
|
2204
|
+
quiet: false,
|
|
2205
|
+
dryRun: false,
|
|
2206
|
+
help: false,
|
|
2207
|
+
schema: false
|
|
2208
|
+
},
|
|
2209
|
+
globals: parseCliGlobalValues(undefined, {}),
|
|
2210
|
+
commandTokens: [],
|
|
2211
|
+
separatedBefore: new Set,
|
|
2212
|
+
topLevelHelp: false,
|
|
2213
|
+
version: false,
|
|
2214
|
+
error
|
|
2215
|
+
};
|
|
1060
2216
|
}
|
|
2217
|
+
throw error;
|
|
1061
2218
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
function routeCliArgv2(argv, defaultCommand) {
|
|
1065
|
-
const index = leadingGlobalCount(argv, defaultCommand !== undefined);
|
|
1066
|
-
const token = argv[index];
|
|
1067
|
-
if (token === "--" && (index > 0 || defaultCommand !== undefined)) {
|
|
2219
|
+
const error = answersBeforeArguments(res) ? undefined : res.deferredError;
|
|
2220
|
+
if (error !== undefined) {
|
|
1068
2221
|
return {
|
|
1069
|
-
|
|
2222
|
+
framework: res.framework,
|
|
2223
|
+
globals: res.globals,
|
|
2224
|
+
commandTokens: [],
|
|
2225
|
+
separatedBefore: new Set,
|
|
1070
2226
|
topLevelHelp: false,
|
|
1071
2227
|
version: false,
|
|
1072
|
-
error
|
|
2228
|
+
error
|
|
1073
2229
|
};
|
|
1074
2230
|
}
|
|
1075
|
-
if (defaultCommand !== undefined) {
|
|
1076
|
-
if (token !== undefined && isTopHelpOption(token)) {
|
|
1077
|
-
const helpFilter = helpFilterFrom(token, argv.slice(index + 1));
|
|
1078
|
-
return {
|
|
1079
|
-
commandArgv: [],
|
|
1080
|
-
topLevelHelp: true,
|
|
1081
|
-
version: false,
|
|
1082
|
-
...helpFilter !== undefined && { helpFilter }
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
if (isCliVersionToken(token)) {
|
|
1086
|
-
return { commandArgv: [], topLevelHelp: false, version: true };
|
|
1087
|
-
}
|
|
1088
|
-
if (token === undefined || token.startsWith("-") && token !== "-") {
|
|
1089
|
-
return {
|
|
1090
|
-
command: defaultCommand,
|
|
1091
|
-
commandArgv: argv.slice(),
|
|
1092
|
-
topLevelHelp: false,
|
|
1093
|
-
version: false
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
const commandIndex = token === undefined ? 0 : index;
|
|
1098
|
-
const command = argv[commandIndex];
|
|
1099
|
-
const rest = argv.slice(commandIndex + 1);
|
|
1100
|
-
const prefix = argv.slice(0, commandIndex);
|
|
1101
|
-
preserveCliBooleanBoundary(prefix, rest[0]);
|
|
1102
|
-
const helpFilter = commandIndex > 0 || defaultCommand === undefined ? helpFilterFrom(command, rest) : undefined;
|
|
1103
2231
|
return {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
2232
|
+
framework: res.framework,
|
|
2233
|
+
globals: res.globals,
|
|
2234
|
+
...res.command !== undefined && { command: res.command },
|
|
2235
|
+
commandTokens: res.commandTokens,
|
|
2236
|
+
separatedBefore: res.separatedBefore,
|
|
2237
|
+
topLevelHelp: res.topLevelHelp,
|
|
2238
|
+
...res.helpFilter !== undefined && { helpFilter: res.helpFilter },
|
|
2239
|
+
version: res.version
|
|
1109
2240
|
};
|
|
1110
2241
|
}
|
|
1111
2242
|
|
|
@@ -1119,9 +2250,12 @@ function writeCliNotice(text) {
|
|
|
1119
2250
|
if (invocation !== undefined) {
|
|
1120
2251
|
if (!invocation.quiet)
|
|
1121
2252
|
invocation.stderr(text);
|
|
1122
|
-
|
|
1123
|
-
process.stderr.write(text);
|
|
2253
|
+
return;
|
|
1124
2254
|
}
|
|
2255
|
+
const scan = scanCliInvocation2(process.argv.slice(2));
|
|
2256
|
+
if (scan.error !== undefined || scan.framework.quiet)
|
|
2257
|
+
return;
|
|
2258
|
+
process.stderr.write(text);
|
|
1125
2259
|
}
|
|
1126
2260
|
|
|
1127
2261
|
// src/tools/cli/download.ts
|
|
@@ -1147,15 +2281,15 @@ async function writeDownload(root, name, data) {
|
|
|
1147
2281
|
// src/tools/cli/inline-files.ts
|
|
1148
2282
|
import { basename } from "node:path";
|
|
1149
2283
|
import { pathToFileURL } from "node:url";
|
|
1150
|
-
import { z as
|
|
1151
|
-
var EmbeddedResourceSchema =
|
|
1152
|
-
type:
|
|
1153
|
-
resource:
|
|
1154
|
-
|
|
1155
|
-
|
|
2284
|
+
import { z as z3 } from "zod";
|
|
2285
|
+
var EmbeddedResourceSchema = z3.object({
|
|
2286
|
+
type: z3.literal("resource"),
|
|
2287
|
+
resource: z3.union([
|
|
2288
|
+
z3.object({ uri: z3.string(), mimeType: z3.string().optional(), blob: z3.string() }),
|
|
2289
|
+
z3.object({ uri: z3.string(), mimeType: z3.string().optional(), text: z3.string() })
|
|
1156
2290
|
])
|
|
1157
2291
|
});
|
|
1158
|
-
var InlineFileSchema =
|
|
2292
|
+
var InlineFileSchema = z3.discriminatedUnion("type", [
|
|
1159
2293
|
McpImageContentSchema,
|
|
1160
2294
|
McpAudioContentSchema,
|
|
1161
2295
|
EmbeddedResourceSchema
|
|
@@ -1331,12 +2465,15 @@ var GLOBAL_OPTIONS = [
|
|
|
1331
2465
|
["--table <a,b>", "Render the named fields as an aligned table"]
|
|
1332
2466
|
];
|
|
1333
2467
|
function typeLabel(schema) {
|
|
1334
|
-
if (Array.isArray(schema.enum))
|
|
2468
|
+
if (HELP_SHOWN_KEYWORDS.has("enum") && Array.isArray(schema.enum)) {
|
|
1335
2469
|
return schema.enum.join("|");
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
2470
|
+
}
|
|
2471
|
+
if (HELP_SHOWN_KEYWORDS.has("type")) {
|
|
2472
|
+
if (schema.type === "array")
|
|
2473
|
+
return "value";
|
|
2474
|
+
if (typeof schema.type === "string")
|
|
2475
|
+
return schema.type;
|
|
2476
|
+
}
|
|
1340
2477
|
return "value";
|
|
1341
2478
|
}
|
|
1342
2479
|
function isPatternOnly(member) {
|
|
@@ -1344,8 +2481,8 @@ function isPatternOnly(member) {
|
|
|
1344
2481
|
}
|
|
1345
2482
|
function constraintLabel(schema) {
|
|
1346
2483
|
const limits = [];
|
|
1347
|
-
const format = typeof schema.format === "string" ? schema.format : undefined;
|
|
1348
|
-
const pattern = typeof schema.pattern === "string" ? schema.pattern : undefined;
|
|
2484
|
+
const format = HELP_SHOWN_KEYWORDS.has("format") && typeof schema.format === "string" ? schema.format : undefined;
|
|
2485
|
+
const pattern = HELP_SHOWN_KEYWORDS.has("pattern") && typeof schema.pattern === "string" ? schema.pattern : undefined;
|
|
1349
2486
|
const named = format !== undefined && STANDARD_STRING_FORMATS.has(format);
|
|
1350
2487
|
if (format !== undefined && (named || pattern === undefined)) {
|
|
1351
2488
|
limits.push(format);
|
|
@@ -1363,6 +2500,8 @@ function constraintLabel(schema) {
|
|
|
1363
2500
|
["maxItems", "items <="]
|
|
1364
2501
|
];
|
|
1365
2502
|
for (const [keyword, label] of bounds) {
|
|
2503
|
+
if (!HELP_SHOWN_KEYWORDS.has(keyword))
|
|
2504
|
+
continue;
|
|
1366
2505
|
const bound = schema[keyword];
|
|
1367
2506
|
if (typeof bound !== "number")
|
|
1368
2507
|
continue;
|
|
@@ -1376,6 +2515,8 @@ function constraintLabel(schema) {
|
|
|
1376
2515
|
["allOf", "all of", " & "]
|
|
1377
2516
|
];
|
|
1378
2517
|
for (const [keyword, label, separator] of compositions) {
|
|
2518
|
+
if (!HELP_SHOWN_KEYWORDS.has(keyword))
|
|
2519
|
+
continue;
|
|
1379
2520
|
const members = schema[keyword];
|
|
1380
2521
|
if (!Array.isArray(members))
|
|
1381
2522
|
continue;
|
|
@@ -1531,50 +2672,10 @@ function renderCommandHelp(name, command, descriptor, applicationOptions = []) {
|
|
|
1531
2672
|
`;
|
|
1532
2673
|
}
|
|
1533
2674
|
|
|
1534
|
-
// src/tools/cli/command-shape.ts
|
|
1535
|
-
function assertCliCommandName(name) {
|
|
1536
|
-
if (isReservedCliCommandName(name)) {
|
|
1537
|
-
throw new Error(`[stitchkit] CLI command "${name}" is reserved. Rename the command to a word outside the framework option syntax.`);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
function assertStaticCliCommandNames(services, runtimeTools) {
|
|
1541
|
-
for (const tool of runtimeTools) {
|
|
1542
|
-
if (tool.transports?.includes("CLI"))
|
|
1543
|
-
assertCliCommandName(tool.name);
|
|
1544
|
-
}
|
|
1545
|
-
for (const service of services) {
|
|
1546
|
-
for (const [key, method] of Object.entries(service.methods)) {
|
|
1547
|
-
const name = projectedContractToolName(service.name, key, method, "CLI") ?? cliStreamIdentity(service.name, key, method)?.name;
|
|
1548
|
-
if (name !== undefined)
|
|
1549
|
-
assertCliCommandName(name);
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
function commandShapeIssue(name, descriptor, exists, passthroughField, applicationGlobals = new Set) {
|
|
1554
|
-
assertUniqueToolName(name, exists, "CLI command");
|
|
1555
|
-
assertCliCommandName(name);
|
|
1556
|
-
if (passthroughField !== undefined && descriptor.aliases.has(passthroughField)) {
|
|
1557
|
-
throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
|
|
1558
|
-
}
|
|
1559
|
-
const fieldNames = jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name);
|
|
1560
|
-
const conflicting = fieldNames.filter((field) => RESERVED_CLI_OPTIONS.has(field));
|
|
1561
|
-
if (conflicting.length > 0) {
|
|
1562
|
-
return `[stitchkit] CLI command "${name}" declares reserved option field(s): ${conflicting.join(", ")}`;
|
|
1563
|
-
}
|
|
1564
|
-
const shadowed = fieldNames.filter((field) => applicationGlobals.has(field));
|
|
1565
|
-
if (shadowed.length > 0) {
|
|
1566
|
-
return `[stitchkit] CLI command "${name}" declares field(s) shadowed by application global options: ${shadowed.join(", ")}`;
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
2675
|
// src/tools/cli/managed-surface.ts
|
|
1571
2676
|
async function buildManagedSurface(session, typedGlobals, forExecution) {
|
|
1572
2677
|
const { config, nativeHelp, applicationGlobalNames } = session;
|
|
1573
|
-
|
|
1574
|
-
const resolveIdentity = () => {
|
|
1575
|
-
authPromise ??= (async () => config.resolveAuth ? await config.resolveAuth(typedGlobals) : await config.auth)();
|
|
1576
|
-
return authPromise;
|
|
1577
|
-
};
|
|
2678
|
+
const resolveIdentity = resolveCliIdentity(config, typedGlobals);
|
|
1578
2679
|
let auth;
|
|
1579
2680
|
if (session.hasManagedFactory || forExecution) {
|
|
1580
2681
|
try {
|
|
@@ -1590,53 +2691,26 @@ async function buildManagedSurface(session, typedGlobals, forExecution) {
|
|
|
1590
2691
|
};
|
|
1591
2692
|
}
|
|
1592
2693
|
}
|
|
1593
|
-
const { tools, streams, help } = buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, commandShapeIssue);
|
|
2694
|
+
const { tools, streams, help } = buildCliSurface(config, auth, typedGlobals, nativeHelp, applicationGlobalNames, commandShapeIssue);
|
|
1594
2695
|
return { resolved: true, auth, help, tools, streams };
|
|
1595
2696
|
}
|
|
1596
2697
|
|
|
1597
|
-
// src/tools/cli/args.ts
|
|
1598
|
-
import { z as z3 } from "zod";
|
|
1599
|
-
|
|
1600
|
-
// src/tools/cli/args-json.ts
|
|
1601
|
-
function cliFieldOption(option, fields) {
|
|
1602
|
-
const json = option.inline && option.name.endsWith(":") && !fields.has(option.name);
|
|
1603
|
-
const name = json ? option.name.slice(0, -1) : option.name;
|
|
1604
|
-
return { name, json };
|
|
1605
|
-
}
|
|
1606
|
-
function appendCliFieldValue(raw, jsonFields, name, value, info, json) {
|
|
1607
|
-
appendCliOptionValue(raw, name, value, json || jsonFields.has(name) ? { kind: "other" } : info);
|
|
1608
|
-
if (json)
|
|
1609
|
-
jsonFields.add(name);
|
|
1610
|
-
}
|
|
1611
|
-
function coerceCliFieldValue(info, values, label, json) {
|
|
1612
|
-
if (!json)
|
|
1613
|
-
return coerceField(info, values, label);
|
|
1614
|
-
try {
|
|
1615
|
-
return safeJsonParse(values[0] ?? "");
|
|
1616
|
-
} catch (cause) {
|
|
1617
|
-
throw new CliArgumentError2(`${label} expects valid JSON`, { cause });
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
2698
|
// src/tools/cli/args-tokens.ts
|
|
1622
2699
|
function readCliTokens(argv, fields, fieldFor, config) {
|
|
1623
|
-
const
|
|
1624
|
-
json: false,
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
help: false
|
|
2700
|
+
const fwState = {
|
|
2701
|
+
fw: { json: false, wait: false, quiet: false, dryRun: false, help: false, schema: false },
|
|
2702
|
+
fwFlags: new Map,
|
|
2703
|
+
viewFlags: new Map,
|
|
2704
|
+
ascending: false
|
|
1629
2705
|
};
|
|
1630
2706
|
const flags = new Map;
|
|
1631
2707
|
const jsonFields = new Set;
|
|
1632
2708
|
const literalBooleanFlags = new Set;
|
|
1633
|
-
const frameworkFlags = new Map;
|
|
1634
|
-
const viewFlags = new Map;
|
|
1635
|
-
let ascending = false;
|
|
1636
2709
|
const positionals = [];
|
|
1637
2710
|
const pushFlag = (name, value, json = false) => {
|
|
1638
2711
|
appendCliFieldValue(flags, jsonFields, name, value, fieldFor(name), json);
|
|
1639
2712
|
};
|
|
2713
|
+
const adjacent = (index) => !config.separatedBefore?.has(index);
|
|
1640
2714
|
let optionsEnded = false;
|
|
1641
2715
|
for (let i = 0;i < argv.length; i++) {
|
|
1642
2716
|
const tok = argv[i];
|
|
@@ -1651,30 +2725,31 @@ function readCliTokens(argv, fields, fieldFor, config) {
|
|
|
1651
2725
|
continue;
|
|
1652
2726
|
}
|
|
1653
2727
|
if (tok === "-h") {
|
|
1654
|
-
|
|
2728
|
+
fwState.fw.help = true;
|
|
1655
2729
|
continue;
|
|
1656
2730
|
}
|
|
1657
2731
|
if (!tok.startsWith("--")) {
|
|
1658
2732
|
const match = /^-([A-Za-z])(?:=(.*))?$/.exec(tok);
|
|
1659
2733
|
const alias = match?.[1];
|
|
1660
|
-
const field = alias === undefined ? undefined : config.
|
|
2734
|
+
const field = alias === undefined ? undefined : config.aliases?.get(alias);
|
|
1661
2735
|
if (!alias || !field)
|
|
1662
2736
|
throw new CliArgumentError2(`Unknown option "${tok}"`);
|
|
1663
2737
|
const inline = match?.[2];
|
|
1664
2738
|
const info = fieldFor(field);
|
|
1665
2739
|
if (info?.kind === "boolean") {
|
|
1666
|
-
const separate = inline === undefined ? separateBoolValue(argv[i + 1]) : undefined;
|
|
2740
|
+
const separate = inline === undefined && adjacent(i + 1) ? separateBoolValue(argv[i + 1]) : undefined;
|
|
1667
2741
|
if (separate !== undefined)
|
|
1668
2742
|
i++;
|
|
1669
2743
|
pushFlag(field, inline ?? String(separate ?? true));
|
|
1670
|
-
if (inline !== undefined)
|
|
2744
|
+
if (inline !== undefined && info.pureBoolean === true) {
|
|
1671
2745
|
parseReservedBool(field, inline);
|
|
2746
|
+
}
|
|
1672
2747
|
literalBooleanFlags.add(field);
|
|
1673
2748
|
continue;
|
|
1674
2749
|
}
|
|
1675
2750
|
let value = inline;
|
|
1676
2751
|
if (value === undefined) {
|
|
1677
|
-
const next = argv[i + 1];
|
|
2752
|
+
const next = adjacent(i + 1) ? argv[i + 1] : undefined;
|
|
1678
2753
|
if (next !== undefined && !isOptionToken(next)) {
|
|
1679
2754
|
value = next;
|
|
1680
2755
|
i++;
|
|
@@ -1695,55 +2770,16 @@ function readCliTokens(argv, fields, fieldFor, config) {
|
|
|
1695
2770
|
if (json && RESERVED_CLI_OPTIONS.has(name)) {
|
|
1696
2771
|
throw new CliArgumentError2(`--${name} is a framework option and does not accept :=JSON`);
|
|
1697
2772
|
}
|
|
1698
|
-
if (option.globalKind
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
appendCliOptionValue(frameworkFlags, name, value ?? String(separate ?? true), {
|
|
1704
|
-
kind: "boolean"
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
const enabled = value === undefined ? separate ?? true : parseReservedBool(name, value);
|
|
1708
|
-
if (name === "dry-run")
|
|
1709
|
-
options.dryRun = enabled;
|
|
1710
|
-
else if (name === "json")
|
|
1711
|
-
options.json = enabled;
|
|
1712
|
-
else if (name === "wait")
|
|
1713
|
-
options.wait = enabled;
|
|
1714
|
-
else if (name === "quiet")
|
|
1715
|
-
options.quiet = enabled;
|
|
1716
|
-
else if (name === "ascending")
|
|
1717
|
-
ascending = enabled;
|
|
1718
|
-
else if (name === "schema")
|
|
1719
|
-
continue;
|
|
1720
|
-
else
|
|
1721
|
-
options.help = options.help || enabled;
|
|
1722
|
-
continue;
|
|
1723
|
-
}
|
|
1724
|
-
if (option.globalKind === "value") {
|
|
1725
|
-
const next = argv[i + 1];
|
|
1726
|
-
value = value ?? next;
|
|
1727
|
-
if (value === undefined || !option.inline && isOptionToken(value)) {
|
|
1728
|
-
throw new CliArgumentError2(`--${name} requires a value`);
|
|
1729
|
-
}
|
|
1730
|
-
if (!option.inline)
|
|
1731
|
-
i++;
|
|
1732
|
-
appendCliOptionValue(frameworkFlags, name, value, { kind: "string" });
|
|
1733
|
-
if (name === "wait-timeout") {
|
|
1734
|
-
const timeout = Number(value);
|
|
1735
|
-
if (!Number.isFinite(timeout) || timeout <= 0) {
|
|
1736
|
-
throw new CliArgumentError2("--wait-timeout must be a positive number");
|
|
2773
|
+
if (option.globalKind !== undefined) {
|
|
2774
|
+
i = consumeFrameworkOptionToken(argv, i, option, fwState, {
|
|
2775
|
+
adjacent,
|
|
2776
|
+
onError: (error) => {
|
|
2777
|
+
throw error;
|
|
1737
2778
|
}
|
|
1738
|
-
|
|
1739
|
-
} else if (VIEW_OPTIONS.has(name)) {
|
|
1740
|
-
viewFlags.set(name, value);
|
|
1741
|
-
} else {
|
|
1742
|
-
options.outputDir = value;
|
|
1743
|
-
}
|
|
2779
|
+
});
|
|
1744
2780
|
continue;
|
|
1745
2781
|
}
|
|
1746
|
-
if (value === undefined && name.startsWith("no-") && fieldFor(name.slice(3))?.kind === "boolean") {
|
|
2782
|
+
if (value === undefined && name.startsWith("no-") && !fieldFor(name) && fieldFor(name.slice(3))?.kind === "boolean") {
|
|
1747
2783
|
pushFlag(name.slice(3), "false");
|
|
1748
2784
|
literalBooleanFlags.add(name.slice(3));
|
|
1749
2785
|
continue;
|
|
@@ -1759,14 +2795,14 @@ function readCliTokens(argv, fields, fieldFor, config) {
|
|
|
1759
2795
|
}
|
|
1760
2796
|
if (value === undefined) {
|
|
1761
2797
|
if (info?.kind === "boolean") {
|
|
1762
|
-
const separate = separateBoolValue(argv[i + 1]);
|
|
2798
|
+
const separate = adjacent(i + 1) ? separateBoolValue(argv[i + 1]) : undefined;
|
|
1763
2799
|
if (separate !== undefined)
|
|
1764
2800
|
i++;
|
|
1765
2801
|
pushFlag(name, String(separate ?? true));
|
|
1766
2802
|
literalBooleanFlags.add(name);
|
|
1767
2803
|
continue;
|
|
1768
2804
|
}
|
|
1769
|
-
const next = argv[i + 1];
|
|
2805
|
+
const next = adjacent(i + 1) ? argv[i + 1] : undefined;
|
|
1770
2806
|
if (next !== undefined && !isOptionToken(next)) {
|
|
1771
2807
|
value = next;
|
|
1772
2808
|
i++;
|
|
@@ -1775,99 +2811,32 @@ function readCliTokens(argv, fields, fieldFor, config) {
|
|
|
1775
2811
|
}
|
|
1776
2812
|
}
|
|
1777
2813
|
pushFlag(name, value, json);
|
|
2814
|
+
if (option.inline && !json && info?.kind === "boolean" && info.pureBoolean === true) {
|
|
2815
|
+
parseReservedBool(name, value);
|
|
2816
|
+
}
|
|
1778
2817
|
}
|
|
2818
|
+
const { fw } = fwState;
|
|
2819
|
+
const options = {
|
|
2820
|
+
json: fw.json,
|
|
2821
|
+
wait: fw.wait,
|
|
2822
|
+
quiet: fw.quiet,
|
|
2823
|
+
dryRun: fw.dryRun,
|
|
2824
|
+
help: fw.help,
|
|
2825
|
+
schema: fw.schema,
|
|
2826
|
+
...fw.waitTimeout !== undefined && { waitTimeout: fw.waitTimeout },
|
|
2827
|
+
...fw.outputDir !== undefined && { outputDir: fw.outputDir }
|
|
2828
|
+
};
|
|
1779
2829
|
return {
|
|
1780
2830
|
options,
|
|
1781
2831
|
flags,
|
|
1782
2832
|
jsonFields,
|
|
1783
2833
|
literalBooleanFlags,
|
|
1784
|
-
viewFlags,
|
|
1785
|
-
ascending,
|
|
2834
|
+
viewFlags: fwState.viewFlags,
|
|
2835
|
+
ascending: fwState.ascending,
|
|
1786
2836
|
positionals
|
|
1787
2837
|
};
|
|
1788
2838
|
}
|
|
1789
2839
|
|
|
1790
|
-
// src/tools/cli/args-view.ts
|
|
1791
|
-
function resolveCliView(flags, ascending) {
|
|
1792
|
-
if (flags.size === 0) {
|
|
1793
|
-
if (ascending) {
|
|
1794
|
-
throw new CliArgumentError2("--ascending orders a record view; pass --sort with it");
|
|
1795
|
-
}
|
|
1796
|
-
return;
|
|
1797
|
-
}
|
|
1798
|
-
const countBy = flags.get("count-by");
|
|
1799
|
-
const sum = flags.get("sum");
|
|
1800
|
-
const table = flags.get("table");
|
|
1801
|
-
const by = flags.get("by");
|
|
1802
|
-
const rawTop = flags.get("top");
|
|
1803
|
-
const named = [
|
|
1804
|
-
["--count-by", countBy],
|
|
1805
|
-
["--sum", sum]
|
|
1806
|
-
].filter(([, value]) => value !== undefined);
|
|
1807
|
-
if (named.length > 1) {
|
|
1808
|
-
throw new CliArgumentError2(`${named.map(([flag]) => flag).join(" and ")} ask for different shapes — pass one`);
|
|
1809
|
-
}
|
|
1810
|
-
let top;
|
|
1811
|
-
if (rawTop !== undefined) {
|
|
1812
|
-
top = Number(rawTop);
|
|
1813
|
-
if (!Number.isInteger(top) || top <= 0) {
|
|
1814
|
-
throw new CliArgumentError2("--top must be a positive whole number");
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
const sort = flags.get("sort");
|
|
1818
|
-
if (table !== undefined || sort !== undefined) {
|
|
1819
|
-
if (countBy !== undefined || sum !== undefined) {
|
|
1820
|
-
throw new CliArgumentError2(`${table !== undefined ? "--table" : "--sort"} lists records; --count-by and --sum aggregate them — pass one`);
|
|
1821
|
-
}
|
|
1822
|
-
if (by !== undefined) {
|
|
1823
|
-
throw new CliArgumentError2("--by groups a view; a record view orders with --sort");
|
|
1824
|
-
}
|
|
1825
|
-
if (top !== undefined && sort === undefined) {
|
|
1826
|
-
throw new CliArgumentError2("--top needs --sort here: unordered records have no n largest");
|
|
1827
|
-
}
|
|
1828
|
-
let fields;
|
|
1829
|
-
if (table !== undefined) {
|
|
1830
|
-
fields = table.split(",").map((field) => field.trim()).filter(Boolean);
|
|
1831
|
-
if (fields.length === 0)
|
|
1832
|
-
throw new CliArgumentError2("--table needs at least one field");
|
|
1833
|
-
}
|
|
1834
|
-
return {
|
|
1835
|
-
kind: "records",
|
|
1836
|
-
...sort !== undefined && { sort },
|
|
1837
|
-
...ascending && { ascending },
|
|
1838
|
-
...top !== undefined && { top },
|
|
1839
|
-
...fields && { table: fields }
|
|
1840
|
-
};
|
|
1841
|
-
}
|
|
1842
|
-
if (ascending) {
|
|
1843
|
-
throw new CliArgumentError2("--ascending orders a record view; pass --sort with it");
|
|
1844
|
-
}
|
|
1845
|
-
if (sum !== undefined) {
|
|
1846
|
-
if (top !== undefined && by === undefined) {
|
|
1847
|
-
throw new CliArgumentError2("--top needs --by: a single sum has nothing to rank");
|
|
1848
|
-
}
|
|
1849
|
-
return {
|
|
1850
|
-
kind: "sum",
|
|
1851
|
-
field: sum,
|
|
1852
|
-
...by !== undefined && { by },
|
|
1853
|
-
...top !== undefined && { top }
|
|
1854
|
-
};
|
|
1855
|
-
}
|
|
1856
|
-
if (countBy !== undefined) {
|
|
1857
|
-
if (by !== undefined) {
|
|
1858
|
-
throw new CliArgumentError2("--count-by already names the grouping field; drop --by");
|
|
1859
|
-
}
|
|
1860
|
-
return { kind: "count", field: countBy, ...top !== undefined && { top } };
|
|
1861
|
-
}
|
|
1862
|
-
if (by !== undefined) {
|
|
1863
|
-
if (top === undefined) {
|
|
1864
|
-
throw new CliArgumentError2("--by groups a view; pass --count-by, --sum or --top with it");
|
|
1865
|
-
}
|
|
1866
|
-
return { kind: "count", field: by, top };
|
|
1867
|
-
}
|
|
1868
|
-
throw new CliArgumentError2("--top needs --sort, --by, --count-by or --sum to rank");
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
2840
|
// src/tools/cli/args.ts
|
|
1872
2841
|
function buildToolArgs(tokens, fields, fieldFor, declaredPositionals, allowUnknown) {
|
|
1873
2842
|
const { flags, jsonFields, literalBooleanFlags, positionals } = tokens;
|
|
@@ -1935,7 +2904,35 @@ function buildToolArgs(tokens, fields, fieldFor, declaredPositionals, allowUnkno
|
|
|
1935
2904
|
}
|
|
1936
2905
|
return toolArgs;
|
|
1937
2906
|
}
|
|
2907
|
+
function cliRunOptions(framework) {
|
|
2908
|
+
return {
|
|
2909
|
+
json: framework.json,
|
|
2910
|
+
wait: framework.wait,
|
|
2911
|
+
quiet: framework.quiet,
|
|
2912
|
+
dryRun: framework.dryRun,
|
|
2913
|
+
help: framework.help,
|
|
2914
|
+
schema: framework.schema,
|
|
2915
|
+
...framework.waitTimeout !== undefined && { waitTimeout: framework.waitTimeout },
|
|
2916
|
+
...framework.outputDir !== undefined && { outputDir: framework.outputDir },
|
|
2917
|
+
...framework.view !== undefined && { view: framework.view }
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
1938
2920
|
function parseCliArgs2(argv, schema, config = {}) {
|
|
2921
|
+
try {
|
|
2922
|
+
return parseCommandArgv(argv, schema, config);
|
|
2923
|
+
} catch (error) {
|
|
2924
|
+
if (!(error instanceof CliArgumentError2))
|
|
2925
|
+
throw error;
|
|
2926
|
+
const scan = scanCliArgv(argv, {
|
|
2927
|
+
afterCommand: true,
|
|
2928
|
+
separatedBefore: config.separatedBefore
|
|
2929
|
+
});
|
|
2930
|
+
if (!answersBeforeArguments(scan))
|
|
2931
|
+
throw error;
|
|
2932
|
+
return { toolArgs: {}, options: cliRunOptions(scan.framework) };
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
function parseCommandArgv(argv, schema, config) {
|
|
1939
2936
|
const fields = describeSchemaFields(schema);
|
|
1940
2937
|
for (const name of config.knownFields ?? []) {
|
|
1941
2938
|
if (!fields.has(name))
|
|
@@ -1952,80 +2949,41 @@ function parseCliArgs2(argv, schema, config = {}) {
|
|
|
1952
2949
|
options
|
|
1953
2950
|
};
|
|
1954
2951
|
}
|
|
1955
|
-
function refuseGlobalOption(issue) {
|
|
1956
|
-
const field = issue?.path[0];
|
|
1957
|
-
const where = typeof field === "string" ? `--${field}` : "application option";
|
|
1958
|
-
throw new CliArgumentError2(`${where}: ${issue?.message ?? "invalid value"}`);
|
|
1959
|
-
}
|
|
1960
2952
|
function extractCliGlobalOptions2(argv, schema) {
|
|
1961
2953
|
if (schema === undefined)
|
|
1962
2954
|
return { argv: [...argv], globals: {} };
|
|
1963
|
-
|
|
1964
|
-
const rest = [];
|
|
1965
|
-
const raw = new Map;
|
|
1966
|
-
const jsonFields = new Set;
|
|
1967
|
-
let ended = false;
|
|
1968
|
-
for (let i = 0;i < argv.length; i++) {
|
|
1969
|
-
const token = argv[i];
|
|
1970
|
-
if (token === undefined)
|
|
1971
|
-
continue;
|
|
1972
|
-
if (!ended && token === "--")
|
|
1973
|
-
ended = true;
|
|
1974
|
-
const option = ended ? undefined : classifyLongOptionToken(token);
|
|
1975
|
-
const field = option ? cliFieldOption(option, fields) : undefined;
|
|
1976
|
-
const info = field && option?.globalKind === undefined ? fields.get(field.name) : undefined;
|
|
1977
|
-
if (!option || !field || !info) {
|
|
1978
|
-
rest.push(token);
|
|
1979
|
-
continue;
|
|
1980
|
-
}
|
|
1981
|
-
let { value } = option;
|
|
1982
|
-
if (value === undefined && info.kind === "boolean") {
|
|
1983
|
-
const separate = separateBoolValue(argv[i + 1]);
|
|
1984
|
-
if (separate !== undefined)
|
|
1985
|
-
i++;
|
|
1986
|
-
value = String(separate ?? true);
|
|
1987
|
-
} else if (value === undefined) {
|
|
1988
|
-
const next = argv[i + 1];
|
|
1989
|
-
if (next !== undefined && !isOptionToken(next)) {
|
|
1990
|
-
value = next;
|
|
1991
|
-
i++;
|
|
1992
|
-
} else {
|
|
1993
|
-
throw new CliArgumentError2(`--${option.name} requires a value`);
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
appendCliFieldValue(raw, jsonFields, field.name, value, info, field.json);
|
|
1997
|
-
preserveCliBooleanBoundary(rest, argv[i + 1]);
|
|
1998
|
-
}
|
|
1999
|
-
const args = {};
|
|
2000
|
-
for (const [name, values] of raw) {
|
|
2001
|
-
args[name] = coerceCliFieldValue(fields.get(name), values, `--${name}`, jsonFields.has(name));
|
|
2002
|
-
}
|
|
2003
|
-
let coerced;
|
|
2955
|
+
let result;
|
|
2004
2956
|
try {
|
|
2005
|
-
|
|
2957
|
+
result = scanCliArgv(argv, { appGlobals: schema });
|
|
2006
2958
|
} catch (error) {
|
|
2007
|
-
if (error instanceof
|
|
2008
|
-
|
|
2959
|
+
if (error instanceof CliArgumentError2) {
|
|
2960
|
+
return { argv: [], globals: {}, error };
|
|
2961
|
+
}
|
|
2009
2962
|
throw error;
|
|
2010
2963
|
}
|
|
2011
|
-
const
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2964
|
+
const early = answersBeforeArguments(result);
|
|
2965
|
+
const error = early ? undefined : result.appGlobalError ?? result.liftedBoundaryError;
|
|
2966
|
+
if (error !== undefined) {
|
|
2967
|
+
return {
|
|
2968
|
+
argv: [],
|
|
2969
|
+
globals: result.globals,
|
|
2970
|
+
error
|
|
2971
|
+
};
|
|
2972
|
+
}
|
|
2973
|
+
return {
|
|
2974
|
+
argv: result.withoutGlobals,
|
|
2975
|
+
globals: result.globals,
|
|
2976
|
+
...result.separatedBeforeGlobals.size > 0 && {
|
|
2977
|
+
separatedBefore: result.separatedBeforeGlobals
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2015
2980
|
}
|
|
2016
2981
|
|
|
2017
2982
|
// src/tools/cli/prepare.ts
|
|
2018
2983
|
function looseCoerceValue(value) {
|
|
2019
2984
|
if (Array.isArray(value))
|
|
2020
2985
|
return value.map(looseCoerceValue);
|
|
2021
|
-
|
|
2022
|
-
return value;
|
|
2023
|
-
if (value === "true")
|
|
2024
|
-
return true;
|
|
2025
|
-
if (value === "false")
|
|
2026
|
-
return false;
|
|
2027
|
-
const n = Number(value);
|
|
2028
|
-
return value.trim() !== "" && !Number.isNaN(n) ? n : value;
|
|
2986
|
+
return typeof value === "string" ? looseCoerce(value) : value;
|
|
2029
2987
|
}
|
|
2030
2988
|
function passthroughBase(value) {
|
|
2031
2989
|
if (isRecord(value))
|
|
@@ -2053,21 +3011,24 @@ function collectPassthrough(toolArgs, field, knownKeys) {
|
|
|
2053
3011
|
const base = passthroughBase(toolArgs[field]);
|
|
2054
3012
|
toolArgs[field] = base ? { ...base, ...bag } : bag;
|
|
2055
3013
|
}
|
|
2056
|
-
async function prepareInvocation(command,
|
|
3014
|
+
async function prepareInvocation(command, commandTokens, separatedBefore, framework, descriptor, config, readStdin) {
|
|
3015
|
+
const passthroughField = cliPassthroughField(config, command);
|
|
2057
3016
|
let parsed;
|
|
2058
3017
|
try {
|
|
2059
|
-
parsed = parseCliArgs2(
|
|
2060
|
-
allowUnknown:
|
|
3018
|
+
parsed = parseCliArgs2(commandTokens, descriptor.argumentSchema, {
|
|
3019
|
+
allowUnknown: passthroughField !== undefined,
|
|
2061
3020
|
knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
|
|
2062
|
-
|
|
2063
|
-
positionals: descriptor.positionals
|
|
3021
|
+
aliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
|
|
3022
|
+
positionals: descriptor.positionals,
|
|
3023
|
+
separatedBefore
|
|
2064
3024
|
});
|
|
2065
3025
|
} catch (error) {
|
|
2066
3026
|
if (!(error instanceof CliArgumentError2))
|
|
2067
3027
|
throw error;
|
|
2068
3028
|
return { ok: false, message: error.message };
|
|
2069
3029
|
}
|
|
2070
|
-
const { toolArgs
|
|
3030
|
+
const { toolArgs } = parsed;
|
|
3031
|
+
const options = cliRunOptions(framework);
|
|
2071
3032
|
const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
|
|
2072
3033
|
if (firstUnset) {
|
|
2073
3034
|
const piped = await readStdin();
|
|
@@ -2075,31 +3036,28 @@ async function prepareInvocation(command, commandArgv, descriptor, config, readS
|
|
|
2075
3036
|
if (descriptor.positionals === undefined) {
|
|
2076
3037
|
toolArgs[firstUnset.name] = piped;
|
|
2077
3038
|
} else {
|
|
2078
|
-
const
|
|
2079
|
-
|
|
3039
|
+
const fieldInfo = describeSchemaFields(descriptor.argumentSchema).get(firstUnset.name);
|
|
3040
|
+
try {
|
|
3041
|
+
toolArgs[firstUnset.name] = coerceField(fieldInfo, [piped], `--${firstUnset.name}`);
|
|
3042
|
+
} catch (error) {
|
|
3043
|
+
if (!(error instanceof CliArgumentError2))
|
|
3044
|
+
throw error;
|
|
3045
|
+
return { ok: false, message: error.message };
|
|
3046
|
+
}
|
|
2080
3047
|
}
|
|
2081
3048
|
}
|
|
2082
3049
|
}
|
|
2083
|
-
const passthroughField = config.passthrough?.[command];
|
|
2084
3050
|
if (passthroughField) {
|
|
2085
3051
|
collectPassthrough(toolArgs, passthroughField, objectShapeKeys(descriptor.argumentSchema));
|
|
2086
|
-
}
|
|
2087
|
-
return { ok: true, toolArgs, options };
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
// src/tools/cli/session.ts
|
|
2091
|
-
function nativeDescriptor(definition) {
|
|
2092
|
-
return {
|
|
2093
|
-
description: definition.description,
|
|
2094
|
-
argumentSchema: definition.input,
|
|
2095
|
-
presentationSchema: cliCommandPresentationSchema(definition),
|
|
2096
|
-
outputSchema: definition.output
|
|
2097
|
-
};
|
|
3052
|
+
}
|
|
3053
|
+
return { ok: true, toolArgs, options };
|
|
2098
3054
|
}
|
|
3055
|
+
|
|
3056
|
+
// src/tools/cli/session.ts
|
|
2099
3057
|
function createCliSession(config, io) {
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
3058
|
+
const lifecycle = resolveOptionalCliToolAccess("createCliSession", config);
|
|
3059
|
+
assertNoLegacyCliPolicyKeys(config);
|
|
3060
|
+
assertCliAuthConfig(config);
|
|
2103
3061
|
assertPositiveSafeInteger("createCli maxDownloadBytes", config.maxDownloadBytes);
|
|
2104
3062
|
const applicationOptions = config.globalOptions ? jsonSchemaFields(buildToolPresentationSchema({
|
|
2105
3063
|
inputSchema: config.globalOptions,
|
|
@@ -2115,15 +3073,22 @@ function createCliSession(config, io) {
|
|
|
2115
3073
|
const nativeHelp = new Map;
|
|
2116
3074
|
assertStaticCliCommandNames(typeof config.services === "function" ? [] : config.services ?? [], typeof config.runtimeTools === "function" ? [] : config.runtimeTools ?? []);
|
|
2117
3075
|
for (const definition of config.commands ?? []) {
|
|
2118
|
-
|
|
2119
|
-
|
|
3076
|
+
if (cliResultPolicy(config, definition.name) !== undefined) {
|
|
3077
|
+
throw new Error(`[stitchkit] CLI result policy "${definition.name}" targets a command that is not managed; a native command declares present and exitCode on defineCliCommand`);
|
|
3078
|
+
}
|
|
3079
|
+
const descriptor = applyCliPresentationPolicy(definition.name, nativeCliDescriptor(definition), config);
|
|
3080
|
+
const issue = commandShapeIssue(definition.name, descriptor, nativeCommands.has(definition.name), cliPassthroughField(config, definition.name), applicationGlobalNames);
|
|
2120
3081
|
if (issue !== undefined)
|
|
2121
3082
|
throw new Error(issue);
|
|
2122
3083
|
nativeCommands.set(definition.name, definition);
|
|
2123
3084
|
nativeHelp.set(definition.name, descriptor);
|
|
2124
3085
|
}
|
|
3086
|
+
if (config.services === undefined && config.runtimeTools === undefined) {
|
|
3087
|
+
assertCliPoliciesResolved(nativeHelp, config);
|
|
3088
|
+
}
|
|
2125
3089
|
return {
|
|
2126
3090
|
config,
|
|
3091
|
+
lifecycle,
|
|
2127
3092
|
io,
|
|
2128
3093
|
applicationOptions,
|
|
2129
3094
|
applicationGlobalNames,
|
|
@@ -2135,50 +3100,34 @@ function createCliSession(config, io) {
|
|
|
2135
3100
|
function resolveCliRoute(session, argv) {
|
|
2136
3101
|
const { config } = session;
|
|
2137
3102
|
const { stdout, stderr, exit } = session.io;
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
} catch (error) {
|
|
2145
|
-
if (!(error instanceof CliArgumentError2))
|
|
2146
|
-
throw error;
|
|
2147
|
-
stderr(`${error.message}
|
|
2148
|
-
`);
|
|
2149
|
-
exit(2);
|
|
2150
|
-
return;
|
|
2151
|
-
}
|
|
2152
|
-
const typedGlobals = globals;
|
|
2153
|
-
const route = routeCliArgv2(routableArgv, config.defaultCommand);
|
|
2154
|
-
if (route.error) {
|
|
2155
|
-
stderr(`${route.error}
|
|
2156
|
-
`);
|
|
2157
|
-
exit(2);
|
|
2158
|
-
return;
|
|
2159
|
-
}
|
|
2160
|
-
const { command, commandArgv } = route;
|
|
2161
|
-
if (config.defaultCommand === undefined && session.hasManagedFactory && command !== undefined && command !== routableArgv[0] && session.nativeCommands.has(command)) {
|
|
2162
|
-
stderr(`Managed command names are unknown before native dispatch. Put "${config.name} ${command}" first and keep options with their values. ` + `If moving a bare boolean flag next to positional true or false, spell the flag explicitly (for example, --dry-run=true).
|
|
3103
|
+
const scan = scanCliInvocation2(argv, {
|
|
3104
|
+
appGlobals: config.globalOptions,
|
|
3105
|
+
defaultCommand: config.defaultCommand
|
|
3106
|
+
});
|
|
3107
|
+
if (scan.error !== undefined) {
|
|
3108
|
+
stderr(`${scan.error.message}
|
|
2163
3109
|
`);
|
|
2164
3110
|
exit(2);
|
|
2165
3111
|
return;
|
|
2166
3112
|
}
|
|
2167
|
-
if (
|
|
3113
|
+
if (scan.version) {
|
|
2168
3114
|
stdout(`${config.name} ${config.version}
|
|
2169
3115
|
`);
|
|
2170
3116
|
exit(0);
|
|
2171
3117
|
return;
|
|
2172
3118
|
}
|
|
2173
|
-
const helpRequested =
|
|
2174
|
-
const schemaRequested = !helpRequested &&
|
|
3119
|
+
const helpRequested = scan.framework.help;
|
|
3120
|
+
const schemaRequested = !helpRequested && scan.framework.schema;
|
|
2175
3121
|
return {
|
|
2176
|
-
globals,
|
|
2177
|
-
typedGlobals,
|
|
2178
|
-
|
|
2179
|
-
command,
|
|
2180
|
-
|
|
2181
|
-
|
|
3122
|
+
globals: scan.globals,
|
|
3123
|
+
typedGlobals: scan.globals,
|
|
3124
|
+
framework: scan.framework,
|
|
3125
|
+
command: scan.command,
|
|
3126
|
+
commandTokens: scan.commandTokens,
|
|
3127
|
+
separatedBefore: scan.separatedBefore,
|
|
3128
|
+
topLevelHelp: scan.topLevelHelp,
|
|
3129
|
+
...scan.helpFilter !== undefined && { helpFilter: scan.helpFilter },
|
|
3130
|
+
quiet: scan.framework.quiet,
|
|
2182
3131
|
helpRequested,
|
|
2183
3132
|
schemaRequested
|
|
2184
3133
|
};
|
|
@@ -2222,17 +3171,10 @@ async function runStreamCommand(session, route, managed, stream, { toolArgs, opt
|
|
|
2222
3171
|
cancel();
|
|
2223
3172
|
else
|
|
2224
3173
|
config.signal?.addEventListener("abort", cancel, { once: true });
|
|
2225
|
-
const runTool =
|
|
2226
|
-
source: "cli",
|
|
2227
|
-
toolSurface: true,
|
|
2228
|
-
context: { ...config.context?.(managed.auth, route.typedGlobals), signal: abort.signal },
|
|
2229
|
-
hooks: config.hooks,
|
|
2230
|
-
lifecycle: config.lifecycle,
|
|
2231
|
-
coerceJsonArgs: config.coerceJsonArgs
|
|
2232
|
-
});
|
|
3174
|
+
const runTool = createCliToolRunner(config, session.lifecycle, managed.auth, route.typedGlobals);
|
|
2233
3175
|
let opened;
|
|
2234
3176
|
try {
|
|
2235
|
-
opened = await runTool(stream.tool, toolArgs);
|
|
3177
|
+
opened = await runTool(stream.tool, toolArgs, { signal: abort.signal });
|
|
2236
3178
|
} catch (error) {
|
|
2237
3179
|
opened = toolResultFromError(error);
|
|
2238
3180
|
}
|
|
@@ -2255,7 +3197,7 @@ async function runStreamCommand(session, route, managed, stream, { toolArgs, opt
|
|
|
2255
3197
|
}
|
|
2256
3198
|
function streamLine(command, item, policy, options) {
|
|
2257
3199
|
if (policy?.present === undefined)
|
|
2258
|
-
return `${
|
|
3200
|
+
return `${stringifyJsonSafe(item)}
|
|
2259
3201
|
`;
|
|
2260
3202
|
let line;
|
|
2261
3203
|
try {
|
|
@@ -2291,7 +3233,7 @@ async function printStreamItems(source, { descriptor }, abort, wasCancelled, wri
|
|
|
2291
3233
|
if (lifetimeExpired) {
|
|
2292
3234
|
return toolResultFromError(contractStreamLifetimeExceeded());
|
|
2293
3235
|
}
|
|
2294
|
-
return toolResultFromError(error);
|
|
3236
|
+
return projectCliUnixFailure(toolResultFromError(error));
|
|
2295
3237
|
} finally {
|
|
2296
3238
|
if (lifetime !== undefined)
|
|
2297
3239
|
clearTimeout(lifetime);
|
|
@@ -2302,198 +3244,6 @@ async function printStreamItems(source, { descriptor }, abort, wasCancelled, wri
|
|
|
2302
3244
|
}
|
|
2303
3245
|
}
|
|
2304
3246
|
|
|
2305
|
-
// src/tools/cli/unavailable.ts
|
|
2306
|
-
function unavailableCommand(reason) {
|
|
2307
|
-
return toolResultFromError(new AppError2("CLI_COMMAND_UNAVAILABLE", {
|
|
2308
|
-
message: reason,
|
|
2309
|
-
status: STITCH_ERROR_STATUS2.CLI_COMMAND_UNAVAILABLE,
|
|
2310
|
-
retryable: false
|
|
2311
|
-
}));
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
|
-
// src/tools/cli/view.ts
|
|
2315
|
-
var ABSENT = "(absent)";
|
|
2316
|
-
function selectRecords(data) {
|
|
2317
|
-
if (Array.isArray(data))
|
|
2318
|
-
return data;
|
|
2319
|
-
if (isRecord(data)) {
|
|
2320
|
-
const arrays = Object.entries(data).filter(([, value]) => Array.isArray(value));
|
|
2321
|
-
const only = arrays[0];
|
|
2322
|
-
if (arrays.length === 1 && only && Array.isArray(only[1]))
|
|
2323
|
-
return only[1];
|
|
2324
|
-
if (arrays.length > 1) {
|
|
2325
|
-
throw new CliArgumentError2(`an aggregate needs one collection, but the result carries several: ${arrays.map(([key]) => key).join(", ")} — name the shape you want with jq instead`);
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
throw new CliArgumentError2("an aggregate needs a collection; this result is not one");
|
|
2329
|
-
}
|
|
2330
|
-
function isAbsent(value) {
|
|
2331
|
-
return value === undefined || value === null;
|
|
2332
|
-
}
|
|
2333
|
-
function readField(record, path) {
|
|
2334
|
-
let current = record;
|
|
2335
|
-
for (const segment of path) {
|
|
2336
|
-
if (!isRecord(current) || !Object.hasOwn(current, segment))
|
|
2337
|
-
return;
|
|
2338
|
-
current = current[segment];
|
|
2339
|
-
}
|
|
2340
|
-
return current;
|
|
2341
|
-
}
|
|
2342
|
-
function fieldPath(field) {
|
|
2343
|
-
const path = field.split(".");
|
|
2344
|
-
if (path.some((segment) => segment.length === 0 || isUnsafeKey(segment))) {
|
|
2345
|
-
throw new CliArgumentError2(`"${field}" is not a readable field path`);
|
|
2346
|
-
}
|
|
2347
|
-
return path;
|
|
2348
|
-
}
|
|
2349
|
-
function availableFields(records) {
|
|
2350
|
-
const keys = new Set;
|
|
2351
|
-
for (const record of records) {
|
|
2352
|
-
if (isRecord(record))
|
|
2353
|
-
for (const key of Object.keys(record))
|
|
2354
|
-
keys.add(key);
|
|
2355
|
-
}
|
|
2356
|
-
return [...keys].sort();
|
|
2357
|
-
}
|
|
2358
|
-
function assertFieldPresent(records, field) {
|
|
2359
|
-
const path = fieldPath(field);
|
|
2360
|
-
const present = records.some((record) => readField(record, path) !== undefined);
|
|
2361
|
-
if (records.length > 0 && !present) {
|
|
2362
|
-
const available = availableFields(records);
|
|
2363
|
-
throw new CliArgumentError2(`no record carries the field "${field}"${available.length > 0 ? ` — available: ${available.join(", ")}` : ""}`);
|
|
2364
|
-
}
|
|
2365
|
-
return path;
|
|
2366
|
-
}
|
|
2367
|
-
function groupKey(value) {
|
|
2368
|
-
if (value === undefined)
|
|
2369
|
-
return ABSENT;
|
|
2370
|
-
if (value === null)
|
|
2371
|
-
return "null";
|
|
2372
|
-
if (value === "null" || value === ABSENT)
|
|
2373
|
-
return JSON.stringify(value);
|
|
2374
|
-
if (typeof value === "object")
|
|
2375
|
-
return JSON.stringify(value);
|
|
2376
|
-
return String(value);
|
|
2377
|
-
}
|
|
2378
|
-
function ordered(totals, top) {
|
|
2379
|
-
const entries = [...totals].sort(([leftKey, left], [rightKey, right]) => right === left ? leftKey.localeCompare(rightKey) : right - left);
|
|
2380
|
-
const sliced = top === undefined ? entries : entries.slice(0, top);
|
|
2381
|
-
return {
|
|
2382
|
-
kind: "json",
|
|
2383
|
-
data: Object.fromEntries(sliced),
|
|
2384
|
-
order: sliced.map(([key]) => key)
|
|
2385
|
-
};
|
|
2386
|
-
}
|
|
2387
|
-
function stringifyGroups(data, order, compact) {
|
|
2388
|
-
if (!isRecord(data) || order.length === 0)
|
|
2389
|
-
return JSON.stringify(data);
|
|
2390
|
-
const lines = order.map((key) => `${JSON.stringify(key)}:${compact ? "" : " "}${JSON.stringify(data[key])}`);
|
|
2391
|
-
return compact ? `{${lines.join(",")}}` : `{
|
|
2392
|
-
${lines.join(`,
|
|
2393
|
-
`)}
|
|
2394
|
-
}`;
|
|
2395
|
-
}
|
|
2396
|
-
function numericValue(value, field) {
|
|
2397
|
-
if (isAbsent(value))
|
|
2398
|
-
return;
|
|
2399
|
-
if (typeof value === "number" && Number.isFinite(value))
|
|
2400
|
-
return value;
|
|
2401
|
-
if (typeof value === "bigint")
|
|
2402
|
-
return Number(value);
|
|
2403
|
-
throw new CliArgumentError2(`--sum ${field}: "${groupKey(value)}" is not a number`);
|
|
2404
|
-
}
|
|
2405
|
-
function renderTable(records, columns) {
|
|
2406
|
-
const fields = columns.map(({ field }) => field);
|
|
2407
|
-
const cell = (value) => {
|
|
2408
|
-
if (value === undefined)
|
|
2409
|
-
return "";
|
|
2410
|
-
if (value === null)
|
|
2411
|
-
return "null";
|
|
2412
|
-
if (typeof value === "object")
|
|
2413
|
-
return JSON.stringify(value);
|
|
2414
|
-
return String(value);
|
|
2415
|
-
};
|
|
2416
|
-
const rows = records.map((record) => columns.map(({ path }) => cell(readField(record, path))));
|
|
2417
|
-
const widths = fields.map((field, column) => Math.max(field.length, ...rows.map((row) => row[column]?.length ?? 0)));
|
|
2418
|
-
const line = (cells) => cells.map((value, column) => value.padEnd(widths[column] ?? value.length)).join(" ").trimEnd();
|
|
2419
|
-
return `${[line(fields), line(widths.map((width) => "-".repeat(width))), ...rows.map(line)].join(`
|
|
2420
|
-
`)}
|
|
2421
|
-
`;
|
|
2422
|
-
}
|
|
2423
|
-
function compareFieldValues(left, right) {
|
|
2424
|
-
if (isAbsent(left))
|
|
2425
|
-
return isAbsent(right) ? 0 : 1;
|
|
2426
|
-
if (isAbsent(right))
|
|
2427
|
-
return -1;
|
|
2428
|
-
if (typeof left === "number" && typeof right === "number")
|
|
2429
|
-
return left - right;
|
|
2430
|
-
if (typeof left === "bigint" || typeof right === "bigint") {
|
|
2431
|
-
return Number(left) - Number(right);
|
|
2432
|
-
}
|
|
2433
|
-
return groupKey(left).localeCompare(groupKey(right));
|
|
2434
|
-
}
|
|
2435
|
-
function renderRecords(records, view) {
|
|
2436
|
-
let selected = [...records];
|
|
2437
|
-
if (view.sort !== undefined) {
|
|
2438
|
-
const path = assertFieldPresent(records, view.sort);
|
|
2439
|
-
const direction = view.ascending ? 1 : -1;
|
|
2440
|
-
selected.sort((left, right) => {
|
|
2441
|
-
const leftValue = readField(left, path);
|
|
2442
|
-
const rightValue = readField(right, path);
|
|
2443
|
-
const order = compareFieldValues(leftValue, rightValue);
|
|
2444
|
-
return isAbsent(leftValue) || isAbsent(rightValue) ? order : order * direction;
|
|
2445
|
-
});
|
|
2446
|
-
}
|
|
2447
|
-
const columns = view.table?.map((field) => ({
|
|
2448
|
-
field,
|
|
2449
|
-
path: assertFieldPresent(records, field)
|
|
2450
|
-
}));
|
|
2451
|
-
if (view.top !== undefined)
|
|
2452
|
-
selected = selected.slice(0, view.top);
|
|
2453
|
-
return columns ? { kind: "text", text: renderTable(selected, columns) } : { kind: "json", data: selected };
|
|
2454
|
-
}
|
|
2455
|
-
function refuseEnvelopeFields(data, view) {
|
|
2456
|
-
if (!isRecord(data))
|
|
2457
|
-
return;
|
|
2458
|
-
const fields = view.kind === "records" ? [...view.sort === undefined ? [] : [view.sort], ...view.table ?? []] : [view.field, ...view.kind === "sum" && view.by !== undefined ? [view.by] : []];
|
|
2459
|
-
for (const field of fields) {
|
|
2460
|
-
const first = field.split(".")[0] ?? "";
|
|
2461
|
-
if (Object.hasOwn(data, first) && !Array.isArray(data[first])) {
|
|
2462
|
-
throw new CliArgumentError2(`"${field}" belongs to the result object, not to its empty collection`);
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
function renderCliView2(data, view) {
|
|
2467
|
-
const records = selectRecords(data);
|
|
2468
|
-
if (records.length === 0)
|
|
2469
|
-
refuseEnvelopeFields(data, view);
|
|
2470
|
-
if (view.kind === "records")
|
|
2471
|
-
return renderRecords(records, view);
|
|
2472
|
-
if (view.kind === "count") {
|
|
2473
|
-
const path = assertFieldPresent(records, view.field);
|
|
2474
|
-
const totals = new Map;
|
|
2475
|
-
for (const record of records) {
|
|
2476
|
-
const key = groupKey(readField(record, path));
|
|
2477
|
-
totals.set(key, (totals.get(key) ?? 0) + 1);
|
|
2478
|
-
}
|
|
2479
|
-
return ordered(totals, view.top);
|
|
2480
|
-
}
|
|
2481
|
-
const path = assertFieldPresent(records, view.field);
|
|
2482
|
-
if (view.by === undefined) {
|
|
2483
|
-
let total = 0;
|
|
2484
|
-
for (const record of records)
|
|
2485
|
-
total += numericValue(readField(record, path), view.field) ?? 0;
|
|
2486
|
-
return { kind: "json", data: total };
|
|
2487
|
-
}
|
|
2488
|
-
const byPath = assertFieldPresent(records, view.by);
|
|
2489
|
-
const totals = new Map;
|
|
2490
|
-
for (const record of records) {
|
|
2491
|
-
const key = groupKey(readField(record, byPath));
|
|
2492
|
-
totals.set(key, (totals.get(key) ?? 0) + (numericValue(readField(record, path), view.field) ?? 0));
|
|
2493
|
-
}
|
|
2494
|
-
return ordered(totals, view.top);
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
3247
|
// src/tools/cli/wait.ts
|
|
2498
3248
|
var DEFAULT_TIMEOUT = 600;
|
|
2499
3249
|
function waitFailure(tool, result) {
|
|
@@ -2552,22 +3302,19 @@ async function pollUntilDone2(params) {
|
|
|
2552
3302
|
async function runManagedInvocation(session, route) {
|
|
2553
3303
|
const { config } = session;
|
|
2554
3304
|
const { stdout, stderr, exit } = session.io;
|
|
2555
|
-
const { command, helpRequested, schemaRequested } = route;
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
if (topLevelHelp)
|
|
3305
|
+
const { command, topLevelHelp, helpRequested, schemaRequested } = route;
|
|
3306
|
+
const managed = await buildManagedSurface(session, route.typedGlobals, !topLevelHelp && !helpRequested && !schemaRequested && !isInspectOnlyLifecycle(session.lifecycle));
|
|
3307
|
+
if (topLevelHelp || command === undefined)
|
|
2559
3308
|
return respondTopLevelHelp(session, route, managed);
|
|
2560
3309
|
if (!managed.resolved) {
|
|
2561
|
-
return exit(emitResult2(managed.failure, { stdout, stderr }, emitOptionsFor(config,
|
|
3310
|
+
return exit(emitResult2(managed.failure, { stdout, stderr }, emitOptionsFor(config, route.framework.json, command)));
|
|
2562
3311
|
}
|
|
2563
3312
|
return runManagedCommand(session, route, command, managed);
|
|
2564
3313
|
}
|
|
2565
3314
|
function respondTopLevelHelp(session, route, managed) {
|
|
2566
3315
|
const { config, applicationOptions } = session;
|
|
2567
3316
|
const { stdout, stderr, exit } = session.io;
|
|
2568
|
-
const
|
|
2569
|
-
const helpFilter = route.route.helpFilter ?? (command !== undefined ? commandArgv[0] : undefined);
|
|
2570
|
-
const filter = helpFilter !== undefined && !helpFilter.startsWith("-") ? helpFilter : undefined;
|
|
3317
|
+
const filter = route.helpFilter;
|
|
2571
3318
|
if (filter !== undefined && filterCommands(managed.help, filter).size === 0) {
|
|
2572
3319
|
stderr(`no command matches "${filter}" (${[...managed.help.values()].filter((entry) => entry.unavailableReason === undefined).length} available)
|
|
2573
3320
|
` + (managed.resolved ? "" : `Managed commands are unavailable: ${managed.reason}
|
|
@@ -2594,7 +3341,7 @@ async function runManagedCommand(session, route, command, managed) {
|
|
|
2594
3341
|
if (!descriptor) {
|
|
2595
3342
|
stderr(`Unknown command "${command}". Run "${config.name} --help" for the command list.
|
|
2596
3343
|
`);
|
|
2597
|
-
return exit(
|
|
3344
|
+
return exit(cliExitCode2(unknownCliCommand(command), config.exitCodes));
|
|
2598
3345
|
}
|
|
2599
3346
|
if (route.helpRequested) {
|
|
2600
3347
|
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
@@ -2604,21 +3351,25 @@ async function runManagedCommand(session, route, command, managed) {
|
|
|
2604
3351
|
stdout(renderCommandSchema(command, descriptor));
|
|
2605
3352
|
return exit(0);
|
|
2606
3353
|
}
|
|
3354
|
+
const inspectErr = inspectOnlyError(session.lifecycle);
|
|
3355
|
+
if (inspectErr) {
|
|
3356
|
+
return exit(emitResult2(toolResultFromError(inspectErr), { stdout, stderr }, emitOptionsFor(config, route.framework.json, command)));
|
|
3357
|
+
}
|
|
2607
3358
|
if (descriptor.unavailableReason !== undefined) {
|
|
2608
|
-
return exit(emitResult2(unavailableCommand(descriptor.unavailableReason), { stdout, stderr }, emitOptionsFor(config,
|
|
3359
|
+
return exit(emitResult2(unavailableCommand(descriptor.unavailableReason), { stdout, stderr }, emitOptionsFor(config, route.framework.json, command)));
|
|
2609
3360
|
}
|
|
2610
3361
|
const stream = managed.streams.get(command);
|
|
2611
3362
|
const tool = managed.tools.get(command);
|
|
2612
3363
|
if (!tool && !stream)
|
|
2613
3364
|
throw new Error("[stitchkit] managed CLI executable invariant failed");
|
|
2614
|
-
const prepared = await prepareInvocation(command, route.
|
|
3365
|
+
const prepared = await prepareInvocation(command, route.commandTokens, route.separatedBefore, route.framework, descriptor, config, readStdin);
|
|
2615
3366
|
if (!prepared.ok) {
|
|
2616
3367
|
stderr(`${prepared.message}
|
|
2617
3368
|
`);
|
|
2618
3369
|
return exit(2);
|
|
2619
3370
|
}
|
|
2620
3371
|
const { toolArgs, options } = prepared;
|
|
2621
|
-
if (options.wait && !config
|
|
3372
|
+
if (options.wait && !cliWaitConfig(config, command)) {
|
|
2622
3373
|
stderr(`--wait is not configured for command "${command}"
|
|
2623
3374
|
`);
|
|
2624
3375
|
return exit(2);
|
|
@@ -2628,10 +3379,6 @@ async function runManagedCommand(session, route, command, managed) {
|
|
|
2628
3379
|
`);
|
|
2629
3380
|
return exit(2);
|
|
2630
3381
|
}
|
|
2631
|
-
if (options.help) {
|
|
2632
|
-
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
2633
|
-
return exit(0);
|
|
2634
|
-
}
|
|
2635
3382
|
if (options.dryRun) {
|
|
2636
3383
|
stdout(`${JSON.stringify({ command, args: toolArgs }, null, 2)}
|
|
2637
3384
|
`);
|
|
@@ -2641,6 +3388,17 @@ async function runManagedCommand(session, route, command, managed) {
|
|
|
2641
3388
|
return runStreamCommand(session, route, managed, stream, { toolArgs, options });
|
|
2642
3389
|
if (!tool)
|
|
2643
3390
|
throw new Error("[stitchkit] managed CLI executable invariant failed");
|
|
3391
|
+
if (options.view !== undefined && !options.wait) {
|
|
3392
|
+
try {
|
|
3393
|
+
assertViewColumns(options.view, descriptor.outputSchema);
|
|
3394
|
+
} catch (error) {
|
|
3395
|
+
if (!(error instanceof CliArgumentError2))
|
|
3396
|
+
throw error;
|
|
3397
|
+
stderr(`${error.message}
|
|
3398
|
+
`);
|
|
3399
|
+
return exit(2);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
2644
3402
|
const result = await executeManagedTool(session, route, command, managed, tool, {
|
|
2645
3403
|
toolArgs,
|
|
2646
3404
|
options
|
|
@@ -2650,21 +3408,14 @@ async function runManagedCommand(session, route, command, managed) {
|
|
|
2650
3408
|
async function executeManagedTool(session, route, command, managed, tool, { toolArgs, options }) {
|
|
2651
3409
|
const { config } = session;
|
|
2652
3410
|
const { stderr } = session.io;
|
|
2653
|
-
const runTool =
|
|
2654
|
-
source: "cli",
|
|
2655
|
-
toolSurface: true,
|
|
2656
|
-
context: { ...config.context?.(managed.auth, route.typedGlobals), signal: config.signal },
|
|
2657
|
-
hooks: config.hooks,
|
|
2658
|
-
lifecycle: config.lifecycle,
|
|
2659
|
-
coerceJsonArgs: config.coerceJsonArgs
|
|
2660
|
-
});
|
|
3411
|
+
const runTool = createCliToolRunner(config, session.lifecycle, managed.auth, route.typedGlobals);
|
|
2661
3412
|
let result;
|
|
2662
3413
|
try {
|
|
2663
3414
|
result = await runTool(tool, toolArgs);
|
|
2664
3415
|
} catch (err) {
|
|
2665
3416
|
result = toolResultFromError(err);
|
|
2666
3417
|
}
|
|
2667
|
-
const waitConfig = config
|
|
3418
|
+
const waitConfig = cliWaitConfig(config, command);
|
|
2668
3419
|
if (options.wait && waitConfig) {
|
|
2669
3420
|
result = await pollUntilDone2({
|
|
2670
3421
|
initial: result,
|
|
@@ -2716,39 +3467,14 @@ async function emitManagedResult(session, command, result, options, repeatable)
|
|
|
2716
3467
|
if (!saved.ok)
|
|
2717
3468
|
mediaExitCode = 1;
|
|
2718
3469
|
}
|
|
2719
|
-
|
|
2720
|
-
let viewed;
|
|
2721
|
-
try {
|
|
2722
|
-
viewed = renderCliView2(shown.data, options.view);
|
|
2723
|
-
} catch (error) {
|
|
2724
|
-
const failure = error instanceof CliArgumentError2 ? {
|
|
2725
|
-
ok: false,
|
|
2726
|
-
code: "BAD_REQUEST",
|
|
2727
|
-
details: { message: error.message }
|
|
2728
|
-
} : toolResultFromError(error);
|
|
2729
|
-
return exit(emitPresentationFailure(shown, failure, { stdout, stderr }, emit));
|
|
2730
|
-
}
|
|
2731
|
-
if (viewed.kind === "text") {
|
|
2732
|
-
stdout(viewed.text);
|
|
2733
|
-
return exit(mediaExitCode);
|
|
2734
|
-
}
|
|
2735
|
-
if (viewed.order) {
|
|
2736
|
-
stdout(`${stringifyGroups(viewed.data, viewed.order, options.json === true)}
|
|
2737
|
-
`);
|
|
2738
|
-
return exit(mediaExitCode);
|
|
2739
|
-
}
|
|
2740
|
-
shown = { ...shown, data: viewed.data };
|
|
2741
|
-
}
|
|
2742
|
-
const policy = options.view === undefined && !options.wait ? cliResultPolicy(config, command) : undefined;
|
|
2743
|
-
const exitCode = emitCliCommandResult(policy, result, options, { stdout, stderr }, emit, shown);
|
|
2744
|
-
return exit(mediaExitCode || exitCode);
|
|
3470
|
+
return exit(emitCliViewOrResult(cliResultPolicy(config, command), result, options, { stdout, stderr }, emit, shown, mediaExitCode));
|
|
2745
3471
|
}
|
|
2746
3472
|
|
|
2747
3473
|
// src/tools/cli/run-native.ts
|
|
2748
|
-
async function
|
|
3474
|
+
async function runNativeCommand(session, route, command, native) {
|
|
2749
3475
|
const { config, applicationOptions, nativeHelp } = session;
|
|
2750
3476
|
const { stdout, stderr, exit, readStdin } = session.io;
|
|
2751
|
-
const {
|
|
3477
|
+
const { commandTokens, separatedBefore, framework, helpRequested, globals } = route;
|
|
2752
3478
|
const descriptor = nativeHelp.get(command);
|
|
2753
3479
|
if (!descriptor)
|
|
2754
3480
|
throw new Error("[stitchkit] native CLI descriptor invariant failed");
|
|
@@ -2760,17 +3486,13 @@ async function runNativeCommand2(session, route, command, native) {
|
|
|
2760
3486
|
stdout(renderCommandSchema(command, descriptor));
|
|
2761
3487
|
return exit(0);
|
|
2762
3488
|
}
|
|
2763
|
-
const prepared = await prepareInvocation(command,
|
|
3489
|
+
const prepared = await prepareInvocation(command, commandTokens, separatedBefore, framework, descriptor, config, readStdin);
|
|
2764
3490
|
if (!prepared.ok) {
|
|
2765
3491
|
stderr(`${prepared.message}
|
|
2766
3492
|
`);
|
|
2767
3493
|
return exit(2);
|
|
2768
3494
|
}
|
|
2769
3495
|
const { toolArgs, options } = prepared;
|
|
2770
|
-
if (options.help) {
|
|
2771
|
-
stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
|
|
2772
|
-
return exit(0);
|
|
2773
|
-
}
|
|
2774
3496
|
if (options.wait) {
|
|
2775
3497
|
stderr(`--wait is not configured for native command "${command}"
|
|
2776
3498
|
`);
|
|
@@ -2791,17 +3513,20 @@ async function runNativeCommand2(session, route, command, native) {
|
|
|
2791
3513
|
`);
|
|
2792
3514
|
return exit(0);
|
|
2793
3515
|
}
|
|
2794
|
-
|
|
2795
|
-
|
|
3516
|
+
return exit(await executeNativeCommand(native, toolArgs, config.coerceJsonArgs ?? true, globals, {
|
|
3517
|
+
mode: "terminal",
|
|
3518
|
+
options,
|
|
3519
|
+
writers: { stdout, stderr },
|
|
3520
|
+
emit: { ...emitOptionsFor(config, options.json, command), repeatable: false }
|
|
3521
|
+
}));
|
|
2796
3522
|
}
|
|
2797
3523
|
|
|
2798
3524
|
// src/tools/cli/create-cli.ts
|
|
2799
3525
|
async function createCli2(config) {
|
|
3526
|
+
resolveOptionalCliToolAccess("createCli", config);
|
|
3527
|
+
assertNoLegacyCliPolicyKeys(config);
|
|
2800
3528
|
const io = createCliIo(config);
|
|
2801
3529
|
const argv = config.argv ?? process.argv.slice(2);
|
|
2802
|
-
if (config.auth !== undefined && config.resolveAuth !== undefined) {
|
|
2803
|
-
throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
|
|
2804
|
-
}
|
|
2805
3530
|
const session = createCliSession(config, io);
|
|
2806
3531
|
const route = resolveCliRoute(session, argv);
|
|
2807
3532
|
if (route === undefined)
|
|
@@ -2810,10 +3535,10 @@ async function createCli2(config) {
|
|
|
2810
3535
|
const { command } = route;
|
|
2811
3536
|
const native = command === undefined ? undefined : session.nativeCommands.get(command);
|
|
2812
3537
|
if (native && command !== undefined) {
|
|
2813
|
-
return
|
|
3538
|
+
return runNativeCommand(session, route, command, native);
|
|
2814
3539
|
}
|
|
2815
3540
|
return runManagedInvocation(session, route);
|
|
2816
3541
|
});
|
|
2817
3542
|
}
|
|
2818
3543
|
|
|
2819
|
-
export { DEFAULT_EXIT_CODES2, cliExitCode2, emitResult2, defineCliResult2, defineCliCommand2,
|
|
3544
|
+
export { CliArgumentError2, DEFAULT_EXIT_CODES2, cliExitCode2, emitResult2, renderCliView2, defineCliResult2, defineCliCommand2, cliInvocationResult2, createCliInvoker2, scanCliArgv, answersBeforeArguments, scanCliInvocation2, writeCliNotice, parseCliArgs2, extractCliGlobalOptions2, pollUntilDone2, createCli2 };
|