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,260 @@
|
|
|
1
|
+
import { normalize, posix, win32 } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { isAbortError } from "../../loop/errors.js";
|
|
4
|
+
import { ToolAccesses } from "../access.js";
|
|
5
|
+
import { defineTool } from "../define.js";
|
|
6
|
+
import { resolveRgCommand, rgUnavailableMessage } from "../support/rg-locator.js";
|
|
7
|
+
import { runRipgrep, stillRunningNote } from "../support/ripgrep-run.js";
|
|
8
|
+
import { globApproval, resolveToolPath, SEARCH_ACCESS_POLICY } from "../support/tool-path.js";
|
|
9
|
+
const GlobInput = z.object({
|
|
10
|
+
pattern: z.string().describe("Glob pattern to match files."),
|
|
11
|
+
path: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Absolute path to the directory to search in. Defaults to the current working directory."),
|
|
15
|
+
});
|
|
16
|
+
export const MAX_MATCHES = 100;
|
|
17
|
+
const DEFAULT_TIMEOUT_MS = 20_000;
|
|
18
|
+
const MAX_OUTPUT_BYTES = 10 * 1024 * 1024;
|
|
19
|
+
// rg --files lists files only (it cannot emit directories); VCS metadata dirs are noise.
|
|
20
|
+
const VCS_DIRECTORIES_TO_EXCLUDE = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
|
|
21
|
+
const GLOB_DESCRIPTION = [
|
|
22
|
+
"Find files by glob pattern, sorted by modification time (most recent first).",
|
|
23
|
+
"",
|
|
24
|
+
"Good patterns:",
|
|
25
|
+
"- `*.ts` — files at any depth matching an extension",
|
|
26
|
+
"- `src/**/*.ts` — recursive walk with a subdirectory anchor and extension",
|
|
27
|
+
"- `**/*.py` — recursive walk from the search root for an extension",
|
|
28
|
+
"- `*.{ts,tsx}` — brace alternation is supported",
|
|
29
|
+
"",
|
|
30
|
+
"This tool returns files only, not directories. This searches by path/name only; to search file contents, use Grep instead.",
|
|
31
|
+
"",
|
|
32
|
+
`Results are capped at the first ${String(MAX_MATCHES)} matching paths after modification-time sorting. Refine the pattern (extension, subdirectory) when ${String(MAX_MATCHES)} is not enough, or call again with a narrower anchor.`,
|
|
33
|
+
"",
|
|
34
|
+
"Large-directory caveat — avoid recursing into dependency / build output even with an anchor:",
|
|
35
|
+
"- `node_modules/**/*.js`, `.venv/**/*.py`, `__pycache__/**`, `target/**` all match technically but typically produce thousands of results that truncate at the match cap and waste the caller context. Prefer specific subpaths like `node_modules/react/src/**/*.js`.",
|
|
36
|
+
].join("\n");
|
|
37
|
+
export const globTool = defineTool({
|
|
38
|
+
name: "Glob",
|
|
39
|
+
description: GLOB_DESCRIPTION,
|
|
40
|
+
params: GlobInput,
|
|
41
|
+
async resolve(args, ctx) {
|
|
42
|
+
const root = args.path !== undefined
|
|
43
|
+
? await resolveToolPath(args.path, ctx.machine, "search", SEARCH_ACCESS_POLICY)
|
|
44
|
+
: ctx.machine.getcwd();
|
|
45
|
+
return {
|
|
46
|
+
accesses: ToolAccesses.searchTree(root),
|
|
47
|
+
display: { title: `Searching ${args.pattern}`, detail: `pattern: ${args.pattern}` },
|
|
48
|
+
...globApproval("Glob", args.pattern),
|
|
49
|
+
run: (runCtx) => execute(args, root, runCtx.machine, runCtx.signal),
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
async function execute(args, root, machine, signal) {
|
|
54
|
+
if (signal.aborted)
|
|
55
|
+
return err("Glob aborted");
|
|
56
|
+
let rgCommand;
|
|
57
|
+
try {
|
|
58
|
+
rgCommand = await resolveRgCommand(machine, { signal });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (isAbortError(error))
|
|
62
|
+
return err("Glob aborted");
|
|
63
|
+
return err(rgUnavailableMessage(error));
|
|
64
|
+
}
|
|
65
|
+
// Probe the root so a missing/non-dir root reports clearly. rg would otherwise emit a
|
|
66
|
+
// terse stderr; this single fileInfo gives the same ENOENT/ENOTDIR message Read/Grep do.
|
|
67
|
+
try {
|
|
68
|
+
const info = await machine.fileInfo(root);
|
|
69
|
+
if (info.kind !== "dir")
|
|
70
|
+
return err(`${root} is not a directory`);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
const code = errorCode(error);
|
|
74
|
+
if (code === "ENOENT")
|
|
75
|
+
return err(`${root} does not exist`);
|
|
76
|
+
if (code === "ENOTDIR")
|
|
77
|
+
return err(`${root} is not a directory`);
|
|
78
|
+
// Unknown failure: fall through and let rg run.
|
|
79
|
+
}
|
|
80
|
+
const pattern = relativizePattern(args.pattern, root, machine.pathClass());
|
|
81
|
+
// Search target is "." with the process cwd at `root`, NOT the absolute root — see
|
|
82
|
+
// buildRgArgs. Everything downstream therefore sees paths like `./src/a.ts`.
|
|
83
|
+
const runOptions = { timeoutMs: DEFAULT_TIMEOUT_MS, maxOutputBytes: MAX_OUTPUT_BYTES, cwd: root };
|
|
84
|
+
let outcome = await runRipgrep(machine, buildRgArgs(rgCommand, pattern), signal, runOptions);
|
|
85
|
+
const earlyExit = mapNonResult(outcome);
|
|
86
|
+
if (earlyExit)
|
|
87
|
+
return earlyExit;
|
|
88
|
+
let runResult = outcome.result;
|
|
89
|
+
if (shouldRetryEagain(runResult)) {
|
|
90
|
+
outcome = await runRipgrep(machine, buildRgArgs(rgCommand, pattern, true), signal, runOptions);
|
|
91
|
+
const retryExit = mapNonResult(outcome);
|
|
92
|
+
if (retryExit)
|
|
93
|
+
return retryExit;
|
|
94
|
+
runResult = outcome.result;
|
|
95
|
+
}
|
|
96
|
+
const { exitCode, stdoutText, stderrText, truncated, timedOut, terminated } = runResult;
|
|
97
|
+
// rg --files: 0 = matches, 1 = no matches, >1 = real error. An `undefined` code is not a
|
|
98
|
+
// failure — it means the run was cut short (timeout kill, or a backend that cannot
|
|
99
|
+
// confirm completion), and whatever rg printed before that is still usable.
|
|
100
|
+
if (exitCode !== undefined && exitCode !== 0 && exitCode !== 1 && !timedOut) {
|
|
101
|
+
return err(formatRgError(exitCode, stderrText, truncated));
|
|
102
|
+
}
|
|
103
|
+
if (signal.aborted)
|
|
104
|
+
return err("Glob aborted");
|
|
105
|
+
const lines = splitLines(stdoutText);
|
|
106
|
+
// A byte-cap/timeout cut may have severed the last path mid-line; drop it.
|
|
107
|
+
if ((truncated || timedOut) && lines.length > 0)
|
|
108
|
+
lines.pop();
|
|
109
|
+
if (timedOut && lines.length === 0) {
|
|
110
|
+
return err(`Glob timed out after ${String(DEFAULT_TIMEOUT_MS / 1000)}s${stillRunningNote(terminated)}. ` +
|
|
111
|
+
`Try a more specific path or pattern.`);
|
|
112
|
+
}
|
|
113
|
+
// rg already ordered results newest-first (--sortr modified); we only cap.
|
|
114
|
+
const overCap = lines.length > MAX_MATCHES;
|
|
115
|
+
const capped = overCap ? lines.slice(0, MAX_MATCHES) : lines;
|
|
116
|
+
// Paths arrive relative to `root` (the target was "."). Keep them that way when the search
|
|
117
|
+
// stayed inside the workspace; otherwise re-absolutize, since a bare relative path would be
|
|
118
|
+
// read against the caller's cwd and point somewhere else entirely.
|
|
119
|
+
const pathClass = machine.pathClass();
|
|
120
|
+
const keepRelative = isWithinDirectory(root, machine.getcwd(), pathClass);
|
|
121
|
+
const displayLines = capped.map((p) => {
|
|
122
|
+
const relative = stripLeadingDotSlash(p);
|
|
123
|
+
return keepRelative ? relative : joinPath(pathClass, root, relative);
|
|
124
|
+
});
|
|
125
|
+
if (displayLines.length === 0 && !overCap && !timedOut && !truncated)
|
|
126
|
+
return ok("No matches found");
|
|
127
|
+
const out = [];
|
|
128
|
+
if (overCap) {
|
|
129
|
+
out.push(`[Truncated at ${String(MAX_MATCHES)} matches — use a more specific pattern]`);
|
|
130
|
+
}
|
|
131
|
+
out.push(...displayLines);
|
|
132
|
+
if (truncated)
|
|
133
|
+
out.push(`[output truncated at ${String(MAX_OUTPUT_BYTES)} bytes]`);
|
|
134
|
+
if (timedOut) {
|
|
135
|
+
out.push(`Glob timed out after ${String(DEFAULT_TIMEOUT_MS / 1000)}s${stillRunningNote(terminated)}; ` +
|
|
136
|
+
`partial results returned`);
|
|
137
|
+
}
|
|
138
|
+
return ok(out.join("\n"));
|
|
139
|
+
}
|
|
140
|
+
function buildRgArgs(rgCommand, pattern, singleThreaded = false) {
|
|
141
|
+
// List every file (--hidden, --no-ignore), most-recently-modified first (--sortr modified),
|
|
142
|
+
// filtered by the requested glob. rg's globs natively support brace alternation and
|
|
143
|
+
// gitignore-style `**`, so no tool-side brace expansion is needed.
|
|
144
|
+
//
|
|
145
|
+
// The target is "." and the ROOT IS THE PROCESS CWD. It cannot be the absolute root:
|
|
146
|
+
// `--glob` matches against the paths ripgrep prints, and a glob containing a `/` anchors
|
|
147
|
+
// to the start of that path, so `src/**/*.ts` against printed `/abs/root/src/a.ts` matches
|
|
148
|
+
// nothing — including the anchored patterns this tool's own description recommends.
|
|
149
|
+
const cmd = [rgCommand, "--files", "--hidden", "--no-ignore", "--sortr", "modified"];
|
|
150
|
+
if (singleThreaded)
|
|
151
|
+
cmd.push("-j", "1");
|
|
152
|
+
for (const dir of VCS_DIRECTORIES_TO_EXCLUDE)
|
|
153
|
+
cmd.push("--glob", `!${dir}`);
|
|
154
|
+
cmd.push("--glob", pattern);
|
|
155
|
+
cmd.push("--", ".");
|
|
156
|
+
return cmd;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* An absolute pattern under the search root becomes relative to it, since `--glob` is matched
|
|
160
|
+
* against root-relative printed paths and an absolute glob can never match one.
|
|
161
|
+
*
|
|
162
|
+
* A pattern outside the root is left alone: it genuinely matches nothing here, and silently
|
|
163
|
+
* reinterpreting it as relative would answer a different question than the one asked.
|
|
164
|
+
*/
|
|
165
|
+
function relativizePattern(pattern, root, pathClass) {
|
|
166
|
+
const isAbsolutePattern = pathClass === "win32" ? /^(?:[A-Za-z]:[\\/]|[\\/])/.test(pattern) : pattern.startsWith("/");
|
|
167
|
+
if (!isAbsolutePattern)
|
|
168
|
+
return pattern;
|
|
169
|
+
const relative = relativizeIfUnder(pattern, root, pathClass);
|
|
170
|
+
return relative === pattern ? pattern : relative;
|
|
171
|
+
}
|
|
172
|
+
/** Map an aborted/exec-error outcome to a tool result, or null when ripgrep ran. */
|
|
173
|
+
function mapNonResult(outcome) {
|
|
174
|
+
if (outcome.kind === "aborted")
|
|
175
|
+
return err("Glob aborted");
|
|
176
|
+
if (outcome.kind === "exec-error") {
|
|
177
|
+
return err(outcome.isEnoent
|
|
178
|
+
? rgUnavailableMessage(outcome.error)
|
|
179
|
+
: outcome.error instanceof Error
|
|
180
|
+
? outcome.error.message
|
|
181
|
+
: String(outcome.error));
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
function shouldRetryEagain(result) {
|
|
186
|
+
// No exit code means the run was cut short, not that rg failed to spawn threads — a
|
|
187
|
+
// retry would just hit the same timeout.
|
|
188
|
+
if (result.exitCode === undefined)
|
|
189
|
+
return false;
|
|
190
|
+
if (result.exitCode === 0 || result.exitCode === 1 || result.timedOut)
|
|
191
|
+
return false;
|
|
192
|
+
return result.stderrText.includes("os error 11") || result.stderrText.includes("Resource temporarily unavailable");
|
|
193
|
+
}
|
|
194
|
+
function splitLines(text) {
|
|
195
|
+
if (text === "")
|
|
196
|
+
return [];
|
|
197
|
+
const lines = text.split("\n");
|
|
198
|
+
while (lines.length > 0 && lines.at(-1) === "")
|
|
199
|
+
lines.pop();
|
|
200
|
+
return lines.map((line) => (line.endsWith("\r") ? line.slice(0, -1) : line));
|
|
201
|
+
}
|
|
202
|
+
function formatRgError(exitCode, stderrText, truncated) {
|
|
203
|
+
const stderr = stderrText.trim();
|
|
204
|
+
if (stderr.length === 0)
|
|
205
|
+
return `Failed to glob: ripgrep exited with code ${String(exitCode)}`;
|
|
206
|
+
const summary = stderr
|
|
207
|
+
.split("\n")
|
|
208
|
+
.map((line) => line.trim())
|
|
209
|
+
.filter((line) => line.length > 0)
|
|
210
|
+
.at(-1) ?? "ripgrep error";
|
|
211
|
+
const lines = [`Failed to glob: ${summary}`, "", "ripgrep stderr:", stderr];
|
|
212
|
+
if (truncated)
|
|
213
|
+
lines.push(`[output truncated at ${String(MAX_OUTPUT_BYTES)} bytes]`);
|
|
214
|
+
return lines.join("\n");
|
|
215
|
+
}
|
|
216
|
+
/** ripgrep prefixes every path with the `.` target it was given. */
|
|
217
|
+
function stripLeadingDotSlash(value) {
|
|
218
|
+
if (value.startsWith("./"))
|
|
219
|
+
return value.slice(2);
|
|
220
|
+
if (value.startsWith(".\\"))
|
|
221
|
+
return value.slice(2);
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
/** Join with the TARGET machine's path flavour — a local process may drive a posix machine. */
|
|
225
|
+
function joinPath(pathClass, dir, name) {
|
|
226
|
+
return (pathClass === "win32" ? win32 : posix).join(dir, name);
|
|
227
|
+
}
|
|
228
|
+
function relativizeIfUnder(candidate, base, pathClass) {
|
|
229
|
+
const normCandidate = normalize(candidate);
|
|
230
|
+
const normBase = normalize(base);
|
|
231
|
+
const comparableCandidate = pathClass === "win32" ? normCandidate.toLowerCase() : normCandidate;
|
|
232
|
+
const comparableBase = pathClass === "win32" ? normBase.toLowerCase() : normBase;
|
|
233
|
+
if (comparableCandidate === comparableBase)
|
|
234
|
+
return ".";
|
|
235
|
+
const prefix = comparableBase.endsWith("/") ? comparableBase : comparableBase + "/";
|
|
236
|
+
if (comparableCandidate.startsWith(prefix))
|
|
237
|
+
return normCandidate.slice(prefix.length);
|
|
238
|
+
return normCandidate;
|
|
239
|
+
}
|
|
240
|
+
function isWithinDirectory(candidate, base, pathClass) {
|
|
241
|
+
const c = pathClass === "win32" ? normalize(candidate).toLowerCase() : normalize(candidate);
|
|
242
|
+
const b = pathClass === "win32" ? normalize(base).toLowerCase() : normalize(base);
|
|
243
|
+
if (c === b)
|
|
244
|
+
return true;
|
|
245
|
+
const prefix = b.endsWith("/") ? b : b + "/";
|
|
246
|
+
return c.startsWith(prefix);
|
|
247
|
+
}
|
|
248
|
+
function errorCode(error) {
|
|
249
|
+
if (error !== null && typeof error === "object" && "code" in error) {
|
|
250
|
+
return error.code;
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
function ok(output) {
|
|
255
|
+
return { content: [{ type: "text", text: output }] };
|
|
256
|
+
}
|
|
257
|
+
function err(output) {
|
|
258
|
+
return { content: [{ type: "text", text: output }], isError: true };
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=glob.js.map
|