@askexenow/exe-os 0.9.21 → 0.9.22
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/bin/backfill-conversations.js +17 -4
- package/dist/bin/backfill-responses.js +17 -4
- package/dist/bin/backfill-vectors.js +2 -2
- package/dist/bin/cleanup-stale-review-tasks.js +17 -4
- package/dist/bin/cli.js +378 -171
- package/dist/bin/exe-assign.js +17 -4
- package/dist/bin/exe-boot.js +2 -2
- package/dist/bin/exe-dispatch.js +17 -4
- package/dist/bin/exe-doctor.js +2 -2
- package/dist/bin/exe-export-behaviors.js +17 -4
- package/dist/bin/exe-forget.js +17 -4
- package/dist/bin/exe-gateway.js +17 -4
- package/dist/bin/exe-heartbeat.js +17 -4
- package/dist/bin/exe-kill.js +17 -4
- package/dist/bin/exe-launch-agent.js +17 -4
- package/dist/bin/exe-pending-messages.js +17 -4
- package/dist/bin/exe-pending-notifications.js +17 -4
- package/dist/bin/exe-pending-reviews.js +17 -4
- package/dist/bin/exe-review.js +17 -4
- package/dist/bin/exe-search.js +23 -8
- package/dist/bin/exe-session-cleanup.js +17 -4
- package/dist/bin/exe-start-codex.js +209 -32
- package/dist/bin/exe-start-opencode.js +17 -4
- package/dist/bin/exe-status.js +17 -4
- package/dist/bin/exe-team.js +17 -4
- package/dist/bin/git-sweep.js +17 -4
- package/dist/bin/graph-backfill.js +17 -4
- package/dist/bin/graph-export.js +17 -4
- package/dist/bin/install.js +42 -0
- package/dist/bin/intercom-check.js +17 -4
- package/dist/bin/scan-tasks.js +17 -4
- package/dist/bin/shard-migrate.js +17 -4
- package/dist/bin/update.js +187 -42
- package/dist/gateway/index.js +17 -4
- package/dist/hooks/bug-report-worker.js +793 -150
- package/dist/hooks/codex-stop-task-finalizer.js +3020 -2375
- package/dist/hooks/commit-complete.js +156 -6
- package/dist/hooks/error-recall.js +23 -8
- package/dist/hooks/ingest.js +17 -4
- package/dist/hooks/instructions-loaded.js +17 -4
- package/dist/hooks/notification.js +17 -4
- package/dist/hooks/post-compact.js +17 -4
- package/dist/hooks/post-tool-combined.js +23 -8
- package/dist/hooks/pre-compact.js +156 -8
- package/dist/hooks/pre-tool-use.js +21 -12
- package/dist/hooks/prompt-submit.js +23 -8
- package/dist/hooks/session-end.js +156 -8
- package/dist/hooks/session-start.js +23 -8
- package/dist/hooks/stop.js +306 -9
- package/dist/hooks/subagent-stop.js +306 -9
- package/dist/hooks/summary-worker.js +2 -2
- package/dist/index.js +17 -4
- package/dist/lib/exe-daemon.js +17 -4
- package/dist/lib/hybrid-search.js +23 -8
- package/dist/lib/schedules.js +2 -2
- package/dist/lib/store.js +17 -4
- package/dist/mcp/server.js +36 -10
- package/dist/runtime/index.js +17 -4
- package/dist/tui/App.js +17 -4
- package/package.json +1 -1
|
@@ -1540,6 +1540,17 @@ var init_daemon_auth = __esm({
|
|
|
1540
1540
|
});
|
|
1541
1541
|
|
|
1542
1542
|
// src/lib/exe-daemon-client.ts
|
|
1543
|
+
var exe_daemon_client_exports = {};
|
|
1544
|
+
__export(exe_daemon_client_exports, {
|
|
1545
|
+
connectEmbedDaemon: () => connectEmbedDaemon,
|
|
1546
|
+
disconnectClient: () => disconnectClient,
|
|
1547
|
+
embedBatchViaClient: () => embedBatchViaClient,
|
|
1548
|
+
embedViaClient: () => embedViaClient,
|
|
1549
|
+
isClientConnected: () => isClientConnected,
|
|
1550
|
+
pingDaemon: () => pingDaemon,
|
|
1551
|
+
sendDaemonRequest: () => sendDaemonRequest,
|
|
1552
|
+
sendIngestRequest: () => sendIngestRequest
|
|
1553
|
+
});
|
|
1543
1554
|
import net from "net";
|
|
1544
1555
|
import os6 from "os";
|
|
1545
1556
|
import { spawn } from "child_process";
|
|
@@ -1928,6 +1939,15 @@ async function embedViaClient(text, priority = "high") {
|
|
|
1928
1939
|
);
|
|
1929
1940
|
return !result.error && result.vectors?.[0] ? result.vectors[0] : null;
|
|
1930
1941
|
}
|
|
1942
|
+
async function embedBatchViaClient(texts, priority = "high") {
|
|
1943
|
+
if (!_connected && !await connectEmbedDaemon()) return null;
|
|
1944
|
+
_requestCount++;
|
|
1945
|
+
const result = await retryThenRestart(
|
|
1946
|
+
() => sendRequest(texts, priority),
|
|
1947
|
+
"Batch embed"
|
|
1948
|
+
);
|
|
1949
|
+
return !result.error && result.vectors ? result.vectors : null;
|
|
1950
|
+
}
|
|
1931
1951
|
function disconnectClient() {
|
|
1932
1952
|
if (_socket) {
|
|
1933
1953
|
_socket.destroy();
|
|
@@ -1944,6 +1964,17 @@ function disconnectClient() {
|
|
|
1944
1964
|
function isClientConnected() {
|
|
1945
1965
|
return _connected;
|
|
1946
1966
|
}
|
|
1967
|
+
function sendIngestRequest(payload) {
|
|
1968
|
+
if (!_socket || !_connected) return false;
|
|
1969
|
+
try {
|
|
1970
|
+
const id = randomUUID();
|
|
1971
|
+
const token = process.env[DAEMON_TOKEN_ENV] ?? readDaemonToken();
|
|
1972
|
+
_socket.write(JSON.stringify({ id, token, type: "ingest", ...payload }) + "\n");
|
|
1973
|
+
return true;
|
|
1974
|
+
} catch {
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1947
1978
|
var SOCKET_PATH, PID_PATH, SPAWN_LOCK_PATH, SPAWN_LOCK_STALE_MS, CONNECT_TIMEOUT_MS, REQUEST_TIMEOUT_MS, DAEMON_TOKEN_ENV, _socket, _connected, _buffer, _requestCount, _consecutiveFailures, HEALTH_CHECK_INTERVAL, MAX_RETRIES_BEFORE_RESTART, RETRY_DELAYS_MS, MIN_DAEMON_AGE_MS, _pending, MAX_BUFFER;
|
|
1948
1979
|
var init_exe_daemon_client = __esm({
|
|
1949
1980
|
"src/lib/exe-daemon-client.ts"() {
|
|
@@ -1972,6 +2003,15 @@ var init_exe_daemon_client = __esm({
|
|
|
1972
2003
|
});
|
|
1973
2004
|
|
|
1974
2005
|
// src/lib/daemon-protocol.ts
|
|
2006
|
+
var daemon_protocol_exports = {};
|
|
2007
|
+
__export(daemon_protocol_exports, {
|
|
2008
|
+
deserializeArgs: () => deserializeArgs,
|
|
2009
|
+
deserializeResultSet: () => deserializeResultSet,
|
|
2010
|
+
deserializeValue: () => deserializeValue,
|
|
2011
|
+
serializeArgs: () => serializeArgs,
|
|
2012
|
+
serializeResultSet: () => serializeResultSet,
|
|
2013
|
+
serializeValue: () => serializeValue
|
|
2014
|
+
});
|
|
1975
2015
|
function serializeValue(v) {
|
|
1976
2016
|
if (v === null || v === void 0) return null;
|
|
1977
2017
|
if (typeof v === "bigint") return Number(v);
|
|
@@ -1996,6 +2036,32 @@ function deserializeValue(v) {
|
|
|
1996
2036
|
}
|
|
1997
2037
|
return v;
|
|
1998
2038
|
}
|
|
2039
|
+
function serializeArgs(args) {
|
|
2040
|
+
return args.map(serializeValue);
|
|
2041
|
+
}
|
|
2042
|
+
function deserializeArgs(args) {
|
|
2043
|
+
return args.map(deserializeValue);
|
|
2044
|
+
}
|
|
2045
|
+
function serializeResultSet(rs) {
|
|
2046
|
+
const rows = [];
|
|
2047
|
+
for (const row of rs.rows) {
|
|
2048
|
+
const obj = {};
|
|
2049
|
+
for (let i = 0; i < rs.columns.length; i++) {
|
|
2050
|
+
const col = rs.columns[i];
|
|
2051
|
+
if (col !== void 0) {
|
|
2052
|
+
obj[col] = serializeValue(row[i]);
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
rows.push(obj);
|
|
2056
|
+
}
|
|
2057
|
+
return {
|
|
2058
|
+
columns: [...rs.columns],
|
|
2059
|
+
columnTypes: [...rs.columnTypes ?? []],
|
|
2060
|
+
rows,
|
|
2061
|
+
rowsAffected: typeof rs.rowsAffected === "bigint" ? Number(rs.rowsAffected) : rs.rowsAffected ?? 0,
|
|
2062
|
+
lastInsertRowid: rs.lastInsertRowid != null ? typeof rs.lastInsertRowid === "bigint" ? Number(rs.lastInsertRowid) : rs.lastInsertRowid : null
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
1999
2065
|
function deserializeResultSet(srs) {
|
|
2000
2066
|
const rows = srs.rows.map((obj) => {
|
|
2001
2067
|
const values = srs.columns.map(
|
|
@@ -6536,8 +6602,8 @@ function getShardClient(projectName) {
|
|
|
6536
6602
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
6537
6603
|
}
|
|
6538
6604
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
6539
|
-
if (!safeName) {
|
|
6540
|
-
throw new Error(`Invalid project name for shard: "${projectName}"`);
|
|
6605
|
+
if (!safeName || safeName === "unknown") {
|
|
6606
|
+
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
6541
6607
|
}
|
|
6542
6608
|
const cached = _shards.get(safeName);
|
|
6543
6609
|
if (cached) {
|
|
@@ -7406,19 +7472,32 @@ async function flushBatch() {
|
|
|
7406
7472
|
const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
|
|
7407
7473
|
if (isShardingEnabled2()) {
|
|
7408
7474
|
const byProject = /* @__PURE__ */ new Map();
|
|
7475
|
+
let skippedUnknown = 0;
|
|
7409
7476
|
for (const row of batch) {
|
|
7410
|
-
const proj = row.project_name
|
|
7477
|
+
const proj = row.project_name?.trim();
|
|
7478
|
+
if (!proj) {
|
|
7479
|
+
skippedUnknown++;
|
|
7480
|
+
continue;
|
|
7481
|
+
}
|
|
7411
7482
|
if (!byProject.has(proj)) byProject.set(proj, []);
|
|
7412
7483
|
byProject.get(proj).push(row);
|
|
7413
7484
|
}
|
|
7485
|
+
if (skippedUnknown > 0) {
|
|
7486
|
+
process.stderr.write(
|
|
7487
|
+
`[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
|
|
7488
|
+
`
|
|
7489
|
+
);
|
|
7490
|
+
}
|
|
7414
7491
|
for (const [project, rows] of byProject) {
|
|
7415
7492
|
try {
|
|
7416
7493
|
const shardClient = await getReadyShardClient2(project);
|
|
7417
7494
|
const shardStmts = rows.map(buildStmt);
|
|
7418
7495
|
await shardClient.batch(shardStmts, "write");
|
|
7419
7496
|
} catch (err) {
|
|
7497
|
+
const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
7498
|
+
${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
|
|
7420
7499
|
process.stderr.write(
|
|
7421
|
-
`[store] Shard write failed for ${project}
|
|
7500
|
+
`[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
|
|
7422
7501
|
`
|
|
7423
7502
|
);
|
|
7424
7503
|
}
|
|
@@ -7657,6 +7736,77 @@ var init_store = __esm({
|
|
|
7657
7736
|
}
|
|
7658
7737
|
});
|
|
7659
7738
|
|
|
7739
|
+
// src/bin/fast-db-init.ts
|
|
7740
|
+
var fast_db_init_exports = {};
|
|
7741
|
+
__export(fast_db_init_exports, {
|
|
7742
|
+
fastDbInit: () => fastDbInit
|
|
7743
|
+
});
|
|
7744
|
+
async function fastDbInit() {
|
|
7745
|
+
const { isInitialized: isInitialized2, getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
7746
|
+
if (isInitialized2()) {
|
|
7747
|
+
return getClient2();
|
|
7748
|
+
}
|
|
7749
|
+
try {
|
|
7750
|
+
const { connectEmbedDaemon: connectEmbedDaemon2, sendDaemonRequest: sendDaemonRequest2, isClientConnected: isClientConnected2 } = await Promise.resolve().then(() => (init_exe_daemon_client(), exe_daemon_client_exports));
|
|
7751
|
+
const { deserializeResultSet: deserializeResultSet2 } = await Promise.resolve().then(() => (init_daemon_protocol(), daemon_protocol_exports));
|
|
7752
|
+
await connectEmbedDaemon2();
|
|
7753
|
+
if (isClientConnected2()) {
|
|
7754
|
+
const daemonClient = {
|
|
7755
|
+
async execute(stmt) {
|
|
7756
|
+
const sql = typeof stmt === "string" ? stmt : stmt.sql;
|
|
7757
|
+
const args = typeof stmt === "string" ? [] : Array.isArray(stmt.args) ? stmt.args : [];
|
|
7758
|
+
const resp = await sendDaemonRequest2({ type: "db-execute", sql, args });
|
|
7759
|
+
if (resp.error) throw new Error(String(resp.error));
|
|
7760
|
+
if (resp.db) return deserializeResultSet2(resp.db);
|
|
7761
|
+
throw new Error("Unexpected daemon response");
|
|
7762
|
+
},
|
|
7763
|
+
async batch(stmts, mode) {
|
|
7764
|
+
const statements = stmts.map((s) => {
|
|
7765
|
+
const sql = typeof s === "string" ? s : s.sql;
|
|
7766
|
+
const args = typeof s === "string" ? [] : Array.isArray(s.args) ? s.args : [];
|
|
7767
|
+
return { sql, args };
|
|
7768
|
+
});
|
|
7769
|
+
const resp = await sendDaemonRequest2({ type: "db-batch", statements, mode: mode ?? "deferred" });
|
|
7770
|
+
if (resp.error) throw new Error(String(resp.error));
|
|
7771
|
+
const batchResults = resp["db-batch"];
|
|
7772
|
+
if (batchResults) return batchResults.map(deserializeResultSet2);
|
|
7773
|
+
throw new Error("Unexpected daemon batch response");
|
|
7774
|
+
},
|
|
7775
|
+
async transaction(_mode) {
|
|
7776
|
+
throw new Error("Transactions not supported via daemon socket");
|
|
7777
|
+
},
|
|
7778
|
+
async executeMultiple(_sql) {
|
|
7779
|
+
throw new Error("executeMultiple not supported via daemon socket");
|
|
7780
|
+
},
|
|
7781
|
+
async migrate(_stmts) {
|
|
7782
|
+
throw new Error("migrate not supported via daemon socket");
|
|
7783
|
+
},
|
|
7784
|
+
sync() {
|
|
7785
|
+
return Promise.resolve(void 0);
|
|
7786
|
+
},
|
|
7787
|
+
close() {
|
|
7788
|
+
},
|
|
7789
|
+
get closed() {
|
|
7790
|
+
return false;
|
|
7791
|
+
},
|
|
7792
|
+
get protocol() {
|
|
7793
|
+
return "file";
|
|
7794
|
+
}
|
|
7795
|
+
};
|
|
7796
|
+
return daemonClient;
|
|
7797
|
+
}
|
|
7798
|
+
} catch {
|
|
7799
|
+
}
|
|
7800
|
+
const { initStore: initStore2 } = await Promise.resolve().then(() => (init_store(), store_exports));
|
|
7801
|
+
await initStore2({ lightweight: true });
|
|
7802
|
+
return getClient2();
|
|
7803
|
+
}
|
|
7804
|
+
var init_fast_db_init = __esm({
|
|
7805
|
+
"src/bin/fast-db-init.ts"() {
|
|
7806
|
+
"use strict";
|
|
7807
|
+
}
|
|
7808
|
+
});
|
|
7809
|
+
|
|
7660
7810
|
// src/lib/memory-queue.ts
|
|
7661
7811
|
import { appendFileSync as appendFileSync2, readFileSync as readFileSync14, renameSync as renameSync4, unlinkSync as unlinkSync8, existsSync as existsSync17, statSync as statSync2 } from "fs";
|
|
7662
7812
|
import path21 from "path";
|
|
@@ -7847,10 +7997,8 @@ process.stdin.on("end", async () => {
|
|
|
7847
7997
|
const agent = getActiveAgent();
|
|
7848
7998
|
const sections = [];
|
|
7849
7999
|
try {
|
|
7850
|
-
const {
|
|
7851
|
-
await
|
|
7852
|
-
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
7853
|
-
const client = getClient2();
|
|
8000
|
+
const { fastDbInit: fastDbInit2 } = await Promise.resolve().then(() => (init_fast_db_init(), fast_db_init_exports));
|
|
8001
|
+
const client = await fastDbInit2();
|
|
7854
8002
|
const projectName = process.cwd().split("/").pop() ?? "unknown";
|
|
7855
8003
|
const pcScope = sessionScopeFilter();
|
|
7856
8004
|
if (agent.agentId !== "default") {
|
|
@@ -3812,8 +3812,8 @@ function getShardClient(projectName) {
|
|
|
3812
3812
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3813
3813
|
}
|
|
3814
3814
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3815
|
-
if (!safeName) {
|
|
3816
|
-
throw new Error(`Invalid project name for shard: "${projectName}"`);
|
|
3815
|
+
if (!safeName || safeName === "unknown") {
|
|
3816
|
+
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3817
3817
|
}
|
|
3818
3818
|
const cached = _shards.get(safeName);
|
|
3819
3819
|
if (cached) {
|
|
@@ -4682,19 +4682,32 @@ async function flushBatch() {
|
|
|
4682
4682
|
const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
|
|
4683
4683
|
if (isShardingEnabled2()) {
|
|
4684
4684
|
const byProject = /* @__PURE__ */ new Map();
|
|
4685
|
+
let skippedUnknown = 0;
|
|
4685
4686
|
for (const row of batch) {
|
|
4686
|
-
const proj = row.project_name
|
|
4687
|
+
const proj = row.project_name?.trim();
|
|
4688
|
+
if (!proj) {
|
|
4689
|
+
skippedUnknown++;
|
|
4690
|
+
continue;
|
|
4691
|
+
}
|
|
4687
4692
|
if (!byProject.has(proj)) byProject.set(proj, []);
|
|
4688
4693
|
byProject.get(proj).push(row);
|
|
4689
4694
|
}
|
|
4695
|
+
if (skippedUnknown > 0) {
|
|
4696
|
+
process.stderr.write(
|
|
4697
|
+
`[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
|
|
4698
|
+
`
|
|
4699
|
+
);
|
|
4700
|
+
}
|
|
4690
4701
|
for (const [project, rows] of byProject) {
|
|
4691
4702
|
try {
|
|
4692
4703
|
const shardClient = await getReadyShardClient2(project);
|
|
4693
4704
|
const shardStmts = rows.map(buildStmt);
|
|
4694
4705
|
await shardClient.batch(shardStmts, "write");
|
|
4695
4706
|
} catch (err) {
|
|
4707
|
+
const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
4708
|
+
${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
|
|
4696
4709
|
process.stderr.write(
|
|
4697
|
-
`[store] Shard write failed for ${project}
|
|
4710
|
+
`[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
|
|
4698
4711
|
`
|
|
4699
4712
|
);
|
|
4700
4713
|
}
|
|
@@ -5371,10 +5384,8 @@ This write was prevented. Do NOT retry.`
|
|
|
5371
5384
|
const isUpdateTaskDone = (data.tool_name === "mcp__exe-os__update_task" || data.tool_name === "mcp__exe-mem__update_task") && toolInput.status === "done" && CTO_ROLES.includes(agent.agentRole);
|
|
5372
5385
|
if (isUpdateTaskDone) {
|
|
5373
5386
|
try {
|
|
5374
|
-
const {
|
|
5375
|
-
await
|
|
5376
|
-
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5377
|
-
const client = getClient2();
|
|
5387
|
+
const { fastDbInit: fastDbInit2 } = await Promise.resolve().then(() => (init_fast_db_init(), fast_db_init_exports));
|
|
5388
|
+
const client = await fastDbInit2();
|
|
5378
5389
|
const taskId = String(toolInput.task_id ?? "");
|
|
5379
5390
|
const ptScope = sessionScopeFilter();
|
|
5380
5391
|
const taskRow = await client.execute({
|
|
@@ -5431,10 +5442,8 @@ This write was prevented. Do NOT retry.`
|
|
|
5431
5442
|
}
|
|
5432
5443
|
if (CTO_ROLES.includes(agent.agentRole) && !hasDelegationFired()) {
|
|
5433
5444
|
try {
|
|
5434
|
-
const {
|
|
5435
|
-
await
|
|
5436
|
-
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5437
|
-
const client = getClient2();
|
|
5445
|
+
const { fastDbInit: fastDbInit2 } = await Promise.resolve().then(() => (init_fast_db_init(), fast_db_init_exports));
|
|
5446
|
+
const client = await fastDbInit2();
|
|
5438
5447
|
const dlScope = sessionScopeFilter();
|
|
5439
5448
|
const result = await client.execute({
|
|
5440
5449
|
sql: `SELECT COUNT(*) as cnt FROM tasks WHERE assigned_to = ? AND status IN ('open', 'in_progress')${dlScope.sql}`,
|
|
@@ -3256,8 +3256,8 @@ function getShardClient(projectName) {
|
|
|
3256
3256
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3257
3257
|
}
|
|
3258
3258
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3259
|
-
if (!safeName) {
|
|
3260
|
-
throw new Error(`Invalid project name for shard: "${projectName}"`);
|
|
3259
|
+
if (!safeName || safeName === "unknown") {
|
|
3260
|
+
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3261
3261
|
}
|
|
3262
3262
|
const cached = _shards.get(safeName);
|
|
3263
3263
|
if (cached) {
|
|
@@ -4126,19 +4126,32 @@ async function flushBatch() {
|
|
|
4126
4126
|
const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
|
|
4127
4127
|
if (isShardingEnabled2()) {
|
|
4128
4128
|
const byProject = /* @__PURE__ */ new Map();
|
|
4129
|
+
let skippedUnknown = 0;
|
|
4129
4130
|
for (const row of batch) {
|
|
4130
|
-
const proj = row.project_name
|
|
4131
|
+
const proj = row.project_name?.trim();
|
|
4132
|
+
if (!proj) {
|
|
4133
|
+
skippedUnknown++;
|
|
4134
|
+
continue;
|
|
4135
|
+
}
|
|
4131
4136
|
if (!byProject.has(proj)) byProject.set(proj, []);
|
|
4132
4137
|
byProject.get(proj).push(row);
|
|
4133
4138
|
}
|
|
4139
|
+
if (skippedUnknown > 0) {
|
|
4140
|
+
process.stderr.write(
|
|
4141
|
+
`[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
|
|
4142
|
+
`
|
|
4143
|
+
);
|
|
4144
|
+
}
|
|
4134
4145
|
for (const [project, rows] of byProject) {
|
|
4135
4146
|
try {
|
|
4136
4147
|
const shardClient = await getReadyShardClient2(project);
|
|
4137
4148
|
const shardStmts = rows.map(buildStmt);
|
|
4138
4149
|
await shardClient.batch(shardStmts, "write");
|
|
4139
4150
|
} catch (err) {
|
|
4151
|
+
const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
4152
|
+
${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
|
|
4140
4153
|
process.stderr.write(
|
|
4141
|
-
`[store] Shard write failed for ${project}
|
|
4154
|
+
`[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
|
|
4142
4155
|
`
|
|
4143
4156
|
);
|
|
4144
4157
|
}
|
|
@@ -9360,10 +9373,12 @@ async function hybridSearch(queryText, agentId, options) {
|
|
|
9360
9373
|
);
|
|
9361
9374
|
}
|
|
9362
9375
|
let rerankerAvailable = false;
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9376
|
+
if (process.env.EXE_IS_DAEMON === "1") {
|
|
9377
|
+
try {
|
|
9378
|
+
const { isRerankerAvailable: isRerankerAvailable2 } = await Promise.resolve().then(() => (init_reranker(), reranker_exports));
|
|
9379
|
+
rerankerAvailable = isRerankerAvailable2();
|
|
9380
|
+
} catch {
|
|
9381
|
+
}
|
|
9367
9382
|
}
|
|
9368
9383
|
const broadFetchTopK = config.scalingRoadmap?.rerankerAutoTrigger?.fetchTopK ?? 150;
|
|
9369
9384
|
const fetchLimit = effectiveIsBroad ? Math.max(limit * 5, broadFetchTopK) : rerankerAvailable ? Math.max(limit * 4, 60) : Math.max(limit * 3, 30);
|
|
@@ -1543,6 +1543,17 @@ var init_daemon_auth = __esm({
|
|
|
1543
1543
|
});
|
|
1544
1544
|
|
|
1545
1545
|
// src/lib/exe-daemon-client.ts
|
|
1546
|
+
var exe_daemon_client_exports = {};
|
|
1547
|
+
__export(exe_daemon_client_exports, {
|
|
1548
|
+
connectEmbedDaemon: () => connectEmbedDaemon,
|
|
1549
|
+
disconnectClient: () => disconnectClient,
|
|
1550
|
+
embedBatchViaClient: () => embedBatchViaClient,
|
|
1551
|
+
embedViaClient: () => embedViaClient,
|
|
1552
|
+
isClientConnected: () => isClientConnected,
|
|
1553
|
+
pingDaemon: () => pingDaemon,
|
|
1554
|
+
sendDaemonRequest: () => sendDaemonRequest,
|
|
1555
|
+
sendIngestRequest: () => sendIngestRequest
|
|
1556
|
+
});
|
|
1546
1557
|
import net from "net";
|
|
1547
1558
|
import os7 from "os";
|
|
1548
1559
|
import { spawn } from "child_process";
|
|
@@ -1931,6 +1942,15 @@ async function embedViaClient(text, priority = "high") {
|
|
|
1931
1942
|
);
|
|
1932
1943
|
return !result.error && result.vectors?.[0] ? result.vectors[0] : null;
|
|
1933
1944
|
}
|
|
1945
|
+
async function embedBatchViaClient(texts, priority = "high") {
|
|
1946
|
+
if (!_connected && !await connectEmbedDaemon()) return null;
|
|
1947
|
+
_requestCount++;
|
|
1948
|
+
const result = await retryThenRestart(
|
|
1949
|
+
() => sendRequest(texts, priority),
|
|
1950
|
+
"Batch embed"
|
|
1951
|
+
);
|
|
1952
|
+
return !result.error && result.vectors ? result.vectors : null;
|
|
1953
|
+
}
|
|
1934
1954
|
function disconnectClient() {
|
|
1935
1955
|
if (_socket) {
|
|
1936
1956
|
_socket.destroy();
|
|
@@ -1947,6 +1967,17 @@ function disconnectClient() {
|
|
|
1947
1967
|
function isClientConnected() {
|
|
1948
1968
|
return _connected;
|
|
1949
1969
|
}
|
|
1970
|
+
function sendIngestRequest(payload) {
|
|
1971
|
+
if (!_socket || !_connected) return false;
|
|
1972
|
+
try {
|
|
1973
|
+
const id = randomUUID();
|
|
1974
|
+
const token = process.env[DAEMON_TOKEN_ENV] ?? readDaemonToken();
|
|
1975
|
+
_socket.write(JSON.stringify({ id, token, type: "ingest", ...payload }) + "\n");
|
|
1976
|
+
return true;
|
|
1977
|
+
} catch {
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1950
1981
|
var SOCKET_PATH, PID_PATH, SPAWN_LOCK_PATH, SPAWN_LOCK_STALE_MS, CONNECT_TIMEOUT_MS, REQUEST_TIMEOUT_MS, DAEMON_TOKEN_ENV, _socket, _connected, _buffer, _requestCount, _consecutiveFailures, HEALTH_CHECK_INTERVAL, MAX_RETRIES_BEFORE_RESTART, RETRY_DELAYS_MS, MIN_DAEMON_AGE_MS, _pending, MAX_BUFFER;
|
|
1951
1982
|
var init_exe_daemon_client = __esm({
|
|
1952
1983
|
"src/lib/exe-daemon-client.ts"() {
|
|
@@ -1975,6 +2006,15 @@ var init_exe_daemon_client = __esm({
|
|
|
1975
2006
|
});
|
|
1976
2007
|
|
|
1977
2008
|
// src/lib/daemon-protocol.ts
|
|
2009
|
+
var daemon_protocol_exports = {};
|
|
2010
|
+
__export(daemon_protocol_exports, {
|
|
2011
|
+
deserializeArgs: () => deserializeArgs,
|
|
2012
|
+
deserializeResultSet: () => deserializeResultSet,
|
|
2013
|
+
deserializeValue: () => deserializeValue,
|
|
2014
|
+
serializeArgs: () => serializeArgs,
|
|
2015
|
+
serializeResultSet: () => serializeResultSet,
|
|
2016
|
+
serializeValue: () => serializeValue
|
|
2017
|
+
});
|
|
1978
2018
|
function serializeValue(v) {
|
|
1979
2019
|
if (v === null || v === void 0) return null;
|
|
1980
2020
|
if (typeof v === "bigint") return Number(v);
|
|
@@ -1999,6 +2039,32 @@ function deserializeValue(v) {
|
|
|
1999
2039
|
}
|
|
2000
2040
|
return v;
|
|
2001
2041
|
}
|
|
2042
|
+
function serializeArgs(args) {
|
|
2043
|
+
return args.map(serializeValue);
|
|
2044
|
+
}
|
|
2045
|
+
function deserializeArgs(args) {
|
|
2046
|
+
return args.map(deserializeValue);
|
|
2047
|
+
}
|
|
2048
|
+
function serializeResultSet(rs) {
|
|
2049
|
+
const rows = [];
|
|
2050
|
+
for (const row of rs.rows) {
|
|
2051
|
+
const obj = {};
|
|
2052
|
+
for (let i = 0; i < rs.columns.length; i++) {
|
|
2053
|
+
const col = rs.columns[i];
|
|
2054
|
+
if (col !== void 0) {
|
|
2055
|
+
obj[col] = serializeValue(row[i]);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
rows.push(obj);
|
|
2059
|
+
}
|
|
2060
|
+
return {
|
|
2061
|
+
columns: [...rs.columns],
|
|
2062
|
+
columnTypes: [...rs.columnTypes ?? []],
|
|
2063
|
+
rows,
|
|
2064
|
+
rowsAffected: typeof rs.rowsAffected === "bigint" ? Number(rs.rowsAffected) : rs.rowsAffected ?? 0,
|
|
2065
|
+
lastInsertRowid: rs.lastInsertRowid != null ? typeof rs.lastInsertRowid === "bigint" ? Number(rs.lastInsertRowid) : rs.lastInsertRowid : null
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2002
2068
|
function deserializeResultSet(srs) {
|
|
2003
2069
|
const rows = srs.rows.map((obj) => {
|
|
2004
2070
|
const values = srs.columns.map(
|
|
@@ -6745,8 +6811,8 @@ function getShardClient(projectName) {
|
|
|
6745
6811
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
6746
6812
|
}
|
|
6747
6813
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
6748
|
-
if (!safeName) {
|
|
6749
|
-
throw new Error(`Invalid project name for shard: "${projectName}"`);
|
|
6814
|
+
if (!safeName || safeName === "unknown") {
|
|
6815
|
+
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
6750
6816
|
}
|
|
6751
6817
|
const cached = _shards.get(safeName);
|
|
6752
6818
|
if (cached) {
|
|
@@ -7615,19 +7681,32 @@ async function flushBatch() {
|
|
|
7615
7681
|
const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
|
|
7616
7682
|
if (isShardingEnabled2()) {
|
|
7617
7683
|
const byProject = /* @__PURE__ */ new Map();
|
|
7684
|
+
let skippedUnknown = 0;
|
|
7618
7685
|
for (const row of batch) {
|
|
7619
|
-
const proj = row.project_name
|
|
7686
|
+
const proj = row.project_name?.trim();
|
|
7687
|
+
if (!proj) {
|
|
7688
|
+
skippedUnknown++;
|
|
7689
|
+
continue;
|
|
7690
|
+
}
|
|
7620
7691
|
if (!byProject.has(proj)) byProject.set(proj, []);
|
|
7621
7692
|
byProject.get(proj).push(row);
|
|
7622
7693
|
}
|
|
7694
|
+
if (skippedUnknown > 0) {
|
|
7695
|
+
process.stderr.write(
|
|
7696
|
+
`[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
|
|
7697
|
+
`
|
|
7698
|
+
);
|
|
7699
|
+
}
|
|
7623
7700
|
for (const [project, rows] of byProject) {
|
|
7624
7701
|
try {
|
|
7625
7702
|
const shardClient = await getReadyShardClient2(project);
|
|
7626
7703
|
const shardStmts = rows.map(buildStmt);
|
|
7627
7704
|
await shardClient.batch(shardStmts, "write");
|
|
7628
7705
|
} catch (err) {
|
|
7706
|
+
const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
7707
|
+
${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
|
|
7629
7708
|
process.stderr.write(
|
|
7630
|
-
`[store] Shard write failed for ${project}
|
|
7709
|
+
`[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
|
|
7631
7710
|
`
|
|
7632
7711
|
);
|
|
7633
7712
|
}
|
|
@@ -7866,6 +7945,77 @@ var init_store = __esm({
|
|
|
7866
7945
|
}
|
|
7867
7946
|
});
|
|
7868
7947
|
|
|
7948
|
+
// src/bin/fast-db-init.ts
|
|
7949
|
+
var fast_db_init_exports = {};
|
|
7950
|
+
__export(fast_db_init_exports, {
|
|
7951
|
+
fastDbInit: () => fastDbInit
|
|
7952
|
+
});
|
|
7953
|
+
async function fastDbInit() {
|
|
7954
|
+
const { isInitialized: isInitialized2, getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
7955
|
+
if (isInitialized2()) {
|
|
7956
|
+
return getClient2();
|
|
7957
|
+
}
|
|
7958
|
+
try {
|
|
7959
|
+
const { connectEmbedDaemon: connectEmbedDaemon2, sendDaemonRequest: sendDaemonRequest2, isClientConnected: isClientConnected2 } = await Promise.resolve().then(() => (init_exe_daemon_client(), exe_daemon_client_exports));
|
|
7960
|
+
const { deserializeResultSet: deserializeResultSet2 } = await Promise.resolve().then(() => (init_daemon_protocol(), daemon_protocol_exports));
|
|
7961
|
+
await connectEmbedDaemon2();
|
|
7962
|
+
if (isClientConnected2()) {
|
|
7963
|
+
const daemonClient = {
|
|
7964
|
+
async execute(stmt) {
|
|
7965
|
+
const sql = typeof stmt === "string" ? stmt : stmt.sql;
|
|
7966
|
+
const args = typeof stmt === "string" ? [] : Array.isArray(stmt.args) ? stmt.args : [];
|
|
7967
|
+
const resp = await sendDaemonRequest2({ type: "db-execute", sql, args });
|
|
7968
|
+
if (resp.error) throw new Error(String(resp.error));
|
|
7969
|
+
if (resp.db) return deserializeResultSet2(resp.db);
|
|
7970
|
+
throw new Error("Unexpected daemon response");
|
|
7971
|
+
},
|
|
7972
|
+
async batch(stmts, mode) {
|
|
7973
|
+
const statements = stmts.map((s) => {
|
|
7974
|
+
const sql = typeof s === "string" ? s : s.sql;
|
|
7975
|
+
const args = typeof s === "string" ? [] : Array.isArray(s.args) ? s.args : [];
|
|
7976
|
+
return { sql, args };
|
|
7977
|
+
});
|
|
7978
|
+
const resp = await sendDaemonRequest2({ type: "db-batch", statements, mode: mode ?? "deferred" });
|
|
7979
|
+
if (resp.error) throw new Error(String(resp.error));
|
|
7980
|
+
const batchResults = resp["db-batch"];
|
|
7981
|
+
if (batchResults) return batchResults.map(deserializeResultSet2);
|
|
7982
|
+
throw new Error("Unexpected daemon batch response");
|
|
7983
|
+
},
|
|
7984
|
+
async transaction(_mode) {
|
|
7985
|
+
throw new Error("Transactions not supported via daemon socket");
|
|
7986
|
+
},
|
|
7987
|
+
async executeMultiple(_sql) {
|
|
7988
|
+
throw new Error("executeMultiple not supported via daemon socket");
|
|
7989
|
+
},
|
|
7990
|
+
async migrate(_stmts) {
|
|
7991
|
+
throw new Error("migrate not supported via daemon socket");
|
|
7992
|
+
},
|
|
7993
|
+
sync() {
|
|
7994
|
+
return Promise.resolve(void 0);
|
|
7995
|
+
},
|
|
7996
|
+
close() {
|
|
7997
|
+
},
|
|
7998
|
+
get closed() {
|
|
7999
|
+
return false;
|
|
8000
|
+
},
|
|
8001
|
+
get protocol() {
|
|
8002
|
+
return "file";
|
|
8003
|
+
}
|
|
8004
|
+
};
|
|
8005
|
+
return daemonClient;
|
|
8006
|
+
}
|
|
8007
|
+
} catch {
|
|
8008
|
+
}
|
|
8009
|
+
const { initStore: initStore2 } = await Promise.resolve().then(() => (init_store(), store_exports));
|
|
8010
|
+
await initStore2({ lightweight: true });
|
|
8011
|
+
return getClient2();
|
|
8012
|
+
}
|
|
8013
|
+
var init_fast_db_init = __esm({
|
|
8014
|
+
"src/bin/fast-db-init.ts"() {
|
|
8015
|
+
"use strict";
|
|
8016
|
+
}
|
|
8017
|
+
});
|
|
8018
|
+
|
|
7869
8019
|
// src/lib/memory-queue.ts
|
|
7870
8020
|
import { appendFileSync as appendFileSync2, readFileSync as readFileSync15, renameSync as renameSync4, unlinkSync as unlinkSync9, existsSync as existsSync18, statSync as statSync2 } from "fs";
|
|
7871
8021
|
import path22 from "path";
|
|
@@ -8416,10 +8566,8 @@ process.stdin.on("end", async () => {
|
|
|
8416
8566
|
const agent = getActiveAgent();
|
|
8417
8567
|
if (agent.agentId !== "default") {
|
|
8418
8568
|
try {
|
|
8419
|
-
const {
|
|
8420
|
-
await
|
|
8421
|
-
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
8422
|
-
const client = getClient2();
|
|
8569
|
+
const { fastDbInit: fastDbInit2 } = await Promise.resolve().then(() => (init_fast_db_init(), fast_db_init_exports));
|
|
8570
|
+
const client = await fastDbInit2();
|
|
8423
8571
|
const seScope = strictSessionScopeFilter();
|
|
8424
8572
|
const orphanResult = await client.execute({
|
|
8425
8573
|
sql: `SELECT title, status FROM tasks WHERE assigned_to = ? AND status IN ('open', 'in_progress')${seScope.sql}`,
|
|
@@ -3322,8 +3322,8 @@ function getShardClient(projectName) {
|
|
|
3322
3322
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3323
3323
|
}
|
|
3324
3324
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3325
|
-
if (!safeName) {
|
|
3326
|
-
throw new Error(`Invalid project name for shard: "${projectName}"`);
|
|
3325
|
+
if (!safeName || safeName === "unknown") {
|
|
3326
|
+
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3327
3327
|
}
|
|
3328
3328
|
const cached = _shards.get(safeName);
|
|
3329
3329
|
if (cached) {
|
|
@@ -4192,19 +4192,32 @@ async function flushBatch() {
|
|
|
4192
4192
|
const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
|
|
4193
4193
|
if (isShardingEnabled2()) {
|
|
4194
4194
|
const byProject = /* @__PURE__ */ new Map();
|
|
4195
|
+
let skippedUnknown = 0;
|
|
4195
4196
|
for (const row of batch) {
|
|
4196
|
-
const proj = row.project_name
|
|
4197
|
+
const proj = row.project_name?.trim();
|
|
4198
|
+
if (!proj) {
|
|
4199
|
+
skippedUnknown++;
|
|
4200
|
+
continue;
|
|
4201
|
+
}
|
|
4197
4202
|
if (!byProject.has(proj)) byProject.set(proj, []);
|
|
4198
4203
|
byProject.get(proj).push(row);
|
|
4199
4204
|
}
|
|
4205
|
+
if (skippedUnknown > 0) {
|
|
4206
|
+
process.stderr.write(
|
|
4207
|
+
`[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
|
|
4208
|
+
`
|
|
4209
|
+
);
|
|
4210
|
+
}
|
|
4200
4211
|
for (const [project, rows] of byProject) {
|
|
4201
4212
|
try {
|
|
4202
4213
|
const shardClient = await getReadyShardClient2(project);
|
|
4203
4214
|
const shardStmts = rows.map(buildStmt);
|
|
4204
4215
|
await shardClient.batch(shardStmts, "write");
|
|
4205
4216
|
} catch (err) {
|
|
4217
|
+
const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
4218
|
+
${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
|
|
4206
4219
|
process.stderr.write(
|
|
4207
|
-
`[store] Shard write failed for ${project}
|
|
4220
|
+
`[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
|
|
4208
4221
|
`
|
|
4209
4222
|
);
|
|
4210
4223
|
}
|
|
@@ -5626,10 +5639,12 @@ async function hybridSearch(queryText, agentId, options) {
|
|
|
5626
5639
|
);
|
|
5627
5640
|
}
|
|
5628
5641
|
let rerankerAvailable = false;
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5642
|
+
if (process.env.EXE_IS_DAEMON === "1") {
|
|
5643
|
+
try {
|
|
5644
|
+
const { isRerankerAvailable: isRerankerAvailable2 } = await Promise.resolve().then(() => (init_reranker(), reranker_exports));
|
|
5645
|
+
rerankerAvailable = isRerankerAvailable2();
|
|
5646
|
+
} catch {
|
|
5647
|
+
}
|
|
5633
5648
|
}
|
|
5634
5649
|
const broadFetchTopK = config.scalingRoadmap?.rerankerAutoTrigger?.fetchTopK ?? 150;
|
|
5635
5650
|
const fetchLimit = effectiveIsBroad ? Math.max(limit * 5, broadFetchTopK) : rerankerAvailable ? Math.max(limit * 4, 60) : Math.max(limit * 3, 30);
|