pi-improve-interation 0.0.1
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 +21 -0
- package/README.en.md +57 -0
- package/README.md +57 -0
- package/extensions/plus.ts +93 -0
- package/node_modules/acorn/CHANGELOG.md +998 -0
- package/node_modules/acorn/LICENSE +21 -0
- package/node_modules/acorn/README.md +309 -0
- package/node_modules/acorn/bin/acorn +4 -0
- package/node_modules/acorn/dist/acorn.d.mts +897 -0
- package/node_modules/acorn/dist/acorn.d.ts +897 -0
- package/node_modules/acorn/dist/acorn.js +6342 -0
- package/node_modules/acorn/dist/acorn.mjs +6313 -0
- package/node_modules/acorn/dist/bin.js +90 -0
- package/node_modules/acorn/package.json +50 -0
- package/node_modules/jiti/LICENSE +21 -0
- package/node_modules/jiti/README.md +258 -0
- package/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/node_modules/jiti/lib/jiti.cjs +30 -0
- package/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/jiti/package.json +146 -0
- package/node_modules/pi-subagents/CHANGELOG.md +2282 -0
- package/node_modules/pi-subagents/LICENSE +21 -0
- package/node_modules/pi-subagents/README.md +126 -0
- package/node_modules/pi-subagents/agents/claude-code-writer.md +15 -0
- package/node_modules/pi-subagents/agents/claude-code.md +15 -0
- package/node_modules/pi-subagents/agents/codex-exec-writer.md +15 -0
- package/node_modules/pi-subagents/agents/codex-exec.md +15 -0
- package/node_modules/pi-subagents/agents/cursor-agent-writer.md +14 -0
- package/node_modules/pi-subagents/agents/cursor-agent.md +14 -0
- package/node_modules/pi-subagents/agents/delegate.md +14 -0
- package/node_modules/pi-subagents/agents/oracle.md +78 -0
- package/node_modules/pi-subagents/agents/researcher.md +52 -0
- package/node_modules/pi-subagents/agents/reviewer.md +89 -0
- package/node_modules/pi-subagents/agents/scout.md +50 -0
- package/node_modules/pi-subagents/agents/worker.md +59 -0
- package/node_modules/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/node_modules/pi-subagents/docs/agents.md +492 -0
- package/node_modules/pi-subagents/docs/configuration.md +508 -0
- package/node_modules/pi-subagents/docs/extension-api.md +443 -0
- package/node_modules/pi-subagents/docs/missions.md +121 -0
- package/node_modules/pi-subagents/docs/models.md +258 -0
- package/node_modules/pi-subagents/docs/observability.md +262 -0
- package/node_modules/pi-subagents/docs/tool-reference.md +482 -0
- package/node_modules/pi-subagents/docs/watchdog.md +176 -0
- package/node_modules/pi-subagents/docs/workflows.md +475 -0
- package/node_modules/pi-subagents/index.ts +10 -0
- package/node_modules/pi-subagents/inspector-runner.mjs +11 -0
- package/node_modules/pi-subagents/install.mjs +93 -0
- package/node_modules/pi-subagents/package.json +109 -0
- package/node_modules/pi-subagents/prompts/council.md +60 -0
- package/node_modules/pi-subagents/prompts/gather-context-and-clarify.md +13 -0
- package/node_modules/pi-subagents/prompts/parallel-cleanup.md +59 -0
- package/node_modules/pi-subagents/prompts/parallel-research.md +50 -0
- package/node_modules/pi-subagents/prompts/parallel-review.md +58 -0
- package/node_modules/pi-subagents/prompts/review-loop.md +47 -0
- package/node_modules/pi-subagents/skills/council-mode/SKILL.md +59 -0
- package/node_modules/pi-subagents/skills/council-mode/references/pass-contracts.md +150 -0
- package/node_modules/pi-subagents/skills/pi-subagents/SKILL.md +103 -0
- package/node_modules/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +70 -0
- package/node_modules/pi-subagents/skills/pi-subagents/references/execution-controls.md +538 -0
- package/node_modules/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +161 -0
- package/node_modules/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +51 -0
- package/node_modules/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +295 -0
- package/node_modules/pi-subagents/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/node_modules/pi-subagents/src/agents/agent-management.ts +1355 -0
- package/node_modules/pi-subagents/src/agents/agent-memory.ts +254 -0
- package/node_modules/pi-subagents/src/agents/agent-refinements.ts +624 -0
- package/node_modules/pi-subagents/src/agents/agent-scope.ts +6 -0
- package/node_modules/pi-subagents/src/agents/agent-selection.ts +25 -0
- package/node_modules/pi-subagents/src/agents/agent-serializer.ts +179 -0
- package/node_modules/pi-subagents/src/agents/agents.ts +2808 -0
- package/node_modules/pi-subagents/src/agents/builtin-names.ts +15 -0
- package/node_modules/pi-subagents/src/agents/chain-serializer.ts +280 -0
- package/node_modules/pi-subagents/src/agents/frontmatter.ts +153 -0
- package/node_modules/pi-subagents/src/agents/identity.ts +30 -0
- package/node_modules/pi-subagents/src/agents/proactive-skills.ts +194 -0
- package/node_modules/pi-subagents/src/agents/runtime-agent-events.ts +70 -0
- package/node_modules/pi-subagents/src/agents/runtime-agent-registry.ts +429 -0
- package/node_modules/pi-subagents/src/agents/skills.ts +754 -0
- package/node_modules/pi-subagents/src/api/agents.ts +12 -0
- package/node_modules/pi-subagents/src/api/background-work.ts +206 -0
- package/node_modules/pi-subagents/src/api/capability-ceiling.ts +17 -0
- package/node_modules/pi-subagents/src/api/control-channel.ts +4 -0
- package/node_modules/pi-subagents/src/api/delegation.ts +112 -0
- package/node_modules/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/node_modules/pi-subagents/src/api/external-runs.ts +282 -0
- package/node_modules/pi-subagents/src/api/intercom-bridge.ts +3 -0
- package/node_modules/pi-subagents/src/api/pi-args.ts +5 -0
- package/node_modules/pi-subagents/src/api/preflight.ts +501 -0
- package/node_modules/pi-subagents/src/api/project-panes.ts +32 -0
- package/node_modules/pi-subagents/src/api/shared-types.ts +24 -0
- package/node_modules/pi-subagents/src/extension/config.ts +235 -0
- package/node_modules/pi-subagents/src/extension/control-notices.ts +58 -0
- package/node_modules/pi-subagents/src/extension/doctor.ts +278 -0
- package/node_modules/pi-subagents/src/extension/fanout-child.ts +205 -0
- package/node_modules/pi-subagents/src/extension/index.ts +1093 -0
- package/node_modules/pi-subagents/src/extension/public-execution.ts +210 -0
- package/node_modules/pi-subagents/src/extension/rpc.ts +860 -0
- package/node_modules/pi-subagents/src/extension/schemas.ts +419 -0
- package/node_modules/pi-subagents/src/extension/steering-notices.ts +35 -0
- package/node_modules/pi-subagents/src/extension/subagent-guide.ts +39 -0
- package/node_modules/pi-subagents/src/extension/tool-description.ts +221 -0
- package/node_modules/pi-subagents/src/extension/tool-result.ts +19 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/actions.ts +235 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/client.ts +130 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/inspector-runner.ts +147 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/project-panes.ts +730 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/node_modules/pi-subagents/src/inspectors/herdr/shell-command.ts +16 -0
- package/node_modules/pi-subagents/src/integrations/herdr-status.ts +400 -0
- package/node_modules/pi-subagents/src/intercom/intercom-bridge.ts +191 -0
- package/node_modules/pi-subagents/src/intercom/native-supervisor-channel.ts +812 -0
- package/node_modules/pi-subagents/src/intercom/result-intercom.ts +423 -0
- package/node_modules/pi-subagents/src/missions/actions.ts +433 -0
- package/node_modules/pi-subagents/src/missions/goal-driver.ts +164 -0
- package/node_modules/pi-subagents/src/missions/lifecycle.ts +367 -0
- package/node_modules/pi-subagents/src/missions/store.ts +584 -0
- package/node_modules/pi-subagents/src/missions/types.ts +190 -0
- package/node_modules/pi-subagents/src/missions/workflow-state.ts +260 -0
- package/node_modules/pi-subagents/src/policy/authority.ts +46 -0
- package/node_modules/pi-subagents/src/profiles/profiles.ts +662 -0
- package/node_modules/pi-subagents/src/runs/background/active-async-capacity.ts +517 -0
- package/node_modules/pi-subagents/src/runs/background/active-run-index.ts +139 -0
- package/node_modules/pi-subagents/src/runs/background/async-execution.ts +2031 -0
- package/node_modules/pi-subagents/src/runs/background/async-job-tracker.ts +781 -0
- package/node_modules/pi-subagents/src/runs/background/async-resume.ts +628 -0
- package/node_modules/pi-subagents/src/runs/background/async-retention.ts +903 -0
- package/node_modules/pi-subagents/src/runs/background/async-status-snapshot.ts +48 -0
- package/node_modules/pi-subagents/src/runs/background/async-status.ts +736 -0
- package/node_modules/pi-subagents/src/runs/background/auto-drain.ts +68 -0
- package/node_modules/pi-subagents/src/runs/background/chain-append.ts +321 -0
- package/node_modules/pi-subagents/src/runs/background/chain-root-attachment.ts +270 -0
- package/node_modules/pi-subagents/src/runs/background/completion-batcher.ts +168 -0
- package/node_modules/pi-subagents/src/runs/background/completion-dedupe.ts +58 -0
- package/node_modules/pi-subagents/src/runs/background/completion-replay.ts +287 -0
- package/node_modules/pi-subagents/src/runs/background/control-channel.ts +768 -0
- package/node_modules/pi-subagents/src/runs/background/fleet-view.ts +620 -0
- package/node_modules/pi-subagents/src/runs/background/index-segment.ts +59 -0
- package/node_modules/pi-subagents/src/runs/background/inspect-rpc.ts +443 -0
- package/node_modules/pi-subagents/src/runs/background/notify.ts +594 -0
- package/node_modules/pi-subagents/src/runs/background/owned-process-tree.ts +104 -0
- package/node_modules/pi-subagents/src/runs/background/parallel-groups.ts +45 -0
- package/node_modules/pi-subagents/src/runs/background/process-terminal.ts +310 -0
- package/node_modules/pi-subagents/src/runs/background/result-delivery-ownership.ts +45 -0
- package/node_modules/pi-subagents/src/runs/background/result-files.ts +519 -0
- package/node_modules/pi-subagents/src/runs/background/result-watcher.ts +792 -0
- package/node_modules/pi-subagents/src/runs/background/resume-guidance.ts +56 -0
- package/node_modules/pi-subagents/src/runs/background/retained-children.ts +135 -0
- package/node_modules/pi-subagents/src/runs/background/run-id-query.ts +7 -0
- package/node_modules/pi-subagents/src/runs/background/run-id-resolver.ts +175 -0
- package/node_modules/pi-subagents/src/runs/background/run-status.ts +694 -0
- package/node_modules/pi-subagents/src/runs/background/scheduled-runs.ts +965 -0
- package/node_modules/pi-subagents/src/runs/background/stale-run-reconciler.ts +410 -0
- package/node_modules/pi-subagents/src/runs/background/steering.ts +242 -0
- package/node_modules/pi-subagents/src/runs/background/subagent-runner.ts +5649 -0
- package/node_modules/pi-subagents/src/runs/background/subagent-wait.ts +725 -0
- package/node_modules/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/node_modules/pi-subagents/src/runs/background/top-level-async.ts +14 -0
- package/node_modules/pi-subagents/src/runs/background/wait-completions.ts +196 -0
- package/node_modules/pi-subagents/src/runs/background/wait-config.ts +50 -0
- package/node_modules/pi-subagents/src/runs/background/wait-subscriptions.ts +348 -0
- package/node_modules/pi-subagents/src/runs/background/wait-tool.ts +43 -0
- package/node_modules/pi-subagents/src/runs/foreground/async-dismiss-action.ts +86 -0
- package/node_modules/pi-subagents/src/runs/foreground/async-steering-action.ts +262 -0
- package/node_modules/pi-subagents/src/runs/foreground/async-stop-action.ts +86 -0
- package/node_modules/pi-subagents/src/runs/foreground/execution.ts +2437 -0
- package/node_modules/pi-subagents/src/runs/foreground/foreground-control.ts +153 -0
- package/node_modules/pi-subagents/src/runs/foreground/foreground-history.ts +160 -0
- package/node_modules/pi-subagents/src/runs/foreground/prompt-audit.ts +172 -0
- package/node_modules/pi-subagents/src/runs/foreground/subagent-executor.ts +6916 -0
- package/node_modules/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +299 -0
- package/node_modules/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +188 -0
- package/node_modules/pi-subagents/src/runs/shared/abort-recovery.ts +119 -0
- package/node_modules/pi-subagents/src/runs/shared/acceptance.ts +1509 -0
- package/node_modules/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
- package/node_modules/pi-subagents/src/runs/shared/async-status-projection.ts +597 -0
- package/node_modules/pi-subagents/src/runs/shared/background-process-options.ts +9 -0
- package/node_modules/pi-subagents/src/runs/shared/capability-ceiling.ts +210 -0
- package/node_modules/pi-subagents/src/runs/shared/chain-outputs.ts +116 -0
- package/node_modules/pi-subagents/src/runs/shared/child-identity.ts +51 -0
- package/node_modules/pi-subagents/src/runs/shared/child-launch-plan.ts +151 -0
- package/node_modules/pi-subagents/src/runs/shared/child-protocol.ts +415 -0
- package/node_modules/pi-subagents/src/runs/shared/claude-code-adapter.ts +129 -0
- package/node_modules/pi-subagents/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/node_modules/pi-subagents/src/runs/shared/completion-evidence.ts +89 -0
- package/node_modules/pi-subagents/src/runs/shared/completion-guard.ts +252 -0
- package/node_modules/pi-subagents/src/runs/shared/context-mode.ts +44 -0
- package/node_modules/pi-subagents/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/node_modules/pi-subagents/src/runs/shared/dynamic-fanout.ts +297 -0
- package/node_modules/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/node_modules/pi-subagents/src/runs/shared/external-cli-contract.ts +167 -0
- package/node_modules/pi-subagents/src/runs/shared/external-cli-preflight.ts +122 -0
- package/node_modules/pi-subagents/src/runs/shared/external-cli-runner.ts +429 -0
- package/node_modules/pi-subagents/src/runs/shared/external-job-bridge.ts +460 -0
- package/node_modules/pi-subagents/src/runs/shared/external-job-runner.ts +389 -0
- package/node_modules/pi-subagents/src/runs/shared/fast-mode-extension.ts +10 -0
- package/node_modules/pi-subagents/src/runs/shared/host-step-status.ts +231 -0
- package/node_modules/pi-subagents/src/runs/shared/lane-metadata.ts +105 -0
- package/node_modules/pi-subagents/src/runs/shared/launch-cwd.ts +16 -0
- package/node_modules/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +302 -0
- package/node_modules/pi-subagents/src/runs/shared/long-running-guard.ts +221 -0
- package/node_modules/pi-subagents/src/runs/shared/mcp-config-sources.ts +422 -0
- package/node_modules/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +483 -0
- package/node_modules/pi-subagents/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
- package/node_modules/pi-subagents/src/runs/shared/model-exclusions.ts +305 -0
- package/node_modules/pi-subagents/src/runs/shared/model-fallback.ts +578 -0
- package/node_modules/pi-subagents/src/runs/shared/model-scope.ts +205 -0
- package/node_modules/pi-subagents/src/runs/shared/mutation-evidence.ts +199 -0
- package/node_modules/pi-subagents/src/runs/shared/nested-events.ts +1086 -0
- package/node_modules/pi-subagents/src/runs/shared/nested-path.ts +52 -0
- package/node_modules/pi-subagents/src/runs/shared/nested-render.ts +127 -0
- package/node_modules/pi-subagents/src/runs/shared/orca-progress-tabs.ts +499 -0
- package/node_modules/pi-subagents/src/runs/shared/parallel-handoff.ts +692 -0
- package/node_modules/pi-subagents/src/runs/shared/parallel-utils.ts +275 -0
- package/node_modules/pi-subagents/src/runs/shared/permissions.ts +99 -0
- package/node_modules/pi-subagents/src/runs/shared/pi-args.ts +1056 -0
- package/node_modules/pi-subagents/src/runs/shared/pi-spawn.ts +197 -0
- package/node_modules/pi-subagents/src/runs/shared/process-signal.ts +32 -0
- package/node_modules/pi-subagents/src/runs/shared/run-fanout-budget.ts +280 -0
- package/node_modules/pi-subagents/src/runs/shared/run-history.ts +201 -0
- package/node_modules/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
- package/node_modules/pi-subagents/src/runs/shared/session-lease.ts +293 -0
- package/node_modules/pi-subagents/src/runs/shared/single-output.ts +304 -0
- package/node_modules/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
- package/node_modules/pi-subagents/src/runs/shared/structured-output.ts +223 -0
- package/node_modules/pi-subagents/src/runs/shared/subagent-control.ts +290 -0
- package/node_modules/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +824 -0
- package/node_modules/pi-subagents/src/runs/shared/subagent-startup-retry.ts +116 -0
- package/node_modules/pi-subagents/src/runs/shared/task-intent.ts +208 -0
- package/node_modules/pi-subagents/src/runs/shared/tool-availability.ts +81 -0
- package/node_modules/pi-subagents/src/runs/shared/tool-budget.ts +80 -0
- package/node_modules/pi-subagents/src/runs/shared/tool-timeout.ts +93 -0
- package/node_modules/pi-subagents/src/runs/shared/usage-budget.ts +65 -0
- package/node_modules/pi-subagents/src/runs/shared/workflow-graph.ts +225 -0
- package/node_modules/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +847 -0
- package/node_modules/pi-subagents/src/runs/shared/worktree.ts +802 -0
- package/node_modules/pi-subagents/src/shared/accessible-dir.ts +47 -0
- package/node_modules/pi-subagents/src/shared/agent-stream-options.ts +5 -0
- package/node_modules/pi-subagents/src/shared/artifacts.ts +281 -0
- package/node_modules/pi-subagents/src/shared/atomic-json.ts +83 -0
- package/node_modules/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/node_modules/pi-subagents/src/shared/child-session-name.ts +46 -0
- package/node_modules/pi-subagents/src/shared/child-transcript.ts +264 -0
- package/node_modules/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/node_modules/pi-subagents/src/shared/display-text.ts +150 -0
- package/node_modules/pi-subagents/src/shared/extension-context.ts +24 -0
- package/node_modules/pi-subagents/src/shared/file-coalescer.ts +49 -0
- package/node_modules/pi-subagents/src/shared/file-system-retry.ts +95 -0
- package/node_modules/pi-subagents/src/shared/fork-context.ts +293 -0
- package/node_modules/pi-subagents/src/shared/fork-session-cwd.ts +27 -0
- package/node_modules/pi-subagents/src/shared/formatters.ts +146 -0
- package/node_modules/pi-subagents/src/shared/jsonl-writer.ts +81 -0
- package/node_modules/pi-subagents/src/shared/launch-contract.ts +138 -0
- package/node_modules/pi-subagents/src/shared/model-info.ts +101 -0
- package/node_modules/pi-subagents/src/shared/node-executable.ts +21 -0
- package/node_modules/pi-subagents/src/shared/post-exit-stdio-guard.ts +85 -0
- package/node_modules/pi-subagents/src/shared/prompt-resources.ts +11 -0
- package/node_modules/pi-subagents/src/shared/pruned-fork.ts +450 -0
- package/node_modules/pi-subagents/src/shared/session-file-trust.ts +19 -0
- package/node_modules/pi-subagents/src/shared/session-identity.ts +10 -0
- package/node_modules/pi-subagents/src/shared/session-tokens.ts +55 -0
- package/node_modules/pi-subagents/src/shared/settings.ts +409 -0
- package/node_modules/pi-subagents/src/shared/shortcuts.ts +17 -0
- package/node_modules/pi-subagents/src/shared/status-format.ts +55 -0
- package/node_modules/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/node_modules/pi-subagents/src/shared/types.ts +2836 -0
- package/node_modules/pi-subagents/src/shared/utf8.ts +11 -0
- package/node_modules/pi-subagents/src/shared/utils.ts +590 -0
- package/node_modules/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/node_modules/pi-subagents/src/shared/workflow-child-permit.ts +207 -0
- package/node_modules/pi-subagents/src/slash/delegation-adapters.ts +426 -0
- package/node_modules/pi-subagents/src/slash/delegation-json.ts +108 -0
- package/node_modules/pi-subagents/src/slash/delegation-request.ts +162 -0
- package/node_modules/pi-subagents/src/slash/prompt-template-bridge.ts +419 -0
- package/node_modules/pi-subagents/src/slash/prompt-workflows.ts +287 -0
- package/node_modules/pi-subagents/src/slash/selector.ts +147 -0
- package/node_modules/pi-subagents/src/slash/slash-bridge.ts +192 -0
- package/node_modules/pi-subagents/src/slash/slash-commands.ts +1336 -0
- package/node_modules/pi-subagents/src/slash/slash-live-state.ts +310 -0
- package/node_modules/pi-subagents/src/slash/subagents-admin.ts +437 -0
- package/node_modules/pi-subagents/src/tui/fleet-status.ts +905 -0
- package/node_modules/pi-subagents/src/tui/fleet-transcript.ts +536 -0
- package/node_modules/pi-subagents/src/tui/fleet.ts +1436 -0
- package/node_modules/pi-subagents/src/tui/render-helpers.ts +111 -0
- package/node_modules/pi-subagents/src/tui/render.ts +3146 -0
- package/node_modules/pi-subagents/src/types/pi-runtime-compat.d.ts +8 -0
- package/node_modules/pi-subagents/src/watchdog/change-signature.ts +260 -0
- package/node_modules/pi-subagents/src/watchdog/child-status.ts +205 -0
- package/node_modules/pi-subagents/src/watchdog/emission-guard.ts +123 -0
- package/node_modules/pi-subagents/src/watchdog/lsp-diagnostics.ts +538 -0
- package/node_modules/pi-subagents/src/watchdog/model-selection.ts +167 -0
- package/node_modules/pi-subagents/src/watchdog/permission-arbiter.ts +154 -0
- package/node_modules/pi-subagents/src/watchdog/register-child.ts +117 -0
- package/node_modules/pi-subagents/src/watchdog/register-main.ts +440 -0
- package/node_modules/pi-subagents/src/watchdog/render.ts +54 -0
- package/node_modules/pi-subagents/src/watchdog/review.ts +303 -0
- package/node_modules/pi-subagents/src/watchdog/runtime.ts +868 -0
- package/node_modules/pi-subagents/src/watchdog/scope.ts +62 -0
- package/node_modules/pi-subagents/src/watchdog/settings.ts +568 -0
- package/node_modules/pi-subagents/src/watchdog/tool-actions.ts +155 -0
- package/node_modules/pi-subagents/src/watchdog/turn-delta.ts +161 -0
- package/node_modules/pi-subagents/src/watchdog/types.ts +198 -0
- package/node_modules/pi-subagents/src/watchdog/warning-format.ts +73 -0
- package/node_modules/pi-subagents/src/workflows/chat-progress.ts +151 -0
- package/node_modules/pi-subagents/src/workflows/host-command.ts +235 -0
- package/node_modules/pi-subagents/src/workflows/scripted-workflow.ts +2183 -0
- package/node_modules/pi-subagents/src/workflows/workflow-child-summary.ts +121 -0
- package/node_modules/pi-subagents/src/workflows/workflow-preflight.ts +270 -0
- package/node_modules/pi-subagents/src/workflows/workflow-receipt.ts +366 -0
- package/node_modules/pi-subagents/src/workflows/workflow-resources.ts +150 -0
- package/node_modules/pi-subagents/src/workflows/workflow-settlement.ts +246 -0
- package/node_modules/typebox/build/compile/code.d.mts +12 -0
- package/node_modules/typebox/build/compile/code.mjs +65 -0
- package/node_modules/typebox/build/compile/compile.d.mts +6 -0
- package/node_modules/typebox/build/compile/compile.mjs +12 -0
- package/node_modules/typebox/build/compile/index.d.mts +8 -0
- package/node_modules/typebox/build/compile/index.mjs +14 -0
- package/node_modules/typebox/build/compile/validator.d.mts +43 -0
- package/node_modules/typebox/build/compile/validator.mjs +121 -0
- package/node_modules/typebox/build/error/errors.d.mts +214 -0
- package/node_modules/typebox/build/error/errors.mjs +18 -0
- package/node_modules/typebox/build/error/index.d.mts +1 -0
- package/node_modules/typebox/build/error/index.mjs +1 -0
- package/node_modules/typebox/build/format/_idna.d.mts +2 -0
- package/node_modules/typebox/build/format/_idna.mjs +216 -0
- package/node_modules/typebox/build/format/_puny.d.mts +1 -0
- package/node_modules/typebox/build/format/_puny.mjs +74 -0
- package/node_modules/typebox/build/format/_registry.d.mts +15 -0
- package/node_modules/typebox/build/format/_registry.mjs +96 -0
- package/node_modules/typebox/build/format/date.d.mts +6 -0
- package/node_modules/typebox/build/format/date.mjs +19 -0
- package/node_modules/typebox/build/format/date_time.d.mts +6 -0
- package/node_modules/typebox/build/format/date_time.mjs +11 -0
- package/node_modules/typebox/build/format/duration.d.mts +5 -0
- package/node_modules/typebox/build/format/duration.mjs +8 -0
- package/node_modules/typebox/build/format/email.d.mts +5 -0
- package/node_modules/typebox/build/format/email.mjs +8 -0
- package/node_modules/typebox/build/format/format.d.mts +22 -0
- package/node_modules/typebox/build/format/format.mjs +22 -0
- package/node_modules/typebox/build/format/hostname.d.mts +7 -0
- package/node_modules/typebox/build/format/hostname.mjs +18 -0
- package/node_modules/typebox/build/format/idn_email.d.mts +5 -0
- package/node_modules/typebox/build/format/idn_email.mjs +8 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +7 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +19 -0
- package/node_modules/typebox/build/format/index.d.mts +4 -0
- package/node_modules/typebox/build/format/index.mjs +4 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +6 -0
- package/node_modules/typebox/build/format/ipv4.mjs +38 -0
- package/node_modules/typebox/build/format/ipv6.d.mts +5 -0
- package/node_modules/typebox/build/format/ipv6.mjs +67 -0
- package/node_modules/typebox/build/format/iri.d.mts +5 -0
- package/node_modules/typebox/build/format/iri.mjs +13 -0
- package/node_modules/typebox/build/format/iri_reference.d.mts +5 -0
- package/node_modules/typebox/build/format/iri_reference.mjs +60 -0
- package/node_modules/typebox/build/format/json_pointer.d.mts +6 -0
- package/node_modules/typebox/build/format/json_pointer.mjs +9 -0
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +6 -0
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +9 -0
- package/node_modules/typebox/build/format/regex.d.mts +6 -0
- package/node_modules/typebox/build/format/regex.mjs +17 -0
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +6 -0
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +9 -0
- package/node_modules/typebox/build/format/time.d.mts +5 -0
- package/node_modules/typebox/build/format/time.mjs +27 -0
- package/node_modules/typebox/build/format/uri.d.mts +5 -0
- package/node_modules/typebox/build/format/uri.mjs +135 -0
- package/node_modules/typebox/build/format/uri_reference.d.mts +5 -0
- package/node_modules/typebox/build/format/uri_reference.mjs +9 -0
- package/node_modules/typebox/build/format/uri_template.d.mts +6 -0
- package/node_modules/typebox/build/format/uri_template.mjs +10 -0
- package/node_modules/typebox/build/format/url.d.mts +6 -0
- package/node_modules/typebox/build/format/url.mjs +9 -0
- package/node_modules/typebox/build/format/uuid.d.mts +6 -0
- package/node_modules/typebox/build/format/uuid.mjs +9 -0
- package/node_modules/typebox/build/guard/emit.d.mts +58 -0
- package/node_modules/typebox/build/guard/emit.mjs +194 -0
- package/node_modules/typebox/build/guard/globals.d.mts +35 -0
- package/node_modules/typebox/build/guard/globals.mjs +90 -0
- package/node_modules/typebox/build/guard/guard.d.mts +69 -0
- package/node_modules/typebox/build/guard/guard.mjs +217 -0
- package/node_modules/typebox/build/guard/index.d.mts +6 -0
- package/node_modules/typebox/build/guard/index.mjs +6 -0
- package/node_modules/typebox/build/guard/native.d.mts +20 -0
- package/node_modules/typebox/build/guard/native.mjs +60 -0
- package/node_modules/typebox/build/guard/string.d.mts +6 -0
- package/node_modules/typebox/build/guard/string.mjs +164 -0
- package/node_modules/typebox/build/index.d.mts +8 -0
- package/node_modules/typebox/build/index.mjs +14 -0
- package/node_modules/typebox/build/schema/build.d.mts +39 -0
- package/node_modules/typebox/build/schema/build.mjs +118 -0
- package/node_modules/typebox/build/schema/check.d.mts +6 -0
- package/node_modules/typebox/build/schema/check.mjs +14 -0
- package/node_modules/typebox/build/schema/compile.d.mts +22 -0
- package/node_modules/typebox/build/schema/compile.mjs +46 -0
- package/node_modules/typebox/build/schema/engine/_context.d.mts +35 -0
- package/node_modules/typebox/build/schema/engine/_context.mjs +129 -0
- package/node_modules/typebox/build/schema/engine/_exact_optional.d.mts +3 -0
- package/node_modules/typebox/build/schema/engine/_exact_optional.mjs +20 -0
- package/node_modules/typebox/build/schema/engine/_externals.d.mts +7 -0
- package/node_modules/typebox/build/schema/engine/_externals.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/_functions.mjs +47 -0
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/_guard.mjs +26 -0
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +4 -0
- package/node_modules/typebox/build/schema/engine/_reducer.mjs +45 -0
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/_refine.mjs +29 -0
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +18 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +107 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_unique.mjs +5 -0
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +50 -0
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +110 -0
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/allOf.mjs +47 -0
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +52 -0
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +5 -0
- package/node_modules/typebox/build/schema/engine/boolean.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/const.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/const.mjs +30 -0
- package/node_modules/typebox/build/schema/engine/contains.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/contains.mjs +42 -0
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +45 -0
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +40 -0
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +38 -0
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/enum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/enum.mjs +33 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/format.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/format.mjs +26 -0
- package/node_modules/typebox/build/schema/engine/if.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/if.mjs +47 -0
- package/node_modules/typebox/build/schema/engine/index.d.mts +49 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +55 -0
- package/node_modules/typebox/build/schema/engine/items.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +68 -0
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +42 -0
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maximum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minContains.mjs +41 -0
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minItems.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minLength.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minimum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/not.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/not.mjs +37 -0
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +58 -0
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/pattern.mjs +28 -0
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +44 -0
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +35 -0
- package/node_modules/typebox/build/schema/engine/properties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/properties.mjs +75 -0
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +39 -0
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/ref.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/ref.mjs +58 -0
- package/node_modules/typebox/build/schema/engine/required.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/required.mjs +32 -0
- package/node_modules/typebox/build/schema/engine/schema.d.mts +9 -0
- package/node_modules/typebox/build/schema/engine/schema.mjs +352 -0
- package/node_modules/typebox/build/schema/engine/type.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/type.mjs +74 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +51 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +51 -0
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +51 -0
- package/node_modules/typebox/build/schema/errors.d.mts +6 -0
- package/node_modules/typebox/build/schema/errors.mjs +24 -0
- package/node_modules/typebox/build/schema/index.d.mts +3 -0
- package/node_modules/typebox/build/schema/index.mjs +9 -0
- package/node_modules/typebox/build/schema/parse.d.mts +13 -0
- package/node_modules/typebox/build/schema/parse.mjs +27 -0
- package/node_modules/typebox/build/schema/pointer/index.d.mts +2 -0
- package/node_modules/typebox/build/schema/pointer/index.mjs +2 -0
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +10 -0
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +106 -0
- package/node_modules/typebox/build/schema/pointer/pointer_get.d.mts +9 -0
- package/node_modules/typebox/build/schema/pointer/pointer_get.mjs +2 -0
- package/node_modules/typebox/build/schema/resolve/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/resolve/index.mjs +1 -0
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +3 -0
- package/node_modules/typebox/build/schema/resolve/ref.mjs +146 -0
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +1 -0
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +1 -0
- package/node_modules/typebox/build/schema/schema.d.mts +10 -0
- package/node_modules/typebox/build/schema/schema.mjs +10 -0
- package/node_modules/typebox/build/schema/static/_canonical.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/_canonical.mjs +2 -0
- package/node_modules/typebox/build/schema/static/_comparer.d.mts +6 -0
- package/node_modules/typebox/build/schema/static/_comparer.mjs +2 -0
- package/node_modules/typebox/build/schema/static/_elements.d.mts +18 -0
- package/node_modules/typebox/build/schema/static/_elements.mjs +2 -0
- package/node_modules/typebox/build/schema/static/additionalProperties.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/additionalProperties.mjs +3 -0
- package/node_modules/typebox/build/schema/static/allOf.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/allOf.mjs +2 -0
- package/node_modules/typebox/build/schema/static/anyOf.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/anyOf.mjs +2 -0
- package/node_modules/typebox/build/schema/static/const.d.mts +1 -0
- package/node_modules/typebox/build/schema/static/const.mjs +2 -0
- package/node_modules/typebox/build/schema/static/enum.d.mts +1 -0
- package/node_modules/typebox/build/schema/static/enum.mjs +2 -0
- package/node_modules/typebox/build/schema/static/if.d.mts +15 -0
- package/node_modules/typebox/build/schema/static/if.mjs +2 -0
- package/node_modules/typebox/build/schema/static/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/static/index.mjs +1 -0
- package/node_modules/typebox/build/schema/static/items.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/items.mjs +2 -0
- package/node_modules/typebox/build/schema/static/oneOf.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/oneOf.mjs +2 -0
- package/node_modules/typebox/build/schema/static/patternProperties.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/patternProperties.mjs +2 -0
- package/node_modules/typebox/build/schema/static/prefixItems.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/prefixItems.mjs +2 -0
- package/node_modules/typebox/build/schema/static/properties.d.mts +32 -0
- package/node_modules/typebox/build/schema/static/properties.mjs +2 -0
- package/node_modules/typebox/build/schema/static/ref.d.mts +8 -0
- package/node_modules/typebox/build/schema/static/ref.mjs +3 -0
- package/node_modules/typebox/build/schema/static/required.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/required.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +56 -0
- package/node_modules/typebox/build/schema/static/schema.mjs +2 -0
- package/node_modules/typebox/build/schema/static/static.d.mts +4 -0
- package/node_modules/typebox/build/schema/static/static.mjs +3 -0
- package/node_modules/typebox/build/schema/static/type.d.mts +4 -0
- package/node_modules/typebox/build/schema/static/type.mjs +3 -0
- package/node_modules/typebox/build/schema/static/unevaluatedProperties.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/unevaluatedProperties.mjs +3 -0
- package/node_modules/typebox/build/schema/types/_guard.d.mts +10 -0
- package/node_modules/typebox/build/schema/types/_guard.mjs +16 -0
- package/node_modules/typebox/build/schema/types/_refine.d.mts +13 -0
- package/node_modules/typebox/build/schema/types/_refine.mjs +18 -0
- package/node_modules/typebox/build/schema/types/additionalItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/additionalItems.mjs +14 -0
- package/node_modules/typebox/build/schema/types/additionalProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/additionalProperties.mjs +14 -0
- package/node_modules/typebox/build/schema/types/allOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/allOf.mjs +15 -0
- package/node_modules/typebox/build/schema/types/anchor.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/anchor.mjs +12 -0
- package/node_modules/typebox/build/schema/types/anyOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/anyOf.mjs +15 -0
- package/node_modules/typebox/build/schema/types/const.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/const.mjs +12 -0
- package/node_modules/typebox/build/schema/types/contains.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/contains.mjs +14 -0
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +13 -0
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +13 -0
- package/node_modules/typebox/build/schema/types/default.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/default.mjs +12 -0
- package/node_modules/typebox/build/schema/types/defs.d.mts +6 -0
- package/node_modules/typebox/build/schema/types/defs.mjs +12 -0
- package/node_modules/typebox/build/schema/types/dependencies.d.mts +11 -0
- package/node_modules/typebox/build/schema/types/dependencies.mjs +16 -0
- package/node_modules/typebox/build/schema/types/dependentRequired.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/dependentRequired.mjs +15 -0
- package/node_modules/typebox/build/schema/types/dependentSchemas.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/dependentSchemas.mjs +15 -0
- package/node_modules/typebox/build/schema/types/dynamicAnchor.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/dynamicAnchor.mjs +12 -0
- package/node_modules/typebox/build/schema/types/dynamicRef.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/dynamicRef.mjs +12 -0
- package/node_modules/typebox/build/schema/types/else.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/else.mjs +14 -0
- package/node_modules/typebox/build/schema/types/enum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/enum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/exclusiveMaximum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/exclusiveMaximum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/exclusiveMinimum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/exclusiveMinimum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/format.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/format.mjs +13 -0
- package/node_modules/typebox/build/schema/types/id.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/id.mjs +13 -0
- package/node_modules/typebox/build/schema/types/if.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/if.mjs +14 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +54 -0
- package/node_modules/typebox/build/schema/types/index.mjs +60 -0
- package/node_modules/typebox/build/schema/types/items.d.mts +19 -0
- package/node_modules/typebox/build/schema/types/items.mjs +26 -0
- package/node_modules/typebox/build/schema/types/maxContains.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxContains.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maxItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxItems.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maxLength.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxLength.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maxProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxProperties.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maximum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maximum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minContains.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minContains.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minItems.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minLength.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minLength.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minProperties.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minimum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minimum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/multipleOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/multipleOf.mjs +13 -0
- package/node_modules/typebox/build/schema/types/not.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/not.mjs +14 -0
- package/node_modules/typebox/build/schema/types/oneOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/oneOf.mjs +15 -0
- package/node_modules/typebox/build/schema/types/pattern.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/pattern.mjs +14 -0
- package/node_modules/typebox/build/schema/types/patternProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/patternProperties.mjs +15 -0
- package/node_modules/typebox/build/schema/types/prefixItems.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/prefixItems.mjs +14 -0
- package/node_modules/typebox/build/schema/types/properties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/properties.mjs +15 -0
- package/node_modules/typebox/build/schema/types/propertyNames.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/propertyNames.mjs +15 -0
- package/node_modules/typebox/build/schema/types/recursiveAnchor.d.mts +12 -0
- package/node_modules/typebox/build/schema/types/recursiveAnchor.mjs +19 -0
- package/node_modules/typebox/build/schema/types/recursiveRef.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/recursiveRef.mjs +12 -0
- package/node_modules/typebox/build/schema/types/ref.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/ref.mjs +13 -0
- package/node_modules/typebox/build/schema/types/required.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/required.mjs +14 -0
- package/node_modules/typebox/build/schema/types/schema.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/schema.mjs +14 -0
- package/node_modules/typebox/build/schema/types/then.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/then.mjs +14 -0
- package/node_modules/typebox/build/schema/types/type.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/type.mjs +15 -0
- package/node_modules/typebox/build/schema/types/unevaluatedItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/unevaluatedItems.mjs +14 -0
- package/node_modules/typebox/build/schema/types/unevaluatedProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/unevaluatedProperties.mjs +14 -0
- package/node_modules/typebox/build/schema/types/uniqueItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/uniqueItems.mjs +13 -0
- package/node_modules/typebox/build/system/arguments/arguments.d.mts +5 -0
- package/node_modules/typebox/build/system/arguments/arguments.mjs +9 -0
- package/node_modules/typebox/build/system/arguments/index.d.mts +1 -0
- package/node_modules/typebox/build/system/arguments/index.mjs +1 -0
- package/node_modules/typebox/build/system/environment/environment.d.mts +1 -0
- package/node_modules/typebox/build/system/environment/environment.mjs +1 -0
- package/node_modules/typebox/build/system/environment/evaluate.d.mts +9 -0
- package/node_modules/typebox/build/system/environment/evaluate.mjs +37 -0
- package/node_modules/typebox/build/system/environment/index.d.mts +1 -0
- package/node_modules/typebox/build/system/environment/index.mjs +1 -0
- package/node_modules/typebox/build/system/hashing/hash.d.mts +4 -0
- package/node_modules/typebox/build/system/hashing/hash.mjs +232 -0
- package/node_modules/typebox/build/system/hashing/index.d.mts +1 -0
- package/node_modules/typebox/build/system/hashing/index.mjs +1 -0
- package/node_modules/typebox/build/system/index.d.mts +4 -0
- package/node_modules/typebox/build/system/index.mjs +4 -0
- package/node_modules/typebox/build/system/locale/_config.d.mts +7 -0
- package/node_modules/typebox/build/system/locale/_config.mjs +15 -0
- package/node_modules/typebox/build/system/locale/_locale.d.mts +40 -0
- package/node_modules/typebox/build/system/locale/_locale.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ar_001.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ar_001.mjs +41 -0
- package/node_modules/typebox/build/system/locale/bn_BD.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +41 -0
- package/node_modules/typebox/build/system/locale/cs_CZ.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +41 -0
- package/node_modules/typebox/build/system/locale/de_DE.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/de_DE.mjs +41 -0
- package/node_modules/typebox/build/system/locale/el_GR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/el_GR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/en_US.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/en_US.mjs +40 -0
- package/node_modules/typebox/build/system/locale/es_419.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_419.mjs +41 -0
- package/node_modules/typebox/build/system/locale/es_AR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_AR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/es_ES.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_ES.mjs +41 -0
- package/node_modules/typebox/build/system/locale/es_MX.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_MX.mjs +41 -0
- package/node_modules/typebox/build/system/locale/fa_IR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/fil_PH.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +41 -0
- package/node_modules/typebox/build/system/locale/fr_CA.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +41 -0
- package/node_modules/typebox/build/system/locale/fr_FR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ha_NG.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +41 -0
- package/node_modules/typebox/build/system/locale/hi_IN.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +41 -0
- package/node_modules/typebox/build/system/locale/hu_HU.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +41 -0
- package/node_modules/typebox/build/system/locale/id_ID.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/id_ID.mjs +41 -0
- package/node_modules/typebox/build/system/locale/index.d.mts +1 -0
- package/node_modules/typebox/build/system/locale/index.mjs +1 -0
- package/node_modules/typebox/build/system/locale/it_IT.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/it_IT.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ja_JP.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ko_KR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ms_MY.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +41 -0
- package/node_modules/typebox/build/system/locale/nl_NL.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +41 -0
- package/node_modules/typebox/build/system/locale/pl_PL.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +41 -0
- package/node_modules/typebox/build/system/locale/pt_BR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/pt_PT.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ro_RO.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ru_RU.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +41 -0
- package/node_modules/typebox/build/system/locale/sv_SE.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +41 -0
- package/node_modules/typebox/build/system/locale/sw_TZ.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +41 -0
- package/node_modules/typebox/build/system/locale/th_TH.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/th_TH.mjs +41 -0
- package/node_modules/typebox/build/system/locale/tr_TR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +41 -0
- package/node_modules/typebox/build/system/locale/uk_UA.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +41 -0
- package/node_modules/typebox/build/system/locale/ur_PK.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +41 -0
- package/node_modules/typebox/build/system/locale/vi_VN.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +41 -0
- package/node_modules/typebox/build/system/locale/yo_NG.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +41 -0
- package/node_modules/typebox/build/system/locale/zh_Hans.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +41 -0
- package/node_modules/typebox/build/system/locale/zh_Hant.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +41 -0
- package/node_modules/typebox/build/system/memory/assign.d.mts +14 -0
- package/node_modules/typebox/build/system/memory/assign.mjs +11 -0
- package/node_modules/typebox/build/system/memory/clone.d.mts +6 -0
- package/node_modules/typebox/build/system/memory/clone.mjs +63 -0
- package/node_modules/typebox/build/system/memory/create.d.mts +8 -0
- package/node_modules/typebox/build/system/memory/create.mjs +30 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/discard.mjs +17 -0
- package/node_modules/typebox/build/system/memory/index.d.mts +1 -0
- package/node_modules/typebox/build/system/memory/index.mjs +1 -0
- package/node_modules/typebox/build/system/memory/memory.d.mts +6 -0
- package/node_modules/typebox/build/system/memory/memory.mjs +7 -0
- package/node_modules/typebox/build/system/memory/metrics.d.mts +14 -0
- package/node_modules/typebox/build/system/memory/metrics.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +7 -0
- package/node_modules/typebox/build/system/memory/update.mjs +32 -0
- package/node_modules/typebox/build/system/settings/index.d.mts +1 -0
- package/node_modules/typebox/build/system/settings/index.mjs +1 -0
- package/node_modules/typebox/build/system/settings/settings.d.mts +56 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +32 -0
- package/node_modules/typebox/build/system/system.d.mts +6 -0
- package/node_modules/typebox/build/system/system.mjs +6 -0
- package/node_modules/typebox/build/system/unreachable/index.d.mts +1 -0
- package/node_modules/typebox/build/system/unreachable/index.mjs +1 -0
- package/node_modules/typebox/build/system/unreachable/unreachable.d.mts +3 -0
- package/node_modules/typebox/build/system/unreachable/unreachable.mjs +6 -0
- package/node_modules/typebox/build/type/action/_optional.d.mts +19 -0
- package/node_modules/typebox/build/type/action/_optional.mjs +40 -0
- package/node_modules/typebox/build/type/action/_readonly.d.mts +19 -0
- package/node_modules/typebox/build/type/action/_readonly.mjs +40 -0
- package/node_modules/typebox/build/type/action/awaited.d.mts +15 -0
- package/node_modules/typebox/build/type/action/awaited.mjs +15 -0
- package/node_modules/typebox/build/type/action/capitalize.d.mts +11 -0
- package/node_modules/typebox/build/type/action/capitalize.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +13 -0
- package/node_modules/typebox/build/type/action/conditional.mjs +12 -0
- package/node_modules/typebox/build/type/action/constructor_parameters.d.mts +11 -0
- package/node_modules/typebox/build/type/action/constructor_parameters.mjs +11 -0
- package/node_modules/typebox/build/type/action/evaluate.d.mts +11 -0
- package/node_modules/typebox/build/type/action/evaluate.mjs +11 -0
- package/node_modules/typebox/build/type/action/exclude.d.mts +11 -0
- package/node_modules/typebox/build/type/action/exclude.mjs +11 -0
- package/node_modules/typebox/build/type/action/extract.d.mts +11 -0
- package/node_modules/typebox/build/type/action/extract.mjs +11 -0
- package/node_modules/typebox/build/type/action/index.d.mts +27 -0
- package/node_modules/typebox/build/type/action/index.mjs +27 -0
- package/node_modules/typebox/build/type/action/indexed.d.mts +14 -0
- package/node_modules/typebox/build/type/action/indexed.mjs +14 -0
- package/node_modules/typebox/build/type/action/instance_type.d.mts +11 -0
- package/node_modules/typebox/build/type/action/instance_type.mjs +11 -0
- package/node_modules/typebox/build/type/action/interface.d.mts +14 -0
- package/node_modules/typebox/build/type/action/interface.mjs +22 -0
- package/node_modules/typebox/build/type/action/keyof.d.mts +11 -0
- package/node_modules/typebox/build/type/action/keyof.mjs +11 -0
- package/node_modules/typebox/build/type/action/lowercase.d.mts +11 -0
- package/node_modules/typebox/build/type/action/lowercase.mjs +11 -0
- package/node_modules/typebox/build/type/action/mapped.d.mts +14 -0
- package/node_modules/typebox/build/type/action/mapped.mjs +12 -0
- package/node_modules/typebox/build/type/action/module.d.mts +12 -0
- package/node_modules/typebox/build/type/action/module.mjs +12 -0
- package/node_modules/typebox/build/type/action/non_nullable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/non_nullable.mjs +11 -0
- package/node_modules/typebox/build/type/action/omit.d.mts +14 -0
- package/node_modules/typebox/build/type/action/omit.mjs +14 -0
- package/node_modules/typebox/build/type/action/options.d.mts +11 -0
- package/node_modules/typebox/build/type/action/options.mjs +11 -0
- package/node_modules/typebox/build/type/action/parameters.d.mts +11 -0
- package/node_modules/typebox/build/type/action/parameters.mjs +11 -0
- package/node_modules/typebox/build/type/action/partial.d.mts +11 -0
- package/node_modules/typebox/build/type/action/partial.mjs +11 -0
- package/node_modules/typebox/build/type/action/pick.d.mts +14 -0
- package/node_modules/typebox/build/type/action/pick.mjs +14 -0
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +16 -0
- package/node_modules/typebox/build/type/action/readonly_object.mjs +16 -0
- package/node_modules/typebox/build/type/action/required.d.mts +11 -0
- package/node_modules/typebox/build/type/action/required.mjs +11 -0
- package/node_modules/typebox/build/type/action/return_type.d.mts +11 -0
- package/node_modules/typebox/build/type/action/return_type.mjs +11 -0
- package/node_modules/typebox/build/type/action/uncapitalize.d.mts +11 -0
- package/node_modules/typebox/build/type/action/uncapitalize.mjs +11 -0
- package/node_modules/typebox/build/type/action/uppercase.d.mts +11 -0
- package/node_modules/typebox/build/type/action/uppercase.mjs +11 -0
- package/node_modules/typebox/build/type/engine/awaited/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/awaited/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +20 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +53 -0
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +23 -0
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +48 -0
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.d.mts +13 -0
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +33 -0
- package/node_modules/typebox/build/type/engine/call/resolve_target.d.mts +25 -0
- package/node_modules/typebox/build/type/engine/call/resolve_target.mjs +27 -0
- package/node_modules/typebox/build/type/engine/conditional/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/conditional/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/conditional/instantiate.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/conditional/instantiate.mjs +23 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +24 -0
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +19 -0
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +24 -0
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +51 -0
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +25 -0
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +53 -0
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +31 -0
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +53 -0
- package/node_modules/typebox/build/type/engine/cyclic/index.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/cyclic/index.mjs +6 -0
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +30 -0
- package/node_modules/typebox/build/type/engine/cyclic/target.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/cyclic/target.mjs +16 -0
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +24 -0
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +2 -0
- package/node_modules/typebox/build/type/engine/enum/index.mjs +2 -0
- package/node_modules/typebox/build/type/engine/enum/typescript_enum_to_enum_values.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/enum/typescript_enum_to_enum_values.mjs +9 -0
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +47 -0
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +22 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +63 -0
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +27 -0
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +45 -0
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +27 -0
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +11 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +8 -0
- package/node_modules/typebox/build/type/engine/evaluate/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/evaluate/instantiate.mjs +12 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +11 -0
- package/node_modules/typebox/build/type/engine/exclude/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/exclude/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/exclude/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/exclude/instantiate.mjs +16 -0
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +24 -0
- package/node_modules/typebox/build/type/engine/extract/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/extract/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/extract/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/extract/instantiate.mjs +16 -0
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +24 -0
- package/node_modules/typebox/build/type/engine/helpers/index.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/helpers/index.mjs +3 -0
- package/node_modules/typebox/build/type/engine/helpers/keys.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/helpers/keys.mjs +8 -0
- package/node_modules/typebox/build/type/engine/helpers/keys_to_indexer.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/helpers/keys_to_indexer.mjs +15 -0
- package/node_modules/typebox/build/type/engine/helpers/union.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/helpers/union.mjs +3 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +31 -0
- package/node_modules/typebox/build/type/engine/index.mjs +37 -0
- package/node_modules/typebox/build/type/engine/indexable/from_cyclic.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/indexable/from_cyclic.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_literal.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/indexable/from_literal.mjs +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +17 -0
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +22 -0
- package/node_modules/typebox/build/type/engine/indexable/from_union.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/indexable/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable.mjs +14 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable_keys.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable_keys.mjs +12 -0
- package/node_modules/typebox/build/type/engine/indexed/array_indexer.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/indexed/array_indexer.mjs +18 -0
- package/node_modules/typebox/build/type/engine/indexed/from_array.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/indexed/from_array.mjs +35 -0
- package/node_modules/typebox/build/type/engine/indexed/from_object.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/indexed/from_object.mjs +40 -0
- package/node_modules/typebox/build/type/engine/indexed/from_tuple.d.mts +13 -0
- package/node_modules/typebox/build/type/engine/indexed/from_tuple.mjs +35 -0
- package/node_modules/typebox/build/type/engine/indexed/from_type.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/indexed/from_type.mjs +14 -0
- package/node_modules/typebox/build/type/engine/indexed/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/indexed/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +25 -0
- package/node_modules/typebox/build/type/engine/instance_type/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/instance_type/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/instance_type/instantiate.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/instance_type/instantiate.mjs +21 -0
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +165 -0
- package/node_modules/typebox/build/type/engine/instantiate.mjs +159 -0
- package/node_modules/typebox/build/type/engine/interface/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/interface/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +18 -0
- package/node_modules/typebox/build/type/engine/interface/instantiate.mjs +23 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_literal.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_literal.mjs +9 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +8 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_type.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_type.mjs +13 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_union.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/intrinsics/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/intrinsics/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/intrinsics/instantiate.d.mts +38 -0
- package/node_modules/typebox/build/type/engine/intrinsics/instantiate.mjs +52 -0
- package/node_modules/typebox/build/type/engine/intrinsics/mapping.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/intrinsics/mapping.mjs +4 -0
- package/node_modules/typebox/build/type/engine/keyof/from_any.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/keyof/from_any.mjs +8 -0
- package/node_modules/typebox/build/type/engine/keyof/from_array.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/keyof/from_array.mjs +5 -0
- package/node_modules/typebox/build/type/engine/keyof/from_object.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/keyof/from_object.mjs +20 -0
- package/node_modules/typebox/build/type/engine/keyof/from_record.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/keyof/from_record.mjs +5 -0
- package/node_modules/typebox/build/type/engine/keyof/from_tuple.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/keyof/from_tuple.mjs +7 -0
- package/node_modules/typebox/build/type/engine/keyof/from_type.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/keyof/from_type.mjs +23 -0
- package/node_modules/typebox/build/type/engine/keyof/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/keyof/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +25 -0
- package/node_modules/typebox/build/type/engine/mapped/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/mapped/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/mapped/instantiate.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/mapped/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +22 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +42 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +34 -0
- package/node_modules/typebox/build/type/engine/module/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/module/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +21 -0
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +34 -0
- package/node_modules/typebox/build/type/engine/non_nullable/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/non_nullable/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/non_nullable/instantiate.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/non_nullable/instantiate.mjs +22 -0
- package/node_modules/typebox/build/type/engine/object/collapse.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/object/collapse.mjs +14 -0
- package/node_modules/typebox/build/type/engine/object/from_cyclic.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/object/from_cyclic.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +17 -0
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +22 -0
- package/node_modules/typebox/build/type/engine/object/from_object.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/object/from_object.mjs +4 -0
- package/node_modules/typebox/build/type/engine/object/from_tuple.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/object/from_tuple.mjs +9 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +20 -0
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +19 -0
- package/node_modules/typebox/build/type/engine/object/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/object/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/omit/from_type.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/omit/from_type.mjs +18 -0
- package/node_modules/typebox/build/type/engine/omit/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/omit/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/omit/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/omit/instantiate.mjs +16 -0
- package/node_modules/typebox/build/type/engine/options/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/options/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/options/instantiate.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/parameters/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +24 -0
- package/node_modules/typebox/build/type/engine/partial/from_cyclic.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/partial/from_cyclic.mjs +11 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +7 -0
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +11 -0
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +17 -0
- package/node_modules/typebox/build/type/engine/partial/from_union.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/partial/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/partial/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/partial/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/partial/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/patterns/index.d.mts +2 -0
- package/node_modules/typebox/build/type/engine/patterns/index.mjs +2 -0
- package/node_modules/typebox/build/type/engine/patterns/pattern.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/patterns/pattern.mjs +11 -0
- package/node_modules/typebox/build/type/engine/patterns/template.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/patterns/template.mjs +20 -0
- package/node_modules/typebox/build/type/engine/pick/from_type.d.mts +13 -0
- package/node_modules/typebox/build/type/engine/pick/from_type.mjs +20 -0
- package/node_modules/typebox/build/type/engine/pick/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/pick/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/pick/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/pick/instantiate.mjs +16 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_cyclic.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_cyclic.mjs +11 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +11 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +22 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_union.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/readonly_object/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/readonly_object/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/readonly_object/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/record/from_key.d.mts +24 -0
- package/node_modules/typebox/build/type/engine/record/from_key.mjs +40 -0
- package/node_modules/typebox/build/type/engine/record/from_key_any.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/record/from_key_any.mjs +6 -0
- package/node_modules/typebox/build/type/engine/record/from_key_boolean.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/record/from_key_boolean.mjs +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +8 -0
- package/node_modules/typebox/build/type/engine/record/from_key_integer.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_integer.mjs +7 -0
- package/node_modules/typebox/build/type/engine/record/from_key_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/record/from_key_literal.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/record/from_key_literal.mjs +10 -0
- package/node_modules/typebox/build/type/engine/record/from_key_number.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_number.mjs +7 -0
- package/node_modules/typebox/build/type/engine/record/from_key_string.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_string.mjs +12 -0
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +12 -0
- package/node_modules/typebox/build/type/engine/record/from_key_union.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/record/from_key_union.mjs +39 -0
- package/node_modules/typebox/build/type/engine/record/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/record/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/record/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/record/instantiate.mjs +17 -0
- package/node_modules/typebox/build/type/engine/record/record_create.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/record/record_create.mjs +7 -0
- package/node_modules/typebox/build/type/engine/ref/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/ref/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +10 -0
- package/node_modules/typebox/build/type/engine/required/from_cyclic.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/required/from_cyclic.mjs +11 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +7 -0
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +11 -0
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +17 -0
- package/node_modules/typebox/build/type/engine/required/from_union.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/required/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/required/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/required/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/required/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/rest/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/rest/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/rest/spread.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/rest/spread.mjs +19 -0
- package/node_modules/typebox/build/type/engine/return_type/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/return_type/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/return_type/instantiate.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/return_type/instantiate.mjs +21 -0
- package/node_modules/typebox/build/type/engine/template_literal/create.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/template_literal/create.mjs +5 -0
- package/node_modules/typebox/build/type/engine/template_literal/decode.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +81 -0
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +33 -0
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +81 -0
- package/node_modules/typebox/build/type/engine/template_literal/index.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/template_literal/index.mjs +6 -0
- package/node_modules/typebox/build/type/engine/template_literal/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/template_literal/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +26 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +9 -0
- package/node_modules/typebox/build/type/engine/template_literal/static.d.mts +18 -0
- package/node_modules/typebox/build/type/engine/template_literal/static.mjs +2 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +19 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +32 -0
- package/node_modules/typebox/build/type/engine/tuple/to_object.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/tuple/to_object.mjs +14 -0
- package/node_modules/typebox/build/type/extends/any.d.mts +9 -0
- package/node_modules/typebox/build/type/extends/any.mjs +12 -0
- package/node_modules/typebox/build/type/extends/array.d.mts +20 -0
- package/node_modules/typebox/build/type/extends/array.mjs +21 -0
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +9 -0
- package/node_modules/typebox/build/type/extends/bigint.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/bigint.mjs +9 -0
- package/node_modules/typebox/build/type/extends/boolean.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/boolean.mjs +9 -0
- package/node_modules/typebox/build/type/extends/constructor.d.mts +10 -0
- package/node_modules/typebox/build/type/extends/constructor.mjs +17 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/enum.mjs +6 -0
- package/node_modules/typebox/build/type/extends/extends.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/extends.mjs +17 -0
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +55 -0
- package/node_modules/typebox/build/type/extends/extends_left.mjs +83 -0
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +25 -0
- package/node_modules/typebox/build/type/extends/extends_right.mjs +44 -0
- package/node_modules/typebox/build/type/extends/function.d.mts +10 -0
- package/node_modules/typebox/build/type/extends/function.mjs +17 -0
- package/node_modules/typebox/build/type/extends/index.d.mts +2 -0
- package/node_modules/typebox/build/type/extends/index.mjs +2 -0
- package/node_modules/typebox/build/type/extends/inference.d.mts +34 -0
- package/node_modules/typebox/build/type/extends/inference.mjs +62 -0
- package/node_modules/typebox/build/type/extends/integer.d.mts +8 -0
- package/node_modules/typebox/build/type/extends/integer.mjs +10 -0
- package/node_modules/typebox/build/type/extends/intersect.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/intersect.mjs +15 -0
- package/node_modules/typebox/build/type/extends/iterator.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/iterator.mjs +9 -0
- package/node_modules/typebox/build/type/extends/literal.d.mts +18 -0
- package/node_modules/typebox/build/type/extends/literal.mjs +44 -0
- package/node_modules/typebox/build/type/extends/never.d.mts +8 -0
- package/node_modules/typebox/build/type/extends/never.mjs +9 -0
- package/node_modules/typebox/build/type/extends/null.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/null.mjs +9 -0
- package/node_modules/typebox/build/type/extends/number.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/number.mjs +9 -0
- package/node_modules/typebox/build/type/extends/object.d.mts +25 -0
- package/node_modules/typebox/build/type/extends/object.mjs +87 -0
- package/node_modules/typebox/build/type/extends/parameters.d.mts +15 -0
- package/node_modules/typebox/build/type/extends/parameters.mjs +28 -0
- package/node_modules/typebox/build/type/extends/promise.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/promise.mjs +9 -0
- package/node_modules/typebox/build/type/extends/result.d.mts +24 -0
- package/node_modules/typebox/build/type/extends/result.mjs +36 -0
- package/node_modules/typebox/build/type/extends/return_type.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/return_type.mjs +9 -0
- package/node_modules/typebox/build/type/extends/string.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/string.mjs +9 -0
- package/node_modules/typebox/build/type/extends/symbol.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/symbol.mjs +9 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/template_literal.mjs +7 -0
- package/node_modules/typebox/build/type/extends/tuple.d.mts +25 -0
- package/node_modules/typebox/build/type/extends/tuple.mjs +60 -0
- package/node_modules/typebox/build/type/extends/undefined.d.mts +8 -0
- package/node_modules/typebox/build/type/extends/undefined.mjs +10 -0
- package/node_modules/typebox/build/type/extends/union.d.mts +11 -0
- package/node_modules/typebox/build/type/extends/union.mjs +24 -0
- package/node_modules/typebox/build/type/extends/unknown.d.mts +9 -0
- package/node_modules/typebox/build/type/extends/unknown.mjs +12 -0
- package/node_modules/typebox/build/type/extends/void.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/void.mjs +9 -0
- package/node_modules/typebox/build/type/index.d.mts +5 -0
- package/node_modules/typebox/build/type/index.mjs +5 -0
- package/node_modules/typebox/build/type/script/index.d.mts +1 -0
- package/node_modules/typebox/build/type/script/index.mjs +1 -0
- package/node_modules/typebox/build/type/script/mapping.d.mts +365 -0
- package/node_modules/typebox/build/type/script/mapping.mjs +532 -0
- package/node_modules/typebox/build/type/script/parser.d.mts +260 -0
- package/node_modules/typebox/build/type/script/parser.mjs +135 -0
- package/node_modules/typebox/build/type/script/script.d.mts +17 -0
- package/node_modules/typebox/build/type/script/script.mjs +21 -0
- package/node_modules/typebox/build/type/script/token/bigint.d.mts +8 -0
- package/node_modules/typebox/build/type/script/token/bigint.mjs +14 -0
- package/node_modules/typebox/build/type/script/token/const.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/const.mjs +18 -0
- package/node_modules/typebox/build/type/script/token/ident.d.mts +16 -0
- package/node_modules/typebox/build/type/script/token/ident.mjs +26 -0
- package/node_modules/typebox/build/type/script/token/index.d.mts +12 -0
- package/node_modules/typebox/build/type/script/token/index.mjs +12 -0
- package/node_modules/typebox/build/type/script/token/integer.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/integer.mjs +19 -0
- package/node_modules/typebox/build/type/script/token/internal/char.d.mts +75 -0
- package/node_modules/typebox/build/type/script/token/internal/char.mjs +26 -0
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -0
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +15 -0
- package/node_modules/typebox/build/type/script/token/internal/many.d.mts +7 -0
- package/node_modules/typebox/build/type/script/token/internal/many.mjs +14 -0
- package/node_modules/typebox/build/type/script/token/internal/match.d.mts +6 -0
- package/node_modules/typebox/build/type/script/token/internal/match.mjs +11 -0
- package/node_modules/typebox/build/type/script/token/internal/optional.d.mts +5 -0
- package/node_modules/typebox/build/type/script/token/internal/optional.mjs +9 -0
- package/node_modules/typebox/build/type/script/token/internal/take.d.mts +6 -0
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +30 -0
- package/node_modules/typebox/build/type/script/token/internal/trim.d.mts +19 -0
- package/node_modules/typebox/build/type/script/token/internal/trim.mjs +34 -0
- package/node_modules/typebox/build/type/script/token/number.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/number.mjs +19 -0
- package/node_modules/typebox/build/type/script/token/rest.d.mts +4 -0
- package/node_modules/typebox/build/type/script/token/rest.mjs +9 -0
- package/node_modules/typebox/build/type/script/token/span.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/span.mjs +24 -0
- package/node_modules/typebox/build/type/script/token/string.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/string.mjs +20 -0
- package/node_modules/typebox/build/type/script/token/unsigned_integer.d.mts +16 -0
- package/node_modules/typebox/build/type/script/token/unsigned_integer.mjs +26 -0
- package/node_modules/typebox/build/type/script/token/unsigned_number.d.mts +17 -0
- package/node_modules/typebox/build/type/script/token/unsigned_number.mjs +38 -0
- package/node_modules/typebox/build/type/script/token/until.d.mts +7 -0
- package/node_modules/typebox/build/type/script/token/until.mjs +21 -0
- package/node_modules/typebox/build/type/script/token/until_1.d.mts +5 -0
- package/node_modules/typebox/build/type/script/token/until_1.mjs +12 -0
- package/node_modules/typebox/build/type/types/_codec.d.mts +30 -0
- package/node_modules/typebox/build/type/types/_codec.mjs +61 -0
- package/node_modules/typebox/build/type/types/_immutable.d.mts +16 -0
- package/node_modules/typebox/build/type/types/_immutable.mjs +26 -0
- package/node_modules/typebox/build/type/types/_optional.d.mts +16 -0
- package/node_modules/typebox/build/type/types/_optional.mjs +27 -0
- package/node_modules/typebox/build/type/types/_readonly.d.mts +16 -0
- package/node_modules/typebox/build/type/types/_readonly.mjs +26 -0
- package/node_modules/typebox/build/type/types/_refine.d.mts +26 -0
- package/node_modules/typebox/build/type/types/_refine.mjs +37 -0
- package/node_modules/typebox/build/type/types/any.d.mts +10 -0
- package/node_modules/typebox/build/type/types/any.mjs +18 -0
- package/node_modules/typebox/build/type/types/array.d.mts +18 -0
- package/node_modules/typebox/build/type/types/array.mjs +25 -0
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +20 -0
- package/node_modules/typebox/build/type/types/async_iterator.mjs +28 -0
- package/node_modules/typebox/build/type/types/base.d.mts +50 -0
- package/node_modules/typebox/build/type/types/base.mjs +84 -0
- package/node_modules/typebox/build/type/types/bigint.d.mts +12 -0
- package/node_modules/typebox/build/type/types/bigint.mjs +21 -0
- package/node_modules/typebox/build/type/types/boolean.d.mts +11 -0
- package/node_modules/typebox/build/type/types/boolean.mjs +17 -0
- package/node_modules/typebox/build/type/types/call.d.mts +16 -0
- package/node_modules/typebox/build/type/types/call.mjs +22 -0
- package/node_modules/typebox/build/type/types/constructor.d.mts +18 -0
- package/node_modules/typebox/build/type/types/constructor.mjs +24 -0
- package/node_modules/typebox/build/type/types/cyclic.d.mts +16 -0
- package/node_modules/typebox/build/type/types/cyclic.mjs +29 -0
- package/node_modules/typebox/build/type/types/deferred.d.mts +12 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +16 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +16 -0
- package/node_modules/typebox/build/type/types/enum.mjs +17 -0
- package/node_modules/typebox/build/type/types/function.d.mts +21 -0
- package/node_modules/typebox/build/type/types/function.mjs +25 -0
- package/node_modules/typebox/build/type/types/generic.d.mts +13 -0
- package/node_modules/typebox/build/type/types/generic.mjs +17 -0
- package/node_modules/typebox/build/type/types/identifier.d.mts +11 -0
- package/node_modules/typebox/build/type/types/identifier.mjs +17 -0
- package/node_modules/typebox/build/type/types/index.d.mts +48 -0
- package/node_modules/typebox/build/type/types/index.mjs +54 -0
- package/node_modules/typebox/build/type/types/infer.d.mts +15 -0
- package/node_modules/typebox/build/type/types/infer.mjs +20 -0
- package/node_modules/typebox/build/type/types/integer.d.mts +12 -0
- package/node_modules/typebox/build/type/types/integer.mjs +21 -0
- package/node_modules/typebox/build/type/types/intersect.d.mts +15 -0
- package/node_modules/typebox/build/type/types/intersect.mjs +24 -0
- package/node_modules/typebox/build/type/types/iterator.d.mts +20 -0
- package/node_modules/typebox/build/type/types/iterator.mjs +28 -0
- package/node_modules/typebox/build/type/types/literal.d.mts +31 -0
- package/node_modules/typebox/build/type/types/literal.mjs +62 -0
- package/node_modules/typebox/build/type/types/never.d.mts +12 -0
- package/node_modules/typebox/build/type/types/never.mjs +22 -0
- package/node_modules/typebox/build/type/types/null.d.mts +11 -0
- package/node_modules/typebox/build/type/types/null.mjs +17 -0
- package/node_modules/typebox/build/type/types/number.d.mts +12 -0
- package/node_modules/typebox/build/type/types/number.mjs +21 -0
- package/node_modules/typebox/build/type/types/object.d.mts +18 -0
- package/node_modules/typebox/build/type/types/object.mjs +28 -0
- package/node_modules/typebox/build/type/types/parameter.d.mts +17 -0
- package/node_modules/typebox/build/type/types/parameter.mjs +21 -0
- package/node_modules/typebox/build/type/types/promise.d.mts +21 -0
- package/node_modules/typebox/build/type/types/promise.mjs +29 -0
- package/node_modules/typebox/build/type/types/properties.d.mts +43 -0
- package/node_modules/typebox/build/type/types/properties.mjs +15 -0
- package/node_modules/typebox/build/type/types/record.d.mts +46 -0
- package/node_modules/typebox/build/type/types/record.mjs +60 -0
- package/node_modules/typebox/build/type/types/ref.d.mts +19 -0
- package/node_modules/typebox/build/type/types/ref.mjs +18 -0
- package/node_modules/typebox/build/type/types/rest.d.mts +11 -0
- package/node_modules/typebox/build/type/types/rest.mjs +17 -0
- package/node_modules/typebox/build/type/types/schema.d.mts +176 -0
- package/node_modules/typebox/build/type/types/schema.mjs +15 -0
- package/node_modules/typebox/build/type/types/static.d.mts +48 -0
- package/node_modules/typebox/build/type/types/static.mjs +3 -0
- package/node_modules/typebox/build/type/types/string.d.mts +12 -0
- package/node_modules/typebox/build/type/types/string.mjs +22 -0
- package/node_modules/typebox/build/type/types/symbol.d.mts +11 -0
- package/node_modules/typebox/build/type/types/symbol.mjs +17 -0
- package/node_modules/typebox/build/type/types/template_literal.d.mts +28 -0
- package/node_modules/typebox/build/type/types/template_literal.mjs +37 -0
- package/node_modules/typebox/build/type/types/this.d.mts +14 -0
- package/node_modules/typebox/build/type/types/this.mjs +17 -0
- package/node_modules/typebox/build/type/types/tuple.d.mts +38 -0
- package/node_modules/typebox/build/type/types/tuple.mjs +25 -0
- package/node_modules/typebox/build/type/types/undefined.d.mts +11 -0
- package/node_modules/typebox/build/type/types/undefined.mjs +17 -0
- package/node_modules/typebox/build/type/types/union.d.mts +15 -0
- package/node_modules/typebox/build/type/types/union.mjs +24 -0
- package/node_modules/typebox/build/type/types/unknown.d.mts +10 -0
- package/node_modules/typebox/build/type/types/unknown.mjs +17 -0
- package/node_modules/typebox/build/type/types/unsafe.d.mts +10 -0
- package/node_modules/typebox/build/type/types/unsafe.mjs +20 -0
- package/node_modules/typebox/build/type/types/void.d.mts +11 -0
- package/node_modules/typebox/build/type/types/void.mjs +17 -0
- package/node_modules/typebox/build/typebox.d.mts +73 -0
- package/node_modules/typebox/build/typebox.mjs +89 -0
- package/node_modules/typebox/build/value/assert/assert.d.mts +14 -0
- package/node_modules/typebox/build/value/assert/assert.mjs +28 -0
- package/node_modules/typebox/build/value/assert/index.d.mts +1 -0
- package/node_modules/typebox/build/value/assert/index.mjs +1 -0
- package/node_modules/typebox/build/value/check/check.d.mts +5 -0
- package/node_modules/typebox/build/value/check/check.mjs +11 -0
- package/node_modules/typebox/build/value/check/index.d.mts +1 -0
- package/node_modules/typebox/build/value/check/index.mjs +1 -0
- package/node_modules/typebox/build/value/clean/additional.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/additional.mjs +6 -0
- package/node_modules/typebox/build/value/clean/clean.d.mts +15 -0
- package/node_modules/typebox/build/value/clean/clean.mjs +15 -0
- package/node_modules/typebox/build/value/clean/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_array.mjs +8 -0
- package/node_modules/typebox/build/value/clean/from_base.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_base.mjs +4 -0
- package/node_modules/typebox/build/value/clean/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/clean/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +26 -0
- package/node_modules/typebox/build/value/clean/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_object.mjs +31 -0
- package/node_modules/typebox/build/value/clean/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_record.mjs +32 -0
- package/node_modules/typebox/build/value/clean/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_ref.mjs +8 -0
- package/node_modules/typebox/build/value/clean/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_tuple.mjs +14 -0
- package/node_modules/typebox/build/value/clean/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_type.mjs +23 -0
- package/node_modules/typebox/build/value/clean/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_union.mjs +13 -0
- package/node_modules/typebox/build/value/clean/index.d.mts +1 -0
- package/node_modules/typebox/build/value/clean/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +5 -0
- package/node_modules/typebox/build/value/clone/clone.mjs +83 -0
- package/node_modules/typebox/build/value/clone/index.d.mts +1 -0
- package/node_modules/typebox/build/value/clone/index.mjs +1 -0
- package/node_modules/typebox/build/value/codec/callback.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/callback.mjs +25 -0
- package/node_modules/typebox/build/value/codec/decode.d.mts +12 -0
- package/node_modules/typebox/build/value/codec/decode.mjs +50 -0
- package/node_modules/typebox/build/value/codec/encode.d.mts +12 -0
- package/node_modules/typebox/build/value/codec/encode.mjs +50 -0
- package/node_modules/typebox/build/value/codec/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_array.mjs +38 -0
- package/node_modules/typebox/build/value/codec/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_cyclic.mjs +8 -0
- package/node_modules/typebox/build/value/codec/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_intersect.mjs +58 -0
- package/node_modules/typebox/build/value/codec/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_object.mjs +45 -0
- package/node_modules/typebox/build/value/codec/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_record.mjs +44 -0
- package/node_modules/typebox/build/value/codec/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_ref.mjs +31 -0
- package/node_modules/typebox/build/value/codec/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +35 -0
- package/node_modules/typebox/build/value/codec/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_type.mjs +22 -0
- package/node_modules/typebox/build/value/codec/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_union.mjs +40 -0
- package/node_modules/typebox/build/value/codec/has.d.mts +5 -0
- package/node_modules/typebox/build/value/codec/has.mjs +93 -0
- package/node_modules/typebox/build/value/codec/index.d.mts +3 -0
- package/node_modules/typebox/build/value/codec/index.mjs +3 -0
- package/node_modules/typebox/build/value/convert/convert.d.mts +13 -0
- package/node_modules/typebox/build/value/convert/convert.mjs +15 -0
- package/node_modules/typebox/build/value/convert/from_additional.d.mts +6 -0
- package/node_modules/typebox/build/value/convert/from_additional.mjs +18 -0
- package/node_modules/typebox/build/value/convert/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_array.mjs +7 -0
- package/node_modules/typebox/build/value/convert/from_base.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_base.mjs +4 -0
- package/node_modules/typebox/build/value/convert/from_bigint.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_bigint.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_boolean.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_boolean.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_enum.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_enum.mjs +7 -0
- package/node_modules/typebox/build/value/convert/from_integer.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_integer.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/value/convert/from_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_literal.mjs +44 -0
- package/node_modules/typebox/build/value/convert/from_null.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_null.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_number.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_number.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_object.mjs +28 -0
- package/node_modules/typebox/build/value/convert/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_record.mjs +23 -0
- package/node_modules/typebox/build/value/convert/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_ref.mjs +8 -0
- package/node_modules/typebox/build/value/convert/from_string.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_string.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +7 -0
- package/node_modules/typebox/build/value/convert/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_tuple.mjs +11 -0
- package/node_modules/typebox/build/value/convert/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_type.mjs +45 -0
- package/node_modules/typebox/build/value/convert/from_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_undefined.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_union.mjs +13 -0
- package/node_modules/typebox/build/value/convert/from_void.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_void.mjs +6 -0
- package/node_modules/typebox/build/value/convert/index.d.mts +1 -0
- package/node_modules/typebox/build/value/convert/index.mjs +1 -0
- package/node_modules/typebox/build/value/convert/try/index.d.mts +1 -0
- package/node_modules/typebox/build/value/convert/try/index.mjs +1 -0
- package/node_modules/typebox/build/value/convert/try/try.d.mts +8 -0
- package/node_modules/typebox/build/value/convert/try/try.mjs +8 -0
- package/node_modules/typebox/build/value/convert/try/try_array.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_array.mjs +6 -0
- package/node_modules/typebox/build/value/convert/try/try_bigint.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_bigint.mjs +45 -0
- package/node_modules/typebox/build/value/convert/try/try_boolean.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_boolean.mjs +41 -0
- package/node_modules/typebox/build/value/convert/try/try_null.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_null.mjs +44 -0
- package/node_modules/typebox/build/value/convert/try/try_number.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_number.mjs +44 -0
- package/node_modules/typebox/build/value/convert/try/try_result.d.mts +8 -0
- package/node_modules/typebox/build/value/convert/try/try_result.mjs +17 -0
- package/node_modules/typebox/build/value/convert/try/try_string.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_string.mjs +12 -0
- package/node_modules/typebox/build/value/convert/try/try_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_undefined.mjs +44 -0
- package/node_modules/typebox/build/value/create/create.d.mts +5 -0
- package/node_modules/typebox/build/value/create/create.mjs +11 -0
- package/node_modules/typebox/build/value/create/error.d.mts +5 -0
- package/node_modules/typebox/build/value/create/error.mjs +7 -0
- package/node_modules/typebox/build/value/create/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_array.mjs +10 -0
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_base.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_base.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_bigint.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_bigint.mjs +7 -0
- package/node_modules/typebox/build/value/create/from_boolean.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_boolean.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_constructor.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_constructor.mjs +10 -0
- package/node_modules/typebox/build/value/create/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/create/from_default.d.mts +3 -0
- package/node_modules/typebox/build/value/create/from_default.mjs +10 -0
- package/node_modules/typebox/build/value/create/from_enum.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_enum.mjs +6 -0
- package/node_modules/typebox/build/value/create/from_function.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_function.mjs +6 -0
- package/node_modules/typebox/build/value/create/from_integer.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_integer.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_iterator.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_literal.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_never.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_never.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_null.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_null.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_number.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_number.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_object.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_promise.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_promise.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_record.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_ref.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_string.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_string.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_symbol.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_symbol.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_template_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_template_literal.mjs +11 -0
- package/node_modules/typebox/build/value/create/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_tuple.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_type.mjs +69 -0
- package/node_modules/typebox/build/value/create/from_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_undefined.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_union.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_void.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_void.mjs +4 -0
- package/node_modules/typebox/build/value/create/index.d.mts +2 -0
- package/node_modules/typebox/build/value/create/index.mjs +2 -0
- package/node_modules/typebox/build/value/default/default.d.mts +13 -0
- package/node_modules/typebox/build/value/default/default.mjs +15 -0
- package/node_modules/typebox/build/value/default/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_array.mjs +12 -0
- package/node_modules/typebox/build/value/default/from_base.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_base.mjs +5 -0
- package/node_modules/typebox/build/value/default/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_cyclic.mjs +7 -0
- package/node_modules/typebox/build/value/default/from_default.d.mts +3 -0
- package/node_modules/typebox/build/value/default/from_default.mjs +13 -0
- package/node_modules/typebox/build/value/default/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_intersect.mjs +9 -0
- package/node_modules/typebox/build/value/default/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_object.mjs +32 -0
- package/node_modules/typebox/build/value/default/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_record.mjs +26 -0
- package/node_modules/typebox/build/value/default/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_ref.mjs +9 -0
- package/node_modules/typebox/build/value/default/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_tuple.mjs +14 -0
- package/node_modules/typebox/build/value/default/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_type.mjs +27 -0
- package/node_modules/typebox/build/value/default/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_union.mjs +14 -0
- package/node_modules/typebox/build/value/default/index.d.mts +1 -0
- package/node_modules/typebox/build/value/default/index.mjs +1 -0
- package/node_modules/typebox/build/value/delta/diff.d.mts +10 -0
- package/node_modules/typebox/build/value/delta/diff.mjs +135 -0
- package/node_modules/typebox/build/value/delta/edit.d.mts +24 -0
- package/node_modules/typebox/build/value/delta/edit.mjs +17 -0
- package/node_modules/typebox/build/value/delta/index.d.mts +3 -0
- package/node_modules/typebox/build/value/delta/index.mjs +3 -0
- package/node_modules/typebox/build/value/delta/patch.d.mts +8 -0
- package/node_modules/typebox/build/value/delta/patch.mjs +42 -0
- package/node_modules/typebox/build/value/equal/equal.d.mts +2 -0
- package/node_modules/typebox/build/value/equal/equal.mjs +6 -0
- package/node_modules/typebox/build/value/equal/index.d.mts +1 -0
- package/node_modules/typebox/build/value/equal/index.mjs +1 -0
- package/node_modules/typebox/build/value/errors/errors.d.mts +16 -0
- package/node_modules/typebox/build/value/errors/errors.mjs +17 -0
- package/node_modules/typebox/build/value/errors/index.d.mts +1 -0
- package/node_modules/typebox/build/value/errors/index.mjs +1 -0
- package/node_modules/typebox/build/value/hash/hash.d.mts +6 -0
- package/node_modules/typebox/build/value/hash/hash.mjs +10 -0
- package/node_modules/typebox/build/value/hash/index.d.mts +1 -0
- package/node_modules/typebox/build/value/hash/index.mjs +1 -0
- package/node_modules/typebox/build/value/index.d.mts +21 -0
- package/node_modules/typebox/build/value/index.mjs +30 -0
- package/node_modules/typebox/build/value/mutate/error.d.mts +3 -0
- package/node_modules/typebox/build/value/mutate/error.mjs +6 -0
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/mutate/from_array.mjs +16 -0
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/mutate/from_object.mjs +40 -0
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +2 -0
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +7 -0
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +2 -0
- package/node_modules/typebox/build/value/mutate/from_value.mjs +12 -0
- package/node_modules/typebox/build/value/mutate/index.d.mts +1 -0
- package/node_modules/typebox/build/value/mutate/index.mjs +1 -0
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +11 -0
- package/node_modules/typebox/build/value/mutate/mutate.mjs +41 -0
- package/node_modules/typebox/build/value/parse/index.d.mts +1 -0
- package/node_modules/typebox/build/value/parse/index.mjs +1 -0
- package/node_modules/typebox/build/value/parse/parse.d.mts +11 -0
- package/node_modules/typebox/build/value/parse/parse.mjs +47 -0
- package/node_modules/typebox/build/value/pipeline/index.d.mts +1 -0
- package/node_modules/typebox/build/value/pipeline/index.mjs +1 -0
- package/node_modules/typebox/build/value/pipeline/pipeline.d.mts +10 -0
- package/node_modules/typebox/build/value/pipeline/pipeline.mjs +15 -0
- package/node_modules/typebox/build/value/pointer/index.d.mts +1 -0
- package/node_modules/typebox/build/value/pointer/index.mjs +1 -0
- package/node_modules/typebox/build/value/repair/error.d.mts +7 -0
- package/node_modules/typebox/build/value/repair/error.mjs +8 -0
- package/node_modules/typebox/build/value/repair/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_array.mjs +39 -0
- package/node_modules/typebox/build/value/repair/from_base.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_base.mjs +8 -0
- package/node_modules/typebox/build/value/repair/from_enum.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_enum.mjs +7 -0
- package/node_modules/typebox/build/value/repair/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/value/repair/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_object.mjs +33 -0
- package/node_modules/typebox/build/value/repair/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_record.mjs +33 -0
- package/node_modules/typebox/build/value/repair/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_ref.mjs +9 -0
- package/node_modules/typebox/build/value/repair/from_template_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_template_literal.mjs +7 -0
- package/node_modules/typebox/build/value/repair/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_tuple.mjs +12 -0
- package/node_modules/typebox/build/value/repair/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_type.mjs +86 -0
- package/node_modules/typebox/build/value/repair/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_union.mjs +24 -0
- package/node_modules/typebox/build/value/repair/from_unknown.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_unknown.mjs +12 -0
- package/node_modules/typebox/build/value/repair/index.d.mts +1 -0
- package/node_modules/typebox/build/value/repair/index.mjs +1 -0
- package/node_modules/typebox/build/value/repair/repair.d.mts +17 -0
- package/node_modules/typebox/build/value/repair/repair.mjs +20 -0
- package/node_modules/typebox/build/value/shared/index.d.mts +3 -0
- package/node_modules/typebox/build/value/shared/index.mjs +4 -0
- package/node_modules/typebox/build/value/shared/optional_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/shared/optional_undefined.mjs +15 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +3 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +36 -0
- package/node_modules/typebox/build/value/shared/union_score_select.d.mts +3 -0
- package/node_modules/typebox/build/value/shared/union_score_select.mjs +51 -0
- package/node_modules/typebox/build/value/value.d.mts +16 -0
- package/node_modules/typebox/build/value/value.mjs +16 -0
- package/node_modules/typebox/license +23 -0
- package/node_modules/typebox/package.json +87 -0
- package/node_modules/typebox/readme.md +356 -0
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +172 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +217 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +223 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +11 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +114 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +717 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +967 -0
- package/node_modules/yaml/browser/dist/public-api.js +102 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +64 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +24 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +201 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
- package/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
- package/node_modules/yaml/dist/compose/composer.js +222 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +225 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +337 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +25 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +19 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/Alias.js +116 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +43 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +350 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +719 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +972 -0
- package/node_modules/yaml/dist/public-api.d.ts +44 -0
- package/node_modules/yaml/dist/public-api.js +107 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
- package/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
- package/node_modules/yaml/dist/schema/tags.js +99 -0
- package/node_modules/yaml/dist/schema/types.d.ts +92 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +68 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +26 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +16 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +97 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +60 -0
- package/src/adapters/index.ts +13 -0
- package/src/adapters/pi-subagents/agents.ts +136 -0
- package/src/adapters/pi-subagents/autocomplete.ts +46 -0
- package/src/adapters/pi-subagents/index.ts +48 -0
- package/src/adapters/types.ts +25 -0
- package/src/commands/delegation.ts +32 -0
- package/src/commands/doctor.ts +36 -0
- package/test/agent-palette.test.ts +215 -0
- package/test/wiring.test.ts +15 -0
|
@@ -0,0 +1,2808 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent discovery and configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { execSync } from "node:child_process";
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import { parse as parseYaml } from "yaml";
|
|
8
|
+
import * as os from "node:os";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import type { AcceptanceInput, AcceptanceRole, AgentRunnerConfig, OutputMode, ToolBudgetConfig } from "../shared/types.ts";
|
|
12
|
+
import { CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL, isCodeOwnedExternalCliAdapterId, parseExternalCliCapabilityNarrowing, validateCodeOwnedProfileRunner } from "../runs/shared/external-cli-contract.ts";
|
|
13
|
+
import { getAgentDir, getProjectConfigDir } from "../shared/utils.ts";
|
|
14
|
+
import { KNOWN_FIELDS } from "./agent-serializer.ts";
|
|
15
|
+
import { parseChain, parseJsonChain } from "./chain-serializer.ts";
|
|
16
|
+
import { mergeAgentsForScope } from "./agent-selection.ts";
|
|
17
|
+
import { parseFrontmatter, parseFrontmatterList } from "./frontmatter.ts";
|
|
18
|
+
import { buildRuntimeName, parsePackageName } from "./identity.ts";
|
|
19
|
+
import { parseModelScopeConfig, type ModelScopeConfig } from "../runs/shared/model-scope.ts";
|
|
20
|
+
export { BUILTIN_AGENT_NAMES } from "./builtin-names.ts";
|
|
21
|
+
export { buildRuntimeName, frontmatterNameForConfig, parsePackageName } from "./identity.ts";
|
|
22
|
+
import { parseMemoryFrontmatter } from "./agent-memory.ts";
|
|
23
|
+
import { validateAcceptanceInput } from "../runs/shared/acceptance.ts";
|
|
24
|
+
import { validatePermissionRules, type PermissionRules } from "../runs/shared/permissions.ts";
|
|
25
|
+
import { parseThinkingLevel, type ThinkingLevel } from "../shared/thinking-ceiling.ts";
|
|
26
|
+
|
|
27
|
+
export type AgentScope = "user" | "project" | "both";
|
|
28
|
+
|
|
29
|
+
export type AgentSource = "builtin" | "package" | "user" | "project" | "runtime";
|
|
30
|
+
type SystemPromptMode = "append" | "replace";
|
|
31
|
+
export type AgentDefaultContext = "fresh" | "fork";
|
|
32
|
+
|
|
33
|
+
export type AgentMemoryScope = "project" | "user";
|
|
34
|
+
|
|
35
|
+
export interface AgentMemoryConfig {
|
|
36
|
+
scope: AgentMemoryScope;
|
|
37
|
+
path: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function defaultSystemPromptMode(name: string): SystemPromptMode {
|
|
41
|
+
return name === "delegate" ? "append" : "replace";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function defaultInheritProjectContext(name: string): boolean {
|
|
45
|
+
return name === "delegate";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function defaultInheritSkills(): boolean {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface BuiltinAgentOverrideBase {
|
|
53
|
+
description?: string;
|
|
54
|
+
output?: string;
|
|
55
|
+
outputMode?: OutputMode;
|
|
56
|
+
defaultReads?: string[];
|
|
57
|
+
model?: string;
|
|
58
|
+
modelProvider?: string;
|
|
59
|
+
fallbackModels?: string[];
|
|
60
|
+
fast?: boolean;
|
|
61
|
+
thinking?: string | false;
|
|
62
|
+
systemPromptMode: SystemPromptMode;
|
|
63
|
+
inheritProjectContext: boolean;
|
|
64
|
+
inheritGlobalContext: boolean;
|
|
65
|
+
inheritSkills: boolean;
|
|
66
|
+
defaultContext?: AgentDefaultContext;
|
|
67
|
+
acceptanceRole?: AcceptanceRole;
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
systemPrompt: string;
|
|
70
|
+
skills?: string[];
|
|
71
|
+
skillPath?: string[];
|
|
72
|
+
tools?: string[];
|
|
73
|
+
excludeTools?: string[];
|
|
74
|
+
allowNestedSubagents?: boolean;
|
|
75
|
+
mcpDirectTools?: string[];
|
|
76
|
+
extensions?: string[];
|
|
77
|
+
subagentOnlyExtensions?: string[];
|
|
78
|
+
mutationTools?: string[];
|
|
79
|
+
completionGuard?: boolean;
|
|
80
|
+
toolBudget?: ToolBudgetConfig;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface BuiltinAgentOverrideConfig {
|
|
84
|
+
description?: string;
|
|
85
|
+
output?: string | false;
|
|
86
|
+
outputMode?: OutputMode;
|
|
87
|
+
defaultReads?: string[] | false;
|
|
88
|
+
model?: string | false;
|
|
89
|
+
defaultProvider?: string | false;
|
|
90
|
+
fallbackModels?: string[] | false;
|
|
91
|
+
fast?: boolean;
|
|
92
|
+
thinking?: string | false;
|
|
93
|
+
systemPromptMode?: SystemPromptMode;
|
|
94
|
+
inheritProjectContext?: boolean;
|
|
95
|
+
inheritGlobalContext?: boolean;
|
|
96
|
+
inheritSkills?: boolean;
|
|
97
|
+
defaultContext?: AgentDefaultContext | false;
|
|
98
|
+
acceptanceRole?: AcceptanceRole | false;
|
|
99
|
+
disabled?: boolean;
|
|
100
|
+
systemPrompt?: string;
|
|
101
|
+
skills?: string[] | false;
|
|
102
|
+
tools?: string[] | false | "inherit";
|
|
103
|
+
excludeTools?: string[] | false;
|
|
104
|
+
allowNestedSubagents?: boolean;
|
|
105
|
+
extensions?: string[] | false;
|
|
106
|
+
subagentOnlyExtensions?: string[] | false;
|
|
107
|
+
mutationTools?: string[] | false;
|
|
108
|
+
completionGuard?: boolean;
|
|
109
|
+
toolBudget?: ToolBudgetConfig | false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface BuiltinAgentOverrideInfo {
|
|
113
|
+
scope: "user" | "project";
|
|
114
|
+
path: string;
|
|
115
|
+
base: BuiltinAgentOverrideBase;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface AgentModelSourceInfo {
|
|
119
|
+
type: "subagents.defaultModel";
|
|
120
|
+
scope: "user" | "project";
|
|
121
|
+
path: string;
|
|
122
|
+
model: string;
|
|
123
|
+
defaultProvider?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface AgentConfig {
|
|
127
|
+
name: string;
|
|
128
|
+
runner?: AgentRunnerConfig;
|
|
129
|
+
localName?: string;
|
|
130
|
+
packageName?: string;
|
|
131
|
+
packageSourceName?: string;
|
|
132
|
+
packageSourceVersion?: string;
|
|
133
|
+
packageSourceRoot?: string;
|
|
134
|
+
description: string;
|
|
135
|
+
aliases?: string[];
|
|
136
|
+
tools?: string[];
|
|
137
|
+
excludeTools?: string[];
|
|
138
|
+
allowNestedSubagents?: boolean;
|
|
139
|
+
mcpDirectTools?: string[];
|
|
140
|
+
model?: string;
|
|
141
|
+
modelProvider?: string;
|
|
142
|
+
fallbackModels?: string[];
|
|
143
|
+
fast?: boolean;
|
|
144
|
+
thinking?: string | false;
|
|
145
|
+
systemPromptMode: SystemPromptMode;
|
|
146
|
+
inheritProjectContext: boolean;
|
|
147
|
+
inheritGlobalContext: boolean;
|
|
148
|
+
inheritSkills: boolean;
|
|
149
|
+
defaultContext?: AgentDefaultContext;
|
|
150
|
+
defaultAsync?: boolean;
|
|
151
|
+
defaultTimeoutMs?: number;
|
|
152
|
+
defaultToolTimeoutMs?: number;
|
|
153
|
+
defaultAcceptance?: AcceptanceInput;
|
|
154
|
+
acceptanceRole?: AcceptanceRole;
|
|
155
|
+
systemPrompt: string;
|
|
156
|
+
source: AgentSource;
|
|
157
|
+
filePath: string;
|
|
158
|
+
discoveryPriority?: number;
|
|
159
|
+
skills?: string[];
|
|
160
|
+
skillPath?: string[];
|
|
161
|
+
extensions?: string[];
|
|
162
|
+
extensionsFromDefault?: boolean;
|
|
163
|
+
subagentOnlyExtensions?: string[];
|
|
164
|
+
mutationTools?: string[];
|
|
165
|
+
output?: string;
|
|
166
|
+
outputMode?: OutputMode;
|
|
167
|
+
defaultReads?: string[];
|
|
168
|
+
defaultProgress?: boolean;
|
|
169
|
+
interactive?: boolean;
|
|
170
|
+
maxSubagentDepth?: number;
|
|
171
|
+
completionGuard?: boolean;
|
|
172
|
+
toolBudget?: ToolBudgetConfig;
|
|
173
|
+
permissions?: PermissionRules;
|
|
174
|
+
memory?: AgentMemoryConfig;
|
|
175
|
+
disabled?: boolean;
|
|
176
|
+
extraFields?: Record<string, string>;
|
|
177
|
+
override?: BuiltinAgentOverrideInfo;
|
|
178
|
+
modelSource?: AgentModelSourceInfo;
|
|
179
|
+
maxThinking?: ThinkingLevel;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
type ProjectRootResolution = "nearest" | "git-root";
|
|
183
|
+
|
|
184
|
+
interface SubagentSettings {
|
|
185
|
+
overrides: Record<string, BuiltinAgentOverrideConfig>;
|
|
186
|
+
providerOverrides: Record<string, Record<string, BuiltinAgentOverrideConfig>>;
|
|
187
|
+
defaultModel?: string;
|
|
188
|
+
defaultProvider?: string;
|
|
189
|
+
defaultThinking?: string;
|
|
190
|
+
maxThinking?: ThinkingLevel;
|
|
191
|
+
defaultExtensions?: string[];
|
|
192
|
+
disableBuiltins?: boolean;
|
|
193
|
+
disableThinking?: boolean;
|
|
194
|
+
modelScope?: ModelScopeConfig;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const EMPTY_SUBAGENT_SETTINGS: SubagentSettings = { overrides: {}, providerOverrides: {} };
|
|
198
|
+
const agentFrontmatterFields = new WeakMap<AgentConfig, Set<string>>();
|
|
199
|
+
|
|
200
|
+
export interface ChainStepConfig {
|
|
201
|
+
agent?: string;
|
|
202
|
+
task?: string;
|
|
203
|
+
phase?: string;
|
|
204
|
+
label?: string;
|
|
205
|
+
as?: string;
|
|
206
|
+
outputSchema?: string | Record<string, unknown>;
|
|
207
|
+
output?: string | false;
|
|
208
|
+
outputMode?: OutputMode;
|
|
209
|
+
reads?: string[] | false;
|
|
210
|
+
model?: string;
|
|
211
|
+
skills?: string[] | false;
|
|
212
|
+
progress?: boolean;
|
|
213
|
+
parallel?: unknown;
|
|
214
|
+
expand?: unknown;
|
|
215
|
+
collect?: unknown;
|
|
216
|
+
concurrency?: number;
|
|
217
|
+
failFast?: boolean;
|
|
218
|
+
worktree?: boolean;
|
|
219
|
+
acceptance?: AcceptanceInput;
|
|
220
|
+
toolBudget?: ToolBudgetConfig;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface ChainConfig {
|
|
224
|
+
name: string;
|
|
225
|
+
localName?: string;
|
|
226
|
+
packageName?: string;
|
|
227
|
+
description: string;
|
|
228
|
+
source: AgentSource;
|
|
229
|
+
filePath: string;
|
|
230
|
+
steps: ChainStepConfig[];
|
|
231
|
+
extraFields?: Record<string, string>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface ChainDiscoveryDiagnostic {
|
|
235
|
+
source: AgentSource;
|
|
236
|
+
filePath: string;
|
|
237
|
+
error: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface AgentDiscoveryDiagnostic extends ChainDiscoveryDiagnostic {
|
|
241
|
+
name?: string;
|
|
242
|
+
runtimeName?: string;
|
|
243
|
+
packageSpecified?: boolean;
|
|
244
|
+
discoveryPriority?: number;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const AGENT_SOURCE_PRIORITY: Record<AgentSource, number> = {
|
|
248
|
+
builtin: 0,
|
|
249
|
+
package: 1,
|
|
250
|
+
user: 2,
|
|
251
|
+
project: 3,
|
|
252
|
+
runtime: 4,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
function agentDefinitionPriority(definition: Pick<AgentConfig | AgentDiscoveryDiagnostic, "source" | "discoveryPriority">): number {
|
|
256
|
+
return AGENT_SOURCE_PRIORITY[definition.source] * 1_000_000
|
|
257
|
+
+ (definition.discoveryPriority ?? 0);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function findBlockingAgentDiagnostic(name: string, agent: AgentConfig | readonly AgentConfig[] | undefined, diagnostics: AgentDiscoveryDiagnostic[] | undefined): AgentDiscoveryDiagnostic | undefined {
|
|
261
|
+
const normalizedName = name.trim();
|
|
262
|
+
const agents = Array.isArray(agent) ? agent : agent ? [agent] : [];
|
|
263
|
+
let match: AgentDiscoveryDiagnostic | undefined;
|
|
264
|
+
for (const diagnostic of diagnostics ?? []) {
|
|
265
|
+
if ((diagnostic.runtimeName === normalizedName
|
|
266
|
+
|| (diagnostic.name === normalizedName && (!diagnostic.packageSpecified
|
|
267
|
+
|| diagnostic.runtimeName === undefined
|
|
268
|
+
|| agents.some((agent) => agent.name === diagnostic.runtimeName && agent.localName === diagnostic.name))))
|
|
269
|
+
&& (!match || agentDefinitionPriority(diagnostic) > agentDefinitionPriority(match))) {
|
|
270
|
+
match = diagnostic;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const highestPriority = Math.max(...agents.map(agentDefinitionPriority), -Infinity);
|
|
274
|
+
return !agents.length || (match && agentDefinitionPriority(match) > highestPriority) ? match : undefined;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export type AgentDefinitionDirectoryState = "absent" | "empty" | "candidates" | "unreadable" | "not-directory";
|
|
278
|
+
|
|
279
|
+
/** A definition directory actually inspected during one agent-discovery operation. */
|
|
280
|
+
export interface AgentDefinitionDirectoryReport {
|
|
281
|
+
source: AgentSource;
|
|
282
|
+
path: string;
|
|
283
|
+
state: AgentDefinitionDirectoryState;
|
|
284
|
+
candidateCount?: number;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Filesystem provenance for a failed agent resolution. Context is created from
|
|
289
|
+
* the discovery result that supplied the effective agents; callers must not
|
|
290
|
+
* pair arbitrary agent arrays with these directory reports.
|
|
291
|
+
*/
|
|
292
|
+
export interface UnknownAgentDiagnosticContext {
|
|
293
|
+
cwd: string;
|
|
294
|
+
scope: AgentScope;
|
|
295
|
+
directories: readonly AgentDefinitionDirectoryReport[];
|
|
296
|
+
agents: readonly AgentConfig[];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface AgentDiscoveryResult {
|
|
300
|
+
agents: AgentConfig[];
|
|
301
|
+
agentDiagnostics?: AgentDiscoveryDiagnostic[];
|
|
302
|
+
projectAgentsDir: string | null;
|
|
303
|
+
cwd: string;
|
|
304
|
+
scope: AgentScope;
|
|
305
|
+
directories: readonly AgentDefinitionDirectoryReport[];
|
|
306
|
+
modelScope?: ModelScopeConfig;
|
|
307
|
+
maxThinking?: ThinkingLevel;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Create formatter input from the exact discovery operation used for resolution. */
|
|
311
|
+
export function unknownAgentDiagnosticContext(discovered: Pick<AgentDiscoveryResult, "cwd" | "scope" | "directories" | "agents">): UnknownAgentDiagnosticContext {
|
|
312
|
+
return {
|
|
313
|
+
cwd: discovered.cwd,
|
|
314
|
+
scope: discovered.scope,
|
|
315
|
+
directories: discovered.directories,
|
|
316
|
+
agents: discovered.agents,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Render local discovery evidence without exposing filesystem error details. */
|
|
321
|
+
export function formatUnknownAgentError(name: string, context: UnknownAgentDiagnosticContext, prefix = "Unknown agent"): string {
|
|
322
|
+
const directories = context.directories.map((directory) => {
|
|
323
|
+
const state = directory.state === "candidates"
|
|
324
|
+
? `${directory.candidateCount ?? 0} candidate${directory.candidateCount === 1 ? "" : "s"}`
|
|
325
|
+
: directory.state === "empty" ? "present but empty"
|
|
326
|
+
: directory.state === "not-directory" ? "not a directory"
|
|
327
|
+
: directory.state;
|
|
328
|
+
return `- ${directory.source}: ${directory.path} (${state})`;
|
|
329
|
+
});
|
|
330
|
+
const agents = [...context.agents]
|
|
331
|
+
.sort((left, right) => left.name.localeCompare(right.name) || left.source.localeCompare(right.source))
|
|
332
|
+
.map((agent) => `- ${agent.name} (${agent.source})`);
|
|
333
|
+
return [
|
|
334
|
+
`${prefix}: ${name}`,
|
|
335
|
+
`Effective cwd: ${path.resolve(context.cwd)}`,
|
|
336
|
+
"Consulted agent-definition directories:",
|
|
337
|
+
...(directories.length ? directories : ["- (none)"]),
|
|
338
|
+
"Discovered agents:",
|
|
339
|
+
...(agents.length ? agents : ["- (none)"]),
|
|
340
|
+
].join("\n");
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function getUserChainDir(): string {
|
|
344
|
+
return path.join(getAgentDir(), "chains");
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
type PackageScope = "root" | "user" | "project";
|
|
348
|
+
type PackageSettingsScope = Exclude<PackageScope, "root">;
|
|
349
|
+
|
|
350
|
+
interface PackageSubagentPath {
|
|
351
|
+
dir: string;
|
|
352
|
+
// A package can be reachable from more than one settings scope. Keep the
|
|
353
|
+
// actual memberships instead of promoting a mixed-scope path to root.
|
|
354
|
+
scope: Set<PackageScope>;
|
|
355
|
+
packageName?: string;
|
|
356
|
+
packageVersion?: string;
|
|
357
|
+
packageRoot: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
interface PackageChainPath {
|
|
361
|
+
dir: string;
|
|
362
|
+
scope: Set<PackageScope>;
|
|
363
|
+
packageRoot: string;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
interface PackageSubagentPaths {
|
|
367
|
+
agents: PackageSubagentPath[];
|
|
368
|
+
chains: PackageChainPath[];
|
|
369
|
+
watchPaths: string[];
|
|
370
|
+
settingsErrors: Partial<Record<PackageSettingsScope, Error>>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
let cachedGlobalNpmRoot: string | null = null;
|
|
374
|
+
|
|
375
|
+
function readJsonFileBestEffort(filePath: string): unknown {
|
|
376
|
+
try {
|
|
377
|
+
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
378
|
+
} catch {
|
|
379
|
+
// Installed package scans are opportunistic; bad third-party manifests
|
|
380
|
+
// should not break local agent discovery.
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function isSafePackagePath(value: string): boolean {
|
|
386
|
+
return value.length > 0
|
|
387
|
+
&& !path.isAbsolute(value)
|
|
388
|
+
&& value.split(/[\\/]/).every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function parseNpmPackageName(source: string): string | undefined {
|
|
392
|
+
const spec = source.slice(4).trim();
|
|
393
|
+
if (!spec) return undefined;
|
|
394
|
+
const match = spec.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);
|
|
395
|
+
const packageName = match?.[1] ?? spec;
|
|
396
|
+
return isSafePackagePath(packageName) ? packageName : undefined;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function stripGitRef(repoPath: string): string {
|
|
400
|
+
const atIndex = repoPath.indexOf("@");
|
|
401
|
+
const hashIndex = repoPath.indexOf("#");
|
|
402
|
+
const refIndex = [atIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0];
|
|
403
|
+
return refIndex === undefined ? repoPath : repoPath.slice(0, refIndex);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function parseGitPackagePath(source: string): { host: string; repoPath: string } | undefined {
|
|
407
|
+
const spec = source.slice(4).trim();
|
|
408
|
+
if (!spec) return undefined;
|
|
409
|
+
|
|
410
|
+
let host = "";
|
|
411
|
+
let repoPath = "";
|
|
412
|
+
const scpLike = spec.match(/^git@([^:]+):(.+)$/);
|
|
413
|
+
if (scpLike) {
|
|
414
|
+
host = scpLike[1] ?? "";
|
|
415
|
+
repoPath = scpLike[2] ?? "";
|
|
416
|
+
} else if (/^[a-z][a-z0-9+.-]*:\/\//i.test(spec)) {
|
|
417
|
+
try {
|
|
418
|
+
const url = new URL(spec);
|
|
419
|
+
host = url.hostname;
|
|
420
|
+
repoPath = url.pathname.replace(/^\/+/, "");
|
|
421
|
+
} catch {
|
|
422
|
+
return undefined;
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
const slashIndex = spec.indexOf("/");
|
|
426
|
+
if (slashIndex < 0) return undefined;
|
|
427
|
+
host = spec.slice(0, slashIndex);
|
|
428
|
+
repoPath = spec.slice(slashIndex + 1);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const normalizedPath = stripGitRef(repoPath).replace(/\.git$/, "").replace(/^\/+/, "");
|
|
432
|
+
if (!host || !isSafePackagePath(host) || !isSafePackagePath(normalizedPath) || normalizedPath.split(/[\\/]/).length < 2) {
|
|
433
|
+
return undefined;
|
|
434
|
+
}
|
|
435
|
+
return { host, repoPath: normalizedPath };
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function resolveSettingsPackageRoot(source: string, baseDir: string): string | undefined {
|
|
439
|
+
const trimmed = source.trim();
|
|
440
|
+
if (!trimmed) return undefined;
|
|
441
|
+
if (trimmed.startsWith("git:")) {
|
|
442
|
+
const parsed = parseGitPackagePath(trimmed);
|
|
443
|
+
return parsed ? path.join(baseDir, "git", parsed.host, parsed.repoPath) : undefined;
|
|
444
|
+
}
|
|
445
|
+
if (trimmed.startsWith("npm:")) {
|
|
446
|
+
const packageName = parseNpmPackageName(trimmed);
|
|
447
|
+
return packageName ? path.join(baseDir, "npm", "node_modules", packageName) : undefined;
|
|
448
|
+
}
|
|
449
|
+
const normalized = trimmed.startsWith("file:") ? trimmed.slice(5) : trimmed;
|
|
450
|
+
if (normalized === "~") return os.homedir();
|
|
451
|
+
if (normalized.startsWith("~/")) return path.join(os.homedir(), normalized.slice(2));
|
|
452
|
+
if (path.isAbsolute(normalized)) return normalized;
|
|
453
|
+
if (normalized === "." || normalized === ".." || normalized.startsWith("./") || normalized.startsWith("../")) {
|
|
454
|
+
return path.resolve(baseDir, normalized);
|
|
455
|
+
}
|
|
456
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
457
|
+
const parsed = parseGitPackagePath(`git:${trimmed}`);
|
|
458
|
+
return parsed ? path.join(baseDir, "git", parsed.host, parsed.repoPath) : undefined;
|
|
459
|
+
}
|
|
460
|
+
return undefined;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function getGlobalNpmRoot(): string | null {
|
|
464
|
+
const offline = process.env.PI_OFFLINE?.toLowerCase();
|
|
465
|
+
if (offline === "1" || offline === "true" || offline === "yes") return null;
|
|
466
|
+
if (cachedGlobalNpmRoot !== null) return cachedGlobalNpmRoot;
|
|
467
|
+
|
|
468
|
+
const windowsGlobalRoot = process.platform === "win32" && process.env.APPDATA
|
|
469
|
+
? path.join(process.env.APPDATA, "npm", "node_modules")
|
|
470
|
+
: undefined;
|
|
471
|
+
if (windowsGlobalRoot) {
|
|
472
|
+
try {
|
|
473
|
+
if (fs.statSync(windowsGlobalRoot).isDirectory()) {
|
|
474
|
+
cachedGlobalNpmRoot = fs.realpathSync(windowsGlobalRoot);
|
|
475
|
+
return cachedGlobalNpmRoot;
|
|
476
|
+
}
|
|
477
|
+
} catch {
|
|
478
|
+
// Fall through if the directory disappears while resolving it.
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
try {
|
|
483
|
+
cachedGlobalNpmRoot = fs.realpathSync(execSync("npm root -g", { encoding: "utf-8", timeout: 5000, windowsHide: true }).trim());
|
|
484
|
+
return cachedGlobalNpmRoot;
|
|
485
|
+
} catch {
|
|
486
|
+
cachedGlobalNpmRoot = "";
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function stringArray(value: unknown): string[] {
|
|
492
|
+
if (!Array.isArray(value)) return [];
|
|
493
|
+
return value.filter((entry): entry is string => typeof entry === "string" && entry.trim().length > 0);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function packageMetadata(pkg: Record<string, unknown>, packageRoot: string): Omit<PackageSubagentPath, "dir" | "scope"> {
|
|
497
|
+
const name = typeof pkg.name === "string" && pkg.name.trim() ? pkg.name.trim() : undefined;
|
|
498
|
+
const version = typeof pkg.version === "string" && pkg.version.trim() ? pkg.version.trim() : undefined;
|
|
499
|
+
return {
|
|
500
|
+
packageRoot,
|
|
501
|
+
...(name ? { packageName: name } : {}),
|
|
502
|
+
...(version ? { packageVersion: version } : {}),
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function extractSubagentPathsFromPackageRoot(packageRoot: string, scope: Set<PackageScope>): PackageSubagentPaths {
|
|
507
|
+
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
508
|
+
const pkg = readJsonFileBestEffort(packageJsonPath);
|
|
509
|
+
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) return { agents: [], chains: [], watchPaths: [packageJsonPath], settingsErrors: {} };
|
|
510
|
+
const pkgRecord = pkg as Record<string, unknown>;
|
|
511
|
+
const metadata = packageMetadata(pkgRecord, packageRoot);
|
|
512
|
+
|
|
513
|
+
const roots: Record<string, unknown>[] = [];
|
|
514
|
+
const piSubagents = pkgRecord["pi-subagents"];
|
|
515
|
+
if (piSubagents && typeof piSubagents === "object" && !Array.isArray(piSubagents)) {
|
|
516
|
+
roots.push(piSubagents as Record<string, unknown>);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const pi = pkgRecord.pi;
|
|
520
|
+
if (pi && typeof pi === "object" && !Array.isArray(pi)) {
|
|
521
|
+
const subagents = (pi as { subagents?: unknown }).subagents;
|
|
522
|
+
if (subagents && typeof subagents === "object" && !Array.isArray(subagents)) {
|
|
523
|
+
roots.push(subagents as Record<string, unknown>);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const agents: PackageSubagentPath[] = [];
|
|
528
|
+
const chains: PackageChainPath[] = [];
|
|
529
|
+
for (const root of roots) {
|
|
530
|
+
for (const entry of stringArray(root.agents)) agents.push({ dir: path.resolve(packageRoot, entry), scope, ...metadata });
|
|
531
|
+
for (const entry of stringArray(root.chains)) chains.push({ dir: path.resolve(packageRoot, entry), scope, packageRoot });
|
|
532
|
+
}
|
|
533
|
+
return { agents, chains, watchPaths: [packageJsonPath], settingsErrors: {} };
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function collectPackageRootsFromNodeModules(nodeModulesDir: string, watchPaths?: string[]): string[] {
|
|
537
|
+
const roots: string[] = [];
|
|
538
|
+
watchPaths?.push(nodeModulesDir);
|
|
539
|
+
if (!fs.existsSync(nodeModulesDir)) return roots;
|
|
540
|
+
|
|
541
|
+
let entries: fs.Dirent[];
|
|
542
|
+
try {
|
|
543
|
+
entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
544
|
+
} catch {
|
|
545
|
+
return roots;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
for (const entry of entries) {
|
|
549
|
+
if (entry.name.startsWith(".")) continue;
|
|
550
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
551
|
+
|
|
552
|
+
if (entry.name.startsWith("@")) {
|
|
553
|
+
const scopeDir = path.join(nodeModulesDir, entry.name);
|
|
554
|
+
watchPaths?.push(scopeDir);
|
|
555
|
+
let scopeEntries: fs.Dirent[];
|
|
556
|
+
try {
|
|
557
|
+
scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
|
|
558
|
+
} catch {
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
for (const scopeEntry of scopeEntries) {
|
|
562
|
+
if (scopeEntry.name.startsWith(".")) continue;
|
|
563
|
+
if (!scopeEntry.isDirectory() && !scopeEntry.isSymbolicLink()) continue;
|
|
564
|
+
roots.push(path.join(scopeDir, scopeEntry.name));
|
|
565
|
+
}
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
roots.push(path.join(nodeModulesDir, entry.name));
|
|
570
|
+
}
|
|
571
|
+
return roots;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function collectSettingsPackageRoots(settingsFile: string, baseDir: string): string[] {
|
|
575
|
+
const settings = readSettingsFileStrict(settingsFile);
|
|
576
|
+
const packages = (settings as { packages?: unknown }).packages;
|
|
577
|
+
if (!Array.isArray(packages)) return [];
|
|
578
|
+
|
|
579
|
+
const roots: string[] = [];
|
|
580
|
+
for (const entry of packages) {
|
|
581
|
+
const packageSource = typeof entry === "string"
|
|
582
|
+
? entry
|
|
583
|
+
: typeof entry === "object" && entry !== null && typeof (entry as { source?: unknown }).source === "string"
|
|
584
|
+
? (entry as { source: string }).source
|
|
585
|
+
: undefined;
|
|
586
|
+
if (!packageSource) continue;
|
|
587
|
+
const packageRoot = resolveSettingsPackageRoot(packageSource, baseDir);
|
|
588
|
+
if (packageRoot) roots.push(packageRoot);
|
|
589
|
+
}
|
|
590
|
+
return roots;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function collectPackageSubagentPaths(cwd: string, options: { includeUser: boolean; includeProject: boolean } = { includeUser: true, includeProject: true }): PackageSubagentPaths {
|
|
594
|
+
const agentDir = getAgentDir();
|
|
595
|
+
const projectRoot = findConfiguredProjectRoot(cwd) ?? cwd;
|
|
596
|
+
const packageRoots: Array<{ root: string; scope: PackageScope }> = [
|
|
597
|
+
{ root: projectRoot, scope: "root" },
|
|
598
|
+
];
|
|
599
|
+
const watchPaths: string[] = [path.join(projectRoot, "package.json")];
|
|
600
|
+
const settingsErrors: Partial<Record<PackageSettingsScope, Error>> = {};
|
|
601
|
+
const collectScopedSettingsRoots = (scope: PackageSettingsScope, settingsFile: string, baseDir: string): string[] => {
|
|
602
|
+
try {
|
|
603
|
+
return collectSettingsPackageRoots(settingsFile, baseDir);
|
|
604
|
+
} catch (error) {
|
|
605
|
+
// The raw source snapshot includes both settings scopes. Defer a
|
|
606
|
+
// strict failure until a projection actually selects this scope so an
|
|
607
|
+
// unrelated malformed settings file stays out of scoped discovery.
|
|
608
|
+
settingsErrors[scope] = error instanceof Error
|
|
609
|
+
? error
|
|
610
|
+
: new Error(`Failed to read settings file '${settingsFile}': ${String(error)}`, { cause: error });
|
|
611
|
+
return [];
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
if (options.includeProject) {
|
|
615
|
+
const projectConfigDir = getProjectConfigDir(projectRoot);
|
|
616
|
+
const nodeModulesDir = path.join(projectConfigDir, "npm", "node_modules");
|
|
617
|
+
packageRoots.push(...collectPackageRootsFromNodeModules(nodeModulesDir, watchPaths).map((root) => ({ root, scope: "project" as const })));
|
|
618
|
+
packageRoots.push(...collectScopedSettingsRoots("project", path.join(projectConfigDir, "settings.json"), projectConfigDir).map((root) => ({ root, scope: "project" as const })));
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (options.includeUser) {
|
|
622
|
+
const nodeModulesDir = path.join(agentDir, "npm", "node_modules");
|
|
623
|
+
packageRoots.push(...collectPackageRootsFromNodeModules(nodeModulesDir, watchPaths).map((root) => ({ root, scope: "user" as const })));
|
|
624
|
+
packageRoots.push(...collectScopedSettingsRoots("user", path.join(agentDir, "settings.json"), agentDir).map((root) => ({ root, scope: "user" as const })));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (options.includeUser) {
|
|
628
|
+
const globalRoot = getGlobalNpmRoot();
|
|
629
|
+
if (globalRoot) {
|
|
630
|
+
packageRoots.push(...collectPackageRootsFromNodeModules(globalRoot, watchPaths).map((root) => ({ root, scope: "user" as const })));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const seenRoots = new Map<string, Set<PackageScope>>();
|
|
635
|
+
const seenAgents = new Map<string, PackageSubagentPath>();
|
|
636
|
+
const seenChains = new Map<string, PackageChainPath>();
|
|
637
|
+
const agents: PackageSubagentPath[] = [];
|
|
638
|
+
const chains: PackageChainPath[] = [];
|
|
639
|
+
for (const { root: packageRoot, scope } of packageRoots) {
|
|
640
|
+
const resolvedRoot = path.resolve(packageRoot);
|
|
641
|
+
const scopes = seenRoots.get(resolvedRoot);
|
|
642
|
+
if (scopes !== undefined) {
|
|
643
|
+
scopes.add(scope);
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const packageScopes = new Set<PackageScope>([scope]);
|
|
647
|
+
seenRoots.set(resolvedRoot, packageScopes);
|
|
648
|
+
const paths = extractSubagentPathsFromPackageRoot(resolvedRoot, packageScopes);
|
|
649
|
+
watchPaths.push(...paths.watchPaths);
|
|
650
|
+
for (const agentPath of paths.agents) {
|
|
651
|
+
const agentKey = `${agentPath.dir}\u0000${agentPath.packageRoot}`;
|
|
652
|
+
const existing = seenAgents.get(agentKey);
|
|
653
|
+
if (existing) {
|
|
654
|
+
for (const packageScope of agentPath.scope) existing.scope.add(packageScope);
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
seenAgents.set(agentKey, agentPath);
|
|
658
|
+
agents.push(agentPath);
|
|
659
|
+
}
|
|
660
|
+
for (const chainDir of paths.chains) {
|
|
661
|
+
const chainKey = `${chainDir.dir}\u0000${chainDir.packageRoot}`;
|
|
662
|
+
const existing = seenChains.get(chainKey);
|
|
663
|
+
if (existing) {
|
|
664
|
+
for (const packageScope of chainDir.scope) existing.scope.add(packageScope);
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
seenChains.set(chainKey, chainDir);
|
|
668
|
+
chains.push(chainDir);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return { agents, chains, watchPaths, settingsErrors };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function normalizeAgentAliases(rawAliases: string[] | undefined, agentName: string): string[] | undefined {
|
|
675
|
+
const aliases = [...new Set((rawAliases ?? []).map((alias) => alias.trim()).filter(Boolean))]
|
|
676
|
+
.filter((alias) => alias !== agentName);
|
|
677
|
+
return aliases.length > 0 ? aliases : undefined;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function effectiveAgentMatch(matches: AgentConfig[]): { agent?: AgentConfig; error?: string } {
|
|
681
|
+
const distinctNames = [...new Set(matches.map((agent) => agent.name))];
|
|
682
|
+
if (distinctNames.length === 1) {
|
|
683
|
+
const sourceRank = new Map<AgentConfig["source"], number>([["builtin", 0], ["package", 1], ["user", 2], ["project", 3], ["runtime", 4]]);
|
|
684
|
+
const agent = [...matches].sort((a, b) => (sourceRank.get(b.source) ?? 0) - (sourceRank.get(a.source) ?? 0))[0];
|
|
685
|
+
return agent ? { agent } : {};
|
|
686
|
+
}
|
|
687
|
+
return {};
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export function resolveAgentName(name: string, agents: AgentConfig[]): { agent?: AgentConfig; error?: string } {
|
|
691
|
+
const raw = name.trim();
|
|
692
|
+
const exact = agents.filter((agent) => agent.name === raw || agent.localName === raw);
|
|
693
|
+
if (exact.length === 1) return exact[0] ? { agent: exact[0] } : {};
|
|
694
|
+
if (exact.length > 1) {
|
|
695
|
+
const effective = effectiveAgentMatch(exact);
|
|
696
|
+
if (effective.agent) return effective;
|
|
697
|
+
return { error: `Ambiguous agent name '${name}': ${exact.map((agent) => agent.name).join(", ")}` };
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const aliases = agents.filter((agent) => agent.aliases?.includes(raw));
|
|
701
|
+
if (aliases.length === 1) return aliases[0] ? { agent: aliases[0] } : {};
|
|
702
|
+
if (aliases.length > 1) {
|
|
703
|
+
const effective = effectiveAgentMatch(aliases);
|
|
704
|
+
if (effective.agent) return effective;
|
|
705
|
+
return { error: `Ambiguous agent alias '${name}': ${aliases.map((agent) => agent.name).join(", ")}` };
|
|
706
|
+
}
|
|
707
|
+
return {};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function splitToolList(rawTools: string[] | undefined): { tools?: string[]; mcpDirectTools?: string[] } {
|
|
711
|
+
const mcpDirectTools: string[] = [];
|
|
712
|
+
const tools: string[] = [];
|
|
713
|
+
for (const tool of rawTools ?? []) {
|
|
714
|
+
if (tool.startsWith("mcp:")) {
|
|
715
|
+
mcpDirectTools.push(tool.slice(4));
|
|
716
|
+
} else {
|
|
717
|
+
tools.push(tool);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
return {
|
|
721
|
+
...(rawTools !== undefined ? { tools } : {}),
|
|
722
|
+
...(mcpDirectTools.length > 0 ? { mcpDirectTools } : {}),
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function joinToolList(config: Pick<AgentConfig, "tools" | "mcpDirectTools">): string[] | undefined {
|
|
727
|
+
const joined = [
|
|
728
|
+
...(config.tools ?? []),
|
|
729
|
+
...(config.mcpDirectTools ?? []).map((tool) => `mcp:${tool}`),
|
|
730
|
+
];
|
|
731
|
+
return joined.length > 0 ? joined : undefined;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function arraysEqual(a: string[] | undefined, b: string[] | undefined): boolean {
|
|
735
|
+
if (!a && !b) return true;
|
|
736
|
+
if (!a || !b) return false;
|
|
737
|
+
if (a.length !== b.length) return false;
|
|
738
|
+
for (let i = 0; i < a.length; i++) {
|
|
739
|
+
if (a[i] !== b[i]) return false;
|
|
740
|
+
}
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function cloneOverrideBase(agent: AgentConfig): BuiltinAgentOverrideBase {
|
|
745
|
+
return {
|
|
746
|
+
description: agent.description,
|
|
747
|
+
...(agent.output !== undefined ? { output: agent.output } : {}),
|
|
748
|
+
...(agent.outputMode !== undefined ? { outputMode: agent.outputMode } : {}),
|
|
749
|
+
...(agent.defaultReads !== undefined ? { defaultReads: [...agent.defaultReads] } : {}),
|
|
750
|
+
...(agent.model !== undefined ? { model: agent.model } : {}),
|
|
751
|
+
...(agent.modelProvider !== undefined ? { modelProvider: agent.modelProvider } : {}),
|
|
752
|
+
...(agent.fallbackModels ? { fallbackModels: [...agent.fallbackModels] } : {}),
|
|
753
|
+
...(agent.fast !== undefined ? { fast: agent.fast } : {}),
|
|
754
|
+
...(agent.thinking !== undefined ? { thinking: agent.thinking } : {}),
|
|
755
|
+
systemPromptMode: agent.systemPromptMode,
|
|
756
|
+
inheritProjectContext: agent.inheritProjectContext,
|
|
757
|
+
inheritGlobalContext: agent.inheritGlobalContext,
|
|
758
|
+
inheritSkills: agent.inheritSkills,
|
|
759
|
+
...(agent.defaultContext !== undefined ? { defaultContext: agent.defaultContext } : {}),
|
|
760
|
+
...(agent.acceptanceRole !== undefined ? { acceptanceRole: agent.acceptanceRole } : {}),
|
|
761
|
+
...(agent.disabled !== undefined ? { disabled: agent.disabled } : {}),
|
|
762
|
+
systemPrompt: agent.systemPrompt,
|
|
763
|
+
...(agent.skills ? { skills: [...agent.skills] } : {}),
|
|
764
|
+
...(agent.skillPath ? { skillPath: [...agent.skillPath] } : {}),
|
|
765
|
+
...(agent.tools ? { tools: [...agent.tools] } : {}),
|
|
766
|
+
...(agent.excludeTools ? { excludeTools: [...agent.excludeTools] } : {}),
|
|
767
|
+
...(agent.allowNestedSubagents !== undefined ? { allowNestedSubagents: agent.allowNestedSubagents } : {}),
|
|
768
|
+
...(agent.mcpDirectTools ? { mcpDirectTools: [...agent.mcpDirectTools] } : {}),
|
|
769
|
+
...(!agent.extensionsFromDefault && agent.extensions ? { extensions: [...agent.extensions] } : {}),
|
|
770
|
+
...(agent.subagentOnlyExtensions ? { subagentOnlyExtensions: [...agent.subagentOnlyExtensions] } : {}),
|
|
771
|
+
...(agent.mutationTools ? { mutationTools: [...agent.mutationTools] } : {}),
|
|
772
|
+
...(agent.completionGuard !== undefined ? { completionGuard: agent.completionGuard } : {}),
|
|
773
|
+
...(agent.toolBudget !== undefined ? { toolBudget: agent.toolBudget } : {}),
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
function cloneOverrideValue(override: BuiltinAgentOverrideConfig): BuiltinAgentOverrideConfig {
|
|
778
|
+
return {
|
|
779
|
+
...(override.description !== undefined ? { description: override.description } : {}),
|
|
780
|
+
...(override.output !== undefined ? { output: override.output } : {}),
|
|
781
|
+
...(override.outputMode !== undefined ? { outputMode: override.outputMode } : {}),
|
|
782
|
+
...(override.defaultReads !== undefined ? { defaultReads: override.defaultReads === false ? false : [...override.defaultReads] } : {}),
|
|
783
|
+
...(override.model !== undefined ? { model: override.model } : {}),
|
|
784
|
+
...(override.defaultProvider !== undefined ? { defaultProvider: override.defaultProvider } : {}),
|
|
785
|
+
...(override.fallbackModels !== undefined
|
|
786
|
+
? { fallbackModels: override.fallbackModels === false ? false : [...override.fallbackModels] }
|
|
787
|
+
: {}),
|
|
788
|
+
...(override.fast !== undefined ? { fast: override.fast } : {}),
|
|
789
|
+
...(override.thinking !== undefined ? { thinking: override.thinking } : {}),
|
|
790
|
+
...(override.systemPromptMode !== undefined ? { systemPromptMode: override.systemPromptMode } : {}),
|
|
791
|
+
...(override.inheritProjectContext !== undefined ? { inheritProjectContext: override.inheritProjectContext } : {}),
|
|
792
|
+
...(override.inheritGlobalContext !== undefined ? { inheritGlobalContext: override.inheritGlobalContext } : {}),
|
|
793
|
+
...(override.inheritSkills !== undefined ? { inheritSkills: override.inheritSkills } : {}),
|
|
794
|
+
...(override.defaultContext !== undefined ? { defaultContext: override.defaultContext } : {}),
|
|
795
|
+
...(override.acceptanceRole !== undefined ? { acceptanceRole: override.acceptanceRole } : {}),
|
|
796
|
+
...(override.disabled !== undefined ? { disabled: override.disabled } : {}),
|
|
797
|
+
...(override.systemPrompt !== undefined ? { systemPrompt: override.systemPrompt } : {}),
|
|
798
|
+
...(override.skills !== undefined ? { skills: override.skills === false ? false : [...override.skills] } : {}),
|
|
799
|
+
...(override.tools !== undefined ? { tools: Array.isArray(override.tools) ? [...override.tools] : override.tools } : {}),
|
|
800
|
+
...(override.excludeTools !== undefined ? { excludeTools: override.excludeTools === false ? false : [...override.excludeTools] } : {}),
|
|
801
|
+
...(override.allowNestedSubagents !== undefined ? { allowNestedSubagents: override.allowNestedSubagents } : {}),
|
|
802
|
+
...(override.extensions !== undefined ? { extensions: override.extensions === false ? false : [...override.extensions] } : {}),
|
|
803
|
+
...(override.subagentOnlyExtensions !== undefined ? { subagentOnlyExtensions: override.subagentOnlyExtensions === false ? false : [...override.subagentOnlyExtensions] } : {}),
|
|
804
|
+
...(override.mutationTools !== undefined ? { mutationTools: override.mutationTools === false ? false : [...override.mutationTools] } : {}),
|
|
805
|
+
...(override.completionGuard !== undefined ? { completionGuard: override.completionGuard } : {}),
|
|
806
|
+
...(override.toolBudget !== undefined ? { toolBudget: override.toolBudget === false ? false : { ...override.toolBudget, ...(Array.isArray(override.toolBudget.block) ? { block: [...override.toolBudget.block] } : {}) } } : {}),
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function isProjectRootCandidate(dir: string): boolean {
|
|
811
|
+
return isDirectory(getProjectConfigDir(dir)) || isDirectory(path.join(dir, ".agents"));
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function findProjectRootCandidates(cwd: string): string[] {
|
|
815
|
+
const roots: string[] = [];
|
|
816
|
+
let currentDir = cwd;
|
|
817
|
+
while (true) {
|
|
818
|
+
if (isProjectRootCandidate(currentDir)) roots.push(currentDir);
|
|
819
|
+
|
|
820
|
+
const parentDir = path.dirname(currentDir);
|
|
821
|
+
if (parentDir === currentDir) return roots;
|
|
822
|
+
currentDir = parentDir;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function findNearestGitRoot(cwd: string): string | null {
|
|
827
|
+
let currentDir = cwd;
|
|
828
|
+
while (true) {
|
|
829
|
+
if (fs.existsSync(path.join(currentDir, ".git"))) return currentDir;
|
|
830
|
+
|
|
831
|
+
const parentDir = path.dirname(currentDir);
|
|
832
|
+
if (parentDir === currentDir) return null;
|
|
833
|
+
currentDir = parentDir;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
function readProjectRootResolution(projectRoot: string): ProjectRootResolution | undefined {
|
|
838
|
+
const settingsPath = path.join(getProjectConfigDir(projectRoot), "settings.json");
|
|
839
|
+
if (!fs.existsSync(settingsPath)) return undefined;
|
|
840
|
+
const settings = readSettingsFileStrict(settingsPath);
|
|
841
|
+
const subagents = settings.subagents;
|
|
842
|
+
if (!subagents || typeof subagents !== "object" || Array.isArray(subagents)) return undefined;
|
|
843
|
+
|
|
844
|
+
const value = (subagents as Record<string, unknown>).projectRootResolution;
|
|
845
|
+
if (value === undefined) return undefined;
|
|
846
|
+
if (value === "nearest" || value === "git-root") return value;
|
|
847
|
+
throw new Error(`Subagent settings in '${settingsPath}' have invalid 'projectRootResolution'; expected 'nearest' or 'git-root'.`);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
export function findNearestProjectRoot(cwd: string): string | null {
|
|
851
|
+
return findProjectRootCandidates(cwd)[0] ?? null;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
export function findConfiguredProjectRoot(cwd: string): string | null {
|
|
855
|
+
const candidates = findProjectRootCandidates(cwd);
|
|
856
|
+
const nearestRoot = candidates[0];
|
|
857
|
+
if (!nearestRoot) return null;
|
|
858
|
+
|
|
859
|
+
let policyRoot: string | undefined;
|
|
860
|
+
let policyRootIndex = -1;
|
|
861
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
862
|
+
const mode = readProjectRootResolution(candidate);
|
|
863
|
+
if (mode === "nearest") return nearestRoot;
|
|
864
|
+
if (mode === "git-root") {
|
|
865
|
+
policyRoot = candidate;
|
|
866
|
+
policyRootIndex = index;
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
if (!policyRoot) return nearestRoot;
|
|
871
|
+
|
|
872
|
+
const gitRoot = findNearestGitRoot(cwd);
|
|
873
|
+
const gitProjectRoot = gitRoot
|
|
874
|
+
? candidates.slice(policyRootIndex).find((candidate) => path.resolve(candidate) === path.resolve(gitRoot))
|
|
875
|
+
: undefined;
|
|
876
|
+
const configuredGitRoot = fs.existsSync(path.join(policyRoot, ".git")) ? policyRoot : undefined;
|
|
877
|
+
return gitProjectRoot ?? configuredGitRoot ?? nearestRoot;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
function getUserAgentSettingsPath(): string {
|
|
881
|
+
return path.join(getAgentDir(), "settings.json");
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function getProjectAgentSettingsPath(cwd: string): string | null {
|
|
885
|
+
const projectRoot = findConfiguredProjectRoot(cwd);
|
|
886
|
+
return projectRoot ? path.join(getProjectConfigDir(projectRoot), "settings.json") : null;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
function readSettingsFileStrict(filePath: string): Record<string, unknown> {
|
|
890
|
+
if (!fs.existsSync(filePath)) return {};
|
|
891
|
+
let raw: string;
|
|
892
|
+
try {
|
|
893
|
+
raw = fs.readFileSync(filePath, "utf-8");
|
|
894
|
+
} catch (error) {
|
|
895
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
896
|
+
throw new Error(`Failed to read settings file '${filePath}': ${message}`, { cause: error });
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
let parsed: unknown;
|
|
900
|
+
try {
|
|
901
|
+
parsed = JSON.parse(raw);
|
|
902
|
+
} catch (error) {
|
|
903
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
904
|
+
throw new Error(`Failed to parse settings file '${filePath}': ${message}`, { cause: error });
|
|
905
|
+
}
|
|
906
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
907
|
+
throw new Error(`Settings file '${filePath}' must contain a JSON object.`);
|
|
908
|
+
}
|
|
909
|
+
return parsed as Record<string, unknown>;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
function writeSettingsFile(filePath: string, settings: Record<string, unknown>): void {
|
|
913
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
914
|
+
fs.writeFileSync(filePath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function parseOverrideStringArrayOrFalse(
|
|
918
|
+
value: unknown,
|
|
919
|
+
meta: { filePath: string; name: string; field: string },
|
|
920
|
+
): string[] | false | undefined {
|
|
921
|
+
if (value === undefined) return undefined;
|
|
922
|
+
if (value === false) return false;
|
|
923
|
+
if (!Array.isArray(value)) {
|
|
924
|
+
throw new Error(`Builtin override '${meta.name}' in '${meta.filePath}' has invalid '${meta.field}'; expected an array of strings or false.`);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
const items: string[] = [];
|
|
928
|
+
for (const item of value) {
|
|
929
|
+
if (typeof item !== "string") {
|
|
930
|
+
throw new Error(`Builtin override '${meta.name}' in '${meta.filePath}' has invalid '${meta.field}'; expected an array of strings or false.`);
|
|
931
|
+
}
|
|
932
|
+
const trimmed = item.trim();
|
|
933
|
+
if (trimmed) items.push(trimmed);
|
|
934
|
+
}
|
|
935
|
+
return items;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function parseToolsOverride(
|
|
939
|
+
value: unknown,
|
|
940
|
+
meta: { filePath: string; name: string },
|
|
941
|
+
): BuiltinAgentOverrideConfig["tools"] | undefined {
|
|
942
|
+
if (typeof value === "string" && value.trim() === "inherit") return "inherit";
|
|
943
|
+
if (value === undefined || value === false || Array.isArray(value)) {
|
|
944
|
+
return parseOverrideStringArrayOrFalse(value, { ...meta, field: "tools" });
|
|
945
|
+
}
|
|
946
|
+
throw new Error(`Builtin override '${meta.name}' in '${meta.filePath}' has invalid 'tools'; expected an array of strings, "inherit", or false.`);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function parseBuiltinOverrideEntry(
|
|
950
|
+
name: string,
|
|
951
|
+
value: unknown,
|
|
952
|
+
filePath: string,
|
|
953
|
+
): BuiltinAgentOverrideConfig | undefined {
|
|
954
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
955
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' must be an object.`);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
const input = value as Record<string, unknown>;
|
|
959
|
+
const override: BuiltinAgentOverrideConfig = {};
|
|
960
|
+
|
|
961
|
+
if ("description" in input) {
|
|
962
|
+
if (typeof input.description === "string" && input.description.trim()) {
|
|
963
|
+
override.description = input.description.trim();
|
|
964
|
+
} else {
|
|
965
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'description'; expected a non-empty string.`);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
if ("output" in input) {
|
|
970
|
+
if ((typeof input.output === "string" && input.output.trim()) || input.output === false) override.output = input.output;
|
|
971
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'output'; expected a non-empty string or false.`);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
if ("outputMode" in input) {
|
|
975
|
+
if (input.outputMode === "inline" || input.outputMode === "file-only") {
|
|
976
|
+
override.outputMode = input.outputMode;
|
|
977
|
+
} else {
|
|
978
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'outputMode'; expected 'inline' or 'file-only'.`);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if ("model" in input) {
|
|
983
|
+
if (typeof input.model === "string" || input.model === false) override.model = input.model;
|
|
984
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'model'; expected a string or false.`);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
if ("fast" in input) {
|
|
988
|
+
if (typeof input.fast === "boolean") override.fast = input.fast;
|
|
989
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'fast'; expected a boolean.`);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if ("thinking" in input) {
|
|
993
|
+
if (typeof input.thinking === "string" || input.thinking === false) override.thinking = input.thinking;
|
|
994
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'thinking'; expected a string or false.`);
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
if ("systemPromptMode" in input) {
|
|
998
|
+
if (input.systemPromptMode === "append" || input.systemPromptMode === "replace") {
|
|
999
|
+
override.systemPromptMode = input.systemPromptMode;
|
|
1000
|
+
} else {
|
|
1001
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'systemPromptMode'; expected 'append' or 'replace'.`);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
if ("inheritProjectContext" in input) {
|
|
1006
|
+
if (typeof input.inheritProjectContext === "boolean") {
|
|
1007
|
+
override.inheritProjectContext = input.inheritProjectContext;
|
|
1008
|
+
} else {
|
|
1009
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'inheritProjectContext'; expected a boolean.`);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if ("inheritGlobalContext" in input) {
|
|
1014
|
+
if (typeof input.inheritGlobalContext === "boolean") {
|
|
1015
|
+
override.inheritGlobalContext = input.inheritGlobalContext;
|
|
1016
|
+
} else {
|
|
1017
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'inheritGlobalContext'; expected a boolean.`);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
if ("inheritSkills" in input) {
|
|
1022
|
+
if (typeof input.inheritSkills === "boolean") {
|
|
1023
|
+
override.inheritSkills = input.inheritSkills;
|
|
1024
|
+
} else {
|
|
1025
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'inheritSkills'; expected a boolean.`);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
if ("defaultContext" in input) {
|
|
1030
|
+
if (input.defaultContext === "fresh" || input.defaultContext === "fork" || input.defaultContext === false) {
|
|
1031
|
+
override.defaultContext = input.defaultContext;
|
|
1032
|
+
} else {
|
|
1033
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'defaultContext'; expected 'fresh', 'fork', or false.`);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
if ("acceptanceRole" in input) {
|
|
1038
|
+
if (input.acceptanceRole === "read-only" || input.acceptanceRole === "writer" || input.acceptanceRole === false) {
|
|
1039
|
+
override.acceptanceRole = input.acceptanceRole;
|
|
1040
|
+
} else {
|
|
1041
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'acceptanceRole'; expected 'read-only', 'writer', or false.`);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
if ("disabled" in input) {
|
|
1046
|
+
if (typeof input.disabled === "boolean") {
|
|
1047
|
+
override.disabled = input.disabled;
|
|
1048
|
+
} else {
|
|
1049
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'disabled'; expected a boolean.`);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
if ("completionGuard" in input) {
|
|
1054
|
+
if (typeof input.completionGuard === "boolean") {
|
|
1055
|
+
override.completionGuard = input.completionGuard;
|
|
1056
|
+
} else {
|
|
1057
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'completionGuard'; expected a boolean.`);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if ("toolBudget" in input) {
|
|
1062
|
+
if (input.toolBudget === false) {
|
|
1063
|
+
override.toolBudget = false;
|
|
1064
|
+
} else if (input.toolBudget && typeof input.toolBudget === "object" && !Array.isArray(input.toolBudget)) {
|
|
1065
|
+
override.toolBudget = input.toolBudget as ToolBudgetConfig;
|
|
1066
|
+
} else {
|
|
1067
|
+
throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'toolBudget'; expected an object or false.`);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
if ("systemPrompt" in input) {
|
|
1072
|
+
if (typeof input.systemPrompt === "string") override.systemPrompt = input.systemPrompt;
|
|
1073
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'systemPrompt'; expected a string.`);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
const defaultReads = parseOverrideStringArrayOrFalse(input.defaultReads, { filePath, name, field: "defaultReads" });
|
|
1077
|
+
if (defaultReads !== undefined) override.defaultReads = defaultReads;
|
|
1078
|
+
|
|
1079
|
+
const fallbackModels = parseOverrideStringArrayOrFalse(input.fallbackModels, { filePath, name, field: "fallbackModels" });
|
|
1080
|
+
if (fallbackModels !== undefined) override.fallbackModels = fallbackModels;
|
|
1081
|
+
|
|
1082
|
+
if ("defaultProvider" in input) {
|
|
1083
|
+
if (input.defaultProvider === false) override.defaultProvider = false;
|
|
1084
|
+
else if (typeof input.defaultProvider === "string" && input.defaultProvider.trim()) override.defaultProvider = input.defaultProvider.trim();
|
|
1085
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'defaultProvider'; expected a non-empty string or false.`);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
const skills = parseOverrideStringArrayOrFalse(input.skills, { filePath, name, field: "skills" });
|
|
1089
|
+
if (skills !== undefined) override.skills = skills;
|
|
1090
|
+
|
|
1091
|
+
const tools = parseToolsOverride(input.tools, { filePath, name });
|
|
1092
|
+
if (tools !== undefined) override.tools = tools;
|
|
1093
|
+
const excludeTools = parseOverrideStringArrayOrFalse(input.excludeTools, { filePath, name, field: "excludeTools" });
|
|
1094
|
+
if (excludeTools !== undefined) override.excludeTools = excludeTools;
|
|
1095
|
+
if ("allowNestedSubagents" in input) {
|
|
1096
|
+
if (typeof input.allowNestedSubagents === "boolean") override.allowNestedSubagents = input.allowNestedSubagents;
|
|
1097
|
+
else throw new Error(`Builtin override '${name}' in '${filePath}' has invalid 'allowNestedSubagents'; expected a boolean.`);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
const extensions = parseOverrideStringArrayOrFalse(input.extensions, { filePath, name, field: "extensions" });
|
|
1101
|
+
if (extensions !== undefined) override.extensions = extensions;
|
|
1102
|
+
|
|
1103
|
+
const subagentOnlyExtensions = parseOverrideStringArrayOrFalse(input.subagentOnlyExtensions, { filePath, name, field: "subagentOnlyExtensions" });
|
|
1104
|
+
if (subagentOnlyExtensions !== undefined) override.subagentOnlyExtensions = subagentOnlyExtensions;
|
|
1105
|
+
|
|
1106
|
+
const mutationTools = parseOverrideStringArrayOrFalse(input.mutationTools, { filePath, name, field: "mutationTools" });
|
|
1107
|
+
if (mutationTools !== undefined) override.mutationTools = mutationTools;
|
|
1108
|
+
|
|
1109
|
+
return Object.keys(override).length > 0 ? override : undefined;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function readSubagentSettings(filePath: string | null): SubagentSettings {
|
|
1113
|
+
if (!filePath) return EMPTY_SUBAGENT_SETTINGS;
|
|
1114
|
+
const settings = readSettingsFileStrict(filePath);
|
|
1115
|
+
const subagents = settings.subagents;
|
|
1116
|
+
if (!subagents || typeof subagents !== "object" || Array.isArray(subagents)) return EMPTY_SUBAGENT_SETTINGS;
|
|
1117
|
+
|
|
1118
|
+
const subagentsObject = subagents as Record<string, unknown>;
|
|
1119
|
+
let disableBuiltins: boolean | undefined;
|
|
1120
|
+
if ("disableBuiltins" in subagentsObject) {
|
|
1121
|
+
if (typeof subagentsObject.disableBuiltins === "boolean") {
|
|
1122
|
+
disableBuiltins = subagentsObject.disableBuiltins;
|
|
1123
|
+
} else {
|
|
1124
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'disableBuiltins'; expected a boolean.`);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
let disableThinking: boolean | undefined;
|
|
1128
|
+
if ("disableThinking" in subagentsObject) {
|
|
1129
|
+
if (typeof subagentsObject.disableThinking === "boolean") {
|
|
1130
|
+
disableThinking = subagentsObject.disableThinking;
|
|
1131
|
+
} else {
|
|
1132
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'disableThinking'; expected a boolean.`);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
let defaultModel: string | undefined;
|
|
1136
|
+
if ("defaultModel" in subagentsObject) {
|
|
1137
|
+
if (typeof subagentsObject.defaultModel === "string" && subagentsObject.defaultModel.trim()) {
|
|
1138
|
+
defaultModel = subagentsObject.defaultModel.trim();
|
|
1139
|
+
} else {
|
|
1140
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'defaultModel'; expected a non-empty string.`);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
let defaultProvider: string | undefined;
|
|
1144
|
+
if ("defaultProvider" in subagentsObject) {
|
|
1145
|
+
if (typeof subagentsObject.defaultProvider === "string" && subagentsObject.defaultProvider.trim()) {
|
|
1146
|
+
defaultProvider = subagentsObject.defaultProvider.trim();
|
|
1147
|
+
} else {
|
|
1148
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'defaultProvider'; expected a non-empty string.`);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
let defaultThinking: string | undefined;
|
|
1152
|
+
if ("defaultThinking" in subagentsObject) {
|
|
1153
|
+
if (typeof subagentsObject.defaultThinking === "string" && subagentsObject.defaultThinking.trim()) {
|
|
1154
|
+
defaultThinking = subagentsObject.defaultThinking.trim();
|
|
1155
|
+
} else {
|
|
1156
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'defaultThinking'; expected a non-empty string.`);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
let maxThinking: ThinkingLevel | undefined;
|
|
1160
|
+
if ("maxThinking" in subagentsObject) {
|
|
1161
|
+
try {
|
|
1162
|
+
maxThinking = parseThinkingLevel(subagentsObject.maxThinking, `'${filePath}' subagents.maxThinking`);
|
|
1163
|
+
} catch (error) {
|
|
1164
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'maxThinking'; expected one of off, minimal, low, medium, high, xhigh, or max.`, { cause: error instanceof Error ? error : undefined });
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
let defaultExtensions: string[] | undefined;
|
|
1168
|
+
if ("defaultExtensions" in subagentsObject) {
|
|
1169
|
+
if (!Array.isArray(subagentsObject.defaultExtensions)
|
|
1170
|
+
|| subagentsObject.defaultExtensions.some((item) => typeof item !== "string" || !item.trim())) {
|
|
1171
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'defaultExtensions'; expected an array of non-empty strings.`);
|
|
1172
|
+
}
|
|
1173
|
+
defaultExtensions = subagentsObject.defaultExtensions.map((item) => item.trim());
|
|
1174
|
+
}
|
|
1175
|
+
const modelScope = parseModelScopeConfig(subagentsObject.modelScope, { filePath });
|
|
1176
|
+
|
|
1177
|
+
const parsed: Record<string, BuiltinAgentOverrideConfig> = {};
|
|
1178
|
+
const providerOverrides: Record<string, Record<string, BuiltinAgentOverrideConfig>> = {};
|
|
1179
|
+
const agentOverrides = subagentsObject.agentOverrides;
|
|
1180
|
+
const agentOverridesByProvider = subagentsObject.agentOverridesByProvider;
|
|
1181
|
+
const parsedSettings: SubagentSettings = {
|
|
1182
|
+
overrides: parsed,
|
|
1183
|
+
providerOverrides,
|
|
1184
|
+
...(defaultModel !== undefined ? { defaultModel } : {}),
|
|
1185
|
+
...(defaultProvider !== undefined ? { defaultProvider } : {}),
|
|
1186
|
+
...(defaultThinking !== undefined ? { defaultThinking } : {}),
|
|
1187
|
+
...(maxThinking !== undefined ? { maxThinking } : {}),
|
|
1188
|
+
...(defaultExtensions !== undefined ? { defaultExtensions } : {}),
|
|
1189
|
+
...(disableBuiltins !== undefined ? { disableBuiltins } : {}),
|
|
1190
|
+
...(disableThinking !== undefined ? { disableThinking } : {}),
|
|
1191
|
+
...(modelScope !== undefined ? { modelScope } : {}),
|
|
1192
|
+
};
|
|
1193
|
+
if (agentOverrides && typeof agentOverrides === "object" && !Array.isArray(agentOverrides)) {
|
|
1194
|
+
for (const [name, value] of Object.entries(agentOverrides)) {
|
|
1195
|
+
const override = parseBuiltinOverrideEntry(name, value, filePath);
|
|
1196
|
+
if (override) parsed[name] = override;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
if (agentOverridesByProvider !== undefined) {
|
|
1200
|
+
if (!agentOverridesByProvider || typeof agentOverridesByProvider !== "object" || Array.isArray(agentOverridesByProvider)) {
|
|
1201
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'agentOverridesByProvider'; expected an object keyed by provider.`);
|
|
1202
|
+
}
|
|
1203
|
+
for (const [provider, value] of Object.entries(agentOverridesByProvider)) {
|
|
1204
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1205
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'agentOverridesByProvider.${provider}'; expected an object keyed by agent.`);
|
|
1206
|
+
}
|
|
1207
|
+
const entries: Record<string, BuiltinAgentOverrideConfig> = {};
|
|
1208
|
+
for (const [agentName, agentValue] of Object.entries(value)) {
|
|
1209
|
+
const override = parseBuiltinOverrideEntry(`agentOverridesByProvider.${provider}.${agentName}`, agentValue, filePath);
|
|
1210
|
+
if (override) entries[agentName] = override;
|
|
1211
|
+
}
|
|
1212
|
+
providerOverrides[provider] = entries;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
return parsedSettings;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function selectProviderOverrides(settings: SubagentSettings, provider: string | undefined): SubagentSettings {
|
|
1219
|
+
if (!provider) return settings;
|
|
1220
|
+
const selected = settings.providerOverrides[provider];
|
|
1221
|
+
if (!selected) return settings;
|
|
1222
|
+
const overrides = { ...settings.overrides };
|
|
1223
|
+
for (const [name, override] of Object.entries(selected)) {
|
|
1224
|
+
overrides[name] = { ...overrides[name], ...override };
|
|
1225
|
+
}
|
|
1226
|
+
return { ...settings, overrides };
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
function resolveSubagentDefaultProvider(
|
|
1230
|
+
userSettings: SubagentSettings,
|
|
1231
|
+
projectSettings: SubagentSettings,
|
|
1232
|
+
projectSettingsPath: string | null,
|
|
1233
|
+
): string | undefined {
|
|
1234
|
+
if (projectSettingsPath && projectSettings.defaultProvider !== undefined) return projectSettings.defaultProvider;
|
|
1235
|
+
return userSettings.defaultProvider;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function resolveSubagentDefaultModel(
|
|
1239
|
+
userSettings: SubagentSettings,
|
|
1240
|
+
projectSettings: SubagentSettings,
|
|
1241
|
+
userSettingsPath: string,
|
|
1242
|
+
projectSettingsPath: string | null,
|
|
1243
|
+
defaultProvider: string | undefined,
|
|
1244
|
+
): AgentModelSourceInfo | undefined {
|
|
1245
|
+
if (projectSettingsPath && projectSettings.defaultModel !== undefined) {
|
|
1246
|
+
return { type: "subagents.defaultModel", scope: "project", path: projectSettingsPath, model: projectSettings.defaultModel, ...(defaultProvider ? { defaultProvider } : {}) };
|
|
1247
|
+
}
|
|
1248
|
+
return userSettings.defaultModel !== undefined
|
|
1249
|
+
? { type: "subagents.defaultModel", scope: "user", path: userSettingsPath, model: userSettings.defaultModel, ...(defaultProvider ? { defaultProvider } : {}) }
|
|
1250
|
+
: undefined;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function applySubagentDefaultModel(agents: AgentConfig[], defaultModel: AgentModelSourceInfo | undefined, defaultProvider: string | undefined): AgentConfig[] {
|
|
1254
|
+
if (!defaultModel && !defaultProvider) return agents;
|
|
1255
|
+
return agents.map((agent) => {
|
|
1256
|
+
if (agent.model !== undefined && (agent.modelProvider !== undefined || !defaultProvider)) return agent;
|
|
1257
|
+
const next = {
|
|
1258
|
+
...agent,
|
|
1259
|
+
...(agent.model === undefined && defaultModel ? { model: defaultModel.model, modelSource: defaultModel } : {}),
|
|
1260
|
+
...(defaultProvider ? { modelProvider: defaultProvider } : {}),
|
|
1261
|
+
};
|
|
1262
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1263
|
+
if (frontmatterFields) agentFrontmatterFields.set(next, frontmatterFields);
|
|
1264
|
+
return next;
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
function resolveSubagentDefaultThinking(
|
|
1269
|
+
userSettings: SubagentSettings,
|
|
1270
|
+
projectSettings: SubagentSettings,
|
|
1271
|
+
projectSettingsPath: string | null,
|
|
1272
|
+
): string | undefined {
|
|
1273
|
+
if (projectSettingsPath && projectSettings.defaultThinking !== undefined) return projectSettings.defaultThinking;
|
|
1274
|
+
return userSettings.defaultThinking;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function applySubagentDefaultThinking(agents: AgentConfig[], defaultThinking: string | undefined): AgentConfig[] {
|
|
1278
|
+
if (defaultThinking === undefined) return agents;
|
|
1279
|
+
return agents.map((agent) => {
|
|
1280
|
+
if (agent.thinking !== undefined) return agent;
|
|
1281
|
+
const next = { ...agent, thinking: defaultThinking };
|
|
1282
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1283
|
+
if (frontmatterFields) agentFrontmatterFields.set(next, frontmatterFields);
|
|
1284
|
+
return next;
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
function resolveSubagentMaxThinking(
|
|
1289
|
+
userSettings: SubagentSettings,
|
|
1290
|
+
projectSettings: SubagentSettings,
|
|
1291
|
+
projectSettingsPath: string | null,
|
|
1292
|
+
): ThinkingLevel | undefined {
|
|
1293
|
+
if (projectSettingsPath && projectSettings.maxThinking !== undefined) return projectSettings.maxThinking;
|
|
1294
|
+
return userSettings.maxThinking;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
function applySubagentMaxThinking(agents: AgentConfig[], maxThinking: ThinkingLevel | undefined): AgentConfig[] {
|
|
1298
|
+
if (maxThinking === undefined) return agents;
|
|
1299
|
+
return agents.map((agent) => agent.maxThinking === maxThinking ? agent : { ...agent, maxThinking });
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
function resolveSubagentDefaultExtensions(
|
|
1303
|
+
userSettings: SubagentSettings,
|
|
1304
|
+
projectSettings: SubagentSettings,
|
|
1305
|
+
projectSettingsPath: string | null,
|
|
1306
|
+
): string[] | undefined {
|
|
1307
|
+
if (projectSettingsPath && projectSettings.defaultExtensions !== undefined) return projectSettings.defaultExtensions;
|
|
1308
|
+
return userSettings.defaultExtensions;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function applySubagentDefaultExtensions(agents: AgentConfig[], defaultExtensions: string[] | undefined): AgentConfig[] {
|
|
1312
|
+
if (defaultExtensions === undefined) return agents;
|
|
1313
|
+
return agents.map((agent) => {
|
|
1314
|
+
if (agent.extensions !== undefined) return agent;
|
|
1315
|
+
const next = { ...agent, extensions: [...defaultExtensions], extensionsFromDefault: true };
|
|
1316
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1317
|
+
if (frontmatterFields) agentFrontmatterFields.set(next, frontmatterFields);
|
|
1318
|
+
return next;
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
function applySubagentDefaults(
|
|
1323
|
+
agents: AgentConfig[],
|
|
1324
|
+
defaultModel: AgentModelSourceInfo | undefined,
|
|
1325
|
+
defaultProvider: string | undefined,
|
|
1326
|
+
defaultThinking: string | undefined,
|
|
1327
|
+
defaultExtensions: string[] | undefined,
|
|
1328
|
+
): AgentConfig[] {
|
|
1329
|
+
return applySubagentDefaultExtensions(
|
|
1330
|
+
applySubagentDefaultThinking(applySubagentDefaultModel(agents, defaultModel, defaultProvider), defaultThinking),
|
|
1331
|
+
defaultExtensions,
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
function applyToolsOverride(target: AgentConfig, toolsOverride: string[] | false | "inherit"): void {
|
|
1336
|
+
if (toolsOverride === "inherit") {
|
|
1337
|
+
delete target.tools;
|
|
1338
|
+
delete target.mcpDirectTools;
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
const { tools, mcpDirectTools } = splitToolList(toolsOverride === false ? [] : toolsOverride);
|
|
1342
|
+
if (tools === undefined) delete target.tools; else target.tools = tools;
|
|
1343
|
+
if (mcpDirectTools === undefined) delete target.mcpDirectTools; else target.mcpDirectTools = mcpDirectTools;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
function applyBuiltinOverride(
|
|
1347
|
+
agent: AgentConfig,
|
|
1348
|
+
override: BuiltinAgentOverrideConfig,
|
|
1349
|
+
meta: { scope: "user" | "project"; path: string },
|
|
1350
|
+
): AgentConfig {
|
|
1351
|
+
const next: AgentConfig = {
|
|
1352
|
+
...agent,
|
|
1353
|
+
override: { ...meta, base: cloneOverrideBase(agent) },
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
if (override.description !== undefined) next.description = override.description;
|
|
1357
|
+
if (override.output !== undefined) { if (override.output === false) delete next.output; else next.output = override.output; }
|
|
1358
|
+
if (override.outputMode !== undefined) next.outputMode = override.outputMode;
|
|
1359
|
+
if (override.defaultReads !== undefined) { if (override.defaultReads === false) delete next.defaultReads; else next.defaultReads = [...override.defaultReads]; }
|
|
1360
|
+
if (override.model !== undefined) {
|
|
1361
|
+
if (override.model === false) delete next.model; else next.model = override.model;
|
|
1362
|
+
delete next.modelSource;
|
|
1363
|
+
}
|
|
1364
|
+
if (override.defaultProvider !== undefined) {
|
|
1365
|
+
if (override.defaultProvider === false) delete next.modelProvider;
|
|
1366
|
+
else next.modelProvider = override.defaultProvider;
|
|
1367
|
+
}
|
|
1368
|
+
if (override.fallbackModels !== undefined) { if (override.fallbackModels === false) delete next.fallbackModels; else next.fallbackModels = [...override.fallbackModels]; }
|
|
1369
|
+
if (override.fast !== undefined) next.fast = override.fast;
|
|
1370
|
+
if (override.thinking !== undefined) { if (override.thinking === false) delete next.thinking; else next.thinking = override.thinking; }
|
|
1371
|
+
if (override.systemPromptMode !== undefined) next.systemPromptMode = override.systemPromptMode;
|
|
1372
|
+
if (override.inheritProjectContext !== undefined) next.inheritProjectContext = override.inheritProjectContext;
|
|
1373
|
+
if (override.inheritGlobalContext !== undefined) next.inheritGlobalContext = override.inheritGlobalContext;
|
|
1374
|
+
if (override.inheritSkills !== undefined) next.inheritSkills = override.inheritSkills;
|
|
1375
|
+
if (override.defaultContext !== undefined) { if (override.defaultContext === false) delete next.defaultContext; else next.defaultContext = override.defaultContext; }
|
|
1376
|
+
if (override.acceptanceRole !== undefined) { if (override.acceptanceRole === false) delete next.acceptanceRole; else next.acceptanceRole = override.acceptanceRole; }
|
|
1377
|
+
if (override.disabled !== undefined) next.disabled = override.disabled;
|
|
1378
|
+
if (override.systemPrompt !== undefined) next.systemPrompt = override.systemPrompt;
|
|
1379
|
+
if (override.skills !== undefined) { if (override.skills === false) delete next.skills; else next.skills = [...override.skills]; }
|
|
1380
|
+
if (override.tools !== undefined) applyToolsOverride(next, override.tools);
|
|
1381
|
+
if (override.excludeTools !== undefined) { if (override.excludeTools === false) delete next.excludeTools; else next.excludeTools = [...override.excludeTools]; }
|
|
1382
|
+
if (override.allowNestedSubagents !== undefined) next.allowNestedSubagents = override.allowNestedSubagents;
|
|
1383
|
+
if (override.extensions !== undefined) { if (override.extensions === false) delete next.extensions; else next.extensions = [...override.extensions]; }
|
|
1384
|
+
if (override.subagentOnlyExtensions !== undefined) { if (override.subagentOnlyExtensions === false) delete next.subagentOnlyExtensions; else next.subagentOnlyExtensions = [...override.subagentOnlyExtensions]; }
|
|
1385
|
+
if (override.mutationTools !== undefined) { if (override.mutationTools === false) delete next.mutationTools; else next.mutationTools = [...override.mutationTools]; }
|
|
1386
|
+
if (override.completionGuard !== undefined) next.completionGuard = override.completionGuard;
|
|
1387
|
+
if (override.toolBudget !== undefined) { if (override.toolBudget === false) delete next.toolBudget; else next.toolBudget = override.toolBudget; }
|
|
1388
|
+
|
|
1389
|
+
return next;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
function clearBuiltinThinking(agent: AgentConfig, meta: { scope: "user" | "project"; path: string }): AgentConfig {
|
|
1393
|
+
if (agent.thinking === undefined) return agent;
|
|
1394
|
+
const { thinking: _thinking, ...next } = agent;
|
|
1395
|
+
return { ...next, override: agent.override ?? { ...meta, base: cloneOverrideBase(agent) } };
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function applyBuiltinOverrides(
|
|
1399
|
+
builtinAgents: AgentConfig[],
|
|
1400
|
+
userSettings: SubagentSettings,
|
|
1401
|
+
projectSettings: SubagentSettings,
|
|
1402
|
+
userSettingsPath: string,
|
|
1403
|
+
projectSettingsPath: string | null,
|
|
1404
|
+
): AgentConfig[] {
|
|
1405
|
+
const projectBulkDisabled = projectSettings.disableBuiltins === true && projectSettingsPath !== null;
|
|
1406
|
+
const userBulkDisabled = projectSettings.disableBuiltins === undefined && userSettings.disableBuiltins === true;
|
|
1407
|
+
const projectThinkingConfigured = projectSettings.disableThinking !== undefined && projectSettingsPath !== null;
|
|
1408
|
+
const disableThinking = projectThinkingConfigured ? projectSettings.disableThinking === true : userSettings.disableThinking === true;
|
|
1409
|
+
const disableThinkingMeta = projectThinkingConfigured
|
|
1410
|
+
? { scope: "project" as const, path: projectSettingsPath! }
|
|
1411
|
+
: { scope: "user" as const, path: userSettingsPath };
|
|
1412
|
+
|
|
1413
|
+
const applyGlobalThinking = (agent: AgentConfig, hasExplicitThinkingOverride: boolean): AgentConfig => {
|
|
1414
|
+
if (!disableThinking || hasExplicitThinkingOverride) return agent;
|
|
1415
|
+
return clearBuiltinThinking(agent, disableThinkingMeta);
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
return builtinAgents.map((agent) => {
|
|
1419
|
+
const projectOverride = projectSettings.overrides[agent.name];
|
|
1420
|
+
if (projectOverride && projectSettingsPath) {
|
|
1421
|
+
return applyGlobalThinking(
|
|
1422
|
+
applyBuiltinOverride(agent, projectOverride, { scope: "project", path: projectSettingsPath }),
|
|
1423
|
+
projectOverride.thinking !== undefined,
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
if (projectBulkDisabled && projectSettingsPath) {
|
|
1428
|
+
return applyGlobalThinking(
|
|
1429
|
+
applyBuiltinOverride(agent, { disabled: true }, { scope: "project", path: projectSettingsPath }),
|
|
1430
|
+
false,
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
const userOverride = userSettings.overrides[agent.name];
|
|
1435
|
+
if (userOverride) {
|
|
1436
|
+
return applyGlobalThinking(
|
|
1437
|
+
applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath }),
|
|
1438
|
+
!projectThinkingConfigured && userOverride.thinking !== undefined,
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
if (userBulkDisabled) {
|
|
1443
|
+
return applyGlobalThinking(
|
|
1444
|
+
applyBuiltinOverride(agent, { disabled: true }, { scope: "user", path: userSettingsPath }),
|
|
1445
|
+
false,
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
return applyGlobalThinking(agent, false);
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
export function agentHasFrontmatterField(agent: AgentConfig, ...fields: string[]): boolean {
|
|
1454
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1455
|
+
return frontmatterFields ? fields.some((field) => frontmatterFields.has(field)) : false;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
function applyCustomAgentOverride(
|
|
1459
|
+
agent: AgentConfig,
|
|
1460
|
+
override: BuiltinAgentOverrideConfig,
|
|
1461
|
+
meta: { scope: "user" | "project"; path: string },
|
|
1462
|
+
): AgentConfig {
|
|
1463
|
+
let next: AgentConfig | undefined;
|
|
1464
|
+
let anyFilled = false;
|
|
1465
|
+
|
|
1466
|
+
const mutable = (): AgentConfig => {
|
|
1467
|
+
next ??= { ...agent };
|
|
1468
|
+
return next;
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
const fill = <K extends keyof AgentConfig>(
|
|
1472
|
+
field: K,
|
|
1473
|
+
frontmatterFields: string[],
|
|
1474
|
+
value: AgentConfig[K],
|
|
1475
|
+
): void => {
|
|
1476
|
+
if (agentHasFrontmatterField(agent, ...frontmatterFields)) return;
|
|
1477
|
+
const target = mutable();
|
|
1478
|
+
if (value === undefined) delete target[field]; else target[field] = value;
|
|
1479
|
+
anyFilled = true;
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
if (override.description !== undefined) {
|
|
1483
|
+
mutable().description = override.description;
|
|
1484
|
+
anyFilled = true;
|
|
1485
|
+
}
|
|
1486
|
+
if (override.output !== undefined) {
|
|
1487
|
+
fill("output", ["output"], override.output === false ? undefined : override.output);
|
|
1488
|
+
}
|
|
1489
|
+
if (override.outputMode !== undefined) {
|
|
1490
|
+
fill("outputMode", ["outputMode"], override.outputMode);
|
|
1491
|
+
}
|
|
1492
|
+
if (override.defaultReads !== undefined) {
|
|
1493
|
+
fill("defaultReads", ["defaultReads"], override.defaultReads === false ? undefined : [...override.defaultReads]);
|
|
1494
|
+
}
|
|
1495
|
+
if (override.model !== undefined && !agentHasFrontmatterField(agent, "model")) {
|
|
1496
|
+
const target = mutable();
|
|
1497
|
+
if (override.model === false) delete target.model; else target.model = override.model;
|
|
1498
|
+
delete target.modelSource;
|
|
1499
|
+
anyFilled = true;
|
|
1500
|
+
}
|
|
1501
|
+
if (override.defaultProvider !== undefined) {
|
|
1502
|
+
fill("modelProvider", ["modelProvider", "defaultProvider"], override.defaultProvider === false ? undefined : override.defaultProvider);
|
|
1503
|
+
}
|
|
1504
|
+
if (override.fallbackModels !== undefined) {
|
|
1505
|
+
fill(
|
|
1506
|
+
"fallbackModels",
|
|
1507
|
+
["fallbackModels"],
|
|
1508
|
+
override.fallbackModels === false ? undefined : [...override.fallbackModels],
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
if (override.fast !== undefined) {
|
|
1512
|
+
fill("fast", ["fast"], override.fast);
|
|
1513
|
+
}
|
|
1514
|
+
if (override.thinking !== undefined) {
|
|
1515
|
+
fill("thinking", ["thinking"], override.thinking === false ? undefined : override.thinking);
|
|
1516
|
+
}
|
|
1517
|
+
if (override.systemPromptMode !== undefined) {
|
|
1518
|
+
fill("systemPromptMode", ["systemPromptMode"], override.systemPromptMode);
|
|
1519
|
+
}
|
|
1520
|
+
if (override.inheritProjectContext !== undefined) {
|
|
1521
|
+
fill("inheritProjectContext", ["inheritProjectContext"], override.inheritProjectContext);
|
|
1522
|
+
}
|
|
1523
|
+
if (override.inheritGlobalContext !== undefined) {
|
|
1524
|
+
fill("inheritGlobalContext", ["inheritGlobalContext"], override.inheritGlobalContext);
|
|
1525
|
+
}
|
|
1526
|
+
if (override.inheritSkills !== undefined) {
|
|
1527
|
+
fill("inheritSkills", ["inheritSkills"], override.inheritSkills);
|
|
1528
|
+
}
|
|
1529
|
+
if (override.defaultContext !== undefined) {
|
|
1530
|
+
fill("defaultContext", ["defaultContext"], override.defaultContext === false ? undefined : override.defaultContext);
|
|
1531
|
+
}
|
|
1532
|
+
if (override.acceptanceRole !== undefined) {
|
|
1533
|
+
fill("acceptanceRole", ["acceptanceRole"], override.acceptanceRole === false ? undefined : override.acceptanceRole);
|
|
1534
|
+
}
|
|
1535
|
+
if (override.disabled !== undefined) {
|
|
1536
|
+
// Custom agent files cannot set `disabled`, so project overrides replace user overrides.
|
|
1537
|
+
mutable().disabled = override.disabled;
|
|
1538
|
+
anyFilled = true;
|
|
1539
|
+
}
|
|
1540
|
+
if (override.skills !== undefined) {
|
|
1541
|
+
fill("skills", ["skill", "skills"], override.skills === false ? undefined : [...override.skills]);
|
|
1542
|
+
}
|
|
1543
|
+
if (override.tools !== undefined && !agentHasFrontmatterField(agent, "tools")) {
|
|
1544
|
+
applyToolsOverride(mutable(), override.tools);
|
|
1545
|
+
anyFilled = true;
|
|
1546
|
+
}
|
|
1547
|
+
if (override.excludeTools !== undefined) {
|
|
1548
|
+
fill("excludeTools", ["excludeTools"], override.excludeTools === false ? undefined : [...override.excludeTools]);
|
|
1549
|
+
}
|
|
1550
|
+
if (override.allowNestedSubagents !== undefined) {
|
|
1551
|
+
fill("allowNestedSubagents", ["allowNestedSubagents"], override.allowNestedSubagents);
|
|
1552
|
+
}
|
|
1553
|
+
if (override.extensions !== undefined) {
|
|
1554
|
+
fill("extensions", ["extensions"], override.extensions === false ? undefined : [...override.extensions]);
|
|
1555
|
+
}
|
|
1556
|
+
if (override.subagentOnlyExtensions !== undefined) {
|
|
1557
|
+
fill(
|
|
1558
|
+
"subagentOnlyExtensions",
|
|
1559
|
+
["subagentOnlyExtensions"],
|
|
1560
|
+
override.subagentOnlyExtensions === false ? undefined : [...override.subagentOnlyExtensions],
|
|
1561
|
+
);
|
|
1562
|
+
}
|
|
1563
|
+
if (override.mutationTools !== undefined) {
|
|
1564
|
+
fill("mutationTools", ["mutationTools"], override.mutationTools === false ? undefined : [...override.mutationTools]);
|
|
1565
|
+
}
|
|
1566
|
+
if (override.completionGuard !== undefined) {
|
|
1567
|
+
fill("completionGuard", ["completionGuard"], override.completionGuard);
|
|
1568
|
+
}
|
|
1569
|
+
if (override.toolBudget !== undefined) {
|
|
1570
|
+
fill("toolBudget", ["toolBudget"], override.toolBudget === false ? undefined : override.toolBudget);
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
if (!anyFilled || !next) return agent;
|
|
1574
|
+
next.override = { ...meta, base: agent.override?.base ?? cloneOverrideBase(agent) };
|
|
1575
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1576
|
+
if (frontmatterFields) agentFrontmatterFields.set(next, frontmatterFields);
|
|
1577
|
+
return next;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
function applyCustomAgentOverrides(
|
|
1581
|
+
agents: AgentConfig[],
|
|
1582
|
+
userSettings: SubagentSettings,
|
|
1583
|
+
projectSettings: SubagentSettings,
|
|
1584
|
+
userSettingsPath: string,
|
|
1585
|
+
projectSettingsPath: string | null,
|
|
1586
|
+
): AgentConfig[] {
|
|
1587
|
+
// Apply user then project so project fields win without dropping user-only fields.
|
|
1588
|
+
return agents.map((agent) => {
|
|
1589
|
+
const userOverride = userSettings.overrides[agent.name];
|
|
1590
|
+
const withUserOverride = userOverride
|
|
1591
|
+
? applyCustomAgentOverride(agent, userOverride, { scope: "user", path: userSettingsPath })
|
|
1592
|
+
: agent;
|
|
1593
|
+
|
|
1594
|
+
const projectOverride = projectSettings.overrides[agent.name];
|
|
1595
|
+
if (projectOverride && projectSettingsPath) {
|
|
1596
|
+
return applyCustomAgentOverride(withUserOverride, projectOverride, { scope: "project", path: projectSettingsPath });
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
return withUserOverride;
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
export function buildBuiltinOverrideConfig(
|
|
1604
|
+
base: BuiltinAgentOverrideBase,
|
|
1605
|
+
draft: Pick<AgentConfig, "model" | "modelProvider" | "fallbackModels" | "fast" | "thinking" | "systemPromptMode" | "inheritProjectContext" | "inheritGlobalContext" | "inheritSkills" | "defaultContext" | "acceptanceRole" | "disabled" | "systemPrompt" | "skills" | "tools" | "allowNestedSubagents" | "mcpDirectTools" | "extensions" | "subagentOnlyExtensions" | "mutationTools" | "completionGuard" | "toolBudget"> & Partial<Pick<AgentConfig, "description" | "output" | "outputMode" | "defaultReads" | "excludeTools">>,
|
|
1606
|
+
): BuiltinAgentOverrideConfig | undefined {
|
|
1607
|
+
const override: BuiltinAgentOverrideConfig = {};
|
|
1608
|
+
|
|
1609
|
+
if (draft.description !== undefined) {
|
|
1610
|
+
const description = draft.description.trim();
|
|
1611
|
+
if (description && description !== base.description) override.description = description;
|
|
1612
|
+
}
|
|
1613
|
+
if (draft.output !== base.output) override.output = draft.output ?? false;
|
|
1614
|
+
if (draft.outputMode !== undefined && draft.outputMode !== base.outputMode) override.outputMode = draft.outputMode;
|
|
1615
|
+
if (!arraysEqual(draft.defaultReads, base.defaultReads)) override.defaultReads = draft.defaultReads ? [...draft.defaultReads] : false;
|
|
1616
|
+
if (draft.model !== base.model) override.model = draft.model ?? false;
|
|
1617
|
+
if (draft.modelProvider !== base.modelProvider) override.defaultProvider = draft.modelProvider ?? false;
|
|
1618
|
+
if (!arraysEqual(draft.fallbackModels, base.fallbackModels)) override.fallbackModels = draft.fallbackModels ? [...draft.fallbackModels] : false;
|
|
1619
|
+
if (draft.fast !== base.fast) override.fast = draft.fast === true;
|
|
1620
|
+
if (draft.thinking !== base.thinking) override.thinking = draft.thinking ?? false;
|
|
1621
|
+
if (draft.systemPromptMode !== base.systemPromptMode) override.systemPromptMode = draft.systemPromptMode;
|
|
1622
|
+
if (draft.inheritProjectContext !== base.inheritProjectContext) override.inheritProjectContext = draft.inheritProjectContext;
|
|
1623
|
+
if (draft.inheritGlobalContext !== base.inheritGlobalContext) override.inheritGlobalContext = draft.inheritGlobalContext;
|
|
1624
|
+
if (draft.inheritSkills !== base.inheritSkills) override.inheritSkills = draft.inheritSkills;
|
|
1625
|
+
if (draft.defaultContext !== base.defaultContext) override.defaultContext = draft.defaultContext ?? false;
|
|
1626
|
+
if (draft.acceptanceRole !== base.acceptanceRole) override.acceptanceRole = draft.acceptanceRole ?? false;
|
|
1627
|
+
if (draft.disabled !== base.disabled) override.disabled = draft.disabled ?? false;
|
|
1628
|
+
if (draft.systemPrompt !== base.systemPrompt) override.systemPrompt = draft.systemPrompt;
|
|
1629
|
+
if (!arraysEqual(draft.skills, base.skills)) override.skills = draft.skills ? [...draft.skills] : false;
|
|
1630
|
+
|
|
1631
|
+
const baseTools = joinToolList(base);
|
|
1632
|
+
const draftTools = joinToolList(draft);
|
|
1633
|
+
if (!arraysEqual(draftTools, baseTools)) override.tools = draftTools ? [...draftTools] : false;
|
|
1634
|
+
if (!arraysEqual(draft.excludeTools, base.excludeTools)) override.excludeTools = draft.excludeTools ? [...draft.excludeTools] : false;
|
|
1635
|
+
if (draft.allowNestedSubagents !== base.allowNestedSubagents) override.allowNestedSubagents = draft.allowNestedSubagents === true;
|
|
1636
|
+
if (!arraysEqual(draft.extensions, base.extensions)) override.extensions = draft.extensions ? [...draft.extensions] : false;
|
|
1637
|
+
if (!arraysEqual(draft.subagentOnlyExtensions, base.subagentOnlyExtensions)) {
|
|
1638
|
+
override.subagentOnlyExtensions = draft.subagentOnlyExtensions ? [...draft.subagentOnlyExtensions] : false;
|
|
1639
|
+
}
|
|
1640
|
+
if (!arraysEqual(draft.mutationTools, base.mutationTools)) override.mutationTools = draft.mutationTools ? [...draft.mutationTools] : false;
|
|
1641
|
+
if ((draft.completionGuard !== false) !== (base.completionGuard !== false)) {
|
|
1642
|
+
override.completionGuard = draft.completionGuard !== false;
|
|
1643
|
+
}
|
|
1644
|
+
if (JSON.stringify(draft.toolBudget) !== JSON.stringify(base.toolBudget)) override.toolBudget = draft.toolBudget ?? false;
|
|
1645
|
+
|
|
1646
|
+
return Object.keys(override).length > 0 ? override : undefined;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
export function saveBuiltinAgentOverride(
|
|
1650
|
+
cwd: string,
|
|
1651
|
+
name: string,
|
|
1652
|
+
scope: "user" | "project",
|
|
1653
|
+
override: BuiltinAgentOverrideConfig,
|
|
1654
|
+
): string {
|
|
1655
|
+
const filePath = scope === "project" ? getProjectAgentSettingsPath(cwd) : getUserAgentSettingsPath();
|
|
1656
|
+
if (!filePath) throw new Error("Project override is not available here. No project config root was found.");
|
|
1657
|
+
|
|
1658
|
+
const settings = readSettingsFileStrict(filePath);
|
|
1659
|
+
const subagents = settings.subagents && typeof settings.subagents === "object" && !Array.isArray(settings.subagents)
|
|
1660
|
+
? { ...(settings.subagents as Record<string, unknown>) }
|
|
1661
|
+
: {};
|
|
1662
|
+
const agentOverrides = subagents.agentOverrides && typeof subagents.agentOverrides === "object" && !Array.isArray(subagents.agentOverrides)
|
|
1663
|
+
? { ...(subagents.agentOverrides as Record<string, unknown>) }
|
|
1664
|
+
: {};
|
|
1665
|
+
|
|
1666
|
+
agentOverrides[name] = cloneOverrideValue(override);
|
|
1667
|
+
subagents.agentOverrides = agentOverrides;
|
|
1668
|
+
settings.subagents = subagents;
|
|
1669
|
+
writeSettingsFile(filePath, settings);
|
|
1670
|
+
return filePath;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
export function removeBuiltinAgentOverride(cwd: string, name: string, scope: "user" | "project"): { path: string; removed: boolean } {
|
|
1674
|
+
const filePath = scope === "project" ? getProjectAgentSettingsPath(cwd) : getUserAgentSettingsPath();
|
|
1675
|
+
if (!filePath) throw new Error("Project override is not available here. No project config root was found.");
|
|
1676
|
+
if (!fs.existsSync(filePath)) return { path: filePath, removed: false };
|
|
1677
|
+
|
|
1678
|
+
const settings = readSettingsFileStrict(filePath);
|
|
1679
|
+
const subagents = settings.subagents;
|
|
1680
|
+
if (!subagents || typeof subagents !== "object" || Array.isArray(subagents)) return { path: filePath, removed: false };
|
|
1681
|
+
const nextSubagents = { ...(subagents as Record<string, unknown>) };
|
|
1682
|
+
const agentOverrides = nextSubagents.agentOverrides;
|
|
1683
|
+
if (!agentOverrides || typeof agentOverrides !== "object" || Array.isArray(agentOverrides)) return { path: filePath, removed: false };
|
|
1684
|
+
|
|
1685
|
+
const nextOverrides = { ...(agentOverrides as Record<string, unknown>) };
|
|
1686
|
+
if (!Object.prototype.hasOwnProperty.call(nextOverrides, name)) return { path: filePath, removed: false };
|
|
1687
|
+
delete nextOverrides[name];
|
|
1688
|
+
if (Object.keys(nextOverrides).length > 0) nextSubagents.agentOverrides = nextOverrides;
|
|
1689
|
+
else delete nextSubagents.agentOverrides;
|
|
1690
|
+
|
|
1691
|
+
if (Object.keys(nextSubagents).length > 0) settings.subagents = nextSubagents;
|
|
1692
|
+
else delete settings.subagents;
|
|
1693
|
+
|
|
1694
|
+
writeSettingsFile(filePath, settings);
|
|
1695
|
+
return { path: filePath, removed: true };
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
export function mergeBuiltinAgentOverride(
|
|
1699
|
+
cwd: string,
|
|
1700
|
+
name: string,
|
|
1701
|
+
scope: "user" | "project",
|
|
1702
|
+
fields: BuiltinAgentOverrideConfig,
|
|
1703
|
+
): string {
|
|
1704
|
+
const filePath = scope === "project" ? getProjectAgentSettingsPath(cwd) : getUserAgentSettingsPath();
|
|
1705
|
+
if (!filePath) throw new Error("Project override is not available here. No project config root was found.");
|
|
1706
|
+
|
|
1707
|
+
const settings = readSettingsFileStrict(filePath);
|
|
1708
|
+
const subagents = settings.subagents && typeof settings.subagents === "object" && !Array.isArray(settings.subagents)
|
|
1709
|
+
? { ...(settings.subagents as Record<string, unknown>) }
|
|
1710
|
+
: {};
|
|
1711
|
+
const agentOverrides = subagents.agentOverrides && typeof subagents.agentOverrides === "object" && !Array.isArray(subagents.agentOverrides)
|
|
1712
|
+
? { ...(subagents.agentOverrides as Record<string, unknown>) }
|
|
1713
|
+
: {};
|
|
1714
|
+
|
|
1715
|
+
const existing = agentOverrides[name];
|
|
1716
|
+
const base = existing && typeof existing === "object" && !Array.isArray(existing)
|
|
1717
|
+
? existing as Record<string, unknown>
|
|
1718
|
+
: {};
|
|
1719
|
+
agentOverrides[name] = { ...base, ...cloneOverrideValue(fields) };
|
|
1720
|
+
subagents.agentOverrides = agentOverrides;
|
|
1721
|
+
settings.subagents = subagents;
|
|
1722
|
+
writeSettingsFile(filePath, settings);
|
|
1723
|
+
return filePath;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
export function removeBuiltinAgentOverrideFields(
|
|
1727
|
+
cwd: string,
|
|
1728
|
+
name: string,
|
|
1729
|
+
scope: "user" | "project",
|
|
1730
|
+
fields: string[],
|
|
1731
|
+
): { path: string; removed: boolean } {
|
|
1732
|
+
const filePath = scope === "project" ? getProjectAgentSettingsPath(cwd) : getUserAgentSettingsPath();
|
|
1733
|
+
if (!filePath) throw new Error("Project override is not available here. No project config root was found.");
|
|
1734
|
+
if (!fs.existsSync(filePath)) return { path: filePath, removed: false };
|
|
1735
|
+
|
|
1736
|
+
const settings = readSettingsFileStrict(filePath);
|
|
1737
|
+
const subagents = settings.subagents;
|
|
1738
|
+
if (!subagents || typeof subagents !== "object" || Array.isArray(subagents)) return { path: filePath, removed: false };
|
|
1739
|
+
const agentOverrides = (subagents as Record<string, unknown>).agentOverrides;
|
|
1740
|
+
if (!agentOverrides || typeof agentOverrides !== "object" || Array.isArray(agentOverrides)) return { path: filePath, removed: false };
|
|
1741
|
+
|
|
1742
|
+
const entry = (agentOverrides as Record<string, unknown>)[name];
|
|
1743
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return { path: filePath, removed: false };
|
|
1744
|
+
|
|
1745
|
+
const nextEntry: Record<string, unknown> = { ...(entry as Record<string, unknown>) };
|
|
1746
|
+
let removed = false;
|
|
1747
|
+
for (const field of fields) {
|
|
1748
|
+
if (Object.prototype.hasOwnProperty.call(nextEntry, field)) {
|
|
1749
|
+
delete nextEntry[field];
|
|
1750
|
+
removed = true;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
if (!removed) return { path: filePath, removed: false };
|
|
1754
|
+
|
|
1755
|
+
const nextSubagents = { ...(subagents as Record<string, unknown>) };
|
|
1756
|
+
if (Object.keys(nextEntry).length > 0) {
|
|
1757
|
+
(nextSubagents.agentOverrides as Record<string, unknown>)[name] = nextEntry;
|
|
1758
|
+
} else {
|
|
1759
|
+
const nextOverrides = { ...(agentOverrides as Record<string, unknown>) };
|
|
1760
|
+
delete nextOverrides[name];
|
|
1761
|
+
if (Object.keys(nextOverrides).length > 0) nextSubagents.agentOverrides = nextOverrides;
|
|
1762
|
+
else delete nextSubagents.agentOverrides;
|
|
1763
|
+
}
|
|
1764
|
+
if (Object.keys(nextSubagents).length > 0) settings.subagents = nextSubagents;
|
|
1765
|
+
else delete settings.subagents;
|
|
1766
|
+
writeSettingsFile(filePath, settings);
|
|
1767
|
+
return { path: filePath, removed: true };
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
const DISCOVERY_PRUNED_DIR_NAMES = new Set([".git", "node_modules", ".pi", "sync-backups"]);
|
|
1771
|
+
|
|
1772
|
+
function isDiscoveryNestedProjectRoot(dir: string): boolean {
|
|
1773
|
+
return isDirectory(getProjectConfigDir(dir)) || isDirectory(path.join(dir, ".agents"));
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
function shouldPruneDiscoveryDir(rootDir: string, dir: string, dirName: string): boolean {
|
|
1777
|
+
if (DISCOVERY_PRUNED_DIR_NAMES.has(dirName)) return true;
|
|
1778
|
+
if (fs.existsSync(path.join(dir, ".git"))) return true;
|
|
1779
|
+
return path.resolve(dir) !== path.resolve(rootDir) && isDiscoveryNestedProjectRoot(dir);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
function listFilesRecursive(
|
|
1783
|
+
dir: string,
|
|
1784
|
+
predicate: (fileName: string) => boolean,
|
|
1785
|
+
rootDir = dir,
|
|
1786
|
+
visitedDirectories = new Set<string>(),
|
|
1787
|
+
inspectedDirectories = new Set<string>(),
|
|
1788
|
+
): string[] {
|
|
1789
|
+
const files: string[] = [];
|
|
1790
|
+
if (!fs.existsSync(dir)) return files;
|
|
1791
|
+
inspectedDirectories.add(path.resolve(dir));
|
|
1792
|
+
let realDir: string;
|
|
1793
|
+
try {
|
|
1794
|
+
realDir = fs.realpathSync(dir);
|
|
1795
|
+
} catch {
|
|
1796
|
+
return files;
|
|
1797
|
+
}
|
|
1798
|
+
if (visitedDirectories.has(realDir)) return files;
|
|
1799
|
+
visitedDirectories.add(realDir);
|
|
1800
|
+
|
|
1801
|
+
let entries: fs.Dirent[];
|
|
1802
|
+
try {
|
|
1803
|
+
entries = fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
1804
|
+
} catch {
|
|
1805
|
+
return files;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
for (const entry of entries) {
|
|
1809
|
+
const filePath = path.join(dir, entry.name);
|
|
1810
|
+
let isDirectory = entry.isDirectory();
|
|
1811
|
+
if (entry.isSymbolicLink()) {
|
|
1812
|
+
try {
|
|
1813
|
+
isDirectory = fs.statSync(filePath).isDirectory();
|
|
1814
|
+
} catch {
|
|
1815
|
+
isDirectory = false;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (isDirectory) {
|
|
1819
|
+
if (!shouldPruneDiscoveryDir(rootDir, filePath, entry.name)) {
|
|
1820
|
+
files.push(...listFilesRecursive(filePath, predicate, rootDir, visitedDirectories, inspectedDirectories));
|
|
1821
|
+
}
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
|
|
1825
|
+
if (!predicate(entry.name)) continue;
|
|
1826
|
+
files.push(filePath);
|
|
1827
|
+
}
|
|
1828
|
+
return files;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
export interface AgentDefinitionInspection {
|
|
1832
|
+
files: string[];
|
|
1833
|
+
state: AgentDefinitionDirectoryState;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
const agentDefinitionInspectionDirectories = new WeakMap<AgentDefinitionInspection, string[]>();
|
|
1837
|
+
|
|
1838
|
+
function rememberAgentDefinitionInspection(inspection: AgentDefinitionInspection, directories: Iterable<string>): AgentDefinitionInspection {
|
|
1839
|
+
agentDefinitionInspectionDirectories.set(inspection, [...new Set([...directories].map((directory) => path.resolve(directory)))]);
|
|
1840
|
+
return inspection;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
function inspectedAgentDefinitionDirectories(inspection: AgentDefinitionInspection, root: string): string[] {
|
|
1844
|
+
return agentDefinitionInspectionDirectories.get(inspection) ?? [path.resolve(root)];
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
/** Narrow filesystem seam so unavailable paths can be tested without permissions. */
|
|
1848
|
+
export interface AgentDefinitionInspectionFs {
|
|
1849
|
+
existsSync(filePath: string): boolean;
|
|
1850
|
+
realpathSync?(filePath: string): string;
|
|
1851
|
+
statSync(filePath: string): { isDirectory(): boolean };
|
|
1852
|
+
readdirSync(dir: string): fs.Dirent[];
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
const DEFAULT_AGENT_DEFINITION_INSPECTION_FS: AgentDefinitionInspectionFs = {
|
|
1856
|
+
existsSync: fs.existsSync,
|
|
1857
|
+
realpathSync: fs.realpathSync,
|
|
1858
|
+
statSync: fs.statSync,
|
|
1859
|
+
readdirSync: (dir) => fs.readdirSync(dir, { withFileTypes: true }),
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
* Inspect one agent-definition directory while retaining traversal failure
|
|
1864
|
+
* state. A nested unreadable directory makes the whole inspection unavailable,
|
|
1865
|
+
* preventing a partial traversal from being reported as empty or complete.
|
|
1866
|
+
*/
|
|
1867
|
+
export function inspectAgentDefinitionDirectory(dir: string, operations: AgentDefinitionInspectionFs = DEFAULT_AGENT_DEFINITION_INSPECTION_FS): AgentDefinitionInspection {
|
|
1868
|
+
const root = path.resolve(dir);
|
|
1869
|
+
try {
|
|
1870
|
+
if (!operations.existsSync(root)) return rememberAgentDefinitionInspection({ files: [], state: "absent" }, [root]);
|
|
1871
|
+
if (!operations.statSync(root).isDirectory()) return rememberAgentDefinitionInspection({ files: [], state: "not-directory" }, [root]);
|
|
1872
|
+
} catch {
|
|
1873
|
+
return rememberAgentDefinitionInspection({ files: [], state: "unreadable" }, [root]);
|
|
1874
|
+
}
|
|
1875
|
+
const files: string[] = [];
|
|
1876
|
+
let unreadable = false;
|
|
1877
|
+
const visitedDirectories = new Set<string>();
|
|
1878
|
+
const inspectedDirectories = new Set<string>();
|
|
1879
|
+
const visit = (current: string): void => {
|
|
1880
|
+
inspectedDirectories.add(path.resolve(current));
|
|
1881
|
+
let realDir: string;
|
|
1882
|
+
try {
|
|
1883
|
+
realDir = operations.realpathSync?.(current) ?? path.resolve(current);
|
|
1884
|
+
} catch {
|
|
1885
|
+
unreadable = true;
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1888
|
+
if (visitedDirectories.has(realDir)) return;
|
|
1889
|
+
visitedDirectories.add(realDir);
|
|
1890
|
+
|
|
1891
|
+
let entries: fs.Dirent[];
|
|
1892
|
+
try {
|
|
1893
|
+
entries = operations.readdirSync(current).sort((a, b) => a.name.localeCompare(b.name));
|
|
1894
|
+
} catch {
|
|
1895
|
+
unreadable = true;
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
for (const entry of entries) {
|
|
1899
|
+
const filePath = path.join(current, entry.name);
|
|
1900
|
+
let isDirectory = entry.isDirectory();
|
|
1901
|
+
if (entry.isSymbolicLink()) {
|
|
1902
|
+
try {
|
|
1903
|
+
isDirectory = operations.statSync(filePath).isDirectory();
|
|
1904
|
+
} catch {
|
|
1905
|
+
isDirectory = false;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
if (isDirectory) {
|
|
1909
|
+
if (!shouldPruneDiscoveryDir(root, filePath, entry.name)) visit(filePath);
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
if ((entry.isFile() || entry.isSymbolicLink()) && entry.name.endsWith(".md") && !entry.name.endsWith(".chain.md") && !isLegacyAgentSkillPath(root, filePath)) files.push(filePath);
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
visit(root);
|
|
1916
|
+
return rememberAgentDefinitionInspection({ files, state: unreadable ? "unreadable" : files.length ? "candidates" : "empty" }, inspectedDirectories);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
function isLegacyAgentSkillPath(rootDir: string, filePath: string): boolean {
|
|
1920
|
+
const relative = path.relative(rootDir, filePath);
|
|
1921
|
+
const parts = relative.split(path.sep).map((part) => part.toLowerCase());
|
|
1922
|
+
if (path.basename(rootDir).toLowerCase() === ".agents") {
|
|
1923
|
+
parts.unshift(".agents");
|
|
1924
|
+
}
|
|
1925
|
+
return parts.some((part, index) => part === ".agents" && parts[index + 1] === "skills");
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
function isJsonSerializable(value: unknown): boolean {
|
|
1929
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
1930
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
1931
|
+
if (Array.isArray(value)) return value.every(isJsonSerializable);
|
|
1932
|
+
if (value && typeof value === "object") return Object.values(value).every(isJsonSerializable);
|
|
1933
|
+
return false;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
function parseAgentRunnerFrontmatter(raw: string | undefined, agentName: string): AgentRunnerConfig | undefined {
|
|
1937
|
+
if (raw === undefined || !raw.trim()) return undefined;
|
|
1938
|
+
let parsed: unknown;
|
|
1939
|
+
try {
|
|
1940
|
+
parsed = parseYaml(raw);
|
|
1941
|
+
} catch (error) {
|
|
1942
|
+
throw new Error(`Agent '${agentName}' has invalid runner frontmatter: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
1943
|
+
}
|
|
1944
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1945
|
+
throw new Error(`Agent '${agentName}' has invalid runner frontmatter; expected an object.`);
|
|
1946
|
+
}
|
|
1947
|
+
const runner = parsed as Record<string, unknown>;
|
|
1948
|
+
if (runner.type === "pi") {
|
|
1949
|
+
if (Object.keys(runner).some((key) => key !== "type")) throw new Error(`Agent '${agentName}' has invalid Pi runner frontmatter; only 'type' is supported.`);
|
|
1950
|
+
return { type: "pi" };
|
|
1951
|
+
}
|
|
1952
|
+
if (runner.type === "external-job") {
|
|
1953
|
+
if (typeof runner.provider !== "string" || !runner.provider.trim() || runner.provider.trim() !== runner.provider) {
|
|
1954
|
+
throw new Error(`Agent '${agentName}' external-job runner requires a non-empty trimmed provider string.`);
|
|
1955
|
+
}
|
|
1956
|
+
if (runner.options !== undefined && (!runner.options || typeof runner.options !== "object" || Array.isArray(runner.options) || !isJsonSerializable(runner.options))) {
|
|
1957
|
+
throw new Error(`Agent '${agentName}' external-job runner options must be a JSON-serializable object.`);
|
|
1958
|
+
}
|
|
1959
|
+
const supported = new Set(["type", "provider", "options"]);
|
|
1960
|
+
const unknown = Object.keys(runner).filter((key) => !supported.has(key));
|
|
1961
|
+
if (unknown.length > 0) throw new Error(`Agent '${agentName}' external-job runner has unsupported fields: ${unknown.join(", ")}.`);
|
|
1962
|
+
return {
|
|
1963
|
+
type: "external-job",
|
|
1964
|
+
provider: runner.provider,
|
|
1965
|
+
...(runner.options ? { options: runner.options as Record<string, unknown> } : {}),
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
if (runner.type !== "external-cli") {
|
|
1969
|
+
throw new Error(`Agent '${agentName}' has invalid runner.type; expected 'pi', 'external-cli', or 'external-job'.`);
|
|
1970
|
+
}
|
|
1971
|
+
if (typeof runner.command !== "string" || !runner.command.trim()) {
|
|
1972
|
+
throw new Error(`Agent '${agentName}' external-cli runner requires a non-empty command string.`);
|
|
1973
|
+
}
|
|
1974
|
+
if (runner.args !== undefined && (!Array.isArray(runner.args) || runner.args.some((arg) => typeof arg !== "string"))) {
|
|
1975
|
+
throw new Error(`Agent '${agentName}' external-cli runner args must be an array of strings.`);
|
|
1976
|
+
}
|
|
1977
|
+
if (runner.adapter !== undefined && !isCodeOwnedExternalCliAdapterId(runner.adapter)) throw new Error(`Agent '${agentName}' external-cli runner adapter must be ${CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL}.`);
|
|
1978
|
+
if (runner.adapter !== undefined && Array.isArray(runner.args) && runner.args.length > 0) throw new Error(`Agent '${agentName}' ${runner.adapter} adapter owns its argv; runner args are not supported.`);
|
|
1979
|
+
if (runner.promptDelivery !== undefined && runner.promptDelivery !== "stdin") {
|
|
1980
|
+
throw new Error(`Agent '${agentName}' external-cli runner promptDelivery must be 'stdin'.`);
|
|
1981
|
+
}
|
|
1982
|
+
const capabilities = parseExternalCliCapabilityNarrowing(runner.capabilities, `Agent '${agentName}' external-cli runner capabilities`);
|
|
1983
|
+
const supported = new Set(["type", "adapter", "command", "args", "promptDelivery", "capabilities"]);
|
|
1984
|
+
const unknown = Object.keys(runner).filter((key) => !supported.has(key));
|
|
1985
|
+
if (unknown.length > 0) throw new Error(`Agent '${agentName}' external-cli runner has unsupported fields: ${unknown.join(", ")}.`);
|
|
1986
|
+
const runnerArgs = Array.isArray(runner.args) ? runner.args.filter((arg): arg is string => typeof arg === "string") : undefined;
|
|
1987
|
+
return {
|
|
1988
|
+
type: "external-cli",
|
|
1989
|
+
...(isCodeOwnedExternalCliAdapterId(runner.adapter) ? { adapter: runner.adapter } : {}),
|
|
1990
|
+
command: runner.command.trim(),
|
|
1991
|
+
...(runnerArgs?.length ? { args: runnerArgs } : {}),
|
|
1992
|
+
...(runner.promptDelivery ? { promptDelivery: "stdin" as const } : {}),
|
|
1993
|
+
...(capabilities ? { capabilities } : {}),
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
function validateExternalRunnerProfile(frontmatter: Record<string, string>, agentName: string, runner: AgentRunnerConfig | undefined): void {
|
|
1998
|
+
if (runner?.type !== "external-cli" && runner?.type !== "external-job") return;
|
|
1999
|
+
const unsupported = ["tools", "excludeTools", "allowNestedSubagents", "model", "fallbackModels", "thinking", "extensions", "subagentOnlyExtensions", "mutationTools", "maxSubagentDepth", "completionGuard", "skills", "skill", "skillPath", "toolBudget", "permission", "permissions"]
|
|
2000
|
+
.filter((field) => frontmatter[field] !== undefined);
|
|
2001
|
+
if (unsupported.length > 0) {
|
|
2002
|
+
throw new Error(`Agent '${agentName}' uses runner.type='${runner.type}' and declares unsupported Pi-only fields: ${unsupported.join(", ")}.`);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
function parseAgentAcceptanceFrontmatter(raw: string | undefined, agentName: string): AcceptanceInput | undefined {
|
|
2007
|
+
if (raw === undefined || !raw.trim()) return undefined;
|
|
2008
|
+
let parsed: unknown;
|
|
2009
|
+
try {
|
|
2010
|
+
parsed = parseYaml(raw);
|
|
2011
|
+
} catch (error) {
|
|
2012
|
+
throw new Error(`Agent '${agentName}' has invalid acceptance frontmatter: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
2013
|
+
}
|
|
2014
|
+
const errors = validateAcceptanceInput(parsed, `Agent '${agentName}' acceptance frontmatter`);
|
|
2015
|
+
if (errors.length > 0) throw new Error(errors.join(" "));
|
|
2016
|
+
return parsed as AcceptanceInput;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
interface AgentDefinitionFile {
|
|
2020
|
+
filePath: string;
|
|
2021
|
+
content: string;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
function readAgentDefinitionFiles(dir: string, inspection = inspectAgentDefinitionDirectory(dir)): AgentDefinitionFile[] {
|
|
2025
|
+
const files: AgentDefinitionFile[] = [];
|
|
2026
|
+
for (const filePath of inspection.files) {
|
|
2027
|
+
if (isLegacyAgentSkillPath(dir, filePath)) {
|
|
2028
|
+
continue;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
try {
|
|
2032
|
+
files.push({ filePath, content: fs.readFileSync(filePath, "utf-8") });
|
|
2033
|
+
} catch {
|
|
2034
|
+
continue;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
return files;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
function resolveAgentRelativeExtensionPaths(paths: string[] | undefined, agentFilePath: string): string[] | undefined {
|
|
2041
|
+
if (paths === undefined) return undefined;
|
|
2042
|
+
const baseDir = path.dirname(agentFilePath);
|
|
2043
|
+
return paths.map((entry) => {
|
|
2044
|
+
const trimmed = entry.trim();
|
|
2045
|
+
if (trimmed === "." || trimmed === ".." || trimmed.startsWith("./") || trimmed.startsWith("../")) {
|
|
2046
|
+
return path.resolve(baseDir, trimmed);
|
|
2047
|
+
}
|
|
2048
|
+
return entry;
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
function loadAgentsFromDefinitionFiles(files: AgentDefinitionFile[], source: AgentSource, discoveryPriority?: number, packageSource?: Omit<PackageSubagentPath, "dir" | "scope">): { agents: AgentConfig[]; diagnostics: AgentDiscoveryDiagnostic[] } {
|
|
2053
|
+
const agents: AgentConfig[] = [];
|
|
2054
|
+
const diagnostics: AgentDiscoveryDiagnostic[] = [];
|
|
2055
|
+
|
|
2056
|
+
for (const { filePath, content } of files) {
|
|
2057
|
+
let name: string | undefined;
|
|
2058
|
+
let runtimeName: string | undefined;
|
|
2059
|
+
let packageSpecified = false;
|
|
2060
|
+
try {
|
|
2061
|
+
const { frontmatter, body } = parseFrontmatter(content);
|
|
2062
|
+
|
|
2063
|
+
if (!frontmatter.name || !frontmatter.description) {
|
|
2064
|
+
continue;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
const localName = frontmatter.name;
|
|
2068
|
+
name = localName;
|
|
2069
|
+
const parsedPackage = parsePackageName(frontmatter.package, `Agent '${localName}' package`);
|
|
2070
|
+
packageSpecified = parsedPackage.packageName !== undefined || parsedPackage.error !== undefined;
|
|
2071
|
+
if (parsedPackage.error) throw new Error(parsedPackage.error);
|
|
2072
|
+
const packageName = parsedPackage.packageName;
|
|
2073
|
+
runtimeName = buildRuntimeName(localName, packageName);
|
|
2074
|
+
|
|
2075
|
+
const runner = parseAgentRunnerFrontmatter(frontmatter.runner, localName);
|
|
2076
|
+
validateExternalRunnerProfile(frontmatter, localName, runner);
|
|
2077
|
+
const rawTools = parseFrontmatterList(frontmatter.tools);
|
|
2078
|
+
const parsedTools = splitToolList(rawTools);
|
|
2079
|
+
const tools = parsedTools.tools ?? [];
|
|
2080
|
+
const mcpDirectTools = parsedTools.mcpDirectTools ?? [];
|
|
2081
|
+
const excludeTools = parseFrontmatterList(frontmatter.excludeTools);
|
|
2082
|
+
const defaultReads = parseFrontmatterList(frontmatter.defaultReads);
|
|
2083
|
+
const aliases = normalizeAgentAliases(parseFrontmatterList(frontmatter.aliases ?? frontmatter.alias), runtimeName);
|
|
2084
|
+
const profileError = validateCodeOwnedProfileRunner({ name: runtimeName, localName, aliases, runner });
|
|
2085
|
+
if (profileError) throw new Error(profileError);
|
|
2086
|
+
const skillStr = frontmatter.skill || frontmatter.skills;
|
|
2087
|
+
const skills = parseFrontmatterList(skillStr);
|
|
2088
|
+
const skillPath = parseFrontmatterList(frontmatter.skillPath);
|
|
2089
|
+
const fallbackModels = parseFrontmatterList(frontmatter.fallbackModels);
|
|
2090
|
+
const systemPromptMode = frontmatter.systemPromptMode === "replace"
|
|
2091
|
+
? "replace"
|
|
2092
|
+
: frontmatter.systemPromptMode === "append"
|
|
2093
|
+
? "append"
|
|
2094
|
+
: defaultSystemPromptMode(localName);
|
|
2095
|
+
const inheritProjectContext = frontmatter.inheritProjectContext === "true"
|
|
2096
|
+
? true
|
|
2097
|
+
: frontmatter.inheritProjectContext === "false"
|
|
2098
|
+
? false
|
|
2099
|
+
: defaultInheritProjectContext(localName);
|
|
2100
|
+
const inheritGlobalContext = frontmatter.inheritGlobalContext === "true";
|
|
2101
|
+
const inheritSkills = frontmatter.inheritSkills === "true"
|
|
2102
|
+
? true
|
|
2103
|
+
: frontmatter.inheritSkills === "false"
|
|
2104
|
+
? false
|
|
2105
|
+
: defaultInheritSkills();
|
|
2106
|
+
const defaultContext = frontmatter.defaultContext === "fork"
|
|
2107
|
+
? "fork" as const
|
|
2108
|
+
: frontmatter.defaultContext === "fresh"
|
|
2109
|
+
? "fresh" as const
|
|
2110
|
+
: undefined;
|
|
2111
|
+
let defaultAsync: boolean | undefined;
|
|
2112
|
+
if (frontmatter.async !== undefined) {
|
|
2113
|
+
if (frontmatter.async === "true") defaultAsync = true;
|
|
2114
|
+
else if (frontmatter.async === "false") defaultAsync = false;
|
|
2115
|
+
else throw new Error(`Agent '${localName}' has invalid async frontmatter; expected true or false.`);
|
|
2116
|
+
}
|
|
2117
|
+
let defaultTimeoutMs: number | undefined;
|
|
2118
|
+
if (frontmatter.timeoutMs !== undefined) {
|
|
2119
|
+
const parsed = Number(frontmatter.timeoutMs);
|
|
2120
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
2121
|
+
throw new Error(`Agent '${localName}' has invalid timeoutMs frontmatter; expected a positive integer.`);
|
|
2122
|
+
}
|
|
2123
|
+
defaultTimeoutMs = parsed;
|
|
2124
|
+
}
|
|
2125
|
+
let defaultToolTimeoutMs: number | undefined;
|
|
2126
|
+
if (frontmatter.toolTimeoutMs !== undefined) {
|
|
2127
|
+
const parsed = Number(frontmatter.toolTimeoutMs);
|
|
2128
|
+
if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 2_147_483_647) {
|
|
2129
|
+
throw new Error(`Agent '${localName}' has invalid toolTimeoutMs frontmatter; expected a positive integer no larger than 2147483647.`);
|
|
2130
|
+
}
|
|
2131
|
+
defaultToolTimeoutMs = parsed;
|
|
2132
|
+
}
|
|
2133
|
+
const defaultAcceptance = parseAgentAcceptanceFrontmatter(frontmatter.acceptance, localName);
|
|
2134
|
+
let outputMode: OutputMode | undefined;
|
|
2135
|
+
if (frontmatter.outputMode !== undefined) {
|
|
2136
|
+
if (frontmatter.outputMode === "inline" || frontmatter.outputMode === "file-only") outputMode = frontmatter.outputMode;
|
|
2137
|
+
else throw new Error(`Agent '${localName}' has invalid outputMode frontmatter; expected 'inline' or 'file-only'.`);
|
|
2138
|
+
}
|
|
2139
|
+
let acceptanceRole: AcceptanceRole | undefined;
|
|
2140
|
+
if (frontmatter.acceptanceRole !== undefined && frontmatter.acceptanceRole.trim()) {
|
|
2141
|
+
if (frontmatter.acceptanceRole === "read-only" || frontmatter.acceptanceRole === "writer") acceptanceRole = frontmatter.acceptanceRole;
|
|
2142
|
+
else throw new Error(`Agent '${localName}' has invalid acceptanceRole frontmatter; expected 'read-only' or 'writer'.`);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
const extensions = resolveAgentRelativeExtensionPaths(parseFrontmatterList(frontmatter.extensions), filePath);
|
|
2146
|
+
const subagentOnlyExtensions = resolveAgentRelativeExtensionPaths(parseFrontmatterList(frontmatter.subagentOnlyExtensions), filePath);
|
|
2147
|
+
const mutationTools = parseFrontmatterList(frontmatter.mutationTools);
|
|
2148
|
+
let fast: boolean | undefined;
|
|
2149
|
+
if (frontmatter.fast !== undefined) {
|
|
2150
|
+
if (frontmatter.fast === "true") fast = true;
|
|
2151
|
+
else if (frontmatter.fast === "false") fast = false;
|
|
2152
|
+
else throw new Error(`Agent '${localName}' has invalid fast frontmatter; expected true or false.`);
|
|
2153
|
+
}
|
|
2154
|
+
let allowNestedSubagents: boolean | undefined;
|
|
2155
|
+
if (frontmatter.allowNestedSubagents !== undefined) {
|
|
2156
|
+
if (frontmatter.allowNestedSubagents === "true") allowNestedSubagents = true;
|
|
2157
|
+
else if (frontmatter.allowNestedSubagents === "false") allowNestedSubagents = false;
|
|
2158
|
+
else throw new Error(`Agent '${localName}' has invalid allowNestedSubagents frontmatter; expected true or false.`);
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
const extraFields: Record<string, string> = {};
|
|
2162
|
+
for (const [key, value] of Object.entries(frontmatter)) {
|
|
2163
|
+
if (!KNOWN_FIELDS.has(key)) extraFields[key] = value;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
const parsedMaxSubagentDepth = Number(frontmatter.maxSubagentDepth);
|
|
2167
|
+
if (frontmatter.permission !== undefined && frontmatter.permissions !== undefined) {
|
|
2168
|
+
throw new Error(`Agent '${localName}' cannot declare both permission and permissions frontmatter.`);
|
|
2169
|
+
}
|
|
2170
|
+
const permissionSource = frontmatter.permissions ?? frontmatter.permission;
|
|
2171
|
+
const permissions = permissionSource?.trim()
|
|
2172
|
+
? validatePermissionRules(parseYaml(permissionSource), `Agent '${localName}' permissions`)
|
|
2173
|
+
: undefined;
|
|
2174
|
+
let toolBudget: ToolBudgetConfig | undefined;
|
|
2175
|
+
if (frontmatter.toolBudget !== undefined && frontmatter.toolBudget.trim()) {
|
|
2176
|
+
const parsed = JSON.parse(frontmatter.toolBudget) as unknown;
|
|
2177
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2178
|
+
throw new Error(`Agent '${localName}' has invalid toolBudget frontmatter; expected a JSON object.`);
|
|
2179
|
+
}
|
|
2180
|
+
toolBudget = parsed as ToolBudgetConfig;
|
|
2181
|
+
}
|
|
2182
|
+
const completionGuard = frontmatter.completionGuard === "false"
|
|
2183
|
+
? false
|
|
2184
|
+
: frontmatter.completionGuard === "true"
|
|
2185
|
+
? true
|
|
2186
|
+
: undefined;
|
|
2187
|
+
|
|
2188
|
+
const maxSubagentDepth = Number.isInteger(parsedMaxSubagentDepth) && parsedMaxSubagentDepth >= 0
|
|
2189
|
+
? parsedMaxSubagentDepth
|
|
2190
|
+
: undefined;
|
|
2191
|
+
const memory = parseMemoryFrontmatter(frontmatter.memory);
|
|
2192
|
+
const agent: AgentConfig = {
|
|
2193
|
+
name: runtimeName,
|
|
2194
|
+
...(runner !== undefined ? { runner } : {}),
|
|
2195
|
+
localName,
|
|
2196
|
+
...(packageName !== undefined ? { packageName } : {}),
|
|
2197
|
+
...(packageSource?.packageName ? { packageSourceName: packageSource.packageName } : {}),
|
|
2198
|
+
...(packageSource?.packageVersion ? { packageSourceVersion: packageSource.packageVersion } : {}),
|
|
2199
|
+
...(packageSource?.packageRoot ? { packageSourceRoot: packageSource.packageRoot } : {}),
|
|
2200
|
+
description: frontmatter.description,
|
|
2201
|
+
...(aliases !== undefined ? { aliases } : {}),
|
|
2202
|
+
...(rawTools !== undefined ? { tools } : {}),
|
|
2203
|
+
...(excludeTools !== undefined ? { excludeTools } : {}),
|
|
2204
|
+
...(allowNestedSubagents !== undefined ? { allowNestedSubagents } : {}),
|
|
2205
|
+
...(mcpDirectTools.length > 0 ? { mcpDirectTools } : {}),
|
|
2206
|
+
...(frontmatter.model !== undefined ? { model: frontmatter.model } : {}),
|
|
2207
|
+
...(fallbackModels?.length ? { fallbackModels } : {}),
|
|
2208
|
+
...(fast !== undefined ? { fast } : {}),
|
|
2209
|
+
...(frontmatter.thinking !== undefined ? { thinking: frontmatter.thinking === "false" ? false : frontmatter.thinking } : {}),
|
|
2210
|
+
systemPromptMode,
|
|
2211
|
+
inheritProjectContext,
|
|
2212
|
+
inheritGlobalContext,
|
|
2213
|
+
inheritSkills,
|
|
2214
|
+
...(defaultContext !== undefined ? { defaultContext } : {}),
|
|
2215
|
+
...(defaultAsync !== undefined ? { defaultAsync } : {}),
|
|
2216
|
+
...(defaultTimeoutMs !== undefined ? { defaultTimeoutMs } : {}),
|
|
2217
|
+
...(defaultToolTimeoutMs !== undefined ? { defaultToolTimeoutMs } : {}),
|
|
2218
|
+
...(defaultAcceptance !== undefined ? { defaultAcceptance } : {}),
|
|
2219
|
+
...(acceptanceRole !== undefined ? { acceptanceRole } : {}),
|
|
2220
|
+
systemPrompt: body,
|
|
2221
|
+
source,
|
|
2222
|
+
filePath,
|
|
2223
|
+
...(discoveryPriority !== undefined ? { discoveryPriority } : {}),
|
|
2224
|
+
...(skills?.length ? { skills } : {}),
|
|
2225
|
+
...(skillPath?.length ? { skillPath } : {}),
|
|
2226
|
+
...(extensions !== undefined ? { extensions } : {}),
|
|
2227
|
+
...(subagentOnlyExtensions !== undefined ? { subagentOnlyExtensions } : {}),
|
|
2228
|
+
...(mutationTools?.length ? { mutationTools } : {}),
|
|
2229
|
+
...(frontmatter.output !== undefined ? { output: frontmatter.output } : {}),
|
|
2230
|
+
...(outputMode !== undefined ? { outputMode } : {}),
|
|
2231
|
+
...(defaultReads?.length ? { defaultReads } : {}),
|
|
2232
|
+
defaultProgress: frontmatter.defaultProgress === "true",
|
|
2233
|
+
interactive: frontmatter.interactive === "true",
|
|
2234
|
+
...(maxSubagentDepth !== undefined ? { maxSubagentDepth } : {}),
|
|
2235
|
+
...(completionGuard !== undefined ? { completionGuard } : {}),
|
|
2236
|
+
...(toolBudget !== undefined ? { toolBudget } : {}),
|
|
2237
|
+
...(permissions !== undefined ? { permissions } : {}),
|
|
2238
|
+
...(memory !== undefined ? { memory } : {}),
|
|
2239
|
+
...(Object.keys(extraFields).length > 0 ? { extraFields } : {}),
|
|
2240
|
+
};
|
|
2241
|
+
agentFrontmatterFields.set(agent, new Set(Object.keys(frontmatter)));
|
|
2242
|
+
agents.push(agent);
|
|
2243
|
+
} catch (error) {
|
|
2244
|
+
diagnostics.push({ source, filePath, ...(name ? { name } : {}), ...(runtimeName && runtimeName !== name ? { runtimeName } : {}), ...(packageSpecified ? { packageSpecified: true } : {}), ...(discoveryPriority !== undefined ? { discoveryPriority } : {}), error: error instanceof Error ? error.message : String(error) });
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
return { agents, diagnostics };
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
function loadAgentsFromDir(dir: string, source: AgentSource, discoveryPriority?: number, packageSource?: Omit<PackageSubagentPath, "dir" | "scope">, inspection = inspectAgentDefinitionDirectory(dir)): { agents: AgentConfig[]; diagnostics: AgentDiscoveryDiagnostic[] } {
|
|
2252
|
+
return loadAgentsFromDefinitionFiles(readAgentDefinitionFiles(dir, inspection), source, discoveryPriority, packageSource);
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
function reportAgentDefinitionDirectory(source: AgentSource, dir: string, inspection: AgentDefinitionInspection): AgentDefinitionDirectoryReport {
|
|
2256
|
+
return {
|
|
2257
|
+
source,
|
|
2258
|
+
path: path.resolve(dir),
|
|
2259
|
+
state: inspection.state,
|
|
2260
|
+
...(inspection.state === "candidates" ? { candidateCount: inspection.files.length } : {}),
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
function loadChainsFromDir(dir: string, source: AgentSource): { chains: ChainConfig[]; diagnostics: ChainDiscoveryDiagnostic[]; files: string[]; directories: string[] } {
|
|
2265
|
+
const chains = new Map<string, ChainConfig>();
|
|
2266
|
+
const diagnostics: ChainDiscoveryDiagnostic[] = [];
|
|
2267
|
+
const directories = new Set<string>();
|
|
2268
|
+
const files = listFilesRecursive(dir, (fileName) => fileName.endsWith(".chain.md") || fileName.endsWith(".chain.json"), dir, new Set<string>(), directories);
|
|
2269
|
+
|
|
2270
|
+
for (const filePath of files) {
|
|
2271
|
+
let content: string;
|
|
2272
|
+
try {
|
|
2273
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
2274
|
+
} catch {
|
|
2275
|
+
continue;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
try {
|
|
2279
|
+
const chain = filePath.endsWith(".chain.json") ? parseJsonChain(content, source, filePath) : parseChain(content, source, filePath);
|
|
2280
|
+
const existing = chains.get(chain.name);
|
|
2281
|
+
if (existing && existing.filePath.endsWith(".chain.json") && filePath.endsWith(".chain.md")) continue;
|
|
2282
|
+
chains.set(chain.name, chain);
|
|
2283
|
+
} catch (error) {
|
|
2284
|
+
diagnostics.push({ source, filePath, error: error instanceof Error ? error.message : String(error) });
|
|
2285
|
+
continue;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
return { chains: Array.from(chains.values()), diagnostics, files, directories: [...directories] };
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
function isDirectory(p: string): boolean {
|
|
2293
|
+
try {
|
|
2294
|
+
return fs.statSync(p).isDirectory();
|
|
2295
|
+
} catch {
|
|
2296
|
+
return false;
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
function resolveNearestProjectAgentDirs(cwd: string): { readDirs: string[]; candidateDirs: string[]; preferredDir: string | null } {
|
|
2301
|
+
const projectRoot = findConfiguredProjectRoot(cwd);
|
|
2302
|
+
if (!projectRoot) return { readDirs: [], candidateDirs: [], preferredDir: null };
|
|
2303
|
+
|
|
2304
|
+
const legacyDir = path.join(projectRoot, ".agents");
|
|
2305
|
+
const preferredDir = path.join(getProjectConfigDir(projectRoot), "agents");
|
|
2306
|
+
const candidateDirs = [legacyDir, preferredDir];
|
|
2307
|
+
const readDirs: string[] = [];
|
|
2308
|
+
if (isDirectory(legacyDir)) readDirs.push(legacyDir);
|
|
2309
|
+
if (isDirectory(preferredDir)) readDirs.push(preferredDir);
|
|
2310
|
+
|
|
2311
|
+
return { readDirs, candidateDirs, preferredDir };
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
function resolveNearestProjectChainDirs(cwd: string): { readDirs: string[]; preferredDir: string | null } {
|
|
2315
|
+
const projectRoot = findConfiguredProjectRoot(cwd);
|
|
2316
|
+
if (!projectRoot) return { readDirs: [], preferredDir: null };
|
|
2317
|
+
|
|
2318
|
+
const preferredDir = path.join(getProjectConfigDir(projectRoot), "chains");
|
|
2319
|
+
return {
|
|
2320
|
+
readDirs: isDirectory(preferredDir) ? [preferredDir] : [],
|
|
2321
|
+
preferredDir,
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
const BUILTIN_AGENTS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "agents");
|
|
2325
|
+
// Candidate files and inspection state must describe the same cached builtin scan.
|
|
2326
|
+
const BUILTIN_AGENT_DEFINITION_INSPECTION = inspectAgentDefinitionDirectory(BUILTIN_AGENTS_DIR);
|
|
2327
|
+
const BUILTIN_AGENT_DEFINITION_FILES = readAgentDefinitionFiles(BUILTIN_AGENTS_DIR, BUILTIN_AGENT_DEFINITION_INSPECTION);
|
|
2328
|
+
|
|
2329
|
+
export const EXTRA_AGENT_DIRS_ENV = "PI_SUBAGENT_EXTRA_AGENT_DIRS";
|
|
2330
|
+
|
|
2331
|
+
// Additional read-only directories to scan for agent definitions, supplied by the
|
|
2332
|
+
// launcher via PI_SUBAGENT_EXTRA_AGENT_DIRS (PATH-style, split on os/path delimiter).
|
|
2333
|
+
// Lets a hermetic wrapper (e.g. a Nix-store install) expose bundled agents without
|
|
2334
|
+
// copying or symlinking them into the writable agent dir. Loaded as "user" source,
|
|
2335
|
+
// at lower precedence than agents the user placed in their own agent dir.
|
|
2336
|
+
function extraUserAgentDirs(): string[] {
|
|
2337
|
+
const raw = process.env[EXTRA_AGENT_DIRS_ENV];
|
|
2338
|
+
if (!raw) return [];
|
|
2339
|
+
return raw
|
|
2340
|
+
.split(path.delimiter)
|
|
2341
|
+
.map((dir) => dir.trim())
|
|
2342
|
+
.filter((dir) => dir.length > 0);
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
export interface AgentDiscoveryAllResult {
|
|
2346
|
+
builtin: AgentConfig[];
|
|
2347
|
+
package: AgentConfig[];
|
|
2348
|
+
user: AgentConfig[];
|
|
2349
|
+
project: AgentConfig[];
|
|
2350
|
+
agentDiagnostics?: AgentDiscoveryDiagnostic[];
|
|
2351
|
+
chains: ChainConfig[];
|
|
2352
|
+
chainDiagnostics: ChainDiscoveryDiagnostic[];
|
|
2353
|
+
userDir: string;
|
|
2354
|
+
projectDir: string | null;
|
|
2355
|
+
userChainDir: string;
|
|
2356
|
+
projectChainDir: string | null;
|
|
2357
|
+
userSettingsPath: string;
|
|
2358
|
+
projectSettingsPath: string | null;
|
|
2359
|
+
maxThinking?: ThinkingLevel;
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
/**
|
|
2363
|
+
* A single fresh source scan with both projections retained. The effective
|
|
2364
|
+
* projection intentionally remains separate from the all-source projection:
|
|
2365
|
+
* disabled and shadowed definitions are needed for diagnostics and runtime
|
|
2366
|
+
* collision checks even when they are not launchable.
|
|
2367
|
+
*/
|
|
2368
|
+
export interface AgentDiscoverySnapshot {
|
|
2369
|
+
effective: AgentDiscoveryResult;
|
|
2370
|
+
all: AgentDiscoveryAllResult;
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
interface LoadedAgentDirectory {
|
|
2374
|
+
dir: string;
|
|
2375
|
+
inspection: AgentDefinitionInspection;
|
|
2376
|
+
loaded: ReturnType<typeof loadAgentsFromDir>;
|
|
2377
|
+
packageEntry?: PackageSubagentPath;
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
interface AgentDiscoverySources {
|
|
2381
|
+
cwd: string;
|
|
2382
|
+
preferredModelProvider?: string;
|
|
2383
|
+
userDir: string;
|
|
2384
|
+
userDirOld: string;
|
|
2385
|
+
userDirNew: string;
|
|
2386
|
+
userChainDir: string;
|
|
2387
|
+
projectAgentDirs: string[];
|
|
2388
|
+
projectCandidateDirs: string[];
|
|
2389
|
+
projectAgentsDir: string | null;
|
|
2390
|
+
projectChainDirs: string[];
|
|
2391
|
+
projectChainDir: string | null;
|
|
2392
|
+
userSettingsPath: string;
|
|
2393
|
+
projectSettingsPath: string | null;
|
|
2394
|
+
userSettings?: SubagentSettings;
|
|
2395
|
+
projectSettings?: SubagentSettings;
|
|
2396
|
+
packageSubagentPaths: PackageSubagentPaths;
|
|
2397
|
+
builtinLoaded: ReturnType<typeof loadAgentsFromDefinitionFiles>;
|
|
2398
|
+
userLoaded: LoadedAgentDirectory[];
|
|
2399
|
+
projectLoaded: LoadedAgentDirectory[];
|
|
2400
|
+
projectInspections: Map<string, AgentDefinitionInspection>;
|
|
2401
|
+
packageLoaded: LoadedAgentDirectory[];
|
|
2402
|
+
userChains?: ReturnType<typeof loadChainsFromDir>;
|
|
2403
|
+
projectChainLoaded?: Array<{ dir: string; loaded: ReturnType<typeof loadChainsFromDir> }>;
|
|
2404
|
+
packageChainLoaded?: Array<{ entry: PackageChainPath; loaded: ReturnType<typeof loadChainsFromDir> }>;
|
|
2405
|
+
watchPaths: string[];
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
interface AgentDiscoveryCacheEntry {
|
|
2409
|
+
sources: AgentDiscoverySources;
|
|
2410
|
+
fingerprint: string;
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
const agentDiscoveryCache = new Map<string, AgentDiscoveryCacheEntry>();
|
|
2414
|
+
|
|
2415
|
+
function isPathWithin(root: string, candidate: string): boolean {
|
|
2416
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
|
2417
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
function addDirectoryWatchPaths(paths: Set<string>, root: string, files: readonly string[], directories: readonly string[] = []): void {
|
|
2421
|
+
const resolvedRoot = path.resolve(root);
|
|
2422
|
+
paths.add(resolvedRoot);
|
|
2423
|
+
// The initial recursive inspection is already bounded to this discovery
|
|
2424
|
+
// root. Keep every visited directory in the fingerprint so a file added to
|
|
2425
|
+
// an existing empty nested directory invalidates the snapshot too.
|
|
2426
|
+
for (const directory of directories) {
|
|
2427
|
+
if (isPathWithin(resolvedRoot, directory)) paths.add(path.resolve(directory));
|
|
2428
|
+
}
|
|
2429
|
+
for (const file of files) {
|
|
2430
|
+
paths.add(path.resolve(file));
|
|
2431
|
+
let current = path.resolve(path.dirname(file));
|
|
2432
|
+
while (isPathWithin(resolvedRoot, current)) {
|
|
2433
|
+
paths.add(current);
|
|
2434
|
+
if (current === resolvedRoot) break;
|
|
2435
|
+
current = path.dirname(current);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
function watchPathSignature(filePath: string): string {
|
|
2441
|
+
try {
|
|
2442
|
+
const stat = fs.statSync(filePath);
|
|
2443
|
+
if (stat.isDirectory()) {
|
|
2444
|
+
const entries = fs.readdirSync(filePath, { withFileTypes: true })
|
|
2445
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
2446
|
+
.map((entry) => `${entry.name}:${entry.isDirectory() ? "d" : entry.isSymbolicLink() ? "l" : "f"}`)
|
|
2447
|
+
.join("|");
|
|
2448
|
+
return `directory:${entries}`;
|
|
2449
|
+
}
|
|
2450
|
+
return `file:${stat.size}:${stat.mtimeMs}`;
|
|
2451
|
+
} catch {
|
|
2452
|
+
return "missing";
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
function discoveryFingerprint(paths: readonly string[]): string {
|
|
2457
|
+
return [...new Set(paths)]
|
|
2458
|
+
.sort((left, right) => left.localeCompare(right))
|
|
2459
|
+
.map((filePath) => `${filePath}:${watchPathSignature(filePath)}`)
|
|
2460
|
+
.join("\n");
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
function discoveryCacheKey(cwd: string, preferredModelProvider: string | undefined): string {
|
|
2464
|
+
return JSON.stringify([
|
|
2465
|
+
path.resolve(cwd),
|
|
2466
|
+
preferredModelProvider ?? null,
|
|
2467
|
+
getProjectConfigDir(path.resolve(cwd)),
|
|
2468
|
+
getAgentDir(),
|
|
2469
|
+
os.homedir(),
|
|
2470
|
+
process.env.HOME ?? "",
|
|
2471
|
+
process.env.USERPROFILE ?? "",
|
|
2472
|
+
process.env[EXTRA_AGENT_DIRS_ENV] ?? "",
|
|
2473
|
+
process.env.PI_OFFLINE ?? "",
|
|
2474
|
+
process.env.APPDATA ?? "",
|
|
2475
|
+
]);
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
function projectDiscoveryWatchPaths(cwd: string): string[] {
|
|
2479
|
+
const paths: string[] = [];
|
|
2480
|
+
let current = path.resolve(cwd);
|
|
2481
|
+
while (true) {
|
|
2482
|
+
paths.push(getProjectConfigDir(current), path.join(current, ".agents"), path.join(current, ".git"));
|
|
2483
|
+
const parent = path.dirname(current);
|
|
2484
|
+
if (parent === current) break;
|
|
2485
|
+
current = parent;
|
|
2486
|
+
}
|
|
2487
|
+
return paths;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
function packageEntryIncluded(scope: AgentScope, packageScopes: PackageSubagentPath["scope"]): boolean {
|
|
2491
|
+
if (scope === "both" || packageScopes.has("root")) return true;
|
|
2492
|
+
return packageScopes.has(scope);
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
function buildAgentDiscoverySources(cwd: string, preferredModelProvider?: string): AgentDiscoverySources {
|
|
2496
|
+
const effectiveCwd = path.resolve(cwd);
|
|
2497
|
+
const userDirOld = path.join(getAgentDir(), "agents");
|
|
2498
|
+
const userDirNew = path.join(os.homedir(), ".agents");
|
|
2499
|
+
const userChainDir = getUserChainDir();
|
|
2500
|
+
const { readDirs: projectAgentDirs, candidateDirs: projectCandidateDirs, preferredDir: projectAgentsDir } = resolveNearestProjectAgentDirs(effectiveCwd);
|
|
2501
|
+
const { readDirs: projectChainDirs, preferredDir: projectChainDir } = resolveNearestProjectChainDirs(effectiveCwd);
|
|
2502
|
+
const userSettingsPath = getUserAgentSettingsPath();
|
|
2503
|
+
const projectSettingsPath = getProjectAgentSettingsPath(effectiveCwd);
|
|
2504
|
+
const packageSubagentPaths = collectPackageSubagentPaths(effectiveCwd);
|
|
2505
|
+
|
|
2506
|
+
const builtinLoaded = loadAgentsFromDefinitionFiles(BUILTIN_AGENT_DEFINITION_FILES, "builtin");
|
|
2507
|
+
const userLoaded = [...extraUserAgentDirs(), userDirOld, userDirNew].map((dir, discoveryPriority): LoadedAgentDirectory => {
|
|
2508
|
+
const inspection = inspectAgentDefinitionDirectory(dir);
|
|
2509
|
+
return { dir, inspection, loaded: loadAgentsFromDir(dir, "user", discoveryPriority, undefined, inspection) };
|
|
2510
|
+
});
|
|
2511
|
+
const projectInspections = new Map(projectCandidateDirs.map((dir) => [dir, inspectAgentDefinitionDirectory(dir)]));
|
|
2512
|
+
const projectLoaded = projectAgentDirs.map((dir): LoadedAgentDirectory => {
|
|
2513
|
+
const inspection = projectInspections.get(dir)!;
|
|
2514
|
+
return { dir, inspection, loaded: loadAgentsFromDir(dir, "project", dir === projectAgentsDir ? 1 : 0, undefined, inspection) };
|
|
2515
|
+
});
|
|
2516
|
+
const packageLoaded = packageSubagentPaths.agents.map((entry, index): LoadedAgentDirectory => {
|
|
2517
|
+
const inspection = inspectAgentDefinitionDirectory(entry.dir);
|
|
2518
|
+
return { dir: entry.dir, inspection, packageEntry: entry, loaded: loadAgentsFromDir(entry.dir, "package", packageSubagentPaths.agents.length - index, entry, inspection) };
|
|
2519
|
+
});
|
|
2520
|
+
|
|
2521
|
+
const watchPaths = new Set<string>([
|
|
2522
|
+
userSettingsPath,
|
|
2523
|
+
...(projectSettingsPath ? [projectSettingsPath] : []),
|
|
2524
|
+
...projectDiscoveryWatchPaths(effectiveCwd),
|
|
2525
|
+
...findProjectRootCandidates(effectiveCwd).map((root) => path.join(getProjectConfigDir(root), "settings.json")),
|
|
2526
|
+
...packageSubagentPaths.watchPaths,
|
|
2527
|
+
]);
|
|
2528
|
+
for (const directory of userLoaded) addDirectoryWatchPaths(watchPaths, directory.dir, directory.inspection.files, inspectedAgentDefinitionDirectories(directory.inspection, directory.dir));
|
|
2529
|
+
for (const dir of projectCandidateDirs) {
|
|
2530
|
+
const inspection = projectInspections.get(dir);
|
|
2531
|
+
addDirectoryWatchPaths(watchPaths, dir, inspection?.files ?? [], inspection ? inspectedAgentDefinitionDirectories(inspection, dir) : []);
|
|
2532
|
+
}
|
|
2533
|
+
for (const directory of packageLoaded) addDirectoryWatchPaths(watchPaths, directory.dir, directory.inspection.files, inspectedAgentDefinitionDirectories(directory.inspection, directory.dir));
|
|
2534
|
+
|
|
2535
|
+
const userDir = process.env.PI_CODING_AGENT_DIR ? userDirOld : fs.existsSync(userDirNew) ? userDirNew : userDirOld;
|
|
2536
|
+
return {
|
|
2537
|
+
cwd: effectiveCwd,
|
|
2538
|
+
...(preferredModelProvider !== undefined ? { preferredModelProvider } : {}),
|
|
2539
|
+
userDir,
|
|
2540
|
+
userDirOld,
|
|
2541
|
+
userDirNew,
|
|
2542
|
+
userChainDir,
|
|
2543
|
+
projectAgentDirs,
|
|
2544
|
+
projectCandidateDirs,
|
|
2545
|
+
projectAgentsDir,
|
|
2546
|
+
projectChainDirs,
|
|
2547
|
+
projectChainDir,
|
|
2548
|
+
userSettingsPath,
|
|
2549
|
+
projectSettingsPath,
|
|
2550
|
+
packageSubagentPaths,
|
|
2551
|
+
builtinLoaded,
|
|
2552
|
+
userLoaded,
|
|
2553
|
+
projectLoaded,
|
|
2554
|
+
projectInspections,
|
|
2555
|
+
packageLoaded,
|
|
2556
|
+
watchPaths: [...watchPaths],
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
function ensureDiscoveryChains(sources: AgentDiscoverySources): void {
|
|
2561
|
+
if (sources.userChains) return;
|
|
2562
|
+
sources.packageChainLoaded = sources.packageSubagentPaths.chains.map((entry) => ({ entry, loaded: loadChainsFromDir(entry.dir, "package") }));
|
|
2563
|
+
sources.userChains = loadChainsFromDir(sources.userChainDir, "user");
|
|
2564
|
+
sources.projectChainLoaded = sources.projectChainDirs.map((dir) => ({ dir, loaded: loadChainsFromDir(dir, "project") }));
|
|
2565
|
+
const watchPaths = new Set(sources.watchPaths);
|
|
2566
|
+
addDirectoryWatchPaths(watchPaths, sources.userChainDir, sources.userChains.files, sources.userChains.directories);
|
|
2567
|
+
for (const chain of sources.projectChainLoaded) addDirectoryWatchPaths(watchPaths, chain.dir, chain.loaded.files, chain.loaded.directories);
|
|
2568
|
+
for (const chain of sources.packageChainLoaded) addDirectoryWatchPaths(watchPaths, chain.entry.dir, chain.loaded.files, chain.loaded.directories);
|
|
2569
|
+
sources.watchPaths = [...watchPaths];
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
function getAgentDiscoverySources(cwd: string, preferredModelProvider?: string, includeChains = false): AgentDiscoverySources {
|
|
2573
|
+
const key = discoveryCacheKey(cwd, preferredModelProvider);
|
|
2574
|
+
const cached = agentDiscoveryCache.get(key);
|
|
2575
|
+
if (cached && cached.fingerprint === discoveryFingerprint(cached.sources.watchPaths)) {
|
|
2576
|
+
if (includeChains) {
|
|
2577
|
+
ensureDiscoveryChains(cached.sources);
|
|
2578
|
+
cached.fingerprint = discoveryFingerprint(cached.sources.watchPaths);
|
|
2579
|
+
}
|
|
2580
|
+
return cached.sources;
|
|
2581
|
+
}
|
|
2582
|
+
const sources = buildAgentDiscoverySources(cwd, preferredModelProvider);
|
|
2583
|
+
const entry = { sources, fingerprint: discoveryFingerprint(sources.watchPaths) };
|
|
2584
|
+
agentDiscoveryCache.set(key, entry);
|
|
2585
|
+
if (includeChains) {
|
|
2586
|
+
ensureDiscoveryChains(sources);
|
|
2587
|
+
entry.fingerprint = discoveryFingerprint(sources.watchPaths);
|
|
2588
|
+
}
|
|
2589
|
+
return sources;
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
/** Clear process-local discovery snapshots, primarily for hosts that reload settings in place. */
|
|
2593
|
+
export function clearAgentDiscoveryCache(): void {
|
|
2594
|
+
agentDiscoveryCache.clear();
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
function ensureSettingsForScope(sources: AgentDiscoverySources, scope: AgentScope, preferredModelProvider?: string): void {
|
|
2598
|
+
if (scope !== "project" && sources.userSettings === undefined) {
|
|
2599
|
+
if (sources.packageSubagentPaths.settingsErrors.user) throw sources.packageSubagentPaths.settingsErrors.user;
|
|
2600
|
+
sources.userSettings = selectProviderOverrides(readSubagentSettings(sources.userSettingsPath), preferredModelProvider);
|
|
2601
|
+
}
|
|
2602
|
+
if (scope !== "user" && sources.projectSettings === undefined) {
|
|
2603
|
+
if (sources.packageSubagentPaths.settingsErrors.project) throw sources.packageSubagentPaths.settingsErrors.project;
|
|
2604
|
+
sources.projectSettings = selectProviderOverrides(readSubagentSettings(sources.projectSettingsPath), preferredModelProvider);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
function settingsForScope(sources: AgentDiscoverySources, scope: AgentScope): { user: SubagentSettings; project: SubagentSettings } {
|
|
2609
|
+
// Parse only settings that participate in this projection. The source cache
|
|
2610
|
+
// still retains both source trees, while malformed out-of-scope settings do
|
|
2611
|
+
// not make an otherwise valid scoped projection fail.
|
|
2612
|
+
ensureSettingsForScope(sources, scope, sources.preferredModelProvider);
|
|
2613
|
+
return {
|
|
2614
|
+
user: scope === "project" ? EMPTY_SUBAGENT_SETTINGS : sources.userSettings ?? EMPTY_SUBAGENT_SETTINGS,
|
|
2615
|
+
project: scope === "user" ? EMPTY_SUBAGENT_SETTINGS : sources.projectSettings ?? EMPTY_SUBAGENT_SETTINGS,
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
function configuredAgentsForScope(sources: AgentDiscoverySources, scope: AgentScope, settingsScope = scope): {
|
|
2620
|
+
builtin: AgentConfig[];
|
|
2621
|
+
package: AgentConfig[];
|
|
2622
|
+
user: AgentConfig[];
|
|
2623
|
+
project: AgentConfig[];
|
|
2624
|
+
userSettings: SubagentSettings;
|
|
2625
|
+
projectSettings: SubagentSettings;
|
|
2626
|
+
maxThinking?: ThinkingLevel;
|
|
2627
|
+
modelScope?: ModelScopeConfig;
|
|
2628
|
+
} {
|
|
2629
|
+
const { user: userSettings, project: projectSettings } = settingsForScope(sources, settingsScope);
|
|
2630
|
+
const defaultProvider = resolveSubagentDefaultProvider(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2631
|
+
const defaultModel = resolveSubagentDefaultModel(userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath, defaultProvider);
|
|
2632
|
+
const defaultThinking = resolveSubagentDefaultThinking(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2633
|
+
const maxThinking = resolveSubagentMaxThinking(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2634
|
+
const defaultExtensions = resolveSubagentDefaultExtensions(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2635
|
+
const applyDefaults = (agents: AgentConfig[]): AgentConfig[] => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions);
|
|
2636
|
+
const builtin = applyBuiltinOverrides(applyDefaults(sources.builtinLoaded.agents), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2637
|
+
const user = applyCustomAgentOverrides(
|
|
2638
|
+
applyDefaults(scope === "project" ? [] : sources.userLoaded.flatMap((loaded) => loaded.loaded.agents)),
|
|
2639
|
+
userSettings,
|
|
2640
|
+
projectSettings,
|
|
2641
|
+
sources.userSettingsPath,
|
|
2642
|
+
sources.projectSettingsPath,
|
|
2643
|
+
);
|
|
2644
|
+
const projectMap = new Map<string, AgentConfig>();
|
|
2645
|
+
if (scope !== "user") for (const loaded of sources.projectLoaded) for (const agent of loaded.loaded.agents) projectMap.set(agent.name, agent);
|
|
2646
|
+
const project = applyCustomAgentOverrides(applyDefaults(Array.from(projectMap.values())), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2647
|
+
const packageMap = new Map<string, AgentConfig>();
|
|
2648
|
+
for (const loaded of sources.packageLoaded) {
|
|
2649
|
+
if (!loaded.packageEntry || !packageEntryIncluded(scope, loaded.packageEntry.scope)) continue;
|
|
2650
|
+
for (const agent of loaded.loaded.agents) if (!packageMap.has(agent.name)) packageMap.set(agent.name, agent);
|
|
2651
|
+
}
|
|
2652
|
+
const packageAgents = applyCustomAgentOverrides(applyDefaults(Array.from(packageMap.values())), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2653
|
+
return {
|
|
2654
|
+
builtin,
|
|
2655
|
+
package: packageAgents,
|
|
2656
|
+
user,
|
|
2657
|
+
project,
|
|
2658
|
+
userSettings,
|
|
2659
|
+
projectSettings,
|
|
2660
|
+
maxThinking,
|
|
2661
|
+
modelScope: projectSettings.modelScope ?? userSettings.modelScope,
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
function discoveryDirectories(sources: AgentDiscoverySources, scope: AgentScope): AgentDefinitionDirectoryReport[] {
|
|
2666
|
+
const directories: AgentDefinitionDirectoryReport[] = [reportAgentDefinitionDirectory("builtin", BUILTIN_AGENTS_DIR, BUILTIN_AGENT_DEFINITION_INSPECTION)];
|
|
2667
|
+
if (scope !== "project") for (const directory of sources.userLoaded) directories.push(reportAgentDefinitionDirectory("user", directory.dir, directory.inspection));
|
|
2668
|
+
if (scope !== "user") for (const dir of sources.projectCandidateDirs) directories.push(reportAgentDefinitionDirectory("project", dir, sources.projectInspections.get(dir)!));
|
|
2669
|
+
for (const directory of sources.packageLoaded) {
|
|
2670
|
+
if (directory.packageEntry && packageEntryIncluded(scope, directory.packageEntry.scope)) directories.push(reportAgentDefinitionDirectory("package", directory.dir, directory.inspection));
|
|
2671
|
+
}
|
|
2672
|
+
return directories;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
function discoveryDiagnostics(sources: AgentDiscoverySources, scope: AgentScope): AgentDiscoveryDiagnostic[] {
|
|
2676
|
+
return [
|
|
2677
|
+
...sources.builtinLoaded.diagnostics,
|
|
2678
|
+
...(scope === "project" ? [] : sources.userLoaded.flatMap((loaded) => loaded.loaded.diagnostics)),
|
|
2679
|
+
...(scope === "user" ? [] : sources.projectLoaded.flatMap((loaded) => loaded.loaded.diagnostics)),
|
|
2680
|
+
...sources.packageLoaded
|
|
2681
|
+
.filter((loaded) => loaded.packageEntry && packageEntryIncluded(scope, loaded.packageEntry.scope))
|
|
2682
|
+
.flatMap((loaded) => loaded.loaded.diagnostics),
|
|
2683
|
+
];
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
function buildEffectiveDiscovery(sources: AgentDiscoverySources, scope: AgentScope): AgentDiscoveryResult {
|
|
2687
|
+
const configured = configuredAgentsForScope(sources, scope);
|
|
2688
|
+
const agents = applySubagentMaxThinking(
|
|
2689
|
+
mergeAgentsForScope(scope, configured.user, configured.project, configured.builtin, configured.package).filter((agent) => agent.disabled !== true),
|
|
2690
|
+
configured.maxThinking,
|
|
2691
|
+
);
|
|
2692
|
+
return {
|
|
2693
|
+
agents,
|
|
2694
|
+
agentDiagnostics: discoveryDiagnostics(sources, scope),
|
|
2695
|
+
projectAgentsDir: sources.projectAgentsDir,
|
|
2696
|
+
cwd: sources.cwd,
|
|
2697
|
+
scope,
|
|
2698
|
+
directories: discoveryDirectories(sources, scope),
|
|
2699
|
+
...(configured.modelScope !== undefined ? { modelScope: configured.modelScope } : {}),
|
|
2700
|
+
...(configured.maxThinking !== undefined ? { maxThinking: configured.maxThinking } : {}),
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
function buildAllDiscovery(sources: AgentDiscoverySources, includeChains: boolean, settingsScope: AgentScope): AgentDiscoveryAllResult {
|
|
2705
|
+
if (includeChains) ensureDiscoveryChains(sources);
|
|
2706
|
+
const configured = configuredAgentsForScope(sources, "both", settingsScope);
|
|
2707
|
+
const packageChainMap = new Map<string, ChainConfig>();
|
|
2708
|
+
const packageChainDiagnostics: ChainDiscoveryDiagnostic[] = [];
|
|
2709
|
+
for (const chain of sources.packageChainLoaded ?? []) {
|
|
2710
|
+
packageChainDiagnostics.push(...chain.loaded.diagnostics);
|
|
2711
|
+
for (const definition of chain.loaded.chains) if (!packageChainMap.has(definition.name)) packageChainMap.set(definition.name, definition);
|
|
2712
|
+
}
|
|
2713
|
+
const projectChainMap = new Map<string, ChainConfig>();
|
|
2714
|
+
const projectChainDiagnostics: ChainDiscoveryDiagnostic[] = [];
|
|
2715
|
+
for (const chain of sources.projectChainLoaded ?? []) {
|
|
2716
|
+
projectChainDiagnostics.push(...chain.loaded.diagnostics);
|
|
2717
|
+
for (const definition of chain.loaded.chains) projectChainMap.set(definition.name, definition);
|
|
2718
|
+
}
|
|
2719
|
+
const chains = [
|
|
2720
|
+
...Array.from(packageChainMap.values()),
|
|
2721
|
+
...(sources.userChains?.chains ?? []),
|
|
2722
|
+
...Array.from(projectChainMap.values()),
|
|
2723
|
+
];
|
|
2724
|
+
return {
|
|
2725
|
+
builtin: applySubagentMaxThinking(configured.builtin, configured.maxThinking),
|
|
2726
|
+
package: applySubagentMaxThinking(configured.package, configured.maxThinking),
|
|
2727
|
+
user: applySubagentMaxThinking(configured.user, configured.maxThinking),
|
|
2728
|
+
project: applySubagentMaxThinking(configured.project, configured.maxThinking),
|
|
2729
|
+
agentDiagnostics: [
|
|
2730
|
+
...sources.builtinLoaded.diagnostics,
|
|
2731
|
+
...sources.userLoaded.flatMap((loaded) => loaded.loaded.diagnostics),
|
|
2732
|
+
...sources.packageLoaded.flatMap((loaded) => loaded.loaded.diagnostics),
|
|
2733
|
+
...sources.projectLoaded.flatMap((loaded) => loaded.loaded.diagnostics),
|
|
2734
|
+
],
|
|
2735
|
+
chains,
|
|
2736
|
+
chainDiagnostics: [...packageChainDiagnostics, ...(sources.userChains?.diagnostics ?? []), ...projectChainDiagnostics],
|
|
2737
|
+
userDir: sources.userDir,
|
|
2738
|
+
projectDir: sources.projectAgentsDir,
|
|
2739
|
+
userChainDir: sources.userChainDir,
|
|
2740
|
+
projectChainDir: sources.projectChainDir,
|
|
2741
|
+
userSettingsPath: sources.userSettingsPath,
|
|
2742
|
+
projectSettingsPath: sources.projectSettingsPath,
|
|
2743
|
+
...(configured.maxThinking !== undefined ? { maxThinking: configured.maxThinking } : {}),
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
export function discoverAgentSnapshot(
|
|
2748
|
+
cwd: string,
|
|
2749
|
+
scope: AgentScope,
|
|
2750
|
+
preferredModelProvider?: string,
|
|
2751
|
+
options: { includeChains?: boolean } = {},
|
|
2752
|
+
): AgentDiscoverySnapshot {
|
|
2753
|
+
const includeChains = options.includeChains !== false;
|
|
2754
|
+
const sources = getAgentDiscoverySources(cwd, preferredModelProvider, includeChains);
|
|
2755
|
+
return { effective: buildEffectiveDiscovery(sources, scope), all: buildAllDiscovery(sources, includeChains, scope) };
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
function discoverAgentsUncached(cwd: string, scope: AgentScope, preferredModelProvider?: string): AgentDiscoveryResult {
|
|
2759
|
+
const effectiveCwd = path.resolve(cwd);
|
|
2760
|
+
const userDirOld = path.join(getAgentDir(), "agents");
|
|
2761
|
+
const userDirNew = path.join(os.homedir(), ".agents");
|
|
2762
|
+
const { readDirs: projectAgentDirs, candidateDirs: projectCandidateDirs, preferredDir: projectAgentsDir } = resolveNearestProjectAgentDirs(effectiveCwd);
|
|
2763
|
+
const userSettingsPath = getUserAgentSettingsPath();
|
|
2764
|
+
const projectSettingsPath = getProjectAgentSettingsPath(effectiveCwd);
|
|
2765
|
+
const userSettings = selectProviderOverrides(scope === "project" ? EMPTY_SUBAGENT_SETTINGS : readSubagentSettings(userSettingsPath), preferredModelProvider);
|
|
2766
|
+
const projectSettings = selectProviderOverrides(scope === "user" ? EMPTY_SUBAGENT_SETTINGS : readSubagentSettings(projectSettingsPath), preferredModelProvider);
|
|
2767
|
+
const defaultProvider = resolveSubagentDefaultProvider(userSettings, projectSettings, projectSettingsPath);
|
|
2768
|
+
const defaultModel = resolveSubagentDefaultModel(userSettings, projectSettings, userSettingsPath, projectSettingsPath, defaultProvider);
|
|
2769
|
+
const defaultThinking = resolveSubagentDefaultThinking(userSettings, projectSettings, projectSettingsPath);
|
|
2770
|
+
const maxThinking = resolveSubagentMaxThinking(userSettings, projectSettings, projectSettingsPath);
|
|
2771
|
+
const defaultExtensions = resolveSubagentDefaultExtensions(userSettings, projectSettings, projectSettingsPath);
|
|
2772
|
+
const modelScope = projectSettings.modelScope ?? userSettings.modelScope;
|
|
2773
|
+
const packageSubagentPaths = collectPackageSubagentPaths(effectiveCwd, { includeUser: scope !== "project", includeProject: scope !== "user" });
|
|
2774
|
+
const directories: AgentDefinitionDirectoryReport[] = [reportAgentDefinitionDirectory("builtin", BUILTIN_AGENTS_DIR, BUILTIN_AGENT_DEFINITION_INSPECTION)];
|
|
2775
|
+
const builtinLoaded = loadAgentsFromDefinitionFiles(BUILTIN_AGENT_DEFINITION_FILES, "builtin");
|
|
2776
|
+
const builtinAgents = applyBuiltinOverrides(applySubagentDefaults(builtinLoaded.agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions), userSettings, projectSettings, userSettingsPath, projectSettingsPath);
|
|
2777
|
+
const userLoaded = scope === "project" ? [] : [...extraUserAgentDirs(), userDirOld, userDirNew].map((dir, discoveryPriority) => {
|
|
2778
|
+
const inspection = inspectAgentDefinitionDirectory(dir);
|
|
2779
|
+
directories.push(reportAgentDefinitionDirectory("user", dir, inspection));
|
|
2780
|
+
return loadAgentsFromDir(dir, "user", discoveryPriority, undefined, inspection);
|
|
2781
|
+
});
|
|
2782
|
+
const userAgents = applyCustomAgentOverrides(applySubagentDefaults(userLoaded.flatMap((loaded) => loaded.agents), defaultModel, defaultProvider, defaultThinking, defaultExtensions), userSettings, projectSettings, userSettingsPath, projectSettingsPath);
|
|
2783
|
+
const projectInspections = scope === "user" ? new Map<string, AgentDefinitionInspection>() : new Map(projectCandidateDirs.map((dir) => [dir, inspectAgentDefinitionDirectory(dir)]));
|
|
2784
|
+
if (scope !== "user") for (const dir of projectCandidateDirs) directories.push(reportAgentDefinitionDirectory("project", dir, projectInspections.get(dir)!));
|
|
2785
|
+
const projectLoaded = scope === "user" ? [] : projectAgentDirs.map((dir) => loadAgentsFromDir(dir, "project", dir === projectAgentsDir ? 1 : 0, undefined, projectInspections.get(dir)!));
|
|
2786
|
+
const projectAgents = applyCustomAgentOverrides(applySubagentDefaults(projectLoaded.flatMap((loaded) => loaded.agents), defaultModel, defaultProvider, defaultThinking, defaultExtensions), userSettings, projectSettings, userSettingsPath, projectSettingsPath);
|
|
2787
|
+
const packageLoaded = packageSubagentPaths.agents.map((entry, index) => {
|
|
2788
|
+
const inspection = inspectAgentDefinitionDirectory(entry.dir);
|
|
2789
|
+
directories.push(reportAgentDefinitionDirectory("package", entry.dir, inspection));
|
|
2790
|
+
return loadAgentsFromDir(entry.dir, "package", packageSubagentPaths.agents.length - index, entry, inspection);
|
|
2791
|
+
});
|
|
2792
|
+
const packageMap = new Map<string, AgentConfig>();
|
|
2793
|
+
for (const loaded of packageLoaded) for (const agent of loaded.agents) if (!packageMap.has(agent.name)) packageMap.set(agent.name, agent);
|
|
2794
|
+
const packageAgents = applyCustomAgentOverrides(applySubagentDefaults(Array.from(packageMap.values()), defaultModel, defaultProvider, defaultThinking, defaultExtensions), userSettings, projectSettings, userSettingsPath, projectSettingsPath);
|
|
2795
|
+
const agents = applySubagentMaxThinking(mergeAgentsForScope(scope, userAgents, projectAgents, builtinAgents, packageAgents).filter((agent) => agent.disabled !== true), maxThinking);
|
|
2796
|
+
const agentDiagnostics = [...builtinLoaded.diagnostics, ...userLoaded.flatMap((loaded) => loaded.diagnostics), ...projectLoaded.flatMap((loaded) => loaded.diagnostics), ...packageLoaded.flatMap((loaded) => loaded.diagnostics)];
|
|
2797
|
+
return { agents, agentDiagnostics, projectAgentsDir, cwd: effectiveCwd, scope, directories, ...(modelScope !== undefined ? { modelScope } : {}), ...(maxThinking !== undefined ? { maxThinking } : {}) };
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
export function discoverAgents(cwd: string, scope: AgentScope, preferredModelProvider?: string): AgentDiscoveryResult {
|
|
2801
|
+
if (scope !== "both") return discoverAgentsUncached(cwd, scope, preferredModelProvider);
|
|
2802
|
+
const sources = getAgentDiscoverySources(cwd, preferredModelProvider);
|
|
2803
|
+
return buildEffectiveDiscovery(sources, scope);
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
export function discoverAgentsAll(cwd: string, preferredModelProvider?: string): AgentDiscoveryAllResult {
|
|
2807
|
+
return discoverAgentSnapshot(cwd, "both", preferredModelProvider).all;
|
|
2808
|
+
}
|