@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
@@ -129,6 +129,68 @@ var init_vault_tool_policy = __esm(() => {
129
129
  DIRECT_VAULT_EXECUTION_TOOLS = new Set(["Bash", "WebFetch"]);
130
130
  });
131
131
 
132
+ // ../../packages/core/src/platform/browser-backend.ts
133
+ import { execFile } from "child_process";
134
+ import { accessSync, constants, statSync } from "fs";
135
+ import { homedir } from "os";
136
+ import { delimiter, isAbsolute as isAbsolute2, join } from "path";
137
+ import { promisify } from "util";
138
+ function resolveBrowserBackend(value, findEgoBrowser = resolveEgoBrowserBin) {
139
+ const backend = value?.trim();
140
+ if (!backend)
141
+ return findEgoBrowser() ? "egolite" : "chrome";
142
+ if (backend === "chrome" || backend === "egolite")
143
+ return backend;
144
+ throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
145
+ }
146
+ function resolveEgoBrowserBin(path = process.env.PATH ?? "", home = homedir()) {
147
+ const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
148
+ const directories = [...path.split(delimiter).filter(isAbsolute2), join(home, ".local", "bin")];
149
+ for (const directory of directories) {
150
+ for (const name of names) {
151
+ const candidate = join(directory, name);
152
+ try {
153
+ accessSync(candidate, constants.X_OK);
154
+ if (statSync(candidate).isFile())
155
+ return candidate;
156
+ } catch {}
157
+ }
158
+ }
159
+ return;
160
+ }
161
+ async function prepareEgoBrowser() {
162
+ const command = resolveEgoBrowserBin();
163
+ if (!command) {
164
+ throw new Error("ego-browser is not installed on this Negotium node or is not executable");
165
+ }
166
+ await promisify(execFile)(command, ["--version"], {
167
+ timeout: 5000,
168
+ maxBuffer: 16384,
169
+ windowsHide: true
170
+ });
171
+ return command;
172
+ }
173
+ var EGO_BROWSER_INSTRUCTIONS = `## Browser
174
+ This node uses ego lite through the official ego-browser CLI, using its existing logged-in browser.
175
+ The Chrome browser_* MCP tools are not registered. Never start browser-rs, point AB_CHROME at ego lite,
176
+ attach to its debugging port, or create a replacement browser/profile.
177
+ Use browser automation only when this turn's runtime reminder authorizes it. If it is unavailable or
178
+ the topic owner check denies access, do not bypass that decision through a shell or another tool.
179
+ When authorized, use the executable supplied by the runtime through your foreground shell tool.
180
+ Before the first browser action in a session, run that executable with "skill" and read its entire
181
+ installed-version guide. Use its "nodejs" command and documented APIs; do not assume Playwright APIs.
182
+ Create one task space for the user goal and retain its spaceId across commands and follow-up turns.
183
+ Use a unique task name tied to this topic and goal; never claim another topic's or a user's space
184
+ without explicit authorization. Existing login state is shared, not the user's other task spaces.
185
+ Stop when the user takes control. Hand off authentication to the user and resume the same task space
186
+ only after confirmation. On successful completion, call finish({ keep: [] }) unless the user needs
187
+ specific result tabs. On interruption, preserve the space for resumption; never kill the browser or
188
+ delete its profile. Do not close a space just because an AI turn ended.
189
+ Verify each action through the guide's observation APIs. Report CLI/browser errors as errors and do
190
+ not silently switch to Chrome. The CLI probe does not prove the browser is connected or authenticated.
191
+ Vault secret injection through browser-rs is not available here; do not copy secrets into scripts or logs.`;
192
+ var init_browser_backend = () => {};
193
+
132
194
  // ../../packages/core/src/types.ts
