negotium 0.1.45 → 0.1.47

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 (54) hide show
  1. package/dist/agent-helpers.js +372 -266
  2. package/dist/agent-helpers.js.map +9 -9
  3. package/dist/background-bash.js.map +2 -2
  4. package/dist/browser-runtime.js +2 -18
  5. package/dist/browser-runtime.js.map +4 -4
  6. package/dist/canonical-mcp-bridge.js +1 -1
  7. package/dist/{chunk-s2gez3wg.js → chunk-r0xs3t81.js} +3 -18
  8. package/dist/{chunk-s2gez3wg.js.map → chunk-r0xs3t81.js.map} +2 -2
  9. package/dist/{chunk-c1bycsm0.js → chunk-x8dze1pj.js} +3 -18
  10. package/dist/{chunk-c1bycsm0.js.map → chunk-x8dze1pj.js.map} +4 -4
  11. package/dist/hosted-agent.js +16 -4
  12. package/dist/hosted-agent.js.map +6 -6
  13. package/dist/main.js +2154 -863
  14. package/dist/main.js.map +30 -27
  15. package/dist/mcp-catalog.js.map +1 -1
  16. package/dist/mcp-factories.js +334 -234
  17. package/dist/mcp-factories.js.map +9 -9
  18. package/dist/outbox.js +1 -1
  19. package/dist/outbox.js.map +3 -3
  20. package/dist/platform-runtime.js.map +1 -1
  21. package/dist/prompts.js.map +2 -2
  22. package/dist/query-runtime.js +2 -18
  23. package/dist/query-runtime.js.map +4 -4
  24. package/dist/registry.js +3 -4
  25. package/dist/registry.js.map +4 -4
  26. package/dist/rollout.js +1 -1
  27. package/dist/runtime/src/agents/maestro-provider.ts +35 -0
  28. package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +16 -1
  29. package/dist/runtime/src/index.ts +4 -1
  30. package/dist/runtime/src/mcp/background-bash-server.ts +170 -37
  31. package/dist/runtime/src/platform/background-bash/output-buffer.ts +323 -0
  32. package/dist/runtime/src/platform/jsonl.ts +62 -14
  33. package/dist/runtime/src/runtime/inbox.ts +60 -3
  34. package/dist/runtime/src/storage/activity-log.ts +7 -1
  35. package/dist/runtime/src/storage/conversations.ts +36 -3
  36. package/dist/runtime/src/storage/storage-host.ts +8 -1
  37. package/dist/runtime/src/topics/session.ts +13 -17
  38. package/dist/runtime/src/types.ts +29 -0
  39. package/dist/runtime/src/version.ts +1 -1
  40. package/dist/runtime-helpers.js +27 -26
  41. package/dist/runtime-helpers.js.map +5 -5
  42. package/dist/sqlite.js +1 -17
  43. package/dist/sqlite.js.map +2 -2
  44. package/dist/storage.js +61 -31
  45. package/dist/storage.js.map +7 -7
  46. package/dist/types/packages/core/src/agents/maestro-provider.d.ts +7 -0
  47. package/dist/types/packages/core/src/platform/jsonl.d.ts +11 -0
  48. package/dist/types/packages/core/src/storage/conversations.d.ts +16 -2
  49. package/dist/types/packages/core/src/types.d.ts +29 -0
  50. package/dist/types/packages/core/src/version.d.ts +1 -1
  51. package/dist/vault.js +1 -17
  52. package/dist/vault.js.map +3 -3
  53. package/package.json +3 -3
  54. package/dist/runtime/src/query/control.ts +0 -313
@@ -1,30 +1,20 @@
1
1
  // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
2
  var __defProp = Object.defineProperty;
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
- };
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
18
7
  var __export = (target, all) => {
19
8
  for (var name in all)
20
9
  __defProp(target, name, {
21
10
  get: all[name],
22
11
  enumerable: true,
23
12
  configurable: true,
24
- set: (newValue) => all[name] = () => newValue
13
+ set: __exportSetter.bind(all, name)
25
14
  });
26
15
  };
27
16
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
+ var __promiseAll = (args) => Promise.all(args);
28
18
  var __require = import.meta.require;
29
19
 
30
20
  // ../../packages/core/src/platform/config-helpers.ts
@@ -559,6 +549,13 @@ function parseJsonlText(raw) {
559
549
  return raw.trim().split(`
560
550
  `).filter(Boolean).map((line) => JSON.parse(line));
561
551
  }
552
+ function lockStaleMs() {
553
+ const raw = Number.parseInt(process.env.NEGOTIUM_JSONL_LOCK_STALE_MS ?? "", 10);
554
+ return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_LOCK_STALE_MS;
555
+ }
556
+ function lockTimeoutMs() {
557
+ return lockStaleMs() + LOCK_TIMEOUT_HEADROOM_MS;
558
+ }
562
559
  function sleepForAppendLock(ms) {
563
560
  Atomics.wait(LOCK_SLEEP, 0, 0, ms);
564
561
  }
@@ -574,7 +571,7 @@ function tryAcquireAppendLock(lockPath) {
574
571
  }
