@openclaw/gateway-client 2026.7.2-beta.5 → 2026.7.2-beta.6
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/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +8 -6
- package/dist/{protocol-client-Cj1WAoMt.d.mts → protocol-client-BfBHwA5H.d.mts} +3 -1
- package/dist/{readiness-CPiKyi1s.d.mts → readiness-BJT_oUZE.d.mts} +1 -1
- package/dist/readiness.d.mts +1 -1
- package/dist/{reconnect-policy-CkzLe1_K.mjs → session-subscriptions-BV7MxYiL.mjs} +638 -12
- package/dist/session-subscriptions-DrhzqL6v.d.mts +282 -0
- package/dist/timeouts.d.mts +5 -1
- package/dist/timeouts.mjs +12 -1
- package/package.json +2 -2
- package/dist/browser-device-auth-Bp297Rtf.d.mts +0 -130
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { ConnectParams, HelloOk } from "@openclaw/gateway-protocol";
|
|
2
|
+
|
|
3
|
+
//#region packages/gateway-client/src/device-auth.d.ts
|
|
4
|
+
declare function normalizeDeviceMetadataForAuth(value?: string | null): string;
|
|
5
|
+
type DeviceAuthPayloadParams = {
|
|
6
|
+
deviceId: string;
|
|
7
|
+
clientId: string;
|
|
8
|
+
clientMode: string;
|
|
9
|
+
role: string;
|
|
10
|
+
scopes: string[];
|
|
11
|
+
signedAtMs: number;
|
|
12
|
+
token?: string | null;
|
|
13
|
+
nonce: string;
|
|
14
|
+
};
|
|
15
|
+
type DeviceAuthPayloadV3Params = DeviceAuthPayloadParams & {
|
|
16
|
+
platform?: string | null;
|
|
17
|
+
deviceFamily?: string | null;
|
|
18
|
+
};
|
|
19
|
+
declare function buildDeviceAuthPayload(params: DeviceAuthPayloadParams): string;
|
|
20
|
+
declare function buildDeviceAuthPayloadV3(params: DeviceAuthPayloadV3Params): string;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region packages/gateway-client/src/connect-auth.d.ts
|
|
23
|
+
type GatewayConnectAuthSelection = {
|
|
24
|
+
authToken?: string;
|
|
25
|
+
authBootstrapToken?: string;
|
|
26
|
+
authDeviceToken?: string;
|
|
27
|
+
authPassword?: string;
|
|
28
|
+
authApprovalRuntimeToken?: string;
|
|
29
|
+
authAgentRuntimeIdentityToken?: string;
|
|
30
|
+
signatureToken?: string;
|
|
31
|
+
resolvedDeviceToken?: string;
|
|
32
|
+
storedToken?: string;
|
|
33
|
+
storedScopes?: string[];
|
|
34
|
+
usingStoredDeviceToken?: boolean;
|
|
35
|
+
};
|
|
36
|
+
declare function selectGatewayConnectAuth(params: {
|
|
37
|
+
token?: string;
|
|
38
|
+
bootstrapToken?: string;
|
|
39
|
+
deviceToken?: string;
|
|
40
|
+
password?: string;
|
|
41
|
+
approvalRuntimeToken?: string;
|
|
42
|
+
agentRuntimeIdentityToken?: string;
|
|
43
|
+
storedToken?: string;
|
|
44
|
+
storedScopes?: string[];
|
|
45
|
+
pendingDeviceTokenRetry?: boolean;
|
|
46
|
+
trustedDeviceTokenRetry?: boolean;
|
|
47
|
+
preferBootstrapToken?: boolean;
|
|
48
|
+
}): GatewayConnectAuthSelection;
|
|
49
|
+
declare function buildGatewayConnectAuth(selected: GatewayConnectAuthSelection): ConnectParams["auth"];
|
|
50
|
+
declare function resolveGatewayConnectScopes(params: {
|
|
51
|
+
requestedScopes?: string[];
|
|
52
|
+
usingStoredDeviceToken?: boolean;
|
|
53
|
+
storedScopes?: string[];
|
|
54
|
+
defaultScopes: readonly string[];
|
|
55
|
+
}): string[];
|
|
56
|
+
declare function shouldRetryGatewayWithDeviceToken(params: {
|
|
57
|
+
retryBudgetUsed: boolean;
|
|
58
|
+
currentDeviceToken?: string;
|
|
59
|
+
explicitToken?: string;
|
|
60
|
+
storedToken?: string;
|
|
61
|
+
trustedEndpoint: boolean;
|
|
62
|
+
canRetryWithDeviceTokenHint?: boolean;
|
|
63
|
+
errorDetails?: unknown;
|
|
64
|
+
}): boolean;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region packages/gateway-client/src/browser-device-auth.d.ts
|
|
67
|
+
type GatewayBrowserDeviceIdentity = {
|
|
68
|
+
deviceId: string;
|
|
69
|
+
publicKey: string;
|
|
70
|
+
sign: (payload: string) => Promise<string>;
|
|
71
|
+
};
|
|
72
|
+
type GatewayBrowserDeviceTokenRecord = {
|
|
73
|
+
token: string;
|
|
74
|
+
scopes: string[];
|
|
75
|
+
};
|
|
76
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
77
|
+
type GatewayBrowserDeviceTokenStore = {
|
|
78
|
+
load: (params: {
|
|
79
|
+
clientId: string;
|
|
80
|
+
deviceId: string;
|
|
81
|
+
role: string;
|
|
82
|
+
}) => MaybePromise<GatewayBrowserDeviceTokenRecord | null>;
|
|
83
|
+
store: (params: {
|
|
84
|
+
clientId: string;
|
|
85
|
+
deviceId: string;
|
|
86
|
+
role: string;
|
|
87
|
+
token: string;
|
|
88
|
+
scopes: string[];
|
|
89
|
+
}) => MaybePromise<void>;
|
|
90
|
+
clear: (params: {
|
|
91
|
+
clientId: string;
|
|
92
|
+
deviceId: string;
|
|
93
|
+
role: string;
|
|
94
|
+
}) => MaybePromise<void>;
|
|
95
|
+
};
|
|
96
|
+
type GatewayBrowserDeviceAuthPlan = {
|
|
97
|
+
clientId: string;
|
|
98
|
+
role: string;
|
|
99
|
+
identity: GatewayBrowserDeviceIdentity | null;
|
|
100
|
+
selectedAuth: GatewayConnectAuthSelection;
|
|
101
|
+
scopes: string[];
|
|
102
|
+
device?: NonNullable<ConnectParams["device"]>;
|
|
103
|
+
auth?: ConnectParams["auth"];
|
|
104
|
+
};
|
|
105
|
+
/** Browser-safe device pairing and issued-token lifecycle shared by first-party UI clients. */
|
|
106
|
+
declare class GatewayBrowserDeviceAuthLifecycle {
|
|
107
|
+
private readonly deps;
|
|
108
|
+
constructor(deps: {
|
|
109
|
+
loadIdentity: () => Promise<GatewayBrowserDeviceIdentity | null>;
|
|
110
|
+
tokenStore: GatewayBrowserDeviceTokenStore;
|
|
111
|
+
nowMs?: () => number;
|
|
112
|
+
});
|
|
113
|
+
buildPlan(params: {
|
|
114
|
+
client: ConnectParams["client"];
|
|
115
|
+
role: string;
|
|
116
|
+
defaultScopes: readonly string[];
|
|
117
|
+
bootstrapScopes?: readonly string[];
|
|
118
|
+
token?: string;
|
|
119
|
+
bootstrapToken?: string;
|
|
120
|
+
password?: string;
|
|
121
|
+
pendingDeviceTokenRetry?: boolean;
|
|
122
|
+
trustedDeviceTokenRetry?: boolean;
|
|
123
|
+
preferBootstrapToken?: boolean;
|
|
124
|
+
nonce: string | null;
|
|
125
|
+
}): Promise<GatewayBrowserDeviceAuthPlan>;
|
|
126
|
+
acceptHello(hello: Pick<HelloOk, "auth">, plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
127
|
+
clearStoredToken(plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region packages/gateway-client/src/session-projection.d.ts
|
|
131
|
+
/** Browser-safe identity and replay rules shared by Gateway conversation clients. */
|
|
132
|
+
type SessionMessageEnvelope = {
|
|
133
|
+
messageId?: unknown;
|
|
134
|
+
messageSeq?: unknown;
|
|
135
|
+
clientRunId?: unknown;
|
|
136
|
+
runId?: unknown;
|
|
137
|
+
idempotencyKey?: unknown;
|
|
138
|
+
};
|
|
139
|
+
type SessionMessageIdentity = {
|
|
140
|
+
role: string;
|
|
141
|
+
id: string | null;
|
|
142
|
+
sequence: number | null;
|
|
143
|
+
idempotencyKey: string | null;
|
|
144
|
+
runId: string | null;
|
|
145
|
+
isImported: boolean;
|
|
146
|
+
externalSource: string | null;
|
|
147
|
+
};
|
|
148
|
+
type SessionProjectionScope = {
|
|
149
|
+
sessionKey?: string;
|
|
150
|
+
sessionId?: string;
|
|
151
|
+
agentId?: string;
|
|
152
|
+
lifecycleRevision?: number | string;
|
|
153
|
+
activeLeafEntryId?: string | null;
|
|
154
|
+
};
|
|
155
|
+
type SessionProjectionSnapshotOptions = {
|
|
156
|
+
shouldIncludeMessage?: (message: unknown) => boolean;
|
|
157
|
+
};
|
|
158
|
+
type SessionProjectionRunStatus = "streaming" | "completed" | "error" | "aborted" | "timeout" | "yielded";
|
|
159
|
+
type SessionProjectionRun = {
|
|
160
|
+
runId: string;
|
|
161
|
+
status: SessionProjectionRunStatus;
|
|
162
|
+
message?: unknown;
|
|
163
|
+
acceptedFinalMessageIdentities?: readonly string[];
|
|
164
|
+
stopReason?: string;
|
|
165
|
+
errorKind?: string;
|
|
166
|
+
errorMessage?: string;
|
|
167
|
+
};
|
|
168
|
+
type SessionProjectionGatewayRunEvent = {
|
|
169
|
+
state?: unknown;
|
|
170
|
+
yielded?: unknown;
|
|
171
|
+
} & Partial<Record<"runId" | "message" | "stopReason" | "errorKind" | "errorMessage", unknown>>;
|
|
172
|
+
type SessionProjectionRunTransition = {
|
|
173
|
+
projection: SessionProjectionState;
|
|
174
|
+
previousRun: SessionProjectionRun | undefined;
|
|
175
|
+
currentRun: SessionProjectionRun | undefined;
|
|
176
|
+
};
|
|
177
|
+
type SessionProjectionEntry = {
|
|
178
|
+
message: unknown;
|
|
179
|
+
identity: SessionMessageIdentity | null;
|
|
180
|
+
live: boolean;
|
|
181
|
+
pending: boolean;
|
|
182
|
+
pendingRunId: string | null;
|
|
183
|
+
};
|
|
184
|
+
type SessionProjectionState = {
|
|
185
|
+
scope: SessionProjectionScope;
|
|
186
|
+
entries: readonly SessionProjectionEntry[];
|
|
187
|
+
messages: readonly unknown[];
|
|
188
|
+
runs: Readonly<Record<string, SessionProjectionRun>>;
|
|
189
|
+
hasTransportGap: boolean;
|
|
190
|
+
};
|
|
191
|
+
type ScopedSessionProjectionEvent = SessionProjectionScope & {
|
|
192
|
+
scope?: SessionProjectionScope;
|
|
193
|
+
};
|
|
194
|
+
type SessionProjectionEvent = ScopedSessionProjectionEvent & ({
|
|
195
|
+
type: "snapshotLoaded";
|
|
196
|
+
messages: readonly unknown[];
|
|
197
|
+
options?: SessionProjectionSnapshotOptions;
|
|
198
|
+
} | ({
|
|
199
|
+
type: "messagePersisted";
|
|
200
|
+
message: unknown;
|
|
201
|
+
envelope?: SessionMessageEnvelope;
|
|
202
|
+
} & SessionMessageEnvelope) | {
|
|
203
|
+
type: "sendPending";
|
|
204
|
+
message: unknown;
|
|
205
|
+
runId?: string;
|
|
206
|
+
idempotencyKey?: string;
|
|
207
|
+
} | {
|
|
208
|
+
type: "sendAcknowledged";
|
|
209
|
+
runId?: string;
|
|
210
|
+
idempotencyKey?: string;
|
|
211
|
+
previousRunId?: string;
|
|
212
|
+
} | {
|
|
213
|
+
type: "sendFailed";
|
|
214
|
+
runId: string;
|
|
215
|
+
} | {
|
|
216
|
+
type: "runDelta";
|
|
217
|
+
runId: string;
|
|
218
|
+
message?: unknown;
|
|
219
|
+
} | (Omit<SessionProjectionRun, "acceptedFinalMessageIdentities"> & {
|
|
220
|
+
type: "runTerminal";
|
|
221
|
+
status: Exclude<SessionProjectionRunStatus, "streaming">;
|
|
222
|
+
}) | {
|
|
223
|
+
type: "sessionReset";
|
|
224
|
+
} | {
|
|
225
|
+
type: "transportGap";
|
|
226
|
+
} | {
|
|
227
|
+
type: "reconnected";
|
|
228
|
+
});
|
|
229
|
+
/** History and status markers carry transcript order even when they have no chat role. */
|
|
230
|
+
declare function readSessionMessageSequence(message: unknown, envelope?: SessionMessageEnvelope): number | null;
|
|
231
|
+
/** Run ownership normalizes a user-turn suffix without changing its persisted send key. */
|
|
232
|
+
declare function normalizeSessionProjectionRunId(value: unknown): string | null;
|
|
233
|
+
/** Persisted transcript facts win over envelope projections and provider-local import IDs. */
|
|
234
|
+
declare function readSessionMessageIdentity(message: unknown, envelope?: SessionMessageEnvelope): SessionMessageIdentity | null;
|
|
235
|
+
/** Local turns have no durable transcript metadata beyond their own optional send key. */
|
|
236
|
+
declare function isLocallyOptimisticSessionMessage(message: unknown): boolean;
|
|
237
|
+
declare function createSessionProjection(scope?: SessionProjectionScope, messages?: readonly unknown[]): SessionProjectionState;
|
|
238
|
+
declare function projectLiveSessionMessage(state: SessionProjectionState, message: unknown, envelope?: SessionMessageEnvelope, scope?: SessionProjectionScope): SessionProjectionState;
|
|
239
|
+
/** Only observed live events and this client's pending turns may survive an older snapshot. */
|
|
240
|
+
declare function reconcileSessionProjectionSnapshot(state: SessionProjectionState, messages: readonly unknown[], scope?: SessionProjectionScope, options?: SessionProjectionSnapshotOptions): SessionProjectionState;
|
|
241
|
+
/** Replayed finals are recognized against this run's bounded canonical terminal history. */
|
|
242
|
+
declare function hasSessionProjectionAcceptedFinal(run: SessionProjectionRun | undefined, message: unknown): boolean;
|
|
243
|
+
/** Reduces durable events, snapshots, and transport lifecycle without client-specific policy. */
|
|
244
|
+
declare function reduceSessionProjection(state: SessionProjectionState, event: SessionProjectionEvent): SessionProjectionState;
|
|
245
|
+
/** Normalizes Gateway run envelopes once for every browser and terminal adapter. */
|
|
246
|
+
declare function reduceSessionProjectionRunEvent(projection: SessionProjectionState, event: SessionProjectionGatewayRunEvent, scope?: SessionProjectionScope): SessionProjectionRunTransition | null;
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region packages/gateway-client/src/session-subscriptions.d.ts
|
|
249
|
+
type GatewaySessionMessageRequestClient = {
|
|
250
|
+
request<T = unknown>(method: string, params: Record<string, unknown>): Promise<T>;
|
|
251
|
+
};
|
|
252
|
+
type GatewaySessionMessageSubscription = {
|
|
253
|
+
key: string;
|
|
254
|
+
agentId?: string | null;
|
|
255
|
+
includeApprovals?: true;
|
|
256
|
+
approvalReplay?: unknown;
|
|
257
|
+
};
|
|
258
|
+
type GatewaySessionMessageSubscriptionOptions = {
|
|
259
|
+
agentId?: string | null;
|
|
260
|
+
includeApprovals?: boolean;
|
|
261
|
+
};
|
|
262
|
+
type GatewaySessionMessageSubscriptionCoordinatorOptions = {
|
|
263
|
+
keysEquivalent?: (left: string, right: string) => boolean;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* One Gateway connection owns one targeted observer per canonical session.
|
|
267
|
+
* Approval delivery is an upgrade of that observer, never a second observer.
|
|
268
|
+
*/
|
|
269
|
+
declare class GatewaySessionMessageSubscriptionCoordinator {
|
|
270
|
+
#private;
|
|
271
|
+
constructor(client: GatewaySessionMessageRequestClient, options?: GatewaySessionMessageSubscriptionCoordinatorOptions);
|
|
272
|
+
configure(options?: GatewaySessionMessageSubscriptionCoordinatorOptions): this;
|
|
273
|
+
acquire(key: string, options?: GatewaySessionMessageSubscriptionOptions): Promise<GatewaySessionMessageSubscription>;
|
|
274
|
+
release(subscription: GatewaySessionMessageSubscription): Promise<void>;
|
|
275
|
+
/** A reconnect retires leases without touching the next connection's observers. */
|
|
276
|
+
reset(): void;
|
|
277
|
+
}
|
|
278
|
+
declare function getGatewaySessionMessageSubscriptionCoordinator(client: GatewaySessionMessageRequestClient, options?: GatewaySessionMessageSubscriptionCoordinatorOptions): GatewaySessionMessageSubscriptionCoordinator;
|
|
279
|
+
declare function resetGatewaySessionMessageSubscriptionCoordinator(client: GatewaySessionMessageRequestClient): void;
|
|
280
|
+
declare function releaseGatewaySessionMessageSubscription(subscription: GatewaySessionMessageSubscription): Promise<void>;
|
|
281
|
+
//#endregion
|
|
282
|
+
export { GatewayBrowserDeviceAuthLifecycle as A, buildDeviceAuthPayload as B, normalizeSessionProjectionRunId as C, reconcileSessionProjectionSnapshot as D, readSessionMessageSequence as E, GatewayConnectAuthSelection as F, normalizeDeviceMetadataForAuth as H, buildGatewayConnectAuth as I, resolveGatewayConnectScopes as L, GatewayBrowserDeviceIdentity as M, GatewayBrowserDeviceTokenRecord as N, reduceSessionProjection as O, GatewayBrowserDeviceTokenStore as P, selectGatewayConnectAuth as R, isLocallyOptimisticSessionMessage as S, readSessionMessageIdentity as T, buildDeviceAuthPayloadV3 as V, SessionProjectionScope as _, GatewaySessionMessageSubscriptionOptions as a, createSessionProjection as b, resetGatewaySessionMessageSubscriptionCoordinator as c, SessionProjectionEntry as d, SessionProjectionEvent as f, SessionProjectionRunTransition as g, SessionProjectionRunStatus as h, GatewaySessionMessageSubscriptionCoordinatorOptions as i, GatewayBrowserDeviceAuthPlan as j, reduceSessionProjectionRunEvent as k, SessionMessageEnvelope as l, SessionProjectionRun as m, GatewaySessionMessageSubscription as n, getGatewaySessionMessageSubscriptionCoordinator as o, SessionProjectionGatewayRunEvent as p, GatewaySessionMessageSubscriptionCoordinator as r, releaseGatewaySessionMessageSubscription as s, GatewaySessionMessageRequestClient as t, SessionMessageIdentity as u, SessionProjectionSnapshotOptions as v, projectLiveSessionMessage as w, hasSessionProjectionAcceptedFinal as x, SessionProjectionState as y, shouldRetryGatewayWithDeviceToken as z };
|
package/dist/timeouts.d.mts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
declare const MAX_SAFE_TIMEOUT_DELAY_MS = 2147483647;
|
|
4
4
|
/** Default server-side window for gateway preauth handshakes. */
|
|
5
5
|
declare const DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = 15000;
|
|
6
|
+
/** Starts the browser-safe deadline that covers Gateway connect preparation and hello. */
|
|
7
|
+
declare function startGatewayConnectTimeout(onTimeout: () => void): ReturnType<typeof setTimeout>;
|
|
8
|
+
/** Clears either pending Gateway handshake phase without retaining its timer. */
|
|
9
|
+
declare function clearGatewayConnectTimeout(timer: ReturnType<typeof setTimeout> | null): null;
|
|
6
10
|
/** Default deadline for a single non-streaming Gateway request. */
|
|
7
11
|
declare const DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS = 30000;
|
|
8
12
|
/** Minimum client watchdog delay for connect challenge setup. */
|
|
@@ -36,4 +40,4 @@ declare function resolvePreauthHandshakeTimeoutMs(params?: {
|
|
|
36
40
|
configuredTimeoutMs?: number | null;
|
|
37
41
|
}): number;
|
|
38
42
|
//#endregion
|
|
39
|
-
export { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, addSafeTimeoutDelayGraceMs, clampConnectChallengeTimeoutMs, getConnectChallengeTimeoutMsFromEnv, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs };
|
|
43
|
+
export { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, addSafeTimeoutDelayGraceMs, clampConnectChallengeTimeoutMs, clearGatewayConnectTimeout, getConnectChallengeTimeoutMsFromEnv, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs, startGatewayConnectTimeout };
|
package/dist/timeouts.mjs
CHANGED
|
@@ -12,6 +12,17 @@ function isTestRuntimeEnv(env) {
|
|
|
12
12
|
const MAX_SAFE_TIMEOUT_DELAY_MS = 2147483647;
|
|
13
13
|
/** Default server-side window for gateway preauth handshakes. */
|
|
14
14
|
const DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = 15e3;
|
|
15
|
+
/** Starts the browser-safe deadline that covers Gateway connect preparation and hello. */
|
|
16
|
+
function startGatewayConnectTimeout(onTimeout) {
|
|
17
|
+
const timer = setTimeout(onTimeout, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS);
|
|
18
|
+
timer.unref?.();
|
|
19
|
+
return timer;
|
|
20
|
+
}
|
|
21
|
+
/** Clears either pending Gateway handshake phase without retaining its timer. */
|
|
22
|
+
function clearGatewayConnectTimeout(timer) {
|
|
23
|
+
if (timer !== null) clearTimeout(timer);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
15
26
|
/** Default deadline for a single non-streaming Gateway request. */
|
|
16
27
|
const DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS = 3e4;
|
|
17
28
|
/** Minimum client watchdog delay for connect challenge setup. */
|
|
@@ -74,4 +85,4 @@ function resolvePreauthHandshakeTimeoutMs(params) {
|
|
|
74
85
|
return DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS;
|
|
75
86
|
}
|
|
76
87
|
//#endregion
|
|
77
|
-
export { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, addSafeTimeoutDelayGraceMs, clampConnectChallengeTimeoutMs, getConnectChallengeTimeoutMsFromEnv, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs };
|
|
88
|
+
export { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, addSafeTimeoutDelayGraceMs, clampConnectChallengeTimeoutMs, clearGatewayConnectTimeout, getConnectChallengeTimeoutMsFromEnv, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs, startGatewayConnectTimeout };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/gateway-client",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.6",
|
|
4
4
|
"description": "Reference WebSocket client for the OpenClaw Gateway protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"client",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"ipaddr.js": "2.4.0",
|
|
56
56
|
"ws": "8.21.1",
|
|
57
|
-
"@openclaw/gateway-protocol": "2026.7.2-beta.
|
|
57
|
+
"@openclaw/gateway-protocol": "2026.7.2-beta.6"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=22.19.0"
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { ConnectParams, HelloOk } from "@openclaw/gateway-protocol";
|
|
2
|
-
|
|
3
|
-
//#region packages/gateway-client/src/device-auth.d.ts
|
|
4
|
-
declare function normalizeDeviceMetadataForAuth(value?: string | null): string;
|
|
5
|
-
type DeviceAuthPayloadParams = {
|
|
6
|
-
deviceId: string;
|
|
7
|
-
clientId: string;
|
|
8
|
-
clientMode: string;
|
|
9
|
-
role: string;
|
|
10
|
-
scopes: string[];
|
|
11
|
-
signedAtMs: number;
|
|
12
|
-
token?: string | null;
|
|
13
|
-
nonce: string;
|
|
14
|
-
};
|
|
15
|
-
type DeviceAuthPayloadV3Params = DeviceAuthPayloadParams & {
|
|
16
|
-
platform?: string | null;
|
|
17
|
-
deviceFamily?: string | null;
|
|
18
|
-
};
|
|
19
|
-
declare function buildDeviceAuthPayload(params: DeviceAuthPayloadParams): string;
|
|
20
|
-
declare function buildDeviceAuthPayloadV3(params: DeviceAuthPayloadV3Params): string;
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region packages/gateway-client/src/connect-auth.d.ts
|
|
23
|
-
type GatewayConnectAuthSelection = {
|
|
24
|
-
authToken?: string;
|
|
25
|
-
authBootstrapToken?: string;
|
|
26
|
-
authDeviceToken?: string;
|
|
27
|
-
authPassword?: string;
|
|
28
|
-
authApprovalRuntimeToken?: string;
|
|
29
|
-
authAgentRuntimeIdentityToken?: string;
|
|
30
|
-
signatureToken?: string;
|
|
31
|
-
resolvedDeviceToken?: string;
|
|
32
|
-
storedToken?: string;
|
|
33
|
-
storedScopes?: string[];
|
|
34
|
-
usingStoredDeviceToken?: boolean;
|
|
35
|
-
};
|
|
36
|
-
declare function selectGatewayConnectAuth(params: {
|
|
37
|
-
token?: string;
|
|
38
|
-
bootstrapToken?: string;
|
|
39
|
-
deviceToken?: string;
|
|
40
|
-
password?: string;
|
|
41
|
-
approvalRuntimeToken?: string;
|
|
42
|
-
agentRuntimeIdentityToken?: string;
|
|
43
|
-
storedToken?: string;
|
|
44
|
-
storedScopes?: string[];
|
|
45
|
-
pendingDeviceTokenRetry?: boolean;
|
|
46
|
-
trustedDeviceTokenRetry?: boolean;
|
|
47
|
-
preferBootstrapToken?: boolean;
|
|
48
|
-
}): GatewayConnectAuthSelection;
|
|
49
|
-
declare function buildGatewayConnectAuth(selected: GatewayConnectAuthSelection): ConnectParams["auth"];
|
|
50
|
-
declare function resolveGatewayConnectScopes(params: {
|
|
51
|
-
requestedScopes?: string[];
|
|
52
|
-
usingStoredDeviceToken?: boolean;
|
|
53
|
-
storedScopes?: string[];
|
|
54
|
-
defaultScopes: readonly string[];
|
|
55
|
-
}): string[];
|
|
56
|
-
declare function shouldRetryGatewayWithDeviceToken(params: {
|
|
57
|
-
retryBudgetUsed: boolean;
|
|
58
|
-
currentDeviceToken?: string;
|
|
59
|
-
explicitToken?: string;
|
|
60
|
-
storedToken?: string;
|
|
61
|
-
trustedEndpoint: boolean;
|
|
62
|
-
canRetryWithDeviceTokenHint?: boolean;
|
|
63
|
-
errorDetails?: unknown;
|
|
64
|
-
}): boolean;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region packages/gateway-client/src/browser-device-auth.d.ts
|
|
67
|
-
type GatewayBrowserDeviceIdentity = {
|
|
68
|
-
deviceId: string;
|
|
69
|
-
publicKey: string;
|
|
70
|
-
sign: (payload: string) => Promise<string>;
|
|
71
|
-
};
|
|
72
|
-
type GatewayBrowserDeviceTokenRecord = {
|
|
73
|
-
token: string;
|
|
74
|
-
scopes: string[];
|
|
75
|
-
};
|
|
76
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
77
|
-
type GatewayBrowserDeviceTokenStore = {
|
|
78
|
-
load: (params: {
|
|
79
|
-
clientId: string;
|
|
80
|
-
deviceId: string;
|
|
81
|
-
role: string;
|
|
82
|
-
}) => MaybePromise<GatewayBrowserDeviceTokenRecord | null>;
|
|
83
|
-
store: (params: {
|
|
84
|
-
clientId: string;
|
|
85
|
-
deviceId: string;
|
|
86
|
-
role: string;
|
|
87
|
-
token: string;
|
|
88
|
-
scopes: string[];
|
|
89
|
-
}) => MaybePromise<void>;
|
|
90
|
-
clear: (params: {
|
|
91
|
-
clientId: string;
|
|
92
|
-
deviceId: string;
|
|
93
|
-
role: string;
|
|
94
|
-
}) => MaybePromise<void>;
|
|
95
|
-
};
|
|
96
|
-
type GatewayBrowserDeviceAuthPlan = {
|
|
97
|
-
clientId: string;
|
|
98
|
-
role: string;
|
|
99
|
-
identity: GatewayBrowserDeviceIdentity | null;
|
|
100
|
-
selectedAuth: GatewayConnectAuthSelection;
|
|
101
|
-
scopes: string[];
|
|
102
|
-
device?: NonNullable<ConnectParams["device"]>;
|
|
103
|
-
auth?: ConnectParams["auth"];
|
|
104
|
-
};
|
|
105
|
-
/** Browser-safe device pairing and issued-token lifecycle shared by first-party UI clients. */
|
|
106
|
-
declare class GatewayBrowserDeviceAuthLifecycle {
|
|
107
|
-
private readonly deps;
|
|
108
|
-
constructor(deps: {
|
|
109
|
-
loadIdentity: () => Promise<GatewayBrowserDeviceIdentity | null>;
|
|
110
|
-
tokenStore: GatewayBrowserDeviceTokenStore;
|
|
111
|
-
nowMs?: () => number;
|
|
112
|
-
});
|
|
113
|
-
buildPlan(params: {
|
|
114
|
-
client: ConnectParams["client"];
|
|
115
|
-
role: string;
|
|
116
|
-
defaultScopes: readonly string[];
|
|
117
|
-
bootstrapScopes?: readonly string[];
|
|
118
|
-
token?: string;
|
|
119
|
-
bootstrapToken?: string;
|
|
120
|
-
password?: string;
|
|
121
|
-
pendingDeviceTokenRetry?: boolean;
|
|
122
|
-
trustedDeviceTokenRetry?: boolean;
|
|
123
|
-
preferBootstrapToken?: boolean;
|
|
124
|
-
nonce: string | null;
|
|
125
|
-
}): Promise<GatewayBrowserDeviceAuthPlan>;
|
|
126
|
-
acceptHello(hello: Pick<HelloOk, "auth">, plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
127
|
-
clearStoredToken(plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
export { GatewayBrowserDeviceTokenStore as a, resolveGatewayConnectScopes as c, buildDeviceAuthPayload as d, buildDeviceAuthPayloadV3 as f, GatewayBrowserDeviceTokenRecord as i, selectGatewayConnectAuth as l, GatewayBrowserDeviceAuthPlan as n, GatewayConnectAuthSelection as o, normalizeDeviceMetadataForAuth as p, GatewayBrowserDeviceIdentity as r, buildGatewayConnectAuth as s, GatewayBrowserDeviceAuthLifecycle as t, shouldRetryGatewayWithDeviceToken as u };
|