@morphllm/morphsdk 0.2.202 → 0.2.204

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 (246) hide show
  1. package/README.md +101 -0
  2. package/dist/chunk-2GMG5XKU.js +100 -0
  3. package/dist/chunk-2PPYWRMZ.js +3 -4
  4. package/dist/chunk-3HAHJYZQ.cjs +74 -0
  5. package/dist/{chunk-2XU3XXUE.js → chunk-3JROKKS4.js} +3 -25
  6. package/dist/{chunk-26K5EJD3.js → chunk-43JBUEIX.js} +4 -18
  7. package/dist/chunk-44OIEPIO.js +4 -23
  8. package/dist/chunk-4EQQGUZ7.cjs +104 -0
  9. package/dist/chunk-4OUGA3KS.js +1 -5
  10. package/dist/{chunk-VQDDL3UH.js → chunk-4TZBUFVP.js} +2 -8
  11. package/dist/{chunk-YAM6P5OQ.js → chunk-564XJOQP.js} +2 -6
  12. package/dist/chunk-5H3FKFOI.cjs +77 -0
  13. package/dist/chunk-5TTZQF4X.cjs +110 -0
  14. package/dist/chunk-6HAYJA6M.cjs +317 -0
  15. package/dist/chunk-6TZCVTW5.js +3 -4
  16. package/dist/chunk-6WP7EA4F.js +2 -4
  17. package/dist/chunk-74A4HLIO.cjs +42 -0
  18. package/dist/chunk-75ZPJI57.cjs +9 -0
  19. package/dist/chunk-7PJYY46L.cjs +2 -0
  20. package/dist/chunk-AWFZKS27.cjs +11 -0
  21. package/dist/chunk-BJBWWIZV.cjs +2 -0
  22. package/dist/chunk-DLYDIYDK.cjs +305 -0
  23. package/dist/{chunk-65TUD7JV.js → chunk-DYCMPDPV.js} +13 -29
  24. package/dist/{chunk-3CPI6ZIC.js → chunk-DZP7BR66.js} +22 -43
  25. package/dist/chunk-E63OPKP7.js +96 -0
  26. package/dist/chunk-E6V75LI6.cjs +334 -0
  27. package/dist/{chunk-XPHNS7NW.js → chunk-EJ6ID24K.js} +3 -12
  28. package/dist/chunk-EJTL2BOZ.cjs +42 -0
  29. package/dist/chunk-ETBRAKVV.js +1 -5
  30. package/dist/chunk-F633IVQA.cjs +91 -0
  31. package/dist/chunk-FBOZIVVQ.js +1 -0
  32. package/dist/{chunk-UKXCGQPS.js → chunk-FGA6EYC2.js} +35 -37
  33. package/dist/{chunk-CAWQEHKP.js → chunk-G4RODMXA.js} +4 -19
  34. package/dist/chunk-GUNGJC6X.cjs +256 -0
  35. package/dist/chunk-GYE3FY6Z.js +8 -0
  36. package/dist/chunk-HDP4QAZL.js +1 -4
  37. package/dist/chunk-HNMEBYIS.cjs +86 -0
  38. package/dist/chunk-HP3PCOTW.cjs +81 -0
  39. package/dist/{chunk-ICCGLO6V.js → chunk-IGXNLXPN.js} +12 -17
  40. package/dist/chunk-IPJA3ZS6.cjs +10 -0
  41. package/dist/chunk-JHC2R3HU.cjs +317 -0
  42. package/dist/{chunk-IBRBSDLT.js → chunk-JVMIFGZY.js} +5 -8
  43. package/dist/chunk-KF6S3EPJ.cjs +100 -0
  44. package/dist/chunk-KVGZ2TSG.cjs +274 -0
  45. package/dist/{chunk-6OYJC4TZ.js → chunk-L5SCKZVK.js} +13 -22
  46. package/dist/chunk-LDM7RNNN.js +1 -0
  47. package/dist/{chunk-UAZKHSEU.js → chunk-LQST3NW2.js} +5 -15
  48. package/dist/chunk-M34E2AMK.js +1 -5
  49. package/dist/chunk-MF56KEI4.js +1 -4
  50. package/dist/chunk-MLKGABMK.js +1 -3
  51. package/dist/chunk-MLPZKUCO.js +4 -5
  52. package/dist/chunk-MMX5PUGC.cjs +242 -0
  53. package/dist/chunk-MWXJ6DZ2.cjs +21 -0
  54. package/dist/chunk-NJWOWXUR.cjs +137 -0
  55. package/dist/chunk-NNKBKENK.cjs +15 -0
  56. package/dist/chunk-NRG6QX3L.js +1 -3
  57. package/dist/chunk-OCKEEEYE.cjs +433 -0
  58. package/dist/chunk-OENJO7YW.js +306 -0
  59. package/dist/chunk-OKLAYEBC.cjs +2 -0
  60. package/dist/chunk-OPDWMD4Q.js +1 -3
  61. package/dist/{chunk-D6YJ5X3C.js → chunk-OX5GN2KB.js} +26 -14
  62. package/dist/{chunk-JEVLCA5C.js → chunk-OYBOP47A.js} +18 -19
  63. package/dist/chunk-OZHCHPIE.js +1 -0
  64. package/dist/chunk-PA3UTI4A.js +1 -4
  65. package/dist/chunk-QEEAIXL5.cjs +74 -0
  66. package/dist/chunk-QT5LGZG3.cjs +10 -0
  67. package/dist/chunk-R3TUE7O2.cjs +107 -0
  68. package/dist/chunk-RYVW7RUM.js +2 -6
  69. package/dist/{chunk-LVKKICOB.js → chunk-SOQYE5A4.js} +36 -69
  70. package/dist/chunk-ST2OXLT5.cjs +91 -0
  71. package/dist/{chunk-SIFDK4AA.js → chunk-TH4MG73B.js} +3 -24
  72. package/dist/{chunk-OSL4CNSO.js → chunk-TLMAMVAW.js} +7 -23
  73. package/dist/chunk-TPZHMD7J.cjs +72 -0
  74. package/dist/{chunk-PDSIWL7I.js → chunk-U4PYAGNR.js} +6 -19
  75. package/dist/chunk-UAPK3AIJ.js +1 -10
  76. package/dist/chunk-UF5IKELS.cjs +26 -0
  77. package/dist/chunk-UHFVWYSP.cjs +408 -0
  78. package/dist/chunk-UKBSXYKE.cjs +280 -0
  79. package/dist/chunk-UNX7V6P6.cjs +60 -0
  80. package/dist/chunk-UZMMJ47A.cjs +107 -0
  81. package/dist/chunk-VHD7CW5O.cjs +43 -0
  82. package/dist/chunk-VL4QNALG.cjs +50 -0
  83. package/dist/chunk-VYE7O4FM.cjs +51 -0
  84. package/dist/chunk-WIYVT4UO.cjs +173 -0
  85. package/dist/chunk-WJHHO24M.cjs +91 -0
  86. package/dist/chunk-WR7LSUIR.cjs +213 -0
  87. package/dist/chunk-XE6D4J63.cjs +72 -0
  88. package/dist/chunk-YAUXTFIN.cjs +21 -0
  89. package/dist/{chunk-NFPRKZQ5.js → chunk-YJUCGZNN.js} +5 -22
  90. package/dist/chunk-ZSHVXDA2.js +4 -10
  91. package/dist/chunk-ZX6T3LNG.js +302 -0
  92. package/dist/{client-BWhi-vSj.d.ts → client-DSXbcxII.d.ts} +10 -1
  93. package/dist/client.cjs +44 -4360
  94. package/dist/client.d.ts +4 -2
  95. package/dist/client.js +36 -37
  96. package/dist/core/client.cjs +14 -476
  97. package/dist/core/client.d.ts +8 -0
  98. package/dist/core/client.js +10 -11
  99. package/dist/core/error.cjs +8 -251
  100. package/dist/core/error.js +4 -9
  101. package/dist/core/index.cjs +27 -491
  102. package/dist/core/index.d.ts +2 -0
  103. package/dist/core/index.js +12 -19
  104. package/dist/core/resource.cjs +9 -33
  105. package/dist/core/resource.d.ts +2 -0
  106. package/dist/core/resource.js +2 -7
  107. package/dist/edge.cjs +74 -1111
  108. package/dist/edge.d.ts +3 -0
  109. package/dist/edge.js +14 -42
  110. package/dist/guard-CvW03v4u.d.ts +59 -0
  111. package/dist/index.cjs +140 -4431
  112. package/dist/index.d.ts +6 -2
  113. package/dist/index.js +44 -87
  114. package/dist/modelrouter/core.cjs +35 -651
  115. package/dist/modelrouter/core.d.ts +2 -0
  116. package/dist/modelrouter/core.js +12 -21
  117. package/dist/modelrouter/index.cjs +35 -651
  118. package/dist/modelrouter/index.d.ts +2 -0
  119. package/dist/modelrouter/index.js +12 -21
  120. package/dist/modelrouter/types.cjs +1 -17
  121. package/dist/modelrouter/types.d.ts +5 -0
  122. package/dist/modelrouter/types.js +1 -0
  123. package/dist/subagents/anthropic.cjs +31 -2784
  124. package/dist/subagents/anthropic.d.ts +3 -1
  125. package/dist/subagents/anthropic.js +23 -24
  126. package/dist/subagents/index.cjs +14 -95
  127. package/dist/subagents/index.d.ts +3 -1
  128. package/dist/subagents/index.js +2 -11
  129. package/dist/subagents/prompts.cjs +14 -93
  130. package/dist/subagents/prompts.d.ts +3 -1
  131. package/dist/subagents/prompts.js +2 -11
  132. package/dist/subagents/types.cjs +1 -17
  133. package/dist/subagents/types.d.ts +3 -1
  134. package/dist/subagents/types.js +1 -0
  135. package/dist/subagents/vercel.cjs +31 -2761
  136. package/dist/subagents/vercel.d.ts +3 -1
  137. package/dist/subagents/vercel.js +23 -24
  138. package/dist/tools/compact/core.cjs +20 -552
  139. package/dist/tools/compact/core.d.ts +2 -0
  140. package/dist/tools/compact/core.js +12 -13
  141. package/dist/tools/compact/index.cjs +24 -598
  142. package/dist/tools/compact/index.d.ts +3 -1
  143. package/dist/tools/compact/index.js +13 -17
  144. package/dist/tools/compact/types.cjs +1 -17
  145. package/dist/tools/compact/types.d.ts +4 -4
  146. package/dist/tools/compact/types.js +1 -0
  147. package/dist/tools/fastapply/anthropic.cjs +39 -899
  148. package/dist/tools/fastapply/anthropic.d.ts +2 -0
  149. package/dist/tools/fastapply/anthropic.js +15 -24
  150. package/dist/tools/fastapply/apply.cjs +32 -672
  151. package/dist/tools/fastapply/apply.d.ts +2 -0
  152. package/dist/tools/fastapply/apply.js +8 -19
  153. package/dist/tools/fastapply/core.cjs +49 -1069
  154. package/dist/tools/fastapply/core.d.ts +3 -0
  155. package/dist/tools/fastapply/core.js +13 -29
  156. package/dist/tools/fastapply/index.cjs +56 -1052
  157. package/dist/tools/fastapply/index.d.ts +2 -0
  158. package/dist/tools/fastapply/index.js +18 -44
  159. package/dist/tools/fastapply/openai.cjs +45 -910
  160. package/dist/tools/fastapply/openai.d.ts +2 -0
  161. package/dist/tools/fastapply/openai.js +15 -26
  162. package/dist/tools/fastapply/prompts.cjs +10 -62
  163. package/dist/tools/fastapply/prompts.js +2 -9
  164. package/dist/tools/fastapply/types.cjs +1 -17
  165. package/dist/tools/fastapply/types.d.ts +9 -4
  166. package/dist/tools/fastapply/types.js +1 -0
  167. package/dist/tools/fastapply/vercel.cjs +37 -905
  168. package/dist/tools/fastapply/vercel.d.ts +2 -0
  169. package/dist/tools/fastapply/vercel.js +15 -22
  170. package/dist/tools/index.cjs +56 -1052
  171. package/dist/tools/index.d.ts +2 -0
  172. package/dist/tools/index.js +18 -44
  173. package/dist/tools/pii/index.cjs +47 -0
  174. package/dist/tools/pii/index.d.ts +4 -0
  175. package/dist/tools/pii/index.js +6 -0
  176. package/dist/tools/pii/model.cjs +45 -0
  177. package/dist/tools/pii/model.d.ts +83 -0
  178. package/dist/tools/pii/model.js +4 -0
  179. package/dist/tools/pii/patterns.cjs +15 -0
  180. package/dist/tools/pii/patterns.d.ts +31 -0
  181. package/dist/tools/pii/patterns.js +2 -0
  182. package/dist/tools/pii/regex.cjs +32 -0
  183. package/dist/tools/pii/regex.d.ts +48 -0
  184. package/dist/tools/pii/regex.js +3 -0
  185. package/dist/tools/pii/types.cjs +2 -0
  186. package/dist/tools/pii/types.d.ts +108 -0
  187. package/dist/tools/pii/types.js +1 -0
  188. package/dist/tools/utils/resilience.cjs +15 -312
  189. package/dist/tools/utils/resilience.js +3 -12
  190. package/dist/tools/warp_grep/agent/config.cjs +16 -127
  191. package/dist/tools/warp_grep/agent/config.js +2 -11
  192. package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
  193. package/dist/tools/warp_grep/agent/formatter.js +2 -9
  194. package/dist/tools/warp_grep/agent/parser.cjs +16 -83
  195. package/dist/tools/warp_grep/agent/parser.d.ts +2 -0
  196. package/dist/tools/warp_grep/agent/parser.js +2 -11
  197. package/dist/tools/warp_grep/agent/runner.cjs +19 -1081
  198. package/dist/tools/warp_grep/agent/runner.d.ts +2 -0
  199. package/dist/tools/warp_grep/agent/runner.js +11 -14
  200. package/dist/tools/warp_grep/agent/types.cjs +1 -17
  201. package/dist/tools/warp_grep/agent/types.d.ts +4 -0
  202. package/dist/tools/warp_grep/agent/types.js +1 -0
  203. package/dist/tools/warp_grep/anthropic.cjs +51 -2561
  204. package/dist/tools/warp_grep/anthropic.d.ts +3 -1
  205. package/dist/tools/warp_grep/anthropic.js +23 -35
  206. package/dist/tools/warp_grep/client.cjs +53 -2471
  207. package/dist/tools/warp_grep/client.d.ts +3 -1
  208. package/dist/tools/warp_grep/client.js +21 -34
  209. package/dist/tools/warp_grep/gemini.cjs +52 -2490
  210. package/dist/tools/warp_grep/gemini.d.ts +3 -1
  211. package/dist/tools/warp_grep/gemini.js +25 -41
  212. package/dist/tools/warp_grep/harness.cjs +81 -936
  213. package/dist/tools/warp_grep/harness.d.ts +2 -0
  214. package/dist/tools/warp_grep/harness.js +12 -51
  215. package/dist/tools/warp_grep/index.cjs +128 -2575
  216. package/dist/tools/warp_grep/index.d.ts +3 -1
  217. package/dist/tools/warp_grep/index.js +28 -87
  218. package/dist/tools/warp_grep/openai.cjs +57 -2575
  219. package/dist/tools/warp_grep/openai.d.ts +3 -1
  220. package/dist/tools/warp_grep/openai.js +23 -37
  221. package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
  222. package/dist/tools/warp_grep/providers/code_storage_http.d.ts +3 -1
  223. package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
  224. package/dist/tools/warp_grep/providers/local.cjs +10 -589
  225. package/dist/tools/warp_grep/providers/local.js +6 -11
  226. package/dist/tools/warp_grep/providers/remote.cjs +8 -331
  227. package/dist/tools/warp_grep/providers/remote.d.ts +3 -1
  228. package/dist/tools/warp_grep/providers/remote.js +3 -8
  229. package/dist/tools/warp_grep/providers/types.cjs +1 -17
  230. package/dist/tools/warp_grep/providers/types.js +1 -0
  231. package/dist/tools/warp_grep/utils/files.cjs +9 -42
  232. package/dist/tools/warp_grep/utils/files.js +2 -7
  233. package/dist/tools/warp_grep/utils/github.cjs +9 -43
  234. package/dist/tools/warp_grep/utils/github.js +2 -7
  235. package/dist/tools/warp_grep/utils/paths.cjs +28 -104
  236. package/dist/tools/warp_grep/utils/paths.js +2 -17
  237. package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -103
  238. package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
  239. package/dist/tools/warp_grep/vercel.cjs +57 -2557
  240. package/dist/tools/warp_grep/vercel.d.ts +3 -1
  241. package/dist/tools/warp_grep/vercel.js +23 -37
  242. package/dist/{types-DxZLPogx.d.ts → types-BKhXjDCB.d.ts} +6 -1
  243. package/dist/version.cjs +7 -225
  244. package/dist/version.js +2 -7
  245. package/package.json +11 -2
  246. package/dist/chunk-E6TL6MIH.js +0 -203
