@phnx-labs/agents-cli 1.22.41 → 1.22.42
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 +14 -0
- package/README.md +9 -3
- package/dist/bin/agents +0 -0
- package/dist/cli/command-registry.d.ts +2 -0
- package/dist/cli/command-registry.js +4 -0
- package/dist/commands/accounts.d.ts +29 -0
- package/dist/commands/accounts.js +220 -29
- package/dist/commands/alias.js +1 -1
- package/dist/commands/auth.d.ts +9 -0
- package/dist/commands/auth.js +104 -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 +2 -2
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/feed.js +1 -1
- 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/org.d.ts +6 -0
- package/dist/commands/org.js +174 -0
- package/dist/commands/packages.js +1 -1
- package/dist/commands/prune.js +1 -1
- package/dist/commands/routines.js +1 -1
- 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/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 +5 -3
- package/dist/commands/sync.js +1 -1
- package/dist/commands/versions.js +1 -1
- package/dist/commands/view.js +1 -1
- package/dist/lib/account-capabilities.d.ts +10 -0
- package/dist/lib/account-capabilities.js +34 -0
- 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/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/daemon/daemon.js +1 -1
- package/dist/lib/{runner.d.ts → daemon/runner.d.ts} +10 -10
- package/dist/lib/{runner.js → daemon/runner.js} +40 -114
- package/dist/lib/devices/doctor-findings.d.ts +1 -1
- package/dist/lib/devices/doctor-findings.js +3 -3
- package/dist/lib/devices/fleet-inventory.js +1 -1
- package/dist/lib/devices/harness-inventory.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.js +1 -1
- package/dist/lib/entitlement.d.ts +31 -0
- package/dist/lib/entitlement.js +137 -0
- package/dist/lib/exec.js +39 -202
- package/dist/lib/feed/feed.js +2 -8
- package/dist/lib/fs-atomic.d.ts +7 -0
- package/dist/lib/fs-atomic.js +9 -0
- package/dist/lib/harness/adapter.d.ts +160 -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/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} +12 -114
- package/dist/lib/installations/store.d.ts +141 -3
- package/dist/lib/installations/store.js +475 -5
- package/dist/lib/installations/versions.d.ts +1 -126
- package/dist/lib/installations/versions.js +5 -465
- 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/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/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/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/scheduling/routines.js +1 -1
- 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/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/session/discover.d.ts +39 -0
- package/dist/lib/session/discover.js +3 -3
- package/dist/lib/session/parse.js +24 -42
- package/dist/lib/session/recovery.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.js +1 -1
- package/dist/lib/teams/agents.js +2 -19
- package/dist/lib/teams/parsers.js +20 -26
- package/dist/lib/teams/registry.js +2 -21
- package/dist/lib/triggers/handlers.js +1 -1
- package/dist/lib/triggers/webhook.js +1 -1
- package/dist/lib/uninstall.js +1 -1
- package/dist/lib/version.d.ts +9 -2
- package/dist/lib/version.js +11 -9
- package/package.json +1 -1
- /package/dist/lib/{computer-rpc.d.ts → computer/computer-rpc.d.ts} +0 -0
package/dist/lib/fs-atomic.js
CHANGED
|
@@ -55,6 +55,15 @@ export function atomicWriteFileSync(filePath, content, options = 'utf-8') {
|
|
|
55
55
|
throw err;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Convenience wrapper around {@link atomicWriteFileSync} for the common case of
|
|
60
|
+
* writing pretty-printed JSON (RUSH-2840). Same tmp-then-rename mechanics, same
|
|
61
|
+
* caller responsibility to ensure the parent directory exists first — this adds
|
|
62
|
+
* only the `JSON.stringify`.
|
|
63
|
+
*/
|
|
64
|
+
export function atomicWriteJsonSync(filePath, data) {
|
|
65
|
+
atomicWriteFileSync(filePath, JSON.stringify(data, null, 2));
|
|
66
|
+
}
|
|
58
67
|
export function withFileLock(filePath, fn, opts = {}) {
|
|
59
68
|
let release = null;
|
|
60
69
|
let lastError;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness adapter registry — the behavior axis of a supported harness.
|
|
3
|
+
*
|
|
4
|
+
* The declarative FLAG table lives in `AGENTS` (lib/agents.ts): what a harness
|
|
5
|
+
* *is* (cliCommand, configDir, capabilities). A HarnessAdapter carries what a
|
|
6
|
+
* harness *does* at the execution boundary — the per-harness quirks that four
|
|
7
|
+
* call sites otherwise each re-express as a `if (agent === 'x') … else if …`
|
|
8
|
+
* name-chain:
|
|
9
|
+
*
|
|
10
|
+
* - config-dir env pins → exec.ts buildExecEnv + shims.ts shim script
|
|
11
|
+
* - launch-arg quirks → exec.ts buildExecCommand + runner.ts buildJobCommand
|
|
12
|
+
*
|
|
13
|
+
* One adapter per harness is the single source of truth for that harness's
|
|
14
|
+
* behavior across every consuming site, mirroring the ChannelProvider
|
|
15
|
+
* (lib/channels/registry.ts), HostProvider (lib/hosts/types.ts), and
|
|
16
|
+
* AccountProviderAdapter (lib/account-provider-registry.ts) registries this repo
|
|
17
|
+
* already proves.
|
|
18
|
+
*
|
|
19
|
+
* NOT here: transcript parsing and live team-event normalization. Those are
|
|
20
|
+
* registry-dispatched too — a `Record` table in `session/parse.ts`
|
|
21
|
+
* (`TRANSCRIPT_PARSERS`) and one in `teams/parsers.ts` (`TEAM_EVENT_NORMALIZERS`)
|
|
22
|
+
* — but kept beside the parser functions they dispatch (which live in those
|
|
23
|
+
* files) rather than on this `AgentId` registry, because their id domains differ:
|
|
24
|
+
* the offline transcript reader keys on `SessionAgentId` (which includes `rush`,
|
|
25
|
+
* not an `AgentId`), and the live team-event normalizer keys on the teams
|
|
26
|
+
* `AgentType`. They stay separate functions — offline transcript vs live team
|
|
27
|
+
* events — deliberately.
|
|
28
|
+
*/
|
|
29
|
+
import type { AgentId, Mode } from '../types.js';
|
|
30
|
+
import type { JobConfig } from '../scheduling/routines.js';
|
|
31
|
+
/**
|
|
32
|
+
* Context for the exec-time config-env pin (mapping A, exec.ts side). The caller
|
|
33
|
+
* resolves the interactive/version facts once; the adapter only expresses the
|
|
34
|
+
* harness-specific env manipulation, operating on the accumulating `result` env
|
|
35
|
+
* exactly as the old per-agent branch did.
|
|
36
|
+
*/
|
|
37
|
+
export interface ExecConfigEnvCtx {
|
|
38
|
+
agent: AgentId;
|
|
39
|
+
/** The version to pin, pre-resolved by the caller (null = unresolved/not installed). */
|
|
40
|
+
version: string | null;
|
|
41
|
+
/** That version's home, pre-resolved by the caller (null when version is null). */
|
|
42
|
+
versionHome: string | null;
|
|
43
|
+
/** resolveInteractive(options) — computed once by the caller. */
|
|
44
|
+
interactive: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* claude-account-token's resolveClaudeSetupToken, injected. The adapters MUST
|
|
47
|
+
* stay import-leaf: claude-account-token pulls in the secrets stack, which
|
|
48
|
+
* transitively imports sqlite.ts (top-level await). Importing it inside an
|
|
49
|
+
* adapter drags that into shims.ts's module graph (shims imports the harness
|
|
50
|
+
* barrel), and subprocess-spawning tests that load shims via tsx then fail the
|
|
51
|
+
* cjs transform. Only claude uses it.
|
|
52
|
+
*/
|
|
53
|
+
resolveClaudeSetupToken: (versionHome: string) => string | null;
|
|
54
|
+
}
|
|
55
|
+
/** Context for the shim-script config-env block (mapping A, shims.ts side). */
|
|
56
|
+
export interface ShimConfigEnvCtx {
|
|
57
|
+
/**
|
|
58
|
+
* The config-dir path relative to `$HOME` (e.g. `.claude`, or the nested
|
|
59
|
+
* `.gemini/antigravity-cli`), derived by the caller from the AGENTS registry.
|
|
60
|
+
*/
|
|
61
|
+
configDirName: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Context for the exec-time launch-arg quirks (mapping B, exec.ts side). Mirrors
|
|
65
|
+
* the locals buildExecCommand already computed at the emission point.
|
|
66
|
+
*/
|
|
67
|
+
export interface ExecLaunchArgsCtx {
|
|
68
|
+
resolvedMode: Mode;
|
|
69
|
+
interactive: boolean;
|
|
70
|
+
cwd: string;
|
|
71
|
+
/** Extra writable roots (`--add-dir`) requested for this run, home-expanded. */
|
|
72
|
+
addDirs: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Context for the routine (daemon-job) launch-arg quirks (mapping B, runner.ts
|
|
76
|
+
* side). This idiom mutates a pre-baked token array from ROUTINE_AGENT_COMMANDS,
|
|
77
|
+
* distinct from buildExecCommand's declarative modeFlags — so it is a separate
|
|
78
|
+
* method on the same adapter, one source of truth per harness across both.
|
|
79
|
+
*/
|
|
80
|
+
export interface RoutineLaunchCtx {
|
|
81
|
+
/** normalizeMode(config.mode) — the canonicalized mode. */
|
|
82
|
+
mode: Mode;
|
|
83
|
+
config: JobConfig;
|
|
84
|
+
/**
|
|
85
|
+
* exec.ts resolveHeadlessMode, injected to avoid an import cycle (exec.ts
|
|
86
|
+
* imports this registry). Kimi calls it for its plan→auto downgrade warning.
|
|
87
|
+
*/
|
|
88
|
+
resolveHeadlessMode: (agent: AgentId, mode: Mode, interactive: boolean) => void;
|
|
89
|
+
}
|
|
90
|
+
export interface HarnessAdapter {
|
|
91
|
+
id: AgentId;
|
|
92
|
+
/**
|
|
93
|
+
* Apply this harness's config-dir env pins to the live process env for an
|
|
94
|
+
* `agents run` invocation (exec.ts buildExecEnv). Mutates `result` in place,
|
|
95
|
+
* exactly as the old per-agent branch did. The caller has already stripped the
|
|
96
|
+
* shared config-dir keys (CONFIG_DIR_ENV_KEYS), so an adapter only sets its own
|
|
97
|
+
* vars (plus any harness-specific extra it must delete, e.g. Claude's inherited
|
|
98
|
+
* OAuth token). Omitted for a harness with no config-dir env (the old `else`).
|
|
99
|
+
*/
|
|
100
|
+
applyExecConfigEnv?(result: NodeJS.ProcessEnv, ctx: ExecConfigEnvCtx): void;
|
|
101
|
+
/**
|
|
102
|
+
* The config-env bash block for this harness's generated shim (shims.ts). The
|
|
103
|
+
* returned string is spliced verbatim into the shim script. Omitted (⇒ '') for
|
|
104
|
+
* a harness with no managed config-dir env.
|
|
105
|
+
*/
|
|
106
|
+
shimConfigEnvBash?(ctx: ShimConfigEnvCtx): string;
|
|
107
|
+
/**
|
|
108
|
+
* Launch args appended to this harness's shim `exec` line (shims.ts). Codex
|
|
109
|
+
* pins `check_for_update_on_startup=false` + its edit-profile policy args here.
|
|
110
|
+
* Returns '' for a harness with no shim launch args.
|
|
111
|
+
*/
|
|
112
|
+
shimLaunchArgs?(): string;
|
|
113
|
+
/**
|
|
114
|
+
* The shim's `exec` tail for this harness (shims.ts). Codex resolves the repo's
|
|
115
|
+
* `.agents` dir from `$PWD` at run time and appends `--add-dir`. Omitted ⇒ the
|
|
116
|
+
* default `exec "$BINARY"<launchArgs> "$@"`.
|
|
117
|
+
*/
|
|
118
|
+
shimExecTail?(launchArgs: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Additive launch args emitted BEFORE mode-flag resolution in buildExecCommand
|
|
121
|
+
* (exec.ts). Cursor's `--trust` for a configured headless edit lives here.
|
|
122
|
+
* Returns undefined when this harness adds nothing.
|
|
123
|
+
*/
|
|
124
|
+
execPreModeArgs?(ctx: ExecLaunchArgsCtx): string[] | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* This harness's mode-flag emission for buildExecCommand (exec.ts), overriding
|
|
127
|
+
* the generic `template.modeFlags` / resume-subcommand path. Codex returns its
|
|
128
|
+
* policy args; Kimi returns [] for a headless run (and throws on an invariant
|
|
129
|
+
* violation). Returns undefined to defer to the generic path.
|
|
130
|
+
*/
|
|
131
|
+
execModeArgs?(ctx: ExecLaunchArgsCtx): string[] | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* This harness's routine (daemon-job) launch-arg quirks for buildJobCommand
|
|
134
|
+
* (runner.ts). Mutates the ROUTINE_AGENT_COMMANDS token array in place, exactly
|
|
135
|
+
* as the old per-agent arm did; runner appends model/reasoning flags after.
|
|
136
|
+
* Omitted for a harness with no routine launch quirks.
|
|
137
|
+
*/
|
|
138
|
+
routineModeArgs?(cmd: string[], ctx: RoutineLaunchCtx): void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The four config-dir env keys a harness pins to its version home. Every
|
|
142
|
+
* per-harness branch in the old buildExecEnv deleted the ones it does NOT set,
|
|
143
|
+
* so its own config pointer never leaks into a foreign harness's invocation.
|
|
144
|
+
* (XDG_CONFIG_HOME / XDG_DATA_HOME — Muse/Cursor — are deliberately absent: the
|
|
145
|
+
* old code sets them but never strips them, and this preserves that exactly.)
|
|
146
|
+
*/
|
|
147
|
+
export declare const CONFIG_DIR_ENV_KEYS: readonly ["CLAUDE_CONFIG_DIR", "CODEX_HOME", "COPILOT_HOME", "KIMI_CODE_HOME"];
|
|
148
|
+
/**
|
|
149
|
+
* Strip every config-dir env key except the one(s) this harness sets. `keep=[]`
|
|
150
|
+
* (the default / no-config-dir harness) deletes all four — the old `else` arm.
|
|
151
|
+
*/
|
|
152
|
+
export declare function stripForeignConfigDir(result: NodeJS.ProcessEnv, keep?: readonly string[]): void;
|
|
153
|
+
export declare function registerHarnessAdapter(adapter: HarnessAdapter): void;
|
|
154
|
+
/**
|
|
155
|
+
* The behavior adapter for a harness. Every `AgentId` resolves to an adapter —
|
|
156
|
+
* one with real behavior when registered, else the id-only default (the old
|
|
157
|
+
* `else` arm). Callers therefore never name-check a harness.
|
|
158
|
+
*/
|
|
159
|
+
export declare function resolveHarnessAdapter(id: AgentId): HarnessAdapter;
|
|
160
|
+
export declare function listHarnessAdapters(): AgentId[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The four config-dir env keys a harness pins to its version home. Every
|
|
3
|
+
* per-harness branch in the old buildExecEnv deleted the ones it does NOT set,
|
|
4
|
+
* so its own config pointer never leaks into a foreign harness's invocation.
|
|
5
|
+
* (XDG_CONFIG_HOME / XDG_DATA_HOME — Muse/Cursor — are deliberately absent: the
|
|
6
|
+
* old code sets them but never strips them, and this preserves that exactly.)
|
|
7
|
+
*/
|
|
8
|
+
export const CONFIG_DIR_ENV_KEYS = [
|
|
9
|
+
'CLAUDE_CONFIG_DIR',
|
|
10
|
+
'CODEX_HOME',
|
|
11
|
+
'COPILOT_HOME',
|
|
12
|
+
'KIMI_CODE_HOME',
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Strip every config-dir env key except the one(s) this harness sets. `keep=[]`
|
|
16
|
+
* (the default / no-config-dir harness) deletes all four — the old `else` arm.
|
|
17
|
+
*/
|
|
18
|
+
export function stripForeignConfigDir(result, keep = []) {
|
|
19
|
+
for (const key of CONFIG_DIR_ENV_KEYS) {
|
|
20
|
+
if (!keep.includes(key))
|
|
21
|
+
delete result[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const REGISTRY = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* The no-behavior adapter — a harness with no managed config-dir env and no
|
|
27
|
+
* launch-arg quirks. buildExecEnv strips all four config-dir keys for it (the old
|
|
28
|
+
* `else` arm) by falling back to {@link stripForeignConfigDir} when an adapter
|
|
29
|
+
* omits `applyExecConfigEnv`.
|
|
30
|
+
*/
|
|
31
|
+
function defaultAdapter(id) {
|
|
32
|
+
return { id };
|
|
33
|
+
}
|
|
34
|
+
export function registerHarnessAdapter(adapter) {
|
|
35
|
+
REGISTRY.set(adapter.id, adapter);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The behavior adapter for a harness. Every `AgentId` resolves to an adapter —
|
|
39
|
+
* one with real behavior when registered, else the id-only default (the old
|
|
40
|
+
* `else` arm). Callers therefore never name-check a harness.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveHarnessAdapter(id) {
|
|
43
|
+
return REGISTRY.get(id) ?? defaultAdapter(id);
|
|
44
|
+
}
|
|
45
|
+
export function listHarnessAdapters() {
|
|
46
|
+
return [...REGISTRY.keys()].sort();
|
|
47
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { stripForeignConfigDir } from '../adapter.js';
|
|
3
|
+
export const claudeAdapter = {
|
|
4
|
+
id: 'claude',
|
|
5
|
+
applyExecConfigEnv(result, ctx) {
|
|
6
|
+
const { versionHome } = ctx;
|
|
7
|
+
// The per-account `claude setup-token` only resolves when there is a version
|
|
8
|
+
// home to key it to; version===null (claude unresolved / not installed) yields
|
|
9
|
+
// null, exactly as the routines path treats it (`runner.ts:1017-1021`). The
|
|
10
|
+
// token decision below runs even then, so an ambient inherited value is stripped
|
|
11
|
+
// on the routines/provisioned path regardless of whether a version resolved.
|
|
12
|
+
// resolveClaudeSetupToken is injected (see ExecConfigEnvCtx) to keep this
|
|
13
|
+
// adapter import-leaf — importing claude-account-token here would drag the
|
|
14
|
+
// secrets/sqlite graph into shims.ts.
|
|
15
|
+
const setupToken = versionHome ? ctx.resolveClaudeSetupToken(versionHome) : null;
|
|
16
|
+
if (versionHome) {
|
|
17
|
+
result.CLAUDE_CONFIG_DIR = path.join(versionHome, '.claude');
|
|
18
|
+
// A managed pin lives in a per-version dir; Claude Code's own background
|
|
19
|
+
// auto-updater would rewrite that pinned binary in place (and has left it
|
|
20
|
+
// half-swapped and broken). Disable it so a pin stays a pin. Honor an
|
|
21
|
+
// explicit user value — from process.env (already in result) or from
|
|
22
|
+
// options.env (spread over result below).
|
|
23
|
+
if (result.DISABLE_AUTOUPDATER === undefined) {
|
|
24
|
+
result.DISABLE_AUTOUPDATER = '1';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// The `auth` bundle's setup-token exists so a run with NO human present
|
|
28
|
+
// authenticates without the Touch-ID-gated login item — usage probes,
|
|
29
|
+
// routines, dispatched runs (claude-account-token.ts). An interactive run
|
|
30
|
+
// has a human at the TTY, and their own per-version login is the credential
|
|
31
|
+
// they established and expect; overriding it made `/status` report
|
|
32
|
+
// `Auth token: CLAUDE_CODE_OAUTH_TOKEN` on a personal machine and took every
|
|
33
|
+
// hand-driven session off that login. macOS cannot cheaply confirm a home's
|
|
34
|
+
// login first (probing the Keychain raises an authorization sheet per
|
|
35
|
+
// installed version on the `agents run` hot path — agents.ts
|
|
36
|
+
// `isClaudeCredentialFileBlank`), so interactive simply defers to Claude
|
|
37
|
+
// Code, which prompts a present human to log in if the login is missing.
|
|
38
|
+
if (ctx.interactive) {
|
|
39
|
+
// Drop an INHERITED copy of OUR OWN setup-token: an interactive launch from
|
|
40
|
+
// inside a headless agent's shell inherits that agent's injected value via
|
|
41
|
+
// sanitizeProcessEnv(process.env) and would keep authenticating as it.
|
|
42
|
+
// Matched by VALUE, so a token the user exported deliberately is a different
|
|
43
|
+
// string and is left alone (#2383). This is NARROWER than the non-interactive
|
|
44
|
+
// path below, which overwrites-or-deletes unconditionally and never inspects
|
|
45
|
+
// the inherited value — a DIFFERENT account's inherited setup-token passing
|
|
46
|
+
// through this equality check is the adjacent hole RUSH-2360 leaves as
|
|
47
|
+
// follow-up (it does not silently run on a *shared, rotating* token, which is
|
|
48
|
+
// what caused the RUSH-1822 logout storm).
|
|
49
|
+
if (setupToken && result.CLAUDE_CODE_OAUTH_TOKEN === setupToken) {
|
|
50
|
+
delete result.CLAUDE_CODE_OAUTH_TOKEN;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Non-interactive (routines, dispatched, provisioned box): mirror the routines
|
|
55
|
+
// path (`runner.ts:1017-1021`) UNCONDITIONALLY. Inject the per-account
|
|
56
|
+
// setup-token when one resolves — it replaces any ambient shared value
|
|
57
|
+
// inherited from the launcher. When NONE resolves, STRIP the ambient
|
|
58
|
+
// CLAUDE_CODE_OAUTH_TOKEN so a run on a provisioned box can never silently
|
|
59
|
+
// authenticate as the shared, rotating token an earlier version of this path
|
|
60
|
+
// let through — the RUSH-1822 fleet-wide-logout hazard, tracked by RUSH-2360.
|
|
61
|
+
// A missing login then fails loud (401) against this home's own credential
|
|
62
|
+
// instead of quietly borrowing another's. options.env still wins below for an
|
|
63
|
+
// explicit caller override.
|
|
64
|
+
if (setupToken) {
|
|
65
|
+
result.CLAUDE_CODE_OAUTH_TOKEN = setupToken;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
delete result.CLAUDE_CODE_OAUTH_TOKEN;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
stripForeignConfigDir(result, ['CLAUDE_CONFIG_DIR']);
|
|
72
|
+
},
|
|
73
|
+
shimConfigEnvBash(ctx) {
|
|
74
|
+
return `
|
|
75
|
+
# Claude stores OAuth credentials in the macOS keychain. Scope them to the
|
|
76
|
+
# selected version's config directory so switching versions also switches the
|
|
77
|
+
# live Claude account.
|
|
78
|
+
export CLAUDE_CONFIG_DIR="$VERSION_DIR/home/${ctx.configDirName}"
|
|
79
|
+
# Managed installs are pinned in a per-version dir; Claude Code's background
|
|
80
|
+
# auto-updater would rewrite the pinned binary in place. Disable it so a pin
|
|
81
|
+
# stays a pin. An explicit user value always wins.
|
|
82
|
+
export DISABLE_AUTOUPDATER="\${DISABLE_AUTOUPDATER:-1}"
|
|
83
|
+
# On Linux sandboxes (no keychain), fall back to a per-version token file.
|
|
84
|
+
# The env var always wins if already set; no-op on macOS.
|
|
85
|
+
if [ "\$(uname -s)" = "Linux" ] && [ -z "\${CLAUDE_CODE_OAUTH_TOKEN:-}" ] && [ -f "\$CLAUDE_CONFIG_DIR/.oauth_token" ]; then
|
|
86
|
+
CLAUDE_CODE_OAUTH_TOKEN=\$(cat "\$CLAUDE_CONFIG_DIR/.oauth_token")
|
|
87
|
+
export CLAUDE_CODE_OAUTH_TOKEN
|
|
88
|
+
fi
|
|
89
|
+
`;
|
|
90
|
+
},
|
|
91
|
+
routineModeArgs(cmd, ctx) {
|
|
92
|
+
const mode = ctx.mode;
|
|
93
|
+
if (mode === 'edit') {
|
|
94
|
+
const planIndex = cmd.indexOf('plan');
|
|
95
|
+
if (planIndex !== -1)
|
|
96
|
+
cmd[planIndex] = 'acceptEdits';
|
|
97
|
+
}
|
|
98
|
+
else if (mode === 'auto') {
|
|
99
|
+
const planIndex = cmd.indexOf('plan');
|
|
100
|
+
if (planIndex !== -1)
|
|
101
|
+
cmd[planIndex] = 'auto';
|
|
102
|
+
}
|
|
103
|
+
else if (mode === 'skip') {
|
|
104
|
+
// Replace --permission-mode plan with --dangerously-skip-permissions
|
|
105
|
+
const pmIndex = cmd.indexOf('--permission-mode');
|
|
106
|
+
if (pmIndex !== -1)
|
|
107
|
+
cmd.splice(pmIndex, 2, '--dangerously-skip-permissions');
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as os from 'os';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { getHistoryDir } from '../../state.js';
|
|
4
|
+
import { resolveCodexHome, codexHomeShimBash } from '../../codex-home.js';
|
|
5
|
+
import { codexEditWritableRoots, codexPolicyArgs } from '../../codex-policy.js';
|
|
6
|
+
import { stripForeignConfigDir } from '../adapter.js';
|
|
7
|
+
/**
|
|
8
|
+
* Shim-script single-quoting — identical to the local `shellQuote` in shims.ts
|
|
9
|
+
* (always wraps in single quotes), NOT ssh-exec's variant (which leaves
|
|
10
|
+
* shell-safe strings unquoted). The generated shim's codex launch args must stay
|
|
11
|
+
* byte-for-byte what shims.ts produced, so the quoting moves with the logic.
|
|
12
|
+
*/
|
|
13
|
+
function shimShellQuote(value) {
|
|
14
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
15
|
+
}
|
|
16
|
+
export const codexAdapter = {
|
|
17
|
+
id: 'codex',
|
|
18
|
+
applyExecConfigEnv(result, ctx) {
|
|
19
|
+
if (ctx.version && ctx.versionHome) {
|
|
20
|
+
// On macOS the deep versioned home overflows the Unix-socket SUN_LEN
|
|
21
|
+
// limit for codex's app-server control socket; resolve to a short,
|
|
22
|
+
// SUN_LEN-safe home (migrating once if needed). See codex-home.ts.
|
|
23
|
+
const versionedHome = path.join(ctx.versionHome, '.codex');
|
|
24
|
+
const agentsUserDir = path.dirname(getHistoryDir());
|
|
25
|
+
result.CODEX_HOME = resolveCodexHome(versionedHome, agentsUserDir, ctx.version);
|
|
26
|
+
}
|
|
27
|
+
stripForeignConfigDir(result, ['CODEX_HOME']);
|
|
28
|
+
},
|
|
29
|
+
shimConfigEnvBash(ctx) {
|
|
30
|
+
return codexHomeShimBash(`$VERSION_DIR/home/${ctx.configDirName}`, `$AGENTS_USER_DIR/.codex-homes/$VERSION`);
|
|
31
|
+
},
|
|
32
|
+
shimLaunchArgs() {
|
|
33
|
+
return ` ${[
|
|
34
|
+
'-c',
|
|
35
|
+
'check_for_update_on_startup=false',
|
|
36
|
+
...codexPolicyArgs('edit'),
|
|
37
|
+
].map(shimShellQuote).join(' ')}`;
|
|
38
|
+
},
|
|
39
|
+
shimExecTail(launchArgs) {
|
|
40
|
+
// Codex is special: its `workspace-write` sandbox hardcodes any `.agents/`
|
|
41
|
+
// (and `.codex/`) directory read-only, but agents-cli keeps every worktree at
|
|
42
|
+
// `<repo>/.agents/worktrees/<slug>`, so an in-repo build under a static shim
|
|
43
|
+
// would hit `EROFS`. The shim resolves the repo's `.agents` from `$PWD` at RUN
|
|
44
|
+
// time — worktree-aware, mirroring repoAgentsDirForCwd — and passes it via
|
|
45
|
+
// Codex's own `--add-dir`. `--add-dir` is added only when the resolved
|
|
46
|
+
// `.agents` exists.
|
|
47
|
+
return `_repo_agents=""
|
|
48
|
+
case "$PWD" in
|
|
49
|
+
*/.agents/worktrees/*) _repo_agents="\${PWD%%/.agents/worktrees/*}/.agents" ;;
|
|
50
|
+
*)
|
|
51
|
+
_d="$PWD"
|
|
52
|
+
# Stop before $HOME so a dotfiles repo at $HOME is not treated as the project
|
|
53
|
+
# root (mirrors repoRootForCwd's home exclusion in project-key.ts).
|
|
54
|
+
while [ -n "$_d" ] && [ "$_d" != "/" ] && [ "$_d" != "$HOME" ]; do
|
|
55
|
+
if [ -e "$_d/.git" ]; then _repo_agents="$_d/.agents"; break; fi
|
|
56
|
+
_d=$(dirname "$_d")
|
|
57
|
+
done
|
|
58
|
+
;;
|
|
59
|
+
esac
|
|
60
|
+
if [ -n "$_repo_agents" ] && [ -d "$_repo_agents" ]; then
|
|
61
|
+
exec "$BINARY"${launchArgs} --add-dir "$_repo_agents" "$@"
|
|
62
|
+
fi
|
|
63
|
+
exec "$BINARY"${launchArgs} "$@"`;
|
|
64
|
+
},
|
|
65
|
+
execModeArgs(ctx) {
|
|
66
|
+
const policyMode = ctx.resolvedMode === 'plan' || ctx.resolvedMode === 'skip' ? ctx.resolvedMode : 'edit';
|
|
67
|
+
const writableRoots = [
|
|
68
|
+
...codexEditWritableRoots(ctx.cwd),
|
|
69
|
+
...ctx.addDirs,
|
|
70
|
+
];
|
|
71
|
+
return codexPolicyArgs(policyMode, writableRoots);
|
|
72
|
+
},
|
|
73
|
+
routineModeArgs(cmd, ctx) {
|
|
74
|
+
const policyMode = ctx.mode === 'plan' || ctx.mode === 'skip' ? ctx.mode : 'edit';
|
|
75
|
+
const routineRoots = (ctx.config.allow?.dirs ?? []).map((dir) => {
|
|
76
|
+
if (dir.startsWith('-')) {
|
|
77
|
+
throw new Error(`allow.dirs entries must not start with '-': ${JSON.stringify(dir)}`);
|
|
78
|
+
}
|
|
79
|
+
return dir.replace(/^~/, os.homedir());
|
|
80
|
+
});
|
|
81
|
+
cmd.push(...codexPolicyArgs(policyMode, [...codexEditWritableRoots(), ...routineRoots]));
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { stripForeignConfigDir } from '../adapter.js';
|
|
3
|
+
export const copilotAdapter = {
|
|
4
|
+
id: 'copilot',
|
|
5
|
+
// Copilot honors COPILOT_HOME (relocates ~/.copilot, including settings,
|
|
6
|
+
// mcp-config.json, sessions, logs). Pin it at the per-version home so
|
|
7
|
+
// version switches isolate MCP servers, auth, and session history.
|
|
8
|
+
applyExecConfigEnv(result, ctx) {
|
|
9
|
+
if (ctx.versionHome) {
|
|
10
|
+
result.COPILOT_HOME = path.join(ctx.versionHome, '.copilot');
|
|
11
|
+
}
|
|
12
|
+
stripForeignConfigDir(result, ['COPILOT_HOME']);
|
|
13
|
+
},
|
|
14
|
+
shimConfigEnvBash(ctx) {
|
|
15
|
+
return `
|
|
16
|
+
# GitHub Copilot CLI honors COPILOT_HOME to relocate its config and state
|
|
17
|
+
# (settings.json, mcp-config.json, session-state/, logs/, plugins/). Point
|
|
18
|
+
# it at the versioned home so MCP servers, custom agents, and session
|
|
19
|
+
# history are isolated per copilot version.
|
|
20
|
+
export COPILOT_HOME="$VERSION_DIR/home/${ctx.configDirName}"
|
|
21
|
+
`;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { stripForeignConfigDir } from '../adapter.js';
|
|
3
|
+
export const cursorAdapter = {
|
|
4
|
+
id: 'cursor',
|
|
5
|
+
// Cursor has no config-dir env var (only CURSOR_API_KEY / CURSOR_API_ENDPOINT).
|
|
6
|
+
// Its OAuth token — the login gate — lives at $XDG_CONFIG_HOME/cursor/auth.json
|
|
7
|
+
// (verified empirically: relocating XDG_CONFIG_HOME relocates the login;
|
|
8
|
+
// ~/.cursor/cli-config.json holds only account metadata, not the token). Pin
|
|
9
|
+
// XDG_CONFIG_HOME into the version home so each installed Cursor account
|
|
10
|
+
// authenticates from its own token, isolated per run — no global ~/.cursor
|
|
11
|
+
// symlink swap, so concurrent runs on different accounts never clobber one
|
|
12
|
+
// another. cli-config.json (HOME-relative) has no override and stays on the
|
|
13
|
+
// shared home; only the token is per-account, which is what gates the login.
|
|
14
|
+
applyExecConfigEnv(result, ctx) {
|
|
15
|
+
if (ctx.versionHome) {
|
|
16
|
+
result.XDG_CONFIG_HOME = path.join(ctx.versionHome, '.config');
|
|
17
|
+
}
|
|
18
|
+
stripForeignConfigDir(result);
|
|
19
|
+
},
|
|
20
|
+
execPreModeArgs(ctx) {
|
|
21
|
+
// A configured headless run is the workspace trust decision. Keep this
|
|
22
|
+
// narrower than --yolo/-f, which also bypasses permission checks.
|
|
23
|
+
return ctx.resolvedMode === 'edit' && !ctx.interactive ? ['--trust'] : undefined;
|
|
24
|
+
},
|
|
25
|
+
routineModeArgs(cmd, ctx) {
|
|
26
|
+
if (ctx.mode === 'plan') {
|
|
27
|
+
cmd.push('--plan');
|
|
28
|
+
}
|
|
29
|
+
else if (ctx.mode === 'skip') {
|
|
30
|
+
cmd.push('-f');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// The configured cwd is the user's workspace trust decision. --trust is
|
|
34
|
+
// narrower than --yolo/-f because it does not bypass tool permissions.
|
|
35
|
+
cmd.push('--trust');
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Droid has no config-dir env pin (exec strips the foreign keys via the registry
|
|
2
|
+
// fallback) and no shim config env. Its only harness quirk is routine autonomy.
|
|
3
|
+
export const droidAdapter = {
|
|
4
|
+
id: 'droid',
|
|
5
|
+
// droid exec defaults to read-only (plan). Escalate autonomy per mode.
|
|
6
|
+
routineModeArgs(cmd, ctx) {
|
|
7
|
+
if (ctx.mode === 'edit') {
|
|
8
|
+
cmd.push('--auto', 'low');
|
|
9
|
+
}
|
|
10
|
+
else if (ctx.mode === 'auto') {
|
|
11
|
+
cmd.push('--auto', 'high');
|
|
12
|
+
}
|
|
13
|
+
else if (ctx.mode === 'skip') {
|
|
14
|
+
cmd.push('--skip-permissions-unsafe');
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Grok has no exec-time config-dir env pin (buildExecEnv's `else` strips the
|
|
2
|
+
// foreign keys — the registry fallback preserves that). It DOES relocate its
|
|
3
|
+
// whole config tree via GROK_HOME in the generated shim.
|
|
4
|
+
export const grokAdapter = {
|
|
5
|
+
id: 'grok',
|
|
6
|
+
shimConfigEnvBash() {
|
|
7
|
+
return `
|
|
8
|
+
# Grok Build uses GROK_HOME to isolate its entire configuration tree
|
|
9
|
+
# (skills, hooks, plugins, agents, memory, sessions, config.toml, MCP, etc.).
|
|
10
|
+
# This gives agents-cli full versioned isolation + resource sync for grok.
|
|
11
|
+
export GROK_HOME="$VERSION_DIR/home/.grok"
|
|
12
|
+
`;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { stripForeignConfigDir } from '../adapter.js';
|
|
3
|
+
export const kimiAdapter = {
|
|
4
|
+
id: 'kimi',
|
|
5
|
+
// Kimi honors KIMI_CODE_HOME (relocates ~/.kimi-code, including config,
|
|
6
|
+
// skills, hooks, sessions). Pin it at the per-version home.
|
|
7
|
+
applyExecConfigEnv(result, ctx) {
|
|
8
|
+
if (ctx.versionHome) {
|
|
9
|
+
result.KIMI_CODE_HOME = path.join(ctx.versionHome, '.kimi-code');
|
|
10
|
+
}
|
|
11
|
+
stripForeignConfigDir(result, ['KIMI_CODE_HOME']);
|
|
12
|
+
},
|
|
13
|
+
shimConfigEnvBash(ctx) {
|
|
14
|
+
return `
|
|
15
|
+
# Kimi Code CLI honors KIMI_CODE_HOME to relocate ~/.kimi-code (config.toml,
|
|
16
|
+
# mcp.json, sessions, skills, hooks). Point it at the versioned home.
|
|
17
|
+
export KIMI_CODE_HOME="$VERSION_DIR/home/${ctx.configDirName}"
|
|
18
|
+
`;
|
|
19
|
+
},
|
|
20
|
+
execModeArgs(ctx) {
|
|
21
|
+
// kimi's headless prompt mode (`-p`/`--prompt`) is self-contained and REFUSES
|
|
22
|
+
// to be combined with any startup-mode flag: `--plan`, `--auto`, and `--yolo`
|
|
23
|
+
// all abort with "Cannot combine --prompt with --X" (verified against the live
|
|
24
|
+
// kimi CLI). The write-capable modes (edit/auto/skip) all collapse to kimi's
|
|
25
|
+
// default `-p` behavior, which already auto-approves tool calls, so we emit no
|
|
26
|
+
// mode flag. An interactive kimi run defers to the generic modeFlags path.
|
|
27
|
+
if (ctx.interactive)
|
|
28
|
+
return undefined;
|
|
29
|
+
// Plan can't reach here headless — resolveHeadlessMode already downgraded it to
|
|
30
|
+
// auto (kimi's headlessPlan:false); this asserts that invariant so a plan-mode
|
|
31
|
+
// run can never silently mutate the workspace.
|
|
32
|
+
if (ctx.resolvedMode === 'plan') {
|
|
33
|
+
throw new Error(`Internal error: kimi reached headless command build with resolved mode 'plan'; ` +
|
|
34
|
+
`resolveHeadlessMode should have downgraded it to auto (capabilities.headlessPlan is false).`);
|
|
35
|
+
}
|
|
36
|
+
// edit/auto/skip: emit no mode flag — `kimi -p` auto-runs.
|
|
37
|
+
return [];
|
|
38
|
+
},
|
|
39
|
+
routineModeArgs(_cmd, ctx) {
|
|
40
|
+
// kimi daemon jobs always run headless via `--prompt`, which cannot be
|
|
41
|
+
// combined with any startup-mode flag (--plan/--auto/--yolo all abort with
|
|
42
|
+
// "Cannot combine --prompt with --X"). edit/auto/skip reduce to kimi's default
|
|
43
|
+
// headless auto-run, so emit no flag. plan has no headless read-only
|
|
44
|
+
// equivalent, so resolveHeadlessMode downgrades a plan request to auto with a
|
|
45
|
+
// stderr warning (kimi's headlessPlan is false) — routines run headless, so
|
|
46
|
+
// interactive is always false here. The returned mode carries no flag either.
|
|
47
|
+
ctx.resolveHeadlessMode('kimi', ctx.mode, false);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { stripForeignConfigDir } from '../adapter.js';
|
|
3
|
+
export const museAdapter = {
|
|
4
|
+
id: 'muse',
|
|
5
|
+
// Muse has no MUSE_CONFIG_DIR. Config is XDG-based:
|
|
6
|
+
// $XDG_CONFIG_HOME/muse (settings, skills, hooks, auth)
|
|
7
|
+
// $XDG_DATA_HOME/muse (sessions, plugins)
|
|
8
|
+
// Pin both into the version home so multi-version isolation matches
|
|
9
|
+
// Claude's CLAUDE_CONFIG_DIR / Codex's CODEX_HOME, and so Muse never
|
|
10
|
+
// resolves through the adopt-time ~/.config/muse symlink (SymlinkOrReparse).
|
|
11
|
+
applyExecConfigEnv(result, ctx) {
|
|
12
|
+
if (ctx.versionHome) {
|
|
13
|
+
result.XDG_CONFIG_HOME = path.join(ctx.versionHome, '.config');
|
|
14
|
+
result.XDG_DATA_HOME = path.join(ctx.versionHome, '.local', 'share');
|
|
15
|
+
}
|
|
16
|
+
stripForeignConfigDir(result);
|
|
17
|
+
},
|
|
18
|
+
shimConfigEnvBash() {
|
|
19
|
+
return `
|
|
20
|
+
# Muse Code has no MUSE_CONFIG_DIR. It resolves config via XDG:
|
|
21
|
+
# $XDG_CONFIG_HOME/muse (settings, skills, hooks, auth)
|
|
22
|
+
# $XDG_DATA_HOME/muse (sessions, plugins)
|
|
23
|
+
# Pin XDG into the version home so managed runs never walk the adopt-time
|
|
24
|
+
# ~/.config/muse -> version-home symlink — Muse refuses agent-definition
|
|
25
|
+
# sources that are SymlinkOrReparse (exit 1). Same idea as CLAUDE_CONFIG_DIR.
|
|
26
|
+
export XDG_CONFIG_HOME="$VERSION_DIR/home/.config"
|
|
27
|
+
export XDG_DATA_HOME="$VERSION_DIR/home/.local/share"
|
|
28
|
+
`;
|
|
29
|
+
},
|
|
30
|
+
// muse exec: plan ≈ no non-shell writes; auto skips approval prompts but
|
|
31
|
+
// keeps the OS sandbox; skip is --yolo (no approval, no sandbox, trust).
|
|
32
|
+
routineModeArgs(cmd, ctx) {
|
|
33
|
+
if (ctx.mode === 'plan') {
|
|
34
|
+
cmd.push('--disable-write');
|
|
35
|
+
}
|
|
36
|
+
else if (ctx.mode === 'auto') {
|
|
37
|
+
cmd.push('--disable-approval');
|
|
38
|
+
}
|
|
39
|
+
else if (ctx.mode === 'skip') {
|
|
40
|
+
cmd.push('--yolo');
|
|
41
|
+
}
|
|
42
|
+
// edit: default on-request approval + sandbox
|
|
43
|
+
},
|
|
44
|
+
};
|