@wonderwhy-er/desktop-commander 0.3.1-alpha.2 → 0.3.2-alpha.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.
- package/LICENSE +20 -20
- package/README.md +1154 -1152
- package/dist/bootstrap.js +0 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/command-manager.js +0 -0
- package/dist/command-manager.js.map +1 -0
- package/dist/config-field-definitions.js +0 -0
- package/dist/config-field-definitions.js.map +1 -0
- package/dist/config-manager.js +0 -0
- package/dist/config-manager.js.map +1 -0
- package/dist/config-recovery.js +0 -0
- package/dist/config-recovery.js.map +1 -0
- package/dist/config.js +0 -0
- package/dist/config.js.map +1 -0
- package/dist/custom-stdio.js +0 -0
- package/dist/custom-stdio.js.map +1 -0
- package/dist/data/onboarding-prompts.json +70 -70
- package/dist/error-handlers.js +0 -0
- package/dist/error-handlers.js.map +1 -0
- package/dist/handlers/edit-search-handlers.js.map +1 -0
- package/dist/handlers/filesystem-handlers.js +2 -2
- package/dist/handlers/filesystem-handlers.js.map +1 -0
- package/dist/handlers/history-handlers.js.map +1 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/process-handlers.js.map +1 -0
- package/dist/handlers/search-answers.js.map +1 -0
- package/dist/handlers/search-handlers.js.map +1 -0
- package/dist/handlers/terminal-handlers.js.map +1 -0
- package/dist/index.js +0 -0
- package/dist/index.js.map +1 -0
- package/dist/npm-scripts/remote.js +32 -28
- package/dist/npm-scripts/remote.js.map +1 -0
- package/dist/npm-scripts/setup.js.map +1 -0
- package/dist/npm-scripts/uninstall.js.map +1 -0
- package/dist/npm-scripts/verify-ripgrep.js.map +1 -0
- package/dist/remote-device/desktop-commander-integration.d.ts +1 -0
- package/dist/remote-device/desktop-commander-integration.js.map +1 -0
- package/dist/remote-device/device-authenticator.js.map +1 -0
- package/dist/remote-device/device.d.ts +4 -3
- package/dist/remote-device/device.js +134 -35
- package/dist/remote-device/device.js.map +1 -0
- package/dist/remote-device/diagnostics/device-log.js.map +1 -0
- package/dist/remote-device/diagnostics/redact.js.map +1 -0
- package/dist/remote-device/diagnostics/report.js +2 -1
- package/dist/remote-device/diagnostics/report.js.map +1 -0
- package/dist/remote-device/diagnostics/upload.d.ts +1 -1
- package/dist/remote-device/diagnostics/upload.js +3 -3
- package/dist/remote-device/diagnostics/upload.js.map +1 -0
- package/dist/remote-device/mqtt/config.d.ts +1 -0
- package/dist/remote-device/mqtt/config.js +3 -0
- package/dist/remote-device/mqtt/config.js.map +1 -0
- package/dist/remote-device/mqtt/mqtt-enrollment.d.ts +15 -0
- package/dist/remote-device/mqtt/mqtt-enrollment.js +293 -0
- package/dist/remote-device/mqtt/mqtt-enrollment.js.map +1 -0
- package/dist/remote-device/mqtt/mqtt-transport.d.ts +45 -0
- package/dist/remote-device/mqtt/mqtt-transport.js +276 -0
- package/dist/remote-device/mqtt/mqtt-transport.js.map +1 -0
- package/dist/remote-device/realtime-health-telemetry.d.ts +35 -0
- package/dist/remote-device/realtime-health-telemetry.js +110 -0
- package/dist/remote-device/realtime-health-telemetry.js.map +1 -0
- package/dist/remote-device/remote-channel.d.ts +87 -59
- package/dist/remote-device/remote-channel.js +509 -398
- package/dist/remote-device/remote-channel.js.map +1 -0
- package/dist/remote-device/remote-utils.d.ts +3 -0
- package/dist/remote-device/remote-utils.js +20 -0
- package/dist/remote-device/remote-utils.js.map +1 -0
- package/dist/remote-device/rollouts.d.ts +48 -0
- package/dist/remote-device/rollouts.js +105 -0
- package/dist/remote-device/rollouts.js.map +1 -0
- package/dist/remote-device/scripts/blocking-offline-update.js +135 -133
- package/dist/remote-device/transport-telemetry.d.ts +1 -1
- package/dist/remote-device/transport-telemetry.js +4 -2
- package/dist/remote-device/transport-telemetry.js.map +1 -0
- package/dist/search-manager.js +0 -0
- package/dist/search-manager.js.map +1 -0
- package/dist/server.js +581 -712
- package/dist/server.js.map +1 -0
- package/dist/setup-claude-server.js +942 -942
- package/dist/terminal-manager.js +2 -37
- package/dist/terminal-manager.js.map +1 -0
- package/dist/tools/config.js.map +1 -0
- package/dist/tools/edit.js +2 -2
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/feedback.js.map +1 -0
- package/dist/tools/filesystem.js.map +1 -0
- package/dist/tools/fuzzySearch.js +9 -9
- package/dist/tools/fuzzySearch.js.map +1 -0
- package/dist/tools/fuzzySearchCore.js.map +1 -0
- package/dist/tools/improved-process-tools.js +12 -11
- package/dist/tools/improved-process-tools.js.map +1 -0
- package/dist/tools/mime-types.js.map +1 -0
- package/dist/tools/pdf/extract-images.js +2 -6
- package/dist/tools/pdf/extract-images.js.map +1 -0
- package/dist/tools/pdf/index.js.map +1 -0
- package/dist/tools/pdf/lib/pdf2md.js +28 -33
- package/dist/tools/pdf/lib/pdf2md.js.map +1 -0
- package/dist/tools/pdf/manipulations.js.map +1 -0
- package/dist/tools/pdf/markdown.d.ts +10 -38
- package/dist/tools/pdf/markdown.js.map +1 -0
- package/dist/tools/pdf/utils.d.ts +10 -0
- package/dist/tools/pdf/utils.js +11 -0
- package/dist/tools/pdf/utils.js.map +1 -0
- package/dist/tools/process.js.map +1 -0
- package/dist/tools/prompts.js +1 -1
- package/dist/tools/prompts.js.map +1 -0
- package/dist/tools/schemas.d.ts +0 -10
- package/dist/tools/schemas.js +0 -8
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/usage.js.map +1 -0
- package/dist/track-installation.js +387 -387
- package/dist/types.js +0 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/config-editor/config-editor-runtime.js +61 -80
- package/dist/ui/config-editor/index.html +13 -13
- package/dist/ui/config-editor/src/app.js +30 -30
- package/dist/ui/config-editor/src/app.js.map +1 -0
- package/dist/ui/config-editor/src/array-modal.js +32 -32
- package/dist/ui/config-editor/src/array-modal.js.map +1 -0
- package/dist/ui/config-editor/src/main.js.map +1 -0
- package/dist/ui/config-editor/styles.css +586 -586
- package/dist/ui/contracts.d.ts +27 -0
- package/dist/ui/contracts.js +36 -0
- package/dist/ui/contracts.js.map +1 -0
- package/dist/ui/file-preview/index.html +16 -16
- package/dist/ui/file-preview/preview-runtime.js +221 -231
- package/dist/ui/file-preview/shared/preview-file-types.js.map +1 -0
- package/dist/ui/file-preview/src/app.js +8 -8
- package/dist/ui/file-preview/src/app.js.map +1 -0
- package/dist/ui/file-preview/src/components/code-viewer.js.map +1 -0
- package/dist/ui/file-preview/src/components/highlighting.js.map +1 -0
- package/dist/ui/file-preview/src/components/html-renderer.js +4 -2
- package/dist/ui/file-preview/src/components/html-renderer.js.map +1 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.js.map +1 -0
- package/dist/ui/file-preview/src/directory-controller.js.map +1 -0
- package/dist/ui/file-preview/src/document-layout.js +31 -31
- package/dist/ui/file-preview/src/document-layout.js.map +1 -0
- package/dist/ui/file-preview/src/document-outline.js +8 -8
- package/dist/ui/file-preview/src/document-outline.js.map +1 -0
- package/dist/ui/file-preview/src/document-workspace.js.map +1 -0
- package/dist/ui/file-preview/src/file-type-handlers.js.map +1 -0
- package/dist/ui/file-preview/src/host/external-actions.js.map +1 -0
- package/dist/ui/file-preview/src/host/selection-context.js.map +1 -0
- package/dist/ui/file-preview/src/image-preview.js.map +1 -0
- package/dist/ui/file-preview/src/main.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +33 -33
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/controller.js +9 -9
- package/dist/ui/file-preview/src/markdown/controller.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/editor.js +31 -31
- package/dist/ui/file-preview/src/markdown/editor.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/linking.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/outline.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/parser.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/preview.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/slugify.js.map +1 -0
- package/dist/ui/file-preview/src/markdown/utils.js.map +1 -0
- package/dist/ui/file-preview/src/model.js.map +1 -0
- package/dist/ui/file-preview/src/panel-actions.js.map +1 -0
- package/dist/ui/file-preview/src/path-utils.js.map +1 -0
- package/dist/ui/file-preview/src/payload-utils.js.map +1 -0
- package/dist/ui/file-preview/src/types.js.map +1 -0
- package/dist/ui/file-preview/styles.css +1630 -1630
- package/dist/ui/resources.js +11 -4
- package/dist/ui/resources.js.map +1 -0
- package/dist/ui/shared/compact-row.js.map +1 -0
- package/dist/ui/shared/escape-html.js.map +1 -0
- package/dist/ui/shared/host-context.js.map +1 -0
- package/dist/ui/shared/tool-bridge.js.map +1 -0
- package/dist/ui/shared/tool-shell.js.map +1 -0
- package/dist/ui/shared/ui-event-tracker.js.map +1 -0
- package/dist/ui/shared/widget-state.js.map +1 -0
- package/dist/uninstall-claude-server.js +745 -745
- package/dist/utils/ab-test.js.map +1 -0
- package/dist/utils/atomic-write.js.map +1 -0
- package/dist/utils/capture.d.ts +1 -1
- package/dist/utils/capture.js +28 -6
- package/dist/utils/capture.js.map +1 -0
- package/dist/utils/dockerPrompt.js.map +1 -0
- package/dist/utils/exit-process.js.map +1 -0
- package/dist/utils/feature-flags.js.map +1 -0
- package/dist/utils/files/base.js.map +1 -0
- package/dist/utils/files/binary.js +4 -4
- package/dist/utils/files/binary.js.map +1 -0
- package/dist/utils/files/docx.js.map +1 -0
- package/dist/utils/files/excel.js +3 -3
- package/dist/utils/files/excel.js.map +1 -0
- package/dist/utils/files/factory.js.map +1 -0
- package/dist/utils/files/image.js.map +1 -0
- package/dist/utils/files/index.js.map +1 -0
- package/dist/utils/files/pdf.js.map +1 -0
- package/dist/utils/files/text.d.ts +7 -0
- package/dist/utils/files/text.js +40 -21
- package/dist/utils/files/text.js.map +1 -0
- package/dist/utils/fuzzySearchLogger.js.map +1 -0
- package/dist/utils/internal-facts.js.map +1 -0
- package/dist/utils/lazy-package.js.map +1 -0
- package/dist/utils/lineEndingHandler.js.map +1 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-ui-ab-test.js.map +1 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/process-detection.js.map +1 -0
- package/dist/utils/process-tree.js.map +1 -0
- package/dist/utils/rename.js.map +1 -0
- package/dist/utils/ripgrep-resolver.js.map +1 -0
- package/dist/utils/shell.d.ts +11 -0
- package/dist/utils/shell.js +50 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/system-info.d.ts +1 -0
- package/dist/utils/system-info.js +110 -97
- package/dist/utils/system-info.js.map +1 -0
- package/dist/utils/terminal-timestamps.d.ts +2 -0
- package/dist/utils/terminal-timestamps.js +18 -0
- package/dist/utils/terminal-timestamps.js.map +1 -0
- package/dist/utils/toolHistory.js.map +1 -0
- package/dist/utils/trackTools.js.map +1 -0
- package/dist/utils/unsupportedParams.js.map +1 -0
- package/dist/utils/usageTracker.d.ts +0 -39
- package/dist/utils/usageTracker.js +16 -176
- package/dist/utils/usageTracker.js.map +1 -0
- package/dist/utils/welcome-onboarding.js.map +1 -0
- package/dist/utils/withTimeout.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -0
- package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -56
- package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -32
- package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +39 -38
- package/node_modules/@desktop-commander/telemetry-contract/transport.js +167 -164
- package/package.json +11 -10
- package/vendor/telemetry-contract/README.md +56 -56
- package/vendor/telemetry-contract/package.json +32 -32
- package/vendor/telemetry-contract/transport.d.ts +38 -38
- package/vendor/telemetry-contract/transport.js +164 -164
- package/vendor/telemetry-contract/transport.test.js +39 -39
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type RealtimeCounter = 'explicit_subscribe_calls' | 'join_successes' | 'join_errors' | 'join_timeouts' | 'join_closures' | 'watchdog_recreates' | 'socket_disconnects' | 'presence_attempts' | 'presence_successes' | 'presence_failures' | 'readiness_write_failures';
|
|
2
|
+
export type RealtimeWindow = Record<RealtimeCounter, number> & {
|
|
3
|
+
event_version: number;
|
|
4
|
+
device_diag_id: string;
|
|
5
|
+
process_session_id: string;
|
|
6
|
+
channel_generation: number;
|
|
7
|
+
window_start: string;
|
|
8
|
+
window_seconds: number;
|
|
9
|
+
app_version: string;
|
|
10
|
+
platform: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class RealtimeHealthTelemetry {
|
|
13
|
+
private readonly emit;
|
|
14
|
+
private readonly sample;
|
|
15
|
+
private readonly random;
|
|
16
|
+
readonly processSessionId: `${string}-${string}-${string}-${string}-${string}`;
|
|
17
|
+
private deviceDiagId;
|
|
18
|
+
private generation;
|
|
19
|
+
private counts;
|
|
20
|
+
private windowStart;
|
|
21
|
+
private windowStartMonotonic;
|
|
22
|
+
private socketState;
|
|
23
|
+
private timer;
|
|
24
|
+
constructor(emit: (window: RealtimeWindow) => void, sample?: (key: string) => number, random?: () => number);
|
|
25
|
+
private emptyCounts;
|
|
26
|
+
/** Stable for one registered device, unlinkable to its raw UUID without knowing the UUID. */
|
|
27
|
+
setDevice(deviceId: string): void;
|
|
28
|
+
newChannel(): void;
|
|
29
|
+
record(key: RealtimeCounter): void;
|
|
30
|
+
observeSocketState(state: string): void;
|
|
31
|
+
start(): void;
|
|
32
|
+
private schedule;
|
|
33
|
+
flush(now?: number, monotonicNow?: number): RealtimeWindow | null;
|
|
34
|
+
stop(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-volume Realtime lifecycle counters. No per-retry HTTP requests.
|
|
3
|
+
* Counts are local observations, NOT exact Phoenix phx_join wire frames.
|
|
4
|
+
*/
|
|
5
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
6
|
+
import { VERSION } from '../version.js';
|
|
7
|
+
const COUNTERS = [
|
|
8
|
+
'explicit_subscribe_calls', 'join_successes', 'join_errors',
|
|
9
|
+
'join_timeouts', 'join_closures', 'watchdog_recreates',
|
|
10
|
+
'socket_disconnects', 'presence_attempts', 'presence_successes',
|
|
11
|
+
'presence_failures', 'readiness_write_failures',
|
|
12
|
+
];
|
|
13
|
+
const DEGRADED = [
|
|
14
|
+
'join_errors', 'join_timeouts', 'join_closures', 'watchdog_recreates',
|
|
15
|
+
'socket_disconnects', 'presence_failures', 'readiness_write_failures',
|
|
16
|
+
];
|
|
17
|
+
export class RealtimeHealthTelemetry {
|
|
18
|
+
constructor(emit, sample = (key) => parseInt(createHash('sha256').update(key).digest('hex').slice(0, 8), 16) / 0x100000000, random = Math.random) {
|
|
19
|
+
this.emit = emit;
|
|
20
|
+
this.sample = sample;
|
|
21
|
+
this.random = random;
|
|
22
|
+
this.processSessionId = randomUUID();
|
|
23
|
+
this.deviceDiagId = '';
|
|
24
|
+
this.generation = 0;
|
|
25
|
+
this.counts = this.emptyCounts();
|
|
26
|
+
this.windowStart = Date.now();
|
|
27
|
+
this.windowStartMonotonic = performance.now();
|
|
28
|
+
this.socketState = null;
|
|
29
|
+
this.timer = null;
|
|
30
|
+
}
|
|
31
|
+
emptyCounts() {
|
|
32
|
+
return Object.fromEntries(COUNTERS.map((key) => [key, 0]));
|
|
33
|
+
}
|
|
34
|
+
/** Stable for one registered device, unlinkable to its raw UUID without knowing the UUID. */
|
|
35
|
+
setDevice(deviceId) {
|
|
36
|
+
if (!deviceId)
|
|
37
|
+
return;
|
|
38
|
+
const id = createHash('sha256').update('dc-realtime-diagnostics-v1:').update(deviceId).digest('hex').slice(0, 32);
|
|
39
|
+
if (this.deviceDiagId === id)
|
|
40
|
+
return;
|
|
41
|
+
this.deviceDiagId = id;
|
|
42
|
+
this.windowStart = Date.now();
|
|
43
|
+
this.windowStartMonotonic = performance.now();
|
|
44
|
+
this.counts = this.emptyCounts();
|
|
45
|
+
}
|
|
46
|
+
newChannel() {
|
|
47
|
+
this.generation++;
|
|
48
|
+
this.record('explicit_subscribe_calls');
|
|
49
|
+
}
|
|
50
|
+
record(key) {
|
|
51
|
+
this.counts[key]++;
|
|
52
|
+
}
|
|
53
|
+
observeSocketState(state) {
|
|
54
|
+
if (this.socketState === 'open' && state !== 'open')
|
|
55
|
+
this.record('socket_disconnects');
|
|
56
|
+
this.socketState = state;
|
|
57
|
+
}
|
|
58
|
+
start() {
|
|
59
|
+
if (this.timer)
|
|
60
|
+
return;
|
|
61
|
+
this.schedule();
|
|
62
|
+
}
|
|
63
|
+
schedule() {
|
|
64
|
+
// Each device chooses a different reporting boundary; never a fleet-wide minute mark.
|
|
65
|
+
this.timer = setTimeout(() => {
|
|
66
|
+
this.timer = null;
|
|
67
|
+
this.flush();
|
|
68
|
+
this.schedule();
|
|
69
|
+
}, 60000 + Math.floor(this.random() * 30000));
|
|
70
|
+
this.timer.unref?.();
|
|
71
|
+
}
|
|
72
|
+
flush(now = Date.now(), monotonicNow = performance.now()) {
|
|
73
|
+
// Wall time may jump when observeServerDate() corrects clock skew.
|
|
74
|
+
// Use only monotonic time for durations; wall time still locates the window.
|
|
75
|
+
const elapsed = Math.max(1, Math.round((monotonicNow - this.windowStartMonotonic) / 1000));
|
|
76
|
+
const counts = this.counts;
|
|
77
|
+
const start = this.windowStart;
|
|
78
|
+
this.counts = this.emptyCounts();
|
|
79
|
+
this.windowStart = now;
|
|
80
|
+
this.windowStartMonotonic = monotonicNow;
|
|
81
|
+
if (!this.deviceDiagId)
|
|
82
|
+
return null;
|
|
83
|
+
const degraded = DEGRADED.some((key) => counts[key] > 0);
|
|
84
|
+
const sampleRate = degraded ? 0.05 : 0.01;
|
|
85
|
+
if (this.sample(this.deviceDiagId) >= sampleRate)
|
|
86
|
+
return null;
|
|
87
|
+
const window = {
|
|
88
|
+
...counts,
|
|
89
|
+
event_version: 1,
|
|
90
|
+
device_diag_id: this.deviceDiagId,
|
|
91
|
+
process_session_id: this.processSessionId,
|
|
92
|
+
channel_generation: this.generation,
|
|
93
|
+
window_start: new Date(start).toISOString(),
|
|
94
|
+
window_seconds: elapsed,
|
|
95
|
+
app_version: VERSION,
|
|
96
|
+
platform: process.platform,
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
this.emit(window);
|
|
100
|
+
}
|
|
101
|
+
catch { /* diagnostics must not affect transport */ }
|
|
102
|
+
return window;
|
|
103
|
+
}
|
|
104
|
+
stop() {
|
|
105
|
+
if (this.timer)
|
|
106
|
+
clearTimeout(this.timer);
|
|
107
|
+
this.timer = null;
|
|
108
|
+
this.flush();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime-health-telemetry.js","sourceRoot":"","sources":["../../src/remote-device/realtime-health-telemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAmBxC,MAAM,QAAQ,GAA+B;IACzC,0BAA0B,EAAE,gBAAgB,EAAE,aAAa;IAC3D,eAAe,EAAE,eAAe,EAAE,oBAAoB;IACtD,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB;IAC/D,mBAAmB,EAAE,0BAA0B;CAClD,CAAC;AACF,MAAM,QAAQ,GAA+B;IACzC,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,oBAAoB;IACrE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B;CACxE,CAAC;AACF,MAAM,OAAO,uBAAuB;IAUhC,YACqB,IAAsC,EACtC,SAAkC,CAAC,GAAG,EAAE,EAAE,CACvD,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,WAAW,EACzE,SAAuB,IAAI,CAAC,MAAM;QAHlC,SAAI,GAAJ,IAAI,CAAkC;QACtC,WAAM,GAAN,M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AC,oBAAoB,GAAG,YAAY,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACzD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1C,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,UAAU;YAAE,OAAO,IAAI,CAAC;QAC9D,MAAM,MAAM,GAAmB;YAC3B,GAAG,MAAM;YACT,aAAa,EAAE,CAAC;YAChB,cAAc,EAAE,IAAI,CAAC,YAAY;YACjC,kBAAkB,EAAE,IAAI,CAAC,gBAAgB;YACzC,kBAAkB,EAAE,IAAI,CAAC,UAAU;YACnC,YAAY,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE;YAC3C,cAAc,EAAE,OAAO;YACvB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC7B,CAAC;QACF,IAAI,CAAC;YAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,2CAA2C,CAAC,CAAC;QAChF,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,IAAI;QACA,IAAI,IAAI,CAAC,KAAK;YAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -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
|
|
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,23 @@ interface DeviceData {
|
|
|
27
27
|
status: string;
|
|
28
28
|
last_seen: string;
|
|
29
29
|
}
|
|
30
|
-
|
|
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
|
-
/**
|
|
33
|
-
export declare function
|
|
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 {
|
|
42
|
+
private readonly enrollment?;
|
|
36
43
|
private client;
|
|
37
44
|
private channel;
|
|
38
45
|
private heartbeatInterval;
|
|
39
46
|
private connectionCheckInterval;
|
|
40
|
-
/** Device the heartbeat timer maintains; null = stopped, so re-arm is inert. */
|
|
41
|
-
private heartbeatDeviceId;
|
|
42
47
|
private statusWriteChain;
|
|
43
48
|
/**
|
|
44
49
|
* Answers whether the local execution child is alive. Default yes, so a
|
|
@@ -56,23 +61,35 @@ export declare class RemoteChannel {
|
|
|
56
61
|
/** Auth session gone for good: stops rejoins and caps the notice at one line. */
|
|
57
62
|
private sessionLost;
|
|
58
63
|
private handlingSignedOut;
|
|
64
|
+
private mqttReceiver;
|
|
65
|
+
private mqttReady;
|
|
66
|
+
private mqttCapabilityWriteChain;
|
|
67
|
+
private authGeneration;
|
|
59
68
|
private deviceId;
|
|
60
69
|
private deviceName;
|
|
61
70
|
private onToolCall;
|
|
62
71
|
private authListenerRegistered;
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
72
|
+
/** The current join's status write landed: dispatchable. Gates the
|
|
73
|
+
* heartbeat, so only that write first marks the row online. */
|
|
74
|
+
private channelReady;
|
|
75
|
+
/** Readiness write in flight. Cleared on every join, so each join writes its own. */
|
|
76
|
+
private readinessInFlight;
|
|
77
|
+
private consecutiveReadinessFailures;
|
|
78
|
+
private nextReadinessAttemptAt;
|
|
79
|
+
/** Presence published on the current join. Dashboard only; never gates dispatch. */
|
|
65
80
|
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
81
|
/** Re-entrancy guard: on a wedged socket each track() buffers for the full
|
|
74
82
|
* 10s push timeout, so 10s health ticks would stack pushes. */
|
|
75
83
|
private isTrackingPresence;
|
|
84
|
+
private consecutiveUnreadyJoins;
|
|
85
|
+
private consecutivePresenceFailures;
|
|
86
|
+
private nextPresenceAttemptAt;
|
|
87
|
+
/** performance.now() of the latest SUBSCRIBED; null while not joined. */
|
|
88
|
+
private joinedAt;
|
|
89
|
+
/** SDK channel and socket timers share reconnectAfterMs. The persistent
|
|
90
|
+
* unready-join budget prevents a series of partial successes restarting at 1s. */
|
|
91
|
+
private reconnectDelayMs;
|
|
92
|
+
private readonly realtimeHealth;
|
|
76
93
|
private lastDeviceStatus;
|
|
77
94
|
private lastChannelState;
|
|
78
95
|
private reconnectAttempt;
|
|
@@ -89,6 +106,9 @@ export declare class RemoteChannel {
|
|
|
89
106
|
private tokenRefreshInterval;
|
|
90
107
|
private _user;
|
|
91
108
|
get user(): User | null;
|
|
109
|
+
constructor(enrollment?: {
|
|
110
|
+
serverUrl: string;
|
|
111
|
+
} | undefined);
|
|
92
112
|
initialize(url: string, key: string): void;
|
|
93
113
|
/**
|
|
94
114
|
* Teach the channel how to ask whether the local executor is alive.
|
|
@@ -120,51 +140,64 @@ export declare class RemoteChannel {
|
|
|
120
140
|
};
|
|
121
141
|
error: any;
|
|
122
142
|
}>;
|
|
143
|
+
/**
|
|
144
|
+
* The session's current access token, for the realtime socket and the
|
|
145
|
+
* device's own requests. getSession() may refresh on-demand when the token
|
|
146
|
+
* reads expired — that check is clock-skew-safe now (see clockAwareFetch
|
|
147
|
+
* above). Without a session it falls back to the last token known, and
|
|
148
|
+
* without that it is null, never the anon key.
|
|
149
|
+
*/
|
|
150
|
+
getAccessToken(): Promise<string | null>;
|
|
123
151
|
findDevice(deviceId: string): Promise<{
|
|
124
152
|
id: any;
|
|
125
153
|
device_name: any;
|
|
126
154
|
} | null>;
|
|
127
155
|
updateDevice(deviceId: string, updates: any): Promise<{
|
|
128
156
|
data: any[] | null;
|
|
129
|
-
error: import("@supabase/
|
|
157
|
+
error: import("@supabase/supabase-js").PostgrestError | null;
|
|
130
158
|
}>;
|
|
131
159
|
createDevice(deviceData: DeviceData): Promise<{
|
|
132
160
|
data: any;
|
|
133
161
|
error: null;
|
|
134
162
|
}>;
|
|
135
163
|
registerDevice(capabilities: any, currentDeviceId: string | undefined, deviceName: string, onToolCall: (payload: any) => void): Promise<void>;
|
|
164
|
+
private startMqtt;
|
|
165
|
+
private prepareMqttConfig;
|
|
166
|
+
private startMqttTransport;
|
|
167
|
+
private stopMqttTransport;
|
|
168
|
+
private setMqttReady;
|
|
169
|
+
/** MQTT delivery hook; this branch records receipts without executing calls. */
|
|
170
|
+
private onMqttDoorbell;
|
|
171
|
+
private onBroadcastDoorbell;
|
|
136
172
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
173
|
+
* Mark this join dispatchable by writing `status`. The write has to land —
|
|
174
|
+
* Supabase reports a refused write in the result rather than by throwing.
|
|
175
|
+
* The health check retries on its own cooldown.
|
|
140
176
|
*/
|
|
141
|
-
private
|
|
142
|
-
private
|
|
177
|
+
private markChannelReady;
|
|
178
|
+
private markChannelReadyInner;
|
|
143
179
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
180
|
+
* Publish presence for the dashboard. Best effort: one track() per call,
|
|
181
|
+
* no effect on readiness, and a growing cooldown after each failure — a
|
|
182
|
+
* track() timeout on the server can end the whole channel, and every
|
|
183
|
+
* rejoin would otherwise publish again.
|
|
146
184
|
*/
|
|
147
|
-
private
|
|
185
|
+
private trackPresence;
|
|
186
|
+
/** Presence is withheld by its cooldown right now. Monotonic, so a Date.now
|
|
187
|
+
* skew correction cannot shorten or extend it. */
|
|
188
|
+
private presenceInCooldown;
|
|
148
189
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
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.
|
|
190
|
+
* The complete `capabilities` JSONB value. The write replaces the whole
|
|
191
|
+
* column, so a key left out here is dropped from the row.
|
|
158
192
|
*/
|
|
159
|
-
private
|
|
160
|
-
private writeTransportCapable;
|
|
193
|
+
private capabilitiesPayload;
|
|
161
194
|
/** Aborts one write to this device's row after DEVICE_ROW_WRITE_TIMEOUT_MS (a method, so tests can shorten it). */
|
|
162
195
|
private deviceRowWriteSignal;
|
|
163
196
|
/** Create and subscribe the private channel (initial join and recreation). */
|
|
164
197
|
private createChannel;
|
|
165
198
|
/**
|
|
166
|
-
* Recover calls whose
|
|
167
|
-
* disconnected.
|
|
199
|
+
* Recover calls whose doorbell was missed while this device was
|
|
200
|
+
* disconnected. Notifications provide the fast path; the DB row is the source
|
|
168
201
|
* of truth. Only still-live pending rows for this device are considered.
|
|
169
202
|
*
|
|
170
203
|
* The follow-up onDoorbell() call performs the existing conditional claim,
|
|
@@ -212,18 +245,21 @@ export declare class RemoteChannel {
|
|
|
212
245
|
* Claim a call. True only when THIS update flipped the row pending ->
|
|
213
246
|
* executing, which is what makes dual delivery safe across processes.
|
|
214
247
|
* .eq('status','pending') makes it conditional; .select('id') makes the
|
|
215
|
-
* result observable.
|
|
216
|
-
*
|
|
248
|
+
* result observable. Expiry is checked using Postgres time, not the
|
|
249
|
+
* device clock. On a transient DB error it returns true (execute anyway),
|
|
250
|
+
* matching prior behaviour — so device.ts's in-memory guard is what
|
|
217
251
|
* actually guarantees exactly-once within a process.
|
|
218
252
|
*/
|
|
219
253
|
markCallExecuting(callId: string): Promise<boolean>;
|
|
220
|
-
updateCallResult(callId: string, status: string, result?: any, errorMessage?: string | null): Promise<void>;
|
|
254
|
+
updateCallResult(callId: string, status: string, result?: any, errorMessage?: string | null, originInstance?: string): Promise<void>;
|
|
255
|
+
private publishMqttResult;
|
|
221
256
|
/**
|
|
222
257
|
* Reachable means all of it is true at once: the private channel is
|
|
223
|
-
* joined,
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
258
|
+
* joined, the join's status write landed, and the local executor answers.
|
|
259
|
+
* The server needs the first two before it will dispatch, and a healthy
|
|
260
|
+
* channel on a device whose executor is dead is the false-online state
|
|
261
|
+
* issue #4 was opened for. Presence is not part of it. Gates the heartbeat
|
|
262
|
+
* and `status`.
|
|
227
263
|
*/
|
|
228
264
|
private isReachable;
|
|
229
265
|
/**
|
|
@@ -239,28 +275,20 @@ export declare class RemoteChannel {
|
|
|
239
275
|
/** Resolves with whether the row actually took the write. */
|
|
240
276
|
syncReachabilityStatus(): Promise<boolean>;
|
|
241
277
|
/**
|
|
242
|
-
* Serialize the
|
|
243
|
-
* callbacks, and inside recreateChannel() a teardown's 'offline'
|
|
244
|
-
* fresh join's 'online' land ~100-300ms apart — unordered, 'offline'
|
|
245
|
-
* and leave a healthy device undispatchable until the next heartbeat.
|
|
278
|
+
* Serialize the status writes, the heartbeat's included. They fire from
|
|
279
|
+
* un-awaited callbacks, and inside recreateChannel() a teardown's 'offline'
|
|
280
|
+
* and the fresh join's 'online' land ~100-300ms apart — unordered, 'offline'
|
|
281
|
+
* can win and leave a healthy device undispatchable until the next heartbeat.
|
|
246
282
|
*
|
|
247
|
-
* Not the single writer:
|
|
248
|
-
*
|
|
283
|
+
* Not the single writer: registerDevice and setOffline's subprocess write
|
|
284
|
+
* status directly, so this is not total ordering.
|
|
249
285
|
*/
|
|
250
286
|
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>;
|
|
287
|
+
updateHeartbeat(): Promise<void>;
|
|
258
288
|
startHeartbeat(deviceId: string): void;
|
|
259
289
|
private refreshTokenNow;
|
|
260
290
|
private startTokenRefresh;
|
|
261
291
|
private stopTokenRefresh;
|
|
262
|
-
/** Arm (or re-arm) the last_seen timer at the current tier's cadence. */
|
|
263
|
-
private scheduleHeartbeat;
|
|
264
292
|
stopHeartbeat(): void;
|
|
265
293
|
/** @returns whether the row actually took the write. */
|
|
266
294
|
setOnlineStatus(deviceId: string, status: 'online' | 'offline'): Promise<boolean>;
|