@@ -0,0 +1,256 @@
1
+ 'use strict';
2
+
3
+ var chunkJHC2R3HU_cjs = require('./chunk-JHC2R3HU.cjs');
4
+ var chunkTPZHMD7J_cjs = require('./chunk-TPZHMD7J.cjs');
5
+ var ai = require('ai');
6
+ var zod = require('zod');
7
+
8
+ var DEFAULT_MAX_TURNS = {
9
+ quick: 3,
10
+ medium: 6,
11
+ thorough: 12
12
+ };
13
+ function getMaxTurns(config) {
14
+ return config.maxTurns ?? DEFAULT_MAX_TURNS[config.thoroughness ?? "medium"] ?? 6;
15
+ }
16
+ function createExploreSubagent(config) {
17
+ if (!config.repoRoot) {
18
+ throw new Error("repoRoot is required for Explore subagent");
19
+ }
20
+ const warpGrep = new chunkJHC2R3HU_cjs.WarpGrepClient({
21
+ morphApiKey: config.morphApiKey
22
+ });
23
+ const thoroughness = config.thoroughness ?? "medium";
24
+ const replyTimeout = config.replyTimeout ?? 3e4;
25
+ async function runExplore(prompt, callbacks = {}) {
26
+ const startTime = Date.now();
27
+ const allContexts = [];
28
+ let searchCount = 0;
29
+ const timeoutMs = config.timeout;
30
+ const timeoutPromise = timeoutMs ? new Promise(
31
+ (_, reject) => setTimeout(() => reject(new Error(`Exploration timed out after ${timeoutMs}ms`)), timeoutMs)
32
+ ) : null;
33
+ const runPromise = (async () => {
34
+ try {
35
+ const codebaseSearchSchema = zod.z.object({
36
+ searchRequest: zod.z.string().describe("Natural language description of what to search for")
37
+ });
38
+ const sendMessageSchema = zod.z.object({
39
+ message: zod.z.string().describe("The message to send to the orchestrator")
40
+ });
41
+ const result = await ai.generateText({
42
+ model: config.model,
43
+ system: chunkTPZHMD7J_cjs.getSystemPrompt(thoroughness),
44
+ prompt,
45
+ tools: {
46
+ codebase_search: ai.tool({
47
+ description: chunkTPZHMD7J_cjs.CODEBASE_SEARCH_TOOL.description,
48
+ inputSchema: codebaseSearchSchema,
49
+ execute: async (params) => {
50
+ searchCount++;
51
+ const warpResult = await warpGrep.execute({
52
+ searchTerm: params.searchRequest,
53
+ repoRoot: config.repoRoot,
54
+ excludes: config.excludes,
55
+ includes: config.includes
56
+ });
57
+ if (warpResult.contexts) {
58
+ allContexts.push(...warpResult.contexts);
59
+ }
60
+ callbacks.onStep?.({
61
+ step: searchCount,
62
+ searchRequest: params.searchRequest,
63
+ contextsFound: warpResult.contexts?.length ?? 0,
64
+ isFinal: false
65
+ });
66
+ return chunkJHC2R3HU_cjs.formatResult(warpResult);
67
+ }
68
+ }),
69
+ send_message: ai.tool({
70
+ description: chunkTPZHMD7J_cjs.SEND_MESSAGE_TOOL.description,
71
+ inputSchema: sendMessageSchema,
72
+ execute: async (params) => {
73
+ const subagentMsg = {
74
+ from: "explore",
75
+ content: params.message,
76
+ timestamp: Date.now()
77
+ };
78
+ const replyPromise = new Promise((resolve) => {
79
+ if (callbacks.onMessage) {
80
+ callbacks.onMessage(subagentMsg, (replyText) => {
81
+ resolve(replyText);
82
+ });
83
+ } else {
84
+ setTimeout(() => resolve(""), replyTimeout);
85
+ }
86
+ });
87
+ const reply = await Promise.race([
88
+ replyPromise,
89
+ new Promise(
90
+ (resolve) => setTimeout(() => resolve(""), replyTimeout)
91
+ )
92
+ ]);
93
+ if (reply) {
94
+ return `Response from orchestrator: ${reply}`;
95
+ }
96
+ return "No response. Continue with your best judgment.";
97
+ }
98
+ })
99
+ },
100
+ stopWhen: ai.stepCountIs(getMaxTurns(config))
101
+ });
102
+ callbacks.onStep?.({
103
+ step: searchCount,
104
+ searchRequest: "",
105
+ contextsFound: allContexts.length,
106
+ isFinal: true
107
+ });
108
+ const uniqueContexts = deduplicateContexts(allContexts);
109
+ return {
110
+ success: true,
111
+ summary: result.text || "Exploration completed but no summary was generated.",
112
+ contexts: uniqueContexts,
113
+ searchCount,
114
+ durationMs: Date.now() - startTime
115
+ };
116
+ } catch (error) {
117
+ return {
118
+ success: false,
119
+ summary: "",
120
+ contexts: deduplicateContexts(allContexts),
121
+ searchCount,
122
+ durationMs: Date.now() - startTime,
123
+ error: error instanceof Error ? error.message : String(error)
124
+ };
125
+ }
126
+ })();
127
+ if (timeoutPromise) {
128
+ try {
129
+ return await Promise.race([runPromise, timeoutPromise]);
130
+ } catch (error) {
131
+ return {
132
+ success: false,
133
+ summary: "",
134
+ contexts: deduplicateContexts(allContexts),
135
+ searchCount,
136
+ durationMs: Date.now() - startTime,
137
+ error: error instanceof Error ? error.message : String(error)
138
+ };
139
+ }
140
+ }
141
+ return runPromise;
142
+ }
143
+ const exploreToolSchema = zod.z.object({
144
+ searchRequest: zod.z.string().describe("What to explore in the codebase. Be specific about what you want to understand.")
145
+ });
146
+ const exploreTool = ai.tool({
147
+ 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.",
148
+ inputSchema: exploreToolSchema,
149
+ execute: async (params) => {
150
+ const result = await runExplore(params.searchRequest);
151
+ return {
152
+ success: result.success,
153
+ summary: result.summary,
154
+ searchCount: result.searchCount,
155
+ error: result.error
156
+ };
157
+ }
158
+ });
159
+ return {
160
+ /** Vercel AI SDK tool for use as a tool in parent agents */
161
+ tool: exploreTool,
162
+ /** Run exploration with messaging support */
163
+ run(prompt) {
164
+ const messageHandlers = [];
165
+ const stepHandlers = [];
166
+ let resultPromise = null;
167
+ const session = {
168
+ on(event, handler) {
169
+ if (event === "message") messageHandlers.push(handler);
170
+ if (event === "step") stepHandlers.push(handler);
171
+ return session;
172
+ },
173
+ send(_text) {
174
+ },
175
+ get result() {
176
+ if (!resultPromise) {
177
+ resultPromise = runExplore(prompt, {
178
+ onStep: (step) => {
179
+ for (const handler of stepHandlers) handler(step);
180
+ },
181
+ onMessage: (msg, reply) => {
182
+ if (messageHandlers.length > 0) {
183
+ for (const handler of messageHandlers) handler(msg, reply);
184
+ } else {
185
+ reply("");
186
+ }
187
+ }
188
+ });
189
+ }
190
+ return resultPromise;
191
+ }
192
+ };
193
+ return session;
194
+ },
195
+ /** Stream exploration events as an async generator */
196
+ async *stream(prompt) {
197
+ const events = [];
198
+ let resolveNext = null;
199
+ let done = false;
200
+ const resultPromise = runExplore(prompt, {
201
+ onStep: (step) => {
202
+ events.push({
203
+ type: "step",
204
+ step: step.step,
205
+ searchRequest: step.searchRequest,
206
+ contextsFound: step.contextsFound,
207
+ isFinal: step.isFinal
208
+ });
209
+ resolveNext?.();
210
+ },
211
+ onMessage: (msg, reply) => {
212
+ events.push({
213
+ type: "message",
214
+ from: msg.from,
215
+ content: msg.content,
216
+ timestamp: msg.timestamp
217
+ });
218
+ resolveNext?.();
219
+ reply("Continue with your best judgment.");
220
+ }
221
+ });
222
+ while (!done) {
223
+ if (events.length > 0) {
224
+ yield events.shift();
225
+ } else {
226
+ const raceResult = await Promise.race([
227
+ resultPromise.then((r) => ({ type: "done", result: r })),
228
+ new Promise((resolve) => {
229
+ resolveNext = () => resolve({ type: "event" });
230
+ })
231
+ ]);
232
+ if (raceResult.type === "done") {
233
+ while (events.length > 0) {
234
+ yield events.shift();
235
+ }
236
+ done = true;
237
+ return raceResult.result;
238
+ }
239
+ }
240
+ }
241
+ return await resultPromise;
242
+ }
243
+ };
244
+ }
245
+ function deduplicateContexts(contexts) {
246
+ const map = /* @__PURE__ */ new Map();
247
+ for (const ctx of contexts) {
248
+ const existing = map.get(ctx.file);
249
+ if (!existing || ctx.content.length > existing.content.length) {
250
+ map.set(ctx.file, ctx);
251
+ }
252
+ }
253
+ return Array.from(map.values());
254
+ }
255
+
256
+ exports.createExploreSubagent = createExploreSubagent;
@@ -0,0 +1,8 @@
1
+ // package.json
2
+ var package_default = {
3
+ version: "0.2.204"};
4
+
5
+ // version.ts
6
+ var SDK_VERSION = package_default.version;
7
+
8
+ export { SDK_VERSION };
@@ -37,7 +37,4 @@ function createCodeStorageHttpCommands(config) {
37
37
  };
