negotium 0.4.0 → 0.4.2
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 +179 -142
- package/dist/agent-helpers.js.map +7 -7
- package/dist/{chunk-zq2tcq4k.js → chunk-238qj1qy.js} +58 -22
- package/dist/{chunk-zq2tcq4k.js.map → chunk-238qj1qy.js.map} +5 -5
- package/dist/hosted-agent.js +89 -47
- package/dist/hosted-agent.js.map +8 -8
- package/dist/main.js +315 -278
- package/dist/main.js.map +7 -7
- package/dist/mcp-catalog.js +3 -2
- package/dist/mcp-catalog.js.map +3 -3
- package/dist/mcp-factories.js +161 -124
- package/dist/mcp-factories.js.map +7 -7
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/codex-provider.ts +7 -1
- package/dist/runtime/src/agents/codex-vault-hook-bridge.ts +14 -8
- package/dist/runtime/src/agents/codex-vault-hook.mjs +3 -1
- package/dist/runtime/src/platform/mcp-catalog-policy.ts +5 -0
- package/dist/runtime/src/platform/mcp-config.ts +81 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/types/packages/core/src/agents/codex-vault-hook-bridge.d.ts +1 -0
- package/dist/types/packages/core/src/platform/mcp-catalog-policy.d.ts +4 -0
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +19 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/agent-helpers.js
CHANGED
|
@@ -828,7 +828,8 @@ var init_mcp_catalog_policy = __esm(() => {
|
|
|
828
828
|
"system-health": { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
829
829
|
"background-bash": { scopes: ["forum"], forumRequired: true },
|
|
830
830
|
"agent-health": { scopes: ["forum", "manager", "cron"], forumRequired: true },
|
|
831
|
-
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true }
|
|
831
|
+
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
832
|
+
"cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false }
|
|
832
833
|
};
|
|
833
834
|
});
|
|
834
835
|
|
|
@@ -840,6 +841,9 @@ function browserOwnerCapability(capability, owner) {
|
|
|
840
841
|
var init_capability = () => {};
|
|
841
842
|
|
|
842
843
|
// ../../packages/core/src/platform/mcp-config.ts
|
|
844
|
+
import { accessSync as accessSync2, constants as fsConstants } from "fs";
|
|
845
|
+
import { homedir as homedir2 } from "os";
|
|
846
|
+
import { join as join2 } from "path";
|
|
843
847
|
function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
|
|
844
848
|
if (agent === "codex") {
|
|
845
849
|
return {
|
|
@@ -952,6 +956,27 @@ function backgroundBashTransport(agent, port, userId, topic) {
|
|
|
952
956
|
}
|
|
953
957
|
return { type: "sse", url: `http://127.0.0.1:${port}/sse`, headers };
|
|
954
958
|
}
|
|
959
|
+
function cuaRsArgs() {
|
|
960
|
+
const raw = envText("NEGOTIUM_CUA_RS_ALLOW_HID")?.trim().toLowerCase();
|
|
961
|
+
const on = raw === "1" || raw === "true" || raw === "yes";
|
|
962
|
+
return on ? ["--allow-hid"] : [];
|
|
963
|
+
}
|
|
964
|
+
function resolveCuaRsBinary(platform = process.platform) {
|
|
965
|
+
if (platform !== "darwin")
|
|
966
|
+
return null;
|
|
967
|
+
const candidates = [
|
|
968
|
+
envText("NEGOTIUM_CUA_RS_BIN"),
|
|
969
|
+
join2(homedir2(), ".local", "bin", "cua-rs"),
|
|
970
|
+
"/usr/local/bin/cua-rs"
|
|
971
|
+
].filter((p) => Boolean(p));
|
|
972
|
+
for (const candidate of candidates) {
|
|
973
|
+
try {
|
|
974
|
+
accessSync2(candidate, fsConstants.X_OK);
|
|
975
|
+
return candidate;
|
|
976
|
+
} catch {}
|
|
977
|
+
}
|
|
978
|
+
return null;
|
|
979
|
+
}
|
|
955
980
|
function refreshForumCatalogViews() {
|
|
956
981
|
const { all, required, optional } = classifyForumMcpServers(MCP_CATALOG);
|
|
957
982
|
allForumMcpServerNames.splice(0, allForumMcpServerNames.length, ...all);
|
|
@@ -1385,6 +1410,15 @@ var init_mcp_config = __esm(() => {
|
|
|
1385
1410
|
args.push("--list-only=true");
|
|
1386
1411
|
return buildBuiltinMcpServer("vault", { ...ctx, userId: vaultUserId ?? userId }, () => buildStdioMcpServer(agent, VAULT_SERVER, args));
|
|
1387
1412
|
}
|
|
1413
|
+
},
|
|
1414
|
+
"cua-rs": {
|
|
1415
|
+
...commonRuntimeMcpPolicy("cua-rs"),
|
|
1416
|
+
build() {
|
|
1417
|
+
const bin = resolveCuaRsBinary();
|
|
1418
|
+
if (!bin)
|
|
1419
|
+
return null;
|
|
1420
|
+
return { command: bin, args: cuaRsArgs() };
|
|
1421
|
+
}
|
|
1388
1422
|
}
|
|
1389
1423
|
};
|
|
1390
1424
|
allForumMcpServerNames = [];
|
|
@@ -1450,8 +1484,8 @@ var init_sqlite = __esm(async () => {
|
|
|
1450
1484
|
|
|
1451
1485
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1452
1486
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
1453
|
-
import { homedir as
|
|
1454
|
-
import { dirname as dirname2, join as
|
|
1487
|
+
import { homedir as homedir3 } from "os";
|
|
1488
|
+
import { dirname as dirname2, join as join3, resolve as resolve3 } from "path";
|
|
1455
1489
|
function storageState() {
|
|
1456
1490
|
const holder = globalThis;
|
|
1457
1491
|
const existing = holder[STORAGE_HOST_STATE];
|
|
@@ -1479,23 +1513,23 @@ function envPath(name, fallback) {
|
|
|
1479
1513
|
return resolve3(value || fallback);
|
|
1480
1514
|
}
|
|
1481
1515
|
function defaultStateDir() {
|
|
1482
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
1516
|
+
return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
|
|
1483
1517
|
}
|
|
1484
1518
|
function defaultDataDir() {
|
|
1485
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
1519
|
+
return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
|
|
1486
1520
|
}
|
|
1487
1521
|
function defaultLogDir() {
|
|
1488
|
-
return envPath("NEGOTIUM_LOG_DIR",
|
|
1522
|
+
return envPath("NEGOTIUM_LOG_DIR", join3(defaultStateDir(), "logs"));
|
|
1489
1523
|
}
|
|
1490
1524
|
function defaultWorkspaceDir() {
|
|
1491
|
-
return envPath("NEGOTIUM_WORKSPACE_DIR",
|
|
1525
|
+
return envPath("NEGOTIUM_WORKSPACE_DIR", join3(defaultStateDir(), "workspace"));
|
|
1492
1526
|
}
|
|
1493
1527
|
function defaultSessionAsksDir() {
|
|
1494
|
-
const runDir = envPath("NEGOTIUM_RUN_DIR",
|
|
1495
|
-
return
|
|
1528
|
+
const runDir = envPath("NEGOTIUM_RUN_DIR", join3(defaultStateDir(), "runtime"));
|
|
1529
|
+
return join3(runDir, "session-asks");
|
|
1496
1530
|
}
|
|
1497
1531
|
function defaultSessionsDatabasePath() {
|
|
1498
|
-
return envPath("SESSIONS_DB_PATH",
|
|
1532
|
+
return envPath("SESSIONS_DB_PATH", join3(resolveStorageDataDir(), "sessions.db"));
|
|
1499
1533
|
}
|
|
1500
1534
|
function isSqliteBusy(error) {
|
|
1501
1535
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1552,7 +1586,7 @@ function resolveStorageWorkspaceDir() {
|
|
|
1552
1586
|
return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
1553
1587
|
}
|
|
1554
1588
|
function resolveStorageSharedWikiDir() {
|
|
1555
|
-
return storageState().configuredHost.sharedWikiDir ??
|
|
1589
|
+
return storageState().configuredHost.sharedWikiDir ?? join3(resolveStorageWorkspaceDir(), "wiki");
|
|
1556
1590
|
}
|
|
1557
1591
|
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
1558
1592
|
const initializers = storageState().schemaInitializers;
|
|
@@ -1662,7 +1696,7 @@ var init_vault_crypto = __esm(() => {
|
|
|
1662
1696
|
|
|
1663
1697
|
// ../../packages/core/src/storage/vault.ts
|
|
1664
1698
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync3 } from "fs";
|
|
1665
|
-
import { join as
|
|
1699
|
+
import { join as join4 } from "path";
|
|
1666
1700
|
function initializeVaultDatabase(database) {
|
|
1667
1701
|
database.exec("PRAGMA journal_mode = WAL");
|
|
1668
1702
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -1697,8 +1731,8 @@ function initializeVaultDatabase(database) {
|
|
|
1697
1731
|
}
|
|
1698
1732
|
}
|
|
1699
1733
|
function openVaultDatabase(dataDir) {
|
|
1700
|
-
const vaultDir =
|
|
1701
|
-
const path =
|
|
1734
|
+
const vaultDir = join4(dataDir, "vault");
|
|
1735
|
+
const path = join4(vaultDir, "vault.db");
|
|
1702
1736
|
mkdirSync3(vaultDir, { recursive: true, mode: 448 });
|
|
1703
1737
|
const database = new Database(path, { create: true });
|
|
1704
1738
|
chmodSync2(path, 384);
|
|
@@ -2205,12 +2239,12 @@ var init_jsonl = __esm(() => {
|
|
|
2205
2239
|
// ../../packages/core/src/agents/rollout/claude.ts
|
|
2206
2240
|
import { randomUUID } from "crypto";
|
|
2207
2241
|
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
2208
|
-
import { homedir as
|
|
2209
|
-
import { join as
|
|
2242
|
+
import { homedir as homedir4 } from "os";
|
|
2243
|
+
import { join as join5 } from "path";
|
|
2210
2244
|
function loadClaudeAttachments() {
|
|
2211
2245
|
if (_attachmentsCache)
|
|
2212
2246
|
return _attachmentsCache;
|
|
2213
|
-
const raw = readFileSync3(
|
|
2247
|
+
const raw = readFileSync3(join5(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
|
|
2214
2248
|
const lines = parseJsonlText(raw);
|
|
2215
2249
|
if (lines.length < 2) {
|
|
2216
2250
|
throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
|
|
@@ -2311,8 +2345,8 @@ function writeClaudeRollout(opts) {
|
|
|
2311
2345
|
});
|
|
2312
2346
|
lastUuid = assistantUuid;
|
|
2313
2347
|
}
|
|
2314
|
-
const projectsDir =
|
|
2315
|
-
const path =
|
|
2348
|
+
const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
|
|
2349
|
+
const path = join5(projectsDir, `${sessionId}.jsonl`);
|
|
2316
2350
|
writeJsonlFile(path, lines);
|
|
2317
2351
|
logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
|
|
2318
2352
|
return { sessionId, rolloutPath: path };
|
|
@@ -2326,8 +2360,8 @@ var init_claude = __esm(() => {
|
|
|
2326
2360
|
|
|
2327
2361
|
// ../../packages/core/src/agents/claude-registry.ts
|
|
2328
2362
|
import { existsSync as existsSync3, mkdirSync as mkdirSync6, readdirSync, renameSync as renameSync2, unlinkSync as unlinkSync3 } from "fs";
|
|
2329
|
-
import { homedir as
|
|
2330
|
-
import { join as
|
|
2363
|
+
import { homedir as homedir5 } from "os";
|
|
2364
|
+
import { join as join6 } from "path";
|
|
2331
2365
|
var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
|
|
2332
2366
|
var init_claude_registry = __esm(() => {
|
|
2333
2367
|
init_claude();
|
|
@@ -2374,11 +2408,11 @@ var init_claude_registry = __esm(() => {
|
|
|
2374
2408
|
const result = await forkSession(parentSessionId, {
|
|
2375
2409
|
...title ? { title } : {}
|
|
2376
2410
|
});
|
|
2377
|
-
const projectsRoot =
|
|
2378
|
-
const destDir =
|
|
2379
|
-
const destPath =
|
|
2411
|
+
const projectsRoot = join6(homedir5(), ".claude", "projects");
|
|
2412
|
+
const destDir = join6(projectsRoot, encodeClaudeCwd(cwd));
|
|
2413
|
+
const destPath = join6(destDir, `${result.sessionId}.jsonl`);
|
|
2380
2414
|
if (!existsSync3(destPath)) {
|
|
2381
|
-
const sourcePath = readdirSync(projectsRoot).map((d) =>
|
|
2415
|
+
const sourcePath = readdirSync(projectsRoot).map((d) => join6(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync3(p));
|
|
2382
2416
|
if (!sourcePath) {
|
|
2383
2417
|
throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
|
|
2384
2418
|
}
|
|
@@ -2391,10 +2425,10 @@ var init_claude_registry = __esm(() => {
|
|
|
2391
2425
|
};
|
|
2392
2426
|
},
|
|
2393
2427
|
async cleanupRollouts({ cwd, sessionIds }) {
|
|
2394
|
-
const projectsDir =
|
|
2428
|
+
const projectsDir = join6(homedir5(), ".claude", "projects", encodeClaudeCwd(cwd));
|
|
2395
2429
|
const failures = [];
|
|
2396
2430
|
for (const sid of sessionIds) {
|
|
2397
|
-
const path =
|
|
2431
|
+
const path = join6(projectsDir, `${sid}.jsonl`);
|
|
2398
2432
|
try {
|
|
2399
2433
|
unlinkSync3(path);
|
|
2400
2434
|
} catch (e) {
|
|
@@ -2412,7 +2446,7 @@ var init_claude_registry = __esm(() => {
|
|
|
2412
2446
|
});
|
|
2413
2447
|
|
|
2414
2448
|
// ../../packages/core/src/version.ts
|
|
2415
|
-
var NEGOTIUM_VERSION = "0.4.
|
|
2449
|
+
var NEGOTIUM_VERSION = "0.4.2";
|
|
2416
2450
|
|
|
2417
2451
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
2418
2452
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -2430,7 +2464,7 @@ import {
|
|
|
2430
2464
|
} from "fs";
|
|
2431
2465
|
import { createRequire as createRequire2 } from "module";
|
|
2432
2466
|
import { tmpdir } from "os";
|
|
2433
|
-
import { dirname as dirname5, join as
|
|
2467
|
+
import { dirname as dirname5, join as join7 } from "path";
|
|
2434
2468
|
function readPackageVersion(packageJsonPath) {
|
|
2435
2469
|
const parsed = JSON.parse(readFileSync4(packageJsonPath, "utf8"));
|
|
2436
2470
|
if (typeof parsed.version !== "string" || !parsed.version.trim()) {
|
|
@@ -2439,7 +2473,7 @@ function readPackageVersion(packageJsonPath) {
|
|
|
2439
2473
|
return parsed.version;
|
|
2440
2474
|
}
|
|
2441
2475
|
function codexCliScriptPath() {
|
|
2442
|
-
return
|
|
2476
|
+
return join7(dirname5(bundledCodexPackagePath), "bin", "codex.js");
|
|
2443
2477
|
}
|
|
2444
2478
|
function parseCodexModelCache(contents, sourcePath) {
|
|
2445
2479
|
let parsed;
|
|
@@ -2480,7 +2514,7 @@ function writePrivateFileAtomic(path, contents) {
|
|
|
2480
2514
|
}
|
|
2481
2515
|
}
|
|
2482
2516
|
function bundledCodexModelCachePath(authFilePath) {
|
|
2483
|
-
return
|
|
2517
|
+
return join7(dirname5(authFilePath), NEGOTIUM_MODEL_CACHE);
|
|
2484
2518
|
}
|
|
2485
2519
|
async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
2486
2520
|
const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
|
|
@@ -2566,15 +2600,15 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
2566
2600
|
}
|
|
2567
2601
|
async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
2568
2602
|
const sourceHome = dirname5(authFilePath);
|
|
2569
|
-
const isolatedHome = mkdtempSync(
|
|
2570
|
-
const isolatedCachePath =
|
|
2603
|
+
const isolatedHome = mkdtempSync(join7(tmpdir(), "negotium-codex-models-"));
|
|
2604
|
+
const isolatedCachePath = join7(isolatedHome, "models_cache.json");
|
|
2571
2605
|
try {
|
|
2572
|
-
const isolatedAuthPath =
|
|
2606
|
+
const isolatedAuthPath = join7(isolatedHome, "auth.json");
|
|
2573
2607
|
copyFileSync(authFilePath, isolatedAuthPath);
|
|
2574
2608
|
chmodSync3(isolatedAuthPath, 384);
|
|
2575
|
-
const sourceConfigPath =
|
|
2609
|
+
const sourceConfigPath = join7(sourceHome, "config.toml");
|
|
2576
2610
|
if (existsSync4(sourceConfigPath)) {
|
|
2577
|
-
const isolatedConfigPath =
|
|
2611
|
+
const isolatedConfigPath = join7(isolatedHome, "config.toml");
|
|
2578
2612
|
copyFileSync(sourceConfigPath, isolatedConfigPath);
|
|
2579
2613
|
chmodSync3(isolatedConfigPath, 384);
|
|
2580
2614
|
}
|
|
@@ -2595,7 +2629,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
2595
2629
|
return configuredCachePath;
|
|
2596
2630
|
}
|
|
2597
2631
|
const bundledCachePath = bundledCodexModelCachePath(authFilePath);
|
|
2598
|
-
const sharedCachePath =
|
|
2632
|
+
const sharedCachePath = join7(codexHome, "models_cache.json");
|
|
2599
2633
|
if (existsSync4(sharedCachePath)) {
|
|
2600
2634
|
try {
|
|
2601
2635
|
const shared = readCompatibleCodexModelCache(sharedCachePath);
|
|
@@ -2615,7 +2649,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
2615
2649
|
}
|
|
2616
2650
|
function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
|
|
2617
2651
|
const codexHome = dirname5(authFilePath);
|
|
2618
|
-
const outputPath =
|
|
2652
|
+
const outputPath = join7(codexHome, NEGOTIUM_MODEL_CATALOG);
|
|
2619
2653
|
const parsed = readCodexModelCache(sourcePath).parsed;
|
|
2620
2654
|
const models = parsed.models.map((model, index) => {
|
|
2621
2655
|
if (!model || typeof model !== "object" || Array.isArray(model)) {
|
|
@@ -2643,14 +2677,14 @@ var init_codex_native_multi_agent = __esm(() => {
|
|
|
2643
2677
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2644
2678
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
2645
2679
|
import { existsSync as existsSync5, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync2, unlinkSync as unlinkSync5 } from "fs";
|
|
2646
|
-
import { basename, dirname as dirname6, join as
|
|
2680
|
+
import { basename, dirname as dirname6, join as join8, resolve as resolve5 } from "path";
|
|
2647
2681
|
function codexSessionsDir() {
|
|
2648
|
-
return
|
|
2682
|
+
return join8(hostedCodexHomePath(), "sessions");
|
|
2649
2683
|
}
|
|
2650
2684
|
function loadCodexShell() {
|
|
2651
2685
|
if (_shellCache)
|
|
2652
2686
|
return _shellCache;
|
|
2653
|
-
const raw = readFileSync5(
|
|
2687
|
+
const raw = readFileSync5(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
2654
2688
|
const lines = parseJsonlText(raw);
|
|
2655
2689
|
if (lines.length < 5) {
|
|
2656
2690
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -2717,8 +2751,8 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
2717
2751
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
2718
2752
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
2719
2753
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
2720
|
-
const dir =
|
|
2721
|
-
return
|
|
2754
|
+
const dir = join8(codexSessionsDir(), yyyy, mm, dd);
|
|
2755
|
+
return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
2722
2756
|
}
|
|
2723
2757
|
function canonicalFilePath(path) {
|
|
2724
2758
|
const absolute = resolve5(path);
|
|
@@ -2726,7 +2760,7 @@ function canonicalFilePath(path) {
|
|
|
2726
2760
|
return realpathSync2(absolute);
|
|
2727
2761
|
} catch {
|
|
2728
2762
|
try {
|
|
2729
|
-
return
|
|
2763
|
+
return join8(realpathSync2(dirname6(absolute)), basename(absolute));
|
|
2730
2764
|
} catch {
|
|
2731
2765
|
return absolute;
|
|
2732
2766
|
}
|
|
@@ -2956,19 +2990,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
2956
2990
|
try {
|
|
2957
2991
|
if (buckets) {
|
|
2958
2992
|
for (const bucket of buckets) {
|
|
2959
|
-
const dir =
|
|
2993
|
+
const dir = join8(sessionsDir, bucket);
|
|
2960
2994
|
if (!existsSync5(dir))
|
|
2961
2995
|
continue;
|
|
2962
2996
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
2963
2997
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
2964
|
-
candidates.push(
|
|
2998
|
+
candidates.push(join8(dir, rel));
|
|
2965
2999
|
}
|
|
2966
3000
|
}
|
|
2967
3001
|
}
|
|
2968
3002
|
if (candidates.length === 0) {
|
|
2969
3003
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
2970
3004
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
2971
|
-
candidates.push(
|
|
3005
|
+
candidates.push(join8(sessionsDir, rel));
|
|
2972
3006
|
}
|
|
2973
3007
|
}
|
|
2974
3008
|
return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
|
|
@@ -3089,13 +3123,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
3089
3123
|
return;
|
|
3090
3124
|
}
|
|
3091
3125
|
for (const bucket of buckets) {
|
|
3092
|
-
const dir =
|
|
3126
|
+
const dir = join8(sessionsDir, bucket);
|
|
3093
3127
|
if (!existsSync5(dir))
|
|
3094
3128
|
continue;
|
|
3095
3129
|
try {
|
|
3096
3130
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3097
3131
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3098
|
-
const fullPath =
|
|
3132
|
+
const fullPath = join8(dir, rel);
|
|
3099
3133
|
try {
|
|
3100
3134
|
unlinkSync5(fullPath);
|
|
3101
3135
|
} catch (e) {
|
|
@@ -3113,7 +3147,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
3113
3147
|
try {
|
|
3114
3148
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3115
3149
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3116
|
-
const fullPath =
|
|
3150
|
+
const fullPath = join8(sessionsDir, rel);
|
|
3117
3151
|
try {
|
|
3118
3152
|
unlinkSync5(fullPath);
|
|
3119
3153
|
} catch (e) {
|
|
@@ -3291,7 +3325,7 @@ var init_codex_app_server = __esm(async () => {
|
|
|
3291
3325
|
|
|
3292
3326
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
3293
3327
|
import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
|
|
3294
|
-
import { join as
|
|
3328
|
+
import { join as join9 } from "path";
|
|
3295
3329
|
var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
|
|
3296
3330
|
var init_codex_registry = __esm(async () => {
|
|
3297
3331
|
await init_codex_app_server();
|
|
@@ -3334,7 +3368,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3334
3368
|
async cleanupRollouts({ sessionIds }) {
|
|
3335
3369
|
if (sessionIds.length === 0)
|
|
3336
3370
|
return;
|
|
3337
|
-
const sessionsDir =
|
|
3371
|
+
const sessionsDir = join9(hostedCodexHomePath(), "sessions");
|
|
3338
3372
|
if (!existsSync6(sessionsDir))
|
|
3339
3373
|
return;
|
|
3340
3374
|
const failures = [];
|
|
@@ -3342,7 +3376,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3342
3376
|
try {
|
|
3343
3377
|
const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
|
|
3344
3378
|
for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3345
|
-
const path =
|
|
3379
|
+
const path = join9(sessionsDir, rel);
|
|
3346
3380
|
try {
|
|
3347
3381
|
unlinkSync6(path);
|
|
3348
3382
|
} catch (e) {
|
|
@@ -3367,16 +3401,16 @@ var init_codex_registry = __esm(async () => {
|
|
|
3367
3401
|
// ../../packages/core/src/agents/maestro-registry.ts
|
|
3368
3402
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
3369
3403
|
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
3370
|
-
import { homedir as
|
|
3371
|
-
import { join as
|
|
3404
|
+
import { homedir as homedir6 } from "os";
|
|
3405
|
+
import { join as join10, resolve as resolve6 } from "path";
|
|
3372
3406
|
function maestroSessionsDir() {
|
|
3373
|
-
return
|
|
3407
|
+
return join10(process.env.MAESTRO_DATA_DIR ? resolve6(process.env.MAESTRO_DATA_DIR) : join10(homedir6(), ".maestro"), "sessions");
|
|
3374
3408
|
}
|
|
3375
3409
|
function maestroSessionPath(sessionId) {
|
|
3376
|
-
return
|
|
3410
|
+
return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
|
|
3377
3411
|
}
|
|
3378
3412
|
function maestroActiveSessionPath(sessionId) {
|
|
3379
|
-
return
|
|
3413
|
+
return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
|
|
3380
3414
|
}
|
|
3381
3415
|
function existingCreatedAt(path) {
|
|
3382
3416
|
if (!existsSync7(path))
|
|
@@ -3552,7 +3586,7 @@ function sanitizeId(id) {
|
|
|
3552
3586
|
|
|
3553
3587
|
// ../../packages/core/src/storage/tasks.ts
|
|
3554
3588
|
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
3555
|
-
import { dirname as dirname7, join as
|
|
3589
|
+
import { dirname as dirname7, join as join11 } from "path";
|
|
3556
3590
|
function safeTaskScopeKey(scopeKey) {
|
|
3557
3591
|
const safe = sanitizeFileName(scopeKey);
|
|
3558
3592
|
if (!safe || safe === "." || safe === "..") {
|
|
@@ -3564,7 +3598,7 @@ function taskScopeKey(opts) {
|
|
|
3564
3598
|
return opts.topicId?.trim() || opts.session || "default";
|
|
3565
3599
|
}
|
|
3566
3600
|
function getTaskFilePath(userId, scopeKey) {
|
|
3567
|
-
return
|
|
3601
|
+
return join11(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
|
|
3568
3602
|
}
|
|
3569
3603
|
function readTasks(userId, scopeKey) {
|
|
3570
3604
|
const path = getTaskFilePath(userId, scopeKey);
|
|
@@ -3640,16 +3674,16 @@ import {
|
|
|
3640
3674
|
unlinkSync as unlinkSync7,
|
|
3641
3675
|
writeFileSync as writeFileSync7
|
|
3642
3676
|
} from "fs";
|
|
3643
|
-
import { dirname as dirname8, join as
|
|
3677
|
+
import { dirname as dirname8, join as join12 } from "path";
|
|
3644
3678
|
function conversationDir(_userId) {
|
|
3645
|
-
return
|
|
3679
|
+
return join12(resolveStorageDataDir(), "conversations");
|
|
3646
3680
|
}
|
|
3647
3681
|
function topicFilename(topicName) {
|
|
3648
3682
|
const t = sanitizeTopicName(topicName, true);
|
|
3649
3683
|
return `${t}.jsonl`;
|
|
3650
3684
|
}
|
|
3651
3685
|
function getConversationPath(userId, topicName) {
|
|
3652
|
-
return
|
|
3686
|
+
return join12(conversationDir(userId), topicFilename(topicName));
|
|
3653
3687
|
}
|
|
3654
3688
|
function getActiveConversationPath(userId, topicName) {
|
|
3655
3689
|
const rawPath = getConversationPath(userId, topicName);
|
|
@@ -4583,7 +4617,7 @@ import { existsSync as existsSync11 } from "fs";
|
|
|
4583
4617
|
import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
|
|
4584
4618
|
import { createServer } from "net";
|
|
4585
4619
|
import { tmpdir as tmpdir2 } from "os";
|
|
4586
|
-
import { dirname as dirname9, join as
|
|
4620
|
+
import { dirname as dirname9, join as join13, resolve as resolve7 } from "path";
|
|
4587
4621
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4588
4622
|
function evaluateCodexVaultPreToolUse(input, userId, operations) {
|
|
4589
4623
|
if (operations.referencesSensitiveStorage(input.tool_input)) {
|
|
@@ -4621,9 +4655,11 @@ function hookClientPath() {
|
|
|
4621
4655
|
return packaged;
|
|
4622
4656
|
throw new Error("Codex Vault hook client is missing from this installation");
|
|
4623
4657
|
}
|
|
4624
|
-
function privateCodexWrapper(codexScript) {
|
|
4658
|
+
function privateCodexWrapper(codexScript, socketPath, token) {
|
|
4625
4659
|
return [
|
|
4626
4660
|
"#!/bin/sh",
|
|
4661
|
+
`export ${HOOK_SOCKET_ENV}=${shellQuote(socketPath)}`,
|
|
4662
|
+
`export ${HOOK_TOKEN_ENV}=${shellQuote(token)}`,
|
|
4627
4663
|
'if [ "$1" = "exec" ]; then',
|
|
4628
4664
|
" shift",
|
|
4629
4665
|
` exec ${shellQuote(process.execPath)} ${shellQuote(codexScript)} exec --dangerously-bypass-hook-trust "$@"`,
|
|
@@ -4634,10 +4670,10 @@ function privateCodexWrapper(codexScript) {
|
|
|
4634
4670
|
`);
|
|
4635
4671
|
}
|
|
4636
4672
|
async function createCodexVaultHookBridge(userId) {
|
|
4637
|
-
const root = await mkdtemp(
|
|
4673
|
+
const root = await mkdtemp(join13(tmpdir2(), "negotium-codex-vault-"));
|
|
4638
4674
|
await chmod(root, 448);
|
|
4639
|
-
const socketPath =
|
|
4640
|
-
const wrapperPath =
|
|
4675
|
+
const socketPath = join13(root, "hook.sock");
|
|
4676
|
+
const wrapperPath = join13(root, "codex-with-hooks");
|
|
4641
4677
|
const token = randomBytes5(32).toString("hex");
|
|
4642
4678
|
const connections = new Set;
|
|
4643
4679
|
const server = createServer((socket) => {
|
|
@@ -4686,15 +4722,13 @@ async function createCodexVaultHookBridge(userId) {
|
|
|
4686
4722
|
});
|
|
4687
4723
|
});
|
|
4688
4724
|
await chmod(socketPath, 384);
|
|
4689
|
-
await writeFile(wrapperPath, privateCodexWrapper(codexCliScriptPath()), {
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
shellQuote(socketPath),
|
|
4694
|
-
shellQuote(token)
|
|
4695
|
-
].join(" ");
|
|
4725
|
+
await writeFile(wrapperPath, privateCodexWrapper(codexCliScriptPath(), socketPath, token), {
|
|
4726
|
+
mode: 448
|
|
4727
|
+
});
|
|
4728
|
+
const command = [shellQuote(process.execPath), shellQuote(hookClientPath())].join(" ");
|
|
4696
4729
|
return {
|
|
4697
4730
|
codexPathOverride: wrapperPath,
|
|
4731
|
+
environment: { [HOOK_SOCKET_ENV]: socketPath, [HOOK_TOKEN_ENV]: token },
|
|
4698
4732
|
hooks: {
|
|
4699
4733
|
PreToolUse: [
|
|
4700
4734
|
{
|
|
@@ -4723,7 +4757,7 @@ async function createCodexVaultHookBridge(userId) {
|
|
|
4723
4757
|
throw error;
|
|
4724
4758
|
}
|
|
4725
4759
|
}
|
|
4726
|
-
var MAX_HOOK_REQUEST_BYTES, SENSITIVE_STORAGE_DENIAL = "Runtime secret storage access is not permitted";
|
|
4760
|
+
var MAX_HOOK_REQUEST_BYTES, SENSITIVE_STORAGE_DENIAL = "Runtime secret storage access is not permitted", HOOK_SOCKET_ENV = "NEGOTIUM_CODEX_VAULT_HOOK_SOCKET", HOOK_TOKEN_ENV = "NEGOTIUM_CODEX_VAULT_HOOK_TOKEN";
|
|
4727
4761
|
var init_codex_vault_hook_bridge = __esm(async () => {
|
|
4728
4762
|
init_codex_native_multi_agent();
|
|
4729
4763
|
await init_execution_host();
|
|
@@ -5256,8 +5290,8 @@ __export(exports_codex_provider, {
|
|
|
5256
5290
|
});
|
|
5257
5291
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
5258
5292
|
import { existsSync as existsSync12, readFileSync as readFileSync11, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
|
|
5259
|
-
import { homedir as
|
|
5260
|
-
import { dirname as dirname10, isAbsolute as isAbsolute2, join as
|
|
5293
|
+
import { homedir as homedir7 } from "os";
|
|
5294
|
+
import { dirname as dirname10, isAbsolute as isAbsolute2, join as join14, relative, resolve as resolve9 } from "path";
|
|
5261
5295
|
import { Codex } from "@openai/codex-sdk";
|
|
5262
5296
|
function sameCodexUsage(usage, total) {
|
|
5263
5297
|
return usage.input_tokens === total.inputTokens && usage.output_tokens === total.outputTokens && (usage.cached_input_tokens ?? 0) === total.cachedInputTokens && (usage.cache_write_input_tokens ?? 0) === total.cacheWriteInputTokens;
|
|
@@ -5285,7 +5319,7 @@ function codexMcpServerName(name) {
|
|
|
5285
5319
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
5286
5320
|
}
|
|
5287
5321
|
function globalCodexMcpServerNames(authFilePath) {
|
|
5288
|
-
const configPath =
|
|
5322
|
+
const configPath = join14(dirname10(authFilePath), "config.toml");
|
|
5289
5323
|
if (!existsSync12(configPath))
|
|
5290
5324
|
return [];
|
|
5291
5325
|
try {
|
|
@@ -5643,7 +5677,7 @@ async function* codexProvider(opts) {
|
|
|
5643
5677
|
mcpServerCount: Object.keys(codexMcpServers).length
|
|
5644
5678
|
}, "codexProvider: starting turn");
|
|
5645
5679
|
const hostedCodexHome = hostedCodexHomePath();
|
|
5646
|
-
const inheritedCodexHome = process.env.CODEX_HOME ||
|
|
5680
|
+
const inheritedCodexHome = process.env.CODEX_HOME || join14(homedir7(), ".codex");
|
|
5647
5681
|
const codexEnvironment = scopedBrowserCapability || resolve9(hostedCodexHome) !== resolve9(inheritedCodexHome) ? {
|
|
5648
5682
|
...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
|
|
5649
5683
|
CODEX_HOME: hostedCodexHome,
|
|
@@ -5837,7 +5871,10 @@ async function* codexProvider(opts) {
|
|
|
5837
5871
|
yield fileEvent;
|
|
5838
5872
|
}
|
|
5839
5873
|
} else if (item.type === "error") {
|
|
5840
|
-
|
|
5874
|
+
const message = String(item.message ?? "");
|
|
5875
|
+
if (message !== CODEX_HOOK_TRUST_BYPASS_NOTICE) {
|
|
5876
|
+
yield { type: "error", content: message };
|
|
5877
|
+
}
|
|
5841
5878
|
}
|
|
5842
5879
|
break;
|
|
5843
5880
|
}
|
|
@@ -5928,7 +5965,7 @@ async function* codexProvider(opts) {
|
|
|
5928
5965
|
await vaultHook.close();
|
|
5929
5966
|
}
|
|
5930
5967
|
}
|
|
5931
|
-
var CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_FILE_LIMIT = 200, CODEX_DIFF_BASELINE_BYTE_LIMIT, CODEX_STARTUP_TIMEOUT_MS = 90000;
|
|
5968
|
+
var CODEX_HOOK_TRUST_BYPASS_NOTICE = "`--dangerously-bypass-hook-trust` is enabled. Enabled hooks may run without review for this invocation.", CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_FILE_LIMIT = 200, CODEX_DIFF_BASELINE_BYTE_LIMIT, CODEX_STARTUP_TIMEOUT_MS = 90000;
|
|
5932
5969
|
var init_codex_provider = __esm(async () => {
|
|
5933
5970
|
init_codex_native_multi_agent();
|
|
5934
5971
|
init_codex_tree_kill();
|
|
@@ -6099,8 +6136,8 @@ var init_maestro_provider = __esm(async () => {
|
|
|
6099
6136
|
|
|
6100
6137
|
// ../../packages/core/src/agents/index.ts
|
|
6101
6138
|
import { existsSync as existsSync13 } from "fs";
|
|
6102
|
-
import { homedir as
|
|
6103
|
-
import { join as
|
|
6139
|
+
import { homedir as homedir8 } from "os";
|
|
6140
|
+
import { join as join15 } from "path";
|
|
6104
6141
|
async function* dispatchAgent(opts) {
|
|
6105
6142
|
switch (opts.agent) {
|
|
6106
6143
|
case "claude": {
|
|
@@ -6134,11 +6171,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
|
|
|
6134
6171
|
switch (agent) {
|
|
6135
6172
|
case "claude": {
|
|
6136
6173
|
const encodedCwd = encodeClaudeCwd(cwd);
|
|
6137
|
-
const path =
|
|
6174
|
+
const path = join15(homedir8(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
|
|
6138
6175
|
return !existsSync13(path);
|
|
6139
6176
|
}
|
|
6140
6177
|
case "codex": {
|
|
6141
|
-
const sessionsDir =
|
|
6178
|
+
const sessionsDir = join15(hostedCodexHomePath(), "sessions");
|
|
6142
6179
|
const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
|
|
6143
6180
|
for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
6144
6181
|
return false;
|
|
@@ -7393,9 +7430,9 @@ var init_api_topic_brief = __esm(async () => {
|
|
|
7393
7430
|
});
|
|
7394
7431
|
|
|
7395
7432
|
// ../../packages/core/src/storage/wiki.ts
|
|
7396
|
-
import { basename as basename2, dirname as dirname11, join as
|
|
7433
|
+
import { basename as basename2, dirname as dirname11, join as join16 } from "path";
|
|
7397
7434
|
function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
|
|
7398
|
-
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() :
|
|
7435
|
+
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join16(workspaceDir, "wiki");
|
|
7399
7436
|
}
|
|
7400
7437
|
var init_wiki = __esm(async () => {
|
|
7401
7438
|
await init_storage_host();
|
|
@@ -8230,7 +8267,7 @@ var init_personal_general = __esm(async () => {
|
|
|
8230
8267
|
// ../../packages/core/src/agents/archiver.ts
|
|
8231
8268
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
8232
8269
|
import { existsSync as existsSync14, readdirSync as readdirSync2, readFileSync as readFileSync13, statSync as statSync6 } from "fs";
|
|
8233
|
-
import { join as
|
|
8270
|
+
import { join as join17 } from "path";
|
|
8234
8271
|
function resolveMemoryLanguage() {
|
|
8235
8272
|
const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
|
|
8236
8273
|
return override && override.length > 0 ? override : resolveOutputLanguage();
|
|
@@ -8481,10 +8518,10 @@ function distillOneLine(summaryMd) {
|
|
|
8481
8518
|
return "";
|
|
8482
8519
|
}
|
|
8483
8520
|
function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
8484
|
-
const dir =
|
|
8521
|
+
const dir = join17(storage.getWikiDir(), "summaries");
|
|
8485
8522
|
if (!storage.fileExists(dir))
|
|
8486
8523
|
return null;
|
|
8487
|
-
const predicted =
|
|
8524
|
+
const predicted = join17(dir, wikiSummaryFilename(date, topicTitle, topicId));
|
|
8488
8525
|
if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
|
|
8489
8526
|
return predicted;
|
|
8490
8527
|
let best = null;
|
|
@@ -8492,7 +8529,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
|
8492
8529
|
if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
|
|
8493
8530
|
continue;
|
|
8494
8531
|
}
|
|
8495
|
-
const p =
|
|
8532
|
+
const p = join17(dir, f);
|
|
8496
8533
|
try {
|
|
8497
8534
|
const m = storage.fileModifiedAt(p);
|
|
8498
8535
|
if (m >= sinceMs && (!best || m > best.mtime))
|
|
@@ -8619,8 +8656,8 @@ __export(exports_auth_check, {
|
|
|
8619
8656
|
});
|
|
8620
8657
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
8621
8658
|
import { existsSync as existsSync15 } from "fs";
|
|
8622
|
-
import { homedir as
|
|
8623
|
-
import { join as
|
|
8659
|
+
import { homedir as homedir9, platform } from "os";
|
|
8660
|
+
import { join as join18 } from "path";
|
|
8624
8661
|
function hasMaestroCredential(host, key, userId) {
|
|
8625
8662
|
if (userId && host.getVaultValue(userId, key)?.trim())
|
|
8626
8663
|
return true;
|
|
@@ -8640,7 +8677,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
|
|
|
8640
8677
|
case "claude": {
|
|
8641
8678
|
if (host.environment.ANTHROPIC_API_KEY)
|
|
8642
8679
|
return { ok: true };
|
|
8643
|
-
const path =
|
|
8680
|
+
const path = join18(host.homeDirectory(), ".claude", ".credentials.json");
|
|
8644
8681
|
if (host.operatingSystem() === "darwin") {
|
|
8645
8682
|
if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
|
|
8646
8683
|
return { ok: true };
|
|
@@ -8693,7 +8730,7 @@ var init_auth_check = __esm(async () => {
|
|
|
8693
8730
|
codexAuthFilePath,
|
|
8694
8731
|
exists: existsSync15,
|
|
8695
8732
|
environment: process.env,
|
|
8696
|
-
homeDirectory:
|
|
8733
|
+
homeDirectory: homedir9,
|
|
8697
8734
|
operatingSystem: platform,
|
|
8698
8735
|
hasMacOsCredential(service) {
|
|
8699
8736
|
try {
|
|
@@ -9401,13 +9438,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
|
|
|
9401
9438
|
|
|
9402
9439
|
// ../../packages/core/src/storage/topic-archive.ts
|
|
9403
9440
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8 } from "fs";
|
|
9404
|
-
import { join as
|
|
9441
|
+
import { join as join19 } from "path";
|
|
9405
9442
|
function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
9406
9443
|
const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
|
|
9407
9444
|
if (rows.length === 0)
|
|
9408
9445
|
return null;
|
|
9409
9446
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
9410
|
-
const archiveDir =
|
|
9447
|
+
const archiveDir = join19(getSharedWikiDir(), "archive");
|
|
9411
9448
|
mkdirSync10(archiveDir, { recursive: true });
|
|
9412
9449
|
const date = new Date().toISOString().slice(0, 10);
|
|
9413
9450
|
const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
|
|
@@ -9420,7 +9457,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
|
9420
9457
|
let path;
|
|
9421
9458
|
while (true) {
|
|
9422
9459
|
filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
|
|
9423
|
-
path =
|
|
9460
|
+
path = join19(archiveDir, filename);
|
|
9424
9461
|
try {
|
|
9425
9462
|
writeFileSync8(path, body, { flag: "wx" });
|
|
9426
9463
|
break;
|
|
@@ -9465,7 +9502,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
9465
9502
|
const entries = readRawConversation(userId, topicTitle);
|
|
9466
9503
|
if (entries.length === 0)
|
|
9467
9504
|
return null;
|
|
9468
|
-
const archiveDir =
|
|
9505
|
+
const archiveDir = join19(getSharedWikiDir(), "archive");
|
|
9469
9506
|
mkdirSync10(archiveDir, { recursive: true });
|
|
9470
9507
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
9471
9508
|
const date = new Date().toISOString().slice(0, 10);
|
|
@@ -9493,7 +9530,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
9493
9530
|
let counter = 1;
|
|
9494
9531
|
while (true) {
|
|
9495
9532
|
const suffix = counter === 1 ? "" : `_${counter}`;
|
|
9496
|
-
const path =
|
|
9533
|
+
const path = join19(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
|
|
9497
9534
|
try {
|
|
9498
9535
|
writeFileSync8(path, body, { flag: "wx" });
|
|
9499
9536
|
logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
|
|
@@ -10826,13 +10863,13 @@ var init_browser_processes = __esm(async () => {
|
|
|
10826
10863
|
});
|
|
10827
10864
|
|
|
10828
10865
|
// ../../packages/core/src/platform/playwright/headed-launch.ts
|
|
10829
|
-
import { accessSync as
|
|
10866
|
+
import { accessSync as accessSync3, constants as constants2 } from "fs";
|
|
10830
10867
|
import { delimiter, isAbsolute as isAbsolute4, resolve as resolve14 } from "path";
|
|
10831
10868
|
function findExecutableOnPath(command, environment = process.env) {
|
|
10832
10869
|
const candidates = isAbsolute4(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve14(directory, command));
|
|
10833
10870
|
for (const candidate of candidates) {
|
|
10834
10871
|
try {
|
|
10835
|
-
|
|
10872
|
+
accessSync3(candidate, constants2.X_OK);
|
|
10836
10873
|
return candidate;
|
|
10837
10874
|
} catch {}
|
|
10838
10875
|
}
|
|
@@ -10931,7 +10968,7 @@ import { randomBytes as randomBytes6, timingSafeEqual as timingSafeEqual2 } from
|
|
|
10931
10968
|
import { chmodSync as chmodSync4 } from "fs";
|
|
10932
10969
|
import { createServer as createServer3 } from "net";
|
|
10933
10970
|
import { tmpdir as tmpdir3 } from "os";
|
|
10934
|
-
import { join as
|
|
10971
|
+
import { join as join20 } from "path";
|
|
10935
10972
|
function deepMapStrings2(value, transform) {
|
|
10936
10973
|
if (typeof value === "string")
|
|
10937
10974
|
return transform(value);
|
|
@@ -11018,7 +11055,7 @@ function authorized(actual, expected) {
|
|
|
11018
11055
|
}
|
|
11019
11056
|
async function createBrowserVaultBroker(userId) {
|
|
11020
11057
|
const token = randomBytes6(32).toString("hex");
|
|
11021
|
-
const socketPath =
|
|
11058
|
+
const socketPath = join20(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`);
|
|
11022
11059
|
const retainedForms = new Map;
|
|
11023
11060
|
const leases = new Map;
|
|
11024
11061
|
const sockets = new Set;
|
|
@@ -11227,7 +11264,7 @@ import {
|
|
|
11227
11264
|
unlinkSync as unlinkSync11,
|
|
11228
11265
|
writeFileSync as writeFileSync9
|
|
11229
11266
|
} from "fs";
|
|
11230
|
-
import { dirname as dirname12, join as
|
|
11267
|
+
import { dirname as dirname12, join as join21, resolve as resolve15 } from "path";
|
|
11231
11268
|
function removeDefaultProfileDataDir(userDataDir) {
|
|
11232
11269
|
const root = resolve15(BROWSER_PROFILES_DIR);
|
|
11233
11270
|
const target = resolve15(userDataDir);
|
|
@@ -11317,14 +11354,14 @@ function portFileName(instanceKey) {
|
|
|
11317
11354
|
function writePortFile(instanceKey, port) {
|
|
11318
11355
|
try {
|
|
11319
11356
|
mkdirSync11(managerHost.portsDir, { recursive: true });
|
|
11320
|
-
writeFileSync9(
|
|
11357
|
+
writeFileSync9(join21(managerHost.portsDir, portFileName(instanceKey)), String(port));
|
|
11321
11358
|
} catch (e) {
|
|
11322
11359
|
logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
|
|
11323
11360
|
}
|
|
11324
11361
|
}
|
|
11325
11362
|
function deletePortFile(instanceKey) {
|
|
11326
11363
|
try {
|
|
11327
|
-
unlinkSync11(
|
|
11364
|
+
unlinkSync11(join21(managerHost.portsDir, portFileName(instanceKey)));
|
|
11328
11365
|
} catch (e) {
|
|
11329
11366
|
if (e.code === "ENOENT")
|
|
11330
11367
|
return;
|
|
@@ -12483,7 +12520,7 @@ var init_runtime_turn_requests = __esm(async () => {
|
|
|
12483
12520
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
12484
12521
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "fs";
|
|
12485
12522
|
import { tmpdir as tmpdir4 } from "os";
|
|
12486
|
-
import { join as
|
|
12523
|
+
import { join as join22 } from "path";
|
|
12487
12524
|
function previousCompactedSummary(entries) {
|
|
12488
12525
|
for (let index = entries.length - 2;index >= 0; index -= 1) {
|
|
12489
12526
|
const request = entries[index]?.event;
|
|
@@ -12613,7 +12650,7 @@ function formatCompactElapsed(startedAt) {
|
|
|
12613
12650
|
async function summarizeTopicContext(request) {
|
|
12614
12651
|
const startedAt = Date.now();
|
|
12615
12652
|
const sessionIds = [];
|
|
12616
|
-
const compactCwd = mkdtempSync2(
|
|
12653
|
+
const compactCwd = mkdtempSync2(join22(tmpdir4(), "negotium-compact-"));
|
|
12617
12654
|
const abortController = new AbortController;
|
|
12618
12655
|
const relayAbort = () => abortController.abort(request.signal?.reason);
|
|
12619
12656
|
if (request.signal?.aborted)
|
|
@@ -12640,7 +12677,7 @@ async function summarizeTopicContext(request) {
|
|
|
12640
12677
|
let error = "";
|
|
12641
12678
|
let toolViolation = false;
|
|
12642
12679
|
let compactionLogCalls = 0;
|
|
12643
|
-
const compactionLogPath =
|
|
12680
|
+
const compactionLogPath = join22(compactCwd, "conversation.log");
|
|
12644
12681
|
try {
|
|
12645
12682
|
const compactionMcp = useCompactionLog ? {
|
|
12646
12683
|
compact_log: {
|
|
@@ -13259,14 +13296,14 @@ var init_derive = __esm(async () => {
|
|
|
13259
13296
|
});
|
|
13260
13297
|
|
|
13261
13298
|
// ../../packages/core/src/query/session-inbox-path.ts
|
|
13262
|
-
import { join as
|
|
13299
|
+
import { join as join23 } from "path";
|
|
13263
13300
|
function sessionInboxPath(userId, topicId) {
|
|
13264
13301
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
13265
|
-
return
|
|
13302
|
+
return join23(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
|
|
13266
13303
|
}
|
|
13267
13304
|
function scheduledSessionInboxPath(userId, topicId) {
|
|
13268
13305
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
13269
|
-
return
|
|
13306
|
+
return join23(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
|
|
13270
13307
|
}
|
|
13271
13308
|
var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
|
|
13272
13309
|
var init_session_inbox_path = __esm(() => {
|
|
@@ -13275,13 +13312,13 @@ var init_session_inbox_path = __esm(() => {
|
|
|
13275
13312
|
|
|
13276
13313
|
// ../../packages/core/src/query/session-inbox-cleanup.ts
|
|
13277
13314
|
import { unlinkSync as unlinkSync14 } from "fs";
|
|
13278
|
-
import { basename as basename3, join as
|
|
13315
|
+
import { basename as basename3, join as join24 } from "path";
|
|
13279
13316
|
function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
|
|
13280
13317
|
const live = sessionInboxPath(userId, topicId);
|
|
13281
13318
|
const scheduled = scheduledSessionInboxPath(userId, topicId);
|
|
13282
13319
|
const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
|
|
13283
13320
|
if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename3(legacyTopicTitle) === legacyTopicTitle) {
|
|
13284
|
-
const legacyBase =
|
|
13321
|
+
const legacyBase = join24(SESSION_INBOX_DIR, userId, legacyTopicTitle);
|
|
13285
13322
|
for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
|
|
13286
13323
|
candidates.add(`${legacyBase}${suffix}`);
|
|
13287
13324
|
}
|
|
@@ -13307,16 +13344,16 @@ var init_session_inbox_cleanup = __esm(() => {
|
|
|
13307
13344
|
|
|
13308
13345
|
// ../../packages/core/src/query/state.ts
|
|
13309
13346
|
import { mkdirSync as mkdirSync14, renameSync as renameSync7, unlinkSync as unlinkSync15, writeFileSync as writeFileSync12 } from "fs";
|
|
13310
|
-
import { basename as basename4, join as
|
|
13347
|
+
import { basename as basename4, join as join25 } from "path";
|
|
13311
13348
|
function createQueryStateStore(options) {
|
|
13312
13349
|
const sanitize = options.sanitizeTopicId ?? sanitizeId;
|
|
13313
|
-
const queryStateDirPath = (userId) =>
|
|
13314
|
-
const queryStateFile = (userId, topicId) =>
|
|
13350
|
+
const queryStateDirPath = (userId) => join25(options.usersLogDir, String(userId), "active-queries");
|
|
13351
|
+
const queryStateFile = (userId, topicId) => join25(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
|
|
13315
13352
|
const legacyQueryStateFile = (userId, topicName) => {
|
|
13316
13353
|
if (!topicName || topicName === "." || topicName === ".." || basename4(topicName) !== topicName) {
|
|
13317
13354
|
return null;
|
|
13318
13355
|
}
|
|
13319
|
-
return
|
|
13356
|
+
return join25(queryStateDirPath(userId), `${topicName}.json`);
|
|
13320
13357
|
};
|
|
13321
13358
|
return {
|
|
13322
13359
|
write(userId, topicId, topicName, task) {
|
|
@@ -13477,29 +13514,29 @@ import {
|
|
|
13477
13514
|
unlinkSync as unlinkSync16,
|
|
13478
13515
|
writeFileSync as writeFileSync13
|
|
13479
13516
|
} from "fs";
|
|
13480
|
-
import { dirname as dirname14, join as
|
|
13517
|
+
import { dirname as dirname14, join as join26 } from "path";
|
|
13481
13518
|
function pendingAskDir(userId) {
|
|
13482
13519
|
const rawUserId = String(userId);
|
|
13483
13520
|
const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash6("sha256").update(rawUserId).digest("hex")}`;
|
|
13484
|
-
return
|
|
13521
|
+
return join26(resolveStorageSessionAsksDir(), safeUserId);
|
|
13485
13522
|
}
|
|
13486
13523
|
function encodeAskKey(key) {
|
|
13487
13524
|
return JSON.stringify([key.from, key.to]);
|
|
13488
13525
|
}
|
|
13489
13526
|
function pendingAskPath(key) {
|
|
13490
13527
|
const digest = createHash6("sha256").update(encodeAskKey(key)).digest("hex");
|
|
13491
|
-
return
|
|
13528
|
+
return join26(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
|
|
13492
13529
|
}
|
|
13493
13530
|
function v2PendingAskPath(key) {
|
|
13494
13531
|
const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
|
|
13495
|
-
return
|
|
13532
|
+
return join26(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
|
|
13496
13533
|
}
|
|
13497
13534
|
function legacyPendingAskPath(key) {
|
|
13498
13535
|
if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
|
|
13499
13536
|
return null;
|
|
13500
13537
|
}
|
|
13501
13538
|
const dir = pendingAskDir(key.userId);
|
|
13502
|
-
const candidate =
|
|
13539
|
+
const candidate = join26(dir, `${key.from}___${key.to}.pending`);
|
|
13503
13540
|
return dirname14(candidate) === dir ? candidate : null;
|
|
13504
13541
|
}
|
|
13505
13542
|
function parsePendingAskFilename(fileName) {
|
|
@@ -13740,7 +13777,7 @@ function listPendingAsksForCaller(args) {
|
|
|
13740
13777
|
const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
|
|
13741
13778
|
if (!parsed)
|
|
13742
13779
|
continue;
|
|
13743
|
-
const path =
|
|
13780
|
+
const path = join26(dir, fileName);
|
|
13744
13781
|
const record = readPendingAskFile(path, {
|
|
13745
13782
|
userId: args.userId,
|
|
13746
13783
|
from: parsed.from,
|
|
@@ -13782,7 +13819,7 @@ function deletePendingAsksForTopic(args) {
|
|
|
13782
13819
|
}
|
|
13783
13820
|
let deleted = 0;
|
|
13784
13821
|
for (const fileName of files) {
|
|
13785
|
-
const path =
|
|
13822
|
+
const path = join26(dir, fileName);
|
|
13786
13823
|
const parsed = parsePendingAskFilename(fileName);
|
|
13787
13824
|
const record = readPendingAskFile(path, {
|
|
13788
13825
|
userId: args.userId,
|
|
@@ -14182,7 +14219,7 @@ body{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:var(--
|
|
|
14182
14219
|
// ../../packages/core/src/storage/token-stats.ts
|
|
14183
14220
|
import { createHash as createHash7 } from "crypto";
|
|
14184
14221
|
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync14 } from "fs";
|
|
14185
|
-
import { join as
|
|
14222
|
+
import { join as join27 } from "path";
|
|
14186
14223
|
function tokenStatsFileId(userId) {
|
|
14187
14224
|
const rawUserId = String(userId);
|
|
14188
14225
|
return /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash7("sha256").update(rawUserId).digest("hex")}`;
|
|
@@ -14191,7 +14228,7 @@ function queriesPath(userId) {
|
|
|
14191
14228
|
const fileId = tokenStatsFileId(userId);
|
|
14192
14229
|
const logDir = resolveStorageLogDir();
|
|
14193
14230
|
mkdirSync16(logDir, { recursive: true });
|
|
14194
|
-
return
|
|
14231
|
+
return join27(logDir, `token-queries-${fileId}.jsonl`);
|
|
14195
14232
|
}
|
|
14196
14233
|
function estimateUsageCost(agent, model, usage) {
|
|
14197
14234
|
const prices = TOKEN_PRICES[`${agent}:${model}`];
|
|
@@ -14507,7 +14544,7 @@ var init_lifecycle = __esm(async () => {
|
|
|
14507
14544
|
// ../../packages/core/src/runtime/attachments.ts
|
|
14508
14545
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
14509
14546
|
import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
14510
|
-
import { basename as basename5, join as
|
|
14547
|
+
import { basename as basename5, join as join28 } from "path";
|
|
14511
14548
|
function workspaceCwdFor(topicId) {
|
|
14512
14549
|
return resolveTopicWorkspaceDir(topicId);
|
|
14513
14550
|
}
|
|
@@ -14520,7 +14557,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
14520
14557
|
if (!attachmentIds?.length)
|
|
14521
14558
|
return [];
|
|
14522
14559
|
const out = [];
|
|
14523
|
-
const destDir =
|
|
14560
|
+
const destDir = join28(workspaceCwdFor(topicId), "attachments", queryId);
|
|
14524
14561
|
for (const rawId of attachmentIds) {
|
|
14525
14562
|
if (typeof rawId !== "string")
|
|
14526
14563
|
continue;
|
|
@@ -14537,7 +14574,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
14537
14574
|
mkdirSync17(destDir, { recursive: true });
|
|
14538
14575
|
const index = String(out.length + 1).padStart(2, "0");
|
|
14539
14576
|
const safeName = safeAttachmentFilename(attachment.filename, fileId);
|
|
14540
|
-
const destPath =
|
|
14577
|
+
const destPath = join28(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
|
|
14541
14578
|
copyFileSync2(sourcePath, destPath);
|
|
14542
14579
|
out.push({
|
|
14543
14580
|
id: attachment.id,
|
|
@@ -14567,10 +14604,10 @@ function promptWithAttachments(prompt, attachments) {
|
|
|
14567
14604
|
return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
|
|
14568
14605
|
}
|
|
14569
14606
|
function ingestAttachment(args) {
|
|
14570
|
-
const destDir =
|
|
14607
|
+
const destDir = join28(UPLOADS_DIR, args.topicId);
|
|
14571
14608
|
mkdirSync17(destDir, { recursive: true });
|
|
14572
14609
|
const safeName = safeAttachmentFilename(args.filename, "upload");
|
|
14573
|
-
const destPath =
|
|
14610
|
+
const destPath = join28(destDir, `${Date.now()}-${randomUUID14().slice(0, 8)}-${safeName}`);
|
|
14574
14611
|
if (args.sourcePath !== undefined) {
|
|
14575
14612
|
copyFileSync2(args.sourcePath, destPath);
|
|
14576
14613
|
} else if (args.bytes !== undefined) {
|
|
@@ -15859,9 +15896,9 @@ var init_turn_session = __esm(async () => {
|
|
|
15859
15896
|
|
|
15860
15897
|
// ../../packages/core/src/storage/app-settings.ts
|
|
15861
15898
|
import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
15862
|
-
import { dirname as dirname15, join as
|
|
15899
|
+
import { dirname as dirname15, join as join29 } from "path";
|
|
15863
15900
|
function settingsFile() {
|
|
15864
|
-
return
|
|
15901
|
+
return join29(resolveStorageDataDir(), "otium-settings.json");
|
|
15865
15902
|
}
|
|
15866
15903
|
function getGlobalAiName() {
|
|
15867
15904
|
const path = settingsFile();
|
|
@@ -15956,7 +15993,7 @@ __export(exports_turn_runner, {
|
|
|
15956
15993
|
});
|
|
15957
15994
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
15958
15995
|
import { existsSync as existsSync20, mkdirSync as mkdirSync19, readdirSync as readdirSync5, statSync as statSync10 } from "fs";
|
|
15959
|
-
import { join as
|
|
15996
|
+
import { join as join30 } from "path";
|
|
15960
15997
|
function withDefaultPlaywright(configuredMcp, isManager) {
|
|
15961
15998
|
if (isManager)
|
|
15962
15999
|
return configuredMcp;
|
|
@@ -16011,7 +16048,7 @@ function appendAskReplyMessage(topicId, text2, agentType) {
|
|
|
16011
16048
|
return message;
|
|
16012
16049
|
}
|
|
16013
16050
|
function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
|
|
16014
|
-
const preferred =
|
|
16051
|
+
const preferred = join30(directory, preferredFilename);
|
|
16015
16052
|
if (preferExact && existsSync20(preferred))
|
|
16016
16053
|
return preferred;
|
|
16017
16054
|
let newestLegacyId = null;
|
|
@@ -16022,7 +16059,7 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
16022
16059
|
const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
|
|
16023
16060
|
if (!titleMatch && !legacyIdMatch)
|
|
16024
16061
|
continue;
|
|
16025
|
-
const path =
|
|
16062
|
+
const path = join30(directory, filename);
|
|
16026
16063
|
const mtimeMs = statSync10(path).mtimeMs;
|
|
16027
16064
|
if (titleMatch) {
|
|
16028
16065
|
if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
|
|
@@ -16036,9 +16073,9 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
16036
16073
|
return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
|
|
16037
16074
|
}
|
|
16038
16075
|
function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
|
|
16039
|
-
const briefFile = resolveWikiMirrorPath(
|
|
16076
|
+
const briefFile = resolveWikiMirrorPath(join30(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
|
|
16040
16077
|
const hasBriefFile = existsSync20(briefFile) && statSync10(briefFile).isFile();
|
|
16041
|
-
const latestSummaryCandidate = resolveWikiMirrorPath(
|
|
16078
|
+
const latestSummaryCandidate = resolveWikiMirrorPath(join30(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
|
|
16042
16079
|
const latestSummaryFile = existsSync20(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
|
|
16043
16080
|
return { briefFile, hasBriefFile, latestSummaryFile };
|
|
16044
16081
|
}
|
|
@@ -19130,4 +19167,4 @@ export {
|
|
|
19130
19167
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
19131
19168
|
};
|
|
19132
19169
|
|
|
19133
|
-
//# debugId=
|
|
19170
|
+
//# debugId=D944C86CF6E691B664756E2164756E21
|