@openclaw/gateway-client 2026.8.1-beta.1 → 2026.8.1-beta.3
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 +15 -3
- package/dist/browser-device-auth-Dz6H7eXy.d.mts +112 -0
- package/dist/browser.d.mts +5 -3
- package/dist/browser.mjs +2 -2
- package/dist/index.d.mts +16 -3
- package/dist/index.mjs +653 -1136
- package/dist/{protocol-client-U142L0j3.d.mts → protocol-client-BbN-I582.d.mts} +15 -30
- package/dist/protocol-request-D4mVhLxE.d.mts +32 -0
- package/dist/{readiness-uSDrqxDM.d.mts → readiness-JllUDKLg.d.mts} +28 -14
- package/dist/readiness.d.mts +1 -1
- package/dist/scope-upgrade.d.mts +38 -0
- package/dist/scope-upgrade.mjs +73 -0
- package/dist/{session-subscriptions-Das1PATe.d.mts → session-subscriptions-CKF7acYN.d.mts} +17 -119
- package/dist/{session-subscriptions-D4Xv60cN.mjs → session-subscriptions-OJnDJHPL.mjs} +336 -191
- package/dist/timeouts.mjs +3 -3
- package/dist/websocket-data.d.mts +6 -0
- package/dist/websocket-data.mjs +8 -0
- package/package.json +16 -3
|
@@ -1,23 +1,18 @@
|
|
|
1
|
+
import { n as GatewayProtocolRequestOptions, t as GatewayProtocolRequestError } from "./protocol-request-D4mVhLxE.mjs";
|
|
1
2
|
import { ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol";
|
|
2
3
|
|
|
3
|
-
//#region packages/gateway-client/src/
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
//#region packages/gateway-client/src/pending-request.d.ts
|
|
5
|
+
type GatewayProtocolRequestTiming = {
|
|
6
|
+
id: string;
|
|
7
|
+
method: string;
|
|
8
|
+
ok: boolean;
|
|
9
|
+
durationMs: number;
|
|
10
|
+
startedAtMs: number;
|
|
11
|
+
endedAtMs: number;
|
|
12
|
+
errorCode?: string;
|
|
10
13
|
};
|
|
11
|
-
declare class GatewayProtocolRequestError extends Error {
|
|
12
|
-
readonly code: string;
|
|
13
|
-
readonly gatewayCode: string;
|
|
14
|
-
readonly details?: unknown;
|
|
15
|
-
readonly retryable: boolean;
|
|
16
|
-
readonly retryAfterMs?: number;
|
|
17
|
-
constructor(error: Partial<ErrorShape>);
|
|
18
|
-
}
|
|
19
14
|
//#endregion
|
|
20
|
-
//#region packages/gateway-client/src/protocol-client.d.ts
|
|
15
|
+
//#region packages/gateway-client/src/protocol-client-contract.d.ts
|
|
21
16
|
type GatewayProtocolSocket = {
|
|
22
17
|
isOpen: () => boolean;
|
|
23
18
|
send: (data: string) => void;
|
|
@@ -70,15 +65,6 @@ type GatewayProtocolTiming<TPlan> = {
|
|
|
70
65
|
plan?: TPlan;
|
|
71
66
|
detail?: unknown;
|
|
72
67
|
};
|
|
73
|
-
type GatewayProtocolRequestTiming = {
|
|
74
|
-
id: string;
|
|
75
|
-
method: string;
|
|
76
|
-
ok: boolean;
|
|
77
|
-
durationMs: number;
|
|
78
|
-
startedAtMs: number;
|
|
79
|
-
endedAtMs: number;
|
|
80
|
-
errorCode?: string;
|
|
81
|
-
};
|
|
82
68
|
type GatewayProtocolClientOptions<TPlan> = {
|
|
83
69
|
createSocket: (handlers: GatewayProtocolSocketHandlers) => GatewayProtocolSocket;
|
|
84
70
|
createRequestId: () => string;
|
|
@@ -128,6 +114,8 @@ type GatewayProtocolClientOptions<TPlan> = {
|
|
|
128
114
|
shouldRetrySocketFactoryError?: (error: Error) => boolean;
|
|
129
115
|
rethrowSocketFactoryError?: (error: Error) => boolean;
|
|
130
116
|
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region packages/gateway-client/src/protocol-client.d.ts
|
|
131
119
|
/**
|
|
132
120
|
* Browser-safe gateway wire client. Environment adapters own transport and auth
|
|
133
121
|
* policy; this class owns the single socket/handshake/reconnect/frame state machine.
|
|
@@ -135,7 +123,7 @@ type GatewayProtocolClientOptions<TPlan> = {
|
|
|
135
123
|
declare class GatewayProtocolClient<TPlan> {
|
|
136
124
|
private readonly opts;
|
|
137
125
|
private socket;
|
|
138
|
-
private readonly
|
|
126
|
+
private readonly requests;
|
|
139
127
|
private readonly listeners;
|
|
140
128
|
private stopped;
|
|
141
129
|
private generation;
|
|
@@ -171,11 +159,8 @@ declare class GatewayProtocolClient<TPlan> {
|
|
|
171
159
|
private handleConnectPlanError;
|
|
172
160
|
private sendConnectPlan;
|
|
173
161
|
private handleMessage;
|
|
174
|
-
private handleResponse;
|
|
175
162
|
private handleClose;
|
|
176
163
|
private handleSocketError;
|
|
177
|
-
private flushRequests;
|
|
178
|
-
private finishRequestTiming;
|
|
179
164
|
private scheduleReconnect;
|
|
180
165
|
private closeContext;
|
|
181
166
|
private isActive;
|
|
@@ -184,4 +169,4 @@ declare class GatewayProtocolClient<TPlan> {
|
|
|
184
169
|
private invoke;
|
|
185
170
|
}
|
|
186
171
|
//#endregion
|
|
187
|
-
export {
|
|
172
|
+
export { GatewayProtocolTiming as a, GatewayProtocolSocketHandlers as i, GatewayProtocolCloseContext as n, GatewayProtocolRequestTiming as o, GatewayProtocolSocket as r, GatewayProtocolClient as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ErrorShape } from "@openclaw/gateway-protocol";
|
|
2
|
+
|
|
3
|
+
//#region packages/gateway-client/src/protocol-request.d.ts
|
|
4
|
+
type GatewayProtocolRequestOptions = {
|
|
5
|
+
timeoutMs?: number | null;
|
|
6
|
+
expectFinal?: boolean;
|
|
7
|
+
onSent?: () => void;
|
|
8
|
+
onAccepted?: (payload: unknown) => void;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
};
|
|
11
|
+
declare class GatewayProtocolRequestError extends Error {
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly gatewayCode: string;
|
|
14
|
+
readonly details?: unknown;
|
|
15
|
+
readonly retryable: boolean;
|
|
16
|
+
readonly retryAfterMs?: number;
|
|
17
|
+
constructor(error: Partial<ErrorShape>);
|
|
18
|
+
}
|
|
19
|
+
/** A local transport deadline, distinct from a Gateway's authoritative rejection. */
|
|
20
|
+
declare class GatewayProtocolRequestTimeoutError extends Error {
|
|
21
|
+
readonly code = "CLIENT_TIMEOUT";
|
|
22
|
+
readonly method: string;
|
|
23
|
+
readonly timeoutMs: number;
|
|
24
|
+
readonly requestSent: boolean;
|
|
25
|
+
constructor(params: {
|
|
26
|
+
method: string;
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
requestSent: boolean;
|
|
29
|
+
}, message?: string);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { GatewayProtocolRequestOptions as n, GatewayProtocolRequestTimeoutError as r, GatewayProtocolRequestError as t };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol/frame-guards";
|
|
1
|
+
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-D4mVhLxE.mjs";
|
|
2
|
+
import { ConnectParams, ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol/frame-guards";
|
|
3
3
|
import { GatewayClientMode, GatewayClientName } from "@openclaw/gateway-protocol/client-info";
|
|
4
4
|
|
|
5
|
+
//#region packages/gateway-client/src/request-error.d.ts
|
|
6
|
+
declare class GatewayClientRequestError extends GatewayProtocolRequestError {
|
|
7
|
+
constructor(error: Partial<ErrorShape>);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
5
10
|
//#region packages/gateway-client/src/client.d.ts
|
|
6
11
|
type DeviceIdentity = {
|
|
7
12
|
deviceId: string;
|
|
@@ -50,15 +55,11 @@ type GatewayClientCloseInfo = {
|
|
|
50
55
|
phase: "pre-hello" | "post-hello";
|
|
51
56
|
socketOpened: boolean;
|
|
52
57
|
transportValidated: boolean;
|
|
58
|
+
connectRequestSent?: boolean;
|
|
53
59
|
transientPreHelloCleanClose: boolean;
|
|
60
|
+
connectError?: Error;
|
|
54
61
|
};
|
|
55
|
-
declare class
|
|
56
|
-
constructor(error: Partial<ErrorShape>);
|
|
57
|
-
}
|
|
58
|
-
declare class GatewayClientRequestTimeoutError extends Error {
|
|
59
|
-
readonly method: string;
|
|
60
|
-
readonly timeoutMs: number;
|
|
61
|
-
readonly requestSent: boolean;
|
|
62
|
+
declare class GatewayClientRequestTimeoutError extends GatewayProtocolRequestTimeoutError {
|
|
62
63
|
constructor(params: {
|
|
63
64
|
method: string;
|
|
64
65
|
timeoutMs: number;
|
|
@@ -68,7 +69,8 @@ declare class GatewayClientRequestTimeoutError extends Error {
|
|
|
68
69
|
declare function isGatewayConnectAssemblyError(value: unknown): value is Error;
|
|
69
70
|
type GatewayClientOptions = {
|
|
70
71
|
url?: string;
|
|
71
|
-
origin?: string;
|
|
72
|
+
origin?: string; /** Already-resolved edge-proxy auth headers (identity-aware proxy in front of the Gateway). */
|
|
73
|
+
edgeAuthHeaders?: Readonly<Record<string, string>>;
|
|
72
74
|
connectChallengeTimeoutMs?: number;
|
|
73
75
|
/**
|
|
74
76
|
* Server-side pre-auth handshake budget. Config-derived local clients use
|
|
@@ -79,7 +81,8 @@ type GatewayClientOptions = {
|
|
|
79
81
|
tickWatchTimeoutMs?: number;
|
|
80
82
|
requestTimeoutMs?: number;
|
|
81
83
|
token?: string;
|
|
82
|
-
bootstrapToken?: string;
|
|
84
|
+
bootstrapToken?: string; /** Prefer one setup credential for the first successful device-auth exchange. */
|
|
85
|
+
preferBootstrapToken?: boolean;
|
|
83
86
|
deviceToken?: string;
|
|
84
87
|
password?: string;
|
|
85
88
|
approvalRuntimeToken?: string;
|
|
@@ -88,6 +91,7 @@ type GatewayClientOptions = {
|
|
|
88
91
|
clientName?: GatewayClientName;
|
|
89
92
|
clientDisplayName?: string;
|
|
90
93
|
clientVersion?: string;
|
|
94
|
+
clientBuildId?: string;
|
|
91
95
|
platform?: string;
|
|
92
96
|
deviceFamily?: string;
|
|
93
97
|
mode?: GatewayClientMode;
|
|
@@ -95,6 +99,8 @@ type GatewayClientOptions = {
|
|
|
95
99
|
scopes?: string[];
|
|
96
100
|
caps?: string[];
|
|
97
101
|
commands?: string[];
|
|
102
|
+
computerUse?: ConnectParams["computerUse"]; /** @deprecated Compatibility for the shipped v1 node-host connect envelope. */
|
|
103
|
+
workerRuns?: ConnectParams["workerRuns"];
|
|
98
104
|
permissions?: Record<string, boolean>;
|
|
99
105
|
pathEnv?: string;
|
|
100
106
|
env?: NodeJS.ProcessEnv;
|
|
@@ -106,7 +112,8 @@ type GatewayClientOptions = {
|
|
|
106
112
|
onEvent?: (evt: EventFrame) => void;
|
|
107
113
|
onHelloOk?: (hello: HelloOk) => void;
|
|
108
114
|
onConnectError?: (err: Error) => void;
|
|
109
|
-
onReconnectPaused?: (info: GatewayReconnectPausedInfo) => void;
|
|
115
|
+
onReconnectPaused?: (info: GatewayReconnectPausedInfo) => void; /** Report retryable startup closes for clients that present connection progress. */
|
|
116
|
+
notifyOnStartupRetry?: boolean;
|
|
110
117
|
onClose?: (code: number, reason: string, info?: GatewayClientCloseInfo) => void;
|
|
111
118
|
onGap?: (info: {
|
|
112
119
|
expected: number;
|
|
@@ -125,6 +132,9 @@ declare class GatewayClient {
|
|
|
125
132
|
private opts;
|
|
126
133
|
private deps;
|
|
127
134
|
private stopped;
|
|
135
|
+
private useLegacyNodeProtocolEnvelope;
|
|
136
|
+
private nodeProtocolTransitionPending;
|
|
137
|
+
private suppressNextHelloCallback;
|
|
128
138
|
private pendingDeviceTokenRetry;
|
|
129
139
|
private deviceTokenRetryBudgetUsed;
|
|
130
140
|
private approvalRuntimeTokenCompatibilityDisabled;
|
|
@@ -141,6 +151,8 @@ declare class GatewayClient {
|
|
|
141
151
|
updateNodeManifest(manifest: {
|
|
142
152
|
caps: string[];
|
|
143
153
|
commands: string[];
|
|
154
|
+
computerUse?: ConnectParams["computerUse"]; /** @deprecated Compatibility for the shipped v1 node-host connect envelope. */
|
|
155
|
+
workerRuns?: ConnectParams["workerRuns"];
|
|
144
156
|
}): void;
|
|
145
157
|
start(): void;
|
|
146
158
|
private createSocket;
|
|
@@ -154,6 +166,9 @@ declare class GatewayClient {
|
|
|
154
166
|
private logDebug;
|
|
155
167
|
private logError;
|
|
156
168
|
private assembleConnectParams;
|
|
169
|
+
private shouldNegotiateLegacyNodeProtocol;
|
|
170
|
+
private shouldRetryWithLegacyNodeProtocol;
|
|
171
|
+
private shouldRetryWithCurrentNodeProtocol;
|
|
157
172
|
private buildDeviceConnectParams;
|
|
158
173
|
private handleConnectHello;
|
|
159
174
|
private handleConnectRequestFailure;
|
|
@@ -167,7 +182,6 @@ declare class GatewayClient {
|
|
|
167
182
|
private isTrustedDeviceRetryEndpoint;
|
|
168
183
|
private selectConnectAuth;
|
|
169
184
|
private startTickWatch;
|
|
170
|
-
private validateTlsFingerprint;
|
|
171
185
|
request<T = Record<string, unknown>>(method: string, params?: unknown, opts?: GatewayClientRequestOptions): Promise<T>;
|
|
172
186
|
}
|
|
173
187
|
//#endregion
|
|
@@ -208,4 +222,4 @@ declare function startGatewayClientWithReadinessWait(waitForReady: EventLoopRead
|
|
|
208
222
|
/** Starts a gateway client after the default event-loop readiness probe succeeds. */
|
|
209
223
|
declare function startGatewayClientWhenEventLoopReady(client: GatewayClientStartable, options?: GatewayClientStartReadinessOptions): Promise<EventLoopReadyResult>;
|
|
210
224
|
//#endregion
|
|
211
|
-
export {
|
|
225
|
+
export { GatewayClientRequestTimeoutError as _, startGatewayClientWithReadinessWait as a, GatewayClientRequestError as b, waitForEventLoopReady as c, GatewayClient as d, GatewayClientCloseInfo as f, GatewayClientRequestOptions as g, GatewayClientOptions as h, startGatewayClientWhenEventLoopReady as i, DeviceAuthTokenRecord as l, GatewayClientHostDeps as m, GatewayClientStartReadinessOptions as n, EventLoopReadyOptions as o, GatewayClientConnectionMetadata as p, GatewayClientStartable as r, EventLoopReadyResult as s, EventLoopReadyWaiter as t, DeviceIdentity as u, GatewayReconnectPausedInfo as v, isGatewayConnectAssemblyError as y };
|
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-JllUDKLg.mjs";
|
|
2
2
|
export { EventLoopReadyWaiter, GatewayClientStartReadinessOptions, GatewayClientStartable, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { a as GatewayBrowserDeviceTokenStore } from "./browser-device-auth-Dz6H7eXy.mjs";
|
|
2
|
+
import { n as GatewayProtocolRequestOptions } from "./protocol-request-D4mVhLxE.mjs";
|
|
3
|
+
|
|
4
|
+
//#region packages/gateway-client/src/scope-upgrade.d.ts
|
|
5
|
+
type ScopeUpgradeBinding = {
|
|
6
|
+
clientId: string;
|
|
7
|
+
deviceId: string;
|
|
8
|
+
role: string;
|
|
9
|
+
};
|
|
10
|
+
type ScopeUpgradeOutcome = {
|
|
11
|
+
status: "approved";
|
|
12
|
+
requestId: string;
|
|
13
|
+
scopes: string[];
|
|
14
|
+
} | {
|
|
15
|
+
status: "rejected" | "expired";
|
|
16
|
+
requestId: string;
|
|
17
|
+
};
|
|
18
|
+
type ScopeUpgradeOptions = {
|
|
19
|
+
binding: ScopeUpgradeBinding;
|
|
20
|
+
scopes: readonly string[];
|
|
21
|
+
onPending?: (requestId: string) => void;
|
|
22
|
+
};
|
|
23
|
+
type UpgradeRequester = (method: string, params?: unknown, options?: GatewayProtocolRequestOptions) => Promise<unknown>;
|
|
24
|
+
/** Runs one browser device scope upgrade and owns rotated-token persistence. */
|
|
25
|
+
declare class GatewayScopeUpgrade {
|
|
26
|
+
private readonly deps;
|
|
27
|
+
private active?;
|
|
28
|
+
constructor(deps: {
|
|
29
|
+
request: UpgradeRequester;
|
|
30
|
+
tokenStore: GatewayBrowserDeviceTokenStore;
|
|
31
|
+
reconnect: () => void;
|
|
32
|
+
});
|
|
33
|
+
requestScopeUpgrade(options: ScopeUpgradeOptions): Promise<ScopeUpgradeOutcome>;
|
|
34
|
+
cancelScopeUpgrade(): void;
|
|
35
|
+
private runUpgrade;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { GatewayScopeUpgrade, ScopeUpgradeBinding, ScopeUpgradeOptions, ScopeUpgradeOutcome };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region packages/gateway-client/src/scope-upgrade.ts
|
|
2
|
+
function readRequestId(value) {
|
|
3
|
+
const requestId = value && typeof value === "object" && "requestId" in value ? value.requestId : void 0;
|
|
4
|
+
if (typeof requestId !== "string" || !requestId.trim()) throw new Error("gateway returned an invalid scope upgrade request id");
|
|
5
|
+
return requestId;
|
|
6
|
+
}
|
|
7
|
+
function readUpgradeResult(value, requestId) {
|
|
8
|
+
if (!value || typeof value !== "object") throw new Error("gateway returned an invalid scope upgrade result");
|
|
9
|
+
const result = value;
|
|
10
|
+
if (result.requestId !== requestId) throw new Error("gateway returned a mismatched scope upgrade result");
|
|
11
|
+
if (result.status === "rejected" || result.status === "expired") return {
|
|
12
|
+
status: result.status,
|
|
13
|
+
requestId
|
|
14
|
+
};
|
|
15
|
+
const deviceToken = result.status === "approved" && typeof result.deviceToken === "string" ? result.deviceToken.trim() : "";
|
|
16
|
+
const rawScopes = result.status === "approved" && Array.isArray(result.scopes) ? result.scopes : [];
|
|
17
|
+
if (!deviceToken || rawScopes.length === 0 || rawScopes.some((scope) => typeof scope !== "string" || !scope.trim())) throw new Error("gateway returned invalid approved scope upgrade credentials");
|
|
18
|
+
return {
|
|
19
|
+
status: "approved",
|
|
20
|
+
requestId,
|
|
21
|
+
deviceToken,
|
|
22
|
+
scopes: rawScopes
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Runs one browser device scope upgrade and owns rotated-token persistence. */
|
|
26
|
+
var GatewayScopeUpgrade = class {
|
|
27
|
+
constructor(deps) {
|
|
28
|
+
this.deps = deps;
|
|
29
|
+
}
|
|
30
|
+
requestScopeUpgrade(options) {
|
|
31
|
+
if (this.active) {
|
|
32
|
+
if (this.active.requestId) options.onPending?.(this.active.requestId);
|
|
33
|
+
return this.active.promise;
|
|
34
|
+
}
|
|
35
|
+
const operation = { controller: new AbortController() };
|
|
36
|
+
const promise = this.runUpgrade(operation, options).finally(() => {
|
|
37
|
+
if (this.active === operation) this.active = void 0;
|
|
38
|
+
});
|
|
39
|
+
operation.promise = promise;
|
|
40
|
+
this.active = operation;
|
|
41
|
+
return promise;
|
|
42
|
+
}
|
|
43
|
+
cancelScopeUpgrade() {
|
|
44
|
+
const operation = this.active;
|
|
45
|
+
this.active = void 0;
|
|
46
|
+
operation?.controller.abort();
|
|
47
|
+
}
|
|
48
|
+
async runUpgrade(operation, options) {
|
|
49
|
+
const requestId = readRequestId(await this.deps.request("device.scopes.requestUpgrade", { scopes: [...options.scopes] }, { signal: operation.controller.signal }));
|
|
50
|
+
operation.requestId = requestId;
|
|
51
|
+
options.onPending?.(requestId);
|
|
52
|
+
const result = readUpgradeResult(await this.deps.request("device.scopes.waitUpgrade", { requestId }, {
|
|
53
|
+
timeoutMs: null,
|
|
54
|
+
signal: operation.controller.signal
|
|
55
|
+
}), requestId);
|
|
56
|
+
if (result.status !== "approved") return result;
|
|
57
|
+
await this.deps.tokenStore.store({
|
|
58
|
+
clientId: options.binding.clientId,
|
|
59
|
+
deviceId: options.binding.deviceId,
|
|
60
|
+
role: options.binding.role,
|
|
61
|
+
token: result.deviceToken,
|
|
62
|
+
scopes: result.scopes
|
|
63
|
+
});
|
|
64
|
+
this.deps.reconnect();
|
|
65
|
+
return {
|
|
66
|
+
status: "approved",
|
|
67
|
+
requestId,
|
|
68
|
+
scopes: result.scopes
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { GatewayScopeUpgrade };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as GatewayProtocolRequestOptions } from "./protocol-request-D4mVhLxE.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/gateway-client/src/device-auth.d.ts
|
|
4
4
|
declare function normalizeDeviceMetadataForAuth(value?: string | null): string;
|
|
@@ -19,117 +19,13 @@ type DeviceAuthPayloadV3Params = DeviceAuthPayloadParams & {
|
|
|
19
19
|
declare function buildDeviceAuthPayload(params: DeviceAuthPayloadParams): string;
|
|
20
20
|
declare function buildDeviceAuthPayloadV3(params: DeviceAuthPayloadV3Params): string;
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region packages/gateway-client/src/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
authPassword?: string;
|
|
28
|
-
authApprovalRuntimeToken?: string;
|
|
29
|
-
authAgentRuntimeIdentityToken?: string;
|
|
30
|
-
signatureToken?: string;
|
|
31
|
-
resolvedDeviceToken?: string;
|
|
32
|
-
storedToken?: string;
|
|
33
|
-
storedScopes?: string[];
|
|
34
|
-
usingStoredDeviceToken?: boolean;
|
|
35
|
-
};
|
|
36
|
-
declare function selectGatewayConnectAuth(params: {
|
|
37
|
-
token?: string;
|
|
38
|
-
bootstrapToken?: string;
|
|
39
|
-
deviceToken?: string;
|
|
40
|
-
password?: string;
|
|
41
|
-
approvalRuntimeToken?: string;
|
|
42
|
-
agentRuntimeIdentityToken?: string;
|
|
43
|
-
storedToken?: string;
|
|
44
|
-
storedScopes?: string[];
|
|
45
|
-
pendingDeviceTokenRetry?: boolean;
|
|
46
|
-
trustedDeviceTokenRetry?: boolean;
|
|
47
|
-
preferBootstrapToken?: boolean;
|
|
48
|
-
}): GatewayConnectAuthSelection;
|
|
49
|
-
declare function buildGatewayConnectAuth(selected: GatewayConnectAuthSelection): ConnectParams["auth"];
|
|
50
|
-
declare function resolveGatewayConnectScopes(params: {
|
|
51
|
-
requestedScopes?: string[];
|
|
52
|
-
usingStoredDeviceToken?: boolean;
|
|
53
|
-
storedScopes?: string[];
|
|
54
|
-
defaultScopes: readonly string[];
|
|
55
|
-
}): string[];
|
|
56
|
-
declare function shouldRetryGatewayWithDeviceToken(params: {
|
|
57
|
-
retryBudgetUsed: boolean;
|
|
58
|
-
currentDeviceToken?: string;
|
|
59
|
-
explicitToken?: string;
|
|
60
|
-
storedToken?: string;
|
|
61
|
-
trustedEndpoint: boolean;
|
|
62
|
-
canRetryWithDeviceTokenHint?: boolean;
|
|
63
|
-
errorDetails?: unknown;
|
|
64
|
-
}): boolean;
|
|
22
|
+
//#region packages/gateway-client/src/gateway-origin-scope.d.ts
|
|
23
|
+
/** Normalizes the gateway URL scope used for origin-bound device tokens. */
|
|
24
|
+
declare function gatewayOriginScope(gatewayUrl: string): string;
|
|
25
|
+
/** Normalizes the gateway URL scope used for browser credential records. */
|
|
26
|
+
declare function gatewayCredentialScope(gatewayUrl: string): string;
|
|
65
27
|
//#endregion
|
|
66
|
-
//#region packages/gateway-client/src/
|
|
67
|
-
type GatewayBrowserDeviceIdentity = {
|
|
68
|
-
deviceId: string;
|
|
69
|
-
publicKey: string;
|
|
70
|
-
sign: (payload: string) => Promise<string>;
|
|
71
|
-
};
|
|
72
|
-
type GatewayBrowserDeviceTokenRecord = {
|
|
73
|
-
token: string;
|
|
74
|
-
scopes: string[];
|
|
75
|
-
};
|
|
76
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
77
|
-
type GatewayBrowserDeviceTokenStore = {
|
|
78
|
-
load: (params: {
|
|
79
|
-
clientId: string;
|
|
80
|
-
deviceId: string;
|
|
81
|
-
role: string;
|
|
82
|
-
}) => MaybePromise<GatewayBrowserDeviceTokenRecord | null>;
|
|
83
|
-
store: (params: {
|
|
84
|
-
clientId: string;
|
|
85
|
-
deviceId: string;
|
|
86
|
-
role: string;
|
|
87
|
-
token: string;
|
|
88
|
-
scopes: string[];
|
|
89
|
-
}) => MaybePromise<void>;
|
|
90
|
-
clear: (params: {
|
|
91
|
-
clientId: string;
|
|
92
|
-
deviceId: string;
|
|
93
|
-
role: string;
|
|
94
|
-
}) => MaybePromise<void>;
|
|
95
|
-
};
|
|
96
|
-
type GatewayBrowserDeviceAuthPlan = {
|
|
97
|
-
clientId: string;
|
|
98
|
-
role: string;
|
|
99
|
-
identity: GatewayBrowserDeviceIdentity | null;
|
|
100
|
-
selectedAuth: GatewayConnectAuthSelection;
|
|
101
|
-
scopes: string[];
|
|
102
|
-
device?: NonNullable<ConnectParams["device"]>;
|
|
103
|
-
auth?: ConnectParams["auth"];
|
|
104
|
-
};
|
|
105
|
-
/** Browser-safe device pairing and issued-token lifecycle shared by first-party UI clients. */
|
|
106
|
-
declare class GatewayBrowserDeviceAuthLifecycle {
|
|
107
|
-
private readonly deps;
|
|
108
|
-
constructor(deps: {
|
|
109
|
-
loadIdentity: () => Promise<GatewayBrowserDeviceIdentity | null>;
|
|
110
|
-
tokenStore: GatewayBrowserDeviceTokenStore;
|
|
111
|
-
nowMs?: () => number;
|
|
112
|
-
});
|
|
113
|
-
buildPlan(params: {
|
|
114
|
-
client: ConnectParams["client"];
|
|
115
|
-
role: string;
|
|
116
|
-
defaultScopes: readonly string[];
|
|
117
|
-
bootstrapScopes?: readonly string[];
|
|
118
|
-
token?: string;
|
|
119
|
-
bootstrapToken?: string;
|
|
120
|
-
password?: string;
|
|
121
|
-
pendingDeviceTokenRetry?: boolean;
|
|
122
|
-
trustedDeviceTokenRetry?: boolean;
|
|
123
|
-
preferBootstrapToken?: boolean;
|
|
124
|
-
nonce: string | null;
|
|
125
|
-
challengeTs?: number | null;
|
|
126
|
-
}): Promise<GatewayBrowserDeviceAuthPlan>;
|
|
127
|
-
acceptHello(hello: Pick<HelloOk, "auth">, plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
128
|
-
clearStoredToken(plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region packages/gateway-client/src/session-projection.d.ts
|
|
132
|
-
/** Browser-safe identity and replay rules shared by Gateway conversation clients. */
|
|
28
|
+
//#region packages/gateway-client/src/session-projection-message-identity.d.ts
|
|
133
29
|
type SessionMessageEnvelope = {
|
|
134
30
|
messageId?: unknown;
|
|
135
31
|
messageSeq?: unknown;
|
|
@@ -146,6 +42,14 @@ type SessionMessageIdentity = {
|
|
|
146
42
|
isImported: boolean;
|
|
147
43
|
externalSource: string | null;
|
|
148
44
|
};
|
|
45
|
+
/** History and status markers carry transcript order even when they have no chat role. */
|
|
46
|
+
declare function readSessionMessageSequence(message: unknown, envelope?: SessionMessageEnvelope): number | null;
|
|
47
|
+
/** Run ownership normalizes a user-turn suffix without changing its persisted send key. */
|
|
48
|
+
declare function normalizeSessionProjectionRunId(value: unknown): string | null;
|
|
49
|
+
/** Persisted row facts win; assistant run ownership comes from its authoritative producer. */
|
|
50
|
+
declare function readSessionMessageIdentity(message: unknown, envelope?: SessionMessageEnvelope): SessionMessageIdentity | null;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region packages/gateway-client/src/session-projection.d.ts
|
|
149
53
|
type SessionProjectionScope = {
|
|
150
54
|
sessionKey?: string;
|
|
151
55
|
sessionId?: string;
|
|
@@ -227,12 +131,6 @@ type SessionProjectionEvent = ScopedSessionProjectionEvent & ({
|
|
|
227
131
|
} | {
|
|
228
132
|
type: "reconnected";
|
|
229
133
|
});
|
|
230
|
-
/** History and status markers carry transcript order even when they have no chat role. */
|
|
231
|
-
declare function readSessionMessageSequence(message: unknown, envelope?: SessionMessageEnvelope): number | null;
|
|
232
|
-
/** Run ownership normalizes a user-turn suffix without changing its persisted send key. */
|
|
233
|
-
declare function normalizeSessionProjectionRunId(value: unknown): string | null;
|
|
234
|
-
/** Persisted transcript facts win over envelope projections and provider-local import IDs. */
|
|
235
|
-
declare function readSessionMessageIdentity(message: unknown, envelope?: SessionMessageEnvelope): SessionMessageIdentity | null;
|
|
236
134
|
/** Local turns have no durable transcript metadata beyond their own optional send key. */
|
|
237
135
|
declare function isLocallyOptimisticSessionMessage(message: unknown): boolean;
|
|
238
136
|
declare function createSessionProjection(scope?: SessionProjectionScope, messages?: readonly unknown[]): SessionProjectionState;
|
|
@@ -248,7 +146,7 @@ declare function reduceSessionProjectionRunEvent(projection: SessionProjectionSt
|
|
|
248
146
|
//#endregion
|
|
249
147
|
//#region packages/gateway-client/src/session-subscriptions.d.ts
|
|
250
148
|
type GatewaySessionMessageRequestClient = {
|
|
251
|
-
request<T = unknown>(method: string, params: Record<string, unknown
|
|
149
|
+
request<T = unknown>(method: string, params: Record<string, unknown>, options?: GatewayProtocolRequestOptions): Promise<T>;
|
|
252
150
|
};
|
|
253
151
|
type GatewaySessionMessageSubscription = {
|
|
254
152
|
key: string;
|
|
@@ -280,4 +178,4 @@ declare function getGatewaySessionMessageSubscriptionCoordinator(client: Gateway
|
|
|
280
178
|
declare function resetGatewaySessionMessageSubscriptionCoordinator(client: GatewaySessionMessageRequestClient): void;
|
|
281
179
|
declare function releaseGatewaySessionMessageSubscription(subscription: GatewaySessionMessageSubscription): Promise<void>;
|
|
282
180
|
//#endregion
|
|
283
|
-
export {
|
|
181
|
+
export { gatewayCredentialScope as A, reduceSessionProjection as C, normalizeSessionProjectionRunId as D, SessionMessageIdentity as E, buildDeviceAuthPayload as M, buildDeviceAuthPayloadV3 as N, readSessionMessageIdentity as O, normalizeDeviceMetadataForAuth as P, reconcileSessionProjectionSnapshot as S, SessionMessageEnvelope as T, SessionProjectionState as _, GatewaySessionMessageSubscriptionOptions as a, isLocallyOptimisticSessionMessage as b, resetGatewaySessionMessageSubscriptionCoordinator as c, SessionProjectionGatewayRunEvent as d, SessionProjectionRun as f, SessionProjectionSnapshotOptions as g, SessionProjectionScope as h, GatewaySessionMessageSubscriptionCoordinatorOptions as i, gatewayOriginScope as j, readSessionMessageSequence as k, SessionProjectionEntry as l, SessionProjectionRunTransition as m, GatewaySessionMessageSubscription as n, getGatewaySessionMessageSubscriptionCoordinator as o, SessionProjectionRunStatus as p, GatewaySessionMessageSubscriptionCoordinator as r, releaseGatewaySessionMessageSubscription as s, GatewaySessionMessageRequestClient as t, SessionProjectionEvent as u, createSessionProjection as v, reduceSessionProjectionRunEvent as w, projectLiveSessionMessage as x, hasSessionProjectionAcceptedFinal as y };
|