@devness/useai 0.5.19 → 0.5.21
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/index.js +19 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2681,7 +2681,7 @@ var VERSION;
|
|
|
2681
2681
|
var init_version = __esm({
|
|
2682
2682
|
"../shared/dist/constants/version.js"() {
|
|
2683
2683
|
"use strict";
|
|
2684
|
-
VERSION = "0.5.
|
|
2684
|
+
VERSION = "0.5.21";
|
|
2685
2685
|
}
|
|
2686
2686
|
});
|
|
2687
2687
|
|
|
@@ -36299,21 +36299,24 @@ var init_session_state = __esm({
|
|
|
36299
36299
|
|
|
36300
36300
|
// src/mcp-map.ts
|
|
36301
36301
|
import { join as join7 } from "path";
|
|
36302
|
+
function mcpMapPath() {
|
|
36303
|
+
return join7(DATA_DIR, "mcp-map.json");
|
|
36304
|
+
}
|
|
36302
36305
|
function readMcpMap() {
|
|
36303
|
-
return readJson(
|
|
36306
|
+
return readJson(mcpMapPath(), {});
|
|
36304
36307
|
}
|
|
36305
36308
|
function writeMcpMapping(mcpSessionId, useaiSessionId) {
|
|
36306
36309
|
if (!mcpSessionId) return;
|
|
36307
36310
|
const map = readMcpMap();
|
|
36308
36311
|
map[mcpSessionId] = useaiSessionId;
|
|
36309
|
-
writeJson(
|
|
36312
|
+
writeJson(mcpMapPath(), map);
|
|
36310
36313
|
}
|
|
36311
36314
|
function removeMcpMapping(mcpSessionId) {
|
|
36312
36315
|
if (!mcpSessionId) return;
|
|
36313
36316
|
const map = readMcpMap();
|
|
36314
36317
|
if (mcpSessionId in map) {
|
|
36315
36318
|
delete map[mcpSessionId];
|
|
36316
|
-
writeJson(
|
|
36319
|
+
writeJson(mcpMapPath(), map);
|
|
36317
36320
|
}
|
|
36318
36321
|
}
|
|
36319
36322
|
function removeMcpMappingByUseaiId(useaiSessionId) {
|
|
@@ -36325,14 +36328,12 @@ function removeMcpMappingByUseaiId(useaiSessionId) {
|
|
|
36325
36328
|
changed = true;
|
|
36326
36329
|
}
|
|
36327
36330
|
}
|
|
36328
|
-
if (changed) writeJson(
|
|
36331
|
+
if (changed) writeJson(mcpMapPath(), map);
|
|
36329
36332
|
}
|
|
36330
|
-
var MCP_MAP_FILE;
|
|
36331
36333
|
var init_mcp_map = __esm({
|
|
36332
36334
|
"src/mcp-map.ts"() {
|
|
36333
36335
|
"use strict";
|
|
36334
36336
|
init_dist8();
|
|
36335
|
-
MCP_MAP_FILE = join7(DATA_DIR, "mcp-map.json");
|
|
36336
36337
|
}
|
|
36337
36338
|
});
|
|
36338
36339
|
|
|
@@ -36950,7 +36951,7 @@ __export(daemon_exports, {
|
|
|
36950
36951
|
});
|
|
36951
36952
|
import { createServer } from "http";
|
|
36952
36953
|
import { createHash as createHash4, randomUUID as randomUUID4 } from "crypto";
|
|
36953
|
-
import { existsSync as existsSync11, readdirSync, readFileSync as readFileSync5, appendFileSync as appendFileSync2, renameSync as renameSync3, writeFileSync as writeFileSync5, unlinkSync as unlinkSync6 } from "fs";
|
|
36954
|
+
import { existsSync as existsSync11, readdirSync, readFileSync as readFileSync5, appendFileSync as appendFileSync2, renameSync as renameSync3, writeFileSync as writeFileSync5, unlinkSync as unlinkSync6, statSync } from "fs";
|
|
36954
36955
|
import { join as join10 } from "path";
|
|
36955
36956
|
function getActiveUseaiSessionIds() {
|
|
36956
36957
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -37060,12 +37061,22 @@ function sealOrphanFile(sessionId) {
|
|
|
37060
37061
|
function sealOrphanedSessions() {
|
|
37061
37062
|
if (!existsSync11(ACTIVE_DIR)) return;
|
|
37062
37063
|
const activeIds = getActiveUseaiSessionIds();
|
|
37064
|
+
const mcpMap = readMcpMap();
|
|
37065
|
+
const mappedUseaiIds = new Set(Object.values(mcpMap));
|
|
37063
37066
|
let sealed = 0;
|
|
37064
37067
|
try {
|
|
37065
37068
|
const files = readdirSync(ACTIVE_DIR).filter((f) => f.endsWith(".jsonl"));
|
|
37066
37069
|
for (const file of files) {
|
|
37067
37070
|
const sessionId = file.replace(".jsonl", "");
|
|
37068
37071
|
if (activeIds.has(sessionId)) continue;
|
|
37072
|
+
if (mappedUseaiIds.has(sessionId)) {
|
|
37073
|
+
try {
|
|
37074
|
+
const mtime = statSync(join10(ACTIVE_DIR, file)).mtimeMs;
|
|
37075
|
+
if (Date.now() - mtime < IDLE_TIMEOUT_MS) continue;
|
|
37076
|
+
} catch {
|
|
37077
|
+
continue;
|
|
37078
|
+
}
|
|
37079
|
+
}
|
|
37069
37080
|
sealOrphanFile(sessionId);
|
|
37070
37081
|
sealed++;
|
|
37071
37082
|
}
|