@phnx-labs/agents-cli 1.22.65 → 1.22.68

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 (112) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +7 -2
  3. package/dist/bootstrap.js +3 -3
  4. package/dist/commands/apply.js +9 -2
  5. package/dist/commands/browser.js +46 -21
  6. package/dist/commands/daemon-test-harness.d.ts +1 -1
  7. package/dist/commands/daemon-test-harness.js +2 -2
  8. package/dist/commands/daemon.js +21 -22
  9. package/dist/commands/exec.js +40 -0
  10. package/dist/commands/monitors.js +2 -2
  11. package/dist/commands/repo.js +57 -19
  12. package/dist/commands/resume.d.ts +16 -0
  13. package/dist/commands/resume.js +41 -8
  14. package/dist/commands/routines.js +42 -21
  15. package/dist/commands/sessions-optimize.js +1 -1
  16. package/dist/commands/sessions.js +4 -11
  17. package/dist/commands/share.d.ts +5 -3
  18. package/dist/commands/share.js +33 -9
  19. package/dist/lib/accounting/account-pool-collect.d.ts +6 -4
  20. package/dist/lib/accounting/account-pool-collect.js +6 -4
  21. package/dist/lib/accounting/usage-ingest.js +4 -2
  22. package/dist/lib/accounting/usage-sync.d.ts +38 -93
  23. package/dist/lib/accounting/usage-sync.js +66 -210
  24. package/dist/lib/accounting/usage.d.ts +11 -3
  25. package/dist/lib/accounting/usage.js +23 -10
  26. package/dist/lib/auth-health.d.ts +8 -0
  27. package/dist/lib/auth-health.js +4 -4
  28. package/dist/lib/browser/caller-identity.d.ts +12 -0
  29. package/dist/lib/browser/caller-identity.js +19 -0
  30. package/dist/lib/browser/ipc.d.ts +37 -32
  31. package/dist/lib/browser/ipc.js +146 -94
  32. package/dist/lib/browser/task-index.d.ts +10 -2
  33. package/dist/lib/browser/task-index.js +22 -3
  34. package/dist/lib/daemon/account-state-daemon-service.d.ts +49 -9
  35. package/dist/lib/daemon/account-state-daemon-service.js +81 -18
  36. package/dist/lib/daemon/auth-sync-service.d.ts +4 -4
  37. package/dist/lib/daemon/auth-sync-service.js +17 -6
  38. package/dist/lib/daemon/catchup-service.d.ts +51 -0
  39. package/dist/lib/daemon/catchup-service.js +51 -0
  40. package/dist/lib/daemon/daemon.d.ts +12 -22
  41. package/dist/lib/daemon/daemon.js +463 -176
  42. package/dist/lib/daemon/runner.js +2 -0
  43. package/dist/lib/daemon/service.d.ts +22 -4
  44. package/dist/lib/daemon/service.js +2 -2
  45. package/dist/lib/daemon/supervisor.d.ts +55 -15
  46. package/dist/lib/daemon/supervisor.js +119 -29
  47. package/dist/lib/daemon/usage-sync-service.d.ts +4 -6
  48. package/dist/lib/daemon/usage-sync-service.js +22 -18
  49. package/dist/lib/daemon-health.js +36 -31
  50. package/dist/lib/daemon-services.d.ts +1 -1
  51. package/dist/lib/daemon-services.js +12 -2
  52. package/dist/lib/daemon-ticks.d.ts +9 -6
  53. package/dist/lib/daemon-ticks.js +14 -8
  54. package/dist/lib/devices/known-hosts.d.ts +15 -0
  55. package/dist/lib/devices/known-hosts.js +18 -0
  56. package/dist/lib/devices/registry.js +2 -0
  57. package/dist/lib/exec.js +11 -0
  58. package/dist/lib/feed/watch.d.ts +3 -0
  59. package/dist/lib/feed/watch.js +13 -3
  60. package/dist/lib/fleet-shared-repo-sync.d.ts +36 -0
  61. package/dist/lib/fleet-shared-repo-sync.js +333 -0
  62. package/dist/lib/fleet-shared-state.d.ts +38 -0
  63. package/dist/lib/fleet-shared-state.js +105 -0
  64. package/dist/lib/hosts/remote-cmd.d.ts +2 -0
  65. package/dist/lib/hosts/remote-cmd.js +12 -3
  66. package/dist/lib/lock-compromise.d.ts +8 -0
  67. package/dist/lib/lock-compromise.js +12 -0
  68. package/dist/lib/monitors/engine.d.ts +2 -1
  69. package/dist/lib/monitors/engine.js +9 -2
  70. package/dist/lib/refresh-coordinator.js +2 -0
  71. package/dist/lib/run-trace-sync.d.ts +13 -0
  72. package/dist/lib/run-trace-sync.js +77 -0
  73. package/dist/lib/secrets/push.d.ts +10 -0
  74. package/dist/lib/secrets/push.js +86 -7
  75. package/dist/lib/secrets/remote.d.ts +18 -6
  76. package/dist/lib/secrets/remote.js +29 -4
  77. package/dist/lib/secrets/reserved-sync.d.ts +28 -27
  78. package/dist/lib/secrets/reserved-sync.js +120 -102
  79. package/dist/lib/session/active.d.ts +3 -1
  80. package/dist/lib/session/active.js +2 -0
  81. package/dist/lib/session/actor-sidecar.d.ts +12 -0
  82. package/dist/lib/session/actor-sidecar.js +2 -0
  83. package/dist/lib/session/db.d.ts +5 -2
  84. package/dist/lib/session/db.js +54 -22
  85. package/dist/lib/session/discover.d.ts +12 -3
  86. package/dist/lib/session/discover.js +106 -25
  87. package/dist/lib/session/prompt.d.ts +11 -0
  88. package/dist/lib/session/prompt.js +25 -0
  89. package/dist/lib/session/recovery.d.ts +30 -2
  90. package/dist/lib/session/recovery.js +56 -4
  91. package/dist/lib/session/remote/remote-list.d.ts +17 -1
  92. package/dist/lib/session/remote/remote-list.js +29 -4
  93. package/dist/lib/session/remote/watch.d.ts +25 -2
  94. package/dist/lib/session/remote/watch.js +185 -11
  95. package/dist/lib/session/session-cache.d.ts +2 -1
  96. package/dist/lib/session/session-cache.js +1 -0
  97. package/dist/lib/session/types.d.ts +2 -0
  98. package/dist/lib/share/publish.d.ts +55 -9
  99. package/dist/lib/share/publish.js +87 -9
  100. package/dist/lib/share/worker-template.js +100 -8
  101. package/dist/lib/ssh-exec.d.ts +2 -0
  102. package/dist/lib/ssh-exec.js +20 -4
  103. package/dist/lib/teams/registry.js +2 -0
  104. package/dist/lib/testdata/daemon-health-writer.d.ts +1 -0
  105. package/dist/lib/testdata/daemon-health-writer.js +8 -0
  106. package/dist/lib/traces/sync.d.ts +7 -0
  107. package/dist/lib/traces/sync.js +9 -0
  108. package/dist/lib/usage-refresh.d.ts +8 -2
  109. package/dist/lib/usage-refresh.js +3 -3
  110. package/package.json +1 -1
  111. package/dist/lib/account-state-service.d.ts +0 -21
  112. package/dist/lib/account-state-service.js +0 -60
