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,9 @@
|
|
|
1
|
+
import { BoundaryInjector, type InjectionContext, type InjectionResult } from "../injection.ts";
|
|
2
|
+
import type { TodoStore } from "./todo-store.ts";
|
|
3
|
+
export declare class TodoListInjector extends BoundaryInjector {
|
|
4
|
+
readonly id = "todo";
|
|
5
|
+
private readonly store;
|
|
6
|
+
constructor(store: TodoStore);
|
|
7
|
+
protected getInjection(ctx: InjectionContext): InjectionResult | null;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=injector.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BoundaryInjector } from "../injection.js";
|
|
2
|
+
import { renderTodoList, TODO_LIST_TOOL_NAME } from "./tools.js";
|
|
3
|
+
// Occasional-nudge cadence: remind only when the model hasn't touched the list
|
|
4
|
+
// for a while AND we haven't just reminded — so the reminder is a sparse, recorded nudge, not a
|
|
5
|
+
// per-turn state mirror (the current list already rides in each TodoList tool result).
|
|
6
|
+
const TURNS_SINCE_WRITE = 10;
|
|
7
|
+
const TURNS_BETWEEN_REMINDERS = 10;
|
|
8
|
+
export class TodoListInjector extends BoundaryInjector {
|
|
9
|
+
id = "todo";
|
|
10
|
+
store;
|
|
11
|
+
constructor(store) {
|
|
12
|
+
super();
|
|
13
|
+
this.store = store;
|
|
14
|
+
}
|
|
15
|
+
getInjection(ctx) {
|
|
16
|
+
this.restoreInjectedAt(ctx, ["todo_reminder"]);
|
|
17
|
+
const todos = this.store.get();
|
|
18
|
+
if (todos.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
const turnsSinceWrite = assistantTurnsSinceTodoWrite(ctx.history);
|
|
21
|
+
// Reminder spacing is tracked by `injectedAt` (the position of the last reminder) + role
|
|
22
|
+
// counting — no need to read message origin, so this holds under origin-on-Entry-only.
|
|
23
|
+
const turnsSinceReminder = this.injectedAt === null ? Number.POSITIVE_INFINITY : assistantTurnsSince(ctx.history, this.injectedAt);
|
|
24
|
+
if (turnsSinceWrite < TURNS_SINCE_WRITE || turnsSinceReminder < TURNS_BETWEEN_REMINDERS)
|
|
25
|
+
return null;
|
|
26
|
+
return {
|
|
27
|
+
variant: "todo_reminder",
|
|
28
|
+
text: [
|
|
29
|
+
"The TodoList tool has not been updated recently. If you are working on tasks that benefit from progress tracking, consider using TodoList to update task status. Also consider clearing or rewriting the list if it has gone stale. Only use it if relevant — this is a gentle reminder, ignore if not applicable. Never mention this reminder to the user.",
|
|
30
|
+
"",
|
|
31
|
+
"Current todo list:",
|
|
32
|
+
renderTodoList(todos),
|
|
33
|
+
].join("\n"),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Assistant messages between `from` (exclusive) and the end of history. */
|
|
38
|
+
function assistantTurnsSince(history, from) {
|
|
39
|
+
let count = 0;
|
|
40
|
+
for (let i = from + 1; i < history.length; i++) {
|
|
41
|
+
if (history[i]?.role === "assistant")
|
|
42
|
+
count += 1;
|
|
43
|
+
}
|
|
44
|
+
return count;
|
|
45
|
+
}
|
|
46
|
+
/** Assistant messages since the last TodoList write (a TodoList tool call or its result).
|
|
47
|
+
* `Infinity` when there is no write in history (so a fresh list nudges only after enough turns). */
|
|
48
|
+
function assistantTurnsSinceTodoWrite(history) {
|
|
49
|
+
let count = 0;
|
|
50
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
51
|
+
const msg = history[i];
|
|
52
|
+
if (msg === undefined)
|
|
53
|
+
continue;
|
|
54
|
+
if (isTodoWrite(msg))
|
|
55
|
+
return count;
|
|
56
|
+
if (msg.role === "assistant")
|
|
57
|
+
count += 1;
|
|
58
|
+
}
|
|
59
|
+
return Number.POSITIVE_INFINITY;
|
|
60
|
+
}
|
|
61
|
+
function isTodoWrite(msg) {
|
|
62
|
+
if (msg.role === "toolResult")
|
|
63
|
+
return msg.toolName === TODO_LIST_TOOL_NAME;
|
|
64
|
+
if (msg.role === "assistant")
|
|
65
|
+
return msg.content.some((p) => p.type === "toolCall" && p.name === TODO_LIST_TOOL_NAME);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=injector.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentRecord } from "../../store/index.ts";
|
|
2
|
+
export declare const TODO_LIST_TOOL_NAME = "TodoList";
|
|
3
|
+
export type TodoStatus = "pending" | "in_progress" | "done";
|
|
4
|
+
export interface TodoItem {
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly status: TodoStatus;
|
|
7
|
+
}
|
|
8
|
+
/** Snapshot carried in the TodoList tool result `details`, folded back on session open. */
|
|
9
|
+
export interface TodoDetails {
|
|
10
|
+
readonly todos: readonly TodoItem[];
|
|
11
|
+
}
|
|
12
|
+
export declare class TodoStore {
|
|
13
|
+
private todos;
|
|
14
|
+
get(): readonly TodoItem[];
|
|
15
|
+
set(todos: readonly TodoItem[]): readonly TodoItem[];
|
|
16
|
+
/** Rebuild from the log: the latest TodoList tool result is the current list. */
|
|
17
|
+
reconstruct(entries: readonly AgentRecord[]): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=todo-store.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { latestToolDetails } from "../capability-state.js";
|
|
2
|
+
export const TODO_LIST_TOOL_NAME = "TodoList";
|
|
3
|
+
export class TodoStore {
|
|
4
|
+
todos = [];
|
|
5
|
+
get() {
|
|
6
|
+
return this.todos;
|
|
7
|
+
}
|
|
8
|
+
set(todos) {
|
|
9
|
+
this.todos = normalizeTodos(todos);
|
|
10
|
+
return this.todos;
|
|
11
|
+
}
|
|
12
|
+
/** Rebuild from the log: the latest TodoList tool result is the current list. */
|
|
13
|
+
reconstruct(entries) {
|
|
14
|
+
const details = latestToolDetails(entries, TODO_LIST_TOOL_NAME);
|
|
15
|
+
this.todos = isTodoDetails(details) ? normalizeTodos(details.todos) : [];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function normalizeTodos(todos) {
|
|
19
|
+
return todos.map((todo) => ({ title: todo.title, status: todo.status }));
|
|
20
|
+
}
|
|
21
|
+
function isTodoDetails(value) {
|
|
22
|
+
if (typeof value !== "object" || value === null)
|
|
23
|
+
return false;
|
|
24
|
+
const todos = value.todos;
|
|
25
|
+
return Array.isArray(todos) && todos.every(isTodoItem);
|
|
26
|
+
}
|
|
27
|
+
function isTodoItem(item) {
|
|
28
|
+
if (typeof item !== "object" || item === null)
|
|
29
|
+
return false;
|
|
30
|
+
const record = item;
|
|
31
|
+
return typeof record["title"] === "string" && isTodoStatus(record["status"]);
|
|
32
|
+
}
|
|
33
|
+
function isTodoStatus(value) {
|
|
34
|
+
return value === "pending" || value === "in_progress" || value === "done";
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=todo-store.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Tool } from "../../tool/types.ts";
|
|
2
|
+
import type { TodoItem, TodoStore } from "./todo-store.ts";
|
|
3
|
+
export { TODO_LIST_TOOL_NAME } from "./todo-store.ts";
|
|
4
|
+
export declare function todoListTool(store: TodoStore): Tool;
|
|
5
|
+
export declare function renderTodoList(todos: readonly TodoItem[], title?: string): string;
|
|
6
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "../../tool/define.js";
|
|
3
|
+
import { ToolAccesses } from "../../tool/access.js";
|
|
4
|
+
import { TODO_LIST_TOOL_NAME } from "./todo-store.js";
|
|
5
|
+
export { TODO_LIST_TOOL_NAME } from "./todo-store.js";
|
|
6
|
+
const TODO_LIST_WRITE_REMINDER = "Ensure that you continue to use the todo list to track progress. Mark tasks done immediately after finishing them, and keep exactly one task in_progress when work is underway.";
|
|
7
|
+
const TodoItemSchema = z.object({
|
|
8
|
+
title: z.string().min(1).describe("Short, actionable title for the todo."),
|
|
9
|
+
status: z.enum(["pending", "in_progress", "done"]).describe("Current status of the todo."),
|
|
10
|
+
});
|
|
11
|
+
const TodoListInput = z.object({
|
|
12
|
+
todos: z
|
|
13
|
+
.array(TodoItemSchema)
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("The updated todo list. Omit to read the current todo list without making changes. Pass an empty array to clear the list."),
|
|
16
|
+
});
|
|
17
|
+
const TODO_LIST_DESCRIPTION = [
|
|
18
|
+
"Use this tool to maintain a structured TODO list as you work through a multi-step task.",
|
|
19
|
+
"Call with `todos: [...]` to replace the full list, with no arguments to read it, and with `todos: []` to clear it.",
|
|
20
|
+
"Statuses are pending, in_progress, and done. Keep exactly one task in_progress when work is underway.",
|
|
21
|
+
].join("\n");
|
|
22
|
+
export function todoListTool(store) {
|
|
23
|
+
return defineTool({
|
|
24
|
+
name: TODO_LIST_TOOL_NAME,
|
|
25
|
+
description: TODO_LIST_DESCRIPTION,
|
|
26
|
+
params: TodoListInput,
|
|
27
|
+
resolve: (args) => {
|
|
28
|
+
const title = args.todos === undefined
|
|
29
|
+
? "Read todo list"
|
|
30
|
+
: args.todos.length === 0
|
|
31
|
+
? "Clear todo list"
|
|
32
|
+
: "Update todo list";
|
|
33
|
+
return {
|
|
34
|
+
approvalRule: TODO_LIST_TOOL_NAME,
|
|
35
|
+
accesses: ToolAccesses.none(),
|
|
36
|
+
display: { title },
|
|
37
|
+
run: async () => {
|
|
38
|
+
// Read mode carries the current list too, so a resumed/forked session reconstructs
|
|
39
|
+
// from the latest TodoList result even when the last write was on a parent node.
|
|
40
|
+
if (args.todos === undefined)
|
|
41
|
+
return todoResult(renderTodoList(store.get()), store.get());
|
|
42
|
+
const stored = store.set(args.todos);
|
|
43
|
+
if (stored.length === 0)
|
|
44
|
+
return todoResult("Todo list cleared.", stored);
|
|
45
|
+
return todoResult(`Todo list updated.\n${renderTodoList(stored)}\n\n${TODO_LIST_WRITE_REMINDER}`, stored);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export function renderTodoList(todos, title = "Current todo list:") {
|
|
52
|
+
if (todos.length === 0)
|
|
53
|
+
return "Todo list is empty.";
|
|
54
|
+
return [title, ...todos.map((todo) => ` ${statusMarker(todo.status)} ${todo.title}`)].join("\n");
|
|
55
|
+
}
|
|
56
|
+
function statusMarker(status) {
|
|
57
|
+
switch (status) {
|
|
58
|
+
case "pending":
|
|
59
|
+
return "[pending]";
|
|
60
|
+
case "in_progress":
|
|
61
|
+
return "[in_progress]";
|
|
62
|
+
case "done":
|
|
63
|
+
return "[done]";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function todoResult(text, todos) {
|
|
67
|
+
// The list snapshot rides in `details` so the log is the single source of truth.
|
|
68
|
+
return { content: [{ type: "text", text }], details: { todos } };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Tool } from "../tool/types.ts";
|
|
2
|
+
import type { CapabilityContext } from "./capability.ts";
|
|
3
|
+
export interface ToolProvider {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
listTools(ctx: CapabilityContext): Promise<readonly Tool[]> | readonly Tool[];
|
|
6
|
+
start?(ctx: CapabilityContext): Promise<void> | void;
|
|
7
|
+
stop?(): Promise<void> | void;
|
|
8
|
+
}
|
|
9
|
+
export declare function staticToolProvider(id: string, tools: readonly Tool[]): ToolProvider;
|
|
10
|
+
export declare function tagToolSource(tool: Tool, source: string): void;
|
|
11
|
+
export declare function toolSource(tool: Tool): string | undefined;
|
|
12
|
+
//# sourceMappingURL=tool-provider.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function staticToolProvider(id, tools) {
|
|
2
|
+
return { id, listTools: () => tools };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Provenance for dynamically contributed tools, kept off the `Tool` itself so the tool shape
|
|
6
|
+
* stays a plain value. Toolset assembly reads it to name the culprit when a contributed tool
|
|
7
|
+
* collides with one the agent already owns — without that, a provider's tool would either
|
|
8
|
+
* silently lose or silently win.
|
|
9
|
+
*
|
|
10
|
+
* Tagging is optional: an untagged tool is treated as trusted (agent-owned or first-party) and
|
|
11
|
+
* keeps its name.
|
|
12
|
+
*/
|
|
13
|
+
const toolSources = new WeakMap();
|
|
14
|
+
export function tagToolSource(tool, source) {
|
|
15
|
+
toolSources.set(tool, source);
|
|
16
|
+
}
|
|
17
|
+
export function toolSource(tool) {
|
|
18
|
+
return toolSources.get(tool);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=tool-provider.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Machine } from "../../tool/machine.ts";
|
|
2
|
+
import { type HookBlockResult, type HookDef, type HookEventType, type HookTriggerArgs } from "./types.ts";
|
|
3
|
+
export declare class HookEngine {
|
|
4
|
+
private readonly hooks;
|
|
5
|
+
private machine;
|
|
6
|
+
constructor(hooks: readonly HookDef[]);
|
|
7
|
+
attachMachine(machine: Machine): void;
|
|
8
|
+
has(event: HookEventType): boolean;
|
|
9
|
+
triggerBlock(event: HookEventType, args?: HookTriggerArgs): Promise<HookBlockResult>;
|
|
10
|
+
trigger(event: HookEventType, args?: HookTriggerArgs): Promise<string>;
|
|
11
|
+
fireAndForgetTrigger(event: HookEventType, args?: HookTriggerArgs): void;
|
|
12
|
+
private matching;
|
|
13
|
+
private matches;
|
|
14
|
+
/**
|
|
15
|
+
* The hook's input data goes in on stdin and its timeout/cancellation are stated as
|
|
16
|
+
* intent, so the backend enforces both with its own kill. A timeout still THROWS rather
|
|
17
|
+
* than returning a verdict: every caller treats a thrown hook as "no opinion", and a
|
|
18
|
+
* timed-out hook has no opinion to report.
|
|
19
|
+
*/
|
|
20
|
+
private runHook;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { DEFAULT_HOOK_TIMEOUT_MS, } from "./types.js";
|
|
2
|
+
export class HookEngine {
|
|
3
|
+
hooks;
|
|
4
|
+
machine = null;
|
|
5
|
+
constructor(hooks) {
|
|
6
|
+
this.hooks = hooks;
|
|
7
|
+
}
|
|
8
|
+
attachMachine(machine) {
|
|
9
|
+
this.machine = machine;
|
|
10
|
+
}
|
|
11
|
+
has(event) {
|
|
12
|
+
return this.hooks.some((h) => h.event === event);
|
|
13
|
+
}
|
|
14
|
+
async triggerBlock(event, args = {}) {
|
|
15
|
+
for (const hook of this.matching(event, args.matcherValue)) {
|
|
16
|
+
const result = await this.runHook(hook, args).catch(() => undefined);
|
|
17
|
+
if (result?.block)
|
|
18
|
+
return { block: true, reason: result.reason };
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
async trigger(event, args = {}) {
|
|
23
|
+
const out = [];
|
|
24
|
+
for (const hook of this.matching(event, args.matcherValue)) {
|
|
25
|
+
const result = await this.runHook(hook, args).catch(() => undefined);
|
|
26
|
+
if (result?.stdout)
|
|
27
|
+
out.push(result.stdout);
|
|
28
|
+
}
|
|
29
|
+
return out.join("\n");
|
|
30
|
+
}
|
|
31
|
+
fireAndForgetTrigger(event, args = {}) {
|
|
32
|
+
for (const hook of this.matching(event, args.matcherValue)) {
|
|
33
|
+
void this.runHook(hook, args).catch(() => undefined);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
matching(event, matcherValue) {
|
|
37
|
+
const seen = new Set();
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const hook of this.hooks) {
|
|
40
|
+
if (hook.event !== event)
|
|
41
|
+
continue;
|
|
42
|
+
if (hook.matcher !== undefined && !this.matches(hook.matcher, matcherValue))
|
|
43
|
+
continue;
|
|
44
|
+
if (seen.has(hook.command))
|
|
45
|
+
continue;
|
|
46
|
+
seen.add(hook.command);
|
|
47
|
+
out.push(hook);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
matches(pattern, value) {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return false;
|
|
54
|
+
try {
|
|
55
|
+
return new RegExp(pattern).test(value);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false; // a malformed matcher never matches (fail closed on the matcher only)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The hook's input data goes in on stdin and its timeout/cancellation are stated as
|
|
63
|
+
* intent, so the backend enforces both with its own kill. A timeout still THROWS rather
|
|
64
|
+
* than returning a verdict: every caller treats a thrown hook as "no opinion", and a
|
|
65
|
+
* timed-out hook has no opinion to report.
|
|
66
|
+
*/
|
|
67
|
+
async runHook(hook, args) {
|
|
68
|
+
if (!this.machine)
|
|
69
|
+
throw new Error("HookEngine has no machine attached.");
|
|
70
|
+
const timeoutMs = hook.timeout ?? DEFAULT_HOOK_TIMEOUT_MS;
|
|
71
|
+
const shell = this.machine.osEnv.shellPath || "/bin/sh";
|
|
72
|
+
const result = await this.machine.run([shell, "-c", hook.command], {
|
|
73
|
+
stdin: JSON.stringify(args.inputData ?? {}),
|
|
74
|
+
timeoutMs,
|
|
75
|
+
...(args.signal !== undefined ? { signal: args.signal } : {}),
|
|
76
|
+
});
|
|
77
|
+
if (result.timedOut)
|
|
78
|
+
throw new Error(`hook timed out after ${timeoutMs}ms`);
|
|
79
|
+
// No exit status = killed (abort) or a backend that cannot report one. Neither is a
|
|
80
|
+
// verdict, so treat it the same as a throw rather than inventing a code.
|
|
81
|
+
if (result.exitCode === undefined)
|
|
82
|
+
throw new Error("hook did not report an exit status");
|
|
83
|
+
return interpret(result.stdout, result.exitCode);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function interpret(stdout, exitCode) {
|
|
87
|
+
let block = exitCode !== 0;
|
|
88
|
+
let reason = exitCode !== 0 ? stdout.trim() || `hook exited ${exitCode}` : undefined;
|
|
89
|
+
const trimmed = stdout.trim();
|
|
90
|
+
if (trimmed.startsWith("{")) {
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse(trimmed);
|
|
93
|
+
if (parsed.block === true || parsed.action === "block" || parsed.decision === "block") {
|
|
94
|
+
block = true;
|
|
95
|
+
if (typeof parsed.reason === "string")
|
|
96
|
+
reason = parsed.reason;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
/* not JSON — treat as plain stdout */
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { block, reason, stdout, exitCode };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Capability } from "../capability.ts";
|
|
2
|
+
import type { HookDef } from "./types.ts";
|
|
3
|
+
export { HookEngine } from "./engine.ts";
|
|
4
|
+
export type { HookDef, HookEventType } from "./types.ts";
|
|
5
|
+
export { HOOK_EVENT_TYPES } from "./types.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Shell hooks (the `PreToolUse`/`Stop`/… lifecycle contract) are a peer capability of
|
|
8
|
+
* the extension runtime, not a client of it. The two intervention points that need a return
|
|
9
|
+
* value are a permission policy and a loop hook; everything else is pure observation, which
|
|
10
|
+
* subscribes to the session event sink directly — no extension registry in between.
|
|
11
|
+
*/
|
|
12
|
+
export declare function userHooksCapability(hooks: readonly HookDef[]): Capability;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { BoundaryInjector } from "../injection.js";
|
|
2
|
+
import { HookEngine } from "./engine.js";
|
|
3
|
+
export { HookEngine } from "./engine.js";
|
|
4
|
+
export { HOOK_EVENT_TYPES } from "./types.js";
|
|
5
|
+
function preToolCallHookPolicy(engine) {
|
|
6
|
+
return {
|
|
7
|
+
name: "pre-tool-call-hook",
|
|
8
|
+
async evaluate(ctx) {
|
|
9
|
+
if (!engine.has("PreToolUse"))
|
|
10
|
+
return undefined;
|
|
11
|
+
const result = await engine.triggerBlock("PreToolUse", {
|
|
12
|
+
matcherValue: ctx.toolCall.name,
|
|
13
|
+
inputData: {
|
|
14
|
+
tool_name: ctx.toolCall.name,
|
|
15
|
+
tool_input: ctx.args,
|
|
16
|
+
approval_rule: ctx.plan.approvalRule,
|
|
17
|
+
},
|
|
18
|
+
signal: ctx.signal,
|
|
19
|
+
});
|
|
20
|
+
if (result?.block)
|
|
21
|
+
return { kind: "deny", message: result.reason ?? "Blocked by a PreToolUse hook." };
|
|
22
|
+
return undefined;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
class SessionStartInjector extends BoundaryInjector {
|
|
27
|
+
id = "user_hooks_session_start";
|
|
28
|
+
getOutput;
|
|
29
|
+
constructor(getOutput) {
|
|
30
|
+
super();
|
|
31
|
+
this.getOutput = getOutput;
|
|
32
|
+
}
|
|
33
|
+
getInjection(ctx) {
|
|
34
|
+
if (this.restoreInjectedAt(ctx, ["session_start"]))
|
|
35
|
+
return null;
|
|
36
|
+
const output = this.getOutput();
|
|
37
|
+
return output && output.trim().length > 0 ? { text: output, variant: "session_start" } : null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Shell hooks (the `PreToolUse`/`Stop`/… lifecycle contract) are a peer capability of
|
|
42
|
+
* the extension runtime, not a client of it. The two intervention points that need a return
|
|
43
|
+
* value are a permission policy and a loop hook; everything else is pure observation, which
|
|
44
|
+
* subscribes to the session event sink directly — no extension registry in between.
|
|
45
|
+
*/
|
|
46
|
+
export function userHooksCapability(hooks) {
|
|
47
|
+
const engine = new HookEngine(hooks);
|
|
48
|
+
let sessionStartOutput = null;
|
|
49
|
+
let continuedViaStop = false;
|
|
50
|
+
let unsubscribe;
|
|
51
|
+
return {
|
|
52
|
+
name: "user-hooks",
|
|
53
|
+
policies: [preToolCallHookPolicy(engine)],
|
|
54
|
+
injectors: [new SessionStartInjector(() => sessionStartOutput)],
|
|
55
|
+
hooks: {
|
|
56
|
+
// Stop — a hook may force exactly one more turn (by design: at most one continuation).
|
|
57
|
+
shouldContinueAfterStop: async (ctx) => {
|
|
58
|
+
if (continuedViaStop || ctx.stopReason !== "end_turn" || !engine.has("Stop"))
|
|
59
|
+
return undefined;
|
|
60
|
+
const result = await engine.triggerBlock("Stop", { inputData: { stop_reason: ctx.stopReason }, signal: ctx.signal });
|
|
61
|
+
if (result?.block) {
|
|
62
|
+
continuedViaStop = true;
|
|
63
|
+
return { continue: true };
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
service: engine,
|
|
69
|
+
openSession: async (ctx) => {
|
|
70
|
+
engine.attachMachine(ctx.machine);
|
|
71
|
+
if (engine.has("SessionStart")) {
|
|
72
|
+
sessionStartOutput = await engine
|
|
73
|
+
.trigger("SessionStart", { inputData: { session_id: ctx.sessionId }, signal: ctx.signal })
|
|
74
|
+
.catch(() => null);
|
|
75
|
+
}
|
|
76
|
+
unsubscribe = ctx.events.subscribe((event) => observeShellHookEvent(engine, event));
|
|
77
|
+
},
|
|
78
|
+
closeSession: () => {
|
|
79
|
+
unsubscribe?.();
|
|
80
|
+
unsubscribe = undefined;
|
|
81
|
+
if (engine.has("SessionEnd"))
|
|
82
|
+
engine.fireAndForgetTrigger("SessionEnd", {});
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function observeShellHookEvent(engine, event) {
|
|
87
|
+
switch (event.type) {
|
|
88
|
+
case "agent.started":
|
|
89
|
+
if (event.address.includes("/") && engine.has("SubagentStart")) {
|
|
90
|
+
engine.fireAndForgetTrigger("SubagentStart", { matcherValue: event.agent, inputData: { agent: event.agent, address: event.address } });
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case "agent.ended":
|
|
94
|
+
if (event.address.includes("/") && engine.has("SubagentStop")) {
|
|
95
|
+
engine.fireAndForgetTrigger("SubagentStop", { matcherValue: event.agent, inputData: { agent: event.agent, address: event.address } });
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
case "tool.result": {
|
|
99
|
+
const hookEvent = event.isError ? "PostToolUseFailure" : "PostToolUse";
|
|
100
|
+
if (engine.has(hookEvent)) {
|
|
101
|
+
engine.fireAndForgetTrigger(hookEvent, {
|
|
102
|
+
matcherValue: event.toolName,
|
|
103
|
+
inputData: { tool_name: event.toolName, is_error: event.isError },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "compaction.started":
|
|
109
|
+
if (engine.has("PreCompact"))
|
|
110
|
+
engine.fireAndForgetTrigger("PreCompact", { inputData: { trigger: event.trigger } });
|
|
111
|
+
break;
|
|
112
|
+
case "compaction.completed":
|
|
113
|
+
if (engine.has("PostCompact")) {
|
|
114
|
+
engine.fireAndForgetTrigger("PostCompact", { inputData: { tokens_before: event.tokensBefore, tokens_after: event.tokensAfter, compacted_count: event.compactedCount } });
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case "warning":
|
|
118
|
+
case "error":
|
|
119
|
+
if (engine.has("Notification"))
|
|
120
|
+
engine.fireAndForgetTrigger("Notification", { matcherValue: event.message, inputData: { level: event.type, message: event.message } });
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const HOOK_EVENT_TYPES: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PermissionRequest", "PermissionResult", "UserPromptSubmit", "Stop", "StopFailure", "SessionStart", "SessionEnd", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "Notification"];
|
|
2
|
+
export type HookEventType = (typeof HOOK_EVENT_TYPES)[number];
|
|
3
|
+
export declare const DEFAULT_HOOK_TIMEOUT_MS = 30000;
|
|
4
|
+
export interface HookDef {
|
|
5
|
+
readonly event: HookEventType;
|
|
6
|
+
readonly matcher?: string;
|
|
7
|
+
readonly command: string;
|
|
8
|
+
readonly timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
export type HookInputData = Readonly<Record<string, unknown>>;
|
|
11
|
+
export interface HookTriggerArgs {
|
|
12
|
+
readonly matcherValue?: string;
|
|
13
|
+
readonly inputData?: HookInputData;
|
|
14
|
+
readonly signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
export interface HookRunResult {
|
|
17
|
+
readonly block: boolean;
|
|
18
|
+
readonly reason?: string;
|
|
19
|
+
readonly stdout: string;
|
|
20
|
+
readonly exitCode: number;
|
|
21
|
+
}
|
|
22
|
+
export type HookBlockResult = {
|
|
23
|
+
readonly block: true;
|
|
24
|
+
readonly reason?: string;
|
|
25
|
+
} | undefined;
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const HOOK_EVENT_TYPES = [
|
|
2
|
+
"PreToolUse",
|
|
3
|
+
"PostToolUse",
|
|
4
|
+
"PostToolUseFailure",
|
|
5
|
+
"PermissionRequest",
|
|
6
|
+
"PermissionResult",
|
|
7
|
+
"UserPromptSubmit",
|
|
8
|
+
"Stop",
|
|
9
|
+
"StopFailure",
|
|
10
|
+
"SessionStart",
|
|
11
|
+
"SessionEnd",
|
|
12
|
+
"SubagentStart",
|
|
13
|
+
"SubagentStop",
|
|
14
|
+
"PreCompact",
|
|
15
|
+
"PostCompact",
|
|
16
|
+
"Notification",
|
|
17
|
+
];
|
|
18
|
+
export const DEFAULT_HOOK_TIMEOUT_MS = 30_000;
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow capability — exposes the WorkflowManager as a session service
|
|
3
|
+
* (`session.workflow`), mirroring how `background` exposes the BackgroundManager.
|
|
4
|
+
*
|
|
5
|
+
* It contributes NO tools: the `Workflow` tool is built by the Runner (it needs
|
|
6
|
+
* runLoop to spawn subagents), and reaches this service through the session to read
|
|
7
|
+
* its configured directories and persist run snapshots. The capability's job is
|
|
8
|
+
* purely to make the management/read machine available to upper layers and the
|
|
9
|
+
* `/workflows` command.
|
|
10
|
+
*/
|
|
11
|
+
import type { Capability } from "../capability.ts";
|
|
12
|
+
import { WorkflowManager } from "../../agent/workflow/manager.ts";
|
|
13
|
+
export { WorkflowManager } from "../../agent/workflow/manager.ts";
|
|
14
|
+
export type { WorkflowSnapshot, WorkflowSnapshotStatus } from "../../agent/workflow/snapshot.ts";
|
|
15
|
+
export declare function workflowCapability(manager?: WorkflowManager): Capability;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WorkflowManager } from "../../agent/workflow/manager.js";
|
|
2
|
+
export { WorkflowManager } from "../../agent/workflow/manager.js";
|
|
3
|
+
export function workflowCapability(manager = new WorkflowManager()) {
|
|
4
|
+
return {
|
|
5
|
+
name: "workflow",
|
|
6
|
+
service: manager,
|
|
7
|
+
openSession: (ctx) => {
|
|
8
|
+
// Bookkeeping goes through the SessionStore, never the Machine: without a
|
|
9
|
+
// durable store the manager stays on its in-memory store for the session's lifetime.
|
|
10
|
+
if (ctx.store !== undefined)
|
|
11
|
+
manager.attachStore(ctx.store);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Session } from "../agent/session.ts";
|
|
2
|
+
export interface CommandContext {
|
|
3
|
+
readonly session: Session;
|
|
4
|
+
}
|
|
5
|
+
export interface CommandResult<T = unknown> {
|
|
6
|
+
readonly ok: boolean;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
readonly data?: T;
|
|
9
|
+
}
|
|
10
|
+
export interface ParsedCommand {
|
|
11
|
+
readonly raw: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly args: string;
|
|
14
|
+
}
|
|
15
|
+
export interface HeadlessCommand {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly aliases?: readonly string[];
|
|
18
|
+
readonly description: string;
|
|
19
|
+
run(ctx: CommandContext, args: string, parsed: ParsedCommand): Promise<CommandResult> | CommandResult;
|
|
20
|
+
}
|
|
21
|
+
export declare class CommandRegistry {
|
|
22
|
+
private readonly commands;
|
|
23
|
+
register(command: HeadlessCommand): void;
|
|
24
|
+
list(session?: Session): readonly HeadlessCommand[];
|
|
25
|
+
run(input: string, ctx: CommandContext): Promise<CommandResult>;
|
|
26
|
+
}
|
|
27
|
+
export declare function parseCommand(input: string): ParsedCommand;
|
|
28
|
+
export declare function createExtensionCommandRegistry(): CommandRegistry;
|
|
29
|
+
export declare function registerExtensionCommands(registry: CommandRegistry): void;
|
|
30
|
+
export declare function registerCapabilityCommands(registry: CommandRegistry): void;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|