@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
|
@@ -11,13 +11,13 @@ import * as fs from 'fs';
|
|
|
11
11
|
import * as path from 'path';
|
|
12
12
|
import * as os from 'os';
|
|
13
13
|
import { getDaemonDir } from '../state.js';
|
|
14
|
-
import { isolatedHomeSuffix, namespacedServiceLabel, serviceManifestHomeEnv } from '../service-manifest.js';
|
|
14
|
+
import { isolatedHomeSuffix, namespacedServiceLabel, serviceManifestHomeEnv, serviceManagerRegistrationAllowed } from '../service-manifest.js';
|
|
15
15
|
import { isAlive, killTree, backgroundSpawnOptions, waitForExit } from '../platform/index.js';
|
|
16
16
|
import { listJobs as listAllJobs } from '../scheduling/routines.js';
|
|
17
17
|
import { syncAllProjectRoutines } from '../routines-project.js';
|
|
18
18
|
import { JobScheduler } from '../scheduler.js';
|
|
19
19
|
import { MonitorEngine } from '../monitors/engine.js';
|
|
20
|
-
import { executeJobDetached, monitorRunningJobs, listLiveRoutineChildren } from '
|
|
20
|
+
import { executeJobDetached, monitorRunningJobs, listLiveRoutineChildren } from './runner.js';
|
|
21
21
|
import { detectOverdueJobs, notifyOverdue } from '../overdue.js';
|
|
22
22
|
import { runCatchup } from '../catchup.js';
|
|
23
23
|
import { notifyRoutineStart, notifyRoutineFinish, notifyRoutineStartFailed } from '../routine-notify.js';
|
|
@@ -1763,6 +1763,9 @@ export { getAgentsBinPath };
|
|
|
1763
1763
|
* in fact up. Returns null when the service isn't running or the query fails.
|
|
1764
1764
|
*/
|
|
1765
1765
|
function readServiceManagerPid(platform = os.platform()) {
|
|
1766
|
+
const reg = serviceManagerRegistrationAllowed();
|
|
1767
|
+
if (!reg.allowed)
|
|
1768
|
+
return null;
|
|
1766
1769
|
try {
|
|
1767
1770
|
if (platform === 'linux') {
|
|
1768
1771
|
const out = execFileSync('systemctl', ['--user', 'show', '-p', 'MainPID', '--value', daemonSystemdUnitName()], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
@@ -1912,61 +1915,72 @@ function startDaemonLocked(agentsBin, releaseLock) {
|
|
|
1912
1915
|
releaseLock();
|
|
1913
1916
|
return startDetached({ agentsBin });
|
|
1914
1917
|
};
|
|
1918
|
+
const reg = serviceManagerRegistrationAllowed();
|
|
1915
1919
|
if (platform === 'darwin') {
|
|
1916
|
-
|
|
1917
|
-
const plistPath = getLaunchdPlistPath();
|
|
1918
|
-
const plistDir = path.dirname(plistPath);
|
|
1919
|
-
if (!fs.existsSync(plistDir)) {
|
|
1920
|
-
fs.mkdirSync(plistDir, { recursive: true });
|
|
1921
|
-
}
|
|
1922
|
-
// The plist carries no credential (RUSH-1759 — the daemon reads the OAuth
|
|
1923
|
-
// token itself at startup); still create owner-only atomically to match the
|
|
1924
|
-
// detached path and keep the log/PATH surface owner-private.
|
|
1925
|
-
writeOwnerOnlyServiceManifest(plistPath, generateLaunchdPlist(agentsBin));
|
|
1920
|
+
if (reg.allowed) {
|
|
1926
1921
|
try {
|
|
1927
|
-
|
|
1922
|
+
const plistPath = getLaunchdPlistPath();
|
|
1923
|
+
const plistDir = path.dirname(plistPath);
|
|
1924
|
+
if (!fs.existsSync(plistDir)) {
|
|
1925
|
+
fs.mkdirSync(plistDir, { recursive: true });
|
|
1926
|
+
}
|
|
1927
|
+
// The plist carries no credential (RUSH-1759 — the daemon reads the OAuth
|
|
1928
|
+
// token itself at startup); still create owner-only atomically to match the
|
|
1929
|
+
// detached path and keep the log/PATH surface owner-private.
|
|
1930
|
+
writeOwnerOnlyServiceManifest(plistPath, generateLaunchdPlist(agentsBin));
|
|
1931
|
+
try {
|
|
1932
|
+
execFileSync('launchctl', ['unload', plistPath], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
1933
|
+
}
|
|
1934
|
+
catch { /* not loaded, expected */ }
|
|
1935
|
+
// launchctl prints `Load failed:` and exits 0 when the label is in a
|
|
1936
|
+
// stuck state from a prior session — so a zero exit code isn't proof
|
|
1937
|
+
// of success. If no pid materializes within the window, give up on
|
|
1938
|
+
// launchd and fall through to a plain detached spawn.
|
|
1939
|
+
execFileSync('launchctl', ['load', plistPath], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
1940
|
+
// Launch issued — the child needs this lock to claim (RUSH-2417).
|
|
1941
|
+
releaseLock();
|
|
1942
|
+
const pid = waitForPid(3000) ?? readServiceManagerPid();
|
|
1943
|
+
if (pid)
|
|
1944
|
+
return { pid, method: 'launchd' };
|
|
1945
|
+
// launchctl claimed success but nothing ran. Fall through.
|
|
1946
|
+
}
|
|
1947
|
+
catch {
|
|
1948
|
+
// load threw — fall through to detached spawn
|
|
1928
1949
|
}
|
|
1929
|
-
catch { /* not loaded, expected */ }
|
|
1930
|
-
// launchctl prints `Load failed:` and exits 0 when the label is in a
|
|
1931
|
-
// stuck state from a prior session — so a zero exit code isn't proof
|
|
1932
|
-
// of success. If no pid materializes within the window, give up on
|
|
1933
|
-
// launchd and fall through to a plain detached spawn.
|
|
1934
|
-
execFileSync('launchctl', ['load', plistPath], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
1935
|
-
// Launch issued — the child needs this lock to claim (RUSH-2417).
|
|
1936
|
-
releaseLock();
|
|
1937
|
-
const pid = waitForPid(3000) ?? readServiceManagerPid();
|
|
1938
|
-
if (pid)
|
|
1939
|
-
return { pid, method: 'launchd' };
|
|
1940
|
-
// launchctl claimed success but nothing ran. Fall through.
|
|
1941
1950
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1951
|
+
else {
|
|
1952
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
1944
1953
|
}
|
|
1945
1954
|
return detachedFallback();
|
|
1946
1955
|
}
|
|
1947
1956
|
if (platform === 'linux') {
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
fs.
|
|
1957
|
+
if (reg.allowed) {
|
|
1958
|
+
try {
|
|
1959
|
+
const unitPath = getSystemdUnitPath();
|
|
1960
|
+
const unitDir = path.dirname(unitPath);
|
|
1961
|
+
if (!fs.existsSync(unitDir)) {
|
|
1962
|
+
fs.mkdirSync(unitDir, { recursive: true });
|
|
1963
|
+
}
|
|
1964
|
+
// Carries no credential (RUSH-1759 — the daemon reads the OAuth token
|
|
1965
|
+
// itself at startup); owner-only to keep the PATH/log surface private.
|
|
1966
|
+
writeOwnerOnlyServiceManifest(unitPath, generateSystemdUnit(agentsBin));
|
|
1967
|
+
execFileSync('systemctl', ['--user', 'daemon-reload'], { encoding: 'utf-8' });
|
|
1968
|
+
execFileSync('systemctl', ['--user', 'enable', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
1969
|
+
execFileSync('systemctl', ['--user', 'start', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
1970
|
+
// Launch issued — the child needs this lock to claim (RUSH-2417).
|
|
1971
|
+
releaseLock();
|
|
1972
|
+
const pid = waitForPid(3000) ?? readServiceManagerPid();
|
|
1973
|
+
if (pid)
|
|
1974
|
+
return { pid, method: 'systemd' };
|
|
1975
|
+
// systemctl returned success but no PID surfaced — fall through to a
|
|
1976
|
+
// plain detached spawn rather than reporting a null PID.
|
|
1977
|
+
}
|
|
1978
|
+
catch {
|
|
1979
|
+
// start threw — fall through to detached spawn
|
|
1953
1980
|
}
|
|
1954
|
-
// Carries no credential (RUSH-1759 — the daemon reads the OAuth token
|
|
1955
|
-
// itself at startup); owner-only to keep the PATH/log surface private.
|
|
1956
|
-
writeOwnerOnlyServiceManifest(unitPath, generateSystemdUnit(agentsBin));
|
|
1957
|
-
execFileSync('systemctl', ['--user', 'daemon-reload'], { encoding: 'utf-8' });
|
|
1958
|
-
execFileSync('systemctl', ['--user', 'enable', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
1959
|
-
execFileSync('systemctl', ['--user', 'start', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
1960
|
-
// Launch issued — the child needs this lock to claim (RUSH-2417).
|
|
1961
|
-
releaseLock();
|
|
1962
|
-
const pid = waitForPid(3000) ?? readServiceManagerPid();
|
|
1963
|
-
if (pid)
|
|
1964
|
-
return { pid, method: 'systemd' };
|
|
1965
|
-
// systemctl returned success but no PID surfaced — fall through to a
|
|
1966
|
-
// plain detached spawn rather than reporting a null PID.
|
|
1967
1981
|
}
|
|
1968
|
-
|
|
1969
|
-
|
|
1982
|
+
else {
|
|
1983
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
1970
1984
|
}
|
|
1971
1985
|
return detachedFallback();
|
|
1972
1986
|
}
|
|
@@ -2261,29 +2275,43 @@ export function stopDaemon() {
|
|
|
2261
2275
|
const released = [];
|
|
2262
2276
|
const surviving = [];
|
|
2263
2277
|
let escalated = false;
|
|
2278
|
+
const reg = serviceManagerRegistrationAllowed();
|
|
2264
2279
|
if (platform === 'darwin') {
|
|
2265
2280
|
const plistPath = getLaunchdPlistPath();
|
|
2266
2281
|
if (fs.existsSync(plistPath)) {
|
|
2282
|
+
if (reg.allowed) {
|
|
2283
|
+
try {
|
|
2284
|
+
execFileSync('launchctl', ['unload', plistPath], { encoding: 'utf-8' });
|
|
2285
|
+
}
|
|
2286
|
+
catch (err) {
|
|
2287
|
+
if (process.env.AGENTS_DEBUG) {
|
|
2288
|
+
console.error(`[debug] launchctl unload failed: ${err.message}`);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
else {
|
|
2293
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
2294
|
+
}
|
|
2267
2295
|
try {
|
|
2268
|
-
execFileSync('launchctl', ['unload', plistPath], { encoding: 'utf-8' });
|
|
2269
2296
|
fs.unlinkSync(plistPath);
|
|
2270
2297
|
}
|
|
2298
|
+
catch { /* plist already removed */ }
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
if (platform === 'linux') {
|
|
2302
|
+
if (reg.allowed) {
|
|
2303
|
+
try {
|
|
2304
|
+
execFileSync('systemctl', ['--user', 'stop', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
2305
|
+
execFileSync('systemctl', ['--user', 'disable', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
2306
|
+
}
|
|
2271
2307
|
catch (err) {
|
|
2272
2308
|
if (process.env.AGENTS_DEBUG) {
|
|
2273
|
-
console.error(`[debug]
|
|
2309
|
+
console.error(`[debug] systemctl stop failed: ${err.message}`);
|
|
2274
2310
|
}
|
|
2275
2311
|
}
|
|
2276
2312
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
try {
|
|
2280
|
-
execFileSync('systemctl', ['--user', 'stop', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
2281
|
-
execFileSync('systemctl', ['--user', 'disable', daemonSystemdUnitName()], { encoding: 'utf-8' });
|
|
2282
|
-
}
|
|
2283
|
-
catch (err) {
|
|
2284
|
-
if (process.env.AGENTS_DEBUG) {
|
|
2285
|
-
console.error(`[debug] systemctl stop failed: ${err.message}`);
|
|
2286
|
-
}
|
|
2313
|
+
else {
|
|
2314
|
+
process.stderr.write(`[agents] ${reg.reason}\n`);
|
|
2287
2315
|
}
|
|
2288
2316
|
const unitPath = getSystemdUnitPath();
|
|
2289
2317
|
if (fs.existsSync(unitPath)) {
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
* limit is detected mid-run (foreground `executeJob` only — detached daemon
|
|
14
14
|
* fires once with the pre-flight pick).
|
|
15
15
|
*/
|
|
16
|
-
import type { JobConfig, RunMeta } from '
|
|
17
|
-
import { readMeta } from '
|
|
18
|
-
import type { AgentId } from '
|
|
19
|
-
import { type FallbackEntry } from '
|
|
20
|
-
import type { LoopDeps } from '
|
|
21
|
-
import { resolveRunVersion, resolveAccountVersion, type RotateResult } from '
|
|
16
|
+
import type { JobConfig, RunMeta } from '../scheduling/routines.js';
|
|
17
|
+
import { readMeta } from '../state.js';
|
|
18
|
+
import type { AgentId } from '../types.js';
|
|
19
|
+
import { type FallbackEntry } from '../exec.js';
|
|
20
|
+
import type { LoopDeps } from '../loop.js';
|
|
21
|
+
import { resolveRunVersion, resolveAccountVersion, type RotateResult } from '../accounting/rotate.js';
|
|
22
22
|
/** Result of a completed job execution, including metadata and optional report. */
|
|
23
23
|
export interface RunResult {
|
|
24
24
|
meta: RunMeta;
|
|
@@ -74,6 +74,23 @@ interface RoutineAttempt {
|
|
|
74
74
|
* but the gate should have paused such a routine before it ever spawned.
|
|
75
75
|
*/
|
|
76
76
|
export declare function routineSpawnCwd(config: Pick<JobConfig, 'name' | 'project' | 'cwd' | 'agent' | 'workflow' | 'command'>): string;
|
|
77
|
+
/**
|
|
78
|
+
* Bake the daemon-job argv skeleton from AGENT_COMMANDS.
|
|
79
|
+
*
|
|
80
|
+
* The two tables used to be independent copies of the same launch decision.
|
|
81
|
+
* Argv now comes from AGENT_COMMANDS.base / promptFlag / jsonFlags / modeFlags.
|
|
82
|
+
* Two documented exceptions, not a second table:
|
|
83
|
+
* - kimi uses `--prompt` (long form). `-p` is the exec alias; combining
|
|
84
|
+
* either with --plan/--auto/--yolo aborts, so routineModeArgs emits no
|
|
85
|
+
* mode flag. The daemon has always spawned the long form.
|
|
86
|
+
* - claude places `--verbose` (from jsonFlags) before the prompt and bakes
|
|
87
|
+
* modeFlags.plan so claudeAdapter.routineModeArgs can splice
|
|
88
|
+
* plan → acceptEdits / auto / skip.
|
|
89
|
+
*
|
|
90
|
+
* Returns undefined when `agent` is outside ROUTINE_AGENT_IDS (gemini, grok,
|
|
91
|
+
* and every other harness the daemon does not fire locally).
|
|
92
|
+
*/
|
|
93
|
+
export declare function bakeRoutineArgv(agent: string): string[] | undefined;
|
|
77
94
|
/** Build the full CLI argv for executing a job, applying mode, model, and permission flags. */
|
|
78
95
|
export declare function buildJobCommand(config: JobConfig, resolvedPrompt: string, forwardAccount?: boolean): string[];
|
|
79
96
|
/**
|
|
@@ -142,11 +159,11 @@ export declare function pinJobBinary(cmd: string[], agent: AgentId, version: str
|
|
|
142
159
|
* registry or a real dispatch.
|
|
143
160
|
*/
|
|
144
161
|
export declare function assertRoutineAccountLocalForPlacement(config: Pick<JobConfig, 'name' | 'account'>, mode: 'host' | 'cloud', deps?: {
|
|
145
|
-
account?: import('
|
|
162
|
+
account?: import('../account-registry.js').UnifiedAccount | null;
|
|
146
163
|
readMeta?: typeof readMeta;
|
|
147
164
|
}): Promise<void>;
|
|
148
|
-
export declare function dispatchPlacedJob(config: JobConfig, target: import('
|
|
149
|
-
account?: import('
|
|
165
|
+
export declare function dispatchPlacedJob(config: JobConfig, target: import('../routines-placement.js').PlacementTarget, attempt: RoutineAttempt, deps?: {
|
|
166
|
+
account?: import('../account-registry.js').UnifiedAccount | null;
|
|
150
167
|
host?: typeof executeJobOnHost;
|
|
151
168
|
cloud?: typeof executeJobOnCloud;
|
|
152
169
|
}): Promise<RunResult | undefined>;
|
|
@@ -160,8 +177,8 @@ export declare function buildHostDispatchOptions(config: JobConfig, ctx: {
|
|
|
160
177
|
remoteCwd: string | undefined;
|
|
161
178
|
runDir: string;
|
|
162
179
|
detached: boolean;
|
|
163
|
-
}): import('
|
|
164
|
-
export declare function dispatchesViaAgentsRun(config: Pick<JobConfig, 'workflow' | 'resume'>): boolean;
|
|
180
|
+
}): import('../hosts/run-target.js').HostPromptRun;
|
|
181
|
+
export declare function dispatchesViaAgentsRun(config: Pick<JobConfig, 'workflow' | 'resume' | 'agent'>): boolean;
|
|
165
182
|
/**
|
|
166
183
|
* Merge sandbox/base env with the canonical per-version exec env
|
|
167
184
|
* (CLAUDE_CONFIG_DIR / CODEX_HOME / …) so routines share account isolation
|