@desplega.ai/agent-swarm 1.131.0 → 1.133.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/README.md +2 -2
  2. package/dist/{actions-w53mbns9.js → actions-cskpayd7.js} +11 -9
  3. package/dist/{anthropic-messages-rjmd2e7n.js → anthropic-messages-tpxtbx7b.js} +28 -12
  4. package/dist/{app-m9gwqsqv.js → app-ang77nbb.js} +8 -6
  5. package/dist/{assistant-bp65m6f3.js → assistant-b4exebdw.js} +16 -13
  6. package/dist/{azure-openai-responses-c0yjmbfd.js → azure-openai-responses-m3921t4y.js} +8 -8
  7. package/dist/{boot-reembed-62p0at2k.js → boot-reembed-ps2aftpb.js} +9 -7
  8. package/dist/{boot-reembed-xmfp6wdh.js → boot-reembed-znyk3nxb.js} +10 -8
  9. package/dist/{boot-scrub-logs-rr8q2dms.js → boot-scrub-logs-2ax3xgz1.js} +7 -5
  10. package/dist/{claude-adapter-2y47mrkd.js → claude-adapter-3ct8kgxw.js} +13 -9
  11. package/dist/{claude-managed-adapter-gv19tdew.js → claude-managed-adapter-akx4ntf2.js} +2 -2
  12. package/dist/{cli-t1xze5qh.js → cli-13w2hwkh.js} +1 -1
  13. package/dist/{cli-efxfnq6q.js → cli-1532szb1.js} +8 -6
  14. package/dist/{cli-d2tfkcga.js → cli-23d3rseb.js} +33 -17
  15. package/dist/{cli-nm5gtp1x.js → cli-2a75z9c5.js} +196 -7
  16. package/dist/{cli-fywms69x.js → cli-2t30rj0d.js} +1 -1
  17. package/dist/{cli-cvgjwnh1.js → cli-3c3tdgab.js} +10 -10
  18. package/dist/{cli-pm6xbh84.js → cli-3zzxa9jz.js} +46 -16
  19. package/dist/{cli-cdeg08wx.js → cli-4k6233gc.js} +1 -1
  20. package/dist/{cli-t55yw3a1.js → cli-5p2tz05r.js} +2 -2
  21. package/dist/{cli-0rcyq6d9.js → cli-5z2yhzvd.js} +125 -47
  22. package/dist/{cli-3kf51j15.js → cli-6zfq31nj.js} +9 -3
  23. package/dist/{cli-er3a4bb0.js → cli-8m9de10a.js} +6 -1
  24. package/dist/{cli-gm9cbhbq.js → cli-8t14vg9w.js} +27 -8
  25. package/dist/{cli-72q8m8gk.js → cli-9nfc2es8.js} +6 -6
  26. package/dist/{cli-5ze9rv97.js → cli-9ta3pwms.js} +11 -4
  27. package/dist/{cli-78xwvkhj.js → cli-avr0ns7z.js} +2 -2
  28. package/dist/{cli-n6h8qt8n.js → cli-c897wyhw.js} +12 -7
  29. package/dist/{cli-2q72qz2s.js → cli-dgk20ft7.js} +15 -6
  30. package/dist/cli-et1bbwqf.js +13 -0
  31. package/dist/{cli-bqw0mt1n.js → cli-f5w27pj3.js} +3 -3
  32. package/dist/{cli-2wadx7p2.js → cli-f8dre4bz.js} +2 -2
  33. package/dist/{cli-e7ckcg4v.js → cli-ftwpv451.js} +170 -387
  34. package/dist/{cli-g6b8x1h8.js → cli-g854s2dw.js} +1 -1
  35. package/dist/{cli-5kx36evn.js → cli-ggmdxeqa.js} +13 -8
  36. package/dist/cli-hkwfe3qj.js +530 -0
  37. package/dist/{cli-5dsbcjjw.js → cli-jqwnqx9m.js} +1 -1
  38. package/dist/{cli-9dr5qzc0.js → cli-ny122vh4.js} +21 -10
  39. package/dist/{cli-5v4rw6yd.js → cli-pvzqhbs9.js} +2 -2
  40. package/dist/cli-pzq5rjym.js +15 -0
  41. package/dist/{cli-xpxde7rm.js → cli-qes8ef67.js} +48 -30
  42. package/dist/{cli-sajgpkqg.js → cli-qs9hhsvb.js} +1723 -325
  43. package/dist/cli-qys3rhhz.js +27 -0
  44. package/dist/{cli-rzbpmxdr.js → cli-r6tpm37h.js} +2 -2
  45. package/dist/{cli-qv61hp37.js → cli-rch80c76.js} +2 -2
  46. package/dist/{cli-0258203w.js → cli-rpp0x4zy.js} +137 -17
  47. package/dist/{cli-5n6e5yfn.js → cli-s1k0wxhe.js} +12 -7
  48. package/dist/{cli-psh3c4va.js → cli-sfd9v7sj.js} +1 -1
  49. package/dist/{cli-70xqj0z3.js → cli-sh3ytsyj.js} +49 -39
  50. package/dist/{cli-zsspvvm2.js → cli-w1mp9jy7.js} +1 -1
  51. package/dist/{cli-d3x3x1c9.js → cli-xdb4mpnp.js} +2 -2
  52. package/dist/{cli-57khth04.js → cli-xmyqv00z.js} +120 -4
  53. package/dist/{cli-yw8vghx2.js → cli-xv8t8p3c.js} +65 -32
  54. package/dist/{cli-f1am9szv.js → cli-xxv5pn4f.js} +1 -1
  55. package/dist/{cli-t76vw5db.js → cli-y08jvxzx.js} +601 -140
  56. package/dist/{cli-a4jzdpa3.js → cli-zfbf3srj.js} +650 -245
  57. package/dist/{cli-a40rnf71.js → cli-zmq89k34.js} +6 -6
  58. package/dist/{cli-qmdnhpej.js → cli-zr9q011v.js} +23 -13
  59. package/dist/cli.js +22 -22
  60. package/dist/{codex-adapter-d24q75wk.js → codex-adapter-bef93pq4.js} +9 -7
  61. package/dist/{codex-hook-hq54t9ft.js → codex-hook-e8dba65p.js} +3 -2
  62. package/dist/{codex-session-runner-g50vcsex.js → codex-session-runner-5pkxys7x.js} +9 -7
  63. package/dist/{commands-c3nrc5hg.js → commands-e23s1bff.js} +9 -7
  64. package/dist/{db-nt7fg3tw.js → db-m3nabatn.js} +17 -5
  65. package/dist/{google-generative-ai-hysrd8qx.js → google-generative-ai-8maw55xh.js} +11 -8
  66. package/dist/{google-vertex-p5arrga0.js → google-vertex-8vjqmx8g.js} +11 -8
  67. package/dist/{handlers-fkr6swat.js → handlers-akazedvr.js} +16 -13
  68. package/dist/{hook-77wpvnjc.js → hook-ze4cpf0v.js} +55 -41
  69. package/dist/{hook-g019yehy.js → hook-zfqyyenw.js} +10 -7
  70. package/dist/{http-jewj0syk.js → http-sja0n6kw.js} +730 -150
  71. package/dist/index-0gr8vd6k.js +39 -0
  72. package/dist/{index-7n2xpbd4.js → index-354vkhdv.js} +154 -74
  73. package/dist/{index-070v4eyb.js → index-5qthek5t.js} +2 -3
  74. package/dist/{index-hfvggd0z.js → index-95t3cqq5.js} +16 -14
  75. package/dist/{index-9znhar3x.js → index-sea66619.js} +3 -4
  76. package/dist/{index-6gm5he8h.js → index-vpn36mma.js} +15 -13
  77. package/dist/{keepalive-j0fjvqfd.js → keepalive-3sp3meqj.js} +16 -10
  78. package/dist/{lead-1n8x30xe.js → lead-mefeewkf.js} +39 -36
  79. package/dist/{maintenance-gvev11sa.js → maintenance-8tbrbjfg.js} +10 -8
  80. package/dist/mistral-conversations-00zrp7g4.js +717 -0
  81. package/dist/{oauth-refresh-sweep-s9ecsvh0.js → oauth-refresh-sweep-srjwjz6m.js} +8 -6
  82. package/dist/{onboard-pvm5b38w.js → onboard-mt2tgyjg.js} +7 -7
  83. package/dist/{openai-codex-responses-5g27pd6f.js → openai-codex-responses-map32h2s.js} +18 -18
  84. package/dist/{openai-completions-3vkmfz2a.js → openai-completions-w871b1cq.js} +12 -11
  85. package/dist/{openai-responses-dg4t7j7a.js → openai-responses-b0j7xnw8.js} +15 -12
  86. package/dist/{opencode-adapter-1gm38aba.js → opencode-adapter-b39jefcj.js} +5 -3
  87. package/dist/{openrouter-images-g3gm8931.js → openrouter-images-srfkywy0.js} +4 -4
  88. package/dist/{otel-impl-p6jvgd9c.js → otel-impl-z6pxt3j9.js} +224 -9
  89. package/dist/{pi-mono-adapter-t091s27g.js → pi-mono-adapter-btvqmj58.js} +1138 -408
  90. package/dist/{pricing-refresh-k49rcyed.js → pricing-refresh-kyq8cezh.js} +9 -7
  91. package/dist/{rbac-roles-cr80g96t.js → rbac-roles-3ryfrfna.js} +8 -6
  92. package/dist/{rbac-roles-30pspvy7.js → rbac-roles-6qfvbee1.js} +9 -7
  93. package/dist/{render-v2-xm457ng1.js → render-v2-p61ppjey.js} +8 -6
  94. package/dist/{seed-pricing-yhpv35fr.js → seed-pricing-j56bbj4y.js} +8 -6
  95. package/dist/{setup-nytnmwwr.js → setup-tpr6c1kn.js} +2 -2
  96. package/dist/{worker-msytr2cw.js → worker-9w1v0mbb.js} +39 -36
  97. package/openapi.json +542 -16
  98. package/package.json +6 -6
  99. package/src/be/budget-refusal-notify.ts +14 -7
  100. package/src/be/db-queries/task-artifacts.ts +182 -0
  101. package/src/be/db.ts +783 -169
  102. package/src/be/events.ts +5 -0
  103. package/src/be/migrations/130_scratch_script_retention_grace.sql +6 -0
  104. package/src/be/migrations/131_session_logs_created_at_index.sql +2 -0
  105. package/src/be/migrations/132_multi_runtime_instances.sql +44 -0
  106. package/src/be/migrations/133_workflow_run_trigger_type.sql +12 -0
  107. package/src/be/migrations/135_backfill_task_pull_request_attachments.sql +228 -0
  108. package/src/be/migrations/136_task_requester_provenance.sql +37 -0
  109. package/src/be/migrations/137_memory_retrieval_composite_index.sql +1 -0
  110. package/src/be/multi-runtime.ts +430 -0
  111. package/src/be/scripts/db.ts +43 -1
  112. package/src/be/scripts/extract-schema.ts +3 -1
  113. package/src/be/scripts/retention.ts +164 -0
  114. package/src/be/scripts/run-saved.ts +16 -1
  115. package/src/be/scripts/typecheck.ts +3 -2
  116. package/src/be/seed-skills/index.ts +7 -0
  117. package/src/be/steering.ts +1 -1
  118. package/src/be/swarm-config-guard.ts +18 -0
  119. package/src/commands/credential-wait.ts +54 -0
  120. package/src/commands/onboard/steps/core-credentials.tsx +1 -1
  121. package/src/commands/onboard/steps/custom-templates.tsx +1 -1
  122. package/src/commands/onboard/steps/harness-credentials.tsx +1 -1
  123. package/src/commands/onboard/steps/health-check.tsx +1 -1
  124. package/src/commands/onboard/steps/start.tsx +1 -1
  125. package/src/commands/profile-sync-audit.ts +56 -0
  126. package/src/commands/profile-sync.ts +287 -15
  127. package/src/commands/provider-credentials.ts +46 -19
  128. package/src/commands/runner.ts +196 -33
  129. package/src/commands/templates.ts +22 -0
  130. package/src/github/handlers.ts +55 -9
  131. package/src/heartbeat/heartbeat.ts +71 -12
  132. package/src/hooks/hook.ts +49 -33
  133. package/src/http/active-sessions.ts +11 -1
  134. package/src/http/agents.ts +261 -30
  135. package/src/http/all-routes.ts +1 -0
  136. package/src/http/config.ts +13 -2
  137. package/src/http/core.ts +102 -4
  138. package/src/http/db-query-bounded.ts +313 -0
  139. package/src/http/db-query-shared.ts +249 -0
  140. package/src/http/db-query.ts +54 -42
  141. package/src/http/events.ts +2 -0
  142. package/src/http/index.ts +27 -2
  143. package/src/http/mcp-bridge.ts +37 -3
  144. package/src/http/mcp.ts +12 -0
  145. package/src/http/memory.ts +13 -2
  146. package/src/http/openapi.ts +1 -0
  147. package/src/http/poll.ts +70 -27
  148. package/src/http/route-def.ts +43 -9
  149. package/src/http/schedules.ts +2 -2
  150. package/src/http/scripts.ts +31 -4
  151. package/src/http/session-data.ts +44 -0
  152. package/src/http/tasks.ts +2 -2
  153. package/src/http/users.ts +74 -52
  154. package/src/http/webhooks.ts +5 -2
  155. package/src/http/workflows.ts +1 -4
  156. package/src/http/x.ts +14 -0
  157. package/src/integrations/kapso/inbound.ts +1 -1
  158. package/src/jira/outbound.ts +39 -8
  159. package/src/jira/webhook-lifecycle.ts +13 -2
  160. package/src/linear/outbound.ts +43 -10
  161. package/src/oauth/keepalive.ts +13 -2
  162. package/src/prompts/base-prompt.ts +1 -1
  163. package/src/prompts/session-templates.ts +45 -7
  164. package/src/providers/claude-adapter.ts +6 -0
  165. package/src/providers/claude-managed-models.ts +34 -10
  166. package/src/providers/codex-adapter.ts +6 -0
  167. package/src/providers/opencode-adapter.ts +6 -0
  168. package/src/providers/pi-mono-adapter.ts +8 -0
  169. package/src/providers/pricing-sources.md +24 -0
  170. package/src/queue-stall-alarm.ts +216 -0
  171. package/src/scheduler/scheduler.ts +7 -0
  172. package/src/script-workflows/executor.ts +2 -1
  173. package/src/scripts-runtime/executors/native.ts +2 -1
  174. package/src/scripts-runtime/executors/types.ts +5 -0
  175. package/src/scripts-runtime/loader.ts +5 -0
  176. package/src/scripts-runtime/swarm-config.ts +8 -0
  177. package/src/scripts-runtime/swarm-sdk.ts +7 -0
  178. package/src/scripts-runtime/types/stdlib.d.ts +1 -0
  179. package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
  180. package/src/tests/budget-claim-gate.test.ts +20 -0
  181. package/src/tests/claude-adapter.test.ts +32 -0
  182. package/src/tests/claude-managed-adapter.test.ts +38 -7
  183. package/src/tests/codex-adapter.test.ts +30 -0
  184. package/src/tests/create-task-validation.test.ts +128 -0
  185. package/src/tests/credential-wait.test.ts +67 -1
  186. package/src/tests/db-query.test.ts +711 -2
  187. package/src/tests/http-api-integration.test.ts +81 -0
  188. package/src/tests/http-users.test.ts +166 -1
  189. package/src/tests/identity-field-budget.test.ts +176 -0
  190. package/src/tests/mcp-tools-user.test.ts +34 -0
  191. package/src/tests/mcp-user-route.test.ts +17 -0
  192. package/src/tests/metrics-http.test.ts +44 -0
  193. package/src/tests/multi-runtime-registration.test.ts +2703 -0
  194. package/src/tests/openapi-response-contract.test.ts +24 -0
  195. package/src/tests/openapi-route-headers.test.ts +83 -0
  196. package/src/tests/opencode-adapter.test.ts +40 -0
  197. package/src/tests/outbound-listener-rejection.test.ts +138 -0
  198. package/src/tests/pi-mono-adapter.test.ts +98 -0
  199. package/src/tests/profile-sync-warning.test.ts +277 -0
  200. package/src/tests/profile-sync.test.ts +232 -6
  201. package/src/tests/prompt-template-session.test.ts +32 -3
  202. package/src/tests/queue-stall-alarm.test.ts +226 -0
  203. package/src/tests/requester-comms.test.ts +32 -0
  204. package/src/tests/runner-requester-profile.test.ts +38 -0
  205. package/src/tests/sandboxed-process.test.ts +45 -0
  206. package/src/tests/schedule-target-type.test.ts +38 -0
  207. package/src/tests/script-connections.test.ts +16 -3
  208. package/src/tests/scripts-external-api.test.ts +8 -3
  209. package/src/tests/scripts-http.test.ts +12 -0
  210. package/src/tests/scripts-retention.test.ts +384 -0
  211. package/src/tests/scripts-runtime-identity.test.ts +375 -0
  212. package/src/tests/scripts-runtime.test.ts +4 -3
  213. package/src/tests/sdk-allowlist.test.ts +47 -0
  214. package/src/tests/send-task-requested-by.test.ts +9 -0
  215. package/src/tests/session-costs.test.ts +506 -1
  216. package/src/tests/shutdown-error-scrubbing.test.ts +92 -0
  217. package/src/tests/steering-core.test.ts +28 -0
  218. package/src/tests/task-artifacts.test.ts +386 -0
  219. package/src/tests/task-attachments-schema.test.ts +17 -1
  220. package/src/tests/task-completion-idempotency.test.ts +57 -0
  221. package/src/tests/task-pull-request-backfill-migration.test.ts +321 -0
  222. package/src/tests/update-profile-api.test.ts +67 -39
  223. package/src/tests/update-profile-auth.test.ts +48 -4
  224. package/src/tests/user-attribution-migration.test.ts +54 -0
  225. package/src/tests/user-identity.test.ts +72 -0
  226. package/src/tests/workflow-async-v2.test.ts +39 -1
  227. package/src/tests/workflow-http-v2.test.ts +3 -2
  228. package/src/tests/workflow-mcp-trigger-schema.test.ts +52 -3
  229. package/src/tests/workflow-retry-v2.test.ts +45 -1
  230. package/src/tests/workflow-swarm-script.test.ts +14 -5
  231. package/src/tools/db-query.ts +18 -8
  232. package/src/tools/get-task-details.ts +24 -3
  233. package/src/tools/manage-user.ts +36 -3
  234. package/src/tools/poll-task.ts +93 -14
  235. package/src/tools/script-common.ts +5 -0
  236. package/src/tools/send-task.ts +1 -4
  237. package/src/tools/store-progress.ts +13 -2
  238. package/src/tools/swarm-config/delete-config.ts +9 -0
  239. package/src/tools/swarm-config/set-config.ts +3 -2
  240. package/src/tools/task-action.ts +30 -0
  241. package/src/tools/task-tool-ctx.ts +8 -1
  242. package/src/tools/update-profile.ts +16 -21
  243. package/src/tools/utils.ts +5 -0
  244. package/src/tools/workflows/trigger-workflow.ts +7 -1
  245. package/src/types.ts +165 -1
  246. package/src/utils/github-pull-request.ts +76 -0
  247. package/src/utils/identity-field-budget.ts +73 -0
  248. package/src/utils/multi-runtime.ts +20 -0
  249. package/src/utils/requester-comms.ts +24 -0
  250. package/src/utils/sandboxed-process.ts +40 -14
  251. package/src/workflows/engine.ts +22 -2
  252. package/src/workflows/executors/swarm-script.ts +24 -1
  253. package/src/workflows/resume.ts +19 -11
  254. package/src/workflows/retry-poller.ts +1 -0
  255. package/src/workflows/triggers.ts +4 -0
  256. package/templates/schedules/daily-compounding-reflection/content.md +12 -3
  257. package/templates/skills/db-query-guidance/config.json +14 -0
  258. package/templates/skills/db-query-guidance/content.md +57 -0
  259. package/dist/cli-3te4jdkm.js +0 -225
  260. package/dist/cli-bmze986d.js +0 -7
  261. package/dist/cli-kh3ba2zf.js +0 -607
  262. package/dist/index-hp1kdbjj.js +0 -36
  263. package/dist/mistral-conversations-81fwav0j.js +0 -30578
  264. package/dist/otel-nqa12wf3.js +0 -3149
  265. package/dist/{pi-messages-tqj8q6b9.js → pi-messages-sssy32x4.js} +3 -3
