@otium-team/negotium 0.23.13 → 0.23.14

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 +316 -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-3v58ejrk.js} +3 -3
  9. package/dist/{chunk-mk9x18jn.js.map → chunk-3v58ejrk.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 +476 -358
  20. package/dist/main.js.map +16 -15
  21. package/dist/mcp-factories.js +333 -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 +20 -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
package/dist/main.js CHANGED
@@ -32,6 +32,68 @@ var init_maestro_bootstrap_env = __esm(() => {
32
32
  process.env.MAESTRO_SDK_SILENT_BOOTSTRAP ??= "1";
33
33
  });
34
34
 
35
+ // ../../packages/core/src/platform/browser-backend.ts
36
+ import { execFile } from "child_process";
37
+ import { accessSync, constants, statSync } from "fs";
38
+ import { homedir } from "os";
39
+ import { delimiter, isAbsolute, join } from "path";
40
+ import { promisify } from "util";
41
+ function resolveBrowserBackend(value, findEgoBrowser = resolveEgoBrowserBin) {
42
+ const backend = value?.trim();
43
+ if (!backend)
44
+ return findEgoBrowser() ? "egolite" : "chrome";
45
+ if (backend === "chrome" || backend === "egolite")
46
+ return backend;
47
+ throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
48
+ }
49
+ function resolveEgoBrowserBin(path = process.env.PATH ?? "", home = homedir()) {
50
+ const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
51
+ const directories = [...path.split(delimiter).filter(isAbsolute), join(home, ".local", "bin")];
52
+ for (const directory of directories) {
53
+ for (const name of names) {
54
+ const candidate = join(directory, name);
55
+ try {
56
+ accessSync(candidate, constants.X_OK);
57
+ if (statSync(candidate).isFile())
58
+ return candidate;
59
+ } catch {}
60
+ }
61
+ }
62
+ return;
63
+ }
64
+ async function prepareEgoBrowser() {
65
+ const command = resolveEgoBrowserBin();
66
+ if (!command) {
67
+ throw new Error("ego-browser is not installed on this Negotium node or is not executable");
68
+ }
69
+ await promisify(execFile)(command, ["--version"], {
70
+ timeout: 5000,
71
+ maxBuffer: 16384,
72
+ windowsHide: true
73
+ });
74
+ return command;
75
+ }
76
+ var EGO_BROWSER_INSTRUCTIONS = `## Browser
77
+ This node uses ego lite through the official ego-browser CLI, using its existing logged-in browser.
78
+ The Chrome browser_* MCP tools are not registered. Never start browser-rs, point AB_CHROME at ego lite,
79
+ attach to its debugging port, or create a replacement browser/profile.
80
+ Use browser automation only when this turn's runtime reminder authorizes it. If it is unavailable or
81
+ the topic owner check denies access, do not bypass that decision through a shell or another tool.
82
+ When authorized, use the executable supplied by the runtime through your foreground shell tool.
83
+ Before the first browser action in a session, run that executable with "skill" and read its entire
84
+ installed-version guide. Use its "nodejs" command and documented APIs; do not assume Playwright APIs.
85
+ Create one task space for the user goal and retain its spaceId across commands and follow-up turns.
86
+ Use a unique task name tied to this topic and goal; never claim another topic's or a user's space
87
+ without explicit authorization. Existing login state is shared, not the user's other task spaces.
88
+ Stop when the user takes control. Hand off authentication to the user and resume the same task space
89
+ only after confirmation. On successful completion, call finish({ keep: [] }) unless the user needs
90
+ specific result tabs. On interruption, preserve the space for resumption; never kill the browser or
91
+ delete its profile. Do not close a space just because an AI turn ended.
92
+ Verify each action through the guide's observation APIs. Report CLI/browser errors as errors and do
93
+ not silently switch to Chrome. The CLI probe does not prove the browser is connected or authenticated.
94
+ Vault secret injection through browser-rs is not available here; do not copy secrets into scripts or logs.`;
95
+ var init_browser_backend = () => {};
96
+
35
97
  // ../../packages/core/src/types.ts
36
98
  function isAgentKind(value) {
37
99
  return typeof value === "string" && SUPPORTED_AGENTS.includes(value);
@@ -99,17 +161,17 @@ var init_logger = __esm(() => {
99
161
  import { execFileSync } from "child_process";
100
162
  import { randomBytes } from "crypto";
101
163
  import {
102
- accessSync,
164
+ accessSync as accessSync2,
103
165
  chmodSync,
104
- constants,
166
+ constants as constants2,
105
167
  existsSync,
106
168
  mkdirSync,
107
169
  readFileSync,
108
170
  writeFileSync
109
171
  } from "fs";
110
172
  import { createRequire } from "module";
111
- import { homedir } from "os";
112
- import { dirname, join, resolve } from "path";
173
+ import { homedir as homedir2 } from "os";
174
+ import { dirname, join as join2, resolve } from "path";
113
175
  import { fileURLToPath, pathToFileURL } from "url";
114
176
  function envText(envKey) {
115
177
  return readEnvText(process.env, envKey);
@@ -195,7 +257,7 @@ function resolveBrowserRsBin(envValue) {
195
257
  }
196
258
  const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
197
259
  try {
198
- accessSync(candidate, constants.X_OK);
260
+ accessSync2(candidate, constants2.X_OK);
199
261
  return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
200
262
  } catch {
201
263
  return;
@@ -205,7 +267,7 @@ function resolveBashRsBin(envValue) {
205
267
  const override = envValue?.trim();
206
268
  const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
207
269
  try {
208
- accessSync(candidate, constants.X_OK);
270
+ accessSync2(candidate, constants2.X_OK);
209
271
  return candidate;
210
272
  } catch {
211
273
  return;
@@ -243,7 +305,7 @@ function safeWorkspaceSegment(value, fallback) {
243
305
  return safeRuntimePathSegment(value, fallback);
244
306
  }
245
307
  function resolveTopicWorkspaceDir(topicId) {
246
- return join(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
308
+ return join2(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
247
309
  }
248
310
  function loadOrCreateLocalSecret(envKey, filename, options = {}) {
249
311
  const envValue = envText(envKey);
@@ -283,14 +345,15 @@ function resolveWhisperBackend() {
283
345
  return envText("WHISPER_BACKEND") === "mlx-whisper" ? "mlx-whisper" : "faster-whisper";
284
346
  }
285
347
  function codexAuthFilePath() {
286
- return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
348
+ return process.env.NEGOTIUM_CODEX_AUTH_FILE || join2(process.env.CODEX_HOME || join2(homedir2(), ".codex"), "auth.json");
287
349
  }
288
- 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;
350
+ 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;
289
351
  var init_config = __esm(() => {
352
+ init_browser_backend();
290
353
  init_config_helpers();
291
354
  init_logger();
292
355
  init_types();
293
- HOME = homedir();
356
+ HOME = homedir2();
294
357
  PROJECT_ROOT = resolveProjectRoot();
295
358
  STATE_DIR = resolveStateDir();
296
359
  WORKSPACE_DIR = resolveLocalStateDir("NEGOTIUM_WORKSPACE_DIR", "workspace");
@@ -298,6 +361,7 @@ var init_config = __esm(() => {
298
361
  SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
299
362
  CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
300
363
  BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
364
+ BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
301
365
  BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
302
366
  BINARIES_DIR = resolve(STATE_DIR, "binaries");
303
367
  SECRETS_DIR = resolve(STATE_DIR, "secrets");
@@ -462,8 +526,8 @@ var init_sqlite = __esm(async () => {
462
526
 
463
527
  // ../../packages/core/src/storage/storage-host.ts
464
528
  import { mkdirSync as mkdirSync2 } from "fs";
465
- import { homedir as homedir2 } from "os";
466
- import { dirname as dirname2, join as join2, resolve as resolve2 } from "path";
529
+ import { homedir as homedir3 } from "os";
530
+ import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
467
531
  function storageState() {
468
532
  const holder = globalThis;
469
533
  const existing = holder[STORAGE_HOST_STATE];
@@ -491,23 +555,23 @@ function envPath(name, fallback) {
491
555
  return resolve2(value || fallback);
492
556
  }
493
557
  function defaultStateDir() {
494
- return envPath("NEGOTIUM_STATE_DIR", join2(homedir2(), ".negotium"));
558
+ return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
495
559
  }
496
560
  function defaultDataDir() {
497
- return envPath("NEGOTIUM_DATA_DIR", join2(defaultStateDir(), "data"));
561
+ return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
498
562
  }
499
563
  function defaultLogDir() {
500
- return envPath("NEGOTIUM_LOG_DIR", join2(defaultStateDir(), "logs"));
564
+ return envPath("NEGOTIUM_LOG_DIR", join3(defaultStateDir(), "logs"));
501
565
  }
502
566
  function defaultWorkspaceDir() {
503
- return envPath("NEGOTIUM_WORKSPACE_DIR", join2(defaultStateDir(), "workspace"));
567
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join3(defaultStateDir(), "workspace"));
504
568
  }
505
569
  function defaultSessionAsksDir() {
506
- const runDir = envPath("NEGOTIUM_RUN_DIR", join2(defaultStateDir(), "runtime"));
507
- return join2(runDir, "session-asks");
570
+ const runDir = envPath("NEGOTIUM_RUN_DIR", join3(defaultStateDir(), "runtime"));
571
+ return join3(runDir, "session-asks");
508
572
  }
509
573
  function defaultSessionsDatabasePath() {
510
- return envPath("SESSIONS_DB_PATH", join2(resolveStorageDataDir(), "sessions.db"));
574
+ return envPath("SESSIONS_DB_PATH", join3(resolveStorageDataDir(), "sessions.db"));
511
575
  }
512
576
  function isSqliteBusy(error) {
513
577
  const message = error instanceof Error ? error.message : String(error);
@@ -564,7 +628,7 @@ function resolveStorageWorkspaceDir() {
564
628
  return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
565
629
  }
566
630
  function resolveStorageSharedWikiDir() {
567
- return storageState().configuredHost.sharedWikiDir ?? join2(resolveStorageWorkspaceDir(), "wiki");
631
+ return storageState().configuredHost.sharedWikiDir ?? join3(resolveStorageWorkspaceDir(), "wiki");
568
632
  }
569
633
  function registerStorageSchemaInitializer(initialize, priority = 100) {
570
634
  const initializers = storageState().schemaInitializers;
@@ -674,7 +738,7 @@ var init_vault_crypto = __esm(() => {
674
738
 
675
739
  // ../../packages/core/src/storage/vault.ts
676
740
  import { chmodSync as chmodSync2, mkdirSync as mkdirSync3 } from "fs";
677
- import { join as join3 } from "path";
741
+ import { join as join4 } from "path";
678
742
  function initializeVaultDatabase(database) {
679
743
  database.exec("PRAGMA journal_mode = WAL");
680
744
  database.exec("PRAGMA busy_timeout = 5000");
@@ -709,8 +773,8 @@ function initializeVaultDatabase(database) {
709
773
  }
710
774
  }
711
775
  function openVaultDatabase(dataDir) {
712
- const vaultDir = join3(dataDir, "vault");
713
- const path = join3(vaultDir, "vault.db");
776
+ const vaultDir = join4(dataDir, "vault");
777
+ const path = join4(vaultDir, "vault.db");
714
778
  mkdirSync3(vaultDir, { recursive: true, mode: 448 });
715
779
  const database = new Database(path, { create: true });
716
780
  chmodSync2(path, 384);
@@ -850,8 +914,8 @@ var init_vault = __esm(async () => {
850
914
  // ../../packages/core/src/agents/auth-check.ts
851
915
  import { execFileSync as execFileSync2 } from "child_process";
852
916
  import { existsSync as existsSync2 } from "fs";
853
- import { homedir as homedir3, platform } from "os";
854
- import { join as join4 } from "path";
917
+ import { homedir as homedir4, platform } from "os";
918
+ import { join as join5 } from "path";
855
919
  function hasMaestroCredential(host, key, userId) {
856
920
  if (userId && host.getVaultValue(userId, key)?.trim())
857
921
  return true;
@@ -871,7 +935,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
871
935
  case "claude": {
872
936
  if (host.environment.ANTHROPIC_API_KEY)
873
937
  return { ok: true };
874
- const path = join4(host.homeDirectory(), ".claude", ".credentials.json");
938
+ const path = join5(host.homeDirectory(), ".claude", ".credentials.json");
875
939
  if (host.operatingSystem() === "darwin") {
876
940
  if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
877
941
  return { ok: true };
@@ -930,7 +994,7 @@ var init_auth_check = __esm(async () => {
930
994
  codexAuthFilePath,
931
995
  exists: existsSync2,
932
996
  environment: process.env,
933
- homeDirectory: homedir3,
997
+ homeDirectory: homedir4,
934
998
  operatingSystem: platform,
935
999
  hasMacOsCredential(service) {
936
1000
  try {
@@ -1253,7 +1317,7 @@ function agentAliases(agent) {
1253
1317
  "gpt-6-astra"
1254
1318
  ];
1255
1319
  case "claude":
1256
- return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable"];
1320
+ return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable", "fable-5.2"];
1257
1321
  case "maestro":
1258
1322
  return [
1259
1323
  "maestro",
@@ -1303,7 +1367,7 @@ var init_explicit_agent_switch = __esm(() => {
1303
1367
 
1304
1368
  // ../../packages/core/src/platform/paths.ts
1305
1369
  import { existsSync as existsSync3, realpathSync } from "fs";
1306
- import { dirname as dirname3, isAbsolute, relative, resolve as resolve3, sep } from "path";
1370
+ import { dirname as dirname3, isAbsolute as isAbsolute2, relative, resolve as resolve3, sep } from "path";
1307
1371
  function normalizeExistingOrResolved(filePath) {
1308
1372
  const resolved = resolve3(filePath);
1309
1373
  try {
@@ -1327,7 +1391,7 @@ function isInsideDir(childPath, parentDir) {
1327
1391
  const parent = normalizeExistingOrResolved(parentDir);
1328
1392
  const child = normalizeExistingOrResolved(childPath);
1329
1393
  const rel = relative(parent, child);
1330
- return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute(rel);
1394
+ return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute2(rel);
1331
1395
  }
1332
1396
  function toDisplayPath(filePath) {
1333
1397
  return filePath.split(sep).join("/");
@@ -1601,7 +1665,7 @@ import {
1601
1665
  openSync,
1602
1666
  readFileSync as readFileSync2,
1603
1667
  renameSync,
1604
- statSync,
1668
+ statSync as statSync2,
1605
1669
  unlinkSync as unlinkSync2,
1606
1670
  writeFileSync as writeFileSync2
1607
1671
  } from "fs";
@@ -1643,7 +1707,7 @@ function tryAcquireAppendLock(lockPath) {
1643
1707
  }
1644
1708
  function isStaleLock(lockPath) {
1645
1709
  try {
1646
- return Date.now() - statSync(lockPath).mtimeMs > lockStaleMs();
1710
+ return Date.now() - statSync2(lockPath).mtimeMs > lockStaleMs();
1647
1711
  } catch {
1648
1712
  return false;
1649
1713
  }
@@ -1743,12 +1807,12 @@ var init_jsonl = __esm(() => {
1743
1807
  // ../../packages/core/src/agents/rollout/claude.ts
1744
1808
  import { randomUUID } from "crypto";
1745
1809
  import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
1746
- import { homedir as homedir4 } from "os";
1747
- import { join as join5 } from "path";
1810
+ import { homedir as homedir5 } from "os";
1811
+ import { join as join6 } from "path";
1748
1812
  function loadClaudeAttachments() {
1749
1813
  if (_attachmentsCache)
1750
1814
  return _attachmentsCache;
1751
- const raw = readFileSync3(join5(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
1815
+ const raw = readFileSync3(join6(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
1752
1816
  const lines = parseJsonlText(raw);
1753
1817
  if (lines.length < 2) {
1754
1818
  throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
@@ -1849,8 +1913,8 @@ function writeClaudeRollout(opts) {
1849
1913
  });
1850
1914
  lastUuid = assistantUuid;
1851
1915
  }
1852
- const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
1853
- const path = join5(projectsDir, `${sessionId}.jsonl`);
1916
+ const projectsDir = join6(homedir5(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
1917
+ const path = join6(projectsDir, `${sessionId}.jsonl`);
1854
1918
  writeJsonlFile(path, lines);
1855
1919
  logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
1856
1920
  return { sessionId, rolloutPath: path };
@@ -1864,8 +1928,8 @@ var init_claude = __esm(() => {
1864
1928
 
1865
1929
  // ../../packages/core/src/agents/claude-registry.ts
1866
1930
  import { existsSync as existsSync5, mkdirSync as mkdirSync6, readdirSync, renameSync as renameSync2, unlinkSync as unlinkSync3 } from "fs";
1867
- import { homedir as homedir5 } from "os";
1868
- import { join as join6 } from "path";
1931
+ import { homedir as homedir6 } from "os";
1932
+ import { join as join7 } from "path";
1869
1933
  var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
1870
1934
  var init_claude_registry = __esm(() => {
1871
1935
  init_claude();
@@ -1875,7 +1939,8 @@ var init_claude_registry = __esm(() => {
1875
1939
  ALIAS_MAP = {
1876
1940
  sonnet: MODEL_SONNET,
1877
1941
  opus: MODEL_OPUS,
1878
- fable: MODEL_FABLE
1942
+ fable: MODEL_FABLE,
1943
+ "fable-5.2": MODEL_FABLE_5_2
1879
1944
  };
1880
1945
  VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));
1881
1946
  VALID_EFFORTS = new Set(CLAUDE_EFFORT_VALUES);
@@ -1912,11 +1977,11 @@ var init_claude_registry = __esm(() => {
1912
1977
  const result = await forkSession(parentSessionId, {
1913
1978
  ...title ? { title } : {}
1914
1979
  });
1915
- const projectsRoot = join6(homedir5(), ".claude", "projects");
1916
- const destDir = join6(projectsRoot, encodeClaudeCwd(cwd));
1917
- const destPath = join6(destDir, `${result.sessionId}.jsonl`);
1980
+ const projectsRoot = join7(homedir6(), ".claude", "projects");
1981
+ const destDir = join7(projectsRoot, encodeClaudeCwd(cwd));
1982
+ const destPath = join7(destDir, `${result.sessionId}.jsonl`);
1918
1983
  if (!existsSync5(destPath)) {
1919
- const sourcePath = readdirSync(projectsRoot).map((d) => join6(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync5(p));
1984
+ const sourcePath = readdirSync(projectsRoot).map((d) => join7(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync5(p));
1920
1985
  if (!sourcePath) {
1921
1986
  throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
1922
1987
  }
@@ -1929,10 +1994,10 @@ var init_claude_registry = __esm(() => {
1929
1994
  };
1930
1995
  },
1931
1996
  async cleanupRollouts({ cwd, sessionIds }) {
1932
- const projectsDir = join6(homedir5(), ".claude", "projects", encodeClaudeCwd(cwd));
1997
+ const projectsDir = join7(homedir6(), ".claude", "projects", encodeClaudeCwd(cwd));
1933
1998
  const failures = [];
1934
1999
  for (const sid of sessionIds) {
1935
- const path = join6(projectsDir, `${sid}.jsonl`);
2000
+ const path = join7(projectsDir, `${sid}.jsonl`);
1936
2001
  try {
1937
2002
  unlinkSync3(path);
1938
2003
  } catch (e) {
@@ -4795,9 +4860,9 @@ var init_api_topics = __esm(async () => {
4795
4860
  });
4796
4861
 
4797
4862
  // ../../packages/core/src/platform/mcp-config.ts
4798
- import { accessSync as accessSync2, constants as fsConstants } from "fs";
4799
- import { homedir as homedir6 } from "os";
4800
- import { join as join7 } from "path";
4863
+ import { accessSync as accessSync3, constants as fsConstants } from "fs";
4864
+ import { homedir as homedir7 } from "os";
4865
+ import { join as join8 } from "path";
4801
4866
  function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
4802
4867
  if (agent === "codex") {
4803
4868
  return {
@@ -4915,12 +4980,12 @@ function resolveCuaRsBinary(platform = process.platform) {
4915
4980
  return null;
4916
4981
  const candidates = [
4917
4982
  envText("NEGOTIUM_CUA_RS_BIN"),
4918
- join7(homedir6(), ".local", "bin", "cua-rs"),
4983
+ join8(homedir7(), ".local", "bin", "cua-rs"),
4919
4984
  "/usr/local/bin/cua-rs"
4920
4985
  ].filter((p) => Boolean(p));
4921
4986
  for (const candidate of candidates) {
4922
4987
  try {
4923
- accessSync2(candidate, fsConstants.X_OK);
4988
+ accessSync3(candidate, fsConstants.X_OK);
4924
4989
  return candidate;
4925
4990
  } catch {}
4926
4991
  }
@@ -5298,6 +5363,8 @@ var init_mcp_config = __esm(async () => {
5298
5363
  playwright: {
5299
5364
  ...commonRuntimeMcpPolicy("playwright"),
5300
5365
  build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
5366
+ if (BROWSER_BACKEND === "egolite")
5367
+ return null;
5301
5368
  if (playwrightPort && playwrightCapability) {
5302
5369
  const owner = browserOwnerForContext({ userId, session, topicId });
5303
5370
  if (!owner)
@@ -5618,15 +5685,15 @@ var init_execution_host = __esm(async () => {
5618
5685
 
5619
5686
  // ../../packages/core/src/agents/rollout/codex.ts
5620
5687
  import { randomBytes as randomBytes4 } from "crypto";
5621
- import { existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync2, unlinkSync as unlinkSync4 } from "fs";
5622
- import { basename, dirname as dirname6, join as join8, resolve as resolve6 } from "path";
5688
+ import { existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync4 } from "fs";
5689
+ import { basename, dirname as dirname6, join as join9, resolve as resolve6 } from "path";
5623
5690
  function codexSessionsDir() {
5624
- return join8(hostedCodexHomePath(), "sessions");
5691
+ return join9(hostedCodexHomePath(), "sessions");
5625
5692
  }
5626
5693
  function loadCodexShell() {
5627
5694
  if (_shellCache)
5628
5695
  return _shellCache;
5629
- const raw = readFileSync4(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
5696
+ const raw = readFileSync4(join9(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
5630
5697
  const lines = parseJsonlText(raw);
5631
5698
  if (lines.length < 5) {
5632
5699
  throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
@@ -5693,8 +5760,8 @@ function codexRolloutPath(threadId, fallback) {
5693
5760
  const hh = String(createdAt.getHours()).padStart(2, "0");
5694
5761
  const min = String(createdAt.getMinutes()).padStart(2, "0");
5695
5762
  const ss = String(createdAt.getSeconds()).padStart(2, "0");
5696
- const dir = join8(codexSessionsDir(), yyyy, mm, dd);
5697
- return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
5763
+ const dir = join9(codexSessionsDir(), yyyy, mm, dd);
5764
+ return join9(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
5698
5765
  }
5699
5766
  function canonicalFilePath(path) {
5700
5767
  const absolute = resolve6(path);
@@ -5702,7 +5769,7 @@ function canonicalFilePath(path) {
5702
5769
  return realpathSync3(absolute);
5703
5770
  } catch {
5704
5771
  try {
5705
- return join8(realpathSync3(dirname6(absolute)), basename(absolute));
5772
+ return join9(realpathSync3(dirname6(absolute)), basename(absolute));
5706
5773
  } catch {
5707
5774
  return absolute;
5708
5775
  }
@@ -5991,22 +6058,22 @@ function latestCodexRolloutPath(threadId) {
5991
6058
  try {
5992
6059
  if (buckets) {
5993
6060
  for (const bucket of buckets) {
5994
- const dir = join8(sessionsDir, bucket);
6061
+ const dir = join9(sessionsDir, bucket);
5995
6062
  if (!existsSync6(dir))
5996
6063
  continue;
5997
6064
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
5998
6065
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
5999
- candidates.push(join8(dir, rel));
6066
+ candidates.push(join9(dir, rel));
6000
6067
  }
6001
6068
  }
6002
6069
  }
6003
6070
  if (candidates.length === 0) {
6004
6071
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
6005
6072
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
6006
- candidates.push(join8(sessionsDir, rel));
6073
+ candidates.push(join9(sessionsDir, rel));
6007
6074
  }
6008
6075
  }
6009
- return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
6076
+ return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
6010
6077
  } catch (error) {
6011
6078
  logger.debug({ error, threadId }, "codex rollout lookup failed");
6012
6079
  return;
@@ -6127,13 +6194,13 @@ function sweepPriorRolloutsForThread(threadId) {
6127
6194
  return;
6128
6195
  }
6129
6196
  for (const bucket of buckets) {
6130
- const dir = join8(sessionsDir, bucket);
6197
+ const dir = join9(sessionsDir, bucket);
6131
6198
  if (!existsSync6(dir))
6132
6199
  continue;
6133
6200
  try {
6134
6201
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
6135
6202
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
6136
- const fullPath = join8(dir, rel);
6203
+ const fullPath = join9(dir, rel);
6137
6204
  try {
6138
6205
  unlinkSync4(fullPath);
6139
6206
  } catch (e) {
@@ -6151,7 +6218,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
6151
6218
  try {
6152
6219
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
6153
6220
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
6154
- const fullPath = join8(sessionsDir, rel);
6221
+ const fullPath = join9(sessionsDir, rel);
6155
6222
  try {
6156
6223
  unlinkSync4(fullPath);
6157
6224
  } catch (e) {
@@ -6213,7 +6280,7 @@ var init_codex = __esm(async () => {
6213
6280
  });
6214
6281
 
6215
6282
  // ../../packages/core/src/version.ts
6216
- var NEGOTIUM_VERSION = "0.23.13";
6283
+ var NEGOTIUM_VERSION = "0.23.14";
6217
6284
 
6218
6285
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
6219
6286
  import { spawn as spawn2 } from "child_process";
@@ -6230,12 +6297,12 @@ import {
6230
6297
  writeFileSync as writeFileSync4
6231
6298
  } from "fs";
6232
6299
  import { tmpdir } from "os";
6233
- import { dirname as dirname7, join as join9 } from "path";
6300
+ import { dirname as dirname7, join as join10 } from "path";
6234
6301
  import { fileURLToPath as fileURLToPath2 } from "url";
6235
6302
  function findPackageJson(specifier, searchFromDir) {
6236
6303
  let dir = searchFromDir;
6237
6304
  for (;; ) {
6238
- const candidate = join9(dir, "node_modules", specifier, "package.json");
6305
+ const candidate = join10(dir, "node_modules", specifier, "package.json");
6239
6306
  if (existsSync7(candidate))
6240
6307
  return candidate;
6241
6308
  const parent = dirname7(dir);
@@ -6253,7 +6320,7 @@ function readPackageVersion(packageJsonPath) {
6253
6320
  return parsed.version;
6254
6321
  }
6255
6322
  function codexCliScriptPath() {
6256
- return join9(dirname7(bundledCodexPackagePath), "bin", "codex.js");
6323
+ return join10(dirname7(bundledCodexPackagePath), "bin", "codex.js");
6257
6324
  }
6258
6325
  function parseCodexModelCache(contents, sourcePath) {
6259
6326
  let parsed;
@@ -6294,7 +6361,7 @@ function writePrivateFileAtomic(path, contents) {
6294
6361
  }
6295
6362
  }
6296
6363
  function bundledCodexModelCachePath(authFilePath) {
6297
- return join9(dirname7(authFilePath), NEGOTIUM_MODEL_CACHE);
6364
+ return join10(dirname7(authFilePath), NEGOTIUM_MODEL_CACHE);
6298
6365
  }
6299
6366
  async function bootstrapCodexModelCache(codexHome, cachePath) {
6300
6367
  const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
@@ -6407,15 +6474,15 @@ function removeIsolatedCodexHome(dir) {
6407
6474
  }
6408
6475
  async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
6409
6476
  const sourceHome = dirname7(authFilePath);
6410
- const isolatedHome = mkdtempSync(join9(tmpdir(), "negotium-codex-models-"));
6411
- const isolatedCachePath = join9(isolatedHome, "models_cache.json");
6477
+ const isolatedHome = mkdtempSync(join10(tmpdir(), "negotium-codex-models-"));
6478
+ const isolatedCachePath = join10(isolatedHome, "models_cache.json");
6412
6479
  try {
6413
- const isolatedAuthPath = join9(isolatedHome, "auth.json");
6480
+ const isolatedAuthPath = join10(isolatedHome, "auth.json");
6414
6481
  copyFileSync(authFilePath, isolatedAuthPath);
6415
6482
  chmodSync3(isolatedAuthPath, 384);
6416
- const sourceConfigPath = join9(sourceHome, "config.toml");
6483
+ const sourceConfigPath = join10(sourceHome, "config.toml");
6417
6484
  if (existsSync7(sourceConfigPath)) {
6418
- const isolatedConfigPath = join9(isolatedHome, "config.toml");
6485
+ const isolatedConfigPath = join10(isolatedHome, "config.toml");
6419
6486
  copyFileSync(sourceConfigPath, isolatedConfigPath);
6420
6487
  chmodSync3(isolatedConfigPath, 384);
6421
6488
  }
@@ -6436,7 +6503,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
6436
6503
  return configuredCachePath;
6437
6504
  }
6438
6505
  const bundledCachePath = bundledCodexModelCachePath(authFilePath);
6439
- const sharedCachePath = join9(codexHome, "models_cache.json");
6506
+ const sharedCachePath = join10(codexHome, "models_cache.json");
6440
6507
  if (existsSync7(sharedCachePath)) {
6441
6508
  try {
6442
6509
  const shared = readCompatibleCodexModelCache(sharedCachePath);
@@ -6456,7 +6523,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
6456
6523
  }
6457
6524
  function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
6458
6525
  const codexHome = dirname7(authFilePath);
6459
- const outputPath = join9(codexHome, NEGOTIUM_MODEL_CATALOG);
6526
+ const outputPath = join10(codexHome, NEGOTIUM_MODEL_CATALOG);
6460
6527
  const parsed = readCodexModelCache(sourcePath).parsed;
6461
6528
  const models = parsed.models.map((model, index) => {
6462
6529
  if (!model || typeof model !== "object" || Array.isArray(model)) {
@@ -6600,7 +6667,7 @@ var init_codex_app_server = __esm(async () => {
6600
6667
 
6601
6668
  // ../../packages/core/src/agents/codex-registry.ts
6602
6669
  import { existsSync as existsSync8, unlinkSync as unlinkSync6 } from "fs";
6603
- import { join as join10 } from "path";
6670
+ import { join as join11 } from "path";
6604
6671
  var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
6605
6672
  var init_codex_registry = __esm(async () => {
6606
6673
  init_logger();
@@ -6645,7 +6712,7 @@ var init_codex_registry = __esm(async () => {
6645
6712
  async cleanupRollouts({ sessionIds }) {
6646
6713
  if (sessionIds.length === 0)
6647
6714
  return;
6648
- const sessionsDir = join10(hostedCodexHomePath(), "sessions");
6715
+ const sessionsDir = join11(hostedCodexHomePath(), "sessions");
6649
6716
  if (!existsSync8(sessionsDir))
6650
6717
  return;
6651
6718
  const failures = [];
@@ -6653,7 +6720,7 @@ var init_codex_registry = __esm(async () => {
6653
6720
  try {
6654
6721
  const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
6655
6722
  for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
6656
- const path = join10(sessionsDir, rel);
6723
+ const path = join11(sessionsDir, rel);
6657
6724
  try {
6658
6725
  unlinkSync6(path);
6659
6726
  } catch (e) {
@@ -6678,16 +6745,16 @@ var init_codex_registry = __esm(async () => {
6678
6745
  // ../../packages/core/src/agents/maestro-registry.ts
6679
6746
  import { randomUUID as randomUUID4 } from "crypto";
6680
6747
  import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
6681
- import { homedir as homedir7 } from "os";
6682
- import { join as join11, resolve as resolve7 } from "path";
6748
+ import { homedir as homedir8 } from "os";
6749
+ import { join as join12, resolve as resolve7 } from "path";
6683
6750
  function maestroSessionsDir() {
6684
- return join11(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join11(homedir7(), ".maestro"), "sessions");
6751
+ return join12(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join12(homedir8(), ".maestro"), "sessions");
6685
6752
  }
6686
6753
  function maestroSessionPath(sessionId) {
6687
- return join11(maestroSessionsDir(), `${sessionId}.jsonl`);
6754
+ return join12(maestroSessionsDir(), `${sessionId}.jsonl`);
6688
6755
  }
6689
6756
  function maestroActiveSessionPath(sessionId) {
6690
- return join11(maestroSessionsDir(), `${sessionId}.active.jsonl`);
6757
+ return join12(maestroSessionsDir(), `${sessionId}.active.jsonl`);
6691
6758
  }
6692
6759
  function existingCreatedAt(path) {
6693
6760
  if (!existsSync9(path))
@@ -6904,8 +6971,8 @@ function sanitizeId(id) {
6904
6971
  }
6905
6972
 
6906
6973
  // ../../packages/core/src/storage/tasks.ts
6907
- import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
6908
- import { dirname as dirname8, join as join12 } from "path";
6974
+ import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync4, writeFileSync as writeFileSync6 } from "fs";
6975
+ import { dirname as dirname8, join as join13 } from "path";
6909
6976
  function safeTaskScopeKey(scopeKey) {
6910
6977
  const safe = sanitizeFileName(scopeKey);
6911
6978
  if (!safe || safe === "." || safe === "..") {
@@ -6917,7 +6984,7 @@ function taskScopeKey(opts) {
6917
6984
  return opts.topicId?.trim() || opts.session || "default";
6918
6985
  }
6919
6986
  function getTaskFilePath(userId, scopeKey) {
6920
- return join12(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
6987
+ return join13(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
6921
6988
  }
6922
6989
  function readTasks(userId, scopeKey) {
6923
6990
  const path = getTaskFilePath(userId, scopeKey);
@@ -6941,7 +7008,7 @@ function writeTasks(userId, scopeKey, tasks) {
6941
7008
  }
6942
7009
  function taskFileMtimeNs(userId, scopeKey) {
6943
7010
  try {
6944
- return statSync3(getTaskFilePath(userId, scopeKey), { bigint: true }).mtimeNs;
7011
+ return statSync4(getTaskFilePath(userId, scopeKey), { bigint: true }).mtimeNs;
6945
7012
  } catch {
6946
7013
  return null;
6947
7014
  }
@@ -7099,9 +7166,9 @@ import {
7099
7166
  unlinkSync as unlinkSync8,
7100
7167
  writeFileSync as writeFileSync7
7101
7168
  } from "fs";
7102
- import { dirname as dirname9, join as join13 } from "path";
7169
+ import { dirname as dirname9, join as join14 } from "path";
7103
7170
  function conversationDir(_userId) {
7104
- return join13(resolveStorageDataDir(), "conversations");
7171
+ return join14(resolveStorageDataDir(), "conversations");
7105
7172
  }
7106
7173
  function topicFilename(userId, topicName) {
7107
7174
  const t = sanitizeTopicName(topicName, true);
@@ -7111,7 +7178,7 @@ function topicFilename(userId, topicName) {
7111
7178
  return `${t}.${sanitizeId(owner)}.jsonl`;
7112
7179
  }
7113
7180
  function getConversationPath(userId, topicName) {
7114
- return join13(conversationDir(userId), topicFilename(userId, topicName));
7181
+ return join14(conversationDir(userId), topicFilename(userId, topicName));
7115
7182
  }
7116
7183
  function getActiveConversationPath(userId, topicName) {
7117
7184
  const rawPath = getConversationPath(userId, topicName);
@@ -8142,16 +8209,16 @@ var init_codex_tier_resolver = __esm(async () => {
8142
8209
  });
8143
8210
 
8144
8211
  // ../../packages/core/src/agents/codex-windows-wrapper.ts
8145
- import { execFile } from "child_process";
8212
+ import { execFile as execFile2 } from "child_process";
8146
8213
  import { createHash as createHash4, randomUUID as randomUUID6 } from "crypto";
8147
8214
  import { existsSync as existsSync14 } from "fs";
8148
8215
  import { mkdir, rename, rm, writeFile } from "fs/promises";
8149
- import { join as join14 } from "path";
8150
- import { promisify } from "util";
8216
+ import { join as join15 } from "path";
8217
+ import { promisify as promisify2 } from "util";
8151
8218
  function cscPath() {
8152
8219
  const windir = process.env.WINDIR ?? process.env.SystemRoot ?? "C:\\Windows";
8153
8220
  for (const framework of ["Framework64", "Framework"]) {
8154
- const candidate = join14(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe");
8221
+ const candidate = join15(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe");
8155
8222
  if (existsSync14(candidate))
8156
8223
  return candidate;
8157
8224
  }
@@ -8159,13 +8226,13 @@ function cscPath() {
8159
8226
  }
8160
8227
  async function ensureCodexWindowsWrapperExe(cacheDir) {
8161
8228
  const digest = createHash4("sha256").update(CODEX_WINDOWS_WRAPPER_SOURCE).digest("hex").slice(0, 12);
8162
- const exePath = join14(cacheDir, `codex-hook-wrapper-${digest}.exe`);
8229
+ const exePath = join15(cacheDir, `codex-hook-wrapper-${digest}.exe`);
8163
8230
  if (existsSync14(exePath))
8164
8231
  return exePath;
8165
8232
  await mkdir(cacheDir, { recursive: true });
8166
8233
  const stamp = randomUUID6();
8167
- const sourcePath = join14(cacheDir, `wrapper-${stamp}.cs`);
8168
- const tempExe = join14(cacheDir, `wrapper-${stamp}.exe`);
8234
+ const sourcePath = join15(cacheDir, `wrapper-${stamp}.cs`);
8235
+ const tempExe = join15(cacheDir, `wrapper-${stamp}.exe`);
8169
8236
  try {
8170
8237
  await writeFile(sourcePath, CODEX_WINDOWS_WRAPPER_SOURCE, "utf8");
8171
8238
  await execFileAsync(cscPath(), ["/nologo", "/target:exe", "/optimize+", `/out:${tempExe}`, sourcePath], { windowsHide: true, timeout: 60000 });
@@ -8187,7 +8254,7 @@ ${detail}` : ""}`);
8187
8254
  }
8188
8255
  var execFileAsync, CODEX_WINDOWS_WRAPPER_SOURCE;
8189
8256
  var init_codex_windows_wrapper = __esm(() => {
8190
- execFileAsync = promisify(execFile);
8257
+ execFileAsync = promisify2(execFile2);
8191
8258
  CODEX_WINDOWS_WRAPPER_SOURCE = String.raw`
8192
8259
  using System;
8193
8260
  using System.Diagnostics;
@@ -8303,7 +8370,7 @@ import { existsSync as existsSync15 } from "fs";
8303
8370
  import { chmod, copyFile, mkdtemp, rm as rm2, writeFile as writeFile2 } from "fs/promises";
8304
8371
  import { createServer } from "net";
8305
8372
  import { tmpdir as tmpdir2 } from "os";
8306
- import { dirname as dirname10, join as join15, resolve as resolve8 } from "path";
8373
+ import { dirname as dirname10, join as join16, resolve as resolve8 } from "path";
8307
8374
  import { fileURLToPath as fileURLToPath3 } from "url";
8308
8375
  function evaluateCodexVaultPreToolUse(input, userId, operations) {
8309
8376
  if (operations.referencesSensitiveStorage(input.tool_input)) {
@@ -8359,10 +8426,10 @@ function windowsQuote(value) {
8359
8426
  return `"${value.replaceAll('"', "\\\"")}"`;
8360
8427
  }
8361
8428
  async function createCodexVaultHookBridge(userId) {
8362
- const root = await mkdtemp(join15(tmpdir2(), "negotium-codex-vault-"));
8429
+ const root = await mkdtemp(join16(tmpdir2(), "negotium-codex-vault-"));
8363
8430
  await chmod(root, 448);
8364
- const socketPath = ipcEndpoint(join15(root, "hook.sock"));
8365
- const wrapperPath = join15(root, IS_WINDOWS2 ? "codex-with-hooks.exe" : "codex-with-hooks");
8431
+ const socketPath = ipcEndpoint(join16(root, "hook.sock"));
8432
+ const wrapperPath = join16(root, IS_WINDOWS2 ? "codex-with-hooks.exe" : "codex-with-hooks");
8366
8433
  const token = randomBytes5(32).toString("hex");
8367
8434
  const connections = new Set;
8368
8435
  const server = createServer((socket) => {
@@ -8413,9 +8480,9 @@ async function createCodexVaultHookBridge(userId) {
8413
8480
  restrictIpcEndpoint(socketPath);
8414
8481
  if (IS_WINDOWS2) {
8415
8482
  await Promise.resolve().then(() => init_config());
8416
- const cached = await ensureCodexWindowsWrapperExe(join15(BINARIES_DIR, "codex-hook-wrapper"));
8483
+ const cached = await ensureCodexWindowsWrapperExe(join16(BINARIES_DIR, "codex-hook-wrapper"));
8417
8484
  await copyFile(cached, wrapperPath);
8418
- await writeFile2(join15(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
8485
+ await writeFile2(join16(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
8419
8486
  `), { encoding: "utf8", mode: 384 });
8420
8487
  } else {
8421
8488
  await writeFile2(wrapperPath, privateCodexWrapper(codexCliScriptPath(), socketPath, token), {
@@ -8467,8 +8534,8 @@ var init_codex_vault_hook_bridge = __esm(async () => {
8467
8534
  });
8468
8535
 
8469
8536
  // ../../packages/core/src/agents/tool-format.ts
8470
- import { readFileSync as readFileSync10, statSync as statSync4 } from "fs";
8471
- import { isAbsolute as isAbsolute2, resolve as resolve9 } from "path";
8537
+ import { readFileSync as readFileSync10, statSync as statSync5 } from "fs";
8538
+ import { isAbsolute as isAbsolute3, resolve as resolve9 } from "path";
8472
8539
  import { diffLines as computeLineDiff } from "diff";
8473
8540
  function summarizeDisplayText(value) {
8474
8541
  const normalized = value.replace(/\s+/g, " ").trim();
@@ -8792,9 +8859,9 @@ function sourceStartLine(input, before, after, cwd) {
8792
8859
  const rawPath = input.file_path ?? input.path;
8793
8860
  if (typeof rawPath !== "string" || !rawPath.trim())
8794
8861
  return 1;
8795
- const path = isAbsolute2(rawPath) ? rawPath : resolve9(cwd ?? process.cwd(), rawPath);
8862
+ const path = isAbsolute3(rawPath) ? rawPath : resolve9(cwd ?? process.cwd(), rawPath);
8796
8863
  try {
8797
- if (statSync4(path).size > TOOL_DIFF_SOURCE_MAX_BYTES)
8864
+ if (statSync5(path).size > TOOL_DIFF_SOURCE_MAX_BYTES)
8798
8865
  return 1;
8799
8866
  const source = readFileSync10(path, "utf8").replace(/\r\n?/g, `
8800
8867
  `);
@@ -8991,9 +9058,9 @@ __export(exports_codex_provider, {
8991
9058
  toCodexMcpServers: () => toCodexMcpServers
8992
9059
  });
8993
9060
  import { execFileSync as execFileSync5 } from "child_process";
8994
- import { existsSync as existsSync16, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
8995
- import { homedir as homedir8 } from "os";
8996
- import { dirname as dirname11, isAbsolute as isAbsolute3, join as join16, relative as relative2, resolve as resolve10 } from "path";
9061
+ import { existsSync as existsSync16, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync6 } from "fs";
9062
+ import { homedir as homedir9 } from "os";
9063
+ import { dirname as dirname11, isAbsolute as isAbsolute4, join as join17, relative as relative2, resolve as resolve10 } from "path";
8997
9064
  import { Codex } from "@openai/codex-sdk";
8998
9065
  function codexNoticeStatus(message) {
8999
9066
  const firstLine = message.trim().split(`
@@ -9029,7 +9096,7 @@ function codexMcpServerName(name) {
9029
9096
  return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
9030
9097
  }
9031
9098
  function globalCodexMcpServerNames(authFilePath) {
9032
- const configPath = join16(dirname11(authFilePath), "config.toml");
9099
+ const configPath = join17(dirname11(authFilePath), "config.toml");
9033
9100
  if (!existsSync16(configPath))
9034
9101
  return [];
9035
9102
  try {
@@ -9139,7 +9206,7 @@ function textFile(path, maxBytes = CODEX_DIFF_FILE_LIMIT) {
9139
9206
  return null;
9140
9207
  try {
9141
9208
  const byteLimit = Math.min(CODEX_DIFF_FILE_LIMIT, Math.max(0, maxBytes));
9142
- if (statSync5(path).size > byteLimit)
9209
+ if (statSync6(path).size > byteLimit)
9143
9210
  return;
9144
9211
  const content = readFileSync11(path);
9145
9212
  if (content.byteLength > byteLimit || content.includes(0))
@@ -9188,9 +9255,9 @@ class CodexFilePreviewTracker {
9188
9255
  preview(path, succeeded) {
9189
9256
  if (!this.#root || !this.#baselineAvailable || !succeeded)
9190
9257
  return {};
9191
- const absolute = canonicalPath(isAbsolute3(path) ? path : resolve10(this.#cwd, path));
9258
+ const absolute = canonicalPath(isAbsolute4(path) ? path : resolve10(this.#cwd, path));
9192
9259
  const relativePath = relative2(this.#root, absolute);
9193
- if (!relativePath || relativePath.startsWith("..") || isAbsolute3(relativePath))
9260
+ if (!relativePath || relativePath.startsWith("..") || isAbsolute4(relativePath))
9194
9261
  return {};
9195
9262
  const before = this.#baseline.has(relativePath) ? this.#baseline.get(relativePath) : this.#headFile(relativePath);
9196
9263
  const after = textFile(absolute);
@@ -9224,7 +9291,7 @@ class CodexFilePreviewTracker {
9224
9291
  }
9225
9292
  }
9226
9293
  async function fileChangeEvents(item, previews, cwd, threadId, consumedPatchCallIds) {
9227
- const expectedPaths = item.changes.map((change) => isAbsolute3(change.path) ? change.path : resolve10(cwd, change.path));
9294
+ const expectedPaths = item.changes.map((change) => isAbsolute4(change.path) ? change.path : resolve10(cwd, change.path));
9228
9295
  let nativePreview;
9229
9296
  if (threadId && item.status === "completed") {
9230
9297
  await new Promise((resolveDelay) => setTimeout(resolveDelay, 20));
@@ -9392,7 +9459,7 @@ async function* codexProvider(opts) {
9392
9459
  mcpServerCount: Object.keys(codexMcpServers).length
9393
9460
  }, "codexProvider: starting turn");
9394
9461
  const hostedCodexHome = hostedCodexHomePath();
9395
- const inheritedCodexHome = process.env.CODEX_HOME || join16(homedir8(), ".codex");
9462
+ const inheritedCodexHome = process.env.CODEX_HOME || join17(homedir9(), ".codex");
9396
9463
  const codexEnvironment = scopedBrowserCapability || resolve10(hostedCodexHome) !== resolve10(inheritedCodexHome) ? {
9397
9464
  ...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
9398
9465
  CODEX_HOME: hostedCodexHome,
@@ -9856,8 +9923,8 @@ var init_maestro_provider = __esm(async () => {
9856
9923
 
9857
9924
  // ../../packages/core/src/agents/index.ts
9858
9925
  import { existsSync as existsSync17 } from "fs";
9859
- import { homedir as homedir9 } from "os";
9860
- import { join as join17 } from "path";
9926
+ import { homedir as homedir10 } from "os";
9927
+ import { join as join18 } from "path";
9861
9928
  async function* dispatchAgent(opts) {
9862
9929
  switch (opts.agent) {
9863
9930
  case "claude": {
@@ -9891,11 +9958,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
9891
9958
  switch (agent) {
9892
9959
  case "claude": {
9893
9960
  const encodedCwd = encodeClaudeCwd(cwd);
9894
- const path = join17(homedir9(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
9961
+ const path = join18(homedir10(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
9895
9962
  return !existsSync17(path);
9896
9963
  }
9897
9964
  case "codex": {
9898
- const sessionsDir = join17(hostedCodexHomePath(), "sessions");
9965
+ const sessionsDir = join18(hostedCodexHomePath(), "sessions");
9899
9966
  const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
9900
9967
  for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
9901
9968
  return false;
@@ -11983,6 +12050,7 @@ var init_model_catalog = __esm(() => {
11983
12050
  opus: "claude",
11984
12051
  haiku: "claude",
11985
12052
  fable: "claude",
12053
+ "fable-5.2": "claude",
11986
12054
  astra: "codex",
11987
12055
  sol: "codex",
11988
12056
  luna: "codex",
@@ -12060,6 +12128,16 @@ var init_model_catalog = __esm(() => {
12060
12128
  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",
12061
12129
  estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
12062
12130
  },
12131
+ {
12132
+ model: "fable-5.2",
12133
+ agent: "claude",
12134
+ description: "Claude Fable 5.2 (2026-11-09): same top-tier route as fable, newer and cheaper, for the hardest and longest-running tasks.",
12135
+ intelligenceTier: "fable",
12136
+ routingSummary: "hardest long-running work; cheaper than fable (5.1); explicit request only",
12137
+ accessCost: CLAUDE_MAX_20X_COST,
12138
+ 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)",
12139
+ estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
12140
+ },
12063
12141
  {
12064
12142
  model: "opus",
12065
12143
  agent: "claude",
@@ -12676,13 +12754,13 @@ var init_browser_processes = __esm(async () => {
12676
12754
  });
12677
12755
 
12678
12756
  // ../../packages/core/src/platform/playwright/headed-launch.ts
12679
- import { accessSync as accessSync3, constants as constants2 } from "fs";
12680
- import { delimiter, isAbsolute as isAbsolute4, resolve as resolve13 } from "path";
12757
+ import { accessSync as accessSync4, constants as constants3 } from "fs";
12758
+ import { delimiter as delimiter2, isAbsolute as isAbsolute5, resolve as resolve13 } from "path";
12681
12759
  function findExecutableOnPath(command, environment = process.env) {
12682
- const candidates = isAbsolute4(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve13(directory, command));
12760
+ const candidates = isAbsolute5(command) ? [command] : (environment.PATH ?? "").split(delimiter2).filter(Boolean).map((directory) => resolve13(directory, command));
12683
12761
  for (const candidate of candidates) {
12684
12762
  try {
12685
- accessSync3(candidate, constants2.X_OK);
12763
+ accessSync4(candidate, constants3.X_OK);
12686
12764
  return candidate;
12687
12765
  } catch {}
12688
12766
  }
@@ -12780,7 +12858,7 @@ var init_vault_public = __esm(async () => {
12780
12858
  import { randomBytes as randomBytes6, timingSafeEqual as timingSafeEqual2 } from "crypto";
12781
12859
  import { createServer as createServer3 } from "net";
12782
12860
  import { tmpdir as tmpdir3 } from "os";
12783
- import { join as join18 } from "path";
12861
+ import { join as join19 } from "path";
12784
12862
  function deepMapStrings2(value, transform) {
12785
12863
  if (typeof value === "string")
12786
12864
  return transform(value);
@@ -12867,7 +12945,7 @@ function authorized(actual, expected) {
12867
12945
  }
12868
12946
  async function createBrowserVaultBroker(userId) {
12869
12947
  const token = randomBytes6(32).toString("hex");
12870
- const socketPath = ipcEndpoint(join18(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`));
12948
+ const socketPath = ipcEndpoint(join19(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`));
12871
12949
  const retainedForms = new Map;
12872
12950
  const leases = new Map;
12873
12951
  const sockets = new Set;
@@ -13146,7 +13224,7 @@ import {
13146
13224
  unlinkSync as unlinkSync11,
13147
13225
  writeFileSync as writeFileSync8
13148
13226
  } from "fs";
13149
- import { dirname as dirname12, join as join19, resolve as resolve14 } from "path";
13227
+ import { dirname as dirname12, join as join20, resolve as resolve14 } from "path";
13150
13228
  function removeDefaultProfileDataDir(userDataDir) {
13151
13229
  const root = resolve14(BROWSER_PROFILES_DIR);
13152
13230
  const target = resolve14(userDataDir);
@@ -13242,14 +13320,14 @@ function portFileName(instanceKey) {
13242
13320
  function writePortFile(instanceKey, port) {
13243
13321
  try {
13244
13322
  mkdirSync10(managerHost.portsDir, { recursive: true });
13245
- writeFileSync8(join19(managerHost.portsDir, portFileName(instanceKey)), String(port));
13323
+ writeFileSync8(join20(managerHost.portsDir, portFileName(instanceKey)), String(port));
13246
13324
  } catch (e) {
13247
13325
  logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
13248
13326
  }
13249
13327
  }
13250
13328
  function deletePortFile(instanceKey) {
13251
13329
  try {
13252
- unlinkSync11(join19(managerHost.portsDir, portFileName(instanceKey)));
13330
+ unlinkSync11(join20(managerHost.portsDir, portFileName(instanceKey)));
13253
13331
  } catch (e) {
13254
13332
  if (e.code === "ENOENT")
13255
13333
  return;
@@ -14490,7 +14568,8 @@ function loadSessionPrompt(filename, fallback) {
14490
14568
  }
14491
14569
  function sharedToolsPartial() {
14492
14570
  if (_sharedToolsPartial === null) {
14493
- _sharedToolsPartial = loadSessionPrompt("_shared-tools.md", "");
14571
+ const shared = loadSessionPrompt("_shared-tools.md", "");
14572
+ _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, ""));
14494
14573
  }
14495
14574
  return _sharedToolsPartial;
14496
14575
  }
@@ -14667,7 +14746,7 @@ function buildRuntimeToolSection(opts, extensions) {
14667
14746
  "`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.",
14668
14747
  "`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.",
14669
14748
  "`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.",
14670
- "Never use `fable` unless the user explicitly requests it; it is expensive.",
14749
+ "Never use `fable` or `fable-5.2` unless the user explicitly requests it; they are expensive.",
14671
14750
  "",
14672
14751
  "Model catalog (capability/cost routing guidance):",
14673
14752
  MODEL_COST_ROUTING_SUMMARY,
@@ -14866,6 +14945,7 @@ This is the shared "General" hub of the user's workspace.
14866
14945
  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;
14867
14946
  var init_builders = __esm(() => {
14868
14947
  init_model_catalog();
14948
+ init_browser_backend();
14869
14949
  init_config();
14870
14950
  init_logger();
14871
14951
  PROMPTS_DIR = resolve15(PROJECT_ROOT, "src/prompts");
@@ -14991,9 +15071,9 @@ var init_api_topic_brief = __esm(async () => {
14991
15071
  });
14992
15072
 
14993
15073
  // ../../packages/core/src/storage/wiki.ts
14994
- import { basename as basename3, dirname as dirname13, join as join20 } from "path";
15074
+ import { basename as basename3, dirname as dirname13, join as join21 } from "path";
14995
15075
  function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
14996
- return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join20(workspaceDir, "wiki");
15076
+ return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join21(workspaceDir, "wiki");
14997
15077
  }
14998
15078
  var init_wiki = __esm(async () => {
14999
15079
  await init_storage_host();
@@ -15001,8 +15081,8 @@ var init_wiki = __esm(async () => {
15001
15081
 
15002
15082
  // ../../packages/core/src/agents/archiver.ts
15003
15083
  import { randomUUID as randomUUID13 } from "crypto";
15004
- import { existsSync as existsSync19, readdirSync as readdirSync3, readFileSync as readFileSync14, statSync as statSync6 } from "fs";
15005
- import { join as join21 } from "path";
15084
+ import { existsSync as existsSync19, readdirSync as readdirSync3, readFileSync as readFileSync14, statSync as statSync7 } from "fs";
15085
+ import { join as join22 } from "path";
15006
15086
  function resolveMemoryLanguage() {
15007
15087
  const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
15008
15088
  return override && override.length > 0 ? override : resolveOutputLanguage();
@@ -15260,10 +15340,10 @@ function distillOneLine(summaryMd) {
15260
15340
  return "";
15261
15341
  }
15262
15342
  function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
15263
- const dir = join21(storage.getWikiDir(), "summaries");
15343
+ const dir = join22(storage.getWikiDir(), "summaries");
15264
15344
  if (!storage.fileExists(dir))
15265
15345
  return null;
15266
- const predicted = join21(dir, wikiSummaryFilename(date, topicTitle, topicId));
15346
+ const predicted = join22(dir, wikiSummaryFilename(date, topicTitle, topicId));
15267
15347
  if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
15268
15348
  return predicted;
15269
15349
  let best = null;
@@ -15271,7 +15351,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
15271
15351
  if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
15272
15352
  continue;
15273
15353
  }
15274
- const p = join21(dir, f);
15354
+ const p = join22(dir, f);
15275
15355
  try {
15276
15356
  const m = storage.fileModifiedAt(p);
15277
15357
  if (m >= sinceMs && (!best || m > best.mtime))
@@ -15363,8 +15443,8 @@ var init_archiver = __esm(async () => {
15363
15443
  fileExists: existsSync19,
15364
15444
  listDirectory: readdirSync3,
15365
15445
  readTextFile: (path) => readFileSync14(path, "utf-8"),
15366
- fileSize: (path) => statSync6(path).size,
15367
- fileModifiedAt: (path) => statSync6(path).mtimeMs,
15446
+ fileSize: (path) => statSync7(path).size,
15447
+ fileModifiedAt: (path) => statSync7(path).mtimeMs,
15368
15448
  getGeneralTopicId: (userId, sourceTopicId) => {
15369
15449
  const source = sourceTopicId ? getTopic(sourceTopicId) : null;
15370
15450
  return source ? ensurePersonalGeneral(userId, source.surface, {
@@ -15488,13 +15568,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
15488
15568
 
15489
15569
  // ../../packages/core/src/storage/topic-archive.ts
15490
15570
  import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync9 } from "fs";
15491
- import { join as join22 } from "path";
15571
+ import { join as join23 } from "path";
15492
15572
  function archiveTopicMessages(topicId, topicTitle, options = {}) {
15493
15573
  const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
15494
15574
  if (rows.length === 0)
15495
15575
  return null;
15496
15576
  const safeTopic = sanitizeTopicName(topicTitle, true);
15497
- const archiveDir = join22(getSharedWikiDir(), "archive");
15577
+ const archiveDir = join23(getSharedWikiDir(), "archive");
15498
15578
  mkdirSync11(archiveDir, { recursive: true });
15499
15579
  const date = new Date().toISOString().slice(0, 10);
15500
15580
  const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
@@ -15507,7 +15587,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
15507
15587
  let path;
15508
15588
  while (true) {
15509
15589
  filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
15510
- path = join22(archiveDir, filename);
15590
+ path = join23(archiveDir, filename);
15511
15591
  try {
15512
15592
  writeFileSync9(path, body, { flag: "wx" });
15513
15593
  break;
@@ -15552,7 +15632,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
15552
15632
  const entries = readRawConversation(userId, topicTitle);
15553
15633
  if (entries.length === 0)
15554
15634
  return null;
15555
- const archiveDir = join22(getSharedWikiDir(), "archive");
15635
+ const archiveDir = join23(getSharedWikiDir(), "archive");
15556
15636
  mkdirSync11(archiveDir, { recursive: true });
15557
15637
  const safeTopic = sanitizeTopicName(topicTitle, true);
15558
15638
  const date = new Date().toISOString().slice(0, 10);
@@ -15580,7 +15660,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
15580
15660
  let counter = 1;
15581
15661
  while (true) {
15582
15662
  const suffix = counter === 1 ? "" : `_${counter}`;
15583
- const path = join22(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
15663
+ const path = join23(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
15584
15664
  try {
15585
15665
  writeFileSync9(path, body, { flag: "wx" });
15586
15666
  logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
@@ -15908,7 +15988,7 @@ var init_idle_archiver = __esm(async () => {
15908
15988
  // ../../packages/core/src/storage/token-stats.ts
15909
15989
  import { createHash as createHash10 } from "crypto";
15910
15990
  import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync10 } from "fs";
15911
- import { join as join23 } from "path";
15991
+ import { join as join24 } from "path";
15912
15992
  function emptyBucket() {
15913
15993
  return {
15914
15994
  inputTokens: 0,
@@ -15927,7 +16007,7 @@ function queriesPath(userId) {
15927
16007
  const fileId = tokenStatsFileId(userId);
15928
16008
  const logDir = resolveStorageLogDir();
15929
16009
  mkdirSync12(logDir, { recursive: true });
15930
- return join23(logDir, `token-queries-${fileId}.jsonl`);
16010
+ return join24(logDir, `token-queries-${fileId}.jsonl`);
15931
16011
  }
15932
16012
  function loadRecords(userId) {
15933
16013
  try {
@@ -16147,6 +16227,8 @@ var init_token_stats = __esm(async () => {
16147
16227
  "codex:gpt-5.6-terra": { input: 2.5, cacheRead: 0.25, output: 15 },
16148
16228
  "codex:gpt-5.6-luna": { input: 1, cacheRead: 0.1, output: 6 },
16149
16229
  "claude:fable": { input: 10, cacheWrite: 12.5, cacheRead: 0.25, output: 50 },
16230
+ "claude:fable-5.2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
16231
+ "claude:claude-fable-5-2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
16150
16232
  "claude:opus": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
16151
16233
  "claude:claude-opus-5-5": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
16152
16234
  "claude:sonnet": { input: 2, cacheWrite: 2.5, cacheRead: 0.2, output: 10 },
@@ -17091,7 +17173,7 @@ var init_runtime_turn_requests = __esm(async () => {
17091
17173
  import { randomUUID as randomUUID15 } from "crypto";
17092
17174
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
17093
17175
  import { tmpdir as tmpdir4 } from "os";
17094
- import { join as join24 } from "path";
17176
+ import { join as join25 } from "path";
17095
17177
  async function waitForMemoryArchive(settled, timeoutMs) {
17096
17178
  let timer;
17097
17179
  try {
@@ -17406,7 +17488,7 @@ function formatCompactElapsed(startedAt) {
17406
17488
  async function summarizeTopicContext(request) {
17407
17489
  const startedAt = Date.now();
17408
17490
  const sessionIds = [];
17409
- const compactCwd = mkdtempSync2(join24(tmpdir4(), "negotium-compact-"));
17491
+ const compactCwd = mkdtempSync2(join25(tmpdir4(), "negotium-compact-"));
17410
17492
  const abortController = new AbortController;
17411
17493
  const relayAbort = () => abortController.abort(request.signal?.reason);
17412
17494
  if (request.signal?.aborted)
@@ -17433,7 +17515,7 @@ async function summarizeTopicContext(request) {
17433
17515
  let error = "";
17434
17516
  let toolViolation = false;
17435
17517
  let compactionLogCalls = 0;
17436
- const compactionLogPath = join24(compactCwd, "conversation.log");
17518
+ const compactionLogPath = join25(compactCwd, "conversation.log");
17437
17519
  try {
17438
17520
  const compactionMcp = useCompactionLog ? {
17439
17521
  compact_log: {
@@ -18615,7 +18697,7 @@ function createSelfConfigToolDefinitionsForCore(core, ctx, capabilities) {
18615
18697
  const tools = [
18616
18698
  {
18617
18699
  name: "set_model",
18618
- description: toolDescription(core, "set_model", "Set the model for THIS topic; it persists and applies from the NEXT turn. Use a model from the system prompt's same-agent catalog. Cross-agent changes require an explicit user-requested set_agent first. Fails if the user locked this setting. NEVER use 'fable' unless explicitly requested."),
18700
+ description: toolDescription(core, "set_model", "Set the model for THIS topic; it persists and applies from the NEXT turn. Use a model from the system prompt's same-agent catalog. Cross-agent changes require an explicit user-requested set_agent first. Fails if the user locked this setting. NEVER use 'fable' or 'fable-5.2' unless explicitly requested."),
18619
18701
  schema: { model: z3.string().describe("Model id valid for the topic's current agent.") },
18620
18702
  async handler({ model }) {
18621
18703
  return mcpResult(core.setModel(getCtx(), model));
@@ -18772,16 +18854,16 @@ var init_self_config = __esm(async () => {
18772
18854
 
18773
18855
  // ../../packages/core/src/query/state.ts
18774
18856
  import { mkdirSync as mkdirSync15, renameSync as renameSync7, unlinkSync as unlinkSync14, writeFileSync as writeFileSync13 } from "fs";
18775
- import { basename as basename4, join as join25 } from "path";
18857
+ import { basename as basename4, join as join26 } from "path";
18776
18858
  function createQueryStateStore(options) {
18777
18859
  const sanitize = options.sanitizeTopicId ?? sanitizeId;
18778
- const queryStateDirPath = (userId) => join25(options.usersLogDir, String(userId), "active-queries");
18779
- const queryStateFile = (userId, topicId) => join25(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
18860
+ const queryStateDirPath = (userId) => join26(options.usersLogDir, String(userId), "active-queries");
18861
+ const queryStateFile = (userId, topicId) => join26(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
18780
18862
  const legacyQueryStateFile = (userId, topicName) => {
18781
18863
  if (!topicName || topicName === "." || topicName === ".." || basename4(topicName) !== topicName) {
18782
18864
  return null;
18783
18865
  }
18784
- return join25(queryStateDirPath(userId), `${topicName}.json`);
18866
+ return join26(queryStateDirPath(userId), `${topicName}.json`);
18785
18867
  };
18786
18868
  return {
18787
18869
  write(userId, topicId, topicName, task) {
@@ -18902,14 +18984,14 @@ var init_actor_topic_reach = __esm(async () => {
18902
18984
  });
18903
18985
 
18904
18986
  // ../../packages/core/src/query/session-inbox-path.ts
18905
- import { join as join26 } from "path";
18987
+ import { join as join27 } from "path";
18906
18988
  function sessionInboxPath(userId, topicId) {
18907
18989
  const key = Buffer.from(topicId, "utf8").toString("base64url");
18908
- return join26(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
18990
+ return join27(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
18909
18991
  }
18910
18992
  function scheduledSessionInboxPath(userId, topicId) {
18911
18993
  const key = Buffer.from(topicId, "utf8").toString("base64url");
18912
- return join26(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
18994
+ return join27(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
18913
18995
  }
18914
18996
  function decodeTopicIdFileName(fileName, suffix) {
18915
18997
  if (!fileName.startsWith(TOPIC_ID_FILE_PREFIX) || !fileName.endsWith(suffix))
@@ -18937,7 +19019,7 @@ var init_session_inbox_path = __esm(() => {
18937
19019
 
18938
19020
  // ../../packages/core/src/storage/session-inbox-signal.ts
18939
19021
  import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync14 } from "fs";
18940
- import { join as join27 } from "path";
19022
+ import { join as join28 } from "path";
18941
19023
  function subscribeSessionInboxWrite(listener) {
18942
19024
  listeners.add(listener);
18943
19025
  return () => {
@@ -18975,7 +19057,7 @@ var SESSION_INBOX_WAKE_FILE, listeners, scheduled = null;
18975
19057
  var init_session_inbox_signal = __esm(() => {
18976
19058
  init_config();
18977
19059
  init_logger();
18978
- SESSION_INBOX_WAKE_FILE = join27(SESSION_INBOX_DIR, ".wake");
19060
+ SESSION_INBOX_WAKE_FILE = join28(SESSION_INBOX_DIR, ".wake");
18979
19061
  listeners = new Set;
18980
19062
  });
18981
19063
 
@@ -19078,13 +19160,13 @@ var init_session_inbox = __esm(async () => {
19078
19160
 
19079
19161
  // ../../packages/core/src/query/session-inbox-cleanup.ts
19080
19162
  import { unlinkSync as unlinkSync15 } from "fs";
19081
- import { basename as basename5, join as join28 } from "path";
19163
+ import { basename as basename5, join as join29 } from "path";
19082
19164
  function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
19083
19165
  const live = sessionInboxPath(userId, topicId);
19084
19166
  const scheduled = scheduledSessionInboxPath(userId, topicId);
19085
19167
  const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
19086
19168
  if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename5(legacyTopicTitle) === legacyTopicTitle) {
19087
- const legacyBase = join28(SESSION_INBOX_DIR, userId, legacyTopicTitle);
19169
+ const legacyBase = join29(SESSION_INBOX_DIR, userId, legacyTopicTitle);
19088
19170
  for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
19089
19171
  candidates.add(`${legacyBase}${suffix}`);
19090
19172
  }
@@ -19476,33 +19558,33 @@ import {
19476
19558
  openSync as openSync2,
19477
19559
  readdirSync as readdirSync4,
19478
19560
  readFileSync as readFileSync15,
19479
- statSync as statSync7,
19561
+ statSync as statSync8,
19480
19562
  unlinkSync as unlinkSync16,
19481
19563
  writeFileSync as writeFileSync15
19482
19564
  } from "fs";
19483
- import { dirname as dirname15, join as join29 } from "path";
19565
+ import { dirname as dirname15, join as join30 } from "path";
19484
19566
  function pendingAskDir(userId) {
19485
19567
  const rawUserId = String(userId);
19486
19568
  const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash12("sha256").update(rawUserId).digest("hex")}`;
19487
- return join29(resolveStorageSessionAsksDir(), safeUserId);
19569
+ return join30(resolveStorageSessionAsksDir(), safeUserId);
19488
19570
  }
19489
19571
  function encodeAskKey(key) {
19490
19572
  return JSON.stringify([key.from, key.to]);
19491
19573
  }
19492
19574
  function pendingAskPath(key) {
19493
19575
  const digest = createHash12("sha256").update(encodeAskKey(key)).digest("hex");
19494
- return join29(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
19576
+ return join30(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
19495
19577
  }
19496
19578
  function v2PendingAskPath(key) {
19497
19579
  const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
19498
- return join29(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
19580
+ return join30(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
19499
19581
  }
19500
19582
  function legacyPendingAskPath(key) {
19501
19583
  if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
19502
19584
  return null;
19503
19585
  }
19504
19586
  const dir = pendingAskDir(key.userId);
19505
- const candidate = join29(dir, `${key.from}___${key.to}.pending`);
19587
+ const candidate = join30(dir, `${key.from}___${key.to}.pending`);
19506
19588
  return dirname15(candidate) === dir ? candidate : null;
19507
19589
  }
19508
19590
  function parsePendingAskFilename(fileName) {
@@ -19528,7 +19610,7 @@ function readPendingAskFile(path, fallback) {
19528
19610
  if (!raw)
19529
19611
  return null;
19530
19612
  if (!raw.startsWith("{")) {
19531
- const ts = new Date(statSync7(path).mtimeMs).toISOString();
19613
+ const ts = new Date(statSync8(path).mtimeMs).toISOString();
19532
19614
  return {
19533
19615
  userId: fallback.userId,
19534
19616
  from: fallback.from,
@@ -19568,7 +19650,7 @@ function isStale(record, path) {
19568
19650
  if (Number.isFinite(ts))
19569
19651
  return Date.now() - ts > PENDING_ASK_TTL_MS;
19570
19652
  try {
19571
- return Date.now() - statSync7(path).mtimeMs > PENDING_ASK_TTL_MS;
19653
+ return Date.now() - statSync8(path).mtimeMs > PENDING_ASK_TTL_MS;
19572
19654
  } catch {
19573
19655
  return false;
19574
19656
  }
@@ -19724,7 +19806,7 @@ function listPendingAsksForCaller(args) {
19724
19806
  const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
19725
19807
  if (!parsed)
19726
19808
  continue;
19727
- const path = join29(dir, fileName);
19809
+ const path = join30(dir, fileName);
19728
19810
  const record = readPendingAskFile(path, {
19729
19811
  userId: args.userId,
19730
19812
  from: parsed.from,
@@ -19766,7 +19848,7 @@ function deletePendingAsksForTopic(args) {
19766
19848
  }
19767
19849
  let deleted = 0;
19768
19850
  for (const fileName of files) {
19769
- const path = join29(dir, fileName);
19851
+ const path = join30(dir, fileName);
19770
19852
  const parsed = parsePendingAskFilename(fileName);
19771
19853
  const record = readPendingAskFile(path, {
19772
19854
  userId: args.userId,
@@ -20288,7 +20370,7 @@ var init_file_hooks = __esm(() => {
20288
20370
  // ../../packages/core/src/runtime/attachments.ts
20289
20371
  import { randomUUID as randomUUID19 } from "crypto";
20290
20372
  import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync18, writeFileSync as writeFileSync16 } from "fs";
20291
- import { basename as basename6, join as join30 } from "path";
20373
+ import { basename as basename6, join as join31 } from "path";
20292
20374
  function workspaceCwdFor(topicId) {
20293
20375
  return resolveTopicWorkspaceDir(topicId);
20294
20376
  }
@@ -20301,7 +20383,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
20301
20383
  if (!attachmentIds?.length)
20302
20384
  return [];
20303
20385
  const out = [];
20304
- const destDir = join30(workspaceCwdFor(topicId), "attachments", queryId);
20386
+ const destDir = join31(workspaceCwdFor(topicId), "attachments", queryId);
20305
20387
  for (const rawId of attachmentIds) {
20306
20388
  if (typeof rawId !== "string")
20307
20389
  continue;
@@ -20318,7 +20400,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
20318
20400
  mkdirSync18(destDir, { recursive: true });
20319
20401
  const index = String(out.length + 1).padStart(2, "0");
20320
20402
  const safeName = safeAttachmentFilename(attachment.filename, fileId);
20321
- const destPath = join30(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
20403
+ const destPath = join31(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
20322
20404
  copyFileSync2(sourcePath, destPath);
20323
20405
  out.push({
20324
20406
  id: attachment.id,
@@ -20348,10 +20430,10 @@ function promptWithAttachments(prompt, attachments) {
20348
20430
  return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
20349
20431
  }
20350
20432
  function ingestAttachment(args) {
20351
- const destDir = join30(UPLOADS_DIR, args.topicId);
20433
+ const destDir = join31(UPLOADS_DIR, args.topicId);
20352
20434
  mkdirSync18(destDir, { recursive: true });
20353
20435
  const safeName = safeAttachmentFilename(args.filename, "upload");
20354
- const destPath = join30(destDir, `${Date.now()}-${randomUUID19().slice(0, 8)}-${safeName}`);
20436
+ const destPath = join31(destDir, `${Date.now()}-${randomUUID19().slice(0, 8)}-${safeName}`);
20355
20437
  if (args.sourcePath !== undefined) {
20356
20438
  copyFileSync2(args.sourcePath, destPath);
20357
20439
  } else if (args.bytes !== undefined) {
@@ -21120,7 +21202,7 @@ var init_visual_html = __esm(() => {
21120
21202
 
21121
21203
  // ../../packages/core/src/runtime/visuals.ts
21122
21204
  import { realpathSync as realpathSync5 } from "fs";
21123
- import { isAbsolute as isAbsolute5, resolve as resolve16 } from "path";
21205
+ import { isAbsolute as isAbsolute6, resolve as resolve16 } from "path";
21124
21206
  function activeVisualHtmlForPrompt(html) {
21125
21207
  if (html.length <= ACTIVE_VISUAL_PROMPT_MAX_CHARS) {
21126
21208
  return { html, omittedChars: 0 };
@@ -21225,7 +21307,7 @@ function locateVisualMediaInput(topicId, input) {
21225
21307
  }
21226
21308
  const rawPath = input.file_path.trim();
21227
21309
  const cwd = workspaceCwdFor(topicId);
21228
- const candidate = isAbsolute5(rawPath) ? rawPath : resolve16(cwd, rawPath);
21310
+ const candidate = isAbsolute6(rawPath) ? rawPath : resolve16(cwd, rawPath);
21229
21311
  let realCandidate;
21230
21312
  try {
21231
21313
  realCandidate = realpathSync5(candidate);
@@ -21285,8 +21367,8 @@ var init_visuals = __esm(async () => {
21285
21367
 
21286
21368
  // ../../packages/core/src/runtime/turn-event-stream.ts
21287
21369
  import { randomUUID as randomUUID21 } from "crypto";
21288
- import { realpathSync as realpathSync6, statSync as statSync8 } from "fs";
21289
- import { isAbsolute as isAbsolute6, resolve as resolve17 } from "path";
21370
+ import { realpathSync as realpathSync6, statSync as statSync9 } from "fs";
21371
+ import { isAbsolute as isAbsolute7, resolve as resolve17 } from "path";
21290
21372
  function sessionEventMatchesCurrentExecution(topicId, queryId, agent, model) {
21291
21373
  if (getRoomQuery(topicId)?.queryId !== queryId)
21292
21374
  return false;
@@ -21312,6 +21394,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
21312
21394
  let accumulatedText = "";
21313
21395
  let pendingText = "";
21314
21396
  let previewText = "";
21397
+ let blockStart = null;
21398
+ let lastCompletedBlock = "";
21315
21399
  let pendingMessage = null;
21316
21400
  let previewTimer = null;
21317
21401
  const clearPreviewTimer = () => {
@@ -21426,6 +21510,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
21426
21510
  const text = pendingText.trimEnd();
21427
21511
  pendingText = "";
21428
21512
  previewText = "";
21513
+ lastCompletedBlock = "";
21514
+ blockStart = null;
21429
21515
  if (silent || !text.trim()) {
21430
21516
  if (identity && !silent) {
21431
21517
  hub.broadcastMessageUpdated(topicId, identity.id, { deleted: true, text: "" });
@@ -21494,6 +21580,9 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
21494
21580
  }
21495
21581
  switch (event.type) {
21496
21582
  case "text_delta": {
21583
+ if (!pendingSawDelta) {
21584
+ blockStart = { accumulated: accumulatedText.length, pending: pendingText.length };
21585
+ }
21497
21586
  pendingSawDelta = true;
21498
21587
  const incoming = event.content;
21499
21588
  accumulatedText += incoming;
@@ -21509,9 +21598,26 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
21509
21598
  break;
21510
21599
  case "text":
21511
21600
  previewText = "";
21512
- if (pendingSawDelta) {
21513
- pendingSawDelta = false;
21514
- break;
21601
+ {
21602
+ const completed = event.content.trim();
21603
+ const repeatsPreviousBlock = completed !== "" && completed === lastCompletedBlock;
21604
+ if (pendingSawDelta) {
21605
+ pendingSawDelta = false;
21606
+ if (repeatsPreviousBlock && blockStart) {
21607
+ accumulatedText = accumulatedText.slice(0, blockStart.accumulated);
21608
+ pendingText = pendingText.slice(0, blockStart.pending);
21609
+ assistantContextTokens = estimateTextTokens(accumulatedText);
21610
+ broadcastContextProgress();
21611
+ } else if (completed) {
21612
+ lastCompletedBlock = completed;
21613
+ }
21614
+ blockStart = null;
21615
+ break;
21616
+ }
21617
+ if (repeatsPreviousBlock)
21618
+ break;
21619
+ if (completed)
21620
+ lastCompletedBlock = completed;
21515
21621
  }
21516
21622
  {
21517
21623
  const incoming = event.content;
@@ -21687,7 +21793,7 @@ ${JSON.stringify(event.input ?? {})}`);
21687
21793
  case "file":
21688
21794
  if (!silent && peerBridge) {
21689
21795
  const cwd = workspaceCwdFor(topicId);
21690
- const path = isAbsolute6(event.path) ? event.path : resolve17(cwd, event.path);
21796
+ const path = isAbsolute7(event.path) ? event.path : resolve17(cwd, event.path);
21691
21797
  if (!isPathInside(cwd, path)) {
21692
21798
  logger.warn({ topicId, path }, "peer output file is outside the topic workspace");
21693
21799
  break;
@@ -21695,7 +21801,7 @@ ${JSON.stringify(event.input ?? {})}`);
21695
21801
  let safePath;
21696
21802
  try {
21697
21803
  safePath = realpathSync6(path);
21698
- if (!statSync8(safePath).isFile()) {
21804
+ if (!statSync9(safePath).isFile()) {
21699
21805
  logger.warn({ topicId, path }, "peer output path is not a regular file");
21700
21806
  break;
21701
21807
  }
@@ -22025,9 +22131,9 @@ var init_turn_session = __esm(async () => {
22025
22131
 
22026
22132
  // ../../packages/core/src/storage/app-settings.ts
22027
22133
  import { existsSync as existsSync20, mkdirSync as mkdirSync19, readFileSync as readFileSync16, writeFileSync as writeFileSync17 } from "fs";
22028
- import { dirname as dirname16, join as join31 } from "path";
22134
+ import { dirname as dirname16, join as join32 } from "path";
22029
22135
  function settingsFile() {
22030
- return join31(resolveStorageDataDir(), "otium-settings.json");
22136
+ return join32(resolveStorageDataDir(), "otium-settings.json");
22031
22137
  }
22032
22138
  function getGlobalAiName() {
22033
22139
  const path = settingsFile();
@@ -22644,8 +22750,8 @@ __export(exports_turn_runner, {
22644
22750
  triggerTopicAiTurn: () => triggerTopicAiTurn
22645
22751
  });
22646
22752
  import { randomUUID as randomUUID22 } from "crypto";
22647
- import { existsSync as existsSync21, mkdirSync as mkdirSync20, readdirSync as readdirSync5, statSync as statSync9 } from "fs";
22648
- import { join as join32 } from "path";
22753
+ import { existsSync as existsSync21, mkdirSync as mkdirSync20, readdirSync as readdirSync5, statSync as statSync10 } from "fs";
22754
+ import { join as join33 } from "path";
22649
22755
  function withDefaultPlaywright(configuredMcp, isManager) {
22650
22756
  if (isManager)
22651
22757
  return configuredMcp;
@@ -22709,7 +22815,7 @@ function appendAskReplyMessage(topicId, text, sourceLabel, body, kind, agentType
22709
22815
  return message;
22710
22816
  }
22711
22817
  function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
22712
- const preferred = join32(directory, preferredFilename);
22818
+ const preferred = join33(directory, preferredFilename);
22713
22819
  if (preferExact && existsSync21(preferred))
22714
22820
  return preferred;
22715
22821
  let newestLegacyId = null;
@@ -22720,8 +22826,8 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
22720
22826
  const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
22721
22827
  if (!titleMatch && !legacyIdMatch)
22722
22828
  continue;
22723
- const path = join32(directory, filename);
22724
- const mtimeMs = statSync9(path).mtimeMs;
22829
+ const path = join33(directory, filename);
22830
+ const mtimeMs = statSync10(path).mtimeMs;
22725
22831
  if (titleMatch) {
22726
22832
  if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
22727
22833
  newestTitle = { path, mtimeMs };
@@ -22734,10 +22840,10 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
22734
22840
  return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
22735
22841
  }
22736
22842
  function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
22737
- const briefFile = resolveWikiMirrorPath(join32(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
22738
- const hasBriefFile = existsSync21(briefFile) && statSync9(briefFile).isFile();
22739
- const latestSummaryCandidate = resolveWikiMirrorPath(join32(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
22740
- const latestSummaryFile = existsSync21(latestSummaryCandidate) && statSync9(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
22843
+ const briefFile = resolveWikiMirrorPath(join33(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
22844
+ const hasBriefFile = existsSync21(briefFile) && statSync10(briefFile).isFile();
22845
+ const latestSummaryCandidate = resolveWikiMirrorPath(join33(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
22846
+ const latestSummaryFile = existsSync21(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
22741
22847
  return { briefFile, hasBriefFile, latestSummaryFile };
22742
22848
  }
22743
22849
  async function streamAgentEvents(topicId, topicTitle, queryId, events, control, agentType, model, effort, userId, retryableSessionExpired = true, onSessionId, execution) {
@@ -23651,7 +23757,8 @@ function startAiTurn(params) {
23651
23757
  const enabledMcp = withDefaultPlaywright(configuredMcp, isManager);
23652
23758
  const playwrightRequested = !isManager && enabledMcp.includes("playwright");
23653
23759
  const browserProfileOwner = isTopicBrowserProfileOwner(topic.id, userId);
23654
- const wantsPlaywright = playwrightRequested && browserProfileOwner;
23760
+ const wantsPlaywright = playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "chrome";
23761
+ const wantsEgoBrowser = playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "egolite";
23655
23762
  const turnMcpEnabled = browserProfileOwner ? enabledMcp : enabledMcp.filter((name) => name !== "playwright");
23656
23763
  const wantsBgBash = !isManager && enabledMcp.includes("background-bash");
23657
23764
  async function* runWithPlaywright() {
@@ -23681,6 +23788,15 @@ function startAiTurn(params) {
23681
23788
  let playwrightCapability;
23682
23789
  let playwrightInstanceKey;
23683
23790
  let bgBashPort;
23791
+ if (wantsEgoBrowser) {
23792
+ try {
23793
+ const command = await prepareEgoBrowser();
23794
+ 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>`);
23795
+ } catch (err) {
23796
+ logger.warn({ topicId, err }, "ai: ego-browser CLI unavailable");
23797
+ 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>");
23798
+ }
23799
+ }
23684
23800
  if (wantsPlaywright) {
23685
23801
  try {
23686
23802
  playwrightInstanceKey = makeInstanceKey(userId, topic.id);
@@ -23711,7 +23827,7 @@ function startAiTurn(params) {
23711
23827
  }
23712
23828
  }
23713
23829
  if (playwrightRequested && !browserProfileOwner) {
23714
- 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>");
23830
+ 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>");
23715
23831
  }
23716
23832
  if (consumePlaywrightUnavailable(userId, topic.title)) {
23717
23833
  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>");
@@ -24065,6 +24181,8 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
24065
24181
  var PLAYWRIGHT_UNAVAILABLE_NOTICE_COOLDOWN_MS, ASK_REPLY_INJECT_BATCH_MS = 500, playwrightUnavailableNoticeAt, askReplyInjectBatcher, remoteInjectWaiters, durableTurnWorker = null, durableTurnWorkerBusy = false;
24066
24182
  var init_turn_runner = __esm(async () => {
24067
24183
  init_manager();
24184
+ init_browser_backend();
24185
+ init_config();
24068
24186
  init_constants();
24069
24187
  init_logger();
24070
24188
  init_builders();
@@ -25316,7 +25434,7 @@ function createSubagentLifecycle(host) {
25316
25434
  }
25317
25435
  function canSpawnSubagentsFromTopic(topicId) {
25318
25436
  const topic = host.storage.getTopic(topicId);
25319
- return topic?.kind === "agent" && computeSubagentDepth(topicId) < limits.maxDepth;
25437
+ return topic?.kind === "agent" && topic.surface !== "otium" && computeSubagentDepth(topicId) < limits.maxDepth;
25320
25438
  }
25321
25439
  function patchSubagentCard(parentTopicId, cardMessageId, patch) {
25322
25440
  const current = host.storage.getMessage(parentTopicId, cardMessageId)?.subagentCard;
@@ -26959,11 +27077,11 @@ var init_vault_command = __esm(async () => {
26959
27077
  });
26960
27078
 
26961
27079
  // ../../packages/core/src/media/text-extractor.ts
26962
- import { execFile as execFile2 } from "child_process";
27080
+ import { execFile as execFile3 } from "child_process";
26963
27081
  import { existsSync as existsSync22, mkdirSync as mkdirSync22, readFileSync as readFileSync17, rmSync as rmSync7 } from "fs";
26964
27082
  import { readFile } from "fs/promises";
26965
- import { extname, join as join33 } from "path";
26966
- import { promisify as promisify2 } from "util";
27083
+ import { extname, join as join34 } from "path";
27084
+ import { promisify as promisify3 } from "util";
26967
27085
  async function extractText(filePath) {
26968
27086
  const ext = extname(filePath).toLowerCase();
26969
27087
  if (TEXT_EXTENSIONS.has(ext)) {
@@ -27086,7 +27204,7 @@ async function extractFromAudio(filePath, opts = {}) {
27086
27204
  const backend = opts.backend ?? WHISPER_BACKEND;
27087
27205
  try {
27088
27206
  mkdirSync22(tmpDir, { recursive: true });
27089
- const mp3Path = join33(tmpDir, "audio.mp3");
27207
+ const mp3Path = join34(tmpDir, "audio.mp3");
27090
27208
  await execFileAsync2(opts.ffmpegBin ?? FFMPEG_BIN2, [
27091
27209
  "-y",
27092
27210
  "-i",
@@ -27121,7 +27239,7 @@ async function extractFromAudio(filePath, opts = {}) {
27121
27239
  } else {
27122
27240
  await execFileAsync2(opts.pythonBin ?? PYTHON_BIN, [opts.wrapperPath ?? FASTER_WHISPER_WRAPPER, ...whisperArgs], { timeout: 120000 });
27123
27241
  }
27124
- const txtPath = join33(tmpDir, "audio.txt");
27242
+ const txtPath = join34(tmpDir, "audio.txt");
27125
27243
  const text = existsSync22(txtPath) ? readFileSync17(txtPath, "utf-8").trim() : null;
27126
27244
  if (!text) {
27127
27245
  return { text: null, method: "whisper", error: "Whisper produced no text" };
@@ -27146,7 +27264,7 @@ var execFileAsync2, FFMPEG_BIN2, TEXT_EXTENSIONS, IMAGE_EXTENSIONS;
27146
27264
  var init_text_extractor = __esm(() => {
27147
27265
  init_config();
27148
27266
  init_logger();
27149
- execFileAsync2 = promisify2(execFile2);
27267
+ execFileAsync2 = promisify3(execFile3);
27150
27268
  FFMPEG_BIN2 = FFMPEG_BIN;
27151
27269
  TEXT_EXTENSIONS = new Set([
27152
27270
  ".txt",
@@ -27296,19 +27414,19 @@ var init_lifecycle2 = __esm(() => {
27296
27414
  });
27297
27415
 
27298
27416
  // ../../packages/core/src/platform/log-rotation.ts
27299
- import { existsSync as existsSync23, renameSync as renameSync8, statSync as statSync10 } from "fs";
27300
- import { join as join34 } from "path";
27417
+ import { existsSync as existsSync23, renameSync as renameSync8, statSync as statSync11 } from "fs";
27418
+ import { join as join35 } from "path";
27301
27419
  function rotateOversizedLog(logPath, maxBytes = DEFAULT_DAEMON_LOG_ROTATE_BYTES) {
27302
27420
  try {
27303
27421
  if (!existsSync23(logPath))
27304
27422
  return;
27305
- const { size } = statSync10(logPath);
27423
+ const { size } = statSync11(logPath);
27306
27424
  if (size < maxBytes)
27307
27425
  return;
27308
27426
  const stamp = new Date().toISOString().replace(/[:.]/g, "-");
27309
- const dir = join34(logPath, "..");
27427
+ const dir = join35(logPath, "..");
27310
27428
  const base = logPath.slice(dir.length + 1);
27311
- renameSync8(logPath, join34(dir, `${base}.${stamp}`));
27429
+ renameSync8(logPath, join35(dir, `${base}.${stamp}`));
27312
27430
  } catch {}
27313
27431
  }
27314
27432
  var DEFAULT_DAEMON_LOG_ROTATE_BYTES;
@@ -27500,9 +27618,9 @@ import {
27500
27618
  readSync,
27501
27619
  renameSync as renameSync9,
27502
27620
  rmSync as rmSync8,
27503
- statSync as statSync11
27621
+ statSync as statSync12
27504
27622
  } from "fs";
27505
- import { join as join35 } from "path";
27623
+ import { join as join36 } from "path";
27506
27624
  function setBashrsCompletionSink(sink) {
27507
27625
  completionSink = sink ?? defaultSink;
27508
27626
  }
@@ -27514,7 +27632,7 @@ function isJobResult(value) {
27514
27632
  }
27515
27633
  function readTail(filePath) {
27516
27634
  try {
27517
- const { size } = statSync11(filePath);
27635
+ const { size } = statSync12(filePath);
27518
27636
  const fd = openSync3(filePath, "r");
27519
27637
  try {
27520
27638
  const start = Math.max(0, size - TAIL_BYTES);
@@ -27529,15 +27647,15 @@ function readTail(filePath) {
27529
27647
  }
27530
27648
  }
27531
27649
  function buildMessage(dir, result) {
27532
- const stdout = readTail(join35(dir, "stdout.log"));
27533
- const stderr = readTail(join35(dir, "stderr.log"));
27650
+ const stdout = readTail(join36(dir, "stdout.log"));
27651
+ const stderr = readTail(join36(dir, "stderr.log"));
27534
27652
  const parts = [];
27535
27653
  if (stdout.text.trim() || stdout.truncated) {
27536
- parts.push(`stdout${stdout.truncated ? ` (truncated, full output: ${join35(dir, "stdout.log")})` : ""}:
27654
+ parts.push(`stdout${stdout.truncated ? ` (truncated, full output: ${join36(dir, "stdout.log")})` : ""}:
27537
27655
  ${stdout.text.trim()}`);
27538
27656
  }
27539
27657
  if (stderr.text.trim() || stderr.truncated) {
27540
- parts.push(`stderr${stderr.truncated ? ` (truncated, full output: ${join35(dir, "stderr.log")})` : ""}:
27658
+ parts.push(`stderr${stderr.truncated ? ` (truncated, full output: ${join36(dir, "stderr.log")})` : ""}:
27541
27659
  ${stderr.text.trim()}`);
27542
27660
  }
27543
27661
  const header = watchHeader(result) ?? `[background_bash ${result.bash_id} finished]`;
@@ -27571,7 +27689,7 @@ function parseOwner(owner) {
27571
27689
  return { userId, topicId };
27572
27690
  }
27573
27691
  function injectedMarker(dir) {
27574
- return join35(dir, "result.json.injected");
27692
+ return join36(dir, "result.json.injected");
27575
27693
  }
27576
27694
  async function flushBashrsCompletions() {
27577
27695
  let entries;
@@ -27582,11 +27700,11 @@ async function flushBashrsCompletions() {
27582
27700
  }
27583
27701
  const now = Date.now();
27584
27702
  for (const bashId of entries) {
27585
- const dir = join35(BASHRS_SPILL_ROOT, bashId);
27586
- const resultPath = join35(dir, "result.json");
27703
+ const dir = join36(BASHRS_SPILL_ROOT, bashId);
27704
+ const resultPath = join36(dir, "result.json");
27587
27705
  const marker = injectedMarker(dir);
27588
27706
  try {
27589
- const markerStat = statSync11(marker);
27707
+ const markerStat = statSync12(marker);
27590
27708
  if (now - markerStat.mtimeMs > RETENTION_MS) {
27591
27709
  rmSync8(dir, { recursive: true, force: true });
27592
27710
  }
@@ -28000,8 +28118,8 @@ var init_file_ops = __esm(() => {
28000
28118
 
28001
28119
  // ../../packages/core/src/runtime/inbox.ts
28002
28120
  import { createHash as createHash15, randomUUID as randomUUID27 } from "crypto";
28003
- import { readdirSync as readdirSync7, statSync as statSync12, writeFileSync as writeFileSync18 } from "fs";
28004
- import { join as join36 } from "path";
28121
+ import { readdirSync as readdirSync7, statSync as statSync13, writeFileSync as writeFileSync18 } from "fs";
28122
+ import { join as join37 } from "path";
28005
28123
  function normalizeAskTarget(target) {
28006
28124
  if (target === undefined || target === "main")
28007
28125
  return "main";
@@ -28156,7 +28274,7 @@ async function flushSessionInbox() {
28156
28274
  return;
28157
28275
  }
28158
28276
  for (const uid of userDirs) {
28159
- const userInboxDir = join36(SESSION_INBOX_DIR, uid);
28277
+ const userInboxDir = join37(SESSION_INBOX_DIR, uid);
28160
28278
  let entries;
28161
28279
  try {
28162
28280
  entries = readdirSync7(userInboxDir);
@@ -28164,10 +28282,10 @@ async function flushSessionInbox() {
28164
28282
  continue;
28165
28283
  }
28166
28284
  for (const entry of entries) {
28167
- const entryPath = join36(userInboxDir, entry);
28285
+ const entryPath = join37(userInboxDir, entry);
28168
28286
  let isDir = false;
28169
28287
  try {
28170
- isDir = statSync12(entryPath).isDirectory();
28288
+ isDir = statSync13(entryPath).isDirectory();
28171
28289
  } catch {
28172
28290
  continue;
28173
28291
  }
@@ -28260,7 +28378,7 @@ function sweepScheduledSessionInbox(nowMs = Date.now()) {
28260
28378
  return;
28261
28379
  }
28262
28380
  for (const userId of userDirs) {
28263
- const userInboxDir = join36(SESSION_INBOX_DIR, userId);
28381
+ const userInboxDir = join37(SESSION_INBOX_DIR, userId);
28264
28382
  let files;
28265
28383
  try {
28266
28384
  files = readdirSync7(userInboxDir);
@@ -28272,7 +28390,7 @@ function sweepScheduledSessionInbox(nowMs = Date.now()) {
28272
28390
  const topicId = topicIdFromScheduledSessionInboxFileName(file);
28273
28391
  if (!topicId)
28274
28392
  continue;
28275
- const schedulePath = join36(userInboxDir, file);
28393
+ const schedulePath = join37(userInboxDir, file);
28276
28394
  const hasProcessingClaim = files.includes(`${file}.processing`);
28277
28395
  if (!hasProcessingClaim && !scheduledFileNeedsClaim(schedulePath, nowMs))
28278
28396
  continue;
@@ -29442,7 +29560,7 @@ var init_src = __esm(async () => {
29442
29560
 
29443
29561
  // ../../packages/core/src/storage/conversation-migration.ts
29444
29562
  import { copyFileSync as copyFileSync3, existsSync as existsSync26, mkdirSync as mkdirSync24, readFileSync as readFileSync20 } from "fs";
29445
- import { dirname as dirname17, join as join37 } from "path";
29563
+ import { dirname as dirname17, join as join38 } from "path";
29446
29564
  function readEntries(path) {
29447
29565
  const entries = [];
29448
29566
  for (const [index, line] of readFileSync20(path, "utf8").split(`
@@ -29509,7 +29627,7 @@ function migrateLegacyCompactedConversations() {
29509
29627
  result.skipped++;
29510
29628
  continue;
29511
29629
  }
29512
- const backupPath = join37(resolveStorageDataDir(), "conversation-migration-backups", MIGRATION_NAME, userId, `${sanitizeTopicName(topic.title, true)}.jsonl`);
29630
+ const backupPath = join38(resolveStorageDataDir(), "conversation-migration-backups", MIGRATION_NAME, userId, `${sanitizeTopicName(topic.title, true)}.jsonl`);
29513
29631
  const sourcePath = existsSync26(backupPath) ? backupPath : rawPath;
29514
29632
  const legacyEntries = readEntries(sourcePath);
29515
29633
  const compactIndex = compactionEntryIndex(legacyEntries);
@@ -29853,7 +29971,7 @@ var init_turn_follow_ups = __esm(async () => {
29853
29971
 
29854
29972
  // ../../packages/core/src/storage/decisions.ts
29855
29973
  import { existsSync as existsSync27, mkdirSync as mkdirSync25, readFileSync as readFileSync21, renameSync as renameSync11, writeFileSync as writeFileSync19 } from "fs";
29856
- import { dirname as dirname18, join as join38 } from "path";
29974
+ import { dirname as dirname18, join as join39 } from "path";
29857
29975
  function safeDecisionScopeKey(scopeKey) {
29858
29976
  const safe = sanitizeFileName(scopeKey);
29859
29977
  if (!safe || safe === "." || safe === "..") {
@@ -29865,10 +29983,10 @@ function decisionScopeKey(opts) {
29865
29983
  return opts.topicId?.trim() || opts.session || "default";
29866
29984
  }
29867
29985
  function getDecisionFilePath(userId, scopeKey) {
29868
- return join38(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
29986
+ return join39(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
29869
29987
  }
29870
29988
  function getDecisionGraphSvgPath(userId, scopeKey) {
29871
- return join38(resolveStorageDataDir(), "decision-renders", safeDecisionScopeKey(scopeKey), "latest.svg");
29989
+ return join39(resolveStorageDataDir(), "decision-renders", safeDecisionScopeKey(scopeKey), "latest.svg");
29872
29990
  }
29873
29991
  function writeDecisionGraphSvg(userId, scopeKey, svg) {
29874
29992
  const path = getDecisionGraphSvgPath(userId, scopeKey);
@@ -30091,8 +30209,8 @@ var init_node_host = __esm(async () => {
30091
30209
  });
30092
30210
 
30093
30211
  // ../../packages/core/src/agents/mcp-tools/inline-assets.ts
30094
- import { existsSync as existsSync28, readFileSync as readFileSync22, statSync as statSync13 } from "fs";
30095
- import { extname as extname2, isAbsolute as isAbsolute7, resolve as resolve18 } from "path";
30212
+ import { existsSync as existsSync28, readFileSync as readFileSync22, statSync as statSync14 } from "fs";
30213
+ import { extname as extname2, isAbsolute as isAbsolute8, resolve as resolve18 } from "path";
30096
30214
  function isNonLocal(ref) {
30097
30215
  const trimmed = ref.trim();
30098
30216
  if (process.platform === "win32" && WINDOWS_DRIVE_PATH.test(trimmed))
@@ -30119,15 +30237,15 @@ function inlineLocalAssets(html, options) {
30119
30237
  const relPath = stripSuffix(ref);
30120
30238
  if (!relPath)
30121
30239
  return null;
30122
- const abs = isAbsolute7(relPath) ? relPath : resolve18(baseDir, relPath);
30240
+ const abs = isAbsolute8(relPath) ? relPath : resolve18(baseDir, relPath);
30123
30241
  let bytes;
30124
30242
  try {
30125
- if (!existsSync28(abs) || !statSync13(abs).isFile()) {
30243
+ if (!existsSync28(abs) || !statSync14(abs).isFile()) {
30126
30244
  unresolved.push(ref);
30127
30245
  cache.set(ref, null);
30128
30246
  return null;
30129
30247
  }
30130
- bytes = statSync13(abs).size;
30248
+ bytes = statSync14(abs).size;
30131
30249
  } catch {
30132
30250
  unresolved.push(ref);
30133
30251
  cache.set(ref, null);
@@ -31071,9 +31189,9 @@ var init_token_stats2 = __esm(async () => {
31071
31189
  });
31072
31190
 
31073
31191
  // ../../packages/core/src/mcp/factories/system-health.ts
31074
- import { execFile as execFile3 } from "child_process";
31192
+ import { execFile as execFile4 } from "child_process";
31075
31193
  import { cpus, loadavg } from "os";
31076
- import { promisify as promisify3 } from "util";
31194
+ import { promisify as promisify4 } from "util";
31077
31195
  import { McpServer as McpServer4 } from "@modelcontextprotocol/sdk/server/mcp.js";
31078
31196
  function fmtBytes(bytes) {
31079
31197
  const gb = bytes / 1024 ** 3;
@@ -31228,7 +31346,7 @@ function createSystemHealthMcpServer(host = defaultSystemHealthMcpHost) {
31228
31346
  var execFileAsync3, defaultSystemHealthMcpHost;
31229
31347
  var init_system_health = __esm(() => {
31230
31348
  init_mcp_helpers();
31231
- execFileAsync3 = promisify3(execFile3);
31349
+ execFileAsync3 = promisify4(execFile4);
31232
31350
  defaultSystemHealthMcpHost = {
31233
31351
  async readSystemHealth() {
31234
31352
  const [memoryPressure, swap, thermal, disk, processCount, memory] = await Promise.all([
@@ -31257,7 +31375,7 @@ var init_system_health = __esm(() => {
31257
31375
  // ../../packages/core/src/mcp/factories/agent-health.ts
31258
31376
  import { spawn as spawn6 } from "child_process";
31259
31377
  import { existsSync as existsSync29, readdirSync as readdirSync8 } from "fs";
31260
- import { join as join39 } from "path";
31378
+ import { join as join40 } from "path";
31261
31379
  import { McpServer as McpServer5 } from "@modelcontextprotocol/sdk/server/mcp.js";
31262
31380
  import { z as z11 } from "zod";
31263
31381
  function signalProcessTree2(child, signal) {
@@ -31502,7 +31620,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
31502
31620
  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 () => {
31503
31621
  if (!context.userId)
31504
31622
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
31505
- const stateDir = join39(USERS_LOG_DIR, context.userId, "active-queries");
31623
+ const stateDir = join40(USERS_LOG_DIR, context.userId, "active-queries");
31506
31624
  if (!existsSync29(stateDir))
31507
31625
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
31508
31626
  let files;
@@ -31515,7 +31633,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
31515
31633
  const entries = files.flatMap((file) => {
31516
31634
  if (!file.endsWith(".json"))
31517
31635
  return [];
31518
- const state = readJsonFile(join39(stateDir, file));
31636
+ const state = readJsonFile(join40(stateDir, file));
31519
31637
  if (!state)
31520
31638
  return [];
31521
31639
  const sinceMs = new Date(state.since).getTime();
@@ -32111,7 +32229,7 @@ var exports_default_host = {};
32111
32229
  __export(exports_default_host, {
32112
32230
  createDefaultSessionCommMcpHost: () => createDefaultSessionCommMcpHost
32113
32231
  });
32114
- import { basename as basename7, join as join40 } from "path";
32232
+ import { basename as basename7, join as join41 } from "path";
32115
32233
  function ok2(text) {
32116
32234
  return { content: [{ type: "text", text }] };
32117
32235
  }
@@ -32184,10 +32302,10 @@ function activeQuery(context, topicId, title) {
32184
32302
  callerUserId: context.userId,
32185
32303
  targetParticipants: getTopic(topicId)?.participants
32186
32304
  }) ?? context.userId;
32187
- const dir = join40(USERS_LOG_DIR, principal, "active-queries");
32188
- const candidates = [join40(dir, `${sanitizeId(topicId)}.json`)];
32305
+ const dir = join41(USERS_LOG_DIR, principal, "active-queries");
32306
+ const candidates = [join41(dir, `${sanitizeId(topicId)}.json`)];
32189
32307
  if (title && basename7(title) === title && title !== "." && title !== "..") {
32190
- candidates.push(join40(dir, `${title}.json`));
32308
+ candidates.push(join41(dir, `${title}.json`));
32191
32309
  }
32192
32310
  for (const path of candidates) {
32193
32311
  const state = readJsonFile(path);
@@ -32994,11 +33112,11 @@ import {
32994
33112
  readdirSync as readdirSync9,
32995
33113
  readFileSync as readFileSync24,
32996
33114
  renameSync as renameSync12,
32997
- statSync as statSync14,
33115
+ statSync as statSync15,
32998
33116
  unlinkSync as unlinkSync19,
32999
33117
  writeFileSync as writeFileSync20
33000
33118
  } from "fs";
33001
- import { basename as basename8, dirname as dirname19, join as join41, relative as relative3, resolve as resolve19 } from "path";
33119
+ import { basename as basename8, dirname as dirname19, join as join42, relative as relative3, resolve as resolve19 } from "path";
33002
33120
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
33003
33121
  import { StdioServerTransport as StdioServerTransport2 } from "@modelcontextprotocol/sdk/server/stdio.js";
33004
33122
  import {
@@ -33097,7 +33215,7 @@ function acquireFileLock(path) {
33097
33215
  try {
33098
33216
  try {
33099
33217
  const staleToken = readFileSync24(lockPath, "utf-8");
33100
- if (Date.now() - statSync14(lockPath).mtimeMs > FILE_LOCK_STALE_MS && readFileSync24(lockPath, "utf-8") === staleToken) {
33218
+ if (Date.now() - statSync15(lockPath).mtimeMs > FILE_LOCK_STALE_MS && readFileSync24(lockPath, "utf-8") === staleToken) {
33101
33219
  unlinkSync19(lockPath);
33102
33220
  continue;
33103
33221
  }
@@ -33270,7 +33388,7 @@ function indexWikiSearchDocument(kind, key, text) {
33270
33388
  if (!index)
33271
33389
  return false;
33272
33390
  try {
33273
- const stat = statSync14(path);
33391
+ const stat = statSync15(path);
33274
33392
  index.upsert({ kind, key, path, mtimeMs: stat.mtimeMs, size: stat.size }, prepareWikiSearchDocument(kind, key, text));
33275
33393
  return true;
33276
33394
  } catch {
@@ -33341,7 +33459,7 @@ function indexCandidateExists(candidate) {
33341
33459
  if (relativePath.startsWith("..") || relativePath.startsWith("/"))
33342
33460
  return false;
33343
33461
  try {
33344
- return statSync14(filePath).isFile();
33462
+ return statSync15(filePath).isFile();
33345
33463
  } catch {
33346
33464
  return false;
33347
33465
  }
@@ -33453,13 +33571,13 @@ function wikiQuery(args) {
33453
33571
  try {
33454
33572
  for (const entry of readdirSync9(dir, { withFileTypes: true })) {
33455
33573
  if (entry.isDirectory()) {
33456
- const sub = join41(dir, entry.name);
33574
+ const sub = join42(dir, entry.name);
33457
33575
  if (label === "articles" || label === "skills") {
33458
33576
  try {
33459
33577
  for (const f of readdirSync9(sub, { withFileTypes: true })) {
33460
33578
  if (!f.isFile() || !f.name.endsWith(".md"))
33461
33579
  continue;
33462
- const fp = join41(sub, f.name);
33580
+ const fp = join42(sub, f.name);
33463
33581
  try {
33464
33582
  const text = readFileSync24(fp, "utf-8");
33465
33583
  const key = `${entry.name}/${f.name.replace(/\.md$/i, "")}`;
@@ -33480,7 +33598,7 @@ function wikiQuery(args) {
33480
33598
  if (label === "topic" && canReadTopicMemory && !canReadTopicMemory(entry.name.replace(/\.md$/i, ""), runtime().userId)) {
33481
33599
  continue;
33482
33600
  }
33483
- const fp = join41(dir, entry.name);
33601
+ const fp = join42(dir, entry.name);
33484
33602
  try {
33485
33603
  const text = readFileSync24(fp, "utf-8");
33486
33604
  const key = entry.name.replace(/\.md$/i, "");
@@ -34196,7 +34314,7 @@ function collectIndexableDocuments() {
34196
34314
  const sources = [];
34197
34315
  function add(kind, key, path) {
34198
34316
  try {
34199
- const stat = statSync14(path);
34317
+ const stat = statSync15(path);
34200
34318
  if (!stat.isFile())
34201
34319
  return;
34202
34320
  sources.push({ kind, key, path, mtimeMs: stat.mtimeMs, size: stat.size });
@@ -34214,21 +34332,21 @@ function collectIndexableDocuments() {
34214
34332
  }
34215
34333
  for (const entry of entries) {
34216
34334
  if (entry.isFile() && entry.name.endsWith(".md")) {
34217
- add(kind, entry.name.replace(/\.md$/i, ""), join41(root, entry.name));
34335
+ add(kind, entry.name.replace(/\.md$/i, ""), join42(root, entry.name));
34218
34336
  continue;
34219
34337
  }
34220
34338
  if (!entry.isDirectory() || !allowSubdirectories)
34221
34339
  continue;
34222
34340
  let nested;
34223
34341
  try {
34224
- nested = readdirSync9(join41(root, entry.name), { withFileTypes: true });
34342
+ nested = readdirSync9(join42(root, entry.name), { withFileTypes: true });
34225
34343
  } catch {
34226
34344
  continue;
34227
34345
  }
34228
34346
  for (const file of nested) {
34229
34347
  if (!file.isFile() || !file.name.endsWith(".md"))
34230
34348
  continue;
34231
- add(kind, `${entry.name}/${file.name.replace(/\.md$/i, "")}`, join41(root, entry.name, file.name));
34349
+ add(kind, `${entry.name}/${file.name.replace(/\.md$/i, "")}`, join42(root, entry.name, file.name));
34232
34350
  }
34233
34351
  }
34234
34352
  }
@@ -34346,7 +34464,7 @@ function wikiDocumentExists(kind, slug) {
34346
34464
  if (relative3(root, filePath).startsWith(".."))
34347
34465
  return false;
34348
34466
  try {
34349
- return statSync14(filePath).isFile();
34467
+ return statSync15(filePath).isFile();
34350
34468
  } catch {
34351
34469
  return false;
34352
34470
  }
@@ -34962,7 +35080,7 @@ var init_sse_transport = () => {};
34962
35080
 
34963
35081
  // ../../packages/mcp/src/server.ts
34964
35082
  import { createHash as createHash16, randomUUID as randomUUID31 } from "crypto";
34965
- import { statSync as statSync15 } from "fs";
35083
+ import { statSync as statSync16 } from "fs";
34966
35084
  import { basename as basename9, extname as extname3, resolve as resolve21 } from "path";
34967
35085
  import { McpServer as McpServer9 } from "@modelcontextprotocol/sdk/server/mcp.js";
34968
35086
  import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
@@ -34988,7 +35106,7 @@ function localFileInfo(ctx, filePath) {
34988
35106
  return { error: "Access denied. Path matches the sensitive-file blacklist." };
34989
35107
  }
34990
35108
  try {
34991
- const stats = statSync15(normalizedPath);
35109
+ const stats = statSync16(normalizedPath);
34992
35110
  if (!stats.isFile())
34993
35111
  return { error: `${filePath} is not a file` };
34994
35112
  return {
@@ -35541,11 +35659,11 @@ var init_src2 = __esm(async () => {
35541
35659
  });
35542
35660
 
35543
35661
  // ../../packages/mcp-host/src/paths.ts
35544
- import { homedir as homedir10 } from "os";
35662
+ import { homedir as homedir11 } from "os";
35545
35663
  import { resolve as resolve22 } from "path";
35546
35664
  function stateDir() {
35547
35665
  const env = process.env.NEGOTIUM_STATE_DIR?.trim();
35548
- return env ? resolve22(env) : resolve22(homedir10(), ".negotium");
35666
+ return env ? resolve22(env) : resolve22(homedir11(), ".negotium");
35549
35667
  }
35550
35668
  function defaultPortsDir() {
35551
35669
  return resolve22(stateDir(), "run", "mcp-ports");
@@ -35706,7 +35824,7 @@ import {
35706
35824
  writeFileSync as writeFileSync22
35707
35825
  } from "fs";
35708
35826
  import { connect, createServer as createServer4 } from "net";
35709
- import { join as join42 } from "path";
35827
+ import { join as join43 } from "path";
35710
35828
  function regKey(key, instanceKey) {
35711
35829
  return `${key}\x00${instanceKey}`;
35712
35830
  }
@@ -36019,7 +36137,7 @@ class McpHost {
36019
36137
  if (file.includes(".tmp-"))
36020
36138
  continue;
36021
36139
  try {
36022
- const port = Number.parseInt(readFileSync26(join42(this.portsDir, file), "utf8").trim(), 10);
36140
+ const port = Number.parseInt(readFileSync26(join43(this.portsDir, file), "utf8").trim(), 10);
36023
36141
  if (!Number.isNaN(port))
36024
36142
  claims.set(file, port);
36025
36143
  } catch {}
@@ -36029,7 +36147,7 @@ class McpHost {
36029
36147
  writePortFile(fileName, port) {
36030
36148
  try {
36031
36149
  mkdirSync28(this.portsDir, { recursive: true });
36032
- const file = join42(this.portsDir, fileName);
36150
+ const file = join43(this.portsDir, fileName);
36033
36151
  const tmp = `${file}.tmp-${process.pid}`;
36034
36152
  writeFileSync22(tmp, String(port));
36035
36153
  renameSync14(tmp, file);
@@ -36039,7 +36157,7 @@ class McpHost {
36039
36157
  }
36040
36158
  deletePortFile(fileName) {
36041
36159
  try {
36042
- unlinkSync20(join42(this.portsDir, fileName));
36160
+ unlinkSync20(join43(this.portsDir, fileName));
36043
36161
  } catch {}
36044
36162
  }
36045
36163
  cleanupRunning(rkey, inst) {
@@ -37869,10 +37987,10 @@ import {
37869
37987
  mkdirSync as mkdirSync30,
37870
37988
  readFileSync as readFileSync27,
37871
37989
  rmSync as rmSync9,
37872
- statSync as statSync16,
37990
+ statSync as statSync17,
37873
37991
  writeFileSync as writeFileSync23
37874
37992
  } from "fs";
37875
- import { basename as basename10, extname as extname4, join as join43 } from "path";
37993
+ import { basename as basename10, extname as extname4, join as join44 } from "path";
37876
37994
  function safeExtension(filename) {
37877
37995
  const extension = extname4(basename10(filename));
37878
37996
  return /^\.[A-Za-z0-9]{1,16}$/.test(extension) ? extension.toLowerCase() : "";
@@ -37890,14 +38008,14 @@ function contentDisposition(filename) {
37890
38008
 
37891
38009
  class NodeFileStore {
37892
38010
  uploadDir;
37893
- constructor(uploadDir = join43(DATA_DIR, "uploads")) {
38011
+ constructor(uploadDir = join44(DATA_DIR, "uploads")) {
37894
38012
  this.uploadDir = uploadDir;
37895
38013
  }
37896
38014
  #ensureDir() {
37897
38015
  mkdirSync30(this.uploadDir, { recursive: true });
37898
38016
  }
37899
38017
  #metadataPath(fileId) {
37900
- return join43(this.uploadDir, `${fileId}.meta.json`);
38018
+ return join44(this.uploadDir, `${fileId}.meta.json`);
37901
38019
  }
37902
38020
  #metadata(fileId) {
37903
38021
  if (!FILE_ID_RE.test(fileId))
@@ -37926,7 +38044,7 @@ class NodeFileStore {
37926
38044
  hooks = {
37927
38045
  resolveAttachmentByFileId: (fileId) => {
37928
38046
  const metadata = this.#metadata(fileId);
37929
- if (!metadata || !existsSync35(join43(this.uploadDir, metadata.savedName)))
38047
+ if (!metadata || !existsSync35(join44(this.uploadDir, metadata.savedName)))
37930
38048
  return null;
37931
38049
  return this.#attachment(fileId, metadata);
37932
38050
  },
@@ -37934,7 +38052,7 @@ class NodeFileStore {
37934
38052
  const metadata = this.#metadata(fileId);
37935
38053
  if (!metadata)
37936
38054
  return null;
37937
- const path = join43(this.uploadDir, metadata.savedName);
38055
+ const path = join44(this.uploadDir, metadata.savedName);
37938
38056
  return existsSync35(path) ? path : null;
37939
38057
  },
37940
38058
  storeLocalFileAsUpload: (absPath, access = {}) => this.store(absPath, access),
@@ -37949,11 +38067,11 @@ class NodeFileStore {
37949
38067
  const mimeType = file.type || MIME_BY_EXT2[extension] || "application/octet-stream";
37950
38068
  const existing = this.#metadata(fileId);
37951
38069
  if (existing) {
37952
- const matches = existing.filename === filename && existing.mimeType === mimeType && existing.sizeBytes === file.size && existing.ownerUserId === access.ownerUserId && existing.topicId === access.topicId && existsSync35(join43(this.uploadDir, existing.savedName));
38070
+ const matches = existing.filename === filename && existing.mimeType === mimeType && existing.sizeBytes === file.size && existing.ownerUserId === access.ownerUserId && existing.topicId === access.topicId && existsSync35(join44(this.uploadDir, existing.savedName));
37953
38071
  return matches ? this.#attachment(fileId, existing) : null;
37954
38072
  }
37955
38073
  const savedName = `${fileId}${extension}`;
37956
- const savedPath = join43(this.uploadDir, savedName);
38074
+ const savedPath = join44(this.uploadDir, savedName);
37957
38075
  try {
37958
38076
  const sizeBytes = await Bun.write(savedPath, file);
37959
38077
  if (sizeBytes !== file.size)
@@ -37978,20 +38096,20 @@ class NodeFileStore {
37978
38096
  }
37979
38097
  allows(fileId, access) {
37980
38098
  const metadata = this.#metadata(fileId);
37981
- return Boolean(metadata && metadata.ownerUserId === access.ownerUserId && metadata.topicId === access.topicId && existsSync35(join43(this.uploadDir, metadata.savedName)));
38099
+ return Boolean(metadata && metadata.ownerUserId === access.ownerUserId && metadata.topicId === access.topicId && existsSync35(join44(this.uploadDir, metadata.savedName)));
37982
38100
  }
37983
38101
  belongsToTopic(fileId, topicId) {
37984
38102
  const metadata = this.#metadata(fileId);
37985
- return Boolean(metadata && metadata.topicId === topicId && existsSync35(join43(this.uploadDir, metadata.savedName)));
38103
+ return Boolean(metadata && metadata.topicId === topicId && existsSync35(join44(this.uploadDir, metadata.savedName)));
37986
38104
  }
37987
38105
  store(absPath, access = {}) {
37988
38106
  this.#ensureDir();
37989
38107
  const fileId = randomUUID33();
37990
38108
  const extension = safeExtension(absPath);
37991
38109
  const savedName = `${fileId}${extension}`;
37992
- const savedPath = join43(this.uploadDir, savedName);
38110
+ const savedPath = join44(this.uploadDir, savedName);
37993
38111
  try {
37994
- const stats = statSync16(absPath);
38112
+ const stats = statSync17(absPath);
37995
38113
  if (!stats.isFile() || stats.size > MAX_NODE_UPLOAD_BYTES)
37996
38114
  return null;
37997
38115
  const metadata = {
@@ -38021,7 +38139,7 @@ class NodeFileStore {
38021
38139
  const allowed = metadata.visibility === "workspace" || metadata.ownerUserId === userId || Boolean(topic && isParticipant(topic, userId));
38022
38140
  if (!allowed)
38023
38141
  return null;
38024
- const path = join43(this.uploadDir, metadata.savedName);
38142
+ const path = join44(this.uploadDir, metadata.savedName);
38025
38143
  if (!existsSync35(path))
38026
38144
  return null;
38027
38145
  return new Response(Bun.file(path), {
@@ -38040,7 +38158,7 @@ class NodeFileStore {
38040
38158
  const metadata = this.#metadata(fileId);
38041
38159
  if (metadata?.topicId !== topicId)
38042
38160
  continue;
38043
- rmSync9(join43(this.uploadDir, metadata.savedName), { force: true });
38161
+ rmSync9(join44(this.uploadDir, metadata.savedName), { force: true });
38044
38162
  rmSync9(this.#metadataPath(fileId), { force: true });
38045
38163
  }
38046
38164
  }
@@ -40553,7 +40671,7 @@ function runSingletonStartupMaintenance(maintenance) {
40553
40671
  import { randomBytes as randomBytes8 } from "crypto";
40554
40672
  import { readFileSync as readFileSync29, rmSync as rmSync10, writeFileSync as writeFileSync25 } from "fs";
40555
40673
  import { createServer as createServer5 } from "net";
40556
- import { join as join44 } from "path";
40674
+ import { join as join45 } from "path";
40557
40675
  async function availableLoopbackPort() {
40558
40676
  return new Promise((resolve, reject) => {
40559
40677
  const probe = createServer5();
@@ -40630,7 +40748,7 @@ async function wireNodeMcps(host, manifest, opts = {}) {
40630
40748
  return { active, failed };
40631
40749
  }
40632
40750
  function cuaRsToken() {
40633
- const file = join44(RUN_DIR, CUA_RS_MCP_TOKEN_FILE);
40751
+ const file = join45(RUN_DIR, CUA_RS_MCP_TOKEN_FILE);
40634
40752
  try {
40635
40753
  const existing = readFileSync29(file, "utf8").trim();
40636
40754
  if (/^[0-9a-f]{64}$/.test(existing))
@@ -40662,7 +40780,7 @@ async function wireCuaRsMcp() {
40662
40780
  const binary = resolveCuaRsBinary();
40663
40781
  if (!binary)
40664
40782
  return;
40665
- const manifestFile = join44(RUN_DIR, CUA_RS_MCP_MANIFEST_FILE);
40783
+ const manifestFile = join45(RUN_DIR, CUA_RS_MCP_MANIFEST_FILE);
40666
40784
  rmSync10(manifestFile, { force: true });
40667
40785
  const manifest = new McpManifest({ file: manifestFile });
40668
40786
  const token = cuaRsToken();
@@ -40997,8 +41115,8 @@ function terminalNowMs() {
40997
41115
 
40998
41116
  // ../../adapters/terminal/src/color-depth.ts
40999
41117
  import { readFileSync as readFileSync30 } from "fs";
41000
- import { homedir as homedir11 } from "os";
41001
- import { join as join45 } from "path";
41118
+ import { homedir as homedir12 } from "os";
41119
+ import { join as join46 } from "path";
41002
41120
  function asDepth(value) {
41003
41121
  if (!value)
41004
41122
  return null;
@@ -41020,8 +41138,8 @@ function forceColorDepth(raw) {
41020
41138
  return null;
41021
41139
  }
41022
41140
  function tuiColorFile(env = process.env) {
41023
- const dir = env.NEGOTIUM_STATE_DIR?.trim() || join45(homedir11(), ".negotium");
41024
- return join45(dir, "tui-color");
41141
+ const dir = env.NEGOTIUM_STATE_DIR?.trim() || join46(homedir12(), ".negotium");
41142
+ return join46(dir, "tui-color");
41025
41143
  }
41026
41144
  function readSavedDepth(env) {
41027
41145
  try {
@@ -42294,11 +42412,11 @@ var init_context_usage = __esm(async () => {
42294
42412
  });
42295
42413
 
42296
42414
  // ../../adapters/terminal/src/path-suggest.ts
42297
- import { execFile as execFile4 } from "child_process";
42298
- import { existsSync as existsSync37, readdirSync as readdirSync12, statSync as statSync17 } from "fs";
42299
- import { homedir as homedir12 } from "os";
42300
- import { basename as basename11, dirname as dirname22, isAbsolute as isAbsolute8, join as join46, relative as relative4, sep as sep4 } from "path";
42301
- import { promisify as promisify4 } from "util";
42415
+ import { execFile as execFile5 } from "child_process";
42416
+ import { existsSync as existsSync37, readdirSync as readdirSync12, statSync as statSync18 } from "fs";
42417
+ import { homedir as homedir13 } from "os";
42418
+ import { basename as basename11, dirname as dirname22, isAbsolute as isAbsolute9, join as join47, relative as relative4, sep as sep4 } from "path";
42419
+ import { promisify as promisify5 } from "util";
42302
42420
  function indexRecursivePaths(files) {
42303
42421
  const paths = [];
42304
42422
  const directories = new Set;
@@ -42397,31 +42515,31 @@ function isHomeRoot(frag) {
42397
42515
  return frag === "~/" || sep4 === "\\" && frag === "~\\";
42398
42516
  }
42399
42517
  function resolveFragment(frag) {
42400
- const home = homedir12();
42518
+ const home = homedir13();
42401
42519
  let path;
42402
42520
  if (frag === "" || frag === "~")
42403
42521
  path = home;
42404
42522
  else if (isHomeRoot(frag))
42405
42523
  path = home;
42406
42524
  else if (frag.startsWith("~/") || frag.startsWith("~\\"))
42407
- path = join46(home, frag.slice(2));
42408
- else if (isAbsolute8(frag))
42525
+ path = join47(home, frag.slice(2));
42526
+ else if (isAbsolute9(frag))
42409
42527
  path = frag;
42410
42528
  else
42411
- path = join46(home, frag);
42529
+ path = join47(home, frag);
42412
42530
  if (endsWithSeparator(frag) || frag === "" || frag === "~") {
42413
42531
  return { dir: path, prefix: "" };
42414
42532
  }
42415
42533
  return { dir: dirname22(path), prefix: basename11(path) };
42416
42534
  }
42417
42535
  function toToken(fullPath, isDir) {
42418
- const home = homedir12();
42536
+ const home = homedir13();
42419
42537
  let shown = fullPath;
42420
42538
  if (fullPath === home)
42421
42539
  shown = "~";
42422
42540
  else {
42423
42541
  const rel = relative4(home, fullPath);
42424
- if (rel && !rel.startsWith("..") && !isAbsolute8(rel)) {
42542
+ if (rel && !rel.startsWith("..") && !isAbsolute9(rel)) {
42425
42543
  shown = `~/${rel.split(sep4).join("/")}`;
42426
42544
  }
42427
42545
  }
@@ -42441,7 +42559,7 @@ function rankAndSlice(dir, candidates) {
42441
42559
  });
42442
42560
  return candidates.slice(0, MAX_SUGGESTIONS).map(({ relPath, isDir }) => ({
42443
42561
  label: `${relPath}${isDir ? "/" : ""}`,
42444
- value: toToken(join46(dir, relPath), isDir),
42562
+ value: toToken(join47(dir, relPath), isDir),
42445
42563
  isDir
42446
42564
  }));
42447
42565
  }
@@ -42488,7 +42606,7 @@ async function warmPathSuggestions(lineText, col, loader = listFilesWithRipgrep)
42488
42606
  return false;
42489
42607
  const { dir } = resolveFragment(token.frag);
42490
42608
  try {
42491
- if (!statSync17(dir).isDirectory())
42609
+ if (!statSync18(dir).isDirectory())
42492
42610
  return false;
42493
42611
  } catch {
42494
42612
  return false;
@@ -42520,7 +42638,7 @@ function pathSuggestions(lineText, col) {
42520
42638
  let isDir = entry.isDirectory();
42521
42639
  if (!isDir && entry.isSymbolicLink()) {
42522
42640
  try {
42523
- isDir = statSync17(join46(dir, entry.name)).isDirectory();
42641
+ isDir = statSync18(join47(dir, entry.name)).isDirectory();
42524
42642
  } catch {}
42525
42643
  }
42526
42644
  return {
@@ -42543,14 +42661,14 @@ function pathSuggestions(lineText, col) {
42543
42661
  };
42544
42662
  }
42545
42663
  function fragmentToAbsolutePath(frag) {
42546
- const home = homedir12();
42664
+ const home = homedir13();
42547
42665
  if (frag === "~" || isHomeRoot(frag))
42548
42666
  return home;
42549
42667
  if (frag.startsWith("~/") || frag.startsWith("~\\"))
42550
- return join46(home, frag.slice(2));
42551
- if (isAbsolute8(frag))
42668
+ return join47(home, frag.slice(2));
42669
+ if (isAbsolute9(frag))
42552
42670
  return frag;
42553
- return join46(home, frag);
42671
+ return join47(home, frag);
42554
42672
  }
42555
42673
  function fragmentResolves(frag) {
42556
42674
  try {
@@ -42589,7 +42707,7 @@ var init_path_suggest = __esm(() => {
42589
42707
  RECURSIVE_EXCLUDES = ["node_modules", ".git", ".cache", "dist", "build", "Library", ".Trash"];
42590
42708
  recursiveCache = new Map;
42591
42709
  recursiveSearches = new Map;
42592
- execFileAsync4 = promisify4(execFile4);
42710
+ execFileAsync4 = promisify5(execFile5);
42593
42711
  AT_PATH_TOKEN = /(^|[\s([{<])@([^\s]+)/g;
42594
42712
  TRAILING_PUNCT = /[.,;:!?)\]}>"'`]+$/;
42595
42713
  });
@@ -42664,7 +42782,7 @@ var init_terminal_width = __esm(() => {
42664
42782
  });
42665
42783
 
42666
42784
  // ../../adapters/terminal/src/visualization.ts
42667
- import { basename as basename12, extname as extname5, isAbsolute as isAbsolute9 } from "path";
42785
+ import { basename as basename12, extname as extname5, isAbsolute as isAbsolute10 } from "path";
42668
42786
  function hasControlCharacter(value) {
42669
42787
  for (const character of value) {
42670
42788
  const code = character.codePointAt(0) ?? 0;
@@ -42674,7 +42792,7 @@ function hasControlCharacter(value) {
42674
42792
  return false;
42675
42793
  }
42676
42794
  function isSupportedVisualizationPath(value) {
42677
- if (value.length === 0 || value.length > MAX_VISUALIZATION_PATH_LENGTH || !isAbsolute9(value) || hasControlCharacter(value)) {
42795
+ if (value.length === 0 || value.length > MAX_VISUALIZATION_PATH_LENGTH || !isAbsolute10(value) || hasControlCharacter(value)) {
42678
42796
  return false;
42679
42797
  }
42680
42798
  const extension = extname5(value).toLowerCase();
@@ -50876,7 +50994,7 @@ var init_commands2 = __esm(async () => {
50876
50994
  // ../../adapters/telegram/src/mapping-store.ts
50877
50995
  import { Database as Database2 } from "bun:sqlite";
50878
50996
  import { mkdirSync as mkdirSync32 } from "fs";
50879
- import { dirname as dirname23, join as join47 } from "path";
50997
+ import { dirname as dirname23, join as join48 } from "path";
50880
50998
  function outboxRowToEntry(row) {
50881
50999
  return {
50882
51000
  id: row.id,
@@ -50960,7 +51078,7 @@ function migrateRuntimeInboxSchema(db) {
50960
51078
  ON runtime_inbox(runtime_message_id) WHERE runtime_message_id IS NOT NULL`);
50961
51079
  }
50962
51080
  function openMappingStore(path) {
50963
- const dbPath = path ?? join47(DATA_DIR, "adapter-telegram.db");
51081
+ const dbPath = path ?? join48(DATA_DIR, "adapter-telegram.db");
50964
51082
  if (dbPath !== ":memory:")
50965
51083
  mkdirSync32(dirname23(dbPath), { recursive: true });
50966
51084
  const db = new Database2(dbPath);
@@ -53693,7 +53811,7 @@ import {
53693
53811
  readFileSync as readFileSync31,
53694
53812
  renameSync as renameSync16,
53695
53813
  rmSync as rmSync11,
53696
- statSync as statSync18,
53814
+ statSync as statSync19,
53697
53815
  unlinkSync as unlinkSync22,
53698
53816
  writeFileSync as writeFileSync26
53699
53817
  } from "fs";
@@ -53798,7 +53916,7 @@ function withJoinCredentialLock(operation) {
53798
53916
  } catch {}
53799
53917
  let ageMs;
53800
53918
  try {
53801
- ageMs = Date.now() - statSync18(lockPath).mtimeMs;
53919
+ ageMs = Date.now() - statSync19(lockPath).mtimeMs;
53802
53920
  } catch (statError) {
53803
53921
  if (statError.code === "ENOENT")
53804
53922
  continue;
@@ -54010,8 +54128,8 @@ var init_join = __esm(async () => {
54010
54128
 
54011
54129
  // ../../adapters/otium/src/peer-files.ts
54012
54130
  import { randomUUID as randomUUID39 } from "crypto";
54013
- import { copyFileSync as copyFileSync5, mkdirSync as mkdirSync34, rmSync as rmSync12, statSync as statSync19 } from "fs";
54014
- import { basename as basename14, extname as extname7, join as join48 } from "path";
54131
+ import { copyFileSync as copyFileSync5, mkdirSync as mkdirSync34, rmSync as rmSync12, statSync as statSync20 } from "fs";
54132
+ import { basename as basename14, extname as extname7, join as join49 } from "path";
54015
54133
  function fileType(mimeType) {
54016
54134
  if (mimeType.startsWith("image/"))
54017
54135
  return "image";
@@ -54077,9 +54195,9 @@ function recordFile(args) {
54077
54195
  function insertLocalFile(args) {
54078
54196
  const id = randomUUID39();
54079
54197
  mkdirSync34(PEER_FILES_DIR, { recursive: true });
54080
- const path = join48(PEER_FILES_DIR, `${id}-${safeFilename(args.filename)}`);
54198
+ const path = join49(PEER_FILES_DIR, `${id}-${safeFilename(args.filename)}`);
54081
54199
  copyFileSync5(args.sourcePath, path);
54082
- return recordFile({ id, path, sizeBytes: statSync19(path).size, ...args });
54200
+ return recordFile({ id, path, sizeBytes: statSync20(path).size, ...args });
54083
54201
  }
54084
54202
  function deletePeerFilesForTopic(topicId) {
54085
54203
  const rows = db.query("SELECT path FROM otium_peer_files WHERE topic_id = ?").all(topicId);
@@ -54123,7 +54241,7 @@ function installPeerFileHooks() {
54123
54241
  var PEER_FILES_DIR;
54124
54242
  var init_peer_files = __esm(async () => {
54125
54243
  await init_src();
54126
- PEER_FILES_DIR = join48(DATA_DIR, "otium-peer-files");
54244
+ PEER_FILES_DIR = join49(DATA_DIR, "otium-peer-files");
54127
54245
  db.exec(`
54128
54246
  CREATE TABLE IF NOT EXISTS otium_peer_files (
54129
54247
  id TEXT PRIMARY KEY,
@@ -57790,8 +57908,8 @@ var init_errors2 = __esm(() => {
57790
57908
  });
57791
57909
 
57792
57910
  // ../cli/src/commands/admin/paths.ts
57793
- import { homedir as homedir13 } from "os";
57794
- import { join as join49, resolve as resolve29 } from "path";
57911
+ import { homedir as homedir14 } from "os";
57912
+ import { join as join50, resolve as resolve29 } from "path";
57795
57913
  function envText2(env, key) {
57796
57914
  const value = env[key]?.trim();
57797
57915
  return value || undefined;
@@ -57806,7 +57924,7 @@ function safeRuntimePathSegment2(value, fallback, maxLength = 160) {
57806
57924
  }
57807
57925
  function nodePaths(env = process.env) {
57808
57926
  const configured = envText2(env, "NEGOTIUM_STATE_DIR");
57809
- const stateDir = configured ? resolve29(configured) : resolve29(homedir13(), ".negotium");
57927
+ const stateDir = configured ? resolve29(configured) : resolve29(homedir14(), ".negotium");
57810
57928
  const dataDir = stateChild(env, "NEGOTIUM_DATA_DIR", stateDir, "data");
57811
57929
  const runDir = stateChild(env, "NEGOTIUM_RUN_DIR", stateDir, "runtime");
57812
57930
  const workspaceDir = stateChild(env, "NEGOTIUM_WORKSPACE_DIR", stateDir, "workspace");
@@ -57817,36 +57935,36 @@ function nodePaths(env = process.env) {
57817
57935
  uploadsDir: resolve29(dataDir, "uploads"),
57818
57936
  runDir,
57819
57937
  sessionInboxDir: resolve29(runDir, "session-inbox"),
57820
- sessionAsksDir: join49(runDir, "session-asks"),
57938
+ sessionAsksDir: join50(runDir, "session-asks"),
57821
57939
  topicWorkspaceDir: resolve29(workspaceDir, "topics"),
57822
57940
  nodeDaemonInfo: resolve29(runDir, "node-daemon.json")
57823
57941
  };
57824
57942
  }
57825
57943
  function topicWorkspaceDir(paths, topicId) {
57826
- return join49(paths.topicWorkspaceDir, safeRuntimePathSegment2(topicId, "topic"));
57944
+ return join50(paths.topicWorkspaceDir, safeRuntimePathSegment2(topicId, "topic"));
57827
57945
  }
57828
57946
  function sessionInboxFiles(paths, userId, topicId) {
57829
57947
  const key = Buffer.from(topicId, "utf8").toString("base64url");
57830
- const live = join49(paths.sessionInboxDir, userId, `${TOPIC_ID_FILE_PREFIX2}${key}.jsonl`);
57831
- const scheduled = join49(paths.sessionInboxDir, userId, `${TOPIC_ID_FILE_PREFIX2}${key}.schedule`);
57948
+ const live = join50(paths.sessionInboxDir, userId, `${TOPIC_ID_FILE_PREFIX2}${key}.jsonl`);
57949
+ const scheduled = join50(paths.sessionInboxDir, userId, `${TOPIC_ID_FILE_PREFIX2}${key}.schedule`);
57832
57950
  return [live, `${live}.processing`, scheduled, `${scheduled}.processing`];
57833
57951
  }
57834
57952
  function legacySessionInboxFiles(paths, userId, title) {
57835
57953
  if (!title || title === "." || title === ".." || title.includes("/"))
57836
57954
  return [];
57837
- const base = join49(paths.sessionInboxDir, userId, title);
57955
+ const base = join50(paths.sessionInboxDir, userId, title);
57838
57956
  return [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"].map((suffix) => `${base}${suffix}`);
57839
57957
  }
57840
57958
  function pendingAskDir2(paths, userId) {
57841
57959
  const safe = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(userId) && !userId.includes("..") ? userId : `sha256-${new Bun.CryptoHasher("sha256").update(userId).digest("hex")}`;
57842
- return join49(paths.sessionAsksDir, safe);
57960
+ return join50(paths.sessionAsksDir, safe);
57843
57961
  }
57844
57962
  var TOPIC_ID_FILE_PREFIX2 = "topic-id-";
57845
57963
  var init_paths3 = () => {};
57846
57964
 
57847
57965
  // ../cli/src/commands/admin/facts.ts
57848
57966
  import { existsSync as existsSync42, readdirSync as readdirSync13, readFileSync as readFileSync34 } from "fs";
57849
- import { join as join50 } from "path";
57967
+ import { join as join51 } from "path";
57850
57968
  function tableExists(db, name) {
57851
57969
  return Boolean(db.query("SELECT COUNT(*) AS n FROM sqlite_master WHERE type = 'table' AND name = ?").get(name)?.n);
57852
57970
  }
@@ -57979,7 +58097,7 @@ function topicFileState(paths, topicId, title, owners) {
57979
58097
  }
57980
58098
  const askDir = pendingAskDir2(paths, owner);
57981
58099
  for (const name of listDir(askDir)) {
57982
- const path = join50(askDir, name);
58100
+ const path = join51(askDir, name);
57983
58101
  let record = null;
57984
58102
  try {
57985
58103
  record = JSON.parse(readFileSync34(path, "utf8"));
@@ -57995,7 +58113,7 @@ function topicFileState(paths, topicId, title, owners) {
57995
58113
  for (const name of listDir(paths.uploadsDir)) {
57996
58114
  if (!name.endsWith(".meta.json"))
57997
58115
  continue;
57998
- const path = join50(paths.uploadsDir, name);
58116
+ const path = join51(paths.uploadsDir, name);
57999
58117
  try {
58000
58118
  const meta = JSON.parse(readFileSync34(path, "utf8"));
58001
58119
  if (meta.topicId === topicId)
@@ -58025,7 +58143,7 @@ var init_facts = __esm(() => {
58025
58143
  import { randomBytes as randomBytes9 } from "crypto";
58026
58144
  import {
58027
58145
  closeSync as closeSync7,
58028
- constants as constants3,
58146
+ constants as constants4,
58029
58147
  fstatSync,
58030
58148
  fsyncSync as fsyncSync4,
58031
58149
  linkSync as linkSync3,
@@ -58034,7 +58152,7 @@ import {
58034
58152
  openSync as openSync7,
58035
58153
  unlinkSync as unlinkSync24
58036
58154
  } from "fs";
58037
- import { basename as basename15, dirname as dirname27, join as join51, resolve as resolve30 } from "path";
58155
+ import { basename as basename15, dirname as dirname27, join as join52, resolve as resolve30 } from "path";
58038
58156
  function currentUid() {
58039
58157
  return typeof process.getuid === "function" ? process.getuid() : null;
58040
58158
  }
@@ -58104,7 +58222,7 @@ var init_safe_fs = __esm(() => {
58104
58222
  fsyncSync4(fd);
58105
58223
  },
58106
58224
  fsyncDir(dir) {
58107
- const fd = openSync7(dir, constants3.O_RDONLY | constants3.O_DIRECTORY);
58225
+ const fd = openSync7(dir, constants4.O_RDONLY | constants4.O_DIRECTORY);
58108
58226
  try {
58109
58227
  fsyncSync4(fd);
58110
58228
  } finally {
@@ -58123,7 +58241,7 @@ import { Database as Database3 } from "bun:sqlite";
58123
58241
  import { createHash as createHash20, randomBytes as randomBytes10 } from "crypto";
58124
58242
  import {
58125
58243
  closeSync as closeSync8,
58126
- constants as constants4,
58244
+ constants as constants5,
58127
58245
  existsSync as existsSync43,
58128
58246
  fchmodSync,
58129
58247
  fstatSync as fstatSync2,
@@ -58133,7 +58251,7 @@ import {
58133
58251
  readSync as readSync2,
58134
58252
  rmSync as rmSync13
58135
58253
  } from "fs";
58136
- import { join as join52 } from "path";
58254
+ import { join as join53 } from "path";
58137
58255
  function pidAlive(pid) {
58138
58256
  if (!Number.isSafeInteger(pid) || pid <= 0)
58139
58257
  return false;
@@ -58203,7 +58321,7 @@ function assertNoSqliteSidecars(path) {
58203
58321
  refuse(`${path} has SQLite sidecar files: ${present.join(", ")}`);
58204
58322
  }
58205
58323
  function openBackupReadOnly(path) {
58206
- const fd = openSync8(path, constants4.O_RDONLY | constants4.O_NOFOLLOW);
58324
+ const fd = openSync8(path, constants5.O_RDONLY | constants5.O_NOFOLLOW);
58207
58325
  const header = Buffer.alloc(100);
58208
58326
  try {
58209
58327
  if (readSync2(fd, header, 0, 100, 0) !== 100)
@@ -58223,15 +58341,15 @@ function openBackupReadOnly(path) {
58223
58341
  function takeVerifiedBackup(db, dir, label, seam, verify) {
58224
58342
  const finalName = randomBasename(`pre-${label}`, ".db");
58225
58343
  recheckSafeDir(dir);
58226
- const staging = mkdtempSync3(join52(dir.path, ".staging-"));
58227
- const tempPath = join52(staging, "backup.db");
58344
+ const staging = mkdtempSync3(join53(dir.path, ".staging-"));
58345
+ const tempPath = join53(staging, "backup.db");
58228
58346
  seam.event?.("create", tempPath);
58229
58347
  let fd = null;
58230
58348
  try {
58231
58349
  openSafeDir(staging);
58232
58350
  db.query("VACUUM INTO ?").run(tempPath);
58233
58351
  seam.event?.("vacuum-into", tempPath);
58234
- fd = openSync8(tempPath, constants4.O_RDONLY | constants4.O_NOFOLLOW);
58352
+ fd = openSync8(tempPath, constants5.O_RDONLY | constants5.O_NOFOLLOW);
58235
58353
  const stat = fstatSync2(fd);
58236
58354
  if (!stat.isFile() || stat.nlink !== 1)
58237
58355
  refuse(`${tempPath} is not a fresh regular file`);
@@ -58260,7 +58378,7 @@ function takeVerifiedBackup(db, dir, label, seam, verify) {
58260
58378
  seam.event?.("verify", tempPath);
58261
58379
  recheckSafeDir(dir);
58262
58380
  assertSameFile(file);
58263
- const finalPath = join52(dir.path, finalName);
58381
+ const finalPath = join53(dir.path, finalName);
58264
58382
  seam.renameNoClobber(tempPath, finalPath);
58265
58383
  seam.event?.("rename", finalPath);
58266
58384
  rmSync13(staging, { recursive: true, force: true });
@@ -58351,18 +58469,18 @@ import { Database as Database4 } from "bun:sqlite";
58351
58469
  import { createHash as createHash21 } from "crypto";
58352
58470
  import {
58353
58471
  closeSync as closeSync9,
58354
- constants as constants5,
58472
+ constants as constants6,
58355
58473
  existsSync as existsSync44,
58356
58474
  mkdtempSync as mkdtempSync4,
58357
58475
  openSync as openSync9,
58358
58476
  readdirSync as readdirSync14,
58359
58477
  readFileSync as readFileSync36,
58360
58478
  rmSync as rmSync14,
58361
- statSync as statSync20,
58479
+ statSync as statSync21,
58362
58480
  writeSync as writeSync2
58363
58481
  } from "fs";
58364
58482
  import { tmpdir as tmpdir5 } from "os";
58365
- import { join as join53 } from "path";
58483
+ import { join as join54 } from "path";
58366
58484
  function installExitHook() {
58367
58485
  if (exitHookInstalled)
58368
58486
  return;
@@ -58375,7 +58493,7 @@ function installExitHook() {
58375
58493
  function stateOf(path, suffix) {
58376
58494
  let stat;
58377
58495
  try {
58378
- stat = statSync20(path + suffix);
58496
+ stat = statSync21(path + suffix);
58379
58497
  } catch {
58380
58498
  return null;
58381
58499
  }
@@ -58390,7 +58508,7 @@ function sameStates(a, b) {
58390
58508
  });
58391
58509
  }
58392
58510
  function writeNewFile(path, bytes) {
58393
- const fd = openSync9(path, constants5.O_WRONLY | constants5.O_CREAT | constants5.O_EXCL | constants5.O_NOFOLLOW, 384);
58511
+ const fd = openSync9(path, constants6.O_WRONLY | constants6.O_CREAT | constants6.O_EXCL | constants6.O_NOFOLLOW, 384);
58394
58512
  try {
58395
58513
  let offset = 0;
58396
58514
  while (offset < bytes.length)
@@ -58408,7 +58526,7 @@ function isOpenInThisProcess(target) {
58408
58526
  }
58409
58527
  return fds.some((fd) => {
58410
58528
  try {
58411
- const stat = statSync20(`/dev/fd/${fd}`);
58529
+ const stat = statSync21(`/dev/fd/${fd}`);
58412
58530
  return stat.dev === target.dev && stat.ino === target.ino;
58413
58531
  } catch {
58414
58532
  return false;
@@ -58416,7 +58534,7 @@ function isOpenInThisProcess(target) {
58416
58534
  });
58417
58535
  }
58418
58536
  function createPrivateCopy(source, options = {}) {
58419
- const main = statSync20(source);
58537
+ const main = statSync21(source);
58420
58538
  if (!main.isFile())
58421
58539
  refuse(`${source} is not a regular file`);
58422
58540
  if (!options.allowSourceOpenInThisProcessForTests && isOpenInThisProcess(main)) {
@@ -58429,7 +58547,7 @@ function createPrivateCopy(source, options = {}) {
58429
58547
  }
58430
58548
  }
58431
58549
  installExitHook();
58432
- const dir = mkdtempSync4(join53(tmpdir5(), "negotium-admin-"));
58550
+ const dir = mkdtempSync4(join54(tmpdir5(), "negotium-admin-"));
58433
58551
  try {
58434
58552
  openSafeDir(dir);
58435
58553
  for (let attempt = 1;attempt <= ATTEMPTS; attempt++) {
@@ -58440,7 +58558,7 @@ function createPrivateCopy(source, options = {}) {
58440
58558
  const lengthsMatch = contents.every((bytes, index) => bytes === null || bytes.length === before[index]?.size);
58441
58559
  if (!sameStates(before, after) || !lengthsMatch)
58442
58560
  continue;
58443
- const path = join53(dir, `copy-${attempt}.db`);
58561
+ const path = join54(dir, `copy-${attempt}.db`);
58444
58562
  const copiedSidecars = [];
58445
58563
  contents.forEach((bytes, index) => {
58446
58564
  if (!bytes)
@@ -58494,7 +58612,7 @@ var init_private_copy = __esm(() => {
58494
58612
 
58495
58613
  // ../cli/src/commands/admin/hub-report.ts
58496
58614
  import { createHash as createHash22 } from "crypto";
58497
- import { closeSync as closeSync10, constants as constants6, fstatSync as fstatSync3, openSync as openSync10, readSync as readSync3 } from "fs";
58615
+ import { closeSync as closeSync10, constants as constants7, fstatSync as fstatSync3, openSync as openSync10, readSync as readSync3 } from "fs";
58498
58616
  import { resolve as resolve31 } from "path";
58499
58617
  function parseMaxAge(value) {
58500
58618
  if (value === undefined)
@@ -58514,7 +58632,7 @@ function isHex64(value) {
58514
58632
  function readReportBytes(path) {
58515
58633
  let fd;
58516
58634
  try {
58517
- fd = openSync10(path, constants6.O_RDONLY | constants6.O_NOFOLLOW);
58635
+ fd = openSync10(path, constants7.O_RDONLY | constants7.O_NOFOLLOW);
58518
58636
  } catch (error) {
58519
58637
  return reportRejected(`cannot open --hub-report ${path}: ${error instanceof Error ? error.message : String(error)}`);
58520
58638
  }
@@ -60226,4 +60344,4 @@ switch (command) {
60226
60344
  }
60227
60345
  }
60228
60346
 
60229
- //# debugId=571F66E865703EC164756E2164756E21
60347
+ //# debugId=679C95BE9420CE7464756E2164756E21