@orion-agents/orion-code 0.1.3 → 0.1.4-2
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 +26 -4
- package/README.zh-CN.md +41 -5
- package/dist/agents/coder.d.ts.map +1 -1
- package/dist/agents/coder.js.map +1 -1
- package/dist/agents/fork.d.ts +12 -4
- package/dist/agents/fork.d.ts.map +1 -1
- package/dist/agents/fork.js +28 -32
- package/dist/agents/fork.js.map +1 -1
- package/dist/agents/leader.d.ts.map +1 -1
- package/dist/agents/leader.js.map +1 -1
- package/dist/agents/worker-pool.d.ts.map +1 -1
- package/dist/agents/worker-pool.js +38 -29
- package/dist/agents/worker-pool.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +0 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/context-commands.d.ts +4 -0
- package/dist/commands/context-commands.d.ts.map +1 -0
- package/dist/commands/context-commands.js +52 -0
- package/dist/commands/context-commands.js.map +1 -0
- package/dist/commands/context-tool-command-handlers.d.ts +13 -0
- package/dist/commands/context-tool-command-handlers.d.ts.map +1 -0
- package/dist/commands/context-tool-command-handlers.js +573 -0
- package/dist/commands/context-tool-command-handlers.js.map +1 -0
- package/dist/commands/core-command-handlers.d.ts +12 -0
- package/dist/commands/core-command-handlers.d.ts.map +1 -0
- package/dist/commands/core-command-handlers.js +798 -0
- package/dist/commands/core-command-handlers.js.map +1 -0
- package/dist/commands/diagnostic-command-handlers.d.ts +14 -0
- package/dist/commands/diagnostic-command-handlers.d.ts.map +1 -0
- package/dist/commands/diagnostic-command-handlers.js +1043 -0
- package/dist/commands/diagnostic-command-handlers.js.map +1 -0
- package/dist/commands/diagnostic-commands.d.ts +4 -0
- package/dist/commands/diagnostic-commands.d.ts.map +1 -0
- package/dist/commands/diagnostic-commands.js +132 -0
- package/dist/commands/diagnostic-commands.js.map +1 -0
- package/dist/commands/index.d.ts +7 -8
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +34 -3562
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/legacy-commands.d.ts +4 -0
- package/dist/commands/legacy-commands.d.ts.map +1 -0
- package/dist/commands/legacy-commands.js +44 -0
- package/dist/commands/legacy-commands.js.map +1 -0
- package/dist/commands/model-command-handlers.d.ts +13 -0
- package/dist/commands/model-command-handlers.d.ts.map +1 -0
- package/dist/commands/model-command-handlers.js +314 -0
- package/dist/commands/model-command-handlers.js.map +1 -0
- package/dist/commands/model-commands.d.ts +4 -0
- package/dist/commands/model-commands.d.ts.map +1 -0
- package/dist/commands/model-commands.js +52 -0
- package/dist/commands/model-commands.js.map +1 -0
- package/dist/commands/session-command-handlers.d.ts +9 -0
- package/dist/commands/session-command-handlers.d.ts.map +1 -0
- package/dist/commands/session-command-handlers.js +566 -0
- package/dist/commands/session-command-handlers.js.map +1 -0
- package/dist/commands/session-commands.d.ts +4 -0
- package/dist/commands/session-commands.d.ts.map +1 -0
- package/dist/commands/session-commands.js +78 -0
- package/dist/commands/session-commands.js.map +1 -0
- package/dist/commands/system-commands.d.ts +4 -0
- package/dist/commands/system-commands.d.ts.map +1 -0
- package/dist/commands/system-commands.js +92 -0
- package/dist/commands/system-commands.js.map +1 -0
- package/dist/commands/target-command.d.ts.map +1 -1
- package/dist/commands/target-command.js +29 -2
- package/dist/commands/target-command.js.map +1 -1
- package/dist/commands/tool-commands.d.ts +4 -0
- package/dist/commands/tool-commands.d.ts.map +1 -0
- package/dist/commands/tool-commands.js +49 -0
- package/dist/commands/tool-commands.js.map +1 -0
- package/dist/commands/types.d.ts +4 -4
- package/dist/commands/workflow-command-handlers.d.ts +7 -0
- package/dist/commands/workflow-command-handlers.d.ts.map +1 -0
- package/dist/commands/workflow-command-handlers.js +35 -0
- package/dist/commands/workflow-command-handlers.js.map +1 -0
- package/dist/commands/workflow-commands.d.ts +4 -0
- package/dist/commands/workflow-commands.d.ts.map +1 -0
- package/dist/commands/workflow-commands.js +92 -0
- package/dist/commands/workflow-commands.js.map +1 -0
- package/dist/core/checkpoint.d.ts +12 -4
- package/dist/core/checkpoint.d.ts.map +1 -1
- package/dist/core/checkpoint.js +114 -28
- package/dist/core/checkpoint.js.map +1 -1
- package/dist/core/cost-tracker.d.ts +5 -1
- package/dist/core/cost-tracker.d.ts.map +1 -1
- package/dist/core/cost-tracker.js +12 -2
- package/dist/core/cost-tracker.js.map +1 -1
- package/dist/core/warn-dedup.d.ts +3 -0
- package/dist/core/warn-dedup.d.ts.map +1 -1
- package/dist/core/warn-dedup.js +6 -6
- package/dist/core/warn-dedup.js.map +1 -1
- package/dist/framework/index.d.ts +1 -1
- package/dist/framework/index.d.ts.map +1 -1
- package/dist/framework/index.js.map +1 -1
- package/dist/framework/prompt.d.ts +2 -2
- package/dist/framework/query.d.ts +2 -2
- package/dist/framework/query.d.ts.map +1 -1
- package/dist/framework/query.js +57 -10
- package/dist/framework/query.js.map +1 -1
- package/dist/framework/store.d.ts +4 -4
- package/dist/framework/tool-scheduler.d.ts +16 -13
- package/dist/framework/tool-scheduler.d.ts.map +1 -1
- package/dist/framework/tool-scheduler.js +135 -32
- package/dist/framework/tool-scheduler.js.map +1 -1
- package/dist/framework/tool.d.ts +30 -2
- package/dist/framework/tool.d.ts.map +1 -1
- package/dist/framework/tool.js +27 -1
- package/dist/framework/tool.js.map +1 -1
- package/dist/harness/assembler.d.ts.map +1 -1
- package/dist/harness/assembler.js +4 -2
- package/dist/harness/assembler.js.map +1 -1
- package/dist/harness/evidence.d.ts.map +1 -1
- package/dist/harness/evidence.js +3 -2
- package/dist/harness/evidence.js.map +1 -1
- package/dist/harness/safety.d.ts +11 -1
- package/dist/harness/safety.d.ts.map +1 -1
- package/dist/harness/safety.js +112 -16
- package/dist/harness/safety.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +4 -8
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +4 -4
- package/dist/init.js.map +1 -1
- package/dist/ink-ui/App.d.ts +2 -2
- package/dist/ink-ui/components/Markdown.d.ts.map +1 -1
- package/dist/ink-ui/components/Markdown.js.map +1 -1
- package/dist/ink-ui/components/PixelHorseBanner.d.ts +2 -2
- package/dist/ink-ui/components/StatusLine.d.ts +2 -2
- package/dist/ink-ui/launch.d.ts +2 -2
- package/dist/ink-ui/screens/ReplScreen.d.ts +2 -2
- package/dist/ink-ui/screens/ReplScreen.js.map +1 -1
- package/dist/memory/embeddings.d.ts.map +1 -1
- package/dist/memory/embeddings.js +3 -2
- package/dist/memory/embeddings.js.map +1 -1
- package/dist/memory/relevant-finder.d.ts +2 -1
- package/dist/memory/relevant-finder.d.ts.map +1 -1
- package/dist/memory/relevant-finder.js +17 -8
- package/dist/memory/relevant-finder.js.map +1 -1
- package/dist/memory/semantic-config.d.ts +9 -0
- package/dist/memory/semantic-config.d.ts.map +1 -0
- package/dist/memory/semantic-config.js +16 -0
- package/dist/memory/semantic-config.js.map +1 -0
- package/dist/memory/semantic-search.d.ts +1 -6
- package/dist/memory/semantic-search.d.ts.map +1 -1
- package/dist/memory/semantic-search.js +5 -16
- package/dist/memory/semantic-search.js.map +1 -1
- package/dist/memory/storage.d.ts +23 -0
- package/dist/memory/storage.d.ts.map +1 -1
- package/dist/memory/storage.js +109 -8
- package/dist/memory/storage.js.map +1 -1
- package/dist/memory/vector-store.d.ts +12 -0
- package/dist/memory/vector-store.d.ts.map +1 -1
- package/dist/memory/vector-store.js +139 -18
- package/dist/memory/vector-store.js.map +1 -1
- package/dist/migration/command.d.ts.map +1 -1
- package/dist/migration/command.js +0 -1
- package/dist/migration/command.js.map +1 -1
- package/dist/migration/migrate.d.ts.map +1 -1
- package/dist/migration/migrate.js +43 -109
- package/dist/migration/migrate.js.map +1 -1
- package/dist/migration/types.d.ts +0 -1
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/print-ui/launch.d.ts +10 -3
- package/dist/print-ui/launch.d.ts.map +1 -1
- package/dist/print-ui/launch.js +18 -0
- package/dist/print-ui/launch.js.map +1 -1
- package/dist/product/environment.d.ts +3 -5
- package/dist/product/environment.d.ts.map +1 -1
- package/dist/product/environment.js +4 -32
- package/dist/product/environment.js.map +1 -1
- package/dist/product/index.d.ts +1 -1
- package/dist/product/index.d.ts.map +1 -1
- package/dist/product/index.js +1 -3
- package/dist/product/index.js.map +1 -1
- package/dist/product/paths.d.ts.map +1 -1
- package/dist/product/paths.js +12 -0
- package/dist/product/paths.js.map +1 -1
- package/dist/runtime/agent-runtime-controller.d.ts +2 -2
- package/dist/runtime/agent-runtime-protocol.d.ts +4 -1
- package/dist/runtime/agent-runtime-protocol.d.ts.map +1 -1
- package/dist/runtime/agent-runtime-protocol.js +6 -0
- package/dist/runtime/agent-runtime-protocol.js.map +1 -1
- package/dist/runtime/chat-checkpoint.d.ts +17 -0
- package/dist/runtime/chat-checkpoint.d.ts.map +1 -0
- package/dist/runtime/chat-checkpoint.js +108 -0
- package/dist/runtime/chat-checkpoint.js.map +1 -0
- package/dist/runtime/chat-controller.d.ts +10 -46
- package/dist/runtime/chat-controller.d.ts.map +1 -1
- package/dist/runtime/chat-controller.js +199 -1051
- package/dist/runtime/chat-controller.js.map +1 -1
- package/dist/runtime/chat-presentation.d.ts +60 -0
- package/dist/runtime/chat-presentation.d.ts.map +1 -0
- package/dist/runtime/chat-presentation.js +537 -0
- package/dist/runtime/chat-presentation.js.map +1 -0
- package/dist/runtime/chat-trace.d.ts +52 -0
- package/dist/runtime/chat-trace.d.ts.map +1 -0
- package/dist/runtime/chat-trace.js +234 -0
- package/dist/runtime/chat-trace.js.map +1 -0
- package/dist/runtime/chat-workspace.d.ts +22 -0
- package/dist/runtime/chat-workspace.d.ts.map +1 -0
- package/dist/runtime/chat-workspace.js +154 -0
- package/dist/runtime/chat-workspace.js.map +1 -0
- package/dist/runtime/goals/accounting.js +1 -1
- package/dist/runtime/goals/accounting.js.map +1 -1
- package/dist/runtime/goals/completion-audit.d.ts.map +1 -1
- package/dist/runtime/goals/completion-audit.js +5 -4
- package/dist/runtime/goals/completion-audit.js.map +1 -1
- package/dist/runtime/goals/coordinator.d.ts +3 -0
- package/dist/runtime/goals/coordinator.d.ts.map +1 -1
- package/dist/runtime/goals/coordinator.js +30 -2
- package/dist/runtime/goals/coordinator.js.map +1 -1
- package/dist/runtime/goals/prompt.d.ts +1 -1
- package/dist/runtime/goals/prompt.d.ts.map +1 -1
- package/dist/runtime/goals/prompt.js +3 -2
- package/dist/runtime/goals/prompt.js.map +1 -1
- package/dist/runtime/goals/tools.d.ts +21 -8
- package/dist/runtime/goals/tools.d.ts.map +1 -1
- package/dist/runtime/goals/tools.js +141 -10
- package/dist/runtime/goals/tools.js.map +1 -1
- package/dist/runtime/loop-budget.d.ts +2 -2
- package/dist/runtime/model-coordinator.d.ts.map +1 -1
- package/dist/runtime/model-coordinator.js.map +1 -1
- package/dist/runtime/subagents/child-executor-guard.d.ts.map +1 -1
- package/dist/runtime/subagents/child-executor-guard.js +4 -0
- package/dist/runtime/subagents/child-executor-guard.js.map +1 -1
- package/dist/runtime/subagents/index.d.ts +10 -3
- package/dist/runtime/subagents/index.d.ts.map +1 -1
- package/dist/runtime/subagents/index.js +25 -1
- package/dist/runtime/subagents/index.js.map +1 -1
- package/dist/runtime/subagents/policy.d.ts +1 -1
- package/dist/runtime/subagents/policy.d.ts.map +1 -1
- package/dist/runtime/subagents/policy.js.map +1 -1
- package/dist/runtime/subagents/presets.d.ts +2 -2
- package/dist/runtime/subagents/provider-gate.d.ts.map +1 -1
- package/dist/runtime/subagents/provider-gate.js +0 -1
- package/dist/runtime/subagents/provider-gate.js.map +1 -1
- package/dist/runtime/subagents/research-artifact.d.ts +101 -0
- package/dist/runtime/subagents/research-artifact.d.ts.map +1 -0
- package/dist/runtime/subagents/research-artifact.js +210 -0
- package/dist/runtime/subagents/research-artifact.js.map +1 -0
- package/dist/runtime/subagents/research-citation.d.ts +66 -0
- package/dist/runtime/subagents/research-citation.d.ts.map +1 -0
- package/dist/runtime/subagents/research-citation.js +185 -0
- package/dist/runtime/subagents/research-citation.js.map +1 -0
- package/dist/runtime/subagents/research-contract.d.ts +83 -0
- package/dist/runtime/subagents/research-contract.d.ts.map +1 -0
- package/dist/runtime/subagents/research-contract.js +337 -0
- package/dist/runtime/subagents/research-contract.js.map +1 -0
- package/dist/runtime/subagents/research-quality.d.ts +47 -0
- package/dist/runtime/subagents/research-quality.d.ts.map +1 -0
- package/dist/runtime/subagents/research-quality.js +125 -0
- package/dist/runtime/subagents/research-quality.js.map +1 -0
- package/dist/runtime/subagents/research-renderer.d.ts +95 -0
- package/dist/runtime/subagents/research-renderer.d.ts.map +1 -0
- package/dist/runtime/subagents/research-renderer.js +186 -0
- package/dist/runtime/subagents/research-renderer.js.map +1 -0
- package/dist/runtime/subagents/research-types.d.ts +105 -0
- package/dist/runtime/subagents/research-types.d.ts.map +1 -0
- package/dist/runtime/subagents/research-types.js +16 -0
- package/dist/runtime/subagents/research-types.js.map +1 -0
- package/dist/runtime/subagents/result-parser.d.ts +1 -5
- package/dist/runtime/subagents/result-parser.d.ts.map +1 -1
- package/dist/runtime/subagents/result-parser.js +5 -72
- package/dist/runtime/subagents/result-parser.js.map +1 -1
- package/dist/runtime/subagents/runtime-integration.d.ts +13 -7
- package/dist/runtime/subagents/runtime-integration.d.ts.map +1 -1
- package/dist/runtime/subagents/runtime-integration.js +112 -2
- package/dist/runtime/subagents/runtime-integration.js.map +1 -1
- package/dist/runtime/subagents/supervisor.d.ts +15 -1
- package/dist/runtime/subagents/supervisor.d.ts.map +1 -1
- package/dist/runtime/subagents/supervisor.js +58 -3
- package/dist/runtime/subagents/supervisor.js.map +1 -1
- package/dist/runtime/subagents/tool.d.ts +2 -2
- package/dist/runtime/subagents/tool.d.ts.map +1 -1
- package/dist/runtime/subagents/tool.js +129 -9
- package/dist/runtime/subagents/tool.js.map +1 -1
- package/dist/runtime/subagents/types.d.ts +20 -0
- package/dist/runtime/subagents/types.d.ts.map +1 -1
- package/dist/runtime/subagents/types.js.map +1 -1
- package/dist/runtime/subagents/web-research-adapter.d.ts +85 -0
- package/dist/runtime/subagents/web-research-adapter.d.ts.map +1 -0
- package/dist/runtime/subagents/web-research-adapter.js +328 -0
- package/dist/runtime/subagents/web-research-adapter.js.map +1 -0
- package/dist/runtime/ui-events.d.ts +8 -8
- package/dist/runtime/ui-events.d.ts.map +1 -1
- package/dist/runtime/ui-events.js.map +1 -1
- package/dist/runtime/ui-view-model.d.ts +40 -0
- package/dist/runtime/ui-view-model.d.ts.map +1 -1
- package/dist/runtime/ui-view-model.js +126 -0
- package/dist/runtime/ui-view-model.js.map +1 -1
- package/dist/services/agent-runner.d.ts +5 -2
- package/dist/services/agent-runner.d.ts.map +1 -1
- package/dist/services/agent-runner.js +18 -18
- package/dist/services/agent-runner.js.map +1 -1
- package/dist/services/atomic-write.d.ts +9 -1
- package/dist/services/atomic-write.d.ts.map +1 -1
- package/dist/services/atomic-write.js +55 -2
- package/dist/services/atomic-write.js.map +1 -1
- package/dist/services/auth/auth.d.ts +11 -7
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +133 -34
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/aws.d.ts +2 -0
- package/dist/services/auth/aws.d.ts.map +1 -1
- package/dist/services/auth/aws.js +126 -12
- package/dist/services/auth/aws.js.map +1 -1
- package/dist/services/auth/index.d.ts +1 -1
- package/dist/services/auth/index.d.ts.map +1 -1
- package/dist/services/auth/index.js +2 -1
- package/dist/services/auth/index.js.map +1 -1
- package/dist/services/auto-fix/autoFixConfig.d.ts +0 -3
- package/dist/services/auto-fix/autoFixConfig.d.ts.map +1 -1
- package/dist/services/auto-fix/autoFixConfig.js +25 -8
- package/dist/services/auto-fix/autoFixConfig.js.map +1 -1
- package/dist/services/auto-fix/autoFixHook.d.ts +7 -0
- package/dist/services/auto-fix/autoFixHook.d.ts.map +1 -1
- package/dist/services/auto-fix/autoFixHook.js +10 -1
- package/dist/services/auto-fix/autoFixHook.js.map +1 -1
- package/dist/services/compact/auto-compact.d.ts +2 -0
- package/dist/services/compact/auto-compact.d.ts.map +1 -1
- package/dist/services/compact/auto-compact.js +15 -1
- package/dist/services/compact/auto-compact.js.map +1 -1
- package/dist/services/compact/compact.d.ts.map +1 -1
- package/dist/services/compact/compact.js +9 -11
- package/dist/services/compact/compact.js.map +1 -1
- package/dist/services/compact/summary-generator.d.ts.map +1 -1
- package/dist/services/compact/summary-generator.js +28 -4
- package/dist/services/compact/summary-generator.js.map +1 -1
- package/dist/services/compact/tool-call-groups.d.ts +19 -0
- package/dist/services/compact/tool-call-groups.d.ts.map +1 -0
- package/dist/services/compact/tool-call-groups.js +105 -0
- package/dist/services/compact/tool-call-groups.js.map +1 -0
- package/dist/services/concurrent-sessions.d.ts +4 -0
- package/dist/services/concurrent-sessions.d.ts.map +1 -1
- package/dist/services/concurrent-sessions.js +76 -21
- package/dist/services/concurrent-sessions.js.map +1 -1
- package/dist/services/config-dir.d.ts.map +1 -1
- package/dist/services/config-dir.js +19 -5
- package/dist/services/config-dir.js.map +1 -1
- package/dist/services/config.d.ts +6 -4
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +14 -71
- package/dist/services/config.js.map +1 -1
- package/dist/services/doctor.d.ts +2 -2
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/file-glob.d.ts.map +1 -1
- package/dist/services/file-glob.js +22 -2
- package/dist/services/file-glob.js.map +1 -1
- package/dist/services/file-lock.d.ts +7 -0
- package/dist/services/file-lock.d.ts.map +1 -0
- package/dist/services/file-lock.js +139 -0
- package/dist/services/file-lock.js.map +1 -0
- package/dist/services/global-config.d.ts +2 -0
- package/dist/services/global-config.d.ts.map +1 -1
- package/dist/services/global-config.js +67 -4
- package/dist/services/global-config.js.map +1 -1
- package/dist/services/goal-storage.d.ts.map +1 -1
- package/dist/services/goal-storage.js +52 -19
- package/dist/services/goal-storage.js.map +1 -1
- package/dist/services/llm.d.ts +12 -0
- package/dist/services/llm.d.ts.map +1 -1
- package/dist/services/llm.js +166 -69
- package/dist/services/llm.js.map +1 -1
- package/dist/services/mcp/transports.d.ts +0 -1
- package/dist/services/mcp/transports.d.ts.map +1 -1
- package/dist/services/mcp/transports.js +12 -13
- package/dist/services/mcp/transports.js.map +1 -1
- package/dist/services/model-context.d.ts +8 -0
- package/dist/services/model-context.d.ts.map +1 -1
- package/dist/services/model-context.js +111 -7
- package/dist/services/model-context.js.map +1 -1
- package/dist/services/provider-resilience/coordinator.d.ts +9 -4
- package/dist/services/provider-resilience/coordinator.d.ts.map +1 -1
- package/dist/services/provider-resilience/coordinator.js +88 -21
- package/dist/services/provider-resilience/coordinator.js.map +1 -1
- package/dist/services/provider-resilience/error-classifier.d.ts +1 -0
- package/dist/services/provider-resilience/error-classifier.d.ts.map +1 -1
- package/dist/services/provider-resilience/error-classifier.js +50 -29
- package/dist/services/provider-resilience/error-classifier.js.map +1 -1
- package/dist/services/provider-resilience/index.d.ts +3 -3
- package/dist/services/provider-resilience/index.d.ts.map +1 -1
- package/dist/services/provider-resilience/index.js +3 -1
- package/dist/services/provider-resilience/index.js.map +1 -1
- package/dist/services/provider-resilience/request-gate.d.ts +6 -0
- package/dist/services/provider-resilience/request-gate.d.ts.map +1 -1
- package/dist/services/provider-resilience/request-gate.js +24 -9
- package/dist/services/provider-resilience/request-gate.js.map +1 -1
- package/dist/services/provider-resilience/stream-recovery.d.ts +1 -1
- package/dist/services/provider-resilience/stream-recovery.d.ts.map +1 -1
- package/dist/services/provider-resilience/stream-recovery.js +1 -1
- package/dist/services/provider-resilience/stream-recovery.js.map +1 -1
- package/dist/services/provider-resilience/types.d.ts +9 -0
- package/dist/services/provider-resilience/types.d.ts.map +1 -1
- package/dist/services/provider-resilience/types.js.map +1 -1
- package/dist/services/redaction.d.ts.map +1 -1
- package/dist/services/redaction.js +29 -1
- package/dist/services/redaction.js.map +1 -1
- package/dist/services/session-index.d.ts.map +1 -1
- package/dist/services/session-index.js +75 -44
- package/dist/services/session-index.js.map +1 -1
- package/dist/services/session-memory/sessionMemory.d.ts.map +1 -1
- package/dist/services/session-memory/sessionMemory.js +6 -3
- package/dist/services/session-memory/sessionMemory.js.map +1 -1
- package/dist/services/session-storage.d.ts +8 -0
- package/dist/services/session-storage.d.ts.map +1 -1
- package/dist/services/session-storage.js +105 -27
- package/dist/services/session-storage.js.map +1 -1
- package/dist/services/storage-maintenance.d.ts.map +1 -1
- package/dist/services/storage-maintenance.js +62 -9
- package/dist/services/storage-maintenance.js.map +1 -1
- package/dist/services/task-manager.d.ts +9 -4
- package/dist/services/task-manager.d.ts.map +1 -1
- package/dist/services/task-manager.js +18 -4
- package/dist/services/task-manager.js.map +1 -1
- package/dist/services/usage-state.d.ts +1 -0
- package/dist/services/usage-state.d.ts.map +1 -1
- package/dist/services/usage-state.js +81 -45
- package/dist/services/usage-state.js.map +1 -1
- package/dist/services/verification-profile.d.ts.map +1 -1
- package/dist/services/verification-profile.js +23 -3
- package/dist/services/verification-profile.js.map +1 -1
- package/dist/services/web-search-adapters.d.ts.map +1 -1
- package/dist/services/web-search-adapters.js +48 -18
- package/dist/services/web-search-adapters.js.map +1 -1
- package/dist/services/web-search-mcp.d.ts.map +1 -1
- package/dist/services/web-search-mcp.js +27 -11
- package/dist/services/web-search-mcp.js.map +1 -1
- package/dist/services/workspace-diff.d.ts +14 -0
- package/dist/services/workspace-diff.d.ts.map +1 -1
- package/dist/services/workspace-diff.js +60 -11
- package/dist/services/workspace-diff.js.map +1 -1
- package/dist/services/yaml-config.d.ts.map +1 -1
- package/dist/services/yaml-config.js +2 -1
- package/dist/services/yaml-config.js.map +1 -1
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +26 -11
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/runtime.d.ts +3 -3
- package/dist/skills/runtime.d.ts.map +1 -1
- package/dist/skills/runtime.js +37 -4
- package/dist/skills/runtime.js.map +1 -1
- package/dist/skills/types.d.ts +1 -1
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/terminal-ui/launch.d.ts +16 -8
- package/dist/terminal-ui/launch.d.ts.map +1 -1
- package/dist/terminal-ui/launch.js +26 -0
- package/dist/terminal-ui/launch.js.map +1 -1
- package/dist/terminal-ui/raw-editor.js.map +1 -1
- package/dist/tools/bash_security.d.ts +58 -18
- package/dist/tools/bash_security.d.ts.map +1 -1
- package/dist/tools/bash_security.js +587 -80
- package/dist/tools/bash_security.js.map +1 -1
- package/dist/tools/git.d.ts +8 -8
- package/dist/tools/git.d.ts.map +1 -1
- package/dist/tools/git.js +248 -55
- package/dist/tools/git.js.map +1 -1
- package/dist/tools/index.d.ts +14 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +236 -42
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lsp.d.ts +74 -6
- package/dist/tools/lsp.d.ts.map +1 -1
- package/dist/tools/lsp.js +24 -5
- package/dist/tools/lsp.js.map +1 -1
- package/dist/tools/mcp.d.ts +19 -6
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mcp.js +143 -26
- package/dist/tools/mcp.js.map +1 -1
- package/dist/tools/plan.d.ts +4 -4
- package/dist/tools/sandbox.d.ts +3 -1
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +28 -13
- package/dist/tools/sandbox.js.map +1 -1
- package/dist/tools/todo.d.ts +3 -3
- package/dist/tools/web.d.ts +15 -4
- package/dist/tools/web.d.ts.map +1 -1
- package/dist/tools/web.js +240 -26
- package/dist/tools/web.js.map +1 -1
- package/dist/tui-core/frame.js.map +1 -1
- package/dist/tui-ui/launch.d.ts +3 -3
- package/dist/tui-ui/layout.d.ts.map +1 -1
- package/dist/tui-ui/layout.js +2 -0
- package/dist/tui-ui/layout.js.map +1 -1
- package/dist/tui-ui/runner.d.ts.map +1 -1
- package/dist/tui-ui/runner.js +1 -0
- package/dist/tui-ui/runner.js.map +1 -1
- package/dist/tui-ui/state.d.ts +9 -1
- package/dist/tui-ui/state.d.ts.map +1 -1
- package/dist/tui-ui/state.js +13 -0
- package/dist/tui-ui/state.js.map +1 -1
- package/dist/ui/markdown.js.map +1 -1
- package/dist/utils/debug-log.d.ts +52 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +94 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +25 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +47 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/json.d.ts +6 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +66 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mask.d.ts +8 -1
- package/dist/utils/mask.d.ts.map +1 -1
- package/dist/utils/mask.js +10 -12
- package/dist/utils/mask.js.map +1 -1
- package/dist/utils/observability.d.ts +22 -0
- package/dist/utils/observability.d.ts.map +1 -0
- package/dist/utils/observability.js +80 -0
- package/dist/utils/observability.js.map +1 -0
- package/dist/utils/token-estimate.d.ts +8 -0
- package/dist/utils/token-estimate.d.ts.map +1 -1
- package/dist/utils/token-estimate.js +30 -17
- package/dist/utils/token-estimate.js.map +1 -1
- package/package.json +8 -7
package/dist/tools/index.js
CHANGED
|
@@ -10,9 +10,43 @@
|
|
|
10
10
|
*
|
|
11
11
|
* 使用 buildTool() 工厂模式。
|
|
12
12
|
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
13
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
47
|
+
exports.findDestructiveRmTarget = exports.assessCommandSecurity = exports.isPotentiallyDestructive = exports.checkDangerousCommand = exports.isReadOnlyCommand = exports.POTENTIALLY_DESTRUCTIVE_PATTERNS = exports.DANGEROUS_PATTERNS = exports.READ_ONLY_COMMANDS = exports.TOOLS = exports.BATCH_READ_MAX_STEPS = exports.BATCH_READ_ALLOWED_TOOLS = void 0;
|
|
15
48
|
exports.getRuntimeTools = getRuntimeTools;
|
|
49
|
+
exports.validateRegexPattern = validateRegexPattern;
|
|
16
50
|
exports.executeTool = executeTool;
|
|
17
51
|
exports.getToolNames = getToolNames;
|
|
18
52
|
const child_process_1 = require("child_process");
|
|
@@ -20,12 +54,13 @@ const fs_1 = require("fs");
|
|
|
20
54
|
const path_1 = require("path");
|
|
21
55
|
const readline_1 = require("readline");
|
|
22
56
|
const tool_1 = require("../framework/tool");
|
|
57
|
+
const tool_scheduler_1 = require("../framework/tool-scheduler");
|
|
23
58
|
const external_assertion_1 = require("../framework/external-assertion");
|
|
24
59
|
const tool_state_1 = require("../framework/tool-state");
|
|
25
60
|
const tool_artifacts_1 = require("../core/tool-artifacts");
|
|
26
61
|
const environment_1 = require("../product/environment");
|
|
27
|
-
const
|
|
28
|
-
const
|
|
62
|
+
const storage_1 = require("../memory/storage");
|
|
63
|
+
const semantic_config_1 = require("../memory/semantic-config");
|
|
29
64
|
const session_storage_1 = require("../services/session-storage");
|
|
30
65
|
const web_1 = require("./web");
|
|
31
66
|
const mcp_1 = require("./mcp");
|
|
@@ -35,6 +70,8 @@ const git_1 = require("./git");
|
|
|
35
70
|
const lsp_1 = require("./lsp");
|
|
36
71
|
const tools_1 = require("../runtime/goals/tools");
|
|
37
72
|
const bash_security_1 = require("./bash_security");
|
|
73
|
+
const debug_log_1 = require("../utils/debug-log");
|
|
74
|
+
const errors_1 = require("../utils/errors");
|
|
38
75
|
const sandbox_1 = require("./sandbox");
|
|
39
76
|
exports.BATCH_READ_ALLOWED_TOOLS = new Set([
|
|
40
77
|
'git_status',
|
|
@@ -166,7 +203,6 @@ exports.TOOLS = [
|
|
|
166
203
|
isDestructive: () => true,
|
|
167
204
|
isFileEdit: () => true,
|
|
168
205
|
checkPermissions: (_args, _context) => {
|
|
169
|
-
// Destructive operation - ask for confirmation in default mode
|
|
170
206
|
return { behavior: 'ask', reason: 'Write operation may modify existing files' };
|
|
171
207
|
},
|
|
172
208
|
userFacingName: args => `Write ${args.path}`,
|
|
@@ -558,17 +594,18 @@ exports.TOOLS = [
|
|
|
558
594
|
createdAt: Date.now(),
|
|
559
595
|
updatedAt: Date.now(),
|
|
560
596
|
};
|
|
561
|
-
if ((0,
|
|
597
|
+
if ((0, semantic_config_1.isSemanticEnabled)()) {
|
|
562
598
|
// saveAndIndex internally calls saveMemory + vectorStore.upsert
|
|
563
|
-
await
|
|
599
|
+
const { getSemanticSearchService } = await Promise.resolve().then(() => __importStar(require('../memory/semantic-search')));
|
|
600
|
+
await getSemanticSearchService().saveAndIndex(entry, projectPath);
|
|
564
601
|
}
|
|
565
602
|
else {
|
|
566
|
-
(0,
|
|
603
|
+
(0, storage_1.saveMemory)(entry, projectPath);
|
|
567
604
|
}
|
|
568
605
|
return { success: true, output: `Saved memory: ${name} (${type})` };
|
|
569
606
|
}
|
|
570
607
|
catch (err) {
|
|
571
|
-
return { success: false, output: '', error: err
|
|
608
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
572
609
|
}
|
|
573
610
|
},
|
|
574
611
|
isReadOnly: () => false,
|
|
@@ -605,11 +642,12 @@ exports.TOOLS = [
|
|
|
605
642
|
const query = args.query || '';
|
|
606
643
|
const type = args.type;
|
|
607
644
|
let memories;
|
|
608
|
-
if (query && (0,
|
|
645
|
+
if (query && (0, semantic_config_1.isSemanticEnabled)()) {
|
|
609
646
|
// Semantic path: ask the vector store, then fall back to keywords if it
|
|
610
647
|
// returns nothing (e.g. embedding provider unreachable, empty index)
|
|
611
648
|
try {
|
|
612
|
-
const
|
|
649
|
+
const { getSemanticSearchService } = await Promise.resolve().then(() => __importStar(require('../memory/semantic-search')));
|
|
650
|
+
const result = await getSemanticSearchService().search({
|
|
613
651
|
query,
|
|
614
652
|
projectPath,
|
|
615
653
|
type,
|
|
@@ -623,25 +661,26 @@ exports.TOOLS = [
|
|
|
623
661
|
updatedAt: m.createdAt,
|
|
624
662
|
}));
|
|
625
663
|
if (memories.length === 0) {
|
|
626
|
-
memories = (0,
|
|
664
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
627
665
|
if (type)
|
|
628
666
|
memories = memories.filter(m => m.type === type);
|
|
629
667
|
}
|
|
630
668
|
}
|
|
631
|
-
catch {
|
|
632
|
-
|
|
669
|
+
catch (error) {
|
|
670
|
+
(0, debug_log_1.debugError)('tools.memory.semanticSearch', error, query);
|
|
671
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
633
672
|
if (type)
|
|
634
673
|
memories = memories.filter(m => m.type === type);
|
|
635
674
|
}
|
|
636
675
|
}
|
|
637
676
|
else if (type) {
|
|
638
|
-
memories = (0,
|
|
677
|
+
memories = (0, storage_1.loadAllMemories)(projectPath).filter(m => m.type === type);
|
|
639
678
|
}
|
|
640
679
|
else if (query) {
|
|
641
|
-
memories = (0,
|
|
680
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
642
681
|
}
|
|
643
682
|
else {
|
|
644
|
-
memories = (0,
|
|
683
|
+
memories = (0, storage_1.loadAllMemories)(projectPath);
|
|
645
684
|
}
|
|
646
685
|
if (memories.length === 0) {
|
|
647
686
|
return { success: true, output: 'No memories found' };
|
|
@@ -656,7 +695,7 @@ exports.TOOLS = [
|
|
|
656
695
|
return { success: true, output: lines.join('\n') };
|
|
657
696
|
}
|
|
658
697
|
catch (err) {
|
|
659
|
-
return { success: false, output: '', error: err
|
|
698
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
660
699
|
}
|
|
661
700
|
},
|
|
662
701
|
isReadOnly: () => true,
|
|
@@ -691,24 +730,26 @@ exports.TOOLS = [
|
|
|
691
730
|
}
|
|
692
731
|
try {
|
|
693
732
|
const projectPath = context?.cwd || process.cwd();
|
|
694
|
-
const existing = (0,
|
|
733
|
+
const existing = (0, storage_1.loadMemory)(name, projectPath);
|
|
695
734
|
if (!existing) {
|
|
696
735
|
return { success: false, output: '', error: `Memory not found: ${name}` };
|
|
697
736
|
}
|
|
698
|
-
(0,
|
|
699
|
-
if ((0,
|
|
737
|
+
(0, storage_1.deleteMemory)(name, projectPath);
|
|
738
|
+
if ((0, semantic_config_1.isSemanticEnabled)()) {
|
|
700
739
|
try {
|
|
701
740
|
const { getVectorStore } = require('../memory/vector-store');
|
|
702
741
|
getVectorStore().delete(name, projectPath);
|
|
703
742
|
}
|
|
704
|
-
catch {
|
|
705
|
-
// Vector store cleanup is best-effort
|
|
743
|
+
catch (error) {
|
|
744
|
+
// Vector store cleanup is best-effort, but a failure leaves an
|
|
745
|
+
// orphaned embedding that keeps surfacing a deleted memory.
|
|
746
|
+
(0, debug_log_1.debugError)('tools.memory.vectorDelete', error, name);
|
|
706
747
|
}
|
|
707
748
|
}
|
|
708
749
|
return { success: true, output: `Deleted memory: ${name}` };
|
|
709
750
|
}
|
|
710
751
|
catch (err) {
|
|
711
|
-
return { success: false, output: '', error: err
|
|
752
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
712
753
|
}
|
|
713
754
|
},
|
|
714
755
|
isReadOnly: () => false,
|
|
@@ -803,7 +844,7 @@ exports.TOOLS = [
|
|
|
803
844
|
return { success: true, output: lines.join('\n') };
|
|
804
845
|
}
|
|
805
846
|
catch (err) {
|
|
806
|
-
return { success: false, output: '', error: err
|
|
847
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
807
848
|
}
|
|
808
849
|
},
|
|
809
850
|
isReadOnly: () => true,
|
|
@@ -858,7 +899,9 @@ function normalizeToolPath(input) {
|
|
|
858
899
|
try {
|
|
859
900
|
return decodeURIComponent(new URL(value).pathname);
|
|
860
901
|
}
|
|
861
|
-
catch {
|
|
902
|
+
catch (error) {
|
|
903
|
+
// Malformed URL or bad percent-encoding: strip the scheme so the path
|
|
904
|
+
// still reaches the caller's own validation instead of vanishing.
|
|
862
905
|
return value.replace(/^file:\/\//u, '');
|
|
863
906
|
}
|
|
864
907
|
}
|
|
@@ -898,7 +941,10 @@ function safeReadFileSync(resolved) {
|
|
|
898
941
|
return null;
|
|
899
942
|
return (0, fs_1.readFileSync)(resolved, 'utf-8');
|
|
900
943
|
}
|
|
901
|
-
catch {
|
|
944
|
+
catch (error) {
|
|
945
|
+
// Permission denied or a binary that is not valid UTF-8; callers treat null
|
|
946
|
+
// as "no content", which otherwise hides a real read failure.
|
|
947
|
+
(0, debug_log_1.debugError)('tools.safeReadFile', error, resolved);
|
|
902
948
|
return null;
|
|
903
949
|
}
|
|
904
950
|
}
|
|
@@ -906,6 +952,56 @@ function safeReadFileSync(resolved) {
|
|
|
906
952
|
function safePath(input, cwd = process.cwd()) {
|
|
907
953
|
return (0, path_1.resolve)(cwd, normalizeToolPath(input));
|
|
908
954
|
}
|
|
955
|
+
/**
|
|
956
|
+
* Return true when `p` resolves (after following symlinks) to a location at or
|
|
957
|
+
* under `rootReal`. Used to enforce that a realpath is still inside the
|
|
958
|
+
* workspace even when directories along the path are themselves symlinks.
|
|
959
|
+
*/
|
|
960
|
+
function isUnderRealRoot(p, rootReal) {
|
|
961
|
+
const rel = (0, path_1.relative)(rootReal, p);
|
|
962
|
+
return rel === '' || (!rel.startsWith('..') && !(0, path_1.isAbsolute)(rel));
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Contain a tool-resolved path inside the workspace root (cwd).
|
|
966
|
+
*
|
|
967
|
+
* Blocks `../` traversal and absolute paths outside the workspace, which would
|
|
968
|
+
* otherwise let `write_file`/`edit_file` scribble over `~/.bashrc`, SSH config
|
|
969
|
+
* or other projects — especially dangerous under `acceptEdits` auto-approval,
|
|
970
|
+
* where the write runs without a confirmation prompt (issue #65).
|
|
971
|
+
*
|
|
972
|
+
* Containment is lexical first, then re-checked after resolving symlinks
|
|
973
|
+
* (issue #99): a workspace symlink that points outside the workspace must not
|
|
974
|
+
* be followed into an arbitrary write target. We resolve the realpath of the
|
|
975
|
+
* parent directory (which also collapses any intermediate symlinked dirs) and,
|
|
976
|
+
* if the target already exists, the target itself; if either escapes the
|
|
977
|
+
* workspace we refuse. The workspace root is also realpath-resolved so a
|
|
978
|
+
* symlinked cwd does not produce false rejections. Fail-closed on any
|
|
979
|
+
* filesystem error.
|
|
980
|
+
*/
|
|
981
|
+
function isWithinWorkspace(resolved, cwd) {
|
|
982
|
+
const root = (0, path_1.resolve)(cwd);
|
|
983
|
+
const rel = (0, path_1.relative)(root, resolved);
|
|
984
|
+
if (!(rel === '' || (!rel.startsWith('..') && !(0, path_1.isAbsolute)(rel))))
|
|
985
|
+
return false;
|
|
986
|
+
try {
|
|
987
|
+
const rootReal = (0, fs_1.realpathSync)(root);
|
|
988
|
+
const realParent = (0, fs_1.realpathSync)((0, path_1.dirname)(resolved));
|
|
989
|
+
if (!isUnderRealRoot(realParent, rootReal))
|
|
990
|
+
return false;
|
|
991
|
+
// Only the existing target needs its own realpath check; a brand-new file
|
|
992
|
+
// inherits the (already-validated) containment of its parent directory.
|
|
993
|
+
if ((0, fs_1.existsSync)(resolved)) {
|
|
994
|
+
const realTarget = (0, fs_1.realpathSync)(resolved);
|
|
995
|
+
if (!isUnderRealRoot(realTarget, rootReal))
|
|
996
|
+
return false;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
catch {
|
|
1000
|
+
// A missing/unknowable realpath means we cannot prove containment — refuse.
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
909
1005
|
/**
|
|
910
1006
|
* Truncate text to at most maxBytes UTF-8 bytes, cutting on a character
|
|
911
1007
|
* boundary (never inside a multi-byte sequence or surrogate pair). Returns the
|
|
@@ -998,13 +1094,21 @@ async function readFileSync_(path, maxLines, offset, cwd) {
|
|
|
998
1094
|
return { success: true, output: selected };
|
|
999
1095
|
}
|
|
1000
1096
|
catch (err) {
|
|
1001
|
-
return { success: false, output: '', error:
|
|
1097
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
1002
1098
|
}
|
|
1003
1099
|
}
|
|
1004
1100
|
async function writeFileSync_(path, content, cwd) {
|
|
1005
1101
|
try {
|
|
1006
1102
|
const normalizedPath = normalizeToolPath(path);
|
|
1007
1103
|
const resolved = safePath(path, cwd);
|
|
1104
|
+
const workspaceRoot = cwd ?? process.cwd();
|
|
1105
|
+
if (!isWithinWorkspace(resolved, workspaceRoot)) {
|
|
1106
|
+
return {
|
|
1107
|
+
success: false,
|
|
1108
|
+
output: '',
|
|
1109
|
+
error: `Refusing to write outside the workspace: ${normalizedPath}`,
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1008
1112
|
(0, fs_1.writeFileSync)(resolved, content, 'utf-8');
|
|
1009
1113
|
return {
|
|
1010
1114
|
success: true,
|
|
@@ -1012,7 +1116,7 @@ async function writeFileSync_(path, content, cwd) {
|
|
|
1012
1116
|
};
|
|
1013
1117
|
}
|
|
1014
1118
|
catch (err) {
|
|
1015
|
-
return { success: false, output: '', error:
|
|
1119
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
1016
1120
|
}
|
|
1017
1121
|
}
|
|
1018
1122
|
async function listFiles_(path, maxDepth, cwd) {
|
|
@@ -1098,6 +1202,11 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1098
1202
|
cwd: workdir,
|
|
1099
1203
|
detached: useProcessGroup,
|
|
1100
1204
|
});
|
|
1205
|
+
// Issue #53: exec_command runs a complete command as a single argv element
|
|
1206
|
+
// and never pipes input into it. If stdin stays open, stdin-reading commands
|
|
1207
|
+
// (cat, sort, grep, `python3 -`, ...) block waiting for EOF until the timeout.
|
|
1208
|
+
// Close it immediately so the child receives EOF and can proceed.
|
|
1209
|
+
child.stdin?.end();
|
|
1101
1210
|
let stdoutData = '';
|
|
1102
1211
|
let stderrData = '';
|
|
1103
1212
|
let stdoutTruncated = false;
|
|
@@ -1107,6 +1216,10 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1107
1216
|
let stderrBytes = 0;
|
|
1108
1217
|
let interrupted = null;
|
|
1109
1218
|
// Issue #32 #3.2: AbortSignal 处理
|
|
1219
|
+
// Declared uninitialized on purpose: `finish()` below closes over it before the
|
|
1220
|
+
// `timeoutId = setTimeout(...)` assignment. `const` without an initializer is a
|
|
1221
|
+
// compile error (TS1155), and inlining the assignment would put it in the closure's TDZ.
|
|
1222
|
+
// eslint-disable-next-line prefer-const
|
|
1110
1223
|
let timeoutId;
|
|
1111
1224
|
let killTimerId;
|
|
1112
1225
|
let settled = false;
|
|
@@ -1175,13 +1288,19 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1175
1288
|
child.stdout.on('data', (data) => {
|
|
1176
1289
|
if (!stdoutTruncated) {
|
|
1177
1290
|
const chunk = data.toString();
|
|
1178
|
-
|
|
1179
|
-
|
|
1291
|
+
// Issue #30: count UTF-8 bytes, not UTF-16 code units, so CJK/emoji
|
|
1292
|
+
// output is bounded by `maxBytes` (a UTF-16 count could exceed it ~2x).
|
|
1293
|
+
const chunkBytes = Buffer.byteLength(chunk, 'utf8');
|
|
1294
|
+
if (stdoutBytes + chunkBytes > maxBytes) {
|
|
1180
1295
|
stdoutTruncated = true;
|
|
1181
|
-
|
|
1296
|
+
const room = Math.max(0, maxBytes - stdoutBytes);
|
|
1297
|
+
// Byte-accurate truncation that respects multi-byte character boundaries.
|
|
1298
|
+
stdoutData += truncateToBytes(chunk, room).text;
|
|
1299
|
+
stdoutBytes = maxBytes;
|
|
1182
1300
|
}
|
|
1183
1301
|
else {
|
|
1184
1302
|
stdoutData += chunk;
|
|
1303
|
+
stdoutBytes += chunkBytes;
|
|
1185
1304
|
}
|
|
1186
1305
|
}
|
|
1187
1306
|
});
|
|
@@ -1189,13 +1308,17 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1189
1308
|
child.stderr.on('data', (data) => {
|
|
1190
1309
|
if (!stderrTruncated) {
|
|
1191
1310
|
const chunk = data.toString();
|
|
1192
|
-
|
|
1193
|
-
|
|
1311
|
+
// Issue #30: count UTF-8 bytes, not UTF-16 code units.
|
|
1312
|
+
const chunkBytes = Buffer.byteLength(chunk, 'utf8');
|
|
1313
|
+
if (stderrBytes + chunkBytes > maxBytes) {
|
|
1194
1314
|
stderrTruncated = true;
|
|
1195
|
-
|
|
1315
|
+
const room = Math.max(0, maxBytes - stderrBytes);
|
|
1316
|
+
stderrData += truncateToBytes(chunk, room).text;
|
|
1317
|
+
stderrBytes = maxBytes;
|
|
1196
1318
|
}
|
|
1197
1319
|
else {
|
|
1198
1320
|
stderrData += chunk;
|
|
1321
|
+
stderrBytes += chunkBytes;
|
|
1199
1322
|
}
|
|
1200
1323
|
}
|
|
1201
1324
|
});
|
|
@@ -1203,7 +1326,7 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1203
1326
|
if (interrupted === 'aborted') {
|
|
1204
1327
|
finish({
|
|
1205
1328
|
success: false,
|
|
1206
|
-
output: stdoutData
|
|
1329
|
+
output: truncateToBytes(stdoutData, maxBytes).text,
|
|
1207
1330
|
error: 'Command aborted by user',
|
|
1208
1331
|
});
|
|
1209
1332
|
return;
|
|
@@ -1211,7 +1334,7 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1211
1334
|
if (interrupted === 'timeout') {
|
|
1212
1335
|
finish({
|
|
1213
1336
|
success: false,
|
|
1214
|
-
output: stdoutData
|
|
1337
|
+
output: truncateToBytes(stdoutData, maxBytes).text,
|
|
1215
1338
|
error: `Command timed out after ${timeoutMs}ms`,
|
|
1216
1339
|
});
|
|
1217
1340
|
return;
|
|
@@ -1361,6 +1484,14 @@ async function editFile_(path, old_string, new_string, replace_all, fuzzy_match,
|
|
|
1361
1484
|
try {
|
|
1362
1485
|
const normalizedPath = normalizeToolPath(path);
|
|
1363
1486
|
const resolved = safePath(path, cwd);
|
|
1487
|
+
const workspaceRoot = cwd ?? process.cwd();
|
|
1488
|
+
if (!isWithinWorkspace(resolved, workspaceRoot)) {
|
|
1489
|
+
return {
|
|
1490
|
+
success: false,
|
|
1491
|
+
output: '',
|
|
1492
|
+
error: `Refusing to edit outside the workspace: ${normalizedPath}`,
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1364
1495
|
if (!(0, fs_1.existsSync)(resolved)) {
|
|
1365
1496
|
return { success: false, output: '', error: `File not found: ${normalizedPath}` };
|
|
1366
1497
|
}
|
|
@@ -1490,13 +1621,40 @@ async function editFile_(path, old_string, new_string, replace_all, fuzzy_match,
|
|
|
1490
1621
|
};
|
|
1491
1622
|
}
|
|
1492
1623
|
catch (err) {
|
|
1493
|
-
return { success: false, output: '', error:
|
|
1624
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
1494
1625
|
}
|
|
1495
1626
|
}
|
|
1496
1627
|
/** Escape special regex characters for literal matching */
|
|
1497
1628
|
function escapeRegExp(str) {
|
|
1498
1629
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1499
1630
|
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Validate a caller-supplied regular expression pattern before compiling it.
|
|
1633
|
+
*
|
|
1634
|
+
* Issue #79: `grep_` compiles user/model-supplied patterns with `new RegExp`
|
|
1635
|
+
* directly. A pathological pattern with a quantified group that itself contains
|
|
1636
|
+
* a quantifier (e.g. `(a+)+`, `(\d+)*`) triggers catastrophic backtracking
|
|
1637
|
+
* (ReDoS) and can hang the process on adversarial input (prompt injection).
|
|
1638
|
+
* Reject empty/oversized patterns and the classic nested-quantifier shapes.
|
|
1639
|
+
*/
|
|
1640
|
+
function validateRegexPattern(pattern) {
|
|
1641
|
+
if (!pattern)
|
|
1642
|
+
return 'pattern must not be empty';
|
|
1643
|
+
if (pattern.length > 2000)
|
|
1644
|
+
return 'pattern is too long (max 2000 characters)';
|
|
1645
|
+
// A group containing an internal quantifier, then quantified again: the
|
|
1646
|
+
// canonical exponential-backtracking construction.
|
|
1647
|
+
if (/\([^()]*[*+?][^()]*\)\s*[*+?]/.test(pattern)) {
|
|
1648
|
+
return 'pattern contains a quantified group with an internal quantifier — this risks catastrophic backtracking (ReDoS)';
|
|
1649
|
+
}
|
|
1650
|
+
try {
|
|
1651
|
+
new RegExp(pattern);
|
|
1652
|
+
}
|
|
1653
|
+
catch {
|
|
1654
|
+
return 'pattern is not a valid regular expression';
|
|
1655
|
+
}
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1500
1658
|
// ============================================================================
|
|
1501
1659
|
// Glob/Grep 工具实现
|
|
1502
1660
|
// ============================================================================
|
|
@@ -1587,7 +1745,7 @@ async function glob_(pattern, basePath, cwd) {
|
|
|
1587
1745
|
return { success: true, output };
|
|
1588
1746
|
}
|
|
1589
1747
|
catch (err) {
|
|
1590
|
-
return { success: false, output: '', error:
|
|
1748
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
1591
1749
|
}
|
|
1592
1750
|
}
|
|
1593
1751
|
/**
|
|
@@ -1600,6 +1758,10 @@ async function grep_(pattern, basePath, globPattern, contextLines, cwd) {
|
|
|
1600
1758
|
if (!(0, fs_1.existsSync)(base)) {
|
|
1601
1759
|
return { success: false, output: '', error: `Path not found: ${normalizedBasePath}` };
|
|
1602
1760
|
}
|
|
1761
|
+
const patternError = validateRegexPattern(pattern);
|
|
1762
|
+
if (patternError) {
|
|
1763
|
+
return { success: false, output: '', error: `Invalid grep pattern: ${patternError}` };
|
|
1764
|
+
}
|
|
1603
1765
|
const regex = new RegExp(pattern);
|
|
1604
1766
|
const context = contextLines ?? 0;
|
|
1605
1767
|
const results = [];
|
|
@@ -1721,7 +1883,7 @@ async function grep_(pattern, basePath, globPattern, contextLines, cwd) {
|
|
|
1721
1883
|
return { success: true, output: results.slice(0, maxResults).join('\n') + symlinkWarning };
|
|
1722
1884
|
}
|
|
1723
1885
|
catch (err) {
|
|
1724
|
-
return { success: false, output: '', error:
|
|
1886
|
+
return { success: false, output: '', error: (0, errors_1.errorMessage)(err) };
|
|
1725
1887
|
}
|
|
1726
1888
|
}
|
|
1727
1889
|
function isRecord(value) {
|
|
@@ -1827,6 +1989,35 @@ async function executeBatchRead(args, context) {
|
|
|
1827
1989
|
},
|
|
1828
1990
|
], error);
|
|
1829
1991
|
}
|
|
1992
|
+
// The scheduler resolved permissions for `batch_read` itself, not for the
|
|
1993
|
+
// tools it fans out to. Without re-running the gate here, a project
|
|
1994
|
+
// `deny: read_file(*.env)` rule -- and the plan-mode block -- apply to the
|
|
1995
|
+
// flat call but not to the batched one, so the model can read a denied path
|
|
1996
|
+
// simply by wrapping it in `batch_read`.
|
|
1997
|
+
const stepPermission = (0, tool_1.getToolMetadataPresence)(tool).hasPermissionCheck && tool.checkPermissions
|
|
1998
|
+
? tool.checkPermissions(step.args, context)
|
|
1999
|
+
: undefined;
|
|
2000
|
+
const effective = (0, tool_scheduler_1.resolveEffectivePermission)({
|
|
2001
|
+
toolName: step.tool,
|
|
2002
|
+
tool,
|
|
2003
|
+
args: step.args,
|
|
2004
|
+
permission: stepPermission,
|
|
2005
|
+
permissionMode: context.permissionMode,
|
|
2006
|
+
allowlist: context.toolAllowlist?.(step.tool, step.args),
|
|
2007
|
+
});
|
|
2008
|
+
if (effective.outcome === 'deny' || effective.outcome === 'block') {
|
|
2009
|
+
const error = effective.reason || `Tool ${step.tool} is not permitted (${effective.source ?? 'policy'})`;
|
|
2010
|
+
return buildBatchReadPayload(false, error, [
|
|
2011
|
+
{
|
|
2012
|
+
index: i + 1,
|
|
2013
|
+
tool: step.tool,
|
|
2014
|
+
args: step.args,
|
|
2015
|
+
success: false,
|
|
2016
|
+
error,
|
|
2017
|
+
output: '',
|
|
2018
|
+
},
|
|
2019
|
+
], error);
|
|
2020
|
+
}
|
|
1830
2021
|
}
|
|
1831
2022
|
const stepResults = [];
|
|
1832
2023
|
for (let i = 0; i < parsed.steps.length; i++) {
|
|
@@ -1853,7 +2044,7 @@ async function executeBatchRead(args, context) {
|
|
|
1853
2044
|
tool: step.tool,
|
|
1854
2045
|
args: step.args,
|
|
1855
2046
|
success: false,
|
|
1856
|
-
error:
|
|
2047
|
+
error: (0, errors_1.errorMessage)(err),
|
|
1857
2048
|
output: '',
|
|
1858
2049
|
});
|
|
1859
2050
|
}
|
|
@@ -1888,6 +2079,10 @@ async function executeTool(name, args, abortSignal, toolContext) {
|
|
|
1888
2079
|
abortSignal, // Issue #32 #3.2: 透传 abortSignal
|
|
1889
2080
|
sessionId: toolContext?.sessionId,
|
|
1890
2081
|
turnId: toolContext?.turnId,
|
|
2082
|
+
// Must survive the rebuild: batch_read re-runs the permission gate on its
|
|
2083
|
+
// sub-steps and reads both of these off the context.
|
|
2084
|
+
permissionMode: toolContext?.permissionMode,
|
|
2085
|
+
toolAllowlist: toolContext?.toolAllowlist,
|
|
1891
2086
|
};
|
|
1892
2087
|
const result = await tool.execute(args, context);
|
|
1893
2088
|
// Assertions are generated by the runtime allowlist, never accepted from a
|
|
@@ -1944,6 +2139,5 @@ Object.defineProperty(exports, "isReadOnlyCommand", { enumerable: true, get: fun
|
|
|
1944
2139
|
Object.defineProperty(exports, "checkDangerousCommand", { enumerable: true, get: function () { return bash_security_2.checkDangerousCommand; } });
|
|
1945
2140
|
Object.defineProperty(exports, "isPotentiallyDestructive", { enumerable: true, get: function () { return bash_security_2.isPotentiallyDestructive; } });
|
|
1946
2141
|
Object.defineProperty(exports, "assessCommandSecurity", { enumerable: true, get: function () { return bash_security_2.assessCommandSecurity; } });
|
|
1947
|
-
Object.defineProperty(exports, "
|
|
1948
|
-
Object.defineProperty(exports, "DEFAULT_SANDBOX_OPTIONS", { enumerable: true, get: function () { return bash_security_2.DEFAULT_SANDBOX_OPTIONS; } });
|
|
2142
|
+
Object.defineProperty(exports, "findDestructiveRmTarget", { enumerable: true, get: function () { return bash_security_2.findDestructiveRmTarget; } });
|
|
1949
2143
|
//# sourceMappingURL=index.js.map
|