@wonderwhy-er/desktop-commander 0.3.1-alpha.2 → 0.3.1

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 (80) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +1152 -1152
  3. package/dist/bootstrap.js +0 -0
  4. package/dist/command-manager.js +0 -0
  5. package/dist/config-field-definitions.js +0 -0
  6. package/dist/config-manager.js +0 -0
  7. package/dist/config-recovery.js +0 -0
  8. package/dist/config.js +0 -0
  9. package/dist/custom-stdio.js +0 -0
  10. package/dist/data/onboarding-prompts.json +70 -70
  11. package/dist/error-handlers.js +0 -0
  12. package/dist/handlers/filesystem-handlers.js +2 -2
  13. package/dist/index.js +0 -0
  14. package/dist/npm-scripts/remote.js +25 -23
  15. package/dist/remote-device/desktop-commander-integration.d.ts +1 -0
  16. package/dist/remote-device/device.js +14 -2
  17. package/dist/remote-device/realtime-health-telemetry.d.ts +35 -0
  18. package/dist/remote-device/realtime-health-telemetry.js +110 -0
  19. package/dist/remote-device/remote-channel.d.ts +66 -55
  20. package/dist/remote-device/remote-channel.js +336 -389
  21. package/dist/remote-device/rollouts.d.ts +48 -0
  22. package/dist/remote-device/rollouts.js +105 -0
  23. package/dist/remote-device/scripts/blocking-offline-update.js +135 -133
  24. package/dist/search-manager.js +0 -0
  25. package/dist/server.js +581 -712
  26. package/dist/setup-claude-server.js +942 -942
  27. package/dist/terminal-manager.js +0 -0
  28. package/dist/tools/edit.js +2 -2
  29. package/dist/tools/fuzzySearch.js +9 -9
  30. package/dist/tools/improved-process-tools.js +10 -10
  31. package/dist/tools/pdf/extract-images.js +2 -6
  32. package/dist/tools/pdf/lib/pdf2md.js +28 -33
  33. package/dist/tools/pdf/utils.d.ts +10 -0
  34. package/dist/tools/pdf/utils.js +11 -0
  35. package/dist/tools/prompts.js +1 -1
  36. package/dist/tools/schemas.d.ts +0 -10
  37. package/dist/tools/schemas.js +0 -8
  38. package/dist/track-installation.js +387 -387
  39. package/dist/types.js +0 -0
  40. package/dist/ui/config-editor/config-editor-runtime.js +53 -53
  41. package/dist/ui/config-editor/index.html +13 -13
  42. package/dist/ui/config-editor/src/app.js +30 -30
  43. package/dist/ui/config-editor/src/array-modal.js +32 -32
  44. package/dist/ui/config-editor/styles.css +586 -586
  45. package/dist/ui/contracts.d.ts +27 -0
  46. package/dist/ui/contracts.js +36 -0
  47. package/dist/ui/file-preview/index.html +16 -16
  48. package/dist/ui/file-preview/preview-runtime.js +190 -182
  49. package/dist/ui/file-preview/src/app.js +8 -8
  50. package/dist/ui/file-preview/src/components/html-renderer.js +4 -2
  51. package/dist/ui/file-preview/src/document-layout.js +31 -31
  52. package/dist/ui/file-preview/src/document-outline.js +8 -8
  53. package/dist/ui/file-preview/src/markdown/conflict-dialog.js +33 -33
  54. package/dist/ui/file-preview/src/markdown/controller.js +9 -9
  55. package/dist/ui/file-preview/src/markdown/editor.js +31 -31
  56. package/dist/ui/file-preview/styles.css +1630 -1630
  57. package/dist/ui/resources.js +11 -4
  58. package/dist/uninstall-claude-server.js +745 -745
  59. package/dist/utils/files/binary.js +4 -4
  60. package/dist/utils/files/excel.js +3 -3
  61. package/dist/utils/files/text.d.ts +7 -0
  62. package/dist/utils/files/text.js +40 -21
  63. package/dist/utils/system-info.d.ts +1 -0
  64. package/dist/utils/system-info.js +110 -97
  65. package/dist/utils/terminal-timestamps.d.ts +2 -0
  66. package/dist/utils/terminal-timestamps.js +18 -0
  67. package/dist/utils/usageTracker.d.ts +0 -39
  68. package/dist/utils/usageTracker.js +16 -176
  69. package/dist/version.d.ts +1 -1
  70. package/dist/version.js +1 -1
  71. package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -56
  72. package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -32
  73. package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -38
  74. package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -164
  75. package/package.json +6 -10
  76. package/vendor/telemetry-contract/README.md +56 -56
  77. package/vendor/telemetry-contract/package.json +32 -32
  78. package/vendor/telemetry-contract/transport.d.ts +38 -38
  79. package/vendor/telemetry-contract/transport.js +164 -164
  80. package/vendor/telemetry-contract/transport.test.js +39 -39
