@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.
- package/dist/chunk-2PPYWRMZ.js +3 -4
- package/dist/{chunk-DBNSOYQ3.js → chunk-2UIOCSVJ.js} +3 -24
- package/dist/chunk-44OIEPIO.js +4 -23
- package/dist/chunk-4EQQGUZ7.cjs +104 -0
- package/dist/chunk-4OUGA3KS.js +1 -5
- package/dist/chunk-4R5MDGL6.cjs +280 -0
- package/dist/chunk-65W4I66Q.cjs +103 -0
- package/dist/{chunk-WBTXEJOC.js → chunk-66THRMD7.js} +10 -35
- package/dist/chunk-6TZCVTW5.js +3 -4
- package/dist/chunk-6WP7EA4F.js +2 -4
- package/dist/chunk-74A4HLIO.cjs +42 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-7NA7X7W2.cjs +77 -0
- package/dist/chunk-7PJYY46L.cjs +2 -0
- package/dist/chunk-AFF6XYKL.cjs +71 -0
- package/dist/{chunk-P2KW2O5R.js → chunk-AJBZA23L.js} +3 -25
- package/dist/chunk-AWFZKS27.cjs +11 -0
- package/dist/{chunk-FVT4PU4I.js → chunk-AXEKIRRY.js} +22 -62
- package/dist/chunk-B3FD67F2.cjs +256 -0
- package/dist/chunk-BJBWWIZV.cjs +2 -0
- package/dist/{chunk-M6AVXUM4.js → chunk-E3XNKAMI.js} +5 -15
- package/dist/{chunk-TS3OJ4LA.js → chunk-E7FLETFO.js} +2 -8
- package/dist/{chunk-EQAWWVKV.js → chunk-EI2M567U.js} +2 -6
- package/dist/chunk-EJTL2BOZ.cjs +42 -0
- package/dist/chunk-ETBRAKVV.js +1 -5
- package/dist/{chunk-VOXUA5ZH.js → chunk-EZ2OFDBJ.js} +5 -19
- package/dist/chunk-FBOZIVVQ.js +1 -0
- package/dist/{chunk-TZC3EOZS.js → chunk-GDFPZ3NJ.js} +4 -19
- package/dist/{chunk-LISSWRUD.js → chunk-GIQAIHUI.js} +8 -33
- package/dist/chunk-GSUQGDCL.cjs +235 -0
- package/dist/{chunk-5NSYDT36.js → chunk-H3HRSRR5.js} +4 -12
- package/dist/chunk-HDP4QAZL.js +1 -4
- package/dist/chunk-HMLYJVZM.cjs +410 -0
- package/dist/chunk-IPJA3ZS6.cjs +10 -0
- package/dist/{chunk-B376VMIH.js → chunk-IUM6CQYX.js} +3 -12
- package/dist/{chunk-OVLUL5AC.js → chunk-J56Q6C4Y.js} +4 -18
- package/dist/chunk-JBTR3FQD.cjs +135 -0
- package/dist/chunk-JNQKQKHS.cjs +81 -0
- package/dist/chunk-JOZC4T6C.cjs +168 -0
- package/dist/{chunk-ILY5N5NJ.js → chunk-JUGNTIVU.js} +6 -19
- package/dist/{chunk-SU7AAS3O.js → chunk-JY6COF3X.js} +5 -22
- package/dist/{chunk-JBAY3PRV.js → chunk-KLVJIC2O.js} +5 -17
- package/dist/chunk-KSZYOX6S.cjs +91 -0
- package/dist/chunk-KVGZ2TSG.cjs +274 -0
- package/dist/chunk-LDM7RNNN.js +1 -0
- package/dist/{chunk-RZOJ4GSY.js → chunk-LLQH6CCB.js} +10 -28
- package/dist/chunk-M34E2AMK.js +1 -5
- package/dist/chunk-MF56KEI4.js +1 -4
- package/dist/chunk-MLKGABMK.js +1 -3
- package/dist/{chunk-I26FQELI.js → chunk-MLPZKUCO.js} +11 -5
- package/dist/chunk-MWXJ6DZ2.cjs +21 -0
- package/dist/{chunk-NWGRW4V7.js → chunk-N7UKZ5X7.js} +2 -6
- package/dist/chunk-NDUC7OV6.cjs +74 -0
- package/dist/{chunk-RJXAXR7Q.js → chunk-NLACTMZT.js} +6 -19
- package/dist/chunk-NNKBKENK.cjs +15 -0
- package/dist/chunk-NRG6QX3L.js +1 -3
- package/dist/chunk-OCCGJ4S6.js +8 -0
- package/dist/chunk-ODY2NKQU.cjs +50 -0
- package/dist/chunk-OM5ZSXQW.cjs +91 -0
- package/dist/chunk-OOEORM7H.cjs +334 -0
- package/dist/chunk-OPDWMD4Q.js +1 -3
- package/dist/{chunk-BZXOAC2R.js → chunk-OSL4CNSO.js} +7 -23
- package/dist/chunk-OXXMTDOY.cjs +86 -0
- package/dist/chunk-PA3UTI4A.js +1 -4
- package/dist/chunk-QEEAIXL5.cjs +74 -0
- package/dist/chunk-RYVW7RUM.js +2 -6
- package/dist/chunk-S6QBPXBI.cjs +107 -0
- package/dist/chunk-TL34BLQD.cjs +10 -0
- package/dist/chunk-TPZHMD7J.cjs +72 -0
- package/dist/chunk-UAPK3AIJ.js +1 -10
- package/dist/chunk-UF5IKELS.cjs +26 -0
- package/dist/chunk-UNX7V6P6.cjs +60 -0
- package/dist/chunk-UUCRWJJR.cjs +313 -0
- package/dist/chunk-VDFLPO7B.cjs +396 -0
- package/dist/chunk-VHD7CW5O.cjs +43 -0
- package/dist/chunk-VL4QNALG.cjs +50 -0
- package/dist/chunk-WR7LSUIR.cjs +213 -0
- package/dist/chunk-XE6D4J63.cjs +72 -0
- package/dist/chunk-ZLG2M2I4.cjs +21 -0
- package/dist/chunk-ZSHVXDA2.js +4 -10
- package/dist/client.cjs +40 -4353
- package/dist/client.js +32 -37
- package/dist/core/client.cjs +10 -476
- package/dist/core/client.js +6 -11
- package/dist/core/error.cjs +8 -251
- package/dist/core/error.js +4 -9
- package/dist/core/index.cjs +20 -488
- package/dist/core/index.js +8 -19
- package/dist/core/resource.cjs +9 -33
- package/dist/core/resource.js +2 -7
- package/dist/edge.cjs +62 -1111
- package/dist/edge.js +10 -42
- package/dist/index.cjs +115 -4424
- package/dist/index.js +39 -87
- package/dist/modelrouter/core.cjs +28 -648
- package/dist/modelrouter/core.js +8 -21
- package/dist/modelrouter/index.cjs +28 -648
- package/dist/modelrouter/index.js +8 -21
- package/dist/modelrouter/types.cjs +1 -17
- package/dist/modelrouter/types.js +1 -0
- package/dist/subagents/anthropic.cjs +27 -2777
- package/dist/subagents/anthropic.js +19 -24
- package/dist/subagents/index.cjs +14 -95
- package/dist/subagents/index.js +2 -11
- package/dist/subagents/prompts.cjs +14 -93
- package/dist/subagents/prompts.js +2 -11
- package/dist/subagents/types.cjs +1 -17
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/vercel.cjs +27 -2754
- package/dist/subagents/vercel.js +19 -24
- package/dist/tools/compact/core.cjs +12 -548
- package/dist/tools/compact/core.js +8 -13
- package/dist/tools/compact/index.cjs +17 -595
- package/dist/tools/compact/index.js +9 -17
- package/dist/tools/compact/types.cjs +1 -17
- package/dist/tools/compact/types.js +1 -0
- package/dist/tools/fastapply/anthropic.cjs +27 -891
- package/dist/tools/fastapply/anthropic.js +11 -24
- package/dist/tools/fastapply/apply.cjs +28 -672
- package/dist/tools/fastapply/apply.js +4 -19
- package/dist/tools/fastapply/core.cjs +37 -1061
- package/dist/tools/fastapply/core.js +9 -29
- package/dist/tools/fastapply/index.cjs +62 -1062
- package/dist/tools/fastapply/index.js +14 -44
- package/dist/tools/fastapply/openai.cjs +32 -901
- package/dist/tools/fastapply/openai.js +11 -26
- package/dist/tools/fastapply/prompts.cjs +10 -62
- package/dist/tools/fastapply/prompts.js +2 -9
- package/dist/tools/fastapply/types.cjs +1 -17
- package/dist/tools/fastapply/types.js +1 -0
- package/dist/tools/fastapply/vercel.cjs +25 -897
- package/dist/tools/fastapply/vercel.js +11 -22
- package/dist/tools/index.cjs +62 -1062
- package/dist/tools/index.js +14 -44
- package/dist/tools/utils/resilience.cjs +15 -312
- package/dist/tools/utils/resilience.js +3 -12
- package/dist/tools/warp_grep/agent/config.cjs +16 -127
- package/dist/tools/warp_grep/agent/config.js +2 -11
- package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
- package/dist/tools/warp_grep/agent/formatter.js +2 -9
- package/dist/tools/warp_grep/agent/parser.cjs +16 -83
- package/dist/tools/warp_grep/agent/parser.js +2 -11
- package/dist/tools/warp_grep/agent/runner.cjs +15 -1081
- package/dist/tools/warp_grep/agent/runner.js +7 -14
- package/dist/tools/warp_grep/agent/types.cjs +1 -17
- package/dist/tools/warp_grep/agent/types.js +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +47 -2554
- package/dist/tools/warp_grep/anthropic.js +19 -35
- package/dist/tools/warp_grep/client.cjs +49 -2464
- package/dist/tools/warp_grep/client.js +17 -34
- package/dist/tools/warp_grep/gemini.cjs +48 -2483
- package/dist/tools/warp_grep/gemini.js +21 -41
- package/dist/tools/warp_grep/harness.cjs +81 -929
- package/dist/tools/warp_grep/harness.js +12 -51
- package/dist/tools/warp_grep/index.cjs +124 -2568
- package/dist/tools/warp_grep/index.js +24 -87
- package/dist/tools/warp_grep/openai.cjs +53 -2568
- package/dist/tools/warp_grep/openai.js +19 -37
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
- package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
- package/dist/tools/warp_grep/providers/local.cjs +10 -582
- package/dist/tools/warp_grep/providers/local.js +6 -11
- package/dist/tools/warp_grep/providers/remote.cjs +8 -331
- package/dist/tools/warp_grep/providers/remote.js +3 -8
- package/dist/tools/warp_grep/providers/types.cjs +1 -17
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +9 -42
- package/dist/tools/warp_grep/utils/files.js +2 -7
- package/dist/tools/warp_grep/utils/github.cjs +9 -43
- package/dist/tools/warp_grep/utils/github.js +2 -7
- package/dist/tools/warp_grep/utils/paths.cjs +28 -104
- package/dist/tools/warp_grep/utils/paths.js +2 -17
- package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -86
- package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
- package/dist/tools/warp_grep/vercel.cjs +53 -2550
- package/dist/tools/warp_grep/vercel.js +19 -37
- package/dist/version.cjs +7 -225
- package/dist/version.js +2 -7
- package/package.json +2 -2
- package/dist/chunk-UZCXOOZO.js +0 -203
|
@@ -1,29 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import {
|
|
6
|
-
MorphAPIClient
|
|
7
|
-
} from "./chunk-JBAY3PRV.js";
|
|
8
|
-
import {
|
|
9
|
-
logger
|
|
10
|
-
} from "./chunk-6WP7EA4F.js";
|
|
11
|
-
import {
|
|
12
|
-
APIResource
|
|
13
|
-
} from "./chunk-NRG6QX3L.js";
|
|
1
|
+
import { FastApplyContextLengthError, FastApplyAnchorIntegrityError } from './chunk-JUGNTIVU.js';
|
|
2
|
+
import { MorphAPIClient } from './chunk-KLVJIC2O.js';
|
|
3
|
+
import { logger } from './chunk-6WP7EA4F.js';
|
|
4
|
+
import { APIResource } from './chunk-NRG6QX3L.js';
|
|
5
|
+
import { resolve, join, relative } from 'path';
|
|
14
6
|
|
|
15
|
-
// tools/fastapply/core.ts
|
|
16
|
-
import { join, resolve, relative } from "path";
|
|
17
7
|
var DEFAULT_CONFIG = {
|
|
18
|
-
morphApiUrl: "https://api.morphllm.com",
|
|
19
8
|
baseDir: process.cwd(),
|
|
20
9
|
generateUdiff: true,
|
|
21
10
|
autoWrite: true,
|
|
22
|
-
timeout: 6e5
|
|
23
|
-
anchorCompaction: true,
|
|
24
|
-
anchorCompactionThreshold: 128 * 1024,
|
|
25
|
-
debug: false
|
|
26
|
-
};
|
|
11
|
+
timeout: 6e5};
|
|
27
12
|
var FastApplyClient = class extends APIResource {
|
|
28
13
|
config;
|
|
29
14
|
constructor(clientOrConfig = {}) {
|
|
@@ -77,7 +62,7 @@ var FastApplyClient = class extends APIResource {
|
|
|
77
62
|
* ```
|
|
78
63
|
*/
|
|
79
64
|
async applyEdit(input, overrides) {
|
|
80
|
-
const { applyEdit: applyEdit2 } = await import(
|
|
65
|
+
const { applyEdit: applyEdit2 } = await import('./tools/fastapply/apply.js');
|
|
81
66
|
return applyEdit2(input, { ...this.config, ...overrides });
|
|
82
67
|
}
|
|
83
68
|
};
|
|
@@ -97,8 +82,8 @@ async function executeEditFile(input, config = {}) {
|
|
|
97
82
|
}
|
|
98
83
|
logger.debug("FastApply", "security_check", { resolved: fullPath, relative: relativePath });
|
|
99
84
|
try {
|
|
100
|
-
const { readFile, writeFile } = await import(
|
|
101
|
-
const { callMorphAPI: callMorphAPI2, generateUdiff: generateUdiff2, countChanges: countChanges2 } = await import(
|
|
85
|
+
const { readFile, writeFile } = await import('fs/promises');
|
|
86
|
+
const { callMorphAPI: callMorphAPI2, generateUdiff: generateUdiff2, countChanges: countChanges2 } = await import('./tools/fastapply/apply.js');
|
|
102
87
|
let originalCode = "";
|
|
103
88
|
let fileExists = true;
|
|
104
89
|
try {
|
|
@@ -144,7 +129,4 @@ async function executeEditFile(input, config = {}) {
|
|
|
144
129
|
}
|
|
145
130
|
}
|
|
146
131
|
|
|
147
|
-
export {
|
|
148
|
-
FastApplyClient,
|
|
149
|
-
executeEditFile
|
|
150
|
-
};
|
|
132
|
+
export { FastApplyClient, executeEditFile };
|
package/dist/chunk-M34E2AMK.js
CHANGED
|
@@ -97,8 +97,4 @@ var BUILTIN_EXCLUDES = [
|
|
|
97
97
|
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
98
98
|
var DEFAULT_MODEL = "morph-warp-grep-v2.1";
|
|
99
99
|
|
|
100
|
-
export {
|
|
101
|
-
AGENT_CONFIG,
|
|
102
|
-
DEFAULT_EXCLUDES,
|
|
103
|
-
DEFAULT_MODEL
|
|
104
|
-
};
|
|
100
|
+
export { AGENT_CONFIG, DEFAULT_EXCLUDES, DEFAULT_MODEL };
|
package/dist/chunk-MF56KEI4.js
CHANGED
|
@@ -20,7 +20,4 @@ function formatAgentToolOutput(toolName, args, output, options = {}) {
|
|
|
20
20
|
return sharedFormatter.format(toolName, args, output, options);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export {
|
|
24
|
-
ToolOutputFormatter,
|
|
25
|
-
formatAgentToolOutput
|
|
26
|
-
};
|
|
23
|
+
export { ToolOutputFormatter, formatAgentToolOutput };
|
package/dist/chunk-MLKGABMK.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
|
|
1
3
|
// tools/warp_grep/utils/ripgrep.ts
|
|
2
|
-
import { spawn } from "child_process";
|
|
3
|
-
import { rgPath } from "@vscode/ripgrep";
|
|
4
4
|
var resolvedRgPath = null;
|
|
5
5
|
var rgPathChecked = false;
|
|
6
6
|
function spawnRg(rgBinary, args, opts) {
|
|
@@ -22,6 +22,13 @@ function spawnRg(rgBinary, args, opts) {
|
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
async function preferredRgPath() {
|
|
26
|
+
try {
|
|
27
|
+
return (await import('@vscode/ripgrep')).rgPath ?? "rg";
|
|
28
|
+
} catch {
|
|
29
|
+
return "rg";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
25
32
|
function isBinaryFailure(result) {
|
|
26
33
|
if (result.exitCode === -1) return true;
|
|
27
34
|
if (result.stderr.includes("jemalloc") || result.stderr.includes("Unsupported system page size")) return true;
|
|
@@ -33,6 +40,7 @@ async function runRipgrep(args, opts) {
|
|
|
33
40
|
return spawnRg(resolvedRgPath, args, opts);
|
|
34
41
|
}
|
|
35
42
|
if (!rgPathChecked) {
|
|
43
|
+
const rgPath = await preferredRgPath();
|
|
36
44
|
const result = await spawnRg(rgPath, args, opts);
|
|
37
45
|
if (!isBinaryFailure(result)) {
|
|
38
46
|
resolvedRgPath = rgPath;
|
|
@@ -59,6 +67,4 @@ async function runRipgrep(args, opts) {
|
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
69
|
|
|
62
|
-
export {
|
|
63
|
-
runRipgrep
|
|
64
|
-
};
|
|
70
|
+
export { runRipgrep };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// tools/warp_grep/utils/github.ts
|
|
4
|
+
function parseGitHubUrl(input) {
|
|
5
|
+
input = input.trim();
|
|
6
|
+
const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
|
|
7
|
+
const match = input.match(urlPattern);
|
|
8
|
+
if (match) {
|
|
9
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
|
|
10
|
+
}
|
|
11
|
+
const shortPattern = /^([^\/]+)\/([^\/]+)$/;
|
|
12
|
+
const shortMatch = input.match(shortPattern);
|
|
13
|
+
if (shortMatch && !shortMatch[1].includes(".")) {
|
|
14
|
+
return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
|
|
15
|
+
}
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.parseGitHubUrl = parseGitHubUrl;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CompactClient
|
|
3
|
-
} from "./chunk-5NSYDT36.js";
|
|
1
|
+
import { CompactClient } from './chunk-H3HRSRR5.js';
|
|
4
2
|
|
|
5
3
|
// tools/compact/utils.ts
|
|
6
4
|
async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4, maxConcurrency = 3) {
|
|
@@ -47,6 +45,4 @@ async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4
|
|
|
47
45
|
return results.sort((a, b) => (orderMap.get(a.path) ?? 0) - (orderMap.get(b.path) ?? 0));
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
export {
|
|
51
|
-
compactFileContexts
|
|
52
|
-
};
|
|
48
|
+
export { compactFileContexts };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk74A4HLIO_cjs = require('./chunk-74A4HLIO.cjs');
|
|
4
|
+
var chunkJBTR3FQD_cjs = require('./chunk-JBTR3FQD.cjs');
|
|
5
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
|
+
|
|
7
|
+
// tools/fastapply/anthropic.ts
|
|
8
|
+
var anthropic_exports = {};
|
|
9
|
+
chunk75ZPJI57_cjs.__export(anthropic_exports, {
|
|
10
|
+
createEditFileTool: () => createEditFileTool,
|
|
11
|
+
editFileTool: () => editFileTool,
|
|
12
|
+
execute: () => execute,
|
|
13
|
+
formatResult: () => formatResult,
|
|
14
|
+
getSystemPrompt: () => getSystemPrompt
|
|
15
|
+
});
|
|
16
|
+
var editFileTool = {
|
|
17
|
+
name: "edit_file",
|
|
18
|
+
description: chunk74A4HLIO_cjs.EDIT_FILE_TOOL_DESCRIPTION,
|
|
19
|
+
input_schema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
target_filepath: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "The path of the target file to modify"
|
|
25
|
+
},
|
|
26
|
+
instruction: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."
|
|
29
|
+
},
|
|
30
|
+
code_edit: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function formatResult(result) {
|
|
39
|
+
if (!result.success) {
|
|
40
|
+
return `Error editing file: ${result.error}`;
|
|
41
|
+
}
|
|
42
|
+
const { changes } = result;
|
|
43
|
+
return `Successfully applied changes to ${result.filepath}. Added ${changes.linesAdded}, removed ${changes.linesRemoved}, modified ${changes.linesModified}.`;
|
|
44
|
+
}
|
|
45
|
+
function createEditFileTool(config = {}) {
|
|
46
|
+
const toolDef = {
|
|
47
|
+
...editFileTool,
|
|
48
|
+
...config.description && { description: config.description }
|
|
49
|
+
};
|
|
50
|
+
return Object.assign({}, toolDef, {
|
|
51
|
+
execute: async (input) => {
|
|
52
|
+
return chunkJBTR3FQD_cjs.executeEditFile(input, config);
|
|
53
|
+
},
|
|
54
|
+
formatResult: (result) => {
|
|
55
|
+
return formatResult(result);
|
|
56
|
+
},
|
|
57
|
+
getSystemPrompt: () => {
|
|
58
|
+
return chunk74A4HLIO_cjs.EDIT_FILE_SYSTEM_PROMPT;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function execute(input, config) {
|
|
63
|
+
return chunkJBTR3FQD_cjs.executeEditFile(input, config);
|
|
64
|
+
}
|
|
65
|
+
function getSystemPrompt() {
|
|
66
|
+
return chunk74A4HLIO_cjs.EDIT_FILE_SYSTEM_PROMPT;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
exports.anthropic_exports = anthropic_exports;
|
|
70
|
+
exports.createEditFileTool = createEditFileTool;
|
|
71
|
+
exports.editFileTool = editFileTool;
|
|
72
|
+
exports.execute = execute;
|
|
73
|
+
exports.formatResult = formatResult;
|
|
74
|
+
exports.getSystemPrompt = getSystemPrompt;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import {
|
|
6
|
-
executeEditFile
|
|
7
|
-
} from "./chunk-RZOJ4GSY.js";
|
|
8
|
-
import {
|
|
9
|
-
__export
|
|
10
|
-
} from "./chunk-MLKGABMK.js";
|
|
1
|
+
import { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './chunk-PA3UTI4A.js';
|
|
2
|
+
import { executeEditFile } from './chunk-LLQH6CCB.js';
|
|
3
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
4
|
+
import { tool } from 'ai';
|
|
5
|
+
import { z } from 'zod';
|
|
11
6
|
|
|
12
7
|
// tools/fastapply/vercel.ts
|
|
13
8
|
var vercel_exports = {};
|
|
@@ -17,8 +12,6 @@ __export(vercel_exports, {
|
|
|
17
12
|
editFileTool: () => editFileTool,
|
|
18
13
|
getSystemPrompt: () => getSystemPrompt
|
|
19
14
|
});
|
|
20
|
-
import { tool } from "ai";
|
|
21
|
-
import { z } from "zod";
|
|
22
15
|
var editFileSchema = z.object({
|
|
23
16
|
target_filepath: z.string().describe("The path of the target file to modify"),
|
|
24
17
|
instruction: 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."),
|
|
@@ -79,10 +72,4 @@ function createEditFileTool(config = {}) {
|
|
|
79
72
|
}
|
|
80
73
|
var vercel_default = editFileTool;
|
|
81
74
|
|
|
82
|
-
export {
|
|
83
|
-
editFileTool,
|
|
84
|
-
getSystemPrompt,
|
|
85
|
-
createEditFileTool,
|
|
86
|
-
vercel_default,
|
|
87
|
-
vercel_exports
|
|
88
|
-
};
|
|
75
|
+
export { createEditFileTool, editFileTool, getSystemPrompt, vercel_default, vercel_exports };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs/promises');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
8
|
+
|
|
9
|
+
// tools/warp_grep/utils/files.ts
|
|
10
|
+
async function readAllLines(filePath) {
|
|
11
|
+
const content = await fs__default.default.readFile(filePath, "utf8");
|
|
12
|
+
return content.split(/\r?\n/);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.readAllLines = readAllLines;
|
package/dist/chunk-NRG6QX3L.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkAFF6XYKL_cjs = require('./chunk-AFF6XYKL.cjs');
|
|
4
|
+
|
|
5
|
+
// tools/compact/utils.ts
|
|
6
|
+
async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4, maxConcurrency = 3) {
|
|
7
|
+
const totalLength = files.reduce((sum, file) => sum + file.content.length, 0);
|
|
8
|
+
const estimatedTokens = totalLength / 3;
|
|
9
|
+
if (estimatedTokens <= maxTokens) {
|
|
10
|
+
return files;
|
|
11
|
+
}
|
|
12
|
+
let compressionRatio = maxTokens / estimatedTokens;
|
|
13
|
+
compressionRatio = Math.max(0.3, Math.min(0.99, compressionRatio));
|
|
14
|
+
const client = new chunkAFF6XYKL_cjs.CompactClient({
|
|
15
|
+
morphApiKey: apiKey,
|
|
16
|
+
morphApiUrl: apiUrl
|
|
17
|
+
});
|
|
18
|
+
const results = [];
|
|
19
|
+
const inProgress = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
if (file.content.length < 500) {
|
|
22
|
+
results.push({ path: file.path, content: file.content });
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const task = async () => {
|
|
26
|
+
try {
|
|
27
|
+
const result = await client.compact({
|
|
28
|
+
input: file.content,
|
|
29
|
+
query,
|
|
30
|
+
compressionRatio,
|
|
31
|
+
preserveRecent: 0
|
|
32
|
+
});
|
|
33
|
+
results.push({ path: file.path, content: result.output });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(`[compactFileContexts] Failed to compact file ${file.path}:`, error);
|
|
36
|
+
results.push({ path: file.path, content: file.content });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const promise = task().finally(() => inProgress.delete(promise));
|
|
40
|
+
inProgress.add(promise);
|
|
41
|
+
if (inProgress.size >= maxConcurrency) {
|
|
42
|
+
await Promise.race(inProgress);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
await Promise.all(inProgress);
|
|
46
|
+
const orderMap = new Map(files.map((f, i) => [f.path, i]));
|
|
47
|
+
return results.sort((a, b) => (orderMap.get(a.path) ?? 0) - (orderMap.get(b.path) ?? 0));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.compactFileContexts = compactFileContexts;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTL34BLQD_cjs = require('./chunk-TL34BLQD.cjs');
|
|
4
|
+
|
|
5
|
+
// tools/utils/resilience.ts
|
|
6
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
7
|
+
maxRetries: 3,
|
|
8
|
+
initialDelay: 1e3,
|
|
9
|
+
maxDelay: 3e4,
|
|
10
|
+
backoffMultiplier: 2,
|
|
11
|
+
retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
|
|
12
|
+
};
|
|
13
|
+
async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
14
|
+
const {
|
|
15
|
+
maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
|
|
16
|
+
initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
|
|
17
|
+
maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
|
|
18
|
+
backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
|
|
19
|
+
retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
20
|
+
onRetry
|
|
21
|
+
} = retryConfig;
|
|
22
|
+
let lastError = null;
|
|
23
|
+
let delay = initialDelay;
|
|
24
|
+
options = { ...options, headers: { "X-Morph-SDK-Version": chunkTL34BLQD_cjs.SDK_VERSION, ...options.headers } };
|
|
25
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
26
|
+
try {
|
|
27
|
+
const response = await fetch(url, options);
|
|
28
|
+
if (response.status === 429 || response.status === 503) {
|
|
29
|
+
if (attempt < maxRetries) {
|
|
30
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
31
|
+
const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
|
|
32
|
+
const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
|
|
33
|
+
if (onRetry) {
|
|
34
|
+
onRetry(attempt + 1, error);
|
|
35
|
+
}
|
|
36
|
+
await sleep(waitTime);
|
|
37
|
+
delay *= backoffMultiplier;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return response;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
lastError = error;
|
|
44
|
+
const isRetryable = retryableErrors.some(
|
|
45
|
+
(errType) => lastError?.message?.includes(errType)
|
|
46
|
+
);
|
|
47
|
+
if (!isRetryable || attempt === maxRetries) {
|
|
48
|
+
throw lastError;
|
|
49
|
+
}
|
|
50
|
+
const waitTime = Math.min(delay, maxDelay);
|
|
51
|
+
if (onRetry) {
|
|
52
|
+
onRetry(attempt + 1, lastError);
|
|
53
|
+
}
|
|
54
|
+
await sleep(waitTime);
|
|
55
|
+
delay *= backoffMultiplier;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
throw lastError || new Error("Max retries exceeded");
|
|
59
|
+
}
|
|
60
|
+
async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
61
|
+
let timeoutId;
|
|
62
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
63
|
+
timeoutId = setTimeout(() => {
|
|
64
|
+
reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
|
|
65
|
+
}, timeoutMs);
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
const result = await Promise.race([promise, timeoutPromise]);
|
|
69
|
+
clearTimeout(timeoutId);
|
|
70
|
+
return result;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
clearTimeout(timeoutId);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function sleep(ms) {
|
|
77
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
78
|
+
}
|
|
79
|
+
var MorphError = class extends Error {
|
|
80
|
+
constructor(message, code, statusCode, retryable = false) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.code = code;
|
|
83
|
+
this.statusCode = statusCode;
|
|
84
|
+
this.retryable = retryable;
|
|
85
|
+
this.name = "MorphError";
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
exports.MorphError = MorphError;
|
|
90
|
+
exports.fetchWithRetry = fetchWithRetry;
|
|
91
|
+
exports.withTimeout = withTimeout;
|