llama-stack-client 0.0.35 → 0.1.2

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 (490) hide show
  1. package/LICENSE +22 -201
  2. package/README.md +60 -26
  3. package/core.d.ts +7 -7
  4. package/core.d.ts.map +1 -1
  5. package/core.js +44 -19
  6. package/core.js.map +1 -1
  7. package/core.mjs +41 -17
  8. package/core.mjs.map +1 -1
  9. package/error.d.ts +18 -24
  10. package/error.d.ts.map +1 -1
  11. package/error.js +1 -31
  12. package/error.js.map +1 -1
  13. package/error.mjs +1 -31
  14. package/error.mjs.map +1 -1
  15. package/index.d.mts +106 -120
  16. package/index.d.ts +106 -120
  17. package/index.d.ts.map +1 -1
  18. package/index.js +100 -45
  19. package/index.js.map +1 -1
  20. package/index.mjs +84 -44
  21. package/index.mjs.map +1 -1
  22. package/internal/decoders/jsonl.d.ts +12 -0
  23. package/internal/decoders/jsonl.d.ts.map +1 -0
  24. package/internal/decoders/jsonl.js +35 -0
  25. package/internal/decoders/jsonl.js.map +1 -0
  26. package/internal/decoders/jsonl.mjs +31 -0
  27. package/internal/decoders/jsonl.mjs.map +1 -0
  28. package/internal/decoders/line.d.ts +20 -0
  29. package/internal/decoders/line.d.ts.map +1 -0
  30. package/internal/decoders/line.js +88 -0
  31. package/internal/decoders/line.js.map +1 -0
  32. package/internal/decoders/line.mjs +84 -0
  33. package/internal/decoders/line.mjs.map +1 -0
  34. package/internal/qs/formats.d.ts +6 -0
  35. package/internal/qs/formats.d.ts.map +1 -0
  36. package/internal/qs/formats.js +11 -0
  37. package/internal/qs/formats.js.map +1 -0
  38. package/internal/qs/formats.mjs +8 -0
  39. package/internal/qs/formats.mjs.map +1 -0
  40. package/internal/qs/index.d.ts +10 -0
  41. package/internal/qs/index.d.ts.map +1 -0
  42. package/internal/qs/index.js +14 -0
  43. package/internal/qs/index.js.map +1 -0
  44. package/internal/qs/index.mjs +10 -0
  45. package/internal/qs/index.mjs.map +1 -0
  46. package/internal/qs/stringify.d.ts +3 -0
  47. package/internal/qs/stringify.d.ts.map +1 -0
  48. package/internal/qs/stringify.js +280 -0
  49. package/internal/qs/stringify.js.map +1 -0
  50. package/internal/qs/stringify.mjs +276 -0
  51. package/internal/qs/stringify.mjs.map +1 -0
  52. package/internal/qs/types.d.ts +57 -0
  53. package/internal/qs/types.d.ts.map +1 -0
  54. package/internal/qs/types.js +3 -0
  55. package/internal/qs/types.js.map +1 -0
  56. package/internal/qs/types.mjs +2 -0
  57. package/internal/qs/types.mjs.map +1 -0
  58. package/internal/qs/utils.d.ts +14 -0
  59. package/internal/qs/utils.d.ts.map +1 -0
  60. package/internal/qs/utils.js +229 -0
  61. package/internal/qs/utils.js.map +1 -0
  62. package/internal/qs/utils.mjs +217 -0
  63. package/internal/qs/utils.mjs.map +1 -0
  64. package/internal/stream-utils.d.ts +8 -0
  65. package/internal/stream-utils.d.ts.map +1 -0
  66. package/internal/stream-utils.js +39 -0
  67. package/internal/stream-utils.js.map +1 -0
  68. package/internal/stream-utils.mjs +35 -0
  69. package/internal/stream-utils.mjs.map +1 -0
  70. package/package.json +8 -6
  71. package/resources/agents/agents.d.ts +31 -187
  72. package/resources/agents/agents.d.ts.map +1 -1
  73. package/resources/agents/agents.js +15 -32
  74. package/resources/agents/agents.js.map +1 -1
  75. package/resources/agents/agents.mjs +15 -32
  76. package/resources/agents/agents.mjs.map +1 -1
  77. package/resources/agents/index.d.ts +4 -4
  78. package/resources/agents/index.d.ts.map +1 -1
  79. package/resources/agents/index.js +7 -7
  80. package/resources/agents/index.js.map +1 -1
  81. package/resources/agents/index.mjs +3 -3
  82. package/resources/agents/index.mjs.map +1 -1
  83. package/resources/agents/session.d.ts +31 -0
  84. package/resources/agents/session.d.ts.map +1 -0
  85. package/resources/agents/session.js +25 -0
  86. package/resources/agents/session.js.map +1 -0
  87. package/resources/agents/session.mjs +21 -0
  88. package/resources/agents/session.mjs.map +1 -0
  89. package/resources/agents/steps.d.ts +3 -24
  90. package/resources/agents/steps.d.ts.map +1 -1
  91. package/resources/agents/steps.js +2 -14
  92. package/resources/agents/steps.js.map +1 -1
  93. package/resources/agents/steps.mjs +2 -14
  94. package/resources/agents/steps.mjs.map +1 -1
  95. package/resources/agents/turn.d.ts +199 -0
  96. package/resources/agents/turn.d.ts.map +1 -0
  97. package/resources/agents/turn.js +19 -0
  98. package/resources/agents/turn.js.map +1 -0
  99. package/resources/agents/turn.mjs +15 -0
  100. package/resources/agents/turn.mjs.map +1 -0
  101. package/resources/batch-inference.d.ts +23 -56
  102. package/resources/batch-inference.d.ts.map +1 -1
  103. package/resources/batch-inference.js +4 -26
  104. package/resources/batch-inference.js.map +1 -1
  105. package/resources/batch-inference.mjs +4 -26
  106. package/resources/batch-inference.mjs.map +1 -1
  107. package/resources/datasetio.d.ts +25 -0
  108. package/resources/datasetio.d.ts.map +1 -0
  109. package/resources/datasetio.js +19 -0
  110. package/resources/datasetio.js.map +1 -0
  111. package/resources/datasetio.mjs +15 -0
  112. package/resources/datasetio.mjs.map +1 -0
  113. package/resources/datasets.d.ts +34 -46
  114. package/resources/datasets.d.ts.map +1 -1
  115. package/resources/datasets.js +11 -35
  116. package/resources/datasets.js.map +1 -1
  117. package/resources/datasets.mjs +11 -35
  118. package/resources/datasets.mjs.map +1 -1
  119. package/resources/eval/eval.d.ts +62 -0
  120. package/resources/eval/eval.d.ts.map +1 -0
  121. package/resources/{inference/embeddings.js → eval/eval.js} +16 -20
  122. package/resources/eval/eval.js.map +1 -0
  123. package/resources/eval/eval.mjs +18 -0
  124. package/resources/eval/eval.mjs.map +1 -0
  125. package/resources/eval/index.d.ts +3 -0
  126. package/resources/eval/index.d.ts.map +1 -0
  127. package/resources/eval/index.js +9 -0
  128. package/resources/eval/index.js.map +1 -0
  129. package/resources/eval/index.mjs +4 -0
  130. package/resources/eval/index.mjs.map +1 -0
  131. package/resources/eval/jobs.d.ts +13 -0
  132. package/resources/eval/jobs.d.ts.map +1 -0
  133. package/resources/eval/jobs.js +21 -0
  134. package/resources/eval/jobs.js.map +1 -0
  135. package/resources/eval/jobs.mjs +17 -0
  136. package/resources/eval/jobs.mjs.map +1 -0
  137. package/resources/eval-tasks.d.ts +32 -0
  138. package/resources/eval-tasks.d.ts.map +1 -0
  139. package/resources/eval-tasks.js +22 -0
  140. package/resources/eval-tasks.js.map +1 -0
  141. package/resources/eval-tasks.mjs +18 -0
  142. package/resources/eval-tasks.mjs.map +1 -0
  143. package/resources/index.d.ts +23 -15
  144. package/resources/index.d.ts.map +1 -1
  145. package/resources/index.js +33 -17
  146. package/resources/index.js.map +1 -1
  147. package/resources/index.mjs +19 -11
  148. package/resources/index.mjs.map +1 -1
  149. package/resources/inference.d.ts +286 -0
  150. package/resources/inference.d.ts.map +1 -0
  151. package/resources/inference.js +29 -0
  152. package/resources/inference.js.map +1 -0
  153. package/resources/inference.mjs +25 -0
  154. package/resources/inference.mjs.map +1 -0
  155. package/resources/inspect.d.ts +26 -0
  156. package/resources/inspect.d.ts.map +1 -0
  157. package/resources/inspect.js +15 -0
  158. package/resources/inspect.js.map +1 -0
  159. package/resources/inspect.mjs +11 -0
  160. package/resources/inspect.mjs.map +1 -0
  161. package/resources/models.d.ts +21 -36
  162. package/resources/models.d.ts.map +1 -1
  163. package/resources/models.js +11 -27
  164. package/resources/models.js.map +1 -1
  165. package/resources/models.mjs +11 -27
  166. package/resources/models.mjs.map +1 -1
  167. package/resources/post-training/index.d.ts +2 -2
  168. package/resources/post-training/index.d.ts.map +1 -1
  169. package/resources/post-training/index.js +3 -3
  170. package/resources/post-training/index.js.map +1 -1
  171. package/resources/post-training/index.mjs +1 -1
  172. package/resources/post-training/index.mjs.map +1 -1
  173. package/resources/post-training/job.d.ts +47 -0
  174. package/resources/post-training/job.d.ts.map +1 -0
  175. package/resources/post-training/job.js +25 -0
  176. package/resources/post-training/job.js.map +1 -0
  177. package/resources/post-training/job.mjs +21 -0
  178. package/resources/post-training/job.mjs.map +1 -0
  179. package/resources/post-training/post-training.d.ts +95 -142
  180. package/resources/post-training/post-training.d.ts.map +1 -1
  181. package/resources/post-training/post-training.js +8 -29
  182. package/resources/post-training/post-training.js.map +1 -1
  183. package/resources/post-training/post-training.mjs +8 -29
  184. package/resources/post-training/post-training.mjs.map +1 -1
  185. package/resources/providers.d.ts +14 -0
  186. package/resources/providers.d.ts.map +1 -0
  187. package/resources/providers.js +12 -0
  188. package/resources/providers.js.map +1 -0
  189. package/resources/providers.mjs +8 -0
  190. package/resources/providers.mjs.map +1 -0
  191. package/resources/routes.d.ts +14 -0
  192. package/resources/routes.d.ts.map +1 -0
  193. package/resources/routes.js +12 -0
  194. package/resources/routes.js.map +1 -0
  195. package/resources/routes.mjs +8 -0
  196. package/resources/routes.mjs.map +1 -0
  197. package/resources/safety.d.ts +6 -29
  198. package/resources/safety.d.ts.map +1 -1
  199. package/resources/safety.js +2 -14
  200. package/resources/safety.js.map +1 -1
  201. package/resources/safety.mjs +2 -14
  202. package/resources/safety.mjs.map +1 -1
  203. package/resources/scoring-functions.d.ts +53 -0
  204. package/resources/scoring-functions.d.ts.map +1 -0
  205. package/resources/scoring-functions.js +22 -0
  206. package/resources/scoring-functions.js.map +1 -0
  207. package/resources/scoring-functions.mjs +18 -0
  208. package/resources/scoring-functions.mjs.map +1 -0
  209. package/resources/scoring.d.ts +28 -0
  210. package/resources/scoring.d.ts.map +1 -0
  211. package/resources/scoring.js +15 -0
  212. package/resources/scoring.js.map +1 -0
  213. package/resources/scoring.mjs +11 -0
  214. package/resources/scoring.mjs.map +1 -0
  215. package/resources/shared.d.ts +406 -14
  216. package/resources/shared.d.ts.map +1 -1
  217. package/resources/shields.d.ts +21 -32
  218. package/resources/shields.d.ts.map +1 -1
  219. package/resources/shields.js +7 -29
  220. package/resources/shields.js.map +1 -1
  221. package/resources/shields.mjs +7 -29
  222. package/resources/shields.mjs.map +1 -1
  223. package/resources/synthetic-data-generation.d.ts +12 -22
  224. package/resources/synthetic-data-generation.d.ts.map +1 -1
  225. package/resources/synthetic-data-generation.js +5 -17
  226. package/resources/synthetic-data-generation.js.map +1 -1
  227. package/resources/synthetic-data-generation.mjs +3 -15
  228. package/resources/synthetic-data-generation.mjs.map +1 -1
  229. package/resources/telemetry.d.ts +84 -35
  230. package/resources/telemetry.d.ts.map +1 -1
  231. package/resources/telemetry.js +29 -22
  232. package/resources/telemetry.js.map +1 -1
  233. package/resources/telemetry.mjs +29 -22
  234. package/resources/telemetry.mjs.map +1 -1
  235. package/resources/tool-runtime/index.d.ts +3 -0
  236. package/resources/tool-runtime/index.d.ts.map +1 -0
  237. package/resources/tool-runtime/index.js +9 -0
  238. package/resources/tool-runtime/index.js.map +1 -0
  239. package/resources/tool-runtime/index.mjs +4 -0
  240. package/resources/tool-runtime/index.mjs.map +1 -0
  241. package/resources/tool-runtime/rag-tool.d.ts +30 -0
  242. package/resources/tool-runtime/rag-tool.d.ts.map +1 -0
  243. package/resources/tool-runtime/rag-tool.js +25 -0
  244. package/resources/tool-runtime/rag-tool.js.map +1 -0
  245. package/resources/tool-runtime/rag-tool.mjs +21 -0
  246. package/resources/tool-runtime/rag-tool.mjs.map +1 -0
  247. package/resources/tool-runtime/tool-runtime.d.ts +51 -0
  248. package/resources/tool-runtime/tool-runtime.d.ts.map +1 -0
  249. package/resources/{evaluate/evaluate.js → tool-runtime/tool-runtime.js} +29 -18
  250. package/resources/tool-runtime/tool-runtime.js.map +1 -0
  251. package/resources/tool-runtime/tool-runtime.mjs +33 -0
  252. package/resources/tool-runtime/tool-runtime.mjs.map +1 -0
  253. package/resources/toolgroups.d.ts +40 -0
  254. package/resources/toolgroups.d.ts.map +1 -0
  255. package/resources/toolgroups.js +37 -0
  256. package/resources/toolgroups.js.map +1 -0
  257. package/resources/toolgroups.mjs +33 -0
  258. package/resources/toolgroups.mjs.map +1 -0
  259. package/resources/tools.d.ts +41 -0
  260. package/resources/tools.d.ts.map +1 -0
  261. package/resources/tools.js +19 -0
  262. package/resources/tools.js.map +1 -0
  263. package/resources/tools.mjs +15 -0
  264. package/resources/tools.mjs.map +1 -0
  265. package/resources/vector-dbs.d.ts +49 -0
  266. package/resources/vector-dbs.d.ts.map +1 -0
  267. package/resources/vector-dbs.js +24 -0
  268. package/resources/vector-dbs.js.map +1 -0
  269. package/resources/vector-dbs.mjs +20 -0
  270. package/resources/vector-dbs.mjs.map +1 -0
  271. package/resources/vector-io.d.ts +46 -0
  272. package/resources/vector-io.d.ts.map +1 -0
  273. package/resources/vector-io.js +19 -0
  274. package/resources/vector-io.js.map +1 -0
  275. package/resources/vector-io.mjs +15 -0
  276. package/resources/vector-io.mjs.map +1 -0
  277. package/src/core.ts +57 -27
  278. package/src/error.ts +25 -41
  279. package/src/index.ts +457 -153
  280. package/src/internal/decoders/jsonl.ts +41 -0
  281. package/src/internal/decoders/line.ts +114 -0
  282. package/src/internal/qs/LICENSE.md +13 -0
  283. package/src/internal/qs/README.md +3 -0
  284. package/src/internal/qs/formats.ts +9 -0
  285. package/src/internal/qs/index.ts +13 -0
  286. package/src/internal/qs/stringify.ts +388 -0
  287. package/src/internal/qs/types.ts +71 -0
  288. package/src/internal/qs/utils.ts +265 -0
  289. package/src/internal/stream-utils.ts +32 -0
  290. package/src/resources/agents/agents.ts +81 -299
  291. package/src/resources/agents/index.ts +24 -27
  292. package/src/resources/agents/session.ts +76 -0
  293. package/src/resources/agents/steps.ts +14 -40
  294. package/src/resources/agents/turn.ts +322 -0
  295. package/src/resources/batch-inference.ts +33 -84
  296. package/src/resources/datasetio.ts +53 -0
  297. package/src/resources/datasets.ts +70 -82
  298. package/src/resources/eval/eval.ts +107 -0
  299. package/src/resources/eval/index.ts +12 -0
  300. package/src/resources/eval/jobs.ts +36 -0
  301. package/src/resources/eval-tasks.ts +69 -0
  302. package/src/resources/index.ts +141 -65
  303. package/src/resources/inference.ts +395 -0
  304. package/src/resources/inspect.ts +47 -0
  305. package/src/resources/models.ts +46 -66
  306. package/src/resources/post-training/index.ts +14 -14
  307. package/src/resources/post-training/job.ts +96 -0
  308. package/src/resources/post-training/post-training.ts +151 -182
  309. package/src/resources/providers.ts +26 -0
  310. package/src/resources/routes.ts +23 -0
  311. package/src/resources/safety.ts +8 -47
  312. package/src/resources/scoring-functions.ts +108 -0
  313. package/src/resources/scoring.ts +52 -0
  314. package/src/resources/shared.ts +530 -14
  315. package/src/resources/shields.ts +40 -64
  316. package/src/resources/synthetic-data-generation.ts +17 -37
  317. package/src/resources/telemetry.ts +211 -65
  318. package/src/resources/tool-runtime/index.ts +10 -0
  319. package/src/resources/tool-runtime/rag-tool.ts +48 -0
  320. package/src/resources/tool-runtime/tool-runtime.ts +109 -0
  321. package/src/resources/toolgroups.ts +80 -0
  322. package/src/resources/tools.ts +81 -0
  323. package/src/resources/vector-dbs.ts +105 -0
  324. package/src/resources/vector-io.ts +74 -0
  325. package/src/streaming.ts +6 -148
  326. package/src/version.ts +1 -1
  327. package/streaming.d.ts +0 -7
  328. package/streaming.d.ts.map +1 -1
  329. package/streaming.js +8 -123
  330. package/streaming.js.map +1 -1
  331. package/streaming.mjs +4 -118
  332. package/streaming.mjs.map +1 -1
  333. package/version.d.ts +1 -1
  334. package/version.d.ts.map +1 -1
  335. package/version.js +1 -1
  336. package/version.js.map +1 -1
  337. package/version.mjs +1 -1
  338. package/version.mjs.map +1 -1
  339. package/resources/agents/sessions.d.ts +0 -76
  340. package/resources/agents/sessions.d.ts.map +0 -1
  341. package/resources/agents/sessions.js +0 -52
  342. package/resources/agents/sessions.js.map +0 -1
  343. package/resources/agents/sessions.mjs +0 -48
  344. package/resources/agents/sessions.mjs.map +0 -1
  345. package/resources/agents/turns.d.ts +0 -133
  346. package/resources/agents/turns.d.ts.map +0 -1
  347. package/resources/agents/turns.js +0 -38
  348. package/resources/agents/turns.js.map +0 -1
  349. package/resources/agents/turns.mjs +0 -34
  350. package/resources/agents/turns.mjs.map +0 -1
  351. package/resources/evaluate/evaluate.d.ts +0 -29
  352. package/resources/evaluate/evaluate.d.ts.map +0 -1
  353. package/resources/evaluate/evaluate.js.map +0 -1
  354. package/resources/evaluate/evaluate.mjs +0 -22
  355. package/resources/evaluate/evaluate.mjs.map +0 -1
  356. package/resources/evaluate/index.d.ts +0 -6
  357. package/resources/evaluate/index.d.ts.map +0 -1
  358. package/resources/evaluate/index.js +0 -15
  359. package/resources/evaluate/index.js.map +0 -1
  360. package/resources/evaluate/index.mjs +0 -7
  361. package/resources/evaluate/index.mjs.map +0 -1
  362. package/resources/evaluate/jobs/artifacts.d.ts +0 -22
  363. package/resources/evaluate/jobs/artifacts.d.ts.map +0 -1
  364. package/resources/evaluate/jobs/artifacts.js +0 -24
  365. package/resources/evaluate/jobs/artifacts.js.map +0 -1
  366. package/resources/evaluate/jobs/artifacts.mjs +0 -20
  367. package/resources/evaluate/jobs/artifacts.mjs.map +0 -1
  368. package/resources/evaluate/jobs/index.d.ts +0 -5
  369. package/resources/evaluate/jobs/index.d.ts.map +0 -1
  370. package/resources/evaluate/jobs/index.js +0 -13
  371. package/resources/evaluate/jobs/index.js.map +0 -1
  372. package/resources/evaluate/jobs/index.mjs +0 -6
  373. package/resources/evaluate/jobs/index.mjs.map +0 -1
  374. package/resources/evaluate/jobs/jobs.d.ts +0 -56
  375. package/resources/evaluate/jobs/jobs.d.ts.map +0 -1
  376. package/resources/evaluate/jobs/jobs.js +0 -76
  377. package/resources/evaluate/jobs/jobs.js.map +0 -1
  378. package/resources/evaluate/jobs/jobs.mjs +0 -49
  379. package/resources/evaluate/jobs/jobs.mjs.map +0 -1
  380. package/resources/evaluate/jobs/logs.d.ts +0 -22
  381. package/resources/evaluate/jobs/logs.d.ts.map +0 -1
  382. package/resources/evaluate/jobs/logs.js +0 -24
  383. package/resources/evaluate/jobs/logs.js.map +0 -1
  384. package/resources/evaluate/jobs/logs.mjs +0 -20
  385. package/resources/evaluate/jobs/logs.mjs.map +0 -1
  386. package/resources/evaluate/jobs/status.d.ts +0 -22
  387. package/resources/evaluate/jobs/status.d.ts.map +0 -1
  388. package/resources/evaluate/jobs/status.js +0 -24
  389. package/resources/evaluate/jobs/status.js.map +0 -1
  390. package/resources/evaluate/jobs/status.mjs +0 -20
  391. package/resources/evaluate/jobs/status.mjs.map +0 -1
  392. package/resources/evaluate/question-answering.d.ts +0 -22
  393. package/resources/evaluate/question-answering.d.ts.map +0 -1
  394. package/resources/evaluate/question-answering.js +0 -24
  395. package/resources/evaluate/question-answering.js.map +0 -1
  396. package/resources/evaluate/question-answering.mjs +0 -20
  397. package/resources/evaluate/question-answering.mjs.map +0 -1
  398. package/resources/evaluate/summarization.d.ts +0 -4
  399. package/resources/evaluate/summarization.d.ts.map +0 -1
  400. package/resources/evaluate/summarization.js +0 -9
  401. package/resources/evaluate/summarization.js.map +0 -1
  402. package/resources/evaluate/summarization.mjs +0 -5
  403. package/resources/evaluate/summarization.mjs.map +0 -1
  404. package/resources/evaluate/text-generation.d.ts +0 -4
  405. package/resources/evaluate/text-generation.d.ts.map +0 -1
  406. package/resources/evaluate/text-generation.js +0 -9
  407. package/resources/evaluate/text-generation.js.map +0 -1
  408. package/resources/evaluate/text-generation.mjs +0 -5
  409. package/resources/evaluate/text-generation.mjs.map +0 -1
  410. package/resources/evaluations.d.ts +0 -35
  411. package/resources/evaluations.d.ts.map +0 -1
  412. package/resources/evaluations.js +0 -37
  413. package/resources/evaluations.js.map +0 -1
  414. package/resources/evaluations.mjs +0 -33
  415. package/resources/evaluations.mjs.map +0 -1
  416. package/resources/inference/embeddings.d.ts +0 -29
  417. package/resources/inference/embeddings.d.ts.map +0 -1
  418. package/resources/inference/embeddings.js.map +0 -1
  419. package/resources/inference/embeddings.mjs +0 -22
  420. package/resources/inference/embeddings.mjs.map +0 -1
  421. package/resources/inference/index.d.ts +0 -3
  422. package/resources/inference/index.d.ts.map +0 -1
  423. package/resources/inference/index.js +0 -9
  424. package/resources/inference/index.js.map +0 -1
  425. package/resources/inference/index.mjs +0 -4
  426. package/resources/inference/index.mjs.map +0 -1
  427. package/resources/inference/inference.d.ts +0 -172
  428. package/resources/inference/inference.d.ts.map +0 -1
  429. package/resources/inference/inference.js +0 -67
  430. package/resources/inference/inference.js.map +0 -1
  431. package/resources/inference/inference.mjs +0 -40
  432. package/resources/inference/inference.mjs.map +0 -1
  433. package/resources/memory/documents.d.ts +0 -49
  434. package/resources/memory/documents.d.ts.map +0 -1
  435. package/resources/memory/documents.js +0 -39
  436. package/resources/memory/documents.js.map +0 -1
  437. package/resources/memory/documents.mjs +0 -35
  438. package/resources/memory/documents.mjs.map +0 -1
  439. package/resources/memory/index.d.ts +0 -3
  440. package/resources/memory/index.d.ts.map +0 -1
  441. package/resources/memory/index.js +0 -9
  442. package/resources/memory/index.js.map +0 -1
  443. package/resources/memory/index.mjs +0 -4
  444. package/resources/memory/index.mjs.map +0 -1
  445. package/resources/memory/memory.d.ts +0 -158
  446. package/resources/memory/memory.d.ts.map +0 -1
  447. package/resources/memory/memory.js +0 -137
  448. package/resources/memory/memory.js.map +0 -1
  449. package/resources/memory/memory.mjs +0 -110
  450. package/resources/memory/memory.mjs.map +0 -1
  451. package/resources/memory-banks.d.ts +0 -42
  452. package/resources/memory-banks.d.ts.map +0 -1
  453. package/resources/memory-banks.js +0 -40
  454. package/resources/memory-banks.js.map +0 -1
  455. package/resources/memory-banks.mjs +0 -36
  456. package/resources/memory-banks.mjs.map +0 -1
  457. package/resources/post-training/jobs.d.ts +0 -91
  458. package/resources/post-training/jobs.d.ts.map +0 -1
  459. package/resources/post-training/jobs.js +0 -80
  460. package/resources/post-training/jobs.js.map +0 -1
  461. package/resources/post-training/jobs.mjs +0 -76
  462. package/resources/post-training/jobs.mjs.map +0 -1
  463. package/resources/reward-scoring.d.ts +0 -47
  464. package/resources/reward-scoring.d.ts.map +0 -1
  465. package/resources/reward-scoring.js +0 -24
  466. package/resources/reward-scoring.js.map +0 -1
  467. package/resources/reward-scoring.mjs +0 -20
  468. package/resources/reward-scoring.mjs.map +0 -1
  469. package/src/resources/agents/sessions.ts +0 -135
  470. package/src/resources/agents/turns.ts +0 -231
  471. package/src/resources/evaluate/evaluate.ts +0 -35
  472. package/src/resources/evaluate/index.ts +0 -14
  473. package/src/resources/evaluate/jobs/artifacts.ts +0 -42
  474. package/src/resources/evaluate/jobs/index.ts +0 -13
  475. package/src/resources/evaluate/jobs/jobs.ts +0 -99
  476. package/src/resources/evaluate/jobs/logs.ts +0 -42
  477. package/src/resources/evaluate/jobs/status.ts +0 -42
  478. package/src/resources/evaluate/question-answering.ts +0 -42
  479. package/src/resources/evaluate/summarization.ts +0 -5
  480. package/src/resources/evaluate/text-generation.ts +0 -5
  481. package/src/resources/evaluations.ts +0 -73
  482. package/src/resources/inference/embeddings.ts +0 -48
  483. package/src/resources/inference/index.ts +0 -15
  484. package/src/resources/inference/inference.ts +0 -268
  485. package/src/resources/memory/documents.ts +0 -92
  486. package/src/resources/memory/index.ts +0 -23
  487. package/src/resources/memory/memory.ts +0 -297
  488. package/src/resources/memory-banks.ts +0 -84
  489. package/src/resources/post-training/jobs.ts +0 -192
  490. package/src/resources/reward-scoring.ts +0 -82