@@ -12,7 +12,7 @@ export interface AuthSession {
12
12
  }
13
13
  /**
14
14
  * The device registered, but its realtime channel is not usable — the join
15
- * failed, or presence was never acknowledged. Distinct from every other
15
+ * failed, or the device row could not be marked ready. Distinct from every other
16
16
  * registration failure on purpose: this one the socket watchdog can repair, so
17
17
  * the caller keeps the process alive, while a failed lookup or a missing row
18
18
  * happens before the recreation parameters are stored and nothing can repair it.
@@ -27,18 +27,22 @@ interface DeviceData {
27
27
  status: string;
28
28
  last_seen: string;
29
29
  }
30
- /** Jittered version of realtime-js's default 1s/2s/5s/10s stepped backoff. */
30
+ export declare const HEARTBEAT_INTERVAL_MS: number;
31
+ /** Exponential-ish SDK backoff. Attempts 1-4 preserve short recovery latency. */
31
32
  export declare function realtimeReconnectDelayMs(tries: number, random?: () => number): number;
32
- /** Preserve Presence's existing 500ms-per-attempt retry shape, but desynchronize it. */
33
- export declare function presenceRetryDelayMs(failedAttempt: number, random?: () => number): number;
33
+ /** Watchdog must not defeat the SDK's slower persistent-failure backoff. */
34
+ export declare function watchdogRecreateDelayMs(tries: number, random?: () => number): number;
35
+ /**
36
+ * Wait before the next track() after failed ones, across SDK rejoins and
37
+ * recreates. Never shorter than the step; up to 50% extra spreads the fleet.
38
+ */
39
+ export declare function presenceRecoveryDelayMs(failures: number, random?: () => number): number;
34
40
  export declare function observeServerDate(dateHeader: string | null): void;
35
41
  export declare class RemoteChannel {
36
42
  private client;
37
43
  private channel;
38
44
  private heartbeatInterval;
39
45
  private connectionCheckInterval;
40
- /** Device the heartbeat timer maintains; null = stopped, so re-arm is inert. */
41
- private heartbeatDeviceId;
42
46
  private statusWriteChain;
43
47
  /**
44
48
  * Answers whether the local execution child is alive. Default yes, so a
@@ -60,19 +64,27 @@ export declare class RemoteChannel {
60
64
  private deviceName;
61
65
  private onToolCall;
62
66
  private authListenerRegistered;
63
- /** False when presence publishing failed on an otherwise healthy channel;
64
- * the health check retries, since SUBSCRIBED won't fire again. */
67
+ /** The current join's status write landed: dispatchable. Gates the
68
+ * heartbeat, so only that write first marks the row online. */
69
+ private channelReady;
70
+ /** Readiness write in flight. Cleared on every join, so each join writes its own. */
71
+ private readinessInFlight;
72
+ private consecutiveReadinessFailures;
73
+ private nextReadinessAttemptAt;
74
+ /** Presence published on the current join. Dashboard only; never gates dispatch. */
65
75
  private presenceTracked;
66
- /** Last capability value written (null = never), to avoid redundant writes. */
67
- private transportCapableWritten;
68
- /** Value of the last capability write still queued or in flight; null once the queue is idle. */
69
- private transportCapableQueued;
70
- private capabilityWriteChain;
71
- /** Monotonic start of a Presence-only degradation while broadcast remains joined. */
72
- private presenceFailureStartedAt;
73
76
  /** Re-entrancy guard: on a wedged socket each track() buffers for the full
74
77
  * 10s push timeout, so 10s health ticks would stack pushes. */
75
78
  private isTrackingPresence;
79
+ private consecutiveUnreadyJoins;
80
+ private consecutivePresenceFailures;
81
+ private nextPresenceAttemptAt;
82
+ /** performance.now() of the latest SUBSCRIBED; null while not joined. */
83
+ private joinedAt;
84
+ /** SDK channel and socket timers share reconnectAfterMs. The persistent
85
+ * unready-join budget prevents a series of partial successes restarting at 1s. */
86
+ private reconnectDelayMs;
87
+ private readonly realtimeHealth;
76
88
  private lastDeviceStatus;
77
89
  private lastChannelState;
78
90
  private reconnectAttempt;
@@ -120,6 +132,14 @@ export declare class RemoteChannel {
120
132
  };
121
133
  error: any;
122
134
  }>;
