truefoundry-gateway-sdk 0.1.0 → 0.2.0-rc.1

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.
Files changed (165) hide show
  1. package/README.md +393 -3
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/CustomClient.d.ts +4 -0
  4. package/dist/cjs/CustomClient.js +4 -0
  5. package/dist/cjs/agents/AgentSession.d.ts +37 -0
  6. package/dist/cjs/agents/AgentSession.js +31 -0
  7. package/dist/cjs/agents/AgentSessionClient.d.ts +30 -0
  8. package/dist/cjs/agents/AgentSessionClient.js +30 -0
  9. package/dist/cjs/agents/PreparedTurn.d.ts +63 -0
  10. package/dist/cjs/agents/PreparedTurn.js +53 -0
  11. package/dist/cjs/agents/Turn.d.ts +45 -0
  12. package/dist/cjs/agents/Turn.js +38 -0
  13. package/dist/cjs/agents/TurnStreamData.d.ts +8 -0
  14. package/dist/cjs/agents/TurnStreamData.js +6 -0
  15. package/dist/cjs/agents/eventDelta.d.ts +13 -0
  16. package/dist/cjs/agents/eventDelta.js +13 -0
  17. package/dist/cjs/api/errors/BadGatewayError.d.ts +6 -0
  18. package/dist/cjs/api/errors/BadGatewayError.js +54 -0
  19. package/dist/cjs/api/errors/ContentTooLargeError.d.ts +6 -0
  20. package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
  21. package/dist/cjs/api/errors/GoneError.d.ts +6 -0
  22. package/dist/cjs/api/errors/GoneError.js +54 -0
  23. package/dist/cjs/api/errors/index.d.ts +3 -0
  24. package/dist/cjs/api/errors/index.js +3 -0
  25. package/dist/cjs/api/resources/private/resources/agents/client/Client.d.ts +21 -4
  26. package/dist/cjs/api/resources/private/resources/agents/client/Client.js +164 -5
  27. package/dist/cjs/api/resources/private/resources/agents/client/index.d.ts +1 -1
  28. package/dist/cjs/api/resources/private/resources/agents/client/index.js +15 -0
  29. package/dist/cjs/api/resources/private/resources/agents/client/requests/AgentsDownloadSandboxFileRequest.d.ts +10 -0
  30. package/dist/cjs/api/resources/private/resources/agents/client/requests/index.d.ts +1 -0
  31. package/dist/cjs/api/resources/private/resources/agents/resources/index.d.ts +1 -2
  32. package/dist/cjs/api/resources/private/resources/agents/resources/index.js +5 -6
  33. package/dist/cjs/api/resources/private/resources/agents/resources/private/client/Client.d.ts +12 -0
  34. package/dist/cjs/api/resources/private/resources/agents/resources/private/client/Client.js +16 -0
  35. package/dist/cjs/api/resources/private/resources/agents/resources/private/client/index.js +2 -0
  36. package/dist/cjs/api/resources/private/resources/agents/resources/private/exports.d.ts +3 -0
  37. package/dist/cjs/api/resources/private/resources/agents/resources/private/exports.js +22 -0
  38. package/dist/cjs/api/resources/private/resources/agents/resources/private/index.d.ts +2 -0
  39. package/dist/cjs/api/resources/private/resources/agents/resources/private/index.js +18 -0
  40. package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/Client.d.ts +14 -14
  41. package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/Client.js +16 -16
  42. package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/CreateDraftSessionRequest.d.ts +1 -1
  43. package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/DraftSessionsListRequest.d.ts +1 -1
  44. package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/UpdateDraftSessionRequest.d.ts +1 -1
  45. package/dist/cjs/api/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/UpdateDraftSessionRequest.js +3 -0
  46. package/dist/cjs/api/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/index.js +2 -0
  47. package/dist/cjs/api/resources/private/resources/agents/resources/private/resources/index.d.ts +2 -0
  48. package/dist/cjs/api/resources/private/resources/agents/resources/private/resources/index.js +41 -0
  49. package/dist/cjs/api/resources/private/resources/index.d.ts +1 -0
  50. package/dist/cjs/api/resources/private/resources/index.js +4 -0
  51. package/dist/cjs/serialization/resources/private/resources/agents/resources/index.d.ts +1 -2
  52. package/dist/cjs/serialization/resources/private/resources/agents/resources/index.js +5 -6
  53. package/dist/cjs/serialization/resources/private/resources/agents/resources/private/index.d.ts +1 -0
  54. package/dist/cjs/serialization/resources/private/resources/agents/resources/private/index.js +17 -0
  55. package/dist/cjs/serialization/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/CreateDraftSessionRequest.d.ts +11 -0
  56. package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/CreateDraftSessionRequest.js +2 -2
  57. package/dist/cjs/serialization/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/UpdateDraftSessionRequest.d.ts +10 -0
  58. package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/UpdateDraftSessionRequest.js +2 -2
  59. package/dist/cjs/serialization/resources/private/resources/agents/resources/private/resources/index.d.ts +2 -0
  60. package/dist/cjs/serialization/resources/private/resources/agents/resources/private/resources/index.js +41 -0
  61. package/dist/cjs/version.d.ts +1 -1
  62. package/dist/cjs/version.js +1 -1
  63. package/dist/esm/BaseClient.mjs +2 -2
  64. package/dist/esm/CustomClient.d.mts +4 -0
  65. package/dist/esm/CustomClient.mjs +4 -0
  66. package/dist/esm/agents/AgentSession.d.mts +37 -0
  67. package/dist/esm/agents/AgentSession.mjs +31 -0
  68. package/dist/esm/agents/AgentSessionClient.d.mts +30 -0
  69. package/dist/esm/agents/AgentSessionClient.mjs +30 -0
  70. package/dist/esm/agents/PreparedTurn.d.mts +63 -0
  71. package/dist/esm/agents/PreparedTurn.mjs +53 -0
  72. package/dist/esm/agents/Turn.d.mts +45 -0
  73. package/dist/esm/agents/Turn.mjs +38 -0
  74. package/dist/esm/agents/TurnStreamData.d.mts +8 -0
  75. package/dist/esm/agents/TurnStreamData.mjs +6 -0
  76. package/dist/esm/agents/eventDelta.d.mts +13 -0
  77. package/dist/esm/agents/eventDelta.mjs +13 -0
  78. package/dist/esm/api/errors/BadGatewayError.d.mts +6 -0
  79. package/dist/esm/api/errors/BadGatewayError.mjs +17 -0
  80. package/dist/esm/api/errors/ContentTooLargeError.d.mts +6 -0
  81. package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
  82. package/dist/esm/api/errors/GoneError.d.mts +6 -0
  83. package/dist/esm/api/errors/GoneError.mjs +17 -0
  84. package/dist/esm/api/errors/index.d.mts +3 -0
  85. package/dist/esm/api/errors/index.mjs +3 -0
  86. package/dist/esm/api/resources/private/resources/agents/client/Client.d.mts +21 -4
  87. package/dist/esm/api/resources/private/resources/agents/client/Client.mjs +131 -5
  88. package/dist/esm/api/resources/private/resources/agents/client/index.d.mts +1 -1
  89. package/dist/esm/api/resources/private/resources/agents/client/index.mjs +1 -1
  90. package/dist/esm/api/resources/private/resources/agents/client/requests/AgentsDownloadSandboxFileRequest.d.mts +10 -0
  91. package/dist/esm/api/resources/private/resources/agents/client/requests/index.d.mts +1 -0
  92. package/dist/esm/api/resources/private/resources/agents/client/requests/index.mjs +1 -0
  93. package/dist/esm/api/resources/private/resources/agents/resources/index.d.mts +1 -2
  94. package/dist/esm/api/resources/private/resources/agents/resources/index.mjs +1 -2
  95. package/dist/esm/api/resources/private/resources/agents/resources/private/client/Client.d.mts +12 -0
  96. package/dist/esm/api/resources/private/resources/agents/resources/private/client/Client.mjs +12 -0
  97. package/dist/esm/api/resources/private/resources/agents/resources/private/client/index.d.mts +1 -0
  98. package/dist/esm/api/resources/private/resources/agents/resources/private/client/index.mjs +1 -0
  99. package/dist/esm/api/resources/private/resources/agents/resources/private/exports.d.mts +3 -0
  100. package/dist/esm/api/resources/private/resources/agents/resources/private/exports.mjs +4 -0
  101. package/dist/esm/api/resources/private/resources/agents/resources/private/index.d.mts +2 -0
  102. package/dist/esm/api/resources/private/resources/agents/resources/private/index.mjs +2 -0
  103. package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/Client.d.mts +14 -14
  104. package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/Client.mjs +16 -16
  105. package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/CreateDraftSessionRequest.d.mts +1 -1
  106. package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/DraftSessionsListRequest.d.mts +1 -1
  107. package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/UpdateDraftSessionRequest.d.mts +1 -1
  108. package/dist/esm/api/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/UpdateDraftSessionRequest.mjs +2 -0
  109. package/dist/esm/api/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/index.mjs +1 -0
  110. package/dist/esm/api/resources/private/resources/agents/resources/private/resources/index.d.mts +2 -0
  111. package/dist/esm/api/resources/private/resources/agents/resources/private/resources/index.mjs +2 -0
  112. package/dist/esm/api/resources/private/resources/index.d.mts +1 -0
  113. package/dist/esm/api/resources/private/resources/index.mjs +1 -0
  114. package/dist/esm/serialization/resources/private/resources/agents/resources/index.d.mts +1 -2
  115. package/dist/esm/serialization/resources/private/resources/agents/resources/index.mjs +1 -2
  116. package/dist/esm/serialization/resources/private/resources/agents/resources/private/index.d.mts +1 -0
  117. package/dist/esm/serialization/resources/private/resources/agents/resources/private/index.mjs +1 -0
  118. package/dist/esm/serialization/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/CreateDraftSessionRequest.d.mts +11 -0
  119. package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/CreateDraftSessionRequest.mjs +2 -2
  120. package/dist/esm/serialization/resources/private/resources/agents/resources/private/resources/draftSessions/client/requests/UpdateDraftSessionRequest.d.mts +10 -0
  121. package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/UpdateDraftSessionRequest.mjs +2 -2
  122. package/dist/esm/serialization/resources/private/resources/agents/resources/private/resources/index.d.mts +2 -0
  123. package/dist/esm/serialization/resources/private/resources/agents/resources/private/resources/index.mjs +2 -0
  124. package/dist/esm/version.d.mts +1 -1
  125. package/dist/esm/version.mjs +1 -1
  126. package/package.json +23 -12
  127. package/reference.md +225 -151
  128. package/dist/cjs/serialization/resources/private/resources/agents/resources/draftSessions/client/requests/CreateDraftSessionRequest.d.ts +0 -11
  129. package/dist/cjs/serialization/resources/private/resources/agents/resources/draftSessions/client/requests/UpdateDraftSessionRequest.d.ts +0 -10
  130. package/dist/esm/serialization/resources/private/resources/agents/resources/draftSessions/client/requests/CreateDraftSessionRequest.d.mts +0 -11
  131. package/dist/esm/serialization/resources/private/resources/agents/resources/draftSessions/client/requests/UpdateDraftSessionRequest.d.mts +0 -10
  132. /package/dist/cjs/api/resources/private/resources/agents/{resources/draftSessions/client/requests/CreateDraftSessionRequest.js → client/requests/AgentsDownloadSandboxFileRequest.js} +0 -0
  133. /package/dist/cjs/api/resources/private/resources/agents/{resources/draftSessions/client → client}/requests/index.js +0 -0
  134. /package/dist/{esm/api/resources/private/resources/agents/resources/draftSessions/client/requests/index.mjs → cjs/api/resources/private/resources/agents/resources/private/client/index.d.ts} +0 -0
  135. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.d.ts +0 -0
  136. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.js +0 -0
  137. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions/client/requests/DraftSessionsListRequest.js → private/resources/draftSessions/client/requests/CreateDraftSessionRequest.js} +0 -0
  138. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions/client/requests/UpdateDraftSessionRequest.js → private/resources/draftSessions/client/requests/DraftSessionsListRequest.js} +0 -0
  139. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/index.d.ts +0 -0
  140. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/exports.d.ts +0 -0
  141. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/exports.js +0 -0
  142. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.d.ts +0 -0
  143. /package/dist/cjs/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.js +0 -0
  144. /package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.d.ts +0 -0
  145. /package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.js +0 -0
  146. /package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/index.d.ts +0 -0
  147. /package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/index.js +0 -0
  148. /package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.d.ts +0 -0
  149. /package/dist/cjs/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.js +0 -0
  150. /package/dist/esm/api/resources/private/resources/agents/{resources/draftSessions/client/requests/CreateDraftSessionRequest.mjs → client/requests/AgentsDownloadSandboxFileRequest.mjs} +0 -0
  151. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.d.mts +0 -0
  152. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.mjs +0 -0
  153. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions/client/requests/DraftSessionsListRequest.mjs → private/resources/draftSessions/client/requests/CreateDraftSessionRequest.mjs} +0 -0
  154. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions/client/requests/UpdateDraftSessionRequest.mjs → private/resources/draftSessions/client/requests/DraftSessionsListRequest.mjs} +0 -0
  155. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/index.d.mts +0 -0
  156. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/exports.d.mts +0 -0
  157. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/exports.mjs +0 -0
  158. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.d.mts +0 -0
  159. /package/dist/esm/api/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.mjs +0 -0
  160. /package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.d.mts +0 -0
  161. /package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/index.mjs +0 -0
  162. /package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/index.d.mts +0 -0
  163. /package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/client/requests/index.mjs +0 -0
  164. /package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.d.mts +0 -0
  165. /package/dist/esm/serialization/resources/private/resources/agents/resources/{draftSessions → private/resources/draftSessions}/index.mjs +0 -0
