@tangle-network/sandbox 0.60.78-develop.20261017090901.9326d18 → 0.60.78-develop.20261021201434.3bcd5ef
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 +61 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +2 -2
- package/dist/{agent-run-outcome-CTEpjCEZ.d.ts → agent-run-outcome-brwJbH5S.d.ts} +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +5 -5
- package/dist/{backend-types-D6bYbvMB.js → backend-types-CLvdSX8V.js} +41 -1
- package/dist/{browser-interactive-control-controller-rpTbyvAS.d.ts → browser-interactive-control-controller-CvObO_Kf.d.ts} +1 -1
- package/dist/{browser-interactive-control-controller-BJf0P_J4.js → browser-interactive-control-controller-DHx53yre.js} +16 -1
- package/dist/{chunked-upload-DtIvkKNo.js → chunked-upload-DN2twsUu.js} +2 -59
- package/dist/{chunked-upload-file-DnsHEjg0.js → chunked-upload-file-Dpv1YsoA.js} +2 -1
- package/dist/{cli-auth-bundle-cSJjPeFF.js → cli-auth-bundle-CFeHsq-5.js} +23 -11
- package/dist/{client-R1tw-4Px.js → client-CgtR203z.js} +3349 -3341
- package/dist/client-Dr8qasCR.d.ts +6076 -0
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-DaJU5O0E.js → collaboration-g_HzXa6f.js} +5 -5
- package/dist/core.d.ts +7 -7
- package/dist/core.js +7 -6
- package/dist/direct-http2-Dar5erTH.js +99 -0
- package/dist/{errors-DSJBKmGZ.js → errors-BfbOP_rx.js} +171 -22
- package/dist/{index-DO7GVpk_.d.ts → index-C8VSFtWl.d.ts} +1 -1
- package/dist/{index-DZ27pdB8.d.ts → index-CVjTnRWP.d.ts} +1 -1
- package/dist/{sandbox-CoIGxzm_.d.ts → index-D5dVNm76.d.ts} +2117 -1519
- package/dist/index.d.ts +12 -4704
- package/dist/index.js +40 -15
- package/dist/intelligence/index.js +1 -1
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-CJ24g8Va.js → interactive-controller-OAsASPd_.js} +662 -620
- package/dist/interactive-controller-nMhGqXxq.d.ts +41 -0
- package/dist/keep-alive-fetch-BBzJDWyt.js +247 -0
- package/dist/{lines-DodQslsf.d.ts → lines-C5CPSg8n.d.ts} +21 -17
- package/dist/lines-C5ER4aN_.js +298 -0
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -295
- package/dist/{local-cli-auth-CBV7Vjk5.js → local-cli-auth-D-CQ0-ub.js} +1 -1
- package/dist/{mcp-local-DjryqUiY.js → mcp-local-BjLG7VHY.js} +1 -1
- package/dist/{preview-wpGGk0bu.d.ts → preview-COO7TSBk.d.ts} +3 -3
- package/dist/public-templates-BDrchm0J.d.ts +80 -0
- package/dist/public-templates.d.ts +2 -0
- package/dist/public-templates.js +173 -0
- package/dist/{raw-evidence-archive-Br5a3xZ_.js → raw-evidence-archive-CDYDqHNv.js} +161 -69
- package/dist/runtime.d.ts +49 -41
- package/dist/runtime.js +8 -8
- package/dist/{sandbox-C7Tk62qn.js → sandbox-BrZxAq11.js} +9048 -8939
- package/dist/{secp256k1-Dx2XABHz.js → secp256k1-CmLpsmWl.js} +1 -1
- package/dist/session-gateway/index.d.ts +23 -67
- package/dist/session-gateway/index.js +578 -451
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-Ba4Kz5zT.js → tangle-GiPBak5X.js} +176 -169
- package/dist/terminal-stream-types-ClZCArRg.d.ts +662 -0
- package/dist/{types-B_QF-iHm.d.ts → types-CtH0GRql.d.ts} +6161 -5812
- package/package.json +12 -7
- package/dist/client-Lhxo82x1.d.ts +0 -1261
- package/dist/errors-mPL-qvgF.d.ts +0 -347
- package/dist/index-DRto9Ijb.d.ts +0 -579
- package/dist/managed-process-B7WfqKmi.d.ts +0 -15
- package/dist/terminal-stream-jdYomM1m.d.ts +0 -389
- /package/dist/{cli-auth-bundle-ODe06Ts7.d.ts → cli-auth-bundle-Dyw3hCGx.d.ts} +0 -0
- /package/dist/{line-application-Cq6dJLBD.js → line-application-DY9ZTdgF.js} +0 -0
- /package/dist/{preview-operations-DqSo-IBm.js → preview-operations-Ca02vPDJ.js} +0 -0
- /package/dist/{utils-B7_9Hl_z.js → utils-BGvM02yJ.js} +0 -0
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { AgentInteractiveSessionControlClaim, AgentInteractiveSessionRef } from "@tangle-network/agent-interface";
|
|
3
|
-
|
|
4
|
-
//#region ../../../packages/runtime-contracts/dist/terminal-websocket.d.ts
|
|
5
|
-
/** Non-credential protocol selected during a successful terminal handshake. */
|
|
6
|
-
declare const TERMINAL_WS_ECHO_SUBPROTOCOL = "tangle.terminal.v1";
|
|
7
|
-
/**
|
|
8
|
-
* Server stamps for one attach, in epoch milliseconds on the sidecar's clock.
|
|
9
|
-
* They are absolute so a caller can lay them against its own marks and read
|
|
10
|
-
* each leg (client clock skew is the only error). `spawn*` and `initPersistAt`
|
|
11
|
-
* are absent when the attach adopted a PTY that already existed.
|
|
12
|
-
*/
|
|
13
|
-
declare const terminalReadyTimingsSchema: z.ZodObject<{
|
|
14
|
-
upgradeAt: z.ZodNumber;
|
|
15
|
-
authAt: z.ZodNumber;
|
|
16
|
-
initAt: z.ZodNumber;
|
|
17
|
-
loadAt: z.ZodNumber;
|
|
18
|
-
spawnAt: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
initPersistAt: z.ZodOptional<z.ZodNumber>;
|
|
20
|
-
loadedAt: z.ZodNumber;
|
|
21
|
-
historyAt: z.ZodNumber;
|
|
22
|
-
historyEvents: z.ZodNumber;
|
|
23
|
-
historyBytes: z.ZodNumber;
|
|
24
|
-
readyAt: z.ZodNumber;
|
|
25
|
-
via: z.ZodEnum<{
|
|
26
|
-
upgrade: "upgrade";
|
|
27
|
-
frame: "frame";
|
|
28
|
-
}>;
|
|
29
|
-
ptid: z.ZodOptional<z.ZodString>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
type TerminalReadyTimings = z.infer<typeof terminalReadyTimingsSchema>;
|
|
32
|
-
declare const terminalReadyMessageSchema: z.ZodObject<{
|
|
33
|
-
type: z.ZodLiteral<"ready">;
|
|
34
|
-
connectionId: z.ZodString;
|
|
35
|
-
sessionId: z.ZodString;
|
|
36
|
-
restored: z.ZodBoolean;
|
|
37
|
-
detachTimeoutMs: z.ZodNumber;
|
|
38
|
-
attachCount: z.ZodOptional<z.ZodNumber>;
|
|
39
|
-
cursors: z.ZodOptional<z.ZodObject<{
|
|
40
|
-
earliest: z.ZodNumber;
|
|
41
|
-
latest: z.ZodNumber;
|
|
42
|
-
}, z.core.$strip>>;
|
|
43
|
-
timings: z.ZodOptional<z.ZodObject<{
|
|
44
|
-
upgradeAt: z.ZodNumber;
|
|
45
|
-
authAt: z.ZodNumber;
|
|
46
|
-
initAt: z.ZodNumber;
|
|
47
|
-
loadAt: z.ZodNumber;
|
|
48
|
-
spawnAt: z.ZodOptional<z.ZodNumber>;
|
|
49
|
-
initPersistAt: z.ZodOptional<z.ZodNumber>;
|
|
50
|
-
loadedAt: z.ZodNumber;
|
|
51
|
-
historyAt: z.ZodNumber;
|
|
52
|
-
historyEvents: z.ZodNumber;
|
|
53
|
-
historyBytes: z.ZodNumber;
|
|
54
|
-
readyAt: z.ZodNumber;
|
|
55
|
-
via: z.ZodEnum<{
|
|
56
|
-
upgrade: "upgrade";
|
|
57
|
-
frame: "frame";
|
|
58
|
-
}>;
|
|
59
|
-
ptid: z.ZodOptional<z.ZodString>;
|
|
60
|
-
}, z.core.$strip>>;
|
|
61
|
-
}, z.core.$strip>;
|
|
62
|
-
type TerminalReadyMessage = z.infer<typeof terminalReadyMessageSchema>;
|
|
63
|
-
type TerminalReadyInfo = Omit<TerminalReadyMessage, "type">;
|
|
64
|
-
/** One sequenced output frame for an exact interactive terminal. */
|
|
65
|
-
declare const terminalOutputMessageSchema: z.ZodObject<{
|
|
66
|
-
type: z.ZodLiteral<"output">;
|
|
67
|
-
seq: z.ZodNumber;
|
|
68
|
-
data: z.ZodString;
|
|
69
|
-
}, z.core.$strip>;
|
|
70
|
-
type TerminalOutputMessage = z.infer<typeof terminalOutputMessageSchema>;
|
|
71
|
-
declare const terminalExitMessageSchema: z.ZodObject<{
|
|
72
|
-
type: z.ZodLiteral<"exit">;
|
|
73
|
-
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
74
|
-
exitSignal: z.ZodOptional<z.ZodString>;
|
|
75
|
-
}, z.core.$strip>;
|
|
76
|
-
type TerminalExitMessage = z.infer<typeof terminalExitMessageSchema>;
|
|
77
|
-
type TerminalExitInfo = Omit<TerminalExitMessage, "type">;
|
|
78
|
-
type TerminalStreamAuthFormat = "edge" | "sidecar-direct";
|
|
79
|
-
interface TerminalInteractiveSessionIdentity {
|
|
80
|
-
incarnationId: AgentInteractiveSessionRef["incarnationId"];
|
|
81
|
-
control: AgentInteractiveSessionControlClaim;
|
|
82
|
-
}
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/scoped-token-types.d.ts
|
|
85
|
-
/**
|
|
86
|
-
* Public types for scoped consumer-side tokens.
|
|
87
|
-
*
|
|
88
|
-
* This module intentionally has no SDK implementation imports. Terminal
|
|
89
|
-
* streams and token requests share these contracts without depending on the
|
|
90
|
-
* SDK's aggregate types module.
|
|
91
|
-
*/
|
|
92
|
-
/**
|
|
93
|
-
* Scope of a `box.mintScopedToken()` request. `session` and `project` mint
|
|
94
|
-
* SessionGateway read tokens. `session-runtime` and `read-only` mint sidecar
|
|
95
|
-
* capability tokens for browser-safe runtime access.
|
|
96
|
-
*/
|
|
97
|
-
type ScopedTokenScope = "session" | "session-runtime" | "project" | "read-only";
|
|
98
|
-
interface MintScopedTokenBase {
|
|
99
|
-
/** TTL in minutes. Default 5; clamped to [1, 15]. */
|
|
100
|
-
ttlMinutes?: number;
|
|
101
|
-
/** Cancel the token request before it reaches the terminal dial. */
|
|
102
|
-
signal?: AbortSignal;
|
|
103
|
-
}
|
|
104
|
-
/** Options for `box.mintScopedToken()`, narrowed by consumer scope. */
|
|
105
|
-
type MintScopedTokenOptions = (MintScopedTokenBase & {
|
|
106
|
-
scope: "session"; /** Client-facing browser session ID. */
|
|
107
|
-
sessionId: string; /** Actual runtime session ID used to filter the sandbox event stream. */
|
|
108
|
-
runtimeSessionId: string;
|
|
109
|
-
}) | (MintScopedTokenBase & {
|
|
110
|
-
scope: "session-runtime";
|
|
111
|
-
sessionId: string;
|
|
112
|
-
runtimeSessionId?: never;
|
|
113
|
-
}) | (MintScopedTokenBase & {
|
|
114
|
-
scope: "project" | "read-only";
|
|
115
|
-
sessionId?: never;
|
|
116
|
-
runtimeSessionId?: never;
|
|
117
|
-
});
|
|
118
|
-
/** Options for the server-side exact interactive-session token request. */
|
|
119
|
-
type MintInteractiveSessionTokenOptions = Pick<MintScopedTokenBase, "ttlMinutes" | "signal">;
|
|
120
|
-
/**
|
|
121
|
-
* Returned by `box.mintScopedToken()`. Use session/project tokens with
|
|
122
|
-
* `SessionGatewayClient`; use session-runtime/read-only tokens with
|
|
123
|
-
* `SandboxRuntimeClient`.
|
|
124
|
-
*/
|
|
125
|
-
interface ScopedToken {
|
|
126
|
-
/** Bearer token (JWT) for the consumer selected by `scope`. */
|
|
127
|
-
token: string;
|
|
128
|
-
/** When the token expires. */
|
|
129
|
-
expiresAt: Date;
|
|
130
|
-
/** The runtime's direct edge URL. Use with runtime scopes; session/project
|
|
131
|
-
* tokens instead connect to the Sandbox API's `/session` WebSocket. */
|
|
132
|
-
runtimeUrl: string;
|
|
133
|
-
/** Browser-safe Sandbox API proxy base for terminal and runtime requests. */
|
|
134
|
-
sidecarProxyUrl: string;
|
|
135
|
-
/** Echo of the requested scope. */
|
|
136
|
-
scope: ScopedTokenScope;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/terminal-stream.d.ts
|
|
140
|
-
/** A protocol `error` control frame or a transport failure. */
|
|
141
|
-
declare class TerminalStreamError extends Error {
|
|
142
|
-
/** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
|
|
143
|
-
readonly code: string;
|
|
144
|
-
/**
|
|
145
|
-
* True when the socket never reached OPEN: the upgrade was refused (a
|
|
146
|
-
* WebSocket client cannot read the HTTP status, so a 401 and a network drop
|
|
147
|
-
* look alike) or the runtime rejected the dial's options. No PTY work had
|
|
148
|
-
* started on the client's side of that dial.
|
|
149
|
-
*/
|
|
150
|
-
readonly beforeOpen: boolean;
|
|
151
|
-
constructor(message: string, code: string, options?: {
|
|
152
|
-
beforeOpen?: boolean;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Event callbacks, passed at construction (the same idiom as
|
|
157
|
-
* `SessionGatewayClient`'s `handlers` config). Registering them up front is
|
|
158
|
-
* load-bearing: the server replays PTY history immediately after `ready`, so
|
|
159
|
-
* a handler attached after connect would miss the replayed screen.
|
|
160
|
-
*/
|
|
161
|
-
interface TerminalStreamHandlers {
|
|
162
|
-
/** Raw PTY output bytes (both live output and reattach history replay). */
|
|
163
|
-
onData?: (data: Uint8Array) => void;
|
|
164
|
-
/** Server-sequenced output for exact interactive terminal sessions. */
|
|
165
|
-
onOutput?: (seq: number, data: Uint8Array) => void;
|
|
166
|
-
onReady?: (info: TerminalReadyInfo) => void;
|
|
167
|
-
onExit?: (info: TerminalExitInfo) => void;
|
|
168
|
-
/** Protocol `error` frames and post-connect transport failures. */
|
|
169
|
-
onError?: (error: TerminalStreamError) => void;
|
|
170
|
-
/** Socket closed — by the server, the network, or a local `close()`. */
|
|
171
|
-
onClose?: (code: number, reason: string) => void;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Which WebSocket-subprotocol auth envelope to offer. A WebSocket client
|
|
175
|
-
* cannot set an Authorization header, so the bearer rides the
|
|
176
|
-
* `Sec-WebSocket-Protocol` offer — and the two dialable endpoints expect
|
|
177
|
-
* DIFFERENT envelopes:
|
|
178
|
-
*
|
|
179
|
-
* - `"edge"` (default): the public API proxy
|
|
180
|
-
* (`wss://<api>/v1/sidecar-proxy/{sidecarId}/terminals/{id}/ws`) expects
|
|
181
|
-
* `bearer.<base64url(token)>` — see `parseTerminalWsSubprotocolToken` in
|
|
182
|
-
* `products/sandbox/api/src/lib/terminal-websocket.ts`. The fixed
|
|
183
|
-
* `tangle.terminal.v1` marker is offered alongside the credential (see
|
|
184
|
-
* {@link TERMINAL_WS_ECHO_SUBPROTOCOL}).
|
|
185
|
-
* - `"sidecar-direct"`: the sidecar's own `/terminals/{id}/ws` route expects
|
|
186
|
-
* `tangle.bearer.<token>` plus the same `tangle.terminal.v1` echo marker —
|
|
187
|
-
* see `apps/sidecar/src/routes/ws-subprotocol-auth.ts`. Only
|
|
188
|
-
* platform-internal callers (and the composed integration tests) dial the
|
|
189
|
-
* sidecar directly.
|
|
190
|
-
*/
|
|
191
|
-
/**
|
|
192
|
-
* Bearer credential for the dial: a token string, or a provider invoked on
|
|
193
|
-
* EVERY dial (including {@link TerminalStream.reconnect}). The provider
|
|
194
|
-
* receives that dial's AbortSignal so token minting observes cancellation.
|
|
195
|
-
* Scoped terminal tokens are short-lived (the platform clamps them to <= 15
|
|
196
|
-
* minutes), so a provider lets the SDK re-mint a fresh token per dial.
|
|
197
|
-
*/
|
|
198
|
-
type TerminalStreamBearerToken = string | ScopedToken | ((signal?: AbortSignal) => Promise<string | ScopedToken> | string | ScopedToken);
|
|
199
|
-
/**
|
|
200
|
-
* The account API key, sent as the `Authorization` header of the upgrade
|
|
201
|
-
* instead of a subprotocol credential. Only a runtime that can set headers on
|
|
202
|
-
* a WebSocket upgrade (Node, Bun) can dial this way — see
|
|
203
|
-
* {@link terminalUpgradeHeadersSupported}; a browser keeps a scoped token. The
|
|
204
|
-
* public API proxy takes its owner path for the key, so no scoped token is
|
|
205
|
-
* minted first. Dial the public API proxy with it, never the sidecar directly.
|
|
206
|
-
*/
|
|
207
|
-
interface TerminalStreamApiKey {
|
|
208
|
-
readonly apiKey: string;
|
|
209
|
-
}
|
|
210
|
-
type TerminalStreamToken = TerminalStreamBearerToken | TerminalStreamApiKey;
|
|
211
|
-
/**
|
|
212
|
-
* Wall-clock marks for one attach, in milliseconds on the caller's monotonic
|
|
213
|
-
* clock. `server` holds the sidecar's absolute stamps from the `ready` frame
|
|
214
|
-
* (epoch milliseconds on the sidecar's clock); a caller lays them against its
|
|
215
|
-
* own epoch marks to split each leg.
|
|
216
|
-
*/
|
|
217
|
-
interface TerminalAttachTimings {
|
|
218
|
-
/** The caller's wall to mint the scoped token; absent when the dial used the API key. */
|
|
219
|
-
mintMs?: number;
|
|
220
|
-
/** WebSocket construction to `open`: the upgrade round trip. */
|
|
221
|
-
wsOpenMs: number;
|
|
222
|
-
/** `open` to `ready`. One client/sidecar round trip plus the sidecar's work when `init` was a frame; the sidecar's work alone once the PTY starts on the upgrade. */
|
|
223
|
-
initToReadyMs: number;
|
|
224
|
-
/** `ready` to the first output byte (replayed screen or live output); absent until it arrives. */
|
|
225
|
-
firstByteMs?: number;
|
|
226
|
-
/** The first `write()` to the next output byte; absent until it arrives. */
|
|
227
|
-
echoRttMs?: number;
|
|
228
|
-
/** How the init was offered: on the upgrade URL as well as in the frame (a default-shell attach), or in the frame alone. */
|
|
229
|
-
init: "upgrade" | "frame";
|
|
230
|
-
/** The sidecar's stamps; absent from a sidecar that predates them. */
|
|
231
|
-
server?: TerminalReadyTimings;
|
|
232
|
-
}
|
|
233
|
-
/** Authority refreshed before an interactive stream reconnects. */
|
|
234
|
-
interface TerminalStreamReconnectBinding {
|
|
235
|
-
incarnationId: TerminalInteractiveSessionIdentity["incarnationId"];
|
|
236
|
-
control: TerminalInteractiveSessionIdentity["control"];
|
|
237
|
-
/** Release a claim if the new socket cannot be opened. */
|
|
238
|
-
onFailure?: () => Promise<void> | void;
|
|
239
|
-
}
|
|
240
|
-
/** Internal SDK hook that reclaims interactive authority before reconnect. */
|
|
241
|
-
interface TerminalStreamReconnectAuthority {
|
|
242
|
-
acquire(signal?: AbortSignal): Promise<TerminalStreamReconnectBinding>;
|
|
243
|
-
}
|
|
244
|
-
interface TerminalStreamOptions {
|
|
245
|
-
/**
|
|
246
|
-
* Absolute URL of the terminal WebSocket endpoint. `http(s)` URLs are
|
|
247
|
-
* converted to `ws(s)` automatically.
|
|
248
|
-
*/
|
|
249
|
-
url: string;
|
|
250
|
-
/**
|
|
251
|
-
* Bearer token carried in the auth subprotocol (see `authFormat`) — a
|
|
252
|
-
* string, or a provider re-invoked on every dial so short-lived scoped
|
|
253
|
-
* tokens stay fresh across reconnects.
|
|
254
|
-
*/
|
|
255
|
-
token: TerminalStreamToken;
|
|
256
|
-
/**
|
|
257
|
-
* PTY connection id — also sent in the `init` frame; the server rejects a
|
|
258
|
-
* mismatch with the URL's id. Reusing an id reattaches the existing PTY.
|
|
259
|
-
*/
|
|
260
|
-
connectionId: string;
|
|
261
|
-
cols?: number;
|
|
262
|
-
rows?: number;
|
|
263
|
-
/** Command to run when the id has no live PTY (defaults to the shell). */
|
|
264
|
-
command?: string;
|
|
265
|
-
cwd?: string;
|
|
266
|
-
env?: Record<string, string>;
|
|
267
|
-
/**
|
|
268
|
-
* Exact interactive-agent incarnation. Ordinary terminal consumers omit
|
|
269
|
-
* both interactive fields and retain the existing wire contract.
|
|
270
|
-
*/
|
|
271
|
-
incarnationId?: TerminalInteractiveSessionIdentity["incarnationId"];
|
|
272
|
-
/** Exact active control claim for the interactive-agent incarnation. */
|
|
273
|
-
control?: TerminalInteractiveSessionIdentity["control"];
|
|
274
|
-
/** Auth subprotocol envelope. Default `"edge"`. */
|
|
275
|
-
authFormat?: TerminalStreamAuthFormat;
|
|
276
|
-
handlers?: TerminalStreamHandlers;
|
|
277
|
-
/** Reject `connect()` if `ready` has not arrived within this window. */
|
|
278
|
-
connectTimeoutMs?: number;
|
|
279
|
-
/** Cancel token resolution or an in-progress WebSocket handshake. */
|
|
280
|
-
signal?: AbortSignal;
|
|
281
|
-
/** Reclaim interactive authority before a reconnecting dial. */
|
|
282
|
-
reconnectAuthority?: TerminalStreamReconnectAuthority;
|
|
283
|
-
/**
|
|
284
|
-
* Correlation id for this attach: sent as `x-tangle-trace-id` where the
|
|
285
|
-
* runtime can set upgrade headers, and on the upgrade URL and the `init`
|
|
286
|
-
* frame everywhere else. A fresh id is minted when omitted.
|
|
287
|
-
*/
|
|
288
|
-
traceId?: string;
|
|
289
|
-
/** Wall the caller spent minting this dial's credential, reported in {@link TerminalAttachTimings}. */
|
|
290
|
-
mintMs?: number;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Whether this runtime's global `WebSocket` accepts request headers on the
|
|
294
|
-
* upgrade (Node >= 22 through undici, and Bun): the condition for dialing with
|
|
295
|
-
* the API key and for sending `x-tangle-trace-id` as a header. Browsers and
|
|
296
|
-
* Workers cannot. A runtime that is judged able but ignores the headers is
|
|
297
|
-
* still safe: the upgrade is refused, and the caller dials with a scoped token.
|
|
298
|
-
*/
|
|
299
|
-
declare function terminalUpgradeHeadersSupported(): boolean;
|
|
300
|
-
/**
|
|
301
|
-
* Client for one terminal WebSocket connection. Construct via
|
|
302
|
-
* {@link TerminalStream.connect}, which resolves once the server
|
|
303
|
-
* acknowledges the attach with `ready` (history replay then streams through
|
|
304
|
-
* `handlers.onData`).
|
|
305
|
-
*/
|
|
306
|
-
declare class TerminalStream {
|
|
307
|
-
private readonly ws;
|
|
308
|
-
private readonly options;
|
|
309
|
-
private readonly interactiveIdentity;
|
|
310
|
-
private readonly initMessage;
|
|
311
|
-
private readonly handlers;
|
|
312
|
-
private readonly attachTraceId;
|
|
313
|
-
private readonly initOnUpgrade;
|
|
314
|
-
private readonly dialStartedAt;
|
|
315
|
-
private openedAt;
|
|
316
|
-
private readyAt;
|
|
317
|
-
private firstByteAt;
|
|
318
|
-
private firstWriteAt;
|
|
319
|
-
private echoRttMs;
|
|
320
|
-
private readyInfo;
|
|
321
|
-
private closed;
|
|
322
|
-
private closeWaiters;
|
|
323
|
-
private readonly textDecoder;
|
|
324
|
-
private reconnectInFlight?;
|
|
325
|
-
/**
|
|
326
|
-
* Dial the endpoint, send `init` as the first frame, and resolve once the
|
|
327
|
-
* server responds `ready`. Rejects on a protocol `error` frame, a socket
|
|
328
|
-
* close/failure before `ready`, or the connect timeout — always with the
|
|
329
|
-
* reason the server gave. A token PROVIDER is awaited here, before the
|
|
330
|
-
* socket opens, so every dial (first connect and each reconnect) carries a
|
|
331
|
-
* fresh credential.
|
|
332
|
-
*/
|
|
333
|
-
static connect(options: TerminalStreamOptions): Promise<TerminalStream>;
|
|
334
|
-
private constructor();
|
|
335
|
-
private establish;
|
|
336
|
-
private handleMessage;
|
|
337
|
-
/** PTY connection id this stream is attached to. */
|
|
338
|
-
get connectionId(): string;
|
|
339
|
-
/** The server's `ready` acknowledgement. Set once `connect()` resolves. */
|
|
340
|
-
get ready(): TerminalReadyInfo;
|
|
341
|
-
/** Correlation id of this attach (`x-tangle-trace-id` / `traceId`). */
|
|
342
|
-
get traceId(): string;
|
|
343
|
-
/**
|
|
344
|
-
* Timings of this attach. `firstByteMs` and `echoRttMs` appear once the
|
|
345
|
-
* stream has produced the output they measure.
|
|
346
|
-
*/
|
|
347
|
-
get timings(): TerminalAttachTimings;
|
|
348
|
-
/** Stamp the first output byte after `ready`, and the first one after the first write. */
|
|
349
|
-
private noteOutput;
|
|
350
|
-
/** True while the socket is open. */
|
|
351
|
-
get isOpen(): boolean;
|
|
352
|
-
/**
|
|
353
|
-
* Send input keystrokes to the PTY. `Uint8Array` input is decoded as
|
|
354
|
-
* UTF-8 (the wire protocol carries input as JSON text). Input larger than
|
|
355
|
-
* the server's 1 MiB frame cap is split across multiple `input` frames in
|
|
356
|
-
* order on the same socket, so delivery order is preserved.
|
|
357
|
-
*/
|
|
358
|
-
write(data: string | Uint8Array): void;
|
|
359
|
-
/** Resize the PTY. */
|
|
360
|
-
resize(cols: number, rows: number): void;
|
|
361
|
-
/**
|
|
362
|
-
* Detach cleanly: close the socket and resolve once the close completes.
|
|
363
|
-
* The PTY survives server-side for `ready.detachTimeoutMs` (5 minutes
|
|
364
|
-
* today) — reattach within that window via {@link reconnect} (or a fresh
|
|
365
|
-
* `connect()` with the same connectionId) to replay history and continue.
|
|
366
|
-
*/
|
|
367
|
-
close(): Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
* Re-dial the same endpoint with the same connectionId on a fresh socket
|
|
370
|
-
* — the server reattaches the PTY and replays its buffered history. When
|
|
371
|
-
* the stream was constructed with a token PROVIDER, it is re-invoked for
|
|
372
|
-
* the new dial (scoped terminal tokens expire within minutes, so the
|
|
373
|
-
* original credential may be dead by reconnect time); with a plain string
|
|
374
|
-
* token, pass a fresh `token` override yourself when it may have expired.
|
|
375
|
-
* `handlers` rebinds callbacks for the new stream.
|
|
376
|
-
*/
|
|
377
|
-
reconnect(overrides?: {
|
|
378
|
-
token?: TerminalStreamToken;
|
|
379
|
-
handlers?: TerminalStreamHandlers;
|
|
380
|
-
cols?: number;
|
|
381
|
-
rows?: number;
|
|
382
|
-
signal?: AbortSignal;
|
|
383
|
-
}): Promise<TerminalStream>;
|
|
384
|
-
private reconnectOnce;
|
|
385
|
-
private handlersForReconnect;
|
|
386
|
-
private assertOpen;
|
|
387
|
-
}
|
|
388
|
-
//#endregion
|
|
389
|
-
export { TerminalInteractiveSessionIdentity as _, TerminalStreamError as a, TerminalReadyTimings as b, TerminalStreamReconnectAuthority as c, MintInteractiveSessionTokenOptions as d, MintScopedTokenOptions as f, TerminalExitInfo as g, TERMINAL_WS_ECHO_SUBPROTOCOL as h, TerminalStreamBearerToken as i, TerminalStreamToken as l, ScopedTokenScope as m, TerminalStream as n, TerminalStreamHandlers as o, ScopedToken as p, TerminalStreamApiKey as r, TerminalStreamOptions as s, TerminalAttachTimings as t, terminalUpgradeHeadersSupported as u, TerminalOutputMessage as v, TerminalStreamAuthFormat as x, TerminalReadyInfo as y };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|