@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,139 @@
|
|
|
1
|
+
/** More than this at once costs more than anyone meant to spend. */
|
|
2
|
+
export const MAX_RUNNING_BACKGROUND = 4;
|
|
3
|
+
export class BackgroundAgents {
|
|
4
|
+
entries = new Map();
|
|
5
|
+
listeners = new Set();
|
|
6
|
+
counter = 0;
|
|
7
|
+
start(options) {
|
|
8
|
+
const running = [...this.entries.values()].filter((e) => e.state === 'running').length;
|
|
9
|
+
if (running >= MAX_RUNNING_BACKGROUND) {
|
|
10
|
+
throw new Error(`At most ${MAX_RUNNING_BACKGROUND} background agents can run at once; wait for one to finish or stop one.`);
|
|
11
|
+
}
|
|
12
|
+
this.counter += 1;
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
const entry = {
|
|
15
|
+
id: `bg-${this.counter}`,
|
|
16
|
+
task: options.task,
|
|
17
|
+
...(options.agent ? { agent: options.agent } : {}),
|
|
18
|
+
state: 'running',
|
|
19
|
+
startedAt: Date.now(),
|
|
20
|
+
controller,
|
|
21
|
+
finished: Promise.resolve(),
|
|
22
|
+
delivered: false,
|
|
23
|
+
};
|
|
24
|
+
entry.finished = options.run(controller.signal).then((result) => {
|
|
25
|
+
entry.result = result;
|
|
26
|
+
// A stop makes the child return with reason "aborted": that is a stopped run, not a finished one.
|
|
27
|
+
entry.state = controller.signal.aborted || result.reason === 'aborted' ? 'stopped' : 'done';
|
|
28
|
+
entry.endedAt = Date.now();
|
|
29
|
+
this.changed();
|
|
30
|
+
}, (err) => {
|
|
31
|
+
entry.error = err?.message ?? String(err);
|
|
32
|
+
entry.state = controller.signal.aborted ? 'stopped' : 'failed';
|
|
33
|
+
entry.endedAt = Date.now();
|
|
34
|
+
this.changed();
|
|
35
|
+
});
|
|
36
|
+
this.entries.set(entry.id, entry);
|
|
37
|
+
this.changed();
|
|
38
|
+
return this.view(entry);
|
|
39
|
+
}
|
|
40
|
+
list() {
|
|
41
|
+
return [...this.entries.values()].map((e) => this.view(e));
|
|
42
|
+
}
|
|
43
|
+
get(id) {
|
|
44
|
+
const e = this.entries.get(id);
|
|
45
|
+
return e ? this.view(e) : undefined;
|
|
46
|
+
}
|
|
47
|
+
stop(id) {
|
|
48
|
+
const e = this.entries.get(id);
|
|
49
|
+
if (e?.state === 'running')
|
|
50
|
+
e.controller.abort();
|
|
51
|
+
}
|
|
52
|
+
stopAll() {
|
|
53
|
+
for (const e of this.entries.values())
|
|
54
|
+
if (e.state === 'running')
|
|
55
|
+
e.controller.abort();
|
|
56
|
+
}
|
|
57
|
+
/** Stop everything and forget it all (a new chat starts with none). */
|
|
58
|
+
clear() {
|
|
59
|
+
this.stopAll();
|
|
60
|
+
this.entries.clear();
|
|
61
|
+
this.changed();
|
|
62
|
+
}
|
|
63
|
+
/** Remove a finished entry from the list. A running one must be stopped first. */
|
|
64
|
+
dismiss(id) {
|
|
65
|
+
const e = this.entries.get(id);
|
|
66
|
+
if (!e || e.state === 'running')
|
|
67
|
+
return false;
|
|
68
|
+
this.entries.delete(id);
|
|
69
|
+
this.changed();
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Wait until the named runs (default: all that are running) have finished, or the timeout passes. Never throws:
|
|
74
|
+
* the answer is the current state of each run.
|
|
75
|
+
*/
|
|
76
|
+
async wait(ids, options = {}) {
|
|
77
|
+
const chosen = ids ? ids.map((id) => this.entries.get(id)).filter((e) => e !== undefined) : [...this.entries.values()].filter((e) => e.state === 'running');
|
|
78
|
+
const all = Promise.all(chosen.map((e) => e.finished));
|
|
79
|
+
const races = [all];
|
|
80
|
+
let timer;
|
|
81
|
+
if (options.timeoutMs !== undefined)
|
|
82
|
+
races.push(new Promise((resolve) => (timer = setTimeout(resolve, options.timeoutMs))));
|
|
83
|
+
if (options.signal) {
|
|
84
|
+
const signal = options.signal;
|
|
85
|
+
races.push(new Promise((resolve) => (signal.aborted ? resolve(undefined) : signal.addEventListener('abort', () => resolve(undefined), { once: true }))));
|
|
86
|
+
}
|
|
87
|
+
await Promise.race(races);
|
|
88
|
+
if (timer)
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
return chosen.map((e) => this.view(e));
|
|
91
|
+
}
|
|
92
|
+
/** Finished runs the model has not been told about yet; each is returned once. */
|
|
93
|
+
takeUndelivered() {
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const e of this.entries.values()) {
|
|
96
|
+
if (e.state !== 'running' && !e.delivered) {
|
|
97
|
+
e.delivered = true;
|
|
98
|
+
out.push(this.view(e));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
/** Mark runs as already known to the model (a `sub_agent_wait` answered for them). */
|
|
104
|
+
markDelivered(ids) {
|
|
105
|
+
for (const id of ids) {
|
|
106
|
+
const e = this.entries.get(id);
|
|
107
|
+
if (e && e.state !== 'running')
|
|
108
|
+
e.delivered = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
onChange(listener) {
|
|
112
|
+
this.listeners.add(listener);
|
|
113
|
+
return () => this.listeners.delete(listener);
|
|
114
|
+
}
|
|
115
|
+
changed() {
|
|
116
|
+
for (const l of this.listeners) {
|
|
117
|
+
try {
|
|
118
|
+
l();
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// a listener that throws must not stop the run bookkeeping
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
view(e) {
|
|
126
|
+
const { controller: _c, finished: _f, delivered: _d, ...rest } = e;
|
|
127
|
+
return { ...rest };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** The model-facing text for finished runs: what each was asked and what it answered. */
|
|
131
|
+
export function backgroundResultsBlock(finished) {
|
|
132
|
+
if (finished.length === 0)
|
|
133
|
+
return '';
|
|
134
|
+
const parts = finished.map((a) => {
|
|
135
|
+
const body = a.state === 'done' ? (a.result?.finalText ?? '').trim() || '(no text)' : a.state === 'failed' ? `failed: ${a.error ?? 'unknown error'}` : `stopped by the user${a.result?.finalText ? `; it had said: ${a.result.finalText.trim()}` : ''}`;
|
|
136
|
+
return `<background-agent id="${a.id}" state="${a.state}" task="${a.task.replace(/"/g, "'").slice(0, 200)}">\n${body}\n</background-agent>`;
|
|
137
|
+
});
|
|
138
|
+
return `<background-agents>\n${parts.join('\n')}\n</background-agents>`;
|
|
139
|
+
}
|
|
@@ -13,4 +13,3 @@ import type { ModelMessage } from 'ai';
|
|
|
13
13
|
import type { ModelConfig } from '../types.js';
|
|
14
14
|
export declare function supportsCacheHints(model: ModelConfig): boolean;
|
|
15
15
|
export declare function applyCacheHints(messages: ModelMessage[], model: ModelConfig): ModelMessage[];
|
|
16
|
-
//# sourceMappingURL=cache-hints.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LanguageModel } from 'ai';
|
|
2
|
+
import type { ModelConfig } from '../types.js';
|
|
3
|
+
/** The prompt for rewriting `input`: the user's own instruction when given (a blank one is ignored), else the built-in. */
|
|
4
|
+
export declare function enhanceRequestPrompt(input: string, instruction?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Rewrite a draft chat message into a clearer request using `model` (typically the cheap model).
|
|
7
|
+
* Never throws: an empty input, a missing model, a model error or an empty reply all return `input` unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function enhancePrompt(input: string, model: ModelConfig | undefined, modelFactory?: (cfg: ModelConfig) => LanguageModel, instruction?: string): Promise<string>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { generateText } from 'ai';
|
|
2
|
+
import { createLanguageModel } from '../providers.js';
|
|
3
|
+
import { stripThinkTags } from './think-tags.js';
|
|
4
|
+
const ENHANCE_INSTRUCTIONS = 'Rewrite the request below so a coding agent can act on it: say what to change and where, name the expected result, and keep every file, symbol and constraint the user mentioned. ' +
|
|
5
|
+
'Do not invent requirements or add steps the user did not ask for. Reply with the rewritten request only, no quotes, no code fences, no preface.';
|
|
6
|
+
/** The prompt for rewriting `input`: the user's own instruction when given (a blank one is ignored), else the built-in. */
|
|
7
|
+
export function enhanceRequestPrompt(input, instruction) {
|
|
8
|
+
return `${instruction?.trim() || ENHANCE_INSTRUCTIONS}\n\nRequest:\n${input}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Rewrite a draft chat message into a clearer request using `model` (typically the cheap model).
|
|
12
|
+
* Never throws: an empty input, a missing model, a model error or an empty reply all return `input` unchanged.
|
|
13
|
+
*/
|
|
14
|
+
export async function enhancePrompt(input, model, modelFactory = createLanguageModel, instruction) {
|
|
15
|
+
if (!model || !input.trim())
|
|
16
|
+
return input;
|
|
17
|
+
try {
|
|
18
|
+
const result = await generateText({ model: modelFactory(model), prompt: enhanceRequestPrompt(input, instruction) });
|
|
19
|
+
return clean(result.text) || input;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return input;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function clean(text) {
|
|
26
|
+
// Reasoning models put an inline <think> block in the reply; only what follows it is the rewrite.
|
|
27
|
+
return stripThinkTags(text)
|
|
28
|
+
.trim()
|
|
29
|
+
.replace(/^```[a-z]*\s*\n?/i, '')
|
|
30
|
+
.replace(/\n?```$/, '')
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/^["'“”](.*)["'“”]$/s, '$1')
|
|
33
|
+
.trim();
|
|
34
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Session goals: one objective kept in focus across turns. Pure state machine plus the `goal_report` tool the
|
|
5
|
+
* model uses to say it is done or stuck. The loop that runs the turns lives in the surface (VS Code chat).
|
|
6
|
+
*/
|
|
7
|
+
export type GoalStatus = 'active' | 'paused' | 'blocked' | 'complete';
|
|
8
|
+
export interface GoalState {
|
|
9
|
+
objective: string;
|
|
10
|
+
status: GoalStatus;
|
|
11
|
+
/** The model's own closing report (complete or blocked); not independently verified. */
|
|
12
|
+
report?: string;
|
|
13
|
+
/** Turns used so far. */
|
|
14
|
+
turns: number;
|
|
15
|
+
}
|
|
16
|
+
export interface GoalReport {
|
|
17
|
+
kind: 'complete' | 'blocked';
|
|
18
|
+
reason: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TurnOutcome {
|
|
21
|
+
/** Tool calls the turn made; zero with no report means the model made no progress. */
|
|
22
|
+
toolCalls: number;
|
|
23
|
+
error?: boolean;
|
|
24
|
+
stopped?: boolean;
|
|
25
|
+
report?: GoalReport;
|
|
26
|
+
/** A permission request or tool call was rejected. */
|
|
27
|
+
rejected?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const MAX_OBJECTIVE_CHARS = 10000;
|
|
30
|
+
export declare function startGoal(objective: string): GoalState;
|
|
31
|
+
/**
|
|
32
|
+
* The goal after one turn. Stop, an error, no progress or an exhausted turn budget pause it; a rejection or a
|
|
33
|
+
* `blocked` report blocks it; a `complete` report finishes it. A report counts only when the turn ended cleanly.
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyTurnOutcome(g: GoalState, o: TurnOutcome, maxTurns: number): GoalState;
|
|
36
|
+
export declare function pauseGoal(g: GoalState): GoalState;
|
|
37
|
+
/** Paused and blocked goals continue; a complete one restarts from zero turns. */
|
|
38
|
+
export declare function resumeGoal(g: GoalState): GoalState;
|
|
39
|
+
/** The message that drives one goal turn. */
|
|
40
|
+
export declare function goalPrompt(g: GoalState): string;
|
|
41
|
+
declare const reportParams: z.ZodObject<{
|
|
42
|
+
kind: z.ZodEnum<["complete", "blocked"]>;
|
|
43
|
+
reason: z.ZodString;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
kind: "blocked" | "complete";
|
|
46
|
+
reason: string;
|
|
47
|
+
}, {
|
|
48
|
+
kind: "blocked" | "complete";
|
|
49
|
+
reason: string;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function createGoalReportTool(onReport: (r: GoalReport) => void): ToolDefinition<z.infer<typeof reportParams>, {
|
|
52
|
+
recorded: true;
|
|
53
|
+
}>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const MAX_OBJECTIVE_CHARS = 10_000;
|
|
3
|
+
export function startGoal(objective) {
|
|
4
|
+
const text = objective.trim();
|
|
5
|
+
if (!text)
|
|
6
|
+
throw new Error('A goal needs an objective.');
|
|
7
|
+
if (text.length > MAX_OBJECTIVE_CHARS)
|
|
8
|
+
throw new Error('A goal objective can be at most 10,000 characters.');
|
|
9
|
+
return { objective: text, status: 'active', turns: 0 };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The goal after one turn. Stop, an error, no progress or an exhausted turn budget pause it; a rejection or a
|
|
13
|
+
* `blocked` report blocks it; a `complete` report finishes it. A report counts only when the turn ended cleanly.
|
|
14
|
+
*/
|
|
15
|
+
export function applyTurnOutcome(g, o, maxTurns) {
|
|
16
|
+
const turns = g.turns + 1;
|
|
17
|
+
const { report: _previous, ...rest } = g;
|
|
18
|
+
if (o.stopped || o.error)
|
|
19
|
+
return { ...rest, status: 'paused', turns };
|
|
20
|
+
if (o.rejected)
|
|
21
|
+
return { ...rest, status: 'blocked', turns, ...(o.report ? { report: o.report.reason } : {}) };
|
|
22
|
+
if (o.report) {
|
|
23
|
+
return { ...rest, status: o.report.kind === 'complete' ? 'complete' : 'blocked', turns, report: o.report.reason };
|
|
24
|
+
}
|
|
25
|
+
if (o.toolCalls === 0)
|
|
26
|
+
return { ...rest, status: 'paused', turns };
|
|
27
|
+
if (turns >= maxTurns)
|
|
28
|
+
return { ...rest, status: 'paused', turns };
|
|
29
|
+
return { ...rest, status: 'active', turns };
|
|
30
|
+
}
|
|
31
|
+
export function pauseGoal(g) {
|
|
32
|
+
return g.status === 'active' ? { ...g, status: 'paused' } : g;
|
|
33
|
+
}
|
|
34
|
+
/** Paused and blocked goals continue; a complete one restarts from zero turns. */
|
|
35
|
+
export function resumeGoal(g) {
|
|
36
|
+
if (g.status === 'complete')
|
|
37
|
+
return { objective: g.objective, status: 'active', turns: 0 };
|
|
38
|
+
const { report: _report, ...rest } = g;
|
|
39
|
+
return { ...rest, status: 'active' };
|
|
40
|
+
}
|
|
41
|
+
/** The message that drives one goal turn. */
|
|
42
|
+
export function goalPrompt(g) {
|
|
43
|
+
return [
|
|
44
|
+
`Goal: ${g.objective}`,
|
|
45
|
+
'',
|
|
46
|
+
'Keep working toward this goal. Make the next concrete step with your tools; do not stop to ask questions, choose safe, reversible options instead.',
|
|
47
|
+
'When the goal is met, call goal_report with kind "complete" and what you did. If you cannot continue safely, call goal_report with kind "blocked" and why.',
|
|
48
|
+
].join('\n');
|
|
49
|
+
}
|
|
50
|
+
const reportParams = z.object({
|
|
51
|
+
kind: z.enum(['complete', 'blocked']).describe('complete when the goal is met; blocked when something prevents safe progress.'),
|
|
52
|
+
reason: z.string().min(1).max(2000).describe('What was done, or what is blocking.'),
|
|
53
|
+
});
|
|
54
|
+
export function createGoalReportTool(onReport) {
|
|
55
|
+
return {
|
|
56
|
+
name: 'goal_report',
|
|
57
|
+
description: 'Report the outcome of the current goal: complete when the objective is met, blocked when you cannot continue safely.',
|
|
58
|
+
parameters: reportParams,
|
|
59
|
+
noApproval: true,
|
|
60
|
+
execute: async (args) => {
|
|
61
|
+
onReport({ kind: args.kind, reason: args.reason });
|
|
62
|
+
return { recorded: true };
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
package/dist/agent/index.d.ts
CHANGED
package/dist/agent/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects a run that is stuck repeating one tool call. A call counts as a repeat only when the tool
|
|
3
|
+
* name, the arguments (key order ignored) and the result all match the previous call, so re-reading
|
|
4
|
+
* a file after an edit changed it never trips the guard.
|
|
5
|
+
*/
|
|
6
|
+
export declare class LoopGuard {
|
|
7
|
+
private lastKey;
|
|
8
|
+
private count;
|
|
9
|
+
private readonly threshold;
|
|
10
|
+
/**
|
|
11
|
+
* `threshold` identical calls in a row trip the guard; 0 turns it off. A threshold of 1 would stop
|
|
12
|
+
* every run at its first call, so it counts as 2.
|
|
13
|
+
*/
|
|
14
|
+
constructor(threshold: number);
|
|
15
|
+
/** Length of the current run of identical calls. */
|
|
16
|
+
get streak(): number;
|
|
17
|
+
/** Record a finished call. Returns true when the streak has reached the threshold. */
|
|
18
|
+
record(toolName: string, args: unknown, resultKey: string): boolean;
|
|
19
|
+
}
|
|
20
|
+
/** A short stable key for a tool result, so the guard never holds large outputs in memory. */
|
|
21
|
+
export declare function resultKeyOf(value: unknown): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Detects a run that is stuck repeating one tool call. A call counts as a repeat only when the tool
|
|
4
|
+
* name, the arguments (key order ignored) and the result all match the previous call, so re-reading
|
|
5
|
+
* a file after an edit changed it never trips the guard.
|
|
6
|
+
*/
|
|
7
|
+
export class LoopGuard {
|
|
8
|
+
lastKey;
|
|
9
|
+
count = 0;
|
|
10
|
+
threshold;
|
|
11
|
+
/**
|
|
12
|
+
* `threshold` identical calls in a row trip the guard; 0 turns it off. A threshold of 1 would stop
|
|
13
|
+
* every run at its first call, so it counts as 2.
|
|
14
|
+
*/
|
|
15
|
+
constructor(threshold) {
|
|
16
|
+
this.threshold = threshold >= 1 ? Math.max(2, threshold) : 0;
|
|
17
|
+
}
|
|
18
|
+
/** Length of the current run of identical calls. */
|
|
19
|
+
get streak() {
|
|
20
|
+
return this.count;
|
|
21
|
+
}
|
|
22
|
+
/** Record a finished call. Returns true when the streak has reached the threshold. */
|
|
23
|
+
record(toolName, args, resultKey) {
|
|
24
|
+
if (this.threshold <= 0)
|
|
25
|
+
return false;
|
|
26
|
+
const key = `${toolName}\u0000${canonical(args)}\u0000${resultKey}`;
|
|
27
|
+
this.count = key === this.lastKey ? this.count + 1 : 1;
|
|
28
|
+
this.lastKey = key;
|
|
29
|
+
return this.count >= this.threshold;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A short stable key for a tool result, so the guard never holds large outputs in memory. */
|
|
33
|
+
export function resultKeyOf(value) {
|
|
34
|
+
const text = typeof value === 'string' ? value : (JSON.stringify(value) ?? '');
|
|
35
|
+
return createHash('sha1').update(text).digest('hex');
|
|
36
|
+
}
|
|
37
|
+
function canonical(value) {
|
|
38
|
+
return JSON.stringify(value, (_k, v) => v !== null && typeof v === 'object' && !Array.isArray(v)
|
|
39
|
+
? Object.fromEntries(Object.entries(v).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))
|
|
40
|
+
: v);
|
|
41
|
+
}
|
package/dist/agent/prompts.d.ts
CHANGED
|
@@ -22,4 +22,3 @@ export declare const DEFAULT_SPEC_MODE_SUFFIX = "\n\nSPEC MODE \u2014 IMPORTANT:
|
|
|
22
22
|
export declare const CONTINUE_PROMPT = "Continue exactly where you stopped. Do not repeat anything you already wrote.";
|
|
23
23
|
/** Spec-mode prompt override for architect phase 1 (see agent/architect.ts). */
|
|
24
24
|
export declare const ARCHITECT_PROMPT = "\n\nYou are the ARCHITECT. Explore the codebase with your read-only tools, then\nreply with a precise change plan for a separate editor model to apply. Do not\nwrite code outside the plan. Your final message must contain only:\n\n1. Files to change \u2014 for each file, the exact edits (what to find, what to\n replace it with, or the new code to add and where).\n2. New files \u2014 path and full contents.\n3. Verification \u2014 the commands to run to check the change.\n\nBe exact: the editor applies your plan literally and cannot ask questions.\n";
|
|
25
|
-
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/agent/prompts.js
CHANGED
package/dist/agent/think-tags.js
CHANGED
package/dist/agent/verify.d.ts
CHANGED
|
@@ -14,4 +14,3 @@ export interface VerifyOutcome {
|
|
|
14
14
|
export declare function runVerification(config: VerifyConfig, ctx: ToolContext, editedFiles?: string[]): Promise<VerifyOutcome>;
|
|
15
15
|
/** The message shown to the model after a failed verification. */
|
|
16
16
|
export declare function failureMessage(failures: VerifyFailure[]): string;
|
|
17
|
-
//# sourceMappingURL=verify.d.ts.map
|
package/dist/agent/verify.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SpecialistConfig } from '../orchestrator/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* An agent defined as a Markdown file: front matter for settings, the body as the system prompt.
|
|
4
|
+
* `~/.forge/agents/*.md` (yours) and `<workspace>/.forge/agents/*.md` (the project's); the file name is the agent name.
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentDef {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
/** `subagent` runs only when delegated to, `primary` only as the chat's agent, `all` both. */
|
|
10
|
+
mode: 'subagent' | 'primary' | 'all';
|
|
11
|
+
model?: string;
|
|
12
|
+
/** Iteration cap. */
|
|
13
|
+
steps?: number;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
/** Tools it may call; empty = every built-in tool except the denied ones. */
|
|
17
|
+
tools: string[];
|
|
18
|
+
/** Tools it may never call. Always contains `sub_agent`. */
|
|
19
|
+
deny: string[];
|
|
20
|
+
/** Left out of menus and the picker; still reachable by name. */
|
|
21
|
+
hidden: boolean;
|
|
22
|
+
/** Set by `disable: true`; a disabled file removes the agent of that name from the result. */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
prompt: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function parseAgentFile(fileName: string, text: string): {
|
|
27
|
+
agent?: AgentDef;
|
|
28
|
+
problem?: string;
|
|
29
|
+
};
|
|
30
|
+
/** Load folders in order (user first, project last); a later agent replaces an earlier one of the same name. */
|
|
31
|
+
export declare function loadAgentFiles(dirs: string[]): Promise<{
|
|
32
|
+
agents: AgentDef[];
|
|
33
|
+
problems: string[];
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* An agent file as a chat mode: modes are specialists, so a `primary` or `all` agent shows up in the mode switcher
|
|
37
|
+
* with its prompt, tools and step cap. No tools list = every tool in `allToolNames` except the denied ones.
|
|
38
|
+
*/
|
|
39
|
+
export declare function agentToSpecialist(def: AgentDef, allToolNames: readonly string[]): SpecialistConfig;
|
|
40
|
+
/** The agents of the running host, so the `sub_agent` tool can find one by name. Hosts register at the start of every run. */
|
|
41
|
+
export declare function registerAgentDefs(agents: AgentDef[]): void;
|
|
42
|
+
export declare function registeredAgent(name: string): AgentDef | undefined;
|
|
43
|
+
export declare function registeredAgents(): AgentDef[];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFile, readdir } from 'node:fs/promises';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
import { parseFrontmatter } from '../skills/parser.js';
|
|
4
|
+
const NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
5
|
+
const list = (v) => (v ?? '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
6
|
+
export function parseAgentFile(fileName, text) {
|
|
7
|
+
const name = basename(fileName).replace(/\.md$/i, '');
|
|
8
|
+
if (!NAME.test(name))
|
|
9
|
+
return { problem: `${fileName}: the file name "${name}" is not a valid agent name (lowercase letters, digits, - and _)` };
|
|
10
|
+
if (!text.startsWith('---'))
|
|
11
|
+
return { problem: `${fileName}: needs front matter (--- lines) with a description` };
|
|
12
|
+
const { fields, body } = parseFrontmatter(text.replace(/\r\n/g, '\n'));
|
|
13
|
+
const description = (fields.get('description') ?? '').trim();
|
|
14
|
+
if (!description)
|
|
15
|
+
return { problem: `${fileName}: description is required` };
|
|
16
|
+
const mode = fields.get('mode') ?? 'subagent';
|
|
17
|
+
if (mode !== 'subagent' && mode !== 'primary' && mode !== 'all')
|
|
18
|
+
return { problem: `${fileName}: mode must be subagent, primary or all` };
|
|
19
|
+
let steps;
|
|
20
|
+
if (fields.has('steps')) {
|
|
21
|
+
steps = Number(fields.get('steps'));
|
|
22
|
+
if (!Number.isInteger(steps) || steps < 1)
|
|
23
|
+
return { problem: `${fileName}: steps must be a positive whole number` };
|
|
24
|
+
}
|
|
25
|
+
let temperature;
|
|
26
|
+
if (fields.has('temperature')) {
|
|
27
|
+
temperature = Number(fields.get('temperature'));
|
|
28
|
+
if (!Number.isFinite(temperature) || temperature < 0 || temperature > 2)
|
|
29
|
+
return { problem: `${fileName}: temperature must be between 0 and 2` };
|
|
30
|
+
}
|
|
31
|
+
const tools = list(fields.get('tools')).filter((t) => t !== 'sub_agent');
|
|
32
|
+
const deny = [...new Set(['sub_agent', ...list(fields.get('deny'))])];
|
|
33
|
+
const model = fields.get('model')?.trim();
|
|
34
|
+
const color = fields.get('color')?.trim();
|
|
35
|
+
return {
|
|
36
|
+
agent: {
|
|
37
|
+
name,
|
|
38
|
+
description,
|
|
39
|
+
mode,
|
|
40
|
+
...(model ? { model } : {}),
|
|
41
|
+
...(steps !== undefined ? { steps } : {}),
|
|
42
|
+
...(temperature !== undefined ? { temperature } : {}),
|
|
43
|
+
...(color ? { color } : {}),
|
|
44
|
+
tools,
|
|
45
|
+
deny,
|
|
46
|
+
hidden: fields.get('hidden') === 'true',
|
|
47
|
+
...(fields.get('disable') === 'true' ? { disabled: true } : {}),
|
|
48
|
+
prompt: body.trim(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Load folders in order (user first, project last); a later agent replaces an earlier one of the same name. */
|
|
53
|
+
export async function loadAgentFiles(dirs) {
|
|
54
|
+
const byName = new Map();
|
|
55
|
+
const problems = [];
|
|
56
|
+
for (const dir of dirs) {
|
|
57
|
+
let names;
|
|
58
|
+
try {
|
|
59
|
+
names = (await readdir(dir)).filter((n) => n.toLowerCase().endsWith('.md')).sort();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
for (const n of names) {
|
|
65
|
+
let text;
|
|
66
|
+
try {
|
|
67
|
+
text = await readFile(join(dir, n), 'utf8');
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
problems.push(`${n}: ${err.message}`);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const { agent, problem } = parseAgentFile(n, text);
|
|
74
|
+
if (problem)
|
|
75
|
+
problems.push(problem);
|
|
76
|
+
else if (agent)
|
|
77
|
+
byName.set(agent.name, agent);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { agents: [...byName.values()].filter((a) => !a.disabled), problems };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* An agent file as a chat mode: modes are specialists, so a `primary` or `all` agent shows up in the mode switcher
|
|
84
|
+
* with its prompt, tools and step cap. No tools list = every tool in `allToolNames` except the denied ones.
|
|
85
|
+
*/
|
|
86
|
+
export function agentToSpecialist(def, allToolNames) {
|
|
87
|
+
const denied = new Set(def.deny);
|
|
88
|
+
const allow = def.tools.length > 0 ? new Set(def.tools) : undefined;
|
|
89
|
+
return {
|
|
90
|
+
id: def.name,
|
|
91
|
+
description: def.description,
|
|
92
|
+
systemPrompt: def.prompt,
|
|
93
|
+
allowedTools: allToolNames.filter((n) => !denied.has(n) && (!allow || allow.has(n))),
|
|
94
|
+
forbiddenTools: [...denied],
|
|
95
|
+
...(def.steps !== undefined ? { maxIterations: def.steps } : {}),
|
|
96
|
+
...(def.model ? { model: def.model } : {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
let registered = new Map();
|
|
100
|
+
/** The agents of the running host, so the `sub_agent` tool can find one by name. Hosts register at the start of every run. */
|
|
101
|
+
export function registerAgentDefs(agents) {
|
|
102
|
+
registered = new Map(agents.map((a) => [a.name, a]));
|
|
103
|
+
}
|
|
104
|
+
export function registeredAgent(name) {
|
|
105
|
+
return registered.get(name);
|
|
106
|
+
}
|
|
107
|
+
export function registeredAgents() {
|
|
108
|
+
return [...registered.values()];
|
|
109
|
+
}
|
|
@@ -38,4 +38,3 @@ export function aiCommentTask(files, action) {
|
|
|
38
38
|
? `Apply the instructions left as AI comments in these files, then remove the AI comments you resolved:\n\n${body}`
|
|
39
39
|
: `Answer the questions left as AI comments in these files. Do not edit any file:\n\n${body}`;
|
|
40
40
|
}
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
package/dist/attachments.d.ts
CHANGED
|
@@ -44,4 +44,3 @@ export declare function attachmentParts(attachments: readonly Attachment[]): Arr
|
|
|
44
44
|
export declare function mediaPartTokens(part: unknown): number;
|
|
45
45
|
/** A short stand-in for a media part in transcripts (summaries, logs), never the bytes. */
|
|
46
46
|
export declare function mediaPartLabel(part: unknown): string | null;
|
|
47
|
-
//# sourceMappingURL=attachments.d.ts.map
|
package/dist/attachments.js
CHANGED
package/dist/browser/cdp.d.ts
CHANGED
package/dist/browser/cdp.js
CHANGED
package/dist/browser/chrome.d.ts
CHANGED
package/dist/browser/chrome.js
CHANGED