@letta-ai/letta-client 0.1.170 → 0.1.173

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 (384) hide show
  1. package/README.md +16 -3
  2. package/api/errors/BadRequestError.d.ts +2 -1
  3. package/api/errors/BadRequestError.js +2 -1
  4. package/api/errors/ConflictError.d.ts +2 -1
  5. package/api/errors/ConflictError.js +2 -1
  6. package/api/errors/InternalServerError.d.ts +2 -1
  7. package/api/errors/InternalServerError.js +2 -1
  8. package/api/errors/NotFoundError.d.ts +2 -1
  9. package/api/errors/NotFoundError.js +2 -1
  10. package/api/errors/PaymentRequiredError.d.ts +2 -1
  11. package/api/errors/PaymentRequiredError.js +2 -1
  12. package/api/errors/UnprocessableEntityError.d.ts +2 -1
  13. package/api/errors/UnprocessableEntityError.js +2 -1
  14. package/api/resources/agents/client/Client.d.ts +20 -10
  15. package/api/resources/agents/client/Client.js +166 -82
  16. package/api/resources/agents/client/requests/AgentsListRequest.d.ts +1 -1
  17. package/api/resources/agents/client/requests/CreateAgentRequest.d.ts +2 -0
  18. package/api/resources/agents/client/requests/UpdateAgent.d.ts +2 -0
  19. package/api/resources/agents/resources/blocks/client/Client.d.ts +10 -5
  20. package/api/resources/agents/resources/blocks/client/Client.js +90 -45
  21. package/api/resources/agents/resources/context/client/Client.d.ts +2 -1
  22. package/api/resources/agents/resources/context/client/Client.js +18 -9
  23. package/api/resources/agents/resources/coreMemory/client/Client.d.ts +2 -1
  24. package/api/resources/agents/resources/coreMemory/client/Client.js +18 -9
  25. package/api/resources/agents/resources/files/client/Client.d.ts +6 -3
  26. package/api/resources/agents/resources/files/client/Client.js +45 -21
  27. package/api/resources/agents/resources/folders/client/Client.d.ts +6 -3
  28. package/api/resources/agents/resources/folders/client/Client.js +54 -27
  29. package/api/resources/agents/resources/groups/client/Client.d.ts +2 -1
  30. package/api/resources/agents/resources/groups/client/Client.js +19 -10
  31. package/api/resources/agents/resources/memoryVariables/client/Client.d.ts +2 -1
  32. package/api/resources/agents/resources/memoryVariables/client/Client.js +18 -9
  33. package/api/resources/agents/resources/messages/client/Client.d.ts +16 -8
  34. package/api/resources/agents/resources/messages/client/Client.js +155 -83
  35. package/api/resources/agents/resources/passages/client/Client.d.ts +8 -4
  36. package/api/resources/agents/resources/passages/client/Client.js +64 -31
  37. package/api/resources/agents/resources/passages/client/requests/PassageUpdate.d.ts +2 -2
  38. package/api/resources/agents/resources/sources/client/Client.d.ts +6 -3
  39. package/api/resources/agents/resources/sources/client/Client.js +54 -27
  40. package/api/resources/agents/resources/templates/client/Client.d.ts +6 -3
  41. package/api/resources/agents/resources/templates/client/Client.js +54 -27
  42. package/api/resources/agents/resources/tools/client/Client.d.ts +6 -3
  43. package/api/resources/agents/resources/tools/client/Client.js +54 -27
  44. package/api/resources/batches/client/Client.d.ts +8 -4
  45. package/api/resources/batches/client/Client.js +63 -30
  46. package/api/resources/blocks/client/Client.d.ts +12 -6
  47. package/api/resources/blocks/client/Client.js +100 -49
  48. package/api/resources/blocks/resources/agents/client/Client.d.ts +2 -1
  49. package/api/resources/blocks/resources/agents/client/Client.js +19 -10
  50. package/api/resources/clientSideAccessTokens/client/Client.d.ts +6 -3
  51. package/api/resources/clientSideAccessTokens/client/Client.js +46 -22
  52. package/api/resources/embeddingModels/client/Client.d.ts +2 -1
  53. package/api/resources/embeddingModels/client/Client.js +18 -9
  54. package/api/resources/folders/client/Client.d.ts +18 -9
  55. package/api/resources/folders/client/Client.js +154 -76
  56. package/api/resources/folders/resources/files/client/Client.d.ts +6 -3
  57. package/api/resources/folders/resources/files/client/Client.js +48 -24
  58. package/api/resources/folders/resources/passages/client/Client.d.ts +2 -1
  59. package/api/resources/folders/resources/passages/client/Client.js +19 -10
  60. package/api/resources/groups/client/Client.d.ts +12 -6
  61. package/api/resources/groups/client/Client.js +105 -52
  62. package/api/resources/groups/resources/messages/client/Client.d.ts +10 -5
  63. package/api/resources/groups/resources/messages/client/Client.js +91 -49
  64. package/api/resources/health/client/Client.d.ts +2 -1
  65. package/api/resources/health/client/Client.js +17 -8
  66. package/api/resources/identities/client/Client.d.ts +14 -7
  67. package/api/resources/identities/client/Client.js +123 -61
  68. package/api/resources/identities/resources/properties/client/Client.d.ts +2 -1
  69. package/api/resources/identities/resources/properties/client/Client.js +9 -3
  70. package/api/resources/jobs/client/Client.d.ts +10 -5
  71. package/api/resources/jobs/client/Client.js +92 -47
  72. package/api/resources/messages/client/Client.d.ts +2 -1
  73. package/api/resources/messages/client/Client.js +19 -10
  74. package/api/resources/models/client/Client.d.ts +2 -1
  75. package/api/resources/models/client/Client.js +27 -14
  76. package/api/resources/projects/client/Client.d.ts +2 -1
  77. package/api/resources/projects/client/Client.js +18 -9
  78. package/api/resources/providers/client/Client.d.ts +10 -5
  79. package/api/resources/providers/client/Client.js +77 -36
  80. package/api/resources/runs/client/Client.d.ts +8 -4
  81. package/api/resources/runs/client/Client.js +74 -38
  82. package/api/resources/runs/resources/messages/client/Client.d.ts +2 -1
  83. package/api/resources/runs/resources/messages/client/Client.js +21 -12
  84. package/api/resources/runs/resources/steps/client/Client.d.ts +2 -1
  85. package/api/resources/runs/resources/steps/client/Client.js +19 -10
  86. package/api/resources/runs/resources/usage/client/Client.d.ts +2 -1
  87. package/api/resources/runs/resources/usage/client/Client.js +18 -9
  88. package/api/resources/sources/client/Client.d.ts +20 -10
  89. package/api/resources/sources/client/Client.js +173 -86
  90. package/api/resources/sources/resources/files/client/Client.d.ts +6 -3
  91. package/api/resources/sources/resources/files/client/Client.js +48 -24
  92. package/api/resources/sources/resources/passages/client/Client.d.ts +2 -1
  93. package/api/resources/sources/resources/passages/client/Client.js +19 -10
  94. package/api/resources/steps/client/Client.d.ts +4 -2
  95. package/api/resources/steps/client/Client.js +41 -21
  96. package/api/resources/steps/resources/feedback/client/Client.d.ts +2 -1
  97. package/api/resources/steps/resources/feedback/client/Client.js +23 -12
  98. package/api/resources/tags/client/Client.d.ts +2 -1
  99. package/api/resources/tags/client/Client.js +19 -10
  100. package/api/resources/telemetry/client/Client.d.ts +2 -1
  101. package/api/resources/telemetry/client/Client.js +18 -9
  102. package/api/resources/templates/client/Client.d.ts +2 -1
  103. package/api/resources/templates/client/Client.js +18 -9
  104. package/api/resources/templates/resources/agents/client/Client.d.ts +2 -1
  105. package/api/resources/templates/resources/agents/client/Client.js +19 -10
  106. package/api/resources/tools/client/Client.d.ts +40 -20
  107. package/api/resources/tools/client/Client.js +356 -182
  108. package/api/resources/tools/client/requests/ToolRunFromSource.d.ts +2 -0
  109. package/api/resources/tools/client/requests/ToolUpdate.d.ts +2 -0
  110. package/api/resources/voice/client/Client.d.ts +2 -1
  111. package/api/resources/voice/client/Client.js +9 -3
  112. package/api/types/AgentState.d.ts +2 -0
  113. package/api/types/EmbeddingConfig.d.ts +1 -11
  114. package/api/types/LettaStreamingRequest.d.ts +2 -0
  115. package/api/types/LlmConfig.d.ts +1 -11
  116. package/api/types/ModalSandboxConfig.d.ts +4 -0
  117. package/api/types/ModalSandboxConfigLanguage.d.ts +8 -0
  118. package/api/types/ModalSandboxConfigLanguage.js +10 -0
  119. package/api/types/NpmRequirement.d.ts +9 -0
  120. package/api/types/NpmRequirement.js +5 -0
  121. package/api/types/Passage.d.ts +4 -4
  122. package/api/types/Tool.d.ts +2 -0
  123. package/api/types/ToolCreate.d.ts +2 -0
  124. package/api/types/ToolType.d.ts +2 -1
  125. package/api/types/ToolType.js +1 -0
  126. package/api/types/index.d.ts +2 -0
  127. package/api/types/index.js +2 -0
  128. package/core/fetcher/APIResponse.d.ts +10 -0
  129. package/core/fetcher/Fetcher.d.ts +1 -1
  130. package/core/fetcher/Fetcher.js +11 -3
  131. package/core/fetcher/Headers.d.ts +2 -0
  132. package/core/fetcher/Headers.js +84 -0
  133. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  134. package/core/fetcher/HttpResponsePromise.js +103 -0
  135. package/core/fetcher/RawResponse.d.ts +29 -0
  136. package/core/fetcher/RawResponse.js +44 -0
  137. package/core/fetcher/createRequestUrl.d.ts +1 -1
  138. package/core/fetcher/getRequestBody.js +2 -1
  139. package/core/fetcher/index.d.ts +3 -0
  140. package/core/fetcher/index.js +7 -1
  141. package/core/fetcher/requestWithRetries.js +1 -1
  142. package/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  143. package/core/form-data-utils/FormDataWrapper.js +53 -10
  144. package/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
  145. package/core/form-data-utils/encodeAsFormParameter.js +18 -0
  146. package/core/form-data-utils/index.d.ts +1 -0
  147. package/core/form-data-utils/index.js +3 -0
  148. package/core/json.d.ts +15 -0
  149. package/core/json.js +24 -0
  150. package/core/schemas/Schema.d.ts +2 -0
  151. package/core/schemas/Schema.js +2 -0
  152. package/core/schemas/builders/bigint/bigint.d.ts +1 -1
  153. package/core/schemas/builders/bigint/bigint.js +21 -17
  154. package/core/schemas/builders/object/object.js +1 -0
  155. package/core/schemas/builders/record/record.js +1 -2
  156. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
  157. package/core/schemas/builders/schema-utils/getSchemaUtils.js +64 -0
  158. package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +1 -1
  159. package/dist/api/errors/BadRequestError.d.ts +2 -1
  160. package/dist/api/errors/BadRequestError.js +2 -1
  161. package/dist/api/errors/ConflictError.d.ts +2 -1
  162. package/dist/api/errors/ConflictError.js +2 -1
  163. package/dist/api/errors/InternalServerError.d.ts +2 -1
  164. package/dist/api/errors/InternalServerError.js +2 -1
  165. package/dist/api/errors/NotFoundError.d.ts +2 -1
  166. package/dist/api/errors/NotFoundError.js +2 -1
  167. package/dist/api/errors/PaymentRequiredError.d.ts +2 -1
  168. package/dist/api/errors/PaymentRequiredError.js +2 -1
  169. package/dist/api/errors/UnprocessableEntityError.d.ts +2 -1
  170. package/dist/api/errors/UnprocessableEntityError.js +2 -1
  171. package/dist/api/resources/agents/client/Client.d.ts +20 -10
  172. package/dist/api/resources/agents/client/Client.js +166 -82
  173. package/dist/api/resources/agents/client/requests/AgentsListRequest.d.ts +1 -1
  174. package/dist/api/resources/agents/client/requests/CreateAgentRequest.d.ts +2 -0
  175. package/dist/api/resources/agents/client/requests/UpdateAgent.d.ts +2 -0
  176. package/dist/api/resources/agents/resources/blocks/client/Client.d.ts +10 -5
  177. package/dist/api/resources/agents/resources/blocks/client/Client.js +90 -45
  178. package/dist/api/resources/agents/resources/context/client/Client.d.ts +2 -1
  179. package/dist/api/resources/agents/resources/context/client/Client.js +18 -9
  180. package/dist/api/resources/agents/resources/coreMemory/client/Client.d.ts +2 -1
  181. package/dist/api/resources/agents/resources/coreMemory/client/Client.js +18 -9
  182. package/dist/api/resources/agents/resources/files/client/Client.d.ts +6 -3
  183. package/dist/api/resources/agents/resources/files/client/Client.js +45 -21
  184. package/dist/api/resources/agents/resources/folders/client/Client.d.ts +6 -3
  185. package/dist/api/resources/agents/resources/folders/client/Client.js +54 -27
  186. package/dist/api/resources/agents/resources/groups/client/Client.d.ts +2 -1
  187. package/dist/api/resources/agents/resources/groups/client/Client.js +19 -10
  188. package/dist/api/resources/agents/resources/memoryVariables/client/Client.d.ts +2 -1
  189. package/dist/api/resources/agents/resources/memoryVariables/client/Client.js +18 -9
  190. package/dist/api/resources/agents/resources/messages/client/Client.d.ts +16 -8
  191. package/dist/api/resources/agents/resources/messages/client/Client.js +155 -83
  192. package/dist/api/resources/agents/resources/passages/client/Client.d.ts +8 -4
  193. package/dist/api/resources/agents/resources/passages/client/Client.js +64 -31
  194. package/dist/api/resources/agents/resources/passages/client/requests/PassageUpdate.d.ts +2 -2
  195. package/dist/api/resources/agents/resources/sources/client/Client.d.ts +6 -3
  196. package/dist/api/resources/agents/resources/sources/client/Client.js +54 -27
  197. package/dist/api/resources/agents/resources/templates/client/Client.d.ts +6 -3
  198. package/dist/api/resources/agents/resources/templates/client/Client.js +54 -27
  199. package/dist/api/resources/agents/resources/tools/client/Client.d.ts +6 -3
  200. package/dist/api/resources/agents/resources/tools/client/Client.js +54 -27
  201. package/dist/api/resources/batches/client/Client.d.ts +8 -4
  202. package/dist/api/resources/batches/client/Client.js +63 -30
  203. package/dist/api/resources/blocks/client/Client.d.ts +12 -6
  204. package/dist/api/resources/blocks/client/Client.js +100 -49
  205. package/dist/api/resources/blocks/resources/agents/client/Client.d.ts +2 -1
  206. package/dist/api/resources/blocks/resources/agents/client/Client.js +19 -10
  207. package/dist/api/resources/clientSideAccessTokens/client/Client.d.ts +6 -3
  208. package/dist/api/resources/clientSideAccessTokens/client/Client.js +46 -22
  209. package/dist/api/resources/embeddingModels/client/Client.d.ts +2 -1
  210. package/dist/api/resources/embeddingModels/client/Client.js +18 -9
  211. package/dist/api/resources/folders/client/Client.d.ts +18 -9
  212. package/dist/api/resources/folders/client/Client.js +154 -76
  213. package/dist/api/resources/folders/resources/files/client/Client.d.ts +6 -3
  214. package/dist/api/resources/folders/resources/files/client/Client.js +48 -24
  215. package/dist/api/resources/folders/resources/passages/client/Client.d.ts +2 -1
  216. package/dist/api/resources/folders/resources/passages/client/Client.js +19 -10
  217. package/dist/api/resources/groups/client/Client.d.ts +12 -6
  218. package/dist/api/resources/groups/client/Client.js +105 -52
  219. package/dist/api/resources/groups/resources/messages/client/Client.d.ts +10 -5
  220. package/dist/api/resources/groups/resources/messages/client/Client.js +91 -49
  221. package/dist/api/resources/health/client/Client.d.ts +2 -1
  222. package/dist/api/resources/health/client/Client.js +17 -8
  223. package/dist/api/resources/identities/client/Client.d.ts +14 -7
  224. package/dist/api/resources/identities/client/Client.js +123 -61
  225. package/dist/api/resources/identities/resources/properties/client/Client.d.ts +2 -1
  226. package/dist/api/resources/identities/resources/properties/client/Client.js +9 -3
  227. package/dist/api/resources/jobs/client/Client.d.ts +10 -5
  228. package/dist/api/resources/jobs/client/Client.js +92 -47
  229. package/dist/api/resources/messages/client/Client.d.ts +2 -1
  230. package/dist/api/resources/messages/client/Client.js +19 -10
  231. package/dist/api/resources/models/client/Client.d.ts +2 -1
  232. package/dist/api/resources/models/client/Client.js +27 -14
  233. package/dist/api/resources/projects/client/Client.d.ts +2 -1
  234. package/dist/api/resources/projects/client/Client.js +18 -9
  235. package/dist/api/resources/providers/client/Client.d.ts +10 -5
  236. package/dist/api/resources/providers/client/Client.js +77 -36
  237. package/dist/api/resources/runs/client/Client.d.ts +8 -4
  238. package/dist/api/resources/runs/client/Client.js +74 -38
  239. package/dist/api/resources/runs/resources/messages/client/Client.d.ts +2 -1
  240. package/dist/api/resources/runs/resources/messages/client/Client.js +21 -12
  241. package/dist/api/resources/runs/resources/steps/client/Client.d.ts +2 -1
  242. package/dist/api/resources/runs/resources/steps/client/Client.js +19 -10
  243. package/dist/api/resources/runs/resources/usage/client/Client.d.ts +2 -1
  244. package/dist/api/resources/runs/resources/usage/client/Client.js +18 -9
  245. package/dist/api/resources/sources/client/Client.d.ts +20 -10
  246. package/dist/api/resources/sources/client/Client.js +173 -86
  247. package/dist/api/resources/sources/resources/files/client/Client.d.ts +6 -3
  248. package/dist/api/resources/sources/resources/files/client/Client.js +48 -24
  249. package/dist/api/resources/sources/resources/passages/client/Client.d.ts +2 -1
  250. package/dist/api/resources/sources/resources/passages/client/Client.js +19 -10
  251. package/dist/api/resources/steps/client/Client.d.ts +4 -2
  252. package/dist/api/resources/steps/client/Client.js +41 -21
  253. package/dist/api/resources/steps/resources/feedback/client/Client.d.ts +2 -1
  254. package/dist/api/resources/steps/resources/feedback/client/Client.js +23 -12
  255. package/dist/api/resources/tags/client/Client.d.ts +2 -1
  256. package/dist/api/resources/tags/client/Client.js +19 -10
  257. package/dist/api/resources/telemetry/client/Client.d.ts +2 -1
  258. package/dist/api/resources/telemetry/client/Client.js +18 -9
  259. package/dist/api/resources/templates/client/Client.d.ts +2 -1
  260. package/dist/api/resources/templates/client/Client.js +18 -9
  261. package/dist/api/resources/templates/resources/agents/client/Client.d.ts +2 -1
  262. package/dist/api/resources/templates/resources/agents/client/Client.js +19 -10
  263. package/dist/api/resources/tools/client/Client.d.ts +40 -20
  264. package/dist/api/resources/tools/client/Client.js +356 -182
  265. package/dist/api/resources/tools/client/requests/ToolRunFromSource.d.ts +2 -0
  266. package/dist/api/resources/tools/client/requests/ToolUpdate.d.ts +2 -0
  267. package/dist/api/resources/voice/client/Client.d.ts +2 -1
  268. package/dist/api/resources/voice/client/Client.js +9 -3
  269. package/dist/api/types/AgentState.d.ts +2 -0
  270. package/dist/api/types/EmbeddingConfig.d.ts +1 -11
  271. package/dist/api/types/LettaStreamingRequest.d.ts +2 -0
  272. package/dist/api/types/LlmConfig.d.ts +1 -11
  273. package/dist/api/types/ModalSandboxConfig.d.ts +4 -0
  274. package/dist/api/types/ModalSandboxConfigLanguage.d.ts +8 -0
  275. package/dist/api/types/ModalSandboxConfigLanguage.js +10 -0
  276. package/dist/api/types/NpmRequirement.d.ts +9 -0
  277. package/dist/api/types/NpmRequirement.js +5 -0
  278. package/dist/api/types/Passage.d.ts +4 -4
  279. package/dist/api/types/Tool.d.ts +2 -0
  280. package/dist/api/types/ToolCreate.d.ts +2 -0
  281. package/dist/api/types/ToolType.d.ts +2 -1
  282. package/dist/api/types/ToolType.js +1 -0
  283. package/dist/api/types/index.d.ts +2 -0
  284. package/dist/api/types/index.js +2 -0
  285. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  286. package/dist/core/fetcher/Fetcher.d.ts +1 -1
  287. package/dist/core/fetcher/Fetcher.js +11 -3
  288. package/dist/core/fetcher/Headers.d.ts +2 -0
  289. package/dist/core/fetcher/Headers.js +84 -0
  290. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  291. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  292. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  293. package/dist/core/fetcher/RawResponse.js +44 -0
  294. package/dist/core/fetcher/createRequestUrl.d.ts +1 -1
  295. package/dist/core/fetcher/getRequestBody.js +2 -1
  296. package/dist/core/fetcher/index.d.ts +3 -0
  297. package/dist/core/fetcher/index.js +7 -1
  298. package/dist/core/fetcher/requestWithRetries.js +1 -1
  299. package/dist/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  300. package/dist/core/form-data-utils/FormDataWrapper.js +53 -10
  301. package/dist/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
  302. package/dist/core/form-data-utils/encodeAsFormParameter.js +18 -0
  303. package/dist/core/form-data-utils/index.d.ts +1 -0
  304. package/dist/core/form-data-utils/index.js +3 -0
  305. package/dist/core/json.d.ts +15 -0
  306. package/dist/core/json.js +24 -0
  307. package/dist/core/schemas/Schema.d.ts +2 -0
  308. package/dist/core/schemas/Schema.js +2 -0
  309. package/dist/core/schemas/builders/bigint/bigint.d.ts +1 -1
  310. package/dist/core/schemas/builders/bigint/bigint.js +21 -17
  311. package/dist/core/schemas/builders/object/object.js +1 -0
  312. package/dist/core/schemas/builders/record/record.js +1 -2
  313. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
  314. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +64 -0
  315. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +1 -1
  316. package/dist/errors/LettaError.d.ts +4 -1
  317. package/dist/errors/LettaError.js +6 -8
  318. package/dist/serialization/resources/agents/client/requests/CreateAgentRequest.d.ts +1 -0
  319. package/dist/serialization/resources/agents/client/requests/CreateAgentRequest.js +1 -0
  320. package/dist/serialization/resources/agents/client/requests/UpdateAgent.d.ts +1 -0
  321. package/dist/serialization/resources/agents/client/requests/UpdateAgent.js +1 -0
  322. package/dist/serialization/resources/agents/resources/passages/client/requests/PassageUpdate.d.ts +1 -1
  323. package/dist/serialization/resources/agents/resources/passages/client/requests/PassageUpdate.js +1 -1
  324. package/dist/serialization/resources/tools/client/requests/ToolRunFromSource.d.ts +2 -0
  325. package/dist/serialization/resources/tools/client/requests/ToolRunFromSource.js +2 -0
  326. package/dist/serialization/resources/tools/client/requests/ToolUpdate.d.ts +2 -0
  327. package/dist/serialization/resources/tools/client/requests/ToolUpdate.js +2 -0
  328. package/dist/serialization/types/AgentState.d.ts +1 -0
  329. package/dist/serialization/types/AgentState.js +1 -0
  330. package/dist/serialization/types/LettaStreamingRequest.d.ts +1 -0
  331. package/dist/serialization/types/LettaStreamingRequest.js +1 -0
  332. package/dist/serialization/types/ModalSandboxConfig.d.ts +3 -0
  333. package/dist/serialization/types/ModalSandboxConfig.js +3 -0
  334. package/dist/serialization/types/ModalSandboxConfigLanguage.d.ts +10 -0
  335. package/dist/serialization/types/ModalSandboxConfigLanguage.js +41 -0
  336. package/dist/serialization/types/NpmRequirement.d.ts +13 -0
  337. package/dist/serialization/types/NpmRequirement.js +44 -0
  338. package/dist/serialization/types/Passage.d.ts +1 -1
  339. package/dist/serialization/types/Passage.js +1 -1
  340. package/dist/serialization/types/Tool.d.ts +2 -0
  341. package/dist/serialization/types/Tool.js +2 -0
  342. package/dist/serialization/types/ToolCreate.d.ts +2 -0
  343. package/dist/serialization/types/ToolCreate.js +2 -0
  344. package/dist/serialization/types/ToolType.d.ts +1 -1
  345. package/dist/serialization/types/ToolType.js +1 -0
  346. package/dist/serialization/types/index.d.ts +2 -0
  347. package/dist/serialization/types/index.js +2 -0
  348. package/dist/version.d.ts +1 -1
  349. package/dist/version.js +1 -1
  350. package/errors/LettaError.d.ts +4 -1
  351. package/errors/LettaError.js +6 -8
  352. package/package.json +4 -4
  353. package/serialization/resources/agents/client/requests/CreateAgentRequest.d.ts +1 -0
  354. package/serialization/resources/agents/client/requests/CreateAgentRequest.js +1 -0
  355. package/serialization/resources/agents/client/requests/UpdateAgent.d.ts +1 -0
  356. package/serialization/resources/agents/client/requests/UpdateAgent.js +1 -0
  357. package/serialization/resources/agents/resources/passages/client/requests/PassageUpdate.d.ts +1 -1
  358. package/serialization/resources/agents/resources/passages/client/requests/PassageUpdate.js +1 -1
  359. package/serialization/resources/tools/client/requests/ToolRunFromSource.d.ts +2 -0
  360. package/serialization/resources/tools/client/requests/ToolRunFromSource.js +2 -0
  361. package/serialization/resources/tools/client/requests/ToolUpdate.d.ts +2 -0
  362. package/serialization/resources/tools/client/requests/ToolUpdate.js +2 -0
  363. package/serialization/types/AgentState.d.ts +1 -0
  364. package/serialization/types/AgentState.js +1 -0
  365. package/serialization/types/LettaStreamingRequest.d.ts +1 -0
  366. package/serialization/types/LettaStreamingRequest.js +1 -0
  367. package/serialization/types/ModalSandboxConfig.d.ts +3 -0
  368. package/serialization/types/ModalSandboxConfig.js +3 -0
  369. package/serialization/types/ModalSandboxConfigLanguage.d.ts +10 -0
  370. package/serialization/types/ModalSandboxConfigLanguage.js +41 -0
  371. package/serialization/types/NpmRequirement.d.ts +13 -0
  372. package/serialization/types/NpmRequirement.js +44 -0
  373. package/serialization/types/Passage.d.ts +1 -1
  374. package/serialization/types/Passage.js +1 -1
  375. package/serialization/types/Tool.d.ts +2 -0
  376. package/serialization/types/Tool.js +2 -0
  377. package/serialization/types/ToolCreate.d.ts +2 -0
  378. package/serialization/types/ToolCreate.js +2 -0
  379. package/serialization/types/ToolType.d.ts +1 -1
  380. package/serialization/types/ToolType.js +1 -0
  381. package/serialization/types/index.d.ts +2 -0
  382. package/serialization/types/index.js +2 -0
  383. package/version.d.ts +1 -1
  384. package/version.js +1 -1
