openpond-sdk 0.12.25 → 0.12.27

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 (297) hide show
  1. package/LEARNING.md +5 -7
  2. package/OPENTELEMETRY.md +1 -1
  3. package/PRODUCT_INTEGRATION.md +18 -16
  4. package/README.md +5 -14
  5. package/SERVERLESS_SERVING.md +54 -0
  6. package/TASKSETS.md +1 -2
  7. package/TASK_INGESTION.md +3 -8
  8. package/TRAINING_PROTOCOL.md +1 -1
  9. package/TRAINING_WORKFLOWS.md +11 -6
  10. package/dist/advanced-refiner-evaluations.js +9 -8
  11. package/dist/ai-sdk.js +21 -83
  12. package/dist/ai-sdk.js.map +1 -1
  13. package/dist/candidate-evaluations.js +7 -6
  14. package/dist/{chunk-IXFUYPGV.js → chunk-3HOGOWKU.js} +10 -8
  15. package/dist/chunk-3HOGOWKU.js.map +1 -0
  16. package/dist/{chunk-YV6PPDXZ.js → chunk-3Z5IK2UK.js} +27 -2
  17. package/dist/chunk-3Z5IK2UK.js.map +1 -0
  18. package/dist/{chunk-3B5KSH3V.js → chunk-456F3BXD.js} +5 -2
  19. package/dist/chunk-456F3BXD.js.map +1 -0
  20. package/dist/{chunk-GS5HEE4M.js → chunk-4D4QSQC3.js} +2 -2
  21. package/dist/{chunk-3VUF5H3B.js → chunk-534W2O2S.js} +2 -2
  22. package/dist/{chunk-47THZRUM.js → chunk-54BJJL7G.js} +8 -5
  23. package/dist/chunk-54BJJL7G.js.map +1 -0
  24. package/dist/{chunk-ZRTNR4U7.js → chunk-5KJY44FB.js} +3 -3
  25. package/dist/{chunk-GX6KMHW2.js → chunk-7MLFWVDI.js} +33 -11
  26. package/dist/chunk-7MLFWVDI.js.map +1 -0
  27. package/dist/{chunk-RTLJV4OS.js → chunk-7ZV626YS.js} +2 -2
  28. package/dist/{chunk-YS7DF76T.js → chunk-ABOZV47D.js} +3 -3
  29. package/dist/{chunk-DDCR4KB5.js → chunk-BIQ5TG3T.js} +4 -4
  30. package/dist/{chunk-JOMZJXGC.js → chunk-BT6CC6QB.js} +3 -3
  31. package/dist/{chunk-QOX57Y27.js → chunk-CNFN6GHY.js} +6 -3
  32. package/dist/chunk-CNFN6GHY.js.map +1 -0
  33. package/dist/{chunk-RN5MK7NH.js → chunk-CVYGJUWM.js} +3 -3
  34. package/dist/{chunk-QNOCM5JX.js → chunk-CX7ETU2F.js} +2 -2
  35. package/dist/{chunk-EZME7DV4.js → chunk-D7LV3USE.js} +2 -2
  36. package/dist/{chunk-7F43U2NC.js → chunk-GA7OSSEA.js} +3 -3
  37. package/dist/{chunk-T67LNKAK.js → chunk-GFWXDWEE.js} +3 -3
  38. package/dist/{chunk-Z5APNTZE.js → chunk-JYWIKBGD.js} +122 -112
  39. package/dist/chunk-JYWIKBGD.js.map +1 -0
  40. package/dist/{chunk-GV6DEDBU.js → chunk-K4WU4JOP.js} +2 -2
  41. package/dist/{chunk-DH6O4JFB.js → chunk-KJTX4A27.js} +5 -2
  42. package/dist/chunk-KJTX4A27.js.map +1 -0
  43. package/dist/{chunk-JMFYNIYZ.js → chunk-L7MVGGBH.js} +6 -3
  44. package/dist/chunk-L7MVGGBH.js.map +1 -0
  45. package/dist/{chunk-3G3HUA32.js → chunk-LRFVISLA.js} +3 -3
  46. package/dist/{chunk-ZQFROKKS.js → chunk-MJHQMQEW.js} +3 -3
  47. package/dist/{chunk-2OVNKPBZ.js → chunk-MUG4OQKL.js} +5 -2
  48. package/dist/chunk-MUG4OQKL.js.map +1 -0
  49. package/dist/{chunk-C3TS766N.js → chunk-N6LGT7NT.js} +5 -2
  50. package/dist/chunk-N6LGT7NT.js.map +1 -0
  51. package/dist/chunk-ON3KSXWR.js +639 -0
  52. package/dist/chunk-ON3KSXWR.js.map +1 -0
  53. package/dist/chunk-QYWPNNP3.js +9 -0
  54. package/dist/chunk-QYWPNNP3.js.map +1 -0
  55. package/dist/{chunk-PMVSO23F.js → chunk-RMXZISHK.js} +10 -1
  56. package/dist/chunk-RMXZISHK.js.map +1 -0
  57. package/dist/{chunk-626JLH4D.js → chunk-TMNEDWA7.js} +10 -3
  58. package/dist/chunk-TMNEDWA7.js.map +1 -0
  59. package/dist/{chunk-BJMENXR4.js → chunk-TX552FQG.js} +3 -3
  60. package/dist/{chunk-Z252BNAZ.js → chunk-VE5JD5FN.js} +6 -2
  61. package/dist/chunk-VE5JD5FN.js.map +1 -0
  62. package/dist/{chunk-XBFOFTK3.js → chunk-VIDRZCPQ.js} +6 -6
  63. package/dist/{chunk-QRYEXPG7.js → chunk-VRUAIMM3.js} +14 -11
  64. package/dist/chunk-VRUAIMM3.js.map +1 -0
  65. package/dist/{chunk-MVAEE5EI.js → chunk-WJZHSIGD.js} +10 -9
  66. package/dist/chunk-WJZHSIGD.js.map +1 -0
  67. package/dist/{chunk-3MWFN7BA.js → chunk-WPTFJZ4L.js} +8 -5
  68. package/dist/chunk-WPTFJZ4L.js.map +1 -0
  69. package/dist/connected-evidence.js +9 -8
  70. package/dist/dataset-commerce.js +4 -1
  71. package/dist/dataset-commerce.js.map +1 -1
  72. package/dist/dataset-marketplace.js +4 -1
  73. package/dist/dataset-marketplace.js.map +1 -1
  74. package/dist/dataset-workspaces.js +18 -15
  75. package/dist/dataset-workspaces.js.map +1 -1
  76. package/dist/errors.js +2 -1
  77. package/dist/experiment-evaluation-schedules.js +19 -18
  78. package/dist/experiment-improvements.js +8 -7
  79. package/dist/experiments.js +17 -16
  80. package/dist/human-review.js +2 -1
  81. package/dist/index.js +33 -29
  82. package/dist/index.js.map +1 -1
  83. package/dist/learning.js +21 -7
  84. package/dist/learning.js.map +1 -1
  85. package/dist/model-projects.js +2 -1
  86. package/dist/model-starter-attempts.js +3 -2
  87. package/dist/model-starter-catalog.js +8 -5
  88. package/dist/model-starter-catalog.js.map +1 -1
  89. package/dist/model-starters.js +5 -4
  90. package/dist/model-taskset-runs.js +7 -4
  91. package/dist/model-taskset-runs.js.map +1 -1
  92. package/dist/post-training.js +7 -6
  93. package/dist/taskset-catalog.js +2 -1
  94. package/dist/taskset-drafts.js +11 -8
  95. package/dist/taskset-drafts.js.map +1 -1
  96. package/dist/taskset-packages.js +14 -11
  97. package/dist/tool-learning.js +4 -1
  98. package/dist/tool-learning.js.map +1 -1
  99. package/dist/training-bundle.js +47 -20
  100. package/dist/training-bundle.js.map +1 -1
  101. package/dist/training-hardware.js +3 -2
  102. package/dist/training-projects.js +4 -1
  103. package/dist/training-projects.js.map +1 -1
  104. package/dist/training.js +5718 -4337
  105. package/dist/training.js.map +1 -1
  106. package/dist/types/packages/sdk/src/ai-sdk.d.ts.map +1 -1
  107. package/dist/types/packages/sdk/src/alphaedit-model-serving.d.ts +8 -4
  108. package/dist/types/packages/sdk/src/alphaedit-model-serving.d.ts.map +1 -1
  109. package/dist/types/packages/sdk/src/candidate-evaluation-client.d.ts +162 -162
  110. package/dist/types/packages/sdk/src/connected-evidence-client.d.ts +1 -1
  111. package/dist/types/packages/sdk/src/connected-evidence-client.d.ts.map +1 -1
  112. package/dist/types/packages/sdk/src/connected-sync.d.ts +1 -1
  113. package/dist/types/packages/sdk/src/connected-sync.d.ts.map +1 -1
  114. package/dist/types/packages/sdk/src/dataset-commerce.d.ts +1 -1
  115. package/dist/types/packages/sdk/src/dataset-commerce.d.ts.map +1 -1
  116. package/dist/types/packages/sdk/src/dataset-marketplace.d.ts +1 -1
  117. package/dist/types/packages/sdk/src/dataset-marketplace.d.ts.map +1 -1
  118. package/dist/types/packages/sdk/src/dataset-population.d.ts +1 -1
  119. package/dist/types/packages/sdk/src/dataset-population.d.ts.map +1 -1
  120. package/dist/types/packages/sdk/src/dataset-preparation-client.d.ts +1 -1
  121. package/dist/types/packages/sdk/src/dataset-preparation-client.d.ts.map +1 -1
  122. package/dist/types/packages/sdk/src/dataset-task-ingestion.d.ts +1 -1
  123. package/dist/types/packages/sdk/src/dataset-task-ingestion.d.ts.map +1 -1
  124. package/dist/types/packages/sdk/src/dataset-workspace-client.d.ts +1 -1
  125. package/dist/types/packages/sdk/src/dataset-workspace-client.d.ts.map +1 -1
  126. package/dist/types/packages/sdk/src/decision-model-serving.d.ts +4 -2
  127. package/dist/types/packages/sdk/src/decision-model-serving.d.ts.map +1 -1
  128. package/dist/types/packages/sdk/src/endpoints.d.ts +4 -0
  129. package/dist/types/packages/sdk/src/endpoints.d.ts.map +1 -0
  130. package/dist/types/packages/sdk/src/engram-model-serving.d.ts +3 -1
  131. package/dist/types/packages/sdk/src/engram-model-serving.d.ts.map +1 -1
  132. package/dist/types/packages/sdk/src/evaluation-coordination-http.d.ts +1 -1
  133. package/dist/types/packages/sdk/src/evaluation-coordination-http.d.ts.map +1 -1
  134. package/dist/types/packages/sdk/src/experiment-client.d.ts +700 -692
  135. package/dist/types/packages/sdk/src/experiment-client.d.ts.map +1 -1
  136. package/dist/types/packages/sdk/src/experiment-draft-storage.d.ts +34 -28
  137. package/dist/types/packages/sdk/src/experiment-draft-storage.d.ts.map +1 -1
  138. package/dist/types/packages/sdk/src/experiment-improvement-client.d.ts +1890 -1890
  139. package/dist/types/packages/sdk/src/experiment-improvement-client.d.ts.map +1 -1
  140. package/dist/types/packages/sdk/src/experiment-inspection.d.ts +1 -1
  141. package/dist/types/packages/sdk/src/experiment-inspection.d.ts.map +1 -1
  142. package/dist/types/packages/sdk/src/experiment-run-details.d.ts +7 -7
  143. package/dist/types/packages/sdk/src/experiment-scoring-contracts.d.ts +21 -3
  144. package/dist/types/packages/sdk/src/experiment-scoring-contracts.d.ts.map +1 -1
  145. package/dist/types/packages/sdk/src/grader-inspection.d.ts +1 -1
  146. package/dist/types/packages/sdk/src/grader-inspection.d.ts.map +1 -1
  147. package/dist/types/packages/sdk/src/human-review-client.d.ts +1 -1
  148. package/dist/types/packages/sdk/src/human-review-client.d.ts.map +1 -1
  149. package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
  150. package/dist/types/packages/sdk/src/learning-client.d.ts +1 -1
  151. package/dist/types/packages/sdk/src/learning-client.d.ts.map +1 -1
  152. package/dist/types/packages/sdk/src/learning-correction-metrics.d.ts +1 -1
  153. package/dist/types/packages/sdk/src/learning-correction-metrics.d.ts.map +1 -1
  154. package/dist/types/packages/sdk/src/learning.d.ts +1 -0
  155. package/dist/types/packages/sdk/src/learning.d.ts.map +1 -1
  156. package/dist/types/packages/sdk/src/managed-alphaedit-executions.d.ts +272 -16
  157. package/dist/types/packages/sdk/src/managed-alphaedit-executions.d.ts.map +1 -1
  158. package/dist/types/packages/sdk/src/managed-compute-price.d.ts +53 -1
  159. package/dist/types/packages/sdk/src/managed-compute-price.d.ts.map +1 -1
  160. package/dist/types/packages/sdk/src/managed-decision-executions.d.ts +612 -356
  161. package/dist/types/packages/sdk/src/managed-decision-executions.d.ts.map +1 -1
  162. package/dist/types/packages/sdk/src/managed-engram-executions.d.ts +272 -16
  163. package/dist/types/packages/sdk/src/managed-engram-executions.d.ts.map +1 -1
  164. package/dist/types/packages/sdk/src/managed-modification-executions.d.ts +208 -16
  165. package/dist/types/packages/sdk/src/managed-modification-executions.d.ts.map +1 -1
  166. package/dist/types/packages/sdk/src/managed-neuron-training-executions.d.ts +272 -16
  167. package/dist/types/packages/sdk/src/managed-neuron-training-executions.d.ts.map +1 -1
  168. package/dist/types/packages/sdk/src/managed-serving-usage.d.ts +3 -0
  169. package/dist/types/packages/sdk/src/managed-serving-usage.d.ts.map +1 -1
  170. package/dist/types/packages/sdk/src/managed-training-preparation.d.ts +25 -25
  171. package/dist/types/packages/sdk/src/managed-training-preparation.d.ts.map +1 -1
  172. package/dist/types/packages/sdk/src/model-learning-capabilities.d.ts +4 -0
  173. package/dist/types/packages/sdk/src/model-learning-capabilities.d.ts.map +1 -0
  174. package/dist/types/packages/sdk/src/model-learning-policy.d.ts.map +1 -1
  175. package/dist/types/packages/sdk/src/model-projects.d.ts +1 -1
  176. package/dist/types/packages/sdk/src/model-projects.d.ts.map +1 -1
  177. package/dist/types/packages/sdk/src/model-starter-attempts.d.ts +1 -1
  178. package/dist/types/packages/sdk/src/model-starter-attempts.d.ts.map +1 -1
  179. package/dist/types/packages/sdk/src/model-starter-catalog.d.ts +1 -1
  180. package/dist/types/packages/sdk/src/model-starter-catalog.d.ts.map +1 -1
  181. package/dist/types/packages/sdk/src/model-supervised-training-defaults.d.ts.map +1 -1
  182. package/dist/types/packages/sdk/src/model-taskset-runs.d.ts +1 -1
  183. package/dist/types/packages/sdk/src/model-taskset-runs.d.ts.map +1 -1
  184. package/dist/types/packages/sdk/src/model-training-defaults.d.ts +5 -2
  185. package/dist/types/packages/sdk/src/model-training-defaults.d.ts.map +1 -1
  186. package/dist/types/packages/sdk/src/neuron-training-model-serving.d.ts +8 -4
  187. package/dist/types/packages/sdk/src/neuron-training-model-serving.d.ts.map +1 -1
  188. package/dist/types/packages/sdk/src/post-training.d.ts +7 -7
  189. package/dist/types/packages/sdk/src/product-model-response.d.ts +6 -2
  190. package/dist/types/packages/sdk/src/product-model-response.d.ts.map +1 -1
  191. package/dist/types/packages/sdk/src/product-model-transport.d.ts +99 -0
  192. package/dist/types/packages/sdk/src/product-model-transport.d.ts.map +1 -0
  193. package/dist/types/packages/sdk/src/product-model-wire.d.ts +104 -0
  194. package/dist/types/packages/sdk/src/product-model-wire.d.ts.map +1 -0
  195. package/dist/types/packages/sdk/src/product-models.d.ts +18 -15
  196. package/dist/types/packages/sdk/src/product-models.d.ts.map +1 -1
  197. package/dist/types/packages/sdk/src/profile-evaluation-discovery.d.ts +1 -1
  198. package/dist/types/packages/sdk/src/profile-evaluation-discovery.d.ts.map +1 -1
  199. package/dist/types/packages/sdk/src/serverless-serving.d.ts +564 -0
  200. package/dist/types/packages/sdk/src/serverless-serving.d.ts.map +1 -0
  201. package/dist/types/packages/sdk/src/steering-model-serving.d.ts +2211 -494
  202. package/dist/types/packages/sdk/src/steering-model-serving.d.ts.map +1 -1
  203. package/dist/types/packages/sdk/src/steering-profile-publication.d.ts +631 -0
  204. package/dist/types/packages/sdk/src/steering-profile-publication.d.ts.map +1 -1
  205. package/dist/types/packages/sdk/src/taskset-catalog.d.ts +1 -1
  206. package/dist/types/packages/sdk/src/taskset-catalog.d.ts.map +1 -1
  207. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +1 -1
  208. package/dist/types/packages/sdk/src/taskset-draft-client.d.ts.map +1 -1
  209. package/dist/types/packages/sdk/src/taskset-package-client.d.ts +1 -1
  210. package/dist/types/packages/sdk/src/taskset-package-client.d.ts.map +1 -1
  211. package/dist/types/packages/sdk/src/taskset-package-projection.d.ts +20 -20
  212. package/dist/types/packages/sdk/src/taskset-packages.d.ts +1 -0
  213. package/dist/types/packages/sdk/src/taskset-packages.d.ts.map +1 -1
  214. package/dist/types/packages/sdk/src/taskset-text-policy.d.ts +11 -0
  215. package/dist/types/packages/sdk/src/taskset-text-policy.d.ts.map +1 -0
  216. package/dist/types/packages/sdk/src/tool-learning-client.d.ts +1 -1
  217. package/dist/types/packages/sdk/src/tool-learning-client.d.ts.map +1 -1
  218. package/dist/types/packages/sdk/src/training-compute-selection.d.ts +6 -19
  219. package/dist/types/packages/sdk/src/training-compute-selection.d.ts.map +1 -1
  220. package/dist/types/packages/sdk/src/training-estimates.d.ts +1 -1
  221. package/dist/types/packages/sdk/src/training-experiment-setup.d.ts +4 -1
  222. package/dist/types/packages/sdk/src/training-experiment-setup.d.ts.map +1 -1
  223. package/dist/types/packages/sdk/src/training-harness-sources.d.ts +2 -2
  224. package/dist/types/packages/sdk/src/training-model-serving-control.d.ts +630 -0
  225. package/dist/types/packages/sdk/src/training-model-serving-control.d.ts.map +1 -1
  226. package/dist/types/packages/sdk/src/training-model-serving.d.ts +1665 -7
  227. package/dist/types/packages/sdk/src/training-model-serving.d.ts.map +1 -1
  228. package/dist/types/packages/sdk/src/training-operations.d.ts +11197 -0
  229. package/dist/types/packages/sdk/src/training-operations.d.ts.map +1 -0
  230. package/dist/types/packages/sdk/src/training-project-client.d.ts +1 -1
  231. package/dist/types/packages/sdk/src/training-project-client.d.ts.map +1 -1
  232. package/dist/types/packages/sdk/src/training-supervised.d.ts +13 -0
  233. package/dist/types/packages/sdk/src/training-supervised.d.ts.map +1 -1
  234. package/dist/types/packages/sdk/src/training-transport.d.ts +5 -2
  235. package/dist/types/packages/sdk/src/training-transport.d.ts.map +1 -1
  236. package/dist/types/packages/sdk/src/training.d.ts +16869 -5331
  237. package/dist/types/packages/sdk/src/training.d.ts.map +1 -1
  238. package/dist/types/packages/sdk/src/types.d.ts +2 -2
  239. package/dist/types/packages/sdk/src/types.d.ts.map +1 -1
  240. package/dist/types/packages/sdk/src/weight-inference.d.ts +8 -5
  241. package/dist/types/packages/sdk/src/weight-inference.d.ts.map +1 -1
  242. package/dist/types/packages/sdk/src/weight-model-versions.d.ts +2089 -398
  243. package/dist/types/packages/sdk/src/weight-model-versions.d.ts.map +1 -1
  244. package/dist/types/packages/sdk/src/weight-space-artifact.d.ts +433 -0
  245. package/dist/types/packages/sdk/src/weight-space-artifact.d.ts.map +1 -0
  246. package/dist/types/packages/sdk/src/weight-space-evaluation.d.ts +1437 -0
  247. package/dist/types/packages/sdk/src/weight-space-evaluation.d.ts.map +1 -0
  248. package/dist/types/packages/sdk/src/weight-space-model-serving.d.ts +2910 -0
  249. package/dist/types/packages/sdk/src/weight-space-model-serving.d.ts.map +1 -0
  250. package/dist/types/packages/sdk/src/weight-space-programming.d.ts +845 -0
  251. package/dist/types/packages/sdk/src/weight-space-programming.d.ts.map +1 -0
  252. package/dist/types/packages/sdk/src/weight-space-sessions.d.ts +4600 -0
  253. package/dist/types/packages/sdk/src/weight-space-sessions.d.ts.map +1 -0
  254. package/examples/learning/submit.py +1 -1
  255. package/examples/learning/submit.ts +2 -2
  256. package/examples/training/continual.ts +4 -4
  257. package/examples/training/manual.ts +1 -3
  258. package/fixtures/python-foundation/operation-matrix.json +369 -0
  259. package/fixtures/python-foundation/schemas.json +37612 -30866
  260. package/fixtures/python-foundation/training-estimate-http-workflow.json +1 -1
  261. package/package.json +3 -2
  262. package/dist/chunk-2OVNKPBZ.js.map +0 -1
  263. package/dist/chunk-3B5KSH3V.js.map +0 -1
  264. package/dist/chunk-3MWFN7BA.js.map +0 -1
  265. package/dist/chunk-47THZRUM.js.map +0 -1
  266. package/dist/chunk-626JLH4D.js.map +0 -1
  267. package/dist/chunk-BRP3EBCR.js +0 -245
  268. package/dist/chunk-BRP3EBCR.js.map +0 -1
  269. package/dist/chunk-C3TS766N.js.map +0 -1
  270. package/dist/chunk-DH6O4JFB.js.map +0 -1
  271. package/dist/chunk-GX6KMHW2.js.map +0 -1
  272. package/dist/chunk-IXFUYPGV.js.map +0 -1
  273. package/dist/chunk-JMFYNIYZ.js.map +0 -1
  274. package/dist/chunk-MVAEE5EI.js.map +0 -1
  275. package/dist/chunk-PMVSO23F.js.map +0 -1
  276. package/dist/chunk-QOX57Y27.js.map +0 -1
  277. package/dist/chunk-QRYEXPG7.js.map +0 -1
  278. package/dist/chunk-YV6PPDXZ.js.map +0 -1
  279. package/dist/chunk-Z252BNAZ.js.map +0 -1
  280. package/dist/chunk-Z5APNTZE.js.map +0 -1
  281. /package/dist/{chunk-GS5HEE4M.js.map → chunk-4D4QSQC3.js.map} +0 -0
  282. /package/dist/{chunk-3VUF5H3B.js.map → chunk-534W2O2S.js.map} +0 -0
  283. /package/dist/{chunk-ZRTNR4U7.js.map → chunk-5KJY44FB.js.map} +0 -0
  284. /package/dist/{chunk-RTLJV4OS.js.map → chunk-7ZV626YS.js.map} +0 -0
  285. /package/dist/{chunk-YS7DF76T.js.map → chunk-ABOZV47D.js.map} +0 -0
  286. /package/dist/{chunk-DDCR4KB5.js.map → chunk-BIQ5TG3T.js.map} +0 -0
  287. /package/dist/{chunk-JOMZJXGC.js.map → chunk-BT6CC6QB.js.map} +0 -0
  288. /package/dist/{chunk-RN5MK7NH.js.map → chunk-CVYGJUWM.js.map} +0 -0
  289. /package/dist/{chunk-QNOCM5JX.js.map → chunk-CX7ETU2F.js.map} +0 -0
  290. /package/dist/{chunk-EZME7DV4.js.map → chunk-D7LV3USE.js.map} +0 -0
  291. /package/dist/{chunk-7F43U2NC.js.map → chunk-GA7OSSEA.js.map} +0 -0
  292. /package/dist/{chunk-T67LNKAK.js.map → chunk-GFWXDWEE.js.map} +0 -0
  293. /package/dist/{chunk-GV6DEDBU.js.map → chunk-K4WU4JOP.js.map} +0 -0
  294. /package/dist/{chunk-3G3HUA32.js.map → chunk-LRFVISLA.js.map} +0 -0
  295. /package/dist/{chunk-ZQFROKKS.js.map → chunk-MJHQMQEW.js.map} +0 -0
  296. /package/dist/{chunk-BJMENXR4.js.map → chunk-TX552FQG.js.map} +0 -0
  297. /package/dist/{chunk-XBFOFTK3.js.map → chunk-VIDRZCPQ.js.map} +0 -0
