stitchkit 0.135.1 → 0.136.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 +109 -0
- package/README.md +25 -11
- package/dist/agent-executor/acp/v1-session-build.d.ts +51 -0
- package/dist/agent-executor/acp/v1-session-build.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/claude/classify.d.ts +1 -1
- package/dist/agent-executor/claude/classify.d.ts.map +1 -1
- package/dist/agent-executor/claude/events-wire.d.ts +13 -0
- package/dist/agent-executor/claude/events-wire.d.ts.map +1 -0
- package/dist/agent-executor/claude/events.d.ts +1 -11
- package/dist/agent-executor/claude/events.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +0 -143
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -1
- package/dist/agent-executor/codex/server-requests.d.ts +150 -0
- package/dist/agent-executor/codex/server-requests.d.ts.map +1 -0
- package/dist/agent-executor/image-input.d.ts +10 -3
- package/dist/agent-executor/image-input.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-scenarios.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -1
- package/dist/agent-runtime/browser/browser-control-contract.d.ts +4 -0
- package/dist/agent-runtime/browser/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser/control-schema.d.ts +4 -0
- package/dist/agent-runtime/browser/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/browser/control-view.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +16 -3
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/loop/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/loop/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/loop/invocation-stream.d.ts +9 -1
- package/dist/agent-runtime/loop/invocation-stream.d.ts.map +1 -1
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts +6 -0
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts +1 -1
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-approval-signature.d.ts +34 -0
- package/dist/agent-runtime/loop/run-approval-signature.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-approval.d.ts +0 -28
- package/dist/agent-runtime/loop/run-approval.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-complete-port.d.ts +24 -0
- package/dist/agent-runtime/loop/run-complete-port.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-complete-stream.d.ts +7 -2
- package/dist/agent-runtime/loop/run-complete-stream.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-complete-types.d.ts +14 -1
- package/dist/agent-runtime/loop/run-complete-types.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-complete.d.ts +2 -2
- package/dist/agent-runtime/loop/run-complete.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-execution-state.d.ts +8 -0
- package/dist/agent-runtime/loop/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-model-call.d.ts +44 -0
- package/dist/agent-runtime/loop/run-model-call.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-step.d.ts +25 -28
- package/dist/agent-runtime/loop/run-model-step.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-model-steps.d.ts +6 -0
- package/dist/agent-runtime/loop/run-model-steps.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-stream.d.ts +3 -1
- package/dist/agent-runtime/loop/run-model-stream.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-operation-lifecycle.d.ts +0 -2
- package/dist/agent-runtime/loop/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-step-loop.d.ts +19 -0
- package/dist/agent-runtime/loop/run-step-loop.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-step-port.d.ts +175 -0
- package/dist/agent-runtime/loop/run-step-port.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-stream-step-text.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-approval-flow.d.ts +2 -1
- package/dist/agent-runtime/loop/run-tool-approval-flow.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-call-input.d.ts +39 -0
- package/dist/agent-runtime/loop/run-tool-call-input.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-call.d.ts +2 -31
- package/dist/agent-runtime/loop/run-tool-call.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-errors.d.ts +5 -0
- package/dist/agent-runtime/loop/run-tool-errors.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-executor.d.ts +1 -1
- package/dist/agent-runtime/loop/run-tool-executor.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-slots.d.ts +2 -1
- package/dist/agent-runtime/loop/run-tool-slots.d.ts.map +1 -1
- package/dist/agent-runtime/loop/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/loop/runtime.d.ts +0 -5
- package/dist/agent-runtime/loop/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-convert.d.ts +1 -5
- package/dist/agent-runtime/providers/ai-sdk-convert.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-normalize.d.ts +11 -0
- package/dist/agent-runtime/providers/ai-sdk-normalize.d.ts.map +1 -0
- package/dist/agent-runtime/providers/ai-sdk-tools.d.ts +11 -0
- package/dist/agent-runtime/providers/ai-sdk-tools.d.ts.map +1 -0
- package/dist/agent-runtime/providers/ai-sdk.d.ts +1 -9
- package/dist/agent-runtime/providers/ai-sdk.d.ts.map +1 -1
- package/dist/agent-runtime/providers/anthropic-sse.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-admission.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-audio.d.ts +123 -81
- package/dist/agent-runtime/providers/openrouter-audio.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-catalog-cache.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-catalog-query.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-catalog.d.ts +2 -2
- package/dist/agent-runtime/providers/openrouter-catalog.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-client.d.ts +37 -0
- package/dist/agent-runtime/providers/openrouter-client.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-http.d.ts +26 -6
- package/dist/agent-runtime/providers/openrouter-http.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-media.d.ts +91 -77
- package/dist/agent-runtime/providers/openrouter-media.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-models.d.ts +2 -23
- package/dist/agent-runtime/providers/openrouter-models.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-options.d.ts +2 -0
- package/dist/agent-runtime/providers/openrouter-options.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-request.d.ts +23 -0
- package/dist/agent-runtime/providers/openrouter-request.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-retrieval.d.ts +86 -55
- package/dist/agent-runtime/providers/openrouter-retrieval.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-speech.d.ts +90 -0
- package/dist/agent-runtime/providers/openrouter-speech.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-spend.d.ts +2 -2
- package/dist/agent-runtime/providers/openrouter-spend.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-stream.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-systemone.d.ts +87 -32
- package/dist/agent-runtime/providers/openrouter-systemone.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-url.d.ts +7 -1
- package/dist/agent-runtime/providers/openrouter-url.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-wire.d.ts +45 -0
- package/dist/agent-runtime/providers/openrouter-wire.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter.d.ts +1 -3
- package/dist/agent-runtime/providers/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-http.d.ts +14 -2
- package/dist/agent-runtime/providers/provider-http.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-json-schema-strip.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-json-schema.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-openai-chat-sse.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-openai-chat-state.d.ts +42 -0
- package/dist/agent-runtime/providers/provider-openai-chat-state.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-usage.d.ts +9 -0
- package/dist/agent-runtime/providers/provider-usage.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap-args.d.ts +9 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap-args.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap.d.ts +6 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-process-linux.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-process-spec.d.ts +5 -1
- package/dist/agent-runtime/sandbox/sandbox-process-spec.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-process-wrapper.d.ts.map +1 -1
- package/dist/agent-runtime/stores/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/stores/branch-observations.d.ts +42 -42
- package/dist/agent-runtime/stores/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/agent-runtime/testing/fault-bench.d.ts +5 -1
- package/dist/agent-runtime/testing/fault-bench.d.ts.map +1 -1
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/testing/store-conformance-support.d.ts +10 -10
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -7
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +17 -5
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +4 -2
- package/dist/entrypoints/agent-executor/claude-sdk.js +20 -20
- package/dist/entrypoints/agent-executor/claude.js +7 -7
- package/dist/entrypoints/agent-executor/codex.d.ts +2 -1
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +129 -35
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +2 -2
- package/dist/entrypoints/agent-executor/testing.js +17 -13
- package/dist/entrypoints/agent-executor.js +1 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +2 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.js +10 -12
- package/dist/entrypoints/agent-runtime/anthropic.js +13 -10
- package/dist/entrypoints/agent-runtime/browser.js +8 -4
- package/dist/entrypoints/agent-runtime/harness.js +18 -19
- package/dist/entrypoints/agent-runtime/openai.js +5 -5
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +7 -5
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +1095 -854
- package/dist/entrypoints/agent-runtime/postgres.js +2 -2
- package/dist/entrypoints/agent-runtime/realtime.js +5 -5
- package/dist/entrypoints/agent-runtime/sandbox.js +167 -139
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +3 -3
- package/dist/entrypoints/agent-runtime.js +246 -360
- package/dist/entrypoints/application.js +2 -2
- package/dist/entrypoints/cli.js +36 -15
- package/dist/entrypoints/contract.js +12 -10
- package/dist/entrypoints/geo.js +1 -1
- package/dist/entrypoints/handler.js +5 -6
- package/dist/entrypoints/http.d.ts +2 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +16 -4
- package/dist/entrypoints/index.js +26 -35
- package/dist/entrypoints/live.js +3 -3
- package/dist/entrypoints/node.js +7 -7
- package/dist/entrypoints/observability.js +9 -7
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/remote.js +5 -5
- package/dist/entrypoints/server.js +29 -16
- package/dist/entrypoints/telegram/grammy.d.ts +1 -1
- package/dist/entrypoints/telegram/grammy.d.ts.map +1 -1
- package/dist/entrypoints/telegram/grammy.js +39 -5
- package/dist/entrypoints/telegram/screens.js +3 -0
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +19 -6
- package/dist/entrypoints/testing.js +10 -11
- package/dist/entrypoints/tools/agent.js +8 -9
- package/dist/entrypoints/tools/connections.js +27 -57
- package/dist/entrypoints/tools/contract.js +4 -4
- package/dist/entrypoints/tools/invoker.js +7 -8
- package/dist/entrypoints/tools/mcp.js +9 -10
- package/dist/entrypoints/tools/toolkit.js +11 -12
- package/dist/entrypoints/tools.js +20 -20
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/tracking/performance.js +1 -1
- package/dist/entrypoints/tracking.js +1 -1
- package/dist/{index-3czc3ykr.js → index-08a3qfr8.js} +1 -1
- package/dist/{index-grhhsrd5.js → index-1en7k3q5.js} +2 -1
- package/dist/{index-pdcbjd6a.js → index-1yky29qg.js} +6 -3
- package/dist/{index-b4c9dpzm.js → index-252den5a.js} +10 -11
- package/dist/{index-xtby8rj3.js → index-28kbdn63.js} +5 -47
- package/dist/{index-57sbckhv.js → index-36mtj8xm.js} +2 -2
- package/dist/{index-dm84tsd5.js → index-3kb8dw48.js} +1 -1
- package/dist/index-3tb82xr7.js +11 -0
- package/dist/{index-c24bj2r1.js → index-4243301z.js} +2 -2
- package/dist/{index-nr4fhfn4.js → index-4p2zx593.js} +2 -0
- package/dist/{index-q86qnzzf.js → index-54wp467c.js} +4 -4
- package/dist/{index-mcv7b2n0.js → index-63ctzjp4.js} +497 -495
- package/dist/{index-y0a4gt1s.js → index-65p8v81y.js} +3 -2
- package/dist/{index-z72vazf5.js → index-6y3eae97.js} +27 -83
- package/dist/{index-5awtbyns.js → index-9vj869rx.js} +1 -1
- package/dist/{index-5q0qpw3v.js → index-aqm7e864.js} +23 -8
- package/dist/{index-d4at0q09.js → index-b9mj31q7.js} +90 -88
- package/dist/{index-baba8ehy.js → index-bjrcbcn2.js} +2 -2
- package/dist/{index-fsw9wxk9.js → index-c9j8441q.js} +1 -103
- package/dist/{index-wdb5jhas.js → index-d1pdv8qc.js} +1 -1
- package/dist/{index-73wq9abg.js → index-df5xr2f9.js} +13 -59
- package/dist/{index-n9358ydy.js → index-dm50x3by.js} +1 -1
- package/dist/{index-zyyerdny.js → index-dmrx8xma.js} +3 -0
- package/dist/{index-78da4g74.js → index-dwq6a6sq.js} +17 -13
- package/dist/{index-9be3tf6r.js → index-e413q2cj.js} +49 -22
- package/dist/{index-g4gstmp1.js → index-ednf2cxs.js} +1 -1
- package/dist/{index-84tp547a.js → index-edpkm3k7.js} +29 -97
- package/dist/{index-gs0jw0hy.js → index-efbzm2se.js} +3 -3
- package/dist/{index-de7b0kvz.js → index-epwvp88y.js} +1 -1
- package/dist/{index-asnd4h2k.js → index-f0dzyskg.js} +27 -4
- package/dist/{index-xbb8ysmq.js → index-fatke81t.js} +2 -2
- package/dist/{index-6nzzj7qr.js → index-gq35s3bm.js} +1 -1
- package/dist/index-gvgtmt7a.js +102 -0
- package/dist/{index-m2b49tvc.js → index-h08xqfw9.js} +20 -21
- package/dist/{index-gk6dq9ay.js → index-ha1tv70k.js} +3 -26
- package/dist/{index-wsv11dhg.js → index-hberxns4.js} +1 -1
- package/dist/{index-rkphknhx.js → index-hpzhz1vm.js} +1 -1
- package/dist/{index-npfdymav.js → index-j5vzhj3d.js} +1 -1
- package/dist/{index-d3s070eh.js → index-jperyn0c.js} +1 -1
- package/dist/{index-yhwx4fwk.js → index-kzsetgh9.js} +1 -1
- package/dist/{index-x6sp5vpa.js → index-q4tr9vnf.js} +1 -1
- package/dist/{index-hce3hbdg.js → index-qj0sq69b.js} +6 -2
- package/dist/{index-v0j22shs.js → index-rg08syp1.js} +9 -6
- package/dist/{index-8vzh5wpv.js → index-rw1caff2.js} +14 -26
- package/dist/index-s8af9jqw.js +6 -0
- package/dist/{index-bgj9hbm3.js → index-sdppfbrh.js} +30 -16
- package/dist/{index-y0mwkgkf.js → index-shte29pg.js} +1086 -1055
- package/dist/{index-fec05c9k.js → index-ta0e2daw.js} +9 -7
- package/dist/{index-ht71v1ag.js → index-tb36xawm.js} +59 -44
- package/dist/{index-c0yym4a0.js → index-w7e402wx.js} +11 -105
- package/dist/{index-bvpevwt6.js → index-xnqab06h.js} +207 -202
- package/dist/index-xrbrvn15.js +147 -0
- package/dist/{index-ac3rfec5.js → index-y6wzzk2e.js} +21 -1
- package/dist/{index-3d2c45jn.js → index-yjx5jna7.js} +2 -2
- package/dist/internal/loopback-host.d.ts +8 -0
- package/dist/internal/loopback-host.d.ts.map +1 -0
- package/dist/internal/own-member.d.ts +7 -0
- package/dist/internal/own-member.d.ts.map +1 -0
- package/dist/internal/request.d.ts +17 -8
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/secret-shapes.d.ts +33 -4
- package/dist/internal/secret-shapes.d.ts.map +1 -1
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/keywords.d.ts +25 -6
- package/dist/json-schema/keywords.d.ts.map +1 -1
- 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/live/watch-delta.d.ts.map +1 -1
- package/dist/observability/context.d.ts +4 -3
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/observability/secret-values.d.ts +0 -9
- package/dist/observability/secret-values.d.ts.map +1 -1
- package/dist/server/context.d.ts +3 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +4 -3
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/event-bus.d.ts.map +1 -1
- package/dist/server/file.d.ts +11 -3
- package/dist/server/file.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +2 -2
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +12 -1
- package/dist/server/middleware/jwt.d.ts.map +1 -1
- package/dist/server/middleware/trust-fence.d.ts +4 -0
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart.d.ts +2 -3
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/raw.d.ts.map +1 -1
- package/dist/server/request-body.d.ts +12 -1
- package/dist/server/request-body.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts.map +1 -1
- package/dist/server/types.d.ts +14 -9
- package/dist/server/types.d.ts.map +1 -1
- package/dist/telegram/crypto.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts +4 -4
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts.map +1 -1
- package/dist/telegram/screens/test-chat.d.ts.map +1 -1
- package/dist/telegram/widget-api.d.ts +85 -13
- package/dist/telegram/widget-api.d.ts.map +1 -1
- package/dist/telegram/widget.d.ts +46 -2
- package/dist/telegram/widget.d.ts.map +1 -1
- package/dist/tools/cli/args-classify.d.ts +4 -74
- package/dist/tools/cli/args-classify.d.ts.map +1 -1
- package/dist/tools/cli/args-framework.d.ts +79 -0
- package/dist/tools/cli/args-framework.d.ts.map +1 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/checkpoint.d.ts +5 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/connections/foreign-schema-join.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/execute-handler.d.ts +24 -0
- package/dist/tools/execute-handler.d.ts.map +1 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/mcp/round.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/flatten.d.ts.map +1 -1
- package/dist/tools/schema/inline-references.d.ts.map +1 -1
- package/dist/tools/schema/nesting-limit.d.ts.map +1 -1
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tracking/privacy.d.ts.map +1 -1
- package/llms/agent-runtime-openrouter.txt +10 -9
- package/llms/agent-runtime-sandbox.txt +50 -11
- package/llms/agent-runtime-testing.txt +1 -1
- package/llms/agent-runtime.2.txt +9 -6
- package/llms/agent-runtime.3.txt +2 -2
- package/llms/agent-runtime.4.txt +11 -5
- package/llms/agent-runtime.5.txt +1 -1
- package/llms/agent-runtime.txt +283 -36
- package/llms/application.txt +3 -1
- package/llms/http.txt +1 -1
- package/llms/live.txt +3 -1
- package/llms/observability.txt +16 -9
- package/llms/server.2.txt +13 -8
- package/llms/server.4.txt +23 -11
- package/llms/server.5.txt +5 -5
- package/llms/server.txt +54 -1
- package/llms/spend.txt +1 -0
- package/llms/stitchkit.2.txt +4 -2
- package/llms/stitchkit.txt +113 -93
- package/llms/telegram-grammy.txt +3 -2
- package/llms/telegram.2.txt +3 -1
- package/llms/telegram.txt +35 -10
- package/llms/upgrading-0.128.0-0.129.0.txt +175 -0
- package/llms/{upgrading-0.128.0-0.135.0.txt → upgrading-0.130.0-0.136.0.txt} +353 -169
- package/llms/upgrading.txt +2 -1
- package/llms-full.txt +994 -217
- package/llms.txt +13 -12
- package/package.json +6 -6
- package/dist/agent-runtime/loop/deferred-tools-internal.d.ts +0 -19
- package/dist/agent-runtime/loop/deferred-tools-internal.d.ts.map +0 -1
- package/dist/agent-runtime/loop/run-complete-retry.d.ts +0 -24
- package/dist/agent-runtime/loop/run-complete-retry.d.ts.map +0 -1
- package/dist/agent-runtime/loop/run-model-attempts.d.ts +0 -6
- package/dist/agent-runtime/loop/run-model-attempts.d.ts.map +0 -1
- package/dist/index-sznqf8fx.js +0 -20
- /package/dist/{index-fthw8dwa.js → index-4gbybjg6.js} +0 -0
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
validateDeclaredOutput
|
|
3
|
-
} from "./index-78da4g74.js";
|
|
4
1
|
import {
|
|
5
2
|
STANDARD_STRING_FORMATS
|
|
6
|
-
} from "./index-
|
|
3
|
+
} from "./index-ha1tv70k.js";
|
|
7
4
|
import {
|
|
8
5
|
toJsonSchema,
|
|
9
6
|
jsonSchemaFields
|
|
10
|
-
} from "./index-
|
|
7
|
+
} from "./index-d1pdv8qc.js";
|
|
11
8
|
import {
|
|
12
9
|
toolSurfaceOutputSchema,
|
|
13
10
|
toToolName,
|
|
14
11
|
assertUniqueToolName,
|
|
15
12
|
buildToolPresentationSchema,
|
|
16
13
|
projectedContractToolName
|
|
17
|
-
} from "./index-
|
|
14
|
+
} from "./index-edpkm3k7.js";
|
|
18
15
|
import {
|
|
19
16
|
unwrapZodWrappers,
|
|
20
17
|
objectShapeKeys,
|
|
21
18
|
mergeSchemas
|
|
22
|
-
} from "./index-
|
|
19
|
+
} from "./index-dm50x3by.js";
|
|
23
20
|
import {
|
|
24
21
|
jsonSchemaObjectCoercionMembers
|
|
25
22
|
} from "./index-dsa676h8.js";
|
|
26
23
|
import {
|
|
27
24
|
coerceJsonArgs2
|
|
28
|
-
} from "./index-
|
|
25
|
+
} from "./index-qj0sq69b.js";
|
|
29
26
|
import {
|
|
30
27
|
isInspectOnlyLifecycle,
|
|
31
28
|
inspectOnlyError,
|
|
@@ -35,7 +32,7 @@ import {
|
|
|
35
32
|
toolCauseFromResult,
|
|
36
33
|
createToolRunner,
|
|
37
34
|
formatToolError
|
|
38
|
-
} from "./index-
|
|
35
|
+
} from "./index-b9mj31q7.js";
|
|
39
36
|
import {
|
|
40
37
|
isRepeatableRead
|
|
41
38
|
} from "./index-0x4mnwg5.js";
|
|
@@ -67,16 +64,19 @@ import {
|
|
|
67
64
|
import {
|
|
68
65
|
projectJsonSafe,
|
|
69
66
|
stringifyJsonSafe
|
|
70
|
-
} from "./index-
|
|
67
|
+
} from "./index-9vj869rx.js";
|
|
71
68
|
import {
|
|
72
69
|
collectToolSurface
|
|
73
|
-
} from "./index-
|
|
70
|
+
} from "./index-bjrcbcn2.js";
|
|
71
|
+
import {
|
|
72
|
+
validateDeclaredOutput
|
|
73
|
+
} from "./index-dwq6a6sq.js";
|
|
74
74
|
import {
|
|
75
75
|
assertNoLegacyTransports
|
|
76
76
|
} from "./index-akfgymyr.js";
|
|
77
77
|
import {
|
|
78
78
|
HELP_SHOWN_KEYWORDS
|
|
79
|
-
} from "./index-
|
|
79
|
+
} from "./index-e413q2cj.js";
|
|
80
80
|
import {
|
|
81
81
|
isUnsafeKey,
|
|
82
82
|
safeJsonParse
|
|
@@ -1036,87 +1036,6 @@ function coerceCliFieldValue(info, values, label, json) {
|
|
|
1036
1036
|
}
|
|
1037
1037
|
}
|
|
1038
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
1039
|
// src/tools/cli/args-classify.ts
|
|
1121
1040
|
function isOptionToken(token) {
|
|
1122
1041
|
return token.startsWith("--") || /^-[A-Za-z](?:=|$)/.test(token);
|
|
@@ -1169,436 +1088,196 @@ function isOwnLeadingToken(token, appFields) {
|
|
|
1169
1088
|
return false;
|
|
1170
1089
|
return opt.globalKind !== undefined || appFields.has(cliFieldOption(opt, appFields).name);
|
|
1171
1090
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1091
|
+
|
|
1092
|
+
// src/tools/cli/stream-surface.ts
|
|
1093
|
+
function cliStreamIdentity(serviceName, methodName, method) {
|
|
1094
|
+
if (!method.stream || !method.expose?.includes("CLI"))
|
|
1095
|
+
return;
|
|
1096
|
+
return { name: toToolName(serviceName, methodName), descriptor: method.stream };
|
|
1174
1097
|
}
|
|
1175
|
-
function
|
|
1176
|
-
|
|
1177
|
-
|
|
1098
|
+
function collectCliStreams(services) {
|
|
1099
|
+
const streams = new Map;
|
|
1100
|
+
for (const service of services) {
|
|
1101
|
+
for (const [methodName, method] of Object.entries(service.methods)) {
|
|
1102
|
+
const identity = cliStreamIdentity(service.name, methodName, method);
|
|
1103
|
+
if (identity === undefined)
|
|
1104
|
+
continue;
|
|
1105
|
+
const { name, descriptor } = identity;
|
|
1106
|
+
streams.set(name, {
|
|
1107
|
+
descriptor,
|
|
1108
|
+
tool: {
|
|
1109
|
+
method,
|
|
1110
|
+
name,
|
|
1111
|
+
argumentSchema: mergeSchemas(method.paramsSchema, method.inputSchema),
|
|
1112
|
+
presentationSchema: buildToolPresentationSchema({
|
|
1113
|
+
paramsSchema: method.paramsSchema,
|
|
1114
|
+
inputSchema: method.inputSchema,
|
|
1115
|
+
inputRecursionDepth: method.inputRecursionDepth,
|
|
1116
|
+
inputNestingDepth: method.inputNestingDepth,
|
|
1117
|
+
unrepresentable: "any"
|
|
1118
|
+
}),
|
|
1119
|
+
shouldExtend: false
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return streams;
|
|
1178
1125
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1126
|
+
|
|
1127
|
+
// src/tools/cli/command-shape.ts
|
|
1128
|
+
function nativeCliDescriptor(definition) {
|
|
1129
|
+
return {
|
|
1130
|
+
description: definition.description,
|
|
1131
|
+
argumentSchema: definition.input,
|
|
1132
|
+
presentationSchema: cliCommandPresentationSchema(definition),
|
|
1133
|
+
outputSchema: definition.output
|
|
1134
|
+
};
|
|
1183
1135
|
}
|
|
1184
|
-
function
|
|
1185
|
-
if (
|
|
1186
|
-
|
|
1136
|
+
function assertNoPassthroughAlias(name, descriptor, passthroughField) {
|
|
1137
|
+
if (passthroughField !== undefined && descriptor.aliases.has(passthroughField)) {
|
|
1138
|
+
throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
|
|
1187
1139
|
}
|
|
1188
|
-
ctx.removedAfterCmdToken = false;
|
|
1189
|
-
ctx.commandTokens.push(token);
|
|
1190
|
-
pushRestToken(ctx, token, index);
|
|
1191
1140
|
}
|
|
1192
|
-
function
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
separated.add(at);
|
|
1197
|
-
});
|
|
1198
|
-
return separated;
|
|
1141
|
+
function invokerCommandShapeIssue(name, descriptor, exists, passthroughField) {
|
|
1142
|
+
assertUniqueToolName(name, exists, "CLI command");
|
|
1143
|
+
assertNoPassthroughAlias(name, descriptor, passthroughField);
|
|
1144
|
+
return;
|
|
1199
1145
|
}
|
|
1200
|
-
function
|
|
1201
|
-
if (
|
|
1202
|
-
|
|
1146
|
+
function assertCliCommandName(name) {
|
|
1147
|
+
if (isReservedCliCommandName(name)) {
|
|
1148
|
+
throw new Error(`[stitchkit] CLI command "${name}" is reserved. Rename the command to a word outside the option syntax.`);
|
|
1149
|
+
}
|
|
1203
1150
|
}
|
|
1204
|
-
function
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
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;
|
|
1151
|
+
function assertStaticCliCommandNames(services, runtimeTools) {
|
|
1152
|
+
for (const tool of runtimeTools) {
|
|
1153
|
+
assertNoLegacyTransports(tool, `Runtime tool "${tool.name}"`);
|
|
1154
|
+
if (tool.expose?.includes("CLI"))
|
|
1155
|
+
assertCliCommandName(tool.name);
|
|
1156
|
+
}
|
|
1157
|
+
for (const service of services) {
|
|
1158
|
+
for (const [key, method] of Object.entries(service.methods)) {
|
|
1159
|
+
const name = projectedContractToolName(service.name, key, method, "CLI") ?? cliStreamIdentity(service.name, key, method)?.name;
|
|
1160
|
+
if (name !== undefined)
|
|
1161
|
+
assertCliCommandName(name);
|
|
1240
1162
|
}
|
|
1241
1163
|
}
|
|
1242
|
-
appendCliFieldValue(raw, jsonFields, appField.name, value, info, appField.json);
|
|
1243
|
-
return nextIndex;
|
|
1244
1164
|
}
|
|
1245
|
-
function
|
|
1246
|
-
|
|
1165
|
+
function commandShapeIssue(name, descriptor, exists, passthroughField, applicationGlobals = new Set) {
|
|
1166
|
+
assertUniqueToolName(name, exists, "CLI command");
|
|
1167
|
+
assertCliCommandName(name);
|
|
1168
|
+
assertNoPassthroughAlias(name, descriptor, passthroughField);
|
|
1169
|
+
const fieldNames = jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name);
|
|
1170
|
+
const conflicting = fieldNames.filter((field) => RESERVED_CLI_OPTIONS.has(field));
|
|
1171
|
+
if (conflicting.length > 0) {
|
|
1172
|
+
return `[stitchkit] CLI command "${name}" declares reserved option field(s): ${conflicting.join(", ")}`;
|
|
1173
|
+
}
|
|
1174
|
+
const shadowed = fieldNames.filter((field) => applicationGlobals.has(field));
|
|
1175
|
+
if (shadowed.length > 0) {
|
|
1176
|
+
return `[stitchkit] CLI command "${name}" declares field(s) shadowed by application global options: ${shadowed.join(", ")}`;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/tools/cli/policy.ts
|
|
1181
|
+
var REMOVED_TOP_LEVEL_KEYS = [
|
|
1182
|
+
"optionAliases",
|
|
1183
|
+
"positionals",
|
|
1184
|
+
"results",
|
|
1185
|
+
"passthrough",
|
|
1186
|
+
"wait"
|
|
1187
|
+
];
|
|
1188
|
+
function assertNoLegacyCliPolicyKeys(config) {
|
|
1189
|
+
if (typeof config !== "object" || config === null)
|
|
1247
1190
|
return;
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1191
|
+
for (const key of REMOVED_TOP_LEVEL_KEYS) {
|
|
1192
|
+
if (Object.hasOwn(config, key)) {
|
|
1193
|
+
throw new TypeError(`[stitchkit] CLI option "${key}" was moved into "commandSettings.<command>" — migrate to commandSettings`);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1250
1196
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
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;
|
|
1197
|
+
var SHORT_ALIAS = /^[A-Za-z]$/;
|
|
1198
|
+
var RESERVED_SHORT_OPTIONS = new Set(["h"]);
|
|
1199
|
+
function fieldMap(descriptor) {
|
|
1200
|
+
return new Map(jsonSchemaFields(descriptor.presentationSchema).map((field) => [field.name, field]));
|
|
1201
|
+
}
|
|
1202
|
+
function resolveAliases(command, descriptor, configured) {
|
|
1203
|
+
if (!configured)
|
|
1204
|
+
return new Map;
|
|
1205
|
+
const fields = fieldMap(descriptor);
|
|
1206
|
+
const aliases = new Map;
|
|
1207
|
+
for (const [alias, target] of Object.entries(configured)) {
|
|
1208
|
+
if (!SHORT_ALIAS.test(alias)) {
|
|
1209
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "${alias}" must be one ASCII letter`);
|
|
1280
1210
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
if (sep !== undefined && nextTok !== undefined) {
|
|
1284
|
-
nextIdx++;
|
|
1285
|
-
callbacks.onValueToken?.(nextTok);
|
|
1211
|
+
if (RESERVED_SHORT_OPTIONS.has(alias)) {
|
|
1212
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" is reserved`);
|
|
1286
1213
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
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;
|
|
1214
|
+
if (isUnsafeKey(target) || !fields.has(target)) {
|
|
1215
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" targets unknown field "${target}"`);
|
|
1303
1216
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
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);
|
|
1217
|
+
const existing = aliases.get(target);
|
|
1218
|
+
if (existing !== undefined) {
|
|
1219
|
+
throw new Error(`[stitchkit] CLI command "${command}" field "${target}" has multiple aliases: -${existing}, -${alias}`);
|
|
1333
1220
|
}
|
|
1221
|
+
aliases.set(target, alias);
|
|
1334
1222
|
}
|
|
1335
|
-
|
|
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
|
-
});
|
|
1223
|
+
return aliases;
|
|
1370
1224
|
}
|
|
1371
|
-
function
|
|
1372
|
-
if (
|
|
1225
|
+
function resolvePositionals(command, descriptor, configured) {
|
|
1226
|
+
if (configured === undefined)
|
|
1373
1227
|
return;
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1228
|
+
const fields = fieldMap(descriptor);
|
|
1229
|
+
const kinds = describeSchemaFields(descriptor.argumentSchema);
|
|
1230
|
+
const seen = new Set;
|
|
1231
|
+
let optionalSeen = false;
|
|
1232
|
+
for (const name of configured) {
|
|
1233
|
+
const field = fields.get(name);
|
|
1234
|
+
if (isUnsafeKey(name) || !field || !kinds.has(name)) {
|
|
1235
|
+
throw new Error(`[stitchkit] CLI command "${command}" positional targets unknown field "${name}"`);
|
|
1236
|
+
}
|
|
1237
|
+
if (seen.has(name)) {
|
|
1238
|
+
throw new Error(`[stitchkit] CLI command "${command}" repeats positional field "${name}"`);
|
|
1239
|
+
}
|
|
1240
|
+
if (kinds.get(name)?.kind === "boolean") {
|
|
1241
|
+
throw new Error(`[stitchkit] CLI command "${command}" boolean field "${name}" cannot be positional`);
|
|
1242
|
+
}
|
|
1243
|
+
if (optionalSeen && field.required) {
|
|
1244
|
+
throw new Error(`[stitchkit] CLI command "${command}" required positional "${name}" cannot follow an optional positional`);
|
|
1245
|
+
}
|
|
1246
|
+
if (!field.required)
|
|
1247
|
+
optionalSeen = true;
|
|
1248
|
+
seen.add(name);
|
|
1381
1249
|
}
|
|
1250
|
+
return [...configured];
|
|
1382
1251
|
}
|
|
1383
|
-
function
|
|
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;
|
|
1252
|
+
function cliCommandSettingsFor(config, command) {
|
|
1253
|
+
return config.commandSettings && Object.hasOwn(config.commandSettings, command) ? config.commandSettings[command] : undefined;
|
|
1407
1254
|
}
|
|
1408
|
-
function
|
|
1409
|
-
|
|
1410
|
-
return new CliArgumentError2(`Bare ${flag} cannot be separated from "${word}" — use ${flag}=true, ${flag}=false or "-- ${word}"`);
|
|
1255
|
+
function cliResultPolicy(config, command) {
|
|
1256
|
+
return cliCommandSettingsFor(config, command)?.result;
|
|
1411
1257
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
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 };
|
|
1258
|
+
function cliPassthroughField(config, command) {
|
|
1259
|
+
return cliCommandSettingsFor(config, command)?.passthrough;
|
|
1418
1260
|
}
|
|
1419
|
-
function
|
|
1420
|
-
|
|
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
|
-
inputNestingDepth: method.inputNestingDepth,
|
|
1438
|
-
unrepresentable: "any"
|
|
1439
|
-
}),
|
|
1440
|
-
shouldExtend: false
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
return streams;
|
|
1261
|
+
function cliWaitConfig(config, command) {
|
|
1262
|
+
return cliCommandSettingsFor(config, command)?.wait;
|
|
1446
1263
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1264
|
+
function applyCliPresentationPolicy(command, descriptor, config) {
|
|
1265
|
+
const base = { ...descriptor, aliases: new Map };
|
|
1266
|
+
const settings = cliCommandSettingsFor(config, command);
|
|
1450
1267
|
return {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
outputSchema: definition.output
|
|
1268
|
+
...base,
|
|
1269
|
+
aliases: resolveAliases(command, base, settings?.aliases),
|
|
1270
|
+
positionals: resolvePositionals(command, base, settings?.positionals)
|
|
1455
1271
|
};
|
|
1456
1272
|
}
|
|
1457
|
-
function
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
return;
|
|
1466
|
-
}
|
|
1467
|
-
function assertCliCommandName(name) {
|
|
1468
|
-
if (isReservedCliCommandName(name)) {
|
|
1469
|
-
throw new Error(`[stitchkit] CLI command "${name}" is reserved. Rename the command to a word outside the option syntax.`);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
function assertStaticCliCommandNames(services, runtimeTools) {
|
|
1473
|
-
for (const tool of runtimeTools) {
|
|
1474
|
-
assertNoLegacyTransports(tool, `Runtime tool "${tool.name}"`);
|
|
1475
|
-
if (tool.expose?.includes("CLI"))
|
|
1476
|
-
assertCliCommandName(tool.name);
|
|
1477
|
-
}
|
|
1478
|
-
for (const service of services) {
|
|
1479
|
-
for (const [key, method] of Object.entries(service.methods)) {
|
|
1480
|
-
const name = projectedContractToolName(service.name, key, method, "CLI") ?? cliStreamIdentity(service.name, key, method)?.name;
|
|
1481
|
-
if (name !== undefined)
|
|
1482
|
-
assertCliCommandName(name);
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
function commandShapeIssue(name, descriptor, exists, passthroughField, applicationGlobals = new Set) {
|
|
1487
|
-
assertUniqueToolName(name, exists, "CLI command");
|
|
1488
|
-
assertCliCommandName(name);
|
|
1489
|
-
assertNoPassthroughAlias(name, descriptor, passthroughField);
|
|
1490
|
-
const fieldNames = jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name);
|
|
1491
|
-
const conflicting = fieldNames.filter((field) => RESERVED_CLI_OPTIONS.has(field));
|
|
1492
|
-
if (conflicting.length > 0) {
|
|
1493
|
-
return `[stitchkit] CLI command "${name}" declares reserved option field(s): ${conflicting.join(", ")}`;
|
|
1494
|
-
}
|
|
1495
|
-
const shadowed = fieldNames.filter((field) => applicationGlobals.has(field));
|
|
1496
|
-
if (shadowed.length > 0) {
|
|
1497
|
-
return `[stitchkit] CLI command "${name}" declares field(s) shadowed by application global options: ${shadowed.join(", ")}`;
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
// src/tools/cli/policy.ts
|
|
1502
|
-
var REMOVED_TOP_LEVEL_KEYS = [
|
|
1503
|
-
"optionAliases",
|
|
1504
|
-
"positionals",
|
|
1505
|
-
"results",
|
|
1506
|
-
"passthrough",
|
|
1507
|
-
"wait"
|
|
1508
|
-
];
|
|
1509
|
-
function assertNoLegacyCliPolicyKeys(config) {
|
|
1510
|
-
if (typeof config !== "object" || config === null)
|
|
1511
|
-
return;
|
|
1512
|
-
for (const key of REMOVED_TOP_LEVEL_KEYS) {
|
|
1513
|
-
if (Object.hasOwn(config, key)) {
|
|
1514
|
-
throw new TypeError(`[stitchkit] CLI option "${key}" was moved into "commandSettings.<command>" — migrate to commandSettings`);
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
var SHORT_ALIAS = /^[A-Za-z]$/;
|
|
1519
|
-
var RESERVED_SHORT_OPTIONS = new Set(["h"]);
|
|
1520
|
-
function fieldMap(descriptor) {
|
|
1521
|
-
return new Map(jsonSchemaFields(descriptor.presentationSchema).map((field) => [field.name, field]));
|
|
1522
|
-
}
|
|
1523
|
-
function resolveAliases(command, descriptor, configured) {
|
|
1524
|
-
if (!configured)
|
|
1525
|
-
return new Map;
|
|
1526
|
-
const fields = fieldMap(descriptor);
|
|
1527
|
-
const aliases = new Map;
|
|
1528
|
-
for (const [alias, target] of Object.entries(configured)) {
|
|
1529
|
-
if (!SHORT_ALIAS.test(alias)) {
|
|
1530
|
-
throw new Error(`[stitchkit] CLI command "${command}" alias "${alias}" must be one ASCII letter`);
|
|
1531
|
-
}
|
|
1532
|
-
if (RESERVED_SHORT_OPTIONS.has(alias)) {
|
|
1533
|
-
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" is reserved`);
|
|
1534
|
-
}
|
|
1535
|
-
if (isUnsafeKey(target) || !fields.has(target)) {
|
|
1536
|
-
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" targets unknown field "${target}"`);
|
|
1537
|
-
}
|
|
1538
|
-
const existing = aliases.get(target);
|
|
1539
|
-
if (existing !== undefined) {
|
|
1540
|
-
throw new Error(`[stitchkit] CLI command "${command}" field "${target}" has multiple aliases: -${existing}, -${alias}`);
|
|
1541
|
-
}
|
|
1542
|
-
aliases.set(target, alias);
|
|
1543
|
-
}
|
|
1544
|
-
return aliases;
|
|
1545
|
-
}
|
|
1546
|
-
function resolvePositionals(command, descriptor, configured) {
|
|
1547
|
-
if (configured === undefined)
|
|
1548
|
-
return;
|
|
1549
|
-
const fields = fieldMap(descriptor);
|
|
1550
|
-
const kinds = describeSchemaFields(descriptor.argumentSchema);
|
|
1551
|
-
const seen = new Set;
|
|
1552
|
-
let optionalSeen = false;
|
|
1553
|
-
for (const name of configured) {
|
|
1554
|
-
const field = fields.get(name);
|
|
1555
|
-
if (isUnsafeKey(name) || !field || !kinds.has(name)) {
|
|
1556
|
-
throw new Error(`[stitchkit] CLI command "${command}" positional targets unknown field "${name}"`);
|
|
1557
|
-
}
|
|
1558
|
-
if (seen.has(name)) {
|
|
1559
|
-
throw new Error(`[stitchkit] CLI command "${command}" repeats positional field "${name}"`);
|
|
1560
|
-
}
|
|
1561
|
-
if (kinds.get(name)?.kind === "boolean") {
|
|
1562
|
-
throw new Error(`[stitchkit] CLI command "${command}" boolean field "${name}" cannot be positional`);
|
|
1563
|
-
}
|
|
1564
|
-
if (optionalSeen && field.required) {
|
|
1565
|
-
throw new Error(`[stitchkit] CLI command "${command}" required positional "${name}" cannot follow an optional positional`);
|
|
1566
|
-
}
|
|
1567
|
-
if (!field.required)
|
|
1568
|
-
optionalSeen = true;
|
|
1569
|
-
seen.add(name);
|
|
1570
|
-
}
|
|
1571
|
-
return [...configured];
|
|
1572
|
-
}
|
|
1573
|
-
function cliCommandSettingsFor(config, command) {
|
|
1574
|
-
return config.commandSettings && Object.hasOwn(config.commandSettings, command) ? config.commandSettings[command] : undefined;
|
|
1575
|
-
}
|
|
1576
|
-
function cliResultPolicy(config, command) {
|
|
1577
|
-
return cliCommandSettingsFor(config, command)?.result;
|
|
1578
|
-
}
|
|
1579
|
-
function cliPassthroughField(config, command) {
|
|
1580
|
-
return cliCommandSettingsFor(config, command)?.passthrough;
|
|
1581
|
-
}
|
|
1582
|
-
function cliWaitConfig(config, command) {
|
|
1583
|
-
return cliCommandSettingsFor(config, command)?.wait;
|
|
1584
|
-
}
|
|
1585
|
-
function applyCliPresentationPolicy(command, descriptor, config) {
|
|
1586
|
-
const base = { ...descriptor, aliases: new Map };
|
|
1587
|
-
const settings = cliCommandSettingsFor(config, command);
|
|
1588
|
-
return {
|
|
1589
|
-
...base,
|
|
1590
|
-
aliases: resolveAliases(command, base, settings?.aliases),
|
|
1591
|
-
positionals: resolvePositionals(command, base, settings?.positionals)
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1594
|
-
function assertCliPoliciesResolved(commands, config) {
|
|
1595
|
-
const configuredNames = new Set(Object.keys(config.commandSettings ?? {}));
|
|
1596
|
-
if (config.defaultCommand !== undefined)
|
|
1597
|
-
configuredNames.add(config.defaultCommand);
|
|
1598
|
-
for (const name of configuredNames) {
|
|
1599
|
-
if (!commands.has(name)) {
|
|
1600
|
-
throw new Error(`[stitchkit] CLI policy targets unavailable command "${name}"`);
|
|
1601
|
-
}
|
|
1273
|
+
function assertCliPoliciesResolved(commands, config) {
|
|
1274
|
+
const configuredNames = new Set(Object.keys(config.commandSettings ?? {}));
|
|
1275
|
+
if (config.defaultCommand !== undefined)
|
|
1276
|
+
configuredNames.add(config.defaultCommand);
|
|
1277
|
+
for (const name of configuredNames) {
|
|
1278
|
+
if (!commands.has(name)) {
|
|
1279
|
+
throw new Error(`[stitchkit] CLI policy targets unavailable command "${name}"`);
|
|
1280
|
+
}
|
|
1602
1281
|
}
|
|
1603
1282
|
}
|
|
1604
1283
|
|
|
@@ -1985,6 +1664,329 @@ function createCliIo(config) {
|
|
|
1985
1664
|
// src/tools/cli/notices.ts
|
|
1986
1665
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1987
1666
|
|
|
1667
|
+
// src/tools/cli/args-view.ts
|
|
1668
|
+
function resolveCliView(flags, ascending) {
|
|
1669
|
+
if (flags.size === 0) {
|
|
1670
|
+
if (ascending) {
|
|
1671
|
+
throw new CliArgumentError2("--ascending orders a record view; pass --sort with it");
|
|
1672
|
+
}
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
const countBy = flags.get("count-by");
|
|
1676
|
+
const sum = flags.get("sum");
|
|
1677
|
+
const table = flags.get("table");
|
|
1678
|
+
const by = flags.get("by");
|
|
1679
|
+
const rawTop = flags.get("top");
|
|
1680
|
+
const named = [
|
|
1681
|
+
["--count-by", countBy],
|
|
1682
|
+
["--sum", sum]
|
|
1683
|
+
].filter(([, value]) => value !== undefined);
|
|
1684
|
+
if (named.length > 1) {
|
|
1685
|
+
throw new CliArgumentError2(`${named.map(([flag]) => flag).join(" and ")} ask for different shapes — pass one`);
|
|
1686
|
+
}
|
|
1687
|
+
let top;
|
|
1688
|
+
if (rawTop !== undefined) {
|
|
1689
|
+
top = Number(rawTop);
|
|
1690
|
+
if (!Number.isInteger(top) || top <= 0) {
|
|
1691
|
+
throw new CliArgumentError2("--top must be a positive whole number");
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
const sort = flags.get("sort");
|
|
1695
|
+
if (table !== undefined || sort !== undefined) {
|
|
1696
|
+
if (countBy !== undefined || sum !== undefined) {
|
|
1697
|
+
throw new CliArgumentError2(`${table !== undefined ? "--table" : "--sort"} lists records; --count-by and --sum aggregate them — pass one`);
|
|
1698
|
+
}
|
|
1699
|
+
if (by !== undefined) {
|
|
1700
|
+
throw new CliArgumentError2("--by groups a view; a record view orders with --sort");
|
|
1701
|
+
}
|
|
1702
|
+
if (top !== undefined && sort === undefined) {
|
|
1703
|
+
throw new CliArgumentError2("--top needs --sort here: unordered records have no n largest");
|
|
1704
|
+
}
|
|
1705
|
+
let fields;
|
|
1706
|
+
if (table !== undefined) {
|
|
1707
|
+
fields = table.split(",").map((field) => field.trim()).filter(Boolean);
|
|
1708
|
+
if (fields.length === 0)
|
|
1709
|
+
throw new CliArgumentError2("--table needs at least one field");
|
|
1710
|
+
}
|
|
1711
|
+
return {
|
|
1712
|
+
kind: "records",
|
|
1713
|
+
...sort !== undefined && { sort },
|
|
1714
|
+
...ascending && { ascending },
|
|
1715
|
+
...top !== undefined && { top },
|
|
1716
|
+
...fields && { table: fields }
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
if (ascending) {
|
|
1720
|
+
throw new CliArgumentError2("--ascending orders a record view; pass --sort with it");
|
|
1721
|
+
}
|
|
1722
|
+
if (sum !== undefined) {
|
|
1723
|
+
if (top !== undefined && by === undefined) {
|
|
1724
|
+
throw new CliArgumentError2("--top needs --by: a single sum has nothing to rank");
|
|
1725
|
+
}
|
|
1726
|
+
return {
|
|
1727
|
+
kind: "sum",
|
|
1728
|
+
field: sum,
|
|
1729
|
+
...by !== undefined && { by },
|
|
1730
|
+
...top !== undefined && { top }
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
if (countBy !== undefined) {
|
|
1734
|
+
if (by !== undefined) {
|
|
1735
|
+
throw new CliArgumentError2("--count-by already names the grouping field; drop --by");
|
|
1736
|
+
}
|
|
1737
|
+
return { kind: "count", field: countBy, ...top !== undefined && { top } };
|
|
1738
|
+
}
|
|
1739
|
+
if (by !== undefined) {
|
|
1740
|
+
if (top === undefined) {
|
|
1741
|
+
throw new CliArgumentError2("--by groups a view; pass --count-by, --sum or --top with it");
|
|
1742
|
+
}
|
|
1743
|
+
return { kind: "count", field: by, top };
|
|
1744
|
+
}
|
|
1745
|
+
throw new CliArgumentError2("--top needs --sort, --by, --count-by or --sum to rank");
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
// src/tools/cli/args-framework.ts
|
|
1749
|
+
function deferScanError(ctx, error) {
|
|
1750
|
+
ctx.deferredError ??= error;
|
|
1751
|
+
}
|
|
1752
|
+
function recordAppGlobalError(ctx, error) {
|
|
1753
|
+
ctx.appGlobalError ??= error;
|
|
1754
|
+
deferScanError(ctx, error);
|
|
1755
|
+
}
|
|
1756
|
+
function pushRestToken(ctx, token, index) {
|
|
1757
|
+
ctx.withoutGlobals.push(token);
|
|
1758
|
+
ctx.withoutCommand.push(token);
|
|
1759
|
+
ctx.withoutCommandFrom.push(index);
|
|
1760
|
+
}
|
|
1761
|
+
function pushCommandToken(ctx, token, index) {
|
|
1762
|
+
if ((ctx.removedAfterCmdToken || ctx.separatedInput.has(index)) && ctx.commandTokens.length > 0) {
|
|
1763
|
+
ctx.separatedBefore.add(ctx.commandTokens.length);
|
|
1764
|
+
}
|
|
1765
|
+
ctx.removedAfterCmdToken = false;
|
|
1766
|
+
ctx.commandTokens.push(token);
|
|
1767
|
+
pushRestToken(ctx, token, index);
|
|
1768
|
+
}
|
|
1769
|
+
function withoutCommandSeparations(ctx) {
|
|
1770
|
+
const separated = new Set;
|
|
1771
|
+
ctx.withoutCommandFrom.forEach((from, at) => {
|
|
1772
|
+
if (at > 0 && ctx.separatedInput.has(from))
|
|
1773
|
+
separated.add(at);
|
|
1774
|
+
});
|
|
1775
|
+
return separated;
|
|
1776
|
+
}
|
|
1777
|
+
function markCommandTokenRemoved(ctx) {
|
|
1778
|
+
if (ctx.commandFound)
|
|
1779
|
+
ctx.removedAfterCmdToken = true;
|
|
1780
|
+
}
|
|
1781
|
+
function tryReadAppGlobalToken(ctx, index, opt, raw, jsonFields) {
|
|
1782
|
+
if (!opt || opt.globalKind !== undefined)
|
|
1783
|
+
return -1;
|
|
1784
|
+
const appField = cliFieldOption(opt, ctx.appFields);
|
|
1785
|
+
const info = ctx.appFields.get(appField.name);
|
|
1786
|
+
if (!info)
|
|
1787
|
+
return -1;
|
|
1788
|
+
if (ctx.bareBool)
|
|
1789
|
+
ctx.bareBool.removedAfter = true;
|
|
1790
|
+
let { value } = opt;
|
|
1791
|
+
let nextIndex = index;
|
|
1792
|
+
if (value === undefined && info.kind === "boolean") {
|
|
1793
|
+
const sep = separateBoolValue(ctx.argv[index + 1]);
|
|
1794
|
+
if (sep !== undefined)
|
|
1795
|
+
nextIndex++;
|
|
1796
|
+
value = String(sep ?? true);
|
|
1797
|
+
} else if (value === undefined) {
|
|
1798
|
+
const next = ctx.argv[index + 1];
|
|
1799
|
+
if (next === undefined || isOptionToken(next)) {
|
|
1800
|
+
recordAppGlobalError(ctx, new CliArgumentError2(`--${opt.name} requires a value`));
|
|
1801
|
+
return nextIndex;
|
|
1802
|
+
}
|
|
1803
|
+
value = next;
|
|
1804
|
+
nextIndex++;
|
|
1805
|
+
} else if (info.kind === "boolean" && !appField.json) {
|
|
1806
|
+
if (raw.has(appField.name)) {
|
|
1807
|
+
appendCliFieldValue(raw, jsonFields, appField.name, value, info, appField.json);
|
|
1808
|
+
return nextIndex;
|
|
1809
|
+
}
|
|
1810
|
+
try {
|
|
1811
|
+
parseReservedBool(appField.name, value);
|
|
1812
|
+
} catch (error) {
|
|
1813
|
+
if (error instanceof CliArgumentError2)
|
|
1814
|
+
recordAppGlobalError(ctx, error);
|
|
1815
|
+
else
|
|
1816
|
+
throw error;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
appendCliFieldValue(raw, jsonFields, appField.name, value, info, appField.json);
|
|
1820
|
+
return nextIndex;
|
|
1821
|
+
}
|
|
1822
|
+
function reservedJsonTarget(opt) {
|
|
1823
|
+
if (!opt?.inline || !opt.name.endsWith(":"))
|
|
1824
|
+
return;
|
|
1825
|
+
const target = opt.name.slice(0, -1);
|
|
1826
|
+
return RESERVED_CLI_OPTIONS.has(target) ? target : undefined;
|
|
1827
|
+
}
|
|
1828
|
+
function consumeFrameworkOptionToken(argv, index, opt, state, callbacks) {
|
|
1829
|
+
const adjacent = callbacks.adjacent ?? (() => true);
|
|
1830
|
+
const report = (error) => {
|
|
1831
|
+
if (opt.name === "schema") {
|
|
1832
|
+
state.fw.schema = false;
|
|
1833
|
+
state.schemaInvalid = true;
|
|
1834
|
+
} else if (opt.name === "help")
|
|
1835
|
+
state.fw.help = false;
|
|
1836
|
+
callbacks.onError(error);
|
|
1837
|
+
};
|
|
1838
|
+
const record = (name, raw, kind) => {
|
|
1839
|
+
try {
|
|
1840
|
+
appendCliOptionValue(state.fwFlags, name, raw, { kind });
|
|
1841
|
+
return true;
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
if (error instanceof CliArgumentError2) {
|
|
1844
|
+
report(error);
|
|
1845
|
+
return false;
|
|
1846
|
+
}
|
|
1847
|
+
throw error;
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
let nextIdx = index;
|
|
1851
|
+
if (opt.globalKind === "boolean") {
|
|
1852
|
+
const following = argv[index + 1];
|
|
1853
|
+
if (!opt.inline && !adjacent(index + 1) && following !== undefined && separateBoolValue(following) !== undefined) {
|
|
1854
|
+
report(brokenBooleanBoundaryError(opt.name, following));
|
|
1855
|
+
if (opt.name === "help" || opt.name === "schema")
|
|
1856
|
+
return nextIdx;
|
|
1857
|
+
}
|
|
1858
|
+
const nextTok = adjacent(index + 1) ? following : undefined;
|
|
1859
|
+
const sep = opt.inline ? undefined : separateBoolValue(nextTok);
|
|
1860
|
+
if (sep !== undefined && nextTok !== undefined) {
|
|
1861
|
+
nextIdx++;
|
|
1862
|
+
callbacks.onValueToken?.(nextTok);
|
|
1863
|
+
}
|
|
1864
|
+
const rawValue = opt.value ?? String(sep ?? true);
|
|
1865
|
+
if (opt.name !== "help" && !record(opt.name, rawValue, "boolean"))
|
|
1866
|
+
return nextIdx;
|
|
1867
|
+
let enabled;
|
|
1868
|
+
if (opt.inline) {
|
|
1869
|
+
try {
|
|
1870
|
+
enabled = parseReservedBool(opt.name, opt.value ?? "");
|
|
1871
|
+
} catch (error) {
|
|
1872
|
+
if (error instanceof CliArgumentError2) {
|
|
1873
|
+
report(error);
|
|
1874
|
+
return nextIdx;
|
|
1875
|
+
}
|
|
1876
|
+
throw error;
|
|
1877
|
+
}
|
|
1878
|
+
} else {
|
|
1879
|
+
enabled = sep ?? true;
|
|
1880
|
+
}
|
|
1881
|
+
if (!opt.inline && sep === undefined)
|
|
1882
|
+
callbacks.onBareBoolean?.(opt.name);
|
|
1883
|
+
if (opt.name === "dry-run")
|
|
1884
|
+
state.fw.dryRun = enabled;
|
|
1885
|
+
else if (opt.name === "json")
|
|
1886
|
+
state.fw.json = enabled;
|
|
1887
|
+
else if (opt.name === "wait")
|
|
1888
|
+
state.fw.wait = enabled;
|
|
1889
|
+
else if (opt.name === "quiet")
|
|
1890
|
+
state.fw.quiet = enabled;
|
|
1891
|
+
else if (opt.name === "ascending")
|
|
1892
|
+
state.ascending = enabled;
|
|
1893
|
+
else if (opt.name === "schema") {
|
|
1894
|
+
state.fw.schema = !state.schemaInvalid && (state.fw.schema || enabled);
|
|
1895
|
+
} else if (opt.name === "help")
|
|
1896
|
+
state.fw.help = state.fw.help || enabled;
|
|
1897
|
+
return nextIdx;
|
|
1898
|
+
}
|
|
1899
|
+
let value = opt.value;
|
|
1900
|
+
if (!opt.inline) {
|
|
1901
|
+
const next = adjacent(index + 1) ? argv[index + 1] : undefined;
|
|
1902
|
+
if (next === undefined || isOptionToken(next)) {
|
|
1903
|
+
report(new CliArgumentError2(`--${opt.name} requires a value`));
|
|
1904
|
+
if (callbacks.onMissingValue?.(next))
|
|
1905
|
+
nextIdx++;
|
|
1906
|
+
} else {
|
|
1907
|
+
value = next;
|
|
1908
|
+
nextIdx++;
|
|
1909
|
+
callbacks.onValueToken?.(next);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
if (value !== undefined) {
|
|
1913
|
+
if (!record(opt.name, value, "string"))
|
|
1914
|
+
return nextIdx;
|
|
1915
|
+
if (opt.name === "wait-timeout") {
|
|
1916
|
+
const n = Number(value);
|
|
1917
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
1918
|
+
report(new CliArgumentError2("--wait-timeout must be a positive number"));
|
|
1919
|
+
} else {
|
|
1920
|
+
state.fw.waitTimeout = n;
|
|
1921
|
+
}
|
|
1922
|
+
} else if (VIEW_OPTIONS.has(opt.name))
|
|
1923
|
+
state.viewFlags.set(opt.name, value);
|
|
1924
|
+
else
|
|
1925
|
+
state.fw.outputDir = value;
|
|
1926
|
+
}
|
|
1927
|
+
return nextIdx;
|
|
1928
|
+
}
|
|
1929
|
+
function readFrameworkOptionToken(ctx, index, token, opt) {
|
|
1930
|
+
ctx.bareBool = undefined;
|
|
1931
|
+
pushRestToken(ctx, token, index);
|
|
1932
|
+
return consumeFrameworkOptionToken(ctx.argv, index, opt, ctx, {
|
|
1933
|
+
adjacent: (at) => !ctx.separatedInput.has(at),
|
|
1934
|
+
onError: (error) => deferScanError(ctx, error),
|
|
1935
|
+
onValueToken: (valueToken) => pushRestToken(ctx, valueToken, index + 1),
|
|
1936
|
+
onBareBoolean: (name) => {
|
|
1937
|
+
ctx.bareBool = { name, removedAfter: false };
|
|
1938
|
+
},
|
|
1939
|
+
onMissingValue: (next) => {
|
|
1940
|
+
if (!ctx.commandFound && next !== undefined && !isOwnLeadingToken(next, ctx.appFields)) {
|
|
1941
|
+
pushRestToken(ctx, next, index + 1);
|
|
1942
|
+
return true;
|
|
1943
|
+
}
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
function finalizeFrameworkView(ctx) {
|
|
1949
|
+
if (ctx.viewFlags.size === 0 && !ctx.ascending)
|
|
1950
|
+
return;
|
|
1951
|
+
try {
|
|
1952
|
+
ctx.fw.view = resolveCliView(ctx.viewFlags, ctx.ascending);
|
|
1953
|
+
} catch (error) {
|
|
1954
|
+
if (error instanceof CliArgumentError2)
|
|
1955
|
+
deferScanError(ctx, error);
|
|
1956
|
+
else
|
|
1957
|
+
throw error;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
function createFrameworkStepContext(argv, appFields, separatedInput = new Set) {
|
|
1961
|
+
return {
|
|
1962
|
+
argv,
|
|
1963
|
+
appFields,
|
|
1964
|
+
fwFlags: new Map,
|
|
1965
|
+
viewFlags: new Map,
|
|
1966
|
+
fw: { json: false, quiet: false, help: false, schema: false, dryRun: false, wait: false },
|
|
1967
|
+
ascending: false,
|
|
1968
|
+
commandFound: false,
|
|
1969
|
+
withoutGlobals: [],
|
|
1970
|
+
withoutCommand: [],
|
|
1971
|
+
withoutCommandFrom: [],
|
|
1972
|
+
commandTokens: [],
|
|
1973
|
+
separatedBefore: new Set,
|
|
1974
|
+
removedAfterCmdToken: false,
|
|
1975
|
+
separatedInput
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
function coerceAppGlobalMap(raw, fields, jsonFields) {
|
|
1979
|
+
const coerced = {};
|
|
1980
|
+
for (const [name, values] of raw) {
|
|
1981
|
+
coerced[name] = coerceCliFieldValue(fields.get(name), values, `--${name}`, jsonFields.has(name));
|
|
1982
|
+
}
|
|
1983
|
+
return coerced;
|
|
1984
|
+
}
|
|
1985
|
+
function brokenBooleanBoundaryError(flagName, word) {
|
|
1986
|
+
const flag = flagName.startsWith("-") ? flagName : `--${flagName}`;
|
|
1987
|
+
return new CliArgumentError2(`Bare ${flag} cannot be separated from "${word}" — use ${flag}=true, ${flag}=false or "-- ${word}"`);
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1988
1990
|
// src/tools/cli/args-scan.ts
|
|
1989
1991
|
var EMPTY_FIELDS = new Map;
|
|
1990
1992
|
function optionBeforeCommandError(token) {
|