package/README.md CHANGED
@@ -25,6 +25,7 @@ Call the gateway directly — not via the control-plane `/api/llm` proxy. The te
25
25
  - [Request and Response Types](#request-and-response-types)
26
26
  - [Exception Handling](#exception-handling)
27
27
  - [Streaming Response](#streaming-response)
28
+ - [Binary Response](#binary-response)
28
29
  - [Pagination](#pagination)
29
30
  - [Advanced](#advanced)
30
31
  - [Subpackage Exports](#subpackage-exports)
@@ -124,7 +125,7 @@ following namespace:
124
125
  ```typescript
125
126
  import { TrueFoundryGateway } from "truefoundry-gateway-sdk";
126
127
 
127
- const request: TrueFoundryGateway.DraftSessionsListRequest = {
128
+ const request: TrueFoundryGateway.AgentsDownloadSandboxFileRequest = {
128
129
  ...
129
130
  };
130
131
  ```
@@ -164,6 +165,395 @@ for await (const item of response) {
164
165
  }
165
166
  ```
166
167
 
168
+ ## Binary Response
169
+
170
+ You can consume binary data from endpoints using the `BinaryResponse` type which lets you choose how to consume the data:
171
+
172
+ ```typescript
173
+ const response = await client.private.agents.downloadSandboxFile(...);
174
+ const stream: ReadableStream<Uint8Array> = response.stream();
175
+ // const arrayBuffer: ArrayBuffer = await response.arrayBuffer();
176
+ // const blob: Blob = response.blob();
177
+ // const bytes: Uint8Array = response.bytes();
178
+ // You can only use the response body once, so you must choose one of the above methods.
179
+ // If you want to check if the response body has been used, you can use the following property.
180
+ const bodyUsed = response.bodyUsed;
181
+ ```
182
+ <details>
183
+ <summary>Save binary response to a file</summary>
184
+
185
+ <blockquote>
186
+ <details>
187
+ <summary>Node.js</summary>
188
+
189
+ <blockquote>
190
+ <details>
191
+ <summary>ReadableStream (most-efficient)</summary>
192
+
193
+ ```ts
194
+ import { createWriteStream } from 'fs';
195
+ import { Readable } from 'stream';
196
+ import { pipeline } from 'stream/promises';
197
+
198
+ const response = await client.private.agents.downloadSandboxFile(...);
199
+
200
+ const stream = response.stream();
201
+ const nodeStream = Readable.fromWeb(stream);
202
+ const writeStream = createWriteStream('path/to/file');
203
+
204
+ await pipeline(nodeStream, writeStream);
205
+ ```
206
+
207
+ </details>
208
+ </blockquote>
209
+
210
+ <blockquote>
211
+ <details>
212
+ <summary>ArrayBuffer</summary>
213
+
214
+ ```ts
215
+ import { writeFile } from 'fs/promises';
216
+
217
+ const response = await client.private.agents.downloadSandboxFile(...);
218
+
219
+ const arrayBuffer = await response.arrayBuffer();
220
+ await writeFile('path/to/file', Buffer.from(arrayBuffer));
221
+ ```
222
+
223
+ </details>
224
+ </blockquote>
225
+
226
+ <blockquote>
227
+ <details>
228
+ <summary>Blob</summary>
229
+
230
+ ```ts
231
+ import { writeFile } from 'fs/promises';
232
+
233
+ const response = await client.private.agents.downloadSandboxFile(...);
234
+
235
+ const blob = await response.blob();
236
+ const arrayBuffer = await blob.arrayBuffer();
237
+ await writeFile('output.bin', Buffer.from(arrayBuffer));
238
+ ```
239
+
240
+ </details>
241
+ </blockquote>
242
+
243
+ <blockquote>
244
+ <details>
245
+ <summary>Bytes (UIntArray8)</summary>
246
+
247
+ ```ts
248
+ import { writeFile } from 'fs/promises';
249
+
250
+ const response = await client.private.agents.downloadSandboxFile(...);
251
+
252
+ const bytes = await response.bytes();
253
+ await writeFile('path/to/file', bytes);
254
+ ```
255
+
256
+ </details>
257
+ </blockquote>
258
+
259
+ </details>
260
+ </blockquote>
261
+
262
+ <blockquote>
263
+ <details>
264
+ <summary>Bun</summary>
265
+
266
+ <blockquote>
267
+ <details>
268
+ <summary>ReadableStream (most-efficient)</summary>
269
+
270
+ ```ts
271
+ const response = await client.private.agents.downloadSandboxFile(...);
272
+
273
+ const stream = response.stream();
274
+ await Bun.write('path/to/file', stream);
275
+ ```
276
+
277
+ </details>
278
+ </blockquote>
279
+
280
+ <blockquote>
281
+ <details>
282
+ <summary>ArrayBuffer</summary>
283
+
284
+ ```ts
285
+ const response = await client.private.agents.downloadSandboxFile(...);
286
+
287
+ const arrayBuffer = await response.arrayBuffer();
288
+ await Bun.write('path/to/file', arrayBuffer);
289
+ ```
290
+
291
+ </details>
292
+ </blockquote>
293
+
294
+ <blockquote>
295
+ <details>
296
+ <summary>Blob</summary>
297
+
298
+ ```ts
299
+ const response = await client.private.agents.downloadSandboxFile(...);
300
+
301
+ const blob = await response.blob();
302
+ await Bun.write('path/to/file', blob);
303
+ ```
304
+
305
+ </details>
306
+ </blockquote>
307
+
308
+ <blockquote>
309
+ <details>
310
+ <summary>Bytes (UIntArray8)</summary>
311
+
312
+ ```ts
313
+ const response = await client.private.agents.downloadSandboxFile(...);
314
+
315
+ const bytes = await response.bytes();
316
+ await Bun.write('path/to/file', bytes);
317
+ ```
318
+
319
+ </details>
320
+ </blockquote>
321
+
322
+ </details>
323
+ </blockquote>
324
+
325
+ <blockquote>
326
+ <details>
327
+ <summary>Deno</summary>
328
+
329
+ <blockquote>
330
+ <details>
331
+ <summary>ReadableStream (most-efficient)</summary>
332
+
333
+ ```ts
334
+ const response = await client.private.agents.downloadSandboxFile(...);
335
+
336
+ const stream = response.stream();
337
+ const file = await Deno.open('path/to/file', { write: true, create: true });
338
+ await stream.pipeTo(file.writable);
339
+ ```
340
+
341
+ </details>
342
+ </blockquote>
343
+
344
+ <blockquote>
345
+ <details>
346
+ <summary>ArrayBuffer</summary>
347
+
348
+ ```ts
349
+ const response = await client.private.agents.downloadSandboxFile(...);
350
+
351
+ const arrayBuffer = await response.arrayBuffer();
352
+ await Deno.writeFile('path/to/file', new Uint8Array(arrayBuffer));
353
+ ```
354
+
355
+ </details>
356
+ </blockquote>
357
+
358
+ <blockquote>
359
+ <details>
360
+ <summary>Blob</summary>
361
+
362
+ ```ts
363
+ const response = await client.private.agents.downloadSandboxFile(...);
364
+
365
+ const blob = await response.blob();
366
+ const arrayBuffer = await blob.arrayBuffer();
367
+ await Deno.writeFile('path/to/file', new Uint8Array(arrayBuffer));
368
+ ```
369
+
370
+ </details>
371
+ </blockquote>
372
+
373
+ <blockquote>
374
+ <details>
375
+ <summary>Bytes (UIntArray8)</summary>
376
+
377
+ ```ts
378
+ const response = await client.private.agents.downloadSandboxFile(...);
379
+
380
+ const bytes = await response.bytes();
381
+ await Deno.writeFile('path/to/file', bytes);
382
+ ```
383
+
384
+ </details>
385
+ </blockquote>
386
+
387
+ </details>
388
+ </blockquote>
389
+
390
+ <blockquote>
391
+ <details>
392
+ <summary>Browser</summary>
393
+
394
+ <blockquote>
395
+ <details>
396
+ <summary>Blob (most-efficient)</summary>
397
+
398
+ ```ts
399
+ const response = await client.private.agents.downloadSandboxFile(...);
400
+
401
+ const blob = await response.blob();
402
+ const url = URL.createObjectURL(blob);
403
+
404
+ // trigger download
405
+ const a = document.createElement('a');
406
+ a.href = url;
407
+ a.download = 'filename';
408
+ a.click();
409
+ URL.revokeObjectURL(url);
410
+ ```
411
+
412
+ </details>
413
+ </blockquote>
414
+
415
+ <blockquote>
416
+ <details>
417
+ <summary>ReadableStream</summary>
418
+
419
+ ```ts
420
+ const response = await client.private.agents.downloadSandboxFile(...);
421
+
422
+ const stream = response.stream();
423
+ const reader = stream.getReader();
424
+ const chunks = [];
425
+
426
+ while (true) {
427
+ const { done, value } = await reader.read();
428
+ if (done) break;
429
+ chunks.push(value);
430
+ }
431
+
432
+ const blob = new Blob(chunks);
433
+ const url = URL.createObjectURL(blob);
434
+
435
+ // trigger download
436
+ const a = document.createElement('a');
437
+ a.href = url;
438
+ a.download = 'filename';
439
+ a.click();
440
+ URL.revokeObjectURL(url);
441
+ ```
442
+
443
+ </details>
444
+ </blockquote>
445
+
446
+ <blockquote>
447
+ <details>
448
+ <summary>ArrayBuffer</summary>
449
+
450
+ ```ts
451
+ const response = await client.private.agents.downloadSandboxFile(...);
452
+
453
+ const arrayBuffer = await response.arrayBuffer();
454
+ const blob = new Blob([arrayBuffer]);
455
+ const url = URL.createObjectURL(blob);
456
+
457
+ // trigger download
458
+ const a = document.createElement('a');
459
+ a.href = url;
460
+ a.download = 'filename';
461
+ a.click();
462
+ URL.revokeObjectURL(url);
463
+ ```
464
+
465
+ </details>
466
+ </blockquote>
467
+
468
+ <blockquote>
469
+ <details>
470
+ <summary>Bytes (UIntArray8)</summary>
471
+
472
+ ```ts
473
+ const response = await client.private.agents.downloadSandboxFile(...);
474
+
475
+ const bytes = await response.bytes();
476
+ const blob = new Blob([bytes]);
477
+ const url = URL.createObjectURL(blob);
478
+
479
+ // trigger download
480
+ const a = document.createElement('a');
481
+ a.href = url;
482
+ a.download = 'filename';
483
+ a.click();
484
+ URL.revokeObjectURL(url);
485
+ ```
486
+
487
+ </details>
488
+ </blockquote>
489
+
490
+ </details>
491
+ </blockquote>
492
+
493
+ </details>
494
+ </blockquote>
495
+
496
+ <details>
497
+ <summary>Convert binary response to text</summary>
498
+
499
+ <blockquote>
500
+ <details>
501
+ <summary>ReadableStream</summary>
502
+
503
+ ```ts
504
+ const response = await client.private.agents.downloadSandboxFile(...);
505
+
506
+ const stream = response.stream();
507
+ const text = await new Response(stream).text();
508
+ ```
509
+
510
+ </details>
511
+ </blockquote>
512
+
513
+ <blockquote>
514
+ <details>
515
+ <summary>ArrayBuffer</summary>
516
+
517
+ ```ts
518
+ const response = await client.private.agents.downloadSandboxFile(...);
519
+
520
+ const arrayBuffer = await response.arrayBuffer();
521
+ const text = new TextDecoder().decode(arrayBuffer);
522
+ ```
523
+
524
+ </details>
525
+ </blockquote>
526
+
527
+ <blockquote>
528
+ <details>
529
+ <summary>Blob</summary>
530
+
531
+ ```ts
532
+ const response = await client.private.agents.downloadSandboxFile(...);
533
+
534
+ const blob = await response.blob();
535
+ const text = await blob.text();
536
+ ```
537
+
538
+ </details>
539
+ </blockquote>
540
+
541
+ <blockquote>
542
+ <details>
543
+ <summary>Bytes (UIntArray8)</summary>
544
+
545
+ ```ts
546
+ const response = await client.private.agents.downloadSandboxFile(...);
547
+
548
+ const bytes = await response.bytes();
549
+ const text = new TextDecoder().decode(bytes);
550
+ ```
551
+
552
+ </details>
553
+ </blockquote>
554
+
555
+ </details>
556
+
167
557
  ## Pagination
168
558
 
169
559
  List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:
@@ -172,7 +562,7 @@ List endpoints are paginated. The SDK provides an iterator so that you can simpl
172
562
  import { TrueFoundryGateway } from "truefoundry-gateway-sdk";
173
563
 
174
564
  const client = new TrueFoundryGateway({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
175
- const pageableResponse = await client.private.agents.draftSessions.list({
565
+ const pageableResponse = await client.private.agents.sessions.list({
176
566
  agentName: "agent_name",
177
567
  limit: 1,
178
568
  order: "asc",
@@ -185,7 +575,7 @@ for await (const item of pageableResponse) {
185
575
  }
186
576
 
187
577
  // Or you can manually iterate page-by-page
188
- let page = await client.private.agents.draftSessions.list({
578
+ let page = await client.private.agents.sessions.list({
189
579
  agentName: "agent_name",
190
580
  limit: 1,
191
581
  order: "asc",
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "truefoundry-gateway-sdk",
46
- "X-Fern-SDK-Version": "0.1.0",
47
- "User-Agent": "truefoundry-gateway-sdk/0.1.0",
46
+ "X-Fern-SDK-Version": "0.2.0-rc.1",
47
+ "User-Agent": "truefoundry-gateway-sdk/0.2.0-rc.1",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -9,8 +9,12 @@ export declare namespace TrueFoundryGateway {
9
9
  interface RequestOptions extends BaseTrueFoundryGateway.RequestOptions {
10
10
  }
11
11
  }
12
+ /** Asynchronous client for the TrueFoundry Gateway API. */
12
13
  export declare class TrueFoundryGateway extends BaseTrueFoundryGateway {
13
14
  protected _agents: AgentsClient | undefined;
14
15
  constructor(_options: TrueFoundryGateway.Options);
16
+ /**
17
+ * @returns {AgentsClient} Low-level agents client. Prefer {@link AgentSessionClient} for the high-level API.
18
+ */
15
19
  get agents(): AgentsClient;
16
20
  }
@@ -2,12 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TrueFoundryGateway = void 0;
4
4
  const Client_js_1 = require("./Client.js");
5
+ /** Asynchronous client for the TrueFoundry Gateway API. */
5
6
  class TrueFoundryGateway extends Client_js_1.TrueFoundryGateway {
6
7
  constructor(_options) {
7
8
  var _a;
8
9
  const options = Object.assign(Object.assign({}, _options), { environment: (_a = _options.environment) !== null && _a !== void 0 ? _a : "" });
9
10
  super(options);
10
11
  }
12
+ /**
13
+ * @returns {AgentsClient} Low-level agents client. Prefer {@link AgentSessionClient} for the high-level API.
14
+ */
11
15
  get agents() {
12
16
  var _a;
13
17
  return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = this.private.agents));
@@ -5,23 +5,60 @@ import * as core from "../core/index.js";
5
5
  import { PreparedTurn } from "./PreparedTurn.js";
6
6
  import { Turn } from "./Turn.js";
7
7
  type RequestOptions = SessionsClient.RequestOptions;
8
+ /**
9
+ * A session enriched with convenience methods: prepareTurn, listTurns, getTurn, cancel.
10
+ */
8
11
  export declare class AgentSession implements TrueFoundryGatewayApi.Session {
9
12
  #private;
13
+ /** Unique identifier of this session. */
10
14
  readonly id: string;
15
+ /** Name of the agent for this session. */
11
16
  readonly agentName: string;
17
+ /** Optional user-visible title for the session. */
12
18
  readonly title?: string;
19
+ /** Subject that created this session. */
13
20
  readonly createdBySubject: TrueFoundryGatewayApi.Subject;
21
+ /** ISO-8601 timestamp when the session was created. */
14
22
  readonly createdAt: string;
23
+ /** ISO-8601 timestamp when the session was last updated. */
15
24
  readonly updatedAt: string;
16
25
  constructor(session: TrueFoundryGatewayApi.Session, client: TrueFoundryGateway);
26
+ /**
27
+ * Stage a turn locally; call `execute()` to start `createTurn`.
28
+ *
29
+ * @param opts.input - Turn input items passed to createTurn.
30
+ * @param opts.previousTurnId - Previous turn to chain from. Default `auto`.
31
+ * @returns {PreparedTurn} Staged turn.
32
+ */
17
33
  prepareTurn(opts?: {
18
34
  input?: TrueFoundryGatewayApi.TurnInputItem[];
19
35
  previousTurnId?: TrueFoundryGatewayApi.PreviousTurnIdInput;
20
36
  }): PreparedTurn;
37
+ /**
38
+ * List turns in this session.
39
+ *
40
+ * @param opts.pageToken - Token from the previous response nextPageToken.
41
+ * @param opts.limit - Page size. Default 10.
42
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
43
+ * @returns {core.Page<Turn, TrueFoundryGatewayApi.ListTurnsResponse>} Paginated turns.
44
+ */
21
45
  listTurns(opts?: TrueFoundryGatewayApi.agents.SessionsListTurnsRequest, requestOptions?: RequestOptions): Promise<core.Page<Turn, TrueFoundryGatewayApi.ListTurnsResponse>>;
46
+ /**
47
+ * Fetch a turn by ID.
48
+ *
49
+ * @param opts.turnId - Unique identifier of the turn to fetch.
50
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
51
+ * @returns {Turn} Turn data.
52
+ */
22
53
  getTurn(opts: {
23
54
  turnId: string;
24
55
  }, requestOptions?: RequestOptions): Promise<Turn>;
56
+ /**
57
+ * Cancel the running last turn for the session.
58
+ *
59
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
60
+ * @returns {void}
61
+ */
25
62
  cancel(requestOptions?: RequestOptions): Promise<void>;
26
63
  }
27
64
  export {};
@@ -58,6 +58,9 @@ exports.AgentSession = void 0;
58
58
  const core = __importStar(require("../core/index.js"));
59
59
  const PreparedTurn_js_1 = require("./PreparedTurn.js");
60
60
  const Turn_js_1 = require("./Turn.js");
61
+ /**
62
+ * A session enriched with convenience methods: prepareTurn, listTurns, getTurn, cancel.
63
+ */
61
64
  class AgentSession {
62
65
  constructor(session, client) {
63
66
  _AgentSession_client.set(this, void 0);
@@ -69,9 +72,24 @@ class AgentSession {
69
72
  this.updatedAt = session.updatedAt;
70
73
  __classPrivateFieldSet(this, _AgentSession_client, client, "f");
71
74
  }
75
+ /**
76
+ * Stage a turn locally; call `execute()` to start `createTurn`.
77
+ *
78
+ * @param opts.input - Turn input items passed to createTurn.
79
+ * @param opts.previousTurnId - Previous turn to chain from. Default `auto`.
80
+ * @returns {PreparedTurn} Staged turn.
81
+ */
72
82
  prepareTurn(opts) {
73
83
  return new PreparedTurn_js_1.PreparedTurn({ input: opts === null || opts === void 0 ? void 0 : opts.input, previousTurnId: opts === null || opts === void 0 ? void 0 : opts.previousTurnId }, this, __classPrivateFieldGet(this, _AgentSession_client, "f"));
74
84
  }
85
+ /**
86
+ * List turns in this session.
87
+ *
88
+ * @param opts.pageToken - Token from the previous response nextPageToken.
89
+ * @param opts.limit - Page size. Default 10.
90
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
91
+ * @returns {core.Page<Turn, TrueFoundryGatewayApi.ListTurnsResponse>} Paginated turns.
92
+ */
75
93
  listTurns(opts, requestOptions) {
76
94
  return __awaiter(this, void 0, void 0, function* () {
77
95
  const client = __classPrivateFieldGet(this, _AgentSession_client, "f");
@@ -88,12 +106,25 @@ class AgentSession {
88
106
  });
89
107
  });
90
108
  }
109
+ /**
110
+ * Fetch a turn by ID.
111
+ *
112
+ * @param opts.turnId - Unique identifier of the turn to fetch.
113
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
114
+ * @returns {Turn} Turn data.
115
+ */
91
116
  getTurn(opts, requestOptions) {
92
117
  return __awaiter(this, void 0, void 0, function* () {
93
118
  const response = yield __classPrivateFieldGet(this, _AgentSession_client, "f").agents.sessions.getTurn(this.id, opts.turnId, requestOptions);
94
119
  return new Turn_js_1.Turn(response.data, this, __classPrivateFieldGet(this, _AgentSession_client, "f"));
95
120
  });
96
121
  }
122
+ /**
123
+ * Cancel the running last turn for the session.
124
+ *
125
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
126
+ * @returns {void}
127
+ */
97
128
  cancel(requestOptions) {
98
129
  return __awaiter(this, void 0, void 0, function* () {
99
130
  yield __classPrivateFieldGet(this, _AgentSession_client, "f").agents.sessions.cancel(this.id, {}, requestOptions);
@@ -7,11 +7,41 @@ export declare namespace AgentSessionClient {
7
7
  type Options = TrueFoundryGateway.Options;
8
8
  type RequestOptions = SessionsClient.RequestOptions;
9
9
  }
10
+ /**
11
+ * Entry-point for the high-level agent API. Wraps TrueFoundryGateway and returns
12
+ * enriched AgentSession objects instead of raw response types.
13
+ */
10
14
  export declare class AgentSessionClient {
11
15
  private readonly client;
12
16
  constructor(options: AgentSessionClient.Options);
17
+ /**
18
+ * Create a new session for a named agent.
19
+ *
20
+ * @param opts.agentName - Name of the agent to create a session for.
21
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
22
+ * @returns {AgentSession} Session created.
23
+ */
13
24
  createSession(opts: TrueFoundryGatewayApi.agents.CreateSessionRequest, requestOptions?: AgentSessionClient.RequestOptions): Promise<AgentSession>;
25
+ /**
26
+ * List sessions for an agent.
27
+ *
28
+ * @param opts.agentName - Name of the agent whose sessions to list.
29
+ * @param opts.limit - Page size. Default 10.
30
+ * @param opts.order - Sort by creation time. Default `desc`.
31
+ * @param opts.pageToken - Token from the previous response nextPageToken.
32
+ * @param opts.startTimestamp - Inclusive lower bound on createdAt (ISO-8601).
33
+ * @param opts.endTimestamp - Inclusive upper bound on createdAt (ISO-8601).
34
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
35
+ * @returns {core.Page<AgentSession, TrueFoundryGatewayApi.ListSessionsResponse>} Paginated sessions.
36
+ */
14
37
  listSessions(opts: TrueFoundryGatewayApi.agents.SessionsListRequest, requestOptions?: AgentSessionClient.RequestOptions): Promise<core.Page<AgentSession, TrueFoundryGatewayApi.ListSessionsResponse>>;
38
+ /**
39
+ * Fetch a session by ID.
40
+ *
41
+ * @param opts.sessionId - Unique identifier of the session to fetch.
42
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
43
+ * @returns {AgentSession} Session data.
44
+ */
15
45
  getSession(opts: {
16
46
  sessionId: string;
17
47
  }, requestOptions?: AgentSessionClient.RequestOptions): Promise<AgentSession>;
@@ -46,16 +46,39 @@ exports.AgentSessionClient = void 0;
46
46
  const CustomClient_js_1 = require("../CustomClient.js");
47
47
  const core = __importStar(require("../core/index.js"));
48
48
  const AgentSession_js_1 = require("./AgentSession.js");
49
+ /**
50
+ * Entry-point for the high-level agent API. Wraps TrueFoundryGateway and returns
51
+ * enriched AgentSession objects instead of raw response types.
52
+ */
49
53
  class AgentSessionClient {
50
54
  constructor(options) {
51
55
  this.client = new CustomClient_js_1.TrueFoundryGateway(options);
52
56
  }
57
+ /**
58
+ * Create a new session for a named agent.
59
+ *
60
+ * @param opts.agentName - Name of the agent to create a session for.
61
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
62
+ * @returns {AgentSession} Session created.
63
+ */
53
64
  createSession(opts, requestOptions) {
54
65
  return __awaiter(this, void 0, void 0, function* () {
55
66
  const response = yield this.client.agents.sessions.create(opts, requestOptions);
56
67
  return new AgentSession_js_1.AgentSession(response.data, this.client);
57
68
  });
58
69
  }
70
+ /**
71
+ * List sessions for an agent.
72
+ *
73
+ * @param opts.agentName - Name of the agent whose sessions to list.
74
+ * @param opts.limit - Page size. Default 10.
75
+ * @param opts.order - Sort by creation time. Default `desc`.
76
+ * @param opts.pageToken - Token from the previous response nextPageToken.
77
+ * @param opts.startTimestamp - Inclusive lower bound on createdAt (ISO-8601).
78
+ * @param opts.endTimestamp - Inclusive upper bound on createdAt (ISO-8601).
79
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
80
+ * @returns {core.Page<AgentSession, TrueFoundryGatewayApi.ListSessionsResponse>} Paginated sessions.
81
+ */
59
82
  listSessions(opts, requestOptions) {
60
83
  return __awaiter(this, void 0, void 0, function* () {
61
84
  const page = yield this.client.agents.sessions.list(opts, requestOptions);
@@ -74,6 +97,13 @@ class AgentSessionClient {
74
97
  });
75
98
  });
76
99
  }
100
+ /**
101
+ * Fetch a session by ID.
102
+ *
103
+ * @param opts.sessionId - Unique identifier of the session to fetch.
104
+ * @param requestOptions - Overrides client timeout, retries, abortSignal, headers, queryParams.
105
+ * @returns {AgentSession} Session data.
106
+ */
77
107
  getSession(opts, requestOptions) {
78
108
  return __awaiter(this, void 0, void 0, function* () {
79
109
  const response = yield this.client.agents.sessions.get(opts.sessionId, requestOptions);