package/LEARNING.md CHANGED
@@ -11,7 +11,7 @@ formats first. The sample uses an input object with `question` and an output
11
11
  object with `answer`; adapt the record to your published format. The scripts read
12
12
  the source's exact task-definition reference from the server.
13
13
 
14
- Set `OPENPOND_API_KEY`, `OPENPOND_API_URL` and `OPENPOND_LEARNING_SCOPE` in your
14
+ Set `OPENPOND_API_KEY` and `OPENPOND_LEARNING_SCOPE` in your
15
15
  shell, then run one of:
16
16
 
17
17
  ```sh
@@ -19,12 +19,10 @@ node --experimental-strip-types submit.ts SOURCE_ID example.json
19
19
  python3 submit.py SOURCE_ID example.json
20
20
  ```
21
21
 
22
- Use the URL of the execution owner: a local OpenPond server or the hosted API
23
- where the learning service is deployed. The server authorizes the requested
24
- profile/team scope. The SDK and Python example send the selected scope in
25
- `X-OpenPond-Team-Id` so hosted requests select that team before authorization;
26
- the local server uses the profile scope in the request body. These variables are example configuration, not arguments
27
- that should be committed with credentials.
22
+ The SDK connects to OpenPond automatically. The server authorizes the requested
23
+ workspace scope. The SDK and Python example send that scope in
24
+ `X-OpenPond-Team-Id`. Keep credentials in your application's secret configuration.
25
+ Do not commit their values.
28
26
 