@@ -28,4 +28,6 @@ export interface ToolRunFromSource {
28
28
  jsonSchema?: Record<string, unknown>;
29
29
  /** Optional list of pip packages required by this tool. */
30
30
  pipRequirements?: Letta.PipRequirement[];
31
+ /** Optional list of npm packages required by this tool. */
32
+ npmRequirements?: Letta.NpmRequirement[];
31
33
  }
@@ -23,4 +23,6 @@ export interface ToolUpdate {
23
23
  returnCharLimit?: number;
24
24
  /** Optional list of pip packages required by this tool. */
25
25
  pipRequirements?: Letta.PipRequirement[];
26
+ /** Optional list of npm packages required by this tool. */
27
+ npmRequirements?: Letta.NpmRequirement[];
26
28
  }
@@ -44,7 +44,8 @@ export declare class Voice {
44
44
  * }
45
45
  * })
46
46
  */
47
- createVoiceChatCompletions(agentId: string, request: Letta.CreateVoiceChatCompletionsRequest, requestOptions?: Voice.RequestOptions): Promise<unknown>;
47
+ createVoiceChatCompletions(agentId: string, request: Letta.CreateVoiceChatCompletionsRequest, requestOptions?: Voice.RequestOptions): core.HttpResponsePromise<unknown>;
48
+ private __createVoiceChatCompletions;
48
49
  protected _getCustomAuthorizationHeaders(): Promise<{
49
50
  Authorization: string;
50
51
  }>;
