llama-stack-client 0.0.1-alpha.0 → 0.1.0

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 +35 -16
  6. package/core.js.map +1 -1
  7. package/core.mjs +32 -14
  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 +100 -121
  16. package/index.d.ts +100 -121
  17. package/index.d.ts.map +1 -1
  18. package/index.js +90 -44
  19. package/index.js.map +1 -1
  20. package/index.mjs +74 -43
  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 +22 -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 +28 -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 +169 -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 +17 -64
  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 +45 -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 +59 -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 +241 -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 +40 -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 +338 -14
  216. package/resources/shared.d.ts.map +1 -1
  217. package/resources/shields.d.ts +18 -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 +7 -24
  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 +95 -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 +27 -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 +48 -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 +59 -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 +37 -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 +46 -24
  278. package/src/error.ts +25 -41
  279. package/src/index.ts +437 -155
  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 +72 -299
  291. package/src/resources/agents/index.ts +24 -27
  292. package/src/resources/agents/session.ts +73 -0
  293. package/src/resources/agents/steps.ts +14 -40
  294. package/src/resources/agents/turn.ts +292 -0
  295. package/src/resources/batch-inference.ts +30 -95
  296. package/src/resources/datasetio.ts +53 -0
  297. package/src/resources/datasets.ts +87 -81
  298. package/src/resources/eval/eval.ts +104 -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 +346 -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 +84 -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 +462 -14
  315. package/src/resources/shields.ts +37 -64
  316. package/src/resources/synthetic-data-generation.ts +13 -40
  317. package/src/resources/telemetry.ts +229 -65
  318. package/src/resources/tool-runtime/index.ts +10 -0
  319. package/src/resources/tool-runtime/rag-tool.ts +45 -0
  320. package/src/resources/tool-runtime/tool-runtime.ts +106 -0
  321. package/src/resources/toolgroups.ts +80 -0
  322. package/src/resources/tools.ts +81 -0
  323. package/src/resources/vector-dbs.ts +121 -0
  324. package/src/resources/vector-io.ts +65 -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
