negotium 0.2.19 → 0.2.21

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 (56) hide show
  1. package/dist/agent-helpers.js +573 -593
  2. package/dist/agent-helpers.js.map +17 -17
  3. package/dist/background-bash.js +3 -2
  4. package/dist/background-bash.js.map +3 -3
  5. package/dist/browser-runtime.js +76 -36
  6. package/dist/browser-runtime.js.map +6 -6
  7. package/dist/canonical-mcp-bridge.js +1 -1
  8. package/dist/{chunk-fc58cqry.js → chunk-rhp26p2c.js} +171 -26
  9. package/dist/{chunk-fc58cqry.js.map → chunk-rhp26p2c.js.map} +6 -5
  10. package/dist/{chunk-r0xs3t81.js → chunk-s2gez3wg.js} +18 -3
  11. package/dist/{chunk-r0xs3t81.js.map → chunk-s2gez3wg.js.map} +2 -2
  12. package/dist/hosted-agent.js +185 -54
  13. package/dist/hosted-agent.js.map +7 -6
  14. package/dist/main.js +1209 -1114
  15. package/dist/main.js.map +25 -25
  16. package/dist/mcp-catalog.js.map +1 -1
  17. package/dist/mcp-factories.js +526 -540
  18. package/dist/mcp-factories.js.map +17 -17
  19. package/dist/outbox.js.map +1 -1
  20. package/dist/platform-runtime.js.map +1 -1
  21. package/dist/prompts.js +3 -2
  22. package/dist/prompts.js.map +3 -3
  23. package/dist/query-runtime.js +63 -26
  24. package/dist/query-runtime.js.map +4 -4
  25. package/dist/registry.js +4 -3
  26. package/dist/registry.js.map +3 -3
  27. package/dist/rollout.js +1 -1
  28. package/dist/runtime/src/agents/archiver.ts +3 -2
  29. package/dist/runtime/src/application/switch-topic-access-mode.ts +81 -8
  30. package/dist/runtime/src/bus.ts +19 -2
  31. package/dist/runtime/src/mcp/session-comm/runtime.ts +16 -0
  32. package/dist/runtime/src/platform/config.ts +13 -1
  33. package/dist/runtime/src/runtime/ask-callbacks.ts +19 -11
  34. package/dist/runtime/src/runtime/background-sessions.ts +9 -7
  35. package/dist/runtime/src/runtime/visual-store.ts +31 -23
  36. package/dist/runtime/src/storage/api-topics.ts +26 -0
  37. package/dist/runtime/src/storage/browser-profiles.ts +16 -8
  38. package/dist/runtime/src/storage/runtime-events.ts +30 -20
  39. package/dist/runtime/src/storage/runtime-gateway-submissions.ts +24 -16
  40. package/dist/runtime/src/storage/runtime-turn-requests.ts +9 -1
  41. package/dist/runtime/src/storage/self-schedules.ts +32 -24
  42. package/dist/runtime/src/storage/storage-host.ts +105 -43
  43. package/dist/runtime/src/storage/vault.ts +12 -3
  44. package/dist/runtime/src/version.ts +1 -1
  45. package/dist/runtime-helpers.js +63 -26
  46. package/dist/runtime-helpers.js.map +4 -4
  47. package/dist/sqlite.js +17 -1
  48. package/dist/sqlite.js.map +2 -2
  49. package/dist/storage.js +92 -46
  50. package/dist/storage.js.map +4 -4
  51. package/dist/types/packages/core/src/storage/api-topics.d.ts +15 -0
  52. package/dist/types/packages/core/src/storage/storage-host.d.ts +10 -0
  53. package/dist/types/packages/core/src/version.d.ts +1 -1
  54. package/dist/vault.js +156 -10
  55. package/dist/vault.js.map +6 -5
  56. package/package.json +1 -1
@@ -1,20 +1,30 @@
1
1
  // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
7
18
  var __export = (target, all) => {
8
19
  for (var name in all)
9
20
  __defProp(target, name, {
10
21
  get: all[name],
11
22
  enumerable: true,
12
23
  configurable: true,
13
- set: __exportSetter.bind(all, name)
24
+ set: (newValue) => all[name] = () => newValue
14
25
  });
15
26
  };
16
27
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
- var __promiseAll = (args) => Promise.all(args);
18
28
  var __require = import.meta.require;
19
29
 
20
30
  // ../../packages/core/src/security/sensitive-path.ts
