negotium 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/agent-helpers.js +339 -298
  2. package/dist/agent-helpers.js.map +15 -14
  3. package/dist/background-bash.js +19 -19
  4. package/dist/background-bash.js.map +6 -6
  5. package/dist/browser-runtime.js +19 -19
  6. package/dist/browser-runtime.js.map +6 -6
  7. package/dist/{chunk-gjtgsggp.js → chunk-5kdwqcz7.js} +1 -1
  8. package/dist/{chunk-j457924j.js → chunk-p0011tm7.js} +23 -23
  9. package/dist/{chunk-j457924j.js.map → chunk-p0011tm7.js.map} +6 -6
  10. package/dist/{chunk-84b5qy2s.js → chunk-vwtb2mqf.js} +3 -3
  11. package/dist/{chunk-84b5qy2s.js.map → chunk-vwtb2mqf.js.map} +2 -2
  12. package/dist/hosted-agent.js +21 -21
  13. package/dist/hosted-agent.js.map +7 -7
  14. package/dist/main.js +132 -75
  15. package/dist/main.js.map +24 -23
  16. package/dist/mcp-factories.js +72 -32
  17. package/dist/mcp-factories.js.map +13 -12
  18. package/dist/media.js +19 -19
  19. package/dist/media.js.map +6 -6
  20. package/dist/platform-runtime.js +1 -1
  21. package/dist/platform-runtime.js.map +3 -3
  22. package/dist/prompts.js +20 -19
  23. package/dist/prompts.js.map +7 -7
  24. package/dist/query-runtime.js +18 -18
  25. package/dist/query-runtime.js.map +5 -5
  26. package/dist/registry.js +3 -3
  27. package/dist/rollout.js +2 -2
  28. package/dist/runtime/cron/store.ts +35 -3
  29. package/dist/runtime/src/agents/archiver.ts +7 -2
  30. package/dist/runtime/src/agents/index.ts +9 -11
  31. package/dist/runtime/src/agents/model-catalog.ts +71 -9
  32. package/dist/runtime/src/agents/self-config-core.ts +2 -1
  33. package/dist/runtime/src/cron-host.ts +4 -3
  34. package/dist/runtime/src/platform/config-helpers.ts +14 -0
  35. package/dist/runtime/src/platform/config.ts +8 -12
  36. package/dist/runtime/src/platform/memoize-import.ts +26 -0
  37. package/dist/runtime/src/runtime/turn-session.ts +2 -1
  38. package/dist/runtime/src/storage/api-topics.ts +3 -4
  39. package/dist/runtime/src/storage/conversation-migration.ts +2 -1
  40. package/dist/runtime/src/storage/forum/repository.ts +2 -10
  41. package/dist/runtime/src/storage/forum/schema.ts +12 -5
  42. package/dist/runtime/src/topics/create.ts +2 -2
  43. package/dist/runtime/src/topics/session.ts +2 -1
  44. package/dist/runtime/src/topics/update.ts +14 -4
  45. package/dist/runtime/src/version.ts +1 -1
  46. package/dist/runtime-helpers.js +18 -18
  47. package/dist/runtime-helpers.js.map +5 -5
  48. package/dist/storage.js +26 -20
  49. package/dist/storage.js.map +8 -7
  50. package/dist/types/packages/core/src/agents/model-catalog.d.ts +28 -0
  51. package/dist/types/packages/core/src/platform/config-helpers.d.ts +10 -0
  52. package/dist/types/packages/core/src/platform/memoize-import.d.ts +15 -0
  53. package/dist/types/packages/core/src/version.d.ts +1 -1
  54. package/dist/vault.js +19 -19
  55. package/dist/vault.js.map +6 -6
  56. package/package.json +1 -1
  57. /package/dist/{chunk-gjtgsggp.js.map → chunk-5kdwqcz7.js.map} +0 -0
@@ -95,11 +95,34 @@ var init_vault_tool_policy = __esm(() => {
95
95
  DIRECT_VAULT_EXECUTION_TOOLS = new Set(["Bash", "WebFetch"]);
96
96
  });
97
97
 
98
+ // ../../packages/core/src/types.ts
99
+ function isAgentKind(value) {
100
+ return typeof value === "string" && SUPPORTED_AGENTS.includes(value);
101
+ }
102
+ var SUPPORTED_AGENTS, CLAUDE_EFFORT_VALUES, CODEX_EFFORT_VALUES, MAESTRO_EFFORT_VALUES, EFFORT_VALUES;
103
+ var init_types = __esm(() => {
104
+ SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
105
+ CLAUDE_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
106
+ CODEX_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
107
+ MAESTRO_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
108
+ EFFORT_VALUES = [
109
+ "low",
110
+ "medium",
111
+ "high",
112
+ "xhigh",
113
+ "max"
114
+ ];
115
+ });
116
+
98
117
  // ../../packages/core/src/platform/config-helpers.ts
99
118
  function readEnvText(env, key) {
100
119
  const value = env[key]?.trim();
101
120
  return value || undefined;
102
121
  }
