@mountaya/client 0.1.0 → 0.2.0
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 +45 -0
- package/README.md +2 -2
- package/dist/admin/index.cjs +2876 -3502
- package/dist/admin/index.cjs.map +1 -1
- package/dist/admin/index.d.cts +731 -912
- package/dist/admin/index.d.ts +731 -912
- package/dist/admin/index.js +188 -285
- package/dist/admin/index.js.map +1 -1
- package/dist/browser.cjs +5913 -7993
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +42 -78
- package/dist/browser.d.ts +42 -78
- package/dist/browser.js +18 -49
- package/dist/browser.js.map +1 -1
- package/dist/chunk-CeEX7ayk.d.cts +75531 -0
- package/dist/chunk-CeEX7ayk.d.ts +75531 -0
- package/dist/chunk-Cg7Dtcb4.js +2987 -0
- package/dist/chunk-Cg7Dtcb4.js.map +1 -0
- package/dist/chunk-DJqUsgsy.d.ts +1463 -0
- package/dist/chunk-DNc8T5K1.js +241 -0
- package/dist/chunk-DNc8T5K1.js.map +1 -0
- package/dist/chunk-DTxzw3hu.d.cts +1463 -0
- package/dist/chunk-DmxQID5X.js +2289 -0
- package/dist/chunk-DmxQID5X.js.map +1 -0
- package/dist/chunk-DoZt_oIV.d.ts +3991 -0
- package/dist/chunk-DpJrqANO.js +11 -0
- package/dist/chunk-Dx8mPAdC.d.cts +3991 -0
- package/dist/chunk-X2ukY3ho.js +419 -0
- package/dist/chunk-X2ukY3ho.js.map +1 -0
- package/dist/events/index.cjs +1338 -1874
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +373 -382
- package/dist/events/index.d.ts +373 -382
- package/dist/events/index.js +523 -806
- package/dist/events/index.js.map +1 -1
- package/dist/index.cjs +5908 -7988
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -69
- package/dist/index.d.ts +37 -69
- package/dist/index.js +17 -48
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
- package/src/browser.ts +1 -0
- package/src/core/rules/clientHeader.ts +1 -1
- package/src/core/rules/errors.ts +1 -1
- package/src/core/rules/nullMasks.gen.ts +14 -2
- package/src/core/rules/version.gen.ts +1 -1
- package/src/events/index.ts +1 -5
- package/src/rest/adminResources.gen.ts +2 -0
- package/src/rest/dates.gen.ts +1 -1
- package/src/rest/resources.gen.ts +2 -0
- package/src/rest/schema.gen.ts +247 -60
- package/src/tiles/schema.gen.ts +1 -3
- package/dist/chunk-BM526BHG.js +0 -342
- package/dist/chunk-BM526BHG.js.map +0 -1
- package/dist/chunk-D2YEVTG7.js +0 -327
- package/dist/chunk-D2YEVTG7.js.map +0 -1
- package/dist/chunk-OHKVUREN.js +0 -3500
- package/dist/chunk-OHKVUREN.js.map +0 -1
- package/dist/chunk-TDTK2L5H.js +0 -3842
- package/dist/chunk-TDTK2L5H.js.map +0 -1
- package/dist/coreOperations.gen-BMYPoBbz.d.ts +0 -1760
- package/dist/coreOperations.gen-BxX5xRxw.d.cts +0 -1760
- package/dist/errors-B-GqAtQv.d.cts +0 -75960
- package/dist/errors-B-GqAtQv.d.ts +0 -75960
- package/dist/operations.gen-CvTyzKNF.d.cts +0 -3993
- package/dist/operations.gen-DUD406TV.d.ts +0 -3993
package/dist/events/index.d.cts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MountayaTransport } from '../index.cjs';
|
|
3
|
-
import 'geojson';
|
|
4
|
-
|
|
1
|
+
import { $t as AgentRunEvent, Ln as CollabChangeAction, Qt as AgentRunCreateParams, fr as CollabSignalParams, lt as MountayaTransport, m as MountayaError, mr as CollabStreamEvent, rn as AgentRunInputParams } from "../chunk-CeEX7ayk.cjs";
|
|
5
2
|
/**
|
|
6
3
|
* SseFrame is one Server-Sent Events record that carried data: its `id`, its `event` name, and
|
|
7
4
|
* the raw `data` text, still a string the caller parses and validates.
|
|
@@ -12,12 +9,12 @@ import 'geojson';
|
|
|
12
9
|
* heartbeat comment, an `id:` alone) dispatches no frame.
|
|
13
10
|
*/
|
|
14
11
|
interface SseFrame {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
/** The record's `data:` lines, joined with newlines, unparsed. */
|
|
13
|
+
data: string;
|
|
14
|
+
/** The record's last `event:` name, or the empty string where it names none. */
|
|
15
|
+
event: string;
|
|
16
|
+
/** The record's own `id:`, or the empty string where it names none. */
|
|
17
|
+
id: string;
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
20
|
* MAX_SSE_BUFFER_CHARS caps the text of one record a parser has not seen the end of: every
|
|
@@ -32,7 +29,7 @@ interface SseFrame {
|
|
|
32
29
|
* it threatens the tab. The unit is UTF-16 code units, a JavaScript string's own `length`, so a
|
|
33
30
|
* record at the cap costs at most twice this many bytes of heap.
|
|
34
31
|
*/
|
|
35
|
-
declare const MAX_SSE_BUFFER_CHARS: number;
|
|
32
|
+
export declare const MAX_SSE_BUFFER_CHARS: number;
|
|
36
33
|
/**
|
|
37
34
|
* SseBufferOverflowError is thrown by a parser whose unterminated record has passed its cap. It
|
|
38
35
|
* carries the `limit` it enforced, so a consumer can tell a broken producer apart from a network
|
|
@@ -48,19 +45,19 @@ declare const MAX_SSE_BUFFER_CHARS: number;
|
|
|
48
45
|
* covers it. A stream torn down by a malformed producer is a platform failure, and an error outside
|
|
49
46
|
* the family would read as the application's own crash.
|
|
50
47
|
*/
|
|
51
|
-
declare class SseBufferOverflowError extends MountayaError {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
export declare class SseBufferOverflowError extends MountayaError {
|
|
49
|
+
readonly name = "SseBufferOverflowError";
|
|
50
|
+
/** The cap the parser enforced, in UTF-16 code units. */
|
|
51
|
+
readonly limit: number;
|
|
52
|
+
/**
|
|
53
|
+
* Builds the error a parser throws once its unterminated record passes the cap.
|
|
54
|
+
*
|
|
55
|
+
* @param limit - the cap the parser enforced, in UTF-16 code units.
|
|
56
|
+
* @param operationId - the operation whose stream overflowed, where the thrower knows it: the
|
|
57
|
+
* message then opens with it and ends with what a reopen would meet.
|
|
58
|
+
* @param options - the standard error options, for the `cause` an opener hands on.
|
|
59
|
+
*/
|
|
60
|
+
constructor(limit: number, operationId?: string, options?: ErrorOptions);
|
|
64
61
|
}
|
|
65
62
|
/**
|
|
66
63
|
* SseFrameParser frames the text of a `text/event-stream` body into records, by the HTML
|
|
@@ -91,76 +88,75 @@ declare class SseBufferOverflowError extends MountayaError {
|
|
|
91
88
|
* was holding and refuses every later push, so a caller that swallowed the throw can never resume
|
|
92
89
|
* mid-record and frame the tail of a refused record as a record of its own.
|
|
93
90
|
*/
|
|
94
|
-
declare class SseFrameParser {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
91
|
+
export declare class SseFrameParser {
|
|
92
|
+
private lineParts;
|
|
93
|
+
private lineLength;
|
|
94
|
+
private dataLines;
|
|
95
|
+
private event;
|
|
96
|
+
private recordId;
|
|
97
|
+
private recordLength;
|
|
98
|
+
private lastId;
|
|
99
|
+
private atStart;
|
|
100
|
+
private afterCarriageReturn;
|
|
101
|
+
private overflowed;
|
|
102
|
+
private readonly maxBufferChars;
|
|
103
|
+
/**
|
|
104
|
+
* Builds a parser that holds at most `maxBufferChars` of a record it has not seen the end of.
|
|
105
|
+
*
|
|
106
|
+
* @param maxBufferChars - bounds the unterminated record this parser holds, in UTF-16 code
|
|
107
|
+
* units: a whole number of 1 or more. A consumer whose frames are known small may tighten
|
|
108
|
+
* it; the shared readers take the default. A cap that is not a number of characters would
|
|
109
|
+
* bound nothing (`NaN` and `Infinity` are exceeded by no length) or refuse every push (zero
|
|
110
|
+
* and below), so it is refused here.
|
|
111
|
+
* @default MAX_SSE_BUFFER_CHARS
|
|
112
|
+
* @throws `MountayaConfigurationError` for a cap that is not a whole number of 1 or more.
|
|
113
|
+
*/
|
|
114
|
+
constructor(maxBufferChars?: number);
|
|
115
|
+
/**
|
|
116
|
+
* lastEventId is the stream's last event ID, as the HTML standard defines it: the value of the
|
|
117
|
+
* latest `id:` in a record the parser has seen the end of, whatever else that record carried.
|
|
118
|
+
*
|
|
119
|
+
* It is the position a reconnect resumes from, sent as `Last-Event-ID`. It carries over a
|
|
120
|
+
* record that names no `id:`, an empty `id:` clears it to the empty string, and an `id:` holding
|
|
121
|
+
* U+0000 is ignored. An `id:` in a record still unterminated has not moved it: a reconnect
|
|
122
|
+
* discards that record, so resuming past it would skip it.
|
|
123
|
+
*
|
|
124
|
+
* It is `undefined` until the stream names a position, where the standard starts from the empty
|
|
125
|
+
* string, so a stream that names none reads apart from one that clears it. A caller resuming
|
|
126
|
+
* from a position an earlier connection named keeps that position through the first and drops
|
|
127
|
+
* it at the second.
|
|
128
|
+
*/
|
|
129
|
+
get lastEventId(): string | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* push feeds the next decoded text chunk and returns every frame the records it completes
|
|
132
|
+
* dispatch, in stream order. What it leaves unterminated stays held for the next push, unless it
|
|
133
|
+
* passes the cap: then push throws {@link SseBufferOverflowError} instead of returning, dropping
|
|
134
|
+
* the frames the same chunk completed. The stream is being torn down with them, and a caller
|
|
135
|
+
* that resumes re-reads from the position it last recorded.
|
|
136
|
+
*/
|
|
137
|
+
push(chunk: string): SseFrame[];
|
|
138
|
+
/**
|
|
139
|
+
* completeLine joins the line held from earlier pushes with its last piece, `tail`, and starts
|
|
140
|
+
* the next line empty.
|
|
141
|
+
*/
|
|
142
|
+
private completeLine;
|
|
143
|
+
/**
|
|
144
|
+
* readLine applies one complete line to the current record, and returns the frame the record
|
|
145
|
+
* dispatches when the line is the empty one that ends it.
|
|
146
|
+
*
|
|
147
|
+
* A field line is split at its first colon, and one space after the colon is dropped: only the
|
|
148
|
+
* first space is the standard's separator, and a second one is part of the value. A line with no
|
|
149
|
+
* colon is its whole self as the field name, with an empty value.
|
|
150
|
+
*/
|
|
151
|
+
private readLine;
|
|
152
|
+
/**
|
|
153
|
+
* endRecord closes the current record: an `id:` it named becomes the stream's last event ID,
|
|
154
|
+
* and it returns the frame the record dispatches, or null for a record with no data.
|
|
155
|
+
*/
|
|
156
|
+
private endRecord;
|
|
157
|
+
/** startRecord empties the record being read, so the next line begins the next one. */
|
|
158
|
+
private startRecord;
|
|
162
159
|
}
|
|
163
|
-
|
|
164
160
|
/** AgentEvent is one decoded frame off a run's event stream. */
|
|
165
161
|
type AgentEvent = AgentRunEvent;
|
|
166
162
|
/** AgentInput is one input signal sent into a running run. */
|
|
@@ -170,7 +166,7 @@ type AgentInput = AgentRunInputParams;
|
|
|
170
166
|
* stream is finished and the read stops rather than waiting on the server to hang up.
|
|
171
167
|
* `done` is the sole terminal: an ended run always finishes with one.
|
|
172
168
|
*/
|
|
173
|
-
declare const agentTerminalEventTypes: ReadonlySet<AgentEvent["type"]>;
|
|
169
|
+
export declare const agentTerminalEventTypes: ReadonlySet<AgentEvent["type"]>;
|
|
174
170
|
/**
|
|
175
171
|
* AgentStreamFrame is one decoded frame paired with its stream position id. A reader
|
|
176
172
|
* records the id of the last frame it consumed, so a reconnect passes it back as
|
|
@@ -180,10 +176,10 @@ declare const agentTerminalEventTypes: ReadonlySet<AgentEvent["type"]>;
|
|
|
180
176
|
* resumes as a full replay.
|
|
181
177
|
*/
|
|
182
178
|
interface AgentStreamFrame {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
/** The decoded event, discriminated on `type`. */
|
|
180
|
+
event: AgentEvent;
|
|
181
|
+
/** The record's own `id:`, the position a resume passes back; absent where it names none. */
|
|
182
|
+
id?: string | undefined;
|
|
187
183
|
}
|
|
188
184
|
/**
|
|
189
185
|
* AgentStreamCloseReason distinguishes how a run's stream finished without an error:
|
|
@@ -206,54 +202,54 @@ type AgentStreamCloseReason = "terminal" | "reconnect" | "ended";
|
|
|
206
202
|
* teardown and fires neither.
|
|
207
203
|
*/
|
|
208
204
|
interface AgentStreamHandlers {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
205
|
+
/** onClose is told once the stream finished with no error, and why. */
|
|
206
|
+
onClose: (reason: AgentStreamCloseReason) => void;
|
|
207
|
+
/**
|
|
208
|
+
* onError receives the failure once. It is an error of the client's family, except a fault the
|
|
209
|
+
* subscriber's own `onFrame`, `onSkippedFrame` or `onLastEventId` threw, which arrives as it was
|
|
210
|
+
* thrown: an open the API refused raises the class a request answered the same way raises, and
|
|
211
|
+
* a connection that failed or broke off raises a `MountayaConnectionError` naming
|
|
212
|
+
* `getAgentRunEvents`.
|
|
213
|
+
*/
|
|
214
|
+
onError: (error: unknown) => void;
|
|
215
|
+
/**
|
|
216
|
+
* onFrame receives one decoded frame. It is awaited, so returning a promise backpressures
|
|
217
|
+
* the read: the next frame is pulled only once the current one is handled, which throttles
|
|
218
|
+
* the stream to tool dispatch rather than letting frames pile up ahead of their effects.
|
|
219
|
+
*/
|
|
220
|
+
onFrame: (frame: AgentStreamFrame) => void | Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* onLastEventId receives the run's stream position when it moves to one no frame carries: a
|
|
223
|
+
* record that names an `id:` and no event, or an empty `id:`, which clears the position and
|
|
224
|
+
* arrives as `undefined`. A subscriber keeping a resume cursor records it as it records a
|
|
225
|
+
* frame's id, so a reopen resumes from the last position the stream named.
|
|
226
|
+
*
|
|
227
|
+
* A frame {@link decodeAgentFrame} skips (a kind this build does not know, or a payload that is
|
|
228
|
+
* not an object) is neither handed to onFrame nor reported here, whatever id it carries, so its
|
|
229
|
+
* position reaches a cursor only once a later frame or record names one. A reopen before then
|
|
230
|
+
* replays it, and it is skipped again.
|
|
231
|
+
*/
|
|
232
|
+
onLastEventId?: ((lastEventId: string | undefined) => void) | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* onSkippedFrame is told of each frame the stream delivers that {@link decodeAgentFrame} skips:
|
|
235
|
+
* one naming an event this build does not know, or carrying data it cannot read. Nothing of it
|
|
236
|
+
* is handed over, and it moves no position, but it is a frame the stream delivered, so a reader
|
|
237
|
+
* counting what an open delivered, as a reconnect policy does to tell an open that made progress
|
|
238
|
+
* from one that did not, counts it. A `reconnect`, which is the transport's own, is not one.
|
|
239
|
+
*/
|
|
240
|
+
onSkippedFrame?: (() => void) | undefined;
|
|
245
241
|
}
|
|
246
242
|
/**
|
|
247
243
|
* AgentWriteOptions tune one write into a run: starting it, or delivering input into it.
|
|
248
244
|
*/
|
|
249
245
|
interface AgentWriteOptions {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
246
|
+
/**
|
|
247
|
+
* The `Idempotency-Key` the write sends on every attempt. Left out, the client draws one for
|
|
248
|
+
* the call. A caller that asks again itself after a failure passes the key it drew for the first
|
|
249
|
+
* ask, so a start whose answer was lost is answered with the run it started rather than a second
|
|
250
|
+
* run.
|
|
251
|
+
*/
|
|
252
|
+
readonly idempotencyKey?: string | undefined;
|
|
257
253
|
}
|
|
258
254
|
/**
|
|
259
255
|
* AgentSubscribeOptions tune one open. `lastEventId` resumes the durable history after a
|
|
@@ -261,10 +257,10 @@ interface AgentWriteOptions {
|
|
|
261
257
|
* open stream down from outside, exactly as the returned unsubscribe does.
|
|
262
258
|
*/
|
|
263
259
|
interface AgentSubscribeOptions {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
260
|
+
/** The position to resume after, sent as `Last-Event-ID`; left out, the run replays whole. */
|
|
261
|
+
lastEventId?: string | undefined;
|
|
262
|
+
/** Closes the stream once it aborts, as the unsubscribe `subscribe` returns does. */
|
|
263
|
+
signal?: AbortSignal | undefined;
|
|
268
264
|
}
|
|
269
265
|
/**
|
|
270
266
|
* AgentTransport is the seam an agent session drives: start a run, deliver input into it,
|
|
@@ -277,31 +273,31 @@ interface AgentSubscribeOptions {
|
|
|
277
273
|
* reports `onClose("terminal")` only after it has handed over a `done`.
|
|
278
274
|
*/
|
|
279
275
|
interface AgentTransport {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
276
|
+
/**
|
|
277
|
+
* sendInput delivers one input signal into a running run, resolving once the API took it.
|
|
278
|
+
*
|
|
279
|
+
* @throws the `MountayaApiError` class the API's refusal maps to, or a
|
|
280
|
+
* `MountayaConnectionError` when no answer arrived; in the live transport, a
|
|
281
|
+
* `MountayaConfigurationError` before anything is sent for a routing update naming a server
|
|
282
|
+
* tool under a publishable key.
|
|
283
|
+
*/
|
|
284
|
+
sendInput: (runId: string, input: AgentInput, options?: AgentWriteOptions) => Promise<void>;
|
|
285
|
+
/**
|
|
286
|
+
* startRun starts a run and answers its id, which `sendInput` and `subscribe` take.
|
|
287
|
+
*
|
|
288
|
+
* @throws the `MountayaApiError` class the API's refusal maps to, including a 202 that names no
|
|
289
|
+
* run, or a `MountayaConnectionError` when no answer arrived; in the live transport, a
|
|
290
|
+
* `MountayaConfigurationError` before anything is sent for a start naming a server tool under
|
|
291
|
+
* a publishable key.
|
|
292
|
+
*/
|
|
293
|
+
startRun: (params: AgentRunCreateParams, options?: AgentWriteOptions) => Promise<{
|
|
294
|
+
runId: string;
|
|
295
|
+
}>;
|
|
296
|
+
/**
|
|
297
|
+
* subscribe opens a run's event stream and returns the function that closes it. Every failure
|
|
298
|
+
* reaches `handlers.onError`; the call itself never throws.
|
|
299
|
+
*/
|
|
300
|
+
subscribe: (runId: string, handlers: AgentStreamHandlers, options?: AgentSubscribeOptions) => () => void;
|
|
305
301
|
}
|
|
306
302
|
/**
|
|
307
303
|
* decodeAgentFrame turns one raw SSE frame into a typed event, or null to skip it.
|
|
@@ -322,7 +318,7 @@ interface AgentTransport {
|
|
|
322
318
|
* discriminant, which arrives on its own line, and nothing below it. A `tool-call`'s input
|
|
323
319
|
* is `unknown` either way and is validated by the tool bus against the tool's own schema.
|
|
324
320
|
*/
|
|
325
|
-
declare const decodeAgentFrame: (frame: SseFrame) => AgentEvent | null;
|
|
321
|
+
export declare const decodeAgentFrame: (frame: SseFrame) => AgentEvent | null;
|
|
326
322
|
/**
|
|
327
323
|
* createAgentTransport binds an agent run's endpoints to one client's transport.
|
|
328
324
|
*
|
|
@@ -343,8 +339,7 @@ declare const decodeAgentFrame: (frame: SseFrame) => AgentEvent | null;
|
|
|
343
339
|
* carried, where the credential's source reports one. A frame it skips is told to
|
|
344
340
|
* `onSkippedFrame`.
|
|
345
341
|
*/
|
|
346
|
-
declare const createAgentTransport: (transport: MountayaTransport) => AgentTransport;
|
|
347
|
-
|
|
342
|
+
export declare const createAgentTransport: (transport: MountayaTransport) => AgentTransport;
|
|
348
343
|
/**
|
|
349
344
|
* CollabEvent is one decoded frame off a collaboration stream: the contract's union,
|
|
350
345
|
* re-exported under the name the reading code uses.
|
|
@@ -367,7 +362,7 @@ type CollabSignal = CollabSignalParams;
|
|
|
367
362
|
* carrying one rather than by being listed.
|
|
368
363
|
*/
|
|
369
364
|
type CollabDurableChange = Extract<CollabEvent, {
|
|
370
|
-
|
|
365
|
+
action: CollabChangeAction;
|
|
371
366
|
}>;
|
|
372
367
|
/**
|
|
373
368
|
* CollabStreamResource is the resource whose editor stream is being read: the collection
|
|
@@ -379,10 +374,10 @@ type CollabDurableChange = Extract<CollabEvent, {
|
|
|
379
374
|
* is structurally identical and assignable to it, and a twin test pins the two.
|
|
380
375
|
*/
|
|
381
376
|
interface CollabStreamResource {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
377
|
+
/** The resource's id, as its path carries it. */
|
|
378
|
+
readonly id: string;
|
|
379
|
+
/** The collection segment of the resource's path. */
|
|
380
|
+
readonly kind: "itineraries" | "zones";
|
|
386
381
|
}
|
|
387
382
|
/**
|
|
388
383
|
* CollabStreamFrame is one decoded frame paired with its stream position id. A reader
|
|
@@ -391,24 +386,24 @@ interface CollabStreamResource {
|
|
|
391
386
|
* numbers its frames, in which case a resume falls back to a full replay.
|
|
392
387
|
*/
|
|
393
388
|
interface CollabStreamFrame {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
389
|
+
/** The decoded frame, discriminated on `type`. */
|
|
390
|
+
event: CollabEvent;
|
|
391
|
+
/** The record's own `id:`, the position a resume passes back; absent where it names none. */
|
|
392
|
+
id?: string | undefined;
|
|
398
393
|
}
|
|
399
394
|
/**
|
|
400
395
|
* CollabStreamErrorOptions classify a stream failure for the reader that has to decide
|
|
401
396
|
* whether to reconnect.
|
|
402
397
|
*/
|
|
403
398
|
interface CollabStreamErrorOptions {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
399
|
+
/**
|
|
400
|
+
* Whether reopening cannot help: a credential refused before the open, a runtime whose fetch
|
|
401
|
+
* streams no body, a 4xx other than 429 on the open, a producer that never ends a frame, and a
|
|
402
|
+
* fault the subscriber's own `onFrame` or `onLastEventId` threw, which a reopen would hand the
|
|
403
|
+
* same frame again. `false` for a failure a reopen can get past: a dropped connection, a
|
|
404
|
+
* stream gone silent, a 429 and a 5xx.
|
|
405
|
+
*/
|
|
406
|
+
terminal?: boolean | undefined;
|
|
412
407
|
}
|
|
413
408
|
/**
|
|
414
409
|
* CollabStreamCloseReason says how a collaboration stream finished without an error:
|
|
@@ -430,48 +425,48 @@ type CollabStreamCloseReason = "reconnect" | "ended";
|
|
|
430
425
|
* after it.
|
|
431
426
|
*/
|
|
432
427
|
interface CollabStreamHandlers {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
428
|
+
/** onClose is told once the stream's body finished with no error, and why. */
|
|
429
|
+
onClose: (reason: CollabStreamCloseReason) => void;
|
|
430
|
+
/**
|
|
431
|
+
* onError receives the failure once, classified. It is an error of the client's family, except
|
|
432
|
+
* a fault the subscriber's own `onOpen`, `onFrame`, `onSkippedFrame` or `onLastEventId` threw,
|
|
433
|
+
* which arrives as it was thrown and classified terminal: an open the API refused raises the
|
|
434
|
+
* class a request answered the same way raises, and a connection that failed or broke off raises
|
|
435
|
+
* a `MountayaConnectionError` naming the stream's operation.
|
|
436
|
+
*/
|
|
437
|
+
onError: (error: unknown, options?: CollabStreamErrorOptions) => void;
|
|
438
|
+
/** onFrame receives each decoded frame, in the order the stream wrote them. */
|
|
439
|
+
onFrame: (frame: CollabStreamFrame) => void;
|
|
440
|
+
/**
|
|
441
|
+
* onLastEventId receives the stream position when it moves to one no frame carries: a record
|
|
442
|
+
* that names an `id:` and no event, or an empty `id:`, which clears the position and arrives as
|
|
443
|
+
* `undefined`. A subscriber keeping a resume cursor records it, so a reopen resumes from the
|
|
444
|
+
* last position the stream named rather than replaying what it has read.
|
|
445
|
+
*
|
|
446
|
+
* A frame {@link decodeCollabFrame} skips (a kind this build does not know, or a payload that is
|
|
447
|
+
* not an object) is neither handed to onFrame nor reported here, whatever id it carries, so its
|
|
448
|
+
* position reaches a cursor only once a later frame or record names one. A reopen before then
|
|
449
|
+
* replays it, and it is skipped again.
|
|
450
|
+
*/
|
|
451
|
+
onLastEventId?: ((lastEventId: string | undefined) => void) | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* onOpen is told once the API has answered the open, before any frame of it, with the user the
|
|
454
|
+
* stream is read as: the user the session token it was opened with names, `userId`, undefined
|
|
455
|
+
* where the credential's source does not say or the token is held as a string or a function,
|
|
456
|
+
* whose user the client is not told. A reader judging its own member's `presence.join` reads
|
|
457
|
+
* that user first, and a user it is told otherwise only where it is undefined.
|
|
458
|
+
*/
|
|
459
|
+
onOpen?: ((open: {
|
|
460
|
+
readonly userId: string | undefined;
|
|
461
|
+
}) => void) | undefined;
|
|
462
|
+
/**
|
|
463
|
+
* onSkippedFrame is told of each frame the stream delivers that {@link decodeCollabFrame} skips:
|
|
464
|
+
* one naming a kind this build does not know, or carrying data it cannot read. Nothing of it is
|
|
465
|
+
* handed over, and it moves no position, but it is a frame the stream delivered, so a reader
|
|
466
|
+
* telling an open that made progress from one that did not counts it as one past those every
|
|
467
|
+
* open begins with. A `reconnect`, which is the transport's own, is not one.
|
|
468
|
+
*/
|
|
469
|
+
onSkippedFrame?: (() => void) | undefined;
|
|
475
470
|
}
|
|
476
471
|
/**
|
|
477
472
|
* CollabSubscribeOptions tune one open. `lastEventId` resumes the durable history after a
|
|
@@ -479,10 +474,10 @@ interface CollabStreamHandlers {
|
|
|
479
474
|
* unsubscribe does.
|
|
480
475
|
*/
|
|
481
476
|
interface CollabSubscribeOptions {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
477
|
+
/** The position to resume after, sent as `Last-Event-ID`; left out, the stream replays whole. */
|
|
478
|
+
lastEventId?: string | undefined;
|
|
479
|
+
/** Closes the stream once it aborts, as the unsubscribe a subscribe returns does. */
|
|
480
|
+
signal?: AbortSignal | undefined;
|
|
486
481
|
}
|
|
487
482
|
/**
|
|
488
483
|
* CollabSignalResult is how a published signal settled. A lock contention is a RESULT
|
|
@@ -495,10 +490,10 @@ interface CollabSubscribeOptions {
|
|
|
495
490
|
* answered in the API's place.
|
|
496
491
|
*/
|
|
497
492
|
type CollabSignalResult = {
|
|
498
|
-
|
|
493
|
+
ok: true;
|
|
499
494
|
} | {
|
|
500
|
-
|
|
501
|
-
|
|
495
|
+
holderId?: string | undefined;
|
|
496
|
+
ok: false;
|
|
502
497
|
};
|
|
503
498
|
/**
|
|
504
499
|
* CollabTransport is the seam a collaboration session drives: publish one signal, and open
|
|
@@ -510,23 +505,23 @@ type CollabSignalResult = {
|
|
|
510
505
|
* your own bounds both waits the same way: the engine waits as long as a stream says nothing.
|
|
511
506
|
*/
|
|
512
507
|
interface CollabTransport {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
508
|
+
/**
|
|
509
|
+
* sendSignal publishes one signal for a resource, and answers how it settled: a lock another
|
|
510
|
+
* member holds is a result naming them, never a throw.
|
|
511
|
+
*
|
|
512
|
+
* @throws the client's own error family for every other refusal: see {@link CollabSignalResult}.
|
|
513
|
+
*/
|
|
514
|
+
sendSignal: (resource: CollabStreamResource, signal: CollabSignal) => Promise<CollabSignalResult>;
|
|
515
|
+
/**
|
|
516
|
+
* subscribeEditor opens the editor stream of one resource and returns the function that closes
|
|
517
|
+
* it. Every failure reaches `handlers.onError`, classified; the call itself never throws.
|
|
518
|
+
*/
|
|
519
|
+
subscribeEditor: (resource: CollabStreamResource, handlers: CollabStreamHandlers, options?: CollabSubscribeOptions) => () => void;
|
|
520
|
+
/**
|
|
521
|
+
* subscribeList opens an organization's event stream, the changes to its itineraries, zones and
|
|
522
|
+
* collections, and returns the function that closes it. Every failure reaches `handlers.onError`, classified; the call itself never throws.
|
|
523
|
+
*/
|
|
524
|
+
subscribeList: (organizationId: string, handlers: CollabStreamHandlers, options?: CollabSubscribeOptions) => () => void;
|
|
530
525
|
}
|
|
531
526
|
/**
|
|
532
527
|
* decodeCollabFrame turns one raw SSE frame into a typed event, or null to skip it.
|
|
@@ -551,7 +546,7 @@ interface CollabTransport {
|
|
|
551
546
|
* What is checked at runtime is the one field the wire and the type disagree about (the
|
|
552
547
|
* discriminant, which arrives on a separate line) and nothing below it.
|
|
553
548
|
*/
|
|
554
|
-
declare const decodeCollabFrame: (frame: SseFrame) => CollabEvent | null;
|
|
549
|
+
export declare const decodeCollabFrame: (frame: SseFrame) => CollabEvent | null;
|
|
555
550
|
/**
|
|
556
551
|
* createCollabTransport binds the collaboration streams to one client's transport.
|
|
557
552
|
*
|
|
@@ -569,8 +564,7 @@ declare const decodeCollabFrame: (frame: SseFrame) => CollabEvent | null;
|
|
|
569
564
|
* answers tells `onOpen` the user that token names, and a frame it skips is told to
|
|
570
565
|
* `onSkippedFrame`.
|
|
571
566
|
*/
|
|
572
|
-
declare const createCollabTransport: (transport: MountayaTransport) => CollabTransport;
|
|
573
|
-
|
|
567
|
+
export declare const createCollabTransport: (transport: MountayaTransport) => CollabTransport;
|
|
574
568
|
/**
|
|
575
569
|
* FrameHandler receives one framed record as readEventStream decodes it. It is
|
|
576
570
|
* awaited, so returning a promise backpressures the read: the next chunk is
|
|
@@ -616,8 +610,7 @@ type EventStreamOutcome = "stopped" | "ended";
|
|
|
616
610
|
* `stopped` or a throw, the connection behind it stays open until the caller, whose body it is,
|
|
617
611
|
* cancels it or aborts the request that opened it.
|
|
618
612
|
*/
|
|
619
|
-
declare const readEventStream: (body: ReadableStream<Uint8Array>, onFrame: FrameHandler, onLastEventId?: (lastEventId: string) => void) => Promise<EventStreamOutcome>;
|
|
620
|
-
|
|
613
|
+
export declare const readEventStream: (body: ReadableStream<Uint8Array>, onFrame: FrameHandler, onLastEventId?: (lastEventId: string) => void) => Promise<EventStreamOutcome>;
|
|
621
614
|
/**
|
|
622
615
|
* OpenSseStreamOptions configure one open of a resumable Server-Sent Events read
|
|
623
616
|
* over fetch. The caller supplies the network seam (doFetch + applyAuth), the URL and
|
|
@@ -627,123 +620,123 @@ declare const readEventStream: (body: ReadableStream<Uint8Array>, onFrame: Frame
|
|
|
627
620
|
* type), so this reader knows no feature's schema.
|
|
628
621
|
*/
|
|
629
622
|
interface OpenSseStreamOptions<TEvent> {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
623
|
+
/**
|
|
624
|
+
* applyAuth folds the host's credential into the request's RequestInit.
|
|
625
|
+
*
|
|
626
|
+
* `method` reaches it because the published seam takes one, for the wording of a refusal.
|
|
627
|
+
*
|
|
628
|
+
* What the stream's operation declares does not reach it, because this reader knows the
|
|
629
|
+
* operation by name alone. An opener states it in the closure it passes, as the collaboration
|
|
630
|
+
* and agent transports do over `MountayaTransport.streamSeam`: the session token every stream
|
|
631
|
+
* requires, that it acts as the member that token names, and, by saying nothing, that no
|
|
632
|
+
* stream accepts a share token. The seam refuses a credential that cannot meet them locally,
|
|
633
|
+
* which for a share token is the only place the rule is named: the server answers one sent where
|
|
634
|
+
* it is not accepted with a 401, as if no credential had been sent. A refusal thrown here
|
|
635
|
+
* surfaces through onError like any other failed open.
|
|
636
|
+
*/
|
|
637
|
+
applyAuth: (init: RequestInit, method: string) => RequestInit;
|
|
638
|
+
/** decode turns one raw SSE frame into a typed event, or null to skip it. */
|
|
639
|
+
decode: (frame: SseFrame) => TEvent | null;
|
|
640
|
+
/** doFetch is the fetch implementation: the real one, or a test double. */
|
|
641
|
+
doFetch: typeof fetch;
|
|
642
|
+
/** lastEventId resumes the stream after a position via the Last-Event-ID header. */
|
|
643
|
+
lastEventId?: string | undefined;
|
|
644
|
+
/** onClose runs once when the body finishes, told why the read returned. */
|
|
645
|
+
onClose?: ((outcome: EventStreamOutcome) => void) | undefined;
|
|
646
|
+
/**
|
|
647
|
+
* onResponse is told of the open's answer once it arrives, a refusal's as well as a stream's,
|
|
648
|
+
* before the stream is read or the refusal classified. The openers of this entry point pass
|
|
649
|
+
* `MountayaTransport.streamSeam`'s `report`, so the client's own `onResponse` hears of every
|
|
650
|
+
* open. A fault it throws fails the open, as a fault of `applyAuth` does.
|
|
651
|
+
*/
|
|
652
|
+
onResponse?: ((response: Response) => void) | undefined;
|
|
653
|
+
/**
|
|
654
|
+
* onError runs once on a failure that is not the caller's own abort (an abort is a silent
|
|
655
|
+
* teardown and fires neither onClose nor onError).
|
|
656
|
+
*
|
|
657
|
+
* What it receives is an error of this package's family, except a fault the caller's own
|
|
658
|
+
* `applyAuth`, `decode`, `onFrame` or `onLastEventId` threw, which arrives as it was thrown:
|
|
659
|
+
* - an open the API refused raises what a request the API answered the same way raises (the
|
|
660
|
+
* class its status and first entry decide, carrying the entries, the `code` and the metadata),
|
|
661
|
+
* so a `402` is a `MountayaBillingError` and a `409` naming a held lock a `MountayaConflictError`. Its body
|
|
662
|
+
* is read under a bound on time and one on size, and past either the status alone decides the
|
|
663
|
+
* class;
|
|
664
|
+
* - a request that failed before a response arrived and a body that broke off mid-read raise a
|
|
665
|
+
* `MountayaConnectionError` carrying the runtime's failure as its `cause`, and an ok answer
|
|
666
|
+
* with no body raises one with no `cause`, since no runtime failure lies behind it;
|
|
667
|
+
* - an open with no response within {@link OpenSseStreamOptions.timeoutMs}, and a stream that
|
|
668
|
+
* delivered nothing for the stall window, raise a `MountayaConnectionError` that says which
|
|
669
|
+
* wait ran out, with no `cause`: the request is aborted and its body let go first;
|
|
670
|
+
* - a `timeoutMs` out of range raises a `MountayaConfigurationError` naming it, and nothing is
|
|
671
|
+
* opened;
|
|
672
|
+
* - a runtime whose fetch exposes no response body to stream raises a
|
|
673
|
+
* `MountayaConfigurationError`, since every reopen meets the same runtime;
|
|
674
|
+
* - a producer past the frame parser's cap raises a `SseBufferOverflowError` naming the
|
|
675
|
+
* operation, with the parser's own error as its `cause`;
|
|
676
|
+
* - a credential the transports' stream seam refuses in applyAuth, and a failure the fetch raised
|
|
677
|
+
* from inside the family, are already of the family and arrive as they were thrown.
|
|
678
|
+
*/
|
|
679
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
680
|
+
/**
|
|
681
|
+
* onFrame receives each decoded event with its stream position id and returns
|
|
682
|
+
* whether to stop the read (a terminal event). Returning a promise backpressures
|
|
683
|
+
* the read: the next frame is pulled only once it settles.
|
|
684
|
+
*/
|
|
685
|
+
onFrame: (event: TEvent, id: string | undefined) => boolean | Promise<boolean>;
|
|
686
|
+
/**
|
|
687
|
+
* onLastEventId receives the stream's position when it moves to one no frame handed to
|
|
688
|
+
* onFrame carries: a record that names an `id:` and no `data:`, which dispatches no frame, or
|
|
689
|
+
* an empty `id:`, even one before the stream names any other position, which clears the
|
|
690
|
+
* position and arrives as `undefined`. A caller keeping a resume cursor records it as it records
|
|
691
|
+
* a frame's id, so a reopen from the cursor resumes from the last position the stream named. It
|
|
692
|
+
* runs only once the frames before it are handled (see `readEventStream`).
|
|
693
|
+
*
|
|
694
|
+
* A frame decode skips is neither handed to onFrame nor reported, whatever id it carries, so its
|
|
695
|
+
* position reaches a cursor only once a later frame or record names one. A reopen before then
|
|
696
|
+
* replays it, and decode skips it again.
|
|
697
|
+
*/
|
|
698
|
+
onLastEventId?: ((lastEventId: string | undefined) => void) | undefined;
|
|
699
|
+
/**
|
|
700
|
+
* operationId names the operation the stream opens, and every failure this open builds names it
|
|
701
|
+
* too: a refusal, a connection failure, and an answer with no body to read
|
|
702
|
+
* (`getAgentRunEvents: 403 FORBIDDEN …`), and so does the frame parser's overflow, which is
|
|
703
|
+
* handed on as a `SseBufferOverflowError` naming it. A failure handed on as it was thrown keeps
|
|
704
|
+
* its own message.
|
|
705
|
+
*/
|
|
706
|
+
operationId: string;
|
|
707
|
+
/** signal is an external abort that tears the open stream down like the returned close. */
|
|
708
|
+
signal?: AbortSignal | undefined;
|
|
709
|
+
/**
|
|
710
|
+
* timeoutMs bounds the open's wait for its response, in milliseconds: past it the request is
|
|
711
|
+
* aborted and onError receives a `MountayaConnectionError` naming the wait. A whole number from
|
|
712
|
+
* 1 to 2,147,483,647; anything else fails the open with a `MountayaConfigurationError` before a
|
|
713
|
+
* request is made. The agent and collaboration transports pass the client's own per-attempt
|
|
714
|
+
* `timeoutMs`, which `MountayaTransport.streamSeam` carries, so their opens wait what a request
|
|
715
|
+
* of the same client waits.
|
|
716
|
+
*
|
|
717
|
+
* Once the response arrives the wait that follows is the stream's silence, which is bounded on
|
|
718
|
+
* its own: a stream that delivers nothing, not even the heartbeat comment the API writes to
|
|
719
|
+
* every live stream, for the stall window is given up the same way.
|
|
720
|
+
*
|
|
721
|
+
* @default the stall window, 45,000 ms, so no wait on the network is unbounded.
|
|
722
|
+
*/
|
|
723
|
+
timeoutMs?: number | undefined;
|
|
724
|
+
/**
|
|
725
|
+
* waitForSession is called before each open's credential is applied, with the open's own
|
|
726
|
+
* signal, and the promise it answers is awaited, so a session token on its way is the one the
|
|
727
|
+
* open carries; `undefined` is nothing to wait for, and the open is made at once. The openers of
|
|
728
|
+
* this entry point pass `MountayaTransport.streamSeam`'s, which waits for a token the
|
|
729
|
+
* credential's source reports on its way, as a request does. What it rejects with reaches
|
|
730
|
+
* onError like any other failed open, and a close during the wait ends it silently.
|
|
731
|
+
*/
|
|
732
|
+
waitForSession?: ((signal: AbortSignal) => Promise<void> | undefined) | undefined;
|
|
733
|
+
/**
|
|
734
|
+
* url is the fully-qualified stream endpoint, or a function answering it. A function is called
|
|
735
|
+
* once, when the open is made, and what it throws reaches onError as a failed open: an opener
|
|
736
|
+
* whose resolver refuses a path (`StreamSeam.url` does, for one that leaves the API) passes the
|
|
737
|
+
* call rather than its answer.
|
|
738
|
+
*/
|
|
739
|
+
url: string | (() => string);
|
|
747
740
|
}
|
|
748
741
|
/**
|
|
749
742
|
* openSseStream opens one resumable `text/event-stream` read over fetch and returns
|
|
@@ -775,7 +768,5 @@ interface OpenSseStreamOptions<TEvent> {
|
|
|
775
768
|
* the failure a caller reopens on, rather than as a read that never settles. The time a frame
|
|
776
769
|
* handler holds the read is the caller's, and never counts as the stream's silence.
|
|
777
770
|
*/
|
|
778
|
-
declare const openSseStream: <TEvent>(options: OpenSseStreamOptions<TEvent>) => (() => void);
|
|
779
|
-
|
|
780
|
-
export { MAX_SSE_BUFFER_CHARS, SseBufferOverflowError, SseFrameParser, agentTerminalEventTypes, createAgentTransport, createCollabTransport, decodeAgentFrame, decodeCollabFrame, openSseStream, readEventStream };
|
|
781
|
-
export type { AgentEvent, AgentInput, AgentStreamCloseReason, AgentStreamFrame, AgentStreamHandlers, AgentSubscribeOptions, AgentTransport, AgentWriteOptions, CollabDurableChange, CollabEvent, CollabSignal, CollabSignalResult, CollabStreamCloseReason, CollabStreamErrorOptions, CollabStreamFrame, CollabStreamHandlers, CollabStreamResource, CollabSubscribeOptions, CollabTransport, EventStreamOutcome, FrameHandler, OpenSseStreamOptions, SseFrame };
|
|
771
|
+
export declare const openSseStream: <TEvent>(options: OpenSseStreamOptions<TEvent>) => (() => void);
|
|
772
|
+
export type { AgentEvent, AgentInput, AgentStreamCloseReason, AgentStreamFrame, AgentStreamHandlers, AgentSubscribeOptions, AgentTransport, AgentWriteOptions, CollabDurableChange, CollabEvent, CollabSignal, CollabSignalResult, CollabStreamCloseReason, CollabStreamErrorOptions, CollabStreamFrame, CollabStreamHandlers, CollabStreamResource, CollabSubscribeOptions, CollabTransport, EventStreamOutcome, FrameHandler, OpenSseStreamOptions, SseFrame };
|