@zergai/ztc 0.18.1-dev.202611101951 → 0.18.3-dev.202611111137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +6 -3
  2. package/bin/zmux-darwin-arm64 +0 -0
  3. package/bin/ztc-audio-darwin-arm64 +0 -0
  4. package/bin/ztc-capture-darwin-arm64 +0 -0
  5. package/bin/ztc-tui-darwin-arm64 +0 -0
  6. package/bin/zterm-darwin-arm64 +2 -2
  7. package/dist/App.js +3 -1
  8. package/dist/agent/backends/index.js +14 -5
  9. package/dist/agent/backends/provider_ids.d.ts +13 -0
  10. package/dist/agent/backends/provider_ids.js +19 -0
  11. package/dist/agent/commands/config.d.ts +8 -3
  12. package/dist/agent/commands/config.js +72 -23
  13. package/dist/agent/commands/credential_status.js +23 -12
  14. package/dist/agent/commands/index.js +2 -1
  15. package/dist/agent/commands/model.js +26 -13
  16. package/dist/agent/commands/models.js +25 -7
  17. package/dist/agent/commands/provider.d.ts +22 -0
  18. package/dist/agent/commands/provider.js +285 -0
  19. package/dist/agent/commands/provider_choices.d.ts +74 -1
  20. package/dist/agent/commands/provider_choices.js +105 -6
  21. package/dist/agent/commands/provider_selection.d.ts +18 -0
  22. package/dist/agent/commands/provider_selection.js +77 -13
  23. package/dist/agent/commands/reasoning_settings.d.ts +1 -1
  24. package/dist/agent/commands/reasoning_settings.js +5 -5
  25. package/dist/agent/commands/runtime_model.d.ts +16 -1
  26. package/dist/agent/commands/runtime_model.js +24 -3
  27. package/dist/agent/commands/settings.js +43 -20
  28. package/dist/agent/commands/types.d.ts +25 -1
  29. package/dist/agent/factory.js +9 -5
  30. package/dist/app/agent_runner.js +8 -3
  31. package/dist/app/command_context.js +31 -15
  32. package/dist/app/model_catalog_cache.d.ts +5 -0
  33. package/dist/app/model_catalog_cache.js +13 -0
  34. package/dist/app/runtime_choices.d.ts +38 -0
  35. package/dist/app/runtime_choices.js +66 -0
  36. package/dist/app/selection_completion.d.ts +5 -0
  37. package/dist/app/selection_completion.js +35 -2
  38. package/dist/cli_ratatui.d.ts +26 -6
  39. package/dist/cli_ratatui.js +126 -54
  40. package/dist/config/defaults.d.ts +5 -2
  41. package/dist/config/defaults.js +8 -4
  42. package/dist/config/provider_models.d.ts +22 -0
  43. package/dist/config/provider_models.js +83 -0
  44. package/dist/config.d.ts +39 -6
  45. package/dist/config.js +90 -14
  46. package/dist/headless.js +10 -3
  47. package/dist/headless_cli.js +21 -2
  48. package/dist/headless_cli_args.js +2 -10
  49. package/dist/onboarding/setup_agent_health.js +4 -0
  50. package/dist/panes/ztc_launch.js +3 -2
  51. package/dist/utils/reasoning.d.ts +5 -0
  52. package/dist/utils/reasoning.js +7 -3
  53. package/dist/zlm-embed.mjs +154 -38
  54. package/package.json +24 -4
package/README.md CHANGED
@@ -1410,9 +1410,12 @@ credentials. Panes need zmux (plain `ztc`) or the desktop app.
1410
1410
  test`); text that starts with a flag goes to the CLI as its arguments
1411
1411
  (`/claude --continue`, `/codex -m gpt-5 "review the diff"`).
1412
1412
  - Ctrl+B c offers Claude Code and Codex next to bash and ZTC when they are
1413
- installed. In the desktop app, the tab strip's + opens a menu: New ZTC Pane,
1414
- New Claude Code Pane, New Codex Pane, New Shell Pane. Cmd+T still opens a ZTC
1415
- tab directly.
1413
+ installed. In the desktop app, the tab strip's + opens a ZTC tab, as Cmd+T
1414
+ does. The ▾ beside it, or a right-click or Ctrl-click on +, opens New tab and
1415
+ Split focused pane, each for ZTC, Claude Code, Codex and Shell.
1416
+ Ctrl+Cmd+A and Ctrl+Cmd+O split the focused pane with Claude Code and Codex
1417
+ (Ctrl+Cmd+Z with ZTC, Cmd+D with a shell; Shift splits down), and Ctrl+Cmd+N
1418
+ opens the menu at the focused pane.
1416
1419
 
1417
1420
  Each of these panes starts with ZTC's workspace MCP server (`ztc
