memorix 1.8.6 → 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 +33 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/cli/index.js +2208 -1160
- package/dist/dashboard/static/app.js +51 -3
- package/dist/dashboard/static/style.css +88 -0
- package/dist/index.js +1726 -736
- package/dist/maintenance-runner.js +855 -218
- package/dist/media-audio-runner.js +856 -219
- package/dist/media-video-runner.js +854 -217
- package/dist/memcode-runtime/CHANGELOG.md +33 -0
- package/dist/sdk.js +1716 -726
- package/dist/vector-backfill-runner.js +853 -216
- package/docs/1.8.7-CODEGRAPH.md +166 -0
- package/docs/API_REFERENCE.md +23 -2
- package/docs/ARCHITECTURE.md +13 -0
- package/docs/README.md +4 -1
- package/package.json +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/codegraph.ts +25 -11
- package/src/cli/commands/doctor.ts +11 -2
- package/src/cli/commands/serve-http.ts +27 -1
- package/src/codegraph/auto-context.ts +19 -10
- package/src/codegraph/context-pack.ts +20 -6
- package/src/codegraph/dashboard.ts +82 -0
- package/src/codegraph/external-provider.ts +10 -1
- package/src/codegraph/freshness.ts +1 -1
- package/src/codegraph/lite-provider.ts +81 -0
- package/src/codegraph/project-context.ts +18 -5
- package/src/codegraph/scip-provider.ts +181 -0
- package/src/codegraph/semantic-context.ts +139 -0
- package/src/codegraph/semantic-provider.ts +404 -0
- package/src/codegraph/store.ts +253 -18
- package/src/codegraph/types.ts +25 -3
- package/src/dashboard/server.ts +6 -0
- package/src/dashboard/static/style.css +88 -0
- package/src/knowledge/workset.ts +46 -44
- package/src/server/mcp-binding-store.ts +17 -0
- package/src/store/sqlite-db.ts +13 -0
|
@@ -533,6 +533,8 @@ CREATE TABLE IF NOT EXISTS code_files (
|
|
|
533
533
|
sizeBytes INTEGER,
|
|
534
534
|
indexedAt TEXT NOT NULL,
|
|
535
535
|
gitCommit TEXT,
|
|
536
|
+
source TEXT,
|
|
537
|
+
parserError TEXT,
|
|
536
538
|
UNIQUE(projectId, path)
|
|
537
539
|
);
|
|
538
540
|
`;
|
|
@@ -551,6 +553,7 @@ CREATE TABLE IF NOT EXISTS code_symbols (
|
|
|
551
553
|
contentHash TEXT,
|
|
552
554
|
indexedAt TEXT NOT NULL,
|
|
553
555
|
stale INTEGER NOT NULL DEFAULT 0,
|
|
556
|
+
source TEXT,
|
|
554
557
|
UNIQUE(projectId, fileId, qualifiedName, kind)
|
|
555
558
|
);
|
|
556
559
|
`;
|
|
@@ -565,6 +568,7 @@ CREATE TABLE IF NOT EXISTS code_edges (
|
|
|
565
568
|
type TEXT NOT NULL,
|
|
566
569
|
confidence REAL NOT NULL DEFAULT 1.0,
|
|
567
570
|
evidence TEXT,
|
|
571
|
+
source TEXT,
|
|
568
572
|
indexedAt TEXT NOT NULL
|
|
569
573
|
);
|
|
570
574
|
`;
|
|
@@ -1296,6 +1300,15 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_maintenance_jobs_active_dedupe
|
|
|
1296
1300
|
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)");
|
|
1297
1301
|
db2.exec("CREATE INDEX IF NOT EXISTS idx_mcp_bindings_project ON mcp_bindings(project_id, last_used_at DESC)");
|
|
1298
1302
|
}
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
id: "1.8.7-codegraph-evidence",
|
|
1306
|
+
apply: (db2) => {
|
|
1307
|
+
addColumnIfMissing(db2, "code_files", "source", "source TEXT");
|
|
1308
|
+
addColumnIfMissing(db2, "code_files", "parserError", "parserError TEXT");
|
|
1309
|
+
addColumnIfMissing(db2, "code_symbols", "source", "source TEXT");
|
|
1310
|
+
addColumnIfMissing(db2, "code_edges", "source", "source TEXT");
|
|
1311
|
+
}
|
|
1299
1312
|
}
|
|
1300
1313
|
];
|
|
1301
1314
|
_dbCache = /* @__PURE__ */ new Map();
|
|
@@ -4035,7 +4048,7 @@ function toProviderInput(input, baseUrl) {
|
|
|
4035
4048
|
return { type: input.modality, url: input.url };
|
|
4036
4049
|
}
|
|
4037
4050
|
function parseCacheJsonInWorker(filePath) {
|
|
4038
|
-
return new Promise((
|
|
4051
|
+
return new Promise((resolve2, reject) => {
|
|
4039
4052
|
void import("worker_threads").then(({ Worker }) => {
|
|
4040
4053
|
const worker = new Worker(
|
|
4041
4054
|
`
|
|
@@ -4056,7 +4069,7 @@ function parseCacheJsonInWorker(filePath) {
|
|
|
4056
4069
|
worker.once("message", (msg) => {
|
|
4057
4070
|
void worker.terminate();
|
|
4058
4071
|
if (msg?.ok && Array.isArray(msg.entries)) {
|
|
4059
|
-
|
|
4072
|
+
resolve2(msg.entries);
|
|
4060
4073
|
return;
|
|
4061
4074
|
}
|
|
4062
4075
|
reject(new Error(msg?.error || "embedding cache worker parse failed"));
|
|
@@ -4120,8 +4133,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
4120
4133
|
let count2 = 0;
|
|
4121
4134
|
const writeLine = async (line) => {
|
|
4122
4135
|
if (!out.write(line)) {
|
|
4123
|
-
await new Promise((
|
|
4124
|
-
out.once("drain",
|
|
4136
|
+
await new Promise((resolve2, reject) => {
|
|
4137
|
+
out.once("drain", resolve2);
|
|
4125
4138
|
out.once("error", reject);
|
|
4126
4139
|
});
|
|
4127
4140
|
}
|
|
@@ -4153,7 +4166,7 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
4153
4166
|
`);
|
|
4154
4167
|
count2 += 1;
|
|
4155
4168
|
if (count2 % 50 === 0) {
|
|
4156
|
-
await new Promise((
|
|
4169
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
4157
4170
|
}
|
|
4158
4171
|
}
|
|
4159
4172
|
}
|
|
@@ -4162,8 +4175,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
|
|
|
4162
4175
|
}
|
|
4163
4176
|
}
|
|
4164
4177
|
} finally {
|
|
4165
|
-
await new Promise((
|
|
4166
|
-
out.end(() =>
|
|
4178
|
+
await new Promise((resolve2, reject) => {
|
|
4179
|
+
out.end(() => resolve2());
|
|
4167
4180
|
out.once("error", reject);
|
|
4168
4181
|
});
|
|
4169
4182
|
}
|
|
@@ -4208,7 +4221,7 @@ async function loadCacheJsonl(filePath) {
|
|
|
4208
4221
|
} catch {
|
|
4209
4222
|
}
|
|
4210
4223
|
if (onDiskCount % 250 === 0) {
|
|
4211
|
-
await new Promise((
|
|
4224
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
4212
4225
|
}
|
|
4213
4226
|
}
|
|
4214
4227
|
diskCacheEntryCount = onDiskCount;
|
|
@@ -4453,7 +4466,7 @@ async function saveDiskCacheNow() {
|
|
|
4453
4466
|
return;
|
|
4454
4467
|
}
|
|
4455
4468
|
const tmpPath = `${jsonlPath}.tmp`;
|
|
4456
|
-
await new Promise((
|
|
4469
|
+
await new Promise((resolve2, reject) => {
|
|
4457
4470
|
const out = createWriteStream(tmpPath);
|
|
4458
4471
|
const entries = cache3.entries();
|
|
4459
4472
|
const writeBatch = () => {
|
|
@@ -4472,7 +4485,7 @@ async function saveDiskCacheNow() {
|
|
|
4472
4485
|
}
|
|
4473
4486
|
setImmediate(writeBatch);
|
|
4474
4487
|
};
|
|
4475
|
-
out.on("finish",
|
|
4488
|
+
out.on("finish", resolve2);
|
|
4476
4489
|
out.on("error", reject);
|
|
4477
4490
|
writeBatch();
|
|
4478
4491
|
});
|
|
@@ -4576,7 +4589,7 @@ function abortError() {
|
|
|
4576
4589
|
}
|
|
4577
4590
|
function raceWithAbort(promise, signal) {
|
|
4578
4591
|
if (signal.aborted) return Promise.reject(abortError());
|
|
4579
|
-
return new Promise((
|
|
4592
|
+
return new Promise((resolve2, reject) => {
|
|
4580
4593
|
const onAbort = () => {
|
|
4581
4594
|
signal.removeEventListener("abort", onAbort);
|
|
4582
4595
|
reject(abortError());
|
|
@@ -4585,7 +4598,7 @@ function raceWithAbort(promise, signal) {
|
|
|
4585
4598
|
promise.then(
|
|
4586
4599
|
(value) => {
|
|
4587
4600
|
signal.removeEventListener("abort", onAbort);
|
|
4588
|
-
|
|
4601
|
+
resolve2(value);
|
|
4589
4602
|
},
|
|
4590
4603
|
(error) => {
|
|
4591
4604
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -4596,12 +4609,12 @@ function raceWithAbort(promise, signal) {
|
|
|
4596
4609
|
}
|
|
4597
4610
|
async function waitForRetry(waitMs, signal) {
|
|
4598
4611
|
if (!signal) {
|
|
4599
|
-
await new Promise((
|
|
4612
|
+
await new Promise((resolve2) => setTimeout(resolve2, waitMs));
|
|
4600
4613
|
return;
|
|
4601
4614
|
}
|
|
4602
4615
|
const abortSignal = signal;
|
|
4603
4616
|
if (abortSignal.aborted) throw new Error("Embedding API retry aborted");
|
|
4604
|
-
await new Promise((
|
|
4617
|
+
await new Promise((resolve2, reject) => {
|
|
4605
4618
|
const timer = setTimeout(done, waitMs);
|
|
4606
4619
|
const onAbort = () => {
|
|
4607
4620
|
clearTimeout(timer);
|
|
@@ -4610,7 +4623,7 @@ async function waitForRetry(waitMs, signal) {
|
|
|
4610
4623
|
};
|
|
4611
4624
|
function done() {
|
|
4612
4625
|
abortSignal.removeEventListener("abort", onAbort);
|
|
4613
|
-
|
|
4626
|
+
resolve2();
|
|
4614
4627
|
}
|
|
4615
4628
|
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
4616
4629
|
});
|
|
@@ -5786,12 +5799,12 @@ var init_policy = __esm({
|
|
|
5786
5799
|
|
|
5787
5800
|
// src/timeout.ts
|
|
5788
5801
|
function withTimeout(promise, ms, label) {
|
|
5789
|
-
return new Promise((
|
|
5802
|
+
return new Promise((resolve2, reject) => {
|
|
5790
5803
|
const timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
|
|
5791
5804
|
promise.then(
|
|
5792
5805
|
(value) => {
|
|
5793
5806
|
clearTimeout(timer);
|
|
5794
|
-
|
|
5807
|
+
resolve2(value);
|
|
5795
5808
|
},
|
|
5796
5809
|
(error) => {
|
|
5797
5810
|
clearTimeout(timer);
|
|
@@ -5803,7 +5816,7 @@ function withTimeout(promise, ms, label) {
|
|
|
5803
5816
|
function withTimeoutSignal(operation, ms, label, parentSignal) {
|
|
5804
5817
|
const controller = new AbortController();
|
|
5805
5818
|
const signal = parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal;
|
|
5806
|
-
return new Promise((
|
|
5819
|
+
return new Promise((resolve2, reject) => {
|
|
5807
5820
|
let settled = false;
|
|
5808
5821
|
let timedOut = false;
|
|
5809
5822
|
let timer;
|
|
@@ -5840,7 +5853,7 @@ function withTimeoutSignal(operation, ms, label, parentSignal) {
|
|
|
5840
5853
|
if (settled) return;
|
|
5841
5854
|
settled = true;
|
|
5842
5855
|
cleanup();
|
|
5843
|
-
|
|
5856
|
+
resolve2(value);
|
|
5844
5857
|
},
|
|
5845
5858
|
(error) => {
|
|
5846
5859
|
if (settled) return;
|
|
@@ -6673,7 +6686,7 @@ async function attachCachedVectors(database, candidates) {
|
|
|
6673
6686
|
} catch {
|
|
6674
6687
|
}
|
|
6675
6688
|
if (index % 50 === 0) {
|
|
6676
|
-
await new Promise((
|
|
6689
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
6677
6690
|
}
|
|
6678
6691
|
}
|
|
6679
6692
|
}
|
|
@@ -6749,7 +6762,7 @@ async function hydrateIndex(observations2, options = {}) {
|
|
|
6749
6762
|
}
|
|
6750
6763
|
}
|
|
6751
6764
|
}
|
|
6752
|
-
await new Promise((
|
|
6765
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
6753
6766
|
}
|
|
6754
6767
|
deferredCachedVectorHydration = options.skipCachedVectors ? null : deferCachedVectors ? attachCachedVectors(database, candidates).catch(() => {
|
|
6755
6768
|
}) : null;
|
|
@@ -8549,8 +8562,8 @@ function localWorkspacePath(dataDir, projectId) {
|
|
|
8549
8562
|
return path10.join(path10.resolve(dataDir), "knowledge-workspaces", hash(projectId).slice(0, 24));
|
|
8550
8563
|
}
|
|
8551
8564
|
function isWithin(root, candidate) {
|
|
8552
|
-
const
|
|
8553
|
-
return
|
|
8565
|
+
const relative3 = path10.relative(root, candidate);
|
|
8566
|
+
return relative3 !== "" && !relative3.startsWith(".." + path10.sep) && relative3 !== ".." && !path10.isAbsolute(relative3);
|
|
8554
8567
|
}
|
|
8555
8568
|
function ensureVersionedPath(projectRoot, rootPath) {
|
|
8556
8569
|
if (!path10.isAbsolute(rootPath)) {
|
|
@@ -8568,8 +8581,8 @@ function ensureVersionedPath(projectRoot, rootPath) {
|
|
|
8568
8581
|
return resolvedWorkspace;
|
|
8569
8582
|
}
|
|
8570
8583
|
async function isIgnoredByGit(projectRoot, workspaceRoot) {
|
|
8571
|
-
const
|
|
8572
|
-
const probes = [
|
|
8584
|
+
const relative3 = path10.relative(projectRoot, workspaceRoot).split(path10.sep).join("/");
|
|
8585
|
+
const probes = [relative3, relative3.replace(/\/+$/, "") + "/.memorix-workspace-probe"];
|
|
8573
8586
|
for (const probe of probes) {
|
|
8574
8587
|
try {
|
|
8575
8588
|
await execFileAsync("git", ["-C", projectRoot, "check-ignore", "--quiet", "--no-index", "--", probe], {
|
|
@@ -9685,8 +9698,8 @@ function projectStorageKey(projectId) {
|
|
|
9685
9698
|
}
|
|
9686
9699
|
function validateUnderRoot(root, candidate) {
|
|
9687
9700
|
const resolved = path11.resolve(candidate);
|
|
9688
|
-
const
|
|
9689
|
-
if (
|
|
9701
|
+
const relative3 = path11.relative(root, resolved);
|
|
9702
|
+
if (relative3.startsWith("..") || path11.isAbsolute(relative3)) {
|
|
9690
9703
|
throw new Error("Media storage path escaped the Memorix data directory");
|
|
9691
9704
|
}
|
|
9692
9705
|
return resolved;
|
|
@@ -9730,8 +9743,8 @@ function detectMedia(bytes) {
|
|
|
9730
9743
|
throw new Error("Unsupported or unrecognized media format");
|
|
9731
9744
|
}
|
|
9732
9745
|
function destinationFor(root, projectId, sha256, extension3) {
|
|
9733
|
-
const
|
|
9734
|
-
return { relative:
|
|
9746
|
+
const relative3 = path11.join("assets", projectStorageKey(projectId), sha256.slice(0, 2), `${sha256}${extension3}`);
|
|
9747
|
+
return { relative: relative3, absolute: validateUnderRoot(root, path11.join(root, relative3)) };
|
|
9735
9748
|
}
|
|
9736
9749
|
async function destinationExists(destination) {
|
|
9737
9750
|
try {
|
|
@@ -18261,7 +18274,7 @@ var init_sleep = __esm({
|
|
|
18261
18274
|
"node_modules/openai/internal/utils/sleep.mjs"() {
|
|
18262
18275
|
"use strict";
|
|
18263
18276
|
init_esm_shims();
|
|
18264
|
-
sleep = (ms) => new Promise((
|
|
18277
|
+
sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
18265
18278
|
}
|
|
18266
18279
|
});
|
|
18267
18280
|
|
|
@@ -19450,8 +19463,8 @@ var init_api_promise = __esm({
|
|
|
19450
19463
|
init_parse();
|
|
19451
19464
|
APIPromise = class _APIPromise extends Promise {
|
|
19452
19465
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
19453
|
-
super((
|
|
19454
|
-
|
|
19466
|
+
super((resolve2) => {
|
|
19467
|
+
resolve2(null);
|
|
19455
19468
|
});
|
|
19456
19469
|
this.responsePromise = responsePromise;
|
|
19457
19470
|
this.parseResponse = parseResponse2;
|
|
@@ -20095,12 +20108,12 @@ var init_EventStream = __esm({
|
|
|
20095
20108
|
_EventStream_errored.set(this, false);
|
|
20096
20109
|
_EventStream_aborted.set(this, false);
|
|
20097
20110
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
20098
|
-
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((
|
|
20099
|
-
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise,
|
|
20111
|
+
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
20112
|
+
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve2, "f");
|
|
20100
20113
|
__classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
20101
20114
|
}), "f");
|
|
20102
|
-
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((
|
|
20103
|
-
__classPrivateFieldSet(this, _EventStream_resolveEndPromise,
|
|
20115
|
+
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
|
|
20116
|
+
__classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve2, "f");
|
|
20104
20117
|
__classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject, "f");
|
|
20105
20118
|
}), "f");
|
|
20106
20119
|
__classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => {
|
|
@@ -20184,11 +20197,11 @@ var init_EventStream = __esm({
|
|
|
20184
20197
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
20185
20198
|
*/
|
|
20186
20199
|
emitted(event) {
|
|
20187
|
-
return new Promise((
|
|
20200
|
+
return new Promise((resolve2, reject) => {
|
|
20188
20201
|
__classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
20189
20202
|
if (event !== "error")
|
|
20190
20203
|
this.once("error", reject);
|
|
20191
|
-
this.once(event,
|
|
20204
|
+
this.once(event, resolve2);
|
|
20192
20205
|
});
|
|
20193
20206
|
}
|
|
20194
20207
|
async done() {
|
|
@@ -21257,7 +21270,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
21257
21270
|
if (done) {
|
|
21258
21271
|
return { value: void 0, done: true };
|
|
21259
21272
|
}
|
|
21260
|
-
return new Promise((
|
|
21273
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
21261
21274
|
}
|
|
21262
21275
|
const chunk = pushQueue.shift();
|
|
21263
21276
|
return { value: chunk, done: false };
|
|
@@ -22240,7 +22253,7 @@ var init_AssistantStream = __esm({
|
|
|
22240
22253
|
if (done) {
|
|
22241
22254
|
return { value: void 0, done: true };
|
|
22242
22255
|
}
|
|
22243
|
-
return new Promise((
|
|
22256
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
22244
22257
|
}
|
|
22245
22258
|
const chunk = pushQueue.shift();
|
|
22246
22259
|
return { value: chunk, done: false };
|
|
@@ -24529,7 +24542,7 @@ var init_ResponseStream = __esm({
|
|
|
24529
24542
|
if (done) {
|
|
24530
24543
|
return { value: void 0, done: true };
|
|
24531
24544
|
}
|
|
24532
|
-
return new Promise((
|
|
24545
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
24533
24546
|
}
|
|
24534
24547
|
const event = pushQueue.shift();
|
|
24535
24548
|
return { value: event, done: false };
|
|
@@ -44728,8 +44741,8 @@ var init_event_stream = __esm({
|
|
|
44728
44741
|
constructor(isComplete, extractResult) {
|
|
44729
44742
|
this.isComplete = isComplete;
|
|
44730
44743
|
this.extractResult = extractResult;
|
|
44731
|
-
this.finalResultPromise = new Promise((
|
|
44732
|
-
this.resolveFinalResult =
|
|
44744
|
+
this.finalResultPromise = new Promise((resolve2) => {
|
|
44745
|
+
this.resolveFinalResult = resolve2;
|
|
44733
44746
|
});
|
|
44734
44747
|
}
|
|
44735
44748
|
push(event) {
|
|
@@ -44763,7 +44776,7 @@ var init_event_stream = __esm({
|
|
|
44763
44776
|
} else if (this.done) {
|
|
44764
44777
|
return;
|
|
44765
44778
|
} else {
|
|
44766
|
-
const result = await new Promise((
|
|
44779
|
+
const result = await new Promise((resolve2) => this.waiting.push(resolve2));
|
|
44767
44780
|
if (result.done)
|
|
44768
44781
|
return;
|
|
44769
44782
|
yield result.value;
|
|
@@ -45034,7 +45047,7 @@ var init_sleep2 = __esm({
|
|
|
45034
45047
|
"node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
45035
45048
|
"use strict";
|
|
45036
45049
|
init_esm_shims();
|
|
45037
|
-
sleep2 = (ms) => new Promise((
|
|
45050
|
+
sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
45038
45051
|
}
|
|
45039
45052
|
});
|
|
45040
45053
|
|
|
@@ -45834,8 +45847,8 @@ var init_api_promise2 = __esm({
|
|
|
45834
45847
|
init_parse2();
|
|
45835
45848
|
APIPromise2 = class _APIPromise extends Promise {
|
|
45836
45849
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
45837
|
-
super((
|
|
45838
|
-
|
|
45850
|
+
super((resolve2) => {
|
|
45851
|
+
resolve2(null);
|
|
45839
45852
|
});
|
|
45840
45853
|
this.responsePromise = responsePromise;
|
|
45841
45854
|
this.parseResponse = parseResponse2;
|
|
@@ -47796,12 +47809,12 @@ var init_BetaMessageStream = __esm({
|
|
|
47796
47809
|
}
|
|
47797
47810
|
return this._emit("error", new AnthropicError(String(error)));
|
|
47798
47811
|
});
|
|
47799
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
47800
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise,
|
|
47812
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
47813
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve2, "f");
|
|
47801
47814
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
47802
47815
|
}), "f");
|
|
47803
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((
|
|
47804
|
-
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise,
|
|
47816
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
47817
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve2, "f");
|
|
47805
47818
|
__classPrivateFieldSet2(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
47806
47819
|
}), "f");
|
|
47807
47820
|
__classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47971,11 +47984,11 @@ var init_BetaMessageStream = __esm({
|
|
|
47971
47984
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47972
47985
|
*/
|
|
47973
47986
|
emitted(event) {
|
|
47974
|
-
return new Promise((
|
|
47987
|
+
return new Promise((resolve2, reject) => {
|
|
47975
47988
|
__classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
47976
47989
|
if (event !== "error")
|
|
47977
47990
|
this.once("error", reject);
|
|
47978
|
-
this.once(event,
|
|
47991
|
+
this.once(event, resolve2);
|
|
47979
47992
|
});
|
|
47980
47993
|
}
|
|
47981
47994
|
async done() {
|
|
@@ -48318,7 +48331,7 @@ var init_BetaMessageStream = __esm({
|
|
|
48318
48331
|
if (done) {
|
|
48319
48332
|
return { value: void 0, done: true };
|
|
48320
48333
|
}
|
|
48321
|
-
return new Promise((
|
|
48334
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
48322
48335
|
}
|
|
48323
48336
|
const chunk = pushQueue.shift();
|
|
48324
48337
|
return { value: chunk, done: false };
|
|
@@ -48393,13 +48406,13 @@ Wrap your summary in <summary></summary> tags.`;
|
|
|
48393
48406
|
|
|
48394
48407
|
// node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs
|
|
48395
48408
|
function promiseWithResolvers() {
|
|
48396
|
-
let
|
|
48409
|
+
let resolve2;
|
|
48397
48410
|
let reject;
|
|
48398
48411
|
const promise = new Promise((res, rej) => {
|
|
48399
|
-
|
|
48412
|
+
resolve2 = res;
|
|
48400
48413
|
reject = rej;
|
|
48401
48414
|
});
|
|
48402
|
-
return { promise, resolve, reject };
|
|
48415
|
+
return { promise, resolve: resolve2, reject };
|
|
48403
48416
|
}
|
|
48404
48417
|
async function generateToolResponse(params, lastMessage = params.messages.at(-1), requestOptions) {
|
|
48405
48418
|
if (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content || typeof lastMessage.content === "string") {
|
|
@@ -50257,12 +50270,12 @@ var init_MessageStream = __esm({
|
|
|
50257
50270
|
}
|
|
50258
50271
|
return this._emit("error", new AnthropicError(String(error)));
|
|
50259
50272
|
});
|
|
50260
|
-
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((
|
|
50261
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise,
|
|
50273
|
+
__classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
50274
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise, resolve2, "f");
|
|
50262
50275
|
__classPrivateFieldSet2(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
50263
50276
|
}), "f");
|
|
50264
|
-
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((
|
|
50265
|
-
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise,
|
|
50277
|
+
__classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
50278
|
+
__classPrivateFieldSet2(this, _MessageStream_resolveEndPromise, resolve2, "f");
|
|
50266
50279
|
__classPrivateFieldSet2(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
50267
50280
|
}), "f");
|
|
50268
50281
|
__classPrivateFieldGet2(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -50432,11 +50445,11 @@ var init_MessageStream = __esm({
|
|
|
50432
50445
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
50433
50446
|
*/
|
|
50434
50447
|
emitted(event) {
|
|
50435
|
-
return new Promise((
|
|
50448
|
+
return new Promise((resolve2, reject) => {
|
|
50436
50449
|
__classPrivateFieldSet2(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
50437
50450
|
if (event !== "error")
|
|
50438
50451
|
this.once("error", reject);
|
|
50439
|
-
this.once(event,
|
|
50452
|
+
this.once(event, resolve2);
|
|
50440
50453
|
});
|
|
50441
50454
|
}
|
|
50442
50455
|
async done() {
|
|
@@ -50754,7 +50767,7 @@ var init_MessageStream = __esm({
|
|
|
50754
50767
|
if (done) {
|
|
50755
50768
|
return { value: void 0, done: true };
|
|
50756
50769
|
}
|
|
50757
|
-
return new Promise((
|
|
50770
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
50758
50771
|
}
|
|
50759
50772
|
const chunk = pushQueue.shift();
|
|
50760
50773
|
return { value: chunk, done: false };
|
|
@@ -54132,7 +54145,7 @@ var require_p_retry = __commonJS({
|
|
|
54132
54145
|
return error;
|
|
54133
54146
|
};
|
|
54134
54147
|
var isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
|
|
54135
|
-
var pRetry2 = (input, options) => new Promise((
|
|
54148
|
+
var pRetry2 = (input, options) => new Promise((resolve2, reject) => {
|
|
54136
54149
|
options = {
|
|
54137
54150
|
onFailedAttempt: () => {
|
|
54138
54151
|
},
|
|
@@ -54142,7 +54155,7 @@ var require_p_retry = __commonJS({
|
|
|
54142
54155
|
const operation = retry2.operation(options);
|
|
54143
54156
|
operation.attempt(async (attemptNumber) => {
|
|
54144
54157
|
try {
|
|
54145
|
-
|
|
54158
|
+
resolve2(await input(attemptNumber));
|
|
54146
54159
|
} catch (error) {
|
|
54147
54160
|
if (!(error instanceof Error)) {
|
|
54148
54161
|
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
@@ -54680,8 +54693,8 @@ var require_retry3 = __commonJS({
|
|
|
54680
54693
|
}
|
|
54681
54694
|
const delay2 = getNextRetryDelay(config);
|
|
54682
54695
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
54683
|
-
const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((
|
|
54684
|
-
setTimeout(
|
|
54696
|
+
const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((resolve2) => {
|
|
54697
|
+
setTimeout(resolve2, delay2);
|
|
54685
54698
|
});
|
|
54686
54699
|
if (config.onRetryAttempt) {
|
|
54687
54700
|
await config.onRetryAttempt(err);
|
|
@@ -55598,8 +55611,8 @@ var require_helpers = __commonJS({
|
|
|
55598
55611
|
function req(url, opts = {}) {
|
|
55599
55612
|
const href = typeof url === "string" ? url : url.href;
|
|
55600
55613
|
const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts);
|
|
55601
|
-
const promise = new Promise((
|
|
55602
|
-
req2.once("response",
|
|
55614
|
+
const promise = new Promise((resolve2, reject) => {
|
|
55615
|
+
req2.once("response", resolve2).once("error", reject).end();
|
|
55603
55616
|
});
|
|
55604
55617
|
req2.then = promise.then.bind(promise);
|
|
55605
55618
|
return req2;
|
|
@@ -55778,7 +55791,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
55778
55791
|
var debug_1 = __importDefault(require_src());
|
|
55779
55792
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
55780
55793
|
function parseProxyResponse(socket) {
|
|
55781
|
-
return new Promise((
|
|
55794
|
+
return new Promise((resolve2, reject) => {
|
|
55782
55795
|
let buffersLength = 0;
|
|
55783
55796
|
const buffers = [];
|
|
55784
55797
|
function read() {
|
|
@@ -55844,7 +55857,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
55844
55857
|
}
|
|
55845
55858
|
debug("got proxy server response: %o %o", firstLine, headers);
|
|
55846
55859
|
cleanup();
|
|
55847
|
-
|
|
55860
|
+
resolve2({
|
|
55848
55861
|
connect: {
|
|
55849
55862
|
statusCode,
|
|
55850
55863
|
statusText,
|
|
@@ -56091,7 +56104,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56091
56104
|
return new originalPromise(executor);
|
|
56092
56105
|
}
|
|
56093
56106
|
function promiseResolvedWith(value) {
|
|
56094
|
-
return newPromise((
|
|
56107
|
+
return newPromise((resolve2) => resolve2(value));
|
|
56095
56108
|
}
|
|
56096
56109
|
function promiseRejectedWith(reason) {
|
|
56097
56110
|
return originalPromiseReject(reason);
|
|
@@ -56261,8 +56274,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56261
56274
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
56262
56275
|
}
|
|
56263
56276
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
56264
|
-
reader._closedPromise = newPromise((
|
|
56265
|
-
reader._closedPromise_resolve =
|
|
56277
|
+
reader._closedPromise = newPromise((resolve2, reject) => {
|
|
56278
|
+
reader._closedPromise_resolve = resolve2;
|
|
56266
56279
|
reader._closedPromise_reject = reject;
|
|
56267
56280
|
});
|
|
56268
56281
|
}
|
|
@@ -56436,8 +56449,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56436
56449
|
}
|
|
56437
56450
|
let resolvePromise;
|
|
56438
56451
|
let rejectPromise;
|
|
56439
|
-
const promise = newPromise((
|
|
56440
|
-
resolvePromise =
|
|
56452
|
+
const promise = newPromise((resolve2, reject) => {
|
|
56453
|
+
resolvePromise = resolve2;
|
|
56441
56454
|
rejectPromise = reject;
|
|
56442
56455
|
});
|
|
56443
56456
|
const readRequest = {
|
|
@@ -56542,8 +56555,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56542
56555
|
const reader = this._reader;
|
|
56543
56556
|
let resolvePromise;
|
|
56544
56557
|
let rejectPromise;
|
|
56545
|
-
const promise = newPromise((
|
|
56546
|
-
resolvePromise =
|
|
56558
|
+
const promise = newPromise((resolve2, reject) => {
|
|
56559
|
+
resolvePromise = resolve2;
|
|
56547
56560
|
rejectPromise = reject;
|
|
56548
56561
|
});
|
|
56549
56562
|
const readRequest = {
|
|
@@ -57562,8 +57575,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57562
57575
|
}
|
|
57563
57576
|
let resolvePromise;
|
|
57564
57577
|
let rejectPromise;
|
|
57565
|
-
const promise = newPromise((
|
|
57566
|
-
resolvePromise =
|
|
57578
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57579
|
+
resolvePromise = resolve2;
|
|
57567
57580
|
rejectPromise = reject;
|
|
57568
57581
|
});
|
|
57569
57582
|
const readIntoRequest = {
|
|
@@ -57875,10 +57888,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57875
57888
|
wasAlreadyErroring = true;
|
|
57876
57889
|
reason = void 0;
|
|
57877
57890
|
}
|
|
57878
|
-
const promise = newPromise((
|
|
57891
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57879
57892
|
stream2._pendingAbortRequest = {
|
|
57880
57893
|
_promise: void 0,
|
|
57881
|
-
_resolve:
|
|
57894
|
+
_resolve: resolve2,
|
|
57882
57895
|
_reject: reject,
|
|
57883
57896
|
_reason: reason,
|
|
57884
57897
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -57895,9 +57908,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57895
57908
|
if (state === "closed" || state === "errored") {
|
|
57896
57909
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
57897
57910
|
}
|
|
57898
|
-
const promise = newPromise((
|
|
57911
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57899
57912
|
const closeRequest = {
|
|
57900
|
-
_resolve:
|
|
57913
|
+
_resolve: resolve2,
|
|
57901
57914
|
_reject: reject
|
|
57902
57915
|
};
|
|
57903
57916
|
stream2._closeRequest = closeRequest;
|
|
@@ -57910,9 +57923,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57910
57923
|
return promise;
|
|
57911
57924
|
}
|
|
57912
57925
|
function WritableStreamAddWriteRequest(stream2) {
|
|
57913
|
-
const promise = newPromise((
|
|
57926
|
+
const promise = newPromise((resolve2, reject) => {
|
|
57914
57927
|
const writeRequest = {
|
|
57915
|
-
_resolve:
|
|
57928
|
+
_resolve: resolve2,
|
|
57916
57929
|
_reject: reject
|
|
57917
57930
|
};
|
|
57918
57931
|
stream2._writeRequests.push(writeRequest);
|
|
@@ -58528,8 +58541,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58528
58541
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
58529
58542
|
}
|
|
58530
58543
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
58531
|
-
writer._closedPromise = newPromise((
|
|
58532
|
-
writer._closedPromise_resolve =
|
|
58544
|
+
writer._closedPromise = newPromise((resolve2, reject) => {
|
|
58545
|
+
writer._closedPromise_resolve = resolve2;
|
|
58533
58546
|
writer._closedPromise_reject = reject;
|
|
58534
58547
|
writer._closedPromiseState = "pending";
|
|
58535
58548
|
});
|
|
@@ -58565,8 +58578,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58565
58578
|
writer._closedPromiseState = "resolved";
|
|
58566
58579
|
}
|
|
58567
58580
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
58568
|
-
writer._readyPromise = newPromise((
|
|
58569
|
-
writer._readyPromise_resolve =
|
|
58581
|
+
writer._readyPromise = newPromise((resolve2, reject) => {
|
|
58582
|
+
writer._readyPromise_resolve = resolve2;
|
|
58570
58583
|
writer._readyPromise_reject = reject;
|
|
58571
58584
|
});
|
|
58572
58585
|
writer._readyPromiseState = "pending";
|
|
@@ -58653,7 +58666,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58653
58666
|
source._disturbed = true;
|
|
58654
58667
|
let shuttingDown = false;
|
|
58655
58668
|
let currentWrite = promiseResolvedWith(void 0);
|
|
58656
|
-
return newPromise((
|
|
58669
|
+
return newPromise((resolve2, reject) => {
|
|
58657
58670
|
let abortAlgorithm;
|
|
58658
58671
|
if (signal !== void 0) {
|
|
58659
58672
|
abortAlgorithm = () => {
|
|
@@ -58798,7 +58811,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
58798
58811
|
if (isError) {
|
|
58799
58812
|
reject(error);
|
|
58800
58813
|
} else {
|
|
58801
|
-
|
|
58814
|
+
resolve2(void 0);
|
|
58802
58815
|
}
|
|
58803
58816
|
return null;
|
|
58804
58817
|
}
|
|
@@ -59079,8 +59092,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59079
59092
|
let branch1;
|
|
59080
59093
|
let branch2;
|
|
59081
59094
|
let resolveCancelPromise;
|
|
59082
|
-
const cancelPromise = newPromise((
|
|
59083
|
-
resolveCancelPromise =
|
|
59095
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
59096
|
+
resolveCancelPromise = resolve2;
|
|
59084
59097
|
});
|
|
59085
59098
|
function pullAlgorithm() {
|
|
59086
59099
|
if (reading) {
|
|
@@ -59171,8 +59184,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59171
59184
|
let branch1;
|
|
59172
59185
|
let branch2;
|
|
59173
59186
|
let resolveCancelPromise;
|
|
59174
|
-
const cancelPromise = newPromise((
|
|
59175
|
-
resolveCancelPromise =
|
|
59187
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
59188
|
+
resolveCancelPromise = resolve2;
|
|
59176
59189
|
});
|
|
59177
59190
|
function forwardReaderError(thisReader) {
|
|
59178
59191
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -59952,8 +59965,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
59952
59965
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
59953
59966
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
59954
59967
|
let startPromise_resolve;
|
|
59955
|
-
const startPromise = newPromise((
|
|
59956
|
-
startPromise_resolve =
|
|
59968
|
+
const startPromise = newPromise((resolve2) => {
|
|
59969
|
+
startPromise_resolve = resolve2;
|
|
59957
59970
|
});
|
|
59958
59971
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
59959
59972
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -60046,8 +60059,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60046
60059
|
if (stream2._backpressureChangePromise !== void 0) {
|
|
60047
60060
|
stream2._backpressureChangePromise_resolve();
|
|
60048
60061
|
}
|
|
60049
|
-
stream2._backpressureChangePromise = newPromise((
|
|
60050
|
-
stream2._backpressureChangePromise_resolve =
|
|
60062
|
+
stream2._backpressureChangePromise = newPromise((resolve2) => {
|
|
60063
|
+
stream2._backpressureChangePromise_resolve = resolve2;
|
|
60051
60064
|
});
|
|
60052
60065
|
stream2._backpressure = backpressure;
|
|
60053
60066
|
}
|
|
@@ -60215,8 +60228,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60215
60228
|
return controller._finishPromise;
|
|
60216
60229
|
}
|
|
60217
60230
|
const readable = stream2._readable;
|
|
60218
|
-
controller._finishPromise = newPromise((
|
|
60219
|
-
controller._finishPromise_resolve =
|
|
60231
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60232
|
+
controller._finishPromise_resolve = resolve2;
|
|
60220
60233
|
controller._finishPromise_reject = reject;
|
|
60221
60234
|
});
|
|
60222
60235
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -60242,8 +60255,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60242
60255
|
return controller._finishPromise;
|
|
60243
60256
|
}
|
|
60244
60257
|
const readable = stream2._readable;
|
|
60245
|
-
controller._finishPromise = newPromise((
|
|
60246
|
-
controller._finishPromise_resolve =
|
|
60258
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60259
|
+
controller._finishPromise_resolve = resolve2;
|
|
60247
60260
|
controller._finishPromise_reject = reject;
|
|
60248
60261
|
});
|
|
60249
60262
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -60273,8 +60286,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
60273
60286
|
return controller._finishPromise;
|
|
60274
60287
|
}
|
|
60275
60288
|
const writable = stream2._writable;
|
|
60276
|
-
controller._finishPromise = newPromise((
|
|
60277
|
-
controller._finishPromise_resolve =
|
|
60289
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
60290
|
+
controller._finishPromise_resolve = resolve2;
|
|
60278
60291
|
controller._finishPromise_reject = reject;
|
|
60279
60292
|
});
|
|
60280
60293
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -62261,7 +62274,7 @@ import zlib from "zlib";
|
|
|
62261
62274
|
import Stream4, { PassThrough as PassThrough2, pipeline as pump } from "stream";
|
|
62262
62275
|
import { Buffer as Buffer3 } from "buffer";
|
|
62263
62276
|
async function fetch2(url, options_) {
|
|
62264
|
-
return new Promise((
|
|
62277
|
+
return new Promise((resolve2, reject) => {
|
|
62265
62278
|
const request = new Request2(url, options_);
|
|
62266
62279
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
62267
62280
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -62270,7 +62283,7 @@ async function fetch2(url, options_) {
|
|
|
62270
62283
|
if (parsedURL.protocol === "data:") {
|
|
62271
62284
|
const data = dist_default(request.url);
|
|
62272
62285
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
62273
|
-
|
|
62286
|
+
resolve2(response2);
|
|
62274
62287
|
return;
|
|
62275
62288
|
}
|
|
62276
62289
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -62392,7 +62405,7 @@ async function fetch2(url, options_) {
|
|
|
62392
62405
|
if (responseReferrerPolicy) {
|
|
62393
62406
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
62394
62407
|
}
|
|
62395
|
-
|
|
62408
|
+
resolve2(fetch2(new Request2(locationURL, requestOptions)));
|
|
62396
62409
|
finalize();
|
|
62397
62410
|
return;
|
|
62398
62411
|
}
|
|
@@ -62425,7 +62438,7 @@ async function fetch2(url, options_) {
|
|
|
62425
62438
|
const codings = headers.get("Content-Encoding");
|
|
62426
62439
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
62427
62440
|
response = new Response2(body, responseOptions);
|
|
62428
|
-
|
|
62441
|
+
resolve2(response);
|
|
62429
62442
|
return;
|
|
62430
62443
|
}
|
|
62431
62444
|
const zlibOptions = {
|
|
@@ -62439,7 +62452,7 @@ async function fetch2(url, options_) {
|
|
|
62439
62452
|
}
|
|
62440
62453
|
});
|
|
62441
62454
|
response = new Response2(body, responseOptions);
|
|
62442
|
-
|
|
62455
|
+
resolve2(response);
|
|
62443
62456
|
return;
|
|
62444
62457
|
}
|
|
62445
62458
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -62463,12 +62476,12 @@ async function fetch2(url, options_) {
|
|
|
62463
62476
|
});
|
|
62464
62477
|
}
|
|
62465
62478
|
response = new Response2(body, responseOptions);
|
|
62466
|
-
|
|
62479
|
+
resolve2(response);
|
|
62467
62480
|
});
|
|
62468
62481
|
raw.once("end", () => {
|
|
62469
62482
|
if (!response) {
|
|
62470
62483
|
response = new Response2(body, responseOptions);
|
|
62471
|
-
|
|
62484
|
+
resolve2(response);
|
|
62472
62485
|
}
|
|
62473
62486
|
});
|
|
62474
62487
|
return;
|
|
@@ -62480,11 +62493,11 @@ async function fetch2(url, options_) {
|
|
|
62480
62493
|
}
|
|
62481
62494
|
});
|
|
62482
62495
|
response = new Response2(body, responseOptions);
|
|
62483
|
-
|
|
62496
|
+
resolve2(response);
|
|
62484
62497
|
return;
|
|
62485
62498
|
}
|
|
62486
62499
|
response = new Response2(body, responseOptions);
|
|
62487
|
-
|
|
62500
|
+
resolve2(response);
|
|
62488
62501
|
});
|
|
62489
62502
|
writeToStream(request_, request).catch(reject);
|
|
62490
62503
|
});
|
|
@@ -68607,7 +68620,7 @@ var require_jwtaccess = __commonJS({
|
|
|
68607
68620
|
}
|
|
68608
68621
|
}
|
|
68609
68622
|
fromStreamAsync(inputStream) {
|
|
68610
|
-
return new Promise((
|
|
68623
|
+
return new Promise((resolve2, reject) => {
|
|
68611
68624
|
if (!inputStream) {
|
|
68612
68625
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
68613
68626
|
}
|
|
@@ -68616,7 +68629,7 @@ var require_jwtaccess = __commonJS({
|
|
|
68616
68629
|
try {
|
|
68617
68630
|
const data = JSON.parse(s2);
|
|
68618
68631
|
this.fromJSON(data);
|
|
68619
|
-
|
|
68632
|
+
resolve2();
|
|
68620
68633
|
} catch (err) {
|
|
68621
68634
|
reject(err);
|
|
68622
68635
|
}
|
|
@@ -68856,7 +68869,7 @@ var require_jwtclient = __commonJS({
|
|
|
68856
68869
|
}
|
|
68857
68870
|
}
|
|
68858
68871
|
fromStreamAsync(inputStream) {
|
|
68859
|
-
return new Promise((
|
|
68872
|
+
return new Promise((resolve2, reject) => {
|
|
68860
68873
|
if (!inputStream) {
|
|
68861
68874
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
68862
68875
|
}
|
|
@@ -68865,7 +68878,7 @@ var require_jwtclient = __commonJS({
|
|
|
68865
68878
|
try {
|
|
68866
68879
|
const data = JSON.parse(s2);
|
|
68867
68880
|
this.fromJSON(data);
|
|
68868
|
-
|
|
68881
|
+
resolve2();
|
|
68869
68882
|
} catch (e2) {
|
|
68870
68883
|
reject(e2);
|
|
68871
68884
|
}
|
|
@@ -68999,7 +69012,7 @@ var require_refreshclient = __commonJS({
|
|
|
68999
69012
|
}
|
|
69000
69013
|
}
|
|
69001
69014
|
async fromStreamAsync(inputStream) {
|
|
69002
|
-
return new Promise((
|
|
69015
|
+
return new Promise((resolve2, reject) => {
|
|
69003
69016
|
if (!inputStream) {
|
|
69004
69017
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
69005
69018
|
}
|
|
@@ -69008,7 +69021,7 @@ var require_refreshclient = __commonJS({
|
|
|
69008
69021
|
try {
|
|
69009
69022
|
const data = JSON.parse(s2);
|
|
69010
69023
|
this.fromJSON(data);
|
|
69011
|
-
return
|
|
69024
|
+
return resolve2();
|
|
69012
69025
|
} catch (err) {
|
|
69013
69026
|
return reject(err);
|
|
69014
69027
|
}
|
|
@@ -70854,7 +70867,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
70854
70867
|
* @return A promise that resolves with the executable response.
|
|
70855
70868
|
*/
|
|
70856
70869
|
retrieveResponseFromExecutable(envMap) {
|
|
70857
|
-
return new Promise((
|
|
70870
|
+
return new Promise((resolve2, reject) => {
|
|
70858
70871
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
70859
70872
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
70860
70873
|
});
|
|
@@ -70876,7 +70889,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
70876
70889
|
try {
|
|
70877
70890
|
const responseJson = JSON.parse(output);
|
|
70878
70891
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
70879
|
-
return
|
|
70892
|
+
return resolve2(response);
|
|
70880
70893
|
} catch (error) {
|
|
70881
70894
|
if (error instanceof executable_response_1.ExecutableResponseError) {
|
|
70882
70895
|
return reject(error);
|
|
@@ -72071,7 +72084,7 @@ var require_googleauth = __commonJS({
|
|
|
72071
72084
|
}
|
|
72072
72085
|
}
|
|
72073
72086
|
fromStreamAsync(inputStream, options) {
|
|
72074
|
-
return new Promise((
|
|
72087
|
+
return new Promise((resolve2, reject) => {
|
|
72075
72088
|
if (!inputStream) {
|
|
72076
72089
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
72077
72090
|
}
|
|
@@ -72081,7 +72094,7 @@ var require_googleauth = __commonJS({
|
|
|
72081
72094
|
try {
|
|
72082
72095
|
const data = JSON.parse(chunks.join(""));
|
|
72083
72096
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
72084
|
-
return
|
|
72097
|
+
return resolve2(r2);
|
|
72085
72098
|
} catch (err) {
|
|
72086
72099
|
if (!this.keyFilename)
|
|
72087
72100
|
throw err;
|
|
@@ -72091,7 +72104,7 @@ var require_googleauth = __commonJS({
|
|
|
72091
72104
|
});
|
|
72092
72105
|
this.cachedCredential = client;
|
|
72093
72106
|
this.setGapicJWTValues(client);
|
|
72094
|
-
return
|
|
72107
|
+
return resolve2(client);
|
|
72095
72108
|
}
|
|
72096
72109
|
} catch (err) {
|
|
72097
72110
|
return reject(err);
|
|
@@ -72127,17 +72140,17 @@ var require_googleauth = __commonJS({
|
|
|
72127
72140
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
72128
72141
|
*/
|
|
72129
72142
|
async getDefaultServiceProjectId() {
|
|
72130
|
-
return new Promise((
|
|
72143
|
+
return new Promise((resolve2) => {
|
|
72131
72144
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
|
|
72132
72145
|
if (!err && stdout) {
|
|
72133
72146
|
try {
|
|
72134
72147
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
72135
|
-
|
|
72148
|
+
resolve2(projectId);
|
|
72136
72149
|
return;
|
|
72137
72150
|
} catch (e2) {
|
|
72138
72151
|
}
|
|
72139
72152
|
}
|
|
72140
|
-
|
|
72153
|
+
resolve2(null);
|
|
72141
72154
|
});
|
|
72142
72155
|
});
|
|
72143
72156
|
}
|
|
@@ -75059,7 +75072,7 @@ var require_websocket = __commonJS({
|
|
|
75059
75072
|
var http3 = __require("http");
|
|
75060
75073
|
var net = __require("net");
|
|
75061
75074
|
var tls = __require("tls");
|
|
75062
|
-
var { randomBytes, createHash:
|
|
75075
|
+
var { randomBytes, createHash: createHash15 } = __require("crypto");
|
|
75063
75076
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
75064
75077
|
var { URL: URL2 } = __require("url");
|
|
75065
75078
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -75727,7 +75740,7 @@ var require_websocket = __commonJS({
|
|
|
75727
75740
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
75728
75741
|
return;
|
|
75729
75742
|
}
|
|
75730
|
-
const digest2 =
|
|
75743
|
+
const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
|
|
75731
75744
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
75732
75745
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
75733
75746
|
return;
|
|
@@ -76099,7 +76112,7 @@ var require_websocket_server = __commonJS({
|
|
|
76099
76112
|
var EventEmitter = __require("events");
|
|
76100
76113
|
var http3 = __require("http");
|
|
76101
76114
|
var { Duplex } = __require("stream");
|
|
76102
|
-
var { createHash:
|
|
76115
|
+
var { createHash: createHash15 } = __require("crypto");
|
|
76103
76116
|
var extension3 = require_extension();
|
|
76104
76117
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
76105
76118
|
var subprotocol2 = require_subprotocol();
|
|
@@ -76406,7 +76419,7 @@ var require_websocket_server = __commonJS({
|
|
|
76406
76419
|
);
|
|
76407
76420
|
}
|
|
76408
76421
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
76409
|
-
const digest2 =
|
|
76422
|
+
const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
|
|
76410
76423
|
const headers = [
|
|
76411
76424
|
"HTTP/1.1 101 Switching Protocols",
|
|
76412
76425
|
"Upgrade: websocket",
|
|
@@ -79815,14 +79828,14 @@ function __asyncValues(o) {
|
|
|
79815
79828
|
}, i2);
|
|
79816
79829
|
function verb(n) {
|
|
79817
79830
|
i2[n] = o[n] && function(v) {
|
|
79818
|
-
return new Promise(function(
|
|
79819
|
-
v = o[n](v), settle(
|
|
79831
|
+
return new Promise(function(resolve2, reject) {
|
|
79832
|
+
v = o[n](v), settle(resolve2, reject, v.done, v.value);
|
|
79820
79833
|
});
|
|
79821
79834
|
};
|
|
79822
79835
|
}
|
|
79823
|
-
function settle(
|
|
79836
|
+
function settle(resolve2, reject, d, v) {
|
|
79824
79837
|
Promise.resolve(v).then(function(v2) {
|
|
79825
|
-
|
|
79838
|
+
resolve2({ value: v2, done: d });
|
|
79826
79839
|
}, reject);
|
|
79827
79840
|
}
|
|
79828
79841
|
}
|
|
@@ -90192,8 +90205,8 @@ var init_node = __esm({
|
|
|
90192
90205
|
const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
|
|
90193
90206
|
let onopenResolve = () => {
|
|
90194
90207
|
};
|
|
90195
|
-
const onopenPromise = new Promise((
|
|
90196
|
-
onopenResolve =
|
|
90208
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
90209
|
+
onopenResolve = resolve2;
|
|
90197
90210
|
});
|
|
90198
90211
|
const callbacks = params.callbacks;
|
|
90199
90212
|
const onopenAwaitedCallback = function() {
|
|
@@ -90399,8 +90412,8 @@ var init_node = __esm({
|
|
|
90399
90412
|
}
|
|
90400
90413
|
let onopenResolve = () => {
|
|
90401
90414
|
};
|
|
90402
|
-
const onopenPromise = new Promise((
|
|
90403
|
-
onopenResolve =
|
|
90415
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
90416
|
+
onopenResolve = resolve2;
|
|
90404
90417
|
});
|
|
90405
90418
|
const callbacks = params.callbacks;
|
|
90406
90419
|
const onopenAwaitedCallback = function() {
|
|
@@ -92748,7 +92761,7 @@ var init_node = __esm({
|
|
|
92748
92761
|
return void 0;
|
|
92749
92762
|
}
|
|
92750
92763
|
};
|
|
92751
|
-
sleep$1 = (ms) => new Promise((
|
|
92764
|
+
sleep$1 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
92752
92765
|
FallbackEncoder3 = ({ headers, body }) => {
|
|
92753
92766
|
return {
|
|
92754
92767
|
bodyHeaders: {
|
|
@@ -93257,8 +93270,8 @@ ${underline}`);
|
|
|
93257
93270
|
};
|
|
93258
93271
|
APIPromise3 = class _APIPromise extends Promise {
|
|
93259
93272
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse3) {
|
|
93260
|
-
super((
|
|
93261
|
-
|
|
93273
|
+
super((resolve2) => {
|
|
93274
|
+
resolve2(null);
|
|
93262
93275
|
});
|
|
93263
93276
|
this.responsePromise = responsePromise;
|
|
93264
93277
|
this.parseResponse = parseResponse2;
|
|
@@ -96489,7 +96502,7 @@ function retryIntervalFromResponse(res) {
|
|
|
96489
96502
|
return 0;
|
|
96490
96503
|
}
|
|
96491
96504
|
async function delay(delay2) {
|
|
96492
|
-
return new Promise((
|
|
96505
|
+
return new Promise((resolve2) => setTimeout(resolve2, delay2));
|
|
96493
96506
|
}
|
|
96494
96507
|
var defaultBackoff, PermanentError, TemporaryError, codeRangeRE2;
|
|
96495
96508
|
var init_retries = __esm({
|
|
@@ -134068,12 +134081,12 @@ function capRetryDelayMs(delayMs, options) {
|
|
|
134068
134081
|
return maxRetryDelayMs > 0 ? Math.min(delayMs, maxRetryDelayMs) : delayMs;
|
|
134069
134082
|
}
|
|
134070
134083
|
function sleep4(ms, signal) {
|
|
134071
|
-
return new Promise((
|
|
134084
|
+
return new Promise((resolve2, reject) => {
|
|
134072
134085
|
if (signal?.aborted) {
|
|
134073
134086
|
reject(new Error("Request was aborted"));
|
|
134074
134087
|
return;
|
|
134075
134088
|
}
|
|
134076
|
-
const timeout = setTimeout(
|
|
134089
|
+
const timeout = setTimeout(resolve2, ms);
|
|
134077
134090
|
signal?.addEventListener("abort", () => {
|
|
134078
134091
|
clearTimeout(timeout);
|
|
134079
134092
|
reject(new Error("Request was aborted"));
|
|
@@ -134405,7 +134418,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
134405
134418
|
}
|
|
134406
134419
|
const wsHeaders = headersToRecord(headers);
|
|
134407
134420
|
delete wsHeaders["OpenAI-Beta"];
|
|
134408
|
-
return new Promise((
|
|
134421
|
+
return new Promise((resolve2, reject) => {
|
|
134409
134422
|
let settled = false;
|
|
134410
134423
|
let timeout;
|
|
134411
134424
|
let socket;
|
|
@@ -134440,7 +134453,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
134440
134453
|
return;
|
|
134441
134454
|
settled = true;
|
|
134442
134455
|
cleanup();
|
|
134443
|
-
|
|
134456
|
+
resolve2(socket);
|
|
134444
134457
|
};
|
|
134445
134458
|
const onError = (event) => {
|
|
134446
134459
|
fail2(extractWebSocketError(event));
|
|
@@ -134597,9 +134610,9 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
134597
134610
|
const wake = () => {
|
|
134598
134611
|
if (!pending)
|
|
134599
134612
|
return;
|
|
134600
|
-
const
|
|
134613
|
+
const resolve2 = pending;
|
|
134601
134614
|
pending = null;
|
|
134602
|
-
|
|
134615
|
+
resolve2();
|
|
134603
134616
|
};
|
|
134604
134617
|
const onMessage = (event) => {
|
|
134605
134618
|
void (async () => {
|
|
@@ -134666,8 +134679,8 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
134666
134679
|
if (done)
|
|
134667
134680
|
break;
|
|
134668
134681
|
let timeout;
|
|
134669
|
-
await new Promise((
|
|
134670
|
-
pending =
|
|
134682
|
+
await new Promise((resolve2, reject) => {
|
|
134683
|
+
pending = resolve2;
|
|
134671
134684
|
if (idleTimeoutMs !== void 0 && idleTimeoutMs > 0) {
|
|
134672
134685
|
timeout = setTimeout(() => {
|
|
134673
134686
|
const error = new Error(`WebSocket idle timeout after ${idleTimeoutMs}ms`);
|
|
@@ -145004,6 +145017,8 @@ function rowToFile(row) {
|
|
|
145004
145017
|
...row.sizeBytes != null ? { sizeBytes: row.sizeBytes } : {},
|
|
145005
145018
|
indexedAt: row.indexedAt,
|
|
145006
145019
|
...row.gitCommit ? { gitCommit: row.gitCommit } : {},
|
|
145020
|
+
...row.source ? { source: row.source } : {},
|
|
145021
|
+
...row.parserError ? { parserError: row.parserError } : {},
|
|
145007
145022
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
145008
145023
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
145009
145024
|
};
|
|
@@ -145023,6 +145038,7 @@ function rowToSymbol(row) {
|
|
|
145023
145038
|
...row.contentHash ? { contentHash: row.contentHash } : {},
|
|
145024
145039
|
indexedAt: row.indexedAt,
|
|
145025
145040
|
stale: !!row.stale,
|
|
145041
|
+
...row.source ? { source: row.source } : {},
|
|
145026
145042
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
145027
145043
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
145028
145044
|
};
|
|
@@ -145038,6 +145054,7 @@ function rowToEdge(row) {
|
|
|
145038
145054
|
type: row.type,
|
|
145039
145055
|
confidence: row.confidence,
|
|
145040
145056
|
...row.evidence ? { evidence: row.evidence } : {},
|
|
145057
|
+
...row.source ? { source: row.source } : {},
|
|
145041
145058
|
indexedAt: row.indexedAt,
|
|
145042
145059
|
...row.snapshotId ? { snapshotId: row.snapshotId } : {},
|
|
145043
145060
|
...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
|
|
@@ -145158,9 +145175,9 @@ var init_store = __esm({
|
|
|
145158
145175
|
if (files.length === 0) return;
|
|
145159
145176
|
const stmt = this.db.prepare(`
|
|
145160
145177
|
INSERT OR REPLACE INTO code_files
|
|
145161
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145178
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
145162
145179
|
VALUES
|
|
145163
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145180
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
145164
145181
|
`);
|
|
145165
145182
|
const tx = this.db.transaction((items) => {
|
|
145166
145183
|
for (const file of items) {
|
|
@@ -145173,7 +145190,9 @@ var init_store = __esm({
|
|
|
145173
145190
|
mtimeMs: file.mtimeMs ?? null,
|
|
145174
145191
|
sizeBytes: file.sizeBytes ?? null,
|
|
145175
145192
|
indexedAt: file.indexedAt,
|
|
145176
|
-
gitCommit: file.gitCommit ?? null
|
|
145193
|
+
gitCommit: file.gitCommit ?? null,
|
|
145194
|
+
source: file.source ?? null,
|
|
145195
|
+
parserError: file.parserError ?? null
|
|
145177
145196
|
});
|
|
145178
145197
|
}
|
|
145179
145198
|
});
|
|
@@ -145183,9 +145202,9 @@ var init_store = __esm({
|
|
|
145183
145202
|
if (symbols.length === 0) return;
|
|
145184
145203
|
const stmt = this.db.prepare(`
|
|
145185
145204
|
INSERT OR REPLACE INTO code_symbols
|
|
145186
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145205
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145187
145206
|
VALUES
|
|
145188
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145207
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145189
145208
|
`);
|
|
145190
145209
|
const tx = this.db.transaction((items) => {
|
|
145191
145210
|
for (const symbol of items) {
|
|
@@ -145202,7 +145221,8 @@ var init_store = __esm({
|
|
|
145202
145221
|
signature: symbol.signature ?? null,
|
|
145203
145222
|
contentHash: symbol.contentHash ?? null,
|
|
145204
145223
|
indexedAt: symbol.indexedAt,
|
|
145205
|
-
stale: symbol.stale ? 1 : 0
|
|
145224
|
+
stale: symbol.stale ? 1 : 0,
|
|
145225
|
+
source: symbol.source ?? null
|
|
145206
145226
|
});
|
|
145207
145227
|
}
|
|
145208
145228
|
});
|
|
@@ -145212,9 +145232,9 @@ var init_store = __esm({
|
|
|
145212
145232
|
if (edges.length === 0) return;
|
|
145213
145233
|
const stmt = this.db.prepare(`
|
|
145214
145234
|
INSERT OR REPLACE INTO code_edges
|
|
145215
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145235
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145216
145236
|
VALUES
|
|
145217
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145237
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145218
145238
|
`);
|
|
145219
145239
|
const tx = this.db.transaction((items) => {
|
|
145220
145240
|
for (const edge of items) {
|
|
@@ -145228,7 +145248,8 @@ var init_store = __esm({
|
|
|
145228
145248
|
type: edge.type,
|
|
145229
145249
|
confidence: edge.confidence,
|
|
145230
145250
|
evidence: edge.evidence ?? null,
|
|
145231
|
-
indexedAt: edge.indexedAt
|
|
145251
|
+
indexedAt: edge.indexedAt,
|
|
145252
|
+
source: edge.source ?? null
|
|
145232
145253
|
});
|
|
145233
145254
|
}
|
|
145234
145255
|
});
|
|
@@ -145240,21 +145261,21 @@ var init_store = __esm({
|
|
|
145240
145261
|
const deleteFiles = this.db.prepare(`DELETE FROM code_files WHERE projectId = ?`);
|
|
145241
145262
|
const insertFile = this.db.prepare(`
|
|
145242
145263
|
INSERT OR REPLACE INTO code_files
|
|
145243
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145264
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
145244
145265
|
VALUES
|
|
145245
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145266
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
145246
145267
|
`);
|
|
145247
145268
|
const insertSymbol = this.db.prepare(`
|
|
145248
145269
|
INSERT OR REPLACE INTO code_symbols
|
|
145249
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145270
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145250
145271
|
VALUES
|
|
145251
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145272
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145252
145273
|
`);
|
|
145253
145274
|
const insertEdge = this.db.prepare(`
|
|
145254
145275
|
INSERT OR REPLACE INTO code_edges
|
|
145255
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145276
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145256
145277
|
VALUES
|
|
145257
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145278
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145258
145279
|
`);
|
|
145259
145280
|
const tx = this.db.transaction(() => {
|
|
145260
145281
|
deleteEdges.run(projectId);
|
|
@@ -145270,7 +145291,9 @@ var init_store = __esm({
|
|
|
145270
145291
|
mtimeMs: file.mtimeMs ?? null,
|
|
145271
145292
|
sizeBytes: file.sizeBytes ?? null,
|
|
145272
145293
|
indexedAt: file.indexedAt,
|
|
145273
|
-
gitCommit: file.gitCommit ?? null
|
|
145294
|
+
gitCommit: file.gitCommit ?? null,
|
|
145295
|
+
source: file.source ?? null,
|
|
145296
|
+
parserError: file.parserError ?? null
|
|
145274
145297
|
});
|
|
145275
145298
|
}
|
|
145276
145299
|
for (const symbol of index.symbols) {
|
|
@@ -145287,7 +145310,8 @@ var init_store = __esm({
|
|
|
145287
145310
|
signature: symbol.signature ?? null,
|
|
145288
145311
|
contentHash: symbol.contentHash ?? null,
|
|
145289
145312
|
indexedAt: symbol.indexedAt,
|
|
145290
|
-
stale: 0
|
|
145313
|
+
stale: 0,
|
|
145314
|
+
source: symbol.source ?? null
|
|
145291
145315
|
});
|
|
145292
145316
|
}
|
|
145293
145317
|
for (const edge of index.edges) {
|
|
@@ -145301,7 +145325,8 @@ var init_store = __esm({
|
|
|
145301
145325
|
type: edge.type,
|
|
145302
145326
|
confidence: edge.confidence,
|
|
145303
145327
|
evidence: edge.evidence ?? null,
|
|
145304
|
-
indexedAt: edge.indexedAt
|
|
145328
|
+
indexedAt: edge.indexedAt,
|
|
145329
|
+
source: edge.source ?? null
|
|
145305
145330
|
});
|
|
145306
145331
|
}
|
|
145307
145332
|
});
|
|
@@ -145346,21 +145371,21 @@ var init_store = __esm({
|
|
|
145346
145371
|
const deleteFile = this.db.prepare(`DELETE FROM code_files WHERE projectId = ? AND id = ?`);
|
|
145347
145372
|
const upsertFile = this.db.prepare(`
|
|
145348
145373
|
INSERT OR REPLACE INTO code_files
|
|
145349
|
-
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
|
|
145374
|
+
(id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
|
|
145350
145375
|
VALUES
|
|
145351
|
-
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
|
|
145376
|
+
(@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
|
|
145352
145377
|
`);
|
|
145353
145378
|
const upsertSymbol = this.db.prepare(`
|
|
145354
145379
|
INSERT OR REPLACE INTO code_symbols
|
|
145355
|
-
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
|
|
145380
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145356
145381
|
VALUES
|
|
145357
|
-
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
|
|
145382
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145358
145383
|
`);
|
|
145359
145384
|
const upsertEdge = this.db.prepare(`
|
|
145360
145385
|
INSERT OR REPLACE INTO code_edges
|
|
145361
|
-
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
|
|
145386
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145362
145387
|
VALUES
|
|
145363
|
-
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
|
|
145388
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145364
145389
|
`);
|
|
145365
145390
|
const writeFile5 = (file) => upsertFile.run({
|
|
145366
145391
|
id: file.id,
|
|
@@ -145371,7 +145396,9 @@ var init_store = __esm({
|
|
|
145371
145396
|
mtimeMs: file.mtimeMs ?? null,
|
|
145372
145397
|
sizeBytes: file.sizeBytes ?? null,
|
|
145373
145398
|
indexedAt: file.indexedAt,
|
|
145374
|
-
gitCommit: file.gitCommit ?? null
|
|
145399
|
+
gitCommit: file.gitCommit ?? null,
|
|
145400
|
+
source: file.source ?? null,
|
|
145401
|
+
parserError: file.parserError ?? null
|
|
145375
145402
|
});
|
|
145376
145403
|
const tx = this.db.transaction(() => {
|
|
145377
145404
|
const staleAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -145405,7 +145432,8 @@ var init_store = __esm({
|
|
|
145405
145432
|
signature: symbol.signature ?? null,
|
|
145406
145433
|
contentHash: symbol.contentHash ?? null,
|
|
145407
145434
|
indexedAt: symbol.indexedAt,
|
|
145408
|
-
stale: symbol.stale ? 1 : 0
|
|
145435
|
+
stale: symbol.stale ? 1 : 0,
|
|
145436
|
+
source: symbol.source ?? null
|
|
145409
145437
|
});
|
|
145410
145438
|
}
|
|
145411
145439
|
for (const edge of delta.edges) {
|
|
@@ -145419,7 +145447,8 @@ var init_store = __esm({
|
|
|
145419
145447
|
type: edge.type,
|
|
145420
145448
|
confidence: edge.confidence,
|
|
145421
145449
|
evidence: edge.evidence ?? null,
|
|
145422
|
-
indexedAt: edge.indexedAt
|
|
145450
|
+
indexedAt: edge.indexedAt,
|
|
145451
|
+
source: edge.source ?? null
|
|
145423
145452
|
});
|
|
145424
145453
|
}
|
|
145425
145454
|
}
|
|
@@ -145567,6 +145596,202 @@ var init_store = __esm({
|
|
|
145567
145596
|
listEdges(projectId) {
|
|
145568
145597
|
return this.db.prepare(`SELECT * FROM code_edges WHERE projectId = ? ORDER BY type, id`).all(projectId).map(rowToEdge);
|
|
145569
145598
|
}
|
|
145599
|
+
/** Return direct importers before a refresh clears their old target IDs. */
|
|
145600
|
+
listImportDependentPaths(projectId, paths, candidatePaths = []) {
|
|
145601
|
+
const normalized = [...new Set(paths.map(normalizeCodePath).filter(Boolean))];
|
|
145602
|
+
if (normalized.length === 0) return [];
|
|
145603
|
+
const files = this.listFiles(projectId);
|
|
145604
|
+
const fileIds = files.filter((file) => normalized.includes(file.path)).map((file) => file.id);
|
|
145605
|
+
const fileById = new Map(files.map((file) => [file.id, file]));
|
|
145606
|
+
const fileByPath = new Map(files.map((file) => [file.path, file]));
|
|
145607
|
+
for (const path22 of candidatePaths.map(normalizeCodePath).filter(Boolean)) {
|
|
145608
|
+
if (!fileByPath.has(path22)) {
|
|
145609
|
+
fileByPath.set(path22, {
|
|
145610
|
+
id: `candidate:${path22}`,
|
|
145611
|
+
projectId,
|
|
145612
|
+
path: path22,
|
|
145613
|
+
contentHash: "",
|
|
145614
|
+
indexedAt: ""
|
|
145615
|
+
});
|
|
145616
|
+
}
|
|
145617
|
+
}
|
|
145618
|
+
const rows = this.db.prepare(`
|
|
145619
|
+
SELECT DISTINCT fromFileId, evidence
|
|
145620
|
+
FROM code_edges
|
|
145621
|
+
WHERE projectId = ? AND type = 'imports'
|
|
145622
|
+
`).all(projectId);
|
|
145623
|
+
const wanted = new Set(normalized);
|
|
145624
|
+
const dependents = /* @__PURE__ */ new Set();
|
|
145625
|
+
const queue = [...normalized];
|
|
145626
|
+
while (queue.length > 0) {
|
|
145627
|
+
const targetPath = queue.shift();
|
|
145628
|
+
for (const row of rows) {
|
|
145629
|
+
const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
|
|
145630
|
+
if (!source || source.path === targetPath || dependents.has(source.path)) continue;
|
|
145631
|
+
const target = resolveRelativeImportTarget(source.path, row.evidence, fileByPath);
|
|
145632
|
+
if (!target || !wanted.has(target.path)) continue;
|
|
145633
|
+
dependents.add(source.path);
|
|
145634
|
+
if (!wanted.has(source.path)) {
|
|
145635
|
+
wanted.add(source.path);
|
|
145636
|
+
queue.push(source.path);
|
|
145637
|
+
}
|
|
145638
|
+
}
|
|
145639
|
+
}
|
|
145640
|
+
if (fileIds.length > 0) {
|
|
145641
|
+
const placeholders = fileIds.map(() => "?").join(", ");
|
|
145642
|
+
const exactRows = this.db.prepare(`
|
|
145643
|
+
SELECT DISTINCT fromFileId
|
|
145644
|
+
FROM code_edges
|
|
145645
|
+
WHERE projectId = ? AND type = 'imports' AND toFileId IN (${placeholders})
|
|
145646
|
+
`).all(projectId, ...fileIds);
|
|
145647
|
+
for (const row of exactRows) {
|
|
145648
|
+
const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
|
|
145649
|
+
if (source) dependents.add(source.path);
|
|
145650
|
+
}
|
|
145651
|
+
}
|
|
145652
|
+
return [...dependents].sort();
|
|
145653
|
+
}
|
|
145654
|
+
/** Replace only the semantic slice touched by a change, in one transaction. */
|
|
145655
|
+
replaceSemanticSlice(projectId, affectedPaths, input) {
|
|
145656
|
+
const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
|
|
145657
|
+
if (normalizedPaths.length === 0) return;
|
|
145658
|
+
const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
|
|
145659
|
+
const fileIds = fileRows.map((file) => file.id);
|
|
145660
|
+
const placeholders = fileIds.map(() => "?").join(", ");
|
|
145661
|
+
if (fileIds.length === 0) return;
|
|
145662
|
+
const staleRefs = this.db.prepare(`
|
|
145663
|
+
UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
|
|
145664
|
+
WHERE projectId = ? AND (fileId IN (${placeholders}) OR symbolId IN (
|
|
145665
|
+
SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})
|
|
145666
|
+
))
|
|
145667
|
+
`);
|
|
145668
|
+
const deleteEdges = this.db.prepare(`
|
|
145669
|
+
DELETE FROM code_edges
|
|
145670
|
+
WHERE projectId = ? AND (source IS NULL OR source IN ('lite-regex', 'typescript-compiler'))
|
|
145671
|
+
AND (fromFileId IN (${placeholders}) OR toFileId IN (${placeholders})
|
|
145672
|
+
OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders}))
|
|
145673
|
+
OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})))
|
|
145674
|
+
`);
|
|
145675
|
+
const deleteSymbols = this.db.prepare(`DELETE FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})`);
|
|
145676
|
+
const updateFile = this.db.prepare("UPDATE code_files SET source = ?, parserError = ? WHERE projectId = ? AND id = ?");
|
|
145677
|
+
const insertSymbol = this.db.prepare(`
|
|
145678
|
+
INSERT OR REPLACE INTO code_symbols
|
|
145679
|
+
(id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
|
|
145680
|
+
VALUES
|
|
145681
|
+
(@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
|
|
145682
|
+
`);
|
|
145683
|
+
const insertEdge = this.db.prepare(`
|
|
145684
|
+
INSERT OR REPLACE INTO code_edges
|
|
145685
|
+
(id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
|
|
145686
|
+
VALUES
|
|
145687
|
+
(@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
|
|
145688
|
+
`);
|
|
145689
|
+
const diagnosticsByPath = new Map((input.diagnostics ?? []).map((item) => [normalizeCodePath(item.path), item.message]));
|
|
145690
|
+
const symbolFileIds = new Set(fileIds);
|
|
145691
|
+
const tx = this.db.transaction(() => {
|
|
145692
|
+
const now3 = (/* @__PURE__ */ new Date()).toISOString();
|
|
145693
|
+
staleRefs.run(now3, projectId, ...fileIds, projectId, ...fileIds);
|
|
145694
|
+
deleteEdges.run(projectId, ...fileIds, ...fileIds, projectId, ...fileIds, projectId, ...fileIds);
|
|
145695
|
+
deleteSymbols.run(projectId, ...fileIds);
|
|
145696
|
+
for (const file of fileRows) {
|
|
145697
|
+
const diagnostic = diagnosticsByPath.get(file.path);
|
|
145698
|
+
updateFile.run(diagnostic ? "typescript-compiler" : "typescript-compiler", diagnostic ?? null, projectId, file.id);
|
|
145699
|
+
}
|
|
145700
|
+
for (const symbol of input.symbols.filter((symbol2) => symbolFileIds.has(symbol2.fileId))) {
|
|
145701
|
+
insertSymbol.run({
|
|
145702
|
+
id: symbol.id,
|
|
145703
|
+
projectId: symbol.projectId,
|
|
145704
|
+
fileId: symbol.fileId,
|
|
145705
|
+
path: normalizeCodePath(symbol.path),
|
|
145706
|
+
name: symbol.name,
|
|
145707
|
+
qualifiedName: symbol.qualifiedName,
|
|
145708
|
+
kind: symbol.kind,
|
|
145709
|
+
startLine: symbol.startLine ?? null,
|
|
145710
|
+
endLine: symbol.endLine ?? null,
|
|
145711
|
+
signature: symbol.signature ?? null,
|
|
145712
|
+
contentHash: symbol.contentHash ?? null,
|
|
145713
|
+
indexedAt: symbol.indexedAt,
|
|
145714
|
+
stale: symbol.stale ? 1 : 0,
|
|
145715
|
+
source: symbol.source ?? "typescript-compiler"
|
|
145716
|
+
});
|
|
145717
|
+
}
|
|
145718
|
+
for (const edge of input.edges) {
|
|
145719
|
+
insertEdge.run({
|
|
145720
|
+
id: edge.id,
|
|
145721
|
+
projectId: edge.projectId,
|
|
145722
|
+
fromSymbolId: edge.fromSymbolId ?? null,
|
|
145723
|
+
toSymbolId: edge.toSymbolId ?? null,
|
|
145724
|
+
fromFileId: edge.fromFileId ?? null,
|
|
145725
|
+
toFileId: edge.toFileId ?? null,
|
|
145726
|
+
type: edge.type,
|
|
145727
|
+
confidence: edge.confidence,
|
|
145728
|
+
evidence: edge.evidence ?? null,
|
|
145729
|
+
indexedAt: edge.indexedAt,
|
|
145730
|
+
source: edge.source ?? "typescript-compiler"
|
|
145731
|
+
});
|
|
145732
|
+
}
|
|
145733
|
+
});
|
|
145734
|
+
tx();
|
|
145735
|
+
}
|
|
145736
|
+
/** Record a semantic refresh failure without presenting the old facts as current. */
|
|
145737
|
+
markSemanticSliceFailed(projectId, affectedPaths, message) {
|
|
145738
|
+
const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
|
|
145739
|
+
const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
|
|
145740
|
+
const fileIds = fileRows.map((file) => file.id);
|
|
145741
|
+
const filePlaceholders = fileIds.map(() => "?").join(", ");
|
|
145742
|
+
const staleRefs = fileIds.length > 0 ? this.db.prepare(`
|
|
145743
|
+
UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
|
|
145744
|
+
WHERE projectId = ? AND (fileId IN (${filePlaceholders}) OR symbolId IN (
|
|
145745
|
+
SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders})
|
|
145746
|
+
))
|
|
145747
|
+
`) : void 0;
|
|
145748
|
+
const staleSymbols = fileIds.length > 0 ? this.db.prepare(`
|
|
145749
|
+
UPDATE code_symbols SET stale = 1
|
|
145750
|
+
WHERE projectId = ? AND source = 'typescript-compiler' AND fileId IN (${filePlaceholders})
|
|
145751
|
+
`) : void 0;
|
|
145752
|
+
const updateFiles = fileIds.length > 0 ? this.db.prepare(`
|
|
145753
|
+
UPDATE code_files SET parserError = ?
|
|
145754
|
+
WHERE projectId = ? AND id IN (${filePlaceholders})
|
|
145755
|
+
`) : void 0;
|
|
145756
|
+
const affectedEdgeClause = fileIds.length > 0 ? `
|
|
145757
|
+
OR fromFileId IN (${filePlaceholders})
|
|
145758
|
+
OR toFileId IN (${filePlaceholders})
|
|
145759
|
+
OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
|
|
145760
|
+
OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
|
|
145761
|
+
` : "";
|
|
145762
|
+
const deleteEdges = this.db.prepare(`
|
|
145763
|
+
DELETE FROM code_edges
|
|
145764
|
+
WHERE projectId = ? AND source = 'typescript-compiler'
|
|
145765
|
+
AND (
|
|
145766
|
+
(fromSymbolId IS NOT NULL AND NOT EXISTS (
|
|
145767
|
+
SELECT 1 FROM code_symbols WHERE projectId = ? AND id = fromSymbolId
|
|
145768
|
+
))
|
|
145769
|
+
OR (toSymbolId IS NOT NULL AND NOT EXISTS (
|
|
145770
|
+
SELECT 1 FROM code_symbols WHERE projectId = ? AND id = toSymbolId
|
|
145771
|
+
))
|
|
145772
|
+
${affectedEdgeClause}
|
|
145773
|
+
)
|
|
145774
|
+
`);
|
|
145775
|
+
const tx = this.db.transaction(() => {
|
|
145776
|
+
const failure = `semantic indexing failed: ${message.slice(0, 500)}`;
|
|
145777
|
+
if (updateFiles) updateFiles.run(failure, projectId, ...fileIds);
|
|
145778
|
+
if (staleRefs) staleRefs.run((/* @__PURE__ */ new Date()).toISOString(), projectId, ...fileIds, projectId, ...fileIds);
|
|
145779
|
+
if (staleSymbols) staleSymbols.run(projectId, ...fileIds);
|
|
145780
|
+
const edgeParams = [projectId, projectId, projectId];
|
|
145781
|
+
if (fileIds.length > 0) {
|
|
145782
|
+
edgeParams.push(
|
|
145783
|
+
...fileIds,
|
|
145784
|
+
...fileIds,
|
|
145785
|
+
projectId,
|
|
145786
|
+
...fileIds,
|
|
145787
|
+
projectId,
|
|
145788
|
+
...fileIds
|
|
145789
|
+
);
|
|
145790
|
+
}
|
|
145791
|
+
deleteEdges.run(...edgeParams);
|
|
145792
|
+
});
|
|
145793
|
+
tx();
|
|
145794
|
+
}
|
|
145570
145795
|
listObservationRefs(projectId, observationId2) {
|
|
145571
145796
|
return this.db.prepare(`
|
|
145572
145797
|
SELECT * FROM observation_code_refs
|
|
@@ -145768,6 +145993,9 @@ var init_store = __esm({
|
|
|
145768
145993
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
145769
145994
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
145770
145995
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
145996
|
+
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
145997
|
+
const semanticEdges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ? AND source = 'typescript-compiler'`).get(projectId).count;
|
|
145998
|
+
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
145771
145999
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
145772
146000
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
145773
146001
|
return {
|
|
@@ -145776,6 +146004,9 @@ var init_store = __esm({
|
|
|
145776
146004
|
symbols,
|
|
145777
146005
|
edges,
|
|
145778
146006
|
refs,
|
|
146007
|
+
semanticSymbols,
|
|
146008
|
+
semanticEdges,
|
|
146009
|
+
parserErrors,
|
|
145779
146010
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
145780
146011
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
145781
146012
|
};
|
|
@@ -145908,6 +146139,350 @@ var init_exclude3 = __esm({
|
|
|
145908
146139
|
}
|
|
145909
146140
|
});
|
|
145910
146141
|
|
|
146142
|
+
// src/codegraph/semantic-provider.ts
|
|
146143
|
+
import { createHash as createHash8 } from "crypto";
|
|
146144
|
+
import "fs";
|
|
146145
|
+
import { resolve } from "path";
|
|
146146
|
+
import ts from "typescript";
|
|
146147
|
+
function hashText(value) {
|
|
146148
|
+
return createHash8("sha256").update(value).digest("hex");
|
|
146149
|
+
}
|
|
146150
|
+
function canonicalPath(value) {
|
|
146151
|
+
const normalized = resolve(value).replace(/\\/g, "/");
|
|
146152
|
+
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
146153
|
+
}
|
|
146154
|
+
function isInside(root, candidate) {
|
|
146155
|
+
const rootPath = canonicalPath(root).replace(/\/$/, "");
|
|
146156
|
+
const candidatePath = canonicalPath(candidate);
|
|
146157
|
+
return candidatePath === rootPath || candidatePath.startsWith(`${rootPath}/`);
|
|
146158
|
+
}
|
|
146159
|
+
function scriptKind(path22) {
|
|
146160
|
+
if (path22.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
146161
|
+
if (path22.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
146162
|
+
if (path22.endsWith(".json")) return ts.ScriptKind.JSON;
|
|
146163
|
+
if (path22.endsWith(".js") || path22.endsWith(".mjs") || path22.endsWith(".cjs")) return ts.ScriptKind.JS;
|
|
146164
|
+
return ts.ScriptKind.TS;
|
|
146165
|
+
}
|
|
146166
|
+
function isTestPath(path22) {
|
|
146167
|
+
return /(^|[/\\])__tests__([/\\])|(?:\.test|\.spec)\.[^.]+$/i.test(path22);
|
|
146168
|
+
}
|
|
146169
|
+
function declarationName(node) {
|
|
146170
|
+
const named = node;
|
|
146171
|
+
const name = named.name;
|
|
146172
|
+
return name && ts.isIdentifier(name) ? name.text : void 0;
|
|
146173
|
+
}
|
|
146174
|
+
function symbolKind(node) {
|
|
146175
|
+
if (ts.isFunctionDeclaration(node)) return "function";
|
|
146176
|
+
if (ts.isClassDeclaration(node)) return "class";
|
|
146177
|
+
if (ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isConstructorDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)) return "method";
|
|
146178
|
+
if (ts.isInterfaceDeclaration(node)) return "interface";
|
|
146179
|
+
if (ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) return "type";
|
|
146180
|
+
if (ts.isEnumMember(node)) return "constant";
|
|
146181
|
+
if (ts.isPropertyDeclaration(node) || ts.isPropertySignature(node)) return "property";
|
|
146182
|
+
if (ts.isVariableDeclaration(node)) return node.initializer && (ts.isFunctionExpression(node.initializer) || ts.isArrowFunction(node.initializer)) ? "function" : "constant";
|
|
146183
|
+
return void 0;
|
|
146184
|
+
}
|
|
146185
|
+
function isDeclarationNode(node) {
|
|
146186
|
+
return Boolean(symbolKind(node) && declarationName(node));
|
|
146187
|
+
}
|
|
146188
|
+
function qualifiedName(node, name, ordinalByKey) {
|
|
146189
|
+
const parts = [name];
|
|
146190
|
+
let parent = node.parent;
|
|
146191
|
+
while (parent && !ts.isSourceFile(parent)) {
|
|
146192
|
+
if (isDeclarationNode(parent)) {
|
|
146193
|
+
const parentName = declarationName(parent);
|
|
146194
|
+
if (parentName) parts.unshift(parentName);
|
|
146195
|
+
}
|
|
146196
|
+
parent = parent.parent;
|
|
146197
|
+
}
|
|
146198
|
+
const base = parts.join("::");
|
|
146199
|
+
const key = `${base}
|
|
146200
|
+
${symbolKind(node)}`;
|
|
146201
|
+
const ordinal = ordinalByKey.get(key) ?? 0;
|
|
146202
|
+
ordinalByKey.set(key, ordinal + 1);
|
|
146203
|
+
return ordinal === 0 ? base : `${base}#${ordinal + 1}`;
|
|
146204
|
+
}
|
|
146205
|
+
function lineAt(sourceFile, position) {
|
|
146206
|
+
return sourceFile.getLineAndCharacterOfPosition(position).line + 1;
|
|
146207
|
+
}
|
|
146208
|
+
function signatureFor(checker, node, sourceFile) {
|
|
146209
|
+
const signature = ts.isFunctionLike(node) ? checker.getSignatureFromDeclaration(node) : void 0;
|
|
146210
|
+
if (signature) {
|
|
146211
|
+
try {
|
|
146212
|
+
return checker.signatureToString(signature, node, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope).slice(0, 240);
|
|
146213
|
+
} catch {
|
|
146214
|
+
}
|
|
146215
|
+
}
|
|
146216
|
+
const text2 = sourceFile.text.slice(node.getStart(sourceFile), Math.min(node.end, node.getStart(sourceFile) + 240));
|
|
146217
|
+
return text2.replace(/\s+/g, " ").trim() || void 0;
|
|
146218
|
+
}
|
|
146219
|
+
function makeCompilerOptions(projectRoot) {
|
|
146220
|
+
const configPath = ts.findConfigFile(projectRoot, ts.sys.fileExists, "tsconfig.json");
|
|
146221
|
+
let options = {
|
|
146222
|
+
allowJs: true,
|
|
146223
|
+
checkJs: false,
|
|
146224
|
+
noEmit: true,
|
|
146225
|
+
noLib: true,
|
|
146226
|
+
skipLibCheck: true,
|
|
146227
|
+
module: ts.ModuleKind.ESNext,
|
|
146228
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
146229
|
+
target: ts.ScriptTarget.ES2022,
|
|
146230
|
+
jsx: ts.JsxEmit.Preserve,
|
|
146231
|
+
types: []
|
|
146232
|
+
};
|
|
146233
|
+
if (configPath) {
|
|
146234
|
+
try {
|
|
146235
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
146236
|
+
if (!config.error) {
|
|
146237
|
+
const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, projectRoot);
|
|
146238
|
+
options = { ...options, ...parsed.options, noEmit: true, noLib: true, skipLibCheck: true, allowJs: true, checkJs: false, types: [] };
|
|
146239
|
+
}
|
|
146240
|
+
} catch {
|
|
146241
|
+
}
|
|
146242
|
+
}
|
|
146243
|
+
return options;
|
|
146244
|
+
}
|
|
146245
|
+
function resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedFileName) {
|
|
146246
|
+
if (!resolvedFileName || !isInside(projectRoot, resolvedFileName)) return void 0;
|
|
146247
|
+
return filesByCanonicalPath.get(canonicalPath(resolvedFileName));
|
|
146248
|
+
}
|
|
146249
|
+
function isSemanticLanguage(language) {
|
|
146250
|
+
return Boolean(language && SUPPORTED_LANGUAGES.has(language));
|
|
146251
|
+
}
|
|
146252
|
+
function buildTypeScriptSemanticIndex(input) {
|
|
146253
|
+
const started = Date.now();
|
|
146254
|
+
const semanticFiles = input.files.filter((file) => isSemanticLanguage(file.language) && !isCodeGraphExcludedPath(file.path, input.exclude));
|
|
146255
|
+
if (semanticFiles.length === 0) {
|
|
146256
|
+
return { symbols: [], edges: [], parsedFiles: 0, parserErrors: 0, unresolvedCalls: 0, durationMs: Date.now() - started, diagnostics: [] };
|
|
146257
|
+
}
|
|
146258
|
+
const projectRoot = resolve(input.projectRoot);
|
|
146259
|
+
const filesByCanonicalPath = new Map(semanticFiles.map((file) => [canonicalPath(resolve(projectRoot, file.path)), file]));
|
|
146260
|
+
const includePaths = input.includePaths ? new Set(input.includePaths.map(normalizeCodePath)) : void 0;
|
|
146261
|
+
const includedFileIds = new Set(
|
|
146262
|
+
semanticFiles.filter((file) => !includePaths || includePaths.has(normalizeCodePath(file.path))).map((file) => file.id)
|
|
146263
|
+
);
|
|
146264
|
+
const rootNames = semanticFiles.map((file) => resolve(projectRoot, file.path));
|
|
146265
|
+
const baseHost = ts.createCompilerHost(makeCompilerOptions(projectRoot), true);
|
|
146266
|
+
const compilerOptions = makeCompilerOptions(projectRoot);
|
|
146267
|
+
const host = {
|
|
146268
|
+
...baseHost,
|
|
146269
|
+
getCurrentDirectory: () => projectRoot,
|
|
146270
|
+
fileExists: (fileName) => isInside(projectRoot, fileName) && baseHost.fileExists(fileName),
|
|
146271
|
+
readFile: (fileName) => isInside(projectRoot, fileName) ? baseHost.readFile(fileName) : void 0,
|
|
146272
|
+
realpath: (fileName) => fileName,
|
|
146273
|
+
getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
|
|
146274
|
+
if (!isInside(projectRoot, fileName)) return void 0;
|
|
146275
|
+
const text2 = baseHost.readFile(fileName);
|
|
146276
|
+
if (text2 === void 0) return void 0;
|
|
146277
|
+
return ts.createSourceFile(fileName, text2, languageVersion, true, scriptKind(fileName));
|
|
146278
|
+
}
|
|
146279
|
+
};
|
|
146280
|
+
const program = ts.createProgram({ rootNames, options: compilerOptions, host });
|
|
146281
|
+
const checker = program.getTypeChecker();
|
|
146282
|
+
const symbols = [];
|
|
146283
|
+
const allSymbols = [];
|
|
146284
|
+
const declarationToRecord = /* @__PURE__ */ new Map();
|
|
146285
|
+
const checkerToRecord = /* @__PURE__ */ new Map();
|
|
146286
|
+
const declarationNameNodes = /* @__PURE__ */ new Set();
|
|
146287
|
+
const ordinalByKey = /* @__PURE__ */ new Map();
|
|
146288
|
+
const sourceFiles = program.getSourceFiles().filter((sourceFile) => filesByCanonicalPath.has(canonicalPath(sourceFile.fileName)));
|
|
146289
|
+
for (const sourceFile of sourceFiles) {
|
|
146290
|
+
const file = filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
|
|
146291
|
+
if (!file) continue;
|
|
146292
|
+
const visitDeclarations = (node) => {
|
|
146293
|
+
if (isDeclarationNode(node)) {
|
|
146294
|
+
const name = declarationName(node);
|
|
146295
|
+
const kind = symbolKind(node);
|
|
146296
|
+
if (name && kind) {
|
|
146297
|
+
const qName = qualifiedName(node, name, ordinalByKey);
|
|
146298
|
+
const start = node.getStart(sourceFile);
|
|
146299
|
+
const symbol = {
|
|
146300
|
+
id: makeCodeSymbolId({ projectId: input.projectId, path: file.path, qualifiedName: qName, kind }),
|
|
146301
|
+
projectId: input.projectId,
|
|
146302
|
+
fileId: file.id || makeCodeFileId(input.projectId, file.path),
|
|
146303
|
+
path: file.path,
|
|
146304
|
+
name,
|
|
146305
|
+
qualifiedName: qName,
|
|
146306
|
+
kind,
|
|
146307
|
+
startLine: lineAt(sourceFile, start),
|
|
146308
|
+
endLine: lineAt(sourceFile, node.end),
|
|
146309
|
+
signature: signatureFor(checker, node, sourceFile),
|
|
146310
|
+
contentHash: hashText(sourceFile.text.slice(start, node.end)),
|
|
146311
|
+
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
146312
|
+
source: SEMANTIC_SOURCE
|
|
146313
|
+
};
|
|
146314
|
+
const namedNode = node;
|
|
146315
|
+
const checkerSymbol = namedNode.name ? checker.getSymbolAtLocation(namedNode.name) : void 0;
|
|
146316
|
+
const record80 = { node, symbol, ...checkerSymbol ? { checkerSymbol } : {} };
|
|
146317
|
+
allSymbols.push(symbol);
|
|
146318
|
+
if (!includePaths || includePaths.has(normalizeCodePath(file.path))) symbols.push(symbol);
|
|
146319
|
+
declarationToRecord.set(node, record80);
|
|
146320
|
+
if (checkerSymbol) {
|
|
146321
|
+
checkerToRecord.set(checkerSymbol, record80);
|
|
146322
|
+
for (const declaration of checkerSymbol.declarations ?? []) declarationToRecord.set(declaration, record80);
|
|
146323
|
+
}
|
|
146324
|
+
if (namedNode.name) declarationNameNodes.add(namedNode.name);
|
|
146325
|
+
}
|
|
146326
|
+
}
|
|
146327
|
+
node.forEachChild(visitDeclarations);
|
|
146328
|
+
};
|
|
146329
|
+
visitDeclarations(sourceFile);
|
|
146330
|
+
}
|
|
146331
|
+
const edges = /* @__PURE__ */ new Map();
|
|
146332
|
+
const addEdge = (inputEdge) => {
|
|
146333
|
+
const from = inputEdge.fromSymbolId ?? inputEdge.fromFileId ?? "";
|
|
146334
|
+
const to = inputEdge.toSymbolId ?? inputEdge.toFileId ?? (inputEdge.type === "imports" && inputEdge.evidence ? `unresolved:${inputEdge.evidence}` : "");
|
|
146335
|
+
if (!from || !to) return;
|
|
146336
|
+
if (includePaths) {
|
|
146337
|
+
const endpointFileIds = /* @__PURE__ */ new Set();
|
|
146338
|
+
if (inputEdge.fromFileId) endpointFileIds.add(inputEdge.fromFileId);
|
|
146339
|
+
if (inputEdge.toFileId) endpointFileIds.add(inputEdge.toFileId);
|
|
146340
|
+
for (const symbol of allSymbols) {
|
|
146341
|
+
if (symbol.id === inputEdge.fromSymbolId || symbol.id === inputEdge.toSymbolId) endpointFileIds.add(symbol.fileId);
|
|
146342
|
+
}
|
|
146343
|
+
if (![...endpointFileIds].some((fileId) => includedFileIds.has(fileId))) return;
|
|
146344
|
+
}
|
|
146345
|
+
const id = makeCodeEdgeId(input.projectId, from, inputEdge.type, to);
|
|
146346
|
+
if (edges.has(id)) return;
|
|
146347
|
+
edges.set(id, {
|
|
146348
|
+
...inputEdge,
|
|
146349
|
+
id,
|
|
146350
|
+
projectId: input.projectId,
|
|
146351
|
+
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
146352
|
+
source: SEMANTIC_SOURCE
|
|
146353
|
+
});
|
|
146354
|
+
};
|
|
146355
|
+
const resolveRecord = (symbol) => {
|
|
146356
|
+
if (!symbol) return void 0;
|
|
146357
|
+
let target = symbol;
|
|
146358
|
+
if (target.flags & ts.SymbolFlags.Alias) {
|
|
146359
|
+
try {
|
|
146360
|
+
target = checker.getAliasedSymbol(target);
|
|
146361
|
+
} catch {
|
|
146362
|
+
}
|
|
146363
|
+
}
|
|
146364
|
+
return checkerToRecord.get(target) ?? (target.declarations ?? []).map((declaration) => declarationToRecord.get(declaration)).find(Boolean);
|
|
146365
|
+
};
|
|
146366
|
+
const currentRecord = (node) => {
|
|
146367
|
+
let parent = node;
|
|
146368
|
+
while (parent) {
|
|
146369
|
+
const record80 = declarationToRecord.get(parent);
|
|
146370
|
+
if (record80) return record80;
|
|
146371
|
+
parent = parent.parent;
|
|
146372
|
+
}
|
|
146373
|
+
return void 0;
|
|
146374
|
+
};
|
|
146375
|
+
const fileForSource = (sourceFile) => filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
|
|
146376
|
+
const addFileRelation = (sourceFile, target, type, node, evidence) => {
|
|
146377
|
+
const source = fileForSource(sourceFile);
|
|
146378
|
+
if (!source || source.id === target?.id) return;
|
|
146379
|
+
addEdge({
|
|
146380
|
+
fromFileId: source.id,
|
|
146381
|
+
...target ? { toFileId: target.id } : {},
|
|
146382
|
+
type,
|
|
146383
|
+
confidence: target ? 0.99 : 0.55,
|
|
146384
|
+
evidence: evidence ?? `${type} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146385
|
+
});
|
|
146386
|
+
};
|
|
146387
|
+
const moduleTarget = (sourceFile, moduleName) => {
|
|
146388
|
+
const resolvedModule = ts.resolveModuleName(moduleName, sourceFile.fileName, compilerOptions, host).resolvedModule;
|
|
146389
|
+
return resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedModule?.resolvedFileName);
|
|
146390
|
+
};
|
|
146391
|
+
let unresolvedCalls = 0;
|
|
146392
|
+
for (const sourceFile of sourceFiles) {
|
|
146393
|
+
const file = fileForSource(sourceFile);
|
|
146394
|
+
if (!file) continue;
|
|
146395
|
+
const visit = (node) => {
|
|
146396
|
+
const owner = currentRecord(node);
|
|
146397
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
146398
|
+
addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "imports", node, `imports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
|
|
146399
|
+
} else if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
146400
|
+
addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "exports", node, `exports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
|
|
146401
|
+
} else if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
146402
|
+
const signature = checker.getResolvedSignature(node);
|
|
146403
|
+
const declarationNameNode = signature?.declaration ? signature.declaration.name : void 0;
|
|
146404
|
+
const target = resolveRecord(declarationNameNode ? checker.getSymbolAtLocation(declarationNameNode) : void 0) ?? (signature?.declaration ? declarationToRecord.get(signature.declaration) : void 0) ?? resolveRecord(checker.getSymbolAtLocation(node.expression));
|
|
146405
|
+
if (target) {
|
|
146406
|
+
const from = owner?.symbol.id;
|
|
146407
|
+
addEdge({
|
|
146408
|
+
...from ? { fromSymbolId: from } : { fromFileId: file.id },
|
|
146409
|
+
toSymbolId: target.symbol.id,
|
|
146410
|
+
type: "calls",
|
|
146411
|
+
confidence: 0.98,
|
|
146412
|
+
evidence: `resolved call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146413
|
+
});
|
|
146414
|
+
if (isTestPath(file.path)) {
|
|
146415
|
+
addEdge({
|
|
146416
|
+
...from ? { fromSymbolId: from } : { fromFileId: file.id },
|
|
146417
|
+
toSymbolId: target.symbol.id,
|
|
146418
|
+
type: "tests",
|
|
146419
|
+
confidence: 0.97,
|
|
146420
|
+
evidence: `resolved test call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146421
|
+
});
|
|
146422
|
+
}
|
|
146423
|
+
} else {
|
|
146424
|
+
unresolvedCalls++;
|
|
146425
|
+
}
|
|
146426
|
+
} else if (ts.isIdentifier(node) && !declarationNameNodes.has(node) && !ts.isImportSpecifier(node.parent) && !ts.isExportSpecifier(node.parent)) {
|
|
146427
|
+
const target = resolveRecord(checker.getSymbolAtLocation(node));
|
|
146428
|
+
if (target) {
|
|
146429
|
+
addEdge({
|
|
146430
|
+
...owner?.symbol.id ? { fromSymbolId: owner.symbol.id } : { fromFileId: file.id },
|
|
146431
|
+
toSymbolId: target.symbol.id,
|
|
146432
|
+
type: "references",
|
|
146433
|
+
confidence: 0.95,
|
|
146434
|
+
evidence: `resolved reference at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
|
|
146435
|
+
});
|
|
146436
|
+
}
|
|
146437
|
+
} else if (ts.isHeritageClause(node)) {
|
|
146438
|
+
const ownerRecord = currentRecord(node);
|
|
146439
|
+
for (const type of node.types) {
|
|
146440
|
+
const target = resolveRecord(checker.getSymbolAtLocation(type.expression));
|
|
146441
|
+
if (ownerRecord && target) {
|
|
146442
|
+
addEdge({
|
|
146443
|
+
fromSymbolId: ownerRecord.symbol.id,
|
|
146444
|
+
toSymbolId: target.symbol.id,
|
|
146445
|
+
type: node.token === ts.SyntaxKind.ExtendsKeyword ? "extends" : "implements",
|
|
146446
|
+
confidence: 0.99,
|
|
146447
|
+
evidence: `compiler-resolved heritage at line ${lineAt(sourceFile, type.getStart(sourceFile))}`
|
|
146448
|
+
});
|
|
146449
|
+
}
|
|
146450
|
+
}
|
|
146451
|
+
}
|
|
146452
|
+
node.forEachChild(visit);
|
|
146453
|
+
};
|
|
146454
|
+
visit(sourceFile);
|
|
146455
|
+
}
|
|
146456
|
+
const diagnostics = sourceFiles.flatMap((sourceFile) => {
|
|
146457
|
+
const file = fileForSource(sourceFile);
|
|
146458
|
+
if (!file || includePaths && !includePaths.has(normalizeCodePath(file.path))) return [];
|
|
146459
|
+
return program.getSyntacticDiagnostics(sourceFile).slice(0, 4).map((diagnostic) => ({
|
|
146460
|
+
path: file.path,
|
|
146461
|
+
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, " ").slice(0, 240)
|
|
146462
|
+
}));
|
|
146463
|
+
});
|
|
146464
|
+
return {
|
|
146465
|
+
symbols,
|
|
146466
|
+
edges: [...edges.values()],
|
|
146467
|
+
parsedFiles: sourceFiles.length,
|
|
146468
|
+
parserErrors: diagnostics.length,
|
|
146469
|
+
unresolvedCalls,
|
|
146470
|
+
durationMs: Date.now() - started,
|
|
146471
|
+
diagnostics
|
|
146472
|
+
};
|
|
146473
|
+
}
|
|
146474
|
+
var SEMANTIC_SOURCE, SUPPORTED_LANGUAGES;
|
|
146475
|
+
var init_semantic_provider = __esm({
|
|
146476
|
+
"src/codegraph/semantic-provider.ts"() {
|
|
146477
|
+
"use strict";
|
|
146478
|
+
init_esm_shims();
|
|
146479
|
+
init_exclude3();
|
|
146480
|
+
init_ids();
|
|
146481
|
+
SEMANTIC_SOURCE = "typescript-compiler";
|
|
146482
|
+
SUPPORTED_LANGUAGES = /* @__PURE__ */ new Set(["typescript", "javascript"]);
|
|
146483
|
+
}
|
|
146484
|
+
});
|
|
146485
|
+
|
|
145911
146486
|
// src/codegraph/lite-provider.ts
|
|
145912
146487
|
var lite_provider_exports = {};
|
|
145913
146488
|
__export(lite_provider_exports, {
|
|
@@ -145915,11 +146490,11 @@ __export(lite_provider_exports, {
|
|
|
145915
146490
|
indexProjectLite: () => indexProjectLite,
|
|
145916
146491
|
refreshProjectLite: () => refreshProjectLite
|
|
145917
146492
|
});
|
|
145918
|
-
import { createHash as
|
|
145919
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
145920
|
-
import { join as join4, relative } from "path";
|
|
145921
|
-
function
|
|
145922
|
-
return
|
|
146493
|
+
import { createHash as createHash9 } from "crypto";
|
|
146494
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
146495
|
+
import { join as join4, relative as relative2 } from "path";
|
|
146496
|
+
function hashText2(text2) {
|
|
146497
|
+
return createHash9("sha256").update(text2).digest("hex");
|
|
145923
146498
|
}
|
|
145924
146499
|
function extension2(path22) {
|
|
145925
146500
|
const index = path22.lastIndexOf(".");
|
|
@@ -145945,7 +146520,7 @@ function walk(root, exclude, maxFiles) {
|
|
|
145945
146520
|
}
|
|
145946
146521
|
for (const entry of entries) {
|
|
145947
146522
|
const abs = join4(dir, entry.name);
|
|
145948
|
-
const rel = normalizeCodePath(
|
|
146523
|
+
const rel = normalizeCodePath(relative2(root, abs));
|
|
145949
146524
|
if (isCodeGraphExcludedPath(rel, exclude)) continue;
|
|
145950
146525
|
if (entry.isDirectory()) {
|
|
145951
146526
|
if (entry.name === ".git" || entry.name === ".worktrees" || entry.name === ".tmp" || entry.name === "node_modules") continue;
|
|
@@ -145988,8 +146563,9 @@ function extractSymbols(projectId, file, text2, indexedAt) {
|
|
|
145988
146563
|
startLine,
|
|
145989
146564
|
endLine: startLine,
|
|
145990
146565
|
signature: match2[0].slice(0, 160),
|
|
145991
|
-
contentHash:
|
|
145992
|
-
indexedAt
|
|
146566
|
+
contentHash: hashText2(match2[0]),
|
|
146567
|
+
indexedAt,
|
|
146568
|
+
source: "lite-regex"
|
|
145993
146569
|
});
|
|
145994
146570
|
}
|
|
145995
146571
|
}
|
|
@@ -146014,7 +146590,8 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
|
|
|
146014
146590
|
type: "imports",
|
|
146015
146591
|
confidence: 0.7,
|
|
146016
146592
|
evidence: line,
|
|
146017
|
-
indexedAt
|
|
146593
|
+
indexedAt,
|
|
146594
|
+
source: "lite-regex"
|
|
146018
146595
|
});
|
|
146019
146596
|
}
|
|
146020
146597
|
continue;
|
|
@@ -146027,28 +146604,30 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
|
|
|
146027
146604
|
type: "imports",
|
|
146028
146605
|
confidence: 0.7,
|
|
146029
146606
|
evidence: target,
|
|
146030
|
-
indexedAt
|
|
146607
|
+
indexedAt,
|
|
146608
|
+
source: "lite-regex"
|
|
146031
146609
|
});
|
|
146032
146610
|
}
|
|
146033
146611
|
}
|
|
146034
146612
|
return edges;
|
|
146035
146613
|
}
|
|
146036
146614
|
function indexFileLite(projectId, projectRoot, abs, indexedAt, fileStat) {
|
|
146037
|
-
const rel = normalizeCodePath(
|
|
146615
|
+
const rel = normalizeCodePath(relative2(projectRoot, abs));
|
|
146038
146616
|
try {
|
|
146039
|
-
const text2 =
|
|
146617
|
+
const text2 = readFileSync8(abs, "utf-8");
|
|
146040
146618
|
const stat5 = fileStat ?? statSync3(abs);
|
|
146041
146619
|
const file = {
|
|
146042
146620
|
id: makeCodeFileId(projectId, rel),
|
|
146043
146621
|
projectId,
|
|
146044
146622
|
path: rel,
|
|
146045
146623
|
language: languageForPath(rel),
|
|
146046
|
-
contentHash:
|
|
146624
|
+
contentHash: hashText2(text2),
|
|
146047
146625
|
// Preserve filesystem precision. Rounding here made same-size edits in
|
|
146048
146626
|
// a short Windows timestamp window indistinguishable to refresh.
|
|
146049
146627
|
mtimeMs: Number(stat5.mtimeMs),
|
|
146050
146628
|
sizeBytes: Number(stat5.size),
|
|
146051
|
-
indexedAt
|
|
146629
|
+
indexedAt,
|
|
146630
|
+
source: "lite-regex"
|
|
146052
146631
|
};
|
|
146053
146632
|
return {
|
|
146054
146633
|
delta: {
|
|
@@ -146103,6 +146682,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146103
146682
|
const indexedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
146104
146683
|
const paths = walk(options.projectRoot, exclude, maxFiles);
|
|
146105
146684
|
const existingByPath = new Map(store.listFiles(options.projectId).map((file) => [file.path, file]));
|
|
146685
|
+
const changedPaths = /* @__PURE__ */ new Set();
|
|
146106
146686
|
const changed = [];
|
|
146107
146687
|
const metadataOnly = [];
|
|
146108
146688
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
@@ -146111,7 +146691,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146111
146691
|
let skippedOversizedFiles = 0;
|
|
146112
146692
|
let unreadableFiles = 0;
|
|
146113
146693
|
for (const abs of paths) {
|
|
146114
|
-
const rel = normalizeCodePath(
|
|
146694
|
+
const rel = normalizeCodePath(relative2(options.projectRoot, abs));
|
|
146115
146695
|
seenPaths.add(rel);
|
|
146116
146696
|
let stat5;
|
|
146117
146697
|
try {
|
|
@@ -146126,6 +146706,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146126
146706
|
if (sizeBytes > maxFileBytes) {
|
|
146127
146707
|
skippedOversizedFiles++;
|
|
146128
146708
|
if (existing) oversizedExistingFileIds.add(existing.id);
|
|
146709
|
+
changedPaths.add(rel);
|
|
146129
146710
|
continue;
|
|
146130
146711
|
}
|
|
146131
146712
|
if (existing && existing.mtimeMs === mtimeMs && existing.sizeBytes === sizeBytes) {
|
|
@@ -146143,6 +146724,7 @@ async function refreshProjectLite(store, options) {
|
|
|
146143
146724
|
unchangedFiles++;
|
|
146144
146725
|
} else {
|
|
146145
146726
|
changed.push(delta);
|
|
146727
|
+
changedPaths.add(rel);
|
|
146146
146728
|
}
|
|
146147
146729
|
}
|
|
146148
146730
|
const removalScanDeferred = paths.length >= maxFiles;
|
|
@@ -146150,11 +146732,64 @@ async function refreshProjectLite(store, options) {
|
|
|
146150
146732
|
...oversizedExistingFileIds,
|
|
146151
146733
|
...removalScanDeferred ? [] : [...existingByPath.values()].filter((file) => !seenPaths.has(file.path)).map((file) => file.id)
|
|
146152
146734
|
])];
|
|
146735
|
+
for (const file of existingByPath.values()) {
|
|
146736
|
+
if (removedFileIds.includes(file.id)) changedPaths.add(file.path);
|
|
146737
|
+
}
|
|
146738
|
+
const affectedSemanticPaths = /* @__PURE__ */ new Set([
|
|
146739
|
+
...changedPaths,
|
|
146740
|
+
...store.listImportDependentPaths(
|
|
146741
|
+
options.projectId,
|
|
146742
|
+
[...changedPaths],
|
|
146743
|
+
changed.map((delta) => delta.file.path)
|
|
146744
|
+
)
|
|
146745
|
+
]);
|
|
146153
146746
|
store.applyFileDeltas(options.projectId, {
|
|
146154
146747
|
changed,
|
|
146155
146748
|
metadataOnly,
|
|
146156
146749
|
removedFileIds
|
|
146157
146750
|
});
|
|
146751
|
+
const currentFiles = store.listFiles(options.projectId);
|
|
146752
|
+
const beforeSemantic = store.status(options.projectId).semanticSymbols;
|
|
146753
|
+
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);
|
|
146754
|
+
let semanticSummary;
|
|
146755
|
+
if (semanticPaths.length > 0) {
|
|
146756
|
+
const semanticIndexer = options.semanticIndexer ?? buildTypeScriptSemanticIndex;
|
|
146757
|
+
const semanticInput = {
|
|
146758
|
+
projectId: options.projectId,
|
|
146759
|
+
projectRoot: options.projectRoot,
|
|
146760
|
+
files: currentFiles,
|
|
146761
|
+
exclude,
|
|
146762
|
+
includePaths: semanticPaths
|
|
146763
|
+
};
|
|
146764
|
+
try {
|
|
146765
|
+
const semantic = semanticIndexer(semanticInput);
|
|
146766
|
+
store.replaceSemanticSlice(options.projectId, semanticPaths, semantic);
|
|
146767
|
+
semanticSummary = {
|
|
146768
|
+
state: semantic.parserErrors > 0 ? "partial" : "ready",
|
|
146769
|
+
parsedFiles: semantic.parsedFiles,
|
|
146770
|
+
affectedFiles: semanticPaths.length,
|
|
146771
|
+
symbols: semantic.symbols.length,
|
|
146772
|
+
edges: semantic.edges.length,
|
|
146773
|
+
parserErrors: semantic.parserErrors,
|
|
146774
|
+
unresolvedCalls: semantic.unresolvedCalls,
|
|
146775
|
+
durationMs: semantic.durationMs
|
|
146776
|
+
};
|
|
146777
|
+
} catch (error) {
|
|
146778
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
146779
|
+
store.markSemanticSliceFailed(options.projectId, semanticPaths, message);
|
|
146780
|
+
semanticSummary = {
|
|
146781
|
+
state: "failed",
|
|
146782
|
+
parsedFiles: 0,
|
|
146783
|
+
affectedFiles: semanticPaths.length,
|
|
146784
|
+
symbols: 0,
|
|
146785
|
+
edges: 0,
|
|
146786
|
+
parserErrors: semanticPaths.length,
|
|
146787
|
+
unresolvedCalls: 0,
|
|
146788
|
+
durationMs: 0,
|
|
146789
|
+
error: message.slice(0, 500)
|
|
146790
|
+
};
|
|
146791
|
+
}
|
|
146792
|
+
}
|
|
146158
146793
|
const completeness = {
|
|
146159
146794
|
scannedFiles: paths.length,
|
|
146160
146795
|
maxFiles,
|
|
@@ -146184,7 +146819,8 @@ async function refreshProjectLite(store, options) {
|
|
|
146184
146819
|
skippedOversizedFiles,
|
|
146185
146820
|
unreadableFiles,
|
|
146186
146821
|
removalScanDeferred,
|
|
146187
|
-
snapshot
|
|
146822
|
+
snapshot,
|
|
146823
|
+
...semanticSummary ? { semantic: semanticSummary } : {}
|
|
146188
146824
|
};
|
|
146189
146825
|
}
|
|
146190
146826
|
var DEFAULT_CODEGRAPH_MAX_FILE_BYTES, LANGUAGE_BY_EXTENSION, SUPPORTED_EXTENSIONS, identifier, languageProfiles;
|
|
@@ -146195,6 +146831,7 @@ var init_lite_provider = __esm({
|
|
|
146195
146831
|
init_code_state();
|
|
146196
146832
|
init_ids();
|
|
146197
146833
|
init_exclude3();
|
|
146834
|
+
init_semantic_provider();
|
|
146198
146835
|
DEFAULT_CODEGRAPH_MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
146199
146836
|
LANGUAGE_BY_EXTENSION = /* @__PURE__ */ new Map([
|
|
146200
146837
|
[".ts", "typescript"],
|
|
@@ -146486,7 +147123,7 @@ var claim_store_exports = {};
|
|
|
146486
147123
|
__export(claim_store_exports, {
|
|
146487
147124
|
ClaimStore: () => ClaimStore
|
|
146488
147125
|
});
|
|
146489
|
-
import { createHash as
|
|
147126
|
+
import { createHash as createHash10, randomUUID as randomUUID12 } from "crypto";
|
|
146490
147127
|
function optionalText3(value) {
|
|
146491
147128
|
return typeof value === "string" && value ? value : void 0;
|
|
146492
147129
|
}
|
|
@@ -146539,7 +147176,7 @@ function rowToEvent3(row) {
|
|
|
146539
147176
|
};
|
|
146540
147177
|
}
|
|
146541
147178
|
function evidenceKey(input) {
|
|
146542
|
-
return
|
|
147179
|
+
return createHash10("sha256").update(JSON.stringify([
|
|
146543
147180
|
input.evidenceKind,
|
|
146544
147181
|
input.evidenceId,
|
|
146545
147182
|
input.relation,
|
|
@@ -146737,7 +147374,7 @@ __export(claims_exports, {
|
|
|
146737
147374
|
supersedeClaim: () => supersedeClaim,
|
|
146738
147375
|
writeClaim: () => writeClaim
|
|
146739
147376
|
});
|
|
146740
|
-
import { createHash as
|
|
147377
|
+
import { createHash as createHash11, randomUUID as randomUUID13 } from "crypto";
|
|
146741
147378
|
function compactText2(value, field) {
|
|
146742
147379
|
if (typeof value !== "string") throw new Error("Claim " + field + " must be text");
|
|
146743
147380
|
const sanitized = sanitizeCredentials(value).trim().replace(/\s+/g, " ");
|
|
@@ -146749,7 +147386,7 @@ function normalizedTerm(value) {
|
|
|
146749
147386
|
return compactText2(value, "identity").toLocaleLowerCase("en-US");
|
|
146750
147387
|
}
|
|
146751
147388
|
function hashIdentity(parts) {
|
|
146752
|
-
return
|
|
147389
|
+
return createHash11("sha256").update(parts.join(String.fromCharCode(31))).digest("hex");
|
|
146753
147390
|
}
|
|
146754
147391
|
function buildClaimIdentity(input) {
|
|
146755
147392
|
const subject = normalizedTerm(input.subject);
|
|
@@ -146990,7 +147627,7 @@ function supersedeClaim(store, input) {
|
|
|
146990
147627
|
});
|
|
146991
147628
|
}
|
|
146992
147629
|
function hashObservation(observation) {
|
|
146993
|
-
return
|
|
147630
|
+
return createHash11("sha256").update(JSON.stringify([
|
|
146994
147631
|
observation.title,
|
|
146995
147632
|
observation.narrative,
|
|
146996
147633
|
observation.facts,
|
|
@@ -147234,11 +147871,11 @@ var init_frontmatter = __esm({
|
|
|
147234
147871
|
});
|
|
147235
147872
|
|
|
147236
147873
|
// src/knowledge/markdown.ts
|
|
147237
|
-
import { createHash as
|
|
147874
|
+
import { createHash as createHash12 } from "crypto";
|
|
147238
147875
|
import { promises as fs10 } from "fs";
|
|
147239
147876
|
import path18 from "path";
|
|
147240
147877
|
function hashContent(content) {
|
|
147241
|
-
return
|
|
147878
|
+
return createHash12("sha256").update(content).digest("hex");
|
|
147242
147879
|
}
|
|
147243
147880
|
function stringField(data, key) {
|
|
147244
147881
|
const value = data[key];
|
|
@@ -147364,11 +148001,11 @@ __export(wiki_exports, {
|
|
|
147364
148001
|
lintKnowledgeWorkspace: () => lintKnowledgeWorkspace,
|
|
147365
148002
|
readKnowledgePage: () => readKnowledgePage
|
|
147366
148003
|
});
|
|
147367
|
-
import { createHash as
|
|
148004
|
+
import { createHash as createHash13 } from "crypto";
|
|
147368
148005
|
import { promises as fs11 } from "fs";
|
|
147369
148006
|
import path19 from "path";
|
|
147370
148007
|
function hash2(value) {
|
|
147371
|
-
return
|
|
148008
|
+
return createHash13("sha256").update(value).digest("hex");
|
|
147372
148009
|
}
|
|
147373
148010
|
function now() {
|
|
147374
148011
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -147522,8 +148159,8 @@ async function writeIndex(workspace, store) {
|
|
|
147522
148159
|
lines.push("No pending proposals.");
|
|
147523
148160
|
} else {
|
|
147524
148161
|
for (const proposal of pending) {
|
|
147525
|
-
const
|
|
147526
|
-
lines.push("- [" + path19.basename(proposal.proposalPath, ".md") + "](" +
|
|
148162
|
+
const relative3 = path19.relative(paths.root, proposal.proposalPath).split(path19.sep).join("/");
|
|
148163
|
+
lines.push("- [" + path19.basename(proposal.proposalPath, ".md") + "](" + relative3 + ")");
|
|
147527
148164
|
}
|
|
147528
148165
|
}
|
|
147529
148166
|
lines.push("");
|
|
@@ -148225,11 +148862,11 @@ __export(workflows_exports, {
|
|
|
148225
148862
|
syncCanonicalWorkflows: () => syncCanonicalWorkflows,
|
|
148226
148863
|
writeCanonicalWorkflow: () => writeCanonicalWorkflow
|
|
148227
148864
|
});
|
|
148228
|
-
import { createHash as
|
|
148865
|
+
import { createHash as createHash14 } from "crypto";
|
|
148229
148866
|
import { promises as fs12 } from "fs";
|
|
148230
148867
|
import path20 from "path";
|
|
148231
148868
|
function hash3(value) {
|
|
148232
|
-
return
|
|
148869
|
+
return createHash14("sha256").update(value).digest("hex");
|
|
148233
148870
|
}
|
|
148234
148871
|
function now2() {
|
|
148235
148872
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -148663,8 +149300,8 @@ async function importWindsurfWorkflows(input) {
|
|
|
148663
149300
|
return { imported, skipped };
|
|
148664
149301
|
}
|
|
148665
149302
|
function isWithin2(root, candidate) {
|
|
148666
|
-
const
|
|
148667
|
-
return
|
|
149303
|
+
const relative3 = path20.relative(root, candidate);
|
|
149304
|
+
return relative3 !== "" && relative3 !== ".." && !relative3.startsWith(".." + path20.sep) && !path20.isAbsolute(relative3);
|
|
148668
149305
|
}
|
|
148669
149306
|
function adapterRelativePath(workflow, agent) {
|
|
148670
149307
|
const name = "memorix-workflow-" + slug(workflow.id.replace(/^workflow:/, ""));
|
|
@@ -149403,7 +150040,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
149403
150040
|
resolveVectorBackfillRunnerPath: () => resolveVectorBackfillRunnerPath
|
|
149404
150041
|
});
|
|
149405
150042
|
import { spawn as spawn4 } from "child_process";
|
|
149406
|
-
import { existsSync as
|
|
150043
|
+
import { existsSync as existsSync12 } from "fs";
|
|
149407
150044
|
import path21 from "path";
|
|
149408
150045
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
149409
150046
|
function isNonEmptyString(value) {
|
|
@@ -149432,7 +150069,7 @@ function parseVectorBackfillRequest(raw) {
|
|
|
149432
150069
|
}
|
|
149433
150070
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
149434
150071
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
149435
|
-
const exists = options.exists ??
|
|
150072
|
+
const exists = options.exists ?? existsSync12;
|
|
149436
150073
|
if (!exists(runnerPath)) return false;
|
|
149437
150074
|
try {
|
|
149438
150075
|
const child = (options.spawn ?? spawn4)(process.execPath, [runnerPath], {
|
|
@@ -149470,14 +150107,14 @@ async function executeVectorBackfill(request) {
|
|
|
149470
150107
|
return worker.runOnce();
|
|
149471
150108
|
}
|
|
149472
150109
|
async function readStdin() {
|
|
149473
|
-
return new Promise((
|
|
150110
|
+
return new Promise((resolve2, reject) => {
|
|
149474
150111
|
let raw = "";
|
|
149475
150112
|
process.stdin.setEncoding("utf8");
|
|
149476
150113
|
process.stdin.on("data", (chunk) => {
|
|
149477
150114
|
raw += chunk;
|
|
149478
150115
|
});
|
|
149479
150116
|
process.stdin.once("error", reject);
|
|
149480
|
-
process.stdin.once("end", () =>
|
|
150117
|
+
process.stdin.once("end", () => resolve2(raw));
|
|
149481
150118
|
});
|
|
149482
150119
|
}
|
|
149483
150120
|
async function main() {
|
|
@@ -150603,14 +151240,14 @@ async function executeMaintenanceRequest(request) {
|
|
|
150603
151240
|
return await handler(request.job) ?? { action: "complete" };
|
|
150604
151241
|
}
|
|
150605
151242
|
function readStdin2() {
|
|
150606
|
-
return new Promise((
|
|
151243
|
+
return new Promise((resolve2, reject) => {
|
|
150607
151244
|
let raw = "";
|
|
150608
151245
|
process.stdin.setEncoding("utf8");
|
|
150609
151246
|
process.stdin.on("data", (chunk) => {
|
|
150610
151247
|
raw += chunk;
|
|
150611
151248
|
});
|
|
150612
151249
|
process.stdin.once("error", reject);
|
|
150613
|
-
process.stdin.once("end", () =>
|
|
151250
|
+
process.stdin.once("end", () => resolve2(raw));
|
|
150614
151251
|
});
|
|
150615
151252
|
}
|
|
150616
151253
|
async function main2() {
|