operon-agents-core 0.1.0-alpha.0
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/LICENSE +55 -0
- package/README.md +7 -0
- package/dist/agent/agent.d.ts +65 -0
- package/dist/agent/agent.js +39 -0
- package/dist/agent/compose-hooks.d.ts +13 -0
- package/dist/agent/compose-hooks.js +197 -0
- package/dist/agent/concurrency.d.ts +22 -0
- package/dist/agent/concurrency.js +70 -0
- package/dist/agent/context-report.d.ts +60 -0
- package/dist/agent/context-report.js +45 -0
- package/dist/agent/graph.d.ts +48 -0
- package/dist/agent/graph.js +129 -0
- package/dist/agent/guardrail.d.ts +105 -0
- package/dist/agent/guardrail.js +314 -0
- package/dist/agent/handoff-executor.d.ts +21 -0
- package/dist/agent/handoff-executor.js +95 -0
- package/dist/agent/handoff.d.ts +42 -0
- package/dist/agent/handoff.js +70 -0
- package/dist/agent/index.d.ts +25 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/instruction-context.d.ts +33 -0
- package/dist/agent/instruction-context.js +100 -0
- package/dist/agent/pause.d.ts +12 -0
- package/dist/agent/pause.js +82 -0
- package/dist/agent/profile-builtins.d.ts +8 -0
- package/dist/agent/profile-builtins.js +130 -0
- package/dist/agent/profiles.d.ts +94 -0
- package/dist/agent/profiles.js +264 -0
- package/dist/agent/recovery.d.ts +10 -0
- package/dist/agent/recovery.js +151 -0
- package/dist/agent/run-support.d.ts +79 -0
- package/dist/agent/run-support.js +211 -0
- package/dist/agent/runner.d.ts +246 -0
- package/dist/agent/runner.js +786 -0
- package/dist/agent/session.d.ts +363 -0
- package/dist/agent/session.js +937 -0
- package/dist/agent/subagent-tools.d.ts +18 -0
- package/dist/agent/subagent-tools.js +650 -0
- package/dist/agent/subagent.d.ts +56 -0
- package/dist/agent/subagent.js +50 -0
- package/dist/agent/toolset.d.ts +24 -0
- package/dist/agent/toolset.js +112 -0
- package/dist/agent/workflow/index.d.ts +9 -0
- package/dist/agent/workflow/index.js +8 -0
- package/dist/agent/workflow/journal.d.ts +180 -0
- package/dist/agent/workflow/journal.js +224 -0
- package/dist/agent/workflow/manager.d.ts +27 -0
- package/dist/agent/workflow/manager.js +33 -0
- package/dist/agent/workflow/parse.d.ts +17 -0
- package/dist/agent/workflow/parse.js +174 -0
- package/dist/agent/workflow/prompt.d.ts +8 -0
- package/dist/agent/workflow/prompt.js +84 -0
- package/dist/agent/workflow/runtime.d.ts +64 -0
- package/dist/agent/workflow/runtime.js +380 -0
- package/dist/agent/workflow/sandbox.d.ts +35 -0
- package/dist/agent/workflow/sandbox.js +90 -0
- package/dist/agent/workflow/snapshot.d.ts +36 -0
- package/dist/agent/workflow/snapshot.js +9 -0
- package/dist/agent/workflow/structured.d.ts +35 -0
- package/dist/agent/workflow/structured.js +79 -0
- package/dist/agent/workflow/tool.d.ts +14 -0
- package/dist/agent/workflow/tool.js +569 -0
- package/dist/agent/workflow/types.d.ts +100 -0
- package/dist/agent/workflow/types.js +17 -0
- package/dist/agent/worktree.d.ts +38 -0
- package/dist/agent/worktree.js +56 -0
- package/dist/capabilities/assembler.d.ts +39 -0
- package/dist/capabilities/assembler.js +171 -0
- package/dist/capabilities/background/agent-task.d.ts +51 -0
- package/dist/capabilities/background/agent-task.js +101 -0
- package/dist/capabilities/background/command-task.d.ts +43 -0
- package/dist/capabilities/background/command-task.js +86 -0
- package/dist/capabilities/background/index.d.ts +20 -0
- package/dist/capabilities/background/index.js +57 -0
- package/dist/capabilities/background/manager.d.ts +194 -0
- package/dist/capabilities/background/manager.js +1131 -0
- package/dist/capabilities/background/persist-disk.d.ts +17 -0
- package/dist/capabilities/background/persist-disk.js +66 -0
- package/dist/capabilities/background/persist.d.ts +61 -0
- package/dist/capabilities/background/persist.js +117 -0
- package/dist/capabilities/background/question-task.d.ts +32 -0
- package/dist/capabilities/background/question-task.js +56 -0
- package/dist/capabilities/background/registrar.d.ts +12 -0
- package/dist/capabilities/background/registrar.js +9 -0
- package/dist/capabilities/background/swappable-sink.d.ts +20 -0
- package/dist/capabilities/background/swappable-sink.js +20 -0
- package/dist/capabilities/background/task.d.ts +114 -0
- package/dist/capabilities/background/task.js +20 -0
- package/dist/capabilities/background/tools.d.ts +6 -0
- package/dist/capabilities/background/tools.js +190 -0
- package/dist/capabilities/background/workflow-task.d.ts +48 -0
- package/dist/capabilities/background/workflow-task.js +91 -0
- package/dist/capabilities/capability-state.d.ts +13 -0
- package/dist/capabilities/capability-state.js +37 -0
- package/dist/capabilities/capability.d.ts +145 -0
- package/dist/capabilities/capability.js +2 -0
- package/dist/capabilities/compaction/full.d.ts +27 -0
- package/dist/capabilities/compaction/full.js +155 -0
- package/dist/capabilities/compaction/index.d.ts +17 -0
- package/dist/capabilities/compaction/index.js +145 -0
- package/dist/capabilities/compaction/instruction.d.ts +2 -0
- package/dist/capabilities/compaction/instruction.js +31 -0
- package/dist/capabilities/compaction/micro.d.ts +17 -0
- package/dist/capabilities/compaction/micro.js +57 -0
- package/dist/capabilities/compaction/service.d.ts +28 -0
- package/dist/capabilities/compaction/service.js +52 -0
- package/dist/capabilities/compaction/strategy.d.ts +43 -0
- package/dist/capabilities/compaction/strategy.js +116 -0
- package/dist/capabilities/compaction/tokens.d.ts +5 -0
- package/dist/capabilities/compaction/tokens.js +28 -0
- package/dist/capabilities/goal/goal-store.d.ts +69 -0
- package/dist/capabilities/goal/goal-store.js +172 -0
- package/dist/capabilities/goal/index.d.ts +6 -0
- package/dist/capabilities/goal/index.js +31 -0
- package/dist/capabilities/goal/injector.d.ts +9 -0
- package/dist/capabilities/goal/injector.js +79 -0
- package/dist/capabilities/goal/tools.d.ts +6 -0
- package/dist/capabilities/goal/tools.js +86 -0
- package/dist/capabilities/index.d.ts +25 -0
- package/dist/capabilities/index.js +22 -0
- package/dist/capabilities/injection.d.ts +44 -0
- package/dist/capabilities/injection.js +112 -0
- package/dist/capabilities/plan/index.d.ts +6 -0
- package/dist/capabilities/plan/index.js +25 -0
- package/dist/capabilities/plan/injector.d.ts +13 -0
- package/dist/capabilities/plan/injector.js +83 -0
- package/dist/capabilities/plan/plan-mode.d.ts +38 -0
- package/dist/capabilities/plan/plan-mode.js +113 -0
- package/dist/capabilities/plan/policies.d.ts +6 -0
- package/dist/capabilities/plan/policies.js +89 -0
- package/dist/capabilities/plan/tools.d.ts +15 -0
- package/dist/capabilities/plan/tools.js +87 -0
- package/dist/capabilities/skills/flow-provider.d.ts +6 -0
- package/dist/capabilities/skills/flow-provider.js +50 -0
- package/dist/capabilities/skills/index.d.ts +43 -0
- package/dist/capabilities/skills/index.js +48 -0
- package/dist/capabilities/skills/injector.d.ts +11 -0
- package/dist/capabilities/skills/injector.js +27 -0
- package/dist/capabilities/skills/parser.d.ts +36 -0
- package/dist/capabilities/skills/parser.js +334 -0
- package/dist/capabilities/skills/registry.d.ts +33 -0
- package/dist/capabilities/skills/registry.js +118 -0
- package/dist/capabilities/skills/scanner.d.ts +26 -0
- package/dist/capabilities/skills/scanner.js +154 -0
- package/dist/capabilities/skills/service.d.ts +39 -0
- package/dist/capabilities/skills/service.js +68 -0
- package/dist/capabilities/skills/skill-tool.d.ts +13 -0
- package/dist/capabilities/skills/skill-tool.js +72 -0
- package/dist/capabilities/skills/types.d.ts +62 -0
- package/dist/capabilities/skills/types.js +26 -0
- package/dist/capabilities/task/index.d.ts +23 -0
- package/dist/capabilities/task/index.js +38 -0
- package/dist/capabilities/task/injector.d.ts +9 -0
- package/dist/capabilities/task/injector.js +62 -0
- package/dist/capabilities/task/persist-disk.d.ts +19 -0
- package/dist/capabilities/task/persist-disk.js +84 -0
- package/dist/capabilities/task/persist.d.ts +52 -0
- package/dist/capabilities/task/persist.js +84 -0
- package/dist/capabilities/task/task-store.d.ts +44 -0
- package/dist/capabilities/task/task-store.js +106 -0
- package/dist/capabilities/task/tools.d.ts +12 -0
- package/dist/capabilities/task/tools.js +164 -0
- package/dist/capabilities/todo/index.d.ts +8 -0
- package/dist/capabilities/todo/index.js +21 -0
- package/dist/capabilities/todo/injector.d.ts +9 -0
- package/dist/capabilities/todo/injector.js +68 -0
- package/dist/capabilities/todo/todo-store.d.ts +19 -0
- package/dist/capabilities/todo/todo-store.js +36 -0
- package/dist/capabilities/todo/tools.d.ts +6 -0
- package/dist/capabilities/todo/tools.js +70 -0
- package/dist/capabilities/tool-provider.d.ts +12 -0
- package/dist/capabilities/tool-provider.js +20 -0
- package/dist/capabilities/user-hooks/engine.d.ts +22 -0
- package/dist/capabilities/user-hooks/engine.js +105 -0
- package/dist/capabilities/user-hooks/index.d.ts +13 -0
- package/dist/capabilities/user-hooks/index.js +126 -0
- package/dist/capabilities/user-hooks/types.d.ts +26 -0
- package/dist/capabilities/user-hooks/types.js +19 -0
- package/dist/capabilities/workflow/index.d.ts +16 -0
- package/dist/capabilities/workflow/index.js +15 -0
- package/dist/commands/index.d.ts +31 -0
- package/dist/commands/index.js +318 -0
- package/dist/config/config-store.d.ts +29 -0
- package/dist/config/config-store.js +103 -0
- package/dist/config/file-source.d.ts +40 -0
- package/dist/config/file-source.js +78 -0
- package/dist/config/flags.d.ts +13 -0
- package/dist/config/flags.js +25 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +10 -0
- package/dist/config/merge.d.ts +5 -0
- package/dist/config/merge.js +57 -0
- package/dist/config/model-catalog.d.ts +17 -0
- package/dist/config/model-catalog.js +37 -0
- package/dist/config/paths.d.ts +31 -0
- package/dist/config/paths.js +28 -0
- package/dist/config/provider-manager.d.ts +57 -0
- package/dist/config/provider-manager.js +344 -0
- package/dist/config/resolver.d.ts +40 -0
- package/dist/config/resolver.js +52 -0
- package/dist/config/schema.d.ts +389 -0
- package/dist/config/schema.js +132 -0
- package/dist/events/events.d.ts +348 -0
- package/dist/events/events.js +146 -0
- package/dist/events/index.d.ts +10 -0
- package/dist/events/index.js +5 -0
- package/dist/events/projection.d.ts +207 -0
- package/dist/events/projection.js +438 -0
- package/dist/events/publisher.d.ts +48 -0
- package/dist/events/publisher.js +404 -0
- package/dist/events/redacting-sink.d.ts +11 -0
- package/dist/events/redacting-sink.js +31 -0
- package/dist/home.d.ts +16 -0
- package/dist/home.js +20 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/internal.d.ts +33 -0
- package/dist/internal.js +29 -0
- package/dist/llm/auth.d.ts +22 -0
- package/dist/llm/auth.js +112 -0
- package/dist/llm/capability.d.ts +13 -0
- package/dist/llm/capability.js +45 -0
- package/dist/llm/define-model.d.ts +110 -0
- package/dist/llm/define-model.js +252 -0
- package/dist/llm/errors.d.ts +33 -0
- package/dist/llm/errors.js +154 -0
- package/dist/llm/index.d.ts +14 -0
- package/dist/llm/index.js +8 -0
- package/dist/llm/model.d.ts +43 -0
- package/dist/llm/model.js +9 -0
- package/dist/llm/retry.d.ts +35 -0
- package/dist/llm/retry.js +160 -0
- package/dist/llm/runtime.d.ts +25 -0
- package/dist/llm/runtime.js +38 -0
- package/dist/logging/diagnostics.d.ts +21 -0
- package/dist/logging/diagnostics.js +46 -0
- package/dist/logging/index.d.ts +11 -0
- package/dist/logging/index.js +7 -0
- package/dist/logging/logger.d.ts +25 -0
- package/dist/logging/logger.js +54 -0
- package/dist/logging/paths.d.ts +11 -0
- package/dist/logging/paths.js +20 -0
- package/dist/logging/policy.d.ts +5 -0
- package/dist/logging/policy.js +19 -0
- package/dist/logging/redact.d.ts +10 -0
- package/dist/logging/redact.js +95 -0
- package/dist/logging/sinks.d.ts +67 -0
- package/dist/logging/sinks.js +117 -0
- package/dist/loop/context.d.ts +69 -0
- package/dist/loop/context.js +129 -0
- package/dist/loop/errors.d.ts +8 -0
- package/dist/loop/errors.js +27 -0
- package/dist/loop/events.d.ts +14 -0
- package/dist/loop/events.js +2 -0
- package/dist/loop/index.d.ts +10 -0
- package/dist/loop/index.js +7 -0
- package/dist/loop/interruption.d.ts +118 -0
- package/dist/loop/interruption.js +191 -0
- package/dist/loop/run-turn.d.ts +54 -0
- package/dist/loop/run-turn.js +203 -0
- package/dist/loop/scheduler.d.ts +18 -0
- package/dist/loop/scheduler.js +71 -0
- package/dist/loop/steer.d.ts +122 -0
- package/dist/loop/steer.js +209 -0
- package/dist/loop/tool-call.d.ts +41 -0
- package/dist/loop/tool-call.js +326 -0
- package/dist/loop/turn-step.d.ts +57 -0
- package/dist/loop/turn-step.js +298 -0
- package/dist/loop/types.d.ts +217 -0
- package/dist/loop/types.js +2 -0
- package/dist/loop/usage.d.ts +6 -0
- package/dist/loop/usage.js +44 -0
- package/dist/mcp/auth-tool.d.ts +12 -0
- package/dist/mcp/auth-tool.js +92 -0
- package/dist/mcp/capability.d.ts +7 -0
- package/dist/mcp/capability.js +91 -0
- package/dist/mcp/config-loader.d.ts +28 -0
- package/dist/mcp/config-loader.js +115 -0
- package/dist/mcp/filter.d.ts +18 -0
- package/dist/mcp/filter.js +35 -0
- package/dist/mcp/index.d.ts +23 -0
- package/dist/mcp/index.js +13 -0
- package/dist/mcp/manager.d.ts +51 -0
- package/dist/mcp/manager.js +412 -0
- package/dist/mcp/mock-transport.d.ts +40 -0
- package/dist/mcp/mock-transport.js +68 -0
- package/dist/mcp/oauth/callback-server.d.ts +14 -0
- package/dist/mcp/oauth/callback-server.js +122 -0
- package/dist/mcp/oauth/index.d.ts +9 -0
- package/dist/mcp/oauth/index.js +5 -0
- package/dist/mcp/oauth/provider.d.ts +39 -0
- package/dist/mcp/oauth/provider.js +121 -0
- package/dist/mcp/oauth/service.d.ts +34 -0
- package/dist/mcp/oauth/service.js +130 -0
- package/dist/mcp/oauth/store.d.ts +40 -0
- package/dist/mcp/oauth/store.js +134 -0
- package/dist/mcp/output.d.ts +12 -0
- package/dist/mcp/output.js +110 -0
- package/dist/mcp/provider.d.ts +7 -0
- package/dist/mcp/provider.js +56 -0
- package/dist/mcp/sdk-transport.d.ts +25 -0
- package/dist/mcp/sdk-transport.js +228 -0
- package/dist/mcp/server.d.ts +77 -0
- package/dist/mcp/server.js +120 -0
- package/dist/mcp/tool-naming.d.ts +4 -0
- package/dist/mcp/tool-naming.js +26 -0
- package/dist/mcp/types.d.ts +75 -0
- package/dist/mcp/types.js +2 -0
- package/dist/net/index.d.ts +3 -0
- package/dist/net/index.js +2 -0
- package/dist/net/proxy.d.ts +16 -0
- package/dist/net/proxy.js +42 -0
- package/dist/permission/auto-approver/index.d.ts +3 -0
- package/dist/permission/auto-approver/index.js +3 -0
- package/dist/permission/auto-approver/llm-auto-approver.d.ts +53 -0
- package/dist/permission/auto-approver/llm-auto-approver.js +122 -0
- package/dist/permission/auto-approver/prompts-data.d.ts +9 -0
- package/dist/permission/auto-approver/prompts-data.js +155 -0
- package/dist/permission/auto-approver/prompts.d.ts +18 -0
- package/dist/permission/auto-approver/prompts.js +40 -0
- package/dist/permission/auto-approver/transcript.d.ts +22 -0
- package/dist/permission/auto-approver/transcript.js +75 -0
- package/dist/permission/auto-approver/xml.d.ts +5 -0
- package/dist/permission/auto-approver/xml.js +25 -0
- package/dist/permission/index.d.ts +7 -0
- package/dist/permission/index.js +5 -0
- package/dist/permission/manager.d.ts +74 -0
- package/dist/permission/manager.js +162 -0
- package/dist/permission/matches-rule.d.ts +27 -0
- package/dist/permission/matches-rule.js +54 -0
- package/dist/permission/policies.d.ts +14 -0
- package/dist/permission/policies.js +233 -0
- package/dist/permission/types.d.ts +84 -0
- package/dist/permission/types.js +2 -0
- package/dist/plugins/archive.d.ts +3 -0
- package/dist/plugins/archive.js +58 -0
- package/dist/plugins/github-resolver.d.ts +13 -0
- package/dist/plugins/github-resolver.js +20 -0
- package/dist/plugins/hooks.d.ts +28 -0
- package/dist/plugins/hooks.js +296 -0
- package/dist/plugins/index.d.ts +23 -0
- package/dist/plugins/index.js +23 -0
- package/dist/plugins/injector.d.ts +11 -0
- package/dist/plugins/injector.js +32 -0
- package/dist/plugins/manager.d.ts +37 -0
- package/dist/plugins/manager.js +330 -0
- package/dist/plugins/manifest.d.ts +9 -0
- package/dist/plugins/manifest.js +234 -0
- package/dist/plugins/marketplace.d.ts +85 -0
- package/dist/plugins/marketplace.js +205 -0
- package/dist/plugins/source.d.ts +23 -0
- package/dist/plugins/source.js +87 -0
- package/dist/plugins/store.d.ts +20 -0
- package/dist/plugins/store.js +30 -0
- package/dist/plugins/types.d.ts +118 -0
- package/dist/plugins/types.js +5 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +2 -0
- package/dist/protocol/tool-schema.d.ts +6 -0
- package/dist/protocol/tool-schema.js +2 -0
- package/dist/store/blob-store.d.ts +45 -0
- package/dist/store/blob-store.js +120 -0
- package/dist/store/catalog-store.d.ts +32 -0
- package/dist/store/catalog-store.js +73 -0
- package/dist/store/disk-store.d.ts +58 -0
- package/dist/store/disk-store.js +369 -0
- package/dist/store/index.d.ts +23 -0
- package/dist/store/index.js +15 -0
- package/dist/store/lock.d.ts +86 -0
- package/dist/store/lock.js +104 -0
- package/dist/store/log-store.d.ts +89 -0
- package/dist/store/log-store.js +296 -0
- package/dist/store/migrate.d.ts +26 -0
- package/dist/store/migrate.js +32 -0
- package/dist/store/origin.d.ts +89 -0
- package/dist/store/origin.js +16 -0
- package/dist/store/pg.d.ts +90 -0
- package/dist/store/pg.js +344 -0
- package/dist/store/redacting-store.d.ts +21 -0
- package/dist/store/redacting-store.js +46 -0
- package/dist/store/redis.d.ts +89 -0
- package/dist/store/redis.js +370 -0
- package/dist/store/repository.d.ts +150 -0
- package/dist/store/repository.js +508 -0
- package/dist/store/session-catalog.d.ts +32 -0
- package/dist/store/session-catalog.js +117 -0
- package/dist/store/storage.d.ts +27 -0
- package/dist/store/storage.js +54 -0
- package/dist/store/store.d.ts +262 -0
- package/dist/store/store.js +129 -0
- package/dist/store/workdir-key.d.ts +4 -0
- package/dist/store/workdir-key.js +28 -0
- package/dist/tool/access.d.ts +37 -0
- package/dist/tool/access.js +79 -0
- package/dist/tool/ask.d.ts +22 -0
- package/dist/tool/ask.js +38 -0
- package/dist/tool/background.d.ts +109 -0
- package/dist/tool/background.js +39 -0
- package/dist/tool/builtin/ask-user-question.d.ts +2 -0
- package/dist/tool/builtin/ask-user-question.js +175 -0
- package/dist/tool/builtin/bash.d.ts +2 -0
- package/dist/tool/builtin/bash.js +407 -0
- package/dist/tool/builtin/edit.d.ts +2 -0
- package/dist/tool/builtin/edit.js +202 -0
- package/dist/tool/builtin/glob.d.ts +3 -0
- package/dist/tool/builtin/glob.js +260 -0
- package/dist/tool/builtin/grep.d.ts +2 -0
- package/dist/tool/builtin/grep.js +574 -0
- package/dist/tool/builtin/line-endings.d.ts +10 -0
- package/dist/tool/builtin/line-endings.js +41 -0
- package/dist/tool/builtin/read.d.ts +28 -0
- package/dist/tool/builtin/read.js +498 -0
- package/dist/tool/builtin/write.d.ts +2 -0
- package/dist/tool/builtin/write.js +179 -0
- package/dist/tool/define.d.ts +46 -0
- package/dist/tool/define.js +45 -0
- package/dist/tool/file-freshness.d.ts +81 -0
- package/dist/tool/file-freshness.js +67 -0
- package/dist/tool/filesystem-tools.d.ts +16 -0
- package/dist/tool/filesystem-tools.js +19 -0
- package/dist/tool/git-context.d.ts +20 -0
- package/dist/tool/git-context.js +114 -0
- package/dist/tool/index.d.ts +37 -0
- package/dist/tool/index.js +34 -0
- package/dist/tool/machine-base.d.ts +138 -0
- package/dist/tool/machine-base.js +388 -0
- package/dist/tool/machine-local.d.ts +35 -0
- package/dist/tool/machine-local.js +316 -0
- package/dist/tool/machine-null.d.ts +36 -0
- package/dist/tool/machine-null.js +64 -0
- package/dist/tool/machine-ssh.d.ts +86 -0
- package/dist/tool/machine-ssh.js +576 -0
- package/dist/tool/machine.d.ts +333 -0
- package/dist/tool/machine.js +15 -0
- package/dist/tool/policies/path-access.d.ts +48 -0
- package/dist/tool/policies/path-access.js +186 -0
- package/dist/tool/policies/sensitive.d.ts +3 -0
- package/dist/tool/policies/sensitive.js +60 -0
- package/dist/tool/questions.d.ts +40 -0
- package/dist/tool/questions.js +8 -0
- package/dist/tool/search/activation.d.ts +13 -0
- package/dist/tool/search/activation.js +31 -0
- package/dist/tool/search/deferral.d.ts +37 -0
- package/dist/tool/search/deferral.js +128 -0
- package/dist/tool/search/search-tool.d.ts +9 -0
- package/dist/tool/search/search-tool.js +62 -0
- package/dist/tool/shell-env.d.ts +9 -0
- package/dist/tool/shell-env.js +34 -0
- package/dist/tool/support/bash-destructive.d.ts +24 -0
- package/dist/tool/support/bash-destructive.js +63 -0
- package/dist/tool/support/bash-paths.d.ts +7 -0
- package/dist/tool/support/bash-paths.js +247 -0
- package/dist/tool/support/bash-read-only.d.ts +8 -0
- package/dist/tool/support/bash-read-only.js +165 -0
- package/dist/tool/support/bash-rule-match.d.ts +20 -0
- package/dist/tool/support/bash-rule-match.js +191 -0
- package/dist/tool/support/file-type.d.ts +10 -0
- package/dist/tool/support/file-type.js +149 -0
- package/dist/tool/support/git-worktree.d.ts +10 -0
- package/dist/tool/support/git-worktree.js +63 -0
- package/dist/tool/support/image-compress.d.ts +69 -0
- package/dist/tool/support/image-compress.js +265 -0
- package/dist/tool/support/machine-ops.d.ts +34 -0
- package/dist/tool/support/machine-ops.js +34 -0
- package/dist/tool/support/path-glob-match.d.ts +12 -0
- package/dist/tool/support/path-glob-match.js +84 -0
- package/dist/tool/support/result-builder.d.ts +27 -0
- package/dist/tool/support/result-builder.js +108 -0
- package/dist/tool/support/rg-locator.d.ts +20 -0
- package/dist/tool/support/rg-locator.js +42 -0
- package/dist/tool/support/ripgrep-run.d.ts +65 -0
- package/dist/tool/support/ripgrep-run.js +40 -0
- package/dist/tool/support/rule-match.d.ts +6 -0
- package/dist/tool/support/rule-match.js +23 -0
- package/dist/tool/support/tool-path.d.ts +8 -0
- package/dist/tool/support/tool-path.js +28 -0
- package/dist/tool/support/workspace.d.ts +5 -0
- package/dist/tool/support/workspace.js +2 -0
- package/dist/tool/types.d.ts +131 -0
- package/dist/tool/types.js +2 -0
- package/dist/tool/web/fetch-url.d.ts +4 -0
- package/dist/tool/web/fetch-url.js +61 -0
- package/dist/tool/web/index.d.ts +11 -0
- package/dist/tool/web/index.js +7 -0
- package/dist/tool/web/providers/direct-fetch.d.ts +33 -0
- package/dist/tool/web/providers/direct-fetch.js +198 -0
- package/dist/tool/web/providers/firecrawl.d.ts +16 -0
- package/dist/tool/web/providers/firecrawl.js +59 -0
- package/dist/tool/web/providers/tavily.d.ts +14 -0
- package/dist/tool/web/providers/tavily.js +43 -0
- package/dist/tool/web/types.d.ts +41 -0
- package/dist/tool/web/types.js +7 -0
- package/dist/tool/web/web-search.d.ts +4 -0
- package/dist/tool/web/web-search.js +68 -0
- package/dist/tool/workspace-spec.d.ts +74 -0
- package/dist/tool/workspace-spec.js +177 -0
- package/dist/tracing/bridge.d.ts +7 -0
- package/dist/tracing/bridge.js +171 -0
- package/dist/tracing/index.d.ts +9 -0
- package/dist/tracing/index.js +5 -0
- package/dist/tracing/otel.d.ts +38 -0
- package/dist/tracing/otel.js +221 -0
- package/dist/tracing/processor.d.ts +47 -0
- package/dist/tracing/processor.js +94 -0
- package/dist/tracing/spans.d.ts +94 -0
- package/dist/tracing/spans.js +56 -0
- package/dist/ui/ai-sdk.d.ts +114 -0
- package/dist/ui/ai-sdk.js +175 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/package.json +101 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { isAbsolute, join, parse } from "pathe";
|
|
2
|
+
import picomatch from "picomatch";
|
|
3
|
+
import { canonicalizePath } from "../policies/path-access.js";
|
|
4
|
+
export function globMatch(value, pattern, options) {
|
|
5
|
+
if (picomatch.isMatch(value, pattern, options))
|
|
6
|
+
return true;
|
|
7
|
+
const normalizedValue = stripLeadingDotSlash(value);
|
|
8
|
+
const normalizedPattern = stripLeadingDotSlash(pattern);
|
|
9
|
+
if (normalizedValue === value && normalizedPattern === pattern)
|
|
10
|
+
return false;
|
|
11
|
+
return picomatch.isMatch(normalizedValue, normalizedPattern, options);
|
|
12
|
+
}
|
|
13
|
+
function stripLeadingDotSlash(value) {
|
|
14
|
+
return value.startsWith("./") ? value.slice(2) : value;
|
|
15
|
+
}
|
|
16
|
+
export function pathGlobMatch(value, pattern, pathOptions) {
|
|
17
|
+
const semantics = pathMatchSemantics(value, pattern, pathOptions);
|
|
18
|
+
const nocase = pathOptions?.caseInsensitivePaths ?? true;
|
|
19
|
+
if (globMatch(value, pattern, { nocase }))
|
|
20
|
+
return true;
|
|
21
|
+
for (const valueVariant of pathVariants(value, semantics, pathOptions)) {
|
|
22
|
+
for (const patternVariant of pathVariants(pattern, semantics, pathOptions)) {
|
|
23
|
+
if (globMatch(valueVariant, patternVariant, { nocase }))
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function pathVariants(value, semantics, pathOptions) {
|
|
30
|
+
const variants = new Set();
|
|
31
|
+
addPathVariant(variants, value, semantics.pathClass);
|
|
32
|
+
addPathVariant(variants, stripLeadingDotPath(value, semantics.pathClass), semantics.pathClass);
|
|
33
|
+
const canonical = canonicalizePathPattern(value, semantics, pathOptions);
|
|
34
|
+
if (canonical !== undefined)
|
|
35
|
+
addPathVariant(variants, canonical, semantics.pathClass);
|
|
36
|
+
return Array.from(variants);
|
|
37
|
+
}
|
|
38
|
+
function canonicalizePathPattern(value, semantics, pathOptions) {
|
|
39
|
+
const expanded = expandUserPath(value, semantics.pathClass, pathOptions?.homeDir);
|
|
40
|
+
const cwd = pathOptions?.cwd ?? defaultCwdForPath(expanded);
|
|
41
|
+
if (cwd === undefined)
|
|
42
|
+
return undefined;
|
|
43
|
+
try {
|
|
44
|
+
return canonicalizePath(expanded, cwd, semantics.pathClass);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function expandUserPath(value, pathClass, homeDir) {
|
|
51
|
+
if (homeDir === undefined)
|
|
52
|
+
return value;
|
|
53
|
+
if (value === "~")
|
|
54
|
+
return homeDir;
|
|
55
|
+
if (value.startsWith("~/") || (pathClass === "win32" && value.startsWith("~\\"))) {
|
|
56
|
+
return join(homeDir, value.slice(2));
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
function defaultCwdForPath(value) {
|
|
61
|
+
if (!isAbsolute(value))
|
|
62
|
+
return undefined;
|
|
63
|
+
return parse(value).root;
|
|
64
|
+
}
|
|
65
|
+
function pathMatchSemantics(value, pattern, pathOptions) {
|
|
66
|
+
const pathClass = pathOptions?.pathClass ??
|
|
67
|
+
([value, pattern].some((candidate) => /^[A-Za-z]:(?:[\\/]|$)/.test(candidate) || candidate.startsWith("\\\\") || candidate.includes("\\"))
|
|
68
|
+
? "win32"
|
|
69
|
+
: "posix");
|
|
70
|
+
return { pathClass };
|
|
71
|
+
}
|
|
72
|
+
function addPathVariant(variants, value, pathClass) {
|
|
73
|
+
variants.add(value);
|
|
74
|
+
if (pathClass === "win32")
|
|
75
|
+
variants.add(value.replaceAll("\\", "/"));
|
|
76
|
+
}
|
|
77
|
+
function stripLeadingDotPath(value, pathClass) {
|
|
78
|
+
if (value.startsWith("./"))
|
|
79
|
+
return value.slice(2);
|
|
80
|
+
if (pathClass === "win32" && value.startsWith(".\\"))
|
|
81
|
+
return value.slice(2);
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=path-glob-match.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ToolResult } from "../types.ts";
|
|
2
|
+
export interface ToolResultBuilderOptions {
|
|
3
|
+
readonly maxChars?: number;
|
|
4
|
+
readonly maxLineLength?: number | null;
|
|
5
|
+
}
|
|
6
|
+
export declare class ToolResultBuilder {
|
|
7
|
+
private readonly maxChars;
|
|
8
|
+
private readonly maxLineLength;
|
|
9
|
+
private readonly buffer;
|
|
10
|
+
private nCharsValue;
|
|
11
|
+
private truncationHappened;
|
|
12
|
+
constructor(options?: ToolResultBuilderOptions);
|
|
13
|
+
get nChars(): number;
|
|
14
|
+
/** Whether anything was dropped. Lets a caller that HAS the full output somewhere — a
|
|
15
|
+
* command whose stdout was also redirected to a log file — say where, instead of leaving
|
|
16
|
+
* the model with a truncation notice and no way to see the rest. */
|
|
17
|
+
get truncated(): boolean;
|
|
18
|
+
write(text: string): number;
|
|
19
|
+
ok(message?: string, options?: {
|
|
20
|
+
readonly brief?: string;
|
|
21
|
+
}): ToolResult;
|
|
22
|
+
error(message: string, options?: {
|
|
23
|
+
readonly brief?: string;
|
|
24
|
+
}): ToolResult;
|
|
25
|
+
private result;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=result-builder.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const DEFAULT_MAX_CHARS = 50_000;
|
|
2
|
+
const DEFAULT_MAX_LINE_LENGTH = 2000;
|
|
3
|
+
const TRUNCATION_MARKER = "[...truncated]";
|
|
4
|
+
const TRUNCATION_MESSAGE = "Output is truncated to fit in the message.";
|
|
5
|
+
export class ToolResultBuilder {
|
|
6
|
+
maxChars;
|
|
7
|
+
maxLineLength;
|
|
8
|
+
buffer = [];
|
|
9
|
+
nCharsValue = 0;
|
|
10
|
+
truncationHappened = false;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.maxChars = options.maxChars ?? DEFAULT_MAX_CHARS;
|
|
13
|
+
this.maxLineLength = options.maxLineLength === undefined ? DEFAULT_MAX_LINE_LENGTH : options.maxLineLength;
|
|
14
|
+
if (this.maxLineLength !== null && this.maxLineLength <= TRUNCATION_MARKER.length) {
|
|
15
|
+
throw new Error("maxLineLength must be greater than the truncation marker length.");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
get nChars() {
|
|
19
|
+
return this.nCharsValue;
|
|
20
|
+
}
|
|
21
|
+
/** Whether anything was dropped. Lets a caller that HAS the full output somewhere — a
|
|
22
|
+
* command whose stdout was also redirected to a log file — say where, instead of leaving
|
|
23
|
+
* the model with a truncation notice and no way to see the rest. */
|
|
24
|
+
get truncated() {
|
|
25
|
+
return this.truncationHappened;
|
|
26
|
+
}
|
|
27
|
+
write(text) {
|
|
28
|
+
if (this.nCharsValue >= this.maxChars) {
|
|
29
|
+
if (text.length > 0 && !this.truncationHappened) {
|
|
30
|
+
this.buffer.push(TRUNCATION_MARKER);
|
|
31
|
+
this.nCharsValue += TRUNCATION_MARKER.length;
|
|
32
|
+
this.truncationHappened = true;
|
|
33
|
+
}
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
const lines = text.match(/[^\r\n]*(?:\r\n|[\n\r])|[^\r\n]+/g) ?? [];
|
|
37
|
+
if (lines.length === 0)
|
|
38
|
+
return 0;
|
|
39
|
+
let charsWritten = 0;
|
|
40
|
+
for (const originalLine of lines) {
|
|
41
|
+
if (this.nCharsValue >= this.maxChars) {
|
|
42
|
+
if (!this.truncationHappened) {
|
|
43
|
+
this.buffer.push(TRUNCATION_MARKER);
|
|
44
|
+
this.nCharsValue += TRUNCATION_MARKER.length;
|
|
45
|
+
this.truncationHappened = true;
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
const remainingChars = this.maxChars - this.nCharsValue;
|
|
50
|
+
const limit = this.maxLineLength === null ? remainingChars : Math.min(remainingChars, this.maxLineLength);
|
|
51
|
+
let line = originalLine;
|
|
52
|
+
if (line.length > limit) {
|
|
53
|
+
const lineBreak = /[\r\n]+$/.exec(line)?.[0] ?? "";
|
|
54
|
+
const suffix = TRUNCATION_MARKER + lineBreak;
|
|
55
|
+
const effectiveMaxLength = Math.max(limit, suffix.length);
|
|
56
|
+
line = line.slice(0, effectiveMaxLength - suffix.length) + suffix;
|
|
57
|
+
}
|
|
58
|
+
if (line !== originalLine)
|
|
59
|
+
this.truncationHappened = true;
|
|
60
|
+
this.buffer.push(line);
|
|
61
|
+
charsWritten += line.length;
|
|
62
|
+
this.nCharsValue += line.length;
|
|
63
|
+
}
|
|
64
|
+
return charsWritten;
|
|
65
|
+
}
|
|
66
|
+
ok(message = "", options = {}) {
|
|
67
|
+
let finalMessage = message;
|
|
68
|
+
if (finalMessage.length > 0 && !finalMessage.endsWith("."))
|
|
69
|
+
finalMessage += ".";
|
|
70
|
+
if (this.truncationHappened) {
|
|
71
|
+
finalMessage = finalMessage.length === 0 ? TRUNCATION_MESSAGE : `${finalMessage} ${TRUNCATION_MESSAGE}`;
|
|
72
|
+
}
|
|
73
|
+
const output = this.buffer.join("");
|
|
74
|
+
const shouldAppendMessage = finalMessage.length > 0 && (this.truncationHappened || output.length === 0);
|
|
75
|
+
const text = shouldAppendMessage
|
|
76
|
+
? output.length === 0
|
|
77
|
+
? finalMessage
|
|
78
|
+
: output.endsWith("\n")
|
|
79
|
+
? `${output}${finalMessage}`
|
|
80
|
+
: `${output}\n${finalMessage}`
|
|
81
|
+
: output;
|
|
82
|
+
return this.result(text, false, options.brief);
|
|
83
|
+
}
|
|
84
|
+
error(message, options = {}) {
|
|
85
|
+
const finalMessage = this.truncationHappened
|
|
86
|
+
? message.length === 0
|
|
87
|
+
? TRUNCATION_MESSAGE
|
|
88
|
+
: `${message} ${TRUNCATION_MESSAGE}`
|
|
89
|
+
: message;
|
|
90
|
+
const output = this.buffer.join("");
|
|
91
|
+
const text = finalMessage.length === 0
|
|
92
|
+
? output
|
|
93
|
+
: output.length === 0
|
|
94
|
+
? finalMessage
|
|
95
|
+
: output.endsWith("\n")
|
|
96
|
+
? `${output}${finalMessage}`
|
|
97
|
+
: `${output}\n${finalMessage}`;
|
|
98
|
+
return this.result(text, true, options.brief);
|
|
99
|
+
}
|
|
100
|
+
result(text, isError, brief) {
|
|
101
|
+
return {
|
|
102
|
+
content: [{ type: "text", text }],
|
|
103
|
+
isError,
|
|
104
|
+
details: { brief, truncated: this.truncationHappened },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=result-builder.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Machine } from "../machine.ts";
|
|
2
|
+
export interface RgResolution {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function ensureRgPath(_options?: {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}): Promise<RgResolution>;
|
|
8
|
+
/**
|
|
9
|
+
* Decide how to invoke ripgrep on a given machine.
|
|
10
|
+
* - Local machine → the absolute path found on the orchestrator's PATH (the
|
|
11
|
+
* process runs here, so the resolved path is correct and avoids PATH ambiguity).
|
|
12
|
+
* - Remote machines (ssh, sandbox) → the bare command name `rg`, resolved against
|
|
13
|
+
* the REMOTE host's PATH when exec'd. The local absolute path would be meaningless
|
|
14
|
+
* there, so we never probe it for non-local machines.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveRgCommand(machine: Pick<Machine, "name">, options?: {
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}): Promise<string>;
|
|
19
|
+
export declare function rgUnavailableMessage(cause: unknown): string;
|
|
20
|
+
//# sourceMappingURL=rg-locator.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { delimiter, join } from "node:path";
|
|
3
|
+
function findOnPath(name) {
|
|
4
|
+
const exts = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
5
|
+
for (const dir of (process.env["PATH"] ?? "").split(delimiter)) {
|
|
6
|
+
if (dir === "")
|
|
7
|
+
continue;
|
|
8
|
+
for (const ext of exts) {
|
|
9
|
+
const candidate = join(dir, name + ext);
|
|
10
|
+
if (existsSync(candidate))
|
|
11
|
+
return candidate;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
export function ensureRgPath(_options = {}) {
|
|
17
|
+
const found = findOnPath("rg");
|
|
18
|
+
if (found === undefined) {
|
|
19
|
+
return Promise.reject(new Error("ripgrep (rg) not found on PATH"));
|
|
20
|
+
}
|
|
21
|
+
return Promise.resolve({ path: found });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decide how to invoke ripgrep on a given machine.
|
|
25
|
+
* - Local machine → the absolute path found on the orchestrator's PATH (the
|
|
26
|
+
* process runs here, so the resolved path is correct and avoids PATH ambiguity).
|
|
27
|
+
* - Remote machines (ssh, sandbox) → the bare command name `rg`, resolved against
|
|
28
|
+
* the REMOTE host's PATH when exec'd. The local absolute path would be meaningless
|
|
29
|
+
* there, so we never probe it for non-local machines.
|
|
30
|
+
*/
|
|
31
|
+
export async function resolveRgCommand(machine, options = {}) {
|
|
32
|
+
if (machine.name === "local")
|
|
33
|
+
return (await ensureRgPath(options)).path;
|
|
34
|
+
return "rg";
|
|
35
|
+
}
|
|
36
|
+
export function rgUnavailableMessage(cause) {
|
|
37
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
38
|
+
return ("Grep requires ripgrep (rg), which could not be located. Install it " +
|
|
39
|
+
"(e.g. `brew install ripgrep`, `apt install ripgrep`, `choco install ripgrep`) and ensure " +
|
|
40
|
+
`it is on PATH. (${detail})`);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=rg-locator.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Machine } from "../machine.ts";
|
|
2
|
+
/**
|
|
3
|
+
* One ripgrep invocation, run on the given machine (local / ssh / sandbox) through
|
|
4
|
+
* `machine.run`. The Grep and Glob tools share this so their handling of a search that
|
|
5
|
+
* runs too long or prints too much stays identical.
|
|
6
|
+
*
|
|
7
|
+
* Timeout, output capping and cancellation are stated as INTENT and fulfilled by the
|
|
8
|
+
* backend natively — local spawn + signals, a vendor's `timeoutMs` + `kill(pid)`. This
|
|
9
|
+
* used to be assembled here out of a raw process handle's POSIX machinery, which only
|
|
10
|
+
* local backends implement honestly: on a sandbox the SIGTERM→SIGKILL escalation went
|
|
11
|
+
* nowhere and the cap only trimmed output that had already been transferred. Backends
|
|
12
|
+
* that still cannot stop a command now say so via `terminated`, instead of the tool
|
|
13
|
+
* assuming it worked.
|
|
14
|
+
*
|
|
15
|
+
* EAGAIN retry policy is left to the caller (each tool decides whether to re-run
|
|
16
|
+
* single-threaded), so this stays a single-shot primitive.
|
|
17
|
+
*/
|
|
18
|
+
export interface RipgrepRunResult {
|
|
19
|
+
/**
|
|
20
|
+
* `undefined` when the run has no meaningful exit status — it was killed on timeout, or
|
|
21
|
+
* the backend could not confirm completion. Callers must not read that as success.
|
|
22
|
+
*/
|
|
23
|
+
readonly exitCode: number | undefined;
|
|
24
|
+
readonly stdoutText: string;
|
|
25
|
+
readonly stderrText: string;
|
|
26
|
+
/** Output hit the cap and was cut — the last record may be severed. */
|
|
27
|
+
readonly truncated: boolean;
|
|
28
|
+
readonly timedOut: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether ripgrep was actually stopped when the timeout demanded it. `false` means the
|
|
31
|
+
* backend could only walk away and the search may still be burning sandbox CPU — worth
|
|
32
|
+
* saying out loud rather than hiding.
|
|
33
|
+
*/
|
|
34
|
+
readonly terminated: boolean;
|
|
35
|
+
}
|
|
36
|
+
export type RipgrepRunOutcome = {
|
|
37
|
+
readonly kind: "result";
|
|
38
|
+
readonly result: RipgrepRunResult;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: "aborted";
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "exec-error";
|
|
43
|
+
readonly error: unknown;
|
|
44
|
+
readonly isEnoent: boolean;
|
|
45
|
+
};
|
|
46
|
+
export interface RipgrepRunOptions {
|
|
47
|
+
readonly timeoutMs: number;
|
|
48
|
+
readonly maxOutputBytes: number;
|
|
49
|
+
/**
|
|
50
|
+
* Working directory for the ripgrep process. Callers that pass a relative search target
|
|
51
|
+
* need this, and Glob needs the relative target: `--glob` is matched against the paths
|
|
52
|
+
* ripgrep PRINTS, so an absolute target makes every glob containing a `/` (`src/**\/*.ts`)
|
|
53
|
+
* anchor against `/abs/root/src/...` and match nothing.
|
|
54
|
+
*/
|
|
55
|
+
readonly cwd?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Wording for a timeout, honest about whether the backend could actually stop ripgrep.
|
|
59
|
+
* A backend that can only walk away leaves the search running on the remote machine —
|
|
60
|
+
* the model should hear that instead of being told the search "timed out" as if it were
|
|
61
|
+
* cleanly cancelled. Phrasing only: no caller branches on it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function stillRunningNote(terminated: boolean): string;
|
|
64
|
+
export declare function runRipgrep(machine: Machine, rgArgs: readonly string[], signal: AbortSignal, options: RipgrepRunOptions): Promise<RipgrepRunOutcome>;
|
|
65
|
+
//# sourceMappingURL=ripgrep-run.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wording for a timeout, honest about whether the backend could actually stop ripgrep.
|
|
3
|
+
* A backend that can only walk away leaves the search running on the remote machine —
|
|
4
|
+
* the model should hear that instead of being told the search "timed out" as if it were
|
|
5
|
+
* cleanly cancelled. Phrasing only: no caller branches on it.
|
|
6
|
+
*/
|
|
7
|
+
export function stillRunningNote(terminated) {
|
|
8
|
+
return terminated ? "" : " (the search could not be stopped and may still be running)";
|
|
9
|
+
}
|
|
10
|
+
export async function runRipgrep(machine, rgArgs, signal, options) {
|
|
11
|
+
if (signal.aborted)
|
|
12
|
+
return { kind: "aborted" };
|
|
13
|
+
let result;
|
|
14
|
+
try {
|
|
15
|
+
result = await machine.run(rgArgs, {
|
|
16
|
+
timeoutMs: options.timeoutMs,
|
|
17
|
+
maxOutputBytes: options.maxOutputBytes,
|
|
18
|
+
...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
|
|
19
|
+
signal,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const isEnoent = error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
24
|
+
return { kind: "exec-error", error, isEnoent };
|
|
25
|
+
}
|
|
26
|
+
if (signal.aborted)
|
|
27
|
+
return { kind: "aborted" };
|
|
28
|
+
return {
|
|
29
|
+
kind: "result",
|
|
30
|
+
result: {
|
|
31
|
+
exitCode: result.exitCode,
|
|
32
|
+
stdoutText: result.stdout,
|
|
33
|
+
stderrText: result.stderr,
|
|
34
|
+
truncated: result.truncated,
|
|
35
|
+
timedOut: result.timedOut,
|
|
36
|
+
terminated: result.terminated,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ripgrep-run.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PermissionPathMatchOptions } from "./path-glob-match.ts";
|
|
2
|
+
export declare function literalRulePattern(toolName: string, subject: string): string;
|
|
3
|
+
export declare function escapeRuleSubjectLiteral(subject: string): string;
|
|
4
|
+
export declare function matchesGlobRuleSubject(ruleArgs: string, subject: string): boolean;
|
|
5
|
+
export declare function matchesPathRuleSubject(ruleArgs: string, subject: string, options?: PermissionPathMatchOptions): boolean;
|
|
6
|
+
//# sourceMappingURL=rule-match.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { globMatch, pathGlobMatch } from "./path-glob-match.js";
|
|
2
|
+
const GLOB_LITERAL_SPECIAL = /[\\*?[\]{}()!+@|]/g;
|
|
3
|
+
export function literalRulePattern(toolName, subject) {
|
|
4
|
+
return `${toolName}(${escapeRuleSubjectLiteral(subject)})`;
|
|
5
|
+
}
|
|
6
|
+
export function escapeRuleSubjectLiteral(subject) {
|
|
7
|
+
return subject.replace(GLOB_LITERAL_SPECIAL, "\\$&");
|
|
8
|
+
}
|
|
9
|
+
export function matchesGlobRuleSubject(ruleArgs, subject) {
|
|
10
|
+
return matchRuleSubjects(ruleArgs, [subject], (pattern, value) => globMatch(value, pattern));
|
|
11
|
+
}
|
|
12
|
+
export function matchesPathRuleSubject(ruleArgs, subject, options) {
|
|
13
|
+
return matchRuleSubjects(ruleArgs, [subject], (pattern, value) => pathGlobMatch(value, pattern, options));
|
|
14
|
+
}
|
|
15
|
+
function matchRuleSubjects(ruleArgs, subjects, matchesPositivePattern) {
|
|
16
|
+
if (ruleArgs.length === 0)
|
|
17
|
+
return true;
|
|
18
|
+
const negated = ruleArgs.startsWith("!");
|
|
19
|
+
const positivePattern = negated ? ruleArgs.slice(1) : ruleArgs;
|
|
20
|
+
const hit = subjects.some((subject) => matchesPositivePattern(positivePattern, subject));
|
|
21
|
+
return negated ? !hit : hit;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=rule-match.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PathAccessOperation, type WorkspaceAccessPolicy } from "../policies/path-access.ts";
|
|
2
|
+
import type { Machine } from "../machine.ts";
|
|
3
|
+
import type { ToolPlan } from "../types.ts";
|
|
4
|
+
export declare const SEARCH_ACCESS_POLICY: WorkspaceAccessPolicy;
|
|
5
|
+
export declare function resolveToolPath(path: string, machine: Machine, operation: PathAccessOperation, policy?: WorkspaceAccessPolicy): Promise<string>;
|
|
6
|
+
export declare function pathApproval(toolName: string, machine: Machine, path: string): Pick<ToolPlan, "approvalRule" | "matchesRule">;
|
|
7
|
+
export declare function globApproval(toolName: string, subject: string): Pick<ToolPlan, "approvalRule" | "matchesRule">;
|
|
8
|
+
//# sourceMappingURL=tool-path.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolvePathAccessPath } from "../policies/path-access.js";
|
|
2
|
+
import { literalRulePattern, matchesGlobRuleSubject, matchesPathRuleSubject } from "./rule-match.js";
|
|
3
|
+
export const SEARCH_ACCESS_POLICY = { guardMode: "absolute-outside-allowed", checkSensitive: false };
|
|
4
|
+
export function resolveToolPath(path, machine, operation, policy) {
|
|
5
|
+
return resolvePathAccessPath(path, {
|
|
6
|
+
machine,
|
|
7
|
+
workspace: { workspaceDir: machine.getcwd(), additionalDirs: machine.additionalDirs?.() ?? [] },
|
|
8
|
+
operation,
|
|
9
|
+
policy,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function pathApproval(toolName, machine, path) {
|
|
13
|
+
return {
|
|
14
|
+
approvalRule: literalRulePattern(toolName, path),
|
|
15
|
+
matchesRule: (ruleArgs) => matchesPathRuleSubject(ruleArgs, path, {
|
|
16
|
+
cwd: machine.getcwd(),
|
|
17
|
+
pathClass: machine.pathClass(),
|
|
18
|
+
homeDir: machine.gethome(),
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function globApproval(toolName, subject) {
|
|
23
|
+
return {
|
|
24
|
+
approvalRule: literalRulePattern(toolName, subject),
|
|
25
|
+
matchesRule: (ruleArgs) => matchesGlobRuleSubject(ruleArgs, subject),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=tool-path.js.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { ImageContent, TextContent, ToolSchema } from "../protocol/index.ts";
|
|
2
|
+
import type { ToolAccesses } from "./access.ts";
|
|
3
|
+
import type { Machine } from "./machine.ts";
|
|
4
|
+
import type { BackgroundSpawner } from "./background.ts";
|
|
5
|
+
import type { FileFreshnessLedger } from "./file-freshness.ts";
|
|
6
|
+
import type { QuestionResponder } from "./questions.ts";
|
|
7
|
+
export type { ToolAccesses, ToolResourceAccess, ToolFileAccess } from "./access.ts";
|
|
8
|
+
export interface ToolDisplay {
|
|
9
|
+
readonly title?: string;
|
|
10
|
+
readonly detail?: string;
|
|
11
|
+
readonly [key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolUpdate {
|
|
14
|
+
readonly kind: "stdout" | "stderr" | "progress" | "status" | "custom";
|
|
15
|
+
readonly text?: string;
|
|
16
|
+
readonly percent?: number;
|
|
17
|
+
readonly customKind?: string;
|
|
18
|
+
readonly customData?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export type ToolResultContent = (TextContent | ImageContent)[];
|
|
21
|
+
/**
|
|
22
|
+
* What a suspending tool wants from the user — the user-facing half of a durable
|
|
23
|
+
* mid-execution interrupt (`ToolRunContext.suspend`). Surfaced to the caller on the
|
|
24
|
+
* paused run's pending list; the private continuation `state` travels separately.
|
|
25
|
+
*/
|
|
26
|
+
export interface ToolInputRequest {
|
|
27
|
+
/** Discriminator for renderers, e.g. "question" | "oauth" | app-defined. */
|
|
28
|
+
readonly kind?: string;
|
|
29
|
+
/** Renderable payload (question items, an auth URL, a plan preview, …). */
|
|
30
|
+
readonly display?: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** Continuation of a previously suspended call, present on its re-run. */
|
|
33
|
+
export interface ToolResumeContext {
|
|
34
|
+
/** The state passed to `suspend` (a JSON snapshot), if any was given. */
|
|
35
|
+
readonly state?: unknown;
|
|
36
|
+
/** The caller's answer from `Runner.resume`. Always delivered: an unanswered
|
|
37
|
+
* suspended call is re-parked by the framework instead of being re-run. */
|
|
38
|
+
readonly answer: unknown;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolResult<Details = unknown> {
|
|
41
|
+
readonly content: ToolResultContent;
|
|
42
|
+
readonly details?: Details;
|
|
43
|
+
/**
|
|
44
|
+
* Tool definitions made available by this result. pi 0.81 uses these names
|
|
45
|
+
* as the transcript load point for native deferred-tool serialization.
|
|
46
|
+
*/
|
|
47
|
+
readonly addedToolNames?: readonly string[];
|
|
48
|
+
readonly isError?: boolean;
|
|
49
|
+
readonly stopTurn?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The call identity + execution surface shared by the resolve phase and the run phase of
|
|
53
|
+
* one tool call. New fields needed by both phases belong here, not on both subtypes.
|
|
54
|
+
*/
|
|
55
|
+
export interface ToolContextBase {
|
|
56
|
+
readonly turnId: string;
|
|
57
|
+
readonly toolCallId: string;
|
|
58
|
+
readonly signal: AbortSignal;
|
|
59
|
+
readonly machine: Machine;
|
|
60
|
+
/**
|
|
61
|
+
* Journal address of the frame running this call — `main` for the root agent, `main/<agentId>`
|
|
62
|
+
* for a subagent. It is the frame's identity: what `agent.started`/`agent.ended` events carry,
|
|
63
|
+
* and what `Session.steerTo` addresses. A tool that coordinates between agents needs it to know
|
|
64
|
+
* which one it is running inside.
|
|
65
|
+
*/
|
|
66
|
+
readonly address?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Session-scoped file freshness ledger (read-before-write / staleness checks); at
|
|
69
|
+
* resolve time it supports pre-approval validation. The runner always provides it;
|
|
70
|
+
* tools that depend on it must fail closed when absent (a hand-built context without
|
|
71
|
+
* one), never skip the check silently.
|
|
72
|
+
*/
|
|
73
|
+
readonly fileLedger?: FileFreshnessLedger;
|
|
74
|
+
}
|
|
75
|
+
export interface ToolRunContext extends ToolContextBase {
|
|
76
|
+
readonly onUpdate?: (update: ToolUpdate) => void;
|
|
77
|
+
readonly background?: BackgroundSpawner;
|
|
78
|
+
/**
|
|
79
|
+
* Client channel for interactive questions (AskUserQuestion). Absent — or present
|
|
80
|
+
* without `requestQuestion` — when the connected client cannot render questions;
|
|
81
|
+
* tools must then fall back to asking in their text response.
|
|
82
|
+
*/
|
|
83
|
+
readonly responder?: QuestionResponder;
|
|
84
|
+
/**
|
|
85
|
+
* Suspend this call durably: `state` (JSON-serializable, keep it small — spill big
|
|
86
|
+
* data to your own storage and save a reference) is persisted with the interruption,
|
|
87
|
+
* `request` is surfaced to the caller, and the whole run pauses. After the caller
|
|
88
|
+
* answers via `Runner.resume`, this call re-runs with `resumed` populated. Note the
|
|
89
|
+
* re-run repeats `resolve()` and everything in `run` before the suspend point — keep
|
|
90
|
+
* side effects idempotent up to the saved state. Never returns.
|
|
91
|
+
*/
|
|
92
|
+
readonly suspend: (request: ToolInputRequest, state?: unknown) => never;
|
|
93
|
+
/** Present when this call is the re-run of a previously suspended call. */
|
|
94
|
+
readonly resumed?: ToolResumeContext;
|
|
95
|
+
/**
|
|
96
|
+
* Fires when the caller requests this running call be moved to the background
|
|
97
|
+
* (foreground → background). DISTINCT from `signal`: `signal` aborting means "stop/kill",
|
|
98
|
+
* whereas `detachSignal` aborting means "detach the live work into a background task and
|
|
99
|
+
* return a synthetic result — do NOT kill it". Present only for tools whose work can be
|
|
100
|
+
* detached (a live process/subagent/workflow) on a session with the background capability.
|
|
101
|
+
*/
|
|
102
|
+
readonly detachSignal?: AbortSignal;
|
|
103
|
+
}
|
|
104
|
+
export interface ToolPlan {
|
|
105
|
+
readonly approvalRule: string;
|
|
106
|
+
readonly matchesRule?: (ruleArgs: string) => boolean;
|
|
107
|
+
readonly accesses?: ToolAccesses;
|
|
108
|
+
readonly display?: ToolDisplay;
|
|
109
|
+
readonly stopBatchAfterThis?: boolean;
|
|
110
|
+
readonly handoff?: {
|
|
111
|
+
readonly targetAgentName: string;
|
|
112
|
+
};
|
|
113
|
+
readonly controlFlow?: boolean;
|
|
114
|
+
readonly run: (ctx: ToolRunContext) => Promise<ToolResult>;
|
|
115
|
+
}
|
|
116
|
+
export interface ToolResolveContext extends ToolContextBase {
|
|
117
|
+
}
|
|
118
|
+
export interface Tool {
|
|
119
|
+
readonly schema: ToolSchema;
|
|
120
|
+
resolve(args: unknown, ctx: ToolResolveContext): ToolPlan | Promise<ToolPlan>;
|
|
121
|
+
/**
|
|
122
|
+
* Compact, security-relevant projection of this tool call for the `auto`-mode judge
|
|
123
|
+
* (and for the prior tool calls it reconstructs from the transcript). Examples: the
|
|
124
|
+
* `command` for Bash, `"path: <new content>"` for Write/Edit. Return `""` to declare
|
|
125
|
+
* the call has no security relevance — the judge then skips it (allow, and omit it
|
|
126
|
+
* from the transcript). When omitted, the judge falls back to a generic projection of
|
|
127
|
+
* the arguments.
|
|
128
|
+
*/
|
|
129
|
+
toAutoApprovalInput?(args: unknown): unknown;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=types.d.ts.map
|