@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
@@ -0,0 +1,168 @@
1
+ 'use strict';
2
+
3
+ var chunk65W4I66Q_cjs = require('./chunk-65W4I66Q.cjs');
4
+ var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
5
+ var chunkOM5ZSXQW_cjs = require('./chunk-OM5ZSXQW.cjs');
6
+ var chunkAWFZKS27_cjs = require('./chunk-AWFZKS27.cjs');
7
+
8
+ // modelrouter/core.ts
9
+ var DEFAULT_API_URL = "https://api.morphllm.com";
10
+ var DEFAULT_TIMEOUT = 5e3;
11
+ function resolveClient(clientOrConfig) {
12
+ if (clientOrConfig instanceof chunk65W4I66Q_cjs.MorphAPIClient) return clientOrConfig;
13
+ return new chunk65W4I66Q_cjs.MorphAPIClient({
14
+ apiKey: clientOrConfig.apiKey,
15
+ baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
16
+ timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
17
+ retryConfig: clientOrConfig.retryConfig,
18
+ debug: clientOrConfig.debug
19
+ });
20
+ }
21
+ var BaseRouter = class extends chunkAWFZKS27_cjs.APIResource {
22
+ provider;
23
+ timeout;
24
+ constructor(provider, clientOrConfig = {}) {
25
+ super(resolveClient(clientOrConfig));
26
+ this.provider = provider;
27
+ const cfg = clientOrConfig instanceof chunk65W4I66Q_cjs.MorphAPIClient ? {} : clientOrConfig;
28
+ this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;
29
+ }
30
+ /** Throw the historical "API key is required" message when no key is resolvable. */
31
+ requireApiKey() {
32
+ if (!this._client.resolveApiKey()) {
33
+ throw new Error(
34
+ "Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
35
+ );
36
+ }
37
+ }
38
+ /** POST to the router and surface failures as `Router API error (<status>): ...`. */
39
+ async route(provider, input) {
40
+ try {
41
+ return await this._client.post(`/v1/router/${provider}`, {
42
+ body: { input: input.input, mode: input.mode || "balanced" },
43
+ timeout: this.timeout
44
+ });
45
+ } catch (error) {
46
+ if (error instanceof chunkOM5ZSXQW_cjs.MorphError) {
47
+ throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
48
+ }
49
+ throw error;
50
+ }
51
+ }
52
+ /**
53
+ * Select the optimal model for a given input and mode
54
+ */
55
+ async selectModel(input) {
56
+ this.requireApiKey();
57
+ chunkVL4QNALG_cjs.logger.debug("ModelRouter", "request", { provider: this.provider, mode: input.mode || "balanced" });
58
+ const apiResult = await this.route(this.provider, input);
59
+ chunkVL4QNALG_cjs.logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model });
60
+ return { model: apiResult.model };
61
+ }
62
+ };
63
+ var OpenAIRouter = class extends BaseRouter {
64
+ constructor(clientOrConfig = {}) {
65
+ super("openai", clientOrConfig);
66
+ }
67
+ /**
68
+ * Select optimal GPT-5 model
69
+ *
70
+ * @param input - User input and mode
71
+ * @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)
72
+ */
73
+ async selectModel(input) {
74
+ return super.selectModel(input);
75
+ }
76
+ };
77
+ var AnthropicRouter = class extends BaseRouter {
78
+ constructor(clientOrConfig = {}) {
79
+ super("anthropic", clientOrConfig);
80
+ }
81
+ /**
82
+ * Select optimal Claude model
83
+ *
84
+ * @param input - User input and mode
85
+ * @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)
86
+ */
87
+ async selectModel(input) {
88
+ return super.selectModel(input);
89
+ }
90
+ };
91
+ var GeminiRouter = class extends BaseRouter {
92
+ constructor(clientOrConfig = {}) {
93
+ super("gemini", clientOrConfig);
94
+ }
95
+ /**
96
+ * Select optimal Gemini model
97
+ *
98
+ * @param input - User input and mode
99
+ * @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)
100
+ */
101
+ async selectModel(input) {
102
+ return super.selectModel(input);
103
+ }
104
+ };
105
+ var RawRouter = class extends BaseRouter {
106
+ constructor(clientOrConfig = {}) {
107
+ super("raw", clientOrConfig);
108
+ }
109
+ /**
110
+ * Get raw difficulty classification
111
+ *
112
+ * @param input - User input and mode
113
+ * @returns Raw difficulty (easy | medium | hard | needs_info)
114
+ */
115
+ async classify(input) {
116
+ this.requireApiKey();
117
+ chunkVL4QNALG_cjs.logger.debug("RawRouter", "request", { mode: input.mode || "balanced" });
118
+ const apiResult = await this.route("raw", input);
119
+ let difficulty;
120
+ if (apiResult.difficulty === "") {
121
+ difficulty = "medium";
122
+ } else {
123
+ difficulty = apiResult.difficulty || apiResult.model;
124
+ }
125
+ chunkVL4QNALG_cjs.logger.debug("RawRouter", "classified", { difficulty });
126
+ return { difficulty };
127
+ }
128
+ };
129
+ var RouterClassifier = class extends chunkAWFZKS27_cjs.APIResource {
130
+ timeout;
131
+ constructor(clientOrConfig = {}) {
132
+ super(resolveClient(clientOrConfig));
133
+ const cfg = clientOrConfig instanceof chunk65W4I66Q_cjs.MorphAPIClient ? {} : clientOrConfig;
134
+ this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;
135
+ }
136
+ /** Classify an input across the requested axes (all three by default). */
137
+ async classify(input) {
138
+ if (!this._client.resolveApiKey()) {
139
+ throw new Error(
140
+ "Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
141
+ );
142
+ }
143
+ chunkVL4QNALG_cjs.logger.debug("RouterClassifier", "request", { classes: input.classes ?? "all" });
144
+ try {
145
+ const res = await this._client.post("/v1/router/classify", {
146
+ body: { input: input.input, ...input.classes ? { classes: input.classes } : {} },
147
+ timeout: this.timeout
148
+ });
149
+ chunkVL4QNALG_cjs.logger.debug("RouterClassifier", "classified", {
150
+ difficulty: res.classifications.difficulty?.label,
151
+ ambiguity: res.classifications.ambiguity?.label,
152
+ domain: res.classifications.domain?.label
153
+ });
154
+ return res.classifications;
155
+ } catch (error) {
156
+ if (error instanceof chunkOM5ZSXQW_cjs.MorphError) {
157
+ throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
158
+ }
159
+ throw error;
160
+ }
161
+ }
162
+ };
163
+
164
+ exports.AnthropicRouter = AnthropicRouter;
165
+ exports.GeminiRouter = GeminiRouter;
166
+ exports.OpenAIRouter = OpenAIRouter;
167
+ exports.RawRouter = RawRouter;
168
+ exports.RouterClassifier = RouterClassifier;
@@ -1,13 +1,7 @@
1
- import {
2
- logger
3
- } from "./chunk-6WP7EA4F.js";
4
- import {
5
- SDK_VERSION
6
- } from "./chunk-UZCXOOZO.js";
7
-
8
- // tools/fastapply/apply.ts
9
- import { createTwoFilesPatch } from "diff";
10
- import OpenAI from "openai";
1
+ import { logger } from './chunk-6WP7EA4F.js';
2
+ import { SDK_VERSION } from './chunk-OCCGJ4S6.js';
3
+ import { createTwoFilesPatch } from 'diff';
4
+ import OpenAI from 'openai';
11
5
 
