@morphllm/morphsdk 0.2.161 → 0.2.163
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-JIPYZNK3.js → chunk-2KDJKRZG.js} +2 -2
- package/dist/chunk-5AM23TC7.js +42 -0
- package/dist/chunk-5AM23TC7.js.map +1 -0
- package/dist/{chunk-PQXJ32G4.js → chunk-5BMWOPYW.js} +2 -2
- package/dist/{chunk-F2SBKBBS.js → chunk-5FYJMU6H.js} +2 -2
- package/dist/{chunk-KP3CAEH5.js → chunk-6PFGM4CM.js} +2 -2
- package/dist/{chunk-5R3QCYHW.js → chunk-6YOSNPHS.js} +2 -2
- package/dist/{chunk-G3E75GPM.js → chunk-6YTCBLRI.js} +2 -2
- package/dist/{chunk-2CE4PG2F.js → chunk-COUYHTIO.js} +2 -2
- package/dist/{chunk-KCJRKSMG.js → chunk-CUMC7Z5R.js} +11 -26
- package/dist/chunk-CUMC7Z5R.js.map +1 -0
- package/dist/{chunk-HDZ4XYUX.js → chunk-EJBWDGTH.js} +2 -2
- package/dist/{chunk-DKQMGEHV.js → chunk-FNCPPCPV.js} +2 -2
- package/dist/{chunk-IHSLH64T.js → chunk-FQXUOZBX.js} +9 -12
- package/dist/chunk-FQXUOZBX.js.map +1 -0
- package/dist/{chunk-27VVVW57.js → chunk-HBH56DLN.js} +2 -2
- package/dist/{chunk-5GVI7L4O.js → chunk-HFN3YCF4.js} +2 -2
- package/dist/{chunk-QQBEGCX2.js → chunk-HMGC7FLZ.js} +2 -2
- package/dist/{chunk-KF2AYKGJ.js → chunk-KHR4CZMX.js} +24 -17
- package/dist/{chunk-KF2AYKGJ.js.map → chunk-KHR4CZMX.js.map} +1 -1
- package/dist/{chunk-LGF2WTXG.js → chunk-LSHQISAX.js} +9 -2
- package/dist/chunk-LSHQISAX.js.map +1 -0
- package/dist/{chunk-L6WYOSFK.js → chunk-LST7MZOZ.js} +7 -2
- package/dist/chunk-LST7MZOZ.js.map +1 -0
- package/dist/{chunk-63JAZOI3.js → chunk-LW5EAPZ6.js} +2 -2
- package/dist/{chunk-N4EFVT45.js → chunk-NNATBEOF.js} +2 -2
- package/dist/{chunk-RZS5DQAX.js → chunk-OKFW4KGU.js} +2 -2
- package/dist/{chunk-QR34LBOS.js → chunk-QXGOEDZD.js} +2 -2
- package/dist/{chunk-442YHCTX.js → chunk-SELI567A.js} +12 -21
- package/dist/chunk-SELI567A.js.map +1 -0
- package/dist/{chunk-VM4TVOBU.js → chunk-VMNEYCFP.js} +17 -6
- package/dist/chunk-VMNEYCFP.js.map +1 -0
- package/dist/{chunk-NBGHPRU6.js → chunk-WM6SBI4B.js} +37 -29
- package/dist/chunk-WM6SBI4B.js.map +1 -0
- package/dist/{chunk-CMRUAJYD.js → chunk-ZMCDGAGF.js} +33 -6
- package/dist/chunk-ZMCDGAGF.js.map +1 -0
- package/dist/client.cjs +186 -117
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +23 -22
- package/dist/edge.cjs +84 -52
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +5 -4
- package/dist/index.cjs +188 -117
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -22
- package/dist/modelrouter/core.cjs +50 -25
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +4 -3
- package/dist/modelrouter/index.cjs +50 -25
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +4 -3
- package/dist/subagents/anthropic.cjs +85 -12
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +5 -4
- package/dist/subagents/vercel.cjs +85 -12
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +5 -4
- package/dist/tools/browser/anthropic.cjs +47 -9
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +6 -5
- package/dist/tools/browser/core.cjs +50 -19
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +5 -4
- package/dist/tools/browser/index.cjs +50 -19
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +8 -7
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/openai.cjs +47 -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 +6 -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 +6 -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 +47 -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 +48 -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 +48 -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 +48 -11
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +7 -6
- package/dist/tools/codebase_search/openai.cjs +48 -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 +48 -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 +96 -33
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +5 -4
- package/dist/tools/fastapply/apply.cjs +76 -28
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +3 -2
- package/dist/tools/fastapply/core.cjs +96 -33
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +4 -3
- package/dist/tools/fastapply/index.cjs +96 -33
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +7 -6
- package/dist/tools/fastapply/openai.cjs +96 -33
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +5 -4
- package/dist/tools/fastapply/types.cjs.map +1 -1
- package/dist/tools/fastapply/types.d.ts +4 -4
- package/dist/tools/fastapply/vercel.cjs +96 -33
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +5 -4
- package/dist/tools/index.cjs +96 -33
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +7 -6
- package/dist/tools/utils/resilience.cjs +6 -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 +74 -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 +85 -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 +85 -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 +85 -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 +85 -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 +85 -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 +85 -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 +6 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
- package/dist/chunk-442YHCTX.js.map +0 -1
- package/dist/chunk-CMRUAJYD.js.map +0 -1
- package/dist/chunk-IHSLH64T.js.map +0 -1
- package/dist/chunk-KCJRKSMG.js.map +0 -1
- package/dist/chunk-L6WYOSFK.js.map +0 -1
- package/dist/chunk-LGF2WTXG.js.map +0 -1
- package/dist/chunk-NBGHPRU6.js.map +0 -1
- package/dist/chunk-VM4TVOBU.js.map +0 -1
- package/dist/{chunk-JIPYZNK3.js.map → chunk-2KDJKRZG.js.map} +0 -0
- package/dist/{chunk-PQXJ32G4.js.map → chunk-5BMWOPYW.js.map} +0 -0
- package/dist/{chunk-F2SBKBBS.js.map → chunk-5FYJMU6H.js.map} +0 -0
- package/dist/{chunk-KP3CAEH5.js.map → chunk-6PFGM4CM.js.map} +0 -0
- package/dist/{chunk-5R3QCYHW.js.map → chunk-6YOSNPHS.js.map} +0 -0
- package/dist/{chunk-G3E75GPM.js.map → chunk-6YTCBLRI.js.map} +0 -0
- package/dist/{chunk-2CE4PG2F.js.map → chunk-COUYHTIO.js.map} +0 -0
- package/dist/{chunk-HDZ4XYUX.js.map → chunk-EJBWDGTH.js.map} +0 -0
- package/dist/{chunk-DKQMGEHV.js.map → chunk-FNCPPCPV.js.map} +0 -0
- package/dist/{chunk-27VVVW57.js.map → chunk-HBH56DLN.js.map} +0 -0
- package/dist/{chunk-5GVI7L4O.js.map → chunk-HFN3YCF4.js.map} +0 -0
- package/dist/{chunk-QQBEGCX2.js.map → chunk-HMGC7FLZ.js.map} +0 -0
- package/dist/{chunk-63JAZOI3.js.map → chunk-LW5EAPZ6.js.map} +0 -0
- package/dist/{chunk-N4EFVT45.js.map → chunk-NNATBEOF.js.map} +0 -0
- package/dist/{chunk-RZS5DQAX.js.map → chunk-OKFW4KGU.js.map} +0 -0
- package/dist/{chunk-QR34LBOS.js.map → chunk-QXGOEDZD.js.map} +0 -0
- package/dist/{client-PkB7g9SA.d.ts → client-DsAAqupx.d.ts} +1 -1
|
@@ -27,12 +27,12 @@ import {
|
|
|
27
27
|
executeWarpGrep,
|
|
28
28
|
formatGitHubReadFileResult,
|
|
29
29
|
formatResult
|
|
30
|
-
} from "../../chunk-
|
|
30
|
+
} from "../../chunk-LSHQISAX.js";
|
|
31
31
|
import "../../chunk-63VHBANJ.js";
|
|
32
32
|
import {
|
|
33
33
|
runWarpGrep,
|
|
34
34
|
runWarpGrepStreaming
|
|
35
|
-
} from "../../chunk-
|
|
35
|
+
} from "../../chunk-ZMCDGAGF.js";
|
|
36
36
|
import {
|
|
37
37
|
createCodeStorageHttpCommands
|
|
38
38
|
} from "../../chunk-GVGJIXV2.js";
|
|
@@ -50,7 +50,8 @@ import "../../chunk-FBRNUWEB.js";
|
|
|
50
50
|
import "../../chunk-I3J46TSB.js";
|
|
51
51
|
import "../../chunk-GLQWEINZ.js";
|
|
52
52
|
import "../../chunk-SCVWDNQP.js";
|
|
53
|
-
import "../../chunk-
|
|
53
|
+
import "../../chunk-5AM23TC7.js";
|
|
54
|
+
import "../../chunk-LST7MZOZ.js";
|
|
54
55
|
import "../../chunk-PZ5AY32C.js";
|
|
55
56
|
export {
|
|
56
57
|
GITHUB_READ_FILE_DESCRIPTION,
|
|
@@ -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
|
});
|
|
@@ -940,7 +940,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
940
940
|
// package.json
|
|
941
941
|
var package_default = {
|
|
942
942
|
name: "@morphllm/morphsdk",
|
|
943
|
-
version: "0.2.
|
|
943
|
+
version: "0.2.163",
|
|
944
944
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
945
945
|
type: "module",
|
|
946
946
|
main: "./dist/index.cjs",
|
|
@@ -952,6 +952,11 @@ var package_default = {
|
|
|
952
952
|
import: "./dist/index.js",
|
|
953
953
|
require: "./dist/index.cjs"
|
|
954
954
|
},
|
|
955
|
+
"./logger": {
|
|
956
|
+
types: "./dist/logger.d.ts",
|
|
957
|
+
import: "./dist/logger.js",
|
|
958
|
+
require: "./dist/logger.cjs"
|
|
959
|
+
},
|
|
955
960
|
"./edge": {
|
|
956
961
|
types: "./dist/edge.d.ts",
|
|
957
962
|
import: "./dist/edge.js",
|
|
@@ -1180,6 +1185,46 @@ var SDK_VERSION = package_default.version;
|
|
|
1180
1185
|
|
|
1181
1186
|
// tools/warp_grep/agent/runner.ts
|
|
1182
1187
|
var import_path3 = __toESM(require("path"), 1);
|
|
1188
|
+
|
|
1189
|
+
// logger.ts
|
|
1190
|
+
var import_fs = require("fs");
|
|
1191
|
+
var MorphLogger = class {
|
|
1192
|
+
enabled;
|
|
1193
|
+
fileStream;
|
|
1194
|
+
constructor() {
|
|
1195
|
+
this.enabled = process.env.MORPH_DEBUG === "1" || !!process.env.MORPH_LOG_FILE;
|
|
1196
|
+
const f = process.env.MORPH_LOG_FILE;
|
|
1197
|
+
this.fileStream = f ? (0, import_fs.createWriteStream)(f, { flags: "a" }) : null;
|
|
1198
|
+
}
|
|
1199
|
+
debug(component, msg, data) {
|
|
1200
|
+
this._log("debug", component, msg, data);
|
|
1201
|
+
}
|
|
1202
|
+
info(component, msg, data) {
|
|
1203
|
+
this._log("info", component, msg, data);
|
|
1204
|
+
}
|
|
1205
|
+
warn(component, msg, data) {
|
|
1206
|
+
this._log("warn", component, msg, data);
|
|
1207
|
+
}
|
|
1208
|
+
error(component, msg, data) {
|
|
1209
|
+
this._log("error", component, msg, data);
|
|
1210
|
+
}
|
|
1211
|
+
enable() {
|
|
1212
|
+
this.enabled = true;
|
|
1213
|
+
}
|
|
1214
|
+
get isEnabled() {
|
|
1215
|
+
return this.enabled;
|
|
1216
|
+
}
|
|
1217
|
+
_log(level, component, msg, data) {
|
|
1218
|
+
if (level !== "error" && !this.enabled) return;
|
|
1219
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
1220
|
+
const prefix = `[${ts}] [${level.toUpperCase()}] [${component}]`;
|
|
1221
|
+
console.error(data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`);
|
|
1222
|
+
this.fileStream?.write(JSON.stringify({ ts, level, component, msg, ...data && { data } }) + "\n");
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
var logger = new MorphLogger();
|
|
1226
|
+
|
|
1227
|
+
// tools/warp_grep/agent/runner.ts
|
|
1183
1228
|
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
1184
1229
|
var TOOL_SPECS = [
|
|
1185
1230
|
{
|
|
@@ -1302,6 +1347,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
1302
1347
|
defaultHeaders: { "X-Morph-SDK-Version": SDK_VERSION }
|
|
1303
1348
|
});
|
|
1304
1349
|
const MAX_EMPTY_RETRIES = 1;
|
|
1350
|
+
logger.debug("WarpGrep", "model_call", { url: baseURL, model, message_count: messages.length });
|
|
1351
|
+
const callStartTime = Date.now();
|
|
1305
1352
|
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
1306
1353
|
let data;
|
|
1307
1354
|
try {
|
|
@@ -1314,10 +1361,16 @@ async function callModel(messages, model, options = {}) {
|
|
|
1314
1361
|
...options.search_type ? { search_type: options.search_type } : {}
|
|
1315
1362
|
});
|
|
1316
1363
|
} catch (error) {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1364
|
+
const callLatencyMs = Date.now() - callStartTime;
|
|
1365
|
+
if (error instanceof import_openai.default.APIError) {
|
|
1366
|
+
logger.error("WarpGrep", "model_call_error", { status: error.status, error: error.message, latency_ms: callLatencyMs });
|
|
1367
|
+
if (error.status === 404) {
|
|
1368
|
+
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";
|
|
1369
|
+
const errorText = error.message?.trim();
|
|
1370
|
+
throw new Error(errorText || defaultMsg);
|
|
1371
|
+
}
|
|
1372
|
+
} else {
|
|
1373
|
+
logger.error("WarpGrep", "model_call_error", { status: void 0, error: error instanceof Error ? error.message : String(error), latency_ms: callLatencyMs });
|
|
1321
1374
|
}
|
|
1322
1375
|
throw error;
|
|
1323
1376
|
}
|
|
@@ -1336,6 +1389,7 @@ async function callModel(messages, model, options = {}) {
|
|
|
1336
1389
|
function: { name: tc.function.name, arguments: tc.function.arguments }
|
|
1337
1390
|
}));
|
|
1338
1391
|
if (message.content || toolCalls.length > 0) {
|
|
1392
|
+
logger.debug("WarpGrep", "model_call_complete", { latency_ms: Date.now() - callStartTime, tool_calls_count: toolCalls.length, finish_reason: choice?.finish_reason ?? "unknown" });
|
|
1339
1393
|
return { content: message.content ?? null, tool_calls: toolCalls };
|
|
1340
1394
|
}
|
|
1341
1395
|
if (attempt === MAX_EMPTY_RETRIES) {
|
|
@@ -1406,9 +1460,11 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1406
1460
|
const model = config.model || DEFAULT_MODEL;
|
|
1407
1461
|
const messages = [];
|
|
1408
1462
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1463
|
+
logger.debug("WarpGrep", "session_start", { search_term: config.searchTerm, model, max_turns: maxTurns });
|
|
1409
1464
|
const initialStateStart = Date.now();
|
|
1410
1465
|
const initialState = await buildInitialState(repoRoot, config.searchTerm, config.provider, { search_type: config.search_type });
|
|
1411
1466
|
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1467
|
+
logger.debug("WarpGrep", "initial_state", { system_prompt_len: initialState.length, user_message_len: initialState.length });
|
|
1412
1468
|
messages.push({ role: "user", content: initialState });
|
|
1413
1469
|
const provider = config.provider;
|
|
1414
1470
|
const errors = [];
|
|
@@ -1416,7 +1472,13 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1416
1472
|
let terminationReason = "terminated";
|
|
1417
1473
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1418
1474
|
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1475
|
+
logger.debug("WarpGrep", "turn_start", { turn, message_count: messages.length });
|
|
1476
|
+
const beforeChars = messages.reduce((sum, m) => sum + (typeof m.content === "string" ? m.content.length : 0), 0);
|
|
1419
1477
|
enforceContextLimit(messages);
|
|
1478
|
+
const afterChars = messages.reduce((sum, m) => sum + (typeof m.content === "string" ? m.content.length : 0), 0);
|
|
1479
|
+
if (afterChars < beforeChars) {
|
|
1480
|
+
logger.debug("WarpGrep", "context_truncated", { before_chars: beforeChars, after_chars: afterChars });
|
|
1481
|
+
}
|
|
1420
1482
|
const modelCallStart = Date.now();
|
|
1421
1483
|
const response = await callModel(messages, model, {
|
|
1422
1484
|
morphApiKey: config.morphApiKey,
|
|
@@ -1427,6 +1489,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1427
1489
|
}).catch((e) => {
|
|
1428
1490
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1429
1491
|
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1492
|
+
logger.error("WarpGrep", "error", { turn, error: errMsg, phase: "model_call" });
|
|
1430
1493
|
errors.push({ message: errMsg });
|
|
1431
1494
|
return null;
|
|
1432
1495
|
});
|
|
@@ -1436,6 +1499,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1436
1499
|
break;
|
|
1437
1500
|
}
|
|
1438
1501
|
const toolCalls = response.tool_calls;
|
|
1502
|
+
logger.debug("WarpGrep", "model_response", { turn, tool_calls: toolCalls.map((tc) => tc.function.name), latency_ms: turnMetrics.morph_api_ms });
|
|
1439
1503
|
messages.push({
|
|
1440
1504
|
role: "assistant",
|
|
1441
1505
|
content: response.content,
|
|
@@ -1462,6 +1526,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1462
1526
|
const files = parseFinishFiles(filesStr);
|
|
1463
1527
|
finishMeta = { files };
|
|
1464
1528
|
terminationReason = "completed";
|
|
1529
|
+
logger.debug("WarpGrep", "finish", { turns: turn, files: files.map((f) => f.path) });
|
|
1465
1530
|
if (files.length === 0) {
|
|
1466
1531
|
const payload2 = filesStr || "No relevant code found.";
|
|
1467
1532
|
timings.turns.push(turnMetrics);
|
|
@@ -1480,7 +1545,11 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1480
1545
|
const results = await Promise.all(
|
|
1481
1546
|
toolCalls.map(async (tc) => {
|
|
1482
1547
|
const args = safeParseJSON(tc.function.arguments);
|
|
1548
|
+
const argsSummary = Object.fromEntries(Object.entries(args).map(([k, v]) => [k, typeof v === "string" && v.length > 100 ? v.slice(0, 100) + "..." : v]));
|
|
1549
|
+
logger.debug("WarpGrep", "tool_exec", { turn, tool: tc.function.name, args_summary: argsSummary });
|
|
1550
|
+
const toolStart = Date.now();
|
|
1483
1551
|
const output = await executeTool(provider, tc.function.name, args, repoRoot).catch((err) => String(err));
|
|
1552
|
+
logger.debug("WarpGrep", "tool_result", { turn, tool: tc.function.name, result_len: output.length, latency_ms: Date.now() - toolStart });
|
|
1484
1553
|
return { tool_call_id: tc.id, content: output };
|
|
1485
1554
|
})
|
|
1486
1555
|
);
|
|
@@ -1988,12 +2057,16 @@ var WarpGrepClient = class {
|
|
|
1988
2057
|
async _resolveGitHubRepo(input) {
|
|
1989
2058
|
const { owner, repo } = parseGitHubUrl(input.github);
|
|
1990
2059
|
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
2060
|
+
logger.debug("WarpGrep", "github_resolve", { owner_repo: `${owner}/${repo}`, branch: input.branch });
|
|
2061
|
+
const resolveStart = Date.now();
|
|
1991
2062
|
const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);
|
|
1992
2063
|
if (!importRes.ok) {
|
|
1993
2064
|
const text = await importRes.text().catch(() => importRes.statusText);
|
|
2065
|
+
logger.error("WarpGrep", "github_resolve_failed", { owner_repo: `${owner}/${repo}`, status: importRes.status, error: text });
|
|
1994
2066
|
throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);
|
|
1995
2067
|
}
|
|
1996
2068
|
const { repoId, defaultBranch } = await importRes.json();
|
|
2069
|
+
logger.debug("WarpGrep", "github_repo_fetched", { repo_id: repoId, default_branch: defaultBranch, latency_ms: Date.now() - resolveStart });
|
|
1997
2070
|
return {
|
|
1998
2071
|
repo,
|
|
1999
2072
|
remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch })
|