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,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Message } from "../protocol/index.ts";
|
|
3
|
+
import type { Tool } from "../tool/types.ts";
|
|
4
|
+
import type { Agent, AgentRunContext } from "./agent.ts";
|
|
5
|
+
export interface HandoffInputData {
|
|
6
|
+
readonly history: readonly Message[];
|
|
7
|
+
}
|
|
8
|
+
export type HandoffInputFilter = (data: HandoffInputData) => HandoffInputData;
|
|
9
|
+
export interface HandoffOptions<TContext = unknown, TInput = {
|
|
10
|
+
reason?: string;
|
|
11
|
+
}> {
|
|
12
|
+
readonly toolName?: string;
|
|
13
|
+
readonly toolDescription?: string;
|
|
14
|
+
readonly inputFilter?: HandoffInputFilter;
|
|
15
|
+
/**
|
|
16
|
+
* Schema for the args the model must produce when it calls this handoff tool. Defaults to
|
|
17
|
+
* `{ reason?: string }`. Pass a Zod object to require structured input at handoff time (e.g.
|
|
18
|
+
* `z.object({ orderId: z.string() })`); the framework validates the model's args against it
|
|
19
|
+
* before transferring (invalid args fail the tool call, so the transfer does not happen), and
|
|
20
|
+
* the validated value is what `onHandoff` receives.
|
|
21
|
+
*/
|
|
22
|
+
readonly inputType?: z.ZodType<TInput>;
|
|
23
|
+
/** Runs when the handoff is invoked, with the validated tool args (typed by `inputType`). */
|
|
24
|
+
readonly onHandoff?: (ctx: AgentRunContext<TContext>, input: TInput) => void | Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare function toFunctionToolName(name: string): string;
|
|
27
|
+
export declare function getTransferMessage(agentName: string): string;
|
|
28
|
+
export declare class Handoff<TContext = unknown> {
|
|
29
|
+
readonly toolName: string;
|
|
30
|
+
readonly toolDescription: string;
|
|
31
|
+
readonly target: Agent<TContext>;
|
|
32
|
+
readonly inputFilter?: HandoffInputFilter;
|
|
33
|
+
/** The args schema exposed to the model; `undefined` → the default `{ reason?: string }`. */
|
|
34
|
+
readonly inputType?: z.ZodType;
|
|
35
|
+
readonly onHandoff?: (ctx: AgentRunContext<TContext>, input: any) => void | Promise<void>;
|
|
36
|
+
constructor(target: Agent<TContext>, options?: HandoffOptions<TContext, any>);
|
|
37
|
+
asTool(): Tool;
|
|
38
|
+
}
|
|
39
|
+
export declare function handoff<TContext = unknown, TInput = {
|
|
40
|
+
reason?: string;
|
|
41
|
+
}>(target: Agent<TContext>, options?: HandoffOptions<TContext, TInput>): Handoff<TContext>;
|
|
42
|
+
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "../tool/define.js";
|
|
3
|
+
import { ToolAccesses } from "../tool/access.js";
|
|
4
|
+
/** Default handoff-tool args when no `inputType` is given: an optional free-text `reason`. */
|
|
5
|
+
const DEFAULT_HANDOFF_PARAMS = z.object({
|
|
6
|
+
reason: z.string().optional().describe("Why control is being transferred (optional)."),
|
|
7
|
+
});
|
|
8
|
+
export function toFunctionToolName(name) {
|
|
9
|
+
// Each disallowed char maps to its own "_" — no run-collapsing. Generated names land
|
|
10
|
+
// in transcripts (transfer_to_*/agent_* tool calls), so the mapping must stay stable.
|
|
11
|
+
const cleaned = name.replace(/[^a-zA-Z0-9_-]/g, "_").toLowerCase();
|
|
12
|
+
return cleaned || "agent";
|
|
13
|
+
}
|
|
14
|
+
export function getTransferMessage(agentName) {
|
|
15
|
+
return JSON.stringify({ assistant: agentName });
|
|
16
|
+
}
|
|
17
|
+
/** Best-effort string `reason` from validated handoff args, for the tool-call display line. */
|
|
18
|
+
function reasonOf(args) {
|
|
19
|
+
if (args !== null && typeof args === "object" && "reason" in args) {
|
|
20
|
+
const reason = args.reason;
|
|
21
|
+
if (typeof reason === "string")
|
|
22
|
+
return reason;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
export class Handoff {
|
|
27
|
+
toolName;
|
|
28
|
+
toolDescription;
|
|
29
|
+
target;
|
|
30
|
+
inputFilter;
|
|
31
|
+
/** The args schema exposed to the model; `undefined` → the default `{ reason?: string }`. */
|
|
32
|
+
inputType;
|
|
33
|
+
// Stored erased (`input: any`): the args schema varies per handoff, but `Agent.handoffs` holds a
|
|
34
|
+
// uniform `Handoff<TContext>[]`. Type safety lives on `HandoffOptions`/`handoff()`, not here.
|
|
35
|
+
onHandoff;
|
|
36
|
+
constructor(target, options = {}) {
|
|
37
|
+
this.target = target;
|
|
38
|
+
this.toolName = options.toolName ?? `transfer_to_${toFunctionToolName(target.name)}`;
|
|
39
|
+
this.toolDescription =
|
|
40
|
+
options.toolDescription ??
|
|
41
|
+
`Handoff to the ${target.name} agent to handle the request.${target.handoffDescription ? ` ${target.handoffDescription}` : ""}`;
|
|
42
|
+
this.inputFilter = options.inputFilter;
|
|
43
|
+
this.inputType = options.inputType;
|
|
44
|
+
this.onHandoff = options.onHandoff;
|
|
45
|
+
}
|
|
46
|
+
asTool() {
|
|
47
|
+
const targetName = this.target.name;
|
|
48
|
+
const toolName = this.toolName;
|
|
49
|
+
// A custom `inputType` replaces the model-facing args schema; otherwise the default `reason`.
|
|
50
|
+
// The tool framework validates args against it, so `resolve`/`onHandoff` see parsed values.
|
|
51
|
+
const params = this.inputType ?? DEFAULT_HANDOFF_PARAMS;
|
|
52
|
+
return defineTool({
|
|
53
|
+
name: toolName,
|
|
54
|
+
description: this.toolDescription,
|
|
55
|
+
params,
|
|
56
|
+
resolve: (args) => ({
|
|
57
|
+
approvalRule: toolName,
|
|
58
|
+
accesses: ToolAccesses.none(),
|
|
59
|
+
handoff: { targetAgentName: targetName },
|
|
60
|
+
controlFlow: true,
|
|
61
|
+
display: { title: `Handoff → ${targetName}`, detail: reasonOf(args) },
|
|
62
|
+
run: async () => ({ content: [{ type: "text", text: getTransferMessage(targetName) }] }),
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function handoff(target, options) {
|
|
68
|
+
return new Handoff(target, options);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { Agent, defineAgent } from "./agent.ts";
|
|
2
|
+
export type { AgentConfig, AgentGuardrails, AgentRunContext } from "./agent.ts";
|
|
3
|
+
export { Handoff, handoff, getTransferMessage, toFunctionToolName } from "./handoff.ts";
|
|
4
|
+
export type { HandoffOptions, HandoffInputData, HandoffInputFilter } from "./handoff.ts";
|
|
5
|
+
export { GuardrailTripwireError, isGuardrailTripwireError, runInputGuardrails, runOutputGuardrails, toolGuardrail, toolInputGuardrailHook, toolOutputGuardrailHook, } from "./guardrail.ts";
|
|
6
|
+
export type { GuardrailFunctionOutput, GuardrailStage, GuardrailLocation, InputGuardrail, InputGuardrailArgs, OutputGuardrail, OutputGuardrailArgs, OutputGuardrailStreamingOptions, ToolGuardrailBehavior, ToolGuardrailFunctionOutput, ToolInputGuardrail, ToolInputGuardrailData, ToolOutputGuardrail, ToolOutputGuardrailData, } from "./guardrail.ts";
|
|
7
|
+
export { composeLoopHooks } from "./compose-hooks.ts";
|
|
8
|
+
/** Agent profile + session runtime → the params one request carries. Exported so embedders
|
|
9
|
+
* that drive `runTurn` directly resolve precedence the same way the Runner does. */
|
|
10
|
+
export { resolveModelParams } from "./run-support.ts";
|
|
11
|
+
export { CapabilityMissingError, Session, newSessionId } from "./session.ts";
|
|
12
|
+
export type { BackgroundTaskListOptions, ReadBackgroundTaskOutputDeltaOptions, ReadBackgroundTaskOutputOptions, ConversationHead, CreateGoalInput, GoalBudgetInput, GoalStatusInput, PlanModeOptions, SessionConfig, SessionPort, } from "./session.ts";
|
|
13
|
+
export { newAgentId } from "./subagent.ts";
|
|
14
|
+
export type { SubagentRecord, SubagentStatus, AgentSpawnDetails } from "./subagent.ts";
|
|
15
|
+
export { RawAgentProfileSchema, resolveAgentProfiles, resolveProfileDirs, loadAgentProfiles, loadAgentProfilesFromSources, prepareSystemPromptContext, buildAgentFromProfile, profileSubagentProvider, } from "./profiles.ts";
|
|
16
|
+
export type { RawAgentProfile, RawSubagentProfile, ResolvedAgentProfile, SystemPromptContext, SystemPromptRenderer, ProfileLoadOptions, BuildAgentOptions, SubagentInfo, SubagentProvider, } from "./profiles.ts";
|
|
17
|
+
export { DEFAULT_AGENT_PROFILES, DEFAULT_AGENT_PROFILE_NAME, DEFAULT_SUBAGENT_NAMES } from "./profile-builtins.ts";
|
|
18
|
+
export { createWorktree } from "./worktree.ts";
|
|
19
|
+
export type { WorktreeHandle } from "./worktree.ts";
|
|
20
|
+
export { computeContextBreakdown } from "./context-report.ts";
|
|
21
|
+
export type { ContextBreakdown, ContextSlice, ContextInjectionSlice, ComputeContextBreakdownInput, } from "./context-report.ts";
|
|
22
|
+
export { Runner } from "./runner.ts";
|
|
23
|
+
export type { AgentInput, ResumeInput, RunInterruption, RunnerConfig, RunOptions, RunResult, RunStatus, } from "./runner.ts";
|
|
24
|
+
export * from "./workflow/index.ts";
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Agent, defineAgent } from "./agent.js";
|
|
2
|
+
export { Handoff, handoff, getTransferMessage, toFunctionToolName } from "./handoff.js";
|
|
3
|
+
export { GuardrailTripwireError, isGuardrailTripwireError, runInputGuardrails, runOutputGuardrails, toolGuardrail, toolInputGuardrailHook, toolOutputGuardrailHook, } from "./guardrail.js";
|
|
4
|
+
export { composeLoopHooks } from "./compose-hooks.js";
|
|
5
|
+
/** Agent profile + session runtime → the params one request carries. Exported so embedders
|
|
6
|
+
* that drive `runTurn` directly resolve precedence the same way the Runner does. */
|
|
7
|
+
export { resolveModelParams } from "./run-support.js";
|
|
8
|
+
export { CapabilityMissingError, Session, newSessionId } from "./session.js";
|
|
9
|
+
export { newAgentId } from "./subagent.js";
|
|
10
|
+
export { RawAgentProfileSchema, resolveAgentProfiles, resolveProfileDirs, loadAgentProfiles, loadAgentProfilesFromSources, prepareSystemPromptContext, buildAgentFromProfile, profileSubagentProvider, } from "./profiles.js";
|
|
11
|
+
export { DEFAULT_AGENT_PROFILES, DEFAULT_AGENT_PROFILE_NAME, DEFAULT_SUBAGENT_NAMES } from "./profile-builtins.js";
|
|
12
|
+
export { createWorktree } from "./worktree.js";
|
|
13
|
+
// Per-turn context-window breakdown (system/tools/messages/injections/free) for observability.
|
|
14
|
+
export { computeContextBreakdown } from "./context-report.js";
|
|
15
|
+
export { Runner } from "./runner.js";
|
|
16
|
+
// Workflow engine (the deterministic subagent-orchestration runtime) + its manager
|
|
17
|
+
// and snapshot/journal layers, exposed so upper layers can integrate programmatically.
|
|
18
|
+
export * from "./workflow/index.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Machine } from "../tool/machine.ts";
|
|
2
|
+
/** Runtime-only values used to render a profile system prompt. */
|
|
3
|
+
export interface SystemPromptContext {
|
|
4
|
+
readonly osKind: string;
|
|
5
|
+
readonly osArch?: string;
|
|
6
|
+
readonly osVersion?: string;
|
|
7
|
+
readonly shell: string;
|
|
8
|
+
/** Stable local calendar date for this live Session (`YYYY-MM-DD`). */
|
|
9
|
+
readonly now?: string | Date;
|
|
10
|
+
readonly cwd: string;
|
|
11
|
+
readonly agentsMd?: string;
|
|
12
|
+
readonly roleAdditional?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Format a date without adding a timezone conversion that could move it to another day. */
|
|
15
|
+
export declare function formatSystemPromptDate(date: Date): string;
|
|
16
|
+
/** Build the environment portion of a profile prompt from the active runtime machine. */
|
|
17
|
+
export declare function prepareSystemPromptContext(machine: Machine, now?: string, cwd?: string): Promise<SystemPromptContext>;
|
|
18
|
+
/**
|
|
19
|
+
* Live-Session cache for system-prompt environment data.
|
|
20
|
+
*
|
|
21
|
+
* Machine object identity separates independent local/remote/worktree runtimes; normalized cwd
|
|
22
|
+
* separates differently rooted frames backed by the same machine. Promise values also coalesce
|
|
23
|
+
* concurrent root/subagent reads. Nothing here is persisted, timed, or checked every turn.
|
|
24
|
+
*/
|
|
25
|
+
export declare class SystemPromptContextCache {
|
|
26
|
+
private readonly sessionDate;
|
|
27
|
+
private readonly entries;
|
|
28
|
+
constructor(createdAt?: Date);
|
|
29
|
+
resolve(machine: Machine, revision?: number): Promise<SystemPromptContext>;
|
|
30
|
+
/** Release runtime references when the owning Session closes. */
|
|
31
|
+
clear(): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=instruction-context.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { dirname, join } from "pathe";
|
|
2
|
+
import { readTextFile } from "../tool/support/machine-ops.js";
|
|
3
|
+
const AGENTS_MD_MAX_CHARS = 32 * 1024;
|
|
4
|
+
/** Format a date without adding a timezone conversion that could move it to another day. */
|
|
5
|
+
export function formatSystemPromptDate(date) {
|
|
6
|
+
const year = String(date.getFullYear()).padStart(4, "0");
|
|
7
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
8
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
9
|
+
return `${year}-${month}-${day}`;
|
|
10
|
+
}
|
|
11
|
+
/** Build the environment portion of a profile prompt from the active runtime machine. */
|
|
12
|
+
export async function prepareSystemPromptContext(machine, now = formatSystemPromptDate(new Date()), cwd = machine.normpath(machine.getcwd())) {
|
|
13
|
+
return {
|
|
14
|
+
osKind: machine.osEnv.osKind,
|
|
15
|
+
osArch: machine.osEnv.osArch,
|
|
16
|
+
osVersion: machine.osEnv.osVersion,
|
|
17
|
+
shell: `${machine.osEnv.shellName} (${machine.osEnv.shellPath})`,
|
|
18
|
+
now,
|
|
19
|
+
cwd,
|
|
20
|
+
agentsMd: await loadAgentsMd(machine, cwd),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Live-Session cache for system-prompt environment data.
|
|
25
|
+
*
|
|
26
|
+
* Machine object identity separates independent local/remote/worktree runtimes; normalized cwd
|
|
27
|
+
* separates differently rooted frames backed by the same machine. Promise values also coalesce
|
|
28
|
+
* concurrent root/subagent reads. Nothing here is persisted, timed, or checked every turn.
|
|
29
|
+
*/
|
|
30
|
+
export class SystemPromptContextCache {
|
|
31
|
+
sessionDate;
|
|
32
|
+
entries = new Map();
|
|
33
|
+
constructor(createdAt = new Date()) {
|
|
34
|
+
this.sessionDate = formatSystemPromptDate(createdAt);
|
|
35
|
+
}
|
|
36
|
+
resolve(machine, revision = 0) {
|
|
37
|
+
const cwd = machine.normpath(machine.getcwd());
|
|
38
|
+
let byCwd = this.entries.get(machine);
|
|
39
|
+
if (byCwd === undefined) {
|
|
40
|
+
byCwd = new Map();
|
|
41
|
+
this.entries.set(machine, byCwd);
|
|
42
|
+
}
|
|
43
|
+
const cached = byCwd.get(cwd);
|
|
44
|
+
if (cached?.revision === revision)
|
|
45
|
+
return cached.value;
|
|
46
|
+
const value = prepareSystemPromptContext(machine, this.sessionDate, cwd).catch((error) => {
|
|
47
|
+
if (byCwd?.get(cwd)?.value === value)
|
|
48
|
+
byCwd.delete(cwd);
|
|
49
|
+
throw error;
|
|
50
|
+
});
|
|
51
|
+
byCwd.set(cwd, { revision, value });
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
/** Release runtime references when the owning Session closes. */
|
|
55
|
+
clear() {
|
|
56
|
+
this.entries.clear();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Collect AGENTS.md from the user dir then filesystem root→cwd (nearest appended last). */
|
|
60
|
+
async function loadAgentsMd(machine, cwd) {
|
|
61
|
+
const paths = agentsMdPaths(machine, cwd);
|
|
62
|
+
// Reads are independent. Keep result order deterministic while avoiding a serial RPC walk on
|
|
63
|
+
// remote machines.
|
|
64
|
+
const files = await Promise.all(paths.map(async (path) => {
|
|
65
|
+
try {
|
|
66
|
+
const text = (await readTextFile(machine, path)).slice(0, AGENTS_MD_MAX_CHARS).trim();
|
|
67
|
+
return text.length > 0 ? { path, text } : undefined;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
return files
|
|
74
|
+
.filter((file) => file !== undefined)
|
|
75
|
+
.map((file) => `# ${file.path}\n${file.text}`)
|
|
76
|
+
.join("\n\n");
|
|
77
|
+
}
|
|
78
|
+
function agentsMdPaths(machine, cwd) {
|
|
79
|
+
const candidates = [join(machine.gethome(), ".agents", "AGENTS.md")];
|
|
80
|
+
const dirs = [];
|
|
81
|
+
let current = machine.normpath(cwd);
|
|
82
|
+
for (;;) {
|
|
83
|
+
dirs.unshift(current);
|
|
84
|
+
const parent = dirname(current);
|
|
85
|
+
if (parent === current)
|
|
86
|
+
break;
|
|
87
|
+
current = parent;
|
|
88
|
+
}
|
|
89
|
+
for (const dir of dirs)
|
|
90
|
+
candidates.push(join(dir, "AGENTS.md"));
|
|
91
|
+
const seen = new Set();
|
|
92
|
+
return candidates.filter((path) => {
|
|
93
|
+
const key = machine.normpath(path);
|
|
94
|
+
if (seen.has(key))
|
|
95
|
+
return false;
|
|
96
|
+
seen.add(key);
|
|
97
|
+
return true;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=instruction-context.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PendingInterrupt } from "../loop/types.ts";
|
|
2
|
+
import type { ConversationContext } from "../loop/context.ts";
|
|
3
|
+
import { type ToolCallSuspension } from "../loop/interruption.ts";
|
|
4
|
+
import type { Agent } from "./agent.ts";
|
|
5
|
+
import type { RunResult, RunState } from "./runner.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Take the run durable: flush the shard, reify the paused frame tree, persist it (root
|
|
8
|
+
* frame only — child frames bubble structurally to their spawning Agent tool and are
|
|
9
|
+
* merged by the parent), and build the `interrupted` RunResult carrying the control tree.
|
|
10
|
+
*/
|
|
11
|
+
export declare function pauseRun<TContext>(active: Agent<TContext>, context: ConversationContext, pending: readonly PendingInterrupt[], suspensions: readonly ToolCallSuspension[], state: RunState<TContext>, turnId: string): Promise<RunResult>;
|
|
12
|
+
//# sourceMappingURL=pause.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { INTERRUPTION_STATE_KEY, INTERRUPTION_STATE_VERSION, attachInterruptionState, flattenPendingInterrupts, interruptionAnchor, newInterruptionId, } from "../loop/interruption.js";
|
|
2
|
+
import { emitRunEvent, finalText, lastAssistant } from "./run-support.js";
|
|
3
|
+
/**
|
|
4
|
+
* Take the run durable: flush the shard, reify the paused frame tree, persist it (root
|
|
5
|
+
* frame only — child frames bubble structurally to their spawning Agent tool and are
|
|
6
|
+
* merged by the parent), and build the `interrupted` RunResult carrying the control tree.
|
|
7
|
+
*/
|
|
8
|
+
export async function pauseRun(active, context, pending, suspensions, state, turnId) {
|
|
9
|
+
const messages = context.messages;
|
|
10
|
+
// The assistant message holding the paused calls and any completed parallel sibling
|
|
11
|
+
// results are already in the log. Flush every shard before publishing the control tree.
|
|
12
|
+
await context.flush();
|
|
13
|
+
const assistant = lastAssistant(messages);
|
|
14
|
+
if (!assistant)
|
|
15
|
+
throw new Error("Cannot interrupt: current shard has no assistant message.");
|
|
16
|
+
const interruption = reify(active, assistant, pending, suspensions, state, turnId);
|
|
17
|
+
state.interruption = interruption;
|
|
18
|
+
const publicPending = flattenPendingInterrupts(interruption);
|
|
19
|
+
// Only the root owns the session-scoped KV key. Child frames bubble structurally to
|
|
20
|
+
// their spawning Agent tool and are merged by the parent frame.
|
|
21
|
+
if (state.parentFrameId === undefined && state.store) {
|
|
22
|
+
await state.store.putState(INTERRUPTION_STATE_KEY, interruption);
|
|
23
|
+
}
|
|
24
|
+
emitRunEvent(state, { type: "turn.paused", pending: publicPending });
|
|
25
|
+
const result = {
|
|
26
|
+
status: "interrupted",
|
|
27
|
+
finalAgent: active.name,
|
|
28
|
+
activeAddress: state.address,
|
|
29
|
+
output: finalText(messages),
|
|
30
|
+
// Snapshot — RunResult.messages must not alias the live context array (see Engine.finish).
|
|
31
|
+
messages: [...messages],
|
|
32
|
+
usage: state.usage,
|
|
33
|
+
interruption: {
|
|
34
|
+
id: interruption.interruptionId,
|
|
35
|
+
revision: interruption.revision,
|
|
36
|
+
pending: publicPending,
|
|
37
|
+
},
|
|
38
|
+
interruptions: publicPending,
|
|
39
|
+
};
|
|
40
|
+
return attachInterruptionState(result, interruption);
|
|
41
|
+
}
|
|
42
|
+
function reify(active, assistant, pending, suspensions, state, turnId) {
|
|
43
|
+
const preferredToolCallId = pending[0]?.toolCallId ?? suspensions[0]?.toolCallId;
|
|
44
|
+
const children = {};
|
|
45
|
+
const frames = {};
|
|
46
|
+
for (const suspension of suspensions) {
|
|
47
|
+
children[suspension.toolCallId] = suspension.state.rootFrameId;
|
|
48
|
+
Object.assign(frames, suspension.state.frames);
|
|
49
|
+
}
|
|
50
|
+
// Input answers are one-shot: a call that suspended AGAIN after consuming its answer
|
|
51
|
+
// must not see the stale answer on the next resume — drop answers for re-suspended
|
|
52
|
+
// calls. Re-parked (never-answered) entries had no answer, so this is a no-op for them.
|
|
53
|
+
const pendingInputIds = new Set(pending.filter((p) => p.kind === "input").map((p) => p.toolCallId));
|
|
54
|
+
const inputAnswers = Object.fromEntries(Object.entries(state.inputAnswers ?? {}).filter(([toolCallId]) => !pendingInputIds.has(toolCallId)));
|
|
55
|
+
frames[state.frameId] = {
|
|
56
|
+
frameId: state.frameId,
|
|
57
|
+
agentInstanceId: state.agentInstanceId,
|
|
58
|
+
address: state.address,
|
|
59
|
+
agent: { key: active.name, name: active.name },
|
|
60
|
+
turnId,
|
|
61
|
+
execution: { turns: state.turns, maxTurns: state.maxTurns, usage: state.usage },
|
|
62
|
+
anchor: interruptionAnchor(assistant, preferredToolCallId),
|
|
63
|
+
pending,
|
|
64
|
+
decisions: { ...(state.answers ?? {}) },
|
|
65
|
+
...(Object.keys(inputAnswers).length > 0 ? { inputAnswers } : {}),
|
|
66
|
+
children,
|
|
67
|
+
};
|
|
68
|
+
const previous = state.interruption;
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
return {
|
|
71
|
+
version: INTERRUPTION_STATE_VERSION,
|
|
72
|
+
runId: state.runId,
|
|
73
|
+
interruptionId: newInterruptionId("interrupt"),
|
|
74
|
+
phase: "waiting",
|
|
75
|
+
revision: (previous?.revision ?? 0) + 1,
|
|
76
|
+
rootFrameId: state.frameId,
|
|
77
|
+
frames,
|
|
78
|
+
createdAt: now,
|
|
79
|
+
updatedAt: now,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=pause.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ResolvedAgentProfile } from "./profiles.ts";
|
|
2
|
+
/** The builtin profiles, `extends` resolved. Key by name: `agent` (default) + coder/explore/plan. */
|
|
3
|
+
export declare const DEFAULT_AGENT_PROFILES: Record<string, ResolvedAgentProfile>;
|
|
4
|
+
/** Name of the builtin default (main) agent profile — the one a harness runs when no agent is given. */
|
|
5
|
+
export declare const DEFAULT_AGENT_PROFILE_NAME = "agent";
|
|
6
|
+
/** Names of the builtin subagents the default `agent` profile delegates to. */
|
|
7
|
+
export declare const DEFAULT_SUBAGENT_NAMES: readonly ["coder", "explore", "plan"];
|
|
8
|
+
//# sourceMappingURL=profile-builtins.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { loadAgentProfilesFromSources } from "./profiles.js";
|
|
2
|
+
// Builtin agent profiles shipped with the framework: a default `agent` plus `coder` / `explore` /
|
|
3
|
+
// `plan` subagents. YAML + an original system-prompt template are inlined as strings (no bundler /
|
|
4
|
+
// filesystem needed); `loadAgentProfilesFromSources` parses + resolves `extends` at module load.
|
|
5
|
+
// Original system-prompt template (nunjucks). Vars: os/osArch/osVersion, shell, now, workDir,
|
|
6
|
+
// agentsMd, roleAdditional (see buildTemplateVars in profiles.ts).
|
|
7
|
+
const SYSTEM_MD = `You are a capable software-engineering agent working directly in the user's environment. Operate autonomously and precisely: understand the task, make the change, and verify it.
|
|
8
|
+
|
|
9
|
+
## Environment
|
|
10
|
+
- OS: {{ os }}{% if osVersion %} ({{ osVersion }}{% if osArch %}, {{ osArch }}{% endif %}){% endif %}
|
|
11
|
+
- Shell: {{ shell }}
|
|
12
|
+
- Working directory: {{ workDir }}
|
|
13
|
+
- Date: {{ now }}
|
|
14
|
+
{% if agentsMd %}
|
|
15
|
+
## Project & user instructions
|
|
16
|
+
The following AGENTS.md instructions apply. Treat them as authoritative; the most specific (nearest) file wins on conflict.
|
|
17
|
+
|
|
18
|
+
{{ agentsMd }}
|
|
19
|
+
{% endif %}
|
|
20
|
+
## Operating guidance
|
|
21
|
+
- Read before you edit; make minimal, focused changes that match the surrounding code's style and idioms.
|
|
22
|
+
- Use the available tools to inspect, modify, and run code. Verify your work (build/tests) before declaring it done, and report what you checked.
|
|
23
|
+
- Never invent file contents, APIs, or results — check the code and the output.
|
|
24
|
+
- Be concise. Briefly explain non-obvious decisions; don't narrate trivial steps.
|
|
25
|
+
{% if roleAdditional %}
|
|
26
|
+
{{ roleAdditional }}
|
|
27
|
+
{% endif %}`;
|
|
28
|
+
const AGENT_YAML = `name: agent
|
|
29
|
+
description: Default general-purpose coding agent.
|
|
30
|
+
systemPromptPath: ./system.md
|
|
31
|
+
promptVars:
|
|
32
|
+
roleAdditional: ""
|
|
33
|
+
tools:
|
|
34
|
+
- Read
|
|
35
|
+
- Write
|
|
36
|
+
- Edit
|
|
37
|
+
- Grep
|
|
38
|
+
- Glob
|
|
39
|
+
- Bash
|
|
40
|
+
- TodoList
|
|
41
|
+
- Skill
|
|
42
|
+
- WebSearch
|
|
43
|
+
- FetchURL
|
|
44
|
+
- Agent
|
|
45
|
+
- AskUserQuestion
|
|
46
|
+
- EnterPlanMode
|
|
47
|
+
- ExitPlanMode
|
|
48
|
+
- CreateGoal
|
|
49
|
+
- GetGoal
|
|
50
|
+
- SetGoalBudget
|
|
51
|
+
- UpdateGoal
|
|
52
|
+
- BackgroundOutput
|
|
53
|
+
- BackgroundStop
|
|
54
|
+
- TaskCreate
|
|
55
|
+
- TaskUpdate
|
|
56
|
+
- TaskList
|
|
57
|
+
- TaskGet
|
|
58
|
+
- CronCreate
|
|
59
|
+
- CronList
|
|
60
|
+
- CronDelete
|
|
61
|
+
- mcp__*
|
|
62
|
+
subagents:
|
|
63
|
+
coder:
|
|
64
|
+
description: General software-engineering tasks end to end.
|
|
65
|
+
explore:
|
|
66
|
+
description: Fast, read-only codebase exploration.
|
|
67
|
+
plan:
|
|
68
|
+
description: Read-only implementation planning and design.
|
|
69
|
+
`;
|
|
70
|
+
const CODER_YAML = `extends: agent
|
|
71
|
+
name: coder
|
|
72
|
+
whenToUse: |
|
|
73
|
+
Delegate non-trivial software-engineering work (reading files, editing code, running commands) that should return a compact but technically complete summary to the parent agent.
|
|
74
|
+
promptVars:
|
|
75
|
+
roleAdditional: |
|
|
76
|
+
You are running as a subagent. Every user message comes from the parent agent, which sees only your final message — not your intermediate context. Treat the parent as your caller: do not ask the end user questions; machine any ambiguity in your final summary instead.
|
|
77
|
+
tools:
|
|
78
|
+
- Read
|
|
79
|
+
- Write
|
|
80
|
+
- Edit
|
|
81
|
+
- Grep
|
|
82
|
+
- Glob
|
|
83
|
+
- Bash
|
|
84
|
+
- WebSearch
|
|
85
|
+
- FetchURL
|
|
86
|
+
- mcp__*
|
|
87
|
+
`;
|
|
88
|
+
const EXPLORE_YAML = `extends: agent
|
|
89
|
+
name: explore
|
|
90
|
+
whenToUse: |
|
|
91
|
+
Fast, read-only codebase exploration. Use it to find files by pattern, search code for keywords, or answer questions about how the codebase works — especially when the task needs more than a few queries. Specify a thoroughness level (quick / medium / thorough). Launch several in parallel for independent questions.
|
|
92
|
+
promptVars:
|
|
93
|
+
roleAdditional: |
|
|
94
|
+
You are running as a subagent; the parent agent sees only your final message. You are a read-only exploration specialist — search, read, and analyze; you have no file-editing tools. Prefer Glob for file patterns, Grep for content, and Read for known paths. Use Bash only for read-only commands (ls, find, git status/log/diff). Run independent searches in parallel and report findings in a clear, structured summary. Match your depth to the requested thoroughness.
|
|
95
|
+
tools:
|
|
96
|
+
- Read
|
|
97
|
+
- Grep
|
|
98
|
+
- Glob
|
|
99
|
+
- Bash
|
|
100
|
+
- WebSearch
|
|
101
|
+
- FetchURL
|
|
102
|
+
`;
|
|
103
|
+
const PLAN_YAML = `extends: agent
|
|
104
|
+
name: plan
|
|
105
|
+
whenToUse: |
|
|
106
|
+
Produce a step-by-step implementation plan, identify key files, and weigh architectural trade-offs before any code changes are made.
|
|
107
|
+
promptVars:
|
|
108
|
+
roleAdditional: |
|
|
109
|
+
You are running as a subagent; the parent agent sees only your final message. Produce a read-only implementation plan — do not modify files. If you lack context, state (1) what you already know, (2) what remains unknown and would benefit from an explore subagent, and (3) your plan — preliminary if questions remain, final if context is sufficient.
|
|
110
|
+
tools:
|
|
111
|
+
- Read
|
|
112
|
+
- Grep
|
|
113
|
+
- Glob
|
|
114
|
+
- WebSearch
|
|
115
|
+
- FetchURL
|
|
116
|
+
`;
|
|
117
|
+
const PROFILE_SOURCES = {
|
|
118
|
+
"default/agent.yaml": AGENT_YAML,
|
|
119
|
+
"default/coder.yaml": CODER_YAML,
|
|
120
|
+
"default/explore.yaml": EXPLORE_YAML,
|
|
121
|
+
"default/plan.yaml": PLAN_YAML,
|
|
122
|
+
"default/system.md": SYSTEM_MD,
|
|
123
|
+
};
|
|
124
|
+
/** The builtin profiles, `extends` resolved. Key by name: `agent` (default) + coder/explore/plan. */
|
|
125
|
+
export const DEFAULT_AGENT_PROFILES = loadAgentProfilesFromSources(["default/agent.yaml", "default/coder.yaml", "default/explore.yaml", "default/plan.yaml"], PROFILE_SOURCES);
|
|
126
|
+
/** Name of the builtin default (main) agent profile — the one a harness runs when no agent is given. */
|
|
127
|
+
export const DEFAULT_AGENT_PROFILE_NAME = "agent";
|
|
128
|
+
/** Names of the builtin subagents the default `agent` profile delegates to. */
|
|
129
|
+
export const DEFAULT_SUBAGENT_NAMES = ["coder", "explore", "plan"];
|
|
130
|
+
//# sourceMappingURL=profile-builtins.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ChatModel } from "../llm/define-model.ts";
|
|
3
|
+
import type { Tool } from "../tool/types.ts";
|
|
4
|
+
import { Agent } from "./agent.ts";
|
|
5
|
+
import type { SystemPromptContext } from "./instruction-context.ts";
|
|
6
|
+
export { prepareSystemPromptContext } from "./instruction-context.ts";
|
|
7
|
+
export type { SystemPromptContext } from "./instruction-context.ts";
|
|
8
|
+
declare const SubagentRefSchema: z.ZodObject<{
|
|
9
|
+
description: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
/** A raw agent profile as authored in YAML (before `extends` is merged). */
|
|
12
|
+
export declare const RawAgentProfileSchema: z.ZodObject<{
|
|
13
|
+
extends: z.ZodOptional<z.ZodString>;
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
description: z.ZodOptional<z.ZodString>;
|
|
16
|
+
systemPromptPath: z.ZodOptional<z.ZodString>;
|
|
17
|
+
systemPromptTemplate: z.ZodOptional<z.ZodString>;
|
|
18
|
+
promptVars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
19
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
model: z.ZodOptional<z.ZodString>;
|
|
21
|
+
whenToUse: z.ZodOptional<z.ZodString>;
|
|
22
|
+
subagents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
23
|
+
description: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type RawAgentProfile = z.infer<typeof RawAgentProfileSchema>;
|
|
27
|
+
export type RawSubagentProfile = z.infer<typeof SubagentRefSchema>;
|
|
28
|
+
export type SystemPromptRenderer = (context: SystemPromptContext) => string;
|
|
29
|
+
/** A profile with `extends` merged and its system prompt exposed as a context-driven renderer. */
|
|
30
|
+
export interface ResolvedAgentProfile {
|
|
31
|
+
name: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
model?: string;
|
|
34
|
+
systemPrompt: SystemPromptRenderer;
|
|
35
|
+
tools: string[];
|
|
36
|
+
whenToUse?: string;
|
|
37
|
+
subagents?: Record<string, ResolvedAgentProfile>;
|
|
38
|
+
}
|
|
39
|
+
/** Resolve raw profiles with `extends` inheritance into renderers + a linked subagent graph. */
|
|
40
|
+
export declare function resolveAgentProfiles(raw: readonly RawAgentProfile[]): Record<string, ResolvedAgentProfile>;
|
|
41
|
+
export interface BuildAgentOptions {
|
|
42
|
+
/** Resolve a profile's `model` ref to a `ChatModel`. Omit to inherit the session model. */
|
|
43
|
+
readonly resolveModel?: (modelRef: string) => ChatModel | Promise<ChatModel>;
|
|
44
|
+
/** Tool registry the profile's `tools` names resolve against. Glob (`mcp__*`) + unknown names are skipped. */
|
|
45
|
+
readonly tools?: Readonly<Record<string, Tool>>;
|
|
46
|
+
/**
|
|
47
|
+
* Called for each non-glob tool name that did not resolve against `tools`. Unknown names
|
|
48
|
+
* CANNOT be errors — capability tools (goal/plan/todo/…) join at runtime and are invisible
|
|
49
|
+
* here — but a typo lands in the same bucket, so hosts should log these for diagnosis.
|
|
50
|
+
* Only invoked when a `tools` registry was provided. Default: silent (unchanged behavior).
|
|
51
|
+
*/
|
|
52
|
+
readonly onUnknownTool?: (toolName: string) => void;
|
|
53
|
+
/** Force the built agent's model, overriding the profile's `model`. Omit to keep the profile's ref
|
|
54
|
+
* (or inherit the session model when the profile declares none). */
|
|
55
|
+
readonly model?: string | ChatModel;
|
|
56
|
+
/** Fill the template's `roleAdditional` slot (rendered after the profile's own prompt), overriding
|
|
57
|
+
* the profile's `promptVars.roleAdditional`. The builtin default profile leaves this empty, so
|
|
58
|
+
* it reads as an append; on a profile that already sets it (e.g. a subagent role) this replaces it. */
|
|
59
|
+
readonly roleAdditional?: string;
|
|
60
|
+
/** Cap on steps within one turn for this agent. Overrides the Runner's own default — see
|
|
61
|
+
* `Agent.maxStepsPerTurn`. Lets a host vary the cap per agent (and so per session) without
|
|
62
|
+
* standing up a second Runner. */
|
|
63
|
+
readonly maxStepsPerTurn?: number;
|
|
64
|
+
}
|
|
65
|
+
/** Turn a resolved profile into a runnable Agent whose system prompt renders from live context. */
|
|
66
|
+
export declare function buildAgentFromProfile<TContext = unknown>(profile: ResolvedAgentProfile, options?: BuildAgentOptions): Promise<Agent<TContext>>;
|
|
67
|
+
export interface ProfileLoadOptions {
|
|
68
|
+
readonly appName?: string;
|
|
69
|
+
readonly homeDir?: string;
|
|
70
|
+
readonly cwd?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Profile dirs, low → high precedence: user (`~/.<app>/agents`) < project (`<cwd>/.<app>/agents`). */
|
|
73
|
+
export declare function resolveProfileDirs(options?: ProfileLoadOptions): string[];
|
|
74
|
+
/** Discover + parse `*.yaml`/`*.yml` profiles across tiers (project name overrides user), resolving
|
|
75
|
+
* each `systemPromptPath` relative to its file. Returns resolved profiles (extends merged). */
|
|
76
|
+
export declare function loadAgentProfiles(options?: ProfileLoadOptions): Promise<Record<string, ResolvedAgentProfile>>;
|
|
77
|
+
/** Build profiles from in-memory sources (YAML strings keyed by path); `systemPromptPath` resolves
|
|
78
|
+
* against the same map. Used for builtin profiles, which ship inline (no bundler/fs needed). */
|
|
79
|
+
export declare function loadAgentProfilesFromSources(profilePaths: readonly string[], sources: Readonly<Record<string, string>>): Record<string, ResolvedAgentProfile>;
|
|
80
|
+
export interface SubagentInfo {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly description?: string;
|
|
83
|
+
}
|
|
84
|
+
/** A runtime source of subagents the `Agent` tool can spawn/resume by type. */
|
|
85
|
+
export interface SubagentProvider<TContext = unknown> {
|
|
86
|
+
list(): Promise<readonly SubagentInfo[]> | readonly SubagentInfo[];
|
|
87
|
+
get(type: string): Promise<Agent<TContext> | undefined> | Agent<TContext> | undefined;
|
|
88
|
+
}
|
|
89
|
+
/** A `SubagentProvider` over resolved profiles (built lazily + cached per type). Pass `only` to
|
|
90
|
+
* expose a subset (e.g. a main profile's declared subagents); omit to expose all. */
|
|
91
|
+
export declare function profileSubagentProvider<TContext = unknown>(profiles: Record<string, ResolvedAgentProfile>, options?: BuildAgentOptions & {
|
|
92
|
+
readonly only?: readonly string[];
|
|
93
|
+
}): SubagentProvider<TContext>;
|
|
94
|
+
//# sourceMappingURL=profiles.d.ts.map
|