negotium 0.2.2 → 0.2.3
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/agent-helpers.js +131 -133
- package/dist/agent-helpers.js.map +4 -4
- package/dist/{chunk-kc5kmr95.js → chunk-hsqgb2hw.js} +22 -24
- package/dist/{chunk-kc5kmr95.js.map → chunk-hsqgb2hw.js.map} +3 -3
- package/dist/hosted-agent.js +34 -36
- package/dist/hosted-agent.js.map +4 -4
- package/dist/main.js +291 -918
- package/dist/main.js.map +7 -9
- package/dist/mcp-factories.js +135 -137
- package/dist/mcp-factories.js.map +4 -4
- package/dist/registry.js +1 -1
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/rollout/shared.ts +3 -5
- package/dist/runtime/src/version.ts +1 -1
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/runtime/src/migration/single-user.ts +0 -805
package/dist/mcp-factories.js
CHANGED
|
@@ -405,8 +405,7 @@ function renderUserPromptBatch(prompts) {
|
|
|
405
405
|
|
|
406
406
|
// ../../packages/core/src/agents/rollout/shared.ts
|
|
407
407
|
import { mkdirSync as mkdirSync3 } from "fs";
|
|
408
|
-
import {
|
|
409
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
408
|
+
import { resolve as resolve3 } from "path";
|
|
410
409
|
function clone(obj) {
|
|
411
410
|
return structuredClone(obj);
|
|
412
411
|
}
|
|
@@ -537,18 +536,17 @@ ${toolBuffer.join(`
|
|
|
537
536
|
flushAssistant();
|
|
538
537
|
return pairs;
|
|
539
538
|
}
|
|
540
|
-
var
|
|
539
|
+
var trustedWorkspaceRoots, FIXTURES_DIR, UUID_RE;
|
|
541
540
|
var init_shared = __esm(() => {
|
|
542
541
|
init_config();
|
|
543
542
|
init_logger();
|
|
544
|
-
__dirname2 = dirname3(fileURLToPath2(import.meta.url));
|
|
545
543
|
trustedWorkspaceRoots = [
|
|
546
544
|
WORKSPACE_DIR,
|
|
547
545
|
DM_WORKSPACE_DIR,
|
|
548
546
|
SESSION_WORKSPACE_DIR,
|
|
549
547
|
TOPIC_WORKSPACE_DIR
|
|
550
548
|
].map((root) => resolve3(root));
|
|
551
|
-
FIXTURES_DIR =
|
|
549
|
+
FIXTURES_DIR = resolve3(PROJECT_ROOT, "src", "agents", "fixtures");
|
|
552
550
|
UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
553
551
|
});
|
|
554
552
|
|
|
@@ -591,7 +589,7 @@ import {
|
|
|
591
589
|
unlinkSync as unlinkSync3,
|
|
592
590
|
writeFileSync as writeFileSync3
|
|
593
591
|
} from "fs";
|
|
594
|
-
import { dirname as
|
|
592
|
+
import { dirname as dirname3 } from "path";
|
|
595
593
|
function readJsonlLines(filePath) {
|
|
596
594
|
return readFileSync3(filePath, "utf-8").trim().split(`
|
|
597
595
|
`).filter(Boolean);
|
|
@@ -639,7 +637,7 @@ function appendJsonlEntry(filePath, entry) {
|
|
|
639
637
|
`);
|
|
640
638
|
}
|
|
641
639
|
function appendJsonlLine(filePath, line) {
|
|
642
|
-
mkdirSync4(
|
|
640
|
+
mkdirSync4(dirname3(filePath), { recursive: true });
|
|
643
641
|
const lockPath = `${filePath}${LOCK_SUFFIX}`;
|
|
644
642
|
const payload = line.endsWith(`
|
|
645
643
|
`) ? line : `${line}
|
|
@@ -670,7 +668,7 @@ function appendJsonlLine(filePath, line) {
|
|
|
670
668
|
}
|
|
671
669
|
}
|
|
672
670
|
function writeJsonlFile(filePath, entries) {
|
|
673
|
-
const dir =
|
|
671
|
+
const dir = dirname3(filePath);
|
|
674
672
|
mkdirSync4(dir, { recursive: true });
|
|
675
673
|
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
676
674
|
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
@@ -730,11 +728,11 @@ var init_jsonl = __esm(() => {
|
|
|
730
728
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
731
729
|
import { existsSync as existsSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
732
730
|
import { homedir as homedir2 } from "os";
|
|
733
|
-
import { join as
|
|
731
|
+
import { join as join3 } from "path";
|
|
734
732
|
function loadClaudeAttachments() {
|
|
735
733
|
if (_attachmentsCache)
|
|
736
734
|
return _attachmentsCache;
|
|
737
|
-
const raw = readFileSync4(
|
|
735
|
+
const raw = readFileSync4(join3(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
|
|
738
736
|
const lines = parseJsonlText(raw);
|
|
739
737
|
if (lines.length < 2) {
|
|
740
738
|
throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
|
|
@@ -835,8 +833,8 @@ function writeClaudeRollout(opts) {
|
|
|
835
833
|
});
|
|
836
834
|
lastUuid = assistantUuid;
|
|
837
835
|
}
|
|
838
|
-
const projectsDir =
|
|
839
|
-
const path =
|
|
836
|
+
const projectsDir = join3(homedir2(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
|
|
837
|
+
const path = join3(projectsDir, `${sessionId}.jsonl`);
|
|
840
838
|
writeJsonlFile(path, lines);
|
|
841
839
|
logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
|
|
842
840
|
return { sessionId, rolloutPath: path };
|
|
@@ -851,7 +849,7 @@ var init_claude = __esm(() => {
|
|
|
851
849
|
// ../../packages/core/src/agents/claude-registry.ts
|
|
852
850
|
import { existsSync as existsSync4, mkdirSync as mkdirSync5, readdirSync as readdirSync2, renameSync as renameSync3, unlinkSync as unlinkSync4 } from "fs";
|
|
853
851
|
import { homedir as homedir3 } from "os";
|
|
854
|
-
import { join as
|
|
852
|
+
import { join as join4 } from "path";
|
|
855
853
|
var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
|
|
856
854
|
var init_claude_registry = __esm(() => {
|
|
857
855
|
init_claude();
|
|
@@ -898,11 +896,11 @@ var init_claude_registry = __esm(() => {
|
|
|
898
896
|
const result = await forkSession(parentSessionId, {
|
|
899
897
|
...title ? { title } : {}
|
|
900
898
|
});
|
|
901
|
-
const projectsRoot =
|
|
902
|
-
const destDir =
|
|
903
|
-
const destPath =
|
|
899
|
+
const projectsRoot = join4(homedir3(), ".claude", "projects");
|
|
900
|
+
const destDir = join4(projectsRoot, encodeClaudeCwd(cwd));
|
|
901
|
+
const destPath = join4(destDir, `${result.sessionId}.jsonl`);
|
|
904
902
|
if (!existsSync4(destPath)) {
|
|
905
|
-
const sourcePath = readdirSync2(projectsRoot).map((d) =>
|
|
903
|
+
const sourcePath = readdirSync2(projectsRoot).map((d) => join4(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync4(p));
|
|
906
904
|
if (!sourcePath) {
|
|
907
905
|
throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
|
|
908
906
|
}
|
|
@@ -915,10 +913,10 @@ var init_claude_registry = __esm(() => {
|
|
|
915
913
|
};
|
|
916
914
|
},
|
|
917
915
|
async cleanupRollouts({ cwd, sessionIds }) {
|
|
918
|
-
const projectsDir =
|
|
916
|
+
const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(cwd));
|
|
919
917
|
const failures = [];
|
|
920
918
|
for (const sid of sessionIds) {
|
|
921
|
-
const path =
|
|
919
|
+
const path = join4(projectsDir, `${sid}.jsonl`);
|
|
922
920
|
try {
|
|
923
921
|
unlinkSync4(path);
|
|
924
922
|
} catch (e) {
|
|
@@ -939,14 +937,14 @@ var init_claude_registry = __esm(() => {
|
|
|
939
937
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
940
938
|
import { existsSync as existsSync5, readFileSync as readFileSync5, realpathSync, statSync as statSync3, unlinkSync as unlinkSync5 } from "fs";
|
|
941
939
|
import { homedir as homedir4 } from "os";
|
|
942
|
-
import { basename as basename2, dirname as
|
|
940
|
+
import { basename as basename2, dirname as dirname4, join as join5, resolve as resolve4 } from "path";
|
|
943
941
|
function codexSessionsDir() {
|
|
944
|
-
return
|
|
942
|
+
return join5(process.env.CODEX_HOME || join5(homedir4(), ".codex"), "sessions");
|
|
945
943
|
}
|
|
946
944
|
function loadCodexShell() {
|
|
947
945
|
if (_shellCache)
|
|
948
946
|
return _shellCache;
|
|
949
|
-
const raw = readFileSync5(
|
|
947
|
+
const raw = readFileSync5(join5(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
950
948
|
const lines = parseJsonlText(raw);
|
|
951
949
|
if (lines.length < 5) {
|
|
952
950
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -1010,7 +1008,7 @@ function canonicalFilePath(path) {
|
|
|
1010
1008
|
return realpathSync(absolute);
|
|
1011
1009
|
} catch {
|
|
1012
1010
|
try {
|
|
1013
|
-
return
|
|
1011
|
+
return join5(realpathSync(dirname4(absolute)), basename2(absolute));
|
|
1014
1012
|
} catch {
|
|
1015
1013
|
return absolute;
|
|
1016
1014
|
}
|
|
@@ -1199,19 +1197,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
1199
1197
|
try {
|
|
1200
1198
|
if (buckets) {
|
|
1201
1199
|
for (const bucket of buckets) {
|
|
1202
|
-
const dir =
|
|
1200
|
+
const dir = join5(sessionsDir, bucket);
|
|
1203
1201
|
if (!existsSync5(dir))
|
|
1204
1202
|
continue;
|
|
1205
1203
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
1206
1204
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
1207
|
-
candidates.push(
|
|
1205
|
+
candidates.push(join5(dir, rel));
|
|
1208
1206
|
}
|
|
1209
1207
|
}
|
|
1210
1208
|
}
|
|
1211
1209
|
if (candidates.length === 0) {
|
|
1212
1210
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
1213
1211
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
1214
|
-
candidates.push(
|
|
1212
|
+
candidates.push(join5(sessionsDir, rel));
|
|
1215
1213
|
}
|
|
1216
1214
|
}
|
|
1217
1215
|
return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
|
|
@@ -1320,8 +1318,8 @@ function writeCodexRollout(opts) {
|
|
|
1320
1318
|
const mm = String(now.getUTCMonth() + 1).padStart(2, "0");
|
|
1321
1319
|
const dd = String(now.getUTCDate()).padStart(2, "0");
|
|
1322
1320
|
const tsStr = tsIso.replace(/[:.]/g, "-").slice(0, 19);
|
|
1323
|
-
const dir =
|
|
1324
|
-
const path =
|
|
1321
|
+
const dir = join5(codexSessionsDir(), String(yyyy), mm, dd);
|
|
1322
|
+
const path = join5(dir, `rollout-${tsStr}-${threadId}.jsonl`);
|
|
1325
1323
|
if (opts.threadId) {
|
|
1326
1324
|
sweepPriorRolloutsForThread(opts.threadId);
|
|
1327
1325
|
}
|
|
@@ -1337,13 +1335,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
1337
1335
|
return;
|
|
1338
1336
|
}
|
|
1339
1337
|
for (const bucket of buckets) {
|
|
1340
|
-
const dir =
|
|
1338
|
+
const dir = join5(sessionsDir, bucket);
|
|
1341
1339
|
if (!existsSync5(dir))
|
|
1342
1340
|
continue;
|
|
1343
1341
|
try {
|
|
1344
1342
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
1345
1343
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
1346
|
-
const fullPath =
|
|
1344
|
+
const fullPath = join5(dir, rel);
|
|
1347
1345
|
try {
|
|
1348
1346
|
unlinkSync5(fullPath);
|
|
1349
1347
|
} catch (e) {
|
|
@@ -1361,7 +1359,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
1361
1359
|
try {
|
|
1362
1360
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
1363
1361
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
1364
|
-
const fullPath =
|
|
1362
|
+
const fullPath = join5(sessionsDir, rel);
|
|
1365
1363
|
try {
|
|
1366
1364
|
unlinkSync5(fullPath);
|
|
1367
1365
|
} catch (e) {
|
|
@@ -1492,29 +1490,29 @@ var init_sqlite = __esm(async () => {
|
|
|
1492
1490
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1493
1491
|
import { mkdirSync as mkdirSync6 } from "fs";
|
|
1494
1492
|
import { homedir as homedir5 } from "os";
|
|
1495
|
-
import { dirname as
|
|
1493
|
+
import { dirname as dirname5, join as join6, resolve as resolve5 } from "path";
|
|
1496
1494
|
function envPath(name, fallback) {
|
|
1497
1495
|
const value2 = process.env[name]?.trim();
|
|
1498
1496
|
return resolve5(value2 || fallback);
|
|
1499
1497
|
}
|
|
1500
1498
|
function defaultStateDir() {
|
|
1501
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
1499
|
+
return envPath("NEGOTIUM_STATE_DIR", join6(homedir5(), ".negotium"));
|
|
1502
1500
|
}
|
|
1503
1501
|
function defaultDataDir() {
|
|
1504
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
1502
|
+
return envPath("NEGOTIUM_DATA_DIR", join6(defaultStateDir(), "data"));
|
|
1505
1503
|
}
|
|
1506
1504
|
function defaultLogDir() {
|
|
1507
|
-
return envPath("NEGOTIUM_LOG_DIR",
|
|
1505
|
+
return envPath("NEGOTIUM_LOG_DIR", join6(defaultStateDir(), "logs"));
|
|
1508
1506
|
}
|
|
1509
1507
|
function defaultWorkspaceDir() {
|
|
1510
|
-
return envPath("NEGOTIUM_WORKSPACE_DIR",
|
|
1508
|
+
return envPath("NEGOTIUM_WORKSPACE_DIR", join6(defaultStateDir(), "workspace"));
|
|
1511
1509
|
}
|
|
1512
1510
|
function defaultSessionAsksDir() {
|
|
1513
|
-
const runDir = envPath("NEGOTIUM_RUN_DIR",
|
|
1514
|
-
return
|
|
1511
|
+
const runDir = envPath("NEGOTIUM_RUN_DIR", join6(defaultStateDir(), "runtime"));
|
|
1512
|
+
return join6(runDir, "session-asks");
|
|
1515
1513
|
}
|
|
1516
1514
|
function defaultSessionsDatabasePath() {
|
|
1517
|
-
return envPath("SESSIONS_DB_PATH",
|
|
1515
|
+
return envPath("SESSIONS_DB_PATH", join6(resolveStorageDataDir(), "sessions.db"));
|
|
1518
1516
|
}
|
|
1519
1517
|
function initializeDatabase(database) {
|
|
1520
1518
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -1531,7 +1529,7 @@ function defaultDatabase() {
|
|
|
1531
1529
|
return fallbackDatabase;
|
|
1532
1530
|
if (fallbackDatabase)
|
|
1533
1531
|
fallbackDatabase.close();
|
|
1534
|
-
mkdirSync6(
|
|
1532
|
+
mkdirSync6(dirname5(path), { recursive: true });
|
|
1535
1533
|
fallbackDatabase = new Database(path, { create: true });
|
|
1536
1534
|
fallbackDatabasePath = path;
|
|
1537
1535
|
initializeDatabase(fallbackDatabase);
|
|
@@ -1553,7 +1551,7 @@ function resolveStorageWorkspaceDir() {
|
|
|
1553
1551
|
return configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
1554
1552
|
}
|
|
1555
1553
|
function resolveStorageSharedWikiDir() {
|
|
1556
|
-
return configuredHost.sharedWikiDir ??
|
|
1554
|
+
return configuredHost.sharedWikiDir ?? join6(resolveStorageWorkspaceDir(), "wiki");
|
|
1557
1555
|
}
|
|
1558
1556
|
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
1559
1557
|
schemaInitializers.push({ initialize, priority });
|
|
@@ -1615,16 +1613,16 @@ import {
|
|
|
1615
1613
|
unlinkSync as unlinkSync6,
|
|
1616
1614
|
writeFileSync as writeFileSync5
|
|
1617
1615
|
} from "fs";
|
|
1618
|
-
import { dirname as
|
|
1616
|
+
import { dirname as dirname6, join as join7 } from "path";
|
|
1619
1617
|
function conversationDir(_userId) {
|
|
1620
|
-
return
|
|
1618
|
+
return join7(resolveStorageDataDir(), "conversations");
|
|
1621
1619
|
}
|
|
1622
1620
|
function topicFilename(topicName) {
|
|
1623
1621
|
const t = sanitizeTopicName(topicName, true);
|
|
1624
1622
|
return `${t}.jsonl`;
|
|
1625
1623
|
}
|
|
1626
1624
|
function getConversationPath(userId, topicName) {
|
|
1627
|
-
return
|
|
1625
|
+
return join7(conversationDir(userId), topicFilename(topicName));
|
|
1628
1626
|
}
|
|
1629
1627
|
function getActiveConversationPath(userId, topicName) {
|
|
1630
1628
|
const rawPath = getConversationPath(userId, topicName);
|
|
@@ -1650,7 +1648,7 @@ function appendConversationEventStrict(userId, topicName, agent, event) {
|
|
|
1650
1648
|
event
|
|
1651
1649
|
};
|
|
1652
1650
|
const line = JSON.stringify(entry);
|
|
1653
|
-
mkdirSync7(
|
|
1651
|
+
mkdirSync7(dirname6(path), { recursive: true });
|
|
1654
1652
|
appendJsonlLine(path, line);
|
|
1655
1653
|
const activePath = getActiveConversationPath(userId, topicName);
|
|
1656
1654
|
if (existsSync6(activePath)) {
|
|
@@ -1699,7 +1697,7 @@ function replaceRawConversationStrict(userId, topicName, entries) {
|
|
|
1699
1697
|
}
|
|
1700
1698
|
function replaceConversationPathStrict(path, entries) {
|
|
1701
1699
|
const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
1702
|
-
mkdirSync7(
|
|
1700
|
+
mkdirSync7(dirname6(path), { recursive: true });
|
|
1703
1701
|
try {
|
|
1704
1702
|
writeFileSync5(tempPath, entries.length > 0 ? `${entries.map((entry) => JSON.stringify(entry)).join(`
|
|
1705
1703
|
`)}
|
|
@@ -1734,7 +1732,7 @@ var init_conversations = __esm(async () => {
|
|
|
1734
1732
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
1735
1733
|
import { existsSync as existsSync7, unlinkSync as unlinkSync7 } from "fs";
|
|
1736
1734
|
import { homedir as homedir6 } from "os";
|
|
1737
|
-
import { join as
|
|
1735
|
+
import { join as join8 } from "path";
|
|
1738
1736
|
var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
|
|
1739
1737
|
var init_codex_registry = __esm(async () => {
|
|
1740
1738
|
init_codex();
|
|
@@ -1783,7 +1781,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
1783
1781
|
async cleanupRollouts({ sessionIds }) {
|
|
1784
1782
|
if (sessionIds.length === 0)
|
|
1785
1783
|
return;
|
|
1786
|
-
const sessionsDir =
|
|
1784
|
+
const sessionsDir = join8(process.env.CODEX_HOME || join8(homedir6(), ".codex"), "sessions");
|
|
1787
1785
|
if (!existsSync7(sessionsDir))
|
|
1788
1786
|
return;
|
|
1789
1787
|
const failures = [];
|
|
@@ -1791,7 +1789,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
1791
1789
|
try {
|
|
1792
1790
|
const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
|
|
1793
1791
|
for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
1794
|
-
const path =
|
|
1792
|
+
const path = join8(sessionsDir, rel);
|
|
1795
1793
|
try {
|
|
1796
1794
|
unlinkSync7(path);
|
|
1797
1795
|
} catch (e) {
|
|
@@ -1817,15 +1815,15 @@ var init_codex_registry = __esm(async () => {
|
|
|
1817
1815
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
1818
1816
|
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
1819
1817
|
import { homedir as homedir7 } from "os";
|
|
1820
|
-
import { join as
|
|
1818
|
+
import { join as join9, resolve as resolve6 } from "path";
|
|
1821
1819
|
function maestroSessionsDir() {
|
|
1822
|
-
return
|
|
1820
|
+
return join9(process.env.MAESTRO_DATA_DIR ? resolve6(process.env.MAESTRO_DATA_DIR) : join9(homedir7(), ".maestro"), "sessions");
|
|
1823
1821
|
}
|
|
1824
1822
|
function maestroSessionPath(sessionId) {
|
|
1825
|
-
return
|
|
1823
|
+
return join9(maestroSessionsDir(), `${sessionId}.jsonl`);
|
|
1826
1824
|
}
|
|
1827
1825
|
function maestroActiveSessionPath(sessionId) {
|
|
1828
|
-
return
|
|
1826
|
+
return join9(maestroSessionsDir(), `${sessionId}.active.jsonl`);
|
|
1829
1827
|
}
|
|
1830
1828
|
function existingCreatedAt(path) {
|
|
1831
1829
|
if (!existsSync8(path))
|
|
@@ -4266,7 +4264,7 @@ var init_vault_crypto = __esm(() => {
|
|
|
4266
4264
|
|
|
4267
4265
|
// ../../packages/core/src/storage/vault.ts
|
|
4268
4266
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync9 } from "fs";
|
|
4269
|
-
import { join as
|
|
4267
|
+
import { join as join11 } from "path";
|
|
4270
4268
|
function initializeVaultDatabase(database) {
|
|
4271
4269
|
database.exec("PRAGMA journal_mode = WAL");
|
|
4272
4270
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -4301,8 +4299,8 @@ function initializeVaultDatabase(database) {
|
|
|
4301
4299
|
}
|
|
4302
4300
|
}
|
|
4303
4301
|
function openVaultDatabase(dataDir) {
|
|
4304
|
-
const vaultDir =
|
|
4305
|
-
const path =
|
|
4302
|
+
const vaultDir = join11(dataDir, "vault");
|
|
4303
|
+
const path = join11(vaultDir, "vault.db");
|
|
4306
4304
|
mkdirSync9(vaultDir, { recursive: true, mode: 448 });
|
|
4307
4305
|
const database = new Database(path, { create: true });
|
|
4308
4306
|
chmodSync2(path, 384);
|
|
@@ -4409,7 +4407,7 @@ import { randomBytes as randomBytes4, timingSafeEqual } from "crypto";
|
|
|
4409
4407
|
import { chmodSync as chmodSync3 } from "fs";
|
|
4410
4408
|
import { createServer as createServer2 } from "net";
|
|
4411
4409
|
import { tmpdir } from "os";
|
|
4412
|
-
import { join as
|
|
4410
|
+
import { join as join12 } from "path";
|
|
4413
4411
|
function deepMapStrings(value2, transform) {
|
|
4414
4412
|
if (typeof value2 === "string")
|
|
4415
4413
|
return transform(value2);
|
|
@@ -4496,7 +4494,7 @@ function authorized(actual, expected) {
|
|
|
4496
4494
|
}
|
|
4497
4495
|
async function createBrowserVaultBroker(userId) {
|
|
4498
4496
|
const token = randomBytes4(32).toString("hex");
|
|
4499
|
-
const socketPath =
|
|
4497
|
+
const socketPath = join12(process.platform === "win32" ? tmpdir() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes4(8).toString("hex")}.sock`);
|
|
4500
4498
|
const retainedForms = new Map;
|
|
4501
4499
|
const leases = new Map;
|
|
4502
4500
|
const sockets = new Set;
|
|
@@ -4700,7 +4698,7 @@ import {
|
|
|
4700
4698
|
unlinkSync as unlinkSync10,
|
|
4701
4699
|
writeFileSync as writeFileSync7
|
|
4702
4700
|
} from "fs";
|
|
4703
|
-
import { dirname as
|
|
4701
|
+
import { dirname as dirname7, join as join13, resolve as resolve9 } from "path";
|
|
4704
4702
|
function makeInstanceKey(userId, topic) {
|
|
4705
4703
|
return resolvePlaywrightTopicBinding(userId, topic).instanceKey;
|
|
4706
4704
|
}
|
|
@@ -4780,14 +4778,14 @@ function portFileName(instanceKey) {
|
|
|
4780
4778
|
function writePortFile(instanceKey, port) {
|
|
4781
4779
|
try {
|
|
4782
4780
|
mkdirSync10(managerHost.portsDir, { recursive: true });
|
|
4783
|
-
writeFileSync7(
|
|
4781
|
+
writeFileSync7(join13(managerHost.portsDir, portFileName(instanceKey)), String(port));
|
|
4784
4782
|
} catch (e) {
|
|
4785
4783
|
logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
|
|
4786
4784
|
}
|
|
4787
4785
|
}
|
|
4788
4786
|
function deletePortFile(instanceKey) {
|
|
4789
4787
|
try {
|
|
4790
|
-
unlinkSync10(
|
|
4788
|
+
unlinkSync10(join13(managerHost.portsDir, portFileName(instanceKey)));
|
|
4791
4789
|
} catch (e) {
|
|
4792
4790
|
logger.warn({ err: e, instanceKey }, "Failed to delete playwright port file");
|
|
4793
4791
|
}
|
|
@@ -5277,7 +5275,7 @@ async function cloneProfileForChild(opts) {
|
|
|
5277
5275
|
if (existsSync11(dstDir)) {
|
|
5278
5276
|
rmSync(dstDir, { recursive: true, force: true });
|
|
5279
5277
|
}
|
|
5280
|
-
mkdirSync10(
|
|
5278
|
+
mkdirSync10(dirname7(dstDir), { recursive: true });
|
|
5281
5279
|
if (process.platform === "darwin") {
|
|
5282
5280
|
try {
|
|
5283
5281
|
execFileSync3("cp", ["-cR", srcDir, dstDir], { stdio: "pipe" });
|
|
@@ -5954,7 +5952,7 @@ RULES:
|
|
|
5954
5952
|
|
|
5955
5953
|
// ../../packages/core/src/storage/tasks.ts
|
|
5956
5954
|
import { existsSync as existsSync12, mkdirSync as mkdirSync11, readFileSync as readFileSync10, renameSync as renameSync5, statSync as statSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
5957
|
-
import { dirname as
|
|
5955
|
+
import { dirname as dirname8, join as join14 } from "path";
|
|
5958
5956
|
function safeTaskScopeKey(scopeKey) {
|
|
5959
5957
|
const safe = sanitizeFileName(scopeKey);
|
|
5960
5958
|
if (!safe || safe === "." || safe === "..") {
|
|
@@ -5966,7 +5964,7 @@ function taskScopeKey(opts) {
|
|
|
5966
5964
|
return opts.topicId?.trim() || opts.session || "default";
|
|
5967
5965
|
}
|
|
5968
5966
|
function getTaskFilePath(userId, scopeKey) {
|
|
5969
|
-
return
|
|
5967
|
+
return join14(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
|
|
5970
5968
|
}
|
|
5971
5969
|
function readTasks(userId, scopeKey) {
|
|
5972
5970
|
const path = getTaskFilePath(userId, scopeKey);
|
|
@@ -5982,7 +5980,7 @@ function readTasks(userId, scopeKey) {
|
|
|
5982
5980
|
}
|
|
5983
5981
|
function writeTasks(userId, scopeKey, tasks) {
|
|
5984
5982
|
const path = getTaskFilePath(userId, scopeKey);
|
|
5985
|
-
mkdirSync11(
|
|
5983
|
+
mkdirSync11(dirname8(path), { recursive: true });
|
|
5986
5984
|
const payload = { version: 1, tasks };
|
|
5987
5985
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
5988
5986
|
writeFileSync8(tmp, JSON.stringify(payload, null, 2), "utf-8");
|
|
@@ -7687,7 +7685,7 @@ var init_claude_provider = __esm(async () => {
|
|
|
7687
7685
|
});
|
|
7688
7686
|
|
|
7689
7687
|
// ../../packages/core/src/version.ts
|
|
7690
|
-
var NEGOTIUM_VERSION = "0.2.
|
|
7688
|
+
var NEGOTIUM_VERSION = "0.2.3";
|
|
7691
7689
|
|
|
7692
7690
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
7693
7691
|
import { spawn as spawn6 } from "child_process";
|
|
@@ -7705,7 +7703,7 @@ import {
|
|
|
7705
7703
|
} from "fs";
|
|
7706
7704
|
import { createRequire as createRequire2 } from "module";
|
|
7707
7705
|
import { tmpdir as tmpdir2 } from "os";
|
|
7708
|
-
import { dirname as
|
|
7706
|
+
import { dirname as dirname9, join as join15 } from "path";
|
|
7709
7707
|
function readPackageVersion(packageJsonPath) {
|
|
7710
7708
|
const parsed = JSON.parse(readFileSync12(packageJsonPath, "utf8"));
|
|
7711
7709
|
if (typeof parsed.version !== "string" || !parsed.version.trim()) {
|
|
@@ -7714,7 +7712,7 @@ function readPackageVersion(packageJsonPath) {
|
|
|
7714
7712
|
return parsed.version;
|
|
7715
7713
|
}
|
|
7716
7714
|
function codexCliScriptPath() {
|
|
7717
|
-
return
|
|
7715
|
+
return join15(dirname9(bundledCodexPackagePath), "bin", "codex.js");
|
|
7718
7716
|
}
|
|
7719
7717
|
function parseCodexModelCache(contents, sourcePath) {
|
|
7720
7718
|
let parsed;
|
|
@@ -7755,7 +7753,7 @@ function writePrivateFileAtomic(path, contents) {
|
|
|
7755
7753
|
}
|
|
7756
7754
|
}
|
|
7757
7755
|
function bundledCodexModelCachePath(authFilePath) {
|
|
7758
|
-
return
|
|
7756
|
+
return join15(dirname9(authFilePath), NEGOTIUM_MODEL_CACHE);
|
|
7759
7757
|
}
|
|
7760
7758
|
async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
7761
7759
|
const child = spawn6(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
|
|
@@ -7840,16 +7838,16 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
7840
7838
|
});
|
|
7841
7839
|
}
|
|
7842
7840
|
async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
7843
|
-
const sourceHome =
|
|
7844
|
-
const isolatedHome = mkdtempSync(
|
|
7845
|
-
const isolatedCachePath =
|
|
7841
|
+
const sourceHome = dirname9(authFilePath);
|
|
7842
|
+
const isolatedHome = mkdtempSync(join15(tmpdir2(), "negotium-codex-models-"));
|
|
7843
|
+
const isolatedCachePath = join15(isolatedHome, "models_cache.json");
|
|
7846
7844
|
try {
|
|
7847
|
-
const isolatedAuthPath =
|
|
7845
|
+
const isolatedAuthPath = join15(isolatedHome, "auth.json");
|
|
7848
7846
|
copyFileSync(authFilePath, isolatedAuthPath);
|
|
7849
7847
|
chmodSync4(isolatedAuthPath, 384);
|
|
7850
|
-
const sourceConfigPath =
|
|
7848
|
+
const sourceConfigPath = join15(sourceHome, "config.toml");
|
|
7851
7849
|
if (existsSync14(sourceConfigPath)) {
|
|
7852
|
-
const isolatedConfigPath =
|
|
7850
|
+
const isolatedConfigPath = join15(isolatedHome, "config.toml");
|
|
7853
7851
|
copyFileSync(sourceConfigPath, isolatedConfigPath);
|
|
7854
7852
|
chmodSync4(isolatedConfigPath, 384);
|
|
7855
7853
|
}
|
|
@@ -7860,7 +7858,7 @@ async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
|
7860
7858
|
}
|
|
7861
7859
|
}
|
|
7862
7860
|
async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexModelCache) {
|
|
7863
|
-
const codexHome =
|
|
7861
|
+
const codexHome = dirname9(authFilePath);
|
|
7864
7862
|
const configuredCachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE;
|
|
7865
7863
|
if (configuredCachePath) {
|
|
7866
7864
|
if (!existsSync14(configuredCachePath)) {
|
|
@@ -7870,7 +7868,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
7870
7868
|
return configuredCachePath;
|
|
7871
7869
|
}
|
|
7872
7870
|
const bundledCachePath = bundledCodexModelCachePath(authFilePath);
|
|
7873
|
-
const sharedCachePath =
|
|
7871
|
+
const sharedCachePath = join15(codexHome, "models_cache.json");
|
|
7874
7872
|
if (existsSync14(sharedCachePath)) {
|
|
7875
7873
|
try {
|
|
7876
7874
|
const shared = readCompatibleCodexModelCache(sharedCachePath);
|
|
@@ -7889,8 +7887,8 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
7889
7887
|
return bundledCachePath;
|
|
7890
7888
|
}
|
|
7891
7889
|
function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
|
|
7892
|
-
const codexHome =
|
|
7893
|
-
const outputPath =
|
|
7890
|
+
const codexHome = dirname9(authFilePath);
|
|
7891
|
+
const outputPath = join15(codexHome, NEGOTIUM_MODEL_CATALOG);
|
|
7894
7892
|
const parsed = readCodexModelCache(sourcePath).parsed;
|
|
7895
7893
|
const models = parsed.models.map((model, index) => {
|
|
7896
7894
|
if (!model || typeof model !== "object" || Array.isArray(model)) {
|
|
@@ -8660,7 +8658,7 @@ __export(exports_codex_provider, {
|
|
|
8660
8658
|
});
|
|
8661
8659
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
8662
8660
|
import { existsSync as existsSync15, readFileSync as readFileSync14, realpathSync as realpathSync4, statSync as statSync6 } from "fs";
|
|
8663
|
-
import { dirname as
|
|
8661
|
+
import { dirname as dirname10, isAbsolute as isAbsolute3, join as join16, relative, resolve as resolve12 } from "path";
|
|
8664
8662
|
import { Codex } from "@openai/codex-sdk";
|
|
8665
8663
|
function mapEffort(effort) {
|
|
8666
8664
|
if (!effort)
|
|
@@ -8674,7 +8672,7 @@ function codexMcpServerName(name) {
|
|
|
8674
8672
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
8675
8673
|
}
|
|
8676
8674
|
function globalCodexMcpServerNames(authFilePath) {
|
|
8677
|
-
const configPath =
|
|
8675
|
+
const configPath = join16(dirname10(authFilePath), "config.toml");
|
|
8678
8676
|
if (!existsSync15(configPath))
|
|
8679
8677
|
return [];
|
|
8680
8678
|
try {
|
|
@@ -9470,7 +9468,7 @@ var init_maestro_provider = __esm(async () => {
|
|
|
9470
9468
|
// ../../packages/core/src/agents/index.ts
|
|
9471
9469
|
import { existsSync as existsSync16 } from "fs";
|
|
9472
9470
|
import { homedir as homedir8 } from "os";
|
|
9473
|
-
import { join as
|
|
9471
|
+
import { join as join17 } from "path";
|
|
9474
9472
|
async function* dispatchAgent(opts) {
|
|
9475
9473
|
switch (opts.agent) {
|
|
9476
9474
|
case "claude": {
|
|
@@ -9504,11 +9502,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
|
|
|
9504
9502
|
switch (agent) {
|
|
9505
9503
|
case "claude": {
|
|
9506
9504
|
const encodedCwd = encodeClaudeCwd(cwd);
|
|
9507
|
-
const path =
|
|
9505
|
+
const path = join17(homedir8(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
|
|
9508
9506
|
return !existsSync16(path);
|
|
9509
9507
|
}
|
|
9510
9508
|
case "codex": {
|
|
9511
|
-
const sessionsDir =
|
|
9509
|
+
const sessionsDir = join17(process.env.CODEX_HOME || join17(homedir8(), ".codex"), "sessions");
|
|
9512
9510
|
const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
|
|
9513
9511
|
for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
9514
9512
|
return false;
|
|
@@ -10024,9 +10022,9 @@ var init_api_topic_brief = __esm(async () => {
|
|
|
10024
10022
|
});
|
|
10025
10023
|
|
|
10026
10024
|
// ../../packages/core/src/storage/wiki.ts
|
|
10027
|
-
import { basename as basename3, dirname as
|
|
10025
|
+
import { basename as basename3, dirname as dirname11, join as join18 } from "path";
|
|
10028
10026
|
function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
|
|
10029
|
-
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() :
|
|
10027
|
+
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join18(workspaceDir, "wiki");
|
|
10030
10028
|
}
|
|
10031
10029
|
var init_wiki = __esm(async () => {
|
|
10032
10030
|
await init_storage_host();
|
|
@@ -10035,7 +10033,7 @@ var init_wiki = __esm(async () => {
|
|
|
10035
10033
|
// ../../packages/core/src/agents/archiver.ts
|
|
10036
10034
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
10037
10035
|
import { existsSync as existsSync17, readdirSync as readdirSync5, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
|
|
10038
|
-
import { join as
|
|
10036
|
+
import { join as join19 } from "path";
|
|
10039
10037
|
function resolveMemoryLanguage() {
|
|
10040
10038
|
const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
|
|
10041
10039
|
return override && override.length > 0 ? override : resolveOutputLanguage();
|
|
@@ -10286,10 +10284,10 @@ function distillOneLine(summaryMd) {
|
|
|
10286
10284
|
return "";
|
|
10287
10285
|
}
|
|
10288
10286
|
function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
10289
|
-
const dir =
|
|
10287
|
+
const dir = join19(storage.getWikiDir(), "summaries");
|
|
10290
10288
|
if (!storage.fileExists(dir))
|
|
10291
10289
|
return null;
|
|
10292
|
-
const predicted =
|
|
10290
|
+
const predicted = join19(dir, wikiSummaryFilename(date, topicTitle, topicId));
|
|
10293
10291
|
if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
|
|
10294
10292
|
return predicted;
|
|
10295
10293
|
let best = null;
|
|
@@ -10297,7 +10295,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
|
10297
10295
|
if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
|
|
10298
10296
|
continue;
|
|
10299
10297
|
}
|
|
10300
|
-
const p =
|
|
10298
|
+
const p = join19(dir, f);
|
|
10301
10299
|
try {
|
|
10302
10300
|
const m = storage.fileModifiedAt(p);
|
|
10303
10301
|
if (m >= sinceMs && (!best || m > best.mtime))
|
|
@@ -10495,13 +10493,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
|
|
|
10495
10493
|
|
|
10496
10494
|
// ../../packages/core/src/storage/topic-archive.ts
|
|
10497
10495
|
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync10 } from "fs";
|
|
10498
|
-
import { join as
|
|
10496
|
+
import { join as join20 } from "path";
|
|
10499
10497
|
function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
10500
10498
|
const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
|
|
10501
10499
|
if (rows.length === 0)
|
|
10502
10500
|
return null;
|
|
10503
10501
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
10504
|
-
const archiveDir =
|
|
10502
|
+
const archiveDir = join20(getSharedWikiDir(), "archive");
|
|
10505
10503
|
mkdirSync12(archiveDir, { recursive: true });
|
|
10506
10504
|
const date = new Date().toISOString().slice(0, 10);
|
|
10507
10505
|
const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
|
|
@@ -10514,7 +10512,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
|
10514
10512
|
let path;
|
|
10515
10513
|
while (true) {
|
|
10516
10514
|
filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
|
|
10517
|
-
path =
|
|
10515
|
+
path = join20(archiveDir, filename);
|
|
10518
10516
|
try {
|
|
10519
10517
|
writeFileSync10(path, body, { flag: "wx" });
|
|
10520
10518
|
break;
|
|
@@ -10559,7 +10557,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
10559
10557
|
const entries = readRawConversation(userId, topicTitle);
|
|
10560
10558
|
if (entries.length === 0)
|
|
10561
10559
|
return null;
|
|
10562
|
-
const archiveDir =
|
|
10560
|
+
const archiveDir = join20(getSharedWikiDir(), "archive");
|
|
10563
10561
|
mkdirSync12(archiveDir, { recursive: true });
|
|
10564
10562
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
10565
10563
|
const date = new Date().toISOString().slice(0, 10);
|
|
@@ -10587,7 +10585,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
10587
10585
|
let counter = 1;
|
|
10588
10586
|
while (true) {
|
|
10589
10587
|
const suffix = counter === 1 ? "" : `_${counter}`;
|
|
10590
|
-
const path =
|
|
10588
|
+
const path = join20(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
|
|
10591
10589
|
try {
|
|
10592
10590
|
writeFileSync10(path, body, { flag: "wx" });
|
|
10593
10591
|
logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
|
|
@@ -10911,7 +10909,7 @@ var init_idle_archiver = __esm(async () => {
|
|
|
10911
10909
|
|
|
10912
10910
|
// ../../packages/core/src/agents/topic-cleanup.ts
|
|
10913
10911
|
import { mkdirSync as mkdirSync13, renameSync as renameSync7, unlinkSync as unlinkSync12, writeFileSync as writeFileSync11 } from "fs";
|
|
10914
|
-
import { dirname as
|
|
10912
|
+
import { dirname as dirname12 } from "path";
|
|
10915
10913
|
function collectSessionIdsByAgent(entries, extraSessions = []) {
|
|
10916
10914
|
const out = new Map;
|
|
10917
10915
|
for (const e of entries) {
|
|
@@ -10977,7 +10975,7 @@ function createTopicLogMaintenance(host) {
|
|
|
10977
10975
|
const path = runtimeHost.activeConversationPath(opts.userId, opts.topicName);
|
|
10978
10976
|
const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
10979
10977
|
try {
|
|
10980
|
-
mkdirSync13(
|
|
10978
|
+
mkdirSync13(dirname12(path), { recursive: true });
|
|
10981
10979
|
writeFileSync11(tempPath, retained.length > 0 ? `${retained.map((entry) => JSON.stringify(entry)).join(`
|
|
10982
10980
|
`)}
|
|
10983
10981
|
` : "", { flag: "wx" });
|
|
@@ -11144,7 +11142,7 @@ var init_usage_alert = __esm(() => {
|
|
|
11144
11142
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
11145
11143
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
|
|
11146
11144
|
import { tmpdir as tmpdir3 } from "os";
|
|
11147
|
-
import { join as
|
|
11145
|
+
import { join as join21 } from "path";
|
|
11148
11146
|
function previousCompactedSummary(entries) {
|
|
11149
11147
|
for (let index = entries.length - 2;index >= 0; index -= 1) {
|
|
11150
11148
|
const request = entries[index]?.event;
|
|
@@ -11274,7 +11272,7 @@ function formatCompactElapsed(startedAt) {
|
|
|
11274
11272
|
async function summarizeTopicContext(request) {
|
|
11275
11273
|
const startedAt = Date.now();
|
|
11276
11274
|
const sessionIds = [];
|
|
11277
|
-
const compactCwd = mkdtempSync2(
|
|
11275
|
+
const compactCwd = mkdtempSync2(join21(tmpdir3(), "negotium-compact-"));
|
|
11278
11276
|
const abortController = new AbortController;
|
|
11279
11277
|
const relayAbort = () => abortController.abort(request.signal?.reason);
|
|
11280
11278
|
if (request.signal?.aborted)
|
|
@@ -11301,7 +11299,7 @@ async function summarizeTopicContext(request) {
|
|
|
11301
11299
|
let error = "";
|
|
11302
11300
|
let toolViolation = false;
|
|
11303
11301
|
let compactionLogCalls = 0;
|
|
11304
|
-
const compactionLogPath =
|
|
11302
|
+
const compactionLogPath = join21(compactCwd, "conversation.log");
|
|
11305
11303
|
try {
|
|
11306
11304
|
const compactionMcp = useCompactionLog ? {
|
|
11307
11305
|
compact_log: {
|
|
@@ -11897,14 +11895,14 @@ var init_derive = __esm(async () => {
|
|
|
11897
11895
|
});
|
|
11898
11896
|
|
|
11899
11897
|
// ../../packages/core/src/query/session-inbox-path.ts
|
|
11900
|
-
import { join as
|
|
11898
|
+
import { join as join22 } from "path";
|
|
11901
11899
|
function sessionInboxPath(userId, topicId) {
|
|
11902
11900
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
11903
|
-
return
|
|
11901
|
+
return join22(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
|
|
11904
11902
|
}
|
|
11905
11903
|
function scheduledSessionInboxPath(userId, topicId) {
|
|
11906
11904
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
11907
|
-
return
|
|
11905
|
+
return join22(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
|
|
11908
11906
|
}
|
|
11909
11907
|
var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
|
|
11910
11908
|
var init_session_inbox_path = __esm(() => {
|
|
@@ -11913,13 +11911,13 @@ var init_session_inbox_path = __esm(() => {
|
|
|
11913
11911
|
|
|
11914
11912
|
// ../../packages/core/src/query/session-inbox-cleanup.ts
|
|
11915
11913
|
import { unlinkSync as unlinkSync14 } from "fs";
|
|
11916
|
-
import { basename as basename4, join as
|
|
11914
|
+
import { basename as basename4, join as join23 } from "path";
|
|
11917
11915
|
function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
|
|
11918
11916
|
const live = sessionInboxPath(userId, topicId);
|
|
11919
11917
|
const scheduled = scheduledSessionInboxPath(userId, topicId);
|
|
11920
11918
|
const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
|
|
11921
11919
|
if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename4(legacyTopicTitle) === legacyTopicTitle) {
|
|
11922
|
-
const legacyBase =
|
|
11920
|
+
const legacyBase = join23(SESSION_INBOX_DIR, userId, legacyTopicTitle);
|
|
11923
11921
|
for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
|
|
11924
11922
|
candidates.add(`${legacyBase}${suffix}`);
|
|
11925
11923
|
}
|
|
@@ -11945,16 +11943,16 @@ var init_session_inbox_cleanup = __esm(() => {
|
|
|
11945
11943
|
|
|
11946
11944
|
// ../../packages/core/src/query/state.ts
|
|
11947
11945
|
import { mkdirSync as mkdirSync15, renameSync as renameSync8, unlinkSync as unlinkSync15, writeFileSync as writeFileSync13 } from "fs";
|
|
11948
|
-
import { basename as basename5, join as
|
|
11946
|
+
import { basename as basename5, join as join24 } from "path";
|
|
11949
11947
|
function createQueryStateStore(options) {
|
|
11950
11948
|
const sanitize = options.sanitizeTopicId ?? sanitizeId;
|
|
11951
|
-
const queryStateDirPath = (userId) =>
|
|
11952
|
-
const queryStateFile = (userId, topicId) =>
|
|
11949
|
+
const queryStateDirPath = (userId) => join24(options.usersLogDir, String(userId), "active-queries");
|
|
11950
|
+
const queryStateFile = (userId, topicId) => join24(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
|
|
11953
11951
|
const legacyQueryStateFile = (userId, topicName) => {
|
|
11954
11952
|
if (!topicName || topicName === "." || topicName === ".." || basename5(topicName) !== topicName) {
|
|
11955
11953
|
return null;
|
|
11956
11954
|
}
|
|
11957
|
-
return
|
|
11955
|
+
return join24(queryStateDirPath(userId), `${topicName}.json`);
|
|
11958
11956
|
};
|
|
11959
11957
|
return {
|
|
11960
11958
|
write(userId, topicId, topicName, task) {
|
|
@@ -12114,30 +12112,30 @@ import {
|
|
|
12114
12112
|
unlinkSync as unlinkSync16,
|
|
12115
12113
|
writeFileSync as writeFileSync14
|
|
12116
12114
|
} from "fs";
|
|
12117
|
-
import { dirname as
|
|
12115
|
+
import { dirname as dirname13, join as join25 } from "path";
|
|
12118
12116
|
function pendingAskDir(userId) {
|
|
12119
12117
|
const rawUserId = String(userId);
|
|
12120
12118
|
const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash4("sha256").update(rawUserId).digest("hex")}`;
|
|
12121
|
-
return
|
|
12119
|
+
return join25(resolveStorageSessionAsksDir(), safeUserId);
|
|
12122
12120
|
}
|
|
12123
12121
|
function encodeAskKey(key) {
|
|
12124
12122
|
return JSON.stringify([key.from, key.to]);
|
|
12125
12123
|
}
|
|
12126
12124
|
function pendingAskPath(key) {
|
|
12127
12125
|
const digest = createHash4("sha256").update(encodeAskKey(key)).digest("hex");
|
|
12128
|
-
return
|
|
12126
|
+
return join25(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
|
|
12129
12127
|
}
|
|
12130
12128
|
function v2PendingAskPath(key) {
|
|
12131
12129
|
const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
|
|
12132
|
-
return
|
|
12130
|
+
return join25(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
|
|
12133
12131
|
}
|
|
12134
12132
|
function legacyPendingAskPath(key) {
|
|
12135
12133
|
if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
|
|
12136
12134
|
return null;
|
|
12137
12135
|
}
|
|
12138
12136
|
const dir = pendingAskDir(key.userId);
|
|
12139
|
-
const candidate =
|
|
12140
|
-
return
|
|
12137
|
+
const candidate = join25(dir, `${key.from}___${key.to}.pending`);
|
|
12138
|
+
return dirname13(candidate) === dir ? candidate : null;
|
|
12141
12139
|
}
|
|
12142
12140
|
function parsePendingAskFilename(fileName) {
|
|
12143
12141
|
if (!fileName.endsWith(".pending"))
|
|
@@ -12377,7 +12375,7 @@ function listPendingAsksForCaller(args) {
|
|
|
12377
12375
|
const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
|
|
12378
12376
|
if (!parsed)
|
|
12379
12377
|
continue;
|
|
12380
|
-
const path =
|
|
12378
|
+
const path = join25(dir, fileName);
|
|
12381
12379
|
const record = readPendingAskFile(path, {
|
|
12382
12380
|
userId: args.userId,
|
|
12383
12381
|
from: parsed.from,
|
|
@@ -12419,7 +12417,7 @@ function deletePendingAsksForTopic(args) {
|
|
|
12419
12417
|
}
|
|
12420
12418
|
let deleted = 0;
|
|
12421
12419
|
for (const fileName of files) {
|
|
12422
|
-
const path =
|
|
12420
|
+
const path = join25(dir, fileName);
|
|
12423
12421
|
const parsed = parsePendingAskFilename(fileName);
|
|
12424
12422
|
const record = readPendingAskFile(path, {
|
|
12425
12423
|
userId: args.userId,
|
|
@@ -13088,7 +13086,7 @@ var init_lifecycle = __esm(async () => {
|
|
|
13088
13086
|
// ../../packages/core/src/runtime/attachments.ts
|
|
13089
13087
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
13090
13088
|
import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
13091
|
-
import { basename as basename6, join as
|
|
13089
|
+
import { basename as basename6, join as join26 } from "path";
|
|
13092
13090
|
function workspaceCwdFor(topicId) {
|
|
13093
13091
|
return resolveTopicWorkspaceDir(topicId);
|
|
13094
13092
|
}
|
|
@@ -13101,7 +13099,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
13101
13099
|
if (!attachmentIds?.length)
|
|
13102
13100
|
return [];
|
|
13103
13101
|
const out = [];
|
|
13104
|
-
const destDir =
|
|
13102
|
+
const destDir = join26(workspaceCwdFor(topicId), "attachments", queryId);
|
|
13105
13103
|
for (const rawId of attachmentIds) {
|
|
13106
13104
|
if (typeof rawId !== "string")
|
|
13107
13105
|
continue;
|
|
@@ -13118,7 +13116,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
13118
13116
|
mkdirSync17(destDir, { recursive: true });
|
|
13119
13117
|
const index = String(out.length + 1).padStart(2, "0");
|
|
13120
13118
|
const safeName = safeAttachmentFilename(attachment.filename, fileId);
|
|
13121
|
-
const destPath =
|
|
13119
|
+
const destPath = join26(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
|
|
13122
13120
|
copyFileSync2(sourcePath, destPath);
|
|
13123
13121
|
out.push({
|
|
13124
13122
|
id: attachment.id,
|
|
@@ -13148,10 +13146,10 @@ function promptWithAttachments(prompt, attachments) {
|
|
|
13148
13146
|
return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
|
|
13149
13147
|
}
|
|
13150
13148
|
function ingestAttachment(args) {
|
|
13151
|
-
const destDir =
|
|
13149
|
+
const destDir = join26(UPLOADS_DIR, args.topicId);
|
|
13152
13150
|
mkdirSync17(destDir, { recursive: true });
|
|
13153
13151
|
const safeName = safeAttachmentFilename(args.filename, "upload");
|
|
13154
|
-
const destPath =
|
|
13152
|
+
const destPath = join26(destDir, `${Date.now()}-${randomUUID13().slice(0, 8)}-${safeName}`);
|
|
13155
13153
|
if (args.sourcePath !== undefined) {
|
|
13156
13154
|
copyFileSync2(args.sourcePath, destPath);
|
|
13157
13155
|
} else if (args.bytes !== undefined) {
|
|
@@ -14292,7 +14290,7 @@ var init_visuals = __esm(async () => {
|
|
|
14292
14290
|
// ../../packages/core/src/storage/token-stats.ts
|
|
14293
14291
|
import { createHash as createHash6 } from "crypto";
|
|
14294
14292
|
import { mkdirSync as mkdirSync18 } from "fs";
|
|
14295
|
-
import { join as
|
|
14293
|
+
import { join as join27 } from "path";
|
|
14296
14294
|
function emptyBucket() {
|
|
14297
14295
|
return {
|
|
14298
14296
|
inputTokens: 0,
|
|
@@ -14310,7 +14308,7 @@ function queriesPath(userId) {
|
|
|
14310
14308
|
const fileId = tokenStatsFileId(userId);
|
|
14311
14309
|
const logDir = resolveStorageLogDir();
|
|
14312
14310
|
mkdirSync18(logDir, { recursive: true });
|
|
14313
|
-
return
|
|
14311
|
+
return join27(logDir, `token-queries-${fileId}.jsonl`);
|
|
14314
14312
|
}
|
|
14315
14313
|
function loadRecords(userId) {
|
|
14316
14314
|
try {
|
|
@@ -14964,9 +14962,9 @@ var init_turn_session = __esm(async () => {
|
|
|
14964
14962
|
|
|
14965
14963
|
// ../../packages/core/src/storage/app-settings.ts
|
|
14966
14964
|
import { existsSync as existsSync18, mkdirSync as mkdirSync19, readFileSync as readFileSync18, writeFileSync as writeFileSync16 } from "fs";
|
|
14967
|
-
import { dirname as
|
|
14965
|
+
import { dirname as dirname14, join as join28 } from "path";
|
|
14968
14966
|
function settingsFile() {
|
|
14969
|
-
return
|
|
14967
|
+
return join28(resolveStorageDataDir(), "otium-settings.json");
|
|
14970
14968
|
}
|
|
14971
14969
|
function ensureSettingsLoaded() {
|
|
14972
14970
|
const path = settingsFile();
|
|
@@ -15066,7 +15064,7 @@ __export(exports_turn_runner, {
|
|
|
15066
15064
|
});
|
|
15067
15065
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
15068
15066
|
import { existsSync as existsSync19, mkdirSync as mkdirSync20, readdirSync as readdirSync7, statSync as statSync10 } from "fs";
|
|
15069
|
-
import { join as
|
|
15067
|
+
import { join as join29 } from "path";
|
|
15070
15068
|
function withDefaultPlaywright(configuredMcp, isManager) {
|
|
15071
15069
|
if (isManager)
|
|
15072
15070
|
return configuredMcp;
|
|
@@ -15109,7 +15107,7 @@ function appendAskReplyMessage(topicId, text2, agentType) {
|
|
|
15109
15107
|
return message;
|
|
15110
15108
|
}
|
|
15111
15109
|
function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
|
|
15112
|
-
const preferred =
|
|
15110
|
+
const preferred = join29(directory, preferredFilename);
|
|
15113
15111
|
if (preferExact && existsSync19(preferred))
|
|
15114
15112
|
return preferred;
|
|
15115
15113
|
let newestLegacyId = null;
|
|
@@ -15120,7 +15118,7 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
15120
15118
|
const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
|
|
15121
15119
|
if (!titleMatch && !legacyIdMatch)
|
|
15122
15120
|
continue;
|
|
15123
|
-
const path =
|
|
15121
|
+
const path = join29(directory, filename);
|
|
15124
15122
|
const mtimeMs = statSync10(path).mtimeMs;
|
|
15125
15123
|
if (titleMatch) {
|
|
15126
15124
|
if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
|
|
@@ -15134,9 +15132,9 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
15134
15132
|
return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
|
|
15135
15133
|
}
|
|
15136
15134
|
function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
|
|
15137
|
-
const briefFile = resolveWikiMirrorPath(
|
|
15135
|
+
const briefFile = resolveWikiMirrorPath(join29(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
|
|
15138
15136
|
const hasBriefFile = existsSync19(briefFile) && statSync10(briefFile).isFile();
|
|
15139
|
-
const latestSummaryCandidate = resolveWikiMirrorPath(
|
|
15137
|
+
const latestSummaryCandidate = resolveWikiMirrorPath(join29(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
|
|
15140
15138
|
const latestSummaryFile = existsSync19(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
|
|
15141
15139
|
return { briefFile, hasBriefFile, latestSummaryFile };
|
|
15142
15140
|
}
|
|
@@ -16291,7 +16289,7 @@ __export(exports_auth_check, {
|
|
|
16291
16289
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
16292
16290
|
import { existsSync as existsSync20 } from "fs";
|
|
16293
16291
|
import { homedir as homedir9, platform } from "os";
|
|
16294
|
-
import { join as
|
|
16292
|
+
import { join as join30 } from "path";
|
|
16295
16293
|
function hasMaestroCredential(host, key, userId) {
|
|
16296
16294
|
if (userId && host.getVaultValue(userId, key)?.trim())
|
|
16297
16295
|
return true;
|
|
@@ -16320,7 +16318,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
|
|
|
16320
16318
|
error: "claude is not logged in (no macOS keychain entry 'Claude Code-credentials'). Run `claude` and complete login first"
|
|
16321
16319
|
};
|
|
16322
16320
|
}
|
|
16323
|
-
const path =
|
|
16321
|
+
const path = join30(host.homeDirectory(), ".claude", ".credentials.json");
|
|
16324
16322
|
if (host.exists(path))
|
|
16325
16323
|
return { ok: true };
|
|
16326
16324
|
return {
|
|
@@ -18436,7 +18434,7 @@ await __promiseAll([
|
|
|
18436
18434
|
]);
|
|
18437
18435
|
import { spawn as spawn2 } from "child_process";
|
|
18438
18436
|
import { existsSync as existsSync9, readdirSync as readdirSync3 } from "fs";
|
|
18439
|
-
import { join as
|
|
18437
|
+
import { join as join10 } from "path";
|
|
18440
18438
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18441
18439
|
import { z } from "zod";
|
|
18442
18440
|
function signalProcessTree(child, signal) {
|
|
@@ -18689,7 +18687,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
|
|
|
18689
18687
|
server.tool("list_active_queries", "\uD604\uC7AC \uC0AC\uC6A9\uC790 \uBC94\uC704\uC5D0\uC11C \uC2E4\uD589 \uC911\uC778 \uD1A0\uD53D \uCFFC\uB9AC \uBAA9\uB85D\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4.", {}, async () => {
|
|
18690
18688
|
if (!context.userId)
|
|
18691
18689
|
return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
|
|
18692
|
-
const stateDir =
|
|
18690
|
+
const stateDir = join10(USERS_LOG_DIR, context.userId, "active-queries");
|
|
18693
18691
|
if (!existsSync9(stateDir))
|
|
18694
18692
|
return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
|
|
18695
18693
|
let files;
|
|
@@ -18702,7 +18700,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
|
|
|
18702
18700
|
const entries = files.flatMap((file) => {
|
|
18703
18701
|
if (!file.endsWith(".json"))
|
|
18704
18702
|
return [];
|
|
18705
|
-
const state = readJsonFile(
|
|
18703
|
+
const state = readJsonFile(join10(stateDir, file));
|
|
18706
18704
|
if (!state)
|
|
18707
18705
|
return [];
|
|
18708
18706
|
const sinceMs = new Date(state.since).getTime();
|
|
@@ -19332,4 +19330,4 @@ export {
|
|
|
19332
19330
|
createAgentHealthMcpServer
|
|
19333
19331
|
};
|
|
19334
19332
|
|
|
19335
|
-
//# debugId=
|
|
19333
|
+
//# debugId=15239079843C89C364756E2164756E21
|