docs: document gateway node helpers · openclaw/openclaw@a3f495e
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Gateway node connect reconciliation. |
| 2 | +// Computes approved runtime surfaces and pending pairing upgrades on reconnect. |
1 | 3 | import type { ConnectParams } from "../../packages/gateway-protocol/src/index.js"; |
2 | 4 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
3 | 5 | import { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Gateway pending node-work queue. |
| 2 | +// Stores short-lived per-node prompts until connected nodes drain/ack them. |
1 | 3 | import { randomUUID } from "node:crypto"; |
2 | 4 | import { |
3 | 5 | asDateTimestampMs, |
@@ -69,6 +71,8 @@ function getOrCreateState(nodeId: string): NodePendingWorkState {
|
69 | 71 | } |
70 | 72 | |
71 | 73 | function pruneExpired(state: NodePendingWorkState, nowMs: number): boolean { |
| 74 | +// Expiry pruning bumps revision so polling nodes can observe that work changed |
| 75 | +// even when no explicit acknowledge call happened. |
72 | 76 | const validNowMs = asDateTimestampMs(nowMs); |
73 | 77 | if (validNowMs === undefined) { |
74 | 78 | return false; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Gateway node event dispatcher. |
| 2 | +// Handles device/node-originated events and routes them to sessions/channels. |
1 | 3 | import { randomUUID } from "node:crypto"; |
2 | 4 | import { |
3 | 5 | normalizeLowercaseStringOrEmpty, |
@@ -117,6 +119,8 @@ function shouldDropDuplicateVoiceTranscript(params: {
|
117 | 119 | fingerprint: string; |
118 | 120 | now: number; |
119 | 121 | }): boolean { |
| 122 | +// Voice providers can replay identical transcript fragments during reconnect. |
| 123 | +// Keep only a bounded last fingerprint per session to avoid duplicate sends. |
120 | 124 | const previous = recentVoiceTranscripts.get(params.sessionKey); |
121 | 125 | if ( |
122 | 126 | previous && |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Gateway node session runtime factory. |
| 2 | +// Creates node registry, subscription, and voice-wake fanout state. |
1 | 3 | import { NodeRegistry, type SerializedEventPayload } from "./node-registry.js"; |
2 | 4 | import { |
3 | 5 | createSessionEventSubscriberRegistry, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Gateway node subscription manager. |
| 2 | +// Maintains bidirectional node/session fanout indexes. |
1 | 3 | import { serializeEventPayload, type SerializedEventPayload } from "./node-registry.js"; |
2 | 4 | |
3 | 5 | // Node subscription manager keeps bidirectional node/session indexes so gateway |
@@ -92,6 +94,8 @@ export function createNodeSubscriptionManager(): NodeSubscriptionManager {
|
92 | 94 | if (!nodeSet) { |
93 | 95 | return; |
94 | 96 | } |
| 97 | +// Remove reverse session indexes before deleting the node index so session |
| 98 | +// fanout cannot retain disconnected node ids. |
95 | 99 | for (const sessionKey of nodeSet) { |
96 | 100 | const sessionSet = sessionSubscribers.get(sessionKey); |
97 | 101 | sessionSet?.delete(normalizedNodeId); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。