@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
|
@@ -10,9 +10,11 @@ import { Tool } from './types.js';
|
|
|
10
10
|
export interface AskUserOption {
|
|
11
11
|
label: string;
|
|
12
12
|
description: string;
|
|
13
|
+
/** Optional short explanation of what happens after this option is chosen. */
|
|
14
|
+
preview?: string;
|
|
13
15
|
/**
|
|
14
16
|
* Marks the option you would pick. At most one option per question may set
|
|
15
|
-
* this; the TUI badges it and starts the cursor on it.
|
|
17
|
+
* this; it appears first and the TUI badges it and starts the cursor on it.
|
|
16
18
|
*/
|
|
17
19
|
recommended?: boolean;
|
|
18
20
|
}
|
|
@@ -83,6 +83,12 @@ function validateOptionsArray(options) {
|
|
|
83
83
|
if (opt.label.length > MAX_LABEL_LENGTH || opt.description.length > MAX_LABEL_LENGTH) {
|
|
84
84
|
return `option label/description exceeds ${MAX_LABEL_LENGTH} character limit.`;
|
|
85
85
|
}
|
|
86
|
+
if (opt.preview !== undefined && typeof opt.preview !== 'string') {
|
|
87
|
+
return 'option preview must be a string when provided.';
|
|
88
|
+
}
|
|
89
|
+
if (opt.preview !== undefined && opt.preview.length > MAX_LABEL_LENGTH) {
|
|
90
|
+
return `option preview exceeds ${MAX_LABEL_LENGTH} character limit.`;
|
|
91
|
+
}
|
|
86
92
|
// Accept the boolean and its string spelling, keep the first recommended
|
|
87
93
|
// option, and drop duplicates instead of failing the whole call.
|
|
88
94
|
const isRecommended = !recommendedSeen && (opt.recommended === true || opt.recommended === 'true');
|
|
@@ -91,10 +97,14 @@ function validateOptionsArray(options) {
|
|
|
91
97
|
normalized.push({
|
|
92
98
|
label: String(opt.label),
|
|
93
99
|
description: String(opt.description),
|
|
100
|
+
...(opt.preview !== undefined ? { preview: opt.preview } : {}),
|
|
94
101
|
...(isRecommended ? { recommended: true } : {}),
|
|
95
102
|
});
|
|
96
103
|
}
|
|
97
|
-
|
|
104
|
+
const recommendation = normalized.findIndex(option => option.recommended === true);
|
|
105
|
+
return recommendation > 0
|
|
106
|
+
? [normalized[recommendation], ...normalized.filter((_option, index) => index !== recommendation)]
|
|
107
|
+
: normalized;
|
|
98
108
|
}
|
|
99
109
|
function parseOptions(raw) {
|
|
100
110
|
let parsed;
|
|
@@ -117,7 +127,15 @@ function normalizeOptions(raw) {
|
|
|
117
127
|
return 'options_json must be an array of {label, description} options, not a single object.';
|
|
118
128
|
return parseOptions(String(raw ?? ''));
|
|
119
129
|
}
|
|
130
|
+
function registrationFailure(message) {
|
|
131
|
+
const detail = message.trim();
|
|
132
|
+
return detail
|
|
133
|
+
? `Error: ${detail}`
|
|
134
|
+
: 'Error: The interactive question could not be registered. Retry when question input is available.';
|
|
135
|
+
}
|
|
120
136
|
export const askUserTool = {
|
|
137
|
+
// Validation and UI registration failures must use the runtime's failure path.
|
|
138
|
+
isErrorResult: (content) => /^Error[: ]/u.test(content),
|
|
121
139
|
definition: {
|
|
122
140
|
name: 'ask_user',
|
|
123
141
|
description: `Ask the user one or more questions with predefined options. Use this to get user preferences, clarify requirements, or confirm approach before proceeding.
|
|
@@ -132,11 +150,12 @@ Use "questions_json" to ask multiple questions at once. This is more efficient t
|
|
|
132
150
|
|
|
133
151
|
### options_json format
|
|
134
152
|
JSON array of objects with "label" and "description" fields.
|
|
135
|
-
|
|
136
|
-
|
|
153
|
+
Put the option you would pick first and add "recommended": true; it is badged and pre-selected for the user. Never mark more than one option per question.
|
|
154
|
+
Optionally add "preview" (a short string, maximum 500 characters) to explain what happens next after choosing that option. The highlighted option shows this separately as "Next:". Keep descriptions about the choice and previews about its next step.
|
|
155
|
+
Example: [{"label": "Option A", "description": "Use approach A", "recommended": true, "preview": "Run the checks, then apply approach A"}, {"label": "Option B", "description": "Use approach B"}]
|
|
137
156
|
|
|
138
157
|
### questions_json format
|
|
139
|
-
JSON array of question objects, each with "question" (string) and "options" (same format as options_json).
|
|
158
|
+
JSON array of question objects, each with "question" (string) and "options" (same format as options_json, including optional recommended and preview fields).
|
|
140
159
|
Example: [{"question": "Which framework?", "options": [{"label": "React", "description": "Use React", "recommended": true}, {"label": "Vue", "description": "Use Vue"}]}, {"question": "Which database?", "options": [{"label": "Postgres", "description": "PostgreSQL"}, {"label": "SQLite", "description": "SQLite"}]}]`,
|
|
141
160
|
parameters: {
|
|
142
161
|
type: 'object',
|
|
@@ -147,11 +166,11 @@ Example: [{"question": "Which framework?", "options": [{"label": "React", "descr
|
|
|
147
166
|
},
|
|
148
167
|
options_json: {
|
|
149
168
|
type: 'string',
|
|
150
|
-
description: 'JSON array of options for single question mode. Each with "label" (1-5 words) and "description"
|
|
169
|
+
description: 'JSON array of options for single question mode. Each with "label" (1-5 words) and "description"; put the one recommended option first and mark "recommended": true (at most one per question). Optional "preview" (string, max 500 characters) briefly explains what happens next. Provide 2-4 options.',
|
|
151
170
|
},
|
|
152
171
|
questions_json: {
|
|
153
172
|
type: 'string',
|
|
154
|
-
description: 'JSON array of question objects for multi-question mode. Each has "question" (string) and "options" (array of {label, description, recommended?}). Use this to ask 2+ questions at once.',
|
|
173
|
+
description: 'JSON array of question objects for multi-question mode. Each has "question" (string) and "options" (array of {label, description, recommended?, preview?}); recommended option first, optional preview is a string of at most 500 characters. Use this to ask 2+ questions at once.',
|
|
155
174
|
},
|
|
156
175
|
allow_other: {
|
|
157
176
|
type: 'boolean',
|
|
@@ -169,7 +188,7 @@ Example: [{"question": "Which framework?", "options": [{"label": "React", "descr
|
|
|
169
188
|
debugLog('execute called:', { hasQuestion: !!question, hasOptionsJson: !!optionsJson, hasQuestionsJson: !!questionsJson, alreadyCalled: askUserCalledThisTurn });
|
|
170
189
|
if (!askUserCallback) {
|
|
171
190
|
debugLog('ERROR: no callback registered');
|
|
172
|
-
return 'ask_user is not available in this context.';
|
|
191
|
+
return 'Error: ask_user is not available in this context. Use an interactive ZTC session with question input enabled.';
|
|
173
192
|
}
|
|
174
193
|
// If ask_user was already called this turn (parallel tool calls), the questions
|
|
175
194
|
// were merged via the callback. Return a dedup message so the LLM doesn't re-ask.
|
|
@@ -228,8 +247,8 @@ Example: [{"question": "Which framework?", "options": [{"label": "React", "descr
|
|
|
228
247
|
questions.push({ question: q.question, options: opts, allow_other: allowOther });
|
|
229
248
|
}
|
|
230
249
|
const error = askUserCallback(questions);
|
|
231
|
-
if (error)
|
|
232
|
-
return error;
|
|
250
|
+
if (error !== null)
|
|
251
|
+
return registrationFailure(error);
|
|
233
252
|
const wasDuplicate = askUserCalledThisTurn;
|
|
234
253
|
askUserCalledThisTurn = true;
|
|
235
254
|
if (wasDuplicate) {
|
|
@@ -253,8 +272,8 @@ Example: [{"question": "Which framework?", "options": [{"label": "React", "descr
|
|
|
253
272
|
return `Error: ${parsed}`;
|
|
254
273
|
}
|
|
255
274
|
const error = askUserCallback([{ question, options: parsed, allow_other: allowOther }]);
|
|
256
|
-
if (error)
|
|
257
|
-
return error;
|
|
275
|
+
if (error !== null)
|
|
276
|
+
return registrationFailure(error);
|
|
258
277
|
const wasDuplicate = askUserCalledThisTurn;
|
|
259
278
|
askUserCalledThisTurn = true;
|
|
260
279
|
if (wasDuplicate) {
|
|
@@ -47,6 +47,7 @@ export const spawnBackgroundAgentTool = {
|
|
|
47
47
|
const taskId = registry.spawn(task, {
|
|
48
48
|
maxIterations,
|
|
49
49
|
cwd: context?.cwd || process.cwd(),
|
|
50
|
+
onUsage: context?.onUsage,
|
|
50
51
|
});
|
|
51
52
|
return `Background agent spawned (${taskId}). I'll continue working while it runs. You'll be notified when it completes.`;
|
|
52
53
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { cpus, release } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { CPU_CHECKER_SHA256, CPU_HOST_INSTANCE_ID, CPU_PROGRAM_SHA256, CPU_RECIPE_SHA256, integerSumOracle, parseCPUWorkload, runCPUWorkload } from '../runtime/cpu_benchmark.js';
|
|
5
|
+
import { parseBenchmarkVerifierDecision } from '../runtime/benchmark_contract.js';
|
|
6
|
+
import { ToolCapability } from '../runtime/capabilities.js';
|
|
7
|
+
import { captureVerifierInputs } from '../runtime/verifier_capture.js';
|
|
8
|
+
import { parseCommandVerificationReceipt, parseVerificationRequest } from '../runtime/source_verification_contract.js';
|
|
9
|
+
export const benchmarkCPUTool = Object.freeze({
|
|
10
|
+
capabilities: Object.freeze([ToolCapability.FILE_READ, ToolCapability.SHELL_EXEC]), effect: 'write',
|
|
11
|
+
definition: { name: 'benchmark_cpu',
|
|
12
|
+
description: 'Execute the registered bounded CPU integer-sum benchmark using immutable captured JSON data and config, actual monotonic measurements and an independent exact oracle. Input is1–1024 integers with absolute value≤1000000. Config: {schema_version:1,variant:"for_loop"|"array_reduce",iterations:1–2048,warmup:0–4,samples:3|5|7|9}. Admits only this fixture; never project code, reported scores, generic command results, production/GPU performance or a plateau. Local execution and exact source-read permissions required; guarded remote sessions cannot use this adapter. Each file≤65536B.',
|
|
13
|
+
parameters: { type: 'object', additionalProperties: false, properties: {
|
|
14
|
+
adapter_id: { type: 'string', enum: ['cpu_integer_sum'] }, input_path: { type: 'string' }, config_path: { type: 'string' },
|
|
15
|
+
}, required: ['adapter_id', 'input_path', 'config_path'] } },
|
|
16
|
+
execute: async (args, context) => {
|
|
17
|
+
if (!context)
|
|
18
|
+
throw new Error('benchmark_cpu requires a host execution context');
|
|
19
|
+
if (Object.keys(args).some(key => !['adapter_id', 'input_path', 'config_path'].includes(key)) || args.adapter_id !== 'cpu_integer_sum') {
|
|
20
|
+
throw new TypeError('benchmark_cpu accepts only the registered CPU adapter and input/config paths');
|
|
21
|
+
}
|
|
22
|
+
const request = parseVerificationRequest({ purpose: 'benchmark', scope: 'benchmark:cpu_integer_sum',
|
|
23
|
+
source_paths: [args.input_path, args.config_path], instrumentation: 'production' });
|
|
24
|
+
if (!request)
|
|
25
|
+
throw new TypeError('benchmark_cpu requires two distinct bounded relative input/config paths');
|
|
26
|
+
const captured = await captureVerifierInputs(context, request.source_paths);
|
|
27
|
+
const processors = cpus();
|
|
28
|
+
if (processors.length === 0)
|
|
29
|
+
throw new Error('The benchmark CPU execution conditions are unavailable');
|
|
30
|
+
const receipt = { schema_version: 1, receipt_id: randomUUID(), source: captured.source,
|
|
31
|
+
end_source: null, purpose: 'benchmark', scope: 'benchmark:cpu_integer_sum', command_sha256: CPU_RECIPE_SHA256,
|
|
32
|
+
command_kind: 'host_verifier', build_identity: CPU_RECIPE_SHA256, instrumentation: 'unknown',
|
|
33
|
+
environment: { platform: process.platform, arch: process.arch, node_version: process.version, declared_id: null },
|
|
34
|
+
process_outcome: 'unknown', source_binding: 'unknown', qualification: 'unverified', artifact_refs: [] };
|
|
35
|
+
const input = captured.documents.get(String(args.input_path));
|
|
36
|
+
const config = captured.documents.get(String(args.config_path));
|
|
37
|
+
const binding = input !== undefined && config !== undefined && !context.signal?.aborted ? 'immutable_bytes' : 'unknown';
|
|
38
|
+
const workload = binding === 'immutable_bytes' ? parseCPUWorkload(input, config) : null;
|
|
39
|
+
let decision = { schema_version: 1, adapter_id: 'cpu_integer_sum', recipe_version: 1,
|
|
40
|
+
execution: 'host_node_subprocess', recipe_sha256: CPU_RECIPE_SHA256, receipt_id: receipt.receipt_id, source_id: receipt.source.source_id,
|
|
41
|
+
scope: 'benchmark:cpu_integer_sum', input_path: String(args.input_path), config_path: String(args.config_path), input_binding: binding,
|
|
42
|
+
outcome: 'unknown', checks_total: 0, checks_passed: 0, reason: 'Complete supported immutable input/config data was unavailable.',
|
|
43
|
+
benchmark_eligibility: 'unknown', variant: workload?.config.variant ?? null,
|
|
44
|
+
program_sha256: workload ? CPU_PROGRAM_SHA256[workload.config.variant] : null, checker_sha256: CPU_CHECKER_SHA256,
|
|
45
|
+
conditions: { host_instance_id: CPU_HOST_INSTANCE_ID, cpu_model: processors[0].model, logical_cpus: processors.length, os_release: release() },
|
|
46
|
+
workload: workload ? { id: 'cpu_integer_sum/v1', input_sha256: captured.source.files.find(row => row.path === args.input_path).sha256,
|
|
47
|
+
length: workload.values.length, iterations: workload.config.iterations, warmup: workload.config.warmup, samples: workload.config.samples } : null,
|
|
48
|
+
measurement: null };
|
|
49
|
+
if (workload) {
|
|
50
|
+
const run = await runCPUWorkload(workload, context);
|
|
51
|
+
receipt.process_outcome = run.outcome;
|
|
52
|
+
receipt.environment.declared_id = run.executionPolicyId;
|
|
53
|
+
decision.reason = 'The actual registered process did not produce a complete supported measured result.';
|
|
54
|
+
decision.benchmark_eligibility = 'ineligible';
|
|
55
|
+
if (run.outcome === 'passed') {
|
|
56
|
+
let output;
|
|
57
|
+
try {
|
|
58
|
+
output = JSON.parse(run.output);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
output = null;
|
|
62
|
+
}
|
|
63
|
+
const row = output;
|
|
64
|
+
if (row && typeof row === 'object' && !Array.isArray(row)
|
|
65
|
+
&& Object.keys(row).length === 8 && row.schema_version === 1 && row.variant === workload.config.variant
|
|
66
|
+
&& Number.isSafeInteger(row.pid) && Number(row.pid) > 0
|
|
67
|
+
&& row.node_version === process.version && row.platform === process.platform && row.arch === process.arch
|
|
68
|
+
&& Array.isArray(row.samples_ms) && row.samples_ms.length === workload.config.samples
|
|
69
|
+
&& row.samples_ms.every(value => typeof value === 'number' && Number.isFinite(value) && value > 0 && value <= 60000)
|
|
70
|
+
&& Array.isArray(row.checksums) && row.checksums.length === workload.config.samples
|
|
71
|
+
&& row.checksums.every(value => typeof value === 'number' && Number.isSafeInteger(value))) {
|
|
72
|
+
const expected = integerSumOracle(workload.values) * workload.config.iterations;
|
|
73
|
+
receipt.instrumentation = 'production';
|
|
74
|
+
const passed = row.checksums.filter(value => value === expected).length;
|
|
75
|
+
const samples = row.samples_ms;
|
|
76
|
+
decision = { ...decision, outcome: passed === workload.config.samples ? 'passed' : 'failed',
|
|
77
|
+
checks_total: workload.config.samples, checks_passed: passed,
|
|
78
|
+
benchmark_eligibility: passed === workload.config.samples ? 'eligible' : 'ineligible',
|
|
79
|
+
reason: passed === workload.config.samples ? 'Every measured checksum matched the independent integer oracle.' : 'A measured checksum failed the independent integer oracle.',
|
|
80
|
+
measurement: { samples_ms: samples, value_ms: [...samples].sort((a, b) => a - b)[Math.floor(samples.length / 2)],
|
|
81
|
+
unit: 'ms', timing_domain: 'node_performance_now', scope: 'integer_sum_kernel', rank: 0, world_size: 1 } };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
receipt.end_source = (await captureVerifierInputs(context, request.source_paths)).source;
|
|
86
|
+
receipt.source_binding = receipt.source.coverage === 'complete' && receipt.end_source.coverage === 'complete'
|
|
87
|
+
&& receipt.source.source_id === receipt.end_source.source_id ? 'observed_endpoints' : 'unknown';
|
|
88
|
+
receipt.artifact_refs = receipt.source.files.filter(file => file.kind === 'file').map(file => ({ origin: 'local',
|
|
89
|
+
path: join(receipt.source.cwd, file.path), sha256: file.sha256 }));
|
|
90
|
+
if (decision.benchmark_eligibility === 'eligible' && receipt.source_binding !== 'observed_endpoints') {
|
|
91
|
+
decision.benchmark_eligibility = 'ineligible';
|
|
92
|
+
decision.reason = 'Inputs/configuration changed or became unavailable during the measured run.';
|
|
93
|
+
}
|
|
94
|
+
const admitted = parseBenchmarkVerifierDecision(decision, receipt);
|
|
95
|
+
if (!admitted || !parseCommandVerificationReceipt(receipt))
|
|
96
|
+
throw new Error('The CPU adapter produced an invalid bounded decision');
|
|
97
|
+
context.onVerificationReceipt?.(receipt);
|
|
98
|
+
if (!context.signal?.aborted)
|
|
99
|
+
context.onHostVerifier?.(receipt, admitted);
|
|
100
|
+
return JSON.stringify({ verification: receipt, verifier: admitted });
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseBenchmarkVerifierDecision } from '../runtime/benchmark_contract.js';
|
|
2
|
+
import { compareRegisteredBenchmarks, parseBenchmarkComparisonDecision } from '../runtime/benchmark_comparison.js';
|
|
3
|
+
import { ToolCapability } from '../runtime/capabilities.js';
|
|
4
|
+
import { parseCommandVerificationReceipt } from '../runtime/source_verification_contract.js';
|
|
5
|
+
async function observed(id, context) {
|
|
6
|
+
const row = context.toolResponseStore.evidence.getSnapshot().records.find(record => record.id === id);
|
|
7
|
+
if (!row || row.kind !== 'observation' || row.partial || row.isError || row.availability === 'unavailable'
|
|
8
|
+
|| row.source.origin !== 'host_receipt' || row.source.toolName !== 'benchmark_cpu' || !row.source.toolCallId)
|
|
9
|
+
return null;
|
|
10
|
+
const receipt = parseCommandVerificationReceipt(row.source.verification);
|
|
11
|
+
const decision = receipt && parseBenchmarkVerifierDecision(row.source.verifier, receipt);
|
|
12
|
+
if (!receipt || !decision)
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
const original = await context.toolResponseStore.getChunk(row.source.toolCallId, { cursor: 0, maxBytes: 32768 });
|
|
16
|
+
if (!original || original.totalBytes > 65536 || original.observationId !== row.id || original.sha256 !== row.resultSha256)
|
|
17
|
+
return null;
|
|
18
|
+
if (!original.complete) {
|
|
19
|
+
const tail = await context.toolResponseStore.getChunk(row.source.toolCallId, { cursor: original.nextCursor, maxBytes: 32768 });
|
|
20
|
+
if (!tail || !tail.complete || tail.observationId !== row.id || tail.sha256 !== row.resultSha256)
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return { id: row.id, receipt, decision };
|
|
28
|
+
}
|
|
29
|
+
export const compareBenchmarksTool = Object.freeze({
|
|
30
|
+
capabilities: Object.freeze([ToolCapability.FILE_READ]), effect: 'read', parallelSafe: true,
|
|
31
|
+
definition: { name: 'compare_benchmarks',
|
|
32
|
+
description: 'Compare two retained host-admitted benchmark_cpu observations by their original observation IDs. Require independent measured runs with the same captured input/workload, checker, runner and declared host/runtime/measurement conditions; registered program/source identities may differ. Copied JSON, generic command output, incomplete or unavailable records cannot admit eligibility. Returns only the scoped historical CPU-fixture comparison; a measured delta never proves a causal win, production/GPU performance or a plateau.',
|
|
33
|
+
parameters: { type: 'object', additionalProperties: false, properties: {
|
|
34
|
+
observation_ids: { type: 'array', items: { type: 'string' }, minItems: 2, maxItems: 2, uniqueItems: true },
|
|
35
|
+
}, required: ['observation_ids'] } },
|
|
36
|
+
execute: async (args, context) => {
|
|
37
|
+
if (!context)
|
|
38
|
+
throw new Error('compare_benchmarks requires a host evidence context');
|
|
39
|
+
const ids = args.observation_ids;
|
|
40
|
+
if (Object.keys(args).length !== 1 || !Array.isArray(ids) || ids.length !== 2
|
|
41
|
+
|| ids.some(id => typeof id !== 'string' || !id.trim() || Buffer.byteLength(id) > 256 || /[\u0000-\u001f\u007f]/u.test(id))
|
|
42
|
+
|| ids[0] === ids[1])
|
|
43
|
+
throw new TypeError('compare_benchmarks requires two distinct bounded original observation IDs');
|
|
44
|
+
const baseline = await observed(ids[0], context);
|
|
45
|
+
const candidate = await observed(ids[1], context);
|
|
46
|
+
const decision = parseBenchmarkComparisonDecision(compareRegisteredBenchmarks(baseline, candidate));
|
|
47
|
+
if (!decision)
|
|
48
|
+
throw new Error('The host comparator produced an invalid bounded decision');
|
|
49
|
+
if (!context.signal?.aborted)
|
|
50
|
+
context.onHostBenchmarkComparison?.(decision);
|
|
51
|
+
return JSON.stringify(decision);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
export const CORE_DISCOVERY_TOOL_NAMES = new Set([
|
|
15
15
|
'tool_search',
|
|
16
16
|
'recall_tool_response',
|
|
17
|
+
'session_evidence',
|
|
17
18
|
]);
|
|
18
19
|
export const ALWAYS_LOADED_TOOL_NAMES = new Set([
|
|
19
20
|
// Core file + shell + search (analogues of claw-code's shell/read/write/edit/glob/grep)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* The sub-agent runs in isolation and only returns a summary, keeping the
|
|
6
6
|
* main agent's context clean.
|
|
7
7
|
*/
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
8
9
|
import { ToolCapability } from '../runtime/capabilities.js';
|
|
9
10
|
import { getWorkerExecutor } from '../../worker/index.js';
|
|
10
11
|
import { renderPrompt } from '../../utils/template.js';
|
|
@@ -24,7 +25,8 @@ export const delegateTaskTool = {
|
|
|
24
25
|
max_iterations: {
|
|
25
26
|
type: 'string',
|
|
26
27
|
description: 'Maximum iterations for the sub-agent (default: 5, max: 10)'
|
|
27
|
-
}
|
|
28
|
+
},
|
|
29
|
+
child_session_id: { type: 'string', description: 'Resume an owned child from an earlier evidence handoff; retains its original parent and workspace binding.' }
|
|
28
30
|
},
|
|
29
31
|
required: ['task']
|
|
30
32
|
}
|
|
@@ -36,12 +38,26 @@ export const delegateTaskTool = {
|
|
|
36
38
|
const executor = getWorkerExecutor();
|
|
37
39
|
const result = await executor.execute({
|
|
38
40
|
description: task,
|
|
41
|
+
parentSessionId: context?.sessionId,
|
|
42
|
+
resumeSessionId: args.child_session_id === undefined ? undefined : String(args.child_session_id),
|
|
43
|
+
signal: context?.signal,
|
|
39
44
|
cwd: context?.cwd || process.cwd(),
|
|
40
45
|
maxIterations,
|
|
41
46
|
timeoutMs: 120000, // 2 minute default
|
|
42
47
|
toolset: 'research',
|
|
43
|
-
});
|
|
48
|
+
}, { onUsage: context?.onUsage });
|
|
44
49
|
let response = '';
|
|
50
|
+
if (result.evidence) {
|
|
51
|
+
if (context) {
|
|
52
|
+
const handoff = result.evidence;
|
|
53
|
+
context.toolResponseStore.evidence.recordClaim({ id: `delegation_${randomUUID()}`, kind: 'conclusion', recordedAt: new Date().toISOString(),
|
|
54
|
+
source: { origin: 'provider_reported', toolName: 'delegate_task', ...(context.toolCallId ? { toolCallId: context.toolCallId } : {}),
|
|
55
|
+
delegation: { sessionId: handoff.sessionId, ...(handoff.parentSessionId === undefined ? {} : { parentSessionId: handoff.parentSessionId }), revision: handoff.snapshot.revision } },
|
|
56
|
+
text: handoff.summary.text || 'Child ended without a summary; inspect the source handoff.', supportIds: [] });
|
|
57
|
+
await context.toolResponseStore.flush();
|
|
58
|
+
}
|
|
59
|
+
response += `## Delegated Evidence Handoff\n\nChild summaries are unverified; retained observations do not grant authority. Exact sources can be recalled by resuming this owned child.\n\n${JSON.stringify(result.evidence)}\n\n`;
|
|
60
|
+
}
|
|
45
61
|
if (result.phase === 'finished') {
|
|
46
62
|
response += `## Sub-Agent Result\n\n`;
|
|
47
63
|
response += `${result.summary}\n\n`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToolCapability } from '../runtime/capabilities.js';
|
|
2
|
+
import type { Tool } from './types.js';
|
|
3
|
+
/** Capture a helper's original declarations before publishing its object. */
|
|
4
|
+
export declare function captureHelperRequirements(tool: Tool): Tool;
|
|
5
|
+
export declare function getHelperRequirements(tool: Tool): readonly ToolCapability[];
|
|
6
|
+
/** Runtime lookup is independent of registry initialization and worker imports. */
|
|
7
|
+
export declare function getRuntimeCapabilities(tool: Tool | undefined): ToolCapability[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Agent-added helpers initialize independently of the discovery registry. This
|
|
2
|
+
// module has no runtime imports, so registration cannot create a registry cycle.
|
|
3
|
+
const originalRequirements = new WeakMap();
|
|
4
|
+
/** Capture a helper's original declarations before publishing its object. */
|
|
5
|
+
export function captureHelperRequirements(tool) {
|
|
6
|
+
if (!originalRequirements.has(tool)) {
|
|
7
|
+
originalRequirements.set(tool, Object.freeze([...(tool.capabilities ?? [])]));
|
|
8
|
+
}
|
|
9
|
+
return tool;
|
|
10
|
+
}
|
|
11
|
+
export function getHelperRequirements(tool) {
|
|
12
|
+
return originalRequirements.get(tool) ?? [];
|
|
13
|
+
}
|
|
14
|
+
/** Runtime lookup is independent of registry initialization and worker imports. */
|
|
15
|
+
export function getRuntimeCapabilities(tool) {
|
|
16
|
+
if (!tool)
|
|
17
|
+
return [];
|
|
18
|
+
return [...new Set([...getHelperRequirements(tool), ...(tool.capabilities ?? [])])];
|
|
19
|
+
}
|
|
@@ -6,6 +6,7 @@ export declare function getTool(name: string, tools?: Tool[]): Tool | undefined;
|
|
|
6
6
|
export declare function executeTool(name: string, args: Record<string, unknown>, tools?: Tool[], context?: ToolContext): Promise<string>;
|
|
7
7
|
export { readFileTool, writeFileTool, editFileTool, listDirectoryTool } from './file.js';
|
|
8
8
|
export { searchTool } from './search.js';
|
|
9
|
+
export { relatedSessionsTool } from './related_sessions.js';
|
|
9
10
|
export { listSkillsTool, invokeSkillTool } from './skills.js';
|
|
10
11
|
export { runCommandTool } from './shell.js';
|
|
11
12
|
export { zergQueryTool, zergTaskStatusTool, zergListTool } from './zerg.js';
|
|
@@ -2,6 +2,7 @@ import { defaultTools as baseDefaultTools } from './registry.js';
|
|
|
2
2
|
import { sendMessageTool, askZtcPaneTool, contactExternalTool } from './bus_message.js';
|
|
3
3
|
import { toolSearchTool } from './tool_search.js';
|
|
4
4
|
import { recallToolResponseTool } from './recall_tool_response.js';
|
|
5
|
+
import { sessionEvidenceTool } from './session_evidence.js';
|
|
5
6
|
import { proposeWorldMutationTool } from './world_mutation.js';
|
|
6
7
|
import { adaptationRunTool } from './adaptation.js';
|
|
7
8
|
// --- Tool Registry ---
|
|
@@ -9,6 +10,7 @@ export const defaultTools = [
|
|
|
9
10
|
...baseDefaultTools,
|
|
10
11
|
toolSearchTool,
|
|
11
12
|
recallToolResponseTool,
|
|
13
|
+
sessionEvidenceTool,
|
|
12
14
|
adaptationRunTool,
|
|
13
15
|
];
|
|
14
16
|
export function getToolDefinitions(tools = defaultTools) {
|
|
@@ -26,6 +28,7 @@ export async function executeTool(name, args, tools = defaultTools, context) {
|
|
|
26
28
|
}
|
|
27
29
|
export { readFileTool, writeFileTool, editFileTool, listDirectoryTool } from './file.js';
|
|
28
30
|
export { searchTool } from './search.js';
|
|
31
|
+
export { relatedSessionsTool } from './related_sessions.js';
|
|
29
32
|
export { listSkillsTool, invokeSkillTool } from './skills.js';
|
|
30
33
|
export { runCommandTool } from './shell.js';
|
|
31
34
|
export { zergQueryTool, zergTaskStatusTool, zergListTool } from './zerg.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type MeasurementComparison, type MeasurementCompatibility, type MeasurementCompletion, type MeasurementReason, type MeasurementReport } from '../runtime/measurements.js';
|
|
2
|
+
import type { Tool } from './types.js';
|
|
3
|
+
export interface MeasurementSourceLink {
|
|
4
|
+
observationId: string;
|
|
5
|
+
toolCallId: string;
|
|
6
|
+
resultSha256: string;
|
|
7
|
+
jobId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MeasurementToolResult {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
verification: 'unknown';
|
|
12
|
+
benchmarkEligibility: 'unknown';
|
|
13
|
+
compatibility: MeasurementCompatibility;
|
|
14
|
+
completion: MeasurementCompletion;
|
|
15
|
+
execution: 'completed' | 'running' | 'failed' | 'unknown';
|
|
16
|
+
reports: MeasurementReport[];
|
|
17
|
+
comparison: MeasurementComparison | null;
|
|
18
|
+
sources: MeasurementSourceLink[];
|
|
19
|
+
reasons: MeasurementReason[];
|
|
20
|
+
}
|
|
21
|
+
/** Read an original retained managed receipt before assessing producer measurement JSON. */
|
|
22
|
+
export declare const measurementReportTool: Tool;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { assessMeasurements, compareMeasurements, parseMeasurementEnvelope, parseMeasurementRequirements } from '../runtime/measurements.js';
|
|
3
|
+
import { ToolCapability } from '../runtime/capabilities.js';
|
|
4
|
+
import { ToolResponseIntegrityError } from '../tool_response_store.js';
|
|
5
|
+
const observationIdsSchema = { type: 'array', description: 'One retained observation, or baseline then candidate observations.',
|
|
6
|
+
items: { type: 'string' }, minItems: 1, maxItems: 2, uniqueItems: true };
|
|
7
|
+
const measurementParameters = {
|
|
8
|
+
type: 'object',
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
properties: {
|
|
11
|
+
observation_ids: observationIdsSchema,
|
|
12
|
+
requirements: { type: 'object', description: 'Expected workload, instrumentation, selected metrics, units, timing domain, scope, ranks and smoke fields.' },
|
|
13
|
+
},
|
|
14
|
+
required: ['observation_ids', 'requirements'],
|
|
15
|
+
};
|
|
16
|
+
const SOURCE_BYTES = 32768;
|
|
17
|
+
const REPORT_BYTES = 65536;
|
|
18
|
+
const managedTools = new Set(['run_command', 'read_command']);
|
|
19
|
+
const statuses = new Set(['running', 'completed', 'failed', 'cancelled', 'timed_out', 'interrupted']);
|
|
20
|
+
const reason = (code, message) => ({ code, message });
|
|
21
|
+
function unknown(reasons, sources = [], execution = 'unknown') {
|
|
22
|
+
return { ok: false, verification: 'unknown', benchmarkEligibility: 'unknown', compatibility: 'unknown',
|
|
23
|
+
completion: execution === 'running' ? 'incomplete' : 'unknown', execution, reports: [], comparison: null, sources, reasons };
|
|
24
|
+
}
|
|
25
|
+
function prefix(text, maxBytes) {
|
|
26
|
+
let kept = '';
|
|
27
|
+
let size = 0;
|
|
28
|
+
for (const character of text) {
|
|
29
|
+
const bytes = Buffer.byteLength(character);
|
|
30
|
+
if (size + bytes > maxBytes)
|
|
31
|
+
break;
|
|
32
|
+
kept += character;
|
|
33
|
+
size += bytes;
|
|
34
|
+
}
|
|
35
|
+
return kept;
|
|
36
|
+
}
|
|
37
|
+
function serialize(result) {
|
|
38
|
+
const bounded = (rows) => rows.slice(0, 32).map(row => ({ code: prefix(row.code, 128), message: prefix(row.message, 512) }));
|
|
39
|
+
result.reasons = bounded(result.reasons);
|
|
40
|
+
for (const report of result.reports)
|
|
41
|
+
report.reasons = bounded(report.reasons);
|
|
42
|
+
if (result.comparison) {
|
|
43
|
+
result.comparison.reasons = bounded(result.comparison.reasons);
|
|
44
|
+
result.comparison.baseline.reasons = bounded(result.comparison.baseline.reasons);
|
|
45
|
+
result.comparison.candidate.reasons = bounded(result.comparison.candidate.reasons);
|
|
46
|
+
}
|
|
47
|
+
const output = JSON.stringify(result);
|
|
48
|
+
return Buffer.byteLength(output) <= REPORT_BYTES ? output : JSON.stringify(unknown([
|
|
49
|
+
reason('report_too_large', 'The aggregate measurement report exceeds65536 UTF8 bytes; narrow the selected metrics.'),
|
|
50
|
+
], result.sources));
|
|
51
|
+
}
|
|
52
|
+
function validReceipt(value, observation, context) {
|
|
53
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
54
|
+
return false;
|
|
55
|
+
const row = value;
|
|
56
|
+
const job = observation.source.job;
|
|
57
|
+
if (!job || (context.sessionId !== undefined && job.sessionId !== context.sessionId)
|
|
58
|
+
|| typeof row.job_id !== 'string' || row.job_id !== job.jobId || typeof row.status !== 'string' || !statuses.has(row.status) || row.status !== job.status
|
|
59
|
+
|| typeof row.cwd !== 'string' || typeof row.command !== 'string' || typeof row.log_path !== 'string'
|
|
60
|
+
|| (observation.source.cwd !== undefined && row.cwd !== observation.source.cwd)
|
|
61
|
+
|| (observation.source.artifact !== undefined && row.log_path !== observation.source.artifact.path)
|
|
62
|
+
|| typeof row.started_at !== 'string' || !Number.isFinite(Date.parse(row.started_at)) || row.started_at !== job.startedAt
|
|
63
|
+
|| row.ended_at !== job.endedAt || (row.exit_code ?? null) !== job.exitCode
|
|
64
|
+
|| (row.exit_code !== undefined && !Number.isSafeInteger(row.exit_code))
|
|
65
|
+
|| typeof row.output !== 'string' || !Number.isSafeInteger(row.cursor) || row.cursor < Buffer.byteLength(row.output)
|
|
66
|
+
|| row.cursor !== job.cursor || typeof row.has_more !== 'boolean' || row.has_more !== job.hasMore
|
|
67
|
+
|| (row.output_truncated !== undefined && typeof row.output_truncated !== 'boolean')
|
|
68
|
+
|| Boolean(row.output_truncated) !== job.outputTruncated)
|
|
69
|
+
return false;
|
|
70
|
+
if (row.status === 'running')
|
|
71
|
+
return row.ended_at === undefined && row.exit_code === undefined;
|
|
72
|
+
return typeof row.ended_at === 'string' && Number.isFinite(Date.parse(row.ended_at))
|
|
73
|
+
&& Date.parse(row.ended_at) >= Date.parse(row.started_at) && Number.isSafeInteger(row.exit_code);
|
|
74
|
+
}
|
|
75
|
+
async function capture(id, context) {
|
|
76
|
+
const store = context.toolResponseStore;
|
|
77
|
+
const row = store.evidence.getSnapshot().records.find(record => record.id === id);
|
|
78
|
+
if (row?.kind !== 'observation')
|
|
79
|
+
return { error: reason('missing_observation', 'The requested retained observation is unavailable or is an interpretation.') };
|
|
80
|
+
if (row.source.origin !== 'host_receipt' || !managedTools.has(row.source.toolName ?? '') || !row.source.job
|
|
81
|
+
|| !row.source.toolCallId || !/^[A-Za-z0-9_-]{1,256}$/.test(row.source.toolCallId)) {
|
|
82
|
+
return { error: reason('untrusted_source', 'Measurement assessment requires original host receipt provenance from a managed command.') };
|
|
83
|
+
}
|
|
84
|
+
if (row.partial || row.availability === 'unavailable')
|
|
85
|
+
return { error: reason('source_incomplete', 'The original source is partial or unavailable.') };
|
|
86
|
+
if (row.resultBytes > SOURCE_BYTES)
|
|
87
|
+
return { error: reason('source_too_large', 'The original receipt exceeds the32768 byte complete source retrieval limit.') };
|
|
88
|
+
let chunk;
|
|
89
|
+
try {
|
|
90
|
+
chunk = await store.getChunk(row.source.toolCallId, { cursor: 0, maxBytes: SOURCE_BYTES });
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (!(error instanceof ToolResponseIntegrityError))
|
|
94
|
+
throw error;
|
|
95
|
+
return { error: reason('source_integrity', 'The original retained source failed its identity or SHA256 integrity check.') };
|
|
96
|
+
}
|
|
97
|
+
if (!chunk || !chunk.complete || chunk.availability === 'unavailable')
|
|
98
|
+
return { error: reason('source_incomplete', 'A complete original retained receipt is unavailable.') };
|
|
99
|
+
const meta = store.getMeta(row.source.toolCallId);
|
|
100
|
+
if (chunk.toolUseId !== row.source.toolCallId || chunk.observationId !== row.id || chunk.cursor !== 0
|
|
101
|
+
|| chunk.totalBytes !== row.resultBytes || chunk.nextCursor !== chunk.totalBytes || chunk.sha256 !== row.resultSha256
|
|
102
|
+
|| createHash('sha256').update(chunk.content).digest('hex') !== row.resultSha256
|
|
103
|
+
|| meta?.observation_id !== row.id || meta.tool_name !== row.source.toolName) {
|
|
104
|
+
return { error: reason('source_integrity', 'The retrieved source identity, byte count or SHA256 digest disagrees with its retained observation.') };
|
|
105
|
+
}
|
|
106
|
+
let receipt;
|
|
107
|
+
try {
|
|
108
|
+
receipt = JSON.parse(chunk.content);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (!(error instanceof SyntaxError))
|
|
112
|
+
throw error;
|
|
113
|
+
return { error: reason('invalid_receipt', 'The original managed receipt must be an entire JSON document.') };
|
|
114
|
+
}
|
|
115
|
+
if (!validReceipt(receipt, row, context))
|
|
116
|
+
return { error: reason('receipt_mismatch', 'The original receipt does not match its retained job identity or lifecycle fields.') };
|
|
117
|
+
const captured = { link: { observationId: row.id, toolCallId: row.source.toolCallId,
|
|
118
|
+
resultSha256: row.resultSha256, jobId: receipt.job_id }, sessionId: row.source.job.sessionId, receipt };
|
|
119
|
+
if (receipt.cursor !== Buffer.byteLength(receipt.output) || receipt.has_more || receipt.output_truncated) {
|
|
120
|
+
return { ...captured, error: reason('source_incomplete', 'The managed receipt does not contain complete command output from byte0, or its output is truncated.') };
|
|
121
|
+
}
|
|
122
|
+
if (receipt.status !== 'completed' || receipt.exit_code !== 0)
|
|
123
|
+
return captured;
|
|
124
|
+
if (row.isError)
|
|
125
|
+
return { ...captured, error: reason('source_error', 'The original captured source is marked as an execution error.') };
|
|
126
|
+
let output;
|
|
127
|
+
try {
|
|
128
|
+
output = JSON.parse(receipt.output);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (!(error instanceof SyntaxError))
|
|
132
|
+
throw error;
|
|
133
|
+
return { ...captured, error: reason('invalid_output', 'Measurement output must be an entire JSON document; surrounding prose is not removed.') };
|
|
134
|
+
}
|
|
135
|
+
const envelope = parseMeasurementEnvelope(output);
|
|
136
|
+
return envelope ? { ...captured, envelope }
|
|
137
|
+
: { ...captured, error: reason('invalid_output', 'The original JSON document is not a supported bounded measurement envelope.') };
|
|
138
|
+
}
|
|
139
|
+
/** Read an original retained managed receipt before assessing producer measurement JSON. */
|
|
140
|
+
export const measurementReportTool = {
|
|
141
|
+
capabilities: [ToolCapability.FILE_READ],
|
|
142
|
+
effect: 'read',
|
|
143
|
+
parallelSafe: true,
|
|
144
|
+
definition: {
|
|
145
|
+
name: 'measurement_report',
|
|
146
|
+
description: 'Assess or compare structured measurements from one or two retained managed-command observations. Supply observation IDs and measurement requirements, never copied values or receipts. Compatibility does not establish verification or benchmark eligibility.',
|
|
147
|
+
parameters: measurementParameters,
|
|
148
|
+
},
|
|
149
|
+
execute: async (args, context) => {
|
|
150
|
+
const unsupported = Object.keys(args).find(key => key !== 'observation_ids' && key !== 'requirements');
|
|
151
|
+
if (unsupported)
|
|
152
|
+
throw new TypeError(`measurement_report: unsupported argument ${unsupported}`);
|
|
153
|
+
const ids = args.observation_ids;
|
|
154
|
+
if (!Array.isArray(ids) || ids.length < 1 || ids.length > 2 || ids.some(id => typeof id !== 'string' || !id.trim()
|
|
155
|
+
|| Buffer.byteLength(id) > 256 || /[\u0000-\u001f\u007f]/u.test(id)) || new Set(ids).size !== ids.length) {
|
|
156
|
+
throw new TypeError('measurement_report: observation_ids must contain one or two unique bounded nonempty observation IDs');
|
|
157
|
+
}
|
|
158
|
+
const required = parseMeasurementRequirements(args.requirements);
|
|
159
|
+
if (!required)
|
|
160
|
+
throw new TypeError('measurement_report: requirements must match the supported bounded measurement schema');
|
|
161
|
+
if (!context)
|
|
162
|
+
throw new Error('measurement_report: store unavailable');
|
|
163
|
+
const captures = [];
|
|
164
|
+
for (const id of ids)
|
|
165
|
+
captures.push(await capture(id, context));
|
|
166
|
+
const sources = captures.flatMap(item => item.link ? [item.link] : []);
|
|
167
|
+
const errors = captures.flatMap(item => item.error ? [item.error] : []);
|
|
168
|
+
if (errors.length)
|
|
169
|
+
return serialize(unknown(errors, sources));
|
|
170
|
+
if (captures.length === 2 && captures[0].sessionId === captures[1].sessionId
|
|
171
|
+
&& captures[0].receipt.job_id === captures[1].receipt.job_id) {
|
|
172
|
+
return serialize(unknown([reason('alias_source', 'Two observations of the same canonical managed job are not independent comparison runs.')], sources));
|
|
173
|
+
}
|
|
174
|
+
if (captures.some(item => item.receipt.status !== 'completed' && item.receipt.status !== 'running'
|
|
175
|
+
|| (item.receipt.exit_code !== undefined && item.receipt.exit_code !== 0))) {
|
|
176
|
+
return serialize(unknown([reason('execution_failed', 'The original managed process did not complete successfully; measurement admission is unavailable.')], sources, 'failed'));
|
|
177
|
+
}
|
|
178
|
+
if (captures.some(item => item.receipt.status === 'running')) {
|
|
179
|
+
return serialize(unknown([reason('execution_running', 'The original managed job is still running; a passed-false progress report is incomplete.')], sources, 'running'));
|
|
180
|
+
}
|
|
181
|
+
const comparison = captures.length === 2 ? compareMeasurements(captures[0].envelope, captures[1].envelope, required) : null;
|
|
182
|
+
const reports = comparison ? [comparison.baseline, comparison.candidate] : [assessMeasurements(captures[0].envelope, required)];
|
|
183
|
+
const completion = reports.some(report => report.completion === 'reported_fail') ? 'reported_fail'
|
|
184
|
+
: reports.some(report => report.completion === 'incomplete') ? 'incomplete'
|
|
185
|
+
: reports.every(report => report.completion === 'reported_pass') ? 'reported_pass' : 'unknown';
|
|
186
|
+
return serialize({ ok: true, verification: 'unknown', benchmarkEligibility: 'unknown', execution: 'completed', completion,
|
|
187
|
+
compatibility: comparison?.compatibility ?? reports[0].compatibility, reports, comparison, sources,
|
|
188
|
+
reasons: comparison?.reasons ?? reports[0].reasons });
|
|
189
|
+
},
|
|
190
|
+
};
|