@phnx-labs/agents-cli 1.22.122 → 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 (194) hide show
  1. package/CHANGELOG.md +261 -0
  2. package/README.md +49 -10
  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 -10
  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 +6 -0
  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/models.js +1 -1
  27. package/dist/commands/prune.js +6 -28
  28. package/dist/commands/ps-roster.d.ts +0 -1
  29. package/dist/commands/ps-roster.js +2 -21
  30. package/dist/commands/ps.js +13 -1
  31. package/dist/commands/recordings.d.ts +2 -0
  32. package/dist/commands/recordings.js +117 -0
  33. package/dist/commands/routines.js +1 -1
  34. package/dist/commands/secrets-passthrough.js +3 -3
  35. package/dist/commands/send.js +33 -20
  36. package/dist/commands/sessions-backfill.d.ts +1 -0
  37. package/dist/commands/sessions-backfill.js +48 -13
  38. package/dist/commands/sessions-migrate.d.ts +1 -1
  39. package/dist/commands/sessions-migrate.js +11 -10
  40. package/dist/commands/sessions-optimize.d.ts +1 -0
  41. package/dist/commands/sessions-optimize.js +7 -4
  42. package/dist/commands/sessions-resume.js +8 -1
  43. package/dist/commands/sessions-stats.d.ts +2 -0
  44. package/dist/commands/sessions-stats.js +24 -7
  45. package/dist/commands/sessions.d.ts +5 -11
  46. package/dist/commands/sessions.js +8 -236
  47. package/dist/commands/setup-computer.js +1 -2
  48. package/dist/commands/setup.js +1 -1
  49. package/dist/commands/teams.js +2 -2
  50. package/dist/commands/testdata/feed-hub.d.ts +1 -0
  51. package/dist/commands/testdata/feed-hub.js +11 -0
  52. package/dist/commands/trash.d.ts +0 -1
  53. package/dist/commands/trash.js +74 -10
  54. package/dist/lib/accounting/usage-sync.js +7 -0
  55. package/dist/lib/agent-modes.d.ts +1 -1
  56. package/dist/lib/agent-modes.js +11 -5
  57. package/dist/lib/auth-mint.d.ts +4 -0
  58. package/dist/lib/auth-mint.js +6 -4
  59. package/dist/lib/browser/native-history.test-fixture.d.ts +12 -0
  60. package/dist/lib/browser/native-history.test-fixture.js +43 -0
  61. package/dist/lib/browser/paths.d.ts +5 -0
  62. package/dist/lib/browser/paths.js +7 -1
  63. package/dist/lib/browser/sessions-list.d.ts +28 -1
  64. package/dist/lib/browser/sessions-list.js +137 -25
  65. package/dist/lib/channels/providers/rush.d.ts +2 -1
  66. package/dist/lib/channels/providers/rush.js +2 -2
  67. package/dist/lib/channels/providers/session.d.ts +1 -0
  68. package/dist/lib/channels/providers/session.js +23 -12
  69. package/dist/lib/channels/registry.d.ts +9 -2
  70. package/dist/lib/channels/send.d.ts +5 -10
  71. package/dist/lib/channels/send.js +88 -50
  72. package/dist/lib/cloud/rush.d.ts +6 -0
  73. package/dist/lib/cloud/rush.js +18 -3
  74. package/dist/lib/computer-client.d.ts +19 -0
  75. package/dist/lib/computer-client.js +104 -0
  76. package/dist/lib/config-keys.d.ts +5 -1
  77. package/dist/lib/config-keys.js +14 -11
  78. package/dist/lib/daemon/auth-sync-service.js +13 -0
  79. package/dist/lib/daemon/daemon.js +20 -8
  80. package/dist/lib/daemon/owner-device-delivery-service.d.ts +10 -0
  81. package/dist/lib/daemon/owner-device-delivery-service.js +28 -0
  82. package/dist/lib/daemon-services.d.ts +2 -1
  83. package/dist/lib/daemon-services.js +17 -5
  84. package/dist/lib/device-config.d.ts +4 -1
  85. package/dist/lib/device-config.js +57 -7
  86. package/dist/lib/devices/doctor-findings.d.ts +2 -3
  87. package/dist/lib/devices/doctor-findings.js +10 -19
  88. package/dist/lib/event-provenance.d.ts +1 -0
  89. package/dist/lib/event-provenance.js +2 -0
  90. package/dist/lib/exec.d.ts +1 -0
  91. package/dist/lib/exec.js +20 -15
  92. package/dist/lib/feed/pr-status.d.ts +5 -1
  93. package/dist/lib/feed/pr-status.js +44 -3
  94. package/dist/lib/feed/tool-activity.js +9 -6
  95. package/dist/lib/feed/tools.d.ts +4 -1
  96. package/dist/lib/feed/tools.js +8 -11
  97. package/dist/lib/feed-broadcast.d.ts +5 -3
  98. package/dist/lib/feed-broadcast.js +47 -36
  99. package/dist/lib/fleet-shared-state.d.ts +5 -0
  100. package/dist/lib/fleet-shared-state.js +8 -0
  101. package/dist/lib/github/project-prs.d.ts +4 -1
  102. package/dist/lib/github/project-prs.js +18 -5
  103. package/dist/lib/help.d.ts +1 -0
  104. package/dist/lib/help.js +8 -0
  105. package/dist/lib/helper-versions.js +1 -1
  106. package/dist/lib/hosts/passthrough.js +5 -8
  107. package/dist/lib/hosts/remote-cmd.d.ts +2 -7
  108. package/dist/lib/hosts/remote-cmd.js +14 -22
  109. package/dist/lib/hosts/routing-flag.d.ts +22 -0
  110. package/dist/lib/hosts/routing-flag.js +127 -14
  111. package/dist/lib/identity/index.d.ts +22 -0
  112. package/dist/lib/identity/index.js +3 -0
  113. package/dist/lib/installations/migrate.d.ts +7 -0
  114. package/dist/lib/installations/migrate.js +99 -88
  115. package/dist/lib/installations/versions.js +2 -2
  116. package/dist/lib/launch-identity.d.ts +6 -1
  117. package/dist/lib/launch-identity.js +12 -2
  118. package/dist/lib/menubar/install-menubar.d.ts +1 -0
  119. package/dist/lib/menubar/install-menubar.js +8 -5
  120. package/dist/lib/menubar/snapshot.js +2 -3
  121. package/dist/lib/notify.d.ts +7 -14
  122. package/dist/lib/notify.js +29 -75
  123. package/dist/lib/owner-message.d.ts +4 -6
  124. package/dist/lib/owner-message.js +12 -11
  125. package/dist/lib/owner-notify-tokens.d.ts +49 -0
  126. package/dist/lib/owner-notify-tokens.js +214 -0
  127. package/dist/lib/owner-notify.d.ts +75 -0
  128. package/dist/lib/owner-notify.js +144 -0
  129. package/dist/lib/recordings/config.d.ts +11 -0
  130. package/dist/lib/recordings/config.js +54 -0
  131. package/dist/lib/recordings/identity.d.ts +12 -0
  132. package/dist/lib/recordings/identity.js +57 -0
  133. package/dist/lib/recordings/ledger.d.ts +16 -0
  134. package/dist/lib/recordings/ledger.js +141 -0
  135. package/dist/lib/recordings/model.d.ts +29 -0
  136. package/dist/lib/recordings/model.js +28 -0
  137. package/dist/lib/recordings/pipeline.d.ts +44 -0
  138. package/dist/lib/recordings/pipeline.js +272 -0
  139. package/dist/lib/recordings/process.d.ts +17 -0
  140. package/dist/lib/recordings/process.js +94 -0
  141. package/dist/lib/recordings/service.d.ts +15 -0
  142. package/dist/lib/recordings/service.js +45 -0
  143. package/dist/lib/recordings/settle.d.ts +21 -0
  144. package/dist/lib/recordings/settle.js +92 -0
  145. package/dist/lib/recordings/transcode.d.ts +13 -0
  146. package/dist/lib/recordings/transcode.js +44 -0
  147. package/dist/lib/reminders.d.ts +0 -1
  148. package/dist/lib/reminders.js +1 -1
  149. package/dist/lib/reserved-stores.d.ts +3 -0
  150. package/dist/lib/reserved-stores.js +13 -0
  151. package/dist/lib/routine-notify-owner.d.ts +3 -23
  152. package/dist/lib/routine-notify-owner.js +26 -107
  153. package/dist/lib/rush-api.d.ts +1 -0
  154. package/dist/lib/rush-api.js +1 -0
  155. package/dist/lib/session/active.d.ts +18 -2
  156. package/dist/lib/session/active.js +47 -37
  157. package/dist/lib/session/cloud.js +18 -45
  158. package/dist/lib/session/db.d.ts +2 -0
  159. package/dist/lib/session/db.js +13 -4
  160. package/dist/lib/session/glance-files.d.ts +4 -3
  161. package/dist/lib/session/glance-files.js +31 -0
  162. package/dist/lib/session/inject-target.js +12 -2
  163. package/dist/lib/session/pid-registry.d.ts +2 -0
  164. package/dist/lib/session/pid-registry.js +6 -2
  165. package/dist/lib/session/presentation.d.ts +21 -0
  166. package/dist/lib/session/presentation.js +198 -0
  167. package/dist/lib/session/projection.js +9 -2
  168. package/dist/lib/sqlite.d.ts +3 -1
  169. package/dist/lib/sqlite.js +7 -3
  170. package/dist/lib/standalone-tools.js +1 -1
  171. package/dist/lib/startup/command-registry.js +9 -4
  172. package/dist/lib/state.d.ts +2 -2
  173. package/dist/lib/state.js +3 -5
  174. package/dist/lib/terminal/inject.js +1 -1
  175. package/dist/lib/testdata/owner-notify-api.d.ts +36 -0
  176. package/dist/lib/testdata/owner-notify-api.js +102 -0
  177. package/dist/lib/trash.d.ts +14 -0
  178. package/dist/lib/trash.js +75 -0
  179. package/dist/lib/types.d.ts +0 -34
  180. package/package.json +1 -1
  181. package/dist/commands/feedback.d.ts +0 -2
  182. package/dist/commands/feedback.js +0 -68
  183. package/dist/commands/humans.d.ts +0 -2
  184. package/dist/commands/humans.js +0 -83
  185. package/dist/commands/modes.d.ts +0 -2
  186. package/dist/commands/modes.js +0 -134
  187. package/dist/commands/reminders.d.ts +0 -2
  188. package/dist/commands/reminders.js +0 -49
  189. package/dist/lib/channels/owner-forward.d.ts +0 -25
  190. package/dist/lib/channels/owner-forward.js +0 -78
  191. package/dist/lib/channels/owner-sink.d.ts +0 -10
  192. package/dist/lib/channels/owner-sink.js +0 -26
  193. package/dist/lib/humans.d.ts +0 -12
  194. package/dist/lib/humans.js +0 -64