12
6
  // tools/fastapply/anchors.ts
13
7
  var DEFAULT_MIN_ANCHOR_LINE_LENGTH = 24;
@@ -255,7 +249,7 @@ async function callMorphAPI(originalCode, codeEdit, instructions, filepath, conf
255
249
  const useLarge = config.large ?? (typeof process !== "undefined" ? process.env?.MORPH_LARGE_APPLY !== "false" : true);
256
250
  const model = useLarge ? "morph-v3-large" : "morph-v3-fast";
257
251
  const timeout = config.timeout ?? DEFAULT_TIMEOUT;
258
- const debug = config.debug || false;
252
+ config.debug || false;
259
253
  if (!apiKey) {
260
254
  throw new Error(
261
255
  "Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config."
@@ -388,11 +382,4 @@ async function applyEdit(input, config = {}) {
388
382
  }
389
383
  }
390
384
 
391
- export {
392
- FastApplyAnchorIntegrityError,
393
- FastApplyContextLengthError,
394
- generateUdiff,
395
- countChanges,
396
- callMorphAPI,
397
- applyEdit
398
- };
385
+ export { FastApplyAnchorIntegrityError, FastApplyContextLengthError, applyEdit, callMorphAPI, countChanges, generateUdiff };
@@ -1,18 +1,8 @@
1
- import {
2
- GITHUB_READ_FILE_DESCRIPTION,
3
- GITHUB_SEARCH_DESCRIPTION,
4
- WARP_GREP_DESCRIPTION
5
- } from "./chunk-UAPK3AIJ.js";
6
- import {
7
- WarpGrepClient,
8
- executeGitHubReadFile,
9
- executeToolCall,
10
- executeToolCallStreaming
11
- } from "./chunk-WBTXEJOC.js";
1
+ import { WARP_GREP_DESCRIPTION, GITHUB_SEARCH_DESCRIPTION, GITHUB_READ_FILE_DESCRIPTION } from './chunk-UAPK3AIJ.js';
2
+ import { executeToolCall, executeToolCallStreaming, WarpGrepClient, executeGitHubReadFile } from './chunk-66THRMD7.js';
3
+ import { tool } from 'ai';
4
+ import { z } from 'zod';
12
5
 
13
- // tools/warp_grep/vercel.ts
14
- import { tool } from "ai";
15
- import { z } from "zod";
16
6
  var warpGrepJsonSchema = {
17
7
  type: "object",
18
8
  properties: {
@@ -107,11 +97,4 @@ function createGitHubReadFileTool(config) {
107
97
  }
108
98
  var vercel_default = createWarpGrepTool;
109
99
 
110
- export {
111
- warpGrepJsonSchema,
112
- execute,
113
- createWarpGrepTool,
114
- createGitHubSearchTool,
115
- createGitHubReadFileTool,
116
- vercel_default
117
- };
100
+ export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, execute, vercel_default, warpGrepJsonSchema };
@@ -1,17 +1,7 @@
1
- import {
2
- logger
3
- } from "./chunk-6WP7EA4F.js";
4
- import {
5
- toMorphError
6
- } from "./chunk-EQAWWVKV.js";
7
- import {
8
- MorphError,
9
- fetchWithRetry,
10
- withTimeout
11
- } from "./chunk-TS3OJ4LA.js";
12
- import {
13
- SDK_VERSION
14
- } from "./chunk-UZCXOOZO.js";
1
+ import { logger } from './chunk-6WP7EA4F.js';
2
+ import { toMorphError } from './chunk-EI2M567U.js';
3
+ import { MorphError, withTimeout, fetchWithRetry } from './chunk-E7FLETFO.js';
4
+ import { SDK_VERSION } from './chunk-OCCGJ4S6.js';
15
5
 
16
6
  // core/client.ts
17
7
  var DEFAULT_BASE_URL = "https://api.morphllm.com";
@@ -108,6 +98,4 @@ var MorphAPIClient = class {
108
98
  }
109
99
  };
110
100
 
111
- export {
112
- MorphAPIClient
113
- };
101
+ export { MorphAPIClient };
@@ -0,0 +1,91 @@
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/openai.ts
7
+ var TOOL_PARAMETERS = {
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
+ type: "function",
16
+ function: {
17
+ name: chunkEJTL2BOZ_cjs.WARP_GREP_TOOL_NAME,
18
+ description: chunkEJTL2BOZ_cjs.WARP_GREP_DESCRIPTION,
19
+ parameters: TOOL_PARAMETERS
20
+ }
21
+ };
22
+ async function execute(input, config) {
23
+ return chunkUUCRWJJR_cjs.executeToolCall(input, config);
24
+ }
25
+ function createWarpGrepTool(config) {
26
+ const tool = {
27
+ type: "function",
28
+ function: {
29
+ name: config.name ?? chunkEJTL2BOZ_cjs.WARP_GREP_TOOL_NAME,
30
+ description: config.description ?? chunkEJTL2BOZ_cjs.WARP_GREP_DESCRIPTION,
31
+ parameters: TOOL_PARAMETERS
32
+ }
33
+ };
34
+ return Object.assign(tool, {
35
+ execute: async (input) => {
36
+ return chunkUUCRWJJR_cjs.executeToolCall(input, config);
37
+ },
38
+ formatResult: (result) => {
39
+ return chunkUUCRWJJR_cjs.formatResult(result);
40
+ }
41
+ });
42
+ }
43
+ function createGitHubSearchTool(config) {
44
+ const client = new chunkUUCRWJJR_cjs.WarpGrepClient(config);
45
+ const tool = {
46
+ type: "function",
47
+ function: {
48
+ name: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_TOOL_NAME,
49
+ description: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_DESCRIPTION,
50
+ parameters: chunkEJTL2BOZ_cjs.GITHUB_SEARCH_INPUT_SCHEMA
51
+ }
52
+ };
53
+ return Object.assign(tool, {
54
+ execute: async (input) => {
55
+ const github = input.github_url || input.owner_repo;
56
+ if (!github) {
57
+ throw new Error("Please provide github search url or owner/repo id");
58
+ }
59
+ return client.searchGitHub({ searchTerm: input.search_term, github, branch: input.branch });
60
+ },
61
+ formatResult: (result) => {
62
+ return chunkUUCRWJJR_cjs.formatResult(result);
63
+ }
64
+ });
65
+ }
66
+ function createGitHubReadFileTool(config) {
67
+ const tool = {
68
+ type: "function",
69
+ function: {
70
+ name: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_TOOL_NAME,
71
+ description: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_DESCRIPTION,
72
+ parameters: chunkEJTL2BOZ_cjs.GITHUB_READ_FILE_INPUT_SCHEMA
73
+ }
74
+ };
75
+ return Object.assign(tool, {
76
+ execute: async (input) => {
77
+ return chunkUUCRWJJR_cjs.executeGitHubReadFile(input, config);
78
+ },
79
+ formatResult: (result) => {
80
+ return chunkUUCRWJJR_cjs.formatGitHubReadFileResult(result);
81
+ }
82
+ });
83
+ }
84
+ var openai_default = warpGrepTool;
85
+
86
+ exports.createGitHubReadFileTool = createGitHubReadFileTool;
87
+ exports.createGitHubSearchTool = createGitHubSearchTool;
88
+ exports.createWarpGrepTool = createWarpGrepTool;
89
+ exports.execute = execute;
90
+ exports.openai_default = openai_default;
91
+ exports.warpGrepTool = warpGrepTool;
@@ -0,0 +1,274 @@
1
+ 'use strict';
2
+
3
+ var chunk4EQQGUZ7_cjs = require('./chunk-4EQQGUZ7.cjs');
4
+ var path = require('path');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var path__default = /*#__PURE__*/_interopDefault(path);
9
+
10
+ // tools/warp_grep/agent/tools/grep.ts
11
+ async function toolGrep(provider, args) {
12
+ const res = await provider.grep(args);
13
+ if (res.error) {
14
+ return { output: res.error };
15
+ }
16
+ if (!res.lines.length) {
17
+ return { output: "no matches" };
18
+ }
19
+ return { output: res.lines.join("\n") };
20
+ }
21
+
22
+ // tools/warp_grep/agent/tools/read.ts
23
+ function isValidRange(start, end) {
24
+ return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
25
+ }
26
+ async function toolRead(provider, args) {
27
+ if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
28
+ const validRanges = [];
29
+ for (const range of args.lines) {
30
+ if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
31
+ validRanges.push([range[0], range[1]]);
32
+ }
33
+ }
34
+ if (validRanges.length === 0) {
35
+ const res2 = await provider.read({ path: args.path });
36
+ if (res2.error) return res2.error;
37
+ if (!res2.lines.length) return "(empty file)";
38
+ return res2.lines.join("\n");
39
+ }
40
+ const chunks = [];
41
+ for (const [start, end] of validRanges) {
42
+ const res2 = await provider.read({ path: args.path, start, end });
43
+ if (res2.error) return res2.error;
44
+ chunks.push(res2.lines.join("\n"));
45
+ }
46
+ if (chunks.every((c) => c === "")) return "(empty file)";
47
+ return chunks.join("\n...\n");
48
+ }
49
+ const res = await provider.read({ path: args.path, start: args.start, end: args.end });
50
+ if (res.error) {
51
+ return res.error;
52
+ }
53
+ if (!res.lines.length) return "(empty file)";
54
+ return res.lines.join("\n");
55
+ }
56
+ async function toolListDirectory(provider, args, repoRoot) {
57
+ const maxResults = args.maxResults ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_LIST_RESULTS;
58
+ const maxDepth = args.maxDepth ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_LIST_DEPTH;
59
+ const entries = await provider.listDirectory({
60
+ path: args.path,
61
+ pattern: args.pattern ?? null,
62
+ maxResults,
63
+ maxDepth
64
+ });
65
+ if (!entries.length) return "empty";
66
+ if (repoRoot) {
67
+ const absRoot = repoRoot;
68
+ const lines = entries.map((e) => path__default.default.join(absRoot, e.path));
69
+ return lines.join("\n");
70
+ }
71
+ return entries.map((e) => e.path).join("\n");
72
+ }
73
+
74
+ // tools/warp_grep/agent/tools/glob.ts
75
+ async function toolGlob(provider, args) {
76
+ const res = await provider.glob(args);
77
+ if (res.error) {
78
+ return res.error;
79
+ }
80
+ if (!res.files.length) {
81
+ return "no matches";
82
+ }
83
+ const header = `Found ${res.totalFound} file(s) matching "${args.pattern}" within ${res.searchDir}, sorted by modification time (newest first):`;
84
+ const body = res.files.join("\n");
85
+ const truncated = res.totalFound > res.files.length ? `
86
+ [${res.totalFound - res.files.length} files truncated]` : "";
87
+ return `${header}
88
+ ---
89
+ ${body}
90
+ ---${truncated}`;
91
+ }
92
+
93
+ // tools/warp_grep/agent/tools/finish.ts
94
+ function isValidRange2(range) {
95
+ return Array.isArray(range) && range.length >= 2 && typeof range[0] === "number" && typeof range[1] === "number" && Number.isFinite(range[0]) && Number.isFinite(range[1]) && range[0] > 0 && range[1] >= range[0];
96
+ }
97
+ function extractValidRanges(lines) {
98
+ if (!Array.isArray(lines)) return null;
99
+ const valid = [];
100
+ for (const range of lines) {
101
+ if (isValidRange2(range)) {
102
+ valid.push([range[0], range[1]]);
103
+ }
104
+ }
105
+ return valid.length > 0 ? valid : null;
106
+ }
107
+ function normalizeFinishFiles(files) {
108
+ return files.map((f) => {
109
+ if (f.lines === "*") return { path: f.path, lines: "*" };
110
+ const validRanges = extractValidRanges(f.lines);
111
+ if (!validRanges) return { path: f.path, lines: "*" };
112
+ return { path: f.path, lines: mergeRanges(validRanges) };
113
+ });
114
+ }
115
+ async function readFinishFiles(repoRoot, files, reader) {
116
+ const out = [];
117
+ for (const f of files) {
118
+ const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
119
+ if (f.lines === "*" || !validRanges) {
120
+ const lines = await reader(f.path);
121
+ out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
122
+ } else {
123
+ const ranges = mergeRanges(validRanges);
124
+ const chunks = [];
125
+ for (let i = 0; i < ranges.length; i++) {
126
+ const [s, e] = ranges[i];
127
+ if (i === 0 && s > 1) {
128
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
129
+ } else if (i > 0) {
130
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
131
+ }
132
+ const lines = await reader(f.path, s, e);
133
+ chunks.push(lines.join("\n"));
134
+ }
135
+ out.push({ path: f.path, ranges, content: chunks.join("\n") });
136
+ }
137
+ }
138
+ return out;
139
+ }
140
+ function mergeRanges(ranges) {
141
+ if (!ranges.length) return [];
142
+ const sorted = [...ranges].sort((a, b) => a[0] - b[0]);
143
+ const merged = [];
144
+ let [cs, ce] = sorted[0];
145
+ for (let i = 1; i < sorted.length; i++) {
146
+ const [s, e] = sorted[i];
147
+ if (s <= ce + 1) {
148
+ ce = Math.max(ce, e);
149
+ } else {
150
+ merged.push([cs, ce]);
151
+ cs = s;
152
+ ce = e;
153
+ }
154
+ }
155
+ merged.push([cs, ce]);
156
+ return merged;
157
+ }
158
+ var TRUNCATED_MARKER = "[truncated for context limit]";
159
+ function getMessageSize(m) {
160
+ if (m.role === "tool") return m.content.length;
161
+ if (m.role === "assistant") {
162
+ let size = typeof m.content === "string" ? m.content.length : 0;
163
+ if (m.tool_calls) {
164
+ size += m.tool_calls.reduce((s, tc) => s + tc.function.name.length + tc.function.arguments.length, 0);
165
+ }
166
+ return size;
167
+ }
168
+ return m.content.length;
169
+ }
170
+ function formatTurnMessage(turnsUsed, maxTurns) {
171
+ const turnsRemaining = maxTurns - turnsUsed;
172
+ if (turnsRemaining === 1) {
173
+ return `
174
+ You have used ${turnsUsed} turns, you only have 1 turn remaining. You have run out of turns to explore the code base and MUST call the finish tool now`;
175
+ }
176
+ return `
177
+ You have used ${turnsUsed} turn${turnsUsed === 1 ? "" : "s"} and have ${turnsRemaining} remaining`;
178
+ }
179
+ function calculateContextBudget(messages) {
180
+ const totalChars = messages.reduce((sum, m) => sum + getMessageSize(m), 0);
181
+ const maxChars = chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_CONTEXT_CHARS;
182
+ const percent = Math.floor(totalChars / maxChars * 100);
183
+ const usedK = Math.floor(totalChars / 1e3);
184
+ const maxK = Math.floor(maxChars / 1e3);
185
+ return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
186
+ }
187
+ async function buildInitialState(repoRoot, searchTerm, provider, options) {
188
+ const budget = calculateContextBudget([]);
189
+ const turnTag = `You have used 0 turns and have ${chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_TURNS} remaining`;
190
+ const treeDepth = options?.search_type === "node_modules" ? 1 : 2;
191
+ const absRoot = repoRoot;
192
+ try {
193
+ const entries = await provider.listDirectory({
194
+ path: ".",
195
+ maxResults: chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES,
196
+ maxDepth: treeDepth
197
+ });
198
+ const lines = [absRoot];
199
+ for (const e of entries) {
200
+ lines.push(path__default.default.join(absRoot, e.path));
201
+ }
202
+ return `<repo_structure>
203
+ ${lines.join("\n")}
204
+ </repo_structure>
205
+
206
+ <search_string>
207
+ ${searchTerm}
208
+ </search_string>
209
+ ${budget}
210
+ ${turnTag}`;
211
+ } catch {
212
+ return `<repo_structure>
213
+ ${absRoot}
214
+ </repo_structure>
215
+
216
+ <search_string>
217
+ ${searchTerm}
218
+ </search_string>
219
+ ${budget}
220
+ ${turnTag}`;
221
+ }
222
+ }
223
+ function formatListDirectoryTree(entries) {
224
+ if (!entries.length) return "empty";
225
+ return entries.map((e) => {
226
+ const indent = " ".repeat(e.depth);
227
+ const name = e.type === "dir" ? `${e.name}/` : e.name;
228
+ return `${indent}${name}`;
229
+ }).join("\n");
230
+ }
231
+ function enforceContextLimit(messages, maxChars = chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_CONTEXT_CHARS) {
232
+ const getTotalChars = () => messages.reduce((sum, m) => sum + getMessageSize(m), 0);
233
+ if (getTotalChars() <= maxChars) {
234
+ return messages;
235
+ }
236
+ const truncatableIndices = [];
237
+ let firstUserSkipped = false;
238
+ for (let i = 0; i < messages.length; i++) {
239
+ const m = messages[i];
240
+ if (m.role === "tool") {
241
+ truncatableIndices.push(i);
242
+ } else if (m.role === "user") {
243
+ if (!firstUserSkipped) {
244
+ firstUserSkipped = true;
245
+ continue;
246
+ }
247
+ truncatableIndices.push(i);
248
+ }
249
+ }
250
+ for (const idx of truncatableIndices) {
251
+ if (getTotalChars() <= maxChars) {
252
+ break;
253
+ }
254
+ const m = messages[idx];
255
+ if (m.role === "tool" && m.content !== TRUNCATED_MARKER) {
256
+ messages[idx] = { role: "tool", tool_call_id: m.tool_call_id, content: TRUNCATED_MARKER };
257
+ } else if (m.role === "user" && m.content !== TRUNCATED_MARKER) {
258
+ messages[idx] = { role: "user", content: TRUNCATED_MARKER };
259
+ }
260
+ }
261
+ return messages;
262
+ }
263
+
264
+ exports.buildInitialState = buildInitialState;
265
+ exports.calculateContextBudget = calculateContextBudget;
266
+ exports.enforceContextLimit = enforceContextLimit;
267
+ exports.formatListDirectoryTree = formatListDirectoryTree;
268
+ exports.formatTurnMessage = formatTurnMessage;
269
+ exports.normalizeFinishFiles = normalizeFinishFiles;
270
+ exports.readFinishFiles = readFinishFiles;
271
+ exports.toolGlob = toolGlob;
272
+ exports.toolGrep = toolGrep;
273
+ exports.toolListDirectory = toolListDirectory;
274
+ exports.toolRead = toolRead;
@@ -0,0 +1 @@
1
+