@otium-team/negotium 0.23.13 → 0.23.15

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.
Files changed (57) hide show
  1. package/README.md +8 -0
  2. package/dist/agent-helpers.js +321 -198
  3. package/dist/agent-helpers.js.map +16 -15
  4. package/dist/background-bash.js +37 -8
  5. package/dist/background-bash.js.map +5 -4
  6. package/dist/browser-runtime.js +55 -26
  7. package/dist/browser-runtime.js.map +5 -4
  8. package/dist/{chunk-mk9x18jn.js → chunk-3hf8y6bd.js} +3 -3
  9. package/dist/{chunk-mk9x18jn.js.map → chunk-3hf8y6bd.js.map} +2 -2
  10. package/dist/{chunk-22kg3fsw.js → chunk-d1c2wt8q.js} +6 -2
  11. package/dist/{chunk-22kg3fsw.js.map → chunk-d1c2wt8q.js.map} +1 -1
  12. package/dist/{chunk-wf7ny8eq.js → chunk-m1ngkjdd.js} +1 -1
  13. package/dist/{chunk-qd0vtfm2.js → chunk-ng13grfj.js} +69 -37
  14. package/dist/{chunk-qd0vtfm2.js.map → chunk-ng13grfj.js.map} +7 -6
  15. package/dist/{chunk-d4j77adx.js → chunk-pesnv5zv.js} +41 -11
  16. package/dist/chunk-pesnv5zv.js.map +14 -0
  17. package/dist/hosted-agent.js +11 -6
  18. package/dist/hosted-agent.js.map +6 -6
  19. package/dist/main.js +37054 -36798
  20. package/dist/main.js.map +86 -84
  21. package/dist/mcp-factories.js +338 -215
  22. package/dist/mcp-factories.js.map +15 -14
  23. package/dist/media.js +40 -11
  24. package/dist/media.js.map +5 -4
  25. package/dist/prompts.js +69 -10
  26. package/dist/prompts.js.map +7 -6
  27. package/dist/query-runtime.js +42 -13
  28. package/dist/query-runtime.js.map +5 -4
  29. package/dist/registry.js +7 -5
  30. package/dist/registry.js.map +3 -3
  31. package/dist/rollout.js +2 -2
  32. package/dist/runtime/src/agents/claude-registry.ts +2 -1
  33. package/dist/runtime/src/agents/explicit-agent-switch.ts +1 -1
  34. package/dist/runtime/src/agents/mcp-tools/self-config.ts +1 -1
  35. package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +9 -1
  36. package/dist/runtime/src/agents/model-catalog.ts +13 -0
  37. package/dist/runtime/src/platform/browser-backend.ts +73 -0
  38. package/dist/runtime/src/platform/config.ts +3 -0
  39. package/dist/runtime/src/platform/mcp-config.ts +3 -0
  40. package/dist/runtime/src/prompts/builders.ts +11 -2
  41. package/dist/runtime/src/prompts/sessions/_shared-tools.md +2 -0
  42. package/dist/runtime/src/runtime/turn-event-stream.ts +34 -6
  43. package/dist/runtime/src/runtime/turn-runner.ts +59 -2
  44. package/dist/runtime/src/storage/token-stats.ts +4 -0
  45. package/dist/runtime/src/version.ts +1 -1
  46. package/dist/runtime-helpers.js +56 -27
  47. package/dist/runtime-helpers.js.map +5 -4
  48. package/dist/storage.js +3 -1
  49. package/dist/storage.js.map +3 -3
  50. package/dist/types/packages/core/src/platform/browser-backend.d.ts +8 -0
  51. package/dist/types/packages/core/src/platform/config.d.ts +2 -0
  52. package/dist/types/packages/core/src/version.d.ts +1 -1
  53. package/dist/vault.js +45 -16
  54. package/dist/vault.js.map +5 -4
  55. package/package.json +1 -1
  56. package/dist/chunk-d4j77adx.js.map +0 -13
  57. /package/dist/{chunk-wf7ny8eq.js.map → chunk-m1ngkjdd.js.map} +0 -0
@@ -366,6 +366,68 @@ var init_sqlite = __esm(async () => {
366
366
  }
367
367
  });
368
368
 
369
+ // ../../packages/core/src/platform/browser-backend.ts
370
+ import { execFile } from "child_process";
371
+ import { accessSync, constants, statSync } from "fs";
372
+ import { homedir } from "os";
373
+ import { delimiter, isAbsolute, join } from "path";
374
+ import { promisify } from "util";
375
+ function resolveBrowserBackend(value, findEgoBrowser = resolveEgoBrowserBin) {
376
+ const backend = value?.trim();
377
+ if (!backend)
378
+ return findEgoBrowser() ? "egolite" : "chrome";
379
+ if (backend === "chrome" || backend === "egolite")
380
+ return backend;
381
+ throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
382
+ }
383
+ function resolveEgoBrowserBin(path = process.env.PATH ?? "", home = homedir()) {
384
+ const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
385
+ const directories = [...path.split(delimiter).filter(isAbsolute), join(home, ".local", "bin")];
386
+ for (const directory of directories) {
387
+ for (const name of names) {
388
+ const candidate = join(directory, name);
389
+ try {
390
+ accessSync(candidate, constants.X_OK);
391
+ if (statSync(candidate).isFile())
392
+ return candidate;
393
+ } catch {}
394
+ }
395
+ }
396
+ return;
397
+ }
398
+ async function prepareEgoBrowser() {
399
+ const command = resolveEgoBrowserBin();
400
+ if (!command) {
401
+ throw new Error("ego-browser is not installed on this Negotium node or is not executable");
402
+ }
403
+ await promisify(execFile)(command, ["--version"], {
404
+ timeout: 5000,
405
+ maxBuffer: 16384,
406
+ windowsHide: true
407
+ });
408
+ return command;
409
+ }
410
+ var EGO_BROWSER_INSTRUCTIONS = `## Browser
411
+ This node uses ego lite through the official ego-browser CLI, using its existing logged-in browser.
412
+ The Chrome browser_* MCP tools are not registered. Never start browser-rs, point AB_CHROME at ego lite,
413
+ attach to its debugging port, or create a replacement browser/profile.
414
+ Use browser automation only when this turn's runtime reminder authorizes it. If it is unavailable or
415
+ the topic owner check denies access, do not bypass that decision through a shell or another tool.
416
+ When authorized, use the executable supplied by the runtime through your foreground shell tool.
417
+ Before the first browser action in a session, run that executable with "skill" and read its entire
418
+ installed-version guide. Use its "nodejs" command and documented APIs; do not assume Playwright APIs.
419
+ Create one task space for the user goal and retain its spaceId across commands and follow-up turns.
420
+ Use a unique task name tied to this topic and goal; never claim another topic's or a user's space
421
+ without explicit authorization. Existing login state is shared, not the user's other task spaces.
422
+ Stop when the user takes control. Hand off authentication to the user and resume the same task space
423
+ only after confirmation. On successful completion, call finish({ keep: [] }) unless the user needs
424
+ specific result tabs. On interruption, preserve the space for resumption; never kill the browser or
425
+ delete its profile. Do not close a space just because an AI turn ended.
426
+ Verify each action through the guide's observation APIs. Report CLI/browser errors as errors and do
427
+ not silently switch to Chrome. The CLI probe does not prove the browser is connected or authenticated.
428
+ Vault secret injection through browser-rs is not available here; do not copy secrets into scripts or logs.`;
429
+ var init_browser_backend = () => {};
430
+
369
431
  // ../../packages/core/src/platform/config-helpers.ts
