negotium 0.4.1 → 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.
@@ -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 homedir2 } from "os";
1454
- import { dirname as dirname2, join as join2, resolve as resolve3 } from "path";
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", join2(homedir2(), ".negotium"));
1516
+ return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
1483
1517
  }
1484
1518
  function defaultDataDir() {
1485
- return envPath("NEGOTIUM_DATA_DIR", join2(defaultStateDir(), "data"));
1519
+ return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
1486
1520
  }
1487
1521
  function defaultLogDir() {
1488
- return envPath("NEGOTIUM_LOG_DIR", join2(defaultStateDir(), "logs"));
1522
+ return envPath("NEGOTIUM_LOG_DIR", join3(defaultStateDir(), "logs"));
1489
1523
  }
1490
1524
  function defaultWorkspaceDir() {
1491
- return envPath("NEGOTIUM_WORKSPACE_DIR", join2(defaultStateDir(), "workspace"));
1525
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join3(defaultStateDir(), "workspace"));
1492
1526
  }
1493
1527
  function defaultSessionAsksDir() {
1494
- const runDir = envPath("NEGOTIUM_RUN_DIR", join2(defaultStateDir(), "runtime"));
1495
- return join2(runDir, "session-asks");
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", join2(resolveStorageDataDir(), "sessions.db"));
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 ?? join2(resolveStorageWorkspaceDir(), "wiki");
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 join3 } from "path";
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 = join3(dataDir, "vault");
1701
- const path = join3(vaultDir, "vault.db");
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 homedir3 } from "os";
2209
- import { join as join4 } from "path";
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(join4(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
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 = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
2315
- const path = join4(projectsDir, `${sessionId}.jsonl`);
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 homedir4 } from "os";
2330
- import { join as join5 } from "path";
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 = join5(homedir4(), ".claude", "projects");
2378
- const destDir = join5(projectsRoot, encodeClaudeCwd(cwd));
2379
- const destPath = join5(destDir, `${result.sessionId}.jsonl`);
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) => join5(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync3(p));
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 = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(cwd));
2428
+ const projectsDir = join6(homedir5(), ".claude", "projects", encodeClaudeCwd(cwd));
2395
2429
  const failures = [];
