@phnx-labs/agents-cli 1.22.41 → 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 +86 -0
- package/README.md +10 -4
- package/dist/bin/agents +0 -0
- package/dist/bootstrap.js +25 -7
- package/dist/cli/command-registry.d.ts +2 -3
- package/dist/cli/command-registry.js +4 -8
- package/dist/commands/accounts.d.ts +29 -0
- package/dist/commands/accounts.js +220 -29
- package/dist/commands/alias.d.ts +7 -4
- package/dist/commands/alias.js +34 -9
- package/dist/commands/auth.d.ts +9 -0
- package/dist/commands/auth.js +108 -0
- package/dist/commands/browser-sessions-picker.js +42 -62
- package/dist/commands/browser.js +30 -38
- package/dist/commands/computer-actions.d.ts +1 -1
- package/dist/commands/computer-actions.js +1 -1
- package/dist/commands/computer-sessions-picker.js +32 -55
- package/dist/commands/computer.d.ts +1 -1
- package/dist/commands/computer.js +22 -8
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/doctor.d.ts +5 -3
- package/dist/commands/doctor.js +23 -8
- package/dist/commands/exec.js +3 -2
- package/dist/commands/feed.js +2 -31
- package/dist/commands/harness.js +3 -3
- package/dist/commands/hooks.js +1 -1
- package/dist/commands/import.js +1 -1
- package/dist/commands/insights.js +163 -85
- package/dist/commands/inspect.js +2 -2
- package/dist/commands/mine.js +1 -1
- package/dist/commands/monitors.js +1 -1
- package/dist/commands/org.d.ts +6 -0
- package/dist/commands/org.js +175 -0
- package/dist/commands/packages.js +1 -1
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/prune.js +1 -1
- package/dist/commands/routines.js +44 -26
- package/dist/commands/run-account-picker.d.ts +19 -0
- package/dist/commands/run-account-picker.js +81 -0
- package/dist/commands/sessions-picker-factory.d.ts +40 -0
- package/dist/commands/sessions-picker-factory.js +67 -0
- package/dist/commands/sessions-picker.js +124 -122
- package/dist/commands/setup-browser.js +4 -4
- package/dist/commands/setup-mine.js +1 -1
- package/dist/commands/setup-preferences.js +2 -2
- package/dist/commands/setup.js +10 -4
- 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 +30 -3
- package/dist/commands/versions.js +1 -1
- package/dist/commands/view.js +7 -1
- package/dist/commands/webhook.js +1 -1
- package/dist/lib/account-capabilities.d.ts +10 -0
- package/dist/lib/account-capabilities.js +34 -0
- 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 +584 -0
- package/dist/lib/agent-spec/agents.js +3127 -0
- package/dist/lib/agent-spec/provider.js +1 -1
- package/dist/lib/agents.d.ts +2 -584
- package/dist/lib/agents.js +2 -3127
- package/dist/lib/browser/drivers/local.d.ts +8 -2
- package/dist/lib/browser/drivers/local.js +8 -2
- package/dist/lib/browser/drivers/ssh.d.ts +8 -2
- package/dist/lib/browser/drivers/ssh.js +10 -4
- package/dist/lib/browser/hygiene.d.ts +1 -1
- package/dist/lib/browser/hygiene.js +5 -1
- package/dist/lib/browser/profiles.d.ts +74 -1
- package/dist/lib/browser/profiles.js +114 -5
- package/dist/lib/browser/runtime-state.d.ts +11 -5
- package/dist/lib/browser/runtime-state.js +13 -9
- package/dist/lib/browser/service.d.ts +68 -30
- package/dist/lib/browser/service.js +305 -194
- package/dist/lib/browser/types.d.ts +95 -3
- package/dist/lib/browser/types.js +51 -0
- package/dist/lib/catchup.js +1 -1
- package/dist/lib/cloud/rush.d.ts +0 -15
- package/dist/lib/cloud/rush.js +0 -35
- package/dist/lib/computer/actions.d.ts +1 -1
- package/dist/lib/computer/actions.js +1 -1
- package/dist/lib/{computer-rpc.js → computer/computer-rpc.js} +5 -5
- package/dist/lib/computer/dispatch.d.ts +1 -1
- package/dist/lib/computer/download.d.ts +1 -1
- package/dist/lib/computer/download.js +3 -3
- package/dist/lib/{ssh-tunnel.d.ts → computer/ssh-tunnel.d.ts} +1 -1
- package/dist/lib/{ssh-tunnel.js → computer/ssh-tunnel.js} +12 -12
- package/dist/lib/crabbox/runtimes.d.ts +6 -2
- package/dist/lib/crabbox/runtimes.js +21 -5
- package/dist/lib/daemon/daemon.js +87 -59
- package/dist/lib/{runner.d.ts → daemon/runner.d.ts} +28 -11
- package/dist/lib/{runner.js → daemon/runner.js} +143 -123
- package/dist/lib/devices/doctor-findings.d.ts +1 -1
- package/dist/lib/devices/doctor-findings.js +4 -4
- package/dist/lib/devices/fleet-inventory.js +1 -1
- package/dist/lib/devices/harness-inventory.js +1 -1
- package/dist/lib/devices/health-report.js +1 -1
- package/dist/lib/devices/registry.js +4 -22
- package/dist/lib/doctor-diff.d.ts +1 -1
- package/dist/lib/doctor-diff.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/drift.js +1 -1
- package/dist/lib/entitlement.d.ts +31 -0
- package/dist/lib/entitlement.js +137 -0
- package/dist/lib/exec.js +52 -205
- package/dist/lib/feed/feed.js +2 -8
- package/dist/lib/format.d.ts +9 -0
- package/dist/lib/format.js +16 -0
- package/dist/lib/fs-atomic.d.ts +7 -0
- package/dist/lib/fs-atomic.js +9 -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 +161 -0
- package/dist/lib/harness/adapter.js +47 -0
- package/dist/lib/harness/adapters/claude.d.ts +2 -0
- package/dist/lib/harness/adapters/claude.js +110 -0
- package/dist/lib/harness/adapters/codex.d.ts +2 -0
- package/dist/lib/harness/adapters/codex.js +83 -0
- package/dist/lib/harness/adapters/copilot.d.ts +2 -0
- package/dist/lib/harness/adapters/copilot.js +23 -0
- package/dist/lib/harness/adapters/cursor.d.ts +2 -0
- package/dist/lib/harness/adapters/cursor.js +38 -0
- package/dist/lib/harness/adapters/droid.d.ts +2 -0
- package/dist/lib/harness/adapters/droid.js +17 -0
- package/dist/lib/harness/adapters/grok.d.ts +2 -0
- package/dist/lib/harness/adapters/grok.js +14 -0
- package/dist/lib/harness/adapters/kimi.d.ts +2 -0
- package/dist/lib/harness/adapters/kimi.js +49 -0
- package/dist/lib/harness/adapters/muse.d.ts +2 -0
- package/dist/lib/harness/adapters/muse.js +44 -0
- package/dist/lib/harness/adapters/opencode.d.ts +2 -0
- package/dist/lib/harness/adapters/opencode.js +14 -0
- package/dist/lib/harness/exec-config-version.d.ts +8 -0
- package/dist/lib/harness/exec-config-version.js +22 -0
- package/dist/lib/harness/index.d.ts +1 -0
- package/dist/lib/harness/index.js +34 -0
- package/dist/lib/{hooks.d.ts → hooks/install.d.ts} +1 -1
- package/dist/lib/{hooks.js → hooks/install.js} +11 -11
- 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/import.js +1 -1
- package/dist/lib/installations/index.d.ts +4 -4
- package/dist/lib/installations/index.js +3 -4
- package/dist/lib/installations/migrate.js +6 -6
- package/dist/lib/{shims.d.ts → installations/shims.d.ts} +2 -2
- package/dist/lib/{shims.js → installations/shims.js} +13 -115
- package/dist/lib/installations/store.d.ts +141 -3
- package/dist/lib/installations/store.js +475 -5
- package/dist/lib/installations/versions.d.ts +40 -125
- package/dist/lib/installations/versions.js +57 -462
- package/dist/lib/isolation-boundary-report.d.ts +1 -1
- package/dist/lib/isolation-boundary-report.js +1 -1
- package/dist/lib/mailbox-gc.js +2 -3
- 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/monitors/dispatch.d.ts +1 -1
- package/dist/lib/monitors/dispatch.js +2 -2
- package/dist/lib/monitors/state.d.ts +1 -1
- 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/plugins/plugins.js +1 -1
- package/dist/lib/plugins/skills.js +1 -1
- package/dist/lib/prix-account.d.ts +158 -0
- package/dist/lib/prix-account.js +214 -0
- package/dist/lib/profiles.d.ts +7 -0
- package/dist/lib/profiles.js +26 -1
- package/dist/lib/project-key.js +2 -2
- package/dist/lib/project-launch.js +1 -1
- package/dist/lib/refresh.js +2 -2
- package/dist/lib/resource-inventory.d.ts +1 -1
- package/dist/lib/resource-inventory.js +1 -1
- package/dist/lib/rules/rules.js +1 -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 +17 -9
- 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/self-heal/checks/hook-runtime.js +1 -1
- package/dist/lib/self-heal/checks/path.js +1 -1
- package/dist/lib/self-heal/checks/shadowing.js +1 -1
- package/dist/lib/self-heal/checks/shims.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/discover.d.ts +39 -0
- package/dist/lib/session/discover.js +3 -3
- 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/parse.js +24 -42
- package/dist/lib/session/recovery.js +1 -1
- 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/staleness/prune.d.ts +1 -1
- package/dist/lib/staleness/prune.js +1 -1
- package/dist/lib/staleness/writers/hooks.js +1 -1
- package/dist/lib/startup/command-registry.d.ts +4 -1
- package/dist/lib/startup/command-registry.js +12 -5
- package/dist/lib/teams/agents.js +2 -19
- package/dist/lib/teams/parsers.js +20 -26
- package/dist/lib/teams/placement-probe.js +1 -1
- package/dist/lib/teams/registry.js +2 -21
- 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 +9 -1
- package/dist/lib/triggers/webhook.d.ts +1 -0
- package/dist/lib/triggers/webhook.js +3 -2
- package/dist/lib/uninstall.js +1 -1
- package/dist/lib/version.d.ts +9 -2
- package/dist/lib/version.js +11 -9
- 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
- /package/dist/lib/{computer-rpc.d.ts → computer/computer-rpc.d.ts} +0 -0
|
@@ -13,12 +13,12 @@ import * as path from 'path';
|
|
|
13
13
|
import * as os from 'os';
|
|
14
14
|
import { fileURLToPath } from 'url';
|
|
15
15
|
import { confirm, select } from '@inquirer/prompts';
|
|
16
|
-
import { IS_WINDOWS, prependToWindowsUserPath } from '
|
|
17
|
-
import { getShimsDir, getVersionsDir, getBackupsDir, getHistoryDir, ensureAgentsDir } from '
|
|
16
|
+
import { IS_WINDOWS, prependToWindowsUserPath } from '../platform/index.js';
|
|
17
|
+
import { getShimsDir, getVersionsDir, getBackupsDir, getHistoryDir, ensureAgentsDir } from '../state.js';
|
|
18
18
|
export { getShimsDir };
|
|
19
|
-
import { AGENTS, agentConfigDirName, readAuthAccountIdentity } from '
|
|
20
|
-
import { codexHomeShimBash } from '
|
|
21
|
-
import {
|
|
19
|
+
import { AGENTS, agentConfigDirName, readAuthAccountIdentity } from '../agents.js';
|
|
20
|
+
import { codexHomeShimBash } from '../codex-home.js';
|
|
21
|
+
import { resolveHarnessAdapter } from '../harness/index.js';
|
|
22
22
|
/**
|
|
23
23
|
* Files and directories to always skip during conflict detection and migration.
|
|
24
24
|
* These are never user config that should be migrated.
|
|
@@ -296,52 +296,8 @@ const GROK_RESOLVE_BINARY_FN = `_resolve_grok_binary() {
|
|
|
296
296
|
done
|
|
297
297
|
printf '%s\\n' "$best"
|
|
298
298
|
}`;
|
|
299
|
-
function codexShimLaunchArgs() {
|
|
300
|
-
return [
|
|
301
|
-
'-c',
|
|
302
|
-
'check_for_update_on_startup=false',
|
|
303
|
-
...codexPolicyArgs('edit'),
|
|
304
|
-
].map(shellQuote).join(' ');
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* The `exec` tail for a generated shim. For most agents this is a plain
|
|
308
|
-
* `exec "$BINARY"<launchArgs> "$@"`.
|
|
309
|
-
*
|
|
310
|
-
* Codex is special: its `workspace-write` sandbox hardcodes any `.agents/` (and
|
|
311
|
-
* `.codex/`) directory read-only, but agents-cli keeps every worktree at
|
|
312
|
-
* `<repo>/.agents/worktrees/<slug>`, so an in-repo build under a static
|
|
313
|
-
* shim would hit `EROFS`. The `agents run codex` path fixes this by adding
|
|
314
|
-
* `<repo>/.agents` to the profile's `workspace_roots` (see codexEditWritableRoots
|
|
315
|
-
* / repoAgentsDirForCwd), but a static shim has no cwd at generation time. So the
|
|
316
|
-
* shim resolves the repo's `.agents` from `$PWD` at RUN time — worktree-aware,
|
|
317
|
-
* mirroring repoAgentsDirForCwd — and passes it via Codex's own `--add-dir`
|
|
318
|
-
* (verified to compose with the `agents-edit` profile). The resolution is inline
|
|
319
|
-
* bash because the shim is the launch hot path and must not spawn Node to compute
|
|
320
|
-
* one directory. `--add-dir` is added only when the resolved `.agents` exists.
|
|
321
|
-
*/
|
|
322
|
-
function shimExecTail(agent, launchArgs) {
|
|
323
|
-
if (agent !== 'codex')
|
|
324
|
-
return `exec "$BINARY"${launchArgs} "$@"`;
|
|
325
|
-
return `_repo_agents=""
|
|
326
|
-
case "$PWD" in
|
|
327
|
-
*/.agents/worktrees/*) _repo_agents="\${PWD%%/.agents/worktrees/*}/.agents" ;;
|
|
328
|
-
*)
|
|
329
|
-
_d="$PWD"
|
|
330
|
-
# Stop before $HOME so a dotfiles repo at $HOME is not treated as the project
|
|
331
|
-
# root (mirrors repoRootForCwd's home exclusion in project-key.ts).
|
|
332
|
-
while [ -n "$_d" ] && [ "$_d" != "/" ] && [ "$_d" != "$HOME" ]; do
|
|
333
|
-
if [ -e "$_d/.git" ]; then _repo_agents="$_d/.agents"; break; fi
|
|
334
|
-
_d=$(dirname "$_d")
|
|
335
|
-
done
|
|
336
|
-
;;
|
|
337
|
-
esac
|
|
338
|
-
if [ -n "$_repo_agents" ] && [ -d "$_repo_agents" ]; then
|
|
339
|
-
exec "$BINARY"${launchArgs} --add-dir "$_repo_agents" "$@"
|
|
340
|
-
fi
|
|
341
|
-
exec "$BINARY"${launchArgs} "$@"`;
|
|
342
|
-
}
|
|
343
299
|
function getAgentsBinForGeneratedShim() {
|
|
344
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'index.js');
|
|
300
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'index.js');
|
|
345
301
|
}
|
|
346
302
|
/**
|
|
347
303
|
* Generate the full bash shim script for the given agent. The returned string
|
|
@@ -356,66 +312,8 @@ export function generateShimScript(agent) {
|
|
|
356
312
|
// subpath so per-version HOME symlinks reach the right place.
|
|
357
313
|
const configDirName = path.relative(os.homedir(), agentConfig.configDir);
|
|
358
314
|
const agentsBin = shellQuote(getAgentsBinForGeneratedShim());
|
|
359
|
-
const managedEnv = agent
|
|
360
|
-
|
|
361
|
-
# Claude stores OAuth credentials in the macOS keychain. Scope them to the
|
|
362
|
-
# selected version's config directory so switching versions also switches the
|
|
363
|
-
# live Claude account.
|
|
364
|
-
export CLAUDE_CONFIG_DIR="$VERSION_DIR/home/${configDirName}"
|
|
365
|
-
# Managed installs are pinned in a per-version dir; Claude Code's background
|
|
366
|
-
# auto-updater would rewrite the pinned binary in place. Disable it so a pin
|
|
367
|
-
# stays a pin. An explicit user value always wins.
|
|
368
|
-
export DISABLE_AUTOUPDATER="\${DISABLE_AUTOUPDATER:-1}"
|
|
369
|
-
# On Linux sandboxes (no keychain), fall back to a per-version token file.
|
|
370
|
-
# The env var always wins if already set; no-op on macOS.
|
|
371
|
-
if [ "\$(uname -s)" = "Linux" ] && [ -z "\${CLAUDE_CODE_OAUTH_TOKEN:-}" ] && [ -f "\$CLAUDE_CONFIG_DIR/.oauth_token" ]; then
|
|
372
|
-
CLAUDE_CODE_OAUTH_TOKEN=\$(cat "\$CLAUDE_CONFIG_DIR/.oauth_token")
|
|
373
|
-
export CLAUDE_CODE_OAUTH_TOKEN
|
|
374
|
-
fi
|
|
375
|
-
`
|
|
376
|
-
: agent === 'codex'
|
|
377
|
-
? codexHomeShimBash(`$VERSION_DIR/home/${configDirName}`, `$AGENTS_USER_DIR/.codex-homes/$VERSION`)
|
|
378
|
-
: agent === 'copilot'
|
|
379
|
-
? `
|
|
380
|
-
# GitHub Copilot CLI honors COPILOT_HOME to relocate its config and state
|
|
381
|
-
# (settings.json, mcp-config.json, session-state/, logs/, plugins/). Point
|
|
382
|
-
# it at the versioned home so MCP servers, custom agents, and session
|
|
383
|
-
# history are isolated per copilot version.
|
|
384
|
-
export COPILOT_HOME="$VERSION_DIR/home/${configDirName}"
|
|
385
|
-
`
|
|
386
|
-
: agent === 'grok'
|
|
387
|
-
? `
|
|
388
|
-
# Grok Build uses GROK_HOME to isolate its entire configuration tree
|
|
389
|
-
# (skills, hooks, plugins, agents, memory, sessions, config.toml, MCP, etc.).
|
|
390
|
-
# This gives agents-cli full versioned isolation + resource sync for grok.
|
|
391
|
-
export GROK_HOME="$VERSION_DIR/home/.grok"
|
|
392
|
-
`
|
|
393
|
-
: agent === 'opencode'
|
|
394
|
-
? `
|
|
395
|
-
# OpenCode reads plugins, agents, commands, and other config-directory
|
|
396
|
-
# resources from OPENCODE_CONFIG_DIR. Point it at the versioned global config
|
|
397
|
-
# tree where agents-cli syncs OpenCode resources.
|
|
398
|
-
export OPENCODE_CONFIG_DIR="$VERSION_DIR/home/.config/opencode"
|
|
399
|
-
`
|
|
400
|
-
: agent === 'kimi'
|
|
401
|
-
? `
|
|
402
|
-
# Kimi Code CLI honors KIMI_CODE_HOME to relocate ~/.kimi-code (config.toml,
|
|
403
|
-
# mcp.json, sessions, skills, hooks). Point it at the versioned home.
|
|
404
|
-
export KIMI_CODE_HOME="$VERSION_DIR/home/${configDirName}"
|
|
405
|
-
`
|
|
406
|
-
: agent === 'muse'
|
|
407
|
-
? `
|
|
408
|
-
# Muse Code has no MUSE_CONFIG_DIR. It resolves config via XDG:
|
|
409
|
-
# $XDG_CONFIG_HOME/muse (settings, skills, hooks, auth)
|
|
410
|
-
# $XDG_DATA_HOME/muse (sessions, plugins)
|
|
411
|
-
# Pin XDG into the version home so managed runs never walk the adopt-time
|
|
412
|
-
# ~/.config/muse -> version-home symlink — Muse refuses agent-definition
|
|
413
|
-
# sources that are SymlinkOrReparse (exit 1). Same idea as CLAUDE_CONFIG_DIR.
|
|
414
|
-
export XDG_CONFIG_HOME="$VERSION_DIR/home/.config"
|
|
415
|
-
export XDG_DATA_HOME="$VERSION_DIR/home/.local/share"
|
|
416
|
-
`
|
|
417
|
-
: '';
|
|
418
|
-
const launchArgs = agent === 'codex' ? ` ${codexShimLaunchArgs()}` : '';
|
|
315
|
+
const managedEnv = resolveHarnessAdapter(agent).shimConfigEnvBash?.({ configDirName }) ?? '';
|
|
316
|
+
const launchArgs = resolveHarnessAdapter(agent).shimLaunchArgs?.() ?? '';
|
|
419
317
|
return `#!/bin/bash
|
|
420
318
|
# Auto-generated by agents-cli - do not edit
|
|
421
319
|
# Shim for ${agentConfig.name}
|
|
@@ -831,7 +729,7 @@ if [ "\$LAUNCH_SKIP" = "0" ]; then
|
|
|
831
729
|
"\$AGENTS_BIN" sync --agent "\$AGENT" --agent-version "\$VERSION" --launch --cwd "\$PWD" --quiet 2>/dev/null || true
|
|
832
730
|
fi
|
|
833
731
|
|
|
834
|
-
${shimExecTail(
|
|
732
|
+
${resolveHarnessAdapter(agent).shimExecTail?.(launchArgs) ?? `exec "$BINARY"${launchArgs} "$@"`}
|
|
835
733
|
`;
|
|
836
734
|
}
|
|
837
735
|
/**
|
|
@@ -1145,7 +1043,7 @@ export XDG_DATA_HOME="$HOME/.agents/.history/versions/${agent}/${version}/home/.
|
|
|
1145
1043
|
export XDG_CONFIG_HOME="$HOME/.agents/.history/versions/${agent}/${version}/home/.config"
|
|
1146
1044
|
`
|
|
1147
1045
|
: '';
|
|
1148
|
-
const launchArgs = agent
|
|
1046
|
+
const launchArgs = resolveHarnessAdapter(agent).shimLaunchArgs?.() ?? '';
|
|
1149
1047
|
// Resolve the binary the same way the main shim does (see generateShimScript).
|
|
1150
1048
|
// Grok and Droid do NOT ship into node_modules/.bin — Grok downloads a native
|
|
1151
1049
|
// binary to ~/.grok/downloads and Droid (Factory AI) installs a standalone
|
|
@@ -1231,7 +1129,7 @@ if [ -z "$BINARY" ] || [ ! -x "$BINARY" ]; then
|
|
|
1231
1129
|
fi
|
|
1232
1130
|
${managedEnv}
|
|
1233
1131
|
|
|
1234
|
-
${shimExecTail(
|
|
1132
|
+
${resolveHarnessAdapter(agent).shimExecTail?.(launchArgs) ?? `exec "$BINARY"${launchArgs} "$@"`}
|
|
1235
1133
|
`;
|
|
1236
1134
|
}
|
|
1237
1135
|
/**
|
|
@@ -1639,7 +1537,7 @@ export async function switchConfigSymlink(agent, version) {
|
|
|
1639
1537
|
// Dynamic import so loading shims.ts doesn't transitively open the
|
|
1640
1538
|
// sessions DB — many tests partially mock state.js and would break.
|
|
1641
1539
|
try {
|
|
1642
|
-
const { updateSessionFilePaths } = await import('
|
|
1540
|
+
const { updateSessionFilePaths } = await import('../session/db.js');
|
|
1643
1541
|
updateSessionFilePaths(configPath, finalBackupPath);
|
|
1644
1542
|
}
|
|
1645
1543
|
catch (err) {
|
|
@@ -2117,7 +2015,7 @@ export function pruneOrphanedCommandShim(fileName) {
|
|
|
2117
2015
|
return false;
|
|
2118
2016
|
}
|
|
2119
2017
|
if (content.includes('# Alias shim:'))
|
|
2120
|
-
return false; // a user `agents alias` — leave it
|
|
2018
|
+
return false; // a user `agents setup alias` shim — leave it
|
|
2121
2019
|
const bin = readAgentsBinFromShim(shimPath);
|
|
2122
2020
|
if (!bin)
|
|
2123
2021
|
return false; // not an AGENTS_BIN-baked shim
|
|
@@ -10,10 +10,12 @@ import { type Installation } from './types.js';
|
|
|
10
10
|
* follow. It is also why the file name is registered in versions.ts's
|
|
11
11
|
* `PRESERVED_ON_CLEAN_REINSTALL` — a repair reinstall must not mint a new id.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Path/enumeration plus frozen installation records. Depends on Node builtins,
|
|
14
|
+
* installations-local modules, and base lib (`state`/`fs-atomic`/`primitives`/
|
|
15
|
+
* `agents`/`shims`/`platform`) — never `plugins/`, `rules/`, `session/`, or
|
|
16
|
+
* `devices/`, so those modules can import this file without an import cycle.
|
|
15
17
|
*/
|
|
16
|
-
/** Directory holding one installation.
|
|
18
|
+
/** Directory holding one installation. Same path as {@link getVersionDir}. */
|
|
17
19
|
export declare function installationDir(agent: AgentId, label: string): string;
|
|
18
20
|
export declare function installationRecordPath(agent: AgentId, label: string): string;
|
|
19
21
|
/** Mint an opaque installation id. Random, never derived from the release. */
|
|
@@ -54,3 +56,139 @@ export declare function listInstallationLabels(agent: AgentId): string[];
|
|
|
54
56
|
* that disappears mid-scan is skipped rather than failing the whole listing.
|
|
55
57
|
*/
|
|
56
58
|
export declare function listInstallations(agent: AgentId): Installation[];
|
|
59
|
+
/**
|
|
60
|
+
* Get the directory where a specific version is installed.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getVersionDir(agent: AgentId, version: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Pick the real grok binary among `grok-*` entries in `downloadsDir` when NO
|
|
65
|
+
* filename carries the pinned version string. Grok self-updates its binary in
|
|
66
|
+
* place while running under the shim, so a version-home's downloads dir can
|
|
67
|
+
* accumulate several `grok-*` files whose names have drifted away from that
|
|
68
|
+
* version-home's pinned version (RUSH-2459: on yosemite-s0, version-home
|
|
69
|
+
* `0.2.82` held `grok-1.0.0-linux-aarch64` after grok self-updated, plus a
|
|
70
|
+
* stale, unrelated 99-byte `grok-0.2.118-linux-aarch64` wrapper script that
|
|
71
|
+
* happened to sort alphabetically first).
|
|
72
|
+
*
|
|
73
|
+
* Never blindly take whatever `fs.readdirSync` returns first — that is exactly
|
|
74
|
+
* the bug this replaces. Instead: exclude anything under
|
|
75
|
+
* {@link MIN_GROK_BINARY_BYTES} (rejects wrapper/alias artifacts on size
|
|
76
|
+
* alone, no content sniffing needed) and, among the survivors, prefer the most
|
|
77
|
+
* recently modified — the file grok's self-updater actually wrote last.
|
|
78
|
+
* Returns null (fail loud, never guess) when nothing survives the size filter.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveGrokFallbackBinary(downloadsDir: string): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Get the binary path for a specific agent version.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getBinaryPath(agent: AgentId, version: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Does this agent resolve to ONE global binary that is the same file regardless
|
|
87
|
+
* of the `version` argument? (droid → always `~/.local/bin/droid`.) Computed
|
|
88
|
+
* generically by probing `getBinaryPath` with two distinct versions rather than
|
|
89
|
+
* hardcoding an agent id, so it stays correct if another global-binary agent is
|
|
90
|
+
* added.
|
|
91
|
+
*
|
|
92
|
+
* This is the narrower cousin of `isSelfUpdatingAgent`: every global-binary
|
|
93
|
+
* agent is self-updating, but grok is self-updating WITHOUT a global binary — it
|
|
94
|
+
* stores a real per-version binary copy under each version-home
|
|
95
|
+
* (`versions/grok/<v>/home/.grok/downloads/grok-<v>`), so its version-homes are
|
|
96
|
+
* genuinely distinct and must NOT be collapsed. Gate the single-binary
|
|
97
|
+
* collapse/live-version logic on THIS predicate; gate pin-refusal / "switch
|
|
98
|
+
* profile" copy on `isSelfUpdatingAgent`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function isGlobalBinaryAgent(agent: AgentId): boolean;
|
|
101
|
+
/** Drop the live-version cache (call after an install/remove that changes the
|
|
102
|
+
* running binary, e.g. `agents add droid@latest`). */
|
|
103
|
+
export declare function invalidateLiveVersionCache(agent?: AgentId): void;
|
|
104
|
+
/**
|
|
105
|
+
* Resolve the version the ONE globally-installed binary actually reports via
|
|
106
|
+
* `<cli> --version`, cached for {@link LIVE_VERSION_TTL_MS}. For a self-updating
|
|
107
|
+
* global-binary agent (droid) this is the single source of truth for "which
|
|
108
|
+
* version is installed" — the on-disk version-dir NAMES are just stale labels
|
|
109
|
+
* left behind by successive `agents add`/self-update cycles. Returns null when
|
|
110
|
+
* the binary isn't on PATH or the probe fails.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getCliVersionFromPath(agent: AgentId): Promise<string | null>;
|
|
113
|
+
export declare function getLiveVersion(agent: AgentId): Promise<string | null>;
|
|
114
|
+
/**
|
|
115
|
+
* Synchronous, non-blocking read of the live-version cache — returns the value
|
|
116
|
+
* only if a recent {@link getLiveVersion} call already warmed it, else null.
|
|
117
|
+
* `listInstalledVersions` is sync and must not shell out, so it prefers this
|
|
118
|
+
* warm value (accurate) and otherwise falls back to the newest on-disk dir.
|
|
119
|
+
*/
|
|
120
|
+
export declare function getCachedLiveVersion(agent: AgentId): string | null;
|
|
121
|
+
/**
|
|
122
|
+
* Get the isolated HOME directory for a specific agent version.
|
|
123
|
+
* Each version has its own config isolation (like jobs sandbox).
|
|
124
|
+
*/
|
|
125
|
+
export declare function getVersionHomePath(agent: AgentId, version: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Check if a specific version is installed.
|
|
128
|
+
*
|
|
129
|
+
* Probes the actual launch binary (the same executable the shims run), not just
|
|
130
|
+
* the version dir or the node_modules/.bin/<cli> wrapper. For npm agents that
|
|
131
|
+
* means statting the package's real `bin` target (getPackageBinaryPath), so a
|
|
132
|
+
* present-but-gutted install (vendor auto-updater destroyed the binary) reports
|
|
133
|
+
* as NOT installed and `agents add` re-runs its install step to repair it.
|
|
134
|
+
*/
|
|
135
|
+
export declare function isVersionInstalled(agent: AgentId, version: string): boolean;
|
|
136
|
+
/** Drop the installed-versions cache (call after install/remove mutations). */
|
|
137
|
+
export declare function invalidateInstalledVersionsCache(agent?: AgentId): void;
|
|
138
|
+
/**
|
|
139
|
+
* Choose the single canonical version-dir to represent a self-updating
|
|
140
|
+
* global-binary agent (droid). All its version dirs map to ONE binary, so
|
|
141
|
+
* exactly one is real; the rest are stale labels. Prefer, in order: the dir the
|
|
142
|
+
* live config symlink points at (what actually runs), the recorded global
|
|
143
|
+
* default, the live `--version` (when the cache is warm), else the newest dir.
|
|
144
|
+
* `versions` MUST be sorted ascending. Callers guarantee it is non-empty.
|
|
145
|
+
*/
|
|
146
|
+
export declare function pickCanonicalGlobalBinaryVersion(agent: AgentId, versions: string[]): string;
|
|
147
|
+
/**
|
|
148
|
+
* List all installed versions for an agent (cached by versions-dir mtime).
|
|
149
|
+
*
|
|
150
|
+
* For a self-updating global-binary agent (droid) every version dir resolves to
|
|
151
|
+
* the SAME binary, so this collapses them to a single canonical entry — one
|
|
152
|
+
* install, one row in `agents view`, never the phantom set of semver dir names.
|
|
153
|
+
*/
|
|
154
|
+
export declare function listInstalledVersions(agent: AgentId): string[];
|
|
155
|
+
/**
|
|
156
|
+
* Get the global default version for an agent.
|
|
157
|
+
*/
|
|
158
|
+
export declare function getGlobalDefault(agent: AgentId): string | null;
|
|
159
|
+
/**
|
|
160
|
+
* Get the preferred ISOLATED version for an agent — the copy a bare
|
|
161
|
+
* `agents run <agent>` falls back to when there is no global default.
|
|
162
|
+
*/
|
|
163
|
+
export declare function getIsolatedDefault(agent: AgentId): string | null;
|
|
164
|
+
/**
|
|
165
|
+
* Mark an installed version as an isolated install (`agents add --isolated`).
|
|
166
|
+
*
|
|
167
|
+
* Isolated versions are fully self-contained: they never become the global
|
|
168
|
+
* default and never own the user's real `~/.<agent>` config directory. This
|
|
169
|
+
* flag is what keeps every "adopting" code path away from them.
|
|
170
|
+
*/
|
|
171
|
+
export declare function markVersionIsolated(agent: AgentId, version: string): void;
|
|
172
|
+
/**
|
|
173
|
+
* Whether a version was installed as an isolated install (`agents add --isolated`).
|
|
174
|
+
*
|
|
175
|
+
* Used to exclude such versions from global-default promotion and from any
|
|
176
|
+
* flow that would touch the user's real `~/.<agent>` directory, and to gate the
|
|
177
|
+
* `--isolated` safety check on `agents remove`.
|
|
178
|
+
*/
|
|
179
|
+
export declare function isVersionIsolated(agent: AgentId, version: string): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Get version specified in a project-root agents.yaml (not the user ~/.agents/.system/agents.yaml).
|
|
182
|
+
*/
|
|
183
|
+
export declare function getProjectVersion(agent: AgentId, startPath: string): string | null;
|
|
184
|
+
/**
|
|
185
|
+
* Get the resolved version for an agent in the current context.
|
|
186
|
+
* Checks project manifest first, then global default.
|
|
187
|
+
*/
|
|
188
|
+
export declare function resolveVersion(agent: AgentId, projectPath?: string): string | null;
|
|
189
|
+
/**
|
|
190
|
+
* Get the effective HOME directory for an agent.
|
|
191
|
+
* If version-managed with a resolved version, returns the version's home directory.
|
|
192
|
+
* Otherwise returns the real HOME.
|
|
193
|
+
*/
|
|
194
|
+
export declare function getEffectiveHome(agentId: AgentId): string;
|