370
432
  function readEnvText(env, key) {
371
433
  const value = env[key]?.trim();
@@ -414,17 +476,17 @@ var init_logger = __esm(() => {
414
476
  import { execFileSync } from "child_process";
415
477
  import { randomBytes } from "crypto";
416
478
  import {
417
- accessSync,
479
+ accessSync as accessSync2,
418
480
  chmodSync as chmodSync2,
419
- constants,
481
+ constants as constants2,
420
482
  existsSync as existsSync2,
421
483
  mkdirSync,
422
484
  readFileSync as readFileSync2,
423
485
  writeFileSync
424
486
  } from "fs";
425
487
  import { createRequire } from "module";
426
- import { homedir } from "os";
427
- import { dirname, join, resolve } from "path";
488
+ import { homedir as homedir2 } from "os";
489
+ import { dirname, join as join2, resolve } from "path";
428
490
  import { fileURLToPath, pathToFileURL } from "url";
429
491
  function envText(envKey) {
430
492
  return readEnvText(process.env, envKey);
@@ -510,7 +572,7 @@ function resolveBrowserRsBin(envValue) {
510
572
  }
511
573
  const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
512
574
  try {
513
- accessSync(candidate, constants.X_OK);
575
+ accessSync2(candidate, constants2.X_OK);
514
576
  return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
515
577
  } catch {
516
578
  return;
@@ -520,7 +582,7 @@ function resolveBashRsBin(envValue) {
520
582
  const override = envValue?.trim();
521
583
  const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
522
584
  try {
523
- accessSync(candidate, constants.X_OK);
585
+ accessSync2(candidate, constants2.X_OK);
524
586
  return candidate;
525
587
  } catch {
526
588
  return;
@@ -558,7 +620,7 @@ function safeWorkspaceSegment(value, fallback) {
558
620
  return safeRuntimePathSegment(value, fallback);
559
621
  }
560
622
  function resolveTopicWorkspaceDir(topicId) {
561
- return join(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
623
+ return join2(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
562
624
  }
563
625
  function loadOrCreateLocalSecret(envKey, filename, options = {}) {
564
626
  const envValue = envText(envKey);
@@ -598,14 +660,15 @@ function resolveWhisperBackend() {
598
660
  return envText("WHISPER_BACKEND") === "mlx-whisper" ? "mlx-whisper" : "faster-whisper";
599
661
  }
600
662
  function codexAuthFilePath() {
601
- return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
663
+ return process.env.NEGOTIUM_CODEX_AUTH_FILE || join2(process.env.CODEX_HOME || join2(homedir2(), ".codex"), "auth.json");
602
664
  }
603
- var HOME, PROJECT_ROOT, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BINARY_EXTENSION, BROWSER_RS_VERSION = "v0.7.7", BROWSER_RS_MIN_SECURE_VERSION = "0.2.1", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.10", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER_PATH, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SESSION_HISTORY_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, ABSOLUTE_PATH_PREFIX, FILE_EXTENSIONS_REGEX, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5-5", MODEL_FABLE = "claude-fable-5-1", FALLBACK_AGENT, FALLBACK_MODEL, DEFAULT_TOPIC_EFFORT, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, WHISPER_BACKEND, MLX_WHISPER_BIN, WHISPER_MODEL_MLX, _envMaxTellDepth, MAX_TELL_DEPTH;
665
+ var HOME, PROJECT_ROOT, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_BACKEND, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BINARY_EXTENSION, BROWSER_RS_VERSION = "v0.7.7", BROWSER_RS_MIN_SECURE_VERSION = "0.2.1", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.10", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER_PATH, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SESSION_HISTORY_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, ABSOLUTE_PATH_PREFIX, FILE_EXTENSIONS_REGEX, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5-5", MODEL_FABLE = "claude-fable-5-1", MODEL_FABLE_5_2 = "claude-fable-5-2", FALLBACK_AGENT, FALLBACK_MODEL, DEFAULT_TOPIC_EFFORT, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, WHISPER_BACKEND, MLX_WHISPER_BIN, WHISPER_MODEL_MLX, _envMaxTellDepth, MAX_TELL_DEPTH;
604
666
  var init_config = __esm(() => {
667
+ init_browser_backend();
605
668
  init_config_helpers();
606
669
  init_logger();
607
670
  init_types();
608
- HOME = homedir();
671
+ HOME = homedir2();
609
672
  PROJECT_ROOT = resolveProjectRoot();
610
673
  STATE_DIR = resolveStateDir();
611
674
  WORKSPACE_DIR = resolveLocalStateDir("NEGOTIUM_WORKSPACE_DIR", "workspace");
@@ -613,6 +676,7 @@ var init_config = __esm(() => {
613
676
  SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
614
677
  CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
615
678
  BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
679
+ BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
616
680
  BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
617
681
  BINARIES_DIR = resolve(STATE_DIR, "binaries");
618
682
  SECRETS_DIR = resolve(STATE_DIR, "secrets");
@@ -754,7 +818,7 @@ var init_wiki_summary_names = __esm(() => {
754
818
 
755
819
  // ../../packages/core/src/platform/paths.ts
756
820
  import { existsSync as existsSync4, realpathSync } from "fs";
757
- import { dirname as dirname3, isAbsolute, relative as relative2, resolve as resolve3, sep } from "path";
821
+ import { dirname as dirname3, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3, sep } from "path";
758
822
  function normalizeExistingOrResolved(filePath) {
759
823
  const resolved = resolve3(filePath);
760
824
  try {
@@ -778,7 +842,7 @@ function isInsideDir(childPath, parentDir) {
778
842
  const parent = normalizeExistingOrResolved(parentDir);
779
843
  const child = normalizeExistingOrResolved(childPath);
780
844
  const rel = relative2(parent, child);
781
- return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute(rel);
845
+ return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute2(rel);
782
846
  }
783
847
  function toDisplayPath(filePath) {
784
848
  return filePath.split(sep).join("/");
@@ -1046,7 +1110,7 @@ import {
1046
1110
  openSync as openSync2,
1047
1111
  readFileSync as readFileSync4,
1048
1112
  renameSync as renameSync2,
1049
- statSync as statSync2,
1113
+ statSync as statSync3,
1050
1114
  unlinkSync as unlinkSync4,
1051
1115
  writeFileSync as writeFileSync3
1052
1116
  } from "fs";
@@ -1088,7 +1152,7 @@ function tryAcquireAppendLock(lockPath) {
1088
1152
  }
1089
1153
  function isStaleLock(lockPath) {
1090
1154
  try {
1091
- return Date.now() - statSync2(lockPath).mtimeMs > lockStaleMs();
1155
+ return Date.now() - statSync3(lockPath).mtimeMs > lockStaleMs();
1092
1156
  } catch {
1093
1157
  return false;
1094
1158
  }
@@ -1188,12 +1252,12 @@ var init_jsonl = __esm(() => {
1188
1252
  // ../../packages/core/src/agents/rollout/claude.ts
1189
1253
  import { randomUUID as randomUUID2 } from "crypto";
1190
1254
  import { existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
1191
- import { homedir as homedir2 } from "os";
1192
- import { join as join3 } from "path";
1255
+ import { homedir as homedir3 } from "os";
1256
+ import { join as join4 } from "path";
1193
1257
  function loadClaudeAttachments() {
1194
1258
  if (_attachmentsCache)
1195
1259
  return _attachmentsCache;
1196
- const raw = readFileSync5(join3(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
1260
+ const raw = readFileSync5(join4(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
1197
1261
  const lines = parseJsonlText(raw);
1198
1262
  if (lines.length < 2) {
1199
1263
  throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
@@ -1294,8 +1358,8 @@ function writeClaudeRollout(opts) {
1294
1358
  });
1295
1359
  lastUuid = assistantUuid;
1296
1360
  }
1297
- const projectsDir = join3(homedir2(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
1298
- const path = join3(projectsDir, `${sessionId}.jsonl`);
1361
+ const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
1362
+ const path = join4(projectsDir, `${sessionId}.jsonl`);
1299
1363
  writeJsonlFile(path, lines);
1300
1364
  logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
1301
1365
  return { sessionId, rolloutPath: path };
@@ -1309,8 +1373,8 @@ var init_claude = __esm(() => {
1309
1373
 
1310
1374
  // ../../packages/core/src/agents/claude-registry.ts
1311
1375
  import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync2, renameSync as renameSync3, unlinkSync as unlinkSync5 } from "fs";
1312
- import { homedir as homedir3 } from "os";
1313
- import { join as join4 } from "path";
1376
+ import { homedir as homedir4 } from "os";
1377
+ import { join as join5 } from "path";
1314
1378
  var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
1315
1379
  var init_claude_registry = __esm(() => {
1316
1380
  init_claude();
@@ -1320,7 +1384,8 @@ var init_claude_registry = __esm(() => {
1320
1384
  ALIAS_MAP = {
1321
1385
  sonnet: MODEL_SONNET,
1322
1386
  opus: MODEL_OPUS,
1323
- fable: MODEL_FABLE
1387
+ fable: MODEL_FABLE,
1388
+ "fable-5.2": MODEL_FABLE_5_2
1324
1389
  };
1325
1390
  VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));
1326
1391
  VALID_EFFORTS = new Set(CLAUDE_EFFORT_VALUES);
@@ -1357,11 +1422,11 @@ var init_claude_registry = __esm(() => {
1357
1422
  const result = await forkSession(parentSessionId, {
1358
1423
  ...title ? { title } : {}
1359
1424
  });
1360
- const projectsRoot = join4(homedir3(), ".claude", "projects");
1361
- const destDir = join4(projectsRoot, encodeClaudeCwd(cwd));
1362
- const destPath = join4(destDir, `${result.sessionId}.jsonl`);
1425
+ const projectsRoot = join5(homedir4(), ".claude", "projects");
1426
+ const destDir = join5(projectsRoot, encodeClaudeCwd(cwd));
1427
+ const destPath = join5(destDir, `${result.sessionId}.jsonl`);
1363
1428
  if (!existsSync6(destPath)) {
1364
- const sourcePath = readdirSync2(projectsRoot).map((d) => join4(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync6(p));
1429
+ const sourcePath = readdirSync2(projectsRoot).map((d) => join5(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync6(p));
1365
1430
  if (!sourcePath) {
1366
1431
  throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
1367
1432
  }
@@ -1374,10 +1439,10 @@ var init_claude_registry = __esm(() => {
1374
1439
  };
1375
1440
  },
1376
1441
  async cleanupRollouts({ cwd, sessionIds }) {
1377
- const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(cwd));
1442
+ const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(cwd));
1378
1443
  const failures = [];
1379
1444
  for (const sid of sessionIds) {
1380
- const path = join4(projectsDir, `${sid}.jsonl`);
1445
+ const path = join5(projectsDir, `${sid}.jsonl`);
1381
1446
  try {
1382
1447
  unlinkSync5(path);
1383
1448
  } catch (e) {
@@ -1487,7 +1552,7 @@ function agentAliases(agent) {
1487
1552
  "gpt-6-astra"
1488
1553
  ];
1489
1554
  case "claude":
1490
- return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable"];
1555
+ return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable", "fable-5.2"];
1491
1556
  case "maestro":
1492
1557
  return [
1493
1558
  "maestro",
@@ -2016,8 +2081,8 @@ var init_constants = __esm(() => {
2016
2081
 
2017
2082
  // ../../packages/core/src/storage/storage-host.ts
2018
2083
  import { mkdirSync as mkdirSync6 } from "fs";
2019
- import { homedir as homedir4 } from "os";
2020
- import { dirname as dirname5, join as join5, resolve as resolve6 } from "path";
2084
+ import { homedir as homedir5 } from "os";
2085
+ import { dirname as dirname5, join as join6, resolve as resolve6 } from "path";
2021
2086
  function storageState() {
2022
2087
  const holder = globalThis;
2023
2088
  const existing = holder[STORAGE_HOST_STATE];
@@ -2045,23 +2110,23 @@ function envPath(name, fallback) {
2045
2110
  return resolve6(value || fallback);
2046
2111
  }
2047
2112
  function defaultStateDir() {
2048
- return envPath("NEGOTIUM_STATE_DIR", join5(homedir4(), ".negotium"));
2113
+ return envPath("NEGOTIUM_STATE_DIR", join6(homedir5(), ".negotium"));
2049
2114
  }
2050
2115
  function defaultDataDir() {
2051
- return envPath("NEGOTIUM_DATA_DIR", join5(defaultStateDir(), "data"));
2116
+ return envPath("NEGOTIUM_DATA_DIR", join6(defaultStateDir(), "data"));
2052
2117
  }
2053
2118
  function defaultLogDir() {
2054
- return envPath("NEGOTIUM_LOG_DIR", join5(defaultStateDir(), "logs"));
2119
+ return envPath("NEGOTIUM_LOG_DIR", join6(defaultStateDir(), "logs"));
2055
2120
  }
2056
2121
  function defaultWorkspaceDir() {
2057
- return envPath("NEGOTIUM_WORKSPACE_DIR", join5(defaultStateDir(), "workspace"));
2122
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join6(defaultStateDir(), "workspace"));
2058
2123
  }
2059
2124
  function defaultSessionAsksDir() {
2060
- const runDir = envPath("NEGOTIUM_RUN_DIR", join5(defaultStateDir(), "runtime"));
2061
- return join5(runDir, "session-asks");
2125
+ const runDir = envPath("NEGOTIUM_RUN_DIR", join6(defaultStateDir(), "runtime"));
2126
+ return join6(runDir, "session-asks");
2062
2127
  }
2063
2128
  function defaultSessionsDatabasePath() {
2064
- return envPath("SESSIONS_DB_PATH", join5(resolveStorageDataDir(), "sessions.db"));
2129
+ return envPath("SESSIONS_DB_PATH", join6(resolveStorageDataDir(), "sessions.db"));
2065
2130
  }
2066
2131
  function isSqliteBusy(error) {
2067
2132
  const message = error instanceof Error ? error.message : String(error);
@@ -2118,7 +2183,7 @@ function resolveStorageWorkspaceDir() {
2118
2183
  return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
2119
2184
  }
2120
2185
  function resolveStorageSharedWikiDir() {
2121
- return storageState().configuredHost.sharedWikiDir ?? join5(resolveStorageWorkspaceDir(), "wiki");
2186
+ return storageState().configuredHost.sharedWikiDir ?? join6(resolveStorageWorkspaceDir(), "wiki");
2122
2187
  }
2123
2188
  function registerStorageSchemaInitializer(initialize, priority = 100) {
2124
2189
  const initializers = storageState().schemaInitializers;
@@ -4119,6 +4184,8 @@ var init_mcp_config = __esm(async () => {
4119
4184
  playwright: {
4120
4185
  ...commonRuntimeMcpPolicy("playwright"),
4121
4186
  build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
4187
+ if (BROWSER_BACKEND === "egolite")
4188
+ return null;
4122
4189
  if (playwrightPort && playwrightCapability) {
4123
4190
  const owner = browserOwnerForContext({ userId, session, topicId });
4124
4191
  if (!owner)
@@ -4434,7 +4501,7 @@ var init_vault_crypto = __esm(() => {
4434
4501
 
4435
4502
  // ../../packages/core/src/storage/vault.ts
4436
4503
  import { chmodSync as chmodSync3, mkdirSync as mkdirSync7 } from "fs";
4437
- import { join as join6 } from "path";
4504
+ import { join as join7 } from "path";
4438
4505
  function initializeVaultDatabase(database) {
4439
4506
  database.exec("PRAGMA journal_mode = WAL");
4440
4507
  database.exec("PRAGMA busy_timeout = 5000");
@@ -4469,8 +4536,8 @@ function initializeVaultDatabase(database) {
4469
4536
  }
4470
4537
  }
4471
4538
  function openVaultDatabase(dataDir) {
4472
- const vaultDir = join6(dataDir, "vault");
4473
- const path = join6(vaultDir, "vault.db");
4539
+ const vaultDir = join7(dataDir, "vault");
4540
+ const path = join7(vaultDir, "vault.db");
4474
4541
  mkdirSync7(vaultDir, { recursive: true, mode: 448 });
4475
4542
  const database = new Database(path, { create: true });
4476
4543
  chmodSync3(path, 384);
@@ -4654,15 +4721,15 @@ var init_execution_host = __esm(async () => {
4654
4721
 
4655
4722
  // ../../packages/core/src/agents/rollout/codex.ts
4656
4723
  import { randomBytes as randomBytes4 } from "crypto";
4657
- import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync6 } from "fs";
4658
- import { basename as basename2, dirname as dirname7, join as join7, resolve as resolve7 } from "path";
4724
+ import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync4, unlinkSync as unlinkSync6 } from "fs";
4725
+ import { basename as basename2, dirname as dirname7, join as join8, resolve as resolve7 } from "path";
4659
4726
  function codexSessionsDir() {
4660
- return join7(hostedCodexHomePath(), "sessions");
4727
+ return join8(hostedCodexHomePath(), "sessions");
4661
4728
  }
4662
4729
  function loadCodexShell() {
4663
4730
  if (_shellCache)
4664
4731
  return _shellCache;
4665
- const raw = readFileSync6(join7(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
4732
+ const raw = readFileSync6(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
4666
4733
  const lines = parseJsonlText(raw);
4667
4734
  if (lines.length < 5) {
4668
4735
  throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
@@ -4729,8 +4796,8 @@ function codexRolloutPath(threadId, fallback) {
4729
4796
  const hh = String(createdAt.getHours()).padStart(2, "0");
4730
4797
  const min = String(createdAt.getMinutes()).padStart(2, "0");
4731
4798
  const ss = String(createdAt.getSeconds()).padStart(2, "0");
4732
- const dir = join7(codexSessionsDir(), yyyy, mm, dd);
4733
- return join7(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
4799
+ const dir = join8(codexSessionsDir(), yyyy, mm, dd);
4800
+ return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
4734
4801
  }
4735
4802
  function canonicalFilePath(path) {
4736
4803
  const absolute = resolve7(path);
@@ -4738,7 +4805,7 @@ function canonicalFilePath(path) {
4738
4805
  return realpathSync3(absolute);
4739
4806
  } catch {
4740
4807
  try {
4741
- return join7(realpathSync3(dirname7(absolute)), basename2(absolute));
4808
+ return join8(realpathSync3(dirname7(absolute)), basename2(absolute));
4742
4809
  } catch {
4743
4810
  return absolute;
4744
4811
  }
@@ -5027,22 +5094,22 @@ function latestCodexRolloutPath(threadId) {
5027
5094
  try {
5028
5095
  if (buckets) {
5029
5096
  for (const bucket of buckets) {
5030
- const dir = join7(sessionsDir, bucket);
5097
+ const dir = join8(sessionsDir, bucket);
5031
5098
  if (!existsSync7(dir))
5032
5099
  continue;
5033
5100
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
5034
5101
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
5035
- candidates.push(join7(dir, rel));
5102
+ candidates.push(join8(dir, rel));
5036
5103
  }
5037
5104
  }
5038
5105
  }
5039
5106
  if (candidates.length === 0) {
5040
5107
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
5041
5108
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
5042
- candidates.push(join7(sessionsDir, rel));
5109
+ candidates.push(join8(sessionsDir, rel));
5043
5110
  }
5044
5111
  }
5045
- return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
5112
+ return candidates.sort((a, b) => statSync4(b).mtimeMs - statSync4(a).mtimeMs)[0];
5046
5113
  } catch (error) {
5047
5114
  logger.debug({ error, threadId }, "codex rollout lookup failed");
5048
5115
  return;
@@ -5163,13 +5230,13 @@ function sweepPriorRolloutsForThread(threadId) {
5163
5230
  return;
5164
5231
  }
5165
5232
  for (const bucket of buckets) {
5166
- const dir = join7(sessionsDir, bucket);
5233
+ const dir = join8(sessionsDir, bucket);
5167
5234
  if (!existsSync7(dir))
5168
5235
  continue;
5169
5236
  try {
5170
5237
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
5171
5238
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
5172
- const fullPath = join7(dir, rel);
5239
+ const fullPath = join8(dir, rel);
5173
5240
  try {
5174
5241
  unlinkSync6(fullPath);
5175
5242
  } catch (e) {
@@ -5187,7 +5254,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
5187
5254
  try {
5188
5255
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
5189
5256
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
5190
- const fullPath = join7(sessionsDir, rel);
5257
+ const fullPath = join8(sessionsDir, rel);
5191
5258
  try {
5192
5259
  unlinkSync6(fullPath);
5193
5260
  } catch (e) {
@@ -5249,7 +5316,7 @@ var init_codex = __esm(async () => {
5249
5316
  });
5250
5317
 
5251
5318
  // ../../packages/core/src/version.ts
5252
- var NEGOTIUM_VERSION = "0.23.13";
5319
+ var NEGOTIUM_VERSION = "0.23.15";
5253
5320
 
5254
5321
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
5255
5322
  import { spawn as spawn2 } from "child_process";
@@ -5266,12 +5333,12 @@ import {
5266
5333
  writeFileSync as writeFileSync5
5267
5334
  } from "fs";
5268
5335
  import { tmpdir } from "os";
5269
- import { dirname as dirname8, join as join8 } from "path";
5336
+ import { dirname as dirname8, join as join9 } from "path";
5270
5337
  import { fileURLToPath as fileURLToPath2 } from "url";
5271
5338
  function findPackageJson(specifier, searchFromDir) {
5272
5339
  let dir = searchFromDir;
5273
5340
  for (;; ) {
5274
- const candidate = join8(dir, "node_modules", specifier, "package.json");
5341
+ const candidate = join9(dir, "node_modules", specifier, "package.json");
5275
5342
  if (existsSync8(candidate))
5276
5343
  return candidate;
5277
5344
  const parent = dirname8(dir);
@@ -5289,7 +5356,7 @@ function readPackageVersion(packageJsonPath) {
5289
5356
  return parsed.version;
5290
5357
  }
5291
5358
  function codexCliScriptPath() {
5292
- return join8(dirname8(bundledCodexPackagePath), "bin", "codex.js");
5359
+ return join9(dirname8(bundledCodexPackagePath), "bin", "codex.js");
5293
5360
  }
5294
5361
  function parseCodexModelCache(contents, sourcePath) {
5295
5362
  let parsed;
@@ -5330,7 +5397,7 @@ function writePrivateFileAtomic(path, contents) {
5330
5397
  }
5331
5398
  }
5332
5399
  function bundledCodexModelCachePath(authFilePath) {
5333
- return join8(dirname8(authFilePath), NEGOTIUM_MODEL_CACHE);
5400
+ return join9(dirname8(authFilePath), NEGOTIUM_MODEL_CACHE);
5334
5401
  }
5335
5402
  async function bootstrapCodexModelCache(codexHome, cachePath) {
5336
5403
  const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
@@ -5443,15 +5510,15 @@ function removeIsolatedCodexHome(dir) {
5443
5510
  }
5444
5511
  async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
5445
5512
  const sourceHome = dirname8(authFilePath);
5446
- const isolatedHome = mkdtempSync(join8(tmpdir(), "negotium-codex-models-"));
5447
- const isolatedCachePath = join8(isolatedHome, "models_cache.json");
5513
+ const isolatedHome = mkdtempSync(join9(tmpdir(), "negotium-codex-models-"));
5514
+ const isolatedCachePath = join9(isolatedHome, "models_cache.json");
5448
5515
  try {
5449
- const isolatedAuthPath = join8(isolatedHome, "auth.json");
5516
+ const isolatedAuthPath = join9(isolatedHome, "auth.json");
5450
5517
  copyFileSync(authFilePath, isolatedAuthPath);
5451
5518
  chmodSync4(isolatedAuthPath, 384);
5452
- const sourceConfigPath = join8(sourceHome, "config.toml");
5519
+ const sourceConfigPath = join9(sourceHome, "config.toml");
5453
5520
  if (existsSync8(sourceConfigPath)) {
5454
- const isolatedConfigPath = join8(isolatedHome, "config.toml");
5521
+ const isolatedConfigPath = join9(isolatedHome, "config.toml");
5455
5522
  copyFileSync(sourceConfigPath, isolatedConfigPath);
5456
5523
  chmodSync4(isolatedConfigPath, 384);
5457
5524
  }
@@ -5472,7 +5539,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
5472
5539
  return configuredCachePath;
5473
5540
  }
5474
5541
  const bundledCachePath = bundledCodexModelCachePath(authFilePath);
5475
- const sharedCachePath = join8(codexHome, "models_cache.json");
5542
+ const sharedCachePath = join9(codexHome, "models_cache.json");
5476
5543
  if (existsSync8(sharedCachePath)) {
5477
5544
  try {
5478
5545
  const shared = readCompatibleCodexModelCache(sharedCachePath);
@@ -5492,7 +5559,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
5492
5559
  }
5493
5560
  function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
5494
5561
  const codexHome = dirname8(authFilePath);
5495
- const outputPath = join8(codexHome, NEGOTIUM_MODEL_CATALOG);
5562
+ const outputPath = join9(codexHome, NEGOTIUM_MODEL_CATALOG);
5496
5563
  const parsed = readCodexModelCache(sourcePath).parsed;
5497
5564
  const models = parsed.models.map((model, index) => {
5498
5565
  if (!model || typeof model !== "object" || Array.isArray(model)) {
@@ -5636,7 +5703,7 @@ var init_codex_app_server = __esm(async () => {
5636
5703
 
5637
5704
  // ../../packages/core/src/agents/codex-registry.ts
5638
5705
  import { existsSync as existsSync9, unlinkSync as unlinkSync8 } from "fs";
5639
- import { join as join9 } from "path";
5706
+ import { join as join10 } from "path";
5640
5707
  var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
5641
5708
  var init_codex_registry = __esm(async () => {
5642
5709
  init_logger();
@@ -5681,7 +5748,7 @@ var init_codex_registry = __esm(async () => {
5681
5748
  async cleanupRollouts({ sessionIds }) {
5682
5749
  if (sessionIds.length === 0)
5683
5750
  return;
5684
- const sessionsDir = join9(hostedCodexHomePath(), "sessions");
5751
+ const sessionsDir = join10(hostedCodexHomePath(), "sessions");
5685
5752
  if (!existsSync9(sessionsDir))
5686
5753
  return;
5687
5754
  const failures = [];
@@ -5689,7 +5756,7 @@ var init_codex_registry = __esm(async () => {
5689
5756
  try {
5690
5757
  const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
5691
5758
  for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
5692
- const path = join9(sessionsDir, rel);
5759
+ const path = join10(sessionsDir, rel);
5693
5760
  try {
5694
5761
  unlinkSync8(path);
5695
5762
  } catch (e) {
@@ -5714,16 +5781,16 @@ var init_codex_registry = __esm(async () => {
5714
5781
  // ../../packages/core/src/agents/maestro-registry.ts
5715
5782
  import { randomUUID as randomUUID5 } from "crypto";
5716
5783
  import { existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
5717
- import { homedir as homedir5 } from "os";
5718
- import { join as join10, resolve as resolve8 } from "path";
5784
+ import { homedir as homedir6 } from "os";
5785
+ import { join as join11, resolve as resolve8 } from "path";
5719
5786
  function maestroSessionsDir() {
5720
- return join10(process.env.MAESTRO_DATA_DIR ? resolve8(process.env.MAESTRO_DATA_DIR) : join10(homedir5(), ".maestro"), "sessions");
5787
+ return join11(process.env.MAESTRO_DATA_DIR ? resolve8(process.env.MAESTRO_DATA_DIR) : join11(homedir6(), ".maestro"), "sessions");
5721
5788
  }
5722
5789
  function maestroSessionPath(sessionId) {
5723
- return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
5790
+ return join11(maestroSessionsDir(), `${sessionId}.jsonl`);
5724
5791
  }
5725
5792
  function maestroActiveSessionPath(sessionId) {
5726
- return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
5793
+ return join11(maestroSessionsDir(), `${sessionId}.active.jsonl`);
5727
5794
  }
5728
5795
  function existingCreatedAt(path) {
5729
5796
  if (!existsSync10(path))
@@ -5929,6 +5996,7 @@ var init_model_catalog = __esm(() => {
5929
5996
  opus: "claude",
5930
5997
  haiku: "claude",
5931
5998
  fable: "claude",
5999
+ "fable-5.2": "claude",
5932
6000
  astra: "codex",
5933
6001
  sol: "codex",
5934
6002
  luna: "codex",
@@ -6006,6 +6074,16 @@ var init_model_catalog = __esm(() => {
6006
6074
  marginalTokenCost: "Claude API/extra usage: $10/M input, $12.50/M cache write, $0.25/M cache read (cut from $1/M in Fable 5.1, 2026-09-01), $50/M output",
6007
6075
  estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
6008
6076
  },
6077
+ {
6078
+ model: "fable-5.2",
6079
+ agent: "claude",
6080
+ description: "Claude Fable 5.2 (2026-11-09): same top-tier route as fable, newer and cheaper, for the hardest and longest-running tasks.",
6081
+ intelligenceTier: "fable",
6082
+ routingSummary: "hardest long-running work; cheaper than fable (5.1); explicit request only",
6083
+ accessCost: CLAUDE_MAX_20X_COST,
6084
+ marginalTokenCost: "Claude API/extra usage: $8/M input, $40/M output (cache rates not published; assumed $10/M cache write, $0.20/M cache read)",
6085
+ estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
6086
+ },
6009
6087
  {
6010
6088
  model: "opus",
6011
6089
  agent: "claude",
@@ -6420,16 +6498,16 @@ var init_bus = __esm(async () => {
6420
6498
 
6421
6499
  // ../../packages/core/src/query/state.ts
6422
6500
  import { mkdirSync as mkdirSync10, renameSync as renameSync6, unlinkSync as unlinkSync9, writeFileSync as writeFileSync8 } from "fs";
6423
- import { basename as basename3, join as join13 } from "path";
6501
+ import { basename as basename3, join as join14 } from "path";
6424
6502
  function createQueryStateStore(options) {
6425
6503
  const sanitize = options.sanitizeTopicId ?? sanitizeId;
6426
- const queryStateDirPath = (userId) => join13(options.usersLogDir, String(userId), "active-queries");
6427
- const queryStateFile = (userId, topicId) => join13(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
6504
+ const queryStateDirPath = (userId) => join14(options.usersLogDir, String(userId), "active-queries");
6505
+ const queryStateFile = (userId, topicId) => join14(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
6428
6506
  const legacyQueryStateFile = (userId, topicName) => {
6429
6507
  if (!topicName || topicName === "." || topicName === ".." || basename3(topicName) !== topicName) {
6430
6508
  return null;
6431
6509
  }
6432
- return join13(queryStateDirPath(userId), `${topicName}.json`);
6510
+ return join14(queryStateDirPath(userId), `${topicName}.json`);
6433
6511
  };
6434
6512
  return {
6435
6513
  write(userId, topicId, topicName, task) {
@@ -7392,13 +7470,13 @@ var init_browser_processes = __esm(async () => {
7392
7470
  });
7393
7471
 
7394
7472
  // ../../packages/core/src/platform/playwright/headed-launch.ts
7395
- import { accessSync as accessSync2, constants as constants2 } from "fs";
7396
- import { delimiter, isAbsolute as isAbsolute2, resolve as resolve10 } from "path";
7473
+ import { accessSync as accessSync3, constants as constants3 } from "fs";
7474
+ import { delimiter as delimiter2, isAbsolute as isAbsolute3, resolve as resolve10 } from "path";
7397
7475
  function findExecutableOnPath(command, environment = process.env) {
7398
- const candidates = isAbsolute2(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve10(directory, command));
7476
+ const candidates = isAbsolute3(command) ? [command] : (environment.PATH ?? "").split(delimiter2).filter(Boolean).map((directory) => resolve10(directory, command));
7399
7477
  for (const candidate of candidates) {
7400
7478
  try {
7401
- accessSync2(candidate, constants2.X_OK);
7479
+ accessSync3(candidate, constants3.X_OK);
7402
7480
  return candidate;
7403
7481
  } catch {}
7404
7482
  }
@@ -7517,7 +7595,7 @@ var init_vault_public = __esm(async () => {
7517
7595
  import { randomBytes as randomBytes5, timingSafeEqual as timingSafeEqual2 } from "crypto";
7518
7596
  import { createServer as createServer2 } from "net";
7519
7597
  import { tmpdir as tmpdir2 } from "os";
7520
- import { join as join14 } from "path";
7598
+ import { join as join15 } from "path";
7521
7599
  function deepMapStrings(value, transform) {
7522
7600
  if (typeof value === "string")
7523
7601
  return transform(value);
@@ -7604,7 +7682,7 @@ function authorized(actual, expected) {
7604
7682
  }
7605
7683
  async function createBrowserVaultBroker(userId) {
7606
7684
  const token = randomBytes5(32).toString("hex");
7607
- const socketPath = ipcEndpoint(join14(process.platform === "win32" ? tmpdir2() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes5(8).toString("hex")}.sock`));
7685
+ const socketPath = ipcEndpoint(join15(process.platform === "win32" ? tmpdir2() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes5(8).toString("hex")}.sock`));
7608
7686
  const retainedForms = new Map;
7609
7687
  const leases = new Map;
7610
7688
  const sockets = new Set;
@@ -7826,7 +7904,7 @@ import {
7826
7904
  unlinkSync as unlinkSync12,
7827
7905
  writeFileSync as writeFileSync9
7828
7906
  } from "fs";
7829
- import { dirname as dirname10, join as join15, resolve as resolve11 } from "path";
7907
+ import { dirname as dirname10, join as join16, resolve as resolve11 } from "path";
7830
7908
  function removeDefaultProfileDataDir(userDataDir) {
7831
7909
  const root = resolve11(BROWSER_PROFILES_DIR);
7832
7910
  const target = resolve11(userDataDir);
@@ -7922,14 +8000,14 @@ function portFileName(instanceKey) {
7922
8000
  function writePortFile(instanceKey, port) {
7923
8001
  try {
7924
8002
  mkdirSync11(managerHost.portsDir, { recursive: true });
7925
- writeFileSync9(join15(managerHost.portsDir, portFileName(instanceKey)), String(port));
8003
+ writeFileSync9(join16(managerHost.portsDir, portFileName(instanceKey)), String(port));
7926
8004
  } catch (e) {
7927
8005
  logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
7928
8006
  }
7929
8007
  }
7930
8008
  function deletePortFile(instanceKey) {
7931
8009
  try {
7932
- unlinkSync12(join15(managerHost.portsDir, portFileName(instanceKey)));
8010
+ unlinkSync12(join16(managerHost.portsDir, portFileName(instanceKey)));
7933
8011
  } catch (e) {
7934
8012
  if (e.code === "ENOENT")
7935
8013
  return;
@@ -9033,9 +9111,9 @@ import {
9033
9111
  unlinkSync as unlinkSync13,
9034
9112
  writeFileSync as writeFileSync10
9035
9113
  } from "fs";
9036
- import { dirname as dirname11, join as join16 } from "path";
9114
+ import { dirname as dirname11, join as join17 } from "path";
9037
9115
  function conversationDir(_userId) {
9038
- return join16(resolveStorageDataDir(), "conversations");
9116
+ return join17(resolveStorageDataDir(), "conversations");
9039
9117
  }
9040
9118
  function topicFilename(userId, topicName) {
9041
9119
  const t = sanitizeTopicName(topicName, true);
@@ -9045,7 +9123,7 @@ function topicFilename(userId, topicName) {
9045
9123
  return `${t}.${sanitizeId(owner)}.jsonl`;
9046
9124
  }
9047
9125
  function getConversationPath(userId, topicName) {
9048
- return join16(conversationDir(userId), topicFilename(userId, topicName));
9126
+ return join17(conversationDir(userId), topicFilename(userId, topicName));
9049
9127
  }
9050
9128
  function getActiveConversationPath(userId, topicName) {
9051
9129
  const rawPath = getConversationPath(userId, topicName);
@@ -9390,8 +9468,8 @@ var init_compaction_tool_projection = __esm(() => {
9390
9468
  });
9391
9469
 
9392
9470
  // ../../packages/core/src/storage/tasks.ts
9393
- import { existsSync as existsSync16, mkdirSync as mkdirSync13, readFileSync as readFileSync13, renameSync as renameSync8, statSync as statSync4, writeFileSync as writeFileSync11 } from "fs";
9394
- import { dirname as dirname12, join as join17 } from "path";
9471
+ import { existsSync as existsSync16, mkdirSync as mkdirSync13, readFileSync as readFileSync13, renameSync as renameSync8, statSync as statSync5, writeFileSync as writeFileSync11 } from "fs";
9472
+ import { dirname as dirname12, join as join18 } from "path";
9395
9473
  function safeTaskScopeKey(scopeKey) {
9396
9474
  const safe = sanitizeFileName(scopeKey);
9397
9475
  if (!safe || safe === "." || safe === "..") {
@@ -9403,7 +9481,7 @@ function taskScopeKey(opts) {
9403
9481
  return opts.topicId?.trim() || opts.session || "default";
9404
9482
  }
9405
9483
  function getTaskFilePath(userId, scopeKey) {
9406
- return join17(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
9484
+ return join18(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
9407
9485
  }
9408
9486
  function readTasks(userId, scopeKey) {
9409
9487
  const path = getTaskFilePath(userId, scopeKey);
@@ -9427,7 +9505,7 @@ function writeTasks(userId, scopeKey, tasks) {
9427
9505
  }
9428
9506
  function taskFileMtimeNs(userId, scopeKey) {
9429
9507
  try {
9430
- return statSync4(getTaskFilePath(userId, scopeKey), { bigint: true }).mtimeNs;
9508
+ return statSync5(getTaskFilePath(userId, scopeKey), { bigint: true }).mtimeNs;
9431
9509
  } catch {
9432
9510
  return null;
9433
9511
  }
@@ -10682,16 +10760,16 @@ var init_codex_tree_kill = __esm(() => {
10682
10760
  });
10683
10761
 
10684
10762
  // ../../packages/core/src/agents/codex-windows-wrapper.ts
10685
- import { execFile } from "child_process";
10763
+ import { execFile as execFile2 } from "child_process";
10686
10764
  import { createHash as createHash6, randomUUID as randomUUID10 } from "crypto";
10687
10765
  import { existsSync as existsSync18 } from "fs";
10688
10766
  import { mkdir, rename, rm, writeFile } from "fs/promises";
10689
- import { join as join18 } from "path";
10690
- import { promisify } from "util";
10767
+ import { join as join19 } from "path";
10768
+ import { promisify as promisify2 } from "util";
10691
10769
  function cscPath() {
10692
10770
  const windir = process.env.WINDIR ?? process.env.SystemRoot ?? "C:\\Windows";
10693
10771
  for (const framework of ["Framework64", "Framework"]) {
10694
- const candidate = join18(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe");
10772
+ const candidate = join19(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe");
10695
10773
  if (existsSync18(candidate))
10696
10774
  return candidate;
10697
10775
  }
@@ -10699,13 +10777,13 @@ function cscPath() {
10699
10777
  }
10700
10778
  async function ensureCodexWindowsWrapperExe(cacheDir) {
10701
10779
  const digest = createHash6("sha256").update(CODEX_WINDOWS_WRAPPER_SOURCE).digest("hex").slice(0, 12);
10702
- const exePath = join18(cacheDir, `codex-hook-wrapper-${digest}.exe`);
10780
+ const exePath = join19(cacheDir, `codex-hook-wrapper-${digest}.exe`);
10703
10781
  if (existsSync18(exePath))
10704
10782
  return exePath;
10705
10783
  await mkdir(cacheDir, { recursive: true });
10706
10784
  const stamp = randomUUID10();
10707
- const sourcePath = join18(cacheDir, `wrapper-${stamp}.cs`);
10708
- const tempExe = join18(cacheDir, `wrapper-${stamp}.exe`);
10785
+ const sourcePath = join19(cacheDir, `wrapper-${stamp}.cs`);
10786
+ const tempExe = join19(cacheDir, `wrapper-${stamp}.exe`);
10709
10787
  try {
10710
10788
  await writeFile(sourcePath, CODEX_WINDOWS_WRAPPER_SOURCE, "utf8");
10711
10789
  await execFileAsync(cscPath(), ["/nologo", "/target:exe", "/optimize+", `/out:${tempExe}`, sourcePath], { windowsHide: true, timeout: 60000 });
@@ -10727,7 +10805,7 @@ ${detail}` : ""}`);
10727
10805
  }
10728
10806
  var execFileAsync, CODEX_WINDOWS_WRAPPER_SOURCE;
10729
10807
  var init_codex_windows_wrapper = __esm(() => {
10730
- execFileAsync = promisify(execFile);
10808
+ execFileAsync = promisify2(execFile2);
10731
10809
  CODEX_WINDOWS_WRAPPER_SOURCE = String.raw`
10732
10810
  using System;
10733
10811
  using System.Diagnostics;
@@ -10822,7 +10900,7 @@ import { existsSync as existsSync19 } from "fs";
10822
10900
  import { chmod, copyFile, mkdtemp, rm as rm2, writeFile as writeFile2 } from "fs/promises";
10823
10901
  import { createServer as createServer3 } from "net";
10824
10902
  import { tmpdir as tmpdir3 } from "os";
10825
- import { dirname as dirname13, join as join19, resolve as resolve12 } from "path";
10903
+ import { dirname as dirname13, join as join20, resolve as resolve12 } from "path";
10826
10904
  import { fileURLToPath as fileURLToPath3 } from "url";
10827
10905
  function evaluateCodexVaultPreToolUse(input, userId, operations) {
10828
10906
  if (operations.referencesSensitiveStorage(input.tool_input)) {
@@ -10878,10 +10956,10 @@ function windowsQuote(value) {
10878
10956
  return `"${value.replaceAll('"', "\\\"")}"`;
10879
10957
  }
10880
10958
  async function createCodexVaultHookBridge(userId) {
10881
- const root = await mkdtemp(join19(tmpdir3(), "negotium-codex-vault-"));
10959
+ const root = await mkdtemp(join20(tmpdir3(), "negotium-codex-vault-"));
10882
10960
  await chmod(root, 448);
10883
- const socketPath = ipcEndpoint(join19(root, "hook.sock"));
10884
- const wrapperPath = join19(root, IS_WINDOWS2 ? "codex-with-hooks.exe" : "codex-with-hooks");
10961
+ const socketPath = ipcEndpoint(join20(root, "hook.sock"));
10962
+ const wrapperPath = join20(root, IS_WINDOWS2 ? "codex-with-hooks.exe" : "codex-with-hooks");
10885
10963
  const token = randomBytes7(32).toString("hex");
10886
10964
  const connections = new Set;
10887
10965
  const server = createServer3((socket) => {
@@ -10932,9 +11010,9 @@ async function createCodexVaultHookBridge(userId) {
10932
11010
  restrictIpcEndpoint(socketPath);
10933
11011
  if (IS_WINDOWS2) {
10934
11012
  await Promise.resolve().then(() => init_config());
10935
- const cached = await ensureCodexWindowsWrapperExe(join19(BINARIES_DIR, "codex-hook-wrapper"));
11013
+ const cached = await ensureCodexWindowsWrapperExe(join20(BINARIES_DIR, "codex-hook-wrapper"));
10936
11014
  await copyFile(cached, wrapperPath);
10937
- await writeFile2(join19(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
11015
+ await writeFile2(join20(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
10938
11016
  `), { encoding: "utf8", mode: 384 });
10939
11017
  } else {
10940
11018
  await writeFile2(wrapperPath, privateCodexWrapper(codexCliScriptPath(), socketPath, token), {
@@ -10986,8 +11064,8 @@ var init_codex_vault_hook_bridge = __esm(async () => {
10986
11064
  });
10987
11065
 
10988
11066
  // ../../packages/core/src/agents/tool-format.ts
10989
- import { readFileSync as readFileSync15, statSync as statSync5 } from "fs";
10990
- import { isAbsolute as isAbsolute3, resolve as resolve13 } from "path";
11067
+ import { readFileSync as readFileSync15, statSync as statSync6 } from "fs";
11068
+ import { isAbsolute as isAbsolute4, resolve as resolve13 } from "path";
10991
11069
  import { diffLines as computeLineDiff } from "diff";
10992
11070
  function summarizeDisplayText(value) {
10993
11071
  const normalized = value.replace(/\s+/g, " ").trim();
@@ -11311,9 +11389,9 @@ function sourceStartLine(input, before, after, cwd) {
11311
11389
  const rawPath = input.file_path ?? input.path;
11312
11390
  if (typeof rawPath !== "string" || !rawPath.trim())
11313
11391
  return 1;
11314
- const path = isAbsolute3(rawPath) ? rawPath : resolve13(cwd ?? process.cwd(), rawPath);
11392
+ const path = isAbsolute4(rawPath) ? rawPath : resolve13(cwd ?? process.cwd(), rawPath);
11315
11393
  try {
11316
- if (statSync5(path).size > TOOL_DIFF_SOURCE_MAX_BYTES)
11394
+ if (statSync6(path).size > TOOL_DIFF_SOURCE_MAX_BYTES)
11317
11395
  return 1;
11318
11396
  const source = readFileSync15(path, "utf8").replace(/\r\n?/g, `
11319
11397
  `);
@@ -11510,9 +11588,9 @@ __export(exports_codex_provider, {
11510
11588
  toCodexMcpServers: () => toCodexMcpServers
11511
11589
  });
11512
11590
  import { execFileSync as execFileSync6 } from "child_process";
11513
- import { existsSync as existsSync20, readFileSync as readFileSync16, realpathSync as realpathSync5, statSync as statSync6 } from "fs";
11514
- import { homedir as homedir6 } from "os";
11515
- import { dirname as dirname14, isAbsolute as isAbsolute4, join as join20, relative as relative3, resolve as resolve14 } from "path";
11591
+ import { existsSync as existsSync20, readFileSync as readFileSync16, realpathSync as realpathSync5, statSync as statSync7 } from "fs";
11592
+ import { homedir as homedir7 } from "os";
11593
+ import { dirname as dirname14, isAbsolute as isAbsolute5, join as join21, relative as relative3, resolve as resolve14 } from "path";
11516
11594
  import { Codex } from "@openai/codex-sdk";
11517
11595
  function codexNoticeStatus(message) {
11518
11596
  const firstLine = message.trim().split(`
@@ -11548,7 +11626,7 @@ function codexMcpServerName(name) {
11548
11626
  return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
11549
11627
  }
11550
11628
  function globalCodexMcpServerNames(authFilePath) {
11551
- const configPath = join20(dirname14(authFilePath), "config.toml");
11629
+ const configPath = join21(dirname14(authFilePath), "config.toml");
11552
11630
  if (!existsSync20(configPath))
11553
11631
  return [];
11554
11632
  try {
@@ -11658,7 +11736,7 @@ function textFile(path, maxBytes = CODEX_DIFF_FILE_LIMIT) {
11658
11736
  return null;
11659
11737
  try {
11660
11738
  const byteLimit = Math.min(CODEX_DIFF_FILE_LIMIT, Math.max(0, maxBytes));
11661
- if (statSync6(path).size > byteLimit)
11739
+ if (statSync7(path).size > byteLimit)
11662
11740
  return;
11663
11741
  const content = readFileSync16(path);
11664
11742
  if (content.byteLength > byteLimit || content.includes(0))
@@ -11707,9 +11785,9 @@ class CodexFilePreviewTracker {
11707
11785
  preview(path, succeeded) {
11708
11786
  if (!this.#root || !this.#baselineAvailable || !succeeded)
11709
11787
  return {};
11710
- const absolute = canonicalPath(isAbsolute4(path) ? path : resolve14(this.#cwd, path));
11788
+ const absolute = canonicalPath(isAbsolute5(path) ? path : resolve14(this.#cwd, path));
11711
11789
  const relativePath = relative3(this.#root, absolute);
11712
- if (!relativePath || relativePath.startsWith("..") || isAbsolute4(relativePath))
11790
+ if (!relativePath || relativePath.startsWith("..") || isAbsolute5(relativePath))
11713
11791
  return {};
11714
11792
  const before = this.#baseline.has(relativePath) ? this.#baseline.get(relativePath) : this.#headFile(relativePath);
11715
11793
  const after = textFile(absolute);
@@ -11743,7 +11821,7 @@ class CodexFilePreviewTracker {
11743
11821
  }
11744
11822
  }
11745
11823
  async function fileChangeEvents(item, previews, cwd, threadId, consumedPatchCallIds) {
11746
- const expectedPaths = item.changes.map((change) => isAbsolute4(change.path) ? change.path : resolve14(cwd, change.path));
11824
+ const expectedPaths = item.changes.map((change) => isAbsolute5(change.path) ? change.path : resolve14(cwd, change.path));
11747
11825
  let nativePreview;
11748
11826
  if (threadId && item.status === "completed") {
11749
11827
  await new Promise((resolveDelay) => setTimeout(resolveDelay, 20));
@@ -11911,7 +11989,7 @@ async function* codexProvider(opts) {
11911
11989
  mcpServerCount: Object.keys(codexMcpServers).length
11912
11990
  }, "codexProvider: starting turn");
11913
11991
  const hostedCodexHome = hostedCodexHomePath();
11914
- const inheritedCodexHome = process.env.CODEX_HOME || join20(homedir6(), ".codex");
11992
+ const inheritedCodexHome = process.env.CODEX_HOME || join21(homedir7(), ".codex");
11915
11993
  const codexEnvironment = scopedBrowserCapability || resolve14(hostedCodexHome) !== resolve14(inheritedCodexHome) ? {
11916
11994
  ...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
11917
11995
  CODEX_HOME: hostedCodexHome,
@@ -12380,8 +12458,8 @@ var init_maestro_provider = __esm(async () => {
12380
12458
 
12381
12459
  // ../../packages/core/src/agents/index.ts
12382
12460
  import { existsSync as existsSync21 } from "fs";
12383
- import { homedir as homedir7 } from "os";
12384
- import { join as join21 } from "path";
12461
+ import { homedir as homedir8 } from "os";
12462
+ import { join as join22 } from "path";
12385
12463
  async function* dispatchAgent(opts) {
12386
12464
  switch (opts.agent) {
12387
12465
  case "claude": {
@@ -12415,11 +12493,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
12415
12493
  switch (agent) {
12416
12494
  case "claude": {
12417
12495
  const encodedCwd = encodeClaudeCwd(cwd);
12418
- const path = join21(homedir7(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
12496
+ const path = join22(homedir8(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
12419
12497
  return !existsSync21(path);
12420
12498
  }
12421
12499
  case "codex": {
12422
- const sessionsDir = join21(hostedCodexHomePath(), "sessions");
12500
+ const sessionsDir = join22(hostedCodexHomePath(), "sessions");
12423
12501
  const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
12424
12502
  for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
12425
12503
  return false;
@@ -12530,7 +12608,8 @@ function loadSessionPrompt(filename, fallback) {
12530
12608
  }
12531
12609
  function sharedToolsPartial() {
12532
12610
  if (_sharedToolsPartial === null) {
12533
- _sharedToolsPartial = loadSessionPrompt("_shared-tools.md", "");
12611
+ const shared = loadSessionPrompt("_shared-tools.md", "");
12612
+ _sharedToolsPartial = shared.replace(/<!-- CHROME_BROWSER_START -->[\s\S]*?<!-- CHROME_BROWSER_END -->/, (chrome) => BROWSER_BACKEND === "egolite" ? EGO_BROWSER_INSTRUCTIONS : chrome.replace(/<!-- CHROME_BROWSER_(?:START|END) -->\n?/g, ""));
12534
12613
  }
12535
12614
  return _sharedToolsPartial;
12536
12615
  }
@@ -12707,7 +12786,7 @@ function buildRuntimeToolSection(opts, extensions) {
12707
12786
  "`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.",
12708
12787
  "`set_model` may be called autonomously only when the current model is clearly below the task's required capability, such as complex algorithm design, proof-level math, or broad multi-file refactoring. Choose the best-fit model directly from the same-agent catalog; model selection is not a mandatory one-step ladder. End the turn after changing it. Do not use vague task complexity as a trigger.",
12709
12788
  "`set_agent` autonomous calls are forbidden. Only switch agent when the user explicitly asks to switch runtime, e.g. \u201Cswitch to codex\u201D, \u201Cuse claude\u201D.",
12710
- "Never use `fable` unless the user explicitly requests it; it is expensive.",
12789
+ "Never use `fable` or `fable-5.2` unless the user explicitly requests it; they are expensive.",
12711
12790
  "",
12712
12791
  "Model catalog (capability/cost routing guidance):",
12713
12792
  MODEL_COST_ROUTING_SUMMARY,
@@ -12906,6 +12985,7 @@ This is the shared "General" hub of the user's workspace.
12906
12985
  Act as the workspace manager: orient the user across topics, summarize what is going on, and route focused work to the right room.`, _topicSystemPromptTemplate = null, _channelSystemPromptTemplate = null, _managerSystemPromptTemplate = null, _visualDesignGuide = null, _sharedToolsPartial = null, defaultPromptBuilders, buildTopicSystemPrompt, buildChannelSystemPrompt, buildManagerSystemPrompt;
12907
12986
  var init_builders = __esm(() => {
12908
12987
  init_model_catalog();
12988
+ init_browser_backend();
12909
12989
  init_config();
12910
12990
  init_logger();
12911
12991
  PROMPTS_DIR = resolve16(PROJECT_ROOT, "src/prompts");
@@ -12992,9 +13072,9 @@ var init_api_topic_brief = __esm(async () => {
12992
13072
  });
12993
13073
 
12994
13074
  // ../../packages/core/src/storage/wiki.ts
12995
- import { basename as basename5, dirname as dirname15, join as join22 } from "path";
13075
+ import { basename as basename5, dirname as dirname15, join as join23 } from "path";
12996
13076
  function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
12997
- return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join22(workspaceDir, "wiki");
13077
+ return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join23(workspaceDir, "wiki");
12998
13078
  }
12999
13079
  var init_wiki = __esm(async () => {
13000
13080
  await init_storage_host();
@@ -13002,8 +13082,8 @@ var init_wiki = __esm(async () => {
13002
13082
 
13003
13083
  // ../../packages/core/src/agents/archiver.ts
13004
13084
  import { randomUUID as randomUUID11 } from "crypto";
13005
- import { existsSync as existsSync22, readdirSync as readdirSync5, readFileSync as readFileSync18, statSync as statSync7 } from "fs";
13006
- import { join as join23 } from "path";
13085
+ import { existsSync as existsSync22, readdirSync as readdirSync5, readFileSync as readFileSync18, statSync as statSync8 } from "fs";
13086
+ import { join as join24 } from "path";
13007
13087
  function resolveMemoryLanguage() {
13008
13088
  const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
13009
13089
  return override && override.length > 0 ? override : resolveOutputLanguage();
@@ -13261,10 +13341,10 @@ function distillOneLine(summaryMd) {
13261
13341
  return "";
13262
13342
  }
13263
13343
  function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
13264
- const dir = join23(storage.getWikiDir(), "summaries");
13344
+ const dir = join24(storage.getWikiDir(), "summaries");
13265
13345
  if (!storage.fileExists(dir))
13266
13346
  return null;
13267
- const predicted = join23(dir, wikiSummaryFilename(date, topicTitle, topicId));
13347
+ const predicted = join24(dir, wikiSummaryFilename(date, topicTitle, topicId));
13268
13348
  if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
13269
13349
  return predicted;
13270
13350
  let best = null;
@@ -13272,7 +13352,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
13272
13352
  if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
13273
13353
  continue;
13274
13354
  }
13275
- const p = join23(dir, f);
13355
+ const p = join24(dir, f);
13276
13356
  try {
13277
13357
  const m = storage.fileModifiedAt(p);
13278
13358
  if (m >= sinceMs && (!best || m > best.mtime))
@@ -13361,8 +13441,8 @@ var init_archiver = __esm(async () => {
13361
13441
  fileExists: existsSync22,
13362
13442
  listDirectory: readdirSync5,
13363
13443
  readTextFile: (path) => readFileSync18(path, "utf-8"),
13364
- fileSize: (path) => statSync7(path).size,
13365
- fileModifiedAt: (path) => statSync7(path).mtimeMs,
13444
+ fileSize: (path) => statSync8(path).size,
13445
+ fileModifiedAt: (path) => statSync8(path).mtimeMs,
13366
13446
  getGeneralTopicId: (userId, sourceTopicId) => {
13367
13447
  const source = sourceTopicId ? getTopic(sourceTopicId) : null;
13368
13448
  return source ? ensurePersonalGeneral(userId, source.surface, {
@@ -13486,13 +13566,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
13486
13566
 
13487
13567
  // ../../packages/core/src/storage/topic-archive.ts
13488
13568
  import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync12 } from "fs";
13489
- import { join as join24 } from "path";
13569
+ import { join as join25 } from "path";
13490
13570
  function archiveTopicMessages(topicId, topicTitle, options = {}) {
13491
13571
  const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
13492
13572
  if (rows.length === 0)
13493
13573
  return null;
13494
13574
  const safeTopic = sanitizeTopicName(topicTitle, true);
13495
- const archiveDir = join24(getSharedWikiDir(), "archive");
13575
+ const archiveDir = join25(getSharedWikiDir(), "archive");
13496
13576
  mkdirSync14(archiveDir, { recursive: true });
13497
13577
  const date = new Date().toISOString().slice(0, 10);
13498
13578
  const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
@@ -13505,7 +13585,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
13505
13585
  let path;
13506
13586
  while (true) {
13507
13587
  filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
13508
- path = join24(archiveDir, filename);
13588
+ path = join25(archiveDir, filename);
13509
13589
  try {
13510
13590
  writeFileSync12(path, body, { flag: "wx" });
13511
13591
  break;
@@ -13550,7 +13630,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
13550
13630
  const entries = readRawConversation(userId, topicTitle);
13551
13631
  if (entries.length === 0)
13552
13632
  return null;
13553
- const archiveDir = join24(getSharedWikiDir(), "archive");
13633
+ const archiveDir = join25(getSharedWikiDir(), "archive");
13554
13634
  mkdirSync14(archiveDir, { recursive: true });
13555
13635
  const safeTopic = sanitizeTopicName(topicTitle, true);
13556
13636
  const date = new Date().toISOString().slice(0, 10);
@@ -13578,7 +13658,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
13578
13658
  let counter = 1;
13579
13659
  while (true) {
13580
13660
  const suffix = counter === 1 ? "" : `_${counter}`;
13581
- const path = join24(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
13661
+ const path = join25(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
13582
13662
  try {
13583
13663
  writeFileSync12(path, body, { flag: "wx" });
13584
13664
  logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
@@ -13906,7 +13986,7 @@ var init_idle_archiver = __esm(async () => {
13906
13986
  // ../../packages/core/src/storage/token-stats.ts
13907
13987
  import { createHash as createHash7 } from "crypto";
13908
13988
  import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync13 } from "fs";
13909
- import { join as join25 } from "path";
13989
+ import { join as join26 } from "path";
13910
13990
  function emptyBucket() {
13911
13991
  return {
13912
13992
  inputTokens: 0,
@@ -13925,7 +14005,7 @@ function queriesPath(userId) {
13925
14005
  const fileId = tokenStatsFileId(userId);
13926
14006
  const logDir = resolveStorageLogDir();
13927
14007
  mkdirSync15(logDir, { recursive: true });
13928
- return join25(logDir, `token-queries-${fileId}.jsonl`);
14008
+ return join26(logDir, `token-queries-${fileId}.jsonl`);
13929
14009
  }
13930
14010
  function loadRecords(userId) {
13931
14011
  try {
@@ -14145,6 +14225,8 @@ var init_token_stats = __esm(async () => {
14145
14225
  "codex:gpt-5.6-terra": { input: 2.5, cacheRead: 0.25, output: 15 },
14146
14226
  "codex:gpt-5.6-luna": { input: 1, cacheRead: 0.1, output: 6 },
14147
14227
  "claude:fable": { input: 10, cacheWrite: 12.5, cacheRead: 0.25, output: 50 },
14228
+ "claude:fable-5.2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
14229
+ "claude:claude-fable-5-2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
14148
14230
  "claude:opus": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
14149
14231
  "claude:claude-opus-5-5": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
14150
14232
  "claude:sonnet": { input: 2, cacheWrite: 2.5, cacheRead: 0.2, output: 10 },
@@ -14550,7 +14632,7 @@ var init_usage_alert = __esm(() => {
14550
14632
  import { randomUUID as randomUUID12 } from "crypto";
14551
14633
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync15 } from "fs";
14552
14634
  import { tmpdir as tmpdir4 } from "os";
14553
- import { join as join26 } from "path";
14635
+ import { join as join27 } from "path";
14554
14636
  async function fenceTopicWork(topicId, maintenance) {
14555
14637
  for (const queryId of cancelRuntimeUserTurnRequestsBeforeEpoch(topicId, maintenance.epoch)) {
14556
14638
  WsHub.get().broadcastAborted(topicId, queryId, "stopped");
@@ -14759,7 +14841,7 @@ function formatCompactElapsed(startedAt) {
14759
14841
  async function summarizeTopicContext(request) {
14760
14842
  const startedAt = Date.now();
14761
14843
  const sessionIds = [];
14762
- const compactCwd = mkdtempSync2(join26(tmpdir4(), "negotium-compact-"));
14844
+ const compactCwd = mkdtempSync2(join27(tmpdir4(), "negotium-compact-"));
14763
14845
  const abortController = new AbortController;
14764
14846
  const relayAbort = () => abortController.abort(request.signal?.reason);
14765
14847
  if (request.signal?.aborted)
@@ -14786,7 +14868,7 @@ async function summarizeTopicContext(request) {
14786
14868
  let error = "";
14787
14869
  let toolViolation = false;
14788
14870
  let compactionLogCalls = 0;
14789
- const compactionLogPath = join26(compactCwd, "conversation.log");
14871
+ const compactionLogPath = join27(compactCwd, "conversation.log");
14790
14872
  try {
14791
14873
  const compactionMcp = useCompactionLog ? {
14792
14874
  compact_log: {
@@ -15545,14 +15627,14 @@ var init_derive = __esm(async () => {
15545
15627
  });
15546
15628
 
15547
15629
  // ../../packages/core/src/query/session-inbox-path.ts
15548
- import { join as join27 } from "path";
15630
+ import { join as join28 } from "path";
15549
15631
  function sessionInboxPath(userId, topicId) {
15550
15632
  const key = Buffer.from(topicId, "utf8").toString("base64url");
15551
- return join27(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
15633
+ return join28(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
15552
15634
  }
15553
15635
  function scheduledSessionInboxPath(userId, topicId) {
15554
15636
  const key = Buffer.from(topicId, "utf8").toString("base64url");
15555
- return join27(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
15637
+ return join28(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
15556
15638
  }
15557
15639
  var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
15558
15640
  var init_session_inbox_path = __esm(() => {
@@ -15560,12 +15642,12 @@ var init_session_inbox_path = __esm(() => {
15560
15642
  });
15561
15643
 
15562
15644
  // ../../packages/core/src/storage/session-inbox-signal.ts
15563
- import { join as join28 } from "path";
15645
+ import { join as join29 } from "path";
15564
15646
  var SESSION_INBOX_WAKE_FILE, listeners;
15565
15647
  var init_session_inbox_signal = __esm(() => {
15566
15648
  init_config();
15567
15649
  init_logger();
15568
- SESSION_INBOX_WAKE_FILE = join28(SESSION_INBOX_DIR, ".wake");
15650
+ SESSION_INBOX_WAKE_FILE = join29(SESSION_INBOX_DIR, ".wake");
15569
15651
  listeners = new Set;
15570
15652
  });
15571
15653
 
@@ -15603,13 +15685,13 @@ var init_session_inbox = __esm(async () => {
15603
15685
 
15604
15686
  // ../../packages/core/src/query/session-inbox-cleanup.ts
15605
15687
  import { unlinkSync as unlinkSync16 } from "fs";
15606
- import { basename as basename6, join as join29 } from "path";
15688
+ import { basename as basename6, join as join30 } from "path";
15607
15689
  function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
15608
15690
  const live = sessionInboxPath(userId, topicId);
15609
15691
  const scheduled = scheduledSessionInboxPath(userId, topicId);
15610
15692
  const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
15611
15693
  if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename6(legacyTopicTitle) === legacyTopicTitle) {
15612
- const legacyBase = join29(SESSION_INBOX_DIR, userId, legacyTopicTitle);
15694
+ const legacyBase = join30(SESSION_INBOX_DIR, userId, legacyTopicTitle);
15613
15695
  for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
15614
15696
  candidates.add(`${legacyBase}${suffix}`);
15615
15697
  }
@@ -15851,33 +15933,33 @@ import {
15851
15933
  openSync as openSync3,
15852
15934
  readdirSync as readdirSync6,
15853
15935
  readFileSync as readFileSync19,
15854
- statSync as statSync8,
15936
+ statSync as statSync9,
15855
15937
  unlinkSync as unlinkSync17,
15856
15938
  writeFileSync as writeFileSync16
15857
15939
  } from "fs";
15858
- import { dirname as dirname17, join as join30 } from "path";
15940
+ import { dirname as dirname17, join as join31 } from "path";
15859
15941
  function pendingAskDir(userId) {
15860
15942
  const rawUserId = String(userId);
15861
15943
  const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash9("sha256").update(rawUserId).digest("hex")}`;
15862
- return join30(resolveStorageSessionAsksDir(), safeUserId);
15944
+ return join31(resolveStorageSessionAsksDir(), safeUserId);
15863
15945
  }
15864
15946
  function encodeAskKey(key) {
15865
15947
  return JSON.stringify([key.from, key.to]);
15866
15948
  }
15867
15949
  function pendingAskPath(key) {
15868
15950
  const digest = createHash9("sha256").update(encodeAskKey(key)).digest("hex");
15869
- return join30(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
15951
+ return join31(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
15870
15952
  }
15871
15953
  function v2PendingAskPath(key) {
15872
15954
  const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
15873
- return join30(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
15955
+ return join31(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
15874
15956
  }
15875
15957
  function legacyPendingAskPath(key) {
15876
15958
  if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
15877
15959
  return null;
15878
15960
  }
15879
15961
  const dir = pendingAskDir(key.userId);
15880
- const candidate = join30(dir, `${key.from}___${key.to}.pending`);
15962
+ const candidate = join31(dir, `${key.from}___${key.to}.pending`);
15881
15963
  return dirname17(candidate) === dir ? candidate : null;
15882
15964
  }
15883
15965
  function parsePendingAskFilename(fileName) {
@@ -15903,7 +15985,7 @@ function readPendingAskFile(path, fallback) {
15903
15985
  if (!raw)
15904
15986
  return null;
15905
15987
  if (!raw.startsWith("{")) {
15906
- const ts = new Date(statSync8(path).mtimeMs).toISOString();
15988
+ const ts = new Date(statSync9(path).mtimeMs).toISOString();
15907
15989
  return {
15908
15990
  userId: fallback.userId,
15909
15991
  from: fallback.from,
@@ -16029,7 +16111,7 @@ function deletePendingAsksForTopic(args) {
16029
16111
  }
16030
16112
  let deleted = 0;
16031
16113
  for (const fileName of files) {
16032
- const path = join30(dir, fileName);
16114
+ const path = join31(dir, fileName);
16033
16115
  const parsed = parsePendingAskFilename(fileName);
16034
16116
  const record = readPendingAskFile(path, {
16035
16117
  userId: args.userId,
@@ -17129,7 +17211,7 @@ var init_lifecycle = __esm(async () => {
17129
17211
 
17130
17212
  // ../../packages/core/src/runtime/attachments.ts
17131
17213
  import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17 } from "fs";
17132
- import { basename as basename7, join as join31 } from "path";
17214
+ import { basename as basename7, join as join32 } from "path";
17133
17215
  function workspaceCwdFor(topicId) {
17134
17216
  return resolveTopicWorkspaceDir(topicId);
17135
17217
  }
@@ -17142,7 +17224,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
17142
17224
  if (!attachmentIds?.length)
17143
17225
  return [];
17144
17226
  const out = [];
17145
- const destDir = join31(workspaceCwdFor(topicId), "attachments", queryId);
17227
+ const destDir = join32(workspaceCwdFor(topicId), "attachments", queryId);
17146
17228
  for (const rawId of attachmentIds) {
17147
17229
  if (typeof rawId !== "string")
17148
17230
  continue;
@@ -17159,7 +17241,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
17159
17241
  mkdirSync19(destDir, { recursive: true });
17160
17242
  const index = String(out.length + 1).padStart(2, "0");
17161
17243
  const safeName = safeAttachmentFilename(attachment.filename, fileId);
17162
- const destPath = join31(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
17244
+ const destPath = join32(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
17163
17245
  copyFileSync2(sourcePath, destPath);
17164
17246
  out.push({
17165
17247
  id: attachment.id,
@@ -18827,7 +18909,7 @@ var init_visual_html = __esm(() => {
18827
18909
 
18828
18910
  // ../../packages/core/src/runtime/visuals.ts
18829
18911
  import { realpathSync as realpathSync6 } from "fs";
18830
- import { isAbsolute as isAbsolute5, resolve as resolve17 } from "path";
18912
+ import { isAbsolute as isAbsolute6, resolve as resolve17 } from "path";
18831
18913
  function activeVisualHtmlForPrompt(html) {
18832
18914
  if (html.length <= ACTIVE_VISUAL_PROMPT_MAX_CHARS) {
18833
18915
  return { html, omittedChars: 0 };
@@ -18932,7 +19014,7 @@ function locateVisualMediaInput(topicId, input) {
18932
19014
  }
18933
19015
  const rawPath = input.file_path.trim();
18934
19016
  const cwd = workspaceCwdFor(topicId);
18935
- const candidate = isAbsolute5(rawPath) ? rawPath : resolve17(cwd, rawPath);
19017
+ const candidate = isAbsolute6(rawPath) ? rawPath : resolve17(cwd, rawPath);
18936
19018
  let realCandidate;
18937
19019
  try {
18938
19020
  realCandidate = realpathSync6(candidate);
@@ -18988,8 +19070,8 @@ var init_visuals = __esm(async () => {
18988
19070
 
18989
19071
  // ../../packages/core/src/runtime/turn-event-stream.ts
18990
19072
  import { randomUUID as randomUUID18 } from "crypto";
18991
- import { realpathSync as realpathSync7, statSync as statSync9 } from "fs";
18992
- import { isAbsolute as isAbsolute6, resolve as resolve18 } from "path";
19073
+ import { realpathSync as realpathSync7, statSync as statSync10 } from "fs";
19074
+ import { isAbsolute as isAbsolute7, resolve as resolve18 } from "path";
18993
19075
  function sessionEventMatchesCurrentExecution(topicId, queryId, agent, model) {
18994
19076
  if (getRoomQuery(topicId)?.queryId !== queryId)
18995
19077
  return false;
@@ -19015,6 +19097,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19015
19097
  let accumulatedText = "";
19016
19098
  let pendingText = "";
19017
19099
  let previewText = "";
19100
+ let blockStart = null;
19101
+ let lastCompletedBlock = "";
19018
19102
  let pendingMessage = null;
19019
19103
  let previewTimer = null;
19020
19104
  const clearPreviewTimer = () => {
@@ -19129,6 +19213,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19129
19213
  const text = pendingText.trimEnd();
19130
19214
  pendingText = "";
19131
19215
  previewText = "";
19216
+ lastCompletedBlock = "";
19217
+ blockStart = null;
19132
19218
  if (silent || !text.trim()) {
19133
19219
  if (identity && !silent) {
19134
19220
  hub.broadcastMessageUpdated(topicId, identity.id, { deleted: true, text: "" });
@@ -19197,6 +19283,9 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19197
19283
  }
19198
19284
  switch (event.type) {
19199
19285
  case "text_delta": {
19286
+ if (!pendingSawDelta) {
19287
+ blockStart = { accumulated: accumulatedText.length, pending: pendingText.length };
19288
+ }
19200
19289
  pendingSawDelta = true;
19201
19290
  const incoming = event.content;
19202
19291
  accumulatedText += incoming;
@@ -19212,9 +19301,26 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19212
19301
  break;
19213
19302
  case "text":
19214
19303
  previewText = "";
19215
- if (pendingSawDelta) {
19216
- pendingSawDelta = false;
19217
- break;
19304
+ {
19305
+ const completed = event.content.trim();
19306
+ const repeatsPreviousBlock = completed !== "" && completed === lastCompletedBlock;
19307
+ if (pendingSawDelta) {
19308
+ pendingSawDelta = false;
19309
+ if (repeatsPreviousBlock && blockStart) {
19310
+ accumulatedText = accumulatedText.slice(0, blockStart.accumulated);
19311
+ pendingText = pendingText.slice(0, blockStart.pending);
19312
+ assistantContextTokens = estimateTextTokens(accumulatedText);
19313
+ broadcastContextProgress();
19314
+ } else if (completed) {
19315
+ lastCompletedBlock = completed;
19316
+ }
19317
+ blockStart = null;
19318
+ break;
19319
+ }
19320
+ if (repeatsPreviousBlock)
19321
+ break;
19322
+ if (completed)
19323
+ lastCompletedBlock = completed;
19218
19324
  }
19219
19325
  {
19220
19326
  const incoming = event.content;
@@ -19390,7 +19496,7 @@ ${JSON.stringify(event.input ?? {})}`);
19390
19496
  case "file":
19391
19497
  if (!silent && peerBridge) {
19392
19498
  const cwd = workspaceCwdFor(topicId);
19393
- const path = isAbsolute6(event.path) ? event.path : resolve18(cwd, event.path);
19499
+ const path = isAbsolute7(event.path) ? event.path : resolve18(cwd, event.path);
19394
19500
  if (!isPathInside(cwd, path)) {
19395
19501
  logger.warn({ topicId, path }, "peer output file is outside the topic workspace");
19396
19502
  break;
@@ -19398,7 +19504,7 @@ ${JSON.stringify(event.input ?? {})}`);
19398
19504
  let safePath;
19399
19505
  try {
19400
19506
  safePath = realpathSync7(path);
19401
- if (!statSync9(safePath).isFile()) {
19507
+ if (!statSync10(safePath).isFile()) {
19402
19508
  logger.warn({ topicId, path }, "peer output path is not a regular file");
19403
19509
  break;
19404
19510
  }
@@ -19728,9 +19834,9 @@ var init_turn_session = __esm(async () => {
19728
19834
 
19729
19835
  // ../../packages/core/src/storage/app-settings.ts
19730
19836
  import { existsSync as existsSync23, mkdirSync as mkdirSync20, readFileSync as readFileSync20, writeFileSync as writeFileSync18 } from "fs";
19731
- import { dirname as dirname18, join as join32 } from "path";
19837
+ import { dirname as dirname18, join as join33 } from "path";
19732
19838
  function settingsFile() {
19733
- return join32(resolveStorageDataDir(), "otium-settings.json");
19839
+ return join33(resolveStorageDataDir(), "otium-settings.json");
19734
19840
  }
19735
19841
  function getGlobalAiName() {
19736
19842
  const path = settingsFile();
@@ -19751,8 +19857,8 @@ var init_app_settings = __esm(async () => {
19751
19857
 
19752
19858
  // ../../packages/core/src/runtime/turn-runner.ts
19753
19859
  import { randomUUID as randomUUID19 } from "crypto";
19754
- import { existsSync as existsSync24, mkdirSync as mkdirSync21, readdirSync as readdirSync7, statSync as statSync10 } from "fs";
19755
- import { join as join33 } from "path";
19860
+ import { existsSync as existsSync24, mkdirSync as mkdirSync21, readdirSync as readdirSync7, statSync as statSync11 } from "fs";
19861
+ import { join as join34 } from "path";
19756
19862
  function withDefaultPlaywright(configuredMcp, isManager) {
19757
19863
  if (isManager)
19758
19864
  return configuredMcp;
@@ -19816,7 +19922,7 @@ function appendAskReplyMessage(topicId, text, sourceLabel, body, kind, agentType
19816
19922
  return message;
19817
19923
  }
19818
19924
  function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
19819
- const preferred = join33(directory, preferredFilename);
19925
+ const preferred = join34(directory, preferredFilename);
19820
19926
  if (preferExact && existsSync24(preferred))
19821
19927
  return preferred;
19822
19928
  let newestLegacyId = null;
@@ -19827,8 +19933,8 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
19827
19933
  const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
19828
19934
  if (!titleMatch && !legacyIdMatch)
19829
19935
  continue;
19830
- const path = join33(directory, filename);
19831
- const mtimeMs = statSync10(path).mtimeMs;
19936
+ const path = join34(directory, filename);
19937
+ const mtimeMs = statSync11(path).mtimeMs;
19832
19938
  if (titleMatch) {
19833
19939
  if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
19834
19940
  newestTitle = { path, mtimeMs };
@@ -19841,10 +19947,10 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
19841
19947
  return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
19842
19948
  }
19843
19949
  function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
19844
- const briefFile = resolveWikiMirrorPath(join33(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
19845
- const hasBriefFile = existsSync24(briefFile) && statSync10(briefFile).isFile();
19846
- const latestSummaryCandidate = resolveWikiMirrorPath(join33(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
19847
- const latestSummaryFile = existsSync24(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
19950
+ const briefFile = resolveWikiMirrorPath(join34(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
19951
+ const hasBriefFile = existsSync24(briefFile) && statSync11(briefFile).isFile();
19952
+ const latestSummaryCandidate = resolveWikiMirrorPath(join34(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
19953
+ const latestSummaryFile = existsSync24(latestSummaryCandidate) && statSync11(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
19848
19954
  return { briefFile, hasBriefFile, latestSummaryFile };
19849
19955
  }
19850
19956
  async function streamAgentEvents(topicId, topicTitle, queryId, events, control, agentType, model, effort, userId, retryableSessionExpired = true, onSessionId, execution) {
@@ -20355,6 +20461,11 @@ function startAiTurn(params) {
20355
20461
  }
20356
20462
  if (decision.action === "abort-replace") {
20357
20463
  const running = decision.running;
20464
+ const runningRequestIds = new Set(running.durableRequestIds ?? []);
20465
+ if (durableRequestIds.length > 0 && durableRequestIds.every((requestId) => runningRequestIds.has(requestId))) {
20466
+ logger.warn({ topicId, queryId: running.queryId, durableRequestIds }, "ai: ignored a replay of the durable request this room is already running");
20467
+ return running.queryId;
20468
+ }
20358
20469
  if (isUserOrigin(running.origin) && !sameTurnActor(running.actorUserId, params.actorUserId)) {
20359
20470
  const queuedQueryId = waitToStartRemoteUserTurn({
20360
20471
  ...params,
@@ -20683,7 +20794,8 @@ function startAiTurn(params) {
20683
20794
  const enabledMcp = withDefaultPlaywright(configuredMcp, isManager);
20684
20795
  const playwrightRequested = !isManager && enabledMcp.includes("playwright");
20685
20796
  const browserProfileOwner = isTopicBrowserProfileOwner(topic.id, userId);
20686
- const wantsPlaywright = playwrightRequested && browserProfileOwner;
20797
+ const wantsPlaywright = playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "chrome";
20798
+ const wantsEgoBrowser = playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "egolite";
20687
20799
  const turnMcpEnabled = browserProfileOwner ? enabledMcp : enabledMcp.filter((name) => name !== "playwright");
20688
20800
  const wantsBgBash = !isManager && enabledMcp.includes("background-bash");
20689
20801
  async function* runWithPlaywright() {
@@ -20713,6 +20825,15 @@ function startAiTurn(params) {
20713
20825
  let playwrightCapability;
20714
20826
  let playwrightInstanceKey;
20715
20827
  let bgBashPort;
20828
+ if (wantsEgoBrowser) {
20829
+ try {
20830
+ const command = await prepareEgoBrowser();
20831
+ turnReminders.push(`<system-reminder>Browser backend: ego lite. Browser automation is authorized for this topic owner on this Negotium node. Use the foreground shell with executable ${JSON.stringify(command)}. Read its full "skill" guide before the first browser action. Reuse this goal's task space across turns. No Chrome browser_* MCP tools are available. This probe checked only the CLI; actual browser connection and login must be verified when used.</system-reminder>`);
20832
+ } catch (err) {
20833
+ logger.warn({ topicId, err }, "ai: ego-browser CLI unavailable");
20834
+ turnReminders.push("<system-reminder>ego lite browser automation is UNAVAILABLE this turn: the ego-browser executable could not be found or its --version probe failed on this Negotium node. Tell the user when browser work is needed. Do not start Chrome, install software, or use another browser as a fallback.</system-reminder>");
20835
+ }
20836
+ }
20716
20837
  if (wantsPlaywright) {
20717
20838
  try {
20718
20839
  playwrightInstanceKey = makeInstanceKey(userId, topic.id);
@@ -20743,7 +20864,7 @@ function startAiTurn(params) {
20743
20864
  }
20744
20865
  }
20745
20866
  if (playwrightRequested && !browserProfileOwner) {
20746
- turnReminders.push("<system-reminder>Browser tools are unavailable in this turn because browser profiles are private to the topic owner. Do not attempt browser calls or ask to reuse the owner's login state.</system-reminder>");
20867
+ turnReminders.push("<system-reminder>Browser tools are unavailable in this turn because browser profiles are private to the topic owner. Do not attempt browser calls, run ego-browser through a shell, or ask to reuse the owner's login state.</system-reminder>");
20747
20868
  }
20748
20869
  if (consumePlaywrightUnavailable(userId, topic.title)) {
20749
20870
  turnReminders.push("<system-reminder>Playwright browser tools are UNAVAILABLE this turn. The `mcp__playwright__*` tools have been removed from this turn's catalog because the long-lived browser MCP could not be prepared. Do not attempt to call browser tools. If browser interaction is required, ask the user to retry shortly or use a non-browser alternative.</system-reminder>");
@@ -21097,6 +21218,8 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
21097
21218
  var PLAYWRIGHT_UNAVAILABLE_NOTICE_COOLDOWN_MS, ASK_REPLY_INJECT_BATCH_MS = 500, playwrightUnavailableNoticeAt, askReplyInjectBatcher, remoteInjectWaiters;
21098
21219
  var init_turn_runner = __esm(async () => {
21099
21220
  init_manager();
21221
+ init_browser_backend();
21222
+ init_config();
21100
21223
  init_constants();
21101
21224
  init_logger();
21102
21225
  init_builders();
@@ -21161,8 +21284,8 @@ var init_turn_runner = __esm(async () => {
21161
21284
  // ../../packages/core/src/agents/auth-check.ts
21162
21285
  import { execFileSync as execFileSync7 } from "child_process";
21163
21286
  import { existsSync as existsSync25 } from "fs";
21164
- import { homedir as homedir8, platform } from "os";
21165
- import { join as join34 } from "path";
21287
+ import { homedir as homedir9, platform } from "os";
21288
+ import { join as join35 } from "path";
21166
21289
  function hasMaestroCredential(host, key, userId) {
21167
21290
  if (userId && host.getVaultValue(userId, key)?.trim())
21168
21291
  return true;
@@ -21182,7 +21305,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
21182
21305
  case "claude": {
21183
21306
  if (host.environment.ANTHROPIC_API_KEY)
21184
21307
  return { ok: true };
21185
- const path = join34(host.homeDirectory(), ".claude", ".credentials.json");
21308
+ const path = join35(host.homeDirectory(), ".claude", ".credentials.json");
21186
21309
  if (host.operatingSystem() === "darwin") {
21187
21310
  if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
21188
21311
  return { ok: true };
@@ -21241,7 +21364,7 @@ var init_auth_check = __esm(async () => {
21241
21364
  codexAuthFilePath,
21242
21365
  exists: existsSync25,
21243
21366
  environment: process.env,
21244
- homeDirectory: homedir8,
21367
+ homeDirectory: homedir9,
21245
21368
  operatingSystem: platform,
21246
21369
  hasMacOsCredential(service) {
21247
21370
  try {
@@ -21338,7 +21461,7 @@ function createSubagentLifecycle(host) {
21338
21461
  }
21339
21462
  function canSpawnSubagentsFromTopic(topicId) {
21340
21463
  const topic = host.storage.getTopic(topicId);
21341
- return topic?.kind === "agent" && computeSubagentDepth(topicId) < limits.maxDepth;
21464
+ return topic?.kind === "agent" && topic.surface !== "otium" && computeSubagentDepth(topicId) < limits.maxDepth;
21342
21465
  }
21343
21466
  function patchSubagentCard(parentTopicId, cardMessageId, patch) {
21344
21467
  const current = host.storage.getMessage(parentTopicId, cardMessageId)?.subagentCard;
@@ -22279,11 +22402,11 @@ import {
22279
22402
  readdirSync,
22280
22403
  readFileSync as readFileSync3,
22281
22404
  renameSync,
22282
- statSync,
22405
+ statSync as statSync2,
22283
22406
  unlinkSync as unlinkSync2,
22284
22407
  writeFileSync as writeFileSync2
22285
22408
  } from "fs";
22286
- import { basename, dirname as dirname2, join as join2, relative, resolve as resolve2 } from "path";
22409
+ import { basename, dirname as dirname2, join as join3, relative, resolve as resolve2 } from "path";
22287
22410
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
22288
22411
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
22289
22412
  import {
@@ -22585,7 +22708,7 @@ function acquireFileLock(path) {
22585
22708
  try {
22586
22709
  try {
22587
22710
  const staleToken = readFileSync3(lockPath, "utf-8");
22588
- if (Date.now() - statSync(lockPath).mtimeMs > FILE_LOCK_STALE_MS && readFileSync3(lockPath, "utf-8") === staleToken) {
22711
+ if (Date.now() - statSync2(lockPath).mtimeMs > FILE_LOCK_STALE_MS && readFileSync3(lockPath, "utf-8") === staleToken) {
22589
22712
  unlinkSync2(lockPath);
22590
22713
  continue;
22591
22714
  }
@@ -22830,7 +22953,7 @@ function indexWikiSearchDocument(kind, key, text) {
22830
22953
  if (!index)
22831
22954
  return false;
22832
22955
  try {
22833
- const stat = statSync(path);
22956
+ const stat = statSync2(path);
22834
22957
  index.upsert({ kind, key, path, mtimeMs: stat.mtimeMs, size: stat.size }, prepareWikiSearchDocument(kind, key, text));
22835
22958
  return true;
22836
22959
  } catch {
@@ -22914,7 +23037,7 @@ function indexCandidateExists(candidate) {
22914
23037
  if (relativePath.startsWith("..") || relativePath.startsWith("/"))
22915
23038
  return false;
22916
23039
  try {
22917
- return statSync(filePath).isFile();
23040
+ return statSync2(filePath).isFile();
22918
23041
  } catch {
22919
23042
  return false;
22920
23043
  }
@@ -23026,13 +23149,13 @@ function wikiQuery(args) {
23026
23149
  try {
23027
23150
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
23028
23151
  if (entry.isDirectory()) {
23029
- const sub = join2(dir, entry.name);
23152
+ const sub = join3(dir, entry.name);
23030
23153
  if (label === "articles" || label === "skills") {
23031
23154
  try {
23032
23155
  for (const f of readdirSync(sub, { withFileTypes: true })) {
23033
23156
  if (!f.isFile() || !f.name.endsWith(".md"))
23034
23157
  continue;
23035
- const fp = join2(sub, f.name);
23158
+ const fp = join3(sub, f.name);
23036
23159
  try {
23037
23160
  const text = readFileSync3(fp, "utf-8");
23038
23161
  const key = `${entry.name}/${f.name.replace(/\.md$/i, "")}`;
@@ -23053,7 +23176,7 @@ function wikiQuery(args) {
23053
23176
  if (label === "topic" && canReadTopicMemory && !canReadTopicMemory(entry.name.replace(/\.md$/i, ""), runtime().userId)) {
23054
23177
  continue;
23055
23178
  }
23056
- const fp = join2(dir, entry.name);
23179
+ const fp = join3(dir, entry.name);
23057
23180
  try {
23058
23181
  const text = readFileSync3(fp, "utf-8");
23059
23182
  const key = entry.name.replace(/\.md$/i, "");
@@ -23769,7 +23892,7 @@ function collectIndexableDocuments() {
23769
23892
  const sources = [];
23770
23893
  function add(kind, key, path) {
23771
23894
  try {
23772
- const stat = statSync(path);
23895
+ const stat = statSync2(path);
23773
23896
  if (!stat.isFile())
23774
23897
  return;
23775
23898
  sources.push({ kind, key, path, mtimeMs: stat.mtimeMs, size: stat.size });
@@ -23787,21 +23910,21 @@ function collectIndexableDocuments() {
23787
23910
  }
23788
23911
  for (const entry of entries) {
23789
23912
  if (entry.isFile() && entry.name.endsWith(".md")) {
23790
- add(kind, entry.name.replace(/\.md$/i, ""), join2(root, entry.name));
23913
+ add(kind, entry.name.replace(/\.md$/i, ""), join3(root, entry.name));
23791
23914
  continue;
23792
23915
  }
23793
23916
  if (!entry.isDirectory() || !allowSubdirectories)
23794
23917
  continue;
23795
23918
  let nested;
23796
23919
  try {
23797
- nested = readdirSync(join2(root, entry.name), { withFileTypes: true });
23920
+ nested = readdirSync(join3(root, entry.name), { withFileTypes: true });
23798
23921
  } catch {
23799
23922
  continue;
23800
23923
  }
23801
23924
  for (const file of nested) {
23802
23925
  if (!file.isFile() || !file.name.endsWith(".md"))
23803
23926
  continue;
23804
- add(kind, `${entry.name}/${file.name.replace(/\.md$/i, "")}`, join2(root, entry.name, file.name));
23927
+ add(kind, `${entry.name}/${file.name.replace(/\.md$/i, "")}`, join3(root, entry.name, file.name));
23805
23928
  }
23806
23929
  }
23807
23930
  }
@@ -23920,7 +24043,7 @@ function wikiDocumentExists(kind, slug) {
23920
24043
  if (relative(root, filePath).startsWith(".."))
23921
24044
  return false;
23922
24045
  try {
23923
- return statSync(filePath).isFile();
24046
+ return statSync2(filePath).isFile();
23924
24047
  } catch {
23925
24048
  return false;
23926
24049
  }
@@ -24212,7 +24335,7 @@ init_mcp_helpers();
24212
24335
  await init_codex_registry();
24213
24336
  import { spawn as spawn4 } from "child_process";
24214
24337
  import { existsSync as existsSync11, readdirSync as readdirSync3 } from "fs";
24215
- import { join as join11 } from "path";
24338
+ import { join as join12 } from "path";
24216
24339
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
24217
24340
  import { z } from "zod";
24218
24341
  function signalProcessTree(child, signal) {
@@ -24466,7 +24589,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
24466
24589
  server.tool("list_active_queries", "\uD604\uC7AC \uC0AC\uC6A9\uC790 \uBC94\uC704\uC5D0\uC11C \uC2E4\uD589 \uC911\uC778 \uD1A0\uD53D \uCFFC\uB9AC \uBAA9\uB85D\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4.", {}, async () => {
24467
24590
  if (!context.userId)
24468
24591
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
24469
- const stateDir = join11(USERS_LOG_DIR, context.userId, "active-queries");
24592
+ const stateDir = join12(USERS_LOG_DIR, context.userId, "active-queries");
24470
24593
  if (!existsSync11(stateDir))
24471
24594
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
24472
24595
  let files;
@@ -24479,7 +24602,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
24479
24602
  const entries = files.flatMap((file) => {
24480
24603
  if (!file.endsWith(".json"))
24481
24604
  return [];
24482
- const state = readJsonFile(join11(stateDir, file));
24605
+ const state = readJsonFile(join12(stateDir, file));
24483
24606
  if (!state)
24484
24607
  return [];
24485
24608
  const sinceMs = new Date(state.since).getTime();
@@ -24615,7 +24738,7 @@ import { z as z3 } from "zod";
24615
24738
  init_logger();
24616
24739
  await init_storage_host();
24617
24740
  import { existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync7 } from "fs";
24618
- import { dirname as dirname9, join as join12 } from "path";
24741
+ import { dirname as dirname9, join as join13 } from "path";
24619
24742
  var DECISION_STATUS_VALUES = [
24620
24743
  "proposed",
24621
24744
  "accepted",
@@ -24634,7 +24757,7 @@ function decisionScopeKey(opts) {
24634
24757
  return opts.topicId?.trim() || opts.session || "default";
24635
24758
  }
24636
24759
  function getDecisionFilePath(userId, scopeKey) {
24637
- return join12(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
24760
+ return join13(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
24638
24761
  }
24639
24762
  function readDecisions(userId, scopeKey) {
24640
24763
  const path = getDecisionFilePath(userId, scopeKey);
@@ -25327,11 +25450,11 @@ function protectMcpStdio(target) {
25327
25450
  }
25328
25451
  // ../../packages/core/src/mcp/factories/system-health.ts
25329
25452
  init_mcp_helpers();
25330
- import { execFile as execFile2 } from "child_process";
25453
+ import { execFile as execFile3 } from "child_process";
25331
25454
  import { cpus, loadavg } from "os";
25332
- import { promisify as promisify2 } from "util";
25455
+ import { promisify as promisify3 } from "util";
25333
25456
  import { McpServer as McpServer6 } from "@modelcontextprotocol/sdk/server/mcp.js";
25334
- var execFileAsync2 = promisify2(execFile2);
25457
+ var execFileAsync2 = promisify3(execFile3);
25335
25458
  function fmtBytes(bytes) {
25336
25459
  const gb = bytes / 1024 ** 3;
25337
25460
  return gb >= 1 ? `${gb.toFixed(1)}GB` : `${(bytes / 1024 ** 2).toFixed(0)}MB`;
@@ -25764,4 +25887,4 @@ export {
25764
25887
  protectMcpStdio
25765
25888
  };
25766
25889
 
25767
- //# debugId=0C7C49A3A20D84C664756E2164756E21
25890
+ //# debugId=6F1E51F59983617264756E2164756E21