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,57 @@
|
|
|
1
|
+
function isPlainObject(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
// Merge is exactly ONE level deep: entries present in both layers are shallow-spread, so a
|
|
5
|
+
// higher layer overriding e.g. one `provider.env` var replaces the WHOLE nested object
|
|
6
|
+
// (`env`/`customHeaders`/`mcpServer.headers` are second-level and thus wholesale-replaced, not
|
|
7
|
+
// field-merged). Callers wanting to tweak a single nested field must restate the full object.
|
|
8
|
+
function mergeRecord(base, over) {
|
|
9
|
+
if (!over)
|
|
10
|
+
return { ...base };
|
|
11
|
+
const out = { ...base };
|
|
12
|
+
for (const [key, value] of Object.entries(over)) {
|
|
13
|
+
const existing = out[key];
|
|
14
|
+
out[key] = isPlainObject(existing) && isPlainObject(value) ? { ...existing, ...value } : value;
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
function mergeOne(base, layer) {
|
|
19
|
+
return {
|
|
20
|
+
providers: mergeRecord(base.providers, layer.providers),
|
|
21
|
+
models: mergeRecord(base.models, layer.models),
|
|
22
|
+
defaultModel: layer.defaultModel ?? base.defaultModel,
|
|
23
|
+
modelCredentials: layer.modelCredentials ?? base.modelCredentials,
|
|
24
|
+
permission: {
|
|
25
|
+
mode: layer.permission?.mode ?? base.permission.mode,
|
|
26
|
+
// Concatenate rules across layers — scope encodes the originating tier.
|
|
27
|
+
rules: [...base.permission.rules, ...(layer.permission?.rules ?? [])],
|
|
28
|
+
// `auto`-mode judge tuning: later layer wins (it's a whole-section override, not additive).
|
|
29
|
+
autoApproval: layer.permission?.autoApproval ?? base.permission.autoApproval,
|
|
30
|
+
},
|
|
31
|
+
loopControl: { ...base.loopControl, ...layer.loopControl },
|
|
32
|
+
thinking: layer.thinking ?? base.thinking,
|
|
33
|
+
mcpServers: mergeRecord(base.mcpServers, layer.mcpServers),
|
|
34
|
+
hooks: [...base.hooks, ...(layer.hooks ?? [])],
|
|
35
|
+
plugins: [...base.plugins, ...(layer.plugins ?? [])],
|
|
36
|
+
pluginMarketplaces: dedupe([...base.pluginMarketplaces, ...(layer.pluginMarketplaces ?? [])]),
|
|
37
|
+
flags: { ...base.flags, ...layer.flags },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function dedupe(values) {
|
|
41
|
+
return [...new Set(values)];
|
|
42
|
+
}
|
|
43
|
+
const EMPTY = {
|
|
44
|
+
providers: {},
|
|
45
|
+
models: {},
|
|
46
|
+
permission: { rules: [] },
|
|
47
|
+
loopControl: {},
|
|
48
|
+
mcpServers: {},
|
|
49
|
+
hooks: [],
|
|
50
|
+
plugins: [],
|
|
51
|
+
pluginMarketplaces: [],
|
|
52
|
+
flags: {},
|
|
53
|
+
};
|
|
54
|
+
export function mergeConfigs(...layers) {
|
|
55
|
+
return layers.reduce((acc, layer) => mergeOne(acc, layer), EMPTY);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ModelCapability } from "../llm/index.ts";
|
|
2
|
+
import type { ModelAlias } from "./schema.ts";
|
|
3
|
+
export interface ModelCapabilityInfo {
|
|
4
|
+
readonly maxContextSize: number | undefined;
|
|
5
|
+
readonly maxOutputSize: number | undefined;
|
|
6
|
+
readonly capability: ModelCapability;
|
|
7
|
+
readonly known: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class ModelCatalog {
|
|
10
|
+
private readonly aliases;
|
|
11
|
+
constructor(models?: Record<string, ModelAlias>);
|
|
12
|
+
private find;
|
|
13
|
+
info(modelRef: string): ModelCapabilityInfo;
|
|
14
|
+
maxContextSize(modelRef: string): number | undefined;
|
|
15
|
+
has(modelRef: string, capability: string): boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=model-catalog.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { UNKNOWN_CAPABILITY, applyDeclaredCapability } from "../llm/index.js";
|
|
2
|
+
export class ModelCatalog {
|
|
3
|
+
aliases;
|
|
4
|
+
constructor(models = {}) {
|
|
5
|
+
this.aliases = new Map(Object.entries(models));
|
|
6
|
+
}
|
|
7
|
+
find(modelRef) {
|
|
8
|
+
const direct = this.aliases.get(modelRef);
|
|
9
|
+
if (direct)
|
|
10
|
+
return direct;
|
|
11
|
+
for (const alias of this.aliases.values()) {
|
|
12
|
+
if (`${alias.provider}/${alias.model}` === modelRef || alias.model === modelRef)
|
|
13
|
+
return alias;
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
info(modelRef) {
|
|
18
|
+
const alias = this.find(modelRef);
|
|
19
|
+
if (!alias) {
|
|
20
|
+
return { maxContextSize: undefined, maxOutputSize: undefined, capability: UNKNOWN_CAPABILITY, known: false };
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
maxContextSize: alias.maxContextSize,
|
|
24
|
+
maxOutputSize: alias.maxOutputSize,
|
|
25
|
+
capability: applyDeclaredCapability(UNKNOWN_CAPABILITY, alias.capabilities, alias.maxContextSize),
|
|
26
|
+
known: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
maxContextSize(modelRef) {
|
|
30
|
+
return this.find(modelRef)?.maxContextSize;
|
|
31
|
+
}
|
|
32
|
+
has(modelRef, capability) {
|
|
33
|
+
const alias = this.find(modelRef);
|
|
34
|
+
return alias?.capabilities?.includes(capability) ?? false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=model-catalog.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ConfigTier = "user" | "project" | "local";
|
|
2
|
+
export interface ConfigLayerOptions {
|
|
3
|
+
/** Names the host config dir/file family. Default "agents". */
|
|
4
|
+
readonly appName?: string;
|
|
5
|
+
/** User-tier directory. Default `~/.<appName>`. */
|
|
6
|
+
readonly homeDir?: string;
|
|
7
|
+
/** Project root for project/local tiers. Default `process.cwd()`. */
|
|
8
|
+
readonly cwd?: string;
|
|
9
|
+
/** Config file name. Default "config.toml" (own config is TOML; mcp.json stays JSON). */
|
|
10
|
+
readonly fileName?: string;
|
|
11
|
+
/** Local (gitignored) override file name. Default "config.local.toml". */
|
|
12
|
+
readonly localFileName?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ConfigLayer {
|
|
15
|
+
readonly tier: ConfigTier;
|
|
16
|
+
readonly path: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ConfigLayerPaths {
|
|
19
|
+
readonly user: string;
|
|
20
|
+
readonly project: string;
|
|
21
|
+
readonly local: string;
|
|
22
|
+
/** Layers in precedence order, low → high (local wins). */
|
|
23
|
+
readonly ordered: readonly ConfigLayer[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Standard three-tier config file locations. Precedence low → high:
|
|
27
|
+
* user (`~/.<app>/config.toml`) < project (`<cwd>/.<app>/config.toml`) <
|
|
28
|
+
* local (`<cwd>/.<app>/config.local.toml`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveConfigLayers(options?: ConfigLayerOptions): ConfigLayerPaths;
|
|
31
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Standard three-tier config file locations. Precedence low → high:
|
|
5
|
+
* user (`~/.<app>/config.toml`) < project (`<cwd>/.<app>/config.toml`) <
|
|
6
|
+
* local (`<cwd>/.<app>/config.local.toml`).
|
|
7
|
+
*/
|
|
8
|
+
export function resolveConfigLayers(options = {}) {
|
|
9
|
+
const appName = options.appName ?? "agents";
|
|
10
|
+
const fileName = options.fileName ?? "config.toml";
|
|
11
|
+
const localFileName = options.localFileName ?? "config.local.toml";
|
|
12
|
+
const homeDir = options.homeDir ?? join(homedir(), `.${appName}`);
|
|
13
|
+
const cwd = options.cwd ?? process.cwd();
|
|
14
|
+
const user = join(homeDir, fileName);
|
|
15
|
+
const project = join(cwd, `.${appName}`, fileName);
|
|
16
|
+
const local = join(cwd, `.${appName}`, localFileName);
|
|
17
|
+
return {
|
|
18
|
+
user,
|
|
19
|
+
project,
|
|
20
|
+
local,
|
|
21
|
+
ordered: [
|
|
22
|
+
{ tier: "user", path: user },
|
|
23
|
+
{ tier: "project", path: project },
|
|
24
|
+
{ tier: "local", path: local },
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type AuthContext, type CredentialStore, type ModelsStore } from "@earendil-works/pi-ai";
|
|
2
|
+
import { ChatModel, UNKNOWN_CAPABILITY, type ModelCapability, type ModelRuntime } from "../llm/index.ts";
|
|
3
|
+
import type { ModelCredentialsConfig, ProviderConfig } from "./schema.ts";
|
|
4
|
+
export interface ResolvedModel {
|
|
5
|
+
readonly model: ChatModel;
|
|
6
|
+
readonly capability: ModelCapability;
|
|
7
|
+
readonly maxOutputSize?: number;
|
|
8
|
+
readonly providerName: string;
|
|
9
|
+
}
|
|
10
|
+
export type ApiKeyResolver = (providerName: string, providerConfig: ProviderConfig) => string | undefined | Promise<string | undefined>;
|
|
11
|
+
export interface ProviderManagerConfig {
|
|
12
|
+
readonly providers: Readonly<Record<string, ProviderConfig>>;
|
|
13
|
+
readonly models: Readonly<Record<string, ResolvableAlias>>;
|
|
14
|
+
readonly defaultModel?: string;
|
|
15
|
+
readonly modelCredentials?: ModelCredentialsConfig;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolvableAlias {
|
|
18
|
+
readonly provider: string;
|
|
19
|
+
readonly model: string;
|
|
20
|
+
readonly maxContextSize?: number;
|
|
21
|
+
readonly maxOutputSize?: number;
|
|
22
|
+
readonly capabilities?: readonly string[];
|
|
23
|
+
readonly displayName?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ProviderManagerOptions {
|
|
26
|
+
readonly config: ProviderManagerConfig | (() => ProviderManagerConfig);
|
|
27
|
+
/** Reuse a caller-owned pi provider/auth/catalog collection. */
|
|
28
|
+
readonly runtime?: ModelRuntime;
|
|
29
|
+
readonly credentials?: CredentialStore;
|
|
30
|
+
readonly modelsStore?: ModelsStore;
|
|
31
|
+
readonly authContext?: AuthContext;
|
|
32
|
+
/** Legacy convenience overlay; `authContext` is the canonical injection. */
|
|
33
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
34
|
+
/**
|
|
35
|
+
* Optional product secret resolver. It is compiled into provider-owned
|
|
36
|
+
* ApiKeyAuth (not called while resolving an alias).
|
|
37
|
+
*/
|
|
38
|
+
readonly resolveApiKey?: ApiKeyResolver;
|
|
39
|
+
}
|
|
40
|
+
export declare class ProviderManager {
|
|
41
|
+
private readonly options;
|
|
42
|
+
readonly runtime: ModelRuntime;
|
|
43
|
+
private readonly baseProviders;
|
|
44
|
+
private readonly overlayFingerprints;
|
|
45
|
+
constructor(options: ProviderManagerOptions);
|
|
46
|
+
private get config();
|
|
47
|
+
get defaultModel(): string | undefined;
|
|
48
|
+
resolveModel(modelRef?: string): Promise<ResolvedModel>;
|
|
49
|
+
modelResolver(): (modelId: string) => Promise<ChatModel>;
|
|
50
|
+
private resolveAlias;
|
|
51
|
+
private syncConfiguredProviders;
|
|
52
|
+
private restoreBaseProvider;
|
|
53
|
+
private buildConfiguredProvider;
|
|
54
|
+
private baseProviderFor;
|
|
55
|
+
}
|
|
56
|
+
export { UNKNOWN_CAPABILITY };
|
|
57
|
+
//# sourceMappingURL=provider-manager.d.ts.map
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join, resolve as resolvePath } from "node:path";
|
|
3
|
+
import { createProvider, defaultProviderAuthContext, } from "@earendil-works/pi-ai";
|
|
4
|
+
import { anthropicMessagesApi } from "@earendil-works/pi-ai/api/anthropic-messages.lazy";
|
|
5
|
+
import { googleGenerativeAIApi } from "@earendil-works/pi-ai/api/google-generative-ai.lazy";
|
|
6
|
+
import { googleVertexApi } from "@earendil-works/pi-ai/api/google-vertex.lazy";
|
|
7
|
+
import { openAICompletionsApi } from "@earendil-works/pi-ai/api/openai-completions.lazy";
|
|
8
|
+
import { openAIResponsesApi } from "@earendil-works/pi-ai/api/openai-responses.lazy";
|
|
9
|
+
import { ChatModel, FileCredentialStore, UNKNOWN_CAPABILITY, applyDeclaredCapability, capabilityFromPiModel, createModelRuntime, } from "../llm/index.js";
|
|
10
|
+
export class ProviderManager {
|
|
11
|
+
options;
|
|
12
|
+
runtime;
|
|
13
|
+
baseProviders = new Map();
|
|
14
|
+
overlayFingerprints = new Map();
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
const initialConfig = this.config;
|
|
18
|
+
const authContext = overlayOptionalAuthContext(options.authContext ?? defaultProviderAuthContext(), options.env);
|
|
19
|
+
const credentials = options.credentials ??
|
|
20
|
+
credentialStoreFromConfig(initialConfig.modelCredentials);
|
|
21
|
+
this.runtime = options.runtime ?? createModelRuntime({
|
|
22
|
+
...(credentials !== undefined ? { credentials } : {}),
|
|
23
|
+
...(options.modelsStore !== undefined ? { modelsStore: options.modelsStore } : {}),
|
|
24
|
+
authContext,
|
|
25
|
+
});
|
|
26
|
+
for (const provider of this.runtime.models.getProviders()) {
|
|
27
|
+
this.baseProviders.set(provider.id, provider);
|
|
28
|
+
}
|
|
29
|
+
this.syncConfiguredProviders(initialConfig);
|
|
30
|
+
}
|
|
31
|
+
get config() {
|
|
32
|
+
const c = this.options.config;
|
|
33
|
+
return typeof c === "function" ? c() : c;
|
|
34
|
+
}
|
|
35
|
+
get defaultModel() {
|
|
36
|
+
return this.config.defaultModel;
|
|
37
|
+
}
|
|
38
|
+
async resolveModel(modelRef) {
|
|
39
|
+
const config = this.config;
|
|
40
|
+
this.syncConfiguredProviders(config);
|
|
41
|
+
const ref = modelRef ?? config.defaultModel;
|
|
42
|
+
if (ref === undefined || ref.length === 0) {
|
|
43
|
+
throw new Error("provider manager: no model specified and config has no defaultModel");
|
|
44
|
+
}
|
|
45
|
+
const alias = this.resolveAlias(ref, config);
|
|
46
|
+
const piModel = this.runtime.models.getModel(alias.provider, alias.model);
|
|
47
|
+
if (piModel === undefined) {
|
|
48
|
+
const providerConfig = config.providers[alias.provider];
|
|
49
|
+
if (providerConfig?.baseUrl === undefined || providerConfig.baseUrl.length === 0) {
|
|
50
|
+
throw new Error(`provider manager: model "${alias.provider}/${alias.model}" is unknown to pi and ` +
|
|
51
|
+
`provider "${alias.provider}" has no baseUrl to build a custom endpoint`);
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`provider manager: configured provider "${alias.provider}" did not expose model "${alias.model}"`);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
model: new ChatModel({
|
|
57
|
+
runtime: this.runtime,
|
|
58
|
+
descriptor: piModel,
|
|
59
|
+
}),
|
|
60
|
+
capability: applyDeclaredCapability(capabilityFromPiModel(piModel), alias.capabilities, alias.maxContextSize),
|
|
61
|
+
maxOutputSize: alias.maxOutputSize,
|
|
62
|
+
providerName: alias.provider,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
modelResolver() {
|
|
66
|
+
return async (id) => (await this.resolveModel(id)).model;
|
|
67
|
+
}
|
|
68
|
+
resolveAlias(ref, config) {
|
|
69
|
+
const declared = config.models[ref];
|
|
70
|
+
if (declared !== undefined)
|
|
71
|
+
return declared;
|
|
72
|
+
const slash = ref.indexOf("/");
|
|
73
|
+
if (slash > 0 && slash < ref.length - 1) {
|
|
74
|
+
return { provider: ref.slice(0, slash), model: ref.slice(slash + 1) };
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`provider manager: model "${ref}" is not in config.models and is not a "provider/model" ref`);
|
|
77
|
+
}
|
|
78
|
+
syncConfiguredProviders(config) {
|
|
79
|
+
const configured = new Set(Object.keys(config.providers));
|
|
80
|
+
for (const providerId of this.overlayFingerprints.keys()) {
|
|
81
|
+
if (configured.has(providerId))
|
|
82
|
+
continue;
|
|
83
|
+
this.restoreBaseProvider(providerId);
|
|
84
|
+
this.overlayFingerprints.delete(providerId);
|
|
85
|
+
}
|
|
86
|
+
for (const [providerId, providerConfig] of Object.entries(config.providers)) {
|
|
87
|
+
const aliases = Object.values(config.models).filter((alias) => alias.provider === providerId);
|
|
88
|
+
const fingerprint = JSON.stringify({ providerConfig, aliases });
|
|
89
|
+
if (this.overlayFingerprints.get(providerId) === fingerprint)
|
|
90
|
+
continue;
|
|
91
|
+
const provider = this.buildConfiguredProvider(providerId, providerConfig, aliases);
|
|
92
|
+
this.runtime.models.setProvider(provider);
|
|
93
|
+
this.overlayFingerprints.set(providerId, fingerprint);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
restoreBaseProvider(providerId) {
|
|
97
|
+
const base = this.baseProviders.get(providerId);
|
|
98
|
+
if (base !== undefined)
|
|
99
|
+
this.runtime.models.setProvider(base);
|
|
100
|
+
else
|
|
101
|
+
this.runtime.models.deleteProvider(providerId);
|
|
102
|
+
}
|
|
103
|
+
buildConfiguredProvider(providerId, config, aliases) {
|
|
104
|
+
const base = this.baseProviderFor(providerId, config.type);
|
|
105
|
+
const models = configuredModels(providerId, config, aliases, base);
|
|
106
|
+
return createProvider({
|
|
107
|
+
id: providerId,
|
|
108
|
+
name: base?.name ?? providerId,
|
|
109
|
+
baseUrl: config.baseUrl ?? base?.baseUrl,
|
|
110
|
+
headers: mergeHeaders(base?.headers, config.customHeaders),
|
|
111
|
+
auth: configuredAuth(providerId, config, base?.auth, this.options.resolveApiKey),
|
|
112
|
+
models,
|
|
113
|
+
api: API_IMPLEMENTATIONS,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
baseProviderFor(providerId, type) {
|
|
117
|
+
return (this.baseProviders.get(providerId) ??
|
|
118
|
+
this.baseProviders.get(builtinProviderIdForType(type)));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function credentialStoreFromConfig(config) {
|
|
122
|
+
return config === undefined
|
|
123
|
+
? undefined
|
|
124
|
+
: new FileCredentialStore(resolveCredentialPath(config.path));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* `~` is the user's home. Relative paths are workspace/process-cwd relative;
|
|
128
|
+
* layered TOML has no single source file whose directory could own them.
|
|
129
|
+
*/
|
|
130
|
+
function resolveCredentialPath(configuredPath) {
|
|
131
|
+
const expanded = configuredPath === "~"
|
|
132
|
+
? homedir()
|
|
133
|
+
: configuredPath.startsWith("~/")
|
|
134
|
+
? join(homedir(), configuredPath.slice(2))
|
|
135
|
+
: configuredPath;
|
|
136
|
+
return resolvePath(expanded);
|
|
137
|
+
}
|
|
138
|
+
function configuredModels(providerId, config, aliases, base) {
|
|
139
|
+
const byId = new Map();
|
|
140
|
+
for (const model of base?.getModels() ?? []) {
|
|
141
|
+
byId.set(model.id, configureKnownModel(model, providerId, config));
|
|
142
|
+
}
|
|
143
|
+
for (const alias of aliases) {
|
|
144
|
+
if (byId.has(alias.model))
|
|
145
|
+
continue;
|
|
146
|
+
// Unknown catalog entries need an explicit endpoint. Without one, leave
|
|
147
|
+
// them absent so resolveModel reports the same actionable error as before.
|
|
148
|
+
if (config.baseUrl === undefined || config.baseUrl.length === 0)
|
|
149
|
+
continue;
|
|
150
|
+
byId.set(alias.model, buildCustomPiModel(alias, providerId, config));
|
|
151
|
+
}
|
|
152
|
+
return [...byId.values()];
|
|
153
|
+
}
|
|
154
|
+
function configureKnownModel(model, providerId, config) {
|
|
155
|
+
return {
|
|
156
|
+
...model,
|
|
157
|
+
provider: providerId,
|
|
158
|
+
...(config.baseUrl !== undefined ? { baseUrl: config.baseUrl } : {}),
|
|
159
|
+
...(config.customHeaders !== undefined
|
|
160
|
+
? { headers: { ...(model.headers ?? {}), ...config.customHeaders } }
|
|
161
|
+
: {}),
|
|
162
|
+
...(config.type === "kimi"
|
|
163
|
+
? { compat: { ...model.compat, deferredToolsMode: "kimi" } }
|
|
164
|
+
: config.type === "anthropic"
|
|
165
|
+
? {
|
|
166
|
+
compat: {
|
|
167
|
+
...model.compat,
|
|
168
|
+
supportsToolReferences: defaultAnthropicToolReferences(model.id),
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
: {}),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function buildCustomPiModel(alias, providerId, providerConfig) {
|
|
175
|
+
const tags = new Set((alias.capabilities ?? []).map((c) => c.trim().toLowerCase()));
|
|
176
|
+
const input = tags.has("image") || tags.has("image_in") || tags.has("vision")
|
|
177
|
+
? ["text", "image"]
|
|
178
|
+
: ["text"];
|
|
179
|
+
const api = apiForProviderType(providerConfig.type);
|
|
180
|
+
const compat = providerConfig.type === "kimi"
|
|
181
|
+
? { deferredToolsMode: "kimi" }
|
|
182
|
+
: providerConfig.type === "anthropic"
|
|
183
|
+
? { supportsToolReferences: defaultAnthropicToolReferences(alias.model) }
|
|
184
|
+
: undefined;
|
|
185
|
+
return {
|
|
186
|
+
id: alias.model,
|
|
187
|
+
name: alias.displayName ?? alias.model,
|
|
188
|
+
api,
|
|
189
|
+
provider: providerId,
|
|
190
|
+
baseUrl: providerConfig.baseUrl,
|
|
191
|
+
reasoning: tags.has("thinking") ||
|
|
192
|
+
tags.has("reasoning") ||
|
|
193
|
+
tags.has("always_thinking"),
|
|
194
|
+
input,
|
|
195
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
196
|
+
contextWindow: alias.maxContextSize ?? 0,
|
|
197
|
+
maxTokens: alias.maxOutputSize ?? 4096,
|
|
198
|
+
...(providerConfig.customHeaders !== undefined
|
|
199
|
+
? { headers: providerConfig.customHeaders }
|
|
200
|
+
: {}),
|
|
201
|
+
...(compat !== undefined ? { compat } : {}),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function configuredAuth(providerId, config, base, resolveApiKey) {
|
|
205
|
+
return {
|
|
206
|
+
apiKey: configuredApiKeyAuth(providerId, config, base?.apiKey, resolveApiKey),
|
|
207
|
+
...(base?.oauth !== undefined ? { oauth: base.oauth } : {}),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function configuredApiKeyAuth(providerId, config, fallback, resolveApiKey) {
|
|
211
|
+
return {
|
|
212
|
+
name: fallback?.name ?? `${providerId} API key`,
|
|
213
|
+
...(fallback?.login !== undefined ? { login: fallback.login } : {}),
|
|
214
|
+
async resolve({ ctx, credential, signal }) {
|
|
215
|
+
const scopedContext = overlayAuthContext(ctx, config.env);
|
|
216
|
+
if (credential !== undefined && fallback !== undefined) {
|
|
217
|
+
const stored = await fallback.resolve({
|
|
218
|
+
ctx: scopedContext,
|
|
219
|
+
credential,
|
|
220
|
+
signal,
|
|
221
|
+
});
|
|
222
|
+
if (stored !== undefined)
|
|
223
|
+
return mergeAuthEnv(stored, config.env);
|
|
224
|
+
}
|
|
225
|
+
const external = config.oauth === undefined
|
|
226
|
+
? undefined
|
|
227
|
+
: await resolveApiKey?.(providerId, config);
|
|
228
|
+
if (external !== undefined && external.length > 0) {
|
|
229
|
+
return {
|
|
230
|
+
auth: { apiKey: external },
|
|
231
|
+
env: config.env,
|
|
232
|
+
source: "Resolver",
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
if (config.apiKey !== undefined && config.apiKey.length > 0) {
|
|
236
|
+
return {
|
|
237
|
+
auth: { apiKey: config.apiKey },
|
|
238
|
+
env: config.env,
|
|
239
|
+
source: "Config",
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const providerEnvName = `${providerId.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
|
|
243
|
+
const providerKey = await scopedContext.env(providerEnvName);
|
|
244
|
+
if (providerKey !== undefined && providerKey.trim().length > 0) {
|
|
245
|
+
return {
|
|
246
|
+
auth: { apiKey: providerKey },
|
|
247
|
+
env: config.env,
|
|
248
|
+
source: providerEnvName,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
if (fallback !== undefined) {
|
|
252
|
+
const ambient = await fallback.resolve({
|
|
253
|
+
ctx: scopedContext,
|
|
254
|
+
credential: undefined,
|
|
255
|
+
signal,
|
|
256
|
+
});
|
|
257
|
+
if (ambient !== undefined)
|
|
258
|
+
return mergeAuthEnv(ambient, config.env);
|
|
259
|
+
}
|
|
260
|
+
// Explicit custom endpoints may be keyless (e.g. local OpenAI-compatible servers).
|
|
261
|
+
if (config.baseUrl !== undefined && config.baseUrl.length > 0) {
|
|
262
|
+
return { auth: {}, env: config.env, source: "Keyless endpoint" };
|
|
263
|
+
}
|
|
264
|
+
return undefined;
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function mergeAuthEnv(result, env) {
|
|
269
|
+
if (env === undefined)
|
|
270
|
+
return result;
|
|
271
|
+
return { ...result, env: { ...(result.env ?? {}), ...env } };
|
|
272
|
+
}
|
|
273
|
+
function overlayAuthContext(base, env) {
|
|
274
|
+
if (env === undefined)
|
|
275
|
+
return base;
|
|
276
|
+
return {
|
|
277
|
+
env: async (name) => env[name] ?? (await base.env(name)),
|
|
278
|
+
fileExists: (path) => base.fileExists(path),
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function overlayOptionalAuthContext(base, env) {
|
|
282
|
+
if (env === undefined)
|
|
283
|
+
return base;
|
|
284
|
+
return {
|
|
285
|
+
env: async (name) => env[name] ?? (await base.env(name)),
|
|
286
|
+
fileExists: (path) => base.fileExists(path),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const API_IMPLEMENTATIONS = {
|
|
290
|
+
"anthropic-messages": anthropicMessagesApi(),
|
|
291
|
+
"openai-completions": openAICompletionsApi(),
|
|
292
|
+
"openai-responses": openAIResponsesApi(),
|
|
293
|
+
"google-generative-ai": googleGenerativeAIApi(),
|
|
294
|
+
"google-vertex": googleVertexApi(),
|
|
295
|
+
};
|
|
296
|
+
function mergeHeaders(base, override) {
|
|
297
|
+
if (base === undefined && override === undefined)
|
|
298
|
+
return undefined;
|
|
299
|
+
return { ...(base ?? {}), ...(override ?? {}) };
|
|
300
|
+
}
|
|
301
|
+
function builtinProviderIdForType(type) {
|
|
302
|
+
switch (type) {
|
|
303
|
+
case "anthropic":
|
|
304
|
+
return "anthropic";
|
|
305
|
+
case "openai":
|
|
306
|
+
case "openai_responses":
|
|
307
|
+
return "openai";
|
|
308
|
+
case "kimi":
|
|
309
|
+
return "moonshotai";
|
|
310
|
+
case "google-genai":
|
|
311
|
+
return "google";
|
|
312
|
+
case "vertexai":
|
|
313
|
+
return "google-vertex";
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function apiForProviderType(type) {
|
|
317
|
+
switch (type) {
|
|
318
|
+
case "anthropic":
|
|
319
|
+
return "anthropic-messages";
|
|
320
|
+
case "openai":
|
|
321
|
+
case "kimi":
|
|
322
|
+
return "openai-completions";
|
|
323
|
+
case "openai_responses":
|
|
324
|
+
return "openai-responses";
|
|
325
|
+
case "google-genai":
|
|
326
|
+
return "google-generative-ai";
|
|
327
|
+
case "vertexai":
|
|
328
|
+
return "google-vertex";
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function defaultAnthropicToolReferences(modelId) {
|
|
332
|
+
if (modelId.includes("haiku"))
|
|
333
|
+
return false;
|
|
334
|
+
const version = modelId.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);
|
|
335
|
+
if (version === null)
|
|
336
|
+
return false;
|
|
337
|
+
const major = Number(version[1]);
|
|
338
|
+
const minor = version[2] !== undefined && version[2].length < 8
|
|
339
|
+
? Number(version[2])
|
|
340
|
+
: 0;
|
|
341
|
+
return major > 4 || (major === 4 && minor >= 5);
|
|
342
|
+
}
|
|
343
|
+
export { UNKNOWN_CAPABILITY };
|
|
344
|
+
//# sourceMappingURL=provider-manager.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HookDef } from "../capabilities/user-hooks/types.ts";
|
|
2
|
+
import type { PermissionMode, PermissionRule } from "../permission/types.ts";
|
|
3
|
+
import { ModelCatalog } from "./model-catalog.ts";
|
|
4
|
+
import { Flags } from "./flags.ts";
|
|
5
|
+
import { type AgentFrameworkConfig, type ThinkingConfig } from "./schema.ts";
|
|
6
|
+
export interface ConfigResolver {
|
|
7
|
+
resolve(): Promise<AgentFrameworkConfig>;
|
|
8
|
+
}
|
|
9
|
+
export declare function objectResolver(config: unknown): ConfigResolver;
|
|
10
|
+
export declare function layeredResolver(...layers: Partial<AgentFrameworkConfig>[]): ConfigResolver;
|
|
11
|
+
export interface AutoApprovalOptions {
|
|
12
|
+
readonly allow: readonly string[];
|
|
13
|
+
readonly deny: readonly string[];
|
|
14
|
+
readonly environment: readonly string[];
|
|
15
|
+
readonly twoStageMode?: "both" | "fast" | "thinking";
|
|
16
|
+
}
|
|
17
|
+
export interface CoreOptions {
|
|
18
|
+
readonly permission: {
|
|
19
|
+
readonly mode?: PermissionMode;
|
|
20
|
+
readonly rules: readonly PermissionRule[];
|
|
21
|
+
readonly autoApproval?: AutoApprovalOptions;
|
|
22
|
+
};
|
|
23
|
+
readonly loopControl: {
|
|
24
|
+
readonly maxStepsPerTurn?: number;
|
|
25
|
+
readonly maxRetriesPerStep?: number;
|
|
26
|
+
readonly maxTurns?: number;
|
|
27
|
+
};
|
|
28
|
+
readonly catalog: ModelCatalog;
|
|
29
|
+
readonly flags: Flags;
|
|
30
|
+
readonly defaultModel?: string;
|
|
31
|
+
readonly thinking?: ThinkingConfig;
|
|
32
|
+
/** Plugin marketplace registry locations (URLs / paths) the product may browse. */
|
|
33
|
+
readonly pluginMarketplaces: readonly string[];
|
|
34
|
+
/** Shell hooks from `config.hooks` (unknown events dropped). Pass to `defaultCapabilities({ hooks })`. */
|
|
35
|
+
readonly hooks: readonly HookDef[];
|
|
36
|
+
readonly config: AgentFrameworkConfig;
|
|
37
|
+
}
|
|
38
|
+
export declare function toCoreOptions(config: AgentFrameworkConfig): CoreOptions;
|
|
39
|
+
export declare function resolveCoreOptions(resolver: ConfigResolver): Promise<CoreOptions>;
|
|
40
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { hookDefsFromConfig } from "../plugins/hooks.js";
|
|
2
|
+
import { mergeConfigs } from "./merge.js";
|
|
3
|
+
import { ModelCatalog } from "./model-catalog.js";
|
|
4
|
+
import { Flags } from "./flags.js";
|
|
5
|
+
import { parseConfig } from "./schema.js";
|
|
6
|
+
export function objectResolver(config) {
|
|
7
|
+
return { resolve: async () => parseConfig(config) };
|
|
8
|
+
}
|
|
9
|
+
export function layeredResolver(...layers) {
|
|
10
|
+
return { resolve: async () => parseConfig(mergeConfigs(...layers)) };
|
|
11
|
+
}
|
|
12
|
+
export function toCoreOptions(config) {
|
|
13
|
+
const rules = config.permission.rules.map((r) => ({
|
|
14
|
+
decision: r.decision,
|
|
15
|
+
scope: r.scope,
|
|
16
|
+
pattern: r.pattern,
|
|
17
|
+
reason: r.reason,
|
|
18
|
+
}));
|
|
19
|
+
const autoApproval = config.permission.autoApproval;
|
|
20
|
+
return {
|
|
21
|
+
permission: {
|
|
22
|
+
mode: config.permission.mode,
|
|
23
|
+
rules,
|
|
24
|
+
...(autoApproval
|
|
25
|
+
? {
|
|
26
|
+
autoApproval: {
|
|
27
|
+
allow: autoApproval.allow,
|
|
28
|
+
deny: autoApproval.deny,
|
|
29
|
+
environment: autoApproval.environment,
|
|
30
|
+
twoStageMode: autoApproval.twoStageMode,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
: {}),
|
|
34
|
+
},
|
|
35
|
+
loopControl: {
|
|
36
|
+
maxStepsPerTurn: config.loopControl.maxStepsPerTurn,
|
|
37
|
+
maxRetriesPerStep: config.loopControl.maxRetriesPerStep,
|
|
38
|
+
maxTurns: config.loopControl.maxTurns,
|
|
39
|
+
},
|
|
40
|
+
catalog: new ModelCatalog(config.models),
|
|
41
|
+
flags: new Flags(config.flags),
|
|
42
|
+
defaultModel: config.defaultModel,
|
|
43
|
+
thinking: config.thinking,
|
|
44
|
+
pluginMarketplaces: config.pluginMarketplaces,
|
|
45
|
+
hooks: hookDefsFromConfig(config.hooks),
|
|
46
|
+
config,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export async function resolveCoreOptions(resolver) {
|
|
50
|
+
return toCoreOptions(await resolver.resolve());
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=resolver.js.map
|