@mycadet/gateway 0.12.10 → 0.13.0

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 (85) hide show
  1. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/__tests__/ingress.test.ts +10 -10
  2. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/ingress.ts +3 -3
  3. package/node_modules/@mycadet/ces-client/src/http-credentials.ts +18 -1
  4. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/__tests__/ingress.test.ts +10 -10
  5. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/ingress.ts +3 -3
  6. package/node_modules/@mycadet/gateway-client/src/gateway-ipc-contracts.ts +0 -20
  7. package/node_modules/@mycadet/service-contracts/src/__tests__/ingress.test.ts +10 -10
  8. package/node_modules/@mycadet/service-contracts/src/ingress.ts +3 -3
  9. package/openapi.json +1 -1
  10. package/package.json +1 -1
  11. package/src/__tests__/actor-token-revocation.test.ts +41 -34
  12. package/src/__tests__/contact-store-mirror-op-missing.test.ts +33 -70
  13. package/src/__tests__/contacts-mirror-op-reporter.test.ts +33 -89
  14. package/src/__tests__/credential-requests.test.ts +4 -4
  15. package/src/__tests__/devices-mine.test.ts +187 -0
  16. package/src/__tests__/edge-auth.test.ts +1 -20
  17. package/src/__tests__/edge-guardian-auth.test.ts +1 -17
  18. package/src/__tests__/feature-flag-resolver.test.ts +2 -30
  19. package/src/__tests__/feature-flag-watcher-callback.test.ts +0 -22
  20. package/src/__tests__/feature-flags-route.test.ts +2 -191
  21. package/src/__tests__/guardian-bootstrap-lookups.test.ts +22 -29
  22. package/src/__tests__/guardian-init-lockfile.test.ts +2 -2
  23. package/src/__tests__/guardian-integrity-reporter.test.ts +51 -82
  24. package/src/__tests__/guardian-integrity.test.ts +16 -20
  25. package/src/__tests__/handle-inbound-trust-verdict.test.ts +1 -14
  26. package/src/__tests__/ipc-feature-flag-routes.test.ts +0 -56
  27. package/src/__tests__/lum-2783-recovery-e2e.test.ts +0 -12
  28. package/src/__tests__/post-assistant-ready-deferred.test.ts +0 -18
  29. package/src/__tests__/refresh-device-binding.test.ts +0 -12
  30. package/src/__tests__/remote-web-pairing-token.test.ts +5 -15
  31. package/src/__tests__/runtime-client.test.ts +7 -7
  32. package/src/__tests__/speech-relay-websocket.test.ts +4 -4
  33. package/src/__tests__/trust-verdict-resolver-guardian-integrity.test.ts +30 -36
  34. package/src/__tests__/twilio-webhooks.test.ts +2 -2
  35. package/src/auth/actor-token-revocation.ts +34 -9
  36. package/src/auth/guardian-bootstrap.ts +1 -1
  37. package/src/cli/__tests__/pairing.test.ts +95 -0
  38. package/src/cli/index.ts +1 -1
  39. package/src/cli/pairing.ts +81 -6
  40. package/src/contacts-mirror-op-reporter.ts +19 -36
  41. package/src/db/connection.ts +0 -10
  42. package/src/feature-flag-resolver.ts +2 -7
  43. package/src/feature-flag-watcher.ts +1 -14
  44. package/src/guardian-integrity-reporter.ts +19 -47
  45. package/src/http/middleware/auth.ts +33 -27
  46. package/src/http/routes/auth-token.ts +1 -1
  47. package/src/http/routes/devices-mine.ts +103 -0
  48. package/src/http/routes/feature-flags.ts +1 -8
  49. package/src/http/routes/guardian-pin.ts +2 -11
  50. package/src/http/routes/ipc-runtime-proxy.ts +1 -1
  51. package/src/http/routes/live-voice-websocket.ts +1 -1
  52. package/src/http/routes/runtime-audio-stream.ts +1 -1
  53. package/src/http/routes/runtime-proxy.ts +2 -2
  54. package/src/http/routes/speech-relay-websocket.ts +2 -2
  55. package/src/http/routes/twilio-voice-webhook.test.ts +13 -13
  56. package/src/index.ts +11 -198
  57. package/src/ipc/feature-flag-handlers.ts +2 -9
  58. package/src/remote-web/pairing-challenge-store.ts +15 -0
  59. package/src/risk/command-registry/commands/assistant.ts +0 -24
  60. package/src/risk/command-registry.test.ts +2 -4
  61. package/src/schema.ts +44 -372
  62. package/src/__tests__/auth-fallback-count-tracker.test.ts +0 -92
  63. package/src/__tests__/auth-fallback-reporter.test.ts +0 -101
  64. package/src/__tests__/backup-worker-cloud-mode.test.ts +0 -44
  65. package/src/__tests__/backup-worker-export-timeout.test.ts +0 -164
  66. package/src/__tests__/migration-teleport-gcs-proxy.test.ts +0 -216
  67. package/src/__tests__/remote-feature-flag-sync.test.ts +0 -961
  68. package/src/auth-fallback-count-tracker.ts +0 -113
  69. package/src/auth-fallback-reporter.ts +0 -127
  70. package/src/backup/backup-key.ts +0 -138
  71. package/src/backup/backup-routes.ts +0 -161
  72. package/src/backup/backup-worker.ts +0 -425
  73. package/src/backup/list-snapshots.ts +0 -97
  74. package/src/backup/local-writer.ts +0 -87
  75. package/src/backup/offsite-writer.ts +0 -182
  76. package/src/backup/paths.ts +0 -113
  77. package/src/backup/stream-crypt.ts +0 -258
  78. package/src/device-id.ts +0 -18
  79. package/src/feature-flag-remote-store.ts +0 -166
  80. package/src/http/routes/migration-proxy.ts +0 -636
  81. package/src/internal-telemetry-client.ts +0 -39
  82. package/src/ipc/debug-export-handlers.test.ts +0 -102
  83. package/src/ipc/debug-export-handlers.ts +0 -81
  84. package/src/remote-feature-flag-sync.ts +0 -440
  85. package/src/watchdog-reporter.ts +0 -110