575
572
  function isStaleLock(lockPath) {
576
573
  try {
577
- return Date.now() - statSync(lockPath).mtimeMs > LOCK_STALE_MS;
574
+ return Date.now() - statSync(lockPath).mtimeMs > lockStaleMs();
578
575
  } catch {
579
576
  return false;
580
577
  }
@@ -596,7 +593,8 @@ function appendJsonlLine(filePath, line) {
596
593
  }
597
594
  if (!acquired) {
598
595
  const start = Date.now();
599
- while (!acquired && Date.now() - start < LOCK_TIMEOUT_MS) {
596
+ const timeoutMs = lockTimeoutMs();
597
+ while (!acquired && Date.now() - start < timeoutMs) {
600
598
  sleepForAppendLock(LOCK_RETRY_MS);
601
599
  acquired = tryAcquireAppendLock(lockPath);
602
600
  if (!acquired && isStaleLock(lockPath)) {
@@ -605,10 +603,8 @@ function appendJsonlLine(filePath, line) {
605
603
  }
606
604
  }
607
605
  }
608
- if (!acquired) {
609
- appendFileSync(filePath, payload);
610
- return;
611
- }
606
+ if (!acquired)
607
+ throw new JsonlLockTimeoutError(filePath, lockTimeoutMs());
612
608
  try {
613
609
  appendFileSync(filePath, payload);
614
610
  } finally {
@@ -656,10 +652,20 @@ function fsyncDirectoryBestEffort(dir) {
656
652
  }
657
653
  }
658
654
  }
659
- var LOCK_SUFFIX = ".lock", LOCK_RETRY_MS = 5, LOCK_TIMEOUT_MS = 1500, LOCK_STALE_MS = 5000, LOCK_SLEEP;
655
+ var LOCK_SUFFIX = ".lock", LOCK_RETRY_MS = 5, DEFAULT_LOCK_STALE_MS = 5000, LOCK_TIMEOUT_HEADROOM_MS = 1500, LOCK_SLEEP, JsonlLockTimeoutError;
660
656
  var init_jsonl = __esm(() => {
661
657
  init_file_utils();
662
658
  LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
659
+ JsonlLockTimeoutError = class JsonlLockTimeoutError extends Error {
660
+ filePath;
661
+ timeoutMs;
662
+ constructor(filePath, timeoutMs) {
663
+ super(`jsonl append lock busy after ${timeoutMs}ms; nothing written to ${filePath}`);
664
+ this.filePath = filePath;
665
+ this.timeoutMs = timeoutMs;
666
+ this.name = "JsonlLockTimeoutError";
667
+ }
668
+ };
663
669
  });
664
670
 
665
671
  // ../../packages/core/src/agents/rollout/claude.ts
@@ -2000,8 +2006,8 @@ function redactVaultSecrets(userId, text) {
2000
2006
  var vaultDb, vaultMasterKey, VAULT_VALUE_MAX_BYTES;
2001
2007
  var init_vault = __esm(async () => {
2002
2008
  init_config();
2003
- await init_sqlite();
2004
2009
  init_vault_crypto();
2010
+ await init_sqlite();
2005
2011
  vaultMasterKey = VAULT_MASTER_KEY;
2006
2012
  VAULT_VALUE_MAX_BYTES = 64 * 1024;
2007
2013
  });
@@ -2598,10 +2604,10 @@ async function* claudeProvider(opts) {
2598
2604
  var CLAUDE_DEFAULT_DISALLOWED_TOOLS, CLAUDE_NATIVE_AGENT_TOOLS, CLAUDE_IMAGE_MAX_BYTES, CLAUDE_IMAGE_MIME_TYPES, CLAUDE_ABORT_SIGKILL_DELAY_MS = 2500;
2599
2605
  var init_claude_provider = __esm(async () => {
2600
2606
  init_claude_registry();
2601
- await init_execution_host();
2602
2607
  init_vault_tool_policy();
2603
2608
  init_file_events();
2604
2609
  init_logger();
2610
+ await init_execution_host();
2605
2611
  CLAUDE_DEFAULT_DISALLOWED_TOOLS = [
2606
2612
  "AskUserQuestion",
2607
2613
  "Workflow",
@@ -2622,7 +2628,7 @@ var init_claude_provider = __esm(async () => {
2622
2628
  });
2623
2629
 
2624
2630
  // ../../packages/core/src/version.ts
2625
- var NEGOTIUM_VERSION = "0.1.45";
2631
+ var NEGOTIUM_VERSION = "0.1.47";
2626
2632
 
2627
2633
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
2628
2634
  import { spawn as spawn3 } from "child_process";
@@ -4718,12 +4724,12 @@ var CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_
4718
4724
  var init_codex_provider = __esm(async () => {
4719
4725
  init_codex_native_multi_agent();
4720
4726
  init_codex_tree_kill();
4721
- await init_execution_host();
4722
4727
  init_codex();
4723
4728
  init_tool_format();
4724
4729
  init_file_events();
4725
4730
  init_logger();
4726
4731
  init_mcp_config();
4732
+ await init_execution_host();
4727
4733
  CODEX_MCP_SERVER_NAME_OVERRIDES = {
4728
4734
  playwright: "otium_playwright"
4729
4735
  };
@@ -4737,6 +4743,7 @@ var init_maestro_bootstrap_env = __esm(() => {
4737
4743
  });
4738
4744
 
4739
4745
  // ../../packages/core/src/agents/maestro-provider.ts
4746
+ import { resolve as resolve7 } from "path";
4740
4747
  import { maestroProvider as sdkMaestroProvider, setMcpResolver } from "maestro-agent-sdk";
4741
4748
  function buildMaestroDisallowedTools(callerDisallowedTools = [], toolPolicy) {
4742
4749
  return [
@@ -4801,6 +4808,16 @@ function buildProviderOwnedToolBlockHook() {
4801
4808
  }
4802
4809
  };
4803
4810
  }
4811
+ function buildMaestroToolResultTruncation(opts) {
4812
+ if (opts.toolResultTruncation)
4813
+ return opts.toolResultTruncation;
4814
+ return {
4815
+ enabled: true,
4816
+ saveFullOutput: true,
4817
+ outputDir: MAESTRO_TOOL_OUTPUT_DIR,
4818
+ ignoreTools: ["ReadToolOutput"]
4819
+ };
4820
+ }
4804
4821
  function maestroProvider(opts) {
4805
4822
  if (opts.agent !== undefined && opts.agent !== "maestro") {
4806
4823
  throw new Error(`maestroProvider: unexpected agent "${opts.agent}", expected "maestro"`);
@@ -4813,6 +4830,7 @@ function maestroProvider(opts) {
4813
4830
  maxTokens: MAESTRO_DEFAULT_MAX_TOKENS,
4814
4831
  ...opts,
4815
4832
  enableToolSearch: !opts.toolPolicy && opts.enableToolSearch !== false,
4833
+ toolResultTruncation: buildMaestroToolResultTruncation(opts),
4816
4834
  apiKeyOverrides: resolveMaestroApiKeyOverrides(userId),
4817
4835
  agent: "maestro",
4818
4836
  disallowedTools: buildMaestroDisallowedTools(callerDisallowedTools, opts.toolPolicy),
@@ -4820,12 +4838,15 @@ function maestroProvider(opts) {
4820
4838
  };
4821
4839
  return sdkMaestroProvider(sdkOpts);
4822
4840
  }
4823
- 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;
4841
+ 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;
4824
4842
  var init_maestro_provider = __esm(async () => {
4825
4843
  init_maestro_bootstrap_env();
4826
- await init_execution_host();
4827
4844
  init_vault_tool_policy();
4828
- await init_vault();
4845
+ init_config();
4846
+ await __promiseAll([
4847
+ init_execution_host(),
4848
+ init_vault()
4849
+ ]);
4829
4850
  MAESTRO_NATIVE_TASK_TOOLS = [
4830
4851
  "TaskCreate",
4831
4852
  "TaskUpdate",
@@ -4857,6 +4878,7 @@ var init_maestro_provider = __esm(async () => {
4857
4878
  "ToolSearch",
4858
4879
  ...DEFAULT_MAESTRO_DISALLOWED_TOOLS
4859
4880
  ];
4881
+ MAESTRO_TOOL_OUTPUT_DIR = resolve7(RUN_DIR, "maestro-tool-outputs");
4860
4882
  });
4861
4883
 
4862
4884
  // ../../packages/core/src/security/sanitize.ts
@@ -4877,10 +4899,10 @@ function sanitizeId(id) {
4877
4899
  // ../../packages/core/src/storage/storage-host.ts
4878
4900
  import { mkdirSync as mkdirSync6 } from "fs";
4879
4901
  import { homedir as homedir5 } from "os";
4880
- import { dirname as dirname7, join as join9, resolve as resolve7 } from "path";
4902
+ import { dirname as dirname7, join as join9, resolve as resolve8 } from "path";
4881
4903
  function envPath(name, fallback) {
4882
4904
  const value = process.env[name]?.trim();
4883
- return resolve7(value || fallback);
4905
+ return resolve8(value || fallback);
4884
4906
  }
4885
4907
  function defaultStateDir() {
4886
4908
  return envPath("NEGOTIUM_STATE_DIR", join9(homedir5(), ".negotium"));
@@ -4902,9 +4924,9 @@ function defaultSessionsDatabasePath() {
4902
4924
  return envPath("SESSIONS_DB_PATH", join9(resolveStorageDataDir(), "sessions.db"));
4903
4925
  }
4904
4926
  function initializeDatabase(database) {
4927
+ database.exec("PRAGMA busy_timeout = 5000");
4905
4928
  database.exec("PRAGMA journal_mode = WAL");
4906
4929
  database.exec("PRAGMA foreign_keys = ON");
4907
- database.exec("PRAGMA busy_timeout = 5000");
4908
4930
  database.exec("PRAGMA wal_autocheckpoint = 1000");
4909
4931
  try {
4910
4932
  database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
@@ -5045,8 +5067,13 @@ function appendConversationEventStrict(userId, topicName, agent, event) {
5045
5067
  mkdirSync7(dirname8(path), { recursive: true });
5046
5068
  appendJsonlLine(path, line);
5047
5069
  const activePath = getActiveConversationPath(userId, topicName);
5048
- if (existsSync8(activePath))
5049
- appendJsonlLine(activePath, line);
5070
+ if (existsSync8(activePath)) {
5071
+ try {
5072
+ appendJsonlLine(activePath, line);
5073
+ } catch (cause) {
5074
+ throw new ConversationLogDivergedError(path, activePath, cause);
5075
+ }
5076
+ }
5050
5077
  }
5051
5078
  function readConversationPath(path) {
5052
5079
  const out = [];
@@ -5110,10 +5137,23 @@ function findLastSessionIdForAgent(entries, agent) {
5110
5137
  }
5111
5138
  return null;
5112
5139
  }
5140
+ var ConversationLogDivergedError;
5113
5141
  var init_conversations = __esm(async () => {
5114
5142
  init_jsonl();
5115
5143
  init_logger();
5116
5144
  await init_storage_host();
5145
+ ConversationLogDivergedError = class ConversationLogDivergedError extends Error {
5146
+ rawPath;
5147
+ activePath;
5148
+ cause;
5149
+ constructor(rawPath, activePath, cause) {
5150
+ super(`conversation logs diverged: the entry is in the raw manifest (${rawPath}) ` + `but the active projection (${activePath}) rejected it`);
5151
+ this.rawPath = rawPath;
5152
+ this.activePath = activePath;
5153
+ this.cause = cause;
5154
+ this.name = "ConversationLogDivergedError";
5155
+ }
5156
+ };
5117
5157
  });
5118
5158
 
5119
5159
  // ../../packages/core/src/agents/codex-registry.ts
@@ -5124,8 +5164,8 @@ var VALID_EFFORTS2, codexRegistry;
5124
5164
  var init_codex_registry = __esm(async () => {
5125
5165
  init_codex();
5126
5166
  init_logger();
5127
- await init_conversations();
5128
5167
  init_types();
5168
+ await init_conversations();
5129
5169
  VALID_EFFORTS2 = new Set(CODEX_EFFORT_VALUES);
5130
5170
  codexRegistry = {
5131
5171
  kind: "codex",
@@ -5252,8 +5292,10 @@ function getRegistry(agent) {
5252
5292
  var REGISTRIES;
5253
5293
  var init_registry = __esm(async () => {
5254
5294
  init_claude_registry();
5255
- await init_codex_registry();
5256
- await init_maestro_registry();
5295
+ await __promiseAll([
5296
+ init_codex_registry(),
5297
+ init_maestro_registry()
5298
+ ]);
5257
5299
  REGISTRIES = {
5258
5300
  claude: claudeRegistry,
5259
5301
  codex: codexRegistry,
@@ -5448,15 +5490,17 @@ async function* runAgent(opts) {
5448
5490
  }
5449
5491
  }
5450
5492
  var init_agents = __esm(async () => {
5451
- await init_claude_provider();
5452
- await init_codex_provider();
5453
- await init_maestro_provider();
5454
- await init_registry();
5455
5493
  init_claude();
5456
- await init_task_events();
5457
5494
  init_logger();
5458
- await init_conversations();
5459
5495
  init_types();
5496
+ await __promiseAll([
5497
+ init_claude_provider(),
5498
+ init_codex_provider(),
5499
+ init_maestro_provider(),
5500
+ init_registry(),
5501
+ init_task_events(),
5502
+ init_conversations()
5503
+ ]);
5460
5504
  });
5461
5505
 
5462
5506
  // ../../packages/core/src/storage/forum-db.ts
@@ -5900,9 +5944,9 @@ var init_model_catalog = __esm(() => {
5900
5944
 
5901
5945
  // ../../packages/core/src/prompts/builders.ts
5902
5946
  import { readFileSync as readFileSync11 } from "fs";
5903
- import { resolve as resolve8 } from "path";
5947
+ import { resolve as resolve9 } from "path";
5904
5948
  function loadPrompt(filename, dir = SESSIONS_DIR) {
5905
- const raw = readFileSync11(resolve8(dir, filename), "utf-8");
5949
+ const raw = readFileSync11(resolve9(dir, filename), "utf-8");
5906
5950
  return raw.replace(/\{\{RESOURCES_DIR\}\}/g, RESOURCES_DIR);
5907
5951
  }
5908
5952
  function replaceVars(template, vars) {
@@ -5951,7 +5995,7 @@ function visualDesignGuide() {
5951
5995
  return _visualDesignGuide;
5952
5996
  }
5953
5997
  function loadAgentPrompt(filename) {
5954
- const raw = readFileSync11(resolve8(AGENTS_PROMPTS_DIR, filename), "utf-8");
5998
+ const raw = readFileSync11(resolve9(AGENTS_PROMPTS_DIR, filename), "utf-8");
5955
5999
  const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
5956
6000
  if (!match)
5957
6001
  throw new Error(`Agent prompt ${filename} is missing frontmatter`);
@@ -6261,8 +6305,8 @@ var init_builders = __esm(() => {
6261
6305
  init_model_catalog();
6262
6306
  init_config();
6263
6307
  init_logger();
6264
- PROMPTS_DIR = resolve8(PROJECT_ROOT, "src/prompts");
6265
- SESSIONS_DIR = resolve8(PROMPTS_DIR, "sessions");
6308
+ PROMPTS_DIR = resolve9(PROJECT_ROOT, "src/prompts");
6309
+ SESSIONS_DIR = resolve9(PROMPTS_DIR, "sessions");
6266
6310
  defaultPromptBuilders = createPromptBuilders();
6267
6311
  buildTopicSystemPrompt = defaultPromptBuilders.buildTopicSystemPrompt;
6268
6312
  buildChannelSystemPrompt = defaultPromptBuilders.buildChannelSystemPrompt;
@@ -6505,8 +6549,10 @@ function getMessagesForTopicAfterRowid(topicId, afterRowid) {
6505
6549
  }
6506
6550
  var appendHooks;
6507
6551
  var init_api_messages = __esm(async () => {
6508
- await init_forum_db();
6509
- await init_storage_host();
6552
+ await __promiseAll([
6553
+ init_forum_db(),
6554
+ init_storage_host()
6555
+ ]);
6510
6556
  registerStorageSchemaInitializer(initializeApiMessagesSchema, 30);
6511
6557
  appendHooks = new Set;
6512
6558
  });
@@ -6596,9 +6642,11 @@ function deleteTopicBrief(topicId) {
6596
6642
  db.query("DELETE FROM api_topic_brief WHERE topic_id = ?").run(topicId);
6597
6643
  }
6598
6644
  var init_api_topic_brief = __esm(async () => {
6599
- await init_forum_db();
6600
- await init_storage_host();
6601
6645
  init_wiki_summary_names();
6646
+ await __promiseAll([
6647
+ init_forum_db(),
6648
+ init_storage_host()
6649
+ ]);
6602
6650
  registerStorageSchemaInitializer((database) => {
6603
6651
  database.exec(`
6604
6652
  CREATE TABLE IF NOT EXISTS api_topic_brief (
@@ -6743,8 +6791,10 @@ function deleteApiTopicConfig(topicId) {
6743
6791
  db.query("DELETE FROM api_topic_config WHERE topic_id = ?").run(topicId);
6744
6792
  }
6745
6793
  var init_api_topic_config = __esm(async () => {
6746
- await init_forum_db();
6747
- await init_storage_host();
6794
+ await __promiseAll([
6795
+ init_forum_db(),
6796
+ init_storage_host()
6797
+ ]);
6748
6798
  registerStorageSchemaInitializer(initializeApiTopicConfigSchema, 40);
6749
6799
  });
6750
6800
 
@@ -7297,8 +7347,10 @@ var DEFAULT_AGENT_ROOM_AGENT = "maestro";
7297
7347
  var init_api_topics = __esm(async () => {
7298
7348
  init_constants();
7299
7349
  init_logger();
7300
- await init_forum_db();
7301
- await init_storage_host();
7350
+ await __promiseAll([
7351
+ init_forum_db(),
7352
+ init_storage_host()
7353
+ ]);
7302
7354
  registerStorageSchemaInitializer(initializeApiTopicsSchema, 20);
7303
7355
  });
7304
7356
 
@@ -7341,11 +7393,13 @@ function isLegacySharedGeneral(topicId) {
7341
7393
  }
7342
7394
  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.";
7343
7395
  var init_personal_general = __esm(async () => {
7344
- await init_registry();
7345
7396
  init_config();
7346
7397
  init_constants();
7347
- await init_api_topic_config();
7348
- await init_api_topics();
7398
+ await __promiseAll([
7399
+ init_registry(),
7400
+ init_api_topic_config(),
7401
+ init_api_topics()
7402
+ ]);
7349
7403
  });
7350
7404
 
7351
7405
  // ../../packages/core/src/agents/archiver.ts
@@ -7679,17 +7733,19 @@ function runArchiverTurn(params) {
7679
7733
  }
7680
7734
  var MAX_BRIEF_ENTRIES = 8, defaultArchiverRuntime;
7681
7735
  var init_archiver = __esm(async () => {
7682
- await init_agents();
7683
- await init_bus();
7684
7736
  init_config();
7685
7737
  init_logger();
7686
7738
  init_builders();
7687
7739
  init_background_session_policy();
7688
- await init_api_messages();
7689
- await init_api_topic_brief();
7690
- await init_wiki();
7691
7740
  init_wiki_summary_names();
7692
- await init_personal_general();
7741
+ await __promiseAll([
7742
+ init_agents(),
7743
+ init_bus(),
7744
+ init_api_messages(),
7745
+ init_api_topic_brief(),
7746
+ init_wiki(),
7747
+ init_personal_general()
7748
+ ]);
7693
7749
  defaultArchiverRuntime = createArchiverRuntime({
7694
7750
  storage: {
7695
7751
  getWikiDir: getSharedWikiDir,
@@ -7859,8 +7915,8 @@ function cleanupAgentFork(handle) {
7859
7915
  }
7860
7916
  var defaultForkHelpers;
7861
7917
  var init_fork = __esm(async () => {
7862
- await init_registry();
7863
7918
  init_logger();
7919
+ await init_registry();
7864
7920
  defaultForkHelpers = createAgentForkHelpers({
7865
7921
  forkSession: (agent, options) => getRegistry(agent).forkSession(options),
7866
7922
  exists: existsSync15,
@@ -7972,8 +8028,10 @@ function beginRuntimeTopicMaintenance(topicId, options = {}) {
7972
8028
  }
7973
8029
  var TOPIC_MAINTENANCE_STALE_MS = 30000, TOPIC_MAINTENANCE_HEARTBEAT_MS = 1000;
7974
8030
  var init_runtime_topic_state = __esm(async () => {
7975
- await init_forum_db();
7976
- await init_storage_host();
8031
+ await __promiseAll([
8032
+ init_forum_db(),
8033
+ init_storage_host()
8034
+ ]);
7977
8035
  registerStorageSchemaInitializer((database) => {
7978
8036
  database.exec(`
7979
8037
  CREATE TABLE IF NOT EXISTS runtime_topic_state (
@@ -8070,9 +8128,11 @@ function releaseRuntimeTurnLease(topicId, queryId, ownerId = RUNTIME_INSTANCE_ID
8070
8128
  }
8071
8129
  var RUNTIME_INSTANCE_ID, TURN_LEASE_STALE_MS = 1e4;
8072
8130
  var init_runtime_leases = __esm(async () => {
8073
- await init_forum_db();
8074
- await init_runtime_topic_state();
8075
- await init_storage_host();
8131
+ await __promiseAll([
8132
+ init_forum_db(),
8133
+ init_runtime_topic_state(),
8134
+ init_storage_host()
8135
+ ]);
8076
8136
  RUNTIME_INSTANCE_ID = `${process.pid}-${randomUUID7()}`;
8077
8137
  registerStorageSchemaInitializer((database) => {
8078
8138
  database.exec(`
@@ -8438,8 +8498,8 @@ function wsAbortReason(reason) {
8438
8498
  var roomQueryRegistry, interSessionQueue;
8439
8499
  var init_active_rooms = __esm(async () => {
8440
8500
  init_logger();
8441
- await init_runtime_leases();
8442
8501
  init_types2();
8502
+ await init_runtime_leases();
8443
8503
  roomQueryRegistry = createRoomQueryRegistry({
8444
8504
  instanceId: RUNTIME_INSTANCE_ID,
8445
8505
  internalAbortReason: "internal" /* Internal */,
@@ -8618,9 +8678,11 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
8618
8678
  }
8619
8679
  var init_topic_archive = __esm(async () => {
8620
8680
  init_logger();
8621
- await init_api_messages();
8622
- await init_conversations();
8623
- await init_wiki();
8681
+ await __promiseAll([
8682
+ init_api_messages(),
8683
+ init_conversations(),
8684
+ init_wiki()
8685
+ ]);
8624
8686
  });
8625
8687
 
8626
8688
  // ../../packages/core/src/storage/topic-archive-state.ts
@@ -8733,8 +8795,10 @@ function deleteTopicArchiveState(topicId) {
8733
8795
  }
8734
8796
  var ARCHIVE_JOB_STALE_MS;
8735
8797
  var init_topic_archive_state = __esm(async () => {
8736
- await init_forum_db();
8737
- await init_storage_host();
8798
+ await __promiseAll([
8799
+ init_forum_db(),
8800
+ init_storage_host()
8801
+ ]);
8738
8802
  registerStorageSchemaInitializer((database) => {
8739
8803
  database.exec(`
8740
8804
  CREATE TABLE IF NOT EXISTS api_topic_archive_state (
@@ -8909,13 +8973,15 @@ function archiveActiveTopicForMemory(topicId, userId, options) {
8909
8973
  }
8910
8974
  var DEFAULT_IDLE_DELAY_MS, DEFAULT_MIN_MESSAGES = 8, timers;
8911
8975
  var init_idle_archiver = __esm(async () => {
8912
- await init_archiver();
8913
8976
  init_logger();
8914
- await init_active_rooms();
8915
- await init_api_messages();
8916
- await init_api_topics();
8917
- await init_topic_archive();
8918
- await init_topic_archive_state();
8977
+ await __promiseAll([
8978
+ init_archiver(),
8979
+ init_active_rooms(),
8980
+ init_api_messages(),
8981
+ init_api_topics(),
8982
+ init_topic_archive(),
8983
+ init_topic_archive_state()
8984
+ ]);
8919
8985
  DEFAULT_IDLE_DELAY_MS = 6 * 60 * 60 * 1000;
8920
8986
  timers = new Map;
8921
8987
  });
@@ -9130,8 +9196,10 @@ function cancelAskUserGate(topicId, messageId, ownerId, now = new Date().toISOSt
9130
9196
  }).immediate();
9131
9197
  }
9132
9198
  var init_ask_user_gates = __esm(async () => {
9133
- await init_forum_db();
9134
- await init_storage_host();
9199
+ await __promiseAll([
9200
+ init_forum_db(),
9201
+ init_storage_host()
9202
+ ]);
9135
9203
  registerStorageSchemaInitializer(initializeAskUserGateSchema, 31);
9136
9204
  });
9137
9205
 
@@ -9250,9 +9318,11 @@ function acquireRuntimeProcessLease(role, options = {}) {
9250
9318
  }
9251
9319
  var PROCESS_LEASE_STALE_MS = 5000, PROCESS_LEASE_HEARTBEAT_MS = 1000;
9252
9320
  var init_runtime_process_leases = __esm(async () => {
9253
- await init_forum_db();
9254
- await init_runtime_leases();
9255
- await init_storage_host();
9321
+ await __promiseAll([
9322
+ init_forum_db(),
9323
+ init_runtime_leases(),
9324
+ init_storage_host()
9325
+ ]);
9256
9326
  registerStorageSchemaInitializer((database) => {
9257
9327
  database.exec(`
9258
9328
  CREATE TABLE IF NOT EXISTS runtime_process_leases (
@@ -9514,8 +9584,8 @@ function createAskUserRuntime(host) {
9514
9584
  return errorResult(`Error: failed to persist ask_user_question: ${error instanceof Error ? error.message : String(error)}`);
9515
9585
  }
9516
9586
  let resolveAnswer;
9517
- const promise = new Promise((resolve9) => {
9518
- resolveAnswer = resolve9;
9587
+ const promise = new Promise((resolve10) => {
9588
+ resolveAnswer = resolve10;
9519
9589
  });
9520
9590
  pendingAsks.set(message.id, {
9521
9591
  topicId: ctx.topicId,
@@ -9570,12 +9640,14 @@ function cancelPendingAskUserQuestions(topicId, queryId) {
9570
9640
  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;
9571
9641
  var init_ask_user = __esm(async () => {
9572
9642
  init_common();
9573
- await init_bus();
9574
- await init_api_messages();
9575
- await init_api_topic_config();
9576
- await init_api_topics();
9577
- await init_ask_user_gates();
9578
- await init_runtime_process_leases();
9643
+ await __promiseAll([
9644
+ init_bus(),
9645
+ init_api_messages(),
9646
+ init_api_topic_config(),
9647
+ init_api_topics(),
9648
+ init_ask_user_gates(),
9649
+ init_runtime_process_leases()
9650
+ ]);
9579
9651
  ASK_GATE_OWNER_ID = `ask-user-${process.pid}-${randomUUID8()}`;
9580
9652
  defaultAskUserDurabilityHost = {
9581
9653
  gates: {
@@ -9680,9 +9752,11 @@ function deleteSelfSchedulesForTopic(topicId) {
9680
9752
  return Number(result.changes ?? 0);
9681
9753
  }
9682
9754
  var init_self_schedules = __esm(async () => {
9683
- await init_forum_db();
9684
- await init_runtime_leases();
9685
- await init_runtime_topic_state();
9755
+ await __promiseAll([
9756
+ init_forum_db(),
9757
+ init_runtime_leases(),
9758
+ init_runtime_topic_state()
9759
+ ]);
9686
9760
  db.exec(`
9687
9761
  CREATE TABLE IF NOT EXISTS runtime_self_schedules (
9688
9762
  id TEXT PRIMARY KEY,
@@ -9767,7 +9841,7 @@ var init_manager_utils = () => {};
9767
9841
  import { execFileSync as execFileSync6 } from "child_process";
9768
9842
  import { readdirSync as readdirSync3, unlinkSync as unlinkSync10 } from "fs";
9769
9843
  import { createServer } from "net";
9770
- import { resolve as resolve9, sep } from "path";
9844
+ import { resolve as resolve10, sep } from "path";
9771
9845
  function isPortInUse(port) {
9772
9846
  return new Promise((resolveProbe) => {
9773
9847
  const server = createServer();
@@ -9800,8 +9874,8 @@ async function reserveAvailableLoopbackPort(minPort, maxPort, reservedPorts, pro
9800
9874
  return null;
9801
9875
  }
9802
9876
  function killBrowserProcsForUserDataDir(userDataDir) {
9803
- const target = resolve9(userDataDir);
9804
- const profileRoot = resolve9(BROWSER_PROFILES_DIR);
9877
+ const target = resolve10(userDataDir);
9878
+ const profileRoot = resolve10(BROWSER_PROFILES_DIR);
9805
9879
  if (target !== profileRoot && !target.startsWith(`${profileRoot}${sep}`))
9806
9880
  return;
9807
9881
  let pids;
@@ -9822,7 +9896,7 @@ function killBrowserProcsForUserDataDir(userDataDir) {
9822
9896
  stdio: "pipe"
9823
9897
  }).toString().trim();
9824
9898
  const argDir = extractUserDataDirArg(cmdline);
9825
- if (!argDir || resolve9(argDir) !== target)
9899
+ if (!argDir || resolve10(argDir) !== target)
9826
9900
  continue;
9827
9901
  killProcessTreeChildren(pidNum);
9828
9902
  process.kill(pidNum, "SIGKILL");
@@ -9833,13 +9907,13 @@ function killBrowserProcsForUserDataDir(userDataDir) {
9833
9907
  }
9834
9908
  }
9835
9909
  function selectOrphanBrowserPids(procs, liveUserDataDirs, profileRoot, selfPid) {
9836
- const root = resolve9(profileRoot);
9837
- const live = new Set([...liveUserDataDirs].map((d) => resolve9(d)));
9910
+ const root = resolve10(profileRoot);
9911
+ const live = new Set([...liveUserDataDirs].map((d) => resolve10(d)));
9838
9912
  const out = [];
9839
9913
  for (const { pid, userDataDir } of procs) {
9840
9914
  if (pid === selfPid || !userDataDir)
9841
9915
  continue;
9842
- const dir = resolve9(userDataDir);
9916
+ const dir = resolve10(userDataDir);
9843
9917
  if (dir !== root && !dir.startsWith(`${root}${sep}`))
9844
9918
  continue;
9845
9919
  if (live.has(dir))
@@ -9855,7 +9929,7 @@ function reapOrphanBrowsers(liveUserDataDirs) {
9855
9929
  const daemonLease = getRuntimeProcessLease("node-daemon", Date.now(), Number.POSITIVE_INFINITY);
9856
9930
  if (!isBrowserJanitorOwner(daemonLease?.pid ?? null, process.pid))
9857
9931
  return;
9858
- const profileRoot = resolve9(BROWSER_PROFILES_DIR);
9932
+ const profileRoot = resolve10(BROWSER_PROFILES_DIR);
9859
9933
  let pids;
9860
9934
  try {
9861
9935
  pids = execFileSync6("pgrep", ["-f", "--", profileRoot], { stdio: "pipe" }).toString().trim();
@@ -9894,7 +9968,7 @@ function cleanSingletonFiles(userDataDir) {
9894
9968
  for (const f of files) {
9895
9969
  if (f.startsWith("Singleton")) {
9896
9970
  try {
9897
- unlinkSync10(resolve9(userDataDir, f));
9971
+ unlinkSync10(resolve10(userDataDir, f));
9898
9972
  logger.info({ file: f, userDataDir }, "Removed stale Singleton file");
9899
9973
  } catch (e) {
9900
9974
  logger.warn({ err: e, file: f }, "Failed to remove stale Chrome Singleton file");
@@ -9934,9 +10008,9 @@ var init_browser_processes = __esm(async () => {
9934
10008
 
9935
10009
  // ../../packages/core/src/platform/playwright/headed-launch.ts
9936
10010
  import { accessSync as accessSync2, constants as constants2 } from "fs";
9937
- import { delimiter, isAbsolute as isAbsolute3, resolve as resolve10 } from "path";
10011
+ import { delimiter, isAbsolute as isAbsolute3, resolve as resolve11 } from "path";
9938
10012
  function findExecutableOnPath(command, environment = process.env) {
9939
- const candidates = isAbsolute3(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve10(directory, command));
10013
+ const candidates = isAbsolute3(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve11(directory, command));
9940
10014
  for (const candidate of candidates) {
9941
10015
  try {
9942
10016
  accessSync2(candidate, constants2.X_OK);
@@ -10097,7 +10171,7 @@ import {
10097
10171
  unlinkSync as unlinkSync11,
10098
10172
  writeFileSync as writeFileSync8
10099
10173
  } from "fs";
10100
- import { dirname as dirname11, join as join18, resolve as resolve11 } from "path";
10174
+ import { dirname as dirname11, join as join18, resolve as resolve12 } from "path";
10101
10175
  function makeInstanceKey(userId, topic) {
10102
10176
  return resolvePlaywrightTopicBinding(userId, topic).instanceKey;
10103
10177
  }
@@ -10136,7 +10210,7 @@ function migrateLegacyTopicProfile(ownerId, topic) {
10136
10210
  const current2 = getTopicBrowserProfile(topic);
10137
10211
  if (current2 !== "default" || !hasBrowserProfileTopic(topic))
10138
10212
  return current2;
10139
- const legacyDir = resolve11(BROWSER_PROFILES_DIR, sanitizeTopicName(topic));
10213
+ const legacyDir = resolve12(BROWSER_PROFILES_DIR, sanitizeTopicName(topic));
10140
10214
  if (!existsSync16(legacyDir))
10141
10215
  return current2;
10142
10216
  const profile = legacyBrowserProfileName(topic);
@@ -10311,7 +10385,7 @@ function ownerDirectory(ownerId) {
10311
10385
  return `${sanitizeTopicName(ownerId).slice(0, 24)}_${digest}`;
10312
10386
  }
10313
10387
  function defaultProfileDir(ownerId, profile) {
10314
- return resolve11(BROWSER_PROFILES_DIR, "profiles", ownerDirectory(ownerId), profile);
10388
+ return resolve12(BROWSER_PROFILES_DIR, "profiles", ownerDirectory(ownerId), profile);
10315
10389
  }
10316
10390
  function resolveUserDataDir(instanceKey) {
10317
10391
  return managerHost.resolveInstanceDataDir(instanceKey);
@@ -10687,7 +10761,7 @@ async function cloneProfileForChild(opts) {
10687
10761
  cleanSingletonFiles(dstDir);
10688
10762
  for (const f of ["DevToolsActivePort", "LOCK"]) {
10689
10763
  try {
10690
- unlinkSync11(resolve11(dstDir, f));
10764
+ unlinkSync11(resolve12(dstDir, f));
10691
10765
  } catch {}
10692
10766
  }
10693
10767
  logger.info({ srcKey, dstKey, srcDir, dstDir }, "Cloned Playwright profile for child topic");
@@ -10704,14 +10778,16 @@ var defaultManagerHost, managerHost, MAX_IDLE_MS, instances, usedPorts, spawning
10704
10778
  var init_manager2 = __esm(async () => {
10705
10779
  init_config();
10706
10780
  init_logger();
10707
- await init_browser_processes();
10708
10781
  init_headed_launch();
10709
10782
  init_transport_probe();
10710
- await init_browser_profiles();
10711
10783
  init_manager_utils();
10712
- await init_browser_processes();
10713
10784
  init_transport_probe();
10714
10785
  init_manager_utils();
10786
+ await __promiseAll([
10787
+ init_browser_processes(),
10788
+ init_browser_profiles(),
10789
+ init_browser_processes()
10790
+ ]);
10715
10791
  defaultManagerHost = Object.freeze({
10716
10792
  portsDir: PLAYWRIGHT_PORTS_DIR,
10717
10793
  basePort: PLAYWRIGHT_BASE_PORT,
@@ -10867,10 +10943,12 @@ function createTopicLogMaintenance(host) {
10867
10943
  }
10868
10944
  var defaultTopicLogMaintenance, cleanupTopicRollouts, cleanupTopicRolloutsFromEntries, rotateTopicLogs, purgeTopicLogs;
10869
10945
  var init_topic_cleanup = __esm(async () => {
10870
- await init_agents();
10871
- await init_registry();
10872
10946
  init_logger();
10873
- await init_conversations();
10947
+ await __promiseAll([
10948
+ init_agents(),
10949
+ init_registry(),
10950
+ init_conversations()
10951
+ ]);
10874
10952
  defaultTopicLogMaintenance = createTopicLogMaintenance({
10875
10953
  agents: SUPPORTED_AGENTS,
10876
10954
  readActiveConversation: readConversation,
@@ -10953,11 +11031,13 @@ function text(value, maxLen) {
10953
11031
  }
10954
11032
  var providers, transientSessions;
10955
11033
  var init_background_sessions = __esm(async () => {
10956
- await init_archiver();
10957
- await init_api_topics();
10958
- await init_runtime_events();
10959
- await init_runtime_leases();
10960
11034
  init_background_session_policy();
11035
+ await __promiseAll([
11036
+ init_archiver(),
11037
+ init_api_topics(),
11038
+ init_runtime_events(),
11039
+ init_runtime_leases()
11040
+ ]);
10961
11041
  providers = new Set;
10962
11042
  transientSessions = new Map;
10963
11043
  });
@@ -11232,9 +11312,11 @@ function getRuntimeUserTurnRequest(topicId) {
11232
11312
  }
11233
11313
  var REQUEST_CLAIM_STALE_MS;
11234
11314
  var init_runtime_turn_requests = __esm(async () => {
11235
- await init_forum_db();
11236
- await init_runtime_leases();
11237
- await init_runtime_topic_state();
11315
+ await __promiseAll([
11316
+ init_forum_db(),
11317
+ init_runtime_leases(),
11318
+ init_runtime_topic_state()
11319
+ ]);
11238
11320
  REQUEST_CLAIM_STALE_MS = TURN_LEASE_STALE_MS;
11239
11321
  ensureRuntimeUserTurnRequestsSchema(db);
11240
11322
  });
@@ -11589,14 +11671,10 @@ The assistant response is the authoritative summary of all earlier context.`
11589
11671
  }
11590
11672
  function shouldCompactForkEntries(entries, thresholdTokens = AUTO_FORK_COMPACTION_TOKENS) {
11591
11673
  const messages = [];
11592
- let cjkChars = 0;
11593
11674
  for (const pair of extractChatPairs(entries)) {
11594
11675
  messages.push({ role: "user", content: pair.userText }, { role: "assistant", content: pair.assistantText });
11595
- cjkChars += (pair.userText.match(/[\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}]/gu) ?? []).length;
11596
- cjkChars += (pair.assistantText.match(/[\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}]/gu) ?? []).length;
11597
11676
  }
11598
- const cjkAdjustment = Math.ceil(cjkChars * (1 - 1 / 3.5));
11599
- return estimateTokens(messages) + cjkAdjustment >= thresholdTokens;
11677
+ return estimateTokens(messages) >= thresholdTokens;
11600
11678
  }
11601
11679
  async function createCompactedRolloutEntries(request, summarize = summarizeTopicContext) {
11602
11680
  const source = buildCompactionSource(request.topicId, request.userId, request.entries, request.visibleMessages);
@@ -11622,29 +11700,31 @@ async function createCompactedRolloutEntries(request, summarize = summarizeTopic
11622
11700
  }
11623
11701
  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;
11624
11702
  var init_session = __esm(async () => {
11625
- await init_idle_archiver();
11626
- await init_agents();
11627
11703
  init_model_catalog();
11628
- await init_registry();
11629
11704
  init_shared();
11630
- await init_topic_cleanup();
11631
- await init_bus();
11632
11705
  init_config();
11633
11706
  init_logger();
11634
11707
  init_mcp_config();
11635
- await init_active_rooms();
11636
- await init_background_sessions();
11637
11708
  init_usage_alert();
11638
- await init_api_messages();
11639
- await init_api_topic_brief();
11640
- await init_api_topic_config();
11641
- await init_api_topics();
11642
- await init_conversations();
11643
- await init_runtime_leases();
11644
- await init_runtime_topic_state();
11645
- await init_runtime_turn_requests();
11646
- await init_topic_archive();
11647
- await init_personal_general();
11709
+ await __promiseAll([
11710
+ init_idle_archiver(),
11711
+ init_agents(),
11712
+ init_registry(),
11713
+ init_topic_cleanup(),
11714
+ init_bus(),
11715
+ init_active_rooms(),
11716
+ init_background_sessions(),
11717
+ init_api_messages(),
11718
+ init_api_topic_brief(),
11719
+ init_api_topic_config(),
11720
+ init_api_topics(),
11721
+ init_conversations(),
11722
+ init_runtime_leases(),
11723
+ init_runtime_topic_state(),
11724
+ init_runtime_turn_requests(),
11725
+ init_topic_archive(),
11726
+ init_personal_general()
11727
+ ]);
11648
11728
  RESET_MEMORY_ARCHIVE_WAIT_MS = 5 * 60 * 1000;
11649
11729
  COMPACTION_SOURCE_CHARS = 512 * 1024;
11650
11730
  COMPACTION_TIMEOUT_MS = 2 * 60000;
@@ -11954,22 +12034,24 @@ async function createDerivedTopicImpl(topic, sourceTopicId, userId, copyHistory,
11954
12034
  }
11955
12035
  var TopicTitleConflictError, TopicDeriveBusyError, TopicForkCompactionError;
11956
12036
  var init_derive = __esm(async () => {
11957
- await init_fork();
11958
12037
  init_model_catalog();
11959
- await init_registry();
11960
- await init_bus();
11961
12038
  init_config();
11962
12039
  init_logger();
11963
- await init_manager2();
11964
- await init_active_rooms();
11965
- await init_api_messages();
11966
- await init_api_topic_config();
11967
- await init_api_topics();
11968
- await init_conversations();
11969
- await init_forum_db();
11970
- await init_runtime_topic_state();
11971
- await init_personal_general();
11972
- await init_session();
12040
+ await __promiseAll([
12041
+ init_fork(),
12042
+ init_registry(),
12043
+ init_bus(),
12044
+ init_manager2(),
12045
+ init_active_rooms(),
12046
+ init_api_messages(),
12047
+ init_api_topic_config(),
12048
+ init_api_topics(),
12049
+ init_conversations(),
12050
+ init_forum_db(),
12051
+ init_runtime_topic_state(),
12052
+ init_personal_general(),
12053
+ init_session()
12054
+ ]);
11973
12055
  TopicTitleConflictError = class TopicTitleConflictError extends Error {
11974
12056
  title;
11975
12057
  constructor(title) {
@@ -12628,8 +12710,10 @@ async function failInterruptedRemoteAskCallbacks() {
12628
12710
  }
12629
12711
  var pendingAsks, MAX_ASK_AGE_MS;
12630
12712
  var init_ask_callbacks = __esm(async () => {
12631
- await init_forum_db();
12632
- await init_session_asks();
12713
+ await __promiseAll([
12714
+ init_forum_db(),
12715
+ init_session_asks()
12716
+ ]);
12633
12717
  db.exec(`
12634
12718
  CREATE TABLE IF NOT EXISTS remote_ask_callbacks (
12635
12719
  target_query_id TEXT PRIMARY KEY,
@@ -13083,35 +13167,37 @@ async function deleteTopicCascadeImpl(topic, userId, options, deletingAncestorId
13083
13167
  }
13084
13168
  var DELETE_TURN_WAIT_MS = 5000, TopicArchiveRequiredError, TopicTurnStillActiveError, TopicCleanupRequiredError;
13085
13169
  var init_lifecycle = __esm(async () => {
13086
- await init_archiver();
13087
- await init_idle_archiver();
13088
- await init_spawn_subagent();
13089
- await init_topic_cleanup();
13090
- await init_bus();
13091
13170
  init_manager();
13092
13171
  init_config();
13093
13172
  init_constants();
13094
13173
  init_logger();
13095
- await init_manager2();
13096
- await init_active_rooms();
13097
13174
  init_session_inbox_cleanup();
13098
13175
  init_state();
13099
- await init_ask_callbacks();
13100
13176
  init_file_hooks();
13101
13177
  init_usage_alert();
13102
- await init_visual_store();
13103
- await init_api_messages();
13104
- await init_api_topic_brief();
13105
- await init_api_topic_config();
13106
- await init_api_topics();
13107
- await init_browser_profiles();
13108
- await init_runtime_leases();
13109
- await init_runtime_topic_state();
13110
- await init_runtime_turn_requests();
13111
- await init_self_schedules();
13112
- await init_session_asks();
13113
- await init_topic_archive();
13114
- await init_topic_archive_state();
13178
+ await __promiseAll([
13179
+ init_archiver(),
13180
+ init_idle_archiver(),
13181
+ init_spawn_subagent(),
13182
+ init_topic_cleanup(),
13183
+ init_bus(),
13184
+ init_manager2(),
13185
+ init_active_rooms(),
13186
+ init_ask_callbacks(),
13187
+ init_visual_store(),
13188
+ init_api_messages(),
13189
+ init_api_topic_brief(),
13190
+ init_api_topic_config(),
13191
+ init_api_topics(),
13192
+ init_browser_profiles(),
13193
+ init_runtime_leases(),
13194
+ init_runtime_topic_state(),
13195
+ init_runtime_turn_requests(),
13196
+ init_self_schedules(),
13197
+ init_session_asks(),
13198
+ init_topic_archive(),
13199
+ init_topic_archive_state()
13200
+ ]);
13115
13201
  TopicArchiveRequiredError = class TopicArchiveRequiredError extends Error {
13116
13202
  code = "TOPIC_ARCHIVE_FAILED";
13117
13203
  topicId;
@@ -13383,12 +13469,12 @@ var init_errors = __esm(() => {
13383
13469
 
13384
13470
  // ../../packages/core/src/runtime/event-heartbeat.ts
13385
13471
  function nextOrHeartbeat(pending, intervalMs) {
13386
- return new Promise((resolve12, reject) => {
13387
- const timer = setTimeout(() => resolve12({ kind: "heartbeat" }), intervalMs);
13472
+ return new Promise((resolve13, reject) => {
13473
+ const timer = setTimeout(() => resolve13({ kind: "heartbeat" }), intervalMs);
13388
13474
  timer.unref?.();
13389
13475
  pending.then((result) => {
13390
13476
  clearTimeout(timer);
13391
- resolve12({ kind: "event", result });
13477
+ resolve13({ kind: "event", result });
13392
13478
  }, (error) => {
13393
13479
  clearTimeout(timer);
13394
13480
  reject(error);
@@ -13471,8 +13557,8 @@ function abortPlaywrightTurns(instanceKey, failure) {
13471
13557
  var turnsByInstance;
13472
13558
  var init_playwright_turn_abort = __esm(async () => {
13473
13559
  init_logger();
13474
- await init_manager2();
13475
13560
  init_types2();
13561
+ await init_manager2();
13476
13562
  turnsByInstance = new Map;
13477
13563
  onPlaywrightFailure(abortPlaywrightTurns);
13478
13564
  });
@@ -13549,8 +13635,10 @@ function upsertTaskPanelMessage(topicId, queryId, tasks, lastRenderedText) {
13549
13635
  return text2;
13550
13636
  }
13551
13637
  var init_tasks2 = __esm(async () => {
13552
- await init_bus();
13553
- await init_api_messages();
13638
+ await __promiseAll([
13639
+ init_bus(),
13640
+ init_api_messages()
13641
+ ]);
13554
13642
  });
13555
13643
 
13556
13644
  // ../../packages/core/src/runtime/visual-html.ts
@@ -13643,7 +13731,7 @@ var init_visual_html = __esm(() => {
13643
13731
 
13644
13732
  // ../../packages/core/src/runtime/visuals.ts
13645
13733
  import { realpathSync as realpathSync4 } from "fs";
13646
- import { isAbsolute as isAbsolute4, resolve as resolve12 } from "path";
13734
+ import { isAbsolute as isAbsolute4, resolve as resolve13 } from "path";
13647
13735
  function activeVisualHtmlForPrompt(html) {
13648
13736
  if (html.length <= ACTIVE_VISUAL_PROMPT_MAX_CHARS) {
13649
13737
  return { html, omittedChars: 0 };
@@ -13694,8 +13782,8 @@ function topicAllowsVisualFileId(topicId, fileId) {
13694
13782
  return topicHasAttachmentFileId(topicId, fileId) || topicHasVisualFileId(topicId, fileId);
13695
13783
  }
13696
13784
  function isPathInside(baseDir, filePath) {
13697
- const base = resolve12(baseDir);
13698
- const normalized = resolve12(filePath);
13785
+ const base = resolve13(baseDir);
13786
+ const normalized = resolve13(filePath);
13699
13787
  try {
13700
13788
  const realBase = realpathSync4(base);
13701
13789
  const real = realpathSync4(normalized);
@@ -13757,7 +13845,7 @@ function resolveVisualMediaInput(topicId, input) {
13757
13845
  }
13758
13846
  const rawPath = input.file_path.trim();
13759
13847
  const cwd = workspaceCwdFor(topicId);
13760
- const candidate = isAbsolute4(rawPath) ? rawPath : resolve12(cwd, rawPath);
13848
+ const candidate = isAbsolute4(rawPath) ? rawPath : resolve13(cwd, rawPath);
13761
13849
  if (!isPathInside(cwd, candidate)) {
13762
13850
  return { error: "file_path must be inside the topic workspace" };
13763
13851
  }
@@ -13786,10 +13874,12 @@ var ACTIVE_VISUAL_PROMPT_MAX_CHARS = 24000, ACTIVE_VISUAL_PROMPT_TAIL_CHARS = 60
13786
13874
  var init_visuals = __esm(async () => {
13787
13875
  init_attachments();
13788
13876
  init_file_hooks();
13789
- await init_visual_store();
13790
13877
  init_sensitive_path();
13791
- await init_api_messages();
13792
13878
  init_visual_html();
13879
+ await __promiseAll([
13880
+ init_visual_store(),
13881
+ init_api_messages()
13882
+ ]);
13793
13883
  });
13794
13884
 
13795
13885
  // ../../packages/core/src/storage/token-stats.ts
@@ -13830,7 +13920,7 @@ var init_token_stats = __esm(async () => {
13830
13920
  // ../../packages/core/src/runtime/turn-event-stream.ts
13831
13921
  import { randomUUID as randomUUID14 } from "crypto";
13832
13922
  import { realpathSync as realpathSync5, statSync as statSync8 } from "fs";
13833
- import { isAbsolute as isAbsolute5, resolve as resolve13 } from "path";
13923
+ import { isAbsolute as isAbsolute5, resolve as resolve14 } from "path";
13834
13924
  function sessionEventMatchesCurrentExecution(topicId, queryId, agent, model) {
13835
13925
  if (getRoomQuery(topicId)?.queryId !== queryId)
13836
13926
  return false;
@@ -14137,7 +14227,7 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14137
14227
  case "file":
14138
14228
  if (!silent && peerBridge) {
14139
14229
  const cwd = workspaceCwdFor(topicId);
14140
- const path = isAbsolute5(event.path) ? event.path : resolve13(cwd, event.path);
14230
+ const path = isAbsolute5(event.path) ? event.path : resolve14(cwd, event.path);
14141
14231
  if (!isPathInside(cwd, path)) {
14142
14232
  logger.warn({ topicId, path }, "peer output file is outside the topic workspace");
14143
14233
  break;
@@ -14347,29 +14437,31 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14347
14437
  return outcome;
14348
14438
  }
14349
14439
  var init_turn_event_stream = __esm(async () => {
14350
- await init_fork();
14351
- await init_idle_archiver();
14352
- await init_ask_user();
14353
- await init_spawn_subagent();
14354
14440
  init_model_catalog();
14355
- await init_registry();
14356
14441
  init_tool_format();
14357
- await init_bus();
14358
14442
  init_logger();
14359
- await init_active_rooms();
14360
14443
  init_state();
14361
14444
  init_types2();
14362
14445
  init_attachments();
14363
14446
  init_errors();
14364
- await init_tasks2();
14365
- await init_topic_config();
14366
14447
  init_usage_alert();
14367
- await init_visual_store();
14368
- await init_visuals();
14369
14448
  init_sensitive_path();
14370
- await init_api_messages();
14371
- await init_api_topics();
14372
- await init_token_stats();
14449
+ await __promiseAll([
14450
+ init_fork(),
14451
+ init_idle_archiver(),
14452
+ init_ask_user(),
14453
+ init_spawn_subagent(),
14454
+ init_registry(),
14455
+ init_bus(),
14456
+ init_active_rooms(),
14457
+ init_tasks2(),
14458
+ init_topic_config(),
14459
+ init_visual_store(),
14460
+ init_visuals(),
14461
+ init_api_messages(),
14462
+ init_api_topics(),
14463
+ init_token_stats()
14464
+ ]);
14373
14465
  });
14374
14466
 
14375
14467
  // ../../packages/core/src/runtime/turn-session.ts
@@ -14401,9 +14493,11 @@ function resolveInitialTurnSessionId(topicId, requestedSessionId, isolated) {
14401
14493
  }
14402
14494
  var init_turn_session = __esm(async () => {
14403
14495
  init_model_catalog();
14404
- await init_registry();
14405
- await init_topic_config();
14406
- await init_api_topics();
14496
+ await __promiseAll([
14497
+ init_registry(),
14498
+ init_topic_config(),
14499
+ init_api_topics()
14500
+ ]);
14407
14501
  });
14408
14502
 
14409
14503
  // ../../packages/core/src/storage/app-settings.ts
@@ -15671,41 +15765,43 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
15671
15765
  }
15672
15766
  var PLAYWRIGHT_UNAVAILABLE_NOTICE_COOLDOWN_MS, ASK_REPLY_INJECT_BATCH_MS = 500, playwrightUnavailableNoticeAt, askReplyInjectBatcher, remoteInjectWaiters, durableTurnWorker = null, durableTurnWorkerBusy = false;
15673
15767
  var init_turn_runner = __esm(async () => {
15674
- await init_fork();
15675
- await init_agents();
15676
- await init_spawn_subagent();
15677
- await init_registry();
15678
- await init_bus();
15679
15768
  init_manager();
15680
15769
  init_constants();
15681
15770
  init_logger();
15682
15771
  init_mcp_config();
15683
- await init_manager2();
15684
15772
  init_builders();
15685
- await init_active_rooms();
15686
15773
  init_state();
15687
15774
  init_types2();
15688
15775
  init_attachments();
15689
- await init_channel_context();
15690
15776
  init_errors();
15691
- await init_playwright_turn_abort();
15692
- await init_topic_config();
15693
- await init_turn_event_stream();
15694
- await init_turn_session();
15695
- await init_visual_store();
15696
- await init_visuals();
15697
- await init_api_messages();
15698
- await init_api_topic_brief();
15699
- await init_api_topics();
15700
- await init_app_settings();
15701
- await init_browser_profiles();
15702
- await init_conversations();
15703
- await init_runtime_leases();
15704
- await init_runtime_topic_state();
15705
- await init_runtime_turn_requests();
15706
- await init_wiki();
15707
15777
  init_wiki_summary_names();
15708
- await init_derive();
15778
+ await __promiseAll([
15779
+ init_fork(),
15780
+ init_agents(),
15781
+ init_spawn_subagent(),
15782
+ init_registry(),
15783
+ init_bus(),
15784
+ init_manager2(),
15785
+ init_active_rooms(),
15786
+ init_channel_context(),
15787
+ init_playwright_turn_abort(),
15788
+ init_topic_config(),
15789
+ init_turn_event_stream(),
15790
+ init_turn_session(),
15791
+ init_visual_store(),
15792
+ init_visuals(),
15793
+ init_api_messages(),
15794
+ init_api_topic_brief(),
15795
+ init_api_topics(),
15796
+ init_app_settings(),
15797
+ init_browser_profiles(),
15798
+ init_conversations(),
15799
+ init_runtime_leases(),
15800
+ init_runtime_topic_state(),
15801
+ init_runtime_turn_requests(),
15802
+ init_wiki(),
15803
+ init_derive()
15804
+ ]);
15709
15805
  init_model_catalog();
15710
15806
  init_attachments();
15711
15807
  init_channel_context();
@@ -16415,14 +16511,16 @@ function processOwnerIsAlive(ownerId) {
16415
16511
  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;
16416
16512
  var init_spawn_subagent = __esm(async () => {
16417
16513
  init_common();
16418
- await init_bus();
16419
16514
  init_logger();
16420
- await init_api_messages();
16421
- await init_api_topics();
16422
- await init_runtime_leases();
16423
- await init_runtime_turn_requests();
16424
16515
  init_wiki_summary_names();
16425
16516
  init_types();
16517
+ await __promiseAll([
16518
+ init_bus(),
16519
+ init_api_messages(),
16520
+ init_api_topics(),
16521
+ init_runtime_leases(),
16522
+ init_runtime_turn_requests()
16523
+ ]);
16426
16524
  defaultSubagentLifecycleHost = {
16427
16525
  storage: {
16428
16526
  getTopic,
@@ -16557,25 +16655,29 @@ var init_spawn_subagent = __esm(async () => {
16557
16655
  });
16558
16656
 
16559
16657
  // ../../packages/core/src/agents/public-helpers.ts
16560
- await init_archiver();
16561
- await init_auth_check();
16562
16658
  init_codex_tree_kill();
16563
- await init_fork();
16564
- await init_idle_archiver();
16565
- await init_ask_user();
16659
+ await __promiseAll([
16660
+ init_archiver(),
16661
+ init_auth_check(),
16662
+ init_fork(),
16663
+ init_idle_archiver(),
16664
+ init_ask_user()
16665
+ ]);
16566
16666
 
16567
16667
  // ../../packages/core/src/agents/mcp-tools/self-config.ts
16568
16668
  init_common();
16569
16669
  import { z as z2 } from "zod";
16570
16670
 
16571
16671
  // ../../packages/core/src/agents/api-topic-agent-switch.ts
16572
- await init_auth_check();
16573
16672
  init_model_catalog();
16574
- await init_registry();
16575
16673
  init_logger();
16576
- await init_api_topic_config();
16577
- await init_api_topics();
16578
- await init_conversations();
16674
+ await __promiseAll([
16675
+ init_auth_check(),
16676
+ init_registry(),
16677
+ init_api_topic_config(),
16678
+ init_api_topics(),
16679
+ init_conversations()
16680
+ ]);
16579
16681
  import { unlinkSync as unlinkSync9 } from "fs";
16580
16682
  function commitApiTopicSwitch(opts, bridgedSessionId) {
16581
16683
  const registry = getRegistry(opts.agent);
@@ -16677,14 +16779,16 @@ function switchApiTopicAgent(opts) {
16677
16779
  }
16678
16780
 
16679
16781
  // ../../packages/core/src/agents/self-config-core.ts
16680
- await init_auth_check();
16681
16782
  init_model_catalog();
16682
- await init_registry();
16683
- await init_bus();
16684
16783
  init_config();
16685
- await init_api_topic_config();
16686
- await init_api_topics();
16687
- await init_self_schedules();
16784
+ await __promiseAll([
16785
+ init_auth_check(),
16786
+ init_registry(),
16787
+ init_bus(),
16788
+ init_api_topic_config(),
16789
+ init_api_topics(),
16790
+ init_self_schedules()
16791
+ ]);
16688
16792
 
16689
16793
  // ../../packages/core/src/topics/links.ts
16690
16794
  function topicAppLink(topicId) {
@@ -17332,10 +17436,12 @@ var otiumVisualToolDefinitions = [
17332
17436
  ];
17333
17437
 
17334
17438
  // ../../packages/core/src/agents/public-helpers.ts
17335
- await init_task_events();
17336
17439
  init_tool_format();
17337
- await init_topic_cleanup();
17338
17440
  init_vault_tool_policy();
17441
+ await __promiseAll([
17442
+ init_task_events(),
17443
+ init_topic_cleanup()
17444
+ ]);
17339
17445
  export {
17340
17446
  withTaskSnapshots,
17341
17447
  withCodexSpawnSerial,
@@ -17391,4 +17497,4 @@ export {
17391
17497
  DEFAULT_SELF_CONFIG_PRODUCT
17392
17498
  };
17393
17499
 
17394
- //# debugId=C02224FF0B17843364756E2164756E21
17500
+ //# debugId=36D5DB4B3E98F69464756E2164756E21