@morphllm/morphsdk 0.2.138 → 0.2.139
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/dist/{chunk-QU5JVTYQ.js → chunk-3J74OXN6.js} +2 -2
- package/dist/chunk-3T5W2D2W.js +288 -0
- package/dist/chunk-3T5W2D2W.js.map +1 -0
- package/dist/{chunk-MDVFAW4F.js → chunk-4J5UW34J.js} +4 -4
- package/dist/{chunk-IMYH4BD2.js → chunk-5CBMLTG5.js} +5 -5
- package/dist/{chunk-CXSAPFUD.js → chunk-6W3X76KE.js} +21 -6
- package/dist/chunk-6W3X76KE.js.map +1 -0
- package/dist/{chunk-HP64WS73.js → chunk-6WSZDCGP.js} +2 -2
- package/dist/{chunk-2PU5V3MK.js → chunk-73ZLTWKF.js} +4 -4
- package/dist/{chunk-ZK5GJIAX.js → chunk-7RCHQN7F.js} +2 -2
- package/dist/{chunk-ZOC7P5RV.js → chunk-ATAQZLQN.js} +2 -2
- package/dist/{chunk-GSOXKIQU.js → chunk-B55ZEX4M.js} +2 -2
- package/dist/{chunk-QNXGYWS3.js → chunk-DRAQDTSR.js} +2 -2
- package/dist/{chunk-G5GPLD2E.js → chunk-EEBGEMOO.js} +2 -2
- package/dist/{chunk-H7RABA4R.js → chunk-EHRKLQ62.js} +2 -2
- package/dist/chunk-GQX4PKXZ.js +265 -0
- package/dist/chunk-GQX4PKXZ.js.map +1 -0
- package/dist/{chunk-YOOALIAK.js → chunk-MHNCFELG.js} +4 -4
- package/dist/{chunk-DOW7Y3AB.js → chunk-MTD2JOO7.js} +1 -1
- package/dist/{chunk-P4FTR3X4.js → chunk-NEVPVOTT.js} +3 -3
- package/dist/{chunk-CUPT64F5.js → chunk-NGHLDI64.js} +2 -2
- package/dist/{chunk-KWFRPYUW.js → chunk-OICUUS5Y.js} +4 -4
- package/dist/{chunk-QNX4PKPV.js → chunk-TCXBKB7P.js} +2 -2
- package/dist/{chunk-XIVAX3WB.js → chunk-ULMSWACH.js} +6 -6
- package/dist/{chunk-KHHSG2LO.js → chunk-XIEU3N3R.js} +4 -4
- package/dist/{chunk-2GSJGZYK.js → chunk-XUDE6SOY.js} +57 -21
- package/dist/{chunk-2GSJGZYK.js.map → chunk-XUDE6SOY.js.map} +1 -1
- package/dist/{chunk-XLDP5S2P.js → chunk-ZUG2L4BJ.js} +2 -2
- package/dist/{chunk-S3CBEA3Y.js → chunk-ZYN64ZVG.js} +4 -4
- package/dist/chunk-ZZ25FZG2.js +73 -0
- package/dist/chunk-ZZ25FZG2.js.map +1 -0
- package/dist/{client-Ca7e11hJ.d.ts → client-BMmG3SZs.d.ts} +39 -0
- package/dist/client.cjs +650 -13
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.js +30 -27
- package/dist/edge.cjs +20 -5
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +9 -9
- package/dist/index.cjs +653 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -34
- package/dist/modelrouter/core.cjs +20 -5
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +20 -5
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/subagents/anthropic.cjs +2397 -0
- package/dist/subagents/anthropic.cjs.map +1 -0
- package/dist/subagents/anthropic.d.ts +41 -0
- package/dist/subagents/anthropic.js +19 -0
- package/dist/subagents/anthropic.js.map +1 -0
- package/dist/subagents/index.cjs +101 -0
- package/dist/subagents/index.cjs.map +1 -0
- package/dist/subagents/index.d.ts +5 -0
- package/dist/subagents/index.js +12 -0
- package/dist/subagents/index.js.map +1 -0
- package/dist/subagents/prompts.cjs +99 -0
- package/dist/subagents/prompts.cjs.map +1 -0
- package/dist/subagents/prompts.d.ts +42 -0
- package/dist/subagents/prompts.js +12 -0
- package/dist/subagents/prompts.js.map +1 -0
- package/dist/subagents/types.cjs +19 -0
- package/dist/subagents/types.cjs.map +1 -0
- package/dist/subagents/types.d.ts +93 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/types.js.map +1 -0
- package/dist/subagents/vercel.cjs +2374 -0
- package/dist/subagents/vercel.cjs.map +1 -0
- package/dist/subagents/vercel.d.ts +32 -0
- package/dist/subagents/vercel.js +19 -0
- package/dist/subagents/vercel.js.map +1 -0
- package/dist/tools/browser/anthropic.cjs +20 -5
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +6 -6
- package/dist/tools/browser/core.cjs +20 -5
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +5 -5
- package/dist/tools/browser/index.cjs +20 -5
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +15 -15
- package/dist/tools/browser/openai.cjs +20 -5
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +6 -6
- package/dist/tools/browser/profiles/core.cjs +20 -5
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +20 -5
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +20 -5
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +6 -6
- package/dist/tools/codebase_search/anthropic.cjs +20 -5
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +4 -4
- package/dist/tools/codebase_search/core.cjs +20 -5
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +3 -3
- package/dist/tools/codebase_search/index.cjs +20 -5
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +10 -10
- package/dist/tools/codebase_search/openai.cjs +20 -5
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +4 -4
- package/dist/tools/codebase_search/vercel.cjs +20 -5
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +4 -4
- package/dist/tools/fastapply/anthropic.cjs +20 -5
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +20 -5
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +20 -5
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +20 -5
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +8 -8
- package/dist/tools/fastapply/openai.cjs +20 -5
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +20 -5
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +20 -5
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +8 -8
- package/dist/tools/utils/resilience.cjs +20 -5
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +20 -5
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/anthropic.cjs +20 -5
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +6 -6
- package/dist/tools/warp_grep/client.cjs +20 -5
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +5 -5
- package/dist/tools/warp_grep/gemini.cjs +20 -5
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +5 -5
- package/dist/tools/warp_grep/harness.js +4 -4
- package/dist/tools/warp_grep/index.cjs +20 -5
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +7 -7
- package/dist/tools/warp_grep/openai.cjs +20 -5
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +6 -6
- package/dist/tools/warp_grep/vercel.cjs +20 -5
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +6 -6
- package/dist/version.cjs +20 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +20 -5
- package/dist/chunk-CXSAPFUD.js.map +0 -1
- /package/dist/{chunk-QU5JVTYQ.js.map → chunk-3J74OXN6.js.map} +0 -0
- /package/dist/{chunk-MDVFAW4F.js.map → chunk-4J5UW34J.js.map} +0 -0
- /package/dist/{chunk-IMYH4BD2.js.map → chunk-5CBMLTG5.js.map} +0 -0
- /package/dist/{chunk-HP64WS73.js.map → chunk-6WSZDCGP.js.map} +0 -0
- /package/dist/{chunk-2PU5V3MK.js.map → chunk-73ZLTWKF.js.map} +0 -0
- /package/dist/{chunk-ZK5GJIAX.js.map → chunk-7RCHQN7F.js.map} +0 -0
- /package/dist/{chunk-ZOC7P5RV.js.map → chunk-ATAQZLQN.js.map} +0 -0
- /package/dist/{chunk-GSOXKIQU.js.map → chunk-B55ZEX4M.js.map} +0 -0
- /package/dist/{chunk-QNXGYWS3.js.map → chunk-DRAQDTSR.js.map} +0 -0
- /package/dist/{chunk-G5GPLD2E.js.map → chunk-EEBGEMOO.js.map} +0 -0
- /package/dist/{chunk-H7RABA4R.js.map → chunk-EHRKLQ62.js.map} +0 -0
- /package/dist/{chunk-YOOALIAK.js.map → chunk-MHNCFELG.js.map} +0 -0
- /package/dist/{chunk-DOW7Y3AB.js.map → chunk-MTD2JOO7.js.map} +0 -0
- /package/dist/{chunk-P4FTR3X4.js.map → chunk-NEVPVOTT.js.map} +0 -0
- /package/dist/{chunk-CUPT64F5.js.map → chunk-NGHLDI64.js.map} +0 -0
- /package/dist/{chunk-KWFRPYUW.js.map → chunk-OICUUS5Y.js.map} +0 -0
- /package/dist/{chunk-QNX4PKPV.js.map → chunk-TCXBKB7P.js.map} +0 -0
- /package/dist/{chunk-XIVAX3WB.js.map → chunk-ULMSWACH.js.map} +0 -0
- /package/dist/{chunk-KHHSG2LO.js.map → chunk-XIEU3N3R.js.map} +0 -0
- /package/dist/{chunk-XLDP5S2P.js.map → chunk-ZUG2L4BJ.js.map} +0 -0
- /package/dist/{chunk-S3CBEA3Y.js.map → chunk-ZYN64ZVG.js.map} +0 -0
package/dist/client.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var init_package = __esm({
|
|
|
36
36
|
"package.json"() {
|
|
37
37
|
package_default = {
|
|
38
38
|
name: "@morphllm/morphsdk",
|
|
39
|
-
version: "0.2.
|
|
39
|
+
version: "0.2.139",
|
|
40
40
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
41
41
|
type: "module",
|
|
42
42
|
main: "./dist/index.cjs",
|
|
@@ -167,6 +167,21 @@ var init_package = __esm({
|
|
|
167
167
|
types: "./dist/tools/compact/index.d.ts",
|
|
168
168
|
import: "./dist/tools/compact/index.js",
|
|
169
169
|
require: "./dist/tools/compact/index.cjs"
|
|
170
|
+
},
|
|
171
|
+
"./subagents": {
|
|
172
|
+
types: "./dist/subagents/index.d.ts",
|
|
173
|
+
import: "./dist/subagents/index.js",
|
|
174
|
+
require: "./dist/subagents/index.cjs"
|
|
175
|
+
},
|
|
176
|
+
"./subagents/vercel": {
|
|
177
|
+
types: "./dist/subagents/vercel.d.ts",
|
|
178
|
+
import: "./dist/subagents/vercel.js",
|
|
179
|
+
require: "./dist/subagents/vercel.cjs"
|
|
180
|
+
},
|
|
181
|
+
"./subagents/anthropic": {
|
|
182
|
+
types: "./dist/subagents/anthropic.d.ts",
|
|
183
|
+
import: "./dist/subagents/anthropic.js",
|
|
184
|
+
require: "./dist/subagents/anthropic.cjs"
|
|
170
185
|
}
|
|
171
186
|
},
|
|
172
187
|
files: [
|
|
@@ -178,7 +193,7 @@ var init_package = __esm({
|
|
|
178
193
|
"!dist/**/*.test.*"
|
|
179
194
|
],
|
|
180
195
|
scripts: {
|
|
181
|
-
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
196
|
+
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
182
197
|
prepare: "npm run build",
|
|
183
198
|
typecheck: "tsc --noEmit",
|
|
184
199
|
lint: "eslint .",
|
|
@@ -208,14 +223,14 @@ var init_package = __esm({
|
|
|
208
223
|
license: "MIT",
|
|
209
224
|
dependencies: {
|
|
210
225
|
"@vscode/ripgrep": "^1.17.0",
|
|
211
|
-
ai: "
|
|
226
|
+
ai: ">=5.0.0",
|
|
212
227
|
diff: "^7.0.0",
|
|
213
228
|
"isomorphic-git": "^1.25.10",
|
|
214
229
|
openai: "^4.52.7",
|
|
215
|
-
zod: "
|
|
230
|
+
zod: ">=3.23.0"
|
|
216
231
|
},
|
|
217
232
|
devDependencies: {
|
|
218
|
-
"@ai-sdk/anthropic": "^
|
|
233
|
+
"@ai-sdk/anthropic": "^2.0.70",
|
|
219
234
|
"@ai-sdk/openai": "^2.0.35",
|
|
220
235
|
"@anthropic-ai/sdk": "^0.30.1",
|
|
221
236
|
"@google/generative-ai": "^0.24.1",
|
|
@@ -4901,7 +4916,7 @@ var TOOL_PARAMETERS = {
|
|
|
4901
4916
|
required: ["search_term"]
|
|
4902
4917
|
};
|
|
4903
4918
|
function createWarpGrepTool(config) {
|
|
4904
|
-
const
|
|
4919
|
+
const tool5 = {
|
|
4905
4920
|
type: "function",
|
|
4906
4921
|
function: {
|
|
4907
4922
|
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
@@ -4909,7 +4924,7 @@ function createWarpGrepTool(config) {
|
|
|
4909
4924
|
parameters: TOOL_PARAMETERS
|
|
4910
4925
|
}
|
|
4911
4926
|
};
|
|
4912
|
-
return Object.assign(
|
|
4927
|
+
return Object.assign(tool5, {
|
|
4913
4928
|
execute: async (input) => {
|
|
4914
4929
|
return executeToolCall(input, config);
|
|
4915
4930
|
},
|
|
@@ -4920,7 +4935,7 @@ function createWarpGrepTool(config) {
|
|
|
4920
4935
|
}
|
|
4921
4936
|
function createGitHubSearchTool(config) {
|
|
4922
4937
|
const client = new WarpGrepClient(config);
|
|
4923
|
-
const
|
|
4938
|
+
const tool5 = {
|
|
4924
4939
|
type: "function",
|
|
4925
4940
|
function: {
|
|
4926
4941
|
name: GITHUB_SEARCH_TOOL_NAME,
|
|
@@ -4928,7 +4943,7 @@ function createGitHubSearchTool(config) {
|
|
|
4928
4943
|
parameters: GITHUB_SEARCH_INPUT_SCHEMA
|
|
4929
4944
|
}
|
|
4930
4945
|
};
|
|
4931
|
-
return Object.assign(
|
|
4946
|
+
return Object.assign(tool5, {
|
|
4932
4947
|
execute: async (input) => {
|
|
4933
4948
|
const github = input.github_url || input.owner_repo;
|
|
4934
4949
|
if (!github) {
|
|
@@ -5208,12 +5223,12 @@ var INPUT_SCHEMA = {
|
|
|
5208
5223
|
required: ["search_term"]
|
|
5209
5224
|
};
|
|
5210
5225
|
function createWarpGrepTool2(config) {
|
|
5211
|
-
const
|
|
5226
|
+
const tool5 = {
|
|
5212
5227
|
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
5213
5228
|
description: config.description ?? WARP_GREP_DESCRIPTION,
|
|
5214
5229
|
input_schema: INPUT_SCHEMA
|
|
5215
5230
|
};
|
|
5216
|
-
return Object.assign(
|
|
5231
|
+
return Object.assign(tool5, {
|
|
5217
5232
|
execute: async (input) => {
|
|
5218
5233
|
return executeToolCall(input, config);
|
|
5219
5234
|
},
|
|
@@ -5224,12 +5239,12 @@ function createWarpGrepTool2(config) {
|
|
|
5224
5239
|
}
|
|
5225
5240
|
function createGitHubSearchTool2(config) {
|
|
5226
5241
|
const client = new WarpGrepClient(config);
|
|
5227
|
-
const
|
|
5242
|
+
const tool5 = {
|
|
5228
5243
|
name: GITHUB_SEARCH_TOOL_NAME,
|
|
5229
5244
|
description: GITHUB_SEARCH_DESCRIPTION,
|
|
5230
5245
|
input_schema: GITHUB_SEARCH_INPUT_SCHEMA
|
|
5231
5246
|
};
|
|
5232
|
-
return Object.assign(
|
|
5247
|
+
return Object.assign(tool5, {
|
|
5233
5248
|
execute: async (input) => {
|
|
5234
5249
|
const github = input.github_url || input.owner_repo;
|
|
5235
5250
|
if (!github) {
|
|
@@ -5362,6 +5377,347 @@ function createEditFileTool2(config = {}) {
|
|
|
5362
5377
|
});
|
|
5363
5378
|
}
|
|
5364
5379
|
|
|
5380
|
+
// subagents/prompts.ts
|
|
5381
|
+
var THOROUGHNESS_INSTRUCTIONS = {
|
|
5382
|
+
quick: `Do 1-2 targeted searches. Find the most relevant file/function quickly and summarize. Don't go deep.`,
|
|
5383
|
+
medium: `Do 2-4 searches. Start broad, then follow up on the most promising leads. Cover the main aspects.`,
|
|
5384
|
+
thorough: `Do 4-8 searches. Explore systematically: start broad, then drill into each relevant area. Cover edge cases, related files, and the full call chain. Leave no stone unturned.`
|
|
5385
|
+
};
|
|
5386
|
+
function getSystemPrompt2(thoroughness = "medium") {
|
|
5387
|
+
return `You are a codebase exploration specialist. Your job is to search a codebase and return a concise, accurate summary of what you find.
|
|
5388
|
+
|
|
5389
|
+
## Mode
|
|
5390
|
+
READ-ONLY. You cannot modify files. You can only search and read code.
|
|
5391
|
+
|
|
5392
|
+
## Strategy
|
|
5393
|
+
${THOROUGHNESS_INSTRUCTIONS[thoroughness]}
|
|
5394
|
+
|
|
5395
|
+
- Use multiple focused searches rather than one vague search
|
|
5396
|
+
- Follow imports, function calls, and type references to build complete understanding
|
|
5397
|
+
- If a search returns no results, try alternative terms (e.g., "auth" vs "authentication" vs "login")
|
|
5398
|
+
- Look at both implementation and tests when relevant
|
|
5399
|
+
|
|
5400
|
+
## Communication
|
|
5401
|
+
You have a \`send_message\` tool. Use it when:
|
|
5402
|
+
- You hit a fork in the road and need guidance ("Found auth in both src/middleware/ and legacy/auth/. Which should I focus on?")
|
|
5403
|
+
- You need clarification on ambiguous requests ("There are 3 auth strategies: JWT, session, OAuth. Which one?")
|
|
5404
|
+
- You want to share a key finding before continuing ("The main auth handler is in src/auth/index.ts. It delegates to strategy-specific modules. Continuing to trace JWT flow.")
|
|
5405
|
+
|
|
5406
|
+
Do NOT use send_message for routine status updates. Only use it when you genuinely need input or have a significant finding worth sharing before you're done.
|
|
5407
|
+
|
|
5408
|
+
## Output
|
|
5409
|
+
When you have enough information, output your final summary. Structure it as:
|
|
5410
|
+
1. Direct answer to the question
|
|
5411
|
+
2. Key files and their roles
|
|
5412
|
+
3. How the pieces connect
|
|
5413
|
+
|
|
5414
|
+
Be concise. The summary should be useful to another AI model that will use your findings to complete a task.`;
|
|
5415
|
+
}
|
|
5416
|
+
var CODEBASE_SEARCH_TOOL = {
|
|
5417
|
+
name: "codebase_search",
|
|
5418
|
+
description: "Search the codebase for relevant code. Takes a natural language search request describing what you want to find. Returns matching file contents with line numbers.",
|
|
5419
|
+
input_schema: {
|
|
5420
|
+
type: "object",
|
|
5421
|
+
properties: {
|
|
5422
|
+
searchRequest: {
|
|
5423
|
+
type: "string",
|
|
5424
|
+
description: "Natural language description of what to search for in the codebase"
|
|
5425
|
+
}
|
|
5426
|
+
},
|
|
5427
|
+
required: ["searchRequest"],
|
|
5428
|
+
additionalProperties: false
|
|
5429
|
+
}
|
|
5430
|
+
};
|
|
5431
|
+
var SEND_MESSAGE_TOOL = {
|
|
5432
|
+
name: "send_message",
|
|
5433
|
+
description: "Send a message to the orchestrating agent. Use this to ask questions, request clarification, or share important findings. The orchestrator may reply with additional context. Use sparingly \u2014 only when you genuinely need input or have a significant finding.",
|
|
5434
|
+
input_schema: {
|
|
5435
|
+
type: "object",
|
|
5436
|
+
properties: {
|
|
5437
|
+
message: {
|
|
5438
|
+
type: "string",
|
|
5439
|
+
description: "The message to send to the orchestrator"
|
|
5440
|
+
}
|
|
5441
|
+
},
|
|
5442
|
+
required: ["message"],
|
|
5443
|
+
additionalProperties: false
|
|
5444
|
+
}
|
|
5445
|
+
};
|
|
5446
|
+
|
|
5447
|
+
// subagents/anthropic.ts
|
|
5448
|
+
var DEFAULT_MAX_TURNS = {
|
|
5449
|
+
quick: 3,
|
|
5450
|
+
medium: 6,
|
|
5451
|
+
thorough: 12
|
|
5452
|
+
};
|
|
5453
|
+
function getMaxTurns(config) {
|
|
5454
|
+
return config.maxTurns ?? DEFAULT_MAX_TURNS[config.thoroughness ?? "medium"] ?? 6;
|
|
5455
|
+
}
|
|
5456
|
+
var TOOLS = [
|
|
5457
|
+
{
|
|
5458
|
+
name: CODEBASE_SEARCH_TOOL.name,
|
|
5459
|
+
description: CODEBASE_SEARCH_TOOL.description,
|
|
5460
|
+
input_schema: CODEBASE_SEARCH_TOOL.input_schema
|
|
5461
|
+
},
|
|
5462
|
+
{
|
|
5463
|
+
name: SEND_MESSAGE_TOOL.name,
|
|
5464
|
+
description: SEND_MESSAGE_TOOL.description,
|
|
5465
|
+
input_schema: SEND_MESSAGE_TOOL.input_schema
|
|
5466
|
+
}
|
|
5467
|
+
];
|
|
5468
|
+
function createExploreSubagent(config) {
|
|
5469
|
+
if (!config.repoRoot) {
|
|
5470
|
+
throw new Error("repoRoot is required for Explore subagent");
|
|
5471
|
+
}
|
|
5472
|
+
const warpGrep = new WarpGrepClient({
|
|
5473
|
+
morphApiKey: config.morphApiKey
|
|
5474
|
+
});
|
|
5475
|
+
const thoroughness = config.thoroughness ?? "medium";
|
|
5476
|
+
const maxTurns = getMaxTurns(config);
|
|
5477
|
+
const replyTimeout = config.replyTimeout ?? 3e4;
|
|
5478
|
+
async function runExplore(prompt, callbacks = {}) {
|
|
5479
|
+
const startTime = Date.now();
|
|
5480
|
+
const allContexts = [];
|
|
5481
|
+
let searchCount = 0;
|
|
5482
|
+
const timeoutMs = config.timeout;
|
|
5483
|
+
try {
|
|
5484
|
+
const messages = [{ role: "user", content: prompt }];
|
|
5485
|
+
let turns = 0;
|
|
5486
|
+
while (turns < maxTurns) {
|
|
5487
|
+
if (timeoutMs && Date.now() - startTime > timeoutMs) {
|
|
5488
|
+
return {
|
|
5489
|
+
success: false,
|
|
5490
|
+
summary: "",
|
|
5491
|
+
contexts: deduplicateContexts(allContexts),
|
|
5492
|
+
searchCount,
|
|
5493
|
+
durationMs: Date.now() - startTime,
|
|
5494
|
+
error: `Exploration timed out after ${timeoutMs}ms`
|
|
5495
|
+
};
|
|
5496
|
+
}
|
|
5497
|
+
const response = await config.client.messages.create({
|
|
5498
|
+
model: config.model,
|
|
5499
|
+
max_tokens: 4096,
|
|
5500
|
+
system: getSystemPrompt2(thoroughness),
|
|
5501
|
+
tools: TOOLS,
|
|
5502
|
+
messages
|
|
5503
|
+
});
|
|
5504
|
+
turns++;
|
|
5505
|
+
if (response.stop_reason === "end_turn" || !response.content.some((b) => b.type === "tool_use")) {
|
|
5506
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
5507
|
+
const summary = textBlock?.text || "Exploration completed but no summary was generated.";
|
|
5508
|
+
callbacks.onStep?.({
|
|
5509
|
+
step: searchCount,
|
|
5510
|
+
searchRequest: "",
|
|
5511
|
+
contextsFound: allContexts.length,
|
|
5512
|
+
isFinal: true
|
|
5513
|
+
});
|
|
5514
|
+
return {
|
|
5515
|
+
success: true,
|
|
5516
|
+
summary,
|
|
5517
|
+
contexts: deduplicateContexts(allContexts),
|
|
5518
|
+
searchCount,
|
|
5519
|
+
durationMs: Date.now() - startTime
|
|
5520
|
+
};
|
|
5521
|
+
}
|
|
5522
|
+
messages.push({ role: "assistant", content: response.content });
|
|
5523
|
+
const toolResults = [];
|
|
5524
|
+
for (const block of response.content) {
|
|
5525
|
+
if (block.type !== "tool_use") continue;
|
|
5526
|
+
if (block.name === "codebase_search") {
|
|
5527
|
+
searchCount++;
|
|
5528
|
+
const input = block.input;
|
|
5529
|
+
const warpResult = await warpGrep.execute({
|
|
5530
|
+
searchTerm: input.searchRequest,
|
|
5531
|
+
repoRoot: config.repoRoot,
|
|
5532
|
+
excludes: config.excludes,
|
|
5533
|
+
includes: config.includes
|
|
5534
|
+
});
|
|
5535
|
+
if (warpResult.contexts) {
|
|
5536
|
+
allContexts.push(...warpResult.contexts);
|
|
5537
|
+
}
|
|
5538
|
+
callbacks.onStep?.({
|
|
5539
|
+
step: searchCount,
|
|
5540
|
+
searchRequest: input.searchRequest,
|
|
5541
|
+
contextsFound: warpResult.contexts?.length ?? 0,
|
|
5542
|
+
isFinal: false
|
|
5543
|
+
});
|
|
5544
|
+
toolResults.push({
|
|
5545
|
+
type: "tool_result",
|
|
5546
|
+
tool_use_id: block.id,
|
|
5547
|
+
content: formatResult(warpResult)
|
|
5548
|
+
});
|
|
5549
|
+
} else if (block.name === "send_message") {
|
|
5550
|
+
const input = block.input;
|
|
5551
|
+
const subagentMsg = {
|
|
5552
|
+
from: "explore",
|
|
5553
|
+
content: input.message,
|
|
5554
|
+
timestamp: Date.now()
|
|
5555
|
+
};
|
|
5556
|
+
let replyText = "";
|
|
5557
|
+
if (callbacks.onMessage) {
|
|
5558
|
+
replyText = await Promise.race([
|
|
5559
|
+
new Promise((resolve2) => {
|
|
5560
|
+
callbacks.onMessage(subagentMsg, (text) => {
|
|
5561
|
+
resolve2(text);
|
|
5562
|
+
});
|
|
5563
|
+
}),
|
|
5564
|
+
new Promise(
|
|
5565
|
+
(resolve2) => setTimeout(() => resolve2(""), replyTimeout)
|
|
5566
|
+
)
|
|
5567
|
+
]);
|
|
5568
|
+
}
|
|
5569
|
+
const toolResponse = replyText ? `Response from orchestrator: ${replyText}` : "No response. Continue with your best judgment.";
|
|
5570
|
+
toolResults.push({
|
|
5571
|
+
type: "tool_result",
|
|
5572
|
+
tool_use_id: block.id,
|
|
5573
|
+
content: toolResponse
|
|
5574
|
+
});
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5577
|
+
messages.push({ role: "user", content: toolResults });
|
|
5578
|
+
}
|
|
5579
|
+
return {
|
|
5580
|
+
success: true,
|
|
5581
|
+
summary: "Exploration completed (max turns reached).",
|
|
5582
|
+
contexts: deduplicateContexts(allContexts),
|
|
5583
|
+
searchCount,
|
|
5584
|
+
durationMs: Date.now() - startTime
|
|
5585
|
+
};
|
|
5586
|
+
} catch (error) {
|
|
5587
|
+
return {
|
|
5588
|
+
success: false,
|
|
5589
|
+
summary: "",
|
|
5590
|
+
contexts: deduplicateContexts(allContexts),
|
|
5591
|
+
searchCount,
|
|
5592
|
+
durationMs: Date.now() - startTime,
|
|
5593
|
+
error: error instanceof Error ? error.message : String(error)
|
|
5594
|
+
};
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
const exploreTool = Object.assign(
|
|
5598
|
+
{
|
|
5599
|
+
name: "explore",
|
|
5600
|
+
description: "Explore a codebase to answer questions about code structure, find implementations, trace call chains, and understand architecture. Returns a summary of findings.",
|
|
5601
|
+
input_schema: {
|
|
5602
|
+
type: "object",
|
|
5603
|
+
properties: {
|
|
5604
|
+
searchRequest: {
|
|
5605
|
+
type: "string",
|
|
5606
|
+
description: "What to explore in the codebase. Be specific about what you want to understand."
|
|
5607
|
+
}
|
|
5608
|
+
},
|
|
5609
|
+
required: ["searchRequest"]
|
|
5610
|
+
}
|
|
5611
|
+
},
|
|
5612
|
+
{
|
|
5613
|
+
execute: async (input) => {
|
|
5614
|
+
return runExplore(input.searchRequest);
|
|
5615
|
+
},
|
|
5616
|
+
formatResult: (result) => {
|
|
5617
|
+
if (!result.success) {
|
|
5618
|
+
return `Exploration failed: ${result.error}`;
|
|
5619
|
+
}
|
|
5620
|
+
return result.summary;
|
|
5621
|
+
}
|
|
5622
|
+
}
|
|
5623
|
+
);
|
|
5624
|
+
return {
|
|
5625
|
+
/** Anthropic Tool definition for use in parent agents */
|
|
5626
|
+
tool: exploreTool,
|
|
5627
|
+
/** Run exploration with messaging support */
|
|
5628
|
+
run(prompt) {
|
|
5629
|
+
const messageHandlers = [];
|
|
5630
|
+
const stepHandlers = [];
|
|
5631
|
+
let resultPromise = null;
|
|
5632
|
+
const session = {
|
|
5633
|
+
on(event, handler) {
|
|
5634
|
+
if (event === "message") messageHandlers.push(handler);
|
|
5635
|
+
if (event === "step") stepHandlers.push(handler);
|
|
5636
|
+
return session;
|
|
5637
|
+
},
|
|
5638
|
+
send(_text) {
|
|
5639
|
+
},
|
|
5640
|
+
get result() {
|
|
5641
|
+
if (!resultPromise) {
|
|
5642
|
+
resultPromise = runExplore(prompt, {
|
|
5643
|
+
onStep: (step) => {
|
|
5644
|
+
for (const handler of stepHandlers) handler(step);
|
|
5645
|
+
},
|
|
5646
|
+
onMessage: (msg, reply) => {
|
|
5647
|
+
if (messageHandlers.length > 0) {
|
|
5648
|
+
for (const handler of messageHandlers) handler(msg, reply);
|
|
5649
|
+
} else {
|
|
5650
|
+
reply("");
|
|
5651
|
+
}
|
|
5652
|
+
}
|
|
5653
|
+
});
|
|
5654
|
+
}
|
|
5655
|
+
return resultPromise;
|
|
5656
|
+
}
|
|
5657
|
+
};
|
|
5658
|
+
return session;
|
|
5659
|
+
},
|
|
5660
|
+
/** Stream exploration events as an async generator */
|
|
5661
|
+
async *stream(prompt) {
|
|
5662
|
+
const events = [];
|
|
5663
|
+
let resolveNext = null;
|
|
5664
|
+
let done = false;
|
|
5665
|
+
const resultPromise = runExplore(prompt, {
|
|
5666
|
+
onStep: (step) => {
|
|
5667
|
+
events.push({
|
|
5668
|
+
type: "step",
|
|
5669
|
+
step: step.step,
|
|
5670
|
+
searchRequest: step.searchRequest,
|
|
5671
|
+
contextsFound: step.contextsFound,
|
|
5672
|
+
isFinal: step.isFinal
|
|
5673
|
+
});
|
|
5674
|
+
resolveNext?.();
|
|
5675
|
+
},
|
|
5676
|
+
onMessage: (msg, reply) => {
|
|
5677
|
+
events.push({
|
|
5678
|
+
type: "message",
|
|
5679
|
+
from: msg.from,
|
|
5680
|
+
content: msg.content,
|
|
5681
|
+
timestamp: msg.timestamp
|
|
5682
|
+
});
|
|
5683
|
+
resolveNext?.();
|
|
5684
|
+
reply("Continue with your best judgment.");
|
|
5685
|
+
}
|
|
5686
|
+
});
|
|
5687
|
+
while (!done) {
|
|
5688
|
+
if (events.length > 0) {
|
|
5689
|
+
yield events.shift();
|
|
5690
|
+
} else {
|
|
5691
|
+
const raceResult = await Promise.race([
|
|
5692
|
+
resultPromise.then((r) => ({ type: "done", result: r })),
|
|
5693
|
+
new Promise((resolve2) => {
|
|
5694
|
+
resolveNext = () => resolve2({ type: "event" });
|
|
5695
|
+
})
|
|
5696
|
+
]);
|
|
5697
|
+
if (raceResult.type === "done") {
|
|
5698
|
+
while (events.length > 0) {
|
|
5699
|
+
yield events.shift();
|
|
5700
|
+
}
|
|
5701
|
+
done = true;
|
|
5702
|
+
return raceResult.result;
|
|
5703
|
+
}
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
return await resultPromise;
|
|
5707
|
+
}
|
|
5708
|
+
};
|
|
5709
|
+
}
|
|
5710
|
+
function deduplicateContexts(contexts) {
|
|
5711
|
+
const map = /* @__PURE__ */ new Map();
|
|
5712
|
+
for (const ctx of contexts) {
|
|
5713
|
+
const existing = map.get(ctx.file);
|
|
5714
|
+
if (!existing || ctx.content.length > existing.content.length) {
|
|
5715
|
+
map.set(ctx.file, ctx);
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
return Array.from(map.values());
|
|
5719
|
+
}
|
|
5720
|
+
|
|
5365
5721
|
// factories/anthropic.ts
|
|
5366
5722
|
var AnthropicToolFactory = class {
|
|
5367
5723
|
constructor(config) {
|
|
@@ -5415,6 +5771,22 @@ var AnthropicToolFactory = class {
|
|
|
5415
5771
|
morphApiKey: this.config.apiKey
|
|
5416
5772
|
});
|
|
5417
5773
|
}
|
|
5774
|
+
/**
|
|
5775
|
+
* Create an Explore subagent that searches the codebase and returns summaries
|
|
5776
|
+
*
|
|
5777
|
+
* @param client - Anthropic SDK client instance
|
|
5778
|
+
* @param model - Model name (e.g., 'claude-haiku-4-5-20251001')
|
|
5779
|
+
* @param toolConfig - Subagent configuration (morphApiKey inherited from MorphClient)
|
|
5780
|
+
* @returns Explore subagent with .tool, .run(), and .stream() methods
|
|
5781
|
+
*/
|
|
5782
|
+
createExploreSubagent(client, model, toolConfig) {
|
|
5783
|
+
return createExploreSubagent({
|
|
5784
|
+
...toolConfig,
|
|
5785
|
+
client,
|
|
5786
|
+
model,
|
|
5787
|
+
morphApiKey: this.config.apiKey
|
|
5788
|
+
});
|
|
5789
|
+
}
|
|
5418
5790
|
};
|
|
5419
5791
|
|
|
5420
5792
|
// tools/warp_grep/vercel.ts
|
|
@@ -5580,6 +5952,257 @@ function createEditFileTool3(config = {}) {
|
|
|
5580
5952
|
});
|
|
5581
5953
|
}
|
|
5582
5954
|
|
|
5955
|
+
// subagents/vercel.ts
|
|
5956
|
+
var import_ai4 = require("ai");
|
|
5957
|
+
var import_zod4 = require("zod");
|
|
5958
|
+
var DEFAULT_MAX_TURNS2 = {
|
|
5959
|
+
quick: 3,
|
|
5960
|
+
medium: 6,
|
|
5961
|
+
thorough: 12
|
|
5962
|
+
};
|
|
5963
|
+
function getMaxTurns2(config) {
|
|
5964
|
+
return config.maxTurns ?? DEFAULT_MAX_TURNS2[config.thoroughness ?? "medium"] ?? 6;
|
|
5965
|
+
}
|
|
5966
|
+
function createExploreSubagent2(config) {
|
|
5967
|
+
if (!config.repoRoot) {
|
|
5968
|
+
throw new Error("repoRoot is required for Explore subagent");
|
|
5969
|
+
}
|
|
5970
|
+
const warpGrep = new WarpGrepClient({
|
|
5971
|
+
morphApiKey: config.morphApiKey
|
|
5972
|
+
});
|
|
5973
|
+
const thoroughness = config.thoroughness ?? "medium";
|
|
5974
|
+
const replyTimeout = config.replyTimeout ?? 3e4;
|
|
5975
|
+
async function runExplore(prompt, callbacks = {}) {
|
|
5976
|
+
const startTime = Date.now();
|
|
5977
|
+
const allContexts = [];
|
|
5978
|
+
let searchCount = 0;
|
|
5979
|
+
const timeoutMs = config.timeout;
|
|
5980
|
+
const timeoutPromise = timeoutMs ? new Promise(
|
|
5981
|
+
(_, reject) => setTimeout(() => reject(new Error(`Exploration timed out after ${timeoutMs}ms`)), timeoutMs)
|
|
5982
|
+
) : null;
|
|
5983
|
+
const runPromise = (async () => {
|
|
5984
|
+
try {
|
|
5985
|
+
const codebaseSearchSchema = import_zod4.z.object({
|
|
5986
|
+
searchRequest: import_zod4.z.string().describe("Natural language description of what to search for")
|
|
5987
|
+
});
|
|
5988
|
+
const sendMessageSchema = import_zod4.z.object({
|
|
5989
|
+
message: import_zod4.z.string().describe("The message to send to the orchestrator")
|
|
5990
|
+
});
|
|
5991
|
+
const result = await (0, import_ai4.generateText)({
|
|
5992
|
+
model: config.model,
|
|
5993
|
+
system: getSystemPrompt2(thoroughness),
|
|
5994
|
+
prompt,
|
|
5995
|
+
tools: {
|
|
5996
|
+
codebase_search: (0, import_ai4.tool)({
|
|
5997
|
+
description: CODEBASE_SEARCH_TOOL.description,
|
|
5998
|
+
inputSchema: codebaseSearchSchema,
|
|
5999
|
+
execute: async (params) => {
|
|
6000
|
+
searchCount++;
|
|
6001
|
+
const warpResult = await warpGrep.execute({
|
|
6002
|
+
searchTerm: params.searchRequest,
|
|
6003
|
+
repoRoot: config.repoRoot,
|
|
6004
|
+
excludes: config.excludes,
|
|
6005
|
+
includes: config.includes
|
|
6006
|
+
});
|
|
6007
|
+
if (warpResult.contexts) {
|
|
6008
|
+
allContexts.push(...warpResult.contexts);
|
|
6009
|
+
}
|
|
6010
|
+
callbacks.onStep?.({
|
|
6011
|
+
step: searchCount,
|
|
6012
|
+
searchRequest: params.searchRequest,
|
|
6013
|
+
contextsFound: warpResult.contexts?.length ?? 0,
|
|
6014
|
+
isFinal: false
|
|
6015
|
+
});
|
|
6016
|
+
return formatResult(warpResult);
|
|
6017
|
+
}
|
|
6018
|
+
}),
|
|
6019
|
+
send_message: (0, import_ai4.tool)({
|
|
6020
|
+
description: SEND_MESSAGE_TOOL.description,
|
|
6021
|
+
inputSchema: sendMessageSchema,
|
|
6022
|
+
execute: async (params) => {
|
|
6023
|
+
const subagentMsg = {
|
|
6024
|
+
from: "explore",
|
|
6025
|
+
content: params.message,
|
|
6026
|
+
timestamp: Date.now()
|
|
6027
|
+
};
|
|
6028
|
+
const replyPromise = new Promise((resolve2) => {
|
|
6029
|
+
if (callbacks.onMessage) {
|
|
6030
|
+
callbacks.onMessage(subagentMsg, (replyText) => {
|
|
6031
|
+
resolve2(replyText);
|
|
6032
|
+
});
|
|
6033
|
+
} else {
|
|
6034
|
+
setTimeout(() => resolve2(""), replyTimeout);
|
|
6035
|
+
}
|
|
6036
|
+
});
|
|
6037
|
+
const reply = await Promise.race([
|
|
6038
|
+
replyPromise,
|
|
6039
|
+
new Promise(
|
|
6040
|
+
(resolve2) => setTimeout(() => resolve2(""), replyTimeout)
|
|
6041
|
+
)
|
|
6042
|
+
]);
|
|
6043
|
+
if (reply) {
|
|
6044
|
+
return `Response from orchestrator: ${reply}`;
|
|
6045
|
+
}
|
|
6046
|
+
return "No response. Continue with your best judgment.";
|
|
6047
|
+
}
|
|
6048
|
+
})
|
|
6049
|
+
},
|
|
6050
|
+
stopWhen: (0, import_ai4.stepCountIs)(getMaxTurns2(config))
|
|
6051
|
+
});
|
|
6052
|
+
callbacks.onStep?.({
|
|
6053
|
+
step: searchCount,
|
|
6054
|
+
searchRequest: "",
|
|
6055
|
+
contextsFound: allContexts.length,
|
|
6056
|
+
isFinal: true
|
|
6057
|
+
});
|
|
6058
|
+
const uniqueContexts = deduplicateContexts2(allContexts);
|
|
6059
|
+
return {
|
|
6060
|
+
success: true,
|
|
6061
|
+
summary: result.text || "Exploration completed but no summary was generated.",
|
|
6062
|
+
contexts: uniqueContexts,
|
|
6063
|
+
searchCount,
|
|
6064
|
+
durationMs: Date.now() - startTime
|
|
6065
|
+
};
|
|
6066
|
+
} catch (error) {
|
|
6067
|
+
return {
|
|
6068
|
+
success: false,
|
|
6069
|
+
summary: "",
|
|
6070
|
+
contexts: deduplicateContexts2(allContexts),
|
|
6071
|
+
searchCount,
|
|
6072
|
+
durationMs: Date.now() - startTime,
|
|
6073
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6074
|
+
};
|
|
6075
|
+
}
|
|
6076
|
+
})();
|
|
6077
|
+
if (timeoutPromise) {
|
|
6078
|
+
try {
|
|
6079
|
+
return await Promise.race([runPromise, timeoutPromise]);
|
|
6080
|
+
} catch (error) {
|
|
6081
|
+
return {
|
|
6082
|
+
success: false,
|
|
6083
|
+
summary: "",
|
|
6084
|
+
contexts: deduplicateContexts2(allContexts),
|
|
6085
|
+
searchCount,
|
|
6086
|
+
durationMs: Date.now() - startTime,
|
|
6087
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6088
|
+
};
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
return runPromise;
|
|
6092
|
+
}
|
|
6093
|
+
const exploreToolSchema = import_zod4.z.object({
|
|
6094
|
+
searchRequest: import_zod4.z.string().describe("What to explore in the codebase. Be specific about what you want to understand.")
|
|
6095
|
+
});
|
|
6096
|
+
const exploreTool = (0, import_ai4.tool)({
|
|
6097
|
+
description: "Explore a codebase to answer questions about code structure, find implementations, trace call chains, and understand architecture. Returns a summary of findings. Use this for broad exploration rather than pinpoint keyword searches.",
|
|
6098
|
+
inputSchema: exploreToolSchema,
|
|
6099
|
+
execute: async (params) => {
|
|
6100
|
+
const result = await runExplore(params.searchRequest);
|
|
6101
|
+
return {
|
|
6102
|
+
success: result.success,
|
|
6103
|
+
summary: result.summary,
|
|
6104
|
+
searchCount: result.searchCount,
|
|
6105
|
+
error: result.error
|
|
6106
|
+
};
|
|
6107
|
+
}
|
|
6108
|
+
});
|
|
6109
|
+
return {
|
|
6110
|
+
/** Vercel AI SDK tool for use as a tool in parent agents */
|
|
6111
|
+
tool: exploreTool,
|
|
6112
|
+
/** Run exploration with messaging support */
|
|
6113
|
+
run(prompt) {
|
|
6114
|
+
const messageHandlers = [];
|
|
6115
|
+
const stepHandlers = [];
|
|
6116
|
+
let resultPromise = null;
|
|
6117
|
+
const session = {
|
|
6118
|
+
on(event, handler) {
|
|
6119
|
+
if (event === "message") messageHandlers.push(handler);
|
|
6120
|
+
if (event === "step") stepHandlers.push(handler);
|
|
6121
|
+
return session;
|
|
6122
|
+
},
|
|
6123
|
+
send(_text) {
|
|
6124
|
+
},
|
|
6125
|
+
get result() {
|
|
6126
|
+
if (!resultPromise) {
|
|
6127
|
+
resultPromise = runExplore(prompt, {
|
|
6128
|
+
onStep: (step) => {
|
|
6129
|
+
for (const handler of stepHandlers) handler(step);
|
|
6130
|
+
},
|
|
6131
|
+
onMessage: (msg, reply) => {
|
|
6132
|
+
if (messageHandlers.length > 0) {
|
|
6133
|
+
for (const handler of messageHandlers) handler(msg, reply);
|
|
6134
|
+
} else {
|
|
6135
|
+
reply("");
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
});
|
|
6139
|
+
}
|
|
6140
|
+
return resultPromise;
|
|
6141
|
+
}
|
|
6142
|
+
};
|
|
6143
|
+
return session;
|
|
6144
|
+
},
|
|
6145
|
+
/** Stream exploration events as an async generator */
|
|
6146
|
+
async *stream(prompt) {
|
|
6147
|
+
const events = [];
|
|
6148
|
+
let resolveNext = null;
|
|
6149
|
+
let done = false;
|
|
6150
|
+
const resultPromise = runExplore(prompt, {
|
|
6151
|
+
onStep: (step) => {
|
|
6152
|
+
events.push({
|
|
6153
|
+
type: "step",
|
|
6154
|
+
step: step.step,
|
|
6155
|
+
searchRequest: step.searchRequest,
|
|
6156
|
+
contextsFound: step.contextsFound,
|
|
6157
|
+
isFinal: step.isFinal
|
|
6158
|
+
});
|
|
6159
|
+
resolveNext?.();
|
|
6160
|
+
},
|
|
6161
|
+
onMessage: (msg, reply) => {
|
|
6162
|
+
events.push({
|
|
6163
|
+
type: "message",
|
|
6164
|
+
from: msg.from,
|
|
6165
|
+
content: msg.content,
|
|
6166
|
+
timestamp: msg.timestamp
|
|
6167
|
+
});
|
|
6168
|
+
resolveNext?.();
|
|
6169
|
+
reply("Continue with your best judgment.");
|
|
6170
|
+
}
|
|
6171
|
+
});
|
|
6172
|
+
while (!done) {
|
|
6173
|
+
if (events.length > 0) {
|
|
6174
|
+
yield events.shift();
|
|
6175
|
+
} else {
|
|
6176
|
+
const raceResult = await Promise.race([
|
|
6177
|
+
resultPromise.then((r) => ({ type: "done", result: r })),
|
|
6178
|
+
new Promise((resolve2) => {
|
|
6179
|
+
resolveNext = () => resolve2({ type: "event" });
|
|
6180
|
+
})
|
|
6181
|
+
]);
|
|
6182
|
+
if (raceResult.type === "done") {
|
|
6183
|
+
while (events.length > 0) {
|
|
6184
|
+
yield events.shift();
|
|
6185
|
+
}
|
|
6186
|
+
done = true;
|
|
6187
|
+
return raceResult.result;
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
}
|
|
6191
|
+
return await resultPromise;
|
|
6192
|
+
}
|
|
6193
|
+
};
|
|
6194
|
+
}
|
|
6195
|
+
function deduplicateContexts2(contexts) {
|
|
6196
|
+
const map = /* @__PURE__ */ new Map();
|
|
6197
|
+
for (const ctx of contexts) {
|
|
6198
|
+
const existing = map.get(ctx.file);
|
|
6199
|
+
if (!existing || ctx.content.length > existing.content.length) {
|
|
6200
|
+
map.set(ctx.file, ctx);
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6203
|
+
return Array.from(map.values());
|
|
6204
|
+
}
|
|
6205
|
+
|
|
5583
6206
|
// factories/vercel.ts
|
|
5584
6207
|
var VercelToolFactory = class {
|
|
5585
6208
|
constructor(config) {
|
|
@@ -5633,6 +6256,20 @@ var VercelToolFactory = class {
|
|
|
5633
6256
|
morphApiKey: this.config.apiKey
|
|
5634
6257
|
});
|
|
5635
6258
|
}
|
|
6259
|
+
/**
|
|
6260
|
+
* Create an Explore subagent that searches the codebase and returns summaries
|
|
6261
|
+
*
|
|
6262
|
+
* @param model - Vercel AI SDK model instance
|
|
6263
|
+
* @param toolConfig - Subagent configuration (morphApiKey inherited from MorphClient)
|
|
6264
|
+
* @returns Explore subagent with .tool, .run(), and .stream() methods
|
|
6265
|
+
*/
|
|
6266
|
+
createExploreSubagent(model, toolConfig) {
|
|
6267
|
+
return createExploreSubagent2({
|
|
6268
|
+
...toolConfig,
|
|
6269
|
+
model,
|
|
6270
|
+
morphApiKey: this.config.apiKey
|
|
6271
|
+
});
|
|
6272
|
+
}
|
|
5636
6273
|
};
|
|
5637
6274
|
|
|
5638
6275
|
// client.ts
|