122
+ function resolveFallbackAgent(env = process.env) {
123
+ const value = readEnvText(env, "FALLBACK_AGENT") ?? readEnvText(env, "DEFAULT_AGENT");
124
+ return isAgentKind(value) ? value : "claude";
125
+ }
103
126
  function parseRuntimePort(value, fallback) {
104
127
  if (!value)
105
128
  return fallback;
@@ -110,7 +133,9 @@ function safeRuntimePathSegment(value, fallback, maxLength = 160) {
110
133
  const cleaned = value.trim().replace(/[^A-Za-z0-9._-]/g, "_").replace(/^_+|_+$/g, "").slice(0, maxLength);
111
134
  return cleaned || fallback;
112
135
  }
113
- var init_config_helpers = () => {};
136
+ var init_config_helpers = __esm(() => {
137
+ init_types();
138
+ });
114
139
 
115
140
  // ../../packages/core/src/platform/logger.ts
116
141
  import pino from "pino";
@@ -133,25 +158,6 @@ var init_logger = __esm(() => {
133
158
  logger = createStdioLogger();
134
159
  });
135
160
 
136
- // ../../packages/core/src/types.ts
137
- function isAgentKind(value) {
138
- return typeof value === "string" && SUPPORTED_AGENTS.includes(value);
139
- }
140
- var SUPPORTED_AGENTS, CLAUDE_EFFORT_VALUES, CODEX_EFFORT_VALUES, MAESTRO_EFFORT_VALUES, EFFORT_VALUES;
141
- var init_types = __esm(() => {
142
- SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
143
- CLAUDE_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
144
- CODEX_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
145
- MAESTRO_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
146
- EFFORT_VALUES = [
147
- "low",
148
- "medium",
149
- "high",
150
- "xhigh",
151
- "max"
152
- ];
153
- });
154
-
155
161
  // ../../packages/core/src/platform/config.ts
156
162
  import { execFileSync } from "child_process";
157
163
  import { randomBytes } from "crypto";
@@ -171,10 +177,6 @@ import { fileURLToPath } from "url";
171
177
  function envText(envKey) {
172
178
  return readEnvText(process.env, envKey);
173
179
  }
174
- function resolveAgentEnv(envKey, fallback, legacyEnvKey) {
175
- const value = envText(envKey) ?? (legacyEnvKey ? envText(legacyEnvKey) : undefined);
176
- return isAgentKind(value) ? value : fallback;
177
- }
178
180
  function resolveStateDir() {
179
181
  const configured = envText("NEGOTIUM_STATE_DIR");
180
182
  if (false) {}
@@ -425,7 +427,7 @@ var init_config = __esm(() => {
425
427
  AGENTS_PROMPTS_DIR = resolve2(PROJECT_ROOT, "src/prompts/agents");
426
428
  RESOURCES_DIR = resolve2(PROJECT_ROOT, "src/resources");
427
429
  FILE_TAG_REGEX = /\[FILE:(\/[^\]]+)\]/gi;
428
- FALLBACK_AGENT = resolveAgentEnv("FALLBACK_AGENT", "claude", "DEFAULT_AGENT");
430
+ FALLBACK_AGENT = resolveFallbackAgent(process.env);
429
431
  FALLBACK_MODEL = envText("FALLBACK_MODEL") ?? envText("DEFAULT_MODEL");
430
432
  DEFAULT_TOPIC_EFFORT = (() => {
431
433
  const raw = envText("NEGOTIUM_DEFAULT_EFFORT")?.toLowerCase();
@@ -3075,7 +3077,7 @@ var init_codex = __esm(async () => {
3075
3077
  });
3076
3078
 
3077
3079
  // ../../packages/core/src/version.ts
3078
- var NEGOTIUM_VERSION = "0.15.0";
3080
+ var NEGOTIUM_VERSION = "0.15.1";
3079
3081
 
3080
3082
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
3081
3083
  import { spawn as spawn2 } from "child_process";
@@ -3768,6 +3770,20 @@ var init_task_events = __esm(async () => {
3768
3770
  defaultTaskEventHost = { readTasks, taskFileMtimeNs, taskScopeKey };
3769
3771
  });
3770
3772
 
3773
+ // ../../packages/core/src/platform/memoize-import.ts
3774
+ function memoizeImport(loader) {
3775
+ let inFlight;
3776
+ return () => {
3777
+ if (!inFlight) {
3778
+ inFlight = loader().catch((err) => {
3779
+ inFlight = undefined;
3780
+ throw err;
3781
+ });
3782
+ }
3783
+ return inFlight;
3784
+ };
3785
+ }
3786
+
3771
3787
  // ../../packages/core/src/platform/constants.ts
3772
3788
  var FROM_AUTO_CONTINUE = "auto-continue", FROM_SELF_SCHEDULE = "self-schedule", RESERVED_TOPIC_NAMES, GENERAL_TOPIC_ID = "general", MANAGER_TOPIC_LOG_NAME = "general", NODE_LOCAL_USER_ID = "local";
3773
3789
  var init_constants = __esm(() => {
@@ -6314,20 +6330,17 @@ import { join as join14 } from "path";
6314
6330
  async function* dispatchAgent(opts) {
6315
6331
  switch (opts.agent) {
6316
6332
  case "claude": {
6317
- claudeProviderImport ??= init_claude_provider().then(() => exports_claude_provider);
6318
- const { claudeProvider: claudeProvider2 } = await claudeProviderImport;
6333
+ const { claudeProvider: claudeProvider2 } = await loadClaudeProvider();
6319
6334
  yield* claudeProvider2(opts);
6320
6335
  return;
6321
6336
  }
6322
6337
  case "codex": {
6323
- codexProviderImport ??= init_codex_provider().then(() => exports_codex_provider);
6324
- const { codexProvider: codexProvider2 } = await codexProviderImport;
6338
+ const { codexProvider: codexProvider2 } = await loadCodexProvider();
6325
6339
  yield* codexProvider2(opts);
6326
6340
  return;
6327
6341
  }
6328
6342
  case "maestro": {
6329
- maestroProviderImport ??= init_maestro_provider().then(() => exports_maestro_provider);
6330
- const { maestroProvider: maestroProvider2 } = await maestroProviderImport;
6343
+ const { maestroProvider: maestroProvider2 } = await loadMaestroProvider();
6331
6344
  yield* maestroProvider2(opts);
6332
6345
  return;
6333
6346
  }
@@ -6420,7 +6433,7 @@ async function* runAgent(opts) {
6420
6433
  yield event;
6421
6434
  }
6422
6435
  }
6423
- var claudeProviderImport, codexProviderImport, maestroProviderImport;
6436
+ var loadClaudeProvider, loadCodexProvider, loadMaestroProvider;
6424
6437
  var init_agents = __esm(async () => {
6425
6438
  await init_execution_host();
6426
6439
  await init_registry();
@@ -6429,6 +6442,282 @@ var init_agents = __esm(async () => {
6429
6442
  init_logger();
6430
6443
  await init_conversations();
6431
6444
  init_types();
6445
+ loadClaudeProvider = memoizeImport(() => init_claude_provider().then(() => exports_claude_provider));
6446
+ loadCodexProvider = memoizeImport(() => init_codex_provider().then(() => exports_codex_provider));
6447
+ loadMaestroProvider = memoizeImport(() => init_maestro_provider().then(() => exports_maestro_provider));
6448
+ });
6449
+
6450
+ // ../../packages/core/src/agents/model-catalog.ts
6451
+ var exports_model_catalog = {};
6452
+ __export(exports_model_catalog, {
6453
+ selectableModel: () => selectableModel,
6454
+ resolveWorkerModel: () => resolveWorkerModel,
6455
+ resolveWorkerDefaultModel: () => resolveWorkerDefaultModel,
6456
+ resolveModelForAgent: () => resolveModelForAgent,
6457
+ resolveDefaultModel: () => resolveDefaultModel,
6458
+ resolveCompactionExecution: () => resolveCompactionExecution,
6459
+ modelOwner: () => modelOwner,
6460
+ formatSelectableModel: () => formatSelectableModel,
6461
+ canonicalModelId: () => canonicalModelId,
6462
+ SELECTABLE_MODELS: () => SELECTABLE_MODELS,
6463
+ MODEL_OWNER: () => MODEL_OWNER,
6464
+ MODEL_COST_ROUTING_SUMMARY: () => MODEL_COST_ROUTING_SUMMARY,
6465
+ MODEL_COST_RESEARCHED_AT: () => MODEL_COST_RESEARCHED_AT,
6466
+ FALLBACK_ORDER: () => FALLBACK_ORDER,
6467
+ AGENT_DISPLAY_NAME: () => AGENT_DISPLAY_NAME
6468
+ });
6469
+ function canonicalModelId(value) {
6470
+ const trimmed = value.trim();
6471
+ const lower = trimmed.toLowerCase();
6472
+ return SELECTABLE_MODEL_ALIASES[lower] ?? CANONICAL_MODEL_CASING[lower] ?? trimmed;
6473
+ }
6474
+ function formatSelectableModel(candidate) {
6475
+ const tier = `${candidate.intelligenceTier[0].toUpperCase()}${candidate.intelligenceTier.slice(1)}`;
6476
+ return `${candidate.agent} / \`${candidate.model}\` [${tier}-level]: ${candidate.routingSummary}`;
6477
+ }
6478
+ function selectableModel(value) {
6479
+ const canonical = canonicalModelId(value).toLowerCase();
6480
+ return SELECTABLE_MODELS.find((candidate) => candidate.model === canonical);
6481
+ }
6482
+ function modelOwner(model) {
6483
+ const lower = model.toLowerCase();
6484
+ if (lower.startsWith("claude-"))
6485
+ return "claude";
6486
+ if (lower.startsWith("deepseek-"))
6487
+ return "maestro";
6488
+ if (lower.startsWith("kimi-"))
6489
+ return "maestro";
6490
+ if (lower.startsWith("glm-"))
6491
+ return "maestro";
6492
+ if (lower.startsWith("gpt-"))
6493
+ return "codex";
6494
+ return MODEL_OWNER[lower];
6495
+ }
6496
+ function resolveDefaultModel(agent, registry) {
6497
+ if (agent !== FALLBACK_AGENT || !FALLBACK_MODEL)
6498
+ return registry.defaultModel;
6499
+ const candidate = canonicalModelId(FALLBACK_MODEL);
6500
+ const owner = modelOwner(candidate);
6501
+ if (owner && owner !== agent || !registry.validateModel(candidate)) {
6502
+ return registry.defaultModel;
6503
+ }
6504
+ return candidate;
6505
+ }
6506
+ function resolveModelForAgent(agent, requested, registry) {
6507
+ const defaultModel = resolveDefaultModel(agent, registry);
6508
+ if (!requested)
6509
+ return defaultModel;
6510
+ const candidate = canonicalModelId(requested);
6511
+ const owner = modelOwner(candidate);
6512
+ if (owner && owner !== agent)
6513
+ return defaultModel;
6514
+ return registry.validateModel(candidate) ? candidate : defaultModel;
6515
+ }
6516
+ function resolveWorkerDefaultModel(agent, registry) {
6517
+ return agent === "codex" ? "gpt-5.6-terra" : registry.defaultModel;
6518
+ }
6519
+ function resolveWorkerModel(agent, requested, registry) {
6520
+ const workerDefault = resolveWorkerDefaultModel(agent, registry);
6521
+ if (!requested)
6522
+ return workerDefault;
6523
+ const candidate = canonicalModelId(requested);
6524
+ const owner = modelOwner(candidate);
6525
+ if (owner && owner !== agent)
6526
+ return workerDefault;
6527
+ return registry.validateModel(candidate) ? candidate : workerDefault;
6528
+ }
6529
+ function resolveCompactionExecution(agent, registry) {
6530
+ const model = registry.expandModelAlias(resolveWorkerModel(agent, resolveWorkerDefaultModel(agent, registry), registry));
6531
+ const effort = registry.validateEffort("medium") ? "medium" : registry.defaultEffort;
6532
+ return { model, ...effort ? { effort } : {} };
6533
+ }
6534
+ var MODEL_OWNER, MODEL_COST_RESEARCHED_AT = "2026-09-05", MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.", CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month", CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)", CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month", CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)", SELECTABLE_MODELS, SELECTABLE_MODEL_ALIASES, CANONICAL_MODEL_CASING, FALLBACK_ORDER, AGENT_DISPLAY_NAME;
6535
+ var init_model_catalog = __esm(() => {
6536
+ init_config();
6537
+ MODEL_OWNER = {
6538
+ sonnet: "claude",
6539
+ opus: "claude",
6540
+ haiku: "claude",
6541
+ fable: "claude",
6542
+ "gpt-6-astra": "codex",
6543
+ "gpt-5.6-luna": "codex",
6544
+ "gpt-5.6-terra": "codex",
6545
+ "gpt-5.6-sol": "codex",
6546
+ "gpt-5.5": "codex",
6547
+ deepseek: "maestro",
6548
+ "deepseek-pro": "maestro",
6549
+ "deepseek-flash": "maestro",
6550
+ kimi: "maestro",
6551
+ "kimi-pro": "maestro",
6552
+ "kimi-k3": "maestro",
6553
+ "kimi-code": "maestro",
6554
+ "kimi-k2.7-code": "maestro",
6555
+ glm: "maestro",
6556
+ "glm-pro": "maestro",
6557
+ "glm-flash": "maestro",
6558
+ "glm-5.3": "maestro",
6559
+ "glm-5.3-flash": "maestro"
6560
+ };
6561
+ SELECTABLE_MODELS = [
6562
+ {
6563
+ model: "gpt-6-astra",
6564
+ agent: "codex",
6565
+ description: "Newest OpenAI flagship; replaces gpt-5.6-sol as Codex's highest-capability route.",
6566
+ intelligenceTier: "fable",
6567
+ routingSummary: "flagship reasoning; 2x sol's input/cache cost and 1.67x its output cost; matches Fable 5.1 pricing",
6568
+ accessCost: CODEX_PRO_20X_COST,
6569
+ marginalTokenCost: "Codex credits (OpenAI API rate): $10/M uncached input, $1/M cached input, $12.50/M cache write, $50/M output",
6570
+ estimatedUsage: `Released 2026-09-03; became Codex CLI's bundled default in v0.153.4 (2026-09-05). Local message-count/quota-weight ranges not yet published as of the last catalog check \u2014 expect a quota weight above gpt-5.6-sol given the higher per-token cost. ${CODEX_COMMUNITY_WEEKLY}`
6571
+ },
6572
+ {
6573
+ model: "gpt-5.6-sol",
6574
+ agent: "codex",
6575
+ description: "High-capability Codex route for demanding agentic coding work; demoted below gpt-6-astra.",
6576
+ intelligenceTier: "opus",
6577
+ routingSummary: "demanding coding work; 5x Codex quota cost; now second-tier behind gpt-6-astra",
6578
+ accessCost: CODEX_PRO_20X_COST,
6579
+ marginalTokenCost: "Codex credits: $5/M uncached input, $0.50/M cached input, $30/M output",
6580
+ estimatedUsage: `Official Pro 20x range: 300\u20131,800 local messages per 5 hours; quota weight 5x Luna. ${CODEX_COMMUNITY_WEEKLY}`
6581
+ },
6582
+ {
6583
+ model: "gpt-5.6-terra",
6584
+ agent: "codex",
6585
+ description: "High-capability Codex route for complex coding and reasoning.",
6586
+ intelligenceTier: "opus",
6587
+ routingSummary: "complex coding and reasoning; 2.5x Codex quota cost",
6588
+ accessCost: CODEX_PRO_20X_COST,
6589
+ marginalTokenCost: "Codex credits: $2.50/M uncached input, $0.25/M cached input, $15/M output",
6590
+ estimatedUsage: `Official Pro 20x range: 400\u20132,200 local messages per 5 hours; quota weight 2.5x Luna. ${CODEX_COMMUNITY_WEEKLY}`
6591
+ },
6592
+ {
6593
+ model: "gpt-5.6-luna",
6594
+ agent: "codex",
6595
+ description: "Default Codex route with strong everyday coding intelligence.",
6596
+ intelligenceTier: "sonnet",
6597
+ routingSummary: "everyday coding default; lowest Codex quota cost (1x)",
6598
+ accessCost: CODEX_PRO_20X_COST,
6599
+ marginalTokenCost: "Codex credits: $1/M uncached input, $0.10/M cached input, $6/M output",
6600
+ estimatedUsage: `Official Pro 20x range: 1,000\u20135,600 local messages per 5 hours; lowest Codex quota weight (1x). ${CODEX_COMMUNITY_WEEKLY}`
6601
+ },
6602
+ {
6603
+ model: "fable",
6604
+ agent: "claude",
6605
+ description: "Highest-capability Claude route (Fable 5.1) for the hardest and longest-running tasks.",
6606
+ intelligenceTier: "fable",
6607
+ routingSummary: "hardest long-running work; highest Claude cost; explicit request only",
6608
+ accessCost: CLAUDE_MAX_20X_COST,
6609
+ marginalTokenCost: "Claude API/extra usage: $10/M input, $12.50/M cache write, $0.25/M cache read (cut from $1/M in Fable 5.1, 2026-09-01), $50/M output",
6610
+ estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
6611
+ },
6612
+ {
6613
+ model: "opus",
6614
+ agent: "claude",
6615
+ description: "High-capability Claude route for complex reasoning and tool-heavy work.",
6616
+ intelligenceTier: "opus",
6617
+ routingSummary: "complex reasoning and tool-heavy work; about 2.5x Sonnet marginal cost",
6618
+ accessCost: CLAUDE_MAX_20X_COST,
6619
+ marginalTokenCost: "Claude API/extra usage: $5/M input, $6.25/M cache write, $0.50/M cache read, $25/M output",
6620
+ estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Opus uses the shared all-model weekly pool more quickly than Sonnet. No stable per-model token cap is published.`
6621
+ },
6622
+ {
6623
+ model: "sonnet",
6624
+ agent: "claude",
6625
+ description: "Default Claude route for capable, efficient everyday work.",
6626
+ intelligenceTier: "sonnet",
6627
+ routingSummary: "capable everyday default; lowest Claude model cost",
6628
+ accessCost: CLAUDE_MAX_20X_COST,
6629
+ marginalTokenCost: "Claude API/extra usage introductory rate: $2/M input, $2.50/M cache write, $0.20/M cache read, $10/M output through 2026-08-31; then $3/M input and $15/M output",
6630
+ estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Sonnet also has a separate weekly allowance and normally provides the highest Claude throughput. No stable weekly token cap is published.`
6631
+ },
6632
+ {
6633
+ model: "kimi-k3",
6634
+ agent: "maestro",
6635
+ description: "Frontier Kimi route for long-horizon coding and knowledge work.",
6636
+ intelligenceTier: "fable",
6637
+ routingSummary: "frontier general/coding route; 1M context; highest Maestro API cost",
6638
+ accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
6639
+ marginalTokenCost: "Kimi API: $3/M cache-miss input, $0.30/M cached input, $15/M output",
6640
+ estimatedUsage: "No subscription token cap; pay per token. Supports a 1M-token context window."
6641
+ },
6642
+ {
6643
+ model: "kimi-k2.7-code",
6644
+ agent: "maestro",
6645
+ description: "Coding-specialized Kimi route for repository-scale, long-horizon work.",
6646
+ intelligenceTier: "opus",
6647
+ routingSummary: "coding-specialized route; 256K context; cheaper than Kimi K3",
6648
+ accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
6649
+ marginalTokenCost: "Kimi API: $0.95/M cache-miss input, $0.19/M cached input, $4/M output",
6650
+ estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 256K context window."
6651
+ },
6652
+ {
6653
+ model: "glm-5.3",
6654
+ agent: "maestro",
6655
+ description: "Coding-focused GLM flagship with Opus-tier benchmark performance.",
6656
+ intelligenceTier: "opus",
6657
+ routingSummary: "coding-focused flagship route; 1M context; competitive with Opus-tier coding benchmarks at a fraction of the cost",
6658
+ accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6659
+ marginalTokenCost: "Approximate GLM API rate: $1.40/M input, $4.40/M output",
6660
+ estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 1M-token context window; text-only input."
6661
+ },
6662
+ {
6663
+ model: "glm-5.3-flash",
6664
+ agent: "maestro",
6665
+ description: "Low-cost multimodal GLM route with native image input.",
6666
+ intelligenceTier: "sonnet",
6667
+ routingSummary: "cheapest GLM route; 1M context; the only GLM model with native vision/multimodal support",
6668
+ accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6669
+ marginalTokenCost: "Approximate GLM API rate: $0.15/M input, $0.50/M output",
6670
+ estimatedUsage: "No subscription token cap; pay per token. Always uses thinking, supports a 1M-token context window, and accepts native image input."
6671
+ },
6672
+ {
6673
+ model: "deepseek-pro",
6674
+ agent: "maestro",
6675
+ description: "API-priced Sonnet-level route for cost-efficient everyday work.",
6676
+ intelligenceTier: "sonnet",
6677
+ routingSummary: "cost-efficient everyday work; pay-per-token, pricier than DeepSeek Flash",
6678
+ accessCost: "DeepSeek V4 Pro pay-as-you-go API; no monthly subscription required",
6679
+ marginalTokenCost: "DeepSeek API: $0.435/M uncached input, $0.003625/M cached input, $0.87/M output",
6680
+ estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 500 requests."
6681
+ },
6682
+ {
6683
+ model: "deepseek-flash",
6684
+ agent: "maestro",
6685
+ description: "Faster, cheaper DeepSeek V4 variant (DeepSeek-V4-Flash-0731) at similar Sonnet-level quality for high-volume everyday work.",
6686
+ intelligenceTier: "sonnet",
6687
+ routingSummary: "cheapest overall route; pay-per-token, 1M context, 5x Pro's concurrency limit",
6688
+ accessCost: "DeepSeek V4 Flash pay-as-you-go API; no monthly subscription required",
6689
+ marginalTokenCost: "DeepSeek API: $0.14/M uncached input, $0.0028/M cached input, $0.28/M output",
6690
+ estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 2500 requests."
6691
+ }
6692
+ ];
6693
+ SELECTABLE_MODEL_ALIASES = {
6694
+ kimi: "kimi-k3",
6695
+ "kimi-pro": "kimi-k3",
6696
+ "kimi-code": "kimi-k2.7-code",
6697
+ glm: "glm-5.3",
6698
+ "glm-pro": "glm-5.3",
6699
+ "glm-flash": "glm-5.3-flash"
6700
+ };
6701
+ CANONICAL_MODEL_CASING = Object.fromEntries(SELECTABLE_MODELS.map((candidate) => [candidate.model.toLowerCase(), candidate.model]));
6702
+ FALLBACK_ORDER = {
6703
+ claude: [
6704
+ { agent: "maestro", model: "deepseek-pro" },
6705
+ { agent: "codex", model: "gpt-5.6-luna" }
6706
+ ],
6707
+ codex: [
6708
+ { agent: "maestro", model: "deepseek-pro" },
6709
+ { agent: "claude", model: "sonnet" }
6710
+ ],
6711
+ maestro: [
6712
+ { agent: "codex", model: "gpt-5.6-luna" },
6713
+ { agent: "claude", model: "sonnet" }
6714
+ ]
6715
+ };
6716
+ AGENT_DISPLAY_NAME = {
6717
+ claude: "Claude",
6718
+ codex: "Codex",
6719
+ maestro: "Maestro"
6720
+ };
6432
6721
  });
6433
6722
 
6434
6723
  // ../../packages/core/src/storage/forum-db.ts
@@ -6699,262 +6988,6 @@ var init_bus = __esm(async () => {
6699
6988
  };
6700
6989
  });
6701
6990
 
6702
- // ../../packages/core/src/agents/model-catalog.ts
6703
- var exports_model_catalog = {};
6704
- __export(exports_model_catalog, {
6705
- selectableModel: () => selectableModel,
6706
- resolveModelForAgent: () => resolveModelForAgent,
6707
- resolveDefaultModel: () => resolveDefaultModel,
6708
- resolveCompactionExecution: () => resolveCompactionExecution,
6709
- modelOwner: () => modelOwner,
6710
- formatSelectableModel: () => formatSelectableModel,
6711
- canonicalModelId: () => canonicalModelId,
6712
- SELECTABLE_MODELS: () => SELECTABLE_MODELS,
6713
- MODEL_OWNER: () => MODEL_OWNER,
6714
- MODEL_COST_ROUTING_SUMMARY: () => MODEL_COST_ROUTING_SUMMARY,
6715
- MODEL_COST_RESEARCHED_AT: () => MODEL_COST_RESEARCHED_AT,
6716
- FALLBACK_ORDER: () => FALLBACK_ORDER,
6717
- AGENT_DISPLAY_NAME: () => AGENT_DISPLAY_NAME
6718
- });
6719
- function canonicalModelId(value) {
6720
- const trimmed = value.trim();
6721
- return SELECTABLE_MODEL_ALIASES[trimmed.toLowerCase()] ?? trimmed;
6722
- }
6723
- function formatSelectableModel(candidate) {
6724
- const tier = `${candidate.intelligenceTier[0].toUpperCase()}${candidate.intelligenceTier.slice(1)}`;
6725
- return `${candidate.agent} / \`${candidate.model}\` [${tier}-level]: ${candidate.routingSummary}`;
6726
- }
6727
- function selectableModel(value) {
6728
- const canonical = canonicalModelId(value).toLowerCase();
6729
- return SELECTABLE_MODELS.find((candidate) => candidate.model === canonical);
6730
- }
6731
- function modelOwner(model) {
6732
- if (model.startsWith("claude-"))
6733
- return "claude";
6734
- if (model.startsWith("deepseek-"))
6735
- return "maestro";
6736
- if (model.startsWith("kimi-"))
6737
- return "maestro";
6738
- if (model.startsWith("glm-"))
6739
- return "maestro";
6740
- if (model.startsWith("gpt-"))
6741
- return "codex";
6742
- return MODEL_OWNER[model];
6743
- }
6744
- function resolveDefaultModel(agent, registry) {
6745
- if (agent !== FALLBACK_AGENT || !FALLBACK_MODEL)
6746
- return registry.defaultModel;
6747
- const candidate = canonicalModelId(FALLBACK_MODEL);
6748
- const owner = modelOwner(candidate);
6749
- if (owner && owner !== agent || !registry.validateModel(candidate)) {
6750
- return registry.defaultModel;
6751
- }
6752
- return candidate;
6753
- }
6754
- function resolveModelForAgent(agent, requested, registry) {
6755
- const defaultModel = resolveDefaultModel(agent, registry);
6756
- if (!requested)
6757
- return defaultModel;
6758
- const candidate = canonicalModelId(requested);
6759
- const owner = modelOwner(candidate);
6760
- if (owner && owner !== agent)
6761
- return defaultModel;
6762
- return registry.validateModel(candidate) ? candidate : defaultModel;
6763
- }
6764
- function resolveCompactionExecution(agent, registry) {
6765
- const requestedModel = agent === "codex" ? "gpt-5.6-terra" : registry.defaultModel;
6766
- const model = registry.expandModelAlias(resolveModelForAgent(agent, requestedModel, registry));
6767
- const effort = registry.validateEffort("medium") ? "medium" : registry.defaultEffort;
6768
- return { model, ...effort ? { effort } : {} };
6769
- }
6770
- var MODEL_OWNER, MODEL_COST_RESEARCHED_AT = "2026-09-05", MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.", CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month", CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)", CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month", CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)", SELECTABLE_MODELS, SELECTABLE_MODEL_ALIASES, FALLBACK_ORDER, AGENT_DISPLAY_NAME;
6771
- var init_model_catalog = __esm(() => {
6772
- init_config();
6773
- MODEL_OWNER = {
6774
- sonnet: "claude",
6775
- opus: "claude",
6776
- haiku: "claude",
6777
- fable: "claude",
6778
- "gpt-6-astra": "codex",
6779
- "gpt-5.6-luna": "codex",
6780
- "gpt-5.6-terra": "codex",
6781
- "gpt-5.6-sol": "codex",
6782
- "gpt-5.5": "codex",
6783
- deepseek: "maestro",
6784
- "deepseek-pro": "maestro",
6785
- "deepseek-flash": "maestro",
6786
- kimi: "maestro",
6787
- "kimi-pro": "maestro",
6788
- "kimi-k3": "maestro",
6789
- "kimi-code": "maestro",
6790
- "kimi-k2.7-code": "maestro",
6791
- glm: "maestro",
6792
- "glm-pro": "maestro",
6793
- "glm-flash": "maestro",
6794
- "glm-5.3": "maestro",
6795
- "glm-5.3-flash": "maestro"
6796
- };
6797
- SELECTABLE_MODELS = [
6798
- {
6799
- model: "gpt-6-astra",
6800
- agent: "codex",
6801
- description: "Newest OpenAI flagship; replaces gpt-5.6-sol as Codex's highest-capability route.",
6802
- intelligenceTier: "fable",
6803
- routingSummary: "flagship reasoning; 2x sol's input/cache cost and 1.67x its output cost; matches Fable 5.1 pricing",
6804
- accessCost: CODEX_PRO_20X_COST,
6805
- marginalTokenCost: "Codex credits (OpenAI API rate): $10/M uncached input, $1/M cached input, $12.50/M cache write, $50/M output",
6806
- estimatedUsage: `Released 2026-09-03; became Codex CLI's bundled default in v0.153.4 (2026-09-05). Local message-count/quota-weight ranges not yet published as of the last catalog check \u2014 expect a quota weight above gpt-5.6-sol given the higher per-token cost. ${CODEX_COMMUNITY_WEEKLY}`
6807
- },
6808
- {
6809
- model: "gpt-5.6-sol",
6810
- agent: "codex",
6811
- description: "High-capability Codex route for demanding agentic coding work; demoted below gpt-6-astra.",
6812
- intelligenceTier: "opus",
6813
- routingSummary: "demanding coding work; 5x Codex quota cost; now second-tier behind gpt-6-astra",
6814
- accessCost: CODEX_PRO_20X_COST,
6815
- marginalTokenCost: "Codex credits: $5/M uncached input, $0.50/M cached input, $30/M output",
6816
- estimatedUsage: `Official Pro 20x range: 300\u20131,800 local messages per 5 hours; quota weight 5x Luna. ${CODEX_COMMUNITY_WEEKLY}`
6817
- },
6818
- {
6819
- model: "gpt-5.6-terra",
6820
- agent: "codex",
6821
- description: "High-capability Codex route for complex coding and reasoning.",
6822
- intelligenceTier: "opus",
6823
- routingSummary: "complex coding and reasoning; 2.5x Codex quota cost",
6824
- accessCost: CODEX_PRO_20X_COST,
6825
- marginalTokenCost: "Codex credits: $2.50/M uncached input, $0.25/M cached input, $15/M output",
6826
- estimatedUsage: `Official Pro 20x range: 400\u20132,200 local messages per 5 hours; quota weight 2.5x Luna. ${CODEX_COMMUNITY_WEEKLY}`
6827
- },
6828
- {
6829
- model: "gpt-5.6-luna",
6830
- agent: "codex",
6831
- description: "Default Codex route with strong everyday coding intelligence.",
6832
- intelligenceTier: "sonnet",
6833
- routingSummary: "everyday coding default; lowest Codex quota cost (1x)",
6834
- accessCost: CODEX_PRO_20X_COST,
6835
- marginalTokenCost: "Codex credits: $1/M uncached input, $0.10/M cached input, $6/M output",
6836
- estimatedUsage: `Official Pro 20x range: 1,000\u20135,600 local messages per 5 hours; lowest Codex quota weight (1x). ${CODEX_COMMUNITY_WEEKLY}`
6837
- },
6838
- {
6839
- model: "fable",
6840
- agent: "claude",
6841
- description: "Highest-capability Claude route (Fable 5.1) for the hardest and longest-running tasks.",
6842
- intelligenceTier: "fable",
6843
- routingSummary: "hardest long-running work; highest Claude cost; explicit request only",
6844
- accessCost: CLAUDE_MAX_20X_COST,
6845
- marginalTokenCost: "Claude API/extra usage: $10/M input, $12.50/M cache write, $0.25/M cache read (cut from $1/M in Fable 5.1, 2026-09-01), $50/M output",
6846
- estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
6847
- },
6848
- {
6849
- model: "opus",
6850
- agent: "claude",
6851
- description: "High-capability Claude route for complex reasoning and tool-heavy work.",
6852
- intelligenceTier: "opus",
6853
- routingSummary: "complex reasoning and tool-heavy work; about 2.5x Sonnet marginal cost",
6854
- accessCost: CLAUDE_MAX_20X_COST,
6855
- marginalTokenCost: "Claude API/extra usage: $5/M input, $6.25/M cache write, $0.50/M cache read, $25/M output",
6856
- estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Opus uses the shared all-model weekly pool more quickly than Sonnet. No stable per-model token cap is published.`
6857
- },
6858
- {
6859
- model: "sonnet",
6860
- agent: "claude",
6861
- description: "Default Claude route for capable, efficient everyday work.",
6862
- intelligenceTier: "sonnet",
6863
- routingSummary: "capable everyday default; lowest Claude model cost",
6864
- accessCost: CLAUDE_MAX_20X_COST,
6865
- marginalTokenCost: "Claude API/extra usage introductory rate: $2/M input, $2.50/M cache write, $0.20/M cache read, $10/M output through 2026-08-31; then $3/M input and $15/M output",
6866
- estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Sonnet also has a separate weekly allowance and normally provides the highest Claude throughput. No stable weekly token cap is published.`
6867
- },
6868
- {
6869
- model: "kimi-k3",
6870
- agent: "maestro",
6871
- description: "Frontier Kimi route for long-horizon coding and knowledge work.",
6872
- intelligenceTier: "fable",
6873
- routingSummary: "frontier general/coding route; 1M context; highest Maestro API cost",
6874
- accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
6875
- marginalTokenCost: "Kimi API: $3/M cache-miss input, $0.30/M cached input, $15/M output",
6876
- estimatedUsage: "No subscription token cap; pay per token. Supports a 1M-token context window."
6877
- },
6878
- {
6879
- model: "kimi-k2.7-code",
6880
- agent: "maestro",
6881
- description: "Coding-specialized Kimi route for repository-scale, long-horizon work.",
6882
- intelligenceTier: "opus",
6883
- routingSummary: "coding-specialized route; 256K context; cheaper than Kimi K3",
6884
- accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
6885
- marginalTokenCost: "Kimi API: $0.95/M cache-miss input, $0.19/M cached input, $4/M output",
6886
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 256K context window."
6887
- },
6888
- {
6889
- model: "glm-5.3",
6890
- agent: "maestro",
6891
- description: "Coding-focused GLM flagship with Opus-tier benchmark performance.",
6892
- intelligenceTier: "opus",
6893
- routingSummary: "coding-focused flagship route; 1M context; competitive with Opus-tier coding benchmarks at a fraction of the cost",
6894
- accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6895
- marginalTokenCost: "Approximate GLM API rate: $1.40/M input, $4.40/M output",
6896
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 1M-token context window; text-only input."
6897
- },
6898
- {
6899
- model: "glm-5.3-flash",
6900
- agent: "maestro",
6901
- description: "Low-cost multimodal GLM route with native image input.",
6902
- intelligenceTier: "sonnet",
6903
- routingSummary: "cheapest GLM route; 1M context; the only GLM model with native vision/multimodal support",
6904
- accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6905
- marginalTokenCost: "Approximate GLM API rate: $0.15/M input, $0.50/M output",
6906
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking, supports a 1M-token context window, and accepts native image input."
6907
- },
6908
- {
6909
- model: "deepseek-pro",
6910
- agent: "maestro",
6911
- description: "API-priced Sonnet-level route for cost-efficient everyday work.",
6912
- intelligenceTier: "sonnet",
6913
- routingSummary: "cost-efficient everyday work; pay-per-token, pricier than DeepSeek Flash",
6914
- accessCost: "DeepSeek V4 Pro pay-as-you-go API; no monthly subscription required",
6915
- marginalTokenCost: "DeepSeek API: $0.435/M uncached input, $0.003625/M cached input, $0.87/M output",
6916
- estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 500 requests."
6917
- },
6918
- {
6919
- model: "deepseek-flash",
6920
- agent: "maestro",
6921
- description: "Faster, cheaper DeepSeek V4 variant (DeepSeek-V4-Flash-0731) at similar Sonnet-level quality for high-volume everyday work.",
6922
- intelligenceTier: "sonnet",
6923
- routingSummary: "cheapest overall route; pay-per-token, 1M context, 5x Pro's concurrency limit",
6924
- accessCost: "DeepSeek V4 Flash pay-as-you-go API; no monthly subscription required",
6925
- marginalTokenCost: "DeepSeek API: $0.14/M uncached input, $0.0028/M cached input, $0.28/M output",
6926
- estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 2500 requests."
6927
- }
6928
- ];
6929
- SELECTABLE_MODEL_ALIASES = {
6930
- kimi: "kimi-k3",
6931
- "kimi-pro": "kimi-k3",
6932
- "kimi-code": "kimi-k2.7-code",
6933
- glm: "glm-5.3",
6934
- "glm-pro": "glm-5.3",
6935
- "glm-flash": "glm-5.3-flash"
6936
- };
6937
- FALLBACK_ORDER = {
6938
- claude: [
6939
- { agent: "maestro", model: "deepseek-pro" },
6940
- { agent: "codex", model: "gpt-5.6-luna" }
6941
- ],
6942
- codex: [
6943
- { agent: "maestro", model: "deepseek-pro" },
6944
- { agent: "claude", model: "sonnet" }
6945
- ],
6946
- maestro: [
6947
- { agent: "codex", model: "gpt-5.6-luna" },
6948
- { agent: "claude", model: "sonnet" }
6949
- ]
6950
- };
6951
- AGENT_DISPLAY_NAME = {
6952
- claude: "Claude",
6953
- codex: "Codex",
6954
- maestro: "Maestro"
6955
- };
6956
- });
6957
-
6958
6991
  // ../../packages/core/src/prompts/builders.ts
6959
6992
  import { readFileSync as readFileSync12 } from "fs";
6960
6993
  import { resolve as resolve11 } from "path";
@@ -8128,7 +8161,7 @@ function normalizeTopicState(input) {
8128
8161
  return {
8129
8162
  kind: "manager",
8130
8163
  aiMode: "always",
8131
- agent: input.agent ?? DEFAULT_AGENT_ROOM_AGENT
8164
+ agent: input.agent ?? resolveFallbackAgent()
8132
8165
  };
8133
8166
  }
8134
8167
  const requestedKind = input.kind;
@@ -8137,7 +8170,7 @@ function normalizeTopicState(input) {
8137
8170
  return {
8138
8171
  kind: "agent",
8139
8172
  aiMode: "always",
8140
- agent: input.agent ?? DEFAULT_AGENT_ROOM_AGENT
8173
+ agent: input.agent ?? resolveFallbackAgent()
8141
8174
  };
8142
8175
  }
8143
8176
  const agent = input.aiMode === "off" ? undefined : input.agent ?? undefined;
@@ -8349,8 +8382,9 @@ function reparentTopicChildren(deletedTopicId, replacementParentTopicId) {
8349
8382
  }
8350
8383
  return rows.map((row) => row.id);
8351
8384
  }
8352
- var DEFAULT_AGENT_ROOM_AGENT = "maestro", activeSurfaceScope = null, SURFACE_BACKFILL_MIGRATION = "api_topics_surface_backfill_20260808";
8385
+ var activeSurfaceScope = null, SURFACE_BACKFILL_MIGRATION = "api_topics_surface_backfill_20260808";
8353
8386
  var init_api_topics = __esm(async () => {
8387
+ init_config_helpers();
8354
8388
  init_constants();
8355
8389
  init_logger();
8356
8390
  await init_forum_db();
@@ -8618,7 +8652,7 @@ function createArchiverRuntime(host) {
8618
8652
  const wikiDir = host.storage.getWikiDir();
8619
8653
  const safeTopic = host.config.sanitizeTopicName(topicTitle);
8620
8654
  const agent = params.agent ?? FALLBACK_AGENT;
8621
- const model = params.model;
8655
+ const model = resolveWorkerModel(agent, params.model ?? definition.model, getRegistry(agent));
8622
8656
  const outputLanguage = resolveMemoryLanguage();
8623
8657
  const generalReplyInstruction = `Reply with a short completion message in ${outputLanguage} for display in #General. ` + "Do not include tool-call logs or raw transcripts \u2014 just briefly name the summary / brief / articles you saved.";
8624
8658
  const prompt = mode === "active-topic" ? [
@@ -8655,7 +8689,7 @@ function createArchiverRuntime(host) {
8655
8689
  status: "Starting",
8656
8690
  active: true,
8657
8691
  agent,
8658
- model: model ?? definition.model,
8692
+ model,
8659
8693
  prompt,
8660
8694
  promptTitle: "Prompt",
8661
8695
  steps: [
@@ -8871,6 +8905,8 @@ function runArchiverTurn(params) {
8871
8905
  var MAX_BRIEF_ENTRIES = 8, defaultArchiverRuntime;
8872
8906
  var init_archiver = __esm(async () => {
8873
8907
  await init_agents();
8908
+ init_model_catalog();
8909
+ await init_registry();
8874
8910
  init_tool_format();
8875
8911
  await init_bus();
8876
8912
  init_config();
@@ -13875,7 +13911,7 @@ async function compactTopicSession(topicId, userId, reason = "topic-session-comp
13875
13911
  return { text: "Topic maintenance ownership was lost. Try again.", isError: true };
13876
13912
  }
13877
13913
  cancelIdleCompactForTopic(topicId);
13878
- const agent = topic.agent ?? "maestro";
13914
+ const agent = topic.agent ?? resolveFallbackAgent();
13879
13915
  const registry = getRegistry(agent);
13880
13916
  const config = getApiTopicConfig(topicId);
13881
13917
  const model = resolveModelForAgent(agent, config?.model ?? topic.defaultModel, registry);
@@ -14006,6 +14042,7 @@ var init_session = __esm(async () => {
14006
14042
  await init_topic_cleanup();
14007
14043
  await init_bus();
14008
14044
  init_config();
14045
+ init_config_helpers();
14009
14046
  init_logger();
14010
14047
  init_mcp_config();
14011
14048
  await init_active_rooms();
@@ -17096,7 +17133,7 @@ var init_turn_event_stream = __esm(async () => {
17096
17133
  // ../../packages/core/src/runtime/turn-session.ts
17097
17134
  function resolveTopicTurnExecution(topic, overrides = {}) {
17098
17135
  const config = getTopicConfig(topic.id);
17099
- const agent = overrides.agentOverride ?? topic.agent ?? "maestro";
17136
+ const agent = overrides.agentOverride ?? topic.agent ?? resolveFallbackAgent();
17100
17137
  const registry = getRegistry(agent);
17101
17138
  const usesTopicDefaults = !overrides.agentOverride || overrides.agentOverride === topic.agent;
17102
17139
  const model = resolveModelForAgent(agent, overrides.modelOverride ?? (usesTopicDefaults ? config?.model ?? topic.defaultModel : undefined), registry);
@@ -17123,6 +17160,7 @@ function resolveInitialTurnSessionId(topicId, requestedSessionId, isolated) {
17123
17160
  var init_turn_session = __esm(async () => {
17124
17161
  init_model_catalog();
17125
17162
  await init_registry();
17163
+ init_config_helpers();
17126
17164
  await init_topic_config();
17127
17165
  await init_api_topics();
17128
17166
  });
@@ -17169,6 +17207,8 @@ __export(exports_turn_runner, {
17169
17207
  startAiTurn: () => startAiTurn,
17170
17208
  selectableModel: () => selectableModel,
17171
17209
  safeAttachmentFilename: () => safeAttachmentFilename,
17210
+ resolveWorkerModel: () => resolveWorkerModel,
17211
+ resolveWorkerDefaultModel: () => resolveWorkerDefaultModel,
17172
17212
  resolveWikiMirrorPath: () => resolveWikiMirrorPath,
17173
17213
  resolveWikiMemoryMirror: () => resolveWikiMemoryMirror,
17174
17214
  resolveVisualMediaInput: () => resolveVisualMediaInput,
@@ -19822,6 +19862,7 @@ init_model_catalog();
19822
19862
  await init_registry();
19823
19863
  await init_bus();
19824
19864
  init_config();
19865
+ init_config_helpers();
19825
19866
  await init_api_topic_config();
19826
19867
  await init_api_topics();
19827
19868
  await init_self_schedules();
@@ -19934,7 +19975,7 @@ function createSelfConfigCore(host, productOverrides = {}) {
19934
19975
  return topic;
19935
19976
  }
19936
19977
  function currentAgent(topic) {
19937
- return topic.agent ?? "maestro";
19978
+ return topic.agent ?? resolveFallbackAgent();
19938
19979
  }
19939
19980
  function setModel(ctx, model) {
19940
19981
  const topic = requireTopic(ctx);
@@ -20663,4 +20704,4 @@ export {
20663
20704
  DEFAULT_SELF_CONFIG_PRODUCT
20664
20705
  };
20665
20706
 
20666
- //# debugId=AF4C7F4033D476D264756E2164756E21
20707
+ //# debugId=D82D807A0D54D0E864756E2164756E21