@agentdeck/bridge 1.1.0 → 1.2.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 (199) hide show
  1. package/README.md +14 -6
  2. package/assets/fonts/NOTICE-PocketSansWorld.md +10 -0
  3. package/assets/fonts/OFL-PocketSansWorld.txt +93 -0
  4. package/assets/fonts/PocketSansWorld_12.cpfont +0 -0
  5. package/assets/fonts/pocket-sans-world.manifest.json +49 -0
  6. package/assets/learning/LICENSE-CC-BY-SA-4.0.txt +10 -0
  7. package/assets/learning/NOTICE.md +33 -0
  8. package/assets/learning/jp-n3-ko.manifest.json +27 -0
  9. package/assets/learning/jp-n3-ko.pdl +0 -0
  10. package/dist/agent-cli-diagnostics.d.ts +20 -0
  11. package/dist/agent-cli-diagnostics.d.ts.map +1 -0
  12. package/dist/agent-cli-diagnostics.js +100 -0
  13. package/dist/agent-cli-diagnostics.js.map +1 -0
  14. package/dist/apme/classifier.d.ts.map +1 -1
  15. package/dist/apme/classifier.js +18 -10
  16. package/dist/apme/classifier.js.map +1 -1
  17. package/dist/apme/claude-transcript-reader.d.ts +36 -0
  18. package/dist/apme/claude-transcript-reader.d.ts.map +1 -1
  19. package/dist/apme/claude-transcript-reader.js +78 -2
  20. package/dist/apme/claude-transcript-reader.js.map +1 -1
  21. package/dist/apme/collector.d.ts +126 -3
  22. package/dist/apme/collector.d.ts.map +1 -1
  23. package/dist/apme/collector.js +450 -41
  24. package/dist/apme/collector.js.map +1 -1
  25. package/dist/apme/dashboard-html.d.ts.map +1 -1
  26. package/dist/apme/dashboard-html.js +278 -36
  27. package/dist/apme/dashboard-html.js.map +1 -1
  28. package/dist/apme/graph.d.ts +1 -1
  29. package/dist/apme/graph.d.ts.map +1 -1
  30. package/dist/apme/graph.js +51 -1
  31. package/dist/apme/graph.js.map +1 -1
  32. package/dist/apme/http.d.ts.map +1 -1
  33. package/dist/apme/http.js +37 -5
  34. package/dist/apme/http.js.map +1 -1
  35. package/dist/apme/index.d.ts +4 -0
  36. package/dist/apme/index.d.ts.map +1 -1
  37. package/dist/apme/index.js +19 -3
  38. package/dist/apme/index.js.map +1 -1
  39. package/dist/apme/runner.d.ts +90 -0
  40. package/dist/apme/runner.d.ts.map +1 -1
  41. package/dist/apme/runner.js +524 -48
  42. package/dist/apme/runner.js.map +1 -1
  43. package/dist/apme/sample-to-timeline.d.ts.map +1 -1
  44. package/dist/apme/sample-to-timeline.js +5 -0
  45. package/dist/apme/sample-to-timeline.js.map +1 -1
  46. package/dist/apme/settings.d.ts +8 -0
  47. package/dist/apme/settings.d.ts.map +1 -1
  48. package/dist/apme/settings.js +4 -0
  49. package/dist/apme/settings.js.map +1 -1
  50. package/dist/apme/store.d.ts +118 -9
  51. package/dist/apme/store.d.ts.map +1 -1
  52. package/dist/apme/store.js +342 -44
  53. package/dist/apme/store.js.map +1 -1
  54. package/dist/apme/task-gradeability.d.ts +82 -0
  55. package/dist/apme/task-gradeability.d.ts.map +1 -0
  56. package/dist/apme/task-gradeability.js +126 -0
  57. package/dist/apme/task-gradeability.js.map +1 -0
  58. package/dist/awaiting-overlay.d.ts +13 -26
  59. package/dist/awaiting-overlay.d.ts.map +1 -1
  60. package/dist/awaiting-overlay.js +7 -40
  61. package/dist/awaiting-overlay.js.map +1 -1
  62. package/dist/bridge-core.d.ts +15 -0
  63. package/dist/bridge-core.d.ts.map +1 -1
  64. package/dist/bridge-core.js +30 -4
  65. package/dist/bridge-core.js.map +1 -1
  66. package/dist/claude-permission-rules.d.ts +20 -32
  67. package/dist/claude-permission-rules.d.ts.map +1 -1
  68. package/dist/claude-permission-rules.js +19 -102
  69. package/dist/claude-permission-rules.js.map +1 -1
  70. package/dist/claude-usage-recovery.d.ts +54 -0
  71. package/dist/claude-usage-recovery.d.ts.map +1 -0
  72. package/dist/claude-usage-recovery.js +200 -0
  73. package/dist/claude-usage-recovery.js.map +1 -0
  74. package/dist/cli.d.ts +11 -0
  75. package/dist/cli.d.ts.map +1 -1
  76. package/dist/cli.js +81 -14
  77. package/dist/cli.js.map +1 -1
  78. package/dist/codex-rate-limits-live.d.ts +180 -10
  79. package/dist/codex-rate-limits-live.d.ts.map +1 -1
  80. package/dist/codex-rate-limits-live.js +475 -22
  81. package/dist/codex-rate-limits-live.js.map +1 -1
  82. package/dist/codex-rollout-response.d.ts +43 -0
  83. package/dist/codex-rollout-response.d.ts.map +1 -1
  84. package/dist/codex-rollout-response.js +67 -0
  85. package/dist/codex-rollout-response.js.map +1 -1
  86. package/dist/coordination-evidence.d.ts +150 -0
  87. package/dist/coordination-evidence.d.ts.map +1 -0
  88. package/dist/coordination-evidence.js +455 -0
  89. package/dist/coordination-evidence.js.map +1 -0
  90. package/dist/daemon-server.d.ts.map +1 -1
  91. package/dist/daemon-server.js +592 -35
  92. package/dist/daemon-server.js.map +1 -1
  93. package/dist/daemon-ws-client.d.ts +1 -0
  94. package/dist/daemon-ws-client.d.ts.map +1 -1
  95. package/dist/daemon-ws-client.js +25 -16
  96. package/dist/daemon-ws-client.js.map +1 -1
  97. package/dist/daemon.js +1 -1
  98. package/dist/deferred-reply-read.d.ts +24 -0
  99. package/dist/deferred-reply-read.d.ts.map +1 -0
  100. package/dist/deferred-reply-read.js +42 -0
  101. package/dist/deferred-reply-read.js.map +1 -0
  102. package/dist/esp32-serial.d.ts +15 -0
  103. package/dist/esp32-serial.d.ts.map +1 -1
  104. package/dist/esp32-serial.js +61 -2
  105. package/dist/esp32-serial.js.map +1 -1
  106. package/dist/font-pack.d.ts +15 -0
  107. package/dist/font-pack.d.ts.map +1 -0
  108. package/dist/font-pack.js +75 -0
  109. package/dist/font-pack.js.map +1 -0
  110. package/dist/glance-frame.d.ts.map +1 -1
  111. package/dist/glance-frame.js +2 -0
  112. package/dist/glance-frame.js.map +1 -1
  113. package/dist/hook-codex-sessions.d.ts +9 -0
  114. package/dist/hook-codex-sessions.d.ts.map +1 -1
  115. package/dist/hook-codex-sessions.js +35 -2
  116. package/dist/hook-codex-sessions.js.map +1 -1
  117. package/dist/hook-opencode-sessions.d.ts +62 -0
  118. package/dist/hook-opencode-sessions.d.ts.map +1 -0
  119. package/dist/hook-opencode-sessions.js +180 -0
  120. package/dist/hook-opencode-sessions.js.map +1 -0
  121. package/dist/hook-response-source.d.ts +40 -0
  122. package/dist/hook-response-source.d.ts.map +1 -0
  123. package/dist/hook-response-source.js +31 -0
  124. package/dist/hook-response-source.js.map +1 -0
  125. package/dist/http-auth-gate.d.ts.map +1 -1
  126. package/dist/http-auth-gate.js +9 -1
  127. package/dist/http-auth-gate.js.map +1 -1
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +6 -3
  130. package/dist/index.js.map +1 -1
  131. package/dist/learning-pack.d.ts +24 -0
  132. package/dist/learning-pack.d.ts.map +1 -0
  133. package/dist/learning-pack.js +125 -0
  134. package/dist/learning-pack.js.map +1 -0
  135. package/dist/mdns.js +1 -1
  136. package/dist/mdns.js.map +1 -1
  137. package/dist/native-dependency-diagnostics.d.ts +29 -0
  138. package/dist/native-dependency-diagnostics.d.ts.map +1 -0
  139. package/dist/native-dependency-diagnostics.js +95 -0
  140. package/dist/native-dependency-diagnostics.js.map +1 -0
  141. package/dist/observed-steering.d.ts +4 -4
  142. package/dist/observed-steering.d.ts.map +1 -1
  143. package/dist/observed-steering.js +28 -32
  144. package/dist/observed-steering.js.map +1 -1
  145. package/dist/openclaw-gateway-stability.d.ts +94 -0
  146. package/dist/openclaw-gateway-stability.d.ts.map +1 -0
  147. package/dist/openclaw-gateway-stability.js +176 -0
  148. package/dist/openclaw-gateway-stability.js.map +1 -0
  149. package/dist/pairing-knocks.d.ts +80 -0
  150. package/dist/pairing-knocks.d.ts.map +1 -0
  151. package/dist/pairing-knocks.js +312 -0
  152. package/dist/pairing-knocks.js.map +1 -0
  153. package/dist/passive-observer.d.ts +5 -0
  154. package/dist/passive-observer.d.ts.map +1 -1
  155. package/dist/passive-observer.js +6 -0
  156. package/dist/passive-observer.js.map +1 -1
  157. package/dist/pixoo/micro-glyphs.d.ts +4 -0
  158. package/dist/pixoo/micro-glyphs.d.ts.map +1 -1
  159. package/dist/pixoo/micro-glyphs.js +29 -0
  160. package/dist/pixoo/micro-glyphs.js.map +1 -1
  161. package/dist/pixoo/pixoo-font.d.ts.map +1 -1
  162. package/dist/pixoo/pixoo-font.js +3 -1
  163. package/dist/pixoo/pixoo-font.js.map +1 -1
  164. package/dist/pixoo/pixoo-renderer.d.ts +1 -1
  165. package/dist/pixoo/pixoo-renderer.d.ts.map +1 -1
  166. package/dist/pixoo/pixoo-renderer.js +17 -2
  167. package/dist/pixoo/pixoo-renderer.js.map +1 -1
  168. package/dist/pty-manager.d.ts +9 -0
  169. package/dist/pty-manager.d.ts.map +1 -1
  170. package/dist/pty-manager.js +63 -4
  171. package/dist/pty-manager.js.map +1 -1
  172. package/dist/relayed-usage.d.ts +30 -0
  173. package/dist/relayed-usage.d.ts.map +1 -1
  174. package/dist/relayed-usage.js +25 -2
  175. package/dist/relayed-usage.js.map +1 -1
  176. package/dist/review-runner.js +1 -1
  177. package/dist/subagent-timeline.d.ts +27 -0
  178. package/dist/subagent-timeline.d.ts.map +1 -1
  179. package/dist/subagent-timeline.js +52 -5
  180. package/dist/subagent-timeline.js.map +1 -1
  181. package/dist/surface-protocol.d.ts.map +1 -1
  182. package/dist/surface-protocol.js +2 -0
  183. package/dist/surface-protocol.js.map +1 -1
  184. package/dist/tui/dashboard.d.ts.map +1 -1
  185. package/dist/tui/dashboard.js +8 -1
  186. package/dist/tui/dashboard.js.map +1 -1
  187. package/dist/usage-api.d.ts +3 -0
  188. package/dist/usage-api.d.ts.map +1 -1
  189. package/dist/usage-api.js +101 -36
  190. package/dist/usage-api.js.map +1 -1
  191. package/dist/usage-event.d.ts.map +1 -1
  192. package/dist/usage-event.js +2 -1
  193. package/dist/usage-event.js.map +1 -1
  194. package/dist/ws-server.d.ts +18 -0
  195. package/dist/ws-server.d.ts.map +1 -1
  196. package/dist/ws-server.js +40 -2
  197. package/dist/ws-server.js.map +1 -1
  198. package/package.json +6 -5
  199. package/src/timebox/sync_ble.py +35 -16
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-dependency-diagnostics.js","sourceRoot":"","sources":["../src/native-dependency-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAU,CAAC;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAoC5D,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAQ,qBAA2C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,OAAqC,EAAE;IAEvC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IACnD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9E,MAAM,OAAO,GAA4B;QACvC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,OAAO,CAAC,QAAQ;QACxD,IAAI;QACJ,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO;QAChE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,IAAI,OA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C,IAAI,CAAC,aAAa,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -23,9 +23,8 @@
23
23
  * Keyed by the Claude session UUID (same key as awaiting-overlay.ts). Lives
