memorix 1.8.6 → 1.8.8
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/CHANGELOG.md +41 -0
- package/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/dist/cli/index.js +2209 -1161
- package/dist/cli/memcode.js +0 -0
- package/dist/dashboard/static/app.js +51 -3
- package/dist/dashboard/static/style.css +88 -0
- package/dist/index.js +1726 -736
- package/dist/maintenance-runner.js +855 -218
- package/dist/media-audio-runner.js +856 -219
- package/dist/media-video-runner.js +854 -217
- package/dist/memcode-runtime/CHANGELOG.md +41 -0
- package/dist/sdk.js +1716 -726
- package/dist/vector-backfill-runner.js +853 -216
- package/docs/1.8.7-CODEGRAPH.md +166 -0
- package/docs/API_REFERENCE.md +23 -2
- package/docs/ARCHITECTURE.md +13 -0
- package/docs/README.md +4 -1
- package/package.json +4 -3
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +2 -2
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +2 -2
- package/plugins/codex/memorix/.codex-plugin/plugin.json +3 -3
- package/plugins/copilot/memorix/plugin.json +2 -2
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/hermes/memorix/plugin.yaml +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +3 -3
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +3 -3
- package/src/cli/commands/codegraph.ts +25 -11
- package/src/cli/commands/doctor.ts +11 -2
- package/src/cli/commands/serve-http.ts +27 -1
- package/src/cli/commands/setup.ts +1 -1
- package/src/codegraph/auto-context.ts +19 -10
- package/src/codegraph/context-pack.ts +20 -6
- package/src/codegraph/dashboard.ts +82 -0
- package/src/codegraph/external-provider.ts +10 -1
- package/src/codegraph/freshness.ts +1 -1
- package/src/codegraph/lite-provider.ts +81 -0
- package/src/codegraph/project-context.ts +18 -5
- package/src/codegraph/scip-provider.ts +181 -0
- package/src/codegraph/semantic-context.ts +139 -0
- package/src/codegraph/semantic-provider.ts +404 -0
- package/src/codegraph/store.ts +253 -18
- package/src/codegraph/types.ts +25 -3
- package/src/dashboard/server.ts +6 -0
- package/src/dashboard/static/style.css +88 -0
- package/src/knowledge/workset.ts +46 -44
- package/src/server/mcp-binding-store.ts +17 -0
- package/src/store/sqlite-db.ts +13 -0
|
@@ -695,6 +695,8 @@ CREATE TABLE IF NOT EXISTS code_files (
|
|
|
695
695
|
sizeBytes INTEGER,
|
|
696
696
|
indexedAt TEXT NOT NULL,
|
|
697
697
|
gitCommit TEXT,
|
|
698
|
+
source TEXT,
|
|
699
|
+
parserError TEXT,
|
|
698
700
|
UNIQUE(projectId, path)
|
|
699
701
|
);
|
|
700
702
|
`;
|
|
@@ -713,6 +715,7 @@ CREATE TABLE IF NOT EXISTS code_symbols (
|
|
|
713
715
|
contentHash TEXT,
|
|
714
716
|
indexedAt TEXT NOT NULL,
|
|
715
717
|
stale INTEGER NOT NULL DEFAULT 0,
|
|
718
|
+
source TEXT,
|
|
716
719
|
UNIQUE(projectId, fileId, qualifiedName, kind)
|
|
717
720
|
);
|
|
718
721
|
`;
|
|
@@ -727,6 +730,7 @@ CREATE TABLE IF NOT EXISTS code_edges (
|
|
|
727
730
|
type TEXT NOT NULL,
|
|
728
731
|
confidence REAL NOT NULL DEFAULT 1.0,
|
|
729
732
|
evidence TEXT,
|
|
733
|
+
source TEXT,
|
|
730
734
|
indexedAt TEXT NOT NULL
|
|
731
735
|
);
|
|
732
736
|
`;
|
|
@@ -1458,6 +1462,15 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_maintenance_jobs_active_dedupe
|
|
|
1458
1462
|
db2.exec("CREATE INDEX IF NOT EXISTS idx_memory_feedback_events_candidate ON memory_feedback_events(project_id, candidate_kind, candidate_id, observed_at DESC)");
|
|
1459
1463
|
db2.exec("CREATE INDEX IF NOT EXISTS idx_mcp_bindings_project ON mcp_bindings(project_id, last_used_at DESC)");
|
|
1460
1464
|
}
|
|
1465
|
+
},
|
|
1466
|
+
{
|
|
1467
|
+
id: "1.8.7-codegraph-evidence",
|
|
1468
|
+
apply: (db2) => {
|
|
1469
|
+
addColumnIfMissing(db2, "code_files", "source", "source TEXT");
|
|
1470
|
+
addColumnIfMissing(db2, "code_files", "parserError", "parserError TEXT");
|
|
1471
|
+
addColumnIfMissing(db2, "code_symbols", "source", "source TEXT");
|
|
1472
|
+
addColumnIfMissing(db2, "code_edges", "source", "source TEXT");
|
|
1473
|
+
}
|
|
1461
1474
|
}
|
|
1462
1475
|
];
|
|
1463
1476
|
_dbCache = /* @__PURE__ */ new Map();
|
|
@@ -3888,7 +3901,7 @@ function toProviderInput(input, baseUrl) {
|
|
|
3888
3901
|
return { type: input.modality, url: input.url };
|
|
3889
3902
|
}
|
|
3890
3903
|
function parseCacheJsonInWorker(filePath) {
|
|
3891
|
-
return new Promise((
|
|
3904
|
+
return new Promise((resolve2, reject) => {
|
|
3892
3905
|
void import("worker_threads").then(({ Worker }) => {
|
|
3893
3906
|
const worker = new Worker(
|
|
3894
3907
|
`
|
|
@@ -3909,7 +3922,7 @@ function parseCacheJsonInWorker(filePath) {
|
|
|
3909
3922
|
worker.once("message", (msg) => {
|
|
3910
3923
|
void worker.terminate();
|
|
3911
3924
|
if (msg?.ok && Array.isArray(msg.entries)) {
|
|
3912
|
-
|
|
3925
|
+
resolve2(msg.entries);
|
|
3913
3926
|
return;
|
|
3914
3927
|
}
|
|
3915
3928
|
reject(new Error(msg?.error || "embedding cache worker parse failed"));
|
|
@@ -3973,8 +3986,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
3973
3986
|
let count2 = 0;
|
|
3974
3987
|
const writeLine = async (line) => {
|
|
3975
3988
|
if (!out.write(line)) {
|
|
3976
|
-
await new Promise((
|
|
3977
|
-
out.once("drain",
|
|
3989
|
+
await new Promise((resolve2, reject) => {
|
|
3990
|
+
out.once("drain", resolve2);
|
|
3978
3991
|
out.once("error", reject);
|
|
3979
3992
|
});
|
|
3980
3993
|
}
|
|
@@ -4006,7 +4019,7 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
4006
4019
|
`);
|
|
4007
4020
|
count2 += 1;
|
|
4008
4021
|
if (count2 % 50 === 0) {
|
|
4009
|
-
await new Promise((
|
|
4022
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
4010
4023
|
}
|
|
4011
4024
|
}
|
|
4012
4025
|
}
|
|
@@ -4015,8 +4028,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
4015
4028
|
}
|
|
4016
4029
|
}
|
|
4017
4030
|
} finally {
|
|
4018
|
-
await new Promise((
|
|
4019
|
-
out.end(() =>
|
|
4031
|
+
await new Promise((resolve2, reject) => {
|
|
4032
|
+
out.end(() => resolve2());
|
|
4020
4033
|
out.once("error", reject);
|
|
4021
4034
|
});
|
|
4022
4035
|
}
|
|
@@ -4061,7 +4074,7 @@ async function loadCacheJsonl(filePath) {
|
|
|
4061
4074
|
} catch {
|
|
4062
4075
|
}
|
|
4063
4076
|
if (onDiskCount % 250 === 0) {
|
|
4064
|
-
await new Promise((
|
|
4077
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
4065
4078
|
}
|
|
4066
4079
|
}
|
|
4067
4080
|
diskCacheEntryCount = onDiskCount;
|
|
@@ -4306,7 +4319,7 @@ async function saveDiskCacheNow() {
|
|
|
4306
4319
|
return;
|
|
4307
4320
|
}
|
|
4308
4321
|
const tmpPath = `${jsonlPath}.tmp`;
|
|
4309
|
-
await new Promise((
|
|
4322
|
+
await new Promise((resolve2, reject) => {
|
|
4310
4323
|
const out = createWriteStream(tmpPath);
|
|
4311
4324
|
const entries = cache3.entries();
|
|
4312
4325
|
const writeBatch = () => {
|
|
@@ -4325,7 +4338,7 @@ async function saveDiskCacheNow() {
|
|
|
4325
4338
|
}
|
|
4326
4339
|
setImmediate(writeBatch);
|
|
4327
4340
|
};
|
|
4328
|
-
out.on("finish",
|
|
4341
|
+
out.on("finish", resolve2);
|
|
4329
4342
|
out.on("error", reject);
|
|
4330
4343
|
writeBatch();
|
|
4331
4344
|
});
|
|
@@ -4429,7 +4442,7 @@ function abortError() {
|
|
|
4429
4442
|
}
|
|
4430
4443
|
function raceWithAbort(promise, signal) {
|
|
4431
4444
|
if (signal.aborted) return Promise.reject(abortError());
|
|
4432
|
-
return new Promise((
|
|
4445
|
+
return new Promise((resolve2, reject) => {
|
|
4433
4446
|
const onAbort = () => {
|
|
4434
4447
|
signal.removeEventListener("abort", onAbort);
|
|
4435
4448
|
reject(abortError());
|
|
@@ -4438,7 +4451,7 @@ function raceWithAbort(promise, signal) {
|
|
|
4438
4451
|
promise.then(
|
|
4439
4452
|
(value) => {
|
|
4440
4453
|
signal.removeEventListener("abort", onAbort);
|
|
4441
|
-
|
|
4454
|
+
resolve2(value);
|
|
4442
4455
|
},
|
|
4443
4456
|
(error) => {
|
|
4444
4457
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -4449,12 +4462,12 @@ function raceWithAbort(promise, signal) {
|
|
|
4449
4462
|
}
|
|
4450
4463
|
async function waitForRetry(waitMs, signal) {
|
|
4451
4464
|
if (!signal) {
|
|
4452
|
-
await new Promise((
|
|
4465
|
+
await new Promise((resolve2) => setTimeout(resolve2, waitMs));
|
|
4453
4466
|
return;
|
|
4454
4467
|
}
|
|
4455
4468
|
const abortSignal = signal;
|
|
4456
4469
|
if (abortSignal.aborted) throw new Error("Embedding API retry aborted");
|
|
4457
|
-
await new Promise((
|
|
4470
|
+
await new Promise((resolve2, reject) => {
|
|
4458
4471
|
const timer = setTimeout(done, waitMs);
|
|
4459
4472
|
const onAbort = () => {
|
|
4460
4473
|
clearTimeout(timer);
|
|
@@ -4463,7 +4476,7 @@ async function waitForRetry(waitMs, signal) {
|
|
|
4463
4476
|
};
|
|
4464
4477
|
function done() {
|
|
4465
4478
|
abortSignal.removeEventListener("abort", onAbort);
|
|
4466
|
-
|
|
4479
|
+
resolve2();
|
|
4467
4480
|
}
|
|
4468
4481
|
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
4469
4482
|
});
|
|
@@ -6272,12 +6285,12 @@ var init_policy = __esm({
|
|
|
6272
6285
|
|
|
6273
6286
|
// src/timeout.ts
|
|
6274
6287
|
function withTimeout(promise, ms, label) {
|
|
6275
|
-
return new Promise((
|
|
6288
|
+
return new Promise((resolve2, reject) => {
|
|
6276
6289
|
const timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
|
|
6277
6290
|
promise.then(
|
|
6278
6291
|
(value) => {
|
|
6279
6292
|
clearTimeout(timer);
|
|
6280
|
-
|
|
6293
|
+
resolve2(value);
|
|
6281
6294
|
},
|
|
6282
6295
|
(error) => {
|
|
6283
6296
|
clearTimeout(timer);
|
|
@@ -6289,7 +6302,7 @@ function withTimeout(promise, ms, label) {
|
|
|
6289
6302
|
function withTimeoutSignal(operation, ms, label, parentSignal) {
|
|
6290
6303
|
const controller = new AbortController();
|
|
6291
6304
|
const signal = parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal;
|
|
6292
|
-
return new Promise((
|
|
6305
|
+
return new Promise((resolve2, reject) => {
|
|
6293
6306
|
let settled = false;
|
|
6294
6307
|
let timedOut = false;
|
|
6295
6308
|
let timer;
|
|
@@ -6326,7 +6339,7 @@ function withTimeoutSignal(operation, ms, label, parentSignal) {
|
|
|
6326
6339
|
if (settled) return;
|
|
6327
6340
|
settled = true;
|
|
6328
6341
|
cleanup();
|
|
6329
|
-
|
|
6342
|
+
resolve2(value);
|
|
6330
6343
|
},
|
|
6331
6344
|
(error) => {
|
|
6332
6345
|
if (settled) return;
|
|
@@ -7159,7 +7172,7 @@ async function attachCachedVectors(database, candidates) {
|
|
|
7159
7172
|
} catch {
|
|
7160
7173
|
}
|
|
7161
7174
|
if (index % 50 === 0) {
|
|
7162
|
-
await new Promise((
|
|
7175
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
7163
7176
|
}
|
|
7164
7177
|
}
|
|
7165
7178
|
}
|
|
@@ -7235,7 +7248,7 @@ async function hydrateIndex(observations2, options = {}) {
|
|
|
7235
7248
|
}
|
|
7236
7249
|
}
|
|
7237
7250
|
}
|
|
7238
|
-
await new Promise((
|
|
7251
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
7239
7252
|
}
|
|
7240
7253
|
deferredCachedVectorHydration = options.skipCachedVectors ? null : deferCachedVectors ? attachCachedVectors(database, candidates).catch(() => {
|
|
7241
7254
|
}) : null;
|
|
@@ -9001,8 +9014,8 @@ function localWorkspacePath(dataDir, projectId) {
|
|
|
9001
9014
|
return path9.join(path9.resolve(dataDir), "knowledge-workspaces", hash(projectId).slice(0, 24));
|
|
9002
9015
|
}
|
|
9003
9016
|
function isWithin(root, candidate) {
|
|
9004
|
-
const
|
|
9005
|
-
return
|
|
9017
|
+
const relative3 = path9.relative(root, candidate);
|
|
9018
|
+
return relative3 !== "" && !relative3.startsWith(".." + path9.sep) && relative3 !== ".." && !path9.isAbsolute(relative3);
|
|
9006
9019
|
}
|
|
9007
9020
|
function ensureVersionedPath(projectRoot, rootPath) {
|
|
9008
9021
|
if (!path9.isAbsolute(rootPath)) {
|
|
@@ -9020,8 +9033,8 @@ function ensureVersionedPath(projectRoot, rootPath) {
|
|
|
9020
9033
|
return resolvedWorkspace;
|
|
9021
9034
|
}
|
|
9022
9035
|
async function isIgnoredByGit(projectRoot, workspaceRoot) {
|
|
9023
|
-
const
|
|
9024
|
-
const probes = [
|
|
9036
|
+
const relative3 = path9.relative(projectRoot, workspaceRoot).split(path9.sep).join("/");
|
|
9037
|
+
const probes = [relative3, relative3.replace(/\/+$/, "") + "/.memorix-workspace-probe"];
|
|
9025
9038
|
for (const probe of probes) {
|
|
9026
9039
|
try {
|
|
9027
9040
|
await execFileAsync("git", ["-C", projectRoot, "check-ignore", "--quiet", "--no-index", "--", probe], {
|
|
@@ -9610,8 +9623,8 @@ function projectStorageKey(projectId) {
|
|
|
9610
9623
|
}
|
|
9611
9624
|
function validateUnderRoot(root, candidate) {
|
|
9612
9625
|
const resolved = path10.resolve(candidate);
|
|
9613
|
-
const
|
|
9614
|
-
if (
|
|
9626
|
+
const relative3 = path10.relative(root, resolved);
|
|
9627
|
+
if (relative3.startsWith("..") || path10.isAbsolute(relative3)) {
|
|
9615
9628
|
throw new Error("Media storage path escaped the Memorix data directory");
|
|
9616
9629
|
}
|
|
9617
9630
|
return resolved;
|
|
@@ -9655,8 +9668,8 @@ function detectMedia(bytes) {
|
|
|
9655
9668
|
throw new Error("Unsupported or unrecognized media format");
|
|
9656
9669
|
}
|
|
9657
9670
|
function destinationFor(root, projectId, sha256, extension3) {
|
|
9658
|
-
const
|
|
9659
|
-
return { relative:
|
|
9671
|
+
const relative3 = path10.join("assets", projectStorageKey(projectId), sha256.slice(0, 2), `${sha256}${extension3}`);
|
|
9672
|
+
return { relative: relative3, absolute: validateUnderRoot(root, path10.join(root, relative3)) };
|
|
9660
9673
|
}
|
|
9661
9674
|
async function destinationExists(destination) {
|
|
9662
9675
|
try {
|
|
@@ -18186,7 +18199,7 @@ var init_sleep = __esm({
|
|
|
18186
18199
|
"node_modules/openai/internal/utils/sleep.mjs"() {
|
|
18187
18200
|
"use strict";
|
|
18188
18201
|
init_esm_shims();
|
|
18189
|
-
sleep = (ms) => new Promise((
|
|
18202
|
+
sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
18190
18203
|
}
|
|
18191
18204
|
});
|
|
18192
18205
|
|
|
@@ -19375,8 +19388,8 @@ var init_api_promise = __esm({
|
|
|
19375
19388
|
init_parse();
|
|
19376
19389
|
APIPromise = class _APIPromise extends Promise {
|
|
19377
19390
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
19378
|
-
super((
|
|
19379
|
-
|
|
19391
|
+
super((resolve2) => {
|
|
19392
|
+
resolve2(null);
|
|
19380
19393
|
});
|
|
19381
19394
|
this.responsePromise = responsePromise;
|
|
19382
19395
|
this.parseResponse = parseResponse2;
|
|
@@ -20020,12 +20033,12 @@ var init_EventStream = __esm({
|
|
|
20020
20033
|
_EventStream_errored.set(this, false);
|
|
20021
20034
|
_EventStream_aborted.set(this, false);
|
|
20022
20035
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
20023
|
-
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((
|
|
20024
|
-
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise,
|
|
20036
|
+
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
20037
|
+
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve2, "f");
|
|
20025
20038
|
__classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
20026
20039
|
}), "f");
|
|
20027
|
-
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((
|
|
20028
|
-
__classPrivateFieldSet(this, _EventStream_resolveEndPromise,
|
|
20040
|
+
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
|
|
20041
|
+
__classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve2, "f");
|
|
20029
20042
|
__classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject, "f");
|
|
20030
20043
|
}), "f");
|
|
20031
20044
|
__classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => {
|
|
@@ -20109,11 +20122,11 @@ var init_EventStream = __esm({
|
|
|
20109
20122
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
20110
20123
|
*/
|
|
20111
20124
|
emitted(event) {
|
|
20112
|
-
return new Promise((
|
|
20125
|
+
return new Promise((resolve2, reject) => {
|
|
20113
20126
|
__classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
20114
20127
|
if (event !== "error")
|
|
20115
20128
|
this.once("error", reject);
|
|
20116
|
-
this.once(event,
|
|
20129
|
+
this.once(event, resolve2);
|
|
20117
20130
|
});
|
|
20118
20131
|
}
|
|
20119
20132
|
async done() {
|
|
@@ -21182,7 +21195,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
21182
21195
|
if (done) {
|
|
21183
21196
|
return { value: void 0, done: true };
|
|
21184
21197
|
}
|
|
21185
|
-
return new Promise((
|
|
21198
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
21186
21199
|
}
|
|
21187
21200
|
const chunk = pushQueue.shift();
|
|
21188
21201
|
return { value: chunk, done: false };
|
|
@@ -22165,7 +22178,7 @@ var init_AssistantStream = __esm({
|
|
|
22165
22178
|
if (done) {
|
|
22166
22179
|
return { value: void 0, done: true };
|
|
22167
22180
|
}
|
|
22168
|
-
return new Promise((
|
|
22181
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
22169
22182
|
}
|
|
22170
22183
|
const chunk = pushQueue.shift();
|
|
22171
22184
|
return { value: chunk, done: false };
|
|
@@ -24454,7 +24467,7 @@ var init_ResponseStream = __esm({
|
|
|
24454
24467
|
if (done) {
|
|
24455
24468
|
return { value: void 0, done: true };
|
|
24456
24469
|
}
|
|
24457
|
-
return new Promise((
|
|
24470
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
24458
24471
|
}
|
|
24459
24472
|
const event = pushQueue.shift();
|
|
24460
24473
|
return { value: event, done: false };
|
|
@@ -44653,8 +44666,8 @@ var init_event_stream = __esm({
|
|
|
44653
44666
|
constructor(isComplete, extractResult) {
|
|
44654
44667
|
this.isComplete = isComplete;
|
|
44655
44668
|
this.extractResult = extractResult;
|
|
44656
|
-
this.finalResultPromise = new Promise((
|
|
44657
|
-
this.resolveFinalResult =
|
|
44669
|
+
this.finalResultPromise = new Promise((resolve2) => {
|
|
44670
|
+
this.resolveFinalResult = resolve2;
|
|
44658
44671
|
});
|
|
44659
44672
|
}
|
|
44660
44673
|
push(event) {
|
|
@@ -44688,7 +44701,7 @@ var init_event_stream = __esm({
|
|
|
44688
44701
|
} else if (this.done) {
|
|
44689
44702
|
return;
|
|
44690
44703
|
} else {
|
|
44691
|
-
const result = await new Promise((
|
|
44704
|
+
const result = await new Promise((resolve2) => this.waiting.push(resolve2));
|
|
44692
44705
|
if (result.done)
|
|
44693
44706
|
return;
|
|
44694
44707
|
yield result.value;
|
|
@@ -44959,7 +44972,7 @@ var init_sleep2 = __esm({
|
|
|
44959
44972
|
"node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
44960
44973
|
"use strict";
|
|
44961
44974
|
init_esm_shims();
|
|
44962
|
-
sleep2 = (ms) => new Promise((
|
|
44975
|
+
sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
44963
44976
|
}
|
|
44964
44977
|
});
|
|
44965
44978
|
|
|
@@ -45759,8 +45772,8 @@ var init_api_promise2 = __esm({
|
|
|
45759
45772
|
init_parse2();
|
|
45760
45773
|
APIPromise2 = class _APIPromise extends Promise {
|
|
45761
45774
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
45762
|
-
super((
|
|
45763
|
-
|
|
45775
|
+
super((resolve2) => {
|
|
45776
|
+
resolve2(null);
|
|
45764
45777
|
});
|
|
45765
45778
|
this.responsePromise = responsePromise;
|
|
45766
45779
|
this.parseResponse = parseResponse2;
|
|
@@ -47721,12 +47734,12 @@ var init_BetaMessageStream = __esm({
|
|
|
47721
47734
|
}
|
|
47722
47735
|
return this._emit("error", new AnthropicError(String(error)));
|
|
47723
47736
|
});
|
|
47724
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
47725
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise,
|
|
47737
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
47738
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve2, "f");
|
|
47726
47739
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
47727
47740
|
}), "f");
|
|
47728
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((
|
|
47729
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise,
|
|
47741
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
47742
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve2, "f");
|
|
47730
47743
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
47731
47744
|
}), "f");
|
|
47732
47745
|
__classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47896,11 +47909,11 @@ var init_BetaMessageStream = __esm({
|
|
|
47896
47909
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47897
47910
|
*/
|
|
47898
47911
|
emitted(event) {
|
|
47899
|
-
return new Promise((
|
|
47912
|
+
return new Promise((resolve2, reject) => {
|
|
47900
47913
|
__classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
47901
47914
|
if (event !== "error")
|
|
47902
47915
|
this.once("error", reject);
|
|
47903
|
-
this.once(event,
|
|
47916
|
+
this.once(event, resolve2);
|
|
47904
47917
|
});
|
|
47905
47918
|
}
|
|
47906
47919
|
async done() {
|
|
@@ -48243,7 +48256,7 @@ var init_BetaMessageStream = __esm({
|
|
|
48243
48256
|
if (done) {
|
|
48244
48257
|
return { value: void 0, done: true };
|
|
48245
48258
|
}
|
|
48246
|
-
return new Promise((
|
|
48259
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
48247
48260
|
}
|
|
48248
48261
|
const chunk = pushQueue.shift();
|
|
48249
48262
|
return { value: chunk, done: false };
|
|
@@ -48318,13 +48331,13 @@ Wrap your summary in <summary></summary> tags.`;
|
|
|
48318
48331
|
|
|
48319
48332
|
// node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs
|
|
48320
48333
|
function promiseWithResolvers() {
|
|
48321
|
-
let
|
|
48334
|
+
let resolve2;
|
|
48322
48335
|
let reject;
|
|
48323
48336
|
const promise = new Promise((res, rej) => {
|
|
48324
|
-
|
|
48337
|
+
resolve2 = res;
|
|
48325
48338
|
reject = rej;
|
|
48326
48339
|
});
|
|
48327
|
-
return { promise, resolve, reject };
|
|
48340
|
+
return { promise, resolve: resolve2, reject };
|
|
48328
48341
|
}
|
|
48329
48342
|
async function generateToolResponse(params, lastMessage = params.messages.at(-1), requestOptions) {
|
|
48330
48343
|
if (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content || typeof lastMessage.content === "string") {
|
|
@@ -50182,12 +50195,12 @@ var init_MessageStream = __esm({
|
|
|
50182
50195
|
}
|
|
50183
50196
|
return this._emit("error", new AnthropicError(String(error)));
|
|
50184
50197
|
});
|
|
50185
|
-
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((
|
|
50186
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise,
|
|
50198
|
+
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
50199
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise, resolve2, "f");
|
|
50187
50200
|
__classPrivateFieldSet2(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
50188
50201
|
}), "f");
|
|
50189
|
-
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((
|
|
50190
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise,
|
|
50202
|
+
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
50203
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise, resolve2, "f");
|
|
50191
50204
|
__classPrivateFieldSet2(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
50192
50205
|
}), "f");
|
|
50193
50206
|
__classPrivateFieldGet2(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -50357,11 +50370,11 @@ var init_MessageStream = __esm({
|
|
|
50357
50370
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
50358
50371
|
*/
|
|
50359
50372
|
emitted(event) {
|
|
50360
|
-
return new Promise((
|
|
50373
|
+
return new Promise((resolve2, reject) => {
|
|
50361
50374
|
__classPrivateFieldSet2(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
50362
50375
|
if (event !== "error")
|
|
50363
50376
|
this.once("error", reject);
|
|
50364
|
-
this.once(event,
|
|
50377
|
+
this.once(event, resolve2);
|
|
50365
50378
|
});
|
|
50366
50379
|
}
|
|
50367
50380
|
async done() {
|
|
@@ -50679,7 +50692,7 @@ var init_MessageStream = __esm({
|
|
|
50679
50692
|
if (done) {
|
|
50680
50693
|
return { value: void 0, done: true };
|
|
50681
50694
|
}
|
|
50682
|
-
return new Promise((
|
|
50695
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
50683
50696
|
}
|
|
50684
50697
|
const chunk = pushQueue.shift();
|
|
50685
50698
|
return { value: chunk, done: false };
|
|
@@ -54057,7 +54070,7 @@ var require_p_retry = __commonJS({
|
|
|
54057
54070
|
return error;
|
|
54058
54071
|
};
|
|
54059
54072
|
var isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
|
|
54060
|
-
var pRetry2 = (input, options) => new Promise((
|
|
54073
|
+
var pRetry2 = (input, options) => new Promise((resolve2, reject) => {
|
|
54061
54074
|
options = {
|
|
54062
54075
|
onFailedAttempt: () => {
|
|
54063
54076
|
},
|
|
@@ -54067,7 +54080,7 @@ var require_p_retry = __commonJS({
|
|
|
54067
54080
|
const operation = retry2.operation(options);
|
|
54068
54081
|
operation.attempt(async (attemptNumber) => {
|
|
54069
54082
|
try {
|
|
54070
|
-
|
|
54083
|
+
resolve2(await input(attemptNumber));
|
|
54071
54084
|
} catch (error) {
|
|
54072
54085
|
if (!(error instanceof Error)) {
|
|
54073
54086
|
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
@@ -54605,8 +54618,8 @@ var require_retry3 = __commonJS({
|
|
|
54605
54618
|
}
|
|
54606
54619
|
const delay2 = getNextRetryDelay(config);
|
|
54607
54620
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
54608
|
-
const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((
|
|
54609
|
-
setTimeout(
|
|
54621
|
+
const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((resolve2) => {
|
|
54622
|
+
setTimeout(resolve2, delay2);
|
|
54610
54623
|
});
|
|
54611
54624
|
if (config.onRetryAttempt) {
|
|
54612
54625
|
await config.onRetryAttempt(err);
|
|
@@ -55523,8 +55536,8 @@ var require_helpers = __commonJS({
|
|
|
55523
55536
|
function req(url, opts = {}) {
|
|
55524
55537
|
const href = typeof url === "string" ? url : url.href;
|
|
55525
55538
|
const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts);
|
|
55526
|
-
const promise = new Promise((
|
|
55527
|
-
req2.once("response",
|
|
55539
|
+
const promise = new Promise((resolve2, reject) => {
|
|
55540
|
+
req2.once("response", resolve2).once("error", reject).end();
|
|
55528
55541
|
});
|
|
55529
55542
|
req2.then = promise.then.bind(promise);
|
|
55530
55543
|
return req2;
|
|
@@ -55703,7 +55716,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
55703
55716
|
var debug_1 = __importDefault(require_src());
|
|
55704
55717
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
55705
55718
|
function parseProxyResponse(socket) {
|
|
55706
|
-
return new Promise((
|
|
55719
|
+
return new Promise((resolve2, reject) => {
|
|
55707
55720
|
let buffersLength = 0;
|
|
55708
55721
|
const buffers = [];
|
|
55709
55722
|
function read() {
|
|
@@ -55769,7 +55782,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
55769
55782
|
}
|
|
55770
55783
|
debug("got proxy server response: %o %o", firstLine, headers);
|
|
55771
55784
|
cleanup();
|
|
55772
|
-
|
|
55785
|
+
resolve2({
|
|
55773
55786
|
connect: {
|
|
55774
55787
|
statusCode,
|
|
55775
55788
|
statusText,
|
|
@@ -56016,7 +56029,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56016
56029
|
return new originalPromise(executor);
|
|
56017
56030
|
}
|
|
56018
56031
|
function promiseResolvedWith(value) {
|
|
56019
|
-
return newPromise((
|
|
56032
|
+
return newPromise((resolve2) => resolve2(value));
|
|
56020
56033
|
}
|
|
56021
56034
|
function promiseRejectedWith(reason) {
|
|
56022
56035
|
return originalPromiseReject(reason);
|
|
@@ -56186,8 +56199,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56186
56199
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
56187
56200
|
}
|
|
56188
56201
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
56189
|
-
reader._closedPromise = newPromise((
|
|
56190
|
-
reader._closedPromise_resolve =
|
|
56202
|
+
reader._closedPromise = newPromise((resolve2, reject) => {
|
|
56203
|
+
reader._closedPromise_resolve = resolve2;
|
|
56191
56204
|
reader._closedPromise_reject = reject;
|
|
56192
56205
|
});
|
|
56193
56206
|
}
|
|
@@ -56361,8 +56374,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56361
56374
|
}
|
|
56362
56375
|
let resolvePromise;
|
|
56363
56376
|
let rejectPromise;
|
|
56364
|
-
const promise = newPromise((
|
|
56365
|
-
resolvePromise =
|
|
56377
|
+
const promise = newPromise((resolve2, reject) => {
|
|
56378
|
+
resolvePromise = resolve2;
|
|
56366
56379
|
rejectPromise = reject;
|
|
56367
56380
|
});
|
|
56368
56381
|
const readRequest = {
|
|
@@ -56467,8 +56480,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56467
56480
|
const reader = this._reader;
|
|
56468
56481
|
let resolvePromise;
|
|
56469
56482
|
let rejectPromise;
|
|
56470
|
-
const promise = newPromise((
|
|
56471
|
-
resolvePromise =
|
|
56483
|
+
const promise = newPromise((resolve2, reject) => {
|
|
56484
|
+
resolvePromise = resolve2;
|
|
56472
56485
|
rejectPromise = reject;
|
|
56473
56486
|
});
|
|
56474
56487
|
const readRequest = {
|
|
@@ -57487,8 +57500,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57487
57500
|
}
|
|
57488
57501
|
let resolvePromise;
|
|
57489
57502
|
let rejectPromise;
|
|
57490
|
-
const promise = newPromise((
|
|
57491
|
-
resolvePromise =
|
|
57503
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57504
|
+
resolvePromise = resolve2;
|
|
57492
57505
|
rejectPromise = reject;
|
|
57493
57506
|
});
|
|
57494
57507
|
const readIntoRequest = {
|
|
@@ -57800,10 +57813,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57800
57813
|
wasAlreadyErroring = true;
|
|
57801
57814
|
reason = void 0;
|
|
57802
57815
|
}
|
|
57803
|
-
const promise = newPromise((
|
|
57816
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57804
57817
|
stream2._pendingAbortRequest = {
|
|
57805
57818
|
_promise: void 0,
|
|
57806
|
-
_resolve:
|
|
57819
|
+
_resolve: resolve2,
|
|
57807
57820
|
_reject: reject,
|
|
57808
57821
|
_reason: reason,
|
|
57809
57822
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -57820,9 +57833,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57820
57833
|
if (state === "closed" || state === "errored") {
|
|
57821
57834
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
57822
57835
|
}
|
|
57823
|
-
const promise = newPromise((
|
|
57836
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57824
57837
|
const closeRequest = {
|
|
57825
|
-
_resolve:
|
|
57838
|
+
_resolve: resolve2,
|
|
57826
57839
|
_reject: reject
|
|
57827
57840
|
};
|
|
57828
57841
|
stream2._closeRequest = closeRequest;
|
|
@@ -57835,9 +57848,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57835
57848
|
return promise;
|
|
57836
57849
|
}
|
|
57837
57850
|
function WritableStreamAddWriteRequest(stream2) {
|
|
57838
|
-
const promise = newPromise((
|
|
57851
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57839
57852
|
const writeRequest = {
|
|
57840
|
-
_resolve:
|
|
57853
|
+
_resolve: resolve2,
|
|
57841
57854
|
_reject: reject
|
|
57842
57855
|
};
|
|
57843
57856
|
stream2._writeRequests.push(writeRequest);
|
|
@@ -58453,8 +58466,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58453
58466
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
58454
58467
|
}
|
|
58455
58468
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
58456
|
-
writer._closedPromise = newPromise((
|
|
58457
|
-
writer._closedPromise_resolve =
|
|
58469
|
+
writer._closedPromise = newPromise((resolve2, reject) => {
|
|
58470
|
+
writer._closedPromise_resolve = resolve2;
|
|
58458
58471
|
writer._closedPromise_reject = reject;
|
|
58459
58472
|
writer._closedPromiseState = "pending";
|
|
58460
58473
|
});
|
|
@@ -58490,8 +58503,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58490
58503
|
writer._closedPromiseState = "resolved";
|
|
58491
58504
|
}
|
|
58492
58505
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
58493
|
-
writer._readyPromise = newPromise((
|
|
58494
|
-
writer._readyPromise_resolve =
|
|
58506
|
+
writer._readyPromise = newPromise((resolve2, reject) => {
|
|
58507
|
+
writer._readyPromise_resolve = resolve2;
|
|
58495
58508
|
writer._readyPromise_reject = reject;
|
|
58496
58509
|
});
|
|
58497
58510
|
writer._readyPromiseState = "pending";
|
|
@@ -58578,7 +58591,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58578
58591
|
source._disturbed = true;
|
|
58579
58592
|
let shuttingDown = false;
|
|
58580
58593
|
let currentWrite = promiseResolvedWith(void 0);
|
|
58581
|
-
return newPromise((
|
|
58594
|
+
return newPromise((resolve2, reject) => {
|
|
58582
58595
|
let abortAlgorithm;
|
|
58583
58596
|
if (signal !== void 0) {
|
|
58584
58597
|
abortAlgorithm = () => {
|
|
@@ -58723,7 +58736,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58723
58736
|
if (isError) {
|
|
58724
58737
|
reject(error);
|
|
58725
58738
|
} else {
|
|
58726
|
-
|
|
58739
|
+
resolve2(void 0);
|
|
58727
58740
|
}
|
|
58728
58741
|
return null;
|
|
58729
58742
|
}
|
|
@@ -59004,8 +59017,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59004
59017
|
let branch1;
|
|
59005
59018
|
let branch2;
|
|
59006
59019
|
let resolveCancelPromise;
|
|
59007
|
-
const cancelPromise = newPromise((
|
|
59008
|
-
resolveCancelPromise =
|
|
59020
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
59021
|
+
resolveCancelPromise = resolve2;
|
|
59009
59022
|
});
|
|
59010
59023
|
function pullAlgorithm() {
|
|
59011
59024
|
if (reading) {
|
|
@@ -59096,8 +59109,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59096
59109
|
let branch1;
|
|
59097
59110
|
let branch2;
|
|
59098
59111
|
let resolveCancelPromise;
|
|
59099
|
-
const cancelPromise = newPromise((
|
|
59100
|
-
resolveCancelPromise =
|
|
59112
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
59113
|
+
resolveCancelPromise = resolve2;
|
|
59101
59114
|
});
|
|
59102
59115
|
function forwardReaderError(thisReader) {
|
|
59103
59116
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -59877,8 +59890,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59877
59890
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
59878
59891
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
59879
59892
|
let startPromise_resolve;
|
|
59880
|
-
const startPromise = newPromise((
|
|
59881
|
-
startPromise_resolve =
|
|
59893
|
+
const startPromise = newPromise((resolve2) => {
|
|
59894
|
+
startPromise_resolve = resolve2;
|
|
59882
59895
|
});
|
|
59883
59896
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
59884
59897
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -59971,8 +59984,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59971
59984
|
if (stream2._backpressureChangePromise !== void 0) {
|
|
59972
59985
|
stream2._backpressureChangePromise_resolve();
|
|
59973
59986
|
}
|
|
59974
|
-
stream2._backpressureChangePromise = newPromise((
|
|
59975
|
-
stream2._backpressureChangePromise_resolve =
|
|
59987
|
+
stream2._backpressureChangePromise = newPromise((resolve2) => {
|
|
59988
|
+
stream2._backpressureChangePromise_resolve = resolve2;
|
|
59976
59989
|
});
|
|
59977
59990
|
stream2._backpressure = backpressure;
|
|
59978
59991
|
}
|
|
@@ -60140,8 +60153,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60140
60153
|
return controller._finishPromise;
|
|
60141
60154
|
}
|
|
60142
60155
|
const readable = stream2._readable;
|
|
60143
|
-
controller._finishPromise = newPromise((
|
|
60144
|
-
controller._finishPromise_resolve =
|
|
60156
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60157
|
+
controller._finishPromise_resolve = resolve2;
|
|
60145
60158
|
controller._finishPromise_reject = reject;
|
|
60146
60159
|
});
|
|
60147
60160
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -60167,8 +60180,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60167
60180
|
return controller._finishPromise;
|
|
60168
60181
|
}
|
|
60169
60182
|
const readable = stream2._readable;
|
|
60170
|
-
controller._finishPromise = newPromise((
|
|
60171
|
-
controller._finishPromise_resolve =
|
|
60183
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60184
|
+
controller._finishPromise_resolve = resolve2;
|
|
60172
60185
|
controller._finishPromise_reject = reject;
|
|
60173
60186
|
});
|
|
60174
60187
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -60198,8 +60211,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60198
60211
|
return controller._finishPromise;
|
|
60199
60212
|
}
|
|
60200
60213
|
const writable = stream2._writable;
|
|
60201
|
-
controller._finishPromise = newPromise((
|
|
60202
|
-
controller._finishPromise_resolve =
|
|
60214
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60215
|
+
controller._finishPromise_resolve = resolve2;
|
|
60203
60216
|
controller._finishPromise_reject = reject;
|
|
60204
60217
|
});
|
|
60205
60218
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -62186,7 +62199,7 @@ import zlib from "zlib";
|
|
|
62186
62199
|
import Stream4, { PassThrough as PassThrough2, pipeline as pump } from "stream";
|
|
62187
62200
|
import { Buffer as Buffer3 } from "buffer";
|
|
62188
62201
|
async function fetch2(url, options_) {
|
|
62189
|
-
return new Promise((
|
|
62202
|
+
return new Promise((resolve2, reject) => {
|
|
62190
62203
|
const request = new Request2(url, options_);
|
|
62191
62204
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
62192
62205
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -62195,7 +62208,7 @@ async function fetch2(url, options_) {
|
|
|
62195
62208
|
if (parsedURL.protocol === "data:") {
|
|
62196
62209
|
const data = dist_default(request.url);
|
|
62197
62210
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
62198
|
-
|
|
62211
|
+
resolve2(response2);
|
|
62199
62212
|
return;
|
|
62200
62213
|
}
|
|
62201
62214
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -62317,7 +62330,7 @@ async function fetch2(url, options_) {
|
|
|
62317
62330
|
if (responseReferrerPolicy) {
|
|
62318
62331
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
62319
62332
|
}
|
|
62320
|
-
|
|
62333
|
+
resolve2(fetch2(new Request2(locationURL, requestOptions)));
|
|
62321
62334
|
finalize();
|
|
62322
62335
|
return;
|
|
62323
62336
|
}
|
|
@@ -62350,7 +62363,7 @@ async function fetch2(url, options_) {
|
|
|
62350
62363
|
const codings = headers.get("Content-Encoding");
|
|
62351
62364
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
62352
62365
|
response = new Response2(body, responseOptions);
|
|
62353
|
-
|
|
62366
|
+
resolve2(response);
|
|
62354
62367
|
return;
|
|
62355
62368
|
}
|
|
62356
62369
|
const zlibOptions = {
|
|
@@ -62364,7 +62377,7 @@ async function fetch2(url, options_) {
|
|
|
62364
62377
|
}
|
|
62365
62378
|
});
|
|
62366
62379
|
response = new Response2(body, responseOptions);
|
|
62367
|
-
|
|
62380
|
+
resolve2(response);
|
|
62368
62381
|
return;
|
|
62369
62382
|
}
|
|
62370
62383
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -62388,12 +62401,12 @@ async function fetch2(url, options_) {
|
|
|
62388
62401
|
});
|
|
62389
62402
|
}
|
|
62390
62403
|
response = new Response2(body, responseOptions);
|
|
62391
|
-
|
|
62404
|
+
resolve2(response);
|
|
62392
62405
|
});
|
|
62393
62406
|
raw.once("end", () => {
|
|
62394
62407
|
if (!response) {
|
|
62395
62408
|
response = new Response2(body, responseOptions);
|
|
62396
|
-
|
|
62409
|
+
resolve2(response);
|
|
62397
62410
|
}
|
|
62398
62411
|
});
|
|
62399
62412
|
return;
|
|
@@ -62405,11 +62418,11 @@ async function fetch2(url, options_) {
|
|
|
62405
62418
|
}
|
|
62406
62419
|
});
|
|
62407
62420
|
response = new Response2(body, responseOptions);
|
|
62408
|
-
|
|
62421
|
+
resolve2(response);
|
|
62409
62422
|
return;
|
|
62410
62423
|
}
|
|
62411
62424
|
response = new Response2(body, responseOptions);
|
|
62412
|
-
|
|
62425
|
+
resolve2(response);
|
|
62413
62426
|
});
|
|
62414
62427
|
writeToStream(request_, request).catch(reject);
|
|
62415
62428
|
});
|
|
@@ -68532,7 +68545,7 @@ var require_jwtaccess = __commonJS({
|
|
|
68532
68545
|
}
|
|
68533
68546
|
}
|
|
68534
68547
|
fromStreamAsync(inputStream) {
|
|
68535
|
-
return new Promise((
|
|
68548
|
+
return new Promise((resolve2, reject) => {
|
|
68536
68549
|
if (!inputStream) {
|
|
68537
68550
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
68538
68551
|
}
|
|
@@ -68541,7 +68554,7 @@ var require_jwtaccess = __commonJS({
|
|
|
68541
68554
|
try {
|
|
68542
68555
|
const data = JSON.parse(s2);
|
|
68543
68556
|
this.fromJSON(data);
|
|
68544
|
-
|
|
68557
|
+
resolve2();
|
|
68545
68558
|
} catch (err) {
|
|
68546
68559
|
reject(err);
|
|
68547
68560
|
}
|
|
@@ -68781,7 +68794,7 @@ var require_jwtclient = __commonJS({
|
|
|
68781
68794
|
}
|
|
68782
68795
|
}
|
|
68783
68796
|
fromStreamAsync(inputStream) {
|
|
68784
|
-
return new Promise((
|
|
68797
|
+
return new Promise((resolve2, reject) => {
|
|
68785
68798
|
if (!inputStream) {
|
|
68786
68799
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
68787
68800
|
}
|
|
@@ -68790,7 +68803,7 @@ var require_jwtclient = __commonJS({
|
|
|
68790
68803
|
try {
|
|
68791
68804
|
const data = JSON.parse(s2);
|
|
68792
68805
|
this.fromJSON(data);
|
|
68793
|
-
|
|
68806
|
+
resolve2();
|
|
68794
68807
|
} catch (e2) {
|
|
68795
68808
|
reject(e2);
|
|
68796
68809
|
}
|
|
@@ -68924,7 +68937,7 @@ var require_refreshclient = __commonJS({
|
|
|
68924
68937
|
}
|
|
68925
68938
|
}
|
|
68926
68939
|
async fromStreamAsync(inputStream) {
|
|
68927
|
-
return new Promise((
|
|
68940
|
+
return new Promise((resolve2, reject) => {
|
|
68928
68941
|
if (!inputStream) {
|
|
68929
68942
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
68930
68943
|
}
|
|
@@ -68933,7 +68946,7 @@ var require_refreshclient = __commonJS({
|
|
|
68933
68946
|
try {
|
|
68934
68947
|
const data = JSON.parse(s2);
|
|
68935
68948
|
this.fromJSON(data);
|
|
68936
|
-
return
|
|
68949
|
+
return resolve2();
|
|
68937
68950
|
} catch (err) {
|
|
68938
68951
|
return reject(err);
|
|
68939
68952
|
}
|
|
@@ -70779,7 +70792,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
70779
70792
|
* @return A promise that resolves with the executable response.
|
|
70780
70793
|
*/
|
|
70781
70794
|
retrieveResponseFromExecutable(envMap) {
|
|
70782
|
-
return new Promise((
|
|
70795
|
+
return new Promise((resolve2, reject) => {
|
|
70783
70796
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
70784
70797
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
70785
70798
|
});
|
|
@@ -70801,7 +70814,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
70801
70814
|
try {
|
|
70802
70815
|
const responseJson = JSON.parse(output);
|
|
70803
70816
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
70804
|
-
return
|
|
70817
|
+
return resolve2(response);
|
|
70805
70818
|
} catch (error) {
|
|
70806
70819
|
if (error instanceof executable_response_1.ExecutableResponseError) {
|
|
70807
70820
|
return reject(error);
|
|
@@ -71996,7 +72009,7 @@ var require_googleauth = __commonJS({
|
|
|
71996
72009
|
}
|
|
71997
72010
|
}
|
|
71998
72011
|
fromStreamAsync(inputStream, options) {
|
|
71999
|
-
return new Promise((
|
|
72012
|
+
return new Promise((resolve2, reject) => {
|
|
72000
72013
|
if (!inputStream) {
|
|
72001
72014
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
72002
72015
|
}
|
|
@@ -72006,7 +72019,7 @@ var require_googleauth = __commonJS({
|
|
|
72006
72019
|
try {
|
|
72007
72020
|
const data = JSON.parse(chunks.join(""));
|
|
72008
72021
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
72009
|
-
return
|
|
72022
|
+
return resolve2(r2);
|
|
72010
72023
|
} catch (err) {
|
|
72011
72024
|
if (!this.keyFilename)
|
|
72012
72025
|
throw err;
|
|
@@ -72016,7 +72029,7 @@ var require_googleauth = __commonJS({
|
|
|
72016
72029
|
});
|
|
72017
72030
|
this.cachedCredential = client;
|
|
72018
72031
|
this.setGapicJWTValues(client);
|
|
72019
|
-
return
|
|
72032
|
+
return resolve2(client);
|
|
72020
72033
|
}
|
|
72021
72034
|
} catch (err) {
|
|
72022
72035
|
return reject(err);
|
|
@@ -72052,17 +72065,17 @@ var require_googleauth = __commonJS({
|
|
|
72052
72065
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
72053
72066
|
*/
|
|
72054
72067
|
async getDefaultServiceProjectId() {
|
|
72055
|
-
return new Promise((
|
|
72068
|
+
return new Promise((resolve2) => {
|
|
72056
72069
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
|
|
72057
72070
|
if (!err && stdout) {
|
|
72058
72071
|
try {
|
|
72059
72072
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
72060
|
-
|
|
72073
|
+
resolve2(projectId);
|
|
72061
72074
|
return;
|
|
72062
72075
|
} catch (e2) {
|
|
72063
72076
|
}
|
|
72064
72077
|
}
|
|
72065
|
-
|
|
72078
|
+
resolve2(null);
|
|
72066
72079
|
});
|
|
72067
72080
|
});
|
|
72068
72081
|
}
|
|
@@ -74984,7 +74997,7 @@ var require_websocket = __commonJS({
|
|
|
74984
74997
|
var http3 = __require("http");
|
|
74985
74998
|
var net = __require("net");
|
|
74986
74999
|
var tls = __require("tls");
|
|
74987
|
-
var { randomBytes, createHash:
|
|
75000
|
+
var { randomBytes, createHash: createHash15 } = __require("crypto");
|
|
74988
75001
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
74989
75002
|
var { URL: URL2 } = __require("url");
|
|
74990
75003
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -75652,7 +75665,7 @@ var require_websocket = __commonJS({
|
|
|
75652
75665
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
75653
75666
|
return;
|
|
75654
75667
|
}
|
|
75655
|
-
const digest2 =
|
|
75668
|
+
const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
|
|
75656
75669
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
75657
75670
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
75658
75671
|
return;
|
|
@@ -76024,7 +76037,7 @@ var require_websocket_server = __commonJS({
|
|
|
76024
76037
|
var EventEmitter = __require("events");
|
|
76025
76038
|
var http3 = __require("http");
|
|
76026
76039
|
var { Duplex } = __require("stream");
|
|
76027
|
-
var { createHash:
|
|
76040
|
+
var { createHash: createHash15 } = __require("crypto");
|
|
76028
76041
|
var extension3 = require_extension();
|
|
76029
76042
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
76030
76043
|
var subprotocol2 = require_subprotocol();
|
|
@@ -76331,7 +76344,7 @@ var require_websocket_server = __commonJS({
|
|
|
76331
76344
|
);
|
|
76332
76345
|
}
|
|
76333
76346
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
76334
|
-
const digest2 =
|
|
76347
|
+
const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
|
|
76335
76348
|
const headers = [
|
|
76336
76349
|
"HTTP/1.1 101 Switching Protocols",
|
|
76337
76350
|
"Upgrade: websocket",
|
|
@@ -79740,14 +79753,14 @@ function __asyncValues(o) {
|
|
|
79740
79753
|
}, i2);
|
|
79741
79754
|
function verb(n) {
|
|
79742
79755
|
i2[n] = o[n] && function(v) {
|
|
79743
|
-
return new Promise(function(
|
|
79744
|
-
v = o[n](v), settle(
|
|
79756
|
+
return new Promise(function(resolve2, reject) {
|
|
79757
|
+
v = o[n](v), settle(resolve2, reject, v.done, v.value);
|
|
79745
79758
|
});
|
|
79746
79759
|
};
|
|
79747
79760
|
}
|
|
79748
|
-
function settle(
|
|
79761
|
+
function settle(resolve2, reject, d, v) {
|
|
79749
79762
|
Promise.resolve(v).then(function(v2) {
|
|
79750
|
-
|
|
79763
|
+
resolve2({ value: v2, done: d });
|
|
79751
79764
|
}, reject);
|
|
79752
79765
|
}
|
|
79753
79766
|
}
|
|
@@ -90117,8 +90130,8 @@ var init_node = __esm({
|
|
|
90117
90130
|
const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
|
|
90118
90131
|
let onopenResolve = () => {
|
|
90119
90132
|
};
|
|
90120
|
-
const onopenPromise = new Promise((
|
|
90121
|
-
onopenResolve =
|
|
90133
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
90134
|
+
onopenResolve = resolve2;
|
|
90122
90135
|
});
|
|
90123
90136
|
const callbacks = params.callbacks;
|
|
90124
90137
|
const onopenAwaitedCallback = function() {
|
|
@@ -90324,8 +90337,8 @@ var init_node = __esm({
|
|
|
90324
90337
|
}
|
|
90325
90338
|
let onopenResolve = () => {
|
|
90326
90339
|
};
|
|
90327
|
-
const onopenPromise = new Promise((
|
|
90328
|
-
onopenResolve =
|
|
90340
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
90341
|
+
onopenResolve = resolve2;
|
|
90329
90342
|
});
|
|
90330
90343
|
const callbacks = params.callbacks;
|
|
90331
90344
|
const onopenAwaitedCallback = function() {
|
|
@@ -92673,7 +92686,7 @@ var init_node = __esm({
|
|
|
92673
92686
|
return void 0;
|
|
92674
92687
|
}
|
|
92675
92688
|
};
|
|
92676
|
-
sleep$1 = (ms) => new Promise((
|
|
92689
|
+
sleep$1 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
92677
92690
|
FallbackEncoder3 = ({ headers, body }) => {
|
|
92678
92691
|
return {
|
|
92679
92692
|
bodyHeaders: {
|
|
@@ -93182,8 +93195,8 @@ ${underline}`);
|
|
|
93182
93195
|
};
|
|
93183
93196
|
APIPromise3 = class _APIPromise extends Promise {
|
|
93184
93197
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse3) {
|
|
93185
|
-
super((
|
|
93186
|
-
|
|
93198
|
+
super((resolve2) => {
|
|
93199
|
+
resolve2(null);
|
|
93187
93200
|
});
|
|
93188
93201
|
this.responsePromise = responsePromise;
|
|
93189
93202
|
this.parseResponse = parseResponse2;
|
|
@@ -96414,7 +96427,7 @@ function retryIntervalFromResponse(res) {
|
|
|
96414
96427
|
return 0;
|
|
96415
96428
|
}
|
|
96416
96429
|
async function delay(delay2) {
|
|
96417
|
-
return new Promise((
|
|
96430
|
+
return new Promise((resolve2) => setTimeout(resolve2, delay2));
|
|
96418
96431
|
}
|
|
96419
96432
|
var defaultBackoff, PermanentError, TemporaryError, codeRangeRE2;
|
|
96420
96433
|
var init_retries = __esm({
|
|
@@ -133993,12 +134006,12 @@ function capRetryDelayMs(delayMs, options) {
|
|
|
133993
134006
|
return maxRetryDelayMs > 0 ? Math.min(delayMs, maxRetryDelayMs) : delayMs;
|
|
133994
134007
|
}
|
|
133995
134008
|
function sleep4(ms, signal) {
|
|
133996
|
-
return new Promise((
|
|
134009
|
+
return new Promise((resolve2, reject) => {
|
|
133997
134010
|
if (signal?.aborted) {
|
|
133998
134011
|
reject(new Error("Request was aborted"));
|
|
133999
134012
|
return;
|
|
134000
134013
|
}
|
|
134001
|
-
const timeout = setTimeout(
|
|
134014
|
+
const timeout = setTimeout(resolve2, ms);
|
|
134002
134015
|
signal?.addEventListener("abort", () => {
|
|
134003
134016
|
clearTimeout(timeout);
|
|
134004
134017
|
reject(new Error("Request was aborted"));
|
|
@@ -134330,7 +134343,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
134330
134343
|
}
|
|
134331
134344
|
const wsHeaders = headersToRecord(headers);
|
|
134332
134345
|
delete wsHeaders["OpenAI-Beta"];
|
|
134333
|
-
return new Promise((
|
|
134346
|
+
return new Promise((resolve2, reject) => {
|
|
134334
134347
|
let settled = false;
|
|
134335
134348
|
let timeout;
|
|
134336
134349
|
let socket;
|
|
@@ -134365,7 +134378,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
134365
134378
|
return;
|
|
134366
134379
|
settled = true;
|
|
134367
134380
|
cleanup();
|
|
134368
|
-
|
|
134381
|
+
resolve2(socket);
|
|
134369
134382
|
};
|
|
134370
134383
|
const onError = (event) => {
|
|
134371
134384
|
fail2(extractWebSocketError(event));
|
|
@@ -134522,9 +134535,9 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
134522
134535
|
const wake = () => {
|
|
134523
134536
|
if (!pending)
|
|
134524
134537
|
return;
|
|
134525
|
-
const
|
|
134538
|
+
const resolve2 = pending;
|
|
134526
134539
|
pending = null;
|
|
134527
|
-
|
|
134540
|
+
resolve2();
|
|
134528
134541
|
};
|
|
134529
134542
|
const onMessage = (event) => {
|
|
134530
134543
|
void (async () => {
|
|
@@ -134591,8 +134604,8 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
134591
134604
|
if (done)
|
|
134592
134605
|
break;
|
|
134593
134606
|
let timeout;
|
|
134594
|
-
await new Promise((
|
|
134595
|
-
pending =
|
|
134607
|
+
await new Promise((resolve2, reject) => {
|
|
134608
|
+
pending = resolve2;
|
|
134596
134609
|
if (idleTimeoutMs !== void 0 && idleTimeoutMs > 0) {
|
|
134597
134610
|
timeout = setTimeout(() => {
|
|
134598
134611
|
const error = new Error(`WebSocket idle timeout after ${idleTimeoutMs}ms`);
|
|
@@ -144635,6 +144648,8 @@ function rowToFile(row) {
|
|
|
144635
144648
|
...row.sizeBytes != null ? { sizeBytes: row.sizeBytes } : {},
|
|
144636
144649
|
indexedAt: row.indexedAt,
|
|
144637
144650
|
...row.gitCommit ? { gitCommit: row.gitCommit } : {},
|
|
144651
|
+
...row.source ? { source: row.source } : {},
|
|
144652
|
+
...row.parserError ? { parserError: row.parserError } : {},
|
|
144638
144653
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
144639
144654
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
144640
144655
|
};
|
|
@@ -144654,6 +144669,7 @@ function rowToSymbol(row) {
|
|
|
144654
144669
|
...row.contentHash ? { contentHash: row.contentHash } : {},
|
|
144655
144670
|
indexedAt: row.indexedAt,
|
|
144656
144671
|
stale: !!row.stale,
|
|
144672
|
+
...row.source ? { source: row.source } : {},
|
|
144657
144673
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
144658
144674
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
144659
144675
|
};
|
|
@@ -144669,6 +144685,7 @@ function rowToEdge(row) {
|
|
|
144669
144685
|
type: row.type,
|
|
144670
144686
|
confidence: row.confidence,
|
|
144671
144687
|
...row.evidence ? { evidence: row.evidence } : {},
|
|
144688
|
+
...row.source ? { source: row.source } : {},
|
|
144672
144689
|
indexedAt: row.indexedAt,
|
|
144673
144690
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
144674
144691
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
@@ -144789,9 +144806,9 @@ var init_store = __esm({
|
|
|
144789
144806
|
if (files.length === 0) return;
|
|
144790
144807
|
const stmt = this.db.prepare(`
|
|
144791
144808
|
INSERT OR REPLACE INTO code_files
|
|
144792
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
144809
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
144793
144810
|
VALUES
|
|
144794
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
144811
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
144795
144812
|
`);
|
|
144796
144813
|
const tx = this.db.transaction((items) => {
|
|
144797
144814
|
for (const file of items) {
|
|
@@ -144804,7 +144821,9 @@ var init_store = __esm({
|
|
|
144804
144821
|
mtimeMs: file.mtimeMs ?? null,
|
|
144805
144822
|
sizeBytes: file.sizeBytes ?? null,
|
|
144806
144823
|
indexedAt: file.indexedAt,
|
|
144807
|
-
gitCommit: file.gitCommit ?? null
|
|
144824
|
+
gitCommit: file.gitCommit ?? null,
|
|
144825
|
+
source: file.source ?? null,
|
|
144826
|
+
parserError: file.parserError ?? null
|
|
144808
144827
|
});
|
|
144809
144828
|
}
|
|
144810
144829
|
});
|
|
@@ -144814,9 +144833,9 @@ var init_store = __esm({
|
|
|
144814
144833
|
if (symbols.length === 0) return;
|
|
144815
144834
|
const stmt = this.db.prepare(`
|
|
144816
144835
|
INSERT OR REPLACE INTO code_symbols
|
|
144817
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
144836
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
144818
144837
|
VALUES
|
|
144819
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
144838
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
144820
144839
|
`);
|
|
144821
144840
|
const tx = this.db.transaction((items) => {
|
|
144822
144841
|
for (const symbol of items) {
|
|
@@ -144833,7 +144852,8 @@ var init_store = __esm({
|
|
|
144833
144852
|
signature: symbol.signature ?? null,
|
|
144834
144853
|
contentHash: symbol.contentHash ?? null,
|
|
144835
144854
|
indexedAt: symbol.indexedAt,
|
|
144836
|
-
stale: symbol.stale ? 1 : 0
|
|
144855
|
+
stale: symbol.stale ? 1 : 0,
|
|
144856
|
+
source: symbol.source ?? null
|
|
144837
144857
|
});
|
|
144838
144858
|
}
|
|
144839
144859
|
});
|
|
@@ -144843,9 +144863,9 @@ var init_store = __esm({
|
|
|
144843
144863
|
if (edges.length === 0) return;
|
|
144844
144864
|
const stmt = this.db.prepare(`
|
|
144845
144865
|
INSERT OR REPLACE INTO code_edges
|
|
144846
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
144866
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
144847
144867
|
VALUES
|
|
144848
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
144868
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
144849
144869
|
`);
|
|
144850
144870
|
const tx = this.db.transaction((items) => {
|
|
144851
144871
|
for (const edge of items) {
|
|
@@ -144859,7 +144879,8 @@ var init_store = __esm({
|
|
|
144859
144879
|
type: edge.type,
|
|
144860
144880
|
confidence: edge.confidence,
|
|
144861
144881
|
evidence: edge.evidence ?? null,
|
|
144862
|
-
indexedAt: edge.indexedAt
|
|
144882
|
+
indexedAt: edge.indexedAt,
|
|
144883
|
+
source: edge.source ?? null
|
|
144863
144884
|
});
|
|
144864
144885
|
}
|
|
144865
144886
|
});
|
|
@@ -144871,21 +144892,21 @@ var init_store = __esm({
|
|
|
144871
144892
|
const deleteFiles = this.db.prepare(`DELETE FROM code_files WHERE projectId = ?`);
|
|
144872
144893
|
const insertFile = this.db.prepare(`
|
|
144873
144894
|
INSERT OR REPLACE INTO code_files
|
|
144874
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
144895
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
144875
144896
|
VALUES
|
|
144876
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
144897
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
144877
144898
|
`);
|
|
144878
144899
|
const insertSymbol = this.db.prepare(`
|
|
144879
144900
|
INSERT OR REPLACE INTO code_symbols
|
|
144880
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
144901
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
144881
144902
|
VALUES
|
|
144882
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
144903
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
144883
144904
|
`);
|
|
144884
144905
|
const insertEdge = this.db.prepare(`
|
|
144885
144906
|
INSERT OR REPLACE INTO code_edges
|
|
144886
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
144907
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
144887
144908
|
VALUES
|
|
144888
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
144909
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
144889
144910
|
`);
|
|
144890
144911
|
const tx = this.db.transaction(() => {
|
|
144891
144912
|
deleteEdges.run(projectId);
|
|
@@ -144901,7 +144922,9 @@ var init_store = __esm({
|
|
|
144901
144922
|
mtimeMs: file.mtimeMs ?? null,
|
|
144902
144923
|
sizeBytes: file.sizeBytes ?? null,
|
|
144903
144924
|
indexedAt: file.indexedAt,
|
|
144904
|
-
gitCommit: file.gitCommit ?? null
|
|
144925
|
+
gitCommit: file.gitCommit ?? null,
|
|
144926
|
+
source: file.source ?? null,
|
|
144927
|
+
parserError: file.parserError ?? null
|
|
144905
144928
|
});
|
|
144906
144929
|
}
|
|
144907
144930
|
for (const symbol of index.symbols) {
|
|
@@ -144918,7 +144941,8 @@ var init_store = __esm({
|
|
|
144918
144941
|
signature: symbol.signature ?? null,
|
|
144919
144942
|
contentHash: symbol.contentHash ?? null,
|
|
144920
144943
|
indexedAt: symbol.indexedAt,
|
|
144921
|
-
stale: 0
|
|
144944
|
+
stale: 0,
|
|
144945
|
+
source: symbol.source ?? null
|
|
144922
144946
|
});
|
|
144923
144947
|
}
|
|
144924
144948
|
for (const edge of index.edges) {
|
|
@@ -144932,7 +144956,8 @@ var init_store = __esm({
|
|
|
144932
144956
|
type: edge.type,
|
|
144933
144957
|
confidence: edge.confidence,
|
|
144934
144958
|
evidence: edge.evidence ?? null,
|
|
144935
|
-
indexedAt: edge.indexedAt
|
|
144959
|
+
indexedAt: edge.indexedAt,
|
|
144960
|
+
source: edge.source ?? null
|
|
144936
144961
|
});
|
|
144937
144962
|
}
|
|
144938
144963
|
});
|
|
@@ -144977,21 +145002,21 @@ var init_store = __esm({
|
|
|
144977
145002
|
const deleteFile = this.db.prepare(`DELETE FROM code_files WHERE projectId = ? AND id = ?`);
|
|
144978
145003
|
const upsertFile = this.db.prepare(`
|
|
144979
145004
|
INSERT OR REPLACE INTO code_files
|
|
144980
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145005
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
144981
145006
|
VALUES
|
|
144982
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145007
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
144983
145008
|
`);
|
|
144984
145009
|
const upsertSymbol = this.db.prepare(`
|
|
144985
145010
|
INSERT OR REPLACE INTO code_symbols
|
|
144986
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145011
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
144987
145012
|
VALUES
|
|
144988
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145013
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
144989
145014
|
`);
|
|
144990
145015
|
const upsertEdge = this.db.prepare(`
|
|
144991
145016
|
INSERT OR REPLACE INTO code_edges
|
|
144992
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145017
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
144993
145018
|
VALUES
|
|
144994
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145019
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
144995
145020
|
`);
|
|
144996
145021
|
const writeFile5 = (file) => upsertFile.run({
|
|
144997
145022
|
id: file.id,
|
|
@@ -145002,7 +145027,9 @@ var init_store = __esm({
|
|
|
145002
145027
|
mtimeMs: file.mtimeMs ?? null,
|
|
145003
145028
|
sizeBytes: file.sizeBytes ?? null,
|
|
145004
145029
|
indexedAt: file.indexedAt,
|
|
145005
|
-
gitCommit: file.gitCommit ?? null
|
|
145030
|
+
gitCommit: file.gitCommit ?? null,
|
|
145031
|
+
source: file.source ?? null,
|
|
145032
|
+
parserError: file.parserError ?? null
|
|
145006
145033
|
});
|
|
145007
145034
|
const tx = this.db.transaction(() => {
|
|
145008
145035
|
const staleAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -145036,7 +145063,8 @@ var init_store = __esm({
|
|
|
145036
145063
|
signature: symbol.signature ?? null,
|
|
145037
145064
|
contentHash: symbol.contentHash ?? null,
|
|
145038
145065
|
indexedAt: symbol.indexedAt,
|
|
145039
|
-
stale: symbol.stale ? 1 : 0
|
|
145066
|
+
stale: symbol.stale ? 1 : 0,
|
|
145067
|
+
source: symbol.source ?? null
|
|
145040
145068
|
});
|
|
145041
145069
|
}
|
|
145042
145070
|
for (const edge of delta.edges) {
|
|
@@ -145050,7 +145078,8 @@ var init_store = __esm({
|
|
|
145050
145078
|
type: edge.type,
|
|
145051
145079
|
confidence: edge.confidence,
|
|
145052
145080
|
evidence: edge.evidence ?? null,
|
|
145053
|
-
indexedAt: edge.indexedAt
|
|
145081
|
+
indexedAt: edge.indexedAt,
|
|
145082
|
+
source: edge.source ?? null
|
|
145054
145083
|
});
|
|
145055
145084
|
}
|
|
145056
145085
|
}
|
|
@@ -145198,6 +145227,202 @@ var init_store = __esm({
|
|
|
145198
145227
|
listEdges(projectId) {
|
|
145199
145228
|
return this.db.prepare(`SELECT * FROM code_edges WHERE projectId = ? ORDER BY type, id`).all(projectId).map(rowToEdge);
|
|
145200
145229
|
}
|
|
145230
|
+
/** Return direct importers before a refresh clears their old target IDs. */
|
|
145231
|
+
listImportDependentPaths(projectId, paths, candidatePaths = []) {
|
|
145232
|
+
const normalized = [...new Set(paths.map(normalizeCodePath).filter(Boolean))];
|
|
145233
|
+
if (normalized.length === 0) return [];
|
|
145234
|
+
const files = this.listFiles(projectId);
|
|
145235
|
+
const fileIds = files.filter((file) => normalized.includes(file.path)).map((file) => file.id);
|
|
145236
|
+
const fileById = new Map(files.map((file) => [file.id, file]));
|
|
145237
|
+
const fileByPath = new Map(files.map((file) => [file.path, file]));
|
|
145238
|
+
for (const path22 of candidatePaths.map(normalizeCodePath).filter(Boolean)) {
|
|
145239
|
+
if (!fileByPath.has(path22)) {
|
|
145240
|
+
fileByPath.set(path22, {
|
|
145241
|
+
id: `candidate:${path22}`,
|
|
145242
|
+
projectId,
|
|
145243
|
+
path: path22,
|
|
145244
|
+
contentHash: "",
|
|
145245
|
+
indexedAt: ""
|
|
145246
|
+
});
|
|
145247
|
+
}
|
|
145248
|
+
}
|
|
145249
|
+
const rows = this.db.prepare(`
|
|
145250
|
+
SELECT DISTINCT fromFileId, evidence
|
|
145251
|
+
FROM code_edges
|
|
145252
|
+
WHERE projectId = ? AND type = 'imports'
|
|
145253
|
+
`).all(projectId);
|
|
145254
|
+
const wanted = new Set(normalized);
|
|
145255
|
+
const dependents = /* @__PURE__ */ new Set();
|
|
145256
|
+
const queue = [...normalized];
|
|
145257
|
+
while (queue.length > 0) {
|
|
145258
|
+
const targetPath = queue.shift();
|
|
145259
|
+
for (const row of rows) {
|
|
145260
|
+
const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
|
|
145261
|
+
if (!source || source.path === targetPath || dependents.has(source.path)) continue;
|
|
145262
|
+
const target = resolveRelativeImportTarget(source.path, row.evidence, fileByPath);
|
|
145263
|
+
if (!target || !wanted.has(target.path)) continue;
|
|
145264
|
+
dependents.add(source.path);
|
|
145265
|
+
if (!wanted.has(source.path)) {
|
|
145266
|
+
wanted.add(source.path);
|
|
145267
|
+
queue.push(source.path);
|
|
145268
|
+
}
|
|
145269
|
+
}
|
|
145270
|
+
}
|
|
145271
|
+
if (fileIds.length > 0) {
|
|
145272
|
+
const placeholders = fileIds.map(() => "?").join(", ");
|
|
145273
|
+
const exactRows = this.db.prepare(`
|
|
145274
|
+
SELECT DISTINCT fromFileId
|
|
145275
|
+
FROM code_edges
|
|
145276
|
+
WHERE projectId = ? AND type = 'imports' AND toFileId IN (${placeholders})
|
|
145277
|
+
`).all(projectId, ...fileIds);
|
|
145278
|
+
for (const row of exactRows) {
|
|
145279
|
+
const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
|
|
145280
|
+
if (source) dependents.add(source.path);
|
|
145281
|
+
}
|
|
145282
|
+
}
|
|
145283
|
+
return [...dependents].sort();
|
|
145284
|
+
}
|
|
145285
|
+
/** Replace only the semantic slice touched by a change, in one transaction. */
|
|
145286
|
+
replaceSemanticSlice(projectId, affectedPaths, input) {
|
|
145287
|
+
const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
|
|
145288
|
+
if (normalizedPaths.length === 0) return;
|
|
145289
|
+
const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
|
|
145290
|
+
const fileIds = fileRows.map((file) => file.id);
|
|
145291
|
+
const placeholders = fileIds.map(() => "?").join(", ");
|
|
145292
|
+
if (fileIds.length === 0) return;
|
|
145293
|
+
const staleRefs = this.db.prepare(`
|
|
145294
|
+
UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
|
|
145295
|
+
WHERE projectId = ? AND (fileId IN (${placeholders}) OR symbolId IN (
|
|
145296
|
+
SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})
|
|
145297
|
+
))
|
|
145298
|
+
`);
|
|
145299
|
+
const deleteEdges = this.db.prepare(`
|
|
145300
|
+
DELETE FROM code_edges
|
|
145301
|
+
WHERE projectId = ? AND (source IS NULL OR source IN ('lite-regex', 'typescript-compiler'))
|
|
145302
|
+
AND (fromFileId IN (${placeholders}) OR toFileId IN (${placeholders})
|
|
145303
|
+
OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders}))
|
|
145304
|
+
OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})))
|
|
145305
|
+
`);
|
|
145306
|
+
const deleteSymbols = this.db.prepare(`DELETE FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})`);
|
|
145307
|
+
const updateFile = this.db.prepare("UPDATE code_files SET source = ?, parserError = ? WHERE projectId = ? AND id = ?");
|
|
145308
|
+
const insertSymbol = this.db.prepare(`
|
|
145309
|
+
INSERT OR REPLACE INTO code_symbols
|
|
145310
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145311
|
+
VALUES
|
|
145312
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145313
|
+
`);
|
|
145314
|
+
const insertEdge = this.db.prepare(`
|
|
145315
|
+
INSERT OR REPLACE INTO code_edges
|
|
145316
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145317
|
+
VALUES
|
|
145318
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145319
|
+
`);
|
|
145320
|
+
const diagnosticsByPath = new Map((input.diagnostics ?? []).map((item) => [normalizeCodePath(item.path), item.message]));
|
|
145321
|
+
const symbolFileIds = new Set(fileIds);
|
|
145322
|
+
const tx = this.db.transaction(() => {
|
|
145323
|
+
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
145324
|
+
staleRefs.run(now3, projectId, ...fileIds, projectId, ...fileIds);
|
|
145325
|
+
deleteEdges.run(projectId, ...fileIds, ...fileIds, projectId, ...fileIds, projectId, ...fileIds);
|
|
145326
|
+
deleteSymbols.run(projectId, ...fileIds);
|
|
145327
|
+
for (const file of fileRows) {
|
|
145328
|
+
const diagnostic = diagnosticsByPath.get(file.path);
|
|
145329
|
+
updateFile.run(diagnostic ? "typescript-compiler" : "typescript-compiler", diagnostic ?? null, projectId, file.id);
|
|
145330
|
+
}
|
|
145331
|
+
for (const symbol of input.symbols.filter((symbol2) => symbolFileIds.has(symbol2.fileId))) {
|
|
145332
|
+
insertSymbol.run({
|
|
145333
|
+
id: symbol.id,
|
|
145334
|
+
projectId: symbol.projectId,
|
|
145335
|
+
fileId: symbol.fileId,
|
|
145336
|
+
path: normalizeCodePath(symbol.path),
|
|
145337
|
+
name: symbol.name,
|
|
145338
|
+
qualifiedName: symbol.qualifiedName,
|
|
145339
|
+
kind: symbol.kind,
|
|
145340
|
+
startLine: symbol.startLine ?? null,
|
|
145341
|
+
endLine: symbol.endLine ?? null,
|
|
145342
|
+
signature: symbol.signature ?? null,
|
|
145343
|
+
contentHash: symbol.contentHash ?? null,
|
|
145344
|
+
indexedAt: symbol.indexedAt,
|
|
145345
|
+
stale: symbol.stale ? 1 : 0,
|
|
145346
|
+
source: symbol.source ?? "typescript-compiler"
|
|
145347
|
+
});
|
|
145348
|
+
}
|
|
145349
|
+
for (const edge of input.edges) {
|
|
145350
|
+
insertEdge.run({
|
|
145351
|
+
id: edge.id,
|
|
145352
|
+
projectId: edge.projectId,
|
|
145353
|
+
fromSymbolId: edge.fromSymbolId ?? null,
|
|
145354
|
+
toSymbolId: edge.toSymbolId ?? null,
|
|
145355
|
+
fromFileId: edge.fromFileId ?? null,
|
|
145356
|
+
toFileId: edge.toFileId ?? null,
|
|
145357
|
+
type: edge.type,
|
|
145358
|
+
confidence: edge.confidence,
|
|
145359
|
+
evidence: edge.evidence ?? null,
|
|
145360
|
+
indexedAt: edge.indexedAt,
|
|
145361
|
+
source: edge.source ?? "typescript-compiler"
|
|
145362
|
+
});
|
|
145363
|
+
}
|
|
145364
|
+
});
|
|
145365
|
+
tx();
|
|
145366
|
+
}
|
|
145367
|
+
/** Record a semantic refresh failure without presenting the old facts as current. */
|
|
145368
|
+
markSemanticSliceFailed(projectId, affectedPaths, message) {
|
|
145369
|
+
const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
|
|
145370
|
+
const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
|
|
145371
|
+
const fileIds = fileRows.map((file) => file.id);
|
|
145372
|
+
const filePlaceholders = fileIds.map(() => "?").join(", ");
|
|
145373
|
+
const staleRefs = fileIds.length > 0 ? this.db.prepare(`
|
|
145374
|
+
UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
|
|
145375
|
+
WHERE projectId = ? AND (fileId IN (${filePlaceholders}) OR symbolId IN (
|
|
145376
|
+
SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders})
|
|
145377
|
+
))
|
|
145378
|
+
`) : void 0;
|
|
145379
|
+
const staleSymbols = fileIds.length > 0 ? this.db.prepare(`
|
|
145380
|
+
UPDATE code_symbols SET stale = 1
|
|
145381
|
+
WHERE projectId = ? AND source = 'typescript-compiler' AND fileId IN (${filePlaceholders})
|
|
145382
|
+
`) : void 0;
|
|
145383
|
+
const updateFiles = fileIds.length > 0 ? this.db.prepare(`
|
|
145384
|
+
UPDATE code_files SET parserError = ?
|
|
145385
|
+
WHERE projectId = ? AND id IN (${filePlaceholders})
|
|
145386
|
+
`) : void 0;
|
|
145387
|
+
const affectedEdgeClause = fileIds.length > 0 ? `
|
|
145388
|
+
OR fromFileId IN (${filePlaceholders})
|
|
145389
|
+
OR toFileId IN (${filePlaceholders})
|
|
145390
|
+
OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
|
|
145391
|
+
OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
|
|
145392
|
+
` : "";
|
|
145393
|
+
const deleteEdges = this.db.prepare(`
|
|
145394
|
+
DELETE FROM code_edges
|
|
145395
|
+
WHERE projectId = ? AND source = 'typescript-compiler'
|
|
145396
|
+
AND (
|
|
145397
|
+
(fromSymbolId IS NOT NULL AND NOT EXISTS (
|
|
145398
|
+
SELECT 1 FROM code_symbols WHERE projectId = ? AND id = fromSymbolId
|
|
145399
|
+
))
|
|
145400
|
+
OR (toSymbolId IS NOT NULL AND NOT EXISTS (
|
|
145401
|
+
SELECT 1 FROM code_symbols WHERE projectId = ? AND id = toSymbolId
|
|
145402
|
+
))
|
|
145403
|
+
${affectedEdgeClause}
|
|
145404
|
+
)
|
|
145405
|
+
`);
|
|
145406
|
+
const tx = this.db.transaction(() => {
|
|
145407
|
+
const failure = `semantic indexing failed: ${message.slice(0, 500)}`;
|
|
145408
|
+
if (updateFiles) updateFiles.run(failure, projectId, ...fileIds);
|
|
145409
|
+
if (staleRefs) staleRefs.run((/* @__PURE__ */ new Date()).toISOString(), projectId, ...fileIds, projectId, ...fileIds);
|
|
145410
|
+
if (staleSymbols) staleSymbols.run(projectId, ...fileIds);
|
|
145411
|
+
const edgeParams = [projectId, projectId, projectId];
|
|
145412
|
+
if (fileIds.length > 0) {
|
|
145413
|
+
edgeParams.push(
|
|
145414
|
+
...fileIds,
|
|
145415
|
+
...fileIds,
|
|
145416
|
+
projectId,
|
|
145417
|
+
...fileIds,
|
|
145418
|
+
projectId,
|
|
145419
|
+
...fileIds
|
|
145420
|
+
);
|
|
145421
|
+
}
|
|
145422
|
+
deleteEdges.run(...edgeParams);
|
|
145423
|
+
});
|
|
145424
|
+
tx();
|
|
145425
|
+
}
|
|
145201
145426
|
listObservationRefs(projectId, observationId2) {
|
|
145202
145427
|
return this.db.prepare(`
|
|
145203
145428
|
SELECT * FROM observation_code_refs
|
|
@@ -145399,6 +145624,9 @@ var init_store = __esm({
|
|
|
145399
145624
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
145400
145625
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
145401
145626
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
145627
|
+
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
145628
|
+
const semanticEdges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ? AND source = 'typescript-compiler'`).get(projectId).count;
|
|
145629
|
+
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
145402
145630
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
145403
145631
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
145404
145632
|
return {
|
|
@@ -145407,6 +145635,9 @@ var init_store = __esm({
|
|
|
145407
145635
|
symbols,
|
|
145408
145636
|
edges,
|
|
145409
145637
|
refs,
|
|
145638
|
+
semanticSymbols,
|
|
145639
|
+
semanticEdges,
|
|
145640
|
+
parserErrors,
|
|
145410
145641
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
145411
145642
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
145412
145643
|
};
|
|
@@ -145539,6 +145770,350 @@ var init_exclude3 = __esm({
|
|
|
145539
145770
|
}
|
|
145540
145771
|
});
|
|
145541
145772
|
|
|
145773
|
+
// src/codegraph/semantic-provider.ts
|
|
145774
|
+
import { createHash as createHash8 } from "crypto";
|
|
145775
|
+
import "fs";
|
|
145776
|
+
import { resolve } from "path";
|
|
145777
|
+
import ts from "typescript";
|
|
145778
|
+
function hashText(value) {
|
|
145779
|
+
return createHash8("sha256").update(value).digest("hex");
|
|
145780
|
+
}
|
|
145781
|
+
function canonicalPath(value) {
|
|
145782
|
+
const normalized = resolve(value).replace(/\\/g, "/");
|
|
145783
|
+
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
145784
|
+
}
|
|
145785
|
+
function isInside(root, candidate) {
|
|
145786
|
+
const rootPath = canonicalPath(root).replace(/\/$/, "");
|
|
145787
|
+
const candidatePath = canonicalPath(candidate);
|
|
145788
|
+
return candidatePath === rootPath || candidatePath.startsWith(`${rootPath}/`);
|
|
145789
|
+
}
|
|
145790
|
+
function scriptKind(path22) {
|
|
145791
|
+
if (path22.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
145792
|
+
if (path22.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
145793
|
+
if (path22.endsWith(".json")) return ts.ScriptKind.JSON;
|
|
145794
|
+
if (path22.endsWith(".js") || path22.endsWith(".mjs") || path22.endsWith(".cjs")) return ts.ScriptKind.JS;
|
|
145795
|
+
return ts.ScriptKind.TS;
|
|
145796
|
+
}
|
|
145797
|
+
function isTestPath(path22) {
|
|
145798
|
+
return /(^|[/\\])__tests__([/\\])|(?:\.test|\.spec)\.[^.]+$/i.test(path22);
|
|
145799
|
+
}
|
|
145800
|
+
function declarationName(node) {
|
|
145801
|
+
const named = node;
|
|
145802
|
+
const name = named.name;
|
|
145803
|
+
return name && ts.isIdentifier(name) ? name.text : void 0;
|
|
145804
|
+
}
|
|
145805
|
+
function symbolKind(node) {
|
|
145806
|
+
if (ts.isFunctionDeclaration(node)) return "function";
|
|
145807
|
+
if (ts.isClassDeclaration(node)) return "class";
|
|
145808
|
+
if (ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isConstructorDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)) return "method";
|
|
145809
|
+
if (ts.isInterfaceDeclaration(node)) return "interface";
|
|
145810
|
+
if (ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) return "type";
|
|
145811
|
+
if (ts.isEnumMember(node)) return "constant";
|
|
145812
|
+
if (ts.isPropertyDeclaration(node) || ts.isPropertySignature(node)) return "property";
|
|
145813
|
+
if (ts.isVariableDeclaration(node)) return node.initializer && (ts.isFunctionExpression(node.initializer) || ts.isArrowFunction(node.initializer)) ? "function" : "constant";
|
|
145814
|
+
return void 0;
|
|
145815
|
+
}
|
|
145816
|
+
function isDeclarationNode(node) {
|
|
145817
|
+
return Boolean(symbolKind(node) && declarationName(node));
|
|
145818
|
+
}
|
|
145819
|
+
function qualifiedName(node, name, ordinalByKey) {
|
|
145820
|
+
const parts = [name];
|
|
145821
|
+
let parent = node.parent;
|
|
145822
|
+
while (parent && !ts.isSourceFile(parent)) {
|
|
145823
|
+
if (isDeclarationNode(parent)) {
|
|
145824
|
+
const parentName = declarationName(parent);
|
|
145825
|
+
if (parentName) parts.unshift(parentName);
|
|
145826
|
+
}
|
|
145827
|
+
parent = parent.parent;
|
|
145828
|
+
}
|
|
145829
|
+
const base = parts.join("::");
|
|
145830
|
+
const key = `${base}
|
|
145831
|
+
${symbolKind(node)}`;
|
|
145832
|
+
const ordinal = ordinalByKey.get(key) ?? 0;
|
|
145833
|
+
ordinalByKey.set(key, ordinal + 1);
|
|
145834
|
+
return ordinal === 0 ? base : `${base}#${ordinal + 1}`;
|
|
145835
|
+
}
|
|
145836
|
+
function lineAt(sourceFile, position) {
|
|
145837
|
+
return sourceFile.getLineAndCharacterOfPosition(position).line + 1;
|
|
145838
|
+
}
|
|
145839
|
+
function signatureFor(checker, node, sourceFile) {
|
|
145840
|
+
const signature = ts.isFunctionLike(node) ? checker.getSignatureFromDeclaration(node) : void 0;
|
|
145841
|
+
if (signature) {
|
|
145842
|
+
try {
|
|
145843
|
+
return checker.signatureToString(signature, node, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope).slice(0, 240);
|
|
145844
|
+
} catch {
|
|
145845
|
+
}
|
|
145846
|
+
}
|
|
145847
|
+
const text2 = sourceFile.text.slice(node.getStart(sourceFile), Math.min(node.end, node.getStart(sourceFile) + 240));
|
|
145848
|
+
return text2.replace(/\s+/g, " ").trim() || void 0;
|
|
145849
|
+
}
|
|
145850
|
+
function makeCompilerOptions(projectRoot) {
|
|
145851
|
+
const configPath = ts.findConfigFile(projectRoot, ts.sys.fileExists, "tsconfig.json");
|
|
145852
|
+
let options = {
|
|
145853
|
+
allowJs: true,
|
|
145854
|
+
checkJs: false,
|
|
145855
|
+
noEmit: true,
|
|
145856
|
+
noLib: true,
|
|
145857
|
+
skipLibCheck: true,
|
|
145858
|
+
module: ts.ModuleKind.ESNext,
|
|
145859
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
145860
|
+
target: ts.ScriptTarget.ES2022,
|
|
145861
|
+
jsx: ts.JsxEmit.Preserve,
|
|
145862
|
+
types: []
|
|
145863
|
+
};
|
|
145864
|
+
if (configPath) {
|
|
145865
|
+
try {
|
|
145866
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
145867
|
+
if (!config.error) {
|
|
145868
|
+
const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, projectRoot);
|
|
145869
|
+
options = { ...options, ...parsed.options, noEmit: true, noLib: true, skipLibCheck: true, allowJs: true, checkJs: false, types: [] };
|
|
145870
|
+
}
|
|
145871
|
+
} catch {
|
|
145872
|
+
}
|
|
145873
|
+
}
|
|
145874
|
+
return options;
|
|
145875
|
+
}
|
|
145876
|
+
function resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedFileName) {
|
|
145877
|
+
if (!resolvedFileName || !isInside(projectRoot, resolvedFileName)) return void 0;
|
|
145878
|
+
return filesByCanonicalPath.get(canonicalPath(resolvedFileName));
|
|
145879
|
+
}
|
|
145880
|
+
function isSemanticLanguage(language) {
|
|
145881
|
+
return Boolean(language && SUPPORTED_LANGUAGES.has(language));
|
|
145882
|
+
}
|
|
145883
|
+
function buildTypeScriptSemanticIndex(input) {
|
|
145884
|
+
const started = Date.now();
|
|
145885
|
+
const semanticFiles = input.files.filter((file) => isSemanticLanguage(file.language) && !isCodeGraphExcludedPath(file.path, input.exclude));
|
|
145886
|
+
if (semanticFiles.length === 0) {
|
|
145887
|
+
return { symbols: [], edges: [], parsedFiles: 0, parserErrors: 0, unresolvedCalls: 0, durationMs: Date.now() - started, diagnostics: [] };
|
|
145888
|
+
}
|
|
145889
|
+
const projectRoot = resolve(input.projectRoot);
|
|
145890
|
+
const filesByCanonicalPath = new Map(semanticFiles.map((file) => [canonicalPath(resolve(projectRoot, file.path)), file]));
|
|
145891
|
+
const includePaths = input.includePaths ? new Set(input.includePaths.map(normalizeCodePath)) : void 0;
|
|
145892
|
+
const includedFileIds = new Set(
|
|
145893
|
+
semanticFiles.filter((file) => !includePaths || includePaths.has(normalizeCodePath(file.path))).map((file) => file.id)
|
|
145894
|
+
);
|
|
145895
|
+
const rootNames = semanticFiles.map((file) => resolve(projectRoot, file.path));
|
|
145896
|
+
const baseHost = ts.createCompilerHost(makeCompilerOptions(projectRoot), true);
|
|
145897
|
+
const compilerOptions = makeCompilerOptions(projectRoot);
|
|
145898
|
+
const host = {
|
|
145899
|
+
...baseHost,
|
|
145900
|
+
getCurrentDirectory: () => projectRoot,
|
|
145901
|
+
fileExists: (fileName) => isInside(projectRoot, fileName) && baseHost.fileExists(fileName),
|
|
145902
|
+
readFile: (fileName) => isInside(projectRoot, fileName) ? baseHost.readFile(fileName) : void 0,
|
|
145903
|
+
realpath: (fileName) => fileName,
|
|
145904
|
+
getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
|
|
145905
|
+
if (!isInside(projectRoot, fileName)) return void 0;
|
|
145906
|
+
const text2 = baseHost.readFile(fileName);
|
|
145907
|
+
if (text2 === void 0) return void 0;
|
|
145908
|
+
return ts.createSourceFile(fileName, text2, languageVersion, true, scriptKind(fileName));
|
|
145909
|
+
}
|
|
145910
|
+
};
|
|
145911
|
+
const program = ts.createProgram({ rootNames, options: compilerOptions, host });
|
|
145912
|
+
const checker = program.getTypeChecker();
|
|
145913
|
+
const symbols = [];
|
|
145914
|
+
const allSymbols = [];
|
|
145915
|
+
const declarationToRecord = /* @__PURE__ */ new Map();
|
|
145916
|
+
const checkerToRecord = /* @__PURE__ */ new Map();
|
|
145917
|
+
const declarationNameNodes = /* @__PURE__ */ new Set();
|
|
145918
|
+
const ordinalByKey = /* @__PURE__ */ new Map();
|
|
145919
|
+
const sourceFiles = program.getSourceFiles().filter((sourceFile) => filesByCanonicalPath.has(canonicalPath(sourceFile.fileName)));
|
|
145920
|
+
for (const sourceFile of sourceFiles) {
|
|
145921
|
+
const file = filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
|
|
145922
|
+
if (!file) continue;
|
|
145923
|
+
const visitDeclarations = (node) => {
|
|
145924
|
+
if (isDeclarationNode(node)) {
|
|
145925
|
+
const name = declarationName(node);
|
|
145926
|
+
const kind = symbolKind(node);
|
|
145927
|
+
if (name && kind) {
|
|
145928
|
+
const qName = qualifiedName(node, name, ordinalByKey);
|
|
145929
|
+
const start = node.getStart(sourceFile);
|
|
145930
|
+
const symbol = {
|
|
145931
|
+
id: makeCodeSymbolId({ projectId: input.projectId, path: file.path, qualifiedName: qName, kind }),
|
|
145932
|
+
projectId: input.projectId,
|
|
145933
|
+
fileId: file.id || makeCodeFileId(input.projectId, file.path),
|
|
145934
|
+
path: file.path,
|
|
145935
|
+
name,
|
|
145936
|
+
qualifiedName: qName,
|
|
145937
|
+
kind,
|
|
145938
|
+
startLine: lineAt(sourceFile, start),
|
|
145939
|
+
endLine: lineAt(sourceFile, node.end),
|
|
145940
|
+
signature: signatureFor(checker, node, sourceFile),
|
|
145941
|
+
contentHash: hashText(sourceFile.text.slice(start, node.end)),
|
|
145942
|
+
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
145943
|
+
source: SEMANTIC_SOURCE
|
|
145944
|
+
};
|
|
145945
|
+
const namedNode = node;
|
|
145946
|
+
const checkerSymbol = namedNode.name ? checker.getSymbolAtLocation(namedNode.name) : void 0;
|
|
145947
|
+
const record80 = { node, symbol, ...checkerSymbol ? { checkerSymbol } : {} };
|
|
145948
|
+
allSymbols.push(symbol);
|
|
145949
|
+
if (!includePaths || includePaths.has(normalizeCodePath(file.path))) symbols.push(symbol);
|
|
145950
|
+
declarationToRecord.set(node, record80);
|
|
145951
|
+
if (checkerSymbol) {
|
|
145952
|
+
checkerToRecord.set(checkerSymbol, record80);
|
|
145953
|
+
for (const declaration of checkerSymbol.declarations ?? []) declarationToRecord.set(declaration, record80);
|
|
145954
|
+
}
|
|
145955
|
+
if (namedNode.name) declarationNameNodes.add(namedNode.name);
|
|
145956
|
+
}
|
|
145957
|
+
}
|
|
145958
|
+
node.forEachChild(visitDeclarations);
|
|
145959
|
+
};
|
|
145960
|
+
visitDeclarations(sourceFile);
|
|
145961
|
+
}
|
|
145962
|
+
const edges = /* @__PURE__ */ new Map();
|
|
145963
|
+
const addEdge = (inputEdge) => {
|
|
145964
|
+
const from = inputEdge.fromSymbolId ?? inputEdge.fromFileId ?? "";
|
|
145965
|
+
const to = inputEdge.toSymbolId ?? inputEdge.toFileId ?? (inputEdge.type === "imports" && inputEdge.evidence ? `unresolved:${inputEdge.evidence}` : "");
|
|
145966
|
+
if (!from || !to) return;
|
|
145967
|
+
if (includePaths) {
|
|
145968
|
+
const endpointFileIds = /* @__PURE__ */ new Set();
|
|
145969
|
+
if (inputEdge.fromFileId) endpointFileIds.add(inputEdge.fromFileId);
|
|
145970
|
+
if (inputEdge.toFileId) endpointFileIds.add(inputEdge.toFileId);
|
|
145971
|
+
for (const symbol of allSymbols) {
|
|
145972
|
+
if (symbol.id === inputEdge.fromSymbolId || symbol.id === inputEdge.toSymbolId) endpointFileIds.add(symbol.fileId);
|
|
145973
|
+
}
|
|
145974
|
+
if (![...endpointFileIds].some((fileId) => includedFileIds.has(fileId))) return;
|
|
145975
|
+
}
|
|
145976
|
+
const id = makeCodeEdgeId(input.projectId, from, inputEdge.type, to);
|
|
145977
|
+
if (edges.has(id)) return;
|
|
145978
|
+
edges.set(id, {
|
|
145979
|
+
...inputEdge,
|
|
145980
|
+
id,
|
|
145981
|
+
projectId: input.projectId,
|
|
145982
|
+
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
145983
|
+
source: SEMANTIC_SOURCE
|
|
145984
|
+
});
|
|
145985
|
+
};
|
|
145986
|
+
const resolveRecord = (symbol) => {
|
|
145987
|
+
if (!symbol) return void 0;
|
|
145988
|
+
let target = symbol;
|
|
145989
|
+
if (target.flags & ts.SymbolFlags.Alias) {
|
|
145990
|
+
try {
|
|
145991
|
+
target = checker.getAliasedSymbol(target);
|
|
145992
|
+
} catch {
|
|
145993
|
+
}
|
|
145994
|
+
}
|
|
145995
|
+
return checkerToRecord.get(target) ?? (target.declarations ?? []).map((declaration) => declarationToRecord.get(declaration)).find(Boolean);
|
|
145996
|
+
};
|
|
145997
|
+
const currentRecord = (node) => {
|
|
145998
|
+
let parent = node;
|
|
145999
|
+
while (parent) {
|
|
146000
|
+
const record80 = declarationToRecord.get(parent);
|
|
146001
|
+
if (record80) return record80;
|
|
146002
|
+
parent = parent.parent;
|
|
146003
|
+
}
|
|
146004
|
+
return void 0;
|
|
146005
|
+
};
|
|
146006
|
+
const fileForSource = (sourceFile) => filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
|
|
146007
|
+
const addFileRelation = (sourceFile, target, type, node, evidence) => {
|
|
146008
|
+
const source = fileForSource(sourceFile);
|
|
146009
|
+
if (!source || source.id === target?.id) return;
|
|
146010
|
+
addEdge({
|
|
146011
|
+
fromFileId: source.id,
|
|
146012
|
+
...target ? { toFileId: target.id } : {},
|
|
146013
|
+
type,
|
|
146014
|
+
confidence: target ? 0.99 : 0.55,
|
|
146015
|
+
evidence: evidence ?? `${type} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146016
|
+
});
|
|
146017
|
+
};
|
|
146018
|
+
const moduleTarget = (sourceFile, moduleName) => {
|
|
146019
|
+
const resolvedModule = ts.resolveModuleName(moduleName, sourceFile.fileName, compilerOptions, host).resolvedModule;
|
|
146020
|
+
return resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedModule?.resolvedFileName);
|
|
146021
|
+
};
|
|
146022
|
+
let unresolvedCalls = 0;
|
|
146023
|
+
for (const sourceFile of sourceFiles) {
|
|
146024
|
+
const file = fileForSource(sourceFile);
|
|
146025
|
+
if (!file) continue;
|
|
146026
|
+
const visit = (node) => {
|
|
146027
|
+
const owner = currentRecord(node);
|
|
146028
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
146029
|
+
addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "imports", node, `imports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
|
|
146030
|
+
} else if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
146031
|
+
addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "exports", node, `exports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
|
|
146032
|
+
} else if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
146033
|
+
const signature = checker.getResolvedSignature(node);
|
|
146034
|
+
const declarationNameNode = signature?.declaration ? signature.declaration.name : void 0;
|
|
146035
|
+
const target = resolveRecord(declarationNameNode ? checker.getSymbolAtLocation(declarationNameNode) : void 0) ?? (signature?.declaration ? declarationToRecord.get(signature.declaration) : void 0) ?? resolveRecord(checker.getSymbolAtLocation(node.expression));
|
|
146036
|
+
if (target) {
|
|
146037
|
+
const from = owner?.symbol.id;
|
|
146038
|
+
addEdge({
|
|
146039
|
+
...from ? { fromSymbolId: from } : { fromFileId: file.id },
|
|
146040
|
+
toSymbolId: target.symbol.id,
|
|
146041
|
+
type: "calls",
|
|
146042
|
+
confidence: 0.98,
|
|
146043
|
+
evidence: `resolved call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146044
|
+
});
|
|
146045
|
+
if (isTestPath(file.path)) {
|
|
146046
|
+
addEdge({
|
|
146047
|
+
...from ? { fromSymbolId: from } : { fromFileId: file.id },
|
|
146048
|
+
toSymbolId: target.symbol.id,
|
|
146049
|
+
type: "tests",
|
|
146050
|
+
confidence: 0.97,
|
|
146051
|
+
evidence: `resolved test call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146052
|
+
});
|
|
146053
|
+
}
|
|
146054
|
+
} else {
|
|
146055
|
+
unresolvedCalls++;
|
|
146056
|
+
}
|
|
146057
|
+
} else if (ts.isIdentifier(node) && !declarationNameNodes.has(node) && !ts.isImportSpecifier(node.parent) && !ts.isExportSpecifier(node.parent)) {
|
|
146058
|
+
const target = resolveRecord(checker.getSymbolAtLocation(node));
|
|
146059
|
+
if (target) {
|
|
146060
|
+
addEdge({
|
|
146061
|
+
...owner?.symbol.id ? { fromSymbolId: owner.symbol.id } : { fromFileId: file.id },
|
|
146062
|
+
toSymbolId: target.symbol.id,
|
|
146063
|
+
type: "references",
|
|
146064
|
+
confidence: 0.95,
|
|
146065
|
+
evidence: `resolved reference at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146066
|
+
});
|
|
146067
|
+
}
|
|
146068
|
+
} else if (ts.isHeritageClause(node)) {
|
|
146069
|
+
const ownerRecord = currentRecord(node);
|
|
146070
|
+
for (const type of node.types) {
|
|
146071
|
+
const target = resolveRecord(checker.getSymbolAtLocation(type.expression));
|
|
146072
|
+
if (ownerRecord && target) {
|
|
146073
|
+
addEdge({
|
|
146074
|
+
fromSymbolId: ownerRecord.symbol.id,
|
|
146075
|
+
toSymbolId: target.symbol.id,
|
|
146076
|
+
type: node.token === ts.SyntaxKind.ExtendsKeyword ? "extends" : "implements",
|
|
146077
|
+
confidence: 0.99,
|
|
146078
|
+
evidence: `compiler-resolved heritage at line ${lineAt(sourceFile, type.getStart(sourceFile))}`
|
|
146079
|
+
});
|
|
146080
|
+
}
|
|
146081
|
+
}
|
|
146082
|
+
}
|
|
146083
|
+
node.forEachChild(visit);
|
|
146084
|
+
};
|
|
146085
|
+
visit(sourceFile);
|
|
146086
|
+
}
|
|
146087
|
+
const diagnostics = sourceFiles.flatMap((sourceFile) => {
|
|
146088
|
+
const file = fileForSource(sourceFile);
|
|
146089
|
+
if (!file || includePaths && !includePaths.has(normalizeCodePath(file.path))) return [];
|
|
146090
|
+
return program.getSyntacticDiagnostics(sourceFile).slice(0, 4).map((diagnostic) => ({
|
|
146091
|
+
path: file.path,
|
|
146092
|
+
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, " ").slice(0, 240)
|
|
146093
|
+
}));
|
|
146094
|
+
});
|
|
146095
|
+
return {
|
|
146096
|
+
symbols,
|
|
146097
|
+
edges: [...edges.values()],
|
|
146098
|
+
parsedFiles: sourceFiles.length,
|
|
146099
|
+
parserErrors: diagnostics.length,
|
|
146100
|
+
unresolvedCalls,
|
|
146101
|
+
durationMs: Date.now() - started,
|
|
146102
|
+
diagnostics
|
|
146103
|
+
};
|
|
146104
|
+
}
|
|
146105
|
+
var SEMANTIC_SOURCE, SUPPORTED_LANGUAGES;
|
|
146106
|
+
var init_semantic_provider = __esm({
|
|
146107
|
+
"src/codegraph/semantic-provider.ts"() {
|
|
146108
|
+
"use strict";
|
|
146109
|
+
init_esm_shims();
|
|
146110
|
+
init_exclude3();
|
|
146111
|
+
init_ids();
|
|
146112
|
+
SEMANTIC_SOURCE = "typescript-compiler";
|
|
146113
|
+
SUPPORTED_LANGUAGES = /* @__PURE__ */ new Set(["typescript", "javascript"]);
|
|
146114
|
+
}
|
|
146115
|
+
});
|
|
146116
|
+
|
|
145542
146117
|
// src/codegraph/lite-provider.ts
|
|
145543
146118
|
var lite_provider_exports = {};
|
|
145544
146119
|
__export(lite_provider_exports, {
|
|
@@ -145546,11 +146121,11 @@ __export(lite_provider_exports, {
|
|
|
145546
146121
|
indexProjectLite: () => indexProjectLite,
|
|
145547
146122
|
refreshProjectLite: () => refreshProjectLite
|
|
145548
146123
|
});
|
|
145549
|
-
import { createHash as
|
|
145550
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
145551
|
-
import { join as join4, relative } from "path";
|
|
145552
|
-
function
|
|
145553
|
-
return
|
|
146124
|
+
import { createHash as createHash9 } from "crypto";
|
|
146125
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
146126
|
+
import { join as join4, relative as relative2 } from "path";
|
|
146127
|
+
function hashText2(text2) {
|
|
146128
|
+
return createHash9("sha256").update(text2).digest("hex");
|
|
145554
146129
|
}
|
|
145555
146130
|
function extension2(path22) {
|
|
145556
146131
|
const index = path22.lastIndexOf(".");
|
|
@@ -145576,7 +146151,7 @@ function walk(root, exclude, maxFiles) {
|
|
|
145576
146151
|
}
|
|
145577
146152
|
for (const entry of entries) {
|
|
145578
146153
|
const abs = join4(dir, entry.name);
|
|
145579
|
-
const rel = normalizeCodePath(
|
|
146154
|
+
const rel = normalizeCodePath(relative2(root, abs));
|
|
145580
146155
|
if (isCodeGraphExcludedPath(rel, exclude)) continue;
|
|
145581
146156
|
if (entry.isDirectory()) {
|
|
145582
146157
|
if (entry.name === ".git" || entry.name === ".worktrees" || entry.name === ".tmp" || entry.name === "node_modules") continue;
|
|
@@ -145619,8 +146194,9 @@ function extractSymbols(projectId, file, text2, indexedAt) {
|
|
|
145619
146194
|
startLine,
|
|
145620
146195
|
endLine: startLine,
|
|
145621
146196
|
signature: match2[0].slice(0, 160),
|
|
145622
|
-
contentHash:
|
|
145623
|
-
indexedAt
|
|
146197
|
+
contentHash: hashText2(match2[0]),
|
|
146198
|
+
indexedAt,
|
|
146199
|
+
source: "lite-regex"
|
|
145624
146200
|
});
|
|
145625
146201
|
}
|
|
145626
146202
|
}
|
|
@@ -145645,7 +146221,8 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
|
|
|
145645
146221
|
type: "imports",
|
|
145646
146222
|
confidence: 0.7,
|
|
145647
146223
|
evidence: line,
|
|
145648
|
-
indexedAt
|
|
146224
|
+
indexedAt,
|
|
146225
|
+
source: "lite-regex"
|
|
145649
146226
|
});
|
|
145650
146227
|
}
|
|
145651
146228
|
continue;
|
|
@@ -145658,28 +146235,30 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
|
|
|
145658
146235
|
type: "imports",
|
|
145659
146236
|
confidence: 0.7,
|
|
145660
146237
|
evidence: target,
|
|
145661
|
-
indexedAt
|
|
146238
|
+
indexedAt,
|
|
146239
|
+
source: "lite-regex"
|
|
145662
146240
|
});
|
|
145663
146241
|
}
|
|
145664
146242
|
}
|
|
145665
146243
|
return edges;
|
|
145666
146244
|
}
|
|
145667
146245
|
function indexFileLite(projectId, projectRoot, abs, indexedAt, fileStat) {
|
|
145668
|
-
const rel = normalizeCodePath(
|
|
146246
|
+
const rel = normalizeCodePath(relative2(projectRoot, abs));
|
|
145669
146247
|
try {
|
|
145670
|
-
const text2 =
|
|
146248
|
+
const text2 = readFileSync8(abs, "utf-8");
|
|
145671
146249
|
const stat5 = fileStat ?? statSync3(abs);
|
|
145672
146250
|
const file = {
|
|
145673
146251
|
id: makeCodeFileId(projectId, rel),
|
|
145674
146252
|
projectId,
|
|
145675
146253
|
path: rel,
|
|
145676
146254
|
language: languageForPath(rel),
|
|
145677
|
-
contentHash:
|
|
146255
|
+
contentHash: hashText2(text2),
|
|
145678
146256
|
// Preserve filesystem precision. Rounding here made same-size edits in
|
|
145679
146257
|
// a short Windows timestamp window indistinguishable to refresh.
|
|
145680
146258
|
mtimeMs: Number(stat5.mtimeMs),
|
|
145681
146259
|
sizeBytes: Number(stat5.size),
|
|
145682
|
-
indexedAt
|
|
146260
|
+
indexedAt,
|
|
146261
|
+
source: "lite-regex"
|
|
145683
146262
|
};
|
|
145684
146263
|
return {
|
|
145685
146264
|
delta: {
|
|
@@ -145734,6 +146313,7 @@ async function refreshProjectLite(store, options) {
|
|
|
145734
146313
|
const indexedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
145735
146314
|
const paths = walk(options.projectRoot, exclude, maxFiles);
|
|
145736
146315
|
const existingByPath = new Map(store.listFiles(options.projectId).map((file) => [file.path, file]));
|
|
146316
|
+
const changedPaths = /* @__PURE__ */ new Set();
|
|
145737
146317
|
const changed = [];
|
|
145738
146318
|
const metadataOnly = [];
|
|
145739
146319
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
@@ -145742,7 +146322,7 @@ async function refreshProjectLite(store, options) {
|
|
|
145742
146322
|
let skippedOversizedFiles = 0;
|
|
145743
146323
|
let unreadableFiles = 0;
|
|
145744
146324
|
for (const abs of paths) {
|
|
145745
|
-
const rel = normalizeCodePath(
|
|
146325
|
+
const rel = normalizeCodePath(relative2(options.projectRoot, abs));
|
|
145746
146326
|
seenPaths.add(rel);
|
|
145747
146327
|
let stat5;
|
|
145748
146328
|
try {
|
|
@@ -145757,6 +146337,7 @@ async function refreshProjectLite(store, options) {
|
|
|
145757
146337
|
if (sizeBytes > maxFileBytes) {
|
|
145758
146338
|
skippedOversizedFiles++;
|
|
145759
146339
|
if (existing) oversizedExistingFileIds.add(existing.id);
|
|
146340
|
+
changedPaths.add(rel);
|
|
145760
146341
|
continue;
|
|
145761
146342
|
}
|
|
145762
146343
|
if (existing && existing.mtimeMs === mtimeMs && existing.sizeBytes === sizeBytes) {
|
|
@@ -145774,6 +146355,7 @@ async function refreshProjectLite(store, options) {
|
|
|
145774
146355
|
unchangedFiles++;
|
|
145775
146356
|
} else {
|
|
145776
146357
|
changed.push(delta);
|
|
146358
|
+
changedPaths.add(rel);
|
|
145777
146359
|
}
|
|
145778
146360
|
}
|
|
145779
146361
|
const removalScanDeferred = paths.length >= maxFiles;
|
|
@@ -145781,11 +146363,64 @@ async function refreshProjectLite(store, options) {
|
|
|
145781
146363
|
...oversizedExistingFileIds,
|
|
145782
146364
|
...removalScanDeferred ? [] : [...existingByPath.values()].filter((file) => !seenPaths.has(file.path)).map((file) => file.id)
|
|
145783
146365
|
])];
|
|
146366
|
+
for (const file of existingByPath.values()) {
|
|
146367
|
+
if (removedFileIds.includes(file.id)) changedPaths.add(file.path);
|
|
146368
|
+
}
|
|
146369
|
+
const affectedSemanticPaths = /* @__PURE__ */ new Set([
|
|
146370
|
+
...changedPaths,
|
|
146371
|
+
...store.listImportDependentPaths(
|
|
146372
|
+
options.projectId,
|
|
146373
|
+
[...changedPaths],
|
|
146374
|
+
changed.map((delta) => delta.file.path)
|
|
146375
|
+
)
|
|
146376
|
+
]);
|
|
145784
146377
|
store.applyFileDeltas(options.projectId, {
|
|
145785
146378
|
changed,
|
|
145786
146379
|
metadataOnly,
|
|
145787
146380
|
removedFileIds
|
|
145788
146381
|
});
|
|
146382
|
+
const currentFiles = store.listFiles(options.projectId);
|
|
146383
|
+
const beforeSemantic = store.status(options.projectId).semanticSymbols;
|
|
146384
|
+
const semanticPaths = beforeSemantic === 0 ? currentFiles.filter((file) => isSemanticLanguage(file.language)).map((file) => file.path) : currentFiles.filter((file) => isSemanticLanguage(file.language) && affectedSemanticPaths.has(file.path)).map((file) => file.path);
|
|
146385
|
+
let semanticSummary;
|
|
146386
|
+
if (semanticPaths.length > 0) {
|
|
146387
|
+
const semanticIndexer = options.semanticIndexer ?? buildTypeScriptSemanticIndex;
|
|
146388
|
+
const semanticInput = {
|
|
146389
|
+
projectId: options.projectId,
|
|
146390
|
+
projectRoot: options.projectRoot,
|
|
146391
|
+
files: currentFiles,
|
|
146392
|
+
exclude,
|
|
146393
|
+
includePaths: semanticPaths
|
|
146394
|
+
};
|
|
146395
|
+
try {
|
|
146396
|
+
const semantic = semanticIndexer(semanticInput);
|
|
146397
|
+
store.replaceSemanticSlice(options.projectId, semanticPaths, semantic);
|
|
146398
|
+
semanticSummary = {
|
|
146399
|
+
state: semantic.parserErrors > 0 ? "partial" : "ready",
|
|
146400
|
+
parsedFiles: semantic.parsedFiles,
|
|
146401
|
+
affectedFiles: semanticPaths.length,
|
|
146402
|
+
symbols: semantic.symbols.length,
|
|
146403
|
+
edges: semantic.edges.length,
|
|
146404
|
+
parserErrors: semantic.parserErrors,
|
|
146405
|
+
unresolvedCalls: semantic.unresolvedCalls,
|
|
146406
|
+
durationMs: semantic.durationMs
|
|
146407
|
+
};
|
|
146408
|
+
} catch (error) {
|
|
146409
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
146410
|
+
store.markSemanticSliceFailed(options.projectId, semanticPaths, message);
|
|
146411
|
+
semanticSummary = {
|
|
146412
|
+
state: "failed",
|
|
146413
|
+
parsedFiles: 0,
|
|
146414
|
+
affectedFiles: semanticPaths.length,
|
|
146415
|
+
symbols: 0,
|
|
146416
|
+
edges: 0,
|
|
146417
|
+
parserErrors: semanticPaths.length,
|
|
146418
|
+
unresolvedCalls: 0,
|
|
146419
|
+
durationMs: 0,
|
|
146420
|
+
error: message.slice(0, 500)
|
|
146421
|
+
};
|
|
146422
|
+
}
|
|
146423
|
+
}
|
|
145789
146424
|
const completeness = {
|
|
145790
146425
|
scannedFiles: paths.length,
|
|
145791
146426
|
maxFiles,
|
|
@@ -145815,7 +146450,8 @@ async function refreshProjectLite(store, options) {
|
|
|
145815
146450
|
skippedOversizedFiles,
|
|
145816
146451
|
unreadableFiles,
|
|
145817
146452
|
removalScanDeferred,
|
|
145818
|
-
snapshot
|
|
146453
|
+
snapshot,
|
|
146454
|
+
...semanticSummary ? { semantic: semanticSummary } : {}
|
|
145819
146455
|
};
|
|
145820
146456
|
}
|
|
145821
146457
|
var DEFAULT_CODEGRAPH_MAX_FILE_BYTES, LANGUAGE_BY_EXTENSION, SUPPORTED_EXTENSIONS, identifier, languageProfiles;
|
|
@@ -145826,6 +146462,7 @@ var init_lite_provider = __esm({
|
|
|
145826
146462
|
init_code_state();
|
|
145827
146463
|
init_ids();
|
|
145828
146464
|
init_exclude3();
|
|
146465
|
+
init_semantic_provider();
|
|
145829
146466
|
DEFAULT_CODEGRAPH_MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
145830
146467
|
LANGUAGE_BY_EXTENSION = /* @__PURE__ */ new Map([
|
|
145831
146468
|
[".ts", "typescript"],
|
|
@@ -146117,7 +146754,7 @@ var claim_store_exports = {};
|
|
|
146117
146754
|
__export(claim_store_exports, {
|
|
146118
146755
|
ClaimStore: () => ClaimStore
|
|
146119
146756
|
});
|
|
146120
|
-
import { createHash as
|
|
146757
|
+
import { createHash as createHash10, randomUUID as randomUUID12 } from "crypto";
|
|
146121
146758
|
function optionalText3(value) {
|
|
146122
146759
|
return typeof value === "string" && value ? value : void 0;
|
|
146123
146760
|
}
|
|
@@ -146170,7 +146807,7 @@ function rowToEvent3(row) {
|
|
|
146170
146807
|
};
|
|
146171
146808
|
}
|
|
146172
146809
|
function evidenceKey(input) {
|
|
146173
|
-
return
|
|
146810
|
+
return createHash10("sha256").update(JSON.stringify([
|
|
146174
146811
|
input.evidenceKind,
|
|
146175
146812
|
input.evidenceId,
|
|
146176
146813
|
input.relation,
|
|
@@ -146368,7 +147005,7 @@ __export(claims_exports, {
|
|
|
146368
147005
|
supersedeClaim: () => supersedeClaim,
|
|
146369
147006
|
writeClaim: () => writeClaim
|
|
146370
147007
|
});
|
|
146371
|
-
import { createHash as
|
|
147008
|
+
import { createHash as createHash11, randomUUID as randomUUID13 } from "crypto";
|
|
146372
147009
|
function compactText2(value, field) {
|
|
146373
147010
|
if (typeof value !== "string") throw new Error("Claim " + field + " must be text");
|
|
146374
147011
|
const sanitized = sanitizeCredentials(value).trim().replace(/\s+/g, " ");
|
|
@@ -146380,7 +147017,7 @@ function normalizedTerm(value) {
|
|
|
146380
147017
|
return compactText2(value, "identity").toLocaleLowerCase("en-US");
|
|
146381
147018
|
}
|
|
146382
147019
|
function hashIdentity(parts) {
|
|
146383
|
-
return
|
|
147020
|
+
return createHash11("sha256").update(parts.join(String.fromCharCode(31))).digest("hex");
|
|
146384
147021
|
}
|
|
146385
147022
|
function buildClaimIdentity(input) {
|
|
146386
147023
|
const subject = normalizedTerm(input.subject);
|
|
@@ -146621,7 +147258,7 @@ function supersedeClaim(store, input) {
|
|
|
146621
147258
|
});
|
|
146622
147259
|
}
|
|
146623
147260
|
function hashObservation(observation) {
|
|
146624
|
-
return
|
|
147261
|
+
return createHash11("sha256").update(JSON.stringify([
|
|
146625
147262
|
observation.title,
|
|
146626
147263
|
observation.narrative,
|
|
146627
147264
|
observation.facts,
|
|
@@ -146865,11 +147502,11 @@ var init_frontmatter = __esm({
|
|
|
146865
147502
|
});
|
|
146866
147503
|
|
|
146867
147504
|
// src/knowledge/markdown.ts
|
|
146868
|
-
import { createHash as
|
|
147505
|
+
import { createHash as createHash12 } from "crypto";
|
|
146869
147506
|
import { promises as fs10 } from "fs";
|
|
146870
147507
|
import path16 from "path";
|
|
146871
147508
|
function hashContent(content) {
|
|
146872
|
-
return
|
|
147509
|
+
return createHash12("sha256").update(content).digest("hex");
|
|
146873
147510
|
}
|
|
146874
147511
|
function stringField(data, key) {
|
|
146875
147512
|
const value = data[key];
|
|
@@ -146995,11 +147632,11 @@ __export(wiki_exports, {
|
|
|
146995
147632
|
lintKnowledgeWorkspace: () => lintKnowledgeWorkspace,
|
|
146996
147633
|
readKnowledgePage: () => readKnowledgePage
|
|
146997
147634
|
});
|
|
146998
|
-
import { createHash as
|
|
147635
|
+
import { createHash as createHash13 } from "crypto";
|
|
146999
147636
|
import { promises as fs11 } from "fs";
|
|
147000
147637
|
import path17 from "path";
|
|
147001
147638
|
function hash2(value) {
|
|
147002
|
-
return
|
|
147639
|
+
return createHash13("sha256").update(value).digest("hex");
|
|
147003
147640
|
}
|
|
147004
147641
|
function now() {
|
|
147005
147642
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -147153,8 +147790,8 @@ async function writeIndex(workspace, store) {
|
|
|
147153
147790
|
lines.push("No pending proposals.");
|
|
147154
147791
|
} else {
|
|
147155
147792
|
for (const proposal of pending) {
|
|
147156
|
-
const
|
|
147157
|
-
lines.push("- [" + path17.basename(proposal.proposalPath, ".md") + "](" +
|
|
147793
|
+
const relative3 = path17.relative(paths.root, proposal.proposalPath).split(path17.sep).join("/");
|
|
147794
|
+
lines.push("- [" + path17.basename(proposal.proposalPath, ".md") + "](" + relative3 + ")");
|
|
147158
147795
|
}
|
|
147159
147796
|
}
|
|
147160
147797
|
lines.push("");
|
|
@@ -147856,11 +148493,11 @@ __export(workflows_exports, {
|
|
|
147856
148493
|
syncCanonicalWorkflows: () => syncCanonicalWorkflows,
|
|
147857
148494
|
writeCanonicalWorkflow: () => writeCanonicalWorkflow
|
|
147858
148495
|
});
|
|
147859
|
-
import { createHash as
|
|
148496
|
+
import { createHash as createHash14 } from "crypto";
|
|
147860
148497
|
import { promises as fs12 } from "fs";
|
|
147861
148498
|
import path18 from "path";
|
|
147862
148499
|
function hash3(value) {
|
|
147863
|
-
return
|
|
148500
|
+
return createHash14("sha256").update(value).digest("hex");
|
|
147864
148501
|
}
|
|
147865
148502
|
function now2() {
|
|
147866
148503
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -148294,8 +148931,8 @@ async function importWindsurfWorkflows(input) {
|
|
|
148294
148931
|
return { imported, skipped };
|
|
148295
148932
|
}
|
|
148296
148933
|
function isWithin2(root, candidate) {
|
|
148297
|
-
const
|
|
148298
|
-
return
|
|
148934
|
+
const relative3 = path18.relative(root, candidate);
|
|
148935
|
+
return relative3 !== "" && relative3 !== ".." && !relative3.startsWith(".." + path18.sep) && !path18.isAbsolute(relative3);
|
|
148299
148936
|
}
|
|
148300
148937
|
function adapterRelativePath(workflow, agent) {
|
|
148301
148938
|
const name = "memorix-workflow-" + slug(workflow.id.replace(/^workflow:/, ""));
|
|
@@ -149034,7 +149671,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
149034
149671
|
resolveVectorBackfillRunnerPath: () => resolveVectorBackfillRunnerPath
|
|
149035
149672
|
});
|
|
149036
149673
|
import { spawn as spawn2 } from "child_process";
|
|
149037
|
-
import { existsSync as
|
|
149674
|
+
import { existsSync as existsSync10 } from "fs";
|
|
149038
149675
|
import path19 from "path";
|
|
149039
149676
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
149040
149677
|
function isNonEmptyString(value) {
|
|
@@ -149063,7 +149700,7 @@ function parseVectorBackfillRequest(raw) {
|
|
|
149063
149700
|
}
|
|
149064
149701
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
149065
149702
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
149066
|
-
const exists = options.exists ??
|
|
149703
|
+
const exists = options.exists ?? existsSync10;
|
|
149067
149704
|
if (!exists(runnerPath)) return false;
|
|
149068
149705
|
try {
|
|
149069
149706
|
const child = (options.spawn ?? spawn2)(process.execPath, [runnerPath], {
|
|
@@ -149101,14 +149738,14 @@ async function executeVectorBackfill(request) {
|
|
|
149101
149738
|
return worker.runOnce();
|
|
149102
149739
|
}
|
|
149103
149740
|
async function readStdin() {
|
|
149104
|
-
return new Promise((
|
|
149741
|
+
return new Promise((resolve2, reject) => {
|
|
149105
149742
|
let raw = "";
|
|
149106
149743
|
process.stdin.setEncoding("utf8");
|
|
149107
149744
|
process.stdin.on("data", (chunk) => {
|
|
149108
149745
|
raw += chunk;
|
|
149109
149746
|
});
|
|
149110
149747
|
process.stdin.once("error", reject);
|
|
149111
|
-
process.stdin.once("end", () =>
|
|
149748
|
+
process.stdin.once("end", () => resolve2(raw));
|
|
149112
149749
|
});
|
|
149113
149750
|
}
|
|
149114
149751
|
async function main() {
|
|
@@ -150237,7 +150874,7 @@ __export(audio_jobs_exports, {
|
|
|
150237
150874
|
transcribeAudio: () => transcribeAudio
|
|
150238
150875
|
});
|
|
150239
150876
|
import { spawn as spawn3 } from "child_process";
|
|
150240
|
-
import { existsSync as
|
|
150877
|
+
import { existsSync as existsSync11 } from "fs";
|
|
150241
150878
|
import path20 from "path";
|
|
150242
150879
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
150243
150880
|
function safeError3(error) {
|
|
@@ -150488,7 +151125,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
|
|
|
150488
151125
|
}
|
|
150489
151126
|
function launchMediaAudioRunner(request, options = {}) {
|
|
150490
151127
|
const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
|
|
150491
|
-
if (!
|
|
151128
|
+
if (!existsSync11(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
|
|
150492
151129
|
try {
|
|
150493
151130
|
const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
|
|
150494
151131
|
cwd: request.projectRoot,
|
|
@@ -150539,7 +151176,7 @@ function terminal3(status) {
|
|
|
150539
151176
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
150540
151177
|
}
|
|
150541
151178
|
function sleep5(ms) {
|
|
150542
|
-
return new Promise((
|
|
151179
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
150543
151180
|
}
|
|
150544
151181
|
function parseMediaAudioRunnerRequest(raw) {
|
|
150545
151182
|
let value;
|