@openclaw/gateway-client 2026.9.6 → 2026.9.7
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/README.md +78 -3
- package/dist/browser.d.mts +23 -3
- package/dist/browser.mjs +51 -2
- package/dist/index.d.mts +21 -3
- package/dist/index.mjs +124 -77
- package/dist/{protocol-client-D6mJuY1_.d.mts → protocol-client-DT451Msj.d.mts} +18 -1
- package/dist/{readiness-ChxbBSMj.d.mts → readiness-Cj5C24o2.d.mts} +15 -23
- package/dist/readiness.d.mts +1 -1
- package/dist/scope-upgrade.d.mts +1 -0
- package/dist/scope-upgrade.mjs +12 -2
- package/dist/{session-subscriptions-C91CEXwY.d.mts → session-subscriptions-Bcq6_wtR.d.mts} +15 -3
- package/dist/{session-subscriptions-DUpRfWJb.mjs → session-subscriptions-LtlX9oRQ.mjs} +306 -116
- package/dist/timeouts.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as GatewayProtocolRequestOptions, t as GatewayProtocolRequestError } from "./protocol-request-CtVhe3Bj.mjs";
|
|
2
|
+
import { GatewayClientMode, GatewayClientName } from "@openclaw/gateway-protocol/client-info";
|
|
2
3
|
import { ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol";
|
|
3
4
|
//#region packages/gateway-client/src/pending-request.d.ts
|
|
4
5
|
type GatewayProtocolRequestTiming = {
|
|
@@ -12,6 +13,20 @@ type GatewayProtocolRequestTiming = {
|
|
|
12
13
|
};
|
|
13
14
|
//#endregion
|
|
14
15
|
//#region packages/gateway-client/src/protocol-client-contract.d.ts
|
|
16
|
+
type GatewayClientCloseInfo = {
|
|
17
|
+
phase: "pre-hello" | "post-hello";
|
|
18
|
+
socketOpened: boolean;
|
|
19
|
+
transportValidated: boolean;
|
|
20
|
+
connectRequestSent?: boolean;
|
|
21
|
+
transientPreHelloCleanClose: boolean;
|
|
22
|
+
connectError?: Error;
|
|
23
|
+
};
|
|
24
|
+
type GatewayClientConnectionMetadata = {
|
|
25
|
+
clientName?: GatewayClientName;
|
|
26
|
+
hasDeviceIdentity: boolean;
|
|
27
|
+
mode?: GatewayClientMode;
|
|
28
|
+
preauthHandshakeTimeoutMs?: number;
|
|
29
|
+
};
|
|
15
30
|
type GatewayProtocolSocket = {
|
|
16
31
|
isOpen: () => boolean;
|
|
17
32
|
send: (data: string) => void;
|
|
@@ -91,6 +106,7 @@ type GatewayProtocolClientOptions<TPlan> = {
|
|
|
91
106
|
onConnectError?: (error: Error) => void;
|
|
92
107
|
onSocketFactoryError?: (error: Error) => void;
|
|
93
108
|
onReconnectStopped?: (error: Error) => void;
|
|
109
|
+
onReconnectScheduled?: (delayMs: number, signal: AbortSignal) => void;
|
|
94
110
|
onParseError?: (error: unknown) => void;
|
|
95
111
|
onEvent?: (event: EventFrame) => void;
|
|
96
112
|
onGap?: (info: {
|
|
@@ -166,6 +182,7 @@ declare class GatewayProtocolClient<TPlan> {
|
|
|
166
182
|
private handleConnectPlanError;
|
|
167
183
|
private sendConnectPlan;
|
|
168
184
|
private handleMessage;
|
|
185
|
+
private dispatchEvent;
|
|
169
186
|
private handleClose;
|
|
170
187
|
private handleSocketError;
|
|
171
188
|
private scheduleReconnect;
|
|
@@ -178,4 +195,4 @@ declare class GatewayProtocolClient<TPlan> {
|
|
|
178
195
|
private invoke;
|
|
179
196
|
}
|
|
180
197
|
//#endregion
|
|
181
|
-
export {
|
|
198
|
+
export { GatewayProtocolConnectAuthority as a, GatewayProtocolTiming as c, GatewayProtocolCloseContext as i, GatewayProtocolRequestTiming as l, GatewayClientCloseInfo as n, GatewayProtocolSocket as o, GatewayClientConnectionMetadata as r, GatewayProtocolSocketHandlers as s, GatewayProtocolClient as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-CtVhe3Bj.mjs";
|
|
2
|
-
import "./protocol-client-
|
|
2
|
+
import { l as GatewayProtocolRequestTiming, n as GatewayClientCloseInfo, r as GatewayClientConnectionMetadata } from "./protocol-client-DT451Msj.mjs";
|
|
3
3
|
import { ConnectParams, ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol/frame-guards";
|
|
4
4
|
import { GatewayClientMode, GatewayClientName } from "@openclaw/gateway-protocol/client-info";
|
|
5
|
+
import "ws";
|
|
5
6
|
//#region packages/gateway-client/src/client-device-auth.d.ts
|
|
6
7
|
type DeviceAuthTokenRecord = {
|
|
7
8
|
token?: string;
|
|
@@ -34,6 +35,14 @@ type GatewayClientDeviceAuthStorage = {
|
|
|
34
35
|
}) => unknown;
|
|
35
36
|
};
|
|
36
37
|
//#endregion
|
|
38
|
+
//#region packages/gateway-client/src/websocket.d.ts
|
|
39
|
+
type GatewayWebSocketTargetOptions = {
|
|
40
|
+
url?: string;
|
|
41
|
+
tlsFingerprint?: string;
|
|
42
|
+
/** Original TLS peer hostname or IP when the transport endpoint is translated. */
|
|
43
|
+
tlsServerName?: string;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
37
46
|
//#region packages/gateway-client/src/request-error.d.ts
|
|
38
47
|
declare class GatewayClientRequestError extends GatewayProtocolRequestError {
|
|
39
48
|
constructor(error: Partial<ErrorShape>);
|
|
@@ -63,14 +72,6 @@ type GatewayReconnectPausedInfo = {
|
|
|
63
72
|
reason: string;
|
|
64
73
|
detailCode: string | null;
|
|
65
74
|
};
|
|
66
|
-
type GatewayClientCloseInfo = {
|
|
67
|
-
phase: "pre-hello" | "post-hello";
|
|
68
|
-
socketOpened: boolean;
|
|
69
|
-
transportValidated: boolean;
|
|
70
|
-
connectRequestSent?: boolean;
|
|
71
|
-
transientPreHelloCleanClose: boolean;
|
|
72
|
-
connectError?: Error;
|
|
73
|
-
};
|
|
74
75
|
declare class GatewayClientRequestTimeoutError extends GatewayProtocolRequestTimeoutError {
|
|
75
76
|
constructor(params: {
|
|
76
77
|
method: string;
|
|
@@ -78,8 +79,7 @@ declare class GatewayClientRequestTimeoutError extends GatewayProtocolRequestTim
|
|
|
78
79
|
requestSent: boolean;
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
|
-
type GatewayClientOptions = {
|
|
82
|
-
url?: string;
|
|
82
|
+
type GatewayClientOptions = GatewayWebSocketTargetOptions & {
|
|
83
83
|
origin?: string;
|
|
84
84
|
/** Already-resolved edge-proxy auth headers (identity-aware proxy in front of the Gateway). */
|
|
85
85
|
edgeAuthHeaders?: Readonly<Record<string, string>>;
|
|
@@ -124,7 +124,6 @@ type GatewayClientOptions = {
|
|
|
124
124
|
hostDeps?: GatewayClientHostDeps;
|
|
125
125
|
minProtocol?: number;
|
|
126
126
|
maxProtocol?: number;
|
|
127
|
-
tlsFingerprint?: string;
|
|
128
127
|
onEvent?: (evt: EventFrame) => void;
|
|
129
128
|
onHelloOk?: (hello: HelloOk) => void;
|
|
130
129
|
onConnectError?: (err: Error) => void;
|
|
@@ -136,12 +135,7 @@ type GatewayClientOptions = {
|
|
|
136
135
|
expected: number;
|
|
137
136
|
received: number;
|
|
138
137
|
}) => void;
|
|
139
|
-
|
|
140
|
-
type GatewayClientConnectionMetadata = {
|
|
141
|
-
clientName?: GatewayClientName;
|
|
142
|
-
hasDeviceIdentity: boolean;
|
|
143
|
-
mode?: GatewayClientMode;
|
|
144
|
-
preauthHandshakeTimeoutMs?: number;
|
|
138
|
+
onRequestTiming?: (timing: GatewayProtocolRequestTiming) => void;
|
|
145
139
|
};
|
|
146
140
|
declare class GatewayClient {
|
|
147
141
|
private readonly protocol;
|
|
@@ -189,8 +183,7 @@ declare class GatewayClient {
|
|
|
189
183
|
private logError;
|
|
190
184
|
private assembleConnectParams;
|
|
191
185
|
private shouldNegotiateLegacyNodeProtocol;
|
|
192
|
-
private
|
|
193
|
-
private shouldRetryWithCurrentNodeProtocol;
|
|
186
|
+
private shouldRetryWithAlternateNodeProtocol;
|
|
194
187
|
private buildDeviceConnectParams;
|
|
195
188
|
private handleConnectHello;
|
|
196
189
|
private completeConnectHello;
|
|
@@ -202,8 +195,7 @@ declare class GatewayClient {
|
|
|
202
195
|
private clearDeviceToken;
|
|
203
196
|
private notifyConnectError;
|
|
204
197
|
private notifyReconnectPaused;
|
|
205
|
-
private
|
|
206
|
-
private shouldFailClosedForUnsupportedAgentRuntimeIdentity;
|
|
198
|
+
private isUnsupportedConnectAuthField;
|
|
207
199
|
private isTrustedDeviceRetryEndpoint;
|
|
208
200
|
private selectConnectAuth;
|
|
209
201
|
private startTickWatch;
|
|
@@ -247,4 +239,4 @@ declare function startGatewayClientWithReadinessWait(waitForReady: EventLoopRead
|
|
|
247
239
|
/** Starts a gateway client after the default event-loop readiness probe succeeds. */
|
|
248
240
|
declare function startGatewayClientWhenEventLoopReady(client: GatewayClientStartable, options?: GatewayClientStartReadinessOptions): Promise<EventLoopReadyResult>;
|
|
249
241
|
//#endregion
|
|
250
|
-
export {
|
|
242
|
+
export { isGatewayConnectAssemblyError as _, startGatewayClientWithReadinessWait as a, waitForEventLoopReady as c, GatewayClientHostDeps as d, GatewayClientOptions as f, GatewayClientRequestError as g, GatewayReconnectPausedInfo as h, startGatewayClientWhenEventLoopReady as i, DeviceIdentity as l, GatewayClientRequestTimeoutError as m, GatewayClientStartReadinessOptions as n, EventLoopReadyOptions as o, GatewayClientRequestOptions as p, GatewayClientStartable as r, EventLoopReadyResult as s, EventLoopReadyWaiter as t, GatewayClient as u, DeviceAuthTokenRecord as v };
|
package/dist/readiness.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as startGatewayClientWithReadinessWait, i as startGatewayClientWhenEventLoopReady, n as GatewayClientStartReadinessOptions, r as GatewayClientStartable, t as EventLoopReadyWaiter } from "./readiness-
|
|
1
|
+
import { a as startGatewayClientWithReadinessWait, i as startGatewayClientWhenEventLoopReady, n as GatewayClientStartReadinessOptions, r as GatewayClientStartable, t as EventLoopReadyWaiter } from "./readiness-Cj5C24o2.mjs";
|
|
2
2
|
export { EventLoopReadyWaiter, GatewayClientStartReadinessOptions, GatewayClientStartable, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait };
|
package/dist/scope-upgrade.d.mts
CHANGED
package/dist/scope-upgrade.mjs
CHANGED
|
@@ -46,14 +46,20 @@ var GatewayScopeUpgrade = class {
|
|
|
46
46
|
operation?.controller.abort();
|
|
47
47
|
}
|
|
48
48
|
async runUpgrade(operation, options) {
|
|
49
|
-
const
|
|
49
|
+
const registration = await this.deps.request("device.scopes.requestUpgrade", { scopes: [...options.scopes] }, { signal: operation.controller.signal });
|
|
50
|
+
this.assertCurrent(operation);
|
|
51
|
+
const requestId = readRequestId(registration);
|
|
50
52
|
operation.requestId = requestId;
|
|
51
53
|
options.onPending?.(requestId);
|
|
54
|
+
this.assertCurrent(operation);
|
|
52
55
|
const result = readUpgradeResult(await this.deps.request("device.scopes.waitUpgrade", { requestId }, {
|
|
53
56
|
timeoutMs: null,
|
|
54
57
|
signal: operation.controller.signal
|
|
55
58
|
}), requestId);
|
|
56
|
-
if (result.status !== "approved")
|
|
59
|
+
if (result.status !== "approved") {
|
|
60
|
+
this.assertCurrent(operation);
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
57
63
|
await this.deps.tokenStore.store({
|
|
58
64
|
clientId: options.binding.clientId,
|
|
59
65
|
deviceId: options.binding.deviceId,
|
|
@@ -61,6 +67,7 @@ var GatewayScopeUpgrade = class {
|
|
|
61
67
|
token: result.deviceToken,
|
|
62
68
|
scopes: result.scopes
|
|
63
69
|
});
|
|
70
|
+
this.assertCurrent(operation);
|
|
64
71
|
this.deps.reconnect();
|
|
65
72
|
return {
|
|
66
73
|
status: "approved",
|
|
@@ -68,6 +75,9 @@ var GatewayScopeUpgrade = class {
|
|
|
68
75
|
scopes: result.scopes
|
|
69
76
|
};
|
|
70
77
|
}
|
|
78
|
+
assertCurrent(operation) {
|
|
79
|
+
if (this.active !== operation) throw new DOMException("scope upgrade cancelled", "AbortError");
|
|
80
|
+
}
|
|
71
81
|
};
|
|
72
82
|
//#endregion
|
|
73
83
|
export { GatewayScopeUpgrade };
|
|
@@ -18,6 +18,14 @@ type DeviceAuthPayloadV3Params = DeviceAuthPayloadParams & {
|
|
|
18
18
|
declare function buildDeviceAuthPayload(params: DeviceAuthPayloadParams): string;
|
|
19
19
|
declare function buildDeviceAuthPayloadV3(params: DeviceAuthPayloadV3Params): string;
|
|
20
20
|
//#endregion
|
|
21
|
+
//#region packages/gateway-client/src/chat-stream-message.d.ts
|
|
22
|
+
/** A snapshot includes its delta; append-only frames require an existing baseline. */
|
|
23
|
+
declare function mergeChatStreamMessage(previous: unknown, payload: {
|
|
24
|
+
message?: unknown;
|
|
25
|
+
deltaText?: unknown;
|
|
26
|
+
replace?: unknown;
|
|
27
|
+
}): unknown;
|
|
28
|
+
//#endregion
|
|
21
29
|
//#region packages/gateway-client/src/gateway-origin-scope.d.ts
|
|
22
30
|
/** Normalizes the gateway URL scope used for origin-bound device tokens. */
|
|
23
31
|
declare function gatewayOriginScope(gatewayUrl: string): string;
|
|
@@ -83,6 +91,8 @@ type SessionProjectionGatewayRunEvent = {
|
|
|
83
91
|
state?: unknown;
|
|
84
92
|
yielded?: unknown;
|
|
85
93
|
seq?: unknown;
|
|
94
|
+
deltaText?: unknown;
|
|
95
|
+
replace?: unknown;
|
|
86
96
|
} & Partial<Record<"runId" | "message" | "stopReason" | "errorKind" | "errorMessage", unknown>>;
|
|
87
97
|
type SessionProjectionRunTransition = {
|
|
88
98
|
projection: SessionProjectionState;
|
|
@@ -184,19 +194,21 @@ type GatewaySessionMessageRequestClient = {
|
|
|
184
194
|
type GatewaySessionMessageSubscription = {
|
|
185
195
|
key: string;
|
|
186
196
|
agentId?: string | null;
|
|
197
|
+
mode?: "narration";
|
|
187
198
|
includeApprovals?: true;
|
|
188
199
|
approvalReplay?: unknown;
|
|
189
200
|
};
|
|
190
201
|
type GatewaySessionMessageSubscriptionOptions = {
|
|
191
202
|
agentId?: string | null;
|
|
203
|
+
mode?: "narration";
|
|
192
204
|
includeApprovals?: boolean;
|
|
193
205
|
};
|
|
194
206
|
type GatewaySessionMessageSubscriptionCoordinatorOptions = {
|
|
195
207
|
keysEquivalent?: (left: string, right: string) => boolean;
|
|
196
208
|
};
|
|
197
209
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
210
|
+
* Shared leases retain one wire observer ID. The Gateway combines independently
|
|
211
|
+
* addressed observers; approval delivery upgrades the same owner.
|
|
200
212
|
*/
|
|
201
213
|
declare class GatewaySessionMessageSubscriptionCoordinator {
|
|
202
214
|
#private;
|
|
@@ -211,4 +223,4 @@ declare function getGatewaySessionMessageSubscriptionCoordinator(client: Gateway
|
|
|
211
223
|
declare function resetGatewaySessionMessageSubscriptionCoordinator(client: GatewaySessionMessageRequestClient): void;
|
|
212
224
|
declare function releaseGatewaySessionMessageSubscription(subscription: GatewaySessionMessageSubscription): Promise<void>;
|
|
213
225
|
//#endregion
|
|
214
|
-
export { normalizeSessionProjectionRunId as A, reduceSessionProjectionRunEvent as C, SessionMessageIdentity as D, SessionMessageEnvelope as E, gatewayOriginScope as F,
|
|
226
|
+
export { normalizeSessionProjectionRunId as A, reduceSessionProjectionRunEvent as C, SessionMessageIdentity as D, SessionMessageEnvelope as E, gatewayOriginScope as F, mergeChatStreamMessage as I, buildDeviceAuthPayload as L, readSessionMessageIdentity as M, readSessionMessageSequence as N, SessionProjectionEntry as O, gatewayCredentialScope as P, buildDeviceAuthPayloadV3 as R, SessionProjectionRunTransition as S, readSessionProjectionFinalMessageIdentity as T, reconcileSessionProjectionSnapshot as _, GatewaySessionMessageSubscriptionOptions as a, projectSessionTerminalReplyMessage as b, resetGatewaySessionMessageSubscriptionCoordinator as c, SessionProjectionRunStatus as d, SessionProjectionScope as f, projectLiveSessionMessage as g, createSessionProjection as h, GatewaySessionMessageSubscriptionCoordinatorOptions as i, readAssistantStreamSegmentIdentity as j, isLocallyOptimisticSessionMessage as k, SessionProjectionEvent as l, SessionProjectionState as m, GatewaySessionMessageSubscription as n, getGatewaySessionMessageSubscriptionCoordinator as o, SessionProjectionSnapshotOptions as p, GatewaySessionMessageSubscriptionCoordinator as r, releaseGatewaySessionMessageSubscription as s, GatewaySessionMessageRequestClient as t, SessionProjectionRun as u, reduceSessionProjection as v, hasSessionProjectionAcceptedFinal as w, SessionProjectionGatewayRunEvent as x, isSessionProjectionErrorMessage as y, normalizeDeviceMetadataForAuth as z };
|