memorix 1.8.5 → 1.8.7
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 +51 -0
- package/README.md +5 -3
- package/README.zh-CN.md +1 -1
- package/assets/star-history-dark.svg +5 -5
- package/assets/star-history-light.svg +5 -5
- package/assets/star-history.json +35 -5
- package/dist/cli/index.js +2510 -1284
- package/dist/dashboard/static/app.js +51 -3
- package/dist/dashboard/static/style.css +88 -0
- package/dist/index.js +1797 -743
- 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 +51 -0
- package/dist/sdk.js +1787 -733
- package/dist/types.d.ts +1 -1
- package/dist/vector-backfill-runner.js +853 -216
- package/docs/1.8.7-CODEGRAPH.md +166 -0
- package/docs/API_REFERENCE.md +24 -3
- package/docs/ARCHITECTURE.md +13 -0
- package/docs/DEVELOPMENT.md +2 -2
- package/docs/INTEGRATIONS.md +1 -0
- package/docs/MODULES.md +1 -1
- package/docs/README.md +6 -3
- package/docs/SETUP.md +1 -0
- package/package.json +3 -2
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- 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 +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/agent-integrations.ts +1 -0
- package/src/cli/commands/codegraph.ts +25 -11
- package/src/cli/commands/doctor.ts +11 -2
- package/src/cli/commands/hooks-install.ts +9 -2
- package/src/cli/commands/hooks-preview.ts +5 -0
- package/src/cli/commands/integrate.ts +2 -0
- package/src/cli/commands/serve-http.ts +27 -1
- package/src/cli/commands/setup.ts +11 -1
- package/src/cli/commands/uninstall.ts +24 -2
- 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/task-lens.ts +72 -7
- package/src/codegraph/types.ts +25 -3
- package/src/dashboard/server.ts +6 -0
- package/src/dashboard/static/style.css +88 -0
- package/src/hooks/installers/index.ts +55 -0
- package/src/hooks/types.ts +2 -0
- package/src/integrations/registry.ts +9 -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
- package/src/types.ts +1 -1
- package/src/workspace/mcp-adapters/workbuddy.ts +71 -0
|
@@ -725,6 +725,8 @@ CREATE TABLE IF NOT EXISTS code_files (
|
|
|
725
725
|
sizeBytes INTEGER,
|
|
726
726
|
indexedAt TEXT NOT NULL,
|
|
727
727
|
gitCommit TEXT,
|
|
728
|
+
source TEXT,
|
|
729
|
+
parserError TEXT,
|
|
728
730
|
UNIQUE(projectId, path)
|
|
729
731
|
);
|
|
730
732
|
`;
|
|
@@ -743,6 +745,7 @@ CREATE TABLE IF NOT EXISTS code_symbols (
|
|
|
743
745
|
contentHash TEXT,
|
|
744
746
|
indexedAt TEXT NOT NULL,
|
|
745
747
|
stale INTEGER NOT NULL DEFAULT 0,
|
|
748
|
+
source TEXT,
|
|
746
749
|
UNIQUE(projectId, fileId, qualifiedName, kind)
|
|
747
750
|
);
|
|
748
751
|
`;
|
|
@@ -757,6 +760,7 @@ CREATE TABLE IF NOT EXISTS code_edges (
|
|
|
757
760
|
type TEXT NOT NULL,
|
|
758
761
|
confidence REAL NOT NULL DEFAULT 1.0,
|
|
759
762
|
evidence TEXT,
|
|
763
|
+
source TEXT,
|
|
760
764
|
indexedAt TEXT NOT NULL
|
|
761
765
|
);
|
|
762
766
|
`;
|
|
@@ -1488,6 +1492,15 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_maintenance_jobs_active_dedupe
|
|
|
1488
1492
|
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)");
|
|
1489
1493
|
db2.exec("CREATE INDEX IF NOT EXISTS idx_mcp_bindings_project ON mcp_bindings(project_id, last_used_at DESC)");
|
|
1490
1494
|
}
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
id: "1.8.7-codegraph-evidence",
|
|
1498
|
+
apply: (db2) => {
|
|
1499
|
+
addColumnIfMissing(db2, "code_files", "source", "source TEXT");
|
|
1500
|
+
addColumnIfMissing(db2, "code_files", "parserError", "parserError TEXT");
|
|
1501
|
+
addColumnIfMissing(db2, "code_symbols", "source", "source TEXT");
|
|
1502
|
+
addColumnIfMissing(db2, "code_edges", "source", "source TEXT");
|
|
1503
|
+
}
|
|
1491
1504
|
}
|
|
1492
1505
|
];
|
|
1493
1506
|
_dbCache = /* @__PURE__ */ new Map();
|
|
@@ -2905,7 +2918,7 @@ function toProviderInput(input, baseUrl) {
|
|
|
2905
2918
|
return { type: input.modality, url: input.url };
|
|
2906
2919
|
}
|
|
2907
2920
|
function parseCacheJsonInWorker(filePath) {
|
|
2908
|
-
return new Promise((
|
|
2921
|
+
return new Promise((resolve2, reject) => {
|
|
2909
2922
|
void import("worker_threads").then(({ Worker }) => {
|
|
2910
2923
|
const worker = new Worker(
|
|
2911
2924
|
`
|
|
@@ -2926,7 +2939,7 @@ function parseCacheJsonInWorker(filePath) {
|
|
|
2926
2939
|
worker.once("message", (msg) => {
|
|
2927
2940
|
void worker.terminate();
|
|
2928
2941
|
if (msg?.ok && Array.isArray(msg.entries)) {
|
|
2929
|
-
|
|
2942
|
+
resolve2(msg.entries);
|
|
2930
2943
|
return;
|
|
2931
2944
|
}
|
|
2932
2945
|
reject(new Error(msg?.error || "embedding cache worker parse failed"));
|
|
@@ -2990,8 +3003,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
2990
3003
|
let count2 = 0;
|
|
2991
3004
|
const writeLine = async (line) => {
|
|
2992
3005
|
if (!out.write(line)) {
|
|
2993
|
-
await new Promise((
|
|
2994
|
-
out.once("drain",
|
|
3006
|
+
await new Promise((resolve2, reject) => {
|
|
3007
|
+
out.once("drain", resolve2);
|
|
2995
3008
|
out.once("error", reject);
|
|
2996
3009
|
});
|
|
2997
3010
|
}
|
|
@@ -3023,7 +3036,7 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
3023
3036
|
`);
|
|
3024
3037
|
count2 += 1;
|
|
3025
3038
|
if (count2 % 50 === 0) {
|
|
3026
|
-
await new Promise((
|
|
3039
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
3027
3040
|
}
|
|
3028
3041
|
}
|
|
3029
3042
|
}
|
|
@@ -3032,8 +3045,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
3032
3045
|
}
|
|
3033
3046
|
}
|
|
3034
3047
|
} finally {
|
|
3035
|
-
await new Promise((
|
|
3036
|
-
out.end(() =>
|
|
3048
|
+
await new Promise((resolve2, reject) => {
|
|
3049
|
+
out.end(() => resolve2());
|
|
3037
3050
|
out.once("error", reject);
|
|
3038
3051
|
});
|
|
3039
3052
|
}
|
|
@@ -3078,7 +3091,7 @@ async function loadCacheJsonl(filePath) {
|
|
|
3078
3091
|
} catch {
|
|
3079
3092
|
}
|
|
3080
3093
|
if (onDiskCount % 250 === 0) {
|
|
3081
|
-
await new Promise((
|
|
3094
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
3082
3095
|
}
|
|
3083
3096
|
}
|
|
3084
3097
|
diskCacheEntryCount = onDiskCount;
|
|
@@ -3323,7 +3336,7 @@ async function saveDiskCacheNow() {
|
|
|
3323
3336
|
return;
|
|
3324
3337
|
}
|
|
3325
3338
|
const tmpPath = `${jsonlPath}.tmp`;
|
|
3326
|
-
await new Promise((
|
|
3339
|
+
await new Promise((resolve2, reject) => {
|
|
3327
3340
|
const out = createWriteStream(tmpPath);
|
|
3328
3341
|
const entries = cache3.entries();
|
|
3329
3342
|
const writeBatch = () => {
|
|
@@ -3342,7 +3355,7 @@ async function saveDiskCacheNow() {
|
|
|
3342
3355
|
}
|
|
3343
3356
|
setImmediate(writeBatch);
|
|
3344
3357
|
};
|
|
3345
|
-
out.on("finish",
|
|
3358
|
+
out.on("finish", resolve2);
|
|
3346
3359
|
out.on("error", reject);
|
|
3347
3360
|
writeBatch();
|
|
3348
3361
|
});
|
|
@@ -3446,7 +3459,7 @@ function abortError() {
|
|
|
3446
3459
|
}
|
|
3447
3460
|
function raceWithAbort(promise, signal) {
|
|
3448
3461
|
if (signal.aborted) return Promise.reject(abortError());
|
|
3449
|
-
return new Promise((
|
|
3462
|
+
return new Promise((resolve2, reject) => {
|
|
3450
3463
|
const onAbort = () => {
|
|
3451
3464
|
signal.removeEventListener("abort", onAbort);
|
|
3452
3465
|
reject(abortError());
|
|
@@ -3455,7 +3468,7 @@ function raceWithAbort(promise, signal) {
|
|
|
3455
3468
|
promise.then(
|
|
3456
3469
|
(value) => {
|
|
3457
3470
|
signal.removeEventListener("abort", onAbort);
|
|
3458
|
-
|
|
3471
|
+
resolve2(value);
|
|
3459
3472
|
},
|
|
3460
3473
|
(error) => {
|
|
3461
3474
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -3466,12 +3479,12 @@ function raceWithAbort(promise, signal) {
|
|
|
3466
3479
|
}
|
|
3467
3480
|
async function waitForRetry(waitMs, signal) {
|
|
3468
3481
|
if (!signal) {
|
|
3469
|
-
await new Promise((
|
|
3482
|
+
await new Promise((resolve2) => setTimeout(resolve2, waitMs));
|
|
3470
3483
|
return;
|
|
3471
3484
|
}
|
|
3472
3485
|
const abortSignal = signal;
|
|
3473
3486
|
if (abortSignal.aborted) throw new Error("Embedding API retry aborted");
|
|
3474
|
-
await new Promise((
|
|
3487
|
+
await new Promise((resolve2, reject) => {
|
|
3475
3488
|
const timer = setTimeout(done, waitMs);
|
|
3476
3489
|
const onAbort = () => {
|
|
3477
3490
|
clearTimeout(timer);
|
|
@@ -3480,7 +3493,7 @@ async function waitForRetry(waitMs, signal) {
|
|
|
3480
3493
|
};
|
|
3481
3494
|
function done() {
|
|
3482
3495
|
abortSignal.removeEventListener("abort", onAbort);
|
|
3483
|
-
|
|
3496
|
+
resolve2();
|
|
3484
3497
|
}
|
|
3485
3498
|
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
3486
3499
|
});
|
|
@@ -5289,12 +5302,12 @@ var init_policy = __esm({
|
|
|
5289
5302
|
|
|
5290
5303
|
// src/timeout.ts
|
|
5291
5304
|
function withTimeout(promise, ms, label) {
|
|
5292
|
-
return new Promise((
|
|
5305
|
+
return new Promise((resolve2, reject) => {
|
|
5293
5306
|
const timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
|
|
5294
5307
|
promise.then(
|
|
5295
5308
|
(value) => {
|
|
5296
5309
|
clearTimeout(timer);
|
|
5297
|
-
|
|
5310
|
+
resolve2(value);
|
|
5298
5311
|
},
|
|
5299
5312
|
(error) => {
|
|
5300
5313
|
clearTimeout(timer);
|
|
@@ -5306,7 +5319,7 @@ function withTimeout(promise, ms, label) {
|
|
|
5306
5319
|
function withTimeoutSignal(operation, ms, label, parentSignal) {
|
|
5307
5320
|
const controller = new AbortController();
|
|
5308
5321
|
const signal = parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal;
|
|
5309
|
-
return new Promise((
|
|
5322
|
+
return new Promise((resolve2, reject) => {
|
|
5310
5323
|
let settled = false;
|
|
5311
5324
|
let timedOut = false;
|
|
5312
5325
|
let timer;
|
|
@@ -5343,7 +5356,7 @@ function withTimeoutSignal(operation, ms, label, parentSignal) {
|
|
|
5343
5356
|
if (settled) return;
|
|
5344
5357
|
settled = true;
|
|
5345
5358
|
cleanup();
|
|
5346
|
-
|
|
5359
|
+
resolve2(value);
|
|
5347
5360
|
},
|
|
5348
5361
|
(error) => {
|
|
5349
5362
|
if (settled) return;
|
|
@@ -6176,7 +6189,7 @@ async function attachCachedVectors(database, candidates) {
|
|
|
6176
6189
|
} catch {
|
|
6177
6190
|
}
|
|
6178
6191
|
if (index % 50 === 0) {
|
|
6179
|
-
await new Promise((
|
|
6192
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
6180
6193
|
}
|
|
6181
6194
|
}
|
|
6182
6195
|
}
|
|
@@ -6252,7 +6265,7 @@ async function hydrateIndex(observations2, options = {}) {
|
|
|
6252
6265
|
}
|
|
6253
6266
|
}
|
|
6254
6267
|
}
|
|
6255
|
-
await new Promise((
|
|
6268
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
6256
6269
|
}
|
|
6257
6270
|
deferredCachedVectorHydration = options.skipCachedVectors ? null : deferCachedVectors ? attachCachedVectors(database, candidates).catch(() => {
|
|
6258
6271
|
}) : null;
|
|
@@ -8519,8 +8532,8 @@ function localWorkspacePath(dataDir, projectId) {
|
|
|
8519
8532
|
return path9.join(path9.resolve(dataDir), "knowledge-workspaces", hash(projectId).slice(0, 24));
|
|
8520
8533
|
}
|
|
8521
8534
|
function isWithin(root, candidate) {
|
|
8522
|
-
const
|
|
8523
|
-
return
|
|
8535
|
+
const relative3 = path9.relative(root, candidate);
|
|
8536
|
+
return relative3 !== "" && !relative3.startsWith(".." + path9.sep) && relative3 !== ".." && !path9.isAbsolute(relative3);
|
|
8524
8537
|
}
|
|
8525
8538
|
function ensureVersionedPath(projectRoot, rootPath) {
|
|
8526
8539
|
if (!path9.isAbsolute(rootPath)) {
|
|
@@ -8538,8 +8551,8 @@ function ensureVersionedPath(projectRoot, rootPath) {
|
|
|
8538
8551
|
return resolvedWorkspace;
|
|
8539
8552
|
}
|
|
8540
8553
|
async function isIgnoredByGit(projectRoot, workspaceRoot) {
|
|
8541
|
-
const
|
|
8542
|
-
const probes = [
|
|
8554
|
+
const relative3 = path9.relative(projectRoot, workspaceRoot).split(path9.sep).join("/");
|
|
8555
|
+
const probes = [relative3, relative3.replace(/\/+$/, "") + "/.memorix-workspace-probe"];
|
|
8543
8556
|
for (const probe of probes) {
|
|
8544
8557
|
try {
|
|
8545
8558
|
await execFileAsync("git", ["-C", projectRoot, "check-ignore", "--quiet", "--no-index", "--", probe], {
|
|
@@ -9655,8 +9668,8 @@ function projectStorageKey(projectId) {
|
|
|
9655
9668
|
}
|
|
9656
9669
|
function validateUnderRoot(root, candidate) {
|
|
9657
9670
|
const resolved = path10.resolve(candidate);
|
|
9658
|
-
const
|
|
9659
|
-
if (
|
|
9671
|
+
const relative3 = path10.relative(root, resolved);
|
|
9672
|
+
if (relative3.startsWith("..") || path10.isAbsolute(relative3)) {
|
|
9660
9673
|
throw new Error("Media storage path escaped the Memorix data directory");
|
|
9661
9674
|
}
|
|
9662
9675
|
return resolved;
|
|
@@ -9700,8 +9713,8 @@ function detectMedia(bytes) {
|
|
|
9700
9713
|
throw new Error("Unsupported or unrecognized media format");
|
|
9701
9714
|
}
|
|
9702
9715
|
function destinationFor(root, projectId, sha256, extension3) {
|
|
9703
|
-
const
|
|
9704
|
-
return { relative:
|
|
9716
|
+
const relative3 = path10.join("assets", projectStorageKey(projectId), sha256.slice(0, 2), `${sha256}${extension3}`);
|
|
9717
|
+
return { relative: relative3, absolute: validateUnderRoot(root, path10.join(root, relative3)) };
|
|
9705
9718
|
}
|
|
9706
9719
|
async function destinationExists(destination) {
|
|
9707
9720
|
try {
|
|
@@ -18231,7 +18244,7 @@ var init_sleep = __esm({
|
|
|
18231
18244
|
"node_modules/openai/internal/utils/sleep.mjs"() {
|
|
18232
18245
|
"use strict";
|
|
18233
18246
|
init_esm_shims();
|
|
18234
|
-
sleep = (ms) => new Promise((
|
|
18247
|
+
sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
18235
18248
|
}
|
|
18236
18249
|
});
|
|
18237
18250
|
|
|
@@ -19420,8 +19433,8 @@ var init_api_promise = __esm({
|
|
|
19420
19433
|
init_parse();
|
|
19421
19434
|
APIPromise = class _APIPromise extends Promise {
|
|
19422
19435
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
19423
|
-
super((
|
|
19424
|
-
|
|
19436
|
+
super((resolve2) => {
|
|
19437
|
+
resolve2(null);
|
|
19425
19438
|
});
|
|
19426
19439
|
this.responsePromise = responsePromise;
|
|
19427
19440
|
this.parseResponse = parseResponse2;
|
|
@@ -20065,12 +20078,12 @@ var init_EventStream = __esm({
|
|
|
20065
20078
|
_EventStream_errored.set(this, false);
|
|
20066
20079
|
_EventStream_aborted.set(this, false);
|
|
20067
20080
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
20068
|
-
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((
|
|
20069
|
-
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise,
|
|
20081
|
+
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
20082
|
+
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve2, "f");
|
|
20070
20083
|
__classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
20071
20084
|
}), "f");
|
|
20072
|
-
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((
|
|
20073
|
-
__classPrivateFieldSet(this, _EventStream_resolveEndPromise,
|
|
20085
|
+
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
|
|
20086
|
+
__classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve2, "f");
|
|
20074
20087
|
__classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject, "f");
|
|
20075
20088
|
}), "f");
|
|
20076
20089
|
__classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => {
|
|
@@ -20154,11 +20167,11 @@ var init_EventStream = __esm({
|
|
|
20154
20167
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
20155
20168
|
*/
|
|
20156
20169
|
emitted(event) {
|
|
20157
|
-
return new Promise((
|
|
20170
|
+
return new Promise((resolve2, reject) => {
|
|
20158
20171
|
__classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
20159
20172
|
if (event !== "error")
|
|
20160
20173
|
this.once("error", reject);
|
|
20161
|
-
this.once(event,
|
|
20174
|
+
this.once(event, resolve2);
|
|
20162
20175
|
});
|
|
20163
20176
|
}
|
|
20164
20177
|
async done() {
|
|
@@ -21227,7 +21240,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
21227
21240
|
if (done) {
|
|
21228
21241
|
return { value: void 0, done: true };
|
|
21229
21242
|
}
|
|
21230
|
-
return new Promise((
|
|
21243
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
21231
21244
|
}
|
|
21232
21245
|
const chunk = pushQueue.shift();
|
|
21233
21246
|
return { value: chunk, done: false };
|
|
@@ -22210,7 +22223,7 @@ var init_AssistantStream = __esm({
|
|
|
22210
22223
|
if (done) {
|
|
22211
22224
|
return { value: void 0, done: true };
|
|
22212
22225
|
}
|
|
22213
|
-
return new Promise((
|
|
22226
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
22214
22227
|
}
|
|
22215
22228
|
const chunk = pushQueue.shift();
|
|
22216
22229
|
return { value: chunk, done: false };
|
|
@@ -24499,7 +24512,7 @@ var init_ResponseStream = __esm({
|
|
|
24499
24512
|
if (done) {
|
|
24500
24513
|
return { value: void 0, done: true };
|
|
24501
24514
|
}
|
|
24502
|
-
return new Promise((
|
|
24515
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
24503
24516
|
}
|
|
24504
24517
|
const event = pushQueue.shift();
|
|
24505
24518
|
return { value: event, done: false };
|
|
@@ -44698,8 +44711,8 @@ var init_event_stream = __esm({
|
|
|
44698
44711
|
constructor(isComplete, extractResult) {
|
|
44699
44712
|
this.isComplete = isComplete;
|
|
44700
44713
|
this.extractResult = extractResult;
|
|
44701
|
-
this.finalResultPromise = new Promise((
|
|
44702
|
-
this.resolveFinalResult =
|
|
44714
|
+
this.finalResultPromise = new Promise((resolve2) => {
|
|
44715
|
+
this.resolveFinalResult = resolve2;
|
|
44703
44716
|
});
|
|
44704
44717
|
}
|
|
44705
44718
|
push(event) {
|
|
@@ -44733,7 +44746,7 @@ var init_event_stream = __esm({
|
|
|
44733
44746
|
} else if (this.done) {
|
|
44734
44747
|
return;
|
|
44735
44748
|
} else {
|
|
44736
|
-
const result = await new Promise((
|
|
44749
|
+
const result = await new Promise((resolve2) => this.waiting.push(resolve2));
|
|
44737
44750
|
if (result.done)
|
|
44738
44751
|
return;
|
|
44739
44752
|
yield result.value;
|
|
@@ -45004,7 +45017,7 @@ var init_sleep2 = __esm({
|
|
|
45004
45017
|
"node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
45005
45018
|
"use strict";
|
|
45006
45019
|
init_esm_shims();
|
|
45007
|
-
sleep2 = (ms) => new Promise((
|
|
45020
|
+
sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
45008
45021
|
}
|
|
45009
45022
|
});
|
|
45010
45023
|
|
|
@@ -45804,8 +45817,8 @@ var init_api_promise2 = __esm({
|
|
|
45804
45817
|
init_parse2();
|
|
45805
45818
|
APIPromise2 = class _APIPromise extends Promise {
|
|
45806
45819
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
45807
|
-
super((
|
|
45808
|
-
|
|
45820
|
+
super((resolve2) => {
|
|
45821
|
+
resolve2(null);
|
|
45809
45822
|
});
|
|
45810
45823
|
this.responsePromise = responsePromise;
|
|
45811
45824
|
this.parseResponse = parseResponse2;
|
|
@@ -47766,12 +47779,12 @@ var init_BetaMessageStream = __esm({
|
|
|
47766
47779
|
}
|
|
47767
47780
|
return this._emit("error", new AnthropicError(String(error)));
|
|
47768
47781
|
});
|
|
47769
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
47770
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise,
|
|
47782
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
47783
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve2, "f");
|
|
47771
47784
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
47772
47785
|
}), "f");
|
|
47773
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((
|
|
47774
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise,
|
|
47786
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
47787
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve2, "f");
|
|
47775
47788
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
47776
47789
|
}), "f");
|
|
47777
47790
|
__classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47941,11 +47954,11 @@ var init_BetaMessageStream = __esm({
|
|
|
47941
47954
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47942
47955
|
*/
|
|
47943
47956
|
emitted(event) {
|
|
47944
|
-
return new Promise((
|
|
47957
|
+
return new Promise((resolve2, reject) => {
|
|
47945
47958
|
__classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
47946
47959
|
if (event !== "error")
|
|
47947
47960
|
this.once("error", reject);
|
|
47948
|
-
this.once(event,
|
|
47961
|
+
this.once(event, resolve2);
|
|
47949
47962
|
});
|
|
47950
47963
|
}
|
|
47951
47964
|
async done() {
|
|
@@ -48288,7 +48301,7 @@ var init_BetaMessageStream = __esm({
|
|
|
48288
48301
|
if (done) {
|
|
48289
48302
|
return { value: void 0, done: true };
|
|
48290
48303
|
}
|
|
48291
|
-
return new Promise((
|
|
48304
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
48292
48305
|
}
|
|
48293
48306
|
const chunk = pushQueue.shift();
|
|
48294
48307
|
return { value: chunk, done: false };
|
|
@@ -48363,13 +48376,13 @@ Wrap your summary in <summary></summary> tags.`;
|
|
|
48363
48376
|
|
|
48364
48377
|
// node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs
|
|
48365
48378
|
function promiseWithResolvers() {
|
|
48366
|
-
let
|
|
48379
|
+
let resolve2;
|
|
48367
48380
|
let reject;
|
|
48368
48381
|
const promise = new Promise((res, rej) => {
|
|
48369
|
-
|
|
48382
|
+
resolve2 = res;
|
|
48370
48383
|
reject = rej;
|
|
48371
48384
|
});
|
|
48372
|
-
return { promise, resolve, reject };
|
|
48385
|
+
return { promise, resolve: resolve2, reject };
|
|
48373
48386
|
}
|
|
48374
48387
|
async function generateToolResponse(params, lastMessage = params.messages.at(-1), requestOptions) {
|
|
48375
48388
|
if (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content || typeof lastMessage.content === "string") {
|
|
@@ -50227,12 +50240,12 @@ var init_MessageStream = __esm({
|
|
|
50227
50240
|
}
|
|
50228
50241
|
return this._emit("error", new AnthropicError(String(error)));
|
|
50229
50242
|
});
|
|
50230
|
-
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((
|
|
50231
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise,
|
|
50243
|
+
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
50244
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise, resolve2, "f");
|
|
50232
50245
|
__classPrivateFieldSet2(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
50233
50246
|
}), "f");
|
|
50234
|
-
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((
|
|
50235
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise,
|
|
50247
|
+
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
50248
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise, resolve2, "f");
|
|
50236
50249
|
__classPrivateFieldSet2(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
50237
50250
|
}), "f");
|
|
50238
50251
|
__classPrivateFieldGet2(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -50402,11 +50415,11 @@ var init_MessageStream = __esm({
|
|
|
50402
50415
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
50403
50416
|
*/
|
|
50404
50417
|
emitted(event) {
|
|
50405
|
-
return new Promise((
|
|
50418
|
+
return new Promise((resolve2, reject) => {
|
|
50406
50419
|
__classPrivateFieldSet2(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
50407
50420
|
if (event !== "error")
|
|
50408
50421
|
this.once("error", reject);
|
|
50409
|
-
this.once(event,
|
|
50422
|
+
this.once(event, resolve2);
|
|
50410
50423
|
});
|
|
50411
50424
|
}
|
|
50412
50425
|
async done() {
|
|
@@ -50724,7 +50737,7 @@ var init_MessageStream = __esm({
|
|
|
50724
50737
|
if (done) {
|
|
50725
50738
|
return { value: void 0, done: true };
|
|
50726
50739
|
}
|
|
50727
|
-
return new Promise((
|
|
50740
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
50728
50741
|
}
|
|
50729
50742
|
const chunk = pushQueue.shift();
|
|
50730
50743
|
return { value: chunk, done: false };
|
|
@@ -54102,7 +54115,7 @@ var require_p_retry = __commonJS({
|
|
|
54102
54115
|
return error;
|
|
54103
54116
|
};
|
|
54104
54117
|
var isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
|
|
54105
|
-
var pRetry2 = (input, options) => new Promise((
|
|
54118
|
+
var pRetry2 = (input, options) => new Promise((resolve2, reject) => {
|
|
54106
54119
|
options = {
|
|
54107
54120
|
onFailedAttempt: () => {
|
|
54108
54121
|
},
|
|
@@ -54112,7 +54125,7 @@ var require_p_retry = __commonJS({
|
|
|
54112
54125
|
const operation = retry2.operation(options);
|
|
54113
54126
|
operation.attempt(async (attemptNumber) => {
|
|
54114
54127
|
try {
|
|
54115
|
-
|
|
54128
|
+
resolve2(await input(attemptNumber));
|
|
54116
54129
|
} catch (error) {
|
|
54117
54130
|
if (!(error instanceof Error)) {
|
|
54118
54131
|
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
@@ -54650,8 +54663,8 @@ var require_retry3 = __commonJS({
|
|
|
54650
54663
|
}
|
|
54651
54664
|
const delay2 = getNextRetryDelay(config);
|
|
54652
54665
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
54653
|
-
const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((
|
|
54654
|
-
setTimeout(
|
|
54666
|
+
const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((resolve2) => {
|
|
54667
|
+
setTimeout(resolve2, delay2);
|
|
54655
54668
|
});
|
|
54656
54669
|
if (config.onRetryAttempt) {
|
|
54657
54670
|
await config.onRetryAttempt(err);
|
|
@@ -55568,8 +55581,8 @@ var require_helpers = __commonJS({
|
|
|
55568
55581
|
function req(url, opts = {}) {
|
|
55569
55582
|
const href = typeof url === "string" ? url : url.href;
|
|
55570
55583
|
const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts);
|
|
55571
|
-
const promise = new Promise((
|
|
55572
|
-
req2.once("response",
|
|
55584
|
+
const promise = new Promise((resolve2, reject) => {
|
|
55585
|
+
req2.once("response", resolve2).once("error", reject).end();
|
|
55573
55586
|
});
|
|
55574
55587
|
req2.then = promise.then.bind(promise);
|
|
55575
55588
|
return req2;
|
|
@@ -55748,7 +55761,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
55748
55761
|
var debug_1 = __importDefault(require_src());
|
|
55749
55762
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
55750
55763
|
function parseProxyResponse(socket) {
|
|
55751
|
-
return new Promise((
|
|
55764
|
+
return new Promise((resolve2, reject) => {
|
|
55752
55765
|
let buffersLength = 0;
|
|
55753
55766
|
const buffers = [];
|
|
55754
55767
|
function read() {
|
|
@@ -55814,7 +55827,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
55814
55827
|
}
|
|
55815
55828
|
debug("got proxy server response: %o %o", firstLine, headers);
|
|
55816
55829
|
cleanup();
|
|
55817
|
-
|
|
55830
|
+
resolve2({
|
|
55818
55831
|
connect: {
|
|
55819
55832
|
statusCode,
|
|
55820
55833
|
statusText,
|
|
@@ -56061,7 +56074,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56061
56074
|
return new originalPromise(executor);
|
|
56062
56075
|
}
|
|
56063
56076
|
function promiseResolvedWith(value) {
|
|
56064
|
-
return newPromise((
|
|
56077
|
+
return newPromise((resolve2) => resolve2(value));
|
|
56065
56078
|
}
|
|
56066
56079
|
function promiseRejectedWith(reason) {
|
|
56067
56080
|
return originalPromiseReject(reason);
|
|
@@ -56231,8 +56244,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56231
56244
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
56232
56245
|
}
|
|
56233
56246
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
56234
|
-
reader._closedPromise = newPromise((
|
|
56235
|
-
reader._closedPromise_resolve =
|
|
56247
|
+
reader._closedPromise = newPromise((resolve2, reject) => {
|
|
56248
|
+
reader._closedPromise_resolve = resolve2;
|
|
56236
56249
|
reader._closedPromise_reject = reject;
|
|
56237
56250
|
});
|
|
56238
56251
|
}
|
|
@@ -56406,8 +56419,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56406
56419
|
}
|
|
56407
56420
|
let resolvePromise;
|
|
56408
56421
|
let rejectPromise;
|
|
56409
|
-
const promise = newPromise((
|
|
56410
|
-
resolvePromise =
|
|
56422
|
+
const promise = newPromise((resolve2, reject) => {
|
|
56423
|
+
resolvePromise = resolve2;
|
|
56411
56424
|
rejectPromise = reject;
|
|
56412
56425
|
});
|
|
56413
56426
|
const readRequest = {
|
|
@@ -56512,8 +56525,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56512
56525
|
const reader = this._reader;
|
|
56513
56526
|
let resolvePromise;
|
|
56514
56527
|
let rejectPromise;
|
|
56515
|
-
const promise = newPromise((
|
|
56516
|
-
resolvePromise =
|
|
56528
|
+
const promise = newPromise((resolve2, reject) => {
|
|
56529
|
+
resolvePromise = resolve2;
|
|
56517
56530
|
rejectPromise = reject;
|
|
56518
56531
|
});
|
|
56519
56532
|
const readRequest = {
|
|
@@ -57532,8 +57545,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57532
57545
|
}
|
|
57533
57546
|
let resolvePromise;
|
|
57534
57547
|
let rejectPromise;
|
|
57535
|
-
const promise = newPromise((
|
|
57536
|
-
resolvePromise =
|
|
57548
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57549
|
+
resolvePromise = resolve2;
|
|
57537
57550
|
rejectPromise = reject;
|
|
57538
57551
|
});
|
|
57539
57552
|
const readIntoRequest = {
|
|
@@ -57845,10 +57858,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57845
57858
|
wasAlreadyErroring = true;
|
|
57846
57859
|
reason = void 0;
|
|
57847
57860
|
}
|
|
57848
|
-
const promise = newPromise((
|
|
57861
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57849
57862
|
stream2._pendingAbortRequest = {
|
|
57850
57863
|
_promise: void 0,
|
|
57851
|
-
_resolve:
|
|
57864
|
+
_resolve: resolve2,
|
|
57852
57865
|
_reject: reject,
|
|
57853
57866
|
_reason: reason,
|
|
57854
57867
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -57865,9 +57878,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57865
57878
|
if (state === "closed" || state === "errored") {
|
|
57866
57879
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
57867
57880
|
}
|
|
57868
|
-
const promise = newPromise((
|
|
57881
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57869
57882
|
const closeRequest = {
|
|
57870
|
-
_resolve:
|
|
57883
|
+
_resolve: resolve2,
|
|
57871
57884
|
_reject: reject
|
|
57872
57885
|
};
|
|
57873
57886
|
stream2._closeRequest = closeRequest;
|
|
@@ -57880,9 +57893,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57880
57893
|
return promise;
|
|
57881
57894
|
}
|
|
57882
57895
|
function WritableStreamAddWriteRequest(stream2) {
|
|
57883
|
-
const promise = newPromise((
|
|
57896
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57884
57897
|
const writeRequest = {
|
|
57885
|
-
_resolve:
|
|
57898
|
+
_resolve: resolve2,
|
|
57886
57899
|
_reject: reject
|
|
57887
57900
|
};
|
|
57888
57901
|
stream2._writeRequests.push(writeRequest);
|
|
@@ -58498,8 +58511,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58498
58511
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
58499
58512
|
}
|
|
58500
58513
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
58501
|
-
writer._closedPromise = newPromise((
|
|
58502
|
-
writer._closedPromise_resolve =
|
|
58514
|
+
writer._closedPromise = newPromise((resolve2, reject) => {
|
|
58515
|
+
writer._closedPromise_resolve = resolve2;
|
|
58503
58516
|
writer._closedPromise_reject = reject;
|
|
58504
58517
|
writer._closedPromiseState = "pending";
|
|
58505
58518
|
});
|
|
@@ -58535,8 +58548,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58535
58548
|
writer._closedPromiseState = "resolved";
|
|
58536
58549
|
}
|
|
58537
58550
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
58538
|
-
writer._readyPromise = newPromise((
|
|
58539
|
-
writer._readyPromise_resolve =
|
|
58551
|
+
writer._readyPromise = newPromise((resolve2, reject) => {
|
|
58552
|
+
writer._readyPromise_resolve = resolve2;
|
|
58540
58553
|
writer._readyPromise_reject = reject;
|
|
58541
58554
|
});
|
|
58542
58555
|
writer._readyPromiseState = "pending";
|
|
@@ -58623,7 +58636,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58623
58636
|
source._disturbed = true;
|
|
58624
58637
|
let shuttingDown = false;
|
|
58625
58638
|
let currentWrite = promiseResolvedWith(void 0);
|
|
58626
|
-
return newPromise((
|
|
58639
|
+
return newPromise((resolve2, reject) => {
|
|
58627
58640
|
let abortAlgorithm;
|
|
58628
58641
|
if (signal !== void 0) {
|
|
58629
58642
|
abortAlgorithm = () => {
|
|
@@ -58768,7 +58781,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58768
58781
|
if (isError) {
|
|
58769
58782
|
reject(error);
|
|
58770
58783
|
} else {
|
|
58771
|
-
|
|
58784
|
+
resolve2(void 0);
|
|
58772
58785
|
}
|
|
58773
58786
|
return null;
|
|
58774
58787
|
}
|
|
@@ -59049,8 +59062,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59049
59062
|
let branch1;
|
|
59050
59063
|
let branch2;
|
|
59051
59064
|
let resolveCancelPromise;
|
|
59052
|
-
const cancelPromise = newPromise((
|
|
59053
|
-
resolveCancelPromise =
|
|
59065
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
59066
|
+
resolveCancelPromise = resolve2;
|
|
59054
59067
|
});
|
|
59055
59068
|
function pullAlgorithm() {
|
|
59056
59069
|
if (reading) {
|
|
@@ -59141,8 +59154,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59141
59154
|
let branch1;
|
|
59142
59155
|
let branch2;
|
|
59143
59156
|
let resolveCancelPromise;
|
|
59144
|
-
const cancelPromise = newPromise((
|
|
59145
|
-
resolveCancelPromise =
|
|
59157
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
59158
|
+
resolveCancelPromise = resolve2;
|
|
59146
59159
|
});
|
|
59147
59160
|
function forwardReaderError(thisReader) {
|
|
59148
59161
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -59922,8 +59935,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59922
59935
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
59923
59936
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
59924
59937
|
let startPromise_resolve;
|
|
59925
|
-
const startPromise = newPromise((
|
|
59926
|
-
startPromise_resolve =
|
|
59938
|
+
const startPromise = newPromise((resolve2) => {
|
|
59939
|
+
startPromise_resolve = resolve2;
|
|
59927
59940
|
});
|
|
59928
59941
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
59929
59942
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -60016,8 +60029,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60016
60029
|
if (stream2._backpressureChangePromise !== void 0) {
|
|
60017
60030
|
stream2._backpressureChangePromise_resolve();
|
|
60018
60031
|
}
|
|
60019
|
-
stream2._backpressureChangePromise = newPromise((
|
|
60020
|
-
stream2._backpressureChangePromise_resolve =
|
|
60032
|
+
stream2._backpressureChangePromise = newPromise((resolve2) => {
|
|
60033
|
+
stream2._backpressureChangePromise_resolve = resolve2;
|
|
60021
60034
|
});
|
|
60022
60035
|
stream2._backpressure = backpressure;
|
|
60023
60036
|
}
|
|
@@ -60185,8 +60198,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60185
60198
|
return controller._finishPromise;
|
|
60186
60199
|
}
|
|
60187
60200
|
const readable = stream2._readable;
|
|
60188
|
-
controller._finishPromise = newPromise((
|
|
60189
|
-
controller._finishPromise_resolve =
|
|
60201
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60202
|
+
controller._finishPromise_resolve = resolve2;
|
|
60190
60203
|
controller._finishPromise_reject = reject;
|
|
60191
60204
|
});
|
|
60192
60205
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -60212,8 +60225,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60212
60225
|
return controller._finishPromise;
|
|
60213
60226
|
}
|
|
60214
60227
|
const readable = stream2._readable;
|
|
60215
|
-
controller._finishPromise = newPromise((
|
|
60216
|
-
controller._finishPromise_resolve =
|
|
60228
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60229
|
+
controller._finishPromise_resolve = resolve2;
|
|
60217
60230
|
controller._finishPromise_reject = reject;
|
|
60218
60231
|
});
|
|
60219
60232
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -60243,8 +60256,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60243
60256
|
return controller._finishPromise;
|
|
60244
60257
|
}
|
|
60245
60258
|
const writable = stream2._writable;
|
|
60246
|
-
controller._finishPromise = newPromise((
|
|
60247
|
-
controller._finishPromise_resolve =
|
|
60259
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60260
|
+
controller._finishPromise_resolve = resolve2;
|
|
60248
60261
|
controller._finishPromise_reject = reject;
|
|
60249
60262
|
});
|
|
60250
60263
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -62231,7 +62244,7 @@ import zlib from "zlib";
|
|
|
62231
62244
|
import Stream4, { PassThrough as PassThrough2, pipeline as pump } from "stream";
|
|
62232
62245
|
import { Buffer as Buffer3 } from "buffer";
|
|
62233
62246
|
async function fetch2(url, options_) {
|
|
62234
|
-
return new Promise((
|
|
62247
|
+
return new Promise((resolve2, reject) => {
|
|
62235
62248
|
const request = new Request2(url, options_);
|
|
62236
62249
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
62237
62250
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -62240,7 +62253,7 @@ async function fetch2(url, options_) {
|
|
|
62240
62253
|
if (parsedURL.protocol === "data:") {
|
|
62241
62254
|
const data = dist_default(request.url);
|
|
62242
62255
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
62243
|
-
|
|
62256
|
+
resolve2(response2);
|
|
62244
62257
|
return;
|
|
62245
62258
|
}
|
|
62246
62259
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -62362,7 +62375,7 @@ async function fetch2(url, options_) {
|
|
|
62362
62375
|
if (responseReferrerPolicy) {
|
|
62363
62376
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
62364
62377
|
}
|
|
62365
|
-
|
|
62378
|
+
resolve2(fetch2(new Request2(locationURL, requestOptions)));
|
|
62366
62379
|
finalize();
|
|
62367
62380
|
return;
|
|
62368
62381
|
}
|
|
@@ -62395,7 +62408,7 @@ async function fetch2(url, options_) {
|
|
|
62395
62408
|
const codings = headers.get("Content-Encoding");
|
|
62396
62409
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
62397
62410
|
response = new Response2(body, responseOptions);
|
|
62398
|
-
|
|
62411
|
+
resolve2(response);
|
|
62399
62412
|
return;
|
|
62400
62413
|
}
|
|
62401
62414
|
const zlibOptions = {
|
|
@@ -62409,7 +62422,7 @@ async function fetch2(url, options_) {
|
|
|
62409
62422
|
}
|
|
62410
62423
|
});
|
|
62411
62424
|
response = new Response2(body, responseOptions);
|
|
62412
|
-
|
|
62425
|
+
resolve2(response);
|
|
62413
62426
|
return;
|
|
62414
62427
|
}
|
|
62415
62428
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -62433,12 +62446,12 @@ async function fetch2(url, options_) {
|
|
|
62433
62446
|
});
|
|
62434
62447
|
}
|
|
62435
62448
|
response = new Response2(body, responseOptions);
|
|
62436
|
-
|
|
62449
|
+
resolve2(response);
|
|
62437
62450
|
});
|
|
62438
62451
|
raw.once("end", () => {
|
|
62439
62452
|
if (!response) {
|
|
62440
62453
|
response = new Response2(body, responseOptions);
|
|
62441
|
-
|
|
62454
|
+
resolve2(response);
|
|
62442
62455
|
}
|
|
62443
62456
|
});
|
|
62444
62457
|
return;
|
|
@@ -62450,11 +62463,11 @@ async function fetch2(url, options_) {
|
|
|
62450
62463
|
}
|
|
62451
62464
|
});
|
|
62452
62465
|
response = new Response2(body, responseOptions);
|
|
62453
|
-
|
|
62466
|
+
resolve2(response);
|
|
62454
62467
|
return;
|
|
62455
62468
|
}
|
|
62456
62469
|
response = new Response2(body, responseOptions);
|
|
62457
|
-
|
|
62470
|
+
resolve2(response);
|
|
62458
62471
|
});
|
|
62459
62472
|
writeToStream(request_, request).catch(reject);
|
|
62460
62473
|
});
|
|
@@ -68577,7 +68590,7 @@ var require_jwtaccess = __commonJS({
|
|
|
68577
68590
|
}
|
|
68578
68591
|
}
|
|
68579
68592
|
fromStreamAsync(inputStream) {
|
|
68580
|
-
return new Promise((
|
|
68593
|
+
return new Promise((resolve2, reject) => {
|
|
68581
68594
|
if (!inputStream) {
|
|
68582
68595
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
68583
68596
|
}
|
|
@@ -68586,7 +68599,7 @@ var require_jwtaccess = __commonJS({
|
|
|
68586
68599
|
try {
|
|
68587
68600
|
const data = JSON.parse(s2);
|
|
68588
68601
|
this.fromJSON(data);
|
|
68589
|
-
|
|
68602
|
+
resolve2();
|
|
68590
68603
|
} catch (err) {
|
|
68591
68604
|
reject(err);
|
|
68592
68605
|
}
|
|
@@ -68826,7 +68839,7 @@ var require_jwtclient = __commonJS({
|
|
|
68826
68839
|
}
|
|
68827
68840
|
}
|
|
68828
68841
|
fromStreamAsync(inputStream) {
|
|
68829
|
-
return new Promise((
|
|
68842
|
+
return new Promise((resolve2, reject) => {
|
|
68830
68843
|
if (!inputStream) {
|
|
68831
68844
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
68832
68845
|
}
|
|
@@ -68835,7 +68848,7 @@ var require_jwtclient = __commonJS({
|
|
|
68835
68848
|
try {
|
|
68836
68849
|
const data = JSON.parse(s2);
|
|
68837
68850
|
this.fromJSON(data);
|
|
68838
|
-
|
|
68851
|
+
resolve2();
|
|
68839
68852
|
} catch (e2) {
|
|
68840
68853
|
reject(e2);
|
|
68841
68854
|
}
|
|
@@ -68969,7 +68982,7 @@ var require_refreshclient = __commonJS({
|
|
|
68969
68982
|
}
|
|
68970
68983
|
}
|
|
68971
68984
|
async fromStreamAsync(inputStream) {
|
|
68972
|
-
return new Promise((
|
|
68985
|
+
return new Promise((resolve2, reject) => {
|
|
68973
68986
|
if (!inputStream) {
|
|
68974
68987
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
68975
68988
|
}
|
|
@@ -68978,7 +68991,7 @@ var require_refreshclient = __commonJS({
|
|
|
68978
68991
|
try {
|
|
68979
68992
|
const data = JSON.parse(s2);
|
|
68980
68993
|
this.fromJSON(data);
|
|
68981
|
-
return
|
|
68994
|
+
return resolve2();
|
|
68982
68995
|
} catch (err) {
|
|
68983
68996
|
return reject(err);
|
|
68984
68997
|
}
|
|
@@ -70824,7 +70837,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
70824
70837
|
* @return A promise that resolves with the executable response.
|
|
70825
70838
|
*/
|
|
70826
70839
|
retrieveResponseFromExecutable(envMap) {
|
|
70827
|
-
return new Promise((
|
|
70840
|
+
return new Promise((resolve2, reject) => {
|
|
70828
70841
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
70829
70842
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
70830
70843
|
});
|
|
@@ -70846,7 +70859,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
70846
70859
|
try {
|
|
70847
70860
|
const responseJson = JSON.parse(output);
|
|
70848
70861
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
70849
|
-
return
|
|
70862
|
+
return resolve2(response);
|
|
70850
70863
|
} catch (error) {
|
|
70851
70864
|
if (error instanceof executable_response_1.ExecutableResponseError) {
|
|
70852
70865
|
return reject(error);
|
|
@@ -72041,7 +72054,7 @@ var require_googleauth = __commonJS({
|
|
|
72041
72054
|
}
|
|
72042
72055
|
}
|
|
72043
72056
|
fromStreamAsync(inputStream, options) {
|
|
72044
|
-
return new Promise((
|
|
72057
|
+
return new Promise((resolve2, reject) => {
|
|
72045
72058
|
if (!inputStream) {
|
|
72046
72059
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
72047
72060
|
}
|
|
@@ -72051,7 +72064,7 @@ var require_googleauth = __commonJS({
|
|
|
72051
72064
|
try {
|
|
72052
72065
|
const data = JSON.parse(chunks.join(""));
|
|
72053
72066
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
72054
|
-
return
|
|
72067
|
+
return resolve2(r2);
|
|
72055
72068
|
} catch (err) {
|
|
72056
72069
|
if (!this.keyFilename)
|
|
72057
72070
|
throw err;
|
|
@@ -72061,7 +72074,7 @@ var require_googleauth = __commonJS({
|
|
|
72061
72074
|
});
|
|
72062
72075
|
this.cachedCredential = client;
|
|
72063
72076
|
this.setGapicJWTValues(client);
|
|
72064
|
-
return
|
|
72077
|
+
return resolve2(client);
|
|
72065
72078
|
}
|
|
72066
72079
|
} catch (err) {
|
|
72067
72080
|
return reject(err);
|
|
@@ -72097,17 +72110,17 @@ var require_googleauth = __commonJS({
|
|
|
72097
72110
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
72098
72111
|
*/
|
|
72099
72112
|
async getDefaultServiceProjectId() {
|
|
72100
|
-
return new Promise((
|
|
72113
|
+
return new Promise((resolve2) => {
|
|
72101
72114
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
|
|
72102
72115
|
if (!err && stdout) {
|
|
72103
72116
|
try {
|
|
72104
72117
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
72105
|
-
|
|
72118
|
+
resolve2(projectId);
|
|
72106
72119
|
return;
|
|
72107
72120
|
} catch (e2) {
|
|
72108
72121
|
}
|
|
72109
72122
|
}
|
|
72110
|
-
|
|
72123
|
+
resolve2(null);
|
|
72111
72124
|
});
|
|
72112
72125
|
});
|
|
72113
72126
|
}
|
|
@@ -75029,7 +75042,7 @@ var require_websocket = __commonJS({
|
|
|
75029
75042
|
var http3 = __require("http");
|
|
75030
75043
|
var net = __require("net");
|
|
75031
75044
|
var tls = __require("tls");
|
|
75032
|
-
var { randomBytes, createHash:
|
|
75045
|
+
var { randomBytes, createHash: createHash15 } = __require("crypto");
|
|
75033
75046
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
75034
75047
|
var { URL: URL2 } = __require("url");
|
|
75035
75048
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -75697,7 +75710,7 @@ var require_websocket = __commonJS({
|
|
|
75697
75710
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
75698
75711
|
return;
|
|
75699
75712
|
}
|
|
75700
|
-
const digest2 =
|
|
75713
|
+
const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
|
|
75701
75714
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
75702
75715
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
75703
75716
|
return;
|
|
@@ -76069,7 +76082,7 @@ var require_websocket_server = __commonJS({
|
|
|
76069
76082
|
var EventEmitter = __require("events");
|
|
76070
76083
|
var http3 = __require("http");
|
|
76071
76084
|
var { Duplex } = __require("stream");
|
|
76072
|
-
var { createHash:
|
|
76085
|
+
var { createHash: createHash15 } = __require("crypto");
|
|
76073
76086
|
var extension3 = require_extension();
|
|
76074
76087
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
76075
76088
|
var subprotocol2 = require_subprotocol();
|
|
@@ -76376,7 +76389,7 @@ var require_websocket_server = __commonJS({
|
|
|
76376
76389
|
);
|
|
76377
76390
|
}
|
|
76378
76391
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
76379
|
-
const digest2 =
|
|
76392
|
+
const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
|
|
76380
76393
|
const headers = [
|
|
76381
76394
|
"HTTP/1.1 101 Switching Protocols",
|
|
76382
76395
|
"Upgrade: websocket",
|
|
@@ -79785,14 +79798,14 @@ function __asyncValues(o) {
|
|
|
79785
79798
|
}, i2);
|
|
79786
79799
|
function verb(n) {
|
|
79787
79800
|
i2[n] = o[n] && function(v) {
|
|
79788
|
-
return new Promise(function(
|
|
79789
|
-
v = o[n](v), settle(
|
|
79801
|
+
return new Promise(function(resolve2, reject) {
|
|
79802
|
+
v = o[n](v), settle(resolve2, reject, v.done, v.value);
|
|
79790
79803
|
});
|
|
79791
79804
|
};
|
|
79792
79805
|
}
|
|
79793
|
-
function settle(
|
|
79806
|
+
function settle(resolve2, reject, d, v) {
|
|
79794
79807
|
Promise.resolve(v).then(function(v2) {
|
|
79795
|
-
|
|
79808
|
+
resolve2({ value: v2, done: d });
|
|
79796
79809
|
}, reject);
|
|
79797
79810
|
}
|
|
79798
79811
|
}
|
|
@@ -90162,8 +90175,8 @@ var init_node = __esm({
|
|
|
90162
90175
|
const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
|
|
90163
90176
|
let onopenResolve = () => {
|
|
90164
90177
|
};
|
|
90165
|
-
const onopenPromise = new Promise((
|
|
90166
|
-
onopenResolve =
|
|
90178
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
90179
|
+
onopenResolve = resolve2;
|
|
90167
90180
|
});
|
|
90168
90181
|
const callbacks = params.callbacks;
|
|
90169
90182
|
const onopenAwaitedCallback = function() {
|
|
@@ -90369,8 +90382,8 @@ var init_node = __esm({
|
|
|
90369
90382
|
}
|
|
90370
90383
|
let onopenResolve = () => {
|
|
90371
90384
|
};
|
|
90372
|
-
const onopenPromise = new Promise((
|
|
90373
|
-
onopenResolve =
|
|
90385
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
90386
|
+
onopenResolve = resolve2;
|
|
90374
90387
|
});
|
|
90375
90388
|
const callbacks = params.callbacks;
|
|
90376
90389
|
const onopenAwaitedCallback = function() {
|
|
@@ -92718,7 +92731,7 @@ var init_node = __esm({
|
|
|
92718
92731
|
return void 0;
|
|
92719
92732
|
}
|
|
92720
92733
|
};
|
|
92721
|
-
sleep$1 = (ms) => new Promise((
|
|
92734
|
+
sleep$1 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
92722
92735
|
FallbackEncoder3 = ({ headers, body }) => {
|
|
92723
92736
|
return {
|
|
92724
92737
|
bodyHeaders: {
|
|
@@ -93227,8 +93240,8 @@ ${underline}`);
|
|
|
93227
93240
|
};
|
|
93228
93241
|
APIPromise3 = class _APIPromise extends Promise {
|
|
93229
93242
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse3) {
|
|
93230
|
-
super((
|
|
93231
|
-
|
|
93243
|
+
super((resolve2) => {
|
|
93244
|
+
resolve2(null);
|
|
93232
93245
|
});
|
|
93233
93246
|
this.responsePromise = responsePromise;
|
|
93234
93247
|
this.parseResponse = parseResponse2;
|
|
@@ -96459,7 +96472,7 @@ function retryIntervalFromResponse(res) {
|
|
|
96459
96472
|
return 0;
|
|
96460
96473
|
}
|
|
96461
96474
|
async function delay(delay2) {
|
|
96462
|
-
return new Promise((
|
|
96475
|
+
return new Promise((resolve2) => setTimeout(resolve2, delay2));
|
|
96463
96476
|
}
|
|
96464
96477
|
var defaultBackoff, PermanentError, TemporaryError, codeRangeRE2;
|
|
96465
96478
|
var init_retries = __esm({
|
|
@@ -134038,12 +134051,12 @@ function capRetryDelayMs(delayMs, options) {
|
|
|
134038
134051
|
return maxRetryDelayMs > 0 ? Math.min(delayMs, maxRetryDelayMs) : delayMs;
|
|
134039
134052
|
}
|
|
134040
134053
|
function sleep4(ms, signal) {
|
|
134041
|
-
return new Promise((
|
|
134054
|
+
return new Promise((resolve2, reject) => {
|
|
134042
134055
|
if (signal?.aborted) {
|
|
134043
134056
|
reject(new Error("Request was aborted"));
|
|
134044
134057
|
return;
|
|
134045
134058
|
}
|
|
134046
|
-
const timeout = setTimeout(
|
|
134059
|
+
const timeout = setTimeout(resolve2, ms);
|
|
134047
134060
|
signal?.addEventListener("abort", () => {
|
|
134048
134061
|
clearTimeout(timeout);
|
|
134049
134062
|
reject(new Error("Request was aborted"));
|
|
@@ -134375,7 +134388,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
134375
134388
|
}
|
|
134376
134389
|
const wsHeaders = headersToRecord(headers);
|
|
134377
134390
|
delete wsHeaders["OpenAI-Beta"];
|
|
134378
|
-
return new Promise((
|
|
134391
|
+
return new Promise((resolve2, reject) => {
|
|
134379
134392
|
let settled = false;
|
|
134380
134393
|
let timeout;
|
|
134381
134394
|
let socket;
|
|
@@ -134410,7 +134423,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
134410
134423
|
return;
|
|
134411
134424
|
settled = true;
|
|
134412
134425
|
cleanup();
|
|
134413
|
-
|
|
134426
|
+
resolve2(socket);
|
|
134414
134427
|
};
|
|
134415
134428
|
const onError = (event) => {
|
|
134416
134429
|
fail2(extractWebSocketError(event));
|
|
@@ -134567,9 +134580,9 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
134567
134580
|
const wake = () => {
|
|
134568
134581
|
if (!pending)
|
|
134569
134582
|
return;
|
|
134570
|
-
const
|
|
134583
|
+
const resolve2 = pending;
|
|
134571
134584
|
pending = null;
|
|
134572
|
-
|
|
134585
|
+
resolve2();
|
|
134573
134586
|
};
|
|
134574
134587
|
const onMessage = (event) => {
|
|
134575
134588
|
void (async () => {
|
|
@@ -134636,8 +134649,8 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
134636
134649
|
if (done)
|
|
134637
134650
|
break;
|
|
134638
134651
|
let timeout;
|
|
134639
|
-
await new Promise((
|
|
134640
|
-
pending =
|
|
134652
|
+
await new Promise((resolve2, reject) => {
|
|
134653
|
+
pending = resolve2;
|
|
134641
134654
|
if (idleTimeoutMs !== void 0 && idleTimeoutMs > 0) {
|
|
134642
134655
|
timeout = setTimeout(() => {
|
|
134643
134656
|
const error = new Error(`WebSocket idle timeout after ${idleTimeoutMs}ms`);
|
|
@@ -144974,6 +144987,8 @@ function rowToFile(row) {
|
|
|
144974
144987
|
...row.sizeBytes != null ? { sizeBytes: row.sizeBytes } : {},
|
|
144975
144988
|
indexedAt: row.indexedAt,
|
|
144976
144989
|
...row.gitCommit ? { gitCommit: row.gitCommit } : {},
|
|
144990
|
+
...row.source ? { source: row.source } : {},
|
|
144991
|
+
...row.parserError ? { parserError: row.parserError } : {},
|
|
144977
144992
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
144978
144993
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
144979
144994
|
};
|
|
@@ -144993,6 +145008,7 @@ function rowToSymbol(row) {
|
|
|
144993
145008
|
...row.contentHash ? { contentHash: row.contentHash } : {},
|
|
144994
145009
|
indexedAt: row.indexedAt,
|
|
144995
145010
|
stale: !!row.stale,
|
|
145011
|
+
...row.source ? { source: row.source } : {},
|
|
144996
145012
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
144997
145013
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
144998
145014
|
};
|
|
@@ -145008,6 +145024,7 @@ function rowToEdge(row) {
|
|
|
145008
145024
|
type: row.type,
|
|
145009
145025
|
confidence: row.confidence,
|
|
145010
145026
|
...row.evidence ? { evidence: row.evidence } : {},
|
|
145027
|
+
...row.source ? { source: row.source } : {},
|
|
145011
145028
|
indexedAt: row.indexedAt,
|
|
145012
145029
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
145013
145030
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
@@ -145128,9 +145145,9 @@ var init_store = __esm({
|
|
|
145128
145145
|
if (files.length === 0) return;
|
|
145129
145146
|
const stmt = this.db.prepare(`
|
|
145130
145147
|
INSERT OR REPLACE INTO code_files
|
|
145131
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145148
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
145132
145149
|
VALUES
|
|
145133
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145150
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
145134
145151
|
`);
|
|
145135
145152
|
const tx = this.db.transaction((items) => {
|
|
145136
145153
|
for (const file of items) {
|
|
@@ -145143,7 +145160,9 @@ var init_store = __esm({
|
|
|
145143
145160
|
mtimeMs: file.mtimeMs ?? null,
|
|
145144
145161
|
sizeBytes: file.sizeBytes ?? null,
|
|
145145
145162
|
indexedAt: file.indexedAt,
|
|
145146
|
-
gitCommit: file.gitCommit ?? null
|
|
145163
|
+
gitCommit: file.gitCommit ?? null,
|
|
145164
|
+
source: file.source ?? null,
|
|
145165
|
+
parserError: file.parserError ?? null
|
|
145147
145166
|
});
|
|
145148
145167
|
}
|
|
145149
145168
|
});
|
|
@@ -145153,9 +145172,9 @@ var init_store = __esm({
|
|
|
145153
145172
|
if (symbols.length === 0) return;
|
|
145154
145173
|
const stmt = this.db.prepare(`
|
|
145155
145174
|
INSERT OR REPLACE INTO code_symbols
|
|
145156
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145175
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145157
145176
|
VALUES
|
|
145158
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145177
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145159
145178
|
`);
|
|
145160
145179
|
const tx = this.db.transaction((items) => {
|
|
145161
145180
|
for (const symbol of items) {
|
|
@@ -145172,7 +145191,8 @@ var init_store = __esm({
|
|
|
145172
145191
|
signature: symbol.signature ?? null,
|
|
145173
145192
|
contentHash: symbol.contentHash ?? null,
|
|
145174
145193
|
indexedAt: symbol.indexedAt,
|
|
145175
|
-
stale: symbol.stale ? 1 : 0
|
|
145194
|
+
stale: symbol.stale ? 1 : 0,
|
|
145195
|
+
source: symbol.source ?? null
|
|
145176
145196
|
});
|
|
145177
145197
|
}
|
|
145178
145198
|
});
|
|
@@ -145182,9 +145202,9 @@ var init_store = __esm({
|
|
|
145182
145202
|
if (edges.length === 0) return;
|
|
145183
145203
|
const stmt = this.db.prepare(`
|
|
145184
145204
|
INSERT OR REPLACE INTO code_edges
|
|
145185
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145205
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145186
145206
|
VALUES
|
|
145187
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145207
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145188
145208
|
`);
|
|
145189
145209
|
const tx = this.db.transaction((items) => {
|
|
145190
145210
|
for (const edge of items) {
|
|
@@ -145198,7 +145218,8 @@ var init_store = __esm({
|
|
|
145198
145218
|
type: edge.type,
|
|
145199
145219
|
confidence: edge.confidence,
|
|
145200
145220
|
evidence: edge.evidence ?? null,
|
|
145201
|
-
indexedAt: edge.indexedAt
|
|
145221
|
+
indexedAt: edge.indexedAt,
|
|
145222
|
+
source: edge.source ?? null
|
|
145202
145223
|
});
|
|
145203
145224
|
}
|
|
145204
145225
|
});
|
|
@@ -145210,21 +145231,21 @@ var init_store = __esm({
|
|
|
145210
145231
|
const deleteFiles = this.db.prepare(`DELETE FROM code_files WHERE projectId = ?`);
|
|
145211
145232
|
const insertFile = this.db.prepare(`
|
|
145212
145233
|
INSERT OR REPLACE INTO code_files
|
|
145213
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145234
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
145214
145235
|
VALUES
|
|
145215
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145236
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
145216
145237
|
`);
|
|
145217
145238
|
const insertSymbol = this.db.prepare(`
|
|
145218
145239
|
INSERT OR REPLACE INTO code_symbols
|
|
145219
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145240
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145220
145241
|
VALUES
|
|
145221
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145242
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145222
145243
|
`);
|
|
145223
145244
|
const insertEdge = this.db.prepare(`
|
|
145224
145245
|
INSERT OR REPLACE INTO code_edges
|
|
145225
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145246
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145226
145247
|
VALUES
|
|
145227
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145248
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145228
145249
|
`);
|
|
145229
145250
|
const tx = this.db.transaction(() => {
|
|
145230
145251
|
deleteEdges.run(projectId);
|
|
@@ -145240,7 +145261,9 @@ var init_store = __esm({
|
|
|
145240
145261
|
mtimeMs: file.mtimeMs ?? null,
|
|
145241
145262
|
sizeBytes: file.sizeBytes ?? null,
|
|
145242
145263
|
indexedAt: file.indexedAt,
|
|
145243
|
-
gitCommit: file.gitCommit ?? null
|
|
145264
|
+
gitCommit: file.gitCommit ?? null,
|
|
145265
|
+
source: file.source ?? null,
|
|
145266
|
+
parserError: file.parserError ?? null
|
|
145244
145267
|
});
|
|
145245
145268
|
}
|
|
145246
145269
|
for (const symbol of index.symbols) {
|
|
@@ -145257,7 +145280,8 @@ var init_store = __esm({
|
|
|
145257
145280
|
signature: symbol.signature ?? null,
|
|
145258
145281
|
contentHash: symbol.contentHash ?? null,
|
|
145259
145282
|
indexedAt: symbol.indexedAt,
|
|
145260
|
-
stale: 0
|
|
145283
|
+
stale: 0,
|
|
145284
|
+
source: symbol.source ?? null
|
|
145261
145285
|
});
|
|
145262
145286
|
}
|
|
145263
145287
|
for (const edge of index.edges) {
|
|
@@ -145271,7 +145295,8 @@ var init_store = __esm({
|
|
|
145271
145295
|
type: edge.type,
|
|
145272
145296
|
confidence: edge.confidence,
|
|
145273
145297
|
evidence: edge.evidence ?? null,
|
|
145274
|
-
indexedAt: edge.indexedAt
|
|
145298
|
+
indexedAt: edge.indexedAt,
|
|
145299
|
+
source: edge.source ?? null
|
|
145275
145300
|
});
|
|
145276
145301
|
}
|
|
145277
145302
|
});
|
|
@@ -145316,21 +145341,21 @@ var init_store = __esm({
|
|
|
145316
145341
|
const deleteFile = this.db.prepare(`DELETE FROM code_files WHERE projectId = ? AND id = ?`);
|
|
145317
145342
|
const upsertFile = this.db.prepare(`
|
|
145318
145343
|
INSERT OR REPLACE INTO code_files
|
|
145319
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145344
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
145320
145345
|
VALUES
|
|
145321
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145346
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
145322
145347
|
`);
|
|
145323
145348
|
const upsertSymbol = this.db.prepare(`
|
|
145324
145349
|
INSERT OR REPLACE INTO code_symbols
|
|
145325
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145350
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145326
145351
|
VALUES
|
|
145327
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145352
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145328
145353
|
`);
|
|
145329
145354
|
const upsertEdge = this.db.prepare(`
|
|
145330
145355
|
INSERT OR REPLACE INTO code_edges
|
|
145331
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145356
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145332
145357
|
VALUES
|
|
145333
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145358
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145334
145359
|
`);
|
|
145335
145360
|
const writeFile5 = (file) => upsertFile.run({
|
|
145336
145361
|
id: file.id,
|
|
@@ -145341,7 +145366,9 @@ var init_store = __esm({
|
|
|
145341
145366
|
mtimeMs: file.mtimeMs ?? null,
|
|
145342
145367
|
sizeBytes: file.sizeBytes ?? null,
|
|
145343
145368
|
indexedAt: file.indexedAt,
|
|
145344
|
-
gitCommit: file.gitCommit ?? null
|
|
145369
|
+
gitCommit: file.gitCommit ?? null,
|
|
145370
|
+
source: file.source ?? null,
|
|
145371
|
+
parserError: file.parserError ?? null
|
|
145345
145372
|
});
|
|
145346
145373
|
const tx = this.db.transaction(() => {
|
|
145347
145374
|
const staleAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -145375,7 +145402,8 @@ var init_store = __esm({
|
|
|
145375
145402
|
signature: symbol.signature ?? null,
|
|
145376
145403
|
contentHash: symbol.contentHash ?? null,
|
|
145377
145404
|
indexedAt: symbol.indexedAt,
|
|
145378
|
-
stale: symbol.stale ? 1 : 0
|
|
145405
|
+
stale: symbol.stale ? 1 : 0,
|
|
145406
|
+
source: symbol.source ?? null
|
|
145379
145407
|
});
|
|
145380
145408
|
}
|
|
145381
145409
|
for (const edge of delta.edges) {
|
|
@@ -145389,7 +145417,8 @@ var init_store = __esm({
|
|
|
145389
145417
|
type: edge.type,
|
|
145390
145418
|
confidence: edge.confidence,
|
|
145391
145419
|
evidence: edge.evidence ?? null,
|
|
145392
|
-
indexedAt: edge.indexedAt
|
|
145420
|
+
indexedAt: edge.indexedAt,
|
|
145421
|
+
source: edge.source ?? null
|
|
145393
145422
|
});
|
|
145394
145423
|
}
|
|
145395
145424
|
}
|
|
@@ -145537,6 +145566,202 @@ var init_store = __esm({
|
|
|
145537
145566
|
listEdges(projectId) {
|
|
145538
145567
|
return this.db.prepare(`SELECT * FROM code_edges WHERE projectId = ? ORDER BY type, id`).all(projectId).map(rowToEdge);
|
|
145539
145568
|
}
|
|
145569
|
+
/** Return direct importers before a refresh clears their old target IDs. */
|
|
145570
|
+
listImportDependentPaths(projectId, paths, candidatePaths = []) {
|
|
145571
|
+
const normalized = [...new Set(paths.map(normalizeCodePath).filter(Boolean))];
|
|
145572
|
+
if (normalized.length === 0) return [];
|
|
145573
|
+
const files = this.listFiles(projectId);
|
|
145574
|
+
const fileIds = files.filter((file) => normalized.includes(file.path)).map((file) => file.id);
|
|
145575
|
+
const fileById = new Map(files.map((file) => [file.id, file]));
|
|
145576
|
+
const fileByPath = new Map(files.map((file) => [file.path, file]));
|
|
145577
|
+
for (const path22 of candidatePaths.map(normalizeCodePath).filter(Boolean)) {
|
|
145578
|
+
if (!fileByPath.has(path22)) {
|
|
145579
|
+
fileByPath.set(path22, {
|
|
145580
|
+
id: `candidate:${path22}`,
|
|
145581
|
+
projectId,
|
|
145582
|
+
path: path22,
|
|
145583
|
+
contentHash: "",
|
|
145584
|
+
indexedAt: ""
|
|
145585
|
+
});
|
|
145586
|
+
}
|
|
145587
|
+
}
|
|
145588
|
+
const rows = this.db.prepare(`
|
|
145589
|
+
SELECT DISTINCT fromFileId, evidence
|
|
145590
|
+
FROM code_edges
|
|
145591
|
+
WHERE projectId = ? AND type = 'imports'
|
|
145592
|
+
`).all(projectId);
|
|
145593
|
+
const wanted = new Set(normalized);
|
|
145594
|
+
const dependents = /* @__PURE__ */ new Set();
|
|
145595
|
+
const queue = [...normalized];
|
|
145596
|
+
while (queue.length > 0) {
|
|
145597
|
+
const targetPath = queue.shift();
|
|
145598
|
+
for (const row of rows) {
|
|
145599
|
+
const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
|
|
145600
|
+
if (!source || source.path === targetPath || dependents.has(source.path)) continue;
|
|
145601
|
+
const target = resolveRelativeImportTarget(source.path, row.evidence, fileByPath);
|
|
145602
|
+
if (!target || !wanted.has(target.path)) continue;
|
|
145603
|
+
dependents.add(source.path);
|
|
145604
|
+
if (!wanted.has(source.path)) {
|
|
145605
|
+
wanted.add(source.path);
|
|
145606
|
+
queue.push(source.path);
|
|
145607
|
+
}
|
|
145608
|
+
}
|
|
145609
|
+
}
|
|
145610
|
+
if (fileIds.length > 0) {
|
|
145611
|
+
const placeholders = fileIds.map(() => "?").join(", ");
|
|
145612
|
+
const exactRows = this.db.prepare(`
|
|
145613
|
+
SELECT DISTINCT fromFileId
|
|
145614
|
+
FROM code_edges
|
|
145615
|
+
WHERE projectId = ? AND type = 'imports' AND toFileId IN (${placeholders})
|
|
145616
|
+
`).all(projectId, ...fileIds);
|
|
145617
|
+
for (const row of exactRows) {
|
|
145618
|
+
const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
|
|
145619
|
+
if (source) dependents.add(source.path);
|
|
145620
|
+
}
|
|
145621
|
+
}
|
|
145622
|
+
return [...dependents].sort();
|
|
145623
|
+
}
|
|
145624
|
+
/** Replace only the semantic slice touched by a change, in one transaction. */
|
|
145625
|
+
replaceSemanticSlice(projectId, affectedPaths, input) {
|
|
145626
|
+
const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
|
|
145627
|
+
if (normalizedPaths.length === 0) return;
|
|
145628
|
+
const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
|
|
145629
|
+
const fileIds = fileRows.map((file) => file.id);
|
|
145630
|
+
const placeholders = fileIds.map(() => "?").join(", ");
|
|
145631
|
+
if (fileIds.length === 0) return;
|
|
145632
|
+
const staleRefs = this.db.prepare(`
|
|
145633
|
+
UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
|
|
145634
|
+
WHERE projectId = ? AND (fileId IN (${placeholders}) OR symbolId IN (
|
|
145635
|
+
SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})
|
|
145636
|
+
))
|
|
145637
|
+
`);
|
|
145638
|
+
const deleteEdges = this.db.prepare(`
|
|
145639
|
+
DELETE FROM code_edges
|
|
145640
|
+
WHERE projectId = ? AND (source IS NULL OR source IN ('lite-regex', 'typescript-compiler'))
|
|
145641
|
+
AND (fromFileId IN (${placeholders}) OR toFileId IN (${placeholders})
|
|
145642
|
+
OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders}))
|
|
145643
|
+
OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})))
|
|
145644
|
+
`);
|
|
145645
|
+
const deleteSymbols = this.db.prepare(`DELETE FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})`);
|
|
145646
|
+
const updateFile = this.db.prepare("UPDATE code_files SET source = ?, parserError = ? WHERE projectId = ? AND id = ?");
|
|
145647
|
+
const insertSymbol = this.db.prepare(`
|
|
145648
|
+
INSERT OR REPLACE INTO code_symbols
|
|
145649
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145650
|
+
VALUES
|
|
145651
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145652
|
+
`);
|
|
145653
|
+
const insertEdge = this.db.prepare(`
|
|
145654
|
+
INSERT OR REPLACE INTO code_edges
|
|
145655
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145656
|
+
VALUES
|
|
145657
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145658
|
+
`);
|
|
145659
|
+
const diagnosticsByPath = new Map((input.diagnostics ?? []).map((item) => [normalizeCodePath(item.path), item.message]));
|
|
145660
|
+
const symbolFileIds = new Set(fileIds);
|
|
145661
|
+
const tx = this.db.transaction(() => {
|
|
145662
|
+
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
145663
|
+
staleRefs.run(now3, projectId, ...fileIds, projectId, ...fileIds);
|
|
145664
|
+
deleteEdges.run(projectId, ...fileIds, ...fileIds, projectId, ...fileIds, projectId, ...fileIds);
|
|
145665
|
+
deleteSymbols.run(projectId, ...fileIds);
|
|
145666
|
+
for (const file of fileRows) {
|
|
145667
|
+
const diagnostic = diagnosticsByPath.get(file.path);
|
|
145668
|
+
updateFile.run(diagnostic ? "typescript-compiler" : "typescript-compiler", diagnostic ?? null, projectId, file.id);
|
|
145669
|
+
}
|
|
145670
|
+
for (const symbol of input.symbols.filter((symbol2) => symbolFileIds.has(symbol2.fileId))) {
|
|
145671
|
+
insertSymbol.run({
|
|
145672
|
+
id: symbol.id,
|
|
145673
|
+
projectId: symbol.projectId,
|
|
145674
|
+
fileId: symbol.fileId,
|
|
145675
|
+
path: normalizeCodePath(symbol.path),
|
|
145676
|
+
name: symbol.name,
|
|
145677
|
+
qualifiedName: symbol.qualifiedName,
|
|
145678
|
+
kind: symbol.kind,
|
|
145679
|
+
startLine: symbol.startLine ?? null,
|
|
145680
|
+
endLine: symbol.endLine ?? null,
|
|
145681
|
+
signature: symbol.signature ?? null,
|
|
145682
|
+
contentHash: symbol.contentHash ?? null,
|
|
145683
|
+
indexedAt: symbol.indexedAt,
|
|
145684
|
+
stale: symbol.stale ? 1 : 0,
|
|
145685
|
+
source: symbol.source ?? "typescript-compiler"
|
|
145686
|
+
});
|
|
145687
|
+
}
|
|
145688
|
+
for (const edge of input.edges) {
|
|
145689
|
+
insertEdge.run({
|
|
145690
|
+
id: edge.id,
|
|
145691
|
+
projectId: edge.projectId,
|
|
145692
|
+
fromSymbolId: edge.fromSymbolId ?? null,
|
|
145693
|
+
toSymbolId: edge.toSymbolId ?? null,
|
|
145694
|
+
fromFileId: edge.fromFileId ?? null,
|
|
145695
|
+
toFileId: edge.toFileId ?? null,
|
|
145696
|
+
type: edge.type,
|
|
145697
|
+
confidence: edge.confidence,
|
|
145698
|
+
evidence: edge.evidence ?? null,
|
|
145699
|
+
indexedAt: edge.indexedAt,
|
|
145700
|
+
source: edge.source ?? "typescript-compiler"
|
|
145701
|
+
});
|
|
145702
|
+
}
|
|
145703
|
+
});
|
|
145704
|
+
tx();
|
|
145705
|
+
}
|
|
145706
|
+
/** Record a semantic refresh failure without presenting the old facts as current. */
|
|
145707
|
+
markSemanticSliceFailed(projectId, affectedPaths, message) {
|
|
145708
|
+
const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
|
|
145709
|
+
const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
|
|
145710
|
+
const fileIds = fileRows.map((file) => file.id);
|
|
145711
|
+
const filePlaceholders = fileIds.map(() => "?").join(", ");
|
|
145712
|
+
const staleRefs = fileIds.length > 0 ? this.db.prepare(`
|
|
145713
|
+
UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
|
|
145714
|
+
WHERE projectId = ? AND (fileId IN (${filePlaceholders}) OR symbolId IN (
|
|
145715
|
+
SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders})
|
|
145716
|
+
))
|
|
145717
|
+
`) : void 0;
|
|
145718
|
+
const staleSymbols = fileIds.length > 0 ? this.db.prepare(`
|
|
145719
|
+
UPDATE code_symbols SET stale = 1
|
|
145720
|
+
WHERE projectId = ? AND source = 'typescript-compiler' AND fileId IN (${filePlaceholders})
|
|
145721
|
+
`) : void 0;
|
|
145722
|
+
const updateFiles = fileIds.length > 0 ? this.db.prepare(`
|
|
145723
|
+
UPDATE code_files SET parserError = ?
|
|
145724
|
+
WHERE projectId = ? AND id IN (${filePlaceholders})
|
|
145725
|
+
`) : void 0;
|
|
145726
|
+
const affectedEdgeClause = fileIds.length > 0 ? `
|
|
145727
|
+
OR fromFileId IN (${filePlaceholders})
|
|
145728
|
+
OR toFileId IN (${filePlaceholders})
|
|
145729
|
+
OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
|
|
145730
|
+
OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
|
|
145731
|
+
` : "";
|
|
145732
|
+
const deleteEdges = this.db.prepare(`
|
|
145733
|
+
DELETE FROM code_edges
|
|
145734
|
+
WHERE projectId = ? AND source = 'typescript-compiler'
|
|
145735
|
+
AND (
|
|
145736
|
+
(fromSymbolId IS NOT NULL AND NOT EXISTS (
|
|
145737
|
+
SELECT 1 FROM code_symbols WHERE projectId = ? AND id = fromSymbolId
|
|
145738
|
+
))
|
|
145739
|
+
OR (toSymbolId IS NOT NULL AND NOT EXISTS (
|
|
145740
|
+
SELECT 1 FROM code_symbols WHERE projectId = ? AND id = toSymbolId
|
|
145741
|
+
))
|
|
145742
|
+
${affectedEdgeClause}
|
|
145743
|
+
)
|
|
145744
|
+
`);
|
|
145745
|
+
const tx = this.db.transaction(() => {
|
|
145746
|
+
const failure = `semantic indexing failed: ${message.slice(0, 500)}`;
|
|
145747
|
+
if (updateFiles) updateFiles.run(failure, projectId, ...fileIds);
|
|
145748
|
+
if (staleRefs) staleRefs.run((/* @__PURE__ */ new Date()).toISOString(), projectId, ...fileIds, projectId, ...fileIds);
|
|
145749
|
+
if (staleSymbols) staleSymbols.run(projectId, ...fileIds);
|
|
145750
|
+
const edgeParams = [projectId, projectId, projectId];
|
|
145751
|
+
if (fileIds.length > 0) {
|
|
145752
|
+
edgeParams.push(
|
|
145753
|
+
...fileIds,
|
|
145754
|
+
...fileIds,
|
|
145755
|
+
projectId,
|
|
145756
|
+
...fileIds,
|
|
145757
|
+
projectId,
|
|
145758
|
+
...fileIds
|
|
145759
|
+
);
|
|
145760
|
+
}
|
|
145761
|
+
deleteEdges.run(...edgeParams);
|
|
145762
|
+
});
|
|
145763
|
+
tx();
|
|
145764
|
+
}
|
|
145540
145765
|
listObservationRefs(projectId, observationId2) {
|
|
145541
145766
|
return this.db.prepare(`
|
|
145542
145767
|
SELECT * FROM observation_code_refs
|
|
@@ -145738,6 +145963,9 @@ var init_store = __esm({
|
|
|
145738
145963
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
145739
145964
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
145740
145965
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
145966
|
+
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
145967
|
+
const semanticEdges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ? AND source = 'typescript-compiler'`).get(projectId).count;
|
|
145968
|
+
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
145741
145969
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
145742
145970
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
145743
145971
|
return {
|
|
@@ -145746,6 +145974,9 @@ var init_store = __esm({
|
|
|
145746
145974
|
symbols,
|
|
145747
145975
|
edges,
|
|
145748
145976
|
refs,
|
|
145977
|
+
semanticSymbols,
|
|
145978
|
+
semanticEdges,
|
|
145979
|
+
parserErrors,
|
|
145749
145980
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
145750
145981
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
145751
145982
|
};
|
|
@@ -145878,6 +146109,350 @@ var init_exclude3 = __esm({
|
|
|
145878
146109
|
}
|
|
145879
146110
|
});
|
|
145880
146111
|
|
|
146112
|
+
// src/codegraph/semantic-provider.ts
|
|
146113
|
+
import { createHash as createHash8 } from "crypto";
|
|
146114
|
+
import "fs";
|
|
146115
|
+
import { resolve } from "path";
|
|
146116
|
+
import ts from "typescript";
|
|
146117
|
+
function hashText(value) {
|
|
146118
|
+
return createHash8("sha256").update(value).digest("hex");
|
|
146119
|
+
}
|
|
146120
|
+
function canonicalPath(value) {
|
|
146121
|
+
const normalized = resolve(value).replace(/\\/g, "/");
|
|
146122
|
+
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
146123
|
+
}
|
|
146124
|
+
function isInside(root, candidate) {
|
|
146125
|
+
const rootPath = canonicalPath(root).replace(/\/$/, "");
|
|
146126
|
+
const candidatePath = canonicalPath(candidate);
|
|
146127
|
+
return candidatePath === rootPath || candidatePath.startsWith(`${rootPath}/`);
|
|
146128
|
+
}
|
|
146129
|
+
function scriptKind(path22) {
|
|
146130
|
+
if (path22.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
146131
|
+
if (path22.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
146132
|
+
if (path22.endsWith(".json")) return ts.ScriptKind.JSON;
|
|
146133
|
+
if (path22.endsWith(".js") || path22.endsWith(".mjs") || path22.endsWith(".cjs")) return ts.ScriptKind.JS;
|
|
146134
|
+
return ts.ScriptKind.TS;
|
|
146135
|
+
}
|
|
146136
|
+
function isTestPath(path22) {
|
|
146137
|
+
return /(^|[/\\])__tests__([/\\])|(?:\.test|\.spec)\.[^.]+$/i.test(path22);
|
|
146138
|
+
}
|
|
146139
|
+
function declarationName(node) {
|
|
146140
|
+
const named = node;
|
|
146141
|
+
const name = named.name;
|
|
146142
|
+
return name && ts.isIdentifier(name) ? name.text : void 0;
|
|
146143
|
+
}
|
|
146144
|
+
function symbolKind(node) {
|
|
146145
|
+
if (ts.isFunctionDeclaration(node)) return "function";
|
|
146146
|
+
if (ts.isClassDeclaration(node)) return "class";
|
|
146147
|
+
if (ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isConstructorDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)) return "method";
|
|
146148
|
+
if (ts.isInterfaceDeclaration(node)) return "interface";
|
|
146149
|
+
if (ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) return "type";
|
|
146150
|
+
if (ts.isEnumMember(node)) return "constant";
|
|
146151
|
+
if (ts.isPropertyDeclaration(node) || ts.isPropertySignature(node)) return "property";
|
|
146152
|
+
if (ts.isVariableDeclaration(node)) return node.initializer && (ts.isFunctionExpression(node.initializer) || ts.isArrowFunction(node.initializer)) ? "function" : "constant";
|
|
146153
|
+
return void 0;
|
|
146154
|
+
}
|
|
146155
|
+
function isDeclarationNode(node) {
|
|
146156
|
+
return Boolean(symbolKind(node) && declarationName(node));
|
|
146157
|
+
}
|
|
146158
|
+
function qualifiedName(node, name, ordinalByKey) {
|
|
146159
|
+
const parts = [name];
|
|
146160
|
+
let parent = node.parent;
|
|
146161
|
+
while (parent && !ts.isSourceFile(parent)) {
|
|
146162
|
+
if (isDeclarationNode(parent)) {
|
|
146163
|
+
const parentName = declarationName(parent);
|
|
146164
|
+
if (parentName) parts.unshift(parentName);
|
|
146165
|
+
}
|
|
146166
|
+
parent = parent.parent;
|
|
146167
|
+
}
|
|
146168
|
+
const base = parts.join("::");
|
|
146169
|
+
const key = `${base}
|
|
146170
|
+
${symbolKind(node)}`;
|
|
146171
|
+
const ordinal = ordinalByKey.get(key) ?? 0;
|
|
146172
|
+
ordinalByKey.set(key, ordinal + 1);
|
|
146173
|
+
return ordinal === 0 ? base : `${base}#${ordinal + 1}`;
|
|
146174
|
+
}
|
|
146175
|
+
function lineAt(sourceFile, position) {
|
|
146176
|
+
return sourceFile.getLineAndCharacterOfPosition(position).line + 1;
|
|
146177
|
+
}
|
|
146178
|
+
function signatureFor(checker, node, sourceFile) {
|
|
146179
|
+
const signature = ts.isFunctionLike(node) ? checker.getSignatureFromDeclaration(node) : void 0;
|
|
146180
|
+
if (signature) {
|
|
146181
|
+
try {
|
|
146182
|
+
return checker.signatureToString(signature, node, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope).slice(0, 240);
|
|
146183
|
+
} catch {
|
|
146184
|
+
}
|
|
146185
|
+
}
|
|
146186
|
+
const text2 = sourceFile.text.slice(node.getStart(sourceFile), Math.min(node.end, node.getStart(sourceFile) + 240));
|
|
146187
|
+
return text2.replace(/\s+/g, " ").trim() || void 0;
|
|
146188
|
+
}
|
|
146189
|
+
function makeCompilerOptions(projectRoot) {
|
|
146190
|
+
const configPath = ts.findConfigFile(projectRoot, ts.sys.fileExists, "tsconfig.json");
|
|
146191
|
+
let options = {
|
|
146192
|
+
allowJs: true,
|
|
146193
|
+
checkJs: false,
|
|
146194
|
+
noEmit: true,
|
|
146195
|
+
noLib: true,
|
|
146196
|
+
skipLibCheck: true,
|
|
146197
|
+
module: ts.ModuleKind.ESNext,
|
|
146198
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
146199
|
+
target: ts.ScriptTarget.ES2022,
|
|
146200
|
+
jsx: ts.JsxEmit.Preserve,
|
|
146201
|
+
types: []
|
|
146202
|
+
};
|
|
146203
|
+
if (configPath) {
|
|
146204
|
+
try {
|
|
146205
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
146206
|
+
if (!config.error) {
|
|
146207
|
+
const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, projectRoot);
|
|
146208
|
+
options = { ...options, ...parsed.options, noEmit: true, noLib: true, skipLibCheck: true, allowJs: true, checkJs: false, types: [] };
|
|
146209
|
+
}
|
|
146210
|
+
} catch {
|
|
146211
|
+
}
|
|
146212
|
+
}
|
|
146213
|
+
return options;
|
|
146214
|
+
}
|
|
146215
|
+
function resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedFileName) {
|
|
146216
|
+
if (!resolvedFileName || !isInside(projectRoot, resolvedFileName)) return void 0;
|
|
146217
|
+
return filesByCanonicalPath.get(canonicalPath(resolvedFileName));
|
|
146218
|
+
}
|
|
146219
|
+
function isSemanticLanguage(language) {
|
|
146220
|
+
return Boolean(language && SUPPORTED_LANGUAGES.has(language));
|
|
146221
|
+
}
|
|
146222
|
+
function buildTypeScriptSemanticIndex(input) {
|
|
146223
|
+
const started = Date.now();
|
|
146224
|
+
const semanticFiles = input.files.filter((file) => isSemanticLanguage(file.language) && !isCodeGraphExcludedPath(file.path, input.exclude));
|
|
146225
|
+
if (semanticFiles.length === 0) {
|
|
146226
|
+
return { symbols: [], edges: [], parsedFiles: 0, parserErrors: 0, unresolvedCalls: 0, durationMs: Date.now() - started, diagnostics: [] };
|
|
146227
|
+
}
|
|
146228
|
+
const projectRoot = resolve(input.projectRoot);
|
|
146229
|
+
const filesByCanonicalPath = new Map(semanticFiles.map((file) => [canonicalPath(resolve(projectRoot, file.path)), file]));
|
|
146230
|
+
const includePaths = input.includePaths ? new Set(input.includePaths.map(normalizeCodePath)) : void 0;
|
|
146231
|
+
const includedFileIds = new Set(
|
|
146232
|
+
semanticFiles.filter((file) => !includePaths || includePaths.has(normalizeCodePath(file.path))).map((file) => file.id)
|
|
146233
|
+
);
|
|
146234
|
+
const rootNames = semanticFiles.map((file) => resolve(projectRoot, file.path));
|
|
146235
|
+
const baseHost = ts.createCompilerHost(makeCompilerOptions(projectRoot), true);
|
|
146236
|
+
const compilerOptions = makeCompilerOptions(projectRoot);
|
|
146237
|
+
const host = {
|
|
146238
|
+
...baseHost,
|
|
146239
|
+
getCurrentDirectory: () => projectRoot,
|
|
146240
|
+
fileExists: (fileName) => isInside(projectRoot, fileName) && baseHost.fileExists(fileName),
|
|
146241
|
+
readFile: (fileName) => isInside(projectRoot, fileName) ? baseHost.readFile(fileName) : void 0,
|
|
146242
|
+
realpath: (fileName) => fileName,
|
|
146243
|
+
getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
|
|
146244
|
+
if (!isInside(projectRoot, fileName)) return void 0;
|
|
146245
|
+
const text2 = baseHost.readFile(fileName);
|
|
146246
|
+
if (text2 === void 0) return void 0;
|
|
146247
|
+
return ts.createSourceFile(fileName, text2, languageVersion, true, scriptKind(fileName));
|
|
146248
|
+
}
|
|
146249
|
+
};
|
|
146250
|
+
const program = ts.createProgram({ rootNames, options: compilerOptions, host });
|
|
146251
|
+
const checker = program.getTypeChecker();
|
|
146252
|
+
const symbols = [];
|
|
146253
|
+
const allSymbols = [];
|
|
146254
|
+
const declarationToRecord = /* @__PURE__ */ new Map();
|
|
146255
|
+
const checkerToRecord = /* @__PURE__ */ new Map();
|
|
146256
|
+
const declarationNameNodes = /* @__PURE__ */ new Set();
|
|
146257
|
+
const ordinalByKey = /* @__PURE__ */ new Map();
|
|
146258
|
+
const sourceFiles = program.getSourceFiles().filter((sourceFile) => filesByCanonicalPath.has(canonicalPath(sourceFile.fileName)));
|
|
146259
|
+
for (const sourceFile of sourceFiles) {
|
|
146260
|
+
const file = filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
|
|
146261
|
+
if (!file) continue;
|
|
146262
|
+
const visitDeclarations = (node) => {
|
|
146263
|
+
if (isDeclarationNode(node)) {
|
|
146264
|
+
const name = declarationName(node);
|
|
146265
|
+
const kind = symbolKind(node);
|
|
146266
|
+
if (name && kind) {
|
|
146267
|
+
const qName = qualifiedName(node, name, ordinalByKey);
|
|
146268
|
+
const start = node.getStart(sourceFile);
|
|
146269
|
+
const symbol = {
|
|
146270
|
+
id: makeCodeSymbolId({ projectId: input.projectId, path: file.path, qualifiedName: qName, kind }),
|
|
146271
|
+
projectId: input.projectId,
|
|
146272
|
+
fileId: file.id || makeCodeFileId(input.projectId, file.path),
|
|
146273
|
+
path: file.path,
|
|
146274
|
+
name,
|
|
146275
|
+
qualifiedName: qName,
|
|
146276
|
+
kind,
|
|
146277
|
+
startLine: lineAt(sourceFile, start),
|
|
146278
|
+
endLine: lineAt(sourceFile, node.end),
|
|
146279
|
+
signature: signatureFor(checker, node, sourceFile),
|
|
146280
|
+
contentHash: hashText(sourceFile.text.slice(start, node.end)),
|
|
146281
|
+
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
146282
|
+
source: SEMANTIC_SOURCE
|
|
146283
|
+
};
|
|
146284
|
+
const namedNode = node;
|
|
146285
|
+
const checkerSymbol = namedNode.name ? checker.getSymbolAtLocation(namedNode.name) : void 0;
|
|
146286
|
+
const record80 = { node, symbol, ...checkerSymbol ? { checkerSymbol } : {} };
|
|
146287
|
+
allSymbols.push(symbol);
|
|
146288
|
+
if (!includePaths || includePaths.has(normalizeCodePath(file.path))) symbols.push(symbol);
|
|
146289
|
+
declarationToRecord.set(node, record80);
|
|
146290
|
+
if (checkerSymbol) {
|
|
146291
|
+
checkerToRecord.set(checkerSymbol, record80);
|
|
146292
|
+
for (const declaration of checkerSymbol.declarations ?? []) declarationToRecord.set(declaration, record80);
|
|
146293
|
+
}
|
|
146294
|
+
if (namedNode.name) declarationNameNodes.add(namedNode.name);
|
|
146295
|
+
}
|
|
146296
|
+
}
|
|
146297
|
+
node.forEachChild(visitDeclarations);
|
|
146298
|
+
};
|
|
146299
|
+
visitDeclarations(sourceFile);
|
|
146300
|
+
}
|
|
146301
|
+
const edges = /* @__PURE__ */ new Map();
|
|
146302
|
+
const addEdge = (inputEdge) => {
|
|
146303
|
+
const from = inputEdge.fromSymbolId ?? inputEdge.fromFileId ?? "";
|
|
146304
|
+
const to = inputEdge.toSymbolId ?? inputEdge.toFileId ?? (inputEdge.type === "imports" && inputEdge.evidence ? `unresolved:${inputEdge.evidence}` : "");
|
|
146305
|
+
if (!from || !to) return;
|
|
146306
|
+
if (includePaths) {
|
|
146307
|
+
const endpointFileIds = /* @__PURE__ */ new Set();
|
|
146308
|
+
if (inputEdge.fromFileId) endpointFileIds.add(inputEdge.fromFileId);
|
|
146309
|
+
if (inputEdge.toFileId) endpointFileIds.add(inputEdge.toFileId);
|
|
146310
|
+
for (const symbol of allSymbols) {
|
|
146311
|
+
if (symbol.id === inputEdge.fromSymbolId || symbol.id === inputEdge.toSymbolId) endpointFileIds.add(symbol.fileId);
|
|
146312
|
+
}
|
|
146313
|
+
if (![...endpointFileIds].some((fileId) => includedFileIds.has(fileId))) return;
|
|
146314
|
+
}
|
|
146315
|
+
const id = makeCodeEdgeId(input.projectId, from, inputEdge.type, to);
|
|
146316
|
+
if (edges.has(id)) return;
|
|
146317
|
+
edges.set(id, {
|
|
146318
|
+
...inputEdge,
|
|
146319
|
+
id,
|
|
146320
|
+
projectId: input.projectId,
|
|
146321
|
+
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
146322
|
+
source: SEMANTIC_SOURCE
|
|
146323
|
+
});
|
|
146324
|
+
};
|
|
146325
|
+
const resolveRecord = (symbol) => {
|
|
146326
|
+
if (!symbol) return void 0;
|
|
146327
|
+
let target = symbol;
|
|
146328
|
+
if (target.flags & ts.SymbolFlags.Alias) {
|
|
146329
|
+
try {
|
|
146330
|
+
target = checker.getAliasedSymbol(target);
|
|
146331
|
+
} catch {
|
|
146332
|
+
}
|
|
146333
|
+
}
|
|
146334
|
+
return checkerToRecord.get(target) ?? (target.declarations ?? []).map((declaration) => declarationToRecord.get(declaration)).find(Boolean);
|
|
146335
|
+
};
|
|
146336
|
+
const currentRecord = (node) => {
|
|
146337
|
+
let parent = node;
|
|
146338
|
+
while (parent) {
|
|
146339
|
+
const record80 = declarationToRecord.get(parent);
|
|
146340
|
+
if (record80) return record80;
|
|
146341
|
+
parent = parent.parent;
|
|
146342
|
+
}
|
|
146343
|
+
return void 0;
|
|
146344
|
+
};
|
|
146345
|
+
const fileForSource = (sourceFile) => filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
|
|
146346
|
+
const addFileRelation = (sourceFile, target, type, node, evidence) => {
|
|
146347
|
+
const source = fileForSource(sourceFile);
|
|
146348
|
+
if (!source || source.id === target?.id) return;
|
|
146349
|
+
addEdge({
|
|
146350
|
+
fromFileId: source.id,
|
|
146351
|
+
...target ? { toFileId: target.id } : {},
|
|
146352
|
+
type,
|
|
146353
|
+
confidence: target ? 0.99 : 0.55,
|
|
146354
|
+
evidence: evidence ?? `${type} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146355
|
+
});
|
|
146356
|
+
};
|
|
146357
|
+
const moduleTarget = (sourceFile, moduleName) => {
|
|
146358
|
+
const resolvedModule = ts.resolveModuleName(moduleName, sourceFile.fileName, compilerOptions, host).resolvedModule;
|
|
146359
|
+
return resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedModule?.resolvedFileName);
|
|
146360
|
+
};
|
|
146361
|
+
let unresolvedCalls = 0;
|
|
146362
|
+
for (const sourceFile of sourceFiles) {
|
|
146363
|
+
const file = fileForSource(sourceFile);
|
|
146364
|
+
if (!file) continue;
|
|
146365
|
+
const visit = (node) => {
|
|
146366
|
+
const owner = currentRecord(node);
|
|
146367
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
146368
|
+
addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "imports", node, `imports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
|
|
146369
|
+
} else if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
146370
|
+
addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "exports", node, `exports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
|
|
146371
|
+
} else if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
146372
|
+
const signature = checker.getResolvedSignature(node);
|
|
146373
|
+
const declarationNameNode = signature?.declaration ? signature.declaration.name : void 0;
|
|
146374
|
+
const target = resolveRecord(declarationNameNode ? checker.getSymbolAtLocation(declarationNameNode) : void 0) ?? (signature?.declaration ? declarationToRecord.get(signature.declaration) : void 0) ?? resolveRecord(checker.getSymbolAtLocation(node.expression));
|
|
146375
|
+
if (target) {
|
|
146376
|
+
const from = owner?.symbol.id;
|
|
146377
|
+
addEdge({
|
|
146378
|
+
...from ? { fromSymbolId: from } : { fromFileId: file.id },
|
|
146379
|
+
toSymbolId: target.symbol.id,
|
|
146380
|
+
type: "calls",
|
|
146381
|
+
confidence: 0.98,
|
|
146382
|
+
evidence: `resolved call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146383
|
+
});
|
|
146384
|
+
if (isTestPath(file.path)) {
|
|
146385
|
+
addEdge({
|
|
146386
|
+
...from ? { fromSymbolId: from } : { fromFileId: file.id },
|
|
146387
|
+
toSymbolId: target.symbol.id,
|
|
146388
|
+
type: "tests",
|
|
146389
|
+
confidence: 0.97,
|
|
146390
|
+
evidence: `resolved test call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146391
|
+
});
|
|
146392
|
+
}
|
|
146393
|
+
} else {
|
|
146394
|
+
unresolvedCalls++;
|
|
146395
|
+
}
|
|
146396
|
+
} else if (ts.isIdentifier(node) && !declarationNameNodes.has(node) && !ts.isImportSpecifier(node.parent) && !ts.isExportSpecifier(node.parent)) {
|
|
146397
|
+
const target = resolveRecord(checker.getSymbolAtLocation(node));
|
|
146398
|
+
if (target) {
|
|
146399
|
+
addEdge({
|
|
146400
|
+
...owner?.symbol.id ? { fromSymbolId: owner.symbol.id } : { fromFileId: file.id },
|
|
146401
|
+
toSymbolId: target.symbol.id,
|
|
146402
|
+
type: "references",
|
|
146403
|
+
confidence: 0.95,
|
|
146404
|
+
evidence: `resolved reference at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146405
|
+
});
|
|
146406
|
+
}
|
|
146407
|
+
} else if (ts.isHeritageClause(node)) {
|
|
146408
|
+
const ownerRecord = currentRecord(node);
|
|
146409
|
+
for (const type of node.types) {
|
|
146410
|
+
const target = resolveRecord(checker.getSymbolAtLocation(type.expression));
|
|
146411
|
+
if (ownerRecord && target) {
|
|
146412
|
+
addEdge({
|
|
146413
|
+
fromSymbolId: ownerRecord.symbol.id,
|
|
146414
|
+
toSymbolId: target.symbol.id,
|
|
146415
|
+
type: node.token === ts.SyntaxKind.ExtendsKeyword ? "extends" : "implements",
|
|
146416
|
+
confidence: 0.99,
|
|
146417
|
+
evidence: `compiler-resolved heritage at line ${lineAt(sourceFile, type.getStart(sourceFile))}`
|
|
146418
|
+
});
|
|
146419
|
+
}
|
|
146420
|
+
}
|
|
146421
|
+
}
|
|
146422
|
+
node.forEachChild(visit);
|
|
146423
|
+
};
|
|
146424
|
+
visit(sourceFile);
|
|
146425
|
+
}
|
|
146426
|
+
const diagnostics = sourceFiles.flatMap((sourceFile) => {
|
|
146427
|
+
const file = fileForSource(sourceFile);
|
|
146428
|
+
if (!file || includePaths && !includePaths.has(normalizeCodePath(file.path))) return [];
|
|
146429
|
+
return program.getSyntacticDiagnostics(sourceFile).slice(0, 4).map((diagnostic) => ({
|
|
146430
|
+
path: file.path,
|
|
146431
|
+
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, " ").slice(0, 240)
|
|
146432
|
+
}));
|
|
146433
|
+
});
|
|
146434
|
+
return {
|
|
146435
|
+
symbols,
|
|
146436
|
+
edges: [...edges.values()],
|
|
146437
|
+
parsedFiles: sourceFiles.length,
|
|
146438
|
+
parserErrors: diagnostics.length,
|
|
146439
|
+
unresolvedCalls,
|
|
146440
|
+
durationMs: Date.now() - started,
|
|
146441
|
+
diagnostics
|
|
146442
|
+
};
|
|
146443
|
+
}
|
|
146444
|
+
var SEMANTIC_SOURCE, SUPPORTED_LANGUAGES;
|
|
146445
|
+
var init_semantic_provider = __esm({
|
|
146446
|
+
"src/codegraph/semantic-provider.ts"() {
|
|
146447
|
+
"use strict";
|
|
146448
|
+
init_esm_shims();
|
|
146449
|
+
init_exclude3();
|
|
146450
|
+
init_ids();
|
|
146451
|
+
SEMANTIC_SOURCE = "typescript-compiler";
|
|
146452
|
+
SUPPORTED_LANGUAGES = /* @__PURE__ */ new Set(["typescript", "javascript"]);
|
|
146453
|
+
}
|
|
146454
|
+
});
|
|
146455
|
+
|
|
145881
146456
|
// src/codegraph/lite-provider.ts
|
|
145882
146457
|
var lite_provider_exports = {};
|
|
145883
146458
|
__export(lite_provider_exports, {
|
|
@@ -145885,11 +146460,11 @@ __export(lite_provider_exports, {
|
|
|
145885
146460
|
indexProjectLite: () => indexProjectLite,
|
|
145886
146461
|
refreshProjectLite: () => refreshProjectLite
|
|
145887
146462
|
});
|
|
145888
|
-
import { createHash as
|
|
145889
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
145890
|
-
import { join as join4, relative } from "path";
|
|
145891
|
-
function
|
|
145892
|
-
return
|
|
146463
|
+
import { createHash as createHash9 } from "crypto";
|
|
146464
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
146465
|
+
import { join as join4, relative as relative2 } from "path";
|
|
146466
|
+
function hashText2(text2) {
|
|
146467
|
+
return createHash9("sha256").update(text2).digest("hex");
|
|
145893
146468
|
}
|
|
145894
146469
|
function extension2(path22) {
|
|
145895
146470
|
const index = path22.lastIndexOf(".");
|
|
@@ -145915,7 +146490,7 @@ function walk(root, exclude, maxFiles) {
|
|
|
145915
146490
|
}
|
|
145916
146491
|
for (const entry of entries) {
|
|
145917
146492
|
const abs = join4(dir, entry.name);
|
|
145918
|
-
const rel = normalizeCodePath(
|
|
146493
|
+
const rel = normalizeCodePath(relative2(root, abs));
|
|
145919
146494
|
if (isCodeGraphExcludedPath(rel, exclude)) continue;
|
|
145920
146495
|
if (entry.isDirectory()) {
|
|
145921
146496
|
if (entry.name === ".git" || entry.name === ".worktrees" || entry.name === ".tmp" || entry.name === "node_modules") continue;
|
|
@@ -145958,8 +146533,9 @@ function extractSymbols(projectId, file, text2, indexedAt) {
|
|
|
145958
146533
|
startLine,
|
|
145959
146534
|
endLine: startLine,
|
|
145960
146535
|
signature: match2[0].slice(0, 160),
|
|
145961
|
-
contentHash:
|
|
145962
|
-
indexedAt
|
|
146536
|
+
contentHash: hashText2(match2[0]),
|
|
146537
|
+
indexedAt,
|
|
146538
|
+
source: "lite-regex"
|
|
145963
146539
|
});
|
|
145964
146540
|
}
|
|
145965
146541
|
}
|
|
@@ -145984,7 +146560,8 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
|
|
|
145984
146560
|
type: "imports",
|
|
145985
146561
|
confidence: 0.7,
|
|
145986
146562
|
evidence: line,
|
|
145987
|
-
indexedAt
|
|
146563
|
+
indexedAt,
|
|
146564
|
+
source: "lite-regex"
|
|
145988
146565
|
});
|
|
145989
146566
|
}
|
|
145990
146567
|
continue;
|
|
@@ -145997,28 +146574,30 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
|
|
|
145997
146574
|
type: "imports",
|
|
145998
146575
|
confidence: 0.7,
|
|
145999
146576
|
evidence: target,
|
|
146000
|
-
indexedAt
|
|
146577
|
+
indexedAt,
|
|
146578
|
+
source: "lite-regex"
|
|
146001
146579
|
});
|
|
146002
146580
|
}
|
|
146003
146581
|
}
|
|
146004
146582
|
return edges;
|
|
146005
146583
|
}
|
|
146006
146584
|
function indexFileLite(projectId, projectRoot, abs, indexedAt, fileStat) {
|
|
146007
|
-
const rel = normalizeCodePath(
|
|
146585
|
+
const rel = normalizeCodePath(relative2(projectRoot, abs));
|
|
146008
146586
|
try {
|
|
146009
|
-
const text2 =
|
|
146587
|
+
const text2 = readFileSync8(abs, "utf-8");
|
|
146010
146588
|
const stat5 = fileStat ?? statSync3(abs);
|
|
146011
146589
|
const file = {
|
|
146012
146590
|
id: makeCodeFileId(projectId, rel),
|
|
146013
146591
|
projectId,
|
|
146014
146592
|
path: rel,
|
|
146015
146593
|
language: languageForPath(rel),
|
|
146016
|
-
contentHash:
|
|
146594
|
+
contentHash: hashText2(text2),
|
|
146017
146595
|
// Preserve filesystem precision. Rounding here made same-size edits in
|
|
146018
146596
|
// a short Windows timestamp window indistinguishable to refresh.
|
|
146019
146597
|
mtimeMs: Number(stat5.mtimeMs),
|
|
146020
146598
|
sizeBytes: Number(stat5.size),
|
|
146021
|
-
indexedAt
|
|
146599
|
+
indexedAt,
|
|
146600
|
+
source: "lite-regex"
|
|
146022
146601
|
};
|
|
146023
146602
|
return {
|
|
146024
146603
|
delta: {
|
|
@@ -146073,6 +146652,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146073
146652
|
const indexedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
146074
146653
|
const paths = walk(options.projectRoot, exclude, maxFiles);
|
|
146075
146654
|
const existingByPath = new Map(store.listFiles(options.projectId).map((file) => [file.path, file]));
|
|
146655
|
+
const changedPaths = /* @__PURE__ */ new Set();
|
|
146076
146656
|
const changed = [];
|
|
146077
146657
|
const metadataOnly = [];
|
|
146078
146658
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
@@ -146081,7 +146661,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146081
146661
|
let skippedOversizedFiles = 0;
|
|
146082
146662
|
let unreadableFiles = 0;
|
|
146083
146663
|
for (const abs of paths) {
|
|
146084
|
-
const rel = normalizeCodePath(
|
|
146664
|
+
const rel = normalizeCodePath(relative2(options.projectRoot, abs));
|
|
146085
146665
|
seenPaths.add(rel);
|
|
146086
146666
|
let stat5;
|
|
146087
146667
|
try {
|
|
@@ -146096,6 +146676,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146096
146676
|
if (sizeBytes > maxFileBytes) {
|
|
146097
146677
|
skippedOversizedFiles++;
|
|
146098
146678
|
if (existing) oversizedExistingFileIds.add(existing.id);
|
|
146679
|
+
changedPaths.add(rel);
|
|
146099
146680
|
continue;
|
|
146100
146681
|
}
|
|
146101
146682
|
if (existing && existing.mtimeMs === mtimeMs && existing.sizeBytes === sizeBytes) {
|
|
@@ -146113,6 +146694,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146113
146694
|
unchangedFiles++;
|
|
146114
146695
|
} else {
|
|
146115
146696
|
changed.push(delta);
|
|
146697
|
+
changedPaths.add(rel);
|
|
146116
146698
|
}
|
|
146117
146699
|
}
|
|
146118
146700
|
const removalScanDeferred = paths.length >= maxFiles;
|
|
@@ -146120,11 +146702,64 @@ async function refreshProjectLite(store, options) {
|
|
|
146120
146702
|
...oversizedExistingFileIds,
|
|
146121
146703
|
...removalScanDeferred ? [] : [...existingByPath.values()].filter((file) => !seenPaths.has(file.path)).map((file) => file.id)
|
|
146122
146704
|
])];
|
|
146705
|
+
for (const file of existingByPath.values()) {
|
|
146706
|
+
if (removedFileIds.includes(file.id)) changedPaths.add(file.path);
|
|
146707
|
+
}
|
|
146708
|
+
const affectedSemanticPaths = /* @__PURE__ */ new Set([
|
|
146709
|
+
...changedPaths,
|
|
146710
|
+
...store.listImportDependentPaths(
|
|
146711
|
+
options.projectId,
|
|
146712
|
+
[...changedPaths],
|
|
146713
|
+
changed.map((delta) => delta.file.path)
|
|
146714
|
+
)
|
|
146715
|
+
]);
|
|
146123
146716
|
store.applyFileDeltas(options.projectId, {
|
|
146124
146717
|
changed,
|
|
146125
146718
|
metadataOnly,
|
|
146126
146719
|
removedFileIds
|
|
146127
146720
|
});
|
|
146721
|
+
const currentFiles = store.listFiles(options.projectId);
|
|
146722
|
+
const beforeSemantic = store.status(options.projectId).semanticSymbols;
|
|
146723
|
+
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);
|
|
146724
|
+
let semanticSummary;
|
|
146725
|
+
if (semanticPaths.length > 0) {
|
|
146726
|
+
const semanticIndexer = options.semanticIndexer ?? buildTypeScriptSemanticIndex;
|
|
146727
|
+
const semanticInput = {
|
|
146728
|
+
projectId: options.projectId,
|
|
146729
|
+
projectRoot: options.projectRoot,
|
|
146730
|
+
files: currentFiles,
|
|
146731
|
+
exclude,
|
|
146732
|
+
includePaths: semanticPaths
|
|
146733
|
+
};
|
|
146734
|
+
try {
|
|
146735
|
+
const semantic = semanticIndexer(semanticInput);
|
|
146736
|
+
store.replaceSemanticSlice(options.projectId, semanticPaths, semantic);
|
|
146737
|
+
semanticSummary = {
|
|
146738
|
+
state: semantic.parserErrors > 0 ? "partial" : "ready",
|
|
146739
|
+
parsedFiles: semantic.parsedFiles,
|
|
146740
|
+
affectedFiles: semanticPaths.length,
|
|
146741
|
+
symbols: semantic.symbols.length,
|
|
146742
|
+
edges: semantic.edges.length,
|
|
146743
|
+
parserErrors: semantic.parserErrors,
|
|
146744
|
+
unresolvedCalls: semantic.unresolvedCalls,
|
|
146745
|
+
durationMs: semantic.durationMs
|
|
146746
|
+
};
|
|
146747
|
+
} catch (error) {
|
|
146748
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
146749
|
+
store.markSemanticSliceFailed(options.projectId, semanticPaths, message);
|
|
146750
|
+
semanticSummary = {
|
|
146751
|
+
state: "failed",
|
|
146752
|
+
parsedFiles: 0,
|
|
146753
|
+
affectedFiles: semanticPaths.length,
|
|
146754
|
+
symbols: 0,
|
|
146755
|
+
edges: 0,
|
|
146756
|
+
parserErrors: semanticPaths.length,
|
|
146757
|
+
unresolvedCalls: 0,
|
|
146758
|
+
durationMs: 0,
|
|
146759
|
+
error: message.slice(0, 500)
|
|
146760
|
+
};
|
|
146761
|
+
}
|
|
146762
|
+
}
|
|
146128
146763
|
const completeness = {
|
|
146129
146764
|
scannedFiles: paths.length,
|
|
146130
146765
|
maxFiles,
|
|
@@ -146154,7 +146789,8 @@ async function refreshProjectLite(store, options) {
|
|
|
146154
146789
|
skippedOversizedFiles,
|
|
146155
146790
|
unreadableFiles,
|
|
146156
146791
|
removalScanDeferred,
|
|
146157
|
-
snapshot
|
|
146792
|
+
snapshot,
|
|
146793
|
+
...semanticSummary ? { semantic: semanticSummary } : {}
|
|
146158
146794
|
};
|
|
146159
146795
|
}
|
|
146160
146796
|
var DEFAULT_CODEGRAPH_MAX_FILE_BYTES, LANGUAGE_BY_EXTENSION, SUPPORTED_EXTENSIONS, identifier, languageProfiles;
|
|
@@ -146165,6 +146801,7 @@ var init_lite_provider = __esm({
|
|
|
146165
146801
|
init_code_state();
|
|
146166
146802
|
init_ids();
|
|
146167
146803
|
init_exclude3();
|
|
146804
|
+
init_semantic_provider();
|
|
146168
146805
|
DEFAULT_CODEGRAPH_MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
146169
146806
|
LANGUAGE_BY_EXTENSION = /* @__PURE__ */ new Map([
|
|
146170
146807
|
[".ts", "typescript"],
|
|
@@ -146456,7 +147093,7 @@ var claim_store_exports = {};
|
|
|
146456
147093
|
__export(claim_store_exports, {
|
|
146457
147094
|
ClaimStore: () => ClaimStore
|
|
146458
147095
|
});
|
|
146459
|
-
import { createHash as
|
|
147096
|
+
import { createHash as createHash10, randomUUID as randomUUID12 } from "crypto";
|
|
146460
147097
|
function optionalText3(value) {
|
|
146461
147098
|
return typeof value === "string" && value ? value : void 0;
|
|
146462
147099
|
}
|
|
@@ -146509,7 +147146,7 @@ function rowToEvent3(row) {
|
|
|
146509
147146
|
};
|
|
146510
147147
|
}
|
|
146511
147148
|
function evidenceKey(input) {
|
|
146512
|
-
return
|
|
147149
|
+
return createHash10("sha256").update(JSON.stringify([
|
|
146513
147150
|
input.evidenceKind,
|
|
146514
147151
|
input.evidenceId,
|
|
146515
147152
|
input.relation,
|
|
@@ -146707,7 +147344,7 @@ __export(claims_exports, {
|
|
|
146707
147344
|
supersedeClaim: () => supersedeClaim,
|
|
146708
147345
|
writeClaim: () => writeClaim
|
|
146709
147346
|
});
|
|
146710
|
-
import { createHash as
|
|
147347
|
+
import { createHash as createHash11, randomUUID as randomUUID13 } from "crypto";
|
|
146711
147348
|
function compactText2(value, field) {
|
|
146712
147349
|
if (typeof value !== "string") throw new Error("Claim " + field + " must be text");
|
|
146713
147350
|
const sanitized = sanitizeCredentials(value).trim().replace(/\s+/g, " ");
|
|
@@ -146719,7 +147356,7 @@ function normalizedTerm(value) {
|
|
|
146719
147356
|
return compactText2(value, "identity").toLocaleLowerCase("en-US");
|
|
146720
147357
|
}
|
|
146721
147358
|
function hashIdentity(parts) {
|
|
146722
|
-
return
|
|
147359
|
+
return createHash11("sha256").update(parts.join(String.fromCharCode(31))).digest("hex");
|
|
146723
147360
|
}
|
|
146724
147361
|
function buildClaimIdentity(input) {
|
|
146725
147362
|
const subject = normalizedTerm(input.subject);
|
|
@@ -146960,7 +147597,7 @@ function supersedeClaim(store, input) {
|
|
|
146960
147597
|
});
|
|
146961
147598
|
}
|
|
146962
147599
|
function hashObservation(observation) {
|
|
146963
|
-
return
|
|
147600
|
+
return createHash11("sha256").update(JSON.stringify([
|
|
146964
147601
|
observation.title,
|
|
146965
147602
|
observation.narrative,
|
|
146966
147603
|
observation.facts,
|
|
@@ -147204,11 +147841,11 @@ var init_frontmatter = __esm({
|
|
|
147204
147841
|
});
|
|
147205
147842
|
|
|
147206
147843
|
// src/knowledge/markdown.ts
|
|
147207
|
-
import { createHash as
|
|
147844
|
+
import { createHash as createHash12 } from "crypto";
|
|
147208
147845
|
import { promises as fs10 } from "fs";
|
|
147209
147846
|
import path17 from "path";
|
|
147210
147847
|
function hashContent(content) {
|
|
147211
|
-
return
|
|
147848
|
+
return createHash12("sha256").update(content).digest("hex");
|
|
147212
147849
|
}
|
|
147213
147850
|
function stringField(data, key) {
|
|
147214
147851
|
const value = data[key];
|
|
@@ -147334,11 +147971,11 @@ __export(wiki_exports, {
|
|
|
147334
147971
|
lintKnowledgeWorkspace: () => lintKnowledgeWorkspace,
|
|
147335
147972
|
readKnowledgePage: () => readKnowledgePage
|
|
147336
147973
|
});
|
|
147337
|
-
import { createHash as
|
|
147974
|
+
import { createHash as createHash13 } from "crypto";
|
|
147338
147975
|
import { promises as fs11 } from "fs";
|
|
147339
147976
|
import path18 from "path";
|
|
147340
147977
|
function hash2(value) {
|
|
147341
|
-
return
|
|
147978
|
+
return createHash13("sha256").update(value).digest("hex");
|
|
147342
147979
|
}
|
|
147343
147980
|
function now() {
|
|
147344
147981
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -147492,8 +148129,8 @@ async function writeIndex(workspace, store) {
|
|
|
147492
148129
|
lines.push("No pending proposals.");
|
|
147493
148130
|
} else {
|
|
147494
148131
|
for (const proposal of pending) {
|
|
147495
|
-
const
|
|
147496
|
-
lines.push("- [" + path18.basename(proposal.proposalPath, ".md") + "](" +
|
|
148132
|
+
const relative3 = path18.relative(paths.root, proposal.proposalPath).split(path18.sep).join("/");
|
|
148133
|
+
lines.push("- [" + path18.basename(proposal.proposalPath, ".md") + "](" + relative3 + ")");
|
|
147497
148134
|
}
|
|
147498
148135
|
}
|
|
147499
148136
|
lines.push("");
|
|
@@ -148195,11 +148832,11 @@ __export(workflows_exports, {
|
|
|
148195
148832
|
syncCanonicalWorkflows: () => syncCanonicalWorkflows,
|
|
148196
148833
|
writeCanonicalWorkflow: () => writeCanonicalWorkflow
|
|
148197
148834
|
});
|
|
148198
|
-
import { createHash as
|
|
148835
|
+
import { createHash as createHash14 } from "crypto";
|
|
148199
148836
|
import { promises as fs12 } from "fs";
|
|
148200
148837
|
import path19 from "path";
|
|
148201
148838
|
function hash3(value) {
|
|
148202
|
-
return
|
|
148839
|
+
return createHash14("sha256").update(value).digest("hex");
|
|
148203
148840
|
}
|
|
148204
148841
|
function now2() {
|
|
148205
148842
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -148633,8 +149270,8 @@ async function importWindsurfWorkflows(input) {
|
|
|
148633
149270
|
return { imported, skipped };
|
|
148634
149271
|
}
|
|
148635
149272
|
function isWithin2(root, candidate) {
|
|
148636
|
-
const
|
|
148637
|
-
return
|
|
149273
|
+
const relative3 = path19.relative(root, candidate);
|
|
149274
|
+
return relative3 !== "" && relative3 !== ".." && !relative3.startsWith(".." + path19.sep) && !path19.isAbsolute(relative3);
|
|
148638
149275
|
}
|
|
148639
149276
|
function adapterRelativePath(workflow, agent) {
|
|
148640
149277
|
const name = "memorix-workflow-" + slug(workflow.id.replace(/^workflow:/, ""));
|
|
@@ -149373,7 +150010,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
149373
150010
|
resolveVectorBackfillRunnerPath: () => resolveVectorBackfillRunnerPath
|
|
149374
150011
|
});
|
|
149375
150012
|
import { spawn as spawn3 } from "child_process";
|
|
149376
|
-
import { existsSync as
|
|
150013
|
+
import { existsSync as existsSync11 } from "fs";
|
|
149377
150014
|
import path20 from "path";
|
|
149378
150015
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
149379
150016
|
function isNonEmptyString(value) {
|
|
@@ -149402,7 +150039,7 @@ function parseVectorBackfillRequest(raw) {
|
|
|
149402
150039
|
}
|
|
149403
150040
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
149404
150041
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
149405
|
-
const exists = options.exists ??
|
|
150042
|
+
const exists = options.exists ?? existsSync11;
|
|
149406
150043
|
if (!exists(runnerPath)) return false;
|
|
149407
150044
|
try {
|
|
149408
150045
|
const child = (options.spawn ?? spawn3)(process.execPath, [runnerPath], {
|
|
@@ -149440,14 +150077,14 @@ async function executeVectorBackfill(request) {
|
|
|
149440
150077
|
return worker.runOnce();
|
|
149441
150078
|
}
|
|
149442
150079
|
async function readStdin() {
|
|
149443
|
-
return new Promise((
|
|
150080
|
+
return new Promise((resolve2, reject) => {
|
|
149444
150081
|
let raw = "";
|
|
149445
150082
|
process.stdin.setEncoding("utf8");
|
|
149446
150083
|
process.stdin.on("data", (chunk) => {
|
|
149447
150084
|
raw += chunk;
|
|
149448
150085
|
});
|
|
149449
150086
|
process.stdin.once("error", reject);
|
|
149450
|
-
process.stdin.once("end", () =>
|
|
150087
|
+
process.stdin.once("end", () => resolve2(raw));
|
|
149451
150088
|
});
|
|
149452
150089
|
}
|
|
149453
150090
|
async function main() {
|
|
@@ -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 parseMediaVideoRunnerRequest(raw) {
|
|
150545
151182
|
let value;
|