@phnx-labs/agents-cli 1.23.21 → 1.23.23
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 +115 -0
- package/README.md +17 -0
- package/dist/bootstrap.js +5 -4
- package/dist/cli/command-registry.js +2 -0
- package/dist/commands/config.js +16 -0
- package/dist/commands/daemon.js +3 -3
- package/dist/commands/doctor.js +10 -19
- package/dist/commands/events.js +1 -14
- package/dist/commands/feed-watch.js +5 -2
- package/dist/commands/go.js +2 -2
- package/dist/commands/lead.d.ts +3 -0
- package/dist/commands/lead.js +280 -0
- package/dist/commands/projects.js +3 -2
- package/dist/commands/ps-roster.d.ts +2 -12
- package/dist/commands/ps-roster.js +5 -87
- package/dist/commands/ps.js +3 -1
- package/dist/commands/repo.js +12 -12
- package/dist/commands/resource-view.js +5 -5
- package/dist/commands/sessions-browser.js +2 -2
- package/dist/commands/sessions-watch.js +5 -2
- package/dist/commands/setup-secrets.d.ts +3 -4
- package/dist/commands/setup-secrets.js +15 -46
- package/dist/commands/setup-session-backup.js +1 -1
- package/dist/commands/ssh.d.ts +0 -4
- package/dist/commands/ssh.js +14 -81
- package/dist/commands/teams-picker.js +1 -12
- package/dist/commands/teams.js +1 -13
- package/dist/commands/view.d.ts +1 -40
- package/dist/commands/view.js +9 -330
- package/dist/commands/watchdog.js +4 -4
- package/dist/index.js +4 -0
- package/dist/lib/accounting/usage.d.ts +0 -1
- package/dist/lib/accounting/usage.js +1 -112
- package/dist/lib/accounts/add.js +1 -1
- package/dist/lib/accounts/migrate.js +1 -1
- package/dist/lib/auto-pull-worker.js +2 -16
- package/dist/lib/auto-pull.d.ts +1 -0
- package/dist/lib/auto-pull.js +27 -0
- package/dist/lib/browser-client.js +2 -11
- package/dist/lib/cloud/codex.js +3 -0
- package/dist/lib/commands.d.ts +0 -6
- package/dist/lib/commands.js +3 -116
- package/dist/lib/comms-render.d.ts +1 -7
- package/dist/lib/comms-render.js +0 -19
- package/dist/lib/computer-client.js +2 -11
- package/dist/lib/config-keys.d.ts +7 -3
- package/dist/lib/config-keys.js +15 -2
- package/dist/lib/crabbox/runtimes.d.ts +0 -14
- package/dist/lib/crabbox/runtimes.js +0 -80
- package/dist/lib/daemon/attention-notify-service.d.ts +53 -28
- package/dist/lib/daemon/attention-notify-service.js +232 -53
- package/dist/lib/daemon/daemon.js +1 -2
- package/dist/lib/daemon/feed-stream-service.js +2 -4
- package/dist/lib/device-config.d.ts +0 -5
- package/dist/lib/device-config.js +20 -27
- package/dist/lib/devices/doctor-findings.d.ts +2 -1
- package/dist/lib/devices/doctor-findings.js +12 -1
- package/dist/lib/devices/fleet.d.ts +6 -0
- package/dist/lib/devices/fleet.js +15 -0
- package/dist/lib/devices/harness-inventory.d.ts +9 -0
- package/dist/lib/devices/harness-inventory.js +66 -0
- package/dist/lib/exec.js +1 -3
- package/dist/lib/feed/attention.d.ts +16 -1
- package/dist/lib/feed/attention.js +63 -1
- package/dist/lib/feed/feed.d.ts +1 -1
- package/dist/lib/feed/feed.js +12 -2
- package/dist/lib/feed/hub.d.ts +9 -0
- package/dist/lib/feed/hub.js +27 -1
- package/dist/lib/feed/notify-schedule.d.ts +16 -0
- package/dist/lib/feed/notify-schedule.js +62 -0
- package/dist/lib/feed/ticket-priority.d.ts +4 -0
- package/dist/lib/feed/ticket-priority.js +30 -0
- package/dist/lib/feed/watch.d.ts +1 -0
- package/dist/lib/feed/watch.js +27 -3
- package/dist/lib/feed-ranking.d.ts +1 -0
- package/dist/lib/feed-ranking.js +3 -1
- package/dist/lib/format.d.ts +0 -2
- package/dist/lib/format.js +0 -8
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hooks/cache.d.ts +1 -0
- package/dist/lib/hooks/cache.js +12 -1
- package/dist/lib/installations/duplicate-prune.d.ts +37 -0
- package/dist/lib/installations/duplicate-prune.js +85 -0
- package/dist/lib/installations/inventory-json.d.ts +20 -0
- package/dist/lib/installations/inventory-json.js +252 -0
- package/dist/lib/installations/shims.d.ts +0 -18
- package/dist/lib/installations/shims.js +1 -257
- package/dist/lib/lead/brief.d.ts +49 -0
- package/dist/lib/lead/brief.js +173 -0
- package/dist/lib/lead/client.d.ts +21 -0
- package/dist/lib/lead/client.js +167 -0
- package/dist/lib/lead/confirm.d.ts +22 -0
- package/dist/lib/lead/confirm.js +73 -0
- package/dist/lib/lead/events.d.ts +106 -0
- package/dist/lib/lead/events.js +188 -0
- package/dist/lib/lead/harness.d.ts +29 -0
- package/dist/lib/lead/harness.js +107 -0
- package/dist/lib/lead/host.d.ts +132 -0
- package/dist/lib/lead/host.js +675 -0
- package/dist/lib/lead/paths.d.ts +22 -0
- package/dist/lib/lead/paths.js +69 -0
- package/dist/lib/lead/refs.d.ts +17 -0
- package/dist/lib/lead/refs.js +75 -0
- package/dist/lib/lead/roster.d.ts +26 -0
- package/dist/lib/lead/roster.js +121 -0
- package/dist/lib/lead/shapes.d.ts +23 -0
- package/dist/lib/lead/shapes.js +95 -0
- package/dist/lib/lead/store.d.ts +46 -0
- package/dist/lib/lead/store.js +77 -0
- package/dist/lib/lead/tools.d.ts +18 -0
- package/dist/lib/lead/tools.js +106 -0
- package/dist/lib/lead/visibility.d.ts +16 -0
- package/dist/lib/lead/visibility.js +77 -0
- package/dist/lib/mailbox.d.ts +0 -18
- package/dist/lib/mailbox.js +0 -170
- package/dist/lib/menubar/notify-desktop.d.ts +5 -0
- package/dist/lib/menubar/notify-desktop.js +24 -0
- package/dist/lib/models.js +1 -19
- package/dist/lib/permissions.d.ts +0 -6
- package/dist/lib/permissions.js +0 -140
- package/dist/lib/platform/process.d.ts +1 -0
- package/dist/lib/platform/process.js +5 -0
- package/dist/lib/probe.js +13 -1
- package/dist/lib/project-status.js +4 -3
- package/dist/lib/projects.d.ts +9 -0
- package/dist/lib/projects.js +61 -3
- package/dist/lib/scheduling/routines.d.ts +1 -13
- package/dist/lib/scheduling/routines.js +1 -37
- package/dist/lib/secrets-cli.d.ts +3 -3
- package/dist/lib/secrets-cli.js +1 -1
- package/dist/lib/secrets-client.d.ts +4 -37
- package/dist/lib/secrets-client.js +19 -265
- package/dist/lib/session/active.d.ts +18 -8
- package/dist/lib/session/active.js +94 -18
- package/dist/lib/session/db.d.ts +0 -16
- package/dist/lib/session/db.js +1 -134
- package/dist/lib/session/detached.d.ts +0 -1
- package/dist/lib/session/detached.js +0 -18
- package/dist/lib/session/pending-work.d.ts +21 -0
- package/dist/lib/session/pending-work.js +284 -0
- package/dist/lib/session/remote/remote-list.d.ts +0 -3
- package/dist/lib/session/remote/remote-list.js +1 -23
- package/dist/lib/session/remote/watch.d.ts +5 -0
- package/dist/lib/session/remote/watch.js +19 -2
- package/dist/lib/session/session-cache.d.ts +1 -1
- package/dist/lib/session/session-cache.js +12 -5
- package/dist/lib/session/sync/provision.js +1 -2
- package/dist/lib/smart-launch.js +7 -2
- package/dist/lib/snapshot.js +3 -4
- package/dist/lib/ssh-exec.d.ts +0 -40
- package/dist/lib/ssh-exec.js +0 -108
- package/dist/lib/ssh-tunnel.d.ts +0 -6
- package/dist/lib/ssh-tunnel.js +0 -42
- package/dist/lib/standalone-tools.js +12 -1
- package/dist/lib/startup/command-registry.js +1 -1
- package/dist/lib/startup/spellcheck.d.ts +0 -1
- package/dist/lib/startup/spellcheck.js +1 -20
- package/dist/lib/state.d.ts +0 -6
- package/dist/lib/state.js +1 -14
- package/dist/lib/teams/delivery.d.ts +1 -0
- package/dist/lib/teams/delivery.js +13 -0
- package/dist/lib/types.d.ts +0 -37
- package/dist/lib/types.js +0 -9
- package/dist/lib/watchdog/log.d.ts +1 -1
- package/dist/lib/watchdog/log.js +6 -4
- package/package.json +2 -1
- package/dist/lib/artifact-actions.d.ts +0 -7
- package/dist/lib/artifact-actions.js +0 -39
- package/dist/lib/session/sync/managed-config.d.ts +0 -3
- package/dist/lib/session/sync/managed-config.js +0 -3
- package/dist/lib/session/sync/worker-template.d.ts +0 -1
- package/dist/lib/session/sync/worker-template.js +0 -807
- package/dist/lib/storage/selection.d.ts +0 -8
- package/dist/lib/storage/selection.js +0 -10
- package/dist/lib/watchdog/index.d.ts +0 -3
- package/dist/lib/watchdog/index.js +0 -3
package/dist/lib/ssh-exec.js
CHANGED
|
@@ -158,114 +158,6 @@ export function sshExecRaw(target, remoteCmd, opts = {}) {
|
|
|
158
158
|
timedOut,
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
export const SSH_STREAM_KILL_GRACE_MS = 3_000;
|
|
162
|
-
export const SSH_STREAM_MAX_STDERR = 8 * 1024;
|
|
163
|
-
/**
|
|
164
|
-
* Stream one ssh command's stdout, with the args and env a CALLER built.
|
|
165
|
-
*
|
|
166
|
-
* This exists because {@link sshExecRawStream} assembles its own ssh args, which
|
|
167
|
-
* means it cannot carry a device's canonical auth — the askpass shim for a
|
|
168
|
-
* password-auth box, `-i`/`IdentitiesOnly` for an explicit identity file, or the
|
|
169
|
-
* managed known-hosts pinning. A caller that has already built those through
|
|
170
|
-
* `buildSshInvocation` needs a way to run them, and duplicating the transport to
|
|
171
|
-
* get it would be the worse answer. So this takes `args`/`env` verbatim and adds
|
|
172
|
-
* only the lifecycle guarantees:
|
|
173
|
-
*
|
|
174
|
-
* - **SIGTERM then SIGKILL.** A timeout or abort that only sends SIGTERM leaks a
|
|
175
|
-
* child that ignores it — ssh does, mid-handshake — and the promise never
|
|
176
|
-
* settles. After {@link SSH_STREAM_KILL_GRACE_MS} the child is SIGKILLed and
|
|
177
|
-
* `killed` says so.
|
|
178
|
-
* - **Bounded stderr.** A peer that writes endlessly to stderr would otherwise
|
|
179
|
-
* grow this buffer without limit; it is capped and `stderrTruncated` says so.
|
|
180
|
-
* - **`onStdout` cannot break the caller's cleanup.** A throw from the consumer
|
|
181
|
-
* is captured and re-thrown by the awaiting caller, so a write failure ends the
|
|
182
|
-
* transfer instead of escaping as an unhandled error inside a stream event.
|
|
183
|
-
*/
|
|
184
|
-
export function sshStreamWithArgs(opts) {
|
|
185
|
-
const maxStderr = opts.maxStderrBytes ?? SSH_STREAM_MAX_STDERR;
|
|
186
|
-
const grace = opts.killGraceMs ?? SSH_STREAM_KILL_GRACE_MS;
|
|
187
|
-
return new Promise((resolve, reject) => {
|
|
188
|
-
const child = spawn(opts.sshBin ?? 'ssh', opts.args, {
|
|
189
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
190
|
-
env: opts.env ? { ...process.env, ...opts.env } : process.env,
|
|
191
|
-
windowsHide: true,
|
|
192
|
-
detached: process.platform !== 'win32',
|
|
193
|
-
});
|
|
194
|
-
const stderr = [];
|
|
195
|
-
let stderrBytes = 0;
|
|
196
|
-
let stderrTruncated = false;
|
|
197
|
-
let timedOut = false;
|
|
198
|
-
let killed = false;
|
|
199
|
-
let consumerError;
|
|
200
|
-
let settled = false;
|
|
201
|
-
let killTimer;
|
|
202
|
-
const signal = (sig) => {
|
|
203
|
-
try {
|
|
204
|
-
if (process.platform !== 'win32' && child.pid)
|
|
205
|
-
process.kill(-child.pid, sig);
|
|
206
|
-
else
|
|
207
|
-
child.kill(sig);
|
|
208
|
-
}
|
|
209
|
-
catch { }
|
|
210
|
-
};
|
|
211
|
-
const escalate = () => {
|
|
212
|
-
signal('SIGTERM');
|
|
213
|
-
killTimer = setTimeout(() => { killed = true; signal('SIGKILL'); }, grace);
|
|
214
|
-
killTimer.unref?.();
|
|
215
|
-
};
|
|
216
|
-
const stop = () => escalate();
|
|
217
|
-
const finish = (code) => {
|
|
218
|
-
if (settled)
|
|
219
|
-
return;
|
|
220
|
-
settled = true;
|
|
221
|
-
if (timer)
|
|
222
|
-
clearTimeout(timer);
|
|
223
|
-
if (killTimer)
|
|
224
|
-
clearTimeout(killTimer);
|
|
225
|
-
opts.signal?.removeEventListener('abort', stop);
|
|
226
|
-
if (consumerError !== undefined) {
|
|
227
|
-
reject(consumerError);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
resolve({ code, stderr: Buffer.concat(stderr), timedOut, killed, stderrTruncated });
|
|
231
|
-
};
|
|
232
|
-
const timer = opts.timeoutMs
|
|
233
|
-
? setTimeout(() => { timedOut = true; escalate(); }, opts.timeoutMs)
|
|
234
|
-
: null;
|
|
235
|
-
child.stdout.on('data', (chunk) => {
|
|
236
|
-
if (consumerError !== undefined)
|
|
237
|
-
return;
|
|
238
|
-
try {
|
|
239
|
-
opts.onStdout(chunk);
|
|
240
|
-
}
|
|
241
|
-
catch (error) {
|
|
242
|
-
consumerError = error;
|
|
243
|
-
escalate();
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
child.stderr.on('data', (chunk) => {
|
|
247
|
-
const room = maxStderr - stderrBytes;
|
|
248
|
-
if (room <= 0) {
|
|
249
|
-
stderrTruncated = true;
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (chunk.length > room) {
|
|
253
|
-
stderrTruncated = true;
|
|
254
|
-
stderr.push(chunk.subarray(0, room));
|
|
255
|
-
stderrBytes = maxStderr;
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
stderr.push(chunk);
|
|
259
|
-
stderrBytes += chunk.length;
|
|
260
|
-
});
|
|
261
|
-
child.once('error', () => finish(null));
|
|
262
|
-
child.once('close', finish);
|
|
263
|
-
if (opts.signal?.aborted)
|
|
264
|
-
escalate();
|
|
265
|
-
else
|
|
266
|
-
opts.signal?.addEventListener('abort', stop, { once: true });
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
161
|
export function sshExecRawStream(target, remoteCmd, opts) {
|
|
270
162
|
// Raw streaming preserves byte offsets across UTF-8 chunk boundaries.
|
|
271
163
|
assertValidSshTarget(target);
|
package/dist/lib/ssh-tunnel.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { type ChildProcess } from 'child_process';
|
|
2
1
|
import { type DeviceProfile } from './devices/registry.js';
|
|
3
|
-
interface StartTunnelOptions {
|
|
4
|
-
extraSshArgs?: string[];
|
|
5
|
-
}
|
|
6
|
-
export declare function buildTunnelArgs(user: string, host: string, localPort: number, remotePort: number, extraSshArgs?: string[]): string[];
|
|
7
|
-
export declare function startSSHTunnel(user: string, host: string, localPort: number, remotePort: number, opts?: StartTunnelOptions): Promise<ChildProcess>;
|
|
8
2
|
interface ResolvedRemoteDevice {
|
|
9
3
|
device: DeviceProfile;
|
|
10
4
|
target: string;
|
package/dist/lib/ssh-tunnel.js
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { SSH_OPTS, assertValidSshTarget } from './ssh-exec.js';
|
|
3
1
|
import { getDevice } from './devices/registry.js';
|
|
4
2
|
import { deviceIdentityArgs, sshTargetFor } from './devices/connect.js';
|
|
5
3
|
import { hostNameFor } from './devices/ssh-config.js';
|
|
6
|
-
export function buildTunnelArgs(user, host, localPort, remotePort, extraSshArgs = []) {
|
|
7
|
-
return [
|
|
8
|
-
'-L',
|
|
9
|
-
`${localPort}:127.0.0.1:${remotePort}`,
|
|
10
|
-
`${user}@${host}`,
|
|
11
|
-
'-N',
|
|
12
|
-
...extraSshArgs,
|
|
13
|
-
...SSH_OPTS,
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
export function startSSHTunnel(user, host, localPort, remotePort, opts = {}) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
try {
|
|
19
|
-
assertValidSshTarget(`${user}@${host}`);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
reject(err);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const args = buildTunnelArgs(user, host, localPort, remotePort, opts.extraSshArgs);
|
|
26
|
-
const tunnel = spawn('ssh', args, {
|
|
27
|
-
stdio: ['ignore', 'ignore', 'pipe'],
|
|
28
|
-
detached: false,
|
|
29
|
-
windowsHide: true,
|
|
30
|
-
});
|
|
31
|
-
let stderr = '';
|
|
32
|
-
tunnel.stderr?.on('data', (data) => {
|
|
33
|
-
stderr += data.toString();
|
|
34
|
-
});
|
|
35
|
-
tunnel.on('error', (err) => {
|
|
36
|
-
reject(new Error(`SSH tunnel failed: ${err.message}`));
|
|
37
|
-
});
|
|
38
|
-
setTimeout(() => {
|
|
39
|
-
if (tunnel.killed)
|
|
40
|
-
reject(new Error(`SSH tunnel died: ${stderr}`));
|
|
41
|
-
else
|
|
42
|
-
resolve(tunnel);
|
|
43
|
-
}, 500);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
4
|
export async function resolveRemoteDevice(name, opts = {}) {
|
|
47
5
|
const device = await getDevice(name);
|
|
48
6
|
if (!device) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { installCli, installedCliVersion } from './cli-resources.js';
|
|
2
2
|
import { compareVersions } from './agent-spec/primitives.js';
|
|
3
3
|
import { SECRETS_CLI_PACKAGE, SECRETS_CLI_VERSION } from './secrets-cli.js';
|
|
4
|
+
import { invocation } from './secrets-client.js';
|
|
4
5
|
export const STANDALONE_TOOLS = ['sessions', 'browser', 'secrets', 'computer', 'term'];
|
|
5
6
|
export const STANDALONE_TOOL_PINS = {
|
|
6
7
|
sessions: { tool: 'sessions', pkg: '@phnx-labs/sessions-cli', floor: '0.6.0' },
|
|
@@ -13,10 +14,15 @@ export function pinnedSpec(tool) {
|
|
|
13
14
|
const pin = STANDALONE_TOOL_PINS[tool];
|
|
14
15
|
return `${pin.pkg}@${pin.floor}`;
|
|
15
16
|
}
|
|
17
|
+
function explicitBin(tool) {
|
|
18
|
+
return tool === 'secrets' ? process.env.SECRETS_BIN?.trim() || null : null;
|
|
19
|
+
}
|
|
16
20
|
function pinManifest(tool) {
|
|
21
|
+
const bin = explicitBin(tool);
|
|
22
|
+
const { command, prefix } = bin ? invocation(bin) : { command: tool, prefix: [] };
|
|
17
23
|
return {
|
|
18
24
|
name: tool,
|
|
19
|
-
check: { kind: 'version', cmd:
|
|
25
|
+
check: { kind: 'version', cmd: command, args: [...prefix, '--version'] },
|
|
20
26
|
install: [{ npm: pinnedSpec(tool) }],
|
|
21
27
|
source: 'builtin',
|
|
22
28
|
path: '',
|
|
@@ -41,6 +47,11 @@ export async function ensureToolPins(opts = {}) {
|
|
|
41
47
|
out.push(row);
|
|
42
48
|
continue;
|
|
43
49
|
}
|
|
50
|
+
const bin = explicitBin(row.tool);
|
|
51
|
+
if (bin) {
|
|
52
|
+
out.push({ ...row, state: 'failed', error: `SECRETS_BIN=${bin} reads ${row.installed ?? 'no version'}, below ${pinnedSpec(row.tool)}; point it at a newer build or unset it` });
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
44
55
|
const result = installCli(pinManifest(row.tool), { logToStderr: opts.logToStderr });
|
|
45
56
|
const installed = await installedCliVersion(pinManifest(row.tool));
|
|
46
57
|
if (result.error || !meetsFloor(installed, row.floor)) {
|
|
@@ -8,7 +8,7 @@ const LOADED_COMMAND_NAMES = [
|
|
|
8
8
|
'refresh-rules', 'factory', 'insights', 'trace',
|
|
9
9
|
'watchdog', 'events',
|
|
10
10
|
'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade',
|
|
11
|
-
'teams', 'cloud', 'ps', 'send', 'feed',
|
|
11
|
+
'teams', 'cloud', 'ps', 'send', 'feed', 'lead',
|
|
12
12
|
'daemon', 'recordings',
|
|
13
13
|
];
|
|
14
14
|
const INLINE_COMMAND_NAMES = [
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const m = a.length;
|
|
3
|
-
const n = b.length;
|
|
4
|
-
const dp = Array(m + 1)
|
|
5
|
-
.fill(null)
|
|
6
|
-
.map(() => Array(n + 1).fill(0));
|
|
7
|
-
for (let i = 0; i <= m; i++)
|
|
8
|
-
dp[i][0] = i;
|
|
9
|
-
for (let j = 0; j <= n; j++)
|
|
10
|
-
dp[0][j] = j;
|
|
11
|
-
for (let i = 1; i <= m; i++) {
|
|
12
|
-
for (let j = 1; j <= n; j++) {
|
|
13
|
-
dp[i][j] =
|
|
14
|
-
a[i - 1] === b[j - 1]
|
|
15
|
-
? dp[i - 1][j - 1]
|
|
16
|
-
: 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return dp[m][n];
|
|
20
|
-
}
|
|
1
|
+
import { levenshtein } from '../fuzzy.js';
|
|
21
2
|
export function closestTopLevelCommand(unknown, candidates) {
|
|
22
3
|
let closest = null;
|
|
23
4
|
let minDist = Infinity;
|
package/dist/lib/state.d.ts
CHANGED
|
@@ -47,7 +47,6 @@ export declare function getUserPermissionsDir(): string;
|
|
|
47
47
|
export declare function getUserSubagentsDir(): string;
|
|
48
48
|
export declare function getSystemWorkflowsDir(): string;
|
|
49
49
|
export declare function getUserWorkflowsDir(): string;
|
|
50
|
-
export declare function getUserSecretsDir(): string;
|
|
51
50
|
export declare function getSecretsDbPath(): string;
|
|
52
51
|
export declare function getAnalyticsDir(): string;
|
|
53
52
|
export declare function getUsageDbPath(): string;
|
|
@@ -55,15 +54,11 @@ export declare function getUserPromptcutsPath(): string;
|
|
|
55
54
|
export declare function getHomeDir(): string;
|
|
56
55
|
export declare function getHistoryDir(): string;
|
|
57
56
|
export declare function getCacheDir(): string;
|
|
58
|
-
export declare function getPackagesDir(): string;
|
|
59
57
|
export declare function getRoutinesDir(): string;
|
|
60
58
|
export declare function getProjectsDir(): string;
|
|
61
59
|
export declare function getDaemonConfigDir(): string;
|
|
62
|
-
export declare function getWebhooksDir(): string;
|
|
63
60
|
export declare function getSystemRoutinesDir(): string;
|
|
64
|
-
export declare function getSystemWebhooksDir(): string;
|
|
65
61
|
export declare function getProjectRoutinesDir(cwd?: string): string | null;
|
|
66
|
-
export declare function getProjectWebhooksDir(cwd?: string): string | null;
|
|
67
62
|
export declare function getRunsDir(): string;
|
|
68
63
|
export declare function getMailboxRootDir(): string;
|
|
69
64
|
export declare function getFeedDir(): string;
|
|
@@ -98,7 +93,6 @@ export declare function getPerfSpoolPath(): string;
|
|
|
98
93
|
export declare function getRuntimeStateDir(): string;
|
|
99
94
|
export declare function getCompanionDir(): string;
|
|
100
95
|
export declare function getBrowserRuntimeDir(): string;
|
|
101
|
-
export declare function getBrowserDurableDir(): string;
|
|
102
96
|
export declare function getHelpersDir(): string;
|
|
103
97
|
export declare function getDaemonDir(): string;
|
|
104
98
|
export declare function getTmuxDir(): string;
|
package/dist/lib/state.js
CHANGED
|
@@ -32,14 +32,12 @@ const SYSTEM_SUBAGENTS_DIR = path.join(SYSTEM_AGENTS_DIR, 'subagents');
|
|
|
32
32
|
const SYSTEM_WORKFLOWS_DIR = path.join(SYSTEM_AGENTS_DIR, 'workflows');
|
|
33
33
|
const SYSTEM_PLUGINS_DIR = path.join(SYSTEM_AGENTS_DIR, 'plugins');
|
|
34
34
|
const SYSTEM_ROUTINES_DIR = path.join(SYSTEM_AGENTS_DIR, 'routines');
|
|
35
|
-
const SYSTEM_WEBHOOKS_DIR = path.join(SYSTEM_AGENTS_DIR, 'webhooks');
|
|
36
35
|
const SYSTEM_PROMPTCUTS_FILE = path.join(SYSTEM_AGENTS_DIR, 'hooks', 'promptcuts.yaml');
|
|
37
36
|
const SYSTEM_MCP_CONFIG_FILE = path.join(SYSTEM_AGENTS_DIR, 'mcp.json');
|
|
38
37
|
const SYSTEM_INSTRUCTIONS_FILE = path.join(SYSTEM_AGENTS_DIR, 'instructions.md');
|
|
39
38
|
const HISTORY_DIR = path.join(USER_AGENTS_DIR, '.history');
|
|
40
39
|
const CACHE_DIR = path.join(USER_AGENTS_DIR, '.cache');
|
|
41
40
|
const ROUTINES_DIR = path.join(USER_AGENTS_DIR, 'routines');
|
|
42
|
-
const WEBHOOKS_DIR = path.join(USER_AGENTS_DIR, 'webhooks');
|
|
43
41
|
const TEAMS_DIR = path.join(USER_AGENTS_DIR, 'teams');
|
|
44
42
|
const PROJECTS_DIR = path.join(USER_AGENTS_DIR, 'projects');
|
|
45
43
|
const DAEMON_CONFIG_DIR = path.join(USER_AGENTS_DIR, 'daemon');
|
|
@@ -244,7 +242,6 @@ export function getUserPermissionsDir() { return process.env.AGENTS_USER_PERMISS
|
|
|
244
242
|
export function getUserSubagentsDir() { return USER_SUBAGENTS_DIR; }
|
|
245
243
|
export function getSystemWorkflowsDir() { return SYSTEM_WORKFLOWS_DIR; }
|
|
246
244
|
export function getUserWorkflowsDir() { return USER_WORKFLOWS_DIR; }
|
|
247
|
-
export function getUserSecretsDir() { return USER_SECRETS_DIR; }
|
|
248
245
|
export function getSecretsDbPath() {
|
|
249
246
|
return process.env.AGENTS_SECRETS_DB ?? path.join(USER_SECRETS_DIR, 'secrets.db');
|
|
250
247
|
}
|
|
@@ -258,25 +255,16 @@ export function getUserPromptcutsPath() { return USER_PROMPTCUTS_FILE; }
|
|
|
258
255
|
export function getHomeDir() { return HOME; }
|
|
259
256
|
export function getHistoryDir() { return HISTORY_DIR; }
|
|
260
257
|
export function getCacheDir() { return CACHE_DIR; }
|
|
261
|
-
export function getPackagesDir() { return PACKAGES_DIR; }
|
|
262
258
|
export function getRoutinesDir() { return process.env.AGENTS_ROUTINES_DIR ?? ROUTINES_DIR; }
|
|
263
259
|
export function getProjectsDir() { return process.env.AGENTS_PROJECTS_DIR ?? PROJECTS_DIR; }
|
|
264
260
|
export function getDaemonConfigDir() { return process.env.AGENTS_DAEMON_CONFIG_DIR ?? DAEMON_CONFIG_DIR; }
|
|
265
|
-
export function getWebhooksDir() { return process.env.AGENTS_WEBHOOKS_DIR ?? WEBHOOKS_DIR; }
|
|
266
261
|
export function getSystemRoutinesDir() { return process.env.AGENTS_SYSTEM_ROUTINES_DIR ?? SYSTEM_ROUTINES_DIR; }
|
|
267
|
-
export function getSystemWebhooksDir() { return process.env.AGENTS_SYSTEM_WEBHOOKS_DIR ?? SYSTEM_WEBHOOKS_DIR; }
|
|
268
262
|
export function getProjectRoutinesDir(cwd = process.cwd()) {
|
|
269
263
|
const projectAgentsDir = getProjectAgentsDir(cwd);
|
|
270
264
|
if (!projectAgentsDir)
|
|
271
265
|
return null;
|
|
272
266
|
return path.join(projectAgentsDir, 'routines');
|
|
273
267
|
}
|
|
274
|
-
export function getProjectWebhooksDir(cwd = process.cwd()) {
|
|
275
|
-
const projectAgentsDir = getProjectAgentsDir(cwd);
|
|
276
|
-
if (!projectAgentsDir)
|
|
277
|
-
return null;
|
|
278
|
-
return path.join(projectAgentsDir, 'webhooks');
|
|
279
|
-
}
|
|
280
268
|
export function getRunsDir() { return RUNS_DIR; }
|
|
281
269
|
export function getMailboxRootDir() { return MAILBOX_DIR; }
|
|
282
270
|
export function getFeedDir() { return FEED_DIR; }
|
|
@@ -321,7 +309,7 @@ export function getDevicesPendingDir() { return path.join(getRuntimeStateDir(),
|
|
|
321
309
|
export function getCloudDir() { return CLOUD_DIR; }
|
|
322
310
|
export function getTerminalsDir() { return TERMINALS_DIR; }
|
|
323
311
|
export function getLogsDir() {
|
|
324
|
-
return process.env.AGENTS_LOGS_DIR
|
|
312
|
+
return process.env.AGENTS_LOGS_DIR || LOGS_DIR;
|
|
325
313
|
}
|
|
326
314
|
export function getPerfDir() {
|
|
327
315
|
return process.env.AGENTS_PERF_DIR ?? PERF_DIR;
|
|
@@ -331,7 +319,6 @@ export function getPerfSpoolPath() { return path.join(getPerfDir(), 'spool.jsonl
|
|
|
331
319
|
export function getRuntimeStateDir() { return process.env.AGENTS_STATE_DIR ?? RUNTIME_STATE_DIR; }
|
|
332
320
|
export function getCompanionDir() { return COMPANION_CACHE_DIR; }
|
|
333
321
|
export function getBrowserRuntimeDir() { return BROWSER_RUNTIME_DIR; }
|
|
334
|
-
export function getBrowserDurableDir() { return path.join(HISTORY_DIR, 'browser-profiles'); }
|
|
335
322
|
export function getHelpersDir() { return HELPERS_DIR; }
|
|
336
323
|
export function getDaemonDir() { return process.env.AGENTS_DAEMON_DIR ?? DAEMON_DIR; }
|
|
337
324
|
export function getTmuxDir() { return TMUX_DIR; }
|
|
@@ -8,3 +8,4 @@ export declare function resolveTeammateDelivery(opts: {
|
|
|
8
8
|
}): TeammateDelivery;
|
|
9
9
|
export declare function deliveryDisplayLabel(delivery: TeammateDelivery, processStatus: AgentStatus | string): string;
|
|
10
10
|
export declare function deliveryColorKey(delivery: TeammateDelivery, processStatus: string): string;
|
|
11
|
+
export declare function statusColor(status: string): (s: string) => string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { AgentStatus } from './agents.js';
|
|
2
3
|
export function resolveTeammateDelivery(opts) {
|
|
3
4
|
const status = String(opts.status);
|
|
@@ -36,3 +37,15 @@ export function deliveryColorKey(delivery, processStatus) {
|
|
|
36
37
|
return 'stranded';
|
|
37
38
|
return String(processStatus);
|
|
38
39
|
}
|
|
40
|
+
export function statusColor(status) {
|
|
41
|
+
switch (status) {
|
|
42
|
+
case 'pending': return chalk.blue;
|
|
43
|
+
case 'running': return chalk.yellow;
|
|
44
|
+
case 'completed': return chalk.green;
|
|
45
|
+
case 'pr_open': return chalk.magenta;
|
|
46
|
+
case 'stranded': return chalk.yellow;
|
|
47
|
+
case 'failed': return chalk.red;
|
|
48
|
+
case 'stopped': return chalk.gray;
|
|
49
|
+
default: return chalk.white;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -255,7 +255,6 @@ export interface RegistryConfig {
|
|
|
255
255
|
apiKey?: string;
|
|
256
256
|
}
|
|
257
257
|
export declare const DEFAULT_REGISTRIES: Record<RegistryType, Record<string, RegistryConfig>>;
|
|
258
|
-
export declare const SEEDED_REGISTRIES: Record<RegistryType, Record<string, RegistryConfig>>;
|
|
259
258
|
export interface McpPackage {
|
|
260
259
|
registry_name: string;
|
|
261
260
|
name: string;
|
|
@@ -291,42 +290,6 @@ export interface McpRegistryResponse {
|
|
|
291
290
|
next_cursor?: string;
|
|
292
291
|
};
|
|
293
292
|
}
|
|
294
|
-
export interface SkillEntry {
|
|
295
|
-
name: string;
|
|
296
|
-
description?: string;
|
|
297
|
-
source: string;
|
|
298
|
-
identifier?: string;
|
|
299
|
-
repo?: string;
|
|
300
|
-
path?: string;
|
|
301
|
-
author?: string;
|
|
302
|
-
installs?: number;
|
|
303
|
-
tags?: string[];
|
|
304
|
-
trustLevel?: string;
|
|
305
|
-
sha256?: string;
|
|
306
|
-
}
|
|
307
|
-
export interface SkillRegistryResponse {
|
|
308
|
-
skills: SkillEntry[];
|
|
309
|
-
metadata?: {
|
|
310
|
-
count: number;
|
|
311
|
-
next_cursor?: string;
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
export interface RegistrySearchResult {
|
|
315
|
-
name: string;
|
|
316
|
-
description?: string;
|
|
317
|
-
type: 'mcp' | 'skill';
|
|
318
|
-
source: string;
|
|
319
|
-
registry: string;
|
|
320
|
-
version?: string;
|
|
321
|
-
installs?: number;
|
|
322
|
-
}
|
|
323
|
-
export interface ResolvedPackage {
|
|
324
|
-
type: 'mcp' | 'skill' | 'git' | 'plugin';
|
|
325
|
-
source: string;
|
|
326
|
-
mcpEntry?: McpServerEntry;
|
|
327
|
-
skillEntry?: SkillEntry;
|
|
328
|
-
pluginSpec?: string;
|
|
329
|
-
}
|
|
330
293
|
export type ResourceType = 'commands' | 'skills' | 'hooks' | 'memory' | 'mcp' | 'permissions' | 'subagents' | 'plugins' | 'workflows';
|
|
331
294
|
export type ResourcePattern = string;
|
|
332
295
|
export interface VersionResources {
|
package/dist/lib/types.js
CHANGED
package/dist/lib/watchdog/log.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
|
-
import * as os from 'os';
|
|
3
2
|
import * as path from 'path';
|
|
4
3
|
import { withFileLock, atomicWriteFileSync, ensureLockTarget } from '../fs-atomic.js';
|
|
5
|
-
|
|
4
|
+
import { getLogsDir } from '../state.js';
|
|
5
|
+
export function watchdogLogPath() {
|
|
6
|
+
return path.join(getLogsDir(), 'watchdog.log');
|
|
7
|
+
}
|
|
6
8
|
const WATCHDOG_EVENT_KINDS = new Set(['tick', 'decision', 'nudge', 'undelivered', 'rotate', 'error']);
|
|
7
9
|
export function parseWatchdogEvents(text) {
|
|
8
10
|
const events = [];
|
|
@@ -55,7 +57,7 @@ export function parseWatchdogEvents(text) {
|
|
|
55
57
|
}
|
|
56
58
|
return events;
|
|
57
59
|
}
|
|
58
|
-
export function readWatchdogEvents(logPath =
|
|
60
|
+
export function readWatchdogEvents(logPath = watchdogLogPath()) {
|
|
59
61
|
if (!fs.existsSync(logPath))
|
|
60
62
|
return [];
|
|
61
63
|
return parseWatchdogEvents(fs.readFileSync(logPath, 'utf8'));
|
|
@@ -90,7 +92,7 @@ export function trimToLast(text, maxLines) {
|
|
|
90
92
|
export function appendWatchdogEvents(events, opts = {}) {
|
|
91
93
|
if (events.length === 0)
|
|
92
94
|
return;
|
|
93
|
-
const logPath = opts.logPath ??
|
|
95
|
+
const logPath = opts.logPath ?? watchdogLogPath();
|
|
94
96
|
const maxLines = opts.maxLines ?? WATCHDOG_LOG_MAX_LINES;
|
|
95
97
|
const lockPath = path.join(path.dirname(logPath), '.watchdog.log.lock');
|
|
96
98
|
try {
|
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.23",
|
|
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",
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"@fontsource/inter": "^5.3.0",
|
|
89
89
|
"@fontsource/jetbrains-mono": "^5.3.0",
|
|
90
90
|
"@inquirer/prompts": "8.5.2",
|
|
91
|
+
"@phnx-labs/secrets-cli": "0.4.0",
|
|
91
92
|
"@phnx-labs/sessions-cli": "0.8.4",
|
|
92
93
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
93
94
|
"@types/proper-lockfile": "4.1.4",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export interface ArtifactAction {
|
|
2
|
-
tool: string;
|
|
3
|
-
label: string;
|
|
4
|
-
matches?: string[];
|
|
5
|
-
input?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
export declare function validateArtifactActions(actions: ArtifactAction[], httpToolNames: Set<string>, applicationTools: Set<string>): string[];
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export function validateArtifactActions(actions, httpToolNames, applicationTools) {
|
|
2
|
-
const errors = [];
|
|
3
|
-
for (let i = 0; i < actions.length; i++) {
|
|
4
|
-
const action = actions[i];
|
|
5
|
-
const prefix = `artifact_actions[${i}]`;
|
|
6
|
-
if (!action.tool) {
|
|
7
|
-
errors.push(`${prefix}: tool is required`);
|
|
8
|
-
}
|
|
9
|
-
else if (!applicationTools.has(action.tool) && !httpToolNames.has(action.tool)) {
|
|
10
|
-
errors.push(`${prefix}: unknown application tool '${action.tool}'`);
|
|
11
|
-
}
|
|
12
|
-
if (!action.label) {
|
|
13
|
-
errors.push(`${prefix}: label is required`);
|
|
14
|
-
}
|
|
15
|
-
if (!action.matches || action.matches.length === 0) {
|
|
16
|
-
errors.push(`${prefix}: matches is required (list of artifact labels/patterns)`);
|
|
17
|
-
}
|
|
18
|
-
if (action.input) {
|
|
19
|
-
for (const [key, tmpl] of Object.entries(action.input)) {
|
|
20
|
-
const err = validateTemplate(tmpl);
|
|
21
|
-
if (err) {
|
|
22
|
-
errors.push(`${prefix}.input.${key}: ${err}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return errors;
|
|
28
|
-
}
|
|
29
|
-
function validateTemplate(tmpl) {
|
|
30
|
-
const re = /\{\{(\w+)\.(\w+)\}\}/g;
|
|
31
|
-
let match;
|
|
32
|
-
while ((match = re.exec(tmpl)) !== null) {
|
|
33
|
-
const prefix = match[1];
|
|
34
|
-
if (prefix !== 'artifact' && prefix !== 'preflight') {
|
|
35
|
-
return `invalid template variable '{{${prefix}.${match[2]}}}', only artifact.* and preflight.* allowed`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function renderSessionsWorkerScript(): string;
|