@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,10 +1,15 @@
1
+ import type { InjectOptions, InjectResult } from '../terminal/index.js';
2
+ export type TerminalSendOptions = Pick<InjectOptions, 'enter' | 'combined'> & {
3
+ pane?: string;
4
+ socket?: string;
5
+ };
1
6
  export interface SendOptions {
2
7
  target: string;
3
8
  thread?: string;
4
9
  attachments?: string[];
5
10
  from?: string;
6
- ownerScoped?: boolean;
7
11
  dryRun?: boolean;
12
+ terminal?: TerminalSendOptions;
8
13
  }
9
14
  export interface SendResult {
10
15
  ok: boolean;
@@ -14,7 +19,9 @@ export interface SendResult {
14
19
  attachments?: string[];
15
20
  msgId?: string;
16
21
  body?: string;
17
- deliveries?: SendResult[];
22
+ backend?: InjectResult['backend'];
23
+ writes?: number;
24
+ confirmed?: boolean;
18
25
  }
19
26
  export interface ChannelProvider {
20
27
  name: string;
@@ -1,6 +1,5 @@
1
1
  import type { Meta } from '../types.js';
2
- import type { SendResult } from './registry.js';
3
- import type { SinkMessageFormat } from '../sink-format.js';
2
+ import type { SendResult, TerminalSendOptions } from './registry.js';
4
3
  interface SendEnvelope {
5
4
  text: string;
6
5
  channel: string;
@@ -8,8 +7,8 @@ interface SendEnvelope {
8
7
  thread?: string;
9
8
  attachments?: string[];
10
9
  from?: string;
11
- ownerScoped?: boolean;
12
10
  dryRun?: boolean;
11
+ terminal?: TerminalSendOptions;
13
12
  }
14
13
  export interface ResolveSendInput {
15
14
  text?: string;
@@ -21,7 +20,7 @@ export interface ResolveSendInput {
21
20
  urls?: string[];
22
21
  from?: string;
23
22
  dryRun?: boolean;
24
- ownerMode?: boolean;
23
+ terminal?: TerminalSendOptions;
25
24
  }
26
25
  type ResolveSendResult = {
27
26
  ok: true;
@@ -31,14 +30,10 @@ type ResolveSendResult = {
31
30
  error: string;
32
31
  };
33
32
  export declare function isOwnerAlias(to: string | undefined): boolean;
34
- export declare function composeSendText(text: string, urls?: string[]): string;
35
- export declare function readOwnerDest(meta: Meta): {
36
- channel: string;
37
- to: string;
38
- } | null;
33
+ export declare function composeSendText(text: string, urls?: string[], verbatim?: boolean): string;
39
34
  export declare function resolveSendEnvelope(input: ResolveSendInput, meta: Meta): ResolveSendResult;
40
35
  export declare function deliverEnvelope(envelope: SendEnvelope, meta: Meta): Promise<SendResult>;
41
- export declare function sendMessage(input: ResolveSendInput, meta: Meta, ownerCompose?: (format: SinkMessageFormat) => string): Promise<{
36
+ export declare function sendMessage(input: ResolveSendInput, meta: Meta): Promise<{
42
37
  result: SendResult;
43
38
  envelope: SendEnvelope;
44
39
  } | {
@@ -1,13 +1,13 @@
1
- import { getOwnerNotifyFromHumans } from '../humans.js';
2
1
  import { registerBuiltinProviders } from './providers/index.js';
3
- import { resolveTransport } from './resolve.js';
2
+ import { lookupTransport, resolveTransport } from './resolve.js';
3
+ import { SESSION_CHANNEL } from './providers/session.js';
4
4
  import { sendToOwner } from '../notify.js';
5
5
  const OWNER_ALIAS = 'owner';
6
6
  export function isOwnerAlias(to) {
7
7
  return (to ?? '').trim().toLowerCase() === OWNER_ALIAS;
8
8
  }
9
- export function composeSendText(text, urls) {
10
- const body = text.trim();
9
+ export function composeSendText(text, urls, verbatim = false) {
10
+ const body = verbatim ? text : text.trim();
11
11
  const extra = (urls ?? [])
12
12
  .map((u) => u.trim())
13
13
  .filter(Boolean)
@@ -16,49 +16,71 @@ export function composeSendText(text, urls) {
16
16
  return body;
17
17
  return body ? `${body}\n${extra.join('\n')}` : extra.join('\n');
18
18
  }
19
- export function readOwnerDest(meta) {
20
- const canonical = getOwnerNotifyFromHumans();
21
- if (canonical)
22
- return canonical;
23
- const channel = meta.notify?.owner?.channel?.trim();
24
- const to = meta.notify?.owner?.to?.trim();
25
- return channel && to ? { channel, to } : null;
26
- }
27
- export function resolveSendEnvelope(input, meta) {
28
- const positional = (input.positionalText ?? '').trim();
29
- const flagged = (input.text ?? '').trim();
30
- if (positional && flagged && positional !== flagged) {
19
+ function resolveText(input, verbatim) {
20
+ const norm = (t) => (t === undefined || verbatim ? t : t.trim());
21
+ const positional = norm(input.positionalText);
22
+ const flagged = norm(input.text);
23
+ const conflict = verbatim
24
+ ? positional !== undefined && flagged !== undefined && positional !== flagged
25
+ : Boolean(positional && flagged && positional !== flagged);
26
+ if (conflict) {
31
27
  return {
32
28
  ok: false,
33
29
  error: 'Pass the message once: use --text, or a positional argument, not both with different values.',
34
30
  };
35
31
  }
36
- const rawText = flagged || positional;
37
32
  const urls = (input.urls ?? []).map((u) => u.trim()).filter(Boolean);
38
- const text = composeSendText(rawText, urls);
39
- if (!text) {
33
+ const supplied = verbatim ? (flagged ?? positional) : (flagged || positional);
34
+ const text = composeSendText(supplied ?? '', urls, verbatim);
35
+ if (!text && (supplied === undefined || !verbatim)) {
40
36
  return {
41
37
  ok: false,
42
38
  error: 'Message is empty. Pass --text "…", a positional message, and/or --url.',
43
39
  };
44
40
  }
45
- let channel = (input.channel ?? '').trim();
41
+ return { ok: true, text };
42
+ }
43
+ function terminalOptionsError(terminal, to) {
44
+ if (!terminal)
45
+ return null;
46
+ if (terminal.socket && !terminal.pane) {
47
+ return '--socket addresses an explicit --pane; a session found by --to already carries its own socket.';
48
+ }
49
+ if (terminal.combined && terminal.enter === false) {
50
+ return '--combined fuses the text with Enter; it cannot be used with --no-enter.';
51
+ }
52
+ if (terminal.pane && to && to !== terminal.pane) {
53
+ return `--pane ${terminal.pane} and --to ${to} name different targets; pass one of them.`;
54
+ }
55
+ return null;
56
+ }
57
+ export function resolveSendEnvelope(input, meta) {
58
+ const channel = (input.channel ?? '').trim();
46
59
  let to = (input.to ?? '').trim();
47
- const usedOwnerAlias = isOwnerAlias(to);
48
- if (input.ownerMode || usedOwnerAlias) {
49
- const owner = getOwnerNotifyFromHumans() ?? meta.notify?.owner;
50
- const ownerChannel = owner?.channel ?? '';
51
- const ownerTo = owner?.to ?? '';
52
- if (!channel)
53
- channel = ownerChannel;
54
- if (!to || usedOwnerAlias)
55
- to = ownerTo;
60
+ if (isOwnerAlias(to)) {
61
+ return { ok: false, error: '--to owner sends to your account, whose notification preferences pick the channels, so it cannot be combined with --channel (a feed sink uses `channel: owner` instead). Drop --channel, or name an explicit recipient.' };
56
62
  }
63
+ const isSession = Boolean(channel)
64
+ && lookupTransport(channel, meta).providerName === SESSION_CHANNEL;
65
+ if (input.terminal && !isSession) {
66
+ return {
67
+ ok: false,
68
+ error: '--pane, --socket, --no-enter and --combined only apply to --channel session.',
69
+ };
70
+ }
71
+ const terminalError = isSession ? terminalOptionsError(input.terminal, to) : null;
72
+ if (terminalError)
73
+ return { ok: false, error: terminalError };
74
+ if (isSession && input.terminal?.pane)
75
+ to = input.terminal.pane;
76
+ const resolvedText = resolveText(input, isSession);
77
+ if (!resolvedText.ok)
78
+ return resolvedText;
79
+ const { text } = resolvedText;
57
80
  if (!channel || !to) {
58
- const hint = input.ownerMode || usedOwnerAlias
59
- ? 'Set owner.channels and owner.policy.normal in humans.yaml, or pass --channel and --to explicitly.'
60
- : 'Need --channel and --to (or --to owner with notify.owner configured). ' +
61
- 'Example: agents send --channel desktop --to local --text "hi"';
81
+ const hint = isSession
82
+ ? 'Need --to <session> (find ids with: agents ps) or --pane <tmux pane id>.'
83
+ : 'Need --channel and --to, or --to owner. Example: agents send --channel desktop --to local --text "hi"';
62
84
  return { ok: false, error: hint };
63
85
  }
64
86
  const attachments = [
@@ -75,8 +97,8 @@ export function resolveSendEnvelope(input, meta) {
75
97
  thread: input.thread?.trim() || undefined,
76
98
  attachments: attachments.length ? attachments : undefined,
77
99
  from: input.from?.trim() || undefined,
78
- ownerScoped: usedOwnerAlias || (input.ownerMode === true && !input.to?.trim()),
79
100
  dryRun: input.dryRun,
101
+ terminal: isSession ? input.terminal : undefined,
80
102
  },
81
103
  };
82
104
  }
@@ -88,26 +110,42 @@ export async function deliverEnvelope(envelope, meta) {
88
110
  thread: envelope.thread,
89
111
  attachments: envelope.attachments,
90
112
  from: envelope.from,
91
- ownerScoped: envelope.ownerScoped,
92
113
  dryRun: envelope.dryRun,
114
+ terminal: envelope.terminal,
93
115
  });
94
116
  }
95
- export async function sendMessage(input, meta, ownerCompose) {
117
+ function ownerSendError(input) {
118
+ if (input.channel?.trim())
119
+ return '--to owner sends to your account, whose notification preferences pick the channels, so it cannot be combined with --channel (a feed sink uses `channel: owner` instead). Drop --channel, or name an explicit recipient.';
120
+ if (input.terminal)
121
+ return '--pane, --socket, --no-enter and --combined only apply to --channel session.';
122
+ if (input.thread?.trim())
123
+ return '--thread does not apply to --to owner; the account decides where the message lands.';
124
+ if (input.attachments?.length)
125
+ return '--attach does not apply to --to owner; owner notifications carry text and a link. Pass --url instead.';
126
+ return null;
127
+ }
128
+ export async function sendMessage(input, meta) {
129
+ if (isOwnerAlias(input.to)) {
130
+ const refused = ownerSendError(input);
131
+ if (refused)
132
+ return { error: refused };
133
+ const resolvedText = resolveText(input, false);
134
+ if (!resolvedText.ok)
135
+ return resolvedText;
136
+ const { ownerMessageNotification } = await import('../owner-message.js');
137
+ const notification = ownerMessageNotification(resolvedText.text, {
138
+ ...(input.from?.trim() ? { agent: input.from.trim() } : {}),
139
+ ...(input.urls?.[0]?.trim() ? { url: input.urls[0].trim() } : {}),
140
+ });
141
+ const result = await sendToOwner(notification, { dryRun: input.dryRun });
142
+ return {
143
+ result,
144
+ envelope: { text: notification.body, channel: 'owner', to: 'owner', dryRun: input.dryRun },
145
+ };
146
+ }
96
147
  const resolved = resolveSendEnvelope(input, meta);
97
148
  if (!resolved.ok)
98
149
  return { error: resolved.error };
99
- const ownerPolicyRequest = resolved.envelope.ownerScoped === true
100
- && !input.channel?.trim()
101
- && (!input.to?.trim() || isOwnerAlias(input.to));
102
- const result = ownerPolicyRequest
103
- ? await sendToOwner(resolved.envelope.text, {
104
- meta,
105
- dryRun: resolved.envelope.dryRun,
106
- thread: resolved.envelope.thread,
107
- attachments: resolved.envelope.attachments,
108
- from: resolved.envelope.from,
109
- ...(ownerCompose ? { composeForFormat: ownerCompose } : {}),
110
- })
111
- : await deliverEnvelope(resolved.envelope, meta);
112
- return { result, envelope: resolved.envelope };
150
+ return { result: await deliverEnvelope(resolved.envelope, meta), envelope: resolved.envelope };
113
151
  }
@@ -1,6 +1,12 @@
1
1
  import type { CloudProvider, CloudTask, CloudTaskStatus, CloudEvent, DispatchOptions, ProviderCapabilities, ImageAttachment, SkillRef } from './types.js';
2
2
  export declare function isRushSessionValid(yamlPath?: string): boolean;
3
3
  export declare function readToken(yamlPath?: string): string;
4
+ export interface RushOrg {
5
+ slug?: string;
6
+ kind?: string;
7
+ }
8
+ export declare function rushOrgHandle(token: string, yamlPath?: string): Promise<string>;
9
+ export declare function personalOrgHandle(orgs: RushOrg[]): string | undefined;
4
10
  interface AccountManifestEntry {
5
11
  version: string;
6
12
  email: string;
@@ -9,7 +9,7 @@ import { parseSSE } from './stream.js';
9
9
  import { listInstalledVersions, getVersionHomePath } from '../installations/versions.js';
10
10
  import { getAccountInfo } from '../agents.js';
11
11
  import { selectBalancedVersion } from '../accounting/rotate.js';
12
- const PROXY_BASE = process.env.RUSH_PROXY_BASE ?? 'https://api.prix.dev';
12
+ import { RUSH_API_BASE } from '../rush-api.js';
13
13
  const USER_YAML = path.join(os.homedir(), '.rush', 'user.yaml');
14
14
  export function isRushSessionValid(yamlPath = USER_YAML) {
15
15
  try {
@@ -44,6 +44,21 @@ export function readToken(yamlPath = USER_YAML) {
44
44
  }
45
45
  return token;
46
46
  }
47
+ export async function rushOrgHandle(token, yamlPath = USER_YAML) {
48
+ const saved = yaml.parse(fs.readFileSync(yamlPath, 'utf-8'))?.org?.trim();
49
+ if (saved)
50
+ return saved;
51
+ const res = await api('GET', '/me', token);
52
+ if (!res.ok)
53
+ throw new Error(`Could not read your Rush organizations (${res.status}). Run \`rush login\` again.`);
54
+ const handle = personalOrgHandle((await res.json()).orgs ?? []);
55
+ if (!handle)
56
+ throw new Error('No Rush organization found for your account. Run `rush login` again.');
57
+ return handle;
58
+ }
59
+ export function personalOrgHandle(orgs) {
60
+ return (orgs.find((o) => o.kind === 'personal' && o.slug) ?? orgs.find((o) => o.slug))?.slug;
61
+ }
47
62
  function readEmail() {
48
63
  try {
49
64
  const raw = fs.readFileSync(USER_YAML, 'utf-8');
@@ -55,7 +70,7 @@ function readEmail() {
55
70
  }
56
71
  }
57
72
  async function api(method, endpoint, token, body) {
58
- const url = endpoint.startsWith('http') ? endpoint : `${PROXY_BASE}${endpoint}`;
73
+ const url = endpoint.startsWith('http') ? endpoint : `${RUSH_API_BASE}${endpoint}`;
59
74
  const headers = {
60
75
  'Authorization': `Bearer ${token}`,
61
76
  'Content-Type': 'application/json',
@@ -318,7 +333,7 @@ export class RushCloudProvider {
318
333
  }
319
334
  async *stream(taskId) {
320
335
  const token = readToken();
321
- const res = await fetch(`${PROXY_BASE}/api/v1/cloud-runs/${encodeURIComponent(taskId)}/stream`, {
336
+ const res = await fetch(`${RUSH_API_BASE}/api/v1/cloud-runs/${encodeURIComponent(taskId)}/stream`, {
322
337
  headers: { 'Authorization': `Bearer ${token}` },
323
338
  });
324
339
  if (!res.ok) {
@@ -1,3 +1,4 @@
1
+ import { type ComputerTargetContext } from './computer/context.js';
1
2
  export declare const COMPUTER_CONTEXT_FD = 3;
2
3
  export declare const COMPUTER_EVENTS_FD = 4;
3
4
  export declare class ComputerClientError extends Error {
@@ -40,5 +41,23 @@ interface RunComputerResult {
40
41
  stdout: string;
41
42
  }
42
43
  export declare function runComputer(opts: RunComputerOptions): Promise<RunComputerResult>;
44
+ export declare function withHostFlag(argv: string[], host?: string): string[];
45
+ export declare function resolveDeviceHost(device: string): Promise<{
46
+ host: string;
47
+ target: ComputerTargetContext;
48
+ }>;
49
+ export interface ForwardToComputerOptions {
50
+ argv: string[];
51
+ device?: string;
52
+ record?: boolean;
53
+ capture?: boolean;
54
+ }
55
+ export declare function forwardToComputer(opts: ForwardToComputerOptions): Promise<RunComputerResult>;
56
+ export declare function installComputerHelperMacLocal(): Promise<void>;
57
+ export declare function activateComputerHelperMacLocal(): Promise<{
58
+ trusted: boolean;
59
+ }>;
60
+ export declare function parseTrustFromStatusJson(stdout: string): boolean;
61
+ export declare function probeComputerTrust(): Promise<boolean>;
43
62
  export declare function _resetComputerClientForTest(): void;
44
63
  export {};
@@ -6,6 +6,11 @@ import { spawn } from 'node:child_process';
6
6
  import { realpathSync, existsSync } from 'node:fs';
7
7
  import * as path from 'node:path';
8
8
  import { findInPath } from './agent-spec/agents.js';
9
+ import { buildComputerContext } from './computer/context.js';
10
+ import { recordComputerAction } from './computer/record.js';
11
+ import { resolveRemoteDevice } from './ssh-tunnel.js';
12
+ import { getConfigValue } from './device-config.js';
13
+ import { parseAddress, sshTarget } from './address.js';
9
14
  const INSTALL_HINT = 'npm i -g @phnx-labs/computer-cli';
10
15
  export const COMPUTER_CONTEXT_FD = 3;
11
16
  export const COMPUTER_EVENTS_FD = 4;
@@ -135,6 +140,105 @@ function osSignalNumber(signal) {
135
140
  };
136
141
  return table[signal];
137
142
  }
143
+ export function withHostFlag(argv, host) {
144
+ if (!host)
145
+ return argv;
146
+ if (argv.some((arg) => arg === '--host' || arg.startsWith('--host=')))
147
+ return argv;
148
+ const [verb, ...rest] = argv;
149
+ return [verb, '--host', host, ...rest];
150
+ }
151
+ export async function resolveDeviceHost(device) {
152
+ const configured = getConfigValue('computer.host', { device }).value;
153
+ if (configured) {
154
+ const addr = parseAddress(configured);
155
+ if (addr.scheme === 'vnc' || addr.scheme === 'tcp') {
156
+ return { host: configured, target: { alias: device, host: addr.host, user: addr.user ?? '', hostname: addr.host, platform: addr.scheme, sshArgs: [] } };
157
+ }
158
+ const resolved = await resolveRemoteDevice(device, {});
159
+ const target = sshTarget(addr);
160
+ return {
161
+ host: configured,
162
+ target: { alias: device, host: target, user: addr.user ?? resolved.user, hostname: addr.host, platform: resolved.device.platform, sshArgs: resolved.identityArgs },
163
+ };
164
+ }
165
+ const resolved = await resolveRemoteDevice(device, {
166
+ expectPlatform: 'windows',
167
+ forWhat: '`agents computer --device` drives the Windows computer-helper daemon, so it',
168
+ });
169
+ return {
170
+ host: `ssh://${resolved.target}`,
171
+ target: { alias: device, host: resolved.target, user: resolved.user, hostname: resolved.host, platform: resolved.device.platform, sshArgs: resolved.identityArgs },
172
+ };
173
+ }
174
+ export async function forwardToComputer(opts) {
175
+ let bin;
176
+ try {
177
+ bin = resolveComputerBin();
178
+ }
179
+ catch (err) {
180
+ if (isComputerClientError(err)) {
181
+ console.error(err.message);
182
+ return { exitCode: 1, stdout: '' };
183
+ }
184
+ throw err;
185
+ }
186
+ const hostFlag = opts.argv.findIndex(arg => arg === '--host' || arg.startsWith('--host='));
187
+ let host = hostFlag < 0 ? undefined : (opts.argv[hostFlag].includes('=') ? opts.argv[hostFlag].slice(7) : opts.argv[hostFlag + 1]);
188
+ let target;
189
+ if (!host && opts.device) {
190
+ const resolved = await resolveDeviceHost(opts.device);
191
+ host = resolved.host;
192
+ target = resolved.target;
193
+ }
194
+ const context = await buildComputerContext({ device: opts.device, host, target, computerBin: bin });
195
+ return runComputer({
196
+ argv: withHostFlag(opts.argv, host),
197
+ context,
198
+ capture: opts.capture,
199
+ onEvent: opts.record === false
200
+ ? undefined
201
+ : (event) => recordComputerAction(event, { device: opts.device }),
202
+ });
203
+ }
204
+ export async function installComputerHelperMacLocal() {
205
+ const { exitCode } = await forwardToComputer({ argv: ['setup'], record: false });
206
+ if (exitCode !== 0)
207
+ throw new Error(`\`computer setup\` failed (exit ${exitCode})`);
208
+ }
209
+ export async function activateComputerHelperMacLocal() {
210
+ const { exitCode } = await forwardToComputer({ argv: ['start'], record: false });
211
+ if (exitCode !== 0)
212
+ throw new Error(`\`computer start\` failed (exit ${exitCode})`);
213
+ return { trusted: await probeComputerTrust() };
214
+ }
215
+ export function parseTrustFromStatusJson(stdout) {
216
+ const start = stdout.indexOf('{');
217
+ if (start < 0)
218
+ return false;
219
+ try {
220
+ const parsed = JSON.parse(stdout.slice(start));
221
+ return parsed.trusted === true;
222
+ }
223
+ catch {
224
+ return false;
225
+ }
226
+ }
227
+ export async function probeComputerTrust() {
228
+ try {
229
+ const { exitCode, stdout } = await forwardToComputer({
230
+ argv: ['status', '--json'],
231
+ record: false,
232
+ capture: true,
233
+ });
234
+ if (exitCode !== 0)
235
+ return false;
236
+ return parseTrustFromStatusJson(stdout);
237
+ }
238
+ catch {
239
+ return false;
240
+ }
241
+ }
138
242
  export function _resetComputerClientForTest() {
139
243
  cachedBin = undefined;
140
244
  }
@@ -1,7 +1,10 @@
1
1
  import type { AgentId } from './types.js';
2
2
  import { type ModelTier } from './model-tiers.js';
3
3
  export type ConfigScope = 'run' | 'interactive' | 'auto' | 'browser' | 'project' | 'device' | 'summarizer' | 'updates' | 'menubar';
4
- export declare const MENUBAR_MENU_PROPERTIES: readonly ["defaultProject", "workingRowsShown", "showPreviews", "projectPriorityFilter", "hideCompletedMilestones", "bannerWhenNeedsYou", "includeOtherDeviceRequests", "groupBy", "thenBy", "projectScope", "projectSort", "ticketSort", "showPullRequests", "sessionUpdates", "deviceSort", "headlessAgent", "headlessFallbackAgent", "headlessPlacement", "pinnedProjects", "tabOrder", "hiddenTabs", "groupTicketsByMilestone", "prGroupOpen", "prGroupMerged"];
4
+ export declare const MENUBAR_MENU_PROPERTIES: readonly ["defaultProject", "workingRowsShown", "showPreviews", "projectPriorityFilter", "hideCompletedMilestones", "bannerWhenNeedsYou", "includeOtherDeviceRequests", "groupBy", "thenBy", "projectScope", "projectSort", "ticketSort", "showPullRequests", "sessionUpdates", "deviceSort", "headlessAgent", "headlessFallbackAgent", "headlessPlacement", "pinnedProjects", "tabOrder", "hiddenTabs", "groupTicketsByMilestone", "prGroupOpen", "prGroupMerged", "homeGoals"];
5
+ export declare const MENUBAR_STATUSBAR_PROPERTIES: readonly ["goalCountdown"];
6
+ export type MenubarSection = 'menu' | 'statusbar';
7
+ export declare const MENUBAR_CONFIG_KEYS: readonly string[];
5
8
  export interface ParsedRunConfigKey {
6
9
  scope: 'run';
7
10
  agent: AgentId;
@@ -42,6 +45,7 @@ export interface ParsedUpdatesConfigKey {
42
45
  }
43
46
  export interface ParsedMenubarConfigKey {
44
47
  scope: 'menubar';
48
+ section: MenubarSection;
45
49
  property: string;
46
50
  }
47
51
  export type ParsedConfigKey = ParsedRunConfigKey | ParsedInteractiveConfigKey | ParsedAutoConfigKey | ParsedBrowserConfigKey | ParsedProjectConfigKey | ParsedDeviceConfigKey | ParsedSummarizerConfigKey | ParsedUpdatesConfigKey | ParsedMenubarConfigKey;
@@ -26,6 +26,12 @@ export const MENUBAR_MENU_PROPERTIES = [
26
26
  'groupTicketsByMilestone',
27
27
  'prGroupOpen',
28
28
  'prGroupMerged',
29
+ 'homeGoals',
30
+ ];
31
+ export const MENUBAR_STATUSBAR_PROPERTIES = ['goalCountdown'];
32
+ export const MENUBAR_CONFIG_KEYS = [
33
+ ...MENUBAR_MENU_PROPERTIES.map((p) => `menubar.menu.${p}`),
34
+ ...MENUBAR_STATUSBAR_PROPERTIES.map((p) => `menubar.statusbar.${p}`),
29
35
  ];
30
36
  const DEVICE_CONFIG_PROPERTIES = [
31
37
  'browser.viewer',
@@ -93,13 +99,12 @@ export function parseConfigKey(key) {
93
99
  if (summarizerMatch) {
94
100
  return { scope: 'summarizer', property: summarizerMatch[1] };
95
101
  }
96
- const menubarMatch = raw.match(/^menubar\.menu\.(.+)$/);
102
+ const menubarMatch = raw.match(/^menubar\.(menu|statusbar)\.(.+)$/);
97
103
  if (menubarMatch) {
98
- const property = menubarMatch[1];
99
- if (!MENUBAR_MENU_PROPERTIES.includes(property)) {
100
- throw new Error(`Unknown AGI Menu preference '${key}'. Known keys: ${MENUBAR_MENU_PROPERTIES.map((p) => `menubar.menu.${p}`).join(', ')}.`);
104
+ if (!MENUBAR_CONFIG_KEYS.includes(raw)) {
105
+ throw new Error(`Unknown AGI Menu preference '${key}'. Known keys: ${MENUBAR_CONFIG_KEYS.join(', ')}.`);
101
106
  }
102
- return { scope: 'menubar', property };
107
+ return { scope: 'menubar', section: menubarMatch[1], property: menubarMatch[2] };
103
108
  }
104
109
  if (raw === 'updates.auto') {
105
110
  return { scope: 'updates', property: 'auto' };
@@ -142,7 +147,7 @@ export function parseConfigKey(key) {
142
147
  throw new Error(`Invalid updates config key '${key}'. Use updates.auto or updates.<agent>.auto.`);
143
148
  }
144
149
  if (raw.startsWith('menubar.')) {
145
- throw new Error(`Invalid AGI Menu config key '${key}'. Use ${MENUBAR_MENU_PROPERTIES.map((p) => `menubar.menu.${p}`).join(', ')}.`);
150
+ throw new Error(`Invalid AGI Menu config key '${key}'. Use ${MENUBAR_CONFIG_KEYS.join(', ')}.`);
146
151
  }
147
152
  if (raw.startsWith('devices.')) {
148
153
  throw new Error(`Invalid device config key '${key}'. Expected devices.<name>.<${DEVICE_CONFIG_PROPERTIES.join('|')}>.`);
@@ -173,7 +178,7 @@ export function formatConfigKey(parsed) {
173
178
  case 'updates':
174
179
  return parsed.agent ? `updates.${parsed.agent}.auto` : 'updates.auto';
175
180
  case 'menubar':
176
- return `menubar.menu.${parsed.property}`;
181
+ return `menubar.${parsed.section}.${parsed.property}`;
177
182
  }
178
183
  }
179
184
  export function listKnownConfigKeys() {
@@ -183,9 +188,7 @@ export function listKnownConfigKeys() {
183
188
  keys.push(`run.<agent@version>.tier.${tier}`);
184
189
  }
185
190
  keys.push('interactive.host', 'auto.pool', 'browser.profile', 'browser.viewer', 'browser.device', 'project.root', 'summarizer.enabled', 'summarizer.baseUrl', 'summarizer.model', 'updates.auto', 'updates.<agent>.auto');
186
- for (const prop of MENUBAR_MENU_PROPERTIES) {
187
- keys.push(`menubar.menu.${prop}`);
188
- }
191
+ keys.push(...MENUBAR_CONFIG_KEYS);
189
192
  for (const prop of DEVICE_CONFIG_PROPERTIES) {
190
193
  keys.push(`devices.<name>.${prop}`);
191
194
  }
@@ -256,6 +259,6 @@ export function configKeyStorageHint(parsed) {
256
259
  ? `config.updatesAgentAuto.${parsed.agent} (central agents.yaml; syncs fleet-wide)`
257
260
  : 'config.updatesAuto (central agents.yaml; syncs fleet-wide)';
258
261
  case 'menubar':
259
- return `config.menubarMenu${parsed.property.charAt(0).toUpperCase()}${parsed.property.slice(1)} (central agents.yaml; syncs fleet-wide)`;
262
+ return `config.menubar${parsed.section === 'menu' ? 'Menu' : 'Statusbar'}${parsed.property.charAt(0).toUpperCase()}${parsed.property.slice(1)} (central agents.yaml; syncs fleet-wide)`;
260
263
  }
261
264
  }
@@ -51,5 +51,18 @@ export class AuthSyncService extends BasePeriodicService {
51
51
  catch (err) {
52
52
  ctx.log('WARN', `auth-sync: reserved-store sync: ${err.message}`);
53
53
  }
54
+ try {
55
+ const { syncOwnerNotifyTokens } = await import('../owner-notify-tokens.js');
56
+ const notify = await syncOwnerNotifyTokens();
57
+ if (notify.minted.length > 0)
58
+ ctx.log('INFO', `auth-sync: minted owner-notify device token(s) for ${notify.minted.join(', ')}`);
59
+ if (notify.pushed.length > 0)
60
+ ctx.log('INFO', `auth-sync: pushed owner-notify device token(s) to ${notify.pushed.join(', ')}`);
61
+ for (const err of notify.errors)
62
+ ctx.log('WARN', `auth-sync: owner-notify ${err.device}: ${err.message}`);
63
+ }
64
+ catch (err) {
65
+ ctx.log('WARN', `auth-sync: owner-notify token sync: ${err.message}`);
66
+ }
54
67
  }
55
68
  }