@@ -179,6 +179,33 @@ class InvalidWebhookSignatureError extends Error {
179
179
  }
180
180
  }
181
181
 
182
+ class OAuthError extends APIError {
183
+ constructor(status, error, headers) {
184
+ let finalMessage = "OAuth2 authentication error";
185
+ let error_code = undefined;
186
+ if (error && typeof error === "object") {
187
+ const errorData = error;
188
+ error_code = errorData["error"];
189
+ const description = errorData["error_description"];
190
+ if (description && typeof description === "string") {
191
+ finalMessage = description;
192
+ } else if (error_code) {
193
+ finalMessage = error_code;
194
+ }
195
+ }
196
+ super(status, error, finalMessage, headers);
197
+ this.error_code = error_code;
198
+ }
199
+ }
200
+
201
+ class SubjectTokenProviderError extends OpenAIError {
202
+ constructor(message, provider, cause) {
203
+ super(message);
204
+ this.provider = provider;
205
+ this.cause = cause;
206
+ }
207
+ }
208
+
182
209
  // node_modules/@earendil-works/pi-ai/node_modules/openai/internal/utils/values.mjs
183
210
  var startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
184
211
  var isAbsoluteURL = (url) => {
@@ -226,7 +253,7 @@ var safeJSON = (text) => {
226
253
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
227
254
 
228
255
  // node_modules/@earendil-works/pi-ai/node_modules/openai/version.mjs
229
- var VERSION = "6.26.0";
256
+ var VERSION = "6.40.0";
230
257
 
231
258
  // node_modules/@earendil-works/pi-ai/node_modules/openai/internal/detect-platform.mjs
232
259
  var isRunningInBrowser = () => {
@@ -917,7 +944,7 @@ var formatRequestDetails = (details) => {
917
944
  if (details.headers) {
918
945
  details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
919
946
  name,
920
- name.toLowerCase() === "authorization" || name.toLowerCase() === "cookie" || name.toLowerCase() === "set-cookie" ? "***" : value
947
+ name.toLowerCase() === "authorization" || name.toLowerCase() === "api-key" || name.toLowerCase() === "x-api-key" || name.toLowerCase() === "cookie" || name.toLowerCase() === "set-cookie" ? "***" : value
921
948
  ]));
922
949
  }
923
950
  if ("retryOfRequestLogID" in details) {
@@ -1398,6 +1425,125 @@ class ConversationCursorPage extends AbstractPage {
1398
1425
  }
1399
1426
  }
1400
1427
 
1428
+ class NextCursorPage extends AbstractPage {
1429
+ constructor(client, response, body, options) {
1430
+ super(client, response, body, options);
1431
+ this.data = body.data || [];
1432
+ this.has_more = body.has_more || false;
1433
+ this.next = body.next || null;
1434
+ }
1435
+ getPaginatedItems() {
1436
+ return this.data ?? [];
1437
+ }
1438
+ hasNextPage() {
1439
+ if (this.has_more === false) {
1440
+ return false;
1441
+ }
1442
+ return super.hasNextPage();
1443
+ }
1444
+ nextPageRequestOptions() {
1445
+ const cursor = this.next;
1446
+ if (!cursor) {
1447
+ return null;
1448
+ }
1449
+ return {
1450
+ ...this.options,
1451
+ query: {
1452
+ ...maybeObj(this.options.query),
1453
+ after: cursor
1454
+ }
1455
+ };
1456
+ }
1457
+ }
1458
+
1459
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/auth/workload-identity-auth.mjs
1460
+ var SUBJECT_TOKEN_TYPES = {
1461
+ jwt: "urn:ietf:params:oauth:token-type:jwt",
1462
+ id: "urn:ietf:params:oauth:token-type:id_token"
1463
+ };
1464
+ var TOKEN_EXCHANGE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
1465
+
1466
+ class WorkloadIdentityAuth {
1467
+ constructor(config, fetch2) {
1468
+ this.cachedToken = null;
1469
+ this.refreshPromise = null;
1470
+ this.tokenExchangeUrl = "https://auth.openai.com/oauth/token";
1471
+ this.config = config;
1472
+ this.fetch = fetch2 ?? getDefaultFetch();
1473
+ }
1474
+ async getToken() {
1475
+ if (!this.cachedToken || this.isTokenExpired(this.cachedToken)) {
1476
+ if (this.refreshPromise) {
1477
+ return await this.refreshPromise;
1478
+ }
1479
+ this.refreshPromise = this.refreshToken();
1480
+ try {
1481
+ const token = await this.refreshPromise;
1482
+ return token;
1483
+ } finally {
1484
+ this.refreshPromise = null;
1485
+ }
1486
+ }
1487
+ if (this.needsRefresh(this.cachedToken) && !this.refreshPromise) {
1488
+ this.refreshPromise = this.refreshToken().finally(() => {
1489
+ this.refreshPromise = null;
1490
+ });
1491
+ }
1492
+ return this.cachedToken.token;
1493
+ }
1494
+ async refreshToken() {
1495
+ const subjectToken = await this.config.provider.getToken();
1496
+ const body = {
1497
+ grant_type: TOKEN_EXCHANGE_GRANT_TYPE,
1498
+ subject_token: subjectToken,
1499
+ subject_token_type: SUBJECT_TOKEN_TYPES[this.config.provider.tokenType],
1500
+ identity_provider_id: this.config.identityProviderId,
1501
+ service_account_id: this.config.serviceAccountId
1502
+ };
1503
+ if (this.config.clientId) {
1504
+ body["client_id"] = this.config.clientId;
1505
+ }
1506
+ const response = await this.fetch(this.tokenExchangeUrl, {
1507
+ method: "POST",
1508
+ headers: {
1509
+ "Content-Type": "application/json"
1510
+ },
1511
+ body: JSON.stringify(body)
1512
+ });
1513
+ if (!response.ok) {
1514
+ const errorText = await response.text();
1515
+ let body2 = undefined;
1516
+ try {
1517
+ body2 = JSON.parse(errorText);
1518
+ } catch {}
1519
+ if (response.status === 400 || response.status === 401 || response.status === 403) {
1520
+ throw new OAuthError(response.status, body2, response.headers);
1521
+ }
1522
+ throw APIError.generate(response.status, body2, `Token exchange failed with status ${response.status}`, response.headers);
1523
+ }
1524
+ const tokenResponse = await response.json();
1525
+ const expiresIn = tokenResponse.expires_in || 3600;
1526
+ const expiresAt = Date.now() + expiresIn * 1000;
1527
+ this.cachedToken = {
1528
+ token: tokenResponse.access_token,
1529
+ expiresAt
1530
+ };
1531
+ return tokenResponse.access_token;
1532
+ }
1533
+ isTokenExpired(cachedToken) {
1534
+ return Date.now() >= cachedToken.expiresAt;
1535
+ }
1536
+ needsRefresh(cachedToken) {
1537
+ const bufferSeconds = this.config.refreshBufferSeconds ?? 1200;
1538
+ const bufferMs = bufferSeconds * 1000;
1539
+ return Date.now() >= cachedToken.expiresAt - bufferMs;
1540
+ }
1541
+ invalidateToken() {
1542
+ this.cachedToken = null;
1543
+ this.refreshPromise = null;
1544
+ }
1545
+ }
1546
+
1401
1547
  // node_modules/@earendil-works/pi-ai/node_modules/openai/internal/uploads.mjs
1402
1548
  var checkFileSupport = () => {
1403
1549
  if (typeof File === "undefined") {
@@ -1604,7 +1750,7 @@ var path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
1604
1750
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/chat/completions/messages.mjs
1605
1751
  class Messages extends APIResource {
1606
1752
  list(completionID, query = {}, options) {
1607
- return this._client.getAPIList(path`/chat/completions/${completionID}/messages`, CursorPage, { query, ...options });
1753
+ return this._client.getAPIList(path`/chat/completions/${completionID}/messages`, CursorPage, { query, ...options, __security: { bearerAuth: true } });
1608
1754
  }
1609
1755
  }
1610
1756
  // node_modules/@earendil-works/pi-ai/node_modules/openai/lib/parser.mjs
@@ -2865,19 +3011,38 @@ class Completions extends APIResource {
2865
3011
  this.messages = new Messages(this._client);
2866
3012
  }
2867
3013
  create(body, options) {
2868
- return this._client.post("/chat/completions", { body, ...options, stream: body.stream ?? false });
3014
+ return this._client.post("/chat/completions", {
3015
+ body,
3016
+ ...options,
3017
+ stream: body.stream ?? false,
3018
+ __security: { bearerAuth: true }
3019
+ });
2869
3020
  }
2870
3021
  retrieve(completionID, options) {
2871
- return this._client.get(path`/chat/completions/${completionID}`, options);
3022
+ return this._client.get(path`/chat/completions/${completionID}`, {
3023
+ ...options,
3024
+ __security: { bearerAuth: true }
3025
+ });
2872
3026
  }
2873
3027
  update(completionID, body, options) {
2874
- return this._client.post(path`/chat/completions/${completionID}`, { body, ...options });
3028
+ return this._client.post(path`/chat/completions/${completionID}`, {
3029
+ body,
3030
+ ...options,
3031
+ __security: { bearerAuth: true }
3032
+ });
2875
3033
  }
2876
3034
  list(query = {}, options) {
2877
- return this._client.getAPIList("/chat/completions", CursorPage, { query, ...options });
3035
+ return this._client.getAPIList("/chat/completions", CursorPage, {
3036
+ query,
3037
+ ...options,
3038
+ __security: { bearerAuth: true }
3039
+ });
2878
3040
  }
2879
3041
  delete(completionID, options) {
2880
- return this._client.delete(path`/chat/completions/${completionID}`, options);
3042
+ return this._client.delete(path`/chat/completions/${completionID}`, {
3043
+ ...options,
3044
+ __security: { bearerAuth: true }
3045
+ });
2881
3046
  }
2882
3047
  parse(body, options) {
2883
3048
  validateInputTools(body.tools);
@@ -2909,245 +3074,1150 @@ class Chat extends APIResource {
2909
3074
  }
2910
3075
  }
2911
3076
  Chat.Completions = Completions;
2912
- // node_modules/@earendil-works/pi-ai/node_modules/openai/internal/headers.mjs
2913
- var brand_privateNullableHeaders = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
2914
- function* iterateHeaders(headers) {
2915
- if (!headers)
2916
- return;
2917
- if (brand_privateNullableHeaders in headers) {
2918
- const { values, nulls } = headers;
2919
- yield* values.entries();
2920
- for (const name of nulls) {
2921
- yield [name, null];
2922
- }
2923
- return;
2924
- }
2925
- let shouldClear = false;
2926
- let iter;
2927
- if (headers instanceof Headers) {
2928
- iter = headers.entries();
2929
- } else if (isReadonlyArray(headers)) {
2930
- iter = headers;
2931
- } else {
2932
- shouldClear = true;
2933
- iter = Object.entries(headers ?? {});
2934
- }
2935
- for (let row of iter) {
2936
- const name = row[0];
2937
- if (typeof name !== "string")
2938
- throw new TypeError("expected header name to be a string");
2939
- const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
2940
- let didClear = false;
2941
- for (const value of values) {
2942
- if (value === undefined)
2943
- continue;
2944
- if (shouldClear && !didClear) {
2945
- didClear = true;
2946
- yield [name, null];
2947
- }
2948
- yield [name, value];
2949
- }
2950
- }
2951
- }
2952
- var buildHeaders = (newHeaders) => {
2953
- const targetHeaders = new Headers;
2954
- const nullHeaders = new Set;
2955
- for (const headers of newHeaders) {
2956
- const seenHeaders = new Set;
2957
- for (const [name, value] of iterateHeaders(headers)) {
2958
- const lowerName = name.toLowerCase();
2959
- if (!seenHeaders.has(lowerName)) {
2960
- targetHeaders.delete(name);
2961
- seenHeaders.add(lowerName);
2962
- }
2963
- if (value === null) {
2964
- targetHeaders.delete(name);
2965
- nullHeaders.add(lowerName);
2966
- } else {
2967
- targetHeaders.append(name, value);
2968
- nullHeaders.delete(lowerName);
2969
- }
2970
- }
2971
- }
2972
- return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
2973
- };
2974
-
2975
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/speech.mjs
2976
- class Speech extends APIResource {
3077
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/admin-api-keys.mjs
3078
+ class AdminAPIKeys extends APIResource {
2977
3079
  create(body, options) {
2978
- return this._client.post("/audio/speech", {
3080
+ return this._client.post("/organization/admin_api_keys", {
2979
3081
  body,
2980
3082
  ...options,
2981
- headers: buildHeaders([{ Accept: "application/octet-stream" }, options?.headers]),
2982
- __binaryResponse: true
3083
+ __security: { adminAPIKeyAuth: true }
2983
3084
  });
2984
3085
  }
2985
- }
2986
-
2987
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/transcriptions.mjs
2988
- class Transcriptions extends APIResource {
2989
- create(body, options) {
2990
- return this._client.post("/audio/transcriptions", multipartFormRequestOptions({
2991
- body,
3086
+ retrieve(keyID, options) {
3087
+ return this._client.get(path`/organization/admin_api_keys/${keyID}`, {
2992
3088
  ...options,
2993
- stream: body.stream ?? false,
2994
- __metadata: { model: body.model }
2995
- }, this._client));
3089
+ __security: { adminAPIKeyAuth: true }
3090
+ });
2996
3091
  }
2997
- }
2998
-
2999
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/translations.mjs
3000
- class Translations extends APIResource {
3001
- create(body, options) {
3002
- return this._client.post("/audio/translations", multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client));
3092
+ list(query = {}, options) {
3093
+ return this._client.getAPIList("/organization/admin_api_keys", CursorPage, {
3094
+ query,
3095
+ ...options,
3096
+ __security: { adminAPIKeyAuth: true }
3097
+ });
3003
3098
  }
3004
- }
3005
-
3006
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/audio.mjs
3007
- class Audio extends APIResource {
3008
- constructor() {
3009
- super(...arguments);
3010
- this.transcriptions = new Transcriptions(this._client);
3011
- this.translations = new Translations(this._client);
3012
- this.speech = new Speech(this._client);
3099
+ delete(keyID, options) {
3100
+ return this._client.delete(path`/organization/admin_api_keys/${keyID}`, {
3101
+ ...options,
3102
+ __security: { adminAPIKeyAuth: true }
3103
+ });
3013
3104
  }
3014
3105
  }
3015
- Audio.Transcriptions = Transcriptions;
3016
- Audio.Translations = Translations;
3017
- Audio.Speech = Speech;
3018
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/batches.mjs
3019
- class Batches extends APIResource {
3020
- create(body, options) {
3021
- return this._client.post("/batches", { body, ...options });
3022
- }
3023
- retrieve(batchID, options) {
3024
- return this._client.get(path`/batches/${batchID}`, options);
3025
- }
3106
+
3107
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/audit-logs.mjs
3108
+ class AuditLogs extends APIResource {
3026
3109
  list(query = {}, options) {
3027
- return this._client.getAPIList("/batches", CursorPage, { query, ...options });
3028
- }
3029
- cancel(batchID, options) {
3030
- return this._client.post(path`/batches/${batchID}/cancel`, options);
3110
+ return this._client.getAPIList("/organization/audit_logs", ConversationCursorPage, {
3111
+ query,
3112
+ ...options,
3113
+ __security: { adminAPIKeyAuth: true }
3114
+ });
3031
3115
  }
3032
3116
  }
3033
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/assistants.mjs
3034
- class Assistants extends APIResource {
3117
+
3118
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/certificates.mjs
3119
+ class Certificates extends APIResource {
3035
3120
  create(body, options) {
3036
- return this._client.post("/assistants", {
3121
+ return this._client.post("/organization/certificates", {
3037
3122
  body,
3038
3123
  ...options,
3039
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3124
+ __security: { adminAPIKeyAuth: true }
3040
3125
  });
3041
3126
  }
3042
- retrieve(assistantID, options) {
3043
- return this._client.get(path`/assistants/${assistantID}`, {
3127
+ retrieve(certificateID, query = {}, options) {
3128
+ return this._client.get(path`/organization/certificates/${certificateID}`, {
3129
+ query,
3044
3130
  ...options,
3045
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3131
+ __security: { adminAPIKeyAuth: true }
3046
3132
  });
3047
3133
  }
3048
- update(assistantID, body, options) {
3049
- return this._client.post(path`/assistants/${assistantID}`, {
3134
+ update(certificateID, body, options) {
3135
+ return this._client.post(path`/organization/certificates/${certificateID}`, {
3050
3136
  body,
3051
3137
  ...options,
3052
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3138
+ __security: { adminAPIKeyAuth: true }
3053
3139
  });
3054
3140
  }
3055
3141
  list(query = {}, options) {
3056
- return this._client.getAPIList("/assistants", CursorPage, {
3057
- query,
3142
+ return this._client.getAPIList("/organization/certificates", ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3143
+ }
3144
+ delete(certificateID, options) {
3145
+ return this._client.delete(path`/organization/certificates/${certificateID}`, {
3058
3146
  ...options,
3059
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3147
+ __security: { adminAPIKeyAuth: true }
3060
3148
  });
3061
3149
  }
3062
- delete(assistantID, options) {
3063
- return this._client.delete(path`/assistants/${assistantID}`, {
3150
+ activate(body, options) {
3151
+ return this._client.getAPIList("/organization/certificates/activate", Page, {
3152
+ body,
3153
+ method: "post",
3064
3154
  ...options,
3065
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3155
+ __security: { adminAPIKeyAuth: true }
3066
3156
  });
3067
3157
  }
3158
+ deactivate(body, options) {
3159
+ return this._client.getAPIList("/organization/certificates/deactivate", Page, { body, method: "post", ...options, __security: { adminAPIKeyAuth: true } });
3160
+ }
3068
3161
  }
3069
3162
 
3070
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/realtime/sessions.mjs
3071
- class Sessions extends APIResource {
3072
- create(body, options) {
3073
- return this._client.post("/realtime/sessions", {
3163
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/data-retention.mjs
3164
+ class DataRetention extends APIResource {
3165
+ retrieve(options) {
3166
+ return this._client.get("/organization/data_retention", {
3167
+ ...options,
3168
+ __security: { adminAPIKeyAuth: true }
3169
+ });
3170
+ }
3171
+ update(body, options) {
3172
+ return this._client.post("/organization/data_retention", {
3074
3173
  body,
3075
3174
  ...options,
3076
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3175
+ __security: { adminAPIKeyAuth: true }
3077
3176
  });
3078
3177
  }
3079
3178
  }
3080
3179
 
3081
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs
3082
- class TranscriptionSessions extends APIResource {
3180
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/invites.mjs
3181
+ class Invites extends APIResource {
3083
3182
  create(body, options) {
3084
- return this._client.post("/realtime/transcription_sessions", {
3183
+ return this._client.post("/organization/invites", {
3085
3184
  body,
3086
3185
  ...options,
3087
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
3186
+ __security: { adminAPIKeyAuth: true }
3088
3187
  });
3089
3188
  }
3090
- }
3091
-
3092
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/realtime/realtime.mjs
3093
- class Realtime extends APIResource {
3094
- constructor() {
3095
- super(...arguments);
3096
- this.sessions = new Sessions(this._client);
3097
- this.transcriptionSessions = new TranscriptionSessions(this._client);
3189
+ retrieve(inviteID, options) {
3190
+ return this._client.get(path`/organization/invites/${inviteID}`, {
3191
+ ...options,
3192
+ __security: { adminAPIKeyAuth: true }
3193
+ });
3194
+ }
3195
+ list(query = {}, options) {
3196
+ return this._client.getAPIList("/organization/invites", ConversationCursorPage, {
3197
+ query,
3198
+ ...options,
3199
+ __security: { adminAPIKeyAuth: true }
3200
+ });
3201
+ }
3202
+ delete(inviteID, options) {
3203
+ return this._client.delete(path`/organization/invites/${inviteID}`, {
3204
+ ...options,
3205
+ __security: { adminAPIKeyAuth: true }
3206
+ });
3098
3207
  }
3099
3208
  }
3100
- Realtime.Sessions = Sessions;
3101
- Realtime.TranscriptionSessions = TranscriptionSessions;
3102
3209
 
3103
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/chatkit/sessions.mjs
3104
- class Sessions2 extends APIResource {
3210
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/roles.mjs
3211
+ class Roles extends APIResource {
3105
3212
  create(body, options) {
3106
- return this._client.post("/chatkit/sessions", {
3213
+ return this._client.post("/organization/roles", {
3107
3214
  body,
3108
3215
  ...options,
3109
- headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers])
3216
+ __security: { adminAPIKeyAuth: true }
3110
3217
  });
3111
3218
  }
3112
- cancel(sessionID, options) {
3113
- return this._client.post(path`/chatkit/sessions/${sessionID}/cancel`, {
3219
+ retrieve(roleID, options) {
3220
+ return this._client.get(path`/organization/roles/${roleID}`, {
3114
3221
  ...options,
3115
- headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers])
3222
+ __security: { adminAPIKeyAuth: true }
3116
3223
  });
3117
3224
  }
3118
- }
3119
-
3120
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/chatkit/threads.mjs
3121
- class Threads extends APIResource {
3122
- retrieve(threadID, options) {
3123
- return this._client.get(path`/chatkit/threads/${threadID}`, {
3225
+ update(roleID, body, options) {
3226
+ return this._client.post(path`/organization/roles/${roleID}`, {
3227
+ body,
3124
3228
  ...options,
3125
- headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers])
3229
+ __security: { adminAPIKeyAuth: true }
3126
3230
  });
3127
3231
  }
3128
3232
  list(query = {}, options) {
3129
- return this._client.getAPIList("/chatkit/threads", ConversationCursorPage, {
3233
+ return this._client.getAPIList("/organization/roles", NextCursorPage, {
3130
3234
  query,
3131
3235
  ...options,
3132
- headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers])
3236
+ __security: { adminAPIKeyAuth: true }
3133
3237
  });
3134
3238
  }
3135
- delete(threadID, options) {
3136
- return this._client.delete(path`/chatkit/threads/${threadID}`, {
3239
+ delete(roleID, options) {
3240
+ return this._client.delete(path`/organization/roles/${roleID}`, {
3137
3241
  ...options,
3138
- headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers])
3242
+ __security: { adminAPIKeyAuth: true }
3139
3243
  });
3140
3244
  }
3141
- listItems(threadID, query = {}, options) {
3142
- return this._client.getAPIList(path`/chatkit/threads/${threadID}/items`, ConversationCursorPage, { query, ...options, headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]) });
3143
- }
3144
3245
  }
3145
3246
 
3146
- // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/chatkit/chatkit.mjs
3147
- class ChatKit extends APIResource {
3148
- constructor() {
3149
- super(...arguments);
3150
- this.sessions = new Sessions2(this._client);
3247
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/spend-alerts.mjs
3248
+ class SpendAlerts extends APIResource {
3249
+ create(body, options) {
3250
+ return this._client.post("/organization/spend_alerts", {
3251
+ body,
3252
+ ...options,
3253
+ __security: { adminAPIKeyAuth: true }
3254
+ });
3255
+ }
3256
+ update(alertID, body, options) {
3257
+ return this._client.post(path`/organization/spend_alerts/${alertID}`, {
3258
+ body,
3259
+ ...options,
3260
+ __security: { adminAPIKeyAuth: true }
3261
+ });
3262
+ }
3263
+ list(query = {}, options) {
3264
+ return this._client.getAPIList("/organization/spend_alerts", ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3265
+ }
3266
+ delete(alertID, options) {
3267
+ return this._client.delete(path`/organization/spend_alerts/${alertID}`, {
3268
+ ...options,
3269
+ __security: { adminAPIKeyAuth: true }
3270
+ });
3271
+ }
3272
+ }
3273
+
3274
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/usage.mjs
3275
+ class Usage extends APIResource {
3276
+ audioSpeeches(query, options) {
3277
+ return this._client.get("/organization/usage/audio_speeches", {
3278
+ query,
3279
+ ...options,
3280
+ __security: { adminAPIKeyAuth: true }
3281
+ });
3282
+ }
3283
+ audioTranscriptions(query, options) {
3284
+ return this._client.get("/organization/usage/audio_transcriptions", {
3285
+ query,
3286
+ ...options,
3287
+ __security: { adminAPIKeyAuth: true }
3288
+ });
3289
+ }
3290
+ codeInterpreterSessions(query, options) {
3291
+ return this._client.get("/organization/usage/code_interpreter_sessions", {
3292
+ query,
3293
+ ...options,
3294
+ __security: { adminAPIKeyAuth: true }
3295
+ });
3296
+ }
3297
+ completions(query, options) {
3298
+ return this._client.get("/organization/usage/completions", {
3299
+ query,
3300
+ ...options,
3301
+ __security: { adminAPIKeyAuth: true }
3302
+ });
3303
+ }
3304
+ costs(query, options) {
3305
+ return this._client.get("/organization/costs", {
3306
+ query,
3307
+ ...options,
3308
+ __security: { adminAPIKeyAuth: true }
3309
+ });
3310
+ }
3311
+ embeddings(query, options) {
3312
+ return this._client.get("/organization/usage/embeddings", {
3313
+ query,
3314
+ ...options,
3315
+ __security: { adminAPIKeyAuth: true }
3316
+ });
3317
+ }
3318
+ fileSearchCalls(query, options) {
3319
+ return this._client.get("/organization/usage/file_search_calls", {
3320
+ query,
3321
+ ...options,
3322
+ __security: { adminAPIKeyAuth: true }
3323
+ });
3324
+ }
3325
+ images(query, options) {
3326
+ return this._client.get("/organization/usage/images", {
3327
+ query,
3328
+ ...options,
3329
+ __security: { adminAPIKeyAuth: true }
3330
+ });
3331
+ }
3332
+ moderations(query, options) {
3333
+ return this._client.get("/organization/usage/moderations", {
3334
+ query,
3335
+ ...options,
3336
+ __security: { adminAPIKeyAuth: true }
3337
+ });
3338
+ }
3339
+ vectorStores(query, options) {
3340
+ return this._client.get("/organization/usage/vector_stores", {
3341
+ query,
3342
+ ...options,
3343
+ __security: { adminAPIKeyAuth: true }
3344
+ });
3345
+ }
3346
+ webSearchCalls(query, options) {
3347
+ return this._client.get("/organization/usage/web_search_calls", {
3348
+ query,
3349
+ ...options,
3350
+ __security: { adminAPIKeyAuth: true }
3351
+ });
3352
+ }
3353
+ }
3354
+
3355
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/groups/roles.mjs
3356
+ class Roles2 extends APIResource {
3357
+ create(groupID, body, options) {
3358
+ return this._client.post(path`/organization/groups/${groupID}/roles`, {
3359
+ body,
3360
+ ...options,
3361
+ __security: { adminAPIKeyAuth: true }
3362
+ });
3363
+ }
3364
+ retrieve(roleID, params, options) {
3365
+ const { group_id } = params;
3366
+ return this._client.get(path`/organization/groups/${group_id}/roles/${roleID}`, {
3367
+ ...options,
3368
+ __security: { adminAPIKeyAuth: true }
3369
+ });
3370
+ }
3371
+ list(groupID, query = {}, options) {
3372
+ return this._client.getAPIList(path`/organization/groups/${groupID}/roles`, NextCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3373
+ }
3374
+ delete(roleID, params, options) {
3375
+ const { group_id } = params;
3376
+ return this._client.delete(path`/organization/groups/${group_id}/roles/${roleID}`, {
3377
+ ...options,
3378
+ __security: { adminAPIKeyAuth: true }
3379
+ });
3380
+ }
3381
+ }
3382
+
3383
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/groups/users.mjs
3384
+ class Users extends APIResource {
3385
+ create(groupID, body, options) {
3386
+ return this._client.post(path`/organization/groups/${groupID}/users`, {
3387
+ body,
3388
+ ...options,
3389
+ __security: { adminAPIKeyAuth: true }
3390
+ });
3391
+ }
3392
+ retrieve(userID, params, options) {
3393
+ const { group_id } = params;
3394
+ return this._client.get(path`/organization/groups/${group_id}/users/${userID}`, {
3395
+ ...options,
3396
+ __security: { adminAPIKeyAuth: true }
3397
+ });
3398
+ }
3399
+ list(groupID, query = {}, options) {
3400
+ return this._client.getAPIList(path`/organization/groups/${groupID}/users`, NextCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3401
+ }
3402
+ delete(userID, params, options) {
3403
+ const { group_id } = params;
3404
+ return this._client.delete(path`/organization/groups/${group_id}/users/${userID}`, {
3405
+ ...options,
3406
+ __security: { adminAPIKeyAuth: true }
3407
+ });
3408
+ }
3409
+ }
3410
+
3411
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/groups/groups.mjs
3412
+ class Groups extends APIResource {
3413
+ constructor() {
3414
+ super(...arguments);
3415
+ this.users = new Users(this._client);
3416
+ this.roles = new Roles2(this._client);
3417
+ }
3418
+ create(body, options) {
3419
+ return this._client.post("/organization/groups", {
3420
+ body,
3421
+ ...options,
3422
+ __security: { adminAPIKeyAuth: true }
3423
+ });
3424
+ }
3425
+ retrieve(groupID, options) {
3426
+ return this._client.get(path`/organization/groups/${groupID}`, {
3427
+ ...options,
3428
+ __security: { adminAPIKeyAuth: true }
3429
+ });
3430
+ }
3431
+ update(groupID, body, options) {
3432
+ return this._client.post(path`/organization/groups/${groupID}`, {
3433
+ body,
3434
+ ...options,
3435
+ __security: { adminAPIKeyAuth: true }
3436
+ });
3437
+ }
3438
+ list(query = {}, options) {
3439
+ return this._client.getAPIList("/organization/groups", NextCursorPage, {
3440
+ query,
3441
+ ...options,
3442
+ __security: { adminAPIKeyAuth: true }
3443
+ });
3444
+ }
3445
+ delete(groupID, options) {
3446
+ return this._client.delete(path`/organization/groups/${groupID}`, {
3447
+ ...options,
3448
+ __security: { adminAPIKeyAuth: true }
3449
+ });
3450
+ }
3451
+ }
3452
+ Groups.Users = Users;
3453
+ Groups.Roles = Roles2;
3454
+
3455
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/api-keys.mjs
3456
+ class APIKeys extends APIResource {
3457
+ retrieve(apiKeyID, params, options) {
3458
+ const { project_id } = params;
3459
+ return this._client.get(path`/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
3460
+ ...options,
3461
+ __security: { adminAPIKeyAuth: true }
3462
+ });
3463
+ }
3464
+ list(projectID, query = {}, options) {
3465
+ return this._client.getAPIList(path`/organization/projects/${projectID}/api_keys`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3466
+ }
3467
+ delete(apiKeyID, params, options) {
3468
+ const { project_id } = params;
3469
+ return this._client.delete(path`/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
3470
+ ...options,
3471
+ __security: { adminAPIKeyAuth: true }
3472
+ });
3473
+ }
3474
+ }
3475
+
3476
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/certificates.mjs
3477
+ class Certificates2 extends APIResource {
3478
+ list(projectID, query = {}, options) {
3479
+ return this._client.getAPIList(path`/organization/projects/${projectID}/certificates`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3480
+ }
3481
+ activate(projectID, body, options) {
3482
+ return this._client.getAPIList(path`/organization/projects/${projectID}/certificates/activate`, Page, { body, method: "post", ...options, __security: { adminAPIKeyAuth: true } });
3483
+ }
3484
+ deactivate(projectID, body, options) {
3485
+ return this._client.getAPIList(path`/organization/projects/${projectID}/certificates/deactivate`, Page, { body, method: "post", ...options, __security: { adminAPIKeyAuth: true } });
3486
+ }
3487
+ }
3488
+
3489
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/data-retention.mjs
3490
+ class DataRetention2 extends APIResource {
3491
+ retrieve(projectID, options) {
3492
+ return this._client.get(path`/organization/projects/${projectID}/data_retention`, {
3493
+ ...options,
3494
+ __security: { adminAPIKeyAuth: true }
3495
+ });
3496
+ }
3497
+ update(projectID, body, options) {
3498
+ return this._client.post(path`/organization/projects/${projectID}/data_retention`, {
3499
+ body,
3500
+ ...options,
3501
+ __security: { adminAPIKeyAuth: true }
3502
+ });
3503
+ }
3504
+ }
3505
+
3506
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs
3507
+ class HostedToolPermissions extends APIResource {
3508
+ retrieve(projectID, options) {
3509
+ return this._client.get(path`/organization/projects/${projectID}/hosted_tool_permissions`, {
3510
+ ...options,
3511
+ __security: { adminAPIKeyAuth: true }
3512
+ });
3513
+ }
3514
+ update(projectID, body, options) {
3515
+ return this._client.post(path`/organization/projects/${projectID}/hosted_tool_permissions`, {
3516
+ body,
3517
+ ...options,
3518
+ __security: { adminAPIKeyAuth: true }
3519
+ });
3520
+ }
3521
+ }
3522
+
3523
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs
3524
+ class ModelPermissions extends APIResource {
3525
+ retrieve(projectID, options) {
3526
+ return this._client.get(path`/organization/projects/${projectID}/model_permissions`, {
3527
+ ...options,
3528
+ __security: { adminAPIKeyAuth: true }
3529
+ });
3530
+ }
3531
+ update(projectID, body, options) {
3532
+ return this._client.post(path`/organization/projects/${projectID}/model_permissions`, {
3533
+ body,
3534
+ ...options,
3535
+ __security: { adminAPIKeyAuth: true }
3536
+ });
3537
+ }
3538
+ delete(projectID, options) {
3539
+ return this._client.delete(path`/organization/projects/${projectID}/model_permissions`, {
3540
+ ...options,
3541
+ __security: { adminAPIKeyAuth: true }
3542
+ });
3543
+ }
3544
+ }
3545
+
3546
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs
3547
+ class RateLimits extends APIResource {
3548
+ listRateLimits(projectID, query = {}, options) {
3549
+ return this._client.getAPIList(path`/organization/projects/${projectID}/rate_limits`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3550
+ }
3551
+ updateRateLimit(rateLimitID, params, options) {
3552
+ const { project_id, ...body } = params;
3553
+ return this._client.post(path`/organization/projects/${project_id}/rate_limits/${rateLimitID}`, {
3554
+ body,
3555
+ ...options,
3556
+ __security: { adminAPIKeyAuth: true }
3557
+ });
3558
+ }
3559
+ }
3560
+
3561
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/roles.mjs
3562
+ class Roles3 extends APIResource {
3563
+ create(projectID, body, options) {
3564
+ return this._client.post(path`/projects/${projectID}/roles`, {
3565
+ body,
3566
+ ...options,
3567
+ __security: { adminAPIKeyAuth: true }
3568
+ });
3569
+ }
3570
+ retrieve(roleID, params, options) {
3571
+ const { project_id } = params;
3572
+ return this._client.get(path`/projects/${project_id}/roles/${roleID}`, {
3573
+ ...options,
3574
+ __security: { adminAPIKeyAuth: true }
3575
+ });
3576
+ }
3577
+ update(roleID, params, options) {
3578
+ const { project_id, ...body } = params;
3579
+ return this._client.post(path`/projects/${project_id}/roles/${roleID}`, {
3580
+ body,
3581
+ ...options,
3582
+ __security: { adminAPIKeyAuth: true }
3583
+ });
3584
+ }
3585
+ list(projectID, query = {}, options) {
3586
+ return this._client.getAPIList(path`/projects/${projectID}/roles`, NextCursorPage, {
3587
+ query,
3588
+ ...options,
3589
+ __security: { adminAPIKeyAuth: true }
3590
+ });
3591
+ }
3592
+ delete(roleID, params, options) {
3593
+ const { project_id } = params;
3594
+ return this._client.delete(path`/projects/${project_id}/roles/${roleID}`, {
3595
+ ...options,
3596
+ __security: { adminAPIKeyAuth: true }
3597
+ });
3598
+ }
3599
+ }
3600
+
3601
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs
3602
+ class ServiceAccounts extends APIResource {
3603
+ create(projectID, body, options) {
3604
+ return this._client.post(path`/organization/projects/${projectID}/service_accounts`, {
3605
+ body,
3606
+ ...options,
3607
+ __security: { adminAPIKeyAuth: true }
3608
+ });
3609
+ }
3610
+ retrieve(serviceAccountID, params, options) {
3611
+ const { project_id } = params;
3612
+ return this._client.get(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
3613
+ ...options,
3614
+ __security: { adminAPIKeyAuth: true }
3615
+ });
3616
+ }
3617
+ update(serviceAccountID, params, options) {
3618
+ const { project_id, ...body } = params;
3619
+ return this._client.post(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { body, ...options, __security: { adminAPIKeyAuth: true } });
3620
+ }
3621
+ list(projectID, query = {}, options) {
3622
+ return this._client.getAPIList(path`/organization/projects/${projectID}/service_accounts`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3623
+ }
3624
+ delete(serviceAccountID, params, options) {
3625
+ const { project_id } = params;
3626
+ return this._client.delete(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { ...options, __security: { adminAPIKeyAuth: true } });
3627
+ }
3628
+ }
3629
+
3630
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs
3631
+ class SpendAlerts2 extends APIResource {
3632
+ create(projectID, body, options) {
3633
+ return this._client.post(path`/organization/projects/${projectID}/spend_alerts`, {
3634
+ body,
3635
+ ...options,
3636
+ __security: { adminAPIKeyAuth: true }
3637
+ });
3638
+ }
3639
+ update(alertID, params, options) {
3640
+ const { project_id, ...body } = params;
3641
+ return this._client.post(path`/organization/projects/${project_id}/spend_alerts/${alertID}`, {
3642
+ body,
3643
+ ...options,
3644
+ __security: { adminAPIKeyAuth: true }
3645
+ });
3646
+ }
3647
+ list(projectID, query = {}, options) {
3648
+ return this._client.getAPIList(path`/organization/projects/${projectID}/spend_alerts`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3649
+ }
3650
+ delete(alertID, params, options) {
3651
+ const { project_id } = params;
3652
+ return this._client.delete(path`/organization/projects/${project_id}/spend_alerts/${alertID}`, {
3653
+ ...options,
3654
+ __security: { adminAPIKeyAuth: true }
3655
+ });
3656
+ }
3657
+ }
3658
+
3659
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs
3660
+ class Roles4 extends APIResource {
3661
+ create(groupID, params, options) {
3662
+ const { project_id, ...body } = params;
3663
+ return this._client.post(path`/projects/${project_id}/groups/${groupID}/roles`, {
3664
+ body,
3665
+ ...options,
3666
+ __security: { adminAPIKeyAuth: true }
3667
+ });
3668
+ }
3669
+ retrieve(roleID, params, options) {
3670
+ const { project_id, group_id } = params;
3671
+ return this._client.get(path`/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
3672
+ ...options,
3673
+ __security: { adminAPIKeyAuth: true }
3674
+ });
3675
+ }
3676
+ list(groupID, params, options) {
3677
+ const { project_id, ...query } = params;
3678
+ return this._client.getAPIList(path`/projects/${project_id}/groups/${groupID}/roles`, NextCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3679
+ }
3680
+ delete(roleID, params, options) {
3681
+ const { project_id, group_id } = params;
3682
+ return this._client.delete(path`/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
3683
+ ...options,
3684
+ __security: { adminAPIKeyAuth: true }
3685
+ });
3686
+ }
3687
+ }
3688
+
3689
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs
3690
+ class Groups2 extends APIResource {
3691
+ constructor() {
3692
+ super(...arguments);
3693
+ this.roles = new Roles4(this._client);
3694
+ }
3695
+ create(projectID, body, options) {
3696
+ return this._client.post(path`/organization/projects/${projectID}/groups`, {
3697
+ body,
3698
+ ...options,
3699
+ __security: { adminAPIKeyAuth: true }
3700
+ });
3701
+ }
3702
+ retrieve(groupID, params, options) {
3703
+ const { project_id, ...query } = params;
3704
+ return this._client.get(path`/organization/projects/${project_id}/groups/${groupID}`, {
3705
+ query,
3706
+ ...options,
3707
+ __security: { adminAPIKeyAuth: true }
3708
+ });
3709
+ }
3710
+ list(projectID, query = {}, options) {
3711
+ return this._client.getAPIList(path`/organization/projects/${projectID}/groups`, NextCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3712
+ }
3713
+ delete(groupID, params, options) {
3714
+ const { project_id } = params;
3715
+ return this._client.delete(path`/organization/projects/${project_id}/groups/${groupID}`, {
3716
+ ...options,
3717
+ __security: { adminAPIKeyAuth: true }
3718
+ });
3719
+ }
3720
+ }
3721
+ Groups2.Roles = Roles4;
3722
+
3723
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/users/roles.mjs
3724
+ class Roles5 extends APIResource {
3725
+ create(userID, params, options) {
3726
+ const { project_id, ...body } = params;
3727
+ return this._client.post(path`/projects/${project_id}/users/${userID}/roles`, {
3728
+ body,
3729
+ ...options,
3730
+ __security: { adminAPIKeyAuth: true }
3731
+ });
3732
+ }
3733
+ retrieve(roleID, params, options) {
3734
+ const { project_id, user_id } = params;
3735
+ return this._client.get(path`/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
3736
+ ...options,
3737
+ __security: { adminAPIKeyAuth: true }
3738
+ });
3739
+ }
3740
+ list(userID, params, options) {
3741
+ const { project_id, ...query } = params;
3742
+ return this._client.getAPIList(path`/projects/${project_id}/users/${userID}/roles`, NextCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3743
+ }
3744
+ delete(roleID, params, options) {
3745
+ const { project_id, user_id } = params;
3746
+ return this._client.delete(path`/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
3747
+ ...options,
3748
+ __security: { adminAPIKeyAuth: true }
3749
+ });
3750
+ }
3751
+ }
3752
+
3753
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/users/users.mjs
3754
+ class Users2 extends APIResource {
3755
+ constructor() {
3756
+ super(...arguments);
3757
+ this.roles = new Roles5(this._client);
3758
+ }
3759
+ create(projectID, body, options) {
3760
+ return this._client.post(path`/organization/projects/${projectID}/users`, {
3761
+ body,
3762
+ ...options,
3763
+ __security: { adminAPIKeyAuth: true }
3764
+ });
3765
+ }
3766
+ retrieve(userID, params, options) {
3767
+ const { project_id } = params;
3768
+ return this._client.get(path`/organization/projects/${project_id}/users/${userID}`, {
3769
+ ...options,
3770
+ __security: { adminAPIKeyAuth: true }
3771
+ });
3772
+ }
3773
+ update(userID, params, options) {
3774
+ const { project_id, ...body } = params;
3775
+ return this._client.post(path`/organization/projects/${project_id}/users/${userID}`, {
3776
+ body,
3777
+ ...options,
3778
+ __security: { adminAPIKeyAuth: true }
3779
+ });
3780
+ }
3781
+ list(projectID, query = {}, options) {
3782
+ return this._client.getAPIList(path`/organization/projects/${projectID}/users`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3783
+ }
3784
+ delete(userID, params, options) {
3785
+ const { project_id } = params;
3786
+ return this._client.delete(path`/organization/projects/${project_id}/users/${userID}`, {
3787
+ ...options,
3788
+ __security: { adminAPIKeyAuth: true }
3789
+ });
3790
+ }
3791
+ }
3792
+ Users2.Roles = Roles5;
3793
+
3794
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/projects/projects.mjs
3795
+ class Projects extends APIResource {
3796
+ constructor() {
3797
+ super(...arguments);
3798
+ this.users = new Users2(this._client);
3799
+ this.serviceAccounts = new ServiceAccounts(this._client);
3800
+ this.apiKeys = new APIKeys(this._client);
3801
+ this.rateLimits = new RateLimits(this._client);
3802
+ this.modelPermissions = new ModelPermissions(this._client);
3803
+ this.hostedToolPermissions = new HostedToolPermissions(this._client);
3804
+ this.groups = new Groups2(this._client);
3805
+ this.roles = new Roles3(this._client);
3806
+ this.dataRetention = new DataRetention2(this._client);
3807
+ this.spendAlerts = new SpendAlerts2(this._client);
3808
+ this.certificates = new Certificates2(this._client);
3809
+ }
3810
+ create(body, options) {
3811
+ return this._client.post("/organization/projects", {
3812
+ body,
3813
+ ...options,
3814
+ __security: { adminAPIKeyAuth: true }
3815
+ });
3816
+ }
3817
+ retrieve(projectID, options) {
3818
+ return this._client.get(path`/organization/projects/${projectID}`, {
3819
+ ...options,
3820
+ __security: { adminAPIKeyAuth: true }
3821
+ });
3822
+ }
3823
+ update(projectID, body, options) {
3824
+ return this._client.post(path`/organization/projects/${projectID}`, {
3825
+ body,
3826
+ ...options,
3827
+ __security: { adminAPIKeyAuth: true }
3828
+ });
3829
+ }
3830
+ list(query = {}, options) {
3831
+ return this._client.getAPIList("/organization/projects", ConversationCursorPage, {
3832
+ query,
3833
+ ...options,
3834
+ __security: { adminAPIKeyAuth: true }
3835
+ });
3836
+ }
3837
+ archive(projectID, options) {
3838
+ return this._client.post(path`/organization/projects/${projectID}/archive`, {
3839
+ ...options,
3840
+ __security: { adminAPIKeyAuth: true }
3841
+ });
3842
+ }
3843
+ }
3844
+ Projects.Users = Users2;
3845
+ Projects.ServiceAccounts = ServiceAccounts;
3846
+ Projects.APIKeys = APIKeys;
3847
+ Projects.RateLimits = RateLimits;
3848
+ Projects.ModelPermissions = ModelPermissions;
3849
+ Projects.HostedToolPermissions = HostedToolPermissions;
3850
+ Projects.Groups = Groups2;
3851
+ Projects.Roles = Roles3;
3852
+ Projects.DataRetention = DataRetention2;
3853
+ Projects.SpendAlerts = SpendAlerts2;
3854
+ Projects.Certificates = Certificates2;
3855
+
3856
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/users/roles.mjs
3857
+ class Roles6 extends APIResource {
3858
+ create(userID, body, options) {
3859
+ return this._client.post(path`/organization/users/${userID}/roles`, {
3860
+ body,
3861
+ ...options,
3862
+ __security: { adminAPIKeyAuth: true }
3863
+ });
3864
+ }
3865
+ retrieve(roleID, params, options) {
3866
+ const { user_id } = params;
3867
+ return this._client.get(path`/organization/users/${user_id}/roles/${roleID}`, {
3868
+ ...options,
3869
+ __security: { adminAPIKeyAuth: true }
3870
+ });
3871
+ }
3872
+ list(userID, query = {}, options) {
3873
+ return this._client.getAPIList(path`/organization/users/${userID}/roles`, NextCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
3874
+ }
3875
+ delete(roleID, params, options) {
3876
+ const { user_id } = params;
3877
+ return this._client.delete(path`/organization/users/${user_id}/roles/${roleID}`, {
3878
+ ...options,
3879
+ __security: { adminAPIKeyAuth: true }
3880
+ });
3881
+ }
3882
+ }
3883
+
3884
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/users/users.mjs
3885
+ class Users3 extends APIResource {
3886
+ constructor() {
3887
+ super(...arguments);
3888
+ this.roles = new Roles6(this._client);
3889
+ }
3890
+ retrieve(userID, options) {
3891
+ return this._client.get(path`/organization/users/${userID}`, {
3892
+ ...options,
3893
+ __security: { adminAPIKeyAuth: true }
3894
+ });
3895
+ }
3896
+ update(userID, body, options) {
3897
+ return this._client.post(path`/organization/users/${userID}`, {
3898
+ body,
3899
+ ...options,
3900
+ __security: { adminAPIKeyAuth: true }
3901
+ });
3902
+ }
3903
+ list(query = {}, options) {
3904
+ return this._client.getAPIList("/organization/users", ConversationCursorPage, {
3905
+ query,
3906
+ ...options,
3907
+ __security: { adminAPIKeyAuth: true }
3908
+ });
3909
+ }
3910
+ delete(userID, options) {
3911
+ return this._client.delete(path`/organization/users/${userID}`, {
3912
+ ...options,
3913
+ __security: { adminAPIKeyAuth: true }
3914
+ });
3915
+ }
3916
+ }
3917
+ Users3.Roles = Roles6;
3918
+
3919
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/organization/organization.mjs
3920
+ class Organization extends APIResource {
3921
+ constructor() {
3922
+ super(...arguments);
3923
+ this.auditLogs = new AuditLogs(this._client);
3924
+ this.adminAPIKeys = new AdminAPIKeys(this._client);
3925
+ this.usage = new Usage(this._client);
3926
+ this.invites = new Invites(this._client);
3927
+ this.users = new Users3(this._client);
3928
+ this.groups = new Groups(this._client);
3929
+ this.roles = new Roles(this._client);
3930
+ this.dataRetention = new DataRetention(this._client);
3931
+ this.spendAlerts = new SpendAlerts(this._client);
3932
+ this.certificates = new Certificates(this._client);
3933
+ this.projects = new Projects(this._client);
3934
+ }
3935
+ }
3936
+ Organization.AuditLogs = AuditLogs;
3937
+ Organization.AdminAPIKeys = AdminAPIKeys;
3938
+ Organization.Usage = Usage;
3939
+ Organization.Invites = Invites;
3940
+ Organization.Users = Users3;
3941
+ Organization.Groups = Groups;
3942
+ Organization.Roles = Roles;
3943
+ Organization.DataRetention = DataRetention;
3944
+ Organization.SpendAlerts = SpendAlerts;
3945
+ Organization.Certificates = Certificates;
3946
+ Organization.Projects = Projects;
3947
+
3948
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/admin/admin.mjs
3949
+ class Admin extends APIResource {
3950
+ constructor() {
3951
+ super(...arguments);
3952
+ this.organization = new Organization(this._client);
3953
+ }
3954
+ }
3955
+ Admin.Organization = Organization;
3956
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/internal/headers.mjs
3957
+ var brand_privateNullableHeaders = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
3958
+ function* iterateHeaders(headers) {
3959
+ if (!headers)
3960
+ return;
3961
+ if (brand_privateNullableHeaders in headers) {
3962
+ const { values, nulls } = headers;
3963
+ yield* values.entries();
3964
+ for (const name of nulls) {
3965
+ yield [name, null];
3966
+ }
3967
+ return;
3968
+ }
3969
+ let shouldClear = false;
3970
+ let iter;
3971
+ if (headers instanceof Headers) {
3972
+ iter = headers.entries();
3973
+ } else if (isReadonlyArray(headers)) {
3974
+ iter = headers;
3975
+ } else {
3976
+ shouldClear = true;
3977
+ iter = Object.entries(headers ?? {});
3978
+ }
3979
+ for (let row of iter) {
3980
+ const name = row[0];
3981
+ if (typeof name !== "string")
3982
+ throw new TypeError("expected header name to be a string");
3983
+ const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
3984
+ let didClear = false;
3985
+ for (const value of values) {
3986
+ if (value === undefined)
3987
+ continue;
3988
+ if (shouldClear && !didClear) {
3989
+ didClear = true;
3990
+ yield [name, null];
3991
+ }
3992
+ yield [name, value];
3993
+ }
3994
+ }
3995
+ }
3996
+ var buildHeaders = (newHeaders) => {
3997
+ const targetHeaders = new Headers;
3998
+ const nullHeaders = new Set;
3999
+ for (const headers of newHeaders) {
4000
+ const seenHeaders = new Set;
4001
+ for (const [name, value] of iterateHeaders(headers)) {
4002
+ const lowerName = name.toLowerCase();
4003
+ if (!seenHeaders.has(lowerName)) {
4004
+ targetHeaders.delete(name);
4005
+ seenHeaders.add(lowerName);
4006
+ }
4007
+ if (value === null) {
4008
+ targetHeaders.delete(name);
4009
+ nullHeaders.add(lowerName);
4010
+ } else {
4011
+ targetHeaders.append(name, value);
4012
+ nullHeaders.delete(lowerName);
4013
+ }
4014
+ }
4015
+ }
4016
+ return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
4017
+ };
4018
+
4019
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/speech.mjs
4020
+ class Speech extends APIResource {
4021
+ create(body, options) {
4022
+ return this._client.post("/audio/speech", {
4023
+ body,
4024
+ ...options,
4025
+ headers: buildHeaders([{ Accept: "application/octet-stream" }, options?.headers]),
4026
+ __security: { bearerAuth: true },
4027
+ __binaryResponse: true
4028
+ });
4029
+ }
4030
+ }
4031
+
4032
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/transcriptions.mjs
4033
+ class Transcriptions extends APIResource {
4034
+ create(body, options) {
4035
+ return this._client.post("/audio/transcriptions", multipartFormRequestOptions({
4036
+ body,
4037
+ ...options,
4038
+ stream: body.stream ?? false,
4039
+ __metadata: { model: body.model },
4040
+ __security: { bearerAuth: true }
4041
+ }, this._client));
4042
+ }
4043
+ }
4044
+
4045
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/translations.mjs
4046
+ class Translations extends APIResource {
4047
+ create(body, options) {
4048
+ return this._client.post("/audio/translations", multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model }, __security: { bearerAuth: true } }, this._client));
4049
+ }
4050
+ }
4051
+
4052
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/audio/audio.mjs
4053
+ class Audio extends APIResource {
4054
+ constructor() {
4055
+ super(...arguments);
4056
+ this.transcriptions = new Transcriptions(this._client);
4057
+ this.translations = new Translations(this._client);
4058
+ this.speech = new Speech(this._client);
4059
+ }
4060
+ }
4061
+ Audio.Transcriptions = Transcriptions;
4062
+ Audio.Translations = Translations;
4063
+ Audio.Speech = Speech;
4064
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/batches.mjs
4065
+ class Batches extends APIResource {
4066
+ create(body, options) {
4067
+ return this._client.post("/batches", { body, ...options, __security: { bearerAuth: true } });
4068
+ }
4069
+ retrieve(batchID, options) {
4070
+ return this._client.get(path`/batches/${batchID}`, { ...options, __security: { bearerAuth: true } });
4071
+ }
4072
+ list(query = {}, options) {
4073
+ return this._client.getAPIList("/batches", CursorPage, {
4074
+ query,
4075
+ ...options,
4076
+ __security: { bearerAuth: true }
4077
+ });
4078
+ }
4079
+ cancel(batchID, options) {
4080
+ return this._client.post(path`/batches/${batchID}/cancel`, {
4081
+ ...options,
4082
+ __security: { bearerAuth: true }
4083
+ });
4084
+ }
4085
+ }
4086
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/assistants.mjs
4087
+ class Assistants extends APIResource {
4088
+ create(body, options) {
4089
+ return this._client.post("/assistants", {
4090
+ body,
4091
+ ...options,
4092
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4093
+ __security: { bearerAuth: true }
4094
+ });
4095
+ }
4096
+ retrieve(assistantID, options) {
4097
+ return this._client.get(path`/assistants/${assistantID}`, {
4098
+ ...options,
4099
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4100
+ __security: { bearerAuth: true }
4101
+ });
4102
+ }
4103
+ update(assistantID, body, options) {
4104
+ return this._client.post(path`/assistants/${assistantID}`, {
4105
+ body,
4106
+ ...options,
4107
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4108
+ __security: { bearerAuth: true }
4109
+ });
4110
+ }
4111
+ list(query = {}, options) {
4112
+ return this._client.getAPIList("/assistants", CursorPage, {
4113
+ query,
4114
+ ...options,
4115
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4116
+ __security: { bearerAuth: true }
4117
+ });
4118
+ }
4119
+ delete(assistantID, options) {
4120
+ return this._client.delete(path`/assistants/${assistantID}`, {
4121
+ ...options,
4122
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4123
+ __security: { bearerAuth: true }
4124
+ });
4125
+ }
4126
+ }
4127
+
4128
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/realtime/sessions.mjs
4129
+ class Sessions extends APIResource {
4130
+ create(body, options) {
4131
+ return this._client.post("/realtime/sessions", {
4132
+ body,
4133
+ ...options,
4134
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4135
+ __security: { bearerAuth: true }
4136
+ });
4137
+ }
4138
+ }
4139
+
4140
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs
4141
+ class TranscriptionSessions extends APIResource {
4142
+ create(body, options) {
4143
+ return this._client.post("/realtime/transcription_sessions", {
4144
+ body,
4145
+ ...options,
4146
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4147
+ __security: { bearerAuth: true }
4148
+ });
4149
+ }
4150
+ }
4151
+
4152
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/realtime/realtime.mjs
4153
+ class Realtime extends APIResource {
4154
+ constructor() {
4155
+ super(...arguments);
4156
+ this.sessions = new Sessions(this._client);
4157
+ this.transcriptionSessions = new TranscriptionSessions(this._client);
4158
+ }
4159
+ }
4160
+ Realtime.Sessions = Sessions;
4161
+ Realtime.TranscriptionSessions = TranscriptionSessions;
4162
+
4163
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/chatkit/sessions.mjs
4164
+ class Sessions2 extends APIResource {
4165
+ create(body, options) {
4166
+ return this._client.post("/chatkit/sessions", {
4167
+ body,
4168
+ ...options,
4169
+ headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]),
4170
+ __security: { bearerAuth: true }
4171
+ });
4172
+ }
4173
+ cancel(sessionID, options) {
4174
+ return this._client.post(path`/chatkit/sessions/${sessionID}/cancel`, {
4175
+ ...options,
4176
+ headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]),
4177
+ __security: { bearerAuth: true }
4178
+ });
4179
+ }
4180
+ }
4181
+
4182
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/chatkit/threads.mjs
4183
+ class Threads extends APIResource {
4184
+ retrieve(threadID, options) {
4185
+ return this._client.get(path`/chatkit/threads/${threadID}`, {
4186
+ ...options,
4187
+ headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]),
4188
+ __security: { bearerAuth: true }
4189
+ });
4190
+ }
4191
+ list(query = {}, options) {
4192
+ return this._client.getAPIList("/chatkit/threads", ConversationCursorPage, {
4193
+ query,
4194
+ ...options,
4195
+ headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]),
4196
+ __security: { bearerAuth: true }
4197
+ });
4198
+ }
4199
+ delete(threadID, options) {
4200
+ return this._client.delete(path`/chatkit/threads/${threadID}`, {
4201
+ ...options,
4202
+ headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]),
4203
+ __security: { bearerAuth: true }
4204
+ });
4205
+ }
4206
+ listItems(threadID, query = {}, options) {
4207
+ return this._client.getAPIList(path`/chatkit/threads/${threadID}/items`, ConversationCursorPage, {
4208
+ query,
4209
+ ...options,
4210
+ headers: buildHeaders([{ "OpenAI-Beta": "chatkit_beta=v1" }, options?.headers]),
4211
+ __security: { bearerAuth: true }
4212
+ });
4213
+ }
4214
+ }
4215
+
4216
+ // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/beta/chatkit/chatkit.mjs
4217
+ class ChatKit extends APIResource {
4218
+ constructor() {
4219
+ super(...arguments);
4220
+ this.sessions = new Sessions2(this._client);
3151
4221
  this.threads = new Threads(this._client);
3152
4222
  }
3153
4223
  }
@@ -3160,14 +4230,16 @@ class Messages2 extends APIResource {
3160
4230
  return this._client.post(path`/threads/${threadID}/messages`, {
3161
4231
  body,
3162
4232
  ...options,
3163
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4233
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4234
+ __security: { bearerAuth: true }
3164
4235
  });
3165
4236
  }
3166
4237
  retrieve(messageID, params, options) {
3167
4238
  const { thread_id } = params;
3168
4239
  return this._client.get(path`/threads/${thread_id}/messages/${messageID}`, {
3169
4240
  ...options,
3170
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4241
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4242
+ __security: { bearerAuth: true }
3171
4243
  });
3172
4244
  }
3173
4245
  update(messageID, params, options) {
@@ -3175,21 +4247,24 @@ class Messages2 extends APIResource {
3175
4247
  return this._client.post(path`/threads/${thread_id}/messages/${messageID}`, {
3176
4248
  body,
3177
4249
  ...options,
3178
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4250
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4251
+ __security: { bearerAuth: true }
3179
4252
  });
3180
4253
  }
3181
4254
  list(threadID, query = {}, options) {
3182
4255
  return this._client.getAPIList(path`/threads/${threadID}/messages`, CursorPage, {
3183
4256
  query,
3184
4257
  ...options,
3185
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4258
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4259
+ __security: { bearerAuth: true }
3186
4260
  });
3187
4261
  }
3188
4262
  delete(messageID, params, options) {
3189
4263
  const { thread_id } = params;
3190
4264
  return this._client.delete(path`/threads/${thread_id}/messages/${messageID}`, {
3191
4265
  ...options,
3192
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4266
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4267
+ __security: { bearerAuth: true }
3193
4268
  });
3194
4269
  }
3195
4270
  }
@@ -3201,7 +4276,8 @@ class Steps extends APIResource {
3201
4276
  return this._client.get(path`/threads/${thread_id}/runs/${run_id}/steps/${stepID}`, {
3202
4277
  query,
3203
4278
  ...options,
3204
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4279
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4280
+ __security: { bearerAuth: true }
3205
4281
  });
3206
4282
  }
3207
4283
  list(runID, params, options) {
@@ -3209,7 +4285,8 @@ class Steps extends APIResource {
3209
4285
  return this._client.getAPIList(path`/threads/${thread_id}/runs/${runID}/steps`, CursorPage, {
3210
4286
  query,
3211
4287
  ...options,
3212
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4288
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4289
+ __security: { bearerAuth: true }
3213
4290
  });
3214
4291
  }
3215
4292
  }
@@ -3231,10 +4308,10 @@ var toFloat32Array = (base64Str) => {
3231
4308
  // node_modules/@earendil-works/pi-ai/node_modules/openai/internal/utils/env.mjs
3232
4309
  var readEnv = (env) => {
3233
4310
  if (typeof globalThis.process !== "undefined") {
3234
- return globalThis.process.env?.[env]?.trim() ?? undefined;
4311
+ return globalThis.process.env?.[env]?.trim() || undefined;
3235
4312
  }
3236
4313
  if (typeof globalThis.Deno !== "undefined") {
3237
- return globalThis.Deno.env?.get?.(env)?.trim();
4314
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
3238
4315
  }
3239
4316
  return;
3240
4317
  };
@@ -3791,14 +4868,16 @@ class Runs extends APIResource {
3791
4868
  ...options,
3792
4869
  headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
3793
4870
  stream: params.stream ?? false,
3794
- __synthesizeEventData: true
4871
+ __synthesizeEventData: true,
4872
+ __security: { bearerAuth: true }
3795
4873
  });
3796
4874
  }
3797
4875
  retrieve(runID, params, options) {
3798
4876
  const { thread_id } = params;
3799
4877
  return this._client.get(path`/threads/${thread_id}/runs/${runID}`, {
3800
4878
  ...options,
3801
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4879
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4880
+ __security: { bearerAuth: true }
3802
4881
  });
3803
4882
  }
3804
4883
  update(runID, params, options) {
@@ -3806,21 +4885,24 @@ class Runs extends APIResource {
3806
4885
  return this._client.post(path`/threads/${thread_id}/runs/${runID}`, {
3807
4886
  body,
3808
4887
  ...options,
3809
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4888
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4889
+ __security: { bearerAuth: true }
3810
4890
  });
3811
4891
  }
3812
4892
  list(threadID, query2 = {}, options) {
3813
4893
  return this._client.getAPIList(path`/threads/${threadID}/runs`, CursorPage, {
3814
4894
  query: query2,
3815
4895
  ...options,
3816
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4896
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4897
+ __security: { bearerAuth: true }
3817
4898
  });
3818
4899
  }
3819
4900
  cancel(runID, params, options) {
3820
4901
  const { thread_id } = params;
3821
4902
  return this._client.post(path`/threads/${thread_id}/runs/${runID}/cancel`, {
3822
4903
  ...options,
3823
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4904
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4905
+ __security: { bearerAuth: true }
3824
4906
  });
3825
4907
  }
3826
4908
  async createAndPoll(threadId, body, options) {
@@ -3881,7 +4963,8 @@ class Runs extends APIResource {
3881
4963
  ...options,
3882
4964
  headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
3883
4965
  stream: params.stream ?? false,
3884
- __synthesizeEventData: true
4966
+ __synthesizeEventData: true,
4967
+ __security: { bearerAuth: true }
3885
4968
  });
3886
4969
  }
3887
4970
  async submitToolOutputsAndPoll(runId, params, options) {
@@ -3905,26 +4988,30 @@ class Threads2 extends APIResource {
3905
4988
  return this._client.post("/threads", {
3906
4989
  body,
3907
4990
  ...options,
3908
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4991
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4992
+ __security: { bearerAuth: true }
3909
4993
  });
3910
4994
  }
3911
4995
  retrieve(threadID, options) {
3912
4996
  return this._client.get(path`/threads/${threadID}`, {
3913
4997
  ...options,
3914
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
4998
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
4999
+ __security: { bearerAuth: true }
3915
5000
  });
3916
5001
  }
3917
5002
  update(threadID, body, options) {
3918
5003
  return this._client.post(path`/threads/${threadID}`, {
3919
5004
  body,
3920
5005
  ...options,
3921
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
5006
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
5007
+ __security: { bearerAuth: true }
3922
5008
  });
3923
5009
  }
3924
5010
  delete(threadID, options) {
3925
5011
  return this._client.delete(path`/threads/${threadID}`, {
3926
5012
  ...options,
3927
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
5013
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
5014
+ __security: { bearerAuth: true }
3928
5015
  });
3929
5016
  }
3930
5017
  createAndRun(body, options) {
@@ -3933,7 +5020,8 @@ class Threads2 extends APIResource {
3933
5020
  ...options,
3934
5021
  headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
3935
5022
  stream: body.stream ?? false,
3936
- __synthesizeEventData: true
5023
+ __synthesizeEventData: true,
5024
+ __security: { bearerAuth: true }
3937
5025
  });
3938
5026
  }
3939
5027
  async createAndRunPoll(body, options) {
@@ -3964,7 +5052,12 @@ Beta.Threads = Threads2;
3964
5052
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/completions.mjs
3965
5053
  class Completions2 extends APIResource {
3966
5054
  create(body, options) {
3967
- return this._client.post("/completions", { body, ...options, stream: body.stream ?? false });
5055
+ return this._client.post("/completions", {
5056
+ body,
5057
+ ...options,
5058
+ stream: body.stream ?? false,
5059
+ __security: { bearerAuth: true }
5060
+ });
3968
5061
  }
3969
5062
  }
3970
5063
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/containers/files/content.mjs
@@ -3974,6 +5067,7 @@ class Content extends APIResource {
3974
5067
  return this._client.get(path`/containers/${container_id}/files/${fileID}/content`, {
3975
5068
  ...options,
3976
5069
  headers: buildHeaders([{ Accept: "application/binary" }, options?.headers]),
5070
+ __security: { bearerAuth: true },
3977
5071
  __binaryResponse: true
3978
5072
  });
3979
5073
  }
@@ -3986,23 +5080,28 @@ class Files extends APIResource {
3986
5080
  this.content = new Content(this._client);
3987
5081
  }
3988
5082
  create(containerID, body, options) {
3989
- return this._client.post(path`/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
5083
+ return this._client.post(path`/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
3990
5084
  }
3991
5085
  retrieve(fileID, params, options) {
3992
5086
  const { container_id } = params;
3993
- return this._client.get(path`/containers/${container_id}/files/${fileID}`, options);
5087
+ return this._client.get(path`/containers/${container_id}/files/${fileID}`, {
5088
+ ...options,
5089
+ __security: { bearerAuth: true }
5090
+ });
3994
5091
  }
3995
5092
  list(containerID, query2 = {}, options) {
3996
5093
  return this._client.getAPIList(path`/containers/${containerID}/files`, CursorPage, {
3997
5094
  query: query2,
3998
- ...options
5095
+ ...options,
5096
+ __security: { bearerAuth: true }
3999
5097
  });
4000
5098
  }
4001
5099
  delete(fileID, params, options) {
4002
5100
  const { container_id } = params;
4003
5101
  return this._client.delete(path`/containers/${container_id}/files/${fileID}`, {
4004
5102
  ...options,
4005
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
5103
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
5104
+ __security: { bearerAuth: true }
4006
5105
  });
4007
5106
  }
4008
5107
  }
@@ -4015,18 +5114,26 @@ class Containers extends APIResource {
4015
5114
  this.files = new Files(this._client);
4016
5115
  }
4017
5116
  create(body, options) {
4018
- return this._client.post("/containers", { body, ...options });
5117
+ return this._client.post("/containers", { body, ...options, __security: { bearerAuth: true } });
4019
5118
  }
4020
5119
  retrieve(containerID, options) {
4021
- return this._client.get(path`/containers/${containerID}`, options);
5120
+ return this._client.get(path`/containers/${containerID}`, {
5121
+ ...options,
5122
+ __security: { bearerAuth: true }
5123
+ });
4022
5124
  }
4023
5125
  list(query2 = {}, options) {
4024
- return this._client.getAPIList("/containers", CursorPage, { query: query2, ...options });
5126
+ return this._client.getAPIList("/containers", CursorPage, {
5127
+ query: query2,
5128
+ ...options,
5129
+ __security: { bearerAuth: true }
5130
+ });
4025
5131
  }
4026
5132
  delete(containerID, options) {
4027
5133
  return this._client.delete(path`/containers/${containerID}`, {
4028
5134
  ...options,
4029
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
5135
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
5136
+ __security: { bearerAuth: true }
4030
5137
  });
4031
5138
  }
4032
5139
  }
@@ -4038,19 +5145,27 @@ class Items extends APIResource {
4038
5145
  return this._client.post(path`/conversations/${conversationID}/items`, {
4039
5146
  query: { include },
4040
5147
  body,
4041
- ...options
5148
+ ...options,
5149
+ __security: { bearerAuth: true }
4042
5150
  });
4043
5151
  }
4044
5152
  retrieve(itemID, params, options) {
4045
5153
  const { conversation_id, ...query2 } = params;
4046
- return this._client.get(path`/conversations/${conversation_id}/items/${itemID}`, { query: query2, ...options });
5154
+ return this._client.get(path`/conversations/${conversation_id}/items/${itemID}`, {
5155
+ query: query2,
5156
+ ...options,
5157
+ __security: { bearerAuth: true }
5158
+ });
4047
5159
  }
4048
5160
  list(conversationID, query2 = {}, options) {
4049
- return this._client.getAPIList(path`/conversations/${conversationID}/items`, ConversationCursorPage, { query: query2, ...options });
5161
+ return this._client.getAPIList(path`/conversations/${conversationID}/items`, ConversationCursorPage, { query: query2, ...options, __security: { bearerAuth: true } });
4050
5162
  }
4051
5163
  delete(itemID, params, options) {
4052
5164
  const { conversation_id } = params;
4053
- return this._client.delete(path`/conversations/${conversation_id}/items/${itemID}`, options);
5165
+ return this._client.delete(path`/conversations/${conversation_id}/items/${itemID}`, {
5166
+ ...options,
5167
+ __security: { bearerAuth: true }
5168
+ });
4054
5169
  }
4055
5170
  }
4056
5171
 
@@ -4061,16 +5176,26 @@ class Conversations extends APIResource {
4061
5176
  this.items = new Items(this._client);
4062
5177
  }
4063
5178
  create(body = {}, options) {
4064
- return this._client.post("/conversations", { body, ...options });
5179
+ return this._client.post("/conversations", { body, ...options, __security: { bearerAuth: true } });
4065
5180
  }
4066
5181
  retrieve(conversationID, options) {
4067
- return this._client.get(path`/conversations/${conversationID}`, options);
5182
+ return this._client.get(path`/conversations/${conversationID}`, {
5183
+ ...options,
5184
+ __security: { bearerAuth: true }
5185
+ });
4068
5186
  }
4069
5187
  update(conversationID, body, options) {
4070
- return this._client.post(path`/conversations/${conversationID}`, { body, ...options });
5188
+ return this._client.post(path`/conversations/${conversationID}`, {
5189
+ body,
5190
+ ...options,
5191
+ __security: { bearerAuth: true }
5192
+ });
4071
5193
  }
4072
5194
  delete(conversationID, options) {
4073
- return this._client.delete(path`/conversations/${conversationID}`, options);
5195
+ return this._client.delete(path`/conversations/${conversationID}`, {
5196
+ ...options,
5197
+ __security: { bearerAuth: true }
5198
+ });
4074
5199
  }
4075
5200
  }
4076
5201
  Conversations.Items = Items;
@@ -4087,7 +5212,8 @@ class Embeddings extends APIResource {
4087
5212
  ...body,
4088
5213
  encoding_format
4089
5214
  },
4090
- ...options
5215
+ ...options,
5216
+ __security: { bearerAuth: true }
4091
5217
  });
4092
5218
  if (hasUserProvidedEncodingFormat) {
4093
5219
  return response;
@@ -4108,11 +5234,14 @@ class Embeddings extends APIResource {
4108
5234
  class OutputItems extends APIResource {
4109
5235
  retrieve(outputItemID, params, options) {
4110
5236
  const { eval_id, run_id } = params;
4111
- return this._client.get(path`/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, options);
5237
+ return this._client.get(path`/evals/${eval_id}/runs/${run_id}/output_items/${outputItemID}`, {
5238
+ ...options,
5239
+ __security: { bearerAuth: true }
5240
+ });
4112
5241
  }
4113
5242
  list(runID, params, options) {
4114
5243
  const { eval_id, ...query2 } = params;
4115
- return this._client.getAPIList(path`/evals/${eval_id}/runs/${runID}/output_items`, CursorPage, { query: query2, ...options });
5244
+ return this._client.getAPIList(path`/evals/${eval_id}/runs/${runID}/output_items`, CursorPage, { query: query2, ...options, __security: { bearerAuth: true } });
4116
5245
  }
4117
5246
  }
4118
5247
 
@@ -4123,25 +5252,39 @@ class Runs2 extends APIResource {
4123
5252
  this.outputItems = new OutputItems(this._client);
4124
5253
  }
4125
5254
  create(evalID, body, options) {
4126
- return this._client.post(path`/evals/${evalID}/runs`, { body, ...options });
5255
+ return this._client.post(path`/evals/${evalID}/runs`, {
5256
+ body,
5257
+ ...options,
5258
+ __security: { bearerAuth: true }
5259
+ });
4127
5260
  }
4128
5261
  retrieve(runID, params, options) {
4129
5262
  const { eval_id } = params;
4130
- return this._client.get(path`/evals/${eval_id}/runs/${runID}`, options);
5263
+ return this._client.get(path`/evals/${eval_id}/runs/${runID}`, {
5264
+ ...options,
5265
+ __security: { bearerAuth: true }
5266
+ });
4131
5267
  }
4132
5268
  list(evalID, query2 = {}, options) {
4133
5269
  return this._client.getAPIList(path`/evals/${evalID}/runs`, CursorPage, {
4134
5270
  query: query2,
4135
- ...options
5271
+ ...options,
5272
+ __security: { bearerAuth: true }
4136
5273
  });
4137
5274
  }
4138
5275
  delete(runID, params, options) {
4139
5276
  const { eval_id } = params;
4140
- return this._client.delete(path`/evals/${eval_id}/runs/${runID}`, options);
5277
+ return this._client.delete(path`/evals/${eval_id}/runs/${runID}`, {
5278
+ ...options,
5279
+ __security: { bearerAuth: true }
5280
+ });
4141
5281
  }
4142
5282
  cancel(runID, params, options) {
4143
5283
  const { eval_id } = params;
4144
- return this._client.post(path`/evals/${eval_id}/runs/${runID}`, options);
5284
+ return this._client.post(path`/evals/${eval_id}/runs/${runID}`, {
5285
+ ...options,
5286
+ __security: { bearerAuth: true }
5287
+ });
4145
5288
  }
4146
5289
  }
4147
5290
  Runs2.OutputItems = OutputItems;
@@ -4153,40 +5296,49 @@ class Evals extends APIResource {
4153
5296
  this.runs = new Runs2(this._client);
4154
5297
  }
4155
5298
  create(body, options) {
4156
- return this._client.post("/evals", { body, ...options });
5299
+ return this._client.post("/evals", { body, ...options, __security: { bearerAuth: true } });
4157
5300
  }
4158
5301
  retrieve(evalID, options) {
4159
- return this._client.get(path`/evals/${evalID}`, options);
5302
+ return this._client.get(path`/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
4160
5303
  }
4161
5304
  update(evalID, body, options) {
4162
- return this._client.post(path`/evals/${evalID}`, { body, ...options });
5305
+ return this._client.post(path`/evals/${evalID}`, { body, ...options, __security: { bearerAuth: true } });
4163
5306
  }
4164
5307
  list(query2 = {}, options) {
4165
- return this._client.getAPIList("/evals", CursorPage, { query: query2, ...options });
5308
+ return this._client.getAPIList("/evals", CursorPage, {
5309
+ query: query2,
5310
+ ...options,
5311
+ __security: { bearerAuth: true }
5312
+ });
4166
5313
  }
4167
5314
  delete(evalID, options) {
4168
- return this._client.delete(path`/evals/${evalID}`, options);
5315
+ return this._client.delete(path`/evals/${evalID}`, { ...options, __security: { bearerAuth: true } });
4169
5316
  }
4170
5317
  }
4171
5318
  Evals.Runs = Runs2;
4172
5319
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/files.mjs
4173
5320
  class Files2 extends APIResource {
4174
5321
  create(body, options) {
4175
- return this._client.post("/files", multipartFormRequestOptions({ body, ...options }, this._client));
5322
+ return this._client.post("/files", multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
4176
5323
  }
4177
5324
  retrieve(fileID, options) {
4178
- return this._client.get(path`/files/${fileID}`, options);
5325
+ return this._client.get(path`/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
4179
5326
  }
4180
5327
  list(query2 = {}, options) {
4181
- return this._client.getAPIList("/files", CursorPage, { query: query2, ...options });
5328
+ return this._client.getAPIList("/files", CursorPage, {
5329
+ query: query2,
5330
+ ...options,
5331
+ __security: { bearerAuth: true }
5332
+ });
4182
5333
  }
4183
5334
  delete(fileID, options) {
4184
- return this._client.delete(path`/files/${fileID}`, options);
5335
+ return this._client.delete(path`/files/${fileID}`, { ...options, __security: { bearerAuth: true } });
4185
5336
  }
4186
5337
  content(fileID, options) {
4187
5338
  return this._client.get(path`/files/${fileID}/content`, {
4188
5339
  ...options,
4189
5340
  headers: buildHeaders([{ Accept: "application/binary" }, options?.headers]),
5341
+ __security: { bearerAuth: true },
4190
5342
  __binaryResponse: true
4191
5343
  });
4192
5344
  }
@@ -4213,10 +5365,18 @@ class Methods extends APIResource {
4213
5365
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/fine-tuning/alpha/graders.mjs
4214
5366
  class Graders extends APIResource {
4215
5367
  run(body, options) {
4216
- return this._client.post("/fine_tuning/alpha/graders/run", { body, ...options });
5368
+ return this._client.post("/fine_tuning/alpha/graders/run", {
5369
+ body,
5370
+ ...options,
5371
+ __security: { bearerAuth: true }
5372
+ });
4217
5373
  }
4218
5374
  validate(body, options) {
4219
- return this._client.post("/fine_tuning/alpha/graders/validate", { body, ...options });
5375
+ return this._client.post("/fine_tuning/alpha/graders/validate", {
5376
+ body,
5377
+ ...options,
5378
+ __security: { bearerAuth: true }
5379
+ });
4220
5380
  }
4221
5381
  }
4222
5382
 
@@ -4232,20 +5392,21 @@ Alpha.Graders = Graders;
4232
5392
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs
4233
5393
  class Permissions extends APIResource {
4234
5394
  create(fineTunedModelCheckpoint, body, options) {
4235
- return this._client.getAPIList(path`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, Page, { body, method: "post", ...options });
5395
+ return this._client.getAPIList(path`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, Page, { body, method: "post", ...options, __security: { adminAPIKeyAuth: true } });
4236
5396
  }
4237
5397
  retrieve(fineTunedModelCheckpoint, query2 = {}, options) {
4238
5398
  return this._client.get(path`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
4239
5399
  query: query2,
4240
- ...options
5400
+ ...options,
5401
+ __security: { adminAPIKeyAuth: true }
4241
5402
  });
4242
5403
  }
4243
5404
  list(fineTunedModelCheckpoint, query2 = {}, options) {
4244
- return this._client.getAPIList(path`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, ConversationCursorPage, { query: query2, ...options });
5405
+ return this._client.getAPIList(path`/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, ConversationCursorPage, { query: query2, ...options, __security: { adminAPIKeyAuth: true } });
4245
5406
  }
4246
5407
  delete(permissionID, params, options) {
4247
5408
  const { fine_tuned_model_checkpoint } = params;
4248
- return this._client.delete(path`/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, options);
5409
+ return this._client.delete(path`/fine_tuning/checkpoints/${fine_tuned_model_checkpoint}/permissions/${permissionID}`, { ...options, __security: { adminAPIKeyAuth: true } });
4249
5410
  }
4250
5411
  }
4251
5412
 
@@ -4261,7 +5422,7 @@ Checkpoints.Permissions = Permissions;
4261
5422
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
4262
5423
  class Checkpoints2 extends APIResource {
4263
5424
  list(fineTuningJobID, query2 = {}, options) {
4264
- return this._client.getAPIList(path`/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, CursorPage, { query: query2, ...options });
5425
+ return this._client.getAPIList(path`/fine_tuning/jobs/${fineTuningJobID}/checkpoints`, CursorPage, { query: query2, ...options, __security: { bearerAuth: true } });
4265
5426
  }
4266
5427
  }
4267
5428
 
@@ -4272,25 +5433,41 @@ class Jobs extends APIResource {
4272
5433
  this.checkpoints = new Checkpoints2(this._client);
4273
5434
  }
4274
5435
  create(body, options) {
4275
- return this._client.post("/fine_tuning/jobs", { body, ...options });
5436
+ return this._client.post("/fine_tuning/jobs", { body, ...options, __security: { bearerAuth: true } });
4276
5437
  }
4277
5438
  retrieve(fineTuningJobID, options) {
4278
- return this._client.get(path`/fine_tuning/jobs/${fineTuningJobID}`, options);
5439
+ return this._client.get(path`/fine_tuning/jobs/${fineTuningJobID}`, {
5440
+ ...options,
5441
+ __security: { bearerAuth: true }
5442
+ });
4279
5443
  }
4280
5444
  list(query2 = {}, options) {
4281
- return this._client.getAPIList("/fine_tuning/jobs", CursorPage, { query: query2, ...options });
5445
+ return this._client.getAPIList("/fine_tuning/jobs", CursorPage, {
5446
+ query: query2,
5447
+ ...options,
5448
+ __security: { bearerAuth: true }
5449
+ });
4282
5450
  }
4283
5451
  cancel(fineTuningJobID, options) {
4284
- return this._client.post(path`/fine_tuning/jobs/${fineTuningJobID}/cancel`, options);
5452
+ return this._client.post(path`/fine_tuning/jobs/${fineTuningJobID}/cancel`, {
5453
+ ...options,
5454
+ __security: { bearerAuth: true }
5455
+ });
4285
5456
  }
4286
5457
  listEvents(fineTuningJobID, query2 = {}, options) {
4287
- return this._client.getAPIList(path`/fine_tuning/jobs/${fineTuningJobID}/events`, CursorPage, { query: query2, ...options });
5458
+ return this._client.getAPIList(path`/fine_tuning/jobs/${fineTuningJobID}/events`, CursorPage, { query: query2, ...options, __security: { bearerAuth: true } });
4288
5459
  }
4289
5460
  pause(fineTuningJobID, options) {
4290
- return this._client.post(path`/fine_tuning/jobs/${fineTuningJobID}/pause`, options);
5461
+ return this._client.post(path`/fine_tuning/jobs/${fineTuningJobID}/pause`, {
5462
+ ...options,
5463
+ __security: { bearerAuth: true }
5464
+ });
4291
5465
  }
4292
5466
  resume(fineTuningJobID, options) {
4293
- return this._client.post(path`/fine_tuning/jobs/${fineTuningJobID}/resume`, options);
5467
+ return this._client.post(path`/fine_tuning/jobs/${fineTuningJobID}/resume`, {
5468
+ ...options,
5469
+ __security: { bearerAuth: true }
5470
+ });
4294
5471
  }
4295
5472
  }
4296
5473
  Jobs.Checkpoints = Checkpoints2;
@@ -4324,31 +5501,36 @@ Graders2.GraderModels = GraderModels;
4324
5501
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/images.mjs
4325
5502
  class Images extends APIResource {
4326
5503
  createVariation(body, options) {
4327
- return this._client.post("/images/variations", multipartFormRequestOptions({ body, ...options }, this._client));
5504
+ return this._client.post("/images/variations", multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
4328
5505
  }
4329
5506
  edit(body, options) {
4330
- return this._client.post("/images/edits", multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false }, this._client));
5507
+ return this._client.post("/images/edits", multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false, __security: { bearerAuth: true } }, this._client));
4331
5508
  }
4332
5509
  generate(body, options) {
4333
- return this._client.post("/images/generations", { body, ...options, stream: body.stream ?? false });
5510
+ return this._client.post("/images/generations", {
5511
+ body,
5512
+ ...options,
5513
+ stream: body.stream ?? false,
5514
+ __security: { bearerAuth: true }
5515
+ });
4334
5516
  }
4335
5517
  }
4336
5518
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/models.mjs
4337
5519
  class Models extends APIResource {
4338
5520
  retrieve(model, options) {
4339
- return this._client.get(path`/models/${model}`, options);
5521
+ return this._client.get(path`/models/${model}`, { ...options, __security: { bearerAuth: true } });
4340
5522
  }
4341
5523
  list(options) {
4342
- return this._client.getAPIList("/models", Page, options);
5524
+ return this._client.getAPIList("/models", Page, { ...options, __security: { bearerAuth: true } });
4343
5525
  }
4344
5526
  delete(model, options) {
4345
- return this._client.delete(path`/models/${model}`, options);
5527
+ return this._client.delete(path`/models/${model}`, { ...options, __security: { bearerAuth: true } });
4346
5528
  }
4347
5529
  }
4348
5530
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/moderations.mjs
4349
5531
  class Moderations extends APIResource {
4350
5532
  create(body, options) {
4351
- return this._client.post("/moderations", { body, ...options });
5533
+ return this._client.post("/moderations", { body, ...options, __security: { bearerAuth: true } });
4352
5534
  }
4353
5535
  }
4354
5536
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/realtime/calls.mjs
@@ -4357,27 +5539,31 @@ class Calls extends APIResource {
4357
5539
  return this._client.post(path`/realtime/calls/${callID}/accept`, {
4358
5540
  body,
4359
5541
  ...options,
4360
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
5542
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
5543
+ __security: { bearerAuth: true }
4361
5544
  });
4362
5545
  }
4363
5546
  hangup(callID, options) {
4364
5547
  return this._client.post(path`/realtime/calls/${callID}/hangup`, {
4365
5548
  ...options,
4366
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
5549
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
5550
+ __security: { bearerAuth: true }
4367
5551
  });
4368
5552
  }
4369
5553
  refer(callID, body, options) {
4370
5554
  return this._client.post(path`/realtime/calls/${callID}/refer`, {
4371
5555
  body,
4372
5556
  ...options,
4373
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
5557
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
5558
+ __security: { bearerAuth: true }
4374
5559
  });
4375
5560
  }
4376
5561
  reject(callID, body = {}, options) {
4377
5562
  return this._client.post(path`/realtime/calls/${callID}/reject`, {
4378
5563
  body,
4379
5564
  ...options,
4380
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
5565
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
5566
+ __security: { bearerAuth: true }
4381
5567
  });
4382
5568
  }
4383
5569
  }
@@ -4385,7 +5571,11 @@ class Calls extends APIResource {
4385
5571
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/realtime/client-secrets.mjs
4386
5572
  class ClientSecrets extends APIResource {
4387
5573
  create(body, options) {
4388
- return this._client.post("/realtime/client_secrets", { body, ...options });
5574
+ return this._client.post("/realtime/client_secrets", {
5575
+ body,
5576
+ ...options,
5577
+ __security: { bearerAuth: true }
5578
+ });
4389
5579
  }
4390
5580
  }
4391
5581
 
@@ -4782,14 +5972,18 @@ function finalizeResponse(snapshot, params) {
4782
5972
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/responses/input-items.mjs
4783
5973
  class InputItems extends APIResource {
4784
5974
  list(responseID, query2 = {}, options) {
4785
- return this._client.getAPIList(path`/responses/${responseID}/input_items`, CursorPage, { query: query2, ...options });
5975
+ return this._client.getAPIList(path`/responses/${responseID}/input_items`, CursorPage, { query: query2, ...options, __security: { bearerAuth: true } });
4786
5976
  }
4787
5977
  }
4788
5978
 
4789
5979
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/responses/input-tokens.mjs
4790
5980
  class InputTokens extends APIResource {
4791
5981
  count(body = {}, options) {
4792
- return this._client.post("/responses/input_tokens", { body, ...options });
5982
+ return this._client.post("/responses/input_tokens", {
5983
+ body,
5984
+ ...options,
5985
+ __security: { bearerAuth: true }
5986
+ });
4793
5987
  }
4794
5988
  }
4795
5989
 
@@ -4801,7 +5995,12 @@ class Responses extends APIResource {
4801
5995
  this.inputTokens = new InputTokens(this._client);
4802
5996
  }
4803
5997
  create(body, options) {
4804
- return this._client.post("/responses", { body, ...options, stream: body.stream ?? false })._thenUnwrap((rsp) => {
5998
+ return this._client.post("/responses", {
5999
+ body,
6000
+ ...options,
6001
+ stream: body.stream ?? false,
6002
+ __security: { bearerAuth: true }
6003
+ })._thenUnwrap((rsp) => {
4805
6004
  if ("object" in rsp && rsp.object === "response") {
4806
6005
  addOutputText(rsp);
4807
6006
  }
@@ -4812,7 +6011,8 @@ class Responses extends APIResource {
4812
6011
  return this._client.get(path`/responses/${responseID}`, {
4813
6012
  query: query2,
4814
6013
  ...options,
4815
- stream: query2?.stream ?? false
6014
+ stream: query2?.stream ?? false,
6015
+ __security: { bearerAuth: true }
4816
6016
  })._thenUnwrap((rsp) => {
4817
6017
  if ("object" in rsp && rsp.object === "response") {
4818
6018
  addOutputText(rsp);
@@ -4823,7 +6023,8 @@ class Responses extends APIResource {
4823
6023
  delete(responseID, options) {
4824
6024
  return this._client.delete(path`/responses/${responseID}`, {
4825
6025
  ...options,
4826
- headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
6026
+ headers: buildHeaders([{ Accept: "*/*" }, options?.headers]),
6027
+ __security: { bearerAuth: true }
4827
6028
  });
4828
6029
  }
4829
6030
  parse(body, options) {
@@ -4833,10 +6034,13 @@ class Responses extends APIResource {
4833
6034
  return ResponseStream.createResponse(this._client, body, options);
4834
6035
  }
4835
6036
  cancel(responseID, options) {
4836
- return this._client.post(path`/responses/${responseID}/cancel`, options);
6037
+ return this._client.post(path`/responses/${responseID}/cancel`, {
6038
+ ...options,
6039
+ __security: { bearerAuth: true }
6040
+ });
4837
6041
  }
4838
6042
  compact(body, options) {
4839
- return this._client.post("/responses/compact", { body, ...options });
6043
+ return this._client.post("/responses/compact", { body, ...options, __security: { bearerAuth: true } });
4840
6044
  }
4841
6045
  }
4842
6046
  Responses.InputItems = InputItems;
@@ -4847,6 +6051,7 @@ class Content2 extends APIResource {
4847
6051
  return this._client.get(path`/skills/${skillID}/content`, {
4848
6052
  ...options,
4849
6053
  headers: buildHeaders([{ Accept: "application/binary" }, options?.headers]),
6054
+ __security: { bearerAuth: true },
4850
6055
  __binaryResponse: true
4851
6056
  });
4852
6057
  }
@@ -4859,6 +6064,7 @@ class Content3 extends APIResource {
4859
6064
  return this._client.get(path`/skills/${skill_id}/versions/${version}/content`, {
4860
6065
  ...options,
4861
6066
  headers: buildHeaders([{ Accept: "application/binary" }, options?.headers]),
6067
+ __security: { bearerAuth: true },
4862
6068
  __binaryResponse: true
4863
6069
  });
4864
6070
  }
@@ -4871,21 +6077,28 @@ class Versions extends APIResource {
4871
6077
  this.content = new Content3(this._client);
4872
6078
  }
4873
6079
  create(skillID, body = {}, options) {
4874
- return this._client.post(path`/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6080
+ return this._client.post(path`/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
4875
6081
  }
4876
6082
  retrieve(version, params, options) {
4877
6083
  const { skill_id } = params;
4878
- return this._client.get(path`/skills/${skill_id}/versions/${version}`, options);
6084
+ return this._client.get(path`/skills/${skill_id}/versions/${version}`, {
6085
+ ...options,
6086
+ __security: { bearerAuth: true }
6087
+ });
4879
6088
  }
4880
6089
  list(skillID, query2 = {}, options) {
4881
6090
  return this._client.getAPIList(path`/skills/${skillID}/versions`, CursorPage, {
4882
6091
  query: query2,
4883
- ...options
6092
+ ...options,
6093
+ __security: { bearerAuth: true }
4884
6094
  });
4885
6095
  }
4886
6096
  delete(version, params, options) {
4887
6097
  const { skill_id } = params;
4888
- return this._client.delete(path`/skills/${skill_id}/versions/${version}`, options);
6098
+ return this._client.delete(path`/skills/${skill_id}/versions/${version}`, {
6099
+ ...options,
6100
+ __security: { bearerAuth: true }
6101
+ });
4889
6102
  }
4890
6103
  }
4891
6104
  Versions.Content = Content3;
@@ -4898,19 +6111,27 @@ class Skills extends APIResource {
4898
6111
  this.versions = new Versions(this._client);
4899
6112
  }
4900
6113
  create(body = {}, options) {
4901
- return this._client.post("/skills", maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6114
+ return this._client.post("/skills", maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
4902
6115
  }
4903
6116
  retrieve(skillID, options) {
4904
- return this._client.get(path`/skills/${skillID}`, options);
6117
+ return this._client.get(path`/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
4905
6118
  }
4906
6119
  update(skillID, body, options) {
4907
- return this._client.post(path`/skills/${skillID}`, { body, ...options });
6120
+ return this._client.post(path`/skills/${skillID}`, {
6121
+ body,
6122
+ ...options,
6123
+ __security: { bearerAuth: true }
6124
+ });
4908
6125
  }
4909
6126
  list(query2 = {}, options) {
4910
- return this._client.getAPIList("/skills", CursorPage, { query: query2, ...options });
6127
+ return this._client.getAPIList("/skills", CursorPage, {
6128
+ query: query2,
6129
+ ...options,
6130
+ __security: { bearerAuth: true }
6131
+ });
4911
6132
  }
4912
6133
  delete(skillID, options) {
4913
- return this._client.delete(path`/skills/${skillID}`, options);
6134
+ return this._client.delete(path`/skills/${skillID}`, { ...options, __security: { bearerAuth: true } });
4914
6135
  }
4915
6136
  }
4916
6137
  Skills.Content = Content2;
@@ -4918,7 +6139,7 @@ Skills.Versions = Versions;
4918
6139
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/uploads/parts.mjs
4919
6140
  class Parts extends APIResource {
4920
6141
  create(uploadID, body, options) {
4921
- return this._client.post(path`/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options }, this._client));
6142
+ return this._client.post(path`/uploads/${uploadID}/parts`, multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
4922
6143
  }
4923
6144
  }
4924
6145
 
@@ -4929,13 +6150,20 @@ class Uploads extends APIResource {
4929
6150
  this.parts = new Parts(this._client);
4930
6151
  }
4931
6152
  create(body, options) {
4932
- return this._client.post("/uploads", { body, ...options });
6153
+ return this._client.post("/uploads", { body, ...options, __security: { bearerAuth: true } });
4933
6154
  }
4934
6155
  cancel(uploadID, options) {
4935
- return this._client.post(path`/uploads/${uploadID}/cancel`, options);
6156
+ return this._client.post(path`/uploads/${uploadID}/cancel`, {
6157
+ ...options,
6158
+ __security: { bearerAuth: true }
6159
+ });
4936
6160
  }
4937
6161
  complete(uploadID, body, options) {
4938
- return this._client.post(path`/uploads/${uploadID}/complete`, { body, ...options });
6162
+ return this._client.post(path`/uploads/${uploadID}/complete`, {
6163
+ body,
6164
+ ...options,
6165
+ __security: { bearerAuth: true }
6166
+ });
4939
6167
  }
4940
6168
  }
4941
6169
  Uploads.Parts = Parts;
@@ -4964,21 +6192,24 @@ class FileBatches extends APIResource {
4964
6192
  return this._client.post(path`/vector_stores/${vectorStoreID}/file_batches`, {
4965
6193
  body,
4966
6194
  ...options,
4967
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6195
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6196
+ __security: { bearerAuth: true }
4968
6197
  });
4969
6198
  }
4970
6199
  retrieve(batchID, params, options) {
4971
6200
  const { vector_store_id } = params;
4972
6201
  return this._client.get(path`/vector_stores/${vector_store_id}/file_batches/${batchID}`, {
4973
6202
  ...options,
4974
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6203
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6204
+ __security: { bearerAuth: true }
4975
6205
  });
4976
6206
  }
4977
6207
  cancel(batchID, params, options) {
4978
6208
  const { vector_store_id } = params;
4979
6209
  return this._client.post(path`/vector_stores/${vector_store_id}/file_batches/${batchID}/cancel`, {
4980
6210
  ...options,
4981
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6211
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6212
+ __security: { bearerAuth: true }
4982
6213
  });
4983
6214
  }
4984
6215
  async createAndPoll(vectorStoreId, body, options) {
@@ -4987,7 +6218,12 @@ class FileBatches extends APIResource {
4987
6218
  }
4988
6219
  listFiles(batchID, params, options) {
4989
6220
  const { vector_store_id, ...query2 } = params;
4990
- return this._client.getAPIList(path`/vector_stores/${vector_store_id}/file_batches/${batchID}/files`, CursorPage, { query: query2, ...options, headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]) });
6221
+ return this._client.getAPIList(path`/vector_stores/${vector_store_id}/file_batches/${batchID}/files`, CursorPage, {
6222
+ query: query2,
6223
+ ...options,
6224
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6225
+ __security: { bearerAuth: true }
6226
+ });
4991
6227
  }
4992
6228
  async poll(vectorStoreID, batchID, options) {
4993
6229
  const headers = buildHeaders([
@@ -5054,14 +6290,16 @@ class Files3 extends APIResource {
5054
6290
  return this._client.post(path`/vector_stores/${vectorStoreID}/files`, {
5055
6291
  body,
5056
6292
  ...options,
5057
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6293
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6294
+ __security: { bearerAuth: true }
5058
6295
  });
5059
6296
  }
5060
6297
  retrieve(fileID, params, options) {
5061
6298
  const { vector_store_id } = params;
5062
6299
  return this._client.get(path`/vector_stores/${vector_store_id}/files/${fileID}`, {
5063
6300
  ...options,
5064
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6301
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6302
+ __security: { bearerAuth: true }
5065
6303
  });
5066
6304
  }
5067
6305
  update(fileID, params, options) {
@@ -5069,21 +6307,24 @@ class Files3 extends APIResource {
5069
6307
  return this._client.post(path`/vector_stores/${vector_store_id}/files/${fileID}`, {
5070
6308
  body,
5071
6309
  ...options,
5072
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6310
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6311
+ __security: { bearerAuth: true }
5073
6312
  });
5074
6313
  }
5075
6314
  list(vectorStoreID, query2 = {}, options) {
5076
6315
  return this._client.getAPIList(path`/vector_stores/${vectorStoreID}/files`, CursorPage, {
5077
6316
  query: query2,
5078
6317
  ...options,
5079
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6318
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6319
+ __security: { bearerAuth: true }
5080
6320
  });
5081
6321
  }
5082
6322
  delete(fileID, params, options) {
5083
6323
  const { vector_store_id } = params;
5084
6324
  return this._client.delete(path`/vector_stores/${vector_store_id}/files/${fileID}`, {
5085
6325
  ...options,
5086
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6326
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6327
+ __security: { bearerAuth: true }
5087
6328
  });
5088
6329
  }
5089
6330
  async createAndPoll(vectorStoreId, body, options) {
@@ -5135,7 +6376,11 @@ class Files3 extends APIResource {
5135
6376
  }
5136
6377
  content(fileID, params, options) {
5137
6378
  const { vector_store_id } = params;
5138
- return this._client.getAPIList(path`/vector_stores/${vector_store_id}/files/${fileID}/content`, Page, { ...options, headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]) });
6379
+ return this._client.getAPIList(path`/vector_stores/${vector_store_id}/files/${fileID}/content`, Page, {
6380
+ ...options,
6381
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6382
+ __security: { bearerAuth: true }
6383
+ });
5139
6384
  }
5140
6385
  }
5141
6386
 
@@ -5150,33 +6395,38 @@ class VectorStores extends APIResource {
5150
6395
  return this._client.post("/vector_stores", {
5151
6396
  body,
5152
6397
  ...options,
5153
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6398
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6399
+ __security: { bearerAuth: true }
5154
6400
  });
5155
6401
  }
5156
6402
  retrieve(vectorStoreID, options) {
5157
6403
  return this._client.get(path`/vector_stores/${vectorStoreID}`, {
5158
6404
  ...options,
5159
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6405
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6406
+ __security: { bearerAuth: true }
5160
6407
  });
5161
6408
  }
5162
6409
  update(vectorStoreID, body, options) {
5163
6410
  return this._client.post(path`/vector_stores/${vectorStoreID}`, {
5164
6411
  body,
5165
6412
  ...options,
5166
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6413
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6414
+ __security: { bearerAuth: true }
5167
6415
  });
5168
6416
  }
5169
6417
  list(query2 = {}, options) {
5170
6418
  return this._client.getAPIList("/vector_stores", CursorPage, {
5171
6419
  query: query2,
5172
6420
  ...options,
5173
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6421
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6422
+ __security: { bearerAuth: true }
5174
6423
  });
5175
6424
  }
5176
6425
  delete(vectorStoreID, options) {
5177
6426
  return this._client.delete(path`/vector_stores/${vectorStoreID}`, {
5178
6427
  ...options,
5179
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6428
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6429
+ __security: { bearerAuth: true }
5180
6430
  });
5181
6431
  }
5182
6432
  search(vectorStoreID, body, options) {
@@ -5184,7 +6434,8 @@ class VectorStores extends APIResource {
5184
6434
  body,
5185
6435
  method: "post",
5186
6436
  ...options,
5187
- headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers])
6437
+ headers: buildHeaders([{ "OpenAI-Beta": "assistants=v2" }, options?.headers]),
6438
+ __security: { bearerAuth: true }
5188
6439
  });
5189
6440
  }
5190
6441
  }
@@ -5193,27 +6444,47 @@ VectorStores.FileBatches = FileBatches;
5193
6444
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/videos.mjs
5194
6445
  class Videos extends APIResource {
5195
6446
  create(body, options) {
5196
- return this._client.post("/videos", maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6447
+ return this._client.post("/videos", multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5197
6448
  }
5198
6449
  retrieve(videoID, options) {
5199
- return this._client.get(path`/videos/${videoID}`, options);
6450
+ return this._client.get(path`/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
5200
6451
  }
5201
6452
  list(query2 = {}, options) {
5202
- return this._client.getAPIList("/videos", ConversationCursorPage, { query: query2, ...options });
6453
+ return this._client.getAPIList("/videos", ConversationCursorPage, {
6454
+ query: query2,
6455
+ ...options,
6456
+ __security: { bearerAuth: true }
6457
+ });
5203
6458
  }
5204
6459
  delete(videoID, options) {
5205
- return this._client.delete(path`/videos/${videoID}`, options);
6460
+ return this._client.delete(path`/videos/${videoID}`, { ...options, __security: { bearerAuth: true } });
6461
+ }
6462
+ createCharacter(body, options) {
6463
+ return this._client.post("/videos/characters", multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5206
6464
  }
5207
6465
  downloadContent(videoID, query2 = {}, options) {
5208
6466
  return this._client.get(path`/videos/${videoID}/content`, {
5209
6467
  query: query2,
5210
6468
  ...options,
5211
6469
  headers: buildHeaders([{ Accept: "application/binary" }, options?.headers]),
6470
+ __security: { bearerAuth: true },
5212
6471
  __binaryResponse: true
5213
6472
  });
5214
6473
  }
6474
+ edit(body, options) {
6475
+ return this._client.post("/videos/edits", multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6476
+ }
6477
+ extend(body, options) {
6478
+ return this._client.post("/videos/extensions", multipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
6479
+ }
6480
+ getCharacter(characterID, options) {
6481
+ return this._client.get(path`/videos/characters/${characterID}`, {
6482
+ ...options,
6483
+ __security: { bearerAuth: true }
6484
+ });
6485
+ }
5215
6486
  remix(videoID, body, options) {
5216
- return this._client.post(path`/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6487
+ return this._client.post(path`/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options, __security: { bearerAuth: true } }, this._client));
5217
6488
  }
5218
6489
  }
5219
6490
  // node_modules/@earendil-works/pi-ai/node_modules/openai/resources/webhooks/webhooks.mjs
@@ -5287,9 +6558,10 @@ var _OpenAI_instances;
5287
6558
  var _a2;
5288
6559
  var _OpenAI_encoder;
5289
6560
  var _OpenAI_baseURLOverridden;
6561
+ var WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER = "workload-identity-auth";
5290
6562
 
5291
6563
  class OpenAI {
5292
- constructor({ baseURL = readEnv("OPENAI_BASE_URL"), apiKey = readEnv("OPENAI_API_KEY"), organization = readEnv("OPENAI_ORG_ID") ?? null, project = readEnv("OPENAI_PROJECT_ID") ?? null, webhookSecret = readEnv("OPENAI_WEBHOOK_SECRET") ?? null, ...opts } = {}) {
6564
+ constructor({ baseURL = readEnv("OPENAI_BASE_URL"), apiKey = readEnv("OPENAI_API_KEY") ?? null, adminAPIKey = readEnv("OPENAI_ADMIN_KEY") ?? null, organization = readEnv("OPENAI_ORG_ID") ?? null, project = readEnv("OPENAI_PROJECT_ID") ?? null, webhookSecret = readEnv("OPENAI_WEBHOOK_SECRET") ?? null, workloadIdentity, ...opts } = {}) {
5293
6565
  _OpenAI_instances.add(this);
5294
6566
  _OpenAI_encoder.set(this, undefined);
5295
6567
  this.completions = new Completions2(this);
@@ -5307,6 +6579,7 @@ class OpenAI {
5307
6579
  this.beta = new Beta(this);
5308
6580
  this.batches = new Batches(this);
5309
6581
  this.uploads = new Uploads(this);
6582
+ this.admin = new Admin(this);
5310
6583
  this.responses = new Responses(this);
5311
6584
  this.realtime = new Realtime2(this);
5312
6585
  this.conversations = new Conversations(this);
@@ -5314,17 +6587,22 @@ class OpenAI {
5314
6587
  this.containers = new Containers(this);
5315
6588
  this.skills = new Skills(this);
5316
6589
  this.videos = new Videos(this);
5317
- if (apiKey === undefined) {
5318
- throw new OpenAIError("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");
5319
- }
5320
6590
  const options = {
5321
6591
  apiKey,
6592
+ adminAPIKey,
5322
6593
  organization,
5323
6594
  project,
5324
6595
  webhookSecret,
6596
+ workloadIdentity,
5325
6597
  ...opts,
5326
6598
  baseURL: baseURL || `https://api.openai.com/v1`
5327
6599
  };
6600
+ if (apiKey && workloadIdentity) {
6601
+ throw new OpenAIError("The `apiKey` and `workloadIdentity` options are mutually exclusive");
6602
+ }
6603
+ if (!apiKey && !adminAPIKey && !workloadIdentity) {
6604
+ throw new OpenAIError("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");
6605
+ }
5328
6606
  if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
5329
6607
  throw new OpenAIError(`It looks like you're running in a browser-like environment.
5330
6608
 
@@ -5347,8 +6625,24 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5347
6625
  this.maxRetries = options.maxRetries ?? 2;
5348
6626
  this.fetch = options.fetch ?? getDefaultFetch();
5349
6627
  __classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder, "f");
6628
+ const customHeadersEnv = readEnv("OPENAI_CUSTOM_HEADERS");
6629
+ if (customHeadersEnv) {
6630
+ const parsed = {};
6631
+ for (const line of customHeadersEnv.split(`
6632
+ `)) {
6633
+ const colon = line.indexOf(":");
6634
+ if (colon >= 0) {
6635
+ parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
6636
+ }
6637
+ }
6638
+ options.defaultHeaders = buildHeaders([parsed, options.defaultHeaders]);
6639
+ }
5350
6640
  this._options = options;
5351
- this.apiKey = typeof apiKey === "string" ? apiKey : "Missing Key";
6641
+ if (workloadIdentity) {
6642
+ this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
6643
+ }
6644
+ this.apiKey = typeof apiKey === "string" ? apiKey : null;
6645
+ this.adminAPIKey = adminAPIKey;
5352
6646
  this.organization = organization;
5353
6647
  this.project = project;
5354
6648
  this.webhookSecret = webhookSecret;
@@ -5363,7 +6657,9 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5363
6657
  logLevel: this.logLevel,
5364
6658
  fetch: this.fetch,
5365
6659
  fetchOptions: this.fetchOptions,
5366
- apiKey: this.apiKey,
6660
+ apiKey: this._options.apiKey,
6661
+ adminAPIKey: this.adminAPIKey,
6662
+ workloadIdentity: this._options.workloadIdentity,
5367
6663
  organization: this.organization,
5368
6664
  project: this.project,
5369
6665
  webhookSecret: this.webhookSecret,
@@ -5374,12 +6670,45 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5374
6670
  defaultQuery() {
5375
6671
  return this._options.defaultQuery;
5376
6672
  }
5377
- validateHeaders({ values: values2, nulls }) {
5378
- return;
6673
+ validateHeaders({ values: values2, nulls }, schemes = {
6674
+ bearerAuth: true,
6675
+ adminAPIKeyAuth: true
6676
+ }) {
6677
+ if (values2.get("authorization") || values2.get("api-key")) {
6678
+ return;
6679
+ }
6680
+ if (nulls.has("authorization") || nulls.has("api-key")) {
6681
+ return;
6682
+ }
6683
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
6684
+ return;
6685
+ }
6686
+ throw new Error('Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted');
6687
+ }
6688
+ async authHeaders(opts, schemes = {
6689
+ bearerAuth: true,
6690
+ adminAPIKeyAuth: true
6691
+ }) {
6692
+ return buildHeaders([
6693
+ schemes.bearerAuth ? await this.bearerAuth(opts) : null,
6694
+ schemes.adminAPIKeyAuth ? await this.adminAPIKeyAuth(opts) : null
6695
+ ]);
5379
6696
  }
5380
- async authHeaders(opts) {
6697
+ async bearerAuth(opts) {
6698
+ if (this._workloadIdentityAuth) {
6699
+ return buildHeaders([{ Authorization: `Bearer ${await this._workloadIdentityAuth.getToken()}` }]);
6700
+ }
6701
+ if (this.apiKey == null) {
6702
+ return;
6703
+ }
5381
6704
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
5382
6705
  }
6706
+ async adminAPIKeyAuth(opts) {
6707
+ if (this.adminAPIKey == null) {
6708
+ return;
6709
+ }
6710
+ return buildHeaders([{ Authorization: `Bearer ${this.adminAPIKey}` }]);
6711
+ }
5383
6712
  stringifyQuery(query2) {
5384
6713
  return stringifyQuery(query2);
5385
6714
  }
@@ -5414,8 +6743,9 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5414
6743
  const baseURL = !__classPrivateFieldGet(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
5415
6744
  const url = isAbsoluteURL(path2) ? new URL(path2) : new URL(baseURL + (baseURL.endsWith("/") && path2.startsWith("/") ? path2.slice(1) : path2));
5416
6745
  const defaultQuery = this.defaultQuery();
5417
- if (!isEmptyObj(defaultQuery)) {
5418
- query2 = { ...defaultQuery, ...query2 };
6746
+ const pathQuery = Object.fromEntries(url.searchParams);
6747
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
6748
+ query2 = { ...pathQuery, ...defaultQuery, ...query2 };
5419
6749
  }
5420
6750
  if (typeof query2 === "object" && query2 && !Array.isArray(query2)) {
5421
6751
  url.search = this.stringifyQuery(query2);
@@ -5423,7 +6753,10 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5423
6753
  return url.toString();
5424
6754
  }
5425
6755
  async prepareOptions(options) {
5426
- await this._callApiKey();
6756
+ const security = options.__security ?? { bearerAuth: true };
6757
+ if (security.bearerAuth) {
6758
+ await this._callApiKey();
6759
+ }
5427
6760
  }
5428
6761
  async prepareRequest(request, { url, options }) {}
5429
6762
  get(path2, opts) {
@@ -5473,8 +6806,9 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5473
6806
  if (options.signal?.aborted) {
5474
6807
  throw new APIUserAbortError;
5475
6808
  }
6809
+ const security = options.__security ?? { bearerAuth: true };
5476
6810
  const controller = new AbortController;
5477
- const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
6811
+ const response = await this.fetchWithAuth(url, req, timeout, controller, security).catch(castToError);
5478
6812
  const headersTime = Date.now();
5479
6813
  if (response instanceof globalThis.Error) {
5480
6814
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
@@ -5499,14 +6833,31 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5499
6833
  durationMs: headersTime - startTime,
5500
6834
  message: response.message
5501
6835
  }));
6836
+ if (response instanceof OAuthError || response instanceof SubjectTokenProviderError) {
6837
+ throw response;
6838
+ }
5502
6839
  if (isTimeout) {
5503
6840
  throw new APIConnectionTimeoutError;
5504
6841
  }
5505
- throw new APIConnectionError({ cause: response });
6842
+ throw new APIConnectionError({
6843
+ message: getConnectionErrorMessage(response),
6844
+ cause: response
6845
+ });
5506
6846
  }
5507
6847
  const specialHeaders = [...response.headers.entries()].filter(([name]) => name === "x-request-id").map(([name, value]) => ", " + name + ": " + JSON.stringify(value)).join("");
5508
6848
  const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? "succeeded" : "failed"} with status ${response.status} in ${headersTime - startTime}ms`;
5509
6849
  if (!response.ok) {
6850
+ if (response.status === 401 && this._workloadIdentityAuth && security.bearerAuth && !options.__metadata?.["hasStreamingBody"] && !options.__metadata?.["workloadIdentityTokenRefreshed"]) {
6851
+ await CancelReadableStream(response.body);
6852
+ this._workloadIdentityAuth.invalidateToken();
6853
+ return this.makeRequest({
6854
+ ...options,
6855
+ __metadata: {
6856
+ ...options.__metadata,
6857
+ workloadIdentityTokenRefreshed: true
6858
+ }
6859
+ }, retriesRemaining, retryOfRequestLogID ?? requestLogID);
6860
+ }
5510
6861
  const shouldRetry = await this.shouldRetry(response);
5511
6862
  if (retriesRemaining && shouldRetry) {
5512
6863
  const retryMessage2 = `retrying, ${retriesRemaining} attempts remaining`;
@@ -5554,6 +6905,21 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5554
6905
  const request = this.makeRequest(options, null, undefined);
5555
6906
  return new PagePromise(this, request, Page2);
5556
6907
  }
6908
+ async fetchWithAuth(url, init, timeout, controller, schemes = {
6909
+ bearerAuth: true,
6910
+ adminAPIKeyAuth: true
6911
+ }) {
6912
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
6913
+ const headers = init.headers;
6914
+ const authHeader = headers.get("Authorization");
6915
+ if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
6916
+ const token = await this._workloadIdentityAuth.getToken();
6917
+ headers.set("Authorization", `Bearer ${token}`);
6918
+ }
6919
+ }
6920
+ const response = await this.fetchWithTimeout(url, init, timeout, controller);
6921
+ return response;
6922
+ }
5557
6923
  async fetchWithTimeout(url, init, ms, controller) {
5558
6924
  const { signal, method, ...options } = init || {};
5559
6925
  const abort = this._makeAbort(controller);
@@ -5632,7 +6998,13 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5632
6998
  if ("timeout" in options)
5633
6999
  validatePositiveInteger("timeout", options.timeout);
5634
7000
  options.timeout = options.timeout ?? this.timeout;
5635
- const { bodyHeaders, body } = this.buildBody({ options });
7001
+ const { bodyHeaders, body, isStreamingBody } = this.buildBody({ options });
7002
+ if (isStreamingBody) {
7003
+ inputOptions.__metadata = {
7004
+ ...inputOptions.__metadata,
7005
+ hasStreamingBody: true
7006
+ };
7007
+ }
5636
7008
  const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
5637
7009
  const req = {
5638
7010
  method,
@@ -5663,12 +7035,12 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5663
7035
  "OpenAI-Organization": this.organization,
5664
7036
  "OpenAI-Project": this.project
5665
7037
  },
5666
- await this.authHeaders(options),
7038
+ await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
5667
7039
  this._options.defaultHeaders,
5668
7040
  bodyHeaders,
5669
7041
  options.headers
5670
7042
  ]);
5671
- this.validateHeaders(headers);
7043
+ this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
5672
7044
  return headers.values;
5673
7045
  }
5674
7046
  _makeAbort(controller) {
@@ -5676,20 +7048,27 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5676
7048
  }
5677
7049
  buildBody({ options: { body, headers: rawHeaders } }) {
5678
7050
  if (!body) {
5679
- return { bodyHeaders: undefined, body: undefined };
7051
+ return { bodyHeaders: undefined, body: undefined, isStreamingBody: false };
5680
7052
  }
5681
7053
  const headers = buildHeaders([rawHeaders]);
5682
- if (ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || typeof body === "string" && headers.values.has("content-type") || globalThis.Blob && body instanceof globalThis.Blob || body instanceof FormData || body instanceof URLSearchParams || globalThis.ReadableStream && body instanceof globalThis.ReadableStream) {
5683
- return { bodyHeaders: undefined, body };
7054
+ const isReadableStream = typeof globalThis.ReadableStream !== "undefined" && body instanceof globalThis.ReadableStream;
7055
+ const isRetryableBody = !isReadableStream && (typeof body === "string" || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof globalThis.Blob !== "undefined" && body instanceof globalThis.Blob || body instanceof URLSearchParams || body instanceof FormData);
7056
+ if (ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || typeof body === "string" && headers.values.has("content-type") || globalThis.Blob && body instanceof globalThis.Blob || body instanceof FormData || body instanceof URLSearchParams || isReadableStream) {
7057
+ return { bodyHeaders: undefined, body, isStreamingBody: !isRetryableBody };
5684
7058
  } else if (typeof body === "object" && ((Symbol.asyncIterator in body) || (Symbol.iterator in body) && ("next" in body) && typeof body.next === "function")) {
5685
- return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
7059
+ return {
7060
+ bodyHeaders: undefined,
7061
+ body: ReadableStreamFrom(body),
7062
+ isStreamingBody: true
7063
+ };
5686
7064
  } else if (typeof body === "object" && headers.values.get("content-type") === "application/x-www-form-urlencoded") {
5687
7065
  return {
5688
7066
  bodyHeaders: { "content-type": "application/x-www-form-urlencoded" },
5689
- body: this.stringifyQuery(body)
7067
+ body: this.stringifyQuery(body),
7068
+ isStreamingBody: false
5690
7069
  };
5691
7070
  } else {
5692
- return __classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers });
7071
+ return { ...__classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers }), isStreamingBody: false };
5693
7072
  }
5694
7073
  }
5695
7074
  }
@@ -5728,6 +7107,7 @@ OpenAI.Webhooks = Webhooks;
5728
7107
  OpenAI.Beta = Beta;
5729
7108
  OpenAI.Batches = Batches;
5730
7109
  OpenAI.Uploads = Uploads;
7110
+ OpenAI.Admin = Admin;
5731
7111
  OpenAI.Responses = Responses;
5732
7112
  OpenAI.Realtime = Realtime2;
5733
7113
  OpenAI.Conversations = Conversations;
@@ -5735,6 +7115,23 @@ OpenAI.Evals = Evals;
5735
7115
  OpenAI.Containers = Containers;
5736
7116
  OpenAI.Skills = Skills;
5737
7117
  OpenAI.Videos = Videos;
7118
+ function getConnectionErrorMessage(error2) {
7119
+ if (isUndiciDispatcherVersionMismatchError(error2)) {
7120
+ return `Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });`;
7121
+ }
7122
+ return;
7123
+ }
7124
+ function isUndiciDispatcherVersionMismatchError(error2) {
7125
+ let current = error2;
7126
+ for (let i = 0;i < 8 && current && typeof current === "object"; i++) {
7127
+ const err = current;
7128
+ if (err.code === "UND_ERR_INVALID_ARG" && typeof err.message === "string" && err.message.includes("invalid onRequestStart method")) {
7129
+ return true;
7130
+ }
7131
+ current = err.cause;
7132
+ }
7133
+ return false;
7134
+ }
5738
7135
 
5739
7136
  // node_modules/@earendil-works/pi-ai/node_modules/openai/azure.mjs
5740
7137
  class AzureOpenAI extends OpenAI {
@@ -5787,11 +7184,12 @@ class AzureOpenAI extends OpenAI {
5787
7184
  }
5788
7185
  return super.buildRequest(options, props);
5789
7186
  }
5790
- async authHeaders(opts) {
5791
- if (typeof this._options.apiKey === "string") {
7187
+ async authHeaders(opts, schemes) {
7188
+ const security = schemes ?? { bearerAuth: true, adminAPIKeyAuth: true };
7189
+ if (security.bearerAuth && typeof this._options.apiKey === "string") {
5792
7190
  return buildHeaders([{ "api-key": this.apiKey }]);
5793
7191
  }
5794
- return super.authHeaders(opts);
7192
+ return super.authHeaders(opts, security);
5795
7193
  }
5796
7194
  }
5797
7195
  var _deployments_endpoints = new Set([