@steipete/summarize 0.17.3 → 0.18.1
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 +51 -0
- package/README.md +21 -2
- package/completions/summarize.fish +162 -0
- package/dist/esm/application/api-status.js +31 -0
- package/dist/esm/application/api-status.js.map +1 -0
- package/dist/esm/application/cli-fallback-state.js.map +1 -0
- package/dist/esm/{run/run-config.js → application/config-state.js} +32 -23
- package/dist/esm/application/config-state.js.map +1 -0
- package/dist/esm/application/context.js +15 -0
- package/dist/esm/application/context.js.map +1 -0
- package/dist/esm/{run/run-env.js → application/environment-state.js} +2 -2
- package/dist/esm/application/environment-state.js.map +1 -0
- package/dist/esm/application/environment.js +65 -0
- package/dist/esm/application/environment.js.map +1 -0
- package/dist/esm/application/execute-summarize.js +592 -0
- package/dist/esm/application/execute-summarize.js.map +1 -0
- package/dist/esm/application/execution-resources.js +159 -0
- package/dist/esm/application/execution-resources.js.map +1 -0
- package/dist/esm/{run/runner-contexts.js → application/flow-contexts.js} +17 -55
- package/dist/esm/application/flow-contexts.js.map +1 -0
- package/dist/esm/application/input-acquisition.js +147 -0
- package/dist/esm/application/input-acquisition.js.map +1 -0
- package/dist/esm/{run/run-metrics.js → application/metrics.js} +3 -3
- package/dist/esm/{run/run-metrics.js.map → application/metrics.js.map} +1 -1
- package/dist/esm/application/model-attempts.js +52 -0
- package/dist/esm/application/model-attempts.js.map +1 -0
- package/dist/esm/application/model-catalog.js +34 -0
- package/dist/esm/application/model-catalog.js.map +1 -0
- package/dist/esm/application/model-runtime.js +77 -0
- package/dist/esm/application/model-runtime.js.map +1 -0
- package/dist/esm/{run/run-models.js → application/model-selection.js} +2 -2
- package/dist/esm/application/model-selection.js.map +1 -0
- package/dist/esm/{run/run-output.js → application/output-policy.js} +2 -2
- package/dist/esm/application/output-policy.js.map +1 -0
- package/dist/esm/application/provider-runtime.js +37 -0
- package/dist/esm/application/provider-runtime.js.map +1 -0
- package/dist/esm/application/run-spec.js +110 -0
- package/dist/esm/application/run-spec.js.map +1 -0
- package/dist/esm/{run/stdin-temp-file.js → application/stdin-input.js} +1 -1
- package/dist/esm/{run/stdin-temp-file.js.map → application/stdin-input.js.map} +1 -1
- package/dist/esm/application/summarize-contracts.js +2 -0
- package/dist/esm/application/summarize-contracts.js.map +1 -0
- package/dist/esm/application/url-result.js +18 -0
- package/dist/esm/application/url-result.js.map +1 -0
- package/dist/esm/application/url-runtime.js +86 -0
- package/dist/esm/application/url-runtime.js.map +1 -0
- package/dist/esm/cache.js +7 -3
- package/dist/esm/cache.js.map +1 -1
- package/dist/esm/cli-main.js +33 -5
- package/dist/esm/cli-main.js.map +1 -1
- package/dist/esm/config/sections.js +7 -1
- package/dist/esm/config/sections.js.map +1 -1
- package/dist/esm/content/asset.js +36 -19
- package/dist/esm/content/asset.js.map +1 -1
- package/dist/esm/daemon/agent-cache.js +72 -0
- package/dist/esm/daemon/agent-cache.js.map +1 -0
- package/dist/esm/daemon/agent-model.js +97 -155
- package/dist/esm/daemon/agent-model.js.map +1 -1
- package/dist/esm/daemon/agent.js +9 -1
- package/dist/esm/daemon/agent.js.map +1 -1
- package/dist/esm/daemon/chat.js +33 -228
- package/dist/esm/daemon/chat.js.map +1 -1
- package/dist/esm/daemon/model-discovery.js +50 -0
- package/dist/esm/daemon/model-discovery.js.map +1 -0
- package/dist/esm/daemon/models.js +123 -190
- package/dist/esm/daemon/models.js.map +1 -1
- package/dist/esm/daemon/server-agent-route.js +39 -8
- package/dist/esm/daemon/server-agent-route.js.map +1 -1
- package/dist/esm/daemon/server-auth.js +29 -0
- package/dist/esm/daemon/server-auth.js.map +1 -0
- package/dist/esm/daemon/server-event-channel.js +30 -0
- package/dist/esm/daemon/server-event-channel.js.map +1 -0
- package/dist/esm/daemon/server-refresh-route.js +65 -0
- package/dist/esm/daemon/server-refresh-route.js.map +1 -0
- package/dist/esm/daemon/server-runtime.js +139 -0
- package/dist/esm/daemon/server-runtime.js.map +1 -0
- package/dist/esm/daemon/server-session-routes.js +16 -13
- package/dist/esm/daemon/server-session-routes.js.map +1 -1
- package/dist/esm/daemon/server-session.js +16 -55
- package/dist/esm/daemon/server-session.js.map +1 -1
- package/dist/esm/daemon/server-sse.js +1 -1
- package/dist/esm/daemon/server-sse.js.map +1 -1
- package/dist/esm/daemon/server-summarize-events.js +235 -0
- package/dist/esm/daemon/server-summarize-events.js.map +1 -0
- package/dist/esm/daemon/server-summarize-execution.js +94 -264
- package/dist/esm/daemon/server-summarize-execution.js.map +1 -1
- package/dist/esm/daemon/server-summarize-request.js +1 -17
- package/dist/esm/daemon/server-summarize-request.js.map +1 -1
- package/dist/esm/daemon/server-summarize-route.js +191 -0
- package/dist/esm/daemon/server-summarize-route.js.map +1 -0
- package/dist/esm/daemon/server.js +54 -379
- package/dist/esm/daemon/server.js.map +1 -1
- package/dist/esm/daemon/summarize-presentation.js +74 -0
- package/dist/esm/daemon/summarize-presentation.js.map +1 -0
- package/dist/esm/daemon/url-fetch-guard.js +12 -226
- package/dist/esm/daemon/url-fetch-guard.js.map +1 -1
- package/dist/esm/engine/cli-model-id.js +21 -0
- package/dist/esm/engine/cli-model-id.js.map +1 -0
- package/dist/esm/engine/errors.js +20 -0
- package/dist/esm/engine/errors.js.map +1 -0
- package/dist/esm/engine/events.js +2 -0
- package/dist/esm/engine/events.js.map +1 -0
- package/dist/esm/engine/fetch-with-timeout.js.map +1 -0
- package/dist/esm/engine/fixed-model-attempt.js +41 -0
- package/dist/esm/engine/fixed-model-attempt.js.map +1 -0
- package/dist/esm/{run → engine}/model-attempts.js +4 -0
- package/dist/esm/engine/model-attempts.js.map +1 -0
- package/dist/esm/{run/summary-llm.js → engine/model-call.js} +1 -1
- package/dist/esm/engine/model-call.js.map +1 -0
- package/dist/esm/engine/model-executor.js +389 -0
- package/dist/esm/engine/model-executor.js.map +1 -0
- package/dist/esm/engine/model-meta.js +12 -0
- package/dist/esm/engine/model-meta.js.map +1 -0
- package/dist/esm/engine/openrouter.js.map +1 -0
- package/dist/esm/engine/provider-attempt.js +19 -0
- package/dist/esm/engine/provider-attempt.js.map +1 -0
- package/dist/esm/{run → engine}/streaming.js +1 -1
- package/dist/esm/engine/streaming.js.map +1 -0
- package/dist/esm/engine/summary-execution.js +152 -0
- package/dist/esm/engine/summary-execution.js.map +1 -0
- package/dist/esm/engine/summary-timestamps.js.map +1 -0
- package/dist/esm/{run → engine}/types.js.map +1 -1
- package/dist/esm/{run/flows/url/summary-prompt.js → engine/web-prompt.js} +5 -4
- package/dist/esm/engine/web-prompt.js.map +1 -0
- package/dist/esm/engine/web-summary.js +175 -0
- package/dist/esm/engine/web-summary.js.map +1 -0
- package/dist/esm/flags.js +10 -0
- package/dist/esm/flags.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/llm/cli-exec.js +36 -1
- package/dist/esm/llm/cli-exec.js.map +1 -1
- package/dist/esm/llm/cli.js +13 -2
- package/dist/esm/llm/cli.js.map +1 -1
- package/dist/esm/llm/generate-text-stream.js +58 -21
- package/dist/esm/llm/generate-text-stream.js.map +1 -1
- package/dist/esm/llm/generate-text-types.js +2 -0
- package/dist/esm/llm/generate-text-types.js.map +1 -0
- package/dist/esm/llm/generate-text.js +21 -88
- package/dist/esm/llm/generate-text.js.map +1 -1
- package/dist/esm/llm/openai-client-config.js +47 -0
- package/dist/esm/llm/openai-client-config.js.map +1 -0
- package/dist/esm/llm/provider-capabilities.js +1 -1
- package/dist/esm/llm/provider-capabilities.js.map +1 -1
- package/dist/esm/llm/provider-profile.js +139 -49
- package/dist/esm/llm/provider-profile.js.map +1 -1
- package/dist/esm/llm/providers/models.js +28 -0
- package/dist/esm/llm/providers/models.js.map +1 -1
- package/dist/esm/llm/providers/openai/chat-completions.js +100 -0
- package/dist/esm/llm/providers/openai/chat-completions.js.map +1 -0
- package/dist/esm/llm/providers/openai/github-models.js +30 -0
- package/dist/esm/llm/providers/openai/github-models.js.map +1 -0
- package/dist/esm/llm/providers/openai/request-options.js +42 -0
- package/dist/esm/llm/providers/openai/request-options.js.map +1 -0
- package/dist/esm/llm/providers/openai/responses.js +166 -0
- package/dist/esm/llm/providers/openai/responses.js.map +1 -0
- package/dist/esm/llm/providers/openai/sse.js +57 -0
- package/dist/esm/llm/providers/openai/sse.js.map +1 -0
- package/dist/esm/llm/providers/openai/transport.js +109 -0
- package/dist/esm/llm/providers/openai/transport.js.map +1 -0
- package/dist/esm/llm/providers/openai/types.js +2 -0
- package/dist/esm/llm/providers/openai/types.js.map +1 -0
- package/dist/esm/llm/providers/openai.js +8 -549
- package/dist/esm/llm/providers/openai.js.map +1 -1
- package/dist/esm/logging/daemon.js +9 -1
- package/dist/esm/logging/daemon.js.map +1 -1
- package/dist/esm/media-cache.js +151 -65
- package/dist/esm/media-cache.js.map +1 -1
- package/dist/esm/refresh-free/benchmark.js +267 -0
- package/dist/esm/refresh-free/benchmark.js.map +1 -0
- package/dist/esm/refresh-free/catalog.js +118 -0
- package/dist/esm/refresh-free/catalog.js.map +1 -0
- package/dist/esm/refresh-free/config.js +110 -0
- package/dist/esm/refresh-free/config.js.map +1 -0
- package/dist/esm/refresh-free/presentation.js +161 -0
- package/dist/esm/refresh-free/presentation.js.map +1 -0
- package/dist/esm/refresh-free.js +68 -623
- package/dist/esm/refresh-free.js.map +1 -1
- package/dist/esm/run/cli-input-progress.js +114 -0
- package/dist/esm/run/cli-input-progress.js.map +1 -0
- package/dist/esm/run/cli-preflight.js +5 -1
- package/dist/esm/run/cli-preflight.js.map +1 -1
- package/dist/esm/run/cli-summarize-command.js +285 -0
- package/dist/esm/run/cli-summarize-command.js.map +1 -0
- package/dist/esm/run/cli-summarize-execution.js +75 -0
- package/dist/esm/run/cli-summarize-execution.js.map +1 -0
- package/dist/esm/run/cli-summarize-output.js +85 -0
- package/dist/esm/run/cli-summarize-output.js.map +1 -0
- package/dist/esm/run/cli-summarize-request.js +79 -0
- package/dist/esm/run/cli-summarize-request.js.map +1 -0
- package/dist/esm/run/constants.js +0 -33
- package/dist/esm/run/constants.js.map +1 -1
- package/dist/esm/run/env.js +2 -84
- package/dist/esm/run/env.js.map +1 -1
- package/dist/esm/run/flows/asset/extract.js +8 -3
- package/dist/esm/run/flows/asset/extract.js.map +1 -1
- package/dist/esm/run/flows/asset/media.js +50 -40
- package/dist/esm/run/flows/asset/media.js.map +1 -1
- package/dist/esm/run/flows/asset/output.js +8 -19
- package/dist/esm/run/flows/asset/output.js.map +1 -1
- package/dist/esm/run/flows/asset/preprocess.js.map +1 -1
- package/dist/esm/run/flows/asset/summary-attempts.js +19 -71
- package/dist/esm/run/flows/asset/summary-attempts.js.map +1 -1
- package/dist/esm/run/flows/asset/summary.js +189 -391
- package/dist/esm/run/flows/asset/summary.js.map +1 -1
- package/dist/esm/run/flows/asset/types.js +2 -0
- package/dist/esm/run/flows/asset/types.js.map +1 -0
- package/dist/esm/run/flows/url/extraction-session.js +1 -0
- package/dist/esm/run/flows/url/extraction-session.js.map +1 -1
- package/dist/esm/run/flows/url/fetch-options.js +3 -0
- package/dist/esm/run/flows/url/fetch-options.js.map +1 -1
- package/dist/esm/run/flows/url/flow.js +23 -20
- package/dist/esm/run/flows/url/flow.js.map +1 -1
- package/dist/esm/run/flows/url/markdown.js +54 -201
- package/dist/esm/run/flows/url/markdown.js.map +1 -1
- package/dist/esm/run/flows/url/slides-output-render.js +1 -1
- package/dist/esm/run/flows/url/slides-output-render.js.map +1 -1
- package/dist/esm/run/flows/url/slides-output-stream.js +32 -11
- package/dist/esm/run/flows/url/slides-output-stream.js.map +1 -1
- package/dist/esm/run/flows/url/slides-output.js.map +1 -1
- package/dist/esm/run/flows/url/slides-session.js +1 -1
- package/dist/esm/run/flows/url/slides-session.js.map +1 -1
- package/dist/esm/run/flows/url/summary-finish.js +1 -11
- package/dist/esm/run/flows/url/summary-finish.js.map +1 -1
- package/dist/esm/run/flows/url/summary-json.js +2 -11
- package/dist/esm/run/flows/url/summary-json.js.map +1 -1
- package/dist/esm/run/flows/url/summary.js +36 -33
- package/dist/esm/run/flows/url/summary.js.map +1 -1
- package/dist/esm/run/flows/url/types.js.map +1 -1
- package/dist/esm/run/flows/url/video-only.js +14 -9
- package/dist/esm/run/flows/url/video-only.js.map +1 -1
- package/dist/esm/run/format.js +1 -3
- package/dist/esm/run/format.js.map +1 -1
- package/dist/esm/run/help.js +18 -1
- package/dist/esm/run/help.js.map +1 -1
- package/dist/esm/run/run-input.js +1 -1
- package/dist/esm/run/run-input.js.map +1 -1
- package/dist/esm/run/run-settings.js +23 -3
- package/dist/esm/run/run-settings.js.map +1 -1
- package/dist/esm/run/runner-flags.js +2 -0
- package/dist/esm/run/runner-flags.js.map +1 -1
- package/dist/esm/run/runner.js +6 -9
- package/dist/esm/run/runner.js.map +1 -1
- package/dist/esm/run/slides-cli.js +1 -1
- package/dist/esm/run/slides-cli.js.map +1 -1
- package/dist/esm/run/status-cli.js +339 -0
- package/dist/esm/run/status-cli.js.map +1 -0
- package/dist/esm/run/stream-output.js +22 -7
- package/dist/esm/run/stream-output.js.map +1 -1
- package/dist/esm/run/summary-stream.js +70 -0
- package/dist/esm/run/summary-stream.js.map +1 -0
- package/dist/esm/shared/format-count.js +19 -0
- package/dist/esm/shared/format-count.js.map +1 -0
- package/dist/esm/shared/run-api-status.js +12 -0
- package/dist/esm/shared/run-api-status.js.map +1 -0
- package/dist/esm/shared/summary-length.js +4 -0
- package/dist/esm/shared/summary-length.js.map +1 -0
- package/dist/esm/slides/extract.js +2 -1
- package/dist/esm/slides/extract.js.map +1 -1
- package/dist/esm/slides/frame-extraction.js +2 -2
- package/dist/esm/slides/frame-extraction.js.map +1 -1
- package/dist/esm/slides/settings.js +1 -1
- package/dist/esm/slides/settings.js.map +1 -1
- package/dist/esm/tty/format.js +1 -18
- package/dist/esm/tty/format.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/application/api-status.d.ts +3 -0
- package/dist/types/{run/run-config.d.ts → application/config-state.d.ts} +18 -7
- package/dist/types/application/context.d.ts +8 -0
- package/dist/types/application/environment.d.ts +7 -0
- package/dist/types/application/execute-summarize.d.ts +3 -0
- package/dist/types/application/execution-resources.d.ts +65 -0
- package/dist/types/application/flow-contexts.d.ts +20 -0
- package/dist/types/application/input-acquisition.d.ts +46 -0
- package/dist/types/application/model-attempts.d.ts +36 -0
- package/dist/types/application/model-catalog.d.ts +4 -0
- package/dist/types/application/model-runtime.d.ts +63 -0
- package/dist/types/application/provider-runtime.d.ts +12 -0
- package/dist/types/application/run-spec.d.ts +49 -0
- package/dist/types/application/summarize-contracts.d.ts +201 -0
- package/dist/types/application/url-result.d.ts +36 -0
- package/dist/types/application/url-runtime.d.ts +18 -0
- package/dist/types/cache.d.ts +2 -2
- package/dist/types/cli-main.d.ts +1 -0
- package/dist/types/config/sections.d.ts +3 -2
- package/dist/types/config/types.d.ts +2 -0
- package/dist/types/content/asset.d.ts +3 -0
- package/dist/types/daemon/agent-cache.d.ts +21 -0
- package/dist/types/daemon/agent-model.d.ts +14 -2
- package/dist/types/daemon/agent.d.ts +2 -1
- package/dist/types/daemon/model-discovery.d.ts +9 -0
- package/dist/types/daemon/models.d.ts +22 -20
- package/dist/types/daemon/server-agent-route.d.ts +3 -1
- package/dist/types/daemon/server-auth.d.ts +11 -0
- package/dist/types/daemon/server-event-channel.d.ts +14 -0
- package/dist/types/daemon/server-refresh-route.d.ts +15 -0
- package/dist/types/daemon/server-runtime.d.ts +34 -0
- package/dist/types/daemon/server-session.d.ts +4 -16
- package/dist/types/daemon/server-sse.d.ts +1 -1
- package/dist/types/daemon/server-summarize-events.d.ts +54 -0
- package/dist/types/daemon/server-summarize-execution.d.ts +8 -18
- package/dist/types/daemon/server-summarize-request.d.ts +2 -2
- package/dist/types/daemon/server-summarize-route.d.ts +24 -0
- package/dist/types/daemon/server.d.ts +3 -8
- package/dist/types/daemon/summarize-presentation.d.ts +11 -0
- package/dist/types/daemon/url-fetch-guard.d.ts +4 -10
- package/dist/types/engine/cli-model-id.d.ts +5 -0
- package/dist/types/engine/errors.d.ts +6 -0
- package/dist/types/engine/events.d.ts +10 -0
- package/dist/types/engine/fixed-model-attempt.d.ts +3 -0
- package/dist/types/{run/summary-engine.d.ts → engine/model-executor.d.ts} +12 -64
- package/dist/types/engine/model-meta.d.ts +8 -0
- package/dist/types/engine/provider-attempt.d.ts +6 -0
- package/dist/types/{run → engine}/streaming.d.ts +1 -1
- package/dist/types/engine/summary-execution.d.ts +46 -0
- package/dist/types/{run/flows/url → engine}/summary-timestamps.d.ts +1 -1
- package/dist/types/{run → engine}/types.d.ts +5 -9
- package/dist/types/{run/flows/url/summary-prompt.d.ts → engine/web-prompt.d.ts} +8 -8
- package/dist/types/engine/web-summary.d.ts +82 -0
- package/dist/types/flags.d.ts +3 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/llm/cli-exec.d.ts +2 -1
- package/dist/types/llm/cli.d.ts +2 -1
- package/dist/types/llm/generate-text-stream.d.ts +2 -1
- package/dist/types/llm/generate-text-types.d.ts +7 -0
- package/dist/types/llm/generate-text.d.ts +3 -7
- package/dist/types/llm/openai-client-config.d.ts +13 -0
- package/dist/types/llm/provider-capabilities.d.ts +2 -2
- package/dist/types/llm/provider-profile.d.ts +37 -1
- package/dist/types/llm/providers/models.d.ts +6 -0
- package/dist/types/llm/providers/openai/chat-completions.d.ts +3 -0
- package/dist/types/llm/providers/openai/github-models.d.ts +2 -0
- package/dist/types/llm/providers/openai/request-options.d.ts +5 -0
- package/dist/types/llm/providers/openai/responses.d.ts +21 -0
- package/dist/types/llm/providers/openai/sse.d.ts +6 -0
- package/dist/types/llm/providers/openai/transport.d.ts +23 -0
- package/dist/types/llm/providers/openai/types.d.ts +26 -0
- package/dist/types/llm/providers/openai.d.ts +4 -42
- package/dist/types/refresh-free/benchmark.d.ts +68 -0
- package/dist/types/refresh-free/catalog.d.ts +25 -0
- package/dist/types/refresh-free/config.d.ts +6 -0
- package/dist/types/refresh-free/presentation.d.ts +55 -0
- package/dist/types/run/cli-input-progress.d.ts +13 -0
- package/dist/types/run/{runner-plan.d.ts → cli-summarize-command.d.ts} +2 -7
- package/dist/types/run/cli-summarize-execution.d.ts +13 -0
- package/dist/types/run/cli-summarize-output.d.ts +8 -0
- package/dist/types/run/cli-summarize-request.d.ts +30 -0
- package/dist/types/run/constants.d.ts +0 -4
- package/dist/types/run/env.d.ts +2 -13
- package/dist/types/run/flows/asset/extract.d.ts +2 -1
- package/dist/types/run/flows/asset/media.d.ts +13 -2
- package/dist/types/run/flows/asset/output.d.ts +10 -16
- package/dist/types/run/flows/asset/preprocess.d.ts +1 -1
- package/dist/types/run/flows/asset/summary-attempts.d.ts +3 -3
- package/dist/types/run/flows/asset/summary.d.ts +4 -119
- package/dist/types/run/flows/asset/types.d.ts +121 -0
- package/dist/types/run/flows/url/fetch-options.d.ts +1 -0
- package/dist/types/run/flows/url/flow.d.ts +26 -2
- package/dist/types/run/flows/url/markdown.d.ts +3 -9
- package/dist/types/run/flows/url/slides-output-state.d.ts +1 -1
- package/dist/types/run/flows/url/slides-output-stream.d.ts +1 -1
- package/dist/types/run/flows/url/slides-output.d.ts +2 -2
- package/dist/types/run/flows/url/summary-finish.d.ts +1 -8
- package/dist/types/run/flows/url/summary-json.d.ts +3 -18
- package/dist/types/run/flows/url/summary.d.ts +13 -13
- package/dist/types/run/flows/url/types.d.ts +8 -66
- package/dist/types/run/flows/url/video-only.d.ts +4 -0
- package/dist/types/run/format.d.ts +1 -8
- package/dist/types/run/help.d.ts +1 -0
- package/dist/types/run/run-settings.d.ts +5 -2
- package/dist/types/run/runner-flags.d.ts +1 -0
- package/dist/types/run/status-cli.d.ts +41 -0
- package/dist/types/run/stream-output.d.ts +3 -2
- package/dist/types/run/summary-stream.d.ts +11 -0
- package/dist/types/shared/format-count.d.ts +1 -0
- package/dist/types/shared/run-api-status.d.ts +44 -0
- package/dist/types/shared/summary-length.d.ts +9 -0
- package/dist/types/tty/format.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/docs/README.md +1 -0
- package/docs/cli.md +7 -2
- package/docs/commands/summarize.md +1 -1
- package/docs/config.md +24 -3
- package/docs/engine.md +109 -0
- package/docs/index.md +1 -1
- package/docs/llm.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/website.md +3 -0
- package/package.json +6 -5
- package/dist/esm/daemon/flow-context.js +0 -355
- package/dist/esm/daemon/flow-context.js.map +0 -1
- package/dist/esm/daemon/summarize.js +0 -314
- package/dist/esm/daemon/summarize.js.map +0 -1
- package/dist/esm/run/cli-fallback-state.js.map +0 -1
- package/dist/esm/run/fetch-with-timeout.js.map +0 -1
- package/dist/esm/run/flows/asset/input.js +0 -312
- package/dist/esm/run/flows/asset/input.js.map +0 -1
- package/dist/esm/run/flows/url/slides-text-markdown.js +0 -550
- package/dist/esm/run/flows/url/slides-text-markdown.js.map +0 -1
- package/dist/esm/run/flows/url/slides-text-transcript.js +0 -208
- package/dist/esm/run/flows/url/slides-text-transcript.js.map +0 -1
- package/dist/esm/run/flows/url/slides-text-types.js +0 -2
- package/dist/esm/run/flows/url/slides-text-types.js.map +0 -1
- package/dist/esm/run/flows/url/slides-text.js +0 -3
- package/dist/esm/run/flows/url/slides-text.js.map +0 -1
- package/dist/esm/run/flows/url/summary-prompt.js.map +0 -1
- package/dist/esm/run/flows/url/summary-resolution.js +0 -349
- package/dist/esm/run/flows/url/summary-resolution.js.map +0 -1
- package/dist/esm/run/flows/url/summary-timestamps.js.map +0 -1
- package/dist/esm/run/model-attempts.js.map +0 -1
- package/dist/esm/run/openrouter.js.map +0 -1
- package/dist/esm/run/run-config.js.map +0 -1
- package/dist/esm/run/run-context.js +0 -19
- package/dist/esm/run/run-context.js.map +0 -1
- package/dist/esm/run/run-env.js.map +0 -1
- package/dist/esm/run/run-models.js.map +0 -1
- package/dist/esm/run/run-output.js.map +0 -1
- package/dist/esm/run/runner-contexts.js.map +0 -1
- package/dist/esm/run/runner-execution.js +0 -164
- package/dist/esm/run/runner-execution.js.map +0 -1
- package/dist/esm/run/runner-plan.js +0 -419
- package/dist/esm/run/runner-plan.js.map +0 -1
- package/dist/esm/run/streaming.js.map +0 -1
- package/dist/esm/run/summary-engine.js +0 -536
- package/dist/esm/run/summary-engine.js.map +0 -1
- package/dist/esm/run/summary-llm.js.map +0 -1
- package/dist/esm/shared/cache-store.js +0 -68
- package/dist/esm/shared/cache-store.js.map +0 -1
- package/dist/esm/shared/contracts.js +0 -2
- package/dist/esm/shared/contracts.js.map +0 -1
- package/dist/esm/shared/dns-pinned-fetch.js +0 -93
- package/dist/esm/shared/dns-pinned-fetch.js.map +0 -1
- package/dist/esm/shared/fetch-capabilities.js +0 -37
- package/dist/esm/shared/fetch-capabilities.js.map +0 -1
- package/dist/esm/shared/slides-presentation.js +0 -226
- package/dist/esm/shared/slides-presentation.js.map +0 -1
- package/dist/esm/shared/slides-text.js +0 -2
- package/dist/esm/shared/slides-text.js.map +0 -1
- package/dist/esm/shared/sse-events.js +0 -26
- package/dist/esm/shared/sse-events.js.map +0 -1
- package/dist/esm/shared/streaming-merge.js +0 -44
- package/dist/esm/shared/streaming-merge.js.map +0 -1
- package/dist/types/daemon/flow-context.d.ts +0 -50
- package/dist/types/daemon/summarize.d.ts +0 -104
- package/dist/types/run/flows/asset/input.d.ts +0 -34
- package/dist/types/run/flows/url/slides-text-markdown.d.ts +0 -47
- package/dist/types/run/flows/url/slides-text-transcript.d.ts +0 -36
- package/dist/types/run/flows/url/slides-text-types.d.ts +0 -8
- package/dist/types/run/flows/url/slides-text.d.ts +0 -3
- package/dist/types/run/flows/url/summary-resolution.d.ts +0 -31
- package/dist/types/run/run-context.d.ts +0 -57
- package/dist/types/run/runner-contexts.d.ts +0 -39
- package/dist/types/run/runner-execution.d.ts +0 -59
- package/dist/types/shared/cache-store.d.ts +0 -34
- package/dist/types/shared/contracts.d.ts +0 -2
- package/dist/types/shared/dns-pinned-fetch.d.ts +0 -1
- package/dist/types/shared/fetch-capabilities.d.ts +0 -10
- package/dist/types/shared/slides-presentation.d.ts +0 -45
- package/dist/types/shared/slides-text.d.ts +0 -1
- package/dist/types/shared/sse-events.d.ts +0 -66
- package/dist/types/shared/streaming-merge.d.ts +0 -4
- /package/dist/esm/{run → application}/cli-fallback-state.js +0 -0
- /package/dist/esm/{run → engine}/fetch-with-timeout.js +0 -0
- /package/dist/esm/{run → engine}/openrouter.js +0 -0
- /package/dist/esm/{run/flows/url → engine}/summary-timestamps.js +0 -0
- /package/dist/esm/{run → engine}/types.js +0 -0
- /package/dist/types/{run → application}/cli-fallback-state.d.ts +0 -0
- /package/dist/types/{run/run-env.d.ts → application/environment-state.d.ts} +0 -0
- /package/dist/types/{run/run-metrics.d.ts → application/metrics.d.ts} +0 -0
- /package/dist/types/{run/run-models.d.ts → application/model-selection.d.ts} +0 -0
- /package/dist/types/{run/run-output.d.ts → application/output-policy.d.ts} +0 -0
- /package/dist/types/{run/stdin-temp-file.d.ts → application/stdin-input.d.ts} +0 -0
- /package/dist/types/{run → engine}/fetch-with-timeout.d.ts +0 -0
- /package/dist/types/{run → engine}/model-attempts.d.ts +0 -0
- /package/dist/types/{run/summary-llm.d.ts → engine/model-call.d.ts} +0 -0
- /package/dist/types/{run → engine}/openrouter.d.ts +0 -0
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { render as renderMarkdownAnsi } from "markdansi";
|
|
2
|
-
import {
|
|
2
|
+
import { readLastSuccessfulCliProvider, writeLastSuccessfulCliProvider, } from "../../../application/cli-fallback-state.js";
|
|
3
|
+
import { buildAttachmentContentHash, buildLanguageKey, buildLengthKey, buildPromptContentHash, buildPromptHash, } from "../../../cache.js";
|
|
4
|
+
import { buildModelMetaFromAttempt } from "../../../engine/model-meta.js";
|
|
5
|
+
import { executeSummaryAttempts } from "../../../engine/summary-execution.js";
|
|
3
6
|
import { formatOutputLanguageForJson } from "../../../language.js";
|
|
4
|
-
import { parseGatewayStyleModelId } from "../../../llm/model-id.js";
|
|
5
7
|
import { SUMMARY_LENGTH_TARGET_CHARACTERS, SUMMARY_SYSTEM_PROMPT } from "../../../prompts/index.js";
|
|
8
|
+
import { buildRunJsonEnv } from "../../../shared/run-api-status.js";
|
|
6
9
|
import { countTokens } from "../../../tokenizer.js";
|
|
7
10
|
import { isUnsupportedAttachmentError } from "../../attachments.js";
|
|
8
|
-
import { readLastSuccessfulCliProvider, writeLastSuccessfulCliProvider, } from "../../cli-fallback-state.js";
|
|
9
11
|
import { writeFinishLine } from "../../finish-line.js";
|
|
10
12
|
import { resolveTargetCharacters } from "../../format.js";
|
|
11
13
|
import { writeVerbose } from "../../logging.js";
|
|
12
14
|
import { prepareMarkdownForTerminal } from "../../markdown.js";
|
|
13
|
-
import { runModelAttempts } from "../../model-attempts.js";
|
|
14
|
-
import { buildOpenRouterNoAllowedProvidersMessage } from "../../openrouter.js";
|
|
15
15
|
import { isRichTty, markdownRenderWidth, supportsColor } from "../../terminal.js";
|
|
16
16
|
import { prepareAssetPrompt } from "./preprocess.js";
|
|
17
17
|
import { buildAssetCliContext, buildAssetModelAttempts } from "./summary-attempts.js";
|
|
18
|
-
const buildModelMetaFromAttempt = (attempt) => {
|
|
19
|
-
if (attempt.transport === "cli") {
|
|
20
|
-
return { provider: "cli", canonical: attempt.userModelId };
|
|
21
|
-
}
|
|
22
|
-
const parsed = parseGatewayStyleModelId(attempt.llmModelId ?? attempt.userModelId);
|
|
23
|
-
const canonical = attempt.userModelId.toLowerCase().startsWith("openrouter/")
|
|
24
|
-
? attempt.userModelId
|
|
25
|
-
: parsed.canonical;
|
|
26
|
-
return { provider: parsed.provider, canonical };
|
|
27
|
-
};
|
|
28
18
|
function shouldBypassShortContentSummary({ ctx, textContent, }) {
|
|
29
19
|
if (ctx.forceSummary)
|
|
30
20
|
return false;
|
|
@@ -42,56 +32,68 @@ function shouldBypassShortContentSummary({ ctx, textContent, }) {
|
|
|
42
32
|
}
|
|
43
33
|
return true;
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const extracted = {
|
|
35
|
+
function buildAssetExtracted(args) {
|
|
36
|
+
return {
|
|
48
37
|
kind: "asset",
|
|
49
38
|
source: args.sourceLabel,
|
|
50
39
|
mediaType: args.attachment.mediaType,
|
|
51
40
|
filename: args.attachment.filename,
|
|
52
41
|
};
|
|
42
|
+
}
|
|
43
|
+
function buildAssetJsonInput(ctx, args) {
|
|
44
|
+
const shared = {
|
|
45
|
+
timeoutMs: ctx.timeoutMs,
|
|
46
|
+
length: ctx.lengthArg.kind === "preset"
|
|
47
|
+
? { kind: "preset", preset: ctx.lengthArg.preset }
|
|
48
|
+
: { kind: "chars", maxCharacters: ctx.lengthArg.maxCharacters },
|
|
49
|
+
maxOutputTokens: ctx.maxOutputTokensArg,
|
|
50
|
+
model: ctx.requestedModelLabel,
|
|
51
|
+
language: formatOutputLanguageForJson(ctx.outputLanguage),
|
|
52
|
+
};
|
|
53
|
+
return args.sourceKind === "file"
|
|
54
|
+
? { kind: "file", filePath: args.sourceLabel, ...shared }
|
|
55
|
+
: { kind: "asset-url", url: args.sourceLabel, ...shared };
|
|
56
|
+
}
|
|
57
|
+
async function writeAssetMetrics(ctx, result) {
|
|
58
|
+
const report = ctx.shouldComputeReport ? await ctx.buildReport() : null;
|
|
59
|
+
if (!ctx.metricsEnabled || !report)
|
|
60
|
+
return report;
|
|
61
|
+
const costUsd = await ctx.estimateCostUsd();
|
|
62
|
+
writeFinishLine({
|
|
63
|
+
stderr: ctx.stderr,
|
|
64
|
+
env: ctx.envForRun,
|
|
65
|
+
elapsedMs: Date.now() - ctx.runStartedAtMs,
|
|
66
|
+
elapsedLabel: result.summaryFromCache ? "Cached" : null,
|
|
67
|
+
model: result.llm?.model ?? null,
|
|
68
|
+
report,
|
|
69
|
+
costUsd,
|
|
70
|
+
detailed: ctx.metricsDetailed,
|
|
71
|
+
extraParts: null,
|
|
72
|
+
color: ctx.verboseColor,
|
|
73
|
+
});
|
|
74
|
+
return report;
|
|
75
|
+
}
|
|
76
|
+
export async function presentAssetSummary(ctx, args, result) {
|
|
77
|
+
if (result.outcome === "attempts-exhausted") {
|
|
78
|
+
ctx.clearProgressForStdout();
|
|
79
|
+
ctx.stdout.write(`${result.summary}\n`);
|
|
80
|
+
ctx.restoreProgressAfterStdout?.();
|
|
81
|
+
if (result.footerParts.length > 0) {
|
|
82
|
+
ctx.writeViaFooter([...result.footerParts, "no model"]);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
53
86
|
if (ctx.json) {
|
|
54
87
|
ctx.clearProgressForStdout();
|
|
55
88
|
const finishReport = ctx.shouldComputeReport ? await ctx.buildReport() : null;
|
|
56
|
-
const input = args.sourceKind === "file"
|
|
57
|
-
? {
|
|
58
|
-
kind: "file",
|
|
59
|
-
filePath: args.sourceLabel,
|
|
60
|
-
timeoutMs: ctx.timeoutMs,
|
|
61
|
-
length: ctx.lengthArg.kind === "preset"
|
|
62
|
-
? { kind: "preset", preset: ctx.lengthArg.preset }
|
|
63
|
-
: { kind: "chars", maxCharacters: ctx.lengthArg.maxCharacters },
|
|
64
|
-
maxOutputTokens: ctx.maxOutputTokensArg,
|
|
65
|
-
model: ctx.requestedModelLabel,
|
|
66
|
-
language: formatOutputLanguageForJson(ctx.outputLanguage),
|
|
67
|
-
}
|
|
68
|
-
: {
|
|
69
|
-
kind: "asset-url",
|
|
70
|
-
url: args.sourceLabel,
|
|
71
|
-
timeoutMs: ctx.timeoutMs,
|
|
72
|
-
length: ctx.lengthArg.kind === "preset"
|
|
73
|
-
? { kind: "preset", preset: ctx.lengthArg.preset }
|
|
74
|
-
: { kind: "chars", maxCharacters: ctx.lengthArg.maxCharacters },
|
|
75
|
-
maxOutputTokens: ctx.maxOutputTokensArg,
|
|
76
|
-
model: ctx.requestedModelLabel,
|
|
77
|
-
language: formatOutputLanguageForJson(ctx.outputLanguage),
|
|
78
|
-
};
|
|
79
89
|
const payload = {
|
|
80
|
-
input,
|
|
81
|
-
env:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
hasApifyToken: Boolean(ctx.apiStatus.apifyToken),
|
|
86
|
-
hasFirecrawlKey: ctx.apiStatus.firecrawlConfigured,
|
|
87
|
-
hasGoogleKey: ctx.apiStatus.googleConfigured,
|
|
88
|
-
hasAnthropicKey: ctx.apiStatus.anthropicConfigured,
|
|
89
|
-
},
|
|
90
|
-
extracted,
|
|
91
|
-
prompt: promptText,
|
|
92
|
-
llm: null,
|
|
90
|
+
input: buildAssetJsonInput(ctx, args),
|
|
91
|
+
env: buildRunJsonEnv(ctx.apiStatus),
|
|
92
|
+
extracted: result.extracted,
|
|
93
|
+
prompt: result.prompt,
|
|
94
|
+
llm: result.llm,
|
|
93
95
|
metrics: ctx.metricsEnabled ? finishReport : null,
|
|
94
|
-
summary,
|
|
96
|
+
summary: result.summary,
|
|
95
97
|
};
|
|
96
98
|
ctx.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
97
99
|
ctx.restoreProgressAfterStdout?.();
|
|
@@ -101,8 +103,8 @@ async function outputBypassedAssetSummary({ ctx, args, promptText, summaryText,
|
|
|
101
103
|
stderr: ctx.stderr,
|
|
102
104
|
env: ctx.envForRun,
|
|
103
105
|
elapsedMs: Date.now() - ctx.runStartedAtMs,
|
|
104
|
-
elapsedLabel: null,
|
|
105
|
-
model: null,
|
|
106
|
+
elapsedLabel: result.summaryFromCache ? "Cached" : null,
|
|
107
|
+
model: result.llm?.model ?? null,
|
|
106
108
|
report: finishReport,
|
|
107
109
|
costUsd,
|
|
108
110
|
detailed: ctx.metricsDetailed,
|
|
@@ -112,45 +114,39 @@ async function outputBypassedAssetSummary({ ctx, args, promptText, summaryText,
|
|
|
112
114
|
}
|
|
113
115
|
return;
|
|
114
116
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
ctx.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
if (!result.summaryEmitted) {
|
|
118
|
+
ctx.clearProgressForStdout();
|
|
119
|
+
const rendered = !ctx.plain && isRichTty(ctx.stdout)
|
|
120
|
+
? renderMarkdownAnsi(prepareMarkdownForTerminal(result.summary), {
|
|
121
|
+
width: markdownRenderWidth(ctx.stdout, ctx.env),
|
|
122
|
+
wrap: true,
|
|
123
|
+
color: supportsColor(ctx.stdout, ctx.envForRun),
|
|
124
|
+
hyperlinks: true,
|
|
125
|
+
})
|
|
126
|
+
: result.summary;
|
|
127
|
+
if (!ctx.plain && isRichTty(ctx.stdout)) {
|
|
128
|
+
ctx.stdout.write(`\n${rendered.replace(/^\n+/, "")}`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (isRichTty(ctx.stdout))
|
|
132
|
+
ctx.stdout.write("\n");
|
|
133
|
+
ctx.stdout.write(rendered.replace(/^\n+/, ""));
|
|
134
|
+
}
|
|
135
|
+
if (!rendered.endsWith("\n")) {
|
|
129
136
|
ctx.stdout.write("\n");
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (!rendered.endsWith("\n")) {
|
|
133
|
-
ctx.stdout.write("\n");
|
|
137
|
+
}
|
|
138
|
+
ctx.restoreProgressAfterStdout?.();
|
|
134
139
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
const footerLabel = result.outcome === "model"
|
|
141
|
+
? `model ${result.llm?.model ?? "unknown"}`
|
|
142
|
+
: result.outcome === "short-content"
|
|
143
|
+
? "short content"
|
|
144
|
+
: "no model";
|
|
145
|
+
if (result.outcome === "model" || result.footerParts.length > 0) {
|
|
146
|
+
ctx.writeViaFooter([...result.footerParts, footerLabel]);
|
|
138
147
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const costUsd = await ctx.estimateCostUsd();
|
|
142
|
-
writeFinishLine({
|
|
143
|
-
stderr: ctx.stderr,
|
|
144
|
-
env: ctx.envForRun,
|
|
145
|
-
elapsedMs: Date.now() - ctx.runStartedAtMs,
|
|
146
|
-
elapsedLabel: null,
|
|
147
|
-
model: null,
|
|
148
|
-
report,
|
|
149
|
-
costUsd,
|
|
150
|
-
detailed: ctx.metricsDetailed,
|
|
151
|
-
extraParts: null,
|
|
152
|
-
color: ctx.verboseColor,
|
|
153
|
-
});
|
|
148
|
+
if (result.outcome !== "token-fit") {
|
|
149
|
+
await writeAssetMetrics(ctx, result);
|
|
154
150
|
}
|
|
155
151
|
}
|
|
156
152
|
export function createAssetSummaryContext(input) {
|
|
@@ -164,7 +160,7 @@ export function createAssetSummaryContext(input) {
|
|
|
164
160
|
apiStatus: input.apiStatus,
|
|
165
161
|
};
|
|
166
162
|
}
|
|
167
|
-
export async function
|
|
163
|
+
export async function executeAssetSummary(ctx, args) {
|
|
168
164
|
const lastSuccessfulCliProvider = ctx.isFallbackModel
|
|
169
165
|
? await readLastSuccessfulCliProvider(ctx.envForRun)
|
|
170
166
|
: null;
|
|
@@ -206,15 +202,17 @@ export async function summarizeAsset(ctx, args) {
|
|
|
206
202
|
if (ctx.isFallbackModel &&
|
|
207
203
|
!ctx.isNamedModelSelection &&
|
|
208
204
|
shouldBypassShortContentSummary({ ctx, textContent })) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
205
|
+
return {
|
|
206
|
+
kind: "summary",
|
|
207
|
+
outcome: "short-content",
|
|
208
|
+
summary: (textContent?.content ?? "").trimEnd(),
|
|
209
|
+
summaryEmitted: false,
|
|
210
|
+
summaryFromCache: false,
|
|
211
|
+
prompt: promptText,
|
|
212
|
+
extracted: buildAssetExtracted(args),
|
|
213
|
+
footerParts: assetFooterParts,
|
|
214
|
+
llm: null,
|
|
215
|
+
};
|
|
218
216
|
}
|
|
219
217
|
if (ctx.requestedModel.kind === "auto" &&
|
|
220
218
|
!ctx.isNamedModelSelection &&
|
|
@@ -223,13 +221,17 @@ export async function summarizeAsset(ctx, args) {
|
|
|
223
221
|
typeof ctx.maxOutputTokensArg === "number" &&
|
|
224
222
|
textContent &&
|
|
225
223
|
countTokens(textContent.content) <= ctx.maxOutputTokensArg) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
return {
|
|
225
|
+
kind: "summary",
|
|
226
|
+
outcome: "token-fit",
|
|
227
|
+
summary: textContent.content.trim(),
|
|
228
|
+
summaryEmitted: false,
|
|
229
|
+
summaryFromCache: false,
|
|
230
|
+
prompt: promptText,
|
|
231
|
+
extracted: buildAssetExtracted(args),
|
|
232
|
+
footerParts: assetFooterParts,
|
|
233
|
+
llm: null,
|
|
234
|
+
};
|
|
233
235
|
}
|
|
234
236
|
const attempts = await buildAssetModelAttempts({
|
|
235
237
|
ctx,
|
|
@@ -256,295 +258,91 @@ export async function summarizeAsset(ctx, args) {
|
|
|
256
258
|
const autoSelectionCacheModel = ctx.isFallbackModel
|
|
257
259
|
? `selection:${ctx.requestedModelInput.toLowerCase()}`
|
|
258
260
|
: null;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
lengthKey,
|
|
271
|
-
languageKey,
|
|
272
|
-
});
|
|
273
|
-
const cached = cacheStore.getJson("summary", key);
|
|
274
|
-
const cachedSummary = cached && typeof cached.summary === "string" ? cached.summary.trim() : null;
|
|
275
|
-
const cachedModelId = cached && typeof cached.model === "string" ? cached.model.trim() : null;
|
|
276
|
-
if (cachedSummary) {
|
|
277
|
-
const cachedAttempt = cachedModelId
|
|
278
|
-
? (attempts.find((attempt) => attempt.userModelId === cachedModelId) ?? null)
|
|
279
|
-
: null;
|
|
280
|
-
const fallbackAttempt = attempts.find((attempt) => ctx.summaryEngine.envHasKeyFor(attempt.requiredEnv)) ??
|
|
281
|
-
attempts[0] ??
|
|
282
|
-
null;
|
|
283
|
-
const matchedAttempt = cachedAttempt && ctx.summaryEngine.envHasKeyFor(cachedAttempt.requiredEnv)
|
|
284
|
-
? cachedAttempt
|
|
285
|
-
: fallbackAttempt;
|
|
286
|
-
if (matchedAttempt) {
|
|
287
|
-
writeVerbose(ctx.stderr, ctx.verbose, "cache hit summary (auto selection)", ctx.verboseColor, ctx.envForRun);
|
|
288
|
-
args.onModelChosen?.(cachedModelId || matchedAttempt.userModelId);
|
|
289
|
-
summaryResult = {
|
|
290
|
-
summary: cachedSummary,
|
|
291
|
-
summaryAlreadyPrinted: false,
|
|
292
|
-
modelMeta: buildModelMetaFromAttempt(matchedAttempt),
|
|
293
|
-
maxOutputTokensForCall: null,
|
|
294
|
-
};
|
|
295
|
-
usedAttempt = matchedAttempt;
|
|
296
|
-
summaryFromCache = true;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (!summaryFromCache) {
|
|
301
|
-
for (const attempt of attempts) {
|
|
302
|
-
if (!ctx.summaryEngine.envHasKeyFor(attempt.requiredEnv))
|
|
303
|
-
continue;
|
|
304
|
-
const key = buildSummaryCacheKey({
|
|
305
|
-
contentHash,
|
|
306
|
-
promptHash,
|
|
307
|
-
model: attempt.userModelId,
|
|
308
|
-
lengthKey,
|
|
309
|
-
languageKey,
|
|
310
|
-
});
|
|
311
|
-
const cached = cacheStore.getText("summary", key);
|
|
312
|
-
if (!cached)
|
|
313
|
-
continue;
|
|
314
|
-
writeVerbose(ctx.stderr, ctx.verbose, "cache hit summary", ctx.verboseColor, ctx.envForRun);
|
|
315
|
-
args.onModelChosen?.(attempt.userModelId);
|
|
316
|
-
summaryResult = {
|
|
317
|
-
summary: cached,
|
|
318
|
-
summaryAlreadyPrinted: false,
|
|
319
|
-
modelMeta: buildModelMetaFromAttempt(attempt),
|
|
320
|
-
maxOutputTokensForCall: null,
|
|
321
|
-
};
|
|
322
|
-
usedAttempt = attempt;
|
|
323
|
-
summaryFromCache = true;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (cacheChecked && !summaryFromCache) {
|
|
329
|
-
writeVerbose(ctx.stderr, ctx.verbose, "cache miss summary", ctx.verboseColor, ctx.envForRun);
|
|
330
|
-
}
|
|
331
|
-
let lastError = null;
|
|
332
|
-
let missingRequiredEnvs = new Set();
|
|
333
|
-
let sawOpenRouterNoAllowedProviders = false;
|
|
334
|
-
if (!summaryResult || !usedAttempt) {
|
|
335
|
-
const attemptOutcome = await runModelAttempts({
|
|
336
|
-
attempts,
|
|
337
|
-
isFallbackModel: ctx.isFallbackModel,
|
|
338
|
-
isNamedModelSelection: ctx.isNamedModelSelection,
|
|
339
|
-
envHasKeyFor: ctx.summaryEngine.envHasKeyFor,
|
|
340
|
-
formatMissingModelError: ctx.summaryEngine.formatMissingModelError,
|
|
341
|
-
onAutoSkip: (attempt) => {
|
|
342
|
-
writeVerbose(ctx.stderr, ctx.verbose, `auto skip ${attempt.userModelId}: missing ${attempt.requiredEnv}`, ctx.verboseColor, ctx.envForRun);
|
|
343
|
-
},
|
|
344
|
-
onAutoFailure: (attempt, error) => {
|
|
345
|
-
writeVerbose(ctx.stderr, ctx.verbose, `auto failed ${attempt.userModelId}: ${error instanceof Error ? error.message : String(error)}`, ctx.verboseColor, ctx.envForRun);
|
|
346
|
-
},
|
|
347
|
-
onFixedModelError: (attempt, error) => {
|
|
348
|
-
if (isUnsupportedAttachmentError(error)) {
|
|
349
|
-
throw new Error(`Model ${attempt.userModelId} does not support attaching files of type ${args.attachment.mediaType}. Try a different --model.`, { cause: error });
|
|
350
|
-
}
|
|
351
|
-
throw error;
|
|
352
|
-
},
|
|
353
|
-
runAttempt: (attempt) => ctx.summaryEngine.runSummaryAttempt({
|
|
354
|
-
attempt,
|
|
355
|
-
prompt,
|
|
356
|
-
allowStreaming: ctx.streamingEnabled,
|
|
357
|
-
onModelChosen: args.onModelChosen ?? null,
|
|
358
|
-
cli: cliContext,
|
|
359
|
-
}),
|
|
360
|
-
});
|
|
361
|
-
summaryResult = attemptOutcome.result;
|
|
362
|
-
usedAttempt = attemptOutcome.usedAttempt;
|
|
363
|
-
lastError = attemptOutcome.lastError;
|
|
364
|
-
missingRequiredEnvs = attemptOutcome.missingRequiredEnvs;
|
|
365
|
-
sawOpenRouterNoAllowedProviders = attemptOutcome.sawOpenRouterNoAllowedProviders;
|
|
366
|
-
}
|
|
367
|
-
if (!summaryResult || !usedAttempt) {
|
|
368
|
-
const withFreeTip = (message) => {
|
|
369
|
-
if (!ctx.isNamedModelSelection || !ctx.wantsFreeNamedModel)
|
|
370
|
-
return message;
|
|
371
|
-
return (`${message}\n` +
|
|
372
|
-
`Tip: run "summarize refresh-free" to refresh the free model candidates (writes ~/.summarize/config.json).`);
|
|
373
|
-
};
|
|
374
|
-
if (ctx.isNamedModelSelection) {
|
|
375
|
-
if (lastError === null && missingRequiredEnvs.size > 0) {
|
|
376
|
-
throw new Error(withFreeTip(`Missing ${Array.from(missingRequiredEnvs).sort().join(", ")} for --model ${ctx.requestedModelInput}.`));
|
|
377
|
-
}
|
|
378
|
-
if (lastError instanceof Error) {
|
|
379
|
-
if (sawOpenRouterNoAllowedProviders) {
|
|
380
|
-
const message = await buildOpenRouterNoAllowedProvidersMessage({
|
|
381
|
-
attempts,
|
|
382
|
-
fetchImpl: ctx.trackedFetch,
|
|
383
|
-
timeoutMs: ctx.timeoutMs,
|
|
384
|
-
});
|
|
385
|
-
throw new Error(withFreeTip(message), { cause: lastError });
|
|
386
|
-
}
|
|
387
|
-
throw new Error(withFreeTip(lastError.message), { cause: lastError });
|
|
388
|
-
}
|
|
389
|
-
throw new Error(withFreeTip(`No model available for --model ${ctx.requestedModelInput}`));
|
|
390
|
-
}
|
|
391
|
-
if (textContent) {
|
|
392
|
-
ctx.clearProgressForStdout();
|
|
393
|
-
ctx.stdout.write(`${textContent.content.trim()}\n`);
|
|
394
|
-
ctx.restoreProgressAfterStdout?.();
|
|
395
|
-
if (assetFooterParts.length > 0) {
|
|
396
|
-
ctx.writeViaFooter([...assetFooterParts, "no model"]);
|
|
397
|
-
}
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
if (lastError instanceof Error)
|
|
401
|
-
throw lastError;
|
|
402
|
-
throw new Error("No model available for this input");
|
|
403
|
-
}
|
|
404
|
-
if (!summaryFromCache && cacheStore && contentHash && promptHash) {
|
|
405
|
-
const perModelKey = buildSummaryCacheKey({
|
|
261
|
+
const execution = await executeSummaryAttempts({
|
|
262
|
+
attempts,
|
|
263
|
+
isFallbackModel: ctx.isFallbackModel,
|
|
264
|
+
isNamedModelSelection: ctx.isNamedModelSelection,
|
|
265
|
+
wantsFreeNamedModel: ctx.wantsFreeNamedModel,
|
|
266
|
+
requestedModelInput: ctx.requestedModelInput,
|
|
267
|
+
envHasKeyFor: ctx.summaryEngine.envHasKeyFor,
|
|
268
|
+
formatMissingModelError: ctx.summaryEngine.formatMissingModelError,
|
|
269
|
+
cache: {
|
|
270
|
+
store: cacheStore,
|
|
271
|
+
ttlMs: ctx.cache.ttlMs,
|
|
406
272
|
contentHash,
|
|
407
273
|
promptHash,
|
|
408
|
-
model: usedAttempt.userModelId,
|
|
409
274
|
lengthKey,
|
|
410
275
|
languageKey,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
writeVerbose(ctx.stderr, ctx.verbose,
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
const { summary, summaryAlreadyPrinted, modelMeta, maxOutputTokensForCall } = summaryResult;
|
|
436
|
-
const extracted = {
|
|
437
|
-
kind: "asset",
|
|
438
|
-
source: args.sourceLabel,
|
|
439
|
-
mediaType: args.attachment.mediaType,
|
|
440
|
-
filename: args.attachment.filename,
|
|
441
|
-
};
|
|
442
|
-
if (ctx.json) {
|
|
443
|
-
ctx.clearProgressForStdout();
|
|
444
|
-
const finishReport = ctx.shouldComputeReport ? await ctx.buildReport() : null;
|
|
445
|
-
const input = args.sourceKind === "file"
|
|
446
|
-
? {
|
|
447
|
-
kind: "file",
|
|
448
|
-
filePath: args.sourceLabel,
|
|
449
|
-
timeoutMs: ctx.timeoutMs,
|
|
450
|
-
length: ctx.lengthArg.kind === "preset"
|
|
451
|
-
? { kind: "preset", preset: ctx.lengthArg.preset }
|
|
452
|
-
: { kind: "chars", maxCharacters: ctx.lengthArg.maxCharacters },
|
|
453
|
-
maxOutputTokens: ctx.maxOutputTokensArg,
|
|
454
|
-
model: ctx.requestedModelLabel,
|
|
455
|
-
language: formatOutputLanguageForJson(ctx.outputLanguage),
|
|
276
|
+
autoSelectionModel: autoSelectionCacheModel,
|
|
277
|
+
},
|
|
278
|
+
verbose: (message) => writeVerbose(ctx.stderr, ctx.verbose, message, ctx.verboseColor, ctx.envForRun),
|
|
279
|
+
onModelChosen: args.onModelChosen,
|
|
280
|
+
onCacheResolved: ctx.onSummaryCached ?? null,
|
|
281
|
+
buildCachedResult: (attempt, summary) => ({
|
|
282
|
+
summary,
|
|
283
|
+
summaryEmitted: false,
|
|
284
|
+
modelMeta: buildModelMetaFromAttempt(attempt),
|
|
285
|
+
maxOutputTokensForCall: null,
|
|
286
|
+
}),
|
|
287
|
+
runAttempt: (attempt) => ctx.summaryEngine.runSummaryAttempt({
|
|
288
|
+
attempt,
|
|
289
|
+
prompt,
|
|
290
|
+
allowStreaming: ctx.streamingEnabled,
|
|
291
|
+
onModelChosen: args.onModelChosen ?? null,
|
|
292
|
+
cli: cliContext,
|
|
293
|
+
streamHandler: ctx.summaryStream,
|
|
294
|
+
}),
|
|
295
|
+
onFixedModelError: (attempt, error) => {
|
|
296
|
+
if (isUnsupportedAttachmentError(error)) {
|
|
297
|
+
throw new Error(`Model ${attempt.userModelId} does not support attaching files of type ${args.attachment.mediaType}. Try a different --model.`, { cause: error });
|
|
456
298
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
299
|
+
throw error;
|
|
300
|
+
},
|
|
301
|
+
fetchImpl: ctx.trackedFetch,
|
|
302
|
+
timeoutMs: ctx.timeoutMs,
|
|
303
|
+
rememberCliProvider: (provider) => writeLastSuccessfulCliProvider({ env: ctx.envForRun, provider }),
|
|
304
|
+
});
|
|
305
|
+
if (!execution.result || !execution.usedAttempt) {
|
|
306
|
+
if (textContent) {
|
|
307
|
+
return {
|
|
308
|
+
kind: "summary",
|
|
309
|
+
outcome: "attempts-exhausted",
|
|
310
|
+
summary: textContent.content.trim(),
|
|
311
|
+
summaryEmitted: false,
|
|
312
|
+
summaryFromCache: false,
|
|
313
|
+
prompt: promptText,
|
|
314
|
+
extracted: buildAssetExtracted(args),
|
|
315
|
+
footerParts: assetFooterParts,
|
|
316
|
+
llm: null,
|
|
467
317
|
};
|
|
468
|
-
const payload = {
|
|
469
|
-
input,
|
|
470
|
-
env: {
|
|
471
|
-
hasXaiKey: Boolean(ctx.apiStatus.xaiApiKey),
|
|
472
|
-
hasOpenAIKey: Boolean(ctx.apiStatus.apiKey),
|
|
473
|
-
hasOpenRouterKey: Boolean(ctx.apiStatus.openrouterApiKey),
|
|
474
|
-
hasApifyToken: Boolean(ctx.apiStatus.apifyToken),
|
|
475
|
-
hasFirecrawlKey: ctx.apiStatus.firecrawlConfigured,
|
|
476
|
-
hasGoogleKey: ctx.apiStatus.googleConfigured,
|
|
477
|
-
hasAnthropicKey: ctx.apiStatus.anthropicConfigured,
|
|
478
|
-
},
|
|
479
|
-
extracted,
|
|
480
|
-
prompt: promptText,
|
|
481
|
-
llm: {
|
|
482
|
-
provider: modelMeta.provider,
|
|
483
|
-
model: usedAttempt.userModelId,
|
|
484
|
-
maxCompletionTokens: maxOutputTokensForCall,
|
|
485
|
-
strategy: "single",
|
|
486
|
-
},
|
|
487
|
-
metrics: ctx.metricsEnabled ? finishReport : null,
|
|
488
|
-
summary,
|
|
489
|
-
};
|
|
490
|
-
ctx.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
491
|
-
ctx.restoreProgressAfterStdout?.();
|
|
492
|
-
if (ctx.metricsEnabled && finishReport) {
|
|
493
|
-
const costUsd = await ctx.estimateCostUsd();
|
|
494
|
-
writeFinishLine({
|
|
495
|
-
stderr: ctx.stderr,
|
|
496
|
-
env: ctx.envForRun,
|
|
497
|
-
elapsedMs: Date.now() - ctx.runStartedAtMs,
|
|
498
|
-
elapsedLabel: summaryFromCache ? "Cached" : null,
|
|
499
|
-
model: usedAttempt.userModelId,
|
|
500
|
-
report: finishReport,
|
|
501
|
-
costUsd,
|
|
502
|
-
detailed: ctx.metricsDetailed,
|
|
503
|
-
extraParts: null,
|
|
504
|
-
color: ctx.verboseColor,
|
|
505
|
-
});
|
|
506
318
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
ctx.clearProgressForStdout();
|
|
511
|
-
const rendered = !ctx.plain && isRichTty(ctx.stdout)
|
|
512
|
-
? renderMarkdownAnsi(prepareMarkdownForTerminal(summary), {
|
|
513
|
-
width: markdownRenderWidth(ctx.stdout, ctx.env),
|
|
514
|
-
wrap: true,
|
|
515
|
-
color: supportsColor(ctx.stdout, ctx.envForRun),
|
|
516
|
-
hyperlinks: true,
|
|
517
|
-
})
|
|
518
|
-
: summary;
|
|
519
|
-
if (!ctx.plain && isRichTty(ctx.stdout)) {
|
|
520
|
-
ctx.stdout.write(`\n${rendered.replace(/^\n+/, "")}`);
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
if (isRichTty(ctx.stdout))
|
|
524
|
-
ctx.stdout.write("\n");
|
|
525
|
-
ctx.stdout.write(rendered.replace(/^\n+/, ""));
|
|
526
|
-
}
|
|
527
|
-
if (!rendered.endsWith("\n")) {
|
|
528
|
-
ctx.stdout.write("\n");
|
|
529
|
-
}
|
|
530
|
-
ctx.restoreProgressAfterStdout?.();
|
|
319
|
+
if (execution.failure.lastError instanceof Error)
|
|
320
|
+
throw execution.failure.lastError;
|
|
321
|
+
throw new Error("No model available for this input");
|
|
531
322
|
}
|
|
532
|
-
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
323
|
+
const { summary, summaryEmitted, modelMeta, maxOutputTokensForCall } = execution.result;
|
|
324
|
+
const usedAttempt = execution.usedAttempt;
|
|
325
|
+
const summaryFromCache = execution.summaryFromCache;
|
|
326
|
+
return {
|
|
327
|
+
kind: "summary",
|
|
328
|
+
outcome: "model",
|
|
329
|
+
summary,
|
|
330
|
+
summaryEmitted,
|
|
331
|
+
summaryFromCache,
|
|
332
|
+
prompt: promptText,
|
|
333
|
+
extracted: buildAssetExtracted(args),
|
|
334
|
+
footerParts: assetFooterParts,
|
|
335
|
+
llm: {
|
|
336
|
+
provider: modelMeta.provider,
|
|
541
337
|
model: usedAttempt.userModelId,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
338
|
+
maxCompletionTokens: maxOutputTokensForCall,
|
|
339
|
+
strategy: "single",
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
export async function summarizeAsset(ctx, args) {
|
|
344
|
+
const result = await executeAssetSummary(ctx, args);
|
|
345
|
+
await presentAssetSummary(ctx, args, result);
|
|
346
|
+
return result;
|
|
549
347
|
}
|
|
550
348
|
//# sourceMappingURL=summary.js.map
|