@@ -3,14 +3,13 @@ import type { DuplicateVersionHook } from '../hooks/install.js';
3
3
  import type { AgentsBinaryShadow } from '../binary-shadow.js';
4
4
  import type { LeakedDaemon } from '../daemon/leaked-daemons.js';
5
5
  import type { RcSecretFinding } from '../secrets-types.js';
6
- import type { OwnerSinkStatus } from '../channels/owner-sink.js';
7
6
  import { type WindowsSshEnrollmentAudit } from './windows-ssh-enrollment.js';
8
7
  import type { SyncStatusRow, OrphanRow } from '../drift.js';
9
8
  import type { FetchStatusMarker } from '../auto-pull.js';
10
9
  import { type VersionResourceReport } from '../doctor-diff.js';
11
10
  import type { FleetDivergence, FleetHookRuntimeState, FleetVersionSignIn } from './fleet-divergence.js';
12
11
  export type FindingSeverity = 'critical' | 'warning';
13
- export declare const ALL_FINDING_KINDS: readonly ["logged-out", "logout-unprovable", "missing-hook", "missing-plugin", "unwired-hook", "hook-runtime-broken", "hook-runtime-visibility-unavailable", "cli-missing", "missing-resource", "content-drift", "never-synced", "stale", "repo-behind", "repo-drift", "fleet-resource-gap", "host-cli-missing", "host-cli-invalid", "version-skew", "orphan", "duplicate-hook", "duplicate-hook-drift", "rc-secret-export", "env-secret-export", "auth-bundle-wrong-backend", "exec-policy", "ssh-key-enrollment", "stale-cli", "binary-shadow", "owner-sink-unreachable", "leaked-daemon"];
12
+ export declare const ALL_FINDING_KINDS: readonly ["logged-out", "logout-unprovable", "missing-hook", "missing-plugin", "unwired-hook", "hook-runtime-broken", "hook-runtime-visibility-unavailable", "cli-missing", "missing-resource", "content-drift", "never-synced", "stale", "repo-behind", "repo-drift", "fleet-resource-gap", "host-cli-missing", "host-cli-invalid", "version-skew", "orphan", "duplicate-hook", "duplicate-hook-drift", "rc-secret-export", "env-secret-export", "auth-bundle-wrong-backend", "exec-policy", "ssh-key-enrollment", "stale-cli", "binary-shadow", "owner-not-signed-in", "leaked-daemon"];
14
13
  export declare const FINDING_SEVERITY: Record<FindingKind, FindingSeverity>;
