@morphllm/morphsdk 0.2.162 → 0.2.164
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-OGMHU4PJ.js → chunk-3HVVQHHX.js} +9 -2
- package/dist/chunk-3HVVQHHX.js.map +1 -0
- package/dist/{chunk-JVKGSMEF.js → chunk-3NWJ74R4.js} +2 -2
- package/dist/{chunk-XUV5B27P.js → chunk-4DDD65QF.js} +2 -2
- package/dist/{chunk-DRTPCCEI.js → chunk-4FZXI4FI.js} +2 -2
- package/dist/chunk-5AM23TC7.js +42 -0
- package/dist/chunk-5AM23TC7.js.map +1 -0
- package/dist/{chunk-CNFHKQ42.js → chunk-BFNH475L.js} +2 -2
- package/dist/{chunk-ZG3YLRR5.js → chunk-CFCNSELX.js} +8 -2
- package/dist/chunk-CFCNSELX.js.map +1 -0
- package/dist/{chunk-NKUGRAYU.js → chunk-CRU3FQ54.js} +2 -2
- package/dist/{chunk-DXMNKPB6.js → chunk-DKPC5ZVX.js} +2 -2
- package/dist/{chunk-PWGBAVQ5.js → chunk-DVCIADH3.js} +2 -2
- package/dist/{chunk-LECHLXI4.js → chunk-EAIAZ2GD.js} +17 -6
- package/dist/chunk-EAIAZ2GD.js.map +1 -0
- package/dist/{chunk-4GQNYJBB.js → chunk-ECELX2KF.js} +9 -12
- package/dist/chunk-ECELX2KF.js.map +1 -0
- package/dist/{chunk-YRHM3RCQ.js → chunk-EPYCKNQ3.js} +2 -2
- package/dist/{chunk-OOE2TKKY.js → chunk-MRYULNMU.js} +12 -21
- package/dist/chunk-MRYULNMU.js.map +1 -0
- package/dist/{chunk-4U5JFT6X.js → chunk-MVMB6GBY.js} +33 -26
- package/dist/{chunk-4U5JFT6X.js.map → chunk-MVMB6GBY.js.map} +1 -1
- package/dist/{chunk-UKT3CKC7.js → chunk-N4SSQFYN.js} +2 -2
- package/dist/{chunk-7QMX45QD.js → chunk-NKFMGSUH.js} +33 -6
- package/dist/chunk-NKFMGSUH.js.map +1 -0
- package/dist/{chunk-LZQBVEY2.js → chunk-NMRQWMTH.js} +35 -27
- package/dist/chunk-NMRQWMTH.js.map +1 -0
- package/dist/{chunk-UVRC4LKZ.js → chunk-Q7XZ6JGW.js} +2 -2
- package/dist/{chunk-UZX7SY33.js → chunk-RR7P4SMP.js} +2 -2
- package/dist/{chunk-UETFIUIG.js → chunk-VCFUU5TL.js} +2 -2
- package/dist/{chunk-5XTA7GCY.js → chunk-VDMF4WWF.js} +2 -2
- package/dist/{chunk-YBKT2UOK.js → chunk-XULEBEBX.js} +2 -2
- package/dist/{chunk-Y4NYT5L6.js → chunk-YOF3N2EL.js} +11 -26
- package/dist/chunk-YOF3N2EL.js.map +1 -0
- package/dist/{chunk-4Q6VFODP.js → chunk-ZEEHRQYJ.js} +2 -2
- package/dist/{chunk-VQSLLYKE.js → chunk-ZEMLB2KV.js} +2 -2
- package/dist/client.cjs +185 -115
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +25 -24
- package/dist/edge.cjs +83 -50
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +5 -4
- package/dist/index.cjs +187 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -28
- package/dist/modelrouter/core.cjs +51 -25
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +4 -3
- package/dist/modelrouter/index.cjs +51 -25
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +4 -3
- package/dist/subagents/anthropic.cjs +86 -12
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +5 -4
- package/dist/subagents/vercel.cjs +86 -12
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +5 -4
- package/dist/tools/browser/anthropic.cjs +48 -9
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +6 -5
- package/dist/tools/browser/core.cjs +51 -19
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +5 -4
- package/dist/tools/browser/index.cjs +51 -19
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +10 -9
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/openai.cjs +48 -9
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +6 -5
- package/dist/tools/browser/profiles/core.cjs +7 -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 +7 -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 +48 -9
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +6 -5
- package/dist/tools/codebase_search/anthropic.cjs +49 -11
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +5 -4
- package/dist/tools/codebase_search/core.cjs +49 -11
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +4 -3
- package/dist/tools/codebase_search/index.cjs +49 -11
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +9 -8
- package/dist/tools/codebase_search/openai.cjs +49 -11
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +5 -4
- package/dist/tools/codebase_search/vercel.cjs +49 -11
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +5 -4
- package/dist/tools/fastapply/anthropic.cjs +95 -31
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +5 -4
- package/dist/tools/fastapply/apply.cjs +75 -26
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +3 -2
- package/dist/tools/fastapply/core.cjs +95 -31
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +4 -3
- package/dist/tools/fastapply/index.cjs +95 -31
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +9 -8
- package/dist/tools/fastapply/openai.cjs +95 -31
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +5 -4
- package/dist/tools/fastapply/vercel.cjs +95 -31
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +5 -4
- package/dist/tools/index.cjs +95 -31
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +9 -8
- package/dist/tools/utils/resilience.cjs +7 -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 +75 -5
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -2
- package/dist/tools/warp_grep/anthropic.cjs +86 -12
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +5 -4
- package/dist/tools/warp_grep/client.cjs +86 -12
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +4 -3
- package/dist/tools/warp_grep/gemini.cjs +86 -12
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +4 -3
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +86 -12
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +4 -3
- package/dist/tools/warp_grep/openai.cjs +86 -12
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +5 -4
- package/dist/tools/warp_grep/vercel.cjs +86 -12
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.js +5 -4
- package/dist/version.cjs +7 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -1
- package/dist/chunk-4GQNYJBB.js.map +0 -1
- package/dist/chunk-7QMX45QD.js.map +0 -1
- package/dist/chunk-LECHLXI4.js.map +0 -1
- package/dist/chunk-LZQBVEY2.js.map +0 -1
- package/dist/chunk-OGMHU4PJ.js.map +0 -1
- package/dist/chunk-OOE2TKKY.js.map +0 -1
- package/dist/chunk-Y4NYT5L6.js.map +0 -1
- package/dist/chunk-ZG3YLRR5.js.map +0 -1
- package/dist/{chunk-JVKGSMEF.js.map → chunk-3NWJ74R4.js.map} +0 -0
- package/dist/{chunk-XUV5B27P.js.map → chunk-4DDD65QF.js.map} +0 -0
- package/dist/{chunk-DRTPCCEI.js.map → chunk-4FZXI4FI.js.map} +0 -0
- package/dist/{chunk-CNFHKQ42.js.map → chunk-BFNH475L.js.map} +0 -0
- package/dist/{chunk-NKUGRAYU.js.map → chunk-CRU3FQ54.js.map} +0 -0
- package/dist/{chunk-DXMNKPB6.js.map → chunk-DKPC5ZVX.js.map} +0 -0
- package/dist/{chunk-PWGBAVQ5.js.map → chunk-DVCIADH3.js.map} +0 -0
- package/dist/{chunk-YRHM3RCQ.js.map → chunk-EPYCKNQ3.js.map} +0 -0
- package/dist/{chunk-UKT3CKC7.js.map → chunk-N4SSQFYN.js.map} +0 -0
- package/dist/{chunk-UVRC4LKZ.js.map → chunk-Q7XZ6JGW.js.map} +0 -0
- package/dist/{chunk-UZX7SY33.js.map → chunk-RR7P4SMP.js.map} +0 -0
- package/dist/{chunk-UETFIUIG.js.map → chunk-VCFUU5TL.js.map} +0 -0
- package/dist/{chunk-5XTA7GCY.js.map → chunk-VDMF4WWF.js.map} +0 -0
- package/dist/{chunk-YBKT2UOK.js.map → chunk-XULEBEBX.js.map} +0 -0
- package/dist/{chunk-4Q6VFODP.js.map → chunk-ZEEHRQYJ.js.map} +0 -0
- package/dist/{chunk-VQSLLYKE.js.map → chunk-ZEMLB2KV.js.map} +0 -0
- package/dist/{client-PkB7g9SA.d.ts → client-DsAAqupx.d.ts} +1 -1
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
execute,
|
|
6
6
|
openai_default,
|
|
7
7
|
warpGrepTool
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-VCFUU5TL.js";
|
|
9
9
|
import "../../chunk-Q6QCHAMD.js";
|
|
10
10
|
import {
|
|
11
11
|
formatResult
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-3HVVQHHX.js";
|
|
13
13
|
import "../../chunk-63VHBANJ.js";
|
|
14
|
-
import "../../chunk-
|
|
14
|
+
import "../../chunk-NKFMGSUH.js";
|
|
15
15
|
import "../../chunk-GVGJIXV2.js";
|
|
16
16
|
import "../../chunk-B3AKP3RA.js";
|
|
17
17
|
import "../../chunk-VNAGVCSP.js";
|
|
@@ -19,7 +19,8 @@ import "../../chunk-FBRNUWEB.js";
|
|
|
19
19
|
import "../../chunk-I3J46TSB.js";
|
|
20
20
|
import "../../chunk-GLQWEINZ.js";
|
|
21
21
|
import "../../chunk-SCVWDNQP.js";
|
|
22
|
-
import "../../chunk-
|
|
22
|
+
import "../../chunk-5AM23TC7.js";
|
|
23
|
+
import "../../chunk-CFCNSELX.js";
|
|
23
24
|
import "../../chunk-PZ5AY32C.js";
|
|
24
25
|
export {
|
|
25
26
|
createGitHubReadFileTool,
|
|
@@ -220,7 +220,7 @@ function toRepoRelative(repoRoot, absPath) {
|
|
|
220
220
|
}
|
|
221
221
|
function isSymlink(p) {
|
|
222
222
|
try {
|
|
223
|
-
const st =
|
|
223
|
+
const st = import_fs2.default.lstatSync(p);
|
|
224
224
|
return st.isSymbolicLink();
|
|
225
225
|
} catch {
|
|
226
226
|
return false;
|
|
@@ -243,13 +243,13 @@ function fixPathRepetition(fullPath) {
|
|
|
243
243
|
}
|
|
244
244
|
function isTextualFile(filePath, maxBytes = 2e6) {
|
|
245
245
|
try {
|
|
246
|
-
const st =
|
|
246
|
+
const st = import_fs2.default.statSync(filePath);
|
|
247
247
|
if (!st.isFile()) return false;
|
|
248
248
|
if (st.size > maxBytes) return false;
|
|
249
|
-
const fd =
|
|
249
|
+
const fd = import_fs2.default.openSync(filePath, "r");
|
|
250
250
|
const buf = Buffer.alloc(512);
|
|
251
|
-
const read =
|
|
252
|
-
|
|
251
|
+
const read = import_fs2.default.readSync(fd, buf, 0, buf.length, 0);
|
|
252
|
+
import_fs2.default.closeSync(fd);
|
|
253
253
|
for (let i = 0; i < read; i++) {
|
|
254
254
|
const c = buf[i];
|
|
255
255
|
if (c === 0) return false;
|
|
@@ -259,11 +259,11 @@ function isTextualFile(filePath, maxBytes = 2e6) {
|
|
|
259
259
|
return false;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
var
|
|
262
|
+
var import_fs2, import_path4;
|
|
263
263
|
var init_paths = __esm({
|
|
264
264
|
"tools/warp_grep/utils/paths.ts"() {
|
|
265
265
|
"use strict";
|
|
266
|
-
|
|
266
|
+
import_fs2 = __toESM(require("fs"), 1);
|
|
267
267
|
import_path4 = __toESM(require("path"), 1);
|
|
268
268
|
}
|
|
269
269
|
});
|
|
@@ -942,7 +942,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
942
942
|
// package.json
|
|
943
943
|
var package_default = {
|
|
944
944
|
name: "@morphllm/morphsdk",
|
|
945
|
-
version: "0.2.
|
|
945
|
+
version: "0.2.164",
|
|
946
946
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
947
947
|
type: "module",
|
|
948
948
|
main: "./dist/index.cjs",
|
|
@@ -954,6 +954,11 @@ var package_default = {
|
|
|
954
954
|
import: "./dist/index.js",
|
|
955
955
|
require: "./dist/index.cjs"
|
|
956
956
|
},
|
|
957
|
+
"./logger": {
|
|
958
|
+
types: "./dist/logger.d.ts",
|
|
959
|
+
import: "./dist/logger.js",
|
|
960
|
+
require: "./dist/logger.cjs"
|
|
961
|
+
},
|
|
957
962
|
"./edge": {
|
|
958
963
|
types: "./dist/edge.d.ts",
|
|
959
964
|
import: "./dist/edge.js",
|
|
@@ -1112,6 +1117,7 @@ var package_default = {
|
|
|
1112
1117
|
"test:browser": "vitest run browser",
|
|
1113
1118
|
"test:agent": "npx tsx tests/fullAgentTest.ts",
|
|
1114
1119
|
"test:integration": "npx tsx tests/fullIntegrationTest.ts",
|
|
1120
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
1115
1121
|
"release:patch": "npm version patch && npm publish",
|
|
1116
1122
|
"release:minor": "npm version minor && npm publish",
|
|
1117
1123
|
"release:major": "npm version major && npm publish"
|
|
@@ -1182,6 +1188,46 @@ var SDK_VERSION = package_default.version;
|
|
|
1182
1188
|
|
|
1183
1189
|
// tools/warp_grep/agent/runner.ts
|
|
1184
1190
|
var import_path3 = __toESM(require("path"), 1);
|
|
1191
|
+
|
|
1192
|
+
// logger.ts
|
|
1193
|
+
var import_fs = require("fs");
|
|
1194
|
+
var MorphLogger = class {
|
|
1195
|
+
enabled;
|
|
1196
|
+
fileStream;
|
|
1197
|
+
constructor() {
|
|
1198
|
+
this.enabled = process.env.MORPH_DEBUG === "1" || !!process.env.MORPH_LOG_FILE;
|
|
1199
|
+
const f = process.env.MORPH_LOG_FILE;
|
|
1200
|
+
this.fileStream = f ? (0, import_fs.createWriteStream)(f, { flags: "a" }) : null;
|
|
1201
|
+
}
|
|
1202
|
+
debug(component, msg, data) {
|
|
1203
|
+
this._log("debug", component, msg, data);
|
|
1204
|
+
}
|
|
1205
|
+
info(component, msg, data) {
|
|
1206
|
+
this._log("info", component, msg, data);
|
|
1207
|
+
}
|
|
1208
|
+
warn(component, msg, data) {
|
|
1209
|
+
this._log("warn", component, msg, data);
|
|
1210
|
+
}
|
|
1211
|
+
error(component, msg, data) {
|
|
1212
|
+
this._log("error", component, msg, data);
|
|
1213
|
+
}
|
|
1214
|
+
enable() {
|
|
1215
|
+
this.enabled = true;
|
|
1216
|
+
}
|
|
1217
|
+
get isEnabled() {
|
|
1218
|
+
return this.enabled;
|
|
1219
|
+
}
|
|
1220
|
+
_log(level, component, msg, data) {
|
|
1221
|
+
if (level !== "error" && !this.enabled) return;
|
|
1222
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
1223
|
+
const prefix = `[${ts}] [${level.toUpperCase()}] [${component}]`;
|
|
1224
|
+
console.error(data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`);
|
|
1225
|
+
this.fileStream?.write(JSON.stringify({ ts, level, component, msg, ...data && { data } }) + "\n");
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
var logger = new MorphLogger();
|
|
1229
|
+
|
|
1230
|
+
// tools/warp_grep/agent/runner.ts
|
|
1185
1231
|
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
1186
1232
|
var TOOL_SPECS = [
|
|
1187
1233
|
{
|
|
@@ -1304,6 +1350,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
1304
1350
|
defaultHeaders: { "X-Morph-SDK-Version": SDK_VERSION }
|
|
1305
1351
|
});
|
|
1306
1352
|
const MAX_EMPTY_RETRIES = 1;
|
|
1353
|
+
logger.debug("WarpGrep", "model_call", { url: baseURL, model, message_count: messages.length });
|
|
1354
|
+
const callStartTime = Date.now();
|
|
1307
1355
|
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
1308
1356
|
let data;
|
|
1309
1357
|
try {
|
|
@@ -1316,10 +1364,16 @@ async function callModel(messages, model, options = {}) {
|
|
|
1316
1364
|
...options.search_type ? { search_type: options.search_type } : {}
|
|
1317
1365
|
});
|
|
1318
1366
|
} catch (error) {
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1367
|
+
const callLatencyMs = Date.now() - callStartTime;
|
|
1368
|
+
if (error instanceof import_openai.default.APIError) {
|
|
1369
|
+
logger.error("WarpGrep", "model_call_error", { status: error.status, error: error.message, latency_ms: callLatencyMs });
|
|
1370
|
+
if (error.status === 404) {
|
|
1371
|
+
const defaultMsg = "The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp";
|
|
1372
|
+
const errorText = error.message?.trim();
|
|
1373
|
+
throw new Error(errorText || defaultMsg);
|
|
1374
|
+
}
|
|
1375
|
+
} else {
|
|
1376
|
+
logger.error("WarpGrep", "model_call_error", { status: void 0, error: error instanceof Error ? error.message : String(error), latency_ms: callLatencyMs });
|
|
1323
1377
|
}
|
|
1324
1378
|
throw error;
|
|
1325
1379
|
}
|
|
@@ -1338,6 +1392,7 @@ async function callModel(messages, model, options = {}) {
|
|
|
1338
1392
|
function: { name: tc.function.name, arguments: tc.function.arguments }
|
|
1339
1393
|
}));
|
|
1340
1394
|
if (message.content || toolCalls.length > 0) {
|
|
1395
|
+
logger.debug("WarpGrep", "model_call_complete", { latency_ms: Date.now() - callStartTime, tool_calls_count: toolCalls.length, finish_reason: choice?.finish_reason ?? "unknown" });
|
|
1341
1396
|
return { content: message.content ?? null, tool_calls: toolCalls };
|
|
1342
1397
|
}
|
|
1343
1398
|
if (attempt === MAX_EMPTY_RETRIES) {
|
|
@@ -1408,9 +1463,11 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1408
1463
|
const model = config.model || DEFAULT_MODEL;
|
|
1409
1464
|
const messages = [];
|
|
1410
1465
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1466
|
+
logger.debug("WarpGrep", "session_start", { search_term: config.searchTerm, model, max_turns: maxTurns });
|
|
1411
1467
|
const initialStateStart = Date.now();
|
|
1412
1468
|
const initialState = await buildInitialState(repoRoot, config.searchTerm, config.provider, { search_type: config.search_type });
|
|
1413
1469
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1470
|
+
logger.debug("WarpGrep", "initial_state", { system_prompt_len: initialState.length, user_message_len: initialState.length });
|
|
1414
1471
|
messages.push({ role: "user", content: initialState });
|
|
1415
1472
|
const provider = config.provider;
|
|
1416
1473
|
const errors = [];
|
|
@@ -1418,7 +1475,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1418
1475
|
let terminationReason = "terminated";
|
|
1419
1476
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1420
1477
|
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1478
|
+
logger.debug("WarpGrep", "turn_start", { turn, message_count: messages.length });
|
|
1479
|
+
const beforeChars = messages.reduce((sum, m) => sum + (typeof m.content === "string" ? m.content.length : 0), 0);
|
|
1421
1480
|
enforceContextLimit(messages);
|
|
1481
|
+
const afterChars = messages.reduce((sum, m) => sum + (typeof m.content === "string" ? m.content.length : 0), 0);
|
|
1482
|
+
if (afterChars < beforeChars) {
|
|
1483
|
+
logger.debug("WarpGrep", "context_truncated", { before_chars: beforeChars, after_chars: afterChars });
|
|
1484
|
+
}
|
|
1422
1485
|
const modelCallStart = Date.now();
|
|
1423
1486
|
const response = await callModel(messages, model, {
|
|
1424
1487
|
morphApiKey: config.morphApiKey,
|
|
@@ -1429,6 +1492,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1429
1492
|
}).catch((e) => {
|
|
1430
1493
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1431
1494
|
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1495
|
+
logger.error("WarpGrep", "error", { turn, error: errMsg, phase: "model_call" });
|
|
1432
1496
|
errors.push({ message: errMsg });
|
|
1433
1497
|
return null;
|
|
1434
1498
|
});
|
|
@@ -1438,6 +1502,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1438
1502
|
break;
|
|
1439
1503
|
}
|
|
1440
1504
|
const toolCalls = response.tool_calls;
|
|
1505
|
+
logger.debug("WarpGrep", "model_response", { turn, tool_calls: toolCalls.map((tc) => tc.function.name), latency_ms: turnMetrics.morph_api_ms });
|
|
1441
1506
|
messages.push({
|
|
1442
1507
|
role: "assistant",
|
|
1443
1508
|
content: response.content,
|
|
@@ -1464,6 +1529,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1464
1529
|
const files = parseFinishFiles(filesStr);
|
|
1465
1530
|
finishMeta = { files };
|
|
1466
1531
|
terminationReason = "completed";
|
|
1532
|
+
logger.debug("WarpGrep", "finish", { turns: turn, files: files.map((f) => f.path) });
|
|
1467
1533
|
if (files.length === 0) {
|
|
1468
1534
|
const payload2 = filesStr || "No relevant code found.";
|
|
1469
1535
|
timings.turns.push(turnMetrics);
|
|
@@ -1482,7 +1548,11 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1482
1548
|
const results = await Promise.all(
|
|
1483
1549
|
toolCalls.map(async (tc) => {
|
|
1484
1550
|
const args = safeParseJSON(tc.function.arguments);
|
|
1551
|
+
const argsSummary = Object.fromEntries(Object.entries(args).map(([k, v]) => [k, typeof v === "string" && v.length > 100 ? v.slice(0, 100) + "..." : v]));
|
|
1552
|
+
logger.debug("WarpGrep", "tool_exec", { turn, tool: tc.function.name, args_summary: argsSummary });
|
|
1553
|
+
const toolStart = Date.now();
|
|
1485
1554
|
const output = await executeTool(provider, tc.function.name, args, repoRoot).catch((err) => String(err));
|
|
1555
|
+
logger.debug("WarpGrep", "tool_result", { turn, tool: tc.function.name, result_len: output.length, latency_ms: Date.now() - toolStart });
|
|
1486
1556
|
return { tool_call_id: tc.id, content: output };
|
|
1487
1557
|
})
|
|
1488
1558
|
);
|
|
@@ -1990,12 +2060,16 @@ var WarpGrepClient = class {
|
|
|
1990
2060
|
async _resolveGitHubRepo(input) {
|
|
1991
2061
|
const { owner, repo } = parseGitHubUrl(input.github);
|
|
1992
2062
|
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
2063
|
+
logger.debug("WarpGrep", "github_resolve", { owner_repo: `${owner}/${repo}`, branch: input.branch });
|
|
2064
|
+
const resolveStart = Date.now();
|
|
1993
2065
|
const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);
|
|
1994
2066
|
if (!importRes.ok) {
|
|
1995
2067
|
const text = await importRes.text().catch(() => importRes.statusText);
|
|
2068
|
+
logger.error("WarpGrep", "github_resolve_failed", { owner_repo: `${owner}/${repo}`, status: importRes.status, error: text });
|
|
1996
2069
|
throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);
|
|
1997
2070
|
}
|
|
1998
2071
|
const { repoId, defaultBranch } = await importRes.json();
|
|
2072
|
+
logger.debug("WarpGrep", "github_repo_fetched", { repo_id: repoId, default_branch: defaultBranch, latency_ms: Date.now() - resolveStart });
|
|
1999
2073
|
return {
|
|
2000
2074
|
repo,
|
|
2001
2075
|
remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch })
|