@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
@@ -2,7 +2,10 @@ import { execFile } from 'node:child_process';
2
2
  import { promisify } from 'node:util';
3
3
  const execFileAsync = promisify(execFile);
4
4
  export const PR_STATUS_TTL_MS = 45_000;
5
- const PR_STATUS_FIELDS = 'number,title,state,isDraft,reviewDecision,mergeable,statusCheckRollup';
5
+ const PR_STATUS_FIELDS = 'number,title,headRefOid,state,isDraft,reviewDecision,mergeable,statusCheckRollup';
6
+ export const MAX_PR_CHECK_ITEMS = 30;
7
+ const FAILED_VERDICTS = ['FAILURE', 'ERROR', 'CANCELLED', 'TIMED_OUT', 'ACTION_REQUIRED', 'STARTUP_FAILURE'];
8
+ const PENDING_VERDICTS = ['PENDING', 'EXPECTED', 'STALE'];
6
9
  const cache = new Map();
7
10
  function needsHuman(value) {
8
11
  if (value.state !== 'OPEN' || value.isDraft)
@@ -47,18 +50,56 @@ export function checksVerdict(rollup) {
47
50
  for (const check of rollup) {
48
51
  const row = check;
49
52
  const verdict = (row.conclusion || row.state || '').toUpperCase();
50
- if (['FAILURE', 'ERROR', 'CANCELLED', 'TIMED_OUT', 'ACTION_REQUIRED', 'STARTUP_FAILURE'].includes(verdict))
53
+ if (FAILED_VERDICTS.includes(verdict))
51
54
  return 'failing';
52
- if (verdict === '' ? (row.status ?? '').toUpperCase() !== 'COMPLETED' : ['PENDING', 'EXPECTED', 'STALE'].includes(verdict))
55
+ if (verdict === '' ? (row.status ?? '').toUpperCase() !== 'COMPLETED' : PENDING_VERDICTS.includes(verdict))
53
56
  pending = true;
54
57
  }
55
58
  return pending ? 'pending' : 'passing';
56
59
  }
60
+ function checkItemState(row) {
61
+ const verdict = (row.conclusion || row.state || '').toUpperCase();
62
+ if (FAILED_VERDICTS.includes(verdict))
63
+ return 'failed';
64
+ if (verdict === 'SKIPPED' || verdict === 'NEUTRAL')
65
+ return 'skipped';
66
+ if (verdict === '' ? (row.status ?? '').toUpperCase() !== 'COMPLETED' : PENDING_VERDICTS.includes(verdict))
67
+ return 'running';
68
+ return 'passed';
69
+ }
70
+ export function checkItemsFrom(rollup) {
71
+ if (!rollup || rollup.length === 0)
72
+ return undefined;
73
+ const byName = new Map();
74
+ for (const check of rollup) {
75
+ const row = (check ?? {});
76
+ const name = row.name || row.context;
77
+ if (!name)
78
+ continue;
79
+ const atMs = Date.parse(row.completedAt || row.startedAt || '');
80
+ const at = Number.isFinite(atMs) && atMs > 0 ? atMs : -Infinity;
81
+ const previous = byName.get(name);
82
+ if (previous && previous.atMs > at)
83
+ continue;
84
+ const url = row.detailsUrl || row.targetUrl;
85
+ const item = { name, state: checkItemState(row), ...(url ? { url } : {}) };
86
+ byName.set(name, { item, atMs: at });
87
+ }
88
+ const all = [...byName.values()].map((entry) => entry.item);
89
+ const rank = (item) => item.state === 'failed' ? 0 : item.state === 'running' ? 1 : 2;
90
+ const kept = new Set([...all].sort((a, b) => rank(a) - rank(b)).slice(0, MAX_PR_CHECK_ITEMS));
91
+ const items = all.filter((item) => kept.has(item));
92
+ return items.length ? items : undefined;
93
+ }
57
94
  export function withPullRequestStatus(row, status) {
58
95
  if (!row.pr || !status)
59
96
  return row;
97
+ const checkItems = checkItemsFrom(status.statusCheckRollup);
60
98
  const pr = {
61
99
  ...row.pr,
100
+ ...(status.title ? { title: status.title } : {}),
101
+ ...(status.headRefOid ? { headSha: status.headRefOid } : {}),
102
+ ...(checkItems ? { checkItems } : {}),
62
103
  ...(status.state !== undefined ? { state: status.state } : {}),
63
104
  ...(status.isDraft !== undefined ? { isDraft: status.isDraft } : {}),
64
105
  ...(status.reviewDecision !== undefined ? { reviewDecision: status.reviewDecision } : {}),
@@ -1,8 +1,8 @@
1
1
  import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
- import { getBrowserRuntimeDir } from '../state.js';
3
+ import { getBrowserRuntimeDir, getHistoryDir } from '../state.js';
4
4
  import { getEventsDir } from './events.js';
5
- import { buildBrowserSessionRows } from '../browser/sessions-list.js';
5
+ import { readBrowserSessionRows } from '../browser/sessions-list.js';
6
6
  import { buildComputerSessionRows, standaloneComputerActionsDir } from '../computer/sessions-list.js';
7
7
  import { boundBrowserRow, projectBrowserToolRow, projectComputerToolRow, sortToolRows } from './tools.js';
8
8
  export const TOOL_SWEEP_MS = 5_000;
@@ -25,7 +25,7 @@ export function collectToolRows(scope, sources = {}) {
25
25
  for (const task of read(sources.liveTasks ?? (() => readLiveBrowserTasks()), []))
26
26
  liveTasks.set(task.task, task);
27
27
  const rows = [];
28
- const browserRows = read(sources.browserRows ?? (() => buildBrowserSessionRows()), []);
28
+ const browserRows = read(sources.browserRows ?? (() => readBrowserSessionRows()), []);
29
29
  const captured = new Set();
30
30
  for (const row of browserRows) {
31
31
  if (row.task)
@@ -73,7 +73,7 @@ export class ToolRowSet {
73
73
  }
74
74
  }
75
75
  export function toolWatchRoots() {
76
- return [getBrowserRuntimeDir(), getEventsDir(), standaloneComputerActionsDir()];
76
+ return [getBrowserRuntimeDir(), path.join(getHistoryDir(), 'browser'), getEventsDir(), standaloneComputerActionsDir()];
77
77
  }
78
78
  function readLiveTasksFor(profileDir) {
79
79
  const file = path.join(profileDir, 'tasks.json');
@@ -153,8 +153,11 @@ export function watchToolActivity(options) {
153
153
  if (stopped || watchers.get(root))
154
154
  return;
155
155
  try {
156
- fs.mkdirSync(root, { recursive: true });
157
- const watcher = fs.watch(root, { recursive: true }, () => { dirty = true; });
156
+ fs.mkdirSync(root, { recursive: true, mode: 0o700 });
157
+ const watcher = fs.watch(root, { recursive: true }, (_event, file) => {
158
+ if (!String(file ?? '').endsWith('-shm'))
159
+ dirty = true;
160
+ });
158
161
  watcher.on('error', () => {
159
162
  watcher.close();
160
163
  if (watchers.get(root) === watcher)
@@ -20,7 +20,7 @@ export interface ToolTab {
20
20
  borrowed?: boolean;
21
21
  }
22
22
  export interface ToolCommand {
23
- command: 'agents';
23
+ command: 'browser';
24
24
  args: string[];
25
25
  runOn: string;
26
26
  }
@@ -50,6 +50,9 @@ interface ToolRowBase {
50
50
  export interface BrowserToolRow extends ToolRowBase {
51
51
  kind: 'browser';
52
52
  profile: string;
53
+ machine?: string;
54
+ captureDir?: string;
55
+ capturesRemote?: string;
53
56
  url?: string;
54
57
  tabs?: ToolTab[];
55
58
  showCommand?: ToolCommand;
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * WHAT IS DELIBERATELY DIFFERENT BETWEEN THE TWO KINDS. A browser task is a
17
17
  * LIVE resource: it is bound in the task index while it exists, it can be
18
- * driven, and it can be closed (`agents browser done --task <name>`). A
18
+ * driven, and it can be closed (`browser done --task <name>`). A
19
19
  * computer run is a LEDGER ENTRY: the actions already happened, the CLI process
20
20
  * that performed them has exited, and there is nothing to stop. So
21
21
  * {@link ComputerToolRow} pins `live: false` and carries no close/stop command
@@ -72,12 +72,6 @@ function ownerOf(sessionId, linkedSession, scope) {
72
72
  function knownMachine(machine) {
73
73
  return machine && machine !== 'unknown' ? machine : undefined;
74
74
  }
75
- function countBy(items, key) {
76
- const counts = {};
77
- for (const item of items)
78
- counts[key(item)] = (counts[key(item)] ?? 0) + 1;
79
- return counts;
80
- }
81
75
  export function boundBrowserRow(task, binding) {
82
76
  return {
83
77
  kind: 'task', task, profile: binding.profile ?? '',
@@ -100,7 +94,7 @@ export function projectBrowserToolRow(scope, row, binding, live) {
100
94
  const tabs = live?.tabs;
101
95
  const showTab = tabs?.find((tab) => tab.current && !tab.borrowed)?.id
102
96
  ?? tabs?.find((tab) => !tab.borrowed)?.id;
103
- const startedAtMs = live?.startedAtMs ?? binding?.createdAt ?? oldest;
97
+ const startedAtMs = live?.startedAtMs ?? binding?.createdAt ?? row.startedAt ?? oldest;
104
98
  const updatedAtMs = Math.max(row.latestMtimeMs, live?.lastActionAtMs ?? 0) || startedAtMs;
105
99
  return {
106
100
  kind: 'browser',
@@ -117,12 +111,15 @@ export function projectBrowserToolRow(scope, row, binding, live) {
117
111
  startedAtMs,
118
112
  updatedAtMs,
119
113
  captures,
120
- captureCounts: countBy(row.artifacts, (artifact) => artifact.kind),
114
+ captureCounts: Object.fromEntries(Object.entries(row.counts).filter(([, n]) => n > 0)),
121
115
  profile: row.profile || live?.profile || '',
116
+ ...(row.machine ? { machine: row.machine } : {}),
117
+ ...(row.captureDir ? { captureDir: row.captureDir } : {}),
118
+ ...(row.capturesRemote ? { capturesRemote: row.capturesRemote } : {}),
122
119
  ...(url ? { url } : {}),
123
120
  ...(tabs ? { tabs } : {}),
124
- ...(isLive && showTab ? { showCommand: { command: 'agents', args: ['browser', 'tab', 'focus', showTab, '--task', row.task], runOn: host } } : {}),
125
- ...(isLive ? { closeCommand: { command: 'agents', args: ['browser', 'done', '--task', row.task], runOn: host } } : {}),
121
+ ...(isLive && showTab ? { showCommand: { command: 'browser', args: ['tab', 'focus', showTab, '--task', row.task], runOn: host } } : {}),
122
+ ...(isLive ? { closeCommand: { command: 'browser', args: ['done', '--task', row.task], runOn: host } } : {}),
126
123
  };
127
124
  }
128
125
  export function projectComputerToolRow(scope, row) {
@@ -1,5 +1,6 @@
1
1
  import type { Meta } from './types.js';
2
2
  import { type SinkMessageFormat } from './sink-format.js';
3
+ import type { OwnerEvent, OwnerNotification } from './owner-notify.js';
3
4
  export type FeedPostLevel = 'milestone' | 'important';
4
5
  export declare function parseFeedPostLevel(raw: string | undefined): FeedPostLevel;
5
6
  export interface FeedSinkConfig {
@@ -28,6 +29,7 @@ export interface FeedBroadcastContext {
28
29
  options?: string[];
29
30
  safeDefault?: string;
30
31
  timeoutMinutes?: number;
32
+ eventKey?: string;
31
33
  }
32
34
  export declare function blockBroadcastContext(block: {
33
35
  blockId: string;
@@ -58,8 +60,7 @@ interface PlannedSink {
58
60
  channel?: string;
59
61
  to?: string;
60
62
  text?: string;
61
- ctx?: FeedBroadcastContext;
62
- messageTemplate?: string;
63
+ owner?: OwnerNotification;
63
64
  }
64
65
  export interface SinkOutcome {
65
66
  name: string;
@@ -67,10 +68,11 @@ export interface SinkOutcome {
67
68
  error?: string;
68
69
  }
69
70
  export declare function composeBroadcastMessage(ctx: FeedBroadcastContext, format?: SinkMessageFormat): string;
71
+ export declare function ownerNotificationFromContext(ctx: FeedBroadcastContext, event: OwnerEvent, dedupKey: string, template?: string): OwnerNotification | undefined;
70
72
  export declare function renderSinkArgv(template: string[], ctx: FeedBroadcastContext): string[] | undefined;
71
73
  export declare function renderSinkMessage(template: string, ctx: FeedBroadcastContext, format?: SinkMessageFormat): string | undefined;
72
74
  export declare function planFeedBroadcast(config: FeedBroadcastConfig | undefined, ctx: FeedBroadcastContext, meta?: Meta): PlannedSink[];
73
- export declare function effectiveBroadcastConfig(config: FeedBroadcastConfig | undefined, level: FeedPostLevel, meta: Meta): FeedBroadcastConfig | undefined;
75
+ export declare function effectiveBroadcastConfig(config: FeedBroadcastConfig | undefined, level: FeedPostLevel): FeedBroadcastConfig | undefined;
74
76
  export declare const DESKTOP_NOTIFY_SINK = "notify";
75
77
  export declare function withDesktopNotify(config: FeedBroadcastConfig | undefined, notify: boolean): FeedBroadcastConfig | undefined;
76
78
  export declare function runFeedBroadcast(planned: PlannedSink[], meta: Meta, timeoutMs?: number): Promise<SinkOutcome[]>;
@@ -1,11 +1,10 @@
1
1
  import { spawnSync } from 'child_process';
2
- import { isOwnerAlias, readOwnerDest, resolveSendEnvelope, deliverEnvelope } from './channels/send.js';
2
+ import { isOwnerAlias, resolveSendEnvelope, deliverEnvelope } from './channels/send.js';
3
3
  import { lookupTransport } from './channels/resolve.js';
4
4
  import { registerBuiltinProviders } from './channels/providers/index.js';
5
5
  import { sendToOwner } from './notify.js';
6
6
  import { linearIssueUrl, linearIssueKeys } from '@phnx-labs/sessions-cli/reader';
7
7
  import { isValidMailboxId } from './mailbox.js';
8
- import { forwardOwnerNotifyToPeer } from './channels/owner-forward.js';
9
8
  import { sinkMessageFormat } from './sink-format.js';
10
9
  const LEVEL_RANK = { milestone: 0, important: 1 };
11
10
  export function parseFeedPostLevel(raw) {
@@ -186,6 +185,32 @@ export function composeBroadcastMessage(ctx, format = 'plain') {
186
185
  }
187
186
  return parts.join('\n').trim();
188
187
  }
188
+ const OWNER_DEFAULT_TITLES = {
189
+ needs_you: 'Agent needs input',
190
+ completed: 'Run completed',
191
+ failed: 'Run failed',
192
+ spend_threshold: 'Spend threshold reached',
193
+ message: 'Message from your agent',
194
+ };
195
+ export function ownerNotificationFromContext(ctx, event, dedupKey, template = '{message}') {
196
+ const untitled = { ...ctx, title: undefined };
197
+ const body = renderSinkMessage(template, untitled, 'plain');
198
+ if (!body)
199
+ return undefined;
200
+ const url = ctx.links?.[0] ?? sessionConsoleUrl(ctx.session);
201
+ const device = shortHost(ctx.host);
202
+ const agent = ctx.agent?.trim();
203
+ return {
204
+ event,
205
+ title: scrubOutboundDashes(ctx.title ?? '') || OWNER_DEFAULT_TITLES[event],
206
+ body,
207
+ ...(url ? { url } : {}),
208
+ ...(ctx.session ? { sessionId: ctx.session } : {}),
209
+ ...(ctx.ticket ? { ticket: ctx.ticket } : {}),
210
+ dedupKey,
211
+ ...(device || agent ? { source: { ...(device ? { device } : {}), ...(agent ? { agent } : {}) } } : {}),
212
+ };
213
+ }
189
214
  function templateVars(ctx, format = 'plain') {
190
215
  return {
191
216
  title: ctx.title,
@@ -267,21 +292,23 @@ export function planFeedBroadcast(config, ctx, meta) {
267
292
  continue;
268
293
  const channel = sink.channel?.trim();
269
294
  if (channel) {
270
- if (!isOwnerAlias(channel) && !sink.to?.trim())
271
- continue;
272
- const owner = isOwnerAlias(channel);
273
295
  const template = sink.message ?? '{message}';
274
- const provider = owner ? channel : resolveSinkProvider(channel, meta);
275
- const text = renderSinkMessage(template, ctx, sinkMessageFormat(provider));
296
+ if (isOwnerAlias(channel)) {
297
+ const blocked = Boolean(ctx.blockId);
298
+ const dedupKey = blocked ? `block:${ctx.blockId}` : `feed:${ctx.eventKey}`;
299
+ if (!blocked && !ctx.eventKey)
300
+ throw new Error(`feed sink '${name}': an owner notification needs the post's event key`);
301
+ const owner = ownerNotificationFromContext(ctx, blocked ? 'needs_you' : 'message', dedupKey, template);
302
+ if (owner)
303
+ planned.push({ name, channel, owner });
304
+ continue;
305
+ }
306
+ if (!sink.to?.trim())
307
+ continue;
308
+ const text = renderSinkMessage(template, ctx, sinkMessageFormat(resolveSinkProvider(channel, meta)));
276
309
  if (!text)
277
310
  continue;
278
- planned.push({
279
- name,
280
- channel,
281
- to: owner ? undefined : sink.to.trim(),
282
- text,
283
- ...(owner ? { ctx, messageTemplate: template } : {}),
284
- });
311
+ planned.push({ name, channel, to: sink.to.trim(), text });
285
312
  continue;
286
313
  }
287
314
  if (!Array.isArray(sink.command) || sink.command.length === 0)
@@ -293,13 +320,11 @@ export function planFeedBroadcast(config, ctx, meta) {
293
320
  }
294
321
  return planned;
295
322
  }
296
- export function effectiveBroadcastConfig(config, level, meta) {
323
+ export function effectiveBroadcastConfig(config, level) {
297
324
  if (config && Object.keys(config).length > 0)
298
325
  return config;
299
326
  if (level !== 'important')
300
327
  return undefined;
301
- if (!readOwnerDest(meta))
302
- return undefined;
303
328
  return { owner: { channel: 'owner' } };
304
329
  }
305
330
  export const DESKTOP_NOTIFY_SINK = 'notify';
@@ -329,33 +354,19 @@ function runCommandSink(name, argv, timeoutMs) {
329
354
  }
330
355
  async function runChannelSink(sink, meta) {
331
356
  const name = sink.name;
332
- registerBuiltinProviders();
333
- const owner = isOwnerAlias(sink.channel);
334
- if (owner) {
335
- const composeForFormat = sink.ctx
336
- ? (format) => renderSinkMessage(sink.messageTemplate ?? '{message}', sink.ctx, format) ?? sink.text ?? ''
337
- : undefined;
338
- const result = await sendToOwner(sink.text ?? '', { meta, composeForFormat });
357
+ if (sink.owner) {
358
+ const result = await sendToOwner(sink.owner);
339
359
  return { name, ok: result.ok, ...(result.error ? { error: result.error } : {}) };
340
360
  }
341
- const resolved = resolveSendEnvelope({
342
- text: sink.text ?? '',
343
- channel: owner ? undefined : sink.channel,
344
- to: owner ? 'owner' : sink.to,
345
- ownerMode: owner,
346
- }, meta);
361
+ registerBuiltinProviders();
362
+ const resolved = resolveSendEnvelope({ text: sink.text ?? '', channel: sink.channel, to: sink.to }, meta);
347
363
  if (!resolved.ok)
348
364
  return { name, ok: false, error: resolved.error };
349
365
  const { provider, error } = lookupTransport(resolved.envelope.channel, meta);
350
366
  if (!provider)
351
367
  return { name, ok: false, error };
352
368
  const result = await deliverEnvelope(resolved.envelope, meta);
353
- if (result.ok)
354
- return { name, ok: true };
355
- const forwarded = await forwardOwnerNotifyToPeer(resolved.envelope.text, resolved.envelope.channel, resolved.envelope.to, meta);
356
- if (forwarded?.ok)
357
- return { name, ok: true };
358
- return { name, ok: false, error: result.error };
369
+ return result.ok ? { name, ok: true } : { name, ok: false, error: result.error };
359
370
  }
360
371
  export async function runFeedBroadcast(planned, meta, timeoutMs = 20_000) {
361
372
  const outcomes = [];
@@ -41,6 +41,10 @@ export interface FleetSharedDeviceState {
41
41
  accounts?: {
42
42
  rows: unknown[];
43
43
  };
44
+ ownerNotify?: {
45
+ signedIn: boolean;
46
+ deviceToken: boolean;
47
+ };
44
48
  receivedAt?: number;
45
49
  }
46
50
  interface FleetSharedStatePatch {
@@ -48,6 +52,7 @@ interface FleetSharedStatePatch {
48
52
  auth?: FleetSharedDeviceState['auth'];
49
53
  sessions?: FleetSharedDeviceState['sessions'];
50
54
  accounts?: FleetSharedDeviceState['accounts'];
55
+ ownerNotify?: FleetSharedDeviceState['ownerNotify'];
51
56
  receivedAt?: number;
52
57
  }
53
58
  interface FleetSharedStateReadResult {
@@ -37,6 +37,11 @@ export function parseFleetSharedDeviceStateEnvelope(parsed, owner) {
37
37
  if (accounts !== undefined && (!isRecord(accounts) || !Array.isArray(accounts.rows))) {
38
38
  throw new Error('unrecognized account verdict rows');
39
39
  }
40
+ const ownerNotify = parsed.ownerNotify;
41
+ if (ownerNotify !== undefined &&
42
+ (!isRecord(ownerNotify) || typeof ownerNotify.signedIn !== 'boolean' || typeof ownerNotify.deviceToken !== 'boolean')) {
43
+ throw new Error('unrecognized owner-notify state');
44
+ }
40
45
  if (parsed.receivedAt !== undefined && (typeof parsed.receivedAt !== 'number' || !Number.isFinite(parsed.receivedAt))) {
41
46
  throw new Error('unrecognized receivedAt');
42
47
  }
@@ -61,6 +66,7 @@ function mergeFleetState(currentRaw, device, patch) {
61
66
  ...(patch.auth !== undefined ? { auth: patch.auth } : {}),
62
67
  ...(patch.sessions !== undefined ? { sessions: patch.sessions } : {}),
63
68
  ...(patch.accounts !== undefined ? { accounts: patch.accounts } : {}),
69
+ ...(patch.ownerNotify !== undefined ? { ownerNotify: patch.ownerNotify } : {}),
64
70
  ...(patch.receivedAt !== undefined ? { receivedAt: patch.receivedAt } : {}),
65
71
  version: FLEET_SHARED_STATE_VERSION,
66
72
  device,
@@ -159,5 +165,7 @@ export async function storePeerFleetSharedDeviceState(state, userAgentsDir = get
159
165
  patch.sessions = state.sessions;
160
166
  if (state.accounts !== undefined)
161
167
  patch.accounts = state.accounts;
168
+ if (state.ownerNotify !== undefined)
169
+ patch.ownerNotify = state.ownerNotify;
162
170
  return updateFleetSharedDeviceStateAsync(state.device, patch, userAgentsDir);
163
171
  }
@@ -100,7 +100,10 @@ export declare function fetchReviewAndHead(repo: string, number: number, gh?: Gh
100
100
  reviewDecision: string | null;
101
101
  headRefOid: string | null;
102
102
  }>;
103
- export declare function enrichPr(repo: string, pr: ProjectPr, gh?: GhExec): Promise<ProjectPr>;
103
+ export declare function enrichPr(repo: string, pr: ProjectPr, gh?: GhExec): Promise<{
104
+ pr: ProjectPr;
105
+ reviewError: string | null;
106
+ }>;
104
107
  export declare const MERGED_WINDOW_DAYS = 7;
105
108
  export declare const MERGED_LIMIT = 20;
106
109
  export declare const MERGED_PAGE_CAP = 3;
@@ -79,10 +79,21 @@ export async function fetchReviewAndHead(repo, number, gh = ghExec) {
79
79
  };
80
80
  }
81
81
  export async function enrichPr(repo, pr, gh = ghExec) {
82
- const { reviewDecision, headRefOid } = await fetchReviewAndHead(repo, pr.number, gh);
83
- const head = headRefOid || pr.headSha;
82
+ let review;
83
+ let reviewError = null;
84
+ try {
85
+ review = await fetchReviewAndHead(repo, pr.number, gh);
86
+ }
87
+ catch (err) {
88
+ const message = ghFailure(err);
89
+ if (!isRateLimited(message))
90
+ throw err;
91
+ review = { reviewDecision: null, headRefOid: null };
92
+ reviewError = `review status unavailable: ${message}`;
93
+ }
94
+ const head = review.headRefOid || pr.headSha;
84
95
  const checks = await rollupForSha(repo, head, gh);
85
- return { ...pr, headSha: head, checks, reviewDecision, ...ciFromRollupItems(checks) };
96
+ return { pr: { ...pr, headSha: head, checks, reviewDecision: review.reviewDecision, ...ciFromRollupItems(checks) }, reviewError };
86
97
  }
87
98
  export const MERGED_WINDOW_DAYS = 7;
88
99
  export const MERGED_LIMIT = 20;
@@ -397,11 +408,13 @@ export async function buildProjectPrs(def, opts = {}, gh = ghExec, peers = [], c
397
408
  const mergeRead = readRepoMergeAbility(slug, gh).then((merge) => ({ merge, error: null }), (err) => ({ merge: null, error: err }));
398
409
  if (opts.number !== undefined) {
399
410
  const pr = await fetchOnePr(slug, opts.number, gh);
400
- const enriched = await enrichPr(slug, pr, gh);
411
+ const { pr: enriched, reviewError } = await enrichPr(slug, pr, gh);
401
412
  const { merge, error: mergeError } = await mergeRead;
402
413
  return {
403
414
  slug, sharedWith, pullRequests: [enriched], merge,
404
- recentlyMerged: [], defaultBranch: null, ciError: mergeError === null ? null : ghFailure(mergeError), truncated: false, release: null, releaseError: null, error: null,
415
+ recentlyMerged: [], defaultBranch: null,
416
+ ciError: [reviewError, mergeError === null ? null : ghFailure(mergeError)].filter(Boolean).join('; ') || null,
417
+ truncated: false, release: null, releaseError: null, error: null,
405
418
  };
406
419
  }
407
420
  const errors = new CiErrors();
@@ -536,7 +549,7 @@ export function ghFailure(err) {
536
549
  return line.replace(/^gh:\s*/, '');
537
550
  }
538
551
  export const BLOCKED_WITHOUT_ADMIN = 'Blocked by branch protection; pass --admin to merge as an admin';
539
- const MERGEABLE_STATES = new Set(['clean', 'unstable', 'has_hooks']);
552
+ const MERGEABLE_STATES = new Set(['clean', 'unstable', 'has_hooks', 'unknown', '']);
540
553
  export function mergeRefusalWithoutAdmin(state) {
541
554
  if (MERGEABLE_STATES.has(state))
542
555
  return null;
@@ -545,7 +558,7 @@ export function mergeRefusalWithoutAdmin(state) {
545
558
  case 'dirty': return 'Has merge conflicts';
546
559
  case 'behind': return 'The branch is behind its base; update it, or pass --admin to merge as an admin';
547
560
  case 'draft': return 'Draft: mark it ready for review first';
548
- default: return 'GitHub is still computing mergeability; try again in a moment';
561
+ default: return `GitHub reports the PR as ${state}; not merging`;
549
562
  }
550
563
  }
551
564
  export function readableMergeRefusal(message) {
@@ -12,5 +12,6 @@ interface HelpSections {
12
12
  }
13
13
  export declare function setHelpSections(cmd: Command, sections: HelpSections): void;
14
14
  export declare function getHelpSections(cmd: Command): Readonly<HelpSections>;
15
+ export declare function forwardsHelp(cmd: Command): Command;
15
16
  export declare function applyGlobalHelpConventions(root: Command): void;
16
17
  export {};
package/dist/lib/help.js CHANGED
@@ -151,7 +151,15 @@ function formatHelpCommandsFirst(cmd, helper) {
151
151
  }
152
152
  return output.join('\n');
153
153
  }
154
+ const FORWARDS_HELP = new WeakSet();
155
+ export function forwardsHelp(cmd) {
156
+ cmd.helpOption(false);
157
+ FORWARDS_HELP.add(cmd);
158
+ return cmd;
159
+ }
154
160
  function applyHelpConventionsRecursive(cmd) {
161
+ if (FORWARDS_HELP.has(cmd))
162
+ return;
155
163
  cmd
156
164
  .helpOption('-h, --help', 'Show help')
157
165
  .addHelpCommand(false)
@@ -1,5 +1,5 @@
1
1
  export const HELPER_RELEASES = {
2
- menubar: { tagPrefix: 'menubar', floor: '1.7.0' },
2
+ menubar: { tagPrefix: 'menubar', floor: '1.15.8' },
3
3
  };
4
4
  export function helperTag(helper, version) {
5
5
  const release = HELPER_RELEASES[helper];
@@ -3,12 +3,12 @@ import { assertValidSshTarget, sshStream } from '../ssh-exec.js';
3
3
  import { resolveHost, resolveHostByCap } from './registry.js';
4
4
  import { sshTargetFor, hostIdentityArgs } from './types.js';
5
5
  import { dispatchAgentsCommand, withActorEnv } from './dispatch.js';
6
- import { stripRoutingFlags, buildRemoteAgentsInvocation, stripClixml, HOST_ROUTING_SPECS, } from './remote-cmd.js';
6
+ import { stripRoutingFlags, buildRemoteAgentsInvocation, stripClixml, } from './remote-cmd.js';
7
7
  import { resolveRemoteOsSync } from './remote-os.js';
8
8
  import { machineId } from '../machine-id.js';
9
9
  import { isDeviceAuto, resolveDeviceAffinity } from '../smart-launch.js';
10
10
  import { isDeviceInteractive, resolveInteractiveDevice, interactiveUnsetError, } from '../devices/interactive-host.js';
11
- import { flagValue, hasHostRoutingFlag } from './routing-flag.js';
11
+ import { flagValue, hasHostRoutingFlag, ROUTING_OPTION_SPECS } from './routing-flag.js';
12
12
  import { loadDevices } from '../devices/registry.js';
13
13
  import { isSelfHost } from '../devices/self-host.js';
14
14
  import { markFleetRemote } from '../devices/connect.js';
@@ -84,14 +84,8 @@ export const OWN_HOST_COMMANDS = new Set([
84
84
  'devices',
85
85
  'fleet',
86
86
  'apply',
87
- 'monitors',
88
87
  ]);
89
- const STRIP_SPECS = [
90
- ...HOST_ROUTING_SPECS,
91
- { long: 'no-tty', takesValue: false },
92
- { long: 'hosts', takesValue: true },
93
- { long: 'devices', takesValue: true },
94
- ];
88
+ const STRIP_SPECS = ROUTING_OPTION_SPECS;
95
89
  function firstSubcommand(allArgs, group) {
96
90
  const idx = allArgs.indexOf(group);
97
91
  return idx >= 0 ? allArgs.slice(idx + 1).find((a) => !a.startsWith('-')) : undefined;
@@ -349,6 +343,8 @@ export async function maybeRunOnHost(command, allArgs, opts) {
349
343
  return false;
350
344
  if (OWN_HOST_COMMANDS.has(command))
351
345
  return false;
346
+ if (command === 'daemon' && firstSubcommand(allArgs, 'daemon') === 'index')
347
+ return false;
352
348
  if (command === 'teams') {
353
349
  const teamsIdx = allArgs.indexOf('teams');
354
350
  const sub = teamsIdx >= 0 ? allArgs.slice(teamsIdx + 1).find((a) => !a.startsWith('-')) : undefined;
@@ -1,10 +1,6 @@
1
- export interface StripSpec {
2
- long: string;
3
- short?: string;
4
- takesValue: boolean;
5
- }
1
+ import { type StripSpec } from './routing-flag.js';
2
+ export { HOST_ROUTING_SPECS, type StripSpec } from './routing-flag.js';
6
3
  export declare function stripRoutingFlags(args: string[], specs: StripSpec[]): string[];
7
- export declare const HOST_ROUTING_SPECS: StripSpec[];
8
4
  type RunOptionForwarding = 'forward' | 'reject' | 'local-only';
9
5
  export declare const RUN_OPTION_FORWARDING: Record<string, RunOptionForwarding>;
10
6
  export declare const RUN_OPTION_REJECT_MESSAGES: Record<string, string>;
@@ -36,4 +32,3 @@ export declare function buildWindowsStdinImportCommand(bundle: string, opts?: {
36
32
  force?: boolean;
37
33
  policyNever?: boolean;
38
34
  }): string;
39
- export {};
@@ -3,32 +3,20 @@ import { pwshLiteral, pwshNativeExecStatements } from '../pwsh.js';
3
3
  import { quoteWin32ExecArg } from '../platform/exec.js';
4
4
  import { homeRemainder } from '../project-root.js';
5
5
  import * as zlib from 'node:zlib';
6
+ import { scanArgv } from './routing-flag.js';
7
+ export { HOST_ROUTING_SPECS } from './routing-flag.js';
6
8
  export function stripRoutingFlags(args, specs) {
7
- const out = [];
8
- for (let i = 0; i < args.length; i++) {
9
- const a = args[i];
10
- const spec = specs.find((s) => {
11
- if (a === `--${s.long}` || a.startsWith(`--${s.long}=`))
12
- return true;
13
- if (s.short && (a === `-${s.short}` || a.startsWith(`-${s.short}=`) || new RegExp(`^-${s.short}.+`).test(a)))
14
- return true;
15
- return false;
16
- });
17
- if (!spec) {
18
- out.push(a);
9
+ const out = [...args];
10
+ for (const r of scanArgv(args, specs).routing) {
11
+ if (!specs.some((s) => s.long === r.spec.long))
19
12
  continue;
20
- }
21
- const isExact = a === `--${spec.long}` || (spec.short && a === `-${spec.short}`);
22
- if (spec.takesValue && isExact && i + 1 < args.length)
23
- i++;
13
+ for (let i = r.start; i <= r.end; i++)
14
+ out[i] = undefined;
15
+ if (r.kept && r.kept !== '-')
16
+ out[r.start] = r.kept;
24
17
  }
25
- return out;
18
+ return out.filter((a) => a !== undefined);
26
19
  }
27
- export const HOST_ROUTING_SPECS = [
28
- { long: 'device', short: 'D', takesValue: true },
29
- { long: 'host', short: 'H', takesValue: true },
30
- { long: 'remote-cwd', takesValue: true },
31
- ];
32
20
  export const RUN_OPTION_FORWARDING = {
33
21
  mode: 'forward',
34
22
  effort: 'forward',
@@ -96,6 +84,10 @@ export const RUN_OPTION_FORWARDING = {
96
84
  listTasks: 'local-only',
97
85
  results: 'local-only',
98
86
  concurrency: 'local-only',
87
+ all: 'local-only',
88
+ teams: 'local-only',
89
+ since: 'local-only',
90
+ limit: 'local-only',
99
91
  };
100
92
  export const RUN_OPTION_REJECT_MESSAGES = {
101
93
  terminal: '--terminal opens a tab on THIS machine; it cannot be combined with --device. ' +
@@ -1,2 +1,24 @@
1
+ import type { Command } from 'commander';
2
+ export interface StripSpec {
3
+ long: string;
4
+ short?: string;
5
+ takesValue: boolean;
6
+ }
7
+ export declare const HOST_ROUTING_SPECS: StripSpec[];
8
+ export declare const ROUTING_OPTION_SPECS: StripSpec[];
9
+ export interface RoutingOccurrence {
10
+ spec: StripSpec;
11
+ start: number;
12
+ end: number;
13
+ value?: string;
14
+ kept?: string;
15
+ }
16
+ export interface ScannedArgv {
17
+ commandIndex?: number;
18
+ routing: RoutingOccurrence[];
19
+ }
20
+ export declare function setArgvCommandTree(root: Command | undefined): void;
21
+ export declare function scanArgv(args: string[], extra?: StripSpec[]): ScannedArgv;
22
+ export declare function commandTokenIndex(args: string[]): number | undefined;
1
23
  export declare function flagValue(args: string[], long: string, short?: string): string | undefined;
2
24
  export declare function hasHostRoutingFlag(args: string[]): boolean;