@phnx-labs/agents-cli 1.23.27 → 1.23.29
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 +8 -0
- package/README.md +33 -82
- package/dist/bootstrap.js +0 -17
- package/dist/cli/command-registry.js +0 -2
- package/dist/commands/cloud.js +0 -58
- package/dist/commands/config.js +0 -4
- package/dist/commands/daemon-index.js +1 -1
- package/dist/commands/daemon.js +14 -63
- package/dist/commands/doctor.js +0 -12
- package/dist/commands/events.js +1 -1
- package/dist/commands/feed.d.ts +1 -3
- package/dist/commands/feed.js +1 -6
- package/dist/commands/fleet-capture.js +2 -4
- package/dist/commands/focus.d.ts +0 -1
- package/dist/commands/focus.js +2 -4
- package/dist/commands/inspect.d.ts +1 -19
- package/dist/commands/inspect.js +8 -474
- package/dist/commands/mine.js +1 -1
- package/dist/commands/prune.js +2 -64
- package/dist/commands/ps-roster.d.ts +0 -4
- package/dist/commands/ps-roster.js +2 -30
- package/dist/commands/ps.js +1 -4
- package/dist/commands/repo.d.ts +1 -1
- package/dist/commands/repo.js +4 -4
- package/dist/commands/sessions-browser.d.ts +0 -2
- package/dist/commands/sessions-browser.js +2 -32
- package/dist/commands/sessions-optimize.js +3 -4
- package/dist/commands/setup-mine.js +0 -1
- package/dist/commands/ssh.js +8 -9
- package/dist/commands/sync.js +1 -1
- package/dist/commands/update.js +2 -2
- package/dist/commands/watchdog.js +3 -4
- package/dist/lib/accounting/rotate.d.ts +0 -2
- package/dist/lib/accounting/rotate.js +1 -4
- package/dist/lib/agent-spec/agents.d.ts +0 -1
- package/dist/lib/agent-spec/agents.js +0 -8
- package/dist/lib/auth-health.d.ts +0 -1
- package/dist/lib/auth-health.js +0 -3
- package/dist/lib/cli-entry.d.ts +0 -1
- package/dist/lib/cli-entry.js +0 -36
- package/dist/lib/cloud/types.d.ts +0 -2
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +1 -4
- package/dist/lib/daemon/daemon.d.ts +0 -4
- package/dist/lib/daemon/daemon.js +6 -202
- package/dist/lib/daemon/heartbeat-service.d.ts +1 -1
- package/dist/lib/daemon/heartbeat-service.js +1 -8
- package/dist/lib/daemon-services.d.ts +1 -1
- package/dist/lib/daemon-services.js +1 -11
- package/dist/lib/device-config.d.ts +0 -2
- package/dist/lib/device-config.js +4 -22
- package/dist/lib/devices/config-migration.js +1 -3
- package/dist/lib/exec.d.ts +2 -5
- package/dist/lib/exec.js +18 -18
- package/dist/lib/factory/snapshot.d.ts +0 -5
- package/dist/lib/factory/snapshot.js +1 -28
- package/dist/lib/feed/events.d.ts +1 -11
- package/dist/lib/feed/events.js +0 -20
- package/dist/lib/feed/feed.d.ts +0 -2
- package/dist/lib/feed-outcome.d.ts +0 -2
- package/dist/lib/feed-outcome.js +0 -5
- package/dist/lib/fleet/capture.d.ts +0 -1
- package/dist/lib/fleet/capture.js +0 -3
- package/dist/lib/fleet/manifest.js +0 -6
- package/dist/lib/fleet/types.d.ts +0 -1
- package/dist/lib/harness/adapter.d.ts +0 -7
- package/dist/lib/harness/adapters/claude.js +0 -18
- package/dist/lib/harness/adapters/codex.js +0 -10
- package/dist/lib/harness/adapters/cursor.js +0 -11
- package/dist/lib/harness/adapters/kimi.js +0 -3
- package/dist/lib/harness/adapters/muse.js +0 -11
- package/dist/lib/harness/index.d.ts +1 -1
- package/dist/lib/harness/index.js +0 -2
- package/dist/lib/hosts/passthrough.js +2 -10
- package/dist/lib/hosts/ready.d.ts +0 -4
- package/dist/lib/hosts/ready.js +0 -9
- package/dist/lib/hosts/reconcile.d.ts +0 -1
- package/dist/lib/hosts/reconcile.js +0 -8
- package/dist/lib/installations/migrate.d.ts +0 -2
- package/dist/lib/installations/migrate.js +0 -145
- package/dist/lib/loop.js +1 -2
- package/dist/lib/menubar/snapshot.d.ts +0 -1
- package/dist/lib/menubar/snapshot.js +1 -4
- package/dist/lib/placement.d.ts +1 -2
- package/dist/lib/placement.js +4 -24
- package/dist/lib/profiles.d.ts +0 -1
- package/dist/lib/profiles.js +0 -6
- package/dist/lib/projects.js +15 -17
- package/dist/lib/session/active.d.ts +1 -3
- package/dist/lib/session/active.js +0 -4
- package/dist/lib/session/db.d.ts +0 -1
- package/dist/lib/session/db.js +4 -8
- package/dist/lib/session/discover.d.ts +0 -1
- package/dist/lib/session/discover.js +3 -128
- package/dist/lib/session/live-metadata.js +0 -2
- package/dist/lib/session/presentation.d.ts +0 -1
- package/dist/lib/session/presentation.js +3 -8
- package/dist/lib/session/selection.d.ts +0 -2
- package/dist/lib/session/selection.js +2 -12
- package/dist/lib/staleness/detectors/commands.d.ts +1 -1
- package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
- package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
- package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
- package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
- package/dist/lib/staleness/detectors/rules.d.ts +1 -1
- package/dist/lib/staleness/detectors/skills.d.ts +1 -1
- package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
- package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
- package/dist/lib/staleness/writers/commands.d.ts +1 -1
- package/dist/lib/staleness/writers/hooks.d.ts +1 -1
- package/dist/lib/staleness/writers/mcp.d.ts +1 -1
- package/dist/lib/staleness/writers/permissions.d.ts +1 -1
- package/dist/lib/staleness/writers/plugins.d.ts +1 -1
- package/dist/lib/staleness/writers/rules.d.ts +1 -1
- package/dist/lib/staleness/writers/skills.d.ts +1 -1
- package/dist/lib/staleness/writers/subagents.d.ts +1 -1
- package/dist/lib/staleness/writers/workflows.d.ts +1 -1
- package/dist/lib/startup/command-registry.js +5 -2
- package/dist/lib/state.d.ts +0 -3
- package/dist/lib/state.js +2 -25
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/watchdog/runner.d.ts +0 -2
- package/dist/lib/watchdog/runner.js +0 -2
- package/package.json +1 -1
- package/scripts/postinstall.js +2 -2
- package/dist/commands/routines.d.ts +0 -14
- package/dist/commands/routines.js +0 -2149
- package/dist/commands/routines.test-fixture.d.ts +0 -52
- package/dist/commands/routines.test-fixture.js +0 -254
- package/dist/lib/catchup.d.ts +0 -19
- package/dist/lib/catchup.js +0 -83
- package/dist/lib/daemon/catchup-service.d.ts +0 -18
- package/dist/lib/daemon/catchup-service.js +0 -21
- package/dist/lib/daemon/runner.d.ts +0 -91
- package/dist/lib/daemon/runner.js +0 -1927
- package/dist/lib/harness/adapters/droid.d.ts +0 -2
- package/dist/lib/harness/adapters/droid.js +0 -14
- package/dist/lib/overdue.d.ts +0 -9
- package/dist/lib/overdue.js +0 -74
- package/dist/lib/routine-activation.d.ts +0 -13
- package/dist/lib/routine-activation.js +0 -117
- package/dist/lib/routine-context.d.ts +0 -59
- package/dist/lib/routine-context.js +0 -181
- package/dist/lib/routine-notify-owner.d.ts +0 -4
- package/dist/lib/routine-notify-owner.js +0 -49
- package/dist/lib/routine-notify.d.ts +0 -17
- package/dist/lib/routine-notify.js +0 -138
- package/dist/lib/routine-process-cleanup.d.ts +0 -9
- package/dist/lib/routine-process-cleanup.js +0 -81
- package/dist/lib/routine-readiness.d.ts +0 -31
- package/dist/lib/routine-readiness.js +0 -256
- package/dist/lib/routines-format.d.ts +0 -7
- package/dist/lib/routines-format.js +0 -127
- package/dist/lib/routines-placement.d.ts +0 -16
- package/dist/lib/routines-placement.js +0 -60
- package/dist/lib/routines-project.d.ts +0 -49
- package/dist/lib/routines-project.js +0 -306
- package/dist/lib/sandbox.d.ts +0 -15
- package/dist/lib/sandbox.js +0 -309
- package/dist/lib/scheduler.d.ts +0 -23
- package/dist/lib/scheduler.js +0 -106
- package/dist/lib/scheduling/routines.d.ts +0 -264
- package/dist/lib/scheduling/routines.js +0 -1292
- package/dist/lib/triggers/webhook.d.ts +0 -26
- package/dist/lib/triggers/webhook.js +0 -181
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { resolveHostStrategy } from './scheduling/routines.js';
|
|
2
|
-
import { machineId, normalizeHost } from './machine-id.js';
|
|
3
|
-
import { loadDevicesSync } from './devices/registry.js';
|
|
4
|
-
import { planFleetTargets } from './devices/fleet.js';
|
|
5
|
-
export function pickFleetDevice(_config, platform) {
|
|
6
|
-
let reg;
|
|
7
|
-
try {
|
|
8
|
-
reg = loadDevicesSync();
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const planned = planFleetTargets(reg);
|
|
14
|
-
const candidates = planned
|
|
15
|
-
.filter((t) => !t.skip && (!platform || t.device.platform === platform))
|
|
16
|
-
.map((t) => t.device.name);
|
|
17
|
-
if (candidates.length === 0) {
|
|
18
|
-
return platform ? null : machineId();
|
|
19
|
-
}
|
|
20
|
-
const self = machineId();
|
|
21
|
-
const selfMatch = candidates.find((n) => normalizeHost(n) === self);
|
|
22
|
-
if (selfMatch)
|
|
23
|
-
return selfMatch;
|
|
24
|
-
return [...candidates].sort((a, b) => a.localeCompare(b))[0] ?? null;
|
|
25
|
-
}
|
|
26
|
-
export async function resolvePlacementTarget(config, deps = {}) {
|
|
27
|
-
const strategy = resolveHostStrategy(config);
|
|
28
|
-
switch (strategy) {
|
|
29
|
-
case 'local':
|
|
30
|
-
return { mode: 'local' };
|
|
31
|
-
case 'host': {
|
|
32
|
-
if (!config.host || config.host.trim() === '') {
|
|
33
|
-
throw new Error(`Routine '${config.name}' has hostStrategy: host but no host: — set host: or --run-on`);
|
|
34
|
-
}
|
|
35
|
-
if (normalizeHost(config.host) === machineId())
|
|
36
|
-
return { mode: 'local' };
|
|
37
|
-
return { mode: 'host', host: config.host };
|
|
38
|
-
}
|
|
39
|
-
case 'fleet': {
|
|
40
|
-
let picked;
|
|
41
|
-
if (config.host === 'auto') {
|
|
42
|
-
const resolveAuto = deps.resolveDeviceAuto
|
|
43
|
-
?? (async (agent) => (await import('./smart-launch.js')).resolveDeviceAuto(agent));
|
|
44
|
-
const plan = await resolveAuto(config.agent);
|
|
45
|
-
picked = plan.pickedDeviceKey;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
picked = pickFleetDevice(config);
|
|
49
|
-
}
|
|
50
|
-
if (!picked) {
|
|
51
|
-
throw new Error(`Routine '${config.name}' hostStrategy: fleet — no eligible online device to place the run`);
|
|
52
|
-
}
|
|
53
|
-
if (normalizeHost(picked) === machineId())
|
|
54
|
-
return { mode: 'local' };
|
|
55
|
-
return { mode: 'host', host: picked };
|
|
56
|
-
}
|
|
57
|
-
case 'cloud':
|
|
58
|
-
return { mode: 'cloud' };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type JobConfig } from './scheduling/routines.js';
|
|
2
|
-
export declare function expandProjectPath(p: string): string;
|
|
3
|
-
export declare function displayProjectPath(abs: string): string;
|
|
4
|
-
export declare function resolveProjectRoot(cwd?: string): string | null;
|
|
5
|
-
export declare function listProjectRoutineFiles(projectRoot: string): Array<{
|
|
6
|
-
name: string;
|
|
7
|
-
path: string;
|
|
8
|
-
}>;
|
|
9
|
-
interface SyncProjectResult {
|
|
10
|
-
projectRoot: string;
|
|
11
|
-
synced: string[];
|
|
12
|
-
skipped: Array<{
|
|
13
|
-
name: string;
|
|
14
|
-
reason: string;
|
|
15
|
-
}>;
|
|
16
|
-
removed: string[];
|
|
17
|
-
errors: Array<{
|
|
18
|
-
name: string;
|
|
19
|
-
error: string;
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
export declare function syncProjectRoutines(projectRoot: string): SyncProjectResult;
|
|
23
|
-
export interface SyncAllResult {
|
|
24
|
-
projects: SyncProjectResult[];
|
|
25
|
-
missing: string[];
|
|
26
|
-
}
|
|
27
|
-
export declare function materialisedProjectRoots(): string[];
|
|
28
|
-
export declare function syncAllProjectRoutines(opts?: {
|
|
29
|
-
extraRoots?: string[];
|
|
30
|
-
}): SyncAllResult;
|
|
31
|
-
export interface DiscoveredProjectRoutine {
|
|
32
|
-
name: string;
|
|
33
|
-
projectRoot: string;
|
|
34
|
-
file: string;
|
|
35
|
-
config: JobConfig;
|
|
36
|
-
}
|
|
37
|
-
export declare function discoverProjectRoutines(): DiscoveredProjectRoutine[];
|
|
38
|
-
export declare function findProjectRoutine(name: string, cwd?: string): {
|
|
39
|
-
projectRoot: string;
|
|
40
|
-
file: string;
|
|
41
|
-
} | {
|
|
42
|
-
ambiguous: string[];
|
|
43
|
-
} | null;
|
|
44
|
-
export declare function materialiseProjectRoutine(projectRoot: string, name: string): {
|
|
45
|
-
job: JobConfig;
|
|
46
|
-
} | {
|
|
47
|
-
error: string;
|
|
48
|
-
};
|
|
49
|
-
export {};
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import * as yaml from 'yaml';
|
|
5
|
-
import { execFileSync } from 'child_process';
|
|
6
|
-
import { getProjectAgentsDir, getProjectRoutinesDir, ensureAgentsDir, } from './state.js';
|
|
7
|
-
import { readJob, writeJob, deleteJob, listJobs, validateJob, } from './scheduling/routines.js';
|
|
8
|
-
import { parseOwnerRepoFromRemote } from './git.js';
|
|
9
|
-
import { listProjectDefs, projectDirsAbs } from './projects.js';
|
|
10
|
-
import { isSafeSegmentName } from './paths.js';
|
|
11
|
-
export function expandProjectPath(p) {
|
|
12
|
-
const trimmed = p.trim();
|
|
13
|
-
if (trimmed.startsWith('~/') || trimmed === '~') {
|
|
14
|
-
return path.resolve(trimmed.replace(/^~(?=$|[/\\])/, os.homedir()));
|
|
15
|
-
}
|
|
16
|
-
return path.resolve(trimmed);
|
|
17
|
-
}
|
|
18
|
-
export function displayProjectPath(abs) {
|
|
19
|
-
const home = os.homedir();
|
|
20
|
-
const resolved = path.resolve(abs);
|
|
21
|
-
if (resolved === home)
|
|
22
|
-
return '~';
|
|
23
|
-
if (resolved.startsWith(home + path.sep)) {
|
|
24
|
-
return '~' + resolved.slice(home.length);
|
|
25
|
-
}
|
|
26
|
-
return resolved;
|
|
27
|
-
}
|
|
28
|
-
export function resolveProjectRoot(cwd = process.cwd()) {
|
|
29
|
-
const agentsDir = getProjectAgentsDir(cwd);
|
|
30
|
-
if (!agentsDir)
|
|
31
|
-
return null;
|
|
32
|
-
return path.dirname(agentsDir);
|
|
33
|
-
}
|
|
34
|
-
function readProjectGitSource(projectRoot) {
|
|
35
|
-
const abs = expandProjectPath(projectRoot);
|
|
36
|
-
const out = {};
|
|
37
|
-
try {
|
|
38
|
-
const remote = execFileSync('git', ['-C', abs, 'remote', 'get-url', 'origin'], {
|
|
39
|
-
encoding: 'utf-8',
|
|
40
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
41
|
-
timeout: 5_000,
|
|
42
|
-
}).trim();
|
|
43
|
-
const repo = parseOwnerRepoFromRemote(remote);
|
|
44
|
-
if (repo)
|
|
45
|
-
out.repo = repo;
|
|
46
|
-
}
|
|
47
|
-
catch { }
|
|
48
|
-
try {
|
|
49
|
-
out.branch = execFileSync('git', ['-C', abs, 'rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
50
|
-
encoding: 'utf-8',
|
|
51
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
52
|
-
timeout: 5_000,
|
|
53
|
-
}).trim();
|
|
54
|
-
if (out.branch === 'HEAD')
|
|
55
|
-
delete out.branch;
|
|
56
|
-
}
|
|
57
|
-
catch { }
|
|
58
|
-
try {
|
|
59
|
-
out.commit = execFileSync('git', ['-C', abs, 'rev-parse', '--short', 'HEAD'], {
|
|
60
|
-
encoding: 'utf-8',
|
|
61
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
62
|
-
timeout: 5_000,
|
|
63
|
-
}).trim();
|
|
64
|
-
}
|
|
65
|
-
catch { }
|
|
66
|
-
return out;
|
|
67
|
-
}
|
|
68
|
-
export function listProjectRoutineFiles(projectRoot) {
|
|
69
|
-
const routinesDir = getProjectRoutinesDir(expandProjectPath(projectRoot));
|
|
70
|
-
if (!routinesDir || !fs.existsSync(routinesDir))
|
|
71
|
-
return [];
|
|
72
|
-
return fs.readdirSync(routinesDir)
|
|
73
|
-
.filter((f) => f.endsWith('.yml') || f.endsWith('.yaml'))
|
|
74
|
-
.map((f) => ({
|
|
75
|
-
name: f.replace(/\.ya?ml$/, ''),
|
|
76
|
-
path: path.join(routinesDir, f),
|
|
77
|
-
}))
|
|
78
|
-
.filter((e) => isSafeSegmentName(e.name));
|
|
79
|
-
}
|
|
80
|
-
function readProjectJobFile(filePath) {
|
|
81
|
-
try {
|
|
82
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
83
|
-
const parsed = yaml.parse(content);
|
|
84
|
-
if (!parsed || typeof parsed !== 'object')
|
|
85
|
-
return null;
|
|
86
|
-
if (Object.prototype.hasOwnProperty.call(parsed, 'device'))
|
|
87
|
-
return null;
|
|
88
|
-
return {
|
|
89
|
-
mode: 'auto',
|
|
90
|
-
effort: 'auto',
|
|
91
|
-
timeout: '10m',
|
|
92
|
-
enabled: true,
|
|
93
|
-
...parsed,
|
|
94
|
-
name: parsed.name || path.basename(filePath).replace(/\.ya?ml$/, ''),
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export function syncProjectRoutines(projectRoot) {
|
|
102
|
-
ensureAgentsDir();
|
|
103
|
-
const abs = expandProjectPath(projectRoot);
|
|
104
|
-
const git = readProjectGitSource(abs);
|
|
105
|
-
const source = {
|
|
106
|
-
kind: 'project',
|
|
107
|
-
projectPath: abs,
|
|
108
|
-
...(git.repo ? { repo: git.repo } : {}),
|
|
109
|
-
...(git.branch ? { branch: git.branch } : {}),
|
|
110
|
-
...(git.commit ? { commit: git.commit } : {}),
|
|
111
|
-
};
|
|
112
|
-
const result = {
|
|
113
|
-
projectRoot: abs,
|
|
114
|
-
synced: [],
|
|
115
|
-
skipped: [],
|
|
116
|
-
removed: [],
|
|
117
|
-
errors: [],
|
|
118
|
-
};
|
|
119
|
-
const files = listProjectRoutineFiles(abs);
|
|
120
|
-
const seenNames = new Set();
|
|
121
|
-
for (const file of files) {
|
|
122
|
-
seenNames.add(file.name);
|
|
123
|
-
const existing = readJob(file.name);
|
|
124
|
-
if (!existing)
|
|
125
|
-
continue;
|
|
126
|
-
const existingSource = existing.source;
|
|
127
|
-
const fromThisProject = existingSource?.kind === 'project'
|
|
128
|
-
&& expandProjectPath(existingSource.projectPath) === abs;
|
|
129
|
-
if (!fromThisProject) {
|
|
130
|
-
result.skipped.push({
|
|
131
|
-
name: file.name,
|
|
132
|
-
reason: existingSource
|
|
133
|
-
? `user-layer routine already exists from another source (${existingSource.projectPath})`
|
|
134
|
-
: 'user-layer routine already exists (hand-authored); not overwriting without source match',
|
|
135
|
-
});
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
const job = readProjectJobFile(file.path);
|
|
139
|
-
if (!job) {
|
|
140
|
-
result.errors.push({ name: file.name, error: 'unreadable or invalid YAML' });
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (job.devices === undefined && existing.devices && existing.devices.length > 0) {
|
|
144
|
-
job.devices = existing.devices;
|
|
145
|
-
}
|
|
146
|
-
if (existing.createdAt)
|
|
147
|
-
job.createdAt = existing.createdAt;
|
|
148
|
-
if (git.repo && !job.repo)
|
|
149
|
-
job.repo = git.repo;
|
|
150
|
-
job.source = source;
|
|
151
|
-
job.name = file.name;
|
|
152
|
-
const errors = validateJob(job);
|
|
153
|
-
if (errors.length > 0) {
|
|
154
|
-
result.errors.push({ name: file.name, error: errors.join('; ') });
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
try {
|
|
158
|
-
writeJob(job);
|
|
159
|
-
result.synced.push(file.name);
|
|
160
|
-
}
|
|
161
|
-
catch (err) {
|
|
162
|
-
result.errors.push({ name: file.name, error: err.message });
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
for (const job of listJobs()) {
|
|
166
|
-
if (job.source?.kind !== 'project')
|
|
167
|
-
continue;
|
|
168
|
-
if (expandProjectPath(job.source.projectPath) !== abs)
|
|
169
|
-
continue;
|
|
170
|
-
if (seenNames.has(job.name))
|
|
171
|
-
continue;
|
|
172
|
-
if (deleteJob(job.name))
|
|
173
|
-
result.removed.push(job.name);
|
|
174
|
-
}
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
export function materialisedProjectRoots() {
|
|
178
|
-
const roots = new Set();
|
|
179
|
-
for (const job of listJobs()) {
|
|
180
|
-
if (job.source?.kind === 'project')
|
|
181
|
-
roots.add(expandProjectPath(job.source.projectPath));
|
|
182
|
-
}
|
|
183
|
-
return [...roots];
|
|
184
|
-
}
|
|
185
|
-
export function syncAllProjectRoutines(opts = {}) {
|
|
186
|
-
const roots = new Set(materialisedProjectRoots());
|
|
187
|
-
for (const r of opts.extraRoots ?? [])
|
|
188
|
-
roots.add(expandProjectPath(r));
|
|
189
|
-
const projects = [];
|
|
190
|
-
const missing = [];
|
|
191
|
-
for (const root of roots) {
|
|
192
|
-
if (!fs.existsSync(root)) {
|
|
193
|
-
missing.push(root);
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
projects.push(syncProjectRoutines(root));
|
|
197
|
-
}
|
|
198
|
-
return { projects, missing };
|
|
199
|
-
}
|
|
200
|
-
function registeredProjectRoots() {
|
|
201
|
-
const roots = new Set();
|
|
202
|
-
for (const def of listProjectDefs()) {
|
|
203
|
-
for (const dir of projectDirsAbs(def, { forRemote: false })) {
|
|
204
|
-
if (dir)
|
|
205
|
-
roots.add(path.resolve(dir));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return [...roots];
|
|
209
|
-
}
|
|
210
|
-
export function discoverProjectRoutines() {
|
|
211
|
-
const materialisedNames = new Set(listJobs().map((j) => j.name));
|
|
212
|
-
const out = [];
|
|
213
|
-
const seen = new Set();
|
|
214
|
-
for (const root of registeredProjectRoots()) {
|
|
215
|
-
const files = listProjectRoutineFiles(root).filter((f) => !materialisedNames.has(f.name) && !seen.has(f.name));
|
|
216
|
-
if (files.length === 0)
|
|
217
|
-
continue;
|
|
218
|
-
const git = readProjectGitSource(root);
|
|
219
|
-
for (const file of files) {
|
|
220
|
-
const job = readProjectJobFile(file.path);
|
|
221
|
-
if (!job)
|
|
222
|
-
continue;
|
|
223
|
-
seen.add(file.name);
|
|
224
|
-
job.name = file.name;
|
|
225
|
-
job.source = {
|
|
226
|
-
kind: 'project',
|
|
227
|
-
projectPath: expandProjectPath(root),
|
|
228
|
-
...(git.repo ? { repo: git.repo } : {}),
|
|
229
|
-
...(git.branch ? { branch: git.branch } : {}),
|
|
230
|
-
...(git.commit ? { commit: git.commit } : {}),
|
|
231
|
-
};
|
|
232
|
-
if (git.repo && !job.repo)
|
|
233
|
-
job.repo = git.repo;
|
|
234
|
-
job.enabled = false;
|
|
235
|
-
out.push({ name: file.name, projectRoot: expandProjectPath(root), file: file.path, config: job });
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return out;
|
|
239
|
-
}
|
|
240
|
-
export function findProjectRoutine(name, cwd = process.cwd()) {
|
|
241
|
-
const cwdRoot = resolveProjectRoot(cwd);
|
|
242
|
-
if (cwdRoot) {
|
|
243
|
-
const match = listProjectRoutineFiles(cwdRoot).find((f) => f.name === name);
|
|
244
|
-
if (match)
|
|
245
|
-
return { projectRoot: expandProjectPath(cwdRoot), file: match.path };
|
|
246
|
-
}
|
|
247
|
-
const hits = [];
|
|
248
|
-
const seenRoots = new Set();
|
|
249
|
-
for (const root of registeredProjectRoots()) {
|
|
250
|
-
const abs = expandProjectPath(root);
|
|
251
|
-
if (seenRoots.has(abs))
|
|
252
|
-
continue;
|
|
253
|
-
seenRoots.add(abs);
|
|
254
|
-
const match = listProjectRoutineFiles(abs).find((f) => f.name === name);
|
|
255
|
-
if (match)
|
|
256
|
-
hits.push({ projectRoot: abs, file: match.path });
|
|
257
|
-
}
|
|
258
|
-
if (hits.length === 0)
|
|
259
|
-
return null;
|
|
260
|
-
if (hits.length > 1)
|
|
261
|
-
return { ambiguous: hits.map((h) => displayProjectPath(h.projectRoot)) };
|
|
262
|
-
return hits[0];
|
|
263
|
-
}
|
|
264
|
-
export function materialiseProjectRoutine(projectRoot, name) {
|
|
265
|
-
ensureAgentsDir();
|
|
266
|
-
const abs = expandProjectPath(projectRoot);
|
|
267
|
-
const match = listProjectRoutineFiles(abs).find((f) => f.name === name);
|
|
268
|
-
if (!match)
|
|
269
|
-
return { error: `no routine '${name}' under ${displayProjectPath(abs)}/.agents/routines` };
|
|
270
|
-
const job = readProjectJobFile(match.path);
|
|
271
|
-
if (!job)
|
|
272
|
-
return { error: `routine '${name}' is unreadable or invalid YAML` };
|
|
273
|
-
const existing = readJob(name);
|
|
274
|
-
if (existing) {
|
|
275
|
-
const src = existing.source;
|
|
276
|
-
const fromThisProject = src?.kind === 'project' && expandProjectPath(src.projectPath) === abs;
|
|
277
|
-
if (!fromThisProject) {
|
|
278
|
-
return {
|
|
279
|
-
error: src
|
|
280
|
-
? `a routine named '${name}' already exists from another source (${src.projectPath})`
|
|
281
|
-
: `a hand-authored routine named '${name}' already exists; rename one before enabling`,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
if (existing.createdAt)
|
|
285
|
-
job.createdAt = existing.createdAt;
|
|
286
|
-
if (job.devices === undefined && existing.devices && existing.devices.length > 0) {
|
|
287
|
-
job.devices = existing.devices;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const git = readProjectGitSource(abs);
|
|
291
|
-
job.name = name;
|
|
292
|
-
job.source = {
|
|
293
|
-
kind: 'project',
|
|
294
|
-
projectPath: abs,
|
|
295
|
-
...(git.repo ? { repo: git.repo } : {}),
|
|
296
|
-
...(git.branch ? { branch: git.branch } : {}),
|
|
297
|
-
...(git.commit ? { commit: git.commit } : {}),
|
|
298
|
-
};
|
|
299
|
-
if (git.repo && !job.repo)
|
|
300
|
-
job.repo = git.repo;
|
|
301
|
-
const errors = validateJob(job);
|
|
302
|
-
if (errors.length > 0)
|
|
303
|
-
return { error: errors.join('; ') };
|
|
304
|
-
writeJob(job);
|
|
305
|
-
return { job };
|
|
306
|
-
}
|
package/dist/lib/sandbox.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { JobConfig } from './scheduling/routines.js';
|
|
2
|
-
import type { AgentId } from './types.js';
|
|
3
|
-
export declare function resolveHostGhConfigDir(): string | null;
|
|
4
|
-
export declare function hostHasGhAuth(): boolean;
|
|
5
|
-
export declare function buildSpawnEnv(overlayHome: string, extraEnv?: Record<string, string>): Record<string, string>;
|
|
6
|
-
export declare function getJobHomePath(name: string): string;
|
|
7
|
-
export declare function prepareJobHome(config: JobConfig, version?: string): string;
|
|
8
|
-
export declare function linkVersionAuth(overlayHome: string, agent: AgentId, version?: string): void;
|
|
9
|
-
export declare function linkHostGhConfig(overlayHome: string): void;
|
|
10
|
-
export declare function assertSandboxForwardsHostGhAuth(spawnEnv: Record<string, string>): void;
|
|
11
|
-
export declare function generateCursorConfig(overlayHome: string): void;
|
|
12
|
-
export declare function cleanJobHome(name: string): void;
|
|
13
|
-
export declare function symlinkAllowedDirs(overlayHome: string, dirs: string[]): void;
|
|
14
|
-
export declare function generateClaudeConfig(overlayHome: string, config: JobConfig): void;
|
|
15
|
-
export declare function generateCodexConfig(overlayHome: string, config: JobConfig): void;
|