@@ -74,6 +74,9 @@ class Voice {
74
74
  * })
75
75
  */
76
76
  createVoiceChatCompletions(agentId, request, requestOptions) {
77
+ return core.HttpResponsePromise.fromPromise(this.__createVoiceChatCompletions(agentId, request, requestOptions));
78
+ }
79
+ __createVoiceChatCompletions(agentId, request, requestOptions) {
77
80
  return __awaiter(this, void 0, void 0, function* () {
78
81
  var _a, _b, _c;
79
82
  const { userId, body: _body } = request;
@@ -82,7 +85,7 @@ class Voice {
82
85
  method: "POST",
83
86
  headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
84
87
  ? yield core.Supplier.get(this._options.project)
85
- : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.170", "User-Agent": "@letta-ai/letta-client/0.1.170", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "user-id": userId != null ? userId : undefined }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
88
+ : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.173", "User-Agent": "@letta-ai/letta-client/0.1.173", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "user-id": userId != null ? userId : undefined }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
86
89
  contentType: "application/json",
87
90
  requestType: "json",
88
91
  body: serializers.voice.createVoiceChatCompletions.Request.jsonOrThrow(_body, {
@@ -93,7 +96,7 @@ class Voice {
93
96
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
94
97
  });
95
98
  if (_response.ok) {
96
- return _response.body;
99
+ return { data: _response.body, rawResponse: _response.rawResponse };
97
100
  }
98
101
  if (_response.error.reason === "status-code") {
99
102
  switch (_response.error.statusCode) {
@@ -104,11 +107,12 @@ class Voice {
104
107
  allowUnrecognizedEnumValues: true,
105
108
  skipValidation: true,
106
109
  breadcrumbsPrefix: ["response"],
107
- }));
110
+ }), _response.rawResponse);
108
111
  default:
109
112
  throw new errors.LettaError({
110
113
  statusCode: _response.error.statusCode,
111
114
  body: _response.error.body,
115
+ rawResponse: _response.rawResponse,
112
116
  });
113
117
  }
114
118
  }
