@morphllm/morphsdk 0.2.201 → 0.2.203

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.
Files changed (180) hide show
  1. package/dist/chunk-2PPYWRMZ.js +3 -4
  2. package/dist/{chunk-DBNSOYQ3.js → chunk-2UIOCSVJ.js} +3 -24
  3. package/dist/chunk-44OIEPIO.js +4 -23
  4. package/dist/chunk-4EQQGUZ7.cjs +104 -0
  5. package/dist/chunk-4OUGA3KS.js +1 -5
  6. package/dist/chunk-4R5MDGL6.cjs +280 -0
  7. package/dist/chunk-65W4I66Q.cjs +103 -0
  8. package/dist/{chunk-WBTXEJOC.js → chunk-66THRMD7.js} +10 -35
  9. package/dist/chunk-6TZCVTW5.js +3 -4
  10. package/dist/chunk-6WP7EA4F.js +2 -4
  11. package/dist/chunk-74A4HLIO.cjs +42 -0
  12. package/dist/chunk-75ZPJI57.cjs +9 -0
  13. package/dist/chunk-7NA7X7W2.cjs +77 -0
  14. package/dist/chunk-7PJYY46L.cjs +2 -0
  15. package/dist/chunk-AFF6XYKL.cjs +71 -0
  16. package/dist/{chunk-P2KW2O5R.js → chunk-AJBZA23L.js} +3 -25
  17. package/dist/chunk-AWFZKS27.cjs +11 -0
  18. package/dist/{chunk-FVT4PU4I.js → chunk-AXEKIRRY.js} +22 -62
  19. package/dist/chunk-B3FD67F2.cjs +256 -0
  20. package/dist/chunk-BJBWWIZV.cjs +2 -0
  21. package/dist/{chunk-M6AVXUM4.js → chunk-E3XNKAMI.js} +5 -15
  22. package/dist/{chunk-TS3OJ4LA.js → chunk-E7FLETFO.js} +2 -8
  23. package/dist/{chunk-EQAWWVKV.js → chunk-EI2M567U.js} +2 -6
  24. package/dist/chunk-EJTL2BOZ.cjs +42 -0
  25. package/dist/chunk-ETBRAKVV.js +1 -5
  26. package/dist/{chunk-VOXUA5ZH.js → chunk-EZ2OFDBJ.js} +5 -19
  27. package/dist/chunk-FBOZIVVQ.js +1 -0
  28. package/dist/{chunk-TZC3EOZS.js → chunk-GDFPZ3NJ.js} +4 -19
  29. package/dist/{chunk-LISSWRUD.js → chunk-GIQAIHUI.js} +8 -33
  30. package/dist/chunk-GSUQGDCL.cjs +235 -0
  31. package/dist/{chunk-5NSYDT36.js → chunk-H3HRSRR5.js} +4 -12
  32. package/dist/chunk-HDP4QAZL.js +1 -4
  33. package/dist/chunk-HMLYJVZM.cjs +410 -0
  34. package/dist/chunk-IPJA3ZS6.cjs +10 -0
  35. package/dist/{chunk-B376VMIH.js → chunk-IUM6CQYX.js} +3 -12
  36. package/dist/{chunk-OVLUL5AC.js → chunk-J56Q6C4Y.js} +4 -18
  37. package/dist/chunk-JBTR3FQD.cjs +135 -0
  38. package/dist/chunk-JNQKQKHS.cjs +81 -0
  39. package/dist/chunk-JOZC4T6C.cjs +168 -0
  40. package/dist/{chunk-ILY5N5NJ.js → chunk-JUGNTIVU.js} +6 -19
  41. package/dist/{chunk-SU7AAS3O.js → chunk-JY6COF3X.js} +5 -22
  42. package/dist/{chunk-JBAY3PRV.js → chunk-KLVJIC2O.js} +5 -17
  43. package/dist/chunk-KSZYOX6S.cjs +91 -0
  44. package/dist/chunk-KVGZ2TSG.cjs +274 -0
  45. package/dist/chunk-LDM7RNNN.js +1 -0
  46. package/dist/{chunk-RZOJ4GSY.js → chunk-LLQH6CCB.js} +10 -28
  47. package/dist/chunk-M34E2AMK.js +1 -5
  48. package/dist/chunk-MF56KEI4.js +1 -4
  49. package/dist/chunk-MLKGABMK.js +1 -3
  50. package/dist/{chunk-I26FQELI.js → chunk-MLPZKUCO.js} +11 -5
  51. package/dist/chunk-MWXJ6DZ2.cjs +21 -0
  52. package/dist/{chunk-NWGRW4V7.js → chunk-N7UKZ5X7.js} +2 -6
  53. package/dist/chunk-NDUC7OV6.cjs +74 -0
  54. package/dist/{chunk-RJXAXR7Q.js → chunk-NLACTMZT.js} +6 -19
  55. package/dist/chunk-NNKBKENK.cjs +15 -0
  56. package/dist/chunk-NRG6QX3L.js +1 -3
  57. package/dist/chunk-OCCGJ4S6.js +8 -0
  58. package/dist/chunk-ODY2NKQU.cjs +50 -0
  59. package/dist/chunk-OM5ZSXQW.cjs +91 -0
  60. package/dist/chunk-OOEORM7H.cjs +334 -0
  61. package/dist/chunk-OPDWMD4Q.js +1 -3
  62. package/dist/{chunk-BZXOAC2R.js → chunk-OSL4CNSO.js} +7 -23
  63. package/dist/chunk-OXXMTDOY.cjs +86 -0
  64. package/dist/chunk-PA3UTI4A.js +1 -4
  65. package/dist/chunk-QEEAIXL5.cjs +74 -0
  66. package/dist/chunk-RYVW7RUM.js +2 -6
  67. package/dist/chunk-S6QBPXBI.cjs +107 -0
  68. package/dist/chunk-TL34BLQD.cjs +10 -0
  69. package/dist/chunk-TPZHMD7J.cjs +72 -0
  70. package/dist/chunk-UAPK3AIJ.js +1 -10
  71. package/dist/chunk-UF5IKELS.cjs +26 -0
  72. package/dist/chunk-UNX7V6P6.cjs +60 -0
  73. package/dist/chunk-UUCRWJJR.cjs +313 -0
  74. package/dist/chunk-VDFLPO7B.cjs +396 -0
  75. package/dist/chunk-VHD7CW5O.cjs +43 -0
  76. package/dist/chunk-VL4QNALG.cjs +50 -0
  77. package/dist/chunk-WR7LSUIR.cjs +213 -0
  78. package/dist/chunk-XE6D4J63.cjs +72 -0
  79. package/dist/chunk-ZLG2M2I4.cjs +21 -0
  80. package/dist/chunk-ZSHVXDA2.js +4 -10
  81. package/dist/client.cjs +40 -4353
  82. package/dist/client.js +32 -37
  83. package/dist/core/client.cjs +10 -476
  84. package/dist/core/client.js +6 -11
  85. package/dist/core/error.cjs +8 -251
  86. package/dist/core/error.js +4 -9
  87. package/dist/core/index.cjs +20 -488
  88. package/dist/core/index.js +8 -19
  89. package/dist/core/resource.cjs +9 -33
  90. package/dist/core/resource.js +2 -7
  91. package/dist/edge.cjs +62 -1111
  92. package/dist/edge.js +10 -42
  93. package/dist/index.cjs +115 -4424
  94. package/dist/index.js +39 -87
  95. package/dist/modelrouter/core.cjs +28 -648
  96. package/dist/modelrouter/core.js +8 -21
  97. package/dist/modelrouter/index.cjs +28 -648
  98. package/dist/modelrouter/index.js +8 -21
  99. package/dist/modelrouter/types.cjs +1 -17
  100. package/dist/modelrouter/types.js +1 -0
  101. package/dist/subagents/anthropic.cjs +27 -2777
  102. package/dist/subagents/anthropic.js +19 -24
  103. package/dist/subagents/index.cjs +14 -95
  104. package/dist/subagents/index.js +2 -11
  105. package/dist/subagents/prompts.cjs +14 -93
  106. package/dist/subagents/prompts.js +2 -11
  107. package/dist/subagents/types.cjs +1 -17
  108. package/dist/subagents/types.js +1 -0
  109. package/dist/subagents/vercel.cjs +27 -2754
  110. package/dist/subagents/vercel.js +19 -24
  111. package/dist/tools/compact/core.cjs +12 -548
  112. package/dist/tools/compact/core.js +8 -13
  113. package/dist/tools/compact/index.cjs +17 -595
  114. package/dist/tools/compact/index.js +9 -17
  115. package/dist/tools/compact/types.cjs +1 -17
  116. package/dist/tools/compact/types.js +1 -0
  117. package/dist/tools/fastapply/anthropic.cjs +27 -891
  118. package/dist/tools/fastapply/anthropic.js +11 -24
  119. package/dist/tools/fastapply/apply.cjs +28 -672
  120. package/dist/tools/fastapply/apply.js +4 -19
  121. package/dist/tools/fastapply/core.cjs +37 -1061
  122. package/dist/tools/fastapply/core.js +9 -29
  123. package/dist/tools/fastapply/index.cjs +62 -1062
  124. package/dist/tools/fastapply/index.js +14 -44
  125. package/dist/tools/fastapply/openai.cjs +32 -901
  126. package/dist/tools/fastapply/openai.js +11 -26
  127. package/dist/tools/fastapply/prompts.cjs +10 -62
  128. package/dist/tools/fastapply/prompts.js +2 -9
  129. package/dist/tools/fastapply/types.cjs +1 -17
  130. package/dist/tools/fastapply/types.js +1 -0
  131. package/dist/tools/fastapply/vercel.cjs +25 -897
  132. package/dist/tools/fastapply/vercel.js +11 -22
  133. package/dist/tools/index.cjs +62 -1062
  134. package/dist/tools/index.js +14 -44
  135. package/dist/tools/utils/resilience.cjs +15 -312
  136. package/dist/tools/utils/resilience.js +3 -12
  137. package/dist/tools/warp_grep/agent/config.cjs +16 -127
  138. package/dist/tools/warp_grep/agent/config.js +2 -11
  139. package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
  140. package/dist/tools/warp_grep/agent/formatter.js +2 -9
  141. package/dist/tools/warp_grep/agent/parser.cjs +16 -83
  142. package/dist/tools/warp_grep/agent/parser.js +2 -11
  143. package/dist/tools/warp_grep/agent/runner.cjs +15 -1081
  144. package/dist/tools/warp_grep/agent/runner.js +7 -14
  145. package/dist/tools/warp_grep/agent/types.cjs +1 -17
  146. package/dist/tools/warp_grep/agent/types.js +1 -0
  147. package/dist/tools/warp_grep/anthropic.cjs +47 -2554
  148. package/dist/tools/warp_grep/anthropic.js +19 -35
  149. package/dist/tools/warp_grep/client.cjs +49 -2464
  150. package/dist/tools/warp_grep/client.js +17 -34
  151. package/dist/tools/warp_grep/gemini.cjs +48 -2483
  152. package/dist/tools/warp_grep/gemini.js +21 -41
  153. package/dist/tools/warp_grep/harness.cjs +81 -929
  154. package/dist/tools/warp_grep/harness.js +12 -51
  155. package/dist/tools/warp_grep/index.cjs +124 -2568
  156. package/dist/tools/warp_grep/index.js +24 -87
  157. package/dist/tools/warp_grep/openai.cjs +53 -2568
  158. package/dist/tools/warp_grep/openai.js +19 -37
  159. package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
  160. package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
  161. package/dist/tools/warp_grep/providers/local.cjs +10 -582
  162. package/dist/tools/warp_grep/providers/local.js +6 -11
  163. package/dist/tools/warp_grep/providers/remote.cjs +8 -331
  164. package/dist/tools/warp_grep/providers/remote.js +3 -8
  165. package/dist/tools/warp_grep/providers/types.cjs +1 -17
  166. package/dist/tools/warp_grep/providers/types.js +1 -0
  167. package/dist/tools/warp_grep/utils/files.cjs +9 -42
  168. package/dist/tools/warp_grep/utils/files.js +2 -7
  169. package/dist/tools/warp_grep/utils/github.cjs +9 -43
  170. package/dist/tools/warp_grep/utils/github.js +2 -7
  171. package/dist/tools/warp_grep/utils/paths.cjs +28 -104
  172. package/dist/tools/warp_grep/utils/paths.js +2 -17
  173. package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -86
  174. package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
  175. package/dist/tools/warp_grep/vercel.cjs +53 -2550
  176. package/dist/tools/warp_grep/vercel.js +19 -37
  177. package/dist/version.cjs +7 -225
  178. package/dist/version.js +2 -7
  179. package/package.json +2 -2
  180. package/dist/chunk-UZCXOOZO.js +0 -203