1418
1421
  workspace-mcp`) attached for that session only, through Claude Code's
Binary file
Binary file
Binary file
Binary file
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/zterm-darwin-arm64
3
- size: 33730352 bytes
4
- sha256: 4fbee405314701e3f4054343ddb2f63ae1f03a6d730cc9e6b37b0d36f5b1a6f0
3
+ size: 33779680 bytes
4
+ sha256: 892553d58a2390d8c034f4b8f3d9eadde91f4454589e6e5aa2cb0385a1b7c906
package/dist/App.js CHANGED
@@ -62,6 +62,7 @@ import { compactMessages, localSummarizer } from './utils/compaction.js';
62
62
  import { speak, optionsFromConfig, isProviderAvailable } from './utils/tts.js';
63
63
  import { applyAgentEventToState, buildActivityDisplayState, formatApiRetryNotice, getAgentActivityPlaceholder } from './app/activity.js';
64
64
  import { buildCredentialSetupMessage, buildNoCredentialsWelcome, buildReadyWelcome, createFirstRunLaunchMessage, isFirstRunWelcomeMessage, } from './onboarding/first_run.js';
65
+ import { currentRouterOnlyModelError } from './agent/commands/provider_choices.js';
65
66
  // --- Utilities ---
66
67
  const generateId = () => Math.random().toString(36).slice(2, 11);
67
68
  const ESCAPE_CONFIRMATION_HINT = 'Esc again to stop';
@@ -1796,7 +1797,8 @@ export const App = () => {
1796
1797
  addMessage({ role: 'user', content: text });
1797
1798
  addMessage({
1798
1799
  role: 'system',
1799
- content: buildCredentialSetupMessage(),
1800
+ // A model only Zerg Router serves needs no key here: it names itself and the step that reaches it.
1801
+ content: currentRouterOnlyModelError(configStore)?.message ?? buildCredentialSetupMessage(),
1800
1802
  });
1801
1803
  return;
1802
1804
  }
@@ -27,7 +27,7 @@ import { CodexAuthManager, CodexAuthBackend } from './codex_auth.js';
27
27
  import { ClarifaiBackend } from './clarifai.js';
28
28
  import { KimiCodeAuthBackend, KimiCodeAuthManager } from './kimi_code_auth.js';
29
29
  import { ZRouterStreamBackend } from './zrouter_stream.js';
30
- import { CODEX_APP_SERVER_PROVIDER, CODEX_LEGACY_PROVIDER, normalizeProviderId } from './provider_ids.js';
30
+ import { CODEX_APP_SERVER_PROVIDER, CODEX_LEGACY_PROVIDER, isDirectBackendProvider, normalizeProviderId } from './provider_ids.js';
31
31
  import { writeBackendTrace } from './trace.js';
32
32
  import { assertProviderNotRetired } from '../../config/retired_routes.js';
33
33
  export class TracedBackend {
@@ -128,10 +128,17 @@ export function createBackendForProvider(provider, opts) {
128
128
  // sign-in for Claude Code itself. Say where to go instead of "unknown provider".
129
129
  assertProviderNotRetired(provider);
130
130
  const resolvedProvider = normalizeProviderId(provider);
131
+ if (resolvedProvider === 'modal') {
132
+ throw new Error('Modal requires a Zerg Router backend. Run ztc auth login and use the routed agent factory.');
133
+ }
134
+ if (!isDirectBackendProvider(resolvedProvider)) {
135
+ throw new Error(`Unknown provider: ${provider}. Select a Router integration or a supported direct provider.`);
136
+ }
137
+ // Typed against DIRECT_BACKEND_PROVIDERS: a case missing from the list, or a
138
+ // listed provider with no case, does not compile, so hasDirectBackend and
139
+ // this switch cannot disagree.
131
140
  switch (resolvedProvider) {
132
141
  case 'bedrock': return traced(provider, new BedrockBackend(opts.bedrock));
133
- case 'modal':
134
- throw new Error('Modal requires a Zerg Router backend. Run ztc auth login and use the routed agent factory.');
135
142
  case 'openai':
136
143
  return traced(provider, new OpenAIBackend({ apiKey: opts.apiKey, apiEndpoint: opts.apiEndpoint }));
137
144
  case 'gemini':
@@ -194,7 +201,9 @@ export function createBackendForProvider(provider, opts) {
194
201
  case 'anthropic':
195
202
  case 'claude':
196
203
  return traced(provider, new AnthropicBackend({ apiKey: opts.apiKey, apiEndpoint: opts.apiEndpoint }));
197
- default:
198
- throw new Error(`Unknown provider: ${provider}. Select a Router integration or a supported direct provider.`);
204
+ default: {
205
+ const unbuilt = resolvedProvider;
206
+ throw new Error(`Unknown provider: ${String(unbuilt)}. Select a Router integration or a supported direct provider.`);
207
+ }
199
208
  }
200
209
  }
@@ -13,3 +13,16 @@ export declare function getProviderDisplayName(provider: string): string;
13
13
  * route direct, never through Zerg Router, and switch accounts in /accounts.
14
14
  */
15
15
  export declare function isLocalSubscriptionProvider(provider: string): boolean;
16
+ /**
17
+ * Every provider id createBackendForProvider builds a backend for, in each
18
+ * spelling it accepts (after normalizeProviderId). Its switch is typed against
19
+ * this list, so the compiler keeps the two the same. Modal is not here: its
20
+ * endpoints run only through Zerg Router, like every provider Router serves
21
+ * that ZTC has no backend of its own for.
22
+ */
23
+ export declare const DIRECT_BACKEND_PROVIDERS: readonly ["bedrock", "openai", "gemini", "inception", "openai_compatible", "kimi", "moonshot", "deepseek", "fireworks", "clarifai", "codex_app_server", "codex_legacy", "kimi_code", "kimi-code", "anthropic", "claude"];
24
+ export type DirectBackendProvider = (typeof DIRECT_BACKEND_PROVIDERS)[number];
25
+ /** True when `id`, already normalized, names a provider ZTC builds a backend for itself. */
26
+ export declare function isDirectBackendProvider(id: string): id is DirectBackendProvider;
27
+ /** True when ZTC can reach `provider` without Zerg Router, with a key, an endpoint or a local login. */
28
+ export declare function hasDirectBackend(provider: string): boolean;
@@ -46,3 +46,22 @@ export function isLocalSubscriptionProvider(provider) {
46
46
  return ['codex_app_server', 'codex_legacy', 'kimi_code', 'kimi-code']
47
47
  .includes(normalizeProviderId(provider));
48
48
  }
49
+ /**
50
+ * Every provider id createBackendForProvider builds a backend for, in each
51
+ * spelling it accepts (after normalizeProviderId). Its switch is typed against
52
+ * this list, so the compiler keeps the two the same. Modal is not here: its
53
+ * endpoints run only through Zerg Router, like every provider Router serves
54
+ * that ZTC has no backend of its own for.
55
+ */
56
+ export const DIRECT_BACKEND_PROVIDERS = [
57
+ 'bedrock', 'openai', 'gemini', 'inception', 'openai_compatible', 'kimi', 'moonshot', 'deepseek', 'fireworks',
58
+ 'clarifai', CODEX_APP_SERVER_PROVIDER, CODEX_LEGACY_PROVIDER, 'kimi_code', 'kimi-code', 'anthropic', 'claude',
59
+ ];
60
+ /** True when `id`, already normalized, names a provider ZTC builds a backend for itself. */
61
+ export function isDirectBackendProvider(id) {
62
+ return DIRECT_BACKEND_PROVIDERS.includes(id);
63
+ }
64
+ /** True when ZTC can reach `provider` without Zerg Router, with a key, an endpoint or a local login. */
65
+ export function hasDirectBackend(provider) {
66
+ return isDirectBackendProvider(normalizeProviderId(provider));
67
+ }
@@ -1,4 +1,4 @@
1
- import { Command } from './types.js';
1
+ import { Command, type ConfigController } from './types.js';
2
2
  import { type ZTCAuthMode } from '../../config/types.js';
3
3
  import type { ResolvedLLMConfig } from '../../config/resolved.js';
4
4
  /**
@@ -11,8 +11,13 @@ import type { ResolvedLLMConfig } from '../../config/resolved.js';
11
11
  * dishonest "✓".
12
12
  */
13
13
  export declare function isBuildableResolvedConfig(resolved: ResolvedLLMConfig): boolean;
14
- /** Actionable error shown when a provider/model switch can't build a backend. */
15
- export declare function unbuildableSelectionMessage(provider: string): string;
14
+ /**
15
+ * Actionable error shown when a provider/model switch can't build a backend.
16
+ * `route` is the switch as it resolved: for a provider only Zerg Router serves,
17
+ * its routing mode says which step reaches it, and `config` reads Router's
18
+ * cached catalog, which can say Router serves it.
19
+ */
20
+ export declare function unbuildableSelectionMessage(provider: string, route?: Pick<ResolvedLLMConfig, 'model' | 'authMode'>, config?: Pick<ConfigController, 'getRouterCatalog'>): string;
16
21
  export declare function parseConfigKeyArgs(args: string[], currentProvider: string): {
17
22
  provider: string;
18
23
  apiKey: string;
@@ -6,20 +6,21 @@ import { openFactoryResetConfirmation, settingsCommand } from './settings.js';
6
6
  import { contextProgressBarConfig, normalizeBarColor, publishContextProgressBar, withBarColor, } from './context_progress_bar.js';
7
7
  import { compatEndpoint, DEFAULT_CONTEXT_PROGRESS_BAR, maskApiKey } from '../../config.js';
8
8
  import { parseGoalTurnCap } from './goal.js';
9
- import { getSupportedCodexReasoningEfforts, isCodexReasoningEffortSupported, unsupportedEffortMessage, } from '../../utils/models.js';
9
+ import { getSupportedCodexReasoningEfforts, unsupportedEffortMessage, } from '../../utils/models.js';
10
10
  import { modelForProviderSwitch } from './provider_model_defaults.js';
11
11
  import { CLAUDE_CODE_TOKEN_MESSAGE, isClaudeCodeToken, isRetiredProvider, retiredProviderMessage } from '../../config/retired_routes.js';
12
12
  import { applyRuntimeModelSelection, getEffectiveModel } from './runtime_model.js';
13
13
  import { shutdownAndClearWorkflowRegistry } from '../../workflows/registry_handle.js';
14
14
  import { formatRate } from '../../utils/openrouter_prices.js';
15
- import { API_KEY_PROVIDER_CHOICES, canonicalProvider, describeKeySource, isLocalSubscription, PROVIDER_CHOICES, } from './provider_choices.js';
15
+ import { API_KEY_PROVIDER_CHOICES, canonicalProvider, describeKeySource, isLocalSubscription, isRouterOnlyProvider, PROVIDER_CHOICES, routerOnlyModelError, } from './provider_choices.js';
16
16
  import { canAskForCredential, manageApiKey, promptForMissingDirectKey, removeApiKey, savedKeyNotes, useApiKeyVariable, } from './direct_credential_prompt.js';
17
17
  import { looksLikeApiKeyEnvName } from '../../config/provider_api_key_env.js';
18
18
  import { offerKeyedProviderSwitch } from './provider_selection.js';
19
19
  import { connectionStatusLines } from './credential_status.js';
20
20
  import { normalizeProviderId } from '../backends/provider_ids.js';
21
- import { resolveCodexEffort } from '../../config/defaults.js';
22
- import { formatReasoningEffort } from '../../utils/reasoning.js';
21
+ import { unsupportedCodexEffort } from '../../config/defaults.js';
22
+ import { activeReasoning } from './reasoning_settings.js';
23
+ import { formatReasoningEffort, reasoningContractChoices } from '../../utils/reasoning.js';
23
24
  import { DEFAULT_MESSAGE_DISPLAY, MIN_TOOL_OUTPUT_LINES, parseToolOutputLines, resolveMessageDisplaySettings, } from '../../config/message_display.js';
24
25
  import { DEFAULT_STATUS_LINE_SETTINGS, STATUS_LINE_ITEMS, STATUS_LINE_ITEM_DESCRIPTIONS, STATUS_LINE_VARIANTS, compactStatusLineVariants, formatStatusLineSettings, normalizeStatusLineSeparator, parseStatusLineItems, parseStatusLineVariant, resolveStatusLineSettings, resolveStatusLineVariants, statusLineSettingsForStorage, } from '../../ui/status_line_config.js';
25
26
  import { offerReasoningPicker } from './reasoning_picker.js';
@@ -33,7 +34,10 @@ import { offerReasoningPicker } from './reasoning_picker.js';
33
34
  * dishonest "✓".
34
35
  */
35
36
  export function isBuildableResolvedConfig(resolved) {
36
- if (resolved.provider === 'modal')
37
+ // Modal, and any provider ZTC has no backend of its own for, runs only through
38
+ // Zerg Router, whatever key is set here (one lent from another provider's
39
+ // variable included): the factory refuses any other route.
40
+ if (isRouterOnlyProvider(resolved.provider))
37
41
  return resolved.useProxy;
38
42
  const directKeyAvailable = Boolean(resolved.apiKey && resolved.apiKey.length > 0)
39
43
  || (resolved.provider === 'openai_compatible' && Boolean(resolved.compatBaseUrl));
@@ -44,11 +48,42 @@ export function isBuildableResolvedConfig(resolved) {
44
48
  // Platform-authenticated ZergAPI fallback — only when routing isn't forced direct.
45
49
  return resolved.authMode !== 'direct' && Boolean(resolved.authToken);
46
50
  }
47
- /** Actionable error shown when a provider/model switch can't build a backend. */
48
- export function unbuildableSelectionMessage(provider) {
49
- if (provider === 'modal' || provider === 'zergrouter') {
50
- return `Can't switch to ${provider}: it runs through Zerg Router. Log in with ZergAI (/auth login). Keeping the current selection.`;
51
- }
51
+ /**
52
+ * A Router model's reasoning levels, for its own `/config effort model`
53
+ * setting: its catalog row's, read through the contract of the route it runs
54
+ * on (getReasoningContract), whatever model is active. A provider only Zerg
55
+ * Router serves has no other route, so its row's levels hold while its route
56
+ * isn't Router too (the session expired, or routing is set to direct).
57
+ * Undefined for a model with no Router row, or one of a provider with a route
58
+ * of its own that isn't Zerg Router now.
59
+ */
60
+ function routerModelChoices(ctx, model) {
61
+ const catalog = ctx.config.getRouterCatalog?.();
62
+ const rows = catalog?.version === 1 ? catalog.models.filter(row => row.id === model) : [];
63
+ const owners = [...new Set(rows.map(row => row.owned_by))];
64
+ if (owners.length !== 1)
65
+ return undefined;
66
+ if (isRouterOnlyProvider(owners[0]))
67
+ return rows[0].capabilities?.reasoning?.choices ?? [];
68
+ const contract = ctx.config.getReasoningContract?.(owners[0], model);
69
+ return contract === undefined || typeof contract === 'string' ? undefined : reasoningContractChoices(owners[0], model, contract);
70
+ }
71
+ /** The levels any of `provider`'s rows in Router's cached catalog takes, as Router spells them. */
72
+ function routerProviderChoices(ctx, provider) {
73
+ const catalog = ctx.config.getRouterCatalog?.();
74
+ return catalog?.version === 1
75
+ ? catalog.models.filter(row => row.owned_by === provider).flatMap(row => row.capabilities?.reasoning?.choices ?? []) : [];
76
+ }
77
+ /**
78
+ * Actionable error shown when a provider/model switch can't build a backend.
79
+ * `route` is the switch as it resolved: for a provider only Zerg Router serves,
80
+ * its routing mode says which step reaches it, and `config` reads Router's
81
+ * cached catalog, which can say Router serves it.
82
+ */
83
+ export function unbuildableSelectionMessage(provider, route, config) {
84
+ const routerOnly = routerOnlyModelError({ provider, model: route?.model ?? '', useProxy: false, authMode: route?.authMode ?? 'auto' }, config);
85
+ if (routerOnly)
86
+ return `Can't switch to ${provider}: it ${routerOnly.reason}. ${routerOnly.step}. Keeping the current selection.`;
52
87
  if (isLocalSubscription(provider)) {
53
88
  return `Can't switch to ${provider}: sign in through /accounts. Keeping the current selection.`;
54
89
  }
@@ -193,7 +228,7 @@ async function setConfigProvider(value, ctx, credentialPrompted = false) {
193
228
  if (!isBuildableResolvedConfig(llm)) {
194
229
  if (!credentialPrompted && promptForMissingDirectKey(llm, ctx, () => setConfigProvider(provider, ctx, true)))
195
230
  return;
196
- ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider) });
231
+ ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider, llm, ctx.config) });
197
232
  return;
