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,233 @@
|
|
|
1
|
+
import { isSensitiveFile } from "../tool/policies/sensitive.js";
|
|
2
|
+
import { isWithinDirectory, relativePathParts } from "../tool/policies/path-access.js";
|
|
3
|
+
import { isReadOnlyBashCommand } from "../tool/support/bash-read-only.js";
|
|
4
|
+
import { findGitWorkTreeMarker, isGitControlPath, } from "../tool/support/git-worktree.js";
|
|
5
|
+
import { matchPermissionRule } from "./matches-rule.js";
|
|
6
|
+
const USER_CONFIGURED_SCOPES = new Set(["turn-override", "project", "user"]);
|
|
7
|
+
const DEFAULT_APPROVE_TOOLS = new Set([
|
|
8
|
+
"Read", "Grep", "Glob", "SetTodoList", "TodoList", "BackgroundList", "BackgroundOutput",
|
|
9
|
+
"TaskCreate", "TaskUpdate", "TaskList", "TaskGet",
|
|
10
|
+
"CronList", "WebSearch", "FetchURL", "Agent", "AskUserQuestion", "Skill",
|
|
11
|
+
"GetGoal", "SetGoalBudget", "UpdateGoal",
|
|
12
|
+
// Workflow orchestrates subagents (like Agent); StructuredOutput is the schema
|
|
13
|
+
// tool the Workflow runtime injects into a subagent — neither needs approval.
|
|
14
|
+
"Workflow", "StructuredOutput",
|
|
15
|
+
]);
|
|
16
|
+
function firstMatchingRule(ctx, rules, decision) {
|
|
17
|
+
for (const rule of rules) {
|
|
18
|
+
if (rule.decision !== decision)
|
|
19
|
+
continue;
|
|
20
|
+
const match = matchPermissionRule({ rule, toolName: ctx.toolCall.name, execution: ctx.plan });
|
|
21
|
+
if (match !== undefined)
|
|
22
|
+
return match;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function userRules(state) {
|
|
27
|
+
return state.rules().filter((rule) => USER_CONFIGURED_SCOPES.has(rule.scope));
|
|
28
|
+
}
|
|
29
|
+
function userRuleReason(decision, match) {
|
|
30
|
+
return { rule_decision: decision, has_rule_args: match.hasRuleArgs, match_strategy: match.strategy };
|
|
31
|
+
}
|
|
32
|
+
function fileAccesses(ctx) {
|
|
33
|
+
return (ctx.plan.accesses ?? []).filter((access) => access.kind === "file");
|
|
34
|
+
}
|
|
35
|
+
function writeFileAccesses(ctx) {
|
|
36
|
+
return fileAccesses(ctx).filter((a) => a.operation === "write" || a.operation === "readwrite");
|
|
37
|
+
}
|
|
38
|
+
function fileAccessReason(access, extra) {
|
|
39
|
+
return { file_access_operation: access.operation, recursive: access.recursive === true, ...extra };
|
|
40
|
+
}
|
|
41
|
+
function staged(name) {
|
|
42
|
+
return { name, evaluate: () => undefined };
|
|
43
|
+
}
|
|
44
|
+
export const STAGED_POLICY_SLOTS = new Set([
|
|
45
|
+
"pre-tool-call-hook",
|
|
46
|
+
"plan-mode-guard-deny",
|
|
47
|
+
"exit-plan-mode-review-ask",
|
|
48
|
+
"plan-mode-tool-approve",
|
|
49
|
+
]);
|
|
50
|
+
export function createPolicies(state, overrides) {
|
|
51
|
+
const slot = (name) => overrides?.get(name) ?? staged(name);
|
|
52
|
+
// Shared, memoized git-work-tree marker lookup (one walk per manager; cwd is fixed). Used by
|
|
53
|
+
// both git-control-path-access-ask and git-cwd-write-approve so they probe at most once.
|
|
54
|
+
let markerProbe;
|
|
55
|
+
const gitMarker = () => {
|
|
56
|
+
const machine = state.machine?.();
|
|
57
|
+
const cwd = state.cwd();
|
|
58
|
+
if (machine === undefined || cwd.length === 0)
|
|
59
|
+
return Promise.resolve(null);
|
|
60
|
+
markerProbe ??= findGitWorkTreeMarker(machine, cwd).catch(() => null);
|
|
61
|
+
return markerProbe;
|
|
62
|
+
};
|
|
63
|
+
return [
|
|
64
|
+
// PreToolUse hook returned a block → deny. [STAGED slot: user HookEngine]
|
|
65
|
+
slot("pre-tool-call-hook"),
|
|
66
|
+
// yolo mode + AskUserQuestion → deny.
|
|
67
|
+
{
|
|
68
|
+
name: "yolo-mode-ask-user-question-deny",
|
|
69
|
+
evaluate(ctx) {
|
|
70
|
+
if (state.mode() !== "yolo" || ctx.toolCall.name !== "AskUserQuestion")
|
|
71
|
+
return undefined;
|
|
72
|
+
return { kind: "deny", message: "AskUserQuestion is not allowed in yolo mode.", reason: { source: "yolo_mode_ask" } };
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
slot("plan-mode-guard-deny"),
|
|
76
|
+
// User-configured deny rule matches → deny.
|
|
77
|
+
{
|
|
78
|
+
name: "user-configured-deny",
|
|
79
|
+
evaluate(ctx) {
|
|
80
|
+
const match = firstMatchingRule(ctx, userRules(state), "deny");
|
|
81
|
+
if (match === undefined)
|
|
82
|
+
return undefined;
|
|
83
|
+
const suffix = match.rule.reason ? ` Reason: ${match.rule.reason}` : "";
|
|
84
|
+
return {
|
|
85
|
+
kind: "deny",
|
|
86
|
+
reason: userRuleReason("deny", match),
|
|
87
|
+
message: `Tool "${ctx.toolCall.name}" was denied by permission rule.${suffix}`,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
// Framework control-flow tools (handoff / sub-agent delegation) → approve. They are
|
|
92
|
+
// not side effects; the sub-agent's OWN tools are permission-checked separately
|
|
93
|
+
// rule above this still wins.
|
|
94
|
+
{
|
|
95
|
+
name: "control-flow-approve",
|
|
96
|
+
evaluate(ctx) {
|
|
97
|
+
return ctx.plan.handoff !== undefined || ctx.plan.controlFlow === true ? { kind: "approve" } : undefined;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
// yolo mode → approve (any yolo-mode block must be a deny rule above this).
|
|
101
|
+
{ name: "yolo-mode-approve", evaluate: () => (state.mode() === "yolo" ? { kind: "approve" } : undefined) },
|
|
102
|
+
// Approve-for-session memorized rule matches → approve.
|
|
103
|
+
{
|
|
104
|
+
name: "session-approval-history",
|
|
105
|
+
evaluate(ctx) {
|
|
106
|
+
for (const pattern of state.sessionApprovalRulePatterns()) {
|
|
107
|
+
const match = matchPermissionRule({
|
|
108
|
+
rule: { decision: "allow", scope: "session-runtime", pattern, reason: "approve for session" },
|
|
109
|
+
toolName: ctx.toolCall.name,
|
|
110
|
+
execution: ctx.plan,
|
|
111
|
+
});
|
|
112
|
+
if (match !== undefined) {
|
|
113
|
+
return { kind: "approve", reason: { has_rule_args: match.hasRuleArgs, match_strategy: match.strategy } };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
// User-configured ask rule matches → ask. Marked human-only: an explicit "ask me for X"
|
|
120
|
+
// is a deliberate user choice, so the auto-mode judge must not override it.
|
|
121
|
+
{
|
|
122
|
+
name: "user-configured-ask",
|
|
123
|
+
evaluate(ctx) {
|
|
124
|
+
const match = firstMatchingRule(ctx, userRules(state), "ask");
|
|
125
|
+
return match ? { kind: "ask", reason: userRuleReason("ask", match), classifierApprovable: false } : undefined;
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
// User-configured allow rule matches → approve.
|
|
129
|
+
{
|
|
130
|
+
name: "user-configured-allow",
|
|
131
|
+
evaluate(ctx) {
|
|
132
|
+
const match = firstMatchingRule(ctx, userRules(state), "allow");
|
|
133
|
+
return match ? { kind: "approve", reason: userRuleReason("allow", match) } : undefined;
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
slot("exit-plan-mode-review-ask"),
|
|
137
|
+
slot("plan-mode-tool-approve"),
|
|
138
|
+
// Access touches a sensitive file (.env, SSH key, credentials) → ask.
|
|
139
|
+
{
|
|
140
|
+
name: "sensitive-file-access-ask",
|
|
141
|
+
evaluate(ctx) {
|
|
142
|
+
const access = fileAccesses(ctx).find((a) => isSensitiveFile(a.path));
|
|
143
|
+
return access ? { kind: "ask", reason: fileAccessReason(access, { sensitive_path: true }) } : undefined;
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
// Access touches a `.git` control path → ask. Heuristic first (a literal `.git` component
|
|
147
|
+
// relative to cwd — no I/O), then the precise work-tree marker (catches linked worktrees /
|
|
148
|
+
// submodules whose control dir lives elsewhere).
|
|
149
|
+
{
|
|
150
|
+
name: "git-control-path-access-ask",
|
|
151
|
+
async evaluate(ctx) {
|
|
152
|
+
const cwd = state.cwd();
|
|
153
|
+
if (cwd.length === 0)
|
|
154
|
+
return undefined;
|
|
155
|
+
const pathClass = state.pathClass();
|
|
156
|
+
const accesses = fileAccesses(ctx);
|
|
157
|
+
if (accesses.length === 0)
|
|
158
|
+
return undefined;
|
|
159
|
+
const direct = accesses.find((a) => relativePathParts(a.path, cwd, pathClass).some((part) => part.toLowerCase() === ".git"));
|
|
160
|
+
if (direct !== undefined)
|
|
161
|
+
return { kind: "ask", reason: fileAccessReason(direct, { git_control_path: true }) };
|
|
162
|
+
const marker = await gitMarker();
|
|
163
|
+
if (marker === null)
|
|
164
|
+
return undefined;
|
|
165
|
+
const inside = accesses.find((a) => isGitControlPath(a.path, marker, pathClass));
|
|
166
|
+
return inside ? { kind: "ask", reason: fileAccessReason(inside, { git_control_path: true }) } : undefined;
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
// Write target outside cwd → ask. (reads/searches outside cwd allowed)
|
|
170
|
+
{
|
|
171
|
+
name: "cwd-outside-file-write-ask",
|
|
172
|
+
evaluate(ctx) {
|
|
173
|
+
const cwd = state.cwd();
|
|
174
|
+
if (cwd.length === 0)
|
|
175
|
+
return undefined;
|
|
176
|
+
const pathClass = state.pathClass();
|
|
177
|
+
const access = writeFileAccesses(ctx).find((a) => !isWithinDirectory(a.path, cwd, pathClass));
|
|
178
|
+
return access ? { kind: "ask", reason: fileAccessReason(access, { cwd_outside: true }) } : undefined;
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
// workspace mode → approve (everything inside the workspace; the sensitive-file /
|
|
182
|
+
// git-control / cwd-outside-write asks above this are the workspace safety floor).
|
|
183
|
+
{ name: "workspace-mode-approve", evaluate: () => (state.mode() === "workspace" ? { kind: "approve" } : undefined) },
|
|
184
|
+
// Default-approve list (read-only / UI helpers) → approve.
|
|
185
|
+
{
|
|
186
|
+
name: "default-tool-approve",
|
|
187
|
+
evaluate(ctx) {
|
|
188
|
+
return DEFAULT_APPROVE_TOOLS.has(ctx.toolCall.name) ? { kind: "approve" } : undefined;
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
// A Bash command recognized as read-only → approve, the same as the read-only TOOLS above.
|
|
192
|
+
// It sits below the safety floor deliberately: a read still has to clear the sensitive-file
|
|
193
|
+
// and .git asks, and this only spares the ones that got past them. In `auto` mode that is
|
|
194
|
+
// the point — `git status` and `ls` would otherwise each cost a judge round trip to reach
|
|
195
|
+
// the same answer. Unrecognized commands return undefined and continue down the chain.
|
|
196
|
+
{
|
|
197
|
+
name: "bash-read-only-approve",
|
|
198
|
+
evaluate(ctx) {
|
|
199
|
+
if (ctx.toolCall.name !== "Bash")
|
|
200
|
+
return undefined;
|
|
201
|
+
const command = ctx.args?.command;
|
|
202
|
+
if (typeof command !== "string")
|
|
203
|
+
return undefined;
|
|
204
|
+
return isReadOnlyBashCommand(command) ? { kind: "approve", reason: { bash_read_only: true } } : undefined;
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
// Write/Edit inside cwd inside a git work tree → approve (changes are recoverable via git).
|
|
208
|
+
// Still overridable by name; degrades to undefined (→ fallback ask) when no machine/marker.
|
|
209
|
+
overrides?.get("git-cwd-write-approve") ?? {
|
|
210
|
+
name: "git-cwd-write-approve",
|
|
211
|
+
async evaluate(ctx) {
|
|
212
|
+
if (ctx.toolCall.name !== "Write" && ctx.toolCall.name !== "Edit")
|
|
213
|
+
return undefined;
|
|
214
|
+
if (state.pathClass() !== "posix")
|
|
215
|
+
return undefined;
|
|
216
|
+
const cwd = state.cwd();
|
|
217
|
+
if (cwd.length === 0)
|
|
218
|
+
return undefined;
|
|
219
|
+
const writes = writeFileAccesses(ctx);
|
|
220
|
+
if (writes.length === 0)
|
|
221
|
+
return undefined;
|
|
222
|
+
if (!writes.every((a) => isWithinDirectory(a.path, cwd, state.pathClass())))
|
|
223
|
+
return undefined;
|
|
224
|
+
if ((await gitMarker()) === null)
|
|
225
|
+
return undefined;
|
|
226
|
+
return { kind: "approve", reason: { git_cwd_write: true } };
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
// Nothing matched → ask.
|
|
230
|
+
{ name: "fallback-ask", evaluate: () => ({ kind: "ask" }) },
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=policies.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ResolvedToolExecutionHookContext } from "../loop/types.ts";
|
|
2
|
+
import type { Message } from "../protocol/index.ts";
|
|
3
|
+
import type { Tool } from "../tool/types.ts";
|
|
4
|
+
import type { QuestionResponder } from "../tool/questions.ts";
|
|
5
|
+
export type { QuestionOption, QuestionItem, QuestionRequest, QuestionAnswerValue, QuestionAnswers, QuestionAnswerMethod, QuestionResponse, QuestionResult, QuestionResponder, } from "../tool/questions.ts";
|
|
6
|
+
export type PermissionRuleDecision = "allow" | "deny" | "ask";
|
|
7
|
+
export type PermissionRuleScope = "turn-override" | "session-runtime" | "project" | "user";
|
|
8
|
+
export type PermissionMode = "manual" | "workspace" | "yolo" | "auto";
|
|
9
|
+
export interface PermissionRule {
|
|
10
|
+
readonly decision: PermissionRuleDecision;
|
|
11
|
+
readonly scope: PermissionRuleScope;
|
|
12
|
+
readonly pattern: string;
|
|
13
|
+
readonly reason?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ApprovalRequest {
|
|
16
|
+
readonly toolCallId: string;
|
|
17
|
+
readonly toolName: string;
|
|
18
|
+
readonly approvalRule: string;
|
|
19
|
+
readonly display?: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface ApprovalResponse {
|
|
22
|
+
readonly decision: "approved" | "rejected" | "cancelled";
|
|
23
|
+
readonly scope?: "session";
|
|
24
|
+
readonly feedback?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ApprovalRequestOptions {
|
|
27
|
+
readonly signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
export interface Responder extends QuestionResponder {
|
|
30
|
+
requestApproval(request: ApprovalRequest, options?: ApprovalRequestOptions): Promise<ApprovalResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Whether this responder answers approvals live (inline) right now. When it returns `false`,
|
|
33
|
+
* the run does not consult `requestApproval` and instead interrupts durably — persisting a
|
|
34
|
+
* interruption state and handing control back to the caller to resume later (possibly cross-process).
|
|
35
|
+
* Absent ⇒ treated as `true` (live), preserving the live-answer default. Note this gates only
|
|
36
|
+
* approvals (not questions): returning `true` means it will *answer* the approval inline, not
|
|
37
|
+
* that it will approve it.
|
|
38
|
+
*/
|
|
39
|
+
isLiveApprover?(): boolean;
|
|
40
|
+
}
|
|
41
|
+
export type PermissionPolicyContext = ResolvedToolExecutionHookContext;
|
|
42
|
+
export type PermissionDecisionReason = Readonly<Record<string, string | number | boolean | null>>;
|
|
43
|
+
export type PermissionPolicyResult = {
|
|
44
|
+
readonly kind: "approve";
|
|
45
|
+
readonly reason?: PermissionDecisionReason;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "deny";
|
|
48
|
+
readonly reason?: PermissionDecisionReason;
|
|
49
|
+
readonly message?: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "ask";
|
|
52
|
+
readonly reason?: PermissionDecisionReason;
|
|
53
|
+
readonly resolveApproval?: (response: ApprovalResponse) => PermissionPolicyResult | undefined;
|
|
54
|
+
readonly classifierApprovable?: boolean;
|
|
55
|
+
};
|
|
56
|
+
export interface PermissionPolicy {
|
|
57
|
+
readonly name: string;
|
|
58
|
+
evaluate(context: PermissionPolicyContext): PermissionPolicyResult | undefined | Promise<PermissionPolicyResult | undefined>;
|
|
59
|
+
}
|
|
60
|
+
/** Input handed to the `auto`-mode judge for a single would-prompt action. */
|
|
61
|
+
export interface AutoApprovalInput {
|
|
62
|
+
/** The action under review (tool name / args / tool / model / signal). */
|
|
63
|
+
readonly ctx: ResolvedToolExecutionHookContext;
|
|
64
|
+
/** Conversation so far. The judge sanitises this (user text + tool calls only). */
|
|
65
|
+
readonly transcript: readonly Message[];
|
|
66
|
+
/** The approval-rule subject the static chain produced for this action. */
|
|
67
|
+
readonly approvalRule: string;
|
|
68
|
+
/** Tool registry, so the judge can project prior tool calls in the transcript faithfully. */
|
|
69
|
+
readonly tools?: readonly Tool[];
|
|
70
|
+
}
|
|
71
|
+
export interface AutoApprovalVerdict {
|
|
72
|
+
/** `allow` proceeds without a human; `escalate` falls back to the normal approval prompt. */
|
|
73
|
+
readonly decision: "allow" | "escalate";
|
|
74
|
+
readonly reason?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The `auto`-mode judge. Consulted by the PermissionManager only for actions the static
|
|
78
|
+
* policy chain would otherwise prompt on (and that are `classifierApprovable`). Implementations
|
|
79
|
+
* must be fail-closed — return `escalate` on any uncertainty rather than `allow`.
|
|
80
|
+
*/
|
|
81
|
+
export interface AutoApprover {
|
|
82
|
+
classify(input: AutoApprovalInput): Promise<AutoApprovalVerdict>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
export async function downloadZip(url) {
|
|
12
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
13
|
+
if (!res.ok)
|
|
14
|
+
throw new Error(`Failed to download ${url}: HTTP ${res.status}`);
|
|
15
|
+
return Buffer.from(await res.arrayBuffer());
|
|
16
|
+
}
|
|
17
|
+
export async function extractZip(buffer, destDir) {
|
|
18
|
+
const unzipSync = await loadUnzip();
|
|
19
|
+
const entries = unzipSync(new Uint8Array(buffer));
|
|
20
|
+
const root = path.resolve(destDir);
|
|
21
|
+
const topLevel = new Set();
|
|
22
|
+
for (const name of Object.keys(entries)) {
|
|
23
|
+
const first = name.split("/")[0];
|
|
24
|
+
if (first)
|
|
25
|
+
topLevel.add(first);
|
|
26
|
+
}
|
|
27
|
+
for (const [name, data] of Object.entries(entries)) {
|
|
28
|
+
if (name.endsWith("/"))
|
|
29
|
+
continue; // directory entry
|
|
30
|
+
// zip-slip guard: the archive is untrusted remote content. A crafted entry name
|
|
31
|
+
// (`../../../.zshrc`, or an absolute path) would otherwise `path.join` OUTSIDE destDir
|
|
32
|
+
// and overwrite arbitrary files. Resolve and require containment; a violation means a
|
|
33
|
+
// malicious archive, so refuse the whole extraction rather than partially installing it.
|
|
34
|
+
const target = path.resolve(root, name);
|
|
35
|
+
if (target !== root && !target.startsWith(root + path.sep)) {
|
|
36
|
+
throw new Error(`Refusing to extract zip entry "${name}": resolves outside the destination directory (zip-slip).`);
|
|
37
|
+
}
|
|
38
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
39
|
+
await writeFile(target, data);
|
|
40
|
+
}
|
|
41
|
+
// GitHub archives nest under `repo-ref/`; descend into a lone top-level dir.
|
|
42
|
+
return topLevel.size === 1 ? path.join(destDir, [...topLevel][0]) : destDir;
|
|
43
|
+
}
|
|
44
|
+
async function loadUnzip() {
|
|
45
|
+
try {
|
|
46
|
+
// Non-literal specifier so TS infers `any` and does NOT resolve the optional dep at
|
|
47
|
+
// typecheck — it loads only at call time (same posture as operon-agents-mcp's SDK import).
|
|
48
|
+
const specifier = "fflate";
|
|
49
|
+
const mod = (await import(__rewriteRelativeImportExtension(specifier)));
|
|
50
|
+
if (typeof mod.unzipSync !== "function")
|
|
51
|
+
throw new Error("fflate.unzipSync missing");
|
|
52
|
+
return mod.unzipSync;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new Error(`Zip extraction requires the optional "fflate" dependency (install it to use zip-url / github plugin sources). Cause: ${error instanceof Error ? error.message : String(error)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PluginGithubRef } from "./types.ts";
|
|
2
|
+
export interface GithubResolution {
|
|
3
|
+
readonly zipUrl: string;
|
|
4
|
+
readonly ref: PluginGithubRef;
|
|
5
|
+
}
|
|
6
|
+
export interface GithubSourceInput {
|
|
7
|
+
readonly owner: string;
|
|
8
|
+
readonly repo: string;
|
|
9
|
+
readonly ref?: PluginGithubRef;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveGithubSource(input: GithubSourceInput): Promise<GithubResolution>;
|
|
12
|
+
export declare function codeloadZipUrl(owner: string, repo: string, ref: PluginGithubRef): string;
|
|
13
|
+
//# sourceMappingURL=github-resolver.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export async function resolveGithubSource(input) {
|
|
2
|
+
const ref = input.ref ?? { kind: "branch", value: await defaultBranch(input.owner, input.repo) };
|
|
3
|
+
return { zipUrl: codeloadZipUrl(input.owner, input.repo, ref), ref };
|
|
4
|
+
}
|
|
5
|
+
export function codeloadZipUrl(owner, repo, ref) {
|
|
6
|
+
const value = ref.value.split("/").map(encodeURIComponent).join("/");
|
|
7
|
+
return `https://codeload.github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/zip/${value}`;
|
|
8
|
+
}
|
|
9
|
+
async function defaultBranch(owner, repo) {
|
|
10
|
+
const res = await fetch(`https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`, {
|
|
11
|
+
headers: { Accept: "application/vnd.github+json" },
|
|
12
|
+
});
|
|
13
|
+
if (!res.ok)
|
|
14
|
+
throw new Error(`GitHub API ${res.status} resolving ${owner}/${repo} default branch`);
|
|
15
|
+
const body = (await res.json());
|
|
16
|
+
if (typeof body.default_branch !== "string")
|
|
17
|
+
throw new Error(`GitHub API returned no default_branch for ${owner}/${repo}`);
|
|
18
|
+
return body.default_branch;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=github-resolver.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type HookDef } from "../capabilities/user-hooks/types.ts";
|
|
2
|
+
import type { Machine } from "../tool/machine.ts";
|
|
3
|
+
import type { PluginDiagnostic } from "./types.ts";
|
|
4
|
+
export interface ParsedPluginHooks {
|
|
5
|
+
readonly hooks: readonly HookDef[];
|
|
6
|
+
readonly diagnostics: readonly PluginDiagnostic[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolve hook definitions for a plugin root from the raw manifest `hooks` field.
|
|
10
|
+
* Expands `${PLUGIN_ROOT}` (and Claude-compat aliases) in command strings.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadPluginHooks(machine: Machine, pluginRoot: string, rawHooksField: unknown, diagnostics: PluginDiagnostic[]): Promise<readonly HookDef[]>;
|
|
13
|
+
/** Substitute plugin-root placeholders so commands can address files inside the package. */
|
|
14
|
+
export declare function expandPluginRootInHook(hook: HookDef, pluginRoot: string): HookDef;
|
|
15
|
+
export declare function expandPluginRoot(command: string, pluginRoot: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a hooks document (object or array) into HookDefs.
|
|
18
|
+
* Pure: no I/O.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseHooksDocument(raw: unknown): ParsedPluginHooks;
|
|
21
|
+
/** Project config.hooks entries into HookDefs, dropping unknown events. */
|
|
22
|
+
export declare function hookDefsFromConfig(entries: ReadonlyArray<{
|
|
23
|
+
event: string;
|
|
24
|
+
matcher?: string;
|
|
25
|
+
command: string;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}>): HookDef[];
|
|
28
|
+
//# sourceMappingURL=hooks.d.ts.map
|