29
27
  Assign stable example/attempt identities and preserve `idempotencyKey`, timestamp
30
28
  and content on retries. A different record must use a different key. Submission
package/OPENTELEMETRY.md CHANGED
@@ -19,7 +19,7 @@ import { OpenPondClient } from "openpond-sdk";
19
19
  import { OpenPondSpanExporter } from "openpond-sdk/opentelemetry";
20
20
  import { BatchSpanProcessor, TracerProvider } from "@opentelemetry/sdk-trace";
21
21
 
22
- const client = new OpenPondClient({ baseUrl: apiBaseUrl, apiKey, teamId });
22
+ const client = new OpenPondClient({ apiKey, teamId });
23
23
  const exporter = new OpenPondSpanExporter({
24
24
  client,
25
25
  datasetId,
@@ -1,12 +1,8 @@
1
1
  # Use OpenPond in your product
2
2
 
3
- The APIs below target the **0.12.25 source candidate**, which is not published
4
- yet. Registry version 0.12.24 does not include configured Dataset/named-model
5
- setup. Use the built candidate package until the coordinated release.
6
-
7
3
 
8
4
  Configure one application-owned server client. Bind aliases to exact callable
9
- Model IDs from your serving destination:
5
+ Model IDs from your OpenPond workspace:
10
6
 
11
7
  ```ts
12
8
  import { createOpenPondClient } from "openpond-sdk";
@@ -15,10 +11,6 @@ export const openpond = createOpenPondClient({
15
11
  apiKey: process.env.OPENPOND_API_KEY!,
16
12
  teamId: process.env.OPENPOND_TEAM_ID!,
17
13
  datasetId: process.env.OPENPOND_DATASET_ID!,
18
- serving: {
19
- baseUrl: process.env.OPENPOND_SERVING_BASE_URL!,
20
- apiKey: process.env.OPENPOND_SERVING_API_KEY!,
21
- },
22
14
  models: { support: process.env.OPENPOND_MODEL_ID! },
23
15
  });
24
16
 
@@ -26,10 +18,10 @@ const answer = await openpond.models.support.generate({ prompt: "How do I rotate
26
18
  console.log(answer.text, answer.requestId, answer.usage);
27
19
  ```
28
20
 
29
- `serving.baseUrl` is the personalized OpenAI-compatible Chat Completions base URL,
30
- including its `/v1` path. It is configured explicitly: no catalogue default or
31
- substitute Model is selected. Omit `serving.apiKey` only when this destination
32
- accepts the main API key. Naming a Model never activates serving, approves a
21
+ The SDK connects to OpenPond with your API key for task submission and personalized
22
+ inference. Use a key authorized for the selected Dataset and Model. A Dataset-only
23
+ producer key cannot invoke inference. Bind the exact callable Model ID; no
24
+ catalogue default or substitute Model is selected. Naming a Model never activates serving, approves a
33
25
  candidate, starts training, or automatically captures inference as a task.
34
26
  Decision scorers use their separate typed scoring APIs.
35
27
 
@@ -52,7 +44,7 @@ for await (const event of openpond.models.support.stream({ prompt: "Explain toke
52
44
  Breaking the iteration cancels the response. An interrupted stream raises
53
45
  `ProductModelError` and never emits a successful `finish`. It may already have
54
46
  incurred usage; inference is never automatically replayed. `serving.timeoutMs`
55
- defaults to 60 seconds and accepts at most 300 seconds. Supply a caller abort
47
+ defaults to 630 seconds and accepts at most 630 seconds, bounded by the signed request deadline and response allowance. Queued requests return HTTP 202; the SDK observes the original retained request by GET and never repeats the paid POST. Unknown outcomes retain `requestId` and `clientRequestId`; use `inspectRequest` or `recover` on the same Model handle. Supply a caller abort
56
48
  signal to cancel an individual request. Text requests are bounded to 1 MiB and
57
49
  results to 8 MiB; individual stream frames to 1 MiB.
58
50
 
@@ -66,9 +58,8 @@ the delivery error or pretending the answer failed. See [task ingestion](TASK_IN
66
58
  from ponder_sdk import AsyncClient
67
59
 
68
60
  async with AsyncClient(
69
- base_url=api_origin, api_key=api_key, team_id=team_id,
61
+ api_key=api_key, team_id=team_id,
70
62
  dataset_id=dataset_id,
71
- serving_base_url=serving_base_url, serving_api_key=serving_api_key,
72
63
  model_aliases={"support": model_id},
73
64
  ) as openpond:
74
65
  answer = await openpond.models.support.generate(prompt="How do I rotate a token?")
@@ -110,6 +101,17 @@ export async function POST(request: Request) {
110
101
  }
111
102
  ```
112
103
 
104
+ The adapter shares the named Model's timeout, request identity and GET-only
105
+ pending observation. After a queued request completes, streaming returns the
106
+ retained text or tool calls followed by usage and finish metadata. It does not
107
+ start another generation or resume native token delivery. On an unknown outcome,
108
+ retain `ProductModelError.clientRequestId` and use the original named Model's
109
+ `recover` method; aborting observation does not cancel retained server work.
110
+ For a binding with `capabilities.tools: true`, `recover` and `inspectRequest` return
111
+ retained calls in `status.result.toolCalls`, with each original `id`, function
112
+ `name` and JSON-text `arguments`. Recovery never executes those calls. The direct
113
+ `generate` and `stream` methods remain text-only and reject tool-call outputs.
114
+
113
115
  Use the AI SDK 7 React `useChat`/transport recipe against your own authenticated
114
116
  backend. Never place the OpenPond client or secrets in browser code. AI SDK's UI
115
117
  stream response is different from raw OpenAI SSE; use
package/README.md CHANGED
@@ -20,7 +20,7 @@ Node.js 22.14 or newer is required. This package is server-only: never expose an
20
20
 
21
21
  `OpenPondExperimentsClient` from `openpond-sdk/experiments` admits one run and its
22
22
  immutable configuration with `run(configuration)`. It is also available as
23
- `createOpenPondClient({ apiKey, baseUrl }).experiments(teamId)`. The request includes
23
+ `createOpenPondClient({ apiKey }).experiments(teamId)`. The request includes
24
24
  one stable operation ID (also on its nested request), dataset/population,
25
25
  target/settings, selected graders and spending cap. Reuse the same operation ID
26
26
  after a transport failure; it returns the same Experiment without duplicate work.
@@ -43,19 +43,11 @@ source, package, model and case identities before accepting a run.
43
43
 
44
44
  ## Next.js route handler
45
45
 
46
- Sandbox and model configuration are independently optional. With only `apiKey`,
47
- Work uses OpenPond's hosted defaults. To run tools in your installed runtime while
48
- keeping the hosted model, add `sandbox: { endpoint, apiKey }`. To choose a model,
49
- add `model: { endpoint, apiKey, model }`, where `endpoint` is an OpenAI-compatible
50
- Chat Completions base URL. Each override requires its own credential; credentials
51
- are never borrowed from another service. Both overrides together allow omitting
52
- the hosted `apiKey` for Work.
46
+ With your `apiKey`, Work uses OpenPond’s hosted defaults.
53
47
 
54
48
  The customer runtime uses fresh guests for subsequent turns. Persist history and
55
49
  outputs in your application, then pass them into the next run. A failed output
56
- save retains the guest for recovery; retry persistence before deleting it. Hosted
57
- repository provisioning and spending budgets do not apply to a custom runtime.
58
- An optional UUID `requestId` lets an application reconcile interrupted allocations
50
+ save retains the guest for recovery; retry persistence before deleting it. An optional UUID `requestId` lets an application reconcile interrupted allocations
59
51
  through sandbox metadata; it does not replay model or tool operations.
60
52
 
61
53
  ```ts
@@ -67,7 +59,6 @@ export const maxDuration = 800;
67
59
 
68
60
  const openpond = createOpenPondClient({
69
61
  apiKey: process.env.OPENPOND_API_KEY!,
70
- baseUrl: process.env.OPENPOND_API_URL,
71
62
  });
72
63
 
73
64
  export async function POST(request: Request) {
@@ -392,7 +383,7 @@ not implicitly share a spending cap.
392
383
 
393
384
  ## Add production tasks
394
385
 
395
- The configured API targets unpublished source candidate **0.12.25**; registry 0.12.24 does not provide it. Configure `datasetId` once and await `client.addTask({ id: sourceEventId, name, input })`. Use `client.dataset(otherDatasetId).addTask(task)` for another destination. See [task ingestion](TASK_INGESTION.md) for TypeScript/Python examples, receipt semantics and duplicate-safe retries. Task uploads do not enable training.
386
+ Configure `datasetId` once and await `client.addTask({ id: sourceEventId, name, input })`. Use `client.dataset(otherDatasetId).addTask(task)` for another destination. See [task ingestion](TASK_INGESTION.md) for TypeScript/Python examples, receipt semantics and duplicate-safe retries. Task uploads do not enable training.
396
387
 
397
388
  Dataset workspace HTTP failures throw `DatasetWorkspaceRequestError` from
398
389
  `openpond-sdk/dataset-workspaces`, with `status`, an allowlisted `code`,
@@ -403,4 +394,4 @@ bytes, recover its receipt with `operationResult`, or retry the identical reques
403
394
 
404
395
  ## Add OpenPond to a product
405
396
 
406
- Configure named personalized Model handles with `models` and an explicit `serving` destination, then call `client.models.support.generate({ prompt })` or iterate `stream({ prompt })`. See [product integration](PRODUCT_INTEGRATION.md) for TypeScript, Python, React/backend and optional Vercel AI SDK 7 examples. Inference never activates serving or automatically captures tasks.
397
+ Configure named personalized Model handles with `models` and your API key, then call `client.models.support.generate({ prompt })` or iterate `stream({ prompt })`. See [product integration](PRODUCT_INTEGRATION.md) for TypeScript, Python, React/backend and optional Vercel AI SDK 7 examples. Inference never activates serving or automatically captures tasks.
@@ -0,0 +1,54 @@
1
+ # Saved Model serving
2
+
3
+ Read `training.modelServing(modelProjectId, { teamId, versionHash })` for the
4
+ exact saved version. Create an approval from its `serverlessReview` with
5
+ `createServerlessServingApproval` from `openpond-sdk/training`, then include it
6
+ in `training.controlModelServing`. Retain the original operation ID and exact
7
+ request.
8
+
9
+ Read status to follow waiting, starting, running and stopping. Stop requests
10
+ cancellation of the original work; status remains readable while stopping.
11
+
12
+ The signed review's `workerIdleTimeoutSeconds` sets the billable idle reuse
13
+ window. Current v3 reviews support 5 or 60 seconds; new reviews use 60 seconds
14
+ before unused capacity scales to zero. The activation request must use the
15
+ reviewed value. Historical v1/v2 reviews retain their signed 5-second setting.
16
+ For v3, `idleBillable: true` includes this reuse window in accepted usage.
17
+
18
+ ## Pending inference and recovery
19
+
20
+ A queued serving POST returns HTTP 202 with an
21
+ `openpond.modelRequestStatus.v1` receipt. The SDK observes that original request
22
+ with GET requests until its retained result or bounded observer deadline. It
23
+ never resubmits the paid POST. The default observer is 630 seconds;
24
+ `serving.timeoutMs` can shorten it. A queued `stream()` call emits the retained
25
+ completed text and finish event when available.
26
+
27
+ Every SDK call creates a stable `clientRequestId` before POST. You may supply
28
+ one explicitly. If observation ends with an unknown outcome, retain both IDs
29
+ from `ProductModelError` and recover the original operation:
30
+
31
+ ```ts
32
+ try {
33
+ const answer = await model.generate({ prompt: "Explain the result." });
34
+ } catch (error) {
35
+ if (error instanceof ProductModelError && error.outcomeUnknown && error.clientRequestId) {
36
+ const status = await model.recover(error.clientRequestId);
37
+ // status.result is present when the original operation has completed.
38
+ }
39
+ }
40
+ ```
41
+
42
+ `model.inspectRequest(requestId)` reads by canonical request ID;
43
+ `model.cancelRequest(requestId)` explicitly requests cancellation. Recovery
44
+ checks the original actor, current access and exact model identity. Retained
45
+ answers expire after the service's finite retention period. Recovery never
46
+ resubmits the original request.
47
+
48
+ Python uses the same generated serving contracts and
49
+ `create_serverless_serving_approval` from `ponder_sdk.serverless_serving`.
50
+ Named model calls accept `client_request_id` and a serving-only `timeout`
51
+ (default and maximum 630 seconds). Use `recover`, `inspect_request` and
52
+ `cancel_request` on the same handle, awaiting them on `AsyncClient`.
53
+ `ModelRequestError.client_request_id` retains the original operation identity.
54
+ The official hosted Model-serving CLI operations use these same contracts.
package/TASKSETS.md CHANGED
@@ -8,7 +8,6 @@ optional Model Project attachment filtering before returning records.
8
8
  import { OpenPondTasksetCatalogClient } from "openpond-sdk/taskset-catalog";
9
9
 
10
10
  const tasksets = new OpenPondTasksetCatalogClient({
11
- baseUrl: "https://api.openpond.ai",
12
11
  apiKey,
13
12
  teamId,
14
13
  });
@@ -262,7 +261,7 @@ Imported source still requires explicit source review before publication.
262
261
 
263
262
  `OpenPondTasksetDraftClient` from `openpond-sdk/taskset-drafts` defines the
264
263
  scoped `/v1/models/:modelId/taskset-drafts` protocol. Construct it in server code
265
- with `baseUrl`, `apiKey` and `teamId`. It supports source inspection,
264
+ with `apiKey` and `teamId`. It supports source inspection,
266
265
  initialization, listing, document/file reads and edits, explicit Model refresh,
267
266
  validation, publication and deletion. Hosting these endpoints requires a server
268
267
  implementation; exporting this client alone does not make them available.
package/TASK_INGESTION.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Add tasks to a Dataset
2
2
 
3
- The APIs below target the **0.12.25 source candidate**, which is not published
4
- yet. Registry version 0.12.24 does not include configured Dataset/named-model
5
- setup. Use the built candidate package until the coordinated release.
6
-
7
3
 
8
4
  Configure a client once in your product's server module. Submit one structured
9
5
  source event with `await addTask(task)`:
@@ -26,9 +22,8 @@ const receipt = await openpond.addTask({
26
22
  console.log(receipt.taskId, receipt.receivedAt);
27
23
  ```
28
24
 
29
- Use `baseUrl` for a different OpenPond API origin. Each configured client keeps
30
- its own credentials and destination; no mutable global account is used. For an
31
- explicit alternate Dataset:
25
+ The client connects to OpenPond automatically and keeps its own credentials;
26
+ no mutable global account is used. For an explicit alternate Dataset:
32
27
 
33
28
  ```ts
34
29
  await openpond.dataset(otherDatasetId).addTask({
@@ -94,7 +89,7 @@ owned connection pool:
94
89
  ```python
95
90
  from ponder_sdk import Client
96
91
 
97
- with Client(base_url=api_origin, api_key=api_key, team_id=team_id,
92
+ with Client(api_key=api_key, team_id=team_id,
98
93
  dataset_id=dataset_id) as openpond:
99
94
  receipt = openpond.add_task({
100
95
  "id": source_event_id,
@@ -205,7 +205,7 @@ and an in-memory asset map without creating a training job or acquiring compute.
205
205
 
206
206
  The compiler verifies selected release identities and private verifier bytes,
207
207
  checks training/evaluation isolation, and rejects missing or unexpected Work
208
- assets. Callers retain responsibility for authorizing the inputs and staging the
208
+ assets. Callers retain responsibility for authorizing the inputs and preparing the
209
209
  result through the training artifact API before job admission. Filesystem cache
210
210
  materialization remains a Desktop concern.
211
211
 
@@ -9,8 +9,8 @@ the actual host/account before preparing work.
9
9
 
10
10
  ## Authentication and lifecycle
11
11
 
12
- Training and Model clients accept `baseUrl`, `headers` (including an async token
13
- supplier) and an injectable `fetch`. Use the host's normal Bearer credential and
12
+ Training and Model clients connect to OpenPond automatically. They accept
13
+ `headers` (including an async token supplier) and an injectable `fetch`. Use your API key as the Bearer credential and
14
14
  `X-OpenPond-Team-Id`; retain server authorization and owner checks. Learning,
15
15
  Dataset and taskset-run clients accept their existing `apiKey` and workspace
16
16
  scope. Never put credentials in URLs, request identities, fixtures or receipts.
@@ -204,8 +204,7 @@ the job controls and keep its identity.
204
204
  explicit `recordCandidateDecision` with its exact artifact reference and CAS.
205
205
  `cancel` reconciles the current job version before sending remote cancellation.
206
206
 
207
- The examples require `OPENPOND_API_URL`, `OPENPOND_API_KEY` and
208
- `OPENPOND_TEAM_ID` from the caller's normal configured account. They use only
207
+ The examples require `OPENPOND_API_KEY` and `OPENPOND_TEAM_ID` from the caller's normal configured account. They use only
209
208
  public SDK imports, bound each invocation to two minutes and write new receipt
210
209
  files exclusively with mode0600. They do not poll indefinitely or automatically
211
210
  retry an uncertain paid start. Keep the original receipt for future reconciliation.
@@ -495,9 +494,9 @@ of `neuron_steering` and `inspect_activations`. `draftSchema` describes the form
495
494
  not permission to write or execute.
496
495
 
497
496
  Each capability observation retains `validationLevel`: `null` when execution is
498
- unavailable, `source_validated` for an experimental staging runtime, or
497
+ unavailable, `source_validated` for an experimental runtime, or
499
498
  `gpu_qualified` after a retained exact-model/runtime GPU run. Source validation
500
- describes a runtime reviewed for an experimental staging trial; it is not
499
+ describes a runtime reviewed for an experimental trial; it is not
501
500
  evidence that training or inference has already succeeded. Read the runtime's retained evidence; neither level
502
501
  reserves compute, approves a charge or establishes model quality. Engram,
503
502
  Decision, AlphaEdit and neuron-training capabilities use the same distinction.
@@ -669,3 +668,9 @@ optimizer creation and exports a cumulative patch with parent, initial and
669
668
  final state hashes. A runtime must explicitly advertise this mode before
670
669
  admission; source packaging alone does not establish native qualification or
671
670
  old/new held-out retention.
671
+
672
+ ### Managed GRPO sampling support
673
+
674
+ Use `topP: 1` for managed GRPO. The current qualified trainer replays temperature and the retained required-tool grammar; it cannot replay an independent nucleus filter or separate JSON response grammar. Unsupported generation settings are rejected during preparation, before allocation. Structured Work output uses its supported required-tool path. Existing saved requests retain their explicit settings and are never silently rewritten.
675
+
676
+ The current managed runtime admits at least two optimizer iterations. A single iteration is not inherently invalid GRPO, but needs explicit support from the selected runtime before it can be prepared. Each iteration accumulates the entire trajectory group before stepping; `gradientAccumulationSteps` does not define separate optimizer windows for GRPO. SFT uses its own true batch accumulation and exact model/image limits. Held-out SFT evaluation does not select optimizer updates.
@@ -12,19 +12,20 @@ import {
12
12
  sealAdvancedRefinerEvaluationPin,
13
13
  sealAdvancedRefinerReviewReceipt,
14
14
  verifyAdvancedRefinerEvaluationPin
15
- } from "./chunk-RN5MK7NH.js";
16
- import "./chunk-QNOCM5JX.js";
17
- import "./chunk-3B5KSH3V.js";
18
- import "./chunk-626JLH4D.js";
15
+ } from "./chunk-CVYGJUWM.js";
16
+ import "./chunk-CX7ETU2F.js";
17
+ import "./chunk-456F3BXD.js";
18
+ import "./chunk-TMNEDWA7.js";
19
19
  import "./chunk-O6FKHAWN.js";
20
20
  import "./chunk-H3367ISL.js";
21
- import "./chunk-GS5HEE4M.js";
22
- import "./chunk-ZRTNR4U7.js";
23
- import "./chunk-JMFYNIYZ.js";
24
- import "./chunk-MVAEE5EI.js";
21
+ import "./chunk-4D4QSQC3.js";
22
+ import "./chunk-5KJY44FB.js";
23
+ import "./chunk-L7MVGGBH.js";
24
+ import "./chunk-WJZHSIGD.js";
25
25
  import "./chunk-CL3IOOVL.js";
26
26
  import "./chunk-B3ZHJ2KK.js";
27
27
  import "./chunk-H3JZ3P5T.js";
28
+ import "./chunk-QYWPNNP3.js";
28
29
  import "./chunk-YLJ4XMA6.js";
29
30
  export {
30
31
  AdvancedRefinerEvaluationAccountingSchema,
package/dist/ai-sdk.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  ProductModelError,
3
+ ProductModelTransport,
3
4
  productModelEndpoint
4
- } from "./chunk-BRP3EBCR.js";
5
+ } from "./chunk-ON3KSXWR.js";
5
6
  import "./chunk-B3ZHJ2KK.js";
7
+ import "./chunk-QYWPNNP3.js";
6
8
  import "./chunk-YLJ4XMA6.js";
7
9
 
8
10
  // src/ai-sdk.ts
@@ -10,72 +12,6 @@ import {
10
12
  createOpenAICompatible
11
13
  } from "@ai-sdk/openai-compatible";
12
14
  import { z } from "zod";
13
-
14
- // src/product-model-response.ts
15
- function boundProductModelResponse(response) {
16
- if (!response.body) return response;
17
- const streaming = response.headers.get("content-type")?.includes("text/event-stream") ?? false;
18
- const reader = response.body.getReader();
19
- const decoder = new TextDecoder();
20
- let total = 0, pending = "", terminal = false;
21
- let identity;
22
- const fail = () => new ProductModelError(
23
- streaming ? "model_stream_interrupted" : "model_response_invalid",
24
- response.status,
25
- true,
26
- response.headers.get("x-openpond-request-id") ?? response.headers.get("x-request-id") ?? void 0
27
- );
28
- const body = new ReadableStream({
29
- async pull(controller) {
30
- try {
31
- const { done, value } = await reader.read();
32
- if (done) {
33
- if (streaming && !terminal) throw fail();
34
- controller.close();
35
- reader.releaseLock();
36
- return;
37
- }
38
- total += value.byteLength;
39
- if (total > 8 * 1024 * 1024) throw fail();
40
- if (streaming) {
41
- pending = (pending + decoder.decode(value, { stream: true })).replace(/\r\n/g, "\n");
42
- let boundary;
43
- while ((boundary = pending.indexOf("\n\n")) >= 0) {
44
- const frame = pending.slice(0, boundary);
45
- pending = pending.slice(boundary + 2);
46
- if (new TextEncoder().encode(frame).length > 1024 * 1024) throw fail();
47
- const data = frame.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
48
- if (data === "[DONE]") terminal = true;
49
- else if (data) {
50
- const chunk = JSON.parse(data);
51
- if (typeof chunk.id === "string" && typeof chunk.model === "string") {
52
- if (identity && (chunk.id !== identity.id || chunk.model !== identity.model))
53
- throw fail();
54
- identity = { id: chunk.id, model: chunk.model };
55
- }
56
- }
57
- }
58
- if (new TextEncoder().encode(pending).length > 1024 * 1024) throw fail();
59
- }
60
- controller.enqueue(value);
61
- } catch {
62
- await reader.cancel().catch(() => {
63
- });
64
- controller.error(fail());
65
- }
66
- },
67
- async cancel(reason) {
68
- await reader.cancel(reason);
69
- }
70
- });
71
- return new Response(body, {
72
- status: response.status,
73
- statusText: response.statusText,
74
- headers: response.headers
75
- });
76
- }
77
-
78
- // src/ai-sdk.ts
79
15
  var Evidence = z.object({ openpond: z.record(z.string(), z.json()) }).passthrough();
80
16
  function metadata(raw) {
81
17
  const value = Evidence.safeParse(raw);
@@ -83,6 +19,7 @@ function metadata(raw) {
83
19
  }
84
20
  function toAIModel(model) {
85
21
  const connection = model.providerConnection();
22
+ const transport = new ProductModelTransport(model.id, connection);
86
23
  const provider = createOpenAICompatible({
87
24
  name: "openpond",
88
25
  baseURL: productModelEndpoint(connection.baseUrl),
@@ -129,18 +66,14 @@ function toAIModel(model) {
129
66
  },
130
67
  supportsStructuredOutputs: model.capabilities.structuredOutput,
131
68
  fetch: async (url, init) => {
132
- const timeout = AbortSignal.timeout(connection.timeoutMs ?? 6e4);
133
- const headers = new Headers(init?.headers);
134
- headers.set("Authorization", `Bearer ${connection.apiKey}`);
135
- if (connection.teamId) headers.set("X-OpenPond-Team-Id", connection.teamId);
136
- return boundProductModelResponse(
137
- await (connection.fetch ?? fetch)(url, {
138
- ...init,
139
- redirect: "error",
140
- headers,
141
- signal: init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout
142
- })
143
- );
69
+ if (String(url) !== `${productModelEndpoint(connection.baseUrl)}/chat/completions` || init?.method?.toUpperCase() !== "POST" || typeof init.body !== "string")
70
+ throw new ProductModelError("transport_override_forbidden", 0, false);
71
+ const body = JSON.parse(init.body);
72
+ return transport.request(init.body, {
73
+ stream: body.stream === true,
74
+ headers: init.headers,
75
+ signal: init.signal
76
+ });
144
77
  }
145
78
  }).chatModel(model.id);
146
79
  const check = (options) => {
@@ -158,16 +91,21 @@ function toAIModel(model) {
158
91
  ))
159
92
  throw new ProductModelError("input_capability_unsupported", 0, false);
160
93
  };
161
- const normalizeError = (error) => {
94
+ const normalizeError = (error, streamHeaders) => {
162
95
  if (error instanceof ProductModelError) return error;
163
96
  if (error && typeof error === "object" && "cause" in error && error.cause instanceof ProductModelError)
164
97
  return error.cause;
165
98
  const status = error && typeof error === "object" && "statusCode" in error && typeof error.statusCode === "number" ? error.statusCode : 0;
166
99
  const unknown = status === 0 || status === 408 || status >= 500 || status >= 200 && status < 300;
100
+ const responseHeaders = error && typeof error === "object" && "responseHeaders" in error && error.responseHeaders && typeof error.responseHeaders === "object" ? error.responseHeaders : streamHeaders ?? {};
101
+ const requestId = responseHeaders["x-openpond-request-id"] ?? responseHeaders["x-request-id"];
102
+ const clientRequestId = responseHeaders["x-openpond-client-request-id"];
167
103
  return new ProductModelError(
168
104
  status >= 400 ? "model_request_rejected" : "model_outcome_unknown",
169
105
  status,
170
- unknown
106
+ unknown,
107
+ typeof requestId === "string" ? requestId : void 0,
108
+ typeof clientRequestId === "string" ? clientRequestId : void 0
171
109
  );
172
110
  };
173
111
  return {
@@ -201,10 +139,10 @@ function toAIModel(model) {
201
139
  reader.releaseLock();
202
140
  } else
203
141
  controller.enqueue(
204
- value.type === "error" ? { ...value, error: normalizeError(value.error) } : value
142
+ value.type === "error" ? { ...value, error: normalizeError(value.error, result.response?.headers) } : value
205
143
  );
206
144
  } catch (error) {
207
- controller.error(normalizeError(error));
145
+ controller.error(normalizeError(error, result.response?.headers));
208
146
  }
209
147
  },
210
148
  async cancel(reason) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ai-sdk.ts","../src/product-model-response.ts"],"sourcesContent":["/** Optional integration: AI SDK 7 / @ai-sdk/openai-compatible 3 (LanguageModelV4). */\nimport {\n createOpenAICompatible,\n type OpenAICompatibleChatLanguageModel,\n} from \"@ai-sdk/openai-compatible\";\nimport { z } from \"zod\";\nimport { boundProductModelResponse } from \"./product-model-response.js\";\nimport { ProductModel, ProductModelError, productModelEndpoint } from \"./product-models.js\";\n\nconst Evidence = z.object({ openpond: z.record(z.string(), z.json()) }).passthrough();\nfunction metadata(raw: unknown) {\n const value = Evidence.safeParse(raw);\n return value.success ? { openpond: value.data.openpond } : undefined;\n}\n\n/** Use generateText/streamText with maxRetries: 0; paid inference is never safely replayable implicitly. */\nexport function toAIModel(\n model: ProductModel,\n): Pick<\n OpenAICompatibleChatLanguageModel,\n \"specificationVersion\" | \"provider\" | \"modelId\" | \"supportedUrls\" | \"doGenerate\" | \"doStream\"\n> {\n const connection = model.providerConnection();\n const provider = createOpenAICompatible({\n name: \"openpond\",\n baseURL: productModelEndpoint(connection.baseUrl!),\n apiKey: connection.apiKey,\n // The personalized gateway always supplies terminal usage and rejects\n // OpenAI's optional stream_options field.\n includeUsage: false,\n headers: connection.teamId ? { \"X-OpenPond-Team-Id\": connection.teamId } : undefined,\n transformRequestBody: (raw) => {\n const body = JSON.parse(JSON.stringify(raw)) as Record<string, unknown>;\n if (body.model !== model.id)\n throw new ProductModelError(\"model_override_forbidden\", 0, false);\n const allowed = new Set([\n \"model\",\n \"messages\",\n \"stream\",\n \"max_tokens\",\n \"temperature\",\n \"top_p\",\n \"seed\",\n \"stop\",\n \"tools\",\n \"tool_choice\",\n ]);\n if (Object.keys(body).some((key) => !allowed.has(key)))\n throw new ProductModelError(\"parameter_unsupported\", 0, false);\n return body;\n },\n metadataExtractor: {\n async extractMetadata({ parsedBody }) {\n return metadata(parsedBody);\n },\n createStreamExtractor() {\n let evidence: ReturnType<typeof metadata>;\n return {\n processChunk(chunk) {\n evidence = metadata(chunk) ?? evidence;\n },\n buildMetadata() {\n return evidence;\n },\n };\n },\n },\n supportsStructuredOutputs: model.capabilities.structuredOutput,\n fetch: async (url, init) => {\n const timeout = AbortSignal.timeout(connection.timeoutMs ?? 60_000);\n const headers = new Headers(init?.headers);\n headers.set(\"Authorization\", `Bearer ${connection.apiKey}`);\n if (connection.teamId) headers.set(\"X-OpenPond-Team-Id\", connection.teamId);\n return boundProductModelResponse(\n await (connection.fetch ?? fetch)(url, {\n ...init,\n redirect: \"error\",\n headers,\n signal: init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout,\n }),\n );\n },\n }).chatModel(model.id);\n const check = (options: Parameters<typeof provider.doGenerate>[0]) => {\n const rawOptions = options.providerOptions?.openpond;\n if (rawOptions && [\"stream\", \"stream_options\"].some((key) => key in rawOptions))\n throw new ProductModelError(\"transport_override_forbidden\", 0, false);\n if (options.tools?.length && !model.capabilities.tools)\n throw new ProductModelError(\"tools_unsupported\", 0, false);\n if (options.responseFormat?.type === \"json\")\n throw new ProductModelError(\"structured_output_unsupported\", 0, false);\n if (\n options.prompt.some(\n (message) =>\n (message.role === \"tool\" && !model.capabilities.tools) ||\n (message.role !== \"system\" &&\n message.content.some(\n (part) =>\n part.type !== \"text\" &&\n !(model.capabilities.tools && [\"tool-call\", \"tool-result\"].includes(part.type)),\n )),\n )\n )\n throw new ProductModelError(\"input_capability_unsupported\", 0, false);\n };\n // Convert retryable transport errors to a terminal SDK error: AI SDK's default\n // automatic retries must not accidentally duplicate a billed generation.\n const normalizeError = (error: unknown): ProductModelError => {\n if (error instanceof ProductModelError) return error;\n if (\n error &&\n typeof error === \"object\" &&\n \"cause\" in error &&\n error.cause instanceof ProductModelError\n )\n return error.cause;\n const status =\n error &&\n typeof error === \"object\" &&\n \"statusCode\" in error &&\n typeof error.statusCode === \"number\"\n ? error.statusCode\n : 0;\n const unknown =\n status === 0 || status === 408 || status >= 500 || (status >= 200 && status < 300);\n return new ProductModelError(\n status >= 400 ? \"model_request_rejected\" : \"model_outcome_unknown\",\n status,\n unknown,\n );\n };\n return {\n specificationVersion: provider.specificationVersion,\n provider: provider.provider,\n modelId: provider.modelId,\n supportedUrls: provider.supportedUrls,\n async doGenerate(options: Parameters<typeof provider.doGenerate>[0]) {\n check(options);\n try {\n return await provider.doGenerate(options);\n } catch (error) {\n throw normalizeError(error);\n }\n },\n async doStream(options: Parameters<typeof provider.doStream>[0]) {\n check(options);\n if (!model.capabilities.streaming)\n throw new ProductModelError(\"streaming_unsupported\", 0, false);\n try {\n const result = await provider.doStream(options);\n const reader = result.stream.getReader();\n return {\n ...result,\n stream: new ReadableStream({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n reader.releaseLock();\n } else\n controller.enqueue(\n value.type === \"error\"\n ? { ...value, error: normalizeError(value.error) }\n : value,\n );\n } catch (error) {\n controller.error(normalizeError(error));\n }\n },\n async cancel(reason) {\n await reader.cancel(reason);\n },\n }),\n };\n } catch (error) {\n throw normalizeError(error);\n }\n },\n };\n}\n","import { ProductModelError } from \"./product-models.js\";\n\n/** Bound the optional provider's otherwise unbounded parser and require the\n * personalized gateway's terminal marker before treating EOF as completion. */\nexport function boundProductModelResponse(response: Response): Response {\n if (!response.body) return response;\n const streaming = response.headers.get(\"content-type\")?.includes(\"text/event-stream\") ?? false;\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let total = 0,\n pending = \"\",\n terminal = false;\n let identity: { id: string; model: string } | undefined;\n const fail = () =>\n new ProductModelError(\n streaming ? \"model_stream_interrupted\" : \"model_response_invalid\",\n response.status,\n true,\n response.headers.get(\"x-openpond-request-id\") ??\n response.headers.get(\"x-request-id\") ??\n undefined,\n );\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n if (streaming && !terminal) throw fail();\n controller.close();\n reader.releaseLock();\n return;\n }\n total += value.byteLength;\n if (total > 8 * 1024 * 1024) throw fail();\n if (streaming) {\n pending = (pending + decoder.decode(value, { stream: true })).replace(/\\r\\n/g, \"\\n\");\n let boundary: number;\n while ((boundary = pending.indexOf(\"\\n\\n\")) >= 0) {\n const frame = pending.slice(0, boundary);\n pending = pending.slice(boundary + 2);\n if (new TextEncoder().encode(frame).length > 1024 * 1024) throw fail();\n const data = frame\n .split(\"\\n\")\n .filter((line) => line.startsWith(\"data:\"))\n .map((line) => line.slice(5).trimStart())\n .join(\"\\n\");\n if (data === \"[DONE]\") terminal = true;\n else if (data) {\n const chunk = JSON.parse(data);\n if (typeof chunk.id === \"string\" && typeof chunk.model === \"string\") {\n if (identity && (chunk.id !== identity.id || chunk.model !== identity.model))\n throw fail();\n identity = { id: chunk.id, model: chunk.model };\n }\n }\n }\n if (new TextEncoder().encode(pending).length > 1024 * 1024) throw fail();\n }\n controller.enqueue(value);\n } catch {\n await reader.cancel().catch(() => {});\n controller.error(fail());\n }\n },\n async cancel(reason) {\n await reader.cancel(reason);\n },\n });\n return new Response(body, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n"],"mappings":";;;;;;;;AACA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,SAAS;;;ACDX,SAAS,0BAA0B,UAA8B;AACtE,MAAI,CAAC,SAAS,KAAM,QAAO;AAC3B,QAAM,YAAY,SAAS,QAAQ,IAAI,cAAc,GAAG,SAAS,mBAAmB,KAAK;AACzF,QAAM,SAAS,SAAS,KAAK,UAAU;AACvC,QAAM,UAAU,IAAI,YAAY;AAChC,MAAI,QAAQ,GACV,UAAU,IACV,WAAW;AACb,MAAI;AACJ,QAAM,OAAO,MACX,IAAI;AAAA,IACF,YAAY,6BAA6B;AAAA,IACzC,SAAS;AAAA,IACT;AAAA,IACA,SAAS,QAAQ,IAAI,uBAAuB,KAC1C,SAAS,QAAQ,IAAI,cAAc,KACnC;AAAA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S,SAAS,OAAO;AAC9C,cAAM,SAAS,OAAO,OAAO,UAAU;AACvC,eAAO;AAAA,UACL,GAAG;AAAA,UACH,QAAQ,IAAI,eAAe;AAAA,YACzB,MAAM,KAAK,YAAY;AACrB,kBAAI;AACF,sBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,oBAAI,MAAM;AACR,6BAAW,MAAM;AACjB,yBAAO,YAAY;AAAA,gBACrB;AACE,6BAAW;AAAA,oBACT,MAAM,SAAS,UACX,EAAE,GAAG,OAAO,OAAO,eAAe,MAAM,KAAK,EAAE,IAC/C;AAAA,kBACN;AAAA,cACJ,SAAS,OAAO;AACd,2BAAW,MAAM,eAAe,KAAK,CAAC;AAAA,cACxC;AAAA,YACF;AAAA,YACA,MAAM,OAAO,QAAQ;AACnB,oBAAM,OAAO,OAAO,MAAM;AAAA,YAC5B;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,SAAS,OAAO;AACd,cAAM,eAAe,KAAK;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/ai-sdk.ts"],"sourcesContent":["/** Optional integration: AI SDK 7 / @ai-sdk/openai-compatible 3 (LanguageModelV4). */\nimport {\n createOpenAICompatible,\n type OpenAICompatibleChatLanguageModel,\n} from \"@ai-sdk/openai-compatible\";\nimport { z } from \"zod\";\nimport { ProductModelTransport } from \"./product-model-transport.js\";\nimport { ProductModel, ProductModelError, productModelEndpoint } from \"./product-models.js\";\n\nconst Evidence = z.object({ openpond: z.record(z.string(), z.json()) }).passthrough();\nfunction metadata(raw: unknown) {\n const value = Evidence.safeParse(raw);\n return value.success ? { openpond: value.data.openpond } : undefined;\n}\n\n/** Use generateText/streamText with maxRetries: 0; paid inference is never safely replayable implicitly. */\nexport function toAIModel(\n model: ProductModel,\n): Pick<\n OpenAICompatibleChatLanguageModel,\n \"specificationVersion\" | \"provider\" | \"modelId\" | \"supportedUrls\" | \"doGenerate\" | \"doStream\"\n> {\n const connection = model.providerConnection();\n const transport = new ProductModelTransport(model.id, connection);\n const provider = createOpenAICompatible({\n name: \"openpond\",\n baseURL: productModelEndpoint(connection.baseUrl!),\n apiKey: connection.apiKey,\n // The personalized gateway always supplies terminal usage and rejects\n // OpenAI's optional stream_options field.\n includeUsage: false,\n headers: connection.teamId ? { \"X-OpenPond-Team-Id\": connection.teamId } : undefined,\n transformRequestBody: (raw) => {\n const body = JSON.parse(JSON.stringify(raw)) as Record<string, unknown>;\n if (body.model !== model.id)\n throw new ProductModelError(\"model_override_forbidden\", 0, false);\n const allowed = new Set([\n \"model\",\n \"messages\",\n \"stream\",\n \"max_tokens\",\n \"temperature\",\n \"top_p\",\n \"seed\",\n \"stop\",\n \"tools\",\n \"tool_choice\",\n ]);\n if (Object.keys(body).some((key) => !allowed.has(key)))\n throw new ProductModelError(\"parameter_unsupported\", 0, false);\n return body;\n },\n metadataExtractor: {\n async extractMetadata({ parsedBody }) {\n return metadata(parsedBody);\n },\n createStreamExtractor() {\n let evidence: ReturnType<typeof metadata>;\n return {\n processChunk(chunk) {\n evidence = metadata(chunk) ?? evidence;\n },\n buildMetadata() {\n return evidence;\n },\n };\n },\n },\n supportsStructuredOutputs: model.capabilities.structuredOutput,\n fetch: async (url, init) => {\n // The provider only serializes/parses OpenAI-compatible payloads. All\n // submission, identity and pending observation belong to the shared wire\n // transport, including when this call asks for a stream.\n if (String(url) !== `${productModelEndpoint(connection.baseUrl!)}/chat/completions`\n || init?.method?.toUpperCase() !== \"POST\" || typeof init.body !== \"string\")\n throw new ProductModelError(\"transport_override_forbidden\", 0, false);\n const body = JSON.parse(init.body) as { stream?: boolean };\n return transport.request(init.body, { stream: body.stream === true,\n headers: init.headers, signal: init.signal });\n },\n }).chatModel(model.id);\n const check = (options: Parameters<typeof provider.doGenerate>[0]) => {\n const rawOptions = options.providerOptions?.openpond;\n if (rawOptions && [\"stream\", \"stream_options\"].some((key) => key in rawOptions))\n throw new ProductModelError(\"transport_override_forbidden\", 0, false);\n if (options.tools?.length && !model.capabilities.tools)\n throw new ProductModelError(\"tools_unsupported\", 0, false);\n if (options.responseFormat?.type === \"json\")\n throw new ProductModelError(\"structured_output_unsupported\", 0, false);\n if (\n options.prompt.some(\n (message) =>\n (message.role === \"tool\" && !model.capabilities.tools) ||\n (message.role !== \"system\" &&\n message.content.some(\n (part) =>\n part.type !== \"text\" &&\n !(model.capabilities.tools && [\"tool-call\", \"tool-result\"].includes(part.type)),\n )),\n )\n )\n throw new ProductModelError(\"input_capability_unsupported\", 0, false);\n };\n // Convert retryable transport errors to a terminal SDK error: AI SDK's default\n // automatic retries must not accidentally duplicate a billed generation.\n const normalizeError = (error: unknown, streamHeaders?: Record<string, string | undefined>): ProductModelError => {\n if (error instanceof ProductModelError) return error;\n if (\n error &&\n typeof error === \"object\" &&\n \"cause\" in error &&\n error.cause instanceof ProductModelError\n )\n return error.cause;\n const status =\n error &&\n typeof error === \"object\" &&\n \"statusCode\" in error &&\n typeof error.statusCode === \"number\"\n ? error.statusCode\n : 0;\n const unknown =\n status === 0 || status === 408 || status >= 500 || (status >= 200 && status < 300);\n const responseHeaders = error && typeof error === \"object\" && \"responseHeaders\" in error\n && error.responseHeaders && typeof error.responseHeaders === \"object\"\n ? error.responseHeaders as Record<string, unknown> : streamHeaders ?? {};\n const requestId = responseHeaders[\"x-openpond-request-id\"] ?? responseHeaders[\"x-request-id\"];\n const clientRequestId = responseHeaders[\"x-openpond-client-request-id\"];\n return new ProductModelError(\n status >= 400 ? \"model_request_rejected\" : \"model_outcome_unknown\",\n status,\n unknown,\n typeof requestId === \"string\" ? requestId : undefined,\n typeof clientRequestId === \"string\" ? clientRequestId : undefined,\n );\n };\n return {\n specificationVersion: provider.specificationVersion,\n provider: provider.provider,\n modelId: provider.modelId,\n supportedUrls: provider.supportedUrls,\n async doGenerate(options: Parameters<typeof provider.doGenerate>[0]) {\n check(options);\n try {\n return await provider.doGenerate(options);\n } catch (error) {\n throw normalizeError(error);\n }\n },\n async doStream(options: Parameters<typeof provider.doStream>[0]) {\n check(options);\n if (!model.capabilities.streaming)\n throw new ProductModelError(\"streaming_unsupported\", 0, false);\n try {\n const result = await provider.doStream(options);\n const reader = result.stream.getReader();\n return {\n ...result,\n stream: new ReadableStream({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n reader.releaseLock();\n } else\n controller.enqueue(\n value.type === \"error\"\n ? { ...value, error: normalizeError(value.error, result.response?.headers) }\n : value,\n );\n } catch (error) {\n controller.error(normalizeError(error, result.response?.headers));\n }\n },\n async cancel(reason) {\n await reader.cancel(reason);\n },\n }),\n };\n } catch (error) {\n throw normalizeError(error);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;AACA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,SAAS;AAIlB,IAAM,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,YAAY;AACpF,SAAS,SAAS,KAAc;AAC9B,QAAM,QAAQ,SAAS,UAAU,GAAG;AACpC,SAAO,MAAM,UAAU,EAAE,UAAU,MAAM,KAAK,SAAS,IAAI;AAC7D;AAGO,SAAS,UACd,OAIA;AACA,QAAM,aAAa,MAAM,mBAAmB;AAC5C,QAAM,YAAY,IAAI,sBAAsB,MAAM,IAAI,UAAU;AAChE,QAAM,WAAW,uBAAuB;AAAA,IACtC,MAAM;AAAA,IACN,SAAS,qBAAqB,WAAW,OAAQ;AAAA,IACjD,QAAQ,WAAW;AAAA;AAAA;AAAA,IAGnB,cAAc;AAAA,IACd,SAAS,WAAW,SAAS,EAAE,sBAAsB,WAAW,OAAO,IAAI;AAAA,IAC3E,sBAAsB,CAAC,QAAQ;AAC7B,YAAM,OAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AAC3C,UAAI,KAAK,UAAU,MAAM;AACvB,cAAM,IAAI,kBAAkB,4BAA4B,GAAG,KAAK;AAClE,YAAM,UA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AAAA,IACL,sBAAsB,SAAS;AAAA,IAC/B,UAAU,SAAS;AAAA,IACnB,SAAS,SAAS;AAAA,IAClB,eAAe,SAAS;AAAA,IACxB,MAAM,WAAW,SAAoD;AACnE,YAAM,OAAO;AACb,UAAI;AACF,eAAO,MAAM,SAAS,WAAW,OAAO;AAAA,MAC1C,SAAS,OAAO;AACd,cAAM,eAAe,KAAK;AAAA,MAC5B;AAAA,IACF;AAAA,IACA,MAAM,SAAS,SAAkD;AAC/D,YAAM,OAAO;AACb,UAAI,CAAC,MAAM,aAAa;AACtB,cAAM,IAAI,kBAAkB,yBAAyB,GAAG,KAAK;AAC/D,UAAI;AACF,cAAM,SAAS,MAAM,SAAS,SAAS,OAAO;AAC9C,cAAM,SAAS,OAAO,OAAO,UAAU;AACvC,eAAO;AAAA,UACL,GAAG;AAAA,UACH,QAAQ,IAAI,eAAe;AAAA,YACzB,MAAM,KAAK,YAAY;AACrB,kBAAI;AACF,sBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,oBAAI,MAAM;AACR,6BAAW,MAAM;AACjB,yBAAO,YAAY;AAAA,gBACrB;AACE,6BAAW;AAAA,oBACT,MAAM,SAAS,UACX,EAAE,GAAG,OAAO,OAAO,eAAe,MAAM,OAAO,OAAO,UAAU,OAAO,EAAE,IACzE;AAAA,kBACN;AAAA,cACJ,SAAS,OAAO;AACd,2BAAW,MAAM,eAAe,OAAO,OAAO,UAAU,OAAO,CAAC;AAAA,cAClE;AAAA,YACF;AAAA,YACA,MAAM,OAAO,QAAQ;AACnB,oBAAM,OAAO,OAAO,MAAM;AAAA,YAC5B;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,SAAS,OAAO;AACd,cAAM,eAAe,KAAK;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -5,15 +5,16 @@ import {
5
5
  CandidateEvaluationPreparationSchema,
6
6
  CandidateEvaluationRequestSchema,
7
7
  createCandidateEvaluationClient
8
- } from "./chunk-3VUF5H3B.js";
9
- import "./chunk-ZQFROKKS.js";
10
- import "./chunk-GS5HEE4M.js";
11
- import "./chunk-ZRTNR4U7.js";
12
- import "./chunk-JMFYNIYZ.js";
13
- import "./chunk-MVAEE5EI.js";
8
+ } from "./chunk-534W2O2S.js";
9
+ import "./chunk-MJHQMQEW.js";
10
+ import "./chunk-4D4QSQC3.js";
11
+ import "./chunk-5KJY44FB.js";
12
+ import "./chunk-L7MVGGBH.js";
13
+ import "./chunk-WJZHSIGD.js";
14
14
  import "./chunk-CL3IOOVL.js";
15
15
  import "./chunk-B3ZHJ2KK.js";
16
16
  import "./chunk-H3JZ3P5T.js";
17
+ import "./chunk-QYWPNNP3.js";
17
18
  import "./chunk-YLJ4XMA6.js";
18
19
  export {
19
20
  CandidateEvaluationControlSchema,