package/LICENSE CHANGED
@@ -1,201 +1,22 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2024 Llama Stack Client
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ MIT License
2
+
3
+ Copyright (c) Meta Platforms, Inc. and affiliates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # Llama Stack Client Node API Library
1
+ # Llama Stack Client TypeScript and JavaScript API Library
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/llama-stack-client.svg)](https://npmjs.org/package/llama-stack-client) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/llama-stack-client)
3
+ [![NPM version](https://img.shields.io/npm/v/llama-stack-client.svg)](https://npmjs.org/package/llama-stack-client) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/llama-stack-client) [![Discord](https://img.shields.io/discord/1257833999603335178)](https://discord.gg/llama-stack)
4
4
 
5
5
  This library provides convenient access to the Llama Stack Client REST API from server-side TypeScript or JavaScript.
6
6
 
7
- The REST API documentation can be found on [llama-stack](https://github.com/meta-llama/llama-stack/blob/main/docs/resources/llama-stack-spec.html). The full API of this library can be found in [api.md](api.md).
7
+ The REST API documentation can be found on [https://llama-stack.readthedocs.io/en/latest/references/api_reference/index.html](https://llama-stack.readthedocs.io/en/latest/references/api_reference/index.html). The full API of this library can be found in [api.md](api.md).
8
8
 
9
9
  It is generated with [Stainless](https://www.stainlessapi.com/).
10
10
 
@@ -14,7 +14,6 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
14
14
  npm install llama-stack-client
15
15
  ```
16
16
 
17
-
18
17
  ## Usage
19
18
 
20
19
  The full API of this library can be found in [api.md](api.md).
@@ -24,18 +23,40 @@ The full API of this library can be found in [api.md](api.md).
24
23
  import LlamaStackClient from 'llama-stack-client';
25
24
 
26
25
  const client = new LlamaStackClient({
27
- environment: 'sandbox', // defaults to 'production'
26
+ baseURL: 'http://localhost:8321'
28
27
  });
29
28
 
30
29
  async function main() {
31
- const session = await client.agents.sessions.create({ agent_id: 'agent_id', session_name: 'session_name' });
30
+ const models = await client.models.list();
32
31
 
33
- console.log(session.session_id);
32
+ console.log(models);
34
33
  }
35
34
 
36
35
  main();
37
36
  ```
38
37
 
38
+ ## Streaming responses
39
+
40
+ We provide support for streaming responses using Server Sent Events (SSE).
41
+
42
+ ```ts
43
+ import LlamaStackClient from 'llama-stack-client';
44
+
45
+ const client = new LlamaStackClient();
46
+
47
+ const stream = await client.inference.chatCompletion({
48
+ messages: [{ content: 'string', role: 'user' }],
49
+ model_id: 'meta-llama/Llama-3.2-3B-Instruct',
50
+ stream: true,
51
+ });
52
+ for await (const inferenceChatCompletionResponse of stream) {
53
+ process.stdout.write(inferenceChatCompletionResponse.event.delta.text || '');
54
+ }
55
+ ```
56
+
57
+ If you need to cancel a stream, you can `break` from the loop
58
+ or call `stream.controller.abort()`.
59
+
39
60
  ### Request & Response types
40
61
 
41
62
  This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
@@ -44,16 +65,16 @@ This library includes TypeScript definitions for all request params and response
44
65
  ```ts
45
66
  import LlamaStackClient from 'llama-stack-client';
46
67
 
47
- const client = new LlamaStackClient({
48
- environment: 'sandbox', // defaults to 'production'
49
- });
68
+ const client = new LlamaStackClient();
50
69
 
51
70
  async function main() {
52
- const params: LlamaStackClient.Agents.SessionCreateParams = {
53
- agent_id: 'agent_id',
54
- session_name: 'session_name',
71
+ const params: LlamaStackClient.InferenceChatCompletionParams = {
72
+ messages: [{ content: 'string', role: 'user' }],
73
+ model_id: 'model_id',
55
74
  };
56
- const session: LlamaStackClient.Agents.SessionCreateResponse = await client.agents.sessions.create(params);
75
+ const response: LlamaStackClient.InferenceChatCompletionResponse = await client.inference.chatCompletion(
76
+ params,
77
+ );
57
78
  }
58
79
 
59
80
  main();
@@ -70,8 +91,8 @@ a subclass of `APIError` will be thrown:
70
91
  <!-- prettier-ignore -->
71
92
  ```ts
72
93
  async function main() {
73
- const session = await client.agents.sessions
74
- .create({ agent_id: 'agent_id', session_name: 'session_name' })
94
+ const response = await client.inference
95
+ .chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' })
75
96
  .catch(async (err) => {
76
97
  if (err instanceof LlamaStackClient.APIError) {
77
98
  console.log(err.status); // 400
@@ -115,7 +136,7 @@ const client = new LlamaStackClient({
115
136
  });
116
137
 
117
138
  // Or, configure per-request:
118
- await client.agents.sessions.create({ agent_id: 'agent_id', session_name: 'session_name' }, {
139
+ await client.inference.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' }, {
119
140
  maxRetries: 5,
120
141
  });
121
142
  ```
@@ -132,7 +153,7 @@ const client = new LlamaStackClient({
132
153
  });
133
154
 
134
155
  // Override per-request:
135
- await client.agents.sessions.create({ agent_id: 'agent_id', session_name: 'session_name' }, {
156
+ await client.inference.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' }, {
136
157
  timeout: 5 * 1000,
137
158
  });
138
159
  ```
@@ -153,17 +174,17 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
153
174
  ```ts
154
175
  const client = new LlamaStackClient();
155
176
 
156
- const response = await client.agents.sessions
157
- .create({ agent_id: 'agent_id', session_name: 'session_name' })
177
+ const response = await client.inference
178
+ .chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' })
158
179
  .asResponse();
159
180
  console.log(response.headers.get('X-My-Header'));
160
181
  console.log(response.statusText); // access the underlying Response object
161
182
 
162
- const { data: session, response: raw } = await client.agents.sessions
163
- .create({ agent_id: 'agent_id', session_name: 'session_name' })
183
+ const { data: response, response: raw } = await client.inference
184
+ .chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' })
164
185
  .withResponse();
165
186
  console.log(raw.headers.get('X-My-Header'));
166
- console.log(session.session_id);
187
+ console.log(response);
167
188
  ```
168
189
 
169
190
  ### Making custom/undocumented requests
@@ -267,8 +288,8 @@ const client = new LlamaStackClient({
267
288
  });
268
289
 
269
290
  // Override per-request:
270
- await client.agents.sessions.create(
271
- { agent_id: 'agent_id', session_name: 'session_name' },
291
+ await client.inference.chatCompletion(
292
+ { messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' },
272
293
  {
273
294
  httpAgent: new http.Agent({ keepAlive: false }),
274
295
  },
@@ -280,7 +301,7 @@ await client.agents.sessions.create(
280
301
  This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
281
302
 
282
303
  1. Changes that only affect static types, without breaking runtime behavior.
283
- 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
304
+ 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
284
305
  3. Changes that we do not expect to impact the vast majority of users in practice.
285
306
 
286
307
  We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
@@ -293,6 +314,19 @@ TypeScript >= 4.5 is supported.
293
314
 
294
315
  The following runtimes are supported:
295
316
 
317
+ - Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
318
+ - Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
319
+ - Deno v1.28.0 or higher.
320
+ - Bun 1.0 or later.
321
+ - Cloudflare Workers.
322
+ - Vercel Edge Runtime.
323
+ - Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
324
+ - Nitro v2.6 or greater.
325
+
296
326
  Note that React Native is not supported at this time.
297
327
 
298
328
  If you are interested in other runtime environments, please open or upvote an issue on GitHub.
329
+
330
+ ## Contributing
331
+
332
+ See [the contributing documentation](./CONTRIBUTING.md).
package/core.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare class APIPromise<T> extends Promise<T> {
22
22
  private parseResponse;
23
23
  private parsedPromise;
24
24
  constructor(responsePromise: Promise<APIResponseProps>, parseResponse?: (props: APIResponseProps) => PromiseOrValue<T>);
25
- _thenUnwrap<U>(transform: (data: T) => U): APIPromise<U>;
25
+ _thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
26
26
  /**
27
27
  * Gets the raw `Response` instance instead of parsing the response
28
28
  * data.
@@ -67,7 +67,7 @@ export declare abstract class APIClient {
67
67
  private fetch;
68
68
  protected idempotencyHeader?: string;
69
69
  constructor({ baseURL, maxRetries, timeout, // 1 minute
70
- httpAgent, fetch: overridenFetch, }: {
70
+ httpAgent, fetch: overriddenFetch, }: {
71
71
  baseURL: string;
72
72
  maxRetries?: number | undefined;
73
73
  timeout: number | undefined;
@@ -128,7 +128,6 @@ export declare abstract class APIClient {
128
128
  buildURL<Req>(path: string, query: Req | null | undefined): string;
129
129
  protected stringifyQuery(query: Record<string, unknown>): string;
130
130
  fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
131
- protected getRequestClient(): RequestClient;
132
131
  private shouldRetry;
133
132
  private retryRequest;
134
133
  private calculateDefaultRetryTimeoutMillis;
@@ -153,8 +152,8 @@ export declare abstract class AbstractPage<Item> implements AsyncIterable<Item>
153
152
  abstract getPaginatedItems(): Item[];
154
153
  hasNextPage(): boolean;
155
154
  getNextPage(): Promise<this>;
156
- iterPages(): AsyncGenerator<AbstractPage<Item>, void, unknown>;
157
- [Symbol.asyncIterator](): AsyncGenerator<Awaited<Item>, void, unknown>;
155
+ iterPages(): AsyncGenerator<this>;
156
+ [Symbol.asyncIterator](): AsyncGenerator<Item>;
158
157
  }
159
158
  /**
160
159
  * This subclass of Promise will resolve to an instantiated Page once the request completes.
@@ -174,7 +173,7 @@ export declare class PagePromise<PageClass extends AbstractPage<Item>, Item = Re
174
173
  * console.log(item)
175
174
  * }
176
175
  */
177
- [Symbol.asyncIterator](): AsyncGenerator<Awaited<Item>, void, unknown>;
176
+ [Symbol.asyncIterator](): AsyncGenerator<Item>;
178
177
  }
179
178
  export declare const createResponseHeaders: (headers: Awaited<ReturnType<Fetch>>['headers']) => Record<string, string>;
180
179
  type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
@@ -234,7 +233,8 @@ export interface HeadersProtocol {
234
233
  }
235
234
  export type HeadersLike = Record<string, string | string[] | undefined> | HeadersProtocol;
236
235
  export declare const isHeadersProtocol: (headers: any) => headers is HeadersProtocol;
237
- export declare const getRequiredHeader: (headers: HeadersLike, header: string) => string;
236
+ export declare const getRequiredHeader: (headers: HeadersLike | Headers, header: string) => string;
237
+ export declare const getHeader: (headers: HeadersLike | Headers, header: string) => string | undefined;
238
238
  /**
239
239
  * Encodes a string to Base64 format.
240
240
  */
package/core.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["src/core.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAEL,QAAQ,EAIT,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,KAAK,EAEV,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;AACzB,OAAO,EAAE,QAAQ,EAA+B,MAAM,WAAW,CAAC;AAClE,OAAO,EACL,gCAAgC,EAChC,2BAA2B,EAC3B,UAAU,EACV,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEhF,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAExC,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AA4CF;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAIzC,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,aAAa;IAJvB,OAAO,CAAC,aAAa,CAAyB;gBAGpC,eAAe,EAAE,OAAO,CAAC,gBAAgB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IAAI,GAAG,SAAS,KAAG,MAWzD,CAAC;AAEF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElE"}
package/core.js CHANGED
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  };
13
13
  var _AbstractPage_client;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.isObj = exports.toBase64 = exports.getRequiredHeader = exports.isHeadersProtocol = exports.isRunningInBrowser = exports.debug = exports.hasOwn = exports.isEmptyObj = exports.maybeCoerceBoolean = exports.maybeCoerceFloat = exports.maybeCoerceInteger = exports.coerceBoolean = exports.coerceFloat = exports.coerceInteger = exports.readEnv = exports.ensurePresent = exports.castToError = exports.sleep = exports.safeJSON = exports.isRequestOptions = exports.createResponseHeaders = exports.PagePromise = exports.AbstractPage = exports.APIClient = exports.APIPromise = exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = void 0;
15
+ exports.isObj = exports.toBase64 = exports.getHeader = exports.getRequiredHeader = exports.isHeadersProtocol = exports.isRunningInBrowser = exports.debug = exports.hasOwn = exports.isEmptyObj = exports.maybeCoerceBoolean = exports.maybeCoerceFloat = exports.maybeCoerceInteger = exports.coerceBoolean = exports.coerceFloat = exports.coerceInteger = exports.readEnv = exports.ensurePresent = exports.castToError = exports.sleep = exports.safeJSON = exports.isRequestOptions = exports.createResponseHeaders = exports.PagePromise = exports.AbstractPage = exports.APIClient = exports.APIPromise = exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = void 0;
16
16
  const version_1 = require("./version.js");
17
17
  const streaming_1 = require("./streaming.js");
18
18
  const error_1 = require("./error.js");
@@ -68,7 +68,7 @@ class APIPromise extends Promise {
68
68
  this.parseResponse = parseResponse;
69
69
  }
70
70
  _thenUnwrap(transform) {
71
- return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props)));
71
+ return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props), props));
72
72
  }
73
73
  /**
74
74
  * Gets the raw `Response` instance instead of parsing the response
@@ -122,12 +122,12 @@ class APIPromise extends Promise {
122
122
  exports.APIPromise = APIPromise;
123
123
  class APIClient {
124
124
  constructor({ baseURL, maxRetries = 2, timeout = 60000, // 1 minute
125
- httpAgent, fetch: overridenFetch, }) {
125
+ httpAgent, fetch: overriddenFetch, }) {
126
126
  this.baseURL = baseURL;
127
127
  this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
128
128
  this.timeout = validatePositiveInteger('timeout', timeout);
129
129
  this.httpAgent = httpAgent;
130
- this.fetch = overridenFetch ?? index_1.fetch;
130
+ this.fetch = overriddenFetch ?? index_1.fetch;
131
131
  }
132
132
  authHeaders(opts) {
133
133
  return {};
@@ -201,6 +201,7 @@ class APIClient {
201
201
  return null;
202
202
  }
203
203
  buildRequest(options, { retryCount = 0 } = {}) {
204
+ options = { ...options };
204
205
  const { method, path, query, headers: headers = {} } = options;
205
206
  const body = ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
206
207
  options.body
@@ -211,9 +212,9 @@ class APIClient {
211
212
  const url = this.buildURL(path, query);
212
213
  if ('timeout' in options)
213
214
  validatePositiveInteger('timeout', options.timeout);
214
- const timeout = options.timeout ?? this.timeout;
215
+ options.timeout = options.timeout ?? this.timeout;
215
216
  const httpAgent = options.httpAgent ?? this.httpAgent ?? (0, index_1.getDefaultAgent)(url);
216
- const minAgentTimeout = timeout + 1000;
217
+ const minAgentTimeout = options.timeout + 1000;
217
218
  if (typeof httpAgent?.options?.timeout === 'number' &&
218
219
  minAgentTimeout > (httpAgent.options.timeout ?? 0)) {
219
220
  // Allow any given request to bump our agent active socket timeout.
@@ -237,7 +238,7 @@ class APIClient {
237
238
  // not compatible with standard web types
238
239
  signal: options.signal ?? null,
239
240
  };
240
- return { req, url, timeout };
241
+ return { req, url, timeout: options.timeout };
241
242
  }
242
243
  buildHeaders({ options, headers, contentLength, retryCount, }) {
243
244
  const reqHeaders = {};
@@ -251,7 +252,18 @@ class APIClient {
251
252
  if ((0, uploads_1.isMultipartBody)(options.body) && index_1.kind !== 'node') {
252
253
  delete reqHeaders['content-type'];
253
254
  }
254
- reqHeaders['x-stainless-retry-count'] = String(retryCount);
255
+ // Don't set theses headers if they were already set or removed through default headers or by the caller.
256
+ // We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account
257
+ // for the removal case.
258
+ if ((0, exports.getHeader)(defaultHeaders, 'x-stainless-retry-count') === undefined &&
259
+ (0, exports.getHeader)(headers, 'x-stainless-retry-count') === undefined) {
260
+ reqHeaders['x-stainless-retry-count'] = String(retryCount);
261
+ }
262
+ if ((0, exports.getHeader)(defaultHeaders, 'x-stainless-timeout') === undefined &&
263
+ (0, exports.getHeader)(headers, 'x-stainless-timeout') === undefined &&
264
+ options.timeout) {
265
+ reqHeaders['x-stainless-timeout'] = String(options.timeout);
266
+ }
255
267
  this.validateHeaders(reqHeaders, headers);
256
268
  return reqHeaders;
257
269
  }
@@ -358,16 +370,21 @@ class APIClient {
358
370
  if (signal)
359
371
  signal.addEventListener('abort', () => controller.abort());
360
372
  const timeout = setTimeout(() => controller.abort(), ms);
361
- return (this.getRequestClient()
362
- // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
363
- .fetch.call(undefined, url, { signal: controller.signal, ...options })
364
- .finally(() => {
373
+ const fetchOptions = {
374
+ signal: controller.signal,
375
+ ...options,
376
+ };
377
+ if (fetchOptions.method) {
378
+ // Custom methods like 'patch' need to be uppercased
379
+ // See https://github.com/nodejs/undici/issues/2294
380
+ fetchOptions.method = fetchOptions.method.toUpperCase();
381
+ }
382
+ return (
383
+ // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
384
+ this.fetch.call(undefined, url, fetchOptions).finally(() => {
365
385
  clearTimeout(timeout);
366
386
  }));
367
387
  }
368
- getRequestClient() {
369
- return { fetch: this.fetch };
370
- }
371
388
  shouldRetry(response) {
372
389
  // Note this is not a standard header.
373
390
  const shouldRetryHeader = response.headers.get('x-should-retry');
@@ -689,8 +706,8 @@ const safeJSON = (text) => {
689
706
  }
690
707
  };
691
708
  exports.safeJSON = safeJSON;
692
- // https://stackoverflow.com/a/19709846
693
- const startsWithSchemeRegexp = new RegExp('^(?:[a-z]+:)?//', 'i');
709
+ // https://url.spec.whatwg.org/#url-scheme-string
710
+ const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
694
711
  const isAbsoluteURL = (url) => {
695
712
  return startsWithSchemeRegexp.test(url);
696
713
  };
@@ -852,6 +869,14 @@ const isHeadersProtocol = (headers) => {
852
869
  };
853
870
  exports.isHeadersProtocol = isHeadersProtocol;
854
871
  const getRequiredHeader = (headers, header) => {
872
+ const foundHeader = (0, exports.getHeader)(headers, header);
873
+ if (foundHeader === undefined) {
874
+ throw new Error(`Could not find ${header} header`);
875
+ }
876
+ return foundHeader;
877
+ };
878
+ exports.getRequiredHeader = getRequiredHeader;
879
+ const getHeader = (headers, header) => {
855
880
  const lowerCasedHeader = header.toLowerCase();
856
881
  if ((0, exports.isHeadersProtocol)(headers)) {
857
882
  // to deal with the case where the header looks like Stainless-Event-Id
@@ -875,9 +900,9 @@ const getRequiredHeader = (headers, header) => {
875
900
  return value;
876
901
  }
877
902
  }
878
- throw new Error(`Could not find ${header} header`);
903
+ return undefined;
879
904
  };
880
- exports.getRequiredHeader = getRequiredHeader;
905
+ exports.getHeader = getHeader;
881
906
  /**
882
907
  * Encodes a string to Base64 format.
883
908
  */