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,17 @@
|
|
|
1
|
+
import { type BackgroundTaskPersistence, type PersistedTask } from "./persist.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Disk-directory task store: `<sessionDir>/tasks/<id>/state.json`, one directory per
|
|
4
|
+
* task. Co-located under the SessionStore's own home (next to `agents/`
|
|
5
|
+
* and `blobs/`), so it inherits the session's durability and stays off the Machine
|
|
6
|
+
* sandbox. Writes are atomic (temp + rename) so a crash mid-write never leaves a torn file.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DiskBackgroundTaskPersistence implements BackgroundTaskPersistence {
|
|
9
|
+
private readonly root;
|
|
10
|
+
constructor(sessionDir: string);
|
|
11
|
+
writeTask(task: PersistedTask): Promise<void>;
|
|
12
|
+
readTask(taskId: string): Promise<PersistedTask | undefined>;
|
|
13
|
+
listTasks(): Promise<readonly PersistedTask[]>;
|
|
14
|
+
deleteTask(taskId: string): Promise<void>;
|
|
15
|
+
private taskDir;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=persist-disk.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isValidPersistedTask } from "./persist.js";
|
|
4
|
+
const TASKS_DIR = "tasks";
|
|
5
|
+
const STATE_FILE = "state.json";
|
|
6
|
+
const ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
7
|
+
/**
|
|
8
|
+
* Disk-directory task store: `<sessionDir>/tasks/<id>/state.json`, one directory per
|
|
9
|
+
* task. Co-located under the SessionStore's own home (next to `agents/`
|
|
10
|
+
* and `blobs/`), so it inherits the session's durability and stays off the Machine
|
|
11
|
+
* sandbox. Writes are atomic (temp + rename) so a crash mid-write never leaves a torn file.
|
|
12
|
+
*/
|
|
13
|
+
export class DiskBackgroundTaskPersistence {
|
|
14
|
+
root;
|
|
15
|
+
constructor(sessionDir) {
|
|
16
|
+
this.root = join(sessionDir, TASKS_DIR);
|
|
17
|
+
}
|
|
18
|
+
async writeTask(task) {
|
|
19
|
+
const dir = this.taskDir(task.taskId);
|
|
20
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
21
|
+
const target = join(dir, STATE_FILE);
|
|
22
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
23
|
+
await writeFile(tmp, JSON.stringify(task), "utf-8");
|
|
24
|
+
await rename(tmp, target);
|
|
25
|
+
}
|
|
26
|
+
async readTask(taskId) {
|
|
27
|
+
if (!ID_RE.test(taskId))
|
|
28
|
+
return undefined;
|
|
29
|
+
try {
|
|
30
|
+
const raw = await readFile(join(this.taskDir(taskId), STATE_FILE), "utf-8");
|
|
31
|
+
const value = JSON.parse(raw);
|
|
32
|
+
return isValidPersistedTask(value) ? value : undefined;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Missing / corrupt / torn file — treat as absent.
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async listTasks() {
|
|
40
|
+
let ids;
|
|
41
|
+
try {
|
|
42
|
+
ids = await readdir(this.root);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return []; // no tasks/ dir yet
|
|
46
|
+
}
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const id of ids) {
|
|
49
|
+
const task = await this.readTask(id);
|
|
50
|
+
if (task !== undefined)
|
|
51
|
+
out.push(task);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
async deleteTask(taskId) {
|
|
56
|
+
if (!ID_RE.test(taskId))
|
|
57
|
+
return;
|
|
58
|
+
await rm(this.taskDir(taskId), { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
taskDir(taskId) {
|
|
61
|
+
if (!ID_RE.test(taskId))
|
|
62
|
+
throw new Error(`invalid background task id: ${taskId}`);
|
|
63
|
+
return join(this.root, taskId);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=persist-disk.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { SessionStore } from "../../store/index.ts";
|
|
2
|
+
import { type BackgroundTaskInfo, type BackgroundTaskStatus } from "./task.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Background-task persistence — the durable, per-task STATUS record that survives a process
|
|
5
|
+
* restart, replacing the old fold-over-the-conversation reconstruction. On reopen the manager
|
|
6
|
+
* lists these records: any task still in a non-terminal status is an orphan whose spawning
|
|
7
|
+
* process died, so it is reclassified `lost` (see `manager.reconcile`). This is a dedicated
|
|
8
|
+
* task store (SessionStore-backed), NOT a fold of the append log — an intentional departure
|
|
9
|
+
* from the "append log is the only record" rule, documented in `store.ts`.
|
|
10
|
+
*
|
|
11
|
+
* A `PersistedTask` is the task's serializable status projection plus one stable `outputRef`.
|
|
12
|
+
* Result bytes never live here: Bash points at a file, Agent at its conversation shard, and
|
|
13
|
+
* Workflow at its journal. `schemaVersion: 2` is an intentional clean cut; older shapes are not
|
|
14
|
+
* accepted or migrated.
|
|
15
|
+
*/
|
|
16
|
+
export type PersistedTask = BackgroundTaskInfo & {
|
|
17
|
+
readonly schemaVersion: 2;
|
|
18
|
+
/** Monotonic within one manager. Writes are serialized, so later lifecycle snapshots cannot
|
|
19
|
+
* be overwritten by an older in-flight write. */
|
|
20
|
+
readonly revision: number;
|
|
21
|
+
/**
|
|
22
|
+
* The settle-notification ledger, in two stamps. Queuing alone proves nothing — the SteerBus
|
|
23
|
+
* is in memory, so a crash between enqueue and drain loses the notification while the task
|
|
24
|
+
* record survives as terminal.
|
|
25
|
+
*
|
|
26
|
+
* queued, never confirmed ⇒ lost in the crash window ⇒ redelivered on reopen
|
|
27
|
+
* never queued ⇒ nothing was owed (suppressed settle) ⇒ left alone
|
|
28
|
+
* confirmed ⇒ the model saw it ⇒ done
|
|
29
|
+
*
|
|
30
|
+
* Two stamps rather than one flag is what makes both negatives distinguishable: neither
|
|
31
|
+
* stamp means the terminal notification was intentionally suppressed and nothing is owed.
|
|
32
|
+
*
|
|
33
|
+
* `notifiedAt` is stamped from the recipient's `message.appended`, mirroring how peer
|
|
34
|
+
* delivery settles its ledger on consumption rather than on hand-off.
|
|
35
|
+
*/
|
|
36
|
+
readonly notificationQueuedAt?: number;
|
|
37
|
+
readonly notifiedAt?: number;
|
|
38
|
+
};
|
|
39
|
+
export interface BackgroundTaskPersistence {
|
|
40
|
+
/** Write (create or overwrite) a task's status record. BackgroundManager serializes all
|
|
41
|
+
* calls so whole-record writes and the backend's shared index update cannot race. */
|
|
42
|
+
writeTask(task: PersistedTask): Promise<void>;
|
|
43
|
+
readTask(taskId: string): Promise<PersistedTask | undefined>;
|
|
44
|
+
/** Every persisted task, in unspecified order. */
|
|
45
|
+
listTasks(): Promise<readonly PersistedTask[]>;
|
|
46
|
+
deleteTask(taskId: string): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/** Non-terminal = the spawning process never wrote a terminal status → orphan on reopen. */
|
|
49
|
+
export declare function isPersistedTaskTerminal(status: BackgroundTaskStatus): boolean;
|
|
50
|
+
/** Validate an untrusted persisted record (older wire versions, corrupt files). */
|
|
51
|
+
export declare function isValidPersistedTask(value: unknown): value is PersistedTask;
|
|
52
|
+
export declare class StoreBackgroundTaskPersistence implements BackgroundTaskPersistence {
|
|
53
|
+
private readonly store;
|
|
54
|
+
constructor(store: SessionStore);
|
|
55
|
+
writeTask(task: PersistedTask): Promise<void>;
|
|
56
|
+
readTask(taskId: string): Promise<PersistedTask | undefined>;
|
|
57
|
+
listTasks(): Promise<readonly PersistedTask[]>;
|
|
58
|
+
deleteTask(taskId: string): Promise<void>;
|
|
59
|
+
private readIndex;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=persist.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { TERMINAL_STATUSES } from "./task.js";
|
|
2
|
+
/** Non-terminal = the spawning process never wrote a terminal status → orphan on reopen. */
|
|
3
|
+
export function isPersistedTaskTerminal(status) {
|
|
4
|
+
return TERMINAL_STATUSES.has(status);
|
|
5
|
+
}
|
|
6
|
+
const TASK_KINDS = new Set(["process", "agent", "question", "workflow"]);
|
|
7
|
+
const STATUSES = new Set([
|
|
8
|
+
"running",
|
|
9
|
+
"completed",
|
|
10
|
+
"failed",
|
|
11
|
+
"paused",
|
|
12
|
+
"timed_out",
|
|
13
|
+
"killed",
|
|
14
|
+
"lost",
|
|
15
|
+
]);
|
|
16
|
+
/** Validate an untrusted persisted record (older wire versions, corrupt files). */
|
|
17
|
+
export function isValidPersistedTask(value) {
|
|
18
|
+
if (typeof value !== "object" || value === null)
|
|
19
|
+
return false;
|
|
20
|
+
const o = value;
|
|
21
|
+
if (o["schemaVersion"] !== 2)
|
|
22
|
+
return false;
|
|
23
|
+
if (typeof o["revision"] !== "number" || !Number.isInteger(o["revision"]) || o["revision"] < 1)
|
|
24
|
+
return false;
|
|
25
|
+
if (typeof o["taskId"] !== "string" || o["taskId"].length === 0)
|
|
26
|
+
return false;
|
|
27
|
+
if (typeof o["kind"] !== "string" || !TASK_KINDS.has(o["kind"]))
|
|
28
|
+
return false;
|
|
29
|
+
if (typeof o["status"] !== "string" || !STATUSES.has(o["status"]))
|
|
30
|
+
return false;
|
|
31
|
+
if (typeof o["description"] !== "string")
|
|
32
|
+
return false;
|
|
33
|
+
if (o["parentAddress"] !== undefined && typeof o["parentAddress"] !== "string")
|
|
34
|
+
return false;
|
|
35
|
+
if (o["toolCallId"] !== undefined && typeof o["toolCallId"] !== "string")
|
|
36
|
+
return false;
|
|
37
|
+
if (typeof o["startedAt"] !== "number")
|
|
38
|
+
return false;
|
|
39
|
+
if (o["endedAt"] !== null && typeof o["endedAt"] !== "number")
|
|
40
|
+
return false;
|
|
41
|
+
if (!isValidOutputRef(o["outputRef"]))
|
|
42
|
+
return false;
|
|
43
|
+
if (o["kind"] === "process" && o["outputRef"]?.kind !== "file")
|
|
44
|
+
return false;
|
|
45
|
+
if (o["kind"] === "agent" && o["outputRef"]?.kind !== "conversation")
|
|
46
|
+
return false;
|
|
47
|
+
if (o["kind"] === "workflow" && o["outputRef"]?.kind !== "workflow-run")
|
|
48
|
+
return false;
|
|
49
|
+
if (o["kind"] === "question" && o["outputRef"] !== undefined)
|
|
50
|
+
return false;
|
|
51
|
+
if (o["notificationQueuedAt"] !== undefined && typeof o["notificationQueuedAt"] !== "number")
|
|
52
|
+
return false;
|
|
53
|
+
if (o["notifiedAt"] !== undefined && typeof o["notifiedAt"] !== "number")
|
|
54
|
+
return false;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
function isValidOutputRef(value) {
|
|
58
|
+
if (value === undefined)
|
|
59
|
+
return true;
|
|
60
|
+
if (typeof value !== "object" || value === null)
|
|
61
|
+
return false;
|
|
62
|
+
const ref = value;
|
|
63
|
+
if (ref["kind"] === "file")
|
|
64
|
+
return typeof ref["path"] === "string" && ref["path"].length > 0;
|
|
65
|
+
if (ref["kind"] === "conversation" || ref["kind"] === "workflow-run") {
|
|
66
|
+
return typeof ref["address"] === "string" && ref["address"].length > 0;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// ── SessionStore KV backend ──────────────────────────────────────────────────
|
|
71
|
+
//
|
|
72
|
+
// Works on every SessionStore backend (disk/pg/redis/memory): status lives in KV state,
|
|
73
|
+
// mirroring how cron persists its registry (`cron/persist.ts`). Kept off the Machine
|
|
74
|
+
// for the same reason cron is — bookkeeping must be readable with no workspace attached and
|
|
75
|
+
// must sit outside the space agent-run code can touch. One index key + one key per task
|
|
76
|
+
// (tasks carry a large output tail elsewhere, so unlike cron they are not one whole blob).
|
|
77
|
+
const INDEX_KEY = "bg:index";
|
|
78
|
+
const taskKey = (taskId) => `bg:task:${taskId}`;
|
|
79
|
+
export class StoreBackgroundTaskPersistence {
|
|
80
|
+
store;
|
|
81
|
+
constructor(store) {
|
|
82
|
+
this.store = store;
|
|
83
|
+
}
|
|
84
|
+
async writeTask(task) {
|
|
85
|
+
await this.store.putState(taskKey(task.taskId), task);
|
|
86
|
+
const index = await this.readIndex();
|
|
87
|
+
if (!index.includes(task.taskId)) {
|
|
88
|
+
await this.store.putState(INDEX_KEY, [...index, task.taskId]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async readTask(taskId) {
|
|
92
|
+
const value = await this.store.getState(taskKey(taskId));
|
|
93
|
+
return isValidPersistedTask(value) ? value : undefined;
|
|
94
|
+
}
|
|
95
|
+
async listTasks() {
|
|
96
|
+
const index = await this.readIndex();
|
|
97
|
+
const out = [];
|
|
98
|
+
for (const id of index) {
|
|
99
|
+
const task = await this.readTask(id);
|
|
100
|
+
if (task !== undefined)
|
|
101
|
+
out.push(task);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
async deleteTask(taskId) {
|
|
106
|
+
await this.store.deleteState(taskKey(taskId));
|
|
107
|
+
const index = await this.readIndex();
|
|
108
|
+
if (index.includes(taskId)) {
|
|
109
|
+
await this.store.putState(INDEX_KEY, index.filter((id) => id !== taskId));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async readIndex() {
|
|
113
|
+
const value = await this.store.getState(INDEX_KEY);
|
|
114
|
+
return Array.isArray(value) ? value.filter((id) => typeof id === "string") : [];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=persist.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ToolResult } from "../../tool/types.ts";
|
|
2
|
+
import type { BackgroundTask, BackgroundTaskInfoBase, BackgroundTaskSink } from "./task.ts";
|
|
3
|
+
export interface QuestionBackgroundTaskInfo extends BackgroundTaskInfoBase {
|
|
4
|
+
readonly kind: "question";
|
|
5
|
+
readonly questionCount: number;
|
|
6
|
+
/**
|
|
7
|
+
* What the user answered, once they have. Held on the task rather than pushed through the
|
|
8
|
+
* sink because it is not output in the streaming sense — it arrives whole, exactly once, and
|
|
9
|
+
* its one consumer is the settle notification that carries it into the conversation. (It has
|
|
10
|
+
* to be carried: an answer is the user speaking, reproducible from nowhere.)
|
|
11
|
+
*/
|
|
12
|
+
readonly answer?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface QuestionBackgroundTaskOptions {
|
|
15
|
+
readonly questionCount: number;
|
|
16
|
+
readonly parentAddress?: string;
|
|
17
|
+
readonly toolCallId?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class QuestionBackgroundTask implements BackgroundTask {
|
|
20
|
+
readonly kind: "question";
|
|
21
|
+
readonly idPrefix = "question";
|
|
22
|
+
readonly description: string;
|
|
23
|
+
readonly questionCount: number;
|
|
24
|
+
readonly parentAddress?: string;
|
|
25
|
+
readonly toolCallId?: string;
|
|
26
|
+
private readonly run;
|
|
27
|
+
private answerText?;
|
|
28
|
+
constructor(run: (signal: AbortSignal) => Promise<ToolResult>, description: string, options: QuestionBackgroundTaskOptions);
|
|
29
|
+
start(sink: BackgroundTaskSink): Promise<void>;
|
|
30
|
+
toInfo(base: BackgroundTaskInfoBase): QuestionBackgroundTaskInfo;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=question-task.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { errorMessage, isAbortError } from "../../loop/errors.js";
|
|
2
|
+
export class QuestionBackgroundTask {
|
|
3
|
+
kind = "question";
|
|
4
|
+
idPrefix = "question";
|
|
5
|
+
description;
|
|
6
|
+
questionCount;
|
|
7
|
+
parentAddress;
|
|
8
|
+
toolCallId;
|
|
9
|
+
run;
|
|
10
|
+
answerText;
|
|
11
|
+
constructor(run, description, options) {
|
|
12
|
+
this.run = run;
|
|
13
|
+
this.description = description;
|
|
14
|
+
this.questionCount = options.questionCount;
|
|
15
|
+
this.parentAddress = options.parentAddress;
|
|
16
|
+
this.toolCallId = options.toolCallId;
|
|
17
|
+
}
|
|
18
|
+
async start(sink) {
|
|
19
|
+
try {
|
|
20
|
+
const result = await this.run(sink.signal);
|
|
21
|
+
const output = serializeToolResult(result).trim();
|
|
22
|
+
if (output.length > 0)
|
|
23
|
+
this.answerText = output;
|
|
24
|
+
await sink.settle({
|
|
25
|
+
status: result.isError === true ? "failed" : "completed",
|
|
26
|
+
stopReason: result.isError === true ? errorStopReason(result) : undefined,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (sink.signal.aborted && isAbortError(error)) {
|
|
31
|
+
await sink.settle({ status: "killed" });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
await sink.settle({ status: "failed", stopReason: errorMessage(error) });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
toInfo(base) {
|
|
38
|
+
return {
|
|
39
|
+
...base,
|
|
40
|
+
kind: "question",
|
|
41
|
+
questionCount: this.questionCount,
|
|
42
|
+
answer: this.answerText,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function serializeToolResult(result) {
|
|
47
|
+
return result.content
|
|
48
|
+
.filter((part) => part.type === "text")
|
|
49
|
+
.map((part) => part.text)
|
|
50
|
+
.join("");
|
|
51
|
+
}
|
|
52
|
+
function errorStopReason(result) {
|
|
53
|
+
const trimmed = serializeToolResult(result).trim();
|
|
54
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=question-task.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BackgroundTask, BackgroundTaskInfo } from "./task.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The subset of a BackgroundManager a tool needs to register + peek at a detached task.
|
|
4
|
+
* A `BackgroundSpawner` may or may not be one; `asTaskRegistrar` narrows it structurally
|
|
5
|
+
* so the Agent and Workflow tools can offer `run_in_background` only when it's available.
|
|
6
|
+
*/
|
|
7
|
+
export interface BackgroundTaskRegistrar {
|
|
8
|
+
registerTask(task: BackgroundTask): string;
|
|
9
|
+
getTask(taskId: string): BackgroundTaskInfo | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function asTaskRegistrar(value: unknown): BackgroundTaskRegistrar | undefined;
|
|
12
|
+
//# sourceMappingURL=registrar.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function asTaskRegistrar(value) {
|
|
2
|
+
if (typeof value !== "object" || value === null)
|
|
3
|
+
return undefined;
|
|
4
|
+
const candidate = value;
|
|
5
|
+
return typeof candidate.registerTask === "function" && typeof candidate.getTask === "function"
|
|
6
|
+
? value
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=registrar.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BackgroundTaskSettlement, BackgroundTaskSink } from "./task.ts";
|
|
2
|
+
/** The mutable half of a {@link SwappableSink}: where settlement currently goes. */
|
|
3
|
+
interface SinkDownstream {
|
|
4
|
+
settle(settlement: BackgroundTaskSettlement): Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A {@link BackgroundTaskSink} whose settlement downstream can be swapped atomically at
|
|
8
|
+
* runtime while the `signal` stays fixed. Output is never switched: it already lives at the
|
|
9
|
+
* task's durable output location. On detach only lifecycle ownership moves to the manager.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SwappableSink implements BackgroundTaskSink {
|
|
12
|
+
#private;
|
|
13
|
+
readonly signal: AbortSignal;
|
|
14
|
+
constructor(signal: AbortSignal);
|
|
15
|
+
/** Point settlement at a new downstream. The previous one stops receiving. */
|
|
16
|
+
setDownstream(downstream: SinkDownstream): void;
|
|
17
|
+
settle(settlement: BackgroundTaskSettlement): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=swappable-sink.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link BackgroundTaskSink} whose settlement downstream can be swapped atomically at
|
|
3
|
+
* runtime while the `signal` stays fixed. Output is never switched: it already lives at the
|
|
4
|
+
* task's durable output location. On detach only lifecycle ownership moves to the manager.
|
|
5
|
+
*/
|
|
6
|
+
export class SwappableSink {
|
|
7
|
+
signal;
|
|
8
|
+
#downstream;
|
|
9
|
+
constructor(signal) {
|
|
10
|
+
this.signal = signal;
|
|
11
|
+
}
|
|
12
|
+
/** Point settlement at a new downstream. The previous one stops receiving. */
|
|
13
|
+
setDownstream(downstream) {
|
|
14
|
+
this.#downstream = downstream;
|
|
15
|
+
}
|
|
16
|
+
settle(settlement) {
|
|
17
|
+
return this.#downstream === undefined ? Promise.resolve(false) : this.#downstream.settle(settlement);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=swappable-sink.js.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Machine } from "../../tool/machine.ts";
|
|
2
|
+
import type { AgentBackgroundTaskInfo } from "./agent-task.ts";
|
|
3
|
+
import type { CommandBackgroundTaskInfo } from "./command-task.ts";
|
|
4
|
+
import type { QuestionBackgroundTaskInfo } from "./question-task.ts";
|
|
5
|
+
import type { WorkflowBackgroundTaskInfo } from "./workflow-task.ts";
|
|
6
|
+
export type BackgroundTaskStatus = "running" | "completed" | "failed" | "paused" | "timed_out" | "killed" | "lost";
|
|
7
|
+
export declare const TERMINAL_STATUSES: ReadonlySet<BackgroundTaskStatus>;
|
|
8
|
+
export type BackgroundTaskSettlementStatus = "completed" | "failed" | "paused" | "timed_out" | "killed";
|
|
9
|
+
export interface BackgroundTaskSettlement {
|
|
10
|
+
readonly status: BackgroundTaskSettlementStatus;
|
|
11
|
+
readonly stopReason?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BackgroundTaskInfoBase {
|
|
14
|
+
readonly taskId: string;
|
|
15
|
+
/** Conversation line + assistant tool call that created this task. Together they are unique
|
|
16
|
+
* inside a session and let crash recovery find the task even when its spawn acknowledgement
|
|
17
|
+
* never made it into the parent conversation. */
|
|
18
|
+
readonly parentAddress?: string;
|
|
19
|
+
readonly toolCallId?: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly status: BackgroundTaskStatus;
|
|
22
|
+
readonly startedAt: number;
|
|
23
|
+
readonly endedAt: number | null;
|
|
24
|
+
readonly stopReason?: string;
|
|
25
|
+
readonly terminalNotificationSuppressed?: boolean;
|
|
26
|
+
readonly timeoutMs?: number;
|
|
27
|
+
/** Stable pointer to the task's complete output. This is the wire/store shape: unlike
|
|
28
|
+
* {@link TaskOutputLocation}, it contains no live Machine handle and survives restart. */
|
|
29
|
+
readonly outputRef?: TaskOutputRef;
|
|
30
|
+
}
|
|
31
|
+
export type BackgroundTaskInfo = CommandBackgroundTaskInfo | AgentBackgroundTaskInfo | QuestionBackgroundTaskInfo | WorkflowBackgroundTaskInfo;
|
|
32
|
+
export interface BackgroundTaskSink {
|
|
33
|
+
readonly signal: AbortSignal;
|
|
34
|
+
settle(settlement: BackgroundTaskSettlement): Promise<boolean>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Where a task's output already lives — a FACT the task states, never a copy it holds.
|
|
38
|
+
*
|
|
39
|
+
* The variants exist because output has several native homes and none is this process. A
|
|
40
|
+
* command's bytes are written by the OS into a file on the machine; a sub-agent's messages are
|
|
41
|
+
* appended by its conversation into a shard of the session store. In both cases the substance
|
|
42
|
+
* is already somewhere durable, addressable, and (for the shard) shared with every other view
|
|
43
|
+
* of the same data — the projection a UI subscribes to reads that identical record.
|
|
44
|
+
*
|
|
45
|
+
* Declaring the location instead of mirroring the content is what keeps a task from paying for
|
|
46
|
+
* observation nobody asked for, from capping history at whatever a buffer holds, and from
|
|
47
|
+
* creating a second copy whose authority is ambiguous. Production background work must
|
|
48
|
+
* declare one of these locations. The sole exception is a question: its answer is
|
|
49
|
+
* unreproducible user input and therefore rides along with its settle notification instead
|
|
50
|
+
* of pretending to be a separately retrievable result.
|
|
51
|
+
*/
|
|
52
|
+
export type TaskOutputRef = {
|
|
53
|
+
readonly kind: "file";
|
|
54
|
+
readonly path: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: "conversation";
|
|
57
|
+
readonly address: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly kind: "workflow-run";
|
|
60
|
+
readonly address: string;
|
|
61
|
+
};
|
|
62
|
+
export type TaskOutputLocation =
|
|
63
|
+
/** Redirected on the machine: `<home>/.operon/tasks/<id>.log` and the like. */
|
|
64
|
+
{
|
|
65
|
+
readonly kind: "file";
|
|
66
|
+
readonly machine: Machine;
|
|
67
|
+
readonly path: string;
|
|
68
|
+
}
|
|
69
|
+
/** A sub-agent's own conversation shard, read back and reduced to its latest answer. */
|
|
70
|
+
| {
|
|
71
|
+
readonly kind: "conversation";
|
|
72
|
+
readonly address: string;
|
|
73
|
+
}
|
|
74
|
+
/** A workflow run's journal: inputs, every agent result, and the outcome. */
|
|
75
|
+
| {
|
|
76
|
+
readonly kind: "workflow-run";
|
|
77
|
+
readonly address: string;
|
|
78
|
+
};
|
|
79
|
+
/** Strip runtime-only handles at the persistence/event boundary. */
|
|
80
|
+
export declare function taskOutputRef(location: TaskOutputLocation | undefined): TaskOutputRef | undefined;
|
|
81
|
+
export interface BackgroundTaskOutputSnapshot {
|
|
82
|
+
/** The bounded output window returned by this read. */
|
|
83
|
+
readonly content: string;
|
|
84
|
+
/** Total UTF-8 bytes in the authoritative output. */
|
|
85
|
+
readonly sizeBytes: number;
|
|
86
|
+
/** UTF-8 bytes present in `content` after boundary alignment. */
|
|
87
|
+
readonly contentBytes: number;
|
|
88
|
+
readonly truncated: boolean;
|
|
89
|
+
}
|
|
90
|
+
export interface BackgroundTaskOutputDelta {
|
|
91
|
+
readonly content: string;
|
|
92
|
+
/** Opaque cursor to pass to the next delta read. */
|
|
93
|
+
readonly nextCursor: number;
|
|
94
|
+
/** False when this task's output has no byte-addressable incremental view. */
|
|
95
|
+
readonly followable: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface BackgroundTask {
|
|
98
|
+
readonly idPrefix: string;
|
|
99
|
+
readonly kind: BackgroundTaskInfo["kind"];
|
|
100
|
+
readonly description: string;
|
|
101
|
+
readonly parentAddress?: string;
|
|
102
|
+
readonly toolCallId?: string;
|
|
103
|
+
readonly timeoutMs?: number;
|
|
104
|
+
/** Aborting `sink.signal` is the whole stop protocol — there is no second, harder step.
|
|
105
|
+
* A task that drives a command forwards the signal to `machine.run`, where SIGTERM →
|
|
106
|
+
* grace → SIGKILL escalation lives. */
|
|
107
|
+
start(sink: BackgroundTaskSink): void | Promise<void>;
|
|
108
|
+
toInfo(base: BackgroundTaskInfoBase): BackgroundTaskInfo;
|
|
109
|
+
/** Where this task's output already lives. Required by the manager for every kind except a
|
|
110
|
+
* question. Readers window it on demand; see {@link TaskOutputLocation}. */
|
|
111
|
+
readonly outputLocation?: TaskOutputLocation;
|
|
112
|
+
}
|
|
113
|
+
export declare function isBackgroundTaskTerminal(status: BackgroundTaskStatus): boolean;
|
|
114
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const TERMINAL_STATUSES = new Set([
|
|
2
|
+
"completed",
|
|
3
|
+
"failed",
|
|
4
|
+
"paused",
|
|
5
|
+
"timed_out",
|
|
6
|
+
"killed",
|
|
7
|
+
"lost",
|
|
8
|
+
]);
|
|
9
|
+
/** Strip runtime-only handles at the persistence/event boundary. */
|
|
10
|
+
export function taskOutputRef(location) {
|
|
11
|
+
if (location === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
return location.kind === "file"
|
|
14
|
+
? { kind: "file", path: location.path }
|
|
15
|
+
: { kind: location.kind, address: location.address };
|
|
16
|
+
}
|
|
17
|
+
export function isBackgroundTaskTerminal(status) {
|
|
18
|
+
return TERMINAL_STATUSES.has(status);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Tool } from "../../tool/types.ts";
|
|
2
|
+
import type { BackgroundManager } from "./manager.ts";
|
|
3
|
+
export declare function backgroundListTool(manager: BackgroundManager): Tool;
|
|
4
|
+
export declare function backgroundOutputTool(manager: BackgroundManager): Tool;
|
|
5
|
+
export declare function backgroundStopTool(manager: BackgroundManager): Tool;
|
|
6
|
+
//# sourceMappingURL=tools.d.ts.map
|