@phnx-labs/agents-cli 1.23.38 → 1.23.40

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +7 -20
  3. package/dist/cli/command-registry.js +0 -2
  4. package/dist/commands/config.js +0 -4
  5. package/dist/commands/daemon.js +5 -5
  6. package/dist/commands/events.js +1 -1
  7. package/dist/commands/exec.d.ts +4 -0
  8. package/dist/commands/exec.js +14 -1
  9. package/dist/commands/lead.js +4 -3
  10. package/dist/commands/setup.d.ts +1 -1
  11. package/dist/commands/setup.js +1 -9
  12. package/dist/commands/ssh.js +4 -5
  13. package/dist/lib/accounting/account-pool-collect.d.ts +1 -0
  14. package/dist/lib/accounting/account-pool-collect.js +13 -7
  15. package/dist/lib/accounting/account-pool.d.ts +1 -0
  16. package/dist/lib/accounting/account-pool.js +4 -3
  17. package/dist/lib/accounting/usage.d.ts +1 -1
  18. package/dist/lib/answer-router.d.ts +1 -1
  19. package/dist/lib/answer-router.js +16 -6
  20. package/dist/lib/channels/providers/session.js +13 -0
  21. package/dist/lib/channels/registry.d.ts +1 -1
  22. package/dist/lib/config-keys.d.ts +1 -1
  23. package/dist/lib/config-keys.js +1 -4
  24. package/dist/lib/daemon/daemon.js +1 -6
  25. package/dist/lib/daemon/device-probe-service.js +8 -0
  26. package/dist/lib/daemon-services.d.ts +1 -1
  27. package/dist/lib/daemon-services.js +1 -6
  28. package/dist/lib/device-config.js +2 -11
  29. package/dist/lib/devices/stats-cache.d.ts +24 -1
  30. package/dist/lib/devices/stats-cache.js +52 -18
  31. package/dist/lib/devices/worker-pick.d.ts +1 -1
  32. package/dist/lib/devices/worker-pick.js +8 -1
  33. package/dist/lib/feed/answer.js +25 -1
  34. package/dist/lib/feed/attention.d.ts +8 -0
  35. package/dist/lib/feed/attention.js +39 -0
  36. package/dist/lib/feed/tab-delivery.d.ts +27 -0
  37. package/dist/lib/feed/tab-delivery.js +102 -0
  38. package/dist/lib/feed/watch.d.ts +3 -0
  39. package/dist/lib/feed/watch.js +63 -13
  40. package/dist/lib/hosts/passthrough.js +0 -1
  41. package/dist/lib/hosts/ready.d.ts +3 -0
  42. package/dist/lib/hosts/ready.js +41 -1
  43. package/dist/lib/installations/migrate.d.ts +0 -1
  44. package/dist/lib/installations/migrate.js +0 -17
  45. package/dist/lib/lead/drafts.d.ts +11 -0
  46. package/dist/lib/lead/drafts.js +34 -0
  47. package/dist/lib/lead/host.d.ts +5 -0
  48. package/dist/lib/lead/host.js +52 -1
  49. package/dist/lib/lead/paths.js +1 -1
  50. package/dist/lib/lead/tools.d.ts +1 -0
  51. package/dist/lib/lead/tools.js +22 -0
  52. package/dist/lib/menubar/snapshot.d.ts +0 -6
  53. package/dist/lib/menubar/snapshot.js +0 -18
  54. package/dist/lib/session/active.d.ts +2 -1
  55. package/dist/lib/session/active.js +21 -9
  56. package/dist/lib/session/hook-sessions.d.ts +10 -0
  57. package/dist/lib/session/hook-sessions.js +22 -10
  58. package/dist/lib/session/inject-target.d.ts +1 -0
  59. package/dist/lib/session/inject-target.js +2 -1
  60. package/dist/lib/session/pid-registry.d.ts +1 -0
  61. package/dist/lib/session/remote/watch.d.ts +1 -0
  62. package/dist/lib/smart-launch.d.ts +5 -1
  63. package/dist/lib/smart-launch.js +41 -20
  64. package/dist/lib/startup/command-registry.js +2 -1
  65. package/dist/lib/state.js +0 -1
  66. package/dist/lib/teams/placement-probe.d.ts +5 -2
  67. package/dist/lib/teams/placement-probe.js +119 -57
  68. package/dist/lib/teams/scheduler.d.ts +1 -0
  69. package/dist/lib/terminal/index.d.ts +1 -1
  70. package/dist/lib/terminal/index.js +1 -1
  71. package/dist/lib/terminal/inject.d.ts +0 -15
  72. package/dist/lib/terminal/inject.js +2 -16
  73. package/dist/lib/terminal/resolve.d.ts +2 -1
  74. package/dist/lib/terminal/resolve.js +13 -18
  75. package/dist/lib/types.d.ts +0 -3
  76. package/package.json +1 -1
  77. package/dist/commands/setup-watchdog.d.ts +0 -3
  78. package/dist/commands/setup-watchdog.js +0 -49
  79. package/dist/commands/watchdog.d.ts +0 -4
  80. package/dist/commands/watchdog.js +0 -361
  81. package/dist/lib/daemon/watchdog-service.d.ts +0 -10
  82. package/dist/lib/daemon/watchdog-service.js +0 -27
  83. package/dist/lib/session/presence.d.ts +0 -47
  84. package/dist/lib/session/presence.js +0 -100
  85. package/dist/lib/watchdog/history.d.ts +0 -20
  86. package/dist/lib/watchdog/history.js +0 -43
  87. package/dist/lib/watchdog/log.d.ts +0 -33
  88. package/dist/lib/watchdog/log.js +0 -117
  89. package/dist/lib/watchdog/read.d.ts +0 -8
  90. package/dist/lib/watchdog/read.js +0 -93
  91. package/dist/lib/watchdog/rotate.d.ts +0 -55
  92. package/dist/lib/watchdog/rotate.js +0 -220
  93. package/dist/lib/watchdog/runner.d.ts +0 -100
  94. package/dist/lib/watchdog/runner.js +0 -727
  95. package/dist/lib/watchdog/service.d.ts +0 -15
  96. package/dist/lib/watchdog/service.js +0 -36
  97. package/dist/lib/watchdog/watchdog-agent.d.ts +0 -8
  98. package/dist/lib/watchdog/watchdog-agent.js +0 -32
  99. package/dist/lib/watchdog/watchdog.d.ts +0 -43
  100. package/dist/lib/watchdog/watchdog.js +0 -116
  101. package/dist/lib/watchdog/watchdogTail.d.ts +0 -6
  102. package/dist/lib/watchdog/watchdogTail.js +0 -116