24
24
  * outside the state machine for the same reason: per-session attribution.
25
25
  */
26
- /** Bash signature = first two command tokens (the granularity of Claude's own
27
- * "always allow `git push`"-style session approvals); other tools = tool name. */
28
- export declare function gateSignature(tool: string, toolInput: Record<string, unknown> | undefined): string;
26
+ import { gateSignature } from '@agentdeck/shared';
27
+ export { gateSignature };
29
28
  /** Human-readable question for the gate's awaiting overlay — device-native
30
29
  * semantics ("Allow Bash: git push …?"), never a fabricated mirror of the
31
30
  * TUI prompt's option labels. Overlay caps length at 120 chars. */
@@ -124,6 +123,7 @@ export declare function gateReleased(sid: string, requestId: string, opts: {
124
123
  undecided: boolean;
125
124
  tool: string;
126
125
  toolInput?: Record<string, unknown>;
126
+ toolUseId?: string;
127
127
  }): void;
128
128
  /** A permission_prompt Notification arrived — every recent undecided release
129
129
  * was a GENUINE prompt, so nothing should be learned as auto-approved. */
@@ -134,7 +134,7 @@ export declare function notePermissionPromptShown(sid: string): void;
134
134
  * (session-scoped "always allow" we cannot read) — suppress the signature so