@@ -1,9 +1,8 @@
1
+ import { z } from 'zod';
2
+
1
3
  // tools/warp_grep/index.ts
2
- import { z } from "zod";
3
4
  var warpGrepInputSchema = z.object({
4
5
  search_term: z.string().describe("Search problem statement that this subagent is supposed to research for")
5
6
  });
6
7
 
7
- export {
8
- warpGrepInputSchema
9
- };
8
+ export { warpGrepInputSchema };
@@ -1,20 +1,5 @@
1
- import {
2
- GITHUB_READ_FILE_DESCRIPTION,
3
- GITHUB_READ_FILE_INPUT_SCHEMA,
4
- GITHUB_READ_FILE_TOOL_NAME,
5
- GITHUB_SEARCH_DESCRIPTION,
6
- GITHUB_SEARCH_INPUT_SCHEMA,
7
- GITHUB_SEARCH_TOOL_NAME,
8
- WARP_GREP_DESCRIPTION,
9
- WARP_GREP_TOOL_NAME
10
- } from "./chunk-UAPK3AIJ.js";
11
- import {
12
- WarpGrepClient,
13
- executeGitHubReadFile,
14
- executeToolCall,
15
- formatGitHubReadFileResult,
16
- formatResult
17
- } from "./chunk-WBTXEJOC.js";
1
+ import { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_TOOL_NAME, GITHUB_READ_FILE_INPUT_SCHEMA, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_TOOL_NAME } from './chunk-UAPK3AIJ.js';
2
+ import { executeToolCall, formatResult, WarpGrepClient, formatGitHubReadFileResult, executeGitHubReadFile } from './chunk-66THRMD7.js';
18
3
 
