@perstack/api-client 0.0.47 → 0.0.48

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 CHANGED
@@ -72,6 +72,14 @@ interface RequestOptions {
72
72
  }
73
73
  ```
74
74
 
75
+ For streaming endpoints, an extended `StreamRequestOptions` is available:
76
+
77
+ ```typescript
78
+ interface StreamRequestOptions extends RequestOptions {
79
+ streamIdleTimeout?: number // Idle timeout in ms between chunks (default: client timeout)
80
+ }
81
+ ```
82
+
75
83
  ---
76
84
 
77
85
  ### Applications API
@@ -355,51 +363,6 @@ for await (const checkpoint of client.jobs.checkpoints.stream("job-id")) {
355
363
  }
356
364
  ```
357
365
 
358
- #### Workspace
359
-
360
- Access the job's workspace files.
361
-
362
- ##### `client.jobs.workspace.get(jobId, options?)`
363
-
364
- Get workspace metadata.
365
-
366
- ```typescript
367
- const result = await client.jobs.workspace.get("job-id")
368
- if (result.ok) {
369
- console.log("Branch:", result.data.data.workspace.branch)
370
- console.log("Stats:", result.data.data.workspace.stats)
371
- }
372
- ```
373
-
374
- ##### `client.jobs.workspace.tree(jobId, params?, options?)`
375
-
376
- List files in the workspace.
377
-
378
- ```typescript
379
- const result = await client.jobs.workspace.tree("job-id", {
380
- path: "src/", // Optional: subdirectory path
381
- recursive: true, // Optional: include subdirectories
382
- })
383
-
384
- if (result.ok) {
385
- for (const item of result.data.data.items) {
386
- console.log(`${item.type}: ${item.path}`)
387
- }
388
- }
389
- ```
390
-
391
- ##### `client.jobs.workspace.blob(jobId, path, options?)`
392
-
393
- Download a file from the workspace.
394
-
395
- ```typescript
396
- const result = await client.jobs.workspace.blob("job-id", "src/main.ts")
397
- if (result.ok) {
398
- const content = await result.data.text()
399
- console.log(content)
400
- }
401
- ```
402
-
403
366
  ---
404
367
 
405
368
  ### Experts API
@@ -650,16 +613,39 @@ if (!jobResult.ok) {
650
613
  const jobId = jobResult.data.data.job.id
651
614
 
652
615
  // Stream checkpoints
653
- try {
654
- for await (const checkpoint of client.jobs.checkpoints.stream(jobId)) {
655
- console.log("Checkpoint:", checkpoint.id)
656
- console.log("Activity:", checkpoint.activity)
616
+ for await (const result of client.jobs.checkpoints.stream(jobId)) {
617
+ if (!result.ok) {
618
+ if (result.error.aborted) {
619
+ console.error("Stream timed out or was cancelled")
620
+ } else {
621
+ console.error("Stream error:", result.error.message)
622
+ }
623
+ break
657
624
  }
658
- } catch (error) {
659
- console.error("Stream error:", error)
625
+ console.log("Checkpoint:", result.data.id)
660
626
  }
661
627
  ```
662
628
 
629
+ ### Stream Timeout Configuration
630
+
631
+ The streaming endpoints support an idle timeout that aborts the stream if no data is received within the specified period:
632
+
633
+ ```typescript
634
+ for await (const result of client.jobs.checkpoints.stream(jobId, {
635
+ streamIdleTimeout: 60000, // 60 second idle timeout
636
+ })) {
637
+ if (!result.ok) {
638
+ if (result.error.aborted) {
639
+ console.error("Stream timed out or was cancelled")
640
+ }
641
+ break
642
+ }
643
+ console.log("Checkpoint:", result.data.id)
644
+ }
645
+ ```
646
+
647
+ By default, the stream idle timeout uses the client's configured timeout value (30 seconds if not specified).
648
+
663
649
  ### Advanced SSE Parsing
664
650
 
665
651
  For custom SSE parsing, the package exports utility functions:
@@ -706,6 +692,7 @@ import type {
706
692
  ApiResult,
707
693
  ApiError,
708
694
  RequestOptions,
695
+ StreamRequestOptions,
709
696
 
710
697
  // Application types
711
698
  Application,