@morphllm/morphsdk 0.2.192 → 0.2.194
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-OXVH7KJ7.js → chunk-2JKIWBME.js} +2 -2
- package/dist/{chunk-X57U7AHA.js → chunk-2THF6MNE.js} +2 -2
- package/dist/{chunk-4E2HKWUQ.js → chunk-33WVJLIT.js} +2 -2
- package/dist/{chunk-RAWFZX7R.js → chunk-74LJOCDW.js} +2 -2
- package/dist/{chunk-XT75CKB2.js → chunk-7KAW6EUG.js} +21 -21
- package/dist/{chunk-3RIS4CS2.js → chunk-A2SC5ZOG.js} +2 -2
- package/dist/{chunk-3RIS4CS2.js.map → chunk-A2SC5ZOG.js.map} +1 -1
- package/dist/{chunk-45HXBGGH.js → chunk-C225GOV2.js} +2 -2
- package/dist/{chunk-DRM3ETEL.js → chunk-CKSINYRF.js} +2 -2
- package/dist/{chunk-4BALDMIZ.js → chunk-DL4EUMBV.js} +2 -2
- package/dist/{chunk-NDUHOFAN.js → chunk-EM7BMNSS.js} +2 -2
- package/dist/{chunk-CKN2RJPD.js → chunk-FM2L35XC.js} +2 -2
- package/dist/{chunk-F4L7PCXV.js → chunk-GRYLQ2HM.js} +2 -2
- package/dist/{chunk-EABWHIAS.js → chunk-GWXMT3S2.js} +13 -4
- package/dist/chunk-GWXMT3S2.js.map +1 -0
- package/dist/{chunk-EUZCZNK4.js → chunk-JIHDKRQW.js} +2 -2
- package/dist/chunk-KGHHK42W.js +399 -0
- package/dist/chunk-KGHHK42W.js.map +1 -0
- package/dist/{chunk-UCDN6SER.js → chunk-MFAIFUFK.js} +2 -2
- package/dist/{chunk-VLZ6PNAD.js → chunk-OPNTDMHH.js} +4 -4
- package/dist/{chunk-4EZ7L6FJ.js → chunk-PDSLRLYI.js} +3 -3
- package/dist/{chunk-2W54UBCR.js → chunk-POUBLP4R.js} +4 -4
- package/dist/{chunk-OZDNWR3I.js → chunk-PPNJY7P3.js} +3 -3
- package/dist/{chunk-24ID7P4E.js → chunk-PUTYJ2ET.js} +4 -4
- package/dist/{chunk-A777CPSD.js → chunk-QJSGHJ7D.js} +2 -2
- package/dist/{chunk-G5J5ZHCG.js → chunk-S3V22W7M.js} +2 -2
- package/dist/{chunk-QJQORGE3.js → chunk-SU5FOI4R.js} +2 -2
- package/dist/{chunk-TP625ZYJ.js → chunk-TAQLWNIF.js} +2 -2
- package/dist/{chunk-IY5WUAFH.js → chunk-TT37PYOQ.js} +2 -2
- package/dist/{chunk-FL4XLVK2.js → chunk-U74U4ZFN.js} +2 -2
- package/dist/{chunk-KKVV5RQZ.js → chunk-UDZBOMRA.js} +3 -3
- package/dist/{chunk-GS4QVZ75.js → chunk-VYDKGM7F.js} +9 -9
- package/dist/{chunk-AKPE7Z23.js → chunk-WP44GN6A.js} +2 -2
- package/dist/{chunk-HHSBWOAP.js → chunk-WXUMJSGG.js} +2 -2
- package/dist/{chunk-DDM6B66N.js → chunk-XQR2U3LP.js} +3 -3
- package/dist/client.cjs +284 -21
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +29 -29
- package/dist/core/client.cjs +1 -1
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.js +4 -4
- package/dist/core/error.cjs +1 -1
- package/dist/core/error.cjs.map +1 -1
- package/dist/core/error.js +3 -3
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +4 -4
- package/dist/edge.cjs +269 -18
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +11 -7
- package/dist/git/client.cjs +1 -1
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +5 -5
- package/dist/git/index.cjs +1 -1
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +5 -5
- package/dist/index.cjs +288 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -31
- package/dist/modelrouter/core.cjs +1 -1
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +5 -5
- package/dist/modelrouter/index.cjs +1 -1
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +5 -5
- package/dist/subagents/anthropic.cjs +1 -1
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +10 -10
- package/dist/subagents/vercel.cjs +1 -1
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +10 -10
- package/dist/tools/browser/anthropic.cjs +1 -1
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +7 -7
- package/dist/tools/browser/core.cjs +1 -1
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +6 -6
- package/dist/tools/browser/index.cjs +1 -1
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +9 -9
- package/dist/tools/browser/openai.cjs +1 -1
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +7 -7
- package/dist/tools/browser/profiles/core.cjs +1 -1
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +1 -1
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +1 -1
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +7 -7
- package/dist/tools/codebase_search/anthropic.cjs +1 -1
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +6 -6
- package/dist/tools/codebase_search/core.cjs +1 -1
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +5 -5
- package/dist/tools/codebase_search/index.cjs +1 -1
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +8 -8
- package/dist/tools/codebase_search/openai.cjs +1 -1
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +6 -6
- package/dist/tools/codebase_search/vercel.cjs +1 -1
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +6 -6
- package/dist/tools/compact/core.cjs +1 -1
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.js +5 -5
- package/dist/tools/compact/index.cjs +1 -1
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.js +6 -6
- package/dist/tools/fastapply/anthropic.cjs +284 -21
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +7 -7
- package/dist/tools/fastapply/apply.cjs +269 -18
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.d.ts +13 -1
- package/dist/tools/fastapply/apply.js +6 -2
- package/dist/tools/fastapply/core.cjs +288 -21
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.d.ts +1 -1
- package/dist/tools/fastapply/core.js +10 -6
- package/dist/tools/fastapply/index.cjs +288 -21
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.d.ts +1 -1
- package/dist/tools/fastapply/index.js +13 -9
- package/dist/tools/fastapply/openai.cjs +284 -21
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +7 -7
- package/dist/tools/fastapply/types.cjs.map +1 -1
- package/dist/tools/fastapply/types.d.ts +14 -2
- package/dist/tools/fastapply/vercel.cjs +284 -21
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +7 -7
- package/dist/tools/index.cjs +288 -21
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +13 -9
- package/dist/tools/reflex/core.cjs +1 -1
- package/dist/tools/reflex/core.cjs.map +1 -1
- package/dist/tools/reflex/core.js +5 -5
- package/dist/tools/reflex/index.cjs +1 -1
- package/dist/tools/reflex/index.cjs.map +1 -1
- package/dist/tools/reflex/index.js +5 -5
- package/dist/tools/utils/resilience.cjs +1 -1
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- package/dist/tools/warp_grep/anthropic.cjs +1 -1
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +10 -10
- package/dist/tools/warp_grep/client.cjs +1 -1
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +9 -9
- package/dist/tools/warp_grep/gemini.cjs +1 -1
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +9 -9
- package/dist/tools/warp_grep/harness.js +2 -2
- package/dist/tools/warp_grep/index.cjs +1 -1
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +14 -14
- package/dist/tools/warp_grep/openai.cjs +1 -1
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +10 -10
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +1 -1
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +10 -10
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-EABWHIAS.js.map +0 -1
- package/dist/chunk-SM27L5SF.js +0 -148
- package/dist/chunk-SM27L5SF.js.map +0 -1
- /package/dist/{chunk-OXVH7KJ7.js.map → chunk-2JKIWBME.js.map} +0 -0
- /package/dist/{chunk-X57U7AHA.js.map → chunk-2THF6MNE.js.map} +0 -0
- /package/dist/{chunk-4E2HKWUQ.js.map → chunk-33WVJLIT.js.map} +0 -0
- /package/dist/{chunk-RAWFZX7R.js.map → chunk-74LJOCDW.js.map} +0 -0
- /package/dist/{chunk-XT75CKB2.js.map → chunk-7KAW6EUG.js.map} +0 -0
- /package/dist/{chunk-45HXBGGH.js.map → chunk-C225GOV2.js.map} +0 -0
- /package/dist/{chunk-DRM3ETEL.js.map → chunk-CKSINYRF.js.map} +0 -0
- /package/dist/{chunk-4BALDMIZ.js.map → chunk-DL4EUMBV.js.map} +0 -0
- /package/dist/{chunk-NDUHOFAN.js.map → chunk-EM7BMNSS.js.map} +0 -0
- /package/dist/{chunk-CKN2RJPD.js.map → chunk-FM2L35XC.js.map} +0 -0
- /package/dist/{chunk-F4L7PCXV.js.map → chunk-GRYLQ2HM.js.map} +0 -0
- /package/dist/{chunk-EUZCZNK4.js.map → chunk-JIHDKRQW.js.map} +0 -0
- /package/dist/{chunk-UCDN6SER.js.map → chunk-MFAIFUFK.js.map} +0 -0
- /package/dist/{chunk-VLZ6PNAD.js.map → chunk-OPNTDMHH.js.map} +0 -0
- /package/dist/{chunk-4EZ7L6FJ.js.map → chunk-PDSLRLYI.js.map} +0 -0
- /package/dist/{chunk-2W54UBCR.js.map → chunk-POUBLP4R.js.map} +0 -0
- /package/dist/{chunk-OZDNWR3I.js.map → chunk-PPNJY7P3.js.map} +0 -0
- /package/dist/{chunk-24ID7P4E.js.map → chunk-PUTYJ2ET.js.map} +0 -0
- /package/dist/{chunk-A777CPSD.js.map → chunk-QJSGHJ7D.js.map} +0 -0
- /package/dist/{chunk-G5J5ZHCG.js.map → chunk-S3V22W7M.js.map} +0 -0
- /package/dist/{chunk-QJQORGE3.js.map → chunk-SU5FOI4R.js.map} +0 -0
- /package/dist/{chunk-TP625ZYJ.js.map → chunk-TAQLWNIF.js.map} +0 -0
- /package/dist/{chunk-IY5WUAFH.js.map → chunk-TT37PYOQ.js.map} +0 -0
- /package/dist/{chunk-FL4XLVK2.js.map → chunk-U74U4ZFN.js.map} +0 -0
- /package/dist/{chunk-KKVV5RQZ.js.map → chunk-UDZBOMRA.js.map} +0 -0
- /package/dist/{chunk-GS4QVZ75.js.map → chunk-VYDKGM7F.js.map} +0 -0
- /package/dist/{chunk-AKPE7Z23.js.map → chunk-WP44GN6A.js.map} +0 -0
- /package/dist/{chunk-HHSBWOAP.js.map → chunk-WXUMJSGG.js.map} +0 -0
- /package/dist/{chunk-DDM6B66N.js.map → chunk-XQR2U3LP.js.map} +0 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-F3NCFNUX.js";
|
|
4
|
+
import {
|
|
5
|
+
SDK_VERSION
|
|
6
|
+
} from "./chunk-A2SC5ZOG.js";
|
|
7
|
+
|
|
8
|
+
// tools/fastapply/apply.ts
|
|
9
|
+
import { createTwoFilesPatch } from "diff";
|
|
10
|
+
import OpenAI from "openai";
|
|
11
|
+
|
|
12
|
+
// tools/fastapply/anchors.ts
|
|
13
|
+
var DEFAULT_MIN_ANCHOR_LINE_LENGTH = 24;
|
|
14
|
+
var DEFAULT_ANCHOR_COMPACTION_THRESHOLD = 128 * 1024;
|
|
15
|
+
var FastApplyAnchorIntegrityError = class extends Error {
|
|
16
|
+
code = "anchor_integrity_failed";
|
|
17
|
+
completionId;
|
|
18
|
+
constructor(completionId) {
|
|
19
|
+
super(
|
|
20
|
+
"Fast Apply failed large-file anchor integrity checks. The partial result was discarded safely."
|
|
21
|
+
);
|
|
22
|
+
this.name = "FastApplyAnchorIntegrityError";
|
|
23
|
+
this.completionId = completionId;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function escapeRegExp(value) {
|
|
27
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28
|
+
}
|
|
29
|
+
function findNamespace(values) {
|
|
30
|
+
for (let namespace = 0; namespace < Number.MAX_SAFE_INTEGER; namespace++) {
|
|
31
|
+
const prefix = `\u27EAM${namespace}:`;
|
|
32
|
+
if (values.every((value) => !value.includes(prefix))) {
|
|
33
|
+
return namespace;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw new Error("Unable to allocate a Fast Apply anchor namespace");
|
|
37
|
+
}
|
|
38
|
+
function htmlLabel(token) {
|
|
39
|
+
if (!token.startsWith("<")) return "text";
|
|
40
|
+
const match = token.match(/^<\s*(!doctype|\/?[a-zA-Z][\w:-]*)/);
|
|
41
|
+
return (match?.[1] ?? "tag").toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
function htmlTokenUnits(value, visibleTags = /* @__PURE__ */ new Set()) {
|
|
44
|
+
return (value.match(/<[^>]*>|[^<]+/g) ?? [value]).map((token) => ({
|
|
45
|
+
value: token,
|
|
46
|
+
label: htmlLabel(token),
|
|
47
|
+
anchorable: token.length >= DEFAULT_MIN_ANCHOR_LINE_LENGTH && !visibleTags.has(htmlLabel(token).replace(/^\//, ""))
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function sourceUnits(originalCode, editContext) {
|
|
51
|
+
const trimmed = originalCode.trimStart().toLowerCase();
|
|
52
|
+
const looksLikeHtml = (trimmed.startsWith("<!doctype") || trimmed.startsWith("<html")) && /<\/html\s*>/i.test(originalCode);
|
|
53
|
+
if (looksLikeHtml) {
|
|
54
|
+
const contextWords = new Set(
|
|
55
|
+
editContext.join(" ").toLowerCase().match(/[a-z][\w:-]*/g) ?? []
|
|
56
|
+
);
|
|
57
|
+
return htmlTokenUnits(originalCode, contextWords);
|
|
58
|
+
}
|
|
59
|
+
const parts = originalCode.split(/(\r\n|\n|\r)/);
|
|
60
|
+
const units = [];
|
|
61
|
+
for (let index = 0; index < parts.length; index += 2) {
|
|
62
|
+
const line = parts[index] ?? "";
|
|
63
|
+
const lineEnding = parts[index + 1] ?? "";
|
|
64
|
+
units.push({
|
|
65
|
+
value: line,
|
|
66
|
+
label: "line",
|
|
67
|
+
anchorable: line.length >= DEFAULT_MIN_ANCHOR_LINE_LENGTH
|
|
68
|
+
});
|
|
69
|
+
if (lineEnding) {
|
|
70
|
+
units.push({ value: lineEnding, anchorable: false });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return units;
|
|
74
|
+
}
|
|
75
|
+
function copyCount(value) {
|
|
76
|
+
const words = {
|
|
77
|
+
one: 1,
|
|
78
|
+
two: 2,
|
|
79
|
+
three: 3,
|
|
80
|
+
four: 4,
|
|
81
|
+
five: 5,
|
|
82
|
+
six: 6,
|
|
83
|
+
seven: 7,
|
|
84
|
+
eight: 8,
|
|
85
|
+
nine: 9,
|
|
86
|
+
ten: 10
|
|
87
|
+
};
|
|
88
|
+
return /^\d+$/.test(value) ? Number(value) : words[value.toLowerCase()];
|
|
89
|
+
}
|
|
90
|
+
function structuralExpectation(originalCode, editContext) {
|
|
91
|
+
const context = editContext.join(" ");
|
|
92
|
+
const match = context.match(
|
|
93
|
+
/(?:for every|for each|each)\s+([a-z][\w:-]*)[\s\S]{0,120}?add\s+(one|two|three|four|five|six|seven|eight|nine|ten|\d+)\s+identical cop(?:y|ies)/i
|
|
94
|
+
);
|
|
95
|
+
if (!match) return void 0;
|
|
96
|
+
const tag = match[1].toLowerCase();
|
|
97
|
+
const addedCopies = copyCount(match[2]);
|
|
98
|
+
if (addedCopies === void 0) return void 0;
|
|
99
|
+
const tagPattern = new RegExp(`<${escapeRegExp(tag)}(?:\\s|>)`, "gi");
|
|
100
|
+
const originalCount = originalCode.match(tagPattern)?.length ?? 0;
|
|
101
|
+
if (originalCount === 0) return void 0;
|
|
102
|
+
return { tag, expectedCount: originalCount * (addedCopies + 1) };
|
|
103
|
+
}
|
|
104
|
+
function createAnchorCompactionPlan(originalCode, collisionValues = []) {
|
|
105
|
+
const namespace = findNamespace([originalCode, ...collisionValues]);
|
|
106
|
+
const expectation = structuralExpectation(originalCode, collisionValues);
|
|
107
|
+
const markerPrefix = `\u27EAM${namespace}:`;
|
|
108
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
109
|
+
const values = [];
|
|
110
|
+
const markers = [];
|
|
111
|
+
let anchorCount = 0;
|
|
112
|
+
let skeleton = "";
|
|
113
|
+
for (const unit of sourceUnits(originalCode, collisionValues)) {
|
|
114
|
+
if (!unit.anchorable) {
|
|
115
|
+
skeleton += unit.value;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
let id = definitions.get(unit.value);
|
|
119
|
+
if (id === void 0) {
|
|
120
|
+
id = values.length;
|
|
121
|
+
definitions.set(unit.value, id);
|
|
122
|
+
values.push(unit.value);
|
|
123
|
+
markers.push(`${markerPrefix}${id}:${unit.label ?? "unit"}\u27EB`);
|
|
124
|
+
}
|
|
125
|
+
skeleton += markers[id];
|
|
126
|
+
anchorCount++;
|
|
127
|
+
}
|
|
128
|
+
if (anchorCount === 0 || skeleton.length >= originalCode.length) {
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
131
|
+
const definitionsBegin = `\u27EAMORPH_DEFINITIONS_BEGIN_${namespace}\u27EB`;
|
|
132
|
+
const definitionsEnd = `\u27EAMORPH_DEFINITIONS_END_${namespace}\u27EB`;
|
|
133
|
+
const codeBegin = `\u27EAMORPH_CODE_BEGIN_${namespace}\u27EB`;
|
|
134
|
+
const serializedDefinitions = values.map((value, id) => `${markers[id]}=${JSON.stringify(value)}`).join("\n");
|
|
135
|
+
const code = [
|
|
136
|
+
definitionsBegin,
|
|
137
|
+
serializedDefinitions,
|
|
138
|
+
definitionsEnd,
|
|
139
|
+
codeBegin,
|
|
140
|
+
skeleton
|
|
141
|
+
].join("\n");
|
|
142
|
+
const instructionSuffix = `
|
|
143
|
+
|
|
144
|
+
LARGE-FILE ANCHOR PROTOCOL:
|
|
145
|
+
The <code> block starts with an exact anchor definition table, then ${codeBegin}, then the source skeleton.
|
|
146
|
+
Each ${markerPrefix}N:kind\u27EB placeholder represents the exact source fragment in its matching JSON-string definition. The kind suffix describes its HTML tag, text, or source line.
|
|
147
|
+
Return only the updated source skeleton after ${codeBegin}; never return the definition table or protocol delimiters.
|
|
148
|
+
Copy a placeholder exactly when its source fragment is unchanged. You may repeat, reorder, or remove placeholders when the requested edit requires it.
|
|
149
|
+
To modify an anchored fragment, output the modified source instead of its placeholder.
|
|
150
|
+
Do not invent or alter placeholder IDs.`;
|
|
151
|
+
const markerPattern = new RegExp(`${escapeRegExp(markerPrefix)}(\\d+):[^\u27EB]+\u27EB`, "g");
|
|
152
|
+
return {
|
|
153
|
+
code,
|
|
154
|
+
instructionSuffix,
|
|
155
|
+
anchorCount,
|
|
156
|
+
uniqueAnchorCount: values.length,
|
|
157
|
+
hasStructuralValidation: expectation !== void 0,
|
|
158
|
+
expand(content) {
|
|
159
|
+
const codeBeginIndex = content.lastIndexOf(codeBegin);
|
|
160
|
+
const skeletonContent = codeBeginIndex >= 0 ? content.slice(codeBeginIndex + codeBegin.length).replace(/^\r?\n/, "") : content;
|
|
161
|
+
const expanded = skeletonContent.replace(markerPattern, (marker, idText) => {
|
|
162
|
+
const id = Number(idText);
|
|
163
|
+
const value = values[id];
|
|
164
|
+
return value === void 0 || markers[id] !== marker ? marker : value;
|
|
165
|
+
});
|
|
166
|
+
if (expanded.includes(markerPrefix)) {
|
|
167
|
+
throw new FastApplyAnchorIntegrityError();
|
|
168
|
+
}
|
|
169
|
+
if (expectation) {
|
|
170
|
+
const tagPattern = new RegExp(`<${escapeRegExp(expectation.tag)}(?:\\s|>)`, "gi");
|
|
171
|
+
const actualCount = expanded.match(tagPattern)?.length ?? 0;
|
|
172
|
+
if (actualCount !== expectation.expectedCount) {
|
|
173
|
+
throw new FastApplyAnchorIntegrityError();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return expanded;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// tools/fastapply/apply.ts
|
|
182
|
+
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
183
|
+
var DEFAULT_TIMEOUT = 6e5;
|
|
184
|
+
var FastApplyContextLengthError = class extends Error {
|
|
185
|
+
code = "context_length_exceeded";
|
|
186
|
+
completionId;
|
|
187
|
+
constructor(completionId) {
|
|
188
|
+
super(
|
|
189
|
+
"Fast Apply exhausted its context window before producing the complete file. Retry with a smaller input/update or use sparse anchors for unchanged code."
|
|
190
|
+
);
|
|
191
|
+
this.name = "FastApplyContextLengthError";
|
|
192
|
+
this.completionId = completionId;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
function isAsyncIterable(value) {
|
|
196
|
+
return typeof value === "object" && value !== null && Symbol.asyncIterator in value;
|
|
197
|
+
}
|
|
198
|
+
async function collectCompletion(response) {
|
|
199
|
+
if (!isAsyncIterable(response)) {
|
|
200
|
+
const completion = response;
|
|
201
|
+
return {
|
|
202
|
+
content: completion.choices?.[0]?.message?.content ?? "",
|
|
203
|
+
completionId: completion.id,
|
|
204
|
+
finishReason: completion.choices?.[0]?.finish_reason
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const content = [];
|
|
208
|
+
let completionId;
|
|
209
|
+
let finishReason;
|
|
210
|
+
for await (const chunk of response) {
|
|
211
|
+
completionId = chunk.id ?? completionId;
|
|
212
|
+
for (const choice of chunk.choices ?? []) {
|
|
213
|
+
if (choice.delta?.content) {
|
|
214
|
+
content.push(choice.delta.content);
|
|
215
|
+
}
|
|
216
|
+
if (choice.finish_reason !== void 0 && choice.finish_reason !== null) {
|
|
217
|
+
finishReason = choice.finish_reason;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return { content: content.join(""), completionId, finishReason };
|
|
222
|
+
}
|
|
223
|
+
function generateUdiff(original, modified, filepath) {
|
|
224
|
+
return createTwoFilesPatch(
|
|
225
|
+
filepath,
|
|
226
|
+
filepath,
|
|
227
|
+
original,
|
|
228
|
+
modified,
|
|
229
|
+
"Original",
|
|
230
|
+
"Modified"
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
function countChanges(original, modified) {
|
|
234
|
+
const diff = generateUdiff(original, modified, "file");
|
|
235
|
+
const lines = diff.split("\n");
|
|
236
|
+
let linesAdded = 0;
|
|
237
|
+
let linesRemoved = 0;
|
|
238
|
+
for (const line of lines) {
|
|
239
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
240
|
+
linesAdded++;
|
|
241
|
+
} else if (line.startsWith("-") && !line.startsWith("---")) {
|
|
242
|
+
linesRemoved++;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const linesModified = Math.min(linesAdded, linesRemoved);
|
|
246
|
+
return {
|
|
247
|
+
linesAdded: linesAdded - linesModified,
|
|
248
|
+
linesRemoved: linesRemoved - linesModified,
|
|
249
|
+
linesModified
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
async function callMorphAPI(originalCode, codeEdit, instructions, filepath, config) {
|
|
253
|
+
const apiKey = config.morphApiKey || (typeof process !== "undefined" ? process.env?.MORPH_API_KEY : void 0);
|
|
254
|
+
const apiUrl = config.morphApiUrl || DEFAULT_API_URL;
|
|
255
|
+
const useLarge = config.large ?? (typeof process !== "undefined" ? process.env?.MORPH_LARGE_APPLY !== "false" : true);
|
|
256
|
+
const model = useLarge ? "morph-v3-large" : "morph-v3-fast";
|
|
257
|
+
const timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
258
|
+
const debug = config.debug || false;
|
|
259
|
+
if (!apiKey) {
|
|
260
|
+
throw new Error(
|
|
261
|
+
"Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config."
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
const anchorThreshold = config.anchorCompactionThreshold ?? DEFAULT_ANCHOR_COMPACTION_THRESHOLD;
|
|
265
|
+
const anchorPlan = config.anchorCompaction !== false && originalCode.length >= anchorThreshold ? createAnchorCompactionPlan(originalCode, [codeEdit, instructions]) : void 0;
|
|
266
|
+
const requestCode = anchorPlan?.code ?? originalCode;
|
|
267
|
+
const requestInstructions = anchorPlan ? instructions + anchorPlan.instructionSuffix : instructions;
|
|
268
|
+
const message = `<instruction>${requestInstructions}</instruction>
|
|
269
|
+
<code>${requestCode}</code>
|
|
270
|
+
<update>${codeEdit}</update>`;
|
|
271
|
+
logger.debug("FastApply", "http_request", {
|
|
272
|
+
url: `${apiUrl}/v1/chat/completions`,
|
|
273
|
+
model,
|
|
274
|
+
filepath,
|
|
275
|
+
instruction_len: instructions.length,
|
|
276
|
+
original_len: originalCode.length,
|
|
277
|
+
request_code_len: requestCode.length,
|
|
278
|
+
code_edit_len: codeEdit.length,
|
|
279
|
+
anchor_count: anchorPlan?.anchorCount ?? 0,
|
|
280
|
+
unique_anchor_count: anchorPlan?.uniqueAnchorCount ?? 0
|
|
281
|
+
});
|
|
282
|
+
const startTime = Date.now();
|
|
283
|
+
const client = new OpenAI({
|
|
284
|
+
apiKey,
|
|
285
|
+
baseURL: `${apiUrl}/v1`,
|
|
286
|
+
timeout,
|
|
287
|
+
maxRetries: config.retryConfig?.maxRetries ?? 3,
|
|
288
|
+
defaultHeaders: {
|
|
289
|
+
"X-Morph-SDK-Version": SDK_VERSION,
|
|
290
|
+
...anchorPlan ? { "X-Morph-Apply-Context": "extralong" } : {}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
try {
|
|
294
|
+
const maxAttempts = anchorPlan?.hasStructuralValidation ? 2 : 1;
|
|
295
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
296
|
+
const response = await client.chat.completions.create({
|
|
297
|
+
model,
|
|
298
|
+
messages: [{ role: "user", content: message }],
|
|
299
|
+
stream: true
|
|
300
|
+
});
|
|
301
|
+
const completion = await collectCompletion(response);
|
|
302
|
+
if (completion.finishReason === "length") {
|
|
303
|
+
throw new FastApplyContextLengthError(completion.completionId);
|
|
304
|
+
}
|
|
305
|
+
let content = completion.content;
|
|
306
|
+
if (!content) {
|
|
307
|
+
throw new Error("Morph API returned empty response");
|
|
308
|
+
}
|
|
309
|
+
if (anchorPlan) {
|
|
310
|
+
try {
|
|
311
|
+
content = anchorPlan.expand(content);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
if (error instanceof FastApplyAnchorIntegrityError) {
|
|
314
|
+
if (attempt < maxAttempts) {
|
|
315
|
+
logger.warn("FastApply", "anchor_validation_retry", {
|
|
316
|
+
attempt,
|
|
317
|
+
completion_id: completion.completionId
|
|
318
|
+
});
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
throw new FastApplyAnchorIntegrityError(completion.completionId);
|
|
322
|
+
}
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const elapsed = Date.now() - startTime;
|
|
327
|
+
logger.debug("FastApply", "http_response", { status: 200, completion_id: completion.completionId, content_len: content.length, latency_ms: elapsed });
|
|
328
|
+
return { content, completionId: completion.completionId };
|
|
329
|
+
}
|
|
330
|
+
throw new FastApplyAnchorIntegrityError();
|
|
331
|
+
} catch (error) {
|
|
332
|
+
const elapsed = Date.now() - startTime;
|
|
333
|
+
const status = error?.status || error?.response?.status;
|
|
334
|
+
logger.error("FastApply", "http_error", {
|
|
335
|
+
status,
|
|
336
|
+
error: error?.message,
|
|
337
|
+
latency_ms: elapsed
|
|
338
|
+
});
|
|
339
|
+
if (status === 401) {
|
|
340
|
+
const err = new Error(
|
|
341
|
+
"Authentication failed: Your Morph API key is invalid or has been revoked. Please visit https://morphllm.com to get a valid API key, then update your MCP configuration."
|
|
342
|
+
);
|
|
343
|
+
err.status = 401;
|
|
344
|
+
throw err;
|
|
345
|
+
}
|
|
346
|
+
if (status === 429) {
|
|
347
|
+
const err = new Error(
|
|
348
|
+
"Rate limited: You've exceeded your Morph API usage limits. Please visit https://morphllm.com to check your plan and purchase additional credits."
|
|
349
|
+
);
|
|
350
|
+
err.status = 429;
|
|
351
|
+
throw err;
|
|
352
|
+
}
|
|
353
|
+
throw error;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
async function applyEdit(input, config = {}) {
|
|
357
|
+
const filepath = input.filepath || "file";
|
|
358
|
+
try {
|
|
359
|
+
logger.debug("FastApply", "apply_edit_start", { original_len: input.originalCode.length, code_edit_len: input.codeEdit.length });
|
|
360
|
+
const instruction = input.instruction ?? input.instructions ?? "";
|
|
361
|
+
const { content: mergedCode, completionId } = await callMorphAPI(
|
|
362
|
+
input.originalCode,
|
|
363
|
+
input.codeEdit,
|
|
364
|
+
instruction,
|
|
365
|
+
filepath,
|
|
366
|
+
config
|
|
367
|
+
);
|
|
368
|
+
const udiff = config.generateUdiff !== false ? generateUdiff(input.originalCode, mergedCode, filepath) : void 0;
|
|
369
|
+
const changes = countChanges(input.originalCode, mergedCode);
|
|
370
|
+
return {
|
|
371
|
+
success: true,
|
|
372
|
+
mergedCode,
|
|
373
|
+
udiff,
|
|
374
|
+
changes,
|
|
375
|
+
completionId
|
|
376
|
+
};
|
|
377
|
+
} catch (error) {
|
|
378
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
379
|
+
logger.error("FastApply", "apply_edit_error", { error: errorMessage });
|
|
380
|
+
const structuredError = error instanceof FastApplyContextLengthError || error instanceof FastApplyAnchorIntegrityError ? error : void 0;
|
|
381
|
+
return {
|
|
382
|
+
success: false,
|
|
383
|
+
changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
|
|
384
|
+
error: errorMessage,
|
|
385
|
+
errorCode: structuredError?.code,
|
|
386
|
+
completionId: structuredError?.completionId
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export {
|
|
392
|
+
FastApplyAnchorIntegrityError,
|
|
393
|
+
FastApplyContextLengthError,
|
|
394
|
+
generateUdiff,
|
|
395
|
+
countChanges,
|
|
396
|
+
callMorphAPI,
|
|
397
|
+
applyEdit
|
|
398
|
+
};
|
|
399
|
+
//# sourceMappingURL=chunk-KGHHK42W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/apply.ts","../tools/fastapply/anchors.ts"],"sourcesContent":["/**\n * Edge-compatible code application API\n *\n * This module works on:\n * - Node.js\n * - Cloudflare Workers\n * - Vercel Edge Functions\n * - Deno Deploy\n * - Browser environments\n *\n * For file-based operations, use executeEditFile from core.ts\n */\n\nimport { createTwoFilesPatch } from 'diff';\nimport OpenAI from 'openai';\nimport { SDK_VERSION } from '../../version.js';\nimport { logger } from '../../logger.js';\nimport {\n createAnchorCompactionPlan,\n DEFAULT_ANCHOR_COMPACTION_THRESHOLD,\n FastApplyAnchorIntegrityError,\n} from './anchors.js';\nimport type {\n EditChanges,\n ApplyEditInput,\n ApplyEditResult,\n ApplyEditConfig,\n} from './types.js';\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\nconst DEFAULT_TIMEOUT = 600000;\n\ntype CompletionChunk = {\n id?: string;\n choices?: Array<{\n delta?: { content?: string | null };\n finish_reason?: string | null;\n }>;\n};\n\ntype CompletionResponse = {\n id?: string;\n choices?: Array<{\n message?: { content?: string | null };\n finish_reason?: string | null;\n }>;\n};\n\nexport class FastApplyContextLengthError extends Error {\n readonly code = 'context_length_exceeded';\n readonly completionId?: string;\n\n constructor(completionId?: string) {\n super(\n 'Fast Apply exhausted its context window before producing the complete file. ' +\n 'Retry with a smaller input/update or use sparse anchors for unchanged code.'\n );\n this.name = 'FastApplyContextLengthError';\n this.completionId = completionId;\n }\n}\n\nexport { FastApplyAnchorIntegrityError } from './anchors.js';\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterable<CompletionChunk> {\n return typeof value === 'object' && value !== null && Symbol.asyncIterator in value;\n}\n\nasync function collectCompletion(\n response: unknown\n): Promise<{ content: string; completionId?: string; finishReason?: string | null }> {\n if (!isAsyncIterable(response)) {\n const completion = response as CompletionResponse;\n return {\n content: completion.choices?.[0]?.message?.content ?? '',\n completionId: completion.id,\n finishReason: completion.choices?.[0]?.finish_reason,\n };\n }\n\n const content: string[] = [];\n let completionId: string | undefined;\n let finishReason: string | null | undefined;\n\n for await (const chunk of response) {\n completionId = chunk.id ?? completionId;\n for (const choice of chunk.choices ?? []) {\n if (choice.delta?.content) {\n content.push(choice.delta.content);\n }\n if (choice.finish_reason !== undefined && choice.finish_reason !== null) {\n finishReason = choice.finish_reason;\n }\n }\n }\n\n return { content: content.join(''), completionId, finishReason };\n}\n\n/**\n * Generate a unified diff between two strings\n */\nexport function generateUdiff(\n original: string,\n modified: string,\n filepath: string\n): string {\n return createTwoFilesPatch(\n filepath,\n filepath,\n original,\n modified,\n 'Original',\n 'Modified'\n );\n}\n\n/**\n * Count changes from a unified diff\n */\nexport function countChanges(original: string, modified: string): EditChanges {\n const diff = generateUdiff(original, modified, 'file');\n const lines = diff.split('\\n');\n\n let linesAdded = 0;\n let linesRemoved = 0;\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n linesAdded++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n linesRemoved++;\n }\n }\n\n const linesModified = Math.min(linesAdded, linesRemoved);\n\n return {\n linesAdded: linesAdded - linesModified,\n linesRemoved: linesRemoved - linesModified,\n linesModified,\n };\n}\n\n/**\n * Call Morph Apply API to merge code edits\n * Uses OpenAI SDK for reliable connection handling, retries, and timeouts\n */\nexport async function callMorphAPI(\n originalCode: string,\n codeEdit: string,\n instructions: string,\n filepath: string,\n config: ApplyEditConfig\n): Promise<{ content: string; completionId?: string }> {\n const apiKey = config.morphApiKey || (typeof process !== 'undefined' ? process.env?.MORPH_API_KEY : undefined);\n const apiUrl = config.morphApiUrl || DEFAULT_API_URL;\n const useLarge = config.large ?? (typeof process !== 'undefined' ? process.env?.MORPH_LARGE_APPLY !== 'false' : true);\n const model = useLarge ? 'morph-v3-large' : 'morph-v3-fast';\n const timeout = config.timeout ?? DEFAULT_TIMEOUT;\n const debug = config.debug || false;\n\n if (!apiKey) {\n throw new Error(\n 'Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config.'\n );\n }\n\n const anchorThreshold = config.anchorCompactionThreshold\n ?? DEFAULT_ANCHOR_COMPACTION_THRESHOLD;\n const anchorPlan = config.anchorCompaction !== false\n && originalCode.length >= anchorThreshold\n ? createAnchorCompactionPlan(originalCode, [codeEdit, instructions])\n : undefined;\n const requestCode = anchorPlan?.code ?? originalCode;\n const requestInstructions = anchorPlan\n ? instructions + anchorPlan.instructionSuffix\n : instructions;\n\n // Format message with XML tags as per Morph Fast Apply spec\n const message = `<instruction>${requestInstructions}</instruction>\\n<code>${requestCode}</code>\\n<update>${codeEdit}</update>`;\n\n logger.debug('FastApply', 'http_request', {\n url: `${apiUrl}/v1/chat/completions`,\n model,\n filepath,\n instruction_len: instructions.length,\n original_len: originalCode.length,\n request_code_len: requestCode.length,\n code_edit_len: codeEdit.length,\n anchor_count: anchorPlan?.anchorCount ?? 0,\n unique_anchor_count: anchorPlan?.uniqueAnchorCount ?? 0,\n });\n\n const startTime = Date.now();\n\n const client = new OpenAI({\n apiKey,\n baseURL: `${apiUrl}/v1`,\n timeout,\n maxRetries: config.retryConfig?.maxRetries ?? 3,\n defaultHeaders: {\n 'X-Morph-SDK-Version': SDK_VERSION,\n ...(anchorPlan ? { 'X-Morph-Apply-Context': 'extralong' } : {}),\n },\n });\n\n try {\n const maxAttempts = anchorPlan?.hasStructuralValidation ? 2 : 1;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const response = await client.chat.completions.create({\n model,\n messages: [{ role: 'user', content: message }],\n stream: true,\n });\n const completion = await collectCompletion(response);\n\n if (completion.finishReason === 'length') {\n throw new FastApplyContextLengthError(completion.completionId);\n }\n\n let content = completion.content;\n if (!content) {\n throw new Error('Morph API returned empty response');\n }\n\n if (anchorPlan) {\n try {\n content = anchorPlan.expand(content);\n } catch (error) {\n if (error instanceof FastApplyAnchorIntegrityError) {\n if (attempt < maxAttempts) {\n logger.warn('FastApply', 'anchor_validation_retry', {\n attempt,\n completion_id: completion.completionId,\n });\n continue;\n }\n throw new FastApplyAnchorIntegrityError(completion.completionId);\n }\n throw error;\n }\n }\n\n const elapsed = Date.now() - startTime;\n logger.debug('FastApply', 'http_response', { status: 200, completion_id: completion.completionId, content_len: content.length, latency_ms: elapsed });\n\n return { content, completionId: completion.completionId };\n }\n\n throw new FastApplyAnchorIntegrityError();\n } catch (error: any) {\n const elapsed = Date.now() - startTime;\n const status = error?.status || error?.response?.status;\n logger.error('FastApply', 'http_error', {\n status,\n error: error?.message,\n latency_ms: elapsed,\n });\n\n if (status === 401) {\n const err = new Error(\n 'Authentication failed: Your Morph API key is invalid or has been revoked. ' +\n 'Please visit https://morphllm.com to get a valid API key, then update your MCP configuration.'\n );\n (err as any).status = 401;\n throw err;\n }\n\n if (status === 429) {\n const err = new Error(\n 'Rate limited: You\\'ve exceeded your Morph API usage limits. ' +\n 'Please visit https://morphllm.com to check your plan and purchase additional credits.'\n );\n (err as any).status = 429;\n throw err;\n }\n\n throw error;\n }\n}\n\n/**\n * Apply an edit to code directly without file I/O\n *\n * This is the edge-compatible code-in/code-out API that accepts code content directly\n * and returns the merged result without reading or writing any files.\n *\n * Works on Cloudflare Workers, Vercel Edge Functions, Deno, and browsers.\n *\n * @param input - Code and edit parameters\n * @param config - Optional configuration\n * @returns Result with merged code\n *\n * @example\n * ```typescript\n * import { applyEdit } from '@morphllm/morphsdk';\n *\n * const result = await applyEdit({\n * originalCode: fs.readFileSync('file.ts', 'utf-8'),\n * codeEdit: '// ... existing code ...\\nconst newVar = 42;\\n// ... existing code ...',\n * instructions: 'Add a new variable',\n * // filepath is accepted but does nothing\n * });\n *\n * if (result.success) {\n * fs.writeFileSync('file.ts', result.mergedCode);\n * }\n * ```\n */\nexport async function applyEdit(\n input: ApplyEditInput,\n config: ApplyEditConfig = {}\n): Promise<ApplyEditResult> {\n const filepath = input.filepath || 'file';\n\n try {\n logger.debug('FastApply', 'apply_edit_start', { original_len: input.originalCode.length, code_edit_len: input.codeEdit.length });\n\n const instruction = input.instruction ?? input.instructions ?? '';\n const { content: mergedCode, completionId } = await callMorphAPI(\n input.originalCode,\n input.codeEdit,\n instruction,\n filepath,\n config\n );\n\n const udiff = config.generateUdiff !== false\n ? generateUdiff(input.originalCode, mergedCode, filepath)\n : undefined;\n\n const changes = countChanges(input.originalCode, mergedCode);\n\n return {\n success: true,\n mergedCode,\n udiff,\n changes,\n completionId,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n logger.error('FastApply', 'apply_edit_error', { error: errorMessage });\n const structuredError = error instanceof FastApplyContextLengthError\n || error instanceof FastApplyAnchorIntegrityError\n ? error\n : undefined;\n\n return {\n success: false,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n errorCode: structuredError?.code,\n completionId: structuredError?.completionId,\n };\n }\n}\n","const DEFAULT_MIN_ANCHOR_LINE_LENGTH = 24;\n\nexport const DEFAULT_ANCHOR_COMPACTION_THRESHOLD = 128 * 1024;\n\nexport interface AnchorCompactionPlan {\n code: string;\n instructionSuffix: string;\n anchorCount: number;\n uniqueAnchorCount: number;\n hasStructuralValidation: boolean;\n expand: (content: string) => string;\n}\n\nexport class FastApplyAnchorIntegrityError extends Error {\n readonly code = 'anchor_integrity_failed';\n readonly completionId?: string;\n\n constructor(completionId?: string) {\n super(\n 'Fast Apply failed large-file anchor integrity checks. The partial result was discarded safely.'\n );\n this.name = 'FastApplyAnchorIntegrityError';\n this.completionId = completionId;\n }\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction findNamespace(values: string[]): number {\n for (let namespace = 0; namespace < Number.MAX_SAFE_INTEGER; namespace++) {\n const prefix = `⟪M${namespace}:`;\n if (values.every((value) => !value.includes(prefix))) {\n return namespace;\n }\n }\n\n throw new Error('Unable to allocate a Fast Apply anchor namespace');\n}\n\ninterface SourceUnit {\n value: string;\n label?: string;\n anchorable: boolean;\n}\n\nfunction htmlLabel(token: string): string {\n if (!token.startsWith('<')) return 'text';\n const match = token.match(/^<\\s*(!doctype|\\/?[a-zA-Z][\\w:-]*)/);\n return (match?.[1] ?? 'tag').toLowerCase();\n}\n\nfunction htmlTokenUnits(value: string, visibleTags = new Set<string>()): SourceUnit[] {\n return (value.match(/<[^>]*>|[^<]+/g) ?? [value]).map((token) => ({\n value: token,\n label: htmlLabel(token),\n anchorable: token.length >= DEFAULT_MIN_ANCHOR_LINE_LENGTH\n && !visibleTags.has(htmlLabel(token).replace(/^\\//, '')),\n }));\n}\n\nfunction sourceUnits(originalCode: string, editContext: string[]): SourceUnit[] {\n const trimmed = originalCode.trimStart().toLowerCase();\n const looksLikeHtml = (trimmed.startsWith('<!doctype') || trimmed.startsWith('<html'))\n && /<\\/html\\s*>/i.test(originalCode);\n\n if (looksLikeHtml) {\n const contextWords = new Set(\n editContext.join(' ').toLowerCase().match(/[a-z][\\w:-]*/g) ?? []\n );\n return htmlTokenUnits(originalCode, contextWords);\n }\n\n const parts = originalCode.split(/(\\r\\n|\\n|\\r)/);\n const units: SourceUnit[] = [];\n for (let index = 0; index < parts.length; index += 2) {\n const line = parts[index] ?? '';\n const lineEnding = parts[index + 1] ?? '';\n units.push({\n value: line,\n label: 'line',\n anchorable: line.length >= DEFAULT_MIN_ANCHOR_LINE_LENGTH,\n });\n if (lineEnding) {\n units.push({ value: lineEnding, anchorable: false });\n }\n }\n return units;\n}\n\nfunction copyCount(value: string): number | undefined {\n const words: Record<string, number> = {\n one: 1,\n two: 2,\n three: 3,\n four: 4,\n five: 5,\n six: 6,\n seven: 7,\n eight: 8,\n nine: 9,\n ten: 10,\n };\n return /^\\d+$/.test(value) ? Number(value) : words[value.toLowerCase()];\n}\n\nfunction structuralExpectation(originalCode: string, editContext: string[]) {\n const context = editContext.join(' ');\n const match = context.match(\n /(?:for every|for each|each)\\s+([a-z][\\w:-]*)[\\s\\S]{0,120}?add\\s+(one|two|three|four|five|six|seven|eight|nine|ten|\\d+)\\s+identical cop(?:y|ies)/i\n );\n if (!match) return undefined;\n\n const tag = match[1]!.toLowerCase();\n const addedCopies = copyCount(match[2]!);\n if (addedCopies === undefined) return undefined;\n\n const tagPattern = new RegExp(`<${escapeRegExp(tag)}(?:\\\\s|>)`, 'gi');\n const originalCount = originalCode.match(tagPattern)?.length ?? 0;\n if (originalCount === 0) return undefined;\n\n return { tag, expectedCount: originalCount * (addedCopies + 1) };\n}\n\n/**\n * Replace long source fragments with lossless placeholders. Definitions are sent once,\n * while the model can emit a small skeleton containing repeated/moved placeholders.\n */\nexport function createAnchorCompactionPlan(\n originalCode: string,\n collisionValues: string[] = []\n): AnchorCompactionPlan | undefined {\n const namespace = findNamespace([originalCode, ...collisionValues]);\n const expectation = structuralExpectation(originalCode, collisionValues);\n const markerPrefix = `⟪M${namespace}:`;\n const definitions = new Map<string, number>();\n const values: string[] = [];\n const markers: string[] = [];\n let anchorCount = 0;\n let skeleton = '';\n\n for (const unit of sourceUnits(originalCode, collisionValues)) {\n if (!unit.anchorable) {\n skeleton += unit.value;\n continue;\n }\n\n let id = definitions.get(unit.value);\n if (id === undefined) {\n id = values.length;\n definitions.set(unit.value, id);\n values.push(unit.value);\n markers.push(`${markerPrefix}${id}:${unit.label ?? 'unit'}⟫`);\n }\n\n skeleton += markers[id];\n anchorCount++;\n }\n\n if (anchorCount === 0 || skeleton.length >= originalCode.length) {\n return undefined;\n }\n\n const definitionsBegin = `⟪MORPH_DEFINITIONS_BEGIN_${namespace}⟫`;\n const definitionsEnd = `⟪MORPH_DEFINITIONS_END_${namespace}⟫`;\n const codeBegin = `⟪MORPH_CODE_BEGIN_${namespace}⟫`;\n const serializedDefinitions = values\n .map((value, id) => `${markers[id]}=${JSON.stringify(value)}`)\n .join('\\n');\n\n const code = [\n definitionsBegin,\n serializedDefinitions,\n definitionsEnd,\n codeBegin,\n skeleton,\n ].join('\\n');\n\n const instructionSuffix = `\n\nLARGE-FILE ANCHOR PROTOCOL:\nThe <code> block starts with an exact anchor definition table, then ${codeBegin}, then the source skeleton.\nEach ${markerPrefix}N:kind⟫ placeholder represents the exact source fragment in its matching JSON-string definition. The kind suffix describes its HTML tag, text, or source line.\nReturn only the updated source skeleton after ${codeBegin}; never return the definition table or protocol delimiters.\nCopy a placeholder exactly when its source fragment is unchanged. You may repeat, reorder, or remove placeholders when the requested edit requires it.\nTo modify an anchored fragment, output the modified source instead of its placeholder.\nDo not invent or alter placeholder IDs.`;\n\n const markerPattern = new RegExp(`${escapeRegExp(markerPrefix)}(\\\\d+):[^⟫]+⟫`, 'g');\n\n return {\n code,\n instructionSuffix,\n anchorCount,\n uniqueAnchorCount: values.length,\n hasStructuralValidation: expectation !== undefined,\n expand(content: string): string {\n const codeBeginIndex = content.lastIndexOf(codeBegin);\n const skeletonContent = codeBeginIndex >= 0\n ? content.slice(codeBeginIndex + codeBegin.length).replace(/^\\r?\\n/, '')\n : content;\n\n const expanded = skeletonContent.replace(markerPattern, (marker, idText: string) => {\n const id = Number(idText);\n const value = values[id];\n return value === undefined || markers[id] !== marker ? marker : value;\n });\n\n if (expanded.includes(markerPrefix)) {\n throw new FastApplyAnchorIntegrityError();\n }\n\n if (expectation) {\n const tagPattern = new RegExp(`<${escapeRegExp(expectation.tag)}(?:\\\\s|>)`, 'gi');\n const actualCount = expanded.match(tagPattern)?.length ?? 0;\n if (actualCount !== expectation.expectedCount) {\n throw new FastApplyAnchorIntegrityError();\n }\n }\n\n return expanded;\n },\n };\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,2BAA2B;AACpC,OAAO,YAAY;;;ACdnB,IAAM,iCAAiC;AAEhC,IAAM,sCAAsC,MAAM;AAWlD,IAAM,gCAAN,cAA4C,MAAM;AAAA,EAC9C,OAAO;AAAA,EACP;AAAA,EAET,YAAY,cAAuB;AACjC;AAAA,MACE;AAAA,IACF;AACA,SAAK,OAAO;AACZ,SAAK,eAAe;AAAA,EACtB;AACF;AAEA,SAAS,aAAa,OAAuB;AAC3C,SAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;AAEA,SAAS,cAAc,QAA0B;AAC/C,WAAS,YAAY,GAAG,YA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I;AACF,WAAO,MAAM,aAAa,oBAAoB,EAAE,cAAc,MAAM,aAAa,QAAQ,eAAe,MAAM,SAAS,OAAO,CAAC;AAE/H,UAAM,cAAc,MAAM,eAAe,MAAM,gBAAgB;AAC/D,UAAM,EAAE,SAAS,YAAY,aAAa,IAAI,MAAM;AAAA,MAClD,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,QAAQ,OAAO,kBAAkB,QACnC,cAAc,MAAM,cAAc,YAAY,QAAQ,IACtD;AAEJ,UAAM,UAAU,aAAa,MAAM,cAAc,UAAU;AAE3D,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,WAAO,MAAM,aAAa,oBAAoB,EAAE,OAAO,aAAa,CAAC;AACrE,UAAM,kBAAkB,iBAAiB,+BACpC,iBAAiB,gCAClB,QACA;AAEJ,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,EAAE;AAAA,MAC5D,OAAO;AAAA,MACP,WAAW,iBAAiB;AAAA,MAC5B,cAAc,iBAAiB;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-2HMEZZKK.js";
|
|
5
5
|
import {
|
|
6
6
|
executeBrowserTask
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PUTYJ2ET.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
createBrowserTool,
|
|
78
78
|
anthropic_exports
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-MFAIFUFK.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readAllLines
|
|
3
|
+
} from "./chunk-G2RSY56Q.js";
|
|
1
4
|
import {
|
|
2
5
|
fixPathRepetition,
|
|
3
6
|
isSymlink,
|
|
@@ -8,9 +11,6 @@ import {
|
|
|
8
11
|
import {
|
|
9
12
|
runRipgrep
|
|
10
13
|
} from "./chunk-TPP2UGQP.js";
|
|
11
|
-
import {
|
|
12
|
-
readAllLines
|
|
13
|
-
} from "./chunk-G2RSY56Q.js";
|
|
14
14
|
import {
|
|
15
15
|
AGENT_CONFIG,
|
|
16
16
|
DEFAULT_EXCLUDES
|
|
@@ -341,4 +341,4 @@ Details: ${res.stderr}` : ""}`
|
|
|
341
341
|
export {
|
|
342
342
|
LocalRipgrepProvider
|
|
343
343
|
};
|
|
344
|
-
//# sourceMappingURL=chunk-
|
|
344
|
+
//# sourceMappingURL=chunk-OPNTDMHH.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphAPIClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-POUBLP4R.js";
|
|
4
4
|
import {
|
|
5
5
|
MorphError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JIHDKRQW.js";
|
|
7
7
|
import {
|
|
8
8
|
APIResource
|
|
9
9
|
} from "./chunk-LKFZBBTD.js";
|
|
@@ -199,4 +199,4 @@ export {
|
|
|
199
199
|
ReflexClient,
|
|
200
200
|
ReflexJobsResource
|
|
201
201
|
};
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-PDSLRLYI.js.map
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "./chunk-F3NCFNUX.js";
|
|
4
4
|
import {
|
|
5
5
|
toMorphError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-33WVJLIT.js";
|
|
7
7
|
import {
|
|
8
8
|
MorphError,
|
|
9
9
|
fetchWithRetry,
|
|
10
10
|
withTimeout
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JIHDKRQW.js";
|
|
12
12
|
import {
|
|
13
13
|
SDK_VERSION
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-A2SC5ZOG.js";
|
|
15
15
|
|
|
16
16
|
// core/client.ts
|
|
17
17
|
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
@@ -117,4 +117,4 @@ var MorphAPIClient = class {
|
|
|
117
117
|
export {
|
|
118
118
|
MorphAPIClient
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-POUBLP4R.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphAPIClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-POUBLP4R.js";
|
|
4
4
|
import {
|
|
5
5
|
logger
|
|
6
6
|
} from "./chunk-F3NCFNUX.js";
|
|
7
7
|
import {
|
|
8
8
|
MorphError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JIHDKRQW.js";
|
|
10
10
|
import {
|
|
11
11
|
APIResource
|
|
12
12
|
} from "./chunk-LKFZBBTD.js";
|
|
@@ -174,4 +174,4 @@ export {
|
|
|
174
174
|
RawRouter,
|
|
175
175
|
RouterClassifier
|
|
176
176
|
};
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-PPNJY7P3.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProfilesClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-74LJOCDW.js";
|
|
4
4
|
import {
|
|
5
5
|
buildEmbedCode,
|
|
6
6
|
buildLiveIframe,
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
} from "./chunk-YTYCHRQ2.js";
|
|
10
10
|
import {
|
|
11
11
|
MorphAPIClient
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-POUBLP4R.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
15
|
} from "./chunk-F3NCFNUX.js";
|
|
16
16
|
import {
|
|
17
17
|
fetchWithRetry,
|
|
18
18
|
withTimeout
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JIHDKRQW.js";
|
|
20
20
|
import {
|
|
21
21
|
APIResource
|
|
22
22
|
} from "./chunk-LKFZBBTD.js";
|
|
@@ -619,4 +619,4 @@ export {
|
|
|
619
619
|
getWebp,
|
|
620
620
|
checkHealth
|
|
621
621
|
};
|
|
622
|
-
//# sourceMappingURL=chunk-
|
|
622
|
+
//# sourceMappingURL=chunk-PUTYJ2ET.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-63WE2C5R.js";
|
|
5
5
|
import {
|
|
6
6
|
executeEditFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GWXMT3S2.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -79,4 +79,4 @@ export {
|
|
|
79
79
|
getSystemPrompt,
|
|
80
80
|
anthropic_exports
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-QJSGHJ7D.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-2HMEZZKK.js";
|
|
4
4
|
import {
|
|
5
5
|
executeBrowserTask
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PUTYJ2ET.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -54,4 +54,4 @@ export {
|
|
|
54
54
|
browserTool,
|
|
55
55
|
vercel_exports
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-S3V22W7M.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphAPIClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-POUBLP4R.js";
|
|
4
4
|
import {
|
|
5
5
|
APIResource
|
|
6
6
|
} from "./chunk-LKFZBBTD.js";
|
|
@@ -558,4 +558,4 @@ var MorphGit = class extends APIResource {
|
|
|
558
558
|
export {
|
|
559
559
|
MorphGit
|
|
560
560
|
};
|
|
561
|
-
//# sourceMappingURL=chunk-
|
|
561
|
+
//# sourceMappingURL=chunk-SU5FOI4R.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-2HMEZZKK.js";
|
|
5
5
|
import {
|
|
6
6
|
executeBrowserTask
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PUTYJ2ET.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -93,4 +93,4 @@ export {
|
|
|
93
93
|
createBrowserTool,
|
|
94
94
|
openai_exports
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-TAQLWNIF.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
executeGitHubReadFile,
|
|
9
9
|
executeToolCall,
|
|
10
10
|
executeToolCallStreaming
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VYDKGM7F.js";
|
|
12
12
|
|
|
13
13
|
// tools/warp_grep/vercel.ts
|
|
14
14
|
import { tool } from "ai";
|
|
@@ -115,4 +115,4 @@ export {
|
|
|
115
115
|
createGitHubReadFileTool,
|
|
116
116
|
vercel_default
|
|
117
117
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-TT37PYOQ.js.map
|