@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
@@ -1,15 +1,15 @@
1
1
  import { CODEX_AUTH_SENTINEL, hasUsableCodexAuth } from '../agent/backends/codex_auth.js';
2
- import { CLAUDE_CODE_AUTH_SENTINEL, hasUsableClaudeCodeCliAuth as hasUsableClaudeCodeAuth } from '../agent/backends/claude_cli.js';
3
2
  import { KIMI_CODE_AUTH_SENTINEL, hasUsableKimiCodeAuth } from '../agent/backends/kimi_code_auth.js';
4
3
  import { CODEX_APP_SERVER_SENTINEL, CODEX_LEGACY_PROVIDER, isCodexAppServerProvider, isCodexLegacyProvider } from '../agent/backends/provider_ids.js';
5
4
  import { isCodexReasoningEffortSupported } from '../utils/models.js';
6
5
  import { DEEPSEEK_FLASH_MODEL, MODAL_DEEPSEEK_FLASH_MODEL } from '../utils/deepseek.js';
7
6
  import { FIREWORKS_FUNDED_MODEL } from '../utils/fireworks.js';
7
+ import { newestClaudeModel } from './anthropic_models.js';
8
+ import { isRetiredProvider } from './retired_ids.js';
8
9
  import { providerApiKeyEnvNames, readProviderApiKeyEnv } from './provider_api_key_env.js';
9
10
  export const DEFAULT_OPENAI_MODEL = 'gpt-5.4-nano';
10
11
  export const DEFAULT_CODEX_MODEL = 'gpt-5.6-sol';
11
12
  export const DEFAULT_ANTHROPIC_MODEL = 'claude-opus-5';
12
- export const DEFAULT_CLAUDE_CODE_MODEL = 'sonnet';
13
13
  export const DEFAULT_GEMINI_MODEL = 'gemini-3.6-flash';
14
14
  export const DEFAULT_KIMI_MODEL = 'kimi-k3';
15
15
  export const DEFAULT_KIMI_CODE_MODEL = 'k3';
