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,62 @@
|
|
|
1
|
+
import { BoundaryInjector } from "../injection.js";
|
|
2
|
+
import { renderTaskList, TASK_CREATE_TOOL_NAME, TASK_UPDATE_TOOL_NAME } from "./tools.js";
|
|
3
|
+
// Occasional-nudge cadence (todo-aligned): remind only when the model hasn't touched the task
|
|
4
|
+
// list for a while AND we haven't just reminded — a sparse recorded nudge, not a per-turn mirror.
|
|
5
|
+
const TURNS_SINCE_WRITE = 10;
|
|
6
|
+
const TURNS_BETWEEN_REMINDERS = 10;
|
|
7
|
+
const WRITE_TOOLS = new Set([TASK_CREATE_TOOL_NAME, TASK_UPDATE_TOOL_NAME]);
|
|
8
|
+
export class TaskListInjector extends BoundaryInjector {
|
|
9
|
+
id = "task";
|
|
10
|
+
store;
|
|
11
|
+
constructor(store) {
|
|
12
|
+
super();
|
|
13
|
+
this.store = store;
|
|
14
|
+
}
|
|
15
|
+
getInjection(ctx) {
|
|
16
|
+
this.restoreInjectedAt(ctx, ["task_reminder"]);
|
|
17
|
+
const tasks = this.store.list();
|
|
18
|
+
if (tasks.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
const turnsSinceWrite = assistantTurnsSinceTaskWrite(ctx.history);
|
|
21
|
+
const turnsSinceReminder = this.injectedAt === null ? Number.POSITIVE_INFINITY : assistantTurnsSince(ctx.history, this.injectedAt);
|
|
22
|
+
if (turnsSinceWrite < TURNS_SINCE_WRITE || turnsSinceReminder < TURNS_BETWEEN_REMINDERS)
|
|
23
|
+
return null;
|
|
24
|
+
return {
|
|
25
|
+
variant: "task_reminder",
|
|
26
|
+
text: [
|
|
27
|
+
"The task list has not been updated recently. If you are working on tasks that benefit from tracking, use TaskUpdate to move them through pending → in_progress → completed (keep one in_progress when work is underway). Only if relevant — a gentle reminder, ignore if not applicable. Never mention this reminder to the user.",
|
|
28
|
+
"",
|
|
29
|
+
renderTaskList(tasks),
|
|
30
|
+
].join("\n"),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function assistantTurnsSince(history, from) {
|
|
35
|
+
let count = 0;
|
|
36
|
+
for (let i = from + 1; i < history.length; i++) {
|
|
37
|
+
if (history[i]?.role === "assistant")
|
|
38
|
+
count += 1;
|
|
39
|
+
}
|
|
40
|
+
return count;
|
|
41
|
+
}
|
|
42
|
+
function assistantTurnsSinceTaskWrite(history) {
|
|
43
|
+
let count = 0;
|
|
44
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
45
|
+
const msg = history[i];
|
|
46
|
+
if (msg === undefined)
|
|
47
|
+
continue;
|
|
48
|
+
if (isTaskWrite(msg))
|
|
49
|
+
return count;
|
|
50
|
+
if (msg.role === "assistant")
|
|
51
|
+
count += 1;
|
|
52
|
+
}
|
|
53
|
+
return Number.POSITIVE_INFINITY;
|
|
54
|
+
}
|
|
55
|
+
function isTaskWrite(msg) {
|
|
56
|
+
if (msg.role === "toolResult")
|
|
57
|
+
return WRITE_TOOLS.has(msg.toolName);
|
|
58
|
+
if (msg.role === "assistant")
|
|
59
|
+
return msg.content.some((p) => p.type === "toolCall" && WRITE_TOOLS.has(p.name));
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=injector.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Task, type TaskListPersistence } from "./persist.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Disk-directory task list: one JSON file per task under `<sessionDir>/tasklist/<id>.json`,
|
|
4
|
+
* co-located under the SessionStore's home (next
|
|
5
|
+
* to `agents/`, `blobs/`, `tasks/`), off the Machine sandbox. Atomic writes (temp + rename)
|
|
6
|
+
* so a crash mid-write never leaves a torn file. Single live loop per session ⇒ no file locking.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DiskTaskListPersistence implements TaskListPersistence {
|
|
9
|
+
private readonly root;
|
|
10
|
+
constructor(sessionDir: string);
|
|
11
|
+
writeTask(task: Task): Promise<void>;
|
|
12
|
+
readTask(id: string): Promise<Task | undefined>;
|
|
13
|
+
listTasks(): Promise<Task[]>;
|
|
14
|
+
deleteTask(id: string): Promise<void>;
|
|
15
|
+
readHighWaterMark(): Promise<number>;
|
|
16
|
+
writeHighWaterMark(value: number): Promise<void>;
|
|
17
|
+
private taskPath;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=persist-disk.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isValidTask } from "./persist.js";
|
|
4
|
+
const LIST_DIR = "tasklist";
|
|
5
|
+
const HWM_FILE = ".hwm";
|
|
6
|
+
const ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
7
|
+
/**
|
|
8
|
+
* Disk-directory task list: one JSON file per task under `<sessionDir>/tasklist/<id>.json`,
|
|
9
|
+
* co-located under the SessionStore's home (next
|
|
10
|
+
* to `agents/`, `blobs/`, `tasks/`), off the Machine sandbox. Atomic writes (temp + rename)
|
|
11
|
+
* so a crash mid-write never leaves a torn file. Single live loop per session ⇒ no file locking.
|
|
12
|
+
*/
|
|
13
|
+
export class DiskTaskListPersistence {
|
|
14
|
+
root;
|
|
15
|
+
constructor(sessionDir) {
|
|
16
|
+
this.root = join(sessionDir, LIST_DIR);
|
|
17
|
+
}
|
|
18
|
+
async writeTask(task) {
|
|
19
|
+
await mkdir(this.root, { recursive: true, mode: 0o700 });
|
|
20
|
+
const target = this.taskPath(task.id);
|
|
21
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
22
|
+
await writeFile(tmp, JSON.stringify(task, null, 2), "utf-8");
|
|
23
|
+
await rename(tmp, target);
|
|
24
|
+
}
|
|
25
|
+
async readTask(id) {
|
|
26
|
+
if (!ID_RE.test(id))
|
|
27
|
+
return undefined;
|
|
28
|
+
try {
|
|
29
|
+
const value = JSON.parse(await readFile(this.taskPath(id), "utf-8"));
|
|
30
|
+
return isValidTask(value) ? value : undefined;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async listTasks() {
|
|
37
|
+
let files;
|
|
38
|
+
try {
|
|
39
|
+
files = await readdir(this.root);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const ids = files.filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length));
|
|
45
|
+
const out = [];
|
|
46
|
+
for (const id of ids) {
|
|
47
|
+
const task = await this.readTask(id);
|
|
48
|
+
if (task !== undefined)
|
|
49
|
+
out.push(task);
|
|
50
|
+
}
|
|
51
|
+
// Numeric-id order so the list reads in creation order (ids are sequential integers).
|
|
52
|
+
out.sort((a, b) => Number(a.id) - Number(b.id));
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
async deleteTask(id) {
|
|
56
|
+
if (!ID_RE.test(id))
|
|
57
|
+
return;
|
|
58
|
+
try {
|
|
59
|
+
await unlink(this.taskPath(id));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* already gone */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async readHighWaterMark() {
|
|
66
|
+
try {
|
|
67
|
+
const value = parseInt((await readFile(join(this.root, HWM_FILE), "utf-8")).trim(), 10);
|
|
68
|
+
return Number.isFinite(value) ? value : 0;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async writeHighWaterMark(value) {
|
|
75
|
+
await mkdir(this.root, { recursive: true, mode: 0o700 });
|
|
76
|
+
await writeFile(join(this.root, HWM_FILE), String(value), "utf-8");
|
|
77
|
+
}
|
|
78
|
+
taskPath(id) {
|
|
79
|
+
if (!ID_RE.test(id))
|
|
80
|
+
throw new Error(`invalid task id: ${id}`);
|
|
81
|
+
return join(this.root, `${id}.json`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=persist-disk.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SessionStore } from "../../store/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Structured task list (TaskCreate/Update/List/Get) — a
|
|
4
|
+
* richer replacement for the flat TodoList, with per-task records, statuses, dependencies
|
|
5
|
+
* (blocks/blockedBy), owner, and metadata. Unlike TodoList (a fold of the latest TodoList tool
|
|
6
|
+
* result), the task list is a dedicated per-task store, so it survives resume without folding
|
|
7
|
+
* the conversation. Storage is backend-selected (like background tasks): disk sessions keep one
|
|
8
|
+
* JSON file per task under `<sessionDir>/tasklist/`, other backends use KV state.
|
|
9
|
+
*
|
|
10
|
+
* There is deliberately no swarm/team layer (task claiming, agent-busy checks, team files) —
|
|
11
|
+
* this framework has no team model. The `owner` / `blocks` / `blockedBy` fields are kept so the
|
|
12
|
+
* data model stays complete and dependencies work.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TASK_STATUSES: readonly ["pending", "in_progress", "completed"];
|
|
15
|
+
export type TaskStatus = (typeof TASK_STATUSES)[number];
|
|
16
|
+
export interface Task {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly subject: string;
|
|
19
|
+
readonly description: string;
|
|
20
|
+
/** Present-continuous form for a spinner (e.g. "Running tests"). */
|
|
21
|
+
readonly activeForm?: string;
|
|
22
|
+
/** Agent id that owns the task (optional; no team-claim logic is ported). */
|
|
23
|
+
readonly owner?: string;
|
|
24
|
+
readonly status: TaskStatus;
|
|
25
|
+
/** Task ids this task blocks. */
|
|
26
|
+
readonly blocks: readonly string[];
|
|
27
|
+
/** Task ids that block this task. */
|
|
28
|
+
readonly blockedBy: readonly string[];
|
|
29
|
+
readonly metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface TaskListPersistence {
|
|
32
|
+
writeTask(task: Task): Promise<void>;
|
|
33
|
+
readTask(id: string): Promise<Task | undefined>;
|
|
34
|
+
listTasks(): Promise<Task[]>;
|
|
35
|
+
deleteTask(id: string): Promise<void>;
|
|
36
|
+
/** The highest task id ever assigned (survives deletes, so ids are never reused). */
|
|
37
|
+
readHighWaterMark(): Promise<number>;
|
|
38
|
+
writeHighWaterMark(value: number): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export declare function isValidTask(value: unknown): value is Task;
|
|
41
|
+
export declare class StoreTaskListPersistence implements TaskListPersistence {
|
|
42
|
+
private readonly store;
|
|
43
|
+
constructor(store: SessionStore);
|
|
44
|
+
writeTask(task: Task): Promise<void>;
|
|
45
|
+
readTask(id: string): Promise<Task | undefined>;
|
|
46
|
+
listTasks(): Promise<Task[]>;
|
|
47
|
+
deleteTask(id: string): Promise<void>;
|
|
48
|
+
readHighWaterMark(): Promise<number>;
|
|
49
|
+
writeHighWaterMark(value: number): Promise<void>;
|
|
50
|
+
private readIndex;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=persist.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured task list (TaskCreate/Update/List/Get) — a
|
|
3
|
+
* richer replacement for the flat TodoList, with per-task records, statuses, dependencies
|
|
4
|
+
* (blocks/blockedBy), owner, and metadata. Unlike TodoList (a fold of the latest TodoList tool
|
|
5
|
+
* result), the task list is a dedicated per-task store, so it survives resume without folding
|
|
6
|
+
* the conversation. Storage is backend-selected (like background tasks): disk sessions keep one
|
|
7
|
+
* JSON file per task under `<sessionDir>/tasklist/`, other backends use KV state.
|
|
8
|
+
*
|
|
9
|
+
* There is deliberately no swarm/team layer (task claiming, agent-busy checks, team files) —
|
|
10
|
+
* this framework has no team model. The `owner` / `blocks` / `blockedBy` fields are kept so the
|
|
11
|
+
* data model stays complete and dependencies work.
|
|
12
|
+
*/
|
|
13
|
+
export const TASK_STATUSES = ["pending", "in_progress", "completed"];
|
|
14
|
+
export function isValidTask(value) {
|
|
15
|
+
if (typeof value !== "object" || value === null)
|
|
16
|
+
return false;
|
|
17
|
+
const o = value;
|
|
18
|
+
if (typeof o["id"] !== "string" || o["id"].length === 0)
|
|
19
|
+
return false;
|
|
20
|
+
if (typeof o["subject"] !== "string")
|
|
21
|
+
return false;
|
|
22
|
+
if (typeof o["description"] !== "string")
|
|
23
|
+
return false;
|
|
24
|
+
if (typeof o["status"] !== "string" || !TASK_STATUSES.includes(o["status"]))
|
|
25
|
+
return false;
|
|
26
|
+
if (!Array.isArray(o["blocks"]) || !o["blocks"].every((x) => typeof x === "string"))
|
|
27
|
+
return false;
|
|
28
|
+
if (!Array.isArray(o["blockedBy"]) || !o["blockedBy"].every((x) => typeof x === "string"))
|
|
29
|
+
return false;
|
|
30
|
+
if (o["activeForm"] !== undefined && typeof o["activeForm"] !== "string")
|
|
31
|
+
return false;
|
|
32
|
+
if (o["owner"] !== undefined && typeof o["owner"] !== "string")
|
|
33
|
+
return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
// ── SessionStore KV backend ──────────────────────────────────────────────────
|
|
37
|
+
// One key per task + an index + the high-water-mark, mirroring the background task store's KV
|
|
38
|
+
// backend. Kept off the Machine (agent bookkeeping, per the cron/background rule).
|
|
39
|
+
const INDEX_KEY = "tasklist:index";
|
|
40
|
+
const HWM_KEY = "tasklist:hwm";
|
|
41
|
+
const taskKey = (id) => `tasklist:task:${id}`;
|
|
42
|
+
export class StoreTaskListPersistence {
|
|
43
|
+
store;
|
|
44
|
+
constructor(store) {
|
|
45
|
+
this.store = store;
|
|
46
|
+
}
|
|
47
|
+
async writeTask(task) {
|
|
48
|
+
await this.store.putState(taskKey(task.id), task);
|
|
49
|
+
const index = await this.readIndex();
|
|
50
|
+
if (!index.includes(task.id))
|
|
51
|
+
await this.store.putState(INDEX_KEY, [...index, task.id]);
|
|
52
|
+
}
|
|
53
|
+
async readTask(id) {
|
|
54
|
+
const value = await this.store.getState(taskKey(id));
|
|
55
|
+
return isValidTask(value) ? value : undefined;
|
|
56
|
+
}
|
|
57
|
+
async listTasks() {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const id of await this.readIndex()) {
|
|
60
|
+
const task = await this.readTask(id);
|
|
61
|
+
if (task !== undefined)
|
|
62
|
+
out.push(task);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
async deleteTask(id) {
|
|
67
|
+
await this.store.deleteState(taskKey(id));
|
|
68
|
+
const index = await this.readIndex();
|
|
69
|
+
if (index.includes(id))
|
|
70
|
+
await this.store.putState(INDEX_KEY, index.filter((x) => x !== id));
|
|
71
|
+
}
|
|
72
|
+
async readHighWaterMark() {
|
|
73
|
+
const value = await this.store.getState(HWM_KEY);
|
|
74
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
75
|
+
}
|
|
76
|
+
async writeHighWaterMark(value) {
|
|
77
|
+
await this.store.putState(HWM_KEY, value);
|
|
78
|
+
}
|
|
79
|
+
async readIndex() {
|
|
80
|
+
const value = await this.store.getState(INDEX_KEY);
|
|
81
|
+
return Array.isArray(value) ? value.filter((x) => typeof x === "string") : [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=persist.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Task, TaskListPersistence, TaskStatus } from "./persist.ts";
|
|
2
|
+
export type { Task, TaskStatus } from "./persist.ts";
|
|
3
|
+
export { TASK_STATUSES } from "./persist.ts";
|
|
4
|
+
export interface TaskCreateInput {
|
|
5
|
+
readonly subject: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly activeForm?: string;
|
|
8
|
+
readonly owner?: string;
|
|
9
|
+
readonly status?: TaskStatus;
|
|
10
|
+
readonly metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/** Scalar-field updates (dependency edges go through `block`). */
|
|
13
|
+
export interface TaskScalarUpdate {
|
|
14
|
+
readonly subject?: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly activeForm?: string;
|
|
17
|
+
readonly owner?: string;
|
|
18
|
+
readonly status?: TaskStatus;
|
|
19
|
+
readonly metadata?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* In-memory task list backed by a `TaskListPersistence`. Loaded once at session open, then kept
|
|
23
|
+
* in memory for synchronous reads (the injector) while every mutation writes through to the
|
|
24
|
+
* backend. A session has a single live loop (one writer), so whole-record writes cannot race —
|
|
25
|
+
* no locking is needed. Insertion order is preserved by the Map.
|
|
26
|
+
*/
|
|
27
|
+
export declare class TaskStore {
|
|
28
|
+
private readonly tasks;
|
|
29
|
+
private highWaterMark;
|
|
30
|
+
private persistence?;
|
|
31
|
+
attach(persistence: TaskListPersistence | undefined): void;
|
|
32
|
+
/** Rehydrate from the backend (session open). Ids stay sequential across the high-water-mark. */
|
|
33
|
+
load(): Promise<void>;
|
|
34
|
+
list(): readonly Task[];
|
|
35
|
+
get(id: string): Task | undefined;
|
|
36
|
+
create(input: TaskCreateInput): Promise<Task>;
|
|
37
|
+
update(id: string, updates: TaskScalarUpdate): Promise<Task | undefined>;
|
|
38
|
+
/** Delete a task and cascade-remove references to it from every other task's edges. */
|
|
39
|
+
delete(id: string): Promise<boolean>;
|
|
40
|
+
/** Record that `fromId` blocks `toId` (updates both endpoints' edge lists). */
|
|
41
|
+
block(fromId: string, toId: string): Promise<boolean>;
|
|
42
|
+
private writeEdges;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=task-store.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export { TASK_STATUSES } from "./persist.js";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory task list backed by a `TaskListPersistence`. Loaded once at session open, then kept
|
|
4
|
+
* in memory for synchronous reads (the injector) while every mutation writes through to the
|
|
5
|
+
* backend. A session has a single live loop (one writer), so whole-record writes cannot race —
|
|
6
|
+
* no locking is needed. Insertion order is preserved by the Map.
|
|
7
|
+
*/
|
|
8
|
+
export class TaskStore {
|
|
9
|
+
tasks = new Map();
|
|
10
|
+
highWaterMark = 0;
|
|
11
|
+
persistence;
|
|
12
|
+
attach(persistence) {
|
|
13
|
+
this.persistence = persistence;
|
|
14
|
+
}
|
|
15
|
+
/** Rehydrate from the backend (session open). Ids stay sequential across the high-water-mark. */
|
|
16
|
+
async load() {
|
|
17
|
+
this.tasks.clear();
|
|
18
|
+
this.highWaterMark = 0;
|
|
19
|
+
if (this.persistence === undefined)
|
|
20
|
+
return;
|
|
21
|
+
const loaded = await this.persistence.listTasks();
|
|
22
|
+
loaded.sort((a, b) => Number(a.id) - Number(b.id));
|
|
23
|
+
for (const task of loaded)
|
|
24
|
+
this.tasks.set(task.id, task);
|
|
25
|
+
const maxId = loaded.reduce((m, t) => Math.max(m, Number(t.id) || 0), 0);
|
|
26
|
+
this.highWaterMark = Math.max(await this.persistence.readHighWaterMark(), maxId);
|
|
27
|
+
}
|
|
28
|
+
list() {
|
|
29
|
+
return [...this.tasks.values()];
|
|
30
|
+
}
|
|
31
|
+
get(id) {
|
|
32
|
+
return this.tasks.get(id);
|
|
33
|
+
}
|
|
34
|
+
async create(input) {
|
|
35
|
+
this.highWaterMark += 1;
|
|
36
|
+
const id = String(this.highWaterMark);
|
|
37
|
+
const task = {
|
|
38
|
+
id,
|
|
39
|
+
subject: input.subject,
|
|
40
|
+
description: input.description,
|
|
41
|
+
activeForm: input.activeForm,
|
|
42
|
+
owner: input.owner,
|
|
43
|
+
status: input.status ?? "pending",
|
|
44
|
+
blocks: [],
|
|
45
|
+
blockedBy: [],
|
|
46
|
+
metadata: input.metadata,
|
|
47
|
+
};
|
|
48
|
+
this.tasks.set(id, task);
|
|
49
|
+
await this.persistence?.writeTask(task);
|
|
50
|
+
await this.persistence?.writeHighWaterMark(this.highWaterMark);
|
|
51
|
+
return task;
|
|
52
|
+
}
|
|
53
|
+
async update(id, updates) {
|
|
54
|
+
const existing = this.tasks.get(id);
|
|
55
|
+
if (existing === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
const updated = { ...existing, ...pruneUndefined(updates), id };
|
|
58
|
+
this.tasks.set(id, updated);
|
|
59
|
+
await this.persistence?.writeTask(updated);
|
|
60
|
+
return updated;
|
|
61
|
+
}
|
|
62
|
+
/** Delete a task and cascade-remove references to it from every other task's edges. */
|
|
63
|
+
async delete(id) {
|
|
64
|
+
if (!this.tasks.has(id))
|
|
65
|
+
return false;
|
|
66
|
+
this.tasks.delete(id);
|
|
67
|
+
await this.persistence?.deleteTask(id);
|
|
68
|
+
for (const task of [...this.tasks.values()]) {
|
|
69
|
+
const blocks = task.blocks.filter((x) => x !== id);
|
|
70
|
+
const blockedBy = task.blockedBy.filter((x) => x !== id);
|
|
71
|
+
if (blocks.length !== task.blocks.length || blockedBy.length !== task.blockedBy.length) {
|
|
72
|
+
await this.writeEdges(task.id, blocks, blockedBy);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
/** Record that `fromId` blocks `toId` (updates both endpoints' edge lists). */
|
|
78
|
+
async block(fromId, toId) {
|
|
79
|
+
const from = this.tasks.get(fromId);
|
|
80
|
+
const to = this.tasks.get(toId);
|
|
81
|
+
if (from === undefined || to === undefined)
|
|
82
|
+
return false;
|
|
83
|
+
if (!from.blocks.includes(toId))
|
|
84
|
+
await this.writeEdges(fromId, [...from.blocks, toId], from.blockedBy);
|
|
85
|
+
const toNow = this.tasks.get(toId);
|
|
86
|
+
if (!toNow.blockedBy.includes(fromId))
|
|
87
|
+
await this.writeEdges(toId, toNow.blocks, [...toNow.blockedBy, fromId]);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
async writeEdges(id, blocks, blockedBy) {
|
|
91
|
+
const existing = this.tasks.get(id);
|
|
92
|
+
if (existing === undefined)
|
|
93
|
+
return;
|
|
94
|
+
const updated = { ...existing, blocks, blockedBy };
|
|
95
|
+
this.tasks.set(id, updated);
|
|
96
|
+
await this.persistence?.writeTask(updated);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function pruneUndefined(updates) {
|
|
100
|
+
const out = {};
|
|
101
|
+
for (const [key, value] of Object.entries(updates))
|
|
102
|
+
if (value !== undefined)
|
|
103
|
+
out[key] = value;
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=task-store.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Tool } from "../../tool/types.ts";
|
|
2
|
+
import type { Task, TaskStore } from "./task-store.ts";
|
|
3
|
+
export declare const TASK_CREATE_TOOL_NAME = "TaskCreate";
|
|
4
|
+
export declare const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
|
|
5
|
+
export declare const TASK_LIST_TOOL_NAME = "TaskList";
|
|
6
|
+
export declare const TASK_GET_TOOL_NAME = "TaskGet";
|
|
7
|
+
export declare function taskCreateTool(store: TaskStore): Tool;
|
|
8
|
+
export declare function taskUpdateTool(store: TaskStore): Tool;
|
|
9
|
+
export declare function taskListTool(store: TaskStore): Tool;
|
|
10
|
+
export declare function taskGetTool(store: TaskStore): Tool;
|
|
11
|
+
export declare function renderTaskList(tasks: readonly Task[], title?: string): string;
|
|
12
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "../../tool/define.js";
|
|
3
|
+
import { ToolAccesses } from "../../tool/access.js";
|
|
4
|
+
export const TASK_CREATE_TOOL_NAME = "TaskCreate";
|
|
5
|
+
export const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
|
|
6
|
+
export const TASK_LIST_TOOL_NAME = "TaskList";
|
|
7
|
+
export const TASK_GET_TOOL_NAME = "TaskGet";
|
|
8
|
+
const MetadataSchema = z.record(z.string(), z.unknown());
|
|
9
|
+
// ── TaskCreate ────────────────────────────────────────────────────────────────
|
|
10
|
+
const TaskCreateInput = z.object({
|
|
11
|
+
subject: z.string().min(1).describe("A brief, actionable title for the task."),
|
|
12
|
+
description: z.string().describe("What needs to be done."),
|
|
13
|
+
activeForm: z.string().optional().describe('Present-continuous form shown while in_progress (e.g. "Running tests").'),
|
|
14
|
+
metadata: MetadataSchema.optional().describe("Arbitrary metadata to attach to the task."),
|
|
15
|
+
});
|
|
16
|
+
export function taskCreateTool(store) {
|
|
17
|
+
return defineTool({
|
|
18
|
+
name: TASK_CREATE_TOOL_NAME,
|
|
19
|
+
description: "Create a task in the structured task list. Returns its id. Use TaskUpdate to set status/dependencies later.",
|
|
20
|
+
params: TaskCreateInput,
|
|
21
|
+
resolve: (args) => ({
|
|
22
|
+
approvalRule: TASK_CREATE_TOOL_NAME,
|
|
23
|
+
accesses: ToolAccesses.none(),
|
|
24
|
+
display: { title: `Create task: ${args.subject}` },
|
|
25
|
+
run: async () => {
|
|
26
|
+
const task = await store.create({
|
|
27
|
+
subject: args.subject,
|
|
28
|
+
description: args.description,
|
|
29
|
+
activeForm: args.activeForm,
|
|
30
|
+
metadata: args.metadata,
|
|
31
|
+
});
|
|
32
|
+
return { content: [{ type: "text", text: `Task #${task.id} created: ${task.subject}` }], details: { task } };
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// ── TaskUpdate ────────────────────────────────────────────────────────────────
|
|
38
|
+
const TaskUpdateStatus = z.enum(["pending", "in_progress", "completed", "deleted"]);
|
|
39
|
+
const TaskUpdateInput = z.object({
|
|
40
|
+
taskId: z.string().describe("The id of the task to update."),
|
|
41
|
+
subject: z.string().optional().describe("New subject."),
|
|
42
|
+
description: z.string().optional().describe("New description."),
|
|
43
|
+
activeForm: z.string().optional().describe("New present-continuous form."),
|
|
44
|
+
status: TaskUpdateStatus.optional().describe('New status. "deleted" removes the task.'),
|
|
45
|
+
owner: z.string().optional().describe("New owner (agent id)."),
|
|
46
|
+
addBlocks: z.array(z.string()).optional().describe("Task ids this task should now block."),
|
|
47
|
+
addBlockedBy: z.array(z.string()).optional().describe("Task ids that should now block this task."),
|
|
48
|
+
metadata: MetadataSchema.optional().describe("Metadata to merge in."),
|
|
49
|
+
});
|
|
50
|
+
export function taskUpdateTool(store) {
|
|
51
|
+
return defineTool({
|
|
52
|
+
name: TASK_UPDATE_TOOL_NAME,
|
|
53
|
+
description: "Update a task: fields, status (including \"deleted\"), owner, or dependency edges (addBlocks/addBlockedBy).",
|
|
54
|
+
params: TaskUpdateInput,
|
|
55
|
+
resolve: (args) => ({
|
|
56
|
+
approvalRule: TASK_UPDATE_TOOL_NAME,
|
|
57
|
+
accesses: ToolAccesses.none(),
|
|
58
|
+
display: { title: args.status === "deleted" ? `Delete task #${args.taskId}` : `Update task #${args.taskId}` },
|
|
59
|
+
run: async () => {
|
|
60
|
+
const before = store.get(args.taskId);
|
|
61
|
+
if (before === undefined) {
|
|
62
|
+
return { content: [{ type: "text", text: `Unknown task id "${args.taskId}".` }], isError: true };
|
|
63
|
+
}
|
|
64
|
+
if (args.status === "deleted") {
|
|
65
|
+
await store.delete(args.taskId);
|
|
66
|
+
return { content: [{ type: "text", text: `Task #${args.taskId} deleted.` }], details: { taskId: args.taskId, deleted: true } };
|
|
67
|
+
}
|
|
68
|
+
const scalar = {
|
|
69
|
+
subject: args.subject,
|
|
70
|
+
description: args.description,
|
|
71
|
+
activeForm: args.activeForm,
|
|
72
|
+
owner: args.owner,
|
|
73
|
+
status: args.status,
|
|
74
|
+
metadata: args.metadata === undefined ? undefined : { ...before.metadata, ...args.metadata },
|
|
75
|
+
};
|
|
76
|
+
await store.update(args.taskId, scalar);
|
|
77
|
+
for (const blocked of args.addBlocks ?? [])
|
|
78
|
+
await store.block(args.taskId, blocked);
|
|
79
|
+
for (const blocker of args.addBlockedBy ?? [])
|
|
80
|
+
await store.block(blocker, args.taskId);
|
|
81
|
+
const after = store.get(args.taskId);
|
|
82
|
+
const updatedFields = updatedFieldNames(before, after);
|
|
83
|
+
const statusChange = before.status !== after.status ? { from: before.status, to: after.status } : undefined;
|
|
84
|
+
return {
|
|
85
|
+
content: [{ type: "text", text: `Task #${args.taskId} updated${updatedFields.length > 0 ? `: ${updatedFields.join(", ")}` : "."}` }],
|
|
86
|
+
details: { task: after, updatedFields, statusChange },
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// ── TaskList ──────────────────────────────────────────────────────────────────
|
|
93
|
+
export function taskListTool(store) {
|
|
94
|
+
return defineTool({
|
|
95
|
+
name: TASK_LIST_TOOL_NAME,
|
|
96
|
+
description: "List all tasks in the structured task list, with status and dependencies.",
|
|
97
|
+
params: z.object({}),
|
|
98
|
+
resolve: () => ({
|
|
99
|
+
approvalRule: TASK_LIST_TOOL_NAME,
|
|
100
|
+
accesses: ToolAccesses.none(),
|
|
101
|
+
display: { title: "List tasks" },
|
|
102
|
+
run: async () => {
|
|
103
|
+
const tasks = store.list();
|
|
104
|
+
return { content: [{ type: "text", text: renderTaskList(tasks) }], details: { tasks } };
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// ── TaskGet ───────────────────────────────────────────────────────────────────
|
|
110
|
+
export function taskGetTool(store) {
|
|
111
|
+
return defineTool({
|
|
112
|
+
name: TASK_GET_TOOL_NAME,
|
|
113
|
+
description: "Get one task by id, with its full description, status, and dependencies.",
|
|
114
|
+
params: z.object({ taskId: z.string().describe("The id of the task to read.") }),
|
|
115
|
+
resolve: (args) => ({
|
|
116
|
+
approvalRule: TASK_GET_TOOL_NAME,
|
|
117
|
+
accesses: ToolAccesses.none(),
|
|
118
|
+
display: { title: `Get task #${args.taskId}` },
|
|
119
|
+
run: async () => {
|
|
120
|
+
const task = store.get(args.taskId);
|
|
121
|
+
if (task === undefined) {
|
|
122
|
+
return { content: [{ type: "text", text: `Unknown task id "${args.taskId}".` }], isError: true };
|
|
123
|
+
}
|
|
124
|
+
return { content: [{ type: "text", text: renderTask(task) }], details: { task } };
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// ── Rendering ─────────────────────────────────────────────────────────────────
|
|
130
|
+
export function renderTaskList(tasks, title = "Task list:") {
|
|
131
|
+
if (tasks.length === 0)
|
|
132
|
+
return "Task list is empty.";
|
|
133
|
+
return [title, ...tasks.map(renderTaskRow)].join("\n");
|
|
134
|
+
}
|
|
135
|
+
function renderTaskRow(task) {
|
|
136
|
+
const deps = task.blockedBy.length > 0 ? ` (blockedBy: ${task.blockedBy.join(", ")})` : "";
|
|
137
|
+
const owner = task.owner !== undefined ? ` @${task.owner}` : "";
|
|
138
|
+
return ` #${task.id} [${task.status}] ${task.subject}${owner}${deps}`;
|
|
139
|
+
}
|
|
140
|
+
function renderTask(task) {
|
|
141
|
+
const lines = [`#${task.id} [${task.status}] ${task.subject}`, task.description];
|
|
142
|
+
if (task.owner !== undefined)
|
|
143
|
+
lines.push(`owner: ${task.owner}`);
|
|
144
|
+
if (task.blocks.length > 0)
|
|
145
|
+
lines.push(`blocks: ${task.blocks.join(", ")}`);
|
|
146
|
+
if (task.blockedBy.length > 0)
|
|
147
|
+
lines.push(`blockedBy: ${task.blockedBy.join(", ")}`);
|
|
148
|
+
return lines.join("\n");
|
|
149
|
+
}
|
|
150
|
+
function updatedFieldNames(before, after) {
|
|
151
|
+
const fields = [];
|
|
152
|
+
for (const key of ["subject", "description", "activeForm", "owner", "status"]) {
|
|
153
|
+
if (before[key] !== after[key])
|
|
154
|
+
fields.push(key);
|
|
155
|
+
}
|
|
156
|
+
if (JSON.stringify(before.blocks) !== JSON.stringify(after.blocks))
|
|
157
|
+
fields.push("blocks");
|
|
158
|
+
if (JSON.stringify(before.blockedBy) !== JSON.stringify(after.blockedBy))
|
|
159
|
+
fields.push("blockedBy");
|
|
160
|
+
if (JSON.stringify(before.metadata) !== JSON.stringify(after.metadata))
|
|
161
|
+
fields.push("metadata");
|
|
162
|
+
return fields;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Capability } from "../capability.ts";
|
|
2
|
+
import { TodoStore } from "./todo-store.ts";
|
|
3
|
+
export { TodoStore, TODO_LIST_TOOL_NAME } from "./todo-store.ts";
|
|
4
|
+
export type { TodoItem, TodoStatus, TodoDetails } from "./todo-store.ts";
|
|
5
|
+
export { todoListTool, renderTodoList } from "./tools.ts";
|
|
6
|
+
export { TodoListInjector } from "./injector.ts";
|
|
7
|
+
export declare function todoCapability(store?: TodoStore): Capability;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readSessionLog } from "../capability-state.js";
|
|
2
|
+
import { TodoListInjector } from "./injector.js";
|
|
3
|
+
import { TodoStore } from "./todo-store.js";
|
|
4
|
+
import { todoListTool } from "./tools.js";
|
|
5
|
+
export { TodoStore, TODO_LIST_TOOL_NAME } from "./todo-store.js";
|
|
6
|
+
export { todoListTool, renderTodoList } from "./tools.js";
|
|
7
|
+
export { TodoListInjector } from "./injector.js";
|
|
8
|
+
export function todoCapability(store = new TodoStore()) {
|
|
9
|
+
return {
|
|
10
|
+
name: "todo",
|
|
11
|
+
tools: [todoListTool(store)],
|
|
12
|
+
service: store,
|
|
13
|
+
injectors: [new TodoListInjector(store)],
|
|
14
|
+
// Rebuild the list from the session log (the latest TodoList result), not a KV side
|
|
15
|
+
// channel — so resume restores it and a fork reconstructs the list at the fork point.
|
|
16
|
+
openSession: async (ctx) => {
|
|
17
|
+
store.reconstruct(await readSessionLog(ctx));
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|