@@ -0,0 +1,41 @@
1
+ import { LlamaStackClientError } from '../../error';
2
+ import { ReadableStreamToAsyncIterable } from '../stream-utils';
3
+ import { type Response } from '../../_shims/index';
4
+ import { LineDecoder, type Bytes } from './line';
5
+
6
+ export class JSONLDecoder<T> {
7
+ controller: AbortController;
8
+
9
+ constructor(
10
+ private iterator: AsyncIterableIterator<Bytes>,
11
+ controller: AbortController,
12
+ ) {
13
+ this.controller = controller;
14
+ }
15
+
16
+ private async *decoder(): AsyncIterator<T, any, undefined> {
17
+ const lineDecoder = new LineDecoder();
18
+ for await (const chunk of this.iterator) {
19
+ for (const line of lineDecoder.decode(chunk)) {
20
+ yield JSON.parse(line);
21
+ }
22
+ }
23
+
24
+ for (const line of lineDecoder.flush()) {
25
+ yield JSON.parse(line);
26
+ }
27
+ }
28
+
29
+ [Symbol.asyncIterator](): AsyncIterator<T> {
30
+ return this.decoder();
31
+ }
32
+
33
+ static fromResponse<T>(response: Response, controller: AbortController): JSONLDecoder<T> {
34
+ if (!response.body) {
35
+ controller.abort();
36
+ throw new LlamaStackClientError(`Attempted to iterate over a response with no body`);
37
+ }
38
+
39
+ return new JSONLDecoder(ReadableStreamToAsyncIterable<Bytes>(response.body), controller);
40
+ }
41
+ }
@@ -0,0 +1,114 @@
1
+ import { LlamaStackClientError } from '../../error';
2
+
3
+ export type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
4
+
5
+ /**
6
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
7
+ * reading lines from text.
8
+ *
9
+ * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
10
+ */
11
+ export class LineDecoder {
12
+ // prettier-ignore
13
+ static NEWLINE_CHARS = new Set(['\n', '\r']);
14
+ static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
15
+
16
+ buffer: string[];
17
+ trailingCR: boolean;
18
+ textDecoder: any; // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
19
+
20
+ constructor() {
21
+ this.buffer = [];
22
+ this.trailingCR = false;
23
+ }
24
+
25
+ decode(chunk: Bytes): string[] {
26
+ let text = this.decodeText(chunk);
27
+
28
+ if (this.trailingCR) {
29
+ text = '\r' + text;
30
+ this.trailingCR = false;
31
+ }
32
+ if (text.endsWith('\r')) {
33
+ this.trailingCR = true;
34
+ text = text.slice(0, -1);
35
+ }
36
+
37
+ if (!text) {
38
+ return [];
39
+ }
40
+
41
+ const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
42
+ let lines = text.split(LineDecoder.NEWLINE_REGEXP);
43
+
44
+ // if there is a trailing new line then the last entry will be an empty
45
+ // string which we don't care about
46
+ if (trailingNewline) {
47
+ lines.pop();
48
+ }
49
+
50
+ if (lines.length === 1 && !trailingNewline) {
51
+ this.buffer.push(lines[0]!);
52
+ return [];
53
+ }
54
+
55
+ if (this.buffer.length > 0) {
56
+ lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
57
+ this.buffer = [];
58
+ }
59
+
60
+ if (!trailingNewline) {
61
+ this.buffer = [lines.pop() || ''];
62
+ }
63
+
64
+ return lines;
65
+ }
66
+
67
+ decodeText(bytes: Bytes): string {
68
+ if (bytes == null) return '';
69
+ if (typeof bytes === 'string') return bytes;
70
+
71
+ // Node:
72
+ if (typeof Buffer !== 'undefined') {
73
+ if (bytes instanceof Buffer) {
74
+ return bytes.toString();
75
+ }
76
+ if (bytes instanceof Uint8Array) {
77
+ return Buffer.from(bytes).toString();
78
+ }
79
+
80
+ throw new LlamaStackClientError(
81
+ `Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`,
82
+ );
83
+ }
84
+
85
+ // Browser
86
+ if (typeof TextDecoder !== 'undefined') {
87
+ if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
88
+ this.textDecoder ??= new TextDecoder('utf8');
89
+ return this.textDecoder.decode(bytes);
90
+ }
91
+
92
+ throw new LlamaStackClientError(
93
+ `Unexpected: received non-Uint8Array/ArrayBuffer (${
94
+ (bytes as any).constructor.name
95
+ }) in a web platform. Please report this error.`,
96
+ );
97
+ }
98
+
99
+ throw new LlamaStackClientError(
100
+ `Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`,
101
+ );
102
+ }
103
+
104
+ flush(): string[] {
105
+ if (!this.buffer.length && !this.trailingCR) {
106
+ return [];
107
+ }
108
+
109
+ const lines = [this.buffer.join('')];
110
+ this.buffer = [];
111
+ this.trailingCR = false;
112
+ return lines;
113
+ }
114
+ }
@@ -0,0 +1,13 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+
11
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,3 @@
1
+ # qs
2
+
3
+ This is a vendored version of [neoqs](https://github.com/PuruVJ/neoqs) which is a TypeScript rewrite of [qs](https://github.com/ljharb/qs), a query string library.
@@ -0,0 +1,9 @@
1
+ import type { Format } from './types';
2
+
3
+ export const default_format: Format = 'RFC3986';
4
+ export const formatters: Record<Format, (str: PropertyKey) => string> = {
5
+ RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
6
+ RFC3986: (v: PropertyKey) => String(v),
7
+ };
8
+ export const RFC1738 = 'RFC1738';
9
+ export const RFC3986 = 'RFC3986';
@@ -0,0 +1,13 @@
1
+ import { default_format, formatters, RFC1738, RFC3986 } from './formats';
2
+
3
+ const formats = {
4
+ formatters,
5
+ RFC1738,
6
+ RFC3986,
7
+ default: default_format,
8
+ };
9
+
10
+ export { stringify } from './stringify';
11
+ export { formats };
12
+
13
+ export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';
@@ -0,0 +1,388 @@
1
+ import { encode, is_buffer, maybe_map } from './utils';
2
+ import { default_format, formatters } from './formats';
3
+ import type { NonNullableProperties, StringifyOptions } from './types';
4
+
5
+ const has = Object.prototype.hasOwnProperty;
6
+
7
+ const array_prefix_generators = {
8
+ brackets(prefix: PropertyKey) {
9
+ return String(prefix) + '[]';
10
+ },
11
+ comma: 'comma',
12
+ indices(prefix: PropertyKey, key: string) {
13
+ return String(prefix) + '[' + key + ']';
14
+ },
15
+ repeat(prefix: PropertyKey) {
16
+ return String(prefix);
17
+ },
18
+ };
19
+
20
+ const is_array = Array.isArray;
21
+ const push = Array.prototype.push;
22
+ const push_to_array = function (arr: any[], value_or_array: any) {
23
+ push.apply(arr, is_array(value_or_array) ? value_or_array : [value_or_array]);
24
+ };
25
+
26
+ const to_ISO = Date.prototype.toISOString;
27
+
28
+ const defaults = {
29
+ addQueryPrefix: false,
30
+ allowDots: false,
31
+ allowEmptyArrays: false,
32
+ arrayFormat: 'indices',
33
+ charset: 'utf-8',
34
+ charsetSentinel: false,
35
+ delimiter: '&',
36
+ encode: true,
37
+ encodeDotInKeys: false,
38
+ encoder: encode,
39
+ encodeValuesOnly: false,
40
+ format: default_format,
41
+ formatter: formatters[default_format],
42
+ /** @deprecated */
43
+ indices: false,
44
+ serializeDate(date) {
45
+ return to_ISO.call(date);
46
+ },
47
+ skipNulls: false,
48
+ strictNullHandling: false,
49
+ } as NonNullableProperties<StringifyOptions & { formatter: (typeof formatters)['RFC1738'] }>;
50
+
51
+ function is_non_nullish_primitive(v: unknown): v is string | number | boolean | symbol | bigint {
52
+ return (
53
+ typeof v === 'string' ||
54
+ typeof v === 'number' ||
55
+ typeof v === 'boolean' ||
56
+ typeof v === 'symbol' ||
57
+ typeof v === 'bigint'
58
+ );
59
+ }
60
+
61
+ const sentinel = {};
62
+
63
+ function inner_stringify(
64
+ object: any,
65
+ prefix: PropertyKey,
66
+ generateArrayPrefix: StringifyOptions['arrayFormat'] | ((prefix: string, key: string) => string),
67
+ commaRoundTrip: boolean,
68
+ allowEmptyArrays: boolean,
69
+ strictNullHandling: boolean,
70
+ skipNulls: boolean,
71
+ encodeDotInKeys: boolean,
72
+ encoder: StringifyOptions['encoder'],
73
+ filter: StringifyOptions['filter'],
74
+ sort: StringifyOptions['sort'],
75
+ allowDots: StringifyOptions['allowDots'],
76
+ serializeDate: StringifyOptions['serializeDate'],
77
+ format: StringifyOptions['format'],
78
+ formatter: StringifyOptions['formatter'],
79
+ encodeValuesOnly: boolean,
80
+ charset: StringifyOptions['charset'],
81
+ sideChannel: WeakMap<any, any>,
82
+ ) {
83
+ let obj = object;
84
+
85
+ let tmp_sc = sideChannel;
86
+ let step = 0;
87
+ let find_flag = false;
88
+ while ((tmp_sc = tmp_sc.get(sentinel)) !== void undefined && !find_flag) {
89
+ // Where object last appeared in the ref tree
90
+ const pos = tmp_sc.get(object);
91
+ step += 1;
92
+ if (typeof pos !== 'undefined') {
93
+ if (pos === step) {
94
+ throw new RangeError('Cyclic object value');
95
+ } else {
96
+ find_flag = true; // Break while
97
+ }
98
+ }
99
+ if (typeof tmp_sc.get(sentinel) === 'undefined') {
100
+ step = 0;
101
+ }
102
+ }
103
+
104
+ if (typeof filter === 'function') {
105
+ obj = filter(prefix, obj);
106
+ } else if (obj instanceof Date) {
107
+ obj = serializeDate?.(obj);
108
+ } else if (generateArrayPrefix === 'comma' && is_array(obj)) {
109
+ obj = maybe_map(obj, function (value) {
110
+ if (value instanceof Date) {
111
+ return serializeDate?.(value);
112
+ }
113
+ return value;
114
+ });
115
+ }
116
+
117
+ if (obj === null) {
118
+ if (strictNullHandling) {
119
+ return encoder && !encodeValuesOnly ?
120
+ // @ts-expect-error
121
+ encoder(prefix, defaults.encoder, charset, 'key', format)
122
+ : prefix;
123
+ }
124
+
125
+ obj = '';
126
+ }
127
+
128
+ if (is_non_nullish_primitive(obj) || is_buffer(obj)) {
129
+ if (encoder) {
130
+ const key_value =
131
+ encodeValuesOnly ? prefix
132
+ // @ts-expect-error
133
+ : encoder(prefix, defaults.encoder, charset, 'key', format);
134
+ return [
135
+ formatter?.(key_value) +
136
+ '=' +
137
+ // @ts-expect-error
138
+ formatter?.(encoder(obj, defaults.encoder, charset, 'value', format)),
139
+ ];
140
+ }
141
+ return [formatter?.(prefix) + '=' + formatter?.(String(obj))];
142
+ }
143
+
144
+ const values: string[] = [];
145
+
146
+ if (typeof obj === 'undefined') {
147
+ return values;
148
+ }
149
+
150
+ let obj_keys;
151
+ if (generateArrayPrefix === 'comma' && is_array(obj)) {
152
+ // we need to join elements in
153
+ if (encodeValuesOnly && encoder) {
154
+ // @ts-expect-error values only
155
+ obj = maybe_map(obj, encoder);
156
+ }
157
+ obj_keys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
158
+ } else if (is_array(filter)) {
159
+ obj_keys = filter;
160
+ } else {
161
+ const keys = Object.keys(obj);
162
+ obj_keys = sort ? keys.sort(sort) : keys;
163
+ }
164
+
165
+ const encoded_prefix = encodeDotInKeys ? String(prefix).replace(/\./g, '%2E') : String(prefix);
166
+
167
+ const adjusted_prefix =
168
+ commaRoundTrip && is_array(obj) && obj.length === 1 ? encoded_prefix + '[]' : encoded_prefix;
169
+
170
+ if (allowEmptyArrays && is_array(obj) && obj.length === 0) {
171
+ return adjusted_prefix + '[]';
172
+ }
173
+
174
+ for (let j = 0; j < obj_keys.length; ++j) {
175
+ const key = obj_keys[j];
176
+ const value =
177
+ // @ts-ignore
178
+ typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key as any];
179
+
180
+ if (skipNulls && value === null) {
181
+ continue;
182
+ }
183
+
184
+ // @ts-ignore
185
+ const encoded_key = allowDots && encodeDotInKeys ? (key as any).replace(/\./g, '%2E') : key;
186
+ const key_prefix =
187
+ is_array(obj) ?
188
+ typeof generateArrayPrefix === 'function' ?
189
+ generateArrayPrefix(adjusted_prefix, encoded_key)
190
+ : adjusted_prefix
191
+ : adjusted_prefix + (allowDots ? '.' + encoded_key : '[' + encoded_key + ']');
192
+
193
+ sideChannel.set(object, step);
194
+ const valueSideChannel = new WeakMap();
195
+ valueSideChannel.set(sentinel, sideChannel);
196
+ push_to_array(
197
+ values,
198
+ inner_stringify(
199
+ value,
200
+ key_prefix,
201
+ generateArrayPrefix,
202
+ commaRoundTrip,
203
+ allowEmptyArrays,
204
+ strictNullHandling,
205
+ skipNulls,
206
+ encodeDotInKeys,
207
+ // @ts-ignore
208
+ generateArrayPrefix === 'comma' && encodeValuesOnly && is_array(obj) ? null : encoder,
209
+ filter,
210
+ sort,
211
+ allowDots,
212
+ serializeDate,
213
+ format,
214
+ formatter,
215
+ encodeValuesOnly,
216
+ charset,
217
+ valueSideChannel,
218
+ ),
219
+ );
220
+ }
221
+
222
+ return values;
223
+ }
224
+
225
+ function normalize_stringify_options(
226
+ opts: StringifyOptions = defaults,
227
+ ): NonNullableProperties<Omit<StringifyOptions, 'indices'>> & { indices?: boolean } {
228
+ if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
229
+ throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
230
+ }
231
+
232
+ if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') {
233
+ throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided');
234
+ }
235
+
236
+ if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
237
+ throw new TypeError('Encoder has to be a function.');
238
+ }
239
+
240
+ const charset = opts.charset || defaults.charset;
241
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
242
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
243
+ }
244
+
245
+ let format = default_format;
246
+ if (typeof opts.format !== 'undefined') {
247
+ if (!has.call(formatters, opts.format)) {
248
+ throw new TypeError('Unknown format option provided.');
249
+ }
250
+ format = opts.format;
251
+ }
252
+ const formatter = formatters[format];
253
+
254
+ let filter = defaults.filter;
255
+ if (typeof opts.filter === 'function' || is_array(opts.filter)) {
256
+ filter = opts.filter;
257
+ }
258
+
259
+ let arrayFormat: StringifyOptions['arrayFormat'];
260
+ if (opts.arrayFormat && opts.arrayFormat in array_prefix_generators) {
261
+ arrayFormat = opts.arrayFormat;
262
+ } else if ('indices' in opts) {
263
+ arrayFormat = opts.indices ? 'indices' : 'repeat';
264
+ } else {
265
+ arrayFormat = defaults.arrayFormat;
266
+ }
267
+
268
+ if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
269
+ throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
270
+ }
271
+
272
+ const allowDots =
273
+ typeof opts.allowDots === 'undefined' ?
274
+ !!opts.encodeDotInKeys === true ?
275
+ true
276
+ : defaults.allowDots
277
+ : !!opts.allowDots;
278
+
279
+ return {
280
+ addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
281
+ // @ts-ignore
282
+ allowDots: allowDots,
283
+ allowEmptyArrays:
284
+ typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
285
+ arrayFormat: arrayFormat,
286
+ charset: charset,
287
+ charsetSentinel:
288
+ typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
289
+ commaRoundTrip: !!opts.commaRoundTrip,
290
+ delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
291
+ encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
292
+ encodeDotInKeys:
293
+ typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
294
+ encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
295
+ encodeValuesOnly:
296
+ typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
297
+ filter: filter,
298
+ format: format,
299
+ formatter: formatter,
300
+ serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
301
+ skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
302
+ // @ts-ignore
303
+ sort: typeof opts.sort === 'function' ? opts.sort : null,
304
+ strictNullHandling:
305
+ typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling,
306
+ };
307
+ }
308
+
309
+ export function stringify(object: any, opts: StringifyOptions = {}) {
310
+ let obj = object;
311
+ const options = normalize_stringify_options(opts);
312
+
313
+ let obj_keys: PropertyKey[] | undefined;
314
+ let filter;
315
+
316
+ if (typeof options.filter === 'function') {
317
+ filter = options.filter;
318
+ obj = filter('', obj);
319
+ } else if (is_array(options.filter)) {
320
+ filter = options.filter;
321
+ obj_keys = filter;
322
+ }
323
+
324
+ const keys: string[] = [];
325
+
326
+ if (typeof obj !== 'object' || obj === null) {
327
+ return '';
328
+ }
329
+
330
+ const generateArrayPrefix = array_prefix_generators[options.arrayFormat];
331
+ const commaRoundTrip = generateArrayPrefix === 'comma' && options.commaRoundTrip;
332
+
333
+ if (!obj_keys) {
334
+ obj_keys = Object.keys(obj);
335
+ }
336
+
337
+ if (options.sort) {
338
+ obj_keys.sort(options.sort);
339
+ }
340
+
341
+ const sideChannel = new WeakMap();
342
+ for (let i = 0; i < obj_keys.length; ++i) {
343
+ const key = obj_keys[i]!;
344
+
345
+ if (options.skipNulls && obj[key] === null) {
346
+ continue;
347
+ }
348
+ push_to_array(
349
+ keys,
350
+ inner_stringify(
351
+ obj[key],
352
+ key,
353
+ // @ts-expect-error
354
+ generateArrayPrefix,
355
+ commaRoundTrip,
356
+ options.allowEmptyArrays,
357
+ options.strictNullHandling,
358
+ options.skipNulls,
359
+ options.encodeDotInKeys,
360
+ options.encode ? options.encoder : null,
361
+ options.filter,
362
+ options.sort,
363
+ options.allowDots,
364
+ options.serializeDate,
365
+ options.format,
366
+ options.formatter,
367
+ options.encodeValuesOnly,
368
+ options.charset,
369
+ sideChannel,
370
+ ),
371
+ );
372
+ }
373
+
374
+ const joined = keys.join(options.delimiter);
375
+ let prefix = options.addQueryPrefix === true ? '?' : '';
376
+
377
+ if (options.charsetSentinel) {
378
+ if (options.charset === 'iso-8859-1') {
379
+ // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
380
+ prefix += 'utf8=%26%2310003%3B&';
381
+ } else {
382
+ // encodeURIComponent('✓')
383
+ prefix += 'utf8=%E2%9C%93&';
384
+ }
385
+ }
386
+
387
+ return joined.length > 0 ? prefix + joined : '';
388
+ }
@@ -0,0 +1,71 @@
1
+ export type Format = 'RFC1738' | 'RFC3986';
2
+
3
+ export type DefaultEncoder = (str: any, defaultEncoder?: any, charset?: string) => string;
4
+ export type DefaultDecoder = (str: string, decoder?: any, charset?: string) => string;
5
+
6
+ export type BooleanOptional = boolean | undefined;
7
+
8
+ export type StringifyBaseOptions = {
9
+ delimiter?: string;
10
+ allowDots?: boolean;
11
+ encodeDotInKeys?: boolean;
12
+ strictNullHandling?: boolean;
13
+ skipNulls?: boolean;
14
+ encode?: boolean;
15
+ encoder?: (
16
+ str: any,
17
+ defaultEncoder: DefaultEncoder,
18
+ charset: string,
19
+ type: 'key' | 'value',
20
+ format?: Format,
21
+ ) => string;
22
+ filter?: Array<PropertyKey> | ((prefix: PropertyKey, value: any) => any);
23
+ arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma';
24
+ indices?: boolean;
25
+ sort?: ((a: PropertyKey, b: PropertyKey) => number) | null;
26
+ serializeDate?: (d: Date) => string;
27
+ format?: 'RFC1738' | 'RFC3986';
28
+ formatter?: (str: PropertyKey) => string;
29
+ encodeValuesOnly?: boolean;
30
+ addQueryPrefix?: boolean;
31
+ charset?: 'utf-8' | 'iso-8859-1';
32
+ charsetSentinel?: boolean;
33
+ allowEmptyArrays?: boolean;
34
+ commaRoundTrip?: boolean;
35
+ };
36
+
37
+ export type StringifyOptions = StringifyBaseOptions;
38
+
39
+ export type ParseBaseOptions = {
40
+ comma?: boolean;
41
+ delimiter?: string | RegExp;
42
+ depth?: number | false;
43
+ decoder?: (str: string, defaultDecoder: DefaultDecoder, charset: string, type: 'key' | 'value') => any;
44
+ arrayLimit?: number;
45
+ parseArrays?: boolean;
46
+ plainObjects?: boolean;
47
+ allowPrototypes?: boolean;
48
+ allowSparse?: boolean;
49
+ parameterLimit?: number;
50
+ strictDepth?: boolean;
51
+ strictNullHandling?: boolean;
52
+ ignoreQueryPrefix?: boolean;
53
+ charset?: 'utf-8' | 'iso-8859-1';
54
+ charsetSentinel?: boolean;
55
+ interpretNumericEntities?: boolean;
56
+ allowEmptyArrays?: boolean;
57
+ duplicates?: 'combine' | 'first' | 'last';
58
+ allowDots?: boolean;
59
+ decodeDotInKeys?: boolean;
60
+ };
61
+
62
+ export type ParseOptions = ParseBaseOptions;
63
+
64
+ export type ParsedQs = {
65
+ [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[];
66
+ };
67
+
68
+ // Type to remove null or undefined union from each property
69
+ export type NonNullableProperties<T> = {
70
+ [K in keyof T]-?: Exclude<T[K], undefined | null>;
71
+ };