@pylonsync/functions 0.4.21 → 0.4.22
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/dist/types.d.ts +21 -6
- package/package.json +1 -1
- package/src/types.ts +21 -6
package/dist/types.d.ts
CHANGED
|
@@ -255,10 +255,20 @@ export interface DbWriter extends DbReader {
|
|
|
255
255
|
*/
|
|
256
256
|
advisoryLock(key: string): Promise<void>;
|
|
257
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Progressive output to the calling client (SSE). Every fn stream is
|
|
260
|
+
* RESUMABLE: the host buffers each chunk under a server-assigned
|
|
261
|
+
* stream id (the `X-Pylon-Stream-Id` response header) with a
|
|
262
|
+
* monotonically increasing sequence, so a client that loses its
|
|
263
|
+
* connection reconnects to `GET /api/fn-streams/<id>` from its last
|
|
264
|
+
* cursor and misses nothing — including the terminal result after the
|
|
265
|
+
* handler already returned. The handler never blocks on (or notices)
|
|
266
|
+
* client disconnects; it just keeps writing.
|
|
267
|
+
*/
|
|
258
268
|
export interface Stream {
|
|
259
269
|
/** Write a text chunk to the client (SSE). */
|
|
260
270
|
write(data: string): void;
|
|
261
|
-
/** Write a typed SSE event. */
|
|
271
|
+
/** Write a typed SSE event (`event: <name>` framing on the wire). */
|
|
262
272
|
writeEvent(event: string, data: string): void;
|
|
263
273
|
}
|
|
264
274
|
export interface Scheduler {
|
|
@@ -452,11 +462,16 @@ export type LlmStreamEvent = {
|
|
|
452
462
|
* `useRoom(roomId, userId)`, and the same delivery path a member's
|
|
453
463
|
* `broadcast()` uses.
|
|
454
464
|
*
|
|
455
|
-
* This is the surface for
|
|
456
|
-
*
|
|
457
|
-
* every watcher gets them, not just the caller
|
|
458
|
-
* response.
|
|
459
|
-
*
|
|
465
|
+
* This is the surface for fanning agent output out to a second device
|
|
466
|
+
* or a second tab that is CONNECTED RIGHT NOW: write tokens to the
|
|
467
|
+
* room and every current watcher gets them, not just the caller
|
|
468
|
+
* holding the HTTP response. Delivery is live-only — a subscriber that
|
|
469
|
+
* reconnects does NOT replay messages sent during its gap. For output
|
|
470
|
+
* that must survive a closed tab or a dropped connection, rely on the
|
|
471
|
+
* fn stream itself: every `ctx.stream` stream is buffered server-side
|
|
472
|
+
* and resumable by stream id (`streamFn`'s `onStreamId` +
|
|
473
|
+
* `resumeStream` in the clients), including the final result after the
|
|
474
|
+
* handler finished.
|
|
460
475
|
*
|
|
461
476
|
* Not available in queries — a reactive handler re-runs on every dep
|
|
462
477
|
* change, which would re-broadcast each time.
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -312,11 +312,21 @@ export interface DbWriter extends DbReader {
|
|
|
312
312
|
// Streaming
|
|
313
313
|
// ---------------------------------------------------------------------------
|
|
314
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Progressive output to the calling client (SSE). Every fn stream is
|
|
317
|
+
* RESUMABLE: the host buffers each chunk under a server-assigned
|
|
318
|
+
* stream id (the `X-Pylon-Stream-Id` response header) with a
|
|
319
|
+
* monotonically increasing sequence, so a client that loses its
|
|
320
|
+
* connection reconnects to `GET /api/fn-streams/<id>` from its last
|
|
321
|
+
* cursor and misses nothing — including the terminal result after the
|
|
322
|
+
* handler already returned. The handler never blocks on (or notices)
|
|
323
|
+
* client disconnects; it just keeps writing.
|
|
324
|
+
*/
|
|
315
325
|
export interface Stream {
|
|
316
326
|
/** Write a text chunk to the client (SSE). */
|
|
317
327
|
write(data: string): void;
|
|
318
328
|
|
|
319
|
-
/** Write a typed SSE event. */
|
|
329
|
+
/** Write a typed SSE event (`event: <name>` framing on the wire). */
|
|
320
330
|
writeEvent(event: string, data: string): void;
|
|
321
331
|
}
|
|
322
332
|
|
|
@@ -529,11 +539,16 @@ export type LlmStreamEvent =
|
|
|
529
539
|
* `useRoom(roomId, userId)`, and the same delivery path a member's
|
|
530
540
|
* `broadcast()` uses.
|
|
531
541
|
*
|
|
532
|
-
* This is the surface for
|
|
533
|
-
*
|
|
534
|
-
* every watcher gets them, not just the caller
|
|
535
|
-
* response.
|
|
536
|
-
*
|
|
542
|
+
* This is the surface for fanning agent output out to a second device
|
|
543
|
+
* or a second tab that is CONNECTED RIGHT NOW: write tokens to the
|
|
544
|
+
* room and every current watcher gets them, not just the caller
|
|
545
|
+
* holding the HTTP response. Delivery is live-only — a subscriber that
|
|
546
|
+
* reconnects does NOT replay messages sent during its gap. For output
|
|
547
|
+
* that must survive a closed tab or a dropped connection, rely on the
|
|
548
|
+
* fn stream itself: every `ctx.stream` stream is buffered server-side
|
|
549
|
+
* and resumable by stream id (`streamFn`'s `onStreamId` +
|
|
550
|
+
* `resumeStream` in the clients), including the final result after the
|
|
551
|
+
* handler finished.
|
|
537
552
|
*
|
|
538
553
|
* Not available in queries — a reactive handler re-runs on every dep
|
|
539
554
|
* change, which would re-broadcast each time.
|