@phnx-labs/agents-cli 1.22.121 → 1.22.123

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 (247) hide show
  1. package/CHANGELOG.md +316 -0
  2. package/README.md +53 -53
  3. package/dist/bootstrap.js +22 -17
  4. package/dist/cli/command-registry.d.ts +0 -1
  5. package/dist/cli/command-registry.js +2 -12
  6. package/dist/commands/auth.js +13 -4
  7. package/dist/commands/browser.js +3 -4
  8. package/dist/commands/cloud-transcripts.d.ts +7 -0
  9. package/dist/commands/cloud-transcripts.js +100 -0
  10. package/dist/commands/cloud.js +5 -0
  11. package/dist/commands/computer.d.ts +0 -12
  12. package/dist/commands/computer.js +14 -124
  13. package/dist/commands/config.js +5 -4
  14. package/dist/commands/daemon-index.d.ts +2 -0
  15. package/dist/commands/daemon-index.js +44 -0
  16. package/dist/commands/daemon.js +13 -8
  17. package/dist/commands/doctor.js +3 -4
  18. package/dist/commands/exec.d.ts +5 -0
  19. package/dist/commands/exec.js +35 -7
  20. package/dist/commands/feed-watch.js +12 -0
  21. package/dist/commands/feed.d.ts +1 -1
  22. package/dist/commands/feed.js +7 -4
  23. package/dist/commands/insights.js +3 -1
  24. package/dist/commands/inspect.js +1 -1
  25. package/dist/commands/logs.js +2 -1
  26. package/dist/commands/mailboxes.js +1 -1
  27. package/dist/commands/models.js +1 -1
  28. package/dist/commands/projects.js +3 -3
  29. package/dist/commands/prune.js +6 -28
  30. package/dist/commands/ps-roster.d.ts +0 -1
  31. package/dist/commands/ps-roster.js +2 -21
  32. package/dist/commands/ps.js +13 -1
  33. package/dist/commands/recordings.d.ts +2 -0
  34. package/dist/commands/recordings.js +117 -0
  35. package/dist/commands/routines.js +1 -1
  36. package/dist/commands/secrets-passthrough.js +3 -3
  37. package/dist/commands/send.js +33 -20
  38. package/dist/commands/sessions-backfill.d.ts +1 -0
  39. package/dist/commands/sessions-backfill.js +48 -13
  40. package/dist/commands/sessions-migrate.d.ts +1 -1
  41. package/dist/commands/sessions-migrate.js +11 -10
  42. package/dist/commands/sessions-optimize.d.ts +1 -0
  43. package/dist/commands/sessions-optimize.js +7 -4
  44. package/dist/commands/sessions-resume.js +8 -1
  45. package/dist/commands/sessions-stats.d.ts +2 -0
  46. package/dist/commands/sessions-stats.js +24 -7
  47. package/dist/commands/sessions.d.ts +5 -11
  48. package/dist/commands/sessions.js +8 -236
  49. package/dist/commands/setup-computer.js +1 -2
  50. package/dist/commands/setup-mine.js +0 -1
  51. package/dist/commands/setup.js +1 -1
  52. package/dist/commands/sync.js +101 -1
  53. package/dist/commands/teams.js +2 -2
  54. package/dist/commands/testdata/feed-hub.js +11 -0
  55. package/dist/commands/trash.d.ts +0 -1
  56. package/dist/commands/trash.js +74 -10
  57. package/dist/lib/accounting/usage-sync.js +7 -0
  58. package/dist/lib/agent-modes.d.ts +1 -1
  59. package/dist/lib/agent-modes.js +11 -5
  60. package/dist/lib/auth-mint.d.ts +4 -0
  61. package/dist/lib/auth-mint.js +6 -4
  62. package/dist/lib/browser/native-history.test-fixture.d.ts +12 -0
  63. package/dist/lib/browser/native-history.test-fixture.js +43 -0
  64. package/dist/lib/browser/paths.d.ts +5 -0
  65. package/dist/lib/browser/paths.js +7 -1
  66. package/dist/lib/browser/sessions-list.d.ts +28 -1
  67. package/dist/lib/browser/sessions-list.js +137 -25
  68. package/dist/lib/channels/providers/rush.d.ts +2 -1
  69. package/dist/lib/channels/providers/rush.js +2 -2
  70. package/dist/lib/channels/providers/session.d.ts +1 -0
  71. package/dist/lib/channels/providers/session.js +23 -12
  72. package/dist/lib/channels/registry.d.ts +9 -2
  73. package/dist/lib/channels/send.d.ts +5 -10
  74. package/dist/lib/channels/send.js +88 -50
  75. package/dist/lib/cloud/rush.d.ts +6 -0
  76. package/dist/lib/cloud/rush.js +18 -3
  77. package/dist/lib/computer-client.d.ts +19 -0
  78. package/dist/lib/computer-client.js +104 -0
  79. package/dist/lib/config-keys.d.ts +5 -1
  80. package/dist/lib/config-keys.js +14 -11
  81. package/dist/lib/daemon/auth-sync-service.js +13 -0
  82. package/dist/lib/daemon/daemon.js +20 -23
  83. package/dist/lib/daemon/owner-device-delivery-service.d.ts +10 -0
  84. package/dist/lib/daemon/owner-device-delivery-service.js +28 -0
  85. package/dist/lib/daemon-services.d.ts +2 -1
  86. package/dist/lib/daemon-services.js +17 -10
  87. package/dist/lib/daemon-webhooks.d.ts +1 -1
  88. package/dist/lib/daemon-webhooks.js +1 -1
  89. package/dist/lib/device-config.d.ts +4 -1
  90. package/dist/lib/device-config.js +58 -8
  91. package/dist/lib/devices/doctor-findings.d.ts +2 -3
  92. package/dist/lib/devices/doctor-findings.js +10 -19
  93. package/dist/lib/event-provenance.d.ts +1 -0
  94. package/dist/lib/event-provenance.js +2 -0
  95. package/dist/lib/exec.d.ts +1 -0
  96. package/dist/lib/exec.js +20 -15
  97. package/dist/lib/feed/pr-status.d.ts +5 -1
  98. package/dist/lib/feed/pr-status.js +44 -3
  99. package/dist/lib/feed/tool-activity.js +9 -6
  100. package/dist/lib/feed/tools.d.ts +4 -1
  101. package/dist/lib/feed/tools.js +8 -11
  102. package/dist/lib/feed-broadcast.d.ts +5 -3
  103. package/dist/lib/feed-broadcast.js +47 -36
  104. package/dist/lib/fleet-shared-state.d.ts +5 -0
  105. package/dist/lib/fleet-shared-state.js +8 -0
  106. package/dist/lib/github/project-prs.d.ts +4 -1
  107. package/dist/lib/github/project-prs.js +20 -7
  108. package/dist/lib/help.d.ts +1 -0
  109. package/dist/lib/help.js +8 -0
  110. package/dist/lib/helper-versions.js +1 -1
  111. package/dist/lib/hosts/passthrough.js +5 -9
  112. package/dist/lib/hosts/remote-cmd.d.ts +2 -7
  113. package/dist/lib/hosts/remote-cmd.js +14 -22
  114. package/dist/lib/hosts/routing-flag.d.ts +22 -0
  115. package/dist/lib/hosts/routing-flag.js +127 -14
  116. package/dist/lib/identity/index.d.ts +22 -0
  117. package/dist/lib/identity/index.js +3 -0
  118. package/dist/lib/installations/migrate.d.ts +7 -0
  119. package/dist/lib/installations/migrate.js +99 -88
  120. package/dist/lib/installations/versions.js +2 -2
  121. package/dist/lib/launch-identity.d.ts +6 -1
  122. package/dist/lib/launch-identity.js +12 -2
  123. package/dist/lib/menubar/install-menubar.d.ts +1 -0
  124. package/dist/lib/menubar/install-menubar.js +8 -5
  125. package/dist/lib/menubar/snapshot.js +2 -3
  126. package/dist/lib/notify.d.ts +7 -14
  127. package/dist/lib/notify.js +29 -75
  128. package/dist/lib/owner-message.d.ts +4 -6
  129. package/dist/lib/owner-message.js +12 -11
  130. package/dist/lib/owner-notify-tokens.d.ts +49 -0
  131. package/dist/lib/owner-notify-tokens.js +214 -0
  132. package/dist/lib/owner-notify.d.ts +75 -0
  133. package/dist/lib/owner-notify.js +144 -0
  134. package/dist/lib/plugins/plugins.d.ts +7 -1
  135. package/dist/lib/plugins/plugins.js +26 -5
  136. package/dist/lib/pr-land-detach.js +2 -2
  137. package/dist/lib/recordings/config.d.ts +11 -0
  138. package/dist/lib/recordings/config.js +54 -0
  139. package/dist/lib/recordings/identity.d.ts +12 -0
  140. package/dist/lib/recordings/identity.js +57 -0
  141. package/dist/lib/recordings/ledger.d.ts +16 -0
  142. package/dist/lib/recordings/ledger.js +141 -0
  143. package/dist/lib/recordings/model.d.ts +29 -0
  144. package/dist/lib/recordings/model.js +28 -0
  145. package/dist/lib/recordings/pipeline.d.ts +44 -0
  146. package/dist/lib/recordings/pipeline.js +272 -0
  147. package/dist/lib/recordings/process.d.ts +17 -0
  148. package/dist/lib/recordings/process.js +94 -0
  149. package/dist/lib/recordings/service.d.ts +15 -0
  150. package/dist/lib/recordings/service.js +45 -0
  151. package/dist/lib/recordings/settle.d.ts +21 -0
  152. package/dist/lib/recordings/settle.js +92 -0
  153. package/dist/lib/recordings/transcode.d.ts +13 -0
  154. package/dist/lib/recordings/transcode.js +44 -0
  155. package/dist/lib/refresh.js +4 -1
  156. package/dist/lib/reminders.d.ts +0 -1
  157. package/dist/lib/reminders.js +1 -1
  158. package/dist/lib/reserved-stores.d.ts +3 -0
  159. package/dist/lib/reserved-stores.js +13 -0
  160. package/dist/lib/routine-notify-owner.d.ts +3 -23
  161. package/dist/lib/routine-notify-owner.js +26 -107
  162. package/dist/lib/rush-api.d.ts +1 -0
  163. package/dist/lib/rush-api.js +1 -0
  164. package/dist/lib/scheduling/routines.d.ts +1 -1
  165. package/dist/lib/scheduling/routines.js +1 -1
  166. package/dist/lib/session/active.d.ts +18 -2
  167. package/dist/lib/session/active.js +47 -37
  168. package/dist/lib/session/cloud.js +18 -45
  169. package/dist/lib/session/db.d.ts +3 -1
  170. package/dist/lib/session/db.js +64 -32
  171. package/dist/lib/session/glance-files.d.ts +4 -3
  172. package/dist/lib/session/glance-files.js +31 -0
  173. package/dist/lib/session/inject-target.js +12 -2
  174. package/dist/lib/session/pid-registry.d.ts +2 -0
  175. package/dist/lib/session/pid-registry.js +6 -2
  176. package/dist/lib/session/presentation.d.ts +21 -0
  177. package/dist/lib/session/presentation.js +198 -0
  178. package/dist/lib/session/projection.js +9 -2
  179. package/dist/lib/sqlite.d.ts +3 -1
  180. package/dist/lib/sqlite.js +7 -3
  181. package/dist/lib/staleness/index.js +12 -0
  182. package/dist/lib/staleness/types.d.ts +5 -0
  183. package/dist/lib/standalone-tools.js +1 -1
  184. package/dist/lib/startup/command-registry.js +10 -5
  185. package/dist/lib/state.d.ts +2 -5
  186. package/dist/lib/state.js +3 -11
  187. package/dist/lib/sync-delete.d.ts +21 -0
  188. package/dist/lib/sync-delete.js +113 -0
  189. package/dist/lib/terminal/inject.js +1 -1
  190. package/dist/lib/testdata/owner-notify-api.d.ts +36 -0
  191. package/dist/lib/testdata/owner-notify-api.js +102 -0
  192. package/dist/lib/trash.d.ts +14 -0
  193. package/dist/lib/trash.js +75 -0
  194. package/dist/lib/types.d.ts +0 -34
  195. package/package.json +1 -3
  196. package/dist/commands/feedback.d.ts +0 -2
  197. package/dist/commands/feedback.js +0 -68
  198. package/dist/commands/humans.d.ts +0 -2
  199. package/dist/commands/humans.js +0 -83
  200. package/dist/commands/modes.d.ts +0 -2
  201. package/dist/commands/modes.js +0 -134
  202. package/dist/commands/monitors.d.ts +0 -2
  203. package/dist/commands/monitors.js +0 -1070
  204. package/dist/commands/reminders.d.ts +0 -2
  205. package/dist/commands/reminders.js +0 -49
  206. package/dist/lib/channels/owner-forward.d.ts +0 -25
  207. package/dist/lib/channels/owner-forward.js +0 -78
  208. package/dist/lib/channels/owner-sink.d.ts +0 -10
  209. package/dist/lib/channels/owner-sink.js +0 -26
  210. package/dist/lib/daemon/monitor-engine-service.d.ts +0 -13
  211. package/dist/lib/daemon/monitor-engine-service.js +0 -25
  212. package/dist/lib/humans.d.ts +0 -12
  213. package/dist/lib/humans.js +0 -64
  214. package/dist/lib/monitors/config.d.ts +0 -77
  215. package/dist/lib/monitors/config.js +0 -405
  216. package/dist/lib/monitors/dispatch.d.ts +0 -10
  217. package/dist/lib/monitors/dispatch.js +0 -72
  218. package/dist/lib/monitors/engine.d.ts +0 -45
  219. package/dist/lib/monitors/engine.js +0 -243
  220. package/dist/lib/monitors/fingerprint.d.ts +0 -3
  221. package/dist/lib/monitors/fingerprint.js +0 -43
  222. package/dist/lib/monitors/pid-watch.d.ts +0 -4
  223. package/dist/lib/monitors/pid-watch.js +0 -14
  224. package/dist/lib/monitors/remote.d.ts +0 -31
  225. package/dist/lib/monitors/remote.js +0 -63
  226. package/dist/lib/monitors/sources/command.d.ts +0 -4
  227. package/dist/lib/monitors/sources/command.js +0 -20
  228. package/dist/lib/monitors/sources/device.d.ts +0 -3
  229. package/dist/lib/monitors/sources/device.js +0 -31
  230. package/dist/lib/monitors/sources/failure.d.ts +0 -5
  231. package/dist/lib/monitors/sources/failure.js +0 -25
  232. package/dist/lib/monitors/sources/file.d.ts +0 -4
  233. package/dist/lib/monitors/sources/file.js +0 -46
  234. package/dist/lib/monitors/sources/http.d.ts +0 -3
  235. package/dist/lib/monitors/sources/http.js +0 -25
  236. package/dist/lib/monitors/sources/index.d.ts +0 -5
  237. package/dist/lib/monitors/sources/index.js +0 -22
  238. package/dist/lib/monitors/sources/poll.d.ts +0 -1
  239. package/dist/lib/monitors/sources/poll.js +0 -1
  240. package/dist/lib/monitors/sources/types.d.ts +0 -9
  241. package/dist/lib/monitors/sources/webhook.d.ts +0 -3
  242. package/dist/lib/monitors/sources/webhook.js +0 -3
  243. package/dist/lib/monitors/sources/ws.d.ts +0 -4
  244. package/dist/lib/monitors/sources/ws.js +0 -35
  245. package/dist/lib/monitors/state.d.ts +0 -51
  246. package/dist/lib/monitors/state.js +0 -221
  247. /package/dist/{lib/monitors/sources/types.js → commands/testdata/feed-hub.d.ts} +0 -0
