File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -571,13 +571,17 @@ export const SessionRoutes = lazy(() =>
571571 "query" ,
572572 z . object ( {
573573 limit : z . coerce . number ( ) . optional ( ) ,
574+ ts_before : z . coerce . number ( ) . optional ( ) ,
575+ breakpoint : z . coerce . boolean ( ) . optional ( ) ,
574576 } ) ,
575577 ) ,
576578 async ( c ) => {
577579 const query = c . req . valid ( "query" )
578580 const messages = await Session . messages ( {
579581 sessionID : c . req . valid ( "param" ) . sessionID ,
580582 limit : query . limit ,
583+ ts_before : query . ts_before ,
584+ breakpoint : query . breakpoint ,
581585 } )
582586 return c . json ( messages )
583587 } ,
Original file line number Diff line number Diff line change @@ -317,12 +317,16 @@ export namespace Session {
317317 z . object ( {
318318 sessionID : Identifier . schema ( "session" ) ,
319319 limit : z . number ( ) . optional ( ) ,
320+ ts_before : z . number ( ) . optional ( ) ,
321+ breakpoint : z . boolean ( ) . optional ( ) ,
320322 } ) ,
321323 async ( input ) => {
322324 const result = [ ] as MessageV2 . WithParts [ ]
323325 for await ( const msg of MessageV2 . stream ( input . sessionID ) ) {
326+ if ( input . ts_before && msg . info . time . created >= input . ts_before ) continue
324327 if ( input . limit && result . length >= input . limit ) break
325328 result . push ( msg )
329+ if ( input . ts_before && input . breakpoint && msg . parts . some ( ( p ) => p . type === "compaction" ) ) break
326330 }
327331 result . reverse ( )
328332 return result
Original file line number Diff line number Diff line change @@ -162,16 +162,10 @@ export const createClient = (config: Config = {}): Client => {
162162 case "arrayBuffer" :
163163 case "blob" :
164164 case "formData" :
165+ case "json" :
165166 case "text" :
166167 data = await response [ parseAs ] ( )
167168 break
168- case "json" : {
169- // Some servers return 200 with no Content-Length and empty body.
170- // response.json() would throw; read as text and parse if non-empty.
171- const text = await response . text ( )
172- data = text ? JSON . parse ( text ) : { }
173- break
174- }
175169 case "stream" :
176170 return opts . responseStyle === "data"
177171 ? response . body
@@ -250,7 +244,6 @@ export const createClient = (config: Config = {}): Client => {
250244 }
251245 return request
252246 } ,
253- serializedBody : getValidRequestBody ( opts ) as BodyInit | null | undefined ,
254247 url,
255248 } )
256249 }
Original file line number Diff line number Diff line change @@ -151,8 +151,6 @@ export const createSseClient = <TData = unknown>({
151151 const { done, value } = await reader . read ( )
152152 if ( done ) break
153153 buffer += value
154- // Normalize line endings: CRLF -> LF, then CR -> LF
155- buffer = buffer . replace ( / \r \n / g, "\n" ) . replace ( / \r / g, "\n" )
156154
157155 const chunks = buffer . split ( "\n\n" )
158156 buffer = chunks . pop ( ) ?? ""
You can’t perform that action at this time.
0 commit comments