198
233
  }
199
234
  }
@@ -229,7 +264,7 @@ async function setConfigModel(value, ctx, credentialPrompted = false) {
229
264
  if (!isBuildableResolvedConfig(llm)) {
230
265
  if (!credentialPrompted && promptForMissingDirectKey(llm, ctx, () => setConfigModel(value, ctx, true)))
231
266
  return;
232
- ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(activeProvider) });
267
+ ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(activeProvider, llm, ctx.config) });
233
268
  return;
234
269
  }
235
270
  ctx.config.set('model', value);
@@ -1046,15 +1081,24 @@ Usage: /config context-progress-bar <enabled|accent|warning|critical|track|reset
1046
1081
  : CODEX_REASONING_EFFORTS;
1047
1082
  const CLEAR_WORDS = ['clear', 'default', 'unset', 'reset'];
1048
1083
  const config = ctx.config.get();
1049
- const activeEffort = () => `Active (${config.provider} · ${config.model}): ${formatReasoningEffort(resolveCodexEffort(ctx.config.get(), config.provider, config.model))}`;
1084
+ // The active model's effort as its route applies it, as the status line reads it: a saved
1085
+ // level its Router row lacks is not applied, and says so.
1086
+ const activeEffort = () => {
1087
+ const { provider, model, current, contract } = activeReasoning(ctx);
1088
+ const notApplied = unsupportedCodexEffort(ctx.config.get(), provider, model, contract);
1089
+ return `Active (${provider} · ${model}): ${formatReasoningEffort(current)}`
1090
+ + (notApplied ? ` (${notApplied} not applied: this model doesn't take it)` : '');
1091
+ };
1050
1092
  const [scope, ...scopeRest] = rest;
