@ikarmic/forge-core 4.5.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -21
- package/README.md +1 -1
- package/dist/agent/agent.d.ts +8 -1
- package/dist/agent/agent.js +143 -23
- package/dist/agent/architect.d.ts +0 -1
- package/dist/agent/architect.js +0 -1
- package/dist/agent/background.d.ts +58 -0
- package/dist/agent/background.js +139 -0
- package/dist/agent/cache-hints.d.ts +0 -1
- package/dist/agent/cache-hints.js +0 -1
- package/dist/agent/cost-router.d.ts +0 -1
- package/dist/agent/cost-router.js +0 -1
- package/dist/agent/enhance-prompt.d.ts +9 -0
- package/dist/agent/enhance-prompt.js +34 -0
- package/dist/agent/goal.d.ts +54 -0
- package/dist/agent/goal.js +65 -0
- package/dist/agent/index.d.ts +0 -1
- package/dist/agent/index.js +0 -1
- package/dist/agent/loop-guard.d.ts +21 -0
- package/dist/agent/loop-guard.js +41 -0
- package/dist/agent/prompts.d.ts +0 -1
- package/dist/agent/prompts.js +0 -1
- package/dist/agent/think-tags.d.ts +0 -1
- package/dist/agent/think-tags.js +0 -1
- package/dist/agent/verify.d.ts +0 -1
- package/dist/agent/verify.js +0 -1
- package/dist/agents/agent-files.d.ts +43 -0
- package/dist/agents/agent-files.js +109 -0
- package/dist/ai-comments/index.d.ts +0 -1
- package/dist/ai-comments/index.js +0 -1
- package/dist/attachments.d.ts +0 -1
- package/dist/attachments.js +0 -1
- package/dist/browser/cdp.d.ts +0 -1
- package/dist/browser/cdp.js +0 -1
- package/dist/browser/chrome.d.ts +0 -1
- package/dist/browser/chrome.js +0 -1
- package/dist/browser/session.d.ts +0 -1
- package/dist/browser/session.js +0 -1
- package/dist/checkpoints/index.d.ts +0 -1
- package/dist/checkpoints/index.js +0 -1
- package/dist/checkpoints/store.d.ts +0 -1
- package/dist/checkpoints/store.js +5 -2
- package/dist/checkpoints/types.d.ts +0 -1
- package/dist/checkpoints/types.js +0 -1
- package/dist/code-index/builder.d.ts +0 -1
- package/dist/code-index/builder.js +0 -1
- package/dist/code-index/index-store.d.ts +0 -1
- package/dist/code-index/index-store.js +0 -1
- package/dist/code-index/parser.d.ts +0 -1
- package/dist/code-index/parser.js +0 -1
- package/dist/code-index/types.d.ts +0 -1
- package/dist/code-index/types.js +0 -1
- package/dist/commands/custom-commands.d.ts +9 -5
- package/dist/commands/custom-commands.js +13 -3
- package/dist/config-file.d.ts +47 -1
- package/dist/config-file.js +249 -6
- package/dist/config-merge.d.ts +13 -0
- package/dist/config-merge.js +67 -0
- package/dist/config-schema.d.ts +340 -0
- package/dist/config-schema.js +126 -0
- package/dist/config.d.ts +0 -1
- package/dist/config.js +2 -2
- package/dist/context/compaction.d.ts +0 -1
- package/dist/context/compaction.js +10 -2
- package/dist/context/mask.d.ts +0 -1
- package/dist/context/mask.js +1 -2
- package/dist/credentials/index.d.ts +0 -1
- package/dist/credentials/index.js +0 -1
- package/dist/credentials/types.d.ts +0 -1
- package/dist/credentials/types.js +0 -1
- package/dist/custom-providers.d.ts +95 -0
- package/dist/custom-providers.js +120 -0
- package/dist/diff/index.d.ts +0 -1
- package/dist/diff/index.js +0 -1
- package/dist/diff/unified-diff.d.ts +0 -1
- package/dist/diff/unified-diff.js +0 -1
- package/dist/git/auto-commit.d.ts +3 -4
- package/dist/git/auto-commit.js +8 -7
- package/dist/git/index.d.ts +0 -1
- package/dist/git/index.js +0 -1
- package/dist/github/github-tools.d.ts +2 -3
- package/dist/github/github-tools.js +0 -1
- package/dist/hooks/agent-runner.d.ts +0 -1
- package/dist/hooks/agent-runner.js +0 -1
- package/dist/hooks/bus.d.ts +0 -1
- package/dist/hooks/bus.js +0 -1
- package/dist/hooks/config.d.ts +0 -1
- package/dist/hooks/config.js +0 -1
- package/dist/hooks/events.d.ts +0 -1
- package/dist/hooks/events.js +0 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +0 -1
- package/dist/hooks/loader.d.ts +0 -1
- package/dist/hooks/loader.js +0 -1
- package/dist/hooks/runner.d.ts +0 -1
- package/dist/hooks/runner.js +3 -3
- package/dist/hooks/watch-coalescer.d.ts +0 -1
- package/dist/hooks/watch-coalescer.js +0 -1
- package/dist/hooks/watch-ignore.d.ts +0 -1
- package/dist/hooks/watch-ignore.js +0 -1
- package/dist/hooks/watcher.d.ts +0 -1
- package/dist/hooks/watcher.js +0 -1
- package/dist/import/claude-code.d.ts +39 -0
- package/dist/import/claude-code.js +254 -0
- package/dist/index.d.ts +37 -7
- package/dist/index.js +28 -5
- package/dist/lazy-model.d.ts +0 -1
- package/dist/lazy-model.js +0 -1
- package/dist/lint/auto-lint.d.ts +0 -1
- package/dist/lint/auto-lint.js +0 -1
- package/dist/lint/index.d.ts +0 -1
- package/dist/lint/index.js +0 -1
- package/dist/lsp/client.d.ts +5 -1
- package/dist/lsp/client.js +39 -4
- package/dist/lsp/diagnostics.d.ts +0 -1
- package/dist/lsp/diagnostics.js +0 -1
- package/dist/lsp/index.d.ts +0 -1
- package/dist/lsp/index.js +0 -1
- package/dist/mcp/catalog.d.ts +0 -1
- package/dist/mcp/catalog.js +0 -1
- package/dist/mcp/index.d.ts +5 -2
- package/dist/mcp/index.js +3 -2
- package/dist/mcp/json-schema-to-zod.d.ts +0 -1
- package/dist/mcp/json-schema-to-zod.js +0 -1
- package/dist/mcp/manager.d.ts +17 -4
- package/dist/mcp/manager.js +27 -3
- package/dist/mcp/marketplace-types.d.ts +0 -1
- package/dist/mcp/marketplace-types.js +0 -1
- package/dist/mcp/marketplace.d.ts +2 -1
- package/dist/mcp/marketplace.js +10 -5
- package/dist/mcp/mcp-client.d.ts +12 -3
- package/dist/mcp/mcp-client.js +74 -18
- package/dist/mcp/mcp-config.d.ts +2 -1
- package/dist/mcp/mcp-config.js +1 -1
- package/dist/mcp/oauth.d.ts +55 -0
- package/dist/mcp/oauth.js +197 -0
- package/dist/mcp/registry.d.ts +0 -1
- package/dist/mcp/registry.js +0 -1
- package/dist/mcp/resource-tools.d.ts +8 -0
- package/dist/mcp/resource-tools.js +56 -0
- package/dist/memory/memory-store.d.ts +0 -1
- package/dist/memory/memory-store.js +0 -1
- package/dist/memory/rank.d.ts +0 -1
- package/dist/memory/rank.js +0 -1
- package/dist/memory/session-digest.d.ts +12 -0
- package/dist/memory/session-digest.js +47 -0
- package/dist/memory/stale.d.ts +0 -1
- package/dist/memory/stale.js +2 -2
- package/dist/model-alias.d.ts +18 -3
- package/dist/model-alias.js +27 -4
- package/dist/model-catalog.d.ts +0 -1
- package/dist/model-catalog.js +0 -2
- package/dist/model-list.d.ts +0 -1
- package/dist/model-list.js +2 -2
- package/dist/model-overrides.d.ts +30 -0
- package/dist/model-overrides.js +48 -0
- package/dist/orchestrator/board-tools.d.ts +0 -1
- package/dist/orchestrator/board-tools.js +0 -1
- package/dist/orchestrator/board.d.ts +0 -1
- package/dist/orchestrator/board.js +0 -1
- package/dist/orchestrator/index.d.ts +0 -1
- package/dist/orchestrator/index.js +0 -1
- package/dist/orchestrator/orchestrator.d.ts +0 -1
- package/dist/orchestrator/orchestrator.js +0 -1
- package/dist/orchestrator/router.d.ts +0 -1
- package/dist/orchestrator/router.js +0 -1
- package/dist/orchestrator/specialists-registry.d.ts +0 -1
- package/dist/orchestrator/specialists-registry.js +2 -4
- package/dist/orchestrator/specialists.d.ts +0 -1
- package/dist/orchestrator/specialists.js +4 -5
- package/dist/orchestrator/types.d.ts +0 -1
- package/dist/orchestrator/types.js +0 -1
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +0 -1
- package/dist/plugins/install.d.ts +0 -1
- package/dist/plugins/install.js +0 -1
- package/dist/plugins/loader.d.ts +0 -1
- package/dist/plugins/loader.js +0 -1
- package/dist/policy/audit.d.ts +0 -1
- package/dist/policy/audit.js +0 -1
- package/dist/policy/ca-certs.d.ts +8 -0
- package/dist/policy/ca-certs.js +30 -0
- package/dist/policy/policy.d.ts +0 -1
- package/dist/policy/policy.js +0 -1
- package/dist/policy/proxy.d.ts +10 -4
- package/dist/policy/proxy.js +33 -7
- package/dist/pricing.d.ts +0 -1
- package/dist/pricing.js +4 -1
- package/dist/providers.d.ts +7 -1
- package/dist/providers.js +39 -6
- package/dist/repomap/index.d.ts +0 -1
- package/dist/repomap/index.js +0 -1
- package/dist/repomap/repo-map.d.ts +0 -1
- package/dist/repomap/repo-map.js +0 -1
- package/dist/semantic/chunker.d.ts +0 -1
- package/dist/semantic/chunker.js +0 -1
- package/dist/semantic/embedder.d.ts +15 -1
- package/dist/semantic/embedder.js +25 -1
- package/dist/semantic/semantic-index.d.ts +10 -3
- package/dist/semantic/semantic-index.js +16 -8
- package/dist/semantic/vector-store.d.ts +0 -1
- package/dist/semantic/vector-store.js +0 -1
- package/dist/sessions/index.d.ts +1 -1
- package/dist/sessions/index.js +1 -1
- package/dist/sessions/prune.d.ts +23 -0
- package/dist/sessions/prune.js +35 -0
- package/dist/sessions/search.d.ts +0 -1
- package/dist/sessions/search.js +0 -1
- package/dist/sessions/session-export.d.ts +0 -1
- package/dist/sessions/session-export.js +0 -1
- package/dist/sessions/session-store.d.ts +0 -1
- package/dist/sessions/session-store.js +2 -2
- package/dist/sessions/watch.d.ts +0 -1
- package/dist/sessions/watch.js +0 -1
- package/dist/settings-export.d.ts +0 -1
- package/dist/settings-export.js +0 -1
- package/dist/skills/activator.d.ts +0 -1
- package/dist/skills/activator.js +0 -1
- package/dist/skills/builtin.d.ts +2 -0
- package/dist/skills/builtin.js +68 -0
- package/dist/skills/index.d.ts +2 -1
- package/dist/skills/index.js +2 -1
- package/dist/skills/loader.d.ts +10 -4
- package/dist/skills/loader.js +20 -8
- package/dist/skills/marketplace-types.d.ts +0 -1
- package/dist/skills/marketplace-types.js +0 -1
- package/dist/skills/marketplace.d.ts +0 -1
- package/dist/skills/marketplace.js +2 -2
- package/dist/skills/parser.d.ts +0 -1
- package/dist/skills/parser.js +0 -1
- package/dist/skills/remote.d.ts +14 -0
- package/dist/skills/remote.js +131 -0
- package/dist/skills/types.d.ts +10 -1
- package/dist/skills/types.js +0 -1
- package/dist/specs/generate.d.ts +0 -1
- package/dist/specs/generate.js +0 -1
- package/dist/specs/index.d.ts +0 -1
- package/dist/specs/index.js +0 -1
- package/dist/specs/store.d.ts +0 -1
- package/dist/specs/store.js +0 -1
- package/dist/specs/sync.d.ts +0 -1
- package/dist/specs/sync.js +0 -1
- package/dist/specs/tasks-parser.d.ts +0 -1
- package/dist/specs/tasks-parser.js +0 -1
- package/dist/specs/types.d.ts +0 -1
- package/dist/specs/types.js +0 -1
- package/dist/steering/extra-instructions.d.ts +8 -0
- package/dist/steering/extra-instructions.js +104 -0
- package/dist/steering/folder-instructions.d.ts +8 -0
- package/dist/steering/folder-instructions.js +28 -0
- package/dist/steering/glob.d.ts +0 -1
- package/dist/steering/glob.js +0 -1
- package/dist/steering/index.d.ts +0 -1
- package/dist/steering/index.js +0 -1
- package/dist/steering/loader.d.ts +0 -1
- package/dist/steering/loader.js +0 -1
- package/dist/steering/project-instructions.d.ts +0 -1
- package/dist/steering/project-instructions.js +0 -1
- package/dist/steering/select.d.ts +0 -1
- package/dist/steering/select.js +2 -2
- package/dist/steering/types.d.ts +0 -1
- package/dist/steering/types.js +0 -1
- package/dist/structured/index.d.ts +0 -1
- package/dist/structured/index.js +0 -1
- package/dist/structured/retry.d.ts +0 -1
- package/dist/structured/retry.js +0 -1
- package/dist/structured/schema.d.ts +0 -1
- package/dist/structured/schema.js +0 -1
- package/dist/timed-fetch.d.ts +12 -0
- package/dist/timed-fetch.js +83 -0
- package/dist/tools/apply-patch.d.ts +52 -0
- package/dist/tools/apply-patch.js +197 -0
- package/dist/tools/ask-user.d.ts +27 -0
- package/dist/tools/ask-user.js +32 -0
- package/dist/tools/browser-tools.d.ts +6 -7
- package/dist/tools/browser-tools.js +3 -14
- package/dist/tools/codebase-search.d.ts +4 -3
- package/dist/tools/codebase-search.js +2 -3
- package/dist/tools/command-allow.d.ts +0 -1
- package/dist/tools/command-allow.js +0 -1
- package/dist/tools/edit-file.d.ts +0 -1
- package/dist/tools/edit-file.js +5 -4
- package/dist/tools/fetch-url.d.ts +7 -1
- package/dist/tools/fetch-url.js +52 -20
- package/dist/tools/find-references.d.ts +0 -1
- package/dist/tools/find-references.js +0 -1
- package/dist/tools/find-symbol.d.ts +2 -3
- package/dist/tools/find-symbol.js +0 -1
- package/dist/tools/ignore-rules.d.ts +0 -1
- package/dist/tools/ignore-rules.js +2 -2
- package/dist/tools/index.d.ts +5 -2
- package/dist/tools/index.js +10 -2
- package/dist/tools/list-files.d.ts +0 -1
- package/dist/tools/list-files.js +0 -1
- package/dist/tools/list-symbols.d.ts +0 -1
- package/dist/tools/list-symbols.js +0 -1
- package/dist/tools/memory.d.ts +6 -7
- package/dist/tools/memory.js +0 -1
- package/dist/tools/notebook.d.ts +2 -3
- package/dist/tools/notebook.js +0 -1
- package/dist/tools/permission-rules.d.ts +32 -0
- package/dist/tools/permission-rules.js +182 -0
- package/dist/tools/policy.d.ts +0 -1
- package/dist/tools/policy.js +0 -1
- package/dist/tools/read-file.d.ts +5 -1
- package/dist/tools/read-file.js +7 -3
- package/dist/tools/read-image.d.ts +0 -1
- package/dist/tools/read-image.js +0 -1
- package/dist/tools/read-only.d.ts +1 -2
- package/dist/tools/read-only.js +2 -1
- package/dist/tools/redact.d.ts +0 -1
- package/dist/tools/redact.js +0 -1
- package/dist/tools/result-cache.d.ts +0 -1
- package/dist/tools/result-cache.js +0 -1
- package/dist/tools/run-command.d.ts +4 -3
- package/dist/tools/run-command.js +12 -9
- package/dist/tools/sandbox-loader.d.ts +0 -1
- package/dist/tools/sandbox-loader.js +3 -14
- package/dist/tools/search-files.d.ts +8 -3
- package/dist/tools/search-files.js +43 -1
- package/dist/tools/shared.d.ts +5 -1
- package/dist/tools/shared.js +30 -3
- package/dist/tools/shell-env.d.ts +7 -0
- package/dist/tools/shell-env.js +9 -0
- package/dist/tools/sub-agent-wait.d.ts +29 -0
- package/dist/tools/sub-agent-wait.js +60 -0
- package/dist/tools/sub-agent.d.ts +50 -5
- package/dist/tools/sub-agent.js +210 -126
- package/dist/tools/text-encoding.d.ts +10 -0
- package/dist/tools/text-encoding.js +40 -0
- package/dist/tools/todo.d.ts +36 -0
- package/dist/tools/todo.js +42 -0
- package/dist/tools/web-search.d.ts +0 -1
- package/dist/tools/web-search.js +0 -1
- package/dist/tools/write-file.d.ts +0 -1
- package/dist/tools/write-file.js +15 -10
- package/dist/tools/write-tools.d.ts +12 -0
- package/dist/tools/write-tools.js +18 -0
- package/dist/types.d.ts +85 -2
- package/dist/types.js +0 -1
- package/dist/verify/detect.d.ts +0 -1
- package/dist/verify/detect.js +0 -1
- package/dist/verify/index.d.ts +0 -1
- package/dist/verify/index.js +0 -1
- package/dist/worktree/branch-ops.d.ts +0 -1
- package/dist/worktree/branch-ops.js +0 -1
- package/dist/worktree/index.d.ts +0 -1
- package/dist/worktree/index.js +0 -1
- package/dist/worktree/worktree.d.ts +3 -1
- package/dist/worktree/worktree.js +22 -1
- package/package.json +3 -2
- package/dist/agent/agent.d.ts.map +0 -1
- package/dist/agent/agent.js.map +0 -1
- package/dist/agent/architect.d.ts.map +0 -1
- package/dist/agent/architect.js.map +0 -1
- package/dist/agent/cache-hints.d.ts.map +0 -1
- package/dist/agent/cache-hints.js.map +0 -1
- package/dist/agent/cost-router.d.ts.map +0 -1
- package/dist/agent/cost-router.js.map +0 -1
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/prompts.d.ts.map +0 -1
- package/dist/agent/prompts.js.map +0 -1
- package/dist/agent/think-tags.d.ts.map +0 -1
- package/dist/agent/think-tags.js.map +0 -1
- package/dist/agent/verify.d.ts.map +0 -1
- package/dist/agent/verify.js.map +0 -1
- package/dist/ai-comments/index.d.ts.map +0 -1
- package/dist/ai-comments/index.js.map +0 -1
- package/dist/attachments.d.ts.map +0 -1
- package/dist/attachments.js.map +0 -1
- package/dist/browser/cdp.d.ts.map +0 -1
- package/dist/browser/cdp.js.map +0 -1
- package/dist/browser/chrome.d.ts.map +0 -1
- package/dist/browser/chrome.js.map +0 -1
- package/dist/browser/session.d.ts.map +0 -1
- package/dist/browser/session.js.map +0 -1
- package/dist/checkpoints/index.d.ts.map +0 -1
- package/dist/checkpoints/index.js.map +0 -1
- package/dist/checkpoints/store.d.ts.map +0 -1
- package/dist/checkpoints/store.js.map +0 -1
- package/dist/checkpoints/types.d.ts.map +0 -1
- package/dist/checkpoints/types.js.map +0 -1
- package/dist/code-index/builder.d.ts.map +0 -1
- package/dist/code-index/builder.js.map +0 -1
- package/dist/code-index/index-store.d.ts.map +0 -1
- package/dist/code-index/index-store.js.map +0 -1
- package/dist/code-index/parser.d.ts.map +0 -1
- package/dist/code-index/parser.js.map +0 -1
- package/dist/code-index/types.d.ts.map +0 -1
- package/dist/code-index/types.js.map +0 -1
- package/dist/commands/custom-commands.d.ts.map +0 -1
- package/dist/commands/custom-commands.js.map +0 -1
- package/dist/config-file.d.ts.map +0 -1
- package/dist/config-file.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context/compaction.d.ts.map +0 -1
- package/dist/context/compaction.js.map +0 -1
- package/dist/context/mask.d.ts.map +0 -1
- package/dist/context/mask.js.map +0 -1
- package/dist/credentials/index.d.ts.map +0 -1
- package/dist/credentials/index.js.map +0 -1
- package/dist/credentials/types.d.ts.map +0 -1
- package/dist/credentials/types.js.map +0 -1
- package/dist/diff/index.d.ts.map +0 -1
- package/dist/diff/index.js.map +0 -1
- package/dist/diff/unified-diff.d.ts.map +0 -1
- package/dist/diff/unified-diff.js.map +0 -1
- package/dist/git/auto-commit.d.ts.map +0 -1
- package/dist/git/auto-commit.js.map +0 -1
- package/dist/git/index.d.ts.map +0 -1
- package/dist/git/index.js.map +0 -1
- package/dist/github/github-tools.d.ts.map +0 -1
- package/dist/github/github-tools.js.map +0 -1
- package/dist/hooks/agent-runner.d.ts.map +0 -1
- package/dist/hooks/agent-runner.js.map +0 -1
- package/dist/hooks/bus.d.ts.map +0 -1
- package/dist/hooks/bus.js.map +0 -1
- package/dist/hooks/config.d.ts.map +0 -1
- package/dist/hooks/config.js.map +0 -1
- package/dist/hooks/events.d.ts.map +0 -1
- package/dist/hooks/events.js.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/loader.d.ts.map +0 -1
- package/dist/hooks/loader.js.map +0 -1
- package/dist/hooks/runner.d.ts.map +0 -1
- package/dist/hooks/runner.js.map +0 -1
- package/dist/hooks/watch-coalescer.d.ts.map +0 -1
- package/dist/hooks/watch-coalescer.js.map +0 -1
- package/dist/hooks/watch-ignore.d.ts.map +0 -1
- package/dist/hooks/watch-ignore.js.map +0 -1
- package/dist/hooks/watcher.d.ts.map +0 -1
- package/dist/hooks/watcher.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lazy-model.d.ts.map +0 -1
- package/dist/lazy-model.js.map +0 -1
- package/dist/lint/auto-lint.d.ts.map +0 -1
- package/dist/lint/auto-lint.js.map +0 -1
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js.map +0 -1
- package/dist/lsp/client.d.ts.map +0 -1
- package/dist/lsp/client.js.map +0 -1
- package/dist/lsp/diagnostics.d.ts.map +0 -1
- package/dist/lsp/diagnostics.js.map +0 -1
- package/dist/lsp/index.d.ts.map +0 -1
- package/dist/lsp/index.js.map +0 -1
- package/dist/mcp/catalog.d.ts.map +0 -1
- package/dist/mcp/catalog.js.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/json-schema-to-zod.d.ts.map +0 -1
- package/dist/mcp/json-schema-to-zod.js.map +0 -1
- package/dist/mcp/manager.d.ts.map +0 -1
- package/dist/mcp/manager.js.map +0 -1
- package/dist/mcp/marketplace-types.d.ts.map +0 -1
- package/dist/mcp/marketplace-types.js.map +0 -1
- package/dist/mcp/marketplace.d.ts.map +0 -1
- package/dist/mcp/marketplace.js.map +0 -1
- package/dist/mcp/mcp-client.d.ts.map +0 -1
- package/dist/mcp/mcp-client.js.map +0 -1
- package/dist/mcp/mcp-config.d.ts.map +0 -1
- package/dist/mcp/mcp-config.js.map +0 -1
- package/dist/mcp/registry.d.ts.map +0 -1
- package/dist/mcp/registry.js.map +0 -1
- package/dist/memory/memory-store.d.ts.map +0 -1
- package/dist/memory/memory-store.js.map +0 -1
- package/dist/memory/rank.d.ts.map +0 -1
- package/dist/memory/rank.js.map +0 -1
- package/dist/memory/stale.d.ts.map +0 -1
- package/dist/memory/stale.js.map +0 -1
- package/dist/model-alias.d.ts.map +0 -1
- package/dist/model-alias.js.map +0 -1
- package/dist/model-catalog.d.ts.map +0 -1
- package/dist/model-catalog.js.map +0 -1
- package/dist/model-list.d.ts.map +0 -1
- package/dist/model-list.js.map +0 -1
- package/dist/orchestrator/board-tools.d.ts.map +0 -1
- package/dist/orchestrator/board-tools.js.map +0 -1
- package/dist/orchestrator/board.d.ts.map +0 -1
- package/dist/orchestrator/board.js.map +0 -1
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/index.js.map +0 -1
- package/dist/orchestrator/orchestrator.d.ts.map +0 -1
- package/dist/orchestrator/orchestrator.js.map +0 -1
- package/dist/orchestrator/router.d.ts.map +0 -1
- package/dist/orchestrator/router.js.map +0 -1
- package/dist/orchestrator/specialists-registry.d.ts.map +0 -1
- package/dist/orchestrator/specialists-registry.js.map +0 -1
- package/dist/orchestrator/specialists.d.ts.map +0 -1
- package/dist/orchestrator/specialists.js.map +0 -1
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/orchestrator/types.js.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/install.d.ts.map +0 -1
- package/dist/plugins/install.js.map +0 -1
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js.map +0 -1
- package/dist/policy/audit.d.ts.map +0 -1
- package/dist/policy/audit.js.map +0 -1
- package/dist/policy/policy.d.ts.map +0 -1
- package/dist/policy/policy.js.map +0 -1
- package/dist/policy/proxy.d.ts.map +0 -1
- package/dist/policy/proxy.js.map +0 -1
- package/dist/pricing.d.ts.map +0 -1
- package/dist/pricing.js.map +0 -1
- package/dist/providers.d.ts.map +0 -1
- package/dist/providers.js.map +0 -1
- package/dist/repomap/index.d.ts.map +0 -1
- package/dist/repomap/index.js.map +0 -1
- package/dist/repomap/repo-map.d.ts.map +0 -1
- package/dist/repomap/repo-map.js.map +0 -1
- package/dist/semantic/chunker.d.ts.map +0 -1
- package/dist/semantic/chunker.js.map +0 -1
- package/dist/semantic/embedder.d.ts.map +0 -1
- package/dist/semantic/embedder.js.map +0 -1
- package/dist/semantic/semantic-index.d.ts.map +0 -1
- package/dist/semantic/semantic-index.js.map +0 -1
- package/dist/semantic/vector-store.d.ts.map +0 -1
- package/dist/semantic/vector-store.js.map +0 -1
- package/dist/sessions/index.d.ts.map +0 -1
- package/dist/sessions/index.js.map +0 -1
- package/dist/sessions/search.d.ts.map +0 -1
- package/dist/sessions/search.js.map +0 -1
- package/dist/sessions/session-export.d.ts.map +0 -1
- package/dist/sessions/session-export.js.map +0 -1
- package/dist/sessions/session-store.d.ts.map +0 -1
- package/dist/sessions/session-store.js.map +0 -1
- package/dist/sessions/watch.d.ts.map +0 -1
- package/dist/sessions/watch.js.map +0 -1
- package/dist/settings-export.d.ts.map +0 -1
- package/dist/settings-export.js.map +0 -1
- package/dist/skills/activator.d.ts.map +0 -1
- package/dist/skills/activator.js.map +0 -1
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/loader.d.ts.map +0 -1
- package/dist/skills/loader.js.map +0 -1
- package/dist/skills/marketplace-types.d.ts.map +0 -1
- package/dist/skills/marketplace-types.js.map +0 -1
- package/dist/skills/marketplace.d.ts.map +0 -1
- package/dist/skills/marketplace.js.map +0 -1
- package/dist/skills/parser.d.ts.map +0 -1
- package/dist/skills/parser.js.map +0 -1
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/skills/types.js.map +0 -1
- package/dist/specs/generate.d.ts.map +0 -1
- package/dist/specs/generate.js.map +0 -1
- package/dist/specs/index.d.ts.map +0 -1
- package/dist/specs/index.js.map +0 -1
- package/dist/specs/store.d.ts.map +0 -1
- package/dist/specs/store.js.map +0 -1
- package/dist/specs/sync.d.ts.map +0 -1
- package/dist/specs/sync.js.map +0 -1
- package/dist/specs/tasks-parser.d.ts.map +0 -1
- package/dist/specs/tasks-parser.js.map +0 -1
- package/dist/specs/types.d.ts.map +0 -1
- package/dist/specs/types.js.map +0 -1
- package/dist/steering/glob.d.ts.map +0 -1
- package/dist/steering/glob.js.map +0 -1
- package/dist/steering/index.d.ts.map +0 -1
- package/dist/steering/index.js.map +0 -1
- package/dist/steering/loader.d.ts.map +0 -1
- package/dist/steering/loader.js.map +0 -1
- package/dist/steering/project-instructions.d.ts.map +0 -1
- package/dist/steering/project-instructions.js.map +0 -1
- package/dist/steering/select.d.ts.map +0 -1
- package/dist/steering/select.js.map +0 -1
- package/dist/steering/types.d.ts.map +0 -1
- package/dist/steering/types.js.map +0 -1
- package/dist/structured/index.d.ts.map +0 -1
- package/dist/structured/index.js.map +0 -1
- package/dist/structured/retry.d.ts.map +0 -1
- package/dist/structured/retry.js.map +0 -1
- package/dist/structured/schema.d.ts.map +0 -1
- package/dist/structured/schema.js.map +0 -1
- package/dist/tools/browser-tools.d.ts.map +0 -1
- package/dist/tools/browser-tools.js.map +0 -1
- package/dist/tools/codebase-search.d.ts.map +0 -1
- package/dist/tools/codebase-search.js.map +0 -1
- package/dist/tools/command-allow.d.ts.map +0 -1
- package/dist/tools/command-allow.js.map +0 -1
- package/dist/tools/edit-file.d.ts.map +0 -1
- package/dist/tools/edit-file.js.map +0 -1
- package/dist/tools/fetch-url.d.ts.map +0 -1
- package/dist/tools/fetch-url.js.map +0 -1
- package/dist/tools/find-references.d.ts.map +0 -1
- package/dist/tools/find-references.js.map +0 -1
- package/dist/tools/find-symbol.d.ts.map +0 -1
- package/dist/tools/find-symbol.js.map +0 -1
- package/dist/tools/ignore-rules.d.ts.map +0 -1
- package/dist/tools/ignore-rules.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/list-files.d.ts.map +0 -1
- package/dist/tools/list-files.js.map +0 -1
- package/dist/tools/list-symbols.d.ts.map +0 -1
- package/dist/tools/list-symbols.js.map +0 -1
- package/dist/tools/memory.d.ts.map +0 -1
- package/dist/tools/memory.js.map +0 -1
- package/dist/tools/notebook.d.ts.map +0 -1
- package/dist/tools/notebook.js.map +0 -1
- package/dist/tools/policy.d.ts.map +0 -1
- package/dist/tools/policy.js.map +0 -1
- package/dist/tools/read-file.d.ts.map +0 -1
- package/dist/tools/read-file.js.map +0 -1
- package/dist/tools/read-image.d.ts.map +0 -1
- package/dist/tools/read-image.js.map +0 -1
- package/dist/tools/read-only.d.ts.map +0 -1
- package/dist/tools/read-only.js.map +0 -1
- package/dist/tools/redact.d.ts.map +0 -1
- package/dist/tools/redact.js.map +0 -1
- package/dist/tools/result-cache.d.ts.map +0 -1
- package/dist/tools/result-cache.js.map +0 -1
- package/dist/tools/run-command.d.ts.map +0 -1
- package/dist/tools/run-command.js.map +0 -1
- package/dist/tools/sandbox-loader.d.ts.map +0 -1
- package/dist/tools/sandbox-loader.js.map +0 -1
- package/dist/tools/search-files.d.ts.map +0 -1
- package/dist/tools/search-files.js.map +0 -1
- package/dist/tools/shared.d.ts.map +0 -1
- package/dist/tools/shared.js.map +0 -1
- package/dist/tools/sub-agent.d.ts.map +0 -1
- package/dist/tools/sub-agent.js.map +0 -1
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js.map +0 -1
- package/dist/tools/write-file.d.ts.map +0 -1
- package/dist/tools/write-file.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/verify/detect.d.ts.map +0 -1
- package/dist/verify/detect.js.map +0 -1
- package/dist/verify/index.d.ts.map +0 -1
- package/dist/verify/index.js.map +0 -1
- package/dist/worktree/branch-ops.d.ts.map +0 -1
- package/dist/worktree/branch-ops.js.map +0 -1
- package/dist/worktree/index.d.ts.map +0 -1
- package/dist/worktree/index.js.map +0 -1
- package/dist/worktree/worktree.d.ts.map +0 -1
- package/dist/worktree/worktree.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const params = z.object({
|
|
3
|
+
ids: z
|
|
4
|
+
.array(z.string().min(1).max(40))
|
|
5
|
+
.max(20)
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('Ids from sub_agent { background: true } to wait for. Omit to wait for every background agent still running.'),
|
|
8
|
+
timeout_seconds: z
|
|
9
|
+
.number()
|
|
10
|
+
.min(0)
|
|
11
|
+
.max(900)
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('How long to wait before giving up and reporting what is still running. Default 300. 0 only looks.'),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Collect the answers of sub-agents started with `sub_agent { background: true }`. Waits until they finish or the
|
|
17
|
+
* timeout passes, whichever is first; a run that is still going is reported as running and can be waited for again.
|
|
18
|
+
*/
|
|
19
|
+
export const subAgentWaitTool = {
|
|
20
|
+
name: 'sub_agent_wait',
|
|
21
|
+
description: 'Wait for background sub-agents (started with sub_agent { background: true }) and return their answers. A run still going when the timeout passes is reported as running.',
|
|
22
|
+
parameters: params,
|
|
23
|
+
execute: async (args, ctx) => {
|
|
24
|
+
const bg = ctx.background;
|
|
25
|
+
if (!bg)
|
|
26
|
+
throw new Error('Background agents are not available here.');
|
|
27
|
+
const valid = params.parse(args);
|
|
28
|
+
const unknown = (valid.ids ?? []).filter((id) => !bg.get(id));
|
|
29
|
+
const known = (valid.ids ?? []).filter((id) => bg.get(id));
|
|
30
|
+
if (valid.ids && known.length === 0) {
|
|
31
|
+
return { agents: [], stillRunning: 0, message: `No background agent with id ${unknown.join(', ')}.` };
|
|
32
|
+
}
|
|
33
|
+
if (!valid.ids && bg.list().filter((a) => a.state === 'running').length === 0) {
|
|
34
|
+
// Nothing running: report what has finished, if anything has.
|
|
35
|
+
const finished = bg.takeUndelivered();
|
|
36
|
+
return {
|
|
37
|
+
agents: finished.map(view),
|
|
38
|
+
stillRunning: 0,
|
|
39
|
+
...(finished.length === 0 ? { message: 'There are no background agents running.' } : {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const timeoutMs = (valid.timeout_seconds ?? 300) * 1000;
|
|
43
|
+
const got = await bg.wait(valid.ids ? known : undefined, { timeoutMs, ...(ctx.abortSignal ? { signal: ctx.abortSignal } : {}) });
|
|
44
|
+
bg.markDelivered(got.map((a) => a.id));
|
|
45
|
+
return {
|
|
46
|
+
agents: got.map(view),
|
|
47
|
+
stillRunning: got.filter((a) => a.state === 'running').length,
|
|
48
|
+
...(unknown.length ? { message: `No background agent with id ${unknown.join(', ')}.` } : {}),
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
function view(a) {
|
|
53
|
+
return {
|
|
54
|
+
id: a.id,
|
|
55
|
+
task: a.task,
|
|
56
|
+
state: a.state,
|
|
57
|
+
...(a.result?.finalText ? { finalText: a.result.finalText } : {}),
|
|
58
|
+
...(a.error ? { error: a.error } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type
|
|
2
|
+
import { type AgentDef } from '../agents/agent-files.js';
|
|
3
|
+
import type { AgentConfig, ModelConfig, ToolContext, ToolDefinition } from '../types.js';
|
|
3
4
|
declare const params: z.ZodObject<{
|
|
4
5
|
/** The task for the sub-agent to perform. Free-form text. */
|
|
5
6
|
task: z.ZodString;
|
|
7
|
+
/** Name of an agent file (`.forge/agents/<name>.md`) to run as: its prompt, tools, model and step cap. */
|
|
8
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
6
9
|
/** Hard cap on iterations for the sub-agent. Default 10. */
|
|
7
10
|
max_iterations: z.ZodOptional<z.ZodNumber>;
|
|
8
11
|
/**
|
|
@@ -51,23 +54,39 @@ declare const params: z.ZodObject<{
|
|
|
51
54
|
* won't collide.
|
|
52
55
|
*/
|
|
53
56
|
cleanup_branch: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Start the child and return at once. The child keeps working while the parent continues; collect its answer with
|
|
59
|
+
* `sub_agent_wait`. Only where the surface can show background runs; elsewhere the child runs to completion as usual.
|
|
60
|
+
*/
|
|
61
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
54
62
|
}, "strip", z.ZodTypeAny, {
|
|
55
63
|
task: string;
|
|
64
|
+
agent?: string | undefined;
|
|
56
65
|
cwd?: string | undefined;
|
|
57
|
-
max_iterations?: number | undefined;
|
|
58
66
|
auto?: boolean | undefined;
|
|
67
|
+
background?: boolean | undefined;
|
|
68
|
+
max_iterations?: number | undefined;
|
|
59
69
|
use_worktree?: boolean | undefined;
|
|
60
70
|
worktree_label?: string | undefined;
|
|
61
71
|
cleanup_branch?: boolean | undefined;
|
|
62
72
|
}, {
|
|
63
73
|
task: string;
|
|
74
|
+
agent?: string | undefined;
|
|
64
75
|
cwd?: string | undefined;
|
|
65
|
-
max_iterations?: number | undefined;
|
|
66
76
|
auto?: boolean | undefined;
|
|
77
|
+
background?: boolean | undefined;
|
|
78
|
+
max_iterations?: number | undefined;
|
|
67
79
|
use_worktree?: boolean | undefined;
|
|
68
80
|
worktree_label?: string | undefined;
|
|
69
81
|
cleanup_branch?: boolean | undefined;
|
|
70
82
|
}>;
|
|
83
|
+
/** What `sub_agent { background: true }` returns instead of a result. */
|
|
84
|
+
export interface SubAgentStarted {
|
|
85
|
+
started: true;
|
|
86
|
+
id: string;
|
|
87
|
+
task: string;
|
|
88
|
+
message: string;
|
|
89
|
+
}
|
|
71
90
|
export interface SubAgentResult {
|
|
72
91
|
task: string;
|
|
73
92
|
finalText: string;
|
|
@@ -103,6 +122,32 @@ export interface SubAgentResult {
|
|
|
103
122
|
* tools unless the parent explicitly opts in via the `auto` parameter.
|
|
104
123
|
* - The sub-agent inherits the parent's cwd and model unless overridden.
|
|
105
124
|
*/
|
|
106
|
-
export declare const subAgentTool: ToolDefinition<z.infer<typeof params>, SubAgentResult>;
|
|
125
|
+
export declare const subAgentTool: ToolDefinition<z.infer<typeof params>, SubAgentResult | SubAgentStarted>;
|
|
126
|
+
/**
|
|
127
|
+
* What a child runs with: the tools it may see, its model, step cap and system prompt. Without an agent file this is
|
|
128
|
+
* the old behaviour (every tool but `sub_agent`, the sub-agent or parent model, default cap). `sub_agent` is never
|
|
129
|
+
* offered to a child, whatever the file says.
|
|
130
|
+
*/
|
|
131
|
+
export declare function childSetupFor<T extends {
|
|
132
|
+
name: string;
|
|
133
|
+
}>(def: AgentDef | undefined, tools: readonly T[], ctx: Pick<ToolContext, 'subAgentModel' | 'parentModel'>, requestedIterations: number | undefined): {
|
|
134
|
+
tools: T[];
|
|
135
|
+
model: ModelConfig;
|
|
136
|
+
maxIterations: number;
|
|
137
|
+
systemPrompt?: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The child's Agent configuration. It carries the limits the person set for the parent (permission rules, tool
|
|
141
|
+
* sandbox): a child started with `auto: true` must not be a way around an `edit: deny` rule or a denied tool.
|
|
142
|
+
*/
|
|
143
|
+
export declare function childAgentConfig(setup: {
|
|
144
|
+
tools: readonly unknown[];
|
|
145
|
+
model: ModelConfig;
|
|
146
|
+
maxIterations: number;
|
|
147
|
+
systemPrompt?: string;
|
|
148
|
+
}, ctx: Pick<ToolContext, 'autoApproveTools' | 'permissionRules' | 'toolSandbox'>, cwd: string, auto: boolean): AgentConfig;
|
|
149
|
+
/** What a child runs without asking: what the parent does, else the read-only tools. Destructive tools still never run unasked. */
|
|
150
|
+
export declare function childAutoApprove(ctx: Pick<ToolContext, 'autoApproveTools'>): string[];
|
|
151
|
+
/** The configured sub-agent model, else the parent's, else a last-resort default. */
|
|
152
|
+
export declare function childModelFor(ctx: Pick<ToolContext, 'subAgentModel' | 'parentModel'>): ModelConfig;
|
|
107
153
|
export {};
|
|
108
|
-
//# sourceMappingURL=sub-agent.d.ts.map
|
package/dist/tools/sub-agent.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { registeredAgent, registeredAgents } from '../agents/agent-files.js';
|
|
2
3
|
import { Agent } from '../agent/agent.js';
|
|
4
|
+
import { applyResolved, resolveModelAlias } from '../model-alias.js';
|
|
3
5
|
import { WorktreeError, WorktreeManager } from '../worktree/index.js';
|
|
4
6
|
import { BUILTIN_TOOLS } from './index.js';
|
|
7
|
+
import { READ_ONLY_TOOLS } from './read-only.js';
|
|
5
8
|
import { resolveAndCheckPath } from './shared.js';
|
|
6
9
|
const params = z.object({
|
|
7
10
|
/** The task for the sub-agent to perform. Free-form text. */
|
|
@@ -10,6 +13,13 @@ const params = z.object({
|
|
|
10
13
|
.min(1)
|
|
11
14
|
.max(20_000)
|
|
12
15
|
.describe('Plain-English task for the sub-agent to perform.'),
|
|
16
|
+
/** Name of an agent file (`.forge/agents/<name>.md`) to run as: its prompt, tools, model and step cap. */
|
|
17
|
+
agent: z
|
|
18
|
+
.string()
|
|
19
|
+
.min(1)
|
|
20
|
+
.max(64)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Run as the named agent defined in .forge/agents (its prompt, tools and model). Omit for a general helper.'),
|
|
13
23
|
/** Hard cap on iterations for the sub-agent. Default 10. */
|
|
14
24
|
max_iterations: z
|
|
15
25
|
.number()
|
|
@@ -81,6 +91,14 @@ const params = z.object({
|
|
|
81
91
|
.boolean()
|
|
82
92
|
.optional()
|
|
83
93
|
.describe('When use_worktree is true: also delete the auto-created branch alongside the worktree (skipped if another worktree still uses it). Default true. v2.14.'),
|
|
94
|
+
/**
|
|
95
|
+
* Start the child and return at once. The child keeps working while the parent continues; collect its answer with
|
|
96
|
+
* `sub_agent_wait`. Only where the surface can show background runs; elsewhere the child runs to completion as usual.
|
|
97
|
+
*/
|
|
98
|
+
background: z
|
|
99
|
+
.boolean()
|
|
100
|
+
.optional()
|
|
101
|
+
.describe('Start the sub-agent and return immediately with an id; keep working, then collect the answer with sub_agent_wait. Use it for independent work that does not block your next step. Default false.'),
|
|
84
102
|
});
|
|
85
103
|
const DEFAULT_MAX_ITERATIONS = 10;
|
|
86
104
|
/**
|
|
@@ -89,7 +107,7 @@ const DEFAULT_MAX_ITERATIONS = 10;
|
|
|
89
107
|
* passing `allowSubAgent: true` via context if you really want it)
|
|
90
108
|
* - nothing else: the sub-agent gets the full built-in toolset.
|
|
91
109
|
*/
|
|
92
|
-
const FORBIDDEN_TOOLS = new Set(['sub_agent']);
|
|
110
|
+
const FORBIDDEN_TOOLS = new Set(['sub_agent', 'sub_agent_wait']);
|
|
93
111
|
/**
|
|
94
112
|
* Delegate a task to a child agent. The child runs synchronously and its
|
|
95
113
|
* final text + run statistics are returned to the parent. Useful for
|
|
@@ -122,144 +140,210 @@ export const subAgentTool = {
|
|
|
122
140
|
throw new Error(`Invalid sub_agent arguments: ${parsed.error.message}`);
|
|
123
141
|
}
|
|
124
142
|
const valid = parsed.data;
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
const agentDef = valid.agent ? registeredAgent(valid.agent) : undefined;
|
|
144
|
+
if (valid.agent && !agentDef) {
|
|
145
|
+
const known = registeredAgents().map((a) => a.name);
|
|
146
|
+
throw new Error(`Unknown agent "${valid.agent}". ${known.length ? `Known agents: ${known.join(', ')}.` : 'No agents are defined in .forge/agents.'}`);
|
|
147
|
+
}
|
|
148
|
+
if (valid.background && ctx.background) {
|
|
149
|
+
// The child gets its own abort signal (the person stops it from the strip) and reports to the strip, not to the
|
|
150
|
+
// run that started it, which may be over by the time the child speaks.
|
|
151
|
+
const { abortSignal: _parentSignal, onChildProgress: _progress, onProgress: _line, ...rest } = ctx;
|
|
152
|
+
const started = ctx.background.start({
|
|
153
|
+
task: valid.task,
|
|
154
|
+
agent: valid.agent,
|
|
155
|
+
run: (signal) => runSubAgent(valid, agentDef, { ...rest, abortSignal: signal }),
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
started: true,
|
|
159
|
+
id: started.id,
|
|
160
|
+
task: valid.task,
|
|
161
|
+
message: `Started background agent ${started.id}. Carry on with other work; call sub_agent_wait to collect its answer. Do not start it again.`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return runSubAgent(valid, agentDef, ctx);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
/** One child run, to completion: worktree setup, the child agent, cleanup, and the result. */
|
|
168
|
+
async function runSubAgent(valid, agentDef, ctx) {
|
|
169
|
+
// Security: `cwd` becomes the CHILD agent's own sandbox root: an
|
|
170
|
+
// unvalidated override would let a caller point the child anywhere on
|
|
171
|
+
// disk (e.g. cwd: "C:\\Users\\victim\\Documents") with none of the
|
|
172
|
+
// approval gating `run_command`/`sub_agent` itself otherwise gets.
|
|
173
|
+
// resolveAndCheckPath resolves relative to the parent's own `ctx.cwd`
|
|
174
|
+
// and throws if the result escapes it (or violates `ctx.policy`),
|
|
175
|
+
// which matches this tool's documented intent: "operate on a
|
|
176
|
+
// subdirectory": while still accepting the common case.
|
|
177
|
+
const baseCwd = valid.cwd ? resolveAndCheckPath(valid.cwd, ctx) : ctx.cwd;
|
|
178
|
+
const auto = valid.auto ?? false;
|
|
179
|
+
// Worktree setup. We do this *before* constructing the child Agent
|
|
180
|
+
// so the child runs with the worktree path as its cwd. On any
|
|
181
|
+
// error during creation, we fall back to plain cwd mode with a
|
|
182
|
+
// stderr warning: the user gets a working sub-agent instead of
|
|
183
|
+
// an opaque failure.
|
|
184
|
+
let worktreeInfo;
|
|
185
|
+
let manager;
|
|
186
|
+
if (valid.use_worktree) {
|
|
187
|
+
const repoRoot = await WorktreeManager.resolveRepoRoot(baseCwd);
|
|
188
|
+
if (!repoRoot) {
|
|
189
|
+
// Not a git repo: warn but proceed without isolation. Better
|
|
190
|
+
// than failing outright; the user can fix the repo separately.
|
|
191
|
+
ctx.onProgress?.(`sub_agent: use_worktree requested but ${baseCwd} is not a git repo; running without isolation`);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
try {
|
|
195
|
+
manager = new WorktreeManager(repoRoot);
|
|
196
|
+
// Clean up any leftover worktrees from a previous crashed
|
|
197
|
+
// session before we allocate a new one. Best-effort.
|
|
198
|
+
await manager.pruneStale();
|
|
199
|
+
worktreeInfo = await manager.create({
|
|
200
|
+
...(valid.worktree_label ? { label: valid.worktree_label } : {}),
|
|
201
|
+
});
|
|
202
|
+
ctx.onProgress?.(`sub_agent: isolated in worktree ${worktreeInfo.path} (branch ${worktreeInfo.branch})`);
|
|
149
203
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// Clean up any leftover worktrees from a previous crashed
|
|
154
|
-
// session before we allocate a new one. Best-effort.
|
|
155
|
-
await manager.pruneStale();
|
|
156
|
-
worktreeInfo = await manager.create({
|
|
157
|
-
...(valid.worktree_label ? { label: valid.worktree_label } : {}),
|
|
158
|
-
});
|
|
159
|
-
ctx.onProgress?.(`sub_agent: isolated in worktree ${worktreeInfo.path} (branch ${worktreeInfo.branch})`);
|
|
204
|
+
catch (err) {
|
|
205
|
+
if (err instanceof WorktreeError) {
|
|
206
|
+
ctx.onProgress?.(`sub_agent: worktree setup failed (${err.message}); running without isolation`);
|
|
160
207
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
ctx.onProgress?.(`sub_agent: worktree setup failed (${err.message}); running without isolation`);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
throw err;
|
|
167
|
-
}
|
|
208
|
+
else {
|
|
209
|
+
throw err;
|
|
168
210
|
}
|
|
169
211
|
}
|
|
170
212
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
213
|
+
}
|
|
214
|
+
const cwd = worktreeInfo ? worktreeInfo.path : baseCwd;
|
|
215
|
+
const setup = childSetupFor(agentDef, BUILTIN_TOOLS, ctx, valid.max_iterations);
|
|
216
|
+
const maxIterations = setup.maxIterations;
|
|
217
|
+
// The sub-agent inherits our system prompt by default; users can override
|
|
218
|
+
// via the AGENT_CONFIG system prompt if needed. For the v1 we keep the
|
|
219
|
+
// child on the same system prompt so its behavior matches the parent's.
|
|
220
|
+
const child = new Agent(childAgentConfig({ ...setup, maxIterations }, ctx, cwd, auto));
|
|
221
|
+
const toolsUsed = [];
|
|
222
|
+
const started = Date.now();
|
|
223
|
+
let result;
|
|
224
|
+
try {
|
|
225
|
+
result = await child.run({
|
|
226
|
+
task: valid.task,
|
|
227
|
+
...(ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}),
|
|
228
|
+
onEvent: (event) => {
|
|
229
|
+
if (event.type === 'tool_call') {
|
|
230
|
+
toolsUsed.push(event.name);
|
|
231
|
+
}
|
|
232
|
+
// Stream a compact progress line through the parent's context so the
|
|
233
|
+
// user can see the child is making progress in interactive mode.
|
|
234
|
+
ctx.onChildProgress?.({
|
|
235
|
+
tool: 'sub_agent',
|
|
236
|
+
task: valid.task,
|
|
237
|
+
event,
|
|
238
|
+
});
|
|
239
|
+
},
|
|
184
240
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
// behind is pure clutter. The branch-deletion logic in
|
|
214
|
-
// `WorktreeManager.remove` is safety-checked: it refuses to
|
|
215
|
-
// delete a branch that another worktree still uses, so two
|
|
216
|
-
// concurrent sub-agents on the same branch won't collide.
|
|
217
|
-
if (manager && worktreeInfo) {
|
|
218
|
-
// Optional with z.boolean().optional() → default true when
|
|
219
|
-
// the caller omits the key. Using `.default(true)` on the
|
|
220
|
-
// schema would mismatch ToolDefinition<TArgs>'s expected
|
|
221
|
-
// input type (the schema's input side stays `boolean |
|
|
222
|
-
// undefined` while the inferred output becomes `boolean`),
|
|
223
|
-
// so we keep the default in code.
|
|
224
|
-
const cleanupBranch = valid.cleanup_branch ?? true;
|
|
225
|
-
try {
|
|
226
|
-
const result = await manager.remove(worktreeInfo.path, {
|
|
227
|
-
force: true,
|
|
228
|
-
deleteBranch: cleanupBranch,
|
|
229
|
-
});
|
|
230
|
-
if (cleanupBranch && result.branchDeleted && ctx.onProgress) {
|
|
231
|
-
ctx.onProgress(`sub_agent: removed worktree and branch ${result.branch}`);
|
|
232
|
-
}
|
|
233
|
-
else if (cleanupBranch && !result.branchDeleted && ctx.onProgress) {
|
|
234
|
-
ctx.onProgress(`sub_agent: removed worktree (kept branch ${result.branch ?? '(detached)'}: still in use)`);
|
|
235
|
-
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
// Best-effort cleanup. We always try to remove the worktree,
|
|
244
|
+
// even on error / abort, so a crashed sub-agent doesn't leak a
|
|
245
|
+
// directory. Force=true so uncommitted changes don't block us.
|
|
246
|
+
//
|
|
247
|
+
// v2.14: also delete the auto-created `forge/<label>-<sha>`
|
|
248
|
+
// branch unless the caller explicitly turned it off. Most
|
|
249
|
+
// sub-agents finish their work cleanly, so leaving the branch
|
|
250
|
+
// behind is pure clutter. The branch-deletion logic in
|
|
251
|
+
// `WorktreeManager.remove` is safety-checked: it refuses to
|
|
252
|
+
// delete a branch that another worktree still uses, so two
|
|
253
|
+
// concurrent sub-agents on the same branch won't collide.
|
|
254
|
+
if (manager && worktreeInfo) {
|
|
255
|
+
// Optional with z.boolean().optional() → default true when
|
|
256
|
+
// the caller omits the key. Using `.default(true)` on the
|
|
257
|
+
// schema would mismatch ToolDefinition<TArgs>'s expected
|
|
258
|
+
// input type (the schema's input side stays `boolean |
|
|
259
|
+
// undefined` while the inferred output becomes `boolean`),
|
|
260
|
+
// so we keep the default in code.
|
|
261
|
+
const cleanupBranch = valid.cleanup_branch ?? true;
|
|
262
|
+
try {
|
|
263
|
+
const result = await manager.remove(worktreeInfo.path, {
|
|
264
|
+
force: true,
|
|
265
|
+
deleteBranch: cleanupBranch,
|
|
266
|
+
});
|
|
267
|
+
if (cleanupBranch && result.branchDeleted && ctx.onProgress) {
|
|
268
|
+
ctx.onProgress(`sub_agent: removed worktree and branch ${result.branch}`);
|
|
236
269
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// Just surface it through onProgress so the user can see it.
|
|
240
|
-
ctx.onProgress?.(`sub_agent: warning: failed to remove worktree ${worktreeInfo.path}: ${cleanupErr.message}`);
|
|
270
|
+
else if (cleanupBranch && !result.branchDeleted && ctx.onProgress) {
|
|
271
|
+
ctx.onProgress(`sub_agent: removed worktree (kept branch ${result.branch ?? '(detached)'}: still in use)`);
|
|
241
272
|
}
|
|
242
273
|
}
|
|
274
|
+
catch (cleanupErr) {
|
|
275
|
+
// Don't mask the agent's actual error with a cleanup error.
|
|
276
|
+
// Just surface it through onProgress so the user can see it.
|
|
277
|
+
ctx.onProgress?.(`sub_agent: warning: failed to remove worktree ${worktreeInfo.path}: ${cleanupErr.message}`);
|
|
278
|
+
}
|
|
243
279
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
}
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
task: valid.task,
|
|
283
|
+
finalText: result.finalText,
|
|
284
|
+
iterations: result.iterations,
|
|
285
|
+
reason: result.reason,
|
|
286
|
+
inputTokens: result.inputTokens,
|
|
287
|
+
outputTokens: result.outputTokens,
|
|
288
|
+
durationMs: Date.now() - started,
|
|
289
|
+
toolsUsed,
|
|
290
|
+
...(worktreeInfo
|
|
291
|
+
? { worktreePath: worktreeInfo.path, worktreeBranch: worktreeInfo.branch }
|
|
292
|
+
: {}),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* What a child runs with: the tools it may see, its model, step cap and system prompt. Without an agent file this is
|
|
297
|
+
* the old behaviour (every tool but `sub_agent`, the sub-agent or parent model, default cap). `sub_agent` is never
|
|
298
|
+
* offered to a child, whatever the file says.
|
|
299
|
+
*/
|
|
300
|
+
export function childSetupFor(def, tools, ctx, requestedIterations) {
|
|
301
|
+
const denied = new Set([...FORBIDDEN_TOOLS, ...(def?.deny ?? [])]);
|
|
302
|
+
const allow = def && def.tools.length > 0 ? new Set(def.tools) : undefined;
|
|
303
|
+
const base = childModelFor(ctx);
|
|
304
|
+
let model = base;
|
|
305
|
+
if (def?.model)
|
|
306
|
+
model = applyResolved(base, resolveModelAlias(def.model, undefined, base.provider));
|
|
307
|
+
if (def?.temperature !== undefined)
|
|
308
|
+
model = { ...model, temperature: def.temperature };
|
|
309
|
+
return {
|
|
310
|
+
tools: tools.filter((t) => !denied.has(t.name) && (!allow || allow.has(t.name))),
|
|
311
|
+
model,
|
|
312
|
+
maxIterations: Math.min(requestedIterations ?? def?.steps ?? DEFAULT_MAX_ITERATIONS, 50),
|
|
313
|
+
...(def?.prompt ? { systemPrompt: def.prompt } : {}),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The child's Agent configuration. It carries the limits the person set for the parent (permission rules, tool
|
|
318
|
+
* sandbox): a child started with `auto: true` must not be a way around an `edit: deny` rule or a denied tool.
|
|
319
|
+
*/
|
|
320
|
+
export function childAgentConfig(setup, ctx, cwd, auto) {
|
|
321
|
+
return {
|
|
322
|
+
model: setup.model,
|
|
323
|
+
cwd,
|
|
324
|
+
auto,
|
|
325
|
+
maxIterations: setup.maxIterations,
|
|
326
|
+
...(setup.systemPrompt ? { systemPrompt: setup.systemPrompt } : {}),
|
|
327
|
+
// A child has no one to ask, so without this every tool that needs approval is refused, even reading a folder.
|
|
328
|
+
autoApproveTools: childAutoApprove(ctx),
|
|
329
|
+
...(ctx.permissionRules ? { permissionRules: ctx.permissionRules } : {}),
|
|
330
|
+
...(ctx.toolSandbox ? { toolSandbox: ctx.toolSandbox } : {}),
|
|
331
|
+
// The child's toolset is the built-in set minus sub_agent, narrowed by the agent file when one is named.
|
|
332
|
+
disableBuiltins: true,
|
|
333
|
+
extraTools: setup.tools,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
/** What a child runs without asking: what the parent does, else the read-only tools. Destructive tools still never run unasked. */
|
|
337
|
+
export function childAutoApprove(ctx) {
|
|
338
|
+
return ctx.autoApproveTools ? [...ctx.autoApproveTools] : [...READ_ONLY_TOOLS];
|
|
339
|
+
}
|
|
340
|
+
/** The configured sub-agent model, else the parent's, else a last-resort default. */
|
|
341
|
+
export function childModelFor(ctx) {
|
|
342
|
+
return ctx.subAgentModel ?? ctx.parentModel ?? fallbackModel();
|
|
343
|
+
}
|
|
259
344
|
function fallbackModel() {
|
|
260
345
|
// Best-effort: use whatever the SDK resolves from env. The tool requires
|
|
261
346
|
// a model config to construct an Agent; in practice the parent's config
|
|
262
347
|
// is always passed through `ctx.parentModel`.
|
|
263
348
|
return { provider: 'anthropic', model: 'claude-sonnet-4-5' };
|
|
264
349
|
}
|
|
265
|
-
//# sourceMappingURL=sub-agent.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type TextEncoding = 'utf8' | 'utf8-bom' | 'utf16le' | 'utf16be';
|
|
2
|
+
/**
|
|
3
|
+
* Decode a file's bytes by its byte-order mark. Without one the file is read as UTF-8. The mark itself is not part
|
|
4
|
+
* of the text, and `encodeText` puts it back, so an edit never changes the encoding of a file.
|
|
5
|
+
*/
|
|
6
|
+
export declare function decodeText(buf: Buffer): {
|
|
7
|
+
text: string;
|
|
8
|
+
encoding: TextEncoding;
|
|
9
|
+
};
|
|
10
|
+
export declare function encodeText(text: string, encoding: TextEncoding): Buffer;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode a file's bytes by its byte-order mark. Without one the file is read as UTF-8. The mark itself is not part
|
|
3
|
+
* of the text, and `encodeText` puts it back, so an edit never changes the encoding of a file.
|
|
4
|
+
*/
|
|
5
|
+
export function decodeText(buf) {
|
|
6
|
+
if (buf.length >= 3 && buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf)
|
|
7
|
+
return { text: buf.subarray(3).toString('utf8'), encoding: 'utf8-bom' };
|
|
8
|
+
if (buf.length >= 2 && buf[0] === 0xff && buf[1] === 0xfe)
|
|
9
|
+
return { text: buf.subarray(2).toString('utf16le'), encoding: 'utf16le' };
|
|
10
|
+
if (buf.length >= 2 && buf[0] === 0xfe && buf[1] === 0xff) {
|
|
11
|
+
const body = Buffer.from(buf.subarray(2));
|
|
12
|
+
// Swap each byte pair to little endian, then decode.
|
|
13
|
+
for (let i = 0; i + 1 < body.length; i += 2) {
|
|
14
|
+
const a = body[i];
|
|
15
|
+
body[i] = body[i + 1];
|
|
16
|
+
body[i + 1] = a;
|
|
17
|
+
}
|
|
18
|
+
return { text: body.toString('utf16le'), encoding: 'utf16be' };
|
|
19
|
+
}
|
|
20
|
+
return { text: buf.toString('utf8'), encoding: 'utf8' };
|
|
21
|
+
}
|
|
22
|
+
export function encodeText(text, encoding) {
|
|
23
|
+
switch (encoding) {
|
|
24
|
+
case 'utf8-bom':
|
|
25
|
+
return Buffer.concat([Buffer.from([0xef, 0xbb, 0xbf]), Buffer.from(text, 'utf8')]);
|
|
26
|
+
case 'utf16le':
|
|
27
|
+
return Buffer.concat([Buffer.from([0xff, 0xfe]), Buffer.from(text, 'utf16le')]);
|
|
28
|
+
case 'utf16be': {
|
|
29
|
+
const body = Buffer.from(text, 'utf16le');
|
|
30
|
+
for (let i = 0; i + 1 < body.length; i += 2) {
|
|
31
|
+
const a = body[i];
|
|
32
|
+
body[i] = body[i + 1];
|
|
33
|
+
body[i + 1] = a;
|
|
34
|
+
}
|
|
35
|
+
return Buffer.concat([Buffer.from([0xfe, 0xff]), body]);
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return Buffer.from(text, 'utf8');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { TodoItem, ToolDefinition } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The agent's own checklist for a multi-step task. `todo_write` replaces the whole list (one call per update, as
|
|
5
|
+
* in Kilo), `todo_read` returns it. Neither touches the workspace, so neither asks for approval.
|
|
6
|
+
*/
|
|
7
|
+
declare const writeParams: z.ZodObject<{
|
|
8
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
9
|
+
content: z.ZodString;
|
|
10
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
status: "pending" | "in_progress" | "completed";
|
|
13
|
+
content: string;
|
|
14
|
+
}, {
|
|
15
|
+
status: "pending" | "in_progress" | "completed";
|
|
16
|
+
content: string;
|
|
17
|
+
}>, "many">;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
todos: {
|
|
20
|
+
status: "pending" | "in_progress" | "completed";
|
|
21
|
+
content: string;
|
|
22
|
+
}[];
|
|
23
|
+
}, {
|
|
24
|
+
todos: {
|
|
25
|
+
status: "pending" | "in_progress" | "completed";
|
|
26
|
+
content: string;
|
|
27
|
+
}[];
|
|
28
|
+
}>;
|
|
29
|
+
declare const readParams: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
30
|
+
export declare const todoWriteTool: ToolDefinition<z.infer<typeof writeParams>, {
|
|
31
|
+
todos: TodoItem[];
|
|
32
|
+
}>;
|
|
33
|
+
export declare const todoReadTool: ToolDefinition<z.infer<typeof readParams>, {
|
|
34
|
+
todos: TodoItem[];
|
|
35
|
+
}>;
|
|
36
|
+
export {};
|