negotium 0.14.4 → 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 (65) hide show
  1. package/dist/agent-helpers.js +350 -314
  2. package/dist/agent-helpers.js.map +18 -17
  3. package/dist/background-bash.js +19 -26
  4. package/dist/background-bash.js.map +6 -6
  5. package/dist/browser-runtime.js +19 -26
  6. package/dist/browser-runtime.js.map +6 -6
  7. package/dist/{chunk-p7tprsvc.js → chunk-5kdwqcz7.js} +1 -1
  8. package/dist/{chunk-er68mpja.js → chunk-p0011tm7.js} +23 -30
  9. package/dist/{chunk-er68mpja.js.map → chunk-p0011tm7.js.map} +6 -6
  10. package/dist/{chunk-zcazbmcs.js → chunk-vwtb2mqf.js} +3 -3
  11. package/dist/{chunk-zcazbmcs.js.map → chunk-vwtb2mqf.js.map} +2 -2
  12. package/dist/hosted-agent.js +21 -28
  13. package/dist/hosted-agent.js.map +7 -7
  14. package/dist/main.js +198 -112
  15. package/dist/main.js.map +29 -28
  16. package/dist/mcp-factories.js +331 -295
  17. package/dist/mcp-factories.js.map +17 -16
  18. package/dist/media.js +19 -26
  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 -36
  23. package/dist/prompts.js.map +7 -7
  24. package/dist/query-runtime.js +18 -25
  25. package/dist/query-runtime.js.map +5 -5
  26. package/dist/registry.js +5 -6
  27. package/dist/registry.js.map +3 -3
  28. package/dist/rollout.js +2 -2
  29. package/dist/runtime/cron/store.ts +72 -4
  30. package/dist/runtime/src/agents/archiver.ts +11 -8
  31. package/dist/runtime/src/agents/index.ts +10 -3
  32. package/dist/runtime/src/agents/maestro-registry.ts +0 -1
  33. package/dist/runtime/src/agents/model-catalog.ts +87 -24
  34. package/dist/runtime/src/agents/self-config-core.ts +2 -1
  35. package/dist/runtime/src/cron-host.ts +7 -4
  36. package/dist/runtime/src/mcp/factories/agent-health.ts +3 -2
  37. package/dist/runtime/src/node-host.ts +1 -0
  38. package/dist/runtime/src/platform/config-helpers.ts +14 -0
  39. package/dist/runtime/src/platform/config.ts +9 -32
  40. package/dist/runtime/src/platform/memoize-import.ts +26 -0
  41. package/dist/runtime/src/runtime/turn-session.ts +2 -1
  42. package/dist/runtime/src/storage/api-topics.ts +3 -4
  43. package/dist/runtime/src/storage/conversation-migration.ts +2 -1
  44. package/dist/runtime/src/storage/forum/repository.ts +2 -12
  45. package/dist/runtime/src/storage/forum/schema.ts +12 -5
  46. package/dist/runtime/src/storage/token-stats.ts +5 -1
  47. package/dist/runtime/src/topics/create.ts +2 -2
  48. package/dist/runtime/src/topics/personal-general.ts +8 -6
  49. package/dist/runtime/src/topics/session.ts +2 -1
  50. package/dist/runtime/src/topics/update.ts +14 -4
  51. package/dist/runtime/src/version.ts +1 -1
  52. package/dist/runtime-helpers.js +18 -25
  53. package/dist/runtime-helpers.js.map +5 -5
  54. package/dist/storage.js +27 -28
  55. package/dist/storage.js.map +9 -8
  56. package/dist/types/packages/core/src/agents/archiver.d.ts +1 -1
  57. package/dist/types/packages/core/src/agents/model-catalog.d.ts +33 -0
  58. package/dist/types/packages/core/src/platform/config-helpers.d.ts +10 -0
  59. package/dist/types/packages/core/src/platform/config.d.ts +0 -8
  60. package/dist/types/packages/core/src/platform/memoize-import.d.ts +15 -0
  61. package/dist/types/packages/core/src/version.d.ts +1 -1
  62. package/dist/vault.js +19 -26
  63. package/dist/vault.js.map +6 -6
  64. package/package.json +1 -1
  65. /package/dist/{chunk-p7tprsvc.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) {}
@@ -331,19 +333,13 @@ function loadOrCreateLocalSecret(envKey, filename, options = {}) {
331
333
  return stored;
332
334
  }
333
335
  }