@@ -4,24 +4,24 @@ import type { IPCRequest, IPCResponse } from './types.js';
4
4
  export interface IPCRequestOptions {
5
5
  autoStartDaemon?: boolean;
6
6
  }
7
- export declare class BrowserDaemonNotRunningError extends Error {
7
+ export declare class BrowserServiceNotRunningError extends Error {
8
8
  constructor();
9
9
  }
10
- export declare function formatBrowserDaemonNotRunningError(): string;
10
+ export declare function formatBrowserServiceNotRunningError(daemonRunning?: boolean): string;
11
11
  export declare function getSocketPath(): string;
12
12
  /** Is the daemon reachable? A real connect probe on every platform — a socket
13
13
  * file existing on disk is not proof a daemon is listening on it. */
14
- export declare function isDaemonReachable(): Promise<boolean>;
14
+ export declare function isBrowserServiceReachable(): Promise<boolean>;
15
15
  /**
16
16
  * Is a *reachable* daemon actually responsive, or is its event loop wedged
17
- * (PHNX-3411)? Retries {@link probeDaemonResponsive} up to
17
+ * (PHNX-3411)? Retries {@link probeBrowserServiceResponsive} up to
18
18
  * {@link RESPONSIVENESS_PROBE_ATTEMPTS} times so a single transient miss (a GC
19
19
  * pause) never condemns a healthy daemon; returns true as soon as any attempt
20
20
  * gets a reply, and false only when every attempt fails.
21
21
  */
22
- export declare function isDaemonResponsive(endpoint?: string, attempts?: number): Promise<boolean>;
22
+ export declare function isBrowserServiceResponsive(endpoint?: string, attempts?: number): Promise<boolean>;
23
23
  /**
24
- * Wait until the browser daemon is genuinely reachable, or throw.
24
+ * Wait until the browser service is genuinely reachable, or throw.
25
25
  *
26
26
  * Re-probes across the whole window rather than latching on the first accept, so
27
27
  * it survives an IPC-server restart that happens mid-wait (PHNX-3289): a restart
@@ -30,32 +30,35 @@ export declare function isDaemonResponsive(endpoint?: string, attempts?: number)
30
30
  * that never comes up throws a message naming the endpoint and the budget, never
31
31
  * a silent hang.
32
32
  */
33
- export declare function waitForSocket(_socketPath: string, timeoutMs?: number): Promise<void>;
34
- /** Outcome of {@link resetBrowserDaemon} — what the wedge-recovery actually did. */
35
- export interface BrowserDaemonResetResult {
36
- /** The daemon was reachable before the reset and a stop was issued. */
33
+ export declare function waitForBrowserService(_socketPath: string, timeoutMs?: number): Promise<void>;
34
+ /** Outcome of {@link stopBrowserService} — what the service-scoped stop did. */
35
+ export interface BrowserServiceStopResult {
36
+ /** The browser IPC service was reachable before the stop was requested. */
37
37
  wasRunning: boolean;
38
+ /** The shared daemon stayed running while only browser IPC was stopped. */
39
+ daemonRunning: boolean;
38
40
  /** A leftover `browser.sock` file was unlinked (POSIX only). */
39
41
  socketCleared: boolean;
40
42
  }
41
43
  /**
42
- * Clear a wedged browser daemon so a subsequent `start` comes up clean
43
- * (PHNX-3289). Stops the shared daemon (the same `stopDaemon` path
44
- * `reconcileDaemonVersion` uses for a stale-version restart), waits for the IPC
45
- * endpoint to stop accepting, then unlinks any stale `browser.sock` a
46
- * hard-crashed daemon left behind — the file a fresh `start` would otherwise
47
- * `unlink` blindly, racing whatever still holds it.
44
+ * Stop only the daemon-hosted browser IPC service so a subsequent `start` comes
45
+ * up clean (PHNX-3605). The short-lived browser client persists the
46
+ * `browser-ipc` service off and asks the daemon to apply that transition over
47
+ * its existing SIGHUP control path. It never stops or restarts the shared
48
+ * supervisor, so routines, usage sync, secrets, and every sibling service keep
49
+ * their process and in-flight work.
48
50
  *
49
- * Fails loud: if the endpoint is *still* reachable after the quiesce window, a
50
- * live server is holding it and clearing the socket under it would orphan two
51
- * servers on one path, so we throw rather than pretend the reset worked. The
52
- * daemon auto-restarts on the next browser command.
51
+ * Once the endpoint is quiet, a stale socket left by a hard-crashed browser
52
+ * service is removed. If the daemon event loop itself is wedged and cannot
53
+ * consume SIGHUP, the endpoint remains reachable and this fails loud with the
54
+ * deliberate operator-owned whole-daemon restart command; the client never
55
+ * escalates into that process-wide action itself.
53
56
  */
54
- export declare function resetBrowserDaemon(): Promise<BrowserDaemonResetResult>;
57
+ export declare function stopBrowserService(): Promise<BrowserServiceStopResult>;
55
58
  /**
56
59
  * Remove a leftover browser socket FILE, but only when nothing is listening on
57
60
  * it — re-probing liveness IMMEDIATELY before the unlink to close the TOCTOU
58
- * window (PHNX-3289 review). Between {@link resetBrowserDaemon}'s quiesce loop
61
+ * window (PHNX-3289 review). Between {@link stopBrowserService}'s quiesce loop
59
62
  * deciding the endpoint was unreachable and this unlink, a concurrent
60
63
  * `browser start` could bind a NEW listener on the same path; an unconditional
61
64
  * unlink would then delete a LIVE daemon's socket — the exact two-servers orphan
@@ -65,7 +68,7 @@ export declare function resetBrowserDaemon(): Promise<BrowserDaemonResetResult>;
65
68
  */
66
69
  export declare function clearDeadSocketFile(endpoint: string, socketPath: string): Promise<boolean>;
67
70
  /**
68
- * One long-lived connection to the existing browser daemon. Requests are
71
+ * One long-lived connection to the existing browser service. Requests are
69
72
  * serialized so the daemon's newline-delimited responses always map to the
70
73
  * caller that produced them, while the process and socket stay warm between
71
74
  * actions.
@@ -85,6 +88,8 @@ export declare class BrowserIPCConnection {
85
88
  }
86
89
  export declare class BrowserIPCServer {
87
90
  private server;
91
+ /** Filesystem identity of the POSIX binding this server created. */
92
+ private socketIdentity;
88
93
  private service;
89
94
  /** Live client connections, so {@link stop} can end them rather than wait. */
90
95
  private connections;
@@ -128,21 +133,21 @@ export declare class BrowserIPCServer {
128
133
  private handleRequest;
129
134
  }
130
135
  /**
131
- * Decide whether a running daemon is stale and must be restarted.
136
+ * Decide whether a running daemon is stale enough to name an operator refresh.
132
137
  *
133
- * FORWARD ONLY: restart when the daemon is *older* than this CLI so a newer
134
- * install loads current code. An older CLI rides a newer daemon instead of
135
- * evicting it — two installs sharing one daemon dir (keyed off $HOME) must
136
- * not flap the daemon indefinitely.
138
+ * FORWARD ONLY: recommend a refresh when the daemon is *older* than this CLI.
139
+ * An older CLI rides a newer daemon without noise. A client never performs the
140
+ * refresh itself — two installs sharing one daemon dir (keyed off $HOME) must
141
+ * not flap the daemon or interrupt one another's hosted services.
137
142
  *
138
143
  * `undefined`/`'unknown'` means the daemon is too old to answer the `version`
139
- * action reliably — don't churn it on that ambiguous signal.
144
+ * action reliably — don't recommend an action on that ambiguous signal.
140
145
  *
141
146
  * When numeric compare cannot order two distinct strings (e.g. two
142
- * `0.0.0-dev.*` builds), treat the mismatch as a restart so a concrete
143
- * code change still loads.
147
+ * `0.0.0-dev.*` builds), surface the mismatch without deciding either client
148
+ * owns the shared process.
144
149
  */
145
- export declare function shouldRestartStaleDaemon(daemonVersion: string | undefined, clientVersion: string): boolean;
150
+ export declare function shouldRecommendDaemonRefresh(daemonVersion: string | undefined, clientVersion: string): boolean;
146
151
  export declare function sendIPCRequest(request: IPCRequest, opts?: IPCRequestOptions): Promise<IPCResponse>;
147
152
  /**
148
153
  * Fill actor / launchId / sessionId from the calling process when the request