@gleanwork/api-client 0.19.2 → 0.20.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/README.md +38 -0
- package/dist/commonjs/__tests__/messages.test.js +1 -1
- package/dist/commonjs/__tests__/summarize.test.js +4 -4
- package/dist/commonjs/__tests__/summarize.test.js.map +1 -1
- package/dist/commonjs/funcs/chatCreate.d.ts +1 -7
- package/dist/commonjs/funcs/chatCreate.d.ts.map +1 -1
- package/dist/commonjs/funcs/chatCreate.js +3 -12
- package/dist/commonjs/funcs/chatCreate.js.map +1 -1
- package/dist/commonjs/funcs/chatCreateStream.d.ts +20 -0
- package/dist/commonjs/funcs/chatCreateStream.d.ts.map +1 -0
- package/dist/commonjs/funcs/chatCreateStream.js +134 -0
- package/dist/commonjs/funcs/chatCreateStream.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/lib/event-streams.d.ts +23 -0
- package/dist/commonjs/lib/event-streams.d.ts.map +1 -0
- package/dist/commonjs/lib/event-streams.js +168 -0
- package/dist/commonjs/lib/event-streams.js.map +1 -0
- package/dist/commonjs/models/components/chatmessagefragment.d.ts +1 -1
- package/dist/commonjs/models/components/index.d.ts +15 -1
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +15 -1
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/platformchatcompletedresponse.d.ts +4 -4
- package/dist/commonjs/models/components/platformchatcompletedresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/platformchatcompletedresponse.js +4 -5
- package/dist/commonjs/models/components/platformchatcompletedresponse.js.map +1 -1
- package/dist/commonjs/models/components/platformchatfailedresponse.d.ts +44 -0
- package/dist/commonjs/models/components/platformchatfailedresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatfailedresponse.js +71 -0
- package/dist/commonjs/models/components/platformchatfailedresponse.js.map +1 -0
- package/dist/commonjs/models/components/platformchatresponseerror.d.ts +16 -0
- package/dist/commonjs/models/components/platformchatresponseerror.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatresponseerror.js +52 -0
- package/dist/commonjs/models/components/platformchatresponseerror.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreameventserversentevent.d.ts +17 -0
- package/dist/commonjs/models/components/platformchatstreameventserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreameventserversentevent.js +62 -0
- package/dist/commonjs/models/components/platformchatstreameventserversentevent.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdelta.d.ts +24 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdelta.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdelta.js +58 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdelta.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdeltaserversentevent.d.ts +13 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdeltaserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdeltaserversentevent.js +64 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdeltaserversentevent.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdone.d.ts +24 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdone.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdone.js +58 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdone.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdoneserversentevent.d.ts +13 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdoneserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdoneserversentevent.js +64 -0
- package/dist/commonjs/models/components/platformchatstreamoutputtextdoneserversentevent.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamprogress.d.ts +29 -0
- package/dist/commonjs/models/components/platformchatstreamprogress.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamprogress.js +58 -0
- package/dist/commonjs/models/components/platformchatstreamprogress.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamprogressserversentevent.d.ts +13 -0
- package/dist/commonjs/models/components/platformchatstreamprogressserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamprogressserversentevent.js +64 -0
- package/dist/commonjs/models/components/platformchatstreamprogressserversentevent.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompleted.d.ts +25 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompleted.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompleted.js +60 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompleted.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompletedserversentevent.d.ts +13 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompletedserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompletedserversentevent.js +64 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecompletedserversentevent.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreated.d.ts +23 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreated.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreated.js +57 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreated.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreatedserversentevent.d.ts +13 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreatedserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreatedserversentevent.js +64 -0
- package/dist/commonjs/models/components/platformchatstreamresponsecreatedserversentevent.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailed.d.ts +25 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailed.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailed.js +59 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailed.js.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailedserversentevent.d.ts +13 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailedserversentevent.d.ts.map +1 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailedserversentevent.js +64 -0
- package/dist/commonjs/models/components/platformchatstreamresponsefailedserversentevent.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +1 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +1 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/platformchatcreate.d.ts +41 -5
- package/dist/commonjs/models/operations/platformchatcreate.d.ts.map +1 -1
- package/dist/commonjs/models/operations/platformchatcreate.js +20 -7
- package/dist/commonjs/models/operations/platformchatcreate.js.map +1 -1
- package/dist/commonjs/models/operations/platformchatcreatestream.d.ts +45 -0
- package/dist/commonjs/models/operations/platformchatcreatestream.d.ts.map +1 -0
- package/dist/commonjs/models/{components/platformchatcreaterequest.js → operations/platformchatcreatestream.js} +17 -14
- package/dist/commonjs/models/operations/platformchatcreatestream.js.map +1 -0
- package/dist/commonjs/react-query/chatCreate.d.ts +4 -10
- package/dist/commonjs/react-query/chatCreate.d.ts.map +1 -1
- package/dist/commonjs/react-query/chatCreate.js +0 -3
- package/dist/commonjs/react-query/chatCreate.js.map +1 -1
- package/dist/commonjs/react-query/chatCreateStream.d.ts +31 -0
- package/dist/commonjs/react-query/chatCreateStream.d.ts.map +1 -0
- package/dist/commonjs/react-query/chatCreateStream.js +48 -0
- package/dist/commonjs/react-query/chatCreateStream.js.map +1 -0
- package/dist/commonjs/react-query/index.d.ts +1 -0
- package/dist/commonjs/react-query/index.d.ts.map +1 -1
- package/dist/commonjs/react-query/index.js +1 -0
- package/dist/commonjs/react-query/index.js.map +1 -1
- package/dist/commonjs/sdk/chat.d.ts +9 -5
- package/dist/commonjs/sdk/chat.d.ts.map +1 -1
- package/dist/commonjs/sdk/chat.js +11 -3
- package/dist/commonjs/sdk/chat.js.map +1 -1
- package/dist/esm/__tests__/messages.test.js +1 -1
- package/dist/esm/__tests__/summarize.test.js +4 -4
- package/dist/esm/__tests__/summarize.test.js.map +1 -1
- package/dist/esm/funcs/chatCreate.d.ts +1 -7
- package/dist/esm/funcs/chatCreate.d.ts.map +1 -1
- package/dist/esm/funcs/chatCreate.js +3 -11
- package/dist/esm/funcs/chatCreate.js.map +1 -1
- package/dist/esm/funcs/chatCreateStream.d.ts +20 -0
- package/dist/esm/funcs/chatCreateStream.d.ts.map +1 -0
- package/dist/esm/funcs/chatCreateStream.js +98 -0
- package/dist/esm/funcs/chatCreateStream.js.map +1 -0
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/lib/event-streams.d.ts +23 -0
- package/dist/esm/lib/event-streams.d.ts.map +1 -0
- package/dist/esm/lib/event-streams.js +164 -0
- package/dist/esm/lib/event-streams.js.map +1 -0
- package/dist/esm/models/components/chatmessagefragment.d.ts +1 -1
- package/dist/esm/models/components/index.d.ts +15 -1
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +15 -1
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/platformchatcompletedresponse.d.ts +4 -4
- package/dist/esm/models/components/platformchatcompletedresponse.d.ts.map +1 -1
- package/dist/esm/models/components/platformchatcompletedresponse.js +3 -4
- package/dist/esm/models/components/platformchatcompletedresponse.js.map +1 -1
- package/dist/esm/models/components/platformchatfailedresponse.d.ts +44 -0
- package/dist/esm/models/components/platformchatfailedresponse.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatfailedresponse.js +34 -0
- package/dist/esm/models/components/platformchatfailedresponse.js.map +1 -0
- package/dist/esm/models/components/platformchatresponseerror.d.ts +16 -0
- package/dist/esm/models/components/platformchatresponseerror.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatresponseerror.js +15 -0
- package/dist/esm/models/components/platformchatresponseerror.js.map +1 -0
- package/dist/esm/models/components/platformchatstreameventserversentevent.d.ts +17 -0
- package/dist/esm/models/components/platformchatstreameventserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreameventserversentevent.js +25 -0
- package/dist/esm/models/components/platformchatstreameventserversentevent.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdelta.d.ts +24 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdelta.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdelta.js +21 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdelta.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdeltaserversentevent.d.ts +13 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdeltaserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdeltaserversentevent.js +27 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdeltaserversentevent.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdone.d.ts +24 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdone.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdone.js +21 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdone.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdoneserversentevent.d.ts +13 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdoneserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdoneserversentevent.js +27 -0
- package/dist/esm/models/components/platformchatstreamoutputtextdoneserversentevent.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamprogress.d.ts +29 -0
- package/dist/esm/models/components/platformchatstreamprogress.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamprogress.js +21 -0
- package/dist/esm/models/components/platformchatstreamprogress.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamprogressserversentevent.d.ts +13 -0
- package/dist/esm/models/components/platformchatstreamprogressserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamprogressserversentevent.js +27 -0
- package/dist/esm/models/components/platformchatstreamprogressserversentevent.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecompleted.d.ts +25 -0
- package/dist/esm/models/components/platformchatstreamresponsecompleted.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecompleted.js +23 -0
- package/dist/esm/models/components/platformchatstreamresponsecompleted.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecompletedserversentevent.d.ts +13 -0
- package/dist/esm/models/components/platformchatstreamresponsecompletedserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecompletedserversentevent.js +27 -0
- package/dist/esm/models/components/platformchatstreamresponsecompletedserversentevent.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecreated.d.ts +23 -0
- package/dist/esm/models/components/platformchatstreamresponsecreated.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecreated.js +20 -0
- package/dist/esm/models/components/platformchatstreamresponsecreated.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecreatedserversentevent.d.ts +13 -0
- package/dist/esm/models/components/platformchatstreamresponsecreatedserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsecreatedserversentevent.js +27 -0
- package/dist/esm/models/components/platformchatstreamresponsecreatedserversentevent.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsefailed.d.ts +25 -0
- package/dist/esm/models/components/platformchatstreamresponsefailed.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsefailed.js +22 -0
- package/dist/esm/models/components/platformchatstreamresponsefailed.js.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsefailedserversentevent.d.ts +13 -0
- package/dist/esm/models/components/platformchatstreamresponsefailedserversentevent.d.ts.map +1 -0
- package/dist/esm/models/components/platformchatstreamresponsefailedserversentevent.js +27 -0
- package/dist/esm/models/components/platformchatstreamresponsefailedserversentevent.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +1 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +1 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/platformchatcreate.d.ts +41 -5
- package/dist/esm/models/operations/platformchatcreate.d.ts.map +1 -1
- package/dist/esm/models/operations/platformchatcreate.js +17 -5
- package/dist/esm/models/operations/platformchatcreate.js.map +1 -1
- package/dist/esm/models/operations/platformchatcreatestream.d.ts +45 -0
- package/dist/esm/models/operations/platformchatcreatestream.d.ts.map +1 -0
- package/dist/esm/models/operations/platformchatcreatestream.js +28 -0
- package/dist/esm/models/operations/platformchatcreatestream.js.map +1 -0
- package/dist/esm/react-query/chatCreate.d.ts +4 -10
- package/dist/esm/react-query/chatCreate.d.ts.map +1 -1
- package/dist/esm/react-query/chatCreate.js +0 -1
- package/dist/esm/react-query/chatCreate.js.map +1 -1
- package/dist/esm/react-query/chatCreateStream.d.ts +31 -0
- package/dist/esm/react-query/chatCreateStream.d.ts.map +1 -0
- package/dist/esm/react-query/chatCreateStream.js +43 -0
- package/dist/esm/react-query/chatCreateStream.js.map +1 -0
- package/dist/esm/react-query/index.d.ts +1 -0
- package/dist/esm/react-query/index.d.ts.map +1 -1
- package/dist/esm/react-query/index.js +1 -0
- package/dist/esm/react-query/index.js.map +1 -1
- package/dist/esm/sdk/chat.d.ts +9 -5
- package/dist/esm/sdk/chat.d.ts.map +1 -1
- package/dist/esm/sdk/chat.js +10 -1
- package/dist/esm/sdk/chat.js.map +1 -1
- package/jsr.json +2 -1
- package/package.json +1 -1
- package/src/__tests__/messages.test.ts +1 -1
- package/src/__tests__/summarize.test.ts +4 -4
- package/src/funcs/chatCreate.ts +10 -19
- package/src/funcs/chatCreateStream.ts +197 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/event-streams.ts +192 -0
- package/src/models/components/chatmessagefragment.ts +1 -1
- package/src/models/components/index.ts +15 -1
- package/src/models/components/platformchatcompletedresponse.ts +9 -6
- package/src/models/components/platformchatfailedresponse.ts +92 -0
- package/src/models/components/platformchatresponseerror.ts +39 -0
- package/src/models/components/platformchatstreameventserversentevent.ts +69 -0
- package/src/models/components/platformchatstreamoutputtextdelta.ts +55 -0
- package/src/models/components/platformchatstreamoutputtextdeltaserversentevent.ts +55 -0
- package/src/models/components/platformchatstreamoutputtextdone.ts +55 -0
- package/src/models/components/platformchatstreamoutputtextdoneserversentevent.ts +55 -0
- package/src/models/components/platformchatstreamprogress.ts +59 -0
- package/src/models/components/platformchatstreamprogressserversentevent.ts +54 -0
- package/src/models/components/platformchatstreamresponsecompleted.ts +59 -0
- package/src/models/components/platformchatstreamresponsecompletedserversentevent.ts +55 -0
- package/src/models/components/platformchatstreamresponsecreated.ts +53 -0
- package/src/models/components/platformchatstreamresponsecreatedserversentevent.ts +55 -0
- package/src/models/components/platformchatstreamresponsefailed.ts +59 -0
- package/src/models/components/platformchatstreamresponsefailedserversentevent.ts +55 -0
- package/src/models/operations/index.ts +1 -0
- package/src/models/operations/platformchatcreate.ts +75 -17
- package/src/models/operations/platformchatcreatestream.ts +96 -0
- package/src/react-query/chatCreate.ts +5 -7
- package/src/react-query/chatCreateStream.ts +115 -0
- package/src/react-query/index.ts +1 -0
- package/src/sdk/chat.ts +23 -6
- package/dist/commonjs/models/components/platformchatcreaterequest.d.ts +0 -50
- package/dist/commonjs/models/components/platformchatcreaterequest.d.ts.map +0 -1
- package/dist/commonjs/models/components/platformchatcreaterequest.js.map +0 -1
- package/dist/esm/models/components/platformchatcreaterequest.d.ts +0 -50
- package/dist/esm/models/components/platformchatcreaterequest.d.ts.map +0 -1
- package/dist/esm/models/components/platformchatcreaterequest.js +0 -25
- package/dist/esm/models/components/platformchatcreaterequest.js.map +0 -1
- package/src/models/components/platformchatcreaterequest.ts +0 -90
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 3f731f808a79
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Some environments' type definitions do not include ReadableStream's async
|
|
7
|
+
// iterator, even though the runtime supports it or this class polyfills it.
|
|
8
|
+
// Declare the method here so Stream can override it and preserve T in for-await.
|
|
9
|
+
declare global {
|
|
10
|
+
interface ReadableStream<R = any> {
|
|
11
|
+
[Symbol.asyncIterator](): {
|
|
12
|
+
next(): Promise<IteratorResult<R, undefined>>;
|
|
13
|
+
throw?(e?: unknown): Promise<IteratorResult<R, undefined>>;
|
|
14
|
+
return?(): Promise<IteratorResult<R, undefined>>;
|
|
15
|
+
[Symbol.asyncIterator](): any;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SseMessage<T> = {
|
|
21
|
+
data?: T | undefined;
|
|
22
|
+
event?: string | null | undefined;
|
|
23
|
+
id?: string | null | undefined;
|
|
24
|
+
retry?: number | null | undefined;
|
|
25
|
+
};
|
|
26
|
+
export class EventStream<T extends SseMessage<unknown>>
|
|
27
|
+
extends ReadableStream<T>
|
|
28
|
+
{
|
|
29
|
+
constructor(
|
|
30
|
+
responseBody: ReadableStream<Uint8Array>,
|
|
31
|
+
parse: (x: SseMessage<string>) => IteratorResult<T, undefined>,
|
|
32
|
+
opts?: { dataRequired?: boolean },
|
|
33
|
+
) {
|
|
34
|
+
const upstream = responseBody.getReader();
|
|
35
|
+
let buffer: Uint8Array = new Uint8Array(4096);
|
|
36
|
+
let bufferLen = 0;
|
|
37
|
+
let searchStart = 0;
|
|
38
|
+
const state = { eventId: undefined as string | undefined };
|
|
39
|
+
const dataRequired = opts?.dataRequired ?? true;
|
|
40
|
+
super({
|
|
41
|
+
async pull(downstream) {
|
|
42
|
+
try {
|
|
43
|
+
while (true) {
|
|
44
|
+
const match = findBoundary(buffer, bufferLen, searchStart);
|
|
45
|
+
if (!match) {
|
|
46
|
+
// Bytes before the trailing MAX_BOUNDARY_LEN-1 were already
|
|
47
|
+
// scanned with full lookahead and cannot start a boundary even
|
|
48
|
+
// once more data arrives, so the next scan can skip them.
|
|
49
|
+
searchStart = Math.max(0, bufferLen - MAX_BOUNDARY_LEN + 1);
|
|
50
|
+
const chunk = await upstream.read();
|
|
51
|
+
if (chunk.done) return downstream.close();
|
|
52
|
+
if (bufferLen + chunk.value.length > buffer.length) {
|
|
53
|
+
const grown = new Uint8Array(
|
|
54
|
+
Math.max(buffer.length * 2, bufferLen + chunk.value.length),
|
|
55
|
+
);
|
|
56
|
+
grown.set(buffer.subarray(0, bufferLen));
|
|
57
|
+
buffer = grown;
|
|
58
|
+
}
|
|
59
|
+
buffer.set(chunk.value, bufferLen);
|
|
60
|
+
bufferLen += chunk.value.length;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const message = buffer.slice(0, match.index);
|
|
64
|
+
buffer.copyWithin(0, match.index + match.length, bufferLen);
|
|
65
|
+
bufferLen -= match.index + match.length;
|
|
66
|
+
if (buffer.length > 4096 && bufferLen <= buffer.length >> 2) {
|
|
67
|
+
// Release oversized capacity retained after an unusually large
|
|
68
|
+
// event so long-lived streams do not hold peak memory.
|
|
69
|
+
const shrunk = new Uint8Array(Math.max(4096, bufferLen * 2));
|
|
70
|
+
shrunk.set(buffer.subarray(0, bufferLen));
|
|
71
|
+
buffer = shrunk;
|
|
72
|
+
}
|
|
73
|
+
searchStart = 0;
|
|
74
|
+
const item = parseMessage(message, parse, state, dataRequired);
|
|
75
|
+
if (item && !item.done) return downstream.enqueue(item.value);
|
|
76
|
+
if (item?.done) {
|
|
77
|
+
await upstream.cancel("done");
|
|
78
|
+
return downstream.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
downstream.error(e);
|
|
83
|
+
await upstream.cancel(e);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
cancel: reason => upstream.cancel(reason),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Use ReadableStream's iterator return type instead of `any` so stream events
|
|
91
|
+
// keep their generated type in for-await loops.
|
|
92
|
+
override [Symbol.asyncIterator](): ReturnType<
|
|
93
|
+
ReadableStream<T>[typeof Symbol.asyncIterator]
|
|
94
|
+
> {
|
|
95
|
+
const fn = (ReadableStream.prototype as any)[Symbol.asyncIterator];
|
|
96
|
+
if (typeof fn === "function") return fn.call(this);
|
|
97
|
+
const reader = this.getReader();
|
|
98
|
+
return {
|
|
99
|
+
next: async () => {
|
|
100
|
+
const r = await reader.read();
|
|
101
|
+
if (r.done) {
|
|
102
|
+
reader.releaseLock();
|
|
103
|
+
return { done: true, value: undefined };
|
|
104
|
+
}
|
|
105
|
+
return { done: false, value: r.value };
|
|
106
|
+
},
|
|
107
|
+
throw: async (e) => {
|
|
108
|
+
await reader.cancel(e);
|
|
109
|
+
reader.releaseLock();
|
|
110
|
+
return { done: true, value: undefined };
|
|
111
|
+
},
|
|
112
|
+
return: async () => {
|
|
113
|
+
await reader.cancel("done");
|
|
114
|
+
reader.releaseLock();
|
|
115
|
+
return { done: true, value: undefined };
|
|
116
|
+
},
|
|
117
|
+
[Symbol.asyncIterator]() {
|
|
118
|
+
return this;
|
|
119
|
+
},
|
|
120
|
+
} as ReturnType<ReadableStream<T>[typeof Symbol.asyncIterator]>;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const CR = 13;
|
|
125
|
+
const LF = 10;
|
|
126
|
+
const BOUNDARIES = [
|
|
127
|
+
[CR, LF, CR, LF], // \r\n\r\n
|
|
128
|
+
[CR, LF, CR], // \r\n\r
|
|
129
|
+
[CR, LF, LF], // \r\n\n
|
|
130
|
+
[CR, CR, LF], // \r\r\n
|
|
131
|
+
[LF, CR, LF], // \n\r\n
|
|
132
|
+
[CR, CR], // \r\r
|
|
133
|
+
[LF, CR], // \n\r
|
|
134
|
+
[LF, LF], // \n\n
|
|
135
|
+
];
|
|
136
|
+
const MAX_BOUNDARY_LEN = BOUNDARIES.reduce((m, b) => Math.max(m, b.length), 0);
|
|
137
|
+
|
|
138
|
+
function findBoundary(
|
|
139
|
+
buf: Uint8Array,
|
|
140
|
+
len: number,
|
|
141
|
+
from: number,
|
|
142
|
+
): { index: number; length: number } | null {
|
|
143
|
+
for (let i = from; i < len; i++) {
|
|
144
|
+
if (buf[i] !== CR && buf[i] !== LF) continue;
|
|
145
|
+
for (const boundary of BOUNDARIES) {
|
|
146
|
+
if (i + boundary.length > len) continue;
|
|
147
|
+
let match = true;
|
|
148
|
+
for (let j = 0; j < boundary.length; j++) {
|
|
149
|
+
if (buf[i + j] !== boundary[j]) {
|
|
150
|
+
match = false;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (match) return { index: i, length: boundary.length };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
function parseMessage<T extends SseMessage<unknown>>(
|
|
160
|
+
chunk: Uint8Array,
|
|
161
|
+
parse: (x: SseMessage<string>) => IteratorResult<T, undefined>,
|
|
162
|
+
state: { eventId: string | undefined },
|
|
163
|
+
dataRequired: boolean,
|
|
164
|
+
) {
|
|
165
|
+
const text = new TextDecoder().decode(chunk);
|
|
166
|
+
const lines = text.split(/\r\n|\r|\n/);
|
|
167
|
+
const dataLines: string[] = [];
|
|
168
|
+
const ret: SseMessage<string> = {};
|
|
169
|
+
let ignore = true;
|
|
170
|
+
for (const line of lines) {
|
|
171
|
+
if (!line || line.startsWith(":")) continue;
|
|
172
|
+
ignore = false;
|
|
173
|
+
const i = line.indexOf(":");
|
|
174
|
+
let field = line;
|
|
175
|
+
let value = "";
|
|
176
|
+
if (i > 0) {
|
|
177
|
+
field = line.slice(0, i);
|
|
178
|
+
value = line[i + 1] === " " ? line.slice(i + 2) : line.slice(i + 1);
|
|
179
|
+
}
|
|
180
|
+
if (field === "data") dataLines.push(value);
|
|
181
|
+
else if (field === "event") ret.event = value;
|
|
182
|
+
else if (field === "id" && !value.includes("\0")) state.eventId = value;
|
|
183
|
+
else if (field === "retry" && /^\d+$/.test(value)) {
|
|
184
|
+
ret.retry = Number(value);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (ignore) return;
|
|
188
|
+
ret.id = state.eventId;
|
|
189
|
+
if (dataLines.length) ret.data = dataLines.join("\n");
|
|
190
|
+
else if (dataRequired) return; // skip data-less events when data is required
|
|
191
|
+
return parse(ret);
|
|
192
|
+
}
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
} from "./toolinfo.js";
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* A typed fragment within a chat message that carries text or structured content such as citations, actions, and tool output.
|
|
55
55
|
*/
|
|
56
56
|
export type ChatMessageFragment = {
|
|
57
57
|
/**
|
|
@@ -367,14 +367,28 @@ export * from "./platformchatcitationannotation.js";
|
|
|
367
367
|
export * from "./platformchatcitationsnippet.js";
|
|
368
368
|
export * from "./platformchatcitationsource.js";
|
|
369
369
|
export * from "./platformchatcompletedresponse.js";
|
|
370
|
-
export * from "./platformchatcreaterequest.js";
|
|
371
370
|
export * from "./platformchatcustomentitysource.js";
|
|
372
371
|
export * from "./platformchatdocumentsource.js";
|
|
372
|
+
export * from "./platformchatfailedresponse.js";
|
|
373
373
|
export * from "./platformchatfilesource.js";
|
|
374
374
|
export * from "./platformchatinputmessage.js";
|
|
375
375
|
export * from "./platformchatoutputmessage.js";
|
|
376
376
|
export * from "./platformchatoutputtextcontent.js";
|
|
377
377
|
export * from "./platformchatpersonsource.js";
|
|
378
|
+
export * from "./platformchatresponseerror.js";
|
|
379
|
+
export * from "./platformchatstreameventserversentevent.js";
|
|
380
|
+
export * from "./platformchatstreamoutputtextdelta.js";
|
|
381
|
+
export * from "./platformchatstreamoutputtextdeltaserversentevent.js";
|
|
382
|
+
export * from "./platformchatstreamoutputtextdone.js";
|
|
383
|
+
export * from "./platformchatstreamoutputtextdoneserversentevent.js";
|
|
384
|
+
export * from "./platformchatstreamprogress.js";
|
|
385
|
+
export * from "./platformchatstreamprogressserversentevent.js";
|
|
386
|
+
export * from "./platformchatstreamresponsecompleted.js";
|
|
387
|
+
export * from "./platformchatstreamresponsecompletedserversentevent.js";
|
|
388
|
+
export * from "./platformchatstreamresponsecreated.js";
|
|
389
|
+
export * from "./platformchatstreamresponsecreatedserversentevent.js";
|
|
390
|
+
export * from "./platformchatstreamresponsefailed.js";
|
|
391
|
+
export * from "./platformchatstreamresponsefailedserversentevent.js";
|
|
378
392
|
export * from "./platformcontentschedulewebhookevent.js";
|
|
379
393
|
export * from "./platformcontenttype.js";
|
|
380
394
|
export * from "./platformdatasourcefilterinfo.js";
|
|
@@ -13,10 +13,12 @@ import {
|
|
|
13
13
|
PlatformChatOutputMessage$inboundSchema,
|
|
14
14
|
} from "./platformchatoutputmessage.js";
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const PlatformChatCompletedResponseObject = {
|
|
17
17
|
Response: "RESPONSE",
|
|
18
18
|
} as const;
|
|
19
|
-
export type
|
|
19
|
+
export type PlatformChatCompletedResponseObject = ClosedEnum<
|
|
20
|
+
typeof PlatformChatCompletedResponseObject
|
|
21
|
+
>;
|
|
20
22
|
|
|
21
23
|
export const PlatformChatCompletedResponseStatus = {
|
|
22
24
|
Completed: "COMPLETED",
|
|
@@ -32,7 +34,7 @@ export type PlatformChatCompletedResponse = {
|
|
|
32
34
|
* @remarks
|
|
33
35
|
*/
|
|
34
36
|
id: string;
|
|
35
|
-
object:
|
|
37
|
+
object: PlatformChatCompletedResponseObject;
|
|
36
38
|
/**
|
|
37
39
|
* RFC 3339 UTC timestamp when the response was created.
|
|
38
40
|
*/
|
|
@@ -48,8 +50,9 @@ export type PlatformChatCompletedResponse = {
|
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
/** @internal */
|
|
51
|
-
export const
|
|
52
|
-
|
|
53
|
+
export const PlatformChatCompletedResponseObject$inboundSchema: z.ZodNativeEnum<
|
|
54
|
+
typeof PlatformChatCompletedResponseObject
|
|
55
|
+
> = z.nativeEnum(PlatformChatCompletedResponseObject);
|
|
53
56
|
|
|
54
57
|
/** @internal */
|
|
55
58
|
export const PlatformChatCompletedResponseStatus$inboundSchema: z.ZodNativeEnum<
|
|
@@ -63,7 +66,7 @@ export const PlatformChatCompletedResponse$inboundSchema: z.ZodType<
|
|
|
63
66
|
unknown
|
|
64
67
|
> = z.object({
|
|
65
68
|
id: z.string(),
|
|
66
|
-
object:
|
|
69
|
+
object: PlatformChatCompletedResponseObject$inboundSchema,
|
|
67
70
|
created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
68
71
|
status: PlatformChatCompletedResponseStatus$inboundSchema,
|
|
69
72
|
output: z.array(PlatformChatOutputMessage$inboundSchema),
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: e6542153b492
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as z from "zod/v3";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
9
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
import {
|
|
12
|
+
PlatformChatOutputMessage,
|
|
13
|
+
PlatformChatOutputMessage$inboundSchema,
|
|
14
|
+
} from "./platformchatoutputmessage.js";
|
|
15
|
+
import {
|
|
16
|
+
PlatformChatResponseError,
|
|
17
|
+
PlatformChatResponseError$inboundSchema,
|
|
18
|
+
} from "./platformchatresponseerror.js";
|
|
19
|
+
|
|
20
|
+
export const PlatformChatFailedResponseObject = {
|
|
21
|
+
Response: "RESPONSE",
|
|
22
|
+
} as const;
|
|
23
|
+
export type PlatformChatFailedResponseObject = ClosedEnum<
|
|
24
|
+
typeof PlatformChatFailedResponseObject
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export const PlatformChatFailedResponseStatus = {
|
|
28
|
+
Failed: "FAILED",
|
|
29
|
+
} as const;
|
|
30
|
+
export type PlatformChatFailedResponseStatus = ClosedEnum<
|
|
31
|
+
typeof PlatformChatFailedResponseStatus
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export type PlatformChatFailedResponse = {
|
|
35
|
+
/**
|
|
36
|
+
* Platform-owned, non-persisted response envelope identifier in `resp_<uuid>` form. The same identifier is used for every event in one streamed response.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
*/
|
|
40
|
+
id: string;
|
|
41
|
+
object: PlatformChatFailedResponseObject;
|
|
42
|
+
/**
|
|
43
|
+
* RFC 3339 UTC timestamp when the response was created.
|
|
44
|
+
*/
|
|
45
|
+
created_at: Date;
|
|
46
|
+
status: PlatformChatFailedResponseStatus;
|
|
47
|
+
output: Array<PlatformChatOutputMessage>;
|
|
48
|
+
store: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Present when the interaction was persisted.
|
|
51
|
+
*/
|
|
52
|
+
conversation_id?: string | null | undefined;
|
|
53
|
+
request_id: string;
|
|
54
|
+
error: PlatformChatResponseError;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** @internal */
|
|
58
|
+
export const PlatformChatFailedResponseObject$inboundSchema: z.ZodNativeEnum<
|
|
59
|
+
typeof PlatformChatFailedResponseObject
|
|
60
|
+
> = z.nativeEnum(PlatformChatFailedResponseObject);
|
|
61
|
+
|
|
62
|
+
/** @internal */
|
|
63
|
+
export const PlatformChatFailedResponseStatus$inboundSchema: z.ZodNativeEnum<
|
|
64
|
+
typeof PlatformChatFailedResponseStatus
|
|
65
|
+
> = z.nativeEnum(PlatformChatFailedResponseStatus);
|
|
66
|
+
|
|
67
|
+
/** @internal */
|
|
68
|
+
export const PlatformChatFailedResponse$inboundSchema: z.ZodType<
|
|
69
|
+
PlatformChatFailedResponse,
|
|
70
|
+
z.ZodTypeDef,
|
|
71
|
+
unknown
|
|
72
|
+
> = z.object({
|
|
73
|
+
id: z.string(),
|
|
74
|
+
object: PlatformChatFailedResponseObject$inboundSchema,
|
|
75
|
+
created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
76
|
+
status: PlatformChatFailedResponseStatus$inboundSchema,
|
|
77
|
+
output: z.array(PlatformChatOutputMessage$inboundSchema),
|
|
78
|
+
store: z.boolean(),
|
|
79
|
+
conversation_id: z.nullable(z.string()).optional(),
|
|
80
|
+
request_id: z.string(),
|
|
81
|
+
error: PlatformChatResponseError$inboundSchema,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export function platformChatFailedResponseFromJSON(
|
|
85
|
+
jsonString: string,
|
|
86
|
+
): SafeParseResult<PlatformChatFailedResponse, SDKValidationError> {
|
|
87
|
+
return safeParse(
|
|
88
|
+
jsonString,
|
|
89
|
+
(x) => PlatformChatFailedResponse$inboundSchema.parse(JSON.parse(x)),
|
|
90
|
+
`Failed to parse 'PlatformChatFailedResponse' from JSON`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 40a78a177ff2
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as z from "zod/v3";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export type PlatformChatResponseError = {
|
|
12
|
+
/**
|
|
13
|
+
* Open snake_case error code aligned with ProblemDetail codes when present. Clients must tolerate unknown values; the set of codes is not a closed enum. Limit failures use `spend_limit_exceeded` (billing spend limit) and `token_limit_exceeded` (model context/token limit).
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
*/
|
|
17
|
+
code?: string | null | undefined;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const PlatformChatResponseError$inboundSchema: z.ZodType<
|
|
23
|
+
PlatformChatResponseError,
|
|
24
|
+
z.ZodTypeDef,
|
|
25
|
+
unknown
|
|
26
|
+
> = z.object({
|
|
27
|
+
code: z.nullable(z.string()).optional(),
|
|
28
|
+
message: z.string(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export function platformChatResponseErrorFromJSON(
|
|
32
|
+
jsonString: string,
|
|
33
|
+
): SafeParseResult<PlatformChatResponseError, SDKValidationError> {
|
|
34
|
+
return safeParse(
|
|
35
|
+
jsonString,
|
|
36
|
+
(x) => PlatformChatResponseError$inboundSchema.parse(JSON.parse(x)),
|
|
37
|
+
`Failed to parse 'PlatformChatResponseError' from JSON`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 1a2743e83004
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as z from "zod/v3";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
PlatformChatStreamOutputTextDeltaServerSentEvent,
|
|
12
|
+
PlatformChatStreamOutputTextDeltaServerSentEvent$inboundSchema,
|
|
13
|
+
} from "./platformchatstreamoutputtextdeltaserversentevent.js";
|
|
14
|
+
import {
|
|
15
|
+
PlatformChatStreamOutputTextDoneServerSentEvent,
|
|
16
|
+
PlatformChatStreamOutputTextDoneServerSentEvent$inboundSchema,
|
|
17
|
+
} from "./platformchatstreamoutputtextdoneserversentevent.js";
|
|
18
|
+
import {
|
|
19
|
+
PlatformChatStreamProgressServerSentEvent,
|
|
20
|
+
PlatformChatStreamProgressServerSentEvent$inboundSchema,
|
|
21
|
+
} from "./platformchatstreamprogressserversentevent.js";
|
|
22
|
+
import {
|
|
23
|
+
PlatformChatStreamResponseCompletedServerSentEvent,
|
|
24
|
+
PlatformChatStreamResponseCompletedServerSentEvent$inboundSchema,
|
|
25
|
+
} from "./platformchatstreamresponsecompletedserversentevent.js";
|
|
26
|
+
import {
|
|
27
|
+
PlatformChatStreamResponseCreatedServerSentEvent,
|
|
28
|
+
PlatformChatStreamResponseCreatedServerSentEvent$inboundSchema,
|
|
29
|
+
} from "./platformchatstreamresponsecreatedserversentevent.js";
|
|
30
|
+
import {
|
|
31
|
+
PlatformChatStreamResponseFailedServerSentEvent,
|
|
32
|
+
PlatformChatStreamResponseFailedServerSentEvent$inboundSchema,
|
|
33
|
+
} from "./platformchatstreamresponsefailedserversentevent.js";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A typed server-sent event.
|
|
37
|
+
*/
|
|
38
|
+
export type PlatformChatStreamEventServerSentEvent =
|
|
39
|
+
| PlatformChatStreamResponseCreatedServerSentEvent
|
|
40
|
+
| PlatformChatStreamProgressServerSentEvent
|
|
41
|
+
| PlatformChatStreamOutputTextDeltaServerSentEvent
|
|
42
|
+
| PlatformChatStreamOutputTextDoneServerSentEvent
|
|
43
|
+
| PlatformChatStreamResponseCompletedServerSentEvent
|
|
44
|
+
| PlatformChatStreamResponseFailedServerSentEvent;
|
|
45
|
+
|
|
46
|
+
/** @internal */
|
|
47
|
+
export const PlatformChatStreamEventServerSentEvent$inboundSchema: z.ZodType<
|
|
48
|
+
PlatformChatStreamEventServerSentEvent,
|
|
49
|
+
z.ZodTypeDef,
|
|
50
|
+
unknown
|
|
51
|
+
> = z.union([
|
|
52
|
+
PlatformChatStreamResponseCreatedServerSentEvent$inboundSchema,
|
|
53
|
+
PlatformChatStreamProgressServerSentEvent$inboundSchema,
|
|
54
|
+
PlatformChatStreamOutputTextDeltaServerSentEvent$inboundSchema,
|
|
55
|
+
PlatformChatStreamOutputTextDoneServerSentEvent$inboundSchema,
|
|
56
|
+
PlatformChatStreamResponseCompletedServerSentEvent$inboundSchema,
|
|
57
|
+
PlatformChatStreamResponseFailedServerSentEvent$inboundSchema,
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
export function platformChatStreamEventServerSentEventFromJSON(
|
|
61
|
+
jsonString: string,
|
|
62
|
+
): SafeParseResult<PlatformChatStreamEventServerSentEvent, SDKValidationError> {
|
|
63
|
+
return safeParse(
|
|
64
|
+
jsonString,
|
|
65
|
+
(x) =>
|
|
66
|
+
PlatformChatStreamEventServerSentEvent$inboundSchema.parse(JSON.parse(x)),
|
|
67
|
+
`Failed to parse 'PlatformChatStreamEventServerSentEvent' from JSON`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: fc0843cf9086
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as z from "zod/v3";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
9
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export const PlatformChatStreamOutputTextDeltaType = {
|
|
13
|
+
ResponseOutputTextDelta: "RESPONSE_OUTPUT_TEXT_DELTA",
|
|
14
|
+
} as const;
|
|
15
|
+
export type PlatformChatStreamOutputTextDeltaType = ClosedEnum<
|
|
16
|
+
typeof PlatformChatStreamOutputTextDeltaType
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export type PlatformChatStreamOutputTextDelta = {
|
|
20
|
+
type: PlatformChatStreamOutputTextDeltaType;
|
|
21
|
+
/**
|
|
22
|
+
* Platform-owned, non-persisted response envelope identifier in `resp_<uuid>` form. The same identifier is used for every event in one streamed response.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
*/
|
|
26
|
+
response_id: string;
|
|
27
|
+
delta: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** @internal */
|
|
31
|
+
export const PlatformChatStreamOutputTextDeltaType$inboundSchema:
|
|
32
|
+
z.ZodNativeEnum<typeof PlatformChatStreamOutputTextDeltaType> = z.nativeEnum(
|
|
33
|
+
PlatformChatStreamOutputTextDeltaType,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/** @internal */
|
|
37
|
+
export const PlatformChatStreamOutputTextDelta$inboundSchema: z.ZodType<
|
|
38
|
+
PlatformChatStreamOutputTextDelta,
|
|
39
|
+
z.ZodTypeDef,
|
|
40
|
+
unknown
|
|
41
|
+
> = z.object({
|
|
42
|
+
type: PlatformChatStreamOutputTextDeltaType$inboundSchema,
|
|
43
|
+
response_id: z.string(),
|
|
44
|
+
delta: z.string(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export function platformChatStreamOutputTextDeltaFromJSON(
|
|
48
|
+
jsonString: string,
|
|
49
|
+
): SafeParseResult<PlatformChatStreamOutputTextDelta, SDKValidationError> {
|
|
50
|
+
return safeParse(
|
|
51
|
+
jsonString,
|
|
52
|
+
(x) => PlatformChatStreamOutputTextDelta$inboundSchema.parse(JSON.parse(x)),
|
|
53
|
+
`Failed to parse 'PlatformChatStreamOutputTextDelta' from JSON`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: bcd6daa85743
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as z from "zod/v3";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
PlatformChatStreamOutputTextDelta,
|
|
12
|
+
PlatformChatStreamOutputTextDelta$inboundSchema,
|
|
13
|
+
} from "./platformchatstreamoutputtextdelta.js";
|
|
14
|
+
|
|
15
|
+
export type PlatformChatStreamOutputTextDeltaServerSentEvent = {
|
|
16
|
+
id?: string | undefined;
|
|
17
|
+
event: "RESPONSE_OUTPUT_TEXT_DELTA";
|
|
18
|
+
data: PlatformChatStreamOutputTextDelta;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const PlatformChatStreamOutputTextDeltaServerSentEvent$inboundSchema:
|
|
23
|
+
z.ZodType<
|
|
24
|
+
PlatformChatStreamOutputTextDeltaServerSentEvent,
|
|
25
|
+
z.ZodTypeDef,
|
|
26
|
+
unknown
|
|
27
|
+
> = z.object({
|
|
28
|
+
id: z.string().optional(),
|
|
29
|
+
event: z.literal("RESPONSE_OUTPUT_TEXT_DELTA"),
|
|
30
|
+
data: z.unknown().transform((v, ctx) => {
|
|
31
|
+
if (typeof v !== "string") return v;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(v);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
|
|
36
|
+
return z.NEVER;
|
|
37
|
+
}
|
|
38
|
+
}).pipe(PlatformChatStreamOutputTextDelta$inboundSchema),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export function platformChatStreamOutputTextDeltaServerSentEventFromJSON(
|
|
42
|
+
jsonString: string,
|
|
43
|
+
): SafeParseResult<
|
|
44
|
+
PlatformChatStreamOutputTextDeltaServerSentEvent,
|
|
45
|
+
SDKValidationError
|
|
46
|
+
> {
|
|
47
|
+
return safeParse(
|
|
48
|
+
jsonString,
|
|
49
|
+
(x) =>
|
|
50
|
+
PlatformChatStreamOutputTextDeltaServerSentEvent$inboundSchema.parse(
|
|
51
|
+
JSON.parse(x),
|
|
52
|
+
),
|
|
53
|
+
`Failed to parse 'PlatformChatStreamOutputTextDeltaServerSentEvent' from JSON`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 3a3b1f5d0f7c
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as z from "zod/v3";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
9
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export const PlatformChatStreamOutputTextDoneType = {
|
|
13
|
+
ResponseOutputTextDone: "RESPONSE_OUTPUT_TEXT_DONE",
|
|
14
|
+
} as const;
|
|
15
|
+
export type PlatformChatStreamOutputTextDoneType = ClosedEnum<
|
|
16
|
+
typeof PlatformChatStreamOutputTextDoneType
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export type PlatformChatStreamOutputTextDone = {
|
|
20
|
+
type: PlatformChatStreamOutputTextDoneType;
|
|
21
|
+
/**
|
|
22
|
+
* Platform-owned, non-persisted response envelope identifier in `resp_<uuid>` form. The same identifier is used for every event in one streamed response.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
*/
|
|
26
|
+
response_id: string;
|
|
27
|
+
text: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** @internal */
|
|
31
|
+
export const PlatformChatStreamOutputTextDoneType$inboundSchema:
|
|
32
|
+
z.ZodNativeEnum<typeof PlatformChatStreamOutputTextDoneType> = z.nativeEnum(
|
|
33
|
+
PlatformChatStreamOutputTextDoneType,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/** @internal */
|
|
37
|
+
export const PlatformChatStreamOutputTextDone$inboundSchema: z.ZodType<
|
|
38
|
+
PlatformChatStreamOutputTextDone,
|
|
39
|
+
z.ZodTypeDef,
|
|
40
|
+
unknown
|
|
41
|
+
> = z.object({
|
|
42
|
+
type: PlatformChatStreamOutputTextDoneType$inboundSchema,
|
|
43
|
+
response_id: z.string(),
|
|
44
|
+
text: z.string(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export function platformChatStreamOutputTextDoneFromJSON(
|
|
48
|
+
jsonString: string,
|
|
49
|
+
): SafeParseResult<PlatformChatStreamOutputTextDone, SDKValidationError> {
|
|
50
|
+
return safeParse(
|
|
51
|
+
jsonString,
|
|
52
|
+
(x) => PlatformChatStreamOutputTextDone$inboundSchema.parse(JSON.parse(x)),
|
|
53
|
+
`Failed to parse 'PlatformChatStreamOutputTextDone' from JSON`,
|
|
54
|
+
);
|
|
55
|
+
}
|