@orion-agents/orion-code 0.1.4 → 0.1.5
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 +52 -21
- package/README.zh-CN.md +14 -7
- 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 +4 -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 +74 -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 +580 -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 +805 -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 +175 -0
- package/dist/commands/diagnostic-commands.js.map +1 -0
- package/dist/commands/index.d.ts +9 -10
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +42 -3563
- 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 +15 -0
- package/dist/commands/model-command-handlers.d.ts.map +1 -0
- package/dist/commands/model-command-handlers.js +526 -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 +85 -0
- package/dist/commands/model-commands.js.map +1 -0
- package/dist/commands/parser.d.ts +12 -0
- package/dist/commands/parser.d.ts.map +1 -1
- package/dist/commands/parser.js +48 -7
- package/dist/commands/parser.js.map +1 -1
- package/dist/commands/registry.d.ts +4 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +566 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/session-command-handlers.d.ts +10 -0
- package/dist/commands/session-command-handlers.d.ts.map +1 -0
- package/dist/commands/session-command-handlers.js +626 -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 +102 -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 +80 -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 +69 -5
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +3 -4
- package/dist/commands/types.js.map +1 -1
- 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 +32 -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 +124 -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 +17 -1
- package/dist/core/cost-tracker.d.ts.map +1 -1
- package/dist/core/cost-tracker.js +24 -8
- 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 +15 -6
- package/dist/framework/store.d.ts.map +1 -1
- package/dist/framework/store.js +18 -0
- package/dist/framework/store.js.map +1 -1
- 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 +155 -38
- package/dist/framework/tool-scheduler.js.map +1 -1
- package/dist/framework/tool.d.ts +39 -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 +4 -3
- package/dist/ink-ui/screens/ReplScreen.d.ts.map +1 -1
- package/dist/ink-ui/screens/ReplScreen.js +103 -31
- package/dist/ink-ui/screens/ReplScreen.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 +3 -15
- 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 +116 -9
- package/dist/memory/storage.js.map +1 -1
- package/dist/memory/vector-store.d.ts +30 -0
- package/dist/memory/vector-store.d.ts.map +1 -1
- package/dist/memory/vector-store.js +160 -21
- 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 +47 -103
- 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 +13 -3
- package/dist/print-ui/launch.d.ts.map +1 -1
- package/dist/print-ui/launch.js +28 -3
- 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 +16 -11
- package/dist/product/paths.js.map +1 -1
- package/dist/runtime/agent-runtime-controller.d.ts +4 -2
- package/dist/runtime/agent-runtime-controller.d.ts.map +1 -1
- package/dist/runtime/agent-runtime-controller.js +127 -14
- package/dist/runtime/agent-runtime-controller.js.map +1 -1
- package/dist/runtime/agent-runtime-protocol.d.ts +15 -0
- 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 -51
- package/dist/runtime/chat-controller.d.ts.map +1 -1
- package/dist/runtime/chat-controller.js +256 -1070
- package/dist/runtime/chat-controller.js.map +1 -1
- package/dist/runtime/chat-effort.d.ts +5 -0
- package/dist/runtime/chat-effort.d.ts.map +1 -0
- package/dist/runtime/chat-effort.js +47 -0
- package/dist/runtime/chat-effort.js.map +1 -0
- 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 +4 -3
- 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/rich-text/markdown-parser.d.ts +2 -0
- package/dist/runtime/rich-text/markdown-parser.d.ts.map +1 -1
- package/dist/runtime/rich-text/markdown-parser.js +50 -10
- package/dist/runtime/rich-text/markdown-parser.js.map +1 -1
- package/dist/runtime/subagents/index.d.ts +2 -2
- package/dist/runtime/subagents/index.d.ts.map +1 -1
- package/dist/runtime/subagents/index.js +2 -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/research-artifact.d.ts +7 -0
- package/dist/runtime/subagents/research-artifact.d.ts.map +1 -1
- package/dist/runtime/subagents/research-artifact.js +73 -27
- package/dist/runtime/subagents/research-artifact.js.map +1 -1
- package/dist/runtime/subagents/research-contract.d.ts +18 -4
- package/dist/runtime/subagents/research-contract.d.ts.map +1 -1
- package/dist/runtime/subagents/research-contract.js +122 -17
- package/dist/runtime/subagents/research-contract.js.map +1 -1
- package/dist/runtime/subagents/research-renderer.d.ts +27 -11
- package/dist/runtime/subagents/research-renderer.d.ts.map +1 -1
- package/dist/runtime/subagents/research-renderer.js +34 -2
- package/dist/runtime/subagents/research-renderer.js.map +1 -1
- 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 +4 -2
- package/dist/runtime/subagents/web-research-adapter.d.ts.map +1 -1
- package/dist/runtime/subagents/web-research-adapter.js +81 -15
- package/dist/runtime/subagents/web-research-adapter.js.map +1 -1
- package/dist/runtime/ui-events.d.ts +36 -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 +53 -4
- package/dist/runtime/ui-view-model.d.ts.map +1 -1
- package/dist/runtime/ui-view-model.js +190 -10
- 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 +117 -31
- 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 +59 -12
- package/dist/services/concurrent-sessions.js.map +1 -1
- package/dist/services/config.d.ts +8 -4
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +15 -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/effort.d.ts +40 -0
- package/dist/services/effort.d.ts.map +1 -0
- package/dist/services/effort.js +88 -0
- package/dist/services/effort.js.map +1 -0
- 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 +193 -0
- package/dist/services/file-lock.js.map +1 -0
- package/dist/services/global-config.d.ts +9 -0
- package/dist/services/global-config.d.ts.map +1 -1
- package/dist/services/global-config.js +79 -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 +30 -11
- package/dist/services/goal-storage.js.map +1 -1
- package/dist/services/llm.d.ts +35 -17
- package/dist/services/llm.d.ts.map +1 -1
- package/dist/services/llm.js +249 -113
- 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/model-registry.d.ts +3 -0
- package/dist/services/model-registry.d.ts.map +1 -1
- package/dist/services/model-registry.js +59 -2
- package/dist/services/model-registry.js.map +1 -1
- package/dist/services/provider-diagnostics.d.ts +1 -1
- package/dist/services/provider-diagnostics.d.ts.map +1 -1
- package/dist/services/provider-diagnostics.js +30 -16
- package/dist/services/provider-diagnostics.js.map +1 -1
- package/dist/services/provider-resilience/coordinator.d.ts +8 -3
- package/dist/services/provider-resilience/coordinator.d.ts.map +1 -1
- package/dist/services/provider-resilience/coordinator.js +86 -19
- 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 -26
- 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/types.d.ts +10 -1
- 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 +12 -0
- package/dist/services/session-storage.d.ts.map +1 -1
- package/dist/services/session-storage.js +301 -230
- 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 +25 -7
- package/dist/services/storage-maintenance.js.map +1 -1
- package/dist/services/task-manager.d.ts +6 -1
- 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/tool-allowlist.d.ts +20 -10
- package/dist/services/tool-allowlist.d.ts.map +1 -1
- package/dist/services/tool-allowlist.js +64 -15
- package/dist/services/tool-allowlist.js.map +1 -1
- package/dist/services/usage-state.d.ts +10 -0
- package/dist/services/usage-state.d.ts.map +1 -1
- package/dist/services/usage-state.js +116 -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/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/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +23 -9
- 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 +26 -8
- package/dist/terminal-ui/launch.d.ts.map +1 -1
- package/dist/terminal-ui/launch.js +79 -37
- package/dist/terminal-ui/launch.js.map +1 -1
- package/dist/tools/bash_security.d.ts +17 -0
- package/dist/tools/bash_security.d.ts.map +1 -1
- package/dist/tools/bash_security.js +233 -27
- 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 +13 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +245 -25
- 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 +11 -4
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mcp.js +99 -3
- 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-ui/launch.d.ts +3 -3
- package/dist/tui-ui/launch.d.ts.map +1 -1
- package/dist/tui-ui/launch.js +3 -3
- package/dist/tui-ui/launch.js.map +1 -1
- package/dist/tui-ui/layout.d.ts.map +1 -1
- package/dist/tui-ui/layout.js +9 -3
- package/dist/tui-ui/layout.js.map +1 -1
- package/dist/tui-ui/pickers.d.ts.map +1 -1
- package/dist/tui-ui/pickers.js +1 -0
- package/dist/tui-ui/pickers.js.map +1 -1
- package/dist/tui-ui/runner.d.ts +2 -1
- package/dist/tui-ui/runner.d.ts.map +1 -1
- package/dist/tui-ui/runner.js +18 -29
- package/dist/tui-ui/runner.js.map +1 -1
- package/dist/tui-ui/state.d.ts +13 -1
- package/dist/tui-ui/state.d.ts.map +1 -1
- package/dist/tui-ui/state.js +28 -1
- package/dist/tui-ui/state.js.map +1 -1
- package/dist/ui/markdown.js.map +1 -1
- package/dist/utils/debug-log.d.ts +3 -3
- package/dist/utils/debug-log.d.ts.map +1 -1
- package/dist/utils/debug-log.js +7 -4
- package/dist/utils/debug-log.js.map +1 -1
- 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 +9 -8
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
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");
|
|
@@ -168,7 +203,6 @@ exports.TOOLS = [
|
|
|
168
203
|
isDestructive: () => true,
|
|
169
204
|
isFileEdit: () => true,
|
|
170
205
|
checkPermissions: (_args, _context) => {
|
|
171
|
-
// Destructive operation - ask for confirmation in default mode
|
|
172
206
|
return { behavior: 'ask', reason: 'Write operation may modify existing files' };
|
|
173
207
|
},
|
|
174
208
|
userFacingName: args => `Write ${args.path}`,
|
|
@@ -252,7 +286,7 @@ exports.TOOLS = [
|
|
|
252
286
|
},
|
|
253
287
|
isDestructive: args => {
|
|
254
288
|
const cmd = args.command || '';
|
|
255
|
-
return /(
|
|
289
|
+
return (0, bash_security_1.containsRecursiveRm)(cmd) || /(?:^|[;&|]\s*)(?:[^\s]+\/)?(?:mkfs|dd)(?:\s|$)/.test(cmd);
|
|
256
290
|
},
|
|
257
291
|
checkPermissions: (args, context) => {
|
|
258
292
|
const cmd = args.command || '';
|
|
@@ -560,12 +594,13 @@ exports.TOOLS = [
|
|
|
560
594
|
createdAt: Date.now(),
|
|
561
595
|
updatedAt: Date.now(),
|
|
562
596
|
};
|
|
563
|
-
if ((0,
|
|
597
|
+
if ((0, semantic_config_1.isSemanticEnabled)()) {
|
|
564
598
|
// saveAndIndex internally calls saveMemory + vectorStore.upsert
|
|
565
|
-
await
|
|
599
|
+
const { getSemanticSearchService } = await Promise.resolve().then(() => __importStar(require('../memory/semantic-search')));
|
|
600
|
+
await getSemanticSearchService().saveAndIndex(entry, projectPath);
|
|
566
601
|
}
|
|
567
602
|
else {
|
|
568
|
-
(0,
|
|
603
|
+
(0, storage_1.saveMemory)(entry, projectPath);
|
|
569
604
|
}
|
|
570
605
|
return { success: true, output: `Saved memory: ${name} (${type})` };
|
|
571
606
|
}
|
|
@@ -607,11 +642,12 @@ exports.TOOLS = [
|
|
|
607
642
|
const query = args.query || '';
|
|
608
643
|
const type = args.type;
|
|
609
644
|
let memories;
|
|
610
|
-
if (query && (0,
|
|
645
|
+
if (query && (0, semantic_config_1.isSemanticEnabled)()) {
|
|
611
646
|
// Semantic path: ask the vector store, then fall back to keywords if it
|
|
612
647
|
// returns nothing (e.g. embedding provider unreachable, empty index)
|
|
613
648
|
try {
|
|
614
|
-
const
|
|
649
|
+
const { getSemanticSearchService } = await Promise.resolve().then(() => __importStar(require('../memory/semantic-search')));
|
|
650
|
+
const result = await getSemanticSearchService().search({
|
|
615
651
|
query,
|
|
616
652
|
projectPath,
|
|
617
653
|
type,
|
|
@@ -625,26 +661,26 @@ exports.TOOLS = [
|
|
|
625
661
|
updatedAt: m.createdAt,
|
|
626
662
|
}));
|
|
627
663
|
if (memories.length === 0) {
|
|
628
|
-
memories = (0,
|
|
664
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
629
665
|
if (type)
|
|
630
666
|
memories = memories.filter(m => m.type === type);
|
|
631
667
|
}
|
|
632
668
|
}
|
|
633
669
|
catch (error) {
|
|
634
670
|
(0, debug_log_1.debugError)('tools.memory.semanticSearch', error, query);
|
|
635
|
-
memories = (0,
|
|
671
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
636
672
|
if (type)
|
|
637
673
|
memories = memories.filter(m => m.type === type);
|
|
638
674
|
}
|
|
639
675
|
}
|
|
640
676
|
else if (type) {
|
|
641
|
-
memories = (0,
|
|
677
|
+
memories = (0, storage_1.loadAllMemories)(projectPath).filter(m => m.type === type);
|
|
642
678
|
}
|
|
643
679
|
else if (query) {
|
|
644
|
-
memories = (0,
|
|
680
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
645
681
|
}
|
|
646
682
|
else {
|
|
647
|
-
memories = (0,
|
|
683
|
+
memories = (0, storage_1.loadAllMemories)(projectPath);
|
|
648
684
|
}
|
|
649
685
|
if (memories.length === 0) {
|
|
650
686
|
return { success: true, output: 'No memories found' };
|
|
@@ -694,12 +730,12 @@ exports.TOOLS = [
|
|
|
694
730
|
}
|
|
695
731
|
try {
|
|
696
732
|
const projectPath = context?.cwd || process.cwd();
|
|
697
|
-
const existing = (0,
|
|
733
|
+
const existing = (0, storage_1.loadMemory)(name, projectPath);
|
|
698
734
|
if (!existing) {
|
|
699
735
|
return { success: false, output: '', error: `Memory not found: ${name}` };
|
|
700
736
|
}
|
|
701
|
-
(0,
|
|
702
|
-
if ((0,
|
|
737
|
+
(0, storage_1.deleteMemory)(name, projectPath);
|
|
738
|
+
if ((0, semantic_config_1.isSemanticEnabled)()) {
|
|
703
739
|
try {
|
|
704
740
|
const { getVectorStore } = require('../memory/vector-store');
|
|
705
741
|
getVectorStore().delete(name, projectPath);
|
|
@@ -916,6 +952,56 @@ function safeReadFileSync(resolved) {
|
|
|
916
952
|
function safePath(input, cwd = process.cwd()) {
|
|
917
953
|
return (0, path_1.resolve)(cwd, normalizeToolPath(input));
|
|
918
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
|
+
}
|
|
919
1005
|
/**
|
|
920
1006
|
* Truncate text to at most maxBytes UTF-8 bytes, cutting on a character
|
|
921
1007
|
* boundary (never inside a multi-byte sequence or surrogate pair). Returns the
|
|
@@ -1015,6 +1101,14 @@ async function writeFileSync_(path, content, cwd) {
|
|
|
1015
1101
|
try {
|
|
1016
1102
|
const normalizedPath = normalizeToolPath(path);
|
|
1017
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
|
+
}
|
|
1018
1112
|
(0, fs_1.writeFileSync)(resolved, content, 'utf-8');
|
|
1019
1113
|
return {
|
|
1020
1114
|
success: true,
|
|
@@ -1108,6 +1202,11 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1108
1202
|
cwd: workdir,
|
|
1109
1203
|
detached: useProcessGroup,
|
|
1110
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();
|
|
1111
1210
|
let stdoutData = '';
|
|
1112
1211
|
let stderrData = '';
|
|
1113
1212
|
let stdoutTruncated = false;
|
|
@@ -1189,13 +1288,19 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1189
1288
|
child.stdout.on('data', (data) => {
|
|
1190
1289
|
if (!stdoutTruncated) {
|
|
1191
1290
|
const chunk = data.toString();
|
|
1192
|
-
|
|
1193
|
-
|
|
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) {
|
|
1194
1295
|
stdoutTruncated = true;
|
|
1195
|
-
|
|
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;
|
|
1196
1300
|
}
|
|
1197
1301
|
else {
|
|
1198
1302
|
stdoutData += chunk;
|
|
1303
|
+
stdoutBytes += chunkBytes;
|
|
1199
1304
|
}
|
|
1200
1305
|
}
|
|
1201
1306
|
});
|
|
@@ -1203,13 +1308,17 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1203
1308
|
child.stderr.on('data', (data) => {
|
|
1204
1309
|
if (!stderrTruncated) {
|
|
1205
1310
|
const chunk = data.toString();
|
|
1206
|
-
|
|
1207
|
-
|
|
1311
|
+
// Issue #30: count UTF-8 bytes, not UTF-16 code units.
|
|
1312
|
+
const chunkBytes = Buffer.byteLength(chunk, 'utf8');
|
|
1313
|
+
if (stderrBytes + chunkBytes > maxBytes) {
|
|
1208
1314
|
stderrTruncated = true;
|
|
1209
|
-
|
|
1315
|
+
const room = Math.max(0, maxBytes - stderrBytes);
|
|
1316
|
+
stderrData += truncateToBytes(chunk, room).text;
|
|
1317
|
+
stderrBytes = maxBytes;
|
|
1210
1318
|
}
|
|
1211
1319
|
else {
|
|
1212
1320
|
stderrData += chunk;
|
|
1321
|
+
stderrBytes += chunkBytes;
|
|
1213
1322
|
}
|
|
1214
1323
|
}
|
|
1215
1324
|
});
|
|
@@ -1217,7 +1326,7 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1217
1326
|
if (interrupted === 'aborted') {
|
|
1218
1327
|
finish({
|
|
1219
1328
|
success: false,
|
|
1220
|
-
output: stdoutData
|
|
1329
|
+
output: truncateToBytes(stdoutData, maxBytes).text,
|
|
1221
1330
|
error: 'Command aborted by user',
|
|
1222
1331
|
});
|
|
1223
1332
|
return;
|
|
@@ -1225,7 +1334,7 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1225
1334
|
if (interrupted === 'timeout') {
|
|
1226
1335
|
finish({
|
|
1227
1336
|
success: false,
|
|
1228
|
-
output: stdoutData
|
|
1337
|
+
output: truncateToBytes(stdoutData, maxBytes).text,
|
|
1229
1338
|
error: `Command timed out after ${timeoutMs}ms`,
|
|
1230
1339
|
});
|
|
1231
1340
|
return;
|
|
@@ -1375,6 +1484,14 @@ async function editFile_(path, old_string, new_string, replace_all, fuzzy_match,
|
|
|
1375
1484
|
try {
|
|
1376
1485
|
const normalizedPath = normalizeToolPath(path);
|
|
1377
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
|
+
}
|
|
1378
1495
|
if (!(0, fs_1.existsSync)(resolved)) {
|
|
1379
1496
|
return { success: false, output: '', error: `File not found: ${normalizedPath}` };
|
|
1380
1497
|
}
|
|
@@ -1511,6 +1628,33 @@ async function editFile_(path, old_string, new_string, replace_all, fuzzy_match,
|
|
|
1511
1628
|
function escapeRegExp(str) {
|
|
1512
1629
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1513
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
|
+
}
|
|
1514
1658
|
// ============================================================================
|
|
1515
1659
|
// Glob/Grep 工具实现
|
|
1516
1660
|
// ============================================================================
|
|
@@ -1614,6 +1758,10 @@ async function grep_(pattern, basePath, globPattern, contextLines, cwd) {
|
|
|
1614
1758
|
if (!(0, fs_1.existsSync)(base)) {
|
|
1615
1759
|
return { success: false, output: '', error: `Path not found: ${normalizedBasePath}` };
|
|
1616
1760
|
}
|
|
1761
|
+
const patternError = validateRegexPattern(pattern);
|
|
1762
|
+
if (patternError) {
|
|
1763
|
+
return { success: false, output: '', error: `Invalid grep pattern: ${patternError}` };
|
|
1764
|
+
}
|
|
1617
1765
|
const regex = new RegExp(pattern);
|
|
1618
1766
|
const context = contextLines ?? 0;
|
|
1619
1767
|
const results = [];
|
|
@@ -1841,6 +1989,72 @@ async function executeBatchRead(args, context) {
|
|
|
1841
1989
|
},
|
|
1842
1990
|
], error);
|
|
1843
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
|
+
}
|
|
2021
|
+
if (effective.outcome === 'confirm') {
|
|
2022
|
+
const confirmation = context.toolConfirmation ?? 'ask';
|
|
2023
|
+
if (confirmation === 'deny' || !context.confirmToolUse) {
|
|
2024
|
+
const error = confirmation === 'deny'
|
|
2025
|
+
? `Tool ${step.tool} requires confirmation and was denied by toolConfirmation=deny.`
|
|
2026
|
+
: effective.reason || `Tool ${step.tool} requires user confirmation.`;
|
|
2027
|
+
return buildBatchReadPayload(false, error, [
|
|
2028
|
+
{
|
|
2029
|
+
index: i + 1,
|
|
2030
|
+
tool: step.tool,
|
|
2031
|
+
args: step.args,
|
|
2032
|
+
success: false,
|
|
2033
|
+
error,
|
|
2034
|
+
output: '',
|
|
2035
|
+
},
|
|
2036
|
+
], error);
|
|
2037
|
+
}
|
|
2038
|
+
const approved = await context.confirmToolUse({
|
|
2039
|
+
name: step.tool,
|
|
2040
|
+
args: step.args,
|
|
2041
|
+
reason: effective.reason,
|
|
2042
|
+
abortSignal: context.abortSignal,
|
|
2043
|
+
});
|
|
2044
|
+
if (!approved) {
|
|
2045
|
+
const error = `Tool ${step.tool} requires user confirmation and was denied by user.`;
|
|
2046
|
+
return buildBatchReadPayload(false, error, [
|
|
2047
|
+
{
|
|
2048
|
+
index: i + 1,
|
|
2049
|
+
tool: step.tool,
|
|
2050
|
+
args: step.args,
|
|
2051
|
+
success: false,
|
|
2052
|
+
error,
|
|
2053
|
+
output: '',
|
|
2054
|
+
},
|
|
2055
|
+
], error);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
1844
2058
|
}
|
|
1845
2059
|
const stepResults = [];
|
|
1846
2060
|
for (let i = 0; i < parsed.steps.length; i++) {
|
|
@@ -1902,6 +2116,12 @@ async function executeTool(name, args, abortSignal, toolContext) {
|
|
|
1902
2116
|
abortSignal, // Issue #32 #3.2: 透传 abortSignal
|
|
1903
2117
|
sessionId: toolContext?.sessionId,
|
|
1904
2118
|
turnId: toolContext?.turnId,
|
|
2119
|
+
// Must survive the rebuild: batch_read re-runs the permission gate on its
|
|
2120
|
+
// sub-steps and reads both of these off the context.
|
|
2121
|
+
permissionMode: toolContext?.permissionMode,
|
|
2122
|
+
toolAllowlist: toolContext?.toolAllowlist,
|
|
2123
|
+
toolConfirmation: toolContext?.toolConfirmation,
|
|
2124
|
+
confirmToolUse: toolContext?.confirmToolUse,
|
|
1905
2125
|
};
|
|
1906
2126
|
const result = await tool.execute(args, context);
|
|
1907
2127
|
// Assertions are generated by the runtime allowlist, never accepted from a
|