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,190 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "../../tool/define.js";
|
|
3
|
+
import { ToolAccesses } from "../../tool/access.js";
|
|
4
|
+
import { globApproval } from "../../tool/support/tool-path.js";
|
|
5
|
+
import { isBackgroundTaskTerminal } from "./task.js";
|
|
6
|
+
const OUTPUT_PREVIEW_BYTES = 32 * 1024; // 32 KiB
|
|
7
|
+
function text(s, isError = false) {
|
|
8
|
+
return { content: [{ type: "text", text: s }], isError };
|
|
9
|
+
}
|
|
10
|
+
function formatPlainObject(record) {
|
|
11
|
+
return Object.entries(record)
|
|
12
|
+
.filter(([, value]) => value !== undefined && value !== null)
|
|
13
|
+
.map(([key, value]) => `${key.replaceAll(/[A-Z]/g, (m) => `_${m.toLowerCase()}`)}: ${typeof value === "string" ? value : String(value)}`)
|
|
14
|
+
.join("\n");
|
|
15
|
+
}
|
|
16
|
+
function formatTaskInfo(info) {
|
|
17
|
+
return formatPlainObject({
|
|
18
|
+
...info,
|
|
19
|
+
outputRef: undefined,
|
|
20
|
+
outputKind: info.outputRef?.kind,
|
|
21
|
+
outputPath: info.outputRef?.kind === "file" ? info.outputRef.path : undefined,
|
|
22
|
+
outputAddress: info.outputRef?.kind === "conversation" || info.outputRef?.kind === "workflow-run"
|
|
23
|
+
? info.outputRef.address
|
|
24
|
+
: undefined,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function backgroundListTool(manager) {
|
|
28
|
+
return defineTool({
|
|
29
|
+
// The whole background trio is `Background*` (List/Output/Stop) so it never blurs with the
|
|
30
|
+
// structured todo `Task*` tools: this lists RUNNING BACKGROUND tasks; TaskList lists the todos.
|
|
31
|
+
name: "BackgroundList",
|
|
32
|
+
description: [
|
|
33
|
+
"Host-facing helper that lists this session's background tasks and their current status (id, kind, status, description). It is not exposed by backgroundCapability; applications may construct it explicitly for an administrative surface.",
|
|
34
|
+
"- By default only non-terminal (running) tasks; set active_only=false to also include completed/failed/killed/lost ones (lost = left over from a previous process that can no longer be inspected or controlled; treat as terminated).",
|
|
35
|
+
"- After a context compaction, or whenever you are unsure which tasks are running or what their ids are, call this to re-enumerate instead of guessing a task_id.",
|
|
36
|
+
"- limit caps how many tasks are returned (1–100, default 20). This tool is read-only and safe to call anytime, including in plan mode.",
|
|
37
|
+
"- This lists background RUNTIME tasks. For the structured to-do task list, use TaskList instead.",
|
|
38
|
+
].join("\n"),
|
|
39
|
+
params: z.object({
|
|
40
|
+
active_only: z.boolean().default(true).describe("List only non-terminal tasks.").optional(),
|
|
41
|
+
limit: z.number().int().min(1).max(100).default(20).describe("Maximum tasks to return.").optional(),
|
|
42
|
+
}),
|
|
43
|
+
resolve: (args) => ({
|
|
44
|
+
...globApproval("BackgroundList", (args.active_only ?? true) ? "active" : "all"),
|
|
45
|
+
accesses: ToolAccesses.none(),
|
|
46
|
+
display: { title: "List background tasks" },
|
|
47
|
+
run: async () => {
|
|
48
|
+
const activeOnly = args.active_only ?? true;
|
|
49
|
+
const tasks = manager.list(activeOnly, args.limit ?? 20);
|
|
50
|
+
const label = activeOnly ? "active_background_tasks" : "background_tasks";
|
|
51
|
+
const header = `${label}: ${String(tasks.length)}`;
|
|
52
|
+
if (tasks.length === 0)
|
|
53
|
+
return text(`${header}\nNo background tasks found.`);
|
|
54
|
+
return text(`${header}\n${tasks.map(formatTaskInfo).join("\n---\n")}`);
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function retrievalStatus(status, block) {
|
|
60
|
+
if (isBackgroundTaskTerminal(status))
|
|
61
|
+
return "success";
|
|
62
|
+
return block ? "timeout" : "not_ready";
|
|
63
|
+
}
|
|
64
|
+
/** The full, never-truncated log path for tasks whose authoritative output is a file. */
|
|
65
|
+
function taskLogPath(info) {
|
|
66
|
+
return info.outputRef?.kind === "file" ? info.outputRef.path : undefined;
|
|
67
|
+
}
|
|
68
|
+
function terminalReason(info) {
|
|
69
|
+
if (info.status === "timed_out")
|
|
70
|
+
return "timed_out";
|
|
71
|
+
if (info.status === "killed" && info.stopReason !== undefined)
|
|
72
|
+
return "stopped";
|
|
73
|
+
if (info.status === "failed" && info.stopReason !== undefined)
|
|
74
|
+
return "failed";
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
export function backgroundOutputTool(manager) {
|
|
78
|
+
return defineTool({
|
|
79
|
+
name: "BackgroundOutput",
|
|
80
|
+
description: [
|
|
81
|
+
"Read a background AGENT's or WORKFLOW's result, taken from where it already lives — a sub-agent's own conversation, a workflow run's journal. Works while it is still running: you get whatever it has produced so far.",
|
|
82
|
+
"- You do NOT need to poll. Every background task sends a completion notification on its own; call this when you want the answer before that arrives, or after a notification tells you the agent is done.",
|
|
83
|
+
"- For a background BASH command this returns status only, plus output_path. The command's output is a file on the machine — Read that path instead, which also gives you offset/limit paging over a large log.",
|
|
84
|
+
"- For a background WORKFLOW this returns the run's story from its journal: each phase, each agent's result, any failure, and the final outcome — for a running one, everything so far.",
|
|
85
|
+
"- For a background question this returns the user's answer in full — the place to read the rest when the completion notification truncated it.",
|
|
86
|
+
"- For a terminal task the metadata explains why it ended: status=timed_out when aborted by its deadline, and reason when it was explicitly stopped; terminal_reason is a categorical label (timed_out | stopped | failed). A task that ended on its own emits none of these.",
|
|
87
|
+
"- block=true waits for completion (optional timeout in seconds). Rarely needed — the notification already wakes you.",
|
|
88
|
+
].join("\n"),
|
|
89
|
+
params: z.object({
|
|
90
|
+
task_id: z.string().describe("The background task ID to inspect."),
|
|
91
|
+
block: z.boolean().default(false).describe("Wait for the task to finish before returning.").optional(),
|
|
92
|
+
timeout: z.number().int().min(0).max(3600).default(30).describe("Max seconds to wait when block=true.").optional(),
|
|
93
|
+
}),
|
|
94
|
+
resolve: (args) => ({
|
|
95
|
+
...globApproval("BackgroundOutput", args.task_id),
|
|
96
|
+
accesses: ToolAccesses.none(),
|
|
97
|
+
display: { title: `Read output of task ${args.task_id}` },
|
|
98
|
+
run: async () => {
|
|
99
|
+
const info = manager.getTask(args.task_id);
|
|
100
|
+
if (!info)
|
|
101
|
+
return text(`Task not found: ${args.task_id}`, true);
|
|
102
|
+
if (args.block && !isBackgroundTaskTerminal(info.status)) {
|
|
103
|
+
await manager.wait(args.task_id, (args.timeout ?? 30) * 1000);
|
|
104
|
+
}
|
|
105
|
+
const current = manager.getTask(args.task_id);
|
|
106
|
+
if (!current)
|
|
107
|
+
return text(`Task not found: ${args.task_id}`, true);
|
|
108
|
+
// A file-backed task's bytes are NOT served here: the file is the output, and `Read`
|
|
109
|
+
// pages it properly. Serving a second, worse view of the same file would invite the
|
|
110
|
+
// model to read it the truncating way. Everything else reports what it has.
|
|
111
|
+
const logPath = taskLogPath(current);
|
|
112
|
+
const output = logPath !== undefined ? undefined : await manager.readOutput(args.task_id, OUTPUT_PREVIEW_BYTES);
|
|
113
|
+
const lines = [
|
|
114
|
+
formatPlainObject({
|
|
115
|
+
retrievalStatus: retrievalStatus(current.status, args.block),
|
|
116
|
+
...current,
|
|
117
|
+
// Re-emit the task's log file (process kind) under the `output_path` name; suppress
|
|
118
|
+
// the raw `log_path` from the spread so there's a single, discoverable full-log key.
|
|
119
|
+
outputRef: undefined,
|
|
120
|
+
// A question's answer is served through the [output] section below (via readOutput);
|
|
121
|
+
// spreading it here too would print it twice.
|
|
122
|
+
answer: undefined,
|
|
123
|
+
outputKind: current.outputRef?.kind,
|
|
124
|
+
outputAddress: current.outputRef?.kind === "conversation" || current.outputRef?.kind === "workflow-run"
|
|
125
|
+
? current.outputRef.address
|
|
126
|
+
: undefined,
|
|
127
|
+
terminalReason: terminalReason(current),
|
|
128
|
+
outputSizeBytes: output?.sizeBytes,
|
|
129
|
+
outputContentBytes: output?.contentBytes,
|
|
130
|
+
outputTruncated: output?.truncated,
|
|
131
|
+
outputPath: logPath,
|
|
132
|
+
}),
|
|
133
|
+
"",
|
|
134
|
+
];
|
|
135
|
+
if (logPath !== undefined) {
|
|
136
|
+
lines.push(`This command's output is the file above. Read ${logPath} to see it.`);
|
|
137
|
+
return text(lines.join("\n"));
|
|
138
|
+
}
|
|
139
|
+
if (output !== undefined && output.truncated) {
|
|
140
|
+
lines.push(current.kind === "agent"
|
|
141
|
+
? "[Truncated — the beginning is shown. The whole record is the agent's conversation.]"
|
|
142
|
+
: "[Truncated — the beginning is shown.]");
|
|
143
|
+
}
|
|
144
|
+
lines.push("[output]", output?.content || "[no output available]");
|
|
145
|
+
return text(lines.join("\n"));
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const DEFAULT_STOP_REASON = "Stopped by BackgroundStop";
|
|
151
|
+
function terminalStopReason(reason) {
|
|
152
|
+
const trimmed = reason?.trim();
|
|
153
|
+
return trimmed === undefined || trimmed.length === 0 ? "Task already in terminal state" : trimmed;
|
|
154
|
+
}
|
|
155
|
+
export function backgroundStopTool(manager) {
|
|
156
|
+
return defineTool({
|
|
157
|
+
name: "BackgroundStop",
|
|
158
|
+
description: [
|
|
159
|
+
"Stop a running background task (SIGTERM, then SIGKILL after a grace period). This is a general-purpose stop for any background task, not a bash-specific kill.",
|
|
160
|
+
"- Only use this when a task must genuinely be cancelled — for one finishing normally, wait for its completion notification or inspect it with BackgroundOutput instead.",
|
|
161
|
+
"- Stopping is destructive: it may leave partial side effects behind.",
|
|
162
|
+
"- If the task has already finished, this simply returns its current status.",
|
|
163
|
+
].join("\n"),
|
|
164
|
+
params: z.object({
|
|
165
|
+
task_id: z.string().describe("The background task ID to stop."),
|
|
166
|
+
reason: z.string().default(DEFAULT_STOP_REASON).describe("Short reason recorded when the task is stopped.").optional(),
|
|
167
|
+
}),
|
|
168
|
+
resolve: (args) => ({
|
|
169
|
+
...globApproval("BackgroundStop", args.task_id),
|
|
170
|
+
accesses: ToolAccesses.none(),
|
|
171
|
+
display: { title: `Stop task ${args.task_id}` },
|
|
172
|
+
run: async () => {
|
|
173
|
+
const info = manager.getTask(args.task_id);
|
|
174
|
+
if (!info)
|
|
175
|
+
return text(`Task not found: ${args.task_id}`, true);
|
|
176
|
+
const trimmed = args.reason?.trim();
|
|
177
|
+
const reason = trimmed === undefined || trimmed.length === 0 ? DEFAULT_STOP_REASON : trimmed;
|
|
178
|
+
if (isBackgroundTaskTerminal(info.status)) {
|
|
179
|
+
return text(`task_id: ${info.taskId}\nstatus: ${info.status}\nreason: ${terminalStopReason(info.stopReason)}`);
|
|
180
|
+
}
|
|
181
|
+
await manager.suppressTerminalNotification(args.task_id);
|
|
182
|
+
const result = await manager.stop(args.task_id, reason);
|
|
183
|
+
if (!result)
|
|
184
|
+
return text(`Failed to stop task: ${args.task_id}`, true);
|
|
185
|
+
return text(`task_id: ${result.taskId}\nstatus: ${result.status}\nreason: ${result.stopReason ?? reason}`);
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { BackgroundTask, BackgroundTaskInfoBase, BackgroundTaskSink, TaskOutputLocation } from "./task.ts";
|
|
2
|
+
export interface WorkflowBackgroundTaskInfo extends BackgroundTaskInfoBase {
|
|
3
|
+
readonly kind: "workflow";
|
|
4
|
+
readonly workflowName?: string;
|
|
5
|
+
readonly runId?: string;
|
|
6
|
+
/** The workflow run's own terminal status (finer than the task status), once settled. */
|
|
7
|
+
readonly runStatus?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface WorkflowBackgroundTaskOptions {
|
|
10
|
+
readonly timeoutMs?: number;
|
|
11
|
+
readonly abort?: () => void;
|
|
12
|
+
readonly workflowName?: string;
|
|
13
|
+
readonly runId?: string;
|
|
14
|
+
readonly parentAddress?: string;
|
|
15
|
+
readonly toolCallId?: string;
|
|
16
|
+
/** The run's journal address (`workflow:<runId>`) — every background workflow must have one. */
|
|
17
|
+
readonly address: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A background task that runs a Workflow to completion.
|
|
21
|
+
*
|
|
22
|
+
* Holds no output. Every step the run takes — inputs, each agent starting and returning, the
|
|
23
|
+
* script's `log()` lines, failures, the outcome — is appended to its journal as it happens, so
|
|
24
|
+
* the task names that address and nothing else. The progress this used to mirror into the sink
|
|
25
|
+
* was a strictly worse copy: bounded by a buffer, gone with the process, and — because it was
|
|
26
|
+
* only wired up on the detach path — a different thing depending on whether the run had been
|
|
27
|
+
* backgrounded from the start.
|
|
28
|
+
*/
|
|
29
|
+
export declare class WorkflowBackgroundTask implements BackgroundTask {
|
|
30
|
+
readonly kind: "workflow";
|
|
31
|
+
readonly idPrefix: string;
|
|
32
|
+
readonly description: string;
|
|
33
|
+
readonly timeoutMs?: number;
|
|
34
|
+
readonly workflowName?: string;
|
|
35
|
+
readonly runId?: string;
|
|
36
|
+
readonly parentAddress?: string;
|
|
37
|
+
readonly toolCallId?: string;
|
|
38
|
+
readonly outputLocation?: TaskOutputLocation;
|
|
39
|
+
private runStatus?;
|
|
40
|
+
private readonly run;
|
|
41
|
+
private readonly abort?;
|
|
42
|
+
constructor(run: (sink: BackgroundTaskSink) => Promise<{
|
|
43
|
+
runStatus: "completed" | "failed";
|
|
44
|
+
}>, description: string, options: WorkflowBackgroundTaskOptions);
|
|
45
|
+
start(sink: BackgroundTaskSink): Promise<void>;
|
|
46
|
+
toInfo(base: BackgroundTaskInfoBase): WorkflowBackgroundTaskInfo;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=workflow-task.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { errorMessage, isAbortError } from "../../loop/errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* A background task that runs a Workflow to completion.
|
|
4
|
+
*
|
|
5
|
+
* Holds no output. Every step the run takes — inputs, each agent starting and returning, the
|
|
6
|
+
* script's `log()` lines, failures, the outcome — is appended to its journal as it happens, so
|
|
7
|
+
* the task names that address and nothing else. The progress this used to mirror into the sink
|
|
8
|
+
* was a strictly worse copy: bounded by a buffer, gone with the process, and — because it was
|
|
9
|
+
* only wired up on the detach path — a different thing depending on whether the run had been
|
|
10
|
+
* backgrounded from the start.
|
|
11
|
+
*/
|
|
12
|
+
export class WorkflowBackgroundTask {
|
|
13
|
+
kind = "workflow";
|
|
14
|
+
idPrefix = "workflow";
|
|
15
|
+
description;
|
|
16
|
+
timeoutMs;
|
|
17
|
+
workflowName;
|
|
18
|
+
runId;
|
|
19
|
+
parentAddress;
|
|
20
|
+
toolCallId;
|
|
21
|
+
outputLocation;
|
|
22
|
+
runStatus;
|
|
23
|
+
run;
|
|
24
|
+
abort;
|
|
25
|
+
constructor(run, description, options) {
|
|
26
|
+
if (typeof options.address !== "string" || options.address.length === 0) {
|
|
27
|
+
throw new Error("A background Workflow requires its durable journal address.");
|
|
28
|
+
}
|
|
29
|
+
this.run = run;
|
|
30
|
+
this.description = description;
|
|
31
|
+
this.timeoutMs = options.timeoutMs;
|
|
32
|
+
this.abort = options.abort;
|
|
33
|
+
this.workflowName = options.workflowName;
|
|
34
|
+
this.runId = options.runId;
|
|
35
|
+
this.parentAddress = options.parentAddress;
|
|
36
|
+
this.toolCallId = options.toolCallId;
|
|
37
|
+
this.outputLocation = { kind: "workflow-run", address: options.address };
|
|
38
|
+
}
|
|
39
|
+
async start(sink) {
|
|
40
|
+
const requestAbort = () => {
|
|
41
|
+
this.abort?.();
|
|
42
|
+
};
|
|
43
|
+
if (sink.signal.aborted) {
|
|
44
|
+
requestAbort();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
sink.signal.addEventListener("abort", requestAbort, { once: true });
|
|
48
|
+
}
|
|
49
|
+
const deadlineTimeout = Symbol("background-workflow-deadline");
|
|
50
|
+
const raceInputs = [this.run(sink)];
|
|
51
|
+
const timeoutMs = this.timeoutMs;
|
|
52
|
+
let timer;
|
|
53
|
+
if (timeoutMs !== undefined && timeoutMs > 0) {
|
|
54
|
+
raceInputs.push(new Promise((resolve) => {
|
|
55
|
+
timer = setTimeout(() => resolve(deadlineTimeout), timeoutMs);
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const outcome = await Promise.race(raceInputs);
|
|
60
|
+
if (outcome === deadlineTimeout) {
|
|
61
|
+
this.abort?.();
|
|
62
|
+
await sink.settle({ status: "timed_out" });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.runStatus = outcome.runStatus;
|
|
66
|
+
await sink.settle({ status: outcome.runStatus === "completed" ? "completed" : "failed" });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (sink.signal.aborted && isAbortError(error)) {
|
|
70
|
+
await sink.settle({ status: "killed" });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await sink.settle({ status: "failed", stopReason: errorMessage(error) });
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
if (timer !== undefined)
|
|
77
|
+
clearTimeout(timer);
|
|
78
|
+
sink.signal.removeEventListener("abort", requestAbort);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
toInfo(base) {
|
|
82
|
+
return {
|
|
83
|
+
...base,
|
|
84
|
+
kind: "workflow",
|
|
85
|
+
workflowName: this.workflowName,
|
|
86
|
+
runId: this.runId,
|
|
87
|
+
runStatus: this.runStatus,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=workflow-task.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentRecord, SessionStore } from "../store/index.ts";
|
|
2
|
+
/** The whole linear log in append order, or [] when there is no store / empty session. */
|
|
3
|
+
export declare function readLog(store: SessionStore | undefined): Promise<AgentRecord[]>;
|
|
4
|
+
/** The session's records for a capability's `openSession`: prefers the memoized `logRecords`
|
|
5
|
+
* the session shares across capabilities (one read for goal/plan/todo + the context replay),
|
|
6
|
+
* falling back to a direct `readLog` when it is absent (e.g. a test-constructed context). */
|
|
7
|
+
export declare function readSessionLog(ctx: {
|
|
8
|
+
readonly store?: SessionStore;
|
|
9
|
+
readonly logRecords?: () => Promise<readonly AgentRecord[]>;
|
|
10
|
+
}): Promise<readonly AgentRecord[]>;
|
|
11
|
+
/** The `details` of the latest tool result for `toolName` in the log, or undefined. */
|
|
12
|
+
export declare function latestToolDetails(records: readonly AgentRecord[], toolName: string): unknown;
|
|
13
|
+
//# sourceMappingURL=capability-state.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Capability state lives in the linear session log, not in a side channel: a stateful capability
|
|
2
|
+
// writes its state snapshot into the `details` of the tool result that changed it, and rebuilds
|
|
3
|
+
// its in-memory state by folding the shard's records on session open. This keeps the state
|
|
4
|
+
// durable across resume and, because a fork copies the log, correct after a fork.
|
|
5
|
+
/** The whole linear log in append order, or [] when there is no store / empty session. */
|
|
6
|
+
export async function readLog(store) {
|
|
7
|
+
if (store === undefined)
|
|
8
|
+
return [];
|
|
9
|
+
const records = [];
|
|
10
|
+
for await (const record of store.readRecords())
|
|
11
|
+
records.push(record);
|
|
12
|
+
return records;
|
|
13
|
+
}
|
|
14
|
+
/** The session's records for a capability's `openSession`: prefers the memoized `logRecords`
|
|
15
|
+
* the session shares across capabilities (one read for goal/plan/todo + the context replay),
|
|
16
|
+
* falling back to a direct `readLog` when it is absent (e.g. a test-constructed context). */
|
|
17
|
+
export function readSessionLog(ctx) {
|
|
18
|
+
return ctx.logRecords !== undefined ? ctx.logRecords() : readLog(ctx.store);
|
|
19
|
+
}
|
|
20
|
+
/** Tool-result messages for `toolName` in the log, in append order. */
|
|
21
|
+
function toolResultsInLog(records, toolName) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const record of records) {
|
|
24
|
+
if (record.type !== "context.append_message")
|
|
25
|
+
continue;
|
|
26
|
+
const msg = record.message;
|
|
27
|
+
if (msg.role === "toolResult" && msg.toolName === toolName)
|
|
28
|
+
out.push(msg);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/** The `details` of the latest tool result for `toolName` in the log, or undefined. */
|
|
33
|
+
export function latestToolDetails(records, toolName) {
|
|
34
|
+
const results = toolResultsInLog(records, toolName);
|
|
35
|
+
return results.length === 0 ? undefined : results[results.length - 1].details;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=capability-state.js.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { LoopHooks } from "../loop/types.ts";
|
|
2
|
+
import type { PermissionPolicy } from "../permission/types.ts";
|
|
3
|
+
import type { Message } from "../protocol/index.ts";
|
|
4
|
+
import type { Tool } from "../tool/types.ts";
|
|
5
|
+
import type { Machine } from "../tool/machine.ts";
|
|
6
|
+
import type { BackgroundSpawner } from "../tool/background.ts";
|
|
7
|
+
import type { EventSink } from "../events/index.ts";
|
|
8
|
+
import type { AgentRecord, SessionStore } from "../store/index.ts";
|
|
9
|
+
import type { SteerBus } from "../loop/steer.ts";
|
|
10
|
+
import type { Responder } from "../permission/types.ts";
|
|
11
|
+
import type { Injector } from "./injection.ts";
|
|
12
|
+
import type { ToolProvider } from "./tool-provider.ts";
|
|
13
|
+
import type { Logger } from "../logging/index.ts";
|
|
14
|
+
import type { ChatModel } from "../llm/define-model.ts";
|
|
15
|
+
import type { ThinkingLevel } from "../llm/model.ts";
|
|
16
|
+
import type { ContextBreakdown } from "../agent/context-report.ts";
|
|
17
|
+
import type { CompactRequestOptions, PendingCompaction } from "./compaction/index.ts";
|
|
18
|
+
/**
|
|
19
|
+
* The narrow slice of the owning Session a capability may ACT on (as opposed to observe).
|
|
20
|
+
* Implemented by `Session`; handed to capabilities that participate in the run rather than
|
|
21
|
+
* just watching it — today the extension runtime's `ctx.actions`.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately narrow: everything here is already a public Session operation, so nothing new
|
|
24
|
+
* becomes reachable — a capability simply gets a typed handle instead of the whole Session.
|
|
25
|
+
* Compaction-dependent calls throw when no compaction capability is open; callers are expected
|
|
26
|
+
* to treat that as "unavailable", not as a fatal error.
|
|
27
|
+
*/
|
|
28
|
+
export interface SessionControls {
|
|
29
|
+
/**
|
|
30
|
+
* Cancel work. Scope depends on where the controls came from: from a `CapabilityContext`
|
|
31
|
+
* (per run) this aborts THAT run and leaves the session usable; from a `SessionContext` it
|
|
32
|
+
* aborts the session. Either way the affected run(s) settle as `status: "aborted"`.
|
|
33
|
+
*/
|
|
34
|
+
abort(reason?: string): void;
|
|
35
|
+
compact(options?: CompactRequestOptions): Promise<PendingCompaction>;
|
|
36
|
+
getContextBreakdown(): ContextBreakdown | undefined;
|
|
37
|
+
setModel(model: string | ChatModel): void;
|
|
38
|
+
setThinking(level: ThinkingLevel): void;
|
|
39
|
+
}
|
|
40
|
+
export interface CapabilityContext {
|
|
41
|
+
readonly sessionId: string;
|
|
42
|
+
readonly machine: Machine;
|
|
43
|
+
readonly store?: SessionStore;
|
|
44
|
+
readonly events?: EventSink;
|
|
45
|
+
readonly responder?: Responder;
|
|
46
|
+
readonly signal: AbortSignal;
|
|
47
|
+
readonly background?: BackgroundSpawner;
|
|
48
|
+
readonly injection?: import("./injection.ts").InjectionManager;
|
|
49
|
+
readonly steer?: SteerBus;
|
|
50
|
+
readonly logger?: Logger;
|
|
51
|
+
readonly controls?: SessionControls;
|
|
52
|
+
/** Gates contributed by every capability in this run, for whoever needs to consult them. */
|
|
53
|
+
readonly gates?: AssembledGates;
|
|
54
|
+
}
|
|
55
|
+
/** Collected gate implementations, in capability registration order. */
|
|
56
|
+
export interface AssembledGates {
|
|
57
|
+
readonly compaction: readonly CompactionGate[];
|
|
58
|
+
}
|
|
59
|
+
export interface SessionContext {
|
|
60
|
+
readonly sessionId: string;
|
|
61
|
+
readonly machine: Machine;
|
|
62
|
+
readonly store?: SessionStore;
|
|
63
|
+
readonly events: EventSink;
|
|
64
|
+
readonly signal: AbortSignal;
|
|
65
|
+
readonly steer: SteerBus;
|
|
66
|
+
readonly controls?: SessionControls;
|
|
67
|
+
/** The session's records (append order), read once at open and memoized, so log-fold
|
|
68
|
+
* capabilities (goal/plan/todo) share one read instead of each calling `readLog`.
|
|
69
|
+
* Use `readSessionLog(ctx)` — it falls back to a direct read when this is absent. */
|
|
70
|
+
readonly logRecords?: () => Promise<readonly AgentRecord[]>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Narrows the assembled toolset just before a turn runs. The mirror image of `toolProviders`:
|
|
74
|
+
* providers add, filters remove. Called once per turn with the complete registry (agent tools ∪
|
|
75
|
+
* capability tools ∪ handoff/subagent tools), so a filter that drops a handoff tool is
|
|
76
|
+
* responsible for what that does to the agent graph. A filter that throws is skipped.
|
|
77
|
+
*/
|
|
78
|
+
export type ToolFilter = (tools: readonly Tool[]) => readonly Tool[];
|
|
79
|
+
/**
|
|
80
|
+
* Gates are the one place where a capability ASKS other capabilities before acting, instead of
|
|
81
|
+
* the engine asking capabilities. Every other extension point (`hooks`, `toolFilters`,
|
|
82
|
+
* `injectors`) is engine-driven; compaction is not — it decides on its own that the context is
|
|
83
|
+
* too big, so anyone who wants a say has to be consulted by it.
|
|
84
|
+
*
|
|
85
|
+
* Deliberately a named table rather than a generic string-keyed bus: this interface IS the
|
|
86
|
+
* complete list of "things another capability may veto", and adding one requires changing core.
|
|
87
|
+
* If it ever grows past a handful of entries, that is the signal to design a real middleware
|
|
88
|
+
* mechanism rather than to keep extending this.
|
|
89
|
+
*/
|
|
90
|
+
export interface CompactionGateContext {
|
|
91
|
+
readonly reason: "manual" | "auto";
|
|
92
|
+
/** Full model-visible history at the moment compaction was triggered. */
|
|
93
|
+
readonly messages: readonly Message[];
|
|
94
|
+
/** How many leading messages the default strategy intends to fold into one summary. */
|
|
95
|
+
readonly compactCount: number;
|
|
96
|
+
readonly signal: AbortSignal;
|
|
97
|
+
}
|
|
98
|
+
export interface CompactionGateResult {
|
|
99
|
+
/** Skip this compaction pass entirely. The context is left untouched. */
|
|
100
|
+
readonly cancel?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Supply the summary yourself instead of letting compaction call the model for it — e.g. a
|
|
103
|
+
* rule-based digest, or a cheaper model. `count` defaults to the strategy's `compactCount`.
|
|
104
|
+
*
|
|
105
|
+
* This writes into durable history and shapes every later turn: a summary that drops load-
|
|
106
|
+
* bearing context does not fail loudly, it makes the agent quietly forget. Own that.
|
|
107
|
+
*/
|
|
108
|
+
readonly replacement?: {
|
|
109
|
+
readonly summary: string;
|
|
110
|
+
readonly count?: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export type CompactionGate = (ctx: CompactionGateContext) => Promise<CompactionGateResult | undefined>;
|
|
114
|
+
export interface CapabilityGates {
|
|
115
|
+
compaction?: CompactionGate;
|
|
116
|
+
}
|
|
117
|
+
export interface Capability {
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly tools?: readonly Tool[];
|
|
120
|
+
readonly toolProviders?: readonly ToolProvider[];
|
|
121
|
+
readonly toolFilters?: readonly ToolFilter[];
|
|
122
|
+
/** Arbitration this capability wants a say in. See {@link CapabilityGates}. */
|
|
123
|
+
readonly gates?: CapabilityGates;
|
|
124
|
+
readonly policies?: readonly PermissionPolicy[];
|
|
125
|
+
readonly hooks?: Partial<LoopHooks>;
|
|
126
|
+
readonly injectors?: readonly Injector[];
|
|
127
|
+
readonly service?: unknown;
|
|
128
|
+
/** Per-run startup. `signal` aborts when the assembler's start timeout expires — the
|
|
129
|
+
* timeout itself still wins the race (the capability is marked absent), but a
|
|
130
|
+
* signal-respecting implementation can release whatever it was holding. */
|
|
131
|
+
start?(ctx: CapabilityContext, signal?: AbortSignal): Promise<void> | void;
|
|
132
|
+
/** Per-run teardown. `signal` aborts when the stop timeout expires; the run does not
|
|
133
|
+
* wait past the timeout either way, so use the signal to abandon slow flushes
|
|
134
|
+
* instead of leaking them into the background. */
|
|
135
|
+
stop?(signal?: AbortSignal): Promise<void> | void;
|
|
136
|
+
openSession?(ctx: SessionContext): Promise<void> | void;
|
|
137
|
+
closeSession?(): Promise<void> | void;
|
|
138
|
+
}
|
|
139
|
+
export interface CapabilityDiagnostic {
|
|
140
|
+
readonly capability: string;
|
|
141
|
+
readonly phase: "register" | "start" | "stop";
|
|
142
|
+
readonly level: "warn" | "error";
|
|
143
|
+
readonly message: string;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Message } from "../../protocol/index.ts";
|
|
2
|
+
import type { ChatModel } from "../../llm/define-model.ts";
|
|
3
|
+
import { type Logger } from "../../logging/index.ts";
|
|
4
|
+
import { type ConversationContext } from "../../loop/context.ts";
|
|
5
|
+
import type { InjectionManager } from "../injection.ts";
|
|
6
|
+
import type { CompactionGate } from "../capability.ts";
|
|
7
|
+
import type { CompactionStrategy } from "./strategy.ts";
|
|
8
|
+
export declare const MAX_COMPACTION_RETRY_ATTEMPTS = 5;
|
|
9
|
+
export interface FullCompactionDeps {
|
|
10
|
+
readonly messages: readonly Message[];
|
|
11
|
+
readonly model: ChatModel;
|
|
12
|
+
readonly system?: string;
|
|
13
|
+
readonly signal: AbortSignal;
|
|
14
|
+
readonly strategy: CompactionStrategy;
|
|
15
|
+
readonly customInstruction?: string;
|
|
16
|
+
readonly trigger?: string;
|
|
17
|
+
readonly sessionId: string;
|
|
18
|
+
readonly injection?: InjectionManager;
|
|
19
|
+
readonly context: ConversationContext;
|
|
20
|
+
readonly address: string;
|
|
21
|
+
readonly emit?: (event: import("../../events/index.ts").AgentEventBody) => void;
|
|
22
|
+
readonly logger?: Logger;
|
|
23
|
+
/** Capability gates to consult before compacting. See `CapabilityGates`. */
|
|
24
|
+
readonly gates?: readonly CompactionGate[];
|
|
25
|
+
}
|
|
26
|
+
export declare function runFullCompaction(deps: FullCompactionDeps): Promise<number>;
|
|
27
|
+
//# sourceMappingURL=full.d.ts.map
|