@phnx-labs/agents-cli 1.23.4 → 1.23.6
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/CHANGELOG.md +29 -0
- package/dist/bootstrap.js +14 -9
- package/dist/commands/exec.js +7 -7
- package/dist/commands/focus.js +17 -16
- package/dist/commands/go.js +2 -2
- package/dist/commands/ps-roster.d.ts +1 -1
- package/dist/commands/ps-roster.js +7 -5
- package/dist/commands/resume.d.ts +1 -0
- package/dist/commands/resume.js +9 -1
- package/dist/commands/sessions-resume.js +65 -18
- package/dist/commands/setup-terminal.js +3 -2
- package/dist/lib/exec.js +6 -1
- package/dist/lib/hosts/reconnect.d.ts +3 -2
- package/dist/lib/hosts/reconnect.js +8 -9
- package/dist/lib/launch-log.d.ts +15 -0
- package/dist/lib/launch-log.js +120 -0
- package/dist/lib/project-root.d.ts +1 -0
- package/dist/lib/project-root.js +9 -0
- package/dist/lib/remote-agents-json.d.ts +1 -0
- package/dist/lib/remote-agents-json.js +4 -2
- package/dist/lib/secrets-client.js +18 -3
- package/dist/lib/self-update.d.ts +1 -0
- package/dist/lib/self-update.js +4 -0
- package/dist/lib/session/active.d.ts +9 -3
- package/dist/lib/session/active.js +19 -5
- package/dist/lib/session/pid-registry.d.ts +1 -0
- package/dist/lib/session/pid-registry.js +6 -0
- package/dist/lib/session/remote/remote-list.d.ts +3 -1
- package/dist/lib/session/remote/remote-list.js +65 -19
- package/dist/lib/session/remote-active.d.ts +3 -1
- package/dist/lib/session/remote-active.js +4 -3
- package/dist/lib/session/session-cache.d.ts +1 -0
- package/dist/lib/session/session-cache.js +14 -1
- package/dist/lib/ssh-exec.js +1 -1
- package/dist/lib/terminal/backends/vscodium-agent.d.ts +31 -8
- package/dist/lib/terminal/backends/vscodium-agent.js +134 -7
- package/dist/lib/terminal/engine.d.ts +7 -1
- package/dist/lib/terminal/engine.js +68 -9
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/index.js +1 -1
- package/dist/lib/terminal/run-surface.d.ts +1 -0
- package/dist/lib/terminal/run-surface.js +8 -2
- package/dist/lib/terminal/types.d.ts +6 -2
- package/dist/lib/types.d.ts +1 -0
- package/dist/lib/types.js +1 -0
- package/package.json +1 -1
|
@@ -1,18 +1,41 @@
|
|
|
1
|
-
import type { TerminalBackend, LaunchSpec, SplitDirection } from '../types.js';
|
|
1
|
+
import type { TerminalBackend, LaunchSpec, SplitDirection, SurfaceMeta } from '../types.js';
|
|
2
2
|
export interface EditorVariant {
|
|
3
3
|
cli: string;
|
|
4
4
|
scheme: string;
|
|
5
5
|
app: string;
|
|
6
6
|
label: string;
|
|
7
|
+
dataDir?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare const EDITOR_VARIANTS: EditorVariant[];
|
|
9
|
-
export declare function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}): string;
|
|
10
|
+
export declare function editorWindowFor(folder: string, storageJson: string | undefined): string;
|
|
11
|
+
export declare function editorFolderNamed(project: string, storageJson: string | undefined): string | undefined;
|
|
12
|
+
export declare function storageJsonFor(variant: EditorVariant, env?: NodeJS.ProcessEnv): string | undefined;
|
|
13
|
+
export declare function spawnUri(scheme: string, cwd: string, command: string[], direction?: SplitDirection, meta?: SurfaceMeta): string;
|
|
14
14
|
export declare function editorVariantForHost(host: string | undefined): EditorVariant | undefined;
|
|
15
15
|
export declare function focusUri(scheme: string, terminalId: string): string;
|
|
16
16
|
export declare function focusTabSpecs(variant: EditorVariant, folder: string, terminalId: string): LaunchSpec[];
|
|
17
|
-
export declare function makeVscodiumAgentBackend(variant: EditorVariant): TerminalBackend
|
|
18
|
-
|
|
17
|
+
export declare function makeVscodiumAgentBackend(variant: EditorVariant): TerminalBackend & {
|
|
18
|
+
variant: EditorVariant;
|
|
19
|
+
};
|
|
20
|
+
export declare const vscodiumAgentBackend: TerminalBackend & {
|
|
21
|
+
variant: EditorVariant;
|
|
22
|
+
};
|
|
23
|
+
export type SpawnAckStatus = 'opened' | 'focused-existing' | 'wrong-window' | 'failed';
|
|
24
|
+
export interface SpawnAck {
|
|
25
|
+
nonce: string;
|
|
26
|
+
status: SpawnAckStatus;
|
|
27
|
+
windowFolders: string[];
|
|
28
|
+
workspaceName?: string;
|
|
29
|
+
terminalId?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
pid?: number;
|
|
33
|
+
reason?: string;
|
|
34
|
+
at: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const SPAWN_ACK_TIMEOUT_MS = 15000;
|
|
37
|
+
export declare function spawnAckRelPath(nonce: string): string;
|
|
38
|
+
export declare function localSpawnAckPath(nonce: string): string;
|
|
39
|
+
export declare function parseSpawnAck(raw: string, nonce: string): SpawnAck | undefined;
|
|
40
|
+
export declare function awaitSpawnAck(nonce: string, read: () => string | undefined, timeoutMs?: number): Promise<SpawnAck | undefined>;
|
|
41
|
+
export declare function ackLandedIn(ack: SpawnAck, project: string | undefined): boolean;
|
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
|
+
import * as os from 'os';
|
|
3
|
+
import * as path from 'path';
|
|
2
4
|
const EXTENSION_AUTHORITY = 'swarmify.swarm-ext';
|
|
3
5
|
export const EDITOR_VARIANTS = [
|
|
4
|
-
{ cli: 'codium', scheme: 'vscodium', app: '/Applications/VSCodium.app', label: 'VSCodium' },
|
|
5
|
-
{ cli: 'cursor', scheme: 'cursor', app: '/Applications/Cursor.app', label: 'Cursor' },
|
|
6
|
-
{ cli: 'code', scheme: 'vscode', app: '/Applications/Visual Studio Code.app', label: 'VS Code' },
|
|
6
|
+
{ cli: 'codium', scheme: 'vscodium', app: '/Applications/VSCodium.app', label: 'VSCodium', dataDir: 'VSCodium' },
|
|
7
|
+
{ cli: 'cursor', scheme: 'cursor', app: '/Applications/Cursor.app', label: 'Cursor', dataDir: 'Cursor' },
|
|
8
|
+
{ cli: 'code', scheme: 'vscode', app: '/Applications/Visual Studio Code.app', label: 'VS Code', dataDir: 'Code' },
|
|
7
9
|
];
|
|
10
|
+
function uriPath(uri) {
|
|
11
|
+
if (typeof uri !== 'string' || !uri.startsWith('file://'))
|
|
12
|
+
return undefined;
|
|
13
|
+
try {
|
|
14
|
+
return decodeURIComponent(new URL(uri).pathname).replace(/\/$/, '');
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function within(folder, root) {
|
|
21
|
+
return folder === root || folder.startsWith(root.endsWith('/') ? root : `${root}/`);
|
|
22
|
+
}
|
|
23
|
+
function workspaceFolders(configPath) {
|
|
24
|
+
try {
|
|
25
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
26
|
+
return (Array.isArray(config?.folders) ? config.folders : [])
|
|
27
|
+
.map((f) => typeof f?.path === 'string' ? path.resolve(path.dirname(configPath), f.path) : uriPath(f?.uri))
|
|
28
|
+
.filter((f) => !!f);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function openEditorRoots(storageJson) {
|
|
35
|
+
let state;
|
|
36
|
+
try {
|
|
37
|
+
state = storageJson ? JSON.parse(fs.readFileSync(storageJson, 'utf8'))?.windowsState : undefined;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const windows = [...(state?.openedWindows ?? []), ...(state?.lastActiveWindow ? [state.lastActiveWindow] : [])];
|
|
43
|
+
const roots = [];
|
|
44
|
+
for (const w of windows) {
|
|
45
|
+
const single = uriPath(w?.folder);
|
|
46
|
+
if (single)
|
|
47
|
+
roots.push({ target: single, root: single });
|
|
48
|
+
const config = uriPath(w?.workspaceIdentifier?.configURIPath ?? w?.workspace?.configPath);
|
|
49
|
+
if (config)
|
|
50
|
+
for (const root of workspaceFolders(config))
|
|
51
|
+
roots.push({ target: config, root });
|
|
52
|
+
}
|
|
53
|
+
return roots;
|
|
54
|
+
}
|
|
55
|
+
export function editorWindowFor(folder, storageJson) {
|
|
56
|
+
let best;
|
|
57
|
+
for (const r of openEditorRoots(storageJson)) {
|
|
58
|
+
if (within(folder, r.root) && (!best || r.root.length > best.root.length))
|
|
59
|
+
best = r;
|
|
60
|
+
}
|
|
61
|
+
return best?.target ?? folder;
|
|
62
|
+
}
|
|
63
|
+
export function editorFolderNamed(project, storageJson) {
|
|
64
|
+
const roots = new Set(openEditorRoots(storageJson).map((r) => r.root).filter((r) => path.basename(r) === project));
|
|
65
|
+
return roots.size === 1 ? [...roots][0] : undefined;
|
|
66
|
+
}
|
|
67
|
+
export function storageJsonFor(variant, env = process.env) {
|
|
68
|
+
const userData = env.VSCODE_PORTABLE
|
|
69
|
+
? path.join(env.VSCODE_PORTABLE, 'user-data')
|
|
70
|
+
: variant.dataDir ? path.join(os.homedir(), 'Library', 'Application Support', variant.dataDir) : undefined;
|
|
71
|
+
return userData ? path.join(userData, 'User', 'globalStorage', 'storage.json') : undefined;
|
|
72
|
+
}
|
|
8
73
|
function appExists(p) {
|
|
9
74
|
try {
|
|
10
75
|
return fs.existsSync(p);
|
|
@@ -26,6 +91,10 @@ export function spawnUri(scheme, cwd, command, direction, meta) {
|
|
|
26
91
|
payload.sessionId = meta.sessionId;
|
|
27
92
|
if (meta?.title)
|
|
28
93
|
payload.title = meta.title;
|
|
94
|
+
if (meta?.nonce)
|
|
95
|
+
payload.nonce = meta.nonce;
|
|
96
|
+
if (meta?.project)
|
|
97
|
+
payload.project = meta.project;
|
|
29
98
|
const p = Buffer.from(JSON.stringify(payload), 'utf8').toString('base64url');
|
|
30
99
|
return `${scheme}://${EXTENSION_AUTHORITY}/spawn?p=${p}`;
|
|
31
100
|
}
|
|
@@ -35,27 +104,85 @@ export function editorVariantForHost(host) {
|
|
|
35
104
|
export function focusUri(scheme, terminalId) {
|
|
36
105
|
return `${scheme}://${EXTENSION_AUTHORITY}/focus?terminalId=${encodeURIComponent(terminalId)}`;
|
|
37
106
|
}
|
|
38
|
-
|
|
107
|
+
function inFolderWindowSpecs(variant, folder, url) {
|
|
39
108
|
const bundled = `${variant.app}/Contents/Resources/app/bin/${variant.cli}`;
|
|
40
109
|
const cli = appExists(bundled) ? bundled : variant.cli;
|
|
41
110
|
return [
|
|
42
111
|
{ argv: [cli, folder] },
|
|
43
|
-
{ argv: [cli, '--open-url',
|
|
112
|
+
{ argv: [cli, '--open-url', url] },
|
|
44
113
|
];
|
|
45
114
|
}
|
|
115
|
+
export function focusTabSpecs(variant, folder, terminalId) {
|
|
116
|
+
return inFolderWindowSpecs(variant, folder, focusUri(variant.scheme, terminalId));
|
|
117
|
+
}
|
|
46
118
|
export function makeVscodiumAgentBackend(variant) {
|
|
47
119
|
return {
|
|
120
|
+
variant,
|
|
48
121
|
id: 'vscodium-agent',
|
|
49
122
|
label: `${variant.label} agent`,
|
|
50
123
|
isAvailable(ctx) {
|
|
51
124
|
return ctx.platform === 'darwin' && appExists(variant.app);
|
|
52
125
|
},
|
|
53
126
|
buildTab(cwd, command, meta) {
|
|
54
|
-
|
|
127
|
+
const window = editorWindowFor(meta?.project ?? cwd, storageJsonFor(variant));
|
|
128
|
+
return inFolderWindowSpecs(variant, window, spawnUri(variant.scheme, cwd, command, undefined, meta));
|
|
55
129
|
},
|
|
56
130
|
buildSplit(cwd, command, direction, meta) {
|
|
57
|
-
|
|
131
|
+
const window = editorWindowFor(meta?.project ?? cwd, storageJsonFor(variant));
|
|
132
|
+
return inFolderWindowSpecs(variant, window, spawnUri(variant.scheme, cwd, command, direction, meta));
|
|
58
133
|
},
|
|
59
134
|
};
|
|
60
135
|
}
|
|
61
136
|
export const vscodiumAgentBackend = makeVscodiumAgentBackend(EDITOR_VARIANTS[0]);
|
|
137
|
+
const ACK_STATUSES = ['opened', 'focused-existing', 'wrong-window', 'failed'];
|
|
138
|
+
export const SPAWN_ACK_TIMEOUT_MS = 15_000;
|
|
139
|
+
const SPAWN_ACK_POLL_MS = 200;
|
|
140
|
+
export function spawnAckRelPath(nonce) {
|
|
141
|
+
return `.swarmify/agents/spawn-acks/${nonce}.json`;
|
|
142
|
+
}
|
|
143
|
+
export function localSpawnAckPath(nonce) {
|
|
144
|
+
return path.join(os.homedir(), spawnAckRelPath(nonce));
|
|
145
|
+
}
|
|
146
|
+
export function parseSpawnAck(raw, nonce) {
|
|
147
|
+
let v;
|
|
148
|
+
try {
|
|
149
|
+
v = JSON.parse(raw);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
if (!v || v.nonce !== nonce || !ACK_STATUSES.includes(v.status))
|
|
155
|
+
return undefined;
|
|
156
|
+
const str = (x) => (typeof x === 'string' && x ? x : undefined);
|
|
157
|
+
return {
|
|
158
|
+
nonce,
|
|
159
|
+
status: v.status,
|
|
160
|
+
windowFolders: Array.isArray(v.windowFolders) ? v.windowFolders.filter((f) => typeof f === 'string') : [],
|
|
161
|
+
workspaceName: str(v.workspaceName),
|
|
162
|
+
terminalId: str(v.terminalId),
|
|
163
|
+
title: str(v.title),
|
|
164
|
+
sessionId: str(v.sessionId),
|
|
165
|
+
pid: typeof v.pid === 'number' ? v.pid : undefined,
|
|
166
|
+
reason: str(v.reason),
|
|
167
|
+
at: typeof v.at === 'number' ? v.at : 0,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
export async function awaitSpawnAck(nonce, read, timeoutMs = SPAWN_ACK_TIMEOUT_MS) {
|
|
171
|
+
const deadline = Date.now() + timeoutMs;
|
|
172
|
+
for (;;) {
|
|
173
|
+
const raw = read();
|
|
174
|
+
const ack = raw === undefined ? undefined : parseSpawnAck(raw, nonce);
|
|
175
|
+
if (ack)
|
|
176
|
+
return ack;
|
|
177
|
+
if (Date.now() >= deadline)
|
|
178
|
+
return undefined;
|
|
179
|
+
await new Promise((r) => setTimeout(r, SPAWN_ACK_POLL_MS));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export function ackLandedIn(ack, project) {
|
|
183
|
+
if (ack.status === 'wrong-window' || ack.status === 'failed')
|
|
184
|
+
return false;
|
|
185
|
+
if (!project)
|
|
186
|
+
return true;
|
|
187
|
+
return ack.windowFolders.some((f) => within(project, f));
|
|
188
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Backend, EngineContext, LaunchRequest, LaunchResult, LaunchSpec } from './types.js';
|
|
2
2
|
import { type Packing } from './policy.js';
|
|
3
3
|
import { type HostResolver } from './transport.js';
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function specsForRequest(req: LaunchRequest, nonce?: string): LaunchSpec[];
|
|
5
5
|
export interface OpenOptions {
|
|
6
6
|
resolveHost?: HostResolver;
|
|
7
7
|
ctx?: EngineContext;
|
|
8
|
+
ackTimeoutMs?: number;
|
|
8
9
|
}
|
|
9
10
|
export declare function openSurface(req: LaunchRequest, opts?: OpenOptions): Promise<LaunchResult>;
|
|
10
11
|
export interface SurfaceItem {
|
|
@@ -13,6 +14,7 @@ export interface SurfaceItem {
|
|
|
13
14
|
agent?: string;
|
|
14
15
|
sessionId?: string;
|
|
15
16
|
title?: string;
|
|
17
|
+
project?: string;
|
|
16
18
|
}
|
|
17
19
|
export interface BuildRequestsOptions {
|
|
18
20
|
backend: Backend;
|
|
@@ -24,3 +26,7 @@ export interface OpenManyOptions extends OpenOptions, BuildRequestsOptions {
|
|
|
24
26
|
staggerMs?: number;
|
|
25
27
|
}
|
|
26
28
|
export declare function openSurfaces(items: SurfaceItem[], opts: OpenManyOptions): Promise<LaunchResult[]>;
|
|
29
|
+
export declare function describeLaunch(result: LaunchResult, subject: {
|
|
30
|
+
verb: string;
|
|
31
|
+
label: string;
|
|
32
|
+
}): string;
|
|
@@ -3,18 +3,47 @@ import { planLayouts } from './policy.js';
|
|
|
3
3
|
import { runSpec } from './transport.js';
|
|
4
4
|
import { homeRemainder, remoteCdPrefix } from '../project-root.js';
|
|
5
5
|
import { sshExec } from '../ssh-exec.js';
|
|
6
|
+
import { randomUUID } from 'crypto';
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import { awaitSpawnAck, ackLandedIn, localSpawnAckPath, SPAWN_ACK_TIMEOUT_MS } from './backends/vscodium-agent.js';
|
|
6
9
|
const DEFAULT_STAGGER_MS = 400;
|
|
7
10
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
8
|
-
export function
|
|
11
|
+
export function specsForRequest(req, nonce) {
|
|
9
12
|
const backend = BACKENDS[req.backend];
|
|
10
13
|
if (!backend)
|
|
11
14
|
throw new Error(`unknown backend: ${req.backend}`);
|
|
12
|
-
const meta = req.agent || req.sessionId || req.title
|
|
13
|
-
? { agent: req.agent, sessionId: req.sessionId, title: req.title }
|
|
15
|
+
const meta = req.agent || req.sessionId || req.title || req.project || nonce
|
|
16
|
+
? { agent: req.agent, sessionId: req.sessionId, title: req.title, project: req.project, nonce }
|
|
14
17
|
: undefined;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const specs = req.layout === 'tab'
|
|
19
|
+
? backend.buildTab(req.cwd, req.command, meta)
|
|
20
|
+
: backend.buildSplit(req.cwd, req.command, req.layout === 'split-down' ? 'down' : 'right', meta);
|
|
21
|
+
return Array.isArray(specs) ? specs : [specs];
|
|
22
|
+
}
|
|
23
|
+
function ackReader(nonce) {
|
|
24
|
+
const file = localSpawnAckPath(nonce);
|
|
25
|
+
return () => {
|
|
26
|
+
try {
|
|
27
|
+
return fs.readFileSync(file, 'utf8');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function ackFailure(ack, req, timeoutMs) {
|
|
35
|
+
if (!ack)
|
|
36
|
+
return `VSCodium didn't confirm a tab within ${Math.round(timeoutMs / 1000)}s`;
|
|
37
|
+
if (!ackLandedIn(ack, req.project)) {
|
|
38
|
+
const where = ack.workspaceName ?? (ack.windowFolders.join(', ') || 'an unknown window');
|
|
39
|
+
const why = ack.reason ? ` (${ack.reason})` : '';
|
|
40
|
+
if (ack.status === 'failed')
|
|
41
|
+
return `window "${where}" could not open the tab${why}`;
|
|
42
|
+
if (ack.status === 'wrong-window')
|
|
43
|
+
return `the request reached window "${where}", which does not hold ${req.project ?? 'the project'}; nothing was opened${why}`;
|
|
44
|
+
return `the tab opened in window "${where}", not ${req.project ?? 'the project window'}`;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
18
47
|
}
|
|
19
48
|
export async function openSurface(req, opts = {}) {
|
|
20
49
|
try {
|
|
@@ -28,9 +57,24 @@ export async function openSurface(req, opts = {}) {
|
|
|
28
57
|
}
|
|
29
58
|
resolved = { ...req, cwd };
|
|
30
59
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
if (req.backend === 'vscodium-agent' && req.host && req.host !== 'local') {
|
|
61
|
+
return { ok: false, request: req, error: `VSCodium tabs open on this machine only; run the command on ${req.host} instead of passing --device` };
|
|
62
|
+
}
|
|
63
|
+
if (req.backend === 'vscodium-agent' && !req.project) {
|
|
64
|
+
return { ok: false, request: req, error: `no local project folder for ${req.cwd}, so there is no VSCodium window to open it in` };
|
|
65
|
+
}
|
|
66
|
+
const nonce = req.backend === 'vscodium-agent' ? randomUUID() : undefined;
|
|
67
|
+
for (const spec of specsForRequest(resolved, nonce)) {
|
|
68
|
+
const res = await runSpec(spec, req.host, opts.resolveHost);
|
|
69
|
+
if (!res.ok)
|
|
70
|
+
return { ok: false, request: req, error: res.error };
|
|
71
|
+
}
|
|
72
|
+
if (!nonce)
|
|
73
|
+
return { ok: true, request: req };
|
|
74
|
+
const timeoutMs = opts.ackTimeoutMs ?? SPAWN_ACK_TIMEOUT_MS;
|
|
75
|
+
const ack = await awaitSpawnAck(nonce, ackReader(nonce), timeoutMs);
|
|
76
|
+
const failure = ackFailure(ack, req, timeoutMs);
|
|
77
|
+
return failure ? { ok: false, request: req, error: failure, ack } : { ok: true, request: req, ack };
|
|
34
78
|
}
|
|
35
79
|
catch (err) {
|
|
36
80
|
return { ok: false, request: req, error: err?.message ?? String(err) };
|
|
@@ -47,6 +91,7 @@ export function buildRequests(items, opts) {
|
|
|
47
91
|
agent: item.agent,
|
|
48
92
|
sessionId: item.sessionId,
|
|
49
93
|
title: item.title,
|
|
94
|
+
project: item.project,
|
|
50
95
|
}));
|
|
51
96
|
}
|
|
52
97
|
export async function openSurfaces(items, opts) {
|
|
@@ -60,3 +105,17 @@ export async function openSurfaces(items, opts) {
|
|
|
60
105
|
}
|
|
61
106
|
return results;
|
|
62
107
|
}
|
|
108
|
+
export function describeLaunch(result, subject) {
|
|
109
|
+
const ack = result.ack;
|
|
110
|
+
if (!result.ok)
|
|
111
|
+
return `Can't open ${subject.label}: ${result.error ?? 'unknown error'}.`;
|
|
112
|
+
if (ack) {
|
|
113
|
+
const window = ack.workspaceName ?? ack.windowFolders[0] ?? 'unknown';
|
|
114
|
+
const tab = ack.title ?? ack.terminalId ?? 'untitled';
|
|
115
|
+
return ack.status === 'focused-existing'
|
|
116
|
+
? `Already open → focused tab "${tab}" in window "${window}"`
|
|
117
|
+
: `${subject.verb} ${subject.label}\n → VSCodium window "${window}", new tab "${tab}"`;
|
|
118
|
+
}
|
|
119
|
+
const label = BACKENDS[result.request.backend]?.label ?? result.request.backend;
|
|
120
|
+
return `Sent ${subject.label} to ${label}. ${label} does not report back, so whether the tab opened is not confirmed.`;
|
|
121
|
+
}
|
|
@@ -4,7 +4,7 @@ export { BACKENDS, detectCurrentBackend, availableBackends, itermBackend, ghostt
|
|
|
4
4
|
export { SESSION_HOST_BACKENDS, backendFromSessions, resolveLaunchBackend, describeBackendChoice, type SessionHostSample, type BackendSource, type LaunchBackendChoice, } from './preferred.js';
|
|
5
5
|
export { makeVscodiumAgentBackend, spawnUri, EDITOR_VARIANTS, type EditorVariant } from './backends/vscodium-agent.js';
|
|
6
6
|
export { planLayouts, type Packing } from './policy.js';
|
|
7
|
-
export {
|
|
7
|
+
export { specsForRequest, describeLaunch, buildRequests, openSurface, openSurfaces, type OpenOptions, type OpenManyOptions, type BuildRequestsOptions, type SurfaceItem, } from './engine.js';
|
|
8
8
|
export { runLocal, runRemote, runSpec, remoteCommand, type HostResolver, type RunResult } from './transport.js';
|
|
9
9
|
export { backendCarriesPaste, injectIntoTerminal, tmuxSendKeysArgv, tmuxInjectSpecs, itermInjectScript, ghosttyInjectScript, appleScriptInjectSpec, vscodiumInjectUri, vscodiumInjectSpec, type InjectTarget, type InjectBackend, type InjectOptions, type InjectResult, } from './inject.js';
|
|
10
10
|
export { resolveInjectTarget, resolveInjectTargetForSession, type InjectResolution, type InjectRail, type ResolveOptions, } from './resolve.js';
|
|
@@ -3,7 +3,7 @@ export { BACKENDS, detectCurrentBackend, availableBackends, itermBackend, ghostt
|
|
|
3
3
|
export { SESSION_HOST_BACKENDS, backendFromSessions, resolveLaunchBackend, describeBackendChoice, } from './preferred.js';
|
|
4
4
|
export { makeVscodiumAgentBackend, spawnUri, EDITOR_VARIANTS } from './backends/vscodium-agent.js';
|
|
5
5
|
export { planLayouts } from './policy.js';
|
|
6
|
-
export {
|
|
6
|
+
export { specsForRequest, describeLaunch, buildRequests, openSurface, openSurfaces, } from './engine.js';
|
|
7
7
|
export { runLocal, runRemote, runSpec, remoteCommand } from './transport.js';
|
|
8
8
|
export { backendCarriesPaste, injectIntoTerminal, tmuxSendKeysArgv, tmuxInjectSpecs, itermInjectScript, ghosttyInjectScript, appleScriptInjectSpec, vscodiumInjectUri, vscodiumInjectSpec, } from './inject.js';
|
|
9
9
|
export { resolveInjectTarget, resolveInjectTargetForSession, } from './resolve.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BACKENDS } from './backends/index.js';
|
|
2
|
-
import { openSurface } from './engine.js';
|
|
2
|
+
import { openSurface, describeLaunch } from './engine.js';
|
|
3
3
|
import { getCliLaunch } from '../cli-entry.js';
|
|
4
4
|
import { shellQuote } from './quote.js';
|
|
5
5
|
import { resolveLaunchBackend, describeBackendChoice, } from './preferred.js';
|
|
@@ -95,6 +95,12 @@ export async function openRunInTerminal(params) {
|
|
|
95
95
|
layout: 'tab',
|
|
96
96
|
cwd: params.cwd,
|
|
97
97
|
command,
|
|
98
|
+
project: params.cwd,
|
|
98
99
|
});
|
|
99
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
ok: result.ok,
|
|
102
|
+
choice,
|
|
103
|
+
description: `${describeLaunch(result, { verb: 'Started', label: params.label })} (${describeBackendChoice(choice)})`,
|
|
104
|
+
error: result.error,
|
|
105
|
+
};
|
|
100
106
|
}
|
|
@@ -13,6 +13,8 @@ export interface SurfaceMeta {
|
|
|
13
13
|
agent?: string;
|
|
14
14
|
sessionId?: string;
|
|
15
15
|
title?: string;
|
|
16
|
+
project?: string;
|
|
17
|
+
nonce?: string;
|
|
16
18
|
}
|
|
17
19
|
export interface LaunchRequest {
|
|
18
20
|
backend: Backend;
|
|
@@ -23,16 +25,18 @@ export interface LaunchRequest {
|
|
|
23
25
|
agent?: string;
|
|
24
26
|
sessionId?: string;
|
|
25
27
|
title?: string;
|
|
28
|
+
project?: string;
|
|
26
29
|
}
|
|
27
30
|
export interface LaunchResult {
|
|
28
31
|
ok: boolean;
|
|
29
32
|
request: LaunchRequest;
|
|
30
33
|
error?: string;
|
|
34
|
+
ack?: import('./backends/vscodium-agent.js').SpawnAck;
|
|
31
35
|
}
|
|
32
36
|
export interface TerminalBackend {
|
|
33
37
|
readonly id: Backend;
|
|
34
38
|
readonly label: string;
|
|
35
39
|
isAvailable(ctx: EngineContext): boolean;
|
|
36
|
-
buildTab(cwd: string, command: string[], meta?: SurfaceMeta): LaunchSpec;
|
|
37
|
-
buildSplit(cwd: string, command: string[], direction: SplitDirection, meta?: SurfaceMeta): LaunchSpec;
|
|
40
|
+
buildTab(cwd: string, command: string[], meta?: SurfaceMeta): LaunchSpec | LaunchSpec[];
|
|
41
|
+
buildSplit(cwd: string, command: string[], direction: SplitDirection, meta?: SurfaceMeta): LaunchSpec | LaunchSpec[];
|
|
38
42
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type RunEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto';
|
|
|
36
36
|
export declare const RUN_AUTO_KEYWORD = "auto";
|
|
37
37
|
export declare const RUN_AUTO_HOST_RESOLVED_ENV = "AGENTS_RUN_AUTO_HOST_RESOLVED";
|
|
38
38
|
export declare const REMOTE_INTERACTIVE_ENV = "AGENTS_REMOTE_INTERACTIVE";
|
|
39
|
+
export declare const PEER_HOP_ENV = "AGENTS_PEER_HOP";
|
|
39
40
|
export interface AgentRunConfig {
|
|
40
41
|
strategy?: RunStrategy;
|
|
41
42
|
}
|
package/dist/lib/types.js
CHANGED
|
@@ -5,6 +5,7 @@ export function isAgentId(value) {
|
|
|
5
5
|
export const RUN_AUTO_KEYWORD = 'auto';
|
|
6
6
|
export const RUN_AUTO_HOST_RESOLVED_ENV = 'AGENTS_RUN_AUTO_HOST_RESOLVED';
|
|
7
7
|
export const REMOTE_INTERACTIVE_ENV = 'AGENTS_REMOTE_INTERACTIVE';
|
|
8
|
+
export const PEER_HOP_ENV = 'AGENTS_PEER_HOP';
|
|
8
9
|
export const ALL_MODES = ['plan', 'edit', 'auto', 'skip'];
|
|
9
10
|
export const DEFAULT_SYSTEM_REPO = 'gh:phnx-labs/.agents-system';
|
|
10
11
|
export function systemRepoSlug(repo = DEFAULT_SYSTEM_REPO) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phnx-labs/agents-cli",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.6",
|
|
4
4
|
"description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|