@wrongstack/tools 0.77.0 → 0.82.6
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/audit.d.ts +4 -4
- package/dist/audit.js +10 -2
- package/dist/audit.js.map +1 -1
- package/dist/{background-indexer-C70RD7LU.d.ts → background-indexer-DYm1FUxK.d.ts} +19 -19
- package/dist/bash.d.ts +4 -4
- package/dist/bash.js +18 -4
- package/dist/bash.js.map +1 -1
- package/dist/batch-tool-use.d.ts +4 -4
- package/dist/batch-tool-use.js.map +1 -1
- package/dist/builtin.js +173 -70
- package/dist/builtin.js.map +1 -1
- package/dist/circuit-breaker.d.ts +6 -6
- package/dist/circuit-breaker.js.map +1 -1
- package/dist/codebase-index/index.d.ts +12 -12
- package/dist/codebase-index/index.js +79 -41
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/diff.d.ts +7 -7
- package/dist/diff.js.map +1 -1
- package/dist/document.d.ts +6 -6
- package/dist/document.js.map +1 -1
- package/dist/edit.d.ts +1 -1
- package/dist/edit.js.map +1 -1
- package/dist/exec.d.ts +3 -3
- package/dist/exec.js +15 -3
- package/dist/exec.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.js +3 -1
- package/dist/fetch.js.map +1 -1
- package/dist/format.d.ts +4 -4
- package/dist/format.js +18 -4
- package/dist/format.js.map +1 -1
- package/dist/git.d.ts +10 -10
- package/dist/git.js +8 -2
- package/dist/git.js.map +1 -1
- package/dist/glob.d.ts +2 -2
- package/dist/glob.js.map +1 -1
- package/dist/grep.d.ts +6 -6
- package/dist/grep.js +10 -2
- package/dist/grep.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +173 -70
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +5 -5
- package/dist/install.js +18 -4
- package/dist/install.js.map +1 -1
- package/dist/json.d.ts +8 -8
- package/dist/json.js.map +1 -1
- package/dist/lint.d.ts +4 -4
- package/dist/lint.js +18 -4
- package/dist/lint.js.map +1 -1
- package/dist/logs.d.ts +8 -8
- package/dist/logs.js.map +1 -1
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js.map +1 -1
- package/dist/mode.d.ts +3 -3
- package/dist/mode.js.map +1 -1
- package/dist/outdated.d.ts +4 -4
- package/dist/outdated.js.map +1 -1
- package/dist/pack.js +173 -70
- package/dist/pack.js.map +1 -1
- package/dist/patch.d.ts +3 -3
- package/dist/patch.js.map +1 -1
- package/dist/process-registry.d.ts +3 -3
- package/dist/process-registry.js +7 -1
- package/dist/process-registry.js.map +1 -1
- package/dist/read.d.ts +2 -2
- package/dist/read.js.map +1 -1
- package/dist/replace.d.ts +4 -4
- package/dist/replace.js +8 -2
- package/dist/replace.js.map +1 -1
- package/dist/scaffold.d.ts +2 -2
- package/dist/scaffold.js.map +1 -1
- package/dist/search.d.ts +2 -2
- package/dist/search.js +16 -8
- package/dist/search.js.map +1 -1
- package/dist/test.d.ts +7 -7
- package/dist/test.js +18 -4
- package/dist/test.js.map +1 -1
- package/dist/tool-help.d.ts +4 -4
- package/dist/tool-help.js.map +1 -1
- package/dist/tool-search.d.ts +5 -5
- package/dist/tool-search.js.map +1 -1
- package/dist/tool-use.d.ts +2 -2
- package/dist/tool-use.js.map +1 -1
- package/dist/tree.d.ts +7 -7
- package/dist/tree.js +10 -2
- package/dist/tree.js.map +1 -1
- package/dist/typecheck.d.ts +4 -4
- package/dist/typecheck.js +18 -4
- package/dist/typecheck.js.map +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js.map +1 -1
- package/package.json +2 -2
package/dist/builtin.js
CHANGED
|
@@ -19,6 +19,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
19
19
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
20
20
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
21
21
|
});
|
|
22
|
+
function expectDefined(value) {
|
|
23
|
+
if (value === null || value === void 0) {
|
|
24
|
+
throw new Error("Expected value to be defined");
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
22
28
|
async function* spawnStream(opts) {
|
|
23
29
|
const max = opts.maxBytes ?? 2e5;
|
|
24
30
|
const flushAt = opts.flushBytes ?? 4 * 1024;
|
|
@@ -70,7 +76,7 @@ async function* spawnStream(opts) {
|
|
|
70
76
|
waiter = resolve7;
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
|
-
const chunk = queue.shift();
|
|
79
|
+
const chunk = expectDefined(queue.shift());
|
|
74
80
|
if (chunk.kind === "close") {
|
|
75
81
|
if (!spawnFailed) exitCode = chunk.code ?? 0;
|
|
76
82
|
break;
|
|
@@ -97,6 +103,12 @@ async function* spawnStream(opts) {
|
|
|
97
103
|
error
|
|
98
104
|
};
|
|
99
105
|
}
|
|
106
|
+
function expectDefined2(value) {
|
|
107
|
+
if (value === null || value === void 0) {
|
|
108
|
+
throw new Error("Expected value to be defined");
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
100
112
|
async function detectPackageManager(cwd) {
|
|
101
113
|
const { stat: stat10 } = await import('node:fs/promises');
|
|
102
114
|
try {
|
|
@@ -186,9 +198,9 @@ function collapseConsecutiveDuplicates(text, minRun = REPEAT_RUN_THRESHOLD) {
|
|
|
186
198
|
while (j < lines.length && lines[j] === lines[i]) j++;
|
|
187
199
|
const run = j - i;
|
|
188
200
|
if (run >= minRun) {
|
|
189
|
-
out.push(lines[i], `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
|
|
201
|
+
out.push(expectDefined2(lines[i]), `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
|
|
190
202
|
} else {
|
|
191
|
-
for (let k = i; k < j; k++) out.push(lines[k]);
|
|
203
|
+
for (let k = i; k < j; k++) out.push(expectDefined2(lines[k]));
|
|
192
204
|
}
|
|
193
205
|
i = j;
|
|
194
206
|
}
|
|
@@ -265,7 +277,9 @@ var auditTool = {
|
|
|
265
277
|
},
|
|
266
278
|
async execute(input, ctx, opts) {
|
|
267
279
|
let final;
|
|
268
|
-
|
|
280
|
+
const executeStream = auditTool.executeStream;
|
|
281
|
+
if (!executeStream) throw new Error("auditTool: stream execution unavailable");
|
|
282
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
269
283
|
if (ev.type === "final") final = ev.output;
|
|
270
284
|
}
|
|
271
285
|
if (!final) throw new Error("audit: stream ended without final event");
|
|
@@ -482,6 +496,12 @@ var CircuitBreaker = class {
|
|
|
482
496
|
};
|
|
483
497
|
|
|
484
498
|
// src/process-registry.ts
|
|
499
|
+
function expectDefined3(value) {
|
|
500
|
+
if (value === null || value === void 0) {
|
|
501
|
+
throw new Error("Expected value to be defined");
|
|
502
|
+
}
|
|
503
|
+
return value;
|
|
504
|
+
}
|
|
485
505
|
var SENSITIVE_FLAG_PATTERNS = [
|
|
486
506
|
// --flag=value or --flag "value" (value captured up to next space or comma)
|
|
487
507
|
/--(?:token|password|passwd|pwd|secret|api[-_]?key|api[-_]?secret|auth|credential|private[-_]?key|access[-_]?key|github[-_]?token|gh[-_]?token|bearer|jwt|oauth|pin|pincode|passphrase|access[-_]?token)(?:[=\s,][^\s]*)?/gi,
|
|
@@ -502,7 +522,7 @@ function redactCommand(cmd) {
|
|
|
502
522
|
const sp = match.search(/\s/);
|
|
503
523
|
const delim = eq !== -1 ? "=" : sp !== -1 ? match[sp] : null;
|
|
504
524
|
if (delim !== null) {
|
|
505
|
-
const flag = match.slice(0, match.indexOf(delim) + 1);
|
|
525
|
+
const flag = match.slice(0, match.indexOf(expectDefined3(delim)) + 1);
|
|
506
526
|
return `${flag}[REDACTED]`;
|
|
507
527
|
}
|
|
508
528
|
const flagEnd = match.match(/^--?[a-zA-Z][a-zA-Z0-9_-]*/)?.[0] ?? match;
|
|
@@ -721,7 +741,9 @@ var bashTool = {
|
|
|
721
741
|
},
|
|
722
742
|
async execute(input, ctx, opts) {
|
|
723
743
|
let final;
|
|
724
|
-
|
|
744
|
+
const executeStream = bashTool.executeStream;
|
|
745
|
+
if (!executeStream) throw new Error("bashTool: stream execution unavailable");
|
|
746
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
725
747
|
if (ev.type === "final") final = ev.output;
|
|
726
748
|
}
|
|
727
749
|
if (!final) throw new Error("bash: stream ended without final event");
|
|
@@ -1087,6 +1109,12 @@ function lspKindToInternalKind(k) {
|
|
|
1087
1109
|
}
|
|
1088
1110
|
|
|
1089
1111
|
// src/codebase-index/writer.ts
|
|
1112
|
+
function expectDefined4(value) {
|
|
1113
|
+
if (value === null || value === void 0) {
|
|
1114
|
+
throw new Error("Expected value to be defined");
|
|
1115
|
+
}
|
|
1116
|
+
return value;
|
|
1117
|
+
}
|
|
1090
1118
|
var DB_FILE = "index.db";
|
|
1091
1119
|
function resolveIndexDir(projectRoot, override) {
|
|
1092
1120
|
return override ?? resolveWstackPaths({ projectRoot }).projectCodebaseIndex;
|
|
@@ -1231,7 +1259,7 @@ var IndexStore = class {
|
|
|
1231
1259
|
"SELECT file, lang, mtime_ms, symbol_count, last_indexed FROM files WHERE file = ?"
|
|
1232
1260
|
).all(file);
|
|
1233
1261
|
if (!rows.length) return null;
|
|
1234
|
-
const r = rows[0];
|
|
1262
|
+
const r = expectDefined4(rows[0]);
|
|
1235
1263
|
return { file: r.file, lang: r.lang, mtimeMs: r.mtime_ms, symbolCount: r.symbol_count, lastIndexed: r.last_indexed };
|
|
1236
1264
|
}
|
|
1237
1265
|
getAllFileMetas() {
|
|
@@ -1313,7 +1341,7 @@ var IndexStore = class {
|
|
|
1313
1341
|
const lastRows = this.db.prepare(
|
|
1314
1342
|
"SELECT value FROM metadata WHERE key = 'last_indexed'"
|
|
1315
1343
|
).all();
|
|
1316
|
-
const lastIndexed = lastRows.length ? Number(lastRows[0]
|
|
1344
|
+
const lastIndexed = lastRows.length ? Number(lastRows[0]?.value) : null;
|
|
1317
1345
|
const totalRows = this.db.prepare("SELECT COUNT(*) FROM symbols").all();
|
|
1318
1346
|
const totalSymbols = totalRows[0] ? Number(totalRows[0]["COUNT(*)"]) : 0;
|
|
1319
1347
|
const fileRows = this.db.prepare("SELECT COUNT(*) FROM files").all();
|
|
@@ -1388,8 +1416,9 @@ var IndexStore = class {
|
|
|
1388
1416
|
let resolved = 0;
|
|
1389
1417
|
for (const row of unresolved) {
|
|
1390
1418
|
const target = this.db.prepare("SELECT id FROM symbols WHERE name = ? LIMIT 1").all(row.to_name);
|
|
1391
|
-
|
|
1392
|
-
|
|
1419
|
+
const first = target[0];
|
|
1420
|
+
if (first) {
|
|
1421
|
+
this.db.prepare("UPDATE refs SET to_id = ? WHERE id = ?").run(first.id, row.id);
|
|
1393
1422
|
resolved++;
|
|
1394
1423
|
}
|
|
1395
1424
|
}
|
|
@@ -2143,6 +2172,12 @@ function syncPyParse(filePath, lang) {
|
|
|
2143
2172
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
2144
2173
|
}
|
|
2145
2174
|
}
|
|
2175
|
+
function expectDefined5(value) {
|
|
2176
|
+
if (value === null || value === void 0) {
|
|
2177
|
+
throw new Error("Expected value to be defined");
|
|
2178
|
+
}
|
|
2179
|
+
return value;
|
|
2180
|
+
}
|
|
2146
2181
|
function parseSymbols4(opts) {
|
|
2147
2182
|
const { file, content, lang } = opts;
|
|
2148
2183
|
const nativeAvailable = checkNativeParser();
|
|
@@ -2224,14 +2259,14 @@ function regexParse(opts) {
|
|
|
2224
2259
|
const lines = content.split("\n");
|
|
2225
2260
|
const lineOffsets = [0];
|
|
2226
2261
|
for (let i = 0; i < lines.length; i++) {
|
|
2227
|
-
lineOffsets.push(lineOffsets[i] + lines[i]
|
|
2262
|
+
lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
|
|
2228
2263
|
}
|
|
2229
2264
|
function lineFromOffset(offset) {
|
|
2230
2265
|
let lo = 0;
|
|
2231
2266
|
let hi = lineOffsets.length - 1;
|
|
2232
2267
|
while (lo < hi) {
|
|
2233
2268
|
const mid = lo + hi + 1 >>> 1;
|
|
2234
|
-
if (lineOffsets[mid] <= offset) lo = mid;
|
|
2269
|
+
if (expectDefined5(lineOffsets[mid]) <= offset) lo = mid;
|
|
2235
2270
|
else hi = mid - 1;
|
|
2236
2271
|
}
|
|
2237
2272
|
return lo + 1;
|
|
@@ -2243,8 +2278,8 @@ function regexParse(opts) {
|
|
|
2243
2278
|
for (const pattern of RS_PATTERNS) {
|
|
2244
2279
|
pattern.regex.lastIndex = 0;
|
|
2245
2280
|
for (let match = pattern.regex.exec(content); match !== null; match = pattern.regex.exec(content)) {
|
|
2246
|
-
const name = match[1];
|
|
2247
|
-
const offset = match.index;
|
|
2281
|
+
const name = expectDefined5(match[1]);
|
|
2282
|
+
const offset = match.index ?? 0;
|
|
2248
2283
|
const line = lineFromOffset(offset);
|
|
2249
2284
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2250
2285
|
const lineIdx = line - 1;
|
|
@@ -2273,6 +2308,12 @@ function regexParse(opts) {
|
|
|
2273
2308
|
});
|
|
2274
2309
|
return { file, lang, symbols: deduped, mtimeMs: Date.now() };
|
|
2275
2310
|
}
|
|
2311
|
+
function expectDefined6(value) {
|
|
2312
|
+
if (value === null || value === void 0) {
|
|
2313
|
+
throw new Error("Expected value to be defined");
|
|
2314
|
+
}
|
|
2315
|
+
return value;
|
|
2316
|
+
}
|
|
2276
2317
|
function parseSymbols5(opts) {
|
|
2277
2318
|
const { file, content, lang } = opts;
|
|
2278
2319
|
try {
|
|
@@ -2292,21 +2333,21 @@ function regexParse2(opts) {
|
|
|
2292
2333
|
const lines = content.split("\n");
|
|
2293
2334
|
const lineOffsets = [0];
|
|
2294
2335
|
for (let i = 0; i < lines.length; i++) {
|
|
2295
|
-
lineOffsets.push(lineOffsets[i] + lines[i]
|
|
2336
|
+
lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
|
|
2296
2337
|
}
|
|
2297
2338
|
function lineFromOffset(offset) {
|
|
2298
2339
|
let lo = 0;
|
|
2299
2340
|
let hi = lineOffsets.length - 1;
|
|
2300
2341
|
while (lo < hi) {
|
|
2301
2342
|
const mid = lo + hi + 1 >>> 1;
|
|
2302
|
-
if (lineOffsets[mid] <= offset) lo = mid;
|
|
2343
|
+
if (expectDefined6(lineOffsets[mid]) <= offset) lo = mid;
|
|
2303
2344
|
else hi = mid - 1;
|
|
2304
2345
|
}
|
|
2305
2346
|
return lo + 1;
|
|
2306
2347
|
}
|
|
2307
2348
|
const rootMatch = content.match(/^\s*\{/m);
|
|
2308
2349
|
if (rootMatch) {
|
|
2309
|
-
const offset = rootMatch.index;
|
|
2350
|
+
const offset = expectDefined6(rootMatch.index);
|
|
2310
2351
|
const line = lineFromOffset(offset);
|
|
2311
2352
|
symbols.push(
|
|
2312
2353
|
makeSymbol({
|
|
@@ -2322,8 +2363,8 @@ function regexParse2(opts) {
|
|
|
2322
2363
|
}
|
|
2323
2364
|
const topLevelKeyRegex = /^\s*"([^"]+)"\s*:/gm;
|
|
2324
2365
|
for (let match = topLevelKeyRegex.exec(content); match !== null; match = topLevelKeyRegex.exec(content)) {
|
|
2325
|
-
const key = match[1];
|
|
2326
|
-
const offset = match.index;
|
|
2366
|
+
const key = expectDefined6(match[1]);
|
|
2367
|
+
const offset = match.index ?? 0;
|
|
2327
2368
|
const line = lineFromOffset(offset);
|
|
2328
2369
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2329
2370
|
let kind = "property";
|
|
@@ -2369,7 +2410,7 @@ function regexParse2(opts) {
|
|
|
2369
2410
|
const defsRegex = /"\$defs"\s*:|"\$defs"\s*:/g;
|
|
2370
2411
|
const defsMatch = defsRegex.exec(content);
|
|
2371
2412
|
if (defsMatch !== null) {
|
|
2372
|
-
const offset = defsMatch.index;
|
|
2413
|
+
const offset = expectDefined6(defsMatch.index);
|
|
2373
2414
|
const line = lineFromOffset(offset);
|
|
2374
2415
|
symbols.push(
|
|
2375
2416
|
makeSymbol({
|
|
@@ -2392,9 +2433,9 @@ function regexParse2(opts) {
|
|
|
2392
2433
|
for (const pat of defsPatterns) {
|
|
2393
2434
|
pat.lastIndex = 0;
|
|
2394
2435
|
for (let match = pat.exec(content); match !== null; match = pat.exec(content)) {
|
|
2395
|
-
const offset = match.index;
|
|
2436
|
+
const offset = match.index ?? 0;
|
|
2396
2437
|
const line = lineFromOffset(offset);
|
|
2397
|
-
const key = match[0]
|
|
2438
|
+
const key = match[0]?.match(/"([^"]+)"/)?.[1] ?? expectDefined6(match[0]);
|
|
2398
2439
|
symbols.push(
|
|
2399
2440
|
makeSymbol({
|
|
2400
2441
|
name: key,
|
|
@@ -2413,12 +2454,12 @@ function regexParse2(opts) {
|
|
|
2413
2454
|
function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset) {
|
|
2414
2455
|
const scriptsBlockRegex = /"scripts"\s*:\s*\{([^}]+)\}/g;
|
|
2415
2456
|
for (let match = scriptsBlockRegex.exec(content); match !== null; match = scriptsBlockRegex.exec(content)) {
|
|
2416
|
-
const blockContent = match[0];
|
|
2417
|
-
const blockOffset = match.index;
|
|
2457
|
+
const blockContent = expectDefined6(match[0]);
|
|
2458
|
+
const blockOffset = match.index ?? 0;
|
|
2418
2459
|
const scriptKeyRegex = /"(\w[\w-]*)"\s*:/g;
|
|
2419
2460
|
for (let scriptMatch = scriptKeyRegex.exec(blockContent); scriptMatch !== null; scriptMatch = scriptKeyRegex.exec(blockContent)) {
|
|
2420
|
-
const key = scriptMatch[1];
|
|
2421
|
-
const keyOffset = blockOffset + scriptMatch.index;
|
|
2461
|
+
const key = expectDefined6(scriptMatch[1]);
|
|
2462
|
+
const keyOffset = blockOffset + expectDefined6(scriptMatch.index);
|
|
2422
2463
|
const line = lineFromOffset(keyOffset);
|
|
2423
2464
|
symbols.push(
|
|
2424
2465
|
makeSymbol({
|
|
@@ -2437,12 +2478,12 @@ function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFr
|
|
|
2437
2478
|
function extractCompilerOptions(content, symbols, file, lang, lineOffsets, parentLine, lineFromOffset) {
|
|
2438
2479
|
const optsBlockRegex = /"compilerOptions"\s*:\s*\{([^}]+)\}/g;
|
|
2439
2480
|
for (let match = optsBlockRegex.exec(content); match !== null; match = optsBlockRegex.exec(content)) {
|
|
2440
|
-
const blockContent = match[0];
|
|
2441
|
-
const blockOffset = match.index;
|
|
2481
|
+
const blockContent = expectDefined6(match[0]);
|
|
2482
|
+
const blockOffset = match.index ?? 0;
|
|
2442
2483
|
const optKeyRegex = /"(\w[\w]*)"\s*:/g;
|
|
2443
2484
|
for (let optMatch = optKeyRegex.exec(blockContent); optMatch !== null; optMatch = optKeyRegex.exec(blockContent)) {
|
|
2444
|
-
const key = optMatch[1];
|
|
2445
|
-
const keyOffset = blockOffset + optMatch.index;
|
|
2485
|
+
const key = expectDefined6(optMatch[1]);
|
|
2486
|
+
const keyOffset = blockOffset + expectDefined6(optMatch.index);
|
|
2446
2487
|
const line = lineFromOffset(keyOffset);
|
|
2447
2488
|
if (line <= parentLine) continue;
|
|
2448
2489
|
symbols.push(
|
|
@@ -2476,6 +2517,12 @@ function makeSymbol(opts) {
|
|
|
2476
2517
|
}
|
|
2477
2518
|
|
|
2478
2519
|
// src/codebase-index/yaml-parser.ts
|
|
2520
|
+
function expectDefined7(value) {
|
|
2521
|
+
if (value === null || value === void 0) {
|
|
2522
|
+
throw new Error("Expected value to be defined");
|
|
2523
|
+
}
|
|
2524
|
+
return value;
|
|
2525
|
+
}
|
|
2479
2526
|
function parseSymbols6(opts) {
|
|
2480
2527
|
const { file, content, lang } = opts;
|
|
2481
2528
|
try {
|
|
@@ -2490,22 +2537,22 @@ function regexParse3(opts) {
|
|
|
2490
2537
|
const lines = content.split("\n");
|
|
2491
2538
|
const lineOffsets = [0];
|
|
2492
2539
|
for (let i = 0; i < lines.length; i++) {
|
|
2493
|
-
lineOffsets.push(lineOffsets[i] + lines[i]
|
|
2540
|
+
lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
|
|
2494
2541
|
}
|
|
2495
2542
|
function lineFromOffset(offset) {
|
|
2496
2543
|
let lo = 0;
|
|
2497
2544
|
let hi = lineOffsets.length - 1;
|
|
2498
2545
|
while (lo < hi) {
|
|
2499
2546
|
const mid = lo + hi + 1 >>> 1;
|
|
2500
|
-
if (lineOffsets[mid] <= offset) lo = mid;
|
|
2547
|
+
if (expectDefined7(lineOffsets[mid]) <= offset) lo = mid;
|
|
2501
2548
|
else hi = mid - 1;
|
|
2502
2549
|
}
|
|
2503
2550
|
return lo + 1;
|
|
2504
2551
|
}
|
|
2505
2552
|
const anchorRegex = /&(\w[\w-]*)/g;
|
|
2506
2553
|
for (let match = anchorRegex.exec(content); match !== null; match = anchorRegex.exec(content)) {
|
|
2507
|
-
const name = match[1];
|
|
2508
|
-
const offset = match.index;
|
|
2554
|
+
const name = expectDefined7(match[1]);
|
|
2555
|
+
const offset = match.index ?? 0;
|
|
2509
2556
|
const line = lineFromOffset(offset);
|
|
2510
2557
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2511
2558
|
symbols.push(
|
|
@@ -2522,8 +2569,8 @@ function regexParse3(opts) {
|
|
|
2522
2569
|
}
|
|
2523
2570
|
const aliasRegex = /\*(\w[\w-]*)/g;
|
|
2524
2571
|
for (let match = aliasRegex.exec(content); match !== null; match = aliasRegex.exec(content)) {
|
|
2525
|
-
const name = match[1];
|
|
2526
|
-
const offset = match.index;
|
|
2572
|
+
const name = expectDefined7(match[1]);
|
|
2573
|
+
const offset = match.index ?? 0;
|
|
2527
2574
|
const line = lineFromOffset(offset);
|
|
2528
2575
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2529
2576
|
symbols.push(
|
|
@@ -2540,27 +2587,28 @@ function regexParse3(opts) {
|
|
|
2540
2587
|
}
|
|
2541
2588
|
const kvRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:/gm;
|
|
2542
2589
|
for (let match = kvRegex.exec(content); match !== null; match = kvRegex.exec(content)) {
|
|
2543
|
-
const indent = match[1]
|
|
2590
|
+
const indent = match[1]?.length ?? 0;
|
|
2544
2591
|
const key = match[2];
|
|
2545
|
-
|
|
2592
|
+
if (!key) continue;
|
|
2593
|
+
const offset = match.index ?? 0;
|
|
2546
2594
|
const line = lineFromOffset(offset);
|
|
2547
2595
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2548
2596
|
const lineContent = lines[line - 1] ?? "";
|
|
2549
2597
|
if (/^[|&>]/.test(lineContent.trim())) continue;
|
|
2550
2598
|
if (key === "---" || key === "...") continue;
|
|
2551
2599
|
if (indent > 12) continue;
|
|
2552
|
-
const value = extractValue(content, match.index);
|
|
2600
|
+
const value = extractValue(content, match.index ?? 0);
|
|
2553
2601
|
const kind = isScalar(value) ? "literal" : "property";
|
|
2554
2602
|
const signature = `${key}: ${truncate(value, 60)}`;
|
|
2555
2603
|
symbols.push(makeSymbol2({ name: key, kind, line, col, signature, file, lang }));
|
|
2556
2604
|
}
|
|
2557
2605
|
const listItemRegex = /^-(\s+)([^:#\s][^:#\s]*)\s*:/gm;
|
|
2558
2606
|
for (let match = listItemRegex.exec(content); match !== null; match = listItemRegex.exec(content)) {
|
|
2559
|
-
const key = match[2];
|
|
2560
|
-
const offset = match.index;
|
|
2607
|
+
const key = expectDefined7(match[2]);
|
|
2608
|
+
const offset = match.index ?? 0;
|
|
2561
2609
|
const line = lineFromOffset(offset);
|
|
2562
2610
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2563
|
-
const value = extractValue(content, offset + match[0]
|
|
2611
|
+
const value = extractValue(content, offset + match[0]?.length);
|
|
2564
2612
|
const kind = isScalar(value) ? "literal" : "property";
|
|
2565
2613
|
symbols.push(
|
|
2566
2614
|
makeSymbol2({
|
|
@@ -2576,8 +2624,8 @@ function regexParse3(opts) {
|
|
|
2576
2624
|
}
|
|
2577
2625
|
const blockScalarRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:\s*[|>](\s|$)/gm;
|
|
2578
2626
|
for (let match = blockScalarRegex.exec(content); match !== null; match = blockScalarRegex.exec(content)) {
|
|
2579
|
-
const key = match[2];
|
|
2580
|
-
const offset = match.index;
|
|
2627
|
+
const key = expectDefined7(match[2]);
|
|
2628
|
+
const offset = match.index ?? 0;
|
|
2581
2629
|
const line = lineFromOffset(offset);
|
|
2582
2630
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
2583
2631
|
symbols.push(
|
|
@@ -2707,6 +2755,12 @@ function _setIndexProgress(current, total) {
|
|
|
2707
2755
|
Promise.resolve();
|
|
2708
2756
|
|
|
2709
2757
|
// src/codebase-index/indexer.ts
|
|
2758
|
+
function expectDefined8(value) {
|
|
2759
|
+
if (value === null || value === void 0) {
|
|
2760
|
+
throw new Error("Expected value to be defined");
|
|
2761
|
+
}
|
|
2762
|
+
return value;
|
|
2763
|
+
}
|
|
2710
2764
|
var YIELD_EVERY_N = 50;
|
|
2711
2765
|
function yieldEventLoop() {
|
|
2712
2766
|
return new Promise((resolve7) => setImmediate(resolve7));
|
|
@@ -2815,7 +2869,7 @@ async function runIndexer(_ctx, opts) {
|
|
|
2815
2869
|
for (const meta of store.getAllFileMetas()) existingMeta.set(meta.file, meta);
|
|
2816
2870
|
}
|
|
2817
2871
|
for (let fi = 0; fi < files.length; fi++) {
|
|
2818
|
-
const file = files[fi];
|
|
2872
|
+
const file = expectDefined8(files[fi]);
|
|
2819
2873
|
_setIndexProgress(fi + 1, files.length);
|
|
2820
2874
|
if (fi > 0 && fi % YIELD_EVERY_N === 0) {
|
|
2821
2875
|
await yieldEventLoop();
|
|
@@ -2872,7 +2926,7 @@ async function runIndexer(_ctx, opts) {
|
|
|
2872
2926
|
langStats[lang] = (langStats[lang] ?? 0) + count;
|
|
2873
2927
|
if (parsed.refs && parsed.refs.length > 0) {
|
|
2874
2928
|
for (let i = 0; i < symbolsWithIds.length; i++) {
|
|
2875
|
-
const sym = symbolsWithIds[i];
|
|
2929
|
+
const sym = expectDefined8(symbolsWithIds[i]);
|
|
2876
2930
|
const symRefs = parsed.refs.filter((r) => r.line === sym.line);
|
|
2877
2931
|
if (symRefs.length > 0) {
|
|
2878
2932
|
const refsWithFromId = symRefs.map((r) => ({ ...r, fromId: sym.id }));
|
|
@@ -3033,6 +3087,12 @@ var Bm25Index = class {
|
|
|
3033
3087
|
};
|
|
3034
3088
|
|
|
3035
3089
|
// src/codebase-index/codebase-search-tool.ts
|
|
3090
|
+
function expectDefined9(value) {
|
|
3091
|
+
if (value === null || value === void 0) {
|
|
3092
|
+
throw new Error("Expected value to be defined");
|
|
3093
|
+
}
|
|
3094
|
+
return value;
|
|
3095
|
+
}
|
|
3036
3096
|
var codebaseSearchTool = {
|
|
3037
3097
|
name: "codebase-search",
|
|
3038
3098
|
category: "Project",
|
|
@@ -3122,7 +3182,7 @@ var codebaseSearchTool = {
|
|
|
3122
3182
|
const top = scored.slice(0, limit);
|
|
3123
3183
|
const qTokens = tokenise(input.query);
|
|
3124
3184
|
const results = top.map(({ id, score }) => {
|
|
3125
|
-
const c = candidates.find((c2) => c2.id === id);
|
|
3185
|
+
const c = expectDefined9(candidates.find((c2) => c2.id === id));
|
|
3126
3186
|
const snippet = bm25.extractSnippet(id, qTokens);
|
|
3127
3187
|
return {
|
|
3128
3188
|
...c,
|
|
@@ -3986,7 +4046,9 @@ var fetchTool = {
|
|
|
3986
4046
|
},
|
|
3987
4047
|
async execute(input, ctx, opts) {
|
|
3988
4048
|
let final;
|
|
3989
|
-
|
|
4049
|
+
const executeStream = fetchTool.executeStream;
|
|
4050
|
+
if (!executeStream) throw new Error("fetchTool: stream execution unavailable");
|
|
4051
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
3990
4052
|
if (ev.type === "final") final = ev.output;
|
|
3991
4053
|
}
|
|
3992
4054
|
if (!final) throw new Error("fetch: stream ended without final event");
|
|
@@ -4245,7 +4307,9 @@ var formatTool = {
|
|
|
4245
4307
|
},
|
|
4246
4308
|
async execute(input, ctx, opts) {
|
|
4247
4309
|
let final;
|
|
4248
|
-
|
|
4310
|
+
const executeStream = formatTool.executeStream;
|
|
4311
|
+
if (!executeStream) throw new Error("formatTool: stream execution unavailable");
|
|
4312
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
4249
4313
|
if (ev.type === "final") final = ev.output;
|
|
4250
4314
|
}
|
|
4251
4315
|
if (!final) throw new Error("format: stream ended without final event");
|
|
@@ -4689,6 +4753,12 @@ function capSubject(line) {
|
|
|
4689
4753
|
}
|
|
4690
4754
|
|
|
4691
4755
|
// src/grep.ts
|
|
4756
|
+
function expectDefined10(value) {
|
|
4757
|
+
if (value === null || value === void 0) {
|
|
4758
|
+
throw new Error("Expected value to be defined");
|
|
4759
|
+
}
|
|
4760
|
+
return value;
|
|
4761
|
+
}
|
|
4692
4762
|
var DEFAULT_IGNORE3 = ["node_modules", ".git", "dist", "build", ".next", "coverage"];
|
|
4693
4763
|
var grepTool = {
|
|
4694
4764
|
name: "grep",
|
|
@@ -4737,7 +4807,9 @@ var grepTool = {
|
|
|
4737
4807
|
},
|
|
4738
4808
|
async execute(input, ctx, opts) {
|
|
4739
4809
|
let final;
|
|
4740
|
-
|
|
4810
|
+
const executeStream = grepTool.executeStream;
|
|
4811
|
+
if (!executeStream) throw new Error("grepTool: stream execution unavailable");
|
|
4812
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
4741
4813
|
if (ev.type === "final") final = ev.output;
|
|
4742
4814
|
}
|
|
4743
4815
|
if (!final) throw new Error("grep: stream ended without final event");
|
|
@@ -4828,7 +4900,7 @@ async function* runRgStream(input, base, mode, limit, signal) {
|
|
|
4828
4900
|
waiter = r;
|
|
4829
4901
|
});
|
|
4830
4902
|
}
|
|
4831
|
-
const c = queue.shift();
|
|
4903
|
+
const c = expectDefined10(queue.shift());
|
|
4832
4904
|
if (c.kind === "error") {
|
|
4833
4905
|
errored = true;
|
|
4834
4906
|
continue;
|
|
@@ -5014,7 +5086,9 @@ var installTool = {
|
|
|
5014
5086
|
},
|
|
5015
5087
|
async execute(input, ctx, opts) {
|
|
5016
5088
|
let final;
|
|
5017
|
-
|
|
5089
|
+
const executeStream = installTool.executeStream;
|
|
5090
|
+
if (!executeStream) throw new Error("installTool: stream execution unavailable");
|
|
5091
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
5018
5092
|
if (ev.type === "final") final = ev.output;
|
|
5019
5093
|
}
|
|
5020
5094
|
if (!final) throw new Error("install: stream ended without final event");
|
|
@@ -5229,7 +5303,9 @@ var lintTool = {
|
|
|
5229
5303
|
},
|
|
5230
5304
|
async execute(input, ctx, opts) {
|
|
5231
5305
|
let final;
|
|
5232
|
-
|
|
5306
|
+
const executeStream = lintTool.executeStream;
|
|
5307
|
+
if (!executeStream) throw new Error("lintTool: stream execution unavailable");
|
|
5308
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
5233
5309
|
if (ev.type === "final") final = ev.output;
|
|
5234
5310
|
}
|
|
5235
5311
|
if (!final) throw new Error("lint: stream ended without final event");
|
|
@@ -5856,14 +5932,15 @@ var planTool = {
|
|
|
5856
5932
|
};
|
|
5857
5933
|
function mkResult(plan, ok, message, todos) {
|
|
5858
5934
|
const open = plan.items.filter((i) => i.status !== "done").length;
|
|
5859
|
-
|
|
5935
|
+
const result = {
|
|
5860
5936
|
ok,
|
|
5861
5937
|
message,
|
|
5862
5938
|
plan: formatPlan(plan),
|
|
5863
5939
|
count: plan.items.length,
|
|
5864
|
-
open
|
|
5865
|
-
todos
|
|
5940
|
+
open
|
|
5866
5941
|
};
|
|
5942
|
+
if (todos !== void 0) result.todos = todos;
|
|
5943
|
+
return result;
|
|
5867
5944
|
}
|
|
5868
5945
|
var MAX_BYTES2 = 5 * 1024 * 1024;
|
|
5869
5946
|
var readTool = {
|
|
@@ -5937,6 +6014,12 @@ var readTool = {
|
|
|
5937
6014
|
};
|
|
5938
6015
|
}
|
|
5939
6016
|
};
|
|
6017
|
+
function expectDefined11(value) {
|
|
6018
|
+
if (value === null || value === void 0) {
|
|
6019
|
+
throw new Error("Expected value to be defined");
|
|
6020
|
+
}
|
|
6021
|
+
return value;
|
|
6022
|
+
}
|
|
5940
6023
|
var DEFAULT_IGNORE4 = ["node_modules", ".git", "dist", "build", ".next", "coverage"];
|
|
5941
6024
|
var replaceTool = {
|
|
5942
6025
|
name: "replace",
|
|
@@ -6016,8 +6099,8 @@ var replaceTool = {
|
|
|
6016
6099
|
const count = matches.length;
|
|
6017
6100
|
let newContentLf = contentLf;
|
|
6018
6101
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
6019
|
-
const m = matches[i];
|
|
6020
|
-
newContentLf = newContentLf.slice(0, m.index) + input.replacement + newContentLf.slice(m.index + m[0].length);
|
|
6102
|
+
const m = expectDefined11(matches[i]);
|
|
6103
|
+
newContentLf = newContentLf.slice(0, m.index) + input.replacement + newContentLf.slice(expectDefined11(m.index) + m[0].length);
|
|
6021
6104
|
}
|
|
6022
6105
|
re.lastIndex = 0;
|
|
6023
6106
|
totalReplacements += count;
|
|
@@ -6318,6 +6401,12 @@ function substituteVars(content, name, vars) {
|
|
|
6318
6401
|
}
|
|
6319
6402
|
|
|
6320
6403
|
// src/search.ts
|
|
6404
|
+
function expectDefined12(value) {
|
|
6405
|
+
if (value === null || value === void 0) {
|
|
6406
|
+
throw new Error("Expected value to be defined");
|
|
6407
|
+
}
|
|
6408
|
+
return value;
|
|
6409
|
+
}
|
|
6321
6410
|
var DEFAULT_NUM = 10;
|
|
6322
6411
|
var MAX_RESULTS = 50;
|
|
6323
6412
|
var TIMEOUT_MS4 = 15e3;
|
|
@@ -6350,7 +6439,9 @@ var searchTool = {
|
|
|
6350
6439
|
},
|
|
6351
6440
|
async execute(input, ctx, opts) {
|
|
6352
6441
|
let final;
|
|
6353
|
-
|
|
6442
|
+
const executeStream = searchTool.executeStream;
|
|
6443
|
+
if (!executeStream) throw new Error("searchTool: stream execution unavailable");
|
|
6444
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
6354
6445
|
if (ev.type === "final") final = ev.output;
|
|
6355
6446
|
}
|
|
6356
6447
|
if (!final) throw new Error("search: stream ended without final event");
|
|
@@ -6411,11 +6502,11 @@ function parseDuckDuckGo(html, num) {
|
|
|
6411
6502
|
const snippetRegex = /<a class="result-link"[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>/gi;
|
|
6412
6503
|
const snippet2Regex = /<a class="result-snippet"[^>]*>([^<]+)<\/a>/gi;
|
|
6413
6504
|
const linkMatches = takeFrom(
|
|
6414
|
-
[...html.matchAll(snippetRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: m[1], title: stripTags2(m[2]) })),
|
|
6505
|
+
[...html.matchAll(snippetRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: expectDefined12(m[1]), title: stripTags2(expectDefined12(m[2])) })),
|
|
6415
6506
|
num
|
|
6416
6507
|
);
|
|
6417
6508
|
const snippetMatches = takeFrom(
|
|
6418
|
-
[...html.matchAll(snippet2Regex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
6509
|
+
[...html.matchAll(snippet2Regex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined12(m[1]))),
|
|
6419
6510
|
num
|
|
6420
6511
|
);
|
|
6421
6512
|
for (let i = 0; i < linkMatches.length && i < num; i++) {
|
|
@@ -6446,15 +6537,15 @@ function parseGoogleResults(html, num) {
|
|
|
6446
6537
|
const urlRegex = /<cite[^>]*>([^<]+)<\/cite>/gi;
|
|
6447
6538
|
const snippetRegex = /<span[^>]*class="[^"]*aXCZ0b[^>]*>([^<]+)<\/span>/gi;
|
|
6448
6539
|
const titles = takeFrom(
|
|
6449
|
-
[...html.matchAll(titleRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
6540
|
+
[...html.matchAll(titleRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined12(m[1]))),
|
|
6450
6541
|
num
|
|
6451
6542
|
);
|
|
6452
6543
|
const urls = takeFrom(
|
|
6453
|
-
[...html.matchAll(urlRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1]).replace(/^\*(https?:\/\/[^\s]+).*$/, "$1")).filter((u) => u.startsWith("http")),
|
|
6544
|
+
[...html.matchAll(urlRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined12(m[1])).replace(/^\*(https?:\/\/[^\s]+).*$/, "$1")).filter((u) => u.startsWith("http")),
|
|
6454
6545
|
num
|
|
6455
6546
|
);
|
|
6456
6547
|
const snippets = takeFrom(
|
|
6457
|
-
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
6548
|
+
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined12(m[1]))),
|
|
6458
6549
|
num
|
|
6459
6550
|
);
|
|
6460
6551
|
for (let i = 0; i < Math.min(titles.length, num); i++) {
|
|
@@ -6483,11 +6574,11 @@ function parseBingResults(html, num) {
|
|
|
6483
6574
|
const titleRegex = /<h2[^>]*>\s*<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>\s*<\/h2>/gi;
|
|
6484
6575
|
const snippetRegex = /<p[^>]*class="[^"]*b_paractl[^"]*"[^>]*>([^<]+)<\/p>/gi;
|
|
6485
6576
|
const entries = takeFrom(
|
|
6486
|
-
[...html.matchAll(titleRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: m[1], title: stripTags2(m[2]) })),
|
|
6577
|
+
[...html.matchAll(titleRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: expectDefined12(m[1]), title: stripTags2(expectDefined12(m[2])) })),
|
|
6487
6578
|
num
|
|
6488
6579
|
);
|
|
6489
6580
|
const snippets = takeFrom(
|
|
6490
|
-
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
6581
|
+
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined12(m[1]))),
|
|
6491
6582
|
num
|
|
6492
6583
|
);
|
|
6493
6584
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -6557,7 +6648,9 @@ var testTool = {
|
|
|
6557
6648
|
},
|
|
6558
6649
|
async execute(input, ctx, opts) {
|
|
6559
6650
|
let final;
|
|
6560
|
-
|
|
6651
|
+
const executeStream = testTool.executeStream;
|
|
6652
|
+
if (!executeStream) throw new Error("testTool: stream execution unavailable");
|
|
6653
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
6561
6654
|
if (ev.type === "final") final = ev.output;
|
|
6562
6655
|
}
|
|
6563
6656
|
if (!final) throw new Error("test: stream ended without final event");
|
|
@@ -7009,6 +7102,12 @@ var toolUseTool = {
|
|
|
7009
7102
|
}
|
|
7010
7103
|
}
|
|
7011
7104
|
};
|
|
7105
|
+
function expectDefined13(value) {
|
|
7106
|
+
if (value === null || value === void 0) {
|
|
7107
|
+
throw new Error("Expected value to be defined");
|
|
7108
|
+
}
|
|
7109
|
+
return value;
|
|
7110
|
+
}
|
|
7012
7111
|
var DEFAULT_IGNORE5 = [
|
|
7013
7112
|
"node_modules",
|
|
7014
7113
|
".git",
|
|
@@ -7069,7 +7168,9 @@ var treeTool = {
|
|
|
7069
7168
|
},
|
|
7070
7169
|
async execute(input, ctx, opts) {
|
|
7071
7170
|
let final;
|
|
7072
|
-
|
|
7171
|
+
const executeStream = treeTool.executeStream;
|
|
7172
|
+
if (!executeStream) throw new Error("treeTool: stream execution unavailable");
|
|
7173
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
7073
7174
|
if (ev.type === "final") final = ev.output;
|
|
7074
7175
|
}
|
|
7075
7176
|
if (!final) throw new Error("tree: stream ended without final event");
|
|
@@ -7119,7 +7220,7 @@ var treeTool = {
|
|
|
7119
7220
|
});
|
|
7120
7221
|
while (!walkDone || queue.length > 0) {
|
|
7121
7222
|
if (queue.length > 0) {
|
|
7122
|
-
yield queue.shift();
|
|
7223
|
+
yield expectDefined13(queue.shift());
|
|
7123
7224
|
} else {
|
|
7124
7225
|
let pollTimer;
|
|
7125
7226
|
const poll = new Promise((r) => {
|
|
@@ -7209,7 +7310,9 @@ var typecheckTool = {
|
|
|
7209
7310
|
},
|
|
7210
7311
|
async execute(input, ctx, opts) {
|
|
7211
7312
|
let final;
|
|
7212
|
-
|
|
7313
|
+
const executeStream = typecheckTool.executeStream;
|
|
7314
|
+
if (!executeStream) throw new Error("typecheckTool: stream execution unavailable");
|
|
7315
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
7213
7316
|
if (ev.type === "final") final = ev.output;
|
|
7214
7317
|
}
|
|
7215
7318
|
if (!final) throw new Error("typecheck: stream ended without final event");
|