@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
package/dist/mcp/client.js
CHANGED
|
@@ -3,6 +3,8 @@ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
|
|
|
3
3
|
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
4
|
import { ToolCapability } from '../agent/runtime/capabilities.js';
|
|
5
5
|
import { withoutMirrorCredentials } from '../web/pane_credentials.js';
|
|
6
|
+
import { withoutHostEffortPolicy } from '../utils/subprocess_env.js';
|
|
7
|
+
import { hasLaunchFlag } from '../cli_args.js';
|
|
6
8
|
export const MAX_MCP_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
7
9
|
const CLIENT_INFO = { name: 'ztc', version: '0.1.0' };
|
|
8
10
|
// Connection-independent state and accessors live in registry.ts (so light
|
|
@@ -24,11 +26,12 @@ function withTimeout(promise, ms, label) {
|
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Env for an stdio MCP child: the parent env, less this process's mirror credentials (an MCP server is someone
|
|
27
|
-
* else's program, and they speak for every pane)
|
|
29
|
+
* else's program, and they speak for every pane) and a host's effort policy (which is for ZTC's own turns), plus the
|
|
30
|
+
* entry's own overrides.
|
|
28
31
|
*/
|
|
29
32
|
function buildStdioEnv(extra) {
|
|
30
33
|
const env = {};
|
|
31
|
-
for (const [k, v] of Object.entries(withoutMirrorCredentials(process.env))) {
|
|
34
|
+
for (const [k, v] of Object.entries(withoutHostEffortPolicy(withoutMirrorCredentials(process.env)))) {
|
|
32
35
|
if (typeof v === 'string')
|
|
33
36
|
env[k] = v;
|
|
34
37
|
}
|
|
@@ -195,7 +198,7 @@ function withColonyDefault(servers) {
|
|
|
195
198
|
* keeping the first and warning.
|
|
196
199
|
*/
|
|
197
200
|
export async function initMcpServers(servers, options = {}) {
|
|
198
|
-
if (process.env.ZTC_CLOSED_EXTENSIONS === '1' ||
|
|
201
|
+
if (process.env.ZTC_CLOSED_EXTENSIONS === '1' || hasLaunchFlag('--closed-extensions'))
|
|
199
202
|
return;
|
|
200
203
|
if (!beginMcpInit(options.serverSet ?? null))
|
|
201
204
|
return;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
18
18
|
import { type AgentCliId, type PaneProgram } from '../panes/agent_cli.js';
|
|
19
|
-
import { type PaneCommandTransport } from '../ui/ratatui/pane_relay.js';
|
|
19
|
+
import { PaneRelayClient, type PaneCommandTransport } from '../ui/ratatui/pane_relay.js';
|
|
20
20
|
export interface WorkspaceBusMessage {
|
|
21
21
|
from: {
|
|
22
22
|
id: number;
|
|
@@ -56,5 +56,10 @@ export declare function createWorkspaceMcpServer(options: WorkspaceMcpOptions):
|
|
|
56
56
|
* own mirror credential, so the mirror takes its messages as this pane's, and only as this pane's.
|
|
57
57
|
*/
|
|
58
58
|
export declare function mirrorBusSender(env?: NodeJS.ProcessEnv): WorkspaceBusSender | null;
|
|
59
|
+
/**
|
|
60
|
+
* The connection to this workspace's pane relay, for a server started in a workspace pane; null outside one. It names
|
|
61
|
+
* the pane it serves ($ZTC_PANE_ID) in its relay_hello, as a ZTC pane does, so the main ZTC knows whose commands they are.
|
|
62
|
+
*/
|
|
63
|
+
export declare function workspaceRelayClient(env: NodeJS.ProcessEnv): PaneRelayClient | null;
|
|
59
64
|
/** Entry point for `ztc workspace-mcp`: serve on stdio until the CLI closes it. */
|
|
60
65
|
export declare function runWorkspaceMcpServer(env?: NodeJS.ProcessEnv): Promise<void>;
|
|
@@ -25,6 +25,7 @@ import { TYPED_ENTER_DELAY_MS, formatAgentPaneMessage, openAgentPane } from '../
|
|
|
25
25
|
import { sessionNamePaneTitle } from '../panes/labels.js';
|
|
26
26
|
import { MOTSI_PANE_ENV, remoteViewMotsi, throughMotsi } from '../panes/motsi.js';
|
|
27
27
|
import { configStore } from '../config.js';
|
|
28
|
+
import { resolveWorkerRoute, WORKER_MODEL_ID } from '../panes/worker_route.js';
|
|
28
29
|
import { buildZtcPaneLaunchCommand, createZtcLaunchSpec } from '../panes/ztc_launch.js';
|
|
29
30
|
import { PaneRelayClient } from '../ui/ratatui/pane_relay.js';
|
|
30
31
|
import { buildUserSubprocessEnvOverrides } from '../utils/subprocess_env.js';
|
|
@@ -37,12 +38,12 @@ const PANE_REF = {
|
|
|
37
38
|
const TOOLS = [
|
|
38
39
|
{
|
|
39
40
|
name: 'list_panes',
|
|
40
|
-
description: 'List the panes in this ZTC workspace: each pane\'s id, name and kind (ZTC
|
|
41
|
+
description: 'List the panes in this ZTC workspace: each pane\'s id, name and kind (ZTC, claude_code, codex, terminal, document), its tab, what a ZTC pane is working on, what wants attention, and which pane is yours. Pane ids and names work in every other ztc tool.',
|
|
41
42
|
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
42
43
|
},
|
|
43
44
|
{
|
|
44
45
|
name: 'open_pane',
|
|
45
|
-
description: 'Open a new pane in this ZTC workspace: a ZTC agent ("ztc"), Claude Code ("claude"), Codex ("codex") or a shell ("shell"). Claude Code and Codex run the user\'s own installed CLI on the user\'s own account, with these same ztc tools. Give a task to start an agent working on it at once. Returns the new pane\'s id.',
|
|
46
|
+
description: 'Open a new pane in this ZTC workspace: a ZTC agent ("ztc"), Claude Code ("claude"), Codex ("codex") or a shell ("shell"). Claude Code and Codex run the user\'s own installed CLI on the user\'s own account, with these same ztc tools, and ask before running commands as their own settings say. Give a task to start an agent working on it at once. A ZTC agent starts on the route new panes start on, or on the provider, model and effort you name (checked against Zerg Router\'s list first; nothing is saved as a default). Returns the new pane\'s id.',
|
|
46
47
|
inputSchema: {
|
|
47
48
|
type: 'object',
|
|
48
49
|
properties: {
|
|
@@ -51,6 +52,9 @@ const TOOLS = [
|
|
|
51
52
|
name: { type: 'string', description: 'Name for the pane. Defaults to "ZTC", "Claude Code", "Codex" or "Shell", numbered when taken.' },
|
|
52
53
|
cwd: { type: 'string', description: 'Working directory. Defaults to yours.' },
|
|
53
54
|
placement: { type: 'string', enum: ['right', 'below', 'tab'], description: 'Next to your pane (right or below) or in a new tab. Defaults to the workspace\'s layout.' },
|
|
55
|
+
provider: { type: 'string', description: 'For a ZTC agent: the provider it runs on, as /provider lists it ("morph", or "zergrouter:openai" for Zerg Router\'s and not your own key). Defaults to the route new panes start on.' },
|
|
56
|
+
model: { type: 'string', pattern: WORKER_MODEL_ID.source, description: 'For a ZTC agent: the model id, as Zerg Router or /model lists it ("morph/morph-kimik31"). Defaults to the provider\'s model last used, else its default.' },
|
|
57
|
+
effort: { type: 'string', description: 'For a ZTC agent: the reasoning effort, one the model takes ("high"), or "default".' },
|
|
54
58
|
},
|
|
55
59
|
required: ['kind'],
|
|
56
60
|
additionalProperties: false,
|
|
@@ -99,13 +103,26 @@ const TOOLS = [
|
|
|
99
103
|
},
|
|
100
104
|
{
|
|
101
105
|
name: 'close_pane',
|
|
102
|
-
description: 'Close a pane and stop its program. Your own pane cannot be closed this way.',
|
|
106
|
+
description: 'Close a pane and stop its program. Your own pane and Main (pane 0) cannot be closed this way.',
|
|
103
107
|
inputSchema: { type: 'object', properties: { pane: PANE_REF }, required: ['pane'], additionalProperties: false },
|
|
104
108
|
},
|
|
105
109
|
];
|
|
106
110
|
class ToolError extends Error {
|
|
107
111
|
}
|
|
108
112
|
const KIND_LABELS = { ztc: 'ZTC', process: 'terminal', command: 'terminal', doc: 'document', feed: 'feed' };
|
|
113
|
+
/** A Claude Code or Codex pane, which the main ZTC's relay marks (agent_cli): their kind as open_pane's chooser names it. */
|
|
114
|
+
const AGENT_KIND_LABELS = { claude: 'claude_code', codex: 'codex' };
|
|
115
|
+
function paneKind(pane) {
|
|
116
|
+
return (pane.agent_cli && AGENT_KIND_LABELS[pane.agent_cli]) || KIND_LABELS[pane.pane_type] || pane.pane_type;
|
|
117
|
+
}
|
|
118
|
+
/** What a pane wants attention for: its latest notification's text, else the kind, and how many came. */
|
|
119
|
+
function attentionNote(pane) {
|
|
120
|
+
const attention = pane.attention;
|
|
121
|
+
if (!attention || attention.count <= 0)
|
|
122
|
+
return undefined;
|
|
123
|
+
const what = attention.text?.trim() || attention.kind;
|
|
124
|
+
return `wants attention: ${what}${attention.count > 1 ? ` (${attention.count})` : ''}`;
|
|
125
|
+
}
|
|
109
126
|
function paneName(pane) {
|
|
110
127
|
return pane.labels?.manual_title || pane.title;
|
|
111
128
|
}
|
|
@@ -183,9 +200,18 @@ export function createWorkspaceMcpServer(options) {
|
|
|
183
200
|
};
|
|
184
201
|
const openZtcPane = async (args, cwd) => {
|
|
185
202
|
const tui = workspace();
|
|
203
|
+
// The provider, model and effort named, checked against Router's list; else the route new panes start on, which
|
|
204
|
+
// Router may have no key for (workspace spec §7.5). A route that can't run opens nothing.
|
|
205
|
+
const route = await resolveWorkerRoute({ provider: args.provider, model: args.model, effort: args.effort });
|
|
206
|
+
if (!route.ok)
|
|
207
|
+
throw new ToolError(`No ZTC pane was opened: ${route.message}`);
|
|
186
208
|
const titles = (await panes()).map(paneName);
|
|
187
209
|
const title = typeof args.name === 'string' && args.name.trim() ? args.name.trim() : nextPaneTitle('ZTC', titles);
|
|
188
|
-
|
|
210
|
+
// The route is this worker's own launch flags: nothing is saved as the default for new panes.
|
|
211
|
+
const spec = createZtcLaunchSpec({ cwd, title,
|
|
212
|
+
...(route.providerOverride ? { providerOverride: route.providerOverride, modelOverride: route.modelOverride } : {}),
|
|
213
|
+
...(route.authMode ? { authMode: route.authMode } : {}), ...(route.routerOrigin ? { routerOrigin: route.routerOrigin } : {}),
|
|
214
|
+
...(route.extraArgs.length > 0 ? { extraArgs: route.extraArgs } : {}) });
|
|
189
215
|
// This process was started as `workspace-mcp`; the child is a ZTC session.
|
|
190
216
|
const built = buildZtcPaneLaunchCommand(spec, process.argv.slice(0, 2));
|
|
191
217
|
if (built instanceof Error)
|
|
@@ -220,7 +246,8 @@ export function createWorkspaceMcpServer(options) {
|
|
|
220
246
|
if (event.type !== 'pane_created')
|
|
221
247
|
throw new ToolError('Unexpected response from the workspace.');
|
|
222
248
|
tui.send(sessionNamePaneTitle(event.pane_id, title));
|
|
223
|
-
return `Opened ZTC agent "${title}" in pane ${event.pane_id} (${cwd})${
|
|
249
|
+
return `Opened ZTC agent "${title}" in pane ${event.pane_id} (${cwd})${route.described ? ` on ${route.described}` : ''}`
|
|
250
|
+
+ `${task ? ' with its task' : ''}.`;
|
|
224
251
|
};
|
|
225
252
|
const openShellPane = async (args, cwd) => {
|
|
226
253
|
const tui = workspace();
|
|
@@ -262,16 +289,22 @@ export function createWorkspaceMcpServer(options) {
|
|
|
262
289
|
const all = await panes();
|
|
263
290
|
if (all.length === 0)
|
|
264
291
|
return 'The workspace has no panes.';
|
|
292
|
+
// Tabs numbered as the desktop app's Cmd+1–9 count them: in the order of their ids.
|
|
293
|
+
const tabs = [...new Set(all.flatMap(pane => pane.window_id === undefined ? [] : [pane.window_id]))].sort((a, b) => a - b);
|
|
265
294
|
return all
|
|
266
295
|
.slice()
|
|
267
296
|
.sort((a, b) => a.id - b.id)
|
|
268
297
|
.map(pane => {
|
|
298
|
+
const label = pane.activity_label?.trim() || pane.activity_status;
|
|
269
299
|
const notes = [
|
|
300
|
+
pane.window_id === undefined ? '' : `tab ${tabs.indexOf(pane.window_id) + 1}`,
|
|
270
301
|
pane.id === ownPaneId ? 'you' : '',
|
|
271
302
|
pane.is_focused ? 'focused' : '',
|
|
272
303
|
pane.is_alive ? '' : 'exited',
|
|
304
|
+
pane.activity_status ? `working: ${label}` : '',
|
|
305
|
+
attentionNote(pane) ?? '',
|
|
273
306
|
].filter(Boolean);
|
|
274
|
-
return `[${pane.id}] ${paneName(pane)} (${
|
|
307
|
+
return `[${pane.id}] ${paneName(pane)} (${paneKind(pane)})${notes.length ? ` — ${notes.join(', ')}` : ''}`;
|
|
275
308
|
})
|
|
276
309
|
.join('\n');
|
|
277
310
|
},
|
|
@@ -282,6 +315,9 @@ export function createWorkspaceMcpServer(options) {
|
|
|
282
315
|
const cwd = typeof args.cwd === 'string' && args.cwd.trim() ? args.cwd.trim() : (options.cwd ?? process.cwd());
|
|
283
316
|
if (kind === 'ztc')
|
|
284
317
|
return openZtcPane(args, cwd);
|
|
318
|
+
if (['provider', 'model', 'effort'].some(name => args[name] !== undefined && args[name] !== null)) {
|
|
319
|
+
throw new ToolError('provider, model and effort choose a ZTC pane\'s route; Claude Code and Codex use their own accounts and settings.');
|
|
320
|
+
}
|
|
285
321
|
if (kind === 'shell')
|
|
286
322
|
return openShellPane(args, cwd);
|
|
287
323
|
if (kind !== 'claude' && kind !== 'codex')
|
|
@@ -297,6 +333,8 @@ export function createWorkspaceMcpServer(options) {
|
|
|
297
333
|
server: options.server === undefined ? workspaceMcpProgram(process.argv.slice(0, 2)) : options.server,
|
|
298
334
|
env,
|
|
299
335
|
motsi: paneMotsi(),
|
|
336
|
+
// The agent in this pane asks for it: the CLI asks before running commands, as its own settings say.
|
|
337
|
+
openedBy: 'agent',
|
|
300
338
|
});
|
|
301
339
|
if (result.error)
|
|
302
340
|
throw new ToolError(result.error);
|
|
@@ -338,6 +376,8 @@ export function createWorkspaceMcpServer(options) {
|
|
|
338
376
|
},
|
|
339
377
|
close_pane: async (args) => {
|
|
340
378
|
const pane = await findPane(args.pane);
|
|
379
|
+
if (pane.id === 0)
|
|
380
|
+
throw new ToolError('Main (pane 0) stays open while ZTC runs, so it can\'t be closed this way; the user quits ZTC to close it.');
|
|
341
381
|
if (pane.id === ownPaneId)
|
|
342
382
|
throw new ToolError('That is your own pane; the user can close it, or you can exit.');
|
|
343
383
|
return String(await closeTerminalPaneTool.execute({ pane_id: pane.id }));
|
|
@@ -398,11 +438,20 @@ export function mirrorBusSender(env = process.env) {
|
|
|
398
438
|
}),
|
|
399
439
|
};
|
|
400
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* The connection to this workspace's pane relay, for a server started in a workspace pane; null outside one. It names
|
|
443
|
+
* the pane it serves ($ZTC_PANE_ID) in its relay_hello, as a ZTC pane does, so the main ZTC knows whose commands they are.
|
|
444
|
+
*/
|
|
445
|
+
export function workspaceRelayClient(env) {
|
|
446
|
+
if (!env.ZTC_PANE_RELAY)
|
|
447
|
+
return null;
|
|
448
|
+
const paneId = Number(env.ZTC_PANE_ID);
|
|
449
|
+
return new PaneRelayClient(env.ZTC_PANE_RELAY, Number.isSafeInteger(paneId) && paneId >= 0 ? { paneId } : {});
|
|
450
|
+
}
|
|
401
451
|
/** Entry point for `ztc workspace-mcp`: serve on stdio until the CLI closes it. */
|
|
402
452
|
export async function runWorkspaceMcpServer(env = process.env) {
|
|
403
|
-
let relay =
|
|
404
|
-
if (
|
|
405
|
-
relay = new PaneRelayClient(env.ZTC_PANE_RELAY);
|
|
453
|
+
let relay = workspaceRelayClient(env);
|
|
454
|
+
if (relay) {
|
|
406
455
|
try {
|
|
407
456
|
await relay.connect();
|
|
408
457
|
}
|
|
@@ -40,8 +40,10 @@ export interface FirstRunWelcomeOptions {
|
|
|
40
40
|
sessionName?: string;
|
|
41
41
|
mode?: string;
|
|
42
42
|
recentSession?: RecentSessionInfo;
|
|
43
|
-
/** Zerg Router
|
|
43
|
+
/** This profile's Zerg Router sign-in (router-auth.json): the card says whether it is signed in. */
|
|
44
44
|
routerSession?: RouterSessionStatus;
|
|
45
|
+
/** The name Router gave this device at that sign-in's login, when it kept one. */
|
|
46
|
+
routerDevice?: string;
|
|
45
47
|
now?: Date;
|
|
46
48
|
/** @deprecated The application header owns launch branding. */
|
|
47
49
|
logo?: string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { displayWidth, sanitizeTerminalText } from '../ui/core/text_width.js';
|
|
2
|
-
import { routerLaunchTip } from './router_tips.js';
|
|
3
2
|
import { LOCAL_API_KEYS_LABEL, ZERGAI_LOGIN_LABEL, ZERGAI_LOGIN_PITCH } from './zergai_login.js';
|
|
4
3
|
const WELCOME_TITLE = 'Welcome to ZTC - Zerg Terminal Client.';
|
|
5
4
|
const FIRST_RUN_MESSAGE_KIND = 'first-run';
|
|
@@ -136,12 +135,28 @@ function formatRuntimeLine(options) {
|
|
|
136
135
|
const version = compact(options.version, 12);
|
|
137
136
|
return `Runtime: ${provider}/${model}${version ? ` · ZTC v${version}` : ''}`;
|
|
138
137
|
}
|
|
138
|
+
/** The ZergAI platform login, labelled as ZergAI's: it is not the Zerg Router account Router requests use. */
|
|
139
139
|
function formatIdentityLine(options) {
|
|
140
140
|
const authEmail = compact(options.authEmail, 32);
|
|
141
141
|
if (!authEmail)
|
|
142
142
|
return undefined;
|
|
143
143
|
const workspaceName = compact(options.workspaceName, 24);
|
|
144
|
-
return `
|
|
144
|
+
return `ZergAI login: ${authEmail}${workspaceName ? ` · ${workspaceName}` : ''}`;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Whether this profile's Zerg Router sign-in, the one Router requests go with, is signed in (with the device name its
|
|
148
|
+
* login was given), and otherwise that /auth login signs it in. Read from what the profile holds: nothing asks Router.
|
|
149
|
+
*/
|
|
150
|
+
function formatRouterLine(session, device) {
|
|
151
|
+
switch (session) {
|
|
152
|
+
case 'signed_in': {
|
|
153
|
+
const name = compact(device, 40);
|
|
154
|
+
return `Zerg Router: signed in${name ? ` · ${name}` : ''}`;
|
|
155
|
+
}
|
|
156
|
+
case 'expired': return 'Zerg Router: sign-in expired · /auth login signs it in again';
|
|
157
|
+
case 'signed_out': return 'Zerg Router: not signed in · /auth login signs it in';
|
|
158
|
+
default: return undefined;
|
|
159
|
+
}
|
|
145
160
|
}
|
|
146
161
|
/**
|
|
147
162
|
* The readout's one pointer to saved work in this project. With `resume`, it
|
|
@@ -239,9 +254,9 @@ export function buildCredentialSetupMessage() {
|
|
|
239
254
|
SETUP_ACTION,
|
|
240
255
|
].join('\n');
|
|
241
256
|
}
|
|
242
|
-
/** The readout line for an expired
|
|
257
|
+
/** The readout line for an expired Zerg Router sign-in; other states add none here, where the routes to connect follow. */
|
|
243
258
|
function expiredSessionNote(session) {
|
|
244
|
-
return session === 'expired' ? [
|
|
259
|
+
return session === 'expired' ? [formatRouterLine(session)] : [];
|
|
245
260
|
}
|
|
246
261
|
/**
|
|
247
262
|
* A launch without a model: the readout the site's First Contact film shows
|
|
@@ -283,8 +298,8 @@ export function buildReadyWelcome(options = {}) {
|
|
|
283
298
|
: `Safety: ${permissionProfile} permissions · /permissions`,
|
|
284
299
|
formatRuntimeLine(options),
|
|
285
300
|
formatIdentityLine(options),
|
|
301
|
+
formatRouterLine(options.routerSession, options.routerDevice),
|
|
286
302
|
recent,
|
|
287
|
-
options.routerSession ? routerLaunchTip(options.routerSession) : undefined,
|
|
288
303
|
next,
|
|
289
304
|
].filter((line) => Boolean(line));
|
|
290
305
|
return [
|
|
@@ -316,7 +331,7 @@ export function buildResumedWelcome(options) {
|
|
|
316
331
|
planMode && context ? `Context: ${context}` : undefined,
|
|
317
332
|
formatRuntimeLine(options),
|
|
318
333
|
formatIdentityLine(options),
|
|
319
|
-
|
|
334
|
+
formatRouterLine(options.routerSession, options.routerDevice),
|
|
320
335
|
credentialsReady ? undefined : CONNECT_ACTION,
|
|
321
336
|
credentialsReady
|
|
322
337
|
? undefined
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ZERGAI_LOGIN_BENEFIT, ZERGAI_LOGIN_PITCH } from './zergai_login.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Tips for people working without a Zerg Router sign-in; signed-in users never see one. They name that sign-in, as the
|
|
4
|
+
* launch card's "Zerg Router:" line does: its "ZergAI login:" line is the ZergAI platform's, another login.
|
|
5
|
+
*/
|
|
3
6
|
const ROUTER_LOGIN_TIPS = [
|
|
4
|
-
`Tip: ${ZERGAI_LOGIN_BENEFIT.providerKeys}.
|
|
5
|
-
`Tip: ${ZERGAI_LOGIN_BENEFIT.deepSeek}.
|
|
6
|
-
`Tip: ${ZERGAI_LOGIN_BENEFIT.usage}.
|
|
7
|
+
`Tip: ${ZERGAI_LOGIN_BENEFIT.providerKeys}. Sign in to Zerg Router: /auth login`,
|
|
8
|
+
`Tip: ${ZERGAI_LOGIN_BENEFIT.deepSeek}. Sign in to Zerg Router: /auth login`,
|
|
9
|
+
`Tip: ${ZERGAI_LOGIN_BENEFIT.usage}. Sign in to Zerg Router: /auth login · /auth billing`,
|
|
7
10
|
];
|
|
8
11
|
/** The first tip follows this completed turn; later tips follow every interval after it. */
|
|
9
12
|
const FIRST_TIP_TURN = 3;
|
|
@@ -15,7 +18,7 @@ export function routerLoginTip(session, completedTurns) {
|
|
|
15
18
|
return undefined;
|
|
16
19
|
switch (session) {
|
|
17
20
|
case 'signed_in': return undefined;
|
|
18
|
-
case 'expired': return 'Tip: Your
|
|
21
|
+
case 'expired': return 'Tip: Your Zerg Router sign-in expired. Run /auth login to sign in again.';
|
|
19
22
|
case 'signed_out': return ROUTER_LOGIN_TIPS[(sinceFirst / TIP_INTERVAL_TURNS) % ROUTER_LOGIN_TIPS.length];
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -23,8 +26,8 @@ export function routerLoginTip(session, completedTurns) {
|
|
|
23
26
|
export function routerTipForError(session, routed, error) {
|
|
24
27
|
if (session === 'signed_in' || routed)
|
|
25
28
|
return undefined;
|
|
26
|
-
return /^Authentication failed
|
|
27
|
-
? `Tip: ${ZERGAI_LOGIN_BENEFIT.deepSeek}.
|
|
29
|
+
return /^Authentication failed[.:]|Rate limit exceeded/.test(error)
|
|
30
|
+
? `Tip: ${ZERGAI_LOGIN_BENEFIT.deepSeek}. Sign in to Zerg Router: /auth login`
|
|
28
31
|
: undefined;
|
|
29
32
|
}
|
|
30
33
|
/** The launch card's ZergAI line for a session that can already reach a model. */
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* credentials. (Anthropic's terms for Claude subscription sign-in:
|
|
8
8
|
* https://code.claude.com/docs/en/legal-and-compliance.)
|
|
9
9
|
*
|
|
10
|
+
* In the panes the person opens, ZTC starts both without their permission
|
|
11
|
+
* prompts (Claude Code's --dangerously-skip-permissions, Codex's
|
|
12
|
+
* --dangerously-bypass-approvals-and-sandbox) unless their own arguments choose
|
|
13
|
+
* how the CLI asks, or `panes.agentPermissions` says ask; an agent's panes ask.
|
|
14
|
+
*
|
|
10
15
|
* What ZTC adds is a session-scoped MCP server, `ztc workspace-mcp`, passed on
|
|
11
16
|
* the command line (Claude Code `--mcp-config`, Codex `-c mcp_servers.ztc.*`),
|
|
12
17
|
* so the agent can list, open, read, type into, message and close the other
|
|
@@ -64,6 +69,49 @@ export interface AgentLaunchRequest {
|
|
|
64
69
|
* apostrophes and all (`/claude don't touch the migrations`).
|
|
65
70
|
*/
|
|
66
71
|
export declare function parseAgentCommandBody(body: string): AgentLaunchRequest;
|
|
72
|
+
/** Whether ZTC starts Claude Code and Codex without their permission prompts: `panes.agentPermissions`. */
|
|
73
|
+
export type AgentPermissions = 'bypass' | 'ask';
|
|
74
|
+
/** The flag that starts each CLI without asking before it runs commands (`claude --help` 2.1.322, `codex --help` 0.167.2). */
|
|
75
|
+
export declare const PERMISSION_BYPASS_FLAGS: Readonly<Record<AgentCliId, string>>;
|
|
76
|
+
/**
|
|
77
|
+
* `panes.agentPermissions` as it applies: unset, as in a profile saved before the setting, is 'bypass'; any value but
|
|
78
|
+
* 'bypass' or 'ask' asks, so a mistyped one never lets a CLI skip its prompts.
|
|
79
|
+
*/
|
|
80
|
+
export declare function agentPermissionsSetting(panes: {
|
|
81
|
+
agentPermissions?: unknown;
|
|
82
|
+
} | undefined): AgentPermissions;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the person's own arguments for the CLI choose how it asks before running commands: one of its permission
|
|
85
|
+
* flags (`--permission-mode plan`, `-s read-only`, `-p review`, joined to its value or not), Claude Code settings of
|
|
86
|
+
* their own, or for Codex a `-c`/`--config` override of its approval policy, its sandbox or its profile. Words after
|
|
87
|
+
* `--` are the opening prompt, never a choice.
|
|
88
|
+
*/
|
|
89
|
+
export declare function choosesPermissions(id: AgentCliId, words: readonly string[]): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The word in the arguments for the CLI that starts it with no permission checks at all, or null. Claude Code's
|
|
92
|
+
* --dangerously-skip-permissions, --allow-dangerously-skip-permissions, and a bypassPermissions mode by flag or in
|
|
93
|
+
* settings given inline; Codex's --dangerously-bypass-approvals-and-sandbox, --yolo, and a danger-full-access sandbox
|
|
94
|
+
* by flag or override. Words after `--` are the opening prompt. Only the person starts a CLI so (see openAgentPane).
|
|
95
|
+
*/
|
|
96
|
+
export declare function bypassWord(id: AgentCliId, words: readonly string[]): string | null;
|
|
97
|
+
/** Where the CLI runs, as far as its bypass flag cares: this process's user, platform and environment by default. */
|
|
98
|
+
export interface PermissionHost {
|
|
99
|
+
uid?: number;
|
|
100
|
+
platform?: NodeJS.Platform;
|
|
101
|
+
env?: NodeJS.ProcessEnv;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Why the CLI would refuse its bypass flag here, or null. Claude Code exits at once when started with
|
|
105
|
+
* --dangerously-skip-permissions as root, unless IS_SANDBOX=1 or CLAUDE_CODE_BUBBLEWRAP marks a sandbox (2.1.323's
|
|
106
|
+
* isRootOutsideDeliberateSandbox); Codex has no such check.
|
|
107
|
+
*/
|
|
108
|
+
export declare function bypassRefusal(id: AgentCliId, host?: PermissionHost): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* What ZTC passes the CLI ahead of the person's own arguments: its flag for running without permission prompts while
|
|
111
|
+
* the setting is 'bypass', unless the person's arguments choose for themselves or the CLI would refuse it here
|
|
112
|
+
* (bypassRefusal).
|
|
113
|
+
*/
|
|
114
|
+
export declare function permissionDefaultArgs(id: AgentCliId, words: readonly string[], permissions: AgentPermissions, host?: PermissionHost): string[];
|
|
67
115
|
export interface PaneProgram {
|
|
68
116
|
command: string;
|
|
69
117
|
args: string[];
|
package/dist/panes/agent_cli.js
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* credentials. (Anthropic's terms for Claude subscription sign-in:
|
|
8
8
|
* https://code.claude.com/docs/en/legal-and-compliance.)
|
|
9
9
|
*
|
|
10
|
+
* In the panes the person opens, ZTC starts both without their permission
|
|
11
|
+
* prompts (Claude Code's --dangerously-skip-permissions, Codex's
|
|
12
|
+
* --dangerously-bypass-approvals-and-sandbox) unless their own arguments choose
|
|
13
|
+
* how the CLI asks, or `panes.agentPermissions` says ask; an agent's panes ask.
|
|
14
|
+
*
|
|
10
15
|
* What ZTC adds is a session-scoped MCP server, `ztc workspace-mcp`, passed on
|
|
11
16
|
* the command line (Claude Code `--mcp-config`, Codex `-c mcp_servers.ztc.*`),
|
|
12
17
|
* so the agent can list, open, read, type into, message and close the other
|
|
@@ -189,6 +194,146 @@ export function parseAgentCommandBody(body) {
|
|
|
189
194
|
return withProfile({ words: splitCliArguments(text) });
|
|
190
195
|
return withProfile({ words: [], prompt: text });
|
|
191
196
|
}
|
|
197
|
+
/** The flag that starts each CLI without asking before it runs commands (`claude --help` 2.1.322, `codex --help` 0.167.2). */
|
|
198
|
+
export const PERMISSION_BYPASS_FLAGS = Object.freeze({
|
|
199
|
+
claude: '--dangerously-skip-permissions',
|
|
200
|
+
codex: '--dangerously-bypass-approvals-and-sandbox',
|
|
201
|
+
});
|
|
202
|
+
/**
|
|
203
|
+
* `panes.agentPermissions` as it applies: unset, as in a profile saved before the setting, is 'bypass'; any value but
|
|
204
|
+
* 'bypass' or 'ask' asks, so a mistyped one never lets a CLI skip its prompts.
|
|
205
|
+
*/
|
|
206
|
+
export function agentPermissionsSetting(panes) {
|
|
207
|
+
const value = panes?.agentPermissions;
|
|
208
|
+
return value === undefined || value === null || value === 'bypass' ? 'bypass' : 'ask';
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Claude Code's flags that choose how it asks: skipping its prompts, offering to, a permission mode, who answers its
|
|
212
|
+
* prompts, --restricted, which refuses bypassPermissions, and settings of the person's own, which may set
|
|
213
|
+
* permissions.defaultMode (ZTC never reads them, so they count whatever they hold).
|
|
214
|
+
*/
|
|
215
|
+
const CLAUDE_PERMISSION_FLAGS = new Set([
|
|
216
|
+
'--dangerously-skip-permissions', '--allow-dangerously-skip-permissions', '--permission-mode', '--permission-prompts', '--restricted',
|
|
217
|
+
'--settings',
|
|
218
|
+
]);
|
|
219
|
+
/**
|
|
220
|
+
* Codex's: the bypass itself and its alias --yolo, an approval policy, a sandbox, automatic review and its alias
|
|
221
|
+
* --not-so-yolo, --full-auto from before 0.167, and a profile of the person's own, which may set its approval policy
|
|
222
|
+
* and sandbox. Codex refuses the bypass given twice, under either name.
|
|
223
|
+
*/
|
|
224
|
+
const CODEX_PERMISSION_FLAGS = new Set([
|
|
225
|
+
'--dangerously-bypass-approvals-and-sandbox', '--yolo', '--approve-for-me', '--not-so-yolo', '--full-auto', '-a', '--ask-for-approval',
|
|
226
|
+
'-s', '--sandbox', '-p', '--profile',
|
|
227
|
+
]);
|
|
228
|
+
/**
|
|
229
|
+
* Whether a Codex `-c key=value` override sets how Codex asks or sandboxes: an approval policy, any sandbox setting, or
|
|
230
|
+
* the profile Codex starts on.
|
|
231
|
+
*/
|
|
232
|
+
function codexPermissionOverride(override) {
|
|
233
|
+
const key = /^([^=]*)=/.exec(override)?.[1]?.replace(/["']/g, '').trim();
|
|
234
|
+
if (!key)
|
|
235
|
+
return false;
|
|
236
|
+
const segments = key.split('.').map(segment => segment.trim());
|
|
237
|
+
return segments.at(-1) === 'approval_policy' || segments.at(-1) === 'sandbox_mode' || segments[0].startsWith('sandbox_')
|
|
238
|
+
|| key === 'profile';
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Whether the person's own arguments for the CLI choose how it asks before running commands: one of its permission
|
|
242
|
+
* flags (`--permission-mode plan`, `-s read-only`, `-p review`, joined to its value or not), Claude Code settings of
|
|
243
|
+
* their own, or for Codex a `-c`/`--config` override of its approval policy, its sandbox or its profile. Words after
|
|
244
|
+
* `--` are the opening prompt, never a choice.
|
|
245
|
+
*/
|
|
246
|
+
export function choosesPermissions(id, words) {
|
|
247
|
+
for (let i = 0; i < words.length; i++) {
|
|
248
|
+
const word = words[i];
|
|
249
|
+
if (word === '--')
|
|
250
|
+
return false;
|
|
251
|
+
const flag = word.startsWith('--') ? word.split('=', 1)[0] : word;
|
|
252
|
+
if (id === 'claude') {
|
|
253
|
+
if (CLAUDE_PERMISSION_FLAGS.has(flag))
|
|
254
|
+
return true;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
// -a, -s and -p also take their value joined (-anever, -sread-only, -preview, -a=never).
|
|
258
|
+
if (CODEX_PERMISSION_FLAGS.has(flag) || /^-[asp]./.test(word))
|
|
259
|
+
return true;
|
|
260
|
+
const override = word === '-c' || word === '--config' ? words[i + 1]
|
|
261
|
+
: word.startsWith('--config=') ? word.slice('--config='.length)
|
|
262
|
+
: /^-c./.test(word) ? word.slice(2).replace(/^=/, '') : undefined;
|
|
263
|
+
if (override !== undefined && codexPermissionOverride(override))
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
/** The value an option takes in `words` at `i`: joined (`--flag=value`, `-svalue`, `-s=value`) or the next word. */
|
|
269
|
+
function optionValue(words, i, names) {
|
|
270
|
+
const word = words[i];
|
|
271
|
+
if (names.long && word === names.long)
|
|
272
|
+
return words[i + 1];
|
|
273
|
+
if (names.long && word.startsWith(`${names.long}=`))
|
|
274
|
+
return word.slice(names.long.length + 1);
|
|
275
|
+
if (names.short && word === names.short)
|
|
276
|
+
return words[i + 1];
|
|
277
|
+
if (names.short && word.startsWith(names.short) && word.length > names.short.length)
|
|
278
|
+
return word.slice(names.short.length).replace(/^=/, '');
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The word in the arguments for the CLI that starts it with no permission checks at all, or null. Claude Code's
|
|
283
|
+
* --dangerously-skip-permissions, --allow-dangerously-skip-permissions, and a bypassPermissions mode by flag or in
|
|
284
|
+
* settings given inline; Codex's --dangerously-bypass-approvals-and-sandbox, --yolo, and a danger-full-access sandbox
|
|
285
|
+
* by flag or override. Words after `--` are the opening prompt. Only the person starts a CLI so (see openAgentPane).
|
|
286
|
+
*/
|
|
287
|
+
export function bypassWord(id, words) {
|
|
288
|
+
for (let i = 0; i < words.length; i++) {
|
|
289
|
+
const word = words[i];
|
|
290
|
+
if (word === '--')
|
|
291
|
+
return null;
|
|
292
|
+
if (id === 'claude') {
|
|
293
|
+
if (word === PERMISSION_BYPASS_FLAGS.claude || word === '--allow-dangerously-skip-permissions')
|
|
294
|
+
return word;
|
|
295
|
+
if (optionValue(words, i, { long: '--permission-mode' }) === 'bypassPermissions')
|
|
296
|
+
return '--permission-mode bypassPermissions';
|
|
297
|
+
if (optionValue(words, i, { long: '--settings' })?.includes('bypassPermissions'))
|
|
298
|
+
return '--settings with bypassPermissions';
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (word === PERMISSION_BYPASS_FLAGS.codex || word === '--yolo')
|
|
302
|
+
return word;
|
|
303
|
+
const sandbox = optionValue(words, i, { long: '--sandbox', short: '-s' });
|
|
304
|
+
if (sandbox?.trim() === 'danger-full-access')
|
|
305
|
+
return 'the danger-full-access sandbox';
|
|
306
|
+
const override = optionValue(words, i, { long: '--config', short: '-c' });
|
|
307
|
+
const [key, value] = (override ?? '').split(/=(.*)/s, 2).map(part => part?.replace(/["']/g, '').trim());
|
|
308
|
+
if (key?.split('.').at(-1)?.trim() === 'sandbox_mode' && value === 'danger-full-access')
|
|
309
|
+
return 'the danger-full-access sandbox';
|
|
310
|
+
}
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Why the CLI would refuse its bypass flag here, or null. Claude Code exits at once when started with
|
|
315
|
+
* --dangerously-skip-permissions as root, unless IS_SANDBOX=1 or CLAUDE_CODE_BUBBLEWRAP marks a sandbox (2.1.323's
|
|
316
|
+
* isRootOutsideDeliberateSandbox); Codex has no such check.
|
|
317
|
+
*/
|
|
318
|
+
export function bypassRefusal(id, host = {}) {
|
|
319
|
+
if (id !== 'claude')
|
|
320
|
+
return null;
|
|
321
|
+
const platform = host.platform ?? process.platform;
|
|
322
|
+
const uid = host.uid ?? process.getuid?.();
|
|
323
|
+
const env = host.env ?? process.env;
|
|
324
|
+
const sandboxed = env.IS_SANDBOX === '1' || /^(1|true|yes|on)$/i.test(env.CLAUDE_CODE_BUBBLEWRAP ?? '');
|
|
325
|
+
if (platform === 'win32' || uid !== 0 || sandboxed)
|
|
326
|
+
return null;
|
|
327
|
+
return `${AGENT_CLIS[id].label} starts with its permission prompts: it refuses ${PERMISSION_BYPASS_FLAGS[id]} as root outside a sandbox.`;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* What ZTC passes the CLI ahead of the person's own arguments: its flag for running without permission prompts while
|
|
331
|
+
* the setting is 'bypass', unless the person's arguments choose for themselves or the CLI would refuse it here
|
|
332
|
+
* (bypassRefusal).
|
|
333
|
+
*/
|
|
334
|
+
export function permissionDefaultArgs(id, words, permissions, host = {}) {
|
|
335
|
+
return permissions === 'bypass' && !choosesPermissions(id, words) && !bypassRefusal(id, host) ? [PERMISSION_BYPASS_FLAGS[id]] : [];
|
|
336
|
+
}
|
|
192
337
|
export const WORKSPACE_MCP_SERVER_NAME = 'ztc';
|
|
193
338
|
/**
|
|
194
339
|
* Variables the workspace server reads, where ZTC's settings are among them
|
|
@@ -41,7 +41,16 @@ export interface OpenAgentPaneOptions {
|
|
|
41
41
|
profile?: string | null;
|
|
42
42
|
/** Home directory the profiles live under (default: the user's). */
|
|
43
43
|
profilesHome?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Who asked for the pane. The person: their own /claude or /codex, ZTC's menus and splits, Ctrl+B c. An agent: the
|
|
46
|
+
* ztc_command tool running /claude or /codex, or workspace-mcp's open_pane. Only a pane the person opens starts
|
|
47
|
+
* without permission prompts (panes.agentPermissions); one an agent opens asks as the CLI's own settings say, and
|
|
48
|
+
* an agent's own flag that skips every permission check is refused (bypassWord).
|
|
49
|
+
*/
|
|
50
|
+
openedBy: AgentPaneOpener;
|
|
44
51
|
}
|
|
52
|
+
/** Who asked for an agent CLI pane (OpenAgentPaneOptions.openedBy). */
|
|
53
|
+
export type AgentPaneOpener = 'person' | 'agent';
|
|
45
54
|
export interface OpenAgentPaneResult {
|
|
46
55
|
paneId?: number;
|
|
47
56
|
title?: string;
|
|
@@ -49,6 +58,8 @@ export interface OpenAgentPaneResult {
|
|
|
49
58
|
error?: string;
|
|
50
59
|
/** Set when the pane opened but something about it should be said. */
|
|
51
60
|
notice?: string;
|
|
61
|
+
/** The permission flag ZTC started the CLI with, ahead of the person's own words (permissionDefaultArgs), if any. */
|
|
62
|
+
permissionArgs?: string[];
|
|
52
63
|
}
|
|
53
64
|
/** Open the user's own `claude` or `codex` in a new pane, attached to this workspace. */
|
|
54
65
|
export declare function openAgentPane(transport: PaneCommandTransport | null, options: OpenAgentPaneOptions): Promise<OpenAgentPaneResult>;
|