1051
1093
  const scopeKey = (scope ?? '').toLowerCase();
1052
- const parseLevel = (raw) => {
1094
+ const parseLevel = (raw, levels = EFFORT_LEVELS) => {
1053
1095
  const v = raw.toLowerCase();
1054
1096
  if (CLEAR_WORDS.includes(v))
1055
1097
  return null; // explicit clear
1056
- if (EFFORT_LEVELS.includes(v))
1057
- return v;
1098
+ // A Router row may spell a level its own way; it is saved as the row spells it.
1099
+ const level = levels.find(choice => choice.toLowerCase() === v);
1100
+ if (level !== undefined)
1101
+ return level;
1058
1102
  return undefined; // invalid
1059
1103
  };
1060
1104
  // `/config effort` with no args → show current global + per-provider/model.
@@ -1095,19 +1139,24 @@ Usage: /config context-progress-bar <enabled|accent|warning|critical|track|reset
1095
1139
  // Per-model / per-provider form.
1096
1140
  if (scopeKey === 'model' || scopeKey === 'provider') {
1097
1141
  const [target, levelArg] = scopeRest;
1142
+ // A model's own setting takes that model's levels, never the active
1143
+ // model's: a Router model's are its catalog row's. A provider's takes
1144
+ // any level one of its models may, as Router spells its rows' too.
1145
+ const rowChoices = scopeKey === 'model' && target ? routerModelChoices(ctx, target) : undefined;
1146
+ const levels = scopeKey === 'model' ? rowChoices ?? CODEX_REASONING_EFFORTS
1147
+ : [...new Set([...CODEX_REASONING_EFFORTS, ...(target ? routerProviderChoices(ctx, target) : [])])];
1098
1148
  if (!target || !levelArg) {
1099
- ctx.addMessage({ role: 'system', content: `Usage: /config effort ${scopeKey} <${scopeKey}> <${EFFORT_LEVELS.join('|')}|clear>` });
1149
+ ctx.addMessage({ role: 'system', content: `Usage: /config effort ${scopeKey} <${scopeKey}> <${levels.join('|')}|clear>` });
1100
1150
  return;
1101
1151
  }
1102
- const level = parseLevel(levelArg);
1152
+ const level = parseLevel(levelArg, scopeKey === 'model' ? [...levels, ...CODEX_REASONING_EFFORTS] : levels);
1103
1153
  if (level === undefined) {
1104
- ctx.addMessage({ role: 'system', content: `Invalid effort "${levelArg}". Choose: ${EFFORT_LEVELS.join(', ')} (or clear).` });
1154
+ ctx.addMessage({ role: 'system', content: `Invalid effort "${levelArg}". Choose: ${levels.join(', ')} (or clear).` });
1105
1155
  return;
1106
1156
  }
1107
- if (scopeKey === 'model'
1108
- && level !== null
1109
- && !isCodexReasoningEffortSupported(undefined, target, level)) {
1110
- const supported = getSupportedCodexReasoningEfforts(target) ?? [];
1157
+ // Any other model keeps the reviewed tables, which know it under every provider it runs on.
1158
+ const supported = scopeKey === 'model' ? rowChoices ?? getSupportedCodexReasoningEfforts(target) : undefined;
1159
+ if (level !== null && supported !== undefined && !supported.includes(level)) {
1111
1160
  ctx.addMessage({
1112
1161
  role: 'system',
1113
1162
  content: unsupportedEffortMessage(target, level, supported),
@@ -30,13 +30,16 @@ export function describeActiveRoute(config) {
30
30
  const provider = config.getProvider();
31
31
  try {
32
32
  const llm = config.resolveLLMBackendConfig();
33
+ // A provider only Zerg Router serves reaches no model on any other route, whatever key is set here.
34
+ const offRouter = !llm.useProxy && isRouterOnlyProvider(llm.provider);
33
35
  const ready = isBuildableResolvedConfig(llm);
34
36
  // A custom endpoint may carry a key, but the endpoint is what it connects to.
35
37
  const kind = isLocalSubscription(provider) ? 'local-login'
36
38
  : llm.useProxy ? 'router'
37
- : provider === 'openai_compatible' && llm.compatBaseUrl ? 'endpoint'
38
- : llm.apiKey ? 'api-key'
39
- : ready ? 'platform' : 'none';
39
+ : offRouter ? 'none'
40
+ : provider === 'openai_compatible' && llm.compatBaseUrl ? 'endpoint'
41
+ : llm.apiKey ? 'api-key'
42
+ : ready ? 'platform' : 'none';
40
43
  return { kind, route: ROUTE_NAMES[kind], ready };
41
44
  }
42
45
  catch (error) {
@@ -60,17 +63,25 @@ export function readinessLine(config, route = describeActiveRoute(config)) {
60
63
  const provider = config.getProvider();
61
64
  const session = config.getRouterSessionStatus?.() ?? 'signed_out';
62
65
  const mode = routingMode(config);
63
- const needsRouter = session !== 'signed_in' && (mode === 'zrouter' || isRouterOnlyProvider(provider));
64
- const reason = needsRouter
65
- ? `${mode === 'zrouter' ? 'routing is Zerg Router only' : `${provider} runs through Zerg Router`} and ${session === 'expired' ? 'your ZergAI session expired' : 'you are not logged in with ZergAI'}`
66
- : isLocalSubscription(provider) ? `${provider} is not signed in on this machine`
67
- : provider === 'openai_compatible' ? 'the custom endpoint is not set up'
68
- : `${provider} has no API key here`;
66
+ const routerOnly = isRouterOnlyProvider(provider);
67
+ // Routing set to direct keeps a provider only Zerg Router serves off Router
68
+ // whether or not ZTC is logged in: no login, and no key here, reaches it.
69
+ const routingDirect = routerOnly && mode === 'direct';
70
+ const needsRouter = !routingDirect && session !== 'signed_in' && (mode === 'zrouter' || routerOnly);
71
+ const reason = routingDirect ? `${provider} runs through Zerg Router and routing is set to direct (local keys only)`
72
+ : needsRouter
73
+ ? `${mode === 'zrouter' ? 'routing is Zerg Router only' : `${provider} runs through Zerg Router`} and ${session === 'expired' ? 'your ZergAI session expired' : 'you are not logged in with ZergAI'}`
74
+ : isLocalSubscription(provider) ? `${provider} is not signed in on this machine`
75
+ : provider === 'openai_compatible' ? 'the custom endpoint is not set up'
76
+ : `${provider} has no API key here`;
77
+ const step = routingDirect ? 'set Routing to auto in /config' : needsRouter ? 'log in with /auth login' : 'add a key in /keys';
69
78
  // When routing is the block, the selected provider's own key counts too.
70
- const ready = modelRouteStatus(config).directProviders.filter(id => needsRouter || id !== provider);
79
+ const ready = modelRouteStatus(config).directProviders.filter(id => routingDirect || needsRouter || id !== provider);
71
80
  const next = ready.length > 0
72
- ? `Ready on this machine: ${ready.join(', ')}. Switch with /model direct ${ready[0]}, or ${needsRouter ? 'log in with /auth login' : 'add a key in /keys'}.`
73
- : needsRouter ? 'Log in with /auth login, or add an API key in /keys.' : 'Add a key in /keys, or log in with ZergAI (/auth login).';
81
+ ? `Ready on this machine: ${ready.join(', ')}. Switch with /model direct ${ready[0]}, or ${step}.`
82
+ // Neither a login nor a key here reaches it, only routing set back to auto.
83
+ : routingDirect ? 'Set Routing to auto in /config, or choose another model with /model.'
84
+ : needsRouter ? 'Log in with /auth login, or add an API key in /keys.' : 'Add a key in /keys, or log in with ZergAI (/auth login).';
74
85
  return `No - ${reason}. ${next}`;
75
86
  }
76
87
  /**
@@ -16,6 +16,7 @@ import { shellCommand, cdCommand } from './shell.js';
16
16
  import { clipboardCommand } from './clipboard.js';
17
17
  import { modelsCommand } from './models.js';
18
18
  import { modelCommand } from './model.js';
19
+ import { providerCommand } from './provider.js';
19
20
  import { permissionsCommand } from './permissions.js';
20
21
  import { resourcesCommand } from './resources.js';
21
22
  import { skillsCommand } from './skills.js';
@@ -84,7 +85,7 @@ import { effortCommand, thinkingCommand, reasoningCommand, fastCommand } from '.
84
85
  import { runtimePluginRegistry } from '../../plugin/runtime_registry.js';
85
86
  const commandList = [];
86
87
  const helpCommand = makeHelpCommand(() => commandList);
87
- commandList.push(helpCommand, authCommand, loginCommand, logoutCommand, accountsCommand, zergCommand, zergsCommand, configCommand, debugCommand, clearCommand, handoffCommand, statusCommand, runtimeCommand, environmentCommand, jobCommand, shareCommand, hooksCommand, emulationCommand, shellCommand, cdCommand, clipboardCommand, modelsCommand, modelCommand, permissionsCommand, resourcesCommand, initCommand, forkCommand, sideCommand, claudeCommand, codexCommand, subsCommand, diffCommand, rawCommand, themeCommand, doctorCommand, intentCommand, profileCommand, skillsCommand, runbooksCommand, keybindingsCommand, keymapCommand, shortcutsCommand, updateCommand, desktopCommand, layoutCommand, setupCommand, connectCommand, keysCommand, restartCommand, reloadCommand, inputModeCommand, retryCommand, dictationStatusCommand, embeddedCommand, benchCommand, voiceCommand, sfxCommand, compactCommand, automodeCommand, sessionsCommand, resumeCommand, rewindCommand, renameCommand, labelCommand, inboxCommand, attentionCommand, contextCommand, evidenceCommand, boardCommand, usageCommand, shannonRunnerCommand, planCommand, executeCommand, modeCommand, modeListCommand, exitModeCommand, validateCommand, previewCommand, saveCommand, dcaigCommand, manifestCommand, swarmCommand, swarmStopCommand, swarmStatusCommand, superviseCommand, superviseStopCommand, superviseStatusCommand, zlickyCommand, zlickyStopCommand, zlickyStatusCommand, zlickyActCommand, zlickyPresenceCommand, zlickyPttCommand, simCommand, simStopCommand, simStatusCommand, simRunCommand, simCheckpointCommand, simResumeCommand, evolveCommand, evolveStopCommand, evolveStatusCommand, evolveBestCommand, optimizeCommand, batchCommand, batchStatusCommand, batchStopCommand, workflowsCommand, mirrorCommand, settingsCommand, mcpCommand, loopCommand, goalCommand, effortCommand, thinkingCommand, reasoningCommand, fastCommand, exitCommand);
88
+ commandList.push(helpCommand, authCommand, loginCommand, logoutCommand, accountsCommand, zergCommand, zergsCommand, configCommand, debugCommand, clearCommand, handoffCommand, statusCommand, runtimeCommand, environmentCommand, jobCommand, shareCommand, hooksCommand, emulationCommand, shellCommand, cdCommand, clipboardCommand, modelsCommand, modelCommand, providerCommand, permissionsCommand, resourcesCommand, initCommand, forkCommand, sideCommand, claudeCommand, codexCommand, subsCommand, diffCommand, rawCommand, themeCommand, doctorCommand, intentCommand, profileCommand, skillsCommand, runbooksCommand, keybindingsCommand, keymapCommand, shortcutsCommand, updateCommand, desktopCommand, layoutCommand, setupCommand, connectCommand, keysCommand, restartCommand, reloadCommand, inputModeCommand, retryCommand, dictationStatusCommand, embeddedCommand, benchCommand, voiceCommand, sfxCommand, compactCommand, automodeCommand, sessionsCommand, resumeCommand, rewindCommand, renameCommand, labelCommand, inboxCommand, attentionCommand, contextCommand, evidenceCommand, boardCommand, usageCommand, shannonRunnerCommand, planCommand, executeCommand, modeCommand, modeListCommand, exitModeCommand, validateCommand, previewCommand, saveCommand, dcaigCommand, manifestCommand, swarmCommand, swarmStopCommand, swarmStatusCommand, superviseCommand, superviseStopCommand, superviseStatusCommand, zlickyCommand, zlickyStopCommand, zlickyStatusCommand, zlickyActCommand, zlickyPresenceCommand, zlickyPttCommand, simCommand, simStopCommand, simStatusCommand, simRunCommand, simCheckpointCommand, simResumeCommand, evolveCommand, evolveStopCommand, evolveStatusCommand, evolveBestCommand, optimizeCommand, batchCommand, batchStatusCommand, batchStopCommand, workflowsCommand, mirrorCommand, settingsCommand, mcpCommand, loopCommand, goalCommand, effortCommand, thinkingCommand, reasoningCommand, fastCommand, exitCommand);
88
89
  export const commands = commandList;
89
90
  export function refreshPluginCommands() {
90
91
  const existing = new Set(commandList.map(command => command.name));
@@ -1,10 +1,12 @@
1
1
  import { configCommand } from './config.js';
2
2
  import { modelsCommand } from './models.js';
3
3
  import { canRouteThroughRouter, canonicalProvider, canonicalRoute, describeDirectRoute, describeRouterRoute, isRouterOnlyProvider, modelRouteStatus, } from './provider_choices.js';
4
- import { selectProviderModel } from './provider_selection.js';
4
+ import { refreshRouterModels, selectProviderModel } from './provider_selection.js';
5
+ import { switchProvider } from './provider.js';
5
6
  import { getEffectiveModel } from './runtime_model.js';
6
7
  import { normalizeProviderId } from '../backends/provider_ids.js';
7
8
  import { isModelAvailableForProvider, resolveModelAndProvider } from '../../panes/model_catalog.js';
9
+ import { resolveRouterModel } from '../../utils/router_catalog.js';
8
10
  import { isRetiredModel, isRetiredProvider, retiredModelMessage, retiredProviderMessage } from '../../config/retired_routes.js';
9
11
  const MODEL_SUBCOMMANDS = ['list', 'latest', 'set'];
10
12
  /** Bare `/model`: the active route, the two routes to choose from, and current models. */
@@ -27,15 +29,20 @@ async function showModelRoutes(ctx) {
27
29
  // Router model ids already carry their provider (modal/deepseek-…).
28
30
  const selection = model.startsWith(`${provider}/`) ? model : `${provider}/${model}`;
29
31
  const routerOnly = isRouterOnlyProvider(provider);
32
+ // Routing set to direct keeps it off Zerg Router whether or not ZTC is logged
33
+ // in; otherwise it waits for a ZergAI login.
34
+ const routingDirect = ctx.config.getAuthMode?.() === 'direct';
30
35
  const lines = [
31
- `Current: ${selection} · ${routed ? 'ZergRouter' : routerOnly ? 'ZergRouter (log in with ZergAI)' : 'Local API key'}`,
36
+ `Current: ${selection} · ${routed ? 'ZergRouter' : routerOnly
37
+ ? `ZergRouter (${routingDirect ? 'routing is set to direct' : 'log in with ZergAI'})` : 'Local API key'}`,
32
38
  '',
33
39
  'Routes:',
34
40
  ...routes.map(([label, usage, detail]) => ` ${label.padEnd(width)} ${usage} · ${detail}`),
35
41
  ];
36
42
  lines.push('', `Models (${provider}):`);
37
43
  if (routerOnly && !routed) {
38
- lines.push(' Log in with ZergAI (/auth login) to list ZergRouter models.');
44
+ lines.push(routingDirect ? ' Set Routing to auto in /config to list ZergRouter models.'
45
+ : ' Log in with ZergAI (/auth login) to list ZergRouter models.');
39
46
  }
40
47
  else {
41
48
  try {
@@ -76,6 +83,18 @@ function otherProvidersSelection(modelId, ctx) {
76
83
  return undefined;
77
84
  return routedNow(ctx) && canRouteThroughRouter(owner) ? ['zergrouter', owner, model] : [owner, model];
78
85
  }
86
+ /**
87
+ * `/model <name>` for a provider Zerg Router's cached catalog lists (morph), when no model of the provider in use goes
88
+ * by that name: the provider, as /provider <name> chooses it, rather than a model of the current provider.
89
+ */
90
+ function routerListsProvider(name, ctx) {
91
+ const catalog = ctx.config.getRouterCatalog?.();
92
+ const owner = name.trim().toLowerCase();
93
+ if (!catalog?.models.some(row => row.owned_by === owner && (catalog.version === 0 || row.capabilities?.chat)))
94
+ return false;
95
+ const current = normalizeProviderId(ctx.config.getProvider());
96
+ return !isModelAvailableForProvider(current, name) && !resolveRouterModel(catalog, current, name);
97
+ }
79
98
  export const modelCommand = {
80
99
  name: 'model',
81
100
  description: 'Select provider and model, or set a model on the current provider',
@@ -83,16 +102,8 @@ export const modelCommand = {
83
102
  agentRunnable: true,
84
103
  category: 'config',
85
104
  handler: async (args, ctx) => {
86
- if (args[0] === 'refresh' && ctx.models.catalog) {
87
- try {
88
- const catalog = await ctx.models.catalog(undefined, { refresh: true });
89
- ctx.addMessage({ role: 'system', content: `${catalog.authRequired ? 'Router authentication rejected. Run ztc auth login again. Showing cached catalog' : catalog.cached ? 'Router unavailable. Showing cached catalog' : 'Router catalog refreshed'}: ${catalog.models.length} models. Active responses continue with their current selection.` });
90
- }
91
- catch (error) {
92
- ctx.addMessage({ role: 'system', content: `Could not refresh Router models: ${error.message}` });
93
- }
94
- return;
95
- }
105
+ if (args[0] === 'refresh' && ctx.models.catalog)
106
+ return refreshRouterModels(ctx);
96
107
  if (args.length > 0 && MODEL_SUBCOMMANDS.includes(args[0].toLowerCase())) {
97
108
  return modelsCommand.handler(args, ctx);
98
109
  }
@@ -108,6 +119,8 @@ export const modelCommand = {
108
119
  if (args.length > 1 || (args.length === 1 && (canonicalProvider(args[0]) || canonicalRoute(args[0])))) {
109
120
  return selectProviderModel(args, ctx, { offerReasoning: true });
110
121
  }
122
+ if (args.length === 1 && routerListsProvider(args[0], ctx))
123
+ return switchProvider(args, ctx);
111
124
  // Another provider's model selects that provider too, so its key is the
112
125
  // one asked for and the model is never saved under the current provider.
113
126
  const selection = otherProvidersSelection(args[0], ctx);
@@ -1,7 +1,9 @@
1
- import { applyRuntimeModelSelection } from './runtime_model.js';
1
+ import { applyRuntimeModelSelection, paneRoute } from './runtime_model.js';
2
2
  import { isCodexAppServerProvider, isCodexLegacyProvider, normalizeProviderId } from '../backends/provider_ids.js';
3
3
  import { isBuildableResolvedConfig, unbuildableSelectionMessage } from './config.js';
4
4
  import { promptForMissingDirectKey } from './direct_credential_prompt.js';
5
+ import { canonicalProvider } from './provider_choices.js';
6
+ import { selectProviderModel } from './provider_selection.js';
5
7
  const LATEST_TAGS = ['latest', 'current', 'default'];
6
8
  function filterModelsForProvider(models, provider) {
7
9
  const normalizedProvider = provider.toLowerCase();
@@ -101,19 +103,34 @@ export function pickLatestModel(models, provider) {
101
103
  return candidateModels.slice().sort((a, b) => compareVariantPreference(a, b, provider))[0];
102
104
  }
103
105
  /**
104
- * `/models set <id>` on the active provider. A missing direct key is asked for
106
+ * `/models set <id>` on the provider this pane runs on, saved with that provider and its route, so the saved
107
+ * provider and model stay a pair: a pane running another provider than the profile's once saved its model beside
108
+ * the profile's provider. Key and login prompts, and Zerg Router's catalog check, are selectProviderModel's.
109
+ */
110
+ async function setModel(value, ctx) {
111
+ // The main pane's route can be the web mirror's choice for it alone, not the configuration's.
112
+ const { provider, routed } = paneRoute(ctx);
113
+ if (routed)
114
+ return selectProviderModel(['zergrouter', provider, value], ctx);
115
+ // A provider /model doesn't name (Bedrock) keeps the model-only change.
116
+ if (!canonicalProvider(provider))
117
+ return setModelOnly(value, ctx);
118
+ return selectProviderModel(['direct', provider, value], ctx);
119
+ }
120
+ /**
121
+ * The model alone, on the active provider. A missing direct key is asked for
105
122
  * once; `credentialPrompted` marks the retry after it is saved.
106
123
  */
107
- async function setModel(value, ctx, credentialPrompted = false) {
124
+ async function setModelOnly(value, ctx, credentialPrompted = false) {
108
125
  const provider = ctx.config.getProvider();
109
126
  // Verify the selection builds a backend BEFORE persisting so an unbuildable
110
127
  // choice never lands in config.json nor earns a false "✓".
111
128
  // Checked as it will be once chosen: saving it ends any wait for a route choice.
112
129
  const llm = ctx.config.resolveLLMBackendConfig({ provider, model: value, asChosen: true });
113
130
  if (!isBuildableResolvedConfig(llm)) {
114
- if (!credentialPrompted && promptForMissingDirectKey(llm, ctx, () => setModel(value, ctx, true)))
131
+ if (!credentialPrompted && promptForMissingDirectKey(llm, ctx, () => setModelOnly(value, ctx, true)))
115
132
  return;
116
- ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider) });
133
+ ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider, llm, ctx.config) });
117
134
  return;
118
135
  }
119
136
  ctx.config.set('model', value);
@@ -153,8 +170,9 @@ async function listModels(subCmd, provider, ctx, credentialPrompted = false) {
153
170
  // ctx.config.getProvider() — so we don't persist a kimi id under
154
171
  // provider=openai and hot-swap into a 400-ing mismatch. Verify buildable
155
172
  // BEFORE persisting.
156
- if (!isBuildableResolvedConfig(ctx.config.resolveLLMBackendConfig({ provider, model: latest, asChosen: true }))) {
157
- ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider) });
173
+ const route = ctx.config.resolveLLMBackendConfig({ provider, model: latest, asChosen: true });
174
+ if (!isBuildableResolvedConfig(route)) {
175
+ ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider, route, ctx.config) });
158
176
  return;
159
177
  }
160
178
  const providerChanged = normalizeProviderId(provider) !== normalizeProviderId(ctx.config.getProvider());
@@ -0,0 +1,22 @@
1
+ import type { Command, CommandContext } from './types.js';
2
+ /**
3
+ * `/provider [zergrouter|direct] <name> [model]`, and `/model <name>` for a provider Zerg Router lists. The model is
4
+ * the one named, else the one last used with that provider while it is still offered, else the provider's default.
5
+ */
6
+ export declare function switchProvider(args: string[], ctx: CommandContext): Promise<void>;
7
+ /**
8
+ * The desktop app's model chip: "Choose provider" first, Zerg Router's from the cached catalog whatever route this
9
+ * pane runs on, then the person's own keys, and then that provider's models; the current provider goes straight to
10
+ * its models. The choice applies as `/provider <choice> <model>` does, setting the default and switching this pane.
11
+ * `run` runs a slash command as the renderer does.
12
+ */
13
+ export declare function pickProviderAndModel(ctx: CommandContext, current: {
14
+ provider: string;
15
+ model: string;
16
+ }, run: (command: string, args: string[]) => Promise<void>): Promise<void>;
17
+ /**
18
+ * Whether `/provider <args>` switches, rebuilding this pane's agent, rather than listing the providers or refreshing
19
+ * Router's list: like /model, a switch waits for an agent turn to end.
20
+ */
21
+ export declare function switchesProvider(args: readonly string[]): boolean;
22
+ export declare const providerCommand: Command;