334
- function resolveModelEnv(envKey, agentConst) {
335
- return envText(envKey) ?? (agentConst === FALLBACK_AGENT ? FALLBACK_MODEL : undefined);
336
- }
337
- function resolveDefaultModel(agent, registryDefaultModel) {
338
- return agent === SESSION_AGENT && SESSION_MODEL ? SESSION_MODEL : registryDefaultModel;
339
- }
340
336
  function resolveWhisperBackend() {
341
337
  return envText("WHISPER_BACKEND") === "mlx-whisper" ? "mlx-whisper" : "faster-whisper";
342
338
  }
343
339
  function codexAuthFilePath() {
344
340
  return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
345
341
  }
346
- var HOME, PROJECT_ROOT, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.4.0", BROWSER_RS_MIN_SECURE_VERSION = "0.2.1", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.7", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5-1", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, DEFAULT_TOPIC_EFFORT, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, WHISPER_BACKEND, MLX_WHISPER_BIN, WHISPER_MODEL_MLX, _envMaxTellDepth, MAX_TELL_DEPTH;
342
+ var HOME, PROJECT_ROOT, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.4.0", BROWSER_RS_MIN_SECURE_VERSION = "0.2.1", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.7", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5-1", FALLBACK_AGENT, FALLBACK_MODEL, DEFAULT_TOPIC_EFFORT, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, WHISPER_BACKEND, MLX_WHISPER_BIN, WHISPER_MODEL_MLX, _envMaxTellDepth, MAX_TELL_DEPTH;
347
343
  var init_config = __esm(() => {
348
344
  init_config_helpers();
349
345
  init_logger();
@@ -431,12 +427,8 @@ var init_config = __esm(() => {
431
427
  AGENTS_PROMPTS_DIR = resolve2(PROJECT_ROOT, "src/prompts/agents");
432
428
  RESOURCES_DIR = resolve2(PROJECT_ROOT, "src/resources");
433
429
  FILE_TAG_REGEX = /\[FILE:(\/[^\]]+)\]/gi;
434
- FALLBACK_AGENT = resolveAgentEnv("FALLBACK_AGENT", "maestro", "DEFAULT_AGENT");
435
- SESSION_AGENT = resolveAgentEnv("SESSION_AGENT", FALLBACK_AGENT);
436
- GATEWAY_AGENT = resolveAgentEnv("GATEWAY_AGENT", FALLBACK_AGENT);
430
+ FALLBACK_AGENT = resolveFallbackAgent(process.env);
437
431
  FALLBACK_MODEL = envText("FALLBACK_MODEL") ?? envText("DEFAULT_MODEL");
438
- SESSION_MODEL = resolveModelEnv("SESSION_MODEL", SESSION_AGENT);
439
- GATEWAY_MODEL = resolveModelEnv("GATEWAY_MODEL", GATEWAY_AGENT);
440
432
  DEFAULT_TOPIC_EFFORT = (() => {
441
433
  const raw = envText("NEGOTIUM_DEFAULT_EFFORT")?.toLowerCase();
442
434
  return raw && EFFORT_VALUES.includes(raw) ? raw : "medium";
@@ -3085,7 +3077,7 @@ var init_codex = __esm(async () => {
3085
3077
  });
3086
3078
 
3087
3079
  // ../../packages/core/src/version.ts
3088
- var NEGOTIUM_VERSION = "0.14.4";
3080
+ var NEGOTIUM_VERSION = "0.15.1";
3089
3081
 
3090
3082
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
3091
3083
  import { spawn as spawn2 } from "child_process";
@@ -3578,8 +3570,7 @@ var init_maestro_registry = __esm(() => {
3578
3570
  "kimi-code": "kimi-k2.7-code",
3579
3571
  glm: "glm-5.3",
3580
3572
  "glm-pro": "glm-5.3",
3581
- "glm-flash": "glm-5.3-flash",
3582
- "glm-5.2": "glm-5.2"
3573
+ "glm-flash": "glm-5.3-flash"
3583
3574
  };
3584
3575
  VALID_MODELS = new Set([...Object.keys(ALIAS_MAP2), ...Object.values(ALIAS_MAP2)]);
3585
3576
  VALID_EFFORTS3 = new Set(MAESTRO_EFFORT_VALUES);
@@ -3779,6 +3770,20 @@ var init_task_events = __esm(async () => {
3779
3770
  defaultTaskEventHost = { readTasks, taskFileMtimeNs, taskScopeKey };
3780
3771
  });
3781
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
+
3782
3787
  // ../../packages/core/src/platform/constants.ts
3783
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";
3784
3789
  var init_constants = __esm(() => {
@@ -6325,17 +6330,17 @@ import { join as join14 } from "path";
6325
6330
  async function* dispatchAgent(opts) {
6326
6331
  switch (opts.agent) {
6327
6332
  case "claude": {
6328
- const { claudeProvider: claudeProvider2 } = await init_claude_provider().then(() => exports_claude_provider);
6333
+ const { claudeProvider: claudeProvider2 } = await loadClaudeProvider();
6329
6334
  yield* claudeProvider2(opts);
6330
6335
  return;
6331
6336
  }
6332
6337
  case "codex": {
6333
- const { codexProvider: codexProvider2 } = await init_codex_provider().then(() => exports_codex_provider);
6338
+ const { codexProvider: codexProvider2 } = await loadCodexProvider();
6334
6339
  yield* codexProvider2(opts);
6335
6340
  return;
6336
6341
  }
6337
6342
  case "maestro": {
6338
- const { maestroProvider: maestroProvider2 } = await init_maestro_provider().then(() => exports_maestro_provider);
6343
+ const { maestroProvider: maestroProvider2 } = await loadMaestroProvider();
6339
6344
  yield* maestroProvider2(opts);
6340
6345
  return;
6341
6346
  }
@@ -6428,6 +6433,7 @@ async function* runAgent(opts) {
6428
6433
  yield event;
6429
6434
  }
6430
6435
  }
6436
+ var loadClaudeProvider, loadCodexProvider, loadMaestroProvider;
6431
6437
  var init_agents = __esm(async () => {
6432
6438
  await init_execution_host();
6433
6439
  await init_registry();
@@ -6436,6 +6442,282 @@ var init_agents = __esm(async () => {
6436
6442
  init_logger();
6437
6443
  await init_conversations();
6438
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
+ };
6439
6721
  });
6440
6722
 
6441
6723
  // ../../packages/core/src/storage/forum-db.ts
@@ -6706,262 +6988,6 @@ var init_bus = __esm(async () => {
6706
6988
  };
6707
6989
  });
6708
6990
 
6709
- // ../../packages/core/src/agents/model-catalog.ts
6710
- var exports_model_catalog = {};
6711
- __export(exports_model_catalog, {
6712
- selectableModel: () => selectableModel,
6713
- resolveModelForAgent: () => resolveModelForAgent,
6714
- resolveCompactionExecution: () => resolveCompactionExecution,
6715
- modelOwner: () => modelOwner,
6716
- formatSelectableModel: () => formatSelectableModel,
6717
- canonicalModelId: () => canonicalModelId,
6718
- SELECTABLE_MODELS: () => SELECTABLE_MODELS,
6719
- MODEL_OWNER: () => MODEL_OWNER,
6720
- MODEL_COST_ROUTING_SUMMARY: () => MODEL_COST_ROUTING_SUMMARY,
6721
- MODEL_COST_RESEARCHED_AT: () => MODEL_COST_RESEARCHED_AT,
6722
- FALLBACK_ORDER: () => FALLBACK_ORDER,
6723
- AGENT_DISPLAY_NAME: () => AGENT_DISPLAY_NAME
6724
- });
6725
- function canonicalModelId(value) {
6726
- const trimmed = value.trim();
6727
- return SELECTABLE_MODEL_ALIASES[trimmed.toLowerCase()] ?? trimmed;
6728
- }
6729
- function formatSelectableModel(candidate) {
6730
- const tier = `${candidate.intelligenceTier[0].toUpperCase()}${candidate.intelligenceTier.slice(1)}`;
6731
- return `${candidate.agent} / \`${candidate.model}\` [${tier}-level]: ${candidate.routingSummary}`;
6732
- }
6733
- function selectableModel(value) {
6734
- const canonical = canonicalModelId(value).toLowerCase();
6735
- return SELECTABLE_MODELS.find((candidate) => candidate.model === canonical);
6736
- }
6737
- function modelOwner(model) {
6738
- if (model.startsWith("claude-"))
6739
- return "claude";
6740
- if (model.startsWith("deepseek-"))
6741
- return "maestro";
6742
- if (model.startsWith("kimi-"))
6743
- return "maestro";
6744
- if (model.startsWith("glm-"))
6745
- return "maestro";
6746
- if (model.startsWith("gpt-"))
6747
- return "codex";
6748
- return MODEL_OWNER[model];
6749
- }
6750
- function resolveModelForAgent(agent, requested, registry) {
6751
- const defaultModel = resolveDefaultModel(agent, registry.defaultModel);
6752
- if (!requested)
6753
- return defaultModel;
6754
- const candidate = canonicalModelId(requested);
6755
- const owner = modelOwner(candidate);
6756
- if (owner && owner !== agent)
6757
- return defaultModel;
6758
- return registry.validateModel(candidate) ? candidate : defaultModel;
6759
- }
6760
- function resolveCompactionExecution(agent, registry) {
6761
- const requestedModel = agent === "codex" ? "gpt-5.6-terra" : registry.defaultModel;
6762
- const model = registry.expandModelAlias(resolveModelForAgent(agent, requestedModel, registry));
6763
- const effort = registry.validateEffort("medium") ? "medium" : registry.defaultEffort;
6764
- return { model, ...effort ? { effort } : {} };
6765
- }
6766
- 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;
6767
- var init_model_catalog = __esm(() => {
6768
- init_config();
6769
- MODEL_OWNER = {
6770
- sonnet: "claude",
6771
- opus: "claude",
6772
- haiku: "claude",
6773
- fable: "claude",
6774
- "gpt-6-astra": "codex",
6775
- "gpt-5.6-luna": "codex",
6776
- "gpt-5.6-terra": "codex",
6777
- "gpt-5.6-sol": "codex",
6778
- "gpt-5.5": "codex",
6779
- deepseek: "maestro",
6780
- "deepseek-pro": "maestro",
6781
- "deepseek-flash": "maestro",
6782
- kimi: "maestro",
6783
- "kimi-pro": "maestro",
6784
- "kimi-k3": "maestro",
6785
- "kimi-code": "maestro",
6786
- "kimi-k2.7-code": "maestro",
6787
- glm: "maestro",
6788
- "glm-pro": "maestro",
6789
- "glm-flash": "maestro",
6790
- "glm-5.3": "maestro",
6791
- "glm-5.2": "maestro",
6792
- "glm-5.3-flash": "maestro"
6793
- };
6794
- SELECTABLE_MODELS = [
6795
- {
6796
- model: "gpt-6-astra",
6797
- agent: "codex",
6798
- description: "Newest OpenAI flagship; replaces gpt-5.6-sol as Codex's highest-capability route.",
6799
- intelligenceTier: "fable",
6800
- routingSummary: "flagship reasoning; 2x sol's input/cache cost and 1.67x its output cost; matches Fable 5.1 pricing",
6801
- accessCost: CODEX_PRO_20X_COST,
6802
- marginalTokenCost: "Codex credits (OpenAI API rate): $10/M uncached input, $1/M cached input, $12.50/M cache write, $50/M output",
6803
- 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}`
6804
- },
6805
- {
6806
- model: "gpt-5.6-sol",
6807
- agent: "codex",
6808
- description: "High-capability Codex route for demanding agentic coding work; demoted below gpt-6-astra.",
6809
- intelligenceTier: "opus",
6810
- routingSummary: "demanding coding work; 5x Codex quota cost; now second-tier behind gpt-6-astra",
6811
- accessCost: CODEX_PRO_20X_COST,
6812
- marginalTokenCost: "Codex credits: $5/M uncached input, $0.50/M cached input, $30/M output",
6813
- estimatedUsage: `Official Pro 20x range: 300\u20131,800 local messages per 5 hours; quota weight 5x Luna. ${CODEX_COMMUNITY_WEEKLY}`
6814
- },
6815
- {
6816
- model: "gpt-5.6-terra",
6817
- agent: "codex",
6818
- description: "High-capability Codex route for complex coding and reasoning.",
6819
- intelligenceTier: "opus",
6820
- routingSummary: "complex coding and reasoning; 2.5x Codex quota cost",
6821
- accessCost: CODEX_PRO_20X_COST,
6822
- marginalTokenCost: "Codex credits: $2.50/M uncached input, $0.25/M cached input, $15/M output",
6823
- estimatedUsage: `Official Pro 20x range: 400\u20132,200 local messages per 5 hours; quota weight 2.5x Luna. ${CODEX_COMMUNITY_WEEKLY}`
6824
- },
6825
- {
6826
- model: "gpt-5.6-luna",
6827
- agent: "codex",
6828
- description: "Default Codex route with strong everyday coding intelligence.",
6829
- intelligenceTier: "sonnet",
6830
- routingSummary: "everyday coding default; lowest Codex quota cost (1x)",
6831
- accessCost: CODEX_PRO_20X_COST,
6832
- marginalTokenCost: "Codex credits: $1/M uncached input, $0.10/M cached input, $6/M output",
6833
- estimatedUsage: `Official Pro 20x range: 1,000\u20135,600 local messages per 5 hours; lowest Codex quota weight (1x). ${CODEX_COMMUNITY_WEEKLY}`
6834
- },
6835
- {
6836
- model: "fable",
6837
- agent: "claude",
6838
- description: "Highest-capability Claude route (Fable 5.1) for the hardest and longest-running tasks.",
6839
- intelligenceTier: "fable",
6840
- routingSummary: "hardest long-running work; highest Claude cost; explicit request only",
6841
- accessCost: CLAUDE_MAX_20X_COST,
6842
- 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",
6843
- estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
6844
- },
6845
- {
6846
- model: "opus",
6847
- agent: "claude",
6848
- description: "High-capability Claude route for complex reasoning and tool-heavy work.",
6849
- intelligenceTier: "opus",
6850
- routingSummary: "complex reasoning and tool-heavy work; about 2.5x Sonnet marginal cost",
6851
- accessCost: CLAUDE_MAX_20X_COST,
6852
- marginalTokenCost: "Claude API/extra usage: $5/M input, $6.25/M cache write, $0.50/M cache read, $25/M output",
6853
- estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Opus uses the shared all-model weekly pool more quickly than Sonnet. No stable per-model token cap is published.`
6854
- },
6855
- {
6856
- model: "sonnet",
6857
- agent: "claude",
6858
- description: "Default Claude route for capable, efficient everyday work.",
6859
- intelligenceTier: "sonnet",
6860
- routingSummary: "capable everyday default; lowest Claude model cost",
6861
- accessCost: CLAUDE_MAX_20X_COST,
6862
- 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",
6863
- 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.`
6864
- },
6865
- {
6866
- model: "kimi-k3",
6867
- agent: "maestro",
6868
- description: "Frontier Kimi route for long-horizon coding and knowledge work.",
6869
- intelligenceTier: "fable",
6870
- routingSummary: "frontier general/coding route; 1M context; highest Maestro API cost",
6871
- accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
6872
- marginalTokenCost: "Kimi API: $3/M cache-miss input, $0.30/M cached input, $15/M output",
6873
- estimatedUsage: "No subscription token cap; pay per token. Supports a 1M-token context window."
6874
- },
6875
- {
6876
- model: "kimi-k2.7-code",
6877
- agent: "maestro",
6878
- description: "Coding-specialized Kimi route for repository-scale, long-horizon work.",
6879
- intelligenceTier: "opus",
6880
- routingSummary: "coding-specialized route; 256K context; cheaper than Kimi K3",
6881
- accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
6882
- marginalTokenCost: "Kimi API: $0.95/M cache-miss input, $0.19/M cached input, $4/M output",
6883
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 256K context window."
6884
- },
6885
- {
6886
- model: "glm-5.3",
6887
- agent: "maestro",
6888
- description: "Coding-focused GLM flagship with Opus-tier benchmark performance.",
6889
- intelligenceTier: "opus",
6890
- routingSummary: "coding-focused flagship route; 1M context; competitive with Opus-tier coding benchmarks at a fraction of the cost",
6891
- accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6892
- marginalTokenCost: "Approximate GLM API rate: $1.40/M input, $4.40/M output",
6893
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 1M-token context window; text-only input."
6894
- },
6895
- {
6896
- model: "glm-5.2",
6897
- agent: "maestro",
6898
- description: "Previous-generation GLM flagship for cost-efficient everyday work.",
6899
- intelligenceTier: "sonnet",
6900
- routingSummary: "previous-gen flagship; 1M context; cost-efficient everyday work, cheaper than glm-5.3",
6901
- accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6902
- marginalTokenCost: "Approximate GLM API rate: $0.95/M input, $3/M output",
6903
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 1M-token context window; text-only input."
6904
- },
6905
- {
6906
- model: "glm-5.3-flash",
6907
- agent: "maestro",
6908
- description: "Low-cost multimodal GLM route with native image input.",
6909
- intelligenceTier: "sonnet",
6910
- routingSummary: "cheapest GLM route; 1M context; the only GLM model with native vision/multimodal support",
6911
- accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
6912
- marginalTokenCost: "Approximate GLM API rate: $0.15/M input, $0.50/M output",
6913
- estimatedUsage: "No subscription token cap; pay per token. Always uses thinking, supports a 1M-token context window, and accepts native image input."
6914
- },
6915
- {
6916
- model: "deepseek-pro",
6917
- agent: "maestro",
6918
- description: "API-priced Sonnet-level route for cost-efficient everyday work.",
6919
- intelligenceTier: "sonnet",
6920
- routingSummary: "cost-efficient everyday work; pay-per-token, pricier than DeepSeek Flash",
6921
- accessCost: "DeepSeek V4 Pro pay-as-you-go API; no monthly subscription required",
6922
- marginalTokenCost: "DeepSeek API: $0.435/M uncached input, $0.003625/M cached input, $0.87/M output",
6923
- estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 500 requests."
6924
- },
6925
- {
6926
- model: "deepseek-flash",
6927
- agent: "maestro",
6928
- description: "Faster, cheaper DeepSeek V4 variant (DeepSeek-V4-Flash-0731) at similar Sonnet-level quality for high-volume everyday work.",
6929
- intelligenceTier: "sonnet",
6930
- routingSummary: "cheapest overall route; pay-per-token, 1M context, 5x Pro's concurrency limit",
6931
- accessCost: "DeepSeek V4 Flash pay-as-you-go API; no monthly subscription required",
6932
- marginalTokenCost: "DeepSeek API: $0.14/M uncached input, $0.0028/M cached input, $0.28/M output",
6933
- estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 2500 requests."
6934
- }
6935
- ];
6936
- SELECTABLE_MODEL_ALIASES = {
6937
- kimi: "kimi-k3",
6938
- "kimi-pro": "kimi-k3",
6939
- "kimi-code": "kimi-k2.7-code",
6940
- glm: "glm-5.3",
6941
- "glm-pro": "glm-5.3",
6942
- "glm-flash": "glm-5.3-flash"
6943
- };
6944
- FALLBACK_ORDER = {
6945
- claude: [
6946
- { agent: "maestro", model: "deepseek-pro" },
6947
- { agent: "codex", model: "gpt-5.6-luna" }
6948
- ],
6949
- codex: [
6950
- { agent: "maestro", model: "deepseek-pro" },
6951
- { agent: "claude", model: "sonnet" }
6952
- ],
6953
- maestro: [
6954
- { agent: "codex", model: "gpt-5.6-luna" },
6955
- { agent: "claude", model: "sonnet" }
6956
- ]
6957
- };
6958
- AGENT_DISPLAY_NAME = {
6959
- claude: "Claude",
6960
- codex: "Codex",
6961
- maestro: "Maestro"
6962
- };
6963
- });
6964
-
6965
6991
  // ../../packages/core/src/prompts/builders.ts
6966
6992
  import { readFileSync as readFileSync12 } from "fs";
6967
6993
  import { resolve as resolve11 } from "path";
@@ -8135,7 +8161,7 @@ function normalizeTopicState(input) {
8135
8161
  return {
8136
8162
  kind: "manager",
8137
8163
  aiMode: "always",
8138
- agent: input.agent ?? DEFAULT_AGENT_ROOM_AGENT
8164
+ agent: input.agent ?? resolveFallbackAgent()
8139
8165
  };
8140
8166
  }
8141
8167
  const requestedKind = input.kind;
@@ -8144,7 +8170,7 @@ function normalizeTopicState(input) {
8144
8170
  return {
8145
8171
  kind: "agent",
8146
8172
  aiMode: "always",
8147
- agent: input.agent ?? DEFAULT_AGENT_ROOM_AGENT
8173
+ agent: input.agent ?? resolveFallbackAgent()
8148
8174
  };
8149
8175
  }
8150
8176
  const agent = input.aiMode === "off" ? undefined : input.agent ?? undefined;
@@ -8356,8 +8382,9 @@ function reparentTopicChildren(deletedTopicId, replacementParentTopicId) {
8356
8382
  }
8357
8383
  return rows.map((row) => row.id);
8358
8384
  }
8359
- 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";
8360
8386
  var init_api_topics = __esm(async () => {
8387
+ init_config_helpers();
8361
8388
  init_constants();
8362
8389
  init_logger();
8363
8390
  await init_forum_db();
@@ -8503,19 +8530,19 @@ function ensurePersonalGeneral(userId, surface, opts = {}) {
8503
8530
  upsertTopic(existing);
8504
8531
  }
8505
8532
  if (!getApiTopicConfig(existing.id)) {
8506
- setApiTopicConfig(existing.id, { model: "deepseek-pro", modelLocked: true });
8533
+ setApiTopicConfig(existing.id, {});
8507
8534
  }
8508
8535
  return existing;
8509
8536
  }
8510
8537
  const now = new Date().toISOString();
8511
- const registry = getRegistry("maestro");
8538
+ const registry = getRegistry(FALLBACK_AGENT);
8512
8539
  const topic = {
8513
8540
  id: randomUUID5(),
8514
8541
  title: "General",
8515
8542
  description: PERSONAL_GENERAL_DESCRIPTION,
8516
8543
  kind: "manager",
8517
- agent: "maestro",
8518
- defaultModel: resolveDefaultModel("maestro", registry.defaultModel),
8544
+ agent: FALLBACK_AGENT,
8545
+ defaultModel: resolveDefaultModel(FALLBACK_AGENT, registry),
8519
8546
  defaultEffort: registry.defaultEffort ?? "medium",
8520
8547
  aiMode: "always",
8521
8548
  aiMention: false,
@@ -8526,7 +8553,7 @@ function ensurePersonalGeneral(userId, surface, opts = {}) {
8526
8553
  lastMessageAt: now
8527
8554
  };
8528
8555
  upsertTopic(topic);
8529
- setApiTopicConfig(topic.id, { model: "deepseek-pro", modelLocked: true });
8556
+ setApiTopicConfig(topic.id, {});
8530
8557
  return topic;
8531
8558
  }
8532
8559
  function isLegacySharedGeneral(topicId) {
@@ -8534,6 +8561,7 @@ function isLegacySharedGeneral(topicId) {
8534
8561
  }
8535
8562
  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.";
8536
8563
  var init_personal_general = __esm(async () => {
8564
+ init_model_catalog();
8537
8565
  await init_registry();
8538
8566
  init_config();
8539
8567
  init_constants();
@@ -8623,8 +8651,8 @@ function createArchiverRuntime(host) {
8623
8651
  }
8624
8652
  const wikiDir = host.storage.getWikiDir();
8625
8653
  const safeTopic = host.config.sanitizeTopicName(topicTitle);
8626
- const agent = params.agent ?? "claude";
8627
- const model = params.model;
8654
+ const agent = params.agent ?? FALLBACK_AGENT;
8655
+ const model = resolveWorkerModel(agent, params.model ?? definition.model, getRegistry(agent));
8628
8656
  const outputLanguage = resolveMemoryLanguage();
8629
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.";
8630
8658
  const prompt = mode === "active-topic" ? [
@@ -8661,7 +8689,7 @@ function createArchiverRuntime(host) {
8661
8689
  status: "Starting",
8662
8690
  active: true,
8663
8691
  agent,
8664
- model: model ?? definition.model,
8692
+ model,
8665
8693
  prompt,
8666
8694
  promptTitle: "Prompt",
8667
8695
  steps: [
@@ -8877,6 +8905,8 @@ function runArchiverTurn(params) {
8877
8905
  var MAX_BRIEF_ENTRIES = 8, defaultArchiverRuntime;
8878
8906
  var init_archiver = __esm(async () => {
8879
8907
  await init_agents();
8908
+ init_model_catalog();
8909
+ await init_registry();
8880
8910
  init_tool_format();
8881
8911
  await init_bus();
8882
8912
  init_config();
@@ -12577,7 +12607,7 @@ var init_token_stats = __esm(async () => {
12577
12607
  "maestro:kimi-k3": { input: 3, cacheRead: 0.3, output: 15 },
12578
12608
  "maestro:kimi-k2.7-code": { input: 0.95, cacheRead: 0.19, output: 4 },
12579
12609
  "maestro:glm-5.3": { input: 1.4, cacheRead: 1.4, output: 4.4 },
12580
- "maestro:glm-5.2": { input: 0.95, cacheRead: 0.95, output: 3 },
12610
+ "maestro:glm-5.2": { input: 1.4, cacheRead: 1.4, output: 4.4 },
12581
12611
  "maestro:glm-5.3-flash": { input: 0.15, cacheRead: 0.15, output: 0.5 },
12582
12612
  "maestro:deepseek-pro": { input: 0.435, cacheRead: 0.003625, output: 0.87 },
12583
12613
  "maestro:deepseek-flash": { input: 0.14, cacheRead: 0.0028, output: 0.28 }
@@ -13881,7 +13911,7 @@ async function compactTopicSession(topicId, userId, reason = "topic-session-comp
13881
13911
  return { text: "Topic maintenance ownership was lost. Try again.", isError: true };
13882
13912
  }
13883
13913
  cancelIdleCompactForTopic(topicId);
13884
- const agent = topic.agent ?? "maestro";
13914
+ const agent = topic.agent ?? resolveFallbackAgent();
13885
13915
  const registry = getRegistry(agent);
13886
13916
  const config = getApiTopicConfig(topicId);
13887
13917
  const model = resolveModelForAgent(agent, config?.model ?? topic.defaultModel, registry);
@@ -14012,6 +14042,7 @@ var init_session = __esm(async () => {
14012
14042
  await init_topic_cleanup();
14013
14043
  await init_bus();
14014
14044
  init_config();
14045
+ init_config_helpers();
14015
14046
  init_logger();
14016
14047
  init_mcp_config();
14017
14048
  await init_active_rooms();
@@ -17102,7 +17133,7 @@ var init_turn_event_stream = __esm(async () => {
17102
17133
  // ../../packages/core/src/runtime/turn-session.ts
17103
17134
  function resolveTopicTurnExecution(topic, overrides = {}) {
17104
17135
  const config = getTopicConfig(topic.id);
17105
- const agent = overrides.agentOverride ?? topic.agent ?? "maestro";
17136
+ const agent = overrides.agentOverride ?? topic.agent ?? resolveFallbackAgent();
17106
17137
  const registry = getRegistry(agent);
17107
17138
  const usesTopicDefaults = !overrides.agentOverride || overrides.agentOverride === topic.agent;
17108
17139
  const model = resolveModelForAgent(agent, overrides.modelOverride ?? (usesTopicDefaults ? config?.model ?? topic.defaultModel : undefined), registry);
@@ -17129,6 +17160,7 @@ function resolveInitialTurnSessionId(topicId, requestedSessionId, isolated) {
17129
17160
  var init_turn_session = __esm(async () => {
17130
17161
  init_model_catalog();
17131
17162
  await init_registry();
17163
+ init_config_helpers();
17132
17164
  await init_topic_config();
17133
17165
  await init_api_topics();
17134
17166
  });
@@ -17175,6 +17207,8 @@ __export(exports_turn_runner, {
17175
17207
  startAiTurn: () => startAiTurn,
17176
17208
  selectableModel: () => selectableModel,
17177
17209
  safeAttachmentFilename: () => safeAttachmentFilename,
17210
+ resolveWorkerModel: () => resolveWorkerModel,
17211
+ resolveWorkerDefaultModel: () => resolveWorkerDefaultModel,
17178
17212
  resolveWikiMirrorPath: () => resolveWikiMirrorPath,
17179
17213
  resolveWikiMemoryMirror: () => resolveWikiMemoryMirror,
17180
17214
  resolveVisualMediaInput: () => resolveVisualMediaInput,
@@ -17185,6 +17219,7 @@ __export(exports_turn_runner, {
17185
17219
  resolveSessionRetry: () => resolveSessionRetry,
17186
17220
  resolveModelForAgent: () => resolveModelForAgent,
17187
17221
  resolveInitialTurnSessionId: () => resolveInitialTurnSessionId,
17222
+ resolveDefaultModel: () => resolveDefaultModel,
17188
17223
  resolveCompactionExecution: () => resolveCompactionExecution,
17189
17224
  renderUserTurnBatch: () => renderUserTurnBatch,
17190
17225
  renderUserPromptBatch: () => renderUserPromptBatch,
@@ -19827,6 +19862,7 @@ init_model_catalog();
19827
19862
  await init_registry();
19828
19863
  await init_bus();
19829
19864
  init_config();
19865
+ init_config_helpers();
19830
19866
  await init_api_topic_config();
19831
19867
  await init_api_topics();
19832
19868
  await init_self_schedules();
@@ -19939,7 +19975,7 @@ function createSelfConfigCore(host, productOverrides = {}) {
19939
19975
  return topic;
19940
19976
  }
19941
19977
  function currentAgent(topic) {
19942
- return topic.agent ?? "maestro";
19978
+ return topic.agent ?? resolveFallbackAgent();
19943
19979
  }
19944
19980
  function setModel(ctx, model) {
19945
19981
  const topic = requireTopic(ctx);
@@ -20668,4 +20704,4 @@ export {
20668
20704
  DEFAULT_SELF_CONFIG_PRODUCT
20669
20705
  };
20670
20706
 
20671
- //# debugId=631A95CB99797D8064756E2164756E21
20707
+ //# debugId=D82D807A0D54D0E864756E2164756E21