@zergai/ztc 0.21.0-beta.1 → 0.22.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.
- package/README.md +144 -33
- package/bin/zmux-darwin-arm64 +0 -0
- package/bin/ztc-audio-darwin-arm64 +0 -0
- package/bin/ztc-capture-darwin-arm64 +0 -0
- package/bin/ztc-tui-darwin-arm64 +0 -0
- package/bin/zterm-darwin-arm64 +2 -2
- package/dist/App.js +2 -2
- package/dist/agent/agent.d.ts +13 -3
- package/dist/agent/agent.js +179 -91
- package/dist/agent/backends/codex_app_server.d.ts +1 -0
- package/dist/agent/backends/codex_app_server.js +3 -1
- package/dist/agent/backends/host_effort_policy.d.ts +12 -0
- package/dist/agent/backends/host_effort_policy.js +132 -0
- package/dist/agent/backends/index.d.ts +3 -2
- package/dist/agent/backends/index.js +4 -0
- package/dist/agent/backends/router_gate.d.ts +11 -0
- package/dist/agent/backends/router_gate.js +27 -2
- package/dist/agent/backends/router_keys.d.ts +63 -0
- package/dist/agent/backends/router_keys.js +94 -0
- package/dist/agent/backends/router_refusal.d.ts +12 -15
- package/dist/agent/backends/router_refusal.js +29 -5
- package/dist/agent/backends/types.d.ts +10 -0
- package/dist/agent/backends/zrouter_stream.d.ts +48 -1
- package/dist/agent/backends/zrouter_stream.js +215 -24
- package/dist/agent/commands/agent_cli.js +11 -3
- package/dist/agent/commands/config.js +12 -0
- package/dist/agent/commands/index.js +2 -1
- package/dist/agent/commands/mirror.js +15 -5
- package/dist/agent/commands/provider.js +4 -2
- package/dist/agent/commands/provider_selection.js +16 -2
- package/dist/agent/commands/router_availability.d.ts +15 -0
- package/dist/agent/commands/router_availability.js +45 -0
- package/dist/agent/commands/settings.js +38 -5
- package/dist/agent/commands/subs.d.ts +4 -1
- package/dist/agent/commands/subs.js +15 -5
- package/dist/agent/commands/types.d.ts +10 -0
- package/dist/agent/commands/ztc_pane.d.ts +20 -0
- package/dist/agent/commands/ztc_pane.js +239 -0
- package/dist/agent/factory.js +10 -2
- package/dist/agent/host_model_context.d.ts +9 -0
- package/dist/agent/host_model_context.js +40 -0
- package/dist/agent/request_encoder.d.ts +3 -0
- package/dist/agent/request_encoder.js +11 -4
- package/dist/agent/runtime/tool_runtime.js +8 -2
- package/dist/agent/subagent.d.ts +9 -0
- package/dist/agent/subagent.js +65 -46
- package/dist/agent/tools/file.js +10 -6
- package/dist/agent/tools/pane.d.ts +7 -0
- package/dist/agent/tools/pane.js +31 -6
- package/dist/agent/tools/ztc_command.d.ts +12 -0
- package/dist/agent/tools/ztc_command.js +21 -6
- package/dist/app/agent_runner.js +5 -2
- package/dist/app/command_context.js +10 -4
- package/dist/app/mirror_startup.d.ts +16 -0
- package/dist/app/mirror_startup.js +10 -0
- package/dist/app/runtime_choices.d.ts +2 -0
- package/dist/app/runtime_choices.js +1 -1
- package/dist/app/runtime_choices_source.js +2 -1
- package/dist/app/tool_callbacks.js +1 -0
- package/dist/cli_args.d.ts +2 -0
- package/dist/cli_args.js +5 -0
- package/dist/cli_ratatui.d.ts +14 -0
- package/dist/cli_ratatui.js +113 -27
- package/dist/config/permissions.d.ts +13 -0
- package/dist/config/permissions.js +63 -1
- package/dist/config/retired_routes.d.ts +23 -3
- package/dist/config/retired_routes.js +62 -11
- package/dist/config/types.d.ts +18 -1
- package/dist/config.d.ts +42 -0
- package/dist/config.js +102 -3
- package/dist/desktop/daily/desktop_wiring.js +9 -0
- package/dist/desktop/daily/recipes.js +7 -1
- package/dist/headless.js +2 -2
- package/dist/library.js +2 -2
- package/dist/mcp/client.js +6 -3
- package/dist/mcp/workspace_server.d.ts +6 -1
- package/dist/mcp/workspace_server.js +58 -9
- package/dist/onboarding/first_run.d.ts +3 -1
- package/dist/onboarding/first_run.js +21 -6
- package/dist/onboarding/router_tips.js +10 -7
- package/dist/panes/agent_cli.d.ts +48 -0
- package/dist/panes/agent_cli.js +145 -0
- package/dist/panes/agent_panes.d.ts +11 -0
- package/dist/panes/agent_panes.js +25 -4
- package/dist/panes/initial_input.d.ts +6 -0
- package/dist/panes/initial_input.js +6 -0
- package/dist/panes/motsi.d.ts +22 -7
- package/dist/panes/motsi.js +36 -9
- package/dist/panes/worker_route.d.ts +123 -0
- package/dist/panes/worker_route.js +464 -0
- package/dist/panes/ztc_launch.d.ts +9 -0
- package/dist/panes/ztc_launch.js +58 -2
- package/dist/router_auth.d.ts +18 -0
- package/dist/router_auth.js +78 -2
- package/dist/types.d.ts +5 -0
- package/dist/ui/ratatui/headless_pane_manager.d.ts +2 -0
- package/dist/ui/ratatui/headless_pane_manager.js +6 -3
- package/dist/ui/ratatui/pane_relay.d.ts +11 -1
- package/dist/ui/ratatui/pane_relay.js +14 -2
- package/dist/ui/ratatui/protocol.d.ts +9 -1
- package/dist/utils/atomic_write.js +26 -1
- package/dist/utils/docker_target.js +4 -1
- package/dist/utils/subprocess_env.d.ts +18 -0
- package/dist/utils/subprocess_env.js +45 -0
- package/dist/web/mirror_authenticator.d.ts +6 -0
- package/dist/web/mirror_authenticator.js +15 -12
- package/dist/web/mirror_stream.d.ts +50 -0
- package/dist/web/mirror_stream.js +121 -30
- package/dist/worker/worker_models.d.ts +11 -0
- package/dist/worker/worker_models.js +19 -7
- package/dist/zlm-embed.mjs +1349 -429
- package/dist/zlm.js +1 -1
- package/package.json +32 -16
|
@@ -13,6 +13,19 @@ export interface PermissionPolicySnapshot {
|
|
|
13
13
|
}
|
|
14
14
|
export declare function resolvePermissionProfile(config: ZTCConfig): ZTCPermissionProfile;
|
|
15
15
|
export declare function projectPermissionPolicy(config: ZTCConfig): PermissionPolicySnapshot;
|
|
16
|
+
/**
|
|
17
|
+
* The permission settings a ZTC pane starting now runs under: the profile's saved ones in PATH (its config.json), read
|
|
18
|
+
* as a pane reads them when it starts, with ZTC's defaults for what the file doesn't set (all of them for a file it
|
|
19
|
+
* can't read). A pane's session settings are its own: no pane it opens starts on them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function savedPermissionSettings(path: string): ZTCConfig;
|
|
22
|
+
/**
|
|
23
|
+
* What a pane under NEXT's permission settings may do that one under CURRENT's may not, a few words each; none when
|
|
24
|
+
* NEXT allows nothing more. A capability counts when NEXT turns on one CURRENT keeps off, or lets it run without the
|
|
25
|
+
* host's approval CURRENT asks for; so does leaving off an OS command sandbox CURRENT requests or requires; and, when
|
|
26
|
+
* CURRENT limits files, commands or network hosts, any other limits: limits aren't ordered, so other ones count as more.
|
|
27
|
+
*/
|
|
28
|
+
export declare function permissionsBeyond(next: ZTCConfig, current: ZTCConfig): string[];
|
|
16
29
|
/** Native provider-owned tools do not pass through ZTC's capability/approval boundary. */
|
|
17
30
|
export declare function admitPermissionProvider(profile: ZTCPermissionProfile, policy: PermissionPolicySnapshot, provider: string): void;
|
|
18
31
|
export declare function describePermissionPolicy(policy: PermissionPolicySnapshot): string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
1
2
|
import { readFile } from 'node:fs/promises';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
4
|
import { join, resolve } from 'node:path';
|
|
5
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
4
6
|
import { z } from 'zod';
|
|
5
|
-
import { DEFAULT_PERMISSION_PROFILES } from '../config.js';
|
|
7
|
+
import { build_default_config, DEFAULT_PERMISSION_PROFILES } from '../config.js';
|
|
6
8
|
import { getSandboxPolicyStatus } from '../utils/sandbox.js';
|
|
7
9
|
import { isLocalSubscriptionProvider } from '../agent/backends/provider_ids.js';
|
|
8
10
|
import { assertProviderNotRetired } from './retired_routes.js';
|
|
@@ -38,6 +40,66 @@ export function projectPermissionPolicy(config) {
|
|
|
38
40
|
scope: profile.allowedPaths?.length ? `File roots: ${profile.allowedPaths.join(', ')}` : 'File roots: unrestricted by profile',
|
|
39
41
|
};
|
|
40
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The permission settings a ZTC pane starting now runs under: the profile's saved ones in PATH (its config.json), read
|
|
45
|
+
* as a pane reads them when it starts, with ZTC's defaults for what the file doesn't set (all of them for a file it
|
|
46
|
+
* can't read). A pane's session settings are its own: no pane it opens starts on them.
|
|
47
|
+
*/
|
|
48
|
+
export function savedPermissionSettings(path) {
|
|
49
|
+
let saved = {};
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
52
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
|
|
53
|
+
saved = parsed;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// No file, or one ZTC can't read: a pane starts on the defaults.
|
|
57
|
+
}
|
|
58
|
+
const defaults = build_default_config();
|
|
59
|
+
return {
|
|
60
|
+
...defaults,
|
|
61
|
+
...saved,
|
|
62
|
+
toolPermissions: saved.toolPermissions ?? defaults.toolPermissions,
|
|
63
|
+
permissionProfiles: { ...defaults.permissionProfiles, ...saved.permissionProfiles },
|
|
64
|
+
permissionProfile: saved.permissionProfile || 'trusted',
|
|
65
|
+
sandbox: { ...defaults.sandbox, ...saved.sandbox },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** A capability's standing under POLICY, least to most: off, on after the host's approval, on. */
|
|
69
|
+
function standing(policy, capability) {
|
|
70
|
+
if (!policy.capabilities[capability])
|
|
71
|
+
return 0;
|
|
72
|
+
return policy.approvalRequiredCapabilities.includes(capability) ? 1 : 2;
|
|
73
|
+
}
|
|
74
|
+
/** PROFILE's file, command and network limits, none named counting as none. */
|
|
75
|
+
function limitsOf(profile) {
|
|
76
|
+
return {
|
|
77
|
+
allowedPaths: profile.allowedPaths ?? [], deniedPaths: profile.deniedPaths ?? [], pathPrecedence: profile.pathPrecedence ?? 'deny_first',
|
|
78
|
+
allowedShellCommands: profile.allowedShellCommands ?? [], deniedShellCommands: profile.deniedShellCommands ?? [],
|
|
79
|
+
allowedHosts: profile.networkHosts?.allow ?? [], deniedHosts: profile.networkHosts?.deny ?? [],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What a pane under NEXT's permission settings may do that one under CURRENT's may not, a few words each; none when
|
|
84
|
+
* NEXT allows nothing more. A capability counts when NEXT turns on one CURRENT keeps off, or lets it run without the
|
|
85
|
+
* host's approval CURRENT asks for; so does leaving off an OS command sandbox CURRENT requests or requires; and, when
|
|
86
|
+
* CURRENT limits files, commands or network hosts, any other limits: limits aren't ordered, so other ones count as more.
|
|
87
|
+
*/
|
|
88
|
+
export function permissionsBeyond(next, current) {
|
|
89
|
+
const after = projectPermissionPolicy(next);
|
|
90
|
+
const before = projectPermissionPolicy(current);
|
|
91
|
+
const beyond = PERMISSION_CAPABILITIES.filter(cap => standing(after, cap) > standing(before, cap))
|
|
92
|
+
.map(cap => (standing(before, cap) === 1 ? `${cap} without approval` : cap));
|
|
93
|
+
if ((before.commandSandbox.requested && !after.commandSandbox.requested) || (before.commandSandbox.required && !after.commandSandbox.required)) {
|
|
94
|
+
beyond.push('no OS command sandbox');
|
|
95
|
+
}
|
|
96
|
+
const limits = limitsOf(resolvePermissionProfile(current));
|
|
97
|
+
const limited = [limits.allowedPaths, limits.deniedPaths, limits.allowedShellCommands, limits.deniedShellCommands, limits.allowedHosts,
|
|
98
|
+
limits.deniedHosts].some(list => list.length > 0);
|
|
99
|
+
if (limited && !isDeepStrictEqual(limitsOf(resolvePermissionProfile(next)), limits))
|
|
100
|
+
beyond.push('other file, command or network limits');
|
|
101
|
+
return beyond;
|
|
102
|
+
}
|
|
41
103
|
/** Native provider-owned tools do not pass through ZTC's capability/approval boundary. */
|
|
42
104
|
export function admitPermissionProvider(profile, policy, provider) {
|
|
43
105
|
assertProviderNotRetired(provider);
|
|
@@ -179,9 +179,10 @@ export declare function withoutRetiredSecrets(saved: Partial<ZTCConfig>): Partia
|
|
|
179
179
|
* - Each Claude account (`claude_code` and `claude_code_direct`, both kept a
|
|
180
180
|
* Claude Code config directory) becomes a Claude Code sign-in profile on that
|
|
181
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
|
|
183
|
-
*
|
|
184
|
-
* ~/.claude is Claude Code's own sign-in, which /claude uses
|
|
182
|
+
* relative path gets no profile. The account in use becomes a profile like
|
|
183
|
+
* the rest, never the default: /claude stays on this computer's own sign-in.
|
|
184
|
+
* An account on ~/.claude is Claude Code's own sign-in, which /claude uses
|
|
185
|
+
* anyway.
|
|
185
186
|
* - Automatic account rotation is retired, so its settings go.
|
|
186
187
|
* - Keys and settings filed under a retired id: Claude Code's tokens and the
|
|
187
188
|
* sign-in placeholder are dropped (a token saved as a key anywhere else
|
|
@@ -190,3 +191,22 @@ export declare function withoutRetiredSecrets(saved: Partial<ZTCConfig>): Partia
|
|
|
190
191
|
* the notice and offered in /connect, never used on its own.
|
|
191
192
|
*/
|
|
192
193
|
export declare function migrateRetiredClaudeRoutes(saved: Partial<ZTCConfig>, signals: RetiredRouteSignals): RetiredRouteMigration | null;
|
|
194
|
+
/** The notice the repair leaves for Main's next launch. */
|
|
195
|
+
export declare const CLAUDE_OWN_SIGN_IN_NOTICE_ID = "claude-own-sign-in";
|
|
196
|
+
/**
|
|
197
|
+
* Clear, once, the Claude Code default an earlier release's move set, or null
|
|
198
|
+
* when there is nothing to clear. That move also made the Claude account in use
|
|
199
|
+
* the profile new Claude Code panes start on (panes.agentProfiles.claude), so
|
|
200
|
+
* on a computer whose Claude Code is signed in normally (MotSi keeping that
|
|
201
|
+
* sign-in among them) /claude asked to sign in again. A default naming a
|
|
202
|
+
* profile the move made (one of panes.agentProfileAccountIds.claude's values)
|
|
203
|
+
* goes, unless the person chose it with /subs use (panes.agentProfileChosen);
|
|
204
|
+
* every profile stays, and the notice for Main says how to choose one again.
|
|
205
|
+
* /subs records a choice only from this release on, so one made before it, or
|
|
206
|
+
* one the move kept because the person had made it, can't be told from the
|
|
207
|
+
* move's: it goes too, and the notice says so.
|
|
208
|
+
* The repair is recorded (panes.claudeDefaultRepaired), so a default chosen
|
|
209
|
+
* after it stays. Pure: repairing its result again returns null, and no input
|
|
210
|
+
* shape makes it throw.
|
|
211
|
+
*/
|
|
212
|
+
export declare function repairMovedClaudeDefault(saved: Partial<ZTCConfig>): RetiredRouteMigration | null;
|
|
@@ -367,9 +367,10 @@ const CLAUDE_CODE_TOKEN_IN_ENVIRONMENT = 'CLAUDE_CODE_OAUTH_TOKEN is set in your
|
|
|
367
367
|
* - Each Claude account (`claude_code` and `claude_code_direct`, both kept a
|
|
368
368
|
* Claude Code config directory) becomes a Claude Code sign-in profile on that
|
|
369
369
|
* directory, named from its id, with its old id recorded. `~` is expanded; a
|
|
370
|
-
* relative path gets no profile. The account in use becomes
|
|
371
|
-
*
|
|
372
|
-
* ~/.claude is Claude Code's own sign-in, which /claude uses
|
|
370
|
+
* relative path gets no profile. The account in use becomes a profile like
|
|
371
|
+
* the rest, never the default: /claude stays on this computer's own sign-in.
|
|
372
|
+
* An account on ~/.claude is Claude Code's own sign-in, which /claude uses
|
|
373
|
+
* anyway.
|
|
373
374
|
* - Automatic account rotation is retired, so its settings go.
|
|
374
375
|
* - Keys and settings filed under a retired id: Claude Code's tokens and the
|
|
375
376
|
* sign-in placeholder are dropped (a token saved as a key anywhere else
|
|
@@ -484,7 +485,6 @@ export function migrateRetiredClaudeRoutes(saved, signals) {
|
|
|
484
485
|
const registered = stringEntries(dirsByCli.claude);
|
|
485
486
|
const idsByCli = isRecord(panes.agentProfileAccountIds) ? panes.agentProfileAccountIds : {};
|
|
486
487
|
const formerIds = stringEntries(idsByCli.claude);
|
|
487
|
-
const chosenByCli = isRecord(panes.agentProfiles) ? panes.agentProfiles : {};
|
|
488
488
|
const taken = new Set([...signals.takenProfileNames, ...Object.keys(registered)]);
|
|
489
489
|
const comparable = (path) => resolve(expandHomePath(path, signals.home));
|
|
490
490
|
const claudeHome = comparable(signals.claudeHome);
|
|
@@ -535,14 +535,11 @@ export function migrateRetiredClaudeRoutes(saved, signals) {
|
|
|
535
535
|
if (entry.id === activeId)
|
|
536
536
|
activeProfile = name;
|
|
537
537
|
}
|
|
538
|
-
|
|
538
|
+
// The account in use becomes a profile like the rest, never the default: /claude stays on Claude Code's own
|
|
539
|
+
// sign-in on this computer (the one MotSi or the person keeps in ~/.claude), so it never asks to sign in again.
|
|
539
540
|
if (made.length > 0) {
|
|
540
541
|
panes.agentProfileDirs = { ...dirsByCli, claude: registered };
|
|
541
542
|
panes.agentProfileAccountIds = { ...idsByCli, claude: formerIds };
|
|
542
|
-
if (activeProfile && !chosenByCli.claude) {
|
|
543
|
-
panes.agentProfiles = { ...chosenByCli, claude: activeProfile };
|
|
544
|
-
startsOn = activeProfile;
|
|
545
|
-
}
|
|
546
543
|
settings.panes = panes;
|
|
547
544
|
}
|
|
548
545
|
const keptAccounts = accounts.filter(account => !(isRecord(account) && isRetiredProvider(account.provider)));
|
|
@@ -561,8 +558,9 @@ export function migrateRetiredClaudeRoutes(saved, signals) {
|
|
|
561
558
|
}
|
|
562
559
|
for (const [name, dir] of gone)
|
|
563
560
|
accountLines.push(`/claude @${name} opens on ${dir}, which is gone: sign in there the first time.`);
|
|
564
|
-
if (
|
|
565
|
-
accountLines.push(`
|
|
561
|
+
if (activeProfile) {
|
|
562
|
+
accountLines.push(`Plain /claude opens Claude Code on this computer's own sign-in; /subs use claude ${activeProfile} makes @${activeProfile} the default.`);
|
|
563
|
+
}
|
|
566
564
|
if (ownSignIn)
|
|
567
565
|
accountLines.push('Your ~/.claude account is Claude Code\'s own sign-in, which /claude uses.');
|
|
568
566
|
for (const { label, path, name } of relative) {
|
|
@@ -607,3 +605,56 @@ export function migrateRetiredClaudeRoutes(saved, signals) {
|
|
|
607
605
|
delete settings.retiredRouteAwaitingChoice;
|
|
608
606
|
return { settings, notice };
|
|
609
607
|
}
|
|
608
|
+
// ── The one-time repair of an earlier move's Claude Code default ────────────
|
|
609
|
+
/** The notice the repair leaves for Main's next launch. */
|
|
610
|
+
export const CLAUDE_OWN_SIGN_IN_NOTICE_ID = 'claude-own-sign-in';
|
|
611
|
+
/**
|
|
612
|
+
* Clear, once, the Claude Code default an earlier release's move set, or null
|
|
613
|
+
* when there is nothing to clear. That move also made the Claude account in use
|
|
614
|
+
* the profile new Claude Code panes start on (panes.agentProfiles.claude), so
|
|
615
|
+
* on a computer whose Claude Code is signed in normally (MotSi keeping that
|
|
616
|
+
* sign-in among them) /claude asked to sign in again. A default naming a
|
|
617
|
+
* profile the move made (one of panes.agentProfileAccountIds.claude's values)
|
|
618
|
+
* goes, unless the person chose it with /subs use (panes.agentProfileChosen);
|
|
619
|
+
* every profile stays, and the notice for Main says how to choose one again.
|
|
620
|
+
* /subs records a choice only from this release on, so one made before it, or
|
|
621
|
+
* one the move kept because the person had made it, can't be told from the
|
|
622
|
+
* move's: it goes too, and the notice says so.
|
|
623
|
+
* The repair is recorded (panes.claudeDefaultRepaired), so a default chosen
|
|
624
|
+
* after it stays. Pure: repairing its result again returns null, and no input
|
|
625
|
+
* shape makes it throw.
|
|
626
|
+
*/
|
|
627
|
+
export function repairMovedClaudeDefault(saved) {
|
|
628
|
+
const panes = isRecord(saved.panes) ? saved.panes : undefined;
|
|
629
|
+
if (!panes || panes.claudeDefaultRepaired === true)
|
|
630
|
+
return null;
|
|
631
|
+
const defaults = stringEntries(panes.agentProfiles);
|
|
632
|
+
const current = defaults.claude;
|
|
633
|
+
if (!current)
|
|
634
|
+
return null;
|
|
635
|
+
const madeByMove = Object.values(stringEntries(isRecord(panes.agentProfileAccountIds) ? panes.agentProfileAccountIds.claude : undefined));
|
|
636
|
+
if (!madeByMove.includes(current))
|
|
637
|
+
return null;
|
|
638
|
+
if (stringEntries(panes.agentProfileChosen).claude === current)
|
|
639
|
+
return null;
|
|
640
|
+
const others = Object.fromEntries(Object.entries(isRecord(panes.agentProfiles) ? panes.agentProfiles : {}).filter(([cli]) => cli !== 'claude'));
|
|
641
|
+
const names = [...new Set([current, ...madeByMove])];
|
|
642
|
+
// A /subs choice from before this release was never recorded, so it can't be told from the move's and goes too.
|
|
643
|
+
const notice = 'Claude Code now opens on this computer\'s own sign-in. '
|
|
644
|
+
+ (names.length === 1
|
|
645
|
+
? `Your former ZTC Claude account is a profile: /claude @${current}. /subs use claude ${current} makes it the default again`
|
|
646
|
+
: `Your former ZTC Claude accounts are profiles: ${listOf(names.map(name => `/claude @${name}`))}. `
|
|
647
|
+
+ '/subs use claude <name> makes one the default again')
|
|
648
|
+
+ '; a default you chose with /subs before this update was cleared too.';
|
|
649
|
+
const kept = Array.isArray(saved.pendingNotices)
|
|
650
|
+
? saved.pendingNotices.filter((entry) => isRecord(entry) && entry.id !== CLAUDE_OWN_SIGN_IN_NOTICE_ID)
|
|
651
|
+
: [];
|
|
652
|
+
return {
|
|
653
|
+
settings: {
|
|
654
|
+
...saved,
|
|
655
|
+
panes: { ...panes, agentProfiles: others, claudeDefaultRepaired: true },
|
|
656
|
+
pendingNotices: [...kept, { id: CLAUDE_OWN_SIGN_IN_NOTICE_ID, text: notice }],
|
|
657
|
+
},
|
|
658
|
+
notice,
|
|
659
|
+
};
|
|
660
|
+
}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -301,8 +301,25 @@ export interface PanesSettings {
|
|
|
301
301
|
* applies. ZTC never opens Claude Code's files to decide. Default: true.
|
|
302
302
|
*/
|
|
303
303
|
claudeBadges?: boolean;
|
|
304
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* How the Claude Code and Codex panes ZTC opens handle permission prompts. 'bypass' starts Claude Code with
|
|
306
|
+
* --dangerously-skip-permissions and Codex with --dangerously-bypass-approvals-and-sandbox, so they run commands
|
|
307
|
+
* without asking; 'ask' passes neither and the CLI's own settings apply. A permission flag the person gives a pane
|
|
308
|
+
* wins either way, and #860's delegated workers never bypass. Unset (a profile saved before this setting): 'bypass'.
|
|
309
|
+
*/
|
|
310
|
+
agentPermissions?: 'bypass' | 'ask';
|
|
311
|
+
/** The ZTC sign-in profile new Claude Code / Codex panes start on; unset for this computer's normal sign-in. */
|
|
305
312
|
agentProfiles?: Partial<Record<'claude' | 'codex', string>>;
|
|
313
|
+
/**
|
|
314
|
+
* The profile the person chose with `/subs use`, per CLI: their own choice, which the one-time repair of an earlier
|
|
315
|
+
* release's Claude Code default (config/retired_routes.ts) never clears.
|
|
316
|
+
*/
|
|
317
|
+
agentProfileChosen?: Partial<Record<'claude' | 'codex', string>>;
|
|
318
|
+
/**
|
|
319
|
+
* Set once that repair has cleared a Claude Code default an earlier release's move off the retired routes chose,
|
|
320
|
+
* so a default set again afterwards stays.
|
|
321
|
+
*/
|
|
322
|
+
claudeDefaultRepaired?: boolean;
|
|
306
323
|
/**
|
|
307
324
|
* Sign-in profiles kept in a directory of their own, by profile name, used
|
|
308
325
|
* exactly as written instead of ~/.ztc/agent-profiles/<cli>/<name>. Claude
|
package/dist/config.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ export declare class ConfigStore {
|
|
|
57
57
|
private savedFileStamp;
|
|
58
58
|
/** The profile's Router sign-in as this process last read it, so a login or logout elsewhere is noticed. */
|
|
59
59
|
private savedAuthStamp;
|
|
60
|
+
/** router-auth.json as routerCredentials were read from it (see followRouterSignIn). */
|
|
61
|
+
private routerCredentialsStamp;
|
|
60
62
|
/**
|
|
61
63
|
* The settings as save() would have written them when this process last read or wrote the file: what a later save
|
|
62
64
|
* compares against to tell this process's own changes from another ZTC's (see mergeSavedSettings).
|
|
@@ -168,6 +170,13 @@ export declare class ConfigStore {
|
|
|
168
170
|
* read-time guard still refuses a retired route.
|
|
169
171
|
*/
|
|
170
172
|
private moveOffRetiredRoutes;
|
|
173
|
+
/**
|
|
174
|
+
* Clear, once, the Claude Code default an earlier release's move off the retired routes chose
|
|
175
|
+
* (config/retired_routes.ts, repairMovedClaudeDefault), so /claude opens on this computer's own sign-in, and save it
|
|
176
|
+
* with its notice for Main. Nothing here may stop ZTC from starting: when it can't be saved now (or a move this load
|
|
177
|
+
* made is only ever saved with its backup), it applies to this run, and the next save keeps it.
|
|
178
|
+
*/
|
|
179
|
+
private clearMovedClaudeDefault;
|
|
171
180
|
private applyEnvOverrides;
|
|
172
181
|
load(force?: boolean, options?: ConfigLoadOptions): Promise<ZTCConfig>;
|
|
173
182
|
/**
|
|
@@ -287,6 +296,8 @@ export declare class ConfigStore {
|
|
|
287
296
|
private replaceEnvironmentValue;
|
|
288
297
|
setAll(next: Partial<ZTCConfig>): void;
|
|
289
298
|
hasApiKey(): boolean;
|
|
299
|
+
/** The name Router gave this device at the profile's Router login, when the login kept one (the launch card shows it). */
|
|
300
|
+
getRouterDeviceName(): string | undefined;
|
|
290
301
|
/** Router login state for the configured Router origin; never contacts Router. */
|
|
291
302
|
getRouterSessionStatus(): RouterSessionStatus;
|
|
292
303
|
/**
|
|
@@ -536,6 +547,12 @@ export declare class ConfigStore {
|
|
|
536
547
|
* Undefined when nothing says which levels the model takes (any then).
|
|
537
548
|
*/
|
|
538
549
|
getReasoningChoices(provider?: string, model?: string): readonly string[] | undefined;
|
|
550
|
+
/**
|
|
551
|
+
* The effort a new ZTC process on PROVIDER's MODEL starts at with no launch effort of its own: the profile's saved one
|
|
552
|
+
* for the model, the provider or every model, as getCodexEffort picks it, read without this process's launch flag or
|
|
553
|
+
* session settings, which no other process sees.
|
|
554
|
+
*/
|
|
555
|
+
getSavedCodexEffort(provider: string, model: string): CodexReasoningEffort | undefined;
|
|
539
556
|
/** Saved effort the active (or given) model rejects on its route; undefined when it applies. */
|
|
540
557
|
getUnsupportedCodexEffort(provider?: string, model?: string): CodexReasoningEffort | undefined;
|
|
541
558
|
/** Effort chosen by a startup `--effort` flag for this process (= none when unset). */
|
|
@@ -617,6 +634,11 @@ export declare class ConfigStore {
|
|
|
617
634
|
* reaches neither the panes it opens nor a session it resumes (see launchedByParent).
|
|
618
635
|
*/
|
|
619
636
|
markLaunchedByParent(launched: boolean): void;
|
|
637
|
+
/**
|
|
638
|
+
* The Zerg Router this profile's Router sign-in is for, as router-auth.json holds it now, expired or not; undefined when
|
|
639
|
+
* there is none, or one ZTC can't read. Never its key.
|
|
640
|
+
*/
|
|
641
|
+
getRouterSignInOrigin(): string | undefined;
|
|
620
642
|
/**
|
|
621
643
|
* The person's own Zerg Router credential: this profile's Router sign-in (a CLI device key), while it is valid. The
|
|
622
644
|
* legacy platform login is not one: it is the platform's, scoped to its /api/zrouter proxy.
|
|
@@ -625,6 +647,26 @@ export declare class ConfigStore {
|
|
|
625
647
|
origin: string;
|
|
626
648
|
token: string;
|
|
627
649
|
} | undefined;
|
|
650
|
+
/**
|
|
651
|
+
* The person's own Zerg Router sign-in for ORIGIN as this profile holds it now, for each request a backend built on
|
|
652
|
+
* it sends: its key and account. Router retires this computer's previous device key at every login, so a login made
|
|
653
|
+
* in another pane since the backend was built (or `ztc auth login`) is the one returned. With none for ORIGIN (signed
|
|
654
|
+
* out, in another pane or never, or signed in to another Router), or one that has expired, what the request is
|
|
655
|
+
* refused with before anything is sent.
|
|
656
|
+
*/
|
|
657
|
+
getRouterSignIn(origin: string): {
|
|
658
|
+
token: string;
|
|
659
|
+
workspaceId: string;
|
|
660
|
+
} | {
|
|
661
|
+
refused: string;
|
|
662
|
+
};
|
|
663
|
+
/**
|
|
664
|
+
* Read the profile's Zerg Router sign-in again when router-auth.json changed since this process read it: a login, a
|
|
665
|
+
* logout or a renewed login in another pane or `ztc auth login`, which retires the key this process read. Every reader
|
|
666
|
+
* of the sign-in (the route a request takes, the sign-in state, Router's catalog, a backend's next request) then sees
|
|
667
|
+
* the file as it is, with no restart. Settings saved elsewhere are read on their own schedule (refreshIfChangedElsewhere).
|
|
668
|
+
*/
|
|
669
|
+
private followRouterSignIn;
|
|
628
670
|
/**
|
|
629
671
|
* The ZergAI platform login, for `destination` only when that is the platform's own Router proxy
|
|
630
672
|
* (`<API base>/api/zrouter`), the one place the platform issued it for. Any other Router, Zerg Router's own origin
|
package/dist/config.js
CHANGED
|
@@ -17,10 +17,10 @@ import { resolveRepoModelOverride } from './config/repo_config.js';
|
|
|
17
17
|
import { CODEX_AUTH_SENTINEL, hasUsableCodexAuth } from './agent/backends/codex_auth.js';
|
|
18
18
|
import { KIMI_CODE_AUTH_SENTINEL, hasUsableKimiCodeAuth } from './agent/backends/kimi_code_auth.js';
|
|
19
19
|
import { runtimeDiag, runtimeDiagOnce } from './utils/debug_log.js';
|
|
20
|
-
import { CLAUDE_RETIREMENT_NOTICE_ID, claudeCodeTokenNotSentMessage, isClaudeCodeToken, isRetiredModel, isRetiredProvider, listOf, migrateRetiredClaudeRoutes, needsRetiredRouteMove, RETIRED_ROUTES_BACKUP_SUFFIX, RetiredProviderError, RouteAwaitingChoiceError, retiredRouteWarning, withoutRetiredSecrets, } from './config/retired_routes.js';
|
|
20
|
+
import { CLAUDE_RETIREMENT_NOTICE_ID, claudeCodeTokenNotSentMessage, isClaudeCodeToken, isRetiredModel, isRetiredProvider, listOf, migrateRetiredClaudeRoutes, needsRetiredRouteMove, repairMovedClaudeDefault, RETIRED_ROUTES_BACKUP_SUFFIX, RetiredProviderError, RouteAwaitingChoiceError, retiredRouteWarning, withoutRetiredSecrets, } from './config/retired_routes.js';
|
|
21
21
|
import { withoutRetiredLaunchFlags } from './config/retired_ids.js';
|
|
22
22
|
import { listAgentProfiles } from './panes/agent_profiles.js';
|
|
23
|
-
import { loadRouterCredentials, RouterConfigurationError } from './router_auth.js';
|
|
23
|
+
import { loadRouterCredentials, readRouterCredentialsSync, RouterConfigurationError, routerSignInRefusal } from './router_auth.js';
|
|
24
24
|
import { CODEX_APP_SERVER_SENTINEL, CODEX_LEGACY_PROVIDER, isCodexAppServerProvider, isCodexLegacyProvider, normalizeProviderId } from './agent/backends/provider_ids.js';
|
|
25
25
|
import { requiredRouterModel } from './config/router_required.js';
|
|
26
26
|
import { DEFAULT_SPINNER_VERBS } from './utils/spinner_verbs.js';
|
|
@@ -647,6 +647,8 @@ export class ConfigStore {
|
|
|
647
647
|
savedFileStamp;
|
|
648
648
|
/** The profile's Router sign-in as this process last read it, so a login or logout elsewhere is noticed. */
|
|
649
649
|
savedAuthStamp;
|
|
650
|
+
/** router-auth.json as routerCredentials were read from it (see followRouterSignIn). */
|
|
651
|
+
routerCredentialsStamp;
|
|
650
652
|
/**
|
|
651
653
|
* The settings as save() would have written them when this process last read or wrote the file: what a later save
|
|
652
654
|
* compares against to tell this process's own changes from another ZTC's (see mergeSavedSettings).
|
|
@@ -893,6 +895,34 @@ export class ConfigStore {
|
|
|
893
895
|
return saved;
|
|
894
896
|
}
|
|
895
897
|
}
|
|
898
|
+
/**
|
|
899
|
+
* Clear, once, the Claude Code default an earlier release's move off the retired routes chose
|
|
900
|
+
* (config/retired_routes.ts, repairMovedClaudeDefault), so /claude opens on this computer's own sign-in, and save it
|
|
901
|
+
* with its notice for Main. Nothing here may stop ZTC from starting: when it can't be saved now (or a move this load
|
|
902
|
+
* made is only ever saved with its backup), it applies to this run, and the next save keeps it.
|
|
903
|
+
*/
|
|
904
|
+
async clearMovedClaudeDefault(saved) {
|
|
905
|
+
try {
|
|
906
|
+
const repair = repairMovedClaudeDefault(saved);
|
|
907
|
+
if (!repair)
|
|
908
|
+
return saved;
|
|
909
|
+
if (!this.unsavedRetirement) {
|
|
910
|
+
try {
|
|
911
|
+
await this.rewriteOwnSettings(() => replaceSettingsFile(configFile(), JSON.stringify(repair.settings, null, 2)));
|
|
912
|
+
}
|
|
913
|
+
catch (error) {
|
|
914
|
+
runtimeDiag('warn', `[ztc] Could not save ${configFile()} after clearing the Claude Code default an earlier move chose `
|
|
915
|
+
+ `(${error?.message ?? error}); /claude opens on this computer's own sign-in in this run.`);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return repair.settings;
|
|
919
|
+
}
|
|
920
|
+
catch (error) {
|
|
921
|
+
runtimeDiag('error', `[ztc] Could not clear the Claude Code default an earlier move chose in ${configFile()} `
|
|
922
|
+
+ `(${error?.message ?? error}); ZTC starts with it as saved.`);
|
|
923
|
+
return saved;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
896
926
|
applyEnvOverrides() {
|
|
897
927
|
const fallbackProvider = default_provider();
|
|
898
928
|
const originalProvider = this.config.provider || fallbackProvider;
|
|
@@ -992,6 +1022,7 @@ export class ConfigStore {
|
|
|
992
1022
|
this.profileEmulation = builtinProfileEmulation(activeProfile());
|
|
993
1023
|
this.routerCredentialsError = null;
|
|
994
1024
|
this.savedAuthStamp = fileStamp(routerAuthFile());
|
|
1025
|
+
this.routerCredentialsStamp = this.savedAuthStamp;
|
|
995
1026
|
try {
|
|
996
1027
|
this.routerCredentials = await loadRouterCredentials();
|
|
997
1028
|
}
|
|
@@ -1035,8 +1066,10 @@ export class ConfigStore {
|
|
|
1035
1066
|
saved = migrated;
|
|
1036
1067
|
savedText = JSON.stringify(migrated, null, 2);
|
|
1037
1068
|
}
|
|
1038
|
-
// Then move a profile off the retired Claude Code routes, with its own backup
|
|
1069
|
+
// Then move a profile off the retired Claude Code routes, with its own backup,
|
|
1070
|
+
// and clear, once, the Claude Code default an earlier release's move chose.
|
|
1039
1071
|
saved = await this.moveOffRetiredRoutes(saved, savedText);
|
|
1072
|
+
saved = await this.clearMovedClaudeDefault(saved);
|
|
1040
1073
|
this.config = { ...build_default_config(), ...saved };
|
|
1041
1074
|
this.legacyApiKeyFromEnvironment = saved.apiKey === undefined;
|
|
1042
1075
|
// Defaults were built for the preset provider. A saved provider without
|
|
@@ -1559,6 +1592,7 @@ export class ConfigStore {
|
|
|
1559
1592
|
this.loaded = true;
|
|
1560
1593
|
}
|
|
1561
1594
|
hasApiKey() {
|
|
1595
|
+
this.followRouterSignIn();
|
|
1562
1596
|
// This legacy readiness signal already includes Router/subscription auth.
|
|
1563
1597
|
if (this.getAuthMode() !== 'direct' && this.routerCredentials
|
|
1564
1598
|
&& this.get().zergProxyUrl?.replace(/\/+$/, '') === this.routerCredentials.origin
|
|
@@ -1575,8 +1609,14 @@ export class ConfigStore {
|
|
|
1575
1609
|
const key = this.getApiKey();
|
|
1576
1610
|
return !!key && key.length > 0;
|
|
1577
1611
|
}
|
|
1612
|
+
/** The name Router gave this device at the profile's Router login, when the login kept one (the launch card shows it). */
|
|
1613
|
+
getRouterDeviceName() {
|
|
1614
|
+
this.followRouterSignIn();
|
|
1615
|
+
return this.routerCredentials?.deviceName;
|
|
1616
|
+
}
|
|
1578
1617
|
/** Router login state for the configured Router origin; never contacts Router. */
|
|
1579
1618
|
getRouterSessionStatus() {
|
|
1619
|
+
this.followRouterSignIn();
|
|
1580
1620
|
const credentials = this.routerCredentials;
|
|
1581
1621
|
if (!credentials || this.routerCredentialsError
|
|
1582
1622
|
|| this.get().zergProxyUrl?.replace(/\/+$/, '') !== credentials.origin)
|
|
@@ -2218,6 +2258,16 @@ export class ConfigStore {
|
|
|
2218
2258
|
getReasoningChoices(provider = this.getProvider(), model = this.getModel()) {
|
|
2219
2259
|
return reasoningContractChoices(provider, model, this.getReasoningContract(provider, model));
|
|
2220
2260
|
}
|
|
2261
|
+
/**
|
|
2262
|
+
* The effort a new ZTC process on PROVIDER's MODEL starts at with no launch effort of its own: the profile's saved one
|
|
2263
|
+
* for the model, the provider or every model, as getCodexEffort picks it, read without this process's launch flag or
|
|
2264
|
+
* session settings, which no other process sees.
|
|
2265
|
+
*/
|
|
2266
|
+
getSavedCodexEffort(provider, model) {
|
|
2267
|
+
const catalog = this.getRoutedModelCatalog(provider);
|
|
2268
|
+
const capabilities = catalog ? resolveRouterModel(catalog, provider, model)?.capabilities : undefined;
|
|
2269
|
+
return resolveCodexEffort(this.config, provider, model, capabilities ?? this.getReasoningWireSurface(provider, model));
|
|
2270
|
+
}
|
|
2221
2271
|
/** Saved effort the active (or given) model rejects on its route; undefined when it applies. */
|
|
2222
2272
|
getUnsupportedCodexEffort(provider, model) {
|
|
2223
2273
|
const selectedProvider = provider ?? this.getProvider();
|
|
@@ -2463,16 +2513,62 @@ export class ConfigStore {
|
|
|
2463
2513
|
markLaunchedByParent(launched) {
|
|
2464
2514
|
this.launchedByParent = launched;
|
|
2465
2515
|
}
|
|
2516
|
+
/**
|
|
2517
|
+
* The Zerg Router this profile's Router sign-in is for, as router-auth.json holds it now, expired or not; undefined when
|
|
2518
|
+
* there is none, or one ZTC can't read. Never its key.
|
|
2519
|
+
*/
|
|
2520
|
+
getRouterSignInOrigin() {
|
|
2521
|
+
this.followRouterSignIn();
|
|
2522
|
+
return this.routerCredentials && !this.routerCredentialsError ? this.routerCredentials.origin : undefined;
|
|
2523
|
+
}
|
|
2466
2524
|
/**
|
|
2467
2525
|
* The person's own Zerg Router credential: this profile's Router sign-in (a CLI device key), while it is valid. The
|
|
2468
2526
|
* legacy platform login is not one: it is the platform's, scoped to its /api/zrouter proxy.
|
|
2469
2527
|
*/
|
|
2470
2528
|
getPersonalRouterCredential() {
|
|
2529
|
+
this.followRouterSignIn();
|
|
2471
2530
|
const credentials = this.routerCredentials;
|
|
2472
2531
|
if (!credentials || this.routerCredentialsError || !(Date.parse(credentials.expiresAt) > Date.now()))
|
|
2473
2532
|
return undefined;
|
|
2474
2533
|
return { origin: credentials.origin, token: credentials.token };
|
|
2475
2534
|
}
|
|
2535
|
+
/**
|
|
2536
|
+
* The person's own Zerg Router sign-in for ORIGIN as this profile holds it now, for each request a backend built on
|
|
2537
|
+
* it sends: its key and account. Router retires this computer's previous device key at every login, so a login made
|
|
2538
|
+
* in another pane since the backend was built (or `ztc auth login`) is the one returned. With none for ORIGIN (signed
|
|
2539
|
+
* out, in another pane or never, or signed in to another Router), or one that has expired, what the request is
|
|
2540
|
+
* refused with before anything is sent.
|
|
2541
|
+
*/
|
|
2542
|
+
getRouterSignIn(origin) {
|
|
2543
|
+
this.followRouterSignIn();
|
|
2544
|
+
const credentials = this.routerCredentials;
|
|
2545
|
+
if (!credentials || this.routerCredentialsError || credentials.origin !== normalizedOrigin(origin)) {
|
|
2546
|
+
return { refused: routerSignInRefusal('signed_out') };
|
|
2547
|
+
}
|
|
2548
|
+
if (!(Date.parse(credentials.expiresAt) > Date.now()))
|
|
2549
|
+
return { refused: routerSignInRefusal('expired') };
|
|
2550
|
+
return { token: credentials.token, workspaceId: credentials.workspaceId };
|
|
2551
|
+
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Read the profile's Zerg Router sign-in again when router-auth.json changed since this process read it: a login, a
|
|
2554
|
+
* logout or a renewed login in another pane or `ztc auth login`, which retires the key this process read. Every reader
|
|
2555
|
+
* of the sign-in (the route a request takes, the sign-in state, Router's catalog, a backend's next request) then sees
|
|
2556
|
+
* the file as it is, with no restart. Settings saved elsewhere are read on their own schedule (refreshIfChangedElsewhere).
|
|
2557
|
+
*/
|
|
2558
|
+
followRouterSignIn() {
|
|
2559
|
+
const stamp = fileStamp(routerAuthFile());
|
|
2560
|
+
if (stamp === this.routerCredentialsStamp)
|
|
2561
|
+
return;
|
|
2562
|
+
this.routerCredentialsStamp = stamp;
|
|
2563
|
+
try {
|
|
2564
|
+
this.routerCredentials = readRouterCredentialsSync();
|
|
2565
|
+
this.routerCredentialsError = null;
|
|
2566
|
+
}
|
|
2567
|
+
catch (error) {
|
|
2568
|
+
this.routerCredentials = null;
|
|
2569
|
+
this.routerCredentialsError = error instanceof Error ? error : new Error('Invalid ZTC router credentials. Run ztc auth login.');
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2476
2572
|
/**
|
|
2477
2573
|
* The ZergAI platform login, for `destination` only when that is the platform's own Router proxy
|
|
2478
2574
|
* (`<API base>/api/zrouter`), the one place the platform issued it for. Any other Router, Zerg Router's own origin
|
|
@@ -2488,6 +2584,7 @@ export class ConfigStore {
|
|
|
2488
2584
|
const origin = normalizedOrigin(destination);
|
|
2489
2585
|
if (!origin)
|
|
2490
2586
|
return undefined;
|
|
2587
|
+
this.followRouterSignIn();
|
|
2491
2588
|
const credentials = this.routerCredentials;
|
|
2492
2589
|
if (credentials && !this.routerCredentialsError && credentials.origin === origin) {
|
|
2493
2590
|
return { origin, token: credentials.token, workspaceId: credentials.workspaceId };
|
|
@@ -2672,6 +2769,8 @@ export class ConfigStore {
|
|
|
2672
2769
|
// standalone Router requires its own device login, including after logout.
|
|
2673
2770
|
// Modal shared endpoints are unavailable through the legacy platform proxy.
|
|
2674
2771
|
let authToken = provider !== 'modal' ? this.getPlatformProxyLogin(proxyUrl)?.token : undefined;
|
|
2772
|
+
// The sign-in as router-auth.json holds it now: another pane's login since may have replaced the key this read.
|
|
2773
|
+
this.followRouterSignIn();
|
|
2675
2774
|
let routerError = this.routerCredentialsError;
|
|
2676
2775
|
if (authMode !== 'direct' && this.routerCredentials && !routerError) {
|
|
2677
2776
|
if (proxyUrl?.replace(/\/+$/, '') !== this.routerCredentials.origin) {
|
|
@@ -12,6 +12,8 @@ import { setTimeout as delay } from 'node:timers/promises';
|
|
|
12
12
|
import { inspectWorkspaceSessions, prepareWorkspaceIsolation } from '../../workspace_collision.js';
|
|
13
13
|
import { getVersion } from '../../utils/version.js';
|
|
14
14
|
import { newZtcPaneRouteArgs } from '../../panes/ztc_launch.js';
|
|
15
|
+
import { agentPermissionsSetting, permissionDefaultArgs } from '../../panes/agent_cli.js';
|
|
16
|
+
import { configStore } from '../../config.js';
|
|
15
17
|
import { DailyStore } from './daily_store.js';
|
|
16
18
|
import { createControlServer, readTaskFile } from './control_server.js';
|
|
17
19
|
import { createApprovalBroker } from './broker.js';
|
|
@@ -539,6 +541,13 @@ export class DesktopDaily {
|
|
|
539
541
|
// for new panes, as any new ZTC pane does. Only delegated ZTC is Router-only (recipes.ts).
|
|
540
542
|
if (record.launch.tool === 'ztc')
|
|
541
543
|
record.launch.args = [...record.launch.args, ...newZtcPaneRouteArgs()];
|
|
544
|
+
// A native Claude Code or Codex pane is one the person types into, as any ZTC opens: it starts without permission
|
|
545
|
+
// prompts unless ZTC's setting says ask (panes.agentPermissions), or the CLI would refuse its flag here (Claude Code
|
|
546
|
+
// as root). A delegated worker never gets here.
|
|
547
|
+
if (record.launch.tool === 'claude_code' || record.launch.tool === 'codex') {
|
|
548
|
+
const cli = record.launch.tool === 'codex' ? 'codex' : 'claude';
|
|
549
|
+
record.launch.args = [...permissionDefaultArgs(cli, record.launch.args, agentPermissionsSetting(configStore.get().panes), { env: this.host.env ?? process.env }), ...record.launch.args];
|
|
550
|
+
}
|
|
542
551
|
let lease = await this.lease(record, !saved);
|
|
543
552
|
let accepted = false;
|
|
544
553
|
let dispatched = false;
|
|
@@ -109,12 +109,18 @@ function ztcArgs(record, resume, text) {
|
|
|
109
109
|
args.push('--effort', launch.effort);
|
|
110
110
|
return [...args, '--prompt', prompt(record, text)];
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* The one policy flag an interactive Codex pane may lead with: the person's own panes start without approval prompts
|
|
114
|
+
* unless ZTC's setting says ask (panes.agentPermissions; desktop_wiring.ts adds it). Every other policy flag is still
|
|
115
|
+
* refused, and a delegated worker never takes it (codexOptions).
|
|
116
|
+
*/
|
|
117
|
+
const INTERACTIVE_CODEX_BYPASS = '--dangerously-bypass-approvals-and-sandbox';
|
|
112
118
|
function interactive(record, resume) {
|
|
113
119
|
if (record.launch.task !== undefined)
|
|
114
120
|
throw new Error('Interactive panes accept human input only');
|
|
115
121
|
const { tool, args } = record.launch;
|
|
116
122
|
if (tool === 'codex') {
|
|
117
|
-
assertSettingsAllowed(args);
|
|
123
|
+
assertSettingsAllowed(args[0] === INTERACTIVE_CODEX_BYPASS ? args.slice(1) : args);
|
|
118
124
|
return resume ? [...args, 'resume', id(record)] : [...args];
|
|
119
125
|
}
|
|
120
126
|
if (tool === 'claude_code')
|
package/dist/headless.js
CHANGED
|
@@ -2528,7 +2528,7 @@ export class HeadlessApp {
|
|
|
2528
2528
|
timestamp: new Date(),
|
|
2529
2529
|
// Reasoning models expect their trace replayed with the assistant
|
|
2530
2530
|
// message on later turns; dropping it strips the history.
|
|
2531
|
-
metadata: { ...(response.reasoning ? { reasoningContent: response.reasoning } : {}),
|
|
2531
|
+
metadata: { ...(response.reasoning ? { reasoningContent: response.reasoning, reasoningModel: response.reasoningModel } : {}),
|
|
2532
2532
|
...(response.responseItems ? { openaiResponseItems: response.responseItems, openaiResponseModel: response.nativeModel ?? configStore.get().model } : {}) },
|
|
2533
2533
|
};
|
|
2534
2534
|
this.messages.push(assistantMsg);
|
|
@@ -2872,7 +2872,7 @@ export class HeadlessApp {
|
|
|
2872
2872
|
timestamp: new Date(),
|
|
2873
2873
|
// Reasoning models expect their trace replayed with the assistant
|
|
2874
2874
|
// message on later turns; dropping it strips the history.
|
|
2875
|
-
metadata: { ...(response.reasoning ? { reasoningContent: response.reasoning } : {}),
|
|
2875
|
+
metadata: { ...(response.reasoning ? { reasoningContent: response.reasoning, reasoningModel: response.reasoningModel } : {}),
|
|
2876
2876
|
...(response.responseItems ? { openaiResponseItems: response.responseItems, openaiResponseModel: response.nativeModel ?? configStore.get().model } : {}) },
|
|
2877
2877
|
};
|
|
2878
2878
|
this.messages.push(assistantMsg);
|
package/dist/library.js
CHANGED
|
@@ -272,8 +272,8 @@ async function* runAndAppend(agent, messages, userMsg, model) {
|
|
|
272
272
|
toolCalls: result.toolCalls?.length ? result.toolCalls : undefined,
|
|
273
273
|
// Reasoning models expect their trace replayed with the assistant
|
|
274
274
|
// message on later turns; dropping it strips the history.
|
|
275
|
-
metadata: { ...(result.reasoning ? { reasoningContent: result.reasoning } : {}),
|
|
276
|
-
...(result.responseItems ? { openaiResponseItems: result.responseItems, openaiResponseModel: model } : {}) },
|
|
275
|
+
metadata: { ...(result.reasoning ? { reasoningContent: result.reasoning, reasoningModel: result.reasoningModel } : {}),
|
|
276
|
+
...(result.responseItems ? { openaiResponseItems: result.responseItems, openaiResponseModel: result.nativeModel ?? model } : {}) },
|
|
277
277
|
});
|
|
278
278
|
})
|
|
279
279
|
.catch((err) => {
|