@massa-ai/mcp-client 1.64.0 → 1.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-cli.js +408 -165
- package/dist/index.js +1104 -835
- package/package.json +3 -3
package/dist/config-cli.js
CHANGED
|
@@ -10190,7 +10190,8 @@ var init_ignore_patterns = __esm(() => {
|
|
|
10190
10190
|
"**/pnpm-lock.yaml",
|
|
10191
10191
|
"**/package-lock.json",
|
|
10192
10192
|
"**/bun.lockb",
|
|
10193
|
-
"**/yarn.lock"
|
|
10193
|
+
"**/yarn.lock",
|
|
10194
|
+
"**/Pods/**"
|
|
10194
10195
|
];
|
|
10195
10196
|
});
|
|
10196
10197
|
|
|
@@ -117746,6 +117747,33 @@ class ManagedRunRepositoryPg {
|
|
|
117746
117747
|
`;
|
|
117747
117748
|
return rows[0] ? toActive(rows[0]) : null;
|
|
117748
117749
|
}
|
|
117750
|
+
async getAnyActive() {
|
|
117751
|
+
const rows = await getPrismaClient2().$queryRaw`
|
|
117752
|
+
SELECT id, project_id, run_kind, event_id, content_hash, file_cursor,
|
|
117753
|
+
status, lease_token, lease_expires_at, heartbeat_at,
|
|
117754
|
+
created_at, completed_at
|
|
117755
|
+
FROM managed_runs
|
|
117756
|
+
WHERE status = 'active'
|
|
117757
|
+
AND lease_expires_at > clock_timestamp()
|
|
117758
|
+
ORDER BY lease_expires_at DESC
|
|
117759
|
+
LIMIT 1
|
|
117760
|
+
`;
|
|
117761
|
+
return rows[0] ? toActive(rows[0]) : null;
|
|
117762
|
+
}
|
|
117763
|
+
async release(lease) {
|
|
117764
|
+
const leaseToken = boundedText(lease.leaseToken, "leaseToken", MAX_LEASE_TOKEN);
|
|
117765
|
+
const deleted = await getPrismaClient2().$queryRaw`
|
|
117766
|
+
DELETE FROM managed_runs
|
|
117767
|
+
WHERE id = ${BigInt(lease.runId)}
|
|
117768
|
+
AND project_id = ${lease.projectId}
|
|
117769
|
+
AND run_kind = ${lease.runKind}
|
|
117770
|
+
AND lease_token = ${leaseToken}
|
|
117771
|
+
RETURNING id
|
|
117772
|
+
`;
|
|
117773
|
+
if (!deleted[0])
|
|
117774
|
+
return { status: "lease_lost" };
|
|
117775
|
+
return { status: "aborted", runId: deleted[0].id.toString() };
|
|
117776
|
+
}
|
|
117749
117777
|
}
|
|
117750
117778
|
var DEFAULT_LEASE_TTL_MS = 90000, MIN_LEASE_TTL_MS = 1000, MAX_LEASE_TTL_MS = 300000, HEARTBEAT_TTL_MS = 90000, MAX_PROJECT_ID = 512, MAX_EVENT_ID = 2000, MAX_CONTENT_HASH = 2000, MAX_LEASE_TOKEN = 512;
|
|
117751
117779
|
var init_managed_run_repository_pg = __esm(() => {
|
|
@@ -117783,10 +117811,111 @@ var init_embedding_freshness = __esm(() => {
|
|
|
117783
117811
|
};
|
|
117784
117812
|
});
|
|
117785
117813
|
|
|
117814
|
+
// ../../packages/core/dist/services/jobs/heavy-work-lease.js
|
|
117815
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
117816
|
+
import { setTimeout as delay2 } from "timers/promises";
|
|
117817
|
+
function repository() {
|
|
117818
|
+
return repositoryOverride ?? ManagedRunRepositoryPg.getInstance();
|
|
117819
|
+
}
|
|
117820
|
+
async function withHeavyWorkLease(kind, label, fn) {
|
|
117821
|
+
let repo;
|
|
117822
|
+
let lease;
|
|
117823
|
+
try {
|
|
117824
|
+
repo = repository();
|
|
117825
|
+
const outcome = await repo.begin({
|
|
117826
|
+
projectId: `heavy-work:${label}:${randomUUID3()}`,
|
|
117827
|
+
runKind: kind,
|
|
117828
|
+
eventId: `heavy-work:${label}`
|
|
117829
|
+
});
|
|
117830
|
+
if (outcome.status === "acquired")
|
|
117831
|
+
lease = outcome.lease;
|
|
117832
|
+
} catch (error51) {
|
|
117833
|
+
logger.warn("heavy-work lease unavailable; running without it", { label, error: error51 });
|
|
117834
|
+
}
|
|
117835
|
+
if (!repo || !lease)
|
|
117836
|
+
return fn();
|
|
117837
|
+
const heldRepo = repo;
|
|
117838
|
+
const heldLease = lease;
|
|
117839
|
+
const heartbeatController = new AbortController;
|
|
117840
|
+
(async () => {
|
|
117841
|
+
while (true) {
|
|
117842
|
+
try {
|
|
117843
|
+
await delay2(HEARTBEAT_MS, undefined, { signal: heartbeatController.signal });
|
|
117844
|
+
} catch {
|
|
117845
|
+
return;
|
|
117846
|
+
}
|
|
117847
|
+
try {
|
|
117848
|
+
await heldRepo.heartbeat(heldLease);
|
|
117849
|
+
} catch {}
|
|
117850
|
+
}
|
|
117851
|
+
})();
|
|
117852
|
+
try {
|
|
117853
|
+
return await fn();
|
|
117854
|
+
} finally {
|
|
117855
|
+
heartbeatController.abort();
|
|
117856
|
+
try {
|
|
117857
|
+
await heldRepo.release(heldLease);
|
|
117858
|
+
} catch (error51) {
|
|
117859
|
+
logger.warn("heavy-work lease release failed; it expires on its own", { label, error: error51 });
|
|
117860
|
+
}
|
|
117861
|
+
}
|
|
117862
|
+
}
|
|
117863
|
+
async function probeHeavyWork() {
|
|
117864
|
+
let timer;
|
|
117865
|
+
const timeout = new Promise((_, reject) => {
|
|
117866
|
+
timer = setTimeout(() => reject(new Error(`heavy-work probe timed out after ${PROBE_TIMEOUT_MS}ms`)), PROBE_TIMEOUT_MS);
|
|
117867
|
+
});
|
|
117868
|
+
try {
|
|
117869
|
+
const active = await Promise.race([repository().getAnyActive(), timeout]);
|
|
117870
|
+
if (!active)
|
|
117871
|
+
return { busy: false };
|
|
117872
|
+
return { busy: true, reason: `${active.runKind} run ${active.runId} (${active.projectId})` };
|
|
117873
|
+
} finally {
|
|
117874
|
+
clearTimeout(timer);
|
|
117875
|
+
}
|
|
117876
|
+
}
|
|
117877
|
+
var HEARTBEAT_MS = 30000, PROBE_TIMEOUT_MS = 5000, repositoryOverride = null;
|
|
117878
|
+
var init_heavy_work_lease = __esm(() => {
|
|
117879
|
+
init_dist();
|
|
117880
|
+
init_managed_run_repository_pg();
|
|
117881
|
+
});
|
|
117882
|
+
|
|
117883
|
+
// ../../packages/core/dist/services/search/incremental-reindex.js
|
|
117884
|
+
import path21 from "path";
|
|
117885
|
+
function runIncrementalReindex(deps, projectId, projectPath, filesToReindex) {
|
|
117886
|
+
return withHeavyWorkLease("reindex", `incremental-reindex:${projectId}`, async () => {
|
|
117887
|
+
const centralityMap = await deps.symbolRepo.getCentrality(await getProjectIdentityAliasResolver().resolve(projectId));
|
|
117888
|
+
let filesIndexed = 0;
|
|
117889
|
+
let chunksIndexed = 0;
|
|
117890
|
+
let errors4 = 0;
|
|
117891
|
+
for (const relativeFilePath of filesToReindex) {
|
|
117892
|
+
try {
|
|
117893
|
+
const fullPath = path21.join(projectPath, relativeFilePath);
|
|
117894
|
+
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
117895
|
+
filesIndexed++;
|
|
117896
|
+
chunksIndexed += result.chunks;
|
|
117897
|
+
} catch (error51) {
|
|
117898
|
+
logger.error("Failed to reindex file", error51, {
|
|
117899
|
+
file: relativeFilePath
|
|
117900
|
+
});
|
|
117901
|
+
errors4++;
|
|
117902
|
+
}
|
|
117903
|
+
}
|
|
117904
|
+
await deps.indexManager.updateIndexMetadata(projectId, projectPath, filesToReindex);
|
|
117905
|
+
await deps.searchCache.invalidateProject(projectId);
|
|
117906
|
+
return { filesIndexed, chunksIndexed, errors: errors4 };
|
|
117907
|
+
});
|
|
117908
|
+
}
|
|
117909
|
+
var init_incremental_reindex = __esm(() => {
|
|
117910
|
+
init_dist();
|
|
117911
|
+
init_alias_resolver();
|
|
117912
|
+
init_heavy_work_lease();
|
|
117913
|
+
});
|
|
117914
|
+
|
|
117786
117915
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
117787
117916
|
import fs15 from "fs/promises";
|
|
117788
|
-
import
|
|
117789
|
-
import { randomUUID as
|
|
117917
|
+
import path22 from "path";
|
|
117918
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
117790
117919
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
117791
117920
|
const prevLock = lockMap.get(projectId);
|
|
117792
117921
|
const isQueued = prevLock !== undefined;
|
|
@@ -117828,7 +117957,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
117828
117957
|
dot: false
|
|
117829
117958
|
});
|
|
117830
117959
|
const filteredFiles = files.filter((file2) => {
|
|
117831
|
-
const relativePath =
|
|
117960
|
+
const relativePath = path22.relative(projectPath, file2);
|
|
117832
117961
|
const shouldIgnore = ig.ignores(relativePath);
|
|
117833
117962
|
if (shouldIgnore) {
|
|
117834
117963
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -117868,7 +117997,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
117868
117997
|
});
|
|
117869
117998
|
}
|
|
117870
117999
|
}
|
|
117871
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
118000
|
+
const indexedFilesList = filteredFiles.map((f) => path22.relative(projectPath, f));
|
|
117872
118001
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
117873
118002
|
logger.info("Project indexing completed", {
|
|
117874
118003
|
projectId,
|
|
@@ -117939,7 +118068,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
117939
118068
|
if (needsFullReindex) {
|
|
117940
118069
|
logger.info("Performing full reindex", { projectId });
|
|
117941
118070
|
const managedRunRepo = ManagedRunRepositoryPg.getInstance();
|
|
117942
|
-
const eventId = `reindex:${projectId}:${
|
|
118071
|
+
const eventId = `reindex:${projectId}:${randomUUID4()}`;
|
|
117943
118072
|
const beginOutcome = await managedRunRepo.begin({
|
|
117944
118073
|
projectId,
|
|
117945
118074
|
runKind: "indexing",
|
|
@@ -117992,25 +118121,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
117992
118121
|
projectId,
|
|
117993
118122
|
fileCount: filesToReindex.length
|
|
117994
118123
|
});
|
|
117995
|
-
const
|
|
117996
|
-
let filesIndexed = 0;
|
|
117997
|
-
let chunksIndexed = 0;
|
|
117998
|
-
let errors4 = 0;
|
|
117999
|
-
for (const relativeFilePath of filesToReindex) {
|
|
118000
|
-
try {
|
|
118001
|
-
const fullPath = path21.join(projectPath, relativeFilePath);
|
|
118002
|
-
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
118003
|
-
filesIndexed++;
|
|
118004
|
-
chunksIndexed += result.chunks;
|
|
118005
|
-
} catch (error51) {
|
|
118006
|
-
logger.error("Failed to reindex file", error51, {
|
|
118007
|
-
file: relativeFilePath
|
|
118008
|
-
});
|
|
118009
|
-
errors4++;
|
|
118010
|
-
}
|
|
118011
|
-
}
|
|
118012
|
-
await deps.indexManager.updateIndexMetadata(projectId, projectPath, filesToReindex);
|
|
118013
|
-
await deps.searchCache.invalidateProject(projectId);
|
|
118124
|
+
const { filesIndexed, chunksIndexed, errors: errors4 } = await runIncrementalReindex(deps, projectId, projectPath, filesToReindex);
|
|
118014
118125
|
logger.info("Incremental reindex completed", {
|
|
118015
118126
|
projectId,
|
|
118016
118127
|
filesIndexed,
|
|
@@ -118059,7 +118170,7 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
118059
118170
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
118060
118171
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
118061
118172
|
const content = await fs15.readFile(filePath, "utf-8");
|
|
118062
|
-
const relativePath =
|
|
118173
|
+
const relativePath = path22.relative(projectRoot, filePath);
|
|
118063
118174
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
118064
118175
|
if (content.length > maxFileSize) {
|
|
118065
118176
|
logger.warn("File too large, skipping", {
|
|
@@ -118079,7 +118190,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
118079
118190
|
chunkIndex: i,
|
|
118080
118191
|
totalChunks: chunks.length,
|
|
118081
118192
|
type: chunk.type,
|
|
118082
|
-
language:
|
|
118193
|
+
language: path22.extname(filePath).slice(1),
|
|
118083
118194
|
lineStart: chunk.lineStart,
|
|
118084
118195
|
lineEnd: chunk.lineEnd,
|
|
118085
118196
|
label: chunk.label,
|
|
@@ -118104,6 +118215,7 @@ var init_project_indexer = __esm(() => {
|
|
|
118104
118215
|
init_managed_run_repository_pg();
|
|
118105
118216
|
init_symbol_repo_workspace();
|
|
118106
118217
|
init_embedding_freshness();
|
|
118218
|
+
init_incremental_reindex();
|
|
118107
118219
|
globAsync2 = glob;
|
|
118108
118220
|
});
|
|
118109
118221
|
|
|
@@ -120471,7 +120583,7 @@ __export(exports_memory_consolidation_job, {
|
|
|
120471
120583
|
memoryConsolidationJob: () => memoryConsolidationJob,
|
|
120472
120584
|
MemoryConsolidationJob: () => MemoryConsolidationJob
|
|
120473
120585
|
});
|
|
120474
|
-
import { randomUUID as
|
|
120586
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
120475
120587
|
async function addSupercedesEdge(store2, newId, sourceId, batchId) {
|
|
120476
120588
|
const evidence = JSON.stringify({ batchId, consolidated: true });
|
|
120477
120589
|
await store2.createEdge({
|
|
@@ -120615,11 +120727,11 @@ class MemoryConsolidationJob {
|
|
|
120615
120727
|
});
|
|
120616
120728
|
return { merged: 0, batchesCreated: 0 };
|
|
120617
120729
|
}
|
|
120618
|
-
const batch = await consolidateWindow(rowsToCandidates(candidates), this.llm, { idFactory: () => `batch-${now2}-${
|
|
120730
|
+
const batch = await consolidateWindow(rowsToCandidates(candidates), this.llm, { idFactory: () => `batch-${now2}-${randomUUID5().slice(0, 8)}` }).catch(() => null);
|
|
120619
120731
|
if (!batch)
|
|
120620
120732
|
return { merged: 0, batchesCreated: 0 };
|
|
120621
120733
|
const sourceRows = candidates.filter((c) => batch.sourceIds.includes(c.id));
|
|
120622
|
-
const newId = `mem-${now2}-${
|
|
120734
|
+
const newId = `mem-${now2}-${randomUUID5().slice(0, 8)}`;
|
|
120623
120735
|
const importance = sourceRows.length ? Math.min(1, Math.max(...sourceRows.map((r) => r.importance))) : 0.7;
|
|
120624
120736
|
const projectId = sourceRows.find((r) => r.project_id)?.project_id ?? null;
|
|
120625
120737
|
try {
|
|
@@ -121816,8 +121928,8 @@ function toSymbolIdentityResolution(result) {
|
|
|
121816
121928
|
|
|
121817
121929
|
class DefinitionLookupService {
|
|
121818
121930
|
repository;
|
|
121819
|
-
constructor(
|
|
121820
|
-
this.repository =
|
|
121931
|
+
constructor(repository2 = getSymbolRepository) {
|
|
121932
|
+
this.repository = repository2;
|
|
121821
121933
|
}
|
|
121822
121934
|
async lookup(projectId, query) {
|
|
121823
121935
|
const repo = this.repository();
|
|
@@ -121927,7 +122039,7 @@ class WorkspaceManager {
|
|
|
121927
122039
|
return matches[0];
|
|
121928
122040
|
}
|
|
121929
122041
|
async removeWorkspace(projectId) {
|
|
121930
|
-
await getSymbolRepository().clearProject(projectId);
|
|
122042
|
+
await withHeavyWorkLease("maintenance", `workspace-remove:${projectId}`, () => getSymbolRepository().clearProject(projectId));
|
|
121931
122043
|
logger.info("WorkspaceManager: workspace removed", { projectId });
|
|
121932
122044
|
}
|
|
121933
122045
|
subscribeToEvents() {
|
|
@@ -121952,6 +122064,7 @@ var init_workspace_manager = __esm(() => {
|
|
|
121952
122064
|
init_symbol_repository_factory();
|
|
121953
122065
|
init_event_bus();
|
|
121954
122066
|
init_symbol_graph_service();
|
|
122067
|
+
init_heavy_work_lease();
|
|
121955
122068
|
workspaceManager = WorkspaceManager.getInstance();
|
|
121956
122069
|
});
|
|
121957
122070
|
|
|
@@ -122637,16 +122750,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
122637
122750
|
const seen = new Set;
|
|
122638
122751
|
const out = [];
|
|
122639
122752
|
for (const e of httpEdges) {
|
|
122640
|
-
const
|
|
122641
|
-
if (!
|
|
122753
|
+
const path23 = e.route;
|
|
122754
|
+
if (!path23)
|
|
122642
122755
|
continue;
|
|
122643
122756
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
122644
|
-
const key = method + " " +
|
|
122757
|
+
const key = method + " " + path23;
|
|
122645
122758
|
if (seen.has(key))
|
|
122646
122759
|
continue;
|
|
122647
122760
|
seen.add(key);
|
|
122648
122761
|
out.push({
|
|
122649
|
-
path:
|
|
122762
|
+
path: path23,
|
|
122650
122763
|
method: e.method,
|
|
122651
122764
|
file: e.fromFile,
|
|
122652
122765
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -122657,12 +122770,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
122657
122770
|
continue;
|
|
122658
122771
|
const parsed = parseRouteName(d.name);
|
|
122659
122772
|
const method = parsed?.method ?? "ANY";
|
|
122660
|
-
const
|
|
122661
|
-
const key = method + " " +
|
|
122773
|
+
const path23 = parsed?.path ?? d.name;
|
|
122774
|
+
const key = method + " " + path23;
|
|
122662
122775
|
if (seen.has(key))
|
|
122663
122776
|
continue;
|
|
122664
122777
|
seen.add(key);
|
|
122665
|
-
out.push({ path:
|
|
122778
|
+
out.push({ path: path23, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
122666
122779
|
}
|
|
122667
122780
|
for (const d of defs) {
|
|
122668
122781
|
const parsed = parseRouteName(d.name);
|
|
@@ -122883,7 +122996,7 @@ __export(exports_symbol_graph_service, {
|
|
|
122883
122996
|
symbolGraphService: () => symbolGraphService,
|
|
122884
122997
|
SymbolGraphService: () => SymbolGraphService
|
|
122885
122998
|
});
|
|
122886
|
-
import
|
|
122999
|
+
import path23 from "path";
|
|
122887
123000
|
import fs16 from "fs/promises";
|
|
122888
123001
|
|
|
122889
123002
|
class SymbolGraphService {
|
|
@@ -123237,7 +123350,7 @@ class SymbolGraphService {
|
|
|
123237
123350
|
}
|
|
123238
123351
|
async resolveToAbsolute(relativePath, projectId) {
|
|
123239
123352
|
const root = await this.getProjectRoot(projectId);
|
|
123240
|
-
return root ?
|
|
123353
|
+
return root ? path23.resolve(root, relativePath) : relativePath;
|
|
123241
123354
|
}
|
|
123242
123355
|
async getProjectRoot(projectId) {
|
|
123243
123356
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -125020,31 +125133,31 @@ class TracePathService {
|
|
|
125020
125133
|
const chains = [];
|
|
125021
125134
|
const seen = new Set;
|
|
125022
125135
|
let walks = 0;
|
|
125023
|
-
const walk = (fqn,
|
|
125136
|
+
const walk = (fqn, path24) => {
|
|
125024
125137
|
if (chains.length >= CHAIN_CAP)
|
|
125025
125138
|
return;
|
|
125026
125139
|
if (walks >= MAX_WALKS)
|
|
125027
125140
|
return;
|
|
125028
125141
|
walks++;
|
|
125029
|
-
const key =
|
|
125142
|
+
const key = path24.join("\u2192");
|
|
125030
125143
|
if (seen.has(key))
|
|
125031
125144
|
return;
|
|
125032
125145
|
seen.add(key);
|
|
125033
125146
|
const next = adj.get(fqn);
|
|
125034
125147
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
125035
|
-
if (
|
|
125036
|
-
chains.push(
|
|
125148
|
+
if (path24.length > 1)
|
|
125149
|
+
chains.push(path24.map((n) => this.fqnToName(n)).join(" \u2192 "));
|
|
125037
125150
|
return;
|
|
125038
125151
|
}
|
|
125039
125152
|
for (const child of next) {
|
|
125040
125153
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
125041
125154
|
return;
|
|
125042
|
-
if (
|
|
125043
|
-
const cycled = [...
|
|
125155
|
+
if (path24.includes(child)) {
|
|
125156
|
+
const cycled = [...path24, `${this.fqnToName(child)}\u21BA`];
|
|
125044
125157
|
chains.push(cycled.map((n) => n).join(" \u2192 "));
|
|
125045
125158
|
continue;
|
|
125046
125159
|
}
|
|
125047
|
-
walk(child, [...
|
|
125160
|
+
walk(child, [...path24, child]);
|
|
125048
125161
|
}
|
|
125049
125162
|
};
|
|
125050
125163
|
for (const seed of seeds) {
|
|
@@ -126766,12 +126879,13 @@ function createProjectIdentityService(options = {}) {
|
|
|
126766
126879
|
}
|
|
126767
126880
|
},
|
|
126768
126881
|
apply(input) {
|
|
126769
|
-
return applyService.apply(input);
|
|
126882
|
+
return withHeavyWorkLease("maintenance", "project-identity", () => applyService.apply(input));
|
|
126770
126883
|
}
|
|
126771
126884
|
};
|
|
126772
126885
|
}
|
|
126773
126886
|
var init_service = __esm(() => {
|
|
126774
126887
|
init_db_connection();
|
|
126888
|
+
init_heavy_work_lease();
|
|
126775
126889
|
init_apply();
|
|
126776
126890
|
init_errors4();
|
|
126777
126891
|
init_planner();
|
|
@@ -127069,7 +127183,7 @@ var init_inference_probe = __esm(() => {
|
|
|
127069
127183
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
127070
127184
|
import fs17 from "fs/promises";
|
|
127071
127185
|
import { existsSync as existsSync3 } from "fs";
|
|
127072
|
-
import
|
|
127186
|
+
import path24 from "path";
|
|
127073
127187
|
|
|
127074
127188
|
class LocalHealthChecker {
|
|
127075
127189
|
dataDir = config.get("dataDir");
|
|
@@ -127148,7 +127262,7 @@ class LocalHealthChecker {
|
|
|
127148
127262
|
try {
|
|
127149
127263
|
if (!existsSync3(this.dataDir))
|
|
127150
127264
|
await fs17.mkdir(this.dataDir, { recursive: true });
|
|
127151
|
-
const probe =
|
|
127265
|
+
const probe = path24.join(this.dataDir, ".health-check-test");
|
|
127152
127266
|
await fs17.writeFile(probe, "ok");
|
|
127153
127267
|
await fs17.unlink(probe);
|
|
127154
127268
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
@@ -127538,7 +127652,7 @@ var init_index_job_store = __esm(() => {
|
|
|
127538
127652
|
});
|
|
127539
127653
|
|
|
127540
127654
|
// ../../packages/core/dist/services/jobs/index-job-tracker.js
|
|
127541
|
-
import { randomUUID as
|
|
127655
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
127542
127656
|
|
|
127543
127657
|
class IndexJobTracker {
|
|
127544
127658
|
static instance;
|
|
@@ -127562,7 +127676,7 @@ class IndexJobTracker {
|
|
|
127562
127676
|
return IndexJobTracker.instance;
|
|
127563
127677
|
}
|
|
127564
127678
|
createJob(projectId, projectPath) {
|
|
127565
|
-
const jobId =
|
|
127679
|
+
const jobId = randomUUID6();
|
|
127566
127680
|
const job = {
|
|
127567
127681
|
jobId,
|
|
127568
127682
|
projectId,
|
|
@@ -127652,7 +127766,9 @@ class IndexJobTracker {
|
|
|
127652
127766
|
const cutoff = now2 - staleMs;
|
|
127653
127767
|
let reaped = 0;
|
|
127654
127768
|
for (const job of running) {
|
|
127655
|
-
const
|
|
127769
|
+
const live = this.jobs.get(job.jobId);
|
|
127770
|
+
const liveHb = live?.heartbeatAt?.getTime();
|
|
127771
|
+
const hbMs = liveHb ?? job.heartbeatAt?.getTime();
|
|
127656
127772
|
const startedMs = job.startedAt?.getTime();
|
|
127657
127773
|
const stale = hbMs != null && hbMs < cutoff || hbMs == null && startedMs != null && startedMs < cutoff;
|
|
127658
127774
|
if (!stale)
|
|
@@ -128052,6 +128168,9 @@ class PgScheduledJobStore {
|
|
|
128052
128168
|
}, "save");
|
|
128053
128169
|
this.ensureHydrated();
|
|
128054
128170
|
}
|
|
128171
|
+
async ready() {
|
|
128172
|
+
await this.ensureHydrated();
|
|
128173
|
+
}
|
|
128055
128174
|
get(id) {
|
|
128056
128175
|
this.ensureHydrated();
|
|
128057
128176
|
return this.mirror.get(id) ?? null;
|
|
@@ -128128,10 +128247,18 @@ class Scheduler {
|
|
|
128128
128247
|
handlers = new Map;
|
|
128129
128248
|
cronCache = new Map;
|
|
128130
128249
|
running = new Set;
|
|
128250
|
+
heavyWorkProbe;
|
|
128251
|
+
deferred = new Set;
|
|
128252
|
+
heavyWorkReason = null;
|
|
128253
|
+
lastProbeError = null;
|
|
128254
|
+
consecutiveProbeFailures = 0;
|
|
128255
|
+
evaluating = false;
|
|
128256
|
+
pendingTickAt = null;
|
|
128131
128257
|
timer = null;
|
|
128132
128258
|
started = false;
|
|
128133
128259
|
constructor(opts = {}) {
|
|
128134
128260
|
this.store = opts.store ?? getScheduledJobStore();
|
|
128261
|
+
this.heavyWorkProbe = opts.heavyWorkProbe ?? probeHeavyWork;
|
|
128135
128262
|
const schedulerConfig = config.get("scheduler");
|
|
128136
128263
|
this.tickIntervalMs = opts.tickIntervalMs ?? envPositiveInt(process.env.MASSA_AI_SCHEDULER_TICK_MS) ?? schedulerConfig?.tickMs ?? DEFAULTS.tickMs;
|
|
128137
128264
|
this.maxConcurrent = opts.maxConcurrent ?? envPositiveInt(process.env.MASSA_AI_SCHEDULER_MAX_CONCURRENT) ?? schedulerConfig?.maxConcurrent ?? DEFAULTS.maxConcurrent;
|
|
@@ -128232,31 +128359,43 @@ class Scheduler {
|
|
|
128232
128359
|
this.timer.unref?.();
|
|
128233
128360
|
this.tick().catch(() => {});
|
|
128234
128361
|
}
|
|
128235
|
-
catchUpMissedJobs(now2 = Date.now()) {
|
|
128236
|
-
if (!this.enabled)
|
|
128237
|
-
return { caughtUp: 0, skipped: 0 };
|
|
128362
|
+
async catchUpMissedJobs(now2 = Date.now()) {
|
|
128363
|
+
if (!this.enabled || this.evaluating)
|
|
128364
|
+
return { caughtUp: 0, skipped: 0, deferred: 0 };
|
|
128365
|
+
this.evaluating = true;
|
|
128366
|
+
try {
|
|
128367
|
+
return await this.catchUpOnce(now2);
|
|
128368
|
+
} finally {
|
|
128369
|
+
this.evaluating = false;
|
|
128370
|
+
}
|
|
128371
|
+
}
|
|
128372
|
+
async catchUpOnce(now2) {
|
|
128238
128373
|
const jobs = this.store.listEnabled();
|
|
128239
|
-
let caughtUp = 0;
|
|
128240
128374
|
let skipped = 0;
|
|
128375
|
+
const missed = [];
|
|
128241
128376
|
for (const job of jobs) {
|
|
128242
128377
|
if (this.running.has(job.jobKind)) {
|
|
128243
128378
|
skipped++;
|
|
128244
128379
|
continue;
|
|
128245
128380
|
}
|
|
128246
|
-
|
|
128247
|
-
|
|
128248
|
-
|
|
128249
|
-
|
|
128381
|
+
if (now2 - job.nextRunAt > this.tickIntervalMs)
|
|
128382
|
+
missed.push(job);
|
|
128383
|
+
}
|
|
128384
|
+
if (missed.length > 0 && await this.heavyWorkBusy()) {
|
|
128385
|
+
for (const job of missed)
|
|
128386
|
+
this.deferred.add(job.id);
|
|
128387
|
+
return { caughtUp: 0, skipped, deferred: missed.length };
|
|
128388
|
+
}
|
|
128389
|
+
for (const job of missed) {
|
|
128250
128390
|
logger.info("Scheduler: catch-up tick for missed job", {
|
|
128251
128391
|
id: job.id,
|
|
128252
128392
|
name: job.name,
|
|
128253
128393
|
jobKind: job.jobKind,
|
|
128254
|
-
overdueMs
|
|
128394
|
+
overdueMs: now2 - job.nextRunAt
|
|
128255
128395
|
});
|
|
128256
128396
|
this.fireJob(job, now2);
|
|
128257
|
-
caughtUp++;
|
|
128258
128397
|
}
|
|
128259
|
-
return { caughtUp, skipped };
|
|
128398
|
+
return { caughtUp: missed.length, skipped, deferred: 0 };
|
|
128260
128399
|
}
|
|
128261
128400
|
stop() {
|
|
128262
128401
|
if (this.timer) {
|
|
@@ -128264,17 +128403,47 @@ class Scheduler {
|
|
|
128264
128403
|
this.timer = null;
|
|
128265
128404
|
}
|
|
128266
128405
|
this.started = false;
|
|
128406
|
+
this.pendingTickAt = null;
|
|
128267
128407
|
logger.info("Scheduler stopped");
|
|
128268
128408
|
}
|
|
128269
128409
|
isRunning() {
|
|
128270
128410
|
return this.started && this.timer !== null;
|
|
128271
128411
|
}
|
|
128272
128412
|
async tick(now2 = Date.now()) {
|
|
128273
|
-
const result = { evaluated: 0, fired: 0, skipped: 0, errors: 0 };
|
|
128413
|
+
const result = { evaluated: 0, fired: 0, skipped: 0, errors: 0, deferred: 0 };
|
|
128274
128414
|
if (!this.enabled)
|
|
128275
128415
|
return result;
|
|
128276
|
-
|
|
128416
|
+
if (this.evaluating) {
|
|
128417
|
+
this.pendingTickAt = now2;
|
|
128418
|
+
return result;
|
|
128419
|
+
}
|
|
128420
|
+
this.evaluating = true;
|
|
128421
|
+
try {
|
|
128422
|
+
return await this.tickOnce(now2, result);
|
|
128423
|
+
} finally {
|
|
128424
|
+
this.evaluating = false;
|
|
128425
|
+
const pending = this.pendingTickAt;
|
|
128426
|
+
this.pendingTickAt = null;
|
|
128427
|
+
if (pending !== null) {
|
|
128428
|
+
this.tick(pending).catch((e) => {
|
|
128429
|
+
logger.warn("Scheduler tick failed (swallowed)", { error: e });
|
|
128430
|
+
});
|
|
128431
|
+
}
|
|
128432
|
+
}
|
|
128433
|
+
}
|
|
128434
|
+
async tickOnce(now2, result) {
|
|
128435
|
+
let jobs = this.store.listEnabled();
|
|
128277
128436
|
result.evaluated = jobs.length;
|
|
128437
|
+
const due = jobs.filter((job) => !this.running.has(job.jobKind) && job.nextRunAt <= now2);
|
|
128438
|
+
if (due.length > 0) {
|
|
128439
|
+
if (await this.heavyWorkBusy()) {
|
|
128440
|
+
for (const job of due)
|
|
128441
|
+
this.deferred.add(job.id);
|
|
128442
|
+
result.deferred = due.length;
|
|
128443
|
+
return result;
|
|
128444
|
+
}
|
|
128445
|
+
jobs = this.store.listEnabled();
|
|
128446
|
+
}
|
|
128278
128447
|
for (const job of jobs) {
|
|
128279
128448
|
if (this.running.has(job.jobKind)) {
|
|
128280
128449
|
result.skipped++;
|
|
@@ -128284,7 +128453,7 @@ class Scheduler {
|
|
|
128284
128453
|
continue;
|
|
128285
128454
|
}
|
|
128286
128455
|
const overdueMs = now2 - job.nextRunAt;
|
|
128287
|
-
const isMissed = overdueMs > this.tickIntervalMs;
|
|
128456
|
+
const isMissed = overdueMs > this.tickIntervalMs && !this.deferred.has(job.id);
|
|
128288
128457
|
if (isMissed) {
|
|
128289
128458
|
logger.warn("Scheduler: missed run (skipping, rescheduling)", {
|
|
128290
128459
|
id: job.id,
|
|
@@ -128306,7 +128475,42 @@ class Scheduler {
|
|
|
128306
128475
|
}
|
|
128307
128476
|
return result;
|
|
128308
128477
|
}
|
|
128478
|
+
async heavyWorkBusy() {
|
|
128479
|
+
let state;
|
|
128480
|
+
try {
|
|
128481
|
+
state = await this.heavyWorkProbe();
|
|
128482
|
+
} catch (e) {
|
|
128483
|
+
this.consecutiveProbeFailures++;
|
|
128484
|
+
this.lastProbeError = e.message;
|
|
128485
|
+
if (this.consecutiveProbeFailures === 1 || this.consecutiveProbeFailures % PROBE_FAILURE_WARN_EVERY === 0) {
|
|
128486
|
+
logger.warn("Scheduler: heavy-work probe failed; deferring due jobs", {
|
|
128487
|
+
consecutiveFailures: this.consecutiveProbeFailures,
|
|
128488
|
+
error: e
|
|
128489
|
+
});
|
|
128490
|
+
}
|
|
128491
|
+
return true;
|
|
128492
|
+
}
|
|
128493
|
+
this.consecutiveProbeFailures = 0;
|
|
128494
|
+
this.lastProbeError = null;
|
|
128495
|
+
if (state.busy) {
|
|
128496
|
+
if (this.heavyWorkReason === null) {
|
|
128497
|
+
logger.info("Scheduler: heavy database work in progress; deferring due jobs", {
|
|
128498
|
+
reason: state.reason ?? "unknown"
|
|
128499
|
+
});
|
|
128500
|
+
}
|
|
128501
|
+
this.heavyWorkReason = state.reason ?? "unknown";
|
|
128502
|
+
return true;
|
|
128503
|
+
}
|
|
128504
|
+
if (this.heavyWorkReason !== null) {
|
|
128505
|
+
logger.info("Scheduler: heavy database work finished; running deferred jobs", {
|
|
128506
|
+
deferred: this.deferred.size
|
|
128507
|
+
});
|
|
128508
|
+
this.heavyWorkReason = null;
|
|
128509
|
+
}
|
|
128510
|
+
return false;
|
|
128511
|
+
}
|
|
128309
128512
|
fireJob(job, firedAt) {
|
|
128513
|
+
this.deferred.delete(job.id);
|
|
128310
128514
|
const handler = this.handlers.get(job.jobKind);
|
|
128311
128515
|
if (!handler) {
|
|
128312
128516
|
logger.warn("Scheduler: no handler registered for jobKind", {
|
|
@@ -128366,6 +128570,9 @@ class Scheduler {
|
|
|
128366
128570
|
}
|
|
128367
128571
|
})();
|
|
128368
128572
|
}
|
|
128573
|
+
async ready() {
|
|
128574
|
+
await this.store.ready?.();
|
|
128575
|
+
}
|
|
128369
128576
|
status(now2 = Date.now()) {
|
|
128370
128577
|
const jobs = this.store.listAll();
|
|
128371
128578
|
return {
|
|
@@ -128380,10 +128587,17 @@ class Scheduler {
|
|
|
128380
128587
|
nextRunAt: j.nextRunAt,
|
|
128381
128588
|
lastRunAt: j.lastRunAt,
|
|
128382
128589
|
lastSuccessAt: j.lastSuccessAt ?? null,
|
|
128590
|
+
lastFailureAt: j.lastFailureAt ?? null,
|
|
128383
128591
|
consecutiveFailures: j.consecutiveFailures ?? 0,
|
|
128592
|
+
lastError: j.lastError ?? null,
|
|
128384
128593
|
due: j.enabled && j.nextRunAt <= now2,
|
|
128385
|
-
currentlyRunning: this.running.has(j.jobKind)
|
|
128386
|
-
|
|
128594
|
+
currentlyRunning: this.running.has(j.jobKind),
|
|
128595
|
+
deferred: this.deferred.has(j.id)
|
|
128596
|
+
})),
|
|
128597
|
+
heavyWork: {
|
|
128598
|
+
lastProbeError: this.lastProbeError,
|
|
128599
|
+
consecutiveProbeFailures: this.consecutiveProbeFailures
|
|
128600
|
+
}
|
|
128387
128601
|
};
|
|
128388
128602
|
}
|
|
128389
128603
|
isJobRunning(jobKind) {
|
|
@@ -128402,12 +128616,13 @@ function resetScheduler() {
|
|
|
128402
128616
|
}
|
|
128403
128617
|
resetScheduledJobStore();
|
|
128404
128618
|
}
|
|
128405
|
-
var DEFAULTS, cachedScheduler = null;
|
|
128619
|
+
var DEFAULTS, PROBE_FAILURE_WARN_EVERY = 5, cachedScheduler = null;
|
|
128406
128620
|
var init_scheduler = __esm(() => {
|
|
128407
128621
|
init_dist();
|
|
128408
128622
|
init_config();
|
|
128409
128623
|
init_scheduler_cron();
|
|
128410
128624
|
init_scheduler_store_factory();
|
|
128625
|
+
init_heavy_work_lease();
|
|
128411
128626
|
DEFAULTS = {
|
|
128412
128627
|
tickMs: 60000,
|
|
128413
128628
|
maxConcurrent: 2
|
|
@@ -129316,7 +129531,7 @@ var init_auto_improve_llm = __esm(() => {
|
|
|
129316
129531
|
});
|
|
129317
129532
|
|
|
129318
129533
|
// ../../packages/core/dist/services/jobs/auto-improve-apply.js
|
|
129319
|
-
import { randomUUID as
|
|
129534
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
129320
129535
|
function validateCreatePayload(p) {
|
|
129321
129536
|
if ("type" in p && p.type !== undefined && p.type !== null) {
|
|
129322
129537
|
if (typeof p.type !== "string" || !VALID_MEMORY_TYPES.has(p.type)) {
|
|
@@ -129357,7 +129572,7 @@ function buildUpdatePatch(p) {
|
|
|
129357
129572
|
return patch;
|
|
129358
129573
|
}
|
|
129359
129574
|
async function applyProposal(job, record2) {
|
|
129360
|
-
const memId = record2.targetMemoryId ?? `proposal-mem-${record2.id}-${
|
|
129575
|
+
const memId = record2.targetMemoryId ?? `proposal-mem-${record2.id}-${randomUUID7().slice(0, 8)}`;
|
|
129361
129576
|
const p = record2.payload;
|
|
129362
129577
|
if (record2.kind === "memory.create") {
|
|
129363
129578
|
validateCreatePayload(p);
|
|
@@ -129624,8 +129839,8 @@ __export(exports_auto_improve_job, {
|
|
|
129624
129839
|
|
|
129625
129840
|
class AutoImproveJob {
|
|
129626
129841
|
llm;
|
|
129627
|
-
|
|
129628
|
-
|
|
129842
|
+
injectedObservationStore;
|
|
129843
|
+
injectedProposalStore;
|
|
129629
129844
|
memoryRepo;
|
|
129630
129845
|
thresholds;
|
|
129631
129846
|
minObservations;
|
|
@@ -129636,10 +129851,16 @@ class AutoImproveJob {
|
|
|
129636
129851
|
lastRunAt = 0;
|
|
129637
129852
|
newSinceRun = 0;
|
|
129638
129853
|
runCalls = 0;
|
|
129854
|
+
get observationStore() {
|
|
129855
|
+
return this.injectedObservationStore ?? getObservationStore();
|
|
129856
|
+
}
|
|
129857
|
+
get proposalStore() {
|
|
129858
|
+
return this.injectedProposalStore ?? getProposalStore();
|
|
129859
|
+
}
|
|
129639
129860
|
constructor(opts = {}) {
|
|
129640
129861
|
this.llm = opts.llm ?? llm;
|
|
129641
|
-
this.
|
|
129642
|
-
this.
|
|
129862
|
+
this.injectedObservationStore = opts.observationStore;
|
|
129863
|
+
this.injectedProposalStore = opts.proposalStore;
|
|
129643
129864
|
this.thresholds = { ...DEFAULT_THRESHOLDS, ...opts.thresholds };
|
|
129644
129865
|
this.reviewGateOverride = opts.reviewGate;
|
|
129645
129866
|
this.idFactory = opts.idFactory ?? (() => newProposalId());
|
|
@@ -129719,7 +129940,7 @@ __export(exports_observation_consolidation_job, {
|
|
|
129719
129940
|
observationConsolidationJob: () => observationConsolidationJob,
|
|
129720
129941
|
ObservationConsolidationJob: () => ObservationConsolidationJob
|
|
129721
129942
|
});
|
|
129722
|
-
import { randomUUID as
|
|
129943
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
129723
129944
|
function readBridgeConfig() {
|
|
129724
129945
|
try {
|
|
129725
129946
|
const c = config.get("hooks")?.bridge;
|
|
@@ -129737,7 +129958,7 @@ function readBridgeConfig() {
|
|
|
129737
129958
|
|
|
129738
129959
|
class ObservationConsolidationJob {
|
|
129739
129960
|
llm;
|
|
129740
|
-
|
|
129961
|
+
injectedStore;
|
|
129741
129962
|
memoryRepo;
|
|
129742
129963
|
minObservations;
|
|
129743
129964
|
minIntervalMs;
|
|
@@ -129745,9 +129966,12 @@ class ObservationConsolidationJob {
|
|
|
129745
129966
|
lastRunAt = 0;
|
|
129746
129967
|
newSinceRun = 0;
|
|
129747
129968
|
runCalls = 0;
|
|
129969
|
+
get store() {
|
|
129970
|
+
return this.injectedStore ?? getObservationStore();
|
|
129971
|
+
}
|
|
129748
129972
|
constructor(opts = {}) {
|
|
129749
129973
|
this.llm = opts.llm ?? llm;
|
|
129750
|
-
this.
|
|
129974
|
+
this.injectedStore = opts.store;
|
|
129751
129975
|
const injected = opts.memoryRepo;
|
|
129752
129976
|
this.memoryRepo = injected ?? { insert: (i) => getMemoryRepository().insert(i) };
|
|
129753
129977
|
const cfg = readBridgeConfig();
|
|
@@ -129809,7 +130033,7 @@ class ObservationConsolidationJob {
|
|
|
129809
130033
|
if (observations.length < 2)
|
|
129810
130034
|
return noop2;
|
|
129811
130035
|
const window2 = observations.slice(0, this.maxWindow);
|
|
129812
|
-
const batchId = `obs-batch-${Date.now()}-${
|
|
130036
|
+
const batchId = `obs-batch-${Date.now()}-${randomUUID8().slice(0, 8)}`;
|
|
129813
130037
|
const prompt = buildObservationPrompt(window2);
|
|
129814
130038
|
let batch;
|
|
129815
130039
|
try {
|
|
@@ -129835,7 +130059,7 @@ class ObservationConsolidationJob {
|
|
|
129835
130059
|
}
|
|
129836
130060
|
if (!batch)
|
|
129837
130061
|
return noop2;
|
|
129838
|
-
const newId = `mem-${Date.now()}-${
|
|
130062
|
+
const newId = `mem-${Date.now()}-${randomUUID8().slice(0, 8)}`;
|
|
129839
130063
|
const importance = 0.7;
|
|
129840
130064
|
try {
|
|
129841
130065
|
await Promise.resolve(this.memoryRepo.insert({
|
|
@@ -130453,7 +130677,7 @@ var init_scheduler2 = __esm(() => {
|
|
|
130453
130677
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
130454
130678
|
import fs18 from "fs/promises";
|
|
130455
130679
|
import { existsSync as existsSync4 } from "fs";
|
|
130456
|
-
import
|
|
130680
|
+
import path25 from "path";
|
|
130457
130681
|
function getModelsDevClient() {
|
|
130458
130682
|
if (!clientInstance) {
|
|
130459
130683
|
clientInstance = new ModelsDevClient;
|
|
@@ -130473,7 +130697,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
130473
130697
|
memoryCacheTimestamp = 0;
|
|
130474
130698
|
getLocalCachePath() {
|
|
130475
130699
|
const dataDir = config.get("dataDir");
|
|
130476
|
-
return
|
|
130700
|
+
return path25.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
130477
130701
|
}
|
|
130478
130702
|
async loadLocalCache() {
|
|
130479
130703
|
const cachePath = this.getLocalCachePath();
|
|
@@ -130508,7 +130732,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
130508
130732
|
async saveLocalCache(models) {
|
|
130509
130733
|
const cachePath = this.getLocalCachePath();
|
|
130510
130734
|
try {
|
|
130511
|
-
const dir =
|
|
130735
|
+
const dir = path25.dirname(cachePath);
|
|
130512
130736
|
await fs18.mkdir(dir, { recursive: true });
|
|
130513
130737
|
const data = {
|
|
130514
130738
|
timestamp: Date.now(),
|
|
@@ -131450,7 +131674,7 @@ function stripNul(content) {
|
|
|
131450
131674
|
|
|
131451
131675
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
131452
131676
|
import fs19 from "fs/promises";
|
|
131453
|
-
import
|
|
131677
|
+
import path26 from "path";
|
|
131454
131678
|
import { createHash as createHash8 } from "crypto";
|
|
131455
131679
|
|
|
131456
131680
|
class DiscoverStage {
|
|
@@ -131476,7 +131700,7 @@ class DiscoverStage {
|
|
|
131476
131700
|
dot: false,
|
|
131477
131701
|
absolute: false
|
|
131478
131702
|
});
|
|
131479
|
-
relPaths = found.map((p) =>
|
|
131703
|
+
relPaths = found.map((p) => path26.isAbsolute(p) ? path26.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
131480
131704
|
}
|
|
131481
131705
|
if (ctx.resumeCursor?.path) {
|
|
131482
131706
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -131535,7 +131759,7 @@ class DiscoverStage {
|
|
|
131535
131759
|
return discovered;
|
|
131536
131760
|
}
|
|
131537
131761
|
async processFile(ctx, relativePath, forceReindex) {
|
|
131538
|
-
const absolutePath =
|
|
131762
|
+
const absolutePath = path26.join(ctx.projectPath, relativePath);
|
|
131539
131763
|
try {
|
|
131540
131764
|
const stat = await fs19.stat(absolutePath);
|
|
131541
131765
|
const content = stripNul(await fs19.readFile(absolutePath, "utf-8"));
|
|
@@ -131582,7 +131806,7 @@ class DiscoverStage {
|
|
|
131582
131806
|
ig.add(pattern);
|
|
131583
131807
|
}
|
|
131584
131808
|
try {
|
|
131585
|
-
const gitignorePath =
|
|
131809
|
+
const gitignorePath = path26.join(projectPath, ".gitignore");
|
|
131586
131810
|
const gitignoreContent = await fs19.readFile(gitignorePath, "utf8");
|
|
131587
131811
|
const rules = gitignoreContent.split(`
|
|
131588
131812
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
@@ -132938,8 +133162,8 @@ function rustUseLeaves(node, source, prefix = []) {
|
|
|
132938
133162
|
}
|
|
132939
133163
|
if (node.type === "use_wildcard")
|
|
132940
133164
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
132941
|
-
const
|
|
132942
|
-
return
|
|
133165
|
+
const path27 = rustPathSegments(node, source);
|
|
133166
|
+
return path27.length ? [{ path: [...prefix, ...path27] }] : [];
|
|
132943
133167
|
}
|
|
132944
133168
|
function functionalCaptures(captures, source, family) {
|
|
132945
133169
|
if (family !== "clojure")
|
|
@@ -133911,7 +134135,7 @@ var init_structural_runtime = __esm(() => {
|
|
|
133911
134135
|
});
|
|
133912
134136
|
|
|
133913
134137
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
133914
|
-
import
|
|
134138
|
+
import path27 from "path";
|
|
133915
134139
|
import fs20 from "fs/promises";
|
|
133916
134140
|
function resolveChunkerMaxChars() {
|
|
133917
134141
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
@@ -133940,8 +134164,8 @@ class ParseStage {
|
|
|
133940
134164
|
const results = new Map;
|
|
133941
134165
|
let processed = 0;
|
|
133942
134166
|
const phases = [
|
|
133943
|
-
files.filter((file2) =>
|
|
133944
|
-
files.filter((file2) =>
|
|
134167
|
+
files.filter((file2) => path27.extname(file2.relativePath).toLowerCase() !== ".h"),
|
|
134168
|
+
files.filter((file2) => path27.extname(file2.relativePath).toLowerCase() === ".h")
|
|
133945
134169
|
];
|
|
133946
134170
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
133947
134171
|
for (const batch of batches) {
|
|
@@ -133979,19 +134203,19 @@ class ParseStage {
|
|
|
133979
134203
|
return files.map((file2) => results.get(file2.relativePath));
|
|
133980
134204
|
}
|
|
133981
134205
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
133982
|
-
const knownHeaders = new Set(files.filter((file2) =>
|
|
134206
|
+
const knownHeaders = new Set(files.filter((file2) => path27.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path27.posix.normalize(file2.relativePath)));
|
|
133983
134207
|
const mutable = {
|
|
133984
134208
|
...ctx.structuralHeaderEvidenceByFile
|
|
133985
134209
|
};
|
|
133986
134210
|
for (const parsed of parsedFiles) {
|
|
133987
|
-
const extension =
|
|
134211
|
+
const extension = path27.extname(parsed.file.relativePath).toLowerCase();
|
|
133988
134212
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
133989
134213
|
if (!key)
|
|
133990
134214
|
continue;
|
|
133991
134215
|
for (const imported of parsed.rawImports) {
|
|
133992
134216
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
133993
134217
|
continue;
|
|
133994
|
-
const header =
|
|
134218
|
+
const header = path27.posix.normalize(path27.posix.join(path27.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
133995
134219
|
if (!knownHeaders.has(header))
|
|
133996
134220
|
continue;
|
|
133997
134221
|
const existing = mutable[header] ?? {};
|
|
@@ -134002,7 +134226,7 @@ class ParseStage {
|
|
|
134002
134226
|
}
|
|
134003
134227
|
async parseFile(ctx, file2) {
|
|
134004
134228
|
if (!file2.needsReparse) {
|
|
134005
|
-
const extension =
|
|
134229
|
+
const extension = path27.extname(file2.relativePath).toLowerCase();
|
|
134006
134230
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
134007
134231
|
const content = file2.snapshotContent ?? await fs20.readFile(file2.absolutePath, "utf8");
|
|
134008
134232
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
@@ -134017,7 +134241,7 @@ class ParseStage {
|
|
|
134017
134241
|
}
|
|
134018
134242
|
try {
|
|
134019
134243
|
const content = file2.snapshotContent ?? await fs20.readFile(file2.absolutePath, "utf-8");
|
|
134020
|
-
const ext2 =
|
|
134244
|
+
const ext2 = path27.extname(file2.relativePath).toLowerCase();
|
|
134021
134245
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
134022
134246
|
const chunks = smartChunk(content, file2.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
134023
134247
|
let symbols;
|
|
@@ -134572,7 +134796,7 @@ var init_resolver = __esm(() => {
|
|
|
134572
134796
|
});
|
|
134573
134797
|
|
|
134574
134798
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
134575
|
-
import
|
|
134799
|
+
import path28 from "path";
|
|
134576
134800
|
function candidates(identities) {
|
|
134577
134801
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
134578
134802
|
fqn: identity.fqn,
|
|
@@ -134667,7 +134891,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
134667
134891
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
134668
134892
|
for (const candidateBase of bases)
|
|
134669
134893
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
134670
|
-
const value =
|
|
134894
|
+
const value = path28.posix.normalize(`${candidateBase}${suffix}`);
|
|
134671
134895
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
134672
134896
|
return value;
|
|
134673
134897
|
}
|
|
@@ -134676,7 +134900,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
134676
134900
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
134677
134901
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
134678
134902
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
134679
|
-
return probe(
|
|
134903
|
+
return probe(path28.posix.join(path28.posix.dirname(fromFile), specifier), known, dialect);
|
|
134680
134904
|
}
|
|
134681
134905
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
134682
134906
|
for (const alias of aliases) {
|
|
@@ -134940,7 +135164,7 @@ var init_scripting2 = __esm(() => {
|
|
|
134940
135164
|
});
|
|
134941
135165
|
|
|
134942
135166
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
134943
|
-
import
|
|
135167
|
+
import path29 from "path";
|
|
134944
135168
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
134945
135169
|
var init_systems2 = __esm(() => {
|
|
134946
135170
|
init_typescript2();
|
|
@@ -134959,7 +135183,7 @@ var init_systems2 = __esm(() => {
|
|
|
134959
135183
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
134960
135184
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
134961
135185
|
const crateRoot = file2.file.startsWith("src/") ? "src" : "";
|
|
134962
|
-
return { ...item, bindings, specifier: `./${
|
|
135186
|
+
return { ...item, bindings, specifier: `./${path29.posix.relative(path29.posix.dirname(file2.file), path29.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
134963
135187
|
}
|
|
134964
135188
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
134965
135189
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -135057,7 +135281,7 @@ var init_data_document2 = __esm(() => {
|
|
|
135057
135281
|
});
|
|
135058
135282
|
|
|
135059
135283
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
135060
|
-
import
|
|
135284
|
+
import path30 from "path";
|
|
135061
135285
|
import fs21 from "fs";
|
|
135062
135286
|
|
|
135063
135287
|
class ResolveStage {
|
|
@@ -135082,7 +135306,7 @@ class ResolveStage {
|
|
|
135082
135306
|
const structuralDocuments = files.flatMap((file2) => {
|
|
135083
135307
|
if (!file2.structure)
|
|
135084
135308
|
return [];
|
|
135085
|
-
const language = resolveStructuralLanguage(
|
|
135309
|
+
const language = resolveStructuralLanguage(path30.extname(file2.file.relativePath));
|
|
135086
135310
|
if (language.status !== "supported")
|
|
135087
135311
|
throw new Error(`structural_manifest_missing:${file2.file.relativePath}`);
|
|
135088
135312
|
return [{
|
|
@@ -135094,13 +135318,13 @@ class ResolveStage {
|
|
|
135094
135318
|
}];
|
|
135095
135319
|
});
|
|
135096
135320
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
135097
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
135321
|
+
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path30.extname(item.file.relativePath).toLowerCase())).map((item) => item.file.relativePath));
|
|
135098
135322
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file2) => [
|
|
135099
135323
|
file2,
|
|
135100
135324
|
this.structuralAliasesFor(file2, rootAliases, monorepoPackages)
|
|
135101
135325
|
]));
|
|
135102
135326
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
135103
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
135327
|
+
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(path30.extname(definition.file_path).toLowerCase())).filter((definition) => knownRelPaths.has(definition.file_path) && skippedStructuralFiles.has(definition.file_path)).filter((definition) => !currentStructuralFiles.has(definition.file_path));
|
|
135104
135328
|
const seedIds = new Set;
|
|
135105
135329
|
for (const definition of seedRows) {
|
|
135106
135330
|
if (seedIds.has(definition.id))
|
|
@@ -135197,7 +135421,7 @@ class ResolveStage {
|
|
|
135197
135421
|
if (parsed.file !== definition.file_path) {
|
|
135198
135422
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
135199
135423
|
}
|
|
135200
|
-
const language = resolveStructuralLanguage(
|
|
135424
|
+
const language = resolveStructuralLanguage(path30.extname(definition.file_path));
|
|
135201
135425
|
if (language.status !== "supported")
|
|
135202
135426
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
135203
135427
|
let identity;
|
|
@@ -135249,7 +135473,7 @@ class ResolveStage {
|
|
|
135249
135473
|
});
|
|
135250
135474
|
}
|
|
135251
135475
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
135252
|
-
const fromDir =
|
|
135476
|
+
const fromDir = path30.dirname(path30.join(projectPath, parsed.file.relativePath));
|
|
135253
135477
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
135254
135478
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
135255
135479
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -135320,7 +135544,7 @@ class ResolveStage {
|
|
|
135320
135544
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
135321
135545
|
}
|
|
135322
135546
|
} catch (err) {
|
|
135323
|
-
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
135547
|
+
const skippedStructural = files.some((file2) => !file2.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path30.extname(file2.file.relativePath).toLowerCase()));
|
|
135324
135548
|
if (skippedStructural)
|
|
135325
135549
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
135326
135550
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
@@ -135344,7 +135568,7 @@ class ResolveStage {
|
|
|
135344
135568
|
}
|
|
135345
135569
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
135346
135570
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
135347
|
-
const resolved = this.probeExtensions(
|
|
135571
|
+
const resolved = this.probeExtensions(path30.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
135348
135572
|
return { resolvedPath: resolved, external: false };
|
|
135349
135573
|
}
|
|
135350
135574
|
for (const alias of aliases) {
|
|
@@ -135352,8 +135576,8 @@ class ResolveStage {
|
|
|
135352
135576
|
const suffix = specifier.slice(alias.prefix.length);
|
|
135353
135577
|
for (const target of alias.targets) {
|
|
135354
135578
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
135355
|
-
const basePath = alias.packagePath ?
|
|
135356
|
-
const absPath =
|
|
135579
|
+
const basePath = alias.packagePath ? path30.join(projectPath, alias.packagePath) : projectPath;
|
|
135580
|
+
const absPath = path30.join(basePath, cleanTarget + suffix);
|
|
135357
135581
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
135358
135582
|
if (resolved)
|
|
135359
135583
|
return { resolvedPath: resolved, external: false };
|
|
@@ -135369,7 +135593,7 @@ class ResolveStage {
|
|
|
135369
135593
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
135370
135594
|
];
|
|
135371
135595
|
for (const candidate2 of candidates2) {
|
|
135372
|
-
const rel =
|
|
135596
|
+
const rel = path30.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
135373
135597
|
if (knownRelPaths.has(rel))
|
|
135374
135598
|
return rel;
|
|
135375
135599
|
}
|
|
@@ -135377,7 +135601,7 @@ class ResolveStage {
|
|
|
135377
135601
|
}
|
|
135378
135602
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
135379
135603
|
const aliases = [];
|
|
135380
|
-
const tsconfigPath =
|
|
135604
|
+
const tsconfigPath = path30.join(projectPath, "tsconfig.json");
|
|
135381
135605
|
try {
|
|
135382
135606
|
const raw2 = fs21.readFileSync(tsconfigPath, "utf-8");
|
|
135383
135607
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
@@ -135408,7 +135632,7 @@ class ResolveStage {
|
|
|
135408
135632
|
}
|
|
135409
135633
|
}
|
|
135410
135634
|
for (const packageRelPath of packagePaths) {
|
|
135411
|
-
const absPackagePath =
|
|
135635
|
+
const absPackagePath = path30.join(projectPath, packageRelPath);
|
|
135412
135636
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
135413
135637
|
if (aliases.length > 0) {
|
|
135414
135638
|
packages.push({
|
|
@@ -135438,7 +135662,7 @@ class ResolveStage {
|
|
|
135438
135662
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
135439
135663
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
135440
135664
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
135441
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
135665
|
+
targets: alias.targets.map((target) => alias.packagePath ? path30.posix.join(alias.packagePath, target) : target)
|
|
135442
135666
|
}));
|
|
135443
135667
|
}
|
|
135444
135668
|
}
|
|
@@ -135502,7 +135726,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
135502
135726
|
});
|
|
135503
135727
|
|
|
135504
135728
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
135505
|
-
import
|
|
135729
|
+
import path31 from "path";
|
|
135506
135730
|
function formatDuration(ms) {
|
|
135507
135731
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
135508
135732
|
if (totalSec < 60)
|
|
@@ -135779,7 +136003,7 @@ class LoadStage {
|
|
|
135779
136003
|
const filePath = file2.file.relativePath;
|
|
135780
136004
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file2);
|
|
135781
136005
|
if (ctx.graphGenerationLease) {
|
|
135782
|
-
const manifest = getLanguageManifestEntry(
|
|
136006
|
+
const manifest = getLanguageManifestEntry(path31.extname(filePath));
|
|
135783
136007
|
const diagnostics2 = (file2.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
135784
136008
|
code: diagnostic2.code,
|
|
135785
136009
|
severity: diagnostic2.severity,
|
|
@@ -135831,7 +136055,7 @@ var init_load = __esm(() => {
|
|
|
135831
136055
|
});
|
|
135832
136056
|
|
|
135833
136057
|
// ../../packages/core/dist/data/graph-generation/graph-generation-repository-pg.js
|
|
135834
|
-
import { randomUUID as
|
|
136058
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
135835
136059
|
function boundedText2(value, label, max = 512) {
|
|
135836
136060
|
const normalized = value.normalize("NFC").trim();
|
|
135837
136061
|
if (!normalized || normalized.length > max || normalized.includes("\x00")) {
|
|
@@ -135935,8 +136159,8 @@ class GraphGenerationRepositoryPg {
|
|
|
135935
136159
|
}
|
|
135936
136160
|
async begin(rawInput) {
|
|
135937
136161
|
const input = validateBegin2(rawInput);
|
|
135938
|
-
const generationId =
|
|
135939
|
-
const leaseToken =
|
|
136162
|
+
const generationId = randomUUID9();
|
|
136163
|
+
const leaseToken = randomUUID9();
|
|
135940
136164
|
return getPrismaClient2().$transaction(async (tx) => {
|
|
135941
136165
|
const workspace = await lockWorkspace(tx, input.projectId);
|
|
135942
136166
|
if (workspace.active_graph_generation_id !== input.expectedActiveGenerationId) {
|
|
@@ -136176,8 +136400,8 @@ function buildGraphInputSnapshotHash(files) {
|
|
|
136176
136400
|
|
|
136177
136401
|
class GraphGenerationCoordinator {
|
|
136178
136402
|
repository;
|
|
136179
|
-
constructor(
|
|
136180
|
-
this.repository =
|
|
136403
|
+
constructor(repository2 = getGraphGenerationRepository()) {
|
|
136404
|
+
this.repository = repository2;
|
|
136181
136405
|
}
|
|
136182
136406
|
async begin(input) {
|
|
136183
136407
|
const deadline = Date.now() + GRAPH_GENERATION_LEASE_TTL_MS;
|
|
@@ -136235,10 +136459,10 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
136235
136459
|
|
|
136236
136460
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
136237
136461
|
import { createHash as createHash10 } from "crypto";
|
|
136238
|
-
import { setTimeout as
|
|
136239
|
-
import
|
|
136462
|
+
import { setTimeout as delay3 } from "timers/promises";
|
|
136463
|
+
import path32 from "path";
|
|
136240
136464
|
function buildHeaderLanguageEvidence(files) {
|
|
136241
|
-
const headers = new Set(files.filter((file2) =>
|
|
136465
|
+
const headers = new Set(files.filter((file2) => path32.posix.extname(file2.relativePath).toLowerCase() === ".h").map((file2) => path32.posix.normalize(file2.relativePath)));
|
|
136242
136466
|
const mutable = new Map;
|
|
136243
136467
|
const entry2 = (header) => {
|
|
136244
136468
|
let value = mutable.get(header);
|
|
@@ -136249,7 +136473,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
136249
136473
|
return value;
|
|
136250
136474
|
};
|
|
136251
136475
|
for (const file2 of files) {
|
|
136252
|
-
if (
|
|
136476
|
+
if (path32.posix.basename(file2.relativePath) !== "compile_commands.json" || file2.snapshotContent === undefined)
|
|
136253
136477
|
continue;
|
|
136254
136478
|
let commands;
|
|
136255
136479
|
try {
|
|
@@ -136265,11 +136489,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
136265
136489
|
const record2 = command;
|
|
136266
136490
|
if (typeof record2.file !== "string")
|
|
136267
136491
|
continue;
|
|
136268
|
-
const projectRoot =
|
|
136269
|
-
const commandDirectory = typeof record2.directory === "string" ?
|
|
136270
|
-
const absoluteInput =
|
|
136271
|
-
const relative3 =
|
|
136272
|
-
const header =
|
|
136492
|
+
const projectRoot = path32.resolve(file2.absolutePath, ...file2.relativePath.split("/").map(() => ".."));
|
|
136493
|
+
const commandDirectory = typeof record2.directory === "string" ? path32.resolve(projectRoot, record2.directory) : projectRoot;
|
|
136494
|
+
const absoluteInput = path32.resolve(commandDirectory, record2.file);
|
|
136495
|
+
const relative3 = path32.relative(projectRoot, absoluteInput);
|
|
136496
|
+
const header = path32.posix.normalize(relative3.replaceAll(path32.sep, "/"));
|
|
136273
136497
|
if (!headers.has(header))
|
|
136274
136498
|
continue;
|
|
136275
136499
|
const invocation = typeof record2.command === "string" ? record2.command : Array.isArray(record2.arguments) ? record2.arguments.join(" ") : "";
|
|
@@ -136319,6 +136543,7 @@ var init_pipeline = __esm(() => {
|
|
|
136319
136543
|
init_language_manifest();
|
|
136320
136544
|
init_graph_generation_coordinator();
|
|
136321
136545
|
init_managed_run_repository_pg();
|
|
136546
|
+
init_workspace_manager();
|
|
136322
136547
|
EtlPipeline = class EtlPipeline {
|
|
136323
136548
|
static instance = null;
|
|
136324
136549
|
static runTails = new Map;
|
|
@@ -136434,7 +136659,7 @@ var init_pipeline = __esm(() => {
|
|
|
136434
136659
|
managedRunHeartbeat = (async () => {
|
|
136435
136660
|
while (!stopManagedRunHeartbeat) {
|
|
136436
136661
|
try {
|
|
136437
|
-
await
|
|
136662
|
+
await delay3(30000, undefined, { signal: managedRunTimerController.signal });
|
|
136438
136663
|
} catch {
|
|
136439
136664
|
return;
|
|
136440
136665
|
}
|
|
@@ -136455,11 +136680,25 @@ var init_pipeline = __esm(() => {
|
|
|
136455
136680
|
}
|
|
136456
136681
|
})();
|
|
136457
136682
|
}
|
|
136683
|
+
const jobHeartbeatController = new AbortController;
|
|
136684
|
+
(async () => {
|
|
136685
|
+
while (true) {
|
|
136686
|
+
try {
|
|
136687
|
+
await delay3(30000, undefined, { signal: jobHeartbeatController.signal });
|
|
136688
|
+
} catch {
|
|
136689
|
+
return;
|
|
136690
|
+
}
|
|
136691
|
+
try {
|
|
136692
|
+
indexJobTracker.heartbeat(jobId);
|
|
136693
|
+
} catch {}
|
|
136694
|
+
}
|
|
136695
|
+
})();
|
|
136458
136696
|
try {
|
|
136459
136697
|
const st1 = performance.now();
|
|
136460
136698
|
const discoveredSnapshot = await this.discover.run(ctx, { forceReindex, includeTests: include_tests });
|
|
136461
136699
|
ctx.structuralHeaderEvidenceByFile = buildHeaderLanguageEvidence(discoveredSnapshot);
|
|
136462
136700
|
stageTimings.discover = Math.round(performance.now() - st1);
|
|
136701
|
+
await workspaceManager.markIndexing(projectId, projectPath);
|
|
136463
136702
|
const activeGraph = await getSymbolRepository().getActiveGraphSnapshot(projectId);
|
|
136464
136703
|
try {
|
|
136465
136704
|
graphGenerationLease = await this.graphGenerations.begin({
|
|
@@ -136473,6 +136712,7 @@ var init_pipeline = __esm(() => {
|
|
|
136473
136712
|
if (beginError.message.startsWith("graph_generation_stale_active:") && generationRetry < 3) {
|
|
136474
136713
|
stopManagedRunHeartbeat = true;
|
|
136475
136714
|
managedRunTimerController.abort();
|
|
136715
|
+
jobHeartbeatController.abort();
|
|
136476
136716
|
if (managedRunHeartbeat)
|
|
136477
136717
|
await managedRunHeartbeat;
|
|
136478
136718
|
return this.runInternal(input, generationRetry + 1);
|
|
@@ -136484,7 +136724,7 @@ var init_pipeline = __esm(() => {
|
|
|
136484
136724
|
graphHeartbeat = (async () => {
|
|
136485
136725
|
while (!stopGraphHeartbeat) {
|
|
136486
136726
|
try {
|
|
136487
|
-
await
|
|
136727
|
+
await delay3(30000, undefined, { signal: heartbeatTimerController.signal });
|
|
136488
136728
|
} catch {
|
|
136489
136729
|
return;
|
|
136490
136730
|
}
|
|
@@ -136656,6 +136896,7 @@ var init_pipeline = __esm(() => {
|
|
|
136656
136896
|
activatedGraphGenerationId: result.activatedGraphGenerationId
|
|
136657
136897
|
});
|
|
136658
136898
|
await this.graphGenerations.cleanup(graphGenerationLease);
|
|
136899
|
+
jobHeartbeatController.abort();
|
|
136659
136900
|
stopGraphHeartbeat = true;
|
|
136660
136901
|
heartbeatTimerController.abort();
|
|
136661
136902
|
await graphHeartbeat;
|
|
@@ -136682,6 +136923,7 @@ var init_pipeline = __esm(() => {
|
|
|
136682
136923
|
logger.error("EtlPipeline: pending generation abort failed", abortError, { projectId, jobId });
|
|
136683
136924
|
}
|
|
136684
136925
|
}
|
|
136926
|
+
jobHeartbeatController.abort();
|
|
136685
136927
|
stopGraphHeartbeat = true;
|
|
136686
136928
|
heartbeatTimerController.abort();
|
|
136687
136929
|
graphAbortController.abort();
|
|
@@ -142154,33 +142396,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
142154
142396
|
else
|
|
142155
142397
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
142156
142398
|
}
|
|
142157
|
-
function remove_dot_segments(
|
|
142158
|
-
if (!
|
|
142159
|
-
return
|
|
142399
|
+
function remove_dot_segments(path33) {
|
|
142400
|
+
if (!path33)
|
|
142401
|
+
return path33;
|
|
142160
142402
|
var output = "";
|
|
142161
|
-
while (
|
|
142162
|
-
if (
|
|
142163
|
-
|
|
142403
|
+
while (path33.length > 0) {
|
|
142404
|
+
if (path33 === "." || path33 === "..") {
|
|
142405
|
+
path33 = "";
|
|
142164
142406
|
break;
|
|
142165
142407
|
}
|
|
142166
|
-
var twochars =
|
|
142167
|
-
var threechars =
|
|
142168
|
-
var fourchars =
|
|
142408
|
+
var twochars = path33.substring(0, 2);
|
|
142409
|
+
var threechars = path33.substring(0, 3);
|
|
142410
|
+
var fourchars = path33.substring(0, 4);
|
|
142169
142411
|
if (threechars === "../") {
|
|
142170
|
-
|
|
142412
|
+
path33 = path33.substring(3);
|
|
142171
142413
|
} else if (twochars === "./") {
|
|
142172
|
-
|
|
142414
|
+
path33 = path33.substring(2);
|
|
142173
142415
|
} else if (threechars === "/./") {
|
|
142174
|
-
|
|
142175
|
-
} else if (twochars === "/." &&
|
|
142176
|
-
|
|
142177
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
142178
|
-
|
|
142416
|
+
path33 = "/" + path33.substring(3);
|
|
142417
|
+
} else if (twochars === "/." && path33.length === 2) {
|
|
142418
|
+
path33 = "/";
|
|
142419
|
+
} else if (fourchars === "/../" || threechars === "/.." && path33.length === 3) {
|
|
142420
|
+
path33 = "/" + path33.substring(4);
|
|
142179
142421
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
142180
142422
|
} else {
|
|
142181
|
-
var segment =
|
|
142423
|
+
var segment = path33.match(/(\/?([^\/]*))/)[0];
|
|
142182
142424
|
output += segment;
|
|
142183
|
-
|
|
142425
|
+
path33 = path33.substring(segment.length);
|
|
142184
142426
|
}
|
|
142185
142427
|
}
|
|
142186
142428
|
return output;
|
|
@@ -154250,21 +154492,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
154250
154492
|
walk(value, label, out);
|
|
154251
154493
|
return out;
|
|
154252
154494
|
}
|
|
154253
|
-
function walk(val,
|
|
154495
|
+
function walk(val, path33, out) {
|
|
154254
154496
|
if (val === null || val === undefined)
|
|
154255
154497
|
return;
|
|
154256
154498
|
if (Array.isArray(val)) {
|
|
154257
154499
|
if (val.length === 0) {
|
|
154258
|
-
out.push({ path:
|
|
154500
|
+
out.push({ path: path33, content: `**${path33}** = _[]_` });
|
|
154259
154501
|
return;
|
|
154260
154502
|
}
|
|
154261
154503
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
154262
|
-
val.forEach((v, i) => walk(v, `${
|
|
154504
|
+
val.forEach((v, i) => walk(v, `${path33}[${i}]`, out));
|
|
154263
154505
|
return;
|
|
154264
154506
|
}
|
|
154265
154507
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
154266
154508
|
`);
|
|
154267
|
-
out.push({ path:
|
|
154509
|
+
out.push({ path: path33, content: `**${path33}**
|
|
154268
154510
|
|
|
154269
154511
|
${items}` });
|
|
154270
154512
|
return;
|
|
@@ -154272,16 +154514,16 @@ ${items}` });
|
|
|
154272
154514
|
if (typeof val === "object") {
|
|
154273
154515
|
const entries = Object.entries(val);
|
|
154274
154516
|
if (entries.length === 0) {
|
|
154275
|
-
out.push({ path:
|
|
154517
|
+
out.push({ path: path33, content: `**${path33}** = _{}_` });
|
|
154276
154518
|
return;
|
|
154277
154519
|
}
|
|
154278
154520
|
for (const [k, v] of entries) {
|
|
154279
154521
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
|
|
154280
|
-
walk(v, `${
|
|
154522
|
+
walk(v, `${path33}.${safeKey}`, out);
|
|
154281
154523
|
}
|
|
154282
154524
|
return;
|
|
154283
154525
|
}
|
|
154284
|
-
out.push({ path:
|
|
154526
|
+
out.push({ path: path33, content: `**${path33}** = \`${String(val)}\`` });
|
|
154285
154527
|
}
|
|
154286
154528
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
154287
154529
|
var init_html_to_md = __esm(() => {
|
|
@@ -154621,6 +154863,7 @@ var init_services = __esm(() => {
|
|
|
154621
154863
|
init_embeddings();
|
|
154622
154864
|
init_local_health_checker();
|
|
154623
154865
|
init_index_job_tracker();
|
|
154866
|
+
init_heavy_work_lease();
|
|
154624
154867
|
init_scheduler2();
|
|
154625
154868
|
init_models_dev_client();
|
|
154626
154869
|
init_memory_graph_service();
|
|
@@ -154709,7 +154952,7 @@ init_config();
|
|
|
154709
154952
|
init_dist();
|
|
154710
154953
|
init_inference_providers();
|
|
154711
154954
|
import os9 from "os";
|
|
154712
|
-
import
|
|
154955
|
+
import path33 from "path";
|
|
154713
154956
|
var WRITABLE_PROVIDERS = ["ollama", "lmstudio", "mistral", "openai", "google", "cohere"];
|
|
154714
154957
|
var GENERATOR_MARKER = "scripts/generate-subagent-artifacts.ts";
|
|
154715
154958
|
var GENERATOR_MARKER_MAX_LEVELS = 6;
|
|
@@ -155138,7 +155381,7 @@ Using defaults:`);
|
|
|
155138
155381
|
return 1;
|
|
155139
155382
|
}
|
|
155140
155383
|
const targetOpt = typeof options.target === "string" ? options.target : undefined;
|
|
155141
|
-
const targetHome = targetOpt === undefined ? os9.homedir() :
|
|
155384
|
+
const targetHome = targetOpt === undefined ? os9.homedir() : path33.resolve(targetOpt);
|
|
155142
155385
|
if (targetHome !== os9.homedir() && options.yes !== true) {
|
|
155143
155386
|
console.error(`Error: --target ${targetHome} is not your home (${os9.homedir()}) \u2014 pass --yes to confirm writing there`);
|
|
155144
155387
|
return 1;
|
|
@@ -155158,7 +155401,7 @@ Using defaults:`);
|
|
|
155158
155401
|
const report = applyBootstrapState({
|
|
155159
155402
|
targetHome,
|
|
155160
155403
|
dryRun,
|
|
155161
|
-
sourcePath: repoRoot === null ? undefined :
|
|
155404
|
+
sourcePath: repoRoot === null ? undefined : path33.join(repoRoot, "skills", "AGENTS.md")
|
|
155162
155405
|
});
|
|
155163
155406
|
console.log(formatBootstrapReport(report));
|
|
155164
155407
|
return bootstrapReportSucceeded(report) ? 0 : 1;
|