135
+ /**
136
+ * The session's current access token, for the realtime socket and the
137
+ * device's own requests. getSession() may refresh on-demand when the token
138
+ * reads expired — that check is clock-skew-safe now (see clockAwareFetch
139
+ * above). Without a session it falls back to the last token known, and
140
+ * without that it is null, never the anon key.
141
+ */
142
+ getAccessToken(): Promise<string | null>;
123
143
  findDevice(deviceId: string): Promise<{
124
144
  id: any;
125
145
  device_name: any;
@@ -134,30 +154,27 @@ export declare class RemoteChannel {
134
154
  }>;
135
155
  registerDevice(capabilities: any, currentDeviceId: string | undefined, deviceName: string, onToolCall: (payload: any) => void): Promise<void>;
136
156
  /**
137
- * Publish presence, retrying a non-'ok' result — track() resolves with a
138
- * status rather than rejecting, and absent presence reads as offline on the
139
- * dashboard. `presenceTracked` lets the health check retry later.
157
+ * Mark this join dispatchable by writing `status`. The write has to land —
158
+ * Supabase reports a refused write in the result rather than by throwing.
159
+ * The health check retries on its own cooldown.
140
160
  */
141
- private trackPresenceWithRetry;
142
- private trackPresenceInner;
161
+ private markChannelReady;
162
+ private markChannelReadyInner;
143
163
  /**
144
- * The complete `capabilities` JSONB value. One place only: every write
145
- * replaces the whole column, so a second literal would silently drop keys.
164
+ * Publish presence for the dashboard. Best effort: one track() per call,
165
+ * no effect on readiness, and a growing cooldown after each failure — a
166
+ * track() timeout on the server can end the whole channel, and every
167
+ * rejoin would otherwise publish again.
146
168
  */
147
- private capabilitiesPayload;
169
+ private trackPresence;
170
+ /** Presence is withheld by its cooldown right now. Monotonic, so a Date.now
171
+ * skew correction cannot shorten or extend it. */
172
+ private presenceInCooldown;
148
173
  /**
149
- * Advertise (or withdraw) the broadcast capability. Only true while genuinely
150
- * reachable that way — the server fails dispatch fast without it and picks
151
- * the offline-sweep tier from it, so every change must re-arm the heartbeat.
152
- *
153
- * Writes are queued, like the status writes. A withdrawal the recreate stops
154
- * waiting for still lands: compared with the last landed value, a re-publish
155
- * in the meantime looked redundant and was skipped, and the withdrawal then
156
- * left a device that claims to be online without the flag. Resolves with
157
- * whether the row holds `capable` once this write is done.
174
+ * The complete `capabilities` JSONB value. The write replaces the whole
175
+ * column, so a key left out here is dropped from the row.
158
176
  */
159
- private setTransportCapable;
160
- private writeTransportCapable;
177
+ private capabilitiesPayload;
161
178
  /** Aborts one write to this device's row after DEVICE_ROW_WRITE_TIMEOUT_MS (a method, so tests can shorten it). */
162
179
  private deviceRowWriteSignal;
163
180
  /** Create and subscribe the private channel (initial join and recreation). */
@@ -212,18 +229,20 @@ export declare class RemoteChannel {
212
229
  * Claim a call. True only when THIS update flipped the row pending ->
213
230
  * executing, which is what makes dual delivery safe across processes.
214
231
  * .eq('status','pending') makes it conditional; .select('id') makes the
215
- * result observable. On a transient DB error it returns true (execute
216
- * anyway), matching prior behaviour — so device.ts's in-memory guard is what
232
+ * result observable. Expiry is checked using Postgres time, not the
233
+ * device clock. On a transient DB error it returns true (execute anyway),
234
+ * matching prior behaviour — so device.ts's in-memory guard is what
217
235
  * actually guarantees exactly-once within a process.
218
236
  */
219
237
  markCallExecuting(callId: string): Promise<boolean>;
220
238
  updateCallResult(callId: string, status: string, result?: any, errorMessage?: string | null): Promise<void>;
221
239
  /**
222
240
  * Reachable means all of it is true at once: the private channel is
223
- * joined, this device has published its presence, and the local executor
224
- * answers. The server needs the first two before it will dispatch, and a
225
- * healthy channel on a device whose executor is dead is the false-online
226
- * state issue #4 was opened for. Gates the heartbeat and `status`.
241
+ * joined, the join's status write landed, and the local executor answers.
242
+ * The server needs the first two before it will dispatch, and a healthy
243
+ * channel on a device whose executor is dead is the false-online state
244
+ * issue #4 was opened for. Presence is not part of it. Gates the heartbeat
245
+ * and `status`.
227
246
  */
228
247
  private isReachable;
229
248
  /**
@@ -239,28 +258,20 @@ export declare class RemoteChannel {
239
258
  /** Resolves with whether the row actually took the write. */
240
259
  syncReachabilityStatus(): Promise<boolean>;
241
260
  /**
242
- * Serialize the channel-callback status writes. They fire from un-awaited
243
- * callbacks, and inside recreateChannel() a teardown's 'offline' and the
244
- * fresh join's 'online' land ~100-300ms apart — unordered, 'offline' can win
245
- * and leave a healthy device undispatchable until the next heartbeat.
261
+ * Serialize the status writes, the heartbeat's included. They fire from
262
+ * un-awaited callbacks, and inside recreateChannel() a teardown's 'offline'
263
+ * and the fresh join's 'online' land ~100-300ms apart — unordered, 'offline'
264
+ * can win and leave a healthy device undispatchable until the next heartbeat.
246
265
  *
247
- * Not the single writer: updateHeartbeat, registerDevice and setOffline's
248
- * subprocess write status directly, so this is not total ordering.
266
+ * Not the single writer: registerDevice and setOffline's subprocess write
267
+ * status directly, so this is not total ordering.
249
268
  */
250
269
  private queueStatusWrite;
251
- /**
252
- * Heartbeat cadence for the tier this device is CURRENTLY in. Follows the
253
- * capability flag (what the server actually tiers its sweep on), not the
254
- * build — see LEGACY_HEARTBEAT_INTERVAL.
255
- */
256
- private heartbeatIntervalMs;
257
- updateHeartbeat(deviceId: string): Promise<void>;
270
+ updateHeartbeat(): Promise<void>;
258
271
  startHeartbeat(deviceId: string): void;
259
272
  private refreshTokenNow;
260
273
  private startTokenRefresh;
261
274
  private stopTokenRefresh;
262
- /** Arm (or re-arm) the last_seen timer at the current tier's cadence. */
263
- private scheduleHeartbeat;
264
275
  stopHeartbeat(): void;
265
276
  /** @returns whether the row actually took the write. */
266
277
  setOnlineStatus(deviceId: string, status: 'online' | 'offline'): Promise<boolean>;