38
38
  }
39
39
 
40
- export {
41
- toRepoRelative,
42
- createCodeStorageHttpCommands
43
- };
40
+ export { createCodeStorageHttpCommands, toRepoRelative };
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var chunk74A4HLIO_cjs = require('./chunk-74A4HLIO.cjs');
4
+ var chunkNJWOWXUR_cjs = require('./chunk-NJWOWXUR.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
+
7
+ // tools/fastapply/openai.ts
8
+ var openai_exports = {};
9
+ chunk75ZPJI57_cjs.__export(openai_exports, {
10
+ createEditFileTool: () => createEditFileTool,
11
+ default: () => openai_default,
12
+ editFileTool: () => editFileTool,
13
+ execute: () => execute,
14
+ formatResult: () => formatResult,
15
+ getSystemPrompt: () => getSystemPrompt
16
+ });
17
+ var editFileTool = {
18
+ type: "function",
19
+ function: {
20
+ name: "edit_file",
21
+ description: chunk74A4HLIO_cjs.EDIT_FILE_TOOL_DESCRIPTION,
22
+ parameters: {
23
+ type: "object",
24
+ properties: {
25
+ target_filepath: {
26
+ type: "string",
27
+ description: "The path of the target file to modify"
28
+ },
29
+ instruction: {
30
+ type: "string",
31
+ description: "A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."
32
+ },
33
+ code_edit: {
34
+ type: "string",
35
+ description: "Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections."
36
+ }
37
+ },
38
+ required: ["target_filepath", "instruction", "code_edit"]
39
+ }
40
+ }
41
+ };
42
+ async function execute(input, config) {
43
+ return chunkNJWOWXUR_cjs.executeEditFile(input, config);
44
+ }
45
+ function getSystemPrompt() {
46
+ return chunk74A4HLIO_cjs.EDIT_FILE_SYSTEM_PROMPT;
47
+ }
48
+ function formatResult(result) {
49
+ if (!result.success) {
50
+ return `Error editing file: ${result.error}`;
51
+ }
52
+ const { changes } = result;
53
+ return `Successfully applied changes to ${result.filepath}. Added ${changes.linesAdded}, removed ${changes.linesRemoved}, modified ${changes.linesModified}.`;
54
+ }
55
+ function createEditFileTool(config = {}) {
56
+ const toolDef = {
57
+ ...editFileTool,
58
+ ...config.description && {
59
+ function: {
60
+ ...editFileTool.function,
61
+ description: config.description
62
+ }
63
+ }
64
+ };
65
+ return Object.assign({}, toolDef, {
66
+ execute: async (input) => {
67
+ const parsedInput = typeof input === "string" ? JSON.parse(input) : input;
68
+ return execute(parsedInput, config);
69
+ },
70
+ formatResult: (result) => {
71
+ return formatResult(result);
72
+ },
73
+ getSystemPrompt: () => {
74
+ return getSystemPrompt();
75
+ }
76
+ });
77
+ }
78
+ var openai_default = editFileTool;
79
+
80
+ exports.createEditFileTool = createEditFileTool;
81
+ exports.editFileTool = editFileTool;
82
+ exports.execute = execute;
83
+ exports.formatResult = formatResult;
84
+ exports.getSystemPrompt = getSystemPrompt;
85
+ exports.openai_default = openai_default;
86
+ exports.openai_exports = openai_exports;
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var chunk74A4HLIO_cjs = require('./chunk-74A4HLIO.cjs');
4
+ var chunkNJWOWXUR_cjs = require('./chunk-NJWOWXUR.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
+ var ai = require('ai');
7
+ var zod = require('zod');
8
+
9
+ // tools/fastapply/vercel.ts
10
+ var vercel_exports = {};
11
+ chunk75ZPJI57_cjs.__export(vercel_exports, {
12
+ createEditFileTool: () => createEditFileTool,
13
+ default: () => vercel_default,
14
+ editFileTool: () => editFileTool,
15
+ getSystemPrompt: () => getSystemPrompt
16
+ });
17
+ var editFileSchema = zod.z.object({
18
+ target_filepath: zod.z.string().describe("The path of the target file to modify"),
19
+ instruction: zod.z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
20
+ code_edit: zod.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
21
+ });
22
+ var editFileTool = ai.tool({
23
+ description: chunk74A4HLIO_cjs.EDIT_FILE_TOOL_DESCRIPTION,
24
+ inputSchema: editFileSchema,
25
+ execute: async (params) => {
26
+ const result = await chunkNJWOWXUR_cjs.executeEditFile({
27
+ target_filepath: params.target_filepath,
28
+ instruction: params.instruction,
29
+ code_edit: params.code_edit
30
+ });
31
+ if (!result.success) {
32
+ throw new Error(`Failed to edit file: ${result.error}`);
33
+ }
34
+ return {
35
+ success: true,
36
+ filepath: result.filepath,
37
+ changes: result.changes,
38
+ udiff: result.udiff
39
+ };
40
+ }
41
+ });
42
+ function getSystemPrompt() {
43
+ return chunk74A4HLIO_cjs.EDIT_FILE_SYSTEM_PROMPT;
44
+ }
45
+ function createEditFileTool(config = {}) {
46
+ const schema = zod.z.object({
47
+ target_filepath: zod.z.string().describe("The path of the target file to modify"),
48
+ instruction: zod.z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
49
+ code_edit: zod.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
50
+ });
51
+ return ai.tool({
52
+ description: config.description || chunk74A4HLIO_cjs.EDIT_FILE_TOOL_DESCRIPTION,
53
+ inputSchema: schema,
54
+ execute: async (params) => {
55
+ const result = await chunkNJWOWXUR_cjs.executeEditFile(
56
+ {
57
+ target_filepath: params.target_filepath,
58
+ instruction: params.instruction,
59
+ code_edit: params.code_edit
60
+ },
61
+ config
62
+ );
63
+ if (!result.success) {
64
+ throw new Error(`Failed to edit file: ${result.error}`);
65
+ }
66
+ return {
67
+ success: true,
68
+ filepath: result.filepath,
69
+ changes: result.changes,
70
+ udiff: result.udiff
71
+ };
72
+ }
73
+ });
74
+ }
75
+ var vercel_default = editFileTool;
76
+
77
+ exports.createEditFileTool = createEditFileTool;
78
+ exports.editFileTool = editFileTool;
79
+ exports.getSystemPrompt = getSystemPrompt;
80
+ exports.vercel_default = vercel_default;
81
+ exports.vercel_exports = vercel_exports;
@@ -1,17 +1,8 @@
1
- import {
2
- logger
3
- } from "./chunk-6WP7EA4F.js";
4
- import {
5
- toMorphError
6
- } from "./chunk-YAM6P5OQ.js";
7
- import {
8
- MorphError,
9
- fetchWithRetry,
10
- withTimeout
11
- } from "./chunk-VQDDL3UH.js";
12
- import {
13
- SDK_VERSION
14
- } from "./chunk-E6TL6MIH.js";
1
+ import { logger } from './chunk-6WP7EA4F.js';
2
+ import { resolvePIIGuard } from './chunk-E63OPKP7.js';
3
+ import { toMorphError } from './chunk-564XJOQP.js';
4
+ import { MorphError, withTimeout, fetchWithRetry } from './chunk-4TZBUFVP.js';
5
+ import { SDK_VERSION } from './chunk-GYE3FY6Z.js';
15
6
 
16
7
  // core/client.ts
17
8
  var DEFAULT_BASE_URL = "https://api.morphllm.com";
@@ -29,6 +20,10 @@ var MorphAPIClient = class {
29
20
  timeout;
30
21
  retryConfig;
31
22
  debug;
23
+ /** The `redactPII` option as given, for resources that build their own HTTP client. */
24
+ redactPII;
25
+ /** Set when `redactPII` is on. Resources open a session per request or run. */
26
+ pii;
32
27
  constructor(options = {}) {
33
28
  this.apiKey = options.apiKey;
34
29
  this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
@@ -36,6 +31,8 @@ var MorphAPIClient = class {
36
31
  this.timeout = options.timeout;
37
32
  this.retryConfig = options.retryConfig;
38
33
  this.debug = options.debug ?? false;
34
+ this.redactPII = options.redactPII;
35
+ this.pii = resolvePIIGuard(options.redactPII);
39
36
  if (this.debug) logger.enable();
40
37
  }
41
38
  /** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
@@ -108,6 +105,4 @@ var MorphAPIClient = class {
108
105
  }
109
106
  };
110
107
 
111
- export {
112
- MorphAPIClient
113
- };
108
+ export { MorphAPIClient };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ // tools/warp_grep/index.ts
6
+ var warpGrepInputSchema = zod.z.object({
7
+ search_term: zod.z.string().describe("Search problem statement that this subagent is supposed to research for")
8
+ });
9
+
10
+ exports.warpGrepInputSchema = warpGrepInputSchema;