@amigo-ai/platform-sdk 0.23.0 → 0.24.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/api.md +4 -1
- package/dist/index.cjs +314 -8
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +314 -8
- package/dist/index.mjs.map +4 -4
- package/dist/resources/events.js +452 -0
- package/dist/resources/events.js.map +1 -0
- package/dist/resources/workspaces.js +4 -8
- package/dist/resources/workspaces.js.map +1 -1
- package/dist/types/generated/api.d.ts +11 -52
- package/dist/types/generated/api.d.ts.map +1 -1
- package/dist/types/index.d.cts +4 -1
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/events.d.ts +160 -0
- package/dist/types/resources/events.d.ts.map +1 -0
- package/dist/types/resources/functions.d.ts.map +1 -1
- package/dist/types/resources/metrics.d.ts.map +1 -1
- package/dist/types/resources/operators.d.ts.map +1 -1
- package/dist/types/resources/settings.d.ts.map +1 -1
- package/dist/types/resources/workspaces.d.ts +4 -15
- package/dist/types/resources/workspaces.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-time workspace event streaming via Server-Sent Events.
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to ``GET /v1/{workspace_id}/events/stream`` and yields typed
|
|
5
|
+
* {@link WorkspaceSSEEvent} values. The platform-api endpoint:
|
|
6
|
+
*
|
|
7
|
+
* - Streams ``text/event-stream`` over HTTP/1.1
|
|
8
|
+
* - Sends ``retry: 3000`` directive as the first frame
|
|
9
|
+
* - Tags every event with ``id: <millisecond-timestamp>`` for replay
|
|
10
|
+
* - Buffers the last 5 minutes of events in Valkey for gapless reconnect
|
|
11
|
+
* - Pops the discriminator (``event_type``) out of the JSON ``data:``
|
|
12
|
+
* payload and into the SSE ``event:`` line — this helper reattaches
|
|
13
|
+
* it before yielding the typed union member
|
|
14
|
+
*
|
|
15
|
+
* Implementation choice: this helper uses the SDK's own fetch transport
|
|
16
|
+
* (with auth + retry middleware applied) rather than the WHATWG
|
|
17
|
+
* ``EventSource`` API or the ``eventsource`` polyfill. The reasons are:
|
|
18
|
+
*
|
|
19
|
+
* 1. ``EventSource`` cannot send ``Authorization`` headers — the polyfill
|
|
20
|
+
* can, but adds a runtime dep and bypasses the SDK's BFF-proxy /
|
|
21
|
+
* custom-fetch / mock-fetch composition.
|
|
22
|
+
* 2. Reusing the existing ``createTurnStream`` pattern keeps a single
|
|
23
|
+
* SSE parser in the SDK and shares the auth middleware that already
|
|
24
|
+
* attaches the bearer token on every request.
|
|
25
|
+
* 3. The SDK ships with two runtime deps (``openapi-fetch`` +
|
|
26
|
+
* ``openapi-typescript-helpers``); adding ``eventsource`` would inflate
|
|
27
|
+
* bundle size for a feature that fetch streaming handles cleanly.
|
|
28
|
+
*
|
|
29
|
+
* The trade-off is that we reimplement the reconnect loop. The platform-api
|
|
30
|
+
* advertises ``retry: 3000`` and we honor that as the initial backoff,
|
|
31
|
+
* doubling with full jitter on each successive failure up to ``maxDelayMs``.
|
|
32
|
+
*
|
|
33
|
+
* @see ConversationsResource.streamTurn for the analogous turn-stream helper.
|
|
34
|
+
*/
|
|
35
|
+
import { WorkspaceScopedResource } from './base.js';
|
|
36
|
+
const DEFAULT_INITIAL_DELAY_MS = 3000;
|
|
37
|
+
const DEFAULT_MAX_DELAY_MS = 30000;
|
|
38
|
+
const DEFAULT_MAX_RECONNECTS = 10;
|
|
39
|
+
// Hard ceiling on a single SSE field value to defend against a misbehaving
|
|
40
|
+
// upstream that streams without ever emitting a frame terminator. 1 MiB is
|
|
41
|
+
// far above any legitimate platform event payload (most are <2 KiB).
|
|
42
|
+
const MAX_FRAME_BYTES = 1_048_576;
|
|
43
|
+
/**
|
|
44
|
+
* Real-time event stream resource.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const handle = client.events.subscribeToWorkspace({
|
|
49
|
+
* onEvent: (event) => {
|
|
50
|
+
* switch (event.event_type) {
|
|
51
|
+
* case 'call.started':
|
|
52
|
+
* console.log('Call started:', event.call_sid)
|
|
53
|
+
* break
|
|
54
|
+
* case 'pipeline.error':
|
|
55
|
+
* console.error('Pipeline error:', event)
|
|
56
|
+
* break
|
|
57
|
+
* }
|
|
58
|
+
* },
|
|
59
|
+
* onError: (err) => console.error('Stream error:', err),
|
|
60
|
+
* onReconnect: (attempt) => console.warn(`Reconnect #${attempt}`),
|
|
61
|
+
* })
|
|
62
|
+
*
|
|
63
|
+
* // Later, to stop:
|
|
64
|
+
* handle.unsubscribe()
|
|
65
|
+
* await handle.done
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export class EventsResource extends WorkspaceScopedResource {
|
|
69
|
+
constructor(client, workspaceId) {
|
|
70
|
+
super(client, workspaceId);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Subscribe to the workspace event stream.
|
|
74
|
+
*
|
|
75
|
+
* Establishes an SSE connection to ``/v1/{workspace_id}/events/stream``
|
|
76
|
+
* and invokes ``onEvent`` once per typed {@link WorkspaceSSEEvent}.
|
|
77
|
+
* Unrecoverable failures (auth errors, exhausted reconnect budget,
|
|
78
|
+
* caller abort) surface through ``onError``.
|
|
79
|
+
*
|
|
80
|
+
* Reconnection is automatic: on a network drop or 5xx, the helper
|
|
81
|
+
* backs off (initial delay derived from the ``retry:`` directive,
|
|
82
|
+
* default 3s, doubling with full jitter up to ``maxDelayMs``) and
|
|
83
|
+
* resumes with the most recently seen ``Last-Event-ID``. The platform
|
|
84
|
+
* buffers 5 minutes of events for gapless replay.
|
|
85
|
+
*
|
|
86
|
+
* @returns a {@link SubscriptionHandle} for cleanup. Aborting the
|
|
87
|
+
* caller's ``signal`` is equivalent to calling ``unsubscribe()``.
|
|
88
|
+
*/
|
|
89
|
+
subscribeToWorkspace(options) {
|
|
90
|
+
const localController = new AbortController();
|
|
91
|
+
const cleanups = [];
|
|
92
|
+
if (options.signal) {
|
|
93
|
+
if (options.signal.aborted) {
|
|
94
|
+
localController.abort(options.signal.reason);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const onAbort = () => localController.abort(options.signal?.reason);
|
|
98
|
+
options.signal.addEventListener('abort', onAbort, { once: true });
|
|
99
|
+
cleanups.push(() => options.signal?.removeEventListener('abort', onAbort));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const done = runSubscription(this.client, this.workspaceId, options, localController.signal).finally(() => {
|
|
103
|
+
for (const cleanup of cleanups)
|
|
104
|
+
cleanup();
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
done,
|
|
108
|
+
unsubscribe: () => localController.abort(),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function runSubscription(client, workspaceId, options, signal) {
|
|
113
|
+
let lastEventId = options.lastEventId;
|
|
114
|
+
let attempt = 0;
|
|
115
|
+
let delayMs = options.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;
|
|
116
|
+
const maxDelayMs = options.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
|
|
117
|
+
const maxReconnects = options.maxReconnects ?? DEFAULT_MAX_RECONNECTS;
|
|
118
|
+
let errorReported = false;
|
|
119
|
+
const reportError = (error) => {
|
|
120
|
+
if (errorReported)
|
|
121
|
+
return;
|
|
122
|
+
errorReported = true;
|
|
123
|
+
try {
|
|
124
|
+
options.onError?.(error);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// Consumer-supplied callback raised — swallow to keep teardown clean.
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
while (!signal.aborted) {
|
|
131
|
+
if (attempt > 0) {
|
|
132
|
+
try {
|
|
133
|
+
options.onReconnect?.(attempt);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Consumer-supplied callback raised — swallow to keep teardown clean.
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
let outcome;
|
|
140
|
+
try {
|
|
141
|
+
outcome = await runOneConnection({
|
|
142
|
+
client,
|
|
143
|
+
workspaceId,
|
|
144
|
+
lastEventId,
|
|
145
|
+
signal,
|
|
146
|
+
onEvent: options.onEvent,
|
|
147
|
+
onIdAdvance: (id) => {
|
|
148
|
+
lastEventId = id;
|
|
149
|
+
},
|
|
150
|
+
onRetryDirective: (ms) => {
|
|
151
|
+
// Server-sent retry directive resets the backoff floor.
|
|
152
|
+
delayMs = clampDelay(ms, options.initialDelayMs, maxDelayMs);
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
// runOneConnection surfaces only terminal auth errors via throw;
|
|
158
|
+
// everything else is a StreamOutcome.
|
|
159
|
+
reportError(err instanceof Error ? err : new Error(String(err)));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (signal.aborted || outcome.kind === 'aborted') {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (outcome.kind === 'auth-error') {
|
|
166
|
+
// 401 / 403 — never auto-retry. The token is invalid and the
|
|
167
|
+
// stream cannot succeed without operator intervention.
|
|
168
|
+
reportError(outcome.error);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (attempt >= maxReconnects) {
|
|
172
|
+
reportError(new Error(`SSE subscription exhausted reconnect budget (${maxReconnects}): ${outcome.reason}`));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
attempt += 1;
|
|
176
|
+
const sleepMs = jitter(delayMs);
|
|
177
|
+
delayMs = Math.min(delayMs * 2, maxDelayMs);
|
|
178
|
+
const slept = await abortableSleep(sleepMs, signal);
|
|
179
|
+
if (!slept)
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function runOneConnection(args) {
|
|
184
|
+
const headers = { Accept: 'text/event-stream' };
|
|
185
|
+
if (args.lastEventId !== undefined) {
|
|
186
|
+
headers['Last-Event-ID'] = args.lastEventId;
|
|
187
|
+
}
|
|
188
|
+
let result;
|
|
189
|
+
try {
|
|
190
|
+
result = await args.client.GET('/v1/{workspace_id}/events/stream', {
|
|
191
|
+
params: { path: { workspace_id: args.workspaceId } },
|
|
192
|
+
headers,
|
|
193
|
+
parseAs: 'stream',
|
|
194
|
+
signal: args.signal,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
if (args.signal.aborted)
|
|
199
|
+
return { kind: 'aborted' };
|
|
200
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
201
|
+
// 4xx (including 401 / 403) are surfaced as thrown AmigoErrors by the
|
|
202
|
+
// SDK error middleware. Distinguish those from transport failures.
|
|
203
|
+
const status = readStatus(error);
|
|
204
|
+
if (status === 401 || status === 403) {
|
|
205
|
+
return { kind: 'auth-error', error };
|
|
206
|
+
}
|
|
207
|
+
return { kind: 'transport-error', reason: error.message };
|
|
208
|
+
}
|
|
209
|
+
if (result.error !== undefined) {
|
|
210
|
+
// openapi-fetch surfaces non-OK responses as `error`. The SDK error
|
|
211
|
+
// middleware should have thrown — fall through defensively.
|
|
212
|
+
return { kind: 'transport-error', reason: `API error: ${safeStringify(result.error)}` };
|
|
213
|
+
}
|
|
214
|
+
const body = result.data;
|
|
215
|
+
if (!(body instanceof ReadableStream)) {
|
|
216
|
+
return { kind: 'transport-error', reason: 'Expected ReadableStream body for SSE' };
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
for await (const frame of parseSSEFrames(body, args.signal)) {
|
|
220
|
+
if (args.signal.aborted)
|
|
221
|
+
return { kind: 'aborted' };
|
|
222
|
+
if (frame.retry !== undefined) {
|
|
223
|
+
args.onRetryDirective(frame.retry);
|
|
224
|
+
}
|
|
225
|
+
if (frame.id !== undefined) {
|
|
226
|
+
args.onIdAdvance(frame.id);
|
|
227
|
+
}
|
|
228
|
+
if (frame.event && frame.data !== undefined) {
|
|
229
|
+
const event = parseWorkspaceFrame(frame.event, frame.data);
|
|
230
|
+
if (event) {
|
|
231
|
+
try {
|
|
232
|
+
args.onEvent(event);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
// Consumer threw during onEvent; do not let it kill the
|
|
236
|
+
// subscription. The stream is still healthy.
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
if (args.signal.aborted)
|
|
244
|
+
return { kind: 'aborted' };
|
|
245
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
246
|
+
return { kind: 'transport-error', reason };
|
|
247
|
+
}
|
|
248
|
+
if (args.signal.aborted)
|
|
249
|
+
return { kind: 'aborted' };
|
|
250
|
+
// Reader closed cleanly — server EOF. Treat as recoverable; reconnect
|
|
251
|
+
// with whatever Last-Event-ID we have.
|
|
252
|
+
return { kind: 'transport-error', reason: 'Stream closed by server' };
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Parses an SSE byte stream into structured frames.
|
|
256
|
+
*
|
|
257
|
+
* Forks the parser in {@link ConversationsResource.streamTurn} to also
|
|
258
|
+
* surface ``id:`` and ``retry:`` lines that the workspace event stream
|
|
259
|
+
* relies on for gapless reconnect.
|
|
260
|
+
*/
|
|
261
|
+
async function* parseSSEFrames(stream, signal) {
|
|
262
|
+
const reader = stream.getReader();
|
|
263
|
+
const decoder = new TextDecoder();
|
|
264
|
+
let buffer = '';
|
|
265
|
+
// When the caller aborts, cancel the reader so any in-flight
|
|
266
|
+
// ``reader.read()`` resolves immediately with ``{done: true}`` (or rejects
|
|
267
|
+
// with ``AbortError``, which we trap in the consumer). Without this, an
|
|
268
|
+
// idle SSE stream keeps the read pending indefinitely after abort.
|
|
269
|
+
let cancelled = false;
|
|
270
|
+
const onAbort = () => {
|
|
271
|
+
if (cancelled)
|
|
272
|
+
return;
|
|
273
|
+
cancelled = true;
|
|
274
|
+
void reader.cancel().catch(() => {
|
|
275
|
+
// Already cancelled or locked elsewhere; safe to ignore.
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
let removeAbortHandler;
|
|
279
|
+
if (signal.aborted) {
|
|
280
|
+
onAbort();
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
284
|
+
removeAbortHandler = () => signal.removeEventListener('abort', onAbort);
|
|
285
|
+
}
|
|
286
|
+
function* drain(text) {
|
|
287
|
+
buffer += text;
|
|
288
|
+
if (buffer.length > MAX_FRAME_BYTES) {
|
|
289
|
+
throw new Error(`SSE frame buffer exceeded ${MAX_FRAME_BYTES} bytes without terminator`);
|
|
290
|
+
}
|
|
291
|
+
while (true) {
|
|
292
|
+
const idx = findFrameTerminator(buffer);
|
|
293
|
+
if (idx === null)
|
|
294
|
+
break;
|
|
295
|
+
const block = buffer.slice(0, idx.terminatorStart);
|
|
296
|
+
buffer = buffer.slice(idx.terminatorEnd);
|
|
297
|
+
const frame = parseSSEBlock(block);
|
|
298
|
+
if (frame)
|
|
299
|
+
yield frame;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
while (true) {
|
|
304
|
+
const { done, value } = await reader.read();
|
|
305
|
+
if (done)
|
|
306
|
+
break;
|
|
307
|
+
yield* drain(decoder.decode(value, { stream: true }));
|
|
308
|
+
}
|
|
309
|
+
yield* drain(decoder.decode());
|
|
310
|
+
if (buffer.trim().length > 0) {
|
|
311
|
+
const frame = parseSSEBlock(buffer);
|
|
312
|
+
if (frame)
|
|
313
|
+
yield frame;
|
|
314
|
+
buffer = '';
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
removeAbortHandler?.();
|
|
319
|
+
try {
|
|
320
|
+
reader.releaseLock();
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
// releaseLock can throw if the reader is already detached; ignore.
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function findFrameTerminator(s) {
|
|
328
|
+
const lf = s.indexOf('\n\n');
|
|
329
|
+
const crlf = s.indexOf('\r\n\r\n');
|
|
330
|
+
if (lf < 0 && crlf < 0)
|
|
331
|
+
return null;
|
|
332
|
+
if (lf < 0)
|
|
333
|
+
return { terminatorStart: crlf, terminatorEnd: crlf + 4 };
|
|
334
|
+
if (crlf < 0)
|
|
335
|
+
return { terminatorStart: lf, terminatorEnd: lf + 2 };
|
|
336
|
+
return lf < crlf
|
|
337
|
+
? { terminatorStart: lf, terminatorEnd: lf + 2 }
|
|
338
|
+
: { terminatorStart: crlf, terminatorEnd: crlf + 4 };
|
|
339
|
+
}
|
|
340
|
+
function parseSSEBlock(block) {
|
|
341
|
+
let event = '';
|
|
342
|
+
let id;
|
|
343
|
+
let retry;
|
|
344
|
+
const dataLines = [];
|
|
345
|
+
for (const line of block.split(/\r?\n/)) {
|
|
346
|
+
if (line === '' || line.startsWith(':'))
|
|
347
|
+
continue;
|
|
348
|
+
const colon = line.indexOf(':');
|
|
349
|
+
const field = colon < 0 ? line : line.slice(0, colon);
|
|
350
|
+
let value = colon < 0 ? '' : line.slice(colon + 1);
|
|
351
|
+
if (value.startsWith(' '))
|
|
352
|
+
value = value.slice(1);
|
|
353
|
+
if (field === 'event') {
|
|
354
|
+
event = value;
|
|
355
|
+
}
|
|
356
|
+
else if (field === 'data') {
|
|
357
|
+
dataLines.push(value);
|
|
358
|
+
}
|
|
359
|
+
else if (field === 'id') {
|
|
360
|
+
id = value;
|
|
361
|
+
}
|
|
362
|
+
else if (field === 'retry') {
|
|
363
|
+
const parsed = Number.parseInt(value, 10);
|
|
364
|
+
if (Number.isFinite(parsed) && parsed >= 0)
|
|
365
|
+
retry = parsed;
|
|
366
|
+
}
|
|
367
|
+
// Unknown fields are ignored per the SSE spec.
|
|
368
|
+
}
|
|
369
|
+
// Surface metadata-only frames (id-only or retry-only) so the reconnect
|
|
370
|
+
// loop can observe ``Last-Event-ID`` advances and server-sent retry hints
|
|
371
|
+
// even on heartbeats / replay-position markers.
|
|
372
|
+
if (!event && dataLines.length === 0 && id === undefined && retry === undefined) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
event,
|
|
377
|
+
data: dataLines.length > 0 ? dataLines.join('\n') : undefined,
|
|
378
|
+
id,
|
|
379
|
+
retry,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Validate and reattach the discriminator to a frame's JSON payload.
|
|
384
|
+
*
|
|
385
|
+
* The platform-api SSE serializer pops ``event_type`` out of the JSON body
|
|
386
|
+
* (it lives in the SSE ``event:`` line). Reattach it so the resulting
|
|
387
|
+
* value is a well-formed {@link WorkspaceSSEEvent} union member.
|
|
388
|
+
*
|
|
389
|
+
* Drift-tolerant: an unparseable payload, non-object payload, or unknown
|
|
390
|
+
* ``event:`` discriminator is silently dropped (returns ``null``), matching
|
|
391
|
+
* the behavior of the analogous turn-stream parser.
|
|
392
|
+
*/
|
|
393
|
+
function parseWorkspaceFrame(eventName, dataJson) {
|
|
394
|
+
let payload;
|
|
395
|
+
try {
|
|
396
|
+
payload = JSON.parse(dataJson);
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
if (typeof payload !== 'object' || payload === null || Array.isArray(payload))
|
|
402
|
+
return null;
|
|
403
|
+
// The discriminator is whatever the server's `event:` line says. We trust
|
|
404
|
+
// the platform-api union: anything outside the generated literal type is
|
|
405
|
+
// dropped at the static-type boundary by the consumer's `switch`.
|
|
406
|
+
return {
|
|
407
|
+
...payload,
|
|
408
|
+
event_type: eventName,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
function readStatus(error) {
|
|
412
|
+
if (typeof error !== 'object' || error === null)
|
|
413
|
+
return undefined;
|
|
414
|
+
const status = error.statusCode;
|
|
415
|
+
return typeof status === 'number' ? status : undefined;
|
|
416
|
+
}
|
|
417
|
+
function safeStringify(value) {
|
|
418
|
+
try {
|
|
419
|
+
return JSON.stringify(value);
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
return String(value);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function jitter(ms) {
|
|
426
|
+
// Full jitter: pick a random delay in [0, ms]. Avoids reconnect stampedes
|
|
427
|
+
// when many clients reconnect simultaneously after a deploy.
|
|
428
|
+
return Math.floor(Math.random() * Math.max(1, ms));
|
|
429
|
+
}
|
|
430
|
+
function clampDelay(ms, floor, ceiling) {
|
|
431
|
+
const lo = floor ?? DEFAULT_INITIAL_DELAY_MS;
|
|
432
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
433
|
+
return lo;
|
|
434
|
+
return Math.min(Math.max(ms, lo), ceiling);
|
|
435
|
+
}
|
|
436
|
+
async function abortableSleep(ms, signal) {
|
|
437
|
+
if (signal.aborted)
|
|
438
|
+
return false;
|
|
439
|
+
return new Promise((resolve) => {
|
|
440
|
+
const timer = setTimeout(() => {
|
|
441
|
+
signal.removeEventListener('abort', onAbort);
|
|
442
|
+
resolve(true);
|
|
443
|
+
}, ms);
|
|
444
|
+
const onAbort = () => {
|
|
445
|
+
clearTimeout(timer);
|
|
446
|
+
signal.removeEventListener('abort', onAbort);
|
|
447
|
+
resolve(false);
|
|
448
|
+
};
|
|
449
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/resources/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AA0FnD,MAAM,wBAAwB,GAAG,IAAI,CAAA;AACrC,MAAM,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U,CAAC,EAAU,EAAE,KAAyB,EAAE,OAAe;IACxE,MAAM,EAAE,GAAG,KAAK,IAAI,wBAAwB,CAAA;IAC5C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,EAAE,CAAA;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,EAAU,EAAE,MAAmB;IAC3D,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAChC,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5C,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC,EAAE,EAAE,CAAC,CAAA;QACN,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5C,OAAO,CAAC,KAAK,CAAC,CAAA;QAChB,CAAC,CAAA;QACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -3,16 +3,12 @@ import { WorkspaceScopedResource, extractData } from './base.js';
|
|
|
3
3
|
* Manage Amigo Platform workspaces.
|
|
4
4
|
* Workspaces are the top-level tenancy boundary for all resources.
|
|
5
5
|
*
|
|
6
|
-
* Note: list
|
|
7
|
-
*
|
|
6
|
+
* Note: list operates at account level (/v1/workspaces); creation goes
|
|
7
|
+
* through the authenticated self-service flow. The unauthenticated
|
|
8
|
+
* ``POST /v1/workspaces`` was removed in platform-api PR #2378 (orphan-
|
|
9
|
+
* maker). Get/update/archive/provision operate on a specific workspace.
|
|
8
10
|
*/
|
|
9
11
|
export class WorkspacesResource extends WorkspaceScopedResource {
|
|
10
|
-
/** Create a new workspace (unauthenticated — no owner membership created) */
|
|
11
|
-
async create(body) {
|
|
12
|
-
return extractData(await this.client.POST('/v1/workspaces', {
|
|
13
|
-
body,
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
12
|
/** Create a workspace for the authenticated user and attach owner access */
|
|
17
13
|
async createSelfService(body) {
|
|
18
14
|
return extractData(await this.client.POST('/v1/workspaces/self-service', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/resources/workspaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAGhE
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/resources/workspaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAGhE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAmB,SAAQ,uBAAuB;IAC7D,4EAA4E;IAC5E,KAAK,CAAC,iBAAiB,CAAC,IAAqD;QAC3E,OAAO,WAAW,CAChB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE;YACpD,IAAI;SACL,CAAC,CACH,CAAA;IACH,CAAC;IAED,wDAAwD;IACxD,KAAK,CAAC,IAAI,CAAC,MAAmB;QAC5B,OAAO,WAAW,CAChB,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE;YACtC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;SAC1B,CAAC,CACH,CAAA;IACH,CAAC;IAED,cAAc,CAAC,MAAmB;QAChC,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AC;IAED,gDAAgD;IAChD,KAAK,CAAC,gBAAgB,CAAC,MAAiC,EAAE,EAAyB;QACjF,OAAO,WAAW,CAChB,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iDAAiD,EAAE;YACvE,MAAM,EAAE;gBACN,IAAI,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;gBAC9C,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS;aACvC;SACF,CAAC,CACH,CAAA;IACH,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,kBAAkB,CACtB,IAAwD,EACxD,EAAyB;QAEzB,OAAO,WAAW,CAChB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mDAAmD,EAAE;YAC1E,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YAC1D,IAAI;SACL,CAAC,CACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -560,11 +560,7 @@ export interface paths {
|
|
|
560
560
|
*/
|
|
561
561
|
get: operations["list-workspaces"];
|
|
562
562
|
put?: never;
|
|
563
|
-
|
|
564
|
-
* Create a workspace
|
|
565
|
-
* @description Bootstrap a new workspace. No authentication required.
|
|
566
|
-
*/
|
|
567
|
-
post: operations["create-workspace"];
|
|
563
|
+
post?: never;
|
|
568
564
|
delete?: never;
|
|
569
565
|
options?: never;
|
|
570
566
|
head?: never;
|
|
@@ -11814,10 +11810,7 @@ export interface components {
|
|
|
11814
11810
|
* @default true
|
|
11815
11811
|
*/
|
|
11816
11812
|
enabled?: boolean;
|
|
11817
|
-
/**
|
|
11818
|
-
* Endpoints
|
|
11819
|
-
* @default []
|
|
11820
|
-
*/
|
|
11813
|
+
/** Endpoints */
|
|
11821
11814
|
endpoints?: components["schemas"]["EndpointConfig-Input"][];
|
|
11822
11815
|
/** Mcp Args */
|
|
11823
11816
|
mcp_args?: string[] | null;
|
|
@@ -11831,7 +11824,10 @@ export interface components {
|
|
|
11831
11824
|
mcp_transport?: ("stdio" | "sse" | "http") | null;
|
|
11832
11825
|
/** Mcp Url */
|
|
11833
11826
|
mcp_url?: string | null;
|
|
11834
|
-
/**
|
|
11827
|
+
/**
|
|
11828
|
+
* Name
|
|
11829
|
+
* @description Slug-like identifier, lowercase alphanumeric + hyphens/underscores.
|
|
11830
|
+
*/
|
|
11835
11831
|
name: string;
|
|
11836
11832
|
/**
|
|
11837
11833
|
* Protocol
|
|
@@ -21413,6 +21409,10 @@ export interface components {
|
|
|
21413
21409
|
/**
|
|
21414
21410
|
* SecretInput
|
|
21415
21411
|
* @description Inline secret value — auto-provisioned to SSM on create/update.
|
|
21412
|
+
*
|
|
21413
|
+
* Bounded to 8192 chars: large enough for a PEM RSA-4096 private key
|
|
21414
|
+
* plus a short cert chain, small enough that an adversary cannot
|
|
21415
|
+
* push a 100 MB "secret" through to SSM.
|
|
21416
21416
|
*/
|
|
21417
21417
|
SecretInput: {
|
|
21418
21418
|
/** Value */
|
|
@@ -23559,10 +23559,7 @@ export interface components {
|
|
|
23559
23559
|
};
|
|
23560
23560
|
/** TestEndpointRequest */
|
|
23561
23561
|
TestEndpointRequest: {
|
|
23562
|
-
/**
|
|
23563
|
-
* Params
|
|
23564
|
-
* @default {}
|
|
23565
|
-
*/
|
|
23562
|
+
/** Params */
|
|
23566
23563
|
params?: {
|
|
23567
23564
|
[key: string]: unknown;
|
|
23568
23565
|
};
|
|
@@ -28100,44 +28097,6 @@ export interface operations {
|
|
|
28100
28097
|
};
|
|
28101
28098
|
};
|
|
28102
28099
|
};
|
|
28103
|
-
"create-workspace": {
|
|
28104
|
-
parameters: {
|
|
28105
|
-
query?: never;
|
|
28106
|
-
header?: never;
|
|
28107
|
-
path?: never;
|
|
28108
|
-
cookie?: never;
|
|
28109
|
-
};
|
|
28110
|
-
requestBody: {
|
|
28111
|
-
content: {
|
|
28112
|
-
"application/json": components["schemas"]["CreateWorkspaceRequest"];
|
|
28113
|
-
};
|
|
28114
|
-
};
|
|
28115
|
-
responses: {
|
|
28116
|
-
/** @description Successful Response */
|
|
28117
|
-
201: {
|
|
28118
|
-
headers: {
|
|
28119
|
-
[name: string]: unknown;
|
|
28120
|
-
};
|
|
28121
|
-
content: {
|
|
28122
|
-
"application/json": components["schemas"]["WorkspaceResponse"];
|
|
28123
|
-
};
|
|
28124
|
-
};
|
|
28125
|
-
/** @description Workspace slug already taken. */
|
|
28126
|
-
409: {
|
|
28127
|
-
headers: {
|
|
28128
|
-
[name: string]: unknown;
|
|
28129
|
-
};
|
|
28130
|
-
content?: never;
|
|
28131
|
-
};
|
|
28132
|
-
/** @description Invalid request body. */
|
|
28133
|
-
422: {
|
|
28134
|
-
headers: {
|
|
28135
|
-
[name: string]: unknown;
|
|
28136
|
-
};
|
|
28137
|
-
content?: never;
|
|
28138
|
-
};
|
|
28139
|
-
};
|
|
28140
|
-
};
|
|
28141
28100
|
"create-self-service-workspace": {
|
|
28142
28101
|
parameters: {
|
|
28143
28102
|
query?: never;
|