@witty-ai/skill-insight 0.3.0-beta → 0.5.0-beta
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.
- package/.env.example +51 -6
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +2 -0
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +12 -0
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/auth/apikey/route.js +2 -2
- package/.next/standalone/.next/server/app/api/auth/apikey/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/organization/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/auth/organization/route/build-manifest.json +11 -0
- package/.next/standalone/.next/server/app/api/auth/organization/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/auth/organization/route.js +7 -0
- package/.next/standalone/.next/server/app/api/auth/organization/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/auth/organization/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/auth/organization/route_client-reference-manifest.js +2 -0
- package/.next/standalone/.next/server/app/api/config/create/route.js +5 -5
- package/.next/standalone/.next/server/app/api/config/create/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/config/route.js +5 -4
- package/.next/standalone/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/config/status/route.js +2 -2
- package/.next/standalone/.next/server/app/api/config/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/data/route.js +5 -4
- package/.next/standalone/.next/server/app/api/data/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/executions/[executionId]/analyze-match/route.js +4 -4
- package/.next/standalone/.next/server/app/api/executions/[executionId]/analyze-match/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/guide/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/guide/route/build-manifest.json +11 -0
- package/.next/standalone/.next/server/app/api/guide/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/guide/route.js +7 -0
- package/.next/standalone/.next/server/app/api/guide/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/guide/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/guide/route_client-reference-manifest.js +2 -0
- package/.next/standalone/.next/server/app/api/otel/v1/logs/route.js +5 -4
- package/.next/standalone/.next/server/app/api/otel/v1/logs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/otel/v1/traces/route.js +5 -4
- package/.next/standalone/.next/server/app/api/otel/v1/traces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/proxy/[taskId]/[...path]/route.js +3 -3
- package/.next/standalone/.next/server/app/api/proxy/[taskId]/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/proxy/[taskId]/end/route.js +5 -4
- package/.next/standalone/.next/server/app/api/proxy/[taskId]/end/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/proxy/[taskId]/start/route.js +2 -2
- package/.next/standalone/.next/server/app/api/proxy/[taskId]/start/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/rejudge/route.js +5 -4
- package/.next/standalone/.next/server/app/api/rejudge/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/session/route.js +5 -5
- package/.next/standalone/.next/server/app/api/session/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/settings/route.js +2 -2
- package/.next/standalone/.next/server/app/api/settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/settings/test/route.js +2 -2
- package/.next/standalone/.next/server/app/api/settings/test/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/[id]/activate/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/[id]/activate/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/[id]/toggle/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/[id]/toggle/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/[version]/download/route.js +3 -3
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/[version]/download/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/[version]/parse-flow/route.js +4 -4
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/[version]/parse-flow/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/[version]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/[version]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/[id]/versions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/automation/import/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/automation/import/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/automation/push/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/automation/push/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/by-name/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/by-name/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/logs/route.js +5 -4
- package/.next/standalone/.next/server/app/api/skills/logs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/skills/upload/route.js +2 -2
- package/.next/standalone/.next/server/app/api/skills/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sync/manifest/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sync/manifest/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sync/opencode/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sync/opencode/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/upload/route.js +5 -3
- package/.next/standalone/.next/server/app/api/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/details/page/react-loadable-manifest.json +3 -3
- package/.next/standalone/.next/server/app/details/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/details/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/details.html +1 -1
- package/.next/standalone/.next/server/app/details.rsc +5 -5
- package/.next/standalone/.next/server/app/details.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/details.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/details.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/details.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/details.segments/details/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/details.segments/details.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +5 -5
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/login.html +1 -1
- package/.next/standalone/.next/server/app/login.rsc +5 -5
- package/.next/standalone/.next/server/app/login.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/login.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/skills/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/skills.html +1 -1
- package/.next/standalone/.next/server/app/skills.rsc +5 -5
- package/.next/standalone/.next/server/app/skills.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/skills.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/skills.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/skills.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/skills.segments/skills/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/skills.segments/skills.segment.rsc +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +2 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__02ddba88._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05e510f4._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0a140a5a._.js +122 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1013b265._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1c95bcde._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1ce5e3b8._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__4a6d443b._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__53775b48._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__5444db55._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__591248f3._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__5d8178f6._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__6923eecf._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__6d8053e2._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__6fc12878._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__73ce6d21._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__863cf6de._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__98b3de5e._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__9d551ea2._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a4d3d791._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__c6c98b22._.js → [root-of-the-server]__aa5c8858._.js} +3 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b11acc79._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b835ea7f._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ba01f286._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__bd91659b._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__c200214a._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d7fab946._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d8c1808b._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d9b9fecc._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__e280561d._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__e2f0baee._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__e550423c._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__fc05579d._.js +3 -0
- package/.next/standalone/.next/server/chunks/_33c0c729._.js +1 -1
- package/.next/standalone/.next/server/chunks/_41a98bd8._.js +3 -0
- package/.next/standalone/.next/server/chunks/_c48f7c66._.js +1 -1
- package/.next/standalone/.next/server/chunks/_c82df3e0._.js +3 -3
- package/.next/standalone/.next/server/chunks/_cd3d20ca._.js +1 -1
- package/.next/standalone/.next/server/chunks/_fa49adfa._.js +3 -3
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_auth_organization_route_actions_f58710b7.js +3 -0
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_guide_route_actions_6c188449.js +3 -0
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_c33286ed.js +71 -110
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_f42faeee.js +1 -400
- package/.next/standalone/.next/server/chunks/src_497d2ad2._.js +22 -22
- package/.next/standalone/.next/server/chunks/src_c8971a2d._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_lib_12408140._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__5d576168._.js → [root-of-the-server]__40353d98._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__89851212._.js → [root-of-the-server]__480fcd92._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__72a7f3ed._.js → [root-of-the-server]__48f8fbcb._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__438a2c90._.js → [root-of-the-server]__49921b2a._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__51073007._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__c9e3c893._.js → [root-of-the-server]__593be3d6._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__ca101543._.js → [root-of-the-server]__5e9ff641._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__90641614._.js → [root-of-the-server]__66cc6ff2._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__37bfda90._.js → [root-of-the-server]__9889bdc8._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__42ba97b6._.js → [root-of-the-server]__9905ca7a._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__9ab7cc4a._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__7bb97139._.js → [root-of-the-server]__9d6b7d48._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__6b8b9bb9._.js → [root-of-the-server]__b8edc8c6._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1dfe61f8._.js → [root-of-the-server]__d691ecb0._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__d0917d6e._.js → [root-of-the-server]__e5ddfd15._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__e5e3a145._.js → [root-of-the-server]__f72f330e._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__99ab66d7._.js → [root-of-the-server]__f843e085._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__8a82ef12._.js → [root-of-the-server]__fd69d276._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_7688d7cd._.js → _049876f0._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_981cd263._.js → _09546b95._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_8f5379ab._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_cf1f3d2c._.js → _b121f1ae._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_c8c8c083._.js +18 -42
- package/.next/standalone/.next/server/chunks/ssr/_fd46f439._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_a4a1f3c3._.js → node_modules_039c6a11._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_a7a82280._.js → node_modules_0d3530cd._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0c2939c3._.js → node_modules_0e883565._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_8d9e56b7._.js → node_modules_11dbf165._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_76d6c533._.js → node_modules_2041c122._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_b007145b._.js → node_modules_235267bb._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_11d81adf._.js → node_modules_25dfb0ba._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_205ce1c9._.js → node_modules_2b12c669._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_cc19e85c._.js → node_modules_32996880._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_62621b34._.js → node_modules_35885fe9._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_ee43cfd6._.js → node_modules_38a95353._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_f596a14c._.js → node_modules_3a317c51._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_776b68cf._.js → node_modules_44966ab2._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_514c148b._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_e272ac31._.js → node_modules_53af751a._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_23d38260._.js → node_modules_5f539891._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_86b6ffa4._.js → node_modules_60402210._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_3769cd60._.js → node_modules_60eccfb6._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_fdf808cf._.js → node_modules_632c098c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_60cf7de2._.js → node_modules_6c42f75c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_2f215d2b._.js → node_modules_6fbe276d._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_4cd41088._.js → node_modules_740e9d59._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_d0af4cb2._.js → node_modules_7a3d551c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_4f41f172._.js → node_modules_861cb9cf._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_db8af6e3._.js → node_modules_8a892761._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_28fef057._.js → node_modules_a5a4946e._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_3d9afa91._.js → node_modules_a712c937._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_330b9e3c._.js → node_modules_a8c276dd._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_abf4f826._.js → node_modules_acc9d529._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_39a3e684._.js → node_modules_ad07ab39._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_1d88c7cc._.js → node_modules_b38efa22._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_8633bac6._.js → node_modules_b4ef036d._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_abc9e5a6._.js → node_modules_b6bad701._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_c90fa812._.js → node_modules_b9810024._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_f56b62b0._.js → node_modules_b9ad808d._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_7287189a._.js → node_modules_bc287d9f._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_5ab83f0a._.js → node_modules_c411d7df._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_c98dd942._.js → node_modules_c6469d93._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_6391b0cd._.js → node_modules_c704e802._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_df113a74._.js → node_modules_cda46cfc._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_aa6da06c._.js → node_modules_cf171d0c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_be61cdef._.js → node_modules_e8927fc2._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_katex_dist_katex_mjs_d037b3b1._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_mermaid_dist_chunks_mermaid_core_chunk-7R4GIKGN_mjs_e5dda8cc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_66a70595._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_app_login_page_tsx_72f58654._.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/{d60f0b3e2f4689ac.js → 01eddf501c574a44.js} +1 -1
- package/.next/{static/chunks/ec0de430276c8209.js → standalone/.next/static/chunks/078d76156083f265.js} +1 -1
- package/.next/standalone/.next/static/chunks/{6a17b619eed04f07.js → 07c9f28a269c701a.js} +2 -2
- package/.next/standalone/.next/static/chunks/1e782a49beaf489c.js +1 -0
- package/.next/{static/chunks/55723b38de737547.js → standalone/.next/static/chunks/21105f8885631d60.js} +1 -1
- package/.next/standalone/.next/static/chunks/4071dbec4cf7e72e.js +109 -0
- package/.next/{static/chunks/052f178ab7519d8d.js → standalone/.next/static/chunks/5432ce4a494bc74d.js} +2 -2
- package/.next/standalone/.next/static/chunks/59cd76b8d89e776a.js +1 -0
- package/.next/standalone/.next/static/chunks/67bd1a5de2195779.js +1 -0
- package/.next/standalone/.next/static/chunks/6baf949fafec6be3.js +1 -0
- package/.next/standalone/.next/static/chunks/737b8cff3c6a4e30.js +1 -0
- package/.next/standalone/.next/static/chunks/7e35f4cf2e266022.js +1 -0
- package/.next/standalone/.next/static/chunks/a87b5e84254095a5.js +1 -0
- package/.next/standalone/.next/static/chunks/b43afe7d924243d9.js +2 -0
- package/.next/standalone/.next/static/chunks/c6bd2818656b1f20.css +1 -0
- package/.next/{static/chunks/559e55a53f22f5d1.js → standalone/.next/static/chunks/c875bd2ff662b46f.js} +1 -1
- package/.next/{static/chunks/6d12c79948c7e0ac.js → standalone/.next/static/chunks/dc59a07a8f327b40.js} +1 -1
- package/.next/standalone/.next/static/chunks/e09d9ee16fe90255.js +1 -0
- package/.next/standalone/.next/static/chunks/{20337e5244416041.js → e20b02ee30c11a26.js} +1 -1
- package/.next/standalone/.next/static/chunks/ff6357067630b168.js +1 -0
- package/.next/standalone/LICENSE +1 -1
- package/.next/standalone/bin/cli.js +1 -1
- package/.next/standalone/features/feature-skill-used-jump-link/design/2026-03-18-skill-used-jump-link-design.md +126 -0
- package/.next/standalone/features/feature-skill-used-jump-link/feature.json +32 -0
- package/.next/standalone/features/feature-skill-used-jump-link/issue.md +32 -0
- package/.next/standalone/features/feature-skill-used-jump-link/plans/2026-03-18-skill-used-jump-link.md +528 -0
- package/.next/standalone/next.config.ts +14 -2
- package/.next/standalone/node_modules/.prisma/client/edge.js +23 -5
- package/.next/standalone/node_modules/.prisma/client/index-browser.js +20 -2
- package/.next/standalone/node_modules/.prisma/client/index.js +23 -5
- package/.next/standalone/node_modules/.prisma/client/package.json +1 -1
- package/.next/standalone/node_modules/.prisma/client/schema.prisma +19 -2
- package/.next/standalone/node_modules/.prisma/client/wasm.js +20 -2
- package/.next/standalone/node_modules/@img/colour/color.cjs +11 -9
- package/.next/standalone/node_modules/@img/colour/package.json +21 -8
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/prisma/schema.prisma +19 -2
- package/.next/standalone/scripts/activate_telemetry.sh +24 -24
- package/.next/standalone/scripts/claude_watcher_client.ts +9 -7
- package/.next/standalone/scripts/init_opengauss.py +15 -0
- package/.next/standalone/scripts/install.js +68 -35
- package/.next/standalone/scripts/logs.js +1 -1
- package/.next/standalone/scripts/openclaw_watcher_client.ts +9 -7
- package/.next/standalone/scripts/opencode_plugin.ts +278 -46
- package/.next/standalone/scripts/postinstall.js +80 -38
- package/.next/standalone/scripts/restart.js +1 -1
- package/.next/standalone/scripts/start.js +84 -60
- package/.next/standalone/scripts/status.js +1 -1
- package/.next/standalone/scripts/stop.js +38 -14
- package/.next/standalone/scripts/sync_skills.js +5 -5
- package/.next/standalone/scripts/utils.js +91 -23
- package/.next/standalone/tests/setup_skill_optimizer.sh +118 -0
- package/.next/static/chunks/{d60f0b3e2f4689ac.js → 01eddf501c574a44.js} +1 -1
- package/.next/{standalone/.next/static/chunks/ec0de430276c8209.js → static/chunks/078d76156083f265.js} +1 -1
- package/.next/static/chunks/{6a17b619eed04f07.js → 07c9f28a269c701a.js} +2 -2
- package/.next/static/chunks/1e782a49beaf489c.js +1 -0
- package/.next/{standalone/.next/static/chunks/55723b38de737547.js → static/chunks/21105f8885631d60.js} +1 -1
- package/.next/static/chunks/4071dbec4cf7e72e.js +109 -0
- package/.next/{standalone/.next/static/chunks/052f178ab7519d8d.js → static/chunks/5432ce4a494bc74d.js} +2 -2
- package/.next/static/chunks/59cd76b8d89e776a.js +1 -0
- package/.next/static/chunks/67bd1a5de2195779.js +1 -0
- package/.next/static/chunks/6baf949fafec6be3.js +1 -0
- package/.next/static/chunks/737b8cff3c6a4e30.js +1 -0
- package/.next/static/chunks/7e35f4cf2e266022.js +1 -0
- package/.next/static/chunks/a87b5e84254095a5.js +1 -0
- package/.next/static/chunks/b43afe7d924243d9.js +2 -0
- package/.next/static/chunks/c6bd2818656b1f20.css +1 -0
- package/.next/{standalone/.next/static/chunks/559e55a53f22f5d1.js → static/chunks/c875bd2ff662b46f.js} +1 -1
- package/.next/{standalone/.next/static/chunks/6d12c79948c7e0ac.js → static/chunks/dc59a07a8f327b40.js} +1 -1
- package/.next/static/chunks/e09d9ee16fe90255.js +1 -0
- package/.next/static/chunks/{20337e5244416041.js → e20b02ee30c11a26.js} +1 -1
- package/.next/static/chunks/ff6357067630b168.js +1 -0
- package/LICENSE +1 -1
- package/README.md +7 -6
- package/bin/cli.js +1 -1
- package/package.json +1 -1
- package/prisma/schema.prisma +19 -2
- package/scripts/activate_telemetry.sh +24 -24
- package/scripts/claude_watcher_client.ts +9 -7
- package/scripts/init_opengauss.py +15 -0
- package/scripts/install.js +68 -35
- package/scripts/logs.js +1 -1
- package/scripts/openclaw_watcher_client.ts +9 -7
- package/scripts/opencode_plugin.ts +278 -46
- package/scripts/postinstall.js +80 -38
- package/scripts/restart.js +1 -1
- package/scripts/start.js +84 -60
- package/scripts/status.js +1 -1
- package/scripts/stop.js +38 -14
- package/scripts/sync_skills.js +5 -5
- package/scripts/utils.js +91 -23
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1306e4eb._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1809fb2b._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__19594bdd._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__19db3d34._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2b2e7f49._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__3c02de9b._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__3f3ad12b._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__4c1ad182._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__4dce0fe6._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__582cdc68._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__625e84f3._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__68b5a8b3._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__704b8533._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__78ea20f2._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__7f754db9._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__824c33e1._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__92449e6d._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__9465727f._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__9c3018b5._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a12846e0._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a637116a._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a8f83ee4._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a8ffc1b1._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a9cb205c._.js +0 -122
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ab7048b0._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ac25e4ae._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ae5ac9cd._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__bebf4267._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__c5ae3ebd._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ebdafae4._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__eefd5f5b._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__082c32a2._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_b7889f85._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules_0b762d3e._.js +0 -3
- package/.next/standalone/.next/static/chunks/024c9acb4aa490c8.js +0 -1
- package/.next/standalone/.next/static/chunks/104f2c1fb93033c0.js +0 -1
- package/.next/standalone/.next/static/chunks/222a937a6c859036.js +0 -1
- package/.next/standalone/.next/static/chunks/2e1b2125198a02c4.js +0 -1
- package/.next/standalone/.next/static/chunks/32b26ff1bbd034fd.js +0 -1
- package/.next/standalone/.next/static/chunks/428e6cf64b115e9d.css +0 -1
- package/.next/standalone/.next/static/chunks/62e251619a96dc26.js +0 -1
- package/.next/standalone/.next/static/chunks/65c652f23d2d68bd.js +0 -133
- package/.next/standalone/.next/static/chunks/876e2d70185fd438.js +0 -1
- package/.next/standalone/.next/static/chunks/c647b2e4532050e0.js +0 -1
- package/.next/standalone/.next/static/chunks/d2e574310159a10b.js +0 -1
- package/.next/standalone/.next/static/chunks/dab1749712763979.js +0 -2
- package/.next/static/chunks/024c9acb4aa490c8.js +0 -1
- package/.next/static/chunks/104f2c1fb93033c0.js +0 -1
- package/.next/static/chunks/222a937a6c859036.js +0 -1
- package/.next/static/chunks/2e1b2125198a02c4.js +0 -1
- package/.next/static/chunks/32b26ff1bbd034fd.js +0 -1
- package/.next/static/chunks/428e6cf64b115e9d.css +0 -1
- package/.next/static/chunks/62e251619a96dc26.js +0 -1
- package/.next/static/chunks/65c652f23d2d68bd.js +0 -133
- package/.next/static/chunks/876e2d70185fd438.js +0 -1
- package/.next/static/chunks/c647b2e4532050e0.js +0 -1
- package/.next/static/chunks/d2e574310159a10b.js +0 -1
- package/.next/static/chunks/dab1749712763979.js +0 -2
- /package/.next/standalone/.next/static/{Zt2VD1Py2IilfVNJL-9Wm → H581Rok68JtPV4bAVVH3l}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{Zt2VD1Py2IilfVNJL-9Wm → H581Rok68JtPV4bAVVH3l}/_clientMiddlewareManifest.json +0 -0
- /package/.next/standalone/.next/static/{Zt2VD1Py2IilfVNJL-9Wm → H581Rok68JtPV4bAVVH3l}/_ssgManifest.js +0 -0
- /package/.next/static/{Zt2VD1Py2IilfVNJL-9Wm → H581Rok68JtPV4bAVVH3l}/_buildManifest.js +0 -0
- /package/.next/static/{Zt2VD1Py2IilfVNJL-9Wm → H581Rok68JtPV4bAVVH3l}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{Zt2VD1Py2IilfVNJL-9Wm → H581Rok68JtPV4bAVVH3l}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports=[74008,e=>{"use strict";var t=e.i(36689);let s=null;function n(){let e;if(s)return s;let n=process.env.https_proxy||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.HTTP_PROXY,r="0"!==process.env.NODE_TLS_REJECT_UNAUTHORIZED;if(n){console.log("[ProxyConfig] HTTP proxy configured (URL hidden for privacy)"),!1===r&&console.log("[ProxyConfig] SSL certificate verification is disabled");let s=new t.ProxyAgent({uri:n,connect:{rejectUnauthorized:r}}),i=new t.Agent({connect:{rejectUnauthorized:r}}),a=process.env.no_proxy||process.env.NO_PROXY,o=a?a.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean):[];e=(e,n)=>{let r=e.toString(),a=!1;if(o.length>0)try{let e=new URL(r).hostname.toLowerCase();a=o.some(t=>!!("*"===t||e===t||t.startsWith(".")&&e.endsWith(t)||!t.startsWith(".")&&(e===t||e.endsWith("."+t))))}catch(e){}return(0,t.fetch)(e,{...n,dispatcher:a?i:s})}}else if(!1===r){console.log("[ProxyConfig] No proxy, but SSL certificate verification is disabled");let s=new t.Agent({connect:{rejectUnauthorized:!1}});e=(e,n)=>(0,t.fetch)(e,{...n,dispatcher:s})}return s={customFetch:e,proxyUrl:n,rejectUnauthorized:r}}e.s(["getProxyConfig",()=>n])},88045,94601,86641,33189,98437,55623,85,73730,39357,92146,e=>{"use strict";var t,s,n,r,i,a,o,l,c,h,u,d,f,p,m,g,_,y,w,b,v,x,S,$,A,O,k,I,R,E,P,C,T,j,N,M,L,D,B,W,U,q,F,X,H,J,K,V,z,Q,G,Y,Z,ee,et,es,en,er,ei,ea,eo,el,ec,eh,eu,ed,ef,ep,em,eg,e_,ey,ew,eb,ev,ex;let eS,e$,eA,eO;function ek(e,t,s,n,r){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!r)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,s):r?r.value=s:t.set(e,s),s}function eI(e,t,s,n){if("a"===s&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(e):n?n.value:t.get(e)}let eR=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return eR=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),s=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^s()&15>>e/4).toString(16))};function eE(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}let eP=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class eC extends Error{}class eT extends eC{constructor(e,t,s,n){super(`${eT.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t,this.code=t?.code,this.param=t?.param,this.type=t?.type}static makeMessage(e,t,s){let n=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new eN({message:s,cause:eP(t)});let r=t?.error;return 400===e?new eL(e,r,s,n):401===e?new eD(e,r,s,n):403===e?new eB(e,r,s,n):404===e?new eW(e,r,s,n):409===e?new eU(e,r,s,n):422===e?new eq(e,r,s,n):429===e?new eF(e,r,s,n):e>=500?new eX(e,r,s,n):new eT(e,r,s,n)}}class ej extends eT{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class eN extends eT{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class eM extends eN{constructor({message:e}={}){super({message:e??"Request timed out."})}}class eL extends eT{}class eD extends eT{}class eB extends eT{}class eW extends eT{}class eU extends eT{}class eq extends eT{}class eF extends eT{}class eX extends eT{}class eH extends eC{constructor(){super("Could not parse response content as the length limit was reached")}}class eJ extends eC{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class eK extends Error{constructor(e){super(e)}}e.s(["APIConnectionError",()=>eN,"APIConnectionTimeoutError",()=>eM,"APIError",()=>eT,"APIUserAbortError",()=>ej,"AuthenticationError",()=>eD,"BadRequestError",()=>eL,"ConflictError",()=>eU,"ContentFilterFinishReasonError",()=>eJ,"InternalServerError",()=>eX,"InvalidWebhookSignatureError",()=>eK,"LengthFinishReasonError",()=>eH,"NotFoundError",()=>eW,"OpenAIError",()=>eC,"PermissionDeniedError",()=>eB,"RateLimitError",()=>eF,"UnprocessableEntityError",()=>eq],94601);let eV=/^[a-z][a-z0-9+.-]*:/i,ez=e=>eV.test(e),eQ=e=>(eQ=Array.isArray)(e),eG=eQ;function eY(e){return"object"!=typeof e?{}:e??{}}function eZ(e){if(!e)return!0;for(let t in e)return!1;return!0}function e0(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function e1(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}let e2=(e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eC(`${e} must be an integer`);if(t<0)throw new eC(`${e} must be a positive integer`);return t},e3=e=>{try{return JSON.parse(e)}catch(e){return}};e.s(["hasOwn",()=>e0,"isAbsoluteURL",0,ez,"isArray",()=>eQ,"isEmptyObj",()=>eZ,"isObj",()=>e1,"isReadonlyArray",()=>eG,"maybeObj",()=>eY,"safeJSON",0,e3,"validatePositiveInteger",0,e2],86641);let e8=e=>new Promise(t=>setTimeout(t,e)),e4="6.25.0",e6=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",e5=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";function e9(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function e7(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return e9({start(){},async pull(e){let{done:s,value:n}=await t.next();s?e.close():e.enqueue(n)},async cancel(){await t.return?.()}})}function te(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function tt(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await e[Symbol.asyncIterator]().return?.();let t=e.getReader(),s=t.cancel();t.releaseLock(),await s}let ts=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),tn="RFC3986",tr=e=>String(e),ti={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:tr},ta=(e,t)=>(ta=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty))(e,t),to=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();function tl(e,t){if(eQ(e)){let s=[];for(let n=0;n<e.length;n+=1)s.push(t(e[n]));return s}return t(e)}let tc={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},th=function(e,t){Array.prototype.push.apply(e,eQ(t)?t:[t])},tu={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,s,n,r)=>{if(0===e.length)return e;let i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===s)return escape(i).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<i.length;e+=1024){let t=i.length>=1024?i.slice(e,e+1024):i,s=[];for(let e=0;e<t.length;++e){let n=t.charCodeAt(e);if(45===n||46===n||95===n||126===n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||"RFC1738"===r&&(40===n||41===n)){s[s.length]=t.charAt(e);continue}if(n<128){s[s.length]=to[n];continue}if(n<2048){s[s.length]=to[192|n>>6]+to[128|63&n];continue}if(n<55296||n>=57344){s[s.length]=to[224|n>>12]+to[128|n>>6&63]+to[128|63&n];continue}e+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),s[s.length]=to[240|n>>18]+to[128|n>>12&63]+to[128|n>>6&63]+to[128|63&n]}a+=s.join("")}return a},encodeValuesOnly:!1,format:tn,formatter:tr,indices:!1,serializeDate:e=>(e$??(e$=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1},td={};function tf(e){let t;return(eA??(eA=(t=new globalThis.TextEncoder).encode.bind(t)))(e)}function tp(e){let t;return(eO??(eO=(t=new globalThis.TextDecoder).decode.bind(t)))(e)}class tm{constructor(){t.set(this,void 0),s.set(this,void 0),ek(this,t,new Uint8Array,"f"),ek(this,s,null,"f")}decode(e){let n;if(null==e)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?tf(e):e;ek(this,t,function(e){let t=0;for(let s of e)t+=s.length;let s=new Uint8Array(t),n=0;for(let t of e)s.set(t,n),n+=t.length;return s}([eI(this,t,"f"),r]),"f");let i=[];for(;null!=(n=function(e,t){for(let s=t??0;s<e.length;s++){if(10===e[s])return{preceding:s,index:s+1,carriage:!1};if(13===e[s])return{preceding:s,index:s+1,carriage:!0}}return null}(eI(this,t,"f"),eI(this,s,"f")));){if(n.carriage&&null==eI(this,s,"f")){ek(this,s,n.index,"f");continue}if(null!=eI(this,s,"f")&&(n.index!==eI(this,s,"f")+1||n.carriage)){i.push(tp(eI(this,t,"f").subarray(0,eI(this,s,"f")-1))),ek(this,t,eI(this,t,"f").subarray(eI(this,s,"f")),"f"),ek(this,s,null,"f");continue}let e=null!==eI(this,s,"f")?n.preceding-1:n.preceding,r=tp(eI(this,t,"f").subarray(0,e));i.push(r),ek(this,t,eI(this,t,"f").subarray(n.index),"f"),ek(this,s,null,"f")}return i}flush(){return eI(this,t,"f").length?this.decode("\n"):[]}}t=new WeakMap,s=new WeakMap,tm.NEWLINE_CHARS=new Set(["\n","\r"]),tm.NEWLINE_REGEXP=/\r\n|[\n\r]/g;let tg={off:0,error:200,warn:300,info:400,debug:500},t_=(e,t,s)=>{if(e){if(e0(tg,e))return e;tx(s).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(tg))}`)}};function ty(){}function tw(e,t,s){return!t||tg[e]>tg[s]?ty:t[e].bind(t)}let tb={error:ty,warn:ty,info:ty,debug:ty},tv=new WeakMap;function tx(e){let t=e.logger,s=e.logLevel??"off";if(!t)return tb;let n=tv.get(t);if(n&&n[0]===s)return n[1];let r={error:tw("error",t,s),warn:tw("warn",t,s),info:tw("info",t,s),debug:tw("debug",t,s)};return tv.set(t,[s,r]),r}let tS=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);class t${constructor(e,t,s){this.iterator=e,n.set(this,void 0),this.controller=t,ek(this,n,s,"f")}static fromSSEResponse(e,t,s,n){let r=!1,i=s?tx(s):console;async function*a(){if(r)throw new eC("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let s=!1;try{for await(let r of tA(e,t))if(!s){if(r.data.startsWith("[DONE]")){s=!0;continue}if(null!==r.event&&r.event.startsWith("thread.")){let e;try{e=JSON.parse(r.data)}catch(e){throw console.error("Could not parse message into JSON:",r.data),console.error("From chunk:",r.raw),e}if("error"==r.event)throw new eT(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}else{let t;try{t=JSON.parse(r.data)}catch(e){throw i.error("Could not parse message into JSON:",r.data),i.error("From chunk:",r.raw),e}if(t&&t.error)throw new eT(void 0,t.error,void 0,e.headers);yield n?{event:r.event,data:t}:t}}s=!0}catch(e){if(eE(e))return;throw e}finally{s||t.abort()}}return new t$(a,t,s)}static fromReadableStream(e,t,s){let n=!1;async function*r(){let t=new tm;for await(let s of te(e))for(let e of t.decode(s))yield e;for(let e of t.flush())yield e}return new t$(async function*(){if(n)throw new eC("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let e=!1;try{for await(let t of r())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if(eE(e))return;throw e}finally{e||t.abort()}},t,s)}[(n=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],s=this.iterator(),r=n=>({next:()=>{if(0===n.length){let n=s.next();e.push(n),t.push(n)}return n.shift()}});return[new t$(()=>r(e),this.controller,eI(this,n,"f")),new t$(()=>r(t),this.controller,eI(this,n,"f"))]}toReadableStream(){let e,t=this;return e9({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:s,done:n}=await e.next();if(n)return t.close();let r=tf(JSON.stringify(s)+"\n");t.enqueue(r)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}async function*tA(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new eC("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new eC("Attempted to iterate over a response with no body")}let s=new tk,n=new tm;for await(let t of tO(te(e.body)))for(let e of n.decode(t)){let t=s.decode(e);t&&(yield t)}for(let e of n.flush()){let t=s.decode(e);t&&(yield t)}}async function*tO(e){let t=new Uint8Array;for await(let s of e){let e;if(null==s)continue;let n=s instanceof ArrayBuffer?new Uint8Array(s):"string"==typeof s?tf(s):s,r=new Uint8Array(t.length+n.length);for(r.set(t),r.set(n,t.length),t=r;-1!==(e=function(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1]||13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return -1}(t));)yield t.slice(0,e),t=t.slice(e)}t.length>0&&(yield t)}class tk{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){var t;let s;if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[n,r,i]=-1!==(s=(t=e).indexOf(":"))?[t.substring(0,s),":",t.substring(s+1)]:[t,"",""];return i.startsWith(" ")&&(i=i.substring(1)),"event"===n?this.event=i:"data"===n&&this.data.push(i),null}}async function tI(e,t){let{response:s,requestLogID:n,retryOfRequestLogID:r,startTime:i}=t,a=await (async()=>{if(t.options.stream)return(tx(e).debug("response",s.status,s.url,s.headers,s.body),t.options.__streamClass)?t.options.__streamClass.fromSSEResponse(s,t.controller,e,t.options.__synthesizeEventData):t$.fromSSEResponse(s,t.controller,e,t.options.__synthesizeEventData);if(204===s.status)return null;if(t.options.__binaryResponse)return s;let n=s.headers.get("content-type"),r=n?.split(";")[0]?.trim();if(r?.includes("application/json")||r?.endsWith("+json")){if("0"===s.headers.get("content-length"))return;return tR(await s.json(),s)}return await s.text()})();return tx(e).debug(`[${n}] response parsed`,tS({retryOfRequestLogID:r,url:s.url,status:s.status,body:a,durationMs:Date.now()-i})),a}function tR(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class tE extends Promise{constructor(e,t,s=tI){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=s,r.set(this,void 0),ek(this,r,e,"f")}_thenUnwrap(e){return new tE(eI(this,r,"f"),this.responsePromise,async(t,s)=>tR(e(await this.parseResponse(t,s),s),s.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(eI(this,r,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}r=new WeakMap,e.s(["APIPromise",()=>tE],33189);class tP{constructor(e,t,s,n){i.set(this,void 0),ek(this,i,e,"f"),this.options=n,this.response=t,this.body=s}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new eC("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await eI(this,i,"f").requestAPIList(this.constructor,e)}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(i=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}class tC extends tE{constructor(e,t,s){super(e,t,async(e,t)=>new s(e,t.response,await tI(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}class tT extends tP{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.object=s.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class tj extends tP{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.has_more=s.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...eY(this.options.query),after:t}}:null}}class tN extends tP{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.has_more=s.has_more||!1,this.last_id=s.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...eY(this.options.query),after:e}}:null}}e.s(["ConversationCursorPage",()=>tN,"CursorPage",()=>tj,"Page",()=>tT,"PagePromise",()=>tC],98437);let tM=()=>{if("u"<typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function tL(e,t,s){return tM(),new File(e,t??"unknown_file",s)}function tD(e){return("object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}let tB=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],tW=async(e,t)=>tH(e.body)?{...e,body:await tF(e.body,t)}:e,tU=async(e,t)=>({...e,body:await tF(e.body,t)}),tq=new WeakMap,tF=async(e,t)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,s=tq.get(t);if(s)return s;let n=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,s=new FormData;if(s.toString()===await new e(s).text())return!1;return!0}catch{return!0}})();return tq.set(t,n),n}(t))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let s=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>tJ(s,e,t))),s},tX=e=>e instanceof Blob&&"name"in e,tH=e=>{if("object"==typeof e&&null!==e&&(e instanceof Response||tB(e)||tX(e)))return!0;if(Array.isArray(e))return e.some(tH);if(e&&"object"==typeof e){for(let t in e)if(tH(e[t]))return!0}return!1},tJ=async(e,t,s)=>{if(void 0!==s){if(null==s)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof s||"number"==typeof s||"boolean"==typeof s)e.append(t,String(s));else if(s instanceof Response)e.append(t,tL([await s.blob()],tD(s)));else if(tB(s))e.append(t,tL([await new Response(e7(s)).blob()],tD(s)));else if(tX(s))e.append(t,s,tD(s));else if(Array.isArray(s))await Promise.all(s.map(s=>tJ(e,t+"[]",s)));else if("object"==typeof s)await Promise.all(Object.entries(s).map(([s,n])=>tJ(e,`${t}[${s}]`,n)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${s} instead`)}},tK=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function tV(e,t,s){let n,r;if(tM(),null!=(n=e=await e)&&"object"==typeof n&&"string"==typeof n.name&&"number"==typeof n.lastModified&&tK(n))return e instanceof File?e:tL([await e.arrayBuffer()],e.name);if(null!=(r=e)&&"object"==typeof r&&"string"==typeof r.url&&"function"==typeof r.blob){let n=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),tL(await tz(n),t,s)}let i=await tz(e);if(t||(t=tD(e)),!s?.type){let e=i.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(s={...s,type:e})}return tL(i,t,s)}async function tz(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(tK(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(tB(e))for await(let s of e)t.push(...await tz(s));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}e.s([],55623);class tQ{constructor(e){this._client=e}}function tG(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let tY=Object.freeze(Object.create(null)),tZ=((e=tG)=>function(t,...s){let n;if(1===t.length)return t[0];let r=!1,i=[],a=t.reduce((t,n,a)=>{/[?#]/.test(n)&&(r=!0);let o=s[a],l=(r?encodeURIComponent:e)(""+o);return a!==s.length&&(null==o||"object"==typeof o&&o.toString===Object.getPrototypeOf(Object.getPrototypeOf(o.hasOwnProperty??tY)??tY)?.toString)&&(l=o+"",i.push({start:t.length+n.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(o).slice(8,-1)} is not a valid path parameter`})),t+n+(a===s.length?"":l)},""),o=a.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(n=l.exec(o));)i.push({start:n.index,length:n[0].length,error:`Value "${n[0]}" can't be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,s)=>{let n=" ".repeat(s.start-e),r="^".repeat(s.length);return e=s.start+s.length,t+n+r},"");throw new eC(`Path parameters result in path with invalid segments:
|
|
1
|
+
module.exports=[74008,e=>{"use strict";var t=e.i(36689);let s=null;function n(){let e;if(s)return s;let n=process.env.https_proxy||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.HTTP_PROXY,r="0"!==process.env.NODE_TLS_REJECT_UNAUTHORIZED;if(n){console.log("[ProxyConfig] HTTP proxy configured (URL hidden for privacy)"),!1===r&&console.log("[ProxyConfig] SSL certificate verification is disabled");let s=new t.ProxyAgent({uri:n,connect:{rejectUnauthorized:r}}),i=new t.Agent({connect:{rejectUnauthorized:r}}),a=process.env.no_proxy||process.env.NO_PROXY,o=a?a.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean):[];e=(e,n)=>{let r=e.toString(),a=!1;if(o.length>0)try{let e=new URL(r).hostname.toLowerCase();a=o.some(t=>!!("*"===t||e===t||t.startsWith(".")&&e.endsWith(t)||!t.startsWith(".")&&(e===t||e.endsWith("."+t))))}catch(e){}return(0,t.fetch)(e,{...n,dispatcher:a?i:s})}}else if(!1===r){console.log("[ProxyConfig] No proxy, but SSL certificate verification is disabled");let s=new t.Agent({connect:{rejectUnauthorized:!1}});e=(e,n)=>(0,t.fetch)(e,{...n,dispatcher:s})}return s={customFetch:e,proxyUrl:n,rejectUnauthorized:r}}e.s(["getProxyConfig",()=>n])},88045,94601,86641,33189,98437,55623,85,73730,39357,92146,e=>{"use strict";var t,s,n,r,i,a,o,l,c,h,u,d,f,p,m,g,_,y,w,b,v,x,$,S,A,O,k,I,R,E,P,C,T,j,N,M,L,D,B,W,U,q,F,X,H,J,K,V,z,Q,G,Y,Z,ee,et,es,en,er,ei,ea,eo,el,ec,eh,eu,ed,ef,ep,em,eg,e_,ey,ew,eb,ev,ex;let e$,eS,eA,eO;function ek(e,t,s,n,r){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!r)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,s):r?r.value=s:t.set(e,s),s}function eI(e,t,s,n){if("a"===s&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(e):n?n.value:t.get(e)}let eR=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return eR=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),s=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^s()&15>>e/4).toString(16))};function eE(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}let eP=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class eC extends Error{}class eT extends eC{constructor(e,t,s,n){super(`${eT.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t,this.code=t?.code,this.param=t?.param,this.type=t?.type}static makeMessage(e,t,s){let n=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new eN({message:s,cause:eP(t)});let r=t?.error;return 400===e?new eL(e,r,s,n):401===e?new eD(e,r,s,n):403===e?new eB(e,r,s,n):404===e?new eW(e,r,s,n):409===e?new eU(e,r,s,n):422===e?new eq(e,r,s,n):429===e?new eF(e,r,s,n):e>=500?new eX(e,r,s,n):new eT(e,r,s,n)}}class ej extends eT{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class eN extends eT{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class eM extends eN{constructor({message:e}={}){super({message:e??"Request timed out."})}}class eL extends eT{}class eD extends eT{}class eB extends eT{}class eW extends eT{}class eU extends eT{}class eq extends eT{}class eF extends eT{}class eX extends eT{}class eH extends eC{constructor(){super("Could not parse response content as the length limit was reached")}}class eJ extends eC{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class eK extends Error{constructor(e){super(e)}}e.s(["APIConnectionError",()=>eN,"APIConnectionTimeoutError",()=>eM,"APIError",()=>eT,"APIUserAbortError",()=>ej,"AuthenticationError",()=>eD,"BadRequestError",()=>eL,"ConflictError",()=>eU,"ContentFilterFinishReasonError",()=>eJ,"InternalServerError",()=>eX,"InvalidWebhookSignatureError",()=>eK,"LengthFinishReasonError",()=>eH,"NotFoundError",()=>eW,"OpenAIError",()=>eC,"PermissionDeniedError",()=>eB,"RateLimitError",()=>eF,"UnprocessableEntityError",()=>eq],94601);let eV=/^[a-z][a-z0-9+.-]*:/i,ez=e=>eV.test(e),eQ=e=>(eQ=Array.isArray)(e),eG=eQ;function eY(e){return"object"!=typeof e?{}:e??{}}function eZ(e){if(!e)return!0;for(let t in e)return!1;return!0}function e0(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function e1(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}let e2=(e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eC(`${e} must be an integer`);if(t<0)throw new eC(`${e} must be a positive integer`);return t},e3=e=>{try{return JSON.parse(e)}catch(e){return}};e.s(["hasOwn",()=>e0,"isAbsoluteURL",0,ez,"isArray",()=>eQ,"isEmptyObj",()=>eZ,"isObj",()=>e1,"isReadonlyArray",()=>eG,"maybeObj",()=>eY,"safeJSON",0,e3,"validatePositiveInteger",0,e2],86641);let e8=e=>new Promise(t=>setTimeout(t,e)),e4="6.32.0",e6=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",e5=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";function e9(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function e7(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return e9({start(){},async pull(e){let{done:s,value:n}=await t.next();s?e.close():e.enqueue(n)},async cancel(){await t.return?.()}})}function te(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function tt(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await e[Symbol.asyncIterator]().return?.();let t=e.getReader(),s=t.cancel();t.releaseLock(),await s}let ts=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),tn="RFC3986",tr=e=>String(e),ti={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:tr},ta=(e,t)=>(ta=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty))(e,t),to=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();function tl(e,t){if(eQ(e)){let s=[];for(let n=0;n<e.length;n+=1)s.push(t(e[n]));return s}return t(e)}let tc={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},th=function(e,t){Array.prototype.push.apply(e,eQ(t)?t:[t])},tu={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,s,n,r)=>{if(0===e.length)return e;let i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===s)return escape(i).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<i.length;e+=1024){let t=i.length>=1024?i.slice(e,e+1024):i,s=[];for(let e=0;e<t.length;++e){let n=t.charCodeAt(e);if(45===n||46===n||95===n||126===n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||"RFC1738"===r&&(40===n||41===n)){s[s.length]=t.charAt(e);continue}if(n<128){s[s.length]=to[n];continue}if(n<2048){s[s.length]=to[192|n>>6]+to[128|63&n];continue}if(n<55296||n>=57344){s[s.length]=to[224|n>>12]+to[128|n>>6&63]+to[128|63&n];continue}e+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),s[s.length]=to[240|n>>18]+to[128|n>>12&63]+to[128|n>>6&63]+to[128|63&n]}a+=s.join("")}return a},encodeValuesOnly:!1,format:tn,formatter:tr,indices:!1,serializeDate:e=>(eS??(eS=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1},td={};function tf(e){let t;return(eA??(eA=(t=new globalThis.TextEncoder).encode.bind(t)))(e)}function tp(e){let t;return(eO??(eO=(t=new globalThis.TextDecoder).decode.bind(t)))(e)}class tm{constructor(){t.set(this,void 0),s.set(this,void 0),ek(this,t,new Uint8Array,"f"),ek(this,s,null,"f")}decode(e){let n;if(null==e)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?tf(e):e;ek(this,t,function(e){let t=0;for(let s of e)t+=s.length;let s=new Uint8Array(t),n=0;for(let t of e)s.set(t,n),n+=t.length;return s}([eI(this,t,"f"),r]),"f");let i=[];for(;null!=(n=function(e,t){for(let s=t??0;s<e.length;s++){if(10===e[s])return{preceding:s,index:s+1,carriage:!1};if(13===e[s])return{preceding:s,index:s+1,carriage:!0}}return null}(eI(this,t,"f"),eI(this,s,"f")));){if(n.carriage&&null==eI(this,s,"f")){ek(this,s,n.index,"f");continue}if(null!=eI(this,s,"f")&&(n.index!==eI(this,s,"f")+1||n.carriage)){i.push(tp(eI(this,t,"f").subarray(0,eI(this,s,"f")-1))),ek(this,t,eI(this,t,"f").subarray(eI(this,s,"f")),"f"),ek(this,s,null,"f");continue}let e=null!==eI(this,s,"f")?n.preceding-1:n.preceding,r=tp(eI(this,t,"f").subarray(0,e));i.push(r),ek(this,t,eI(this,t,"f").subarray(n.index),"f"),ek(this,s,null,"f")}return i}flush(){return eI(this,t,"f").length?this.decode("\n"):[]}}t=new WeakMap,s=new WeakMap,tm.NEWLINE_CHARS=new Set(["\n","\r"]),tm.NEWLINE_REGEXP=/\r\n|[\n\r]/g;let tg={off:0,error:200,warn:300,info:400,debug:500},t_=(e,t,s)=>{if(e){if(e0(tg,e))return e;tx(s).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(tg))}`)}};function ty(){}function tw(e,t,s){return!t||tg[e]>tg[s]?ty:t[e].bind(t)}let tb={error:ty,warn:ty,info:ty,debug:ty},tv=new WeakMap;function tx(e){let t=e.logger,s=e.logLevel??"off";if(!t)return tb;let n=tv.get(t);if(n&&n[0]===s)return n[1];let r={error:tw("error",t,s),warn:tw("warn",t,s),info:tw("info",t,s),debug:tw("debug",t,s)};return tv.set(t,[s,r]),r}let t$=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);class tS{constructor(e,t,s){this.iterator=e,n.set(this,void 0),this.controller=t,ek(this,n,s,"f")}static fromSSEResponse(e,t,s,n){let r=!1,i=s?tx(s):console;async function*a(){if(r)throw new eC("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let s=!1;try{for await(let r of tA(e,t))if(!s){if(r.data.startsWith("[DONE]")){s=!0;continue}if(null!==r.event&&r.event.startsWith("thread.")){let e;try{e=JSON.parse(r.data)}catch(e){throw console.error("Could not parse message into JSON:",r.data),console.error("From chunk:",r.raw),e}if("error"==r.event)throw new eT(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}else{let t;try{t=JSON.parse(r.data)}catch(e){throw i.error("Could not parse message into JSON:",r.data),i.error("From chunk:",r.raw),e}if(t&&t.error)throw new eT(void 0,t.error,void 0,e.headers);yield n?{event:r.event,data:t}:t}}s=!0}catch(e){if(eE(e))return;throw e}finally{s||t.abort()}}return new tS(a,t,s)}static fromReadableStream(e,t,s){let n=!1;async function*r(){let t=new tm;for await(let s of te(e))for(let e of t.decode(s))yield e;for(let e of t.flush())yield e}return new tS(async function*(){if(n)throw new eC("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let e=!1;try{for await(let t of r())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if(eE(e))return;throw e}finally{e||t.abort()}},t,s)}[(n=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],s=this.iterator(),r=n=>({next:()=>{if(0===n.length){let n=s.next();e.push(n),t.push(n)}return n.shift()}});return[new tS(()=>r(e),this.controller,eI(this,n,"f")),new tS(()=>r(t),this.controller,eI(this,n,"f"))]}toReadableStream(){let e,t=this;return e9({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:s,done:n}=await e.next();if(n)return t.close();let r=tf(JSON.stringify(s)+"\n");t.enqueue(r)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}async function*tA(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new eC("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new eC("Attempted to iterate over a response with no body")}let s=new tk,n=new tm;for await(let t of tO(te(e.body)))for(let e of n.decode(t)){let t=s.decode(e);t&&(yield t)}for(let e of n.flush()){let t=s.decode(e);t&&(yield t)}}async function*tO(e){let t=new Uint8Array;for await(let s of e){let e;if(null==s)continue;let n=s instanceof ArrayBuffer?new Uint8Array(s):"string"==typeof s?tf(s):s,r=new Uint8Array(t.length+n.length);for(r.set(t),r.set(n,t.length),t=r;-1!==(e=function(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1]||13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return -1}(t));)yield t.slice(0,e),t=t.slice(e)}t.length>0&&(yield t)}class tk{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){var t;let s;if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[n,r,i]=-1!==(s=(t=e).indexOf(":"))?[t.substring(0,s),":",t.substring(s+1)]:[t,"",""];return i.startsWith(" ")&&(i=i.substring(1)),"event"===n?this.event=i:"data"===n&&this.data.push(i),null}}async function tI(e,t){let{response:s,requestLogID:n,retryOfRequestLogID:r,startTime:i}=t,a=await (async()=>{if(t.options.stream)return(tx(e).debug("response",s.status,s.url,s.headers,s.body),t.options.__streamClass)?t.options.__streamClass.fromSSEResponse(s,t.controller,e,t.options.__synthesizeEventData):tS.fromSSEResponse(s,t.controller,e,t.options.__synthesizeEventData);if(204===s.status)return null;if(t.options.__binaryResponse)return s;let n=s.headers.get("content-type"),r=n?.split(";")[0]?.trim();if(r?.includes("application/json")||r?.endsWith("+json")){if("0"===s.headers.get("content-length"))return;return tR(await s.json(),s)}return await s.text()})();return tx(e).debug(`[${n}] response parsed`,t$({retryOfRequestLogID:r,url:s.url,status:s.status,body:a,durationMs:Date.now()-i})),a}function tR(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class tE extends Promise{constructor(e,t,s=tI){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=s,r.set(this,void 0),ek(this,r,e,"f")}_thenUnwrap(e){return new tE(eI(this,r,"f"),this.responsePromise,async(t,s)=>tR(e(await this.parseResponse(t,s),s),s.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(eI(this,r,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}r=new WeakMap,e.s(["APIPromise",()=>tE],33189);class tP{constructor(e,t,s,n){i.set(this,void 0),ek(this,i,e,"f"),this.options=n,this.response=t,this.body=s}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new eC("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await eI(this,i,"f").requestAPIList(this.constructor,e)}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(i=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}class tC extends tE{constructor(e,t,s){super(e,t,async(e,t)=>new s(e,t.response,await tI(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}class tT extends tP{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.object=s.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class tj extends tP{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.has_more=s.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...eY(this.options.query),after:t}}:null}}class tN extends tP{constructor(e,t,s,n){super(e,t,s,n),this.data=s.data||[],this.has_more=s.has_more||!1,this.last_id=s.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...eY(this.options.query),after:e}}:null}}e.s(["ConversationCursorPage",()=>tN,"CursorPage",()=>tj,"Page",()=>tT,"PagePromise",()=>tC],98437);let tM=()=>{if("u"<typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function tL(e,t,s){return tM(),new File(e,t??"unknown_file",s)}function tD(e){return("object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}let tB=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],tW=async(e,t)=>tH(e.body)?{...e,body:await tF(e.body,t)}:e,tU=async(e,t)=>({...e,body:await tF(e.body,t)}),tq=new WeakMap,tF=async(e,t)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,s=tq.get(t);if(s)return s;let n=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,s=new FormData;if(s.toString()===await new e(s).text())return!1;return!0}catch{return!0}})();return tq.set(t,n),n}(t))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let s=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>tJ(s,e,t))),s},tX=e=>e instanceof Blob&&"name"in e,tH=e=>{if("object"==typeof e&&null!==e&&(e instanceof Response||tB(e)||tX(e)))return!0;if(Array.isArray(e))return e.some(tH);if(e&&"object"==typeof e){for(let t in e)if(tH(e[t]))return!0}return!1},tJ=async(e,t,s)=>{if(void 0!==s){if(null==s)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof s||"number"==typeof s||"boolean"==typeof s)e.append(t,String(s));else if(s instanceof Response)e.append(t,tL([await s.blob()],tD(s)));else if(tB(s))e.append(t,tL([await new Response(e7(s)).blob()],tD(s)));else if(tX(s))e.append(t,s,tD(s));else if(Array.isArray(s))await Promise.all(s.map(s=>tJ(e,t+"[]",s)));else if("object"==typeof s)await Promise.all(Object.entries(s).map(([s,n])=>tJ(e,`${t}[${s}]`,n)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${s} instead`)}},tK=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function tV(e,t,s){let n,r;if(tM(),null!=(n=e=await e)&&"object"==typeof n&&"string"==typeof n.name&&"number"==typeof n.lastModified&&tK(n))return e instanceof File?e:tL([await e.arrayBuffer()],e.name);if(null!=(r=e)&&"object"==typeof r&&"string"==typeof r.url&&"function"==typeof r.blob){let n=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),tL(await tz(n),t,s)}let i=await tz(e);if(t||(t=tD(e)),!s?.type){let e=i.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(s={...s,type:e})}return tL(i,t,s)}async function tz(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(tK(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(tB(e))for await(let s of e)t.push(...await tz(s));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}e.s([],55623);class tQ{constructor(e){this._client=e}}function tG(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let tY=Object.freeze(Object.create(null)),tZ=((e=tG)=>function(t,...s){let n;if(1===t.length)return t[0];let r=!1,i=[],a=t.reduce((t,n,a)=>{/[?#]/.test(n)&&(r=!0);let o=s[a],l=(r?encodeURIComponent:e)(""+o);return a!==s.length&&(null==o||"object"==typeof o&&o.toString===Object.getPrototypeOf(Object.getPrototypeOf(o.hasOwnProperty??tY)??tY)?.toString)&&(l=o+"",i.push({start:t.length+n.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(o).slice(8,-1)} is not a valid path parameter`})),t+n+(a===s.length?"":l)},""),o=a.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(n=l.exec(o));)i.push({start:n.index,length:n[0].length,error:`Value "${n[0]}" can't be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,s)=>{let n=" ".repeat(s.start-e),r="^".repeat(s.length);return e=s.start+s.length,t+n+r},"");throw new eC(`Path parameters result in path with invalid segments:
|
|
2
2
|
${i.map(e=>e.error).join("\n")}
|
|
3
3
|
${a}
|
|
4
|
-
${t}`)}return a})(tG);class t0 extends tQ{list(e,t={},s){return this._client.getAPIList(tZ`/chat/completions/${e}/messages`,tj,{query:t,...s})}}function t1(e){return void 0!==e&&"function"in e&&void 0!==e.function}function t2(e){return e?.$brand==="auto-parseable-response-format"}function t3(e){return e?.$brand==="auto-parseable-tool"}function t8(e,t){let s=e.choices.map(e=>{var s,n;if("length"===e.finish_reason)throw new eH;if("content_filter"===e.finish_reason)throw new eJ;return t6(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>{var s,n;let r;return s=t,n=e,r=s.tools?.find(e=>t1(e)&&e.function?.name===n.function.name),{...n,function:{...n.function,parsed_arguments:t3(r)?r.$parseRaw(n.function.arguments):r?.function.strict?JSON.parse(n.function.arguments):null}}})??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?(s=t,n=e.message.content,s.response_format?.type!=="json_schema"?null:s.response_format?.type==="json_schema"?"$parseRaw"in s.response_format?s.response_format.$parseRaw(n):JSON.parse(n):null):null}}});return{...e,choices:s}}function t4(e){return!!t2(e.response_format)||(e.tools?.some(e=>t3(e)||"function"===e.type&&!0===e.function.strict)??!1)}function t6(e){for(let t of e||[])if("function"!==t.type)throw new eC(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}e.s([],85);let t5=e=>e?.role==="assistant",t9=e=>e?.role==="tool";class t7{constructor(){a.add(this),this.controller=new AbortController,o.set(this,void 0),l.set(this,()=>{}),c.set(this,()=>{}),h.set(this,void 0),u.set(this,()=>{}),d.set(this,()=>{}),f.set(this,{}),p.set(this,!1),m.set(this,!1),g.set(this,!1),_.set(this,!1),ek(this,o,new Promise((e,t)=>{ek(this,l,e,"f"),ek(this,c,t,"f")}),"f"),ek(this,h,new Promise((e,t)=>{ek(this,u,e,"f"),ek(this,d,t,"f")}),"f"),eI(this,o,"f").catch(()=>{}),eI(this,h,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},eI(this,a,"m",y).bind(this))},0)}_connected(){this.ended||(eI(this,l,"f").call(this),this._emit("connect"))}get ended(){return eI(this,p,"f")}get errored(){return eI(this,m,"f")}get aborted(){return eI(this,g,"f")}abort(){this.controller.abort()}on(e,t){return(eI(this,f,"f")[e]||(eI(this,f,"f")[e]=[])).push({listener:t}),this}off(e,t){let s=eI(this,f,"f")[e];if(!s)return this;let n=s.findIndex(e=>e.listener===t);return n>=0&&s.splice(n,1),this}once(e,t){return(eI(this,f,"f")[e]||(eI(this,f,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,s)=>{ek(this,_,!0,"f"),"error"!==e&&this.once("error",s),this.once(e,t)})}async done(){ek(this,_,!0,"f"),await eI(this,h,"f")}_emit(e,...t){if(eI(this,p,"f"))return;"end"===e&&(ek(this,p,!0,"f"),eI(this,u,"f").call(this));let s=eI(this,f,"f")[e];if(s&&(eI(this,f,"f")[e]=s.filter(e=>!e.once),s.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];eI(this,_,"f")||s?.length||Promise.reject(e),eI(this,c,"f").call(this,e),eI(this,d,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];eI(this,_,"f")||s?.length||Promise.reject(e),eI(this,c,"f").call(this,e),eI(this,d,"f").call(this,e),this._emit("end")}}_emitFinal(){}}o=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,_=new WeakMap,a=new WeakSet,y=function(e){if(ek(this,m,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new ej),e instanceof ej)return ek(this,g,!0,"f"),this._emit("abort",e);if(e instanceof eC)return this._emit("error",e);if(e instanceof Error){let t=new eC(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new eC(String(e)))};class se extends t7{constructor(){super(...arguments),w.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);let t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t){if(this._emit("message",e),t9(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(t5(e)&&e.tool_calls)for(let t of e.tool_calls)"function"===t.type&&this._emit("functionToolCall",t.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new eC("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),eI(this,w,"m",b).call(this)}async finalMessage(){return await this.done(),eI(this,w,"m",v).call(this)}async finalFunctionToolCall(){return await this.done(),eI(this,w,"m",x).call(this)}async finalFunctionToolCallResult(){return await this.done(),eI(this,w,"m",S).call(this)}async totalUsage(){return await this.done(),eI(this,w,"m",$).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);let t=eI(this,w,"m",v).call(this);t&&this._emit("finalMessage",t);let s=eI(this,w,"m",b).call(this);s&&this._emit("finalContent",s);let n=eI(this,w,"m",x).call(this);n&&this._emit("finalFunctionToolCall",n);let r=eI(this,w,"m",S).call(this);null!=r&&this._emit("finalFunctionToolCallResult",r),this._chatCompletions.some(e=>e.usage)&&this._emit("totalUsage",eI(this,w,"m",$).call(this))}async _createChatCompletion(e,t,s){let n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),eI(this,w,"m",A).call(this,t);let r=await e.chat.completions.create({...t,stream:!1},{...s,signal:this.controller.signal});return this._connected(),this._addChatCompletion(t8(r,t))}async _runChatCompletion(e,t,s){for(let e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,s)}async _runTools(e,t,s){let n="tool",{tool_choice:r="auto",stream:i,...a}=t,o="string"!=typeof r&&"function"===r.type&&r?.function?.name,{maxChatCompletions:l=10}=s||{},c=t.tools.map(e=>{if(t3(e)){if(!e.$callback)throw new eC("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),h={};for(let e of c)"function"===e.type&&(h[e.function.name||e.function.function.name]=e.function);let u="tools"in t?c.map(e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(let e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){let t=await this._createChatCompletion(e,{...a,tool_choice:r,tools:u,messages:[...this.messages]},s),i=t.choices[0]?.message;if(!i)throw new eC("missing message in ChatCompletion response");if(!i.tool_calls?.length)break;for(let e of i.tool_calls){let t;if("function"!==e.type)continue;let s=e.id,{name:r,arguments:i}=e.function,a=h[r];if(a){if(o&&o!==r){let e=`Invalid tool_call: ${JSON.stringify(r)}. ${JSON.stringify(o)} requested. Please try again`;this._addMessage({role:n,tool_call_id:s,content:e});continue}}else{let e=`Invalid tool_call: ${JSON.stringify(r)}. Available options are: ${Object.keys(h).map(e=>JSON.stringify(e)).join(", ")}. Please try again`;this._addMessage({role:n,tool_call_id:s,content:e});continue}try{t="function"==typeof a.parse?await a.parse(i):i}catch(t){let e=t instanceof Error?t.message:String(t);this._addMessage({role:n,tool_call_id:s,content:e});continue}let l=await a.function(t,this),c=eI(this,w,"m",O).call(this,l);if(this._addMessage({role:n,tool_call_id:s,content:c}),o)return}}}}w=new WeakSet,b=function(){return eI(this,w,"m",v).call(this).content??null},v=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if(t5(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new eC("stream ended without producing a ChatCompletionMessage with role=assistant")},x=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(t5(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>"function"===e.type).at(-1)?.function}},S=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(t9(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some(e=>"assistant"===e.role&&e.tool_calls?.some(e=>"function"===e.type&&e.id===t.tool_call_id)))return t.content}},$=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},A=function(e){if(null!=e.n&&e.n>1)throw new eC("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},O=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class st extends se{static runTools(e,t,s){let n=new st,r={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,r)),n}_addMessage(e,t=!0){super._addMessage(e,t),t5(e)&&e.content&&this._emit("content",e.content)}}let ss=511;class sn extends Error{}class sr extends Error{}let si=e=>(function(e,t=ss){var s,n;let r,i,a,o,l,c,h,u,d,f;if("string"!=typeof e)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return s=e.trim(),n=t,r=s.length,i=0,a=e=>{throw new sn(`${e} at position ${i}`)},o=e=>{throw new sr(`${e} at position ${i}`)},l=()=>(f(),i>=r&&a("Unexpected end of input"),'"'===s[i])?c():"{"===s[i]?h():"["===s[i]?u():"null"===s.substring(i,i+4)||16&n&&r-i<4&&"null".startsWith(s.substring(i))?(i+=4,null):"true"===s.substring(i,i+4)||32&n&&r-i<4&&"true".startsWith(s.substring(i))?(i+=4,!0):"false"===s.substring(i,i+5)||32&n&&r-i<5&&"false".startsWith(s.substring(i))?(i+=5,!1):"Infinity"===s.substring(i,i+8)||128&n&&r-i<8&&"Infinity".startsWith(s.substring(i))?(i+=8,1/0):"-Infinity"===s.substring(i,i+9)||256&n&&1<r-i&&r-i<9&&"-Infinity".startsWith(s.substring(i))?(i+=9,-1/0):"NaN"===s.substring(i,i+3)||64&n&&r-i<3&&"NaN".startsWith(s.substring(i))?(i+=3,NaN):d(),c=()=>{let e=i,t=!1;for(i++;i<r&&('"'!==s[i]||t&&"\\"===s[i-1]);)t="\\"===s[i]&&!t,i++;if('"'==s.charAt(i))try{return JSON.parse(s.substring(e,++i-Number(t)))}catch(e){o(String(e))}else if(1&n)try{return JSON.parse(s.substring(e,i-Number(t))+'"')}catch(t){return JSON.parse(s.substring(e,s.lastIndexOf("\\"))+'"')}a("Unterminated string literal")},h=()=>{i++,f();let e={};try{for(;"}"!==s[i];){if(f(),i>=r&&8&n)return e;let t=c();f(),i++;try{let s=l();Object.defineProperty(e,t,{value:s,writable:!0,enumerable:!0,configurable:!0})}catch(t){if(8&n)return e;throw t}f(),","===s[i]&&i++}}catch(t){if(8&n)return e;a("Expected '}' at end of object")}return i++,e},u=()=>{i++;let e=[];try{for(;"]"!==s[i];)e.push(l()),f(),","===s[i]&&i++}catch(t){if(4&n)return e;a("Expected ']' at end of array")}return i++,e},d=()=>{if(0===i){"-"===s&&2&n&&a("Not sure what '-' is");try{return JSON.parse(s)}catch(e){if(2&n)try{if("."===s[s.length-1])return JSON.parse(s.substring(0,s.lastIndexOf(".")));return JSON.parse(s.substring(0,s.lastIndexOf("e")))}catch(e){}o(String(e))}}let e=i;for("-"===s[i]&&i++;s[i]&&!",]}".includes(s[i]);)i++;i!=r||2&n||a("Unterminated number literal");try{return JSON.parse(s.substring(e,i))}catch(t){"-"===s.substring(e,i)&&2&n&&a("Not sure what '-' is");try{return JSON.parse(s.substring(e,s.lastIndexOf("e")))}catch(e){o(String(e))}}},f=()=>{for(;i<r&&" \n\r ".includes(s[i]);)i++},l()})(e,2^ss);class sa extends se{constructor(e){super(),k.add(this),I.set(this,void 0),R.set(this,void 0),E.set(this,void 0),ek(this,I,e,"f"),ek(this,R,[],"f")}get currentChatCompletionSnapshot(){return eI(this,E,"f")}static fromReadableStream(e){let t=new sa(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,s){let n=new sa(t);return n._run(()=>n._runChatCompletion(e,{...t,stream:!0},{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}async _createChatCompletion(e,t,s){super._createChatCompletion;let n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),eI(this,k,"m",P).call(this);let r=await e.chat.completions.create({...t,stream:!0},{...s,signal:this.controller.signal});for await(let e of(this._connected(),r))eI(this,k,"m",T).call(this,e);if(r.controller.signal?.aborted)throw new ej;return this._addChatCompletion(eI(this,k,"m",M).call(this))}async _fromReadableStream(e,t){let s,n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),eI(this,k,"m",P).call(this),this._connected();let r=t$.fromReadableStream(e,this.controller);for await(let e of r)s&&s!==e.id&&this._addChatCompletion(eI(this,k,"m",M).call(this)),eI(this,k,"m",T).call(this,e),s=e.id;if(r.controller.signal?.aborted)throw new ej;return this._addChatCompletion(eI(this,k,"m",M).call(this))}[(I=new WeakMap,R=new WeakMap,E=new WeakMap,k=new WeakSet,P=function(){this.ended||ek(this,E,void 0,"f")},C=function(e){let t=eI(this,R,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},eI(this,R,"f")[e.index]=t),t},T=function(e){if(this.ended)return;let t=eI(this,k,"m",D).call(this,e);for(let s of(this._emit("chunk",e,t),e.choices)){let e=t.choices[s.index];null!=s.delta.content&&e.message?.role==="assistant"&&e.message?.content&&(this._emit("content",s.delta.content,e.message.content),this._emit("content.delta",{delta:s.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=s.delta.refusal&&e.message?.role==="assistant"&&e.message?.refusal&&this._emit("refusal.delta",{delta:s.delta.refusal,snapshot:e.message.refusal}),s.logprobs?.content!=null&&e.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:s.logprobs?.content,snapshot:e.logprobs?.content??[]}),s.logprobs?.refusal!=null&&e.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:s.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let n=eI(this,k,"m",C).call(this,e);for(let t of(e.finish_reason&&(eI(this,k,"m",N).call(this,e),null!=n.current_tool_call_index&&eI(this,k,"m",j).call(this,e,n.current_tool_call_index)),s.delta.tool_calls??[]))n.current_tool_call_index!==t.index&&(eI(this,k,"m",N).call(this,e),null!=n.current_tool_call_index&&eI(this,k,"m",j).call(this,e,n.current_tool_call_index)),n.current_tool_call_index=t.index;for(let t of s.delta.tool_calls??[]){let s=e.message.tool_calls?.[t.index];s?.type&&(s?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:s.function?.name,index:t.index,arguments:s.function.arguments,parsed_arguments:s.function.parsed_arguments,arguments_delta:t.function?.arguments??""}):sc(s?.type))}}},j=function(e,t){if(eI(this,k,"m",C).call(this,e).done_tool_calls.has(t))return;let s=e.message.tool_calls?.[t];if(!s)throw Error("no tool call snapshot");if(!s.type)throw Error("tool call snapshot missing `type`");if("function"===s.type){let e=eI(this,I,"f")?.tools?.find(e=>t1(e)&&e.function.name===s.function.name);this._emit("tool_calls.function.arguments.done",{name:s.function.name,index:t,arguments:s.function.arguments,parsed_arguments:t3(e)?e.$parseRaw(s.function.arguments):e?.function.strict?JSON.parse(s.function.arguments):null})}else sc(s.type)},N=function(e){let t=eI(this,k,"m",C).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let s=eI(this,k,"m",L).call(this);this._emit("content.done",{content:e.message.content,parsed:s?s.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},M=function(){if(this.ended)throw new eC("stream has ended, this shouldn't happen");let e=eI(this,E,"f");if(!e)throw new eC("request ended without sending any chunks");return ek(this,E,void 0,"f"),ek(this,R,[],"f"),function(e,t){var s;let{id:n,choices:r,created:i,model:a,system_fingerprint:o,...l}=e;return s={...l,id:n,choices:r.map(({message:t,finish_reason:s,index:n,logprobs:r,...i})=>{if(!s)throw new eC(`missing finish_reason for choice ${n}`);let{content:a=null,function_call:o,tool_calls:l,...c}=t,h=t.role;if(!h)throw new eC(`missing role for choice ${n}`);if(o){let{arguments:e,name:l}=o;if(null==e)throw new eC(`missing function_call.arguments for choice ${n}`);if(!l)throw new eC(`missing function_call.name for choice ${n}`);return{...i,message:{content:a,function_call:{arguments:e,name:l},role:h,refusal:t.refusal??null},finish_reason:s,index:n,logprobs:r}}return l?{...i,index:n,finish_reason:s,logprobs:r,message:{...c,role:h,content:a,refusal:t.refusal??null,tool_calls:l.map((t,s)=>{let{function:r,type:i,id:a,...o}=t,{arguments:l,name:c,...h}=r||{};if(null==a)throw new eC(`missing choices[${n}].tool_calls[${s}].id
|
|
4
|
+
${t}`)}return a})(tG);class t0 extends tQ{list(e,t={},s){return this._client.getAPIList(tZ`/chat/completions/${e}/messages`,tj,{query:t,...s})}}function t1(e){return void 0!==e&&"function"in e&&void 0!==e.function}function t2(e){return e?.$brand==="auto-parseable-response-format"}function t3(e){return e?.$brand==="auto-parseable-tool"}function t8(e,t){let s=e.choices.map(e=>{var s,n;if("length"===e.finish_reason)throw new eH;if("content_filter"===e.finish_reason)throw new eJ;return t6(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>{var s,n;let r;return s=t,n=e,r=s.tools?.find(e=>t1(e)&&e.function?.name===n.function.name),{...n,function:{...n.function,parsed_arguments:t3(r)?r.$parseRaw(n.function.arguments):r?.function.strict?JSON.parse(n.function.arguments):null}}})??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?(s=t,n=e.message.content,s.response_format?.type!=="json_schema"?null:s.response_format?.type==="json_schema"?"$parseRaw"in s.response_format?s.response_format.$parseRaw(n):JSON.parse(n):null):null}}});return{...e,choices:s}}function t4(e){return!!t2(e.response_format)||(e.tools?.some(e=>t3(e)||"function"===e.type&&!0===e.function.strict)??!1)}function t6(e){for(let t of e||[])if("function"!==t.type)throw new eC(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}e.s([],85);let t5=e=>e?.role==="assistant",t9=e=>e?.role==="tool";class t7{constructor(){a.add(this),this.controller=new AbortController,o.set(this,void 0),l.set(this,()=>{}),c.set(this,()=>{}),h.set(this,void 0),u.set(this,()=>{}),d.set(this,()=>{}),f.set(this,{}),p.set(this,!1),m.set(this,!1),g.set(this,!1),_.set(this,!1),ek(this,o,new Promise((e,t)=>{ek(this,l,e,"f"),ek(this,c,t,"f")}),"f"),ek(this,h,new Promise((e,t)=>{ek(this,u,e,"f"),ek(this,d,t,"f")}),"f"),eI(this,o,"f").catch(()=>{}),eI(this,h,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},eI(this,a,"m",y).bind(this))},0)}_connected(){this.ended||(eI(this,l,"f").call(this),this._emit("connect"))}get ended(){return eI(this,p,"f")}get errored(){return eI(this,m,"f")}get aborted(){return eI(this,g,"f")}abort(){this.controller.abort()}on(e,t){return(eI(this,f,"f")[e]||(eI(this,f,"f")[e]=[])).push({listener:t}),this}off(e,t){let s=eI(this,f,"f")[e];if(!s)return this;let n=s.findIndex(e=>e.listener===t);return n>=0&&s.splice(n,1),this}once(e,t){return(eI(this,f,"f")[e]||(eI(this,f,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,s)=>{ek(this,_,!0,"f"),"error"!==e&&this.once("error",s),this.once(e,t)})}async done(){ek(this,_,!0,"f"),await eI(this,h,"f")}_emit(e,...t){if(eI(this,p,"f"))return;"end"===e&&(ek(this,p,!0,"f"),eI(this,u,"f").call(this));let s=eI(this,f,"f")[e];if(s&&(eI(this,f,"f")[e]=s.filter(e=>!e.once),s.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];eI(this,_,"f")||s?.length||Promise.reject(e),eI(this,c,"f").call(this,e),eI(this,d,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];eI(this,_,"f")||s?.length||Promise.reject(e),eI(this,c,"f").call(this,e),eI(this,d,"f").call(this,e),this._emit("end")}}_emitFinal(){}}o=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,_=new WeakMap,a=new WeakSet,y=function(e){if(ek(this,m,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new ej),e instanceof ej)return ek(this,g,!0,"f"),this._emit("abort",e);if(e instanceof eC)return this._emit("error",e);if(e instanceof Error){let t=new eC(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new eC(String(e)))};class se extends t7{constructor(){super(...arguments),w.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);let t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t){if(this._emit("message",e),t9(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(t5(e)&&e.tool_calls)for(let t of e.tool_calls)"function"===t.type&&this._emit("functionToolCall",t.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new eC("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),eI(this,w,"m",b).call(this)}async finalMessage(){return await this.done(),eI(this,w,"m",v).call(this)}async finalFunctionToolCall(){return await this.done(),eI(this,w,"m",x).call(this)}async finalFunctionToolCallResult(){return await this.done(),eI(this,w,"m",$).call(this)}async totalUsage(){return await this.done(),eI(this,w,"m",S).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);let t=eI(this,w,"m",v).call(this);t&&this._emit("finalMessage",t);let s=eI(this,w,"m",b).call(this);s&&this._emit("finalContent",s);let n=eI(this,w,"m",x).call(this);n&&this._emit("finalFunctionToolCall",n);let r=eI(this,w,"m",$).call(this);null!=r&&this._emit("finalFunctionToolCallResult",r),this._chatCompletions.some(e=>e.usage)&&this._emit("totalUsage",eI(this,w,"m",S).call(this))}async _createChatCompletion(e,t,s){let n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),eI(this,w,"m",A).call(this,t);let r=await e.chat.completions.create({...t,stream:!1},{...s,signal:this.controller.signal});return this._connected(),this._addChatCompletion(t8(r,t))}async _runChatCompletion(e,t,s){for(let e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,s)}async _runTools(e,t,s){let n="tool",{tool_choice:r="auto",stream:i,...a}=t,o="string"!=typeof r&&"function"===r.type&&r?.function?.name,{maxChatCompletions:l=10}=s||{},c=t.tools.map(e=>{if(t3(e)){if(!e.$callback)throw new eC("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),h={};for(let e of c)"function"===e.type&&(h[e.function.name||e.function.function.name]=e.function);let u="tools"in t?c.map(e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(let e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){let t=await this._createChatCompletion(e,{...a,tool_choice:r,tools:u,messages:[...this.messages]},s),i=t.choices[0]?.message;if(!i)throw new eC("missing message in ChatCompletion response");if(!i.tool_calls?.length)break;for(let e of i.tool_calls){let t;if("function"!==e.type)continue;let s=e.id,{name:r,arguments:i}=e.function,a=h[r];if(a){if(o&&o!==r){let e=`Invalid tool_call: ${JSON.stringify(r)}. ${JSON.stringify(o)} requested. Please try again`;this._addMessage({role:n,tool_call_id:s,content:e});continue}}else{let e=`Invalid tool_call: ${JSON.stringify(r)}. Available options are: ${Object.keys(h).map(e=>JSON.stringify(e)).join(", ")}. Please try again`;this._addMessage({role:n,tool_call_id:s,content:e});continue}try{t="function"==typeof a.parse?await a.parse(i):i}catch(t){let e=t instanceof Error?t.message:String(t);this._addMessage({role:n,tool_call_id:s,content:e});continue}let l=await a.function(t,this),c=eI(this,w,"m",O).call(this,l);if(this._addMessage({role:n,tool_call_id:s,content:c}),o)return}}}}w=new WeakSet,b=function(){return eI(this,w,"m",v).call(this).content??null},v=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if(t5(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new eC("stream ended without producing a ChatCompletionMessage with role=assistant")},x=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(t5(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>"function"===e.type).at(-1)?.function}},$=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(t9(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some(e=>"assistant"===e.role&&e.tool_calls?.some(e=>"function"===e.type&&e.id===t.tool_call_id)))return t.content}},S=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},A=function(e){if(null!=e.n&&e.n>1)throw new eC("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},O=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class st extends se{static runTools(e,t,s){let n=new st,r={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,r)),n}_addMessage(e,t=!0){super._addMessage(e,t),t5(e)&&e.content&&this._emit("content",e.content)}}let ss=511;class sn extends Error{}class sr extends Error{}let si=e=>(function(e,t=ss){var s,n;let r,i,a,o,l,c,h,u,d,f;if("string"!=typeof e)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return s=e.trim(),n=t,r=s.length,i=0,a=e=>{throw new sn(`${e} at position ${i}`)},o=e=>{throw new sr(`${e} at position ${i}`)},l=()=>(f(),i>=r&&a("Unexpected end of input"),'"'===s[i])?c():"{"===s[i]?h():"["===s[i]?u():"null"===s.substring(i,i+4)||16&n&&r-i<4&&"null".startsWith(s.substring(i))?(i+=4,null):"true"===s.substring(i,i+4)||32&n&&r-i<4&&"true".startsWith(s.substring(i))?(i+=4,!0):"false"===s.substring(i,i+5)||32&n&&r-i<5&&"false".startsWith(s.substring(i))?(i+=5,!1):"Infinity"===s.substring(i,i+8)||128&n&&r-i<8&&"Infinity".startsWith(s.substring(i))?(i+=8,1/0):"-Infinity"===s.substring(i,i+9)||256&n&&1<r-i&&r-i<9&&"-Infinity".startsWith(s.substring(i))?(i+=9,-1/0):"NaN"===s.substring(i,i+3)||64&n&&r-i<3&&"NaN".startsWith(s.substring(i))?(i+=3,NaN):d(),c=()=>{let e=i,t=!1;for(i++;i<r&&('"'!==s[i]||t&&"\\"===s[i-1]);)t="\\"===s[i]&&!t,i++;if('"'==s.charAt(i))try{return JSON.parse(s.substring(e,++i-Number(t)))}catch(e){o(String(e))}else if(1&n)try{return JSON.parse(s.substring(e,i-Number(t))+'"')}catch(t){return JSON.parse(s.substring(e,s.lastIndexOf("\\"))+'"')}a("Unterminated string literal")},h=()=>{i++,f();let e={};try{for(;"}"!==s[i];){if(f(),i>=r&&8&n)return e;let t=c();f(),i++;try{let s=l();Object.defineProperty(e,t,{value:s,writable:!0,enumerable:!0,configurable:!0})}catch(t){if(8&n)return e;throw t}f(),","===s[i]&&i++}}catch(t){if(8&n)return e;a("Expected '}' at end of object")}return i++,e},u=()=>{i++;let e=[];try{for(;"]"!==s[i];)e.push(l()),f(),","===s[i]&&i++}catch(t){if(4&n)return e;a("Expected ']' at end of array")}return i++,e},d=()=>{if(0===i){"-"===s&&2&n&&a("Not sure what '-' is");try{return JSON.parse(s)}catch(e){if(2&n)try{if("."===s[s.length-1])return JSON.parse(s.substring(0,s.lastIndexOf(".")));return JSON.parse(s.substring(0,s.lastIndexOf("e")))}catch(e){}o(String(e))}}let e=i;for("-"===s[i]&&i++;s[i]&&!",]}".includes(s[i]);)i++;i!=r||2&n||a("Unterminated number literal");try{return JSON.parse(s.substring(e,i))}catch(t){"-"===s.substring(e,i)&&2&n&&a("Not sure what '-' is");try{return JSON.parse(s.substring(e,s.lastIndexOf("e")))}catch(e){o(String(e))}}},f=()=>{for(;i<r&&" \n\r ".includes(s[i]);)i++},l()})(e,2^ss);class sa extends se{constructor(e){super(),k.add(this),I.set(this,void 0),R.set(this,void 0),E.set(this,void 0),ek(this,I,e,"f"),ek(this,R,[],"f")}get currentChatCompletionSnapshot(){return eI(this,E,"f")}static fromReadableStream(e){let t=new sa(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,s){let n=new sa(t);return n._run(()=>n._runChatCompletion(e,{...t,stream:!0},{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}async _createChatCompletion(e,t,s){super._createChatCompletion;let n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),eI(this,k,"m",P).call(this);let r=await e.chat.completions.create({...t,stream:!0},{...s,signal:this.controller.signal});for await(let e of(this._connected(),r))eI(this,k,"m",T).call(this,e);if(r.controller.signal?.aborted)throw new ej;return this._addChatCompletion(eI(this,k,"m",M).call(this))}async _fromReadableStream(e,t){let s,n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),eI(this,k,"m",P).call(this),this._connected();let r=tS.fromReadableStream(e,this.controller);for await(let e of r)s&&s!==e.id&&this._addChatCompletion(eI(this,k,"m",M).call(this)),eI(this,k,"m",T).call(this,e),s=e.id;if(r.controller.signal?.aborted)throw new ej;return this._addChatCompletion(eI(this,k,"m",M).call(this))}[(I=new WeakMap,R=new WeakMap,E=new WeakMap,k=new WeakSet,P=function(){this.ended||ek(this,E,void 0,"f")},C=function(e){let t=eI(this,R,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},eI(this,R,"f")[e.index]=t),t},T=function(e){if(this.ended)return;let t=eI(this,k,"m",D).call(this,e);for(let s of(this._emit("chunk",e,t),e.choices)){let e=t.choices[s.index];null!=s.delta.content&&e.message?.role==="assistant"&&e.message?.content&&(this._emit("content",s.delta.content,e.message.content),this._emit("content.delta",{delta:s.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=s.delta.refusal&&e.message?.role==="assistant"&&e.message?.refusal&&this._emit("refusal.delta",{delta:s.delta.refusal,snapshot:e.message.refusal}),s.logprobs?.content!=null&&e.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:s.logprobs?.content,snapshot:e.logprobs?.content??[]}),s.logprobs?.refusal!=null&&e.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:s.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let n=eI(this,k,"m",C).call(this,e);for(let t of(e.finish_reason&&(eI(this,k,"m",N).call(this,e),null!=n.current_tool_call_index&&eI(this,k,"m",j).call(this,e,n.current_tool_call_index)),s.delta.tool_calls??[]))n.current_tool_call_index!==t.index&&(eI(this,k,"m",N).call(this,e),null!=n.current_tool_call_index&&eI(this,k,"m",j).call(this,e,n.current_tool_call_index)),n.current_tool_call_index=t.index;for(let t of s.delta.tool_calls??[]){let s=e.message.tool_calls?.[t.index];s?.type&&(s?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:s.function?.name,index:t.index,arguments:s.function.arguments,parsed_arguments:s.function.parsed_arguments,arguments_delta:t.function?.arguments??""}):sc(s?.type))}}},j=function(e,t){if(eI(this,k,"m",C).call(this,e).done_tool_calls.has(t))return;let s=e.message.tool_calls?.[t];if(!s)throw Error("no tool call snapshot");if(!s.type)throw Error("tool call snapshot missing `type`");if("function"===s.type){let e=eI(this,I,"f")?.tools?.find(e=>t1(e)&&e.function.name===s.function.name);this._emit("tool_calls.function.arguments.done",{name:s.function.name,index:t,arguments:s.function.arguments,parsed_arguments:t3(e)?e.$parseRaw(s.function.arguments):e?.function.strict?JSON.parse(s.function.arguments):null})}else sc(s.type)},N=function(e){let t=eI(this,k,"m",C).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let s=eI(this,k,"m",L).call(this);this._emit("content.done",{content:e.message.content,parsed:s?s.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},M=function(){if(this.ended)throw new eC("stream has ended, this shouldn't happen");let e=eI(this,E,"f");if(!e)throw new eC("request ended without sending any chunks");return ek(this,E,void 0,"f"),ek(this,R,[],"f"),function(e,t){var s;let{id:n,choices:r,created:i,model:a,system_fingerprint:o,...l}=e;return s={...l,id:n,choices:r.map(({message:t,finish_reason:s,index:n,logprobs:r,...i})=>{if(!s)throw new eC(`missing finish_reason for choice ${n}`);let{content:a=null,function_call:o,tool_calls:l,...c}=t,h=t.role;if(!h)throw new eC(`missing role for choice ${n}`);if(o){let{arguments:e,name:l}=o;if(null==e)throw new eC(`missing function_call.arguments for choice ${n}`);if(!l)throw new eC(`missing function_call.name for choice ${n}`);return{...i,message:{content:a,function_call:{arguments:e,name:l},role:h,refusal:t.refusal??null},finish_reason:s,index:n,logprobs:r}}return l?{...i,index:n,finish_reason:s,logprobs:r,message:{...c,role:h,content:a,refusal:t.refusal??null,tool_calls:l.map((t,s)=>{let{function:r,type:i,id:a,...o}=t,{arguments:l,name:c,...h}=r||{};if(null==a)throw new eC(`missing choices[${n}].tool_calls[${s}].id
|
|
5
5
|
${so(e)}`);if(null==i)throw new eC(`missing choices[${n}].tool_calls[${s}].type
|
|
6
6
|
${so(e)}`);if(null==c)throw new eC(`missing choices[${n}].tool_calls[${s}].function.name
|
|
7
7
|
${so(e)}`);if(null==l)throw new eC(`missing choices[${n}].tool_calls[${s}].function.arguments
|
|
8
|
-
${so(e)}`);return{...o,id:a,type:i,function:{...h,name:c,arguments:l}}})}}:{...i,message:{...c,content:a,role:h,refusal:t.refusal??null},finish_reason:s,index:n,logprobs:r}}),created:i,model:a,object:"chat.completion",...o?{system_fingerprint:o}:{}},t&&t4(t)?t8(s,t):{...s,choices:s.choices.map(e=>(t6(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(e,eI(this,I,"f"))},L=function(){let e=eI(this,I,"f")?.response_format;return t2(e)?e:null},D=function(e){var t,s,n,r;let i=eI(this,E,"f"),{choices:a,...o}=e;for(let{delta:a,finish_reason:l,index:c,logprobs:h=null,...u}of(i?Object.assign(i,o):i=ek(this,E,{...o,choices:[]},"f"),e.choices)){let e=i.choices[c];if(e||(e=i.choices[c]={finish_reason:l,index:c,message:{},logprobs:h,...u}),h)if(e.logprobs){let{content:n,refusal:r,...i}=h;sl(i),Object.assign(e.logprobs,i),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),r&&((s=e.logprobs).refusal??(s.refusal=[]),e.logprobs.refusal.push(...r))}else e.logprobs=Object.assign({},h);if(l&&(e.finish_reason=l,eI(this,I,"f")&&t4(eI(this,I,"f")))){if("length"===l)throw new eH;if("content_filter"===l)throw new eJ}if(Object.assign(e,u),!a)continue;let{content:o,refusal:d,function_call:f,role:p,tool_calls:m,...g}=a;if(sl(g),Object.assign(e.message,g),d&&(e.message.refusal=(e.message.refusal||"")+d),p&&(e.message.role=p),f&&(e.message.function_call?(f.name&&(e.message.function_call.name=f.name),f.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=f.arguments)):e.message.function_call=f),o&&(e.message.content=(e.message.content||"")+o,!e.message.refusal&&eI(this,k,"m",L).call(this)&&(e.message.parsed=si(e.message.content))),m)for(let{index:t,id:s,type:n,function:i,...a}of(e.message.tool_calls||(e.message.tool_calls=[]),m)){let o=(r=e.message.tool_calls)[t]??(r[t]={});Object.assign(o,a),s&&(o.id=s),n&&(o.type=n),i&&(o.function??(o.function={name:i.name??"",arguments:""})),i?.name&&(o.function.name=i.name),i?.arguments&&(o.function.arguments+=i.arguments,function(e,t){if(!e||!("tools"in e)||!e.tools)return!1;let s=e.tools?.find(e=>t1(e)&&e.function?.name===t.function.name);return t1(s)&&(t3(s)||s?.function.strict||!1)}(eI(this,I,"f"),o)&&(o.function.parsed_arguments=si(o.function.arguments)))}}return i},Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("chunk",s=>{let n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{for(let e of(s=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new t$(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function so(e){return JSON.stringify(e)}function sl(e){}function sc(e){}class sh extends sa{static fromReadableStream(e){let t=new sh(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,s){let n=new sh(t),r={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,r)),n}}class su extends tQ{constructor(){super(...arguments),this.messages=new t0(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(tZ`/chat/completions/${e}`,t)}update(e,t,s){return this._client.post(tZ`/chat/completions/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/chat/completions",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/chat/completions/${e}`,t)}parse(e,t){for(let t of e.tools??[]){if("function"!==t.type)throw new eC(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new eC(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}return this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(t=>t8(t,e))}runTools(e,t){return e.stream?sh.runTools(this._client,e,t):st.runTools(this._client,e,t)}stream(e,t){return sa.createChatCompletion(this._client,e,t)}}su.Messages=t0;class sd extends tQ{constructor(){super(...arguments),this.completions=new su(this._client)}}sd.Completions=su,e.s([],98546);let sf=Symbol("brand.privateNullableHeaders"),sp=e=>{let t=new Headers,s=new Set;for(let n of e){let e=new Set;for(let[r,i]of function*(e){let t;if(!e)return;if(sf in e){let{values:t,nulls:s}=e;for(let e of(yield*t.entries(),s))yield[e,null];return}let s=!1;for(let n of(e instanceof Headers?t=e.entries():eG(e)?t=e:(s=!0,t=Object.entries(e??{})),t)){let e=n[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=eG(n[1])?n[1]:[n[1]],r=!1;for(let n of t)void 0!==n&&(s&&!r&&(r=!0,yield[e,null]),yield[e,n])}}(n)){let n=r.toLowerCase();e.has(n)||(t.delete(r),e.add(n)),null===i?(t.delete(r),s.add(n)):(t.append(r,i),s.delete(n))}}return{[sf]:!0,values:t,nulls:s}};e.s(["buildHeaders",0,sp],73730);class sm extends tQ{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:sp([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class sg extends tQ{create(e,t){return this._client.post("/audio/transcriptions",tU({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class s_ extends tQ{create(e,t){return this._client.post("/audio/translations",tU({body:e,...t,__metadata:{model:e.model}},this._client))}}class sy extends tQ{constructor(){super(...arguments),this.transcriptions=new sg(this._client),this.translations=new s_(this._client),this.speech=new sm(this._client)}}sy.Transcriptions=sg,sy.Translations=s_,sy.Speech=sm;class sw extends tQ{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",tj,{query:e,...t})}cancel(e,t){return this._client.post(tZ`/batches/${e}/cancel`,t)}}class sb extends tQ{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(tZ`/assistants/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(tZ`/assistants/${e}`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",tj,{query:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(tZ`/assistants/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sv extends tQ{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sx extends tQ{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sS extends tQ{constructor(){super(...arguments),this.sessions=new sv(this._client),this.transcriptionSessions=new sx(this._client)}}sS.Sessions=sv,sS.TranscriptionSessions=sx;class s$ extends tQ{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(tZ`/chatkit/sessions/${e}/cancel`,{...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class sA extends tQ{retrieve(e,t){return this._client.get(tZ`/chatkit/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",tN,{query:e,...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(tZ`/chatkit/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},s){return this._client.getAPIList(tZ`/chatkit/threads/${e}/items`,tN,{query:t,...s,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},s?.headers])})}}class sO extends tQ{constructor(){super(...arguments),this.sessions=new s$(this._client),this.threads=new sA(this._client)}}sO.Sessions=s$,sO.Threads=sA;class sk extends tQ{create(e,t,s){return this._client.post(tZ`/threads/${e}/messages`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(tZ`/threads/${n}/messages/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(tZ`/threads/${n}/messages/${e}`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(tZ`/threads/${e}/messages`,tj,{query:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{thread_id:n}=t;return this._client.delete(tZ`/threads/${n}/messages/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class sI extends tQ{retrieve(e,t,s){let{thread_id:n,run_id:r,...i}=t;return this._client.get(tZ`/threads/${n}/runs/${r}/steps/${e}`,{query:i,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t,s){let{thread_id:n,...r}=t;return this._client.getAPIList(tZ`/threads/${n}/runs/${e}/steps`,tj,{query:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}let sR=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;e.s(["readEnv",0,sR],39357),e.s([],92146);class sE extends t7{constructor(){super(...arguments),B.add(this),U.set(this,[]),q.set(this,{}),F.set(this,{}),X.set(this,void 0),H.set(this,void 0),J.set(this,void 0),K.set(this,void 0),V.set(this,void 0),z.set(this,void 0),Q.set(this,void 0),G.set(this,void 0),Y.set(this,void 0)}[(U=new WeakMap,q=new WeakMap,F=new WeakMap,X=new WeakMap,H=new WeakMap,J=new WeakMap,K=new WeakMap,V=new WeakMap,z=new WeakMap,Q=new WeakMap,G=new WeakMap,Y=new WeakMap,B=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("event",s=>{let n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{for(let e of(s=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new W;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let s=t?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),this._connected();let n=t$.fromReadableStream(e,this.controller);for await(let e of n)eI(this,B,"m",Z).call(this,e);if(n.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}toReadableStream(){return new t$(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,s,n){let r=new W;return r._run(()=>r._runToolAssistantStream(e,t,s,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createToolAssistantStream(e,t,s,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));let i={...s,stream:!0},a=await e.submitToolOutputs(t,i,{...n,signal:this.controller.signal});for await(let e of(this._connected(),a))eI(this,B,"m",Z).call(this,e);if(a.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}static createThreadAssistantStream(e,t,s){let n=new W;return n._run(()=>n._threadAssistantStream(e,t,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}static createAssistantStream(e,t,s,n){let r=new W;return r._run(()=>r._runAssistantStream(e,t,s,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}currentEvent(){return eI(this,Q,"f")}currentRun(){return eI(this,G,"f")}currentMessageSnapshot(){return eI(this,X,"f")}currentRunStepSnapshot(){return eI(this,Y,"f")}async finalRunSteps(){return await this.done(),Object.values(eI(this,q,"f"))}async finalMessages(){return await this.done(),Object.values(eI(this,F,"f"))}async finalRun(){if(await this.done(),!eI(this,H,"f"))throw Error("Final run was not received.");return eI(this,H,"f")}async _createThreadAssistantStream(e,t,s){let n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort()));let r={...t,stream:!0},i=await e.createAndRun(r,{...s,signal:this.controller.signal});for await(let e of(this._connected(),i))eI(this,B,"m",Z).call(this,e);if(i.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}async _createAssistantStream(e,t,s,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));let i={...s,stream:!0},a=await e.create(t,i,{...n,signal:this.controller.signal});for await(let e of(this._connected(),a))eI(this,B,"m",Z).call(this,e);if(a.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}static accumulateDelta(e,t){for(let[s,n]of Object.entries(t)){if(!e.hasOwnProperty(s)){e[s]=n;continue}let t=e[s];if(null==t||"index"===s||"type"===s){e[s]=n;continue}if("string"==typeof t&&"string"==typeof n)t+=n;else if("number"==typeof t&&"number"==typeof n)t+=n;else if(e1(t)&&e1(n))t=this.accumulateDelta(t,n);else if(Array.isArray(t)&&Array.isArray(n)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...n);continue}for(let e of n){if(!e1(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let s=e.index;if(null==s)throw console.error(e),Error("Expected array delta entry to have an `index` property");if("number"!=typeof s)throw Error(`Expected array delta entry \`index\` property to be a number but got ${s}`);let n=t[s];null==n?t.push(e):t[s]=this.accumulateDelta(n,e)}continue}else throw Error(`Unhandled record type: ${s}, deltaValue: ${n}, accValue: ${t}`);e[s]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,s){return await this._createThreadAssistantStream(t,e,s)}async _runAssistantStream(e,t,s,n){return await this._createAssistantStream(t,e,s,n)}async _runToolAssistantStream(e,t,s,n){return await this._createToolAssistantStream(t,e,s,n)}}W=sE,Z=function(e){if(!this.ended)switch(ek(this,Q,e,"f"),eI(this,B,"m",en).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":eI(this,B,"m",eo).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":eI(this,B,"m",es).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":eI(this,B,"m",et).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},ee=function(){if(this.ended)throw new eC("stream has ended, this shouldn't happen");if(!eI(this,H,"f"))throw Error("Final run has not been received");return eI(this,H,"f")},et=function(e){let[t,s]=eI(this,B,"m",ei).call(this,e,eI(this,X,"f"));for(let e of(ek(this,X,t,"f"),eI(this,F,"f")[t.id]=t,s)){let s=t.content[e.index];s?.type=="text"&&this._emit("textCreated",s.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let s of e.data.delta.content){if("text"==s.type&&s.text){let e=s.text,n=t.content[s.index];if(n&&"text"==n.type)this._emit("textDelta",e,n.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(s.index!=eI(this,J,"f")){if(eI(this,K,"f"))switch(eI(this,K,"f").type){case"text":this._emit("textDone",eI(this,K,"f").text,eI(this,X,"f"));break;case"image_file":this._emit("imageFileDone",eI(this,K,"f").image_file,eI(this,X,"f"))}ek(this,J,s.index,"f")}ek(this,K,t.content[s.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==eI(this,J,"f")){let t=e.data.content[eI(this,J,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,eI(this,X,"f"));break;case"text":this._emit("textDone",t.text,eI(this,X,"f"))}}eI(this,X,"f")&&this._emit("messageDone",e.data),ek(this,X,void 0,"f")}},es=function(e){let t=eI(this,B,"m",er).call(this,e);switch(ek(this,Y,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let s=e.data.delta;if(s.step_details&&"tool_calls"==s.step_details.type&&s.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(let e of s.step_details.tool_calls)e.index==eI(this,V,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(eI(this,z,"f")&&this._emit("toolCallDone",eI(this,z,"f")),ek(this,V,e.index,"f"),ek(this,z,t.step_details.tool_calls[e.index],"f"),eI(this,z,"f")&&this._emit("toolCallCreated",eI(this,z,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":ek(this,Y,void 0,"f"),"tool_calls"==e.data.step_details.type&&eI(this,z,"f")&&(this._emit("toolCallDone",eI(this,z,"f")),ek(this,z,void 0,"f")),this._emit("runStepDone",e.data,t)}},en=function(e){eI(this,U,"f").push(e),this._emit("event",e)},er=function(e){switch(e.event){case"thread.run.step.created":return eI(this,q,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=eI(this,q,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let s=e.data;if(s.delta){let n=W.accumulateDelta(t,s.delta);eI(this,q,"f")[e.data.id]=n}return eI(this,q,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":eI(this,q,"f")[e.data.id]=e.data}if(eI(this,q,"f")[e.data.id])return eI(this,q,"f")[e.data.id];throw Error("No snapshot available")},ei=function(e,t){let s=[];switch(e.event){case"thread.message.created":return[e.data,s];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(let e of n.delta.content)if(e.index in t.content){let s=t.content[e.index];t.content[e.index]=eI(this,B,"m",ea).call(this,e,s)}else t.content[e.index]=e,s.push(e);return[t,s];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,s];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},ea=function(e,t){return W.accumulateDelta(t,e)},eo=function(e){switch(ek(this,G,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":ek(this,H,e.data,"f"),eI(this,z,"f")&&(this._emit("toolCallDone",eI(this,z,"f")),ek(this,z,void 0,"f"))}};class sP extends tQ{constructor(){super(...arguments),this.steps=new sI(this._client)}create(e,t,s){let{include:n,...r}=t;return this._client.post(tZ`/threads/${e}/runs`,{query:{include:n},body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(tZ`/threads/${n}/runs/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(tZ`/threads/${n}/runs/${e}`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(tZ`/threads/${e}/runs`,tj,{query:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{thread_id:n}=t;return this._client.post(tZ`/threads/${n}/runs/${e}/cancel`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(e,t,s){let n=await this.create(e,t,s);return await this.poll(n.id,{thread_id:e},s)}createAndStream(e,t,s){return sE.createAssistantStream(e,this._client.beta.threads.runs,t,s)}async poll(e,t,s){let n=sp([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:r,response:i}=await this.retrieve(e,t,{...s,headers:{...s?.headers,...n}}).withResponse();switch(r.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{let e=i.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await e8(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return r}}}stream(e,t,s){return sE.createAssistantStream(e,this._client.beta.threads.runs,t,s)}submitToolOutputs(e,t,s){let{thread_id:n,...r}=t;return this._client.post(tZ`/threads/${n}/runs/${e}/submit_tool_outputs`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,t,s){let n=await this.submitToolOutputs(e,t,s);return await this.poll(n.id,t,s)}submitToolOutputsStream(e,t,s){return sE.createToolAssistantStream(e,this._client.beta.threads.runs,t,s)}}sP.Steps=sI;class sC extends tQ{constructor(){super(...arguments),this.runs=new sP(this._client),this.messages=new sk(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(tZ`/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(tZ`/threads/${e}`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t){return this._client.delete(tZ`/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,t){let s=await this.createAndRun(e,t);return await this.runs.poll(s.id,{thread_id:s.thread_id},t)}createAndRunStream(e,t){return sE.createThreadAssistantStream(e,this._client.beta.threads,t)}}sC.Runs=sP,sC.Messages=sk;class sT extends tQ{constructor(){super(...arguments),this.realtime=new sS(this._client),this.chatkit=new sO(this._client),this.assistants=new sb(this._client),this.threads=new sC(this._client)}}sT.Realtime=sS,sT.ChatKit=sO,sT.Assistants=sb,sT.Threads=sC;class sj extends tQ{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class sN extends tQ{retrieve(e,t,s){let{container_id:n}=t;return this._client.get(tZ`/containers/${n}/files/${e}/content`,{...s,headers:sp([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class sM extends tQ{constructor(){super(...arguments),this.content=new sN(this._client)}create(e,t,s){return this._client.post(tZ`/containers/${e}/files`,tW({body:t,...s},this._client))}retrieve(e,t,s){let{container_id:n}=t;return this._client.get(tZ`/containers/${n}/files/${e}`,s)}list(e,t={},s){return this._client.getAPIList(tZ`/containers/${e}/files`,tj,{query:t,...s})}delete(e,t,s){let{container_id:n}=t;return this._client.delete(tZ`/containers/${n}/files/${e}`,{...s,headers:sp([{Accept:"*/*"},s?.headers])})}}sM.Content=sN;class sL extends tQ{constructor(){super(...arguments),this.files=new sM(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/containers/${e}`,{...t,headers:sp([{Accept:"*/*"},t?.headers])})}}sL.Files=sM;class sD extends tQ{create(e,t,s){let{include:n,...r}=t;return this._client.post(tZ`/conversations/${e}/items`,{query:{include:n},body:r,...s})}retrieve(e,t,s){let{conversation_id:n,...r}=t;return this._client.get(tZ`/conversations/${n}/items/${e}`,{query:r,...s})}list(e,t={},s){return this._client.getAPIList(tZ`/conversations/${e}/items`,tN,{query:t,...s})}delete(e,t,s){let{conversation_id:n}=t;return this._client.delete(tZ`/conversations/${n}/items/${e}`,s)}}class sB extends tQ{constructor(){super(...arguments),this.items=new sD(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/conversations/${e}`,t)}update(e,t,s){return this._client.post(tZ`/conversations/${e}`,{body:t,...s})}delete(e,t){return this._client.delete(tZ`/conversations/${e}`,t)}}sB.Items=sD;class sW extends tQ{create(e,t){let s=!!e.encoding_format,n=s?e.encoding_format:"base64";s&&tx(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);let r=this._client.post("/embeddings",{body:{...e,encoding_format:n},...t});return s?r:(tx(this._client).debug("embeddings/decoding base64 embeddings from base64"),r._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{let t=e.embedding;e.embedding=(e=>{if("u">typeof Buffer){let t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}{let t=atob(e),s=t.length,n=new Uint8Array(s);for(let e=0;e<s;e++)n[e]=t.charCodeAt(e);return Array.from(new Float32Array(n.buffer))}})(t)}),e)))}}class sU extends tQ{retrieve(e,t,s){let{eval_id:n,run_id:r}=t;return this._client.get(tZ`/evals/${n}/runs/${r}/output_items/${e}`,s)}list(e,t,s){let{eval_id:n,...r}=t;return this._client.getAPIList(tZ`/evals/${n}/runs/${e}/output_items`,tj,{query:r,...s})}}class sq extends tQ{constructor(){super(...arguments),this.outputItems=new sU(this._client)}create(e,t,s){return this._client.post(tZ`/evals/${e}/runs`,{body:t,...s})}retrieve(e,t,s){let{eval_id:n}=t;return this._client.get(tZ`/evals/${n}/runs/${e}`,s)}list(e,t={},s){return this._client.getAPIList(tZ`/evals/${e}/runs`,tj,{query:t,...s})}delete(e,t,s){let{eval_id:n}=t;return this._client.delete(tZ`/evals/${n}/runs/${e}`,s)}cancel(e,t,s){let{eval_id:n}=t;return this._client.post(tZ`/evals/${n}/runs/${e}`,s)}}sq.OutputItems=sU;class sF extends tQ{constructor(){super(...arguments),this.runs=new sq(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/evals/${e}`,t)}update(e,t,s){return this._client.post(tZ`/evals/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/evals",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/evals/${e}`,t)}}sF.Runs=sq;class sX extends tQ{create(e,t){return this._client.post("/files",tU({body:e,...t},this._client))}retrieve(e,t){return this._client.get(tZ`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/files/${e}`,t)}content(e,t){return this._client.get(tZ`/files/${e}/content`,{...t,headers:sp([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:s=18e5}={}){let n=new Set(["processed","error","deleted"]),r=Date.now(),i=await this.retrieve(e);for(;!i.status||!n.has(i.status);)if(await e8(t),i=await this.retrieve(e),Date.now()-r>s)throw new eM({message:`Giving up on waiting for file ${e} to finish processing after ${s} milliseconds.`});return i}}class sH extends tQ{}class sJ extends tQ{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t})}}class sK extends tQ{constructor(){super(...arguments),this.graders=new sJ(this._client)}}sK.Graders=sJ;class sV extends tQ{create(e,t,s){return this._client.getAPIList(tZ`/fine_tuning/checkpoints/${e}/permissions`,tT,{body:t,method:"post",...s})}retrieve(e,t={},s){return this._client.get(tZ`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...s})}delete(e,t,s){let{fine_tuned_model_checkpoint:n}=t;return this._client.delete(tZ`/fine_tuning/checkpoints/${n}/permissions/${e}`,s)}}class sz extends tQ{constructor(){super(...arguments),this.permissions=new sV(this._client)}}sz.Permissions=sV;class sQ extends tQ{list(e,t={},s){return this._client.getAPIList(tZ`/fine_tuning/jobs/${e}/checkpoints`,tj,{query:t,...s})}}class sG extends tQ{constructor(){super(...arguments),this.checkpoints=new sQ(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList("/fine_tuning/jobs",tj,{query:e,...t})}cancel(e,t){return this._client.post(tZ`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},s){return this._client.getAPIList(tZ`/fine_tuning/jobs/${e}/events`,tj,{query:t,...s})}pause(e,t){return this._client.post(tZ`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(tZ`/fine_tuning/jobs/${e}/resume`,t)}}sG.Checkpoints=sQ;class sY extends tQ{constructor(){super(...arguments),this.methods=new sH(this._client),this.jobs=new sG(this._client),this.checkpoints=new sz(this._client),this.alpha=new sK(this._client)}}sY.Methods=sH,sY.Jobs=sG,sY.Checkpoints=sz,sY.Alpha=sK;class sZ extends tQ{}class s0 extends tQ{constructor(){super(...arguments),this.graderModels=new sZ(this._client)}}s0.GraderModels=sZ;class s1 extends tQ{createVariation(e,t){return this._client.post("/images/variations",tU({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",tU({body:e,...t,stream:e.stream??!1},this._client))}generate(e,t){return this._client.post("/images/generations",{body:e,...t,stream:e.stream??!1})}}class s2 extends tQ{retrieve(e,t){return this._client.get(tZ`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",tT,e)}delete(e,t){return this._client.delete(tZ`/models/${e}`,t)}}class s3 extends tQ{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class s8 extends tQ{accept(e,t,s){return this._client.post(tZ`/realtime/calls/${e}/accept`,{body:t,...s,headers:sp([{Accept:"*/*"},s?.headers])})}hangup(e,t){return this._client.post(tZ`/realtime/calls/${e}/hangup`,{...t,headers:sp([{Accept:"*/*"},t?.headers])})}refer(e,t,s){return this._client.post(tZ`/realtime/calls/${e}/refer`,{body:t,...s,headers:sp([{Accept:"*/*"},s?.headers])})}reject(e,t={},s){return this._client.post(tZ`/realtime/calls/${e}/reject`,{body:t,...s,headers:sp([{Accept:"*/*"},s?.headers])})}}class s4 extends tQ{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class s6 extends tQ{constructor(){super(...arguments),this.clientSecrets=new s4(this._client),this.calls=new s8(this._client)}}function s5(e,t){let s=e.output.map(e=>{if("function_call"===e.type)return{...e,parsed_arguments:function(e,t){var s,n;let r=(s=e.tools??[],n=t.name,s.find(e=>"function"===e.type&&e.name===n));return{...t,...t,parsed_arguments:r?.$brand==="auto-parseable-tool"?r.$parseRaw(t.arguments):r?.strict?JSON.parse(t.arguments):null}}(t,e)};if("message"===e.type){let s=e.content.map(e=>{var s,n;return"output_text"===e.type?{...e,parsed:(s=t,n=e.text,s.text?.format?.type!=="json_schema"?null:"$parseRaw"in s.text?.format?(s.text?.format).$parseRaw(n):JSON.parse(n))}:e});return{...e,content:s}}return e}),n=Object.assign({},e,{output:s});return Object.getOwnPropertyDescriptor(e,"output_text")||s9(n),Object.defineProperty(n,"output_parsed",{enumerable:!0,get(){for(let e of n.output)if("message"===e.type){for(let t of e.content)if("output_text"===t.type&&null!==t.parsed)return t.parsed}return null}}),n}function s9(e){let t=[];for(let s of e.output)if("message"===s.type)for(let e of s.content)"output_text"===e.type&&t.push(e.text);e.output_text=t.join("")}s6.ClientSecrets=s4,s6.Calls=s8;class s7 extends t7{constructor(e){super(),el.add(this),ec.set(this,void 0),eh.set(this,void 0),eu.set(this,void 0),ek(this,ec,e,"f")}static createResponse(e,t,s){let n=new s7(t);return n._run(()=>n._createOrRetrieveResponse(e,t,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}async _createOrRetrieveResponse(e,t,s){let n,r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),eI(this,el,"m",ed).call(this);let i=null;for await(let r of("response_id"in t?(n=await e.responses.retrieve(t.response_id,{stream:!0},{...s,signal:this.controller.signal,stream:!0}),i=t.starting_after??null):n=await e.responses.create({...t,stream:!0},{...s,signal:this.controller.signal}),this._connected(),n))eI(this,el,"m",ef).call(this,r,i);if(n.controller.signal?.aborted)throw new ej;return eI(this,el,"m",ep).call(this)}[(ec=new WeakMap,eh=new WeakMap,eu=new WeakMap,el=new WeakSet,ed=function(){this.ended||ek(this,eh,void 0,"f")},ef=function(e,t){if(this.ended)return;let s=(e,s)=>{(null==t||s.sequence_number>t)&&this._emit(e,s)},n=eI(this,el,"m",em).call(this,e);switch(s("event",e),e.type){case"response.output_text.delta":{let t=n.output[e.output_index];if(!t)throw new eC(`missing output at index ${e.output_index}`);if("message"===t.type){let n=t.content[e.content_index];if(!n)throw new eC(`missing content at index ${e.content_index}`);if("output_text"!==n.type)throw new eC(`expected content to be 'output_text', got ${n.type}`);s("response.output_text.delta",{...e,snapshot:n.text})}break}case"response.function_call_arguments.delta":{let t=n.output[e.output_index];if(!t)throw new eC(`missing output at index ${e.output_index}`);"function_call"===t.type&&s("response.function_call_arguments.delta",{...e,snapshot:t.arguments});break}default:s(e.type,e)}},ep=function(){if(this.ended)throw new eC("stream has ended, this shouldn't happen");let e=eI(this,eh,"f");if(!e)throw new eC("request ended without sending any events");ek(this,eh,void 0,"f");let t=function(e,t){var s;return t&&(s=t,t2(s.text?.format))?s5(e,t):{...e,output_parsed:null,output:e.output.map(e=>"function_call"===e.type?{...e,parsed_arguments:null}:"message"===e.type?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}}(e,eI(this,ec,"f"));return ek(this,eu,t,"f"),t},em=function(e){let t=eI(this,eh,"f");if(!t){if("response.created"!==e.type)throw new eC(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return ek(this,eh,e.response,"f")}switch(e.type){case"response.output_item.added":t.output.push(e.item);break;case"response.content_part.added":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);let n=s.type,r=e.part;"message"===n&&"reasoning_text"!==r.type?s.content.push(r):"reasoning"===n&&"reasoning_text"===r.type&&(s.content||(s.content=[]),s.content.push(r));break}case"response.output_text.delta":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);if("message"===s.type){let t=s.content[e.content_index];if(!t)throw new eC(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new eC(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case"response.function_call_arguments.delta":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);"function_call"===s.type&&(s.arguments+=e.delta);break}case"response.reasoning_text.delta":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);if("reasoning"===s.type){let t=s.content?.[e.content_index];if(!t)throw new eC(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new eC(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":ek(this,eh,e.response,"f")}return t},Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("event",s=>{let n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{for(let e of(s=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=eI(this,eu,"f");if(!e)throw new eC("stream ended without producing a ChatCompletion");return e}}class ne extends tQ{list(e,t={},s){return this._client.getAPIList(tZ`/responses/${e}/input_items`,tj,{query:t,...s})}}class nt extends tQ{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class ns extends tQ{constructor(){super(...arguments),this.inputItems=new ne(this._client),this.inputTokens=new nt(this._client)}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&s9(e),e))}retrieve(e,t={},s){return this._client.get(tZ`/responses/${e}`,{query:t,...s,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&s9(e),e))}delete(e,t){return this._client.delete(tZ`/responses/${e}`,{...t,headers:sp([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>s5(t,e))}stream(e,t){return s7.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(tZ`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}ns.InputItems=ne,ns.InputTokens=nt;class nn extends tQ{retrieve(e,t){return this._client.get(tZ`/skills/${e}/content`,{...t,headers:sp([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class nr extends tQ{retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(tZ`/skills/${n}/versions/${e}/content`,{...s,headers:sp([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class ni extends tQ{constructor(){super(...arguments),this.content=new nr(this._client)}create(e,t={},s){return this._client.post(tZ`/skills/${e}/versions`,tW({body:t,...s},this._client))}retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(tZ`/skills/${n}/versions/${e}`,s)}list(e,t={},s){return this._client.getAPIList(tZ`/skills/${e}/versions`,tj,{query:t,...s})}delete(e,t,s){let{skill_id:n}=t;return this._client.delete(tZ`/skills/${n}/versions/${e}`,s)}}ni.Content=nr;class na extends tQ{constructor(){super(...arguments),this.content=new nn(this._client),this.versions=new ni(this._client)}create(e={},t){return this._client.post("/skills",tW({body:e,...t},this._client))}retrieve(e,t){return this._client.get(tZ`/skills/${e}`,t)}update(e,t,s){return this._client.post(tZ`/skills/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/skills",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/skills/${e}`,t)}}na.Content=nn,na.Versions=ni;class no extends tQ{create(e,t,s){return this._client.post(tZ`/uploads/${e}/parts`,tU({body:t,...s},this._client))}}class nl extends tQ{constructor(){super(...arguments),this.parts=new no(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(tZ`/uploads/${e}/cancel`,t)}complete(e,t,s){return this._client.post(tZ`/uploads/${e}/complete`,{body:t,...s})}}nl.Parts=no;let nc=async e=>{let t=await Promise.allSettled(e),s=t.filter(e=>"rejected"===e.status);if(s.length){for(let e of s)console.error(e.reason);throw Error(`${s.length} promise(s) failed - see the above errors`)}let n=[];for(let e of t)"fulfilled"===e.status&&n.push(e.value);return n};class nh extends tQ{create(e,t,s){return this._client.post(tZ`/vector_stores/${e}/file_batches`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(tZ`/vector_stores/${n}/file_batches/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{vector_store_id:n}=t;return this._client.post(tZ`/vector_stores/${n}/file_batches/${e}/cancel`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(e,t,s){let n=await this.create(e,t);return await this.poll(e,n.id,s)}listFiles(e,t,s){let{vector_store_id:n,...r}=t;return this._client.getAPIList(tZ`/vector_stores/${n}/file_batches/${e}/files`,tj,{query:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async poll(e,t,s){let n=sp([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:r,response:i}=await this.retrieve(t,{vector_store_id:e},{...s,headers:n}).withResponse();switch(r.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{let e=i.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await e8(a);break;case"failed":case"cancelled":case"completed":return r}}}async uploadAndPoll(e,{files:t,fileIds:s=[]},n){if(null==t||0==t.length)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let r=Math.min(n?.maxConcurrency??5,t.length),i=this._client,a=t.values(),o=[...s];async function l(e){for(let t of e){let e=await i.files.create({file:t,purpose:"assistants"},n);o.push(e.id)}}let c=Array(r).fill(a).map(l);return await nc(c),await this.createAndPoll(e,{file_ids:o})}}class nu extends tQ{create(e,t,s){return this._client.post(tZ`/vector_stores/${e}/files`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(tZ`/vector_stores/${n}/files/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{vector_store_id:n,...r}=t;return this._client.post(tZ`/vector_stores/${n}/files/${e}`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(tZ`/vector_stores/${e}/files`,tj,{query:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{vector_store_id:n}=t;return this._client.delete(tZ`/vector_stores/${n}/files/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(e,t,s){let n=await this.create(e,t,s);return await this.poll(e,n.id,s)}async poll(e,t,s){let n=sp([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){let r=await this.retrieve(t,{vector_store_id:e},{...s,headers:n}).withResponse(),i=r.data;switch(i.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{let e=r.response.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await e8(a);break;case"failed":case"completed":return i}}}async upload(e,t,s){let n=await this._client.files.create({file:t,purpose:"assistants"},s);return this.create(e,{file_id:n.id},s)}async uploadAndPoll(e,t,s){let n=await this.upload(e,t,s);return await this.poll(e,n.id,s)}content(e,t,s){let{vector_store_id:n}=t;return this._client.getAPIList(tZ`/vector_stores/${n}/files/${e}/content`,tT,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class nd extends tQ{constructor(){super(...arguments),this.files=new nu(this._client),this.fileBatches=new nh(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(tZ`/vector_stores/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(tZ`/vector_stores/${e}`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",tj,{query:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(tZ`/vector_stores/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,s){return this._client.getAPIList(tZ`/vector_stores/${e}/search`,tT,{body:t,method:"post",...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}nd.Files=nu,nd.FileBatches=nh;class nf extends tQ{create(e,t){return this._client.post("/videos",tW({body:e,...t},this._client))}retrieve(e,t){return this._client.get(tZ`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",tN,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/videos/${e}`,t)}downloadContent(e,t={},s){return this._client.get(tZ`/videos/${e}/content`,{query:t,...s,headers:sp([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}remix(e,t,s){return this._client.post(tZ`/videos/${e}/remix`,tW({body:t,...s},this._client))}}class np extends tQ{constructor(){super(...arguments),eg.add(this)}async unwrap(e,t,s=this._client.webhookSecret,n=300){return await this.verifySignature(e,t,s,n),JSON.parse(e)}async verifySignature(e,t,s=this._client.webhookSecret,n=300){if("u"<typeof crypto||"function"!=typeof crypto.subtle.importKey||"function"!=typeof crypto.subtle.verify)throw Error("Webhook signature verification is only supported when the `crypto` global is defined");eI(this,eg,"m",e_).call(this,s);let r=sp([t]).values,i=eI(this,eg,"m",ey).call(this,r,"webhook-signature"),a=eI(this,eg,"m",ey).call(this,r,"webhook-timestamp"),o=eI(this,eg,"m",ey).call(this,r,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new eK("Invalid webhook timestamp format");let c=Math.floor(Date.now()/1e3);if(c-l>n)throw new eK("Webhook timestamp is too old");if(l>c+n)throw new eK("Webhook timestamp is too new");let h=i.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),u=s.startsWith("whsec_")?Buffer.from(s.replace("whsec_",""),"base64"):Buffer.from(s,"utf-8"),d=o?`${o}.${a}.${e}`:`${a}.${e}`,f=await crypto.subtle.importKey("raw",u,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let e of h)try{let t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",f,t,new TextEncoder().encode(d)))return}catch{continue}throw new eK("The given webhook signature does not match the expected signature")}}eg=new WeakSet,e_=function(e){if("string"!=typeof e||0===e.length)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},ey=function(e,t){if(!e)throw Error("Headers are required");let s=e.get(t);if(null==s)throw Error(`Missing required header: ${t}`);return s},e.i(98546);class nm{constructor({baseURL:e=sR("OPENAI_BASE_URL"),apiKey:t=sR("OPENAI_API_KEY"),organization:s=sR("OPENAI_ORG_ID")??null,project:n=sR("OPENAI_PROJECT_ID")??null,webhookSecret:r=sR("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(ew.add(this),ev.set(this,void 0),this.completions=new sj(this),this.chat=new sd(this),this.embeddings=new sW(this),this.files=new sX(this),this.images=new s1(this),this.audio=new sy(this),this.moderations=new s3(this),this.models=new s2(this),this.fineTuning=new sY(this),this.graders=new s0(this),this.vectorStores=new nd(this),this.webhooks=new np(this),this.beta=new sT(this),this.batches=new sw(this),this.uploads=new nl(this),this.responses=new ns(this),this.realtime=new s6(this),this.conversations=new sB(this),this.evals=new sF(this),this.containers=new sL(this),this.skills=new na(this),this.videos=new nf(this),void 0===t)throw new eC("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:t,organization:s,project:n,webhookSecret:r,...i,baseURL:e||"https://api.openai.com/v1"};a.dangerouslyAllowBrowser,this.baseURL=a.baseURL,this.timeout=a.timeout??eb.DEFAULT_TIMEOUT,this.logger=a.logger??console;const o="warn";this.logLevel=o,this.logLevel=t_(a.logLevel,"ClientOptions.logLevel",this)??t_(sR("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??o,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??function(){if("u">typeof fetch)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),ek(this,ev,ts,"f"),this._options=a,this.apiKey="string"==typeof t?t:"Missing Key",this.organization=s,this.project=n,this.webhookSecret=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return sp([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e,t={}){let s,n=e,r=function(e=tu){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let s=e.charset||tu.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=tn;if(void 0!==e.format){if(!ta(ti,e.format))throw TypeError("Unknown format option provided.");n=e.format}let r=ti[n],i=tu.filter;if(("function"==typeof e.filter||eQ(e.filter))&&(i=e.filter),t=e.arrayFormat&&e.arrayFormat in tc?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":tu.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let a=void 0===e.allowDots?!0==!!e.encodeDotInKeys||tu.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:tu.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:tu.allowEmptyArrays,arrayFormat:t,charset:s,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:tu.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?tu.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:tu.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:tu.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:tu.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:tu.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:tu.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:tu.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:tu.strictNullHandling}}(t);"function"==typeof r.filter?n=(0,r.filter)("",n):eQ(r.filter)&&(s=r.filter);let i=[];if("object"!=typeof n||null===n)return"";let a=tc[r.arrayFormat],o="comma"===a&&r.commaRoundTrip;s||(s=Object.keys(n)),r.sort&&s.sort(r.sort);let l=new WeakMap;for(let e=0;e<s.length;++e){let t=s[e];r.skipNulls&&null===n[t]||th(i,function e(t,s,n,r,i,a,o,l,c,h,u,d,f,p,m,g,_,y){var w,b;let v,x=t,S=y,$=0,A=!1;for(;void 0!==(S=S.get(td))&&!A;){let e=S.get(t);if($+=1,void 0!==e)if(e===$)throw RangeError("Cyclic object value");else A=!0;void 0===S.get(td)&&($=0)}if("function"==typeof h?x=h(s,x):x instanceof Date?x=f?.(x):"comma"===n&&eQ(x)&&(x=tl(x,function(e){return e instanceof Date?f?.(e):e})),null===x){if(a)return c&&!g?c(s,tu.encoder,_,"key",p):s;x=""}if("string"==typeof(w=x)||"number"==typeof w||"boolean"==typeof w||"symbol"==typeof w||"bigint"==typeof w||(b=x)&&"object"==typeof b&&b.constructor&&b.constructor.isBuffer&&b.constructor.isBuffer(b)){if(c){let e=g?s:c(s,tu.encoder,_,"key",p);return[m?.(e)+"="+m?.(c(x,tu.encoder,_,"value",p))]}return[m?.(s)+"="+m?.(String(x))]}let O=[];if(void 0===x)return O;if("comma"===n&&eQ(x))g&&c&&(x=tl(x,c)),v=[{value:x.length>0?x.join(",")||null:void 0}];else if(eQ(h))v=h;else{let e=Object.keys(x);v=u?e.sort(u):e}let k=l?String(s).replace(/\./g,"%2E"):String(s),I=r&&eQ(x)&&1===x.length?k+"[]":k;if(i&&eQ(x)&&0===x.length)return I+"[]";for(let s=0;s<v.length;++s){let w=v[s],b="object"==typeof w&&void 0!==w.value?w.value:x[w];if(o&&null===b)continue;let S=d&&l?w.replace(/\./g,"%2E"):w,A=eQ(x)?"function"==typeof n?n(I,S):I:I+(d?"."+S:"["+S+"]");y.set(t,$);let k=new WeakMap;k.set(td,y),th(O,e(b,A,n,r,i,a,o,l,"comma"===n&&g&&eQ(x)?null:c,h,u,d,f,p,m,g,_,k))}return O}(n[t],t,a,o,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let c=i.join(r.delimiter),h=!0===r.addQueryPrefix?"?":"";return r.charsetSentinel&&("iso-8859-1"===r.charset?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),c.length>0?h+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${e4}`}defaultIdempotencyKey(){return`stainless-node-retry-${eR()}`}makeStatusError(e,t,s,n){return eT.generate(e,t,s,n)}async _callApiKey(){let e,t=this._options.apiKey;if("function"!=typeof t)return!1;try{e=await t()}catch(e){if(e instanceof eC)throw e;throw new eC(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof e||!e)throw new eC(`Expected 'apiKey' function argument to return a string but it returned ${e}`);return this.apiKey=e,!0}buildURL(e,t,s){let n=!eI(this,ew,"m",ex).call(this)&&s||this.baseURL,r=new URL(ez(e)?e:n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return eZ(i)||(t={...i,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(r.search=this.stringifyQuery(t)),r.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:s}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,s){return this.request(Promise.resolve(s).then(s=>({method:e,path:t,...s})))}request(e,t=null){return new tE(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,s){let n=await e,r=n.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(n);let{req:i,url:a,timeout:o}=await this.buildRequest(n,{retryCount:r-t});await this.prepareRequest(i,{url:a,options:n});let l="log_"+(0x1000000*Math.random()|0).toString(16).padStart(6,"0"),c=void 0===s?"":`, retryOf: ${s}`,h=Date.now();if(tx(this).debug(`[${l}] sending request`,tS({retryOfRequestLogID:s,method:n.method,url:a,options:n,headers:i.headers})),n.signal?.aborted)throw new ej;let u=new AbortController,d=await this.fetchWithTimeout(a,i,o,u).catch(eP),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new ej;let r=eE(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return tx(this).info(`[${l}] connection ${r?"timed out":"failed"} - ${e}`),tx(this).debug(`[${l}] connection ${r?"timed out":"failed"} (${e})`,tS({retryOfRequestLogID:s,url:a,durationMs:f-h,message:d.message})),this.retryRequest(n,t,s??l);if(tx(this).info(`[${l}] connection ${r?"timed out":"failed"} - error; no more retries left`),tx(this).debug(`[${l}] connection ${r?"timed out":"failed"} (error; no more retries left)`,tS({retryOfRequestLogID:s,url:a,durationMs:f-h,message:d.message})),r)throw new eM;throw new eN({cause:d})}let p=[...d.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${l}${c}${p}] ${i.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${f-h}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await tt(d.body),tx(this).info(`${m} - ${e}`),tx(this).debug(`[${l}] response error (${e})`,tS({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:f-h})),this.retryRequest(n,t,s??l,d.headers)}let r=e?"error; no more retries left":"error; not retryable";tx(this).info(`${m} - ${r}`);let i=await d.text().catch(e=>eP(e).message),a=e3(i),o=a?void 0:i;throw tx(this).debug(`[${l}] response error (${r})`,tS({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,message:o,durationMs:Date.now()-h})),this.makeStatusError(d.status,a,o,d.headers)}return tx(this).info(m),tx(this).debug(`[${l}] response start`,tS({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:f-h})),{response:d,options:n,controller:u,requestLogID:l,retryOfRequestLogID:s,startTime:h}}getAPIList(e,t,s){return this.requestAPIList(t,s&&"then"in s?s.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...s})}requestAPIList(e,t){return new tC(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,s,n){let{signal:r,method:i,...a}=t||{},o=this._makeAbort(n);r&&r.addEventListener("abort",o,{once:!0});let l=setTimeout(o,s),c=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,h={signal:n.signal,...c?{duplex:"half"}:{},method:"GET",...a};i&&(h.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,h)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||409===e.status||429===e.status||!!(e.status>=500))}async retryRequest(e,t,s,n){let r,i=n?.get("retry-after-ms");if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n?.get("retry-after");if(a&&!r){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(!(r&&0<=r&&r<6e4)){let s=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,s)}return await e8(r),this.makeRequest(e,t-1,s)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){let s={...e},{method:n,path:r,query:i,defaultBaseURL:a}=s,o=this.buildURL(r,i,a);"timeout"in s&&e2("timeout",s.timeout),s.timeout=s.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:s}),h=await this.buildHeaders({options:e,method:n,bodyHeaders:l,retryCount:t});return{req:{method:n,headers:h,...s.signal&&{signal:s.signal},...globalThis.ReadableStream&&c instanceof globalThis.ReadableStream&&{duplex:"half"},...c&&{body:c},...this.fetchOptions??{},...s.fetchOptions??{}},url:o,timeout:s.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:s,retryCount:n}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);let i=sp([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...eS??(eS=(()=>{let e="u">typeof Deno&&null!=Deno.build?"deno":"u">typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":e5(Deno.build.os),"X-Stainless-Arch":e6(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("u">typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":e5(globalThis.process.platform??"unknown"),"X-Stainless-Arch":e6(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("u"<typeof navigator||!navigator)return null;for(let{key:e,pattern:t}of[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let s=t.exec(navigator.userAgent);if(s){let t=s[1]||0,n=s[2]||0,r=s[3]||0;return{browser:e,version:`${t}.${n}.${r}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}})()),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,s,e.headers]);return this.validateHeaders(i),i.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let s=sp([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&s.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:e7(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===s.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:eI(this,ev,"f").call(this,{body:e,headers:s})}}eb=nm,ev=new WeakMap,ew=new WeakSet,ex=function(){return"https://api.openai.com/v1"!==this.baseURL},nm.OpenAI=eb,nm.DEFAULT_TIMEOUT=6e5,nm.OpenAIError=eC,nm.APIError=eT,nm.APIConnectionError=eN,nm.APIConnectionTimeoutError=eM,nm.APIUserAbortError=ej,nm.NotFoundError=eW,nm.ConflictError=eU,nm.RateLimitError=eF,nm.BadRequestError=eL,nm.AuthenticationError=eD,nm.InternalServerError=eX,nm.PermissionDeniedError=eB,nm.UnprocessableEntityError=eq,nm.InvalidWebhookSignatureError=eK,nm.toFile=tV,nm.Completions=sj,nm.Chat=sd,nm.Embeddings=sW,nm.Files=sX,nm.Images=s1,nm.Audio=sy,nm.Moderations=s3,nm.Models=s2,nm.FineTuning=sY,nm.Graders=s0,nm.VectorStores=nd,nm.Webhooks=np,nm.Beta=sT,nm.Batches=sw,nm.Uploads=nl,nm.Responses=ns,nm.Realtime=s6,nm.Conversations=sB,nm.Evals=sF,nm.Containers=sL,nm.Skills=na,nm.Videos=nf,e.s(["OpenAI",()=>nm],88045)},89228,e=>{"use strict";var t=e.i(88045);e.i(55623),e.i(33189),e.i(98437),e.i(94601),e.i(73730),e.i(85),e.i(92146),e.i(86641),e.i(39357),t.OpenAI,e.s([],89228)}];
|
|
8
|
+
${so(e)}`);return{...o,id:a,type:i,function:{...h,name:c,arguments:l}}})}}:{...i,message:{...c,content:a,role:h,refusal:t.refusal??null},finish_reason:s,index:n,logprobs:r}}),created:i,model:a,object:"chat.completion",...o?{system_fingerprint:o}:{}},t&&t4(t)?t8(s,t):{...s,choices:s.choices.map(e=>(t6(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(e,eI(this,I,"f"))},L=function(){let e=eI(this,I,"f")?.response_format;return t2(e)?e:null},D=function(e){var t,s,n,r;let i=eI(this,E,"f"),{choices:a,...o}=e;for(let{delta:a,finish_reason:l,index:c,logprobs:h=null,...u}of(i?Object.assign(i,o):i=ek(this,E,{...o,choices:[]},"f"),e.choices)){let e=i.choices[c];if(e||(e=i.choices[c]={finish_reason:l,index:c,message:{},logprobs:h,...u}),h)if(e.logprobs){let{content:n,refusal:r,...i}=h;sl(i),Object.assign(e.logprobs,i),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),r&&((s=e.logprobs).refusal??(s.refusal=[]),e.logprobs.refusal.push(...r))}else e.logprobs=Object.assign({},h);if(l&&(e.finish_reason=l,eI(this,I,"f")&&t4(eI(this,I,"f")))){if("length"===l)throw new eH;if("content_filter"===l)throw new eJ}if(Object.assign(e,u),!a)continue;let{content:o,refusal:d,function_call:f,role:p,tool_calls:m,...g}=a;if(sl(g),Object.assign(e.message,g),d&&(e.message.refusal=(e.message.refusal||"")+d),p&&(e.message.role=p),f&&(e.message.function_call?(f.name&&(e.message.function_call.name=f.name),f.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=f.arguments)):e.message.function_call=f),o&&(e.message.content=(e.message.content||"")+o,!e.message.refusal&&eI(this,k,"m",L).call(this)&&(e.message.parsed=si(e.message.content))),m)for(let{index:t,id:s,type:n,function:i,...a}of(e.message.tool_calls||(e.message.tool_calls=[]),m)){let o=(r=e.message.tool_calls)[t]??(r[t]={});Object.assign(o,a),s&&(o.id=s),n&&(o.type=n),i&&(o.function??(o.function={name:i.name??"",arguments:""})),i?.name&&(o.function.name=i.name),i?.arguments&&(o.function.arguments+=i.arguments,function(e,t){if(!e||!("tools"in e)||!e.tools)return!1;let s=e.tools?.find(e=>t1(e)&&e.function?.name===t.function.name);return t1(s)&&(t3(s)||s?.function.strict||!1)}(eI(this,I,"f"),o)&&(o.function.parsed_arguments=si(o.function.arguments)))}}return i},Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("chunk",s=>{let n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{for(let e of(s=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new tS(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function so(e){return JSON.stringify(e)}function sl(e){}function sc(e){}class sh extends sa{static fromReadableStream(e){let t=new sh(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,s){let n=new sh(t),r={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,r)),n}}class su extends tQ{constructor(){super(...arguments),this.messages=new t0(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(tZ`/chat/completions/${e}`,t)}update(e,t,s){return this._client.post(tZ`/chat/completions/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/chat/completions",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/chat/completions/${e}`,t)}parse(e,t){for(let t of e.tools??[]){if("function"!==t.type)throw new eC(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new eC(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}return this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(t=>t8(t,e))}runTools(e,t){return e.stream?sh.runTools(this._client,e,t):st.runTools(this._client,e,t)}stream(e,t){return sa.createChatCompletion(this._client,e,t)}}su.Messages=t0;class sd extends tQ{constructor(){super(...arguments),this.completions=new su(this._client)}}sd.Completions=su,e.s([],98546);let sf=Symbol("brand.privateNullableHeaders"),sp=e=>{let t=new Headers,s=new Set;for(let n of e){let e=new Set;for(let[r,i]of function*(e){let t;if(!e)return;if(sf in e){let{values:t,nulls:s}=e;for(let e of(yield*t.entries(),s))yield[e,null];return}let s=!1;for(let n of(e instanceof Headers?t=e.entries():eG(e)?t=e:(s=!0,t=Object.entries(e??{})),t)){let e=n[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=eG(n[1])?n[1]:[n[1]],r=!1;for(let n of t)void 0!==n&&(s&&!r&&(r=!0,yield[e,null]),yield[e,n])}}(n)){let n=r.toLowerCase();e.has(n)||(t.delete(r),e.add(n)),null===i?(t.delete(r),s.add(n)):(t.append(r,i),s.delete(n))}}return{[sf]:!0,values:t,nulls:s}};e.s(["buildHeaders",0,sp],73730);class sm extends tQ{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:sp([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class sg extends tQ{create(e,t){return this._client.post("/audio/transcriptions",tU({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class s_ extends tQ{create(e,t){return this._client.post("/audio/translations",tU({body:e,...t,__metadata:{model:e.model}},this._client))}}class sy extends tQ{constructor(){super(...arguments),this.transcriptions=new sg(this._client),this.translations=new s_(this._client),this.speech=new sm(this._client)}}sy.Transcriptions=sg,sy.Translations=s_,sy.Speech=sm;class sw extends tQ{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",tj,{query:e,...t})}cancel(e,t){return this._client.post(tZ`/batches/${e}/cancel`,t)}}class sb extends tQ{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(tZ`/assistants/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(tZ`/assistants/${e}`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",tj,{query:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(tZ`/assistants/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sv extends tQ{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sx extends tQ{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class s$ extends tQ{constructor(){super(...arguments),this.sessions=new sv(this._client),this.transcriptionSessions=new sx(this._client)}}s$.Sessions=sv,s$.TranscriptionSessions=sx;class sS extends tQ{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(tZ`/chatkit/sessions/${e}/cancel`,{...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class sA extends tQ{retrieve(e,t){return this._client.get(tZ`/chatkit/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",tN,{query:e,...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(tZ`/chatkit/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},s){return this._client.getAPIList(tZ`/chatkit/threads/${e}/items`,tN,{query:t,...s,headers:sp([{"OpenAI-Beta":"chatkit_beta=v1"},s?.headers])})}}class sO extends tQ{constructor(){super(...arguments),this.sessions=new sS(this._client),this.threads=new sA(this._client)}}sO.Sessions=sS,sO.Threads=sA;class sk extends tQ{create(e,t,s){return this._client.post(tZ`/threads/${e}/messages`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(tZ`/threads/${n}/messages/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(tZ`/threads/${n}/messages/${e}`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(tZ`/threads/${e}/messages`,tj,{query:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{thread_id:n}=t;return this._client.delete(tZ`/threads/${n}/messages/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class sI extends tQ{retrieve(e,t,s){let{thread_id:n,run_id:r,...i}=t;return this._client.get(tZ`/threads/${n}/runs/${r}/steps/${e}`,{query:i,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t,s){let{thread_id:n,...r}=t;return this._client.getAPIList(tZ`/threads/${n}/runs/${e}/steps`,tj,{query:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}let sR=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;e.s(["readEnv",0,sR],39357),e.s([],92146);class sE extends t7{constructor(){super(...arguments),B.add(this),U.set(this,[]),q.set(this,{}),F.set(this,{}),X.set(this,void 0),H.set(this,void 0),J.set(this,void 0),K.set(this,void 0),V.set(this,void 0),z.set(this,void 0),Q.set(this,void 0),G.set(this,void 0),Y.set(this,void 0)}[(U=new WeakMap,q=new WeakMap,F=new WeakMap,X=new WeakMap,H=new WeakMap,J=new WeakMap,K=new WeakMap,V=new WeakMap,z=new WeakMap,Q=new WeakMap,G=new WeakMap,Y=new WeakMap,B=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("event",s=>{let n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{for(let e of(s=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new W;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let s=t?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),this._connected();let n=tS.fromReadableStream(e,this.controller);for await(let e of n)eI(this,B,"m",Z).call(this,e);if(n.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}toReadableStream(){return new tS(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,s,n){let r=new W;return r._run(()=>r._runToolAssistantStream(e,t,s,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createToolAssistantStream(e,t,s,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));let i={...s,stream:!0},a=await e.submitToolOutputs(t,i,{...n,signal:this.controller.signal});for await(let e of(this._connected(),a))eI(this,B,"m",Z).call(this,e);if(a.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}static createThreadAssistantStream(e,t,s){let n=new W;return n._run(()=>n._threadAssistantStream(e,t,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}static createAssistantStream(e,t,s,n){let r=new W;return r._run(()=>r._runAssistantStream(e,t,s,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}currentEvent(){return eI(this,Q,"f")}currentRun(){return eI(this,G,"f")}currentMessageSnapshot(){return eI(this,X,"f")}currentRunStepSnapshot(){return eI(this,Y,"f")}async finalRunSteps(){return await this.done(),Object.values(eI(this,q,"f"))}async finalMessages(){return await this.done(),Object.values(eI(this,F,"f"))}async finalRun(){if(await this.done(),!eI(this,H,"f"))throw Error("Final run was not received.");return eI(this,H,"f")}async _createThreadAssistantStream(e,t,s){let n=s?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort()));let r={...t,stream:!0},i=await e.createAndRun(r,{...s,signal:this.controller.signal});for await(let e of(this._connected(),i))eI(this,B,"m",Z).call(this,e);if(i.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}async _createAssistantStream(e,t,s,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));let i={...s,stream:!0},a=await e.create(t,i,{...n,signal:this.controller.signal});for await(let e of(this._connected(),a))eI(this,B,"m",Z).call(this,e);if(a.controller.signal?.aborted)throw new ej;return this._addRun(eI(this,B,"m",ee).call(this))}static accumulateDelta(e,t){for(let[s,n]of Object.entries(t)){if(!e.hasOwnProperty(s)){e[s]=n;continue}let t=e[s];if(null==t||"index"===s||"type"===s){e[s]=n;continue}if("string"==typeof t&&"string"==typeof n)t+=n;else if("number"==typeof t&&"number"==typeof n)t+=n;else if(e1(t)&&e1(n))t=this.accumulateDelta(t,n);else if(Array.isArray(t)&&Array.isArray(n)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...n);continue}for(let e of n){if(!e1(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let s=e.index;if(null==s)throw console.error(e),Error("Expected array delta entry to have an `index` property");if("number"!=typeof s)throw Error(`Expected array delta entry \`index\` property to be a number but got ${s}`);let n=t[s];null==n?t.push(e):t[s]=this.accumulateDelta(n,e)}continue}else throw Error(`Unhandled record type: ${s}, deltaValue: ${n}, accValue: ${t}`);e[s]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,s){return await this._createThreadAssistantStream(t,e,s)}async _runAssistantStream(e,t,s,n){return await this._createAssistantStream(t,e,s,n)}async _runToolAssistantStream(e,t,s,n){return await this._createToolAssistantStream(t,e,s,n)}}W=sE,Z=function(e){if(!this.ended)switch(ek(this,Q,e,"f"),eI(this,B,"m",en).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":eI(this,B,"m",eo).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":eI(this,B,"m",es).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":eI(this,B,"m",et).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},ee=function(){if(this.ended)throw new eC("stream has ended, this shouldn't happen");if(!eI(this,H,"f"))throw Error("Final run has not been received");return eI(this,H,"f")},et=function(e){let[t,s]=eI(this,B,"m",ei).call(this,e,eI(this,X,"f"));for(let e of(ek(this,X,t,"f"),eI(this,F,"f")[t.id]=t,s)){let s=t.content[e.index];s?.type=="text"&&this._emit("textCreated",s.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let s of e.data.delta.content){if("text"==s.type&&s.text){let e=s.text,n=t.content[s.index];if(n&&"text"==n.type)this._emit("textDelta",e,n.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(s.index!=eI(this,J,"f")){if(eI(this,K,"f"))switch(eI(this,K,"f").type){case"text":this._emit("textDone",eI(this,K,"f").text,eI(this,X,"f"));break;case"image_file":this._emit("imageFileDone",eI(this,K,"f").image_file,eI(this,X,"f"))}ek(this,J,s.index,"f")}ek(this,K,t.content[s.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==eI(this,J,"f")){let t=e.data.content[eI(this,J,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,eI(this,X,"f"));break;case"text":this._emit("textDone",t.text,eI(this,X,"f"))}}eI(this,X,"f")&&this._emit("messageDone",e.data),ek(this,X,void 0,"f")}},es=function(e){let t=eI(this,B,"m",er).call(this,e);switch(ek(this,Y,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let s=e.data.delta;if(s.step_details&&"tool_calls"==s.step_details.type&&s.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(let e of s.step_details.tool_calls)e.index==eI(this,V,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(eI(this,z,"f")&&this._emit("toolCallDone",eI(this,z,"f")),ek(this,V,e.index,"f"),ek(this,z,t.step_details.tool_calls[e.index],"f"),eI(this,z,"f")&&this._emit("toolCallCreated",eI(this,z,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":ek(this,Y,void 0,"f"),"tool_calls"==e.data.step_details.type&&eI(this,z,"f")&&(this._emit("toolCallDone",eI(this,z,"f")),ek(this,z,void 0,"f")),this._emit("runStepDone",e.data,t)}},en=function(e){eI(this,U,"f").push(e),this._emit("event",e)},er=function(e){switch(e.event){case"thread.run.step.created":return eI(this,q,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=eI(this,q,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let s=e.data;if(s.delta){let n=W.accumulateDelta(t,s.delta);eI(this,q,"f")[e.data.id]=n}return eI(this,q,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":eI(this,q,"f")[e.data.id]=e.data}if(eI(this,q,"f")[e.data.id])return eI(this,q,"f")[e.data.id];throw Error("No snapshot available")},ei=function(e,t){let s=[];switch(e.event){case"thread.message.created":return[e.data,s];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(let e of n.delta.content)if(e.index in t.content){let s=t.content[e.index];t.content[e.index]=eI(this,B,"m",ea).call(this,e,s)}else t.content[e.index]=e,s.push(e);return[t,s];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,s];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},ea=function(e,t){return W.accumulateDelta(t,e)},eo=function(e){switch(ek(this,G,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":ek(this,H,e.data,"f"),eI(this,z,"f")&&(this._emit("toolCallDone",eI(this,z,"f")),ek(this,z,void 0,"f"))}};class sP extends tQ{constructor(){super(...arguments),this.steps=new sI(this._client)}create(e,t,s){let{include:n,...r}=t;return this._client.post(tZ`/threads/${e}/runs`,{query:{include:n},body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(tZ`/threads/${n}/runs/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(tZ`/threads/${n}/runs/${e}`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(tZ`/threads/${e}/runs`,tj,{query:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{thread_id:n}=t;return this._client.post(tZ`/threads/${n}/runs/${e}/cancel`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(e,t,s){let n=await this.create(e,t,s);return await this.poll(n.id,{thread_id:e},s)}createAndStream(e,t,s){return sE.createAssistantStream(e,this._client.beta.threads.runs,t,s)}async poll(e,t,s){let n=sp([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:r,response:i}=await this.retrieve(e,t,{...s,headers:{...s?.headers,...n}}).withResponse();switch(r.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{let e=i.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await e8(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return r}}}stream(e,t,s){return sE.createAssistantStream(e,this._client.beta.threads.runs,t,s)}submitToolOutputs(e,t,s){let{thread_id:n,...r}=t;return this._client.post(tZ`/threads/${n}/runs/${e}/submit_tool_outputs`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,t,s){let n=await this.submitToolOutputs(e,t,s);return await this.poll(n.id,t,s)}submitToolOutputsStream(e,t,s){return sE.createToolAssistantStream(e,this._client.beta.threads.runs,t,s)}}sP.Steps=sI;class sC extends tQ{constructor(){super(...arguments),this.runs=new sP(this._client),this.messages=new sk(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(tZ`/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(tZ`/threads/${e}`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t){return this._client.delete(tZ`/threads/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,t){let s=await this.createAndRun(e,t);return await this.runs.poll(s.id,{thread_id:s.thread_id},t)}createAndRunStream(e,t){return sE.createThreadAssistantStream(e,this._client.beta.threads,t)}}sC.Runs=sP,sC.Messages=sk;class sT extends tQ{constructor(){super(...arguments),this.realtime=new s$(this._client),this.chatkit=new sO(this._client),this.assistants=new sb(this._client),this.threads=new sC(this._client)}}sT.Realtime=s$,sT.ChatKit=sO,sT.Assistants=sb,sT.Threads=sC;class sj extends tQ{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class sN extends tQ{retrieve(e,t,s){let{container_id:n}=t;return this._client.get(tZ`/containers/${n}/files/${e}/content`,{...s,headers:sp([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class sM extends tQ{constructor(){super(...arguments),this.content=new sN(this._client)}create(e,t,s){return this._client.post(tZ`/containers/${e}/files`,tW({body:t,...s},this._client))}retrieve(e,t,s){let{container_id:n}=t;return this._client.get(tZ`/containers/${n}/files/${e}`,s)}list(e,t={},s){return this._client.getAPIList(tZ`/containers/${e}/files`,tj,{query:t,...s})}delete(e,t,s){let{container_id:n}=t;return this._client.delete(tZ`/containers/${n}/files/${e}`,{...s,headers:sp([{Accept:"*/*"},s?.headers])})}}sM.Content=sN;class sL extends tQ{constructor(){super(...arguments),this.files=new sM(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/containers/${e}`,{...t,headers:sp([{Accept:"*/*"},t?.headers])})}}sL.Files=sM;class sD extends tQ{create(e,t,s){let{include:n,...r}=t;return this._client.post(tZ`/conversations/${e}/items`,{query:{include:n},body:r,...s})}retrieve(e,t,s){let{conversation_id:n,...r}=t;return this._client.get(tZ`/conversations/${n}/items/${e}`,{query:r,...s})}list(e,t={},s){return this._client.getAPIList(tZ`/conversations/${e}/items`,tN,{query:t,...s})}delete(e,t,s){let{conversation_id:n}=t;return this._client.delete(tZ`/conversations/${n}/items/${e}`,s)}}class sB extends tQ{constructor(){super(...arguments),this.items=new sD(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/conversations/${e}`,t)}update(e,t,s){return this._client.post(tZ`/conversations/${e}`,{body:t,...s})}delete(e,t){return this._client.delete(tZ`/conversations/${e}`,t)}}sB.Items=sD;class sW extends tQ{create(e,t){let s=!!e.encoding_format,n=s?e.encoding_format:"base64";s&&tx(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);let r=this._client.post("/embeddings",{body:{...e,encoding_format:n},...t});return s?r:(tx(this._client).debug("embeddings/decoding base64 embeddings from base64"),r._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{let t=e.embedding;e.embedding=(e=>{if("u">typeof Buffer){let t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}{let t=atob(e),s=t.length,n=new Uint8Array(s);for(let e=0;e<s;e++)n[e]=t.charCodeAt(e);return Array.from(new Float32Array(n.buffer))}})(t)}),e)))}}class sU extends tQ{retrieve(e,t,s){let{eval_id:n,run_id:r}=t;return this._client.get(tZ`/evals/${n}/runs/${r}/output_items/${e}`,s)}list(e,t,s){let{eval_id:n,...r}=t;return this._client.getAPIList(tZ`/evals/${n}/runs/${e}/output_items`,tj,{query:r,...s})}}class sq extends tQ{constructor(){super(...arguments),this.outputItems=new sU(this._client)}create(e,t,s){return this._client.post(tZ`/evals/${e}/runs`,{body:t,...s})}retrieve(e,t,s){let{eval_id:n}=t;return this._client.get(tZ`/evals/${n}/runs/${e}`,s)}list(e,t={},s){return this._client.getAPIList(tZ`/evals/${e}/runs`,tj,{query:t,...s})}delete(e,t,s){let{eval_id:n}=t;return this._client.delete(tZ`/evals/${n}/runs/${e}`,s)}cancel(e,t,s){let{eval_id:n}=t;return this._client.post(tZ`/evals/${n}/runs/${e}`,s)}}sq.OutputItems=sU;class sF extends tQ{constructor(){super(...arguments),this.runs=new sq(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/evals/${e}`,t)}update(e,t,s){return this._client.post(tZ`/evals/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/evals",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/evals/${e}`,t)}}sF.Runs=sq;class sX extends tQ{create(e,t){return this._client.post("/files",tU({body:e,...t},this._client))}retrieve(e,t){return this._client.get(tZ`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/files/${e}`,t)}content(e,t){return this._client.get(tZ`/files/${e}/content`,{...t,headers:sp([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:s=18e5}={}){let n=new Set(["processed","error","deleted"]),r=Date.now(),i=await this.retrieve(e);for(;!i.status||!n.has(i.status);)if(await e8(t),i=await this.retrieve(e),Date.now()-r>s)throw new eM({message:`Giving up on waiting for file ${e} to finish processing after ${s} milliseconds.`});return i}}class sH extends tQ{}class sJ extends tQ{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t})}}class sK extends tQ{constructor(){super(...arguments),this.graders=new sJ(this._client)}}sK.Graders=sJ;class sV extends tQ{create(e,t,s){return this._client.getAPIList(tZ`/fine_tuning/checkpoints/${e}/permissions`,tT,{body:t,method:"post",...s})}retrieve(e,t={},s){return this._client.get(tZ`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...s})}list(e,t={},s){return this._client.getAPIList(tZ`/fine_tuning/checkpoints/${e}/permissions`,tN,{query:t,...s})}delete(e,t,s){let{fine_tuned_model_checkpoint:n}=t;return this._client.delete(tZ`/fine_tuning/checkpoints/${n}/permissions/${e}`,s)}}class sz extends tQ{constructor(){super(...arguments),this.permissions=new sV(this._client)}}sz.Permissions=sV;class sQ extends tQ{list(e,t={},s){return this._client.getAPIList(tZ`/fine_tuning/jobs/${e}/checkpoints`,tj,{query:t,...s})}}class sG extends tQ{constructor(){super(...arguments),this.checkpoints=new sQ(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(tZ`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList("/fine_tuning/jobs",tj,{query:e,...t})}cancel(e,t){return this._client.post(tZ`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},s){return this._client.getAPIList(tZ`/fine_tuning/jobs/${e}/events`,tj,{query:t,...s})}pause(e,t){return this._client.post(tZ`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(tZ`/fine_tuning/jobs/${e}/resume`,t)}}sG.Checkpoints=sQ;class sY extends tQ{constructor(){super(...arguments),this.methods=new sH(this._client),this.jobs=new sG(this._client),this.checkpoints=new sz(this._client),this.alpha=new sK(this._client)}}sY.Methods=sH,sY.Jobs=sG,sY.Checkpoints=sz,sY.Alpha=sK;class sZ extends tQ{}class s0 extends tQ{constructor(){super(...arguments),this.graderModels=new sZ(this._client)}}s0.GraderModels=sZ;class s1 extends tQ{createVariation(e,t){return this._client.post("/images/variations",tU({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",tU({body:e,...t,stream:e.stream??!1},this._client))}generate(e,t){return this._client.post("/images/generations",{body:e,...t,stream:e.stream??!1})}}class s2 extends tQ{retrieve(e,t){return this._client.get(tZ`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",tT,e)}delete(e,t){return this._client.delete(tZ`/models/${e}`,t)}}class s3 extends tQ{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class s8 extends tQ{accept(e,t,s){return this._client.post(tZ`/realtime/calls/${e}/accept`,{body:t,...s,headers:sp([{Accept:"*/*"},s?.headers])})}hangup(e,t){return this._client.post(tZ`/realtime/calls/${e}/hangup`,{...t,headers:sp([{Accept:"*/*"},t?.headers])})}refer(e,t,s){return this._client.post(tZ`/realtime/calls/${e}/refer`,{body:t,...s,headers:sp([{Accept:"*/*"},s?.headers])})}reject(e,t={},s){return this._client.post(tZ`/realtime/calls/${e}/reject`,{body:t,...s,headers:sp([{Accept:"*/*"},s?.headers])})}}class s4 extends tQ{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class s6 extends tQ{constructor(){super(...arguments),this.clientSecrets=new s4(this._client),this.calls=new s8(this._client)}}function s5(e,t){let s=e.output.map(e=>{if("function_call"===e.type)return{...e,parsed_arguments:function(e,t){var s,n;let r=(s=e.tools??[],n=t.name,s.find(e=>"function"===e.type&&e.name===n));return{...t,...t,parsed_arguments:r?.$brand==="auto-parseable-tool"?r.$parseRaw(t.arguments):r?.strict?JSON.parse(t.arguments):null}}(t,e)};if("message"===e.type){let s=e.content.map(e=>{var s,n;return"output_text"===e.type?{...e,parsed:(s=t,n=e.text,s.text?.format?.type!=="json_schema"?null:"$parseRaw"in s.text?.format?(s.text?.format).$parseRaw(n):JSON.parse(n))}:e});return{...e,content:s}}return e}),n=Object.assign({},e,{output:s});return Object.getOwnPropertyDescriptor(e,"output_text")||s9(n),Object.defineProperty(n,"output_parsed",{enumerable:!0,get(){for(let e of n.output)if("message"===e.type){for(let t of e.content)if("output_text"===t.type&&null!==t.parsed)return t.parsed}return null}}),n}function s9(e){let t=[];for(let s of e.output)if("message"===s.type)for(let e of s.content)"output_text"===e.type&&t.push(e.text);e.output_text=t.join("")}s6.ClientSecrets=s4,s6.Calls=s8;class s7 extends t7{constructor(e){super(),el.add(this),ec.set(this,void 0),eh.set(this,void 0),eu.set(this,void 0),ek(this,ec,e,"f")}static createResponse(e,t,s){let n=new s7(t);return n._run(()=>n._createOrRetrieveResponse(e,t,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),n}async _createOrRetrieveResponse(e,t,s){let n,r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),eI(this,el,"m",ed).call(this);let i=null;for await(let r of("response_id"in t?(n=await e.responses.retrieve(t.response_id,{stream:!0},{...s,signal:this.controller.signal,stream:!0}),i=t.starting_after??null):n=await e.responses.create({...t,stream:!0},{...s,signal:this.controller.signal}),this._connected(),n))eI(this,el,"m",ef).call(this,r,i);if(n.controller.signal?.aborted)throw new ej;return eI(this,el,"m",ep).call(this)}[(ec=new WeakMap,eh=new WeakMap,eu=new WeakMap,el=new WeakSet,ed=function(){this.ended||ek(this,eh,void 0,"f")},ef=function(e,t){if(this.ended)return;let s=(e,s)=>{(null==t||s.sequence_number>t)&&this._emit(e,s)},n=eI(this,el,"m",em).call(this,e);switch(s("event",e),e.type){case"response.output_text.delta":{let t=n.output[e.output_index];if(!t)throw new eC(`missing output at index ${e.output_index}`);if("message"===t.type){let n=t.content[e.content_index];if(!n)throw new eC(`missing content at index ${e.content_index}`);if("output_text"!==n.type)throw new eC(`expected content to be 'output_text', got ${n.type}`);s("response.output_text.delta",{...e,snapshot:n.text})}break}case"response.function_call_arguments.delta":{let t=n.output[e.output_index];if(!t)throw new eC(`missing output at index ${e.output_index}`);"function_call"===t.type&&s("response.function_call_arguments.delta",{...e,snapshot:t.arguments});break}default:s(e.type,e)}},ep=function(){if(this.ended)throw new eC("stream has ended, this shouldn't happen");let e=eI(this,eh,"f");if(!e)throw new eC("request ended without sending any events");ek(this,eh,void 0,"f");let t=function(e,t){var s;return t&&(s=t,t2(s.text?.format))?s5(e,t):{...e,output_parsed:null,output:e.output.map(e=>"function_call"===e.type?{...e,parsed_arguments:null}:"message"===e.type?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}}(e,eI(this,ec,"f"));return ek(this,eu,t,"f"),t},em=function(e){let t=eI(this,eh,"f");if(!t){if("response.created"!==e.type)throw new eC(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return ek(this,eh,e.response,"f")}switch(e.type){case"response.output_item.added":t.output.push(e.item);break;case"response.content_part.added":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);let n=s.type,r=e.part;"message"===n&&"reasoning_text"!==r.type?s.content.push(r):"reasoning"===n&&"reasoning_text"===r.type&&(s.content||(s.content=[]),s.content.push(r));break}case"response.output_text.delta":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);if("message"===s.type){let t=s.content[e.content_index];if(!t)throw new eC(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new eC(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case"response.function_call_arguments.delta":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);"function_call"===s.type&&(s.arguments+=e.delta);break}case"response.reasoning_text.delta":{let s=t.output[e.output_index];if(!s)throw new eC(`missing output at index ${e.output_index}`);if("reasoning"===s.type){let t=s.content?.[e.content_index];if(!t)throw new eC(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new eC(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":ek(this,eh,e.response,"f")}return t},Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("event",s=>{let n=t.shift();n?n.resolve(s):e.push(s)}),this.on("end",()=>{for(let e of(s=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(s=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((e,s)=>t.push({resolve:e,reject:s})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=eI(this,eu,"f");if(!e)throw new eC("stream ended without producing a ChatCompletion");return e}}class ne extends tQ{list(e,t={},s){return this._client.getAPIList(tZ`/responses/${e}/input_items`,tj,{query:t,...s})}}class nt extends tQ{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class ns extends tQ{constructor(){super(...arguments),this.inputItems=new ne(this._client),this.inputTokens=new nt(this._client)}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&s9(e),e))}retrieve(e,t={},s){return this._client.get(tZ`/responses/${e}`,{query:t,...s,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&s9(e),e))}delete(e,t){return this._client.delete(tZ`/responses/${e}`,{...t,headers:sp([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>s5(t,e))}stream(e,t){return s7.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(tZ`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}ns.InputItems=ne,ns.InputTokens=nt;class nn extends tQ{retrieve(e,t){return this._client.get(tZ`/skills/${e}/content`,{...t,headers:sp([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class nr extends tQ{retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(tZ`/skills/${n}/versions/${e}/content`,{...s,headers:sp([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class ni extends tQ{constructor(){super(...arguments),this.content=new nr(this._client)}create(e,t={},s){return this._client.post(tZ`/skills/${e}/versions`,tW({body:t,...s},this._client))}retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(tZ`/skills/${n}/versions/${e}`,s)}list(e,t={},s){return this._client.getAPIList(tZ`/skills/${e}/versions`,tj,{query:t,...s})}delete(e,t,s){let{skill_id:n}=t;return this._client.delete(tZ`/skills/${n}/versions/${e}`,s)}}ni.Content=nr;class na extends tQ{constructor(){super(...arguments),this.content=new nn(this._client),this.versions=new ni(this._client)}create(e={},t){return this._client.post("/skills",tW({body:e,...t},this._client))}retrieve(e,t){return this._client.get(tZ`/skills/${e}`,t)}update(e,t,s){return this._client.post(tZ`/skills/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/skills",tj,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/skills/${e}`,t)}}na.Content=nn,na.Versions=ni;class no extends tQ{create(e,t,s){return this._client.post(tZ`/uploads/${e}/parts`,tU({body:t,...s},this._client))}}class nl extends tQ{constructor(){super(...arguments),this.parts=new no(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(tZ`/uploads/${e}/cancel`,t)}complete(e,t,s){return this._client.post(tZ`/uploads/${e}/complete`,{body:t,...s})}}nl.Parts=no;let nc=async e=>{let t=await Promise.allSettled(e),s=t.filter(e=>"rejected"===e.status);if(s.length){for(let e of s)console.error(e.reason);throw Error(`${s.length} promise(s) failed - see the above errors`)}let n=[];for(let e of t)"fulfilled"===e.status&&n.push(e.value);return n};class nh extends tQ{create(e,t,s){return this._client.post(tZ`/vector_stores/${e}/file_batches`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(tZ`/vector_stores/${n}/file_batches/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{vector_store_id:n}=t;return this._client.post(tZ`/vector_stores/${n}/file_batches/${e}/cancel`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(e,t,s){let n=await this.create(e,t);return await this.poll(e,n.id,s)}listFiles(e,t,s){let{vector_store_id:n,...r}=t;return this._client.getAPIList(tZ`/vector_stores/${n}/file_batches/${e}/files`,tj,{query:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async poll(e,t,s){let n=sp([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:r,response:i}=await this.retrieve(t,{vector_store_id:e},{...s,headers:n}).withResponse();switch(r.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{let e=i.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await e8(a);break;case"failed":case"cancelled":case"completed":return r}}}async uploadAndPoll(e,{files:t,fileIds:s=[]},n){if(null==t||0==t.length)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let r=Math.min(n?.maxConcurrency??5,t.length),i=this._client,a=t.values(),o=[...s];async function l(e){for(let t of e){let e=await i.files.create({file:t,purpose:"assistants"},n);o.push(e.id)}}let c=Array(r).fill(a).map(l);return await nc(c),await this.createAndPoll(e,{file_ids:o})}}class nu extends tQ{create(e,t,s){return this._client.post(tZ`/vector_stores/${e}/files`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(tZ`/vector_stores/${n}/files/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{vector_store_id:n,...r}=t;return this._client.post(tZ`/vector_stores/${n}/files/${e}`,{body:r,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(tZ`/vector_stores/${e}/files`,tj,{query:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{vector_store_id:n}=t;return this._client.delete(tZ`/vector_stores/${n}/files/${e}`,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(e,t,s){let n=await this.create(e,t,s);return await this.poll(e,n.id,s)}async poll(e,t,s){let n=sp([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){let r=await this.retrieve(t,{vector_store_id:e},{...s,headers:n}).withResponse(),i=r.data;switch(i.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{let e=r.response.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(a=t)}}await e8(a);break;case"failed":case"completed":return i}}}async upload(e,t,s){let n=await this._client.files.create({file:t,purpose:"assistants"},s);return this.create(e,{file_id:n.id},s)}async uploadAndPoll(e,t,s){let n=await this.upload(e,t,s);return await this.poll(e,n.id,s)}content(e,t,s){let{vector_store_id:n}=t;return this._client.getAPIList(tZ`/vector_stores/${n}/files/${e}/content`,tT,{...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class nd extends tQ{constructor(){super(...arguments),this.files=new nu(this._client),this.fileBatches=new nh(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(tZ`/vector_stores/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(tZ`/vector_stores/${e}`,{body:t,...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",tj,{query:e,...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(tZ`/vector_stores/${e}`,{...t,headers:sp([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,s){return this._client.getAPIList(tZ`/vector_stores/${e}/search`,tT,{body:t,method:"post",...s,headers:sp([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}nd.Files=nu,nd.FileBatches=nh;class nf extends tQ{create(e,t){return this._client.post("/videos",tU({body:e,...t},this._client))}retrieve(e,t){return this._client.get(tZ`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",tN,{query:e,...t})}delete(e,t){return this._client.delete(tZ`/videos/${e}`,t)}createCharacter(e,t){return this._client.post("/videos/characters",tU({body:e,...t},this._client))}downloadContent(e,t={},s){return this._client.get(tZ`/videos/${e}/content`,{query:t,...s,headers:sp([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}edit(e,t){return this._client.post("/videos/edits",tU({body:e,...t},this._client))}extend(e,t){return this._client.post("/videos/extensions",tU({body:e,...t},this._client))}getCharacter(e,t){return this._client.get(tZ`/videos/characters/${e}`,t)}remix(e,t,s){return this._client.post(tZ`/videos/${e}/remix`,tW({body:t,...s},this._client))}}class np extends tQ{constructor(){super(...arguments),eg.add(this)}async unwrap(e,t,s=this._client.webhookSecret,n=300){return await this.verifySignature(e,t,s,n),JSON.parse(e)}async verifySignature(e,t,s=this._client.webhookSecret,n=300){if("u"<typeof crypto||"function"!=typeof crypto.subtle.importKey||"function"!=typeof crypto.subtle.verify)throw Error("Webhook signature verification is only supported when the `crypto` global is defined");eI(this,eg,"m",e_).call(this,s);let r=sp([t]).values,i=eI(this,eg,"m",ey).call(this,r,"webhook-signature"),a=eI(this,eg,"m",ey).call(this,r,"webhook-timestamp"),o=eI(this,eg,"m",ey).call(this,r,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new eK("Invalid webhook timestamp format");let c=Math.floor(Date.now()/1e3);if(c-l>n)throw new eK("Webhook timestamp is too old");if(l>c+n)throw new eK("Webhook timestamp is too new");let h=i.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),u=s.startsWith("whsec_")?Buffer.from(s.replace("whsec_",""),"base64"):Buffer.from(s,"utf-8"),d=o?`${o}.${a}.${e}`:`${a}.${e}`,f=await crypto.subtle.importKey("raw",u,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let e of h)try{let t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",f,t,new TextEncoder().encode(d)))return}catch{continue}throw new eK("The given webhook signature does not match the expected signature")}}eg=new WeakSet,e_=function(e){if("string"!=typeof e||0===e.length)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},ey=function(e,t){if(!e)throw Error("Headers are required");let s=e.get(t);if(null==s)throw Error(`Missing required header: ${t}`);return s},e.i(98546);class nm{constructor({baseURL:e=sR("OPENAI_BASE_URL"),apiKey:t=sR("OPENAI_API_KEY"),organization:s=sR("OPENAI_ORG_ID")??null,project:n=sR("OPENAI_PROJECT_ID")??null,webhookSecret:r=sR("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(ew.add(this),ev.set(this,void 0),this.completions=new sj(this),this.chat=new sd(this),this.embeddings=new sW(this),this.files=new sX(this),this.images=new s1(this),this.audio=new sy(this),this.moderations=new s3(this),this.models=new s2(this),this.fineTuning=new sY(this),this.graders=new s0(this),this.vectorStores=new nd(this),this.webhooks=new np(this),this.beta=new sT(this),this.batches=new sw(this),this.uploads=new nl(this),this.responses=new ns(this),this.realtime=new s6(this),this.conversations=new sB(this),this.evals=new sF(this),this.containers=new sL(this),this.skills=new na(this),this.videos=new nf(this),void 0===t)throw new eC("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:t,organization:s,project:n,webhookSecret:r,...i,baseURL:e||"https://api.openai.com/v1"};a.dangerouslyAllowBrowser,this.baseURL=a.baseURL,this.timeout=a.timeout??eb.DEFAULT_TIMEOUT,this.logger=a.logger??console;const o="warn";this.logLevel=o,this.logLevel=t_(a.logLevel,"ClientOptions.logLevel",this)??t_(sR("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??o,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??function(){if("u">typeof fetch)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),ek(this,ev,ts,"f"),this._options=a,this.apiKey="string"==typeof t?t:"Missing Key",this.organization=s,this.project=n,this.webhookSecret=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return sp([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e,t={}){let s,n=e,r=function(e=tu){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let s=e.charset||tu.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=tn;if(void 0!==e.format){if(!ta(ti,e.format))throw TypeError("Unknown format option provided.");n=e.format}let r=ti[n],i=tu.filter;if(("function"==typeof e.filter||eQ(e.filter))&&(i=e.filter),t=e.arrayFormat&&e.arrayFormat in tc?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":tu.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let a=void 0===e.allowDots?!0==!!e.encodeDotInKeys||tu.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:tu.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:tu.allowEmptyArrays,arrayFormat:t,charset:s,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:tu.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?tu.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:tu.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:tu.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:tu.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:tu.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:tu.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:tu.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:tu.strictNullHandling}}(t);"function"==typeof r.filter?n=(0,r.filter)("",n):eQ(r.filter)&&(s=r.filter);let i=[];if("object"!=typeof n||null===n)return"";let a=tc[r.arrayFormat],o="comma"===a&&r.commaRoundTrip;s||(s=Object.keys(n)),r.sort&&s.sort(r.sort);let l=new WeakMap;for(let e=0;e<s.length;++e){let t=s[e];r.skipNulls&&null===n[t]||th(i,function e(t,s,n,r,i,a,o,l,c,h,u,d,f,p,m,g,_,y){var w,b;let v,x=t,$=y,S=0,A=!1;for(;void 0!==($=$.get(td))&&!A;){let e=$.get(t);if(S+=1,void 0!==e)if(e===S)throw RangeError("Cyclic object value");else A=!0;void 0===$.get(td)&&(S=0)}if("function"==typeof h?x=h(s,x):x instanceof Date?x=f?.(x):"comma"===n&&eQ(x)&&(x=tl(x,function(e){return e instanceof Date?f?.(e):e})),null===x){if(a)return c&&!g?c(s,tu.encoder,_,"key",p):s;x=""}if("string"==typeof(w=x)||"number"==typeof w||"boolean"==typeof w||"symbol"==typeof w||"bigint"==typeof w||(b=x)&&"object"==typeof b&&b.constructor&&b.constructor.isBuffer&&b.constructor.isBuffer(b)){if(c){let e=g?s:c(s,tu.encoder,_,"key",p);return[m?.(e)+"="+m?.(c(x,tu.encoder,_,"value",p))]}return[m?.(s)+"="+m?.(String(x))]}let O=[];if(void 0===x)return O;if("comma"===n&&eQ(x))g&&c&&(x=tl(x,c)),v=[{value:x.length>0?x.join(",")||null:void 0}];else if(eQ(h))v=h;else{let e=Object.keys(x);v=u?e.sort(u):e}let k=l?String(s).replace(/\./g,"%2E"):String(s),I=r&&eQ(x)&&1===x.length?k+"[]":k;if(i&&eQ(x)&&0===x.length)return I+"[]";for(let s=0;s<v.length;++s){let w=v[s],b="object"==typeof w&&void 0!==w.value?w.value:x[w];if(o&&null===b)continue;let $=d&&l?w.replace(/\./g,"%2E"):w,A=eQ(x)?"function"==typeof n?n(I,$):I:I+(d?"."+$:"["+$+"]");y.set(t,S);let k=new WeakMap;k.set(td,y),th(O,e(b,A,n,r,i,a,o,l,"comma"===n&&g&&eQ(x)?null:c,h,u,d,f,p,m,g,_,k))}return O}(n[t],t,a,o,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let c=i.join(r.delimiter),h=!0===r.addQueryPrefix?"?":"";return r.charsetSentinel&&("iso-8859-1"===r.charset?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),c.length>0?h+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${e4}`}defaultIdempotencyKey(){return`stainless-node-retry-${eR()}`}makeStatusError(e,t,s,n){return eT.generate(e,t,s,n)}async _callApiKey(){let e,t=this._options.apiKey;if("function"!=typeof t)return!1;try{e=await t()}catch(e){if(e instanceof eC)throw e;throw new eC(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof e||!e)throw new eC(`Expected 'apiKey' function argument to return a string but it returned ${e}`);return this.apiKey=e,!0}buildURL(e,t,s){let n=!eI(this,ew,"m",ex).call(this)&&s||this.baseURL,r=new URL(ez(e)?e:n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery(),a=Object.fromEntries(r.searchParams);return eZ(i)&&eZ(a)||(t={...a,...i,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(r.search=this.stringifyQuery(t)),r.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:s}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,s){return this.request(Promise.resolve(s).then(s=>({method:e,path:t,...s})))}request(e,t=null){return new tE(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,s){let n=await e,r=n.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(n);let{req:i,url:a,timeout:o}=await this.buildRequest(n,{retryCount:r-t});await this.prepareRequest(i,{url:a,options:n});let l="log_"+(0x1000000*Math.random()|0).toString(16).padStart(6,"0"),c=void 0===s?"":`, retryOf: ${s}`,h=Date.now();if(tx(this).debug(`[${l}] sending request`,t$({retryOfRequestLogID:s,method:n.method,url:a,options:n,headers:i.headers})),n.signal?.aborted)throw new ej;let u=new AbortController,d=await this.fetchWithTimeout(a,i,o,u).catch(eP),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new ej;let r=eE(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return tx(this).info(`[${l}] connection ${r?"timed out":"failed"} - ${e}`),tx(this).debug(`[${l}] connection ${r?"timed out":"failed"} (${e})`,t$({retryOfRequestLogID:s,url:a,durationMs:f-h,message:d.message})),this.retryRequest(n,t,s??l);if(tx(this).info(`[${l}] connection ${r?"timed out":"failed"} - error; no more retries left`),tx(this).debug(`[${l}] connection ${r?"timed out":"failed"} (error; no more retries left)`,t$({retryOfRequestLogID:s,url:a,durationMs:f-h,message:d.message})),r)throw new eM;throw new eN({cause:d})}let p=[...d.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${l}${c}${p}] ${i.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${f-h}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await tt(d.body),tx(this).info(`${m} - ${e}`),tx(this).debug(`[${l}] response error (${e})`,t$({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:f-h})),this.retryRequest(n,t,s??l,d.headers)}let r=e?"error; no more retries left":"error; not retryable";tx(this).info(`${m} - ${r}`);let i=await d.text().catch(e=>eP(e).message),a=e3(i),o=a?void 0:i;throw tx(this).debug(`[${l}] response error (${r})`,t$({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,message:o,durationMs:Date.now()-h})),this.makeStatusError(d.status,a,o,d.headers)}return tx(this).info(m),tx(this).debug(`[${l}] response start`,t$({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:f-h})),{response:d,options:n,controller:u,requestLogID:l,retryOfRequestLogID:s,startTime:h}}getAPIList(e,t,s){return this.requestAPIList(t,s&&"then"in s?s.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...s})}requestAPIList(e,t){return new tC(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,s,n){let{signal:r,method:i,...a}=t||{},o=this._makeAbort(n);r&&r.addEventListener("abort",o,{once:!0});let l=setTimeout(o,s),c=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,h={signal:n.signal,...c?{duplex:"half"}:{},method:"GET",...a};i&&(h.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,h)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||409===e.status||429===e.status||!!(e.status>=500))}async retryRequest(e,t,s,n){let r,i=n?.get("retry-after-ms");if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n?.get("retry-after");if(a&&!r){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(void 0===r){let s=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,s)}return await e8(r),this.makeRequest(e,t-1,s)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){let s={...e},{method:n,path:r,query:i,defaultBaseURL:a}=s,o=this.buildURL(r,i,a);"timeout"in s&&e2("timeout",s.timeout),s.timeout=s.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:s}),h=await this.buildHeaders({options:e,method:n,bodyHeaders:l,retryCount:t});return{req:{method:n,headers:h,...s.signal&&{signal:s.signal},...globalThis.ReadableStream&&c instanceof globalThis.ReadableStream&&{duplex:"half"},...c&&{body:c},...this.fetchOptions??{},...s.fetchOptions??{}},url:o,timeout:s.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:s,retryCount:n}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);let i=sp([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...e$??(e$=(()=>{let e="u">typeof Deno&&null!=Deno.build?"deno":"u">typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":e5(Deno.build.os),"X-Stainless-Arch":e6(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("u">typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":e5(globalThis.process.platform??"unknown"),"X-Stainless-Arch":e6(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("u"<typeof navigator||!navigator)return null;for(let{key:e,pattern:t}of[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let s=t.exec(navigator.userAgent);if(s){let t=s[1]||0,n=s[2]||0,r=s[3]||0;return{browser:e,version:`${t}.${n}.${r}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e4,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}})()),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,s,e.headers]);return this.validateHeaders(i),i.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let s=sp([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&s.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:e7(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===s.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:eI(this,ev,"f").call(this,{body:e,headers:s})}}eb=nm,ev=new WeakMap,ew=new WeakSet,ex=function(){return"https://api.openai.com/v1"!==this.baseURL},nm.OpenAI=eb,nm.DEFAULT_TIMEOUT=6e5,nm.OpenAIError=eC,nm.APIError=eT,nm.APIConnectionError=eN,nm.APIConnectionTimeoutError=eM,nm.APIUserAbortError=ej,nm.NotFoundError=eW,nm.ConflictError=eU,nm.RateLimitError=eF,nm.BadRequestError=eL,nm.AuthenticationError=eD,nm.InternalServerError=eX,nm.PermissionDeniedError=eB,nm.UnprocessableEntityError=eq,nm.InvalidWebhookSignatureError=eK,nm.toFile=tV,nm.Completions=sj,nm.Chat=sd,nm.Embeddings=sW,nm.Files=sX,nm.Images=s1,nm.Audio=sy,nm.Moderations=s3,nm.Models=s2,nm.FineTuning=sY,nm.Graders=s0,nm.VectorStores=nd,nm.Webhooks=np,nm.Beta=sT,nm.Batches=sw,nm.Uploads=nl,nm.Responses=ns,nm.Realtime=s6,nm.Conversations=sB,nm.Evals=sF,nm.Containers=sL,nm.Skills=na,nm.Videos=nf,e.s(["OpenAI",()=>nm],88045)},89228,e=>{"use strict";var t=e.i(88045);e.i(55623),e.i(33189),e.i(98437),e.i(94601),e.i(73730),e.i(85),e.i(92146),e.i(86641),e.i(39357),t.OpenAI,e.s([],89228)}];
|
|
9
9
|
|
|
10
10
|
//# sourceMappingURL=_fa49adfa._.js.map
|