19
4
  // tools/warp_grep/anthropic.ts
20
5
  var INPUT_SCHEMA = {
@@ -83,10 +68,4 @@ function createGitHubReadFileTool(config) {
83
68
  });
84
69
  }
85
70
 
86
- export {
87
- warpGrepTool,
88
- execute,
89
- createWarpGrepTool,
90
- createGitHubSearchTool,
91
- createGitHubReadFileTool
92
- };
71
+ export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, execute, warpGrepTool };
@@ -1,6 +1,5 @@
1
- import {
2
- AGENT_CONFIG
3
- } from "./chunk-M34E2AMK.js";
1
+ import { AGENT_CONFIG } from './chunk-M34E2AMK.js';
2
+ import path from 'path';
4
3
 
5
4
  // tools/warp_grep/agent/tools/grep.ts
6
5
  async function toolGrep(provider, args) {
@@ -48,9 +47,6 @@ async function toolRead(provider, args) {
48
47
  if (!res.lines.length) return "(empty file)";
49
48
  return res.lines.join("\n");
50
49
  }
51
-
52
- // tools/warp_grep/agent/tools/list_directory.ts
53
- import path from "path";
54
50
  async function toolListDirectory(provider, args, repoRoot) {
55
51
  const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_LIST_RESULTS;
56
52
  const maxDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
@@ -153,9 +149,6 @@ function mergeRanges(ranges) {
153
149
  merged.push([cs, ce]);
154
150
  return merged;
155
151
  }
156
-
157
- // tools/warp_grep/agent/helpers.ts
158
- import path2 from "path";
159
152
  var TRUNCATED_MARKER = "[truncated for context limit]";
160
153
  function getMessageSize(m) {
161
154
  if (m.role === "tool") return m.content.length;
@@ -198,7 +191,7 @@ async function buildInitialState(repoRoot, searchTerm, provider, options) {
198
191
  });
199
192
  const lines = [absRoot];
200
193
  for (const e of entries) {
201
- lines.push(path2.join(absRoot, e.path));
194
+ lines.push(path.join(absRoot, e.path));
202
195
  }
203
196
  return `<repo_structure>
204
197
  ${lines.join("\n")}
@@ -262,16 +255,4 @@ function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS
262
255
  return messages;
263
256
  }
264
257
 
265
- export {
266
- toolGrep,
267
- toolRead,
268
- toolListDirectory,
269
- toolGlob,
270
- normalizeFinishFiles,
271
- readFinishFiles,
272
- formatTurnMessage,
273
- calculateContextBudget,
274
- buildInitialState,
275
- formatListDirectoryTree,
276
- enforceContextLimit
277
- };
258
+ export { buildInitialState, calculateContextBudget, enforceContextLimit, formatListDirectoryTree, formatTurnMessage, normalizeFinishFiles, readFinishFiles, toolGlob, toolGrep, toolListDirectory, toolRead };
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ // tools/warp_grep/agent/config.ts
4
+ var parseEnvTimeout = (envValue, defaultMs) => {
5
+ if (!envValue) return defaultMs;
6
+ const parsed = parseInt(envValue, 10);
7
+ return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
8
+ };
9
+ var AGENT_CONFIG = {
10
+ MAX_TURNS: 6,
11
+ /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
12
+ TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 6e4),
13
+ MAX_CONTEXT_CHARS: 321600,
14
+ MAX_OUTPUT_LINES: 200,
15
+ MAX_LIST_RESULTS: 500,
16
+ MAX_READ_LINES: 800,
17
+ MAX_LIST_DEPTH: 3,
18
+ LIST_TIMEOUT_MS: 2e3
19
+ };
20
+ var BUILTIN_EXCLUDES = [
21
+ // Version control
22
+ ".git",
23
+ ".svn",
24
+ ".hg",
25
+ ".bzr",
26
+ // Dependencies
27
+ "node_modules",
28
+ "bower_components",
29
+ ".pnpm",
30
+ ".yarn",
31
+ "vendor",
32
+ "packages",
33
+ "Pods",
34
+ ".bundle",
35
+ // Python
36
+ "__pycache__",
37
+ ".pytest_cache",
38
+ ".mypy_cache",
39
+ ".ruff_cache",
40
+ ".venv",
41
+ "venv",
42
+ ".tox",
43
+ ".nox",
44
+ ".eggs",
45
+ "*.egg-info",
46
+ // Build outputs
47
+ "dist",
48
+ "build",
49
+ "out",
50
+ "output",
51
+ "target",
52
+ "_build",
53
+ ".next",
54
+ ".nuxt",
55
+ ".output",
56
+ ".vercel",
57
+ ".netlify",
58
+ // Cache directories
59
+ ".cache",
60
+ ".parcel-cache",
61
+ ".turbo",
62
+ ".nx",
63
+ ".gradle",
64
+ // IDE/Editor
65
+ ".idea",
66
+ ".vscode",
67
+ ".vs",
68
+ // Coverage
69
+ "coverage",
70
+ ".coverage",
71
+ "htmlcov",
72
+ ".nyc_output",
73
+ // Temporary
74
+ "tmp",
75
+ "temp",
76
+ ".tmp",
77
+ ".temp",
78
+ // Lock files
79
+ "package-lock.json",
80
+ "yarn.lock",
81
+ "pnpm-lock.yaml",
82
+ "bun.lockb",
83
+ "Cargo.lock",
84
+ "Gemfile.lock",
85
+ "poetry.lock",
86
+ // Binary/minified
87
+ "*.min.js",
88
+ "*.min.css",
89
+ "*.bundle.js",
90
+ "*.wasm",
91
+ "*.so",
92
+ "*.dll",
93
+ "*.pyc",
94
+ "*.map",
95
+ "*.js.map",
96
+ // Hidden directories catch-all
97
+ ".*"
98
+ ];
99
+ var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
100
+ var DEFAULT_MODEL = "morph-warp-grep-v2.1";
101
+
102
+ exports.AGENT_CONFIG = AGENT_CONFIG;
103
+ exports.DEFAULT_EXCLUDES = DEFAULT_EXCLUDES;
104
+ exports.DEFAULT_MODEL = DEFAULT_MODEL;
@@ -53,8 +53,4 @@ function extractPathFromCommand(command) {
53
53
  return pathTokens[0] || ".";
54
54
  }
55
55
 
56
- export {
57
- parseReadLines,
58
- parseFinishFiles,
59
- extractPathFromCommand
60
- };
56
+ export { extractPathFromCommand, parseFinishFiles, parseReadLines };
@@ -0,0 +1,280 @@
1
+ 'use strict';
2
+
3
+ var chunkUUCRWJJR_cjs = require('./chunk-UUCRWJJR.cjs');
4
+ var chunkTPZHMD7J_cjs = require('./chunk-TPZHMD7J.cjs');
5
+
6
+ // subagents/anthropic.ts
7
+ var DEFAULT_MAX_TURNS = {
8
+ quick: 3,
9
+ medium: 6,
10
+ thorough: 12
11
+ };
12
+ function getMaxTurns(config) {
13
+ return config.maxTurns ?? DEFAULT_MAX_TURNS[config.thoroughness ?? "medium"] ?? 6;
14
+ }
15
+ var TOOLS = [
16
+ {
17
+ name: chunkTPZHMD7J_cjs.CODEBASE_SEARCH_TOOL.name,
18
+ description: chunkTPZHMD7J_cjs.CODEBASE_SEARCH_TOOL.description,
19
+ input_schema: chunkTPZHMD7J_cjs.CODEBASE_SEARCH_TOOL.input_schema
20
+ },
21
+ {
22
+ name: chunkTPZHMD7J_cjs.SEND_MESSAGE_TOOL.name,
23
+ description: chunkTPZHMD7J_cjs.SEND_MESSAGE_TOOL.description,
24
+ input_schema: chunkTPZHMD7J_cjs.SEND_MESSAGE_TOOL.input_schema
25
+ }
26
+ ];
27
+ function createExploreSubagent(config) {
28
+ if (!config.repoRoot) {
29
+ throw new Error("repoRoot is required for Explore subagent");
30
+ }
31
+ const warpGrep = new chunkUUCRWJJR_cjs.WarpGrepClient({
32
+ morphApiKey: config.morphApiKey
33
+ });
34
+ const thoroughness = config.thoroughness ?? "medium";
35
+ const maxTurns = getMaxTurns(config);
36
+ const replyTimeout = config.replyTimeout ?? 3e4;
37
+ async function runExplore(prompt, callbacks = {}) {
38
+ const startTime = Date.now();
39
+ const allContexts = [];
40
+ let searchCount = 0;
41
+ const timeoutMs = config.timeout;
42
+ try {
43
+ const messages = [{ role: "user", content: prompt }];
44
+ let turns = 0;
45
+ while (turns < maxTurns) {
46
+ if (timeoutMs && Date.now() - startTime > timeoutMs) {
47
+ return {
48
+ success: false,
49
+ summary: "",
50
+ contexts: deduplicateContexts(allContexts),
51
+ searchCount,
52
+ durationMs: Date.now() - startTime,
53
+ error: `Exploration timed out after ${timeoutMs}ms`
54
+ };
55
+ }
56
+ const response = await config.client.messages.create({
57
+ model: config.model,
58
+ max_tokens: 4096,
59
+ system: chunkTPZHMD7J_cjs.getSystemPrompt(thoroughness),
60
+ tools: TOOLS,
61
+ messages
62
+ });
63
+ turns++;
64
+ if (response.stop_reason === "end_turn" || !response.content.some((b) => b.type === "tool_use")) {
65
+ const textBlock = response.content.find((b) => b.type === "text");
66
+ const summary = textBlock?.text || "Exploration completed but no summary was generated.";
67
+ callbacks.onStep?.({
68
+ step: searchCount,
69
+ searchRequest: "",
70
+ contextsFound: allContexts.length,
71
+ isFinal: true
72
+ });
73
+ return {
74
+ success: true,
75
+ summary,
76
+ contexts: deduplicateContexts(allContexts),
77
+ searchCount,
78
+ durationMs: Date.now() - startTime
79
+ };
80
+ }
81
+ messages.push({ role: "assistant", content: response.content });
82
+ const toolResults = [];
83
+ for (const block of response.content) {
84
+ if (block.type !== "tool_use") continue;
85
+ if (block.name === "codebase_search") {
86
+ searchCount++;
87
+ const input = block.input;
88
+ const warpResult = await warpGrep.execute({
89
+ searchTerm: input.searchRequest,
90
+ repoRoot: config.repoRoot,
91
+ excludes: config.excludes,
92
+ includes: config.includes
93
+ });
94
+ if (warpResult.contexts) {
95
+ allContexts.push(...warpResult.contexts);
96
+ }
97
+ callbacks.onStep?.({
98
+ step: searchCount,
99
+ searchRequest: input.searchRequest,
100
+ contextsFound: warpResult.contexts?.length ?? 0,
101
+ isFinal: false
102
+ });
103
+ toolResults.push({
104
+ type: "tool_result",
105
+ tool_use_id: block.id,
106
+ content: chunkUUCRWJJR_cjs.formatResult(warpResult)
107
+ });
108
+ } else if (block.name === "send_message") {
109
+ const input = block.input;
110
+ const subagentMsg = {
111
+ from: "explore",
112
+ content: input.message,
113
+ timestamp: Date.now()
114
+ };
115
+ let replyText = "";
116
+ if (callbacks.onMessage) {
117
+ replyText = await Promise.race([
118
+ new Promise((resolve) => {
119
+ callbacks.onMessage(subagentMsg, (text) => {
120
+ resolve(text);
121
+ });
122
+ }),
123
+ new Promise(
124
+ (resolve) => setTimeout(() => resolve(""), replyTimeout)
125
+ )
126
+ ]);
127
+ }
128
+ const toolResponse = replyText ? `Response from orchestrator: ${replyText}` : "No response. Continue with your best judgment.";
129
+ toolResults.push({
130
+ type: "tool_result",
131
+ tool_use_id: block.id,
132
+ content: toolResponse
133
+ });
134
+ }
135
+ }
136
+ messages.push({ role: "user", content: toolResults });
137
+ }
138
+ return {
139
+ success: true,
140
+ summary: "Exploration completed (max turns reached).",
141
+ contexts: deduplicateContexts(allContexts),
142
+ searchCount,
143
+ durationMs: Date.now() - startTime
144
+ };
145
+ } catch (error) {
146
+ return {
147
+ success: false,
148
+ summary: "",
149
+ contexts: deduplicateContexts(allContexts),
150
+ searchCount,
151
+ durationMs: Date.now() - startTime,
152
+ error: error instanceof Error ? error.message : String(error)
153
+ };
154
+ }
155
+ }
156
+ const exploreTool = Object.assign(
157
+ {
158
+ name: "explore",
159
+ description: "Explore a codebase to answer questions about code structure, find implementations, trace call chains, and understand architecture. Returns a summary of findings.",
160
+ input_schema: {
161
+ type: "object",
162
+ properties: {
163
+ searchRequest: {
164
+ type: "string",
165
+ description: "What to explore in the codebase. Be specific about what you want to understand."
166
+ }
167
+ },
168
+ required: ["searchRequest"]
169
+ }
170
+ },
171
+ {
172
+ execute: async (input) => {
173
+ return runExplore(input.searchRequest);
174
+ },
175
+ formatResult: (result) => {
176
+ if (!result.success) {
177
+ return `Exploration failed: ${result.error}`;
178
+ }
179
+ return result.summary;
180
+ }
181
+ }
182
+ );
183
+ return {
184
+ /** Anthropic Tool definition for use in parent agents */
185
+ tool: exploreTool,
186
+ /** Run exploration with messaging support */
187
+ run(prompt) {
188
+ const messageHandlers = [];
189
+ const stepHandlers = [];
190
+ let resultPromise = null;
191
+ const session = {
192
+ on(event, handler) {
193
+ if (event === "message") messageHandlers.push(handler);
194
+ if (event === "step") stepHandlers.push(handler);
195
+ return session;
196
+ },
197
+ send(_text) {
198
+ },
199
+ get result() {
200
+ if (!resultPromise) {
201
+ resultPromise = runExplore(prompt, {
202
+ onStep: (step) => {
203
+ for (const handler of stepHandlers) handler(step);
204
+ },
205
+ onMessage: (msg, reply) => {
206
+ if (messageHandlers.length > 0) {
207
+ for (const handler of messageHandlers) handler(msg, reply);
208
+ } else {
209
+ reply("");
210
+ }
211
+ }
212
+ });
213
+ }
214
+ return resultPromise;
215
+ }
216
+ };
217
+ return session;
218
+ },
219
+ /** Stream exploration events as an async generator */
220
+ async *stream(prompt) {
221
+ const events = [];
222
+ let resolveNext = null;
223
+ let done = false;
224
+ const resultPromise = runExplore(prompt, {
225
+ onStep: (step) => {
226
+ events.push({
227
+ type: "step",
228
+ step: step.step,
229
+ searchRequest: step.searchRequest,
230
+ contextsFound: step.contextsFound,
231
+ isFinal: step.isFinal
232
+ });
233
+ resolveNext?.();
234
+ },
235
+ onMessage: (msg, reply) => {
236
+ events.push({
237
+ type: "message",
238
+ from: msg.from,
239
+ content: msg.content,
240
+ timestamp: msg.timestamp
241
+ });
242
+ resolveNext?.();
243
+ reply("Continue with your best judgment.");
244
+ }
245
+ });
246
+ while (!done) {
247
+ if (events.length > 0) {
248
+ yield events.shift();
249
+ } else {
250
+ const raceResult = await Promise.race([
251
+ resultPromise.then((r) => ({ type: "done", result: r })),
252
+ new Promise((resolve) => {
253
+ resolveNext = () => resolve({ type: "event" });
254
+ })
255
+ ]);
256
+ if (raceResult.type === "done") {
257
+ while (events.length > 0) {
258
+ yield events.shift();
259
+ }
260
+ done = true;
261
+ return raceResult.result;
262
+ }
263
+ }
264
+ }
265
+ return await resultPromise;
266
+ }
267
+ };
268
+ }
269
+ function deduplicateContexts(contexts) {
270
+ const map = /* @__PURE__ */ new Map();
271
+ for (const ctx of contexts) {
272
+ const existing = map.get(ctx.file);
273
+ if (!existing || ctx.content.length > existing.content.length) {
274
+ map.set(ctx.file, ctx);
275
+ }
276
+ }
277
+ return Array.from(map.values());
278
+ }
279
+
280
+ exports.createExploreSubagent = createExploreSubagent;
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
4
+ var chunkZLG2M2I4_cjs = require('./chunk-ZLG2M2I4.cjs');
5
+ var chunkOM5ZSXQW_cjs = require('./chunk-OM5ZSXQW.cjs');
6
+ var chunkTL34BLQD_cjs = require('./chunk-TL34BLQD.cjs');
7
+
8
+ // core/client.ts
9
+ var DEFAULT_BASE_URL = "https://api.morphllm.com";
10
+ var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
11
+ var DEFAULT_TIMEOUT = 6e4;
12
+ var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
13
+ var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
14
+ var MorphAPIClient = class {
15
+ /** Explicit key as provided; resolved against env at request time. */
16
+ apiKey;
17
+ baseURL;
18
+ reposURL;
19
+ /** Explicit default timeout (ms), if set. The request default is applied lazily so
20
+ * resources can read an undefined value and supply their own fallback. */
21
+ timeout;
22
+ retryConfig;
23
+ debug;
24
+ constructor(options = {}) {
25
+ this.apiKey = options.apiKey;
26
+ this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
27
+ this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
28
+ this.timeout = options.timeout;
29
+ this.retryConfig = options.retryConfig;
30
+ this.debug = options.debug ?? false;
31
+ if (this.debug) chunkVL4QNALG_cjs.logger.enable();
32
+ }
33
+ /** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
34
+ resolveApiKey() {
35
+ return this.apiKey ?? env("MORPH_API_KEY");
36
+ }
37
+ /** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
38
+ defaultHeaders() {
39
+ return { "X-Morph-SDK-Version": chunkTL34BLQD_cjs.SDK_VERSION };
40
+ }
41
+ buildURL(path, baseURL) {
42
+ if (/^https?:\/\//i.test(path)) return path;
43
+ const base = stripTrailingSlash(baseURL ?? this.baseURL);
44
+ return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
45
+ }
46
+ buildHeaders(apiKey, extra) {
47
+ return {
48
+ "Content-Type": "application/json",
49
+ "X-Morph-SDK-Version": chunkTL34BLQD_cjs.SDK_VERSION,
50
+ Authorization: `Bearer ${apiKey}`,
51
+ ...extra
52
+ };
53
+ }
54
+ applyQuery(url, query) {
55
+ if (!query) return url;
56
+ const params = new URLSearchParams();
57
+ for (const [key, value] of Object.entries(query)) {
58
+ if (value !== void 0 && value !== null) params.set(key, String(value));
59
+ }
60
+ const qs = params.toString();
61
+ return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
62
+ }
63
+ async request(method, path, opts = {}) {
64
+ const apiKey = this.resolveApiKey();
65
+ if (!apiKey) {
66
+ throw new chunkOM5ZSXQW_cjs.MorphError(
67
+ "Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
68
+ "missing_api_key",
69
+ 401
70
+ );
71
+ }
72
+ const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
73
+ const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
74
+ const init = {
75
+ method,
76
+ headers: this.buildHeaders(apiKey, opts.headers),
77
+ ...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
78
+ ...opts.signal ? { signal: opts.signal } : {}
79
+ };
80
+ chunkVL4QNALG_cjs.logger.debug("MorphAPIClient", "request", { method, url });
81
+ const response = await chunkOM5ZSXQW_cjs.withTimeout(
82
+ chunkOM5ZSXQW_cjs.fetchWithRetry(url, init, this.retryConfig ?? {}),
83
+ timeout,
84
+ `Morph request to ${url} timed out after ${timeout}ms`
85
+ );
86
+ if (!response.ok) throw await chunkZLG2M2I4_cjs.toMorphError(response);
87
+ if (opts.stream) return response;
88
+ if (response.status === 204) return void 0;
89
+ const text = await response.text();
90
+ return text ? JSON.parse(text) : void 0;
91
+ }
92
+ get(path, opts) {
93
+ return this.request("GET", path, opts);
94
+ }
95
+ post(path, opts) {
96
+ return this.request("POST", path, opts);
97
+ }
98
+ delete(path, opts) {
99
+ return this.request("DELETE", path, opts);
100
+ }
101
+ };
102
+
103
+ exports.MorphAPIClient = MorphAPIClient;
@@ -1,33 +1,16 @@
1
- import {
2
- createCodeStorageHttpCommands
3
- } from "./chunk-HDP4QAZL.js";
4
- import {
5
- RemoteCommandsProvider
6
- } from "./chunk-RYVW7RUM.js";
7
- import {
8
- parseGitHubUrl
9
- } from "./chunk-OPDWMD4Q.js";
10
- import {
11
- runWarpGrep,
12
- runWarpGrepStreaming
13
- } from "./chunk-LISSWRUD.js";
14
- import {
15
- compactFileContexts
16
- } from "./chunk-NWGRW4V7.js";
17
- import {
18
- MorphAPIClient
19
- } from "./chunk-JBAY3PRV.js";
20
- import {
21
- logger
22
- } from "./chunk-6WP7EA4F.js";
23
- import {
24
- APIResource
25
- } from "./chunk-NRG6QX3L.js";
1
+ import { createCodeStorageHttpCommands } from './chunk-HDP4QAZL.js';
2
+ import { RemoteCommandsProvider } from './chunk-RYVW7RUM.js';
3
+ import { parseGitHubUrl } from './chunk-OPDWMD4Q.js';
4
+ import { runWarpGrep, runWarpGrepStreaming } from './chunk-GIQAIHUI.js';
5
+ import { compactFileContexts } from './chunk-N7UKZ5X7.js';
6
+ import { MorphAPIClient } from './chunk-KLVJIC2O.js';
7
+ import { logger } from './chunk-6WP7EA4F.js';
8
+ import { APIResource } from './chunk-NRG6QX3L.js';
26
9
 
27
10
  // tools/warp_grep/client.ts
28
11
  var DEFAULT_CODE_SEARCH_URL = "https://api.morphllm.com";
29
12
  async function getLocalProvider(repoRoot, excludes, allowNames) {
30
- const { LocalRipgrepProvider } = await import("./tools/warp_grep/providers/local.js");
13
+ const { LocalRipgrepProvider } = await import('./tools/warp_grep/providers/local.js');
31
14
  const opts = allowNames?.length ? { allowNames } : void 0;
32
15
  return new LocalRipgrepProvider(repoRoot, excludes, opts);
33
16
  }
@@ -319,12 +302,4 @@ function formatResult(result) {
319
302
  return parts.join("\n");
320
303
  }
321
304
 
322
- export {
323
- WarpGrepClient,
324
- executeWarpGrep,
325
- executeToolCall,
326
- executeToolCallStreaming,
327
- executeGitHubReadFile,
328
- formatGitHubReadFileResult,
329
- formatResult
330
- };
305
+ export { WarpGrepClient, executeGitHubReadFile, executeToolCall, executeToolCallStreaming, executeWarpGrep, formatGitHubReadFileResult, formatResult };
@@ -1,10 +1,9 @@
1
+ import fs from 'fs/promises';
2
+
1
3
  // tools/warp_grep/utils/files.ts
2
- import fs from "fs/promises";
3
4
  async function readAllLines(filePath) {
4
5
  const content = await fs.readFile(filePath, "utf8");
5
6
  return content.split(/\r?\n/);
6
7
  }
7
8
 
8
- export {
9
- readAllLines
10
- };
9
+ export { readAllLines };
@@ -9,7 +9,7 @@ var MorphLogger = class {
9
9
  this.fileStream = null;
10
10
  const f = typeof process !== "undefined" ? process.env.MORPH_LOG_FILE : void 0;
11
11
  if (f) {
12
- this.ready = import("fs").then((fs) => {
12
+ this.ready = import('fs').then((fs) => {
13
13
  this.fileStream = fs.createWriteStream(f, { flags: "a" });
14
14
  }).catch(() => {
15
15
  });
@@ -45,6 +45,4 @@ var MorphLogger = class {
45
45
  };
46
46
  var logger = new MorphLogger();
47
47
 
48
- export {
49
- logger
50
- };
48
+ export { logger };