@openclaw/gateway-protocol 0.0.0 → 2026.7.2-beta.5
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/CHANGELOG.md +144 -0
- package/LICENSE +21 -0
- package/README.md +157 -2
- package/dist/client-info.d.mts +94 -0
- package/dist/client-info.mjs +82 -0
- package/dist/connect-error-details.d.mts +114 -0
- package/dist/connect-error-details.mjs +296 -0
- package/dist/frame-guards.d.mts +7 -0
- package/dist/frame-guards.mjs +26 -0
- package/dist/frames-DEn_IEne.d.mts +341 -0
- package/dist/gateway-error-details-Btc09cgL.d.mts +51 -0
- package/dist/gateway-error-details.d.mts +2 -0
- package/dist/gateway-error-details.mjs +67 -0
- package/dist/index.d.mts +3418 -0
- package/dist/index.mjs +441 -0
- package/dist/schema-modules-DpxvZ_Jx.d.mts +13395 -0
- package/dist/schema.d.mts +9783 -0
- package/dist/schema.mjs +758 -0
- package/dist/startup-unavailable.d.mts +23 -0
- package/dist/startup-unavailable.mjs +34 -0
- package/dist/version-COV9CEyr.d.mts +11 -0
- package/dist/version.d.mts +2 -0
- package/dist/version.mjs +11 -0
- package/dist/worktrees-CI-UANnD.mjs +9367 -0
- package/package.json +88 -6
- package/protocol.schema.json +69308 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/startup-unavailable.d.ts
|
|
2
|
+
/** Structured error reason used while gateway startup sidecars are still initializing. */
|
|
3
|
+
declare const GATEWAY_STARTUP_UNAVAILABLE_REASON = "startup-sidecars";
|
|
4
|
+
/** Internal close cause that distinguishes startup retry closes from generic disconnects. */
|
|
5
|
+
declare const GATEWAY_STARTUP_PENDING_CLOSE_CAUSE = "startup-sidecars-pending";
|
|
6
|
+
/** WebSocket close code for temporary gateway unavailability. */
|
|
7
|
+
declare const GATEWAY_STARTUP_CLOSE_CODE = 1013;
|
|
8
|
+
/** Human-readable WebSocket close reason for temporary gateway startup unavailability. */
|
|
9
|
+
declare const GATEWAY_STARTUP_CLOSE_REASON = "gateway starting";
|
|
10
|
+
/** Default retry-after hint sent with startup-unavailable handshake errors. */
|
|
11
|
+
declare const GATEWAY_STARTUP_RETRY_AFTER_MS = 500;
|
|
12
|
+
/** Details payload attached to retryable startup-unavailable gateway errors. */
|
|
13
|
+
type GatewayStartupUnavailableDetails = {
|
|
14
|
+
reason: typeof GATEWAY_STARTUP_UNAVAILABLE_REASON;
|
|
15
|
+
};
|
|
16
|
+
/** Builds the canonical startup-unavailable details payload. */
|
|
17
|
+
declare function gatewayStartupUnavailableDetails(): GatewayStartupUnavailableDetails;
|
|
18
|
+
/** Detects the structured retryable error emitted while startup sidecars are pending. */
|
|
19
|
+
declare function isRetryableGatewayStartupUnavailableError(error: unknown): boolean;
|
|
20
|
+
/** Resolves a bounded retry-after delay from a startup-unavailable error. */
|
|
21
|
+
declare function resolveGatewayStartupRetryAfterMs(error: unknown): number | null;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { GATEWAY_STARTUP_CLOSE_CODE, GATEWAY_STARTUP_CLOSE_REASON, GATEWAY_STARTUP_PENDING_CLOSE_CAUSE, GATEWAY_STARTUP_RETRY_AFTER_MS, GATEWAY_STARTUP_UNAVAILABLE_REASON, gatewayStartupUnavailableDetails, isRetryableGatewayStartupUnavailableError, resolveGatewayStartupRetryAfterMs };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/startup-unavailable.ts
|
|
2
|
+
/** Structured error reason used while gateway startup sidecars are still initializing. */
|
|
3
|
+
const GATEWAY_STARTUP_UNAVAILABLE_REASON = "startup-sidecars";
|
|
4
|
+
/** Internal close cause that distinguishes startup retry closes from generic disconnects. */
|
|
5
|
+
const GATEWAY_STARTUP_PENDING_CLOSE_CAUSE = "startup-sidecars-pending";
|
|
6
|
+
/** WebSocket close code for temporary gateway unavailability. */
|
|
7
|
+
const GATEWAY_STARTUP_CLOSE_CODE = 1013;
|
|
8
|
+
/** Human-readable WebSocket close reason for temporary gateway startup unavailability. */
|
|
9
|
+
const GATEWAY_STARTUP_CLOSE_REASON = "gateway starting";
|
|
10
|
+
/** Default retry-after hint sent with startup-unavailable handshake errors. */
|
|
11
|
+
const GATEWAY_STARTUP_RETRY_AFTER_MS = 500;
|
|
12
|
+
const GATEWAY_STARTUP_RETRY_MIN_MS = 100;
|
|
13
|
+
const GATEWAY_STARTUP_RETRY_MAX_MS = 2e3;
|
|
14
|
+
/** Builds the canonical startup-unavailable details payload. */
|
|
15
|
+
function gatewayStartupUnavailableDetails() {
|
|
16
|
+
return { reason: GATEWAY_STARTUP_UNAVAILABLE_REASON };
|
|
17
|
+
}
|
|
18
|
+
function isGatewayStartupUnavailableDetails(details) {
|
|
19
|
+
return typeof details === "object" && details !== null && details.reason === "startup-sidecars";
|
|
20
|
+
}
|
|
21
|
+
/** Detects the structured retryable error emitted while startup sidecars are pending. */
|
|
22
|
+
function isRetryableGatewayStartupUnavailableError(error) {
|
|
23
|
+
if (!error || typeof error !== "object") return false;
|
|
24
|
+
const shaped = error;
|
|
25
|
+
return (shaped.gatewayCode ?? shaped.code) === "UNAVAILABLE" && shaped.retryable === true && isGatewayStartupUnavailableDetails(shaped.details);
|
|
26
|
+
}
|
|
27
|
+
/** Resolves a bounded retry-after delay from a startup-unavailable error. */
|
|
28
|
+
function resolveGatewayStartupRetryAfterMs(error) {
|
|
29
|
+
if (!isRetryableGatewayStartupUnavailableError(error)) return null;
|
|
30
|
+
const retryAfterMs = error.retryAfterMs;
|
|
31
|
+
return Math.min(Math.max(Math.floor(typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) ? retryAfterMs : 500), GATEWAY_STARTUP_RETRY_MIN_MS), GATEWAY_STARTUP_RETRY_MAX_MS);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { GATEWAY_STARTUP_CLOSE_CODE, GATEWAY_STARTUP_CLOSE_REASON, GATEWAY_STARTUP_PENDING_CLOSE_CAUSE, GATEWAY_STARTUP_RETRY_AFTER_MS, GATEWAY_STARTUP_UNAVAILABLE_REASON, gatewayStartupUnavailableDetails, isRetryableGatewayStartupUnavailableError, resolveGatewayStartupRetryAfterMs };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/version.d.ts
|
|
2
|
+
/** Current gateway protocol version emitted by modern clients and servers. */
|
|
3
|
+
declare const PROTOCOL_VERSION: 4;
|
|
4
|
+
/** Lowest general client protocol version accepted by the gateway. */
|
|
5
|
+
declare const MIN_CLIENT_PROTOCOL_VERSION: 4;
|
|
6
|
+
/** Lowest authenticated node protocol version accepted by the gateway. */
|
|
7
|
+
declare const MIN_NODE_PROTOCOL_VERSION: 3;
|
|
8
|
+
/** Lowest lightweight probe protocol version accepted by the gateway. */
|
|
9
|
+
declare const MIN_PROBE_PROTOCOL_VERSION: 3;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { PROTOCOL_VERSION as i, MIN_NODE_PROTOCOL_VERSION as n, MIN_PROBE_PROTOCOL_VERSION as r, MIN_CLIENT_PROTOCOL_VERSION as t };
|
package/dist/version.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/version.ts
|
|
2
|
+
/** Current gateway protocol version emitted by modern clients and servers. */
|
|
3
|
+
const PROTOCOL_VERSION = 4;
|
|
4
|
+
/** Lowest general client protocol version accepted by the gateway. */
|
|
5
|
+
const MIN_CLIENT_PROTOCOL_VERSION = 4;
|
|
6
|
+
/** Lowest authenticated node protocol version accepted by the gateway. */
|
|
7
|
+
const MIN_NODE_PROTOCOL_VERSION = 3;
|
|
8
|
+
/** Lowest lightweight probe protocol version accepted by the gateway. */
|
|
9
|
+
const MIN_PROBE_PROTOCOL_VERSION = 3;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { MIN_CLIENT_PROTOCOL_VERSION, MIN_NODE_PROTOCOL_VERSION, MIN_PROBE_PROTOCOL_VERSION, PROTOCOL_VERSION };
|