@zergai/ztc 0.5.0-beta.1 → 0.6.0-beta.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/README.md +65 -46
- package/THIRD_PARTY_NOTICES.md +7 -2
- package/bin/zmux-darwin-arm64 +0 -0
- package/bin/ztc-audio-darwin-arm64 +0 -0
- package/bin/ztc-capture-darwin-arm64 +0 -0
- package/bin/ztc-computer-darwin-arm64 +0 -0
- package/bin/ztc-llm-darwin-arm64 +0 -0
- package/bin/ztc-tts-darwin-arm64 +0 -0
- package/bin/ztc-tui-darwin-arm64 +0 -0
- package/bin/zterm-darwin-arm64 +0 -0
- package/dist/App.js +26 -9
- package/dist/agent/agent.d.ts +77 -0
- package/dist/agent/agent.js +618 -94
- package/dist/agent/backends/account_login.js +3 -1
- package/dist/agent/backends/anthropic.js +4 -3
- package/dist/agent/backends/bedrock.d.ts +20 -0
- package/dist/agent/backends/bedrock.js +175 -0
- package/dist/agent/backends/claude_cli.js +8 -0
- package/dist/agent/backends/codex_app_server.js +2 -0
- package/dist/agent/backends/codex_auth.d.ts +5 -2
- package/dist/agent/backends/codex_auth.js +131 -31
- package/dist/agent/backends/gemini.js +1 -1
- package/dist/agent/backends/http_error.d.ts +2 -0
- package/dist/agent/backends/http_error.js +4 -0
- package/dist/agent/backends/index.d.ts +3 -0
- package/dist/agent/backends/index.js +16 -0
- package/dist/agent/backends/model_pool.d.ts +20 -0
- package/dist/agent/backends/model_pool.js +98 -0
- package/dist/agent/backends/openai.js +2 -0
- package/dist/agent/backends/openai_compatible.js +8 -3
- package/dist/agent/backends/openai_responses.d.ts +14 -3
- package/dist/agent/backends/openai_responses.js +91 -26
- package/dist/agent/backends/responses_reasoning.d.ts +5 -0
- package/dist/agent/backends/responses_reasoning.js +23 -0
- package/dist/agent/backends/transport_errors.d.ts +6 -0
- package/dist/agent/backends/transport_errors.js +11 -0
- package/dist/agent/backends/types.d.ts +25 -2
- package/dist/agent/backends/types.js +4 -0
- package/dist/agent/backends/zrouter_stream.d.ts +16 -0
- package/dist/agent/backends/zrouter_stream.js +162 -17
- package/dist/agent/background_workers.d.ts +68 -0
- package/dist/agent/background_workers.js +139 -0
- package/dist/agent/commands/accounts.d.ts +9 -1
- package/dist/agent/commands/accounts.js +13 -5
- package/dist/agent/commands/auth.d.ts +30 -1
- package/dist/agent/commands/auth.js +166 -35
- package/dist/agent/commands/command_refusal.d.ts +8 -0
- package/dist/agent/commands/command_refusal.js +8 -0
- package/dist/agent/commands/compact.js +16 -10
- package/dist/agent/commands/config.js +386 -80
- package/dist/agent/commands/connect.d.ts +20 -0
- package/dist/agent/commands/connect.js +150 -0
- package/dist/agent/commands/credential_redaction.d.ts +12 -0
- package/dist/agent/commands/credential_redaction.js +46 -0
- package/dist/agent/commands/credential_status.d.ts +72 -0
- package/dist/agent/commands/credential_status.js +181 -0
- package/dist/agent/commands/direct_credential_prompt.d.ts +71 -0
- package/dist/agent/commands/direct_credential_prompt.js +422 -0
- package/dist/agent/commands/effort.d.ts +1 -0
- package/dist/agent/commands/effort.js +16 -34
- package/dist/agent/commands/goal.d.ts +0 -4
- package/dist/agent/commands/goal.js +48 -10
- package/dist/agent/commands/handoff.d.ts +6 -0
- package/dist/agent/commands/handoff.js +17 -0
- package/dist/agent/commands/help.js +1 -1
- package/dist/agent/commands/inbox.js +3 -0
- package/dist/agent/commands/index.js +5 -3
- package/dist/agent/commands/keybindings.js +4 -3
- package/dist/agent/commands/mirror.js +29 -16
- package/dist/agent/commands/model.js +83 -4
- package/dist/agent/commands/models.d.ts +1 -1
- package/dist/agent/commands/models.js +89 -67
- package/dist/agent/commands/openai_compat_wizard.d.ts +3 -2
- package/dist/agent/commands/openai_compat_wizard.js +53 -15
- package/dist/agent/commands/provider_choices.d.ts +56 -0
- package/dist/agent/commands/provider_choices.js +72 -3
- package/dist/agent/commands/provider_model_defaults.d.ts +7 -0
- package/dist/agent/commands/provider_model_defaults.js +11 -0
- package/dist/agent/commands/provider_selection.d.ts +27 -2
- package/dist/agent/commands/provider_selection.js +143 -8
- package/dist/agent/commands/reasoning_page.d.ts +33 -0
- package/dist/agent/commands/reasoning_page.js +595 -0
- package/dist/agent/commands/reasoning_picker.d.ts +14 -0
- package/dist/agent/commands/reasoning_picker.js +99 -0
- package/dist/agent/commands/reasoning_settings.d.ts +18 -0
- package/dist/agent/commands/reasoning_settings.js +46 -0
- package/dist/agent/commands/settings.d.ts +2 -0
- package/dist/agent/commands/settings.js +689 -264
- package/dist/agent/commands/status.js +13 -44
- package/dist/agent/commands/types.d.ts +108 -2
- package/dist/agent/commands/update.d.ts +18 -0
- package/dist/agent/commands/update.js +55 -96
- package/dist/agent/completion_state.d.ts +18 -0
- package/dist/agent/completion_state.js +35 -3
- package/dist/agent/factory.d.ts +9 -1
- package/dist/agent/factory.js +61 -17
- package/dist/agent/loop_policy.d.ts +14 -0
- package/dist/agent/loop_policy.js +9 -0
- package/dist/agent/request_encoder.d.ts +6 -0
- package/dist/agent/request_encoder.js +36 -6
- package/dist/agent/result_emit_cap.d.ts +1 -0
- package/dist/agent/result_emit_cap.js +1 -0
- package/dist/agent/runaway_output.d.ts +32 -0
- package/dist/agent/runaway_output.js +80 -0
- package/dist/agent/runtime/command_execution_policy.d.ts +6 -0
- package/dist/agent/runtime/command_execution_policy.js +39 -0
- package/dist/agent/runtime/evidence.d.ts +17 -1
- package/dist/agent/runtime/evidence.js +58 -8
- package/dist/agent/runtime/execution_context.js +7 -3
- package/dist/agent/runtime/read_only_command.d.ts +15 -0
- package/dist/agent/runtime/read_only_command.js +265 -0
- package/dist/agent/runtime/recovery.js +2 -38
- package/dist/agent/runtime/source_verification.js +3 -1
- package/dist/agent/runtime/tool_checkpoints.js +5 -1
- package/dist/agent/runtime/tool_runtime.js +15 -1
- package/dist/agent/runtime/tool_scheduler.js +3 -1
- package/dist/agent/subagent.d.ts +4 -0
- package/dist/agent/subagent.js +195 -23
- package/dist/agent/system_prompt.d.ts +3 -1
- package/dist/agent/system_prompt.js +3 -1
- package/dist/agent/tool_response_store.d.ts +9 -0
- package/dist/agent/tool_response_store.js +39 -3
- package/dist/agent/tool_result_parsing.d.ts +2 -0
- package/dist/agent/tool_result_parsing.js +1 -0
- package/dist/agent/tool_result_presentation.d.ts +21 -0
- package/dist/agent/tool_result_presentation.js +237 -0
- package/dist/agent/tools/apply_patch.js +130 -42
- package/dist/agent/tools/deferred.js +22 -2
- package/dist/agent/tools/delegate.js +182 -49
- package/dist/agent/tools/edit_view.d.ts +13 -0
- package/dist/agent/tools/edit_view.js +134 -0
- package/dist/agent/tools/file.js +54 -16
- package/dist/agent/tools/recall_tool_response.d.ts +6 -0
- package/dist/agent/tools/recall_tool_response.js +60 -17
- package/dist/agent/tools/screenshot.js +5 -3
- package/dist/agent/tools/search.js +18 -9
- package/dist/agent/tools/shell.d.ts +1 -1
- package/dist/agent/tools/shell.js +48 -10
- package/dist/agent/tools/sim_domain_tools.js +7 -1
- package/dist/agent/tools/tool_groups.d.ts +34 -0
- package/dist/agent/tools/tool_groups.js +112 -0
- package/dist/agent/tools/types.d.ts +10 -0
- package/dist/app/activity.js +2 -1
- package/dist/app/agent_runner.js +13 -4
- package/dist/app/ask_user_response.d.ts +6 -0
- package/dist/app/ask_user_response.js +26 -0
- package/dist/app/command_context.js +11 -5
- package/dist/app/launch_notices.d.ts +10 -0
- package/dist/app/launch_notices.js +20 -0
- package/dist/app/selection_completion.d.ts +30 -1
- package/dist/app/selection_completion.js +191 -28
- package/dist/app/session_manager.d.ts +5 -0
- package/dist/app/session_manager.js +50 -12
- package/dist/app/session_messages.d.ts +3 -0
- package/dist/app/session_messages.js +34 -12
- package/dist/app/workspace_admission_details.d.ts +7 -0
- package/dist/app/workspace_admission_details.js +45 -1
- package/dist/cli_args.js +1 -1
- package/dist/cli_main.js +20 -3
- package/dist/cli_ratatui.d.ts +95 -3
- package/dist/cli_ratatui.js +654 -161
- package/dist/components/InputArea.js +1 -1
- package/dist/config/compaction.d.ts +2 -1
- package/dist/config/compaction.js +2 -1
- package/dist/config/defaults.js +20 -48
- package/dist/config/provider_api_key_env.d.ts +76 -0
- package/dist/config/provider_api_key_env.js +148 -0
- package/dist/config/resolved.d.ts +4 -4
- package/dist/config/types.d.ts +102 -1
- package/dist/config.d.ts +70 -8
- package/dist/config.js +253 -63
- package/dist/diagnostics/session_export.d.ts +1 -0
- package/dist/diagnostics/session_export.js +81 -13
- package/dist/emulation/catalog.d.ts +2 -0
- package/dist/emulation/catalog.js +50 -21
- package/dist/emulation/tool_adapters.d.ts +6 -0
- package/dist/emulation/tool_adapters.js +30 -0
- package/dist/emulation/ztc_addendum.d.ts +22 -0
- package/dist/emulation/ztc_addendum.js +37 -0
- package/dist/events.d.ts +3 -0
- package/dist/headless.d.ts +35 -1
- package/dist/headless.js +209 -14
- package/dist/headless_cli.js +6 -0
- package/dist/headless_cli_args.d.ts +4 -0
- package/dist/headless_cli_args.js +2 -0
- package/dist/headless_output_schema.d.ts +46 -0
- package/dist/headless_output_schema.js +386 -0
- package/dist/headless_trajectory.d.ts +44 -0
- package/dist/headless_trajectory.js +113 -0
- package/dist/library.d.ts +6 -3
- package/dist/library.js +8 -4
- package/dist/lsp/client.js +4 -1
- package/dist/lsp/servers.js +2 -0
- package/dist/onboarding/first_run.d.ts +26 -6
- package/dist/onboarding/first_run.js +63 -45
- package/dist/onboarding/router_tips.d.ts +7 -0
- package/dist/onboarding/router_tips.js +38 -0
- package/dist/onboarding/setup.js +1 -1
- package/dist/onboarding/wordmark.d.ts +7 -0
- package/dist/onboarding/wordmark.js +14 -0
- package/dist/onboarding/zergai_login.d.ts +48 -0
- package/dist/onboarding/zergai_login.js +60 -0
- package/dist/prompts/subagent_worker.j2 +20 -0
- package/dist/prompts/tool_delegate_task.j2 +5 -14
- package/dist/router_auth.d.ts +37 -3
- package/dist/router_auth.js +221 -73
- package/dist/runtime_info.d.ts +19 -6
- package/dist/runtime_info.js +64 -28
- package/dist/session.d.ts +9 -0
- package/dist/session.js +41 -8
- package/dist/session_handoff_contract.d.ts +13 -0
- package/dist/session_handoff_contract.js +81 -15
- package/dist/session_media.d.ts +5 -0
- package/dist/session_media.js +2 -1
- package/dist/simulation/domain_types.d.ts +3 -3
- package/dist/simulation/living/context.d.ts +9 -9
- package/dist/simulation/living/definition.d.ts +1 -1
- package/dist/simulation/living/open-world.d.ts +3 -3
- package/dist/simulation/living/recall.d.ts +1 -1
- package/dist/simulation/living/types.d.ts +18 -18
- package/dist/simulation/orchestration/world_response.d.ts +2 -2
- package/dist/simulation/toolkit/dynamic_meetings.d.ts +1 -1
- package/dist/simulation/toolkit/dynamic_state.d.ts +1 -1
- package/dist/simulation/world/bootstrap_schema.d.ts +1 -1
- package/dist/simulation/world/gm_schema.d.ts +8 -8
- package/dist/skills/loader.js +3 -1
- package/dist/types.d.ts +6 -2
- package/dist/ui/core/input.d.ts +5 -1
- package/dist/ui/core/input.js +5 -1
- package/dist/ui/core/input_segments.d.ts +5 -1
- package/dist/ui/core/input_segments.js +5 -3
- package/dist/ui/ratatui/headless_pane_manager.d.ts +3 -1
- package/dist/ui/ratatui/headless_pane_manager.js +16 -5
- package/dist/ui/ratatui/input.js +4 -3
- package/dist/ui/ratatui/process.js +22 -13
- package/dist/ui/ratatui/protocol.d.ts +14 -0
- package/dist/ui/ratatui/protocol.js +2 -0
- package/dist/ui/scrollback.d.ts +17 -0
- package/dist/ui/scrollback.js +138 -4
- package/dist/ui/terminal_image.d.ts +129 -0
- package/dist/ui/terminal_image.js +516 -0
- package/dist/ui/transcript_render_cache.d.ts +4 -4
- package/dist/ui/transcript_render_cache.js +7 -4
- package/dist/ui/views/app.d.ts +7 -3
- package/dist/ui/views/app.js +13 -6
- package/dist/ui/views/completion_menu.js +18 -10
- package/dist/ui/views/input_area.d.ts +1 -2
- package/dist/ui/views/input_area.js +2 -2
- package/dist/ui/views/message_list.d.ts +8 -1
- package/dist/ui/views/message_list.js +176 -45
- package/dist/ui/views/status_bar.js +7 -1
- package/dist/ui/views/theme.d.ts +2 -0
- package/dist/ui/views/theme.js +2 -0
- package/dist/ui/widgets/color_panel.js +4 -3
- package/dist/ui/widgets/form.d.ts +8 -1
- package/dist/ui/widgets/form.js +36 -22
- package/dist/ui/widgets/index.d.ts +1 -1
- package/dist/ui/widgets/index.js +1 -1
- package/dist/ui/widgets/log_view.js +4 -3
- package/dist/ui/widgets/navigator_panel.js +5 -4
- package/dist/ui/widgets/panel_frame.d.ts +2 -0
- package/dist/ui/widgets/panel_frame.js +14 -0
- package/dist/ui/widgets/prompt_viewer.js +2 -1
- package/dist/ui/widgets/questionnaire.js +3 -3
- package/dist/ui/widgets/reasoning_track.d.ts +60 -0
- package/dist/ui/widgets/reasoning_track.js +218 -0
- package/dist/ui/widgets/resume_panel.js +15 -10
- package/dist/ui/widgets/rewind_panel.js +4 -16
- package/dist/ui/widgets/select.d.ts +90 -4
- package/dist/ui/widgets/select.js +305 -135
- package/dist/ui/widgets/settings_panel.d.ts +21 -1
- package/dist/ui/widgets/settings_panel.js +266 -45
- package/dist/ui/widgets/status_line_panel.js +6 -5
- package/dist/ui/widgets/text_input.d.ts +4 -0
- package/dist/ui/widgets/text_input.js +20 -13
- package/dist/ui/widgets/types.d.ts +2 -0
- package/dist/utils/compaction.d.ts +24 -4
- package/dist/utils/compaction.js +228 -44
- package/dist/utils/context.js +1 -0
- package/dist/utils/debug_log.d.ts +12 -0
- package/dist/utils/debug_log.js +25 -3
- package/dist/utils/deepseek.d.ts +3 -1
- package/dist/utils/deepseek.js +29 -1
- package/dist/utils/docker_target.d.ts +28 -0
- package/dist/utils/docker_target.js +89 -0
- package/dist/utils/ephemeral.js +2 -0
- package/dist/utils/fireworks.d.ts +4 -4
- package/dist/utils/fireworks.js +11 -7
- package/dist/utils/idle_compaction.d.ts +32 -0
- package/dist/utils/idle_compaction.js +113 -0
- package/dist/utils/mid_turn_compaction.d.ts +12 -0
- package/dist/utils/mid_turn_compaction.js +17 -0
- package/dist/utils/open_url.d.ts +4 -0
- package/dist/utils/open_url.js +10 -0
- package/dist/utils/openrouter_prices.d.ts +165 -0
- package/dist/utils/openrouter_prices.js +313 -0
- package/dist/utils/router_catalog.d.ts +13 -0
- package/dist/utils/router_catalog.js +30 -3
- package/dist/utils/sandbox.d.ts +12 -0
- package/dist/utils/sandbox.js +23 -5
- package/dist/utils/session_interactivity.d.ts +21 -0
- package/dist/utils/session_interactivity.js +28 -0
- package/dist/utils/shell.d.ts +7 -0
- package/dist/utils/shell.js +43 -7
- package/dist/utils/subprocess_env.d.ts +27 -0
- package/dist/utils/subprocess_env.js +69 -3
- package/dist/utils/tool_output_copies.d.ts +44 -0
- package/dist/utils/tool_output_copies.js +196 -0
- package/dist/utils/tool_result_message.d.ts +7 -0
- package/dist/utils/tool_result_message.js +11 -0
- package/dist/utils/tool_trace.d.ts +15 -0
- package/dist/utils/tool_trace.js +40 -9
- package/dist/web/event_history_store.d.ts +2 -0
- package/dist/web/event_history_store.js +31 -6
- package/dist/web/mirror_client.d.ts +3 -0
- package/dist/web/mirror_stream.d.ts +11 -0
- package/dist/web/mirror_stream.js +23 -3
- package/dist/worker/executor.js +3 -1
- package/dist/worker/toolsets.d.ts +1 -1
- package/dist/worker/toolsets.js +4 -3
- package/dist/worker/types.d.ts +6 -0
- package/dist/worker/worker_models.d.ts +17 -0
- package/dist/worker/worker_models.js +79 -0
- package/dist/zlm-embed.mjs +53761 -10916
- package/node_modules/@zerg/model-contracts/README.md +16 -5
- package/node_modules/@zerg/model-contracts/index.d.ts +7 -3
- package/node_modules/@zerg/model-contracts/index.js +40 -18
- package/node_modules/abort-controller/LICENSE +21 -0
- package/node_modules/abort-controller/README.md +98 -0
- package/node_modules/abort-controller/browser.js +13 -0
- package/node_modules/abort-controller/browser.mjs +11 -0
- package/node_modules/abort-controller/dist/abort-controller.d.ts +43 -0
- package/node_modules/abort-controller/dist/abort-controller.js +127 -0
- package/node_modules/abort-controller/dist/abort-controller.js.map +1 -0
- package/node_modules/abort-controller/dist/abort-controller.mjs +118 -0
- package/node_modules/abort-controller/dist/abort-controller.mjs.map +1 -0
- package/node_modules/abort-controller/dist/abort-controller.umd.js +5 -0
- package/node_modules/abort-controller/dist/abort-controller.umd.js.map +1 -0
- package/node_modules/abort-controller/package.json +97 -0
- package/node_modules/abort-controller/polyfill.js +21 -0
- package/node_modules/abort-controller/polyfill.mjs +19 -0
- package/node_modules/bluebird/LICENSE +1 -1
- package/node_modules/bluebird/README.md +8 -2
- package/node_modules/bluebird/js/browser/bluebird.core.js +325 -150
- package/node_modules/bluebird/js/browser/bluebird.core.min.js +4 -4
- package/node_modules/bluebird/js/browser/bluebird.js +362 -165
- package/node_modules/bluebird/js/browser/bluebird.min.js +5 -5
- package/node_modules/bluebird/js/release/async.js +15 -56
- package/node_modules/bluebird/js/release/debuggability.js +118 -25
- package/node_modules/bluebird/js/release/finally.js +37 -2
- package/node_modules/bluebird/js/release/generators.js +1 -1
- package/node_modules/bluebird/js/release/join.js +4 -7
- package/node_modules/bluebird/js/release/map.js +10 -3
- package/node_modules/bluebird/js/release/promise.js +89 -43
- package/node_modules/bluebird/js/release/promise_array.js +2 -0
- package/node_modules/bluebird/js/release/props.js +1 -1
- package/node_modules/bluebird/js/release/reduce.js +16 -5
- package/node_modules/bluebird/js/release/schedule.js +6 -5
- package/node_modules/bluebird/js/release/settle.js +4 -0
- package/node_modules/bluebird/js/release/util.js +53 -11
- package/node_modules/bluebird/package.json +7 -5
- package/node_modules/buffer/AUTHORS.md +3 -0
- package/node_modules/buffer/README.md +1 -1
- package/node_modules/buffer/index.d.ts +11 -3
- package/node_modules/buffer/index.js +424 -135
- package/node_modules/buffer/package.json +8 -11
- package/node_modules/compress-commons/README.md +1 -1
- package/node_modules/compress-commons/lib/archivers/archive-entry.js +6 -16
- package/node_modules/compress-commons/lib/archivers/archive-output-stream.js +79 -98
- package/node_modules/compress-commons/lib/archivers/zip/constants.js +99 -70
- package/node_modules/compress-commons/lib/archivers/zip/general-purpose-bit.js +70 -92
- package/node_modules/compress-commons/lib/archivers/zip/unix-stat.js +19 -53
- package/node_modules/compress-commons/lib/archivers/zip/util.js +49 -49
- package/node_modules/compress-commons/lib/archivers/zip/zip-archive-entry.js +356 -389
- package/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js +335 -404
- package/node_modules/compress-commons/lib/compress-commons.js +18 -13
- package/node_modules/compress-commons/lib/util/index.js +11 -21
- package/node_modules/compress-commons/node_modules/readable-stream/README.md +116 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/_stream_duplex.js +4 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/_stream_passthrough.js +4 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/_stream_readable.js +4 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/_stream_transform.js +4 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/_stream_writable.js +4 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/shims/process.js +19 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +52 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/buffer_list.js +157 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/compose.js +194 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/destroy.js +290 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/duplex.js +143 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/duplexify.js +378 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +286 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/from.js +98 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +51 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/legacy.js +94 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/operators.js +457 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/passthrough.js +39 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/pipeline.js +471 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/readable.js +1290 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/state.js +39 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/transform.js +180 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/utils.js +327 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/streams/writable.js +819 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/internal/validators.js +530 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/ours/browser.js +35 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/ours/errors.js +343 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/ours/index.js +65 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/ours/primordials.js +124 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/ours/util/inspect.js +55 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/ours/util.js +148 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/stream/promises.js +43 -0
- package/node_modules/compress-commons/node_modules/readable-stream/lib/stream.js +143 -0
- package/node_modules/compress-commons/node_modules/readable-stream/package.json +89 -0
- package/node_modules/compress-commons/package.json +13 -10
- package/node_modules/crc32-stream/README.md +8 -8
- package/node_modules/crc32-stream/lib/crc32-stream.js +4 -23
- package/node_modules/crc32-stream/lib/deflate-crc32-stream.js +5 -27
- package/node_modules/crc32-stream/lib/index.js +7 -6
- package/node_modules/crc32-stream/node_modules/readable-stream/README.md +116 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/_stream_duplex.js +4 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/_stream_passthrough.js +4 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/_stream_readable.js +4 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/_stream_transform.js +4 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/_stream_writable.js +4 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/shims/process.js +19 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +52 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/buffer_list.js +157 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/compose.js +194 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/destroy.js +290 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/duplex.js +143 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/duplexify.js +378 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +286 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/from.js +98 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +51 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/legacy.js +94 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/operators.js +457 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/passthrough.js +39 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/pipeline.js +471 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/readable.js +1290 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/state.js +39 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/transform.js +180 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/utils.js +327 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/streams/writable.js +819 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/internal/validators.js +530 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/ours/browser.js +35 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/ours/errors.js +343 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/ours/index.js +65 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/ours/primordials.js +124 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/ours/util/inspect.js +55 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/ours/util.js +148 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/stream/promises.js +43 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/lib/stream.js +143 -0
- package/node_modules/crc32-stream/node_modules/readable-stream/package.json +89 -0
- package/node_modules/crc32-stream/package.json +9 -10
- package/node_modules/event-target-shim/LICENSE +22 -0
- package/node_modules/event-target-shim/README.md +293 -0
- package/node_modules/event-target-shim/dist/event-target-shim.js +871 -0
- package/node_modules/event-target-shim/dist/event-target-shim.js.map +1 -0
- package/node_modules/event-target-shim/dist/event-target-shim.mjs +862 -0
- package/node_modules/event-target-shim/dist/event-target-shim.mjs.map +1 -0
- package/node_modules/event-target-shim/dist/event-target-shim.umd.js +6 -0
- package/node_modules/event-target-shim/dist/event-target-shim.umd.js.map +1 -0
- package/node_modules/event-target-shim/index.d.ts +399 -0
- package/node_modules/event-target-shim/package.json +82 -0
- package/node_modules/events/.airtap.yml +15 -0
- package/node_modules/events/.github/FUNDING.yml +12 -0
- package/node_modules/events/.travis.yml +18 -0
- package/node_modules/events/History.md +118 -0
- package/node_modules/events/LICENSE +22 -0
- package/node_modules/events/Readme.md +50 -0
- package/node_modules/events/events.js +497 -0
- package/node_modules/events/package.json +37 -0
- package/node_modules/events/security.md +10 -0
- package/node_modules/events/tests/add-listeners.js +111 -0
- package/node_modules/events/tests/check-listener-leaks.js +101 -0
- package/node_modules/events/tests/common.js +104 -0
- package/node_modules/events/tests/errors.js +13 -0
- package/node_modules/events/tests/events-list.js +28 -0
- package/node_modules/events/tests/events-once.js +234 -0
- package/node_modules/events/tests/index.js +64 -0
- package/node_modules/events/tests/legacy-compat.js +16 -0
- package/node_modules/events/tests/listener-count.js +37 -0
- package/node_modules/events/tests/listeners-side-effects.js +56 -0
- package/node_modules/events/tests/listeners.js +168 -0
- package/node_modules/events/tests/max-listeners.js +47 -0
- package/node_modules/events/tests/method-names.js +35 -0
- package/node_modules/events/tests/modify-in-emit.js +90 -0
- package/node_modules/events/tests/num-args.js +60 -0
- package/node_modules/events/tests/once.js +83 -0
- package/node_modules/events/tests/prepend.js +31 -0
- package/node_modules/events/tests/remove-all-listeners.js +133 -0
- package/node_modules/events/tests/remove-listeners.js +212 -0
- package/node_modules/events/tests/set-max-listeners-side-effects.js +31 -0
- package/node_modules/events/tests/special-event-names.js +45 -0
- package/node_modules/events/tests/subclass.js +66 -0
- package/node_modules/events/tests/symbols.js +25 -0
- package/node_modules/exceljs/lib/stream/xlsx/workbook-reader.js +5 -1
- package/node_modules/exceljs/lib/stream/xlsx/workbook-writer.js +2 -2
- package/node_modules/exceljs/lib/utils/zip-archive.js +85 -0
- package/node_modules/exceljs/package.json +3 -3
- package/node_modules/fs-extra/LICENSE +15 -0
- package/node_modules/fs-extra/README.md +294 -0
- package/node_modules/fs-extra/lib/copy/copy-sync.js +171 -0
- package/node_modules/fs-extra/lib/copy/copy.js +182 -0
- package/node_modules/fs-extra/lib/copy/index.js +7 -0
- package/node_modules/fs-extra/lib/empty/index.js +39 -0
- package/node_modules/fs-extra/lib/ensure/file.js +66 -0
- package/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/node_modules/fs-extra/lib/ensure/link.js +64 -0
- package/node_modules/fs-extra/lib/ensure/symlink-paths.js +101 -0
- package/node_modules/fs-extra/lib/ensure/symlink-type.js +34 -0
- package/node_modules/fs-extra/lib/ensure/symlink.js +67 -0
- package/node_modules/fs-extra/lib/esm.mjs +68 -0
- package/node_modules/fs-extra/lib/fs/index.js +146 -0
- package/node_modules/fs-extra/lib/index.js +16 -0
- package/node_modules/fs-extra/lib/json/index.js +16 -0
- package/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
- package/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
- package/node_modules/fs-extra/lib/move/index.js +7 -0
- package/node_modules/fs-extra/lib/move/move-sync.js +55 -0
- package/node_modules/fs-extra/lib/move/move.js +59 -0
- package/node_modules/fs-extra/lib/output-file/index.js +31 -0
- package/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/node_modules/fs-extra/lib/remove/index.js +17 -0
- package/node_modules/fs-extra/lib/util/stat.js +159 -0
- package/node_modules/fs-extra/lib/util/utimes.js +36 -0
- package/node_modules/fs-extra/package.json +71 -0
- package/node_modules/is-stream/index.d.ts +90 -0
- package/node_modules/is-stream/index.js +37 -0
- package/node_modules/is-stream/license +9 -0
- package/node_modules/is-stream/package.json +48 -0
- package/node_modules/is-stream/readme.md +57 -0
- package/node_modules/jsonfile/LICENSE +15 -0
- package/node_modules/jsonfile/README.md +230 -0
- package/node_modules/jsonfile/index.js +88 -0
- package/node_modules/jsonfile/package.json +40 -0
- package/node_modules/jsonfile/utils.js +18 -0
- package/node_modules/node-int64/.npmignore +3 -0
- package/node_modules/node-int64/Int64.js +268 -0
- package/node_modules/node-int64/LICENSE +19 -0
- package/node_modules/node-int64/README.md +78 -0
- package/node_modules/node-int64/package.json +27 -0
- package/node_modules/node-int64/test.js +120 -0
- package/node_modules/process/.eslintrc +21 -0
- package/node_modules/process/LICENSE +22 -0
- package/node_modules/process/README.md +26 -0
- package/node_modules/process/browser.js +184 -0
- package/node_modules/process/index.js +2 -0
- package/node_modules/process/package.json +27 -0
- package/node_modules/process/test.js +199 -0
- package/node_modules/universalify/LICENSE +20 -0
- package/node_modules/universalify/README.md +76 -0
- package/node_modules/universalify/index.js +24 -0
- package/node_modules/universalify/package.json +34 -0
- package/node_modules/unzipper/README.md +206 -176
- package/node_modules/unzipper/eslint.config.mjs +29 -0
- package/node_modules/unzipper/lib/BufferStream.js +9 -15
- package/node_modules/unzipper/lib/Decrypt.js +58 -36
- package/node_modules/unzipper/lib/NoopStream.js +5 -10
- package/node_modules/unzipper/lib/Open/directory.js +140 -127
- package/node_modules/unzipper/lib/Open/index.js +72 -32
- package/node_modules/unzipper/lib/Open/unzip.js +68 -74
- package/node_modules/unzipper/lib/PullStream.js +50 -55
- package/node_modules/unzipper/lib/extract.js +26 -18
- package/node_modules/unzipper/lib/parse.js +119 -118
- package/node_modules/unzipper/lib/parseBuffer.js +55 -0
- package/node_modules/unzipper/lib/parseExtraField.js +17 -14
- package/node_modules/unzipper/lib/parseOne.js +23 -27
- package/node_modules/unzipper/package.json +12 -13
- package/node_modules/unzipper/unzip.js +0 -6
- package/node_modules/zip-stream/README.md +5 -5
- package/node_modules/zip-stream/index.js +143 -169
- package/node_modules/zip-stream/node_modules/readable-stream/README.md +116 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/_stream_duplex.js +4 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/_stream_passthrough.js +4 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/_stream_readable.js +4 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/_stream_transform.js +4 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/_stream_writable.js +4 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/shims/process.js +19 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +52 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/buffer_list.js +157 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/compose.js +194 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/destroy.js +290 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/duplex.js +143 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/duplexify.js +378 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +286 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/from.js +98 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +51 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/legacy.js +94 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/operators.js +457 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/passthrough.js +39 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/pipeline.js +471 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/readable.js +1290 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/state.js +39 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/transform.js +180 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/utils.js +327 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/streams/writable.js +819 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/internal/validators.js +530 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/ours/browser.js +35 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/ours/errors.js +343 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/ours/index.js +65 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/ours/primordials.js +124 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/ours/util/inspect.js +55 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/ours/util.js +148 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/stream/promises.js +43 -0
- package/node_modules/zip-stream/node_modules/readable-stream/lib/stream.js +143 -0
- package/node_modules/zip-stream/node_modules/readable-stream/package.json +89 -0
- package/node_modules/zip-stream/package.json +15 -12
- package/node_modules/zip-stream/utils.js +21 -0
- package/package.json +22 -10
- package/packages/exceljs/PROVENANCE.md +24 -1
- package/packages/exceljs/lib/stream/xlsx/workbook-reader.js +5 -1
- package/packages/exceljs/lib/stream/xlsx/workbook-writer.js +2 -2
- package/packages/exceljs/lib/utils/zip-archive.js +85 -0
- package/packages/exceljs/package.json +3 -3
- package/packages/model-contracts/README.md +16 -5
- package/packages/model-contracts/index.d.ts +7 -3
- package/packages/model-contracts/index.js +40 -18
- package/scripts/install-macos-app.mjs +10 -1
- package/node_modules/archiver/LICENSE +0 -22
- package/node_modules/archiver/README.md +0 -94
- package/node_modules/archiver/index.js +0 -84
- package/node_modules/archiver/lib/core.js +0 -974
- package/node_modules/archiver/lib/error.js +0 -40
- package/node_modules/archiver/lib/plugins/json.js +0 -110
- package/node_modules/archiver/lib/plugins/tar.js +0 -167
- package/node_modules/archiver/lib/plugins/zip.js +0 -120
- package/node_modules/archiver/package.json +0 -60
- package/node_modules/archiver-utils/LICENSE +0 -22
- package/node_modules/archiver-utils/README.md +0 -7
- package/node_modules/archiver-utils/file.js +0 -209
- package/node_modules/archiver-utils/index.js +0 -156
- package/node_modules/archiver-utils/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/archiver-utils/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/archiver-utils/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/archiver-utils/node_modules/readable-stream/README.md +0 -58
- package/node_modules/archiver-utils/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/archiver-utils/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/package.json +0 -52
- package/node_modules/archiver-utils/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/archiver-utils/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/archiver-utils/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/archiver-utils/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/archiver-utils/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/archiver-utils/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/archiver-utils/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/archiver-utils/node_modules/safe-buffer/index.js +0 -62
- package/node_modules/archiver-utils/node_modules/safe-buffer/package.json +0 -37
- package/node_modules/archiver-utils/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/archiver-utils/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/archiver-utils/node_modules/string_decoder/README.md +0 -47
- package/node_modules/archiver-utils/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/archiver-utils/node_modules/string_decoder/package.json +0 -31
- package/node_modules/archiver-utils/package.json +0 -54
- package/node_modules/async/CHANGELOG.md +0 -351
- package/node_modules/async/LICENSE +0 -19
- package/node_modules/async/README.md +0 -59
- package/node_modules/async/all.js +0 -119
- package/node_modules/async/allLimit.js +0 -46
- package/node_modules/async/allSeries.js +0 -45
- package/node_modules/async/any.js +0 -122
- package/node_modules/async/anyLimit.js +0 -47
- package/node_modules/async/anySeries.js +0 -46
- package/node_modules/async/apply.js +0 -11
- package/node_modules/async/applyEach.js +0 -57
- package/node_modules/async/applyEachSeries.js +0 -37
- package/node_modules/async/asyncify.js +0 -118
- package/node_modules/async/auto.js +0 -333
- package/node_modules/async/autoInject.js +0 -182
- package/node_modules/async/bower.json +0 -17
- package/node_modules/async/cargo.js +0 -63
- package/node_modules/async/cargoQueue.js +0 -71
- package/node_modules/async/compose.js +0 -55
- package/node_modules/async/concat.js +0 -115
- package/node_modules/async/concatLimit.js +0 -60
- package/node_modules/async/concatSeries.js +0 -41
- package/node_modules/async/constant.js +0 -14
- package/node_modules/async/detect.js +0 -96
- package/node_modules/async/detectLimit.js +0 -48
- package/node_modules/async/detectSeries.js +0 -47
- package/node_modules/async/dir.js +0 -43
- package/node_modules/async/dist/async.js +0 -6061
- package/node_modules/async/dist/async.min.js +0 -1
- package/node_modules/async/dist/async.mjs +0 -5948
- package/node_modules/async/doDuring.js +0 -68
- package/node_modules/async/doUntil.js +0 -46
- package/node_modules/async/doWhilst.js +0 -68
- package/node_modules/async/during.js +0 -78
- package/node_modules/async/each.js +0 -129
- package/node_modules/async/eachLimit.js +0 -50
- package/node_modules/async/eachOf.js +0 -185
- package/node_modules/async/eachOfLimit.js +0 -47
- package/node_modules/async/eachOfSeries.js +0 -39
- package/node_modules/async/eachSeries.js +0 -44
- package/node_modules/async/ensureAsync.js +0 -67
- package/node_modules/async/every.js +0 -119
- package/node_modules/async/everyLimit.js +0 -46
- package/node_modules/async/everySeries.js +0 -45
- package/node_modules/async/filter.js +0 -93
- package/node_modules/async/filterLimit.js +0 -45
- package/node_modules/async/filterSeries.js +0 -43
- package/node_modules/async/find.js +0 -96
- package/node_modules/async/findLimit.js +0 -48
- package/node_modules/async/findSeries.js +0 -47
- package/node_modules/async/flatMap.js +0 -115
- package/node_modules/async/flatMapLimit.js +0 -60
- package/node_modules/async/flatMapSeries.js +0 -41
- package/node_modules/async/foldl.js +0 -153
- package/node_modules/async/foldr.js +0 -41
- package/node_modules/async/forEach.js +0 -129
- package/node_modules/async/forEachLimit.js +0 -50
- package/node_modules/async/forEachOf.js +0 -185
- package/node_modules/async/forEachOfLimit.js +0 -47
- package/node_modules/async/forEachOfSeries.js +0 -39
- package/node_modules/async/forEachSeries.js +0 -44
- package/node_modules/async/forever.js +0 -68
- package/node_modules/async/groupBy.js +0 -108
- package/node_modules/async/groupByLimit.js +0 -71
- package/node_modules/async/groupBySeries.js +0 -36
- package/node_modules/async/index.js +0 -588
- package/node_modules/async/inject.js +0 -153
- package/node_modules/async/internal/DoublyLinkedList.js +0 -92
- package/node_modules/async/internal/Heap.js +0 -120
- package/node_modules/async/internal/applyEach.js +0 -29
- package/node_modules/async/internal/asyncEachOfLimit.js +0 -75
- package/node_modules/async/internal/awaitify.js +0 -28
- package/node_modules/async/internal/breakLoop.js +0 -10
- package/node_modules/async/internal/consoleFunc.js +0 -31
- package/node_modules/async/internal/createTester.js +0 -40
- package/node_modules/async/internal/eachOfLimit.js +0 -90
- package/node_modules/async/internal/filter.js +0 -55
- package/node_modules/async/internal/getIterator.js +0 -11
- package/node_modules/async/internal/initialParams.js +0 -14
- package/node_modules/async/internal/isArrayLike.js +0 -10
- package/node_modules/async/internal/iterator.js +0 -57
- package/node_modules/async/internal/map.js +0 -30
- package/node_modules/async/internal/once.js +0 -17
- package/node_modules/async/internal/onlyOnce.js +0 -15
- package/node_modules/async/internal/parallel.js +0 -34
- package/node_modules/async/internal/promiseCallback.js +0 -23
- package/node_modules/async/internal/queue.js +0 -294
- package/node_modules/async/internal/range.js +0 -14
- package/node_modules/async/internal/reject.js +0 -26
- package/node_modules/async/internal/setImmediate.js +0 -34
- package/node_modules/async/internal/withoutIndex.js +0 -10
- package/node_modules/async/internal/wrapAsync.js +0 -34
- package/node_modules/async/log.js +0 -41
- package/node_modules/async/map.js +0 -142
- package/node_modules/async/mapLimit.js +0 -45
- package/node_modules/async/mapSeries.js +0 -44
- package/node_modules/async/mapValues.js +0 -152
- package/node_modules/async/mapValuesLimit.js +0 -61
- package/node_modules/async/mapValuesSeries.js +0 -37
- package/node_modules/async/memoize.js +0 -91
- package/node_modules/async/nextTick.js +0 -52
- package/node_modules/async/package.json +0 -75
- package/node_modules/async/parallel.js +0 -180
- package/node_modules/async/parallelLimit.js +0 -41
- package/node_modules/async/priorityQueue.js +0 -60
- package/node_modules/async/queue.js +0 -24
- package/node_modules/async/race.js +0 -67
- package/node_modules/async/reduce.js +0 -153
- package/node_modules/async/reduceRight.js +0 -41
- package/node_modules/async/reflect.js +0 -78
- package/node_modules/async/reflectAll.js +0 -93
- package/node_modules/async/reject.js +0 -87
- package/node_modules/async/rejectLimit.js +0 -45
- package/node_modules/async/rejectSeries.js +0 -43
- package/node_modules/async/retry.js +0 -159
- package/node_modules/async/retryable.js +0 -77
- package/node_modules/async/select.js +0 -93
- package/node_modules/async/selectLimit.js +0 -45
- package/node_modules/async/selectSeries.js +0 -43
- package/node_modules/async/seq.js +0 -79
- package/node_modules/async/series.js +0 -186
- package/node_modules/async/setImmediate.js +0 -45
- package/node_modules/async/some.js +0 -122
- package/node_modules/async/someLimit.js +0 -47
- package/node_modules/async/someSeries.js +0 -46
- package/node_modules/async/sortBy.js +0 -190
- package/node_modules/async/timeout.js +0 -89
- package/node_modules/async/times.js +0 -50
- package/node_modules/async/timesLimit.js +0 -43
- package/node_modules/async/timesSeries.js +0 -32
- package/node_modules/async/transform.js +0 -173
- package/node_modules/async/tryEach.js +0 -78
- package/node_modules/async/unmemoize.js +0 -25
- package/node_modules/async/until.js +0 -61
- package/node_modules/async/waterfall.js +0 -105
- package/node_modules/async/whilst.js +0 -78
- package/node_modules/async/wrapSync.js +0 -118
- package/node_modules/big-integer/BigInteger.d.ts +0 -2393
- package/node_modules/big-integer/BigInteger.js +0 -1453
- package/node_modules/big-integer/BigInteger.min.js +0 -1
- package/node_modules/big-integer/LICENSE +0 -24
- package/node_modules/big-integer/README.md +0 -589
- package/node_modules/big-integer/bower.json +0 -29
- package/node_modules/big-integer/package.json +0 -48
- package/node_modules/big-integer/tsconfig.json +0 -24
- package/node_modules/binary/.npmignore +0 -1
- package/node_modules/binary/.travis.yml +0 -4
- package/node_modules/binary/README.markdown +0 -177
- package/node_modules/binary/example/buf.js +0 -11
- package/node_modules/binary/example/parse.js +0 -10
- package/node_modules/binary/example/stream.js +0 -12
- package/node_modules/binary/index.js +0 -397
- package/node_modules/binary/lib/vars.js +0 -28
- package/node_modules/binary/package.json +0 -38
- package/node_modules/binary/perf/loop.js +0 -92
- package/node_modules/binary/perf/small.js +0 -80
- package/node_modules/binary/test/bu.js +0 -46
- package/node_modules/binary/test/deferred.js +0 -20
- package/node_modules/binary/test/dots.js +0 -23
- package/node_modules/binary/test/eof.js +0 -41
- package/node_modules/binary/test/flush.js +0 -17
- package/node_modules/binary/test/from_buffer.js +0 -14
- package/node_modules/binary/test/get_buffer.js +0 -28
- package/node_modules/binary/test/immediate.js +0 -18
- package/node_modules/binary/test/interval.js +0 -38
- package/node_modules/binary/test/into_buffer.js +0 -35
- package/node_modules/binary/test/into_stream.js +0 -43
- package/node_modules/binary/test/loop.js +0 -44
- package/node_modules/binary/test/loop_scan.js +0 -54
- package/node_modules/binary/test/lu.js +0 -46
- package/node_modules/binary/test/negbs.js +0 -29
- package/node_modules/binary/test/negls.js +0 -29
- package/node_modules/binary/test/nested.js +0 -35
- package/node_modules/binary/test/not_enough_buf.js +0 -17
- package/node_modules/binary/test/not_enough_parse.js +0 -19
- package/node_modules/binary/test/parse.js +0 -54
- package/node_modules/binary/test/peek.js +0 -40
- package/node_modules/binary/test/pipe.js +0 -49
- package/node_modules/binary/test/posbs.js +0 -29
- package/node_modules/binary/test/posls.js +0 -29
- package/node_modules/binary/test/scan.js +0 -33
- package/node_modules/binary/test/scan_buf.js +0 -18
- package/node_modules/binary/test/scan_buf_null.js +0 -16
- package/node_modules/binary/test/skip.js +0 -58
- package/node_modules/binary/test/split.js +0 -34
- package/node_modules/bl/.travis.yml +0 -17
- package/node_modules/bl/BufferList.js +0 -396
- package/node_modules/bl/LICENSE.md +0 -13
- package/node_modules/bl/README.md +0 -247
- package/node_modules/bl/bl.js +0 -84
- package/node_modules/bl/package.json +0 -37
- package/node_modules/bl/test/convert.js +0 -21
- package/node_modules/bl/test/indexOf.js +0 -492
- package/node_modules/bl/test/isBufferList.js +0 -32
- package/node_modules/bl/test/test.js +0 -869
- package/node_modules/buffer-crc32/LICENSE +0 -19
- package/node_modules/buffer-crc32/README.md +0 -47
- package/node_modules/buffer-crc32/index.js +0 -111
- package/node_modules/buffer-crc32/package.json +0 -39
- package/node_modules/buffer-indexof-polyfill/.eslintrc +0 -33
- package/node_modules/buffer-indexof-polyfill/.travis.yml +0 -17
- package/node_modules/buffer-indexof-polyfill/LICENSE +0 -22
- package/node_modules/buffer-indexof-polyfill/README.md +0 -33
- package/node_modules/buffer-indexof-polyfill/index.js +0 -73
- package/node_modules/buffer-indexof-polyfill/init-buffer.js +0 -8
- package/node_modules/buffer-indexof-polyfill/package.json +0 -34
- package/node_modules/buffer-indexof-polyfill/test/indexof.js +0 -128
- package/node_modules/buffers/README.markdown +0 -122
- package/node_modules/buffers/examples/slice.js +0 -9
- package/node_modules/buffers/examples/splice.js +0 -17
- package/node_modules/buffers/index.js +0 -269
- package/node_modules/buffers/package.json +0 -14
- package/node_modules/buffers/test/buffers.js +0 -209
- package/node_modules/chainsaw/.npmignore +0 -1
- package/node_modules/chainsaw/README.markdown +0 -157
- package/node_modules/chainsaw/examples/add_do.js +0 -25
- package/node_modules/chainsaw/examples/prompt.js +0 -67
- package/node_modules/chainsaw/index.js +0 -145
- package/node_modules/chainsaw/package.json +0 -23
- package/node_modules/chainsaw/test/chainsaw.js +0 -418
- package/node_modules/concat-map/.travis.yml +0 -4
- package/node_modules/concat-map/LICENSE +0 -18
- package/node_modules/concat-map/README.markdown +0 -62
- package/node_modules/concat-map/example/map.js +0 -6
- package/node_modules/concat-map/index.js +0 -13
- package/node_modules/concat-map/package.json +0 -43
- package/node_modules/concat-map/test/map.js +0 -39
- package/node_modules/end-of-stream/LICENSE +0 -21
- package/node_modules/end-of-stream/README.md +0 -54
- package/node_modules/end-of-stream/index.js +0 -96
- package/node_modules/end-of-stream/package.json +0 -37
- package/node_modules/fs-constants/LICENSE +0 -21
- package/node_modules/fs-constants/README.md +0 -26
- package/node_modules/fs-constants/browser.js +0 -1
- package/node_modules/fs-constants/index.js +0 -1
- package/node_modules/fs-constants/package.json +0 -19
- package/node_modules/fs.realpath/LICENSE +0 -43
- package/node_modules/fs.realpath/README.md +0 -33
- package/node_modules/fs.realpath/index.js +0 -66
- package/node_modules/fs.realpath/old.js +0 -303
- package/node_modules/fs.realpath/package.json +0 -26
- package/node_modules/fstream/.travis.yml +0 -9
- package/node_modules/fstream/LICENSE +0 -15
- package/node_modules/fstream/README.md +0 -76
- package/node_modules/fstream/examples/filter-pipe.js +0 -134
- package/node_modules/fstream/examples/pipe.js +0 -118
- package/node_modules/fstream/examples/reader.js +0 -68
- package/node_modules/fstream/examples/symlink-write.js +0 -27
- package/node_modules/fstream/fstream.js +0 -35
- package/node_modules/fstream/lib/abstract.js +0 -85
- package/node_modules/fstream/lib/collect.js +0 -70
- package/node_modules/fstream/lib/dir-reader.js +0 -252
- package/node_modules/fstream/lib/dir-writer.js +0 -174
- package/node_modules/fstream/lib/file-reader.js +0 -150
- package/node_modules/fstream/lib/file-writer.js +0 -107
- package/node_modules/fstream/lib/get-type.js +0 -33
- package/node_modules/fstream/lib/link-reader.js +0 -53
- package/node_modules/fstream/lib/link-writer.js +0 -95
- package/node_modules/fstream/lib/proxy-reader.js +0 -95
- package/node_modules/fstream/lib/proxy-writer.js +0 -111
- package/node_modules/fstream/lib/reader.js +0 -255
- package/node_modules/fstream/lib/socket-reader.js +0 -36
- package/node_modules/fstream/lib/writer.js +0 -390
- package/node_modules/fstream/package.json +0 -28
- package/node_modules/glob/LICENSE +0 -21
- package/node_modules/glob/README.md +0 -378
- package/node_modules/glob/common.js +0 -238
- package/node_modules/glob/glob.js +0 -790
- package/node_modules/glob/node_modules/balanced-match/.github/FUNDING.yml +0 -2
- package/node_modules/glob/node_modules/balanced-match/LICENSE.md +0 -21
- package/node_modules/glob/node_modules/balanced-match/README.md +0 -97
- package/node_modules/glob/node_modules/balanced-match/index.js +0 -62
- package/node_modules/glob/node_modules/balanced-match/package.json +0 -48
- package/node_modules/glob/node_modules/brace-expansion/LICENSE +0 -21
- package/node_modules/glob/node_modules/brace-expansion/README.md +0 -151
- package/node_modules/glob/node_modules/brace-expansion/index.js +0 -438
- package/node_modules/glob/node_modules/brace-expansion/package.json +0 -50
- package/node_modules/glob/node_modules/minimatch/LICENSE +0 -15
- package/node_modules/glob/node_modules/minimatch/README.md +0 -267
- package/node_modules/glob/node_modules/minimatch/minimatch.js +0 -1005
- package/node_modules/glob/node_modules/minimatch/package.json +0 -33
- package/node_modules/glob/package.json +0 -55
- package/node_modules/glob/sync.js +0 -486
- package/node_modules/inflight/LICENSE +0 -15
- package/node_modules/inflight/README.md +0 -37
- package/node_modules/inflight/inflight.js +0 -54
- package/node_modules/inflight/package.json +0 -29
- package/node_modules/lazystream/LICENSE +0 -23
- package/node_modules/lazystream/README.md +0 -114
- package/node_modules/lazystream/lib/lazystream.js +0 -54
- package/node_modules/lazystream/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/lazystream/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/lazystream/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/lazystream/node_modules/readable-stream/README.md +0 -58
- package/node_modules/lazystream/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/lazystream/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/lazystream/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/lazystream/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/lazystream/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/lazystream/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/node_modules/lazystream/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/node_modules/lazystream/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/node_modules/lazystream/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/package.json +0 -52
- package/node_modules/lazystream/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/lazystream/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/lazystream/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/lazystream/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/lazystream/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/lazystream/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/lazystream/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/lazystream/node_modules/safe-buffer/index.js +0 -62
- package/node_modules/lazystream/node_modules/safe-buffer/package.json +0 -37
- package/node_modules/lazystream/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/lazystream/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/lazystream/node_modules/string_decoder/README.md +0 -47
- package/node_modules/lazystream/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/lazystream/node_modules/string_decoder/package.json +0 -31
- package/node_modules/lazystream/package.json +0 -46
- package/node_modules/lazystream/test/data.md +0 -13
- package/node_modules/lazystream/test/fs_test.js +0 -69
- package/node_modules/lazystream/test/helper.js +0 -39
- package/node_modules/lazystream/test/pipe_test.js +0 -36
- package/node_modules/lazystream/test/readable_test.js +0 -90
- package/node_modules/lazystream/test/writable_test.js +0 -59
- package/node_modules/listenercount/.npmignore +0 -2
- package/node_modules/listenercount/LICENSE.md +0 -5
- package/node_modules/listenercount/README.md +0 -50
- package/node_modules/listenercount/circle.yml +0 -6
- package/node_modules/listenercount/index.js +0 -16
- package/node_modules/listenercount/package.json +0 -27
- package/node_modules/listenercount/test/test.js +0 -31
- package/node_modules/lodash.defaults/LICENSE +0 -47
- package/node_modules/lodash.defaults/README.md +0 -18
- package/node_modules/lodash.defaults/index.js +0 -668
- package/node_modules/lodash.defaults/package.json +0 -17
- package/node_modules/lodash.difference/LICENSE +0 -47
- package/node_modules/lodash.difference/README.md +0 -18
- package/node_modules/lodash.difference/index.js +0 -1170
- package/node_modules/lodash.difference/package.json +0 -17
- package/node_modules/lodash.flatten/LICENSE +0 -47
- package/node_modules/lodash.flatten/README.md +0 -18
- package/node_modules/lodash.flatten/index.js +0 -349
- package/node_modules/lodash.flatten/package.json +0 -17
- package/node_modules/lodash.isplainobject/LICENSE +0 -47
- package/node_modules/lodash.isplainobject/README.md +0 -18
- package/node_modules/lodash.isplainobject/index.js +0 -139
- package/node_modules/lodash.isplainobject/package.json +0 -17
- package/node_modules/lodash.union/LICENSE +0 -47
- package/node_modules/lodash.union/README.md +0 -18
- package/node_modules/lodash.union/index.js +0 -1181
- package/node_modules/lodash.union/package.json +0 -17
- package/node_modules/minimist/.eslintrc +0 -29
- package/node_modules/minimist/.github/FUNDING.yml +0 -12
- package/node_modules/minimist/.nycrc +0 -14
- package/node_modules/minimist/CHANGELOG.md +0 -298
- package/node_modules/minimist/LICENSE +0 -18
- package/node_modules/minimist/README.md +0 -121
- package/node_modules/minimist/example/parse.js +0 -4
- package/node_modules/minimist/index.js +0 -263
- package/node_modules/minimist/package.json +0 -75
- package/node_modules/minimist/test/all_bool.js +0 -34
- package/node_modules/minimist/test/bool.js +0 -177
- package/node_modules/minimist/test/dash.js +0 -43
- package/node_modules/minimist/test/default_bool.js +0 -37
- package/node_modules/minimist/test/dotted.js +0 -24
- package/node_modules/minimist/test/kv_short.js +0 -32
- package/node_modules/minimist/test/long.js +0 -33
- package/node_modules/minimist/test/num.js +0 -38
- package/node_modules/minimist/test/parse.js +0 -209
- package/node_modules/minimist/test/parse_modified.js +0 -11
- package/node_modules/minimist/test/proto.js +0 -64
- package/node_modules/minimist/test/short.js +0 -69
- package/node_modules/minimist/test/stop_early.js +0 -17
- package/node_modules/minimist/test/unknown.js +0 -104
- package/node_modules/minimist/test/whitespace.js +0 -10
- package/node_modules/mkdirp/LICENSE +0 -21
- package/node_modules/mkdirp/bin/cmd.js +0 -33
- package/node_modules/mkdirp/bin/usage.txt +0 -12
- package/node_modules/mkdirp/index.js +0 -102
- package/node_modules/mkdirp/package.json +0 -33
- package/node_modules/mkdirp/readme.markdown +0 -100
- package/node_modules/once/LICENSE +0 -15
- package/node_modules/once/README.md +0 -79
- package/node_modules/once/once.js +0 -42
- package/node_modules/once/package.json +0 -33
- package/node_modules/path-is-absolute/index.js +0 -20
- package/node_modules/path-is-absolute/license +0 -21
- package/node_modules/path-is-absolute/package.json +0 -43
- package/node_modules/path-is-absolute/readme.md +0 -59
- package/node_modules/readdir-glob/LICENSE +0 -201
- package/node_modules/readdir-glob/README.md +0 -85
- package/node_modules/readdir-glob/index.js +0 -243
- package/node_modules/readdir-glob/node_modules/balanced-match/.github/FUNDING.yml +0 -2
- package/node_modules/readdir-glob/node_modules/balanced-match/LICENSE.md +0 -21
- package/node_modules/readdir-glob/node_modules/balanced-match/README.md +0 -97
- package/node_modules/readdir-glob/node_modules/balanced-match/index.js +0 -62
- package/node_modules/readdir-glob/node_modules/balanced-match/package.json +0 -48
- package/node_modules/readdir-glob/node_modules/brace-expansion/.github/FUNDING.yml +0 -2
- package/node_modules/readdir-glob/node_modules/brace-expansion/LICENSE +0 -21
- package/node_modules/readdir-glob/node_modules/brace-expansion/README.md +0 -157
- package/node_modules/readdir-glob/node_modules/brace-expansion/index.js +0 -394
- package/node_modules/readdir-glob/node_modules/brace-expansion/package.json +0 -49
- package/node_modules/readdir-glob/node_modules/minimatch/LICENSE +0 -15
- package/node_modules/readdir-glob/node_modules/minimatch/README.md +0 -296
- package/node_modules/readdir-glob/node_modules/minimatch/lib/path.js +0 -4
- package/node_modules/readdir-glob/node_modules/minimatch/minimatch.js +0 -996
- package/node_modules/readdir-glob/node_modules/minimatch/package.json +0 -35
- package/node_modules/readdir-glob/package.json +0 -43
- package/node_modules/rimraf/LICENSE +0 -15
- package/node_modules/rimraf/README.md +0 -101
- package/node_modules/rimraf/bin.js +0 -50
- package/node_modules/rimraf/package.json +0 -29
- package/node_modules/rimraf/rimraf.js +0 -372
- package/node_modules/tar-stream/LICENSE +0 -21
- package/node_modules/tar-stream/README.md +0 -168
- package/node_modules/tar-stream/extract.js +0 -257
- package/node_modules/tar-stream/headers.js +0 -295
- package/node_modules/tar-stream/index.js +0 -2
- package/node_modules/tar-stream/pack.js +0 -255
- package/node_modules/tar-stream/package.json +0 -58
- package/node_modules/tar-stream/sandbox.js +0 -11
- package/node_modules/traverse/.npmignore +0 -1
- package/node_modules/traverse/LICENSE +0 -24
- package/node_modules/traverse/README.markdown +0 -247
- package/node_modules/traverse/examples/json.js +0 -16
- package/node_modules/traverse/examples/leaves.js +0 -15
- package/node_modules/traverse/examples/negative.js +0 -8
- package/node_modules/traverse/examples/stringify.js +0 -38
- package/node_modules/traverse/index.js +0 -322
- package/node_modules/traverse/package.json +0 -18
- package/node_modules/traverse/test/circular.js +0 -114
- package/node_modules/traverse/test/date.js +0 -35
- package/node_modules/traverse/test/equal.js +0 -219
- package/node_modules/traverse/test/instance.js +0 -17
- package/node_modules/traverse/test/interface.js +0 -42
- package/node_modules/traverse/test/json.js +0 -47
- package/node_modules/traverse/test/leaves.js +0 -21
- package/node_modules/traverse/test/mutability.js +0 -203
- package/node_modules/traverse/test/negative.js +0 -20
- package/node_modules/traverse/test/obj.js +0 -15
- package/node_modules/traverse/test/stop.js +0 -41
- package/node_modules/traverse/test/stringify.js +0 -36
- package/node_modules/traverse/test/super_deep.js +0 -54
- package/node_modules/unzipper/.circleci/config.yml +0 -13
- package/node_modules/unzipper/.travis.yml +0 -21
- package/node_modules/unzipper/lib/Buffer.js +0 -12
- package/node_modules/unzipper/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/unzipper/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/unzipper/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/unzipper/node_modules/readable-stream/README.md +0 -58
- package/node_modules/unzipper/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/unzipper/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/unzipper/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/unzipper/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/unzipper/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/unzipper/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/package.json +0 -52
- package/node_modules/unzipper/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/unzipper/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/unzipper/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/unzipper/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/unzipper/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/unzipper/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/unzipper/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/unzipper/node_modules/safe-buffer/index.js +0 -62
- package/node_modules/unzipper/node_modules/safe-buffer/package.json +0 -37
- package/node_modules/unzipper/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/unzipper/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/unzipper/node_modules/string_decoder/README.md +0 -47
- package/node_modules/unzipper/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/unzipper/node_modules/string_decoder/package.json +0 -31
- package/node_modules/wrappy/LICENSE +0 -15
- package/node_modules/wrappy/README.md +0 -36
- package/node_modules/wrappy/package.json +0 -29
- package/node_modules/wrappy/wrappy.js +0 -33
- package/node_modules/zip-stream/node_modules/archiver-utils/LICENSE +0 -22
- package/node_modules/zip-stream/node_modules/archiver-utils/README.md +0 -6
- package/node_modules/zip-stream/node_modules/archiver-utils/file.js +0 -209
- package/node_modules/zip-stream/node_modules/archiver-utils/index.js +0 -149
- package/node_modules/zip-stream/node_modules/archiver-utils/package.json +0 -54
- /package/node_modules/{archiver-utils → compress-commons}/node_modules/readable-stream/LICENSE +0 -0
- /package/node_modules/{lazystream → crc32-stream}/node_modules/readable-stream/LICENSE +0 -0
- /package/node_modules/{unzipper → zip-stream}/node_modules/readable-stream/LICENSE +0 -0
package/dist/agent/agent.js
CHANGED
|
@@ -5,10 +5,11 @@ import { existsSync, readFileSync, realpathSync } from 'fs';
|
|
|
5
5
|
import { extname, resolve } from 'path';
|
|
6
6
|
import { formatTaskHandoffContext, parseTaskHandoffProjection } from '../session_handoff_contract.js';
|
|
7
7
|
import { createBackendForProvider } from './backends/index.js';
|
|
8
|
+
import { RequestRefusedError } from './backends/types.js';
|
|
8
9
|
import { mergeTokenUsage } from './backends/token_usage.js';
|
|
9
10
|
import { createUsageSnapshot, mergeUsageSnapshots, parseUsageSnapshot, recordUsageReceipt } from '../usage_snapshot.js';
|
|
10
|
-
import { isTransportCodeError, isTransportMessageError } from './backends/transport_errors.js';
|
|
11
|
-
import { retryAfterDelayMs } from './backends/http_error.js';
|
|
11
|
+
import { IncompleteStreamError, isIncompleteStreamError, isTransportCodeError, isTransportMessageError } from './backends/transport_errors.js';
|
|
12
|
+
import { BackendHttpError, redactErrorText, retryAfterDelayMs } from './backends/http_error.js';
|
|
12
13
|
import { inferDefaultProvider, getDefaultApiKeyForProvider, getDefaultModelForProvider } from '../config/defaults.js';
|
|
13
14
|
import { apiRetryDelayMs, resolveApiRetrySettings } from '../config/api_retry.js';
|
|
14
15
|
import { resolveExecutionSettings } from '../config/execution.js';
|
|
@@ -25,7 +26,10 @@ import { defaultTools as baseDefaultTools } from './tools/registry.js';
|
|
|
25
26
|
import { toolSearchTool } from './tools/tool_search.js';
|
|
26
27
|
import { recallToolResponseTool } from './tools/recall_tool_response.js';
|
|
27
28
|
import { adaptationRunTool } from './tools/adaptation.js';
|
|
29
|
+
import { ToolGroupRuntime } from './tools/tool_groups.js';
|
|
30
|
+
import { isCodexAppServerProvider } from './backends/provider_ids.js';
|
|
28
31
|
import { getRequestToolDefinitions } from './tools/deferred.js';
|
|
32
|
+
import { isToolResultMessage } from '../utils/tool_result_message.js';
|
|
29
33
|
import { getLatestTodos } from './tools/todo.js';
|
|
30
34
|
import { ToolResponseStore, ToolResponseIntegrityError, describeOffloadPlaceholderFormat } from './tool_response_store.js';
|
|
31
35
|
import { formatEvidenceContext } from './runtime/evidence.js';
|
|
@@ -34,15 +38,24 @@ import { projectCurrentVerification } from './runtime/source_verification.js';
|
|
|
34
38
|
import { sessionEvidenceTool } from './tools/session_evidence.js';
|
|
35
39
|
import { MEASUREMENT_EVIDENCE_GUIDANCE } from './measurement_guidance.js';
|
|
36
40
|
import { RequestEncoder, STABLE_RESULT_LIMIT, nativeHistoryContextId } from './request_encoder.js';
|
|
41
|
+
import { presentToolResult } from './tool_result_presentation.js';
|
|
42
|
+
import { BackgroundWorkers, formatWorkerReports } from './background_workers.js';
|
|
37
43
|
import { parseImageToolResult } from './tool_result_parsing.js';
|
|
38
|
-
import { createRepeatGuard, pinnedTaskSystem } from './loop_policy.js';
|
|
44
|
+
import { completionCheckDue, createRepeatGuard, needsCompletionCheck, pinnedTaskSystem } from './loop_policy.js';
|
|
39
45
|
import { extractSourcePath } from './tool_compression.js';
|
|
40
46
|
import { executeToolWithRuntime } from './runtime/tool_runtime.js';
|
|
41
47
|
import { createToolProgressAccumulator } from './runtime/tool_progress.js';
|
|
42
48
|
import { ToolCapability } from './runtime/capabilities.js';
|
|
43
49
|
import { buildUserSubprocessEnv } from '../utils/subprocess_env.js';
|
|
44
|
-
import { resolvePromptPrefixId } from '../utils/compaction.js';
|
|
45
|
-
import {
|
|
50
|
+
import { projectHandoffHistory, resolvePromptPrefixId } from '../utils/compaction.js';
|
|
51
|
+
import { estimateConversationTokens, getContextWindowSize } from '../utils/context.js';
|
|
52
|
+
import { shouldCompactMidTurn } from '../utils/mid_turn_compaction.js';
|
|
53
|
+
import { clampCompletionTokens } from '../utils/deepseek.js';
|
|
54
|
+
import { resolveToolEffect } from './runtime/tool_effects.js';
|
|
55
|
+
import { INCOMPLETE_MODEL_RESPONSE_CODE, INCOMPLETE_MODEL_RESPONSE_MESSAGE, incompleteModelResponseMessage, isIncompleteModelResponse, isOutputLimitStop, OUTPUT_LIMIT_RETRY_NOTE, outputLimitRetryEffort, repeatedRunawayMessage, RUNAWAY_OUTPUT_CODE, RUNAWAY_OUTPUT_RETRY_NOTE, } from './completion_state.js';
|
|
56
|
+
import { guardRunawayOutput, RunawayOutputError } from './runaway_output.js';
|
|
57
|
+
import { isEphemeralToolCall } from '../utils/ephemeral_tools.js';
|
|
58
|
+
import { canReadCopies, COPY_ADVICE, resultCopyNote, saveCopy } from '../utils/tool_output_copies.js';
|
|
46
59
|
import { remoteDeletionReport, NO_VERIFIED_DELETION_REPORT } from './runtime/remote_deletion_receipts.js';
|
|
47
60
|
const defaultTools = [
|
|
48
61
|
...baseDefaultTools,
|
|
@@ -87,6 +100,16 @@ export function isContextOverflowMessage(message) {
|
|
|
87
100
|
const haystack = message.toLowerCase();
|
|
88
101
|
return CONTEXT_OVERFLOW_SUBSTRINGS.some(s => haystack.includes(s));
|
|
89
102
|
}
|
|
103
|
+
// Router usage-control refusals (zergrouter usage-denials.ts) that last until
|
|
104
|
+
// their daily, weekly or monthly window resets.
|
|
105
|
+
const LASTING_ROUTER_USAGE_LIMITS = new Set(['router_usage_budget_exceeded', 'router_usage_token_limit_exceeded']);
|
|
106
|
+
const ROUTER_RATE_LIMIT_CODES = new Set(['rate_limit_exceeded', 'free_model_daily_limit']);
|
|
107
|
+
/**
|
|
108
|
+
* Continuous recovery rides out an outage, but a provider that keeps refusing for its rate limit is not recovering:
|
|
109
|
+
* a free OpenRouter model was retried 27 times in ten minutes (2026-10-27). After this many rate-limited attempts in
|
|
110
|
+
* a row (about four minutes at the default backoff) the turn ends and says so.
|
|
111
|
+
*/
|
|
112
|
+
const RATE_LIMITED_ATTEMPTS = 10;
|
|
90
113
|
const DEFAULT_LLM_REQUEST_TIMEOUT_MS = 120_000;
|
|
91
114
|
/**
|
|
92
115
|
* Resolve the per-attempt request timeout.
|
|
@@ -164,11 +187,29 @@ function normalizeRepeatedResponseContent(content) {
|
|
|
164
187
|
return normalized === block.text ? block : { ...block, text: normalized };
|
|
165
188
|
});
|
|
166
189
|
}
|
|
190
|
+
/** The environment lines a saved row must still match to be resent: its
|
|
191
|
+
* listing and git status are labelled as of the start, these are not. */
|
|
192
|
+
const RUNTIME_FACT_LINE = /^(?:Working directory:|Platform:|OS Version:|Today's date:|You are powered by the model:|Commands and file tools run inside |Current branch:)/;
|
|
193
|
+
function runtimeFacts(text) {
|
|
194
|
+
return text.split('\n').filter(line => RUNTIME_FACT_LINE.test(line)).join('\n');
|
|
195
|
+
}
|
|
196
|
+
/** A handoff without its freshness lines: each save moves the as-of time and
|
|
197
|
+
* revision, and each process its owner PID, without changing the task facts. */
|
|
198
|
+
function handoffSubstance(text) {
|
|
199
|
+
return text.split('\n').filter(line => !line.startsWith('Source session: ') && !line.startsWith('Historical owner: ')).join('\n');
|
|
200
|
+
}
|
|
167
201
|
// --- Agent Class ---
|
|
168
202
|
export class Agent {
|
|
169
203
|
config;
|
|
204
|
+
onMidTurnCompact;
|
|
205
|
+
midTurnCompactThresholdPercent;
|
|
206
|
+
midTurnCompactWindow;
|
|
207
|
+
midTurnCompactTokenBudget;
|
|
170
208
|
/** Codex/GPT reasoning effort override; undefined = provider default. */
|
|
171
209
|
_codexEffort;
|
|
210
|
+
/** One-shot: the next request carries the output-limit note at this effort. */
|
|
211
|
+
/** The next request retries a discarded response: a note for the model, and lower effort when offered. */
|
|
212
|
+
responseRetry = null;
|
|
172
213
|
/** Fast mode — request the priority service tier from the Codex/GPT backend. */
|
|
173
214
|
_codexFastMode;
|
|
174
215
|
eventHandlers = new Set();
|
|
@@ -190,6 +231,11 @@ export class Agent {
|
|
|
190
231
|
_autoContinue;
|
|
191
232
|
/** Auto-continues spent since the last tool run; reset per turn and per tool. */
|
|
192
233
|
_consecutiveAutoContinues = 0;
|
|
234
|
+
_turnAutoContinues = 0;
|
|
235
|
+
_turnToolBatches = 0;
|
|
236
|
+
_turnToolChangedState = false;
|
|
237
|
+
_turnCommandsRun = new Set();
|
|
238
|
+
_turnCheckAsked = false;
|
|
193
239
|
_subprocessEnv;
|
|
194
240
|
commandPolicy;
|
|
195
241
|
toolEffectObserver;
|
|
@@ -319,11 +365,16 @@ export class Agent {
|
|
|
319
365
|
? [record.source.verification.receipt_id] : []));
|
|
320
366
|
this.toolResponseStore.evidence.setVerificationCoverage(coverage.filter(row => retained.has(row.receipt_id)));
|
|
321
367
|
}
|
|
368
|
+
toolGroups;
|
|
322
369
|
discoveredTools = new Set();
|
|
323
370
|
// Host-injected agent-domain tools that ship every request regardless of the
|
|
324
371
|
// deferred-tool registry. Unlike discoveredTools (session-scoped, cleared on
|
|
325
372
|
// session bind), this is fixed for the agent's lifetime.
|
|
326
373
|
alwaysLoadedToolNames = new Set();
|
|
374
|
+
/** Workers started with delegate_task `background: true`; stopped when a run ends. */
|
|
375
|
+
backgroundWorkers;
|
|
376
|
+
/** The latest authored prompt, for a worker's brief. */
|
|
377
|
+
turnInstruction = '';
|
|
327
378
|
hooks;
|
|
328
379
|
approvalRequester;
|
|
329
380
|
approvalRequiredCapabilities;
|
|
@@ -333,7 +384,7 @@ export class Agent {
|
|
|
333
384
|
constructor(config = {}) {
|
|
334
385
|
this.toolResponseStore = config.toolResponseStore ?? new ToolResponseStore();
|
|
335
386
|
const ambientDiscovery = config.ambientDiscovery ?? true;
|
|
336
|
-
const defaultProvider = ambientDiscovery ? inferDefaultProvider() : 'anthropic';
|
|
387
|
+
const defaultProvider = config.provider ?? (ambientDiscovery ? inferDefaultProvider() : 'anthropic');
|
|
337
388
|
const defaultModel = getDefaultModelForProvider(defaultProvider);
|
|
338
389
|
const apiKey = config.apiKey
|
|
339
390
|
|| (ambientDiscovery && config.disableApiKeyFallback !== true
|
|
@@ -344,15 +395,21 @@ export class Agent {
|
|
|
344
395
|
apiKey,
|
|
345
396
|
apiEndpoint: config.apiEndpoint,
|
|
346
397
|
});
|
|
347
|
-
const
|
|
398
|
+
const suppliedTools = config.tools ?? (ambientDiscovery ? defaultTools : []);
|
|
399
|
+
this.toolGroups = config.toolGroups ? new ToolGroupRuntime(config.toolGroups, suppliedTools, !isCodexAppServerProvider(config.runtimeFacts?.provider ?? defaultProvider)) : undefined;
|
|
400
|
+
const tools = this.toolGroups?.tools ?? suppliedTools;
|
|
348
401
|
this.config = {
|
|
402
|
+
provider: defaultProvider,
|
|
349
403
|
model: config.model || defaultModel,
|
|
350
404
|
apiKey,
|
|
351
405
|
disableApiKeyFallback: config.disableApiKeyFallback ?? false,
|
|
352
|
-
runtimeCredentialsAvailable: config.runtimeCredentialsAvailable ??
|
|
406
|
+
runtimeCredentialsAvailable: config.runtimeCredentialsAvailable ?? (defaultProvider === 'bedrock'),
|
|
353
407
|
apiEndpoint: config.apiEndpoint || ((defaultProvider === 'anthropic' || defaultProvider === 'claude_code' || defaultProvider === 'claude-code') ? 'https://api.anthropic.com/v1/messages' : 'https://api.openai.com/v1'),
|
|
354
408
|
maxTokens: config.maxTokens,
|
|
355
409
|
routePlan: config.routePlan,
|
|
410
|
+
leadTurnNote: config.leadTurnNote,
|
|
411
|
+
leadStaffingNote: config.leadStaffingNote,
|
|
412
|
+
workerCheckIntervalMs: config.workerCheckIntervalMs,
|
|
356
413
|
maxIterations: config.maxIterations || 10,
|
|
357
414
|
execution: resolveExecutionSettings(config.execution),
|
|
358
415
|
sessionId: config.sessionId ?? randomUUID(),
|
|
@@ -367,10 +424,16 @@ export class Agent {
|
|
|
367
424
|
tracer: config.tracer || new NoopTracer(),
|
|
368
425
|
cwd: config.cwd || process.cwd(),
|
|
369
426
|
autoContinue: config.autoContinue ?? true,
|
|
427
|
+
completionCheck: config.completionCheck ?? false,
|
|
370
428
|
maxConsecutiveAutoContinues: config.maxConsecutiveAutoContinues ?? 3,
|
|
371
429
|
pinTaskHeader: config.pinTaskHeader ?? true,
|
|
372
|
-
deferToolSchemas: config.deferToolSchemas ?? true
|
|
430
|
+
deferToolSchemas: config.deferToolSchemas ?? true,
|
|
373
431
|
};
|
|
432
|
+
this.onMidTurnCompact = config.onMidTurnCompact;
|
|
433
|
+
this.midTurnCompactThresholdPercent = config.midTurnCompactThresholdPercent;
|
|
434
|
+
this.midTurnCompactWindow = config.midTurnCompactWindow;
|
|
435
|
+
this.midTurnCompactTokenBudget = config.midTurnCompactTokenBudget;
|
|
436
|
+
this.runtimeContext = config.runtimeContext?.trim() ? config.runtimeContext : null;
|
|
374
437
|
this._subprocessEnv = config.subprocessEnv === undefined
|
|
375
438
|
? undefined
|
|
376
439
|
: buildUserSubprocessEnv(config.subprocessEnv);
|
|
@@ -383,6 +446,7 @@ export class Agent {
|
|
|
383
446
|
// Host-injected agent-domain tools always ship their schema (they're the
|
|
384
447
|
// agent's primary surface, not a corpus to search). Kept separate from
|
|
385
448
|
// discoveredTools so a session bind's discovered.clear() can't drop them.
|
|
449
|
+
this.backgroundWorkers = new BackgroundWorkers(config.workerCheckIntervalMs);
|
|
386
450
|
for (const name of config.alwaysLoadedToolNames ?? []) {
|
|
387
451
|
this.alwaysLoadedToolNames.add(name);
|
|
388
452
|
}
|
|
@@ -394,6 +458,19 @@ export class Agent {
|
|
|
394
458
|
this.policy = this.config.policy;
|
|
395
459
|
const suppliedTracer = this.config.tracer;
|
|
396
460
|
this.tracer = { event: event => {
|
|
461
|
+
// Opaque provider continuation is session state, not diagnostic content.
|
|
462
|
+
// Never leak it into prompt viewers, traces, or caller audit sinks.
|
|
463
|
+
if (event.type === 'api_request' || event.type === 'api_response') {
|
|
464
|
+
const sanitize = (value) => {
|
|
465
|
+
if (Array.isArray(value))
|
|
466
|
+
return value.filter(item => !(item && typeof item === 'object' && 'type' in item && item.type === 'responses_reasoning')).map(sanitize);
|
|
467
|
+
if (value && typeof value === 'object')
|
|
468
|
+
return Object.fromEntries(Object.entries(value)
|
|
469
|
+
.filter(([key]) => key !== 'responsesItem' && key !== 'responseItems' && key !== 'openaiResponseItems' && key !== 'encrypted_content').map(([key, child]) => [key, sanitize(child)]));
|
|
470
|
+
return value;
|
|
471
|
+
};
|
|
472
|
+
event = { ...event, data: sanitize(event.data) };
|
|
473
|
+
}
|
|
397
474
|
this.captureDiagnosticTrace(event);
|
|
398
475
|
suppliedTracer.event(event);
|
|
399
476
|
} };
|
|
@@ -431,6 +508,8 @@ export class Agent {
|
|
|
431
508
|
/** Override the agent's system prompt (e.g., for simulation persona injection). */
|
|
432
509
|
setSystemPrompt(prompt) {
|
|
433
510
|
this.config.systemPrompt = prompt;
|
|
511
|
+
// The override replaces the composed prompt, environment included.
|
|
512
|
+
this.runtimeContext = null;
|
|
434
513
|
this._hasCustomSystemPrompt = true;
|
|
435
514
|
}
|
|
436
515
|
/**
|
|
@@ -484,10 +563,30 @@ export class Agent {
|
|
|
484
563
|
getCwd() {
|
|
485
564
|
return this._cwd;
|
|
486
565
|
}
|
|
566
|
+
/** Load a declared group after a host page change; Codex requires a new session. */
|
|
567
|
+
loadToolGroup(group) {
|
|
568
|
+
if (!this.toolGroups)
|
|
569
|
+
throw new Error('No tool groups are configured.');
|
|
570
|
+
return this.toolGroups.load(group);
|
|
571
|
+
}
|
|
487
572
|
/** Snapshot the effective tool surface after mode/provider filtering. */
|
|
488
573
|
getConfiguredToolNames() {
|
|
489
574
|
return this.config.tools.map((tool) => tool.definition.name);
|
|
490
575
|
}
|
|
576
|
+
getHandoffContext(messages = []) {
|
|
577
|
+
return { ...this.buildRequest([...messages]), backend: this.backend,
|
|
578
|
+
onMetrics: metrics => {
|
|
579
|
+
this.emit({ type: 'request_metrics', metrics });
|
|
580
|
+
if (!metrics.usage)
|
|
581
|
+
return;
|
|
582
|
+
this.retainUsageReceipt({ id: `usage_${randomUUID()}`, sessionId: this.config.sessionId,
|
|
583
|
+
projectHash: createHash('sha256').update(this._cwd).digest('hex').slice(0, 12),
|
|
584
|
+
provider: this.config.runtimeFacts.provider ?? null, model: this.config.model, accountId: null,
|
|
585
|
+
observedAt: new Date().toISOString(), source: metrics.usage.estimated ? 'estimated' : 'reported',
|
|
586
|
+
usage: metrics.usage, costUsd: null });
|
|
587
|
+
},
|
|
588
|
+
};
|
|
589
|
+
}
|
|
491
590
|
getDefaultSystemPrompt(tools) {
|
|
492
591
|
const offloadEnabled = this.toolResponseStore.getConfig().offloadEnabled;
|
|
493
592
|
const offloadSection = offloadEnabled
|
|
@@ -527,6 +626,12 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
527
626
|
return () => this.eventHandlers.delete(handler);
|
|
528
627
|
}
|
|
529
628
|
emit(event) {
|
|
629
|
+
if (event.type === 'history_checkpoint') {
|
|
630
|
+
event = { ...event, messages: event.messages.map(message => {
|
|
631
|
+
const { openaiResponseItems, ...metadata } = message.metadata ?? {};
|
|
632
|
+
return { ...message, metadata };
|
|
633
|
+
}) };
|
|
634
|
+
}
|
|
530
635
|
for (const handler of this.eventHandlers) {
|
|
531
636
|
handler(event);
|
|
532
637
|
}
|
|
@@ -575,14 +680,19 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
575
680
|
_nativeContextId;
|
|
576
681
|
formatMessages(messages) {
|
|
577
682
|
// Pre-pass: collect every tool_use_id appearing in tool_result messages,
|
|
578
|
-
// and
|
|
683
|
+
// and retain every batch since the latest authored prompt. Running the
|
|
579
684
|
// selector once for the whole request gives aggregate budget control;
|
|
580
685
|
// buildContentBlocks below just reads the verdict.
|
|
581
686
|
const allToolIds = [];
|
|
582
|
-
|
|
687
|
+
const currentTurnToolIds = new Set();
|
|
583
688
|
for (const m of messages) {
|
|
584
689
|
if (m.role !== 'user' || !m.content)
|
|
585
690
|
continue;
|
|
691
|
+
if (!isToolResultMessage(m)) {
|
|
692
|
+
if (!m.metadata?.synthetic && !m.metadata?.hostContext)
|
|
693
|
+
currentTurnToolIds.clear();
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
586
696
|
const trimmed = m.content.trimStart();
|
|
587
697
|
if (!trimmed.startsWith('[') || !trimmed.includes('"tool_use_id"'))
|
|
588
698
|
continue;
|
|
@@ -592,7 +702,8 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
592
702
|
.map(p => (typeof p?.tool_use_id === 'string' ? p.tool_use_id : null))
|
|
593
703
|
.filter((id) => Boolean(id));
|
|
594
704
|
allToolIds.push(...ids);
|
|
595
|
-
|
|
705
|
+
for (const id of ids)
|
|
706
|
+
currentTurnToolIds.add(id);
|
|
596
707
|
}
|
|
597
708
|
catch {
|
|
598
709
|
// Unparseable user message; skip.
|
|
@@ -635,10 +746,25 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
635
746
|
selectorVerdict: this._selectorVerdict,
|
|
636
747
|
currentTurnToolIds: this._currentRequestToolIds,
|
|
637
748
|
renderForContext: (id) => this.toolResponseStore.renderForContext(id),
|
|
749
|
+
saveFullResult: (id, content) => this.saveFullResult(id, content),
|
|
750
|
+
frozenResultContent: (id) => this.toolResponseStore.frozenResultContent(id),
|
|
751
|
+
freezeResultContent: (id, content) => this.toolResponseStore.freezeResultContent(id, content),
|
|
638
752
|
loadImageBlock: (path) => this.loadImageBlock(path),
|
|
639
753
|
loadVideoBlock: (path) => this.loadVideoBlock(path),
|
|
640
754
|
};
|
|
641
755
|
}
|
|
756
|
+
/** A whole result kept on disk before it is sent shortened; an ephemeral tool's stays in memory. */
|
|
757
|
+
saveFullResult(toolUseId, content, call) {
|
|
758
|
+
const config = this.toolResponseStore.getConfig();
|
|
759
|
+
if (this.toolResponseStore.getMeta(toolUseId)?.ephemeral
|
|
760
|
+
|| (call && isEphemeralToolCall(call.name, call.args, config.ephemeralToolNames, config.ephemeralToolRules)))
|
|
761
|
+
return null;
|
|
762
|
+
const folder = this.toolResponseStore.outputCopyDir();
|
|
763
|
+
// A copy nothing can read would only leave the result in plain text on disk.
|
|
764
|
+
if (!folder || !canReadCopies(this.config.tools.map(tool => tool.definition.name)))
|
|
765
|
+
return null;
|
|
766
|
+
return saveCopy(folder, toolUseId, 'result', content);
|
|
767
|
+
}
|
|
642
768
|
contentLength(content) {
|
|
643
769
|
if (typeof content === 'string')
|
|
644
770
|
return content.length;
|
|
@@ -878,7 +1004,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
878
1004
|
content = 'Tool outcome unknown: the original result was not durably observed. Inspect this exact call and its existing receipts/current state before deciding whether to retry. Do not automatically repeat the original command; local interruption does not prove that an external operation stopped.';
|
|
879
1005
|
}
|
|
880
1006
|
if (content.length > SYNTH_RESULT_CAP) {
|
|
881
|
-
|
|
1007
|
+
const copy = this.saveFullResult(tc.id, content, tc);
|
|
1008
|
+
content = content.slice(0, SYNTH_RESULT_CAP)
|
|
1009
|
+
+ `\n[truncated — ${content.length} chars total${copy ? `; ${resultCopyNote(tc.id, copy)}; ${COPY_ADVICE}` : ''}]`;
|
|
882
1010
|
}
|
|
883
1011
|
emittedToolResultIds.add(tc.id);
|
|
884
1012
|
return { tool_use_id: tc.id, content, is_error: Boolean(tc.error) || tc.result == null };
|
|
@@ -899,13 +1027,22 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
899
1027
|
return repaired;
|
|
900
1028
|
}
|
|
901
1029
|
buildRequest(messages, availableTools = this.config.tools) {
|
|
1030
|
+
messages = projectHandoffHistory(messages);
|
|
902
1031
|
this.captureUserInstructions(messages);
|
|
903
|
-
|
|
1032
|
+
// A call with a recorded outcome is sent with its result (inline or as a
|
|
1033
|
+
// stored preview), so its evidence needs no second copy of the output.
|
|
1034
|
+
const toolCallsInContext = new Set(messages.flatMap(message => (message.toolCalls ?? [])
|
|
1035
|
+
.filter(call => call.result !== undefined || call.error !== undefined).map(call => call.id)));
|
|
904
1036
|
const evidenceTurn = [...messages].reverse().find(message => message.role === 'user');
|
|
905
1037
|
// Stamp each source turn once. Render the host index next to that turn
|
|
906
1038
|
// without changing its text, the system prefix or prior request records.
|
|
907
|
-
|
|
908
|
-
|
|
1039
|
+
// Earlier stamps stay in the conversation, so a new stamp lists only the
|
|
1040
|
+
// records they do not already show unchanged.
|
|
1041
|
+
if (evidenceTurn && typeof evidenceTurn.metadata?.evidenceContext !== 'string') {
|
|
1042
|
+
const renderedEarlier = messages.flatMap(message => typeof message.metadata?.evidenceContext === 'string' ? [message.metadata.evidenceContext] : []);
|
|
1043
|
+
const evidence = formatEvidenceContext(this.getEvidenceSnapshot(), { toolCallsInContext, renderedEarlier });
|
|
1044
|
+
if (evidence)
|
|
1045
|
+
evidenceTurn.metadata = { ...evidenceTurn.metadata, evidenceContext: evidence };
|
|
909
1046
|
}
|
|
910
1047
|
// Repair any orphaned tool_use blocks before building request
|
|
911
1048
|
if (this.config.pinTaskHeader) {
|
|
@@ -954,26 +1091,65 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
954
1091
|
});
|
|
955
1092
|
if (this.config.pinTaskHeader && this.taskHandoff) {
|
|
956
1093
|
const snapshot = this.taskHandoff.snapshot;
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1094
|
+
const currentRequest = [...contextMessages].reverse().find(message => message.role === 'user'
|
|
1095
|
+
&& !message.metadata?.synthetic && !message.metadata?.hostContext
|
|
1096
|
+
&& !message.metadata?.toolResult && !message.metadata?.compactionSummary);
|
|
1097
|
+
const compactedHead = resolvePromptPrefixId(contextMessages) ?? null;
|
|
1098
|
+
const prefixId = compactedHead ?? currentRequest?.id ?? null;
|
|
1099
|
+
const kept = this.taskHandoffTurn;
|
|
1100
|
+
if (!kept || (!kept.pinned && kept.prefixId !== prefixId)) {
|
|
1101
|
+
const content = formatTaskHandoffContext(snapshot);
|
|
1102
|
+
// The handoff sits ahead of all history, so new bytes there void the
|
|
1103
|
+
// prompt cache for the whole conversation. Every save moves the
|
|
1104
|
+
// checkpoint's as-of time and revision; only a checkpoint that says
|
|
1105
|
+
// something new, or compacted history, which voids the cache anyway,
|
|
1106
|
+
// replaces the row.
|
|
1107
|
+
if (kept && kept.compactedHead === compactedHead
|
|
1108
|
+
&& handoffSubstance(kept.content) === handoffSubstance(content)) {
|
|
1109
|
+
kept.prefixId = prefixId;
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
this.taskHandoffTurn = { id: `handoff_${snapshot.source.sessionId}_${snapshot.revision}`,
|
|
1113
|
+
content, capturedAt: snapshot.source.capturedAt, prefixId, compactedHead };
|
|
1114
|
+
}
|
|
965
1115
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
timestamp: new Date(snapshot.source.capturedAt),
|
|
1116
|
+
const handoff = this.taskHandoffTurn;
|
|
1117
|
+
contextMessages.unshift({
|
|
1118
|
+
id: handoff.id,
|
|
1119
|
+
role: 'user', content: handoff.content,
|
|
1120
|
+
timestamp: new Date(handoff.capturedAt),
|
|
972
1121
|
metadata: { synthetic: true, hostContext: true, preserveUserBoundary: true }
|
|
973
1122
|
});
|
|
974
1123
|
}
|
|
1124
|
+
if (this.config.pinTaskHeader && this.runtimeContext) {
|
|
1125
|
+
this.runtimeEnvironmentTurn ??= { id: 'runtime_environment', content: this.runtimeContext,
|
|
1126
|
+
capturedAt: (contextMessages[0]?.timestamp instanceof Date
|
|
1127
|
+
? contextMessages[0].timestamp : new Date()).toISOString() };
|
|
1128
|
+
contextMessages.unshift({ id: this.runtimeEnvironmentTurn.id, role: 'user',
|
|
1129
|
+
content: this.runtimeEnvironmentTurn.content,
|
|
1130
|
+
timestamp: new Date(this.runtimeEnvironmentTurn.capturedAt),
|
|
1131
|
+
metadata: { synthetic: true, hostContext: true, preserveUserBoundary: true } });
|
|
1132
|
+
}
|
|
1133
|
+
const responseRetry = this.responseRetry;
|
|
1134
|
+
this.responseRetry = null;
|
|
1135
|
+
if (responseRetry) {
|
|
1136
|
+
contextMessages.push({ id: `retry_note_${randomUUID()}`, role: 'user', content: responseRetry.note,
|
|
1137
|
+
timestamp: new Date(), metadata: { synthetic: true, hostContext: true } });
|
|
1138
|
+
}
|
|
1139
|
+
if (this.config.leadTurnNote) {
|
|
1140
|
+
// After every authored prompt, not only the latest, so earlier requests stay a prefix of later ones.
|
|
1141
|
+
for (let index = contextMessages.length - 1; index >= 0; index--) {
|
|
1142
|
+
const message = contextMessages[index];
|
|
1143
|
+
if (message.role !== 'user' || message.metadata?.synthetic || message.metadata?.hostContext
|
|
1144
|
+
|| message.metadata?.toolResult || message.metadata?.compactionSummary)
|
|
1145
|
+
continue;
|
|
1146
|
+
contextMessages.splice(index + 1, 0, { id: `lead_note_${message.id}`, role: 'user', content: this.config.leadTurnNote,
|
|
1147
|
+
timestamp: message.timestamp, metadata: { synthetic: true, hostContext: true, preserveUserBoundary: true } });
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
975
1150
|
const system = this.systemWithTaskHeader(messages);
|
|
976
|
-
const
|
|
1151
|
+
const baseDefinitions = getRequestToolDefinitions(availableTools, this.discoveredTools, this.config.deferToolSchemas !== false, this.alwaysLoadedToolNames);
|
|
1152
|
+
const tools = this.toolGroups?.requestDefinitions(baseDefinitions, availableTools) ?? baseDefinitions;
|
|
977
1153
|
this._nativeContextId = this.backend.preservesNativeHistory ? nativeHistoryContextId(system, tools) : undefined;
|
|
978
1154
|
return {
|
|
979
1155
|
model: this.config.model,
|
|
@@ -986,7 +1162,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
986
1162
|
// was warmed for. That is compaction, and only this layer can see it.
|
|
987
1163
|
promptPrefixId: resolvePromptPrefixId(repairedMessages),
|
|
988
1164
|
routePlan: this.config.routePlan,
|
|
989
|
-
codexEffort: this._codexEffort,
|
|
1165
|
+
codexEffort: responseRetry?.effort ?? this._codexEffort,
|
|
990
1166
|
codexFastMode: this._codexFastMode,
|
|
991
1167
|
};
|
|
992
1168
|
}
|
|
@@ -1043,7 +1219,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1043
1219
|
let text = '';
|
|
1044
1220
|
let reasoning = '';
|
|
1045
1221
|
const toolUses = [];
|
|
1222
|
+
const closedToolUses = new Set();
|
|
1046
1223
|
const nativeContent = [];
|
|
1224
|
+
let responseItems;
|
|
1047
1225
|
let usage;
|
|
1048
1226
|
let reportedUsage;
|
|
1049
1227
|
let costUsd;
|
|
@@ -1056,8 +1234,11 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1056
1234
|
// paints an empty "Zerg" row in the transcript. Hold it until a visible
|
|
1057
1235
|
// character shows up and ship it with that text, so no byte is dropped.
|
|
1058
1236
|
let pendingWhitespace = '';
|
|
1237
|
+
let streamStarted = false;
|
|
1238
|
+
let sawCompletion = false;
|
|
1059
1239
|
try {
|
|
1060
|
-
for await (const ev of this.backend.generateStream(request)) {
|
|
1240
|
+
for await (const ev of guardRunawayOutput(this.backend.generateStream(request))) {
|
|
1241
|
+
streamStarted = true;
|
|
1061
1242
|
if (signal?.aborted)
|
|
1062
1243
|
throw new AgentError('Cancelled', 'CANCELLED');
|
|
1063
1244
|
// Every stream event is a sign of life for callAPI's inactivity guard,
|
|
@@ -1066,6 +1247,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1066
1247
|
switch (ev.type) {
|
|
1067
1248
|
case 'heartbeat':
|
|
1068
1249
|
break;
|
|
1250
|
+
case 'response_items':
|
|
1251
|
+
responseItems = ev.items;
|
|
1252
|
+
break;
|
|
1069
1253
|
case 'content_block':
|
|
1070
1254
|
nativeContent.push(ev.block);
|
|
1071
1255
|
break;
|
|
@@ -1120,6 +1304,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1120
1304
|
break;
|
|
1121
1305
|
}
|
|
1122
1306
|
case 'tool_use_end':
|
|
1307
|
+
closedToolUses.add(ev.id);
|
|
1123
1308
|
break;
|
|
1124
1309
|
case 'usage': {
|
|
1125
1310
|
usage = ev.usage;
|
|
@@ -1144,34 +1329,49 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1144
1329
|
costUsd = ev.costUsd;
|
|
1145
1330
|
break;
|
|
1146
1331
|
case 'done':
|
|
1332
|
+
sawCompletion = true;
|
|
1147
1333
|
stopReason = ev.stopReason;
|
|
1148
1334
|
stopDetails = ev.stopDetails;
|
|
1149
1335
|
break;
|
|
1150
1336
|
}
|
|
1151
1337
|
}
|
|
1152
1338
|
}
|
|
1339
|
+
catch (error) {
|
|
1340
|
+
if (streamStarted && error instanceof Error
|
|
1341
|
+
&& !(error instanceof AgentError) && !(error instanceof RunawayOutputError)
|
|
1342
|
+
&& !(error instanceof NativeObservationLimitError)
|
|
1343
|
+
&& !isIncompleteStreamError(error) && !(error instanceof BackendHttpError)) {
|
|
1344
|
+
throw new IncompleteStreamError(error.message);
|
|
1345
|
+
}
|
|
1346
|
+
throw error;
|
|
1347
|
+
}
|
|
1153
1348
|
finally {
|
|
1154
1349
|
// Always close an opened stream so the mirror clears its cursor, even on
|
|
1155
1350
|
// abort/error mid-stream.
|
|
1156
1351
|
if (streamOpen)
|
|
1157
1352
|
this.emit({ type: 'stream_end' });
|
|
1158
1353
|
}
|
|
1354
|
+
if (!sawCompletion)
|
|
1355
|
+
throw new IncompleteStreamError();
|
|
1159
1356
|
const content = [];
|
|
1160
1357
|
if (text)
|
|
1161
1358
|
content.push({ type: 'text', text });
|
|
1162
|
-
for (const tu of toolUses) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
}
|
|
1359
|
+
for (const tu of isIncompleteModelResponse(stopReason) ? [] : toolUses) {
|
|
1360
|
+
if (nativeContent.some(block => block.type === 'tool_use' && block.id === tu.id))
|
|
1361
|
+
continue;
|
|
1362
|
+
if (!tu.inputJson.trim() && !closedToolUses.has(tu.id)) {
|
|
1363
|
+
throw new IncompleteStreamError(`Tool call ${tu.name} arrived with no arguments.`);
|
|
1364
|
+
}
|
|
1365
|
+
let input;
|
|
1366
|
+
try {
|
|
1367
|
+
input = tu.inputJson.trim() ? JSON.parse(tu.inputJson) : {};
|
|
1368
|
+
}
|
|
1369
|
+
catch {
|
|
1370
|
+
throw new IncompleteStreamError(`Tool call ${tu.name} arrived with incomplete arguments.`);
|
|
1171
1371
|
}
|
|
1172
1372
|
content.push({ type: 'tool_use', id: tu.id, name: tu.name, input });
|
|
1173
1373
|
}
|
|
1174
|
-
return { content: nativeContent.length > 0 ? nativeContent : content, stopReason,
|
|
1374
|
+
return { content: nativeContent.length > 0 ? nativeContent : content, stopReason, responseItems,
|
|
1175
1375
|
...(stopDetails ? { stopDetails } : {}), reasoning: reasoning || undefined, usage,
|
|
1176
1376
|
...(costUsd === undefined ? {} : { costUsd }) };
|
|
1177
1377
|
}
|
|
@@ -1250,6 +1450,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1250
1450
|
'submit_plan',
|
|
1251
1451
|
'plan_mode',
|
|
1252
1452
|
]);
|
|
1453
|
+
static SELF_RESOLVING_TOOLS = new Set([
|
|
1454
|
+
'ztc_command',
|
|
1455
|
+
]);
|
|
1253
1456
|
/**
|
|
1254
1457
|
* R7: the original task, pinned into request.system so it survives compaction
|
|
1255
1458
|
* (which only rewrites the message array, never request.system) and the rolling
|
|
@@ -1259,7 +1462,10 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1259
1462
|
* genuinely multi-task long-lived agents is deferred (plan A10).
|
|
1260
1463
|
*/
|
|
1261
1464
|
_taskHeader = null;
|
|
1465
|
+
runtimeContext = null;
|
|
1262
1466
|
taskHandoff = null;
|
|
1467
|
+
taskHandoffTurn = null;
|
|
1468
|
+
runtimeEnvironmentTurn = null;
|
|
1263
1469
|
/** Only a host-selected checkpoint may supply historical task context. */
|
|
1264
1470
|
setTaskHandoff(projection) {
|
|
1265
1471
|
const admitted = projection === null ? null : parseTaskHandoffProjection(projection);
|
|
@@ -1269,6 +1475,38 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1269
1475
|
throw new TypeError('Task handoff belongs to a different selected session');
|
|
1270
1476
|
}
|
|
1271
1477
|
this.taskHandoff = admitted;
|
|
1478
|
+
if (!admitted) {
|
|
1479
|
+
this.taskHandoffTurn = null;
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
if (this.taskHandoffTurn)
|
|
1483
|
+
return;
|
|
1484
|
+
this.taskHandoffTurn = { id: `handoff_${admitted.snapshot.source.sessionId}_${admitted.snapshot.revision}`,
|
|
1485
|
+
content: formatTaskHandoffContext(admitted.snapshot),
|
|
1486
|
+
capturedAt: admitted.snapshot.source.capturedAt, prefixId: null };
|
|
1487
|
+
}
|
|
1488
|
+
hostScaffoldMessages() {
|
|
1489
|
+
const rows = [];
|
|
1490
|
+
if (this.taskHandoffTurn)
|
|
1491
|
+
rows.push({ id: this.taskHandoffTurn.id,
|
|
1492
|
+
content: this.taskHandoffTurn.content, capturedAt: this.taskHandoffTurn.capturedAt });
|
|
1493
|
+
if (this.runtimeEnvironmentTurn)
|
|
1494
|
+
rows.push(this.runtimeEnvironmentTurn);
|
|
1495
|
+
return rows;
|
|
1496
|
+
}
|
|
1497
|
+
setHostScaffoldMessages(rows) {
|
|
1498
|
+
if (!rows?.length)
|
|
1499
|
+
return;
|
|
1500
|
+
for (const row of rows) {
|
|
1501
|
+
if (row.id.startsWith('handoff_')) {
|
|
1502
|
+
this.taskHandoffTurn = { id: row.id, content: row.content, capturedAt: row.capturedAt,
|
|
1503
|
+
prefixId: this.taskHandoffTurn?.prefixId ?? null, pinned: true };
|
|
1504
|
+
}
|
|
1505
|
+
else if (row.id === 'runtime_environment' && this.runtimeContext !== null
|
|
1506
|
+
&& runtimeFacts(row.content) === runtimeFacts(this.runtimeContext)) {
|
|
1507
|
+
this.runtimeEnvironmentTurn = { ...row };
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1272
1510
|
}
|
|
1273
1511
|
/**
|
|
1274
1512
|
* Drop the explicitly pinned task for the next conversation. Wired into the /clear-only path (clearTransientState), never into
|
|
@@ -1311,8 +1549,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1311
1549
|
}
|
|
1312
1550
|
systemWithTaskHeader(_messages) {
|
|
1313
1551
|
// Hosted chat owns its system prompt: no local execution facts and no pin.
|
|
1314
|
-
if (!this.config.pinTaskHeader)
|
|
1315
|
-
return this.config.systemPrompt;
|
|
1552
|
+
if (!this.config.pinTaskHeader) {
|
|
1553
|
+
return this.runtimeContext ? `${this.config.systemPrompt}\n\n${this.runtimeContext}` : this.config.systemPrompt;
|
|
1554
|
+
}
|
|
1316
1555
|
return pinnedTaskSystem(this.config.systemPrompt, this._taskHeader);
|
|
1317
1556
|
}
|
|
1318
1557
|
async persistToolCheckpoint(phase, toolCallId, messages, handler = this.toolCheckpoint) {
|
|
@@ -1462,7 +1701,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1462
1701
|
...(result.nativeContent ? { nativeContent: result.nativeContent, nativeModel: result.nativeModel, nativeContextId: result.nativeContextId } : {}),
|
|
1463
1702
|
timestamp: new Date(),
|
|
1464
1703
|
...(result.toolCalls.length > 0 ? { toolCalls: result.toolCalls } : {}),
|
|
1465
|
-
metadata: { ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(result.reasoning ? { reasoningContent: result.reasoning } : {}) },
|
|
1704
|
+
metadata: { ...(result.responseItems ? { openaiResponseItems: result.responseItems, openaiResponseModel: this.config.model } : {}), ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(result.reasoning ? { reasoningContent: result.reasoning } : {}) },
|
|
1466
1705
|
};
|
|
1467
1706
|
const receipt = await binding.driver.publish({
|
|
1468
1707
|
turn,
|
|
@@ -1505,6 +1744,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1505
1744
|
if (!this.hasApiKey()) {
|
|
1506
1745
|
throw new AgentError('No API key configured. Use /config key <key> to set one.', 'NO_API_KEY');
|
|
1507
1746
|
}
|
|
1747
|
+
const authored = [...messages].reverse().find(message => message.role === 'user' && !message.metadata?.synthetic
|
|
1748
|
+
&& !message.metadata?.hostContext && !message.metadata?.toolResult && !message.metadata?.compactionSummary);
|
|
1749
|
+
this.turnInstruction = typeof authored?.content === 'string' ? authored.content : this.turnInstruction;
|
|
1508
1750
|
for (const message of messages) {
|
|
1509
1751
|
if (message.role !== 'assistant')
|
|
1510
1752
|
continue;
|
|
@@ -1519,6 +1761,10 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1519
1761
|
// Each turn gets its own auto-continue budget; a long-running Agent must
|
|
1520
1762
|
// not inherit one spent by the previous turn.
|
|
1521
1763
|
this._consecutiveAutoContinues = 0;
|
|
1764
|
+
this._turnAutoContinues = 0;
|
|
1765
|
+
this._turnToolBatches = 0;
|
|
1766
|
+
this._turnCommandsRun.clear();
|
|
1767
|
+
this._turnCheckAsked = false;
|
|
1522
1768
|
let finalContent = '';
|
|
1523
1769
|
// Provider-opaque reasoning trace for the turn the caller will persist.
|
|
1524
1770
|
// Reasoning models (Kimi K3, DeepSeek) expect the assistant message replayed
|
|
@@ -1526,6 +1772,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1526
1772
|
// only inside one run() and every later user turn sends a stripped history.
|
|
1527
1773
|
let finalReasoning;
|
|
1528
1774
|
let finalNativeContent;
|
|
1775
|
+
let finalResponseItems;
|
|
1529
1776
|
let lastToolTurnText = '';
|
|
1530
1777
|
let totalUsage = null;
|
|
1531
1778
|
let runError = null;
|
|
@@ -1534,6 +1781,10 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1534
1781
|
// Falling through the `while` condition means the model still wanted to
|
|
1535
1782
|
// continue but ran out of iterations — a silent stall today (C5/F8).
|
|
1536
1783
|
let stopReason = 'max_iterations';
|
|
1784
|
+
let outputLimitRetried = false;
|
|
1785
|
+
let runawayRetried = false;
|
|
1786
|
+
let midTurnMessagesSinceCompaction = 0;
|
|
1787
|
+
let midTurnLastFreedTokens;
|
|
1537
1788
|
// R5 progress-delta guard (shared loop_policy, identical to SubAgent.run so
|
|
1538
1789
|
// the two loops cannot drift): flags a tool call whose byte-identical input
|
|
1539
1790
|
// reproduced a byte-identical result as non-progressing (F8 churn / F1
|
|
@@ -1554,6 +1805,24 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1554
1805
|
const availability = await Promise.all(this.config.tools.map(tool => tool.isAvailable?.({ cwd: this._cwd }) ?? true));
|
|
1555
1806
|
const availableTools = this.config.tools.filter((_tool, index) => availability[index]);
|
|
1556
1807
|
await this.refreshVerificationCoverage();
|
|
1808
|
+
// Background workers' reports join the conversation once, ahead of the request that follows them.
|
|
1809
|
+
const reports = this.backgroundWorkers.takeReady();
|
|
1810
|
+
if (reports.length > 0) {
|
|
1811
|
+
messages.push({ id: `worker_reports_${randomUUID()}`, role: 'user', content: formatWorkerReports(reports),
|
|
1812
|
+
timestamp: new Date(), metadata: { synthetic: true, hostContext: true } });
|
|
1813
|
+
}
|
|
1814
|
+
// A lead busy with its own work still gets each progress check on its running workers.
|
|
1815
|
+
const check = this.backgroundWorkers.takeDueCheck();
|
|
1816
|
+
if (check) {
|
|
1817
|
+
messages.push({ id: `worker_check_${randomUUID()}`, role: 'user', content: check, timestamp: new Date(),
|
|
1818
|
+
metadata: { synthetic: true, hostContext: true } });
|
|
1819
|
+
}
|
|
1820
|
+
// A lead knows what to hand off only after exploring, so one that has worked alone is asked once.
|
|
1821
|
+
const staffing = this.config.leadStaffingNote;
|
|
1822
|
+
if (staffing && iterations === staffing.afterSteps + 1 && !allToolCalls.some(call => call.name === 'delegate_task')) {
|
|
1823
|
+
messages.push({ id: `lead_staffing_${randomUUID()}`, role: 'user', content: staffing.content, timestamp: new Date(),
|
|
1824
|
+
metadata: { synthetic: true, hostContext: true } });
|
|
1825
|
+
}
|
|
1557
1826
|
const request = this.buildRequest(messages, availableTools);
|
|
1558
1827
|
request.signal = signal;
|
|
1559
1828
|
request.onMetrics = metrics => {
|
|
@@ -1602,6 +1871,17 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1602
1871
|
else
|
|
1603
1872
|
this.retainUsageReceipt({ ...identity, observedAt: new Date().toISOString(),
|
|
1604
1873
|
source: 'unavailable', usage: null, costUsd: null });
|
|
1874
|
+
// A runaway response was stopped while streaming and is never accepted.
|
|
1875
|
+
// Partial tool calls in it never run. Retry once per turn with a note.
|
|
1876
|
+
if (error instanceof RunawayOutputError) {
|
|
1877
|
+
if (runawayRetried)
|
|
1878
|
+
throw new AgentError(repeatedRunawayMessage(error), RUNAWAY_OUTPUT_CODE);
|
|
1879
|
+
runawayRetried = true;
|
|
1880
|
+
this.responseRetry = { note: RUNAWAY_OUTPUT_RETRY_NOTE, effort: outputLimitRetryEffort(this.backend.getModelCapabilities?.(request.model)?.reasoning?.choices, this._codexEffort) };
|
|
1881
|
+
this.emit({ type: 'api_retry', attempt: 1, maxAttempts: 1, delay: 0, phase: 'retry', elapsedMs: 0,
|
|
1882
|
+
reason: 'The response kept repeating the same text and was stopped; retrying' });
|
|
1883
|
+
continue;
|
|
1884
|
+
}
|
|
1605
1885
|
throw error;
|
|
1606
1886
|
}
|
|
1607
1887
|
// Retain returned accounting before a later cancellation/checkpoint guard can discard the answer.
|
|
@@ -1651,11 +1931,23 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1651
1931
|
// incomplete tool payload. The fixed error deliberately excludes model
|
|
1652
1932
|
// output so callers can log it without reflecting sensitive content.
|
|
1653
1933
|
if (isIncompleteModelResponse(response.stopReason)) {
|
|
1934
|
+
// A response that used its whole output limit reasoning, before any
|
|
1935
|
+
// visible answer, gets one retry per turn. Partial tool calls in it are
|
|
1936
|
+
// never executed; a response that already showed text is not repeated.
|
|
1937
|
+
if (!outputLimitRetried && isOutputLimitStop(response.stopReason, request.maxTokens, response.usage?.outputTokens)
|
|
1938
|
+
&& !response.content.some(block => this.isTextBlock(block) && block.text.trim())) {
|
|
1939
|
+
outputLimitRetried = true;
|
|
1940
|
+
this.responseRetry = { note: OUTPUT_LIMIT_RETRY_NOTE, effort: outputLimitRetryEffort(this.backend.getModelCapabilities?.(request.model)?.reasoning?.choices, this._codexEffort) };
|
|
1941
|
+
this.emit({ type: 'api_retry', attempt: 1, maxAttempts: 1, delay: 0, phase: 'retry', elapsedMs: 0,
|
|
1942
|
+
reason: 'The response reached the output limit while reasoning; retrying in smaller steps' });
|
|
1943
|
+
continue;
|
|
1944
|
+
}
|
|
1654
1945
|
throw new AgentError(incompleteModelResponseMessage(response.stopReason, request.maxTokens, response.usage?.outputTokens), INCOMPLETE_MODEL_RESPONSE_CODE);
|
|
1655
1946
|
}
|
|
1656
1947
|
if (response.stopReason === 'refusal') {
|
|
1657
1948
|
throw new AgentError('The model declined this request.', 'MODEL_REFUSAL');
|
|
1658
1949
|
}
|
|
1950
|
+
finalResponseItems = response.responseItems;
|
|
1659
1951
|
// Check for tool use
|
|
1660
1952
|
const requestedToolBlocks = response.content.filter(this.isToolUseBlock);
|
|
1661
1953
|
const requestedIds = new Set();
|
|
@@ -1733,7 +2025,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1733
2025
|
const answer = {
|
|
1734
2026
|
id: `assistant_${Date.now()}_${iterations}`, role: 'assistant', content: iterationText, timestamp: new Date(),
|
|
1735
2027
|
turn: requestUsage?.getTurn?.(),
|
|
1736
|
-
metadata: { ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? { reasoningContent: response.reasoning } : {}) },
|
|
2028
|
+
metadata: { ...(response.responseItems ? { openaiResponseItems: response.responseItems, openaiResponseModel: this.config.model } : {}), ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? { reasoningContent: response.reasoning } : {}) },
|
|
1737
2029
|
};
|
|
1738
2030
|
messages.push(answer);
|
|
1739
2031
|
turnMessages.push(answer);
|
|
@@ -1770,23 +2062,75 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1770
2062
|
}
|
|
1771
2063
|
this.emit({ type: 'auto_continue', reason });
|
|
1772
2064
|
// Add the assistant's response
|
|
1773
|
-
|
|
2065
|
+
const autoContinueAnswer = {
|
|
1774
2066
|
id: `assistant_${Date.now()}`,
|
|
1775
2067
|
role: 'assistant',
|
|
1776
2068
|
content: iterationText,
|
|
1777
2069
|
...(this.backend.preservesNativeHistory ? { nativeContent: structuredClone(response.content), nativeModel: this.config.model, nativeContextId: this._nativeContextId } : {}),
|
|
1778
2070
|
timestamp: new Date(),
|
|
1779
|
-
metadata: { ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? { reasoningContent: response.reasoning } : {}) },
|
|
1780
|
-
}
|
|
2071
|
+
metadata: { ...(response.responseItems ? { openaiResponseItems: response.responseItems, openaiResponseModel: this.config.model } : {}), ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? { reasoningContent: response.reasoning } : {}) },
|
|
2072
|
+
};
|
|
2073
|
+
messages.push(autoContinueAnswer);
|
|
2074
|
+
turnMessages.push(autoContinueAnswer);
|
|
1781
2075
|
// Add auto-continue prompt as user message
|
|
1782
|
-
|
|
2076
|
+
const autoContinuePrompt = {
|
|
1783
2077
|
id: `auto_continue_${Date.now()}`,
|
|
1784
2078
|
role: 'user',
|
|
1785
2079
|
content: continueMsg,
|
|
1786
|
-
timestamp: new Date()
|
|
1787
|
-
|
|
2080
|
+
timestamp: new Date(),
|
|
2081
|
+
metadata: { synthetic: true, autoContinue: true },
|
|
2082
|
+
};
|
|
2083
|
+
messages.push(autoContinuePrompt);
|
|
2084
|
+
turnMessages.push(autoContinuePrompt);
|
|
2085
|
+
continue; // Don't break, keep looping
|
|
2086
|
+
}
|
|
2087
|
+
if (!this.remoteResourceSession
|
|
2088
|
+
&& needsCompletionCheck({ usedTools: this._turnToolBatches > 0, hasPendingToolCall: false })
|
|
2089
|
+
&& completionCheckDue({ autoContinue: this._autoContinue && this.config.completionCheck === true, toolBatches: this._turnToolBatches,
|
|
2090
|
+
changedState: this._turnToolChangedState,
|
|
2091
|
+
askedSinceProgress: this._turnCheckAsked,
|
|
2092
|
+
turnChecks: this._turnAutoContinues, hardCap: this.config.maxConsecutiveAutoContinues,
|
|
2093
|
+
reply: iterationText })) {
|
|
2094
|
+
const hardCap = this.config.maxConsecutiveAutoContinues;
|
|
2095
|
+
this._turnAutoContinues++;
|
|
2096
|
+
this._turnCheckAsked = this._turnAutoContinues < hardCap;
|
|
2097
|
+
this._turnToolBatches = 0;
|
|
2098
|
+
const acTodos = getLatestTodos();
|
|
2099
|
+
const incomplete = acTodos.filter(t => t.status !== 'completed');
|
|
2100
|
+
const remaining = incomplete.length > 0
|
|
2101
|
+
? ` You still have ${incomplete.length} incomplete task(s): ${incomplete.map(t => t.content).join(', ')}.`
|
|
2102
|
+
: '';
|
|
2103
|
+
const continueMsg = 'If any part of this task is still unfinished, continue with the next step now. '
|
|
2104
|
+
+ 'Otherwise, reply that the work is complete, or state exactly what you need from the user.'
|
|
2105
|
+
+ remaining;
|
|
2106
|
+
const reason = 'completion check';
|
|
2107
|
+
this.emit({ type: 'auto_continue', reason });
|
|
2108
|
+
// Add the assistant's response
|
|
2109
|
+
const completionAnswer = {
|
|
2110
|
+
id: `assistant_${Date.now()}`,
|
|
2111
|
+
role: 'assistant',
|
|
2112
|
+
turn: requestUsage?.getTurn?.(),
|
|
2113
|
+
content: iterationText,
|
|
2114
|
+
...(this.backend.preservesNativeHistory ? { nativeContent: structuredClone(response.content), nativeModel: this.config.model, nativeContextId: this._nativeContextId } : {}),
|
|
2115
|
+
timestamp: new Date(),
|
|
2116
|
+
metadata: { ...(response.responseItems ? { openaiResponseItems: response.responseItems, openaiResponseModel: this.config.model } : {}), ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? { reasoningContent: response.reasoning } : {}) },
|
|
2117
|
+
};
|
|
2118
|
+
messages.push(completionAnswer);
|
|
2119
|
+
turnMessages.push(completionAnswer);
|
|
2120
|
+
// Add auto-continue prompt as user message
|
|
2121
|
+
const completionPrompt = {
|
|
2122
|
+
id: `auto_continue_${Date.now()}`,
|
|
2123
|
+
role: 'user',
|
|
2124
|
+
content: continueMsg,
|
|
2125
|
+
turn: requestUsage?.getTurn?.(),
|
|
2126
|
+
timestamp: new Date(),
|
|
2127
|
+
metadata: { synthetic: true, autoContinue: true },
|
|
2128
|
+
};
|
|
2129
|
+
messages.push(completionPrompt);
|
|
2130
|
+
turnMessages.push(completionPrompt);
|
|
1788
2131
|
continue; // Don't break, keep looping
|
|
1789
2132
|
}
|
|
2133
|
+
this._turnToolBatches = 0;
|
|
1790
2134
|
stopReason = 'complete';
|
|
1791
2135
|
break;
|
|
1792
2136
|
}
|
|
@@ -1806,7 +2150,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1806
2150
|
: response.content.filter(this.isTextBlock).map(block => block.text).join('\n') || '[Using tools...]',
|
|
1807
2151
|
...(this.backend.preservesNativeHistory ? { nativeContent: structuredClone(response.content), nativeModel: this.config.model, nativeContextId: this._nativeContextId } : {}),
|
|
1808
2152
|
timestamp: new Date(), toolCalls: batchCalls,
|
|
1809
|
-
metadata: { toolCheckpoint: true, ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? this.remoteResourceSession
|
|
2153
|
+
metadata: { ...(response.responseItems ? { openaiResponseItems: response.responseItems, openaiResponseModel: this.config.model } : {}), toolCheckpoint: true, ...(this.config.runtimeFacts.mode === 'plan' ? { planMode: true } : {}), ...(response.reasoning ? this.remoteResourceSession
|
|
1810
2154
|
? { providerReasoning: response.reasoning } : { reasoningContent: response.reasoning } : {}) },
|
|
1811
2155
|
};
|
|
1812
2156
|
messages.push(toolUseMessage);
|
|
@@ -1814,7 +2158,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1814
2158
|
allToolCalls.push(...batchCalls);
|
|
1815
2159
|
const toolResultMessage = {
|
|
1816
2160
|
id: `tool_${randomUUID()}`, role: 'user', content: '[]', timestamp: new Date(),
|
|
1817
|
-
metadata: { toolResult: true, toolCheckpoint: true },
|
|
2161
|
+
metadata: { toolResult: true, toolCheckpoint: true, preserveUserBoundary: true },
|
|
1818
2162
|
};
|
|
1819
2163
|
const completedResults = new Map();
|
|
1820
2164
|
const retainToolResult = async (toolCall, rawContent, guardedContent, managedCommand, contentTruncated = false, verificationReceipt, verifierDecision, benchmarkComparisonDecision) => {
|
|
@@ -1832,6 +2176,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1832
2176
|
if (!turnMessages.some(message => message.id === toolResultMessage.id)) {
|
|
1833
2177
|
messages.push(toolResultMessage);
|
|
1834
2178
|
turnMessages.push(toolResultMessage);
|
|
2179
|
+
midTurnMessagesSinceCompaction += 1;
|
|
1835
2180
|
}
|
|
1836
2181
|
await this.refreshVerificationCoverage();
|
|
1837
2182
|
await this.persistToolCheckpoint('terminal', toolCall.id, turnMessages, toolCheckpoint);
|
|
@@ -1920,18 +2265,23 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1920
2265
|
return recordToolError(toolBlock, toolCall, 'finish_task must be the only tool call; observe other results before completing the task.');
|
|
1921
2266
|
}
|
|
1922
2267
|
// Selector intent does not prove visibility: the encoder may cap or
|
|
1923
|
-
// compress the result. Acknowledge only
|
|
1924
|
-
//
|
|
1925
|
-
//
|
|
2268
|
+
// compress the result. Acknowledge only when the request holds the
|
|
2269
|
+
// whole stored result, as the model reads it (tool_result_presentation.ts),
|
|
2270
|
+
// and the stored result is within the historical stability limit.
|
|
2271
|
+
// Larger current results become previews after this recall is appended.
|
|
1926
2272
|
// A hook dispatcher still owns each invocation's admission and outcome.
|
|
1927
2273
|
const innerId = recallInnerIdOf(toolBlock);
|
|
1928
|
-
|
|
2274
|
+
const stored = innerId === null ? undefined : this.toolResponseStore.cachedContent(innerId);
|
|
2275
|
+
const innerName = request.messages.flatMap(message => typeof message.content === 'string' ? [] : message.content)
|
|
2276
|
+
.find((block) => block.type === 'tool_use' && block.id === innerId)?.name ?? '';
|
|
2277
|
+
if (!this.hooks && innerId !== null && stored !== undefined &&
|
|
1929
2278
|
toolBlock.input.cursor === undefined && toolBlock.input.max_bytes === undefined &&
|
|
2279
|
+
(toolBlock.input.part === undefined || toolBlock.input.part === 'result') &&
|
|
1930
2280
|
this.toolResponseStore.willInlineNextRender(innerId) &&
|
|
1931
|
-
|
|
2281
|
+
stored.length <= STABLE_RESULT_LIMIT &&
|
|
2282
|
+
createHash('sha256').update(stored).digest('hex') === this.toolResponseStore.getMeta(innerId)?.result_sha256 &&
|
|
1932
2283
|
request.messages.some(message => typeof message.content !== 'string' && message.content.some(block => block.type === 'tool_result' && block.tool_use_id === innerId &&
|
|
1933
|
-
|
|
1934
|
-
createHash('sha256').update(block.content).digest('hex') === this.toolResponseStore.getMeta(innerId)?.result_sha256))) {
|
|
2284
|
+
block.content === presentToolResult(innerName, stored)))) {
|
|
1935
2285
|
const ack = JSON.stringify({
|
|
1936
2286
|
ok: true,
|
|
1937
2287
|
tool_use_id: innerId,
|
|
@@ -1964,6 +2314,8 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1964
2314
|
signal,
|
|
1965
2315
|
toolResponseStore: this.toolResponseStore,
|
|
1966
2316
|
discoveredTools: this.discoveredTools,
|
|
2317
|
+
backgroundWorkers: this.backgroundWorkers,
|
|
2318
|
+
leadBrief: { task: this.turnInstruction, environment: this.runtimeContext ?? undefined },
|
|
1967
2319
|
availableTools: this.config.tools,
|
|
1968
2320
|
subprocessEnv: this.copySubprocessEnv(),
|
|
1969
2321
|
commandPolicy: this.commandPolicy,
|
|
@@ -1995,6 +2347,8 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
1995
2347
|
signal,
|
|
1996
2348
|
toolResponseStore: this.toolResponseStore,
|
|
1997
2349
|
discoveredTools: this.discoveredTools,
|
|
2350
|
+
backgroundWorkers: this.backgroundWorkers,
|
|
2351
|
+
leadBrief: { task: this.turnInstruction, environment: this.runtimeContext ?? undefined },
|
|
1998
2352
|
availableTools: this.config.tools,
|
|
1999
2353
|
subprocessEnv: this.copySubprocessEnv(),
|
|
2000
2354
|
commandPolicy: this.commandPolicy,
|
|
@@ -2028,9 +2382,26 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2028
2382
|
}
|
|
2029
2383
|
}, result => result.toolCall.status === 'error' || result.managedCommand?.result.status === 'running'
|
|
2030
2384
|
|| commandStillRunning(result.toolResult.content), signal, exclusiveTransitionId);
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2385
|
+
const changedState = combined.every(result => result.toolCall.status === 'complete' && !result.toolResult.is_error)
|
|
2386
|
+
&& combined.some(result => {
|
|
2387
|
+
const tool = this.config.tools.find(candidate => candidate.definition.name === result.toolCall.name);
|
|
2388
|
+
if (tool === undefined || resolveToolEffect(tool) === 'read')
|
|
2389
|
+
return false;
|
|
2390
|
+
const command = typeof result.toolCall.args?.command === 'string' ? result.toolCall.args.command : undefined;
|
|
2391
|
+
if (command === undefined)
|
|
2392
|
+
return true;
|
|
2393
|
+
if (this._turnCommandsRun.has(command))
|
|
2394
|
+
return false;
|
|
2395
|
+
this._turnCommandsRun.add(command);
|
|
2396
|
+
return true;
|
|
2397
|
+
});
|
|
2398
|
+
this._turnToolChangedState = changedState;
|
|
2399
|
+
if (changedState) {
|
|
2400
|
+
this._consecutiveAutoContinues = 0;
|
|
2401
|
+
this._turnCheckAsked = false;
|
|
2402
|
+
}
|
|
2403
|
+
if (changedState)
|
|
2404
|
+
this._turnToolBatches += 1;
|
|
2034
2405
|
// Add assistant message with tool use
|
|
2035
2406
|
const textContent = this.remoteResourceSession
|
|
2036
2407
|
? combined.filter(result => result.toolCall.name === 'remote_resource' && result.toolCall.status === 'complete')
|
|
@@ -2088,10 +2459,6 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2088
2459
|
break;
|
|
2089
2460
|
}
|
|
2090
2461
|
}
|
|
2091
|
-
// Break the loop for interactive tools (ask_user, submit_plan) — the TUI
|
|
2092
|
-
// needs control to show the user interaction widget. Without this break,
|
|
2093
|
-
// auto-continue (shouldContinue) can keep looping if there are pending todos.
|
|
2094
|
-
// Only break if the interactive tool actually succeeded (not an error).
|
|
2095
2462
|
const hasSuccessfulInteractiveTool = toolUseBlocks.some(tb => {
|
|
2096
2463
|
if (!Agent.TURN_ENDING_TOOLS.has(tb.name))
|
|
2097
2464
|
return false;
|
|
@@ -2102,6 +2469,14 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2102
2469
|
stopReason = 'interactive';
|
|
2103
2470
|
break;
|
|
2104
2471
|
}
|
|
2472
|
+
const resolvedTurn = toolUseBlocks.some(tb => {
|
|
2473
|
+
if (!Agent.SELF_RESOLVING_TOOLS.has(tb.name))
|
|
2474
|
+
return false;
|
|
2475
|
+
const result = completedResults.get(tb.id);
|
|
2476
|
+
return result ? !result.content.startsWith('Error:') : false;
|
|
2477
|
+
});
|
|
2478
|
+
if (resolvedTurn)
|
|
2479
|
+
this._turnToolBatches = 0;
|
|
2105
2480
|
// A busy user message belongs after the completed tool-use/result pair
|
|
2106
2481
|
// and before the next inference. Keep terminal tools and exhausted turns
|
|
2107
2482
|
// on the normal next-turn path because no model request remains here.
|
|
@@ -2155,6 +2530,35 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2155
2530
|
throw new AgentError('Cancelled', 'CANCELLED');
|
|
2156
2531
|
}
|
|
2157
2532
|
}
|
|
2533
|
+
if (this.onMidTurnCompact && shouldCompactMidTurn({
|
|
2534
|
+
usedTokens: contextTokens > 0 ? contextTokens : estimateConversationTokens(messages),
|
|
2535
|
+
windowTokens: getContextWindowSize(this.config.model, this.midTurnCompactWindow !== undefined ? this.midTurnCompactWindow : usage.contextWindow),
|
|
2536
|
+
thresholdPercent: this.midTurnCompactThresholdPercent ?? 90,
|
|
2537
|
+
tokenBudget: this.midTurnCompactTokenBudget,
|
|
2538
|
+
reservedOutputTokens: clampCompletionTokens(this.config.model, this.config.maxTokens
|
|
2539
|
+
?? this.backend.getModelCapabilities?.(this.config.model)?.max_output_tokens),
|
|
2540
|
+
messagesSinceLastCompaction: midTurnMessagesSinceCompaction,
|
|
2541
|
+
lastFreedTokens: midTurnLastFreedTokens,
|
|
2542
|
+
enabled: true,
|
|
2543
|
+
})) {
|
|
2544
|
+
try {
|
|
2545
|
+
const before = estimateConversationTokens(messages);
|
|
2546
|
+
const compacted = await this.onMidTurnCompact({ messages: [...messages], usedTokens: contextTokens, windowTokens: usage.contextWindow, signal });
|
|
2547
|
+
if (compacted && compacted.length > 0) {
|
|
2548
|
+
const after = estimateConversationTokens(compacted);
|
|
2549
|
+
messages.length = 0;
|
|
2550
|
+
messages.push(...compacted);
|
|
2551
|
+
turnMessages.length = 0;
|
|
2552
|
+
turnMessages.push(...compacted);
|
|
2553
|
+
midTurnLastFreedTokens = before - after;
|
|
2554
|
+
midTurnMessagesSinceCompaction = 0;
|
|
2555
|
+
this.emit({ type: 'history_checkpoint', messages: [...turnMessages], replacesHistory: true });
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
catch (error) {
|
|
2559
|
+
this.emit({ type: 'error', error: `Mid-turn compaction failed: ${error.message}` });
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2158
2562
|
}
|
|
2159
2563
|
catch (err) {
|
|
2160
2564
|
const error = err.message;
|
|
@@ -2179,6 +2583,8 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2179
2583
|
throw err;
|
|
2180
2584
|
}
|
|
2181
2585
|
finally {
|
|
2586
|
+
// Workers still running when the run ends have no lead left to read their reports.
|
|
2587
|
+
this.backgroundWorkers.stopAll();
|
|
2182
2588
|
// Stop fires on every exit path — clean completion, cancel, API error,
|
|
2183
2589
|
// and exhausted maxIterations. Without this, any error in the run loop
|
|
2184
2590
|
// silently skipped Stop, leaving teardown hooks (e.g. `notify me when
|
|
@@ -2208,6 +2614,8 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2208
2614
|
usage: totalUsage || undefined,
|
|
2209
2615
|
stopReason,
|
|
2210
2616
|
...(finalReasoning ? { reasoning: finalReasoning } : {}),
|
|
2617
|
+
responseItems: finalResponseItems,
|
|
2618
|
+
...(finalResponseItems ? { nativeModel: this.config.model } : {}),
|
|
2211
2619
|
...(finalNativeContent ? { nativeContent: finalNativeContent, nativeModel: this.config.model, nativeContextId: this._nativeContextId } : {}),
|
|
2212
2620
|
turnMessages,
|
|
2213
2621
|
};
|
|
@@ -2295,7 +2703,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2295
2703
|
};
|
|
2296
2704
|
const toolResultMessage = {
|
|
2297
2705
|
id: `tool_${randomUUID()}`, role: 'user', content: '[]', timestamp: new Date(),
|
|
2298
|
-
metadata: { toolResult: true, toolCheckpoint: true },
|
|
2706
|
+
metadata: { toolResult: true, toolCheckpoint: true, preserveUserBoundary: true },
|
|
2299
2707
|
};
|
|
2300
2708
|
owner.messages.push(toolUseMessage);
|
|
2301
2709
|
owner.turnMessages.push(toolUseMessage);
|
|
@@ -2316,6 +2724,8 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2316
2724
|
onUsage: options.onUsage,
|
|
2317
2725
|
toolResponseStore: this.toolResponseStore,
|
|
2318
2726
|
discoveredTools: this.discoveredTools,
|
|
2727
|
+
backgroundWorkers: this.backgroundWorkers,
|
|
2728
|
+
leadBrief: { task: this.turnInstruction, environment: this.runtimeContext ?? undefined },
|
|
2319
2729
|
availableTools: this.config.tools,
|
|
2320
2730
|
subprocessEnv: this.copySubprocessEnv(),
|
|
2321
2731
|
commandPolicy: this.commandPolicy,
|
|
@@ -2450,7 +2860,9 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2450
2860
|
const useStream = process.env.ZTC_NO_STREAM !== '1' && !this.backend.streamsSyntheticallyFor?.(request);
|
|
2451
2861
|
let answerOutputEmitted = false;
|
|
2452
2862
|
let effectObserved = false;
|
|
2863
|
+
let freshTurnRetried = false;
|
|
2453
2864
|
let recoveryStartedAt;
|
|
2865
|
+
let rateLimitedAttempts = 0;
|
|
2454
2866
|
let lastReason = 'Server temporarily unavailable';
|
|
2455
2867
|
const canRegenerate = () => this.backend.allowsRequestRetryAfterFailure?.(request) !== false;
|
|
2456
2868
|
const returned = (response) => { onReturnedResponse?.(response); return response; };
|
|
@@ -2467,6 +2879,7 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2467
2879
|
const attemptController = new AbortController();
|
|
2468
2880
|
let providerAttemptActive = true;
|
|
2469
2881
|
let timedOut = false;
|
|
2882
|
+
let streamingAttempt = useStream;
|
|
2470
2883
|
let removeAbortListener;
|
|
2471
2884
|
// Inactivity guard, not a total-duration cap: harness-owning backends
|
|
2472
2885
|
// (Codex App Server) run their whole tool loop inside ONE request, so a
|
|
@@ -2569,11 +2982,14 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2569
2982
|
// attempt — never regress a turn just because generateStream can't
|
|
2570
2983
|
// serve this request.
|
|
2571
2984
|
if (this.backend.allowsBufferedFallbackAfterStreamFailure?.(guardedRequest) === false
|
|
2985
|
+
|| isIncompleteStreamError(streamErr)
|
|
2572
2986
|
|| !canRegenerate() || effectObserved || answerOutputEmitted || timedOut || signal?.aborted
|
|
2987
|
+
|| streamErr instanceof RunawayOutputError
|
|
2573
2988
|
|| (streamErr instanceof AgentError && streamErr.code === 'CANCELLED')) {
|
|
2574
2989
|
throw streamErr;
|
|
2575
2990
|
}
|
|
2576
2991
|
this._lastResponseStreamed = false;
|
|
2992
|
+
streamingAttempt = false;
|
|
2577
2993
|
return await Promise.race([
|
|
2578
2994
|
this.backend.generate(guardedRequest).then(response => {
|
|
2579
2995
|
if (response.usage)
|
|
@@ -2603,24 +3019,46 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2603
3019
|
this.nativeEvidenceFailure ??= new AgentError(err.message, 'NATIVE_OBSERVATION_LIMIT');
|
|
2604
3020
|
throw this.nativeEvidenceFailure;
|
|
2605
3021
|
}
|
|
3022
|
+
// Router keeps producing a turn after the client leaves, up to the model's
|
|
3023
|
+
// output limit: stop reading and stop generation for every abandoned one.
|
|
3024
|
+
if (err instanceof RunawayOutputError || timedOut || signal?.aborted
|
|
3025
|
+
|| (err instanceof AgentError && err.code === 'CANCELLED')) {
|
|
3026
|
+
attemptController.abort();
|
|
3027
|
+
void this.backend.cancelTurn?.(guardedRequest).catch(() => undefined);
|
|
3028
|
+
}
|
|
2606
3029
|
if (err instanceof AgentError && err.code === 'CANCELLED') {
|
|
2607
3030
|
throw err;
|
|
2608
3031
|
}
|
|
2609
3032
|
if (signal?.aborted) {
|
|
2610
3033
|
throw new AgentError('Cancelled', 'CANCELLED');
|
|
2611
3034
|
}
|
|
3035
|
+
if (err instanceof RunawayOutputError)
|
|
3036
|
+
throw err;
|
|
2612
3037
|
const error = err;
|
|
2613
|
-
if (timedOut) {
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
if (effectObserved || !canRegenerate() || useStream && answerOutputEmitted) {
|
|
3038
|
+
if (effectObserved || !canRegenerate() || timedOut && !streamingAttempt) {
|
|
3039
|
+
if (isIncompleteStreamError(error)) {
|
|
3040
|
+
throw new AgentError(INCOMPLETE_MODEL_RESPONSE_MESSAGE, INCOMPLETE_MODEL_RESPONSE_CODE);
|
|
3041
|
+
}
|
|
3042
|
+
if (timedOut) {
|
|
3043
|
+
throw new AgentError('LLM request timed out. Try again, reduce tool output, or raise ZTC_LLM_REQUEST_TIMEOUT_MS if this model needs longer.', 'API_TIMEOUT');
|
|
3044
|
+
}
|
|
2621
3045
|
throw new AgentError(this.parseAPIError(error).reason, 'API_ERROR');
|
|
2622
3046
|
}
|
|
2623
|
-
|
|
3047
|
+
if (useStream && answerOutputEmitted) {
|
|
3048
|
+
this.emit({ type: 'stream_reset' });
|
|
3049
|
+
answerOutputEmitted = false;
|
|
3050
|
+
}
|
|
3051
|
+
const stalled = timedOut;
|
|
3052
|
+
const { retryable, reason, kind } = stalled
|
|
3053
|
+
? { retryable: true, reason: 'LLM request stalled without activity', kind: undefined }
|
|
3054
|
+
: this.parseAPIError(error);
|
|
3055
|
+
// The Router lost this turn's producer before any answer text: nothing ran and nothing was
|
|
3056
|
+
// shown, so ask once more under a new turn id (resuming the lost turn cannot work).
|
|
3057
|
+
if (kind === 'stream_lost' && !isIncompleteStreamError(error) && attempt < maxAttempts && !freshTurnRetried && request.transportTurnId !== undefined) {
|
|
3058
|
+
freshTurnRetried = true;
|
|
3059
|
+
request = { ...request, transportTurnId: randomUUID() };
|
|
3060
|
+
continue;
|
|
3061
|
+
}
|
|
2624
3062
|
// Transport failures deliberately fall through to the normal retryable
|
|
2625
3063
|
// path even when the backend owns transport reconnects. The backend has
|
|
2626
3064
|
// already spent its bounded reconnect budget by the time control reaches
|
|
@@ -2628,19 +3066,34 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2628
3066
|
// attempt resumes the same Router-buffered turn instead of appending a
|
|
2629
3067
|
// duplicate. Only a failure AFTER answer text is unrecoverable, and the
|
|
2630
3068
|
// answerOutputEmitted guard above already handled that case.
|
|
2631
|
-
if (!retryable || maxAttempts === 1
|
|
3069
|
+
if (!retryable || maxAttempts === 1
|
|
3070
|
+
|| attempt >= maxAttempts && (recoveryWindowMs === 0 || stalled || isIncompleteStreamError(error))) {
|
|
2632
3071
|
if (kind === 'context_overflow') {
|
|
2633
3072
|
throw new ContextOverflowError(reason, request, error.message);
|
|
2634
3073
|
}
|
|
3074
|
+
if (stalled) {
|
|
3075
|
+
throw new AgentError('LLM request timed out. Try again, reduce tool output, or raise ZTC_LLM_REQUEST_TIMEOUT_MS if this model needs longer.', 'API_TIMEOUT');
|
|
3076
|
+
}
|
|
3077
|
+
if (isIncompleteStreamError(error)) {
|
|
3078
|
+
throw new AgentError(INCOMPLETE_MODEL_RESPONSE_MESSAGE, INCOMPLETE_MODEL_RESPONSE_CODE);
|
|
3079
|
+
}
|
|
2635
3080
|
throw new AgentError(reason, 'API_ERROR');
|
|
2636
3081
|
}
|
|
3082
|
+
if (isIncompleteStreamError(error) && request.transportTurnId !== undefined) {
|
|
3083
|
+
request = { ...request, transportTurnId: randomUUID() };
|
|
3084
|
+
}
|
|
3085
|
+
rateLimitedAttempts = kind === 'rate_limit' ? rateLimitedAttempts + 1 : 0;
|
|
3086
|
+
if (rateLimitedAttempts >= RATE_LIMITED_ATTEMPTS) {
|
|
3087
|
+
throw new AgentError(`${reason.replace(/\.?\s*$/, '.')} Still rate-limited after ${rateLimitedAttempts} attempts, so ZTC `
|
|
3088
|
+
+ 'stopped retrying. Send a message to try again, or choose another model with /model.', 'API_ERROR');
|
|
3089
|
+
}
|
|
2637
3090
|
lastReason = reason;
|
|
2638
3091
|
const recovering = attempt >= maxAttempts;
|
|
2639
3092
|
if (recovering)
|
|
2640
3093
|
recoveryStartedAt ??= Date.now();
|
|
2641
3094
|
const elapsedMs = recoveryStartedAt === undefined ? 0 : Math.max(0, Date.now() - recoveryStartedAt);
|
|
2642
3095
|
if (recovering && recoveryWindowMs !== null && elapsedMs >= recoveryWindowMs) {
|
|
2643
|
-
throw new AgentError(reason, 'API_ERROR');
|
|
3096
|
+
throw new AgentError(reason, stalled ? 'API_TIMEOUT' : 'API_ERROR');
|
|
2644
3097
|
}
|
|
2645
3098
|
// Keep the exact pending inference alive. Never resubmit the user turn
|
|
2646
3099
|
// or revisit already checkpointed tool results to recover an endpoint.
|
|
@@ -2673,6 +3126,12 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2673
3126
|
}
|
|
2674
3127
|
// Parse API error to determine if retryable and extract user-friendly message
|
|
2675
3128
|
parseAPIError(error) {
|
|
3129
|
+
if (isIncompleteStreamError(error)) {
|
|
3130
|
+
return { retryable: true, reason: error.message, kind: 'stream_lost' };
|
|
3131
|
+
}
|
|
3132
|
+
// ZTC refused the request before sending it, in words meant for the person.
|
|
3133
|
+
if (error instanceof RequestRefusedError)
|
|
3134
|
+
return { retryable: false, reason: error.message };
|
|
2676
3135
|
// A provider may embed an oversized/malformed diagnostic in an Error.
|
|
2677
3136
|
// Keep all parsing bounded even for transports with their own error type.
|
|
2678
3137
|
const message = error.message.slice(0, 64 * 1024);
|
|
@@ -2686,6 +3145,11 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2686
3145
|
let errorCode = '';
|
|
2687
3146
|
let errorMessage = '';
|
|
2688
3147
|
let admissionMessage = '';
|
|
3148
|
+
let admissionCode = '';
|
|
3149
|
+
// OpenRouter answers "Provider returned error" and nests the upstream provider's own error, as a JSON string, in
|
|
3150
|
+
// error.metadata.raw. That nested message is the one a person can act on.
|
|
3151
|
+
let providerName = '';
|
|
3152
|
+
let upstreamMessage = '';
|
|
2689
3153
|
try {
|
|
2690
3154
|
// Provider envelopes start with an object after the diagnostic prefix.
|
|
2691
3155
|
// Index searches avoid a greedy regex restarting at every forged colon.
|
|
@@ -2701,6 +3165,13 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2701
3165
|
errorType = errorPayload.type || errorPayload.status || '';
|
|
2702
3166
|
errorCode = typeof errorPayload.code === 'string' ? errorPayload.code : '';
|
|
2703
3167
|
errorMessage = errorPayload.message || '';
|
|
3168
|
+
const metadata = errorPayload.metadata;
|
|
3169
|
+
if (metadata && typeof metadata === 'object') {
|
|
3170
|
+
if (typeof metadata.provider_name === 'string')
|
|
3171
|
+
providerName = metadata.provider_name;
|
|
3172
|
+
if (typeof metadata.raw === 'string')
|
|
3173
|
+
upstreamMessage = nestedProviderMessage(metadata.raw);
|
|
3174
|
+
}
|
|
2704
3175
|
}
|
|
2705
3176
|
if (!errorMessage && typeof parsed.detail === 'string') {
|
|
2706
3177
|
errorMessage = parsed.detail;
|
|
@@ -2721,15 +3192,28 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2721
3192
|
admissionMessage = parsed.message;
|
|
2722
3193
|
else if (typeof parsed.statusMessage === 'string')
|
|
2723
3194
|
admissionMessage = parsed.statusMessage;
|
|
3195
|
+
if (typeof parsed.data?.code === 'string')
|
|
3196
|
+
admissionCode = parsed.data.code;
|
|
2724
3197
|
}
|
|
2725
3198
|
}
|
|
2726
3199
|
}
|
|
2727
3200
|
catch {
|
|
2728
3201
|
// Not valid JSON, use raw message
|
|
2729
3202
|
}
|
|
3203
|
+
// The provider's own words, shown so a person can act on them. The HTTP layer already redacted credentials from
|
|
3204
|
+
// its body; an error raised outside it is redacted here.
|
|
3205
|
+
const httpError = error instanceof BackendHttpError;
|
|
3206
|
+
// An error with no HTTP status (a broken stream, a backend's own failure) is its message.
|
|
3207
|
+
const body = httpError ? error.body : /API error \(\d+\): ([\s\S]*)$/.exec(message)?.[1] ?? (statusCode === 0 ? message : '');
|
|
3208
|
+
const providerSource = upstreamMessage || (typeof errorMessage === 'string' ? errorMessage : '') || (body.trimStart().startsWith('{') ? '' : body);
|
|
3209
|
+
const providerText = (httpError ? providerSource : redactErrorText(providerSource)).replace(/\s+/g, ' ').trim();
|
|
3210
|
+
const providerDetail = providerText.length > PROVIDER_DETAIL_CHARS ? `${providerText.slice(0, PROVIDER_DETAIL_CHARS - 1)}…` : providerText;
|
|
3211
|
+
// A message that only repeats the heading ("Invalid request: Invalid request") adds nothing.
|
|
3212
|
+
const withProviderDetail = (base) => `${base}${providerName ? ` from ${providerName}` : ''}`
|
|
3213
|
+
+ (providerDetail && providerDetail.replace(/\.$/, '').toLowerCase() !== base.toLowerCase() ? `: ${providerDetail}` : '');
|
|
2730
3214
|
if (statusCode === 410 && message.startsWith('ZRouter API error (')
|
|
2731
3215
|
&& ['stream_producer_lost', 'stream_producer_failed', 'stream_resume_expired'].includes(errorCode)) {
|
|
2732
|
-
return { retryable: false, reason: 'The Router stream was interrupted and cannot be resumed. '
|
|
3216
|
+
return { retryable: false, kind: 'stream_lost', reason: 'The Router stream was interrupted and cannot be resumed. '
|
|
2733
3217
|
+ 'Send a message to continue from the existing conversation.' };
|
|
2734
3218
|
}
|
|
2735
3219
|
// Detected before the generic 400 bucket so the host can dump the request.
|
|
@@ -2740,16 +3224,28 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2740
3224
|
if (statusCode === 529 || errorType === 'overloaded_error') {
|
|
2741
3225
|
return { retryable: true, reason: 'API is overloaded' };
|
|
2742
3226
|
}
|
|
3227
|
+
// Router usage controls refuse before dispatch. A spending or token limit
|
|
3228
|
+
// lasts until its window resets, so retrying only delays the explanation;
|
|
3229
|
+
// the concurrency limit is temporary and stays a retryable rate limit.
|
|
3230
|
+
if (statusCode === 429 && admissionMessage && LASTING_ROUTER_USAGE_LIMITS.has(admissionCode)) {
|
|
3231
|
+
return { retryable: false, reason: `${admissionMessage.replace(/\.?\s*$/, '.')} `
|
|
3232
|
+
+ 'Wait for the limit to reset, or ask a Zerg Router administrator to raise it.' };
|
|
3233
|
+
}
|
|
3234
|
+
// Router words every OpenRouter rate limit itself, so its message is public. A used-up daily
|
|
3235
|
+
// free-model quota lasts until the day resets; retrying only spends what is left of it.
|
|
3236
|
+
const routerRateLimit = statusCode === 429 && message.startsWith('ZRouter API error (')
|
|
3237
|
+
&& ROUTER_RATE_LIMIT_CODES.has(errorCode) && /^OpenRouter(?:'s)? /.test(errorMessage) ? errorMessage.trim() : '';
|
|
3238
|
+
if (routerRateLimit && errorCode === 'free_model_daily_limit') {
|
|
3239
|
+
return { retryable: false, reason: `${routerRateLimit.replace(/\.?\s*$/, '.')} Choose another model with /model, or wait for the limit to reset.` };
|
|
3240
|
+
}
|
|
2743
3241
|
if (statusCode === 429 || errorType === 'rate_limit_error' || errorType === 'RESOURCE_EXHAUSTED') {
|
|
2744
|
-
return { retryable: true, reason: 'Rate limit exceeded', kind: 'rate_limit' };
|
|
3242
|
+
return { retryable: true, reason: routerRateLimit || 'Rate limit exceeded', kind: 'rate_limit' };
|
|
2745
3243
|
}
|
|
2746
3244
|
if (statusCode === 504 || statusCode === 503 || statusCode === 502 || statusCode === 500 || errorType === 'UNAVAILABLE' || errorType === 'INTERNAL') {
|
|
2747
|
-
//
|
|
2748
|
-
// private; a bounded response-header ID supplies support correlation.
|
|
3245
|
+
// A bounded response-header ID supplies support correlation beside the provider's message.
|
|
2749
3246
|
const requestId = /(?:fly-request-id|x-request-id)=([A-Za-z0-9._:-]{1,128})(?:[ \]]|$)/.exec(message)?.[1];
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
return { retryable: true, reason: `Upstream server error (${statusCode || 'no status'})${cause}` };
|
|
3247
|
+
const base = withProviderDetail(`Upstream server error (${statusCode || 'no status'})`);
|
|
3248
|
+
return { retryable: true, reason: requestId ? `${base}${providerDetail ? ';' : ':'} request_id: ${requestId}` : base };
|
|
2753
3249
|
}
|
|
2754
3250
|
// Non-retryable errors with clean messages
|
|
2755
3251
|
if (statusCode === 401 || errorType === 'authentication_error' || errorType === 'UNAUTHENTICATED') {
|
|
@@ -2777,13 +3273,26 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2777
3273
|
// Keep the Router's setup failure actionable without echoing arbitrary
|
|
2778
3274
|
// remote bodies. Only these known provider names can enter the message.
|
|
2779
3275
|
const missingRouterKey = typeof errorMessage === 'string'
|
|
2780
|
-
? errorMessage.match(/^No API key available for provider: (anthropic|openai|gemini|deepseek|kimi|modal|inception|clarifai)$/)
|
|
3276
|
+
? errorMessage.match(/^No API key available for provider: (anthropic|openai|gemini|deepseek|kimi|modal|inception|clarifai|openrouter|fireworks)$/)
|
|
2781
3277
|
: null;
|
|
2782
3278
|
if (statusCode === 400 && message.startsWith('ZRouter API error (') && missingRouterKey) {
|
|
2783
|
-
|
|
3279
|
+
const provider = missingRouterKey[1];
|
|
3280
|
+
// Modal runs only on Zerg's own key, so another model is the only way on.
|
|
3281
|
+
return { retryable: false, reason: provider === 'modal'
|
|
3282
|
+
? 'Zerg Router has no key for modal, so it cannot run this model. Choose another model with /model.'
|
|
3283
|
+
: `Zerg Router has no key for ${provider}. Add one in Zerg Router, or choose another model with /model.` };
|
|
3284
|
+
}
|
|
3285
|
+
// OpenRouter choices that leave no provider: Router names the cause, and it stays until changed.
|
|
3286
|
+
const openRouterNext = admissionCode === 'openrouter_limits_unmet'
|
|
3287
|
+
? 'Loosen them on the reasoning page (/effort) or with /config openrouter limit.'
|
|
3288
|
+
: admissionCode === 'openrouter_pinned_unsupported'
|
|
3289
|
+
? 'Choose another provider on the reasoning page (/effort).'
|
|
3290
|
+
: admissionCode === 'openrouter_parameters_unsupported' ? 'Choose another model with /model.' : null;
|
|
3291
|
+
if (statusCode === 400 && message.startsWith('ZRouter API error (') && openRouterNext && admissionMessage) {
|
|
3292
|
+
return { retryable: false, reason: `${admissionMessage.replace(/\.?\s*$/, '.')} ${openRouterNext}` };
|
|
2784
3293
|
}
|
|
2785
3294
|
if (statusCode === 400 || errorType === 'invalid_request_error' || errorType === 'INVALID_ARGUMENT') {
|
|
2786
|
-
return { retryable: false, reason: 'Invalid request' };
|
|
3295
|
+
return { retryable: false, reason: withProviderDetail('Invalid request') };
|
|
2787
3296
|
}
|
|
2788
3297
|
// Transport-layer network failures (R8/F10): a raw `fetch failed` / ECONNRESET
|
|
2789
3298
|
// carries no `API error (NNN)` status and no JSON body, so it reaches here and
|
|
@@ -2798,9 +3307,24 @@ INVESTIGATION STRATEGY — before making tool calls to explore or debug, follow
|
|
|
2798
3307
|
if (statusCode === 0 && isTransportMessageError(error)) {
|
|
2799
3308
|
return { retryable: true, reason: 'Network error reaching the LLM endpoint', kind: 'transport' };
|
|
2800
3309
|
}
|
|
2801
|
-
|
|
2802
|
-
// paths. Keep the raw detail inside the provider boundary.
|
|
2803
|
-
return { retryable: false, reason: 'Provider request failed.' };
|
|
3310
|
+
return { retryable: false, reason: providerDetail || providerName ? withProviderDetail('Provider request failed') : 'Provider request failed.' };
|
|
2804
3311
|
}
|
|
2805
3312
|
}
|
|
3313
|
+
/** The longest provider message an error shows, on one line. */
|
|
3314
|
+
const PROVIDER_DETAIL_CHARS = 300;
|
|
3315
|
+
/** The message inside a provider's raw error body: Anthropic's error.message, a bare message, or the text itself. */
|
|
3316
|
+
function nestedProviderMessage(raw) {
|
|
3317
|
+
try {
|
|
3318
|
+
const parsed = JSON.parse(raw);
|
|
3319
|
+
const nested = parsed?.error;
|
|
3320
|
+
if (typeof nested?.message === 'string')
|
|
3321
|
+
return nested.message;
|
|
3322
|
+
if (typeof nested === 'string')
|
|
3323
|
+
return nested;
|
|
3324
|
+
if (typeof parsed?.message === 'string')
|
|
3325
|
+
return parsed.message;
|
|
3326
|
+
}
|
|
3327
|
+
catch { /* not JSON: the raw text is the message */ }
|
|
3328
|
+
return raw;
|
|
3329
|
+
}
|
|
2806
3330
|
export default Agent;
|