133
195
  function isAgentKind(value) {
134
196
  return typeof value === "string" && SUPPORTED_AGENTS.includes(value);
@@ -196,17 +258,17 @@ var init_logger = __esm(() => {
196
258
  import { execFileSync } from "child_process";
197
259
  import { randomBytes } from "crypto";
198
260
  import {
199
- accessSync,
261
+ accessSync as accessSync2,
200
262
  chmodSync,
201
- constants,
263
+ constants as constants2,
202
264
  existsSync as existsSync2,
203
265
  mkdirSync,
204
266
  readFileSync,
205
267
  writeFileSync
206
268
  } from "fs";
207
269
  import { createRequire } from "module";
208
- import { homedir } from "os";
209
- import { dirname as dirname2, join, resolve as resolve3 } from "path";
270
+ import { homedir as homedir2 } from "os";
271
+ import { dirname as dirname2, join as join2, resolve as resolve3 } from "path";
210
272
  import { fileURLToPath, pathToFileURL } from "url";
211
273
  function envText(envKey) {
212
274
  return readEnvText(process.env, envKey);
@@ -292,7 +354,7 @@ function resolveBrowserRsBin(envValue) {
292
354
  }
293
355
  const candidate = override ? resolve3(override) : resolve3(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
294
356
  try {
295
- accessSync(candidate, constants.X_OK);
357
+ accessSync2(candidate, constants2.X_OK);
296
358
  return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
297
359
  } catch {
298
360
  return;
@@ -302,7 +364,7 @@ function resolveBashRsBin(envValue) {
302
364
  const override = envValue?.trim();
303
365
  const candidate = override ? resolve3(override) : resolve3(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
304
366
  try {
305
- accessSync(candidate, constants.X_OK);
367
+ accessSync2(candidate, constants2.X_OK);
306
368
  return candidate;
307
369
  } catch {
308
370
  return;
@@ -340,7 +402,7 @@ function safeWorkspaceSegment(value, fallback) {
340
402
  return safeRuntimePathSegment(value, fallback);
341
403
  }
342
404
  function resolveTopicWorkspaceDir(topicId) {
343
- return join(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
405
+ return join2(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
344
406
  }
345
407
  function loadOrCreateLocalSecret(envKey, filename, options = {}) {
346
408
  const envValue = envText(envKey);
@@ -380,14 +442,15 @@ function resolveWhisperBackend() {
380
442
  return envText("WHISPER_BACKEND") === "mlx-whisper" ? "mlx-whisper" : "faster-whisper";
381
443
  }
382
444
  function codexAuthFilePath() {
383
- return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
445
+ return process.env.NEGOTIUM_CODEX_AUTH_FILE || join2(process.env.CODEX_HOME || join2(homedir2(), ".codex"), "auth.json");
384
446
  }
385
- 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;
447
+ 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;
386
448
  var init_config = __esm(() => {
449
+ init_browser_backend();
387
450
  init_config_helpers();
388
451
  init_logger();
389
452
  init_types();
390
- HOME = homedir();
453
+ HOME = homedir2();
391
454
  PROJECT_ROOT = resolveProjectRoot();
392
455
  STATE_DIR = resolveStateDir();
393
456
  WORKSPACE_DIR = resolveLocalStateDir("NEGOTIUM_WORKSPACE_DIR", "workspace");
@@ -395,6 +458,7 @@ var init_config = __esm(() => {
395
458
  SHARED_WIKI_DIR = resolve3(WORKSPACE_DIR, "wiki");
396
459
  CRON_WORKSPACE_DIR = resolve3(WORKSPACE_DIR, "cron");
397
460
  BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
461
+ BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
398
462
  BROWSER_PROFILES_DIR = resolve3(BROWSER_DIR, "profiles");
399
463
  BINARIES_DIR = resolve3(STATE_DIR, "binaries");
400
464
  SECRETS_DIR = resolve3(STATE_DIR, "secrets");
@@ -518,7 +582,7 @@ function agentAliases(agent) {
518
582
  "gpt-6-astra"
519
583
  ];
520
584
  case "claude":
521
- return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable"];
585
+ return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable", "fable-5.2"];
522
586
  case "maestro":
523
587
  return [
524
588
  "maestro",
@@ -1358,8 +1422,8 @@ var init_sqlite = __esm(async () => {
1358
1422
 
1359
1423
  // ../../packages/core/src/storage/storage-host.ts
1360
1424
  import { mkdirSync as mkdirSync2 } from "fs";
1361
- import { homedir as homedir2 } from "os";
1362
- import { dirname as dirname3, join as join2, resolve as resolve4 } from "path";
1425
+ import { homedir as homedir3 } from "os";
1426
+ import { dirname as dirname3, join as join3, resolve as resolve4 } from "path";
1363
1427
  function storageState() {
1364
1428
  const holder = globalThis;
1365
1429
  const existing = holder[STORAGE_HOST_STATE];
@@ -1387,23 +1451,23 @@ function envPath(name, fallback) {
1387
1451
  return resolve4(value || fallback);
1388
1452
  }
1389
1453
  function defaultStateDir() {
1390
- return envPath("NEGOTIUM_STATE_DIR", join2(homedir2(), ".negotium"));
1454
+ return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
1391
1455
  }
1392
1456
  function defaultDataDir() {
1393
- return envPath("NEGOTIUM_DATA_DIR", join2(defaultStateDir(), "data"));
1457
+ return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
1394
1458
  }
1395
1459
  function defaultLogDir() {
1396
- return envPath("NEGOTIUM_LOG_DIR", join2(defaultStateDir(), "logs"));
1460
+ return envPath("NEGOTIUM_LOG_DIR", join3(defaultStateDir(), "logs"));
1397
1461
  }
1398
1462
  function defaultWorkspaceDir() {
1399
- return envPath("NEGOTIUM_WORKSPACE_DIR", join2(defaultStateDir(), "workspace"));
1463
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join3(defaultStateDir(), "workspace"));
1400
1464
  }
1401
1465
  function defaultSessionAsksDir() {
1402
- const runDir = envPath("NEGOTIUM_RUN_DIR", join2(defaultStateDir(), "runtime"));
1403
- return join2(runDir, "session-asks");
1466
+ const runDir = envPath("NEGOTIUM_RUN_DIR", join3(defaultStateDir(), "runtime"));
1467
+ return join3(runDir, "session-asks");
1404
1468
  }
1405
1469
  function defaultSessionsDatabasePath() {
1406
- return envPath("SESSIONS_DB_PATH", join2(resolveStorageDataDir(), "sessions.db"));
1470
+ return envPath("SESSIONS_DB_PATH", join3(resolveStorageDataDir(), "sessions.db"));
1407
1471
  }
1408
1472
  function isSqliteBusy(error) {
1409
1473
  const message = error instanceof Error ? error.message : String(error);
@@ -1460,7 +1524,7 @@ function resolveStorageWorkspaceDir() {
1460
1524
  return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
1461
1525
  }
1462
1526
  function resolveStorageSharedWikiDir() {
1463
- return storageState().configuredHost.sharedWikiDir ?? join2(resolveStorageWorkspaceDir(), "wiki");
1527
+ return storageState().configuredHost.sharedWikiDir ?? join3(resolveStorageWorkspaceDir(), "wiki");
1464
1528
  }
1465
1529
  function registerStorageSchemaInitializer(initialize, priority = 100) {
1466
1530
  const initializers = storageState().schemaInitializers;
@@ -3464,6 +3528,8 @@ var init_mcp_config = __esm(async () => {
3464
3528
  playwright: {
3465
3529
  ...commonRuntimeMcpPolicy("playwright"),
3466
3530
  build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
3531
+ if (BROWSER_BACKEND === "egolite")
3532
+ return null;
3467
3533
  if (playwrightPort && playwrightCapability) {
3468
3534
  const owner = browserOwnerForContext({ userId, session, topicId });
3469
3535
  if (!owner)
@@ -3779,7 +3845,7 @@ var init_vault_crypto = __esm(() => {
3779
3845
 
3780
3846
  // ../../packages/core/src/storage/vault.ts
3781
3847
  import { chmodSync as chmodSync2, mkdirSync as mkdirSync3 } from "fs";
3782
- import { join as join3 } from "path";
3848
+ import { join as join4 } from "path";
3783
3849
  function initializeVaultDatabase(database) {
3784
3850
  database.exec("PRAGMA journal_mode = WAL");
3785
3851
  database.exec("PRAGMA busy_timeout = 5000");
@@ -3814,8 +3880,8 @@ function initializeVaultDatabase(database) {
3814
3880
  }
3815
3881
  }
3816
3882
  function openVaultDatabase(dataDir) {
3817
- const vaultDir = join3(dataDir, "vault");
3818
- const path = join3(vaultDir, "vault.db");
3883
+ const vaultDir = join4(dataDir, "vault");
3884
+ const path = join4(vaultDir, "vault.db");
3819
3885
  mkdirSync3(vaultDir, { recursive: true, mode: 448 });
3820
3886
  const database = new Database(path, { create: true });
3821
3887
  chmodSync2(path, 384);
@@ -4258,7 +4324,7 @@ import {
4258
4324
  openSync,
4259
4325
  readFileSync as readFileSync2,
4260
4326
  renameSync,
4261
- statSync,
4327
+ statSync as statSync2,
4262
4328
  unlinkSync as unlinkSync2,
4263
4329
  writeFileSync as writeFileSync2
4264
4330
  } from "fs";
@@ -4300,7 +4366,7 @@ function tryAcquireAppendLock(lockPath) {
4300
4366
  }
4301
4367
  function isStaleLock(lockPath) {
4302
4368
  try {
4303
- return Date.now() - statSync(lockPath).mtimeMs > lockStaleMs();
4369
+ return Date.now() - statSync2(lockPath).mtimeMs > lockStaleMs();
4304
4370
  } catch {
4305
4371
  return false;
4306
4372
  }
@@ -4400,12 +4466,12 @@ var init_jsonl = __esm(() => {
4400
4466
  // ../../packages/core/src/agents/rollout/claude.ts
4401
4467
  import { randomUUID as randomUUID2 } from "crypto";
4402
4468
  import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
4403
- import { homedir as homedir3 } from "os";
4404
- import { join as join4 } from "path";
4469
+ import { homedir as homedir4 } from "os";
4470
+ import { join as join5 } from "path";
4405
4471
  function loadClaudeAttachments() {
4406
4472
  if (_attachmentsCache)
4407
4473
  return _attachmentsCache;
4408
- const raw = readFileSync3(join4(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
4474
+ const raw = readFileSync3(join5(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
4409
4475
  const lines = parseJsonlText(raw);
4410
4476
  if (lines.length < 2) {
4411
4477
  throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
@@ -4506,8 +4572,8 @@ function writeClaudeRollout(opts) {
4506
4572
  });
4507
4573
  lastUuid = assistantUuid;
4508
4574
  }
4509
- const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
4510
- const path = join4(projectsDir, `${sessionId}.jsonl`);
4575
+ const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
4576
+ const path = join5(projectsDir, `${sessionId}.jsonl`);
4511
4577
  writeJsonlFile(path, lines);
4512
4578
  logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
4513
4579
  return { sessionId, rolloutPath: path };
@@ -4521,8 +4587,8 @@ var init_claude = __esm(() => {
4521
4587
 
4522
4588
  // ../../packages/core/src/agents/claude-registry.ts
4523
4589
  import { existsSync as existsSync4, mkdirSync as mkdirSync6, readdirSync, renameSync as renameSync2, unlinkSync as unlinkSync3 } from "fs";
4524
- import { homedir as homedir4 } from "os";
4525
- import { join as join5 } from "path";
4590
+ import { homedir as homedir5 } from "os";
4591
+ import { join as join6 } from "path";
4526
4592
  var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
4527
4593
  var init_claude_registry = __esm(() => {
4528
4594
  init_claude();
@@ -4532,7 +4598,8 @@ var init_claude_registry = __esm(() => {
4532
4598
  ALIAS_MAP = {
4533
4599
  sonnet: MODEL_SONNET,
4534
4600
  opus: MODEL_OPUS,
4535
- fable: MODEL_FABLE
4601
+ fable: MODEL_FABLE,
4602
+ "fable-5.2": MODEL_FABLE_5_2
4536
4603
  };
4537
4604
  VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));
4538
4605
  VALID_EFFORTS = new Set(CLAUDE_EFFORT_VALUES);
@@ -4569,11 +4636,11 @@ var init_claude_registry = __esm(() => {
4569
4636
  const result = await forkSession(parentSessionId, {
4570
4637
  ...title ? { title } : {}
4571
4638
  });
4572
- const projectsRoot = join5(homedir4(), ".claude", "projects");
4573
- const destDir = join5(projectsRoot, encodeClaudeCwd(cwd));
4574
- const destPath = join5(destDir, `${result.sessionId}.jsonl`);
4639
+ const projectsRoot = join6(homedir5(), ".claude", "projects");
4640
+ const destDir = join6(projectsRoot, encodeClaudeCwd(cwd));
4641
+ const destPath = join6(destDir, `${result.sessionId}.jsonl`);
4575
4642
  if (!existsSync4(destPath)) {
4576
- const sourcePath = readdirSync(projectsRoot).map((d) => join5(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync4(p));
4643
+ const sourcePath = readdirSync(projectsRoot).map((d) => join6(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync4(p));
4577
4644
  if (!sourcePath) {
4578
4645
  throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
4579
4646
  }
@@ -4586,10 +4653,10 @@ var init_claude_registry = __esm(() => {
4586
4653
  };
4587
4654
  },
4588
4655
  async cleanupRollouts({ cwd, sessionIds }) {
4589
- const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(cwd));
4656
+ const projectsDir = join6(homedir5(), ".claude", "projects", encodeClaudeCwd(cwd));
4590
4657
  const failures = [];
4591
4658
  for (const sid of sessionIds) {
4592
- const path = join5(projectsDir, `${sid}.jsonl`);
4659
+ const path = join6(projectsDir, `${sid}.jsonl`);
4593
4660
  try {
4594
4661
  unlinkSync3(path);
4595
4662
  } catch (e) {
@@ -4608,15 +4675,15 @@ var init_claude_registry = __esm(() => {
4608
4675
 
4609
4676
  // ../../packages/core/src/agents/rollout/codex.ts
4610
4677
  import { randomBytes as randomBytes4 } from "crypto";
4611
- import { existsSync as existsSync5, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync2, unlinkSync as unlinkSync4 } from "fs";
4612
- import { basename, dirname as dirname6, join as join6, resolve as resolve6 } from "path";
4678
+ import { existsSync as existsSync5, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync4 } from "fs";
4679
+ import { basename, dirname as dirname6, join as join7, resolve as resolve6 } from "path";
4613
4680
  function codexSessionsDir() {
4614
- return join6(hostedCodexHomePath(), "sessions");
4681
+ return join7(hostedCodexHomePath(), "sessions");
4615
4682
  }
4616
4683
  function loadCodexShell() {
4617
4684
  if (_shellCache)
4618
4685
  return _shellCache;
4619
- const raw = readFileSync4(join6(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
4686
+ const raw = readFileSync4(join7(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
4620
4687
  const lines = parseJsonlText(raw);
4621
4688
  if (lines.length < 5) {
4622
4689
  throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
@@ -4683,8 +4750,8 @@ function codexRolloutPath(threadId, fallback) {
4683
4750
  const hh = String(createdAt.getHours()).padStart(2, "0");
4684
4751
  const min = String(createdAt.getMinutes()).padStart(2, "0");
4685
4752
  const ss = String(createdAt.getSeconds()).padStart(2, "0");
4686
- const dir = join6(codexSessionsDir(), yyyy, mm, dd);
4687
- return join6(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
4753
+ const dir = join7(codexSessionsDir(), yyyy, mm, dd);
4754
+ return join7(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
4688
4755
  }
4689
4756
  function canonicalFilePath(path) {
4690
4757
  const absolute = resolve6(path);
@@ -4692,7 +4759,7 @@ function canonicalFilePath(path) {
4692
4759
  return realpathSync3(absolute);
4693
4760
  } catch {
4694
4761
  try {
4695
- return join6(realpathSync3(dirname6(absolute)), basename(absolute));
4762
+ return join7(realpathSync3(dirname6(absolute)), basename(absolute));
4696
4763
  } catch {
4697
4764
  return absolute;
4698
4765
  }
@@ -4981,22 +5048,22 @@ function latestCodexRolloutPath(threadId) {
4981
5048
  try {
4982
5049
  if (buckets) {
4983
5050
  for (const bucket of buckets) {
4984
- const dir = join6(sessionsDir, bucket);
5051
+ const dir = join7(sessionsDir, bucket);
4985
5052
  if (!existsSync5(dir))
4986
5053
  continue;
4987
5054
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
4988
5055
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
4989
- candidates.push(join6(dir, rel));
5056
+ candidates.push(join7(dir, rel));
4990
5057
  }
4991
5058
  }
4992
5059
  }
4993
5060
  if (candidates.length === 0) {
4994
5061
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
4995
5062
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
4996
- candidates.push(join6(sessionsDir, rel));
5063
+ candidates.push(join7(sessionsDir, rel));
4997
5064
  }
4998
5065
  }
4999
- return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
5066
+ return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
5000
5067
  } catch (error) {
5001
5068
  logger.debug({ error, threadId }, "codex rollout lookup failed");
5002
5069
  return;
@@ -5117,13 +5184,13 @@ function sweepPriorRolloutsForThread(threadId) {
5117
5184
  return;
5118
5185
  }
5119
5186
  for (const bucket of buckets) {
5120
- const dir = join6(sessionsDir, bucket);
5187
+ const dir = join7(sessionsDir, bucket);
5121
5188
  if (!existsSync5(dir))
5122
5189
  continue;
5123
5190
  try {
5124
5191
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
5125
5192
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
5126
- const fullPath = join6(dir, rel);
5193
+ const fullPath = join7(dir, rel);
5127
5194
  try {
5128
5195
  unlinkSync4(fullPath);
5129
5196
  } catch (e) {
@@ -5141,7 +5208,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
5141
5208
  try {
5142
5209
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
5143
5210
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
5144
- const fullPath = join6(sessionsDir, rel);
5211
+ const fullPath = join7(sessionsDir, rel);
5145
5212
  try {
5146
5213
  unlinkSync4(fullPath);
5147
5214
  } catch (e) {
@@ -5203,7 +5270,7 @@ var init_codex = __esm(async () => {
5203
5270
  });
5204
5271
 
5205
5272
  // ../../packages/core/src/version.ts
5206
- var NEGOTIUM_VERSION = "0.23.13";
5273
+ var NEGOTIUM_VERSION = "0.23.14";
5207
5274
 
5208
5275
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
5209
5276
  import { spawn as spawn2 } from "child_process";
@@ -5220,12 +5287,12 @@ import {
5220
5287
  writeFileSync as writeFileSync4
5221
5288
  } from "fs";
5222
5289
  import { tmpdir } from "os";
5223
- import { dirname as dirname7, join as join7 } from "path";
5290
+ import { dirname as dirname7, join as join8 } from "path";
5224
5291
  import { fileURLToPath as fileURLToPath2 } from "url";
5225
5292
  function findPackageJson(specifier, searchFromDir) {
5226
5293
  let dir = searchFromDir;
5227
5294
  for (;; ) {
5228
- const candidate = join7(dir, "node_modules", specifier, "package.json");
5295
+ const candidate = join8(dir, "node_modules", specifier, "package.json");
5229
5296
  if (existsSync6(candidate))
5230
5297
  return candidate;
5231
5298
  const parent = dirname7(dir);
@@ -5243,7 +5310,7 @@ function readPackageVersion(packageJsonPath) {
5243
5310
  return parsed.version;
5244
5311
  }
5245
5312
  function codexCliScriptPath() {
5246
- return join7(dirname7(bundledCodexPackagePath), "bin", "codex.js");
5313
+ return join8(dirname7(bundledCodexPackagePath), "bin", "codex.js");
5247
5314
  }
5248
5315
  function parseCodexModelCache(contents, sourcePath) {
5249
5316
  let parsed;
@@ -5284,7 +5351,7 @@ function writePrivateFileAtomic(path, contents) {
5284
5351
  }
5285
5352
  }
5286
5353
  function bundledCodexModelCachePath(authFilePath) {
5287
- return join7(dirname7(authFilePath), NEGOTIUM_MODEL_CACHE);
5354
+ return join8(dirname7(authFilePath), NEGOTIUM_MODEL_CACHE);
5288
5355
  }
5289
5356
  async function bootstrapCodexModelCache(codexHome, cachePath) {
5290
5357
  const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
@@ -5397,15 +5464,15 @@ function removeIsolatedCodexHome(dir) {
5397
5464
  }
5398
5465
  async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
5399
5466
  const sourceHome = dirname7(authFilePath);
5400
- const isolatedHome = mkdtempSync(join7(tmpdir(), "negotium-codex-models-"));
5401
- const isolatedCachePath = join7(isolatedHome, "models_cache.json");
5467
+ const isolatedHome = mkdtempSync(join8(tmpdir(), "negotium-codex-models-"));
5468
+ const isolatedCachePath = join8(isolatedHome, "models_cache.json");
5402
5469
  try {
5403
- const isolatedAuthPath = join7(isolatedHome, "auth.json");
5470
+ const isolatedAuthPath = join8(isolatedHome, "auth.json");
5404
5471
  copyFileSync(authFilePath, isolatedAuthPath);
5405
5472
  chmodSync3(isolatedAuthPath, 384);
5406
- const sourceConfigPath = join7(sourceHome, "config.toml");
5473
+ const sourceConfigPath = join8(sourceHome, "config.toml");
5407
5474
  if (existsSync6(sourceConfigPath)) {
5408
- const isolatedConfigPath = join7(isolatedHome, "config.toml");
5475
+ const isolatedConfigPath = join8(isolatedHome, "config.toml");
5409
5476
  copyFileSync(sourceConfigPath, isolatedConfigPath);
5410
5477
  chmodSync3(isolatedConfigPath, 384);
5411
5478
  }
@@ -5426,7 +5493,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
5426
5493
  return configuredCachePath;
5427
5494
  }
5428
5495
  const bundledCachePath = bundledCodexModelCachePath(authFilePath);
5429
- const sharedCachePath = join7(codexHome, "models_cache.json");
5496
+ const sharedCachePath = join8(codexHome, "models_cache.json");
5430
5497
  if (existsSync6(sharedCachePath)) {
5431
5498
  try {
5432
5499
  const shared = readCompatibleCodexModelCache(sharedCachePath);
@@ -5446,7 +5513,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
5446
5513
  }
5447
5514
  function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
5448
5515
  const codexHome = dirname7(authFilePath);
5449
- const outputPath = join7(codexHome, NEGOTIUM_MODEL_CATALOG);
5516
+ const outputPath = join8(codexHome, NEGOTIUM_MODEL_CATALOG);
5450
5517
  const parsed = readCodexModelCache(sourcePath).parsed;
5451
5518
  const models = parsed.models.map((model, index) => {
5452
5519
  if (!model || typeof model !== "object" || Array.isArray(model)) {
@@ -5590,7 +5657,7 @@ var init_codex_app_server = __esm(async () => {
5590
5657
 
5591
5658
  // ../../packages/core/src/agents/codex-registry.ts
5592
5659
  import { existsSync as existsSync7, unlinkSync as unlinkSync6 } from "fs";
5593
- import { join as join8 } from "path";
5660
+ import { join as join9 } from "path";
5594
5661
  var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
5595
5662
  var init_codex_registry = __esm(async () => {
5596
5663
  init_logger();
@@ -5635,7 +5702,7 @@ var init_codex_registry = __esm(async () => {
5635
5702
  async cleanupRollouts({ sessionIds }) {
5636
5703
  if (sessionIds.length === 0)
5637
5704
  return;
5638
- const sessionsDir = join8(hostedCodexHomePath(), "sessions");
5705
+ const sessionsDir = join9(hostedCodexHomePath(), "sessions");
5639
5706
  if (!existsSync7(sessionsDir))
5640
5707
  return;
5641
5708
  const failures = [];
@@ -5643,7 +5710,7 @@ var init_codex_registry = __esm(async () => {
5643
5710
  try {
5644
5711
  const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
5645
5712
  for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
5646
- const path = join8(sessionsDir, rel);
5713
+ const path = join9(sessionsDir, rel);
5647
5714
  try {
5648
5715
  unlinkSync6(path);
5649
5716
  } catch (e) {
@@ -5668,16 +5735,16 @@ var init_codex_registry = __esm(async () => {
5668
5735
  // ../../packages/core/src/agents/maestro-registry.ts
5669
5736
  import { randomUUID as randomUUID4 } from "crypto";
5670
5737
  import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
5671
- import { homedir as homedir5 } from "os";
5672
- import { join as join9, resolve as resolve7 } from "path";
5738
+ import { homedir as homedir6 } from "os";
5739
+ import { join as join10, resolve as resolve7 } from "path";
5673
5740
  function maestroSessionsDir() {
5674
- return join9(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join9(homedir5(), ".maestro"), "sessions");
5741
+ return join10(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join10(homedir6(), ".maestro"), "sessions");
5675
5742
  }
5676
5743
  function maestroSessionPath(sessionId) {
5677
- return join9(maestroSessionsDir(), `${sessionId}.jsonl`);
5744
+ return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
5678
5745
  }
5679
5746
  function maestroActiveSessionPath(sessionId) {
5680
- return join9(maestroSessionsDir(), `${sessionId}.active.jsonl`);
5747
+ return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
5681
5748
  }
5682
5749
  function existingCreatedAt(path) {
5683
5750
  if (!existsSync8(path))
@@ -5850,8 +5917,8 @@ function sanitizeId(id) {
5850
5917
  }
5851
5918
 
5852
5919
  // ../../packages/core/src/storage/tasks.ts
5853
- import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
5854
- import { dirname as dirname8, join as join10 } from "path";
5920
+ import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync4, writeFileSync as writeFileSync6 } from "fs";
5921
+ import { dirname as dirname8, join as join11 } from "path";
5855
5922
  function safeTaskScopeKey(scopeKey) {
5856
5923
  const safe = sanitizeFileName(scopeKey);
5857
5924
  if (!safe || safe === "." || safe === "..") {
@@ -5863,7 +5930,7 @@ function taskScopeKey(opts) {
5863
5930
  return opts.topicId?.trim() || opts.session || "default";
5864
5931
  }
5865
5932
  function getTaskFilePath(userId, scopeKey) {
5866
- return join10(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
5933
+ return join11(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
5867
5934
  }
5868
5935
  function readTasks(userId, scopeKey) {
5869
5936
  const path = getTaskFilePath(userId, scopeKey);
@@ -5879,7 +5946,7 @@ function readTasks(userId, scopeKey) {
5879
5946
  }
5880
5947
  function taskFileMtimeNs(userId, scopeKey) {
5881
5948
  try {
5882
- return statSync3(getTaskFilePath(userId, scopeKey), { bigint: true }).mtimeNs;
5949
+ return statSync4(getTaskFilePath(userId, scopeKey), { bigint: true }).mtimeNs;
5883
5950
  } catch {
5884
5951
  return null;
5885
5952
  }
@@ -5953,9 +6020,9 @@ import {
5953
6020
  unlinkSync as unlinkSync7,
5954
6021
  writeFileSync as writeFileSync7
5955
6022
  } from "fs";
5956
- import { dirname as dirname9, join as join11 } from "path";
6023
+ import { dirname as dirname9, join as join12 } from "path";
5957
6024
  function conversationDir(_userId) {
5958
- return join11(resolveStorageDataDir(), "conversations");
6025
+ return join12(resolveStorageDataDir(), "conversations");
5959
6026
  }
5960
6027
  function topicFilename(userId, topicName) {
5961
6028
  const t = sanitizeTopicName(topicName, true);
@@ -5965,7 +6032,7 @@ function topicFilename(userId, topicName) {
5965
6032
  return `${t}.${sanitizeId(owner)}.jsonl`;
5966
6033
  }
5967
6034
  function getConversationPath(userId, topicName) {
5968
- return join11(conversationDir(userId), topicFilename(userId, topicName));
6035
+ return join12(conversationDir(userId), topicFilename(userId, topicName));
5969
6036
  }
5970
6037
  function getActiveConversationPath(userId, topicName) {
5971
6038
  const rawPath = getConversationPath(userId, topicName);
@@ -7207,16 +7274,16 @@ var init_codex_tree_kill = __esm(() => {
7207
7274
  });
7208
7275
 
7209
7276
  // ../../packages/core/src/agents/codex-windows-wrapper.ts
7210
- import { execFile } from "child_process";
7277
+ import { execFile as execFile2 } from "child_process";
7211
7278
  import { createHash as createHash3, randomUUID as randomUUID6 } from "crypto";
7212
7279
  import { existsSync as existsSync12 } from "fs";
7213
7280
  import { mkdir, rename, rm, writeFile } from "fs/promises";
7214
- import { join as join12 } from "path";
7215
- import { promisify } from "util";
7281
+ import { join as join13 } from "path";
7282
+ import { promisify as promisify2 } from "util";
7216
7283
  function cscPath() {
7217
7284
  const windir = process.env.WINDIR ?? process.env.SystemRoot ?? "C:\\Windows";
7218
7285
  for (const framework of ["Framework64", "Framework"]) {
7219
- const candidate = join12(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe");
7286
+ const candidate = join13(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe");
7220
7287
  if (existsSync12(candidate))
7221
7288
  return candidate;
7222
7289
  }
@@ -7224,13 +7291,13 @@ function cscPath() {
7224
7291
  }
7225
7292
  async function ensureCodexWindowsWrapperExe(cacheDir) {
7226
7293
  const digest = createHash3("sha256").update(CODEX_WINDOWS_WRAPPER_SOURCE).digest("hex").slice(0, 12);
7227
- const exePath = join12(cacheDir, `codex-hook-wrapper-${digest}.exe`);
7294
+ const exePath = join13(cacheDir, `codex-hook-wrapper-${digest}.exe`);
7228
7295
  if (existsSync12(exePath))
7229
7296
  return exePath;
7230
7297
  await mkdir(cacheDir, { recursive: true });
7231
7298
  const stamp = randomUUID6();
7232
- const sourcePath = join12(cacheDir, `wrapper-${stamp}.cs`);
7233
- const tempExe = join12(cacheDir, `wrapper-${stamp}.exe`);
7299
+ const sourcePath = join13(cacheDir, `wrapper-${stamp}.cs`);
7300
+ const tempExe = join13(cacheDir, `wrapper-${stamp}.exe`);
7234
7301
  try {
7235
7302
  await writeFile(sourcePath, CODEX_WINDOWS_WRAPPER_SOURCE, "utf8");
7236
7303
  await execFileAsync(cscPath(), ["/nologo", "/target:exe", "/optimize+", `/out:${tempExe}`, sourcePath], { windowsHide: true, timeout: 60000 });
@@ -7252,7 +7319,7 @@ ${detail}` : ""}`);
7252
7319
  }
7253
7320
  var execFileAsync, CODEX_WINDOWS_WRAPPER_SOURCE;
7254
7321
  var init_codex_windows_wrapper = __esm(() => {
7255
- execFileAsync = promisify(execFile);
7322
+ execFileAsync = promisify2(execFile2);
7256
7323
  CODEX_WINDOWS_WRAPPER_SOURCE = String.raw`
7257
7324
  using System;
7258
7325
  using System.Diagnostics;
@@ -7368,7 +7435,7 @@ import { existsSync as existsSync13 } from "fs";
7368
7435
  import { chmod, copyFile, mkdtemp, rm as rm2, writeFile as writeFile2 } from "fs/promises";
7369
7436
  import { createServer } from "net";
7370
7437
  import { tmpdir as tmpdir2 } from "os";
7371
- import { dirname as dirname10, join as join13, resolve as resolve8 } from "path";
7438
+ import { dirname as dirname10, join as join14, resolve as resolve8 } from "path";
7372
7439
  import { fileURLToPath as fileURLToPath3 } from "url";
7373
7440
  function evaluateCodexVaultPreToolUse(input, userId, operations) {
7374
7441
  if (operations.referencesSensitiveStorage(input.tool_input)) {
@@ -7424,10 +7491,10 @@ function windowsQuote(value) {
7424
7491
  return `"${value.replaceAll('"', "\\\"")}"`;
7425
7492
  }
7426
7493
  async function createCodexVaultHookBridge(userId) {
7427
- const root = await mkdtemp(join13(tmpdir2(), "negotium-codex-vault-"));
7494
+ const root = await mkdtemp(join14(tmpdir2(), "negotium-codex-vault-"));
7428
7495
  await chmod(root, 448);
7429
- const socketPath = ipcEndpoint(join13(root, "hook.sock"));
7430
- const wrapperPath = join13(root, IS_WINDOWS2 ? "codex-with-hooks.exe" : "codex-with-hooks");
7496
+ const socketPath = ipcEndpoint(join14(root, "hook.sock"));
7497
+ const wrapperPath = join14(root, IS_WINDOWS2 ? "codex-with-hooks.exe" : "codex-with-hooks");
7431
7498
  const token = randomBytes5(32).toString("hex");
7432
7499
  const connections = new Set;
7433
7500
  const server = createServer((socket) => {
@@ -7478,9 +7545,9 @@ async function createCodexVaultHookBridge(userId) {
7478
7545
  restrictIpcEndpoint(socketPath);
7479
7546
  if (IS_WINDOWS2) {
7480
7547
  await Promise.resolve().then(() => init_config());
7481
- const cached = await ensureCodexWindowsWrapperExe(join13(BINARIES_DIR, "codex-hook-wrapper"));
7548
+ const cached = await ensureCodexWindowsWrapperExe(join14(BINARIES_DIR, "codex-hook-wrapper"));
7482
7549
  await copyFile(cached, wrapperPath);
7483
- await writeFile2(join13(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
7550
+ await writeFile2(join14(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
7484
7551
  `), { encoding: "utf8", mode: 384 });
7485
7552
  } else {
7486
7553
  await writeFile2(wrapperPath, privateCodexWrapper(codexCliScriptPath(), socketPath, token), {
@@ -7532,8 +7599,8 @@ var init_codex_vault_hook_bridge = __esm(async () => {
7532
7599
  });
7533
7600
 
7534
7601
  // ../../packages/core/src/agents/tool-format.ts
7535
- import { readFileSync as readFileSync10, statSync as statSync4 } from "fs";
7536
- import { isAbsolute as isAbsolute2, resolve as resolve9 } from "path";
7602
+ import { readFileSync as readFileSync10, statSync as statSync5 } from "fs";
7603
+ import { isAbsolute as isAbsolute3, resolve as resolve9 } from "path";
7537
7604
  import { diffLines as computeLineDiff } from "diff";
7538
7605
  function summarizeDisplayText(value) {
7539
7606
  const normalized = value.replace(/\s+/g, " ").trim();
@@ -7857,9 +7924,9 @@ function sourceStartLine(input, before, after, cwd) {
7857
7924
  const rawPath = input.file_path ?? input.path;
7858
7925
  if (typeof rawPath !== "string" || !rawPath.trim())
7859
7926
  return 1;
7860
- const path = isAbsolute2(rawPath) ? rawPath : resolve9(cwd ?? process.cwd(), rawPath);
7927
+ const path = isAbsolute3(rawPath) ? rawPath : resolve9(cwd ?? process.cwd(), rawPath);
7861
7928
  try {
7862
- if (statSync4(path).size > TOOL_DIFF_SOURCE_MAX_BYTES)
7929
+ if (statSync5(path).size > TOOL_DIFF_SOURCE_MAX_BYTES)
7863
7930
  return 1;
7864
7931
  const source = readFileSync10(path, "utf8").replace(/\r\n?/g, `
7865
7932
  `);
@@ -8056,9 +8123,9 @@ __export(exports_codex_provider, {
8056
8123
  toCodexMcpServers: () => toCodexMcpServers
8057
8124
  });
8058
8125
  import { execFileSync as execFileSync4 } from "child_process";
8059
- import { existsSync as existsSync14, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
8060
- import { homedir as homedir6 } from "os";
8061
- import { dirname as dirname11, isAbsolute as isAbsolute3, join as join14, relative as relative2, resolve as resolve10 } from "path";
8126
+ import { existsSync as existsSync14, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync6 } from "fs";
8127
+ import { homedir as homedir7 } from "os";
8128
+ import { dirname as dirname11, isAbsolute as isAbsolute4, join as join15, relative as relative2, resolve as resolve10 } from "path";
8062
8129
  import { Codex } from "@openai/codex-sdk";
8063
8130
  function codexNoticeStatus(message) {
8064
8131
  const firstLine = message.trim().split(`
@@ -8094,7 +8161,7 @@ function codexMcpServerName(name) {
8094
8161
  return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
8095
8162
  }
8096
8163
  function globalCodexMcpServerNames(authFilePath) {
8097
- const configPath = join14(dirname11(authFilePath), "config.toml");
8164
+ const configPath = join15(dirname11(authFilePath), "config.toml");
8098
8165
  if (!existsSync14(configPath))
8099
8166
  return [];
8100
8167
  try {
@@ -8204,7 +8271,7 @@ function textFile(path, maxBytes = CODEX_DIFF_FILE_LIMIT) {
8204
8271
  return null;
8205
8272
  try {
8206
8273
  const byteLimit = Math.min(CODEX_DIFF_FILE_LIMIT, Math.max(0, maxBytes));
8207
- if (statSync5(path).size > byteLimit)
8274
+ if (statSync6(path).size > byteLimit)
8208
8275
  return;
8209
8276
  const content = readFileSync11(path);
8210
8277
  if (content.byteLength > byteLimit || content.includes(0))
@@ -8253,9 +8320,9 @@ class CodexFilePreviewTracker {
8253
8320
  preview(path, succeeded) {
8254
8321
  if (!this.#root || !this.#baselineAvailable || !succeeded)
8255
8322
  return {};
8256
- const absolute = canonicalPath(isAbsolute3(path) ? path : resolve10(this.#cwd, path));
8323
+ const absolute = canonicalPath(isAbsolute4(path) ? path : resolve10(this.#cwd, path));
8257
8324
  const relativePath = relative2(this.#root, absolute);
8258
- if (!relativePath || relativePath.startsWith("..") || isAbsolute3(relativePath))
8325
+ if (!relativePath || relativePath.startsWith("..") || isAbsolute4(relativePath))
8259
8326
  return {};
8260
8327
  const before = this.#baseline.has(relativePath) ? this.#baseline.get(relativePath) : this.#headFile(relativePath);
8261
8328
  const after = textFile(absolute);
@@ -8289,7 +8356,7 @@ class CodexFilePreviewTracker {
8289
8356
  }
8290
8357
  }
8291
8358
  async function fileChangeEvents(item, previews, cwd, threadId, consumedPatchCallIds) {
8292
- const expectedPaths = item.changes.map((change) => isAbsolute3(change.path) ? change.path : resolve10(cwd, change.path));
8359
+ const expectedPaths = item.changes.map((change) => isAbsolute4(change.path) ? change.path : resolve10(cwd, change.path));
8293
8360
  let nativePreview;
8294
8361
  if (threadId && item.status === "completed") {
8295
8362
  await new Promise((resolveDelay) => setTimeout(resolveDelay, 20));
@@ -8457,7 +8524,7 @@ async function* codexProvider(opts) {
8457
8524
  mcpServerCount: Object.keys(codexMcpServers).length
8458
8525
  }, "codexProvider: starting turn");
8459
8526
  const hostedCodexHome = hostedCodexHomePath();
8460
- const inheritedCodexHome = process.env.CODEX_HOME || join14(homedir6(), ".codex");
8527
+ const inheritedCodexHome = process.env.CODEX_HOME || join15(homedir7(), ".codex");
8461
8528
  const codexEnvironment = scopedBrowserCapability || resolve10(hostedCodexHome) !== resolve10(inheritedCodexHome) ? {
8462
8529
  ...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
8463
8530
  CODEX_HOME: hostedCodexHome,
@@ -8926,8 +8993,8 @@ var init_maestro_provider = __esm(async () => {
8926
8993
 
8927
8994
  // ../../packages/core/src/agents/index.ts
8928
8995
  import { existsSync as existsSync15 } from "fs";
8929
- import { homedir as homedir7 } from "os";
8930
- import { join as join15 } from "path";
8996
+ import { homedir as homedir8 } from "os";
8997
+ import { join as join16 } from "path";
8931
8998
  async function* dispatchAgent(opts) {
8932
8999
  switch (opts.agent) {
8933
9000
  case "claude": {
@@ -8961,11 +9028,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
8961
9028
  switch (agent) {
8962
9029
  case "claude": {
8963
9030
  const encodedCwd = encodeClaudeCwd(cwd);
8964
- const path = join15(homedir7(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
9031
+ const path = join16(homedir8(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
8965
9032
  return !existsSync15(path);
8966
9033
  }
8967
9034
  case "codex": {
8968
- const sessionsDir = join15(hostedCodexHomePath(), "sessions");
9035
+ const sessionsDir = join16(hostedCodexHomePath(), "sessions");
8969
9036
  const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
8970
9037
  for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
8971
9038
  return false;
@@ -9125,6 +9192,7 @@ var init_model_catalog = __esm(() => {
9125
9192
  opus: "claude",
9126
9193
  haiku: "claude",
9127
9194
  fable: "claude",
9195
+ "fable-5.2": "claude",
9128
9196
  astra: "codex",
9129
9197
  sol: "codex",
9130
9198
  luna: "codex",
@@ -9202,6 +9270,16 @@ var init_model_catalog = __esm(() => {
9202
9270
  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",
9203
9271
  estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
9204
9272
  },
9273
+ {
9274
+ model: "fable-5.2",
9275
+ agent: "claude",
9276
+ description: "Claude Fable 5.2 (2026-11-09): same top-tier route as fable, newer and cheaper, for the hardest and longest-running tasks.",
9277
+ intelligenceTier: "fable",
9278
+ routingSummary: "hardest long-running work; cheaper than fable (5.1); explicit request only",
9279
+ accessCost: CLAUDE_MAX_20X_COST,
9280
+ 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)",
9281
+ estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
9282
+ },
9205
9283
  {
9206
9284
  model: "opus",
9207
9285
  agent: "claude",
@@ -9595,7 +9673,8 @@ function loadSessionPrompt(filename, fallback) {
9595
9673
  }
9596
9674
  function sharedToolsPartial() {
9597
9675
  if (_sharedToolsPartial === null) {
9598
- _sharedToolsPartial = loadSessionPrompt("_shared-tools.md", "");
9676
+ const shared = loadSessionPrompt("_shared-tools.md", "");
9677
+ _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, ""));
9599
9678
  }
9600
9679
  return _sharedToolsPartial;
9601
9680
  }
@@ -9772,7 +9851,7 @@ function buildRuntimeToolSection(opts, extensions) {
9772
9851
  "`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.",
9773
9852
  "`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.",
9774
9853
  "`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.",
9775
- "Never use `fable` unless the user explicitly requests it; it is expensive.",
9854
+ "Never use `fable` or `fable-5.2` unless the user explicitly requests it; they are expensive.",
9776
9855
  "",
9777
9856
  "Model catalog (capability/cost routing guidance):",
9778
9857
  MODEL_COST_ROUTING_SUMMARY,
@@ -9971,6 +10050,7 @@ This is the shared "General" hub of the user's workspace.
9971
10050
  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;
9972
10051
  var init_builders = __esm(() => {
9973
10052
  init_model_catalog();
10053
+ init_browser_backend();
9974
10054
  init_config();
9975
10055
  init_logger();
9976
10056
  PROMPTS_DIR = resolve12(PROJECT_ROOT, "src/prompts");
@@ -10096,9 +10176,9 @@ var init_api_topic_brief = __esm(async () => {
10096
10176
  });
10097
10177
 
10098
10178
  // ../../packages/core/src/storage/wiki.ts
10099
- import { basename as basename3, dirname as dirname12, join as join16 } from "path";
10179
+ import { basename as basename3, dirname as dirname12, join as join17 } from "path";
10100
10180
  function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
10101
- return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join16(workspaceDir, "wiki");
10181
+ return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join17(workspaceDir, "wiki");
10102
10182
  }
10103
10183
  var init_wiki = __esm(async () => {
10104
10184
  await init_storage_host();
@@ -10278,8 +10358,8 @@ var init_personal_general = __esm(async () => {
10278
10358
 
10279
10359
  // ../../packages/core/src/agents/archiver.ts
10280
10360
  import { randomUUID as randomUUID9 } from "crypto";
10281
- import { existsSync as existsSync16, readdirSync as readdirSync2, readFileSync as readFileSync13, statSync as statSync6 } from "fs";
10282
- import { join as join17 } from "path";
10361
+ import { existsSync as existsSync16, readdirSync as readdirSync2, readFileSync as readFileSync13, statSync as statSync7 } from "fs";
10362
+ import { join as join18 } from "path";
10283
10363
  function resolveMemoryLanguage() {
10284
10364
  const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
10285
10365
  return override && override.length > 0 ? override : resolveOutputLanguage();
@@ -10537,10 +10617,10 @@ function distillOneLine(summaryMd) {
10537
10617
  return "";
10538
10618
  }
10539
10619
  function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
10540
- const dir = join17(storage.getWikiDir(), "summaries");
10620
+ const dir = join18(storage.getWikiDir(), "summaries");
10541
10621
  if (!storage.fileExists(dir))
10542
10622
  return null;
10543
- const predicted = join17(dir, wikiSummaryFilename(date, topicTitle, topicId));
10623
+ const predicted = join18(dir, wikiSummaryFilename(date, topicTitle, topicId));
10544
10624
  if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
10545
10625
  return predicted;
10546
10626
  let best = null;
@@ -10548,7 +10628,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
10548
10628
  if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
10549
10629
  continue;
10550
10630
  }
10551
- const p = join17(dir, f);
10631
+ const p = join18(dir, f);
10552
10632
  try {
10553
10633
  const m = storage.fileModifiedAt(p);
10554
10634
  if (m >= sinceMs && (!best || m > best.mtime))
@@ -10637,8 +10717,8 @@ var init_archiver = __esm(async () => {
10637
10717
  fileExists: existsSync16,
10638
10718
  listDirectory: readdirSync2,
10639
10719
  readTextFile: (path) => readFileSync13(path, "utf-8"),
10640
- fileSize: (path) => statSync6(path).size,
10641
- fileModifiedAt: (path) => statSync6(path).mtimeMs,
10720
+ fileSize: (path) => statSync7(path).size,
10721
+ fileModifiedAt: (path) => statSync7(path).mtimeMs,
10642
10722
  getGeneralTopicId: (userId, sourceTopicId) => {
10643
10723
  const source = sourceTopicId ? getTopic(sourceTopicId) : null;
10644
10724
  return source ? ensurePersonalGeneral(userId, source.surface, {
@@ -10680,8 +10760,8 @@ var init_archiver = __esm(async () => {
10680
10760
  // ../../packages/core/src/agents/auth-check.ts
10681
10761
  import { execFileSync as execFileSync5 } from "child_process";
10682
10762
  import { existsSync as existsSync17 } from "fs";
10683
- import { homedir as homedir8, platform } from "os";
10684
- import { join as join18 } from "path";
10763
+ import { homedir as homedir9, platform } from "os";
10764
+ import { join as join19 } from "path";
10685
10765
  function hasMaestroCredential(host, key, userId) {
10686
10766
  if (userId && host.getVaultValue(userId, key)?.trim())
10687
10767
  return true;
@@ -10701,7 +10781,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
10701
10781
  case "claude": {
10702
10782
  if (host.environment.ANTHROPIC_API_KEY)
10703
10783
  return { ok: true };
10704
- const path = join18(host.homeDirectory(), ".claude", ".credentials.json");
10784
+ const path = join19(host.homeDirectory(), ".claude", ".credentials.json");
10705
10785
  if (host.operatingSystem() === "darwin") {
10706
10786
  if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
10707
10787
  return { ok: true };
@@ -10760,7 +10840,7 @@ var init_auth_check = __esm(async () => {
10760
10840
  codexAuthFilePath,
10761
10841
  exists: existsSync17,
10762
10842
  environment: process.env,
10763
- homeDirectory: homedir8,
10843
+ homeDirectory: homedir9,
10764
10844
  operatingSystem: platform,
10765
10845
  hasMacOsCredential(service) {
10766
10846
  try {
@@ -11358,13 +11438,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
11358
11438
 
11359
11439
  // ../../packages/core/src/storage/topic-archive.ts
11360
11440
  import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8 } from "fs";
11361
- import { join as join19 } from "path";
11441
+ import { join as join20 } from "path";
11362
11442
  function archiveTopicMessages(topicId, topicTitle, options = {}) {
11363
11443
  const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
11364
11444
  if (rows.length === 0)
11365
11445
  return null;
11366
11446
  const safeTopic = sanitizeTopicName(topicTitle, true);
11367
- const archiveDir = join19(getSharedWikiDir(), "archive");
11447
+ const archiveDir = join20(getSharedWikiDir(), "archive");
11368
11448
  mkdirSync10(archiveDir, { recursive: true });
11369
11449
  const date = new Date().toISOString().slice(0, 10);
11370
11450
  const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
@@ -11377,7 +11457,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
11377
11457
  let path;
11378
11458
  while (true) {
11379
11459
  filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
11380
- path = join19(archiveDir, filename);
11460
+ path = join20(archiveDir, filename);
11381
11461
  try {
11382
11462
  writeFileSync8(path, body, { flag: "wx" });
11383
11463
  break;
@@ -11422,7 +11502,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
11422
11502
  const entries = readRawConversation(userId, topicTitle);
11423
11503
  if (entries.length === 0)
11424
11504
  return null;
11425
- const archiveDir = join19(getSharedWikiDir(), "archive");
11505
+ const archiveDir = join20(getSharedWikiDir(), "archive");
11426
11506
  mkdirSync10(archiveDir, { recursive: true });
11427
11507
  const safeTopic = sanitizeTopicName(topicTitle, true);
11428
11508
  const date = new Date().toISOString().slice(0, 10);
@@ -11450,7 +11530,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
11450
11530
  let counter = 1;
11451
11531
  while (true) {
11452
11532
  const suffix = counter === 1 ? "" : `_${counter}`;
11453
- const path = join19(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
11533
+ const path = join20(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
11454
11534
  try {
11455
11535
  writeFileSync8(path, body, { flag: "wx" });
11456
11536
  logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
@@ -12848,13 +12928,13 @@ var init_browser_processes = __esm(async () => {
12848
12928
  });
12849
12929
 
12850
12930
  // ../../packages/core/src/platform/playwright/headed-launch.ts
12851
- import { accessSync as accessSync2, constants as constants2 } from "fs";
12852
- import { delimiter, isAbsolute as isAbsolute5, resolve as resolve15 } from "path";
12931
+ import { accessSync as accessSync3, constants as constants3 } from "fs";
12932
+ import { delimiter as delimiter2, isAbsolute as isAbsolute6, resolve as resolve15 } from "path";
12853
12933
  function findExecutableOnPath(command, environment = process.env) {
12854
- const candidates = isAbsolute5(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve15(directory, command));
12934
+ const candidates = isAbsolute6(command) ? [command] : (environment.PATH ?? "").split(delimiter2).filter(Boolean).map((directory) => resolve15(directory, command));
12855
12935
  for (const candidate of candidates) {
12856
12936
  try {
12857
- accessSync2(candidate, constants2.X_OK);
12937
+ accessSync3(candidate, constants3.X_OK);
12858
12938
  return candidate;
12859
12939
  } catch {}
12860
12940
  }
@@ -12952,7 +13032,7 @@ var init_vault_public = __esm(async () => {
12952
13032
  import { randomBytes as randomBytes6, timingSafeEqual as timingSafeEqual2 } from "crypto";
12953
13033
  import { createServer as createServer3 } from "net";
12954
13034
  import { tmpdir as tmpdir3 } from "os";
12955
- import { join as join20 } from "path";
13035
+ import { join as join21 } from "path";
12956
13036
  function deepMapStrings2(value, transform) {
12957
13037
  if (typeof value === "string")
12958
13038
  return transform(value);
@@ -13039,7 +13119,7 @@ function authorized(actual, expected) {
13039
13119
  }
13040
13120
  async function createBrowserVaultBroker(userId) {
13041
13121
  const token = randomBytes6(32).toString("hex");
13042
- const socketPath = ipcEndpoint(join20(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`));
13122
+ const socketPath = ipcEndpoint(join21(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`));
13043
13123
  const retainedForms = new Map;
13044
13124
  const leases = new Map;
13045
13125
  const sockets = new Set;
@@ -13261,7 +13341,7 @@ import {
13261
13341
  unlinkSync as unlinkSync11,
13262
13342
  writeFileSync as writeFileSync9
13263
13343
  } from "fs";
13264
- import { dirname as dirname13, join as join21, resolve as resolve16 } from "path";
13344
+ import { dirname as dirname13, join as join22, resolve as resolve16 } from "path";
13265
13345
  function removeDefaultProfileDataDir(userDataDir) {
13266
13346
  const root = resolve16(BROWSER_PROFILES_DIR);
13267
13347
  const target = resolve16(userDataDir);
@@ -13357,14 +13437,14 @@ function portFileName(instanceKey) {
13357
13437
  function writePortFile(instanceKey, port) {
13358
13438
  try {
13359
13439
  mkdirSync11(managerHost.portsDir, { recursive: true });
13360
- writeFileSync9(join21(managerHost.portsDir, portFileName(instanceKey)), String(port));
13440
+ writeFileSync9(join22(managerHost.portsDir, portFileName(instanceKey)), String(port));
13361
13441
  } catch (e) {
13362
13442
  logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
13363
13443
  }
13364
13444
  }
13365
13445
  function deletePortFile(instanceKey) {
13366
13446
  try {
13367
- unlinkSync11(join21(managerHost.portsDir, portFileName(instanceKey)));
13447
+ unlinkSync11(join22(managerHost.portsDir, portFileName(instanceKey)));
13368
13448
  } catch (e) {
13369
13449
  if (e.code === "ENOENT")
13370
13450
  return;
@@ -14167,7 +14247,7 @@ var init_compaction_tool_projection = __esm(() => {
14167
14247
  // ../../packages/core/src/storage/token-stats.ts
14168
14248
  import { createHash as createHash8 } from "crypto";
14169
14249
  import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync10 } from "fs";
14170
- import { join as join22 } from "path";
14250
+ import { join as join23 } from "path";
14171
14251
  function emptyBucket() {
14172
14252
  return {
14173
14253
  inputTokens: 0,
@@ -14186,7 +14266,7 @@ function queriesPath(userId) {
14186
14266
  const fileId = tokenStatsFileId(userId);
14187
14267
  const logDir = resolveStorageLogDir();
14188
14268
  mkdirSync12(logDir, { recursive: true });
14189
- return join22(logDir, `token-queries-${fileId}.jsonl`);
14269
+ return join23(logDir, `token-queries-${fileId}.jsonl`);
14190
14270
  }
14191
14271
  function loadRecords(userId) {
14192
14272
  try {
@@ -14339,6 +14419,8 @@ var init_token_stats = __esm(async () => {
14339
14419
  "codex:gpt-5.6-terra": { input: 2.5, cacheRead: 0.25, output: 15 },
14340
14420
  "codex:gpt-5.6-luna": { input: 1, cacheRead: 0.1, output: 6 },
14341
14421
  "claude:fable": { input: 10, cacheWrite: 12.5, cacheRead: 0.25, output: 50 },
14422
+ "claude:fable-5.2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
14423
+ "claude:claude-fable-5-2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
14342
14424
  "claude:opus": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
14343
14425
  "claude:claude-opus-5-5": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
14344
14426
  "claude:sonnet": { input: 2, cacheWrite: 2.5, cacheRead: 0.2, output: 10 },
@@ -15026,7 +15108,7 @@ var init_runtime_turn_requests = __esm(async () => {
15026
15108
  import { randomUUID as randomUUID13 } from "crypto";
15027
15109
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
15028
15110
  import { tmpdir as tmpdir4 } from "os";
15029
- import { join as join23 } from "path";
15111
+ import { join as join24 } from "path";
15030
15112
  async function fenceTopicWork(topicId, maintenance) {
15031
15113
  for (const queryId of cancelRuntimeUserTurnRequestsBeforeEpoch(topicId, maintenance.epoch)) {
15032
15114
  WsHub.get().broadcastAborted(topicId, queryId, "stopped");
@@ -15235,7 +15317,7 @@ function formatCompactElapsed(startedAt) {
15235
15317
  async function summarizeTopicContext(request) {
15236
15318
  const startedAt = Date.now();
15237
15319
  const sessionIds = [];
15238
- const compactCwd = mkdtempSync2(join23(tmpdir4(), "negotium-compact-"));
15320
+ const compactCwd = mkdtempSync2(join24(tmpdir4(), "negotium-compact-"));
15239
15321
  const abortController = new AbortController;
15240
15322
  const relayAbort = () => abortController.abort(request.signal?.reason);
15241
15323
  if (request.signal?.aborted)
@@ -15262,7 +15344,7 @@ async function summarizeTopicContext(request) {
15262
15344
  let error = "";
15263
15345
  let toolViolation = false;
15264
15346
  let compactionLogCalls = 0;
15265
- const compactionLogPath = join23(compactCwd, "conversation.log");
15347
+ const compactionLogPath = join24(compactCwd, "conversation.log");
15266
15348
  try {
15267
15349
  const compactionMcp = useCompactionLog ? {
15268
15350
  compact_log: {
@@ -16022,16 +16104,16 @@ var init_derive = __esm(async () => {
16022
16104
 
16023
16105
  // ../../packages/core/src/query/state.ts
16024
16106
  import { mkdirSync as mkdirSync15, renameSync as renameSync7, unlinkSync as unlinkSync14, writeFileSync as writeFileSync13 } from "fs";
16025
- import { basename as basename4, join as join24 } from "path";
16107
+ import { basename as basename4, join as join25 } from "path";
16026
16108
  function createQueryStateStore(options) {
16027
16109
  const sanitize = options.sanitizeTopicId ?? sanitizeId;
16028
- const queryStateDirPath = (userId) => join24(options.usersLogDir, String(userId), "active-queries");
16029
- const queryStateFile = (userId, topicId) => join24(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
16110
+ const queryStateDirPath = (userId) => join25(options.usersLogDir, String(userId), "active-queries");
16111
+ const queryStateFile = (userId, topicId) => join25(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
16030
16112
  const legacyQueryStateFile = (userId, topicName) => {
16031
16113
  if (!topicName || topicName === "." || topicName === ".." || basename4(topicName) !== topicName) {
16032
16114
  return null;
16033
16115
  }
16034
- return join24(queryStateDirPath(userId), `${topicName}.json`);
16116
+ return join25(queryStateDirPath(userId), `${topicName}.json`);
16035
16117
  };
16036
16118
  return {
16037
16119
  write(userId, topicId, topicName, task) {
@@ -16152,14 +16234,14 @@ var init_actor_topic_reach = __esm(async () => {
16152
16234
  });
16153
16235
 
16154
16236
  // ../../packages/core/src/query/session-inbox-path.ts
16155
- import { join as join25 } from "path";
16237
+ import { join as join26 } from "path";
16156
16238
  function sessionInboxPath(userId, topicId) {
16157
16239
  const key = Buffer.from(topicId, "utf8").toString("base64url");
16158
- return join25(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
16240
+ return join26(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
16159
16241
  }
16160
16242
  function scheduledSessionInboxPath(userId, topicId) {
16161
16243
  const key = Buffer.from(topicId, "utf8").toString("base64url");
16162
- return join25(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
16244
+ return join26(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
16163
16245
  }
16164
16246
  var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
16165
16247
  var init_session_inbox_path = __esm(() => {
@@ -16167,12 +16249,12 @@ var init_session_inbox_path = __esm(() => {
16167
16249
  });
16168
16250
 
16169
16251
  // ../../packages/core/src/storage/session-inbox-signal.ts
16170
- import { join as join26 } from "path";
16252
+ import { join as join27 } from "path";
16171
16253
  var SESSION_INBOX_WAKE_FILE, listeners;
16172
16254
  var init_session_inbox_signal = __esm(() => {
16173
16255
  init_config();
16174
16256
  init_logger();
16175
- SESSION_INBOX_WAKE_FILE = join26(SESSION_INBOX_DIR, ".wake");
16257
+ SESSION_INBOX_WAKE_FILE = join27(SESSION_INBOX_DIR, ".wake");
16176
16258
  listeners = new Set;
16177
16259
  });
16178
16260
 
@@ -16210,13 +16292,13 @@ var init_session_inbox = __esm(async () => {
16210
16292
 
16211
16293
  // ../../packages/core/src/query/session-inbox-cleanup.ts
16212
16294
  import { unlinkSync as unlinkSync15 } from "fs";
16213
- import { basename as basename5, join as join27 } from "path";
16295
+ import { basename as basename5, join as join28 } from "path";
16214
16296
  function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
16215
16297
  const live = sessionInboxPath(userId, topicId);
16216
16298
  const scheduled = scheduledSessionInboxPath(userId, topicId);
16217
16299
  const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
16218
16300
  if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename5(legacyTopicTitle) === legacyTopicTitle) {
16219
- const legacyBase = join27(SESSION_INBOX_DIR, userId, legacyTopicTitle);
16301
+ const legacyBase = join28(SESSION_INBOX_DIR, userId, legacyTopicTitle);
16220
16302
  for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
16221
16303
  candidates.add(`${legacyBase}${suffix}`);
16222
16304
  }
@@ -16458,33 +16540,33 @@ import {
16458
16540
  openSync as openSync2,
16459
16541
  readdirSync as readdirSync4,
16460
16542
  readFileSync as readFileSync16,
16461
- statSync as statSync8,
16543
+ statSync as statSync9,
16462
16544
  unlinkSync as unlinkSync16,
16463
16545
  writeFileSync as writeFileSync14
16464
16546
  } from "fs";
16465
- import { dirname as dirname15, join as join28 } from "path";
16547
+ import { dirname as dirname15, join as join29 } from "path";
16466
16548
  function pendingAskDir(userId) {
16467
16549
  const rawUserId = String(userId);
16468
16550
  const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash10("sha256").update(rawUserId).digest("hex")}`;
16469
- return join28(resolveStorageSessionAsksDir(), safeUserId);
16551
+ return join29(resolveStorageSessionAsksDir(), safeUserId);
16470
16552
  }
16471
16553
  function encodeAskKey(key) {
16472
16554
  return JSON.stringify([key.from, key.to]);
16473
16555
  }
16474
16556
  function pendingAskPath(key) {
16475
16557
  const digest = createHash10("sha256").update(encodeAskKey(key)).digest("hex");
16476
- return join28(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
16558
+ return join29(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
16477
16559
  }
16478
16560
  function v2PendingAskPath(key) {
16479
16561
  const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
16480
- return join28(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
16562
+ return join29(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
16481
16563
  }
16482
16564
  function legacyPendingAskPath(key) {
16483
16565
  if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
16484
16566
  return null;
16485
16567
  }
16486
16568
  const dir = pendingAskDir(key.userId);
16487
- const candidate = join28(dir, `${key.from}___${key.to}.pending`);
16569
+ const candidate = join29(dir, `${key.from}___${key.to}.pending`);
16488
16570
  return dirname15(candidate) === dir ? candidate : null;
16489
16571
  }
16490
16572
  function parsePendingAskFilename(fileName) {
@@ -16510,7 +16592,7 @@ function readPendingAskFile(path, fallback) {
16510
16592
  if (!raw)
16511
16593
  return null;
16512
16594
  if (!raw.startsWith("{")) {
16513
- const ts = new Date(statSync8(path).mtimeMs).toISOString();
16595
+ const ts = new Date(statSync9(path).mtimeMs).toISOString();
16514
16596
  return {
16515
16597
  userId: fallback.userId,
16516
16598
  from: fallback.from,
@@ -16636,7 +16718,7 @@ function deletePendingAsksForTopic(args) {
16636
16718
  }
16637
16719
  let deleted = 0;
16638
16720
  for (const fileName of files) {
16639
- const path = join28(dir, fileName);
16721
+ const path = join29(dir, fileName);
16640
16722
  const parsed = parsePendingAskFilename(fileName);
16641
16723
  const record = readPendingAskFile(path, {
16642
16724
  userId: args.userId,
@@ -17696,7 +17778,7 @@ var init_lifecycle = __esm(async () => {
17696
17778
 
17697
17779
  // ../../packages/core/src/runtime/attachments.ts
17698
17780
  import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
17699
- import { basename as basename6, join as join29 } from "path";
17781
+ import { basename as basename6, join as join30 } from "path";
17700
17782
  function workspaceCwdFor(topicId) {
17701
17783
  return resolveTopicWorkspaceDir(topicId);
17702
17784
  }
@@ -17709,7 +17791,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
17709
17791
  if (!attachmentIds?.length)
17710
17792
  return [];
17711
17793
  const out = [];
17712
- const destDir = join29(workspaceCwdFor(topicId), "attachments", queryId);
17794
+ const destDir = join30(workspaceCwdFor(topicId), "attachments", queryId);
17713
17795
  for (const rawId of attachmentIds) {
17714
17796
  if (typeof rawId !== "string")
17715
17797
  continue;
@@ -17726,7 +17808,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
17726
17808
  mkdirSync17(destDir, { recursive: true });
17727
17809
  const index = String(out.length + 1).padStart(2, "0");
17728
17810
  const safeName = safeAttachmentFilename(attachment.filename, fileId);
17729
- const destPath = join29(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
17811
+ const destPath = join30(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
17730
17812
  copyFileSync2(sourcePath, destPath);
17731
17813
  out.push({
17732
17814
  id: attachment.id,
@@ -18824,7 +18906,7 @@ var init_visual_html = __esm(() => {
18824
18906
 
18825
18907
  // ../../packages/core/src/runtime/visuals.ts
18826
18908
  import { realpathSync as realpathSync5 } from "fs";
18827
- import { isAbsolute as isAbsolute6, resolve as resolve17 } from "path";
18909
+ import { isAbsolute as isAbsolute7, resolve as resolve17 } from "path";
18828
18910
  function activeVisualHtmlForPrompt(html) {
18829
18911
  if (html.length <= ACTIVE_VISUAL_PROMPT_MAX_CHARS) {
18830
18912
  return { html, omittedChars: 0 };
@@ -18929,7 +19011,7 @@ function locateVisualMediaInput(topicId, input) {
18929
19011
  }
18930
19012
  const rawPath = input.file_path.trim();
18931
19013
  const cwd = workspaceCwdFor(topicId);
18932
- const candidate = isAbsolute6(rawPath) ? rawPath : resolve17(cwd, rawPath);
19014
+ const candidate = isAbsolute7(rawPath) ? rawPath : resolve17(cwd, rawPath);
18933
19015
  let realCandidate;
18934
19016
  try {
18935
19017
  realCandidate = realpathSync5(candidate);
@@ -18985,8 +19067,8 @@ var init_visuals = __esm(async () => {
18985
19067
 
18986
19068
  // ../../packages/core/src/runtime/turn-event-stream.ts
18987
19069
  import { randomUUID as randomUUID18 } from "crypto";
18988
- import { realpathSync as realpathSync6, statSync as statSync9 } from "fs";
18989
- import { isAbsolute as isAbsolute7, resolve as resolve18 } from "path";
19070
+ import { realpathSync as realpathSync6, statSync as statSync10 } from "fs";
19071
+ import { isAbsolute as isAbsolute8, resolve as resolve18 } from "path";
18990
19072
  function sessionEventMatchesCurrentExecution(topicId, queryId, agent, model) {
18991
19073
  if (getRoomQuery(topicId)?.queryId !== queryId)
18992
19074
  return false;
@@ -19012,6 +19094,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19012
19094
  let accumulatedText = "";
19013
19095
  let pendingText = "";
19014
19096
  let previewText = "";
19097
+ let blockStart = null;
19098
+ let lastCompletedBlock = "";
19015
19099
  let pendingMessage = null;
19016
19100
  let previewTimer = null;
19017
19101
  const clearPreviewTimer = () => {
@@ -19126,6 +19210,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19126
19210
  const text = pendingText.trimEnd();
19127
19211
  pendingText = "";
19128
19212
  previewText = "";
19213
+ lastCompletedBlock = "";
19214
+ blockStart = null;
19129
19215
  if (silent || !text.trim()) {
19130
19216
  if (identity && !silent) {
19131
19217
  hub.broadcastMessageUpdated(topicId, identity.id, { deleted: true, text: "" });
@@ -19194,6 +19280,9 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19194
19280
  }
19195
19281
  switch (event.type) {
19196
19282
  case "text_delta": {
19283
+ if (!pendingSawDelta) {
19284
+ blockStart = { accumulated: accumulatedText.length, pending: pendingText.length };
19285
+ }
19197
19286
  pendingSawDelta = true;
19198
19287
  const incoming = event.content;
19199
19288
  accumulatedText += incoming;
@@ -19209,9 +19298,26 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
19209
19298
  break;
19210
19299
  case "text":
19211
19300
  previewText = "";
19212
- if (pendingSawDelta) {
19213
- pendingSawDelta = false;
19214
- break;
19301
+ {
19302
+ const completed = event.content.trim();
19303
+ const repeatsPreviousBlock = completed !== "" && completed === lastCompletedBlock;
19304
+ if (pendingSawDelta) {
19305
+ pendingSawDelta = false;
19306
+ if (repeatsPreviousBlock && blockStart) {
19307
+ accumulatedText = accumulatedText.slice(0, blockStart.accumulated);
19308
+ pendingText = pendingText.slice(0, blockStart.pending);
19309
+ assistantContextTokens = estimateTextTokens(accumulatedText);
19310
+ broadcastContextProgress();
19311
+ } else if (completed) {
19312
+ lastCompletedBlock = completed;
19313
+ }
19314
+ blockStart = null;
19315
+ break;
19316
+ }
19317
+ if (repeatsPreviousBlock)
19318
+ break;
19319
+ if (completed)
19320
+ lastCompletedBlock = completed;
19215
19321
  }
19216
19322
  {
19217
19323
  const incoming = event.content;
@@ -19387,7 +19493,7 @@ ${JSON.stringify(event.input ?? {})}`);
19387
19493
  case "file":
19388
19494
  if (!silent && peerBridge) {
19389
19495
  const cwd = workspaceCwdFor(topicId);
19390
- const path = isAbsolute7(event.path) ? event.path : resolve18(cwd, event.path);
19496
+ const path = isAbsolute8(event.path) ? event.path : resolve18(cwd, event.path);
19391
19497
  if (!isPathInside(cwd, path)) {
19392
19498
  logger.warn({ topicId, path }, "peer output file is outside the topic workspace");
19393
19499
  break;
@@ -19395,7 +19501,7 @@ ${JSON.stringify(event.input ?? {})}`);
19395
19501
  let safePath;
19396
19502
  try {
19397
19503
  safePath = realpathSync6(path);
19398
- if (!statSync9(safePath).isFile()) {
19504
+ if (!statSync10(safePath).isFile()) {
19399
19505
  logger.warn({ topicId, path }, "peer output path is not a regular file");
19400
19506
  break;
19401
19507
  }
@@ -19725,9 +19831,9 @@ var init_turn_session = __esm(async () => {
19725
19831
 
19726
19832
  // ../../packages/core/src/storage/app-settings.ts
19727
19833
  import { existsSync as existsSync21, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
19728
- import { dirname as dirname16, join as join30 } from "path";
19834
+ import { dirname as dirname16, join as join31 } from "path";
19729
19835
  function settingsFile() {
19730
- return join30(resolveStorageDataDir(), "otium-settings.json");
19836
+ return join31(resolveStorageDataDir(), "otium-settings.json");
19731
19837
  }
19732
19838
  function getGlobalAiName() {
19733
19839
  const path = settingsFile();
@@ -19748,8 +19854,8 @@ var init_app_settings = __esm(async () => {
19748
19854
 
19749
19855
  // ../../packages/core/src/runtime/turn-runner.ts
19750
19856
  import { randomUUID as randomUUID19 } from "crypto";
19751
- import { existsSync as existsSync22, mkdirSync as mkdirSync19, readdirSync as readdirSync5, statSync as statSync10 } from "fs";
19752
- import { join as join31 } from "path";
19857
+ import { existsSync as existsSync22, mkdirSync as mkdirSync19, readdirSync as readdirSync5, statSync as statSync11 } from "fs";
19858
+ import { join as join32 } from "path";
19753
19859
  function withDefaultPlaywright(configuredMcp, isManager) {
19754
19860
  if (isManager)
19755
19861
  return configuredMcp;
@@ -19813,7 +19919,7 @@ function appendAskReplyMessage(topicId, text, sourceLabel, body, kind, agentType
19813
19919
  return message;
19814
19920
  }
19815
19921
  function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
19816
- const preferred = join31(directory, preferredFilename);
19922
+ const preferred = join32(directory, preferredFilename);
19817
19923
  if (preferExact && existsSync22(preferred))
19818
19924
  return preferred;
19819
19925
  let newestLegacyId = null;
@@ -19824,8 +19930,8 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
19824
19930
  const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
19825
19931
  if (!titleMatch && !legacyIdMatch)
19826
19932
  continue;
19827
- const path = join31(directory, filename);
19828
- const mtimeMs = statSync10(path).mtimeMs;
19933
+ const path = join32(directory, filename);
19934
+ const mtimeMs = statSync11(path).mtimeMs;
19829
19935
  if (titleMatch) {
19830
19936
  if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
19831
19937
  newestTitle = { path, mtimeMs };
@@ -19838,10 +19944,10 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
19838
19944
  return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
19839
19945
  }
19840
19946
  function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
19841
- const briefFile = resolveWikiMirrorPath(join31(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
19842
- const hasBriefFile = existsSync22(briefFile) && statSync10(briefFile).isFile();
19843
- const latestSummaryCandidate = resolveWikiMirrorPath(join31(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
19844
- const latestSummaryFile = existsSync22(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
19947
+ const briefFile = resolveWikiMirrorPath(join32(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
19948
+ const hasBriefFile = existsSync22(briefFile) && statSync11(briefFile).isFile();
19949
+ const latestSummaryCandidate = resolveWikiMirrorPath(join32(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
19950
+ const latestSummaryFile = existsSync22(latestSummaryCandidate) && statSync11(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
19845
19951
  return { briefFile, hasBriefFile, latestSummaryFile };
19846
19952
  }
19847
19953
  async function streamAgentEvents(topicId, topicTitle, queryId, events, control, agentType, model, effort, userId, retryableSessionExpired = true, onSessionId, execution) {
@@ -20680,7 +20786,8 @@ function startAiTurn(params) {
20680
20786
  const enabledMcp = withDefaultPlaywright(configuredMcp, isManager);
20681
20787
  const playwrightRequested = !isManager && enabledMcp.includes("playwright");
20682
20788
  const browserProfileOwner = isTopicBrowserProfileOwner(topic.id, userId);
20683
- const wantsPlaywright = playwrightRequested && browserProfileOwner;
20789
+ const wantsPlaywright = playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "chrome";
20790
+ const wantsEgoBrowser = playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "egolite";
20684
20791
  const turnMcpEnabled = browserProfileOwner ? enabledMcp : enabledMcp.filter((name) => name !== "playwright");
20685
20792
  const wantsBgBash = !isManager && enabledMcp.includes("background-bash");
20686
20793
  async function* runWithPlaywright() {
@@ -20710,6 +20817,15 @@ function startAiTurn(params) {
20710
20817
  let playwrightCapability;
20711
20818
  let playwrightInstanceKey;
20712
20819
  let bgBashPort;
20820
+ if (wantsEgoBrowser) {
20821
+ try {
20822
+ const command = await prepareEgoBrowser();
20823
+ 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>`);
20824
+ } catch (err) {
20825
+ logger.warn({ topicId, err }, "ai: ego-browser CLI unavailable");
20826
+ 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>");
20827
+ }
20828
+ }
20713
20829
  if (wantsPlaywright) {
20714
20830
  try {
20715
20831
  playwrightInstanceKey = makeInstanceKey(userId, topic.id);
@@ -20740,7 +20856,7 @@ function startAiTurn(params) {
20740
20856
  }
20741
20857
  }
20742
20858
  if (playwrightRequested && !browserProfileOwner) {
20743
- 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>");
20859
+ 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>");
20744
20860
  }
20745
20861
  if (consumePlaywrightUnavailable(userId, topic.title)) {
20746
20862
  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>");
@@ -21094,6 +21210,8 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
21094
21210
  var PLAYWRIGHT_UNAVAILABLE_NOTICE_COOLDOWN_MS, ASK_REPLY_INJECT_BATCH_MS = 500, playwrightUnavailableNoticeAt, askReplyInjectBatcher, remoteInjectWaiters;
21095
21211
  var init_turn_runner = __esm(async () => {
21096
21212
  init_manager();
21213
+ init_browser_backend();
21214
+ init_config();
21097
21215
  init_constants();
21098
21216
  init_logger();
21099
21217
  init_builders();
@@ -21238,7 +21356,7 @@ function createSubagentLifecycle(host) {
21238
21356
  }
21239
21357
  function canSpawnSubagentsFromTopic(topicId) {
21240
21358
  const topic = host.storage.getTopic(topicId);
21241
- return topic?.kind === "agent" && computeSubagentDepth(topicId) < limits.maxDepth;
21359
+ return topic?.kind === "agent" && topic.surface !== "otium" && computeSubagentDepth(topicId) < limits.maxDepth;
21242
21360
  }
21243
21361
  function patchSubagentCard(parentTopicId, cardMessageId, patch) {
21244
21362
  const current = host.storage.getMessage(parentTopicId, cardMessageId)?.subagentCard;
@@ -22044,8 +22162,8 @@ init_common();
22044
22162
  import { z as z2 } from "zod";
22045
22163
 
22046
22164
  // ../../packages/core/src/agents/mcp-tools/inline-assets.ts
22047
- import { existsSync as existsSync19, readFileSync as readFileSync14, statSync as statSync7 } from "fs";
22048
- import { extname, isAbsolute as isAbsolute4, resolve as resolve13 } from "path";
22165
+ import { existsSync as existsSync19, readFileSync as readFileSync14, statSync as statSync8 } from "fs";
22166
+ import { extname, isAbsolute as isAbsolute5, resolve as resolve13 } from "path";
22049
22167
  var MIME_BY_EXT = {
22050
22168
  ".apng": "image/apng",
22051
22169
  ".avif": "image/avif",
@@ -22094,15 +22212,15 @@ function inlineLocalAssets(html, options) {
22094
22212
  const relPath = stripSuffix(ref);
22095
22213
  if (!relPath)
22096
22214
  return null;
22097
- const abs = isAbsolute4(relPath) ? relPath : resolve13(baseDir, relPath);
22215
+ const abs = isAbsolute5(relPath) ? relPath : resolve13(baseDir, relPath);
22098
22216
  let bytes;
22099
22217
  try {
22100
- if (!existsSync19(abs) || !statSync7(abs).isFile()) {
22218
+ if (!existsSync19(abs) || !statSync8(abs).isFile()) {
22101
22219
  unresolved.push(ref);
22102
22220
  cache.set(ref, null);
22103
22221
  return null;
22104
22222
  }
22105
- bytes = statSync7(abs).size;
22223
+ bytes = statSync8(abs).size;
22106
22224
  } catch {
22107
22225
  unresolved.push(ref);
22108
22226
  cache.set(ref, null);
@@ -22826,7 +22944,7 @@ function createSelfConfigToolDefinitionsForCore(core, ctx, capabilities) {
22826
22944
  const tools = [
22827
22945
  {
22828
22946
  name: "set_model",
22829
- 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."),
22947
+ 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."),
22830
22948
  schema: { model: z3.string().describe("Model id valid for the topic's current agent.") },
22831
22949
  async handler({ model }) {
22832
22950
  return mcpResult(core.setModel(getCtx(), model));
@@ -23087,4 +23205,4 @@ export {
23087
23205
  withTaskSnapshots
23088
23206
  };
23089
23207
 
23090
- //# debugId=6A82E153BE4B6ED364756E2164756E21
23208
+ //# debugId=7836A053B43D717A64756E2164756E21