@phnx-labs/agents-cli 1.23.17 → 1.23.18
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 +66 -0
- package/README.md +140 -165
- package/dist/bootstrap.js +10 -16
- package/dist/cli/command-registry.d.ts +1 -2
- package/dist/cli/command-registry.js +1 -10
- package/dist/commands/accounts.js +7 -7
- package/dist/commands/cloud-transcripts.d.ts +0 -1
- package/dist/commands/cloud-transcripts.js +2 -2
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/config.js +0 -4
- package/dist/commands/cost.js +1 -1
- package/dist/commands/daemon-index.js +0 -1
- package/dist/commands/detach.d.ts +1 -1
- package/dist/commands/detach.js +5 -5
- package/dist/commands/exec.js +10 -22
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +3 -3
- package/dist/commands/focus.d.ts +1 -4
- package/dist/commands/focus.js +12 -13
- package/dist/commands/fork.d.ts +0 -1
- package/dist/commands/fork.js +7 -16
- package/dist/commands/harness-wizard.js +1 -1
- package/dist/commands/harness.js +1 -1
- package/dist/commands/insights.d.ts +0 -1
- package/dist/commands/insights.js +3 -7
- package/dist/commands/open.js +1 -1
- package/dist/commands/output.js +1 -1
- package/dist/commands/profiles.d.ts +1 -1
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/projects.js +1 -1
- package/dist/commands/prune.js +1 -1
- package/dist/commands/ps.d.ts +0 -1
- package/dist/commands/ps.js +63 -18
- package/dist/commands/routines.js +1 -1
- package/dist/commands/send.js +1 -1
- package/dist/commands/sessions-backfill.d.ts +0 -1
- package/dist/commands/sessions-backfill.js +3 -6
- package/dist/commands/sessions-browser.d.ts +0 -10
- package/dist/commands/sessions-browser.js +19 -25
- package/dist/commands/sessions-migrate.d.ts +2 -2
- package/dist/commands/sessions-migrate.js +13 -13
- package/dist/commands/sessions-optimize.d.ts +0 -1
- package/dist/commands/sessions-optimize.js +0 -3
- package/dist/commands/sessions-picker.js +11 -11
- package/dist/commands/sessions-resume.d.ts +16 -15
- package/dist/commands/sessions-resume.js +101 -269
- package/dist/commands/sessions-stats.d.ts +0 -1
- package/dist/commands/sessions-stats.js +5 -8
- package/dist/commands/sessions-stop.d.ts +1 -1
- package/dist/commands/sessions-stop.js +6 -6
- package/dist/commands/sessions-trace.d.ts +1 -1
- package/dist/commands/sessions-trace.js +40 -17
- package/dist/commands/sessions-watch.js +2 -2
- package/dist/commands/sessions.test-fixture.d.ts +1 -0
- package/dist/commands/sessions.test-fixture.js +14 -0
- package/dist/commands/setup-browser.js +4 -4
- package/dist/commands/setup-computer.js +4 -4
- package/dist/commands/setup-fleet.js +1 -1
- package/dist/commands/setup-preferences.js +1 -1
- package/dist/commands/{sessions-backup-setup.d.ts → setup-session-backup.d.ts} +2 -2
- package/dist/commands/{sessions-backup-setup.js → setup-session-backup.js} +8 -8
- package/dist/commands/setup.js +3 -1
- package/dist/commands/ssh.js +4 -5
- package/dist/commands/sync.js +1 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/utils.d.ts +0 -1
- package/dist/commands/utils.js +0 -10
- package/dist/index.js +0 -71
- package/dist/lib/analytics/mix-commands.js +1 -1
- package/dist/lib/auth-mint.js +2 -2
- package/dist/lib/browser-client.d.ts +0 -1
- package/dist/lib/browser-client.js +0 -3
- package/dist/lib/cloud/antigravity.js +1 -1
- package/dist/lib/cloud/cursor.js +3 -3
- package/dist/lib/cloudflare/creds.js +2 -2
- package/dist/lib/computer/context.d.ts +4 -21
- package/dist/lib/computer/context.js +3 -24
- package/dist/lib/computer/policy.d.ts +0 -10
- package/dist/lib/computer/policy.js +0 -28
- package/dist/lib/computer-client.d.ts +0 -44
- package/dist/lib/computer-client.js +17 -121
- package/dist/lib/config-keys.d.ts +1 -1
- package/dist/lib/config-keys.js +0 -3
- package/dist/lib/crabbox/cli.js +1 -1
- package/dist/lib/device-config.js +5 -28
- package/dist/lib/devices/connect.d.ts +1 -1
- package/dist/lib/devices/connect.js +3 -6
- package/dist/lib/devices/doctor-findings.d.ts +2 -1
- package/dist/lib/devices/doctor-findings.js +4 -4
- package/dist/lib/exec.js +1 -1
- package/dist/lib/feed/activity.js +1 -1
- package/dist/lib/fleet/apply.js +1 -1
- package/dist/lib/help.d.ts +0 -1
- package/dist/lib/help.js +2 -10
- package/dist/lib/hosts/option.js +1 -1
- package/dist/lib/hosts/passthrough.d.ts +0 -1
- package/dist/lib/hosts/passthrough.js +2 -26
- package/dist/lib/hosts/reconnect.js +5 -5
- package/dist/lib/hosts/remote-cmd.d.ts +3 -5
- package/dist/lib/hosts/remote-cmd.js +15 -20
- package/dist/lib/hosts/remote-session-id.js +1 -1
- package/dist/lib/installations/active-check.js +1 -1
- package/dist/lib/installations/migrate.js +4 -15
- package/dist/lib/installations/versions.js +1 -1
- package/dist/lib/launch-log.js +3 -6
- package/dist/lib/owner-notify.d.ts +1 -6
- package/dist/lib/owner-notify.js +0 -2
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -8
- package/dist/lib/permissions.js +1 -1
- package/dist/lib/redact.d.ts +0 -1
- package/dist/lib/redact.js +0 -4
- package/dist/lib/remote-agents-json.d.ts +3 -1
- package/dist/lib/remote-agents-json.js +8 -6
- package/dist/lib/reserved-stores.js +1 -1
- package/dist/lib/scheduling/routines.d.ts +0 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/session/active.d.ts +1 -1
- package/dist/lib/session/db.js +3 -3
- package/dist/lib/session/detached.d.ts +0 -1
- package/dist/lib/session/detached.js +0 -23
- package/dist/lib/session/discover.d.ts +2 -2
- package/dist/lib/session/presentation.d.ts +0 -7
- package/dist/lib/session/presentation.js +4 -4
- package/dist/lib/session/projection.js +1 -1
- package/dist/lib/session/remote/remote-list.d.ts +2 -0
- package/dist/lib/session/remote/remote-list.js +3 -2
- package/dist/lib/session/remote/watch.js +4 -5
- package/dist/lib/session/remote-active.js +1 -1
- package/dist/lib/session/resume-command.d.ts +0 -1
- package/dist/lib/session/resume-command.js +1 -4
- package/dist/lib/session/resume-owner.d.ts +0 -2
- package/dist/lib/session/resume-owner.js +0 -6
- package/dist/lib/session/selection.d.ts +4 -5
- package/dist/lib/session/selection.js +2 -2
- package/dist/lib/session/sync/config.d.ts +0 -25
- package/dist/lib/session/sync/config.js +0 -62
- package/dist/lib/session/sync/managed-config.d.ts +0 -1
- package/dist/lib/session/sync/managed-config.js +0 -3
- package/dist/lib/session/sync/worker-template.js +1 -1
- package/dist/lib/sessions-client.d.ts +0 -16
- package/dist/lib/sessions-client.js +1 -187
- package/dist/lib/startup/command-registry.d.ts +2 -0
- package/dist/lib/startup/command-registry.js +36 -3
- package/dist/lib/startup/root-command.d.ts +0 -1
- package/dist/lib/startup/root-command.js +0 -21
- package/dist/lib/sync-umbrella.js +1 -1
- package/dist/lib/terminal/resolve.js +1 -1
- package/dist/lib/watchdog/rotate.js +1 -1
- package/dist/lib/watchdog/watchdog.d.ts +1 -1
- package/dist/lib/watchdog/watchdog.js +2 -2
- package/package.json +1 -1
- package/dist/commands/browser.d.ts +0 -7
- package/dist/commands/browser.js +0 -139
- package/dist/commands/computer.d.ts +0 -48
- package/dist/commands/computer.js +0 -244
- package/dist/commands/resume.d.ts +0 -23
- package/dist/commands/resume.js +0 -158
- package/dist/commands/secrets-passthrough.d.ts +0 -3
- package/dist/commands/secrets-passthrough.js +0 -52
- package/dist/commands/sessions-bookmark.d.ts +0 -2
- package/dist/commands/sessions-bookmark.js +0 -92
- package/dist/commands/sessions-export.d.ts +0 -31
- package/dist/commands/sessions-export.js +0 -409
- package/dist/commands/sessions-import.d.ts +0 -6
- package/dist/commands/sessions-import.js +0 -343
- package/dist/commands/sessions-inject.d.ts +0 -14
- package/dist/commands/sessions-inject.js +0 -143
- package/dist/commands/sessions-picker-factory.d.ts +0 -24
- package/dist/commands/sessions-picker-factory.js +0 -59
- package/dist/commands/sessions-render.d.ts +0 -11
- package/dist/commands/sessions-render.js +0 -119
- package/dist/commands/sessions-share.d.ts +0 -15
- package/dist/commands/sessions-share.js +0 -171
- package/dist/commands/sessions.d.ts +0 -122
- package/dist/commands/sessions.js +0 -1760
- package/dist/lib/address.d.ts +0 -39
- package/dist/lib/address.js +0 -128
- package/dist/lib/computer/record.d.ts +0 -6
- package/dist/lib/computer/record.js +0 -25
- package/dist/lib/openclaw-keychain.d.ts +0 -43
- package/dist/lib/openclaw-keychain.js +0 -227
- package/dist/lib/session/bundle.d.ts +0 -76
- package/dist/lib/session/bundle.js +0 -146
- package/dist/lib/session/remote/remote-bundle.d.ts +0 -7
- package/dist/lib/session/remote/remote-bundle.js +0 -40
- package/dist/lib/session/remote/remote.d.ts +0 -35
- package/dist/lib/session/remote/remote.js +0 -198
- package/dist/lib/session/remote-bundle.d.ts +0 -1
- package/dist/lib/session/remote-bundle.js +0 -1
- package/dist/lib/session/remote.d.ts +0 -1
- package/dist/lib/session/remote.js +0 -1
- package/dist/lib/session/sync/agents.d.ts +0 -24
- package/dist/lib/session/sync/agents.js +0 -0
- package/dist/lib/session/sync/backend.d.ts +0 -22
- package/dist/lib/session/sync/backend.js +0 -44
- package/dist/lib/session/sync/managed-key.d.ts +0 -5
- package/dist/lib/session/sync/managed-key.js +0 -87
- package/dist/lib/session/sync/net-client.d.ts +0 -29
- package/dist/lib/session/sync/net-client.js +0 -87
- package/dist/lib/session/sync/r2.d.ts +0 -20
- package/dist/lib/session/sync/r2.js +0 -103
- package/dist/lib/session/sync/transcript-crypto.d.ts +0 -41
- package/dist/lib/session/sync/transcript-crypto.js +0 -115
|
@@ -43,7 +43,7 @@ export function toSessionWatchRow(scope, row) {
|
|
|
43
43
|
unwatched: !viewingIn,
|
|
44
44
|
viewingIn,
|
|
45
45
|
recovery: resumable
|
|
46
|
-
? { command: 'agents', args: ['
|
|
46
|
+
? { command: 'agents', args: ['ps', 'focus', row.sessionId], ...(row.cwd ? { cwd: row.cwd } : {}) }
|
|
47
47
|
: null,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -126,14 +126,13 @@ export function toPreviousSessionWatchRow(scope, session, accounts = listNativeA
|
|
|
126
126
|
unwatched: true,
|
|
127
127
|
viewingIn: null,
|
|
128
128
|
recovery: resumable
|
|
129
|
-
? { command: 'agents', args: ['
|
|
129
|
+
? { command: 'agents', args: ['ps', 'focus', session.id], ...(session.cwd ? { cwd: session.cwd } : {}) }
|
|
130
130
|
: null,
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
function demoteWatchRow(scope, row) {
|
|
134
134
|
if (!row.sessionId || row.rowKey === previousSessionWatchRowKey(scope, row.sessionId))
|
|
135
135
|
return null;
|
|
136
|
-
const sourceDevice = row.sourceDevice || scope;
|
|
137
136
|
return {
|
|
138
137
|
...row,
|
|
139
138
|
context: 'recent',
|
|
@@ -145,7 +144,7 @@ function demoteWatchRow(scope, row) {
|
|
|
145
144
|
unwatched: true,
|
|
146
145
|
viewingIn: null,
|
|
147
146
|
recovery: row.resumable
|
|
148
|
-
? { command: 'agents', args: ['
|
|
147
|
+
? { command: 'agents', args: ['ps', 'focus', row.sessionId], ...(row.cwd ? { cwd: row.cwd } : {}) }
|
|
149
148
|
: null,
|
|
150
149
|
};
|
|
151
150
|
}
|
|
@@ -370,7 +369,7 @@ export async function watchLocalSessions(options) {
|
|
|
370
369
|
});
|
|
371
370
|
}
|
|
372
371
|
function remoteWatchCommand(os) {
|
|
373
|
-
const args = ['
|
|
372
|
+
const args = ['ps', 'watch', '--json', '--local'];
|
|
374
373
|
return remoteShellFor(os) === 'powershell'
|
|
375
374
|
? buildWindowsAgentsCommand({ args })
|
|
376
375
|
: `bash -lc ${shellQuote(`agents ${args.map(shellQuote).join(' ')}`)}`;
|
|
@@ -27,7 +27,7 @@ export function parseRemoteActive(stdout, machine) {
|
|
|
27
27
|
}
|
|
28
28
|
export async function gatherRemoteActive(hosts, opts) {
|
|
29
29
|
const result = await gatherRemoteAgentsJson({
|
|
30
|
-
args: ['
|
|
30
|
+
args: ['ps', '--local', '--json'],
|
|
31
31
|
noFanoutEnv: NO_FANOUT_ENV,
|
|
32
32
|
hosts,
|
|
33
33
|
parse: parseRemoteActive,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SessionMeta } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
-
export declare function buildCanonicalResumeCommand(sessionId: string): string[];
|
|
3
2
|
export declare function resumeSessionInPlace(session: SessionMeta): Promise<void>;
|
|
4
3
|
export declare function buildSessionRecoveryCommand(session: Pick<SessionMeta, 'id'>, portable?: boolean): string[];
|
|
5
4
|
export declare function resumeSpawnInvocation(cmd: string[], platform?: NodeJS.Platform): {
|
|
@@ -8,14 +8,11 @@ import { composeWin32CommandLine, needsWindowsShell } from '../platform/index.js
|
|
|
8
8
|
import { getShimsDir } from '../state.js';
|
|
9
9
|
import { sessionAgentSupportsResume, sessionRecoveryRunArgs } from './recovery.js';
|
|
10
10
|
import { sessionOwnerDevice } from './resume-owner.js';
|
|
11
|
-
export function buildCanonicalResumeCommand(sessionId) {
|
|
12
|
-
return ['agents', 'sessions', 'resume', sessionId];
|
|
13
|
-
}
|
|
14
11
|
export async function resumeSessionInPlace(session) {
|
|
15
12
|
const owner = sessionOwnerDevice(session);
|
|
16
13
|
if (owner) {
|
|
17
14
|
console.error(chalk.red(`Session ${session.shortId} belongs to ${owner} — it cannot resume on this machine.`));
|
|
18
|
-
console.error(chalk.gray(` Resume it there: agents
|
|
15
|
+
console.error(chalk.gray(` Resume it there: agents run auto --resume ${session.id}`));
|
|
19
16
|
process.exitCode = 1;
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { SessionMeta } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
-
export declare const RESUME_PINNED_ENV = "AGENTS_RESUME_PINNED";
|
|
3
|
-
export declare function consumeResumePinned(): boolean;
|
|
4
2
|
export declare function sessionOwnerDevice(session: Pick<SessionMeta, 'machine'>): string | undefined;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { isSelfHost } from '../devices/self-host.js';
|
|
2
|
-
export const RESUME_PINNED_ENV = 'AGENTS_RESUME_PINNED';
|
|
3
|
-
export function consumeResumePinned() {
|
|
4
|
-
const pinned = process.env[RESUME_PINNED_ENV] === '1';
|
|
5
|
-
delete process.env[RESUME_PINNED_ENV];
|
|
6
|
-
return pinned;
|
|
7
|
-
}
|
|
8
2
|
export function sessionOwnerDevice(session) {
|
|
9
3
|
const owner = session.machine?.trim();
|
|
10
4
|
if (!owner)
|
|
@@ -2,7 +2,7 @@ import type { SessionAgentId, SessionMeta } from '@phnx-labs/sessions-cli/reader
|
|
|
2
2
|
import { type ActiveSession } from './active.js';
|
|
3
3
|
import { loadLocalActiveSessions } from './session-cache.js';
|
|
4
4
|
import { gatherRemoteList, runOnPeer } from './remote/remote-list.js';
|
|
5
|
-
|
|
5
|
+
interface SessionFilterOptions {
|
|
6
6
|
agent?: string;
|
|
7
7
|
version?: string;
|
|
8
8
|
sessionVersion?: string;
|
|
@@ -42,8 +42,7 @@ export declare function resolveSessionQuery(pool: SessionMeta[], query: string,
|
|
|
42
42
|
}): SessionQueryResolution;
|
|
43
43
|
export declare function filterSessionsByQuery(sessions: SessionMeta[], query: string | undefined, scope?: SessionSearchScope): SessionMeta[];
|
|
44
44
|
export declare function applyScopeFilters(sessions: SessionMeta[], scope: SessionSearchScope): SessionMeta[];
|
|
45
|
-
|
|
46
|
-
export interface FleetResolveDeps {
|
|
45
|
+
interface FleetResolveDeps {
|
|
47
46
|
gatherRemoteList: typeof gatherRemoteList;
|
|
48
47
|
runOnPeer: typeof runOnPeer;
|
|
49
48
|
}
|
|
@@ -51,7 +50,7 @@ interface FleetHit {
|
|
|
51
50
|
machine: string;
|
|
52
51
|
session: SessionMeta;
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
interface FleetSessionCandidate {
|
|
55
54
|
id: string;
|
|
56
55
|
hits: FleetHit[];
|
|
57
56
|
}
|
|
@@ -78,7 +77,7 @@ export declare function metadataResolveOutcome(localMatches: SessionMeta[], remo
|
|
|
78
77
|
}, selector: string): MetadataResolveOutcome;
|
|
79
78
|
export declare function isLocallyDefinitiveMatch(session: SessionMeta, self: string): boolean;
|
|
80
79
|
export declare function preferOwnerAttribution(localMatches: SessionMeta[], remoteSessions: SessionMeta[], self: string): SessionMeta[];
|
|
81
|
-
|
|
80
|
+
type LiveMetadataDeps = {
|
|
82
81
|
loadActive?: typeof loadLocalActiveSessions;
|
|
83
82
|
loadFleetActive?: () => ActiveSession[];
|
|
84
83
|
};
|
|
@@ -250,7 +250,7 @@ export function applyScopeFilters(sessions, scope) {
|
|
|
250
250
|
}
|
|
251
251
|
return filtered;
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
function scopedContentIndex(sessions, query, scope) {
|
|
254
254
|
const hits = searchContentIndex(sessions, query);
|
|
255
255
|
if (!scope || (!scope.agent && !scope.project && !scope.routine))
|
|
256
256
|
return hits;
|
|
@@ -316,7 +316,7 @@ function indexedRowsForSelector(selector, scope) {
|
|
|
316
316
|
return applyScopeFilters(indexed, scope);
|
|
317
317
|
}
|
|
318
318
|
export function metadataResolveForwardedArgs(selector, scope) {
|
|
319
|
-
const args = ['
|
|
319
|
+
const args = ['ps', 'resolve', selector, '--json', '--local'];
|
|
320
320
|
if (scope.agent)
|
|
321
321
|
args.push('--agent', scope.agent);
|
|
322
322
|
if (scope.project)
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* R2 credential resolution + this machine's stable identity. Two consumers read
|
|
3
|
-
* these fields: `agents sessions export --encrypt` / `import` use only the shared
|
|
4
|
-
* `R2_SYNC_ENC_KEY` transcript key (`resolveSyncEncKey`), falling back to an
|
|
5
|
-
* ephemeral key when no bundle is configured; and the off-box backup target
|
|
6
|
-
* (`agents sessions export --to-r2` / `import --from-r2`, RUSH-2437) uses the full
|
|
7
|
-
* credential set (account/bucket/access keys/endpoint) to talk to R2 through the
|
|
8
|
-
* network client in `./r2.ts`. The `--to-r2`/`--from-r2` paths gate on
|
|
9
|
-
* `isSyncConfigured()` and fail loud when the bundle is absent (no silent
|
|
10
|
-
* fallback). This is a pure on-demand backup target, NOT the retired R2/CRDT
|
|
11
|
-
* background sync. Credentials come from the `r2.backups` secrets bundle (OS
|
|
12
|
-
* keychain on macOS, libsecret on Linux) — never from env or disk.
|
|
13
|
-
*/
|
|
14
|
-
export declare const SYNC_BUNDLE = "r2.backups";
|
|
15
|
-
export interface R2Config {
|
|
16
|
-
accountId: string;
|
|
17
|
-
bucket: string;
|
|
18
|
-
accessKeyId: string;
|
|
19
|
-
secretAccessKey: string;
|
|
20
|
-
endpoint: string;
|
|
21
|
-
syncEncKey?: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function clearR2ConfigCache(): void;
|
|
24
|
-
export declare function loadR2Config(): R2Config;
|
|
25
|
-
export declare function isSyncConfigured(_now?: number): boolean;
|
|
26
1
|
export { machineId, normalizeHost } from '../../machine-id.js';
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* R2 credential resolution + this machine's stable identity. Two consumers read
|
|
3
|
-
* these fields: `agents sessions export --encrypt` / `import` use only the shared
|
|
4
|
-
* `R2_SYNC_ENC_KEY` transcript key (`resolveSyncEncKey`), falling back to an
|
|
5
|
-
* ephemeral key when no bundle is configured; and the off-box backup target
|
|
6
|
-
* (`agents sessions export --to-r2` / `import --from-r2`, RUSH-2437) uses the full
|
|
7
|
-
* credential set (account/bucket/access keys/endpoint) to talk to R2 through the
|
|
8
|
-
* network client in `./r2.ts`. The `--to-r2`/`--from-r2` paths gate on
|
|
9
|
-
* `isSyncConfigured()` and fail loud when the bundle is absent (no silent
|
|
10
|
-
* fallback). This is a pure on-demand backup target, NOT the retired R2/CRDT
|
|
11
|
-
* background sync. Credentials come from the `r2.backups` secrets bundle (OS
|
|
12
|
-
* keychain on macOS, libsecret on Linux) — never from env or disk.
|
|
13
|
-
*/
|
|
14
|
-
import { readAndResolveBundleEnvSync } from '../../secrets-client.js';
|
|
15
|
-
export const SYNC_BUNDLE = 'r2.backups';
|
|
16
|
-
function resolveR2Config() {
|
|
17
|
-
const { env } = readAndResolveBundleEnvSync(SYNC_BUNDLE, { caller: 'session-transport', agentOnly: true });
|
|
18
|
-
const accountId = env.R2_ACCOUNT_ID?.trim();
|
|
19
|
-
const bucket = env.R2_BUCKET_NAME?.trim();
|
|
20
|
-
const accessKeyId = env.R2_ACCESS_KEY_ID?.trim();
|
|
21
|
-
const secretAccessKey = env.R2_SECRET_ACCESS_KEY?.trim();
|
|
22
|
-
const syncEncKey = env.R2_SYNC_ENC_KEY?.trim() || undefined;
|
|
23
|
-
const missing = [
|
|
24
|
-
!accountId && 'R2_ACCOUNT_ID',
|
|
25
|
-
!bucket && 'R2_BUCKET_NAME',
|
|
26
|
-
!accessKeyId && 'R2_ACCESS_KEY_ID',
|
|
27
|
-
!secretAccessKey && 'R2_SECRET_ACCESS_KEY',
|
|
28
|
-
].filter(Boolean);
|
|
29
|
-
if (missing.length > 0) {
|
|
30
|
-
throw new Error(`Session R2 transport: bundle '${SYNC_BUNDLE}' is missing ${missing.join(', ')}. ` +
|
|
31
|
-
`Add them with: agents secrets add ${SYNC_BUNDLE} <KEY>`);
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
accountId: accountId,
|
|
35
|
-
bucket: bucket,
|
|
36
|
-
accessKeyId: accessKeyId,
|
|
37
|
-
secretAccessKey: secretAccessKey,
|
|
38
|
-
endpoint: env.R2_ENDPOINT?.trim() || `https://${accountId}.r2.cloudflarestorage.com`,
|
|
39
|
-
syncEncKey,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
let cachedConfig = null;
|
|
43
|
-
export function clearR2ConfigCache() {
|
|
44
|
-
cachedConfig = null;
|
|
45
|
-
}
|
|
46
|
-
export function loadR2Config() {
|
|
47
|
-
if (cachedConfig)
|
|
48
|
-
return cachedConfig;
|
|
49
|
-
cachedConfig = resolveR2Config();
|
|
50
|
-
return cachedConfig;
|
|
51
|
-
}
|
|
52
|
-
export function isSyncConfigured(_now = Date.now()) {
|
|
53
|
-
if (cachedConfig)
|
|
54
|
-
return true;
|
|
55
|
-
try {
|
|
56
|
-
loadR2Config();
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
1
|
export { machineId, normalizeHost } from '../../machine-id.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const DEFAULT_SESSIONS_DOMAIN = "sessions.agents-cli.sh";
|
|
2
2
|
export declare const DEFAULT_SESSIONS_WORKER_NAME = "agents-sessions";
|
|
3
3
|
export declare const DEFAULT_SESSIONS_BUCKET_NAME = "agents-sessions";
|
|
4
|
-
export declare function managedSessionsBaseUrl(): string;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export const DEFAULT_SESSIONS_DOMAIN = 'sessions.agents-cli.sh';
|
|
2
2
|
export const DEFAULT_SESSIONS_WORKER_NAME = 'agents-sessions';
|
|
3
3
|
export const DEFAULT_SESSIONS_BUCKET_NAME = 'agents-sessions';
|
|
4
|
-
export function managedSessionsBaseUrl() {
|
|
5
|
-
return `https://${DEFAULT_SESSIONS_DOMAIN}`;
|
|
6
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function renderSessionsWorkerScript() {
|
|
2
|
-
return `// GENERATED by agents
|
|
2
|
+
return `// GENERATED by agents setup session-backup — do not edit; edit
|
|
3
3
|
// src/lib/session/sync/worker-template.ts and re-provision.
|
|
4
4
|
export const hooks = {
|
|
5
5
|
verifyPhoenixToken: defaultVerifyPhoenixToken,
|
|
@@ -8,20 +8,4 @@ export declare function invocation(bin: string): {
|
|
|
8
8
|
prefix: string[];
|
|
9
9
|
};
|
|
10
10
|
export declare function runSessions(argv: string[]): Promise<number>;
|
|
11
|
-
export declare function usesFilterFlags(args: string[]): boolean;
|
|
12
|
-
export declare function usesHostFlag(args: string[]): boolean;
|
|
13
|
-
export declare function sessionsBinSupports(bin: string, minVersion: string): boolean;
|
|
14
|
-
export declare function sessionsBinSupportsFilters(bin: string): boolean;
|
|
15
|
-
export declare function sessionsBinSupportsHost(bin: string): boolean;
|
|
16
|
-
export declare function isReadQuery(args: string[], opts?: {
|
|
17
|
-
filters?: boolean;
|
|
18
|
-
host?: boolean;
|
|
19
|
-
}): boolean;
|
|
20
|
-
export declare function planDeviceHostRead(args: string[], opts?: {
|
|
21
|
-
filters?: boolean;
|
|
22
|
-
}): {
|
|
23
|
-
device: string;
|
|
24
|
-
readArgs: string[];
|
|
25
|
-
} | null;
|
|
26
11
|
export declare function _resetSessionsClientForTest(): void;
|
|
27
|
-
export declare const SESSIONS_INSTALL_HINT = "npm i -g @phnx-labs/sessions-cli";
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { spawn
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { findInPath } from './agent-spec/agents.js';
|
|
6
|
-
import { compareVersions } from './agent-spec/primitives.js';
|
|
7
|
-
import { stripRoutingFlags } from './hosts/remote-cmd.js';
|
|
8
6
|
const INSTALL_HINT = 'npm i -g @phnx-labs/sessions-cli';
|
|
9
|
-
const SESSIONS_FILTERS_MIN_VERSION = '0.2.0';
|
|
10
|
-
const SESSIONS_HOST_MIN_VERSION = '0.2.1';
|
|
11
7
|
export class SessionsClientError extends Error {
|
|
12
8
|
code;
|
|
13
9
|
constructor(code, message) {
|
|
@@ -40,7 +36,6 @@ function dependencySessionsBin() {
|
|
|
40
36
|
}
|
|
41
37
|
return realpathSync(abs);
|
|
42
38
|
}
|
|
43
|
-
// Skip the legacy agents shim to avoid recursive sessions passthrough.
|
|
44
39
|
export function resolveSessionsBin() {
|
|
45
40
|
if (cachedBin)
|
|
46
41
|
return cachedBin;
|
|
@@ -80,187 +75,6 @@ export function runSessions(argv) {
|
|
|
80
75
|
});
|
|
81
76
|
});
|
|
82
77
|
}
|
|
83
|
-
const READ_FLAGS = new Set([
|
|
84
|
-
'--json',
|
|
85
|
-
'--local',
|
|
86
|
-
'--no-interactive',
|
|
87
|
-
]);
|
|
88
|
-
const FILTER_BOOL_FLAGS = new Set([
|
|
89
|
-
'--claude',
|
|
90
|
-
'--codex',
|
|
91
|
-
'--kimi',
|
|
92
|
-
'--antigravity',
|
|
93
|
-
'--grok',
|
|
94
|
-
'--opencode',
|
|
95
|
-
]);
|
|
96
|
-
const FILTER_VALUE_FLAGS = new Set([
|
|
97
|
-
'--project',
|
|
98
|
-
'--since',
|
|
99
|
-
'--until',
|
|
100
|
-
'--sort',
|
|
101
|
-
]);
|
|
102
|
-
export function usesFilterFlags(args) {
|
|
103
|
-
return args.some((arg) => {
|
|
104
|
-
if (arg === '-p' || arg === '-a')
|
|
105
|
-
return true;
|
|
106
|
-
if (FILTER_BOOL_FLAGS.has(arg))
|
|
107
|
-
return true;
|
|
108
|
-
for (const vf of FILTER_VALUE_FLAGS) {
|
|
109
|
-
if (arg === vf || arg.startsWith(`${vf}=`))
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
export function usesHostFlag(args) {
|
|
116
|
-
return args.some((arg) => arg === '--host' || arg.startsWith('--host='));
|
|
117
|
-
}
|
|
118
|
-
let cachedProbedVersion;
|
|
119
|
-
function probeSessionsVersion(bin) {
|
|
120
|
-
if (cachedProbedVersion !== undefined)
|
|
121
|
-
return cachedProbedVersion;
|
|
122
|
-
const { command, prefix } = invocation(bin);
|
|
123
|
-
const res = spawnSync(command, [...prefix, '--version'], { encoding: 'utf8', timeout: 3000 });
|
|
124
|
-
const version = (res.stdout ?? '').trim();
|
|
125
|
-
cachedProbedVersion = !res.error && /^\d+\.\d+\.\d+/.test(version) ? version : null;
|
|
126
|
-
return cachedProbedVersion;
|
|
127
|
-
}
|
|
128
|
-
// Failed or old version probes stay in the in-repo engine because an old CLI may treat unknown flags as FTS terms.
|
|
129
|
-
export function sessionsBinSupports(bin, minVersion) {
|
|
130
|
-
const version = probeSessionsVersion(bin);
|
|
131
|
-
return version !== null && compareVersions(version, minVersion) >= 0;
|
|
132
|
-
}
|
|
133
|
-
export function sessionsBinSupportsFilters(bin) {
|
|
134
|
-
return sessionsBinSupports(bin, SESSIONS_FILTERS_MIN_VERSION);
|
|
135
|
-
}
|
|
136
|
-
export function sessionsBinSupportsHost(bin) {
|
|
137
|
-
return sessionsBinSupports(bin, SESSIONS_HOST_MIN_VERSION);
|
|
138
|
-
}
|
|
139
|
-
const ENGINE_VERBS = new Set([
|
|
140
|
-
'resume',
|
|
141
|
-
'detach',
|
|
142
|
-
'stop',
|
|
143
|
-
'inject',
|
|
144
|
-
'fork',
|
|
145
|
-
'backfill',
|
|
146
|
-
'migrate',
|
|
147
|
-
'share',
|
|
148
|
-
'export',
|
|
149
|
-
'import',
|
|
150
|
-
'optimize',
|
|
151
|
-
'trace',
|
|
152
|
-
'insights',
|
|
153
|
-
'bookmark',
|
|
154
|
-
'tail',
|
|
155
|
-
'watch',
|
|
156
|
-
'preview',
|
|
157
|
-
'focus',
|
|
158
|
-
'render',
|
|
159
|
-
'stats',
|
|
160
|
-
'migrations',
|
|
161
|
-
'export',
|
|
162
|
-
]);
|
|
163
|
-
export function isReadQuery(args, opts = {}) {
|
|
164
|
-
if (args.length === 0)
|
|
165
|
-
return false;
|
|
166
|
-
const valueFlags = new Set(['--limit', '--agent']);
|
|
167
|
-
const boolFlags = new Set(READ_FLAGS);
|
|
168
|
-
if (opts.filters) {
|
|
169
|
-
for (const vf of FILTER_VALUE_FLAGS)
|
|
170
|
-
valueFlags.add(vf);
|
|
171
|
-
for (const bf of FILTER_BOOL_FLAGS)
|
|
172
|
-
boolFlags.add(bf);
|
|
173
|
-
}
|
|
174
|
-
if (opts.host)
|
|
175
|
-
valueFlags.add('--host');
|
|
176
|
-
for (let i = 0; i < args.length; i++) {
|
|
177
|
-
const arg = args[i];
|
|
178
|
-
if (opts.filters && (arg === '-a' || arg === '-p')) {
|
|
179
|
-
i += 1;
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
let matchedValue = false;
|
|
183
|
-
for (const vf of valueFlags) {
|
|
184
|
-
if (arg === vf) {
|
|
185
|
-
i += 1;
|
|
186
|
-
matchedValue = true;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
if (arg.startsWith(`${vf}=`)) {
|
|
190
|
-
matchedValue = true;
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (matchedValue)
|
|
195
|
-
continue;
|
|
196
|
-
if (arg.startsWith('-')) {
|
|
197
|
-
if (!boolFlags.has(arg))
|
|
198
|
-
return false;
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
if (ENGINE_VERBS.has(arg))
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
function scanDeviceFlag(args) {
|
|
207
|
-
let count = 0;
|
|
208
|
-
let value;
|
|
209
|
-
let valueEndIndex;
|
|
210
|
-
for (let i = 0; i < args.length; i++) {
|
|
211
|
-
const a = args[i];
|
|
212
|
-
let matched = false;
|
|
213
|
-
let v;
|
|
214
|
-
let endIdx = i;
|
|
215
|
-
if (a === '--device' || a === '-D') {
|
|
216
|
-
matched = true;
|
|
217
|
-
v = args[i + 1];
|
|
218
|
-
endIdx = i + 1;
|
|
219
|
-
}
|
|
220
|
-
else if (a.startsWith('--device=')) {
|
|
221
|
-
matched = true;
|
|
222
|
-
v = a.slice('--device='.length);
|
|
223
|
-
}
|
|
224
|
-
else if (a.startsWith('-D=')) {
|
|
225
|
-
matched = true;
|
|
226
|
-
v = a.slice(3);
|
|
227
|
-
}
|
|
228
|
-
else if (/^-D.+/.test(a)) {
|
|
229
|
-
matched = true;
|
|
230
|
-
v = a.slice(2);
|
|
231
|
-
}
|
|
232
|
-
if (matched) {
|
|
233
|
-
count += 1;
|
|
234
|
-
if (count === 1) {
|
|
235
|
-
value = v;
|
|
236
|
-
valueEndIndex = endIdx;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return { count, value, valueEndIndex };
|
|
241
|
-
}
|
|
242
|
-
// Collapse --device to --host only for one unambiguous read; multi/fleet/lifecycle queries remain on in-repo fan-out.
|
|
243
|
-
export function planDeviceHostRead(args, opts = {}) {
|
|
244
|
-
const { count, value, valueEndIndex } = scanDeviceFlag(args);
|
|
245
|
-
if (count !== 1)
|
|
246
|
-
return null;
|
|
247
|
-
if (value === undefined || value === '' || value.startsWith('-'))
|
|
248
|
-
return null;
|
|
249
|
-
if (usesHostFlag(args))
|
|
250
|
-
return null;
|
|
251
|
-
const lower = value.toLowerCase();
|
|
252
|
-
if (lower === 'all' || lower === 'fleet')
|
|
253
|
-
return null;
|
|
254
|
-
const next = valueEndIndex !== undefined ? args[valueEndIndex + 1] : undefined;
|
|
255
|
-
if (next !== undefined && !next.startsWith('-'))
|
|
256
|
-
return null;
|
|
257
|
-
const readArgs = stripRoutingFlags(args, [{ long: 'device', short: 'D', takesValue: true }]);
|
|
258
|
-
if (!isReadQuery(readArgs, { filters: opts.filters }))
|
|
259
|
-
return null;
|
|
260
|
-
return { device: value, readArgs };
|
|
261
|
-
}
|
|
262
78
|
export function _resetSessionsClientForTest() {
|
|
263
79
|
cachedBin = undefined;
|
|
264
|
-
cachedProbedVersion = undefined;
|
|
265
80
|
}
|
|
266
|
-
export const SESSIONS_INSTALL_HINT = INSTALL_HINT;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const KNOWN_TOP_LEVEL_COMMANDS: ReadonlySet<string>;
|
|
2
2
|
export declare const RETIRED_TOP_LEVEL_COMMANDS: ReadonlySet<string>;
|
|
3
|
+
export declare const REMOVED_TOOL_GROUPS: ReadonlySet<string>;
|
|
4
|
+
export declare function removedToolGroupMessage(group: string, rest: readonly string[]): string | undefined;
|
|
3
5
|
export declare function isKnownTopLevelCommand(name: string): boolean;
|
|
@@ -4,10 +4,10 @@ const LOADED_COMMAND_NAMES = [
|
|
|
4
4
|
'remove', 'rm', 'purge', 'update', 'prune', 'import',
|
|
5
5
|
'routines', 'projects', 'run', '_callback', 'open', 'fork', 'config',
|
|
6
6
|
'models', 'doctor',
|
|
7
|
-
'harness', 'harnesses', '
|
|
7
|
+
'harness', 'harnesses', 'menubar', 'sync',
|
|
8
8
|
'refresh-rules', 'factory', 'insights', 'trace',
|
|
9
|
-
'watchdog', '
|
|
10
|
-
'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade',
|
|
9
|
+
'watchdog', 'events',
|
|
10
|
+
'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade',
|
|
11
11
|
'teams', 'cloud', 'ps', 'send', 'feed',
|
|
12
12
|
'daemon', 'recordings',
|
|
13
13
|
];
|
|
@@ -70,6 +70,39 @@ export const RETIRED_TOP_LEVEL_COMMANDS = new Set([
|
|
|
70
70
|
'logs',
|
|
71
71
|
'trash',
|
|
72
72
|
]);
|
|
73
|
+
const STANDALONE_TOOL_GROUPS = ['browser', 'computer', 'secrets', 'sessions'];
|
|
74
|
+
const MOVED_SESSIONS_VERBS = {
|
|
75
|
+
resume: 'agents run auto --resume <id>',
|
|
76
|
+
focus: 'agents ps focus',
|
|
77
|
+
stop: 'agents ps stop',
|
|
78
|
+
detach: 'agents ps detach',
|
|
79
|
+
migrate: 'agents ps migrate',
|
|
80
|
+
migrations: 'agents ps migrations',
|
|
81
|
+
preview: 'agents ps preview',
|
|
82
|
+
watch: 'agents ps watch --json',
|
|
83
|
+
inject: 'agents send --channel session --to <id> --text <text>',
|
|
84
|
+
fork: 'agents fork',
|
|
85
|
+
backfill: 'agents daemon index backfill',
|
|
86
|
+
optimize: 'agents daemon index optimize',
|
|
87
|
+
stats: 'agents insights resources',
|
|
88
|
+
insights: 'agents insights',
|
|
89
|
+
'backup-setup': 'agents setup session-backup',
|
|
90
|
+
};
|
|
91
|
+
export const REMOVED_TOOL_GROUPS = new Set(STANDALONE_TOOL_GROUPS);
|
|
92
|
+
export function removedToolGroupMessage(group, rest) {
|
|
93
|
+
if (!REMOVED_TOOL_GROUPS.has(group))
|
|
94
|
+
return undefined;
|
|
95
|
+
const verb = group === 'sessions' ? rest.find((arg) => Object.hasOwn(MOVED_SESSIONS_VERBS, arg)) : undefined;
|
|
96
|
+
const moved = verb === undefined ? undefined : MOVED_SESSIONS_VERBS[verb];
|
|
97
|
+
if (moved)
|
|
98
|
+
return `error: 'agents sessions ${verb}' was removed; use '${moved}'.`;
|
|
99
|
+
if (group === 'sessions' && rest.some((arg) => arg === '--active' || arg === '--roots')) {
|
|
100
|
+
return rest.includes('--roots')
|
|
101
|
+
? `error: 'agents sessions --roots' was removed; use 'agents daemon index roots'.`
|
|
102
|
+
: `error: 'agents sessions --active' was removed; use 'agents ps'.`;
|
|
103
|
+
}
|
|
104
|
+
return `error: 'agents ${group}' was removed; use the standalone '${group}' CLI (${group} --help).`;
|
|
105
|
+
}
|
|
73
106
|
export function isKnownTopLevelCommand(name) {
|
|
74
107
|
return KNOWN_TOP_LEVEL_COMMANDS.has(name);
|
|
75
108
|
}
|
|
@@ -8,24 +8,3 @@ export function configureRootCommand(program, name, version) {
|
|
|
8
8
|
.helpOption('-h, --help', 'Show help')
|
|
9
9
|
.addHelpCommand(false);
|
|
10
10
|
}
|
|
11
|
-
export function normalizeResumeDeviceArgs(args) {
|
|
12
|
-
if (args[0] !== 'sessions' || args[1] !== 'resume')
|
|
13
|
-
return args;
|
|
14
|
-
let options = true;
|
|
15
|
-
return args.map((arg, index) => {
|
|
16
|
-
if (index < 2 || !options)
|
|
17
|
-
return arg;
|
|
18
|
-
if (arg === '--') {
|
|
19
|
-
options = false;
|
|
20
|
-
return arg;
|
|
21
|
-
}
|
|
22
|
-
if (arg === '--device' || arg === '--devices' || arg === '-D')
|
|
23
|
-
return '--resume-device';
|
|
24
|
-
if (arg.startsWith('--device=') || arg.startsWith('--devices=')) {
|
|
25
|
-
return `--resume-device=${arg.slice(arg.indexOf('=') + 1)}`;
|
|
26
|
-
}
|
|
27
|
-
if (arg.startsWith('-D'))
|
|
28
|
-
return `--resume-device=${arg.slice(arg[2] === '=' ? 3 : 2)}`;
|
|
29
|
-
return arg;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
@@ -59,7 +59,7 @@ export async function runUmbrellaSync(args) {
|
|
|
59
59
|
result.secrets = {
|
|
60
60
|
pulled: 0,
|
|
61
61
|
skipped: true,
|
|
62
|
-
reason: `no passphrase — set ${SYNC_PASSPHRASE_ENV} or run \`
|
|
62
|
+
reason: `no passphrase — set ${SYNC_PASSPHRASE_ENV} or run \`secrets vault unlock\` (#366)`,
|
|
63
63
|
errors: [],
|
|
64
64
|
};
|
|
65
65
|
log(`secrets: skipped (no passphrase — set ${SYNC_PASSPHRASE_ENV})`);
|
|
@@ -10,7 +10,7 @@ export function addressabilityRecoveryHint(session, fallbackId) {
|
|
|
10
10
|
const resumeId = sid ?? fallbackId;
|
|
11
11
|
const shortId = resumeId ? resumeId.slice(0, 8) : '<id>';
|
|
12
12
|
const device = session.machine ?? machineId();
|
|
13
|
-
const resumeCmd = resumeId ? `agents
|
|
13
|
+
const resumeCmd = resumeId ? `agents run auto --resume ${shortId}` : 'agents run auto --resume <id>';
|
|
14
14
|
const tmuxCmd = `agents config set devices.${device}.tmux on`;
|
|
15
15
|
const interactive = session.context === 'terminal' || !!session.tty;
|
|
16
16
|
if (session.host === 'ghostty') {
|
|
@@ -100,7 +100,7 @@ function shellQuoteHost(value) {
|
|
|
100
100
|
}
|
|
101
101
|
export function buildRotateReplayText(oldSessionId) {
|
|
102
102
|
return (`Resume previous work by loading session ${oldSessionId}. ` +
|
|
103
|
-
`Run \`
|
|
103
|
+
`Run \`sessions ${oldSessionId}\` to load the transcript, assess current state, then continue working.`);
|
|
104
104
|
}
|
|
105
105
|
export const DEFAULT_ROTATE_READINESS_MS = 60_000;
|
|
106
106
|
export const DEFAULT_ROTATE_SKIP_COOLDOWN_MS = 30 * 60_000;
|
|
@@ -36,7 +36,7 @@ interface ClassifyInput {
|
|
|
36
36
|
dormantMs: number;
|
|
37
37
|
}
|
|
38
38
|
export declare function classifyTerminal(input: ClassifyInput): StallStatus;
|
|
39
|
-
export declare const WATCHDOG_SYSTEM_PROMPT = "You are the watchdog for AI coding agents running in terminals. You are given the idle\nsessions on this machine \u2014 each with its originating TASK, how long it has been idle, and\nthe tail of its transcript. Your one job is to tell, for each one, whether it is\nIDLE-BUT-UNFINISHED (it was given a task, went quiet, and has NOT finished or handed it\noff) or IDLE-AND-DONE (it finished, or it genuinely needs the human). Idle-but-unfinished\nis the dangerous state \u2014 the work is most likely to be silently abandoned \u2014 so those get a\nNUDGE that drives them to finish. Everything else is a SKIP.\n\nRead each transcript before judging \u2014 an agent that already reached a decision needs \"do\nit,\" not \"decide.\" Judge from the task + tail, not from keywords.\n\nNUDGE when the agent went idle and could keep going on its own:\n- It asked permission for an obvious or already-authorized next step\n (\"should I proceed?\", \"want me to continue?\", \"shall I run the tests?\").\n- It asked a question it could answer itself from the available context or a\n reasonable default, or by using a tool it already has.\n- It announced an action (\"I'll run X\", \"let me write Y\") but no tool call followed.\n- It already decided what to do, then stalled without doing it.\n- It paused with the task incomplete and no real blocker.\n\nThe nudge text MUST carry context, not shove:\n- Restate the goal and reference the conclusion the agent ALREADY reached.\n- Give ONE concrete next step \u2014 the specific action, the sensible default, or a TOOL it\n forgot it has (e.g. \"
|
|
39
|
+
export declare const WATCHDOG_SYSTEM_PROMPT = "You are the watchdog for AI coding agents running in terminals. You are given the idle\nsessions on this machine \u2014 each with its originating TASK, how long it has been idle, and\nthe tail of its transcript. Your one job is to tell, for each one, whether it is\nIDLE-BUT-UNFINISHED (it was given a task, went quiet, and has NOT finished or handed it\noff) or IDLE-AND-DONE (it finished, or it genuinely needs the human). Idle-but-unfinished\nis the dangerous state \u2014 the work is most likely to be silently abandoned \u2014 so those get a\nNUDGE that drives them to finish. Everything else is a SKIP.\n\nRead each transcript before judging \u2014 an agent that already reached a decision needs \"do\nit,\" not \"decide.\" Judge from the task + tail, not from keywords.\n\nNUDGE when the agent went idle and could keep going on its own:\n- It asked permission for an obvious or already-authorized next step\n (\"should I proceed?\", \"want me to continue?\", \"shall I run the tests?\").\n- It asked a question it could answer itself from the available context or a\n reasonable default, or by using a tool it already has.\n- It announced an action (\"I'll run X\", \"let me write Y\") but no tool call followed.\n- It already decided what to do, then stalled without doing it.\n- It paused with the task incomplete and no real blocker.\n\nThe nudge text MUST carry context, not shove:\n- Restate the goal and reference the conclusion the agent ALREADY reached.\n- Give ONE concrete next step \u2014 the specific action, the sensible default, or a TOOL it\n forgot it has (e.g. \"computer\" to drive the Mac, \"browser\" for the web,\n \"agents ssh <mac> \\\"computer \u2026\\\"\" to drive a Mac from another box).\n- Split the ask: drive the reversible, goal-advancing part now; flag only a genuinely\n disruptive sub-step for the human.\n- Tell it to use best judgment and finish end-to-end WITHOUT asking again.\n- Imperative, 1-2 sentences, no emojis, under 240 characters.\n\nSKIP in two distinct cases \u2014 mark which with \"needsHuman\":\n- needsHuman=true \u2014 the agent is genuinely blocked on a human (these belong in the user's\n feed): credentials, auth, login, 2FA, or biometric; an irreversible or outward-facing\n action needing sign-off (force-push, delete prod data, publish/release, spend money,\n send an external message) UNLESS the House Rules below authorize it; a real product or\n intent decision with genuine ambiguity (not a trivial default); or you cannot tell what\n the agent is doing.\n- needsHuman=false \u2014 the task is actually complete (idle-and-done). Leave it alone; do NOT\n poke a finished session.\n\nRespond with ONLY a JSON array (no prose, no code fence). Include \"needsHuman\" on every\nskip:\n[{\"terminalId\":\"<id>\",\"action\":\"nudge\"|\"skip\",\"text\":\"<message or empty>\",\"reason\":\"<brief>\",\"needsHuman\":true|false}]";
|
|
40
40
|
export declare function composePromptWithPlaybook(basePrompt: string, playbook: string): string;
|
|
41
41
|
export declare function renderWatchdogPrompt(candidates: WatchdogCandidate[], playbook?: string): string;
|
|
42
42
|
export declare function parseWatchdogResponse(stdout: string): Decision[];
|
|
@@ -37,8 +37,8 @@ NUDGE when the agent went idle and could keep going on its own:
|
|
|
37
37
|
The nudge text MUST carry context, not shove:
|
|
38
38
|
- Restate the goal and reference the conclusion the agent ALREADY reached.
|
|
39
39
|
- Give ONE concrete next step — the specific action, the sensible default, or a TOOL it
|
|
40
|
-
forgot it has (e.g. "
|
|
41
|
-
"agents ssh <mac> \\"
|
|
40
|
+
forgot it has (e.g. "computer" to drive the Mac, "browser" for the web,
|
|
41
|
+
"agents ssh <mac> \\"computer …\\"" to drive a Mac from another box).
|
|
42
42
|
- Split the ask: drive the reversible, goal-advancing part now; flag only a genuinely
|
|
43
43
|
disruptive sub-step for the human.
|
|
44
44
|
- Tell it to use best judgment and finish end-to-end WITHOUT asking again.
|