@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
|
@@ -1,94 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DEFAULT_PERMISSION_PROFILES } from '../../config.js';
|
|
2
|
+
import { PERMISSION_CAPABILITIES, describePermissionChanges, describePermissionPolicy, projectPermissionPolicy, readRepoPermissionProfiles } from '../../config/permissions.js';
|
|
3
|
+
const usage = '/permissions show | profiles [--repo] | use <profile|repo:name> | set <capability> <on|off>';
|
|
4
|
+
const normalize = (value) => value.trim().toLowerCase();
|
|
5
|
+
export async function activatePermissionConfig(next, ctx) {
|
|
6
|
+
if (ctx.commandOrigin === 'agent')
|
|
7
|
+
throw new Error('Permission changes require an explicit user command.');
|
|
8
|
+
const previous = ctx.config.get(), after = projectPermissionPolicy(next);
|
|
9
|
+
if (after.commandSandbox.required && after.commandSandbox.enforcement !== 'os') {
|
|
10
|
+
throw new Error(`OS command sandbox required but unavailable for ${after.id}; profile unchanged. ${describePermissionPolicy(after)}`);
|
|
11
|
+
}
|
|
12
|
+
let change;
|
|
13
|
+
try {
|
|
14
|
+
change = describePermissionChanges(projectPermissionPolicy(previous), after);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
change = `Previous permission profile was invalid.\n${describePermissionPolicy(after)}`;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
ctx.config.set('permissionProfiles', next.permissionProfiles);
|
|
21
|
+
ctx.config.set('toolPermissions', next.toolPermissions);
|
|
22
|
+
ctx.config.set('permissionProfile', next.permissionProfile);
|
|
23
|
+
ctx.config.set('sandbox', next.sandbox);
|
|
24
|
+
await ctx.reloadAgent();
|
|
25
|
+
await ctx.config.save();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
ctx.config.set('permissionProfiles', previous.permissionProfiles);
|
|
29
|
+
ctx.config.set('toolPermissions', previous.toolPermissions);
|
|
30
|
+
ctx.config.set('permissionProfile', previous.permissionProfile);
|
|
31
|
+
ctx.config.set('sandbox', previous.sandbox);
|
|
32
|
+
await ctx.reloadAgent();
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
return `Permission profile active: ${after.id}\n${change}`;
|
|
4
36
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const profile =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (subCmd === 'profiles') {
|
|
33
|
-
const profiles = config.permissionProfiles || {};
|
|
34
|
-
const lines = Object.entries(profiles).map(([id, profile]) => {
|
|
35
|
-
const marker = id === config.permissionProfile ? '*' : ' ';
|
|
36
|
-
return `${marker} ${id}: ${profile.description || 'No description'}`;
|
|
37
|
-
});
|
|
38
|
-
ctx.addMessage({
|
|
39
|
-
role: 'system',
|
|
40
|
-
content: ['Permission profiles:', ...lines].join('\n')
|
|
41
|
-
});
|
|
42
|
-
return;
|
|
37
|
+
async function run(args, ctx) {
|
|
38
|
+
const action = normalize(args[0] ?? 'show'), config = ctx.config.get();
|
|
39
|
+
if (['use', 'set'].includes(action) && ctx.commandOrigin === 'agent')
|
|
40
|
+
return 'Permission changes require an explicit user command.';
|
|
41
|
+
if (action === 'show')
|
|
42
|
+
return args.length > 1 ? usage : describePermissionPolicy(projectPermissionPolicy(config));
|
|
43
|
+
if (action === 'profiles') {
|
|
44
|
+
if (args.length > 2 || (args.length === 2 && args[1] !== '--repo'))
|
|
45
|
+
return usage;
|
|
46
|
+
const repo = args[1] === '--repo';
|
|
47
|
+
const profiles = repo ? await readRepoPermissionProfiles(ctx.shell.getCwd()) : { ...DEFAULT_PERMISSION_PROFILES, ...config.permissionProfiles };
|
|
48
|
+
return ['Permission profiles (policy checks; not session-wide OS isolation):', ...Object.entries(profiles).map(([id, profile]) => `${(repo ? `repo:${id}` : id) === config.permissionProfile ? '*' : ' '} ${repo ? `repo:${id}` : id}: ${profile.description ?? 'Custom capability/path/command policy'}`)].join('\n');
|
|
49
|
+
}
|
|
50
|
+
if (action === 'use') {
|
|
51
|
+
if (args.length !== 2)
|
|
52
|
+
return usage;
|
|
53
|
+
const id = normalize(args[1]);
|
|
54
|
+
let profiles = { ...DEFAULT_PERMISSION_PROFILES, ...config.permissionProfiles };
|
|
55
|
+
if (id.startsWith('repo:')) {
|
|
56
|
+
const imported = await readRepoPermissionProfiles(ctx.shell.getCwd());
|
|
57
|
+
const profile = imported[id.slice(5)];
|
|
58
|
+
if (!profile)
|
|
59
|
+
return `Unknown repo permission profile: ${id}. Use /permissions profiles --repo.`;
|
|
60
|
+
profiles = { ...profiles, [id]: profile };
|
|
43
61
|
}
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
if (!Object.hasOwn(profiles, id))
|
|
63
|
+
return `Unknown permission profile: ${id}. Use /permissions profiles.`;
|
|
64
|
+
return activatePermissionConfig({ ...config, permissionProfile: id, permissionProfiles: profiles }, ctx);
|
|
65
|
+
}
|
|
66
|
+
if (action === 'set') {
|
|
67
|
+
const cap = normalize(args[1] ?? ''), value = normalize(args[2] ?? '');
|
|
68
|
+
if (args.length !== 3 || !PERMISSION_CAPABILITIES.includes(cap) || !['on', 'off'].includes(value))
|
|
69
|
+
return usage;
|
|
70
|
+
return activatePermissionConfig({ ...config, toolPermissions: { ...config.toolPermissions, [cap]: value === 'on' } }, ctx);
|
|
71
|
+
}
|
|
72
|
+
return usage;
|
|
73
|
+
}
|
|
74
|
+
export const permissionsCommand = {
|
|
75
|
+
name: 'permissions', description: 'Inspect and explicitly switch shared autonomy policy profiles', usage,
|
|
76
|
+
async handler(args, ctx) {
|
|
77
|
+
try {
|
|
78
|
+
ctx.addMessage({ role: 'system', content: await run(args, ctx) });
|
|
61
79
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const value = normalize(args[2] || '');
|
|
65
|
-
if (!cap || !ALL_CAPS.includes(cap)) {
|
|
66
|
-
ctx.addMessage({
|
|
67
|
-
role: 'system',
|
|
68
|
-
content: `Usage: /permissions set <${ALL_CAPS.join('|')}> <on|off>`
|
|
69
|
-
});
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (value !== 'on' && value !== 'off') {
|
|
73
|
-
ctx.addMessage({
|
|
74
|
-
role: 'system',
|
|
75
|
-
content: 'Usage: /permissions set <capability> <on|off>'
|
|
76
|
-
});
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const next = { ...current, [cap]: value === 'on' };
|
|
80
|
-
ctx.config.set('toolPermissions', next);
|
|
81
|
-
await ctx.config.save();
|
|
82
|
-
ctx.reloadAgent();
|
|
83
|
-
ctx.addMessage({
|
|
84
|
-
role: 'system',
|
|
85
|
-
content: `✓ Permission updated: ${cap} ${value}`
|
|
86
|
-
});
|
|
87
|
-
return;
|
|
80
|
+
catch (error) {
|
|
81
|
+
ctx.addMessage({ role: 'system', content: `Permissions: ${error instanceof Error ? error.message : 'Profile could not be applied'}` });
|
|
88
82
|
}
|
|
89
|
-
|
|
90
|
-
role: 'system',
|
|
91
|
-
content: 'Usage: /permissions <show|set|profiles|use> [capability|profile] [on|off]'
|
|
92
|
-
});
|
|
93
|
-
}
|
|
83
|
+
},
|
|
94
84
|
};
|
|
@@ -438,23 +438,14 @@ export function commitPlan(planFile, planContent, tasks, ctx, autoApprove) {
|
|
|
438
438
|
ctx.setMode?.(previousMode);
|
|
439
439
|
throw error;
|
|
440
440
|
}
|
|
441
|
-
// Publish tasks only after the normal agent exists. A failed rebuild must
|
|
442
|
-
// not leave a plan-mode session with implementation todos already armed.
|
|
443
|
-
if (ctx.setTodos && tasks.length > 0) {
|
|
444
|
-
ctx.setTodos(tasks.map((content, i) => ({
|
|
445
|
-
id: `plan_task_${i}`,
|
|
446
|
-
content,
|
|
447
|
-
status: 'pending',
|
|
448
|
-
})));
|
|
449
|
-
}
|
|
450
441
|
ctx.addMessage({
|
|
451
442
|
role: 'system',
|
|
452
|
-
content: `Plan approved. Beginning implementation.
|
|
443
|
+
content: `Plan mode off. Plan approved. Beginning implementation.
|
|
453
444
|
|
|
454
445
|
Plan: ${planFile}
|
|
455
446
|
Tasks extracted: ${tasks.length}
|
|
456
447
|
|
|
457
|
-
${tasks.length > 0 ? '
|
|
448
|
+
${tasks.length > 0 ? 'Implementation steps are included in the plan below.' : 'No tasks found in Implementation Steps section.'}`,
|
|
458
449
|
});
|
|
459
450
|
// Add plan as context for the agent with explicit implementation instructions
|
|
460
451
|
if (tasks.length > 0) {
|
|
@@ -462,12 +453,11 @@ ${tasks.length > 0 ? 'Tasks have been added to the todo list.' : 'No tasks found
|
|
|
462
453
|
role: 'user',
|
|
463
454
|
content: `Implement the following plan.
|
|
464
455
|
|
|
465
|
-
IMPORTANT - after ALL implementation steps are done you MUST do these
|
|
456
|
+
IMPORTANT - after ALL implementation steps are done you MUST do these two things:
|
|
466
457
|
1. Run the verification commands from the plan's Verification section to confirm everything works
|
|
467
|
-
2.
|
|
468
|
-
3. Print a brief final summary listing what was built and whether verification passed
|
|
458
|
+
2. Print a brief final summary listing what was built and whether verification passed
|
|
469
459
|
|
|
470
|
-
Do NOT skip steps 1-
|
|
460
|
+
Do NOT skip steps 1-2. They are required.
|
|
471
461
|
|
|
472
462
|
${planContent}`,
|
|
473
463
|
});
|
|
@@ -6,12 +6,13 @@ const USAGE = [
|
|
|
6
6
|
' /profile <name> switch this session to an existing profile',
|
|
7
7
|
' /profile use <name> same as above',
|
|
8
8
|
' /profile create <name> create and switch to a custom profile',
|
|
9
|
+
' /profile duplicate [name] copy the active profile and switch to the copy',
|
|
9
10
|
].join('\n');
|
|
10
11
|
const OLD_BENCHMARK_COMMANDS = new Set(['show', 'gates', 'command', 'run', 'optimize', 'sweep']);
|
|
11
12
|
export const profileCommand = {
|
|
12
13
|
name: 'profile',
|
|
13
|
-
description: 'List and
|
|
14
|
-
usage: '[list|<name>|use <name>|create <name
|
|
14
|
+
description: 'List, switch, create, and duplicate configuration profiles',
|
|
15
|
+
usage: '[list|<name>|use <name>|create <name>|duplicate [name]]',
|
|
15
16
|
handler: async (args, ctx) => {
|
|
16
17
|
const [action, ...rest] = args;
|
|
17
18
|
if (!action || action === 'list' || action === 'configs' || action === 'help') {
|
|
@@ -31,6 +32,24 @@ export const profileCommand = {
|
|
|
31
32
|
ctx.addMessage({ role: 'system', content: `Config profiles (* active):\n${lines.join('\n')}${!action ? `\n\n${USAGE}` : ''}` });
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
35
|
+
if (action === 'duplicate' || action === 'copy' || action === 'clone') {
|
|
36
|
+
if (rest.length > 1) {
|
|
37
|
+
ctx.addMessage({ role: 'system', content: USAGE });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const source = activeProfile();
|
|
41
|
+
const target = rest[0] ?? `${source}-copy`;
|
|
42
|
+
try {
|
|
43
|
+
if (!ctx.duplicateProfile)
|
|
44
|
+
throw new Error('This renderer cannot switch config profiles in place.');
|
|
45
|
+
const name = await ctx.duplicateProfile(target, source);
|
|
46
|
+
ctx.addMessage({ role: 'system', content: `Duplicated config profile ${source} to ${name} and switched to it.` });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
ctx.addMessage({ role: 'system', content: `Profile duplicate failed: ${error.message}` });
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
34
53
|
if (OLD_BENCHMARK_COMMANDS.has(action)) {
|
|
35
54
|
ctx.addMessage({ role: 'system', content: 'Use /emulation to inspect prompt modes. Profile benchmark gates remain available through npm run profiles:baseline.' });
|
|
36
55
|
return;
|
|
@@ -4,6 +4,7 @@ import { applyRuntimeModelSelection, getEffectiveModel } from './runtime_model.j
|
|
|
4
4
|
import { canRouteThroughRouter, canonicalProvider } from './provider_choices.js';
|
|
5
5
|
import { resolveModelAndProvider } from '../../panes/model_catalog.js';
|
|
6
6
|
import { getDefaultModel } from '../../utils/models.js';
|
|
7
|
+
import { resolveRouterModel, RouterCatalogAuthenticationError } from '../../utils/router_catalog.js';
|
|
7
8
|
/** Apply a provider and optional model in one validated config transition. */
|
|
8
9
|
export async function selectProviderModel(args, ctx) {
|
|
9
10
|
const values = args.filter(Boolean);
|
|
@@ -27,11 +28,29 @@ export async function selectProviderModel(args, ctx) {
|
|
|
27
28
|
const authMode = routed ? 'zrouter' : 'direct';
|
|
28
29
|
const defaultModel = provider === 'inception' ? getDefaultModel(provider) : getDefaultModelForProvider(provider);
|
|
29
30
|
const explicitModel = values[choice === 'zergrouter' ? 2 : 1];
|
|
30
|
-
|
|
31
|
+
let model = explicitModel || (provider === current ? getEffectiveModel(ctx)
|
|
31
32
|
: provider === 'openai_compatible'
|
|
32
33
|
? (ctx.config.getOpenAICompatibleSettings?.().defaultModel || getDefaultModelForProvider(provider))
|
|
33
34
|
: resolveModelAndProvider(defaultModel, provider).model);
|
|
34
35
|
try {
|
|
36
|
+
if (routed && ctx.models.catalog) {
|
|
37
|
+
const catalog = await ctx.models.catalog(undefined, { refresh: !explicitModel }).catch(error => {
|
|
38
|
+
if (error instanceof RouterCatalogAuthenticationError)
|
|
39
|
+
throw error;
|
|
40
|
+
return undefined;
|
|
41
|
+
});
|
|
42
|
+
if (catalog?.authRequired)
|
|
43
|
+
throw new Error('Router authentication rejected. Run /auth login and retry.');
|
|
44
|
+
if (catalog?.version === 1) {
|
|
45
|
+
const models = catalog.models.filter(row => row.owned_by === provider && row.capabilities?.chat);
|
|
46
|
+
if (!explicitModel)
|
|
47
|
+
model = models.find(row => row.is_default)?.id ?? models[0]?.id ?? '';
|
|
48
|
+
const selected = resolveRouterModel(catalog, provider, model);
|
|
49
|
+
if (!selected?.capabilities?.chat)
|
|
50
|
+
throw new Error('Model is not in the Router catalog. Run /model zergrouter to choose an available model.');
|
|
51
|
+
model = selected.id;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
35
54
|
const llm = ctx.config.resolveLLMBackendConfig({ provider, model,
|
|
36
55
|
config: { ...ctx.config.get(), provider, model, authMode } });
|
|
37
56
|
if (llm.authMode !== authMode) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { guardedRemoteSession, requestRemoteResource } from '../runtime/remote_resources.js';
|
|
2
|
+
export const resourcesCommand = {
|
|
3
|
+
name: 'resources',
|
|
4
|
+
description: 'Inspect ownership and reconcile uncertain guarded remote mutations',
|
|
5
|
+
agentRunnable: false,
|
|
6
|
+
usage: '/resources <show|claim|transfer|stop|reconcile|resolve> [resource] [generation-or-operation-id] [target-owner-or-observation-token] [ttl-seconds]',
|
|
7
|
+
handler: async (args, ctx) => {
|
|
8
|
+
const report = (content) => ctx.addMessage({ role: 'system', content });
|
|
9
|
+
if (ctx.commandOrigin === 'agent') {
|
|
10
|
+
report('Resource ownership changes require the user to type /resources. Chat and agent requests cannot grant ownership.');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!ctx.getSessionId) {
|
|
14
|
+
report('Remote resource controls require a host session identity.');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const session = guardedRemoteSession(ctx.getSessionId(), ctx.config.get().remoteResources);
|
|
18
|
+
if (!session) {
|
|
19
|
+
report('Configure remoteResources in the active profile to start a guarded remote session.');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const operation = args[0] || 'show';
|
|
23
|
+
let leaseDispatched = false;
|
|
24
|
+
try {
|
|
25
|
+
if (operation === 'show') {
|
|
26
|
+
const resources = args[1] ? session.resources.filter(resource => resource.id === args[1]) : session.resources;
|
|
27
|
+
if (args[1] && !resources.length)
|
|
28
|
+
throw new Error(`Unknown host-managed resource: ${args[1]}`);
|
|
29
|
+
const lines = [`Immutable owner ID: ${session.ownerId}`];
|
|
30
|
+
for (const resource of resources) {
|
|
31
|
+
const status = await requestRemoteResource(session, resource.id, 'status');
|
|
32
|
+
lines.push(`${resource.id}: ${JSON.stringify(status)}`);
|
|
33
|
+
}
|
|
34
|
+
report(lines.join('\n'));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (operation === 'reconcile' || operation === 'resolve') {
|
|
38
|
+
if (!args[1] || !args[2] || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(args[2]))
|
|
39
|
+
throw new Error('Reconciliation requires a resource and canonical operation UUID.');
|
|
40
|
+
if (operation === 'resolve' && (!args[3] || !/^[a-f0-9]{64}$/.test(args[3])))
|
|
41
|
+
throw new Error('Inspect reconcile first, then supply its exact observation token to accept the current state.');
|
|
42
|
+
const result = await requestRemoteResource(session, args[1], operation, { receipt_id: args[2], observation_token: args[3] });
|
|
43
|
+
report(`${args[1]} ${operation}${operation === 'resolve' ? ' confirmed' : ''}: ${JSON.stringify(result)}${operation === 'reconcile'
|
|
44
|
+
? '\nAccept current state only after reviewing the receipt, current target and retained staging data: /resources resolve ' + args[1] + ' ' + args[2] + ' <observation-token>. This releases admission; it does not replay the operation or prove an uncertain earlier effect.' : ''}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!['claim', 'transfer', 'stop'].includes(operation) || !args[1] || !args[2]) {
|
|
48
|
+
throw new Error('Usage: /resources show [resource]; /resources claim <resource> <generation> [ttl-seconds]; /resources transfer <resource> <generation> <target-owner-id> [ttl-seconds]; /resources stop <resource> <generation>. Inspect show before confirming.');
|
|
49
|
+
}
|
|
50
|
+
const generation = Number(args[2]);
|
|
51
|
+
if (!Number.isSafeInteger(generation) || generation < 0)
|
|
52
|
+
throw new Error('Expected generation must be a non-negative integer from /resources show.');
|
|
53
|
+
const ttl = Number(args[operation === 'transfer' ? 4 : 3] ?? 900);
|
|
54
|
+
leaseDispatched = true;
|
|
55
|
+
const result = await requestRemoteResource(session, args[1], operation, {
|
|
56
|
+
expected_generation: generation,
|
|
57
|
+
...(operation === 'transfer' ? { target_owner_id: args[3] } : {}),
|
|
58
|
+
ttl_seconds: ttl,
|
|
59
|
+
});
|
|
60
|
+
report(`${args[1]} ${operation} confirmed: ${JSON.stringify(result)}`);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
report(`Resource action failed: ${error.message}${leaseDispatched
|
|
64
|
+
? `\nInspect the current owner and generation with /resources show ${args[1]} before retrying; a failed response alone does not establish the lease outcome.` : ''}`);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** History replacement is an explicit user action, separate from stopping. */
|
|
2
|
+
export const rewindCommand = {
|
|
3
|
+
name: 'rewind',
|
|
4
|
+
description: 'Choose an earlier prompt to restore and remove its following context',
|
|
5
|
+
usage: '/rewind',
|
|
6
|
+
handler: (_, ctx) => {
|
|
7
|
+
if (!ctx.rewindPanel) {
|
|
8
|
+
ctx.addMessage({
|
|
9
|
+
role: 'system',
|
|
10
|
+
content: 'The rewind picker requires the Ratatui renderer. Start a Ratatui ZTC terminal and use /rewind to choose an earlier prompt.',
|
|
11
|
+
});
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
ctx.rewindPanel.open();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { findRunbook, installRunbook, listRunbooks } from '../../runbooks/library.js';
|
|
2
|
+
import { prepareRunbookRun } from '../../runbooks/package.js';
|
|
3
|
+
import { ensureWorkflowRegistry } from '../../workflows/registry_lazy.js';
|
|
4
|
+
function describe(book) {
|
|
5
|
+
const value = book.package;
|
|
6
|
+
return [value.name, value.description, `Source: ${book.source}`, `Content SHA256: ${book.digest}`,
|
|
7
|
+
...(book.installedFrom ? [`Recorded install source (advisory): ${book.installedFrom.source}; source content SHA256: ${book.installedFrom.digest}`] : []),
|
|
8
|
+
`Package schema: ${value.schemaVersion}; requires Node ${value.minimumNodeMajor}+`,
|
|
9
|
+
`Required tools: ${value.requiredTools.map(names => names.join(' or ')).join('; ') || 'none'}`,
|
|
10
|
+
'Inputs:', ...value.inputs.map(input => ` ${input.name}${input.required ? ' (required)' : ' (optional)'}: ${input.description}`),
|
|
11
|
+
'Expected evidence (not observed verification):', ...value.expectedEvidence.map(text => ` ${text}`),
|
|
12
|
+
`Workflow entrypoint: ${value.entrypoint}; scripts: ${Object.keys(value.scripts).join(', ')}`,
|
|
13
|
+
'', value.instructions, '', 'Installation does not authorize execution. Invocation retains current workflow and tool permissions.'].join('\n');
|
|
14
|
+
}
|
|
15
|
+
export const runbooksCommand = {
|
|
16
|
+
name: 'runbooks', description: 'Browse, inspect, install, and invoke runbooks',
|
|
17
|
+
usage: '/runbooks [list|show|install|run]', agentRunnable: false, category: 'workflow',
|
|
18
|
+
handler: async (args, ctx) => {
|
|
19
|
+
if (ctx.commandOrigin === 'agent') {
|
|
20
|
+
ctx.addMessage({ role: 'system', content: 'Runbook installation and invocation require an explicit user command.' });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const cwd = ctx.shell.getCwd();
|
|
24
|
+
try {
|
|
25
|
+
const action = args[0] ?? 'list';
|
|
26
|
+
if (action === 'list') {
|
|
27
|
+
const catalog = await listRunbooks(cwd);
|
|
28
|
+
ctx.addMessage({ role: 'system', content: ['Available runbooks:',
|
|
29
|
+
...catalog.runbooks.map(book => ` ${book.package.id}: ${book.package.description} (${book.source})`),
|
|
30
|
+
...catalog.errors.map(error => `Library error: ${error}`),
|
|
31
|
+
'Use /runbooks show <id> to inspect prerequisites, inputs, instructions and expected evidence.'].join('\n') });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const source = args[1];
|
|
35
|
+
if (!source || !['show', 'install', 'run'].includes(action))
|
|
36
|
+
throw new Error('Usage: /runbooks [list|show <id-or-path>|install <id-or-path>|run <id-or-path> [--args <JSON>]]');
|
|
37
|
+
if (action === 'install') {
|
|
38
|
+
const installed = await installRunbook(source, cwd);
|
|
39
|
+
ctx.addMessage({ role: 'system', content: `Runbook installed: ${installed.path}\nSource: ${installed.book.source}\nContent SHA256: ${installed.book.digest}\nNo scripts were executed. Inspect with /runbooks show ${installed.book.package.id}; invoke explicitly with /runbooks run ${installed.book.package.id}. Current permissions still apply.` });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const book = await findRunbook(source, cwd);
|
|
43
|
+
if (action === 'show') {
|
|
44
|
+
ctx.addMessage({ role: 'system', content: describe(book) });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (args.length > 2 && (args[2] !== '--args' || args.length < 4))
|
|
48
|
+
throw new Error('Use /runbooks run <id-or-path> [--args <JSON object>].');
|
|
49
|
+
let inputs = {};
|
|
50
|
+
if (args.length >= 4) {
|
|
51
|
+
// ZTC splits slash input on whitespace, as does the existing workflow command.
|
|
52
|
+
try {
|
|
53
|
+
inputs = JSON.parse(args.slice(3).join(' '));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new Error('Runbook --args must be a valid JSON object.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const execution = ctx.getExecutionContext?.();
|
|
60
|
+
if (!execution)
|
|
61
|
+
throw new Error('Current tool capabilities are unavailable. Open a compatible configured ZTC session before invoking a runbook.');
|
|
62
|
+
const prepared = prepareRunbookRun(book, inputs, execution.tools);
|
|
63
|
+
const registry = await ensureWorkflowRegistry();
|
|
64
|
+
if (!registry)
|
|
65
|
+
throw new Error('Workflow registry is not initialized. Configure an API provider before invoking a runbook.');
|
|
66
|
+
const runId = registry.startInline(prepared);
|
|
67
|
+
ctx.addMessage({ role: 'system', content: `Runbook ${book.package.id} started: ${runId}\nSource: ${book.source}\nContent SHA256: ${book.digest}\nExpected evidence is a plan, not verified output. Inspect actual results with /workflows show ${runId}.` });
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
ctx.addMessage({ role: 'system', content: error instanceof Error ? error.message : String(error) });
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const runbooksCommand = {
|
|
2
|
+
name: 'runbooks', description: 'Browse, inspect, install, and invoke runbooks',
|
|
3
|
+
usage: '/runbooks [list|show|install|run]', agentRunnable: false, category: 'workflow',
|
|
4
|
+
handler: async (args, ctx) => {
|
|
5
|
+
const { runbooksCommand: implementation } = await import('./runbooks.js');
|
|
6
|
+
return implementation.handler(args, ctx);
|
|
7
|
+
},
|
|
8
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
1
|
+
import type { Command } from './types.js';
|
|
2
2
|
export declare const sessionsCommand: Command;
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
import { listSessions, deleteSession } from '../../session.js';
|
|
2
|
+
import { inspectWorkspaceSessions, formatWorkspaceSnapshot } from '../../workspace_collision.js';
|
|
2
3
|
export const sessionsCommand = {
|
|
3
4
|
name: 'sessions',
|
|
4
|
-
description: '
|
|
5
|
-
usage: '/sessions [list|delete <id>]',
|
|
5
|
+
description: 'Inspect active local workspace peers or manage saved sessions',
|
|
6
|
+
usage: '/sessions [active|continue|isolate|list|delete <id>]',
|
|
6
7
|
handler: async (args, ctx) => {
|
|
7
|
-
const cwd = ctx.shell.getCwd();
|
|
8
|
+
const cwd = (ctx.getSessionCwd?.() ?? ctx.shell.getCwd());
|
|
8
9
|
const subcommand = args[0] || 'list';
|
|
10
|
+
if (subcommand === 'active') {
|
|
11
|
+
const snapshot = ctx.workspace
|
|
12
|
+
? await ctx.workspace.getSnapshot()
|
|
13
|
+
: await inspectWorkspaceSessions(cwd, ctx.getSessionId?.());
|
|
14
|
+
ctx.addMessage({ role: 'system', content: formatWorkspaceSnapshot(snapshot) });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (subcommand === 'continue' || subcommand === 'isolate') {
|
|
18
|
+
if (ctx.commandOrigin === 'agent') {
|
|
19
|
+
ctx.addMessage({ role: 'system', content: 'Local workspace continuation and isolation require the user to choose. Remote authority remains unchanged.' });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (args.length !== 1) {
|
|
23
|
+
ctx.addMessage({ role: 'system', content: 'Usage: /sessions continue | /sessions isolate' });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!ctx.workspace) {
|
|
27
|
+
ctx.addMessage({ role: 'system', content: 'This surface cannot continue or isolate a local session. Use an interactive ZTC session. No workspace or remote authority was changed.' });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await ctx.workspace[subcommand]();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
9
33
|
if (subcommand === 'list') {
|
|
10
34
|
const sessions = await listSessions(cwd);
|
|
11
35
|
if (sessions.length === 0) {
|
|
@@ -16,16 +40,20 @@ export const sessionsCommand = {
|
|
|
16
40
|
return;
|
|
17
41
|
}
|
|
18
42
|
const lines = ['Saved sessions:\n'];
|
|
43
|
+
sessions.sort((a, b) => Number(Boolean(b.labels?.pinned)) - Number(Boolean(a.labels?.pinned)) || (a.labels?.group ?? '').localeCompare(b.labels?.group ?? ''));
|
|
19
44
|
for (const session of sessions) {
|
|
20
45
|
const date = new Date(session.updatedAt).toLocaleString();
|
|
46
|
+
const labelTag = [session.labels?.pinned ? 'pinned' : undefined, session.labels?.group, session.labels?.project, session.labels?.task].filter(Boolean).join(' · ');
|
|
21
47
|
const nameTag = session.name ? ` [${session.name}]` : '';
|
|
22
48
|
lines.push(` ${session.id}${nameTag} ${date} (${session.messageCount} messages)`);
|
|
49
|
+
if (labelTag)
|
|
50
|
+
lines.push(` ${labelTag}`);
|
|
23
51
|
lines.push(` ${session.title.slice(0, 60)}${session.title.length > 60 ? '...' : ''}\n`);
|
|
24
52
|
}
|
|
25
53
|
lines.push('\nResume with: /resume (interactive picker)');
|
|
26
54
|
lines.push('Or directly: ztc resume <id-or-name>');
|
|
27
55
|
lines.push('Or: ztc resume (opens the picker), ztc -c (most recent)');
|
|
28
|
-
lines.push('Set a name with: /rename <name>');
|
|
56
|
+
lines.push('Set a name with: /rename <name>. Pin or group with: /label pin, /label group <name>');
|
|
29
57
|
lines.push('If the session was saved in zmux, resume also restores its pane layout.');
|
|
30
58
|
lines.push('Legacy alias: ztc --resume [id-or-name]');
|
|
31
59
|
ctx.addMessage({
|
|
@@ -59,7 +87,7 @@ export const sessionsCommand = {
|
|
|
59
87
|
else {
|
|
60
88
|
ctx.addMessage({
|
|
61
89
|
role: 'system',
|
|
62
|
-
content: 'Usage: /sessions [list|delete <id>]',
|
|
90
|
+
content: 'Usage: /sessions [active|continue|isolate|list|delete <id>]',
|
|
63
91
|
});
|
|
64
92
|
}
|
|
65
93
|
},
|