@orion-agents/orion-code 0.1.4 → 0.1.6
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 +73 -38
- package/README.zh-CN.md +32 -10
- 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 +617 -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 +1 -1
- package/dist/commands/target-command.d.ts.map +1 -1
- package/dist/commands/target-command.js +42 -6
- 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/drift-guard.d.ts.map +1 -1
- package/dist/harness/drift-guard.js +9 -1
- package/dist/harness/drift-guard.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/validation.d.ts +3 -0
- package/dist/memory/validation.d.ts.map +1 -1
- package/dist/memory/validation.js +123 -10
- package/dist/memory/validation.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 +59 -107
- 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 +129 -15
- 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 +56 -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 +32 -8
- package/dist/runtime/goals/tools.d.ts.map +1 -1
- package/dist/runtime/goals/tools.js +187 -11
- package/dist/runtime/goals/tools.js.map +1 -1
- package/dist/runtime/goals/types.d.ts +9 -0
- package/dist/runtime/goals/types.d.ts.map +1 -1
- package/dist/runtime/goals/types.js +1 -0
- package/dist/runtime/goals/types.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 +35 -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/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 +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 +82 -39
- 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 +262 -30
- 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 +5 -1
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +29 -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 +19 -5
- 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 || '';
|
|
@@ -266,11 +300,15 @@ exports.TOOLS = [
|
|
|
266
300
|
}
|
|
267
301
|
// v0.1.3-2 §1.2: a configured-but-unusable sandbox is a hard deny, decided
|
|
268
302
|
// here so the user sees the reason instead of an opaque execution failure.
|
|
269
|
-
const workdir = context?.cwd
|
|
270
|
-
const sandboxSettings = (0, sandbox_1.resolveSandboxSettings)(
|
|
303
|
+
const { workdir, projectRoot } = resolveExecCommandPaths(args.cwd, context?.cwd);
|
|
304
|
+
const sandboxSettings = (0, sandbox_1.resolveSandboxSettings)(projectRoot);
|
|
271
305
|
let sandboxNote = '';
|
|
272
306
|
if ((sandboxSettings.profile ?? 'none') !== 'none') {
|
|
273
|
-
const plan = (0, sandbox_1.planSandboxedCommand)(cmd, {
|
|
307
|
+
const plan = (0, sandbox_1.planSandboxedCommand)(cmd, {
|
|
308
|
+
cwd: workdir,
|
|
309
|
+
projectRoot,
|
|
310
|
+
settings: sandboxSettings,
|
|
311
|
+
});
|
|
274
312
|
if (!plan.ok) {
|
|
275
313
|
return {
|
|
276
314
|
behavior: 'deny',
|
|
@@ -560,12 +598,13 @@ exports.TOOLS = [
|
|
|
560
598
|
createdAt: Date.now(),
|
|
561
599
|
updatedAt: Date.now(),
|
|
562
600
|
};
|
|
563
|
-
if ((0,
|
|
601
|
+
if ((0, semantic_config_1.isSemanticEnabled)()) {
|
|
564
602
|
// saveAndIndex internally calls saveMemory + vectorStore.upsert
|
|
565
|
-
await
|
|
603
|
+
const { getSemanticSearchService } = await Promise.resolve().then(() => __importStar(require('../memory/semantic-search')));
|
|
604
|
+
await getSemanticSearchService().saveAndIndex(entry, projectPath);
|
|
566
605
|
}
|
|
567
606
|
else {
|
|
568
|
-
(0,
|
|
607
|
+
(0, storage_1.saveMemory)(entry, projectPath);
|
|
569
608
|
}
|
|
570
609
|
return { success: true, output: `Saved memory: ${name} (${type})` };
|
|
571
610
|
}
|
|
@@ -607,11 +646,12 @@ exports.TOOLS = [
|
|
|
607
646
|
const query = args.query || '';
|
|
608
647
|
const type = args.type;
|
|
609
648
|
let memories;
|
|
610
|
-
if (query && (0,
|
|
649
|
+
if (query && (0, semantic_config_1.isSemanticEnabled)()) {
|
|
611
650
|
// Semantic path: ask the vector store, then fall back to keywords if it
|
|
612
651
|
// returns nothing (e.g. embedding provider unreachable, empty index)
|
|
613
652
|
try {
|
|
614
|
-
const
|
|
653
|
+
const { getSemanticSearchService } = await Promise.resolve().then(() => __importStar(require('../memory/semantic-search')));
|
|
654
|
+
const result = await getSemanticSearchService().search({
|
|
615
655
|
query,
|
|
616
656
|
projectPath,
|
|
617
657
|
type,
|
|
@@ -625,26 +665,26 @@ exports.TOOLS = [
|
|
|
625
665
|
updatedAt: m.createdAt,
|
|
626
666
|
}));
|
|
627
667
|
if (memories.length === 0) {
|
|
628
|
-
memories = (0,
|
|
668
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
629
669
|
if (type)
|
|
630
670
|
memories = memories.filter(m => m.type === type);
|
|
631
671
|
}
|
|
632
672
|
}
|
|
633
673
|
catch (error) {
|
|
634
674
|
(0, debug_log_1.debugError)('tools.memory.semanticSearch', error, query);
|
|
635
|
-
memories = (0,
|
|
675
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
636
676
|
if (type)
|
|
637
677
|
memories = memories.filter(m => m.type === type);
|
|
638
678
|
}
|
|
639
679
|
}
|
|
640
680
|
else if (type) {
|
|
641
|
-
memories = (0,
|
|
681
|
+
memories = (0, storage_1.loadAllMemories)(projectPath).filter(m => m.type === type);
|
|
642
682
|
}
|
|
643
683
|
else if (query) {
|
|
644
|
-
memories = (0,
|
|
684
|
+
memories = (0, storage_1.searchMemories)(query, projectPath);
|
|
645
685
|
}
|
|
646
686
|
else {
|
|
647
|
-
memories = (0,
|
|
687
|
+
memories = (0, storage_1.loadAllMemories)(projectPath);
|
|
648
688
|
}
|
|
649
689
|
if (memories.length === 0) {
|
|
650
690
|
return { success: true, output: 'No memories found' };
|
|
@@ -694,12 +734,12 @@ exports.TOOLS = [
|
|
|
694
734
|
}
|
|
695
735
|
try {
|
|
696
736
|
const projectPath = context?.cwd || process.cwd();
|
|
697
|
-
const existing = (0,
|
|
737
|
+
const existing = (0, storage_1.loadMemory)(name, projectPath);
|
|
698
738
|
if (!existing) {
|
|
699
739
|
return { success: false, output: '', error: `Memory not found: ${name}` };
|
|
700
740
|
}
|
|
701
|
-
(0,
|
|
702
|
-
if ((0,
|
|
741
|
+
(0, storage_1.deleteMemory)(name, projectPath);
|
|
742
|
+
if ((0, semantic_config_1.isSemanticEnabled)()) {
|
|
703
743
|
try {
|
|
704
744
|
const { getVectorStore } = require('../memory/vector-store');
|
|
705
745
|
getVectorStore().delete(name, projectPath);
|
|
@@ -916,6 +956,56 @@ function safeReadFileSync(resolved) {
|
|
|
916
956
|
function safePath(input, cwd = process.cwd()) {
|
|
917
957
|
return (0, path_1.resolve)(cwd, normalizeToolPath(input));
|
|
918
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* Return true when `p` resolves (after following symlinks) to a location at or
|
|
961
|
+
* under `rootReal`. Used to enforce that a realpath is still inside the
|
|
962
|
+
* workspace even when directories along the path are themselves symlinks.
|
|
963
|
+
*/
|
|
964
|
+
function isUnderRealRoot(p, rootReal) {
|
|
965
|
+
const rel = (0, path_1.relative)(rootReal, p);
|
|
966
|
+
return rel === '' || (!rel.startsWith('..') && !(0, path_1.isAbsolute)(rel));
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Contain a tool-resolved path inside the workspace root (cwd).
|
|
970
|
+
*
|
|
971
|
+
* Blocks `../` traversal and absolute paths outside the workspace, which would
|
|
972
|
+
* otherwise let `write_file`/`edit_file` scribble over `~/.bashrc`, SSH config
|
|
973
|
+
* or other projects — especially dangerous under `acceptEdits` auto-approval,
|
|
974
|
+
* where the write runs without a confirmation prompt (issue #65).
|
|
975
|
+
*
|
|
976
|
+
* Containment is lexical first, then re-checked after resolving symlinks
|
|
977
|
+
* (issue #99): a workspace symlink that points outside the workspace must not
|
|
978
|
+
* be followed into an arbitrary write target. We resolve the realpath of the
|
|
979
|
+
* parent directory (which also collapses any intermediate symlinked dirs) and,
|
|
980
|
+
* if the target already exists, the target itself; if either escapes the
|
|
981
|
+
* workspace we refuse. The workspace root is also realpath-resolved so a
|
|
982
|
+
* symlinked cwd does not produce false rejections. Fail-closed on any
|
|
983
|
+
* filesystem error.
|
|
984
|
+
*/
|
|
985
|
+
function isWithinWorkspace(resolved, cwd) {
|
|
986
|
+
const root = (0, path_1.resolve)(cwd);
|
|
987
|
+
const rel = (0, path_1.relative)(root, resolved);
|
|
988
|
+
if (!(rel === '' || (!rel.startsWith('..') && !(0, path_1.isAbsolute)(rel))))
|
|
989
|
+
return false;
|
|
990
|
+
try {
|
|
991
|
+
const rootReal = (0, fs_1.realpathSync)(root);
|
|
992
|
+
const realParent = (0, fs_1.realpathSync)((0, path_1.dirname)(resolved));
|
|
993
|
+
if (!isUnderRealRoot(realParent, rootReal))
|
|
994
|
+
return false;
|
|
995
|
+
// Only the existing target needs its own realpath check; a brand-new file
|
|
996
|
+
// inherits the (already-validated) containment of its parent directory.
|
|
997
|
+
if ((0, fs_1.existsSync)(resolved)) {
|
|
998
|
+
const realTarget = (0, fs_1.realpathSync)(resolved);
|
|
999
|
+
if (!isUnderRealRoot(realTarget, rootReal))
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
catch {
|
|
1004
|
+
// A missing/unknowable realpath means we cannot prove containment — refuse.
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
919
1009
|
/**
|
|
920
1010
|
* Truncate text to at most maxBytes UTF-8 bytes, cutting on a character
|
|
921
1011
|
* boundary (never inside a multi-byte sequence or surrogate pair). Returns the
|
|
@@ -1015,6 +1105,14 @@ async function writeFileSync_(path, content, cwd) {
|
|
|
1015
1105
|
try {
|
|
1016
1106
|
const normalizedPath = normalizeToolPath(path);
|
|
1017
1107
|
const resolved = safePath(path, cwd);
|
|
1108
|
+
const workspaceRoot = cwd ?? process.cwd();
|
|
1109
|
+
if (!isWithinWorkspace(resolved, workspaceRoot)) {
|
|
1110
|
+
return {
|
|
1111
|
+
success: false,
|
|
1112
|
+
output: '',
|
|
1113
|
+
error: `Refusing to write outside the workspace: ${normalizedPath}`,
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1018
1116
|
(0, fs_1.writeFileSync)(resolved, content, 'utf-8');
|
|
1019
1117
|
return {
|
|
1020
1118
|
success: true,
|
|
@@ -1069,14 +1167,22 @@ async function listFiles_(path, maxDepth, cwd) {
|
|
|
1069
1167
|
return { success: true, output };
|
|
1070
1168
|
}
|
|
1071
1169
|
// Issue #32 #3.2: execCommand_ 支持 abortSignal
|
|
1170
|
+
function resolveExecCommandPaths(cwd, baseCwd) {
|
|
1171
|
+
const projectRoot = baseCwd ?? process.cwd();
|
|
1172
|
+
return {
|
|
1173
|
+
workdir: cwd ? safePath(cwd, projectRoot) : projectRoot,
|
|
1174
|
+
projectRoot,
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1072
1177
|
async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseCwd, sandbox) {
|
|
1073
|
-
const workdir
|
|
1178
|
+
const { workdir, projectRoot } = resolveExecCommandPaths(cwd, baseCwd);
|
|
1074
1179
|
// v0.1.3-2 §1.2: plan the (possibly sandboxed) argv before spawning. A
|
|
1075
1180
|
// configured sandbox that cannot be honoured must refuse the command rather
|
|
1076
1181
|
// than silently degrade into an unsandboxed run.
|
|
1077
1182
|
const plan = (0, sandbox_1.planSandboxedCommand)(command, {
|
|
1078
1183
|
cwd: workdir,
|
|
1079
|
-
|
|
1184
|
+
projectRoot,
|
|
1185
|
+
settings: sandbox ?? (0, sandbox_1.resolveSandboxSettings)(projectRoot),
|
|
1080
1186
|
});
|
|
1081
1187
|
if (!plan.ok) {
|
|
1082
1188
|
return {
|
|
@@ -1108,6 +1214,11 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1108
1214
|
cwd: workdir,
|
|
1109
1215
|
detached: useProcessGroup,
|
|
1110
1216
|
});
|
|
1217
|
+
// Issue #53: exec_command runs a complete command as a single argv element
|
|
1218
|
+
// and never pipes input into it. If stdin stays open, stdin-reading commands
|
|
1219
|
+
// (cat, sort, grep, `python3 -`, ...) block waiting for EOF until the timeout.
|
|
1220
|
+
// Close it immediately so the child receives EOF and can proceed.
|
|
1221
|
+
child.stdin?.end();
|
|
1111
1222
|
let stdoutData = '';
|
|
1112
1223
|
let stderrData = '';
|
|
1113
1224
|
let stdoutTruncated = false;
|
|
@@ -1189,13 +1300,19 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1189
1300
|
child.stdout.on('data', (data) => {
|
|
1190
1301
|
if (!stdoutTruncated) {
|
|
1191
1302
|
const chunk = data.toString();
|
|
1192
|
-
|
|
1193
|
-
|
|
1303
|
+
// Issue #30: count UTF-8 bytes, not UTF-16 code units, so CJK/emoji
|
|
1304
|
+
// output is bounded by `maxBytes` (a UTF-16 count could exceed it ~2x).
|
|
1305
|
+
const chunkBytes = Buffer.byteLength(chunk, 'utf8');
|
|
1306
|
+
if (stdoutBytes + chunkBytes > maxBytes) {
|
|
1194
1307
|
stdoutTruncated = true;
|
|
1195
|
-
|
|
1308
|
+
const room = Math.max(0, maxBytes - stdoutBytes);
|
|
1309
|
+
// Byte-accurate truncation that respects multi-byte character boundaries.
|
|
1310
|
+
stdoutData += truncateToBytes(chunk, room).text;
|
|
1311
|
+
stdoutBytes = maxBytes;
|
|
1196
1312
|
}
|
|
1197
1313
|
else {
|
|
1198
1314
|
stdoutData += chunk;
|
|
1315
|
+
stdoutBytes += chunkBytes;
|
|
1199
1316
|
}
|
|
1200
1317
|
}
|
|
1201
1318
|
});
|
|
@@ -1203,13 +1320,17 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1203
1320
|
child.stderr.on('data', (data) => {
|
|
1204
1321
|
if (!stderrTruncated) {
|
|
1205
1322
|
const chunk = data.toString();
|
|
1206
|
-
|
|
1207
|
-
|
|
1323
|
+
// Issue #30: count UTF-8 bytes, not UTF-16 code units.
|
|
1324
|
+
const chunkBytes = Buffer.byteLength(chunk, 'utf8');
|
|
1325
|
+
if (stderrBytes + chunkBytes > maxBytes) {
|
|
1208
1326
|
stderrTruncated = true;
|
|
1209
|
-
|
|
1327
|
+
const room = Math.max(0, maxBytes - stderrBytes);
|
|
1328
|
+
stderrData += truncateToBytes(chunk, room).text;
|
|
1329
|
+
stderrBytes = maxBytes;
|
|
1210
1330
|
}
|
|
1211
1331
|
else {
|
|
1212
1332
|
stderrData += chunk;
|
|
1333
|
+
stderrBytes += chunkBytes;
|
|
1213
1334
|
}
|
|
1214
1335
|
}
|
|
1215
1336
|
});
|
|
@@ -1217,7 +1338,7 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1217
1338
|
if (interrupted === 'aborted') {
|
|
1218
1339
|
finish({
|
|
1219
1340
|
success: false,
|
|
1220
|
-
output: stdoutData
|
|
1341
|
+
output: truncateToBytes(stdoutData, maxBytes).text,
|
|
1221
1342
|
error: 'Command aborted by user',
|
|
1222
1343
|
});
|
|
1223
1344
|
return;
|
|
@@ -1225,7 +1346,7 @@ async function execCommand_(command, cwd, timeout, maxOutput, abortSignal, baseC
|
|
|
1225
1346
|
if (interrupted === 'timeout') {
|
|
1226
1347
|
finish({
|
|
1227
1348
|
success: false,
|
|
1228
|
-
output: stdoutData
|
|
1349
|
+
output: truncateToBytes(stdoutData, maxBytes).text,
|
|
1229
1350
|
error: `Command timed out after ${timeoutMs}ms`,
|
|
1230
1351
|
});
|
|
1231
1352
|
return;
|
|
@@ -1375,6 +1496,14 @@ async function editFile_(path, old_string, new_string, replace_all, fuzzy_match,
|
|
|
1375
1496
|
try {
|
|
1376
1497
|
const normalizedPath = normalizeToolPath(path);
|
|
1377
1498
|
const resolved = safePath(path, cwd);
|
|
1499
|
+
const workspaceRoot = cwd ?? process.cwd();
|
|
1500
|
+
if (!isWithinWorkspace(resolved, workspaceRoot)) {
|
|
1501
|
+
return {
|
|
1502
|
+
success: false,
|
|
1503
|
+
output: '',
|
|
1504
|
+
error: `Refusing to edit outside the workspace: ${normalizedPath}`,
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1378
1507
|
if (!(0, fs_1.existsSync)(resolved)) {
|
|
1379
1508
|
return { success: false, output: '', error: `File not found: ${normalizedPath}` };
|
|
1380
1509
|
}
|
|
@@ -1511,6 +1640,33 @@ async function editFile_(path, old_string, new_string, replace_all, fuzzy_match,
|
|
|
1511
1640
|
function escapeRegExp(str) {
|
|
1512
1641
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1513
1642
|
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Validate a caller-supplied regular expression pattern before compiling it.
|
|
1645
|
+
*
|
|
1646
|
+
* Issue #79: `grep_` compiles user/model-supplied patterns with `new RegExp`
|
|
1647
|
+
* directly. A pathological pattern with a quantified group that itself contains
|
|
1648
|
+
* a quantifier (e.g. `(a+)+`, `(\d+)*`) triggers catastrophic backtracking
|
|
1649
|
+
* (ReDoS) and can hang the process on adversarial input (prompt injection).
|
|
1650
|
+
* Reject empty/oversized patterns and the classic nested-quantifier shapes.
|
|
1651
|
+
*/
|
|
1652
|
+
function validateRegexPattern(pattern) {
|
|
1653
|
+
if (!pattern)
|
|
1654
|
+
return 'pattern must not be empty';
|
|
1655
|
+
if (pattern.length > 2000)
|
|
1656
|
+
return 'pattern is too long (max 2000 characters)';
|
|
1657
|
+
// A group containing an internal quantifier, then quantified again: the
|
|
1658
|
+
// canonical exponential-backtracking construction.
|
|
1659
|
+
if (/\([^()]*[*+?][^()]*\)\s*[*+?]/.test(pattern)) {
|
|
1660
|
+
return 'pattern contains a quantified group with an internal quantifier — this risks catastrophic backtracking (ReDoS)';
|
|
1661
|
+
}
|
|
1662
|
+
try {
|
|
1663
|
+
new RegExp(pattern);
|
|
1664
|
+
}
|
|
1665
|
+
catch {
|
|
1666
|
+
return 'pattern is not a valid regular expression';
|
|
1667
|
+
}
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1514
1670
|
// ============================================================================
|
|
1515
1671
|
// Glob/Grep 工具实现
|
|
1516
1672
|
// ============================================================================
|
|
@@ -1614,6 +1770,10 @@ async function grep_(pattern, basePath, globPattern, contextLines, cwd) {
|
|
|
1614
1770
|
if (!(0, fs_1.existsSync)(base)) {
|
|
1615
1771
|
return { success: false, output: '', error: `Path not found: ${normalizedBasePath}` };
|
|
1616
1772
|
}
|
|
1773
|
+
const patternError = validateRegexPattern(pattern);
|
|
1774
|
+
if (patternError) {
|
|
1775
|
+
return { success: false, output: '', error: `Invalid grep pattern: ${patternError}` };
|
|
1776
|
+
}
|
|
1617
1777
|
const regex = new RegExp(pattern);
|
|
1618
1778
|
const context = contextLines ?? 0;
|
|
1619
1779
|
const results = [];
|
|
@@ -1841,6 +2001,72 @@ async function executeBatchRead(args, context) {
|
|
|
1841
2001
|
},
|
|
1842
2002
|
], error);
|
|
1843
2003
|
}
|
|
2004
|
+
// The scheduler resolved permissions for `batch_read` itself, not for the
|
|
2005
|
+
// tools it fans out to. Without re-running the gate here, a project
|
|
2006
|
+
// `deny: read_file(*.env)` rule -- and the plan-mode block -- apply to the
|
|
2007
|
+
// flat call but not to the batched one, so the model can read a denied path
|
|
2008
|
+
// simply by wrapping it in `batch_read`.
|
|
2009
|
+
const stepPermission = (0, tool_1.getToolMetadataPresence)(tool).hasPermissionCheck && tool.checkPermissions
|
|
2010
|
+
? tool.checkPermissions(step.args, context)
|
|
2011
|
+
: undefined;
|
|
2012
|
+
const effective = (0, tool_scheduler_1.resolveEffectivePermission)({
|
|
2013
|
+
toolName: step.tool,
|
|
2014
|
+
tool,
|
|
2015
|
+
args: step.args,
|
|
2016
|
+
permission: stepPermission,
|
|
2017
|
+
permissionMode: context.permissionMode,
|
|
2018
|
+
allowlist: context.toolAllowlist?.(step.tool, step.args),
|
|
2019
|
+
});
|
|
2020
|
+
if (effective.outcome === 'deny' || effective.outcome === 'block') {
|
|
2021
|
+
const error = effective.reason || `Tool ${step.tool} is not permitted (${effective.source ?? 'policy'})`;
|
|
2022
|
+
return buildBatchReadPayload(false, error, [
|
|
2023
|
+
{
|
|
2024
|
+
index: i + 1,
|
|
2025
|
+
tool: step.tool,
|
|
2026
|
+
args: step.args,
|
|
2027
|
+
success: false,
|
|
2028
|
+
error,
|
|
2029
|
+
output: '',
|
|
2030
|
+
},
|
|
2031
|
+
], error);
|
|
2032
|
+
}
|
|
2033
|
+
if (effective.outcome === 'confirm') {
|
|
2034
|
+
const confirmation = context.toolConfirmation ?? 'ask';
|
|
2035
|
+
if (confirmation === 'deny' || !context.confirmToolUse) {
|
|
2036
|
+
const error = confirmation === 'deny'
|
|
2037
|
+
? `Tool ${step.tool} requires confirmation and was denied by toolConfirmation=deny.`
|
|
2038
|
+
: effective.reason || `Tool ${step.tool} requires user confirmation.`;
|
|
2039
|
+
return buildBatchReadPayload(false, error, [
|
|
2040
|
+
{
|
|
2041
|
+
index: i + 1,
|
|
2042
|
+
tool: step.tool,
|
|
2043
|
+
args: step.args,
|
|
2044
|
+
success: false,
|
|
2045
|
+
error,
|
|
2046
|
+
output: '',
|
|
2047
|
+
},
|
|
2048
|
+
], error);
|
|
2049
|
+
}
|
|
2050
|
+
const approved = await context.confirmToolUse({
|
|
2051
|
+
name: step.tool,
|
|
2052
|
+
args: step.args,
|
|
2053
|
+
reason: effective.reason,
|
|
2054
|
+
abortSignal: context.abortSignal,
|
|
2055
|
+
});
|
|
2056
|
+
if (!approved) {
|
|
2057
|
+
const error = `Tool ${step.tool} requires user confirmation and was denied by user.`;
|
|
2058
|
+
return buildBatchReadPayload(false, error, [
|
|
2059
|
+
{
|
|
2060
|
+
index: i + 1,
|
|
2061
|
+
tool: step.tool,
|
|
2062
|
+
args: step.args,
|
|
2063
|
+
success: false,
|
|
2064
|
+
error,
|
|
2065
|
+
output: '',
|
|
2066
|
+
},
|
|
2067
|
+
], error);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
1844
2070
|
}
|
|
1845
2071
|
const stepResults = [];
|
|
1846
2072
|
for (let i = 0; i < parsed.steps.length; i++) {
|
|
@@ -1902,6 +2128,12 @@ async function executeTool(name, args, abortSignal, toolContext) {
|
|
|
1902
2128
|
abortSignal, // Issue #32 #3.2: 透传 abortSignal
|
|
1903
2129
|
sessionId: toolContext?.sessionId,
|
|
1904
2130
|
turnId: toolContext?.turnId,
|
|
2131
|
+
// Must survive the rebuild: batch_read re-runs the permission gate on its
|
|
2132
|
+
// sub-steps and reads both of these off the context.
|
|
2133
|
+
permissionMode: toolContext?.permissionMode,
|
|
2134
|
+
toolAllowlist: toolContext?.toolAllowlist,
|
|
2135
|
+
toolConfirmation: toolContext?.toolConfirmation,
|
|
2136
|
+
confirmToolUse: toolContext?.confirmToolUse,
|
|
1905
2137
|
};
|
|
1906
2138
|
const result = await tool.execute(args, context);
|
|
1907
2139
|
// Assertions are generated by the runtime allowlist, never accepted from a
|