mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-29 20:03:35 +00:00
docs: document gateway node helpers
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// Gateway node connect reconciliation.
|
||||
// Computes approved runtime surfaces and pending pairing upgrades on reconnect.
|
||||
import type { ConnectParams } from "../../packages/gateway-protocol/src/index.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Gateway pending node-work queue.
|
||||
// Stores short-lived per-node prompts until connected nodes drain/ack them.
|
||||
import { randomUUID } from "node:crypto";
|
||||
import {
|
||||
asDateTimestampMs,
|
||||
@@ -69,6 +71,8 @@ function getOrCreateState(nodeId: string): NodePendingWorkState {
|
||||
}
|
||||
|
||||
function pruneExpired(state: NodePendingWorkState, nowMs: number): boolean {
|
||||
// Expiry pruning bumps revision so polling nodes can observe that work changed
|
||||
// even when no explicit acknowledge call happened.
|
||||
const validNowMs = asDateTimestampMs(nowMs);
|
||||
if (validNowMs === undefined) {
|
||||
return false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Gateway node event dispatcher.
|
||||
// Handles device/node-originated events and routes them to sessions/channels.
|
||||
import { randomUUID } from "node:crypto";
|
||||
import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
@@ -117,6 +119,8 @@ function shouldDropDuplicateVoiceTranscript(params: {
|
||||
fingerprint: string;
|
||||
now: number;
|
||||
}): boolean {
|
||||
// Voice providers can replay identical transcript fragments during reconnect.
|
||||
// Keep only a bounded last fingerprint per session to avoid duplicate sends.
|
||||
const previous = recentVoiceTranscripts.get(params.sessionKey);
|
||||
if (
|
||||
previous &&
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Gateway node session runtime factory.
|
||||
// Creates node registry, subscription, and voice-wake fanout state.
|
||||
import { NodeRegistry, type SerializedEventPayload } from "./node-registry.js";
|
||||
import {
|
||||
createSessionEventSubscriberRegistry,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Gateway node subscription manager.
|
||||
// Maintains bidirectional node/session fanout indexes.
|
||||
import { serializeEventPayload, type SerializedEventPayload } from "./node-registry.js";
|
||||
|
||||
// Node subscription manager keeps bidirectional node/session indexes so gateway
|
||||
@@ -92,6 +94,8 @@ export function createNodeSubscriptionManager(): NodeSubscriptionManager {
|
||||
if (!nodeSet) {
|
||||
return;
|
||||
}
|
||||
// Remove reverse session indexes before deleting the node index so session
|
||||
// fanout cannot retain disconnected node ids.
|
||||
for (const sessionKey of nodeSet) {
|
||||
const sessionSet = sessionSubscribers.get(sessionKey);
|
||||
sessionSet?.delete(normalizedNodeId);
|
||||
|
||||
Reference in New Issue
Block a user