@openclaw/gateway-client 2026.9.8 → 2026.10.1-beta.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.
@@ -13,13 +13,7 @@ type GatewayConnectAuthSelection = {
13
13
  storedScopes?: string[];
14
14
  usingStoredDeviceToken?: boolean;
15
15
  };
16
- declare function selectGatewayConnectAuth(params: {
17
- token?: string;
18
- bootstrapToken?: string;
19
- deviceToken?: string;
20
- password?: string;
21
- approvalRuntimeToken?: string;
22
- agentRuntimeIdentityToken?: string;
16
+ declare function selectGatewayConnectAuth(params: NonNullable<ConnectParams["auth"]> & {
23
17
  storedToken?: string;
24
18
  storedScopes?: string[];
25
19
  pendingDeviceTokenRetry?: boolean;
@@ -1,10 +1,10 @@
1
1
  import { A as normalizeSessionProjectionRunId, C as reduceSessionProjectionRunEvent, D as SessionMessageIdentity, E as SessionMessageEnvelope, F as gatewayOriginScope, I as mergeChatStreamMessage, L as buildDeviceAuthPayload, M as readSessionMessageIdentity, N as readSessionMessageSequence, O as SessionProjectionEntry, P as gatewayCredentialScope, R as buildDeviceAuthPayloadV3, S as SessionProjectionRunTransition, T as readSessionProjectionFinalMessageIdentity, _ as reconcileSessionProjectionSnapshot, a as GatewaySessionMessageSubscriptionOptions, b as projectSessionTerminalReplyMessage, c as resetGatewaySessionMessageSubscriptionCoordinator, d as SessionProjectionRunStatus, f as SessionProjectionScope, g as projectLiveSessionMessage, h as createSessionProjection, i as GatewaySessionMessageSubscriptionCoordinatorOptions, j as readAssistantStreamSegmentIdentity, k as isLocallyOptimisticSessionMessage, l as SessionProjectionEvent, m as SessionProjectionState, n as GatewaySessionMessageSubscription, o as getGatewaySessionMessageSubscriptionCoordinator, p as SessionProjectionSnapshotOptions, r as GatewaySessionMessageSubscriptionCoordinator, s as releaseGatewaySessionMessageSubscription, t as GatewaySessionMessageRequestClient, u as SessionProjectionRun, v as reduceSessionProjection, w as hasSessionProjectionAcceptedFinal, x as SessionProjectionGatewayRunEvent, y as isSessionProjectionErrorMessage, z as normalizeDeviceMetadataForAuth } from "./session-subscriptions-Bcq6_wtR.mjs";
2
- import { a as GatewayBrowserDeviceTokenStore, c as resolveGatewayConnectScopes, i as GatewayBrowserDeviceTokenRecord, l as selectGatewayConnectAuth, n as GatewayBrowserDeviceAuthPlan, o as GatewayConnectAuthSelection, r as GatewayBrowserDeviceIdentity, s as buildGatewayConnectAuth, t as GatewayBrowserDeviceAuthLifecycle, u as shouldRetryGatewayWithDeviceToken } from "./browser-device-auth-DoPo-sPB.mjs";
2
+ import { a as GatewayBrowserDeviceTokenStore, c as resolveGatewayConnectScopes, i as GatewayBrowserDeviceTokenRecord, l as selectGatewayConnectAuth, n as GatewayBrowserDeviceAuthPlan, o as GatewayConnectAuthSelection, r as GatewayBrowserDeviceIdentity, s as buildGatewayConnectAuth, t as GatewayBrowserDeviceAuthLifecycle, u as shouldRetryGatewayWithDeviceToken } from "./browser-device-auth-_UweR4aN.mjs";
3
3
  import { i as isGatewayProtocolResponseError, n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-CtVhe3Bj.mjs";
4
4
  import { a as GatewayProtocolConnectAuthority, c as GatewayProtocolTiming, i as GatewayProtocolCloseContext, l as GatewayProtocolRequestTiming, o as GatewayProtocolSocket, s as GatewayProtocolSocketHandlers, t as GatewayProtocolClient } from "./protocol-client-DT451Msj.mjs";
5
5
  import { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, resolveSafeTimeoutDelayMs } from "./timeouts.mjs";
6
6
  import { ConnectParams as ConnectParams$1, GATEWAY_SERVER_CAPS } from "@openclaw/gateway-protocol/frame-guards";
7
- import { ConnectParams, ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol";
7
+ import { ChannelsStatusResult, ConnectParams, ErrorShape, EventFrame, HelloOk, QuestionRecord } from "@openclaw/gateway-protocol";
8
8
  export * from "@openclaw/gateway-protocol/connect-error-details";
9
9
  export * from "@openclaw/gateway-protocol/gateway-error-details";
10
10
  export * from "@openclaw/gateway-protocol/client-info";
@@ -47,4 +47,4 @@ export declare function shouldPauseGatewayReconnect(params: {
47
47
  clientVersionMismatchIsTerminal?: boolean;
48
48
  }): boolean;
49
49
  //#endregion
50
- export { type ConnectParams, DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, type ErrorShape, type EventFrame, GATEWAY_SERVER_CAPS, GatewayBrowserDeviceAuthLifecycle, GatewayBrowserDeviceAuthPlan, GatewayBrowserDeviceIdentity, GatewayBrowserDeviceTokenRecord, GatewayBrowserDeviceTokenStore, GatewayConnectAuthSelection, GatewayProtocolClient, type GatewayProtocolCloseContext, type GatewayProtocolConnectAuthority, GatewayProtocolRequestError, type GatewayProtocolRequestOptions, GatewayProtocolRequestTimeoutError, type GatewayProtocolRequestTiming, type GatewayProtocolSocket, type GatewayProtocolSocketHandlers, type GatewayProtocolTiming, GatewaySessionMessageRequestClient, GatewaySessionMessageSubscription, GatewaySessionMessageSubscriptionCoordinator, GatewaySessionMessageSubscriptionCoordinatorOptions, GatewaySessionMessageSubscriptionOptions, type HelloOk, type SessionMessageEnvelope, type SessionMessageIdentity, type SessionProjectionEntry, SessionProjectionEvent, type SessionProjectionGatewayRunEvent, SessionProjectionRun, SessionProjectionRunStatus, type SessionProjectionRunTransition, SessionProjectionScope, SessionProjectionSnapshotOptions, SessionProjectionState, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isGatewayProtocolResponseError, isLocallyOptimisticSessionMessage, isSessionProjectionErrorMessage, mergeChatStreamMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, projectSessionTerminalReplyMessage, readAssistantStreamSegmentIdentity, readSessionMessageIdentity, readSessionMessageSequence, readSessionProjectionFinalMessageIdentity, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveGatewayConnectScopes, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth, shouldRetryGatewayWithDeviceToken };
50
+ export { type ChannelsStatusResult, type ConnectParams, DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, type ErrorShape, type EventFrame, GATEWAY_SERVER_CAPS, GatewayBrowserDeviceAuthLifecycle, GatewayBrowserDeviceAuthPlan, GatewayBrowserDeviceIdentity, GatewayBrowserDeviceTokenRecord, GatewayBrowserDeviceTokenStore, GatewayConnectAuthSelection, GatewayProtocolClient, type GatewayProtocolCloseContext, type GatewayProtocolConnectAuthority, GatewayProtocolRequestError, type GatewayProtocolRequestOptions, GatewayProtocolRequestTimeoutError, type GatewayProtocolRequestTiming, type GatewayProtocolSocket, type GatewayProtocolSocketHandlers, type GatewayProtocolTiming, GatewaySessionMessageRequestClient, GatewaySessionMessageSubscription, GatewaySessionMessageSubscriptionCoordinator, GatewaySessionMessageSubscriptionCoordinatorOptions, GatewaySessionMessageSubscriptionOptions, type HelloOk, type QuestionRecord, type SessionMessageEnvelope, type SessionMessageIdentity, type SessionProjectionEntry, SessionProjectionEvent, type SessionProjectionGatewayRunEvent, SessionProjectionRun, SessionProjectionRunStatus, type SessionProjectionRunTransition, SessionProjectionScope, SessionProjectionSnapshotOptions, SessionProjectionState, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isGatewayProtocolResponseError, isLocallyOptimisticSessionMessage, isSessionProjectionErrorMessage, mergeChatStreamMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, projectSessionTerminalReplyMessage, readAssistantStreamSegmentIdentity, readSessionMessageIdentity, readSessionMessageSequence, readSessionProjectionFinalMessageIdentity, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveGatewayConnectScopes, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth, shouldRetryGatewayWithDeviceToken };
package/dist/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as selectGatewayConnectAuth, C as isGatewayProtocolResponseError, D as GatewayBrowserDeviceAuthLifecycle, E as gatewayOriginScope, I as buildDeviceAuthPayload, L as buildDeviceAuthPayloadV3, M as mergeChatStreamMessage, N as asNullableRecord, O as buildGatewayConnectAuth, R as normalizeDeviceMetadataForAuth, S as GatewayProtocolRequestTimeoutError, T as gatewayCredentialScope, _ as readSessionMessageIdentity, a as createSessionProjection, b as GatewayProtocolClient, c as reduceSessionProjection, d as readSessionProjectionFinalMessageIdentity, f as isSessionProjectionErrorMessage, g as readAssistantStreamSegmentIdentity, h as normalizeSessionProjectionRunId, i as resetGatewaySessionMessageSubscriptionCoordinator, j as shouldRetryGatewayWithDeviceToken, k as resolveGatewayConnectScopes, l as reduceSessionProjectionRunEvent, m as isLocallyOptimisticSessionMessage, n as getGatewaySessionMessageSubscriptionCoordinator, o as projectLiveSessionMessage, p as projectSessionTerminalReplyMessage, r as releaseGatewaySessionMessageSubscription, s as reconcileSessionProjectionSnapshot, t as GatewaySessionMessageSubscriptionCoordinator, u as hasSessionProjectionAcceptedFinal, v as readSessionMessageSequence, w as resolveModelCatalogConnect, x as GatewayProtocolRequestError, y as shouldPauseGatewayReconnect } from "./session-subscriptions-LtlX9oRQ.mjs";
1
+ import { A as resolveGatewayConnectScopes, B as buildDeviceAuthPayloadV3, C as isGatewayProtocolResponseError, D as gatewayOriginScope, E as gatewayCredentialScope, F as mergeChatStreamMessage, I as asNullableRecord, M as shouldRetryGatewayWithDeviceToken, O as GatewayBrowserDeviceAuthLifecycle, S as GatewayProtocolRequestTimeoutError, T as resolveModelCatalogConnect, V as normalizeDeviceMetadataForAuth, _ as readSessionMessageIdentity, a as createSessionProjection, b as GatewayProtocolClient, c as reduceSessionProjection, d as readSessionProjectionFinalMessageIdentity, f as isSessionProjectionErrorMessage, g as readAssistantStreamSegmentIdentity, h as normalizeSessionProjectionRunId, i as resetGatewaySessionMessageSubscriptionCoordinator, j as selectGatewayConnectAuth, k as buildGatewayConnectAuth, l as reduceSessionProjectionRunEvent, m as isLocallyOptimisticSessionMessage, n as getGatewaySessionMessageSubscriptionCoordinator, o as projectLiveSessionMessage, p as projectSessionTerminalReplyMessage, r as releaseGatewaySessionMessageSubscription, s as reconcileSessionProjectionSnapshot, t as GatewaySessionMessageSubscriptionCoordinator, u as hasSessionProjectionAcceptedFinal, v as readSessionMessageSequence, x as GatewayProtocolRequestError, y as shouldPauseGatewayReconnect, z as buildDeviceAuthPayload } from "./session-subscriptions-D5CpDUGt.mjs";
2
2
  import { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, resolveSafeTimeoutDelayMs } from "./timeouts.mjs";
3
3
  import { GATEWAY_SERVER_CAPS } from "@openclaw/gateway-protocol/frame-guards";
4
4
  export * from "@openclaw/gateway-protocol/connect-error-details";
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { A as normalizeSessionProjectionRunId, C as reduceSessionProjectionRunEvent, D as SessionMessageIdentity, E as SessionMessageEnvelope, F as gatewayOriginScope, I as mergeChatStreamMessage, L as buildDeviceAuthPayload, M as readSessionMessageIdentity, N as readSessionMessageSequence, O as SessionProjectionEntry, P as gatewayCredentialScope, R as buildDeviceAuthPayloadV3, S as SessionProjectionRunTransition, T as readSessionProjectionFinalMessageIdentity, _ as reconcileSessionProjectionSnapshot, a as GatewaySessionMessageSubscriptionOptions, b as projectSessionTerminalReplyMessage, c as resetGatewaySessionMessageSubscriptionCoordinator, d as SessionProjectionRunStatus, f as SessionProjectionScope, g as projectLiveSessionMessage, h as createSessionProjection, i as GatewaySessionMessageSubscriptionCoordinatorOptions, j as readAssistantStreamSegmentIdentity, k as isLocallyOptimisticSessionMessage, l as SessionProjectionEvent, m as SessionProjectionState, n as GatewaySessionMessageSubscription, o as getGatewaySessionMessageSubscriptionCoordinator, p as SessionProjectionSnapshotOptions, r as GatewaySessionMessageSubscriptionCoordinator, s as releaseGatewaySessionMessageSubscription, t as GatewaySessionMessageRequestClient, u as SessionProjectionRun, v as reduceSessionProjection, w as hasSessionProjectionAcceptedFinal, x as SessionProjectionGatewayRunEvent, y as isSessionProjectionErrorMessage, z as normalizeDeviceMetadataForAuth } from "./session-subscriptions-Bcq6_wtR.mjs";
2
- import { a as GatewayBrowserDeviceTokenStore, c as resolveGatewayConnectScopes, i as GatewayBrowserDeviceTokenRecord, l as selectGatewayConnectAuth, n as GatewayBrowserDeviceAuthPlan, o as GatewayConnectAuthSelection, r as GatewayBrowserDeviceIdentity, s as buildGatewayConnectAuth, t as GatewayBrowserDeviceAuthLifecycle, u as shouldRetryGatewayWithDeviceToken } from "./browser-device-auth-DoPo-sPB.mjs";
2
+ import { a as GatewayBrowserDeviceTokenStore, c as resolveGatewayConnectScopes, i as GatewayBrowserDeviceTokenRecord, l as selectGatewayConnectAuth, n as GatewayBrowserDeviceAuthPlan, o as GatewayConnectAuthSelection, r as GatewayBrowserDeviceIdentity, s as buildGatewayConnectAuth, t as GatewayBrowserDeviceAuthLifecycle, u as shouldRetryGatewayWithDeviceToken } from "./browser-device-auth-_UweR4aN.mjs";
3
3
  import { i as isGatewayProtocolResponseError } from "./protocol-request-CtVhe3Bj.mjs";
4
4
  import { n as GatewayClientCloseInfo, r as GatewayClientConnectionMetadata } from "./protocol-client-DT451Msj.mjs";
5
5
  import { 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 } from "./timeouts.mjs";
6
- import { _ as isGatewayConnectAssemblyError, a as startGatewayClientWithReadinessWait, c as waitForEventLoopReady, d as GatewayClientHostDeps, f as GatewayClientOptions, g as GatewayClientRequestError, h as GatewayReconnectPausedInfo, i as startGatewayClientWhenEventLoopReady, l as DeviceIdentity, m as GatewayClientRequestTimeoutError, n as GatewayClientStartReadinessOptions, o as EventLoopReadyOptions, p as GatewayClientRequestOptions, r as GatewayClientStartable, s as EventLoopReadyResult, t as EventLoopReadyWaiter, u as GatewayClient, v as DeviceAuthTokenRecord } from "./readiness-Cj5C24o2.mjs";
6
+ import { _ as isGatewayConnectAssemblyError, a as startGatewayClientWithReadinessWait, c as waitForEventLoopReady, d as GatewayClientHostDeps, f as GatewayClientOptions, g as GatewayClientRequestError, h as GatewayReconnectPausedInfo, i as startGatewayClientWhenEventLoopReady, l as DeviceIdentity, m as GatewayClientRequestTimeoutError, n as GatewayClientStartReadinessOptions, o as EventLoopReadyOptions, p as GatewayClientRequestOptions, r as GatewayClientStartable, s as EventLoopReadyResult, t as EventLoopReadyWaiter, u as GatewayClient, v as DeviceAuthTokenRecord } from "./readiness-CLaFwfd4.mjs";
7
7
  import { GatewayScopeUpgrade, ScopeUpgradeBinding, ScopeUpgradeOptions, ScopeUpgradeOutcome } from "./scope-upgrade.mjs";
8
8
  //#region packages/gateway-client/src/run-recovery-text.d.ts
9
9
  export type RecoveryRequest = (method: string, params: Record<string, unknown>, signal: AbortSignal) => Promise<unknown>;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { A as selectGatewayConnectAuth, C as isGatewayProtocolResponseError, D as GatewayBrowserDeviceAuthLifecycle, E as gatewayOriginScope, F as isRecord, I as buildDeviceAuthPayload, L as buildDeviceAuthPayloadV3, M as mergeChatStreamMessage, O as buildGatewayConnectAuth, P as asRecord, R as normalizeDeviceMetadataForAuth, S as GatewayProtocolRequestTimeoutError, T as gatewayCredentialScope, _ as readSessionMessageIdentity, a as createSessionProjection, b as GatewayProtocolClient, c as reduceSessionProjection, d as readSessionProjectionFinalMessageIdentity, f as isSessionProjectionErrorMessage, g as readAssistantStreamSegmentIdentity, h as normalizeSessionProjectionRunId, i as resetGatewaySessionMessageSubscriptionCoordinator, j as shouldRetryGatewayWithDeviceToken, k as resolveGatewayConnectScopes, l as reduceSessionProjectionRunEvent, m as isLocallyOptimisticSessionMessage, n as getGatewaySessionMessageSubscriptionCoordinator, o as projectLiveSessionMessage, p as projectSessionTerminalReplyMessage, r as releaseGatewaySessionMessageSubscription, s as reconcileSessionProjectionSnapshot, t as GatewaySessionMessageSubscriptionCoordinator, u as hasSessionProjectionAcceptedFinal, v as readSessionMessageSequence, w as resolveModelCatalogConnect, x as GatewayProtocolRequestError, y as shouldPauseGatewayReconnect } from "./session-subscriptions-LtlX9oRQ.mjs";
1
+ import { A as resolveGatewayConnectScopes, B as buildDeviceAuthPayloadV3, C as isGatewayProtocolResponseError, D as gatewayOriginScope, E as gatewayCredentialScope, F as mergeChatStreamMessage, L as asRecord, M as shouldRetryGatewayWithDeviceToken, N as normalizeLowercaseStringOrEmpty, O as GatewayBrowserDeviceAuthLifecycle, P as normalizeOptionalString, R as isRecord, S as GatewayProtocolRequestTimeoutError, T as resolveModelCatalogConnect, V as normalizeDeviceMetadataForAuth, _ as readSessionMessageIdentity, a as createSessionProjection, b as GatewayProtocolClient, c as reduceSessionProjection, d as readSessionProjectionFinalMessageIdentity, f as isSessionProjectionErrorMessage, g as readAssistantStreamSegmentIdentity, h as normalizeSessionProjectionRunId, i as resetGatewaySessionMessageSubscriptionCoordinator, j as selectGatewayConnectAuth, k as buildGatewayConnectAuth, l as reduceSessionProjectionRunEvent, m as isLocallyOptimisticSessionMessage, n as getGatewaySessionMessageSubscriptionCoordinator, o as projectLiveSessionMessage, p as projectSessionTerminalReplyMessage, r as releaseGatewaySessionMessageSubscription, s as reconcileSessionProjectionSnapshot, t as GatewaySessionMessageSubscriptionCoordinator, u as hasSessionProjectionAcceptedFinal, v as readSessionMessageSequence, w as raceWithTimeout, x as GatewayProtocolRequestError, y as shouldPauseGatewayReconnect, z as buildDeviceAuthPayload } from "./session-subscriptions-D5CpDUGt.mjs";
2
2
  import { 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 } from "./timeouts.mjs";
3
3
  import { rawDataToString } from "./websocket-data.mjs";
4
- import { n as startGatewayClientWithReadinessWait, r as waitForEventLoopReady, t as startGatewayClientWhenEventLoopReady } from "./readiness-CrWxd4TI.mjs";
4
+ import { n as startGatewayClientWithReadinessWait, r as waitForEventLoopReady, t as startGatewayClientWhenEventLoopReady } from "./readiness-DnB0NLBq.mjs";
5
5
  import { GatewayScopeUpgrade } from "./scope-upgrade.mjs";
6
6
  import { createRequire } from "node:module";
7
7
  import { ConnectErrorDetailCodes, formatConnectErrorMessage, readConnectErrorDetailCode } from "@openclaw/gateway-protocol/connect-error-details";
@@ -13,26 +13,6 @@ import ipaddr from "ipaddr.js";
13
13
  import { isIP } from "node:net";
14
14
  import { TLSSocket, checkServerIdentity } from "node:tls";
15
15
  import path from "node:path";
16
- //#region packages/normalization-core/src/string-coerce.ts
17
- /** Trims string input and returns null for non-strings or empty strings. */
18
- function normalizeNullableString(value) {
19
- if (typeof value !== "string") return null;
20
- const trimmed = value.trim();
21
- return trimmed ? trimmed : null;
22
- }
23
- /** Trims string input and returns undefined for non-strings or empty strings. */
24
- function normalizeOptionalString(value) {
25
- return normalizeNullableString(value) ?? void 0;
26
- }
27
- /** Lowercases a normalized optional string. */
28
- function normalizeOptionalLowercaseString(value) {
29
- return normalizeOptionalString(value)?.toLowerCase();
30
- }
31
- /** Lowercases a normalized string or returns an empty string when absent. */
32
- function normalizeLowercaseStringOrEmpty(value) {
33
- return normalizeOptionalLowercaseString(value) ?? "";
34
- }
35
- //#endregion
36
16
  //#region packages/net-policy/src/redact-sensitive-url.ts
37
17
  const SENSITIVE_URL_QUERY_PARAM_NAMES = /* @__PURE__ */ new Set([
38
18
  "token",
@@ -358,7 +338,8 @@ function parseCanonicalIpAddress(raw) {
358
338
  function normalizeIpAddress(raw) {
359
339
  const parsed = parseCanonicalIpAddress(raw);
360
340
  if (!parsed) return;
361
- return normalizeLowercaseStringOrEmpty(normalizeIpv4MappedAddress(parsed).toString());
341
+ const normalized = normalizeIpv4MappedAddress(parsed);
342
+ return normalizeLowercaseStringOrEmpty(normalized.toString());
362
343
  }
363
344
  /** True when a canonical IP literal is loopback, including IPv4-mapped IPv6. */
364
345
  function isLoopbackIpAddress(raw) {
@@ -591,11 +572,8 @@ function isSecureWebSocketUrl(rawUrl, options) {
591
572
  const protocol = url.protocol === "https:" ? "wss:" : url.protocol === "http:" ? "ws:" : url.protocol;
592
573
  if (protocol === "wss:") return true;
593
574
  if (protocol !== "ws:") return false;
594
- if (isGatewayLoopbackHost(url.hostname) || isTrustedPlaintextWebSocketHost(url.hostname)) return true;
595
- if (options?.allowPrivateWs === true) {
596
- const hostForIpCheck = url.hostname.startsWith("[") && url.hostname.endsWith("]") ? url.hostname.slice(1, -1) : url.hostname;
597
- return isPrivateOrLoopbackHost(url.hostname) || parseGatewayIpAddress(hostForIpCheck) === void 0;
598
- }
575
+ if (isTrustedPlaintextWebSocketHost(url.hostname)) return true;
576
+ if (options?.allowPrivateWs === true) return parseGatewayIpAddress(url.hostname.startsWith("[") && url.hostname.endsWith("]") ? url.hostname.slice(1, -1) : url.hostname) === void 0;
599
577
  return false;
600
578
  } catch {
601
579
  return false;
@@ -956,16 +934,11 @@ var GatewayClient = class {
956
934
  async stopAndWait(opts) {
957
935
  const stopPromise = this.beginStop();
958
936
  const timeoutMs = opts?.timeoutMs === void 0 ? STOP_AND_WAIT_TIMEOUT_MS : resolveSafeTimeoutDelayMs(opts.timeoutMs);
959
- let timeout = null;
960
937
  try {
961
- await Promise.race([stopPromise, new Promise((_, reject) => {
962
- timeout = setTimeout(() => {
963
- reject(/* @__PURE__ */ new Error(`gateway client stop timed out after ${timeoutMs}ms`));
964
- }, timeoutMs);
965
- timeout.unref?.();
966
- })]);
938
+ await raceWithTimeout(Promise.resolve(stopPromise), timeoutMs, () => {
939
+ throw new Error(`gateway client stop timed out after ${timeoutMs}ms`);
940
+ }, { ref: false });
967
941
  } finally {
968
- if (timeout) clearTimeout(timeout);
969
942
  await this.deviceAuth.drain();
970
943
  }
971
944
  }
@@ -1003,7 +976,6 @@ var GatewayClient = class {
1003
976
  return null;
1004
977
  }
1005
978
  createPendingStop(ws) {
1006
- if (this.pendingStop?.ws === ws) return this.pendingStop;
1007
979
  let resolve = () => {};
1008
980
  const promise = new Promise((done) => {
1009
981
  resolve = done;
@@ -79,7 +79,7 @@ declare class GatewayClientRequestTimeoutError extends GatewayProtocolRequestTim
79
79
  requestSent: boolean;
80
80
  });
81
81
  }
82
- type GatewayClientOptions = GatewayWebSocketTargetOptions & {
82
+ type GatewayClientOptions = GatewayWebSocketTargetOptions & NonNullable<ConnectParams["auth"]> & {
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>>;
@@ -92,14 +92,8 @@ type GatewayClientOptions = GatewayWebSocketTargetOptions & {
92
92
  tickWatchMinIntervalMs?: number;
93
93
  tickWatchTimeoutMs?: number;
94
94
  requestTimeoutMs?: number;
95
- token?: string;
96
- bootstrapToken?: string;
97
95
  /** Prefer one setup credential for the first successful device-auth exchange. */
98
96
  preferBootstrapToken?: boolean;
99
- deviceToken?: string;
100
- password?: string;
101
- approvalRuntimeToken?: string;
102
- agentRuntimeIdentityToken?: string;
103
97
  instanceId?: string;
104
98
  clientName?: GatewayClientName;
105
99
  clientDisplayName?: string;
@@ -21,16 +21,13 @@ async function waitForEventLoopReady(options = {}) {
21
21
  return await new Promise((resolve) => {
22
22
  let settled = false;
23
23
  let timer = null;
24
- const clearTimer = () => {
24
+ const finish = (ready, aborted = false) => {
25
+ if (settled) return;
26
+ settled = true;
25
27
  if (timer) {
26
28
  clearTimeout(timer);
27
29
  timer = null;
28
30
  }
29
- };
30
- const finish = (ready, aborted = false) => {
31
- if (settled) return;
32
- settled = true;
33
- clearTimer();
34
31
  signal?.removeEventListener("abort", onAbort);
35
32
  resolve({
36
33
  ready,
@@ -1,2 +1,2 @@
1
- import { a as startGatewayClientWithReadinessWait, i as startGatewayClientWhenEventLoopReady, n as GatewayClientStartReadinessOptions, r as GatewayClientStartable, t as EventLoopReadyWaiter } from "./readiness-Cj5C24o2.mjs";
1
+ import { a as startGatewayClientWithReadinessWait, i as startGatewayClientWhenEventLoopReady, n as GatewayClientStartReadinessOptions, r as GatewayClientStartable, t as EventLoopReadyWaiter } from "./readiness-CLaFwfd4.mjs";
2
2
  export { EventLoopReadyWaiter, GatewayClientStartReadinessOptions, GatewayClientStartable, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait };
@@ -1,3 +1,3 @@
1
1
  import "./timeouts.mjs";
2
- import { n as startGatewayClientWithReadinessWait, t as startGatewayClientWhenEventLoopReady } from "./readiness-CrWxd4TI.mjs";
2
+ import { n as startGatewayClientWithReadinessWait, t as startGatewayClientWhenEventLoopReady } from "./readiness-DnB0NLBq.mjs";
3
3
  export { startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait };
@@ -1,4 +1,4 @@
1
- import { a as GatewayBrowserDeviceTokenStore } from "./browser-device-auth-DoPo-sPB.mjs";
1
+ import { a as GatewayBrowserDeviceTokenStore } from "./browser-device-auth-_UweR4aN.mjs";
2
2
  import { n as GatewayProtocolRequestOptions } from "./protocol-request-CtVhe3Bj.mjs";
3
3
  //#region packages/gateway-client/src/scope-upgrade.d.ts
4
4
  export type ScopeUpgradeBinding = {
@@ -100,16 +100,33 @@ function mergeChatStreamMessage(previous, payload) {
100
100
  };
101
101
  }
102
102
  //#endregion
103
- //#region packages/gateway-client/src/connect-auth.ts
104
- function normalized(value) {
105
- return typeof value === "string" ? value.trim() || void 0 : void 0;
103
+ //#region packages/normalization-core/src/string-coerce.ts
104
+ /** Trims string input and returns null for non-strings or empty strings. */
105
+ function normalizeNullableString(value) {
106
+ if (typeof value !== "string") return null;
107
+ const trimmed = value.trim();
108
+ return trimmed ? trimmed : null;
109
+ }
110
+ /** Trims string input and returns undefined for non-strings or empty strings. */
111
+ function normalizeOptionalString(value) {
112
+ return normalizeNullableString(value) ?? void 0;
113
+ }
114
+ /** Lowercases a normalized optional string. */
115
+ function normalizeOptionalLowercaseString(value) {
116
+ return normalizeOptionalString(value)?.toLowerCase();
106
117
  }
118
+ /** Lowercases a normalized string or returns an empty string when absent. */
119
+ function normalizeLowercaseStringOrEmpty(value) {
120
+ return normalizeOptionalLowercaseString(value) ?? "";
121
+ }
122
+ //#endregion
123
+ //#region packages/gateway-client/src/connect-auth.ts
107
124
  function selectGatewayConnectAuth(params) {
108
- const authToken = normalized(params.token);
109
- const bootstrapToken = normalized(params.bootstrapToken);
110
- const explicitDeviceToken = normalized(params.deviceToken);
111
- const authPassword = normalized(params.password);
112
- const storedToken = normalized(params.storedToken);
125
+ const authToken = normalizeOptionalString(params.token);
126
+ const bootstrapToken = normalizeOptionalString(params.bootstrapToken);
127
+ const explicitDeviceToken = normalizeOptionalString(params.deviceToken);
128
+ const authPassword = normalizeOptionalString(params.password);
129
+ const storedToken = normalizeOptionalString(params.storedToken);
113
130
  const stored = {
114
131
  storedToken,
115
132
  storedScopes: params.storedScopes
@@ -129,8 +146,8 @@ function selectGatewayConnectAuth(params) {
129
146
  authBootstrapToken,
130
147
  authDeviceToken: useRetryToken ? storedToken : void 0,
131
148
  authPassword,
132
- authApprovalRuntimeToken: normalized(params.approvalRuntimeToken),
133
- authAgentRuntimeIdentityToken: normalized(params.agentRuntimeIdentityToken),
149
+ authApprovalRuntimeToken: normalizeOptionalString(params.approvalRuntimeToken),
150
+ authAgentRuntimeIdentityToken: normalizeOptionalString(params.agentRuntimeIdentityToken),
134
151
  signatureToken: selectedToken ?? authBootstrapToken,
135
152
  resolvedDeviceToken,
136
153
  usingStoredDeviceToken,
@@ -186,7 +203,7 @@ var GatewayBrowserDeviceAuthLifecycle = class {
186
203
  storedScopes: selectedAuth.storedScopes,
187
204
  defaultScopes: params.defaultScopes
188
205
  });
189
- if (!identity) return {
206
+ const plan = {
190
207
  clientId: params.client.id,
191
208
  role: params.role,
192
209
  identity,
@@ -194,6 +211,7 @@ var GatewayBrowserDeviceAuthLifecycle = class {
194
211
  scopes,
195
212
  auth: buildGatewayConnectAuth(selectedAuth)
196
213
  };
214
+ if (!identity) return plan;
197
215
  const signedAtMs = params.challengeTs === void 0 ? this.deps.nowMs?.() ?? Date.now() : params.challengeTs;
198
216
  if (typeof signedAtMs !== "number" || !Number.isSafeInteger(signedAtMs) || signedAtMs < 0) throw new Error("gateway connect challenge timestamp invalid");
199
217
  const nonce = params.nonce ?? "";
@@ -209,21 +227,14 @@ var GatewayBrowserDeviceAuthLifecycle = class {
209
227
  platform: params.client.platform,
210
228
  deviceFamily: params.client.deviceFamily
211
229
  });
212
- return {
213
- clientId: params.client.id,
214
- role: params.role,
215
- identity,
216
- selectedAuth,
217
- scopes,
218
- auth: buildGatewayConnectAuth(selectedAuth),
219
- device: {
220
- id: identity.deviceId,
221
- publicKey: identity.publicKey,
222
- signature: await identity.sign(payload),
223
- signedAt: signedAtMs,
224
- nonce
225
- }
230
+ plan.device = {
231
+ id: identity.deviceId,
232
+ publicKey: identity.publicKey,
233
+ signature: await identity.sign(payload),
234
+ signedAt: signedAtMs,
235
+ nonce
226
236
  };
237
+ return plan;
227
238
  }
228
239
  async acceptHello(hello, plan) {
229
240
  const token = hello.auth?.deviceToken?.trim();
@@ -290,6 +301,30 @@ function resolveModelCatalogConnect(params) {
290
301
  //#endregion
291
302
  //#region packages/retry/src/index.ts
292
303
  const MAX_TIMER_TIMEOUT_MS = 2147e6;
304
+ function createAbortError(message, options) {
305
+ const error = new Error(message, options);
306
+ error.name = "AbortError";
307
+ return error;
308
+ }
309
+ /** Bounds observation without cancelling work; a factory starts only after the timer is armed. */
310
+ async function raceWithTimeout(operation, timeoutMs, onTimeout, options = {}) {
311
+ let timer;
312
+ try {
313
+ const deadline = new Promise((resolve, reject) => {
314
+ timer = setTimeout(() => {
315
+ try {
316
+ resolve(onTimeout());
317
+ } catch (error) {
318
+ reject(error);
319
+ }
320
+ }, timeoutMs);
321
+ if (options.ref === false) timer.unref?.();
322
+ });
323
+ return await Promise.race([typeof operation === "function" ? operation() : operation, deadline]);
324
+ } finally {
325
+ clearTimeout(timer);
326
+ }
327
+ }
293
328
  function computeBackoff(policy, attempt) {
294
329
  const base = Math.min(policy.maxMs, policy.initialMs * policy.factor ** Math.max(attempt - 1, 0));
295
330
  const jitter = base * policy.jitter * Math.random();
@@ -311,9 +346,7 @@ async function sleepWithAbort(ms, abortSignal, options = {}) {
311
346
  if (timer) clearTimeout(timer);
312
347
  timer = null;
313
348
  cleanup();
314
- const error = new Error("aborted", { cause: abortSignal?.reason ?? /* @__PURE__ */ new Error("aborted") });
315
- error.name = "AbortError";
316
- reject(error);
349
+ reject(createAbortError("aborted", { cause: abortSignal?.reason ?? /* @__PURE__ */ new Error("aborted") }));
317
350
  };
318
351
  abortSignal?.addEventListener("abort", onAbort, { once: true });
319
352
  if (abortSignal?.aborted) {
@@ -429,18 +462,8 @@ function createRetryRunner(runtime = {}) {
429
462
  const createFailure = runtime.createFailure ?? ((errors) => toRetryError(errors.at(-1) ?? /* @__PURE__ */ new Error("Retry failed")));
430
463
  return async function retryAsync(fn, attemptsOrOptions = 3, initialDelayMs = 300) {
431
464
  const attemptErrors = [];
432
- if (typeof attemptsOrOptions === "number") {
433
- const attempts = resolveAttemptCount(attemptsOrOptions, DEFAULT_RETRY_CONFIG.attempts);
434
- for (let index = 0; index < attempts; index += 1) try {
435
- return await fn();
436
- } catch (err) {
437
- attemptErrors.push(err);
438
- if (index === attempts - 1) break;
439
- await runtimeSleep(resolveRetryDelayMs(initialDelayMs * 2 ** index));
440
- }
441
- throw createFailure(attemptErrors);
442
- }
443
- const options = attemptsOrOptions;
465
+ const numeric = typeof attemptsOrOptions === "number";
466
+ const options = typeof attemptsOrOptions === "number" ? { attempts: attemptsOrOptions } : attemptsOrOptions;
444
467
  const resolved = resolveRetryConfig(DEFAULT_RETRY_CONFIG, options);
445
468
  const maxAttempts = resolved.attempts;
446
469
  const minDelayMs = resolved.minDelayMs;
@@ -454,6 +477,10 @@ function createRetryRunner(runtime = {}) {
454
477
  } catch (err) {
455
478
  attemptErrors.push(err);
456
479
  if (attempt >= maxAttempts || !shouldRetry(err, attempt)) break;
480
+ if (numeric) {
481
+ await runtimeSleep(resolveRetryDelayMs(initialDelayMs * 2 ** (attempt - 1)));
482
+ continue;
483
+ }
457
484
  const context = {
458
485
  attempt,
459
486
  maxAttempts,
@@ -1228,42 +1255,30 @@ function stringifyObjectValue(value, stack, normalizeString, write) {
1228
1255
  return `[${serializedEntries.join(",")}]`;
1229
1256
  }
1230
1257
  const record = value;
1231
- if (normalizeString === preserveString) {
1232
- const fields = Object.keys(record).sort();
1233
- if (write) {
1234
- write("{");
1235
- let separator = "";
1236
- for (const key of fields) {
1237
- write(`${separator}${JSON.stringify(key)}:`);
1238
- write(stringifyStableValue(record[key], stack, normalizeString, write));
1239
- separator = ",";
1240
- }
1241
- write("}");
1242
- return "";
1243
- }
1244
- let fieldIndex = 0;
1245
- for (const key of fields) fields[fieldIndex++] = `${JSON.stringify(key)}:${stringifyStableValue(record[key], stack, normalizeString)}`;
1246
- return `{${fields.join(",")}}`;
1247
- }
1248
- const entries = Object.keys(record).map((key) => ({
1258
+ const keys = Object.keys(record);
1259
+ const fields = normalizeString === preserveString ? keys.sort() : keys.map((key) => ({
1249
1260
  key,
1250
1261
  normalizedKey: normalizeString(key)
1251
1262
  })).sort((left, right) => {
1252
1263
  return compareStableStrings(left.normalizedKey, right.normalizedKey) || compareStableStrings(left.key, right.key);
1253
1264
  });
1254
- const serializedFields = [];
1255
- if (write) {
1256
- write("{");
1257
- let separator = "";
1258
- for (const { key, normalizedKey } of entries) {
1259
- write(`${separator}${JSON.stringify(normalizedKey)}:`);
1265
+ write?.("{");
1266
+ const serializedFields = normalizeString === preserveString ? keys : [];
1267
+ let separator = "";
1268
+ let fieldIndex = 0;
1269
+ for (const field of fields) {
1270
+ const key = typeof field === "string" ? field : field.key;
1271
+ const prefix = `${JSON.stringify(typeof field === "string" ? field : field.normalizedKey)}:`;
1272
+ if (write) {
1273
+ write(`${separator}${prefix}`);
1260
1274
  write(stringifyStableValue(record[key], stack, normalizeString, write));
1261
1275
  separator = ",";
1262
- }
1276
+ } else serializedFields[fieldIndex++] = `${prefix}${stringifyStableValue(record[key], stack, normalizeString)}`;
1277
+ }
1278
+ if (write) {
1263
1279
  write("}");
1264
1280
  return "";
1265
1281
  }
1266
- for (const { key, normalizedKey } of entries) serializedFields.push(`${JSON.stringify(normalizedKey)}:${stringifyStableValue(record[key], stack, normalizeString)}`);
1267
1282
  return `{${serializedFields.join(",")}}`;
1268
1283
  }
1269
1284
  function encodeBase64(value) {
@@ -1277,7 +1292,7 @@ function compareStableStrings(left, right) {
1277
1292
  //#endregion
1278
1293
  //#region packages/gateway-client/src/session-projection-message-identity.ts
1279
1294
  function readSessionProjectionString(value) {
1280
- return typeof value === "string" ? value.trim() || null : null;
1295
+ return normalizeNullableString(value);
1281
1296
  }
1282
1297
  function readPositiveSafeInteger(value) {
1283
1298
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : null;
@@ -2265,4 +2280,4 @@ function releaseGatewaySessionMessageSubscription(subscription) {
2265
2280
  return sessionMessageSubscriptionOwners.get(subscription)?.coordinator.release(subscription) ?? Promise.resolve();
2266
2281
  }
2267
2282
  //#endregion
2268
- export { selectGatewayConnectAuth as A, isGatewayProtocolResponseError as C, GatewayBrowserDeviceAuthLifecycle as D, gatewayOriginScope as E, isRecord as F, buildDeviceAuthPayload as I, buildDeviceAuthPayloadV3 as L, mergeChatStreamMessage as M, asNullableRecord as N, buildGatewayConnectAuth as O, asRecord as P, normalizeDeviceMetadataForAuth as R, GatewayProtocolRequestTimeoutError as S, gatewayCredentialScope as T, readSessionMessageIdentity as _, createSessionProjection as a, GatewayProtocolClient as b, reduceSessionProjection as c, readSessionProjectionFinalMessageIdentity as d, isSessionProjectionErrorMessage as f, readAssistantStreamSegmentIdentity as g, normalizeSessionProjectionRunId as h, resetGatewaySessionMessageSubscriptionCoordinator as i, shouldRetryGatewayWithDeviceToken as j, resolveGatewayConnectScopes as k, reduceSessionProjectionRunEvent as l, isLocallyOptimisticSessionMessage as m, getGatewaySessionMessageSubscriptionCoordinator as n, projectLiveSessionMessage as o, projectSessionTerminalReplyMessage as p, releaseGatewaySessionMessageSubscription as r, reconcileSessionProjectionSnapshot as s, GatewaySessionMessageSubscriptionCoordinator as t, hasSessionProjectionAcceptedFinal as u, readSessionMessageSequence as v, resolveModelCatalogConnect as w, GatewayProtocolRequestError as x, shouldPauseGatewayReconnect as y };
2283
+ export { resolveGatewayConnectScopes as A, buildDeviceAuthPayloadV3 as B, isGatewayProtocolResponseError as C, gatewayOriginScope as D, gatewayCredentialScope as E, mergeChatStreamMessage as F, asNullableRecord as I, asRecord as L, shouldRetryGatewayWithDeviceToken as M, normalizeLowercaseStringOrEmpty as N, GatewayBrowserDeviceAuthLifecycle as O, normalizeOptionalString as P, isRecord as R, GatewayProtocolRequestTimeoutError as S, resolveModelCatalogConnect as T, normalizeDeviceMetadataForAuth as V, readSessionMessageIdentity as _, createSessionProjection as a, GatewayProtocolClient as b, reduceSessionProjection as c, readSessionProjectionFinalMessageIdentity as d, isSessionProjectionErrorMessage as f, readAssistantStreamSegmentIdentity as g, normalizeSessionProjectionRunId as h, resetGatewaySessionMessageSubscriptionCoordinator as i, selectGatewayConnectAuth as j, buildGatewayConnectAuth as k, reduceSessionProjectionRunEvent as l, isLocallyOptimisticSessionMessage as m, getGatewaySessionMessageSubscriptionCoordinator as n, projectLiveSessionMessage as o, projectSessionTerminalReplyMessage as p, releaseGatewaySessionMessageSubscription as r, reconcileSessionProjectionSnapshot as s, GatewaySessionMessageSubscriptionCoordinator as t, hasSessionProjectionAcceptedFinal as u, readSessionMessageSequence as v, raceWithTimeout as w, GatewayProtocolRequestError as x, shouldPauseGatewayReconnect as y, buildDeviceAuthPayload as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/gateway-client",
3
- "version": "2026.9.8",
3
+ "version": "2026.10.1-beta.1",
4
4
  "description": "Reference WebSocket client for the OpenClaw Gateway protocol",
5
5
  "keywords": [
6
6
  "client",
@@ -62,7 +62,7 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "@openclaw/gateway-protocol": "2026.9.8",
65
+ "@openclaw/gateway-protocol": "2026.10.1-beta.1",
66
66
  "ipaddr.js": "2.5.0",
67
67
  "ws": "8.21.3"
68
68
  },