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/types.ts
@@ -192,7 +202,7 @@ function browserRsMeetsMinimumVersion(candidate) {
192
202
  try {
193
203
  const output = execFileSync(candidate, ["--version"], {
194
204
  encoding: "utf8",
195
- timeout: 2000,
205
+ timeout: BROWSER_RS_VERSION_PROBE_TIMEOUT_MS,
196
206
  stdio: ["ignore", "pipe", "ignore"]
197
207
  }).trim();
198
208
  const match = output.match(/^browser-rs (\d+)\.(\d+)\.(\d+)$/);
@@ -303,7 +313,7 @@ function resolveDefaultModel(agent, registryDefaultModel) {
303
313
  function codexAuthFilePath() {
304
314
  return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
305
315
  }
306
- 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;
316
+ 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;
307
317
  var init_config = __esm(() => {
308
318
  init_config_helpers();
309
319
  init_logger();
@@ -1005,7 +1015,7 @@ var init_claude_registry = __esm(() => {
1005
1015
  });
1006
1016
 
1007
1017
  // ../../packages/core/src/version.ts
1008
- var NEGOTIUM_VERSION = "0.2.19";
1018
+ var NEGOTIUM_VERSION = "0.2.21";
1009
1019
 
1010
1020
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
1011
1021
  import { spawn as spawn2 } from "child_process";
@@ -2241,6 +2251,163 @@ var init_mcp_config = __esm(() => {
2241
2251
  nodeMcpEntries = [];
2242
2252
  });
2243
2253
 
2254
+ // ../../packages/core/src/storage/storage-host.ts
2255
+ import { mkdirSync as mkdirSync6 } from "fs";
2256
+ import { homedir as homedir4 } from "os";
2257
+ import { dirname as dirname5, join as join6, resolve as resolve5 } from "path";
2258
+ function storageState() {
2259
+ const holder = globalThis;
2260
+ const existing = holder[STORAGE_HOST_STATE];
2261
+ if (existing)
2262
+ return existing;
2263
+ const created = {
2264
+ configuredHost: {},
2265
+ fallbackDatabase: null,
2266
+ fallbackDatabasePath: null,
2267
+ frames: [],
2268
+ schemaInitializers: [],
2269
+ initializedSchemas: new WeakMap,
2270
+ initializingDatabases: new WeakSet
2271
+ };
2272
+ Object.defineProperty(holder, STORAGE_HOST_STATE, {
2273
+ value: created,
2274
+ enumerable: false,
2275
+ writable: false,
2276
+ configurable: false
2277
+ });
2278
+ return created;
2279
+ }
2280
+ function envPath(name, fallback) {
2281
+ const value2 = process.env[name]?.trim();
2282
+ return resolve5(value2 || fallback);
2283
+ }
2284
+ function defaultStateDir() {
2285
+ return envPath("NEGOTIUM_STATE_DIR", join6(homedir4(), ".negotium"));
2286
+ }
2287
+ function defaultDataDir() {
2288
+ return envPath("NEGOTIUM_DATA_DIR", join6(defaultStateDir(), "data"));
2289
+ }
2290
+ function defaultLogDir() {
2291
+ return envPath("NEGOTIUM_LOG_DIR", join6(defaultStateDir(), "logs"));
2292
+ }
2293
+ function defaultWorkspaceDir() {
2294
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join6(defaultStateDir(), "workspace"));
2295
+ }
2296
+ function defaultSessionAsksDir() {
2297
+ const runDir = envPath("NEGOTIUM_RUN_DIR", join6(defaultStateDir(), "runtime"));
2298
+ return join6(runDir, "session-asks");
2299
+ }
2300
+ function defaultSessionsDatabasePath() {
2301
+ return envPath("SESSIONS_DB_PATH", join6(resolveStorageDataDir(), "sessions.db"));
2302
+ }
2303
+ function isSqliteBusy(error) {
2304
+ const message = error instanceof Error ? error.message : String(error);
2305
+ return /database is (?:locked|busy)|SQLITE_(?:BUSY|LOCKED)/i.test(message);
2306
+ }
2307
+ function execWithBusyRetry(database, sql, timeoutMs = SQLITE_INIT_TIMEOUT_MS) {
2308
+ const deadline = Date.now() + timeoutMs;
2309
+ while (true) {
2310
+ try {
2311
+ database.exec(sql);
2312
+ return;
2313
+ } catch (error) {
2314
+ if (!isSqliteBusy(error) || Date.now() >= deadline)
2315
+ throw error;
2316
+ Atomics.wait(SQLITE_INIT_SLEEP, 0, 0, Math.min(SQLITE_INIT_RETRY_MS, deadline - Date.now()));
2317
+ }
2318
+ }
2319
+ }
2320
+ function initializeDatabase(database) {
2321
+ database.exec("PRAGMA busy_timeout = 5000");
2322
+ execWithBusyRetry(database, "PRAGMA journal_mode = WAL");
2323
+ database.exec("PRAGMA foreign_keys = ON");
2324
+ database.exec("PRAGMA wal_autocheckpoint = 1000");
2325
+ try {
2326
+ database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
2327
+ } catch {}
2328
+ }
2329
+ function defaultDatabase() {
2330
+ const path = defaultSessionsDatabasePath();
2331
+ const state = storageState();
2332
+ if (state.fallbackDatabase && state.fallbackDatabasePath === path)
2333
+ return state.fallbackDatabase;
2334
+ if (state.fallbackDatabase)
2335
+ state.fallbackDatabase.close();
2336
+ mkdirSync6(dirname5(path), { recursive: true });
2337
+ state.fallbackDatabase = new Database(path, { create: true });
2338
+ state.fallbackDatabasePath = path;
2339
+ initializeDatabase(state.fallbackDatabase);
2340
+ return state.fallbackDatabase;
2341
+ }
2342
+ function resolveStorageDatabase() {
2343
+ return storageState().configuredHost.database ?? defaultDatabase();
2344
+ }
2345
+ function resolveStorageDataDir() {
2346
+ return storageState().configuredHost.dataDir ?? defaultDataDir();
2347
+ }
2348
+ function resolveStorageLogDir() {
2349
+ return storageState().configuredHost.logDir ?? defaultLogDir();
2350
+ }
2351
+ function resolveStorageSessionAsksDir() {
2352
+ return storageState().configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
2353
+ }
2354
+ function resolveStorageWorkspaceDir() {
2355
+ return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
2356
+ }
2357
+ function resolveStorageSharedWikiDir() {
2358
+ return storageState().configuredHost.sharedWikiDir ?? join6(resolveStorageWorkspaceDir(), "wiki");
2359
+ }
2360
+ function registerStorageSchemaInitializer(initialize, priority = 100) {
2361
+ const initializers = storageState().schemaInitializers;
2362
+ initializers.push({ initialize, priority });
2363
+ initializers.sort((a, b) => a.priority - b.priority);
2364
+ }
2365
+ function ensureStorageSchemas(database = resolveStorageDatabase()) {
2366
+ const state = storageState();
2367
+ if (state.initializingDatabases.has(database))
2368
+ return;
2369
+ let initialized = state.initializedSchemas.get(database);
2370
+ if (!initialized) {
2371
+ initialized = new Set;
2372
+ state.initializedSchemas.set(database, initialized);
2373
+ }
2374
+ state.initializingDatabases.add(database);
2375
+ try {
2376
+ for (const entry of state.schemaInitializers) {
2377
+ if (initialized.has(entry.initialize))
2378
+ continue;
2379
+ initialized.add(entry.initialize);
2380
+ try {
2381
+ entry.initialize(database);
2382
+ } catch (error) {
2383
+ initialized.delete(entry.initialize);
2384
+ throw error;
2385
+ }
2386
+ }
2387
+ } finally {
2388
+ state.initializingDatabases.delete(database);
2389
+ }
2390
+ }
2391
+ var STORAGE_HOST_STATE, SQLITE_INIT_RETRY_MS = 25, SQLITE_INIT_TIMEOUT_MS = 5000, SQLITE_INIT_SLEEP, internalStorageDatabase;
2392
+ var init_storage_host = __esm(async () => {
2393
+ await init_sqlite();
2394
+ STORAGE_HOST_STATE = Symbol.for("negotium.storage-host.state.v1");
2395
+ SQLITE_INIT_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
2396
+ internalStorageDatabase = new Proxy({}, {
2397
+ get(_target, property) {
2398
+ const database = resolveStorageDatabase();
2399
+ ensureStorageSchemas(database);
2400
+ const value2 = Reflect.get(database, property, database);
2401
+ return typeof value2 === "function" ? value2.bind(database) : value2;
2402
+ },
2403
+ set(_target, property, value2) {
2404
+ const database = resolveStorageDatabase();
2405
+ ensureStorageSchemas(database);
2406
+ return Reflect.set(database, property, value2, database);
2407
+ }
2408
+ });
2409
+ });
2410
+
2244
2411
  // ../../packages/core/src/storage/vault-crypto-core.ts
2245
2412
  import { createCipheriv, createDecipheriv, createHash as createHash2, randomBytes as randomBytes3 } from "crypto";
2246
2413
  function encryptionKey(masterKey) {
@@ -2297,8 +2464,8 @@ var init_vault_crypto = __esm(() => {
2297
2464
  });
2298
2465
 
2299
2466
  // ../../packages/core/src/storage/vault.ts
2300
- import { chmodSync as chmodSync4, mkdirSync as mkdirSync6 } from "fs";
2301
- import { join as join6 } from "path";
2467
+ import { chmodSync as chmodSync4, mkdirSync as mkdirSync7 } from "fs";
2468
+ import { join as join7 } from "path";
2302
2469
  function initializeVaultDatabase(database) {
2303
2470
  database.exec("PRAGMA journal_mode = WAL");
2304
2471
  database.exec("PRAGMA busy_timeout = 5000");
@@ -2333,17 +2500,18 @@ function initializeVaultDatabase(database) {
2333
2500
  }
2334
2501
  }
2335
2502
  function openVaultDatabase(dataDir) {
2336
- const vaultDir = join6(dataDir, "vault");
2337
- const path = join6(vaultDir, "vault.db");
2338
- mkdirSync6(vaultDir, { recursive: true, mode: 448 });
2503
+ const vaultDir = join7(dataDir, "vault");
2504
+ const path = join7(vaultDir, "vault.db");
2505
+ mkdirSync7(vaultDir, { recursive: true, mode: 448 });
2339
2506
  const database = new Database(path, { create: true });
2340
2507
  chmodSync4(path, 384);
2341
2508
  initializeVaultDatabase(database);
2342
2509
  return database;
2343
2510
  }
2344
2511
  function activeVaultDatabase() {
2345
- if (!vaultDb)
2346
- vaultDb = openVaultDatabase(DATA_DIR);
2512
+ if (!vaultDb) {
2513
+ vaultDb = openVaultDatabase(resolveStorageDataDir());
2514
+ }
2347
2515
  return vaultDb;
2348
2516
  }
2349
2517
  function normalizeVaultKey(key) {
@@ -2432,15 +2600,16 @@ function redactVaultSecrets(userId, text) {
2432
2600
  var vaultDb, vaultMasterKey, VAULT_VALUE_MAX_BYTES;
2433
2601
  var init_vault = __esm(async () => {
2434
2602
  init_config();
2435
- init_vault_crypto();
2436
2603
  await init_sqlite();
2604
+ await init_storage_host();
2605
+ init_vault_crypto();
2437
2606
  vaultMasterKey = VAULT_MASTER_KEY;
2438
2607
  VAULT_VALUE_MAX_BYTES = 64 * 1024;
2439
2608
  });
2440
2609
 
2441
2610
  // ../../packages/core/src/agents/execution-host.ts
2442
2611
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
2443
- import { dirname as dirname5 } from "path";
2612
+ import { dirname as dirname6 } from "path";
2444
2613
  function activeHost() {
2445
2614
  const scoped = scopedHost.getStore();
2446
2615
  if (scoped)
@@ -2475,7 +2644,7 @@ function hostedCodexAuthFilePath() {
2475
2644
  return activeHost().codexAuthFilePath();
2476
2645
  }
2477
2646
  function hostedCodexHomePath() {
2478
- return dirname5(hostedCodexAuthFilePath());
2647
+ return dirname6(hostedCodexAuthFilePath());
2479
2648
  }
2480
2649
  var defaultHost, hostRegistrations, scopedHost;
2481
2650
  var init_execution_host = __esm(async () => {
@@ -2499,14 +2668,14 @@ var init_execution_host = __esm(async () => {
2499
2668
  // ../../packages/core/src/agents/rollout/codex.ts
2500
2669
  import { randomBytes as randomBytes4 } from "crypto";
2501
2670
  import { existsSync as existsSync7, readFileSync as readFileSync7, realpathSync as realpathSync2, statSync as statSync3, unlinkSync as unlinkSync7 } from "fs";
2502
- import { basename as basename2, dirname as dirname6, join as join7, resolve as resolve5 } from "path";
2671
+ import { basename as basename2, dirname as dirname7, join as join8, resolve as resolve6 } from "path";
2503
2672
  function codexSessionsDir() {
2504
- return join7(hostedCodexHomePath(), "sessions");
2673
+ return join8(hostedCodexHomePath(), "sessions");
2505
2674
  }
2506
2675
  function loadCodexShell() {
2507
2676
  if (_shellCache)
2508
2677
  return _shellCache;
2509
- const raw = readFileSync7(join7(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
2678
+ const raw = readFileSync7(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
2510
2679
  const lines = parseJsonlText(raw);
2511
2680
  if (lines.length < 5) {
2512
2681
  throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
@@ -2573,16 +2742,16 @@ function codexRolloutPath(threadId, fallback) {
2573
2742
  const hh = String(createdAt.getHours()).padStart(2, "0");
2574
2743
  const min = String(createdAt.getMinutes()).padStart(2, "0");
2575
2744
  const ss = String(createdAt.getSeconds()).padStart(2, "0");
2576
- const dir = join7(codexSessionsDir(), yyyy, mm, dd);
2577
- return join7(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
2745
+ const dir = join8(codexSessionsDir(), yyyy, mm, dd);
2746
+ return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
2578
2747
  }
2579
2748
  function canonicalFilePath(path) {
2580
- const absolute = resolve5(path);
2749
+ const absolute = resolve6(path);
2581
2750
  try {
2582
2751
  return realpathSync2(absolute);
2583
2752
  } catch {
2584
2753
  try {
2585
- return join7(realpathSync2(dirname6(absolute)), basename2(absolute));
2754
+ return join8(realpathSync2(dirname7(absolute)), basename2(absolute));
2586
2755
  } catch {
2587
2756
  return absolute;
2588
2757
  }
@@ -2812,19 +2981,19 @@ function latestCodexRolloutPath(threadId) {
2812
2981
  try {
2813
2982
  if (buckets) {
2814
2983
  for (const bucket of buckets) {
2815
- const dir = join7(sessionsDir, bucket);
2984
+ const dir = join8(sessionsDir, bucket);
2816
2985
  if (!existsSync7(dir))
2817
2986
  continue;
2818
2987
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
2819
2988
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
2820
- candidates.push(join7(dir, rel));
2989
+ candidates.push(join8(dir, rel));
2821
2990
  }
2822
2991
  }
2823
2992
  }
2824
2993
  if (candidates.length === 0) {
2825
2994
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
2826
2995
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
2827
- candidates.push(join7(sessionsDir, rel));
2996
+ candidates.push(join8(sessionsDir, rel));
2828
2997
  }
2829
2998
  }
2830
2999
  return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
@@ -2945,13 +3114,13 @@ function sweepPriorRolloutsForThread(threadId) {
2945
3114
  return;
2946
3115
  }
2947
3116
  for (const bucket of buckets) {
2948
- const dir = join7(sessionsDir, bucket);
3117
+ const dir = join8(sessionsDir, bucket);
2949
3118
  if (!existsSync7(dir))
2950
3119
  continue;
2951
3120
  try {
2952
3121
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
2953
3122
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
2954
- const fullPath = join7(dir, rel);
3123
+ const fullPath = join8(dir, rel);
2955
3124
  try {
2956
3125
  unlinkSync7(fullPath);
2957
3126
  } catch (e) {
@@ -2969,7 +3138,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
2969
3138
  try {
2970
3139
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
2971
3140
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
2972
- const fullPath = join7(sessionsDir, rel);
3141
+ const fullPath = join8(sessionsDir, rel);
2973
3142
  try {
2974
3143
  unlinkSync7(fullPath);
2975
3144
  } catch (e) {
@@ -3024,10 +3193,10 @@ function formatDateBucket(d) {
3024
3193
  }
3025
3194
  var _shellCache = null, MAX_DAY_SPAN = 30, DAY_MS = 86400000, LOCAL_DATE_SKEW_DAYS = 1;
3026
3195
  var init_codex = __esm(async () => {
3196
+ await init_execution_host();
3027
3197
  init_shared();
3028
3198
  init_jsonl();
3029
3199
  init_logger();
3030
- await init_execution_host();
3031
3200
  });
3032
3201
 
3033
3202
  // ../../packages/core/src/agents/codex-app-server.ts
@@ -3035,7 +3204,7 @@ import { spawn as spawn4 } from "child_process";
3035
3204
  function createCodexAppServerForker(host) {
3036
3205
  return async (parentThreadId) => {
3037
3206
  const child = host.spawnServer();
3038
- return await new Promise((resolve6, reject) => {
3207
+ return await new Promise((resolve7, reject) => {
3039
3208
  let settled = false;
3040
3209
  let stdoutBuffer = "";
3041
3210
  let stderr = "";
@@ -3052,7 +3221,7 @@ function createCodexAppServerForker(host) {
3052
3221
  if (error)
3053
3222
  reject(error);
3054
3223
  else if (result)
3055
- resolve6(result);
3224
+ resolve7(result);
3056
3225
  else
3057
3226
  reject(new Error("Codex thread fork returned no result"));
3058
3227
  };
@@ -3131,10 +3300,8 @@ async function forkCodexSession(parentThreadId) {
3131
3300
  var forkCodexThread;
3132
3301
  var init_codex_app_server = __esm(async () => {
3133
3302
  init_codex_native_multi_agent();
3134
- await __promiseAll([
3135
- init_execution_host(),
3136
- init_codex()
3137
- ]);
3303
+ await init_execution_host();
3304
+ await init_codex();
3138
3305
  forkCodexThread = createCodexAppServerForker({
3139
3306
  spawnServer() {
3140
3307
  return spawn4(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
@@ -3149,16 +3316,14 @@ var init_codex_app_server = __esm(async () => {
3149
3316
 
3150
3317
  // ../../packages/core/src/agents/codex-registry.ts
3151
3318
  import { existsSync as existsSync8, unlinkSync as unlinkSync8 } from "fs";
3152
- import { join as join8 } from "path";
3319
+ import { join as join9 } from "path";
3153
3320
  var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
3154
3321
  var init_codex_registry = __esm(async () => {
3322
+ await init_codex_app_server();
3323
+ await init_execution_host();
3324
+ await init_codex();
3155
3325
  init_logger();
3156
3326
  init_types();
3157
- await __promiseAll([
3158
- init_codex_app_server(),
3159
- init_execution_host(),
3160
- init_codex()
3161
- ]);
3162
3327
  VALID_EFFORTS2 = new Set(CODEX_EFFORT_VALUES);
3163
3328
  codexRegistry = {
3164
3329
  kind: "codex",
@@ -3194,7 +3359,7 @@ var init_codex_registry = __esm(async () => {
3194
3359
  async cleanupRollouts({ sessionIds }) {
3195
3360
  if (sessionIds.length === 0)
3196
3361
  return;
3197
- const sessionsDir = join8(hostedCodexHomePath(), "sessions");
3362
+ const sessionsDir = join9(hostedCodexHomePath(), "sessions");
3198
3363
  if (!existsSync8(sessionsDir))
3199
3364
  return;
3200
3365
  const failures = [];
@@ -3202,7 +3367,7 @@ var init_codex_registry = __esm(async () => {
3202
3367
  try {
3203
3368
  const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
3204
3369
  for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
3205
- const path = join8(sessionsDir, rel);
3370
+ const path = join9(sessionsDir, rel);
3206
3371
  try {
3207
3372
  unlinkSync8(path);
3208
3373
  } catch (e) {
@@ -3226,17 +3391,17 @@ var init_codex_registry = __esm(async () => {
3226
3391
 
3227
3392
  // ../../packages/core/src/agents/maestro-registry.ts
3228
3393
  import { randomUUID as randomUUID4 } from "crypto";
3229
- import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
3230
- import { homedir as homedir4 } from "os";
3231
- import { join as join9, resolve as resolve6 } from "path";
3394
+ import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
3395
+ import { homedir as homedir5 } from "os";
3396
+ import { join as join10, resolve as resolve7 } from "path";
3232
3397
  function maestroSessionsDir() {
3233
- return join9(process.env.MAESTRO_DATA_DIR ? resolve6(process.env.MAESTRO_DATA_DIR) : join9(homedir4(), ".maestro"), "sessions");
3398
+ return join10(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join10(homedir5(), ".maestro"), "sessions");
3234
3399
  }
3235
3400
  function maestroSessionPath(sessionId) {
3236
- return join9(maestroSessionsDir(), `${sessionId}.jsonl`);
3401
+ return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
3237
3402
  }
3238
3403
  function maestroActiveSessionPath(sessionId) {
3239
- return join9(maestroSessionsDir(), `${sessionId}.active.jsonl`);
3404
+ return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
3240
3405
  }
3241
3406
  function existingCreatedAt(path) {
3242
3407
  if (!existsSync9(path))
@@ -3258,7 +3423,7 @@ function writeRollout(options) {
3258
3423
  assertUuidLike("sessionId", sessionId);
3259
3424
  ensureCwdExists(options.cwd);
3260
3425
  const path = maestroSessionPath(sessionId);
3261
- mkdirSync7(maestroSessionsDir(), { recursive: true });
3426
+ mkdirSync8(maestroSessionsDir(), { recursive: true });
3262
3427
  const messages = extractChatPairs(options.entries).flatMap((pair) => [
3263
3428
  { role: "user", content: nonEmptyTurnText(pair.userText) },
3264
3429
  { role: "assistant", content: nonEmptyTurnText(pair.assistantText) }
@@ -3394,141 +3559,6 @@ var init_common = __esm(() => {
3394
3559
  init_mcp_helpers();
3395
3560
  });
3396
3561
 
3397
- // ../../packages/core/src/storage/storage-host.ts
3398
- import { mkdirSync as mkdirSync8 } from "fs";
3399
- import { homedir as homedir5 } from "os";
3400
- import { dirname as dirname7, join as join11, resolve as resolve7 } from "path";
3401
- function envPath(name, fallback) {
3402
- const value2 = process.env[name]?.trim();
3403
- return resolve7(value2 || fallback);
3404
- }
3405
- function defaultStateDir() {
3406
- return envPath("NEGOTIUM_STATE_DIR", join11(homedir5(), ".negotium"));
3407
- }
3408
- function defaultDataDir() {
3409
- return envPath("NEGOTIUM_DATA_DIR", join11(defaultStateDir(), "data"));
3410
- }
3411
- function defaultLogDir() {
3412
- return envPath("NEGOTIUM_LOG_DIR", join11(defaultStateDir(), "logs"));
3413
- }
3414
- function defaultWorkspaceDir() {
3415
- return envPath("NEGOTIUM_WORKSPACE_DIR", join11(defaultStateDir(), "workspace"));
3416
- }
3417
- function defaultSessionAsksDir() {
3418
- const runDir = envPath("NEGOTIUM_RUN_DIR", join11(defaultStateDir(), "runtime"));
3419
- return join11(runDir, "session-asks");
3420
- }
3421
- function defaultSessionsDatabasePath() {
3422
- return envPath("SESSIONS_DB_PATH", join11(resolveStorageDataDir(), "sessions.db"));
3423
- }
3424
- function isSqliteBusy(error) {
3425
- const message = error instanceof Error ? error.message : String(error);
3426
- return /database is (?:locked|busy)|SQLITE_(?:BUSY|LOCKED)/i.test(message);
3427
- }
3428
- function execWithBusyRetry(database, sql, timeoutMs = SQLITE_INIT_TIMEOUT_MS) {
3429
- const deadline = Date.now() + timeoutMs;
3430
- while (true) {
3431
- try {
3432
- database.exec(sql);
3433
- return;
3434
- } catch (error) {
3435
- if (!isSqliteBusy(error) || Date.now() >= deadline)
3436
- throw error;
3437
- Atomics.wait(SQLITE_INIT_SLEEP, 0, 0, Math.min(SQLITE_INIT_RETRY_MS, deadline - Date.now()));
3438
- }
3439
- }
3440
- }
3441
- function initializeDatabase(database) {
3442
- database.exec("PRAGMA busy_timeout = 5000");
3443
- execWithBusyRetry(database, "PRAGMA journal_mode = WAL");
3444
- database.exec("PRAGMA foreign_keys = ON");
3445
- database.exec("PRAGMA wal_autocheckpoint = 1000");
3446
- try {
3447
- database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
3448
- } catch {}
3449
- }
3450
- function defaultDatabase() {
3451
- const path = defaultSessionsDatabasePath();
3452
- if (fallbackDatabase && fallbackDatabasePath === path)
3453
- return fallbackDatabase;
3454
- if (fallbackDatabase)
3455
- fallbackDatabase.close();
3456
- mkdirSync8(dirname7(path), { recursive: true });
3457
- fallbackDatabase = new Database(path, { create: true });
3458
- fallbackDatabasePath = path;
3459
- initializeDatabase(fallbackDatabase);
3460
- return fallbackDatabase;
3461
- }
3462
- function resolveStorageDatabase() {
3463
- return configuredHost.database ?? defaultDatabase();
3464
- }
3465
- function resolveStorageDataDir() {
3466
- return configuredHost.dataDir ?? defaultDataDir();
3467
- }
3468
- function resolveStorageLogDir() {
3469
- return configuredHost.logDir ?? defaultLogDir();
3470
- }
3471
- function resolveStorageSessionAsksDir() {
3472
- return configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
3473
- }
3474
- function resolveStorageWorkspaceDir() {
3475
- return configuredHost.workspaceDir ?? defaultWorkspaceDir();
3476
- }
3477
- function resolveStorageSharedWikiDir() {
3478
- return configuredHost.sharedWikiDir ?? join11(resolveStorageWorkspaceDir(), "wiki");
3479
- }
3480
- function registerStorageSchemaInitializer(initialize, priority = 100) {
3481
- schemaInitializers.push({ initialize, priority });
3482
- schemaInitializers.sort((a, b) => a.priority - b.priority);
3483
- }
3484
- function ensureStorageSchemas(database = resolveStorageDatabase()) {
3485
- if (initializingDatabases.has(database))
3486
- return;
3487
- let initialized = initializedSchemas.get(database);
3488
- if (!initialized) {
3489
- initialized = new Set;
3490
- initializedSchemas.set(database, initialized);
3491
- }
3492
- initializingDatabases.add(database);
3493
- try {
3494
- for (const entry of schemaInitializers) {
3495
- if (initialized.has(entry.initialize))
3496
- continue;
3497
- initialized.add(entry.initialize);
3498
- try {
3499
- entry.initialize(database);
3500
- } catch (error) {
3501
- initialized.delete(entry.initialize);
3502
- throw error;
3503
- }
3504
- }
3505
- } finally {
3506
- initializingDatabases.delete(database);
3507
- }
3508
- }
3509
- var configuredHost, fallbackDatabase = null, fallbackDatabasePath = null, schemaInitializers, initializedSchemas, initializingDatabases, SQLITE_INIT_RETRY_MS = 25, SQLITE_INIT_TIMEOUT_MS = 5000, SQLITE_INIT_SLEEP, internalStorageDatabase;
3510
- var init_storage_host = __esm(async () => {
3511
- await init_sqlite();
3512
- configuredHost = {};
3513
- schemaInitializers = [];
3514
- initializedSchemas = new WeakMap;
3515
- initializingDatabases = new WeakSet;
3516
- SQLITE_INIT_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
3517
- internalStorageDatabase = new Proxy({}, {
3518
- get(_target, property) {
3519
- const database = resolveStorageDatabase();
3520
- ensureStorageSchemas(database);
3521
- const value2 = Reflect.get(database, property, database);
3522
- return typeof value2 === "function" ? value2.bind(database) : value2;
3523
- },
3524
- set(_target, property, value2) {
3525
- const database = resolveStorageDatabase();
3526
- ensureStorageSchemas(database);
3527
- return Reflect.set(database, property, value2, database);
3528
- }
3529
- });
3530
- });
3531
-
3532
3562
  // ../../packages/core/src/storage/forum-db.ts
3533
3563
  var db;
3534
3564
  var init_forum_db = __esm(async () => {
@@ -3576,6 +3606,7 @@ function listRuntimeEventsAfter(seq, limit = 500) {
3576
3606
  var RUNTIME_EVENT_TYPES, types;
3577
3607
  var init_runtime_events = __esm(async () => {
3578
3608
  await init_forum_db();
3609
+ await init_storage_host();
3579
3610
  RUNTIME_EVENT_TYPES = [
3580
3611
  "message",
3581
3612
  "message-updated",
@@ -3584,26 +3615,28 @@ var init_runtime_events = __esm(async () => {
3584
3615
  "topic-updated",
3585
3616
  "topic-deleted"
3586
3617
  ];
3587
- db.exec(`
3588
- CREATE TABLE IF NOT EXISTS runtime_events (
3589
- seq INTEGER PRIMARY KEY AUTOINCREMENT,
3590
- source_id TEXT NOT NULL,
3591
- event_type TEXT NOT NULL CHECK (
3592
- event_type IN (
3593
- 'message',
3594
- 'message-updated',
3595
- 'ai-status',
3596
- 'topic-created',
3597
- 'topic-updated',
3598
- 'topic-deleted'
3599
- )
3600
- ),
3601
- topic_id TEXT NOT NULL,
3602
- payload_json TEXT NOT NULL,
3603
- created_at TEXT NOT NULL
3604
- )
3605
- `);
3606
- db.exec("CREATE INDEX IF NOT EXISTS idx_runtime_events_topic_seq ON runtime_events(topic_id, seq)");
3618
+ registerStorageSchemaInitializer((database) => {
3619
+ database.exec(`
3620
+ CREATE TABLE IF NOT EXISTS runtime_events (
3621
+ seq INTEGER PRIMARY KEY AUTOINCREMENT,
3622
+ source_id TEXT NOT NULL,
3623
+ event_type TEXT NOT NULL CHECK (
3624
+ event_type IN (
3625
+ 'message',
3626
+ 'message-updated',
3627
+ 'ai-status',
3628
+ 'topic-created',
3629
+ 'topic-updated',
3630
+ 'topic-deleted'
3631
+ )
3632
+ ),
3633
+ topic_id TEXT NOT NULL,
3634
+ payload_json TEXT NOT NULL,
3635
+ created_at TEXT NOT NULL
3636
+ )
3637
+ `);
3638
+ database.exec("CREATE INDEX IF NOT EXISTS idx_runtime_events_topic_seq ON runtime_events(topic_id, seq)");
3639
+ });
3607
3640
  types = new Set(RUNTIME_EVENT_TYPES);
3608
3641
  });
3609
3642
 
@@ -3763,13 +3796,17 @@ class SqliteRuntimeBus {
3763
3796
  };
3764
3797
  }
3765
3798
  }
3766
- var current, WsHub;
3799
+ function runtimeBus() {
3800
+ if (!current)
3801
+ current = new SqliteRuntimeBus;
3802
+ return current;
3803
+ }
3804
+ var current = null, WsHub;
3767
3805
  var init_bus = __esm(async () => {
3768
3806
  await init_runtime_events();
3769
- current = new SqliteRuntimeBus;
3770
3807
  WsHub = {
3771
3808
  get() {
3772
- return current;
3809
+ return runtimeBus();
3773
3810
  }
3774
3811
  };
3775
3812
  });
@@ -4004,10 +4041,8 @@ function getMessagesForTopicAfterRowid(topicId, afterRowid) {
4004
4041
  }
4005
4042
  var appendHooks;
4006
4043
  var init_api_messages = __esm(async () => {
4007
- await __promiseAll([
4008
- init_forum_db(),
4009
- init_storage_host()
4010
- ]);
4044
+ await init_forum_db();
4045
+ await init_storage_host();
4011
4046
  registerStorageSchemaInitializer(initializeApiMessagesSchema, 30);
4012
4047
  appendHooks = new Set;
4013
4048
  });
@@ -4574,10 +4609,8 @@ var DEFAULT_AGENT_ROOM_AGENT = "maestro";
4574
4609
  var init_api_topics = __esm(async () => {
4575
4610
  init_constants();
4576
4611
  init_logger();
4577
- await __promiseAll([
4578
- init_forum_db(),
4579
- init_storage_host()
4580
- ]);
4612
+ await init_forum_db();
4613
+ await init_storage_host();
4581
4614
  registerStorageSchemaInitializer(initializeApiTopicsSchema, 20);
4582
4615
  });
4583
4616
 
@@ -4664,10 +4697,8 @@ function beginRuntimeTopicMaintenance(topicId, options = {}) {
4664
4697
  }
4665
4698
  var TOPIC_MAINTENANCE_STALE_MS = 30000, TOPIC_MAINTENANCE_HEARTBEAT_MS = 1000;
4666
4699
  var init_runtime_topic_state = __esm(async () => {
4667
- await __promiseAll([
4668
- init_forum_db(),
4669
- init_storage_host()
4670
- ]);
4700
+ await init_forum_db();
4701
+ await init_storage_host();
4671
4702
  registerStorageSchemaInitializer((database) => {
4672
4703
  database.exec(`
4673
4704
  CREATE TABLE IF NOT EXISTS runtime_topic_state (
@@ -4764,11 +4795,9 @@ function releaseRuntimeTurnLease(topicId, queryId, ownerId = RUNTIME_INSTANCE_ID
4764
4795
  }
4765
4796
  var RUNTIME_INSTANCE_ID, TURN_LEASE_STALE_MS = 1e4;
4766
4797
  var init_runtime_leases = __esm(async () => {
4767
- await __promiseAll([
4768
- init_forum_db(),
4769
- init_runtime_topic_state(),
4770
- init_storage_host()
4771
- ]);
4798
+ await init_forum_db();
4799
+ await init_runtime_topic_state();
4800
+ await init_storage_host();
4772
4801
  RUNTIME_INSTANCE_ID = `${process.pid}-${randomUUID7()}`;
4773
4802
  registerStorageSchemaInitializer((database) => {
4774
4803
  database.exec(`
@@ -5065,13 +5094,12 @@ function getRuntimeUserTurnRequest(topicId) {
5065
5094
  }
5066
5095
  var REQUEST_CLAIM_STALE_MS;
5067
5096
  var init_runtime_turn_requests = __esm(async () => {
5068
- await __promiseAll([
5069
- init_forum_db(),
5070
- init_runtime_leases(),
5071
- init_runtime_topic_state()
5072
- ]);
5097
+ await init_forum_db();
5098
+ await init_runtime_leases();
5099
+ await init_runtime_topic_state();
5100
+ await init_storage_host();
5073
5101
  REQUEST_CLAIM_STALE_MS = TURN_LEASE_STALE_MS;
5074
- ensureRuntimeUserTurnRequestsSchema(db);
5102
+ registerStorageSchemaInitializer((database) => ensureRuntimeUserTurnRequestsSchema(database));
5075
5103
  });
5076
5104
 
5077
5105
  // ../../packages/core/src/agents/registry.ts
@@ -5089,8 +5117,8 @@ function getRegistryOperations(agent) {
5089
5117
  var REGISTRIES, OPERATIONS;
5090
5118
  var init_registry = __esm(async () => {
5091
5119
  init_claude_registry();
5092
- init_maestro_registry();
5093
5120
  await init_codex_registry();
5121
+ init_maestro_registry();
5094
5122
  REGISTRIES = {
5095
5123
  claude: claudeRegistry,
5096
5124
  codex: codexRegistry,
@@ -5137,8 +5165,8 @@ function cleanupAgentFork(handle) {
5137
5165
  }
5138
5166
  var defaultForkHelpers;
5139
5167
  var init_fork = __esm(async () => {
5140
- init_logger();
5141
5168
  await init_registry();
5169
+ init_logger();
5142
5170
  defaultForkHelpers = createAgentForkHelpers({
5143
5171
  forkSession: (agent, options) => getRegistryOperations(agent).forkSession(options),
5144
5172
  exists: existsSync11,
@@ -5520,11 +5548,9 @@ function acquireRuntimeProcessLease(role, options = {}) {
5520
5548
  }
5521
5549
  var PROCESS_LEASE_STALE_MS = 5000, PROCESS_LEASE_HEARTBEAT_MS = 1000;
5522
5550
  var init_runtime_process_leases = __esm(async () => {
5523
- await __promiseAll([
5524
- init_forum_db(),
5525
- init_runtime_leases(),
5526
- init_storage_host()
5527
- ]);
5551
+ await init_forum_db();
5552
+ await init_runtime_leases();
5553
+ await init_storage_host();
5528
5554
  registerStorageSchemaInitializer((database) => {
5529
5555
  database.exec(`
5530
5556
  CREATE TABLE IF NOT EXISTS runtime_process_leases (
@@ -5805,8 +5831,8 @@ var init_transport_probe = __esm(() => {
5805
5831
 
5806
5832
  // ../../packages/core/src/storage/vault-public.ts
5807
5833
  var init_vault_public = __esm(async () => {
5808
- init_vault_crypto();
5809
5834
  await init_vault();
5835
+ init_vault_crypto();
5810
5836
  });
5811
5837
 
5812
5838
  // ../../packages/core/src/platform/playwright/vault-broker.ts
@@ -6100,14 +6126,17 @@ function assignTopicBrowserProfile(opts) {
6100
6126
  var DEFAULT_BROWSER_PROFILE = "default";
6101
6127
  var init_browser_profiles = __esm(async () => {
6102
6128
  await init_forum_db();
6103
- db.exec(`
6104
- CREATE TABLE IF NOT EXISTS browser_profiles (
6105
- owner_id TEXT NOT NULL,
6106
- name TEXT NOT NULL,
6107
- created_at TEXT NOT NULL,
6108
- PRIMARY KEY (owner_id, name)
6109
- )
6110
- `);
6129
+ await init_storage_host();
6130
+ registerStorageSchemaInitializer((database) => {
6131
+ database.exec(`
6132
+ CREATE TABLE IF NOT EXISTS browser_profiles (
6133
+ owner_id TEXT NOT NULL,
6134
+ name TEXT NOT NULL,
6135
+ created_at TEXT NOT NULL,
6136
+ PRIMARY KEY (owner_id, name)
6137
+ )
6138
+ `);
6139
+ });
6111
6140
  });
6112
6141
 
6113
6142
  // ../../packages/core/src/platform/playwright/manager.ts
@@ -6746,17 +6775,15 @@ var defaultManagerHost, managerHost, MAX_IDLE_MS, instances, usedPorts, spawning
6746
6775
  var init_manager2 = __esm(async () => {
6747
6776
  init_config();
6748
6777
  init_logger();
6778
+ await init_browser_processes();
6749
6779
  init_headed_launch();
6750
6780
  init_transport_probe();
6781
+ await init_vault_broker();
6782
+ await init_browser_profiles();
6751
6783
  init_manager_utils();
6784
+ await init_browser_processes();
6752
6785
  init_transport_probe();
6753
6786
  init_manager_utils();
6754
- await __promiseAll([
6755
- init_browser_processes(),
6756
- init_vault_broker(),
6757
- init_browser_profiles(),
6758
- init_browser_processes()
6759
- ]);
6760
6787
  defaultManagerHost = Object.freeze({
6761
6788
  portsDir: PLAYWRIGHT_PORTS_DIR,
6762
6789
  basePort: PLAYWRIGHT_BASE_PORT,
@@ -7140,8 +7167,8 @@ function wsAbortReason(reason) {
7140
7167
  var roomQueryRegistry, interSessionQueue;
7141
7168
  var init_active_rooms = __esm(async () => {
7142
7169
  init_logger();
7143
- init_types2();
7144
7170
  await init_runtime_leases();
7171
+ init_types2();
7145
7172
  roomQueryRegistry = createRoomQueryRegistry({
7146
7173
  instanceId: RUNTIME_INSTANCE_ID,
7147
7174
  internalAbortReason: "internal" /* Internal */,
@@ -7268,10 +7295,8 @@ function deleteApiTopicConfig(topicId) {
7268
7295
  db.query("DELETE FROM api_topic_config WHERE topic_id = ?").run(topicId);
7269
7296
  }
7270
7297
  var init_api_topic_config = __esm(async () => {
7271
- await __promiseAll([
7272
- init_forum_db(),
7273
- init_storage_host()
7274
- ]);
7298
+ await init_forum_db();
7299
+ await init_storage_host();
7275
7300
  registerStorageSchemaInitializer(initializeApiTopicConfigSchema, 40);
7276
7301
  });
7277
7302
 
@@ -7439,13 +7464,11 @@ function isLegacySharedGeneral(topicId) {
7439
7464
  }
7440
7465
  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.";
7441
7466
  var init_personal_general = __esm(async () => {
7467
+ await init_registry();
7442
7468
  init_config();
7443
7469
  init_constants();
7444
- await __promiseAll([
7445
- init_registry(),
7446
- init_api_topic_config(),
7447
- init_api_topics()
7448
- ]);
7470
+ await init_api_topic_config();
7471
+ await init_api_topics();
7449
7472
  });
7450
7473
 
7451
7474
  // ../../packages/core/src/agents/compaction-support.ts
@@ -8240,10 +8263,10 @@ async function* claudeProvider(opts) {
8240
8263
  var CLAUDE_DEFAULT_DISALLOWED_TOOLS, CLAUDE_NATIVE_AGENT_TOOLS, CLAUDE_IMAGE_MAX_BYTES, CLAUDE_IMAGE_MIME_TYPES, CLAUDE_ABORT_SIGKILL_DELAY_MS = 2500;
8241
8264
  var init_claude_provider = __esm(async () => {
8242
8265
  init_claude_registry();
8266
+ await init_execution_host();
8243
8267
  init_vault_tool_policy();
8244
8268
  init_file_events();
8245
8269
  init_logger();
8246
- await init_execution_host();
8247
8270
  CLAUDE_DEFAULT_DISALLOWED_TOOLS = [
8248
8271
  "AskUserQuestion",
8249
8272
  "Workflow",
@@ -9678,14 +9701,12 @@ var CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_
9678
9701
  var init_codex_provider = __esm(async () => {
9679
9702
  init_codex_native_multi_agent();
9680
9703
  init_codex_tree_kill();
9704
+ await init_execution_host();
9705
+ await init_codex();
9681
9706
  init_tool_format();
9682
9707
  init_file_events();
9683
9708
  init_logger();
9684
9709
  init_mcp_config();
9685
- await __promiseAll([
9686
- init_execution_host(),
9687
- init_codex()
9688
- ]);
9689
9710
  CODEX_MCP_SERVER_NAME_OVERRIDES = {
9690
9711
  playwright: "otium_playwright"
9691
9712
  };
@@ -9806,12 +9827,10 @@ function maestroProvider(opts) {
9806
9827
  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;
9807
9828
  var init_maestro_provider = __esm(async () => {
9808
9829
  init_maestro_bootstrap_env();
9830
+ await init_execution_host();
9809
9831
  init_vault_tool_policy();
9810
9832
  init_config();
9811
- await __promiseAll([
9812
- init_execution_host(),
9813
- init_vault()
9814
- ]);
9833
+ await init_vault();
9815
9834
  MAESTRO_NATIVE_TASK_TOOLS = [
9816
9835
  "TaskCreate",
9817
9836
  "TaskUpdate",
@@ -9957,15 +9976,13 @@ async function* runAgent(opts) {
9957
9976
  }
9958
9977
  }
9959
9978
  var init_agents = __esm(async () => {
9979
+ await init_execution_host();
9980
+ await init_registry();
9960
9981
  init_claude();
9982
+ await init_task_events();
9961
9983
  init_logger();
9984
+ await init_conversations();
9962
9985
  init_types();
9963
- await __promiseAll([
9964
- init_execution_host(),
9965
- init_registry(),
9966
- init_task_events(),
9967
- init_conversations()
9968
- ]);
9969
9986
  });
9970
9987
 
9971
9988
  // ../../packages/core/src/prompts/builders.ts
@@ -10391,11 +10408,9 @@ function deleteTopicBrief(topicId) {
10391
10408
  db.query("DELETE FROM api_topic_brief WHERE topic_id = ?").run(topicId);
10392
10409
  }
10393
10410
  var init_api_topic_brief = __esm(async () => {
10411
+ await init_forum_db();
10412
+ await init_storage_host();
10394
10413
  init_wiki_summary_names();
10395
- await __promiseAll([
10396
- init_forum_db(),
10397
- init_storage_host()
10398
- ]);
10399
10414
  registerStorageSchemaInitializer((database) => {
10400
10415
  database.exec(`
10401
10416
  CREATE TABLE IF NOT EXISTS api_topic_brief (
@@ -10440,9 +10455,9 @@ function formatArchiverBytes(bytes) {
10440
10455
  function formatArchiverTool(name, input) {
10441
10456
  const params = Object.entries(input).map(([key, value2]) => {
10442
10457
  const rendered = typeof value2 === "string" ? value2 : JSON.stringify(value2);
10443
- return `${key}: ${sessionText(rendered ?? "")}`;
10458
+ return `${key}: ${summarizeDisplayText(sessionText(rendered ?? ""))}`;
10444
10459
  }).join(", ");
10445
- return `${name}${params ? `(${params})` : ""}`;
10460
+ return summarizeDisplayText(`${name}${params ? `(${params})` : ""}`);
10446
10461
  }
10447
10462
  function createArchiverRuntime(host) {
10448
10463
  const activeSessions = new Map;
@@ -10749,19 +10764,18 @@ function runArchiverTurn(params) {
10749
10764
  }
10750
10765
  var MAX_BRIEF_ENTRIES = 8, defaultArchiverRuntime;
10751
10766
  var init_archiver = __esm(async () => {
10767
+ await init_agents();
10768
+ init_tool_format();
10769
+ await init_bus();
10752
10770
  init_config();
10753
10771
  init_logger();
10754
10772
  init_builders();
10755
10773
  init_background_session_policy();
10774
+ await init_api_messages();
10775
+ await init_api_topic_brief();
10776
+ await init_wiki();
10756
10777
  init_wiki_summary_names();
10757
- await __promiseAll([
10758
- init_agents(),
10759
- init_bus(),
10760
- init_api_messages(),
10761
- init_api_topic_brief(),
10762
- init_wiki(),
10763
- init_personal_general()
10764
- ]);
10778
+ await init_personal_general();
10765
10779
  defaultArchiverRuntime = createArchiverRuntime({
10766
10780
  storage: {
10767
10781
  getWikiDir: getSharedWikiDir,
@@ -10994,11 +11008,9 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
10994
11008
  }
10995
11009
  var init_topic_archive = __esm(async () => {
10996
11010
  init_logger();
10997
- await __promiseAll([
10998
- init_api_messages(),
10999
- init_conversations(),
11000
- init_wiki()
11001
- ]);
11011
+ await init_api_messages();
11012
+ await init_conversations();
11013
+ await init_wiki();
11002
11014
  });
11003
11015
 
11004
11016
  // ../../packages/core/src/storage/topic-archive-state.ts
@@ -11111,10 +11123,8 @@ function deleteTopicArchiveState(topicId) {
11111
11123
  }
11112
11124
  var ARCHIVE_JOB_STALE_MS;
11113
11125
  var init_topic_archive_state = __esm(async () => {
11114
- await __promiseAll([
11115
- init_forum_db(),
11116
- init_storage_host()
11117
- ]);
11126
+ await init_forum_db();
11127
+ await init_storage_host();
11118
11128
  registerStorageSchemaInitializer((database) => {
11119
11129
  database.exec(`
11120
11130
  CREATE TABLE IF NOT EXISTS api_topic_archive_state (
@@ -11290,15 +11300,13 @@ function archiveActiveTopicForMemory(topicId, userId, options) {
11290
11300
  }
11291
11301
  var DEFAULT_IDLE_DELAY_MS, DEFAULT_MIN_MESSAGES = 8, timers;
11292
11302
  var init_idle_archiver = __esm(async () => {
11303
+ await init_archiver();
11293
11304
  init_logger();
11294
- await __promiseAll([
11295
- init_archiver(),
11296
- init_active_rooms(),
11297
- init_api_messages(),
11298
- init_api_topics(),
11299
- init_topic_archive(),
11300
- init_topic_archive_state()
11301
- ]);
11305
+ await init_active_rooms();
11306
+ await init_api_messages();
11307
+ await init_api_topics();
11308
+ await init_topic_archive();
11309
+ await init_topic_archive_state();
11302
11310
  DEFAULT_IDLE_DELAY_MS = 6 * 60 * 60 * 1000;
11303
11311
  timers = new Map;
11304
11312
  });
@@ -11422,12 +11430,10 @@ function createTopicLogMaintenance(host) {
11422
11430
  }
11423
11431
  var defaultTopicLogMaintenance, cleanupTopicRollouts, cleanupTopicRolloutsFromEntries, rotateTopicLogs, purgeTopicLogs;
11424
11432
  var init_topic_cleanup = __esm(async () => {
11433
+ await init_agents();
11434
+ await init_registry();
11425
11435
  init_logger();
11426
- await __promiseAll([
11427
- init_agents(),
11428
- init_registry(),
11429
- init_conversations()
11430
- ]);
11436
+ await init_conversations();
11431
11437
  defaultTopicLogMaintenance = createTopicLogMaintenance({
11432
11438
  agents: SUPPORTED_AGENTS,
11433
11439
  readActiveConversation: readConversation,
@@ -11510,13 +11516,12 @@ function text(value2, maxLen) {
11510
11516
  }
11511
11517
  var providers, transientSessions;
11512
11518
  var init_background_sessions = __esm(async () => {
11519
+ await init_archiver();
11520
+ init_tool_format();
11521
+ await init_api_topics();
11522
+ await init_runtime_events();
11523
+ await init_runtime_leases();
11513
11524
  init_background_session_policy();
11514
- await __promiseAll([
11515
- init_archiver(),
11516
- init_api_topics(),
11517
- init_runtime_events(),
11518
- init_runtime_leases()
11519
- ]);
11520
11525
  providers = new Set;
11521
11526
  transientSessions = new Map;
11522
11527
  });
@@ -11914,31 +11919,29 @@ async function createCompactedRolloutEntries(request, summarize = summarizeTopic
11914
11919
  }
11915
11920
  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;
11916
11921
  var init_session = __esm(async () => {
11922
+ await init_idle_archiver();
11923
+ await init_agents();
11917
11924
  init_model_catalog();
11925
+ await init_registry();
11918
11926
  init_shared();
11927
+ await init_topic_cleanup();
11928
+ await init_bus();
11919
11929
  init_config();
11920
11930
  init_logger();
11921
11931
  init_mcp_config();
11932
+ await init_active_rooms();
11933
+ await init_background_sessions();
11922
11934
  init_usage_alert();
11923
- await __promiseAll([
11924
- init_idle_archiver(),
11925
- init_agents(),
11926
- init_registry(),
11927
- init_topic_cleanup(),
11928
- init_bus(),
11929
- init_active_rooms(),
11930
- init_background_sessions(),
11931
- init_api_messages(),
11932
- init_api_topic_brief(),
11933
- init_api_topic_config(),
11934
- init_api_topics(),
11935
- init_conversations(),
11936
- init_runtime_leases(),
11937
- init_runtime_topic_state(),
11938
- init_runtime_turn_requests(),
11939
- init_topic_archive(),
11940
- init_personal_general()
11941
- ]);
11935
+ await init_api_messages();
11936
+ await init_api_topic_brief();
11937
+ await init_api_topic_config();
11938
+ await init_api_topics();
11939
+ await init_conversations();
11940
+ await init_runtime_leases();
11941
+ await init_runtime_topic_state();
11942
+ await init_runtime_turn_requests();
11943
+ await init_topic_archive();
11944
+ await init_personal_general();
11942
11945
  RESET_MEMORY_ARCHIVE_WAIT_MS = 5 * 60 * 1000;
11943
11946
  COMPACTION_SOURCE_CHARS = 512 * 1024;
11944
11947
  COMPACTION_TIMEOUT_MS = 2 * 60000;
@@ -12269,24 +12272,22 @@ async function createDerivedTopicImpl(topic, sourceTopicId, userId, copyHistory,
12269
12272
  }
12270
12273
  var TopicTitleConflictError, TopicDeriveBusyError, TopicForkCompactionError;
12271
12274
  var init_derive = __esm(async () => {
12275
+ await init_fork();
12272
12276
  init_model_catalog();
12277
+ await init_registry();
12278
+ await init_bus();
12273
12279
  init_config();
12274
12280
  init_logger();
12275
- await __promiseAll([
12276
- init_fork(),
12277
- init_registry(),
12278
- init_bus(),
12279
- init_manager2(),
12280
- init_active_rooms(),
12281
- init_api_messages(),
12282
- init_api_topic_config(),
12283
- init_api_topics(),
12284
- init_conversations(),
12285
- init_forum_db(),
12286
- init_runtime_topic_state(),
12287
- init_personal_general(),
12288
- init_session()
12289
- ]);
12281
+ await init_manager2();
12282
+ await init_active_rooms();
12283
+ await init_api_messages();
12284
+ await init_api_topic_config();
12285
+ await init_api_topics();
12286
+ await init_conversations();
12287
+ await init_forum_db();
12288
+ await init_runtime_topic_state();
12289
+ await init_personal_general();
12290
+ await init_session();
12290
12291
  TopicTitleConflictError = class TopicTitleConflictError extends Error {
12291
12292
  title;
12292
12293
  constructor(title) {
@@ -12945,21 +12946,22 @@ async function failInterruptedRemoteAskCallbacks() {
12945
12946
  }
12946
12947
  var pendingAsks, MAX_ASK_AGE_MS;
12947
12948
  var init_ask_callbacks = __esm(async () => {
12948
- await __promiseAll([
12949
- init_forum_db(),
12950
- init_session_asks()
12951
- ]);
12952
- db.exec(`
12953
- CREATE TABLE IF NOT EXISTS remote_ask_callbacks (
12954
- target_query_id TEXT PRIMARY KEY,
12955
- request_id TEXT NOT NULL,
12956
- node_name TEXT NOT NULL,
12957
- node_cell_id TEXT NOT NULL,
12958
- topic_id TEXT NOT NULL,
12959
- user_id TEXT NOT NULL,
12960
- created_at INTEGER NOT NULL
12961
- )
12962
- `);
12949
+ await init_forum_db();
12950
+ await init_session_asks();
12951
+ await init_storage_host();
12952
+ registerStorageSchemaInitializer((database) => {
12953
+ database.exec(`
12954
+ CREATE TABLE IF NOT EXISTS remote_ask_callbacks (
12955
+ target_query_id TEXT PRIMARY KEY,
12956
+ request_id TEXT NOT NULL,
12957
+ node_name TEXT NOT NULL,
12958
+ node_cell_id TEXT NOT NULL,
12959
+ topic_id TEXT NOT NULL,
12960
+ user_id TEXT NOT NULL,
12961
+ created_at INTEGER NOT NULL
12962
+ )
12963
+ `);
12964
+ });
12963
12965
  pendingAsks = new Map;
12964
12966
  MAX_ASK_AGE_MS = PENDING_ASK_TTL_MS;
12965
12967
  });
@@ -13173,29 +13175,32 @@ if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",
13173
13175
  </script>`;
13174
13176
  var init_visual_store = __esm(async () => {
13175
13177
  await init_forum_db();
13176
- db.exec(`
13177
- CREATE TABLE IF NOT EXISTS api_topic_visuals (
13178
- id INTEGER PRIMARY KEY AUTOINCREMENT,
13179
- topic_id TEXT NOT NULL,
13180
- html TEXT NOT NULL,
13181
- title TEXT,
13182
- created_at INTEGER NOT NULL,
13183
- kind TEXT NOT NULL DEFAULT 'html',
13184
- source TEXT,
13185
- file_id TEXT,
13186
- mime_type TEXT,
13187
- media_token TEXT
13188
- );
13189
- CREATE INDEX IF NOT EXISTS idx_api_topic_visuals_topic
13190
- ON api_topic_visuals(topic_id, created_at DESC);
13191
-
13192
- CREATE TABLE IF NOT EXISTS api_topic_visual_views (
13193
- topic_id TEXT NOT NULL,
13194
- user_id TEXT NOT NULL,
13195
- visual_id INTEGER NOT NULL,
13196
- PRIMARY KEY (topic_id, user_id)
13197
- );
13198
- `);
13178
+ await init_storage_host();
13179
+ registerStorageSchemaInitializer((database) => {
13180
+ database.exec(`
13181
+ CREATE TABLE IF NOT EXISTS api_topic_visuals (
13182
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
13183
+ topic_id TEXT NOT NULL,
13184
+ html TEXT NOT NULL,
13185
+ title TEXT,
13186
+ created_at INTEGER NOT NULL,
13187
+ kind TEXT NOT NULL DEFAULT 'html',
13188
+ source TEXT,
13189
+ file_id TEXT,
13190
+ mime_type TEXT,
13191
+ media_token TEXT
13192
+ );
13193
+ CREATE INDEX IF NOT EXISTS idx_api_topic_visuals_topic
13194
+ ON api_topic_visuals(topic_id, created_at DESC);
13195
+
13196
+ CREATE TABLE IF NOT EXISTS api_topic_visual_views (
13197
+ topic_id TEXT NOT NULL,
13198
+ user_id TEXT NOT NULL,
13199
+ visual_id INTEGER NOT NULL,
13200
+ PRIMARY KEY (topic_id, user_id)
13201
+ );
13202
+ `);
13203
+ });
13199
13204
  for (const statement of [
13200
13205
  "ALTER TABLE api_topic_visuals ADD COLUMN kind TEXT NOT NULL DEFAULT 'html'",
13201
13206
  "ALTER TABLE api_topic_visuals ADD COLUMN source TEXT",
@@ -13233,35 +13238,36 @@ function deleteSelfSchedulesForTopic(topicId) {
13233
13238
  return Number(result.changes ?? 0);
13234
13239
  }
13235
13240
  var init_self_schedules = __esm(async () => {
13236
- await __promiseAll([
13237
- init_forum_db(),
13238
- init_runtime_leases(),
13239
- init_runtime_topic_state()
13240
- ]);
13241
- db.exec(`
13242
- CREATE TABLE IF NOT EXISTS runtime_self_schedules (
13243
- id TEXT PRIMARY KEY,
13244
- topic_id TEXT NOT NULL,
13245
- user_id TEXT NOT NULL,
13246
- message TEXT NOT NULL,
13247
- deliver_at INTEGER NOT NULL,
13248
- created_at INTEGER NOT NULL,
13249
- updated_at INTEGER NOT NULL,
13250
- status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running')),
13251
- claimed_by TEXT,
13252
- claimed_at INTEGER,
13253
- running_query_id TEXT
13254
- )
13255
- `);
13256
- db.exec(`
13257
- CREATE UNIQUE INDEX IF NOT EXISTS idx_runtime_self_schedules_one_pending
13258
- ON runtime_self_schedules(topic_id)
13259
- WHERE status = 'pending'
13260
- `);
13261
- db.exec(`
13262
- CREATE INDEX IF NOT EXISTS idx_runtime_self_schedules_due
13263
- ON runtime_self_schedules(status, deliver_at)
13264
- `);
13241
+ await init_forum_db();
13242
+ await init_runtime_leases();
13243
+ await init_runtime_topic_state();
13244
+ await init_storage_host();
13245
+ registerStorageSchemaInitializer((database) => {
13246
+ database.exec(`
13247
+ CREATE TABLE IF NOT EXISTS runtime_self_schedules (
13248
+ id TEXT PRIMARY KEY,
13249
+ topic_id TEXT NOT NULL,
13250
+ user_id TEXT NOT NULL,
13251
+ message TEXT NOT NULL,
13252
+ deliver_at INTEGER NOT NULL,
13253
+ created_at INTEGER NOT NULL,
13254
+ updated_at INTEGER NOT NULL,
13255
+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running')),
13256
+ claimed_by TEXT,
13257
+ claimed_at INTEGER,
13258
+ running_query_id TEXT
13259
+ )
13260
+ `);
13261
+ database.exec(`
13262
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_runtime_self_schedules_one_pending
13263
+ ON runtime_self_schedules(topic_id)
13264
+ WHERE status = 'pending'
13265
+ `);
13266
+ database.exec(`
13267
+ CREATE INDEX IF NOT EXISTS idx_runtime_self_schedules_due
13268
+ ON runtime_self_schedules(status, deliver_at)
13269
+ `);
13270
+ });
13265
13271
  });
13266
13272
 
13267
13273
  // ../../packages/core/src/topics/lifecycle.ts
@@ -13440,37 +13446,35 @@ async function deleteTopicCascadeImpl(topic, userId, options, deletingAncestorId
13440
13446
  }
13441
13447
  var DELETE_TURN_WAIT_MS = 5000, TopicArchiveRequiredError, TopicTurnStillActiveError, TopicCleanupRequiredError;
13442
13448
  var init_lifecycle = __esm(async () => {
13449
+ await init_archiver();
13450
+ await init_idle_archiver();
13451
+ await init_spawn_subagent();
13452
+ await init_topic_cleanup();
13453
+ await init_bus();
13443
13454
  init_manager();
13444
13455
  init_config();
13445
13456
  init_constants();
13446
13457
  init_logger();
13458
+ await init_manager2();
13459
+ await init_active_rooms();
13447
13460
  init_session_inbox_cleanup();
13448
13461
  init_state();
13462
+ await init_ask_callbacks();
13449
13463
  init_file_hooks();
13450
13464
  init_usage_alert();
13451
- await __promiseAll([
13452
- init_archiver(),
13453
- init_idle_archiver(),
13454
- init_spawn_subagent(),
13455
- init_topic_cleanup(),
13456
- init_bus(),
13457
- init_manager2(),
13458
- init_active_rooms(),
13459
- init_ask_callbacks(),
13460
- init_visual_store(),
13461
- init_api_messages(),
13462
- init_api_topic_brief(),
13463
- init_api_topic_config(),
13464
- init_api_topics(),
13465
- init_browser_profiles(),
13466
- init_runtime_leases(),
13467
- init_runtime_topic_state(),
13468
- init_runtime_turn_requests(),
13469
- init_self_schedules(),
13470
- init_session_asks(),
13471
- init_topic_archive(),
13472
- init_topic_archive_state()
13473
- ]);
13465
+ await init_visual_store();
13466
+ await init_api_messages();
13467
+ await init_api_topic_brief();
13468
+ await init_api_topic_config();
13469
+ await init_api_topics();
13470
+ await init_browser_profiles();
13471
+ await init_runtime_leases();
13472
+ await init_runtime_topic_state();
13473
+ await init_runtime_turn_requests();
13474
+ await init_self_schedules();
13475
+ await init_session_asks();
13476
+ await init_topic_archive();
13477
+ await init_topic_archive_state();
13474
13478
  TopicArchiveRequiredError = class TopicArchiveRequiredError extends Error {
13475
13479
  code = "TOPIC_ARCHIVE_FAILED";
13476
13480
  topicId;
@@ -13830,8 +13834,8 @@ function abortPlaywrightTurns(instanceKey, failure) {
13830
13834
  var turnsByInstance;
13831
13835
  var init_playwright_turn_abort = __esm(async () => {
13832
13836
  init_logger();
13833
- init_types2();
13834
13837
  await init_manager2();
13838
+ init_types2();
13835
13839
  turnsByInstance = new Map;
13836
13840
  onPlaywrightFailure(abortPlaywrightTurns);
13837
13841
  });
@@ -14033,10 +14037,8 @@ function cancelAskUserGate(topicId, messageId, ownerId, now = new Date().toISOSt
14033
14037
  }).immediate();
14034
14038
  }
14035
14039
  var init_ask_user_gates = __esm(async () => {
14036
- await __promiseAll([
14037
- init_forum_db(),
14038
- init_storage_host()
14039
- ]);
14040
+ await init_forum_db();
14041
+ await init_storage_host();
14040
14042
  registerStorageSchemaInitializer(initializeAskUserGateSchema, 31);
14041
14043
  });
14042
14044
 
@@ -14343,14 +14345,12 @@ function cancelPendingAskUserQuestions(topicId, queryId) {
14343
14345
  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;
14344
14346
  var init_ask_user = __esm(async () => {
14345
14347
  init_common();
14346
- await __promiseAll([
14347
- init_bus(),
14348
- init_api_messages(),
14349
- init_api_topic_config(),
14350
- init_api_topics(),
14351
- init_ask_user_gates(),
14352
- init_runtime_process_leases()
14353
- ]);
14348
+ await init_bus();
14349
+ await init_api_messages();
14350
+ await init_api_topic_config();
14351
+ await init_api_topics();
14352
+ await init_ask_user_gates();
14353
+ await init_runtime_process_leases();
14354
14354
  ASK_GATE_OWNER_ID = `ask-user-${process.pid}-${randomUUID14()}`;
14355
14355
  defaultAskUserDurabilityHost = {
14356
14356
  gates: {
@@ -14458,10 +14458,8 @@ function upsertTaskPanelMessage(topicId, queryId, tasks, lastRenderedText) {
14458
14458
  return text2;
14459
14459
  }
14460
14460
  var init_tasks2 = __esm(async () => {
14461
- await __promiseAll([
14462
- init_bus(),
14463
- init_api_messages()
14464
- ]);
14461
+ await init_bus();
14462
+ await init_api_messages();
14465
14463
  });
14466
14464
 
14467
14465
  // ../../packages/core/src/runtime/visual-html.ts
@@ -14697,12 +14695,10 @@ var ACTIVE_VISUAL_PROMPT_MAX_CHARS = 24000, ACTIVE_VISUAL_PROMPT_TAIL_CHARS = 60
14697
14695
  var init_visuals = __esm(async () => {
14698
14696
  init_attachments();
14699
14697
  init_file_hooks();
14698
+ await init_visual_store();
14700
14699
  init_sensitive_path();
14700
+ await init_api_messages();
14701
14701
  init_visual_html();
14702
- await __promiseAll([
14703
- init_visual_store(),
14704
- init_api_messages()
14705
- ]);
14706
14702
  });
14707
14703
 
14708
14704
  // ../../packages/core/src/storage/token-stats.ts
@@ -15441,32 +15437,30 @@ ${JSON.stringify(event.input ?? {})}`);
15441
15437
  return outcome;
15442
15438
  }
15443
15439
  var init_turn_event_stream = __esm(async () => {
15440
+ await init_fork();
15441
+ await init_idle_archiver();
15442
+ await init_ask_user();
15443
+ await init_spawn_subagent();
15444
15444
  init_model_catalog();
15445
+ await init_registry();
15445
15446
  init_tool_format();
15447
+ await init_bus();
15446
15448
  init_logger();
15449
+ await init_active_rooms();
15447
15450
  init_state();
15448
15451
  init_types2();
15449
15452
  init_attachments();
15450
15453
  init_errors();
15454
+ await init_tasks2();
15455
+ await init_topic_config();
15451
15456
  init_usage_alert();
15457
+ await init_visual_store();
15458
+ await init_visuals();
15452
15459
  init_sensitive_path();
15453
- await __promiseAll([
15454
- init_fork(),
15455
- init_idle_archiver(),
15456
- init_ask_user(),
15457
- init_spawn_subagent(),
15458
- init_registry(),
15459
- init_bus(),
15460
- init_active_rooms(),
15461
- init_tasks2(),
15462
- init_topic_config(),
15463
- init_visual_store(),
15464
- init_visuals(),
15465
- init_api_messages(),
15466
- init_api_topics(),
15467
- init_runtime_turn_requests(),
15468
- init_token_stats()
15469
- ]);
15460
+ await init_api_messages();
15461
+ await init_api_topics();
15462
+ await init_runtime_turn_requests();
15463
+ await init_token_stats();
15470
15464
  });
15471
15465
 
15472
15466
  // ../../packages/core/src/runtime/turn-session.ts
@@ -15498,11 +15492,9 @@ function resolveInitialTurnSessionId(topicId, requestedSessionId, isolated) {
15498
15492
  }
15499
15493
  var init_turn_session = __esm(async () => {
15500
15494
  init_model_catalog();
15501
- await __promiseAll([
15502
- init_registry(),
15503
- init_topic_config(),
15504
- init_api_topics()
15505
- ]);
15495
+ await init_registry();
15496
+ await init_topic_config();
15497
+ await init_api_topics();
15506
15498
  });
15507
15499
 
15508
15500
  // ../../packages/core/src/storage/app-settings.ts
@@ -16830,43 +16822,41 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
16830
16822
  }
16831
16823
  var PLAYWRIGHT_UNAVAILABLE_NOTICE_COOLDOWN_MS, ASK_REPLY_INJECT_BATCH_MS = 500, playwrightUnavailableNoticeAt, askReplyInjectBatcher, remoteInjectWaiters, durableTurnWorker = null, durableTurnWorkerBusy = false;
16832
16824
  var init_turn_runner = __esm(async () => {
16825
+ await init_fork();
16826
+ await init_agents();
16827
+ await init_spawn_subagent();
16828
+ await init_registry();
16829
+ await init_bus();
16833
16830
  init_manager();
16834
16831
  init_constants();
16835
16832
  init_logger();
16836
16833
  init_mcp_config();
16834
+ await init_manager2();
16837
16835
  init_builders();
16836
+ await init_active_rooms();
16838
16837
  init_state();
16839
16838
  init_types2();
16840
16839
  init_attachments();
16840
+ await init_channel_context();
16841
16841
  init_errors();
16842
+ await init_playwright_turn_abort();
16843
+ await init_topic_config();
16844
+ await init_turn_event_stream();
16845
+ await init_turn_session();
16846
+ await init_visual_store();
16847
+ await init_visuals();
16848
+ await init_api_messages();
16849
+ await init_api_topic_brief();
16850
+ await init_api_topics();
16851
+ await init_app_settings();
16852
+ await init_browser_profiles();
16853
+ await init_conversations();
16854
+ await init_runtime_leases();
16855
+ await init_runtime_topic_state();
16856
+ await init_runtime_turn_requests();
16857
+ await init_wiki();
16842
16858
  init_wiki_summary_names();
16843
- await __promiseAll([
16844
- init_fork(),
16845
- init_agents(),
16846
- init_spawn_subagent(),
16847
- init_registry(),
16848
- init_bus(),
16849
- init_manager2(),
16850
- init_active_rooms(),
16851
- init_channel_context(),
16852
- init_playwright_turn_abort(),
16853
- init_topic_config(),
16854
- init_turn_event_stream(),
16855
- init_turn_session(),
16856
- init_visual_store(),
16857
- init_visuals(),
16858
- init_api_messages(),
16859
- init_api_topic_brief(),
16860
- init_api_topics(),
16861
- init_app_settings(),
16862
- init_browser_profiles(),
16863
- init_conversations(),
16864
- init_runtime_leases(),
16865
- init_runtime_topic_state(),
16866
- init_runtime_turn_requests(),
16867
- init_wiki(),
16868
- init_derive()
16869
- ]);
16859
+ await init_derive();
16870
16860
  init_model_catalog();
16871
16861
  init_attachments();
16872
16862
  init_channel_context();
@@ -17672,16 +17662,14 @@ function processOwnerIsAlive(ownerId) {
17672
17662
  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;
17673
17663
  var init_spawn_subagent = __esm(async () => {
17674
17664
  init_common();
17665
+ await init_bus();
17675
17666
  init_logger();
17667
+ await init_api_messages();
17668
+ await init_api_topics();
17669
+ await init_runtime_leases();
17670
+ await init_runtime_turn_requests();
17676
17671
  init_wiki_summary_names();
17677
17672
  init_types();
17678
- await __promiseAll([
17679
- init_bus(),
17680
- init_api_messages(),
17681
- init_api_topics(),
17682
- init_runtime_leases(),
17683
- init_runtime_turn_requests()
17684
- ]);
17685
17673
  defaultSubagentLifecycleHost = {
17686
17674
  storage: {
17687
17675
  getTopic,
@@ -20113,14 +20101,14 @@ function createWikiMcpServer(context, host) {
20113
20101
  if (false) {}
20114
20102
  // ../../packages/core/src/mcp/factories/agent-health.ts
20115
20103
  init_claude_registry();
20104
+ await init_codex_registry();
20116
20105
  init_maestro_registry();
20117
20106
  init_config();
20118
20107
  init_jsonl();
20119
20108
  init_mcp_helpers();
20120
- await init_codex_registry();
20121
20109
  import { spawn as spawn5 } from "child_process";
20122
20110
  import { existsSync as existsSync10, readdirSync as readdirSync3 } from "fs";
20123
- import { join as join10 } from "path";
20111
+ import { join as join11 } from "path";
20124
20112
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
20125
20113
  import { z } from "zod";
20126
20114
  function signalProcessTree(child, signal) {
@@ -20136,7 +20124,7 @@ function signalProcessTree(child, signal) {
20136
20124
  }
20137
20125
  }
20138
20126
  function spawnCapture(cmd, args, timeoutMs, signal, env) {
20139
- return new Promise((resolve7, reject) => {
20127
+ return new Promise((resolve8, reject) => {
20140
20128
  const child = spawn5(cmd, args, {
20141
20129
  env: env ?? process.env,
20142
20130
  stdio: ["ignore", "pipe", "pipe"],
@@ -20194,7 +20182,7 @@ function spawnCapture(cmd, args, timeoutMs, signal, env) {
20194
20182
  if (killTimer)
20195
20183
  clearTimeout(killTimer);
20196
20184
  if (code === 0)
20197
- resolve7({ stdout, stderr });
20185
+ resolve8({ stdout, stderr });
20198
20186
  else
20199
20187
  reject(new Error(stderr.trim() || `${cmd} exited with ${code ?? exitSignal}`));
20200
20188
  });
@@ -20272,11 +20260,11 @@ async function checkMaestro(model, timeoutMs, signal) {
20272
20260
  const remaining = deadline - Date.now();
20273
20261
  if (remaining <= 0)
20274
20262
  throw new Error("timeout");
20275
- const eventResult = await new Promise((resolve7, reject) => {
20263
+ const eventResult = await new Promise((resolve8, reject) => {
20276
20264
  const timeout = setTimeout(() => reject(new Error("timeout")), remaining);
20277
20265
  const onAbort = () => reject(new Error("aborted"));
20278
20266
  signal.addEventListener("abort", onAbort, { once: true });
20279
- activeIterator.next().then(resolve7, reject).finally(() => {
20267
+ activeIterator.next().then(resolve8, reject).finally(() => {
20280
20268
  clearTimeout(timeout);
20281
20269
  signal.removeEventListener("abort", onAbort);
20282
20270
  });
@@ -20315,7 +20303,7 @@ var checkWaiters = [];
20315
20303
  var activeCheckAllUsers = new Set;
20316
20304
  async function withCheckSlot(operation) {
20317
20305
  if (activeChecks >= MAX_CONCURRENT_CHECKS) {
20318
- await new Promise((resolve7) => checkWaiters.push(resolve7));
20306
+ await new Promise((resolve8) => checkWaiters.push(resolve8));
20319
20307
  }
20320
20308
  activeChecks += 1;
20321
20309
  try {
@@ -20373,7 +20361,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
20373
20361
  server.tool("list_active_queries", "\uD604\uC7AC \uC0AC\uC6A9\uC790 \uBC94\uC704\uC5D0\uC11C \uC2E4\uD589 \uC911\uC778 \uD1A0\uD53D \uCFFC\uB9AC \uBAA9\uB85D\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4.", {}, async () => {
20374
20362
  if (!context.userId)
20375
20363
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
20376
- const stateDir = join10(USERS_LOG_DIR, context.userId, "active-queries");
20364
+ const stateDir = join11(USERS_LOG_DIR, context.userId, "active-queries");
20377
20365
  if (!existsSync10(stateDir))
20378
20366
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
20379
20367
  let files;
@@ -20386,7 +20374,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
20386
20374
  const entries = files.flatMap((file) => {
20387
20375
  if (!file.endsWith(".json"))
20388
20376
  return [];
20389
- const state = readJsonFile(join10(stateDir, file));
20377
+ const state = readJsonFile(join11(stateDir, file));
20390
20378
  if (!state)
20391
20379
  return [];
20392
20380
  const sinceMs = new Date(state.since).getTime();
@@ -20518,10 +20506,8 @@ import { McpServer as McpServer3 } from "@modelcontextprotocol/sdk/server/mcp.js
20518
20506
  import { z as z5 } from "zod";
20519
20507
 
20520
20508
  // ../../packages/core/src/mcp/session-comm/tell-permissions.ts
20521
- await __promiseAll([
20522
- init_spawn_subagent(),
20523
- init_api_topics()
20524
- ]);
20509
+ await init_spawn_subagent();
20510
+ await init_api_topics();
20525
20511
  function resolveSubagentTellIdentity(currentTopicId, assertedParentTopicId) {
20526
20512
  const record = currentTopicId ? getTopic(currentTopicId) : undefined;
20527
20513
  const identityInvalid = Boolean(assertedParentTopicId && (!record?.isSubagent || record.parentTopicId !== assertedParentTopicId)) || Boolean(record?.isSubagent && !record.parentTopicId);
@@ -20739,8 +20725,8 @@ function createSystemHealthMcpServer(host = defaultSystemHealthMcpHost) {
20739
20725
  return server;
20740
20726
  }
20741
20727
  // ../../packages/core/src/mcp/factories/task.ts
20742
- init_mcp_helpers();
20743
20728
  await init_tasks();
20729
+ init_mcp_helpers();
20744
20730
  import { McpServer as McpServer5 } from "@modelcontextprotocol/sdk/server/mcp.js";
20745
20731
  import { z as z6 } from "zod";
20746
20732
  var defaultTaskMcpHost = {
@@ -21037,4 +21023,4 @@ export {
21037
21023
  createAgentHealthMcpServer
21038
21024
  };
21039
21025
 
21040
- //# debugId=1EA78260283E3CD164756E2164756E21
21026
+ //# debugId=A90B1B771901C15064756E2164756E21