@openclaw/gateway-client 2026.8.1-beta.3 → 2026.8.2
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 +27 -7
- package/dist/{browser-device-auth-Dz6H7eXy.d.mts → browser-device-auth-DoPo-sPB.d.mts} +0 -1
- package/dist/browser.d.mts +6 -7
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +54 -36
- package/dist/{protocol-client-BbN-I582.d.mts → protocol-client-DbX7wQED.d.mts} +2 -2
- package/dist/{protocol-request-D4mVhLxE.d.mts → protocol-request-B5gBmLgq.d.mts} +4 -2
- package/dist/{readiness-JllUDKLg.d.mts → readiness-5KjCokrl.d.mts} +12 -7
- package/dist/readiness.d.mts +1 -1
- package/dist/scope-upgrade.d.mts +7 -9
- package/dist/{session-subscriptions-CKF7acYN.d.mts → session-subscriptions-BZp3uoLS.d.mts} +3 -2
- package/dist/{session-subscriptions-OJnDJHPL.mjs → session-subscriptions-CwSFOFqw.mjs} +59 -17
- package/dist/timeouts.d.mts +15 -16
- package/dist/websocket-data.d.mts +2 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -25,13 +25,26 @@ separate from the Gateway's current wire protocol number reported in `hello-ok`.
|
|
|
25
25
|
|
|
26
26
|
## Install
|
|
27
27
|
|
|
28
|
+
Use the verified stable release with exact pins:
|
|
29
|
+
|
|
28
30
|
```bash
|
|
29
|
-
npm install @openclaw/gateway-client @openclaw/gateway-protocol
|
|
31
|
+
npm install --save-exact @openclaw/gateway-client@2026.8.1 @openclaw/gateway-protocol@2026.8.1
|
|
30
32
|
```
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
See the canonical [installation guide](https://docs.openclaw.ai/gateway/clients#install-the-packages)
|
|
35
|
+
for package/wire-version rules and recovery from reserved `0.0.0` artifacts.
|
|
36
|
+
Test it with the Gateway version you deploy; the root `openclaw` CLI has its own
|
|
37
|
+
package versions and dist-tags.
|
|
38
|
+
|
|
39
|
+
This release declares Node.js `>=22.19.0`. Node consumers use the `ws` transport
|
|
40
|
+
included as a runtime dependency. Browser consumers provide their platform
|
|
41
|
+
WebSocket through the browser-safe protocol client surface.
|
|
42
|
+
|
|
43
|
+
For device-authenticated Node connections, supply `deviceIdentity` (or
|
|
44
|
+
`hostDeps.loadOrCreateDeviceIdentity`) and the `hostDeps.signDevicePayload` and
|
|
45
|
+
`hostDeps.publicKeyRawBase64UrlFromPem` callbacks. The host also owns device-token
|
|
46
|
+
storage through `GatewayClientHostDeps`; the package does not load OpenClaw's
|
|
47
|
+
local identity or credentials automatically.
|
|
35
48
|
|
|
36
49
|
## Entry points
|
|
37
50
|
|
|
@@ -80,9 +93,16 @@ The client waits for the Gateway's `connect.challenge` event before sending its
|
|
|
80
93
|
does not fall back to a pre-challenge handshake. `onHelloOk` fires only after the
|
|
81
94
|
Gateway accepts a compatible connection, so requests should wait for that callback.
|
|
82
95
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
This loopback example uses the default `gateway-client` / `backend` identity.
|
|
97
|
+
It is not a device-pairing example. UI clients should declare their actual `mode`
|
|
98
|
+
and supply the device-auth host callbacks described above; see
|
|
99
|
+
[device identity and pairing](https://docs.openclaw.ai/gateway/protocol#device-identity-and-pairing).
|
|
100
|
+
|
|
101
|
+
For remote connections, prefer `wss://`. The Node client also accepts plaintext
|
|
102
|
+
`ws://` by default for loopback, private/link-local/CGNAT IP addresses, and
|
|
103
|
+
`.local` or `.ts.net` hostnames. This allowlist does not provide encryption:
|
|
104
|
+
authentication material and Gateway traffic must not cross an untrusted network
|
|
105
|
+
without transport security.
|
|
86
106
|
|
|
87
107
|
## Browser clients
|
|
88
108
|
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as gatewayCredentialScope, C as reduceSessionProjection, D as normalizeSessionProjectionRunId, E as SessionMessageIdentity, M as buildDeviceAuthPayload, N as buildDeviceAuthPayloadV3, O as readSessionMessageIdentity, P as normalizeDeviceMetadataForAuth, S as reconcileSessionProjectionSnapshot, T as SessionMessageEnvelope, _ as SessionProjectionState, a as GatewaySessionMessageSubscriptionOptions, b as isLocallyOptimisticSessionMessage, c as resetGatewaySessionMessageSubscriptionCoordinator, d as SessionProjectionGatewayRunEvent, f as SessionProjectionRun, g as SessionProjectionSnapshotOptions, h as SessionProjectionScope, i as GatewaySessionMessageSubscriptionCoordinatorOptions, j as gatewayOriginScope, k as readSessionMessageSequence, l as SessionProjectionEntry, m as SessionProjectionRunTransition, n as GatewaySessionMessageSubscription, o as getGatewaySessionMessageSubscriptionCoordinator, p as SessionProjectionRunStatus, r as GatewaySessionMessageSubscriptionCoordinator, s as releaseGatewaySessionMessageSubscription, t as GatewaySessionMessageRequestClient, u as SessionProjectionEvent, v as createSessionProjection, w as reduceSessionProjectionRunEvent, x as projectLiveSessionMessage, y as hasSessionProjectionAcceptedFinal } from "./session-subscriptions-
|
|
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-
|
|
3
|
-
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-
|
|
4
|
-
import { a as GatewayProtocolTiming, i as GatewayProtocolSocketHandlers, n as GatewayProtocolCloseContext, o as GatewayProtocolRequestTiming, r as GatewayProtocolSocket, t as GatewayProtocolClient } from "./protocol-client-
|
|
1
|
+
import { A as gatewayCredentialScope, C as reduceSessionProjection, D as normalizeSessionProjectionRunId, E as SessionMessageIdentity, M as buildDeviceAuthPayload, N as buildDeviceAuthPayloadV3, O as readSessionMessageIdentity, P as normalizeDeviceMetadataForAuth, S as reconcileSessionProjectionSnapshot, T as SessionMessageEnvelope, _ as SessionProjectionState, a as GatewaySessionMessageSubscriptionOptions, b as isLocallyOptimisticSessionMessage, c as resetGatewaySessionMessageSubscriptionCoordinator, d as SessionProjectionGatewayRunEvent, f as SessionProjectionRun, g as SessionProjectionSnapshotOptions, h as SessionProjectionScope, i as GatewaySessionMessageSubscriptionCoordinatorOptions, j as gatewayOriginScope, k as readSessionMessageSequence, l as SessionProjectionEntry, m as SessionProjectionRunTransition, n as GatewaySessionMessageSubscription, o as getGatewaySessionMessageSubscriptionCoordinator, p as SessionProjectionRunStatus, r as GatewaySessionMessageSubscriptionCoordinator, s as releaseGatewaySessionMessageSubscription, t as GatewaySessionMessageRequestClient, u as SessionProjectionEvent, v as createSessionProjection, w as reduceSessionProjectionRunEvent, x as projectLiveSessionMessage, y as hasSessionProjectionAcceptedFinal } from "./session-subscriptions-BZp3uoLS.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";
|
|
3
|
+
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-B5gBmLgq.mjs";
|
|
4
|
+
import { a as GatewayProtocolTiming, i as GatewayProtocolSocketHandlers, n as GatewayProtocolCloseContext, o as GatewayProtocolRequestTiming, r as GatewayProtocolSocket, t as GatewayProtocolClient } from "./protocol-client-DbX7wQED.mjs";
|
|
5
5
|
import { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, resolveSafeTimeoutDelayMs } from "./timeouts.mjs";
|
|
6
6
|
import { ConnectParams, ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol";
|
|
7
7
|
export * from "@openclaw/gateway-protocol/connect-error-details";
|
|
@@ -9,9 +9,8 @@ export * from "@openclaw/gateway-protocol/client-info";
|
|
|
9
9
|
export * from "@openclaw/gateway-protocol/gateway-error-details";
|
|
10
10
|
export * from "@openclaw/gateway-protocol/startup-unavailable";
|
|
11
11
|
export * from "@openclaw/gateway-protocol/version";
|
|
12
|
-
|
|
13
12
|
//#region packages/gateway-client/src/reconnect-policy.d.ts
|
|
14
|
-
declare function shouldPauseGatewayReconnect(params: {
|
|
13
|
+
export declare function shouldPauseGatewayReconnect(params: {
|
|
15
14
|
details?: unknown;
|
|
16
15
|
deviceTokenRetryPending?: boolean;
|
|
17
16
|
tokenMismatchIsTerminal?: boolean;
|
|
@@ -19,4 +18,4 @@ declare function shouldPauseGatewayReconnect(params: {
|
|
|
19
18
|
clientVersionMismatchIsTerminal?: boolean;
|
|
20
19
|
}): boolean;
|
|
21
20
|
//#endregion
|
|
22
|
-
export { type ConnectParams, DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, type ErrorShape, type EventFrame, GatewayBrowserDeviceAuthLifecycle, GatewayBrowserDeviceAuthPlan, GatewayBrowserDeviceIdentity, GatewayBrowserDeviceTokenRecord, GatewayBrowserDeviceTokenStore, GatewayConnectAuthSelection, GatewayProtocolClient, type GatewayProtocolCloseContext, GatewayProtocolRequestError, type GatewayProtocolRequestOptions, GatewayProtocolRequestTimeoutError, type GatewayProtocolRequestTiming, type GatewayProtocolSocket, type GatewayProtocolSocketHandlers, type GatewayProtocolTiming, GatewaySessionMessageRequestClient, GatewaySessionMessageSubscription, GatewaySessionMessageSubscriptionCoordinator, GatewaySessionMessageSubscriptionCoordinatorOptions, GatewaySessionMessageSubscriptionOptions, type HelloOk, type SessionMessageEnvelope, type SessionMessageIdentity, SessionProjectionEntry, SessionProjectionEvent, SessionProjectionGatewayRunEvent, SessionProjectionRun, SessionProjectionRunStatus, SessionProjectionRunTransition, SessionProjectionScope, SessionProjectionSnapshotOptions, SessionProjectionState, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isLocallyOptimisticSessionMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, readSessionMessageIdentity, readSessionMessageSequence, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveGatewayConnectScopes, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth,
|
|
21
|
+
export { type ConnectParams, DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, type ErrorShape, type EventFrame, GatewayBrowserDeviceAuthLifecycle, GatewayBrowserDeviceAuthPlan, GatewayBrowserDeviceIdentity, GatewayBrowserDeviceTokenRecord, GatewayBrowserDeviceTokenStore, GatewayConnectAuthSelection, GatewayProtocolClient, type GatewayProtocolCloseContext, GatewayProtocolRequestError, type GatewayProtocolRequestOptions, GatewayProtocolRequestTimeoutError, type GatewayProtocolRequestTiming, type GatewayProtocolSocket, type GatewayProtocolSocketHandlers, type GatewayProtocolTiming, GatewaySessionMessageRequestClient, GatewaySessionMessageSubscription, GatewaySessionMessageSubscriptionCoordinator, GatewaySessionMessageSubscriptionCoordinatorOptions, GatewaySessionMessageSubscriptionOptions, type HelloOk, type SessionMessageEnvelope, type SessionMessageIdentity, SessionProjectionEntry, SessionProjectionEvent, SessionProjectionGatewayRunEvent, SessionProjectionRun, SessionProjectionRunStatus, SessionProjectionRunTransition, SessionProjectionScope, SessionProjectionSnapshotOptions, SessionProjectionState, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isLocallyOptimisticSessionMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, readSessionMessageIdentity, readSessionMessageSequence, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveGatewayConnectScopes, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth, shouldRetryGatewayWithDeviceToken };
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as normalizeDeviceMetadataForAuth, C as GatewayBrowserDeviceAuthLifecycle, D as shouldRetryGatewayWithDeviceToken, E as selectGatewayConnectAuth, O as buildDeviceAuthPayload, S as gatewayOriginScope, T as resolveGatewayConnectScopes, _ as GatewayProtocolClient, a as createSessionProjection, c as projectLiveSessionMessage, d as reduceSessionProjectionRunEvent, f as normalizeSessionProjectionRunId, g as shouldPauseGatewayReconnect, i as resetGatewaySessionMessageSubscriptionCoordinator, k as buildDeviceAuthPayloadV3, l as reconcileSessionProjectionSnapshot, m as readSessionMessageSequence, n as getGatewaySessionMessageSubscriptionCoordinator, o as hasSessionProjectionAcceptedFinal, p as readSessionMessageIdentity, r as releaseGatewaySessionMessageSubscription, s as isLocallyOptimisticSessionMessage, t as GatewaySessionMessageSubscriptionCoordinator, u as reduceSessionProjection, v as GatewayProtocolRequestError, w as buildGatewayConnectAuth, x as gatewayCredentialScope, y as GatewayProtocolRequestTimeoutError } from "./session-subscriptions-CwSFOFqw.mjs";
|
|
2
2
|
import { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, resolveSafeTimeoutDelayMs } from "./timeouts.mjs";
|
|
3
3
|
export * from "@openclaw/gateway-protocol/connect-error-details";
|
|
4
4
|
export * from "@openclaw/gateway-protocol/client-info";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { A as gatewayCredentialScope, C as reduceSessionProjection, D as normalizeSessionProjectionRunId, E as SessionMessageIdentity, M as buildDeviceAuthPayload, N as buildDeviceAuthPayloadV3, O as readSessionMessageIdentity, P as normalizeDeviceMetadataForAuth, S as reconcileSessionProjectionSnapshot, T as SessionMessageEnvelope, _ as SessionProjectionState, a as GatewaySessionMessageSubscriptionOptions, b as isLocallyOptimisticSessionMessage, c as resetGatewaySessionMessageSubscriptionCoordinator, d as SessionProjectionGatewayRunEvent, f as SessionProjectionRun, g as SessionProjectionSnapshotOptions, h as SessionProjectionScope, i as GatewaySessionMessageSubscriptionCoordinatorOptions, j as gatewayOriginScope, k as readSessionMessageSequence, l as SessionProjectionEntry, m as SessionProjectionRunTransition, n as GatewaySessionMessageSubscription, o as getGatewaySessionMessageSubscriptionCoordinator, p as SessionProjectionRunStatus, r as GatewaySessionMessageSubscriptionCoordinator, s as releaseGatewaySessionMessageSubscription, t as GatewaySessionMessageRequestClient, u as SessionProjectionEvent, v as createSessionProjection, w as reduceSessionProjectionRunEvent, x as projectLiveSessionMessage, y as hasSessionProjectionAcceptedFinal } from "./session-subscriptions-
|
|
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-
|
|
1
|
+
import { A as gatewayCredentialScope, C as reduceSessionProjection, D as normalizeSessionProjectionRunId, E as SessionMessageIdentity, M as buildDeviceAuthPayload, N as buildDeviceAuthPayloadV3, O as readSessionMessageIdentity, P as normalizeDeviceMetadataForAuth, S as reconcileSessionProjectionSnapshot, T as SessionMessageEnvelope, _ as SessionProjectionState, a as GatewaySessionMessageSubscriptionOptions, b as isLocallyOptimisticSessionMessage, c as resetGatewaySessionMessageSubscriptionCoordinator, d as SessionProjectionGatewayRunEvent, f as SessionProjectionRun, g as SessionProjectionSnapshotOptions, h as SessionProjectionScope, i as GatewaySessionMessageSubscriptionCoordinatorOptions, j as gatewayOriginScope, k as readSessionMessageSequence, l as SessionProjectionEntry, m as SessionProjectionRunTransition, n as GatewaySessionMessageSubscription, o as getGatewaySessionMessageSubscriptionCoordinator, p as SessionProjectionRunStatus, r as GatewaySessionMessageSubscriptionCoordinator, s as releaseGatewaySessionMessageSubscription, t as GatewaySessionMessageRequestClient, u as SessionProjectionEvent, v as createSessionProjection, w as reduceSessionProjectionRunEvent, x as projectLiveSessionMessage, y as hasSessionProjectionAcceptedFinal } from "./session-subscriptions-BZp3uoLS.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";
|
|
3
|
+
import { i as isGatewayProtocolResponseError } from "./protocol-request-B5gBmLgq.mjs";
|
|
3
4
|
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";
|
|
4
|
-
import { _ as GatewayClientRequestTimeoutError, a as startGatewayClientWithReadinessWait, b as GatewayClientRequestError, c as waitForEventLoopReady, d as GatewayClient, f as GatewayClientCloseInfo, g as GatewayClientRequestOptions, h as GatewayClientOptions, i as startGatewayClientWhenEventLoopReady, l as DeviceAuthTokenRecord, m as GatewayClientHostDeps, n as GatewayClientStartReadinessOptions, o as EventLoopReadyOptions, p as GatewayClientConnectionMetadata, r as GatewayClientStartable, s as EventLoopReadyResult, t as EventLoopReadyWaiter, u as DeviceIdentity, v as GatewayReconnectPausedInfo, y as isGatewayConnectAssemblyError } from "./readiness-
|
|
5
|
+
import { _ as GatewayClientRequestTimeoutError, a as startGatewayClientWithReadinessWait, b as GatewayClientRequestError, c as waitForEventLoopReady, d as GatewayClient, f as GatewayClientCloseInfo, g as GatewayClientRequestOptions, h as GatewayClientOptions, i as startGatewayClientWhenEventLoopReady, l as DeviceAuthTokenRecord, m as GatewayClientHostDeps, n as GatewayClientStartReadinessOptions, o as EventLoopReadyOptions, p as GatewayClientConnectionMetadata, r as GatewayClientStartable, s as EventLoopReadyResult, t as EventLoopReadyWaiter, u as DeviceIdentity, v as GatewayReconnectPausedInfo, y as isGatewayConnectAssemblyError } from "./readiness-5KjCokrl.mjs";
|
|
5
6
|
import { GatewayScopeUpgrade, ScopeUpgradeBinding, ScopeUpgradeOptions, ScopeUpgradeOutcome } from "./scope-upgrade.mjs";
|
|
6
|
-
|
|
7
7
|
//#region packages/gateway-client/src/cloudflare-access.d.ts
|
|
8
|
-
declare const CF_ACCESS_CLIENT_ID_HEADER = "CF-Access-Client-Id";
|
|
9
|
-
declare const CF_ACCESS_CLIENT_SECRET_HEADER = "CF-Access-Client-Secret";
|
|
10
|
-
type CloudflareAccessCredentials = Readonly<{
|
|
8
|
+
export declare const CF_ACCESS_CLIENT_ID_HEADER = "CF-Access-Client-Id";
|
|
9
|
+
export declare const CF_ACCESS_CLIENT_SECRET_HEADER = "CF-Access-Client-Secret";
|
|
10
|
+
export type CloudflareAccessCredentials = Readonly<{
|
|
11
11
|
clientId: string;
|
|
12
12
|
clientSecret: string;
|
|
13
13
|
}>;
|
|
14
14
|
/** Build only the two headers Cloudflare Access defines for service-token auth. */
|
|
15
|
-
declare function buildCloudflareAccessHeaders(credentials: CloudflareAccessCredentials): Record<string, string>;
|
|
15
|
+
export declare function buildCloudflareAccessHeaders(credentials: CloudflareAccessCredentials): Record<string, string>;
|
|
16
16
|
//#endregion
|
|
17
|
-
export {
|
|
17
|
+
export { DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, DeviceAuthTokenRecord, DeviceIdentity, EventLoopReadyOptions, EventLoopReadyResult, EventLoopReadyWaiter, GatewayBrowserDeviceAuthLifecycle, GatewayBrowserDeviceAuthPlan, GatewayBrowserDeviceIdentity, GatewayBrowserDeviceTokenRecord, GatewayBrowserDeviceTokenStore, GatewayClient, GatewayClientCloseInfo, GatewayClientConnectionMetadata, GatewayClientHostDeps, GatewayClientOptions, GatewayClientRequestError, GatewayClientRequestOptions, GatewayClientRequestTimeoutError, GatewayClientStartReadinessOptions, GatewayClientStartable, GatewayConnectAuthSelection, GatewayReconnectPausedInfo, GatewayScopeUpgrade, GatewaySessionMessageRequestClient, GatewaySessionMessageSubscription, GatewaySessionMessageSubscriptionCoordinator, GatewaySessionMessageSubscriptionCoordinatorOptions, GatewaySessionMessageSubscriptionOptions, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, ScopeUpgradeBinding, ScopeUpgradeOptions, ScopeUpgradeOutcome, type SessionMessageEnvelope, type SessionMessageIdentity, SessionProjectionEntry, SessionProjectionEvent, SessionProjectionGatewayRunEvent, SessionProjectionRun, SessionProjectionRunStatus, SessionProjectionRunTransition, SessionProjectionScope, SessionProjectionSnapshotOptions, SessionProjectionState, addSafeTimeoutDelayGraceMs, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, clampConnectChallengeTimeoutMs, clearGatewayConnectTimeout, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getConnectChallengeTimeoutMsFromEnv, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isGatewayConnectAssemblyError, isGatewayProtocolResponseError, isLocallyOptimisticSessionMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, readSessionMessageIdentity, readSessionMessageSequence, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolveGatewayConnectScopes, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth, shouldRetryGatewayWithDeviceToken, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait, startGatewayConnectTimeout, waitForEventLoopReady };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as normalizeDeviceMetadataForAuth, C as GatewayBrowserDeviceAuthLifecycle, D as shouldRetryGatewayWithDeviceToken, E as selectGatewayConnectAuth, O as buildDeviceAuthPayload, S as gatewayOriginScope, T as resolveGatewayConnectScopes, _ as GatewayProtocolClient, a as createSessionProjection, b as isGatewayProtocolResponseError, c as projectLiveSessionMessage, d as reduceSessionProjectionRunEvent, f as normalizeSessionProjectionRunId, g as shouldPauseGatewayReconnect, h as isRecord, i as resetGatewaySessionMessageSubscriptionCoordinator, k as buildDeviceAuthPayloadV3, l as reconcileSessionProjectionSnapshot, m as readSessionMessageSequence, n as getGatewaySessionMessageSubscriptionCoordinator, o as hasSessionProjectionAcceptedFinal, p as readSessionMessageIdentity, r as releaseGatewaySessionMessageSubscription, s as isLocallyOptimisticSessionMessage, t as GatewaySessionMessageSubscriptionCoordinator, u as reduceSessionProjection, v as GatewayProtocolRequestError, w as buildGatewayConnectAuth, x as gatewayCredentialScope, y as GatewayProtocolRequestTimeoutError } from "./session-subscriptions-CwSFOFqw.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
4
|
import { n as startGatewayClientWithReadinessWait, r as waitForEventLoopReady, t as startGatewayClientWhenEventLoopReady } from "./readiness-CrWxd4TI.mjs";
|
|
@@ -10,6 +10,7 @@ import { MIN_CLIENT_PROTOCOL_VERSION, MIN_NODE_PROTOCOL_VERSION, MIN_PROBE_PROTO
|
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import { WebSocket } from "ws";
|
|
12
12
|
import ipaddr from "ipaddr.js";
|
|
13
|
+
import { TLSSocket } from "node:tls";
|
|
13
14
|
//#region packages/normalization-core/src/string-coerce.ts
|
|
14
15
|
/** Trims string input and returns null for non-strings or empty strings. */
|
|
15
16
|
function normalizeNullableString(value) {
|
|
@@ -484,6 +485,7 @@ function isSecureWebSocketUrl(rawUrl, options) {
|
|
|
484
485
|
}
|
|
485
486
|
}
|
|
486
487
|
var GatewayWebSocketTransportConfigurationError = class extends Error {};
|
|
488
|
+
var GatewayWebSocketTlsPinError = class extends Error {};
|
|
487
489
|
function resolveGatewayWebSocketTransport(params) {
|
|
488
490
|
const usesTls = isWssUrl(params.url);
|
|
489
491
|
if (params.tlsFingerprint && !usesTls) throw new GatewayWebSocketTransportConfigurationError("gateway tls fingerprint requires wss:// gateway url");
|
|
@@ -499,30 +501,37 @@ function resolveGatewayWebSocketTransport(params) {
|
|
|
499
501
|
const expectedFingerprint = params.tlsFingerprint ? normalizeTlsFingerprint(params.tlsFingerprint) : void 0;
|
|
500
502
|
if (params.tlsFingerprint && !expectedFingerprint) throw new GatewayWebSocketTransportConfigurationError("gateway tls fingerprint must be a SHA-256 fingerprint");
|
|
501
503
|
const options = { ...params.options };
|
|
502
|
-
if (usesTls && expectedFingerprint)
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
504
|
+
if (usesTls && expectedFingerprint) applyGatewayWebSocketTlsPin(options, expectedFingerprint, normalize);
|
|
505
|
+
return { options };
|
|
506
|
+
}
|
|
507
|
+
function applyGatewayWebSocketTlsPin(options, expectedFingerprint, normalize = normalizeTlsFingerprint) {
|
|
508
|
+
options.rejectUnauthorized = false;
|
|
509
|
+
const headers = { ...options.headers };
|
|
510
|
+
const deferredHeaders = Object.entries(headers).filter(([key]) => key.toLowerCase() === "expect");
|
|
511
|
+
for (const [key] of deferredHeaders) delete headers[key];
|
|
512
|
+
options.headers = headers;
|
|
513
|
+
options.finishRequest = (request) => {
|
|
514
|
+
request.once("socket", (socket) => {
|
|
515
|
+
if (!(socket instanceof TLSSocket)) {
|
|
516
|
+
request.destroy(new GatewayWebSocketTlsPinError("gateway tls fingerprint unavailable"));
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const validatePin = () => {
|
|
520
|
+
if (request.destroyed) return;
|
|
521
|
+
const canonicalFingerprint = normalizeTlsFingerprint(socket.getPeerCertificate()?.fingerprint256);
|
|
522
|
+
const fingerprint = canonicalFingerprint ? normalize(canonicalFingerprint) : "";
|
|
523
|
+
if (!fingerprint || fingerprint !== normalize(expectedFingerprint)) {
|
|
524
|
+
request.destroy(new GatewayWebSocketTlsPinError(fingerprint ? "gateway tls fingerprint mismatch" : "gateway tls fingerprint unavailable"));
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
for (const [key, value] of deferredHeaders) if (value !== void 0) request.setHeader(key, value);
|
|
528
|
+
request.end();
|
|
529
|
+
};
|
|
530
|
+
if (socket.secureConnecting) {
|
|
531
|
+
socket.once("secureConnect", validatePin);
|
|
532
|
+
request.once("close", () => socket.off("secureConnect", validatePin));
|
|
533
|
+
} else validatePin();
|
|
534
|
+
});
|
|
526
535
|
};
|
|
527
536
|
}
|
|
528
537
|
//#endregion
|
|
@@ -550,7 +559,7 @@ function resolveHostDeps(overrides) {
|
|
|
550
559
|
}
|
|
551
560
|
const DEFAULT_GATEWAY_CLIENT_URL = "ws://127.0.0.1:18789";
|
|
552
561
|
const DEFAULT_CLIENT_VERSION = "0.0.0";
|
|
553
|
-
const MAX_UPGRADE_ERROR_BODY_BYTES =
|
|
562
|
+
const MAX_UPGRADE_ERROR_BODY_BYTES = 2048;
|
|
554
563
|
const UPGRADE_ERROR_BODY_TIMEOUT_MS = 1e3;
|
|
555
564
|
async function readUpgradeErrorBody(response) {
|
|
556
565
|
return await new Promise((resolve) => {
|
|
@@ -703,6 +712,11 @@ var GatewayClient = class {
|
|
|
703
712
|
},
|
|
704
713
|
notifyStoppedClose: true,
|
|
705
714
|
onConnectError: (error) => this.notifyConnectError(error),
|
|
715
|
+
onReconnectStopped: (error) => this.notifyReconnectPaused({
|
|
716
|
+
code: 1008,
|
|
717
|
+
reason: error.message,
|
|
718
|
+
detailCode: null
|
|
719
|
+
}),
|
|
706
720
|
onParseError: (error) => this.logDebug(`gateway client parse error: ${formatGatewayClientErrorForLog(error)}`),
|
|
707
721
|
onEvent: (event) => this.opts.onEvent?.(event),
|
|
708
722
|
onGap: (info) => this.opts.onGap?.(info),
|
|
@@ -762,7 +776,7 @@ var GatewayClient = class {
|
|
|
762
776
|
env: this.opts.env,
|
|
763
777
|
normalizeTlsFingerprint: this.deps.normalizeTlsFingerprint,
|
|
764
778
|
options: {
|
|
765
|
-
maxPayload:
|
|
779
|
+
maxPayload: 26214400,
|
|
766
780
|
handshakeTimeout: handshakeTimeoutMs,
|
|
767
781
|
...this.opts.origin ? { origin: this.opts.origin } : {},
|
|
768
782
|
...edgeAuthHeaders ? {
|
|
@@ -791,14 +805,8 @@ var GatewayClient = class {
|
|
|
791
805
|
this.transportValidated = false;
|
|
792
806
|
let upgradeError;
|
|
793
807
|
ws.on("open", () => {
|
|
794
|
-
handlers.open();
|
|
795
|
-
const tlsError = transport.validateSocket(ws);
|
|
796
|
-
if (tlsError) {
|
|
797
|
-
handlers.error(tlsError);
|
|
798
|
-
ws.close(1008, tlsError.message);
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
808
|
this.transportValidated = true;
|
|
809
|
+
handlers.open();
|
|
802
810
|
});
|
|
803
811
|
ws.on("message", (data) => handlers.message(rawDataToString(data)));
|
|
804
812
|
ws.on("close", (code, reason) => {
|
|
@@ -810,6 +818,12 @@ var GatewayClient = class {
|
|
|
810
818
|
ws.on("unexpected-response", (request, response) => {
|
|
811
819
|
readUpgradeErrorBody(response).then((body) => {
|
|
812
820
|
const statusCode = response.statusCode;
|
|
821
|
+
let gatewayError;
|
|
822
|
+
try {
|
|
823
|
+
const parsed = JSON.parse(body);
|
|
824
|
+
const parsedError = isRecord(parsed) ? parsed.error : void 0;
|
|
825
|
+
gatewayError = isRecord(parsedError) ? parsedError : void 0;
|
|
826
|
+
} catch {}
|
|
813
827
|
const rawLocation = response.headers.location;
|
|
814
828
|
const location = rawLocation ? redactSensitiveUrlLikeString(Array.isArray(rawLocation) ? rawLocation[0] ?? "" : rawLocation) : void 0;
|
|
815
829
|
upgradeError = new GatewayClientRequestError({
|
|
@@ -819,7 +833,11 @@ var GatewayClient = class {
|
|
|
819
833
|
details: {
|
|
820
834
|
reason: "websocket-upgrade-rejected",
|
|
821
835
|
...statusCode === void 0 ? {} : { httpStatus: statusCode },
|
|
822
|
-
...location ? { location } : {}
|
|
836
|
+
...location ? { location } : {},
|
|
837
|
+
...typeof gatewayError?.type === "string" ? {
|
|
838
|
+
gatewayErrorType: gatewayError.type,
|
|
839
|
+
...typeof gatewayError.message === "string" ? { gatewayErrorMessage: gatewayError.message } : {}
|
|
840
|
+
} : {}
|
|
823
841
|
}
|
|
824
842
|
});
|
|
825
843
|
handlers.error(upgradeError);
|
|
@@ -1325,4 +1343,4 @@ function buildCloudflareAccessHeaders(credentials) {
|
|
|
1325
1343
|
};
|
|
1326
1344
|
}
|
|
1327
1345
|
//#endregion
|
|
1328
|
-
export { CF_ACCESS_CLIENT_ID_HEADER, CF_ACCESS_CLIENT_SECRET_HEADER, DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, GatewayBrowserDeviceAuthLifecycle, GatewayClient, GatewayClientRequestError, GatewayClientRequestTimeoutError, GatewayScopeUpgrade, GatewaySessionMessageSubscriptionCoordinator, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, addSafeTimeoutDelayGraceMs, buildCloudflareAccessHeaders, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, clampConnectChallengeTimeoutMs, clearGatewayConnectTimeout, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getConnectChallengeTimeoutMsFromEnv, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isGatewayConnectAssemblyError, isLocallyOptimisticSessionMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, readSessionMessageIdentity, readSessionMessageSequence, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolveGatewayConnectScopes, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth, shouldRetryGatewayWithDeviceToken, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait, startGatewayConnectTimeout, waitForEventLoopReady };
|
|
1346
|
+
export { CF_ACCESS_CLIENT_ID_HEADER, CF_ACCESS_CLIENT_SECRET_HEADER, DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, GatewayBrowserDeviceAuthLifecycle, GatewayClient, GatewayClientRequestError, GatewayClientRequestTimeoutError, GatewayScopeUpgrade, GatewaySessionMessageSubscriptionCoordinator, MAX_CONNECT_CHALLENGE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_DELAY_MS, MIN_CONNECT_CHALLENGE_TIMEOUT_MS, addSafeTimeoutDelayGraceMs, buildCloudflareAccessHeaders, buildDeviceAuthPayload, buildDeviceAuthPayloadV3, buildGatewayConnectAuth, clampConnectChallengeTimeoutMs, clearGatewayConnectTimeout, createSessionProjection, gatewayCredentialScope, gatewayOriginScope, getConnectChallengeTimeoutMsFromEnv, getGatewaySessionMessageSubscriptionCoordinator, hasSessionProjectionAcceptedFinal, isGatewayConnectAssemblyError, isGatewayProtocolResponseError, isLocallyOptimisticSessionMessage, normalizeDeviceMetadataForAuth, normalizeSessionProjectionRunId, projectLiveSessionMessage, readSessionMessageIdentity, readSessionMessageSequence, reconcileSessionProjectionSnapshot, reduceSessionProjection, reduceSessionProjectionRunEvent, releaseGatewaySessionMessageSubscription, resetGatewaySessionMessageSubscriptionCoordinator, resolveConnectChallengeTimeoutMs, resolveFiniteTimeoutDelayMs, resolveGatewayConnectScopes, resolvePreauthHandshakeTimeoutMs, resolveSafeTimeoutDelayMs, selectGatewayConnectAuth, shouldRetryGatewayWithDeviceToken, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait, startGatewayConnectTimeout, waitForEventLoopReady };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as GatewayProtocolRequestOptions, t as GatewayProtocolRequestError } from "./protocol-request-
|
|
1
|
+
import { n as GatewayProtocolRequestOptions, t as GatewayProtocolRequestError } from "./protocol-request-B5gBmLgq.mjs";
|
|
2
2
|
import { ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol";
|
|
3
|
-
|
|
4
3
|
//#region packages/gateway-client/src/pending-request.d.ts
|
|
5
4
|
type GatewayProtocolRequestTiming = {
|
|
6
5
|
id: string;
|
|
@@ -86,6 +85,7 @@ type GatewayProtocolClientOptions<TPlan> = {
|
|
|
86
85
|
notifyStoppedClose?: boolean;
|
|
87
86
|
onConnectError?: (error: Error) => void;
|
|
88
87
|
onSocketFactoryError?: (error: Error) => void;
|
|
88
|
+
onReconnectStopped?: (error: Error) => void;
|
|
89
89
|
onParseError?: (error: unknown) => void;
|
|
90
90
|
onEvent?: (event: EventFrame) => void;
|
|
91
91
|
onGap?: (info: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorShape } from "@openclaw/gateway-protocol";
|
|
2
|
-
|
|
3
2
|
//#region packages/gateway-client/src/protocol-request.d.ts
|
|
3
|
+
/** Distinguishes correlated Gateway responses from locally constructed transport errors. */
|
|
4
|
+
declare function isGatewayProtocolResponseError(error: unknown): error is GatewayProtocolRequestError;
|
|
4
5
|
type GatewayProtocolRequestOptions = {
|
|
5
6
|
timeoutMs?: number | null;
|
|
6
7
|
expectFinal?: boolean;
|
|
@@ -14,6 +15,7 @@ declare class GatewayProtocolRequestError extends Error {
|
|
|
14
15
|
readonly details?: unknown;
|
|
15
16
|
readonly retryable: boolean;
|
|
16
17
|
readonly retryAfterMs?: number;
|
|
18
|
+
readonly responsePayload?: unknown;
|
|
17
19
|
constructor(error: Partial<ErrorShape>);
|
|
18
20
|
}
|
|
19
21
|
/** A local transport deadline, distinct from a Gateway's authoritative rejection. */
|
|
@@ -29,4 +31,4 @@ declare class GatewayProtocolRequestTimeoutError extends Error {
|
|
|
29
31
|
}, message?: string);
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
32
|
-
export { GatewayProtocolRequestOptions as n, GatewayProtocolRequestTimeoutError as r, GatewayProtocolRequestError as t };
|
|
34
|
+
export { isGatewayProtocolResponseError as i, GatewayProtocolRequestOptions as n, GatewayProtocolRequestTimeoutError as r, GatewayProtocolRequestError as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-
|
|
1
|
+
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-B5gBmLgq.mjs";
|
|
2
|
+
import "./protocol-client-DbX7wQED.mjs";
|
|
2
3
|
import { ConnectParams, ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol/frame-guards";
|
|
3
4
|
import { GatewayClientMode, GatewayClientName } from "@openclaw/gateway-protocol/client-info";
|
|
4
|
-
|
|
5
5
|
//#region packages/gateway-client/src/request-error.d.ts
|
|
6
6
|
declare class GatewayClientRequestError extends GatewayProtocolRequestError {
|
|
7
7
|
constructor(error: Partial<ErrorShape>);
|
|
@@ -69,7 +69,8 @@ declare class GatewayClientRequestTimeoutError extends GatewayProtocolRequestTim
|
|
|
69
69
|
declare function isGatewayConnectAssemblyError(value: unknown): value is Error;
|
|
70
70
|
type GatewayClientOptions = {
|
|
71
71
|
url?: string;
|
|
72
|
-
origin?: string;
|
|
72
|
+
origin?: string;
|
|
73
|
+
/** Already-resolved edge-proxy auth headers (identity-aware proxy in front of the Gateway). */
|
|
73
74
|
edgeAuthHeaders?: Readonly<Record<string, string>>;
|
|
74
75
|
connectChallengeTimeoutMs?: number;
|
|
75
76
|
/**
|
|
@@ -81,7 +82,8 @@ type GatewayClientOptions = {
|
|
|
81
82
|
tickWatchTimeoutMs?: number;
|
|
82
83
|
requestTimeoutMs?: number;
|
|
83
84
|
token?: string;
|
|
84
|
-
bootstrapToken?: string;
|
|
85
|
+
bootstrapToken?: string;
|
|
86
|
+
/** Prefer one setup credential for the first successful device-auth exchange. */
|
|
85
87
|
preferBootstrapToken?: boolean;
|
|
86
88
|
deviceToken?: string;
|
|
87
89
|
password?: string;
|
|
@@ -99,7 +101,8 @@ type GatewayClientOptions = {
|
|
|
99
101
|
scopes?: string[];
|
|
100
102
|
caps?: string[];
|
|
101
103
|
commands?: string[];
|
|
102
|
-
computerUse?: ConnectParams["computerUse"];
|
|
104
|
+
computerUse?: ConnectParams["computerUse"];
|
|
105
|
+
/** @deprecated Compatibility for the shipped v1 node-host connect envelope. */
|
|
103
106
|
workerRuns?: ConnectParams["workerRuns"];
|
|
104
107
|
permissions?: Record<string, boolean>;
|
|
105
108
|
pathEnv?: string;
|
|
@@ -112,7 +115,8 @@ type GatewayClientOptions = {
|
|
|
112
115
|
onEvent?: (evt: EventFrame) => void;
|
|
113
116
|
onHelloOk?: (hello: HelloOk) => void;
|
|
114
117
|
onConnectError?: (err: Error) => void;
|
|
115
|
-
onReconnectPaused?: (info: GatewayReconnectPausedInfo) => void;
|
|
118
|
+
onReconnectPaused?: (info: GatewayReconnectPausedInfo) => void;
|
|
119
|
+
/** Report retryable startup closes for clients that present connection progress. */
|
|
116
120
|
notifyOnStartupRetry?: boolean;
|
|
117
121
|
onClose?: (code: number, reason: string, info?: GatewayClientCloseInfo) => void;
|
|
118
122
|
onGap?: (info: {
|
|
@@ -151,7 +155,8 @@ declare class GatewayClient {
|
|
|
151
155
|
updateNodeManifest(manifest: {
|
|
152
156
|
caps: string[];
|
|
153
157
|
commands: string[];
|
|
154
|
-
computerUse?: ConnectParams["computerUse"];
|
|
158
|
+
computerUse?: ConnectParams["computerUse"];
|
|
159
|
+
/** @deprecated Compatibility for the shipped v1 node-host connect envelope. */
|
|
155
160
|
workerRuns?: ConnectParams["workerRuns"];
|
|
156
161
|
}): void;
|
|
157
162
|
start(): void;
|
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-5KjCokrl.mjs";
|
|
2
2
|
export { EventLoopReadyWaiter, GatewayClientStartReadinessOptions, GatewayClientStartable, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait };
|
package/dist/scope-upgrade.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { a as GatewayBrowserDeviceTokenStore } from "./browser-device-auth-
|
|
2
|
-
import { n as GatewayProtocolRequestOptions } from "./protocol-request-
|
|
3
|
-
|
|
1
|
+
import { a as GatewayBrowserDeviceTokenStore } from "./browser-device-auth-DoPo-sPB.mjs";
|
|
2
|
+
import { n as GatewayProtocolRequestOptions } from "./protocol-request-B5gBmLgq.mjs";
|
|
4
3
|
//#region packages/gateway-client/src/scope-upgrade.d.ts
|
|
5
|
-
type ScopeUpgradeBinding = {
|
|
4
|
+
export type ScopeUpgradeBinding = {
|
|
6
5
|
clientId: string;
|
|
7
6
|
deviceId: string;
|
|
8
7
|
role: string;
|
|
9
8
|
};
|
|
10
|
-
type ScopeUpgradeOutcome = {
|
|
9
|
+
export type ScopeUpgradeOutcome = {
|
|
11
10
|
status: "approved";
|
|
12
11
|
requestId: string;
|
|
13
12
|
scopes: string[];
|
|
@@ -15,14 +14,14 @@ type ScopeUpgradeOutcome = {
|
|
|
15
14
|
status: "rejected" | "expired";
|
|
16
15
|
requestId: string;
|
|
17
16
|
};
|
|
18
|
-
type ScopeUpgradeOptions = {
|
|
17
|
+
export type ScopeUpgradeOptions = {
|
|
19
18
|
binding: ScopeUpgradeBinding;
|
|
20
19
|
scopes: readonly string[];
|
|
21
20
|
onPending?: (requestId: string) => void;
|
|
22
21
|
};
|
|
23
22
|
type UpgradeRequester = (method: string, params?: unknown, options?: GatewayProtocolRequestOptions) => Promise<unknown>;
|
|
24
23
|
/** Runs one browser device scope upgrade and owns rotated-token persistence. */
|
|
25
|
-
declare class GatewayScopeUpgrade {
|
|
24
|
+
export declare class GatewayScopeUpgrade {
|
|
26
25
|
private readonly deps;
|
|
27
26
|
private active?;
|
|
28
27
|
constructor(deps: {
|
|
@@ -34,5 +33,4 @@ declare class GatewayScopeUpgrade {
|
|
|
34
33
|
cancelScopeUpgrade(): void;
|
|
35
34
|
private runUpgrade;
|
|
36
35
|
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { GatewayScopeUpgrade, ScopeUpgradeBinding, ScopeUpgradeOptions, ScopeUpgradeOutcome };
|
|
36
|
+
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as GatewayProtocolRequestOptions } from "./protocol-request-
|
|
2
|
-
|
|
1
|
+
import { n as GatewayProtocolRequestOptions } from "./protocol-request-B5gBmLgq.mjs";
|
|
3
2
|
//#region packages/gateway-client/src/device-auth.d.ts
|
|
4
3
|
declare function normalizeDeviceMetadataForAuth(value?: string | null): string;
|
|
5
4
|
type DeviceAuthPayloadParams = {
|
|
@@ -38,6 +37,8 @@ type SessionMessageIdentity = {
|
|
|
38
37
|
id: string | null;
|
|
39
38
|
sequence: number | null;
|
|
40
39
|
idempotencyKey: string | null;
|
|
40
|
+
/** User submission identity stays stable when a queued turn acquires a new execution run. */
|
|
41
|
+
sendId: string | null;
|
|
41
42
|
runId: string | null;
|
|
42
43
|
isImported: boolean;
|
|
43
44
|
externalSource: string | null;
|
|
@@ -433,6 +433,11 @@ var GatewayEventListeners = class {
|
|
|
433
433
|
};
|
|
434
434
|
//#endregion
|
|
435
435
|
//#region packages/gateway-client/src/protocol-request.ts
|
|
436
|
+
const gatewayResponseErrors = /* @__PURE__ */ new WeakSet();
|
|
437
|
+
/** Distinguishes correlated Gateway responses from locally constructed transport errors. */
|
|
438
|
+
function isGatewayProtocolResponseError(error) {
|
|
439
|
+
return error instanceof Error && gatewayResponseErrors.has(error);
|
|
440
|
+
}
|
|
436
441
|
var GatewayProtocolRequestError = class extends Error {
|
|
437
442
|
constructor(error) {
|
|
438
443
|
super(error.message ?? "request failed");
|
|
@@ -444,6 +449,15 @@ var GatewayProtocolRequestError = class extends Error {
|
|
|
444
449
|
this.retryAfterMs = error.retryAfterMs;
|
|
445
450
|
}
|
|
446
451
|
};
|
|
452
|
+
/** Preserve response metadata after custom factories without adding it to error JSON. */
|
|
453
|
+
function retainGatewayResponsePayload(error, payload) {
|
|
454
|
+
gatewayResponseErrors.add(error);
|
|
455
|
+
Object.defineProperty(error, "responsePayload", {
|
|
456
|
+
value: payload,
|
|
457
|
+
enumerable: false,
|
|
458
|
+
configurable: true
|
|
459
|
+
});
|
|
460
|
+
}
|
|
447
461
|
/** A local transport deadline, distinct from a Gateway's authoritative rejection. */
|
|
448
462
|
var GatewayProtocolRequestTimeoutError = class extends Error {
|
|
449
463
|
constructor(params, message = `gateway request timed out after ${params.timeoutMs}ms: ${params.method}`) {
|
|
@@ -544,7 +558,7 @@ var GatewayPendingRequests = class {
|
|
|
544
558
|
const pending = this.pending.get(frame.id);
|
|
545
559
|
if (!pending) return;
|
|
546
560
|
const status = frame.payload?.status;
|
|
547
|
-
if (pending.expectFinal && status === "accepted") {
|
|
561
|
+
if (frame.ok && pending.expectFinal && status === "accepted") {
|
|
548
562
|
if (!pending.acceptedNotified) {
|
|
549
563
|
pending.acceptedNotified = true;
|
|
550
564
|
this.invoke("accepted", () => pending.onAccepted?.(frame.payload));
|
|
@@ -559,16 +573,19 @@ var GatewayPendingRequests = class {
|
|
|
559
573
|
return;
|
|
560
574
|
}
|
|
561
575
|
this.finishTiming(frame.id, pending, false, frame.error?.code);
|
|
562
|
-
|
|
576
|
+
const error = this.opts.createRequestError?.(frame.error ?? {}) ?? new GatewayProtocolRequestError(frame.error ?? {});
|
|
577
|
+
retainGatewayResponsePayload(error, frame.payload);
|
|
578
|
+
pending.reject(error);
|
|
563
579
|
}
|
|
564
580
|
flush(error) {
|
|
565
|
-
|
|
566
|
-
|
|
581
|
+
const retired = [...this.pending];
|
|
582
|
+
this.pending.clear();
|
|
583
|
+
this.requestSequence = 0;
|
|
584
|
+
for (const [id, pending] of retired) {
|
|
567
585
|
pending.cleanup?.();
|
|
586
|
+
this.finishTiming(id, pending, false, "CLIENT_CLOSED");
|
|
568
587
|
pending.reject(error);
|
|
569
588
|
}
|
|
570
|
-
this.pending.clear();
|
|
571
|
-
this.requestSequence = 0;
|
|
572
589
|
}
|
|
573
590
|
allocateRequestId() {
|
|
574
591
|
this.requestSequence += 1;
|
|
@@ -730,8 +747,12 @@ var GatewayProtocolClient = class {
|
|
|
730
747
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
731
748
|
this.opts.onSocketFactoryError?.(normalized);
|
|
732
749
|
this.opts.onConnectError?.(normalized);
|
|
733
|
-
if (this.opts.rethrowSocketFactoryError?.(normalized))
|
|
750
|
+
if (this.opts.rethrowSocketFactoryError?.(normalized)) {
|
|
751
|
+
if (this.generation > 0 && !this.stopped && !this.socket && !this.reconnectSignal) this.opts.onReconnectStopped?.(normalized);
|
|
752
|
+
throw normalized;
|
|
753
|
+
}
|
|
734
754
|
if (this.opts.shouldRetrySocketFactoryError?.(normalized) && !this.stopped && !this.socket && !this.reconnectSignal) this.scheduleReconnect();
|
|
755
|
+
else if (this.generation > 0 && !this.stopped && !this.socket && !this.reconnectSignal) this.opts.onReconnectStopped?.(normalized);
|
|
735
756
|
return;
|
|
736
757
|
}
|
|
737
758
|
this.generation = generation;
|
|
@@ -820,7 +841,7 @@ var GatewayProtocolClient = class {
|
|
|
820
841
|
this.recordTiming("request-sent", generation, plan);
|
|
821
842
|
this.connectRequestSent = true;
|
|
822
843
|
this.request("connect", this.opts.buildConnectParams(plan)).then((hello) => {
|
|
823
|
-
if (!this.isActive(socket, generation)) return;
|
|
844
|
+
if (!this.isActive(socket, generation) || !socket.isOpen()) return;
|
|
824
845
|
this.helloReceived = true;
|
|
825
846
|
this.clearHandshakeTimer();
|
|
826
847
|
this.connectFailure = void 0;
|
|
@@ -924,7 +945,7 @@ var GatewayProtocolClient = class {
|
|
|
924
945
|
const decision = this.opts.resolveClose(context);
|
|
925
946
|
this.requests.flush(decision.pendingError ?? context.connectFailure?.error ?? /* @__PURE__ */ new Error(`gateway closed (${code}): ${reason}`));
|
|
926
947
|
this.invoke("close", () => this.opts.onClose?.(context, decision));
|
|
927
|
-
if (decision.retry && !this.stopped) this.scheduleReconnect(decision.reconnectDelayMs ?? context.connectFailure?.reconnectDelayMs);
|
|
948
|
+
if (decision.retry && !this.stopped && !this.socket && !this.reconnectSignal) this.scheduleReconnect(decision.reconnectDelayMs ?? context.connectFailure?.reconnectDelayMs);
|
|
928
949
|
}
|
|
929
950
|
handleSocketError(socket, generation, error) {
|
|
930
951
|
if (!this.isActive(socket, generation) || this.connectSent) return;
|
|
@@ -939,7 +960,7 @@ var GatewayProtocolClient = class {
|
|
|
939
960
|
sleepWithAbort(retry.delayMs, retry.signal).then(() => {
|
|
940
961
|
if (this.reconnectSignal !== retry.signal) return;
|
|
941
962
|
this.reconnectSignal = null;
|
|
942
|
-
this.connect();
|
|
963
|
+
this.invoke("reconnect", () => this.connect());
|
|
943
964
|
}, () => {
|
|
944
965
|
if (this.reconnectSignal === retry.signal) this.reconnectSignal = null;
|
|
945
966
|
});
|
|
@@ -1039,12 +1060,14 @@ function readSessionMessageIdentity(message, envelope) {
|
|
|
1039
1060
|
const isCliAssistant = role === "assistant" && readSessionProjectionString(record.api)?.toLowerCase() === "cli";
|
|
1040
1061
|
const canonicalPersistedRunId = isCliAssistant && persistedRunId?.startsWith("cli-assistant:") ? readSessionProjectionString(persistedRunId.slice(14)) : persistedRunId;
|
|
1041
1062
|
const optimisticRunId = metadata && Object.keys(metadata).every((key) => key === "idempotencyKey") ? canonicalPersistedRunId : null;
|
|
1063
|
+
const runId = role === "assistant" ? metadataRunId ?? envelopeRunId ?? (isCliAssistant || !mirroredMessage ? canonicalPersistedRunId : null) ?? optimisticRunId : metadataRunId ?? canonicalPersistedRunId ?? envelopeRunId;
|
|
1042
1064
|
return {
|
|
1043
1065
|
role,
|
|
1044
1066
|
id: readSessionProjectionString(metadata?.id) ?? readSessionProjectionString(envelope?.messageId),
|
|
1045
1067
|
sequence: readSessionMessageSequence(message, envelope),
|
|
1046
1068
|
idempotencyKey,
|
|
1047
|
-
|
|
1069
|
+
sendId: role === "user" ? persistedRunId ?? runId : null,
|
|
1070
|
+
runId,
|
|
1048
1071
|
isImported: Boolean(importedFrom || cliSessionId || externalId),
|
|
1049
1072
|
externalSource: importedFrom && cliSessionId && externalId ? JSON.stringify([
|
|
1050
1073
|
importedFrom,
|
|
@@ -1177,7 +1200,7 @@ function entryMatches(left, right, allowSnapshotPromotion = false) {
|
|
|
1177
1200
|
if (left.pending && right.pending) return Boolean(left.identity?.role === right.identity?.role && left.pendingRunId && left.pendingRunId === right.pendingRunId);
|
|
1178
1201
|
const pending = left.pending ? left : right.pending ? right : null;
|
|
1179
1202
|
const authoritative = pending === left ? right : pending === right ? left : null;
|
|
1180
|
-
return Boolean(pending && authoritative && pending.identity && authoritative.identity && pending.identity.role === authoritative.identity.role && !pending.identity.isImported && !authoritative.identity.isImported && pending.pendingRunId && pending.pendingRunId === authoritative.identity.runId && (pending.identity.sequence === null || authoritative.identity.sequence === null || pending.identity.sequence === authoritative.identity.sequence));
|
|
1203
|
+
return Boolean(pending && authoritative && pending.identity && authoritative.identity && pending.identity.role === authoritative.identity.role && !pending.identity.isImported && !authoritative.identity.isImported && pending.pendingRunId && pending.pendingRunId === (authoritative.identity.sendId ?? authoritative.identity.runId) && (pending.identity.sequence === null || authoritative.identity.sequence === null || pending.identity.sequence === authoritative.identity.sequence));
|
|
1181
1204
|
}
|
|
1182
1205
|
function withEntries(state, entries) {
|
|
1183
1206
|
return {
|
|
@@ -1192,10 +1215,24 @@ function insertEntry(entries, incoming, runs) {
|
|
|
1192
1215
|
const candidate = entry.identity?.sequence;
|
|
1193
1216
|
return candidate !== void 0 && candidate !== null && candidate > sequence;
|
|
1194
1217
|
});
|
|
1195
|
-
if (
|
|
1218
|
+
if (sequence !== void 0 && sequence !== null && nextIndex < 0) nextIndex = entries.length;
|
|
1219
|
+
if (incoming.identity?.role === "user" && incoming.identity.runId) {
|
|
1196
1220
|
const runId = incoming.identity.runId;
|
|
1197
1221
|
const terminalMessage = runs?.[runId]?.message;
|
|
1198
|
-
|
|
1222
|
+
const belongsToRun = (entry) => entry.identity?.role === "assistant" && (entry.identity.runId === runId || entry.message === terminalMessage);
|
|
1223
|
+
if (sequence !== void 0 && sequence !== null) {
|
|
1224
|
+
const before = [];
|
|
1225
|
+
const replies = [];
|
|
1226
|
+
for (const entry of entries.slice(0, nextIndex)) (entry.identity?.sequence === null && belongsToRun(entry) ? replies : before).push(entry);
|
|
1227
|
+
return [
|
|
1228
|
+
...before,
|
|
1229
|
+
incoming,
|
|
1230
|
+
...replies,
|
|
1231
|
+
...entries.slice(nextIndex)
|
|
1232
|
+
];
|
|
1233
|
+
}
|
|
1234
|
+
const terminalIndex = entries.findIndex(belongsToRun);
|
|
1235
|
+
if (terminalIndex >= 0 && (nextIndex < 0 || terminalIndex < nextIndex)) nextIndex = terminalIndex;
|
|
1199
1236
|
}
|
|
1200
1237
|
return nextIndex < 0 ? [...entries, incoming] : [
|
|
1201
1238
|
...entries.slice(0, nextIndex),
|
|
@@ -1215,7 +1252,7 @@ function projectLiveSessionMessage(state, message, envelope, scope = {}) {
|
|
|
1215
1252
|
const existing = state.entries[existingIndex];
|
|
1216
1253
|
if (existing && existing.message === message && existing.live && !existing.pending) return state;
|
|
1217
1254
|
if (existing && !existing.pending && existing.identity?.id && !incoming.identity.id) return state;
|
|
1218
|
-
if (existing
|
|
1255
|
+
if (existing && incoming.identity.sequence !== null && (existing.pending || existing.identity?.sequence === null)) {
|
|
1219
1256
|
const sequence = incoming.identity.sequence;
|
|
1220
1257
|
return withEntries(state, state.entries.some(({ identity }, index) => identity?.sequence != null && (index < existingIndex ? identity.sequence > sequence : identity.sequence < sequence)) ? insertEntry(state.entries.filter((_, index) => index !== existingIndex), incoming, state.runs) : state.entries.toSpliced(existingIndex, 1, incoming));
|
|
1221
1258
|
}
|
|
@@ -1451,7 +1488,7 @@ var GatewaySessionMessageSubscriptionCoordinator = class {
|
|
|
1451
1488
|
if (this.#retired) throw new Error("Session message subscription belongs to a replaced Gateway connection");
|
|
1452
1489
|
const existing = [...this.#entries].find((candidate) => candidate.agentId === agentId && (this.#areKeysEquivalent(candidate.key, normalizedKey) || [...candidate.requestedKeys].some((requestedKey) => this.#areKeysEquivalent(requestedKey, normalizedKey))));
|
|
1453
1490
|
if (!existing) {
|
|
1454
|
-
const provisional = [...this.#entries].find((candidate) => candidate.agentId === agentId && !candidate.canonicalSettled);
|
|
1491
|
+
const provisional = [...this.#entries].find((candidate) => candidate.agentId === agentId && !candidate.canonicalSettled && this.#couldShareCanonicalIdentity(candidate.key, normalizedKey));
|
|
1455
1492
|
if (provisional) {
|
|
1456
1493
|
await (provisional.plainFallback ?? provisional.ready).catch(() => void 0);
|
|
1457
1494
|
continue;
|
|
@@ -1611,6 +1648,11 @@ var GatewaySessionMessageSubscriptionCoordinator = class {
|
|
|
1611
1648
|
#areKeysEquivalent(left, right) {
|
|
1612
1649
|
return left === right || this.#keysEquivalent?.(left, right) === true;
|
|
1613
1650
|
}
|
|
1651
|
+
#couldShareCanonicalIdentity(left, right) {
|
|
1652
|
+
const leftBody = left.replace(/^agent:[^:]+:/i, "").toLowerCase();
|
|
1653
|
+
const rightBody = right.replace(/^agent:[^:]+:/i, "").toLowerCase();
|
|
1654
|
+
return leftBody === rightBody || leftBody === "main" || rightBody === "main" || leftBody === "global" || rightBody === "global";
|
|
1655
|
+
}
|
|
1614
1656
|
};
|
|
1615
1657
|
const sessionMessageSubscriptionOwners = /* @__PURE__ */ new WeakMap();
|
|
1616
1658
|
const sessionMessageSubscriptionCoordinators = /* @__PURE__ */ new WeakMap();
|
|
@@ -1629,4 +1671,4 @@ function releaseGatewaySessionMessageSubscription(subscription) {
|
|
|
1629
1671
|
return sessionMessageSubscriptionOwners.get(subscription)?.coordinator.release(subscription) ?? Promise.resolve();
|
|
1630
1672
|
}
|
|
1631
1673
|
//#endregion
|
|
1632
|
-
export {
|
|
1674
|
+
export { normalizeDeviceMetadataForAuth as A, GatewayBrowserDeviceAuthLifecycle as C, shouldRetryGatewayWithDeviceToken as D, selectGatewayConnectAuth as E, buildDeviceAuthPayload as O, gatewayOriginScope as S, resolveGatewayConnectScopes as T, GatewayProtocolClient as _, createSessionProjection as a, isGatewayProtocolResponseError as b, projectLiveSessionMessage as c, reduceSessionProjectionRunEvent as d, normalizeSessionProjectionRunId as f, shouldPauseGatewayReconnect as g, isRecord as h, resetGatewaySessionMessageSubscriptionCoordinator as i, buildDeviceAuthPayloadV3 as k, reconcileSessionProjectionSnapshot as l, readSessionMessageSequence as m, getGatewaySessionMessageSubscriptionCoordinator as n, hasSessionProjectionAcceptedFinal as o, readSessionMessageIdentity as p, releaseGatewaySessionMessageSubscription as r, isLocallyOptimisticSessionMessage as s, GatewaySessionMessageSubscriptionCoordinator as t, reduceSessionProjection as u, GatewayProtocolRequestError as v, buildGatewayConnectAuth as w, gatewayCredentialScope as x, GatewayProtocolRequestTimeoutError as y };
|
package/dist/timeouts.d.mts
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
//#region packages/gateway-client/src/timeouts.d.ts
|
|
2
2
|
/** Maximum delay Node timers can represent without overflow warnings. */
|
|
3
|
-
declare const MAX_SAFE_TIMEOUT_DELAY_MS = 2147483647;
|
|
3
|
+
export declare const MAX_SAFE_TIMEOUT_DELAY_MS = 2147483647;
|
|
4
4
|
/** Default server-side window for gateway preauth handshakes. */
|
|
5
|
-
declare const DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = 15000;
|
|
5
|
+
export declare const DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = 15000;
|
|
6
6
|
/** Starts the browser-safe deadline that covers Gateway connect preparation and hello. */
|
|
7
|
-
declare function startGatewayConnectTimeout(onTimeout: () => void): ReturnType<typeof setTimeout>;
|
|
7
|
+
export declare function startGatewayConnectTimeout(onTimeout: () => void): ReturnType<typeof setTimeout>;
|
|
8
8
|
/** Clears either pending Gateway handshake phase without retaining its timer. */
|
|
9
|
-
declare function clearGatewayConnectTimeout(timer: ReturnType<typeof setTimeout> | null): null;
|
|
9
|
+
export declare function clearGatewayConnectTimeout(timer: ReturnType<typeof setTimeout> | null): null;
|
|
10
10
|
/** Default deadline for a single non-streaming Gateway request. */
|
|
11
|
-
declare const DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS = 30000;
|
|
11
|
+
export declare const DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS = 30000;
|
|
12
12
|
/** Minimum client watchdog delay for connect challenge setup. */
|
|
13
|
-
declare const MIN_CONNECT_CHALLENGE_TIMEOUT_MS = 250;
|
|
13
|
+
export declare const MIN_CONNECT_CHALLENGE_TIMEOUT_MS = 250;
|
|
14
14
|
/** Default maximum client watchdog delay, aligned with the preauth server timeout. */
|
|
15
|
-
declare const MAX_CONNECT_CHALLENGE_TIMEOUT_MS = 15000;
|
|
15
|
+
export declare const MAX_CONNECT_CHALLENGE_TIMEOUT_MS = 15000;
|
|
16
16
|
/** Clamps arbitrary timer delays to Node's safe range and an optional floor. */
|
|
17
|
-
declare function resolveSafeTimeoutDelayMs(delayMs: number, opts?: {
|
|
17
|
+
export declare function resolveSafeTimeoutDelayMs(delayMs: number, opts?: {
|
|
18
18
|
minMs?: number;
|
|
19
19
|
}): number;
|
|
20
20
|
/** Adds grace time while preserving safe timer bounds if inputs overflow or are invalid. */
|
|
21
|
-
declare function addSafeTimeoutDelayGraceMs(delayMs: number, graceMs: number, opts?: {
|
|
21
|
+
export declare function addSafeTimeoutDelayGraceMs(delayMs: number, graceMs: number, opts?: {
|
|
22
22
|
minMs?: number;
|
|
23
23
|
}): number;
|
|
24
24
|
/** Resolves optional timeout values through a fallback and safe timer clamp. */
|
|
25
|
-
declare function resolveFiniteTimeoutDelayMs(delayMs: number | null | undefined, fallbackMs: number, opts?: {
|
|
25
|
+
export declare function resolveFiniteTimeoutDelayMs(delayMs: number | null | undefined, fallbackMs: number, opts?: {
|
|
26
26
|
minMs?: number;
|
|
27
27
|
}): number;
|
|
28
28
|
/** Clamps connect challenge watchdog timeouts to the gateway-supported range. */
|
|
29
|
-
declare function clampConnectChallengeTimeoutMs(timeoutMs: number, maxTimeoutMs?: number): number;
|
|
29
|
+
export declare function clampConnectChallengeTimeoutMs(timeoutMs: number, maxTimeoutMs?: number): number;
|
|
30
30
|
/** Reads the connect challenge watchdog override from the process environment. */
|
|
31
|
-
declare function getConnectChallengeTimeoutMsFromEnv(env?: NodeJS.ProcessEnv): number | undefined;
|
|
31
|
+
export declare function getConnectChallengeTimeoutMsFromEnv(env?: NodeJS.ProcessEnv): number | undefined;
|
|
32
32
|
/** Resolves the client watchdog timeout using explicit, env, then preauth defaults. */
|
|
33
|
-
declare function resolveConnectChallengeTimeoutMs(timeoutMs?: number | null, params?: {
|
|
33
|
+
export declare function resolveConnectChallengeTimeoutMs(timeoutMs?: number | null, params?: {
|
|
34
34
|
env?: NodeJS.ProcessEnv;
|
|
35
35
|
configuredTimeoutMs?: number | null;
|
|
36
36
|
}): number;
|
|
37
37
|
/** Resolves the server preauth timeout from env, explicit config, or default. */
|
|
38
|
-
declare function resolvePreauthHandshakeTimeoutMs(params?: {
|
|
38
|
+
export declare function resolvePreauthHandshakeTimeoutMs(params?: {
|
|
39
39
|
env?: NodeJS.ProcessEnv;
|
|
40
40
|
configuredTimeoutMs?: number | null;
|
|
41
41
|
}): number;
|
|
42
|
-
//#endregion
|
|
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 };
|
|
42
|
+
//#endregion
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { RawData } from "ws";
|
|
2
|
-
|
|
3
2
|
//#region packages/gateway-client/src/websocket-data.d.ts
|
|
4
|
-
declare function rawDataToString(data: RawData, encoding?: BufferEncoding): string;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { rawDataToString };
|
|
3
|
+
export declare function rawDataToString(data: RawData, encoding?: BufferEncoding): string;
|
|
4
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/gateway-client",
|
|
3
|
-
"version": "2026.8.
|
|
3
|
+
"version": "2026.8.2",
|
|
4
4
|
"description": "Reference WebSocket client for the OpenClaw Gateway protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"client",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
65
|
+
"@openclaw/gateway-protocol": "2026.8.2",
|
|
66
|
+
"ipaddr.js": "2.5.0",
|
|
67
|
+
"ws": "8.21.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@openclaw/normalization-core": "0.0.0-private"
|