@@ -117,12 +121,14 @@ class Voice {
117
121
  throw new errors.LettaError({
118
122
  statusCode: _response.error.statusCode,
119
123
  body: _response.error.rawBody,
124
+ rawResponse: _response.rawResponse,
120
125
  });
121
126
  case "timeout":
122
127
  throw new errors.LettaTimeoutError("Timeout exceeded when calling POST /v1/voice-beta/{agent_id}/chat/completions.");
123
128
  case "unknown":
124
129
  throw new errors.LettaError({
125
130
  message: _response.error.errorMessage,
131
+ rawResponse: _response.rawResponse,
126
132
  });
127
133
  }
128
134
  });
@@ -81,4 +81,6 @@ export interface AgentState {
81
81
  maxFilesOpen?: number;
82
82
  /** The per-file view window character limit for this agent. Setting this too high may exceed the context window, which will break the agent. */
83
83
  perFileViewWindowCharLimit?: number;
84
+ /** If set to True, the agent will be hidden. */
85
+ hidden?: boolean;
84
86
  }
@@ -3,17 +3,7 @@
3
3
  */
4
4
  import * as Letta from "../index";
5
5
  /**
6
- * Embedding model configuration. This object specifies all the information necessary to access an embedding model to usage with Letta, except for secret keys.
7
- *
8
- * Attributes:
9
- * embedding_endpoint_type (str): The endpoint type for the model.
10
- * embedding_endpoint (str): The endpoint for the model.
11
- * embedding_model (str): The model for the embedding.
12
- * embedding_dim (int): The dimension of the embedding.
13
- * embedding_chunk_size (int): The chunk size of the embedding.
14
- * azure_endpoint (:obj:`str`, optional): The Azure endpoint for the model (Azure only).
15
- * azure_version (str): The Azure version for the model (Azure only).
16
- * azure_deployment (str): The Azure deployment for the model (Azure only).
6
+ * Configuration for embedding model connection and processing parameters.
17
7
  */