@@ -230,7 +240,7 @@ function browserRsMeetsMinimumVersion(candidate) {
230
240
  try {
231
241
  const output = execFileSync(candidate, ["--version"], {
232
242
  encoding: "utf8",
233
- timeout: 2000,
243
+ timeout: BROWSER_RS_VERSION_PROBE_TIMEOUT_MS,
234
244
  stdio: ["ignore", "pipe", "ignore"]
235
245
  }).trim();
236
246
  const match = output.match(/^browser-rs (\d+)\.(\d+)\.(\d+)$/);
@@ -341,7 +351,7 @@ function resolveDefaultModel(agent, registryDefaultModel) {
341
351
  function codexAuthFilePath() {
342
352
  return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
343
353
  }
344
- var HOME, PROJECT_ROOT, STATE_DIR_ENV, 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", BROWSER_RS_VERSION = "v0.1.19", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.5", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, BROWSER_MCP_SSE_PROXY_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, 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, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, _envMaxTellDepth, MAX_TELL_DEPTH;
354
+ var HOME, PROJECT_ROOT, STATE_DIR_ENV, 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", BROWSER_RS_VERSION = "v0.1.19", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.5", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, BROWSER_MCP_SSE_PROXY_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, 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, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, _envMaxTellDepth, MAX_TELL_DEPTH;
345
355
  var init_config = __esm(() => {
346
356
  init_config_helpers();
347
357
  init_logger();
@@ -1423,6 +1433,163 @@ var init_sqlite = __esm(async () => {
1423
1433
  }
1424
1434
  });
1425
1435
 
1436
+ // ../../packages/core/src/storage/storage-host.ts
1437
+ import { mkdirSync as mkdirSync2 } from "fs";
1438
+ import { homedir as homedir2 } from "os";
1439
+ import { dirname as dirname2, join as join2, resolve as resolve3 } from "path";
1440
+ function storageState() {
1441
+ const holder = globalThis;
1442
+ const existing = holder[STORAGE_HOST_STATE];
1443
+ if (existing)
1444
+ return existing;
1445
+ const created = {
1446
+ configuredHost: {},
1447
+ fallbackDatabase: null,
1448
+ fallbackDatabasePath: null,
1449
+ frames: [],
1450
+ schemaInitializers: [],
1451
+ initializedSchemas: new WeakMap,
1452
+ initializingDatabases: new WeakSet
1453
+ };
1454
+ Object.defineProperty(holder, STORAGE_HOST_STATE, {
1455
+ value: created,
1456
+ enumerable: false,
1457
+ writable: false,
1458
+ configurable: false
1459
+ });
1460
+ return created;
1461
+ }
1462
+ function envPath(name, fallback) {
1463
+ const value = process.env[name]?.trim();
1464
+ return resolve3(value || fallback);
1465
+ }
1466
+ function defaultStateDir() {
1467
+ return envPath("NEGOTIUM_STATE_DIR", join2(homedir2(), ".negotium"));
1468
+ }
1469
+ function defaultDataDir() {
1470
+ return envPath("NEGOTIUM_DATA_DIR", join2(defaultStateDir(), "data"));
1471
+ }
1472
+ function defaultLogDir() {
1473
+ return envPath("NEGOTIUM_LOG_DIR", join2(defaultStateDir(), "logs"));
1474
+ }
1475
+ function defaultWorkspaceDir() {
1476
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join2(defaultStateDir(), "workspace"));
1477
+ }
1478
+ function defaultSessionAsksDir() {
1479
+ const runDir = envPath("NEGOTIUM_RUN_DIR", join2(defaultStateDir(), "runtime"));
1480
+ return join2(runDir, "session-asks");
1481
+ }
1482
+ function defaultSessionsDatabasePath() {
1483
+ return envPath("SESSIONS_DB_PATH", join2(resolveStorageDataDir(), "sessions.db"));
1484
+ }
1485
+ function isSqliteBusy(error) {
1486
+ const message = error instanceof Error ? error.message : String(error);
1487
+ return /database is (?:locked|busy)|SQLITE_(?:BUSY|LOCKED)/i.test(message);
1488
+ }
1489
+ function execWithBusyRetry(database, sql, timeoutMs = SQLITE_INIT_TIMEOUT_MS) {
1490
+ const deadline = Date.now() + timeoutMs;
1491
+ while (true) {
1492
+ try {
1493
+ database.exec(sql);
1494
+ return;
1495
+ } catch (error) {
1496
+ if (!isSqliteBusy(error) || Date.now() >= deadline)
1497
+ throw error;
1498
+ Atomics.wait(SQLITE_INIT_SLEEP, 0, 0, Math.min(SQLITE_INIT_RETRY_MS, deadline - Date.now()));
1499
+ }
1500
+ }
1501
+ }
1502
+ function initializeDatabase(database) {
1503
+ database.exec("PRAGMA busy_timeout = 5000");
1504
+ execWithBusyRetry(database, "PRAGMA journal_mode = WAL");
1505
+ database.exec("PRAGMA foreign_keys = ON");
1506
+ database.exec("PRAGMA wal_autocheckpoint = 1000");
1507
+ try {
1508
+ database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
1509
+ } catch {}
1510
+ }
1511
+ function defaultDatabase() {
1512
+ const path = defaultSessionsDatabasePath();
1513
+ const state = storageState();
1514
+ if (state.fallbackDatabase && state.fallbackDatabasePath === path)
1515
+ return state.fallbackDatabase;
1516
+ if (state.fallbackDatabase)
1517
+ state.fallbackDatabase.close();
1518
+ mkdirSync2(dirname2(path), { recursive: true });
1519
+ state.fallbackDatabase = new Database(path, { create: true });
1520
+ state.fallbackDatabasePath = path;
1521
+ initializeDatabase(state.fallbackDatabase);
1522
+ return state.fallbackDatabase;
1523
+ }
1524
+ function resolveStorageDatabase() {
1525
+ return storageState().configuredHost.database ?? defaultDatabase();
1526
+ }
1527
+ function resolveStorageDataDir() {
1528
+ return storageState().configuredHost.dataDir ?? defaultDataDir();
1529
+ }
1530
+ function resolveStorageLogDir() {
1531
+ return storageState().configuredHost.logDir ?? defaultLogDir();
1532
+ }
1533
+ function resolveStorageSessionAsksDir() {
1534
+ return storageState().configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
1535
+ }
1536
+ function resolveStorageWorkspaceDir() {
1537
+ return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
1538
+ }
1539
+ function resolveStorageSharedWikiDir() {
1540
+ return storageState().configuredHost.sharedWikiDir ?? join2(resolveStorageWorkspaceDir(), "wiki");
1541
+ }
1542
+ function registerStorageSchemaInitializer(initialize, priority = 100) {
1543
+ const initializers = storageState().schemaInitializers;
1544
+ initializers.push({ initialize, priority });
1545
+ initializers.sort((a, b) => a.priority - b.priority);
1546
+ }
1547
+ function ensureStorageSchemas(database = resolveStorageDatabase()) {
1548
+ const state = storageState();
1549
+ if (state.initializingDatabases.has(database))
1550
+ return;
1551
+ let initialized = state.initializedSchemas.get(database);
1552
+ if (!initialized) {
1553
+ initialized = new Set;
1554
+ state.initializedSchemas.set(database, initialized);
1555
+ }
1556
+ state.initializingDatabases.add(database);
1557
+ try {
1558
+ for (const entry of state.schemaInitializers) {
1559
+ if (initialized.has(entry.initialize))
1560
+ continue;
1561
+ initialized.add(entry.initialize);
1562
+ try {
1563
+ entry.initialize(database);
1564
+ } catch (error) {
1565
+ initialized.delete(entry.initialize);
1566
+ throw error;
1567
+ }
1568
+ }
1569
+ } finally {
1570
+ state.initializingDatabases.delete(database);
1571
+ }
1572
+ }
1573
+ var STORAGE_HOST_STATE, SQLITE_INIT_RETRY_MS = 25, SQLITE_INIT_TIMEOUT_MS = 5000, SQLITE_INIT_SLEEP, internalStorageDatabase;
1574
+ var init_storage_host = __esm(async () => {
1575
+ await init_sqlite();
1576
+ STORAGE_HOST_STATE = Symbol.for("negotium.storage-host.state.v1");
1577
+ SQLITE_INIT_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
1578
+ internalStorageDatabase = new Proxy({}, {
1579
+ get(_target, property) {
1580
+ const database = resolveStorageDatabase();
1581
+ ensureStorageSchemas(database);
1582
+ const value = Reflect.get(database, property, database);
1583
+ return typeof value === "function" ? value.bind(database) : value;
1584
+ },
1585
+ set(_target, property, value) {
1586
+ const database = resolveStorageDatabase();
1587
+ ensureStorageSchemas(database);
1588
+ return Reflect.set(database, property, value, database);
1589
+ }
1590
+ });
1591
+ });
1592
+
1426
1593
  // ../../packages/core/src/storage/vault-crypto-core.ts
1427
1594
  import { createCipheriv, createDecipheriv, createHash as createHash2, randomBytes as randomBytes3 } from "crypto";
1428
1595
  function encryptionKey(masterKey) {
@@ -1479,8 +1646,8 @@ var init_vault_crypto = __esm(() => {
1479
1646
  });
1480
1647
 
1481
1648
  // ../../packages/core/src/storage/vault.ts
1482
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync2 } from "fs";
1483
- import { join as join2 } from "path";
1649
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync3 } from "fs";
1650
+ import { join as join3 } from "path";
1484
1651
  function initializeVaultDatabase(database) {
1485
1652
  database.exec("PRAGMA journal_mode = WAL");
1486
1653
  database.exec("PRAGMA busy_timeout = 5000");
@@ -1515,17 +1682,18 @@ function initializeVaultDatabase(database) {
1515
1682
  }
1516
1683
  }
1517
1684
  function openVaultDatabase(dataDir) {
1518
- const vaultDir = join2(dataDir, "vault");
1519
- const path = join2(vaultDir, "vault.db");
1520
- mkdirSync2(vaultDir, { recursive: true, mode: 448 });
1685
+ const vaultDir = join3(dataDir, "vault");
1686
+ const path = join3(vaultDir, "vault.db");
1687
+ mkdirSync3(vaultDir, { recursive: true, mode: 448 });
1521
1688
  const database = new Database(path, { create: true });
1522
1689
  chmodSync2(path, 384);
1523
1690
  initializeVaultDatabase(database);
1524
1691
  return database;
1525
1692
  }
1526
1693
  function activeVaultDatabase() {
1527
- if (!vaultDb)
1528
- vaultDb = openVaultDatabase(DATA_DIR);
1694
+ if (!vaultDb) {
1695
+ vaultDb = openVaultDatabase(resolveStorageDataDir());
1696
+ }
1529
1697
  return vaultDb;
1530
1698
  }
1531
1699
  function normalizeVaultKey(key) {
@@ -1614,15 +1782,16 @@ function redactVaultSecrets(userId, text) {
1614
1782
  var vaultDb, vaultMasterKey, VAULT_VALUE_MAX_BYTES;
1615
1783
  var init_vault = __esm(async () => {
1616
1784
  init_config();
1617
- init_vault_crypto();
1618
1785
  await init_sqlite();
1786
+ await init_storage_host();
1787
+ init_vault_crypto();
1619
1788
  vaultMasterKey = VAULT_MASTER_KEY;
1620
1789
  VAULT_VALUE_MAX_BYTES = 64 * 1024;
1621
1790
  });
1622
1791
 
1623
1792
  // ../../packages/core/src/agents/execution-host.ts
1624
1793
  import { AsyncLocalStorage } from "async_hooks";
1625
- import { dirname as dirname2 } from "path";
1794
+ import { dirname as dirname3 } from "path";
1626
1795
  function activeHost() {
1627
1796
  const scoped = scopedHost.getStore();
1628
1797
  if (scoped)
@@ -1657,7 +1826,7 @@ function hostedCodexAuthFilePath() {
1657
1826
  return activeHost().codexAuthFilePath();
1658
1827
  }
1659
1828
  function hostedCodexHomePath() {
1660
- return dirname2(hostedCodexAuthFilePath());
1829
+ return dirname3(hostedCodexAuthFilePath());
1661
1830
  }
1662
1831
  var defaultHost, hostRegistrations, scopedHost;
1663
1832
  var init_execution_host = __esm(async () => {
@@ -1706,8 +1875,8 @@ function renderUserTurnBatch(messages) {
1706
1875
  }
1707
1876
 
1708
1877
  // ../../packages/core/src/agents/rollout/shared.ts
1709
- import { mkdirSync as mkdirSync3 } from "fs";
1710
- import { resolve as resolve3 } from "path";
1878
+ import { mkdirSync as mkdirSync4 } from "fs";
1879
+ import { resolve as resolve4 } from "path";
1711
1880
  function clone(obj) {
1712
1881
  return structuredClone(obj);
1713
1882
  }
@@ -1717,7 +1886,7 @@ function assertUuidLike(label, value) {
1717
1886
  }
1718
1887
  }
1719
1888
  function assertCwdInWorkspace(cwd) {
1720
- const abs = resolve3(cwd);
1889
+ const abs = resolve4(cwd);
1721
1890
  const ok = trustedWorkspaceRoots.some((root) => abs === root || abs.startsWith(`${root}/`));
1722
1891
  if (!ok) {
1723
1892
  throw new Error(`rollout: cwd outside trusted workspace roots: ${cwd} (resolved=${abs})`);
@@ -1726,7 +1895,7 @@ function assertCwdInWorkspace(cwd) {
1726
1895
  function ensureCwdExists(cwd) {
1727
1896
  assertCwdInWorkspace(cwd);
1728
1897
  try {
1729
- mkdirSync3(cwd, { recursive: true });
1898
+ mkdirSync4(cwd, { recursive: true });
1730
1899
  } catch (err) {
1731
1900
  logger.warn({ err, cwd }, "rollout: ensureCwdExists failed \u2014 caller should pre-create cwd");
1732
1901
  }
@@ -1847,8 +2016,8 @@ var init_shared = __esm(() => {
1847
2016
  DM_WORKSPACE_DIR,
1848
2017
  SESSION_WORKSPACE_DIR,
1849
2018
  TOPIC_WORKSPACE_DIR
1850
- ].map((root) => resolve3(root));
1851
- FIXTURES_DIR = resolve3(PROJECT_ROOT, "src", "agents", "fixtures");
2019
+ ].map((root) => resolve4(root));
2020
+ FIXTURES_DIR = resolve4(PROJECT_ROOT, "src", "agents", "fixtures");
1852
2021
  UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1853
2022
  });
1854
2023
 
@@ -1883,7 +2052,7 @@ import {
1883
2052
  appendFileSync,
1884
2053
  closeSync,
1885
2054
  fsyncSync,
1886
- mkdirSync as mkdirSync4,
2055
+ mkdirSync as mkdirSync5,
1887
2056
  openSync,
1888
2057
  readFileSync as readFileSync2,
1889
2058
  renameSync,
@@ -1891,7 +2060,7 @@ import {
1891
2060
  unlinkSync as unlinkSync2,
1892
2061
  writeFileSync as writeFileSync2
1893
2062
  } from "fs";
1894
- import { dirname as dirname3 } from "path";
2063
+ import { dirname as dirname4 } from "path";
1895
2064
  function parseJsonlText(raw) {
1896
2065
  return raw.trim().split(`
1897
2066
  `).filter(Boolean).map((line) => JSON.parse(line));
@@ -1928,7 +2097,7 @@ function appendJsonlEntry(filePath, entry) {
1928
2097
  `);
1929
2098
  }
1930
2099
  function appendJsonlLine(filePath, line) {
1931
- mkdirSync4(dirname3(filePath), { recursive: true });
2100
+ mkdirSync5(dirname4(filePath), { recursive: true });
1932
2101
  const lockPath = `${filePath}${LOCK_SUFFIX}`;
1933
2102
  const payload = line.endsWith(`
1934
2103
  `) ? line : `${line}
@@ -1959,8 +2128,8 @@ function appendJsonlLine(filePath, line) {
1959
2128
  }
1960
2129
  }
1961
2130
  function writeJsonlFile(filePath, entries) {
1962
- const dir = dirname3(filePath);
1963
- mkdirSync4(dir, { recursive: true });
2131
+ const dir = dirname4(filePath);
2132
+ mkdirSync5(dir, { recursive: true });
1964
2133
  const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1965
2134
  const payload = `${entries.map((e) => JSON.stringify(e)).join(`
1966
2135
  `)}
@@ -2018,12 +2187,12 @@ var init_jsonl = __esm(() => {
2018
2187
  // ../../packages/core/src/agents/rollout/claude.ts
2019
2188
  import { randomUUID } from "crypto";
2020
2189
  import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
2021
- import { homedir as homedir2 } from "os";
2022
- import { join as join3 } from "path";
2190
+ import { homedir as homedir3 } from "os";
2191
+ import { join as join4 } from "path";
2023
2192
  function loadClaudeAttachments() {
2024
2193
  if (_attachmentsCache)
2025
2194
  return _attachmentsCache;
2026
- const raw = readFileSync3(join3(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
2195
+ const raw = readFileSync3(join4(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
2027
2196
  const lines = parseJsonlText(raw);
2028
2197
  if (lines.length < 2) {
2029
2198
  throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
@@ -2124,8 +2293,8 @@ function writeClaudeRollout(opts) {
2124
2293
  });
2125
2294
  lastUuid = assistantUuid;
2126
2295
  }
2127
- const projectsDir = join3(homedir2(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
2128
- const path = join3(projectsDir, `${sessionId}.jsonl`);
2296
+ const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
2297
+ const path = join4(projectsDir, `${sessionId}.jsonl`);
2129
2298
  writeJsonlFile(path, lines);
2130
2299
  logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
2131
2300
  return { sessionId, rolloutPath: path };
@@ -2138,9 +2307,9 @@ var init_claude = __esm(() => {
2138
2307
  });
2139
2308
 
2140
2309
  // ../../packages/core/src/agents/claude-registry.ts
2141
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readdirSync, renameSync as renameSync2, unlinkSync as unlinkSync3 } from "fs";
2142
- import { homedir as homedir3 } from "os";
2143
- import { join as join4 } from "path";
2310
+ import { existsSync as existsSync3, mkdirSync as mkdirSync6, readdirSync, renameSync as renameSync2, unlinkSync as unlinkSync3 } from "fs";
2311
+ import { homedir as homedir4 } from "os";
2312
+ import { join as join5 } from "path";
2144
2313
  var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
2145
2314
  var init_claude_registry = __esm(() => {
2146
2315
  init_claude();
@@ -2187,15 +2356,15 @@ var init_claude_registry = __esm(() => {
2187
2356
  const result = await forkSession(parentSessionId, {
2188
2357
  ...title ? { title } : {}
2189
2358
  });
2190
- const projectsRoot = join4(homedir3(), ".claude", "projects");
2191
- const destDir = join4(projectsRoot, encodeClaudeCwd(cwd));
2192
- const destPath = join4(destDir, `${result.sessionId}.jsonl`);
2359
+ const projectsRoot = join5(homedir4(), ".claude", "projects");
2360
+ const destDir = join5(projectsRoot, encodeClaudeCwd(cwd));
2361
+ const destPath = join5(destDir, `${result.sessionId}.jsonl`);
2193
2362
  if (!existsSync3(destPath)) {
2194
- const sourcePath = readdirSync(projectsRoot).map((d) => join4(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync3(p));
2363
+ const sourcePath = readdirSync(projectsRoot).map((d) => join5(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync3(p));
2195
2364
  if (!sourcePath) {
2196
2365
  throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
2197
2366
  }
2198
- mkdirSync5(destDir, { recursive: true });
2367
+ mkdirSync6(destDir, { recursive: true });
2199
2368
  renameSync2(sourcePath, destPath);
2200
2369
  }
2201
2370
  return {
@@ -2204,10 +2373,10 @@ var init_claude_registry = __esm(() => {
2204
2373
  };
2205
2374
  },
2206
2375
  async cleanupRollouts({ cwd, sessionIds }) {
2207
- const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(cwd));
2376
+ const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(cwd));
2208
2377
  const failures = [];
2209
2378
  for (const sid of sessionIds) {
2210
- const path = join4(projectsDir, `${sid}.jsonl`);
2379
+ const path = join5(projectsDir, `${sid}.jsonl`);
2211
2380
  try {
2212
2381
  unlinkSync3(path);
2213
2382
  } catch (e) {
@@ -2225,7 +2394,7 @@ var init_claude_registry = __esm(() => {
2225
2394
  });
2226
2395
 
2227
2396
  // ../../packages/core/src/version.ts
2228
- var NEGOTIUM_VERSION = "0.2.19";
2397
+ var NEGOTIUM_VERSION = "0.2.21";
2229
2398
 
2230
2399
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
2231
2400
  import { spawn as spawn2 } from "child_process";
@@ -2243,7 +2412,7 @@ import {
2243
2412
  } from "fs";
2244
2413
  import { createRequire as createRequire2 } from "module";
2245
2414
  import { tmpdir } from "os";
2246
- import { dirname as dirname4, join as join5 } from "path";
2415
+ import { dirname as dirname5, join as join6 } from "path";
2247
2416
  function readPackageVersion(packageJsonPath) {
2248
2417
  const parsed = JSON.parse(readFileSync4(packageJsonPath, "utf8"));
2249
2418
  if (typeof parsed.version !== "string" || !parsed.version.trim()) {
@@ -2252,7 +2421,7 @@ function readPackageVersion(packageJsonPath) {
2252
2421
  return parsed.version;
2253
2422
  }
2254
2423
  function codexCliScriptPath() {
2255
- return join5(dirname4(bundledCodexPackagePath), "bin", "codex.js");
2424
+ return join6(dirname5(bundledCodexPackagePath), "bin", "codex.js");
2256
2425
  }
2257
2426
  function parseCodexModelCache(contents, sourcePath) {
2258
2427
  let parsed;
@@ -2293,14 +2462,14 @@ function writePrivateFileAtomic(path, contents) {
2293
2462
  }
2294
2463
  }
2295
2464
  function bundledCodexModelCachePath(authFilePath) {
2296
- return join5(dirname4(authFilePath), NEGOTIUM_MODEL_CACHE);
2465
+ return join6(dirname5(authFilePath), NEGOTIUM_MODEL_CACHE);
2297
2466
  }
2298
2467
  async function bootstrapCodexModelCache(codexHome, cachePath) {
2299
2468
  const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
2300
2469
  env: { ...process.env, CODEX_HOME: codexHome },
2301
2470
  stdio: ["pipe", "pipe", "pipe"]
2302
2471
  });
2303
- await new Promise((resolve4, reject) => {
2472
+ await new Promise((resolve5, reject) => {
2304
2473
  let settled = false;
2305
2474
  let stdoutBuffer = "";
2306
2475
  let stderr = "";
@@ -2319,7 +2488,7 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
2319
2488
  else if (!existsSync4(cachePath))
2320
2489
  reject(new Error("Codex did not create its model cache"));
2321
2490
  else
2322
- resolve4();
2491
+ resolve5();
2323
2492
  };
2324
2493
  const send = (message) => {
2325
2494
  child.stdin.write(`${JSON.stringify(message)}
@@ -2378,16 +2547,16 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
2378
2547
  });
2379
2548
  }
2380
2549
  async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
2381
- const sourceHome = dirname4(authFilePath);
2382
- const isolatedHome = mkdtempSync(join5(tmpdir(), "negotium-codex-models-"));
2383
- const isolatedCachePath = join5(isolatedHome, "models_cache.json");
2550
+ const sourceHome = dirname5(authFilePath);
2551
+ const isolatedHome = mkdtempSync(join6(tmpdir(), "negotium-codex-models-"));
2552
+ const isolatedCachePath = join6(isolatedHome, "models_cache.json");
2384
2553
  try {
2385
- const isolatedAuthPath = join5(isolatedHome, "auth.json");
2554
+ const isolatedAuthPath = join6(isolatedHome, "auth.json");
2386
2555
  copyFileSync(authFilePath, isolatedAuthPath);
2387
2556
  chmodSync3(isolatedAuthPath, 384);
2388
- const sourceConfigPath = join5(sourceHome, "config.toml");
2557
+ const sourceConfigPath = join6(sourceHome, "config.toml");
2389
2558
  if (existsSync4(sourceConfigPath)) {
2390
- const isolatedConfigPath = join5(isolatedHome, "config.toml");
2559
+ const isolatedConfigPath = join6(isolatedHome, "config.toml");
2391
2560
  copyFileSync(sourceConfigPath, isolatedConfigPath);
2392
2561
  chmodSync3(isolatedConfigPath, 384);
2393
2562
  }
@@ -2398,7 +2567,7 @@ async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
2398
2567
  }
2399
2568
  }
2400
2569
  async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexModelCache) {
2401
- const codexHome = dirname4(authFilePath);
2570
+ const codexHome = dirname5(authFilePath);
2402
2571
  const configuredCachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE;
2403
2572
  if (configuredCachePath) {
2404
2573
  if (!existsSync4(configuredCachePath)) {
@@ -2408,7 +2577,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
2408
2577
  return configuredCachePath;
2409
2578
  }
2410
2579
  const bundledCachePath = bundledCodexModelCachePath(authFilePath);
2411
- const sharedCachePath = join5(codexHome, "models_cache.json");
2580
+ const sharedCachePath = join6(codexHome, "models_cache.json");
2412
2581
  if (existsSync4(sharedCachePath)) {
2413
2582
  try {
2414
2583
  const shared = readCompatibleCodexModelCache(sharedCachePath);
@@ -2427,8 +2596,8 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
2427
2596
  return bundledCachePath;
2428
2597
  }
2429
2598
  function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
2430
- const codexHome = dirname4(authFilePath);
2431
- const outputPath = join5(codexHome, NEGOTIUM_MODEL_CATALOG);
2599
+ const codexHome = dirname5(authFilePath);
2600
+ const outputPath = join6(codexHome, NEGOTIUM_MODEL_CATALOG);
2432
2601
  const parsed = readCodexModelCache(sourcePath).parsed;
2433
2602
  const models = parsed.models.map((model, index) => {
2434
2603
  if (!model || typeof model !== "object" || Array.isArray(model)) {
@@ -2456,14 +2625,14 @@ var init_codex_native_multi_agent = __esm(() => {
2456
2625
  // ../../packages/core/src/agents/rollout/codex.ts
2457
2626
  import { randomBytes as randomBytes4 } from "crypto";
2458
2627
  import { existsSync as existsSync5, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync2, unlinkSync as unlinkSync5 } from "fs";
2459
- import { basename, dirname as dirname5, join as join6, resolve as resolve4 } from "path";
2628
+ import { basename, dirname as dirname6, join as join7, resolve as resolve5 } from "path";
2460
2629
  function codexSessionsDir() {
2461
- return join6(hostedCodexHomePath(), "sessions");
2630
+ return join7(hostedCodexHomePath(), "sessions");
2462
2631
  }
2463
2632
  function loadCodexShell() {
2464
2633
  if (_shellCache)
2465
2634
  return _shellCache;
2466
- const raw = readFileSync5(join6(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
2635
+ const raw = readFileSync5(join7(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
2467
2636
  const lines = parseJsonlText(raw);
2468
2637
  if (lines.length < 5) {
2469
2638
  throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
@@ -2530,16 +2699,16 @@ function codexRolloutPath(threadId, fallback) {
2530
2699
  const hh = String(createdAt.getHours()).padStart(2, "0");
2531
2700
  const min = String(createdAt.getMinutes()).padStart(2, "0");
2532
2701
  const ss = String(createdAt.getSeconds()).padStart(2, "0");
2533
- const dir = join6(codexSessionsDir(), yyyy, mm, dd);
2534
- return join6(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
2702
+ const dir = join7(codexSessionsDir(), yyyy, mm, dd);
2703
+ return join7(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
2535
2704
  }
2536
2705
  function canonicalFilePath(path) {
2537
- const absolute = resolve4(path);
2706
+ const absolute = resolve5(path);
2538
2707
  try {
2539
2708
  return realpathSync2(absolute);
2540
2709
  } catch {
2541
2710
  try {
2542
- return join6(realpathSync2(dirname5(absolute)), basename(absolute));
2711
+ return join7(realpathSync2(dirname6(absolute)), basename(absolute));
2543
2712
  } catch {
2544
2713
  return absolute;
2545
2714
  }
@@ -2769,19 +2938,19 @@ function latestCodexRolloutPath(threadId) {
2769
2938
  try {
2770
2939
  if (buckets) {
2771
2940
  for (const bucket of buckets) {
2772
- const dir = join6(sessionsDir, bucket);
2941
+ const dir = join7(sessionsDir, bucket);
2773
2942
  if (!existsSync5(dir))
2774
2943
  continue;
2775
2944
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
2776
2945
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
2777
- candidates.push(join6(dir, rel));
2946
+ candidates.push(join7(dir, rel));
2778
2947
  }
2779
2948
  }
2780
2949
  }
2781
2950
  if (candidates.length === 0) {
2782
2951
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
2783
2952
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
2784
- candidates.push(join6(sessionsDir, rel));
2953
+ candidates.push(join7(sessionsDir, rel));
2785
2954
  }
2786
2955
  }
2787
2956
  return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
@@ -2902,13 +3071,13 @@ function sweepPriorRolloutsForThread(threadId) {
2902
3071
  return;
2903
3072
  }
2904
3073
  for (const bucket of buckets) {
2905
- const dir = join6(sessionsDir, bucket);
3074
+ const dir = join7(sessionsDir, bucket);
2906
3075
  if (!existsSync5(dir))
2907
3076
  continue;
2908
3077
  try {
2909
3078
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
2910
3079
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
2911
- const fullPath = join6(dir, rel);
3080
+ const fullPath = join7(dir, rel);
2912
3081
  try {
2913
3082
  unlinkSync5(fullPath);
2914
3083
  } catch (e) {
@@ -2926,7 +3095,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
2926
3095
  try {
2927
3096
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
2928
3097
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
2929
- const fullPath = join6(sessionsDir, rel);
3098
+ const fullPath = join7(sessionsDir, rel);
2930
3099
  try {
2931
3100
  unlinkSync5(fullPath);
2932
3101
  } catch (e) {
@@ -2981,10 +3150,10 @@ function formatDateBucket(d) {
2981
3150
  }
2982
3151
  var _shellCache = null, MAX_DAY_SPAN = 30, DAY_MS = 86400000, LOCAL_DATE_SKEW_DAYS = 1;
2983
3152
  var init_codex = __esm(async () => {
3153
+ await init_execution_host();
2984
3154
  init_shared();
2985
3155
  init_jsonl();
2986
3156
  init_logger();
2987
- await init_execution_host();
2988
3157
  });
2989
3158
 
2990
3159
  // ../../packages/core/src/agents/codex-app-server.ts
@@ -2992,7 +3161,7 @@ import { spawn as spawn3 } from "child_process";
2992
3161
  function createCodexAppServerForker(host) {
2993
3162
  return async (parentThreadId) => {
2994
3163
  const child = host.spawnServer();
2995
- return await new Promise((resolve5, reject) => {
3164
+ return await new Promise((resolve6, reject) => {
2996
3165
  let settled = false;
2997
3166
  let stdoutBuffer = "";
2998
3167
  let stderr = "";
@@ -3009,7 +3178,7 @@ function createCodexAppServerForker(host) {
3009
3178
  if (error)
3010
3179
  reject(error);
3011
3180
  else if (result)
3012
- resolve5(result);
3181
+ resolve6(result);
3013
3182
  else
3014
3183
  reject(new Error("Codex thread fork returned no result"));
3015
3184
  };
@@ -3088,10 +3257,8 @@ async function forkCodexSession(parentThreadId) {
3088
3257
  var forkCodexThread;
3089
3258
  var init_codex_app_server = __esm(async () => {
3090
3259
  init_codex_native_multi_agent();
3091
- await __promiseAll([
3092
- init_execution_host(),
3093
- init_codex()
3094
- ]);
3260
+ await init_execution_host();
3261
+ await init_codex();
3095
3262
  forkCodexThread = createCodexAppServerForker({
3096
3263
  spawnServer() {
3097
3264
  return spawn3(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
@@ -3106,16 +3273,14 @@ var init_codex_app_server = __esm(async () => {
3106
3273
 
3107
3274
  // ../../packages/core/src/agents/codex-registry.ts
3108
3275
  import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
3109
- import { join as join7 } from "path";
3276
+ import { join as join8 } from "path";
3110
3277
  var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
3111
3278
  var init_codex_registry = __esm(async () => {
3279
+ await init_codex_app_server();
3280
+ await init_execution_host();
3281
+ await init_codex();
3112
3282
  init_logger();
3113
3283
  init_types();
3114
- await __promiseAll([
3115
- init_codex_app_server(),
3116
- init_execution_host(),
3117
- init_codex()
3118
- ]);
3119
3284
  VALID_EFFORTS2 = new Set(CODEX_EFFORT_VALUES);
3120
3285
  codexRegistry = {
3121
3286
  kind: "codex",
@@ -3151,7 +3316,7 @@ var init_codex_registry = __esm(async () => {
3151
3316
  async cleanupRollouts({ sessionIds }) {
3152
3317
  if (sessionIds.length === 0)
3153
3318
  return;
3154
- const sessionsDir = join7(hostedCodexHomePath(), "sessions");
3319
+ const sessionsDir = join8(hostedCodexHomePath(), "sessions");
3155
3320
  if (!existsSync6(sessionsDir))
3156
3321
  return;
3157
3322
  const failures = [];
@@ -3159,7 +3324,7 @@ var init_codex_registry = __esm(async () => {
3159
3324
  try {
3160
3325
  const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
3161
3326
  for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
3162
- const path = join7(sessionsDir, rel);
3327
+ const path = join8(sessionsDir, rel);
3163
3328
  try {
3164
3329
  unlinkSync6(path);
3165
3330
  } catch (e) {
@@ -3183,17 +3348,17 @@ var init_codex_registry = __esm(async () => {
3183
3348
 
3184
3349
  // ../../packages/core/src/agents/maestro-registry.ts
3185
3350
  import { randomUUID as randomUUID3 } from "crypto";
3186
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
3187
- import { homedir as homedir4 } from "os";
3188
- import { join as join8, resolve as resolve5 } from "path";
3351
+ import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
3352
+ import { homedir as homedir5 } from "os";
3353
+ import { join as join9, resolve as resolve6 } from "path";
3189
3354
  function maestroSessionsDir() {
3190
- return join8(process.env.MAESTRO_DATA_DIR ? resolve5(process.env.MAESTRO_DATA_DIR) : join8(homedir4(), ".maestro"), "sessions");
3355
+ return join9(process.env.MAESTRO_DATA_DIR ? resolve6(process.env.MAESTRO_DATA_DIR) : join9(homedir5(), ".maestro"), "sessions");
3191
3356
  }
3192
3357
  function maestroSessionPath(sessionId) {
3193
- return join8(maestroSessionsDir(), `${sessionId}.jsonl`);
3358
+ return join9(maestroSessionsDir(), `${sessionId}.jsonl`);
3194
3359
  }
3195
3360
  function maestroActiveSessionPath(sessionId) {
3196
- return join8(maestroSessionsDir(), `${sessionId}.active.jsonl`);
3361
+ return join9(maestroSessionsDir(), `${sessionId}.active.jsonl`);
3197
3362
  }
3198
3363
  function existingCreatedAt(path) {
3199
3364
  if (!existsSync7(path))
@@ -3215,7 +3380,7 @@ function writeRollout(options) {
3215
3380
  assertUuidLike("sessionId", sessionId);
3216
3381
  ensureCwdExists(options.cwd);
3217
3382
  const path = maestroSessionPath(sessionId);
3218
- mkdirSync6(maestroSessionsDir(), { recursive: true });
3383
+ mkdirSync7(maestroSessionsDir(), { recursive: true });
3219
3384
  const messages = extractChatPairs(options.entries).flatMap((pair) => [
3220
3385
  { role: "user", content: nonEmptyTurnText(pair.userText) },
3221
3386
  { role: "assistant", content: nonEmptyTurnText(pair.assistantText) }
@@ -3338,8 +3503,8 @@ function getRegistryOperations(agent) {
3338
3503
  var REGISTRIES, OPERATIONS;
3339
3504
  var init_registry = __esm(async () => {
3340
3505
  init_claude_registry();
3341
- init_maestro_registry();
3342
3506
  await init_codex_registry();
3507
+ init_maestro_registry();
3343
3508
  REGISTRIES = {
3344
3509
  claude: claudeRegistry,
3345
3510
  codex: codexRegistry,
@@ -3367,141 +3532,6 @@ function sanitizeId(id) {
3367
3532
  return id.replace(/[^a-zA-Z0-9_-]/g, "_") || "_";
3368
3533
  }
3369
3534
 
3370
- // ../../packages/core/src/storage/storage-host.ts
3371
- import { mkdirSync as mkdirSync7 } from "fs";
3372
- import { homedir as homedir5 } from "os";
3373
- import { dirname as dirname6, join as join9, resolve as resolve6 } from "path";
3374
- function envPath(name, fallback) {
3375
- const value = process.env[name]?.trim();
3376
- return resolve6(value || fallback);
3377
- }
3378
- function defaultStateDir() {
3379
- return envPath("NEGOTIUM_STATE_DIR", join9(homedir5(), ".negotium"));
3380
- }
3381
- function defaultDataDir() {
3382
- return envPath("NEGOTIUM_DATA_DIR", join9(defaultStateDir(), "data"));
3383
- }
3384
- function defaultLogDir() {
3385
- return envPath("NEGOTIUM_LOG_DIR", join9(defaultStateDir(), "logs"));
3386
- }
3387
- function defaultWorkspaceDir() {
3388
- return envPath("NEGOTIUM_WORKSPACE_DIR", join9(defaultStateDir(), "workspace"));
3389
- }
3390
- function defaultSessionAsksDir() {
3391
- const runDir = envPath("NEGOTIUM_RUN_DIR", join9(defaultStateDir(), "runtime"));
3392
- return join9(runDir, "session-asks");
3393
- }
3394
- function defaultSessionsDatabasePath() {
3395
- return envPath("SESSIONS_DB_PATH", join9(resolveStorageDataDir(), "sessions.db"));
3396
- }
3397
- function isSqliteBusy(error) {
3398
- const message = error instanceof Error ? error.message : String(error);
3399
- return /database is (?:locked|busy)|SQLITE_(?:BUSY|LOCKED)/i.test(message);
3400
- }
3401
- function execWithBusyRetry(database, sql, timeoutMs = SQLITE_INIT_TIMEOUT_MS) {
3402
- const deadline = Date.now() + timeoutMs;
3403
- while (true) {
3404
- try {
3405
- database.exec(sql);
3406
- return;
3407
- } catch (error) {
3408
- if (!isSqliteBusy(error) || Date.now() >= deadline)
3409
- throw error;
3410
- Atomics.wait(SQLITE_INIT_SLEEP, 0, 0, Math.min(SQLITE_INIT_RETRY_MS, deadline - Date.now()));
3411
- }
3412
- }
3413
- }
3414
- function initializeDatabase(database) {
3415
- database.exec("PRAGMA busy_timeout = 5000");
3416
- execWithBusyRetry(database, "PRAGMA journal_mode = WAL");
3417
- database.exec("PRAGMA foreign_keys = ON");
3418
- database.exec("PRAGMA wal_autocheckpoint = 1000");
3419
- try {
3420
- database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
3421
- } catch {}
3422
- }
3423
- function defaultDatabase() {
3424
- const path = defaultSessionsDatabasePath();
3425
- if (fallbackDatabase && fallbackDatabasePath === path)
3426
- return fallbackDatabase;
3427
- if (fallbackDatabase)
3428
- fallbackDatabase.close();
3429
- mkdirSync7(dirname6(path), { recursive: true });
3430
- fallbackDatabase = new Database(path, { create: true });
3431
- fallbackDatabasePath = path;
3432
- initializeDatabase(fallbackDatabase);
3433
- return fallbackDatabase;
3434
- }
3435
- function resolveStorageDatabase() {
3436
- return configuredHost.database ?? defaultDatabase();
3437
- }
3438
- function resolveStorageDataDir() {
3439
- return configuredHost.dataDir ?? defaultDataDir();
3440
- }
3441
- function resolveStorageLogDir() {
3442
- return configuredHost.logDir ?? defaultLogDir();
3443
- }
3444
- function resolveStorageSessionAsksDir() {
3445
- return configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
3446
- }
3447
- function resolveStorageWorkspaceDir() {
3448
- return configuredHost.workspaceDir ?? defaultWorkspaceDir();
3449
- }
3450
- function resolveStorageSharedWikiDir() {
3451
- return configuredHost.sharedWikiDir ?? join9(resolveStorageWorkspaceDir(), "wiki");
3452
- }
3453
- function registerStorageSchemaInitializer(initialize, priority = 100) {
3454
- schemaInitializers.push({ initialize, priority });
3455
- schemaInitializers.sort((a, b) => a.priority - b.priority);
3456
- }
3457
- function ensureStorageSchemas(database = resolveStorageDatabase()) {
3458
- if (initializingDatabases.has(database))
3459
- return;
3460
- let initialized = initializedSchemas.get(database);
3461
- if (!initialized) {
3462
- initialized = new Set;
3463
- initializedSchemas.set(database, initialized);
3464
- }
3465
- initializingDatabases.add(database);
3466
- try {
3467
- for (const entry of schemaInitializers) {
3468
- if (initialized.has(entry.initialize))
3469
- continue;
3470
- initialized.add(entry.initialize);
3471
- try {
3472
- entry.initialize(database);
3473
- } catch (error) {
3474
- initialized.delete(entry.initialize);
3475
- throw error;
3476
- }
3477
- }
3478
- } finally {
3479
- initializingDatabases.delete(database);
3480
- }
3481
- }
3482
- var configuredHost, fallbackDatabase = null, fallbackDatabasePath = null, schemaInitializers, initializedSchemas, initializingDatabases, SQLITE_INIT_RETRY_MS = 25, SQLITE_INIT_TIMEOUT_MS = 5000, SQLITE_INIT_SLEEP, internalStorageDatabase;
3483
- var init_storage_host = __esm(async () => {
3484
- await init_sqlite();
3485
- configuredHost = {};
3486
- schemaInitializers = [];
3487
- initializedSchemas = new WeakMap;
3488
- initializingDatabases = new WeakSet;
3489
- SQLITE_INIT_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
3490
- internalStorageDatabase = new Proxy({}, {
3491
- get(_target, property) {
3492
- const database = resolveStorageDatabase();
3493
- ensureStorageSchemas(database);
3494
- const value = Reflect.get(database, property, database);
3495
- return typeof value === "function" ? value.bind(database) : value;
3496
- },
3497
- set(_target, property, value) {
3498
- const database = resolveStorageDatabase();
3499
- ensureStorageSchemas(database);
3500
- return Reflect.set(database, property, value, database);
3501
- }
3502
- });
3503
- });
3504
-
3505
3535
  // ../../packages/core/src/storage/tasks.ts
3506
3536
  import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
3507
3537
  import { dirname as dirname7, join as join10 } from "path";
@@ -4281,10 +4311,10 @@ async function* claudeProvider(opts) {
4281
4311
  var CLAUDE_DEFAULT_DISALLOWED_TOOLS, CLAUDE_NATIVE_AGENT_TOOLS, CLAUDE_IMAGE_MAX_BYTES, CLAUDE_IMAGE_MIME_TYPES, CLAUDE_ABORT_SIGKILL_DELAY_MS = 2500;
4282
4312
  var init_claude_provider = __esm(async () => {
4283
4313
  init_claude_registry();
4314
+ await init_execution_host();
4284
4315
  init_vault_tool_policy();
4285
4316
  init_file_events();
4286
4317
  init_logger();
4287
- await init_execution_host();
4288
4318
  CLAUDE_DEFAULT_DISALLOWED_TOOLS = [
4289
4319
  "AskUserQuestion",
4290
4320
  "Workflow",
@@ -5719,14 +5749,12 @@ var CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_
5719
5749
  var init_codex_provider = __esm(async () => {
5720
5750
  init_codex_native_multi_agent();
5721
5751
  init_codex_tree_kill();
5752
+ await init_execution_host();
5753
+ await init_codex();
5722
5754
  init_tool_format();
5723
5755
  init_file_events();
5724
5756
  init_logger();
5725
5757
  init_mcp_config();
5726
- await __promiseAll([
5727
- init_execution_host(),
5728
- init_codex()
5729
- ]);
5730
5758
  CODEX_MCP_SERVER_NAME_OVERRIDES = {
5731
5759
  playwright: "otium_playwright"
5732
5760
  };
@@ -5847,12 +5875,10 @@ function maestroProvider(opts) {
5847
5875
  var MAESTRO_DEFAULT_MAX_TOKENS = 32768, PROVIDER_ASK_USER_TOOL = "AskUserQuestion", PROVIDER_SUBAGENT_TOOL = "Agent", MAESTRO_NATIVE_TASK_TOOLS, MAESTRO_PROVIDER_OWNED_TOOL_SET, DEFAULT_MAESTRO_DISALLOWED_TOOLS, MAESTRO_ALL_BUILTIN_TOOLS, MAESTRO_TOOL_OUTPUT_DIR;
5848
5876
  var init_maestro_provider = __esm(async () => {
5849
5877
  init_maestro_bootstrap_env();
5878
+ await init_execution_host();
5850
5879
  init_vault_tool_policy();
5851
5880
  init_config();
5852
- await __promiseAll([
5853
- init_execution_host(),
5854
- init_vault()
5855
- ]);
5881
+ await init_vault();
5856
5882
  MAESTRO_NATIVE_TASK_TOOLS = [
5857
5883
  "TaskCreate",
5858
5884
  "TaskUpdate",
@@ -5998,15 +6024,13 @@ async function* runAgent(opts) {
5998
6024
  }
5999
6025
  }
6000
6026
  var init_agents = __esm(async () => {
6027
+ await init_execution_host();
6028
+ await init_registry();
6001
6029
  init_claude();
6030
+ await init_task_events();
6002
6031
  init_logger();
6032
+ await init_conversations();
6003
6033
  init_types();
6004
- await __promiseAll([
6005
- init_execution_host(),
6006
- init_registry(),
6007
- init_task_events(),
6008
- init_conversations()
6009
- ]);
6010
6034
  });
6011
6035
 
6012
6036
  // ../../packages/core/src/storage/forum-db.ts
@@ -6056,6 +6080,7 @@ function listRuntimeEventsAfter(seq, limit = 500) {
6056
6080
  var RUNTIME_EVENT_TYPES, types;
6057
6081
  var init_runtime_events = __esm(async () => {
6058
6082
  await init_forum_db();
6083
+ await init_storage_host();
6059
6084
  RUNTIME_EVENT_TYPES = [
6060
6085
  "message",
6061
6086
  "message-updated",
@@ -6064,26 +6089,28 @@ var init_runtime_events = __esm(async () => {
6064
6089
  "topic-updated",
6065
6090
  "topic-deleted"
6066
6091
  ];
6067
- db.exec(`
6068
- CREATE TABLE IF NOT EXISTS runtime_events (
6069
- seq INTEGER PRIMARY KEY AUTOINCREMENT,
6070
- source_id TEXT NOT NULL,
6071
- event_type TEXT NOT NULL CHECK (
6072
- event_type IN (
6073
- 'message',
6074
- 'message-updated',
6075
- 'ai-status',
6076
- 'topic-created',
6077
- 'topic-updated',
6078
- 'topic-deleted'
6079
- )
6080
- ),
6081
- topic_id TEXT NOT NULL,
6082
- payload_json TEXT NOT NULL,
6083
- created_at TEXT NOT NULL
6084
- )
6085
- `);
6086
- db.exec("CREATE INDEX IF NOT EXISTS idx_runtime_events_topic_seq ON runtime_events(topic_id, seq)");
6092
+ registerStorageSchemaInitializer((database) => {
6093
+ database.exec(`
6094
+ CREATE TABLE IF NOT EXISTS runtime_events (
6095
+ seq INTEGER PRIMARY KEY AUTOINCREMENT,
6096
+ source_id TEXT NOT NULL,
6097
+ event_type TEXT NOT NULL CHECK (
6098
+ event_type IN (
6099
+ 'message',
6100
+ 'message-updated',
6101
+ 'ai-status',
6102
+ 'topic-created',
6103
+ 'topic-updated',
6104
+ 'topic-deleted'
6105
+ )
6106
+ ),
6107
+ topic_id TEXT NOT NULL,
6108
+ payload_json TEXT NOT NULL,
6109
+ created_at TEXT NOT NULL
6110
+ )
6111
+ `);
6112
+ database.exec("CREATE INDEX IF NOT EXISTS idx_runtime_events_topic_seq ON runtime_events(topic_id, seq)");
6113
+ });
6087
6114
  types = new Set(RUNTIME_EVENT_TYPES);
6088
6115
  });
6089
6116
 
@@ -6243,13 +6270,17 @@ class SqliteRuntimeBus {
6243
6270
  };
6244
6271
  }
6245
6272
  }
6246
- var current, WsHub;
6273
+ function runtimeBus() {
6274
+ if (!current)
6275
+ current = new SqliteRuntimeBus;
6276
+ return current;
6277
+ }
6278
+ var current = null, WsHub;
6247
6279
  var init_bus = __esm(async () => {
6248
6280
  await init_runtime_events();
6249
- current = new SqliteRuntimeBus;
6250
6281
  WsHub = {
6251
6282
  get() {
6252
- return current;
6283
+ return runtimeBus();
6253
6284
  }
6254
6285
  };
6255
6286
  });
@@ -7065,10 +7096,8 @@ function getMessagesForTopicAfterRowid(topicId, afterRowid) {
7065
7096
  }
7066
7097
  var appendHooks;
7067
7098
  var init_api_messages = __esm(async () => {
7068
- await __promiseAll([
7069
- init_forum_db(),
7070
- init_storage_host()
7071
- ]);
7099
+ await init_forum_db();
7100
+ await init_storage_host();
7072
7101
  registerStorageSchemaInitializer(initializeApiMessagesSchema, 30);
7073
7102
  appendHooks = new Set;
7074
7103
  });
@@ -7158,11 +7187,9 @@ function deleteTopicBrief(topicId) {
7158
7187
  db.query("DELETE FROM api_topic_brief WHERE topic_id = ?").run(topicId);
7159
7188
  }
7160
7189
  var init_api_topic_brief = __esm(async () => {
7190
+ await init_forum_db();
7191
+ await init_storage_host();
7161
7192
  init_wiki_summary_names();
7162
- await __promiseAll([
7163
- init_forum_db(),
7164
- init_storage_host()
7165
- ]);
7166
7193
  registerStorageSchemaInitializer((database) => {
7167
7194
  database.exec(`
7168
7195
  CREATE TABLE IF NOT EXISTS api_topic_brief (
@@ -7307,10 +7334,8 @@ function deleteApiTopicConfig(topicId) {
7307
7334
  db.query("DELETE FROM api_topic_config WHERE topic_id = ?").run(topicId);
7308
7335
  }
7309
7336
  var init_api_topic_config = __esm(async () => {
7310
- await __promiseAll([
7311
- init_forum_db(),
7312
- init_storage_host()
7313
- ]);
7337
+ await init_forum_db();
7338
+ await init_storage_host();
7314
7339
  registerStorageSchemaInitializer(initializeApiTopicConfigSchema, 40);
7315
7340
  });
7316
7341
 
@@ -7869,10 +7894,8 @@ var DEFAULT_AGENT_ROOM_AGENT = "maestro";
7869
7894
  var init_api_topics = __esm(async () => {
7870
7895
  init_constants();
7871
7896
  init_logger();
7872
- await __promiseAll([
7873
- init_forum_db(),
7874
- init_storage_host()
7875
- ]);
7897
+ await init_forum_db();
7898
+ await init_storage_host();
7876
7899
  registerStorageSchemaInitializer(initializeApiTopicsSchema, 20);
7877
7900
  });
7878
7901
 
@@ -7915,13 +7938,11 @@ function isLegacySharedGeneral(topicId) {
7915
7938
  }
7916
7939
  var LEGACY_PERSONAL_GENERAL_DESCRIPTION = "\uB098\uB9CC\uC758 \uAC1C\uC778 \uACF5\uAC04\uC774\uC5D0\uC694. \uB300\uD654\uC640 AI \uC791\uC5C5\uC740 \uB2E4\uB978 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \uACF5\uAC1C\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.", PERSONAL_GENERAL_DESCRIPTION = "Your private General. Messages and membership are visible only to you. Workspace memory, wiki, and skills are shared with your workspace.";
7917
7940
  var init_personal_general = __esm(async () => {
7941
+ await init_registry();
7918
7942
  init_config();
7919
7943
  init_constants();
7920
- await __promiseAll([
7921
- init_registry(),
7922
- init_api_topic_config(),
7923
- init_api_topics()
7924
- ]);
7944
+ await init_api_topic_config();
7945
+ await init_api_topics();
7925
7946
  });
7926
7947
 
7927
7948
  // ../../packages/core/src/agents/archiver.ts
@@ -7946,9 +7967,9 @@ function formatArchiverBytes(bytes) {
7946
7967
  function formatArchiverTool(name, input) {
7947
7968
  const params = Object.entries(input).map(([key, value]) => {
7948
7969
  const rendered = typeof value === "string" ? value : JSON.stringify(value);
7949
- return `${key}: ${sessionText(rendered ?? "")}`;
7970
+ return `${key}: ${summarizeDisplayText(sessionText(rendered ?? ""))}`;
7950
7971
  }).join(", ");
7951
- return `${name}${params ? `(${params})` : ""}`;
7972
+ return summarizeDisplayText(`${name}${params ? `(${params})` : ""}`);
7952
7973
  }
7953
7974
  function createArchiverRuntime(host) {
7954
7975
  const activeSessions = new Map;
@@ -8255,19 +8276,18 @@ function runArchiverTurn(params) {
8255
8276
  }
8256
8277
  var MAX_BRIEF_ENTRIES = 8, defaultArchiverRuntime;
8257
8278
  var init_archiver = __esm(async () => {
8279
+ await init_agents();
8280
+ init_tool_format();
8281
+ await init_bus();
8258
8282
  init_config();
8259
8283
  init_logger();
8260
8284
  init_builders();
8261
8285
  init_background_session_policy();
8286
+ await init_api_messages();
8287
+ await init_api_topic_brief();
8288
+ await init_wiki();
8262
8289
  init_wiki_summary_names();
8263
- await __promiseAll([
8264
- init_agents(),
8265
- init_bus(),
8266
- init_api_messages(),
8267
- init_api_topic_brief(),
8268
- init_wiki(),
8269
- init_personal_general()
8270
- ]);
8290
+ await init_personal_general();
8271
8291
  defaultArchiverRuntime = createArchiverRuntime({
8272
8292
  storage: {
8273
8293
  getWikiDir: getSharedWikiDir,
@@ -8439,8 +8459,8 @@ function cleanupAgentFork(handle) {
8439
8459
  }
8440
8460
  var defaultForkHelpers;
8441
8461
  var init_fork = __esm(async () => {
8442
- init_logger();
8443
8462
  await init_registry();
8463
+ init_logger();
8444
8464
  defaultForkHelpers = createAgentForkHelpers({
8445
8465
  forkSession: (agent, options) => getRegistryOperations(agent).forkSession(options),
8446
8466
  exists: existsSync15,
@@ -8559,10 +8579,8 @@ function beginRuntimeTopicMaintenance(topicId, options = {}) {
8559
8579
  }
8560
8580
  var TOPIC_MAINTENANCE_STALE_MS = 30000, TOPIC_MAINTENANCE_HEARTBEAT_MS = 1000;
8561
8581
  var init_runtime_topic_state = __esm(async () => {
8562
- await __promiseAll([
8563
- init_forum_db(),
8564
- init_storage_host()
8565
- ]);
8582
+ await init_forum_db();
8583
+ await init_storage_host();
8566
8584
  registerStorageSchemaInitializer((database) => {
8567
8585
  database.exec(`
8568
8586
  CREATE TABLE IF NOT EXISTS runtime_topic_state (
@@ -8659,11 +8677,9 @@ function releaseRuntimeTurnLease(topicId, queryId, ownerId = RUNTIME_INSTANCE_ID
8659
8677
  }
8660
8678
  var RUNTIME_INSTANCE_ID, TURN_LEASE_STALE_MS = 1e4;
8661
8679
  var init_runtime_leases = __esm(async () => {
8662
- await __promiseAll([
8663
- init_forum_db(),
8664
- init_runtime_topic_state(),
8665
- init_storage_host()
8666
- ]);
8680
+ await init_forum_db();
8681
+ await init_runtime_topic_state();
8682
+ await init_storage_host();
8667
8683
  RUNTIME_INSTANCE_ID = `${process.pid}-${randomUUID8()}`;
8668
8684
  registerStorageSchemaInitializer((database) => {
8669
8685
  database.exec(`
@@ -9029,8 +9045,8 @@ function wsAbortReason(reason) {
9029
9045
  var roomQueryRegistry, interSessionQueue;
9030
9046
  var init_active_rooms = __esm(async () => {
9031
9047
  init_logger();
9032
- init_types2();
9033
9048
  await init_runtime_leases();
9049
+ init_types2();
9034
9050
  roomQueryRegistry = createRoomQueryRegistry({
9035
9051
  instanceId: RUNTIME_INSTANCE_ID,
9036
9052
  internalAbortReason: "internal" /* Internal */,
@@ -9209,11 +9225,9 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
9209
9225
  }
9210
9226
  var init_topic_archive = __esm(async () => {
9211
9227
  init_logger();
9212
- await __promiseAll([
9213
- init_api_messages(),
9214
- init_conversations(),
9215
- init_wiki()
9216
- ]);
9228
+ await init_api_messages();
9229
+ await init_conversations();
9230
+ await init_wiki();
9217
9231
  });
9218
9232
 
9219
9233
  // ../../packages/core/src/storage/topic-archive-state.ts
@@ -9326,10 +9340,8 @@ function deleteTopicArchiveState(topicId) {
9326
9340
  }
9327
9341
  var ARCHIVE_JOB_STALE_MS;
9328
9342
  var init_topic_archive_state = __esm(async () => {
9329
- await __promiseAll([
9330
- init_forum_db(),
9331
- init_storage_host()
9332
- ]);
9343
+ await init_forum_db();
9344
+ await init_storage_host();
9333
9345
  registerStorageSchemaInitializer((database) => {
9334
9346
  database.exec(`
9335
9347
  CREATE TABLE IF NOT EXISTS api_topic_archive_state (
@@ -9505,15 +9517,13 @@ function archiveActiveTopicForMemory(topicId, userId, options) {
9505
9517
  }
9506
9518
  var DEFAULT_IDLE_DELAY_MS, DEFAULT_MIN_MESSAGES = 8, timers;
9507
9519
  var init_idle_archiver = __esm(async () => {
9520
+ await init_archiver();
9508
9521
  init_logger();
9509
- await __promiseAll([
9510
- init_archiver(),
9511
- init_active_rooms(),
9512
- init_api_messages(),
9513
- init_api_topics(),
9514
- init_topic_archive(),
9515
- init_topic_archive_state()
9516
- ]);
9522
+ await init_active_rooms();
9523
+ await init_api_messages();
9524
+ await init_api_topics();
9525
+ await init_topic_archive();
9526
+ await init_topic_archive_state();
9517
9527
  DEFAULT_IDLE_DELAY_MS = 6 * 60 * 60 * 1000;
9518
9528
  timers = new Map;
9519
9529
  });
@@ -9728,10 +9738,8 @@ function cancelAskUserGate(topicId, messageId, ownerId, now = new Date().toISOSt
9728
9738
  }).immediate();
9729
9739
  }
9730
9740
  var init_ask_user_gates = __esm(async () => {
9731
- await __promiseAll([
9732
- init_forum_db(),
9733
- init_storage_host()
9734
- ]);
9741
+ await init_forum_db();
9742
+ await init_storage_host();
9735
9743
  registerStorageSchemaInitializer(initializeAskUserGateSchema, 31);
9736
9744
  });
9737
9745
 
@@ -9850,11 +9858,9 @@ function acquireRuntimeProcessLease(role, options = {}) {
9850
9858
  }
9851
9859
  var PROCESS_LEASE_STALE_MS = 5000, PROCESS_LEASE_HEARTBEAT_MS = 1000;
9852
9860
  var init_runtime_process_leases = __esm(async () => {
9853
- await __promiseAll([
9854
- init_forum_db(),
9855
- init_runtime_leases(),
9856
- init_storage_host()
9857
- ]);
9861
+ await init_forum_db();
9862
+ await init_runtime_leases();
9863
+ await init_storage_host();
9858
9864
  registerStorageSchemaInitializer((database) => {
9859
9865
  database.exec(`
9860
9866
  CREATE TABLE IF NOT EXISTS runtime_process_leases (
@@ -10172,14 +10178,12 @@ function cancelPendingAskUserQuestions(topicId, queryId) {
10172
10178
  var MAX_QUESTION_CHARS = 2000, MAX_CHOICE_LABEL_CHARS = 128, MAX_CHOICE_DESCRIPTION_CHARS = 500, MAX_CHOICES = 12, MAX_IDEMPOTENCY_KEY_CHARS = 200, ASK_GATE_OWNER_ID, ASK_GATE_LEASE_ROLE_PREFIX = "ask-user-gate:", defaultAskUserDurabilityHost, defaultAskUserRuntime;
10173
10179
  var init_ask_user = __esm(async () => {
10174
10180
  init_common();
10175
- await __promiseAll([
10176
- init_bus(),
10177
- init_api_messages(),
10178
- init_api_topic_config(),
10179
- init_api_topics(),
10180
- init_ask_user_gates(),
10181
- init_runtime_process_leases()
10182
- ]);
10181
+ await init_bus();
10182
+ await init_api_messages();
10183
+ await init_api_topic_config();
10184
+ await init_api_topics();
10185
+ await init_ask_user_gates();
10186
+ await init_runtime_process_leases();
10183
10187
  ASK_GATE_OWNER_ID = `ask-user-${process.pid}-${randomUUID9()}`;
10184
10188
  defaultAskUserDurabilityHost = {
10185
10189
  gates: {
@@ -10284,35 +10288,36 @@ function deleteSelfSchedulesForTopic(topicId) {
10284
10288
  return Number(result.changes ?? 0);
10285
10289
  }
10286
10290
  var init_self_schedules = __esm(async () => {
10287
- await __promiseAll([
10288
- init_forum_db(),
10289
- init_runtime_leases(),
10290
- init_runtime_topic_state()
10291
- ]);
10292
- db.exec(`
10293
- CREATE TABLE IF NOT EXISTS runtime_self_schedules (
10294
- id TEXT PRIMARY KEY,
10295
- topic_id TEXT NOT NULL,
10296
- user_id TEXT NOT NULL,
10297
- message TEXT NOT NULL,
10298
- deliver_at INTEGER NOT NULL,
10299
- created_at INTEGER NOT NULL,
10300
- updated_at INTEGER NOT NULL,
10301
- status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running')),
10302
- claimed_by TEXT,
10303
- claimed_at INTEGER,
10304
- running_query_id TEXT
10305
- )
10306
- `);
10307
- db.exec(`
10308
- CREATE UNIQUE INDEX IF NOT EXISTS idx_runtime_self_schedules_one_pending
10309
- ON runtime_self_schedules(topic_id)
10310
- WHERE status = 'pending'
10311
- `);
10312
- db.exec(`
10313
- CREATE INDEX IF NOT EXISTS idx_runtime_self_schedules_due
10314
- ON runtime_self_schedules(status, deliver_at)
10315
- `);
10291
+ await init_forum_db();
10292
+ await init_runtime_leases();
10293
+ await init_runtime_topic_state();
10294
+ await init_storage_host();
10295
+ registerStorageSchemaInitializer((database) => {
10296
+ database.exec(`
10297
+ CREATE TABLE IF NOT EXISTS runtime_self_schedules (
10298
+ id TEXT PRIMARY KEY,
10299
+ topic_id TEXT NOT NULL,
10300
+ user_id TEXT NOT NULL,
10301
+ message TEXT NOT NULL,
10302
+ deliver_at INTEGER NOT NULL,
10303
+ created_at INTEGER NOT NULL,
10304
+ updated_at INTEGER NOT NULL,
10305
+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running')),
10306
+ claimed_by TEXT,
10307
+ claimed_at INTEGER,
10308
+ running_query_id TEXT
10309
+ )
10310
+ `);
10311
+ database.exec(`
10312
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_runtime_self_schedules_one_pending
10313
+ ON runtime_self_schedules(topic_id)
10314
+ WHERE status = 'pending'
10315
+ `);
10316
+ database.exec(`
10317
+ CREATE INDEX IF NOT EXISTS idx_runtime_self_schedules_due
10318
+ ON runtime_self_schedules(status, deliver_at)
10319
+ `);
10320
+ });
10316
10321
  });
10317
10322
 
10318
10323
  // ../../packages/core/src/platform/playwright/manager-utils.ts
@@ -10635,8 +10640,8 @@ var init_transport_probe = __esm(() => {
10635
10640
 
10636
10641
  // ../../packages/core/src/storage/vault-public.ts
10637
10642
  var init_vault_public = __esm(async () => {
10638
- init_vault_crypto();
10639
10643
  await init_vault();
10644
+ init_vault_crypto();
10640
10645
  });
10641
10646
 
10642
10647
  // ../../packages/core/src/platform/playwright/vault-broker.ts
@@ -10915,14 +10920,17 @@ function assignTopicBrowserProfile(opts) {
10915
10920
  var DEFAULT_BROWSER_PROFILE = "default";
10916
10921
  var init_browser_profiles = __esm(async () => {
10917
10922
  await init_forum_db();
10918
- db.exec(`
10919
- CREATE TABLE IF NOT EXISTS browser_profiles (
10920
- owner_id TEXT NOT NULL,
10921
- name TEXT NOT NULL,
10922
- created_at TEXT NOT NULL,
10923
- PRIMARY KEY (owner_id, name)
10924
- )
10925
- `);
10923
+ await init_storage_host();
10924
+ registerStorageSchemaInitializer((database) => {
10925
+ database.exec(`
10926
+ CREATE TABLE IF NOT EXISTS browser_profiles (
10927
+ owner_id TEXT NOT NULL,
10928
+ name TEXT NOT NULL,
10929
+ created_at TEXT NOT NULL,
10930
+ PRIMARY KEY (owner_id, name)
10931
+ )
10932
+ `);
10933
+ });
10926
10934
  });
10927
10935
 
10928
10936
  // ../../packages/core/src/platform/playwright/manager.ts
@@ -11561,17 +11569,15 @@ var defaultManagerHost, managerHost, MAX_IDLE_MS, instances, usedPorts, spawning
11561
11569
  var init_manager2 = __esm(async () => {
11562
11570
  init_config();
11563
11571
  init_logger();
11572
+ await init_browser_processes();
11564
11573
  init_headed_launch();
11565
11574
  init_transport_probe();
11575
+ await init_vault_broker();
11576
+ await init_browser_profiles();
11566
11577
  init_manager_utils();
11578
+ await init_browser_processes();
11567
11579
  init_transport_probe();
11568
11580
  init_manager_utils();
11569
- await __promiseAll([
11570
- init_browser_processes(),
11571
- init_vault_broker(),
11572
- init_browser_profiles(),
11573
- init_browser_processes()
11574
- ]);
11575
11581
  defaultManagerHost = Object.freeze({
11576
11582
  portsDir: PLAYWRIGHT_PORTS_DIR,
11577
11583
  basePort: PLAYWRIGHT_BASE_PORT,
@@ -11791,12 +11797,10 @@ function createTopicLogMaintenance(host) {
11791
11797
  }
11792
11798
  var defaultTopicLogMaintenance, cleanupTopicRollouts, cleanupTopicRolloutsFromEntries, rotateTopicLogs, purgeTopicLogs;
11793
11799
  var init_topic_cleanup = __esm(async () => {
11800
+ await init_agents();
11801
+ await init_registry();
11794
11802
  init_logger();
11795
- await __promiseAll([
11796
- init_agents(),
11797
- init_registry(),
11798
- init_conversations()
11799
- ]);
11803
+ await init_conversations();
11800
11804
  defaultTopicLogMaintenance = createTopicLogMaintenance({
11801
11805
  agents: SUPPORTED_AGENTS,
11802
11806
  readActiveConversation: readConversation,
@@ -11879,13 +11883,12 @@ function text(value, maxLen) {
11879
11883
  }
11880
11884
  var providers, transientSessions;
11881
11885
  var init_background_sessions = __esm(async () => {
11886
+ await init_archiver();
11887
+ init_tool_format();
11888
+ await init_api_topics();
11889
+ await init_runtime_events();
11890
+ await init_runtime_leases();
11882
11891
  init_background_session_policy();
11883
- await __promiseAll([
11884
- init_archiver(),
11885
- init_api_topics(),
11886
- init_runtime_events(),
11887
- init_runtime_leases()
11888
- ]);
11889
11892
  providers = new Set;
11890
11893
  transientSessions = new Map;
11891
11894
  });
@@ -12181,13 +12184,12 @@ function getRuntimeUserTurnRequest(topicId) {
12181
12184
  }
12182
12185
  var REQUEST_CLAIM_STALE_MS;
12183
12186
  var init_runtime_turn_requests = __esm(async () => {
12184
- await __promiseAll([
12185
- init_forum_db(),
12186
- init_runtime_leases(),
12187
- init_runtime_topic_state()
12188
- ]);
12187
+ await init_forum_db();
12188
+ await init_runtime_leases();
12189
+ await init_runtime_topic_state();
12190
+ await init_storage_host();
12189
12191
  REQUEST_CLAIM_STALE_MS = TURN_LEASE_STALE_MS;
12190
- ensureRuntimeUserTurnRequestsSchema(db);
12192
+ registerStorageSchemaInitializer((database) => ensureRuntimeUserTurnRequestsSchema(database));
12191
12193
  });
12192
12194
 
12193
12195
  // ../../packages/core/src/topics/session.ts
@@ -12570,31 +12572,29 @@ async function createCompactedRolloutEntries(request, summarize = summarizeTopic
12570
12572
  }
12571
12573
  var RESET_MEMORY_ARCHIVE_WAIT_MS, COMPACTION_INLINE_CHARS = 1e5, COMPACTION_SOURCE_CHARS, COMPACTION_MEMORY_CHARS = 80000, COMPACTION_OUTPUT_CHARS = 30000, COMPACTION_TIMEOUT_MS, COMPACTION_LOG_TIMEOUT_MS, COMPACTION_LOG_MAX_CALLS = 12, COMPACTION_LOG_MAX_TOTAL_BYTES, COMPACTION_LOG_MAX_CHUNK_BYTES, COMPACT_CONTEXT_MARKER = "[Negotium compacted context]", AUTO_FORK_COMPACTION_TOKENS = 28000;
12572
12574
  var init_session = __esm(async () => {
12575
+ await init_idle_archiver();
12576
+ await init_agents();
12573
12577
  init_model_catalog();
12578
+ await init_registry();
12574
12579
  init_shared();
12580
+ await init_topic_cleanup();
12581
+ await init_bus();
12575
12582
  init_config();
12576
12583
  init_logger();
12577
12584
  init_mcp_config();
12585
+ await init_active_rooms();
12586
+ await init_background_sessions();
12578
12587
  init_usage_alert();
12579
- await __promiseAll([
12580
- init_idle_archiver(),
12581
- init_agents(),
12582
- init_registry(),
12583
- init_topic_cleanup(),
12584
- init_bus(),
12585
- init_active_rooms(),
12586
- init_background_sessions(),
12587
- init_api_messages(),
12588
- init_api_topic_brief(),
12589
- init_api_topic_config(),
12590
- init_api_topics(),
12591
- init_conversations(),
12592
- init_runtime_leases(),
12593
- init_runtime_topic_state(),
12594
- init_runtime_turn_requests(),
12595
- init_topic_archive(),
12596
- init_personal_general()
12597
- ]);
12588
+ await init_api_messages();
12589
+ await init_api_topic_brief();
12590
+ await init_api_topic_config();
12591
+ await init_api_topics();
12592
+ await init_conversations();
12593
+ await init_runtime_leases();
12594
+ await init_runtime_topic_state();
12595
+ await init_runtime_turn_requests();
12596
+ await init_topic_archive();
12597
+ await init_personal_general();
12598
12598
  RESET_MEMORY_ARCHIVE_WAIT_MS = 5 * 60 * 1000;
12599
12599
  COMPACTION_SOURCE_CHARS = 512 * 1024;
12600
12600
  COMPACTION_TIMEOUT_MS = 2 * 60000;
@@ -12925,24 +12925,22 @@ async function createDerivedTopicImpl(topic, sourceTopicId, userId, copyHistory,
12925
12925
  }
12926
12926
  var TopicTitleConflictError, TopicDeriveBusyError, TopicForkCompactionError;
12927
12927
  var init_derive = __esm(async () => {
12928
+ await init_fork();
12928
12929
  init_model_catalog();
12930
+ await init_registry();
12931
+ await init_bus();
12929
12932
  init_config();
12930
12933
  init_logger();
12931
- await __promiseAll([
12932
- init_fork(),
12933
- init_registry(),
12934
- init_bus(),
12935
- init_manager2(),
12936
- init_active_rooms(),
12937
- init_api_messages(),
12938
- init_api_topic_config(),
12939
- init_api_topics(),
12940
- init_conversations(),
12941
- init_forum_db(),
12942
- init_runtime_topic_state(),
12943
- init_personal_general(),
12944
- init_session()
12945
- ]);
12934
+ await init_manager2();
12935
+ await init_active_rooms();
12936
+ await init_api_messages();
12937
+ await init_api_topic_config();
12938
+ await init_api_topics();
12939
+ await init_conversations();
12940
+ await init_forum_db();
12941
+ await init_runtime_topic_state();
12942
+ await init_personal_general();
12943
+ await init_session();
12946
12944
  TopicTitleConflictError = class TopicTitleConflictError extends Error {
12947
12945
  title;
12948
12946
  constructor(title) {
@@ -13601,21 +13599,22 @@ async function failInterruptedRemoteAskCallbacks() {
13601
13599
  }
13602
13600
  var pendingAsks, MAX_ASK_AGE_MS;
13603
13601
  var init_ask_callbacks = __esm(async () => {
13604
- await __promiseAll([
13605
- init_forum_db(),
13606
- init_session_asks()
13607
- ]);
13608
- db.exec(`
13609
- CREATE TABLE IF NOT EXISTS remote_ask_callbacks (
13610
- target_query_id TEXT PRIMARY KEY,
13611
- request_id TEXT NOT NULL,
13612
- node_name TEXT NOT NULL,
13613
- node_cell_id TEXT NOT NULL,
13614
- topic_id TEXT NOT NULL,
13615
- user_id TEXT NOT NULL,
13616
- created_at INTEGER NOT NULL
13617
- )
13618
- `);
13602
+ await init_forum_db();
13603
+ await init_session_asks();
13604
+ await init_storage_host();
13605
+ registerStorageSchemaInitializer((database) => {
13606
+ database.exec(`
13607
+ CREATE TABLE IF NOT EXISTS remote_ask_callbacks (
13608
+ target_query_id TEXT PRIMARY KEY,
13609
+ request_id TEXT NOT NULL,
13610
+ node_name TEXT NOT NULL,
13611
+ node_cell_id TEXT NOT NULL,
13612
+ topic_id TEXT NOT NULL,
13613
+ user_id TEXT NOT NULL,
13614
+ created_at INTEGER NOT NULL
13615
+ )
13616
+ `);
13617
+ });
13619
13618
  pendingAsks = new Map;
13620
13619
  MAX_ASK_AGE_MS = PENDING_ASK_TTL_MS;
13621
13620
  });
@@ -13829,29 +13828,32 @@ if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",
13829
13828
  </script>`;
13830
13829
  var init_visual_store = __esm(async () => {
13831
13830
  await init_forum_db();
13832
- db.exec(`
13833
- CREATE TABLE IF NOT EXISTS api_topic_visuals (
13834
- id INTEGER PRIMARY KEY AUTOINCREMENT,
13835
- topic_id TEXT NOT NULL,
13836
- html TEXT NOT NULL,
13837
- title TEXT,
13838
- created_at INTEGER NOT NULL,
13839
- kind TEXT NOT NULL DEFAULT 'html',
13840
- source TEXT,
13841
- file_id TEXT,
13842
- mime_type TEXT,
13843
- media_token TEXT
13844
- );
13845
- CREATE INDEX IF NOT EXISTS idx_api_topic_visuals_topic
13846
- ON api_topic_visuals(topic_id, created_at DESC);
13847
-
13848
- CREATE TABLE IF NOT EXISTS api_topic_visual_views (
13849
- topic_id TEXT NOT NULL,
13850
- user_id TEXT NOT NULL,
13851
- visual_id INTEGER NOT NULL,
13852
- PRIMARY KEY (topic_id, user_id)
13853
- );
13854
- `);
13831
+ await init_storage_host();
13832
+ registerStorageSchemaInitializer((database) => {
13833
+ database.exec(`
13834
+ CREATE TABLE IF NOT EXISTS api_topic_visuals (
13835
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
13836
+ topic_id TEXT NOT NULL,
13837
+ html TEXT NOT NULL,
13838
+ title TEXT,
13839
+ created_at INTEGER NOT NULL,
13840
+ kind TEXT NOT NULL DEFAULT 'html',
13841
+ source TEXT,
13842
+ file_id TEXT,
13843
+ mime_type TEXT,
13844
+ media_token TEXT
13845
+ );
13846
+ CREATE INDEX IF NOT EXISTS idx_api_topic_visuals_topic
13847
+ ON api_topic_visuals(topic_id, created_at DESC);
13848
+
13849
+ CREATE TABLE IF NOT EXISTS api_topic_visual_views (
13850
+ topic_id TEXT NOT NULL,
13851
+ user_id TEXT NOT NULL,
13852
+ visual_id INTEGER NOT NULL,
13853
+ PRIMARY KEY (topic_id, user_id)
13854
+ );
13855
+ `);
13856
+ });
13855
13857
  for (const statement of [
13856
13858
  "ALTER TABLE api_topic_visuals ADD COLUMN kind TEXT NOT NULL DEFAULT 'html'",
13857
13859
  "ALTER TABLE api_topic_visuals ADD COLUMN source TEXT",
@@ -14059,37 +14061,35 @@ async function deleteTopicCascadeImpl(topic, userId, options, deletingAncestorId
14059
14061
  }
14060
14062
  var DELETE_TURN_WAIT_MS = 5000, TopicArchiveRequiredError, TopicTurnStillActiveError, TopicCleanupRequiredError;
14061
14063
  var init_lifecycle = __esm(async () => {
14064
+ await init_archiver();
14065
+ await init_idle_archiver();
14066
+ await init_spawn_subagent();
14067
+ await init_topic_cleanup();
14068
+ await init_bus();
14062
14069
  init_manager();
14063
14070
  init_config();
14064
14071
  init_constants();
14065
14072
  init_logger();
14073
+ await init_manager2();
14074
+ await init_active_rooms();
14066
14075
  init_session_inbox_cleanup();
14067
14076
  init_state();
14077
+ await init_ask_callbacks();
14068
14078
  init_file_hooks();
14069
14079
  init_usage_alert();
14070
- await __promiseAll([
14071
- init_archiver(),
14072
- init_idle_archiver(),
14073
- init_spawn_subagent(),
14074
- init_topic_cleanup(),
14075
- init_bus(),
14076
- init_manager2(),
14077
- init_active_rooms(),
14078
- init_ask_callbacks(),
14079
- init_visual_store(),
14080
- init_api_messages(),
14081
- init_api_topic_brief(),
14082
- init_api_topic_config(),
14083
- init_api_topics(),
14084
- init_browser_profiles(),
14085
- init_runtime_leases(),
14086
- init_runtime_topic_state(),
14087
- init_runtime_turn_requests(),
14088
- init_self_schedules(),
14089
- init_session_asks(),
14090
- init_topic_archive(),
14091
- init_topic_archive_state()
14092
- ]);
14080
+ await init_visual_store();
14081
+ await init_api_messages();
14082
+ await init_api_topic_brief();
14083
+ await init_api_topic_config();
14084
+ await init_api_topics();
14085
+ await init_browser_profiles();
14086
+ await init_runtime_leases();
14087
+ await init_runtime_topic_state();
14088
+ await init_runtime_turn_requests();
14089
+ await init_self_schedules();
14090
+ await init_session_asks();
14091
+ await init_topic_archive();
14092
+ await init_topic_archive_state();
14093
14093
  TopicArchiveRequiredError = class TopicArchiveRequiredError extends Error {
14094
14094
  code = "TOPIC_ARCHIVE_FAILED";
14095
14095
  topicId;
@@ -14449,8 +14449,8 @@ function abortPlaywrightTurns(instanceKey, failure) {
14449
14449
  var turnsByInstance;
14450
14450
  var init_playwright_turn_abort = __esm(async () => {
14451
14451
  init_logger();
14452
- init_types2();
14453
14452
  await init_manager2();
14453
+ init_types2();
14454
14454
  turnsByInstance = new Map;
14455
14455
  onPlaywrightFailure(abortPlaywrightTurns);
14456
14456
  });
@@ -14527,10 +14527,8 @@ function upsertTaskPanelMessage(topicId, queryId, tasks, lastRenderedText) {
14527
14527
  return text2;
14528
14528
  }
14529
14529
  var init_tasks2 = __esm(async () => {
14530
- await __promiseAll([
14531
- init_bus(),
14532
- init_api_messages()
14533
- ]);
14530
+ await init_bus();
14531
+ await init_api_messages();
14534
14532
  });
14535
14533
 
14536
14534
  // ../../packages/core/src/runtime/visual-html.ts
@@ -14766,12 +14764,10 @@ var ACTIVE_VISUAL_PROMPT_MAX_CHARS = 24000, ACTIVE_VISUAL_PROMPT_TAIL_CHARS = 60
14766
14764
  var init_visuals = __esm(async () => {
14767
14765
  init_attachments();
14768
14766
  init_file_hooks();
14767
+ await init_visual_store();
14769
14768
  init_sensitive_path();
14769
+ await init_api_messages();
14770
14770
  init_visual_html();
14771
- await __promiseAll([
14772
- init_visual_store(),
14773
- init_api_messages()
14774
- ]);
14775
14771
  });
14776
14772
 
14777
14773
  // ../../packages/core/src/storage/token-stats.ts
@@ -15414,32 +15410,30 @@ ${JSON.stringify(event.input ?? {})}`);
15414
15410
  return outcome;
15415
15411
  }
15416
15412
  var init_turn_event_stream = __esm(async () => {
15413
+ await init_fork();
15414
+ await init_idle_archiver();
15415
+ await init_ask_user();
15416
+ await init_spawn_subagent();
15417
15417
  init_model_catalog();
15418
+ await init_registry();
15418
15419
  init_tool_format();
15420
+ await init_bus();
15419
15421
  init_logger();
15422
+ await init_active_rooms();
15420
15423
  init_state();
15421
15424
  init_types2();
15422
15425
  init_attachments();
15423
15426
  init_errors();
15427
+ await init_tasks2();
15428
+ await init_topic_config();
15424
15429
  init_usage_alert();
15430
+ await init_visual_store();
15431
+ await init_visuals();
15425
15432
  init_sensitive_path();
15426
- await __promiseAll([
15427
- init_fork(),
15428
- init_idle_archiver(),
15429
- init_ask_user(),
15430
- init_spawn_subagent(),
15431
- init_registry(),
15432
- init_bus(),
15433
- init_active_rooms(),
15434
- init_tasks2(),
15435
- init_topic_config(),
15436
- init_visual_store(),
15437
- init_visuals(),
15438
- init_api_messages(),
15439
- init_api_topics(),
15440
- init_runtime_turn_requests(),
15441
- init_token_stats()
15442
- ]);
15433
+ await init_api_messages();
15434
+ await init_api_topics();
15435
+ await init_runtime_turn_requests();
15436
+ await init_token_stats();
15443
15437
  });
15444
15438
 
15445
15439
  // ../../packages/core/src/runtime/turn-session.ts
@@ -15471,11 +15465,9 @@ function resolveInitialTurnSessionId(topicId, requestedSessionId, isolated) {
15471
15465
  }
15472
15466
  var init_turn_session = __esm(async () => {
15473
15467
  init_model_catalog();
15474
- await __promiseAll([
15475
- init_registry(),
15476
- init_topic_config(),
15477
- init_api_topics()
15478
- ]);
15468
+ await init_registry();
15469
+ await init_topic_config();
15470
+ await init_api_topics();
15479
15471
  });
15480
15472
 
15481
15473
  // ../../packages/core/src/storage/app-settings.ts
@@ -16803,43 +16795,41 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
16803
16795
  }
16804
16796
  var PLAYWRIGHT_UNAVAILABLE_NOTICE_COOLDOWN_MS, ASK_REPLY_INJECT_BATCH_MS = 500, playwrightUnavailableNoticeAt, askReplyInjectBatcher, remoteInjectWaiters, durableTurnWorker = null, durableTurnWorkerBusy = false;
16805
16797
  var init_turn_runner = __esm(async () => {
16798
+ await init_fork();
16799
+ await init_agents();
16800
+ await init_spawn_subagent();
16801
+ await init_registry();
16802
+ await init_bus();
16806
16803
  init_manager();
16807
16804
  init_constants();
16808
16805
  init_logger();
16809
16806
  init_mcp_config();
16807
+ await init_manager2();
16810
16808
  init_builders();
16809
+ await init_active_rooms();
16811
16810
  init_state();
16812
16811
  init_types2();
16813
16812
  init_attachments();
16813
+ await init_channel_context();
16814
16814
  init_errors();
16815
+ await init_playwright_turn_abort();
16816
+ await init_topic_config();
16817
+ await init_turn_event_stream();
16818
+ await init_turn_session();
16819
+ await init_visual_store();
16820
+ await init_visuals();
16821
+ await init_api_messages();
16822
+ await init_api_topic_brief();
16823
+ await init_api_topics();
16824
+ await init_app_settings();
16825
+ await init_browser_profiles();
16826
+ await init_conversations();
16827
+ await init_runtime_leases();
16828
+ await init_runtime_topic_state();
16829
+ await init_runtime_turn_requests();
16830
+ await init_wiki();
16815
16831
  init_wiki_summary_names();
16816
- await __promiseAll([
16817
- init_fork(),
16818
- init_agents(),
16819
- init_spawn_subagent(),
16820
- init_registry(),
16821
- init_bus(),
16822
- init_manager2(),
16823
- init_active_rooms(),
16824
- init_channel_context(),
16825
- init_playwright_turn_abort(),
16826
- init_topic_config(),
16827
- init_turn_event_stream(),
16828
- init_turn_session(),
16829
- init_visual_store(),
16830
- init_visuals(),
16831
- init_api_messages(),
16832
- init_api_topic_brief(),
16833
- init_api_topics(),
16834
- init_app_settings(),
16835
- init_browser_profiles(),
16836
- init_conversations(),
16837
- init_runtime_leases(),
16838
- init_runtime_topic_state(),
16839
- init_runtime_turn_requests(),
16840
- init_wiki(),
16841
- init_derive()
16842
- ]);
16832
+ await init_derive();
16843
16833
  init_model_catalog();
16844
16834
  init_attachments();
16845
16835
  init_channel_context();
@@ -17549,16 +17539,14 @@ function processOwnerIsAlive(ownerId) {
17549
17539
  var MAX_TASK_CHARS = 8000, MAX_NAME_CHARS = 80, MAX_LIVE_CHILDREN_PER_PARENT = 5, MAX_PREPARED_CHILDREN_PER_PARENT = 10, MAX_SUBAGENT_DEPTH = 2, RESULT_SUMMARY_CHARS = 300, defaultSubagentLifecycleHost, defaultSubagentLifecycle, computeSubagentDepth, canSpawnSubagentsFromTopic, takeSubagentWatch, cancelSubagentWatchForDeletedTopic, settleSubagentSuccess, settleSubagentFailure, sweepStaleSubagentCards, subagentReportMode, createSubagentManagementToolDefinitions, createSpawnSubagentToolDefinition, createPrepareSubagentToolDefinition;
17550
17540
  var init_spawn_subagent = __esm(async () => {
17551
17541
  init_common();
17542
+ await init_bus();
17552
17543
  init_logger();
17544
+ await init_api_messages();
17545
+ await init_api_topics();
17546
+ await init_runtime_leases();
17547
+ await init_runtime_turn_requests();
17553
17548
  init_wiki_summary_names();
17554
17549
  init_types();
17555
- await __promiseAll([
17556
- init_bus(),
17557
- init_api_messages(),
17558
- init_api_topics(),
17559
- init_runtime_leases(),
17560
- init_runtime_turn_requests()
17561
- ]);
17562
17550
  defaultSubagentLifecycleHost = {
17563
17551
  storage: {
17564
17552
  getTopic,
@@ -17693,14 +17681,12 @@ var init_spawn_subagent = __esm(async () => {
17693
17681
  });
17694
17682
 
17695
17683
  // ../../packages/core/src/agents/public-helpers.ts
17684
+ await init_archiver();
17685
+ await init_auth_check();
17696
17686
  init_codex_tree_kill();
17697
- await __promiseAll([
17698
- init_archiver(),
17699
- init_auth_check(),
17700
- init_fork(),
17701
- init_idle_archiver(),
17702
- init_ask_user()
17703
- ]);
17687
+ await init_fork();
17688
+ await init_idle_archiver();
17689
+ await init_ask_user();
17704
17690
 
17705
17691
  // ../../packages/core/src/agents/mcp-tools/publish-html.ts
17706
17692
  init_common();
@@ -17949,15 +17935,13 @@ init_common();
17949
17935
  import { z as z3 } from "zod";
17950
17936
 
17951
17937
  // ../../packages/core/src/agents/api-topic-agent-switch.ts
17938
+ await init_auth_check();
17952
17939
  init_model_catalog();
17940
+ await init_registry();
17953
17941
  init_logger();
17954
- await __promiseAll([
17955
- init_auth_check(),
17956
- init_registry(),
17957
- init_api_topic_config(),
17958
- init_api_topics(),
17959
- init_conversations()
17960
- ]);
17942
+ await init_api_topic_config();
17943
+ await init_api_topics();
17944
+ await init_conversations();
17961
17945
  import { unlinkSync as unlinkSync9 } from "fs";
17962
17946
  function commitApiTopicSwitch(opts, bridgedSessionId) {
17963
17947
  const registry = getRegistry(opts.agent);
@@ -18057,16 +18041,14 @@ function switchApiTopicAgent(opts) {
18057
18041
  }
18058
18042
 
18059
18043
  // ../../packages/core/src/agents/self-config-core.ts
18044
+ await init_auth_check();
18060
18045
  init_model_catalog();
18046
+ await init_registry();
18047
+ await init_bus();
18061
18048
  init_config();
18062
- await __promiseAll([
18063
- init_auth_check(),
18064
- init_registry(),
18065
- init_bus(),
18066
- init_api_topic_config(),
18067
- init_api_topics(),
18068
- init_self_schedules()
18069
- ]);
18049
+ await init_api_topic_config();
18050
+ await init_api_topics();
18051
+ await init_self_schedules();
18070
18052
 
18071
18053
  // ../../packages/core/src/topics/links.ts
18072
18054
  function topicAppLink(topicId) {
@@ -18714,12 +18696,10 @@ var otiumVisualToolDefinitions = [
18714
18696
  ];
18715
18697
 
18716
18698
  // ../../packages/core/src/agents/public-helpers.ts
18699
+ await init_task_events();
18717
18700
  init_tool_format();
18701
+ await init_topic_cleanup();
18718
18702
  init_vault_tool_policy();
18719
- await __promiseAll([
18720
- init_task_events(),
18721
- init_topic_cleanup()
18722
- ]);
18723
18703
  export {
18724
18704
  withTaskSnapshots,
18725
18705
  withCodexSpawnSerial,
@@ -18776,4 +18756,4 @@ export {
18776
18756
  DEFAULT_SELF_CONFIG_PRODUCT
18777
18757
  };
18778
18758
 
18779
- //# debugId=3089657619E3681164756E2164756E21
18759
+ //# debugId=EBA405ED8B4C4BF164756E2164756E21