@zergai/ztc 0.14.0-beta.1 → 0.15.0-beta.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 (134) hide show
  1. package/README.md +175 -39
  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 +0 -0
  7. package/dist/App.js +17 -0
  8. package/dist/agent/agent.js +1 -5
  9. package/dist/agent/backends/account_events.d.ts +4 -4
  10. package/dist/agent/backends/account_events.js +4 -4
  11. package/dist/agent/backends/account_login.d.ts +1 -1
  12. package/dist/agent/backends/account_login.js +1 -1
  13. package/dist/agent/backends/account_pool.d.ts +11 -54
  14. package/dist/agent/backends/account_pool.js +12 -134
  15. package/dist/agent/backends/anthropic.js +18 -4
  16. package/dist/agent/backends/codex_app_server.d.ts +3 -4
  17. package/dist/agent/backends/codex_app_server.js +4 -5
  18. package/dist/agent/backends/codex_auth.d.ts +1 -0
  19. package/dist/agent/backends/codex_auth.js +6 -4
  20. package/dist/agent/backends/failover.d.ts +1 -1
  21. package/dist/agent/backends/failover.js +9 -9
  22. package/dist/agent/backends/index.d.ts +3 -24
  23. package/dist/agent/backends/index.js +8 -56
  24. package/dist/agent/backends/kimi_code_auth.d.ts +1 -1
  25. package/dist/agent/backends/kimi_code_auth.js +2 -2
  26. package/dist/agent/backends/provider_ids.d.ts +5 -0
  27. package/dist/agent/backends/provider_ids.js +6 -1
  28. package/dist/agent/backends/rate_limit.d.ts +7 -16
  29. package/dist/agent/backends/rate_limit.js +7 -29
  30. package/dist/agent/backends/types.d.ts +0 -5
  31. package/dist/agent/commands/accounts.d.ts +6 -2
  32. package/dist/agent/commands/accounts.js +97 -70
  33. package/dist/agent/commands/compact.js +4 -2
  34. package/dist/agent/commands/config.js +27 -13
  35. package/dist/agent/commands/connect.js +79 -3
  36. package/dist/agent/commands/credential_status.d.ts +2 -0
  37. package/dist/agent/commands/credential_status.js +5 -1
  38. package/dist/agent/commands/dictation.js +34 -14
  39. package/dist/agent/commands/direct_credential_prompt.js +7 -1
  40. package/dist/agent/commands/model.js +8 -0
  41. package/dist/agent/commands/models.js +5 -6
  42. package/dist/agent/commands/provider_choices.js +5 -5
  43. package/dist/agent/commands/provider_model_defaults.d.ts +3 -4
  44. package/dist/agent/commands/provider_model_defaults.js +4 -16
  45. package/dist/agent/commands/provider_selection.d.ts +4 -3
  46. package/dist/agent/commands/provider_selection.js +15 -7
  47. package/dist/agent/commands/settings.js +36 -50
  48. package/dist/agent/commands/sim.js +9 -0
  49. package/dist/agent/commands/subs.js +3 -2
  50. package/dist/agent/commands/types.d.ts +26 -6
  51. package/dist/agent/factory.js +17 -52
  52. package/dist/agent/subagent.js +4 -11
  53. package/dist/agent/tools/adaptation.js +10 -1
  54. package/dist/agent/tools/pane.js +25 -2
  55. package/dist/agent/tools/sim.js +12 -3
  56. package/dist/agent/tools/supervision.js +4 -0
  57. package/dist/app/agent_runner.js +9 -2
  58. package/dist/app/launch_notices.d.ts +44 -0
  59. package/dist/app/launch_notices.js +41 -0
  60. package/dist/app/retired_route_gate.d.ts +44 -0
  61. package/dist/app/retired_route_gate.js +73 -0
  62. package/dist/app/session_manager.js +2 -1
  63. package/dist/app/task_scope_router.js +1 -13
  64. package/dist/cli_main.js +39 -6
  65. package/dist/cli_ratatui.d.ts +28 -2
  66. package/dist/cli_ratatui.js +178 -40
  67. package/dist/components/InputArea.js +27 -10
  68. package/dist/config/anthropic_models.d.ts +18 -0
  69. package/dist/config/anthropic_models.js +22 -0
  70. package/dist/config/defaults.d.ts +0 -1
  71. package/dist/config/defaults.js +9 -10
  72. package/dist/config/permissions.js +4 -2
  73. package/dist/config/repo_config.js +8 -0
  74. package/dist/config/resolved.d.ts +1 -1
  75. package/dist/config/retired_ids.d.ts +33 -0
  76. package/dist/config/retired_ids.js +39 -0
  77. package/dist/config/retired_routes.d.ts +192 -0
  78. package/dist/config/retired_routes.js +609 -0
  79. package/dist/config/types.d.ts +61 -31
  80. package/dist/config.d.ts +269 -23
  81. package/dist/config.js +727 -106
  82. package/dist/evolution/mutation.js +4 -1
  83. package/dist/headless.js +46 -4
  84. package/dist/headless_cli.js +23 -6
  85. package/dist/headless_cli_args.d.ts +3 -1
  86. package/dist/headless_cli_args.js +7 -0
  87. package/dist/hosted/session_settings.js +11 -2
  88. package/dist/library.js +4 -0
  89. package/dist/onboarding/first_run.js +5 -2
  90. package/dist/onboarding/setup.js +2 -1
  91. package/dist/onboarding/setup_agent_health.js +5 -5
  92. package/dist/optimize/llm.js +4 -1
  93. package/dist/panes/agent_cli.d.ts +1 -1
  94. package/dist/panes/agent_cli.js +5 -2
  95. package/dist/panes/agent_panes.js +12 -4
  96. package/dist/panes/agent_profiles.d.ts +25 -5
  97. package/dist/panes/agent_profiles.js +35 -10
  98. package/dist/panes/model_catalog.d.ts +1 -1
  99. package/dist/panes/model_catalog.js +3 -24
  100. package/dist/panes/pane_registry.js +9 -3
  101. package/dist/panes/ztc_launch.js +28 -6
  102. package/dist/simulation/inference.d.ts +38 -4
  103. package/dist/simulation/inference.js +264 -24
  104. package/dist/simulation/living/context.d.ts +1 -1
  105. package/dist/simulation/living/open-world.d.ts +1 -1
  106. package/dist/simulation/living/types.d.ts +4 -4
  107. package/dist/simulation/llm.js +14 -4
  108. package/dist/simulation/memory/embedding.d.ts +6 -0
  109. package/dist/simulation/memory/embedding.js +35 -8
  110. package/dist/utils/compaction.js +0 -1
  111. package/dist/utils/context.js +2 -7
  112. package/dist/utils/dictation.d.ts +43 -8
  113. package/dist/utils/dictation.js +333 -138
  114. package/dist/utils/idle_compaction.js +1 -1
  115. package/dist/utils/models.js +0 -24
  116. package/dist/utils/subprocess_env.d.ts +14 -3
  117. package/dist/utils/subprocess_env.js +16 -3
  118. package/dist/web/accounts_mirror.d.ts +23 -57
  119. package/dist/web/accounts_mirror.js +52 -171
  120. package/dist/web/mirror_stream.d.ts +14 -3
  121. package/dist/web/mirror_stream.js +16 -12
  122. package/dist/zlicky/vision_locator.js +7 -2
  123. package/dist/zlm-embed.mjs +1398 -1488
  124. package/package.json +12 -10
  125. package/dist/agent/backends/account_rotation.d.ts +0 -138
  126. package/dist/agent/backends/account_rotation.js +0 -323
  127. package/dist/agent/backends/account_state.d.ts +0 -59
  128. package/dist/agent/backends/account_state.js +0 -139
  129. package/dist/agent/backends/claude_cli.d.ts +0 -85
  130. package/dist/agent/backends/claude_cli.js +0 -658
  131. package/dist/agent/backends/claude_code_auth.d.ts +0 -48
  132. package/dist/agent/backends/claude_code_auth.js +0 -171
  133. package/dist/agent/backends/rotation_factory.d.ts +0 -26
  134. package/dist/agent/backends/rotation_factory.js +0 -55