@@ -1,110 +0,0 @@
1
- // Shared scaffolding for fail-loud watchdog reporters: per-key hourly rate
2
- // limiting, an error-level log, and a fire-and-forget relay to the daemon's
3
- // internal watchdog telemetry route. Best-effort — never throws, never blocks
4
- // the caller, and a lost event is acceptable for rare, high-signal checks (no
5
- // retry). Each reporter module owns its check names, message copy, and detail
6
- // shaping; this factory owns the state and transport posture.
7
-
8
- import { loadConfig } from "./config.js";
9
- import type { fetchImpl } from "./fetch.js";
10
- import { postInternalTelemetry } from "./internal-telemetry-client.js";
11
-
12
- const ROUTE_PATH = "/v1/internal/telemetry/watchdog";
13
- const REPORT_INTERVAL_MS = 60 * 60 * 1000;
14
-
15
- export type ReporterLog = {
16
- error: (detail: Record<string, unknown>, msg: string) => void;
17
- warn: (detail: Record<string, unknown>, msg: string) => void;
18
- };
19
-
20
- export type ReporterOverrides = {
21
- fetchImpl?: typeof fetchImpl;
22
- mintToken?: () => string;
23
- baseUrl?: string;
24
- log?: ReporterLog;
25
- };
26
-
27
- export type WatchdogReport = {
28
- /** Rate-limit key: at most one report per key per hour per process. */
29
- key: string;
30
- /** Watchdog `check_name` — the cross-repo platform-dashboard contract. */
31
- checkName: string;
32
- /** Error-log message. */
33
- message: string;
34
- /** Logged with the error and sent as the relay body's `detail`. */
35
- detail: Record<string, unknown>;
36
- /** Merged into the non-fatal relay warn logs. */
37
- warnContext: Record<string, unknown>;
38
- };
39
-
40
- export type WatchdogReporter = {
41
- report: (args: WatchdogReport) => void;
42
- /**
43
- * Test-only: inject fetch/token/baseUrl/log so tests never touch the
44
- * network or the process logger.
45
- */
46
- setOverridesForTesting: (next: ReporterOverrides) => void;
47
- /** Test-only: clear overrides and the rate-limit windows. */
48
- resetForTesting: () => void;
49
- /** Test-only: await the most recent fire-and-forget relay. */
50
- flushForTesting: () => Promise<unknown>;
51
- };
52
-
53
- export function createWatchdogReporter(config: {
54
- log: ReporterLog;
55
- relayFailedMessage: string;
56
- relayRejectedMessage: string;
57
- }): WatchdogReporter {
58
- let overrides: ReporterOverrides = {};
59
- const lastReportAtByKey = new Map<string, number>();
60
- let pendingRelay: Promise<unknown> = Promise.resolve();
61
-
62
- const reporterLog = (): ReporterLog => overrides.log ?? config.log;
63
-
64
- async function relayToDaemon(args: WatchdogReport): Promise<void> {
65
- const resp = await postInternalTelemetry({
66
- baseUrl: overrides.baseUrl ?? loadConfig().assistantRuntimeBaseUrl,
67
- path: ROUTE_PATH,
68
- body: { check_name: args.checkName, detail: args.detail },
69
- fetchImpl: overrides.fetchImpl,
70
- mintToken: overrides.mintToken,
71
- });
72
- if (!resp.ok) {
73
- reporterLog().warn(
74
- { status: resp.status, ...args.warnContext },
75
- config.relayRejectedMessage,
76
- );
77
- }
78
- }
79
-
80
- return {
81
- report(args: WatchdogReport): void {
82
- const now = Date.now();
83
- const last = lastReportAtByKey.get(args.key) ?? Number.NEGATIVE_INFINITY;
84
- if (now - last < REPORT_INTERVAL_MS) {
85
- return;
86
- }
87
- lastReportAtByKey.set(args.key, now);
88
-
89
- reporterLog().error(args.detail, args.message);
90
-
91
- pendingRelay = relayToDaemon(args).catch((err) => {
92
- reporterLog().warn(
93
- { err, ...args.warnContext },
94
- config.relayFailedMessage,
95
- );
96
- });
97
- },
98
- setOverridesForTesting(next: ReporterOverrides): void {
99
- overrides = next;
100
- },
101
- resetForTesting(): void {
102
- overrides = {};
103
- lastReportAtByKey.clear();
104
- pendingRelay = Promise.resolve();
105
- },
106
- flushForTesting(): Promise<unknown> {
107
- return pendingRelay;
108
- },
109
- };
110
- }