@phnx-labs/agents-cli 1.23.13 → 1.23.15
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 +47 -0
- package/README.md +30 -59
- package/dist/cli/command-registry.js +0 -24
- package/dist/commands/accounts.js +3 -3
- package/dist/commands/daemon.js +5 -147
- package/dist/commands/doctor.js +7 -0
- package/dist/commands/events-logs.d.ts +2 -0
- package/dist/commands/{logs.js → events-logs.js} +28 -127
- package/dist/commands/events.js +3 -1
- package/dist/commands/exec.d.ts +0 -1
- package/dist/commands/exec.js +3 -11
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +4 -7
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/menubar.js +12 -226
- package/dist/commands/projects.js +1 -2
- package/dist/commands/{trash.d.ts → prune-trash.d.ts} +1 -1
- package/dist/commands/{trash.js → prune-trash.js} +8 -8
- package/dist/commands/prune.js +3 -1
- package/dist/commands/send.js +2 -5
- package/dist/commands/sessions.js +1 -1
- package/dist/commands/ssh.js +2 -2
- package/dist/commands/utils.d.ts +1 -5
- package/dist/commands/utils.js +1 -7
- package/dist/lib/agent-spec/agents.d.ts +0 -2
- package/dist/lib/agent-spec/agents.js +0 -12
- package/dist/lib/agent-spec/index.d.ts +0 -4
- package/dist/lib/agent-spec/index.js +0 -4
- package/dist/lib/commands.d.ts +1 -5
- package/dist/lib/commands.js +2 -69
- package/dist/lib/comms-render.d.ts +0 -7
- package/dist/lib/comms-render.js +0 -41
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +8 -0
- package/dist/lib/daemon/daemon.js +1 -6
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +0 -5
- package/dist/lib/device-config.d.ts +2 -0
- package/dist/lib/device-config.js +81 -8
- package/dist/lib/devices/doctor-findings.d.ts +6 -1
- package/dist/lib/devices/doctor-findings.js +34 -1
- package/dist/lib/git.d.ts +1 -0
- package/dist/lib/git.js +5 -0
- package/dist/lib/hooks/install.d.ts +0 -7
- package/dist/lib/hooks/install.js +0 -55
- package/dist/lib/hosts/passthrough.js +2 -4
- package/dist/lib/hosts/progress.js +2 -2
- package/dist/lib/hosts/remote-cmd.js +0 -1
- package/dist/lib/installations/migrate.d.ts +1 -0
- package/dist/lib/installations/migrate.js +18 -1
- package/dist/lib/installations/versions.js +2 -2
- package/dist/lib/loop.js +1 -1
- package/dist/lib/mailbox-target.d.ts +0 -31
- package/dist/lib/mailbox-target.js +0 -37
- package/dist/lib/mcp-lookup.d.ts +7 -0
- package/dist/lib/mcp-lookup.js +71 -0
- package/dist/lib/mcp.d.ts +0 -8
- package/dist/lib/mcp.js +0 -47
- package/dist/lib/menubar/install-menubar.d.ts +0 -15
- package/dist/lib/menubar/install-menubar.js +24 -118
- package/dist/lib/menubar/resolve-version.d.ts +9 -10
- package/dist/lib/menubar/resolve-version.js +70 -30
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -18
- package/dist/lib/plugins/skills.d.ts +0 -10
- package/dist/lib/plugins/skills.js +2 -165
- package/dist/lib/project-pull.js +1 -2
- package/dist/lib/resources.d.ts +1 -1
- package/dist/lib/routines-project.js +1 -1
- package/dist/lib/session/local-tmux-attach.js +2 -2
- package/dist/lib/startup/command-registry.js +20 -7
- package/dist/lib/teams/agents.js +1 -1
- package/dist/lib/teams/placement-probe.d.ts +9 -0
- package/dist/lib/teams/placement-probe.js +20 -15
- package/dist/lib/triggers/webhook.d.ts +2 -59
- package/dist/lib/triggers/webhook.js +2 -422
- package/package.json +2 -1
- package/dist/commands/funnel.d.ts +0 -2
- package/dist/commands/funnel.js +0 -77
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/mailboxes.d.ts +0 -2
- package/dist/commands/mailboxes.js +0 -400
- package/dist/commands/message.d.ts +0 -2
- package/dist/commands/message.js +0 -259
- package/dist/commands/packages-materialize.d.ts +0 -6
- package/dist/commands/packages-materialize.js +0 -90
- package/dist/commands/packages.d.ts +0 -5
- package/dist/commands/packages.js +0 -763
- package/dist/commands/route.d.ts +0 -2
- package/dist/commands/route.js +0 -259
- package/dist/commands/testdata/feed-hub.d.ts +0 -1
- package/dist/commands/testdata/feed-hub.js +0 -11
- package/dist/commands/tmux.d.ts +0 -7
- package/dist/commands/tmux.js +0 -529
- package/dist/commands/traces.d.ts +0 -2
- package/dist/commands/traces.js +0 -204
- package/dist/commands/webhook.d.ts +0 -5
- package/dist/commands/webhook.js +0 -105
- package/dist/lib/agent-spec/materialize.d.ts +0 -3
- package/dist/lib/agent-spec/materialize.js +0 -277
- package/dist/lib/agent-spec/package-resolve.d.ts +0 -4
- package/dist/lib/agent-spec/package-resolve.js +0 -231
- package/dist/lib/agent-spec/package-schema.d.ts +0 -3
- package/dist/lib/agent-spec/package-schema.js +0 -136
- package/dist/lib/agent-spec/package-types.d.ts +0 -94
- package/dist/lib/agent-spec/package-types.js +0 -10
- package/dist/lib/daemon/testdata/process-view-daemon.d.ts +0 -1
- package/dist/lib/daemon/testdata/process-view-daemon.js +0 -12
- package/dist/lib/daemon/testdata/process-view-start.d.ts +0 -1
- package/dist/lib/daemon/testdata/process-view-start.js +0 -41
- package/dist/lib/daemon/webhook-receiver-service.d.ts +0 -8
- package/dist/lib/daemon/webhook-receiver-service.js +0 -16
- package/dist/lib/daemon-webhooks.d.ts +0 -48
- package/dist/lib/daemon-webhooks.js +0 -177
- package/dist/lib/funnel.d.ts +0 -6
- package/dist/lib/funnel.js +0 -31
- package/dist/lib/net-close.d.ts +0 -2
- package/dist/lib/net-close.js +0 -20
- package/dist/lib/packages/output-home.d.ts +0 -9
- package/dist/lib/packages/output-home.js +0 -89
- package/dist/lib/registry.d.ts +0 -65
- package/dist/lib/registry.js +0 -432
- package/dist/lib/routers.d.ts +0 -25
- package/dist/lib/routers.js +0 -122
- package/dist/lib/run-trace-sync.d.ts +0 -7
- package/dist/lib/run-trace-sync.js +0 -35
- package/dist/lib/session/testdata/pid-registry-namespace.d.ts +0 -1
- package/dist/lib/session/testdata/pid-registry-namespace.js +0 -25
- package/dist/lib/session/testdata/process-view-namespace.d.ts +0 -1
- package/dist/lib/session/testdata/process-view-namespace.js +0 -56
- package/dist/lib/session/testdata/process-view-private.d.ts +0 -1
- package/dist/lib/session/testdata/process-view-private.js +0 -11
- package/dist/lib/testdata/daemon-health-writer.d.ts +0 -1
- package/dist/lib/testdata/daemon-health-writer.js +0 -8
- package/dist/lib/testdata/owner-notify-api.d.ts +0 -23
- package/dist/lib/testdata/owner-notify-api.js +0 -82
- package/dist/lib/testdata/refresh-coordinator-worker.d.ts +0 -1
- package/dist/lib/testdata/refresh-coordinator-worker.js +0 -23
- package/dist/lib/traces/backend.d.ts +0 -8
- package/dist/lib/traces/backend.js +0 -33
- package/dist/lib/traces/classify.d.ts +0 -40
- package/dist/lib/traces/classify.js +0 -70
- package/dist/lib/traces/config.d.ts +0 -2
- package/dist/lib/traces/config.js +0 -2
- package/dist/lib/traces/insights.d.ts +0 -30
- package/dist/lib/traces/insights.js +0 -198
- package/dist/lib/traces/phenotype.d.ts +0 -18
- package/dist/lib/traces/phenotype.js +0 -335
- package/dist/lib/traces/provision.d.ts +0 -16
- package/dist/lib/traces/provision.js +0 -25
- package/dist/lib/traces/schema2-build.d.ts +0 -28
- package/dist/lib/traces/schema2-build.js +0 -496
- package/dist/lib/traces/schema2-danger.d.ts +0 -7
- package/dist/lib/traces/schema2-danger.js +0 -123
- package/dist/lib/traces/schema2.d.ts +0 -139
- package/dist/lib/traces/schema2.js +0 -20
- package/dist/lib/traces/segments.d.ts +0 -73
- package/dist/lib/traces/segments.js +0 -236
- package/dist/lib/traces/sync.d.ts +0 -197
- package/dist/lib/traces/sync.js +0 -654
- package/dist/lib/traces/worker-template.d.ts +0 -1
- package/dist/lib/traces/worker-template.js +0 -292
- package/dist/lib/triggers/handlers.d.ts +0 -66
- package/dist/lib/triggers/handlers.js +0 -383
package/dist/lib/mcp.d.ts
CHANGED
|
@@ -13,10 +13,6 @@ export interface InstalledMcpServer {
|
|
|
13
13
|
config: McpYamlConfig;
|
|
14
14
|
scope?: 'user' | 'project';
|
|
15
15
|
}
|
|
16
|
-
export interface McpCommandSpec {
|
|
17
|
-
command: string;
|
|
18
|
-
args: string[];
|
|
19
|
-
}
|
|
20
16
|
export interface McpTargetOperationResult {
|
|
21
17
|
agentId: AgentId;
|
|
22
18
|
version?: string;
|
|
@@ -44,10 +40,6 @@ export declare function getMcpServersByName(names?: string[], options?: {
|
|
|
44
40
|
enforceProjectTrust?: boolean;
|
|
45
41
|
}): InstalledMcpServer[];
|
|
46
42
|
export declare function buildWorkflowMcpConfig(servers: InstalledMcpServer[]): string;
|
|
47
|
-
export declare function registerMcpCommandToTargets(targets: {
|
|
48
|
-
directAgents: AgentId[];
|
|
49
|
-
versionSelections: Map<AgentId, string[]>;
|
|
50
|
-
}, name: string, commandSpec: McpCommandSpec, scope?: 'user' | 'project', transport?: string): Promise<McpTargetOperationResult[]>;
|
|
51
43
|
export interface WritableMcpServer {
|
|
52
44
|
name: string;
|
|
53
45
|
transport: 'stdio' | 'http' | 'sse';
|
package/dist/lib/mcp.js
CHANGED
|
@@ -3,9 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import * as yaml from 'yaml';
|
|
4
4
|
import * as TOML from 'smol-toml';
|
|
5
5
|
import { execFileSync } from 'child_process';
|
|
6
|
-
import * as os from 'os';
|
|
7
6
|
import { getMcpDir, getUserMcpDir, getProjectAgentsDir, getVersionsDir, getUserAgentsDir } from './state.js';
|
|
8
|
-
import { getBinaryPath, getVersionHomePath } from './installations/versions.js';
|
|
9
7
|
import { IS_WINDOWS, execFileShellSpec } from './platform/index.js';
|
|
10
8
|
import { AGENTS, getMcpConfigPathForHome, getProjectMcpConfigPath, parseMcpConfig, stripJsonComments } from './agents.js';
|
|
11
9
|
import { MCP_TARGETS, mcpWriteUnsupportedReason } from './mcp-registry.js';
|
|
@@ -310,51 +308,6 @@ function installMcpViaCodex(binaryPath, server, versionHome) {
|
|
|
310
308
|
shell: spec.shell,
|
|
311
309
|
});
|
|
312
310
|
}
|
|
313
|
-
export async function registerMcpCommandToTargets(targets, name, commandSpec, scope = 'user', transport = 'stdio') {
|
|
314
|
-
const results = [];
|
|
315
|
-
for (const agentId of targets.directAgents) {
|
|
316
|
-
const result = registerMcpCommand(agentId, name, commandSpec, scope, transport);
|
|
317
|
-
results.push({ agentId, success: result.success, error: result.error });
|
|
318
|
-
}
|
|
319
|
-
for (const [agentId, versions] of targets.versionSelections) {
|
|
320
|
-
for (const version of versions) {
|
|
321
|
-
const result = registerMcpCommand(agentId, name, commandSpec, scope, transport, {
|
|
322
|
-
home: getVersionHomePath(agentId, version),
|
|
323
|
-
binary: getBinaryPath(agentId, version),
|
|
324
|
-
});
|
|
325
|
-
results.push({ agentId, version, success: result.success, error: result.error });
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return results;
|
|
329
|
-
}
|
|
330
|
-
function registerMcpCommand(agentId, name, commandSpec, scope, transport, options = {}) {
|
|
331
|
-
try {
|
|
332
|
-
validateMcpServerName(name);
|
|
333
|
-
if (agentId === 'hermes') {
|
|
334
|
-
const home = options.home || os.homedir();
|
|
335
|
-
writeMcpConfig(agentId, getMcpConfigPathForHome(agentId, home), [{
|
|
336
|
-
name,
|
|
337
|
-
transport: transport === 'http' ? 'http' : 'stdio',
|
|
338
|
-
...(transport === 'http'
|
|
339
|
-
? { url: commandSpec.command }
|
|
340
|
-
: { command: commandSpec.command, args: commandSpec.args }),
|
|
341
|
-
}], 'merge');
|
|
342
|
-
return { success: true };
|
|
343
|
-
}
|
|
344
|
-
const bin = options.binary || AGENTS[agentId].cliCommand;
|
|
345
|
-
const commandArgs = [commandSpec.command, ...commandSpec.args];
|
|
346
|
-
const args = agentId === 'claude'
|
|
347
|
-
? ['mcp', 'add', '--transport', transport, '--scope', scope, '--', name, ...commandArgs]
|
|
348
|
-
: ['mcp', 'add', '--', name, ...commandArgs];
|
|
349
|
-
const env = options.home ? { ...process.env, HOME: options.home } : process.env;
|
|
350
|
-
const spec = execFileShellSpec(bin, args);
|
|
351
|
-
execFileSync(spec.command, spec.args, { stdio: 'pipe', timeout: 30000, env, shell: spec.shell });
|
|
352
|
-
return { success: true };
|
|
353
|
-
}
|
|
354
|
-
catch (err) {
|
|
355
|
-
return { success: false, error: err.message };
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
311
|
function toWritableServer(server) {
|
|
359
312
|
return {
|
|
360
313
|
name: server.config.name,
|
|
@@ -46,9 +46,6 @@ export interface MenubarRestartDeps {
|
|
|
46
46
|
deadlineMs: number;
|
|
47
47
|
}
|
|
48
48
|
export declare function restartMenubarHelper(deps?: MenubarRestartDeps): Promise<MenubarRestartResult>;
|
|
49
|
-
export declare function enableMenubarService(opts?: {
|
|
50
|
-
clearOptOut?: boolean;
|
|
51
|
-
}): Promise<boolean>;
|
|
52
49
|
export declare function stampVersionLabel(stamp: MenubarStamp | null): string | null;
|
|
53
50
|
export declare function stampFor(resolvedSourceAppPath: string): MenubarStamp;
|
|
54
51
|
export declare function releaseVersionOfCachedBundle(appPath: string, cacheDirFor?: (v: string) => string): string | null;
|
|
@@ -99,18 +96,6 @@ export declare function shouldMigrateMenubarTcc(opts: {
|
|
|
99
96
|
export declare function resetMenubarAccessibilityTcc(exec?: (cmd: string, args: readonly string[], opts: {
|
|
100
97
|
stdio: ['ignore', 'ignore', 'ignore'];
|
|
101
98
|
}) => Buffer): void;
|
|
102
|
-
export interface SetupStep {
|
|
103
|
-
name: string;
|
|
104
|
-
outcome: 'ok' | 'changed' | 'failed';
|
|
105
|
-
detail: string;
|
|
106
|
-
}
|
|
107
|
-
export interface SetupResult {
|
|
108
|
-
steps: SetupStep[];
|
|
109
|
-
configured: boolean;
|
|
110
|
-
status: MenubarStatus;
|
|
111
|
-
}
|
|
112
|
-
export declare function processesToEnd(status: Pick<MenubarStatus, 'instances' | 'foreignInstances'>): MenubarProcess[];
|
|
113
|
-
export declare function runMenubarSetup(): Promise<SetupResult>;
|
|
114
99
|
export interface MenubarProcess {
|
|
115
100
|
pid: number;
|
|
116
101
|
executable: string;
|
|
@@ -4,7 +4,8 @@ import * as fs from 'fs';
|
|
|
4
4
|
import * as os from 'os';
|
|
5
5
|
import * as path from 'path';
|
|
6
6
|
import { sleepSync } from '../fs-atomic.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getHelpersDir } from '../state.js';
|
|
8
|
+
import { getConfigValue, setConfigValue } from '../device-config.js';
|
|
8
9
|
import { getCliVersion, resolveAgentsBin, resolveInstalledLayout } from '../version.js';
|
|
9
10
|
import { copyAppBundle, withInstallLock } from '../app-bundle-install.js';
|
|
10
11
|
import { compareVersions } from '../agent-spec/primitives.js';
|
|
@@ -66,11 +67,8 @@ export function resolveInstalledMenubarExecutable() {
|
|
|
66
67
|
function servicePlistPath() {
|
|
67
68
|
return path.join(os.homedir(), 'Library', 'LaunchAgents', `${serviceLabel()}.plist`);
|
|
68
69
|
}
|
|
69
|
-
function disabledSentinelPath() {
|
|
70
|
-
return path.join(getRuntimeStateDir(), 'menubar.disabled');
|
|
71
|
-
}
|
|
72
70
|
function menubarDisabledByUser() {
|
|
73
|
-
return
|
|
71
|
+
return getConfigValue('menubar.enabled').value === false;
|
|
74
72
|
}
|
|
75
73
|
function menubarServiceInstalled() {
|
|
76
74
|
return onDarwin() && fs.existsSync(servicePlistPath());
|
|
@@ -260,10 +258,16 @@ export function restartMenubarLaunchAgent(uid, plist, exec = execFileSync, sleep
|
|
|
260
258
|
bootstrapped = succeeds(['bootstrap', `gui/${uid}`, plist]);
|
|
261
259
|
}
|
|
262
260
|
if (!bootstrapped) {
|
|
263
|
-
process.stderr.write(`[agents] AGI Menu login item could not be registered (launchctl bootstrap gui/${uid} ${plist} failed 3 times);
|
|
261
|
+
process.stderr.write(`[agents] AGI Menu login item could not be registered (launchctl bootstrap gui/${uid} ${plist} failed 3 times); the next agents command retries it\n`);
|
|
264
262
|
}
|
|
265
263
|
succeeds(['kickstart', serviceTarget]);
|
|
266
264
|
}
|
|
265
|
+
function endProcess(pid) {
|
|
266
|
+
try {
|
|
267
|
+
process.kill(pid, 'SIGTERM');
|
|
268
|
+
}
|
|
269
|
+
catch { }
|
|
270
|
+
}
|
|
267
271
|
export function restartMenubarHelperAfterSwap(uid, ownProcesses, exec = execFileSync, kill = endProcess) {
|
|
268
272
|
const reg = serviceManagerRegistrationAllowed();
|
|
269
273
|
if (!reg.allowed)
|
|
@@ -301,7 +305,7 @@ export async function restartMenubarHelper(deps = defaultRestartDeps) {
|
|
|
301
305
|
if (!onDarwin())
|
|
302
306
|
return failed('AGI Menu is macOS only');
|
|
303
307
|
if (menubarDisabledByUser() || !menubarServiceInstalled()) {
|
|
304
|
-
return failed('AGI Menu is turned off; `agents menubar
|
|
308
|
+
return failed('AGI Menu is turned off; `agents config set menubar.enabled true` turns it on');
|
|
305
309
|
}
|
|
306
310
|
const registration = serviceManagerRegistrationAllowed();
|
|
307
311
|
if (!registration.allowed)
|
|
@@ -316,7 +320,7 @@ export async function restartMenubarHelper(deps = defaultRestartDeps) {
|
|
|
316
320
|
let pids = deps.ownPids();
|
|
317
321
|
while (!(pids.length === 1 && !previousPids.includes(pids[0]))) {
|
|
318
322
|
if (Date.now() >= deadline) {
|
|
319
|
-
return failed(`AGI Menu did not come back as one new process within ${Math.round(deps.deadlineMs / 1000)} s
|
|
323
|
+
return failed(`AGI Menu did not come back as one new process within ${Math.round(deps.deadlineMs / 1000)} s`, previousPids, pids);
|
|
320
324
|
}
|
|
321
325
|
await deps.sleep(200);
|
|
322
326
|
pids = deps.ownPids();
|
|
@@ -334,28 +338,12 @@ function startMenubarServiceFromSource(opts = {}) {
|
|
|
334
338
|
return false;
|
|
335
339
|
if (!(codesignVerifies(installedAppPath()) && gatekeeperAssesses(installedAppPath()))) {
|
|
336
340
|
process.stderr.write('agents: AGI Menu is not notarized/valid on this machine; skipping launch. ' +
|
|
337
|
-
'Upgrade to a notarized build (npm i -g @phnx-labs/agents-cli)
|
|
341
|
+
'Upgrade to a notarized build (npm i -g @phnx-labs/agents-cli); the next agents command installs it.\n');
|
|
338
342
|
return false;
|
|
339
343
|
}
|
|
340
|
-
if (opts.clearOptOut)
|
|
341
|
-
clearMenubarOptOut();
|
|
342
344
|
installAndStartService(exec, stampFor(src));
|
|
343
345
|
return true;
|
|
344
346
|
}
|
|
345
|
-
export async function enableMenubarService(opts = { clearOptOut: true }) {
|
|
346
|
-
if (!onDarwin())
|
|
347
|
-
return false;
|
|
348
|
-
let src = shippedAppPath();
|
|
349
|
-
if (!src)
|
|
350
|
-
src = await downloadMenubarHelperApp(await menubarVersionToInstall());
|
|
351
|
-
return startMenubarServiceFromSource({ ...opts, sourceAppPath: src });
|
|
352
|
-
}
|
|
353
|
-
function clearMenubarOptOut() {
|
|
354
|
-
try {
|
|
355
|
-
fs.rmSync(disabledSentinelPath(), { force: true });
|
|
356
|
-
}
|
|
357
|
-
catch { }
|
|
358
|
-
}
|
|
359
347
|
function installAndStartService(exec, stamp) {
|
|
360
348
|
const plist = servicePlistPath();
|
|
361
349
|
fs.mkdirSync(path.dirname(plist), { recursive: true });
|
|
@@ -494,6 +482,10 @@ function plistRelaunchesCleanExit() {
|
|
|
494
482
|
}
|
|
495
483
|
}
|
|
496
484
|
export function disableMenubarService() {
|
|
485
|
+
setConfigValue('menubar.enabled', false);
|
|
486
|
+
stopMenubarService();
|
|
487
|
+
}
|
|
488
|
+
function stopMenubarService() {
|
|
497
489
|
if (!onDarwin())
|
|
498
490
|
return;
|
|
499
491
|
const plist = servicePlistPath();
|
|
@@ -517,11 +509,6 @@ export function disableMenubarService() {
|
|
|
517
509
|
fs.unlinkSync(plist);
|
|
518
510
|
}
|
|
519
511
|
catch { }
|
|
520
|
-
try {
|
|
521
|
-
fs.mkdirSync(path.dirname(disabledSentinelPath()), { recursive: true });
|
|
522
|
-
fs.writeFileSync(disabledSentinelPath(), `disabled ${new Date().toISOString()}\n`);
|
|
523
|
-
}
|
|
524
|
-
catch { }
|
|
525
512
|
}
|
|
526
513
|
export function mayInstallMenubarHelper(opts) {
|
|
527
514
|
if (opts.helperExecMissing || opts.needsDevIdHeal)
|
|
@@ -593,8 +580,11 @@ export function installMenubarLaunchAgentOnUpgrade() {
|
|
|
593
580
|
try {
|
|
594
581
|
if (!onDarwin())
|
|
595
582
|
return;
|
|
596
|
-
if (menubarDisabledByUser())
|
|
583
|
+
if (menubarDisabledByUser()) {
|
|
584
|
+
if (menubarServiceInstalled())
|
|
585
|
+
stopMenubarService();
|
|
597
586
|
return;
|
|
587
|
+
}
|
|
598
588
|
if (menubarServiceInstalled() && fs.existsSync(installedExecutablePath()) && hasDeveloperIdSignature(installedAppPath())) {
|
|
599
589
|
if (menubarSetupNeedsRepoint() && mayHealMenubar(false, installedAppPath())) {
|
|
600
590
|
const stamp = readInstalledMenubarStamp();
|
|
@@ -608,7 +598,7 @@ export function installMenubarLaunchAgentOnUpgrade() {
|
|
|
608
598
|
if (!sourceAppPath())
|
|
609
599
|
return;
|
|
610
600
|
if (!menubarServiceInstalled()) {
|
|
611
|
-
startMenubarServiceFromSource(
|
|
601
|
+
startMenubarServiceFromSource();
|
|
612
602
|
return;
|
|
613
603
|
}
|
|
614
604
|
const needsDevIdHeal = installedNeedsDevIdHeal();
|
|
@@ -617,7 +607,7 @@ export function installMenubarLaunchAgentOnUpgrade() {
|
|
|
617
607
|
return;
|
|
618
608
|
if (!mayHealMenubar(needsDevIdHeal))
|
|
619
609
|
return;
|
|
620
|
-
if (startMenubarServiceFromSource(
|
|
610
|
+
if (startMenubarServiceFromSource()) {
|
|
621
611
|
stampMenubarHeal();
|
|
622
612
|
if (shouldMigrateMenubarTcc({ needsDevIdHeal, alreadyMigrated: menubarTccAlreadyMigrated() })) {
|
|
623
613
|
resetMenubarAccessibilityTcc();
|
|
@@ -658,90 +648,6 @@ export function resetMenubarAccessibilityTcc(exec = execFileSync) {
|
|
|
658
648
|
}
|
|
659
649
|
catch { }
|
|
660
650
|
}
|
|
661
|
-
export function processesToEnd(status) {
|
|
662
|
-
return [...status.instances, ...status.foreignInstances];
|
|
663
|
-
}
|
|
664
|
-
function endProcess(pid) {
|
|
665
|
-
try {
|
|
666
|
-
process.kill(pid, 'SIGTERM');
|
|
667
|
-
}
|
|
668
|
-
catch { }
|
|
669
|
-
}
|
|
670
|
-
export async function runMenubarSetup() {
|
|
671
|
-
const steps = [];
|
|
672
|
-
const step = (name, outcome, detail) => {
|
|
673
|
-
steps.push({ name, outcome, detail });
|
|
674
|
-
};
|
|
675
|
-
if (!onDarwin()) {
|
|
676
|
-
step('platform', 'failed', `AGI Menu is macOS only (this is ${process.platform})`);
|
|
677
|
-
return { steps, configured: false, status: getMenubarStatus() };
|
|
678
|
-
}
|
|
679
|
-
const before = getMenubarStatus();
|
|
680
|
-
let src = shippedAppPath();
|
|
681
|
-
if (!src) {
|
|
682
|
-
try {
|
|
683
|
-
src = await downloadMenubarHelperApp(await menubarVersionToInstall({ force: true }));
|
|
684
|
-
}
|
|
685
|
-
catch (e) {
|
|
686
|
-
step('bundle', 'failed', `no AGI Menu bundle ships with this install, and the release-asset download failed: ${e.message}`);
|
|
687
|
-
return { steps, configured: false, status: before };
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
const doomed = processesToEnd(before);
|
|
691
|
-
for (const p of doomed)
|
|
692
|
-
endProcess(p.pid);
|
|
693
|
-
if (doomed.length > 1) {
|
|
694
|
-
step('duplicates', 'changed', `ended ${doomed.length} running helpers (${doomed.map((p) => p.pid).join(', ')}) — launchd restarts exactly one`);
|
|
695
|
-
}
|
|
696
|
-
else if (doomed.length === 1) {
|
|
697
|
-
step('duplicates', 'ok', 'one helper was running; restarting it under launchd');
|
|
698
|
-
}
|
|
699
|
-
else {
|
|
700
|
-
step('duplicates', 'ok', 'no helper was running');
|
|
701
|
-
}
|
|
702
|
-
const exec = ensureMenubarAppInstalled({ forceReinstall: true, sourceAppPath: src });
|
|
703
|
-
if (!exec) {
|
|
704
|
-
step('bundle', 'failed', 'could not install the helper bundle');
|
|
705
|
-
return { steps, configured: false, status: getMenubarStatus() };
|
|
706
|
-
}
|
|
707
|
-
const bundleStamp = readInstalledMenubarStamp();
|
|
708
|
-
const bundleUnchanged = bundleStamp !== null &&
|
|
709
|
-
!isMenubarStale({ installed: bundleStamp, available: availableStamp(), execExists: true });
|
|
710
|
-
step('bundle', bundleUnchanged ? 'ok' : 'changed', `${installedAppPath()} (${stampVersionLabel(bundleStamp) ?? 'unknown'})`);
|
|
711
|
-
if (!(codesignVerifies(installedAppPath()) && gatekeeperAssesses(installedAppPath()))) {
|
|
712
|
-
step('signature', 'failed', 'not notarized/valid on this machine — refusing to start it (Gatekeeper rejects an ' +
|
|
713
|
-
'un-notarized helper as "damaged"). Upgrade to a notarized build of agents-cli.');
|
|
714
|
-
return { steps, configured: false, status: getMenubarStatus() };
|
|
715
|
-
}
|
|
716
|
-
step('signature', 'ok', 'valid + notarized');
|
|
717
|
-
clearMenubarOptOut();
|
|
718
|
-
installAndStartService(exec, stampFor(src ?? undefined));
|
|
719
|
-
step('login item', before.serviceInstalled ? 'ok' : 'changed', `${serviceLabel()} — starts at login, restarts if it dies`);
|
|
720
|
-
const after = waitForSingleInstance();
|
|
721
|
-
if (after.instances.length === 1 && after.foreignInstances.length === 0) {
|
|
722
|
-
step('single instance', 'ok', `pid ${after.instances[0].pid}`);
|
|
723
|
-
}
|
|
724
|
-
else if (after.instances.length === 0) {
|
|
725
|
-
step('single instance', 'failed', 'the helper did not come back up — see `agents menubar status`');
|
|
726
|
-
}
|
|
727
|
-
else {
|
|
728
|
-
const extra = [...after.instances.slice(1), ...after.foreignInstances];
|
|
729
|
-
step('single instance', 'failed', `${after.instances.length + after.foreignInstances.length} helpers running (${extra.map((p) => p.pid).join(', ')} are extra)`);
|
|
730
|
-
}
|
|
731
|
-
return {
|
|
732
|
-
steps,
|
|
733
|
-
configured: steps.every((s) => s.outcome !== 'failed'),
|
|
734
|
-
status: after,
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
function waitForSingleInstance() {
|
|
738
|
-
let status = getMenubarStatus();
|
|
739
|
-
for (let i = 0; i < 15 && status.instances.length !== 1; i++) {
|
|
740
|
-
sleepSync(200);
|
|
741
|
-
status = getMenubarStatus();
|
|
742
|
-
}
|
|
743
|
-
return status;
|
|
744
|
-
}
|
|
745
651
|
function parsePsLines(psOutput) {
|
|
746
652
|
const out = new Map();
|
|
747
653
|
for (const line of psOutput.split('\n')) {
|
|
@@ -866,7 +772,7 @@ export function menubarUpdateSkipReason(opts) {
|
|
|
866
772
|
if (!opts.darwin)
|
|
867
773
|
return 'macOS only';
|
|
868
774
|
if (opts.disabledByUser)
|
|
869
|
-
return 'the menu bar is disabled (
|
|
775
|
+
return 'the menu bar is disabled (menubar.enabled is false)';
|
|
870
776
|
if (!opts.serviceInstalled)
|
|
871
777
|
return 'the menu bar is not installed on this Mac';
|
|
872
778
|
if (opts.shipped)
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
export interface ReleaseCandidate {
|
|
2
|
-
tagName: string;
|
|
3
|
-
assets: string[];
|
|
4
|
-
draft?: boolean;
|
|
5
|
-
prerelease?: boolean;
|
|
6
|
-
}
|
|
7
1
|
interface MenubarResolveCache {
|
|
8
2
|
checkedAt: number;
|
|
9
3
|
version: string;
|
|
10
4
|
}
|
|
11
|
-
export declare
|
|
5
|
+
export declare const MENUBAR_LS_REFS_REQUEST: string;
|
|
6
|
+
export declare function parseLsRefsTags(body: Buffer): string[];
|
|
7
|
+
export declare function pickNewestMenubarVersion(tags: string[], floor: string, hasPublishedAssets: (version: string) => Promise<boolean>): Promise<string>;
|
|
12
8
|
export declare function readMenubarResolveCache(file: string): MenubarResolveCache | null;
|
|
13
9
|
export declare function cachedMenubarVersion(opts?: {
|
|
14
10
|
floor?: string;
|
|
15
11
|
cacheFile?: string;
|
|
16
12
|
}): string;
|
|
17
|
-
type FetchLike = (input: string, init
|
|
18
|
-
|
|
13
|
+
type FetchLike = (input: string, init: {
|
|
14
|
+
method: 'GET' | 'HEAD' | 'POST';
|
|
15
|
+
headers: Record<string, string>;
|
|
16
|
+
body?: string;
|
|
17
|
+
redirect?: 'manual';
|
|
19
18
|
signal?: AbortSignal;
|
|
20
19
|
}) => Promise<{
|
|
21
20
|
ok: boolean;
|
|
22
21
|
status: number;
|
|
23
|
-
|
|
22
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
24
23
|
}>;
|
|
25
24
|
export declare function resolveMenubarVersion(opts?: {
|
|
26
25
|
floor?: string;
|
|
@@ -2,26 +2,53 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { getCacheDir } from '../state.js';
|
|
4
4
|
import { compareVersions } from '../agent-spec/primitives.js';
|
|
5
|
+
import { HELPER_RELEASE_REPO } from '../helper-download.js';
|
|
5
6
|
import { helperFloor } from '../helper-versions.js';
|
|
6
7
|
import { getCliVersion } from '../version.js';
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
8
|
+
import { menubarHelperAssetUrls } from './download-menubar.js';
|
|
9
|
+
const MENUBAR_UPLOAD_PACK = `https://github.com/${HELPER_RELEASE_REPO}.git/git-upload-pack`;
|
|
10
|
+
const MENUBAR_TAG_REF_PREFIX = 'refs/tags/menubar/';
|
|
9
11
|
const MENUBAR_RESOLVE_TTL_MS = 12 * 60 * 60 * 1000;
|
|
10
12
|
const TAG = /^menubar\/v(\d+\.\d+\.\d+)$/;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
function pktLine(payload) {
|
|
14
|
+
return (Buffer.byteLength(payload) + 4).toString(16).padStart(4, '0') + payload;
|
|
15
|
+
}
|
|
16
|
+
export const MENUBAR_LS_REFS_REQUEST = `${pktLine('command=ls-refs\n')}0001${pktLine(`ref-prefix ${MENUBAR_TAG_REF_PREFIX}\n`)}0000`;
|
|
17
|
+
export function parseLsRefsTags(body) {
|
|
18
|
+
const tags = [];
|
|
19
|
+
let at = 0;
|
|
20
|
+
while (at < body.length) {
|
|
21
|
+
const head = body.subarray(at, at + 4).toString('ascii');
|
|
22
|
+
const len = /^[0-9a-f]{4}$/.test(head) ? Number.parseInt(head, 16) : -1;
|
|
23
|
+
if (len < 0 || len === 3 || at + Math.max(len, 4) > body.length) {
|
|
24
|
+
throw new Error('tag list: malformed git protocol response');
|
|
25
|
+
}
|
|
26
|
+
if (len === 0)
|
|
27
|
+
return tags;
|
|
28
|
+
if (len < 4) {
|
|
29
|
+
at += 4;
|
|
20
30
|
continue;
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
}
|
|
32
|
+
const line = body.subarray(at + 4, at + len).toString('utf8').trimEnd();
|
|
33
|
+
if (line.startsWith('ERR '))
|
|
34
|
+
throw new Error(`tag list: ${line.slice(4)}`);
|
|
35
|
+
const ref = line.split(' ')[1] ?? '';
|
|
36
|
+
if (ref.startsWith('refs/tags/'))
|
|
37
|
+
tags.push(ref.slice('refs/tags/'.length));
|
|
38
|
+
at += len;
|
|
23
39
|
}
|
|
24
|
-
|
|
40
|
+
throw new Error('tag list: git protocol response ended without a flush packet');
|
|
41
|
+
}
|
|
42
|
+
export async function pickNewestMenubarVersion(tags, floor, hasPublishedAssets) {
|
|
43
|
+
const newer = tags
|
|
44
|
+
.map((t) => TAG.exec(t)?.[1])
|
|
45
|
+
.filter((v) => v !== undefined && compareVersions(v, floor) > 0)
|
|
46
|
+
.sort((a, b) => compareVersions(b, a));
|
|
47
|
+
for (const version of new Set(newer)) {
|
|
48
|
+
if (await hasPublishedAssets(version))
|
|
49
|
+
return version;
|
|
50
|
+
}
|
|
51
|
+
return floor;
|
|
25
52
|
}
|
|
26
53
|
function menubarResolveCachePath() {
|
|
27
54
|
return path.join(getCacheDir(), 'menubar', 'latest.json');
|
|
@@ -50,38 +77,51 @@ export function cachedMenubarVersion(opts = {}) {
|
|
|
50
77
|
const cache = readMenubarResolveCache(opts.cacheFile ?? menubarResolveCachePath());
|
|
51
78
|
return cache && compareVersions(cache.version, floor) >= 0 ? cache.version : floor;
|
|
52
79
|
}
|
|
53
|
-
|
|
54
|
-
|
|
80
|
+
function userAgent() {
|
|
81
|
+
return { 'User-Agent': `agents-cli/${getCliVersion()}` };
|
|
82
|
+
}
|
|
83
|
+
async function fetchMenubarTags(fetchImpl) {
|
|
84
|
+
const res = await fetchImpl(MENUBAR_UPLOAD_PACK, {
|
|
85
|
+
method: 'POST',
|
|
55
86
|
headers: {
|
|
56
|
-
|
|
57
|
-
'
|
|
58
|
-
'
|
|
87
|
+
...userAgent(),
|
|
88
|
+
'Git-Protocol': 'version=2',
|
|
89
|
+
'Content-Type': 'application/x-git-upload-pack-request',
|
|
90
|
+
Accept: 'application/x-git-upload-pack-result',
|
|
59
91
|
},
|
|
92
|
+
body: MENUBAR_LS_REFS_REQUEST,
|
|
60
93
|
signal: AbortSignal.timeout(5_000),
|
|
61
94
|
});
|
|
62
95
|
if (!res.ok)
|
|
63
|
-
throw new Error(`
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
96
|
+
throw new Error(`tag list: HTTP ${res.status}`);
|
|
97
|
+
return parseLsRefsTags(Buffer.from(await res.arrayBuffer()));
|
|
98
|
+
}
|
|
99
|
+
async function assetPublished(fetchImpl, url) {
|
|
100
|
+
const res = await fetchImpl(url, { method: 'HEAD', headers: userAgent(), redirect: 'manual', signal: AbortSignal.timeout(5_000) });
|
|
101
|
+
if (res.status === 404)
|
|
102
|
+
return false;
|
|
103
|
+
if (res.ok || (res.status >= 300 && res.status < 400))
|
|
104
|
+
return true;
|
|
105
|
+
throw new Error(`release asset check: HTTP ${res.status}`);
|
|
106
|
+
}
|
|
107
|
+
async function menubarAssetsPublished(fetchImpl, version) {
|
|
108
|
+
const { zip, sha256 } = menubarHelperAssetUrls(version);
|
|
109
|
+
const [hasZip, hasSha] = await Promise.all([assetPublished(fetchImpl, zip), assetPublished(fetchImpl, sha256)]);
|
|
110
|
+
return hasZip && hasSha;
|
|
73
111
|
}
|
|
74
112
|
export async function resolveMenubarVersion(opts = {}) {
|
|
75
113
|
const floor = opts.floor ?? helperFloor('menubar');
|
|
76
114
|
const file = opts.cacheFile ?? menubarResolveCachePath();
|
|
77
115
|
const now = opts.now ?? Date.now();
|
|
78
116
|
const ttl = opts.ttlMs ?? MENUBAR_RESOLVE_TTL_MS;
|
|
117
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
79
118
|
const cached = readMenubarResolveCache(file);
|
|
80
119
|
if (cached && !opts.force && now - cached.checkedAt < ttl && compareVersions(cached.version, floor) >= 0) {
|
|
81
120
|
return cached.version;
|
|
82
121
|
}
|
|
83
122
|
try {
|
|
84
|
-
const
|
|
123
|
+
const tags = await fetchMenubarTags(fetchImpl);
|
|
124
|
+
const version = await pickNewestMenubarVersion(tags, floor, (v) => menubarAssetsPublished(fetchImpl, v));
|
|
85
125
|
writeMenubarResolveCache(file, { checkedAt: now, version });
|
|
86
126
|
return version;
|
|
87
127
|
}
|
package/dist/lib/paths.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function realpathExistingPrefix(target: string): string;
|
|
2
1
|
export declare function isSafeSegmentName(name: string): boolean;
|
|
3
2
|
export declare function safeJoin(base: string, name: string): string;
|
|
4
3
|
export declare function assertWithin(root: string, target: string): string;
|
package/dist/lib/paths.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
1
|
import * as path from 'path';
|
|
3
|
-
export function realpathExistingPrefix(target) {
|
|
4
|
-
let current = path.resolve(target);
|
|
5
|
-
const tail = [];
|
|
6
|
-
for (;;) {
|
|
7
|
-
try {
|
|
8
|
-
const real = fs.realpathSync(current);
|
|
9
|
-
return tail.length ? path.join(real, ...tail.reverse()) : real;
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
const parent = path.dirname(current);
|
|
13
|
-
if (parent === current)
|
|
14
|
-
return path.resolve(target);
|
|
15
|
-
tail.push(path.basename(current));
|
|
16
|
-
current = parent;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
2
|
export function isSafeSegmentName(name) {
|
|
21
3
|
return (!!name &&
|
|
22
4
|
name !== '.' && name !== '..' &&
|
|
@@ -33,13 +33,7 @@ export interface DiscoveredSkill {
|
|
|
33
33
|
source?: string;
|
|
34
34
|
}
|
|
35
35
|
export declare function discoverSkillsFromRepo(repoPath: string): DiscoveredSkill[];
|
|
36
|
-
export declare function installSkill(sourcePath: string, skillName: string, agents: AgentId[], method?: 'symlink' | 'copy'): {
|
|
37
|
-
success: boolean;
|
|
38
|
-
error?: string;
|
|
39
|
-
warnings?: string[];
|
|
40
|
-
};
|
|
41
36
|
export declare function skillExists(agentId: AgentId, skillName: string): boolean;
|
|
42
|
-
export declare function skillContentMatches(agentId: AgentId, skillName: string, sourcePath: string): boolean;
|
|
43
37
|
export declare function listCentralSkills(): string[];
|
|
44
38
|
export declare function resolveSkillSourcePath(skillName: string): string | null;
|
|
45
39
|
export declare function listAllSkills(): string[];
|
|
@@ -54,10 +48,6 @@ export interface VersionSkillDiff {
|
|
|
54
48
|
orphans: string[];
|
|
55
49
|
}
|
|
56
50
|
export declare function diffVersionSkills(agent: AgentId, version: string): VersionSkillDiff;
|
|
57
|
-
export declare function installSkillToVersion(agent: AgentId, version: string, skillName: string, method?: 'symlink' | 'copy'): {
|
|
58
|
-
success: boolean;
|
|
59
|
-
error?: string;
|
|
60
|
-
};
|
|
61
51
|
export declare function removeSkillFromVersion(agent: AgentId, version: string, skillName: string): {
|
|
62
52
|
success: boolean;
|
|
63
53
|
error?: string;
|