@@ -61,8 +61,8 @@ export function inferDefaultProvider() {
61
61
  return keyed;
62
62
  if (hasUsableCodexAuth())
63
63
  return CODEX_LEGACY_PROVIDER;
64
- if (hasUsableClaudeCodeAuth())
65
- return 'claude_code';
64
+ // An installed `claude` is never a reason to pick a provider: Claude Code's
65
+ // sign-in is for Claude Code itself, which runs in a pane (/claude).
66
66
  if (hasUsableKimiCodeAuth())
67
67
  return 'kimi_code';
68
68
  return 'anthropic';
@@ -75,9 +75,8 @@ export function getDefaultModelForProvider(provider) {
75
75
  case 'bedrock': return process.env.AWS_BEDROCK_MODEL_ID || '';
76
76
  case 'anthropic':
77
77
  case 'claude':
78
- case 'claude_code':
79
- case 'claude-code':
80
- return DEFAULT_CLAUDE_CODE_MODEL;
78
+ // A Messages API id: AnthropicBackend sends the model unchanged.
79
+ return newestClaudeModel('sonnet');
81
80
  case 'gemini':
82
81
  return DEFAULT_GEMINI_MODEL;
83
82
  case 'kimi':
@@ -104,6 +103,9 @@ export function getDefaultModelForProvider(provider) {
104
103
  /** Providers whose standard variables an unrecognized provider id falls back to. */
105
104
  const UNKNOWN_PROVIDER_KEY_ORDER = ['anthropic', 'openai', 'gemini', 'kimi', 'openai_compatible', 'inception'];
106
105
  export function getDefaultApiKeyForProvider(provider) {
106
+ // A retired Claude Code route has no key, and must not borrow another provider's.
107
+ if (isRetiredProvider(provider))
108
+ return undefined;
107
109
  if (isCodexAppServerProvider(provider)) {
108
110
  return CODEX_APP_SERVER_SENTINEL;
109
111
  }
@@ -115,9 +117,6 @@ export function getDefaultApiKeyForProvider(provider) {
115
117
  return readProviderApiKeyEnv('anthropic')?.value;
116
118
  case 'moonshot':
117
119
  return readProviderApiKeyEnv('kimi')?.value;
118
- case 'claude_code':
119
- case 'claude-code':
120
- return CLAUDE_CODE_AUTH_SENTINEL;
121
120
  case 'kimi_code':
122
121
  case 'kimi-code':
123
122
  return hasUsableKimiCodeAuth() ? KIMI_CODE_AUTH_SENTINEL : undefined;
@@ -4,7 +4,8 @@ import { join, resolve } from 'node:path';
4
4
  import { z } from 'zod';
5
5
  import { DEFAULT_PERMISSION_PROFILES } from '../config.js';
6
6
  import { getSandboxPolicyStatus } from '../utils/sandbox.js';
7
- import { normalizeProviderId } from '../agent/backends/provider_ids.js';
7
+ import { isLocalSubscriptionProvider } from '../agent/backends/provider_ids.js';
8
+ import { assertProviderNotRetired } from './retired_routes.js';
8
9
  export const PERMISSION_CAPABILITIES = ['file_read', 'file_write', 'shell_exec', 'network', 'screen_capture', 'computer_control', 'ml_inference'];
9
10
  const strings = z.array(z.string().min(1).max(2048)).max(128);
10
11
  const profileSchema = z.object({
@@ -39,7 +40,8 @@ export function projectPermissionPolicy(config) {
39
40
  }
40
41
  /** Native provider-owned tools do not pass through ZTC's capability/approval boundary. */
41
42
  export function admitPermissionProvider(profile, policy, provider) {
42
- const native = ['claude_code', 'claude_code_direct', 'codex_app_server', 'codex_legacy', 'kimi_code'].includes(normalizeProviderId(provider).replaceAll('-', '_'));
43
+ assertProviderNotRetired(provider);
44
+ const native = isLocalSubscriptionProvider(provider);
43
45
  const constrained = Object.values(policy.capabilities).includes(false) || policy.approvalRequiredCapabilities.length > 0
44
46
  || Boolean(profile.allowedPaths?.length || profile.deniedPaths?.length || profile.allowedShellCommands?.length
45
47
  || profile.deniedShellCommands?.length || profile.networkHosts?.allow?.length || profile.networkHosts?.deny?.length || policy.commandSandbox.requested);
@@ -14,6 +14,8 @@ import { existsSync, mkdirSync, readFileSync } from 'fs';
14
14
  import { dirname, join } from 'path';
15
15
  import { isExplicitExtensionDiscovery } from '../extension_discovery.js';
16
16
  import { writeFileAtomicSync } from '../utils/atomic_write.js';
17
+ import { runtimeDiagOnce } from '../utils/debug_log.js';
18
+ import { isRetiredProvider, retiredProviderMessage } from './retired_routes.js';
17
19
  const REPO_CONFIG_RELATIVE_PATH = join('.ztc', 'config.json');
18
20
  export function repoConfigPath(cwd) {
19
21
  return join(cwd, REPO_CONFIG_RELATIVE_PATH);
@@ -49,5 +51,11 @@ export function resolveRepoModelOverride(cwd) {
49
51
  return null;
50
52
  if (!override.provider || !override.model)
51
53
  return null;
54
+ // A checked-in file is shared, so it is never rewritten: a retired Claude
55
+ // Code route in it is ignored, once with a word, and the user's route applies.
56
+ if (isRetiredProvider(override.provider)) {
57
+ runtimeDiagOnce('warn', `[ztc] ${repoConfigPath(cwd)} names model provider ${override.provider}, which is ignored. ${retiredProviderMessage(override.provider)}`);
58
+ return null;
59
+ }
52
60
  return { provider: override.provider, model: override.model };
53
61
  }
@@ -27,7 +27,7 @@ export interface AuthContext {
27
27
  * Everything a backend factory needs, resolved once behind the seam: provider +
28
28
  * model (honoring cli/session overrides), the direct provider apiKey (precedence
29
29
  * `apiKeyOverride > named variable (apiKeyEnv) or saved key > standard env var or
30
- * local login > default`, including the codex/claude_code sentinels — a saved
30
+ * local login > default`, including the codex/kimi_code sentinels — a saved
31
31
  * per-provider config key intentionally beats a stale exported env var), the
32
32
  * proxy decision, the compat baseUrl, and the codex App-Server
33
33
  * command/args + effort.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The ids of the retired Claude subscription routes (see retired_routes.ts),
3
+ * in a leaf module so provider and default resolution can recognise them
4
+ * without loading the settings move.
5
+ */
6
+ /** Every spelling of the retired providers ZTC ever accepted. */
7
+ export declare const RETIRED_PROVIDER_IDS: readonly ["claude_code", "claude-code", "claude_code_direct", "claude-code-direct"];
8
+ /**
9
+ * True for the retired Claude subscription providers in any spelling. The
10
+ * Anthropic API-key provider and its `claude` alias stay supported.
11
+ */
12
+ export declare function isRetiredProvider(provider: unknown): boolean;
13
+ /** True for model ids only the retired routes understood (`claude-code-sonnet`, `cc-opus`, …). */
14
+ export declare function isRetiredModel(model: unknown): boolean;
15
+ /** The route flags a launch was given (`--provider`, `--model`, `--auth-mode`); null when absent. */
16
+ export interface LaunchRouteFlags {
17
+ provider: string | null;
18
+ model: string | null;
19
+ authMode: string | null;
20
+ }
21
+ /**
22
+ * Launch flags with a retired route taken out. A retired provider goes with
23
+ * the model and the auth mode given with it (older parents add `--auth-mode
24
+ * direct` to a claude_code child), as relaunched child panes drop them; a
25
+ * retired model goes on its own. `ignored` names what went, as it was written.
26
+ */
27
+ export declare function withoutRetiredLaunchFlags(flags: LaunchRouteFlags): {
28
+ kept: LaunchRouteFlags;
29
+ ignored?: {
30
+ retired: string;
31
+ settings: string[];
32
+ };
33
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The ids of the retired Claude subscription routes (see retired_routes.ts),
3
+ * in a leaf module so provider and default resolution can recognise them
4
+ * without loading the settings move.
5
+ */
6
+ /** Every spelling of the retired providers ZTC ever accepted. */
7
+ export const RETIRED_PROVIDER_IDS = ['claude_code', 'claude-code', 'claude_code_direct', 'claude-code-direct'];
8
+ /**
9
+ * True for the retired Claude subscription providers in any spelling. The
10
+ * Anthropic API-key provider and its `claude` alias stay supported.
11
+ */
12
+ export function isRetiredProvider(provider) {
13
+ if (typeof provider !== 'string' || !provider)
14
+ return false;
15
+ const id = provider.trim().toLowerCase().replace(/-/g, '_');
16
+ return id === 'claude_code' || id === 'claude_code_direct';
17
+ }
18
+ const RETIRED_MODEL_PATTERN = /^(?:claude-code|cc)-(opus|sonnet|haiku)$/i;
19
+ /** True for model ids only the retired routes understood (`claude-code-sonnet`, `cc-opus`, …). */
20
+ export function isRetiredModel(model) {
21
+ return typeof model === 'string' && RETIRED_MODEL_PATTERN.test(model.trim());
22
+ }
23
+ /**
24
+ * Launch flags with a retired route taken out. A retired provider goes with
25
+ * the model and the auth mode given with it (older parents add `--auth-mode
26
+ * direct` to a claude_code child), as relaunched child panes drop them; a
27
+ * retired model goes on its own. `ignored` names what went, as it was written.
28
+ */
29
+ export function withoutRetiredLaunchFlags(flags) {
30
+ const { provider, model, authMode } = flags;
31
+ if (provider !== null && isRetiredProvider(provider)) {
32
+ const settings = [`--provider ${provider}`, ...(model ? [`--model ${model}`] : []), ...(authMode ? [`--auth-mode ${authMode}`] : [])];
33
+ return { kept: { provider: null, model: null, authMode: null }, ignored: { retired: provider, settings } };
34
+ }
35
+ if (model !== null && isRetiredModel(model)) {
36
+ return { kept: { provider, model: null, authMode }, ignored: { retired: model, settings: [`--model ${model}`] } };
37
+ }
38
+ return { kept: { provider, model, authMode } };
39
+ }
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Retired model routes: the two ways a Claude subscription used to be ZTC's
3
+ * own model backend. `claude_code` ran `claude -p` as the backend, and
4
+ * `claude_code_direct` called the Messages API with Claude Code's saved
5
+ * sign-in. Anthropic's terms reserve subscription sign-in for Claude Code
6
+ * itself, so ZTC no longer offers either; a Claude subscription runs in a
7
+ * Claude Code pane (/claude) instead, with ZTC's sign-in profiles.
8
+ *
9
+ * This module is the one list of retired ids, the words every surface uses
10
+ * about them, and the one-time move of a profile's saved settings. The move
11
+ * reads no credential: it decides from facts ConfigStore hands it (a key
12
+ * variable is set, a Router login is current, a directory exists) and keeps
13
+ * each Claude account's directory by its path only, never opening it. It only
14
+ * ever chooses a route the user set up in ZTC itself, so nobody is moved to
15
+ * per-token billing on a key they never gave ZTC, or to another vendor.
16
+ */
17
+ import type { ZTCConfig } from './types.js';
18
+ export { isRetiredModel, isRetiredProvider, RETIRED_PROVIDER_IDS } from './retired_ids.js';
19
+ /** The notice the move leaves for the next interactive launch. */
20
+ export declare const CLAUDE_RETIREMENT_NOTICE_ID = "claude-subscription-retired";
21
+ /** The move's first backup, next to config.json; a later move adds a timestamp instead. */
22
+ export declare const RETIRED_ROUTES_BACKUP_SUFFIX = ".pre-retired-routes-v1.bak";
23
+ /**
24
+ * The Anthropic model for a model a retired route saved. Claude Code's aliases
25
+ * (`sonnet`, `claude-code-opus`, `cc-haiku`, …) become the newest model of
26
+ * that family in ZTC's catalog; an explicit `claude-*` id stays as chosen;
27
+ * anything else becomes the current Sonnet.
28
+ */
29
+ export declare function anthropicModelFor(model: unknown): string;
30
+ /** Why the routes are gone, in one clause every surface shares. */
31
+ export declare const CLAUDE_SUBSCRIPTION_POLICY = "Anthropic's terms reserve subscription sign-in for Claude Code itself";
32
+ /** Where a Claude subscription and ZTC's own model go instead. */
33
+ export declare const CLAUDE_SUBSCRIPTION_ALTERNATIVES: string;
34
+ /** What ZTC says when something asks for a retired provider. */
35
+ export declare function retiredProviderMessage(provider: string, replacement?: string): string;
36
+ /** What ZTC says about a retired model id. */
37
+ export declare function retiredModelMessage(model: string): string;
38
+ /** Raised wherever a retired provider would otherwise become a backend. */
39
+ export declare class RetiredProviderError extends Error {
40
+ readonly provider: string;
41
+ constructor(provider: string, replacement?: string);
42
+ }
43
+ /** Throw RetiredProviderError for a retired provider; any other id passes. */
44
+ export declare function assertProviderNotRetired(provider: string | null | undefined, replacement?: string): void;
45
+ /** A Claude Code sign-in token, which is never an Anthropic API key. */
46
+ export declare function isClaudeCodeToken(value: unknown): boolean;
47
+ /** What ZTC says when someone offers it a Claude Code sign-in token as a key. */
48
+ export declare const CLAUDE_CODE_TOKEN_MESSAGE = "That is a Claude Code sign-in token, not an API key, so ZTC did not save it: Anthropic's terms reserve subscription sign-in for Claude Code itself. Create an API key at console.anthropic.com, or use your subscription in a Claude Code pane with /claude.";
49
+ /**
50
+ * What ZTC says when the key it would send is a Claude Code sign-in token,
51
+ * which it never sends: `where` names the variable or setting that holds it
52
+ * (`ANTHROPIC_API_KEY`), never its value.
53
+ */
54
+ export declare function claudeCodeTokenNotSentMessage(where: string): string;
55
+ /** What a backend says when the only Anthropic credential it was given is a Claude Code sign-in token. */
56
+ export declare const CLAUDE_CODE_TOKEN_NOT_SENT: string;
57
+ /**
58
+ * Something this process was asked that names a retired route: launch flags,
59
+ * environment variables, a resumed session or a simulation. Interactive
60
+ * launches ignore it and say so; runs nobody watches refuse an explicit one
61
+ * (see app/retired_route_gate.ts).
62
+ */
63
+ export interface RetiredRouteRequest {
64
+ source: 'flag' | 'env' | 'session' | 'simulation';
65
+ /** What asked, as written (`--provider claude_code`, `ZTC_MODEL=sonnet`); empty for a saved session or world. */
66
+ settings: string[];
67
+ /** The retired provider or model id that decided it. */
68
+ retired: string;
69
+ /**
70
+ * For a request from the environment, the launch flags that outrank it, as
71
+ * flags outrank these variables everywhere else: `provider` for a provider
72
+ * variable (and the model variables ignored with it), `model` for a retired
73
+ * model variable. A run given all of them uses its flags instead.
74
+ */
75
+ outrankedBy?: ReadonlyArray<'provider' | 'model'>;
76
+ }
77
+ /** `a`, `a and b`, `a, b and c`. */
78
+ export declare function listOf(items: readonly string[]): string;
79
+ /**
80
+ * What an interactive launch says about a request it ignored, naming the route
81
+ * that actually runs (`provider/model`, read once every override applied).
82
+ */
83
+ export declare function retiredRouteWarning(request: RetiredRouteRequest, route: string): string;
84
+ /**
85
+ * What a run nobody watches can pass to choose a route by itself. `--auth-mode
86
+ * direct` is part of it: a profile without a route (or still saved on a retired
87
+ * one) may be pinned to Zerg Router, where a provider's key alone reaches no model.
88
+ */
89
+ export declare const RUN_ON_A_KEY_ADVICE = "pass --provider, --model and --auth-mode direct to run on that provider's API key";
90
+ /** Why a simulation does not run while the move off the retired routes leaves the profile waiting for a route choice. */
91
+ export declare const SIMULATION_AWAITS_A_ROUTE = "No model route is set up in ZTC yet, so the simulation did not run: choose one with /connect.";
92
+ /** What a caller of route resolution says while the profile waits for a route choice (see RouteAwaitingChoiceError). */
93
+ export declare const ROUTE_AWAITS_A_CHOICE = "No model route is set up in ZTC yet: choose one with /connect.";
94
+ /**
95
+ * Route resolution has no route: the move off the retired routes left this
96
+ * profile waiting for a route choice, and this run's own launch flags chose
97
+ * none (see ConfigStore.routeAwaitingChoice). Every caller treats it as having
98
+ * no route; `notice` is the move's notice, for a launch that shows it again.
99
+ */
100
+ export declare class RouteAwaitingChoiceError extends Error {
101
+ readonly notice: string;
102
+ constructor(notice: string);
103
+ }
104
+ /**
105
+ * What a simulation that named a retired Claude Code route says when it can't
106
+ * continue on the profile's own route either (retiredRouteWarning says where
107
+ * one that can continues): `reason` says why it did not run, and how to choose
108
+ * a route.
109
+ */
110
+ export declare function retiredSimulationRefusal(request: RetiredRouteRequest, reason: string): string;
111
+ /**
112
+ * The route a run would fall back on once a retired request is dropped:
113
+ * `ready` reaches a model, `none` is a profile the move left waiting for
114
+ * /connect, and `retired` is a profile still saved on a retired provider
115
+ * (its move could not run).
116
+ */
117
+ export type ConfiguredRoute = {
118
+ kind: 'ready';
119
+ } | {
120
+ kind: 'none';
121
+ } | {
122
+ kind: 'retired';
123
+ provider: string;
124
+ };
125
+ /**
126
+ * What a run nobody watches says before it exits 2 because a retired route is
127
+ * all it was asked or saved to use. Each way out it names works when a script
128
+ * follows it as written: removing the flags and unsetting the variables it
129
+ * names, or passing --provider and --model of a provider ZTC offers, which
130
+ * outrank those variables.
131
+ */
132
+ export declare function retiredRouteRefusal(requests: readonly RetiredRouteRequest[], configured?: ConfiguredRoute): string;
133
+ /** Facts ConfigStore gathers for the move; none of them is a credential. */
134
+ export interface RetiredRouteSignals {
135
+ /** The standard variable that holds an Anthropic key, when one does: only ever named and offered, never chosen. */
136
+ anthropicKeyInEnvironment?: string;
137
+ /** The variable the user named in ZTC for Anthropic's key (apiKeyEnv) holds a key: that is a key set up in ZTC. */
138
+ namedAnthropicKeySet: boolean;
139
+ /** The Router origin this profile is signed in to, when the login is current. */
140
+ routerOrigin?: string;
141
+ /** CLAUDE_CODE_OAUTH_TOKEN is set (presence only, never its value). */
142
+ claudeCodeTokenInEnvironment: boolean;
143
+ /** The user's home directory, for `~` in saved paths. */
144
+ home: string;
145
+ /** Claude Code's own config directory (~/.claude): its sign-in needs no profile. */
146
+ claudeHome: string;
147
+ /** Profile names already taken by directories under ~/.ztc/agent-profiles/claude. */
148
+ takenProfileNames: readonly string[];
149
+ /** Whether a directory exists, checked without opening anything in it. */
150
+ directoryExists: (path: string) => boolean;
151
+ /** Where the settings from before the move are kept, for the notice to name. */
152
+ backupPath?: string;
153
+ }
154
+ export interface RetiredRouteMigration {
155
+ settings: Partial<ZTCConfig>;
156
+ notice: string;
157
+ }
158
+ /** `~` and `~/…` read against the home directory; anything else as written. */
159
+ export declare function expandHomePath(path: string, home: string): string;
160
+ /** Whether saved settings still name a retired route, and so need the move; cheap, reads nothing else. */
161
+ export declare function needsRetiredRouteMove(saved: Partial<ZTCConfig>): boolean;
162
+ /**
163
+ * A copy of saved settings safe to keep as a backup: keys filed under a retired
164
+ * provider (the legacy single key of a retired provider, and one an earlier
165
+ * move kept apart, included) are left out, and so is any text holding a
166
+ * Claude Code sign-in token, wherever it was saved (a `Bearer sk-ant-oat…`
167
+ * header included).
168
+ */
169
+ export declare function withoutRetiredSecrets(saved: Partial<ZTCConfig>): Partial<ZTCConfig>;
170
+ /**
171
+ * Move a profile's saved settings off the retired routes, or null when there
172
+ * is nothing to move. Pure: the result depends only on `saved` and `signals`,
173
+ * moving its result again returns null, and no input shape makes it throw.
174
+ *
175
+ * - A retired provider moves to Anthropic with the same Claude model (Claude
176
+ * Code's aliases map to the newest model of their family), on a key set up
177
+ * in ZTC, else a Zerg Router login, else waiting for /connect (marked by
178
+ * retiredRouteAwaitingChoice until a route is chosen).
179
+ * - Each Claude account (`claude_code` and `claude_code_direct`, both kept a
180
+ * Claude Code config directory) becomes a Claude Code sign-in profile on that
181
+ * directory, named from its id, with its old id recorded. `~` is expanded; a
182
+ * relative path gets no profile. The account in use becomes the profile new
183
+ * Claude Code panes start on, unless the user chose one. An account on
184
+ * ~/.claude is Claude Code's own sign-in, which /claude uses anyway.
185
+ * - Automatic account rotation is retired, so its settings go.
186
+ * - Keys and settings filed under a retired id: Claude Code's tokens and the
187
+ * sign-in placeholder are dropped (a token saved as a key anywhere else
188
+ * too). A real Anthropic API key is kept apart from apiKeys when no
189
+ * Anthropic key of the user's own is saved (see KeptAnthropicKey): named in
190
+ * the notice and offered in /connect, never used on its own.
191
+ */
192
+ export declare function migrateRetiredClaudeRoutes(saved: Partial<ZTCConfig>, signals: RetiredRouteSignals): RetiredRouteMigration | null;