15
14
  export type FindingKind = typeof ALL_FINDING_KINDS[number];
16
15
  export interface DoctorFinding {
@@ -53,7 +52,7 @@ export interface LocalFindingInputs {
53
52
  };
54
53
  windowsSshEnrollment?: WindowsSshEnrollmentAudit | null;
55
54
  isolatedVersions?: string[];
56
- ownerSink?: OwnerSinkStatus;
55
+ ownerSignedIn?: boolean;
57
56
  binaryShadows?: AgentsBinaryShadow[];
58
57
  leakedDaemons?: LeakedDaemon[];
59
58
  }
@@ -20,8 +20,8 @@
20
20
  * unwired-hook (a hook on disk that settings.json never fires) ·
21
21
  * hook-runtime-broken (a wired hook's generated shim wrapper is
22
22
  * missing or unusable) · cli-missing · ssh-key-enrollment ·
23
- * owner-sink-unreachable (the feed/notify owner lane
24
- * cannot reach the owner from this box).
23
+ * owner-not-signed-in (no Phoenix session or worker device
24
+ * token, so this box cannot reach the owner).
25
25
  * WARNING — logout-unprovable (hedged) · missing-resource · content-drift ·
26
26
  * never-synced · stale · repo-behind · repo-drift · version-skew ·