135
135
  * it is never held again this session.
136
136
  */
137
- export declare function noteToolEnd(sid: string, tool: string | undefined): void;
137
+ export declare function noteToolEnd(sid: string, tool: string | undefined, toolUseId?: string): void;
138
138
  /** Enrichment snapshot for sessions_list (devices render STOPPING / queue badges). */
139
139
  export declare function steeringSnapshot(sid: string): {
140
140
  stopRequested: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"observed-steering.d.ts","sourceRoot":"","sources":["../src/observed-steering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA4CH;mFACmF;AACnF,wBAAgB,aAAa,CAAC,IAAI,EAAE,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AS,CAAC,EAAE,MAAM,CAAA;CAAE,GAClG,IAAI,CAaN;AAED;2EAC2E;AAC3E,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAG3D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAqB3F;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,aAAa,EAAE,OAAO,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAKlG;AAED,mBAAmB;AACnB,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
@@ -24,17 +24,20 @@
24
24
  * outside the state machine for the same reason: per-session attribution.
25
25
  */
26
26
  import { randomUUID } from 'crypto';
27
- import { evaluatePermissionRules, isNeverPromptTool, isPromptProneTool, } from './claude-permission-rules.js';
28
- import { shouldGatePreToolUse } from './awaiting-overlay.js';
27
+ import { GATE_LEARN_WINDOW_MS, gateSignature, predictPreToolUseHold, } from '@agentdeck/shared';
28
+ import { loadMergedPermissionRules } from './claude-permission-rules.js';
29
29
  import { debug } from './logger.js';
30
+ export { gateSignature };
30
31
  const STOP_FLAG_TTL_MS = 10 * 60_000; // stale STOP must not deny a tool an hour later
31
32
  const DIRECTIVE_TTL_MS = 60 * 60_000;
32
33
  const DIRECTIVE_QUEUE_CAP = 3;
33
34
  /** After a hold releases undecided, how long we correlate PostToolUse-without-
34
35
  * Notification to learn "this signature was auto-approved" (session
35
36
  * "always allow" answers live only in Claude's memory — this is the only way
36
- * to see them). */
37
- const ASK_RELEASE_LEARN_WINDOW_MS = 8_000;
37
+ * to see them). SSOT in @agentdeck/shared: a `permission_prompt`
38
+ * Notification clears the pending release, so this bounds only how slow the
39
+ * TOOL may be — and 8 s was shorter than a routine `curl`. */
40
+ const ASK_RELEASE_LEARN_WINDOW_MS = GATE_LEARN_WINDOW_MS;
38
41
  const sessions = new Map();
39
42
  function ses(sid) {
40
43
  let s = sessions.get(sid);
@@ -44,15 +47,6 @@ function ses(sid) {
44
47
  }
45
48
  return s;
46
49
  }
47
- /** Bash signature = first two command tokens (the granularity of Claude's own
48
- * "always allow `git push`"-style session approvals); other tools = tool name. */
49
- export function gateSignature(tool, toolInput) {
50
- if (tool === 'Bash' && typeof toolInput?.command === 'string') {
51
- const head = toolInput.command.trim().split(/\s+/).slice(0, 2).join(' ');
52
- return `Bash|${head}`;
53
- }
54
- return tool;
55
- }
56
50
  /** Human-readable question for the gate's awaiting overlay — device-native
57
51
  * semantics ("Allow Bash: git push …?"), never a fabricated mirror of the
58
52
  * TUI prompt's option labels. Overlay caps length at 120 chars. */
@@ -199,31 +193,26 @@ export function shouldHoldPreToolUse(ctx) {
199
193
  return { hold: false, reason: 'no clients' };
200
194
  if (!ctx.tool)
201
195
  return { hold: false, reason: 'no tool name' };
202
- if (ctx.tool.startsWith('mcp__'))
203
- return { hold: false, reason: 'mcp tool (trust state unknown)' };
204
- if (isNeverPromptTool(ctx.tool))
205
- return { hold: false, reason: 'never-prompt tool' };
206
- if (!isPromptProneTool(ctx.tool))
207
- return { hold: false, reason: 'not prompt-prone' };
208
- if (!shouldGatePreToolUse(ctx.permissionMode, ctx.tool)) {
209
- return { hold: false, reason: `permission_mode=${ctx.permissionMode ?? 'default'} auto-approves` };
210
- }
211
196
  const s = ses(ctx.sessionId);
212
197
  const signature = gateSignature(ctx.tool, ctx.toolInput);
213
198
  if (s.suppressed.has(signature))
214
199
  return { hold: false, reason: 'signature learned auto-approved' };
215
200
  if (s.heldRequestId)
216
201
  return { hold: false, reason: 'another gate already held' };
217
- const verdict = evaluatePermissionRules(ctx.tool, ctx.toolInput, ctx.cwd);
218
- if (verdict === 'unknown')
219
- return { hold: false, reason: 'settings unreadable' };
220
- if (verdict === 'deny')
221
- return { hold: false, reason: 'deny rule may match' };
222
- if (verdict === 'allow')
223
- return { hold: false, reason: 'allow rule may match' };
202
+ // The stateless prediction (tool sets, mode gate, allow/deny/ask rules,
203
+ // built-in read-only and acceptEdits auto-approvals) is the shared SSOT the
204
+ // Swift daemon runs as generated code — one decision, two daemons.
205
+ const prediction = predictPreToolUseHold({
206
+ tool: ctx.tool,
207
+ toolInput: ctx.toolInput,
208
+ permissionMode: ctx.permissionMode,
209
+ rules: loadMergedPermissionRules(ctx.cwd),
210
+ });
211
+ if (!prediction.hold)
212
+ return { hold: false, reason: prediction.reason };
224
213
  const requestId = randomUUID();
225
214
  s.heldRequestId = requestId;
226
- return { hold: true, requestId, reason: verdict === 'ask' ? 'ask rule matches' : 'prompt-prone, no rule match' };
215
+ return { hold: true, requestId, reason: prediction.reason };
227
216
  }
228
217
  /**
229
218
  * Register a hold for an AskUserQuestion PreToolUse so a device can answer it.
@@ -267,6 +256,7 @@ export function gateReleased(sid, requestId, opts) {
267
256
  tool: opts.tool,
268
257
  signature: gateSignature(opts.tool, opts.toolInput),
269
258
  ts: Date.now(),
259
+ toolUseId: opts.toolUseId,
270
260
  });
271
261
  if (s.recentAskReleases.length > 8)
272
262
  s.recentAskReleases.shift();
@@ -285,7 +275,7 @@ export function notePermissionPromptShown(sid) {
285
275
  * (session-scoped "always allow" we cannot read) — suppress the signature so
286
276
  * it is never held again this session.
287
277
  */
288
- export function noteToolEnd(sid, tool) {
278
+ export function noteToolEnd(sid, tool, toolUseId) {
289
279
  const s = sessions.get(sid);
290
280
  if (!s || !tool || s.recentAskReleases.length === 0)
291
281
  return;
@@ -294,7 +284,13 @@ export function noteToolEnd(sid, tool) {
294
284
  for (const r of s.recentAskReleases) {
295
285
  if (now - r.ts > ASK_RELEASE_LEARN_WINDOW_MS)
296
286
  continue; // expired
297
- if (r.tool === tool) {
287
+ // The held call and its PostToolUse share a `tool_use_id`, so a release
288
+ // that recorded one learns ONLY from its own completion — a parallel
289
+ // allowlisted Bash finishing inside the window must not teach the held
290
+ // signature (the window is 15 min now, wide enough for that to happen).
291
+ // Releases without an id (older Claude) fall back to the tool name.
292
+ const matches = r.toolUseId ? r.toolUseId === toolUseId : r.tool === tool;
293
+ if (matches) {
298
294
  s.suppressed.add(r.signature);
299
295
  debug('steering', `learned auto-approved signature for ${sid}: ${r.signature}`);
300
296
  }
@@ -1 +1 @@
1
- {"version":3,"file":"observed-steering.js","sourceRoot":"","sources":["../src/observed-steering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,gBAAgB,GAAG,EAAE,GAAG,MAAM,CAAC,CAAM,gDAAgD;AAC3F,MAAM,gBAAgB,GAAG,EAAE,GAAG,MAAM,CAAC;AACrC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B;;;oBAGoB;AACpB,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAe1C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEpD,SAAS,GAAG,CAAC,GAAW;IACtB,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,GAAG,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC;QACrE,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;mFACmF;AACnF,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,SAA8C;IACxF,IAAI,IAAI,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C,MAAM,KAAK,CAAC;QAAE,OAAO;IAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACpC,IAAI,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,2BAA2B;YAAE,SAAS,CAAC,UAAU;QAClE,wEAAwE;QACxE,qEAAqE;QACrE,uEAAuE;QACvE,wEAAwE;QACxE,oEAAoE;QACpE,MAAM,OAAO,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;QAC1E,IAAI,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC9B,KAAK,CAAC,UAAU,EAAE,uCAAuC,GAAG,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAClF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,CAAC,CAAC,iBAAiB,GAAG,IAAI,CAAC;AAC7B,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,OAAO;QACL,aAAa,EAAE,eAAe,CAAC,GAAG,CAAC;QACnC,gBAAgB,EAAE,oBAAoB,CAAC,GAAG,CAAC;KAC5C,CAAC;AACJ,CAAC;AAED,mBAAmB;AACnB,MAAM,UAAU,cAAc;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * OpenClaw Gateway instability — detect a restart storm and say why.
3
+ *
4
+ * A Gateway restart is invisible from inside the daemon: the socket closes,
5
+ * `disconnectGatewayAdapter` tears the virtual session down, the probe finds
6
+ * the port again a few seconds later and everything reconnects. Each cycle
7
+ * looks like a healthy recovery, and a surface that watched it saw the
8
+ * OpenClaw row flip to `gateway_not_found` and back. On 2026-09-02 that
9
+ * happened eleven times in ninety minutes and nothing anywhere said so —
10
+ * the daemon log carried eleven `connected` lines, every dashboard showed
11
+ * a connected Gateway between flaps, and the cause (two OpenClaw installs
12
+ * fighting over `~/.openclaw/state`, a launchd KeepAlive respawning a
13
+ * Gateway whose startup migration could not run because the other copy
14
+ * held the state, and a plugin install restarting it on top) was written
15
+ * only in OpenClaw's own log, which no surface reads.
16
+ *
17
+ * Two pieces, both pure so a test can drive them with a clock and a string:
18
+ *
19
+ * - `GatewayFlapTracker` counts disconnects inside a rolling window. Three
20
+ * in ten minutes is the line between "a plugin install restarted it" and
21
+ * "something is wrong": a single deliberate restart never crosses it, and
22
+ * the measured storm crossed it inside four minutes.
23
+ * - `diagnoseGatewayLog` reads the Gateway's own log tail for the sentences
24
+ * OpenClaw prints when it knows what is happening. Structural causes
25
+ * (another Gateway owns the state directory, the restart-loop breaker
26
+ * tripped, a startup migration refused to complete) outrank routine ones
27
+ * (a config-change restart, a plain SIGTERM) regardless of which line is
28
+ * newer, because the routine restart is usually the symptom that the
29
+ * structural cause produced.
30
+ *
31
+ * The daemon surfaces the result three ways so it cannot hide: a loud log
32
+ * line, an `instability` field on `/status` and `/health`, and one `error`
33
+ * timeline row per escalation on the virtual `openclaw-gateway` session —
34
+ * the timeline is the one channel every surface already renders, Android
35
+ * and e-ink included, without a protocol change.
36
+ */
37
+ export declare const GATEWAY_FLAP_WINDOW_MS: number;
38
+ export declare const GATEWAY_FLAP_THRESHOLD = 3;
39
+ /** Bytes read from the end of the Gateway log when diagnosing a storm. */
40
+ export declare const GATEWAY_LOG_TAIL_BYTES: number;
41
+ export type GatewayInstabilityKind = 'state_owner_conflict' | 'restart_loop' | 'migration_failed' | 'config_restart' | 'external_sigterm';
42
+ export interface GatewayLogDiagnosis {
43
+ kind: GatewayInstabilityKind;
44
+ /** The Gateway log line that carries the reason, trimmed. */
45
+ line: string;
46
+ /** What an operator should do about it, one sentence. */
47
+ hint: string;
48
+ }
49
+ export interface GatewayInstability {
50
+ flapsInWindow: number;
51
+ windowMs: number;
52
+ /** Epoch ms of the oldest disconnect still inside the window. */
53
+ since: number;
54
+ /** Epoch ms of the disconnect that produced this assessment. */
55
+ lastFlapAt: number;
56
+ diagnosis: GatewayLogDiagnosis | null;
57
+ }
58
+ export declare class GatewayFlapTracker {
59
+ private readonly windowMs;
60
+ private readonly threshold;
61
+ private stamps;
62
+ constructor(windowMs?: number, threshold?: number);
63
+ /** Record a disconnect at `nowMs`; returns the count inside the window including it. */
64
+ record(nowMs: number): number;
65
+ /**
66
+ * How many disconnects are inside the window, and whether that crosses the
67
+ * line. `since` is the oldest one still counted — the start of the storm.
68
+ */
69
+ assess(nowMs: number): {
70
+ flapsInWindow: number;
71
+ unstable: boolean;
72
+ since: number | null;
73
+ };
74
+ private prune;
75
+ }
76
+ /**
77
+ * Scan a Gateway log tail for the sentence that explains a restart storm.
78
+ * Returns the highest-priority kind present, carrying its most recent line.
79
+ * `null` means the tail has no known sentinel — the storm is real but the
80
+ * log does not say why, and the surfaces should say exactly that.
81
+ */
82
+ export declare function diagnoseGatewayLog(text: string): GatewayLogDiagnosis | null;
83
+ /** Default locations of the Gateway's launchd stdout log, most likely first. */
84
+ export declare function defaultGatewayLogPaths(home?: string): string[];
85
+ /**
86
+ * Read the last `maxBytes` of the first readable log path. Best-effort:
87
+ * an unreadable or absent log yields an empty string, never a throw —
88
+ * the storm is still reported, only without a reason.
89
+ */
90
+ export declare function readGatewayLogTail(paths?: string[], maxBytes?: number): Promise<string>;
91
+ /** One line for the timeline row and the daemon log; ≤ ~180 chars. */
92
+ export declare function formatGatewayInstability(i: GatewayInstability): string;
93
+ export declare function describeKind(kind: GatewayInstabilityKind): string;
94
+ //# sourceMappingURL=openclaw-gateway-stability.d.ts.map
@@ -0,0 +1 @@
1
+ {"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,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAW3E;AAED,gFAAgF;AAChF,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,EAAE,CAEzE;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,GAAE,MAAM,EAA6B,EAC1C,QAAQ,GAAE,MAA+B,GACxC,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED,sEAAsE;AACtE,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAKtE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAQjE"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * OpenClaw Gateway instability — detect a restart storm and say why.
3
+ *
4
+ * A Gateway restart is invisible from inside the daemon: the socket closes,
5
+ * `disconnectGatewayAdapter` tears the virtual session down, the probe finds
6
+ * the port again a few seconds later and everything reconnects. Each cycle
7
+ * looks like a healthy recovery, and a surface that watched it saw the
8
+ * OpenClaw row flip to `gateway_not_found` and back. On 2026-09-02 that
9
+ * happened eleven times in ninety minutes and nothing anywhere said so —
10
+ * the daemon log carried eleven `connected` lines, every dashboard showed
11
+ * a connected Gateway between flaps, and the cause (two OpenClaw installs
12
+ * fighting over `~/.openclaw/state`, a launchd KeepAlive respawning a
13
+ * Gateway whose startup migration could not run because the other copy
14
+ * held the state, and a plugin install restarting it on top) was written
15
+ * only in OpenClaw's own log, which no surface reads.
16
+ *
17
+ * Two pieces, both pure so a test can drive them with a clock and a string:
18
+ *
19
+ * - `GatewayFlapTracker` counts disconnects inside a rolling window. Three
20
+ * in ten minutes is the line between "a plugin install restarted it" and
21
+ * "something is wrong": a single deliberate restart never crosses it, and
22
+ * the measured storm crossed it inside four minutes.
23
+ * - `diagnoseGatewayLog` reads the Gateway's own log tail for the sentences
24
+ * OpenClaw prints when it knows what is happening. Structural causes
25
+ * (another Gateway owns the state directory, the restart-loop breaker
26
+ * tripped, a startup migration refused to complete) outrank routine ones
27
+ * (a config-change restart, a plain SIGTERM) regardless of which line is
28
+ * newer, because the routine restart is usually the symptom that the
29
+ * structural cause produced.
30
+ *
31
+ * The daemon surfaces the result three ways so it cannot hide: a loud log
32
+ * line, an `instability` field on `/status` and `/health`, and one `error`
33
+ * timeline row per escalation on the virtual `openclaw-gateway` session —
34
+ * the timeline is the one channel every surface already renders, Android
35
+ * and e-ink included, without a protocol change.
36
+ */
37
+ import { open } from 'node:fs/promises';
38
+ import { homedir } from 'node:os';
39
+ import { join } from 'node:path';
40
+ export const GATEWAY_FLAP_WINDOW_MS = 10 * 60_000;
41
+ export const GATEWAY_FLAP_THRESHOLD = 3;
42
+ /** Bytes read from the end of the Gateway log when diagnosing a storm. */
43
+ export const GATEWAY_LOG_TAIL_BYTES = 64 * 1024;
44
+ /**
45
+ * Sentinels in priority order. The first kind found anywhere in the tail
46
+ * wins, so a structural cause explains a storm even when the most recent
47
+ * line is the routine restart it caused.
48
+ */
49
+ const SENTINELS = [
50
+ {
51
+ kind: 'state_owner_conflict',
52
+ pattern: /another Gateway owns that state directory/i,
53
+ hint: 'Two OpenClaw Gateways are using one ~/.openclaw/state — usually two installs ' +
54
+ '(a global npm/pnpm copy beside the app-managed ~/.openclaw/tools runtime). ' +
55
+ 'Keep one; make sure `openclaw` on PATH is ~/.openclaw/bin/openclaw.',
56
+ },
57
+ {
58
+ kind: 'restart_loop',
59
+ pattern: /restart-loop breaker tripped/i,
60
+ hint: 'OpenClaw\'s own breaker saw repeated unclean boots; launchd KeepAlive is ' +
61
+ 'respawning a Gateway that cannot come up. Read ~/Library/Logs/openclaw/gateway.log.',
62
+ },
63
+ {
64
+ kind: 'migration_failed',
65
+ pattern: /startup migrations did not complete cleanly|migration requires stopped-writer maintenance/i,
66
+ hint: 'A startup migration refused to run because another writer holds the state. ' +
67
+ 'Stop every other Gateway, then restart this one once.',
68
+ },
69
+ {
70
+ kind: 'config_restart',
71
+ pattern: /config change requires gateway restart|received SIGUSR1; restarting|Restart the gateway to (apply|load)/i,
72
+ hint: 'A config or plugin change asked the Gateway to restart. Expected once; a storm of these is not.',
73
+ },
74
+ {
75
+ kind: 'external_sigterm',
76
+ pattern: /received SIGTERM; shutting down/i,
77
+ hint: 'Something sent the Gateway SIGTERM (a CLI restart, an updater, or launchd). Check who.',
78
+ },
79
+ ];
80
+ export class GatewayFlapTracker {
81
+ windowMs;
82
+ threshold;
83
+ stamps = [];
84
+ constructor(windowMs = GATEWAY_FLAP_WINDOW_MS, threshold = GATEWAY_FLAP_THRESHOLD) {
85
+ this.windowMs = windowMs;
86
+ this.threshold = threshold;
87
+ }
88
+ /** Record a disconnect at `nowMs`; returns the count inside the window including it. */
89
+ record(nowMs) {
90
+ this.stamps.push(nowMs);
91
+ this.prune(nowMs);
92
+ return this.stamps.length;
93
+ }
94
+ /**
95
+ * How many disconnects are inside the window, and whether that crosses the
96
+ * line. `since` is the oldest one still counted — the start of the storm.
97
+ */
98
+ assess(nowMs) {
99
+ this.prune(nowMs);
100
+ return {
101
+ flapsInWindow: this.stamps.length,
102
+ unstable: this.stamps.length >= this.threshold,
103
+ since: this.stamps.length > 0 ? this.stamps[0] : null,
104
+ };
105
+ }
106
+ prune(nowMs) {
107
+ const cutoff = nowMs - this.windowMs;
108
+ while (this.stamps.length > 0 && this.stamps[0] < cutoff)
109
+ this.stamps.shift();
110
+ }
111
+ }
112
+ /**
113
+ * Scan a Gateway log tail for the sentence that explains a restart storm.
114
+ * Returns the highest-priority kind present, carrying its most recent line.
115
+ * `null` means the tail has no known sentinel — the storm is real but the
116
+ * log does not say why, and the surfaces should say exactly that.
117
+ */
118
+ export function diagnoseGatewayLog(text) {
119
+ if (!text)
120
+ return null;
121
+ const lines = text.split(/\r?\n/);
122
+ for (const sentinel of SENTINELS) {
123
+ for (let i = lines.length - 1; i >= 0; i--) {
124
+ if (sentinel.pattern.test(lines[i])) {
125
+ return { kind: sentinel.kind, line: lines[i].trim().slice(0, 300), hint: sentinel.hint };
126
+ }
127
+ }
128
+ }
129
+ return null;
130
+ }
131
+ /** Default locations of the Gateway's launchd stdout log, most likely first. */
132
+ export function defaultGatewayLogPaths(home = homedir()) {
133
+ return [join(home, 'Library', 'Logs', 'openclaw', 'gateway.log')];
134
+ }
135
+ /**
136
+ * Read the last `maxBytes` of the first readable log path. Best-effort:
137
+ * an unreadable or absent log yields an empty string, never a throw —
138
+ * the storm is still reported, only without a reason.
139
+ */
140
+ export async function readGatewayLogTail(paths = defaultGatewayLogPaths(), maxBytes = GATEWAY_LOG_TAIL_BYTES) {
141
+ for (const path of paths) {
142
+ let handle;
143
+ try {
144
+ handle = await open(path, 'r');
145
+ const { size } = await handle.stat();
146
+ const length = Math.min(size, maxBytes);
147
+ const buffer = Buffer.alloc(length);
148
+ await handle.read(buffer, 0, length, size - length);
149
+ return buffer.toString('utf8');
150
+ }
151
+ catch {
152
+ continue;
153
+ }
154
+ finally {
155
+ await handle?.close().catch(() => { });
156
+ }
157
+ }
158
+ return '';
159
+ }
160
+ /** One line for the timeline row and the daemon log; ≤ ~180 chars. */
161
+ export function formatGatewayInstability(i) {
162
+ const minutes = Math.max(1, Math.round((i.lastFlapAt - i.since) / 60_000));
163
+ const head = `OpenClaw Gateway unstable · ${i.flapsInWindow} restarts in ${minutes} min`;
164
+ const why = i.diagnosis ? describeKind(i.diagnosis.kind) : 'reason not in the Gateway log';
165
+ return `${head} — ${why}`;
166
+ }
167
+ export function describeKind(kind) {
168
+ switch (kind) {
169
+ case 'state_owner_conflict': return 'two Gateways own ~/.openclaw/state (duplicate install?)';
170
+ case 'restart_loop': return 'OpenClaw restart-loop breaker tripped';
171
+ case 'migration_failed': return 'startup migration blocked by another writer';
172
+ case 'config_restart': return 'config/plugin change restarts';
173
+ case 'external_sigterm': return 'repeated external SIGTERM';
174
+ }
175
+ }
176
+ //# sourceMappingURL=openclaw-gateway-stability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-gateway-stability.js","sourceRoot":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,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,wBAAwB,CAAC,CAAqB;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,+BAA+B,CAAC,CAAC,aAAa,gBAAgB,OAAO,MAAM,CAAC;IACzF,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,+BAA+B,CAAC;IAC3F,OAAO,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAA4B;IACvD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,sBAAsB,CAAC,CAAC,OAAO,yDAAyD,CAAC;QAC9F,KAAK,cAAc,CAAC,CAAC,OAAO,uCAAuC,CAAC;QACpE,KAAK,kBAAkB,CAAC,CAAC,OAAO,6CAA6C,CAAC;QAC9E,KAAK,gBAAgB,CAAC,CAAC,OAAO,+BAA+B,CAAC;QAC9D,KAAK,kBAAkB,CAAC,CAAC,OAAO,2BAA2B,CAAC;IAC9D,CAAC;AACH,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * A knock is worth showing for this long after its last attempt. Long enough
3
+ * that the operator can walk to the machine; short enough that a device carried
4
+ * out of the building stops being offered.
5
+ */
6
+ export declare const KNOCK_TTL_MS: number;
7
+ /** Cap on simultaneously-tracked peers. */
8
+ export declare const MAX_KNOCKS = 12;
9
+ export interface PairingKnock {
10
+ /**
11
+ * What an approval will be recorded against. `device:<id>` when the client
12
+ * identified itself, `ip:<addr>` otherwise — never the bare string, so the
13
+ * two can never collide or be confused downstream.
14
+ */
15
+ key: string;
16
+ ip: string;
17
+ deviceId: string | null;
18
+ attempts: number;
19
+ firstSeen: number;
20
+ lastSeen: number;
21
+ /**
22
+ * True when the peer presented a token we do not accept, rather than no token
23
+ * at all. Reads very differently to an operator: usually a provisioned device
24
+ * whose credential went stale, not a new device.
25
+ */
26
+ staleToken: boolean;
27
+ /** Display only — `key` already encodes which kind this is. */
28
+ deviceScoped: boolean;
29
+ }
30
+ export interface PairingApproval {
31
+ key: string;
32
+ /**
33
+ * Where it last connected from. Display only — an approval keyed on a device
34
+ * id must not start depending on the address, or it would silently reacquire
35
+ * the NAT and DHCP problems it exists to escape.
36
+ */
37
+ lastIP: string;
38
+ approvedAt: number;
39
+ deviceId: string | null;
40
+ }
41
+ /**
42
+ * The one place a key is spelled, so the gate, the store and the UI cannot
43
+ * disagree about what "this peer" means.
44
+ */
45
+ export declare function peerKey(ip: string, deviceId: unknown): string;
46
+ /**
47
+ * Called from the refusal path. Cheap on purpose — it runs for every rejected
48
+ * handshake, and a looping device produces one every few seconds.
49
+ */
50
+ export declare function recordKnock(ip: string, deviceId: unknown, staleToken: boolean, now?: number): void;
51
+ /** Live knocks, newest first. Expiry is applied here — see the header. */
52
+ export declare function pairingKnocks(now?: number): PairingKnock[];
53
+ /**
54
+ * Drop a knock without approving it. Not a block: the peer may knock again,
55
+ * which is deliberate — a permanent denylist keyed on an address a stranger can
56
+ * change is security theatre, and it would silently strand a real device that
57
+ * later inherits that address.
58
+ */
59
+ export declare function dismissKnock(key: string): boolean;
60
+ /**
61
+ * Approving is what a pairing code would have done, minus the typing: from here
62
+ * on this peer authenticates by its key. Persisted immediately.
63
+ */
64
+ export declare function approvePeer(key: string, now?: number): boolean;
65
+ export declare function revokePeer(key: string): boolean;
66
+ /**
67
+ * The question the WebSocket gate asks.
68
+ *
69
+ * A device id wins when the client sent one; the address is consulted only as
70
+ * the legacy path, so a client that adopts the header stops depending on its
71
+ * address the moment it does. Both are checked rather than one, because a
72
+ * device approved by address before it learned to send an id must not be locked
73
+ * out by the upgrade that taught it.
74
+ */
75
+ export declare function isApprovedPeer(ip: string, deviceId: unknown): boolean;
76
+ export declare function pairingApprovals(): PairingApproval[];
77
+ /** Read the device id a client offered on the handshake, if any. */
78
+ export declare function deviceIdFromHeaders(headers: Record<string, string | string[] | undefined> | undefined, headerName: string): string | null;
79
+ export declare function resetPairingKnocksForTests(): void;
80
+ //# sourceMappingURL=pairing-knocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing-knocks.d.ts","sourceRoot":"","sources":["../src/pairing-knocks.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAc,CAAC;AAExC,2CAA2C;AAC3C,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,+DAA+D;IAC/D,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAI7D;AA8ID;;;GAGG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,OAAO,EACnB,GAAG,SAA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