2396
2430
  for (const sid of sessionIds) {
2397
- const path = join5(projectsDir, `${sid}.jsonl`);
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.1";
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 join6 } from "path";
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 join6(dirname5(bundledCodexPackagePath), "bin", "codex.js");
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 join6(dirname5(authFilePath), NEGOTIUM_MODEL_CACHE);
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(join6(tmpdir(), "negotium-codex-models-"));
2570
- const isolatedCachePath = join6(isolatedHome, "models_cache.json");
2603
+ const isolatedHome = mkdtempSync(join7(tmpdir(), "negotium-codex-models-"));
2604
+ const isolatedCachePath = join7(isolatedHome, "models_cache.json");
2571
2605
  try {
2572
- const isolatedAuthPath = join6(isolatedHome, "auth.json");
2606
+ const isolatedAuthPath = join7(isolatedHome, "auth.json");
2573
2607
  copyFileSync(authFilePath, isolatedAuthPath);
2574
2608
  chmodSync3(isolatedAuthPath, 384);
2575
- const sourceConfigPath = join6(sourceHome, "config.toml");
2609
+ const sourceConfigPath = join7(sourceHome, "config.toml");
2576
2610
  if (existsSync4(sourceConfigPath)) {
2577
- const isolatedConfigPath = join6(isolatedHome, "config.toml");
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 = join6(codexHome, "models_cache.json");
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 = join6(codexHome, NEGOTIUM_MODEL_CATALOG);
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 join7, resolve as resolve5 } from "path";
2680
+ import { basename, dirname as dirname6, join as join8, resolve as resolve5 } from "path";
2647
2681
  function codexSessionsDir() {
2648
- return join7(hostedCodexHomePath(), "sessions");
2682
+ return join8(hostedCodexHomePath(), "sessions");
2649
2683
  }
2650
2684
  function loadCodexShell() {
2651
2685
  if (_shellCache)
2652
2686
  return _shellCache;
2653
- const raw = readFileSync5(join7(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
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 = join7(codexSessionsDir(), yyyy, mm, dd);
2721
- return join7(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
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 join7(realpathSync2(dirname6(absolute)), basename(absolute));
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 = join7(sessionsDir, bucket);
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(join7(dir, rel));
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(join7(sessionsDir, rel));
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 = join7(sessionsDir, bucket);
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 = join7(dir, rel);
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 = join7(sessionsDir, rel);
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 join8 } from "path";
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 = join8(hostedCodexHomePath(), "sessions");
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 = join8(sessionsDir, rel);
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 homedir5 } from "os";
3371
- import { join as join9, resolve as resolve6 } from "path";
3404
+ import { homedir as homedir6 } from "os";
3405
+ import { join as join10, resolve as resolve6 } from "path";
3372
3406
  function maestroSessionsDir() {
3373
- return join9(process.env.MAESTRO_DATA_DIR ? resolve6(process.env.MAESTRO_DATA_DIR) : join9(homedir5(), ".maestro"), "sessions");
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 join9(maestroSessionsDir(), `${sessionId}.jsonl`);
3410
+ return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
3377
3411
  }
3378
3412
  function maestroActiveSessionPath(sessionId) {
3379
- return join9(maestroSessionsDir(), `${sessionId}.active.jsonl`);
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 join10 } from "path";
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 join10(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
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 join11 } from "path";
3677
+ import { dirname as dirname8, join as join12 } from "path";
3644
3678
  function conversationDir(_userId) {
3645
- return join11(resolveStorageDataDir(), "conversations");
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 join11(conversationDir(userId), topicFilename(topicName));
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 join12, resolve as resolve7 } from "path";
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)) {
@@ -4636,10 +4670,10 @@ function privateCodexWrapper(codexScript, socketPath, token) {
4636
4670
  `);
4637
4671
  }
4638
4672
  async function createCodexVaultHookBridge(userId) {
4639
- const root = await mkdtemp(join12(tmpdir2(), "negotium-codex-vault-"));
4673
+ const root = await mkdtemp(join13(tmpdir2(), "negotium-codex-vault-"));
4640
4674
  await chmod(root, 448);
4641
- const socketPath = join12(root, "hook.sock");
4642
- const wrapperPath = join12(root, "codex-with-hooks");
4675
+ const socketPath = join13(root, "hook.sock");
4676
+ const wrapperPath = join13(root, "codex-with-hooks");
4643
4677
  const token = randomBytes5(32).toString("hex");
4644
4678
  const connections = new Set;
4645
4679
  const server = createServer((socket) => {
@@ -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 homedir6 } from "os";
5260
- import { dirname as dirname10, isAbsolute as isAbsolute2, join as join13, relative, resolve as resolve9 } from "path";
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 = join13(dirname10(authFilePath), "config.toml");
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 || join13(homedir6(), ".codex");
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,
@@ -6102,8 +6136,8 @@ var init_maestro_provider = __esm(async () => {
6102
6136
 
6103
6137
  // ../../packages/core/src/agents/index.ts
6104
6138
  import { existsSync as existsSync13 } from "fs";
6105
- import { homedir as homedir7 } from "os";
6106
- import { join as join14 } from "path";
6139
+ import { homedir as homedir8 } from "os";
6140
+ import { join as join15 } from "path";
6107
6141
  async function* dispatchAgent(opts) {
6108
6142
  switch (opts.agent) {
6109
6143
  case "claude": {
@@ -6137,11 +6171,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
6137
6171
  switch (agent) {
6138
6172
  case "claude": {
6139
6173
  const encodedCwd = encodeClaudeCwd(cwd);
6140
- const path = join14(homedir7(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
6174
+ const path = join15(homedir8(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
6141
6175
  return !existsSync13(path);
6142
6176
  }
6143
6177
  case "codex": {
6144
- const sessionsDir = join14(hostedCodexHomePath(), "sessions");
6178
+ const sessionsDir = join15(hostedCodexHomePath(), "sessions");
6145
6179
  const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
6146
6180
  for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
6147
6181
  return false;
@@ -7396,9 +7430,9 @@ var init_api_topic_brief = __esm(async () => {
7396
7430
  });
7397
7431
 
7398
7432
  // ../../packages/core/src/storage/wiki.ts
7399
- import { basename as basename2, dirname as dirname11, join as join15 } from "path";
7433
+ import { basename as basename2, dirname as dirname11, join as join16 } from "path";
7400
7434
  function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
7401
- return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join15(workspaceDir, "wiki");
7435
+ return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join16(workspaceDir, "wiki");
7402
7436
  }
7403
7437
  var init_wiki = __esm(async () => {
7404
7438
  await init_storage_host();
@@ -8233,7 +8267,7 @@ var init_personal_general = __esm(async () => {
8233
8267
  // ../../packages/core/src/agents/archiver.ts
8234
8268
  import { randomUUID as randomUUID6 } from "crypto";
8235
8269
  import { existsSync as existsSync14, readdirSync as readdirSync2, readFileSync as readFileSync13, statSync as statSync6 } from "fs";
8236
- import { join as join16 } from "path";
8270
+ import { join as join17 } from "path";
8237
8271
  function resolveMemoryLanguage() {
8238
8272
  const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
8239
8273
  return override && override.length > 0 ? override : resolveOutputLanguage();
@@ -8484,10 +8518,10 @@ function distillOneLine(summaryMd) {
8484
8518
  return "";
8485
8519
  }
8486
8520
  function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
8487
- const dir = join16(storage.getWikiDir(), "summaries");
8521
+ const dir = join17(storage.getWikiDir(), "summaries");
8488
8522
  if (!storage.fileExists(dir))
8489
8523
  return null;
8490
- const predicted = join16(dir, wikiSummaryFilename(date, topicTitle, topicId));
8524
+ const predicted = join17(dir, wikiSummaryFilename(date, topicTitle, topicId));
8491
8525
  if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
8492
8526
  return predicted;
8493
8527
  let best = null;
@@ -8495,7 +8529,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
8495
8529
  if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
8496
8530
  continue;
8497
8531
  }
8498
- const p = join16(dir, f);
8532
+ const p = join17(dir, f);
8499
8533
  try {
8500
8534
  const m = storage.fileModifiedAt(p);
8501
8535
  if (m >= sinceMs && (!best || m > best.mtime))
@@ -8622,8 +8656,8 @@ __export(exports_auth_check, {
8622
8656
  });
8623
8657
  import { execFileSync as execFileSync5 } from "child_process";
8624
8658
  import { existsSync as existsSync15 } from "fs";
8625
- import { homedir as homedir8, platform } from "os";
8626
- import { join as join17 } from "path";
8659
+ import { homedir as homedir9, platform } from "os";
8660
+ import { join as join18 } from "path";
8627
8661
  function hasMaestroCredential(host, key, userId) {
8628
8662
  if (userId && host.getVaultValue(userId, key)?.trim())
8629
8663
  return true;
@@ -8643,7 +8677,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
8643
8677
  case "claude": {
8644
8678
  if (host.environment.ANTHROPIC_API_KEY)
8645
8679
  return { ok: true };
8646
- const path = join17(host.homeDirectory(), ".claude", ".credentials.json");
8680
+ const path = join18(host.homeDirectory(), ".claude", ".credentials.json");
8647
8681
  if (host.operatingSystem() === "darwin") {
8648
8682
  if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
8649
8683
  return { ok: true };
@@ -8696,7 +8730,7 @@ var init_auth_check = __esm(async () => {
8696
8730
  codexAuthFilePath,
8697
8731
  exists: existsSync15,
8698
8732
  environment: process.env,
8699
- homeDirectory: homedir8,
8733
+ homeDirectory: homedir9,
8700
8734
  operatingSystem: platform,
8701
8735
  hasMacOsCredential(service) {
8702
8736
  try {
@@ -9404,13 +9438,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
9404
9438
 
9405
9439
  // ../../packages/core/src/storage/topic-archive.ts
9406
9440
  import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8 } from "fs";
9407
- import { join as join18 } from "path";
9441
+ import { join as join19 } from "path";
9408
9442
  function archiveTopicMessages(topicId, topicTitle, options = {}) {
9409
9443
  const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
9410
9444
  if (rows.length === 0)
9411
9445
  return null;
9412
9446
  const safeTopic = sanitizeTopicName(topicTitle, true);
9413
- const archiveDir = join18(getSharedWikiDir(), "archive");
9447
+ const archiveDir = join19(getSharedWikiDir(), "archive");
9414
9448
  mkdirSync10(archiveDir, { recursive: true });
9415
9449
  const date = new Date().toISOString().slice(0, 10);
9416
9450
  const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
@@ -9423,7 +9457,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
9423
9457
  let path;
9424
9458
  while (true) {
9425
9459
  filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
9426
- path = join18(archiveDir, filename);
9460
+ path = join19(archiveDir, filename);
9427
9461
  try {
9428
9462
  writeFileSync8(path, body, { flag: "wx" });
9429
9463
  break;
@@ -9468,7 +9502,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
9468
9502
  const entries = readRawConversation(userId, topicTitle);
9469
9503
  if (entries.length === 0)
9470
9504
  return null;
9471
- const archiveDir = join18(getSharedWikiDir(), "archive");
9505
+ const archiveDir = join19(getSharedWikiDir(), "archive");
9472
9506
  mkdirSync10(archiveDir, { recursive: true });
9473
9507
  const safeTopic = sanitizeTopicName(topicTitle, true);
9474
9508
  const date = new Date().toISOString().slice(0, 10);
@@ -9496,7 +9530,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
9496
9530
  let counter = 1;
9497
9531
  while (true) {
9498
9532
  const suffix = counter === 1 ? "" : `_${counter}`;
9499
- const path = join18(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
9533
+ const path = join19(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
9500
9534
  try {
9501
9535
  writeFileSync8(path, body, { flag: "wx" });
9502
9536
  logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
@@ -10829,13 +10863,13 @@ var init_browser_processes = __esm(async () => {
10829
10863
  });
10830
10864
 
10831
10865
  // ../../packages/core/src/platform/playwright/headed-launch.ts
10832
- import { accessSync as accessSync2, constants as constants2 } from "fs";
10866
+ import { accessSync as accessSync3, constants as constants2 } from "fs";
10833
10867
  import { delimiter, isAbsolute as isAbsolute4, resolve as resolve14 } from "path";
10834
10868
  function findExecutableOnPath(command, environment = process.env) {
10835
10869
  const candidates = isAbsolute4(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve14(directory, command));
10836
10870
  for (const candidate of candidates) {
10837
10871
  try {
10838
- accessSync2(candidate, constants2.X_OK);
10872
+ accessSync3(candidate, constants2.X_OK);
10839
10873
  return candidate;
10840
10874
  } catch {}
10841
10875
  }
@@ -10934,7 +10968,7 @@ import { randomBytes as randomBytes6, timingSafeEqual as timingSafeEqual2 } from
10934
10968
  import { chmodSync as chmodSync4 } from "fs";
10935
10969
  import { createServer as createServer3 } from "net";
10936
10970
  import { tmpdir as tmpdir3 } from "os";
10937
- import { join as join19 } from "path";
10971
+ import { join as join20 } from "path";
10938
10972
  function deepMapStrings2(value, transform) {
10939
10973
  if (typeof value === "string")
10940
10974
  return transform(value);
@@ -11021,7 +11055,7 @@ function authorized(actual, expected) {
11021
11055
  }
11022
11056
  async function createBrowserVaultBroker(userId) {
11023
11057
  const token = randomBytes6(32).toString("hex");
11024
- const socketPath = join19(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`);
11058
+ const socketPath = join20(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`);
11025
11059
  const retainedForms = new Map;
11026
11060
  const leases = new Map;
11027
11061
  const sockets = new Set;
@@ -11230,7 +11264,7 @@ import {
11230
11264
  unlinkSync as unlinkSync11,
11231
11265
  writeFileSync as writeFileSync9
11232
11266
  } from "fs";
11233
- import { dirname as dirname12, join as join20, resolve as resolve15 } from "path";
11267
+ import { dirname as dirname12, join as join21, resolve as resolve15 } from "path";
11234
11268
  function removeDefaultProfileDataDir(userDataDir) {
11235
11269
  const root = resolve15(BROWSER_PROFILES_DIR);
11236
11270
  const target = resolve15(userDataDir);
@@ -11320,14 +11354,14 @@ function portFileName(instanceKey) {
11320
11354
  function writePortFile(instanceKey, port) {
11321
11355
  try {
11322
11356
  mkdirSync11(managerHost.portsDir, { recursive: true });
11323
- writeFileSync9(join20(managerHost.portsDir, portFileName(instanceKey)), String(port));
11357
+ writeFileSync9(join21(managerHost.portsDir, portFileName(instanceKey)), String(port));
11324
11358
  } catch (e) {
11325
11359
  logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
11326
11360
  }
11327
11361
  }
11328
11362
  function deletePortFile(instanceKey) {
11329
11363
  try {
11330
- unlinkSync11(join20(managerHost.portsDir, portFileName(instanceKey)));
11364
+ unlinkSync11(join21(managerHost.portsDir, portFileName(instanceKey)));
11331
11365
  } catch (e) {
11332
11366
  if (e.code === "ENOENT")
11333
11367
  return;
@@ -12486,7 +12520,7 @@ var init_runtime_turn_requests = __esm(async () => {
12486
12520
  import { randomUUID as randomUUID11 } from "crypto";
12487
12521
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "fs";
12488
12522
  import { tmpdir as tmpdir4 } from "os";
12489
- import { join as join21 } from "path";
12523
+ import { join as join22 } from "path";
12490
12524
  function previousCompactedSummary(entries) {
12491
12525
  for (let index = entries.length - 2;index >= 0; index -= 1) {
12492
12526
  const request = entries[index]?.event;
@@ -12616,7 +12650,7 @@ function formatCompactElapsed(startedAt) {
12616
12650
  async function summarizeTopicContext(request) {
12617
12651
  const startedAt = Date.now();
12618
12652
  const sessionIds = [];
12619
- const compactCwd = mkdtempSync2(join21(tmpdir4(), "negotium-compact-"));
12653
+ const compactCwd = mkdtempSync2(join22(tmpdir4(), "negotium-compact-"));
12620
12654
  const abortController = new AbortController;
12621
12655
  const relayAbort = () => abortController.abort(request.signal?.reason);
12622
12656
  if (request.signal?.aborted)
@@ -12643,7 +12677,7 @@ async function summarizeTopicContext(request) {
12643
12677
  let error = "";
12644
12678
  let toolViolation = false;
12645
12679
  let compactionLogCalls = 0;
12646
- const compactionLogPath = join21(compactCwd, "conversation.log");
12680
+ const compactionLogPath = join22(compactCwd, "conversation.log");
12647
12681
  try {
12648
12682
  const compactionMcp = useCompactionLog ? {
12649
12683
  compact_log: {
@@ -13262,14 +13296,14 @@ var init_derive = __esm(async () => {
13262
13296
  });
13263
13297
 
13264
13298
  // ../../packages/core/src/query/session-inbox-path.ts
13265
- import { join as join22 } from "path";
13299
+ import { join as join23 } from "path";
13266
13300
  function sessionInboxPath(userId, topicId) {
13267
13301
  const key = Buffer.from(topicId, "utf8").toString("base64url");
13268
- return join22(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
13302
+ return join23(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
13269
13303
  }
13270
13304
  function scheduledSessionInboxPath(userId, topicId) {
13271
13305
  const key = Buffer.from(topicId, "utf8").toString("base64url");
13272
- return join22(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
13306
+ return join23(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
13273
13307
  }
13274
13308
  var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
13275
13309
  var init_session_inbox_path = __esm(() => {
@@ -13278,13 +13312,13 @@ var init_session_inbox_path = __esm(() => {
13278
13312
 
13279
13313
  // ../../packages/core/src/query/session-inbox-cleanup.ts
13280
13314
  import { unlinkSync as unlinkSync14 } from "fs";
13281
- import { basename as basename3, join as join23 } from "path";
13315
+ import { basename as basename3, join as join24 } from "path";
13282
13316
  function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
13283
13317
  const live = sessionInboxPath(userId, topicId);
13284
13318
  const scheduled = scheduledSessionInboxPath(userId, topicId);
13285
13319
  const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
13286
13320
  if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename3(legacyTopicTitle) === legacyTopicTitle) {
13287
- const legacyBase = join23(SESSION_INBOX_DIR, userId, legacyTopicTitle);
13321
+ const legacyBase = join24(SESSION_INBOX_DIR, userId, legacyTopicTitle);
13288
13322
  for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
13289
13323
  candidates.add(`${legacyBase}${suffix}`);
13290
13324
  }
@@ -13310,16 +13344,16 @@ var init_session_inbox_cleanup = __esm(() => {
13310
13344
 
13311
13345
  // ../../packages/core/src/query/state.ts
13312
13346
  import { mkdirSync as mkdirSync14, renameSync as renameSync7, unlinkSync as unlinkSync15, writeFileSync as writeFileSync12 } from "fs";
13313
- import { basename as basename4, join as join24 } from "path";
13347
+ import { basename as basename4, join as join25 } from "path";
13314
13348
  function createQueryStateStore(options) {
13315
13349
  const sanitize = options.sanitizeTopicId ?? sanitizeId;
13316
- const queryStateDirPath = (userId) => join24(options.usersLogDir, String(userId), "active-queries");
13317
- const queryStateFile = (userId, topicId) => join24(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
13350
+ const queryStateDirPath = (userId) => join25(options.usersLogDir, String(userId), "active-queries");
13351
+ const queryStateFile = (userId, topicId) => join25(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
13318
13352
  const legacyQueryStateFile = (userId, topicName) => {
13319
13353
  if (!topicName || topicName === "." || topicName === ".." || basename4(topicName) !== topicName) {
13320
13354
  return null;
13321
13355
  }
13322
- return join24(queryStateDirPath(userId), `${topicName}.json`);
13356
+ return join25(queryStateDirPath(userId), `${topicName}.json`);
13323
13357
  };
13324
13358
  return {
13325
13359
  write(userId, topicId, topicName, task) {
@@ -13480,29 +13514,29 @@ import {
13480
13514
  unlinkSync as unlinkSync16,
13481
13515
  writeFileSync as writeFileSync13
13482
13516
  } from "fs";
13483
- import { dirname as dirname14, join as join25 } from "path";
13517
+ import { dirname as dirname14, join as join26 } from "path";
13484
13518
  function pendingAskDir(userId) {
13485
13519
  const rawUserId = String(userId);
13486
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")}`;
13487
- return join25(resolveStorageSessionAsksDir(), safeUserId);
13521
+ return join26(resolveStorageSessionAsksDir(), safeUserId);
13488
13522
  }
13489
13523
  function encodeAskKey(key) {
13490
13524
  return JSON.stringify([key.from, key.to]);
13491
13525
  }
13492
13526
  function pendingAskPath(key) {
13493
13527
  const digest = createHash6("sha256").update(encodeAskKey(key)).digest("hex");
13494
- return join25(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
13528
+ return join26(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
13495
13529
  }
13496
13530
  function v2PendingAskPath(key) {
13497
13531
  const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
13498
- return join25(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
13532
+ return join26(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
13499
13533
  }
13500
13534
  function legacyPendingAskPath(key) {
13501
13535
  if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
13502
13536
  return null;
13503
13537
  }
13504
13538
  const dir = pendingAskDir(key.userId);
13505
- const candidate = join25(dir, `${key.from}___${key.to}.pending`);
13539
+ const candidate = join26(dir, `${key.from}___${key.to}.pending`);
13506
13540
  return dirname14(candidate) === dir ? candidate : null;
13507
13541
  }
13508
13542
  function parsePendingAskFilename(fileName) {
@@ -13743,7 +13777,7 @@ function listPendingAsksForCaller(args) {
13743
13777
  const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
13744
13778
  if (!parsed)
13745
13779
  continue;
13746
- const path = join25(dir, fileName);
13780
+ const path = join26(dir, fileName);
13747
13781
  const record = readPendingAskFile(path, {
13748
13782
  userId: args.userId,
13749
13783
  from: parsed.from,
@@ -13785,7 +13819,7 @@ function deletePendingAsksForTopic(args) {
13785
13819
  }
13786
13820
  let deleted = 0;
13787
13821
  for (const fileName of files) {
13788
- const path = join25(dir, fileName);
13822
+ const path = join26(dir, fileName);
13789
13823
  const parsed = parsePendingAskFilename(fileName);
13790
13824
  const record = readPendingAskFile(path, {
13791
13825
  userId: args.userId,
@@ -14185,7 +14219,7 @@ body{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:var(--
14185
14219
  // ../../packages/core/src/storage/token-stats.ts
14186
14220
  import { createHash as createHash7 } from "crypto";
14187
14221
  import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync14 } from "fs";
14188
- import { join as join26 } from "path";
14222
+ import { join as join27 } from "path";
14189
14223
  function tokenStatsFileId(userId) {
14190
14224
  const rawUserId = String(userId);
14191
14225
  return /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash7("sha256").update(rawUserId).digest("hex")}`;
@@ -14194,7 +14228,7 @@ function queriesPath(userId) {
14194
14228
  const fileId = tokenStatsFileId(userId);
14195
14229
  const logDir = resolveStorageLogDir();
14196
14230
  mkdirSync16(logDir, { recursive: true });
14197
- return join26(logDir, `token-queries-${fileId}.jsonl`);
14231
+ return join27(logDir, `token-queries-${fileId}.jsonl`);
14198
14232
  }
14199
14233
  function estimateUsageCost(agent, model, usage) {
14200
14234
  const prices = TOKEN_PRICES[`${agent}:${model}`];
@@ -14510,7 +14544,7 @@ var init_lifecycle = __esm(async () => {
14510
14544
  // ../../packages/core/src/runtime/attachments.ts
14511
14545
  import { randomUUID as randomUUID14 } from "crypto";
14512
14546
  import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
14513
- import { basename as basename5, join as join27 } from "path";
14547
+ import { basename as basename5, join as join28 } from "path";
14514
14548
  function workspaceCwdFor(topicId) {
14515
14549
  return resolveTopicWorkspaceDir(topicId);
14516
14550
  }
@@ -14523,7 +14557,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
14523
14557
  if (!attachmentIds?.length)
14524
14558
  return [];
14525
14559
  const out = [];
14526
- const destDir = join27(workspaceCwdFor(topicId), "attachments", queryId);
14560
+ const destDir = join28(workspaceCwdFor(topicId), "attachments", queryId);
14527
14561
  for (const rawId of attachmentIds) {
14528
14562
  if (typeof rawId !== "string")
14529
14563
  continue;
@@ -14540,7 +14574,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
14540
14574
  mkdirSync17(destDir, { recursive: true });
14541
14575
  const index = String(out.length + 1).padStart(2, "0");
14542
14576
  const safeName = safeAttachmentFilename(attachment.filename, fileId);
14543
- const destPath = join27(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
14577
+ const destPath = join28(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
14544
14578
  copyFileSync2(sourcePath, destPath);
14545
14579
  out.push({
14546
14580
  id: attachment.id,
@@ -14570,10 +14604,10 @@ function promptWithAttachments(prompt, attachments) {
14570
14604
  return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
14571
14605
  }
14572
14606
  function ingestAttachment(args) {
14573
- const destDir = join27(UPLOADS_DIR, args.topicId);
14607
+ const destDir = join28(UPLOADS_DIR, args.topicId);
14574
14608
  mkdirSync17(destDir, { recursive: true });
14575
14609
  const safeName = safeAttachmentFilename(args.filename, "upload");
14576
- const destPath = join27(destDir, `${Date.now()}-${randomUUID14().slice(0, 8)}-${safeName}`);
14610
+ const destPath = join28(destDir, `${Date.now()}-${randomUUID14().slice(0, 8)}-${safeName}`);
14577
14611
  if (args.sourcePath !== undefined) {
14578
14612
  copyFileSync2(args.sourcePath, destPath);
14579
14613
  } else if (args.bytes !== undefined) {
@@ -15862,9 +15896,9 @@ var init_turn_session = __esm(async () => {
15862
15896
 
15863
15897
  // ../../packages/core/src/storage/app-settings.ts
15864
15898
  import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
15865
- import { dirname as dirname15, join as join28 } from "path";
15899
+ import { dirname as dirname15, join as join29 } from "path";
15866
15900
  function settingsFile() {
15867
- return join28(resolveStorageDataDir(), "otium-settings.json");
15901
+ return join29(resolveStorageDataDir(), "otium-settings.json");
15868
15902
  }
15869
15903
  function getGlobalAiName() {
15870
15904
  const path = settingsFile();
@@ -15959,7 +15993,7 @@ __export(exports_turn_runner, {
15959
15993
  });
15960
15994
  import { randomUUID as randomUUID16 } from "crypto";
15961
15995
  import { existsSync as existsSync20, mkdirSync as mkdirSync19, readdirSync as readdirSync5, statSync as statSync10 } from "fs";
15962
- import { join as join29 } from "path";
15996
+ import { join as join30 } from "path";
15963
15997
  function withDefaultPlaywright(configuredMcp, isManager) {
15964
15998
  if (isManager)
15965
15999
  return configuredMcp;
@@ -16014,7 +16048,7 @@ function appendAskReplyMessage(topicId, text2, agentType) {
16014
16048
  return message;
16015
16049
  }
16016
16050
  function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
16017
- const preferred = join29(directory, preferredFilename);
16051
+ const preferred = join30(directory, preferredFilename);
16018
16052
  if (preferExact && existsSync20(preferred))
16019
16053
  return preferred;
16020
16054
  let newestLegacyId = null;
@@ -16025,7 +16059,7 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
16025
16059
  const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
16026
16060
  if (!titleMatch && !legacyIdMatch)
16027
16061
  continue;
16028
- const path = join29(directory, filename);
16062
+ const path = join30(directory, filename);
16029
16063
  const mtimeMs = statSync10(path).mtimeMs;
16030
16064
  if (titleMatch) {
16031
16065
  if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
@@ -16039,9 +16073,9 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
16039
16073
  return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
16040
16074
  }
16041
16075
  function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
16042
- const briefFile = resolveWikiMirrorPath(join29(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
16076
+ const briefFile = resolveWikiMirrorPath(join30(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
16043
16077
  const hasBriefFile = existsSync20(briefFile) && statSync10(briefFile).isFile();
16044
- const latestSummaryCandidate = resolveWikiMirrorPath(join29(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
16078
+ const latestSummaryCandidate = resolveWikiMirrorPath(join30(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
16045
16079
  const latestSummaryFile = existsSync20(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
16046
16080
  return { briefFile, hasBriefFile, latestSummaryFile };
16047
16081
  }
@@ -19133,4 +19167,4 @@ export {
19133
19167
  DEFAULT_SELF_CONFIG_PRODUCT
19134
19168
  };
19135
19169
 
19136
- //# debugId=0CE166A02CA7806164756E2164756E21
19170
+ //# debugId=D944C86CF6E691B664756E2164756E21