@@ -2,6 +2,7 @@ import { API_KEY_PROVIDER_CHOICES, DIRECT_PROVIDER_CHOICES, isLocalSubscription,
2
2
  import { isBuildableResolvedConfig } from './config.js';
3
3
  import { maskApiKey } from '../../config.js';
4
4
  import { RouterConfigurationError } from '../../router_auth.js';
5
+ import { RouteAwaitingChoiceError } from '../../config/retired_routes.js';
5
6
  /** The route as /status and /config show name it. */
6
7
  const ROUTE_NAMES = {
7
8
  router: 'Zerg Router',
@@ -40,7 +41,7 @@ export function describeActiveRoute(config) {
40
41
  }
41
42
  catch (error) {
42
43
  return { kind: 'none', route: ROUTE_NAMES.none, ready: false, error: error instanceof Error ? error.message : String(error),
43
- signIn: error instanceof RouterConfigurationError && error.needsSignIn };
44
+ signIn: error instanceof RouterConfigurationError && error.needsSignIn, awaitingChoice: error instanceof RouteAwaitingChoiceError };
44
45
  }
45
46
  }
46
47
  function routingMode(config) {
@@ -53,6 +54,9 @@ function routingMode(config) {
53
54
  export function readinessLine(config, route = describeActiveRoute(config)) {
54
55
  if (route.ready)
55
56
  return 'Yes';
57
+ // What blocks it is the choice still to make, not a key or a login (a key in the environment is never chosen on its own).
58
+ if (route.awaitingChoice)
59
+ return 'No - no model route is set up in ZTC yet. Choose one with /connect.';
56
60
  const provider = config.getProvider();
57
61
  const session = config.getRouterSessionStatus?.() ?? 'signed_out';
58
62
  const mode = routingMode(config);
@@ -1,10 +1,10 @@
1
- import { getDictationStatus } from '../../utils/dictation.js';
1
+ import { dictationChoiceNotice, dictationChoiceRefusal, getDictationStatus } from '../../utils/dictation.js';
2
2
  import { isNativeDictationAvailable, listAudioDevices, getNativeDictationStatus } from '../../utils/dictation_native.js';
3
3
  import { configStore } from '../../config.js';
4
4
  export const dictationStatusCommand = {
5
5
  name: 'dictation',
6
6
  description: 'Manage voice dictation settings',
7
- usage: '[devices|device <name>|model <name>|status]',
7
+ usage: '[status|local|macos|openai|devices|device <name>|model <name>]',
8
8
  agentRunnable: true,
9
9
  category: 'audio',
10
10
  handler: async (args, ctx) => {
@@ -20,6 +20,10 @@ export const dictationStatusCommand = {
20
20
  '**Dictation Status**',
21
21
  '',
22
22
  legacyStatus,
23
+ // Native dictation transcribes on this computer, and Ctrl+R uses it whenever it is installed.
24
+ ...(isNativeDictationAvailable()
25
+ ? ['Ctrl+R uses native dictation (ztc-audio), which transcribes on this computer; the transcription above applies without it.']
26
+ : []),
23
27
  '',
24
28
  nativeStatus,
25
29
  '',
@@ -28,6 +32,9 @@ export const dictationStatusCommand = {
28
32
  `Whisper Model: ${currentModel}`,
29
33
  '',
30
34
  '**Commands**',
35
+ '`/dictation local` - Transcribe on this computer: local whisper, else macOS dictation on-device (the default)',
36
+ '`/dictation macos` - Transcribe on this computer with macOS dictation first, on-device only',
37
+ '`/dictation openai` - Send each recording to OpenAI\'s Whisper API instead; OPENAI_API_KEY pays',
31
38
  '`/dictation devices` - List available audio input devices',
32
39
  '`/dictation device <name>` - Set audio input device',
33
40
  '`/dictation model <name>` - Set Whisper model (tiny, base, small, medium, large)',
@@ -35,6 +42,26 @@ export const dictationStatusCommand = {
35
42
  ctx.addMessage({ role: 'system', content: status });
36
43
  return;
37
44
  }
45
+ if (subcommand === 'local' || subcommand === 'macos' || subcommand === 'openai') {
46
+ // The person's choice of where a recording is transcribed, saved, and said as they make it: OpenAI's Whisper
47
+ // API would get their audio on their key. Only the person makes it, in ZTC's main session, the browser mirror
48
+ // or a ztc they run themselves; never the agent, nor input relayed to this ZTC (what a ZTC pane or a colony cell
49
+ // reads from its terminal, what a mirror's /broadcast gets, a bus message, a /loop or the queue), which is told
50
+ // where to make it.
51
+ if (ctx.commandOrigin === 'agent') {
52
+ ctx.addMessage({ role: 'system', content: `Only you can choose where dictation transcribes: type /dictation ${subcommand} yourself.` });
53
+ return;
54
+ }
55
+ if (ctx.commandOrigin === 'relayed') {
56
+ ctx.addMessage({ role: 'system', content: dictationChoiceRefusal(`Type /dictation ${subcommand} again`) });
57
+ return;
58
+ }
59
+ const choice = subcommand;
60
+ configStore.set('dictation', { ...configStore.get().dictation, provider: choice });
61
+ await configStore.save();
62
+ ctx.addMessage({ role: 'system', content: dictationChoiceNotice(choice) });
63
+ return;
64
+ }
38
65
  if (subcommand === 'devices') {
39
66
  // List devices
40
67
  if (!isNativeDictationAvailable()) {
@@ -70,20 +97,17 @@ export const dictationStatusCommand = {
70
97
  }
71
98
  if (subcommand === 'device') {
72
99
  const deviceName = args.slice(1).join(' ');
100
+ // Saved through set(): configStore.get() is a copy, so a change made to it alone was never saved.
101
+ const { device: _device, ...rest } = configStore.get().dictation ?? {};
73
102
  if (!deviceName) {
74
103
  // Clear device (use default)
75
- const config = configStore.get();
76
- delete config.dictation?.device;
104
+ configStore.set('dictation', rest);
77
105
  await configStore.save();
78
106
  ctx.addMessage({ role: 'system', content: 'Audio device reset to system default.' });
79
107
  return;
80
108
  }
81
109
  // Set device
82
- const config = configStore.get();
83
- if (!config.dictation) {
84
- config.dictation = {};
85
- }
86
- config.dictation.device = deviceName;
110
+ configStore.set('dictation', { ...rest, device: deviceName });
87
111
  await configStore.save();
88
112
  ctx.addMessage({ role: 'system', content: `Audio device set to: ${deviceName}` });
89
113
  return;
@@ -98,11 +122,7 @@ export const dictationStatusCommand = {
98
122
  });
99
123
  return;
100
124
  }
101
- const config = configStore.get();
102
- if (!config.dictation) {
103
- config.dictation = {};
104
- }
105
- config.dictation.whisperModel = modelName;
125
+ configStore.set('dictation', { ...configStore.get().dictation, whisperModel: modelName });
106
126
  await configStore.save();
107
127
  ctx.addMessage({ role: 'system', content: `Whisper model set to: ${modelName}` });
108
128
  return;
@@ -1,9 +1,9 @@
1
+ import { CLAUDE_CODE_TOKEN_MESSAGE, isClaudeCodeToken } from '../../config/retired_routes.js';
1
2
  import { runOpenAICompatibleWizard } from './openai_compat_wizard.js';
2
3
  import { canonicalProvider, DIRECT_PROVIDER_CHOICES, isLocalSubscription } from './provider_choices.js';
3
4
  import { compatEndpoint, maskApiKey } from '../../config.js';
4
5
  import { ApiKeyEnvNameError, detectApiKeyEnvCandidates, looksLikeApiKey, looksLikeApiKeyEnvName, parseApiKeyEnvName, providerApiKeyEnvNames, readApiKeyEnvReference, readProviderApiKeyEnv, } from '../../config/provider_api_key_env.js';
5
6
  const LOCAL_LOGIN_HELP = {
6
- claude_code: 'Install Claude Code and sign in with `claude`',
7
7
  codex_app_server: 'Sign in with `codex login`',
8
8
  codex_legacy: 'Sign in with `codex login`',
9
9
  kimi_code: 'Sign in with the Kimi Code CLI',
@@ -294,6 +294,12 @@ function askForKey(request) {
294
294
  }
295
295
  async function saveKey(request, key) {
296
296
  const { provider, label, ctx } = request;
297
+ // A Claude Code sign-in token is not an API key, and ZTC never keeps one.
298
+ if (isClaudeCodeToken(key)) {
299
+ ctx.addMessage({ role: 'system', content: CLAUDE_CODE_TOKEN_MESSAGE });
300
+ await request.onCancel?.();
301
+ return;
302
+ }
297
303
  await request.inScope(async () => {
298
304
  ctx.config.setApiKey(key, provider);
299
305
  await ctx.config.save();
@@ -5,6 +5,7 @@ import { selectProviderModel } from './provider_selection.js';
5
5
  import { getEffectiveModel } from './runtime_model.js';
6
6
  import { normalizeProviderId } from '../backends/provider_ids.js';
7
7
  import { isModelAvailableForProvider, resolveModelAndProvider } from '../../panes/model_catalog.js';
8
+ import { isRetiredModel, isRetiredProvider, retiredModelMessage, retiredProviderMessage } from '../../config/retired_routes.js';
8
9
  const MODEL_SUBCOMMANDS = ['list', 'latest', 'set'];
9
10
  /** Bare `/model`: the active route, the two routes to choose from, and current models. */
10
11
  async function showModelRoutes(ctx) {
@@ -97,6 +98,13 @@ export const modelCommand = {
97
98
  }
98
99
  if (args.length === 0)
99
100
  return showModelRoutes(ctx);
101
+ // Claude Code is no longer a ZTC model provider, under any of its names.
102
+ const retired = args.find(arg => isRetiredProvider(arg) || isRetiredModel(arg));
103
+ if (retired) {
104
+ ctx.addMessage({ role: 'system', content: isRetiredProvider(retired)
105
+ ? retiredProviderMessage(retired, ctx.config.getProvider()) : retiredModelMessage(retired) });
106
+ return;
107
+ }
100
108
  if (args.length > 1 || (args.length === 1 && (canonicalProvider(args[0]) || canonicalRoute(args[0])))) {
101
109
  return selectProviderModel(args, ctx, { offerReasoning: true });
102
110
  }
@@ -14,9 +14,7 @@ function filterModelsForProvider(models, provider) {
14
14
  return preferred.length > 0 ? preferred : models;
15
15
  }
16
16
  if (normalizedProvider === 'anthropic'
17
- || normalizedProvider === 'claude'
18
- || normalizedProvider === 'claude_code'
19
- || normalizedProvider === 'claude-code') {
17
+ || normalizedProvider === 'claude') {
20
18
  const preferred = models.filter(model => /^(claude|opus|sonnet|haiku)/i.test(model));
21
19
  return preferred.length > 0 ? preferred : models;
22
20
  }
@@ -110,7 +108,8 @@ async function setModel(value, ctx, credentialPrompted = false) {
110
108
  const provider = ctx.config.getProvider();
111
109
  // Verify the selection builds a backend BEFORE persisting so an unbuildable
112
110
  // choice never lands in config.json nor earns a false "✓".
113
- const llm = ctx.config.resolveLLMBackendConfig({ provider, model: value });
111
+ // Checked as it will be once chosen: saving it ends any wait for a route choice.
112
+ const llm = ctx.config.resolveLLMBackendConfig({ provider, model: value, asChosen: true });
114
113
  if (!isBuildableResolvedConfig(llm)) {
115
114
  if (!credentialPrompted && promptForMissingDirectKey(llm, ctx, () => setModel(value, ctx, true)))
116
115
  return;
@@ -127,7 +126,7 @@ async function listModels(subCmd, provider, ctx, credentialPrompted = false) {
127
126
  try {
128
127
  // A Router route lists through its login; only a direct route can lack a key.
129
128
  if (subCmd === 'latest' && !credentialPrompted && ctx.config.getAuthMode?.() !== 'zrouter') {
130
- const probe = ctx.config.resolveLLMBackendConfig({ provider });
129
+ const probe = ctx.config.resolveLLMBackendConfig({ provider, asChosen: true });
131
130
  if (!isBuildableResolvedConfig(probe)
132
131
  && promptForMissingDirectKey(probe, ctx, () => listModels(subCmd, provider, ctx, true)))
133
132
  return;
@@ -154,7 +153,7 @@ async function listModels(subCmd, provider, ctx, credentialPrompted = false) {
154
153
  // ctx.config.getProvider() — so we don't persist a kimi id under
155
154
  // provider=openai and hot-swap into a 400-ing mismatch. Verify buildable
156
155
  // BEFORE persisting.
157
- if (!isBuildableResolvedConfig(ctx.config.resolveLLMBackendConfig({ provider, model: latest }))) {
156
+ if (!isBuildableResolvedConfig(ctx.config.resolveLLMBackendConfig({ provider, model: latest, asChosen: true }))) {
158
157
  ctx.addMessage({ role: 'system', content: unbuildableSelectionMessage(provider) });
159
158
  return;
160
159
  }
@@ -1,4 +1,5 @@
1
- import { normalizeProviderId } from '../backends/provider_ids.js';
1
+ import { isLocalSubscriptionProvider, normalizeProviderId } from '../backends/provider_ids.js';
2
+ import { RETIRED_PROVIDER_IDS } from '../../config/retired_ids.js';
2
3
  import { ZERGAI_LOGIN_PITCH } from '../../onboarding/zergai_login.js';
3
4
  export const PROVIDER_CHOICES = [
4
5
  { id: 'zergrouter', label: 'ZergRouter', description: 'Uses your ZergAI login', aliases: ['zrouter', 'router'] },
@@ -12,7 +13,6 @@ export const PROVIDER_CHOICES = [
12
13
  { id: 'clarifai', label: 'Clarifai', description: 'Direct API key' },
13
14
  { id: 'openai_compatible', label: 'OpenAI-compatible', description: 'Local or custom endpoint', aliases: ['openai-compatible', 'local', 'ollama'] },
14
15
  { id: 'modal', label: 'Modal', description: 'Shared endpoints through ZergRouter' },
15
- { id: 'claude_code', label: 'Claude Code', description: 'Local Claude credentials', aliases: ['claude-code'] },
16
16
  { id: 'codex_app_server', label: 'Codex CLI', description: 'Local Codex app server' },
17
17
  { id: 'codex_legacy', label: 'Codex Legacy', description: 'Local Codex credentials' },
18
18
  { id: 'kimi_code', label: 'Kimi Code', description: 'Local Kimi credentials', aliases: ['kimi-code'] },
@@ -29,8 +29,6 @@ export const PROVIDER_CHOICES = [
29
29
  export const ROUTER_EXCLUDED_PROVIDERS = [
30
30
  // Local subscription logins: inference runs on this machine, not Router, and
31
31
  // Router holds no credential for them.
32
- 'claude_code',
33
- 'claude_code_direct',
34
32
  'codex_app_server',
35
33
  'codex_legacy',
36
34
  'kimi_code',
@@ -38,6 +36,8 @@ export const ROUTER_EXCLUDED_PROVIDERS = [
38
36
  'zergrouter',
39
37
  // A custom OpenAI-compatible endpoint names its own base URL and models.
40
38
  'openai_compatible',
39
+ // The retired Claude Code routes: a stale value is never sent upstream.
40
+ ...RETIRED_PROVIDER_IDS,
41
41
  ];
42
42
  const ROUTER_EXCLUDED = new Set(ROUTER_EXCLUDED_PROVIDERS);
43
43
  /** True when a provider can be dispatched as a Router upstream. */
@@ -50,7 +50,7 @@ export function canonicalProvider(value) {
50
50
  return PROVIDER_CHOICES.find(choice => choice.id === normalized || choice.aliases?.includes(normalized))?.id;
51
51
  }
52
52
  export function isLocalSubscription(provider) {
53
- return ['claude_code', 'claude_code_direct', 'codex_app_server', 'codex_legacy', 'kimi_code'].includes(provider);
53
+ return isLocalSubscriptionProvider(provider);
54
54
  }
55
55
  /**
56
56
  * The two ways a model is reached: the personal ZergRouter login, or a
@@ -1,8 +1,7 @@
1
- export declare function resolveModelForProviderChange(provider: string, currentModel: string | undefined): string | null;
2
1
  /**
3
2
  * The model a switch from `previousProvider` to `provider` lands on: the
4
- * Claude Code reset when it applies, the current model when the provider is
5
- * unchanged, otherwise the new provider's default. Callers save it and hand it
6
- * to the runtime, so a live model from the previous provider never carries over.
3
+ * current model when the provider is unchanged, otherwise the new provider's
4
+ * default. Callers save it and hand it to the runtime, so a live model from
5
+ * the previous provider never carries over.
7
6
  */
8
7
  export declare function modelForProviderSwitch(provider: string, previousProvider: string, currentModel: string): string;
@@ -1,23 +1,11 @@
1
1
  import { getDefaultModelForProvider } from '../../config/defaults.js';
2
- import { isCatalogModelForProvider, resolveModelAndProvider } from '../../panes/model_catalog.js';
3
2
  import { normalizeProviderId } from '../backends/provider_ids.js';
4
- export function resolveModelForProviderChange(provider, currentModel) {
5
- const normalizedProvider = provider === 'claude-code' ? 'claude_code' : provider;
6
- if (normalizedProvider !== 'claude_code')
7
- return null;
8
- const model = (currentModel || '').trim();
9
- const resolved = model ? resolveModelAndProvider(model, normalizedProvider) : null;
10
- if (resolved && isCatalogModelForProvider('claude_code', resolved.model))
11
- return null;
12
- return getDefaultModelForProvider('claude_code');
13
- }
14
3
  /**
15
4
  * The model a switch from `previousProvider` to `provider` lands on: the
16
- * Claude Code reset when it applies, the current model when the provider is
17
- * unchanged, otherwise the new provider's default. Callers save it and hand it
18
- * to the runtime, so a live model from the previous provider never carries over.
5
+ * current model when the provider is unchanged, otherwise the new provider's
6
+ * default. Callers save it and hand it to the runtime, so a live model from
7
+ * the previous provider never carries over.
19
8
  */
20
9
  export function modelForProviderSwitch(provider, previousProvider, currentModel) {
21
- return resolveModelForProviderChange(provider, currentModel)
22
- ?? (normalizeProviderId(provider) === normalizeProviderId(previousProvider) ? currentModel : getDefaultModelForProvider(provider));
10
+ return normalizeProviderId(provider) === normalizeProviderId(previousProvider) ? currentModel : getDefaultModelForProvider(provider);
23
11
  }
@@ -18,9 +18,10 @@ export declare function selectProviderModel(args: string[], ctx: CommandContext,
18
18
  export declare function currentRouteReady(ctx: CommandContext): boolean;
19
19
  /**
20
20
  * After a key is saved for `provider`, offer to switch to it when the current
21
- * selection cannot reach a model, so a new profile is not left stuck on a
22
- * route it cannot use. `beforeAsk` runs just before the question opens and
23
- * `onAnswered` once it is answered or dismissed. True when it asked.
21
+ * selection cannot reach a model, so a profile is not left stuck on a route it
22
+ * cannot use: another provider, or this one on a route that waits for a ZergAI
23
+ * login. `beforeAsk` runs just before the question opens and `onAnswered` once
24
+ * it is answered or dismissed. True when it asked.
24
25
  */
25
26
  export declare function offerKeyedProviderSwitch(provider: string, ctx: CommandContext, { beforeAsk, onAnswered }?: {
26
27
  beforeAsk?: () => void;
@@ -1,7 +1,6 @@
1
1
  import { getDefaultModelForProvider } from '../../config/defaults.js';
2
2
  import { isBuildableResolvedConfig } from './config.js';
3
3
  import { canAskForCredential, promptForMissingDirectKey, providerLabel } from './direct_credential_prompt.js';
4
- import { normalizeProviderId } from '../backends/provider_ids.js';
5
4
  import { applyRuntimeModelSelection, getEffectiveModel } from './runtime_model.js';
6
5
  import { canRouteThroughRouter, canonicalProvider, canonicalRoute, DIRECT_PROVIDER_CHOICES, describeDirectProvider, isRouterOnlyProvider, modelRouteStatus, } from './provider_choices.js';
7
6
  import { resolveModelAndProvider } from '../../panes/model_catalog.js';
@@ -10,6 +9,7 @@ import { resolveRouterModel, RouterCatalogAuthenticationError, routerModelForSwi
10
9
  import { ROUTER_MODELS_NEED_LOGIN, ZERGAI_LOGIN_BENEFITS } from '../../onboarding/zergai_login.js';
11
10
  import { runAuthAction } from './auth.js';
12
11
  import { offerReasoningPicker } from './reasoning_picker.js';
12
+ import { isRetiredModel, isRetiredProvider, retiredModelMessage, retiredProviderMessage } from '../../config/retired_routes.js';
13
13
  /** Local providers with their credential state, configured ones first. */
14
14
  export function formatDirectProviders(readyProviders) {
15
15
  const ready = new Set(readyProviders);
@@ -19,6 +19,7 @@ export function formatDirectProviders(readyProviders) {
19
19
  'Local API key providers:',
20
20
  ...rows.map(row => ` ${row.id.padEnd(width)} ${describeDirectProvider(row.id, ready.has(row.id))}`),
21
21
  '',
22
+ 'Your Claude subscription runs in Claude Code itself: open it in a pane with /claude.',
22
23
  'Use /model direct <provider> [model].',
23
24
  ].join('\n');
24
25
  }
@@ -79,6 +80,12 @@ function askForRouterLogin(args, ctx, options) {
79
80
  export async function selectProviderModel(args, ctx, options = {}) {
80
81
  const { credentialPrompted = false } = options;
81
82
  const values = args.filter(Boolean);
83
+ const retired = values.find(value => isRetiredProvider(value) || isRetiredModel(value));
84
+ if (retired) {
85
+ ctx.addMessage({ role: 'system', content: isRetiredProvider(retired)
86
+ ? retiredProviderMessage(retired, ctx.config.getProvider()) : retiredModelMessage(retired) });
87
+ return;
88
+ }
82
89
  if (canonicalRoute(values[0]) === 'direct')
83
90
  return selectDirectRoute(values, ctx, options);
84
91
  const current = ctx.config.getProvider();
@@ -133,7 +140,8 @@ export async function selectProviderModel(args, ctx, options = {}) {
133
140
  model = selected.id;
134
141
  }
135
142
  }
136
- const llm = ctx.config.resolveLLMBackendConfig({ provider, model,
143
+ // Checked as it will be once chosen: saving it ends any wait for a route choice.
144
+ const llm = ctx.config.resolveLLMBackendConfig({ provider, model, asChosen: true,
137
145
  config: { ...ctx.config.get(), provider, model, authMode } });
138
146
  if (llm.authMode !== authMode) {
139
147
  throw new Error('Routing is pinned by ZTC_LLM_AUTH_MODE/ZERG_LLM_AUTH_MODE. Unset it before switching routes.');
@@ -177,14 +185,14 @@ export function currentRouteReady(ctx) {
177
185
  }
178
186
  /**
179
187
  * After a key is saved for `provider`, offer to switch to it when the current
180
- * selection cannot reach a model, so a new profile is not left stuck on a
181
- * route it cannot use. `beforeAsk` runs just before the question opens and
182
- * `onAnswered` once it is answered or dismissed. True when it asked.
188
+ * selection cannot reach a model, so a profile is not left stuck on a route it
189
+ * cannot use: another provider, or this one on a route that waits for a ZergAI
190
+ * login. `beforeAsk` runs just before the question opens and `onAnswered` once
191
+ * it is answered or dismissed. True when it asked.
183
192
  */
184
193
  export function offerKeyedProviderSwitch(provider, ctx, { beforeAsk, onAnswered } = {}) {
185
194
  const id = canonicalProvider(provider) ?? provider;
186
- if (normalizeProviderId(id) === normalizeProviderId(ctx.config.getProvider())
187
- || !canAskForCredential(ctx) || currentRouteReady(ctx)
195
+ if (!canAskForCredential(ctx) || currentRouteReady(ctx)
188
196
  || !(ctx.config.hasDirectCredential?.(id) ?? Boolean(ctx.config.getApiKey(id))))
189
197
  return false;
190
198
  beforeAsk?.();
@@ -1,6 +1,7 @@
1
1
  import { parseReasoningSelection } from '../../utils/reasoning.js';
2
2
  import { resolveRouterModel, routerModelForSwitch } from '../../utils/router_catalog.js';
3
3
  import { getSupportedCodexReasoningEfforts } from '../../utils/models.js';
4
+ import { dictationChoiceNotice, dictationChoiceRefusal } from '../../utils/dictation.js';
4
5
  import { resolveExecutionSettings } from '../../config/execution.js';
5
6
  import { openAccountsManager } from './accounts.js';
6
7
  import { pendingZergAILogin, runAuthAction, stopZergAILogin } from './auth.js';
@@ -15,7 +16,8 @@ import { loadRouterCredentials, routingAfterLogout } from '../../router_auth.js'
15
16
  import { CODEX_REASONING_EFFORTS } from '../../config/types.js';
16
17
  import { customPaneOptions, storedCustomPaneOptions, withCustomPaneOptions, } from '../../config/panes.js';
17
18
  import { getMcpServerStatuses } from '../../mcp/registry.js';
18
- import { hasUsableClaudeCodeCliAuth, isClaudeCliAvailable } from '../backends/claude_cli.js';
19
+ import { CLAUDE_SUBSCRIPTION_POLICY, isRetiredProvider, retiredProviderMessage } from '../../config/retired_routes.js';
20
+ import { subsCommand } from './subs.js';
19
21
  import { modelForProviderSwitch } from './provider_model_defaults.js';
20
22
  import { normalizeProviderId } from '../backends/provider_ids.js';
21
23
  import { applyRuntimeModelSelection, getEffectiveModel } from './runtime_model.js';
@@ -90,7 +92,6 @@ const ZERGAI_LOGIN_HELP = [
90
92
  ].join('\n');
91
93
  /** Local subscription logins, each a family in the account manager. */
92
94
  const LOCAL_LOGINS = [
93
- { id: 'claude_code', label: 'Claude Code login', family: 'Claude', alsoReady: [] },
94
95
  { id: 'codex_app_server', label: 'Codex login', family: 'Codex', alsoReady: ['codex_legacy'] },
95
96
  { id: 'kimi_code', label: 'Kimi Code login', family: 'Kimi', alsoReady: [] },
96
97
  ];
@@ -244,14 +245,6 @@ export async function buildSettingsCategories(ctx) {
244
245
  const model = ctx.config.getModel?.() || config.model;
245
246
  const reasoningEfforts = getSupportedCodexReasoningEfforts(model, provider, ctx.config.getReasoningWireSurface?.(provider, model)
246
247
  ?? (config.authMode === 'zrouter' || provider === 'openai_compatible' ? 'chat_tools' : 'native_api'));
247
- const claudeCliInstalled = isClaudeCliAvailable();
248
- const claudeCodeTokenPresent = Boolean(process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim());
249
- const claudeCodeReady = hasUsableClaudeCodeCliAuth();
250
- const claudeCodeStatus = claudeCodeReady
251
- ? 'ready'
252
- : claudeCliInstalled
253
- ? (claudeCodeTokenPresent ? 'token present, auth check failed' : 'missing CLAUDE_CODE_OAUTH_TOKEN')
254
- : 'missing claude CLI';
255
248
  const configScope = ctx.config.getConfigScope?.() || 'global';
256
249
  const authMode = ctx.config.getAuthMode?.() || config.authMode || 'auto';
257
250
  const zergProxyUrl = config.zergProxyUrl || '';
@@ -360,10 +353,10 @@ export async function buildSettingsCategories(ctx) {
360
353
  settings: [{
361
354
  name: 'manageAccounts',
362
355
  label: 'Manage accounts',
363
- value: 'Claude · Codex · Kimi',
356
+ value: 'Codex · Kimi',
364
357
  type: 'text',
365
- description: 'Subscription logins: switch accounts, check usage, or refresh a stale sign-in.',
366
- keywords: ['subscriptions', 'local login', 'claude code', 'codex', 'kimi code'],
358
+ description: 'Subscription logins: switch accounts, check usage, or refresh a stale sign-in. Claude accounts are Claude Code profiles (/subs).',
359
+ keywords: ['subscriptions', 'local login', 'codex', 'kimi code'],
367
360
  onActivate: () => openAccountsFromSettings(ctx, undefined, { category: PROFILE, setting: 'manageAccounts' }),
368
361
  }],
369
362
  },
@@ -457,6 +450,20 @@ export async function buildSettingsCategories(ctx) {
457
450
  keywords: ['login', 'local login', 'subscription', 'accounts', 'sign in'],
458
451
  onActivate: () => openAccountsFromSettings(ctx, login.family, { category: CONNECTION, setting: `localLogin_${login.id}` }),
459
452
  })),
453
+ {
454
+ // Where people used to find Claude Code as ZTC's model.
455
+ name: 'claudeSubscription',
456
+ label: 'Claude subscription',
457
+ value: 'Claude Code panes',
458
+ type: 'text',
459
+ description: `ZTC's own model can't use a Claude subscription: ${CLAUDE_SUBSCRIPTION_POLICY}. `
460
+ + 'Open Claude Code in a pane with /claude, on one of your sign-in profiles with /claude @<name>. Enter lists them (/subs).',
461
+ keywords: ['claude', 'claude code', 'subscription', 'login', 'profiles', 'accounts', 'sign in'],
462
+ onActivate: () => {
463
+ ctx.settingsPanel?.closeSettingsPanel?.();
464
+ void subsCommand.handler([], ctx);
465
+ },
466
+ },
460
467
  ],
461
468
  },
462
469
  {
@@ -534,33 +541,6 @@ export async function buildSettingsCategories(ctx) {
534
541
  configuredSetting(ctx, 'openaiCompatibleSystemPromptSuffix', 'Custom endpoint prompt suffix', openaiCompat.systemPromptSuffix ? `${openaiCompat.systemPromptSuffix.length} characters` : 'none', 'Edit openaiCompatible.systemPromptSuffix in ~/.ztc/config.json.'),
535
542
  ],
536
543
  },
537
- {
538
- name: 'Claude Code',
539
- settings: [
540
- {
541
- name: 'claudeCodeStatus',
542
- label: 'Claude Code CLI token',
543
- value: claudeCodeStatus,
544
- type: 'select',
545
- options: [
546
- { value: claudeCodeStatus, label: claudeCodeStatus, description: 'Run: claude /login && claude setup-token; export CLAUDE_CODE_OAUTH_TOKEN' },
547
- ],
548
- // The login state is worth seeing whatever provider is selected: it is
549
- // what makes choosing Claude Code possible at all. The label says so.
550
- },
551
- {
552
- name: 'claudeCodeModel',
553
- label: 'Claude Code model',
554
- value: provider === 'claude_code' ? model : 'sonnet',
555
- type: 'select',
556
- options: [
557
- { value: 'sonnet', label: 'sonnet', description: 'Recommended default for Claude Code' },
558
- { value: 'opus', label: 'opus', description: 'Use only if your Claude plan supports it' },
559
- ],
560
- description: 'Used when Claude Code is the selected provider.',
561
- },
562
- ],
563
- },
564
544
  {
565
545
  name: 'Behavior',
566
546
  settings: [
@@ -1089,7 +1069,7 @@ export async function buildSettingsCategories(ctx) {
1089
1069
  });
1090
1070
  return [
1091
1071
  group(CONNECTION, 'Connection'),
1092
- group('Provider & Model', 'Provider & Model', 'Claude Code'),
1072
+ group('Provider & Model', 'Provider & Model'),
1093
1073
  group('Behavior', 'Behavior', 'Retries & Timeouts', 'Automation', 'Execution'),
1094
1074
  group('Context Compaction', 'Context Compaction', 'Context Storage'),
1095
1075
  group('Tools & Security', 'Tool Access'),
@@ -1252,8 +1232,7 @@ function applySettingChange(ctx, setting, value) {
1252
1232
  return;
1253
1233
  }
1254
1234
  switch (setting) {
1255
- case 'provider':
1256
- case 'claudeCodeModel': {
1235
+ case 'provider': {
1257
1236
  // The route is part of the choice: a local provider never runs through
1258
1237
  // Zerg Router because routing happened to be automatic.
1259
1238
  const selection = plannedModelSelection(ctx, setting, value);
@@ -1297,9 +1276,6 @@ function applySettingChange(ctx, setting, value) {
1297
1276
  case 'codexFastMode':
1298
1277
  ctx.config.set('codexFastMode', value === 'true');
1299
1278
  break;
1300
- case 'claudeCodeStatus':
1301
- // Read-only informational setting.
1302
- break;
1303
1279
  case 'panesCustomOptions':
1304
1280
  // The row shows a list and is only ever written by the manager its Enter
1305
1281
  // opens. A renderer without that surface must not store a typed line over
@@ -1767,7 +1743,14 @@ function applySettingChange(ctx, setting, value) {
1767
1743
  case 'dictationProvider':
1768
1744
  if (value !== 'local' && value !== 'openai' && value !== 'macos')
1769
1745
  throw new Error(`Unknown dictation provider: ${value}`);
1746
+ // Only the person chooses, as with /dictation: a panel relayed input opened (any panel opened from the terminal
1747
+ // of a ZTC pane or a colony cell, whose keys can't be told from the overseer's write_terminal_pane) refuses
1748
+ // before anything is saved.
1749
+ if (ctx.commandOrigin === 'relayed')
1750
+ throw new Error(dictationChoiceRefusal('Set the Dictation provider'));
1770
1751
  ctx.config.set('dictation', { ...ctx.config.get().dictation, provider: value });
1752
+ // The same choice as /dictation, said as it is made: where the audio goes and, for OpenAI, what pays.
1753
+ ctx.addMessage({ role: 'system', content: dictationChoiceNotice(value) });
1771
1754
  break;
1772
1755
  case 'dictationLanguage':
1773
1756
  ctx.config.set('dictation', { ...ctx.config.get().dictation, language: value.trim() || undefined });
@@ -1810,6 +1793,8 @@ function applySettingChange(ctx, setting, value) {
1810
1793
  case 'simProvider':
1811
1794
  if (!value.trim())
1812
1795
  throw new Error('Simulation provider cannot be empty.');
1796
+ if (isRetiredProvider(value))
1797
+ throw new Error(retiredProviderMessage(value.trim()));
1813
1798
  ctx.config.set('simProvider', value.trim());
1814
1799
  break;
1815
1800
  case 'simModel':
@@ -1898,15 +1883,15 @@ function applySettingChange(ctx, setting, value) {
1898
1883
  }
1899
1884
  }
1900
1885
  /** Rows that choose what the agent runs on. */
1901
- const MODEL_SELECTION_SETTINGS = new Set(['provider', 'model', 'claudeCodeModel']);
1886
+ const MODEL_SELECTION_SETTINGS = new Set(['provider', 'model']);
1902
1887
  /** The provider, model and route a provider or model row selects. */
1903
1888
  function plannedModelSelection(ctx, setting, value) {
1904
1889
  const current = ctx.config.getProvider();
1905
1890
  if (setting === 'model')
1906
1891
  return { provider: current, model: value };
1907
- if (setting === 'claudeCodeModel')
1908
- return { provider: 'claude_code', model: value, authMode: 'direct' };
1909
1892
  const choice = value.startsWith(ROUTER_CHOICE_PREFIX) ? value.slice(ROUTER_CHOICE_PREFIX.length) : value;
1893
+ if (isRetiredProvider(choice))
1894
+ throw new Error(retiredProviderMessage(choice, current));
1910
1895
  const provider = canonicalProvider(choice) ?? choice;
1911
1896
  if (value.startsWith(ROUTER_CHOICE_PREFIX) || isRouterOnlyProvider(provider)) {
1912
1897
  const catalog = ctx.config.getRouterCatalog?.();
@@ -1937,7 +1922,8 @@ function holdUnbuildableSelection(ctx, categories, setting, { provider, model, a
1937
1922
  }
1938
1923
  let llm;
1939
1924
  try {
1940
- llm = ctx.config.resolveLLMBackendConfig({ provider, model,
1925
+ // Checked as it will be once chosen: saving it ends any wait for a route choice.
1926
+ llm = ctx.config.resolveLLMBackendConfig({ provider, model, asChosen: true,
1941
1927
  config: { ...ctx.config.get(), provider, model, ...(authMode ? { authMode } : {}) } });
1942
1928
  }
1943
1929
  catch (error) {
@@ -39,6 +39,11 @@ export const simCommand = {
39
39
  ctx.reloadAgent();
40
40
  const enterMessage = simMode.messages?.onEnter || 'Simulation mode activated.';
41
41
  ctx.addMessage({ role: 'system', content: enterMessage });
42
+ // A simulation route naming a retired Claude Code provider (ZTC_SIM_PROVIDER,
43
+ // a saved world) runs on another route: say so where the person reads.
44
+ const { takeSimulationRouteNotices } = await import('../../simulation/inference.js');
45
+ for (const content of takeSimulationRouteNotices())
46
+ ctx.addMessage({ role: 'system', content });
42
47
  // If user provided a scenario, inject it as a user message and trigger agent
43
48
  const scenario = args.join(' ');
44
49
  if (scenario) {
@@ -93,6 +98,10 @@ export const simStatusCommand = {
93
98
  });
94
99
  return;
95
100
  }
101
+ // A world loaded since /sim may have named a retired route: say so first.
102
+ const { takeSimulationRouteNotices } = await import('../../simulation/inference.js');
103
+ for (const content of takeSimulationRouteNotices())
104
+ ctx.addMessage({ role: 'system', content });
96
105
  // Inject a status request and trigger agent turn
97
106
  ctx.addMessage({
98
107
  role: 'user',
@@ -19,10 +19,11 @@ export function createSubsCommand(deps = {}) {
19
19
  const home = (deps.home ?? homedir)();
20
20
  const panes = ctx.config.get().panes ?? {};
21
21
  const chosen = panes.agentProfiles ?? {};
22
+ const registered = (cli) => panes.agentProfileDirs?.[cli] ?? {};
22
23
  if (args.length === 0) {
23
24
  const lines = ['claude', 'codex'].map(cli => {
24
25
  const label = AGENT_CLIS[cli].label;
25
- const profiles = listAgentProfiles(cli, home);
26
+ const profiles = listAgentProfiles(cli, home, registered(cli));
26
27
  const using = chosen[cli] ? `the "${chosen[cli]}" profile` : `${label}'s own sign-in`;
27
28
  const known = profiles.length > 0 ? `Profiles: ${profiles.join(', ')}.` : 'No ZTC profiles yet.';
28
29
  return `${label}: new panes use ${using}. ${known}`;
@@ -45,7 +46,7 @@ export function createSubsCommand(deps = {}) {
45
46
  ctx.addMessage({ role: 'system', content: `"${name}" is not a profile name: use letters, digits, ".", "_" or "-", up to 32.` });
46
47
  return;
47
48
  }
48
- ensureAgentProfile(cli, name, home);
49
+ ensureAgentProfile(cli, name, home, registered(cli));
49
50
  next[cli] = name;
50
51
  }
51
52
  else {