@morphllm/morphsdk 0.2.137 → 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-AVIE6SRT.js → chunk-3J74OXN6.js} +2 -2
- package/dist/chunk-3T5W2D2W.js +288 -0
- package/dist/chunk-3T5W2D2W.js.map +1 -0
- package/dist/{chunk-HRJENFMZ.js → chunk-4J5UW34J.js} +4 -4
- package/dist/{chunk-L37HJNBY.js → chunk-5CBMLTG5.js} +5 -5
- package/dist/{chunk-5UDCVVZE.js → chunk-6W3X76KE.js} +21 -6
- package/dist/chunk-6W3X76KE.js.map +1 -0
- package/dist/{chunk-LQIGX3MX.js → chunk-6WSZDCGP.js} +2 -2
- package/dist/{chunk-6EQ5IEK6.js → chunk-73ZLTWKF.js} +4 -4
- package/dist/{chunk-Y4QRWCMI.js → chunk-7RCHQN7F.js} +2 -2
- package/dist/{chunk-5BLLE3UZ.js → chunk-ATAQZLQN.js} +2 -2
- package/dist/{chunk-JTBQIPLB.js → chunk-B55ZEX4M.js} +2 -2
- package/dist/{chunk-RI2GNU2V.js → chunk-DRAQDTSR.js} +2 -2
- package/dist/{chunk-4546AOKY.js → chunk-EEBGEMOO.js} +2 -2
- package/dist/{chunk-4YEGLW4W.js → chunk-EHRKLQ62.js} +2 -2
- package/dist/chunk-GQX4PKXZ.js +265 -0
- package/dist/chunk-GQX4PKXZ.js.map +1 -0
- package/dist/{chunk-SJKGUXNG.js → chunk-MHNCFELG.js} +4 -4
- package/dist/{chunk-3GEXJ6WJ.js → chunk-MTD2JOO7.js} +1 -1
- package/dist/{chunk-ODYZXYFX.js → chunk-NEVPVOTT.js} +3 -3
- package/dist/{chunk-JNMYWTLZ.js → chunk-NGHLDI64.js} +2 -2
- package/dist/{chunk-7JA4SBAA.js → chunk-OICUUS5Y.js} +4 -4
- package/dist/{chunk-3OG25CSW.js → chunk-TCXBKB7P.js} +2 -2
- package/dist/{chunk-2NVSFPMB.js → chunk-ULMSWACH.js} +9 -7
- package/dist/chunk-ULMSWACH.js.map +1 -0
- package/dist/{chunk-K632JRRH.js → chunk-XIEU3N3R.js} +4 -4
- package/dist/{chunk-D7E5WBMV.js → chunk-XUDE6SOY.js} +57 -21
- package/dist/{chunk-D7E5WBMV.js.map → chunk-XUDE6SOY.js.map} +1 -1
- package/dist/{chunk-MJZ5HL6P.js → chunk-ZUG2L4BJ.js} +2 -2
- package/dist/{chunk-OPVFUVNJ.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 +653 -14
- 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 +656 -17
- 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 +23 -6
- 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 +23 -6
- 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 +23 -6
- 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 +23 -6
- 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 +23 -6
- 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 +23 -6
- 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 +23 -6
- 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-2NVSFPMB.js.map +0 -1
- package/dist/chunk-5UDCVVZE.js.map +0 -1
- /package/dist/{chunk-AVIE6SRT.js.map → chunk-3J74OXN6.js.map} +0 -0
- /package/dist/{chunk-HRJENFMZ.js.map → chunk-4J5UW34J.js.map} +0 -0
- /package/dist/{chunk-L37HJNBY.js.map → chunk-5CBMLTG5.js.map} +0 -0
- /package/dist/{chunk-LQIGX3MX.js.map → chunk-6WSZDCGP.js.map} +0 -0
- /package/dist/{chunk-6EQ5IEK6.js.map → chunk-73ZLTWKF.js.map} +0 -0
- /package/dist/{chunk-Y4QRWCMI.js.map → chunk-7RCHQN7F.js.map} +0 -0
- /package/dist/{chunk-5BLLE3UZ.js.map → chunk-ATAQZLQN.js.map} +0 -0
- /package/dist/{chunk-JTBQIPLB.js.map → chunk-B55ZEX4M.js.map} +0 -0
- /package/dist/{chunk-RI2GNU2V.js.map → chunk-DRAQDTSR.js.map} +0 -0
- /package/dist/{chunk-4546AOKY.js.map → chunk-EEBGEMOO.js.map} +0 -0
- /package/dist/{chunk-4YEGLW4W.js.map → chunk-EHRKLQ62.js.map} +0 -0
- /package/dist/{chunk-SJKGUXNG.js.map → chunk-MHNCFELG.js.map} +0 -0
- /package/dist/{chunk-3GEXJ6WJ.js.map → chunk-MTD2JOO7.js.map} +0 -0
- /package/dist/{chunk-ODYZXYFX.js.map → chunk-NEVPVOTT.js.map} +0 -0
- /package/dist/{chunk-JNMYWTLZ.js.map → chunk-NGHLDI64.js.map} +0 -0
- /package/dist/{chunk-7JA4SBAA.js.map → chunk-OICUUS5Y.js.map} +0 -0
- /package/dist/{chunk-3OG25CSW.js.map → chunk-TCXBKB7P.js.map} +0 -0
- /package/dist/{chunk-K632JRRH.js.map → chunk-XIEU3N3R.js.map} +0 -0
- /package/dist/{chunk-MJZ5HL6P.js.map → chunk-ZUG2L4BJ.js.map} +0 -0
- /package/dist/{chunk-OPVFUVNJ.js.map → chunk-ZYN64ZVG.js.map} +0 -0
package/dist/index.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",
|
|
@@ -2878,9 +2893,11 @@ async function callModel(messages, model, options = {}) {
|
|
|
2878
2893
|
const baseUrl = options.morphApiUrl || DEFAULT_API_URL3;
|
|
2879
2894
|
const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || "";
|
|
2880
2895
|
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
2896
|
+
const parsedUrl = new URL(baseUrl);
|
|
2897
|
+
const baseURL = parsedUrl.pathname === "/" ? `${baseUrl}/v1` : baseUrl;
|
|
2881
2898
|
const client = new import_openai2.default({
|
|
2882
2899
|
apiKey,
|
|
2883
|
-
baseURL
|
|
2900
|
+
baseURL,
|
|
2884
2901
|
maxRetries: options.retryConfig?.maxRetries,
|
|
2885
2902
|
timeout: timeoutMs,
|
|
2886
2903
|
defaultHeaders: { "X-Morph-SDK-Version": SDK_VERSION }
|
|
@@ -4921,7 +4938,7 @@ var TOOL_PARAMETERS = {
|
|
|
4921
4938
|
required: ["search_term"]
|
|
4922
4939
|
};
|
|
4923
4940
|
function createWarpGrepTool(config) {
|
|
4924
|
-
const
|
|
4941
|
+
const tool5 = {
|
|
4925
4942
|
type: "function",
|
|
4926
4943
|
function: {
|
|
4927
4944
|
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
@@ -4929,7 +4946,7 @@ function createWarpGrepTool(config) {
|
|
|
4929
4946
|
parameters: TOOL_PARAMETERS
|
|
4930
4947
|
}
|
|
4931
4948
|
};
|
|
4932
|
-
return Object.assign(
|
|
4949
|
+
return Object.assign(tool5, {
|
|
4933
4950
|
execute: async (input) => {
|
|
4934
4951
|
return executeToolCall(input, config);
|
|
4935
4952
|
},
|
|
@@ -4940,7 +4957,7 @@ function createWarpGrepTool(config) {
|
|
|
4940
4957
|
}
|
|
4941
4958
|
function createGitHubSearchTool(config) {
|
|
4942
4959
|
const client = new WarpGrepClient(config);
|
|
4943
|
-
const
|
|
4960
|
+
const tool5 = {
|
|
4944
4961
|
type: "function",
|
|
4945
4962
|
function: {
|
|
4946
4963
|
name: GITHUB_SEARCH_TOOL_NAME,
|
|
@@ -4948,7 +4965,7 @@ function createGitHubSearchTool(config) {
|
|
|
4948
4965
|
parameters: GITHUB_SEARCH_INPUT_SCHEMA
|
|
4949
4966
|
}
|
|
4950
4967
|
};
|
|
4951
|
-
return Object.assign(
|
|
4968
|
+
return Object.assign(tool5, {
|
|
4952
4969
|
execute: async (input) => {
|
|
4953
4970
|
const github = input.github_url || input.owner_repo;
|
|
4954
4971
|
if (!github) {
|
|
@@ -5228,12 +5245,12 @@ var INPUT_SCHEMA = {
|
|
|
5228
5245
|
required: ["search_term"]
|
|
5229
5246
|
};
|
|
5230
5247
|
function createWarpGrepTool2(config) {
|
|
5231
|
-
const
|
|
5248
|
+
const tool5 = {
|
|
5232
5249
|
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
5233
5250
|
description: config.description ?? WARP_GREP_DESCRIPTION,
|
|
5234
5251
|
input_schema: INPUT_SCHEMA
|
|
5235
5252
|
};
|
|
5236
|
-
return Object.assign(
|
|
5253
|
+
return Object.assign(tool5, {
|
|
5237
5254
|
execute: async (input) => {
|
|
5238
5255
|
return executeToolCall(input, config);
|
|
5239
5256
|
},
|
|
@@ -5244,12 +5261,12 @@ function createWarpGrepTool2(config) {
|
|
|
5244
5261
|
}
|
|
5245
5262
|
function createGitHubSearchTool2(config) {
|
|
5246
5263
|
const client = new WarpGrepClient(config);
|
|
5247
|
-
const
|
|
5264
|
+
const tool5 = {
|
|
5248
5265
|
name: GITHUB_SEARCH_TOOL_NAME,
|
|
5249
5266
|
description: GITHUB_SEARCH_DESCRIPTION,
|
|
5250
5267
|
input_schema: GITHUB_SEARCH_INPUT_SCHEMA
|
|
5251
5268
|
};
|
|
5252
|
-
return Object.assign(
|
|
5269
|
+
return Object.assign(tool5, {
|
|
5253
5270
|
execute: async (input) => {
|
|
5254
5271
|
const github = input.github_url || input.owner_repo;
|
|
5255
5272
|
if (!github) {
|
|
@@ -5382,6 +5399,347 @@ function createEditFileTool2(config = {}) {
|
|
|
5382
5399
|
});
|
|
5383
5400
|
}
|
|
5384
5401
|
|
|
5402
|
+
// subagents/prompts.ts
|
|
5403
|
+
var THOROUGHNESS_INSTRUCTIONS = {
|
|
5404
|
+
quick: `Do 1-2 targeted searches. Find the most relevant file/function quickly and summarize. Don't go deep.`,
|
|
5405
|
+
medium: `Do 2-4 searches. Start broad, then follow up on the most promising leads. Cover the main aspects.`,
|
|
5406
|
+
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.`
|
|
5407
|
+
};
|
|
5408
|
+
function getSystemPrompt2(thoroughness = "medium") {
|
|
5409
|
+
return `You are a codebase exploration specialist. Your job is to search a codebase and return a concise, accurate summary of what you find.
|
|
5410
|
+
|
|
5411
|
+
## Mode
|
|
5412
|
+
READ-ONLY. You cannot modify files. You can only search and read code.
|
|
5413
|
+
|
|
5414
|
+
## Strategy
|
|
5415
|
+
${THOROUGHNESS_INSTRUCTIONS[thoroughness]}
|
|
5416
|
+
|
|
5417
|
+
- Use multiple focused searches rather than one vague search
|
|
5418
|
+
- Follow imports, function calls, and type references to build complete understanding
|
|
5419
|
+
- If a search returns no results, try alternative terms (e.g., "auth" vs "authentication" vs "login")
|
|
5420
|
+
- Look at both implementation and tests when relevant
|
|
5421
|
+
|
|
5422
|
+
## Communication
|
|
5423
|
+
You have a \`send_message\` tool. Use it when:
|
|
5424
|
+
- You hit a fork in the road and need guidance ("Found auth in both src/middleware/ and legacy/auth/. Which should I focus on?")
|
|
5425
|
+
- You need clarification on ambiguous requests ("There are 3 auth strategies: JWT, session, OAuth. Which one?")
|
|
5426
|
+
- 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.")
|
|
5427
|
+
|
|
5428
|
+
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.
|
|
5429
|
+
|
|
5430
|
+
## Output
|
|
5431
|
+
When you have enough information, output your final summary. Structure it as:
|
|
5432
|
+
1. Direct answer to the question
|
|
5433
|
+
2. Key files and their roles
|
|
5434
|
+
3. How the pieces connect
|
|
5435
|
+
|
|
5436
|
+
Be concise. The summary should be useful to another AI model that will use your findings to complete a task.`;
|
|
5437
|
+
}
|
|
5438
|
+
var CODEBASE_SEARCH_TOOL = {
|
|
5439
|
+
name: "codebase_search",
|
|
5440
|
+
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.",
|
|
5441
|
+
input_schema: {
|
|
5442
|
+
type: "object",
|
|
5443
|
+
properties: {
|
|
5444
|
+
searchRequest: {
|
|
5445
|
+
type: "string",
|
|
5446
|
+
description: "Natural language description of what to search for in the codebase"
|
|
5447
|
+
}
|
|
5448
|
+
},
|
|
5449
|
+
required: ["searchRequest"],
|
|
5450
|
+
additionalProperties: false
|
|
5451
|
+
}
|
|
5452
|
+
};
|
|
5453
|
+
var SEND_MESSAGE_TOOL = {
|
|
5454
|
+
name: "send_message",
|
|
5455
|
+
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.",
|
|
5456
|
+
input_schema: {
|
|
5457
|
+
type: "object",
|
|
5458
|
+
properties: {
|
|
5459
|
+
message: {
|
|
5460
|
+
type: "string",
|
|
5461
|
+
description: "The message to send to the orchestrator"
|
|
5462
|
+
}
|
|
5463
|
+
},
|
|
5464
|
+
required: ["message"],
|
|
5465
|
+
additionalProperties: false
|
|
5466
|
+
}
|
|
5467
|
+
};
|
|
5468
|
+
|
|
5469
|
+
// subagents/anthropic.ts
|
|
5470
|
+
var DEFAULT_MAX_TURNS = {
|
|
5471
|
+
quick: 3,
|
|
5472
|
+
medium: 6,
|
|
5473
|
+
thorough: 12
|
|
5474
|
+
};
|
|
5475
|
+
function getMaxTurns(config) {
|
|
5476
|
+
return config.maxTurns ?? DEFAULT_MAX_TURNS[config.thoroughness ?? "medium"] ?? 6;
|
|
5477
|
+
}
|
|
5478
|
+
var TOOLS = [
|
|
5479
|
+
{
|
|
5480
|
+
name: CODEBASE_SEARCH_TOOL.name,
|
|
5481
|
+
description: CODEBASE_SEARCH_TOOL.description,
|
|
5482
|
+
input_schema: CODEBASE_SEARCH_TOOL.input_schema
|
|
5483
|
+
},
|
|
5484
|
+
{
|
|
5485
|
+
name: SEND_MESSAGE_TOOL.name,
|
|
5486
|
+
description: SEND_MESSAGE_TOOL.description,
|
|
5487
|
+
input_schema: SEND_MESSAGE_TOOL.input_schema
|
|
5488
|
+
}
|
|
5489
|
+
];
|
|
5490
|
+
function createExploreSubagent(config) {
|
|
5491
|
+
if (!config.repoRoot) {
|
|
5492
|
+
throw new Error("repoRoot is required for Explore subagent");
|
|
5493
|
+
}
|
|
5494
|
+
const warpGrep = new WarpGrepClient({
|
|
5495
|
+
morphApiKey: config.morphApiKey
|
|
5496
|
+
});
|
|
5497
|
+
const thoroughness = config.thoroughness ?? "medium";
|
|
5498
|
+
const maxTurns = getMaxTurns(config);
|
|
5499
|
+
const replyTimeout = config.replyTimeout ?? 3e4;
|
|
5500
|
+
async function runExplore(prompt, callbacks = {}) {
|
|
5501
|
+
const startTime = Date.now();
|
|
5502
|
+
const allContexts = [];
|
|
5503
|
+
let searchCount = 0;
|
|
5504
|
+
const timeoutMs = config.timeout;
|
|
5505
|
+
try {
|
|
5506
|
+
const messages = [{ role: "user", content: prompt }];
|
|
5507
|
+
let turns = 0;
|
|
5508
|
+
while (turns < maxTurns) {
|
|
5509
|
+
if (timeoutMs && Date.now() - startTime > timeoutMs) {
|
|
5510
|
+
return {
|
|
5511
|
+
success: false,
|
|
5512
|
+
summary: "",
|
|
5513
|
+
contexts: deduplicateContexts(allContexts),
|
|
5514
|
+
searchCount,
|
|
5515
|
+
durationMs: Date.now() - startTime,
|
|
5516
|
+
error: `Exploration timed out after ${timeoutMs}ms`
|
|
5517
|
+
};
|
|
5518
|
+
}
|
|
5519
|
+
const response = await config.client.messages.create({
|
|
5520
|
+
model: config.model,
|
|
5521
|
+
max_tokens: 4096,
|
|
5522
|
+
system: getSystemPrompt2(thoroughness),
|
|
5523
|
+
tools: TOOLS,
|
|
5524
|
+
messages
|
|
5525
|
+
});
|
|
5526
|
+
turns++;
|
|
5527
|
+
if (response.stop_reason === "end_turn" || !response.content.some((b) => b.type === "tool_use")) {
|
|
5528
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
5529
|
+
const summary = textBlock?.text || "Exploration completed but no summary was generated.";
|
|
5530
|
+
callbacks.onStep?.({
|
|
5531
|
+
step: searchCount,
|
|
5532
|
+
searchRequest: "",
|
|
5533
|
+
contextsFound: allContexts.length,
|
|
5534
|
+
isFinal: true
|
|
5535
|
+
});
|
|
5536
|
+
return {
|
|
5537
|
+
success: true,
|
|
5538
|
+
summary,
|
|
5539
|
+
contexts: deduplicateContexts(allContexts),
|
|
5540
|
+
searchCount,
|
|
5541
|
+
durationMs: Date.now() - startTime
|
|
5542
|
+
};
|
|
5543
|
+
}
|
|
5544
|
+
messages.push({ role: "assistant", content: response.content });
|
|
5545
|
+
const toolResults = [];
|
|
5546
|
+
for (const block of response.content) {
|
|
5547
|
+
if (block.type !== "tool_use") continue;
|
|
5548
|
+
if (block.name === "codebase_search") {
|
|
5549
|
+
searchCount++;
|
|
5550
|
+
const input = block.input;
|
|
5551
|
+
const warpResult = await warpGrep.execute({
|
|
5552
|
+
searchTerm: input.searchRequest,
|
|
5553
|
+
repoRoot: config.repoRoot,
|
|
5554
|
+
excludes: config.excludes,
|
|
5555
|
+
includes: config.includes
|
|
5556
|
+
});
|
|
5557
|
+
if (warpResult.contexts) {
|
|
5558
|
+
allContexts.push(...warpResult.contexts);
|
|
5559
|
+
}
|
|
5560
|
+
callbacks.onStep?.({
|
|
5561
|
+
step: searchCount,
|
|
5562
|
+
searchRequest: input.searchRequest,
|
|
5563
|
+
contextsFound: warpResult.contexts?.length ?? 0,
|
|
5564
|
+
isFinal: false
|
|
5565
|
+
});
|
|
5566
|
+
toolResults.push({
|
|
5567
|
+
type: "tool_result",
|
|
5568
|
+
tool_use_id: block.id,
|
|
5569
|
+
content: formatResult(warpResult)
|
|
5570
|
+
});
|
|
5571
|
+
} else if (block.name === "send_message") {
|
|
5572
|
+
const input = block.input;
|
|
5573
|
+
const subagentMsg = {
|
|
5574
|
+
from: "explore",
|
|
5575
|
+
content: input.message,
|
|
5576
|
+
timestamp: Date.now()
|
|
5577
|
+
};
|
|
5578
|
+
let replyText = "";
|
|
5579
|
+
if (callbacks.onMessage) {
|
|
5580
|
+
replyText = await Promise.race([
|
|
5581
|
+
new Promise((resolve2) => {
|
|
5582
|
+
callbacks.onMessage(subagentMsg, (text) => {
|
|
5583
|
+
resolve2(text);
|
|
5584
|
+
});
|
|
5585
|
+
}),
|
|
5586
|
+
new Promise(
|
|
5587
|
+
(resolve2) => setTimeout(() => resolve2(""), replyTimeout)
|
|
5588
|
+
)
|
|
5589
|
+
]);
|
|
5590
|
+
}
|
|
5591
|
+
const toolResponse = replyText ? `Response from orchestrator: ${replyText}` : "No response. Continue with your best judgment.";
|
|
5592
|
+
toolResults.push({
|
|
5593
|
+
type: "tool_result",
|
|
5594
|
+
tool_use_id: block.id,
|
|
5595
|
+
content: toolResponse
|
|
5596
|
+
});
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
messages.push({ role: "user", content: toolResults });
|
|
5600
|
+
}
|
|
5601
|
+
return {
|
|
5602
|
+
success: true,
|
|
5603
|
+
summary: "Exploration completed (max turns reached).",
|
|
5604
|
+
contexts: deduplicateContexts(allContexts),
|
|
5605
|
+
searchCount,
|
|
5606
|
+
durationMs: Date.now() - startTime
|
|
5607
|
+
};
|
|
5608
|
+
} catch (error) {
|
|
5609
|
+
return {
|
|
5610
|
+
success: false,
|
|
5611
|
+
summary: "",
|
|
5612
|
+
contexts: deduplicateContexts(allContexts),
|
|
5613
|
+
searchCount,
|
|
5614
|
+
durationMs: Date.now() - startTime,
|
|
5615
|
+
error: error instanceof Error ? error.message : String(error)
|
|
5616
|
+
};
|
|
5617
|
+
}
|
|
5618
|
+
}
|
|
5619
|
+
const exploreTool = Object.assign(
|
|
5620
|
+
{
|
|
5621
|
+
name: "explore",
|
|
5622
|
+
description: "Explore a codebase to answer questions about code structure, find implementations, trace call chains, and understand architecture. Returns a summary of findings.",
|
|
5623
|
+
input_schema: {
|
|
5624
|
+
type: "object",
|
|
5625
|
+
properties: {
|
|
5626
|
+
searchRequest: {
|
|
5627
|
+
type: "string",
|
|
5628
|
+
description: "What to explore in the codebase. Be specific about what you want to understand."
|
|
5629
|
+
}
|
|
5630
|
+
},
|
|
5631
|
+
required: ["searchRequest"]
|
|
5632
|
+
}
|
|
5633
|
+
},
|
|
5634
|
+
{
|
|
5635
|
+
execute: async (input) => {
|
|
5636
|
+
return runExplore(input.searchRequest);
|
|
5637
|
+
},
|
|
5638
|
+
formatResult: (result) => {
|
|
5639
|
+
if (!result.success) {
|
|
5640
|
+
return `Exploration failed: ${result.error}`;
|
|
5641
|
+
}
|
|
5642
|
+
return result.summary;
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5645
|
+
);
|
|
5646
|
+
return {
|
|
5647
|
+
/** Anthropic Tool definition for use in parent agents */
|
|
5648
|
+
tool: exploreTool,
|
|
5649
|
+
/** Run exploration with messaging support */
|
|
5650
|
+
run(prompt) {
|
|
5651
|
+
const messageHandlers = [];
|
|
5652
|
+
const stepHandlers = [];
|
|
5653
|
+
let resultPromise = null;
|
|
5654
|
+
const session = {
|
|
5655
|
+
on(event, handler) {
|
|
5656
|
+
if (event === "message") messageHandlers.push(handler);
|
|
5657
|
+
if (event === "step") stepHandlers.push(handler);
|
|
5658
|
+
return session;
|
|
5659
|
+
},
|
|
5660
|
+
send(_text) {
|
|
5661
|
+
},
|
|
5662
|
+
get result() {
|
|
5663
|
+
if (!resultPromise) {
|
|
5664
|
+
resultPromise = runExplore(prompt, {
|
|
5665
|
+
onStep: (step) => {
|
|
5666
|
+
for (const handler of stepHandlers) handler(step);
|
|
5667
|
+
},
|
|
5668
|
+
onMessage: (msg, reply) => {
|
|
5669
|
+
if (messageHandlers.length > 0) {
|
|
5670
|
+
for (const handler of messageHandlers) handler(msg, reply);
|
|
5671
|
+
} else {
|
|
5672
|
+
reply("");
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
5675
|
+
});
|
|
5676
|
+
}
|
|
5677
|
+
return resultPromise;
|
|
5678
|
+
}
|
|
5679
|
+
};
|
|
5680
|
+
return session;
|
|
5681
|
+
},
|
|
5682
|
+
/** Stream exploration events as an async generator */
|
|
5683
|
+
async *stream(prompt) {
|
|
5684
|
+
const events = [];
|
|
5685
|
+
let resolveNext = null;
|
|
5686
|
+
let done = false;
|
|
5687
|
+
const resultPromise = runExplore(prompt, {
|
|
5688
|
+
onStep: (step) => {
|
|
5689
|
+
events.push({
|
|
5690
|
+
type: "step",
|
|
5691
|
+
step: step.step,
|
|
5692
|
+
searchRequest: step.searchRequest,
|
|
5693
|
+
contextsFound: step.contextsFound,
|
|
5694
|
+
isFinal: step.isFinal
|
|
5695
|
+
});
|
|
5696
|
+
resolveNext?.();
|
|
5697
|
+
},
|
|
5698
|
+
onMessage: (msg, reply) => {
|
|
5699
|
+
events.push({
|
|
5700
|
+
type: "message",
|
|
5701
|
+
from: msg.from,
|
|
5702
|
+
content: msg.content,
|
|
5703
|
+
timestamp: msg.timestamp
|
|
5704
|
+
});
|
|
5705
|
+
resolveNext?.();
|
|
5706
|
+
reply("Continue with your best judgment.");
|
|
5707
|
+
}
|
|
5708
|
+
});
|
|
5709
|
+
while (!done) {
|
|
5710
|
+
if (events.length > 0) {
|
|
5711
|
+
yield events.shift();
|
|
5712
|
+
} else {
|
|
5713
|
+
const raceResult = await Promise.race([
|
|
5714
|
+
resultPromise.then((r) => ({ type: "done", result: r })),
|
|
5715
|
+
new Promise((resolve2) => {
|
|
5716
|
+
resolveNext = () => resolve2({ type: "event" });
|
|
5717
|
+
})
|
|
5718
|
+
]);
|
|
5719
|
+
if (raceResult.type === "done") {
|
|
5720
|
+
while (events.length > 0) {
|
|
5721
|
+
yield events.shift();
|
|
5722
|
+
}
|
|
5723
|
+
done = true;
|
|
5724
|
+
return raceResult.result;
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5727
|
+
}
|
|
5728
|
+
return await resultPromise;
|
|
5729
|
+
}
|
|
5730
|
+
};
|
|
5731
|
+
}
|
|
5732
|
+
function deduplicateContexts(contexts) {
|
|
5733
|
+
const map = /* @__PURE__ */ new Map();
|
|
5734
|
+
for (const ctx of contexts) {
|
|
5735
|
+
const existing = map.get(ctx.file);
|
|
5736
|
+
if (!existing || ctx.content.length > existing.content.length) {
|
|
5737
|
+
map.set(ctx.file, ctx);
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
return Array.from(map.values());
|
|
5741
|
+
}
|
|
5742
|
+
|
|
5385
5743
|
// factories/anthropic.ts
|
|
5386
5744
|
var AnthropicToolFactory = class {
|
|
5387
5745
|
constructor(config) {
|
|
@@ -5435,6 +5793,22 @@ var AnthropicToolFactory = class {
|
|
|
5435
5793
|
morphApiKey: this.config.apiKey
|
|
5436
5794
|
});
|
|
5437
5795
|
}
|
|
5796
|
+
/**
|
|
5797
|
+
* Create an Explore subagent that searches the codebase and returns summaries
|
|
5798
|
+
*
|
|
5799
|
+
* @param client - Anthropic SDK client instance
|
|
5800
|
+
* @param model - Model name (e.g., 'claude-haiku-4-5-20251001')
|
|
5801
|
+
* @param toolConfig - Subagent configuration (morphApiKey inherited from MorphClient)
|
|
5802
|
+
* @returns Explore subagent with .tool, .run(), and .stream() methods
|
|
5803
|
+
*/
|
|
5804
|
+
createExploreSubagent(client, model, toolConfig) {
|
|
5805
|
+
return createExploreSubagent({
|
|
5806
|
+
...toolConfig,
|
|
5807
|
+
client,
|
|
5808
|
+
model,
|
|
5809
|
+
morphApiKey: this.config.apiKey
|
|
5810
|
+
});
|
|
5811
|
+
}
|
|
5438
5812
|
};
|
|
5439
5813
|
|
|
5440
5814
|
// tools/warp_grep/vercel.ts
|
|
@@ -5600,6 +5974,257 @@ function createEditFileTool3(config = {}) {
|
|
|
5600
5974
|
});
|
|
5601
5975
|
}
|
|
5602
5976
|
|
|
5977
|
+
// subagents/vercel.ts
|
|
5978
|
+
var import_ai4 = require("ai");
|
|
5979
|
+
var import_zod4 = require("zod");
|
|
5980
|
+
var DEFAULT_MAX_TURNS2 = {
|
|
5981
|
+
quick: 3,
|
|
5982
|
+
medium: 6,
|
|
5983
|
+
thorough: 12
|
|
5984
|
+
};
|
|
5985
|
+
function getMaxTurns2(config) {
|
|
5986
|
+
return config.maxTurns ?? DEFAULT_MAX_TURNS2[config.thoroughness ?? "medium"] ?? 6;
|
|
5987
|
+
}
|
|
5988
|
+
function createExploreSubagent2(config) {
|
|
5989
|
+
if (!config.repoRoot) {
|
|
5990
|
+
throw new Error("repoRoot is required for Explore subagent");
|
|
5991
|
+
}
|
|
5992
|
+
const warpGrep = new WarpGrepClient({
|
|
5993
|
+
morphApiKey: config.morphApiKey
|
|
5994
|
+
});
|
|
5995
|
+
const thoroughness = config.thoroughness ?? "medium";
|
|
5996
|
+
const replyTimeout = config.replyTimeout ?? 3e4;
|
|
5997
|
+
async function runExplore(prompt, callbacks = {}) {
|
|
5998
|
+
const startTime = Date.now();
|
|
5999
|
+
const allContexts = [];
|
|
6000
|
+
let searchCount = 0;
|
|
6001
|
+
const timeoutMs = config.timeout;
|
|
6002
|
+
const timeoutPromise = timeoutMs ? new Promise(
|
|
6003
|
+
(_, reject) => setTimeout(() => reject(new Error(`Exploration timed out after ${timeoutMs}ms`)), timeoutMs)
|
|
6004
|
+
) : null;
|
|
6005
|
+
const runPromise = (async () => {
|
|
6006
|
+
try {
|
|
6007
|
+
const codebaseSearchSchema = import_zod4.z.object({
|
|
6008
|
+
searchRequest: import_zod4.z.string().describe("Natural language description of what to search for")
|
|
6009
|
+
});
|
|
6010
|
+
const sendMessageSchema = import_zod4.z.object({
|
|
6011
|
+
message: import_zod4.z.string().describe("The message to send to the orchestrator")
|
|
6012
|
+
});
|
|
6013
|
+
const result = await (0, import_ai4.generateText)({
|
|
6014
|
+
model: config.model,
|
|
6015
|
+
system: getSystemPrompt2(thoroughness),
|
|
6016
|
+
prompt,
|
|
6017
|
+
tools: {
|
|
6018
|
+
codebase_search: (0, import_ai4.tool)({
|
|
6019
|
+
description: CODEBASE_SEARCH_TOOL.description,
|
|
6020
|
+
inputSchema: codebaseSearchSchema,
|
|
6021
|
+
execute: async (params) => {
|
|
6022
|
+
searchCount++;
|
|
6023
|
+
const warpResult = await warpGrep.execute({
|
|
6024
|
+
searchTerm: params.searchRequest,
|
|
6025
|
+
repoRoot: config.repoRoot,
|
|
6026
|
+
excludes: config.excludes,
|
|
6027
|
+
includes: config.includes
|
|
6028
|
+
});
|
|
6029
|
+
if (warpResult.contexts) {
|
|
6030
|
+
allContexts.push(...warpResult.contexts);
|
|
6031
|
+
}
|
|
6032
|
+
callbacks.onStep?.({
|
|
6033
|
+
step: searchCount,
|
|
6034
|
+
searchRequest: params.searchRequest,
|
|
6035
|
+
contextsFound: warpResult.contexts?.length ?? 0,
|
|
6036
|
+
isFinal: false
|
|
6037
|
+
});
|
|
6038
|
+
return formatResult(warpResult);
|
|
6039
|
+
}
|
|
6040
|
+
}),
|
|
6041
|
+
send_message: (0, import_ai4.tool)({
|
|
6042
|
+
description: SEND_MESSAGE_TOOL.description,
|
|
6043
|
+
inputSchema: sendMessageSchema,
|
|
6044
|
+
execute: async (params) => {
|
|
6045
|
+
const subagentMsg = {
|
|
6046
|
+
from: "explore",
|
|
6047
|
+
content: params.message,
|
|
6048
|
+
timestamp: Date.now()
|
|
6049
|
+
};
|
|
6050
|
+
const replyPromise = new Promise((resolve2) => {
|
|
6051
|
+
if (callbacks.onMessage) {
|
|
6052
|
+
callbacks.onMessage(subagentMsg, (replyText) => {
|
|
6053
|
+
resolve2(replyText);
|
|
6054
|
+
});
|
|
6055
|
+
} else {
|
|
6056
|
+
setTimeout(() => resolve2(""), replyTimeout);
|
|
6057
|
+
}
|
|
6058
|
+
});
|
|
6059
|
+
const reply = await Promise.race([
|
|
6060
|
+
replyPromise,
|
|
6061
|
+
new Promise(
|
|
6062
|
+
(resolve2) => setTimeout(() => resolve2(""), replyTimeout)
|
|
6063
|
+
)
|
|
6064
|
+
]);
|
|
6065
|
+
if (reply) {
|
|
6066
|
+
return `Response from orchestrator: ${reply}`;
|
|
6067
|
+
}
|
|
6068
|
+
return "No response. Continue with your best judgment.";
|
|
6069
|
+
}
|
|
6070
|
+
})
|
|
6071
|
+
},
|
|
6072
|
+
stopWhen: (0, import_ai4.stepCountIs)(getMaxTurns2(config))
|
|
6073
|
+
});
|
|
6074
|
+
callbacks.onStep?.({
|
|
6075
|
+
step: searchCount,
|
|
6076
|
+
searchRequest: "",
|
|
6077
|
+
contextsFound: allContexts.length,
|
|
6078
|
+
isFinal: true
|
|
6079
|
+
});
|
|
6080
|
+
const uniqueContexts = deduplicateContexts2(allContexts);
|
|
6081
|
+
return {
|
|
6082
|
+
success: true,
|
|
6083
|
+
summary: result.text || "Exploration completed but no summary was generated.",
|
|
6084
|
+
contexts: uniqueContexts,
|
|
6085
|
+
searchCount,
|
|
6086
|
+
durationMs: Date.now() - startTime
|
|
6087
|
+
};
|
|
6088
|
+
} catch (error) {
|
|
6089
|
+
return {
|
|
6090
|
+
success: false,
|
|
6091
|
+
summary: "",
|
|
6092
|
+
contexts: deduplicateContexts2(allContexts),
|
|
6093
|
+
searchCount,
|
|
6094
|
+
durationMs: Date.now() - startTime,
|
|
6095
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6096
|
+
};
|
|
6097
|
+
}
|
|
6098
|
+
})();
|
|
6099
|
+
if (timeoutPromise) {
|
|
6100
|
+
try {
|
|
6101
|
+
return await Promise.race([runPromise, timeoutPromise]);
|
|
6102
|
+
} catch (error) {
|
|
6103
|
+
return {
|
|
6104
|
+
success: false,
|
|
6105
|
+
summary: "",
|
|
6106
|
+
contexts: deduplicateContexts2(allContexts),
|
|
6107
|
+
searchCount,
|
|
6108
|
+
durationMs: Date.now() - startTime,
|
|
6109
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6110
|
+
};
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
return runPromise;
|
|
6114
|
+
}
|
|
6115
|
+
const exploreToolSchema = import_zod4.z.object({
|
|
6116
|
+
searchRequest: import_zod4.z.string().describe("What to explore in the codebase. Be specific about what you want to understand.")
|
|
6117
|
+
});
|
|
6118
|
+
const exploreTool = (0, import_ai4.tool)({
|
|
6119
|
+
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.",
|
|
6120
|
+
inputSchema: exploreToolSchema,
|
|
6121
|
+
execute: async (params) => {
|
|
6122
|
+
const result = await runExplore(params.searchRequest);
|
|
6123
|
+
return {
|
|
6124
|
+
success: result.success,
|
|
6125
|
+
summary: result.summary,
|
|
6126
|
+
searchCount: result.searchCount,
|
|
6127
|
+
error: result.error
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
});
|
|
6131
|
+
return {
|
|
6132
|
+
/** Vercel AI SDK tool for use as a tool in parent agents */
|
|
6133
|
+
tool: exploreTool,
|
|
6134
|
+
/** Run exploration with messaging support */
|
|
6135
|
+
run(prompt) {
|
|
6136
|
+
const messageHandlers = [];
|
|
6137
|
+
const stepHandlers = [];
|
|
6138
|
+
let resultPromise = null;
|
|
6139
|
+
const session = {
|
|
6140
|
+
on(event, handler) {
|
|
6141
|
+
if (event === "message") messageHandlers.push(handler);
|
|
6142
|
+
if (event === "step") stepHandlers.push(handler);
|
|
6143
|
+
return session;
|
|
6144
|
+
},
|
|
6145
|
+
send(_text) {
|
|
6146
|
+
},
|
|
6147
|
+
get result() {
|
|
6148
|
+
if (!resultPromise) {
|
|
6149
|
+
resultPromise = runExplore(prompt, {
|
|
6150
|
+
onStep: (step) => {
|
|
6151
|
+
for (const handler of stepHandlers) handler(step);
|
|
6152
|
+
},
|
|
6153
|
+
onMessage: (msg, reply) => {
|
|
6154
|
+
if (messageHandlers.length > 0) {
|
|
6155
|
+
for (const handler of messageHandlers) handler(msg, reply);
|
|
6156
|
+
} else {
|
|
6157
|
+
reply("");
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
});
|
|
6161
|
+
}
|
|
6162
|
+
return resultPromise;
|
|
6163
|
+
}
|
|
6164
|
+
};
|
|
6165
|
+
return session;
|
|
6166
|
+
},
|
|
6167
|
+
/** Stream exploration events as an async generator */
|
|
6168
|
+
async *stream(prompt) {
|
|
6169
|
+
const events = [];
|
|
6170
|
+
let resolveNext = null;
|
|
6171
|
+
let done = false;
|
|
6172
|
+
const resultPromise = runExplore(prompt, {
|
|
6173
|
+
onStep: (step) => {
|
|
6174
|
+
events.push({
|
|
6175
|
+
type: "step",
|
|
6176
|
+
step: step.step,
|
|
6177
|
+
searchRequest: step.searchRequest,
|
|
6178
|
+
contextsFound: step.contextsFound,
|
|
6179
|
+
isFinal: step.isFinal
|
|
6180
|
+
});
|
|
6181
|
+
resolveNext?.();
|
|
6182
|
+
},
|
|
6183
|
+
onMessage: (msg, reply) => {
|
|
6184
|
+
events.push({
|
|
6185
|
+
type: "message",
|
|
6186
|
+
from: msg.from,
|
|
6187
|
+
content: msg.content,
|
|
6188
|
+
timestamp: msg.timestamp
|
|
6189
|
+
});
|
|
6190
|
+
resolveNext?.();
|
|
6191
|
+
reply("Continue with your best judgment.");
|
|
6192
|
+
}
|
|
6193
|
+
});
|
|
6194
|
+
while (!done) {
|
|
6195
|
+
if (events.length > 0) {
|
|
6196
|
+
yield events.shift();
|
|
6197
|
+
} else {
|
|
6198
|
+
const raceResult = await Promise.race([
|
|
6199
|
+
resultPromise.then((r) => ({ type: "done", result: r })),
|
|
6200
|
+
new Promise((resolve2) => {
|
|
6201
|
+
resolveNext = () => resolve2({ type: "event" });
|
|
6202
|
+
})
|
|
6203
|
+
]);
|
|
6204
|
+
if (raceResult.type === "done") {
|
|
6205
|
+
while (events.length > 0) {
|
|
6206
|
+
yield events.shift();
|
|
6207
|
+
}
|
|
6208
|
+
done = true;
|
|
6209
|
+
return raceResult.result;
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
}
|
|
6213
|
+
return await resultPromise;
|
|
6214
|
+
}
|
|
6215
|
+
};
|
|
6216
|
+
}
|
|
6217
|
+
function deduplicateContexts2(contexts) {
|
|
6218
|
+
const map = /* @__PURE__ */ new Map();
|
|
6219
|
+
for (const ctx of contexts) {
|
|
6220
|
+
const existing = map.get(ctx.file);
|
|
6221
|
+
if (!existing || ctx.content.length > existing.content.length) {
|
|
6222
|
+
map.set(ctx.file, ctx);
|
|
6223
|
+
}
|
|
6224
|
+
}
|
|
6225
|
+
return Array.from(map.values());
|
|
6226
|
+
}
|
|
6227
|
+
|
|
5603
6228
|
// factories/vercel.ts
|
|
5604
6229
|
var VercelToolFactory = class {
|
|
5605
6230
|
constructor(config) {
|
|
@@ -5653,6 +6278,20 @@ var VercelToolFactory = class {
|
|
|
5653
6278
|
morphApiKey: this.config.apiKey
|
|
5654
6279
|
});
|
|
5655
6280
|
}
|
|
6281
|
+
/**
|
|
6282
|
+
* Create an Explore subagent that searches the codebase and returns summaries
|
|
6283
|
+
*
|
|
6284
|
+
* @param model - Vercel AI SDK model instance
|
|
6285
|
+
* @param toolConfig - Subagent configuration (morphApiKey inherited from MorphClient)
|
|
6286
|
+
* @returns Explore subagent with .tool, .run(), and .stream() methods
|
|
6287
|
+
*/
|
|
6288
|
+
createExploreSubagent(model, toolConfig) {
|
|
6289
|
+
return createExploreSubagent2({
|
|
6290
|
+
...toolConfig,
|
|
6291
|
+
model,
|
|
6292
|
+
morphApiKey: this.config.apiKey
|
|
6293
|
+
});
|
|
6294
|
+
}
|
|
5656
6295
|
};
|
|
5657
6296
|
|
|
5658
6297
|
// client.ts
|
|
@@ -5771,7 +6410,7 @@ var MorphClient = class {
|
|
|
5771
6410
|
};
|
|
5772
6411
|
|
|
5773
6412
|
// tools/warp_grep/index.ts
|
|
5774
|
-
var
|
|
6413
|
+
var import_zod5 = require("zod");
|
|
5775
6414
|
|
|
5776
6415
|
// tools/warp_grep/providers/index.ts
|
|
5777
6416
|
init_local();
|
|
@@ -5783,8 +6422,8 @@ init_paths();
|
|
|
5783
6422
|
init_config();
|
|
5784
6423
|
|
|
5785
6424
|
// tools/warp_grep/index.ts
|
|
5786
|
-
var warpGrepInputSchema =
|
|
5787
|
-
search_term:
|
|
6425
|
+
var warpGrepInputSchema = import_zod5.z.object({
|
|
6426
|
+
search_term: import_zod5.z.string().describe("Search problem statement that this subagent is supposed to research for")
|
|
5788
6427
|
});
|
|
5789
6428
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5790
6429
|
0 && (module.exports = {
|