@phnx-labs/agents-cli 1.22.42 → 1.22.43
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 +72 -0
- package/README.md +1 -1
- package/dist/bin/agents +0 -0
- package/dist/bootstrap.js +25 -7
- package/dist/cli/command-registry.d.ts +0 -3
- package/dist/cli/command-registry.js +0 -8
- package/dist/commands/alias.d.ts +7 -4
- package/dist/commands/alias.js +33 -8
- package/dist/commands/auth.js +7 -3
- package/dist/commands/computer.js +20 -6
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/doctor.d.ts +4 -2
- package/dist/commands/doctor.js +20 -5
- package/dist/commands/exec.js +3 -2
- package/dist/commands/feed.js +1 -30
- package/dist/commands/harness.js +3 -3
- package/dist/commands/monitors.js +1 -1
- package/dist/commands/org.js +9 -8
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/routines.js +43 -25
- package/dist/commands/sessions-picker.js +124 -122
- package/dist/commands/setup.js +5 -1
- package/dist/commands/snapshot.d.ts +1 -1
- package/dist/commands/snapshot.js +4 -4
- package/dist/commands/status.d.ts +4 -2
- package/dist/commands/status.js +10 -7
- package/dist/commands/sync.d.ts +1 -0
- package/dist/commands/sync.js +29 -2
- package/dist/commands/view.js +6 -0
- package/dist/commands/webhook.js +1 -1
- package/dist/lib/accounting/rotate.d.ts +5 -3
- package/dist/lib/accounting/rotate.js +36 -7
- package/dist/lib/accounting/usage.d.ts +18 -4
- package/dist/lib/accounting/usage.js +138 -27
- package/dist/lib/agent-spec/agents.d.ts +7 -7
- package/dist/lib/agent-spec/agents.js +15 -15
- package/dist/lib/cloud/rush.d.ts +0 -15
- package/dist/lib/cloud/rush.js +0 -35
- package/dist/lib/crabbox/runtimes.d.ts +6 -2
- package/dist/lib/crabbox/runtimes.js +21 -5
- package/dist/lib/daemon/daemon.js +86 -58
- package/dist/lib/daemon/runner.d.ts +18 -1
- package/dist/lib/daemon/runner.js +105 -11
- package/dist/lib/devices/doctor-findings.js +1 -1
- package/dist/lib/devices/health-report.js +1 -1
- package/dist/lib/drift-sync.d.ts +1 -1
- package/dist/lib/drift-sync.js +2 -2
- package/dist/lib/drift.d.ts +1 -1
- package/dist/lib/exec.js +13 -3
- package/dist/lib/format.d.ts +9 -0
- package/dist/lib/format.js +16 -0
- package/dist/lib/github/pr-mergeable.d.ts +49 -0
- package/dist/lib/github/pr-mergeable.js +157 -0
- package/dist/lib/github/pr-verdict.d.ts +67 -0
- package/dist/lib/github/pr-verdict.js +72 -0
- package/dist/lib/harness/adapter.d.ts +6 -5
- package/dist/lib/hosts/passthrough.d.ts +10 -0
- package/dist/lib/hosts/passthrough.js +28 -6
- package/dist/lib/hosts/session-index.js +1 -1
- package/dist/lib/installations/shims.js +1 -1
- package/dist/lib/installations/versions.d.ts +40 -0
- package/dist/lib/installations/versions.js +57 -2
- package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
- package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
- package/dist/lib/menubar/install-menubar.js +19 -8
- package/dist/lib/monitors/config.d.ts +2 -2
- package/dist/lib/monitors/config.js +3 -2
- package/dist/lib/origin-machine.d.ts +18 -0
- package/dist/lib/origin-machine.js +34 -0
- package/dist/lib/perf/db.js +1 -1
- package/dist/lib/perf/spool.js +1 -1
- package/dist/lib/profiles.d.ts +7 -0
- package/dist/lib/profiles.js +26 -1
- package/dist/lib/sandbox.d.ts +24 -0
- package/dist/lib/sandbox.js +101 -0
- package/dist/lib/scheduling/routines.d.ts +18 -9
- package/dist/lib/scheduling/routines.js +16 -8
- package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
- package/dist/lib/secrets/agent.js +9 -1
- package/dist/lib/secrets/index.js +1 -1
- package/dist/lib/secrets/list-filter.js +1 -1
- package/dist/lib/service-manifest.d.ts +20 -0
- package/dist/lib/service-manifest.js +34 -0
- package/dist/lib/session/cloud.js +1 -1
- package/dist/lib/session/db.js +1 -1
- package/dist/lib/session/fork.js +1 -1
- package/dist/lib/session/live-metadata.js +1 -1
- package/dist/lib/session/origin-machine.d.ts +1 -18
- package/dist/lib/session/origin-machine.js +4 -34
- package/dist/lib/session/relative-time.d.ts +1 -44
- package/dist/lib/session/relative-time.js +4 -120
- package/dist/lib/session/remote-list.js +1 -1
- package/dist/lib/session/remote.js +2 -2
- package/dist/lib/session/short-id.d.ts +1 -17
- package/dist/lib/session/short-id.js +4 -20
- package/dist/lib/session/width.d.ts +1 -29
- package/dist/lib/session/width.js +4 -101
- package/dist/lib/snapshot.d.ts +2 -2
- package/dist/lib/snapshot.js +1 -1
- package/dist/lib/startup/command-registry.d.ts +4 -1
- package/dist/lib/startup/command-registry.js +11 -4
- package/dist/lib/teams/placement-probe.js +1 -1
- package/dist/lib/teams/scheduler.js +1 -1
- package/dist/lib/text/relative-time.d.ts +44 -0
- package/dist/lib/text/relative-time.js +120 -0
- package/dist/lib/text/short-id.d.ts +17 -0
- package/dist/lib/text/short-id.js +20 -0
- package/dist/lib/text/width.d.ts +29 -0
- package/dist/lib/text/width.js +101 -0
- package/dist/lib/triggers/handlers.d.ts +7 -0
- package/dist/lib/triggers/handlers.js +8 -0
- package/dist/lib/triggers/webhook.d.ts +1 -0
- package/dist/lib/triggers/webhook.js +2 -1
- package/dist/lib/view-types.d.ts +4 -0
- package/package.json +1 -1
- package/dist/commands/tickets.d.ts +0 -2
- package/dist/commands/tickets.js +0 -43
- package/dist/lib/observe-aliases.d.ts +0 -30
- package/dist/lib/observe-aliases.js +0 -38
- package/dist/lib/tickets/list.d.ts +0 -53
- package/dist/lib/tickets/list.js +0 -153
|
@@ -32,9 +32,9 @@ import { VERSION_RE, compareVersions } from '../agent-spec/primitives.js';
|
|
|
32
32
|
import { AGENTS, agentConfigDirName, getAccountEmail, resolveAgentName, formatAgentError, findInPath, isSelfUpdatingAgent, isAgentHardDeprecated, hardDeprecationError } from '../agents.js';
|
|
33
33
|
import { discoverPermissionGroups, getActivePermissionPresetName, readPermissionPresetRecipe, PERMISSION_PRESET_ENV_VAR } from '../permissions.js';
|
|
34
34
|
import { parseMcpConfigForScan, isProjectMcpTrusted } from '../mcp.js';
|
|
35
|
-
import { createVersionedAlias, removeVersionedAlias, getConfigSymlinkVersion, ensureClaudeInsideSymlink, assertIsolationBoundary, } from './shims.js';
|
|
35
|
+
import { createVersionedAlias, removeVersionedAlias, switchConfigSymlink, getConfigSymlinkVersion, ensureClaudeInsideSymlink, assertIsolationBoundary, isIsolationProtected, } from './shims.js';
|
|
36
36
|
import { importInstallScriptBinary } from '../import.js';
|
|
37
|
-
import { createInstallation, getBinaryPath, getCliVersionFromPath, getGlobalDefault, getIsolatedDefault, getLiveVersion, getVersionDir, getVersionHomePath, invalidateInstalledVersionsCache, invalidateLiveVersionCache, isGlobalBinaryAgent, isVersionInstalled, isVersionIsolated, listInstalledVersions, pickCanonicalGlobalBinaryVersion, } from './store.js';
|
|
37
|
+
import { createInstallation, getBinaryPath, getCliVersionFromPath, getGlobalDefault, getIsolatedDefault, getLiveVersion, getVersionDir, getVersionHomePath, invalidateInstalledVersionsCache, invalidateLiveVersionCache, isGlobalBinaryAgent, isVersionInstalled, isVersionIsolated, listInstalledVersions, pickCanonicalGlobalBinaryVersion, resolveVersion, } from './store.js';
|
|
38
38
|
export * from './store.js';
|
|
39
39
|
import { INSTALLATION_RECORD_FILE } from './types.js';
|
|
40
40
|
import { composeWin32CommandLine } from '../platform/index.js';
|
|
@@ -1745,6 +1745,61 @@ export function removeAllVersions(agent) {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
return removed;
|
|
1747
1747
|
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Repoint an agent's version pointers — the global/isolated default and the
|
|
1750
|
+
* `~/.<agent>` config symlink — off any version that is no longer installed, so
|
|
1751
|
+
* neither `agents sync`/`agents run` resolution nor the conventional-path home
|
|
1752
|
+
* can land on a dead version (RUSH-2471).
|
|
1753
|
+
*
|
|
1754
|
+
* How a pointer goes dangling: {@link removeVersion} reassigns the defaults and
|
|
1755
|
+
* clears the config symlink only when IT removes the pointed-at version. A
|
|
1756
|
+
* version-home whose launch binary disappears by any other route — grok
|
|
1757
|
+
* self-updated its per-version binary out from under the old dir, a manual
|
|
1758
|
+
* delete, a half-finished install that seeded the home but never landed the
|
|
1759
|
+
* binary — leaves the default and/or the symlink pointing at something
|
|
1760
|
+
* {@link isVersionInstalled} reports as gone.
|
|
1761
|
+
*
|
|
1762
|
+
* Called from the sync resolve path so the invariant self-heals. Mirrors
|
|
1763
|
+
* {@link removeVersion}'s reassignment: the global default prefers the newest
|
|
1764
|
+
* NON-isolated survivor else clears; the isolated default prefers the newest
|
|
1765
|
+
* remaining isolated copy else clears. The symlink is repointed at the now-healed
|
|
1766
|
+
* resolved default, else the newest installed non-isolated version. A symlink
|
|
1767
|
+
* already on an installed version, a real (non-symlink) config dir, and an
|
|
1768
|
+
* isolated-only agent are left untouched.
|
|
1769
|
+
*/
|
|
1770
|
+
export async function healDanglingVersionPointers(agent, cwd) {
|
|
1771
|
+
const healed = {};
|
|
1772
|
+
const installed = listInstalledVersions(agent);
|
|
1773
|
+
const globalDefault = getGlobalDefault(agent);
|
|
1774
|
+
if (globalDefault !== null && !isVersionInstalled(agent, globalDefault)) {
|
|
1775
|
+
const promotable = installed.filter((v) => !isVersionIsolated(agent, v));
|
|
1776
|
+
const to = promotable.length > 0 ? promotable[promotable.length - 1] : undefined;
|
|
1777
|
+
setGlobalDefault(agent, to);
|
|
1778
|
+
healed.globalDefault = { from: globalDefault, to: to ?? null };
|
|
1779
|
+
}
|
|
1780
|
+
const isolatedDefault = getIsolatedDefault(agent);
|
|
1781
|
+
if (isolatedDefault !== null && !isVersionInstalled(agent, isolatedDefault)) {
|
|
1782
|
+
const survivors = installed.filter((v) => isVersionIsolated(agent, v));
|
|
1783
|
+
const to = survivors.length > 0 ? survivors[survivors.length - 1] : undefined;
|
|
1784
|
+
setIsolatedDefault(agent, to);
|
|
1785
|
+
healed.isolatedDefault = { from: isolatedDefault, to: to ?? null };
|
|
1786
|
+
}
|
|
1787
|
+
const current = getConfigSymlinkVersion(agent);
|
|
1788
|
+
const nonIsolated = installed.filter((v) => !isVersionIsolated(agent, v));
|
|
1789
|
+
if (current !== null &&
|
|
1790
|
+
!isVersionInstalled(agent, current) &&
|
|
1791
|
+
!isIsolationProtected(agent) &&
|
|
1792
|
+
nonIsolated.length > 0) {
|
|
1793
|
+
const pinned = resolveVersion(agent, cwd);
|
|
1794
|
+
const target = pinned && isVersionInstalled(agent, pinned) && !isVersionIsolated(agent, pinned)
|
|
1795
|
+
? pinned
|
|
1796
|
+
: nonIsolated[nonIsolated.length - 1];
|
|
1797
|
+
const result = await switchConfigSymlink(agent, target);
|
|
1798
|
+
if (result.success)
|
|
1799
|
+
healed.configSymlink = { from: current, to: target };
|
|
1800
|
+
}
|
|
1801
|
+
return healed;
|
|
1802
|
+
}
|
|
1748
1803
|
/**
|
|
1749
1804
|
* Normalize a user-supplied @version token across CLI subcommands.
|
|
1750
1805
|
*
|
|
Binary file
|
|
Binary file
|
|
@@ -24,7 +24,7 @@ import { getRuntimeStateDir, getHelpersDir } from '../state.js';
|
|
|
24
24
|
import { getCliVersion, resolveAgentsBin, resolveInstalledLayout } from '../version.js';
|
|
25
25
|
import { copyAppBundle, withInstallLock } from '../app-bundle-install.js';
|
|
26
26
|
import { compareVersions } from '../agent-spec/primitives.js';
|
|
27
|
-
import { namespacedServiceLabel, serviceManifestHomeEnv } from '../service-manifest.js';
|
|
27
|
+
import { namespacedServiceLabel, serviceManifestHomeEnv, serviceManagerRegistrationAllowed } from '../service-manifest.js';
|
|
28
28
|
const APP_BUNDLE_NAME = 'MenubarHelper.app';
|
|
29
29
|
const INSTALL_DIR_NAME = 'agents-cli';
|
|
30
30
|
const SERVICE_LABEL_BASE = 'com.phnx-labs.agents-menubar';
|
|
@@ -333,6 +333,11 @@ ${envXml}
|
|
|
333
333
|
* is the only sequence that reliably re-attaches the status item.
|
|
334
334
|
*/
|
|
335
335
|
export function restartMenubarLaunchAgent(uid, plist, exec = execFileSync) {
|
|
336
|
+
const reg = serviceManagerRegistrationAllowed();
|
|
337
|
+
if (!reg.allowed) {
|
|
338
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
336
341
|
const serviceTarget = `gui/${uid}/${serviceLabel()}`;
|
|
337
342
|
const opts = { stdio: ['ignore', 'ignore', 'ignore'] };
|
|
338
343
|
try {
|
|
@@ -467,15 +472,21 @@ export function disableMenubarService() {
|
|
|
467
472
|
if (!onDarwin())
|
|
468
473
|
return;
|
|
469
474
|
const plist = servicePlistPath();
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
catch {
|
|
475
|
+
const reg = serviceManagerRegistrationAllowed();
|
|
476
|
+
if (reg.allowed) {
|
|
477
|
+
const uid = process.getuid?.() ?? 0;
|
|
475
478
|
try {
|
|
476
|
-
execFileSync('launchctl', ['
|
|
479
|
+
execFileSync('launchctl', ['bootout', `gui/${uid}/${serviceLabel()}`], { stdio: ['ignore', 'ignore', 'ignore'] });
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
try {
|
|
483
|
+
execFileSync('launchctl', ['unload', '-w', plist], { stdio: ['ignore', 'ignore', 'ignore'] });
|
|
484
|
+
}
|
|
485
|
+
catch { /* not loaded */ }
|
|
477
486
|
}
|
|
478
|
-
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
479
490
|
}
|
|
480
491
|
try {
|
|
481
492
|
fs.unlinkSync(plist);
|
|
@@ -68,8 +68,8 @@ export type MonitorActionType = 'run' | 'routine' | 'notify' | 'webhook-out';
|
|
|
68
68
|
*/
|
|
69
69
|
export interface ActionConfig {
|
|
70
70
|
type: MonitorActionType;
|
|
71
|
-
/** run: which agent to spawn. */
|
|
72
|
-
agent?: AgentId;
|
|
71
|
+
/** run: which agent to spawn — a native harness id or a custom harness name (agents harness list). */
|
|
72
|
+
agent?: AgentId | (string & {});
|
|
73
73
|
/** run: the prompt; `{event}` is replaced with the fired event summary. */
|
|
74
74
|
prompt?: string;
|
|
75
75
|
/** run: execution mode (shared with routines). */
|
|
@@ -17,6 +17,7 @@ import { safeJoin, isSafeSegmentName } from '../paths.js';
|
|
|
17
17
|
import { atomicWriteFileSync } from '../fs-atomic.js';
|
|
18
18
|
import { machineId, normalizeHost } from '../machine-id.js';
|
|
19
19
|
import { ALL_AGENT_IDS } from '../agents.js';
|
|
20
|
+
import { isCustomHarnessName } from '../profiles.js';
|
|
20
21
|
/** Default values applied to every monitor config when fields are omitted. */
|
|
21
22
|
const MONITOR_DEFAULTS = {
|
|
22
23
|
enabled: true,
|
|
@@ -215,8 +216,8 @@ export function validateMonitor(config) {
|
|
|
215
216
|
errors.push(`action has conflicting fields (${populatedAct.join(', ')}); specify exactly one action`);
|
|
216
217
|
}
|
|
217
218
|
if (action.type === 'run') {
|
|
218
|
-
if (action.agent && !ALL_AGENT_IDS.includes(action.agent)) {
|
|
219
|
-
errors.push(`action.agent must be one of: ${ALL_AGENT_IDS.join(', ')}`);
|
|
219
|
+
if (action.agent && !ALL_AGENT_IDS.includes(action.agent) && !isCustomHarnessName(action.agent)) {
|
|
220
|
+
errors.push(`action.agent must be one of: ${ALL_AGENT_IDS.join(', ')}, or a custom harness (agents harness list)`);
|
|
220
221
|
}
|
|
221
222
|
if (!action.prompt || typeof action.prompt !== 'string') {
|
|
222
223
|
errors.push("action.type 'run' requires action.prompt");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve which machine a session transcript originated on.
|
|
3
|
+
*
|
|
4
|
+
* Cross-machine sync mirrors a remote transcript to
|
|
5
|
+
* `backups/<agent>/<machine>/<subdir>/…`. Every other transcript is a live-home
|
|
6
|
+
* file on this box, so the origin is the local machine id.
|
|
7
|
+
*
|
|
8
|
+
* Kept in a leaf module (no session/db imports) so both discovery and the
|
|
9
|
+
* sessions DB upsert path can stamp `machine` without circular deps.
|
|
10
|
+
*/
|
|
11
|
+
/** Local machine id, cached for the process lifetime. */
|
|
12
|
+
export declare function localMachineId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* The machine a discovered session originated on.
|
|
15
|
+
* When the path sits under the agent's backups root, the first segment below it
|
|
16
|
+
* is the origin machine id; otherwise it's the local machine.
|
|
17
|
+
*/
|
|
18
|
+
export declare function machineForSessionFile(filePath: string, agent: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve which machine a session transcript originated on.
|
|
3
|
+
*
|
|
4
|
+
* Cross-machine sync mirrors a remote transcript to
|
|
5
|
+
* `backups/<agent>/<machine>/<subdir>/…`. Every other transcript is a live-home
|
|
6
|
+
* file on this box, so the origin is the local machine id.
|
|
7
|
+
*
|
|
8
|
+
* Kept in a leaf module (no session/db imports) so both discovery and the
|
|
9
|
+
* sessions DB upsert path can stamp `machine` without circular deps.
|
|
10
|
+
*/
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import { getHistoryDir } from './state.js';
|
|
13
|
+
import { machineId } from './machine-id.js';
|
|
14
|
+
let _localMachineId;
|
|
15
|
+
/** Local machine id, cached for the process lifetime. */
|
|
16
|
+
export function localMachineId() {
|
|
17
|
+
return (_localMachineId ??= machineId());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The machine a discovered session originated on.
|
|
21
|
+
* When the path sits under the agent's backups root, the first segment below it
|
|
22
|
+
* is the origin machine id; otherwise it's the local machine.
|
|
23
|
+
*/
|
|
24
|
+
export function machineForSessionFile(filePath, agent) {
|
|
25
|
+
if (!filePath)
|
|
26
|
+
return localMachineId();
|
|
27
|
+
const base = path.join(getHistoryDir(), 'backups', agent) + path.sep;
|
|
28
|
+
if (filePath.startsWith(base)) {
|
|
29
|
+
const seg = filePath.slice(base.length).split(path.sep)[0];
|
|
30
|
+
if (seg)
|
|
31
|
+
return seg;
|
|
32
|
+
}
|
|
33
|
+
return localMachineId();
|
|
34
|
+
}
|
package/dist/lib/perf/db.js
CHANGED
|
@@ -8,7 +8,7 @@ import * as fs from 'fs';
|
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import Database from '../sqlite.js';
|
|
10
10
|
import { getPerfDbPath, getPerfDir } from '../state.js';
|
|
11
|
-
import { localMachineId } from '../
|
|
11
|
+
import { localMachineId } from '../origin-machine.js';
|
|
12
12
|
import { resolveProjectKey } from '../project-key.js';
|
|
13
13
|
import { percentile } from '../percentile.js';
|
|
14
14
|
import { resolveSpoolPath, shortSessionId, _resetPerfSpoolForTest } from './spool.js';
|
package/dist/lib/perf/spool.js
CHANGED
|
@@ -9,7 +9,7 @@ import * as fs from 'fs';
|
|
|
9
9
|
import * as os from 'os';
|
|
10
10
|
import * as path from 'path';
|
|
11
11
|
import { getPerfSpoolPath } from '../state.js';
|
|
12
|
-
import { localMachineId } from '../
|
|
12
|
+
import { localMachineId } from '../origin-machine.js';
|
|
13
13
|
let _spoolOverride = null;
|
|
14
14
|
let _disabled = false;
|
|
15
15
|
/** Test seam — pair with db._resetPerfDbForTest. */
|
package/dist/lib/profiles.d.ts
CHANGED
|
@@ -96,6 +96,13 @@ export declare function getProfilePath(name: string): string;
|
|
|
96
96
|
export declare function validateProfileName(name: string): void;
|
|
97
97
|
/** Check whether a profile YAML file exists on disk. */
|
|
98
98
|
export declare function profileExists(name: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* True when `name` is a custom harness (a profile that is not shadowing a
|
|
101
|
+
* native agent id) — the predicate routines/monitors use to accept an
|
|
102
|
+
* `agent:` value that `agents run` will resolve as a profile. A native id
|
|
103
|
+
* always reads as native, matching exec's resolution order.
|
|
104
|
+
*/
|
|
105
|
+
export declare function isCustomHarnessName(name: string): boolean;
|
|
99
106
|
/** Read and parse a profile from disk. Throws if not found or malformed. */
|
|
100
107
|
export declare function readProfile(name: string): Profile;
|
|
101
108
|
/** Write a profile to disk atomically (write-to-tmp then rename). */
|
package/dist/lib/profiles.js
CHANGED
|
@@ -9,6 +9,7 @@ import * as fs from 'fs';
|
|
|
9
9
|
import * as path from 'path';
|
|
10
10
|
import * as crypto from 'node:crypto';
|
|
11
11
|
import * as yaml from 'yaml';
|
|
12
|
+
import { ALL_AGENT_IDS } from './agents.js';
|
|
12
13
|
import { getUserAgentsDir } from './state.js';
|
|
13
14
|
import { deleteKeychainToken, getKeychainToken, hasKeychainToken, keychainItemName } from './secrets/profiles.js';
|
|
14
15
|
import { getPreset } from './profiles-presets.js';
|
|
@@ -39,6 +40,17 @@ export function validateProfileName(name) {
|
|
|
39
40
|
export function profileExists(name) {
|
|
40
41
|
return fs.existsSync(profilePath(name));
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* True when `name` is a custom harness (a profile that is not shadowing a
|
|
45
|
+
* native agent id) — the predicate routines/monitors use to accept an
|
|
46
|
+
* `agent:` value that `agents run` will resolve as a profile. A native id
|
|
47
|
+
* always reads as native, matching exec's resolution order.
|
|
48
|
+
*/
|
|
49
|
+
export function isCustomHarnessName(name) {
|
|
50
|
+
if (!PROFILE_NAME_PATTERN.test(name))
|
|
51
|
+
return false;
|
|
52
|
+
return !ALL_AGENT_IDS.includes(name) && profileExists(name);
|
|
53
|
+
}
|
|
42
54
|
/** Read and parse a profile from disk. Throws if not found or malformed. */
|
|
43
55
|
export function readProfile(name) {
|
|
44
56
|
validateProfileName(name);
|
|
@@ -77,7 +89,11 @@ function migrateLegacyProfileAuth(profile, file) {
|
|
|
77
89
|
}
|
|
78
90
|
const migratedAccount = findAccount(accountName);
|
|
79
91
|
const oldItem = profile.auth.keychainItem;
|
|
80
|
-
|
|
92
|
+
// Reference by NAME, not id: profiles sync fleet-wide with `agents repo push`
|
|
93
|
+
// while account ids are minted per-device, so an id ref breaks on every other
|
|
94
|
+
// machine ("Unknown account '<uuid>'"). Names are the portable handle — the
|
|
95
|
+
// registry resolves both, and `accounts rename` already rewrites name refs.
|
|
96
|
+
profile.account = migratedAccount.name;
|
|
81
97
|
profile.provider = provider;
|
|
82
98
|
delete profile.auth;
|
|
83
99
|
delete profile.authOptional;
|
|
@@ -477,6 +493,15 @@ export function renameProfile(oldName, newName) {
|
|
|
477
493
|
export function resolveProfileEnv(profile) {
|
|
478
494
|
const env = { ...profile.env };
|
|
479
495
|
if (profile.account) {
|
|
496
|
+
if (!findAccount(profile.account)) {
|
|
497
|
+
// The commonest cause: the profile synced here via `agents repo push/pull`
|
|
498
|
+
// but its account ref was minted on another device (legacy id refs), so
|
|
499
|
+
// the bare "Unknown account" from the registry gives the user nothing to
|
|
500
|
+
// act on. Name the harness and the repair.
|
|
501
|
+
throw new Error(`Harness '${profile.name}' references account '${profile.account}', which does not exist on this device. ` +
|
|
502
|
+
`Accounts are per-machine; pick one from 'agents accounts list' and repoint with ` +
|
|
503
|
+
`'agents harness edit ${profile.name} --account <name>', or add it with 'agents accounts add'.`);
|
|
504
|
+
}
|
|
480
505
|
const account = resolveCredentialAccount(profile.account, profile.host.agent, profile.provider);
|
|
481
506
|
Object.assign(env, account.env);
|
|
482
507
|
}
|
package/dist/lib/sandbox.d.ts
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
* access to explicitly allowed paths.
|
|
8
8
|
*/
|
|
9
9
|
import type { JobConfig } from './scheduling/routines.js';
|
|
10
|
+
/**
|
|
11
|
+
* Absolute path to this host's `gh` config directory (`hosts.yml` + `config.yml`),
|
|
12
|
+
* or null when the host has never run `gh auth login`. Prefer `GH_CONFIG_DIR` when
|
|
13
|
+
* the parent already pinned one; otherwise `$XDG_CONFIG_HOME/gh` or `~/.config/gh`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveHostGhConfigDir(): string | null;
|
|
16
|
+
/** True when this host holds usable GitHub CLI auth (hosts.yml or a token env). */
|
|
17
|
+
export declare function hostHasGhAuth(): boolean;
|
|
10
18
|
/** Build a restricted environment for a sandboxed process, setting HOME to the overlay. */
|
|
11
19
|
export declare function buildSpawnEnv(overlayHome: string, extraEnv?: Record<string, string>): Record<string, string>;
|
|
12
20
|
/**
|
|
@@ -21,6 +29,22 @@ export declare function buildSpawnEnv(overlayHome: string, extraEnv?: Record<str
|
|
|
21
29
|
export declare function getJobHomePath(name: string): string;
|
|
22
30
|
/** Create a fresh overlay HOME for a job, including agent config and allowed-dir symlinks. */
|
|
23
31
|
export declare function prepareJobHome(config: JobConfig): string;
|
|
32
|
+
/**
|
|
33
|
+
* Link this host's `gh` config directory into the disposable overlay so
|
|
34
|
+
* `$HOME/.config/gh` resolves even when `GH_CONFIG_DIR` is unset. Mirrors
|
|
35
|
+
* `generateCursorConfig`: same-host credentials, never copied to another box.
|
|
36
|
+
*/
|
|
37
|
+
export declare function linkHostGhConfig(overlayHome: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Refuse to launch a sandboxed child when THIS host holds GitHub auth but the
|
|
40
|
+
* spawn env would hide it. The RUSH-2860 failure mode was silent: the monitor
|
|
41
|
+
* fire recorded `ok` (spawn succeeded) while every `gh` call inside the child
|
|
42
|
+
* failed. Prefer forwarding (buildSpawnEnv / linkHostGhConfig); this assert is
|
|
43
|
+
* the regression tripwire — if forwarding ever regresses, fail loud at spawn
|
|
44
|
+
* instead of recording a hollow success. No-ops when the host has no gh auth
|
|
45
|
+
* (jobs that do not need GitHub still run).
|
|
46
|
+
*/
|
|
47
|
+
export declare function assertSandboxForwardsHostGhAuth(spawnEnv: Record<string, string>): void;
|
|
24
48
|
/** Link this host's Cursor login and CLI config into the disposable overlay. */
|
|
25
49
|
export declare function generateCursorConfig(overlayHome: string): void;
|
|
26
50
|
/** Remove a job's overlay HOME directory entirely. */
|
package/dist/lib/sandbox.js
CHANGED
|
@@ -43,6 +43,14 @@ const ENV_ALLOWLIST = [
|
|
|
43
43
|
'VISUAL',
|
|
44
44
|
'NO_COLOR',
|
|
45
45
|
'FORCE_COLOR',
|
|
46
|
+
// GitHub CLI — same host credentials interactive `agents run` already sees.
|
|
47
|
+
// Without these, a sandboxed monitor `--run` child has no gh auth even when
|
|
48
|
+
// the daemon user is logged in (RUSH-2860).
|
|
49
|
+
'GH_TOKEN',
|
|
50
|
+
'GH_HOST',
|
|
51
|
+
'GH_ENTERPRISE_TOKEN',
|
|
52
|
+
'GITHUB_TOKEN',
|
|
53
|
+
'GH_CONFIG_DIR',
|
|
46
54
|
];
|
|
47
55
|
/** Tools safe to grant as wildcards (no filesystem access). */
|
|
48
56
|
const SAFE_TOOLS = {
|
|
@@ -57,6 +65,32 @@ function tomlString(value) {
|
|
|
57
65
|
}
|
|
58
66
|
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
59
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Absolute path to this host's `gh` config directory (`hosts.yml` + `config.yml`),
|
|
70
|
+
* or null when the host has never run `gh auth login`. Prefer `GH_CONFIG_DIR` when
|
|
71
|
+
* the parent already pinned one; otherwise `$XDG_CONFIG_HOME/gh` or `~/.config/gh`.
|
|
72
|
+
*/
|
|
73
|
+
export function resolveHostGhConfigDir() {
|
|
74
|
+
// Honor an explicit pin only when it actually exists; otherwise fall through
|
|
75
|
+
// to the default locations so a stale/broken GH_CONFIG_DIR cannot hide a
|
|
76
|
+
// healthy ~/.config/gh (RUSH-2860).
|
|
77
|
+
if (process.env.GH_CONFIG_DIR && fs.existsSync(process.env.GH_CONFIG_DIR)) {
|
|
78
|
+
return process.env.GH_CONFIG_DIR;
|
|
79
|
+
}
|
|
80
|
+
const configHome = process.env.XDG_CONFIG_HOME || path.join(resolveRealHome(), '.config');
|
|
81
|
+
const ghDir = path.join(configHome, 'gh');
|
|
82
|
+
return fs.existsSync(ghDir) ? ghDir : null;
|
|
83
|
+
}
|
|
84
|
+
/** True when this host holds usable GitHub CLI auth (hosts.yml or a token env). */
|
|
85
|
+
export function hostHasGhAuth() {
|
|
86
|
+
if (process.env.GH_TOKEN || process.env.GH_ENTERPRISE_TOKEN || process.env.GITHUB_TOKEN) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const dir = resolveHostGhConfigDir();
|
|
90
|
+
if (!dir)
|
|
91
|
+
return false;
|
|
92
|
+
return fs.existsSync(path.join(dir, 'hosts.yml'));
|
|
93
|
+
}
|
|
60
94
|
/** Build a restricted environment for a sandboxed process, setting HOME to the overlay. */
|
|
61
95
|
export function buildSpawnEnv(overlayHome, extraEnv) {
|
|
62
96
|
const env = {
|
|
@@ -68,6 +102,18 @@ export function buildSpawnEnv(overlayHome, extraEnv) {
|
|
|
68
102
|
env[key] = process.env[key];
|
|
69
103
|
}
|
|
70
104
|
}
|
|
105
|
+
// Pin GH_CONFIG_DIR at the REAL host config so `gh` does not look under the
|
|
106
|
+
// disposable overlay HOME (which has no hosts.yml). Same posture as linking
|
|
107
|
+
// Cursor's auth.json — forward the credentials the daemon user already holds
|
|
108
|
+
// (RUSH-2860). Always prefer resolveHostGhConfigDir over a stale allowlisted
|
|
109
|
+
// value; an explicit extraEnv GH_CONFIG_DIR still wins below.
|
|
110
|
+
const hostGh = resolveHostGhConfigDir();
|
|
111
|
+
if (hostGh) {
|
|
112
|
+
env.GH_CONFIG_DIR = hostGh;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
delete env.GH_CONFIG_DIR;
|
|
116
|
+
}
|
|
71
117
|
if (extraEnv) {
|
|
72
118
|
Object.assign(env, extraEnv);
|
|
73
119
|
}
|
|
@@ -101,11 +147,66 @@ export function prepareJobHome(config) {
|
|
|
101
147
|
else if (config.agent === 'cursor') {
|
|
102
148
|
generateCursorConfig(overlayHome);
|
|
103
149
|
}
|
|
150
|
+
// Host tool credentials / setup the overlay HOME would otherwise hide.
|
|
151
|
+
// Cursor already links its own auth above; gh is harness-agnostic and needed
|
|
152
|
+
// by every sandboxed `--run` that shells out to `gh` (RUSH-2860 — monitor
|
|
153
|
+
// merge agents saw "not logged into any GitHub hosts" while the daemon user
|
|
154
|
+
// was fine).
|
|
155
|
+
//
|
|
156
|
+
// Deliberately NOT linking the real ~/.agents here. It would put the secrets
|
|
157
|
+
// master key (.secrets-key) and the encrypted store (.cache/secrets) together
|
|
158
|
+
// at a predictable path inside the overlay, through a writable symlink, in a
|
|
159
|
+
// child whose prompt can carry untrusted text from a watched source. The
|
|
160
|
+
// separate "agents-cli is not set up" defect (state.ts ignores AGENTS_USER_DIR)
|
|
161
|
+
// gets its own scoped change: RUSH-2954.
|
|
162
|
+
linkHostGhConfig(overlayHome);
|
|
104
163
|
if (config.allow?.dirs) {
|
|
105
164
|
symlinkAllowedDirs(overlayHome, config.allow.dirs);
|
|
106
165
|
}
|
|
107
166
|
return overlayHome;
|
|
108
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Link this host's `gh` config directory into the disposable overlay so
|
|
170
|
+
* `$HOME/.config/gh` resolves even when `GH_CONFIG_DIR` is unset. Mirrors
|
|
171
|
+
* `generateCursorConfig`: same-host credentials, never copied to another box.
|
|
172
|
+
*/
|
|
173
|
+
export function linkHostGhConfig(overlayHome) {
|
|
174
|
+
const realGhDir = resolveHostGhConfigDir();
|
|
175
|
+
if (!realGhDir || !fs.existsSync(realGhDir))
|
|
176
|
+
return;
|
|
177
|
+
const overlayGhDir = path.join(overlayHome, '.config', 'gh');
|
|
178
|
+
if (fs.existsSync(overlayGhDir))
|
|
179
|
+
return;
|
|
180
|
+
fs.mkdirSync(path.dirname(overlayGhDir), { recursive: true });
|
|
181
|
+
try {
|
|
182
|
+
createLink(realGhDir, overlayGhDir);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
/* cross-volume or link creation refused: GH_CONFIG_DIR in buildSpawnEnv is the backup */
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Refuse to launch a sandboxed child when THIS host holds GitHub auth but the
|
|
190
|
+
* spawn env would hide it. The RUSH-2860 failure mode was silent: the monitor
|
|
191
|
+
* fire recorded `ok` (spawn succeeded) while every `gh` call inside the child
|
|
192
|
+
* failed. Prefer forwarding (buildSpawnEnv / linkHostGhConfig); this assert is
|
|
193
|
+
* the regression tripwire — if forwarding ever regresses, fail loud at spawn
|
|
194
|
+
* instead of recording a hollow success. No-ops when the host has no gh auth
|
|
195
|
+
* (jobs that do not need GitHub still run).
|
|
196
|
+
*/
|
|
197
|
+
export function assertSandboxForwardsHostGhAuth(spawnEnv) {
|
|
198
|
+
if (!hostHasGhAuth())
|
|
199
|
+
return;
|
|
200
|
+
if (spawnEnv.GH_TOKEN || spawnEnv.GH_ENTERPRISE_TOKEN || spawnEnv.GITHUB_TOKEN)
|
|
201
|
+
return;
|
|
202
|
+
if (spawnEnv.GH_CONFIG_DIR && fs.existsSync(path.join(spawnEnv.GH_CONFIG_DIR, 'hosts.yml')))
|
|
203
|
+
return;
|
|
204
|
+
if (spawnEnv.HOME && fs.existsSync(path.join(spawnEnv.HOME, '.config', 'gh', 'hosts.yml')))
|
|
205
|
+
return;
|
|
206
|
+
throw new Error("sandbox spawn would hide this host's GitHub auth from the child " +
|
|
207
|
+
'(no GH_CONFIG_DIR / ~/.config/gh / GH_TOKEN). Refusing to launch — ' +
|
|
208
|
+
'the agent would record ok then fail every gh call (RUSH-2860).');
|
|
209
|
+
}
|
|
109
210
|
/** Link this host's Cursor login and CLI config into the disposable overlay. */
|
|
110
211
|
export function generateCursorConfig(overlayHome) {
|
|
111
212
|
const realConfigHome = process.env.XDG_CONFIG_HOME || path.join(resolveRealHome(), '.config');
|
|
@@ -107,8 +107,14 @@ export interface JobConfig {
|
|
|
107
107
|
schedule?: string;
|
|
108
108
|
/** Event/webhook fire condition. Optional when `schedule` is set. */
|
|
109
109
|
trigger?: JobTrigger;
|
|
110
|
-
/**
|
|
111
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Which agent runs the routine — a native harness id, or the name of a
|
|
112
|
+
* custom harness (`agents harness list`), which the runner delegates to
|
|
113
|
+
* `agents run <name>` the same way workflow jobs are. Optional — omitted
|
|
114
|
+
* for `workflow`/`command` routines. Exactly one of agent/workflow/command
|
|
115
|
+
* must be set.
|
|
116
|
+
*/
|
|
117
|
+
agent?: AgentId | (string & {});
|
|
112
118
|
workflow?: string;
|
|
113
119
|
/**
|
|
114
120
|
* A plain shell command run directly instead of an agent/workflow — no LLM,
|
|
@@ -298,16 +304,16 @@ export interface JobConfig {
|
|
|
298
304
|
* `lib/monitors/config.ts`) — re-gating here was double-gating on the wrong
|
|
299
305
|
* key.
|
|
300
306
|
*
|
|
301
|
-
* Deliberately narrow: a monitor's `routine` action fires a
|
|
302
|
-
* keeps its activation gate, so a routine defined but not
|
|
303
|
-
* device is still refused.
|
|
307
|
+
* Deliberately narrow: a monitor's or webhook handler's `routine` action fires a
|
|
308
|
+
* REAL routine, which keeps its activation gate, so a routine defined but not
|
|
309
|
+
* activated on this device is still refused.
|
|
304
310
|
*
|
|
305
311
|
* Runtime-only, enforced at both ends of the schema boundary: `writeJob`
|
|
306
312
|
* strips it, and `readJobFileResult` refuses a definition that carries it
|
|
307
313
|
* (a hand-authored one would otherwise fire on every box regardless of
|
|
308
314
|
* activation, since the daemon's load path never calls `validateJob`).
|
|
309
315
|
*/
|
|
310
|
-
dispatchedBy?: 'monitor';
|
|
316
|
+
dispatchedBy?: 'monitor' | 'webhook';
|
|
311
317
|
}
|
|
312
318
|
/**
|
|
313
319
|
* Canonical form of a routine's `projects` field: drop non-string and empty
|
|
@@ -399,7 +405,7 @@ export declare function resolveJobExecutionContext(config: Pick<JobConfig, 'name
|
|
|
399
405
|
export interface RunMeta {
|
|
400
406
|
jobName: string;
|
|
401
407
|
runId: string;
|
|
402
|
-
agent?: AgentId;
|
|
408
|
+
agent?: AgentId | (string & {});
|
|
403
409
|
/**
|
|
404
410
|
* Resolved agent version this run launched under. Re-pointed to each failover
|
|
405
411
|
* attempt's version as the single-shot chain advances (runner.ts), so it names
|
|
@@ -504,10 +510,13 @@ export declare function finalizeRunMeta(meta: RunMeta, status: RunMeta['status']
|
|
|
504
510
|
* `yosemite-s0` all agree. Every fire path (cron scheduler, webhook,
|
|
505
511
|
* catchup/overdue, manual run) gates on this.
|
|
506
512
|
*
|
|
507
|
-
* A monitor-dispatched job ({@link JobConfig.dispatchedBy}
|
|
513
|
+
* A monitor- or webhook-dispatched job ({@link JobConfig.dispatchedBy} set) skips
|
|
508
514
|
* the routine activation manifest: it is not a routine, so its name can never be
|
|
509
515
|
* a member and the lookup could only ever answer "not activated here"
|
|
510
|
-
* (RUSH-2681
|
|
516
|
+
* (RUSH-2681 for monitors; the same hole broke every `run.agent`/`run.workflow`
|
|
517
|
+
* webhook handler, which the receiver logged as `fired` while the run record read
|
|
518
|
+
* `skipped` with an empty allowlist). Ownership was already decided upstream — by
|
|
519
|
+
* the monitor's `device:` pin, or by the one box the webhook was delivered to.
|
|
511
520
|
*/
|
|
512
521
|
export declare function jobRunsOnThisDevice(config: Pick<JobConfig, 'name' | 'devices' | 'dispatchedBy'>): boolean;
|
|
513
522
|
/**
|
|
@@ -14,6 +14,7 @@ import { getRoutinesDir, getSystemRoutinesDir, getRunsDir, ensureAgentsDir, getP
|
|
|
14
14
|
import * as os from 'os';
|
|
15
15
|
import { safeJoin, isSafeSegmentName } from '../paths.js';
|
|
16
16
|
import { isSafeProjectName, loadProjectDef, projectBasePath } from '../projects.js';
|
|
17
|
+
import { isCustomHarnessName } from '../profiles.js';
|
|
17
18
|
import { resolveRoutineExecutionContext, } from '../routine-context.js';
|
|
18
19
|
import { atomicWriteFileSync } from '../fs-atomic.js';
|
|
19
20
|
import { ALL_AGENT_IDS, ROUTINE_AGENT_IDS } from '../agents.js';
|
|
@@ -351,13 +352,16 @@ export function finalizeRunMeta(meta, status, exitCode, opts) {
|
|
|
351
352
|
* `yosemite-s0` all agree. Every fire path (cron scheduler, webhook,
|
|
352
353
|
* catchup/overdue, manual run) gates on this.
|
|
353
354
|
*
|
|
354
|
-
* A monitor-dispatched job ({@link JobConfig.dispatchedBy}
|
|
355
|
+
* A monitor- or webhook-dispatched job ({@link JobConfig.dispatchedBy} set) skips
|
|
355
356
|
* the routine activation manifest: it is not a routine, so its name can never be
|
|
356
357
|
* a member and the lookup could only ever answer "not activated here"
|
|
357
|
-
* (RUSH-2681
|
|
358
|
+
* (RUSH-2681 for monitors; the same hole broke every `run.agent`/`run.workflow`
|
|
359
|
+
* webhook handler, which the receiver logged as `fired` while the run record read
|
|
360
|
+
* `skipped` with an empty allowlist). Ownership was already decided upstream — by
|
|
361
|
+
* the monitor's `device:` pin, or by the one box the webhook was delivered to.
|
|
358
362
|
*/
|
|
359
363
|
export function jobRunsOnThisDevice(config) {
|
|
360
|
-
if (config.dispatchedBy
|
|
364
|
+
if (config.dispatchedBy === undefined) {
|
|
361
365
|
const activated = routineEnabledOnThisDevice(config.name);
|
|
362
366
|
if (activated !== null)
|
|
363
367
|
return activated;
|
|
@@ -636,7 +640,7 @@ export function readJobFileResult(filePath) {
|
|
|
636
640
|
// written back (writeJob deletes it), so its presence here means hand-authored
|
|
637
641
|
// state, not drift.
|
|
638
642
|
if (Object.prototype.hasOwnProperty.call(parsed, 'dispatchedBy')) {
|
|
639
|
-
return { config: null, problem: '`dispatchedBy:` is a runtime-only monitor marker, not a routine field — routine is inert' };
|
|
643
|
+
return { config: null, problem: '`dispatchedBy:` is a runtime-only monitor/webhook marker, not a routine field — routine is inert' };
|
|
640
644
|
}
|
|
641
645
|
return {
|
|
642
646
|
config: {
|
|
@@ -844,13 +848,17 @@ export function validateJob(config) {
|
|
|
844
848
|
if (config.command !== undefined && (typeof config.command !== 'string' || config.command.trim() === '')) {
|
|
845
849
|
errors.push('command must be a non-empty shell command string');
|
|
846
850
|
}
|
|
847
|
-
if (hasAgent && config.agent && !ALL_AGENT_IDS.includes(config.agent)) {
|
|
848
|
-
errors.push(`agent must be one of: ${ALL_AGENT_IDS.join(', ')}`);
|
|
851
|
+
if (hasAgent && config.agent && !ALL_AGENT_IDS.includes(config.agent) && !isCustomHarnessName(config.agent)) {
|
|
852
|
+
errors.push(`agent must be one of: ${ALL_AGENT_IDS.join(', ')}, or a custom harness (agents harness list)`);
|
|
849
853
|
}
|
|
850
854
|
else if (hasAgent && config.agent && strategy === 'local' &&
|
|
851
|
-
!ROUTINE_AGENT_IDS.includes(config.agent)
|
|
855
|
+
!ROUTINE_AGENT_IDS.includes(config.agent) &&
|
|
856
|
+
// A custom harness is exempt from the local-daemon command table: the
|
|
857
|
+
// runner delegates it to `agents run <name>`, the same path workflow
|
|
858
|
+
// jobs take, so no ROUTINE_AGENT_COMMANDS template is needed.
|
|
859
|
+
!isCustomHarnessName(config.agent)) {
|
|
852
860
|
// The local daemon only knows how to build a command for the agents in
|
|
853
|
-
// ROUTINE_AGENT_IDS (runner.ts
|
|
861
|
+
// ROUTINE_AGENT_IDS (baked from AGENT_COMMANDS in runner.ts) — anything else is a
|
|
854
862
|
// real, installable agent (it passed the ALL_AGENT_IDS check above) but one
|
|
855
863
|
// the daemon can't fire itself, so reject it now instead of accepting the
|
|
856
864
|
// routine and failing at fire time (runner.ts buildJobCommand: "Unsupported
|
|
Binary file
|
|
Binary file
|
|
@@ -36,6 +36,7 @@ import { getCliVersion, getCliVersionFresh } from '../version.js';
|
|
|
36
36
|
import { getCliLaunch } from '../cli-entry.js';
|
|
37
37
|
import { GLOBAL_HARNESS, bundleScopeChain } from './scope.js';
|
|
38
38
|
import { deleteLeaseSession, rehydrateSessions, pruneSessionsOnSleep } from './session-store.js';
|
|
39
|
+
import { serviceManagerRegistrationAllowed } from '../service-manifest.js';
|
|
39
40
|
import { SYNC_GET_CMD, SYNC_PING_CMD, SYNC_LOCK_CMD } from './sync-commands.js';
|
|
40
41
|
import { MAX_LEASE_MS, MIN_LEASE_MS } from './lease.js';
|
|
41
42
|
import { selectLeasedEnv } from './lease.js';
|
|
@@ -316,7 +317,11 @@ export function retireLegacySecretsAgentService() {
|
|
|
316
317
|
const plist = servicePlistPath();
|
|
317
318
|
// Only the real LaunchAgents dir is launchd-managed; a relocated (test) dir
|
|
318
319
|
// has no bootstrapped job, so skip launchctl and just remove the plist.
|
|
319
|
-
|
|
320
|
+
// Also skip launchctl under a redirected HOME: launchctl is per-user-session
|
|
321
|
+
// and HOME-independent, so a sandboxed process would still talk to the real
|
|
322
|
+
// launchd (RUSH-2968).
|
|
323
|
+
const reg = serviceManagerRegistrationAllowed();
|
|
324
|
+
if (!process.env.AGENTS_SECRETS_LAUNCHAGENTS_DIR && reg.allowed) {
|
|
320
325
|
const uid = process.getuid?.() ?? 0;
|
|
321
326
|
try {
|
|
322
327
|
execFileSync('launchctl', ['bootout', `gui/${uid}/${SERVICE_LABEL}`], { stdio: ['ignore', 'ignore', 'ignore'] });
|
|
@@ -328,6 +333,9 @@ export function retireLegacySecretsAgentService() {
|
|
|
328
333
|
catch { /* not loaded */ }
|
|
329
334
|
}
|
|
330
335
|
}
|
|
336
|
+
else if (!reg.allowed) {
|
|
337
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
338
|
+
}
|
|
331
339
|
try {
|
|
332
340
|
fs.unlinkSync(plist);
|
|
333
341
|
}
|
|
@@ -32,7 +32,7 @@ import { windowsBackend, usesFileFallback as windowsUsesFileFallback, importNati
|
|
|
32
32
|
import { isHeadlessSecretsContext } from './headless.js';
|
|
33
33
|
import { KEYCHAIN_READ_BACKOFF_TTL_MS, clearKeychainReadBackoff, isKeychainReadBackedOff, noteKeychainReadFailure, } from './read-backoff.js';
|
|
34
34
|
import { getKeychainHelperPath } from './install-helper.js';
|
|
35
|
-
import { deriveShortId } from '../
|
|
35
|
+
import { deriveShortId } from '../text/short-id.js';
|
|
36
36
|
const SERVICE_PREFIX = 'agents-cli';
|
|
37
37
|
export const SECRETS_ITEM_PREFIX = `${SERVICE_PREFIX}.secrets.`;
|
|
38
38
|
const BUNDLES_ITEM_PREFIX = `${SERVICE_PREFIX}.bundles.`;
|