18
8
  export interface EmbeddingConfig {
19
9
  /** The endpoint type for the model. */
@@ -19,4 +19,6 @@ export interface LettaStreamingRequest {
19
19
  enableThinking?: string;
20
20
  /** Flag to determine if individual tokens should be streamed. Set to True for token streaming (requires stream_steps = True). */
21
21
  streamTokens?: boolean;
22
+ /** Whether to include periodic keepalive ping messages in the stream to prevent connection timeouts. */
23
+ includePings?: boolean;
22
24
  }
@@ -3,17 +3,7 @@
3
3
  */
4
4
  import * as Letta from "../index";
5
5
  /**
6
- * Configuration for a Language Model (LLM) model. This object specifies all the information necessary to access an LLM model to usage with Letta, except for secret keys.
7
- *
8
- * Attributes:
9
- * model (str): The name of the LLM model.
10
- * model_endpoint_type (str): The endpoint type for the model.
11
- * model_endpoint (str): The endpoint for the model.
12
- * model_wrapper (str): The wrapper for the model. This is used to wrap additional text around the input/output of the model. This is useful for text-to-text completions, such as the Completions API in OpenAI.
13
- * context_window (int): The context window size for the model.
14
- * put_inner_thoughts_in_kwargs (bool): Puts `inner_thoughts` as a kwarg in the function call if this is set to True. This helps with function calling performance and also the generation of inner thoughts.
15
- * temperature (float): The temperature to use when generating text with the model. A higher temperature will result in more random text.
16
- * max_tokens (int): The maximum number of tokens to generate.
6
+ * Configuration for Language Model (LLM) connection and generation parameters.
17
7
  */
18
8
  export interface LlmConfig {
19
9
  /** LLM model name. */
@@ -1,9 +1,13 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
+ import * as Letta from "../index";
4
5
  export interface ModalSandboxConfig {
5
6
  /** Time limit for the sandbox (in seconds). */
6
7
  timeout?: number;
7
8
  /** A list of pip packages to install in the Modal sandbox */
8
9
  pipRequirements?: string[];
10
+ /** A list of npm packages to install in the Modal sandbox */
11
+ npmRequirements?: string[];
12
+ language?: Letta.ModalSandboxConfigLanguage;
9
13
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type ModalSandboxConfigLanguage = "python" | "typescript";
5
+ export declare const ModalSandboxConfigLanguage: {
6
+ readonly Python: "python";
7
+ readonly Typescript: "typescript";
8
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ModalSandboxConfigLanguage = void 0;
7
+ exports.ModalSandboxConfigLanguage = {
8
+ Python: "python",
9
+ Typescript: "typescript",
10
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface NpmRequirement {
5
+ /** Name of the npm package. */
6
+ name: string;
7
+ /** Optional version of the package, following semantic versioning. */
8
+ version?: string;
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,8 +10,8 @@ import * as Letta from "../index";
10
10
  * embedding (List[float]): The embedding of the passage.
11
11
  * embedding_config (EmbeddingConfig): The embedding configuration used by the passage.
12
12
  * created_at (datetime): The creation date of the passage.
13
- * user_id (str): The unique identifier of the user associated with the passage.
14
- * agent_id (str): The unique identifier of the agent associated with the passage.
13
+ * organization_id (str): The unique identifier of the organization associated with the passage.
14
+ * archive_id (str): The unique identifier of the archive containing this passage.
15
15
  * source_id (str): The data source of the passage.
16
16
  * file_id (str): The unique identifier of the file associated with the passage.
17
17
  */
@@ -26,8 +26,8 @@ export interface Passage {
26
26
  updatedAt?: Date;
27
27
  /** Whether this passage is deleted or not. */
28
28
  isDeleted?: boolean;
29
- /** The unique identifier of the agent associated with the passage. */
30
- agentId?: string;
29
+ /** The unique identifier of the archive containing this passage. */
30
+ archiveId?: string;
31
31
  /** The data source of the passage. */
32
32
  sourceId?: string;
33
33
  /** The unique identifier of the file associated with the passage. */
@@ -35,6 +35,8 @@ export interface Tool {
35
35
  returnCharLimit?: number;
36
36
  /** Optional list of pip packages required by this tool. */
37
37
  pipRequirements?: Letta.PipRequirement[];
38
+ /** Optional list of npm packages required by this tool. */
39
+ npmRequirements?: Letta.NpmRequirement[];
38
40
  /** The id of the user that made this Tool. */
39
41
  createdById?: string;
40
42
  /** The id of the user that made this Tool. */
@@ -19,4 +19,6 @@ export interface ToolCreate {
19
19
  returnCharLimit?: number;
20
20
  /** Optional list of pip packages required by this tool. */
21
21
  pipRequirements?: Letta.PipRequirement[];
22
+ /** Optional list of npm packages required by this tool. */
23
+ npmRequirements?: Letta.NpmRequirement[];
22
24
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type ToolType = "custom" | "letta_core" | "letta_memory_core" | "letta_multi_agent_core" | "letta_sleeptime_core" | "letta_voice_sleeptime_core" | "letta_builtin" | "letta_files_core" | "external_composio" | "external_mcp";
4
+ export type ToolType = "custom" | "letta_core" | "letta_memory_core" | "letta_multi_agent_core" | "letta_sleeptime_core" | "letta_voice_sleeptime_core" | "letta_builtin" | "letta_files_core" | "external_composio" | "external_langchain" | "external_mcp";
5
5
  export declare const ToolType: {
6
6
  readonly Custom: "custom";
7
7
  readonly LettaCore: "letta_core";
@@ -12,5 +12,6 @@ export declare const ToolType: {
12
12
  readonly LettaBuiltin: "letta_builtin";
13
13
  readonly LettaFilesCore: "letta_files_core";
14
14
  readonly ExternalComposio: "external_composio";
15
+ readonly ExternalLangchain: "external_langchain";
15
16
  readonly ExternalMcp: "external_mcp";
16
17
  };
@@ -14,5 +14,6 @@ exports.ToolType = {
14
14
  LettaBuiltin: "letta_builtin",
15
15
  LettaFilesCore: "letta_files_core",
16
16
  ExternalComposio: "external_composio",
17
+ ExternalLangchain: "external_langchain",
17
18
  ExternalMcp: "external_mcp",
18
19
  };
@@ -157,7 +157,9 @@ export * from "./MessageCreate";
157
157
  export * from "./MessageRole";
158
158
  export * from "./MessageSchema";
159
159
  export * from "./MessageType";
160
+ export * from "./ModalSandboxConfigLanguage";
160
161
  export * from "./ModalSandboxConfig";
162
+ export * from "./NpmRequirement";
161
163
  export * from "./OmittedReasoningContent";
162
164
  export * from "./Organization";
163
165
  export * from "./OrganizationCreate";
@@ -173,7 +173,9 @@ __exportStar(require("./MessageCreate"), exports);
173
173
  __exportStar(require("./MessageRole"), exports);
174
174
  __exportStar(require("./MessageSchema"), exports);
175
175
  __exportStar(require("./MessageType"), exports);
176
+ __exportStar(require("./ModalSandboxConfigLanguage"), exports);
176
177
  __exportStar(require("./ModalSandboxConfig"), exports);
178
+ __exportStar(require("./NpmRequirement"), exports);
177
179
  __exportStar(require("./OmittedReasoningContent"), exports);
178
180
  __exportStar(require("./Organization"), exports);
179
181
  __exportStar(require("./OrganizationCreate"), exports);
@@ -1,10 +1,20 @@
1
+ import { RawResponse } from "./RawResponse";
2
+ /**
3
+ * The response of an API call.
4
+ * It is a successful response or a failed response.
5
+ */
1
6
  export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
2
7
  export interface SuccessfulResponse<T> {
3
8
  ok: true;
4
9
  body: T;
10
+ /**
11
+ * @deprecated Use `rawResponse` instead
12
+ */
5
13
  headers?: Record<string, any>;
14
+ rawResponse: RawResponse;
6
15
  }
7
16
  export interface FailedResponse<T> {
8
17
  ok: false;
9
18
  error: T;
19
+ rawResponse: RawResponse;
10
20
  }
@@ -6,7 +6,7 @@ export declare namespace Fetcher {
6
6
  method: string;
7
7
  contentType?: string;
8
8
  headers?: Record<string, string | undefined>;
9
- queryParameters?: Record<string, string | string[] | object | object[]>;
9
+ queryParameters?: Record<string, string | string[] | object | object[] | null>;
10
10
  body?: unknown;
11
11
  timeoutMs?: number;
12
12
  maxRetries?: number;
@@ -11,6 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.fetcher = void 0;
13
13
  exports.fetcherImpl = fetcherImpl;
14
+ const json_1 = require("../json");
15
+ const RawResponse_1 = require("./RawResponse");
14
16
  const createRequestUrl_1 = require("./createRequestUrl");
15
17
  const getFetchFn_1 = require("./getFetchFn");
16
18
  const getRequestBody_1 = require("./getRequestBody");
@@ -31,7 +33,7 @@ function fetcherImpl(args) {
31
33
  }
32
34
  }
33
35
  const url = (0, createRequestUrl_1.createRequestUrl)(args.url, args.queryParameters);
34
- let requestBody = yield (0, getRequestBody_1.getRequestBody)({
36
+ const requestBody = yield (0, getRequestBody_1.getRequestBody)({
35
37
  body: args.body,
36
38
  type: args.requestType === "json" ? "json" : "other",
37
39
  });
@@ -40,12 +42,13 @@ function fetcherImpl(args) {
40
42
  const response = yield (0, requestWithRetries_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
41
43
  return (0, makeRequest_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
42
44
  }), args.maxRetries);
43
- let responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType);
45
+ const responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType);
44
46
  if (response.status >= 200 && response.status < 400) {
45
47
  return {
46
48
  ok: true,
47
49
  body: responseBody,
48
50
  headers: response.headers,
51
+ rawResponse: (0, RawResponse_1.toRawResponse)(response),
49
52
  };
50
53
  }
51
54
  else {
@@ -56,6 +59,7 @@ function fetcherImpl(args) {
56
59
  statusCode: response.status,
57
60
  body: responseBody,
58
61
  },
62
+ rawResponse: (0, RawResponse_1.toRawResponse)(response),
59
63
  };
60
64
  }
61
65
  }
@@ -67,6 +71,7 @@ function fetcherImpl(args) {
67
71
  reason: "unknown",
68
72
  errorMessage: "The user aborted a request",
69
73
  },
74
+ rawResponse: RawResponse_1.abortRawResponse,
70
75
  };
71
76
  }
72
77
  else if (error instanceof Error && error.name === "AbortError") {
@@ -75,6 +80,7 @@ function fetcherImpl(args) {
75
80
  error: {
76
81
  reason: "timeout",
77
82
  },
83
+ rawResponse: RawResponse_1.abortRawResponse,
78
84
  };
79
85
  }
80
86
  else if (error instanceof Error) {
@@ -84,14 +90,16 @@ function fetcherImpl(args) {
84
90
  reason: "unknown",
85
91
  errorMessage: error.message,
86
92
  },
93
+ rawResponse: RawResponse_1.unknownRawResponse,
87
94
  };
88
95
  }
89
96
  return {
90
97
  ok: false,
91
98
  error: {
92
99
  reason: "unknown",
93
- errorMessage: JSON.stringify(error),
100
+ errorMessage: (0, json_1.toJson)(error),
94
101
  },
102
+ rawResponse: RawResponse_1.unknownRawResponse,
95
103
  };
96
104
  }
97
105
  });
@@ -0,0 +1,2 @@
1
+ declare let Headers: typeof globalThis.Headers;
2
+ export { Headers };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Headers = void 0;
4
+ let Headers;
5
+ if (typeof globalThis.Headers !== "undefined") {
6
+ exports.Headers = Headers = globalThis.Headers;
7
+ }
8
+ else {
9
+ exports.Headers = Headers = class Headers {
10
+ constructor(init) {
11
+ this.headers = new Map();
12
+ if (init) {
13
+ if (init instanceof Headers) {
14
+ init.forEach((value, key) => this.append(key, value));
15
+ }
16
+ else if (Array.isArray(init)) {
17
+ for (const [key, value] of init) {
18
+ if (typeof key === "string" && typeof value === "string") {
19
+ this.append(key, value);
20
+ }
21
+ else {
22
+ throw new TypeError("Each header entry must be a [string, string] tuple");
23
+ }
24
+ }
25
+ }
26
+ else {
27
+ for (const [key, value] of Object.entries(init)) {
28
+ if (typeof value === "string") {
29
+ this.append(key, value);
30
+ }
31
+ else {
32
+ throw new TypeError("Header values must be strings");
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ append(name, value) {
39
+ const key = name.toLowerCase();
40
+ const existing = this.headers.get(key) || [];
41
+ this.headers.set(key, [...existing, value]);
42
+ }
43
+ delete(name) {
44
+ const key = name.toLowerCase();
45
+ this.headers.delete(key);
46
+ }
47
+ get(name) {
48
+ const key = name.toLowerCase();
49
+ const values = this.headers.get(key);
50
+ return values ? values.join(", ") : null;
51
+ }
52
+ has(name) {
53
+ const key = name.toLowerCase();
54
+ return this.headers.has(key);
55
+ }
56
+ set(name, value) {
57
+ const key = name.toLowerCase();
58
+ this.headers.set(key, [value]);
59
+ }
60
+ forEach(callbackfn, thisArg) {
61
+ const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
62
+ this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
63
+ }
64
+ getSetCookie() {
65
+ return this.headers.get("set-cookie") || [];
66
+ }
67
+ *entries() {
68
+ for (const [key, values] of this.headers.entries()) {
69
+ yield [key, values.join(", ")];
70
+ }
71
+ }
72
+ *keys() {
73
+ yield* this.headers.keys();
74
+ }
75
+ *values() {
76
+ for (const values of this.headers.values()) {
77
+ yield values.join(", ");
78
+ }
79
+ }
80
+ [Symbol.iterator]() {
81
+ return this.entries();
82
+ }
83
+ };
84
+ }
@@ -0,0 +1,58 @@
1
+ import { WithRawResponse } from "./RawResponse";
2
+ /**
3
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
4
+ */
5
+ export declare class HttpResponsePromise<T> extends Promise<T> {
6
+ private innerPromise;
7
+ private unwrappedPromise;
8
+ private constructor();
9
+ /**
10
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
11
+ *
12
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
13
+ * @param args - Arguments to pass to the function.
14
+ * @returns An `HttpResponsePromise` instance.
15
+ */
16
+ static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
17
+ /**
18
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
19
+ *
20
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
21
+ * @returns A function that returns an `HttpResponsePromise` instance.
22
+ */
23
+ static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
24
+ /**
25
+ * Creates an `HttpResponsePromise` from an existing promise.
26
+ *
27
+ * @param promise - A promise resolving to a `WithRawResponse` object.
28
+ * @returns An `HttpResponsePromise` instance.
29
+ */
30
+ static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
31
+ /**
32
+ * Creates an `HttpResponsePromise` from an executor function.
33
+ *
34
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
35
+ * @returns An `HttpResponsePromise` instance.
36
+ */
37
+ static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
38
+ /**
39
+ * Creates an `HttpResponsePromise` from a resolved result.
40
+ *
41
+ * @param result - A `WithRawResponse` object to resolve immediately.
42
+ * @returns An `HttpResponsePromise` instance.
43
+ */
44
+ static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
45
+ private unwrap;
46
+ /** @inheritdoc */
47
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
48
+ /** @inheritdoc */
49
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
50
+ /** @inheritdoc */
51
+ finally(onfinally?: (() => void) | null): Promise<T>;
52
+ /**
53
+ * Retrieves the data and raw response.
54
+ *
55
+ * @returns A promise resolving to a `WithRawResponse` object.
56
+ */
57
+ withRawResponse(): Promise<WithRawResponse<T>>;
58
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HttpResponsePromise = void 0;
13
+ /**
14
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
15
+ */
16
+ class HttpResponsePromise extends Promise {
17
+ constructor(promise) {
18
+ // Initialize with a no-op to avoid premature parsing
19
+ super((resolve) => {
20
+ resolve(undefined);
21
+ });
22
+ this.innerPromise = promise;
23
+ }
24
+ /**
25
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
26
+ *
27
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
28
+ * @param args - Arguments to pass to the function.
29
+ * @returns An `HttpResponsePromise` instance.
30
+ */
31
+ static fromFunction(fn, ...args) {
32
+ return new HttpResponsePromise(fn(...args));
33
+ }
34
+ /**
35
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
36
+ *
37
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
38
+ * @returns A function that returns an `HttpResponsePromise` instance.
39
+ */
40
+ static interceptFunction(fn) {
41
+ return (...args) => {
42
+ return HttpResponsePromise.fromPromise(fn(...args));
43
+ };
44
+ }
45
+ /**
46
+ * Creates an `HttpResponsePromise` from an existing promise.
47
+ *
48
+ * @param promise - A promise resolving to a `WithRawResponse` object.
49
+ * @returns An `HttpResponsePromise` instance.
50
+ */
51
+ static fromPromise(promise) {
52
+ return new HttpResponsePromise(promise);
53
+ }
54
+ /**
55
+ * Creates an `HttpResponsePromise` from an executor function.
56
+ *
57
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
58
+ * @returns An `HttpResponsePromise` instance.
59
+ */
60
+ static fromExecutor(executor) {
61
+ const promise = new Promise(executor);
62
+ return new HttpResponsePromise(promise);
63
+ }
64
+ /**
65
+ * Creates an `HttpResponsePromise` from a resolved result.
66
+ *
67
+ * @param result - A `WithRawResponse` object to resolve immediately.
68
+ * @returns An `HttpResponsePromise` instance.
69
+ */
70
+ static fromResult(result) {
71
+ const promise = Promise.resolve(result);
72
+ return new HttpResponsePromise(promise);
73
+ }
74
+ unwrap() {
75
+ if (!this.unwrappedPromise) {
76
+ this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
77
+ }
78
+ return this.unwrappedPromise;
79
+ }
80
+ /** @inheritdoc */
81
+ then(onfulfilled, onrejected) {
82
+ return this.unwrap().then(onfulfilled, onrejected);
83
+ }
84
+ /** @inheritdoc */
85
+ catch(onrejected) {
86
+ return this.unwrap().catch(onrejected);
87
+ }
88
+ /** @inheritdoc */
89
+ finally(onfinally) {
90
+ return this.unwrap().finally(onfinally);
91
+ }
92
+ /**
93
+ * Retrieves the data and raw response.
94
+ *
95
+ * @returns A promise resolving to a `WithRawResponse` object.
96
+ */
97
+ withRawResponse() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ return yield this.innerPromise;
100
+ });
101
+ }
102
+ }
103
+ exports.HttpResponsePromise = HttpResponsePromise;