@@ -1,2 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function registerRemindersCommand(program: Command): void;
@@ -1,49 +0,0 @@
1
- import chalk from 'chalk';
2
- import { loadReminders, remindersFilePath } from '../lib/reminders.js';
3
- import { setHelpSections } from '../lib/help.js';
4
- const EXAMPLES = [
5
- 'agents reminders # list your operating reminders',
6
- 'agents reminders --json # machine-readable output',
7
- ].join('\n');
8
- const NOTES = [
9
- "Reminders live in ~/.agents/reminders/reminders.yaml and sync across the fleet via 'agents repo push'.",
10
- 'One shows succinctly in the Claude statusline per session, chosen deterministically from the session id,',
11
- 'so concurrent agents each show a different one and it stays stable within a session.',
12
- ].join('\n');
13
- export function registerRemindersCommand(program) {
14
- const cmd = program
15
- .command('reminders')
16
- .description('Personal operating reminders shown in the Claude statusline')
17
- .option('--json', 'output as JSON')
18
- .action((opts) => {
19
- const file = remindersFilePath();
20
- let reminders;
21
- try {
22
- reminders = loadReminders();
23
- }
24
- catch (err) {
25
- console.error(chalk.red(`Could not read reminders: ${err instanceof Error ? err.message : String(err)}`));
26
- process.exitCode = 1;
27
- return;
28
- }
29
- if (opts.json) {
30
- process.stdout.write(`${JSON.stringify({ file, reminders }, null, 2)}\n`);
31
- return;
32
- }
33
- if (reminders.length === 0) {
34
- console.log(`No reminders yet. Add them to ${chalk.cyan(file)}`);
35
- console.log(chalk.dim('Each shows succinctly in the Claude statusline — one per session.'));
36
- return;
37
- }
38
- const count = `${reminders.length} reminder${reminders.length === 1 ? '' : 's'}`;
39
- console.log(chalk.dim(`${count} · ${file}`));
40
- console.log(chalk.dim('One shows in the Claude statusline per session, chosen from the session id.\n'));
41
- for (const reminder of reminders) {
42
- console.log(` ${chalk.cyan('◆')} ${chalk.bold(reminder.short)}`);
43
- if (reminder.full && reminder.full !== reminder.short) {
44
- console.log(` ${chalk.dim(reminder.full)}`);
45
- }
46
- }
47
- });
48
- setHelpSections(cmd, { examples: EXAMPLES, notes: NOTES });
49
- }
@@ -1,25 +0,0 @@
1
- import type { Meta } from '../types.js';
2
- import type { SendResult } from './registry.js';
3
- import type { DeviceProfile } from '../devices/registry.js';
4
- export declare const OWNER_FORWARD_GUARD_ENV = "AGENTS_OWNER_NO_FORWARD";
5
- type OwnerForwardSkip = 'guarded' | 'not-rush-backed' | 'no-capable-peer';
6
- interface OwnerForwardPlan {
7
- candidates: string[];
8
- skip?: OwnerForwardSkip;
9
- }
10
- export declare function isRushBackedTransport(channel: string, meta: Meta): boolean;
11
- export declare function planOwnerForward(channel: string, meta: Meta, devices: DeviceProfile[], self: string, opts?: {
12
- guarded?: boolean;
13
- }): OwnerForwardPlan;
14
- interface PeerOwnerEnvelope {
15
- thread?: string;
16
- from?: string;
17
- }
18
- type PeerOwnerSender = (machine: string, text: string, channel: string, target: string, envelope?: PeerOwnerEnvelope) => Promise<SendResult | undefined>;
19
- export declare function forwardOwnerNotifyToPeer(text: string, channel: string, target: string, meta: Meta, opts?: {
20
- self?: string;
21
- devices?: DeviceProfile[];
22
- send?: PeerOwnerSender;
23
- envelope?: PeerOwnerEnvelope;
24
- }): Promise<SendResult | undefined>;
25
- export {};
@@ -1,78 +0,0 @@
1
- import { loadDevices, isDialableDevice } from '../devices/registry.js';
2
- import { machineId, normalizeHost } from '../machine-id.js';
3
- import { RUSH_CHANNELS } from './providers/rush.js';
4
- import { resolvePeerTarget, sshCapture } from '../session/remote/remote-list.js';
5
- import { buildRemoteAgentsInvocation, stripClixml } from '../hosts/remote-cmd.js';
6
- export const OWNER_FORWARD_GUARD_ENV = 'AGENTS_OWNER_NO_FORWARD';
7
- const PEER_SEND_TIMEOUT_MS = 15_000;
8
- export function isRushBackedTransport(channel, meta) {
9
- const transport = meta.notify?.transports?.[channel] ?? channel;
10
- return RUSH_CHANNELS.includes(transport);
11
- }
12
- export function planOwnerForward(channel, meta, devices, self, opts = {}) {
13
- if (opts.guarded)
14
- return { candidates: [], skip: 'guarded' };
15
- if (!isRushBackedTransport(channel, meta))
16
- return { candidates: [], skip: 'not-rush-backed' };
17
- const selfId = normalizeHost(self);
18
- const capable = devices.filter((d) => d.platform === 'macos' && isDialableDevice(d) && normalizeHost(d.name) !== selfId);
19
- const interactiveHost = typeof meta.config?.interactiveHost === 'string'
20
- ? normalizeHost(meta.config.interactiveHost)
21
- : undefined;
22
- const rank = (name) => (interactiveHost && normalizeHost(name) === interactiveHost ? 0 : 1);
23
- const candidates = capable
24
- .map((d) => normalizeHost(d.name))
25
- .sort((a, b) => rank(a) - rank(b));
26
- if (candidates.length === 0)
27
- return { candidates: [], skip: 'no-capable-peer' };
28
- return { candidates };
29
- }
30
- async function sendOnPeer(machine, text, channel, target, envelope = {}) {
31
- const peer = await resolvePeerTarget(machine);
32
- if (!peer)
33
- return undefined;
34
- const args = ['send', '--channel', channel, '--to', target, '--text', text, '--json'];
35
- if (envelope.thread)
36
- args.push('--thread', envelope.thread);
37
- if (envelope.from)
38
- args.push('--from', envelope.from);
39
- const remoteCmd = buildRemoteAgentsInvocation(args, undefined, peer.os, { [OWNER_FORWARD_GUARD_ENV]: '1' });
40
- const capture = await sshCapture(peer.target, remoteCmd, PEER_SEND_TIMEOUT_MS);
41
- if (capture.code !== 0)
42
- return undefined;
43
- try {
44
- const parsed = JSON.parse(stripClixml(capture.stdout));
45
- if (parsed && typeof parsed === 'object' && typeof parsed.ok === 'boolean')
46
- return parsed;
47
- }
48
- catch {
49
- return undefined;
50
- }
51
- return undefined;
52
- }
53
- export async function forwardOwnerNotifyToPeer(text, channel, target, meta, opts = {}) {
54
- if (process.env[OWNER_FORWARD_GUARD_ENV] === '1')
55
- return undefined;
56
- if (!isRushBackedTransport(channel, meta))
57
- return undefined;
58
- const self = opts.self ?? machineId();
59
- let devices = opts.devices;
60
- if (!devices) {
61
- try {
62
- devices = Object.values(await loadDevices());
63
- }
64
- catch {
65
- return undefined;
66
- }
67
- }
68
- const plan = planOwnerForward(channel, meta, devices, self);
69
- if (plan.candidates.length === 0)
70
- return undefined;
71
- const send = opts.send ?? sendOnPeer;
72
- for (const machine of plan.candidates) {
73
- const result = await send(machine, text, channel, target, opts.envelope);
74
- if (result?.ok)
75
- return result;
76
- }
77
- return undefined;
78
- }
@@ -1,10 +0,0 @@
1
- import type { Meta } from '../types.js';
2
- export type OwnerSinkReason = 'imessage-not-macos' | 'slack-no-token' | 'channel-unsupported';
3
- export interface OwnerSinkStatus {
4
- configured: boolean;
5
- reachable: boolean;
6
- channel?: string;
7
- transport?: string;
8
- reason?: OwnerSinkReason;
9
- }
10
- export declare function probeOwnerSink(meta: Meta): Promise<OwnerSinkStatus>;
@@ -1,26 +0,0 @@
1
- import { platform } from 'os';
2
- import { readOwnerDest } from './send.js';
3
- import { RUSH_CHANNELS, resolveSlackToken } from './providers/rush.js';
4
- export async function probeOwnerSink(meta) {
5
- const dest = readOwnerDest(meta);
6
- if (!dest)
7
- return { configured: false, reachable: false };
8
- const channel = dest.channel;
9
- const transport = meta.notify?.transports?.[channel] ?? channel;
10
- if (!RUSH_CHANNELS.includes(transport)) {
11
- return { configured: true, reachable: true, channel, transport };
12
- }
13
- if (transport === 'imessage') {
14
- if (platform() !== 'darwin') {
15
- return { configured: true, reachable: false, channel, transport, reason: 'imessage-not-macos' };
16
- }
17
- return { configured: true, reachable: true, channel, transport };
18
- }
19
- if (transport === 'slack') {
20
- if (resolveSlackToken()) {
21
- return { configured: true, reachable: true, channel, transport };
22
- }
23
- return { configured: true, reachable: false, channel, transport, reason: 'slack-no-token' };
24
- }
25
- return { configured: true, reachable: false, channel, transport, reason: 'channel-unsupported' };
26
- }
@@ -1,13 +0,0 @@
1
- import { BasePeriodicService, type DaemonContext } from './service.js';
2
- import type { DaemonServiceId } from '../daemon-services.js';
3
- import { MonitorEngine } from '../monitors/engine.js';
4
- export declare class MonitorEngineService extends BasePeriodicService {
5
- readonly id: DaemonServiceId;
6
- readonly intervalMs = 5000;
7
- readonly deadlineMs: number;
8
- private engine;
9
- getEngine(): MonitorEngine | null;
10
- protected onStart(ctx: DaemonContext): Promise<void>;
11
- protected onStop(): Promise<void>;
12
- protected onTick(_ctx: DaemonContext): Promise<void>;
13
- }
@@ -1,25 +0,0 @@
1
- import { BasePeriodicService } from './service.js';
2
- import { MONITOR_ENGINE_TICK_MS, MonitorEngine } from '../monitors/engine.js';
3
- import { POLL_TIMEOUT_MS } from '../monitors/sources/command.js';
4
- export class MonitorEngineService extends BasePeriodicService {
5
- id = 'monitors';
6
- intervalMs = MONITOR_ENGINE_TICK_MS;
7
- deadlineMs = 3 * POLL_TIMEOUT_MS;
8
- engine = null;
9
- getEngine() {
10
- return this.engine;
11
- }
12
- async onStart(ctx) {
13
- this.engine = new MonitorEngine((level, message) => ctx.log(level, message));
14
- this.engine.start({ externalScheduler: true });
15
- }
16
- async onStop() {
17
- this.engine?.stop();
18
- this.engine = null;
19
- }
20
- async onTick(_ctx) {
21
- if (!this.engine)
22
- throw new Error('monitor engine tick requested before start');
23
- await this.engine.tick(POLL_TIMEOUT_MS);
24
- }
25
- }
@@ -1,12 +0,0 @@
1
- import type { HumansConfig, HumanOwner } from './types.js';
2
- export declare function readHumans(): HumansConfig | null;
3
- export declare function writeHumans(config: HumansConfig): void;
4
- export declare function getOwnerNotifyFromHumans(): {
5
- channel: string;
6
- to: string;
7
- } | null;
8
- export declare function getOwnerNotifyDestinationsFromHumans(): Array<{
9
- channel: string;
10
- to: string;
11
- }>;
12
- export declare function getOwnerFromHumans(): HumanOwner | null;
@@ -1,64 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as yaml from 'yaml';
3
- import { getHumansFilePath } from './state.js';
4
- const HUMANS_VERSION = 1;
5
- const HUMANS_HEADER = `# humans.yaml — owner identity and notification channels
6
- # Managed by agents-cli. See: agents humans --help
7
- `;
8
- export function readHumans() {
9
- const filePath = getHumansFilePath();
10
- if (!fs.existsSync(filePath))
11
- return null;
12
- try {
13
- const raw = fs.readFileSync(filePath, 'utf-8');
14
- const parsed = yaml.parse(raw);
15
- if (!parsed || typeof parsed !== 'object')
16
- return null;
17
- const doc = parsed;
18
- if (doc['version'] !== HUMANS_VERSION)
19
- return null;
20
- return doc;
21
- }
22
- catch {
23
- return null;
24
- }
25
- }
26
- export function writeHumans(config) {
27
- const filePath = getHumansFilePath();
28
- const body = yaml.stringify(config, { lineWidth: 120 });
29
- fs.writeFileSync(filePath, HUMANS_HEADER + body, { encoding: 'utf-8', mode: 0o600 });
30
- }
31
- export function getOwnerNotifyFromHumans() {
32
- return getOwnerNotifyDestinationsFromHumans()[0] ?? null;
33
- }
34
- export function getOwnerNotifyDestinationsFromHumans() {
35
- const owner = readHumans()?.owner;
36
- const channels = owner?.channels ?? [];
37
- const preferredIds = owner?.policy?.normal ?? [];
38
- const selected = preferredIds.length > 0
39
- ? preferredIds.map((id) => channels.find((entry) => entry.id === id))
40
- : [channels.find((entry) => entry.to)];
41
- const seen = new Set();
42
- const destinations = selected
43
- .filter((entry) => Boolean(entry?.id && entry.to))
44
- .map((entry) => ({ channel: entry.id, to: entry.to }))
45
- .filter((entry) => {
46
- const key = `${entry.channel}\0${entry.to}`;
47
- if (seen.has(key))
48
- return false;
49
- seen.add(key);
50
- return true;
51
- });
52
- if (destinations.length > 0)
53
- return destinations;
54
- const firstAddressable = channels.find((entry) => entry.id && entry.to);
55
- if (firstAddressable?.to)
56
- return [{ channel: firstAddressable.id, to: firstAddressable.to }];
57
- const migrated = owner?.notify;
58
- if (migrated?.channel && migrated.to)
59
- return [migrated];
60
- return [];
61
- }
62
- export function getOwnerFromHumans() {
63
- return readHumans()?.owner ?? null;
64
- }
@@ -1,77 +0,0 @@
1
- import type { AgentId } from '../types.js';
2
- export type MonitorSourceType = 'command' | 'poll' | 'poll-http' | 'webhook' | 'ws' | 'file' | 'device';
3
- export interface MonitorWebhookSource {
4
- source: 'github' | 'linear';
5
- event: string;
6
- repo?: string;
7
- branch?: string;
8
- action?: string;
9
- teamKey?: string;
10
- label?: string;
11
- }
12
- export interface MonitorSource {
13
- type: MonitorSourceType;
14
- command?: string;
15
- interval?: string;
16
- url?: string;
17
- wsUrl?: string;
18
- path?: string;
19
- device?: string;
20
- webhook?: MonitorWebhookSource;
21
- }
22
- export type MonitorConditionMode = 'on-change' | 'match' | 'every';
23
- export interface MonitorCondition {
24
- mode: MonitorConditionMode;
25
- match?: string;
26
- dedupeKey?: string;
27
- }
28
- export type MonitorActionType = 'run' | 'routine' | 'notify' | 'webhook-out';
29
- export interface ActionConfig {
30
- type: MonitorActionType;
31
- agent?: AgentId | (string & {});
32
- prompt?: string;
33
- mode?: 'plan' | 'edit' | 'auto' | 'skip' | 'full';
34
- effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto';
35
- timeout?: string;
36
- routine?: string;
37
- notifyChannel?: string;
38
- url?: string;
39
- postcondition?: string;
40
- }
41
- export interface MonitorConfig {
42
- name: string;
43
- enabled: boolean;
44
- source: MonitorSource;
45
- condition: MonitorCondition;
46
- action: ActionConfig;
47
- device?: string;
48
- devices?: string[];
49
- sharedInput?: boolean;
50
- runOn?: string;
51
- cwd?: string;
52
- rateLimit?: {
53
- max: number;
54
- per: string;
55
- };
56
- variables?: Record<string, string>;
57
- version?: string;
58
- scope?: 'user' | 'system';
59
- }
60
- export interface MonitorEvent {
61
- monitorName: string;
62
- firedAt: string;
63
- summary: string;
64
- payload: Record<string, unknown>;
65
- }
66
- export declare function parseInterval(interval: string): number | null;
67
- export declare function requiresSingleOwner(config: Pick<MonitorConfig, 'device' | 'devices' | 'scope' | 'sharedInput'>): boolean;
68
- export declare function resolveSharedInputOwner(interactiveHost: string | undefined, deviceNames: string[], self: string): string | undefined;
69
- export declare function monitorSharedInputOwner(): string | undefined;
70
- export declare function monitorRunsOnThisDevice(config: Pick<MonitorConfig, 'device' | 'devices' | 'scope' | 'sharedInput'>, ownerHost?: string): boolean;
71
- export declare function validateMonitor(config: Partial<MonitorConfig>): string[];
72
- export declare function listMonitors(): MonitorConfig[];
73
- export declare function readMonitor(name: string): MonitorConfig | null;
74
- export declare function getMonitorPath(name: string): string | null;
75
- export declare function writeMonitor(config: MonitorConfig): void;
76
- export declare function deleteMonitor(name: string): boolean;
77
- export declare function setMonitorEnabled(name: string, enabled: boolean): void;