@@ -1,100 +0,0 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { getRuntimeStateDir } from '../state.js';
5
- export const PRESENCE_TTL_MS = 30 * 60_000;
6
- export function presenceFilePath(dir) {
7
- return path.join(dir ?? path.join(getRuntimeStateDir(), 'watchdog'), 'presence.json');
8
- }
9
- export function loadPresence(dir) {
10
- let raw;
11
- try {
12
- raw = fs.readFileSync(presenceFilePath(dir), 'utf8');
13
- }
14
- catch {
15
- return {};
16
- }
17
- try {
18
- const parsed = JSON.parse(raw);
19
- if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
20
- return parsed;
21
- }
22
- }
23
- catch {
24
- }
25
- return {};
26
- }
27
- export function savePresence(map, dir) {
28
- try {
29
- const file = presenceFilePath(dir);
30
- fs.mkdirSync(path.dirname(file), { recursive: true });
31
- fs.writeFileSync(file, JSON.stringify(map), 'utf8');
32
- }
33
- catch {
34
- }
35
- }
36
- export function observedFromActive(sessions, selfHost = os.hostname()) {
37
- const out = [];
38
- for (const s of sessions) {
39
- if (!s.sessionId)
40
- continue;
41
- const location = s.machine ? 'ssh' : 'local';
42
- out.push({
43
- sessionId: s.sessionId,
44
- agent: s.kind,
45
- location,
46
- device: s.machine ?? selfHost,
47
- transport: s.provenance?.transport ?? location,
48
- interactive: s.context === 'terminal',
49
- });
50
- }
51
- return out;
52
- }
53
- export function actionFor(record) {
54
- if (record.status !== 'disconnected')
55
- return 'none';
56
- if (record.interactive)
57
- return 'reconnect-nudge';
58
- if (record.location === 'ssh')
59
- return 'keep-alive';
60
- return 'none';
61
- }
62
- export function reconcilePresence(prev, observed, nowMs) {
63
- const next = {};
64
- const transitions = [];
65
- const observedIds = new Set(observed.map((o) => o.sessionId));
66
- for (const o of observed) {
67
- const before = prev[o.sessionId];
68
- const record = {
69
- sessionId: o.sessionId,
70
- agent: o.agent,
71
- location: o.location,
72
- device: o.device,
73
- transport: o.transport,
74
- interactive: o.interactive,
75
- lastSeenMs: nowMs,
76
- status: 'connected',
77
- };
78
- next[o.sessionId] = record;
79
- if (before && before.status === 'disconnected') {
80
- transitions.push({ record, from: 'disconnected', to: 'connected', action: 'none' });
81
- }
82
- }
83
- for (const [id, before] of Object.entries(prev)) {
84
- if (observedIds.has(id))
85
- continue;
86
- if (nowMs - before.lastSeenMs > PRESENCE_TTL_MS)
87
- continue;
88
- const record = { ...before, status: 'disconnected' };
89
- next[id] = record;
90
- if (before.status === 'connected') {
91
- transitions.push({
92
- record,
93
- from: 'connected',
94
- to: 'disconnected',
95
- action: actionFor(record),
96
- });
97
- }
98
- }
99
- return { next, transitions };
100
- }
@@ -1,20 +0,0 @@
1
- import type { WatchdogEvent, WatchdogEventKind } from './log.js';
2
- interface WatchdogHistoryEntry {
3
- ts: number;
4
- kind: WatchdogEventKind | 'inspection';
5
- sessionId?: string;
6
- agent?: string;
7
- message: string;
8
- reason?: string;
9
- stalledForMs?: number;
10
- nudgeText?: string;
11
- }
12
- interface WatchdogHistoryOptions {
13
- limit?: number;
14
- sinceMs?: number;
15
- sessionId?: string;
16
- includeTicks?: boolean;
17
- nowMs?: number;
18
- }
19
- export declare function selectWatchdogHistory(events: WatchdogEvent[], options?: WatchdogHistoryOptions): WatchdogHistoryEntry[];
20
- export {};
@@ -1,43 +0,0 @@
1
- export function selectWatchdogHistory(events, options = {}) {
2
- const limit = options.limit ?? 50;
3
- const cutoff = options.sinceMs === undefined
4
- ? Number.NEGATIVE_INFINITY
5
- : (options.nowMs ?? Date.now()) - options.sinceMs;
6
- const session = options.sessionId?.toLowerCase();
7
- const expanded = events.flatMap((event) => {
8
- const inspections = event.inspections?.map((inspection) => ({
9
- ts: event.ts,
10
- kind: 'inspection',
11
- sessionId: inspection.terminalId,
12
- agent: inspection.agentType,
13
- message: inspection.message,
14
- reason: inspection.reason,
15
- stalledForMs: inspection.stalledForMs,
16
- })) ?? [];
17
- if (event.kind === 'tick' && !options.includeTicks)
18
- return inspections;
19
- return [...inspections, {
20
- ts: event.ts,
21
- kind: event.kind,
22
- sessionId: event.terminalId,
23
- agent: event.agentType,
24
- message: event.message,
25
- reason: event.reason,
26
- stalledForMs: event.stalledForMs,
27
- nudgeText: event.nudgeText,
28
- }];
29
- });
30
- const matching = expanded
31
- .filter((entry) => entry.ts >= cutoff)
32
- .filter((entry) => !session || entry.sessionId?.toLowerCase().startsWith(session))
33
- .sort((a, b) => b.ts - a.ts);
34
- if (matching.length <= limit)
35
- return matching;
36
- const newest = matching.slice(0, limit);
37
- if (newest.some((entry) => entry.kind !== 'inspection'))
38
- return newest;
39
- const newestAction = matching.find((entry) => entry.kind !== 'inspection');
40
- if (!newestAction)
41
- return newest;
42
- return [...newest.slice(0, limit - 1), newestAction].sort((a, b) => b.ts - a.ts);
43
- }
@@ -1,33 +0,0 @@
1
- export declare function watchdogLogPath(): string;
2
- export type WatchdogEventKind = 'tick' | 'decision' | 'nudge' | 'undelivered' | 'rotate' | 'error';
3
- export interface WatchdogEvent {
4
- ts: number;
5
- kind: WatchdogEventKind;
6
- terminalId?: string;
7
- agentType?: string;
8
- message: string;
9
- reason?: string;
10
- tailLines?: string[];
11
- stalledForMs?: number;
12
- lastUserMessage?: string;
13
- lastAssistantMessage?: string;
14
- nudgeText?: string;
15
- inspections?: WatchdogInspection[];
16
- }
17
- export interface WatchdogInspection {
18
- terminalId?: string;
19
- agentType: string;
20
- message: string;
21
- reason: string;
22
- stalledForMs?: number;
23
- }
24
- export declare function parseWatchdogEvents(text: string): WatchdogEvent[];
25
- export declare function readWatchdogEvents(logPath?: string): WatchdogEvent[];
26
- export declare function formatEvent(ev: WatchdogEvent): string;
27
- export declare const WATCHDOG_TAIL_MAX_CHARS = 4096;
28
- export declare function boundTailLines(lines: string[], maxChars?: number): string[];
29
- export declare function trimToLast(text: string, maxLines: number): string;
30
- export declare function appendWatchdogEvents(events: WatchdogEvent[], opts?: {
31
- logPath?: string;
32
- maxLines?: number;
33
- }): void;
@@ -1,117 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { withFileLock, atomicWriteFileSync, ensureLockTarget } from '../fs-atomic.js';
4
- import { getLogsDir } from '../state.js';
5
- export function watchdogLogPath() {
6
- return path.join(getLogsDir(), 'watchdog.log');
7
- }
8
- const WATCHDOG_EVENT_KINDS = new Set(['tick', 'decision', 'nudge', 'undelivered', 'rotate', 'error']);
9
- export function parseWatchdogEvents(text) {
10
- const events = [];
11
- for (const line of text.split('\n')) {
12
- if (!line.trim())
13
- continue;
14
- try {
15
- const value = JSON.parse(line);
16
- if (typeof value.ts !== 'number' ||
17
- !Number.isFinite(value.ts) ||
18
- typeof value.kind !== 'string' ||
19
- !WATCHDOG_EVENT_KINDS.has(value.kind) ||
20
- typeof value.message !== 'string')
21
- continue;
22
- const inspections = Array.isArray(value.inspections)
23
- ? value.inspections.flatMap((item) => {
24
- if (item === null || typeof item !== 'object')
25
- return [];
26
- const row = item;
27
- if (typeof row.agentType !== 'string' || typeof row.message !== 'string' || typeof row.reason !== 'string')
28
- return [];
29
- return [{
30
- terminalId: typeof row.terminalId === 'string' ? row.terminalId : undefined,
31
- agentType: row.agentType,
32
- message: row.message,
33
- reason: row.reason,
34
- stalledForMs: typeof row.stalledForMs === 'number' ? row.stalledForMs : undefined,
35
- }];
36
- })
37
- : undefined;
38
- events.push({
39
- ts: value.ts,
40
- kind: value.kind,
41
- message: value.message,
42
- terminalId: typeof value.terminalId === 'string' ? value.terminalId : undefined,
43
- agentType: typeof value.agentType === 'string' ? value.agentType : undefined,
44
- reason: typeof value.reason === 'string' ? value.reason : undefined,
45
- tailLines: Array.isArray(value.tailLines)
46
- ? value.tailLines.filter((item) => typeof item === 'string')
47
- : undefined,
48
- stalledForMs: typeof value.stalledForMs === 'number' ? value.stalledForMs : undefined,
49
- lastUserMessage: typeof value.lastUserMessage === 'string' ? value.lastUserMessage : undefined,
50
- lastAssistantMessage: typeof value.lastAssistantMessage === 'string' ? value.lastAssistantMessage : undefined,
51
- nudgeText: typeof value.nudgeText === 'string' ? value.nudgeText : undefined,
52
- inspections,
53
- });
54
- }
55
- catch {
56
- }
57
- }
58
- return events;
59
- }
60
- export function readWatchdogEvents(logPath = watchdogLogPath()) {
61
- if (!fs.existsSync(logPath))
62
- return [];
63
- return parseWatchdogEvents(fs.readFileSync(logPath, 'utf8'));
64
- }
65
- export function formatEvent(ev) {
66
- return JSON.stringify(ev);
67
- }
68
- const WATCHDOG_LOG_MAX_LINES = 5000;
69
- export const WATCHDOG_TAIL_MAX_CHARS = 4096;
70
- export function boundTailLines(lines, maxChars = WATCHDOG_TAIL_MAX_CHARS) {
71
- const kept = [];
72
- let remaining = maxChars;
73
- for (let i = lines.length - 1; i >= 0 && remaining > 0; i--) {
74
- const line = lines[i];
75
- if (line.length <= remaining) {
76
- kept.unshift(line);
77
- remaining -= line.length;
78
- }
79
- else {
80
- kept.unshift(line.slice(-remaining));
81
- remaining = 0;
82
- }
83
- }
84
- return kept;
85
- }
86
- export function trimToLast(text, maxLines) {
87
- const lines = text.split('\n').filter((l) => l.trim().length > 0);
88
- if (lines.length <= maxLines)
89
- return lines.join('\n') + (lines.length ? '\n' : '');
90
- return lines.slice(lines.length - maxLines).join('\n') + '\n';
91
- }
92
- export function appendWatchdogEvents(events, opts = {}) {
93
- if (events.length === 0)
94
- return;
95
- const logPath = opts.logPath ?? watchdogLogPath();
96
- const maxLines = opts.maxLines ?? WATCHDOG_LOG_MAX_LINES;
97
- const lockPath = path.join(path.dirname(logPath), '.watchdog.log.lock');
98
- try {
99
- ensureLockTarget(lockPath);
100
- withFileLock(lockPath, () => {
101
- let existing = '';
102
- try {
103
- existing = fs.readFileSync(logPath, 'utf8');
104
- }
105
- catch {
106
- }
107
- const boundedEvents = events.map((event) => event.tailLines === undefined
108
- ? event
109
- : { ...event, tailLines: boundTailLines(event.tailLines) });
110
- const appended = boundedEvents.map(formatEvent).join('\n') + '\n';
111
- const body = trimToLast(existing + appended, maxLines);
112
- atomicWriteFileSync(logPath, body);
113
- });
114
- }
115
- catch {
116
- }
117
- }
@@ -1,8 +0,0 @@
1
- export declare const WATCHDOG_TAIL_LINES = 20;
2
- export declare const WATCHDOG_STALL_MS = 300000;
3
- export declare const WATCHDOG_COOLDOWN_MS = 1200000;
4
- export declare const WATCHDOG_DORMANT_MS = 3600000;
5
- export declare function readTailLines(filePath: string, maxLines: number): string[];
6
- export declare function findSessionJsonlIn(dirs: string[], sessionId: string, ext?: string): string | undefined;
7
- export declare function resolveWatchdogSessionPath(sessionId: string, agent: string): string | undefined;
8
- export declare function readWatchdogTail(sessionId: string, agent: string, maxLines?: number): string[];
@@ -1,93 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { getAgentSessionDirs } from '../session/discover.js';
4
- import { walkForFiles } from '../fs-walk.js';
5
- export const WATCHDOG_TAIL_LINES = 20;
6
- export const WATCHDOG_STALL_MS = 300_000;
7
- export const WATCHDOG_COOLDOWN_MS = 1_200_000;
8
- export const WATCHDOG_DORMANT_MS = 3_600_000;
9
- const CHUNK_SIZE = 64 * 1024;
10
- const UUID_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
11
- const WATCHDOG_WALK_CAP = 100_000;
12
- const WATCHDOG_SESSION_LAYOUT = {
13
- claude: { subdir: 'projects', ext: '.jsonl' },
14
- codex: { subdir: 'sessions', ext: '.jsonl' },
15
- droid: { subdir: 'sessions', ext: '.jsonl' },
16
- };
17
- const WATCHDOG_SESSION_LAYOUT_DEFAULT = { subdir: 'projects', ext: '.jsonl' };
18
- export function readTailLines(filePath, maxLines) {
19
- let fd;
20
- try {
21
- fd = fs.openSync(filePath, 'r');
22
- }
23
- catch {
24
- return [];
25
- }
26
- try {
27
- const fileSize = fs.fstatSync(fd).size;
28
- if (fileSize === 0)
29
- return [];
30
- let position = fileSize;
31
- let buffer = '';
32
- let collected = [];
33
- while (position > 0 && collected.length <= maxLines) {
34
- const readSize = Math.min(CHUNK_SIZE, position);
35
- position -= readSize;
36
- const chunk = Buffer.alloc(readSize);
37
- fs.readSync(fd, chunk, 0, readSize, position);
38
- buffer = chunk.toString('utf-8') + buffer;
39
- collected = buffer.split(/\r?\n/).filter((l) => l.trim());
40
- }
41
- return collected.slice(-maxLines);
42
- }
43
- catch {
44
- return [];
45
- }
46
- finally {
47
- try {
48
- fs.closeSync(fd);
49
- }
50
- catch {
51
- }
52
- }
53
- }
54
- export function findSessionJsonlIn(dirs, sessionId, ext = '.jsonl') {
55
- if (!sessionId)
56
- return undefined;
57
- const matches = (name) => {
58
- if (!name.endsWith(ext))
59
- return false;
60
- const stem = name.slice(0, -ext.length);
61
- if (stem === sessionId)
62
- return true;
63
- return name.includes(sessionId) || (UUID_RE.test(sessionId) && stem.includes(sessionId));
64
- };
65
- let best;
66
- for (const dir of dirs) {
67
- for (const file of walkForFiles(dir, ext, WATCHDOG_WALK_CAP)) {
68
- if (!matches(path.basename(file)))
69
- continue;
70
- let mtime;
71
- try {
72
- mtime = fs.statSync(file).mtimeMs;
73
- }
74
- catch {
75
- continue;
76
- }
77
- if (!best || mtime > best.mtime)
78
- best = { file, mtime };
79
- }
80
- }
81
- return best?.file;
82
- }
83
- export function resolveWatchdogSessionPath(sessionId, agent) {
84
- const layout = WATCHDOG_SESSION_LAYOUT[agent] ?? WATCHDOG_SESSION_LAYOUT_DEFAULT;
85
- const dirs = getAgentSessionDirs(agent, layout.subdir);
86
- return findSessionJsonlIn(dirs, sessionId, layout.ext);
87
- }
88
- export function readWatchdogTail(sessionId, agent, maxLines = WATCHDOG_TAIL_LINES) {
89
- const filePath = resolveWatchdogSessionPath(sessionId, agent);
90
- if (!filePath)
91
- return [];
92
- return readTailLines(filePath, maxLines);
93
- }
@@ -1,55 +0,0 @@
1
- import type { InjectTarget } from '../terminal/index.js';
2
- import type { ActiveSession } from '../session/active.js';
3
- type RotateTailVerdict = {
4
- kind: 'none';
5
- } | {
6
- kind: 'rate_limited';
7
- resetsAtMs?: number;
8
- };
9
- export declare function classifyTailForRotate(tailLines: string[], nowMs: number): RotateTailVerdict;
10
- export declare function parseRotateResetMs(text: string, nowMs: number): number | undefined;
11
- export declare const ROTATE_EXIT_SEQUENCES: Record<string, string[]>;
12
- export declare const DEFAULT_ROTATE_EXIT_SEQUENCE: string[];
13
- export declare function exitSequenceFor(agent: string): string[];
14
- export declare function buildRotateLaunchCommand(opts: {
15
- host?: string;
16
- sessionId: string;
17
- }): string;
18
- export declare function buildRotateReplayText(oldSessionId: string): string;
19
- export type RotatePhase = 'exiting' | 'launching' | 'awaiting-tui' | 'replaying' | 'done' | 'failed';
20
- export interface RotateState {
21
- sessionId: string;
22
- newSessionId: string;
23
- agent: string;
24
- phase: RotatePhase;
25
- target: InjectTarget;
26
- host?: string;
27
- cwd?: string;
28
- machineHost?: string;
29
- startedAtMs: number;
30
- updatedAtMs: number;
31
- deadlineMs: number;
32
- error?: string;
33
- suppressUntilMs?: number;
34
- }
35
- export declare const DEFAULT_ROTATE_READINESS_MS = 60000;
36
- export declare const DEFAULT_ROTATE_SKIP_COOLDOWN_MS: number;
37
- export declare const DEFAULT_ROTATE_FAILED_COOLDOWN_MS: number;
38
- export declare function readRotateState(dir: string, sessionId: string): RotateState | null;
39
- export declare function writeRotateState(dir: string, state: RotateState): void;
40
- export declare function isInflightPhase(phase: RotatePhase): boolean;
41
- export declare function listRotateStates(dir: string): RotateState[];
42
- export declare function listInflightRotates(dir: string): RotateState[];
43
- export declare function shouldLogRotateSkip(dir: string, sessionId: string, nowMs: number): boolean;
44
- export declare function recordRotateSkip(dir: string, sessionId: string, suppressUntilMs: number): void;
45
- export declare function isWatchdogRotateEnabled(): boolean;
46
- export declare function setWatchdogRotateEnabled(on: boolean): void;
47
- export interface RotateGateResult {
48
- healthy: boolean;
49
- resetsAtMs?: number;
50
- detail: string;
51
- }
52
- export declare function defaultRotateGate(): Promise<RotateGateResult>;
53
- export declare function isCorrelatedRelaunch(state: RotateState, s: ActiveSession): boolean;
54
- export declare function defaultTuiLiveFor(state: RotateState, sessions: ActiveSession[]): boolean;
55
- export {};