@zergai/ztc 0.4.0-beta.1 → 0.5.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 +398 -45
- package/RUST_THIRD_PARTY_LICENSES.txt +1080 -822
- package/THIRD_PARTY_NOTICES.md +273 -12
- 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/ztc-zlicky-overlay-darwin-arm64 +0 -0
- package/bin/zterm-darwin-arm64 +0 -0
- package/dist/App.js +1206 -209
- package/dist/agent/agent.d.ts +74 -8
- package/dist/agent/agent.js +1073 -184
- package/dist/agent/backends/account_rotation.d.ts +4 -0
- package/dist/agent/backends/account_rotation.js +8 -2
- package/dist/agent/backends/anthropic.d.ts +13 -0
- package/dist/agent/backends/anthropic.js +169 -28
- package/dist/agent/backends/claude_cli.js +18 -8
- package/dist/agent/backends/codex_app_server.d.ts +1 -0
- package/dist/agent/backends/codex_app_server.js +55 -3
- package/dist/agent/backends/codex_auth.d.ts +1 -0
- package/dist/agent/backends/codex_auth.js +67 -13
- package/dist/agent/backends/codex_buffered_recovery.d.ts +27 -0
- package/dist/agent/backends/codex_buffered_recovery.js +293 -0
- package/dist/agent/backends/gemini.js +3 -1
- package/dist/agent/backends/http_error.d.ts +26 -0
- package/dist/agent/backends/http_error.js +221 -0
- package/dist/agent/backends/index.d.ts +9 -2
- package/dist/agent/backends/index.js +22 -2
- package/dist/agent/backends/openai.d.ts +0 -6
- package/dist/agent/backends/openai.js +5 -2
- package/dist/agent/backends/openai_compatible.d.ts +5 -4
- package/dist/agent/backends/openai_compatible.js +26 -19
- package/dist/agent/backends/openai_responses.d.ts +8 -3
- package/dist/agent/backends/openai_responses.js +77 -33
- package/dist/agent/backends/provider_ids.d.ts +1 -0
- package/dist/agent/backends/provider_ids.js +4 -0
- package/dist/agent/backends/request_metrics.js +12 -2
- package/dist/agent/backends/types.d.ts +109 -6
- package/dist/agent/backends/types.js +5 -1
- package/dist/agent/backends/zrouter_stream.d.ts +6 -1
- package/dist/agent/backends/zrouter_stream.js +160 -42
- package/dist/agent/background_registry.d.ts +2 -0
- package/dist/agent/background_registry.js +1 -0
- package/dist/agent/claim_observation.d.ts +6 -0
- package/dist/agent/claim_observation.js +54 -0
- package/dist/agent/commands/accounts.js +46 -177
- package/dist/agent/commands/attention.d.ts +2 -0
- package/dist/agent/commands/attention.js +67 -0
- package/dist/agent/commands/auth.js +18 -2
- package/dist/agent/commands/board.d.ts +2 -0
- package/dist/agent/commands/board.js +169 -0
- package/dist/agent/commands/clipboard.js +50 -1
- package/dist/agent/commands/compact.js +21 -13
- package/dist/agent/commands/config.js +4 -1
- package/dist/agent/commands/context.js +6 -1
- package/dist/agent/commands/desktop.d.ts +2 -0
- package/dist/agent/commands/desktop.js +29 -0
- package/dist/agent/commands/effort.js +14 -6
- package/dist/agent/commands/environment.d.ts +3 -0
- package/dist/agent/commands/environment.js +109 -0
- package/dist/agent/commands/evidence.d.ts +2 -0
- package/dist/agent/commands/evidence.js +9 -0
- package/dist/agent/commands/fork.js +4 -3
- package/dist/agent/commands/goal.d.ts +33 -1
- package/dist/agent/commands/goal.js +174 -14
- package/dist/agent/commands/goal_exit.d.ts +36 -0
- package/dist/agent/commands/goal_exit.js +120 -0
- package/dist/agent/commands/help.js +3 -1
- package/dist/agent/commands/history.js +3 -1
- package/dist/agent/commands/inbox.d.ts +2 -0
- package/dist/agent/commands/inbox.js +148 -0
- package/dist/agent/commands/index.js +16 -1
- package/dist/agent/commands/input_mode.js +8 -6
- package/dist/agent/commands/job.d.ts +2 -0
- package/dist/agent/commands/job.js +93 -0
- package/dist/agent/commands/keybindings.js +4 -1
- package/dist/agent/commands/label.d.ts +2 -0
- package/dist/agent/commands/label.js +77 -0
- package/dist/agent/commands/layout.d.ts +2 -0
- package/dist/agent/commands/layout.js +20 -0
- package/dist/agent/commands/mirror.js +16 -1
- package/dist/agent/commands/model.js +12 -2
- package/dist/agent/commands/permissions.d.ts +3 -1
- package/dist/agent/commands/permissions.js +79 -89
- package/dist/agent/commands/plan.js +5 -15
- package/dist/agent/commands/profile.js +21 -2
- package/dist/agent/commands/provider_selection.js +20 -1
- package/dist/agent/commands/rename.js +1 -1
- package/dist/agent/commands/resources.d.ts +2 -0
- package/dist/agent/commands/resources.js +67 -0
- package/dist/agent/commands/rewind.d.ts +3 -0
- package/dist/agent/commands/rewind.js +16 -0
- package/dist/agent/commands/runbooks.d.ts +2 -0
- package/dist/agent/commands/runbooks.js +73 -0
- package/dist/agent/commands/runbooks_lazy.d.ts +2 -0
- package/dist/agent/commands/runbooks_lazy.js +8 -0
- package/dist/agent/commands/sessions.d.ts +1 -1
- package/dist/agent/commands/sessions.js +33 -5
- package/dist/agent/commands/settings.js +185 -39
- package/dist/agent/commands/setup.d.ts +2 -0
- package/dist/agent/commands/setup.js +78 -0
- package/dist/agent/commands/share.d.ts +2 -0
- package/dist/agent/commands/share.js +64 -0
- package/dist/agent/commands/status.js +14 -2
- package/dist/agent/commands/types.d.ts +99 -6
- package/dist/agent/commands/update.js +8 -0
- package/dist/agent/commands/usage.d.ts +2 -0
- package/dist/agent/commands/usage.js +8 -0
- package/dist/agent/factory.d.ts +11 -0
- package/dist/agent/factory.js +113 -88
- package/dist/agent/loop_policy.d.ts +6 -3
- package/dist/agent/loop_policy.js +12 -3
- package/dist/agent/measurement_guidance.d.ts +2 -0
- package/dist/agent/measurement_guidance.js +5 -0
- package/dist/agent/request_encoder.d.ts +8 -1
- package/dist/agent/request_encoder.js +95 -23
- package/dist/agent/runtime/benchmark_comparison.d.ts +30 -0
- package/dist/agent/runtime/benchmark_comparison.js +94 -0
- package/dist/agent/runtime/benchmark_contract.d.ts +48 -0
- package/dist/agent/runtime/benchmark_contract.js +90 -0
- package/dist/agent/runtime/checked_commands.d.ts +32 -0
- package/dist/agent/runtime/checked_commands.js +119 -0
- package/dist/agent/runtime/command_execution_policy.d.ts +26 -0
- package/dist/agent/runtime/command_execution_policy.js +91 -0
- package/dist/agent/runtime/command_jobs.d.ts +36 -18
- package/dist/agent/runtime/command_jobs.js +151 -13
- package/dist/agent/runtime/command_panes.d.ts +59 -0
- package/dist/agent/runtime/command_panes.js +398 -0
- package/dist/agent/runtime/command_wait.d.ts +19 -0
- package/dist/agent/runtime/command_wait.js +167 -0
- package/dist/agent/runtime/cpu_benchmark.d.ts +30 -0
- package/dist/agent/runtime/cpu_benchmark.js +126 -0
- package/dist/agent/runtime/delegated_evidence.d.ts +26 -0
- package/dist/agent/runtime/delegated_evidence.js +80 -0
- package/dist/agent/runtime/evidence.d.ts +127 -0
- package/dist/agent/runtime/evidence.js +468 -0
- package/dist/agent/runtime/execution_context.d.ts +7 -0
- package/dist/agent/runtime/execution_context.js +39 -3
- package/dist/agent/runtime/json_verifier_recipe.d.ts +8 -0
- package/dist/agent/runtime/json_verifier_recipe.js +66 -0
- package/dist/agent/runtime/measurements.d.ts +110 -0
- package/dist/agent/runtime/measurements.js +317 -0
- package/dist/agent/runtime/policy.d.ts +4 -0
- package/dist/agent/runtime/policy.js +31 -20
- package/dist/agent/runtime/provider_native_evidence.d.ts +20 -0
- package/dist/agent/runtime/provider_native_evidence.js +86 -0
- package/dist/agent/runtime/recovery.d.ts +2 -0
- package/dist/agent/runtime/recovery.js +45 -2
- package/dist/agent/runtime/remote_broker_transport.d.ts +10 -0
- package/dist/agent/runtime/remote_broker_transport.js +84 -0
- package/dist/agent/runtime/remote_deletion_receipts.d.ts +3 -0
- package/dist/agent/runtime/remote_deletion_receipts.js +43 -0
- package/dist/agent/runtime/remote_journal_replay.d.ts +13 -0
- package/dist/agent/runtime/remote_journal_replay.js +233 -0
- package/dist/agent/runtime/remote_mutation_journal.d.ts +25 -0
- package/dist/agent/runtime/remote_mutation_journal.js +208 -0
- package/dist/agent/runtime/remote_resource_endpoint.d.ts +7 -0
- package/dist/agent/runtime/remote_resource_endpoint.js +6 -0
- package/dist/agent/runtime/remote_resource_errors.d.ts +5 -0
- package/dist/agent/runtime/remote_resource_errors.js +9 -0
- package/dist/agent/runtime/remote_resource_script.d.ts +2 -0
- package/dist/agent/runtime/remote_resource_script.js +1009 -0
- package/dist/agent/runtime/remote_resources.d.ts +29 -0
- package/dist/agent/runtime/remote_resources.js +160 -0
- package/dist/agent/runtime/source_verification.d.ts +12 -0
- package/dist/agent/runtime/source_verification.js +210 -0
- package/dist/agent/runtime/source_verification_contract.d.ts +75 -0
- package/dist/agent/runtime/source_verification_contract.js +203 -0
- package/dist/agent/runtime/tool_checkpoints.d.ts +11 -0
- package/dist/agent/runtime/tool_checkpoints.js +26 -0
- package/dist/agent/runtime/tool_effects.d.ts +5 -0
- package/dist/agent/runtime/tool_progress.d.ts +12 -0
- package/dist/agent/runtime/tool_progress.js +76 -0
- package/dist/agent/runtime/tool_runtime.d.ts +16 -1
- package/dist/agent/runtime/tool_runtime.js +204 -10
- package/dist/agent/runtime/tracing.d.ts +1 -1
- package/dist/agent/runtime/verifier_capture.d.ts +9 -0
- package/dist/agent/runtime/verifier_capture.js +100 -0
- package/dist/agent/runtime/verifier_contract.d.ts +24 -0
- package/dist/agent/runtime/verifier_contract.js +41 -0
- package/dist/agent/subagent.d.ts +20 -10
- package/dist/agent/subagent.js +266 -29
- package/dist/agent/tool_response_directory.d.ts +24 -0
- package/dist/agent/tool_response_directory.js +61 -0
- package/dist/agent/tool_response_source.d.ts +8 -0
- package/dist/agent/tool_response_source.js +49 -0
- package/dist/agent/tool_response_store.d.ts +75 -4
- package/dist/agent/tool_response_store.js +583 -64
- package/dist/agent/tools/ask_user.d.ts +3 -1
- package/dist/agent/tools/ask_user.js +30 -11
- package/dist/agent/tools/background.js +1 -0
- package/dist/agent/tools/benchmark_cpu.d.ts +2 -0
- package/dist/agent/tools/benchmark_cpu.js +102 -0
- package/dist/agent/tools/compare_benchmarks.d.ts +2 -0
- package/dist/agent/tools/compare_benchmarks.js +53 -0
- package/dist/agent/tools/deferred.js +1 -0
- package/dist/agent/tools/delegate.js +18 -2
- package/dist/agent/tools/helper_requirements.d.ts +7 -0
- package/dist/agent/tools/helper_requirements.js +19 -0
- package/dist/agent/tools/index.d.ts +1 -0
- package/dist/agent/tools/index.js +3 -0
- package/dist/agent/tools/measurement_report.d.ts +22 -0
- package/dist/agent/tools/measurement_report.js +190 -0
- package/dist/agent/tools/pane.d.ts +0 -7
- package/dist/agent/tools/pane.js +5 -4
- package/dist/agent/tools/project_context.d.ts +3 -0
- package/dist/agent/tools/project_context.js +45 -0
- package/dist/agent/tools/recall_tool_response.d.ts +3 -5
- package/dist/agent/tools/recall_tool_response.js +19 -29
- package/dist/agent/tools/registry.d.ts +1 -0
- package/dist/agent/tools/registry.js +23 -0
- package/dist/agent/tools/related_sessions.d.ts +2 -0
- package/dist/agent/tools/related_sessions.js +156 -0
- package/dist/agent/tools/routine.js +13 -3
- package/dist/agent/tools/session_evidence.d.ts +3 -0
- package/dist/agent/tools/session_evidence.js +72 -0
- package/dist/agent/tools/shell.d.ts +4 -3
- package/dist/agent/tools/shell.js +174 -47
- package/dist/agent/tools/tool_search.js +3 -2
- package/dist/agent/tools/types.d.ts +28 -0
- package/dist/agent/tools/verify_artifact.d.ts +2 -0
- package/dist/agent/tools/verify_artifact.js +60 -0
- package/dist/agent/tools/workflow.js +1 -0
- package/dist/app/activity.d.ts +6 -1
- package/dist/app/activity.js +81 -12
- package/dist/app/agent_runner.d.ts +6 -1
- package/dist/app/agent_runner.js +34 -19
- package/dist/app/command_context.js +106 -10
- package/dist/app/controller.d.ts +15 -4
- package/dist/app/controller.js +29 -3
- package/dist/app/escape_stop.d.ts +11 -0
- package/dist/app/escape_stop.js +15 -0
- package/dist/app/liveness.d.ts +6 -4
- package/dist/app/liveness.js +13 -3
- package/dist/app/model_catalog_cache.d.ts +5 -0
- package/dist/app/model_catalog_cache.js +138 -0
- package/dist/app/ordered_transcript.js +43 -4
- package/dist/app/prompt_turn.d.ts +14 -0
- package/dist/app/prompt_turn.js +53 -0
- package/dist/app/recap.d.ts +3 -0
- package/dist/app/recap.js +9 -3
- package/dist/app/restart.d.ts +3 -2
- package/dist/app/restart.js +22 -7
- package/dist/app/rewind.d.ts +3 -3
- package/dist/app/rewind.js +3 -3
- package/dist/app/selection_completion.d.ts +17 -2
- package/dist/app/selection_completion.js +84 -9
- package/dist/app/session_manager.d.ts +38 -6
- package/dist/app/session_manager.js +263 -60
- package/dist/app/session_messages.d.ts +3 -0
- package/dist/app/session_messages.js +60 -0
- package/dist/app/task_scope_router.d.ts +20 -0
- package/dist/app/task_scope_router.js +173 -0
- package/dist/app/transcript_window.d.ts +2 -0
- package/dist/app/transcript_window.js +4 -0
- package/dist/app/workspace_admission_details.d.ts +3 -0
- package/dist/app/workspace_admission_details.js +26 -0
- package/dist/app/workspace_layout_controller.d.ts +11 -0
- package/dist/app/workspace_layout_controller.js +88 -0
- package/dist/app/workspace_monitor.d.ts +1 -0
- package/dist/app/workspace_monitor.js +216 -0
- package/dist/app/workspace_presets.d.ts +29 -0
- package/dist/app/workspace_presets.js +192 -0
- package/dist/attention/queue.d.ts +37 -0
- package/dist/attention/queue.js +183 -0
- package/dist/bench/rf_shared.d.ts +2 -0
- package/dist/board/binding.d.ts +42 -0
- package/dist/board/binding.js +38 -0
- package/dist/board/client.d.ts +42 -0
- package/dist/board/client.js +60 -0
- package/dist/cli.js +1 -1
- package/dist/cli_args.js +19 -17
- package/dist/cli_main.js +110 -13
- package/dist/cli_ratatui.d.ts +183 -16
- package/dist/cli_ratatui.js +3989 -1255
- package/dist/components/ActivityLine.d.ts +3 -2
- package/dist/components/ActivityLine.js +2 -2
- package/dist/components/InputArea.d.ts +19 -1
- package/dist/components/InputArea.js +264 -190
- package/dist/components/MessageList.d.ts +2 -0
- package/dist/components/MessageList.js +3 -1
- package/dist/components/SingleMessage.d.ts +2 -0
- package/dist/components/SingleMessage.js +4 -2
- package/dist/components/StatusBar.d.ts +4 -2
- package/dist/components/StatusBar.js +3 -1
- package/dist/conductor_branch.js +3 -0
- package/dist/config/api_retry.d.ts +6 -1
- package/dist/config/api_retry.js +19 -1
- package/dist/config/defaults.d.ts +2 -1
- package/dist/config/defaults.js +9 -2
- package/dist/config/message_display.d.ts +1 -0
- package/dist/config/message_display.js +17 -2
- package/dist/config/permissions.d.ts +21 -0
- package/dist/config/permissions.js +89 -0
- package/dist/config/resolved.d.ts +2 -2
- package/dist/config/types.d.ts +32 -5
- package/dist/config.d.ts +38 -4
- package/dist/config.js +290 -42
- package/dist/context/project_intelligence.d.ts +44 -0
- package/dist/context/project_intelligence.js +246 -0
- package/dist/desktop/cli_launch.d.ts +8 -0
- package/dist/desktop/cli_launch.js +6 -0
- package/dist/desktop/cli_shim.d.ts +8 -0
- package/dist/desktop/cli_shim.js +120 -0
- package/dist/desktop/runtime.d.ts +16 -0
- package/dist/desktop/runtime.js +161 -0
- package/dist/desktop/worker_launch.d.ts +7 -0
- package/dist/desktop/worker_launch.js +7 -0
- package/dist/diagnostics/cargo_mutants_selection.d.ts +27 -0
- package/dist/diagnostics/cargo_mutants_selection.js +48 -0
- package/dist/diagnostics/native_terminal_benchmark.d.ts +58 -0
- package/dist/diagnostics/native_terminal_benchmark.js +1247 -0
- package/dist/diagnostics/session_evidence_package.d.ts +40 -0
- package/dist/diagnostics/session_evidence_package.js +234 -0
- package/dist/diagnostics/session_export.d.ts +93 -0
- package/dist/diagnostics/session_export.js +634 -0
- package/dist/emulation/tool_adapters.js +48 -18
- package/dist/emulation/ztc_addendum.d.ts +1 -0
- package/dist/emulation/ztc_addendum.js +13 -12
- package/dist/environment/service_runner.d.ts +1 -0
- package/dist/environment/service_runner.js +68 -0
- package/dist/environment/store.d.ts +120 -0
- package/dist/environment/store.js +387 -0
- package/dist/events.d.ts +40 -1
- package/dist/events.js +10 -17
- package/dist/goal_contract.d.ts +25 -0
- package/dist/goal_contract.js +44 -0
- package/dist/headless.d.ts +31 -0
- package/dist/headless.js +578 -70
- package/dist/headless_cli.js +8 -0
- package/dist/headless_cli_args.d.ts +1 -0
- package/dist/headless_cli_args.js +1 -0
- package/dist/intake/cli.d.ts +1 -0
- package/dist/intake/cli.js +33 -0
- package/dist/intake/format.d.ts +2 -0
- package/dist/intake/format.js +14 -0
- package/dist/intake/notifications.d.ts +16 -0
- package/dist/intake/notifications.js +132 -0
- package/dist/intake/store.d.ts +56 -0
- package/dist/intake/store.js +238 -0
- package/dist/library.d.ts +8 -0
- package/dist/library.js +19 -10
- package/dist/mcp/client.d.ts +1 -0
- package/dist/mcp/client.js +20 -0
- package/dist/modes/builtin/plan.yaml +2 -2
- package/dist/modes/handlers.js +1 -1
- package/dist/onboarding/first_run.d.ts +3 -0
- package/dist/onboarding/first_run.js +33 -25
- package/dist/onboarding/setup.d.ts +32 -0
- package/dist/onboarding/setup.js +133 -0
- package/dist/onboarding/setup_agent_health.d.ts +17 -0
- package/dist/onboarding/setup_agent_health.js +79 -0
- package/dist/onboarding/setup_environment.d.ts +66 -0
- package/dist/onboarding/setup_environment.js +219 -0
- package/dist/onboarding/setup_workspace.d.ts +17 -0
- package/dist/onboarding/setup_workspace.js +129 -0
- package/dist/optimize/adapters/index.d.ts +4 -1
- package/dist/optimize/adapters/index.js +7 -0
- package/dist/optimize/adapters/kernelbench.js +14 -5
- package/dist/optimize/adapters/popcorn.js +3 -2
- package/dist/optimize/adapters/profile_benchmark.js +13 -7
- package/dist/optimize/adapters/rfbench.js +25 -14
- package/dist/optimize/adapters/types.d.ts +3 -0
- package/dist/optimize/adapters/zergpod.js +5 -2
- package/dist/optimize/baseline.js +10 -21
- package/dist/optimize/branch.js +9 -12
- package/dist/optimize/combine.js +2 -3
- package/dist/optimize/executor.js +34 -48
- package/dist/optimize/measurements.d.ts +55 -0
- package/dist/optimize/measurements.js +173 -0
- package/dist/optimize/results.d.ts +1 -0
- package/dist/optimize/results.js +11 -33
- package/dist/optimize/tge.js +2 -1
- package/dist/panes/initial_input.d.ts +19 -0
- package/dist/panes/initial_input.js +206 -0
- package/dist/panes/labels.d.ts +16 -0
- package/dist/panes/labels.js +42 -0
- package/dist/panes/model_catalog.d.ts +3 -3
- package/dist/panes/model_catalog.js +28 -4
- package/dist/panes/pane_registry.js +6 -2
- package/dist/panes/types.d.ts +3 -0
- package/dist/panes/ztc_launch.js +19 -0
- package/dist/plugin/optimization.d.ts +2 -0
- package/dist/plugin/optimization.js +1 -0
- package/dist/plugin/runtime.d.ts +2 -0
- package/dist/plugin/simulation.d.ts +6 -1
- package/dist/plugin/simulation_contract.d.ts +836 -1
- package/dist/plugin/simulation_documents.d.ts +22 -0
- package/dist/plugin/simulation_documents.js +1 -0
- package/dist/plugin/simulation_interventions.d.ts +103 -0
- package/dist/plugin/simulation_interventions.js +1 -0
- package/dist/plugin/simulation_living.d.ts +1 -0
- package/dist/plugin/simulation_living.js +3 -0
- package/dist/plugin/simulation_meetings.d.ts +121 -0
- package/dist/plugin/simulation_meetings.js +1 -0
- package/dist/plugin/simulation_story_review.d.ts +111 -0
- package/dist/plugin/simulation_story_review.js +1 -0
- package/dist/plugin/simulation_storyteller.d.ts +91 -0
- package/dist/plugin/simulation_storyteller.js +1 -0
- package/dist/plugin/simulation_structured.d.ts +2 -0
- package/dist/plugin/simulation_structured.js +2 -0
- package/dist/plugin/simulation_toolkit.d.ts +21 -0
- package/dist/plugin/simulation_toolkit.js +24 -0
- package/dist/prompts/tool_delegate_task.j2 +1 -1
- package/dist/remote-broker/Dockerfile +10 -0
- package/dist/remote-broker/archive.py +1227 -0
- package/dist/remote-broker/cutover.py +761 -0
- package/dist/remote-broker/requirements.txt +5 -0
- package/dist/remote-broker/resources.json +6 -0
- package/dist/remote-broker/resources.write-staging.example.json +18 -0
- package/dist/remote-broker/retained.py +686 -0
- package/dist/remote-broker/retained_cleanup.py +550 -0
- package/dist/remote-broker/server.py +648 -0
- package/dist/remote-broker/worker.py +1007 -0
- package/dist/router_auth.d.ts +31 -0
- package/dist/router_auth.js +155 -9
- package/dist/runbooks/catalog.d.ts +3 -0
- package/dist/runbooks/catalog.js +26 -0
- package/dist/runbooks/library.d.ts +11 -0
- package/dist/runbooks/library.js +95 -0
- package/dist/runbooks/package.d.ts +43 -0
- package/dist/runbooks/package.js +102 -0
- package/dist/session.d.ts +65 -13
- package/dist/session.js +548 -43
- package/dist/session_handoff.d.ts +25 -0
- package/dist/session_handoff.js +322 -0
- package/dist/session_handoff_contract.d.ts +89 -0
- package/dist/session_handoff_contract.js +179 -0
- package/dist/session_media.d.ts +41 -0
- package/dist/session_media.js +357 -0
- package/dist/session_ownership.d.ts +16 -0
- package/dist/session_ownership.js +221 -0
- package/dist/session_public.d.ts +10 -2
- package/dist/session_public.js +6 -1
- package/dist/simulation/dynamic_history.d.ts +42 -0
- package/dist/simulation/dynamic_history.js +173 -0
- package/dist/simulation/engines/swarm/pane_manager.js +7 -6
- package/dist/simulation/inference.d.ts +3 -1
- package/dist/simulation/inference.js +19 -1
- package/dist/simulation/intervention_generation.d.ts +27 -0
- package/dist/simulation/intervention_generation.js +246 -0
- package/dist/simulation/intervention_material.d.ts +4 -0
- package/dist/simulation/intervention_material.js +81 -0
- package/dist/simulation/living/context.d.ts +3130 -0
- package/dist/simulation/living/context.js +944 -0
- package/dist/simulation/living/definer.d.ts +12 -0
- package/dist/simulation/living/definer.js +223 -0
- package/dist/simulation/living/definition.d.ts +257 -0
- package/dist/simulation/living/definition.js +341 -0
- package/dist/simulation/living/frame.d.ts +259 -0
- package/dist/simulation/living/frame.js +223 -0
- package/dist/simulation/living/identifiers.d.ts +2 -0
- package/dist/simulation/living/identifiers.js +12 -0
- package/dist/simulation/living/index.d.ts +15 -0
- package/dist/simulation/living/index.js +15 -0
- package/dist/simulation/living/inference.d.ts +219 -0
- package/dist/simulation/living/inference.js +576 -0
- package/dist/simulation/living/mechanics.d.ts +54 -0
- package/dist/simulation/living/mechanics.js +588 -0
- package/dist/simulation/living/model-input.d.ts +25 -0
- package/dist/simulation/living/model-input.js +215 -0
- package/dist/simulation/living/open-world.d.ts +257 -0
- package/dist/simulation/living/open-world.js +102 -0
- package/dist/simulation/living/projection.d.ts +7 -0
- package/dist/simulation/living/projection.js +31 -0
- package/dist/simulation/living/recall.d.ts +17 -0
- package/dist/simulation/living/recall.js +25 -0
- package/dist/simulation/living/reduce.d.ts +15 -0
- package/dist/simulation/living/reduce.js +1853 -0
- package/dist/simulation/living/replay.d.ts +6 -0
- package/dist/simulation/living/replay.js +22 -0
- package/dist/simulation/living/runtime.d.ts +140 -0
- package/dist/simulation/living/runtime.js +3020 -0
- package/dist/simulation/living/shared-kinds.d.ts +24 -0
- package/dist/simulation/living/shared-kinds.js +96 -0
- package/dist/simulation/living/types.d.ts +2785 -0
- package/dist/simulation/living/types.js +669 -0
- package/dist/simulation/llm.d.ts +3 -1
- package/dist/simulation/llm.js +90 -30
- package/dist/simulation/memory/embedding.d.ts +1 -1
- package/dist/simulation/memory/embedding.js +9 -3
- package/dist/simulation/memory/filesystem.d.ts +2 -0
- package/dist/simulation/memory/filesystem.js +5 -1
- package/dist/simulation/memory/filesystem_file_tree.d.ts +4 -1
- package/dist/simulation/memory/filesystem_file_tree.js +41 -10
- package/dist/simulation/memory/filesystem_invariants.js +1 -2
- package/dist/simulation/memory/filesystem_types.d.ts +1 -0
- package/dist/simulation/memory/memory.d.ts +2 -0
- package/dist/simulation/memory/memory.js +5 -1
- package/dist/simulation/orchestration/intent.js +0 -2
- package/dist/simulation/orchestration/lifecycle.js +0 -2
- package/dist/simulation/plugin_host.d.ts +25 -1
- package/dist/simulation/plugin_host.js +334 -17
- package/dist/simulation/session_documents.d.ts +20 -0
- package/dist/simulation/session_documents.js +62 -0
- package/dist/simulation/session_input_validation.d.ts +43 -0
- package/dist/simulation/session_input_validation.js +364 -0
- package/dist/simulation/session_inputs.d.ts +32 -0
- package/dist/simulation/session_inputs.js +154 -0
- package/dist/simulation/telemetry.d.ts +11 -14
- package/dist/simulation/telemetry.js +177 -54
- package/dist/simulation/toolkit/bounded_turns.d.ts +13 -0
- package/dist/simulation/toolkit/bounded_turns.js +80 -0
- package/dist/simulation/toolkit/dynamic_agents.d.ts +25 -0
- package/dist/simulation/toolkit/dynamic_agents.js +218 -0
- package/dist/simulation/toolkit/dynamic_digest.d.ts +1 -0
- package/dist/simulation/toolkit/dynamic_digest.js +8 -0
- package/dist/simulation/toolkit/dynamic_documents.d.ts +7 -0
- package/dist/simulation/toolkit/dynamic_documents.js +71 -0
- package/dist/simulation/toolkit/dynamic_driver.d.ts +8 -0
- package/dist/simulation/toolkit/dynamic_driver.js +269 -0
- package/dist/simulation/toolkit/dynamic_game.d.ts +53 -0
- package/dist/simulation/toolkit/dynamic_game.js +805 -0
- package/dist/simulation/toolkit/dynamic_knowledge.d.ts +15 -0
- package/dist/simulation/toolkit/dynamic_knowledge.js +91 -0
- package/dist/simulation/toolkit/dynamic_mechanics.d.ts +22 -0
- package/dist/simulation/toolkit/dynamic_mechanics.js +910 -0
- package/dist/simulation/toolkit/dynamic_meetings.d.ts +239 -0
- package/dist/simulation/toolkit/dynamic_meetings.js +350 -0
- package/dist/simulation/toolkit/dynamic_progress.d.ts +131 -0
- package/dist/simulation/toolkit/dynamic_progress.js +214 -0
- package/dist/simulation/toolkit/dynamic_projection.d.ts +9 -0
- package/dist/simulation/toolkit/dynamic_projection.js +219 -0
- package/dist/simulation/toolkit/dynamic_runtime.d.ts +412 -0
- package/dist/simulation/toolkit/dynamic_runtime.js +6536 -0
- package/dist/simulation/toolkit/dynamic_state.d.ts +111 -0
- package/dist/simulation/toolkit/dynamic_state.js +1967 -0
- package/dist/simulation/toolkit/dynamic_story_review.d.ts +508 -0
- package/dist/simulation/toolkit/dynamic_story_review.js +333 -0
- package/dist/simulation/toolkit/dynamic_storyteller.d.ts +77 -0
- package/dist/simulation/toolkit/dynamic_storyteller.js +114 -0
- package/dist/simulation/toolkit/dynamic_storyteller_runtime.d.ts +26 -0
- package/dist/simulation/toolkit/dynamic_storyteller_runtime.js +126 -0
- package/dist/simulation/toolkit/dynamic_world.d.ts +22 -0
- package/dist/simulation/toolkit/dynamic_world.js +377 -0
- package/dist/simulation/toolkit/structured_output.d.ts +5 -0
- package/dist/simulation/toolkit/structured_output.js +321 -0
- package/dist/simulation/types/world.d.ts +2 -0
- package/dist/simulation/world/artifact_store.js +1 -1
- package/dist/simulation/world/memory_manager.d.ts +5 -0
- package/dist/simulation/world/memory_manager.js +17 -2
- package/dist/simulation/world/state.d.ts +3 -2
- package/dist/simulation/world/state.js +15 -5
- package/dist/skills/bundled/measurement-validation/SKILL.md +144 -0
- package/dist/terminal_attach.d.ts +1 -0
- package/dist/terminal_attach.js +113 -0
- package/dist/tool_progress.d.ts +3 -0
- package/dist/tool_progress.js +27 -0
- package/dist/types.d.ts +145 -10
- package/dist/types.js +3 -0
- package/dist/ui/core/input.d.ts +3 -0
- package/dist/ui/core/input_segments.d.ts +18 -1
- package/dist/ui/core/input_segments.js +131 -47
- package/dist/ui/core/input_state.d.ts +12 -0
- package/dist/ui/core/layout_yoga.d.ts +1 -1
- package/dist/ui/core/turn_metadata.d.ts +5 -0
- package/dist/ui/core/turn_metadata.js +22 -0
- package/dist/ui/ink/render.d.ts +2 -1
- package/dist/ui/ink/render.js +6 -5
- package/dist/ui/ratatui/headless_pane_manager.d.ts +14 -1
- package/dist/ui/ratatui/headless_pane_manager.js +293 -104
- package/dist/ui/ratatui/index.d.ts +1 -0
- package/dist/ui/ratatui/input.d.ts +4 -0
- package/dist/ui/ratatui/input.js +15 -0
- package/dist/ui/ratatui/ipc_path.d.ts +2 -0
- package/dist/ui/ratatui/ipc_path.js +29 -1
- package/dist/ui/ratatui/mux_persistence.d.ts +3 -1
- package/dist/ui/ratatui/mux_persistence.js +139 -1
- package/dist/ui/ratatui/pane_relay.d.ts +1 -1
- package/dist/ui/ratatui/pane_relay.js +55 -27
- package/dist/ui/ratatui/process.d.ts +17 -1
- package/dist/ui/ratatui/process.js +80 -7
- package/dist/ui/ratatui/protocol.d.ts +236 -1
- package/dist/ui/ratatui/protocol.js +90 -0
- package/dist/ui/scrollback.d.ts +2 -1
- package/dist/ui/scrollback.js +9 -4
- package/dist/ui/stream_typewriter.d.ts +8 -3
- package/dist/ui/stream_typewriter.js +30 -1
- package/dist/ui/streaming_scrollback.d.ts +1 -0
- package/dist/ui/streaming_scrollback.js +1 -1
- package/dist/ui/transcript_render_cache.js +10 -0
- package/dist/ui/views/activity_line.d.ts +5 -3
- package/dist/ui/views/activity_line.js +65 -7
- package/dist/ui/views/app.d.ts +6 -3
- package/dist/ui/views/app.js +17 -6
- package/dist/ui/views/completion_menu.js +10 -5
- package/dist/ui/views/input_area.d.ts +7 -3
- package/dist/ui/views/input_area.js +15 -9
- package/dist/ui/views/message_list.d.ts +4 -1
- package/dist/ui/views/message_list.js +89 -19
- package/dist/ui/views/queue_panel.d.ts +3 -1
- package/dist/ui/views/queue_panel.js +9 -2
- package/dist/ui/views/status_bar.d.ts +4 -2
- package/dist/ui/views/status_bar.js +28 -13
- package/dist/ui/views/theme.d.ts +2 -0
- package/dist/ui/views/theme.js +2 -0
- package/dist/ui/widgets/color_panel.js +18 -0
- package/dist/ui/widgets/form.js +8 -0
- package/dist/ui/widgets/log_view.js +7 -0
- package/dist/ui/widgets/navigator_panel.js +8 -0
- package/dist/ui/widgets/prompt_viewer.js +2 -0
- package/dist/ui/widgets/questionnaire.d.ts +2 -0
- package/dist/ui/widgets/questionnaire.js +79 -16
- package/dist/ui/widgets/resume_panel.d.ts +2 -0
- package/dist/ui/widgets/resume_panel.js +26 -15
- package/dist/ui/widgets/rewind_panel.d.ts +2 -2
- package/dist/ui/widgets/rewind_panel.js +4 -2
- package/dist/ui/widgets/select.js +16 -27
- package/dist/ui/widgets/settings_panel.js +16 -0
- package/dist/ui/widgets/status_line_panel.d.ts +1 -0
- package/dist/ui/widgets/status_line_panel.js +30 -4
- package/dist/ui/widgets/text_input.d.ts +2 -0
- package/dist/ui/widgets/text_input.js +15 -1
- package/dist/ui/widgets/types.d.ts +2 -0
- package/dist/usage_projection.d.ts +24 -0
- package/dist/usage_projection.js +130 -0
- package/dist/usage_snapshot.d.ts +36 -0
- package/dist/usage_snapshot.js +131 -0
- package/dist/utils/assistant_message.d.ts +2 -0
- package/dist/utils/assistant_message.js +5 -0
- package/dist/utils/atomic_write.d.ts +6 -2
- package/dist/utils/atomic_write.js +29 -4
- package/dist/utils/checked_shell.d.ts +25 -0
- package/dist/utils/checked_shell.js +107 -0
- package/dist/utils/compaction.d.ts +4 -1
- package/dist/utils/compaction.js +31 -7
- package/dist/utils/context.d.ts +4 -4
- package/dist/utils/context.js +14 -12
- package/dist/utils/deepseek.d.ts +2 -2
- package/dist/utils/deepseek.js +13 -5
- package/dist/utils/ephemeral.js +4 -0
- package/dist/utils/ephemeral_tools.d.ts +18 -0
- package/dist/utils/ephemeral_tools.js +97 -0
- package/dist/utils/jev_client.d.ts +4 -0
- package/dist/utils/jev_client.js +15 -0
- package/dist/utils/model_cache.d.ts +15 -0
- package/dist/utils/model_cache.js +143 -0
- package/dist/utils/models.d.ts +4 -2
- package/dist/utils/models.js +12 -16
- package/dist/utils/reasoning.d.ts +8 -1
- package/dist/utils/reasoning.js +31 -11
- package/dist/utils/router_catalog.d.ts +49 -0
- package/dist/utils/router_catalog.js +271 -0
- package/dist/utils/sandbox.d.ts +9 -0
- package/dist/utils/sandbox.js +118 -15
- package/dist/utils/shell.d.ts +7 -0
- package/dist/utils/shell.js +98 -34
- package/dist/utils/subprocess_env.d.ts +3 -0
- package/dist/utils/subprocess_env.js +27 -1
- package/dist/web/accounts_mirror.d.ts +3 -1
- package/dist/web/accounts_mirror.js +13 -9
- package/dist/web/child_publication.d.ts +17 -0
- package/dist/web/child_publication.js +45 -0
- package/dist/web/mirror_authenticator.d.ts +31 -11
- package/dist/web/mirror_authenticator.js +67 -17
- package/dist/web/mirror_client.d.ts +31 -4
- package/dist/web/mirror_client.js +189 -23
- package/dist/web/mirror_stream.d.ts +84 -22
- package/dist/web/mirror_stream.js +676 -95
- package/dist/web/observer_query_redaction.d.ts +6 -0
- package/dist/web/observer_query_redaction.js +58 -0
- package/dist/web/pane_registry.d.ts +2 -0
- package/dist/web/pane_registry.js +86 -22
- package/dist/web/tool_image.d.ts +6 -0
- package/dist/web/tool_image.js +17 -0
- package/dist/web/view_plugin.d.ts +14 -0
- package/dist/web/view_plugin.js +23 -1
- package/dist/worker/executor.js +31 -12
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/toolsets.js +3 -1
- package/dist/worker/types.d.ts +12 -1
- package/dist/workflows/registry.js +1 -0
- package/dist/workflows/registry_handle.d.ts +2 -0
- package/dist/workflows/runtime.d.ts +2 -0
- package/dist/workflows/runtime.js +1 -0
- package/dist/workspace_agent.d.ts +7 -0
- package/dist/workspace_agent.js +36 -0
- package/dist/workspace_collision.d.ts +76 -0
- package/dist/workspace_collision.js +688 -0
- package/dist/workspace_layout.d.ts +18 -0
- package/dist/workspace_layout.js +121 -0
- package/dist/workspace_runtime.d.ts +44 -0
- package/dist/workspace_runtime.js +82 -0
- package/dist/workspace_session_context.d.ts +62 -0
- package/dist/workspace_session_context.js +160 -0
- package/dist/zlm-embed.mjs +32518 -9615
- package/dist/zlm.js +1 -0
- package/node_modules/@zerg/model-contracts/LICENSE.md +375 -0
- package/node_modules/@zerg/model-contracts/README.md +90 -0
- package/node_modules/@zerg/model-contracts/index.d.ts +20 -0
- package/node_modules/@zerg/model-contracts/index.js +223 -0
- package/node_modules/@zerg/model-contracts/package.json +8 -0
- package/node_modules/glob/node_modules/brace-expansion/index.js +78 -22
- package/node_modules/glob/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/index.js +78 -22
- package/node_modules/readdir-glob/node_modules/brace-expansion/package.json +1 -1
- package/package.json +45 -24
- package/packages/model-contracts/LICENSE.md +375 -0
- package/packages/model-contracts/README.md +90 -0
- package/packages/model-contracts/index.d.ts +20 -0
- package/packages/model-contracts/index.js +223 -0
- package/packages/model-contracts/package.json +8 -0
- package/remote-broker/Dockerfile +10 -0
- package/remote-broker/README.md +308 -0
- package/remote-broker/archive.py +1227 -0
- package/remote-broker/cutover.py +761 -0
- package/remote-broker/requirements.txt +5 -0
- package/remote-broker/resources.example.json +6 -0
- package/remote-broker/resources.write-staging.example.json +18 -0
- package/remote-broker/retained.py +686 -0
- package/remote-broker/retained_cleanup.py +550 -0
- package/remote-broker/server.py +648 -0
- package/scripts/build-remote-broker.mjs +13 -0
- package/scripts/ensure-local-packages.mjs +6 -0
- package/scripts/node-pty-helpers.mjs +103 -0
package/dist/app/activity.js
CHANGED
|
@@ -1,33 +1,84 @@
|
|
|
1
1
|
import { AGENT_STATUS_LABELS } from '../types.js';
|
|
2
2
|
import { getToolVerb } from '../utils/tool_verbs.js';
|
|
3
|
+
import { parseEvidenceSnapshot } from '../agent/runtime/evidence.js';
|
|
4
|
+
import { parseTaskHandoffProjection } from '../session_handoff_contract.js';
|
|
5
|
+
import { parseToolProgress } from '../tool_progress.js';
|
|
3
6
|
export function applyAgentEventToState(previous, event) {
|
|
4
7
|
// Preserve startedAt across mid-run re-entries (e.g. after a tool round-trip)
|
|
5
8
|
// so the activity-line elapsed timer has a stable origin.
|
|
6
9
|
const startedAt = previous.startedAt ?? new Date();
|
|
7
10
|
switch (event.type) {
|
|
11
|
+
case 'task_handoff': {
|
|
12
|
+
if (!event.sessionId)
|
|
13
|
+
return previous;
|
|
14
|
+
const projection = event.projection === null ? null : parseTaskHandoffProjection(event.projection);
|
|
15
|
+
if (event.projection !== null && !projection)
|
|
16
|
+
return previous;
|
|
17
|
+
const retained = previous.taskHandoff;
|
|
18
|
+
if (projection && retained?.sessionId === event.sessionId
|
|
19
|
+
&& retained.projection?.snapshot.source.sessionId === projection.snapshot.source.sessionId
|
|
20
|
+
&& retained.projection.snapshot.revision >= projection.snapshot.revision)
|
|
21
|
+
return previous;
|
|
22
|
+
return { ...previous, taskHandoff: { sessionId: event.sessionId, projection } };
|
|
23
|
+
}
|
|
24
|
+
case 'evidence': {
|
|
25
|
+
const snapshot = parseEvidenceSnapshot(event.snapshot);
|
|
26
|
+
if (!snapshot || !event.sessionId || (previous.evidence?.sessionId === event.sessionId
|
|
27
|
+
&& previous.evidence.snapshot.revision >= snapshot.revision))
|
|
28
|
+
return previous;
|
|
29
|
+
return { ...previous, evidence: { sessionId: event.sessionId, snapshot } };
|
|
30
|
+
}
|
|
31
|
+
case 'command_wait':
|
|
32
|
+
return { ...previous, status: 'tool_use', startedAt, waiting: event.waiting, requestRetry: undefined, error: undefined };
|
|
33
|
+
case 'command_wait_end':
|
|
34
|
+
return previous.waiting?.toolCallId === event.toolCallId ? { ...previous, waiting: undefined } : previous;
|
|
8
35
|
case 'thinking_start':
|
|
9
|
-
return { ...previous, status: 'thinking', currentTool: undefined, startedAt, error: undefined };
|
|
10
|
-
case '
|
|
11
|
-
return { ...previous, status: '
|
|
36
|
+
return { ...previous, status: 'thinking', currentTool: undefined, startedAt, error: undefined, requestRetry: undefined, waiting: undefined, toolProgress: undefined };
|
|
37
|
+
case 'api_retry':
|
|
38
|
+
return { ...previous, status: 'thinking', currentTool: undefined, startedAt, error: undefined,
|
|
39
|
+
waiting: undefined, toolProgress: undefined, requestRetry: { phase: event.phase ?? 'retry', attempt: event.attempt, delay: event.delay, ...(event.rateLimited ? { rateLimited: true } : {}) } };
|
|
40
|
+
case 'tool_start': {
|
|
41
|
+
const toolProgress = parseToolProgress({ toolCallId: event.toolCallId, tool: event.tool,
|
|
42
|
+
progress: { startedAt: Date.now(), outputBytes: 0, outputLines: 0, latestLine: '' } });
|
|
43
|
+
return { ...previous, status: 'tool_use', currentTool: event.tool, startedAt, error: undefined, requestRetry: undefined, waiting: undefined,
|
|
44
|
+
toolProgress: toolProgress ?? undefined };
|
|
45
|
+
}
|
|
46
|
+
case 'tool_progress': {
|
|
47
|
+
const observed = parseToolProgress({ toolCallId: event.toolCallId, tool: event.tool, progress: event.progress });
|
|
48
|
+
const owned = previous.toolProgress;
|
|
49
|
+
if (!observed || previous.status !== 'tool_use' || !owned
|
|
50
|
+
|| owned.toolCallId !== observed.toolCallId || owned.tool !== observed.tool
|
|
51
|
+
|| observed.progress.outputBytes < owned.progress.outputBytes
|
|
52
|
+
|| observed.progress.outputLines < owned.progress.outputLines
|
|
53
|
+
|| (owned.progress.lastOutputAt !== undefined
|
|
54
|
+
&& (observed.progress.lastOutputAt === undefined || observed.progress.lastOutputAt < owned.progress.lastOutputAt)))
|
|
55
|
+
return previous;
|
|
56
|
+
return { ...previous, toolProgress: observed };
|
|
57
|
+
}
|
|
58
|
+
case 'tool_end':
|
|
59
|
+
return previous.toolProgress?.toolCallId === event.toolCallId
|
|
60
|
+
? { ...previous, toolProgress: undefined } : previous;
|
|
12
61
|
case 'stream_start':
|
|
13
62
|
case 'stream_end':
|
|
14
|
-
return { ...previous, status: 'streaming', startedAt, error: undefined };
|
|
63
|
+
return { ...previous, status: 'streaming', startedAt, error: undefined, requestRetry: undefined, waiting: undefined, toolProgress: undefined };
|
|
15
64
|
case 'reasoning_delta':
|
|
16
|
-
if (previous.status === 'thinking' && previous.startedAt && previous.error === undefined) {
|
|
65
|
+
if (previous.status === 'thinking' && previous.startedAt && previous.error === undefined && !previous.requestRetry && !previous.waiting && !previous.toolProgress) {
|
|
17
66
|
return previous;
|
|
18
67
|
}
|
|
19
|
-
return { ...previous, status: 'thinking', startedAt, error: undefined };
|
|
68
|
+
return { ...previous, status: 'thinking', startedAt, error: undefined, requestRetry: undefined, waiting: undefined, toolProgress: undefined };
|
|
20
69
|
case 'stream_delta':
|
|
21
70
|
// Hot path: one event per token. Skip the allocation when the status is
|
|
22
71
|
// already streaming so subscribers don't fire per-token no-op updates.
|
|
23
|
-
if (previous.status === 'streaming' && previous.startedAt && previous.error === undefined) {
|
|
72
|
+
if (previous.status === 'streaming' && previous.startedAt && previous.error === undefined && !previous.waiting && !previous.toolProgress) {
|
|
24
73
|
return previous;
|
|
25
74
|
}
|
|
26
|
-
return { ...previous, status: 'streaming', startedAt, error: undefined };
|
|
75
|
+
return { ...previous, status: 'streaming', startedAt, error: undefined, requestRetry: undefined, waiting: undefined, toolProgress: undefined };
|
|
27
76
|
case 'tool_error':
|
|
28
|
-
|
|
77
|
+
if (previous.toolProgress && previous.toolProgress.toolCallId !== event.toolCallId)
|
|
78
|
+
return previous;
|
|
79
|
+
return { ...previous, status: 'error', currentTool: event.tool, error: event.error, requestRetry: undefined, waiting: undefined, toolProgress: undefined };
|
|
29
80
|
case 'error':
|
|
30
|
-
return { ...previous, status: 'error', error: event.error };
|
|
81
|
+
return { ...previous, status: 'error', error: event.error, requestRetry: undefined, waiting: undefined, toolProgress: undefined };
|
|
31
82
|
default:
|
|
32
83
|
return previous;
|
|
33
84
|
}
|
|
@@ -37,14 +88,19 @@ export function buildActivityDisplayState(state, thinkingLabel) {
|
|
|
37
88
|
case 'thinking':
|
|
38
89
|
return {
|
|
39
90
|
wireStatus: 'thinking',
|
|
40
|
-
label: thinkingLabel,
|
|
91
|
+
label: state.requestRetry ? retryActivityLabel(state.requestRetry) : thinkingLabel,
|
|
92
|
+
...(state.requestRetry?.rateLimited ? { verb: retryActivityLabel(state.requestRetry) } : {}),
|
|
41
93
|
};
|
|
42
94
|
case 'tool_use': {
|
|
95
|
+
if (state.waiting)
|
|
96
|
+
return { wireStatus: 'tool_executing', verb: 'Waiting for command', label: 'Waiting for command', waiting: state.waiting,
|
|
97
|
+
...(state.toolProgress ? { toolProgress: state.toolProgress } : {}) };
|
|
43
98
|
const verb = state.currentTool ? getToolVerb(state.currentTool) : 'Running tool';
|
|
44
99
|
return {
|
|
45
100
|
wireStatus: 'tool_executing',
|
|
46
101
|
verb,
|
|
47
102
|
label: verb,
|
|
103
|
+
...(state.toolProgress ? { toolProgress: state.toolProgress } : {}),
|
|
48
104
|
};
|
|
49
105
|
}
|
|
50
106
|
case 'streaming':
|
|
@@ -74,8 +130,10 @@ export function buildActivityDisplayState(state, thinkingLabel) {
|
|
|
74
130
|
export function getAgentActionLabel(state) {
|
|
75
131
|
switch (state.status) {
|
|
76
132
|
case 'thinking':
|
|
77
|
-
return AGENT_STATUS_LABELS.thinking;
|
|
133
|
+
return state.requestRetry ? retryActivityLabel(state.requestRetry) : AGENT_STATUS_LABELS.thinking;
|
|
78
134
|
case 'tool_use':
|
|
135
|
+
if (state.waiting)
|
|
136
|
+
return 'Waiting for command';
|
|
79
137
|
return getToolVerb(state.currentTool || 'tool');
|
|
80
138
|
case 'streaming':
|
|
81
139
|
return `${AGENT_STATUS_LABELS.streaming} response`;
|
|
@@ -83,6 +141,17 @@ export function getAgentActionLabel(state) {
|
|
|
83
141
|
return null;
|
|
84
142
|
}
|
|
85
143
|
}
|
|
144
|
+
function retryActivityLabel(retry) {
|
|
145
|
+
if (retry.rateLimited)
|
|
146
|
+
return `Rate-limited, waiting ${Math.ceil(retry.delay / 1000)}s`;
|
|
147
|
+
return retry.phase === 'recovery' ? 'Waiting for LLM endpoint' : 'Retrying LLM request';
|
|
148
|
+
}
|
|
149
|
+
export function formatApiRetryNotice(event) {
|
|
150
|
+
const attempts = event.phase === 'recovery'
|
|
151
|
+
? `recovery attempt ${event.attempt - event.maxAttempts + 1}; current task retained`
|
|
152
|
+
: `attempt ${event.attempt}/${event.maxAttempts}`;
|
|
153
|
+
return `⚠️ ${event.reason}. Retrying in ${event.delay / 1000}s... (${attempts})`;
|
|
154
|
+
}
|
|
86
155
|
/**
|
|
87
156
|
* Placeholder text for the composer while the agent is active.
|
|
88
157
|
* Shared by every renderer so Ink and Ratatui show the same prompt.
|
|
@@ -8,9 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Agent } from '../agent/index.js';
|
|
10
10
|
import type { AgentEvent } from '../types.js';
|
|
11
|
+
import type { ModelUsageObserver } from '../types.js';
|
|
11
12
|
import { type AgentFactoryOptions } from '../agent/factory.js';
|
|
12
13
|
import type { Message } from '../types.js';
|
|
14
|
+
import type { ToolCheckpointHandler } from '../agent/runtime/tool_checkpoints.js';
|
|
15
|
+
import type { SteeringAdmissionCheckpointHandler } from '../agent/agent.js';
|
|
13
16
|
interface AgentRunnerOptions extends Partial<AgentFactoryOptions> {
|
|
17
|
+
/** Profile selection may wait for sign-in while retaining its session. */
|
|
18
|
+
allowUnavailableRouterAuth?: boolean;
|
|
14
19
|
cwdProvider?: () => string;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
@@ -52,7 +57,7 @@ export declare class AgentRunLifecycle {
|
|
|
52
57
|
* The callback should contain the renderer-specific event switch.
|
|
53
58
|
* @returns The agent response and whether it was cancelled
|
|
54
59
|
*/
|
|
55
|
-
run(agent: Agent, messages: Message[], onEvent: (event: AgentEvent) => void, takeSteering?: () => Message[]): Promise<AgentRunResult>;
|
|
60
|
+
run(agent: Agent, messages: Message[], onEvent: (event: AgentEvent) => void, takeSteering?: () => Message[], toolCheckpoint?: ToolCheckpointHandler, steeringAdmission?: SteeringAdmissionCheckpointHandler, onUsage?: ModelUsageObserver): Promise<AgentRunResult>;
|
|
56
61
|
/**
|
|
57
62
|
* Cancel the currently active run (if any).
|
|
58
63
|
* Aborts the in-flight API call and stops event delivery.
|
package/dist/app/agent_runner.js
CHANGED
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
import { AgentError } from '../agent/index.js';
|
|
10
10
|
import { createAgentFromConfig, resolveAgentBackendFromConfig } from '../agent/factory.js';
|
|
11
11
|
import { configStore } from '../config.js';
|
|
12
|
+
import { RouterConfigurationError } from '../router_auth.js';
|
|
12
13
|
import { setBackgroundRegistry, getBackgroundRegistry, clearBackgroundRegistry } from '../agent/tools/index.js';
|
|
13
14
|
import { BackgroundTaskRegistry } from '../agent/background_registry.js';
|
|
14
15
|
import { InProcessWorkerExecutor, setWorkerExecutor, clearWorkerExecutor } from '../worker/index.js';
|
|
15
16
|
import { configureWorkflowRegistry, shutdownAndClearWorkflowRegistry } from '../workflows/registry_handle.js';
|
|
16
17
|
import { workflowsEnabled } from '../workflows/config.js';
|
|
17
|
-
import { isCodexAppServerProvider } from '../agent/backends/provider_ids.js';
|
|
18
|
+
import { isCodexAppServerProvider, normalizeProviderId } from '../agent/backends/provider_ids.js';
|
|
19
|
+
import { admitPermissionProvider, projectPermissionPolicy, resolvePermissionProfile } from '../config/permissions.js';
|
|
18
20
|
/**
|
|
19
21
|
* Ensure the BackgroundTaskRegistry tracks the current shared executor.
|
|
20
22
|
* Reuses the existing registry if one is already set — background tasks
|
|
@@ -40,11 +42,6 @@ function configureWorkflowRegistryContext(executor, cwdProvider, execution) {
|
|
|
40
42
|
};
|
|
41
43
|
configureWorkflowRegistry(registryOptions);
|
|
42
44
|
}
|
|
43
|
-
function resolveWorkerPermissionProfile() {
|
|
44
|
-
const config = configStore.get();
|
|
45
|
-
const id = config.permissionProfile;
|
|
46
|
-
return id ? config.permissionProfiles?.[id] : undefined;
|
|
47
|
-
}
|
|
48
45
|
function providerSupportsWorkflowWorkers(provider) {
|
|
49
46
|
return !isCodexAppServerProvider(provider);
|
|
50
47
|
}
|
|
@@ -58,23 +55,38 @@ function providerSupportsWorkflowWorkers(provider) {
|
|
|
58
55
|
* @returns Agent instance or null if no usable credentials are configured
|
|
59
56
|
*/
|
|
60
57
|
export function createAgentWithConfig(overrides = {}) {
|
|
61
|
-
const { cwdProvider = () => process.cwd(), ...agentOverrides } = overrides;
|
|
58
|
+
const { cwdProvider = () => process.cwd(), allowUnavailableRouterAuth = false, ...agentOverrides } = overrides;
|
|
62
59
|
const config = configStore.get();
|
|
60
|
+
const permissionProfile = resolvePermissionProfile(config);
|
|
61
|
+
admitPermissionProvider(permissionProfile, projectPermissionPolicy(config), normalizeProviderId(agentOverrides.provider ?? config.provider ?? configStore.getProvider()));
|
|
63
62
|
// provider/model are intentionally NOT passed here: the config snapshot
|
|
64
63
|
// already carries the resolved values (get() folds in CLI/session
|
|
65
64
|
// overrides), and passing them as renderer intent would make the
|
|
66
65
|
// repo-scoped override (<cwd>/.ztc/config.json) unreachable. Renderer
|
|
67
66
|
// overrides still flow via agentOverrides and win.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
let resolvedBackend;
|
|
68
|
+
let deferredRouterAuth = false;
|
|
69
|
+
try {
|
|
70
|
+
resolvedBackend = resolveAgentBackendFromConfig({
|
|
71
|
+
config,
|
|
72
|
+
apiKey: overrides.apiKey,
|
|
73
|
+
// Backend resolution validates the endpoint only when that provider is
|
|
74
|
+
// selected; unrelated saved settings must not block another provider.
|
|
75
|
+
openaiCompatibleBaseUrl: configStore.getOpenAICompatibleSettings().baseUrl,
|
|
76
|
+
emulationId: configStore.getEmulationId(),
|
|
77
|
+
cwd: cwdProvider(),
|
|
78
|
+
...agentOverrides,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (!allowUnavailableRouterAuth || !(error instanceof RouterConfigurationError) || !error.needsSignIn)
|
|
83
|
+
throw error;
|
|
84
|
+
resolvedBackend = null;
|
|
85
|
+
deferredRouterAuth = true;
|
|
86
|
+
}
|
|
76
87
|
// Set up shared WorkerExecutor so delegate/background/batch can access the API
|
|
77
88
|
if (resolvedBackend) {
|
|
89
|
+
admitPermissionProvider(permissionProfile, projectPermissionPolicy(config), resolvedBackend.provider);
|
|
78
90
|
const executor = new InProcessWorkerExecutor({
|
|
79
91
|
provider: resolvedBackend.provider,
|
|
80
92
|
apiKey: resolvedBackend.apiKey,
|
|
@@ -86,7 +98,8 @@ export function createAgentWithConfig(overrides = {}) {
|
|
|
86
98
|
approvalRequester: overrides.hookApprovalRequester,
|
|
87
99
|
backend: resolvedBackend.backend,
|
|
88
100
|
toolPermissions: config.toolPermissions,
|
|
89
|
-
permissionProfile
|
|
101
|
+
permissionProfile,
|
|
102
|
+
commandPolicy: { profileId: config.permissionProfile ?? 'trusted', profile: permissionProfile, sandbox: config.sandbox },
|
|
90
103
|
});
|
|
91
104
|
setWorkerExecutor(executor);
|
|
92
105
|
ensureBackgroundRegistry(executor);
|
|
@@ -108,10 +121,12 @@ export function createAgentWithConfig(overrides = {}) {
|
|
|
108
121
|
clearBackgroundRegistry();
|
|
109
122
|
void shutdownAndClearWorkflowRegistry(5000);
|
|
110
123
|
}
|
|
124
|
+
if (deferredRouterAuth)
|
|
125
|
+
return null;
|
|
111
126
|
return createAgentFromConfig({
|
|
112
127
|
config,
|
|
113
128
|
apiKey: overrides.apiKey,
|
|
114
|
-
openaiCompatibleBaseUrl: configStore.
|
|
129
|
+
openaiCompatibleBaseUrl: configStore.getOpenAICompatibleSettings().baseUrl,
|
|
115
130
|
emulationId: configStore.getEmulationId(),
|
|
116
131
|
cwd: cwdProvider(),
|
|
117
132
|
...agentOverrides,
|
|
@@ -140,7 +155,7 @@ export class AgentRunLifecycle {
|
|
|
140
155
|
* The callback should contain the renderer-specific event switch.
|
|
141
156
|
* @returns The agent response and whether it was cancelled
|
|
142
157
|
*/
|
|
143
|
-
async run(agent, messages, onEvent, takeSteering) {
|
|
158
|
+
async run(agent, messages, onEvent, takeSteering, toolCheckpoint, steeringAdmission, onUsage) {
|
|
144
159
|
// Abort previous run if still in flight to avoid concurrent API calls
|
|
145
160
|
if (this.abortController) {
|
|
146
161
|
this.abortController.abort();
|
|
@@ -160,7 +175,7 @@ export class AgentRunLifecycle {
|
|
|
160
175
|
// iterates. Renderers own their controller state and persist the visible
|
|
161
176
|
// final turn themselves, so keep those API-only mutations off the live
|
|
162
177
|
// transcript array.
|
|
163
|
-
const response = await agent.run(messages.slice(), controller.signal, takeSteering);
|
|
178
|
+
const response = await agent.run(messages.slice(), controller.signal, takeSteering, toolCheckpoint, steeringAdmission, onUsage);
|
|
164
179
|
const cancelled = !isActive();
|
|
165
180
|
return { response: cancelled ? null : response, cancelled };
|
|
166
181
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Shared helpers for building CommandContext objects used by command handlers.
|
|
5
|
-
* Eliminates duplication between TUI (cli_ratatui.ts) and headless (headless.ts) renderers.
|
|
6
|
-
*/
|
|
7
|
-
import { listModels } from '../utils/models.js';
|
|
1
|
+
import { discoverRouterCatalog, readRouterCatalog, routerModelIds, routerCatalogScope } from '../utils/router_catalog.js';
|
|
2
|
+
import { loadModelCatalog } from './model_catalog_cache.js';
|
|
8
3
|
import { getSkills } from '../skills/registry.js';
|
|
9
4
|
import { runShellCommand } from '../utils/shell.js';
|
|
10
5
|
import { configStore } from '../config.js';
|
|
@@ -33,6 +28,58 @@ export function routeUserInput(text) {
|
|
|
33
28
|
const parts = text.slice(1).trimEnd().split(/\s+/);
|
|
34
29
|
const cmd = parts[0];
|
|
35
30
|
if (!cmd.includes('/')) {
|
|
31
|
+
if (cmd === 'job' && parts[1] === 'pin') {
|
|
32
|
+
// Only parse pin options. The command after -- belongs to the shell and
|
|
33
|
+
// must retain its exact quotes, argument spaces and metacharacters.
|
|
34
|
+
const tokens = [];
|
|
35
|
+
let token = '';
|
|
36
|
+
let quote = '';
|
|
37
|
+
let braces = 0;
|
|
38
|
+
let escaped = false;
|
|
39
|
+
const source = text.slice(1).trimEnd();
|
|
40
|
+
for (let i = 0; i < source.length; i++) {
|
|
41
|
+
const char = source[i];
|
|
42
|
+
if (!quote && !braces && /\s/.test(char)) {
|
|
43
|
+
if (token) {
|
|
44
|
+
tokens.push(token);
|
|
45
|
+
if (token === '--') {
|
|
46
|
+
tokens.push(source.slice(i + 1));
|
|
47
|
+
return { type: 'command', cmd, args: tokens.slice(1) };
|
|
48
|
+
}
|
|
49
|
+
token = '';
|
|
50
|
+
}
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
token += char;
|
|
54
|
+
if (escaped) {
|
|
55
|
+
escaped = false;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (quote && char === '\\') {
|
|
59
|
+
escaped = true;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (quote) {
|
|
63
|
+
if (char === quote)
|
|
64
|
+
quote = '';
|
|
65
|
+
}
|
|
66
|
+
else if (char === '"' || char === "'")
|
|
67
|
+
quote = char;
|
|
68
|
+
else if (char === '{')
|
|
69
|
+
braces++;
|
|
70
|
+
else if (char === '}')
|
|
71
|
+
braces = Math.max(0, braces - 1);
|
|
72
|
+
}
|
|
73
|
+
if (token)
|
|
74
|
+
tokens.push(token);
|
|
75
|
+
return { type: 'command', cmd, args: tokens.slice(1) };
|
|
76
|
+
}
|
|
77
|
+
if (cmd.toLowerCase() === 'fork' || cmd.toLowerCase() === 'side') {
|
|
78
|
+
// A fork's body is authored task data, not tokenized command options.
|
|
79
|
+
// Remove exactly the command separator and retain the remaining bytes.
|
|
80
|
+
const task = text.slice(cmd.length + 2);
|
|
81
|
+
return { type: 'command', cmd, args: task.length ? [task] : [] };
|
|
82
|
+
}
|
|
36
83
|
return { type: 'command', cmd, args: parts.slice(1) };
|
|
37
84
|
}
|
|
38
85
|
}
|
|
@@ -43,19 +90,66 @@ export function routeUserInput(text) {
|
|
|
43
90
|
* The models.list implementation is identical across all renderers.
|
|
44
91
|
*/
|
|
45
92
|
export function buildModelsController(config) {
|
|
93
|
+
const listRouter = async (provider, options) => {
|
|
94
|
+
options?.signal?.throwIfAborted();
|
|
95
|
+
const connection = config.getRouterCatalogConnection?.();
|
|
96
|
+
const preview = connection && readRouterCatalog(connection);
|
|
97
|
+
const age = preview ? Date.now() - preview.fetchedAt : Infinity;
|
|
98
|
+
if (!options?.refresh && preview && !preview.authRequired && age >= 0 && age < 24 * 60 * 60 * 1000) {
|
|
99
|
+
// Scoped disk rows preview choices; a shared background refresh owns
|
|
100
|
+
// qualification and adoption. Editing never waits on a stale catalog.
|
|
101
|
+
if (age >= 30_000)
|
|
102
|
+
void buildModelsController(config).catalog(options?.signal, { refresh: true }).catch(() => { });
|
|
103
|
+
return routerModelIds(preview, provider);
|
|
104
|
+
}
|
|
105
|
+
return routerModelIds(await buildModelsController(config).catalog(options?.signal, options), provider);
|
|
106
|
+
};
|
|
46
107
|
return {
|
|
108
|
+
catalog: async (signal, options) => {
|
|
109
|
+
try {
|
|
110
|
+
const connection = config.getRouterCatalogConnection?.();
|
|
111
|
+
if (!connection)
|
|
112
|
+
throw new Error('Router discovery requires a Router login. Run ztc auth login.');
|
|
113
|
+
const scope = routerCatalogScope(connection);
|
|
114
|
+
signal?.throwIfAborted();
|
|
115
|
+
const previous = readRouterCatalog(connection);
|
|
116
|
+
const age = previous === undefined ? Infinity : Date.now() - previous.fetchedAt;
|
|
117
|
+
// Startup may reuse this process's live discovery, but always refreshes
|
|
118
|
+
// disk previews. An explicit refresh still forces a new HTTP request.
|
|
119
|
+
const reuse = !options?.refresh || options.refresh === 'startup' && !!readRouterCatalog(connection, { liveOnly: true });
|
|
120
|
+
const catalog = reuse && previous && !previous.authRequired && age >= 0 && age < 30_000
|
|
121
|
+
? previous : await discoverRouterCatalog(connection, signal);
|
|
122
|
+
signal?.throwIfAborted();
|
|
123
|
+
const active = config.getRouterCatalogConnection?.();
|
|
124
|
+
if (!active || routerCatalogScope(active) !== scope)
|
|
125
|
+
throw new Error('Router discovery context changed. Retry model discovery.');
|
|
126
|
+
await config.adoptRouterCatalog?.(catalog);
|
|
127
|
+
return catalog;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
const cached = config.getRouterCatalog?.();
|
|
131
|
+
if (!signal?.aborted && cached)
|
|
132
|
+
return { ...cached, ...(error instanceof Error && /authentication|expired|login|origin/i.test(error.message) ? { authRequired: true } : {}) };
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
47
136
|
list: async (provider, options) => {
|
|
137
|
+
if ((options?.authMode ?? config.getAuthMode?.()) === 'zrouter') {
|
|
138
|
+
return listRouter(provider ?? config.getProvider(), options);
|
|
139
|
+
}
|
|
48
140
|
const llm = config.resolveLLMBackendConfig({ provider,
|
|
49
141
|
config: options?.authMode ? { ...config.get(), authMode: options.authMode } : undefined });
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
142
|
+
if (llm.useProxy) {
|
|
143
|
+
return listRouter(llm.provider, options);
|
|
144
|
+
}
|
|
145
|
+
return loadModelCatalog({
|
|
53
146
|
signal: options?.signal,
|
|
54
147
|
provider: llm.provider,
|
|
55
148
|
apiKey: llm.apiKey,
|
|
56
149
|
baseUrl: llm.provider === 'openai_compatible' ? llm.compatBaseUrl : undefined,
|
|
57
150
|
proxyUrl: llm.useProxy ? llm.proxyUrl : undefined,
|
|
58
151
|
authToken: llm.useProxy ? llm.authToken : undefined,
|
|
152
|
+
workspaceId: llm.useProxy ? config.getRouterCatalogConnection?.()?.workspaceId : undefined,
|
|
59
153
|
codexAppServerCommand: llm.codexAppServerCommand,
|
|
60
154
|
codexAppServerArgs: llm.codexAppServerArgs,
|
|
61
155
|
codexHome: llm.codexHome,
|
|
@@ -178,6 +272,7 @@ export function buildAutoSelectWidgets() {
|
|
|
178
272
|
/** Session controls do not execute the plan or change project files. */
|
|
179
273
|
const PLAN_MODE_SESSION_COMMANDS = new Set([
|
|
180
274
|
'accounts',
|
|
275
|
+
'attention',
|
|
181
276
|
'auth',
|
|
182
277
|
'config',
|
|
183
278
|
'context',
|
|
@@ -192,6 +287,7 @@ const PLAN_MODE_SESSION_COMMANDS = new Set([
|
|
|
192
287
|
'models',
|
|
193
288
|
'permissions',
|
|
194
289
|
'profile',
|
|
290
|
+
'rewind',
|
|
195
291
|
'settings',
|
|
196
292
|
'shortcuts',
|
|
197
293
|
'skills',
|
package/dist/app/controller.d.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* The state is a single immutable object that gets updated via dispatch().
|
|
8
8
|
* Subscribers are notified whenever the state changes.
|
|
9
9
|
*/
|
|
10
|
-
import type
|
|
10
|
+
import { type Message, type AgentState, type InputMode, type CanonicalInputMode, type MessageInput, type QueueEntry, type DeliveryIntent, type TodoStatus } from '../types.js';
|
|
11
11
|
import type { InputState } from '../ui/core/input_state.js';
|
|
12
12
|
import type { ContextStatus } from '../utils/context.js';
|
|
13
13
|
import type { Skill } from '../skills/types.js';
|
|
14
14
|
import type { AgentMode } from './modes.js';
|
|
15
|
+
import type { WorkspaceCollisionSnapshot } from '../workspace_collision.js';
|
|
15
16
|
export type { TodoStatus } from '../types.js';
|
|
16
17
|
export interface TodoItem {
|
|
17
18
|
/** Unique identifier for the todo */
|
|
@@ -33,6 +34,7 @@ export declare const MAX_QUEUE = 10;
|
|
|
33
34
|
*/
|
|
34
35
|
export declare const DEFAULT_TOAST_MS = 5000;
|
|
35
36
|
export interface AppState {
|
|
37
|
+
workspaceCollision: WorkspaceCollisionSnapshot | null;
|
|
36
38
|
/** Chat messages */
|
|
37
39
|
messages: Message[];
|
|
38
40
|
/** Current agent state (thinking, streaming, etc.) */
|
|
@@ -41,8 +43,8 @@ export interface AppState {
|
|
|
41
43
|
sessionId: string;
|
|
42
44
|
/** Current input state (segments, cursor, history) */
|
|
43
45
|
inputState: InputState;
|
|
44
|
-
/**
|
|
45
|
-
inputMode:
|
|
46
|
+
/** Busy Enter mode; legacy values are normalized at dispatch. */
|
|
47
|
+
inputMode: CanonicalInputMode;
|
|
46
48
|
/** Toast notification message */
|
|
47
49
|
toast: string | null;
|
|
48
50
|
/** Spinner label when agent is working */
|
|
@@ -89,10 +91,13 @@ export interface AppState {
|
|
|
89
91
|
mode: AgentMode;
|
|
90
92
|
/** Path to current plan file (when in plan mode) */
|
|
91
93
|
planFile: string | null;
|
|
92
|
-
/** Outbound message queue
|
|
94
|
+
/** Outbound message queue, updated only through canonical queue actions. */
|
|
93
95
|
queue: QueueEntry[];
|
|
94
96
|
}
|
|
95
97
|
export type AppAction = {
|
|
98
|
+
type: 'SET_WORKSPACE_COLLISION';
|
|
99
|
+
snapshot: WorkspaceCollisionSnapshot | null;
|
|
100
|
+
} | {
|
|
96
101
|
type: 'ADD_MESSAGE';
|
|
97
102
|
message: Omit<Message, 'id' | 'timestamp'>;
|
|
98
103
|
} | {
|
|
@@ -194,6 +199,9 @@ export type AppAction = {
|
|
|
194
199
|
type: 'UPDATE_QUEUE_ENTRY';
|
|
195
200
|
id: string;
|
|
196
201
|
text: string;
|
|
202
|
+
} | {
|
|
203
|
+
type: 'REORDER_QUEUE';
|
|
204
|
+
ids: string[];
|
|
197
205
|
} | {
|
|
198
206
|
type: 'CLEAR_QUEUE';
|
|
199
207
|
};
|
|
@@ -228,6 +236,7 @@ export declare class AppController {
|
|
|
228
236
|
setMessages(messages: Message[]): void;
|
|
229
237
|
clearMessages(): void;
|
|
230
238
|
setAgentState(agentState: AgentState): void;
|
|
239
|
+
setWorkspaceCollision(snapshot: WorkspaceCollisionSnapshot | null): void;
|
|
231
240
|
setInputState(inputState: InputState): void;
|
|
232
241
|
setInputStateSilent(inputState: InputState): void;
|
|
233
242
|
/**
|
|
@@ -287,6 +296,8 @@ export declare class AppController {
|
|
|
287
296
|
removeQueueEntry(id: string): void;
|
|
288
297
|
/** Rewrite a queued entry's text in place. Returns false when the id is no longer queued. */
|
|
289
298
|
updateQueueEntry(id: string, text: string): boolean;
|
|
299
|
+
/** Apply only an exact permutation of the currently accepted queue IDs. */
|
|
300
|
+
reorderQueue(ids: readonly string[]): boolean;
|
|
290
301
|
clearQueue(): void;
|
|
291
302
|
getQueue(): QueueEntry[];
|
|
292
303
|
}
|
package/dist/app/controller.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* The state is a single immutable object that gets updated via dispatch().
|
|
8
8
|
* Subscribers are notified whenever the state changes.
|
|
9
9
|
*/
|
|
10
|
+
import { normalizeInputMode } from '../types.js';
|
|
10
11
|
import { buildTodoIdentity } from './todo_state.js';
|
|
11
12
|
function getActiveTodoKey(todos) {
|
|
12
13
|
const activeIndex = todos.findIndex(todo => todo.status === 'in_progress');
|
|
@@ -41,6 +42,7 @@ export const DEFAULT_TOAST_MS = 5000;
|
|
|
41
42
|
const generateId = () => Math.random().toString(36).slice(2, 11);
|
|
42
43
|
function createInitialState() {
|
|
43
44
|
return {
|
|
45
|
+
workspaceCollision: null,
|
|
44
46
|
messages: [],
|
|
45
47
|
agentState: { status: 'idle' },
|
|
46
48
|
sessionId: generateId(),
|
|
@@ -50,7 +52,7 @@ function createInitialState() {
|
|
|
50
52
|
history: [],
|
|
51
53
|
historyIdx: -1,
|
|
52
54
|
},
|
|
53
|
-
inputMode: '
|
|
55
|
+
inputMode: 'steer',
|
|
54
56
|
toast: null,
|
|
55
57
|
spinnerLabel: null,
|
|
56
58
|
spinnerFrame: null,
|
|
@@ -88,6 +90,8 @@ function isDuplicateAssistantAppend(previous, next) {
|
|
|
88
90
|
}
|
|
89
91
|
function reducer(state, action) {
|
|
90
92
|
switch (action.type) {
|
|
93
|
+
case 'SET_WORKSPACE_COLLISION':
|
|
94
|
+
return { ...state, workspaceCollision: action.snapshot };
|
|
91
95
|
case 'ADD_MESSAGE': {
|
|
92
96
|
const lastMessage = state.messages[state.messages.length - 1];
|
|
93
97
|
if (isDuplicateAssistantAppend(lastMessage, action.message)) {
|
|
@@ -142,11 +146,13 @@ function reducer(state, action) {
|
|
|
142
146
|
messages: state.messages.filter((msg) => msg.id !== action.id),
|
|
143
147
|
};
|
|
144
148
|
case 'SET_AGENT_STATE':
|
|
145
|
-
return { ...state, agentState: action.state
|
|
149
|
+
return { ...state, agentState: { ...action.state,
|
|
150
|
+
taskHandoff: action.state.taskHandoff ?? state.agentState.taskHandoff,
|
|
151
|
+
evidence: action.state.evidence ?? state.agentState.evidence } };
|
|
146
152
|
case 'SET_INPUT_STATE':
|
|
147
153
|
return { ...state, inputState: action.state };
|
|
148
154
|
case 'SET_INPUT_MODE':
|
|
149
|
-
return { ...state, inputMode: action.mode };
|
|
155
|
+
return { ...state, inputMode: normalizeInputMode(action.mode) };
|
|
150
156
|
case 'SET_TOAST':
|
|
151
157
|
return { ...state, toast: action.message };
|
|
152
158
|
case 'SET_SPINNER':
|
|
@@ -234,6 +240,17 @@ function reducer(state, action) {
|
|
|
234
240
|
queue[index] = { ...current, text: action.text };
|
|
235
241
|
return { ...state, queue };
|
|
236
242
|
}
|
|
243
|
+
case 'REORDER_QUEUE': {
|
|
244
|
+
if (action.ids.length !== state.queue.length || new Set(action.ids).size !== action.ids.length)
|
|
245
|
+
return state;
|
|
246
|
+
const byId = new Map(state.queue.map(entry => [entry.id, entry]));
|
|
247
|
+
if (action.ids.some(id => !byId.has(id)))
|
|
248
|
+
return state;
|
|
249
|
+
const queue = action.ids.map(id => byId.get(id));
|
|
250
|
+
if (queue.every((entry, index) => entry === state.queue[index]))
|
|
251
|
+
return state;
|
|
252
|
+
return { ...state, queue };
|
|
253
|
+
}
|
|
237
254
|
case 'CLEAR_QUEUE':
|
|
238
255
|
return { ...state, queue: [] };
|
|
239
256
|
default:
|
|
@@ -309,6 +326,9 @@ export class AppController {
|
|
|
309
326
|
setAgentState(agentState) {
|
|
310
327
|
this.dispatch({ type: 'SET_AGENT_STATE', state: agentState });
|
|
311
328
|
}
|
|
329
|
+
setWorkspaceCollision(snapshot) {
|
|
330
|
+
this.dispatch({ type: 'SET_WORKSPACE_COLLISION', snapshot });
|
|
331
|
+
}
|
|
312
332
|
setInputState(inputState) {
|
|
313
333
|
this.dispatch({ type: 'SET_INPUT_STATE', state: inputState });
|
|
314
334
|
}
|
|
@@ -474,6 +494,12 @@ export class AppController {
|
|
|
474
494
|
this.dispatch({ type: 'UPDATE_QUEUE_ENTRY', id, text });
|
|
475
495
|
return true;
|
|
476
496
|
}
|
|
497
|
+
/** Apply only an exact permutation of the currently accepted queue IDs. */
|
|
498
|
+
reorderQueue(ids) {
|
|
499
|
+
this.dispatch({ type: 'REORDER_QUEUE', ids: [...ids] });
|
|
500
|
+
return ids.length === this.state.queue.length
|
|
501
|
+
&& this.state.queue.every((entry, index) => entry.id === ids[index]);
|
|
502
|
+
}
|
|
477
503
|
clearQueue() {
|
|
478
504
|
this.dispatch({ type: 'CLEAR_QUEUE' });
|
|
479
505
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Global Escape confirms only the same running owner within this window. */
|
|
2
|
+
export declare const ESCAPE_STOP_WINDOW_MS = 2000;
|
|
3
|
+
export interface EscapeStopArm<Owner> {
|
|
4
|
+
owner: Owner;
|
|
5
|
+
armedAtMs: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function isEscapeStopArmed<Owner>(arm: EscapeStopArm<Owner> | null, owner: Owner | null, nowMs: number): boolean;
|
|
8
|
+
export declare function advanceEscapeStop<Owner>(arm: EscapeStopArm<Owner> | null, owner: Owner | null, nowMs: number): {
|
|
9
|
+
confirmed: boolean;
|
|
10
|
+
arm: EscapeStopArm<Owner> | null;
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Global Escape confirms only the same running owner within this window. */
|
|
2
|
+
export const ESCAPE_STOP_WINDOW_MS = 2000;
|
|
3
|
+
export function isEscapeStopArmed(arm, owner, nowMs) {
|
|
4
|
+
if (arm === null || owner === null || arm.owner !== owner)
|
|
5
|
+
return false;
|
|
6
|
+
const elapsed = nowMs - arm.armedAtMs;
|
|
7
|
+
return elapsed >= 0 && elapsed <= ESCAPE_STOP_WINDOW_MS;
|
|
8
|
+
}
|
|
9
|
+
export function advanceEscapeStop(arm, owner, nowMs) {
|
|
10
|
+
if (owner === null)
|
|
11
|
+
return { confirmed: false, arm: null };
|
|
12
|
+
if (isEscapeStopArmed(arm, owner, nowMs))
|
|
13
|
+
return { confirmed: true, arm: null };
|
|
14
|
+
return { confirmed: false, arm: { owner, armedAtMs: nowMs } };
|
|
15
|
+
}
|