@morphllm/morphsdk 0.2.202 → 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-SIFDK4AA.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-3CPI6ZIC.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-2XU3XXUE.js → chunk-AJBZA23L.js} +3 -25
  17. package/dist/chunk-AWFZKS27.cjs +11 -0
  18. package/dist/{chunk-LVKKICOB.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-UAZKHSEU.js → chunk-E3XNKAMI.js} +5 -15
  22. package/dist/{chunk-VQDDL3UH.js → chunk-E7FLETFO.js} +2 -8
  23. package/dist/{chunk-YAM6P5OQ.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-6OYJC4TZ.js → chunk-EZ2OFDBJ.js} +5 -19
  27. package/dist/chunk-FBOZIVVQ.js +1 -0
  28. package/dist/{chunk-CAWQEHKP.js → chunk-GDFPZ3NJ.js} +4 -19
  29. package/dist/{chunk-UKXCGQPS.js → chunk-GIQAIHUI.js} +8 -33
  30. package/dist/chunk-GSUQGDCL.cjs +235 -0
  31. package/dist/{chunk-D6YJ5X3C.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-XPHNS7NW.js → chunk-IUM6CQYX.js} +3 -12
  36. package/dist/{chunk-26K5EJD3.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-JEVLCA5C.js → chunk-JUGNTIVU.js} +6 -19
  41. package/dist/{chunk-NFPRKZQ5.js → chunk-JY6COF3X.js} +5 -22
  42. package/dist/{chunk-ICCGLO6V.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-65TUD7JV.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-MLPZKUCO.js +4 -5
  51. package/dist/chunk-MWXJ6DZ2.cjs +21 -0
  52. package/dist/{chunk-IBRBSDLT.js → chunk-N7UKZ5X7.js} +2 -6
  53. package/dist/chunk-NDUC7OV6.cjs +74 -0
  54. package/dist/{chunk-PDSIWL7I.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-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 -4360
  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 -4431
  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 -2784
  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 -2761
  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 -2561
  148. package/dist/tools/warp_grep/anthropic.js +19 -35
  149. package/dist/tools/warp_grep/client.cjs +49 -2471
  150. package/dist/tools/warp_grep/client.js +17 -34
  151. package/dist/tools/warp_grep/gemini.cjs +48 -2490
  152. package/dist/tools/warp_grep/gemini.js +21 -41
  153. package/dist/tools/warp_grep/harness.cjs +81 -936
  154. package/dist/tools/warp_grep/harness.js +12 -51
  155. package/dist/tools/warp_grep/index.cjs +124 -2575
  156. package/dist/tools/warp_grep/index.js +24 -87
  157. package/dist/tools/warp_grep/openai.cjs +53 -2575
  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 -589
  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 -103
  174. package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
  175. package/dist/tools/warp_grep/vercel.cjs +53 -2557
  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-E6TL6MIH.js +0 -203
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ // tools/fastapply/prompts.ts
4
+ var EDIT_FILE_TOOL_DESCRIPTION = `Use this tool to make an edit to an existing file.
5
+
6
+ This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
7
+
8
+ When writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.
9
+
10
+ For example:
11
+
12
+ // ... existing code ...
13
+ FIRST_EDIT
14
+ // ... existing code ...
15
+ SECOND_EDIT
16
+ // ... existing code ...
17
+ THIRD_EDIT
18
+ // ... existing code ...
19
+
20
+ You should still bias towards repeating as few lines of the original file as possible to convey the change.
21
+ But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
22
+
23
+ DO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.
24
+
25
+ If you plan on deleting a section, you must provide context before and after to delete it.
26
+
27
+ Make sure it is clear what the edit should be, and where it should be applied.
28
+ Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.`;
29
+ var EDIT_FILE_SYSTEM_PROMPT = `When the user is asking for edits to their code, use the edit_file tool to highlight the changes necessary and add comments to indicate where unchanged code has been skipped. For example:
30
+
31
+ // ... existing code ...
32
+ {{ edit_1 }}
33
+ // ... existing code ...
34
+ {{ edit_2 }}
35
+ // ... existing code ...
36
+
37
+ Often this will mean that the start/end of the file will be skipped, but that's okay! Rewrite the entire file ONLY if specifically requested. Always provide a brief explanation of the updates, unless the user specifically requests only the code.
38
+
39
+ These edit codeblocks are also read by a less intelligent language model, colloquially called the apply model, to update the file. To help specify the edit to the apply model, you will be very careful when generating the codeblock to not introduce ambiguity. You will specify all unchanged regions (code and comments) of the file with "// ... existing code ..." comment markers. This will ensure the apply model will not delete existing unchanged code or comments when editing the file.`;
40
+
41
+ exports.EDIT_FILE_SYSTEM_PROMPT = EDIT_FILE_SYSTEM_PROMPT;
42
+ exports.EDIT_FILE_TOOL_DESCRIPTION = EDIT_FILE_TOOL_DESCRIPTION;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+
9
+ exports.__export = __export;
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ var chunkEJTL2BOZ_cjs = require('./chunk-EJTL2BOZ.cjs');
4
+ var chunkUUCRWJJR_cjs = require('./chunk-UUCRWJJR.cjs');
5
+
6
+ // tools/warp_grep/anthropic.ts
7
+ var INPUT_SCHEMA = {
8
+ type: "object",
9
+ properties: {
10
+ search_term: { type: "string", description: "Search problem statement that this subagent is supposed to research for" }
11
+ },
12
+ required: ["search_term"]
13
+ };
14
+ var warpGrepTool = {
15
+ name: chunkEJTL2BOZ_cjs.WARP_GREP_TOOL_NAME,
16
+ description: chunkEJTL2BOZ_cjs.WARP_GREP_DESCRIPTION,
17
+ input_schema: INPUT_SCHEMA
18
+ };
19
+ async function execute(input, config) {
20
+ return chunkUUCRWJJR_cjs.executeToolCall(input, config);
21
+ }
22
+ function createWarpGrepTool(config) {
23
+ const tool = {
24
+ name: config.name ?? chunkEJTL2BOZ_cjs.WARP_GREP_TOOL_NAME,
25
+ description: config.description ?? chunkEJTL2BOZ_cjs.WARP_GREP_DESCRIPTION,
26
+ input_schema: INPUT_SCHEMA
27
+ };
28
+ return Object.assign(tool, {
29
+ execute: async (input) => {
30
+ return chunkUUCRWJJR_cjs.executeToolCall(input, config);
31
+ },
32
+ formatResult: (result) => {
33
+ return chunkUUCRWJJR_cjs.formatResult(result);
34
+ }
35
+ });
36
+ }
37
+ function createGitHubSearchTool(config) {
38
+ const client = new chunkUUCRWJJR_cjs.WarpGrepClient(config);
39
+ const tool = {
40
+ name: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_TOOL_NAME,
41
+ description: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_DESCRIPTION,
42
+ input_schema: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_INPUT_SCHEMA
43
+ };
44
+ return Object.assign(tool, {
45
+ execute: async (input) => {
46
+ const github = input.github_url || input.owner_repo;
47
+ if (!github) {
48
+ throw new Error("Please provide github search url or owner/repo id");
49
+ }
50
+ return client.searchGitHub({ searchTerm: input.search_term, github, branch: input.branch });
51
+ },
52
+ formatResult: (result) => {
53
+ return chunkUUCRWJJR_cjs.formatResult(result);
54
+ }
55
+ });
56
+ }
57
+ function createGitHubReadFileTool(config) {
58
+ const tool = {
59
+ name: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_TOOL_NAME,
60
+ description: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_DESCRIPTION,
61
+ input_schema: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_INPUT_SCHEMA
62
+ };
63
+ return Object.assign(tool, {
64
+ execute: async (input) => {
65
+ return chunkUUCRWJJR_cjs.executeGitHubReadFile(input, config);
66
+ },
67
+ formatResult: (result) => {
68
+ return chunkUUCRWJJR_cjs.formatGitHubReadFileResult(result);
69
+ }
70
+ });
71
+ }
72
+
73
+ exports.createGitHubReadFileTool = createGitHubReadFileTool;
74
+ exports.createGitHubSearchTool = createGitHubSearchTool;
75
+ exports.createWarpGrepTool = createWarpGrepTool;
76
+ exports.execute = execute;
77
+ exports.warpGrepTool = warpGrepTool;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ var chunk65W4I66Q_cjs = require('./chunk-65W4I66Q.cjs');
4
+ var chunkOM5ZSXQW_cjs = require('./chunk-OM5ZSXQW.cjs');
5
+ var chunkAWFZKS27_cjs = require('./chunk-AWFZKS27.cjs');
6
+
7
+ // tools/compact/core.ts
8
+ var DEFAULT_API_URL = "https://api.morphllm.com";
9
+ var DEFAULT_TIMEOUT = 12e4;
10
+ function resolveClient(clientOrConfig) {
11
+ if (clientOrConfig instanceof chunk65W4I66Q_cjs.MorphAPIClient) return clientOrConfig;
12
+ return new chunk65W4I66Q_cjs.MorphAPIClient({
13
+ apiKey: clientOrConfig.morphApiKey,
14
+ baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL,
15
+ timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
16
+ retryConfig: clientOrConfig.retryConfig,
17
+ debug: clientOrConfig.debug
18
+ });
19
+ }
20
+ var CompactClient = class extends chunkAWFZKS27_cjs.APIResource {
21
+ /** Resolved URL/timeout, exposed for backwards-compatible introspection. */
22
+ config;
23
+ constructor(clientOrConfig = {}) {
24
+ super(resolveClient(clientOrConfig));
25
+ const cfg = clientOrConfig instanceof chunk65W4I66Q_cjs.MorphAPIClient ? {} : clientOrConfig;
26
+ this.config = {
27
+ morphApiUrl: this._client.baseURL,
28
+ timeout: cfg.timeout ?? DEFAULT_TIMEOUT,
29
+ debug: cfg.debug ?? false
30
+ };
31
+ }
32
+ /**
33
+ * Compact messages or text via /v1/compact.
34
+ * Returns per-message `compacted_line_ranges` showing which lines were removed.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const client = new CompactClient({ morphApiKey: 'sk-...' });
39
+ * const result = await client.compact({
40
+ * input: codeFile,
41
+ * query: "authentication",
42
+ * compressionRatio: 0.5,
43
+ * });
44
+ * console.log(result.output);
45
+ * ```
46
+ */
47
+ async compact(input) {
48
+ const body = {
49
+ compression_ratio: input.compressionRatio ?? 0.5,
50
+ preserve_recent: input.preserveRecent ?? 2,
51
+ model: input.model ?? "morph-compactor",
52
+ include_line_ranges: input.includeLineRanges ?? true,
53
+ include_markers: input.includeMarkers ?? true
54
+ };
55
+ if (input.query !== void 0) body.query = input.query;
56
+ if (input.messages) body.messages = input.messages;
57
+ else if (typeof input.input === "string") body.input = input.input;
58
+ else if (Array.isArray(input.input)) body.messages = input.input;
59
+ else throw new Error("Either 'input' or 'messages' must be provided");
60
+ try {
61
+ return await this._client.post("/v1/compact", { body, timeout: this.config.timeout });
62
+ } catch (err) {
63
+ if (err instanceof chunkOM5ZSXQW_cjs.MorphError) {
64
+ throw new Error(`Compact API error ${err.statusCode}: ${err.message}`);
65
+ }
66
+ throw err;
67
+ }
68
+ }
69
+ };
70
+
71
+ exports.CompactClient = CompactClient;
@@ -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-3CPI6ZIC.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/openai.ts
20
5
  var TOOL_PARAMETERS = {
@@ -96,11 +81,4 @@ function createGitHubReadFileTool(config) {
96
81
  }
97
82
  var openai_default = warpGrepTool;
98
83
 
99
- export {
100
- warpGrepTool,
101
- execute,
102
- createWarpGrepTool,
103
- createGitHubSearchTool,
104
- createGitHubReadFileTool,
105
- openai_default
106
- };
84
+ export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, execute, openai_default, warpGrepTool };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // core/resource.ts
4
+ var APIResource = class {
5
+ _client;
6
+ constructor(client) {
7
+ this._client = client;
8
+ }
9
+ };
10
+
11
+ exports.APIResource = APIResource;
@@ -1,52 +1,17 @@
1
- import {
2
- createGitHubSearchTool,
3
- createWarpGrepTool
4
- } from "./chunk-2XU3XXUE.js";
5
- import {
6
- createGitHubSearchTool as createGitHubSearchTool3,
7
- createWarpGrepTool as createWarpGrepTool3
8
- } from "./chunk-NFPRKZQ5.js";
9
- import {
10
- createGitHubSearchTool as createGitHubSearchTool2,
11
- createWarpGrepTool as createWarpGrepTool2
12
- } from "./chunk-SIFDK4AA.js";
13
- import {
14
- createEditFileTool
15
- } from "./chunk-CAWQEHKP.js";
16
- import {
17
- createEditFileTool as createEditFileTool3
18
- } from "./chunk-PDSIWL7I.js";
19
- import {
20
- createEditFileTool as createEditFileTool2
21
- } from "./chunk-26K5EJD3.js";
22
- import {
23
- FastApplyClient
24
- } from "./chunk-65TUD7JV.js";
25
- import {
26
- createExploreSubagent
27
- } from "./chunk-XPHNS7NW.js";
28
- import {
29
- createExploreSubagent as createExploreSubagent2
30
- } from "./chunk-UAZKHSEU.js";
31
- import {
32
- WarpGrepClient
33
- } from "./chunk-3CPI6ZIC.js";
34
- import {
35
- AnthropicRouter,
36
- GeminiRouter,
37
- OpenAIRouter,
38
- RawRouter,
39
- RouterClassifier
40
- } from "./chunk-6OYJC4TZ.js";
41
- import {
42
- CompactClient
43
- } from "./chunk-D6YJ5X3C.js";
44
- import {
45
- MorphAPIClient
46
- } from "./chunk-ICCGLO6V.js";
47
- import {
48
- logger
49
- } from "./chunk-6WP7EA4F.js";
1
+ import { createWarpGrepTool, createGitHubSearchTool } from './chunk-AJBZA23L.js';
2
+ import { createWarpGrepTool as createWarpGrepTool$2, createGitHubSearchTool as createGitHubSearchTool$2 } from './chunk-JY6COF3X.js';
3
+ import { createWarpGrepTool as createWarpGrepTool$1, createGitHubSearchTool as createGitHubSearchTool$1 } from './chunk-2UIOCSVJ.js';
4
+ import { createEditFileTool } from './chunk-GDFPZ3NJ.js';
5
+ import { createEditFileTool as createEditFileTool$2 } from './chunk-NLACTMZT.js';
6
+ import { createEditFileTool as createEditFileTool$1 } from './chunk-J56Q6C4Y.js';
7
+ import { FastApplyClient } from './chunk-LLQH6CCB.js';
8
+ import { createExploreSubagent } from './chunk-IUM6CQYX.js';
9
+ import { createExploreSubagent as createExploreSubagent$1 } from './chunk-E3XNKAMI.js';
10
+ import { WarpGrepClient } from './chunk-66THRMD7.js';
11
+ import { RouterClassifier, RawRouter, GeminiRouter, AnthropicRouter, OpenAIRouter } from './chunk-EZ2OFDBJ.js';
12
+ import { CompactClient } from './chunk-H3HRSRR5.js';
13
+ import { MorphAPIClient } from './chunk-KLVJIC2O.js';
14
+ import { logger } from './chunk-6WP7EA4F.js';
50
15
 
51
16
  // factories/openai.ts
52
17
  var OpenAIToolFactory = class {
@@ -103,7 +68,7 @@ var AnthropicToolFactory = class {
103
68
  * @returns Anthropic Tool with execute and formatResult methods
104
69
  */
105
70
  createWarpGrepTool(toolConfig) {
106
- return createWarpGrepTool2({
71
+ return createWarpGrepTool$1({
107
72
  ...toolConfig,
108
73
  morphApiKey: this.config.apiKey
109
74
  });
@@ -115,7 +80,7 @@ var AnthropicToolFactory = class {
115
80
  * @returns Anthropic Tool with execute and formatResult methods
116
81
  */
117
82
  createEditFileTool(toolConfig = {}) {
118
- return createEditFileTool2({
83
+ return createEditFileTool$1({
119
84
  ...toolConfig,
120
85
  morphApiKey: this.config.apiKey
121
86
  });
@@ -127,7 +92,7 @@ var AnthropicToolFactory = class {
127
92
  * @returns Anthropic Tool with execute and formatResult methods
128
93
  */
129
94
  createGitHubSearchTool(toolConfig) {
130
- return createGitHubSearchTool2({
95
+ return createGitHubSearchTool$1({
131
96
  ...toolConfig,
132
97
  morphApiKey: this.config.apiKey
133
98
  });
@@ -158,7 +123,7 @@ var VercelToolFactory = class {
158
123
  * @returns Vercel AI SDK tool
159
124
  */
160
125
  createWarpGrepTool(toolConfig) {
161
- return createWarpGrepTool3({
126
+ return createWarpGrepTool$2({
162
127
  ...toolConfig,
163
128
  morphApiKey: this.config.apiKey
164
129
  });
@@ -170,7 +135,7 @@ var VercelToolFactory = class {
170
135
  * @returns Vercel AI SDK tool
171
136
  */
172
137
  createEditFileTool(toolConfig = {}) {
173
- return createEditFileTool3({
138
+ return createEditFileTool$2({
174
139
  ...toolConfig,
175
140
  morphApiKey: this.config.apiKey
176
141
  });
@@ -182,7 +147,7 @@ var VercelToolFactory = class {
182
147
  * @returns Vercel AI SDK tool
183
148
  */
184
149
  createGitHubSearchTool(toolConfig) {
185
- return createGitHubSearchTool3({
150
+ return createGitHubSearchTool$2({
186
151
  ...toolConfig,
187
152
  morphApiKey: this.config.apiKey
188
153
  });
@@ -194,7 +159,7 @@ var VercelToolFactory = class {
194
159
  * @returns Explore subagent with .tool, .run(), and .stream() methods
195
160
  */
196
161
  createExploreSubagent(config) {
197
- return createExploreSubagent2({
162
+ return createExploreSubagent$1({
198
163
  ...config,
199
164
  morphApiKey: this.config.apiKey
200
165
  });
@@ -262,9 +227,4 @@ var MorphClient = class extends MorphAPIClient {
262
227
  }
263
228
  };
264
229
 
265
- export {
266
- OpenAIToolFactory,
267
- AnthropicToolFactory,
268
- VercelToolFactory,
269
- MorphClient
270
- };
230
+ export { AnthropicToolFactory, MorphClient, OpenAIToolFactory, VercelToolFactory };
@@ -0,0 +1,256 @@
1
+ 'use strict';
2
+
3
+ var chunkUUCRWJJR_cjs = require('./chunk-UUCRWJJR.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 chunkUUCRWJJR_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 chunkUUCRWJJR_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,2 @@
1
+ 'use strict';
2
+
@@ -1,16 +1,8 @@
1
- import {
2
- WarpGrepClient,
3
- formatResult
4
- } from "./chunk-3CPI6ZIC.js";
5
- import {
6
- CODEBASE_SEARCH_TOOL,
7
- SEND_MESSAGE_TOOL,
8
- getSystemPrompt
9
- } from "./chunk-ETBRAKVV.js";
1
+ import { WarpGrepClient, formatResult } from './chunk-66THRMD7.js';
2
+ import { SEND_MESSAGE_TOOL, CODEBASE_SEARCH_TOOL, getSystemPrompt } from './chunk-ETBRAKVV.js';
3
+ import { tool, generateText, stepCountIs } from 'ai';
4
+ import { z } from 'zod';
10
5
 
11
- // subagents/vercel.ts
12
- import { tool, generateText, stepCountIs } from "ai";
13
- import { z } from "zod";
14
6
  var DEFAULT_MAX_TURNS = {
15
7
  quick: 3,
16
8
  medium: 6,
@@ -259,6 +251,4 @@ function deduplicateContexts(contexts) {
259
251
  return Array.from(map.values());
260
252
  }
261
253
 
262
- export {
263
- createExploreSubagent
264
- };
254
+ export { createExploreSubagent };