27
27
  * fleet-resource-gap · hook-runtime-visibility-unavailable · orphan · duplicate-hook ·
@@ -97,7 +97,7 @@ export const ALL_FINDING_KINDS = [
97
97
  'ssh-key-enrollment',
98
98
  'stale-cli',
99
99
  'binary-shadow',
100
- 'owner-sink-unreachable',
100
+ 'owner-not-signed-in',
101
101
  'leaked-daemon',
102
102
  ];
103
103
  export const FINDING_SEVERITY = {
@@ -107,7 +107,7 @@ export const FINDING_SEVERITY = {
107
107
  'unwired-hook': 'critical',
108
108
  'hook-runtime-broken': 'critical',
109
109
  'cli-missing': 'critical',
110
- 'owner-sink-unreachable': 'critical',
110
+ 'owner-not-signed-in': 'critical',
111
111
  'logout-unprovable': 'warning',
112
112
  'hook-runtime-visibility-unavailable': 'warning',
113
113
  'missing-resource': 'warning',
@@ -216,8 +216,8 @@ export function remediationFor(finding) {
216
216
  return 'remove or repoint the shadowing agents install(s)';
217
217
  case 'leaked-daemon':
218
218
  return 'kill <pid>';
219
- case 'owner-sink-unreachable':
220
- return 'check the channel transport: iMessage needs macOS, Slack needs SLACK_BOT_TOKEN in env or the webhooks bundle';
219
+ case 'owner-not-signed-in':
220
+ return 'agents auth login';
221
221
  }
222
222
  }
223
223
  function finding(f) {
@@ -241,19 +241,10 @@ export function buildLocalFindings(input) {
241
241
  message: `${agentName(agent)} binary not found`,
242
242
  }));
243
243
  }
244
- const sink = input.ownerSink;
245
- if (sink?.configured && !sink.reachable) {
246
- const chan = sink.channel ?? 'owner';
247
- const why = sink.reason === 'imessage-not-macos'
248
- ? 'iMessage requires macOS (peer-forward delivers from a macOS peer)'
249
- : sink.reason === 'slack-no-token'
250
- ? 'no SLACK_BOT_TOKEN — set it in env or the webhooks secrets bundle'
251
- : sink.reason === 'channel-unsupported'
252
- ? `${chan} transport removed (Rush daemon)`
253
- : 'transport unreachable';
244
+ if (input.ownerSignedIn === false) {
254
245
  out.push(finding({
255
- severity: FINDING_SEVERITY['owner-sink-unreachable'], kind: 'owner-sink-unreachable', device,
256
- message: `${chan} → owner unreachable: ${why}`,
246
+ severity: FINDING_SEVERITY['owner-not-signed-in'], kind: 'owner-not-signed-in', device,
247
+ message: 'cannot reach the owner: no Phoenix session or worker device token',
257
248
  }));
258
249
  }
259
250
  for (const report of input.reports) {
@@ -706,7 +697,7 @@ function subjectLabel(f) {
706
697
  return f.version ? `${f.agent} @${f.version}` : f.agent;
707
698
  }
708
699
  function critLabel(f) {
709
- if (f.kind === 'owner-sink-unreachable')
700
+ if (f.kind === 'owner-not-signed-in')
710
701
  return { left: 'owner', account: '', message: f.message };
711
702
  return {
712
703
  left: subjectLabel(f),
@@ -12,6 +12,7 @@ interface EventProvenance {
12
12
  parentSessionId?: string;
13
13
  parentLaunchId?: string;
14
14
  originTerminalId?: string;
15
+ originDevice?: string;
15
16
  }
16
17
  export declare function stampProvenance(env?: NodeJS.ProcessEnv): EventProvenance;
17
18
  export declare function resetEventProvenanceForTest(): void;
@@ -39,6 +39,8 @@ export function stampProvenance(env = process.env) {
39
39
  provenance.parentLaunchId = env.AGENTS_PARENT_LAUNCH_ID;
40
40
  if (env.AGENTS_ORIGIN_TERMINAL_ID)
41
41
  provenance.originTerminalId = env.AGENTS_ORIGIN_TERMINAL_ID;
42
+ if (env.AGENTS_ORIGIN_DEVICE)
43
+ provenance.originDevice = env.AGENTS_ORIGIN_DEVICE;
42
44
  return provenance;
43
45
  }
44
46
  export function resetEventProvenanceForTest() {
@@ -102,6 +102,7 @@ export declare function inferredInteractiveWithoutTty(options: Pick<ExecOptions,
102
102
  export declare function shouldTapStdout(interactive: boolean, piped: boolean, capsActive: boolean, captureTail?: boolean): boolean;
103
103
  export declare function parseExecEnv(entries: string[]): Record<string, string> | undefined;
104
104
  export declare function resolveLaunchId(envLaunchId: string | undefined): string;
105
+ export declare function inheritsHarnessMode(options: ExecOptions): boolean;
105
106
  export declare function buildExecEnv(options: ExecOptions): NodeJS.ProcessEnv;
106
107
  export declare function ensureVendorHomeDir(agent: AgentId, versionHome: string): string | null;
107
108
  interface AgentCommandTemplate {
package/dist/lib/exec.js CHANGED
@@ -12,7 +12,7 @@ import { isTierToken, resolveTier } from './model-tiers.js';
12
12
  import { emit, createTimer, redactPrompt, redactArgs } from './feed/events.js';
13
13
  import { sanitizeProcessEnv } from './secrets-client.js';
14
14
  import { resolveActor, actorEnv } from './actor.js';
15
- import { launchIdentityEnv, LAUNCH_IDENTITY_KEYS } from './launch-identity.js';
15
+ import { launchIdentityEnv, launchOrigin, LAUNCH_IDENTITY_KEYS } from './launch-identity.js';
16
16
  import { expandLocalHome } from './project-root.js';
17
17
  import { getShimsDir, getHistoryDir, getUserAgentsDir, getRuntimeStateDir } from './state.js';
18
18
  import { readCodexConfiguredModel } from './installations/shims.js';
@@ -221,6 +221,9 @@ export function resolveLaunchId(envLaunchId) {
221
221
  const inbound = envLaunchId?.trim();
222
222
  return inbound ? inbound : randomUUID();
223
223
  }
224
+ export function inheritsHarnessMode(options) {
225
+ return options.modeWasImplicit === true && implicitModeFor(options.agent) === 'plan';
226
+ }
224
227
  // Child runs shed parent session/mailbox/account/exec-home identity; lineage is reintroduced only through explicit parent fields.
225
228
  export function buildExecEnv(options) {
226
229
  const result = { ...sanitizeProcessEnv(process.env) };
@@ -258,7 +261,12 @@ export function buildExecEnv(options) {
258
261
  result.AGENTS_RUNTIME = resolveInteractive(options) ? 'terminal' : 'headless';
259
262
  // Bind the standalone secrets client to the same store agents-cli resolved.
260
263
  result.SECRETS_HOME = result.SECRETS_HOME ?? getUserAgentsDir();
261
- result.AGENTS_RUN_MODE = resolveHeadlessMode(options.agent, normalizeMode(options.mode), resolveInteractive(options), options.modeWarningContext, options.modeWarningState);
264
+ if (inheritsHarnessMode(options)) {
265
+ delete result.AGENTS_RUN_MODE;
266
+ }
267
+ else {
268
+ result.AGENTS_RUN_MODE = resolveHeadlessMode(options.agent, normalizeMode(options.mode), resolveInteractive(options), options.modeWarningContext, options.modeWarningState);
269
+ }
262
270
  result.AGENTS_HISTORY_DIR = getHistoryDir();
263
271
  if (options.agent) {
264
272
  const runVersion = options.version ?? resolveVersion(options.agent, options.cwd || process.cwd());
@@ -567,7 +575,7 @@ export function buildExecCommand(options) {
567
575
  }
568
576
  }
569
577
  }
570
- const resolvedMode = resolveHeadlessMode(options.agent, normalizeMode(options.mode), interactive, options.modeWarningContext, options.modeWarningState);
578
+ const resolvedMode = resolveHeadlessMode(options.agent, normalizeMode(options.mode), interactive, options.modeWarningContext, inheritsHarnessMode(options) ? { quiet: true } : options.modeWarningState);
571
579
  const modeFlags = template.modeFlags[resolvedMode];
572
580
  if (!modeFlags) {
573
581
  throw new Error(`Internal error: ${options.agent} declares '${resolvedMode}' in capabilities.modes but has no entry in AGENT_COMMANDS.modeFlags.${resolvedMode}.`);
@@ -583,24 +591,18 @@ export function buildExecCommand(options) {
583
591
  if (preModeArgs) {
584
592
  cmd.push(...preModeArgs);
585
593
  }
586
- const modeArgsOverride = launchAdapter.execModeArgs?.(launchArgsCtx);
587
- if (modeArgsOverride !== undefined) {
588
- cmd.push(...modeArgsOverride);
589
- }
590
- else if (resumeSpec && 'subcommand' in resumeSpec) {
591
- if (resolvedMode === 'skip') {
592
- cmd.push('--dangerously-bypass-approvals-and-sandbox');
594
+ if (!inheritsHarnessMode(options)) {
595
+ const modeArgsOverride = launchAdapter.execModeArgs?.(launchArgsCtx);
596
+ if (modeArgsOverride !== undefined) {
597
+ cmd.push(...modeArgsOverride);
593
598
  }
594
- else if (interactive) {
595
- cmd.push(...modeFlags);
599
+ else if (resumeSpec && 'subcommand' in resumeSpec && resolvedMode === 'skip') {
600
+ cmd.push('--dangerously-bypass-approvals-and-sandbox');
596
601
  }
597
602
  else {
598
603
  cmd.push(...modeFlags);
599
604
  }
600
605
  }
601
- else {
602
- cmd.push(...modeFlags);
603
- }
604
606
  if (!interactive && template.printFlags) {
605
607
  cmd.push(...template.printFlags);
606
608
  }
@@ -736,6 +738,7 @@ async function execShimPassthroughLeased(agent, rawArgs, cwd, pinnedVersion) {
736
738
  initiatedBy: resolveActor().kind,
737
739
  launchId,
738
740
  terminalId: launchIdentityEnv().AGENT_TERMINAL_ID,
741
+ originTerminal: launchOrigin(),
739
742
  startedAtMs: Date.now(),
740
743
  });
741
744
  if (passthroughSessionId) {
@@ -953,6 +956,7 @@ async function runInTmux(options, executable, args) {
953
956
  initiatedBy: resolveActor().kind,
954
957
  launchId: options.env?.AGENT_LAUNCH_ID,
955
958
  terminalId: launchIdentityEnv().AGENT_TERMINAL_ID,
959
+ originTerminal: launchOrigin(),
956
960
  tmuxPane: pane,
957
961
  startedAtMs: Date.now(),
958
962
  });
@@ -1253,6 +1257,7 @@ async function spawnAgentLeased(options) {
1253
1257
  initiatedBy: resolveActor().kind,
1254
1258
  launchId,
1255
1259
  terminalId: launchIdentityEnv().AGENT_TERMINAL_ID,
1260
+ originTerminal: launchOrigin(),
1256
1261
  tmuxPane: process.env.TMUX_PANE,
1257
1262
  startedAtMs: Date.now(),
1258
1263
  });
@@ -1,9 +1,12 @@
1
1
  import type { ActiveSession } from '../session/active.js';
2
2
  import type { DetectedPr } from '@phnx-labs/sessions-cli/reader';
3
+ import type { PrCheckItem, SessionPr } from '../session/active.js';
3
4
  import type { GhExec } from '../github/pr-mergeable.js';
4
5
  import type { PullRequestAttentionSignal } from './attention.js';
5
6
  export declare const PR_STATUS_TTL_MS = 45000;
7
+ export declare const MAX_PR_CHECK_ITEMS = 30;
6
8
  export interface PullRequestStatus extends PullRequestAttentionSignal {
9
+ headRefOid?: string;
7
10
  statusCheckRollup?: unknown[];
8
11
  }
9
12
  export declare const PR_STATUS_DEFAULT_TIMEOUT_MS = 15000;
@@ -15,6 +18,7 @@ export declare function readPullRequestStatus(session: ActiveSession, options?:
15
18
  }): Promise<PullRequestStatus | undefined>;
16
19
  export declare function resetPullRequestStatusCache(): void;
17
20
  export declare function checksVerdict(rollup?: unknown[]): DetectedPr['checks'];
21
+ export declare function checkItemsFrom(rollup?: unknown[]): PrCheckItem[] | undefined;
18
22
  export declare function withPullRequestStatus<T extends {
19
- pr?: DetectedPr;
23
+ pr?: SessionPr;
20
24
  }>(row: T, status?: PullRequestStatus): T;
@@ -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
  }