@slycode/slycode 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/bridge/pty-handler.js +7 -1
  2. package/dist/bridge/pty-handler.js.map +1 -1
  3. package/dist/web/.next/BUILD_ID +1 -1
  4. package/dist/web/.next/build-manifest.json +2 -2
  5. package/dist/web/.next/server/app/_global-error.html +2 -2
  6. package/dist/web/.next/server/app/_global-error.rsc +1 -1
  7. package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/dist/web/.next/server/app/_not-found.html +1 -1
  13. package/dist/web/.next/server/app/_not-found.rsc +1 -1
  14. package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  15. package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  17. package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  20. package/dist/web/.next/server/chunks/[root-of-the-server]__198f01e0._.js +1 -1
  21. package/dist/web/.next/server/chunks/[root-of-the-server]__884d73e4._.js +1 -1
  22. package/dist/web/.next/server/chunks/[root-of-the-server]__aa814a86._.js +1 -1
  23. package/dist/web/.next/server/chunks/[root-of-the-server]__b90bbd70._.js +1 -1
  24. package/dist/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_ffc6c790.js +1 -1
  25. package/dist/web/.next/server/pages/404.html +1 -1
  26. package/dist/web/.next/server/pages/500.html +2 -2
  27. package/dist/web/src/app/api/git-status/route.ts +1 -0
  28. package/dist/web/src/app/api/projects/analyze/route.ts +1 -0
  29. package/dist/web/src/app/api/projects/route.ts +1 -0
  30. package/dist/web/src/app/api/transcribe/route.ts +1 -1
  31. package/dist/web/src/app/api/version-check/route.ts +1 -0
  32. package/lib/cli/doctor.d.ts.map +1 -1
  33. package/lib/cli/doctor.js +2 -1
  34. package/lib/cli/doctor.js.map +1 -1
  35. package/lib/cli/start.d.ts.map +1 -1
  36. package/lib/cli/start.js +1 -0
  37. package/lib/cli/start.js.map +1 -1
  38. package/lib/cli/stop.d.ts.map +1 -1
  39. package/lib/cli/stop.js +6 -4
  40. package/lib/cli/stop.js.map +1 -1
  41. package/lib/cli/update.d.ts.map +1 -1
  42. package/lib/cli/update.js +8 -5
  43. package/lib/cli/update.js.map +1 -1
  44. package/package.json +1 -1
  45. package/templates/kanban-seed.json +1 -1
  46. package/templates/tutorial-project/.agents/skills/checkpoint/SKILL.md +43 -0
  47. package/templates/tutorial-project/.agents/skills/context-priming/SKILL.md +152 -0
  48. package/templates/tutorial-project/.agents/skills/context-priming/references/area-index.md +101 -0
  49. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/claude-actions.md +120 -0
  50. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/messaging.md +177 -0
  51. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/scripts-deployment.md +138 -0
  52. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/skills.md +135 -0
  53. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/terminal-bridge.md +232 -0
  54. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/web-frontend.md +252 -0
  55. package/templates/tutorial-project/.agents/skills/context-priming/references/maintenance.md +128 -0
  56. package/templates/tutorial-project/.agents/skills/design/SKILL.md +141 -0
  57. package/templates/tutorial-project/.agents/skills/feature/SKILL.md +159 -0
  58. package/templates/tutorial-project/.agents/skills/implement/SKILL.md +132 -0
  59. package/templates/tutorial-project/.agents/skills/kanban/SKILL.md +264 -0
  60. package/templates/tutorial-project/.claude/skills/checkpoint/SKILL.md +43 -0
  61. package/templates/tutorial-project/.claude/skills/context-priming/SKILL.md +152 -0
  62. package/templates/tutorial-project/.claude/skills/context-priming/references/area-index.md +101 -0
  63. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/claude-actions.md +120 -0
  64. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/messaging.md +177 -0
  65. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/scripts-deployment.md +138 -0
  66. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/skills.md +135 -0
  67. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/terminal-bridge.md +232 -0
  68. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/web-frontend.md +252 -0
  69. package/templates/tutorial-project/.claude/skills/context-priming/references/maintenance.md +128 -0
  70. package/templates/tutorial-project/.claude/skills/design/SKILL.md +141 -0
  71. package/templates/tutorial-project/.claude/skills/feature/SKILL.md +159 -0
  72. package/templates/tutorial-project/.claude/skills/implement/SKILL.md +132 -0
  73. package/templates/tutorial-project/.claude/skills/kanban/SKILL.md +264 -0
  74. package/templates/tutorial-project/CLAUDE.md +16 -0
  75. package/templates/tutorial-project/documentation/designs/example_welcome_dashboard.md +38 -0
  76. package/templates/tutorial-project/documentation/events.json +1 -0
  77. package/templates/tutorial-project/documentation/features/example_in_card_deliverable_feature.md +31 -0
  78. package/templates/tutorial-project/documentation/kanban.json +385 -0
  79. /package/dist/web/.next/static/{cut-BpEHnH8_V_vl0UOOW → QUrfyJ4-tKEk_x5K_NIKK}/_buildManifest.js +0 -0
  80. /package/dist/web/.next/static/{cut-BpEHnH8_V_vl0UOOW → QUrfyJ4-tKEk_x5K_NIKK}/_clientMiddlewareManifest.json +0 -0
  81. /package/dist/web/.next/static/{cut-BpEHnH8_V_vl0UOOW → QUrfyJ4-tKEk_x5K_NIKK}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},7367,e=>{"use strict";var t=e.i(14747),r=e.i(22734);function a(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let e=process.cwd();return(console.warn("[paths] SLYCODE_HOME not set in production — falling back to cwd:",e),e.endsWith("/web")||e.endsWith("\\web"))?t.default.dirname(e):e}function n(){let e=a(),n=t.default.join(e,"node_modules","@slycode","slycode","dist");return r.default.existsSync(n)?n:e}e.s(["getPackageDir",()=>n,"getSlycodeRoot",()=>a])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},73178,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(46676),n=e.i(7367);function s(){return r.default.join((0,n.getSlycodeRoot)(),"store")}function i(e,n){let s=[],i="skill"===n?"skills":"agents",o=r.default.join(e,i);try{if(!t.default.existsSync(o))return s;for(let e of t.default.readdirSync(o,{withFileTypes:!0})){let l,d;if("skill"===n){if(!e.isDirectory()||(l=r.default.join(o,e.name,"SKILL.md"),d=r.default.join(i,e.name,"SKILL.md"),!t.default.existsSync(l)))continue}else{if(!e.isFile()||!e.name.endsWith(".md"))continue;l=r.default.join(o,e.name),d=r.default.join(i,e.name)}let u=t.default.readFileSync(l,"utf-8"),c=(0,a.parseFrontmatter)(u),p=c?.name||e.name.replace(/\.md$/,"");s.push({name:p,type:n,path:d,frontmatter:c,isValid:(0,a.validateFrontmatter)(c)})}}catch{}return s.sort((e,t)=>e.name.localeCompare(t.name))}function o(){let e=s();return{skills:i(e,"skill"),agents:i(e,"agent"),mcp:function(e){let a=r.default.join(e,"mcp"),n=[];try{if(!t.default.existsSync(a))return n;for(let e of t.default.readdirSync(a,{withFileTypes:!0})){let s;if(!e.isFile()||!e.name.endsWith(".json"))continue;let i=r.default.join(a,e.name),o=t.default.readFileSync(i,"utf-8");try{s=JSON.parse(o)}catch{continue}let l=s.name||e.name.replace(/\.json$/,"");n.push({name:l,type:"mcp",path:r.default.join("mcp",e.name),frontmatter:{name:l,version:s.version,description:s.description,updated:s.updated},isValid:!!(s.name&&s.command)})}}catch{}return n}(e)}}function l(){let e=s();return[...i(e,"skill"),...i(e,"agent")]}e.s(["getStoreAssets",()=>l,"scanStore",()=>o])},48044,e=>{"use strict";var t=e.i(22734),r=e.i(33405),a=e.i(14747),n=e.i(46676),s=e.i(73178);let i={outdatedAssets:.3,staleCards:.15,unresolvedProblems:.25,missingClaudeMd:.1,nonCompliantFrontmatter:.2};function o(e,t=0,r=0,a=0,n=i){let s=[],l=Math.max(r,1);s.push({name:"Outdated Assets",weight:n.outdatedAssets,value:t,maxValue:l});let d=Date.now(),u=[...e.backlog],c=u.filter(e=>(d-new Date(e.created_at).getTime())/864e5>14&&"done"!==e.status).length,p=Math.max(u.length,1);s.push({name:"Stale Cards",weight:n.staleCards,value:c,maxValue:p}),s.push({name:"Unresolved Problems",weight:n.unresolvedProblems,value:0,maxValue:1}),s.push({name:"Missing CLAUDE.md",weight:n.missingClaudeMd,value:+!e.hasClaudeMd,maxValue:1});let f=Math.max(r,1);s.push({name:"Non-compliant Frontmatter",weight:n.nonCompliantFrontmatter,value:a,maxValue:f});let m=0;for(let e of s)m+=Math.min(e.maxValue>0?e.value/e.maxValue:0,1)*e.weight;let h=Math.round(Math.max(0,(1-m)*100));return{score:h,level:h>=80?"green":h>=50?"amber":"red",factors:s}}function l(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let e=process.cwd();return e.endsWith("/web")||e.endsWith("\\web")?a.default.dirname(e):e}let d=l(),u=a.default.join(d,"projects","registry.json");async function c(){try{let e=await t.promises.readFile(u,"utf-8");return JSON.parse(e)}catch(e){throw console.error("Failed to load registry:",e),Error(`Failed to load registry from ${u}`)}}async function p(e){let r=JSON.stringify(e,null,2)+"\n";await t.promises.writeFile(u,r,"utf-8")}async function f(e){try{return(await t.promises.stat(e)).isDirectory()}catch{return!1}}async function m(e){try{let r=await t.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}async function h(e,t,r){let n=a.default.join(e,"documentation","backlog.json"),s=await m(n);return s?s.map(e=>({...e,projectId:t,projectName:r})):[]}async function g(e,t){let r=a.default.join(e,"documentation","designs.json"),n=await m(r);return n?n.map(e=>({...e,projectId:t})):[]}async function x(e,t){let r=a.default.join(e,"documentation","features.json"),n=await m(r);return n?n.map(e=>({...e,projectId:t})):[]}async function y(e){let t=e.path;if(!await f(t))return{...e,backlog:[],designs:[],features:[],accessible:!1,error:`Path not accessible: ${t}`};let[a,s,i]=await Promise.all([h(t,e.id,e.name),g(t,e.id),x(t,e.id)]),o=(0,n.scanProjectAssets)(t,e.id),l=(0,n.detectPlatforms)(t),d=function(e){try{return(0,r.execSync)("git status --porcelain",{cwd:e,encoding:"utf-8",timeout:5e3}).split("\n").filter(e=>e.trim().length>0).length}catch{return -1}}(t);return{...e,backlog:a,designs:s,features:i,assets:o,platforms:l,gitUncommitted:d>=0?d:void 0,accessible:!0}}async function v(){let e=await c();for(let t=0;t<e.projects.length;t++)void 0===e.projects[t].order&&(e.projects[t].order=t);e.projects.sort((e,t)=>(e.order??0)-(t.order??0));let t=e.projects.map(e=>y(e)),r=await Promise.all(t),i=(0,s.getStoreAssets)(),d=["skill","agent"],u=0,p=[];for(let t of["claude","agents"])for(let r of d){let a=i.filter(e=>e.type===r),s=new Map;for(let a of e.projects){let e=(0,n.scanProviderAssets)(a.path,t);s.set(a.id,e.filter(e=>e.type===r))}let o=(0,n.buildStoreAssetMatrix)(a,s,e.projects,r);p.push(...o)}for(let e of p)for(let t of e.cells)"outdated"===t.status&&u++;for(let e of r){if(!e.accessible)continue;let t=0;for(let r of p)for(let a of r.cells)a.projectId===e.id&&"outdated"===a.status&&t++;e.healthScore=function(e,t,r=0,a){if(!t)return o(e,0,0,0,void 0);let n=[...t.skills,...t.agents];return o(e,r,n.length,n.filter(e=>!e.isValid).length,void 0)}(e,e.assets,t)}let f=0,h=0;for(let e of r){if(!e.accessible)continue;let t=a.default.join(e.path,"documentation","kanban.json"),r=await m(t);if(r?.stages){f+=(r.stages.backlog||[]).filter(e=>!e.archived).length;let e=(r.stages.implementation||[]).filter(e=>!e.archived),t=(r.stages.testing||[]).filter(e=>!e.archived);h+=e.length+t.length}}let g=r.reduce((e,t)=>e+(t.gitUncommitted&&t.gitUncommitted>0?t.gitUncommitted:0),0),x=process.env.BRIDGE_URL||"http://127.0.0.1:7592";try{let e=await fetch(`${x}/stats`,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json(),a={};for(let e of t.sessions||[])if(e.isActive){let t=e.name.split(":")[0];a[t]=(a[t]||0)+1}for(let e of r)e.activeSessions=a[e.id]??0}}catch{}let v=l();return{projects:r,totalBacklogItems:f,activeItems:h,totalOutdatedAssets:u,totalUncommitted:g,lastRefresh:new Date().toISOString(),slycodeRoot:v,projectsDir:a.default.dirname(v)}}e.s(["getRepoRoot",()=>l,"loadDashboardData",()=>v,"loadRegistry",()=>c,"saveRegistry",()=>p],48044)},98036,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),f=e.i(70101),m=e.i(74838),h=e.i(10372),g=e.i(93695);e.i(52474);var x=e.i(220),y=e.i(89171),v=e.i(33405),w=e.i(48044);async function R(){try{let e=await (0,w.loadRegistry)(),t={};for(let r of e.projects)t[r.id]=function(e){try{return(0,v.execSync)("git status --porcelain",{cwd:e,encoding:"utf-8",timeout:5e3}).split("\n").filter(e=>e.trim().length>0).length}catch{return -1}}(r.path);return y.NextResponse.json(t)}catch(e){return console.error("Failed to get git status:",e),y.NextResponse.json({error:"Failed to get git status",details:String(e)},{status:500})}}e.s(["GET",()=>R,"dynamic",0,"force-dynamic"],46438);var E=e.i(46438);let j=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/git-status/route",pathname:"/api/git-status",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/git-status/route.ts",nextConfigOutput:"standalone",userland:E}),{workAsyncStorage:S,workUnitAsyncStorage:C,serverHooks:b}=j;function A(){return(0,a.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:C})}async function k(e,t,a){j.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/git-status/route";y=y.replace(/\/index$/,"")||"/";let v=await j.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:w,params:R,nextConfig:E,parsedUrl:S,isDraftMode:C,prerenderManifest:b,routerServerContext:A,isOnDemandRevalidate:k,revalidateOnlyGenerated:O,resolvedPathname:P,clientReferenceManifest:N,serverActionsManifest:_}=v,D=(0,o.normalizeAppPath)(y),M=!!(b.dynamicRoutes[D]||b.routes[P]),T=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,S,!1):t.end("This page could not be found"),null);if(M&&!C){let e=!!b.routes[P],t=b.dynamicRoutes[D];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await T();throw new g.NoFallbackError}}let F=null;!M||j.isDev||C||(F="/index"===(F=P)?"/":F);let q=!0===j.isDev||!M,U=M&&!q;_&&N&&(0,i.setManifestsSingleton)({page:y,clientReferenceManifest:N,serverActionsManifest:_});let H=e.method||"GET",I=(0,s.getTracer)(),L=I.getActiveScopeSpan(),$={params:R,prerenderManifest:b,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:q,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>j.onRequestError(e,t,a,n,A)},sharedContext:{buildId:w}},V=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),W=d.NextRequestAdapter.fromNodeNextRequest(V,(0,d.signalFromNodeResponse)(t));try{let i=async e=>j.handle(W,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=I.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${H} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${H} ${y}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let d=async({previousCacheEntry:r})=>{try{if(!o&&k&&O&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=$.renderOpts.fetchMetrics;let l=$.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let d=$.renderOpts.collectedTags;if(!M)return await (0,p.sendResponse)(V,K,s,$.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[h.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==$.renderOpts.collectedRevalidate&&!($.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&$.renderOpts.collectedRevalidate,a=void 0===$.renderOpts.collectedExpire||$.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:$.renderOpts.collectedExpire;return{value:{kind:x.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await j.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:k})},!1,A),t}},u=await j.handleResponse({req:e,nextConfig:E,cacheKey:F,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:b,isRoutePPREnabled:!1,isOnDemandRevalidate:k,revalidateOnlyGenerated:O,responseGenerator:d,waitUntil:a.waitUntil,isMinimalMode:o});if(!M)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==x.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",k?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let g=(0,f.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&M||g.delete(h.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||g.get("Cache-Control")||g.set("Cache-Control",(0,m.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(V,K,new Response(u.value.body,{headers:g,status:u.value.status||200})),null};L?await l(L):await I.withPropagatedContext(e.headers,()=>I.trace(u.BaseServerSpan.handleRequest,{spanName:`${H} ${y}`,kind:s.SpanKind.SERVER,attributes:{"http.method":H,"http.target":e.url}},l))}catch(t){if(t instanceof g.NoFallbackError||await j.onRequestError(e,t,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:k})},!1,A),M)throw t;return await (0,p.sendResponse)(V,K,new Response(null,{status:500})),null}}e.s(["handler",()=>k,"patchFetch",()=>A,"routeModule",()=>j,"serverHooks",()=>b,"workAsyncStorage",()=>S,"workUnitAsyncStorage",()=>C],98036)}];
1
+ module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},7367,e=>{"use strict";var t=e.i(14747),r=e.i(22734);function a(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let e=process.cwd();return(console.warn("[paths] SLYCODE_HOME not set in production — falling back to cwd:",e),e.endsWith("/web")||e.endsWith("\\web"))?t.default.dirname(e):e}function n(){let e=a(),n=t.default.join(e,"node_modules","@slycode","slycode","dist");return r.default.existsSync(n)?n:e}e.s(["getPackageDir",()=>n,"getSlycodeRoot",()=>a])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},73178,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(46676),n=e.i(7367);function s(){return r.default.join((0,n.getSlycodeRoot)(),"store")}function i(e,n){let s=[],i="skill"===n?"skills":"agents",o=r.default.join(e,i);try{if(!t.default.existsSync(o))return s;for(let e of t.default.readdirSync(o,{withFileTypes:!0})){let l,d;if("skill"===n){if(!e.isDirectory()||(l=r.default.join(o,e.name,"SKILL.md"),d=r.default.join(i,e.name,"SKILL.md"),!t.default.existsSync(l)))continue}else{if(!e.isFile()||!e.name.endsWith(".md"))continue;l=r.default.join(o,e.name),d=r.default.join(i,e.name)}let u=t.default.readFileSync(l,"utf-8"),c=(0,a.parseFrontmatter)(u),p=c?.name||e.name.replace(/\.md$/,"");s.push({name:p,type:n,path:d,frontmatter:c,isValid:(0,a.validateFrontmatter)(c)})}}catch{}return s.sort((e,t)=>e.name.localeCompare(t.name))}function o(){let e=s();return{skills:i(e,"skill"),agents:i(e,"agent"),mcp:function(e){let a=r.default.join(e,"mcp"),n=[];try{if(!t.default.existsSync(a))return n;for(let e of t.default.readdirSync(a,{withFileTypes:!0})){let s;if(!e.isFile()||!e.name.endsWith(".json"))continue;let i=r.default.join(a,e.name),o=t.default.readFileSync(i,"utf-8");try{s=JSON.parse(o)}catch{continue}let l=s.name||e.name.replace(/\.json$/,"");n.push({name:l,type:"mcp",path:r.default.join("mcp",e.name),frontmatter:{name:l,version:s.version,description:s.description,updated:s.updated},isValid:!!(s.name&&s.command)})}}catch{}return n}(e)}}function l(){let e=s();return[...i(e,"skill"),...i(e,"agent")]}e.s(["getStoreAssets",()=>l,"scanStore",()=>o])},48044,e=>{"use strict";var t=e.i(22734),r=e.i(33405),a=e.i(14747),n=e.i(46676),s=e.i(73178);let i={outdatedAssets:.3,staleCards:.15,unresolvedProblems:.25,missingClaudeMd:.1,nonCompliantFrontmatter:.2};function o(e,t=0,r=0,a=0,n=i){let s=[],l=Math.max(r,1);s.push({name:"Outdated Assets",weight:n.outdatedAssets,value:t,maxValue:l});let d=Date.now(),u=[...e.backlog],c=u.filter(e=>(d-new Date(e.created_at).getTime())/864e5>14&&"done"!==e.status).length,p=Math.max(u.length,1);s.push({name:"Stale Cards",weight:n.staleCards,value:c,maxValue:p}),s.push({name:"Unresolved Problems",weight:n.unresolvedProblems,value:0,maxValue:1}),s.push({name:"Missing CLAUDE.md",weight:n.missingClaudeMd,value:+!e.hasClaudeMd,maxValue:1});let f=Math.max(r,1);s.push({name:"Non-compliant Frontmatter",weight:n.nonCompliantFrontmatter,value:a,maxValue:f});let m=0;for(let e of s)m+=Math.min(e.maxValue>0?e.value/e.maxValue:0,1)*e.weight;let h=Math.round(Math.max(0,(1-m)*100));return{score:h,level:h>=80?"green":h>=50?"amber":"red",factors:s}}function l(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let e=process.cwd();return e.endsWith("/web")||e.endsWith("\\web")?a.default.dirname(e):e}let d=l(),u=a.default.join(d,"projects","registry.json");async function c(){try{let e=await t.promises.readFile(u,"utf-8");return JSON.parse(e)}catch(e){throw console.error("Failed to load registry:",e),Error(`Failed to load registry from ${u}`)}}async function p(e){let r=JSON.stringify(e,null,2)+"\n";await t.promises.writeFile(u,r,"utf-8")}async function f(e){try{return(await t.promises.stat(e)).isDirectory()}catch{return!1}}async function m(e){try{let r=await t.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}async function h(e,t,r){let n=a.default.join(e,"documentation","backlog.json"),s=await m(n);return s?s.map(e=>({...e,projectId:t,projectName:r})):[]}async function g(e,t){let r=a.default.join(e,"documentation","designs.json"),n=await m(r);return n?n.map(e=>({...e,projectId:t})):[]}async function x(e,t){let r=a.default.join(e,"documentation","features.json"),n=await m(r);return n?n.map(e=>({...e,projectId:t})):[]}async function y(e){let t=e.path;if(!await f(t))return{...e,backlog:[],designs:[],features:[],accessible:!1,error:`Path not accessible: ${t}`};let[a,s,i]=await Promise.all([h(t,e.id,e.name),g(t,e.id),x(t,e.id)]),o=(0,n.scanProjectAssets)(t,e.id),l=(0,n.detectPlatforms)(t),d=function(e){try{return(0,r.execSync)("git status --porcelain",{cwd:e,encoding:"utf-8",timeout:5e3}).split("\n").filter(e=>e.trim().length>0).length}catch{return -1}}(t);return{...e,backlog:a,designs:s,features:i,assets:o,platforms:l,gitUncommitted:d>=0?d:void 0,accessible:!0}}async function v(){let e=await c();for(let t=0;t<e.projects.length;t++)void 0===e.projects[t].order&&(e.projects[t].order=t);e.projects.sort((e,t)=>(e.order??0)-(t.order??0));let t=e.projects.map(e=>y(e)),r=await Promise.all(t),i=(0,s.getStoreAssets)(),d=["skill","agent"],u=0,p=[];for(let t of["claude","agents"])for(let r of d){let a=i.filter(e=>e.type===r),s=new Map;for(let a of e.projects){let e=(0,n.scanProviderAssets)(a.path,t);s.set(a.id,e.filter(e=>e.type===r))}let o=(0,n.buildStoreAssetMatrix)(a,s,e.projects,r);p.push(...o)}for(let e of p)for(let t of e.cells)"outdated"===t.status&&u++;for(let e of r){if(!e.accessible)continue;let t=0;for(let r of p)for(let a of r.cells)a.projectId===e.id&&"outdated"===a.status&&t++;e.healthScore=function(e,t,r=0,a){if(!t)return o(e,0,0,0,void 0);let n=[...t.skills,...t.agents];return o(e,r,n.length,n.filter(e=>!e.isValid).length,void 0)}(e,e.assets,t)}let f=0,h=0;for(let e of r){if(!e.accessible)continue;let t=a.default.join(e.path,"documentation","kanban.json"),r=await m(t);if(r?.stages){f+=(r.stages.backlog||[]).filter(e=>!e.archived).length;let e=(r.stages.implementation||[]).filter(e=>!e.archived),t=(r.stages.testing||[]).filter(e=>!e.archived);h+=e.length+t.length}}let g=r.reduce((e,t)=>e+(t.gitUncommitted&&t.gitUncommitted>0?t.gitUncommitted:0),0),x=process.env.BRIDGE_URL||"http://127.0.0.1:7592";try{let e=await fetch(`${x}/stats`,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json(),a={};for(let e of t.sessions||[])if(e.isActive){let t=e.name.split(":")[0];a[t]=(a[t]||0)+1}for(let e of r)e.activeSessions=a[e.id]??0}}catch{}let v=l();return{projects:r,totalBacklogItems:f,activeItems:h,totalOutdatedAssets:u,totalUncommitted:g,lastRefresh:new Date().toISOString(),slycodeRoot:v,projectsDir:a.default.dirname(v)}}e.s(["getRepoRoot",()=>l,"loadDashboardData",()=>v,"loadRegistry",()=>c,"saveRegistry",()=>p],48044)},98036,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),f=e.i(70101),m=e.i(74838),h=e.i(10372),g=e.i(93695);e.i(52474);var x=e.i(220),y=e.i(89171),v=e.i(33405),w=e.i(48044);async function R(){try{let e=await (0,w.loadRegistry)(),t={};for(let r of e.projects)t[r.id]=function(e){try{return(0,v.execSync)("git status --porcelain",{cwd:e,encoding:"utf-8",timeout:5e3,windowsHide:!0}).split("\n").filter(e=>e.trim().length>0).length}catch{return -1}}(r.path);return y.NextResponse.json(t)}catch(e){return console.error("Failed to get git status:",e),y.NextResponse.json({error:"Failed to get git status",details:String(e)},{status:500})}}e.s(["GET",()=>R,"dynamic",0,"force-dynamic"],46438);var E=e.i(46438);let j=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/git-status/route",pathname:"/api/git-status",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/git-status/route.ts",nextConfigOutput:"standalone",userland:E}),{workAsyncStorage:S,workUnitAsyncStorage:C,serverHooks:b}=j;function A(){return(0,a.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:C})}async function k(e,t,a){j.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/git-status/route";y=y.replace(/\/index$/,"")||"/";let v=await j.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:w,params:R,nextConfig:E,parsedUrl:S,isDraftMode:C,prerenderManifest:b,routerServerContext:A,isOnDemandRevalidate:k,revalidateOnlyGenerated:O,resolvedPathname:P,clientReferenceManifest:N,serverActionsManifest:_}=v,D=(0,o.normalizeAppPath)(y),M=!!(b.dynamicRoutes[D]||b.routes[P]),T=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,S,!1):t.end("This page could not be found"),null);if(M&&!C){let e=!!b.routes[P],t=b.dynamicRoutes[D];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await T();throw new g.NoFallbackError}}let F=null;!M||j.isDev||C||(F="/index"===(F=P)?"/":F);let q=!0===j.isDev||!M,H=M&&!q;_&&N&&(0,i.setManifestsSingleton)({page:y,clientReferenceManifest:N,serverActionsManifest:_});let U=e.method||"GET",I=(0,s.getTracer)(),L=I.getActiveScopeSpan(),$={params:R,prerenderManifest:b,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:q,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>j.onRequestError(e,t,a,n,A)},sharedContext:{buildId:w}},V=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),W=d.NextRequestAdapter.fromNodeNextRequest(V,(0,d.signalFromNodeResponse)(t));try{let i=async e=>j.handle(W,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=I.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${U} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${U} ${y}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let d=async({previousCacheEntry:r})=>{try{if(!o&&k&&O&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=$.renderOpts.fetchMetrics;let l=$.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let d=$.renderOpts.collectedTags;if(!M)return await (0,p.sendResponse)(V,K,s,$.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[h.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==$.renderOpts.collectedRevalidate&&!($.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&$.renderOpts.collectedRevalidate,a=void 0===$.renderOpts.collectedExpire||$.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:$.renderOpts.collectedExpire;return{value:{kind:x.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await j.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:k})},!1,A),t}},u=await j.handleResponse({req:e,nextConfig:E,cacheKey:F,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:b,isRoutePPREnabled:!1,isOnDemandRevalidate:k,revalidateOnlyGenerated:O,responseGenerator:d,waitUntil:a.waitUntil,isMinimalMode:o});if(!M)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==x.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",k?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let g=(0,f.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&M||g.delete(h.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||g.get("Cache-Control")||g.set("Cache-Control",(0,m.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(V,K,new Response(u.value.body,{headers:g,status:u.value.status||200})),null};L?await l(L):await I.withPropagatedContext(e.headers,()=>I.trace(u.BaseServerSpan.handleRequest,{spanName:`${U} ${y}`,kind:s.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},l))}catch(t){if(t instanceof g.NoFallbackError||await j.onRequestError(e,t,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:k})},!1,A),M)throw t;return await (0,p.sendResponse)(V,K,new Response(null,{status:500})),null}}e.s(["handler",()=>k,"patchFetch",()=>A,"routeModule",()=>j,"serverHooks",()=>b,"workAsyncStorage",()=>S,"workUnitAsyncStorage",()=>C],98036)}];
2
2
 
3
3
  //# sourceMappingURL=%5Broot-of-the-server%5D__aa814a86._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},7367,e=>{"use strict";var t=e.i(14747),r=e.i(22734);function n(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let e=process.cwd();return(console.warn("[paths] SLYCODE_HOME not set in production — falling back to cwd:",e),e.endsWith("/web")||e.endsWith("\\web"))?t.default.dirname(e):e}function a(){let e=n(),a=t.default.join(e,"node_modules","@slycode","slycode","dist");return r.default.existsSync(a)?a:e}e.s(["getPackageDir",()=>a,"getSlycodeRoot",()=>n])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},57032,e=>{"use strict";var t=e.i(47909),r=e.i(74017),n=e.i(96250),a=e.i(59756),s=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),x=e.i(74838),v=e.i(10372),f=e.i(93695);e.i(52474);var R=e.i(220),g=e.i(89171),y=e.i(33405),m=e.i(22734),E=e.i(14747),w=e.i(7367);async function C(){let e=(0,w.getSlycodeRoot)(),t="0.0.0";for(let r of[E.default.join(e,"node_modules","@slycode","slycode","package.json"),E.default.join(e,"packages","slycode","package.json")])if((0,m.existsSync)(r))try{t=JSON.parse((0,m.readFileSync)(r,"utf-8")).version||"0.0.0";break}catch{}let r=null;try{r=(0,y.execSync)("npm view @slycode/slycode version",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()||null}catch{}let n=!!(r&&r!==t);return g.NextResponse.json({current:t,latest:r,updateAvailable:n})}e.s(["GET",()=>C],74335);var b=e.i(74335);let k=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/version-check/route",pathname:"/api/version-check",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/version-check/route.ts",nextConfigOutput:"standalone",userland:b}),{workAsyncStorage:A,workUnitAsyncStorage:S,serverHooks:O}=k;function _(){return(0,n.patchFetch)({workAsyncStorage:A,workUnitAsyncStorage:S})}async function N(e,t,n){k.isDev&&(0,a.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/version-check/route";g=g.replace(/\/index$/,"")||"/";let y=await k.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:m,params:E,nextConfig:w,parsedUrl:C,isDraftMode:b,prerenderManifest:A,routerServerContext:S,isOnDemandRevalidate:O,revalidateOnlyGenerated:_,resolvedPathname:N,clientReferenceManifest:T,serverActionsManifest:P}=y,j=(0,i.normalizeAppPath)(g),q=!!(A.dynamicRoutes[j]||A.routes[N]),H=async()=>((null==S?void 0:S.render404)?await S.render404(e,t,C,!1):t.end("This page could not be found"),null);if(q&&!b){let e=!!A.routes[N],t=A.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(w.experimental.adapterPath)return await H();throw new f.NoFallbackError}}let D=null;!q||k.isDev||b||(D="/index"===(D=N)?"/":D);let U=!0===k.isDev||!q,I=q&&!U;P&&T&&(0,o.setManifestsSingleton)({page:g,clientReferenceManifest:T,serverActionsManifest:P});let M=e.method||"GET",F=(0,s.getTracer)(),$=F.getActiveScopeSpan(),K={params:E,prerenderManifest:A,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,a.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:w.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,a)=>k.onRequestError(e,t,n,a,S)},sharedContext:{buildId:m}},L=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(L,(0,d.signalFromNodeResponse)(t));try{let o=async e=>k.handle(G,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=r.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${g}`)}),i=!!(0,a.getRequestMeta)(e,"minimalMode"),l=async a=>{var s,l;let d=async({previousCacheEntry:r})=>{try{if(!i&&O&&_&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await o(a);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&n.waitUntil&&(n.waitUntil(l),l=void 0);let d=K.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(L,B,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[v.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=v.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=v.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:R.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==r?void 0:r.isStale)&&await k.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:I,isOnDemandRevalidate:O})},!1,S),t}},u=await k.handleResponse({req:e,nextConfig:w,cacheKey:D,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:_,responseGenerator:d,waitUntil:n.waitUntil,isMinimalMode:i});if(!q)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",O?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return i&&q||f.delete(v.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,x.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(L,B,new Response(u.value.body,{headers:f,status:u.value.status||200})),null};$?await l($):await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${g}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof f.NoFallbackError||await k.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:I,isOnDemandRevalidate:O})},!1,S),q)throw t;return await (0,p.sendResponse)(L,B,new Response(null,{status:500})),null}}e.s(["handler",()=>N,"patchFetch",()=>_,"routeModule",()=>k,"serverHooks",()=>O,"workAsyncStorage",()=>A,"workUnitAsyncStorage",()=>S],57032)}];
1
+ module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},7367,e=>{"use strict";var t=e.i(14747),r=e.i(22734);function n(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let e=process.cwd();return(console.warn("[paths] SLYCODE_HOME not set in production — falling back to cwd:",e),e.endsWith("/web")||e.endsWith("\\web"))?t.default.dirname(e):e}function a(){let e=n(),a=t.default.join(e,"node_modules","@slycode","slycode","dist");return r.default.existsSync(a)?a:e}e.s(["getPackageDir",()=>a,"getSlycodeRoot",()=>n])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},57032,e=>{"use strict";var t=e.i(47909),r=e.i(74017),n=e.i(96250),a=e.i(59756),s=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),x=e.i(74838),v=e.i(10372),f=e.i(93695);e.i(52474);var R=e.i(220),g=e.i(89171),y=e.i(33405),m=e.i(22734),w=e.i(14747),E=e.i(7367);async function C(){let e=(0,E.getSlycodeRoot)(),t="0.0.0";for(let r of[w.default.join(e,"node_modules","@slycode","slycode","package.json"),w.default.join(e,"packages","slycode","package.json")])if((0,m.existsSync)(r))try{t=JSON.parse((0,m.readFileSync)(r,"utf-8")).version||"0.0.0";break}catch{}let r=null;try{r=(0,y.execSync)("npm view @slycode/slycode version",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"],windowsHide:!0}).trim()||null}catch{}let n=!!(r&&r!==t);return g.NextResponse.json({current:t,latest:r,updateAvailable:n})}e.s(["GET",()=>C],74335);var b=e.i(74335);let k=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/version-check/route",pathname:"/api/version-check",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/version-check/route.ts",nextConfigOutput:"standalone",userland:b}),{workAsyncStorage:A,workUnitAsyncStorage:S,serverHooks:O}=k;function _(){return(0,n.patchFetch)({workAsyncStorage:A,workUnitAsyncStorage:S})}async function N(e,t,n){k.isDev&&(0,a.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/version-check/route";g=g.replace(/\/index$/,"")||"/";let y=await k.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:m,params:w,nextConfig:E,parsedUrl:C,isDraftMode:b,prerenderManifest:A,routerServerContext:S,isOnDemandRevalidate:O,revalidateOnlyGenerated:_,resolvedPathname:N,clientReferenceManifest:T,serverActionsManifest:P}=y,j=(0,i.normalizeAppPath)(g),q=!!(A.dynamicRoutes[j]||A.routes[N]),H=async()=>((null==S?void 0:S.render404)?await S.render404(e,t,C,!1):t.end("This page could not be found"),null);if(q&&!b){let e=!!A.routes[N],t=A.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await H();throw new f.NoFallbackError}}let D=null;!q||k.isDev||b||(D="/index"===(D=N)?"/":D);let U=!0===k.isDev||!q,I=q&&!U;P&&T&&(0,o.setManifestsSingleton)({page:g,clientReferenceManifest:T,serverActionsManifest:P});let M=e.method||"GET",F=(0,s.getTracer)(),$=F.getActiveScopeSpan(),K={params:w,prerenderManifest:A,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,a.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,a)=>k.onRequestError(e,t,n,a,S)},sharedContext:{buildId:m}},L=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(L,(0,d.signalFromNodeResponse)(t));try{let o=async e=>k.handle(G,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=r.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${g}`)}),i=!!(0,a.getRequestMeta)(e,"minimalMode"),l=async a=>{var s,l;let d=async({previousCacheEntry:r})=>{try{if(!i&&O&&_&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await o(a);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&n.waitUntil&&(n.waitUntil(l),l=void 0);let d=K.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(L,B,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[v.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=v.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=v.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:R.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==r?void 0:r.isStale)&&await k.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:I,isOnDemandRevalidate:O})},!1,S),t}},u=await k.handleResponse({req:e,nextConfig:E,cacheKey:D,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:_,responseGenerator:d,waitUntil:n.waitUntil,isMinimalMode:i});if(!q)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",O?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return i&&q||f.delete(v.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,x.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(L,B,new Response(u.value.body,{headers:f,status:u.value.status||200})),null};$?await l($):await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${g}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof f.NoFallbackError||await k.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:I,isOnDemandRevalidate:O})},!1,S),q)throw t;return await (0,p.sendResponse)(L,B,new Response(null,{status:500})),null}}e.s(["handler",()=>N,"patchFetch",()=>_,"routeModule",()=>k,"serverHooks",()=>O,"workAsyncStorage",()=>A,"workUnitAsyncStorage",()=>S],57032)}];
2
2
 
3
3
  //# sourceMappingURL=%5Broot-of-the-server%5D__b90bbd70._.js.map
@@ -5,7 +5,7 @@ ${t}`)}return a})(se);class sn extends t7{list(e,t={},s){return this._client.get
5
5
  ${sb(e)}`);if(null==i)throw new eG(`missing choices[${n}].tool_calls[${s}].type
6
6
  ${sb(e)}`);if(null==c)throw new eG(`missing choices[${n}].tool_calls[${s}].function.name
7
7
  ${sb(e)}`);if(null==l)throw new eG(`missing choices[${n}].tool_calls[${s}].function.arguments
8
- ${sb(e)}`);return{...o,id:a,type:i,function:{...u,name:c,arguments:l}}})}}:{...i,message:{...c,content:a,role:u,refusal:t.refusal??null},finish_reason:s,index:n,logprobs:r}}),created:i,model:a,object:"chat.completion",...o?{system_fingerprint:o}:{}},t&&sl(t)?so(s,t):{...s,choices:s.choices.map(e=>(sc(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(e,eK(this,C,"f"))},q=function(){let e=eK(this,C,"f")?.response_format;return si(e)?e:null},U=function(e){var t,s,n,r;let i=eK(this,N,"f"),{choices:a,...o}=e;for(let{delta:a,finish_reason:l,index:c,logprobs:u=null,...h}of(i?Object.assign(i,o):i=eX(this,N,{...o,choices:[]},"f"),e.choices)){let e=i.choices[c];if(e||(e=i.choices[c]={finish_reason:l,index:c,message:{},logprobs:u,...h}),u)if(e.logprobs){let{content:n,refusal:r,...i}=u;sv(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({},u);if(l&&(e.finish_reason=l,eK(this,C,"f")&&sl(eK(this,C,"f")))){if("length"===l)throw new e7;if("content_filter"===l)throw new te}if(Object.assign(e,h),!a)continue;let{content:o,refusal:d,function_call:p,role:f,tool_calls:m,...g}=a;if(sv(g),Object.assign(e.message,g),d&&(e.message.refusal=(e.message.refusal||"")+d),f&&(e.message.role=f),p&&(e.message.function_call?(p.name&&(e.message.function_call.name=p.name),p.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=p.arguments)):e.message.function_call=p),o&&(e.message.content=(e.message.content||"")+o,!e.message.refusal&&eK(this,P,"m",q).call(this)&&(e.message.parsed=sw(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=>sr(e)&&e.function?.name===t.function.name);return sr(s)&&(sa(s)||s?.function.strict||!1)}(eK(this,C,"f"),o)&&(o.function.parsed_arguments=sw(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 tD(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function sb(e){return JSON.stringify(e)}function sv(e){}function sx(e){}class sS extends sy{static fromReadableStream(e){let t=new sS(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,s){let n=new sS(t),r={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,r)),n}}class s$ extends t7{constructor(){super(...arguments),this.messages=new sn(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(ss`/chat/completions/${e}`,t)}update(e,t,s){return this._client.post(ss`/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(ss`/chat/completions/${e}`,t)}parse(e,t){for(let t of e.tools??[]){if("function"!==t.type)throw new eG(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new eG(`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=>so(t,e))}runTools(e,t){return e.stream?sS.runTools(this._client,e,t):sf.runTools(this._client,e,t)}stream(e,t){return sy.createChatCompletion(this._client,e,t)}}s$.Messages=sn;class sA extends t7{constructor(){super(...arguments),this.completions=new s$(this._client)}}sA.Completions=s$,e.s([],98546);let sR=Symbol("brand.privateNullableHeaders"),sI=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(sR 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():tr(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=tr(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{[sR]:!0,values:t,nulls:s}};class sO extends t7{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:sI([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class sk extends t7{create(e,t){return this._client.post("/audio/transcriptions",t0({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class sE extends t7{create(e,t){return this._client.post("/audio/translations",t0({body:e,...t,__metadata:{model:e.model}},this._client))}}class sP extends t7{constructor(){super(...arguments),this.transcriptions=new sk(this._client),this.translations=new sE(this._client),this.speech=new sO(this._client)}}sP.Transcriptions=sk,sP.Translations=sE,sP.Speech=sO;class sC extends t7{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",tJ,{query:e,...t})}cancel(e,t){return this._client.post(ss`/batches/${e}/cancel`,t)}}class sT extends t7{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ss`/assistants/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(ss`/assistants/${e}`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",tJ,{query:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(ss`/assistants/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sN extends t7{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sj extends t7{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sM extends t7{constructor(){super(...arguments),this.sessions=new sN(this._client),this.transcriptionSessions=new sj(this._client)}}sM.Sessions=sN,sM.TranscriptionSessions=sj;class sD extends t7{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(ss`/chatkit/sessions/${e}/cancel`,{...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class sL extends t7{retrieve(e,t){return this._client.get(ss`/chatkit/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",tV,{query:e,...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(ss`/chatkit/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},s){return this._client.getAPIList(ss`/chatkit/threads/${e}/items`,tV,{query:t,...s,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},s?.headers])})}}class sB extends t7{constructor(){super(...arguments),this.sessions=new sD(this._client),this.threads=new sL(this._client)}}sB.Sessions=sD,sB.Threads=sL;class sW extends t7{create(e,t,s){return this._client.post(ss`/threads/${e}/messages`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(ss`/threads/${n}/messages/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(ss`/threads/${n}/messages/${e}`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(ss`/threads/${e}/messages`,tJ,{query:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{thread_id:n}=t;return this._client.delete(ss`/threads/${n}/messages/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class sq extends t7{retrieve(e,t,s){let{thread_id:n,run_id:r,...i}=t;return this._client.get(ss`/threads/${n}/runs/${r}/steps/${e}`,{query:i,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t,s){let{thread_id:n,...r}=t;return this._client.getAPIList(ss`/threads/${n}/runs/${e}/steps`,tJ,{query:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}let sU=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;class sH extends sd{constructor(){super(...arguments),H.add(this),X.set(this,[]),K.set(this,{}),J.set(this,{}),V.set(this,void 0),z.set(this,void 0),G.set(this,void 0),Q.set(this,void 0),Y.set(this,void 0),Z.set(this,void 0),ee.set(this,void 0),et.set(this,void 0),es.set(this,void 0)}[(X=new WeakMap,K=new WeakMap,J=new WeakMap,V=new WeakMap,z=new WeakMap,G=new WeakMap,Q=new WeakMap,Y=new WeakMap,Z=new WeakMap,ee=new WeakMap,et=new WeakMap,es=new WeakMap,H=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 F;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=tD.fromReadableStream(e,this.controller);for await(let e of n)eK(this,H,"m",en).call(this,e);if(n.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).call(this))}toReadableStream(){return new tD(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,s,n){let r=new F;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))eK(this,H,"m",en).call(this,e);if(a.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).call(this))}static createThreadAssistantStream(e,t,s){let n=new F;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 F;return r._run(()=>r._runAssistantStream(e,t,s,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}currentEvent(){return eK(this,ee,"f")}currentRun(){return eK(this,et,"f")}currentMessageSnapshot(){return eK(this,V,"f")}currentRunStepSnapshot(){return eK(this,es,"f")}async finalRunSteps(){return await this.done(),Object.values(eK(this,K,"f"))}async finalMessages(){return await this.done(),Object.values(eK(this,J,"f"))}async finalRun(){if(await this.done(),!eK(this,z,"f"))throw Error("Final run was not received.");return eK(this,z,"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))eK(this,H,"m",en).call(this,e);if(i.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).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))eK(this,H,"m",en).call(this,e);if(a.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).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(ta(t)&&ta(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(!ta(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)}}F=sH,en=function(e){if(!this.ended)switch(eX(this,ee,e,"f"),eK(this,H,"m",eo).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":eK(this,H,"m",eh).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":eK(this,H,"m",ea).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":eK(this,H,"m",ei).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},er=function(){if(this.ended)throw new eG("stream has ended, this shouldn't happen");if(!eK(this,z,"f"))throw Error("Final run has not been received");return eK(this,z,"f")},ei=function(e){let[t,s]=eK(this,H,"m",ec).call(this,e,eK(this,V,"f"));for(let e of(eX(this,V,t,"f"),eK(this,J,"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!=eK(this,G,"f")){if(eK(this,Q,"f"))switch(eK(this,Q,"f").type){case"text":this._emit("textDone",eK(this,Q,"f").text,eK(this,V,"f"));break;case"image_file":this._emit("imageFileDone",eK(this,Q,"f").image_file,eK(this,V,"f"))}eX(this,G,s.index,"f")}eX(this,Q,t.content[s.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==eK(this,G,"f")){let t=e.data.content[eK(this,G,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,eK(this,V,"f"));break;case"text":this._emit("textDone",t.text,eK(this,V,"f"))}}eK(this,V,"f")&&this._emit("messageDone",e.data),eX(this,V,void 0,"f")}},ea=function(e){let t=eK(this,H,"m",el).call(this,e);switch(eX(this,es,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==eK(this,Y,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(eK(this,Z,"f")&&this._emit("toolCallDone",eK(this,Z,"f")),eX(this,Y,e.index,"f"),eX(this,Z,t.step_details.tool_calls[e.index],"f"),eK(this,Z,"f")&&this._emit("toolCallCreated",eK(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":eX(this,es,void 0,"f"),"tool_calls"==e.data.step_details.type&&eK(this,Z,"f")&&(this._emit("toolCallDone",eK(this,Z,"f")),eX(this,Z,void 0,"f")),this._emit("runStepDone",e.data,t)}},eo=function(e){eK(this,X,"f").push(e),this._emit("event",e)},el=function(e){switch(e.event){case"thread.run.step.created":return eK(this,K,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=eK(this,K,"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=F.accumulateDelta(t,s.delta);eK(this,K,"f")[e.data.id]=n}return eK(this,K,"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":eK(this,K,"f")[e.data.id]=e.data}if(eK(this,K,"f")[e.data.id])return eK(this,K,"f")[e.data.id];throw Error("No snapshot available")},ec=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]=eK(this,H,"m",eu).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")},eu=function(e,t){return F.accumulateDelta(t,e)},eh=function(e){switch(eX(this,et,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":eX(this,z,e.data,"f"),eK(this,Z,"f")&&(this._emit("toolCallDone",eK(this,Z,"f")),eX(this,Z,void 0,"f"))}};class sF extends t7{constructor(){super(...arguments),this.steps=new sq(this._client)}create(e,t,s){let{include:n,...r}=t;return this._client.post(ss`/threads/${e}/runs`,{query:{include:n},body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(ss`/threads/${n}/runs/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(ss`/threads/${n}/runs/${e}`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(ss`/threads/${e}/runs`,tJ,{query:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{thread_id:n}=t;return this._client.post(ss`/threads/${n}/runs/${e}/cancel`,{...s,headers:sI([{"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 sH.createAssistantStream(e,this._client.beta.threads.runs,t,s)}async poll(e,t,s){let n=sI([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 to(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return r}}}stream(e,t,s){return sH.createAssistantStream(e,this._client.beta.threads.runs,t,s)}submitToolOutputs(e,t,s){let{thread_id:n,...r}=t;return this._client.post(ss`/threads/${n}/runs/${e}/submit_tool_outputs`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1})}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 sH.createToolAssistantStream(e,this._client.beta.threads.runs,t,s)}}sF.Steps=sq;class sX extends t7{constructor(){super(...arguments),this.runs=new sF(this._client),this.messages=new sW(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ss`/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(ss`/threads/${e}`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t){return this._client.delete(ss`/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1})}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 sH.createThreadAssistantStream(e,this._client.beta.threads,t)}}sX.Runs=sF,sX.Messages=sW;class sK extends t7{constructor(){super(...arguments),this.realtime=new sM(this._client),this.chatkit=new sB(this._client),this.assistants=new sT(this._client),this.threads=new sX(this._client)}}sK.Realtime=sM,sK.ChatKit=sB,sK.Assistants=sT,sK.Threads=sX;class sJ extends t7{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class sV extends t7{retrieve(e,t,s){let{container_id:n}=t;return this._client.get(ss`/containers/${n}/files/${e}/content`,{...s,headers:sI([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class sz extends t7{constructor(){super(...arguments),this.content=new sV(this._client)}create(e,t,s){return this._client.post(ss`/containers/${e}/files`,tZ({body:t,...s},this._client))}retrieve(e,t,s){let{container_id:n}=t;return this._client.get(ss`/containers/${n}/files/${e}`,s)}list(e,t={},s){return this._client.getAPIList(ss`/containers/${e}/files`,tJ,{query:t,...s})}delete(e,t,s){let{container_id:n}=t;return this._client.delete(ss`/containers/${n}/files/${e}`,{...s,headers:sI([{Accept:"*/*"},s?.headers])})}}sz.Content=sV;class sG extends t7{constructor(){super(...arguments),this.files=new sz(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/containers/${e}`,{...t,headers:sI([{Accept:"*/*"},t?.headers])})}}sG.Files=sz;class sQ extends t7{create(e,t,s){let{include:n,...r}=t;return this._client.post(ss`/conversations/${e}/items`,{query:{include:n},body:r,...s})}retrieve(e,t,s){let{conversation_id:n,...r}=t;return this._client.get(ss`/conversations/${n}/items/${e}`,{query:r,...s})}list(e,t={},s){return this._client.getAPIList(ss`/conversations/${e}/items`,tV,{query:t,...s})}delete(e,t,s){let{conversation_id:n}=t;return this._client.delete(ss`/conversations/${n}/items/${e}`,s)}}class sY extends t7{constructor(){super(...arguments),this.items=new sQ(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/conversations/${e}`,t)}update(e,t,s){return this._client.post(ss`/conversations/${e}`,{body:t,...s})}delete(e,t){return this._client.delete(ss`/conversations/${e}`,t)}}sY.Items=sQ;class sZ extends t7{create(e,t){let s=!!e.encoding_format,n=s?e.encoding_format:"base64";s&&tj(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:(tj(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 s0 extends t7{retrieve(e,t,s){let{eval_id:n,run_id:r}=t;return this._client.get(ss`/evals/${n}/runs/${r}/output_items/${e}`,s)}list(e,t,s){let{eval_id:n,...r}=t;return this._client.getAPIList(ss`/evals/${n}/runs/${e}/output_items`,tJ,{query:r,...s})}}class s1 extends t7{constructor(){super(...arguments),this.outputItems=new s0(this._client)}create(e,t,s){return this._client.post(ss`/evals/${e}/runs`,{body:t,...s})}retrieve(e,t,s){let{eval_id:n}=t;return this._client.get(ss`/evals/${n}/runs/${e}`,s)}list(e,t={},s){return this._client.getAPIList(ss`/evals/${e}/runs`,tJ,{query:t,...s})}delete(e,t,s){let{eval_id:n}=t;return this._client.delete(ss`/evals/${n}/runs/${e}`,s)}cancel(e,t,s){let{eval_id:n}=t;return this._client.post(ss`/evals/${n}/runs/${e}`,s)}}s1.OutputItems=s0;class s2 extends t7{constructor(){super(...arguments),this.runs=new s1(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/evals/${e}`,t)}update(e,t,s){return this._client.post(ss`/evals/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/evals",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/evals/${e}`,t)}}s2.Runs=s1;class s4 extends t7{create(e,t){return this._client.post("/files",t0({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ss`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/files/${e}`,t)}content(e,t){return this._client.get(ss`/files/${e}/content`,{...t,headers:sI([{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 to(t),i=await this.retrieve(e),Date.now()-r>s)throw new e0({message:`Giving up on waiting for file ${e} to finish processing after ${s} milliseconds.`});return i}}class s6 extends t7{}class s3 extends t7{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 s8 extends t7{constructor(){super(...arguments),this.graders=new s3(this._client)}}s8.Graders=s3;class s5 extends t7{create(e,t,s){return this._client.getAPIList(ss`/fine_tuning/checkpoints/${e}/permissions`,tK,{body:t,method:"post",...s})}retrieve(e,t={},s){return this._client.get(ss`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...s})}delete(e,t,s){let{fine_tuned_model_checkpoint:n}=t;return this._client.delete(ss`/fine_tuning/checkpoints/${n}/permissions/${e}`,s)}}class s9 extends t7{constructor(){super(...arguments),this.permissions=new s5(this._client)}}s9.Permissions=s5;class s7 extends t7{list(e,t={},s){return this._client.getAPIList(ss`/fine_tuning/jobs/${e}/checkpoints`,tJ,{query:t,...s})}}class ne extends t7{constructor(){super(...arguments),this.checkpoints=new s7(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/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(ss`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},s){return this._client.getAPIList(ss`/fine_tuning/jobs/${e}/events`,tJ,{query:t,...s})}pause(e,t){return this._client.post(ss`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(ss`/fine_tuning/jobs/${e}/resume`,t)}}ne.Checkpoints=s7;class nt extends t7{constructor(){super(...arguments),this.methods=new s6(this._client),this.jobs=new ne(this._client),this.checkpoints=new s9(this._client),this.alpha=new s8(this._client)}}nt.Methods=s6,nt.Jobs=ne,nt.Checkpoints=s9,nt.Alpha=s8;class ns extends t7{}class nn extends t7{constructor(){super(...arguments),this.graderModels=new ns(this._client)}}nn.GraderModels=ns;class nr extends t7{createVariation(e,t){return this._client.post("/images/variations",t0({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",t0({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 ni extends t7{retrieve(e,t){return this._client.get(ss`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",tK,e)}delete(e,t){return this._client.delete(ss`/models/${e}`,t)}}class na extends t7{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class no extends t7{accept(e,t,s){return this._client.post(ss`/realtime/calls/${e}/accept`,{body:t,...s,headers:sI([{Accept:"*/*"},s?.headers])})}hangup(e,t){return this._client.post(ss`/realtime/calls/${e}/hangup`,{...t,headers:sI([{Accept:"*/*"},t?.headers])})}refer(e,t,s){return this._client.post(ss`/realtime/calls/${e}/refer`,{body:t,...s,headers:sI([{Accept:"*/*"},s?.headers])})}reject(e,t={},s){return this._client.post(ss`/realtime/calls/${e}/reject`,{body:t,...s,headers:sI([{Accept:"*/*"},s?.headers])})}}class nl extends t7{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class nc extends t7{constructor(){super(...arguments),this.clientSecrets=new nl(this._client),this.calls=new no(this._client)}}function nu(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")||nh(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 nh(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("")}nc.ClientSecrets=nl,nc.Calls=no;class nd extends sd{constructor(e){super(),ed.add(this),ep.set(this,void 0),ef.set(this,void 0),em.set(this,void 0),eX(this,ep,e,"f")}static createResponse(e,t,s){let n=new nd(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())),eK(this,ed,"m",eg).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))eK(this,ed,"m",e_).call(this,r,i);if(n.controller.signal?.aborted)throw new eY;return eK(this,ed,"m",ew).call(this)}[(ep=new WeakMap,ef=new WeakMap,em=new WeakMap,ed=new WeakSet,eg=function(){this.ended||eX(this,ef,void 0,"f")},e_=function(e,t){if(this.ended)return;let s=(e,s)=>{(null==t||s.sequence_number>t)&&this._emit(e,s)},n=eK(this,ed,"m",ey).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 eG(`missing output at index ${e.output_index}`);if("message"===t.type){let n=t.content[e.content_index];if(!n)throw new eG(`missing content at index ${e.content_index}`);if("output_text"!==n.type)throw new eG(`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 eG(`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)}},ew=function(){if(this.ended)throw new eG("stream has ended, this shouldn't happen");let e=eK(this,ef,"f");if(!e)throw new eG("request ended without sending any events");eX(this,ef,void 0,"f");let t=function(e,t){var s;return t&&(s=t,si(s.text?.format))?nu(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,eK(this,ep,"f"));return eX(this,em,t,"f"),t},ey=function(e){let t=eK(this,ef,"f");if(!t){if("response.created"!==e.type)throw new eG(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return eX(this,ef,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 eG(`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 eG(`missing output at index ${e.output_index}`);if("message"===s.type){let t=s.content[e.content_index];if(!t)throw new eG(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new eG(`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 eG(`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 eG(`missing output at index ${e.output_index}`);if("reasoning"===s.type){let t=s.content?.[e.content_index];if(!t)throw new eG(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new eG(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":eX(this,ef,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=eK(this,em,"f");if(!e)throw new eG("stream ended without producing a ChatCompletion");return e}}class np extends t7{list(e,t={},s){return this._client.getAPIList(ss`/responses/${e}/input_items`,tJ,{query:t,...s})}}class nf extends t7{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class nm extends t7{constructor(){super(...arguments),this.inputItems=new np(this._client),this.inputTokens=new nf(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&&nh(e),e))}retrieve(e,t={},s){return this._client.get(ss`/responses/${e}`,{query:t,...s,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&nh(e),e))}delete(e,t){return this._client.delete(ss`/responses/${e}`,{...t,headers:sI([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>nu(t,e))}stream(e,t){return nd.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(ss`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}nm.InputItems=np,nm.InputTokens=nf;class ng extends t7{retrieve(e,t){return this._client.get(ss`/skills/${e}/content`,{...t,headers:sI([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class n_ extends t7{retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(ss`/skills/${n}/versions/${e}/content`,{...s,headers:sI([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class nw extends t7{constructor(){super(...arguments),this.content=new n_(this._client)}create(e,t={},s){return this._client.post(ss`/skills/${e}/versions`,tZ({body:t,...s},this._client))}retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(ss`/skills/${n}/versions/${e}`,s)}list(e,t={},s){return this._client.getAPIList(ss`/skills/${e}/versions`,tJ,{query:t,...s})}delete(e,t,s){let{skill_id:n}=t;return this._client.delete(ss`/skills/${n}/versions/${e}`,s)}}nw.Content=n_;class ny extends t7{constructor(){super(...arguments),this.content=new ng(this._client),this.versions=new nw(this._client)}create(e={},t){return this._client.post("/skills",tZ({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ss`/skills/${e}`,t)}update(e,t,s){return this._client.post(ss`/skills/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/skills",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/skills/${e}`,t)}}ny.Content=ng,ny.Versions=nw;class nb extends t7{create(e,t,s){return this._client.post(ss`/uploads/${e}/parts`,t0({body:t,...s},this._client))}}class nv extends t7{constructor(){super(...arguments),this.parts=new nb(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(ss`/uploads/${e}/cancel`,t)}complete(e,t,s){return this._client.post(ss`/uploads/${e}/complete`,{body:t,...s})}}nv.Parts=nb;let nx=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 nS extends t7{create(e,t,s){return this._client.post(ss`/vector_stores/${e}/file_batches`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(ss`/vector_stores/${n}/file_batches/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{vector_store_id:n}=t;return this._client.post(ss`/vector_stores/${n}/file_batches/${e}/cancel`,{...s,headers:sI([{"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(ss`/vector_stores/${n}/file_batches/${e}/files`,tJ,{query:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async poll(e,t,s){let n=sI([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 to(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 nx(c),await this.createAndPoll(e,{file_ids:o})}}class n$ extends t7{create(e,t,s){return this._client.post(ss`/vector_stores/${e}/files`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(ss`/vector_stores/${n}/files/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{vector_store_id:n,...r}=t;return this._client.post(ss`/vector_stores/${n}/files/${e}`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(ss`/vector_stores/${e}/files`,tJ,{query:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{vector_store_id:n}=t;return this._client.delete(ss`/vector_stores/${n}/files/${e}`,{...s,headers:sI([{"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=sI([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 to(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(ss`/vector_stores/${n}/files/${e}/content`,tK,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class nA extends t7{constructor(){super(...arguments),this.files=new n$(this._client),this.fileBatches=new nS(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ss`/vector_stores/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(ss`/vector_stores/${e}`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",tJ,{query:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(ss`/vector_stores/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,s){return this._client.getAPIList(ss`/vector_stores/${e}/search`,tK,{body:t,method:"post",...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}nA.Files=n$,nA.FileBatches=nS;class nR extends t7{create(e,t){return this._client.post("/videos",tZ({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ss`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",tV,{query:e,...t})}delete(e,t){return this._client.delete(ss`/videos/${e}`,t)}downloadContent(e,t={},s){return this._client.get(ss`/videos/${e}/content`,{query:t,...s,headers:sI([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}remix(e,t,s){return this._client.post(ss`/videos/${e}/remix`,tZ({body:t,...s},this._client))}}class nI extends t7{constructor(){super(...arguments),eb.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");eK(this,eb,"m",ev).call(this,s);let r=sI([t]).values,i=eK(this,eb,"m",ex).call(this,r,"webhook-signature"),a=eK(this,eb,"m",ex).call(this,r,"webhook-timestamp"),o=eK(this,eb,"m",ex).call(this,r,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new tt("Invalid webhook timestamp format");let c=Math.floor(Date.now()/1e3);if(c-l>n)throw new tt("Webhook timestamp is too old");if(l>c+n)throw new tt("Webhook timestamp is too new");let u=i.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),h=s.startsWith("whsec_")?Buffer.from(s.replace("whsec_",""),"base64"):Buffer.from(s,"utf-8"),d=o?`${o}.${a}.${e}`:`${a}.${e}`,p=await crypto.subtle.importKey("raw",h,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let e of u)try{let t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",p,t,new TextEncoder().encode(d)))return}catch{continue}throw new tt("The given webhook signature does not match the expected signature")}}eb=new WeakSet,ev=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")},ex=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 nO{constructor({baseURL:e=sU("OPENAI_BASE_URL"),apiKey:t=sU("OPENAI_API_KEY"),organization:s=sU("OPENAI_ORG_ID")??null,project:n=sU("OPENAI_PROJECT_ID")??null,webhookSecret:r=sU("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(eS.add(this),eA.set(this,void 0),this.completions=new sJ(this),this.chat=new sA(this),this.embeddings=new sZ(this),this.files=new s4(this),this.images=new nr(this),this.audio=new sP(this),this.moderations=new na(this),this.models=new ni(this),this.fineTuning=new nt(this),this.graders=new nn(this),this.vectorStores=new nA(this),this.webhooks=new nI(this),this.beta=new sK(this),this.batches=new sC(this),this.uploads=new nv(this),this.responses=new nm(this),this.realtime=new nc(this),this.conversations=new sY(this),this.evals=new s2(this),this.containers=new sG(this),this.skills=new ny(this),this.videos=new nR(this),void 0===t)throw new eG("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??e$.DEFAULT_TIMEOUT,this.logger=a.logger??console;const o="warn";this.logLevel=o,this.logLevel=tE(a.logLevel,"ClientOptions.logLevel",this)??tE(sU("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`")}(),eX(this,eA,tm,"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 sI([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e,t={}){let s,n=e,r=function(e=t$){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||t$.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=tg;if(void 0!==e.format){if(!ty(tw,e.format))throw TypeError("Unknown format option provided.");n=e.format}let r=tw[n],i=t$.filter;if(("function"==typeof e.filter||tn(e.filter))&&(i=e.filter),t=e.arrayFormat&&e.arrayFormat in tx?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":t$.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||t$.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:t$.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:t$.allowEmptyArrays,arrayFormat:t,charset:s,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:t$.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?t$.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:t$.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:t$.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:t$.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:t$.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:t$.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:t$.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:t$.strictNullHandling}}(t);"function"==typeof r.filter?n=(0,r.filter)("",n):tn(r.filter)&&(s=r.filter);let i=[];if("object"!=typeof n||null===n)return"";let a=tx[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]||tS(i,function e(t,s,n,r,i,a,o,l,c,u,h,d,p,f,m,g,_,w){var y,b;let v,x=t,S=w,$=0,A=!1;for(;void 0!==(S=S.get(tA))&&!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(tA)&&($=0)}if("function"==typeof u?x=u(s,x):x instanceof Date?x=p?.(x):"comma"===n&&tn(x)&&(x=tv(x,function(e){return e instanceof Date?p?.(e):e})),null===x){if(a)return c&&!g?c(s,t$.encoder,_,"key",f):s;x=""}if("string"==typeof(y=x)||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||(b=x)&&"object"==typeof b&&b.constructor&&b.constructor.isBuffer&&b.constructor.isBuffer(b)){if(c){let e=g?s:c(s,t$.encoder,_,"key",f);return[m?.(e)+"="+m?.(c(x,t$.encoder,_,"value",f))]}return[m?.(s)+"="+m?.(String(x))]}let R=[];if(void 0===x)return R;if("comma"===n&&tn(x))g&&c&&(x=tv(x,c)),v=[{value:x.length>0?x.join(",")||null:void 0}];else if(tn(u))v=u;else{let e=Object.keys(x);v=h?e.sort(h):e}let I=l?String(s).replace(/\./g,"%2E"):String(s),O=r&&tn(x)&&1===x.length?I+"[]":I;if(i&&tn(x)&&0===x.length)return O+"[]";for(let s=0;s<v.length;++s){let y=v[s],b="object"==typeof y&&void 0!==y.value?y.value:x[y];if(o&&null===b)continue;let S=d&&l?y.replace(/\./g,"%2E"):y,A=tn(x)?"function"==typeof n?n(O,S):O:O+(d?"."+S:"["+S+"]");w.set(t,$);let I=new WeakMap;I.set(tA,w),tS(R,e(b,A,n,r,i,a,o,l,"comma"===n&&g&&tn(x)?null:c,u,h,d,p,f,m,g,_,I))}return R}(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),u=!0===r.addQueryPrefix?"?":"";return r.charsetSentinel&&("iso-8859-1"===r.charset?u+="utf8=%26%2310003%3B&":u+="utf8=%E2%9C%93&"),c.length>0?u+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${tl}`}defaultIdempotencyKey(){return`stainless-node-retry-${eJ()}`}makeStatusError(e,t,s,n){return eQ.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 eG)throw e;throw new eG(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof e||!e)throw new eG(`Expected 'apiKey' function argument to return a string but it returned ${e}`);return this.apiKey=e,!0}buildURL(e,t,s){let n=!eK(this,eS,"m",eR).call(this)&&s||this.baseURL,r=new URL(ts.test(e)?e:n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return!function(e){if(!e)return!0;for(let t in e)return!1;return!0}(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 tH(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}`,u=Date.now();if(tj(this).debug(`[${l}] sending request`,tM({retryOfRequestLogID:s,method:n.method,url:a,options:n,headers:i.headers})),n.signal?.aborted)throw new eY;let h=new AbortController,d=await this.fetchWithTimeout(a,i,o,h).catch(ez),p=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new eY;let r=eV(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return tj(this).info(`[${l}] connection ${r?"timed out":"failed"} - ${e}`),tj(this).debug(`[${l}] connection ${r?"timed out":"failed"} (${e})`,tM({retryOfRequestLogID:s,url:a,durationMs:p-u,message:d.message})),this.retryRequest(n,t,s??l);if(tj(this).info(`[${l}] connection ${r?"timed out":"failed"} - error; no more retries left`),tj(this).debug(`[${l}] connection ${r?"timed out":"failed"} (error; no more retries left)`,tM({retryOfRequestLogID:s,url:a,durationMs:p-u,message:d.message})),r)throw new e0;throw new eZ({cause:d})}let f=[...d.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${l}${c}${f}] ${i.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${p-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await tf(d.body),tj(this).info(`${m} - ${e}`),tj(this).debug(`[${l}] response error (${e})`,tM({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:p-u})),this.retryRequest(n,t,s??l,d.headers)}let r=e?"error; no more retries left":"error; not retryable";tj(this).info(`${m} - ${r}`);let i=await d.text().catch(e=>ez(e).message),a=(e=>{try{return JSON.parse(e)}catch(e){return}})(i),o=a?void 0:i;throw tj(this).debug(`[${l}] response error (${r})`,tM({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,message:o,durationMs:Date.now()-u})),this.makeStatusError(d.status,a,o,d.headers)}return tj(this).info(m),tj(this).debug(`[${l}] response start`,tM({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:p-u})),{response:d,options:n,controller:h,requestLogID:l,retryOfRequestLogID:s,startTime:u}}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 tX(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,u={signal:n.signal,...c?{duplex:"half"}:{},method:"GET",...a};i&&(u.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,u)}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 to(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&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eG(`${e} must be an integer`);if(t<0)throw new eG(`${e} must be a positive integer`)})("timeout",s.timeout),s.timeout=s.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:s}),u=await this.buildHeaders({options:e,method:n,bodyHeaders:l,retryCount:t});return{req:{method:n,headers:u,...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:s,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&"get"!==s&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let a=sI([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...t??(t=(()=>{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":tl,"X-Stainless-OS":tu(Deno.build.os),"X-Stainless-Arch":tc(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":tl,"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":tl,"X-Stainless-OS":tu(globalThis.process.platform??"unknown"),"X-Stainless-Arch":tc(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":tl,"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":tl,"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,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let s=sI([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:td(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)}:eK(this,eA,"f").call(this,{body:e,headers:s})}}e$=nO,eA=new WeakMap,eS=new WeakSet,eR=function(){return"https://api.openai.com/v1"!==this.baseURL},nO.OpenAI=e$,nO.DEFAULT_TIMEOUT=6e5,nO.OpenAIError=eG,nO.APIError=eQ,nO.APIConnectionError=eZ,nO.APIConnectionTimeoutError=e0,nO.APIUserAbortError=eY,nO.NotFoundError=e6,nO.ConflictError=e3,nO.RateLimitError=e5,nO.BadRequestError=e1,nO.AuthenticationError=e2,nO.InternalServerError=e9,nO.PermissionDeniedError=e4,nO.UnprocessableEntityError=e8,nO.InvalidWebhookSignatureError=tt,nO.toFile=t5,nO.Completions=sJ,nO.Chat=sA,nO.Embeddings=sZ,nO.Files=s4,nO.Images=nr,nO.Audio=sP,nO.Moderations=na,nO.Models=ni,nO.FineTuning=nt,nO.Graders=nn,nO.VectorStores=nA,nO.Webhooks=nI,nO.Beta=sK,nO.Batches=sC,nO.Uploads=nv,nO.Responses=nm,nO.Realtime=nc,nO.Conversations=sY,nO.Evals=s2,nO.Containers=sG,nO.Skills=ny,nO.Videos=nR;var nk=e.i(22734),nE=e.i(14747),nP=e.i(33405),nC=e.i(7367);let nT=null,nN=!1,nj={};async function nM(){if(nN)return nj;nN=!0;try{let e=nE.default.join((0,nC.getSlycodeRoot)(),".env");for(let t of(await nk.promises.readFile(e,"utf-8")).split("\n")){let e=t.match(/^([A-Z_]+)=(.+)$/);e&&(nj[e[1]]=e[2].trim(),process.env[e[1]]||(process.env[e[1]]=nj[e[1]]))}}catch{}return nj}async function nD(){if(!nT){let e=await nM(),t=process.env.OPENAI_API_KEY||e.OPENAI_API_KEY;if(!t)throw Error("OPENAI_API_KEY not configured");nT=new nO({apiKey:t})}return nT}function nL(e,t,s){return new Promise((n,r)=>{(0,nP.execFile)(e,t,s,(e,t,s)=>{e?r(Error(`${e.message}
8
+ ${sb(e)}`);return{...o,id:a,type:i,function:{...u,name:c,arguments:l}}})}}:{...i,message:{...c,content:a,role:u,refusal:t.refusal??null},finish_reason:s,index:n,logprobs:r}}),created:i,model:a,object:"chat.completion",...o?{system_fingerprint:o}:{}},t&&sl(t)?so(s,t):{...s,choices:s.choices.map(e=>(sc(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(e,eK(this,C,"f"))},q=function(){let e=eK(this,C,"f")?.response_format;return si(e)?e:null},U=function(e){var t,s,n,r;let i=eK(this,N,"f"),{choices:a,...o}=e;for(let{delta:a,finish_reason:l,index:c,logprobs:u=null,...h}of(i?Object.assign(i,o):i=eX(this,N,{...o,choices:[]},"f"),e.choices)){let e=i.choices[c];if(e||(e=i.choices[c]={finish_reason:l,index:c,message:{},logprobs:u,...h}),u)if(e.logprobs){let{content:n,refusal:r,...i}=u;sv(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({},u);if(l&&(e.finish_reason=l,eK(this,C,"f")&&sl(eK(this,C,"f")))){if("length"===l)throw new e7;if("content_filter"===l)throw new te}if(Object.assign(e,h),!a)continue;let{content:o,refusal:d,function_call:p,role:f,tool_calls:m,...g}=a;if(sv(g),Object.assign(e.message,g),d&&(e.message.refusal=(e.message.refusal||"")+d),f&&(e.message.role=f),p&&(e.message.function_call?(p.name&&(e.message.function_call.name=p.name),p.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=p.arguments)):e.message.function_call=p),o&&(e.message.content=(e.message.content||"")+o,!e.message.refusal&&eK(this,P,"m",q).call(this)&&(e.message.parsed=sw(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=>sr(e)&&e.function?.name===t.function.name);return sr(s)&&(sa(s)||s?.function.strict||!1)}(eK(this,C,"f"),o)&&(o.function.parsed_arguments=sw(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 tD(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function sb(e){return JSON.stringify(e)}function sv(e){}function sx(e){}class sS extends sy{static fromReadableStream(e){let t=new sS(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,s){let n=new sS(t),r={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,r)),n}}class s$ extends t7{constructor(){super(...arguments),this.messages=new sn(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(ss`/chat/completions/${e}`,t)}update(e,t,s){return this._client.post(ss`/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(ss`/chat/completions/${e}`,t)}parse(e,t){for(let t of e.tools??[]){if("function"!==t.type)throw new eG(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new eG(`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=>so(t,e))}runTools(e,t){return e.stream?sS.runTools(this._client,e,t):sf.runTools(this._client,e,t)}stream(e,t){return sy.createChatCompletion(this._client,e,t)}}s$.Messages=sn;class sA extends t7{constructor(){super(...arguments),this.completions=new s$(this._client)}}sA.Completions=s$,e.s([],98546);let sR=Symbol("brand.privateNullableHeaders"),sI=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(sR 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():tr(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=tr(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{[sR]:!0,values:t,nulls:s}};class sO extends t7{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:sI([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class sk extends t7{create(e,t){return this._client.post("/audio/transcriptions",t0({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class sE extends t7{create(e,t){return this._client.post("/audio/translations",t0({body:e,...t,__metadata:{model:e.model}},this._client))}}class sP extends t7{constructor(){super(...arguments),this.transcriptions=new sk(this._client),this.translations=new sE(this._client),this.speech=new sO(this._client)}}sP.Transcriptions=sk,sP.Translations=sE,sP.Speech=sO;class sC extends t7{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",tJ,{query:e,...t})}cancel(e,t){return this._client.post(ss`/batches/${e}/cancel`,t)}}class sT extends t7{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ss`/assistants/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(ss`/assistants/${e}`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",tJ,{query:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(ss`/assistants/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sN extends t7{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sj extends t7{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class sM extends t7{constructor(){super(...arguments),this.sessions=new sN(this._client),this.transcriptionSessions=new sj(this._client)}}sM.Sessions=sN,sM.TranscriptionSessions=sj;class sD extends t7{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(ss`/chatkit/sessions/${e}/cancel`,{...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class sL extends t7{retrieve(e,t){return this._client.get(ss`/chatkit/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",tV,{query:e,...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(ss`/chatkit/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},s){return this._client.getAPIList(ss`/chatkit/threads/${e}/items`,tV,{query:t,...s,headers:sI([{"OpenAI-Beta":"chatkit_beta=v1"},s?.headers])})}}class sB extends t7{constructor(){super(...arguments),this.sessions=new sD(this._client),this.threads=new sL(this._client)}}sB.Sessions=sD,sB.Threads=sL;class sW extends t7{create(e,t,s){return this._client.post(ss`/threads/${e}/messages`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(ss`/threads/${n}/messages/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(ss`/threads/${n}/messages/${e}`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(ss`/threads/${e}/messages`,tJ,{query:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{thread_id:n}=t;return this._client.delete(ss`/threads/${n}/messages/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class sq extends t7{retrieve(e,t,s){let{thread_id:n,run_id:r,...i}=t;return this._client.get(ss`/threads/${n}/runs/${r}/steps/${e}`,{query:i,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t,s){let{thread_id:n,...r}=t;return this._client.getAPIList(ss`/threads/${n}/runs/${e}/steps`,tJ,{query:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}let sU=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;class sH extends sd{constructor(){super(...arguments),H.add(this),X.set(this,[]),K.set(this,{}),J.set(this,{}),V.set(this,void 0),z.set(this,void 0),G.set(this,void 0),Q.set(this,void 0),Y.set(this,void 0),Z.set(this,void 0),ee.set(this,void 0),et.set(this,void 0),es.set(this,void 0)}[(X=new WeakMap,K=new WeakMap,J=new WeakMap,V=new WeakMap,z=new WeakMap,G=new WeakMap,Q=new WeakMap,Y=new WeakMap,Z=new WeakMap,ee=new WeakMap,et=new WeakMap,es=new WeakMap,H=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 F;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=tD.fromReadableStream(e,this.controller);for await(let e of n)eK(this,H,"m",en).call(this,e);if(n.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).call(this))}toReadableStream(){return new tD(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,s,n){let r=new F;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))eK(this,H,"m",en).call(this,e);if(a.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).call(this))}static createThreadAssistantStream(e,t,s){let n=new F;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 F;return r._run(()=>r._runAssistantStream(e,t,s,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}currentEvent(){return eK(this,ee,"f")}currentRun(){return eK(this,et,"f")}currentMessageSnapshot(){return eK(this,V,"f")}currentRunStepSnapshot(){return eK(this,es,"f")}async finalRunSteps(){return await this.done(),Object.values(eK(this,K,"f"))}async finalMessages(){return await this.done(),Object.values(eK(this,J,"f"))}async finalRun(){if(await this.done(),!eK(this,z,"f"))throw Error("Final run was not received.");return eK(this,z,"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))eK(this,H,"m",en).call(this,e);if(i.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).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))eK(this,H,"m",en).call(this,e);if(a.controller.signal?.aborted)throw new eY;return this._addRun(eK(this,H,"m",er).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(ta(t)&&ta(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(!ta(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)}}F=sH,en=function(e){if(!this.ended)switch(eX(this,ee,e,"f"),eK(this,H,"m",eo).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":eK(this,H,"m",eh).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":eK(this,H,"m",ea).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":eK(this,H,"m",ei).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},er=function(){if(this.ended)throw new eG("stream has ended, this shouldn't happen");if(!eK(this,z,"f"))throw Error("Final run has not been received");return eK(this,z,"f")},ei=function(e){let[t,s]=eK(this,H,"m",ec).call(this,e,eK(this,V,"f"));for(let e of(eX(this,V,t,"f"),eK(this,J,"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!=eK(this,G,"f")){if(eK(this,Q,"f"))switch(eK(this,Q,"f").type){case"text":this._emit("textDone",eK(this,Q,"f").text,eK(this,V,"f"));break;case"image_file":this._emit("imageFileDone",eK(this,Q,"f").image_file,eK(this,V,"f"))}eX(this,G,s.index,"f")}eX(this,Q,t.content[s.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==eK(this,G,"f")){let t=e.data.content[eK(this,G,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,eK(this,V,"f"));break;case"text":this._emit("textDone",t.text,eK(this,V,"f"))}}eK(this,V,"f")&&this._emit("messageDone",e.data),eX(this,V,void 0,"f")}},ea=function(e){let t=eK(this,H,"m",el).call(this,e);switch(eX(this,es,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==eK(this,Y,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(eK(this,Z,"f")&&this._emit("toolCallDone",eK(this,Z,"f")),eX(this,Y,e.index,"f"),eX(this,Z,t.step_details.tool_calls[e.index],"f"),eK(this,Z,"f")&&this._emit("toolCallCreated",eK(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":eX(this,es,void 0,"f"),"tool_calls"==e.data.step_details.type&&eK(this,Z,"f")&&(this._emit("toolCallDone",eK(this,Z,"f")),eX(this,Z,void 0,"f")),this._emit("runStepDone",e.data,t)}},eo=function(e){eK(this,X,"f").push(e),this._emit("event",e)},el=function(e){switch(e.event){case"thread.run.step.created":return eK(this,K,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=eK(this,K,"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=F.accumulateDelta(t,s.delta);eK(this,K,"f")[e.data.id]=n}return eK(this,K,"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":eK(this,K,"f")[e.data.id]=e.data}if(eK(this,K,"f")[e.data.id])return eK(this,K,"f")[e.data.id];throw Error("No snapshot available")},ec=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]=eK(this,H,"m",eu).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")},eu=function(e,t){return F.accumulateDelta(t,e)},eh=function(e){switch(eX(this,et,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":eX(this,z,e.data,"f"),eK(this,Z,"f")&&(this._emit("toolCallDone",eK(this,Z,"f")),eX(this,Z,void 0,"f"))}};class sF extends t7{constructor(){super(...arguments),this.steps=new sq(this._client)}create(e,t,s){let{include:n,...r}=t;return this._client.post(ss`/threads/${e}/runs`,{query:{include:n},body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1})}retrieve(e,t,s){let{thread_id:n}=t;return this._client.get(ss`/threads/${n}/runs/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{thread_id:n,...r}=t;return this._client.post(ss`/threads/${n}/runs/${e}`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(ss`/threads/${e}/runs`,tJ,{query:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{thread_id:n}=t;return this._client.post(ss`/threads/${n}/runs/${e}/cancel`,{...s,headers:sI([{"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 sH.createAssistantStream(e,this._client.beta.threads.runs,t,s)}async poll(e,t,s){let n=sI([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 to(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return r}}}stream(e,t,s){return sH.createAssistantStream(e,this._client.beta.threads.runs,t,s)}submitToolOutputs(e,t,s){let{thread_id:n,...r}=t;return this._client.post(ss`/threads/${n}/runs/${e}/submit_tool_outputs`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:t.stream??!1})}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 sH.createToolAssistantStream(e,this._client.beta.threads.runs,t,s)}}sF.Steps=sq;class sX extends t7{constructor(){super(...arguments),this.runs=new sF(this._client),this.messages=new sW(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ss`/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(ss`/threads/${e}`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t){return this._client.delete(ss`/threads/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1})}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 sH.createThreadAssistantStream(e,this._client.beta.threads,t)}}sX.Runs=sF,sX.Messages=sW;class sK extends t7{constructor(){super(...arguments),this.realtime=new sM(this._client),this.chatkit=new sB(this._client),this.assistants=new sT(this._client),this.threads=new sX(this._client)}}sK.Realtime=sM,sK.ChatKit=sB,sK.Assistants=sT,sK.Threads=sX;class sJ extends t7{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class sV extends t7{retrieve(e,t,s){let{container_id:n}=t;return this._client.get(ss`/containers/${n}/files/${e}/content`,{...s,headers:sI([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class sz extends t7{constructor(){super(...arguments),this.content=new sV(this._client)}create(e,t,s){return this._client.post(ss`/containers/${e}/files`,tZ({body:t,...s},this._client))}retrieve(e,t,s){let{container_id:n}=t;return this._client.get(ss`/containers/${n}/files/${e}`,s)}list(e,t={},s){return this._client.getAPIList(ss`/containers/${e}/files`,tJ,{query:t,...s})}delete(e,t,s){let{container_id:n}=t;return this._client.delete(ss`/containers/${n}/files/${e}`,{...s,headers:sI([{Accept:"*/*"},s?.headers])})}}sz.Content=sV;class sG extends t7{constructor(){super(...arguments),this.files=new sz(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/containers/${e}`,{...t,headers:sI([{Accept:"*/*"},t?.headers])})}}sG.Files=sz;class sQ extends t7{create(e,t,s){let{include:n,...r}=t;return this._client.post(ss`/conversations/${e}/items`,{query:{include:n},body:r,...s})}retrieve(e,t,s){let{conversation_id:n,...r}=t;return this._client.get(ss`/conversations/${n}/items/${e}`,{query:r,...s})}list(e,t={},s){return this._client.getAPIList(ss`/conversations/${e}/items`,tV,{query:t,...s})}delete(e,t,s){let{conversation_id:n}=t;return this._client.delete(ss`/conversations/${n}/items/${e}`,s)}}class sY extends t7{constructor(){super(...arguments),this.items=new sQ(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/conversations/${e}`,t)}update(e,t,s){return this._client.post(ss`/conversations/${e}`,{body:t,...s})}delete(e,t){return this._client.delete(ss`/conversations/${e}`,t)}}sY.Items=sQ;class sZ extends t7{create(e,t){let s=!!e.encoding_format,n=s?e.encoding_format:"base64";s&&tj(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:(tj(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 s0 extends t7{retrieve(e,t,s){let{eval_id:n,run_id:r}=t;return this._client.get(ss`/evals/${n}/runs/${r}/output_items/${e}`,s)}list(e,t,s){let{eval_id:n,...r}=t;return this._client.getAPIList(ss`/evals/${n}/runs/${e}/output_items`,tJ,{query:r,...s})}}class s1 extends t7{constructor(){super(...arguments),this.outputItems=new s0(this._client)}create(e,t,s){return this._client.post(ss`/evals/${e}/runs`,{body:t,...s})}retrieve(e,t,s){let{eval_id:n}=t;return this._client.get(ss`/evals/${n}/runs/${e}`,s)}list(e,t={},s){return this._client.getAPIList(ss`/evals/${e}/runs`,tJ,{query:t,...s})}delete(e,t,s){let{eval_id:n}=t;return this._client.delete(ss`/evals/${n}/runs/${e}`,s)}cancel(e,t,s){let{eval_id:n}=t;return this._client.post(ss`/evals/${n}/runs/${e}`,s)}}s1.OutputItems=s0;class s2 extends t7{constructor(){super(...arguments),this.runs=new s1(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/evals/${e}`,t)}update(e,t,s){return this._client.post(ss`/evals/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/evals",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/evals/${e}`,t)}}s2.Runs=s1;class s4 extends t7{create(e,t){return this._client.post("/files",t0({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ss`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/files/${e}`,t)}content(e,t){return this._client.get(ss`/files/${e}/content`,{...t,headers:sI([{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 to(t),i=await this.retrieve(e),Date.now()-r>s)throw new e0({message:`Giving up on waiting for file ${e} to finish processing after ${s} milliseconds.`});return i}}class s6 extends t7{}class s3 extends t7{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 s8 extends t7{constructor(){super(...arguments),this.graders=new s3(this._client)}}s8.Graders=s3;class s5 extends t7{create(e,t,s){return this._client.getAPIList(ss`/fine_tuning/checkpoints/${e}/permissions`,tK,{body:t,method:"post",...s})}retrieve(e,t={},s){return this._client.get(ss`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...s})}delete(e,t,s){let{fine_tuned_model_checkpoint:n}=t;return this._client.delete(ss`/fine_tuning/checkpoints/${n}/permissions/${e}`,s)}}class s9 extends t7{constructor(){super(...arguments),this.permissions=new s5(this._client)}}s9.Permissions=s5;class s7 extends t7{list(e,t={},s){return this._client.getAPIList(ss`/fine_tuning/jobs/${e}/checkpoints`,tJ,{query:t,...s})}}class ne extends t7{constructor(){super(...arguments),this.checkpoints=new s7(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(ss`/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(ss`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},s){return this._client.getAPIList(ss`/fine_tuning/jobs/${e}/events`,tJ,{query:t,...s})}pause(e,t){return this._client.post(ss`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(ss`/fine_tuning/jobs/${e}/resume`,t)}}ne.Checkpoints=s7;class nt extends t7{constructor(){super(...arguments),this.methods=new s6(this._client),this.jobs=new ne(this._client),this.checkpoints=new s9(this._client),this.alpha=new s8(this._client)}}nt.Methods=s6,nt.Jobs=ne,nt.Checkpoints=s9,nt.Alpha=s8;class ns extends t7{}class nn extends t7{constructor(){super(...arguments),this.graderModels=new ns(this._client)}}nn.GraderModels=ns;class nr extends t7{createVariation(e,t){return this._client.post("/images/variations",t0({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",t0({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 ni extends t7{retrieve(e,t){return this._client.get(ss`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",tK,e)}delete(e,t){return this._client.delete(ss`/models/${e}`,t)}}class na extends t7{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class no extends t7{accept(e,t,s){return this._client.post(ss`/realtime/calls/${e}/accept`,{body:t,...s,headers:sI([{Accept:"*/*"},s?.headers])})}hangup(e,t){return this._client.post(ss`/realtime/calls/${e}/hangup`,{...t,headers:sI([{Accept:"*/*"},t?.headers])})}refer(e,t,s){return this._client.post(ss`/realtime/calls/${e}/refer`,{body:t,...s,headers:sI([{Accept:"*/*"},s?.headers])})}reject(e,t={},s){return this._client.post(ss`/realtime/calls/${e}/reject`,{body:t,...s,headers:sI([{Accept:"*/*"},s?.headers])})}}class nl extends t7{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class nc extends t7{constructor(){super(...arguments),this.clientSecrets=new nl(this._client),this.calls=new no(this._client)}}function nu(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")||nh(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 nh(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("")}nc.ClientSecrets=nl,nc.Calls=no;class nd extends sd{constructor(e){super(),ed.add(this),ep.set(this,void 0),ef.set(this,void 0),em.set(this,void 0),eX(this,ep,e,"f")}static createResponse(e,t,s){let n=new nd(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())),eK(this,ed,"m",eg).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))eK(this,ed,"m",e_).call(this,r,i);if(n.controller.signal?.aborted)throw new eY;return eK(this,ed,"m",ew).call(this)}[(ep=new WeakMap,ef=new WeakMap,em=new WeakMap,ed=new WeakSet,eg=function(){this.ended||eX(this,ef,void 0,"f")},e_=function(e,t){if(this.ended)return;let s=(e,s)=>{(null==t||s.sequence_number>t)&&this._emit(e,s)},n=eK(this,ed,"m",ey).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 eG(`missing output at index ${e.output_index}`);if("message"===t.type){let n=t.content[e.content_index];if(!n)throw new eG(`missing content at index ${e.content_index}`);if("output_text"!==n.type)throw new eG(`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 eG(`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)}},ew=function(){if(this.ended)throw new eG("stream has ended, this shouldn't happen");let e=eK(this,ef,"f");if(!e)throw new eG("request ended without sending any events");eX(this,ef,void 0,"f");let t=function(e,t){var s;return t&&(s=t,si(s.text?.format))?nu(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,eK(this,ep,"f"));return eX(this,em,t,"f"),t},ey=function(e){let t=eK(this,ef,"f");if(!t){if("response.created"!==e.type)throw new eG(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return eX(this,ef,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 eG(`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 eG(`missing output at index ${e.output_index}`);if("message"===s.type){let t=s.content[e.content_index];if(!t)throw new eG(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new eG(`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 eG(`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 eG(`missing output at index ${e.output_index}`);if("reasoning"===s.type){let t=s.content?.[e.content_index];if(!t)throw new eG(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new eG(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":eX(this,ef,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=eK(this,em,"f");if(!e)throw new eG("stream ended without producing a ChatCompletion");return e}}class np extends t7{list(e,t={},s){return this._client.getAPIList(ss`/responses/${e}/input_items`,tJ,{query:t,...s})}}class nf extends t7{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class nm extends t7{constructor(){super(...arguments),this.inputItems=new np(this._client),this.inputTokens=new nf(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&&nh(e),e))}retrieve(e,t={},s){return this._client.get(ss`/responses/${e}`,{query:t,...s,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&nh(e),e))}delete(e,t){return this._client.delete(ss`/responses/${e}`,{...t,headers:sI([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>nu(t,e))}stream(e,t){return nd.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(ss`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}nm.InputItems=np,nm.InputTokens=nf;class ng extends t7{retrieve(e,t){return this._client.get(ss`/skills/${e}/content`,{...t,headers:sI([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class n_ extends t7{retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(ss`/skills/${n}/versions/${e}/content`,{...s,headers:sI([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}}class nw extends t7{constructor(){super(...arguments),this.content=new n_(this._client)}create(e,t={},s){return this._client.post(ss`/skills/${e}/versions`,tZ({body:t,...s},this._client))}retrieve(e,t,s){let{skill_id:n}=t;return this._client.get(ss`/skills/${n}/versions/${e}`,s)}list(e,t={},s){return this._client.getAPIList(ss`/skills/${e}/versions`,tJ,{query:t,...s})}delete(e,t,s){let{skill_id:n}=t;return this._client.delete(ss`/skills/${n}/versions/${e}`,s)}}nw.Content=n_;class ny extends t7{constructor(){super(...arguments),this.content=new ng(this._client),this.versions=new nw(this._client)}create(e={},t){return this._client.post("/skills",tZ({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ss`/skills/${e}`,t)}update(e,t,s){return this._client.post(ss`/skills/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/skills",tJ,{query:e,...t})}delete(e,t){return this._client.delete(ss`/skills/${e}`,t)}}ny.Content=ng,ny.Versions=nw;class nb extends t7{create(e,t,s){return this._client.post(ss`/uploads/${e}/parts`,t0({body:t,...s},this._client))}}class nv extends t7{constructor(){super(...arguments),this.parts=new nb(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(ss`/uploads/${e}/cancel`,t)}complete(e,t,s){return this._client.post(ss`/uploads/${e}/complete`,{body:t,...s})}}nv.Parts=nb;let nx=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 nS extends t7{create(e,t,s){return this._client.post(ss`/vector_stores/${e}/file_batches`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(ss`/vector_stores/${n}/file_batches/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(e,t,s){let{vector_store_id:n}=t;return this._client.post(ss`/vector_stores/${n}/file_batches/${e}/cancel`,{...s,headers:sI([{"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(ss`/vector_stores/${n}/file_batches/${e}/files`,tJ,{query:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async poll(e,t,s){let n=sI([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 to(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 nx(c),await this.createAndPoll(e,{file_ids:o})}}class n$ extends t7{create(e,t,s){return this._client.post(ss`/vector_stores/${e}/files`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(e,t,s){let{vector_store_id:n}=t;return this._client.get(ss`/vector_stores/${n}/files/${e}`,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(e,t,s){let{vector_store_id:n,...r}=t;return this._client.post(ss`/vector_stores/${n}/files/${e}`,{body:r,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e,t={},s){return this._client.getAPIList(ss`/vector_stores/${e}/files`,tJ,{query:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(e,t,s){let{vector_store_id:n}=t;return this._client.delete(ss`/vector_stores/${n}/files/${e}`,{...s,headers:sI([{"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=sI([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 to(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(ss`/vector_stores/${n}/files/${e}/content`,tK,{...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}class nA extends t7{constructor(){super(...arguments),this.files=new n$(this._client),this.fileBatches=new nS(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(ss`/vector_stores/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,s){return this._client.post(ss`/vector_stores/${e}`,{body:t,...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",tJ,{query:e,...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(ss`/vector_stores/${e}`,{...t,headers:sI([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,s){return this._client.getAPIList(ss`/vector_stores/${e}/search`,tK,{body:t,method:"post",...s,headers:sI([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}}nA.Files=n$,nA.FileBatches=nS;class nR extends t7{create(e,t){return this._client.post("/videos",tZ({body:e,...t},this._client))}retrieve(e,t){return this._client.get(ss`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",tV,{query:e,...t})}delete(e,t){return this._client.delete(ss`/videos/${e}`,t)}downloadContent(e,t={},s){return this._client.get(ss`/videos/${e}/content`,{query:t,...s,headers:sI([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}remix(e,t,s){return this._client.post(ss`/videos/${e}/remix`,tZ({body:t,...s},this._client))}}class nI extends t7{constructor(){super(...arguments),eb.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");eK(this,eb,"m",ev).call(this,s);let r=sI([t]).values,i=eK(this,eb,"m",ex).call(this,r,"webhook-signature"),a=eK(this,eb,"m",ex).call(this,r,"webhook-timestamp"),o=eK(this,eb,"m",ex).call(this,r,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new tt("Invalid webhook timestamp format");let c=Math.floor(Date.now()/1e3);if(c-l>n)throw new tt("Webhook timestamp is too old");if(l>c+n)throw new tt("Webhook timestamp is too new");let u=i.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),h=s.startsWith("whsec_")?Buffer.from(s.replace("whsec_",""),"base64"):Buffer.from(s,"utf-8"),d=o?`${o}.${a}.${e}`:`${a}.${e}`,p=await crypto.subtle.importKey("raw",h,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let e of u)try{let t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",p,t,new TextEncoder().encode(d)))return}catch{continue}throw new tt("The given webhook signature does not match the expected signature")}}eb=new WeakSet,ev=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")},ex=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 nO{constructor({baseURL:e=sU("OPENAI_BASE_URL"),apiKey:t=sU("OPENAI_API_KEY"),organization:s=sU("OPENAI_ORG_ID")??null,project:n=sU("OPENAI_PROJECT_ID")??null,webhookSecret:r=sU("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(eS.add(this),eA.set(this,void 0),this.completions=new sJ(this),this.chat=new sA(this),this.embeddings=new sZ(this),this.files=new s4(this),this.images=new nr(this),this.audio=new sP(this),this.moderations=new na(this),this.models=new ni(this),this.fineTuning=new nt(this),this.graders=new nn(this),this.vectorStores=new nA(this),this.webhooks=new nI(this),this.beta=new sK(this),this.batches=new sC(this),this.uploads=new nv(this),this.responses=new nm(this),this.realtime=new nc(this),this.conversations=new sY(this),this.evals=new s2(this),this.containers=new sG(this),this.skills=new ny(this),this.videos=new nR(this),void 0===t)throw new eG("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??e$.DEFAULT_TIMEOUT,this.logger=a.logger??console;const o="warn";this.logLevel=o,this.logLevel=tE(a.logLevel,"ClientOptions.logLevel",this)??tE(sU("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`")}(),eX(this,eA,tm,"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 sI([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e,t={}){let s,n=e,r=function(e=t$){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||t$.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=tg;if(void 0!==e.format){if(!ty(tw,e.format))throw TypeError("Unknown format option provided.");n=e.format}let r=tw[n],i=t$.filter;if(("function"==typeof e.filter||tn(e.filter))&&(i=e.filter),t=e.arrayFormat&&e.arrayFormat in tx?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":t$.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||t$.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:t$.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:t$.allowEmptyArrays,arrayFormat:t,charset:s,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:t$.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?t$.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:t$.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:t$.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:t$.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:t$.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:t$.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:t$.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:t$.strictNullHandling}}(t);"function"==typeof r.filter?n=(0,r.filter)("",n):tn(r.filter)&&(s=r.filter);let i=[];if("object"!=typeof n||null===n)return"";let a=tx[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]||tS(i,function e(t,s,n,r,i,a,o,l,c,u,h,d,p,f,m,g,_,w){var y,b;let v,x=t,S=w,$=0,A=!1;for(;void 0!==(S=S.get(tA))&&!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(tA)&&($=0)}if("function"==typeof u?x=u(s,x):x instanceof Date?x=p?.(x):"comma"===n&&tn(x)&&(x=tv(x,function(e){return e instanceof Date?p?.(e):e})),null===x){if(a)return c&&!g?c(s,t$.encoder,_,"key",f):s;x=""}if("string"==typeof(y=x)||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||(b=x)&&"object"==typeof b&&b.constructor&&b.constructor.isBuffer&&b.constructor.isBuffer(b)){if(c){let e=g?s:c(s,t$.encoder,_,"key",f);return[m?.(e)+"="+m?.(c(x,t$.encoder,_,"value",f))]}return[m?.(s)+"="+m?.(String(x))]}let R=[];if(void 0===x)return R;if("comma"===n&&tn(x))g&&c&&(x=tv(x,c)),v=[{value:x.length>0?x.join(",")||null:void 0}];else if(tn(u))v=u;else{let e=Object.keys(x);v=h?e.sort(h):e}let I=l?String(s).replace(/\./g,"%2E"):String(s),O=r&&tn(x)&&1===x.length?I+"[]":I;if(i&&tn(x)&&0===x.length)return O+"[]";for(let s=0;s<v.length;++s){let y=v[s],b="object"==typeof y&&void 0!==y.value?y.value:x[y];if(o&&null===b)continue;let S=d&&l?y.replace(/\./g,"%2E"):y,A=tn(x)?"function"==typeof n?n(O,S):O:O+(d?"."+S:"["+S+"]");w.set(t,$);let I=new WeakMap;I.set(tA,w),tS(R,e(b,A,n,r,i,a,o,l,"comma"===n&&g&&tn(x)?null:c,u,h,d,p,f,m,g,_,I))}return R}(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),u=!0===r.addQueryPrefix?"?":"";return r.charsetSentinel&&("iso-8859-1"===r.charset?u+="utf8=%26%2310003%3B&":u+="utf8=%E2%9C%93&"),c.length>0?u+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${tl}`}defaultIdempotencyKey(){return`stainless-node-retry-${eJ()}`}makeStatusError(e,t,s,n){return eQ.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 eG)throw e;throw new eG(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof e||!e)throw new eG(`Expected 'apiKey' function argument to return a string but it returned ${e}`);return this.apiKey=e,!0}buildURL(e,t,s){let n=!eK(this,eS,"m",eR).call(this)&&s||this.baseURL,r=new URL(ts.test(e)?e:n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return!function(e){if(!e)return!0;for(let t in e)return!1;return!0}(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 tH(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}`,u=Date.now();if(tj(this).debug(`[${l}] sending request`,tM({retryOfRequestLogID:s,method:n.method,url:a,options:n,headers:i.headers})),n.signal?.aborted)throw new eY;let h=new AbortController,d=await this.fetchWithTimeout(a,i,o,h).catch(ez),p=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new eY;let r=eV(d)||/timed? ?out/i.test(String(d)+("cause"in d?String(d.cause):""));if(t)return tj(this).info(`[${l}] connection ${r?"timed out":"failed"} - ${e}`),tj(this).debug(`[${l}] connection ${r?"timed out":"failed"} (${e})`,tM({retryOfRequestLogID:s,url:a,durationMs:p-u,message:d.message})),this.retryRequest(n,t,s??l);if(tj(this).info(`[${l}] connection ${r?"timed out":"failed"} - error; no more retries left`),tj(this).debug(`[${l}] connection ${r?"timed out":"failed"} (error; no more retries left)`,tM({retryOfRequestLogID:s,url:a,durationMs:p-u,message:d.message})),r)throw new e0;throw new eZ({cause:d})}let f=[...d.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${l}${c}${f}] ${i.method} ${a} ${d.ok?"succeeded":"failed"} with status ${d.status} in ${p-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await tf(d.body),tj(this).info(`${m} - ${e}`),tj(this).debug(`[${l}] response error (${e})`,tM({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:p-u})),this.retryRequest(n,t,s??l,d.headers)}let r=e?"error; no more retries left":"error; not retryable";tj(this).info(`${m} - ${r}`);let i=await d.text().catch(e=>ez(e).message),a=(e=>{try{return JSON.parse(e)}catch(e){return}})(i),o=a?void 0:i;throw tj(this).debug(`[${l}] response error (${r})`,tM({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,message:o,durationMs:Date.now()-u})),this.makeStatusError(d.status,a,o,d.headers)}return tj(this).info(m),tj(this).debug(`[${l}] response start`,tM({retryOfRequestLogID:s,url:d.url,status:d.status,headers:d.headers,durationMs:p-u})),{response:d,options:n,controller:h,requestLogID:l,retryOfRequestLogID:s,startTime:u}}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 tX(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,u={signal:n.signal,...c?{duplex:"half"}:{},method:"GET",...a};i&&(u.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,u)}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 to(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&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eG(`${e} must be an integer`);if(t<0)throw new eG(`${e} must be a positive integer`)})("timeout",s.timeout),s.timeout=s.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:s}),u=await this.buildHeaders({options:e,method:n,bodyHeaders:l,retryCount:t});return{req:{method:n,headers:u,...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:s,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&"get"!==s&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let a=sI([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...t??(t=(()=>{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":tl,"X-Stainless-OS":tu(Deno.build.os),"X-Stainless-Arch":tc(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":tl,"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":tl,"X-Stainless-OS":tu(globalThis.process.platform??"unknown"),"X-Stainless-Arch":tc(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":tl,"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":tl,"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,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let s=sI([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:td(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)}:eK(this,eA,"f").call(this,{body:e,headers:s})}}e$=nO,eA=new WeakMap,eS=new WeakSet,eR=function(){return"https://api.openai.com/v1"!==this.baseURL},nO.OpenAI=e$,nO.DEFAULT_TIMEOUT=6e5,nO.OpenAIError=eG,nO.APIError=eQ,nO.APIConnectionError=eZ,nO.APIConnectionTimeoutError=e0,nO.APIUserAbortError=eY,nO.NotFoundError=e6,nO.ConflictError=e3,nO.RateLimitError=e5,nO.BadRequestError=e1,nO.AuthenticationError=e2,nO.InternalServerError=e9,nO.PermissionDeniedError=e4,nO.UnprocessableEntityError=e8,nO.InvalidWebhookSignatureError=tt,nO.toFile=t5,nO.Completions=sJ,nO.Chat=sA,nO.Embeddings=sZ,nO.Files=s4,nO.Images=nr,nO.Audio=sP,nO.Moderations=na,nO.Models=ni,nO.FineTuning=nt,nO.Graders=nn,nO.VectorStores=nA,nO.Webhooks=nI,nO.Beta=sK,nO.Batches=sC,nO.Uploads=nv,nO.Responses=nm,nO.Realtime=nc,nO.Conversations=sY,nO.Evals=s2,nO.Containers=sG,nO.Skills=ny,nO.Videos=nR;var nk=e.i(22734),nE=e.i(14747),nP=e.i(33405),nC=e.i(7367);let nT=null,nN=!1,nj={};async function nM(){if(nN)return nj;nN=!0;try{let e=nE.default.join((0,nC.getSlycodeRoot)(),".env");for(let t of(await nk.promises.readFile(e,"utf-8")).split("\n")){let e=t.match(/^([A-Z_]+)=(.+)$/);e&&(nj[e[1]]=e[2].trim(),process.env[e[1]]||(process.env[e[1]]=nj[e[1]]))}}catch{}return nj}async function nD(){if(!nT){let e=await nM(),t=process.env.OPENAI_API_KEY||e.OPENAI_API_KEY;if(!t)throw Error("OPENAI_API_KEY not configured");nT=new nO({apiKey:t})}return nT}function nL(e,t,s){return new Promise((n,r)=>{(0,nP.execFile)(e,t,{...s,windowsHide:!0},(e,t,s)=>{e?r(Error(`${e.message}
9
9
  ${s}`)):n("string"==typeof t?t:String(t))})})}async function nB(e,t,s,n){let r=process.env.TMPDIR||"/tmp",i=nE.default.join(r,`whisper_${Date.now()}.${t}`),a=i.replace(/\.[^.]+$/,".wav");try{return await nk.promises.writeFile(i,e),await nL("ffmpeg",["-i",i,"-ar","16000","-ac","1","-y",a],{timeout:3e4}),(await nL(s,["-m",n,"-f",a,"--no-timestamps","--output-txt"],{timeout:12e4,encoding:"utf-8"})).trim()}finally{await nk.promises.unlink(i).catch(()=>{}),await nk.promises.unlink(a).catch(()=>{})}}async function nW(e){try{let t,s=(await e.formData()).get("audio");if(!s||!(s instanceof Blob))return eF.NextResponse.json({error:'Missing "audio" file in form data'},{status:400});let n=Buffer.from(await s.arrayBuffer()),r=s.type.includes("mp4")?"mp4":s.type.includes("ogg")?"ogg":"webm",i=await nM(),a=process.env.STT_BACKEND||i.STT_BACKEND||"openai";if("local"===a){let e=process.env.WHISPER_CLI_PATH||i.WHISPER_CLI_PATH,t=process.env.WHISPER_MODEL_PATH||i.WHISPER_MODEL_PATH;if(!e||!t)return eF.NextResponse.json({error:"Local STT not configured: set WHISPER_CLI_PATH and WHISPER_MODEL_PATH"},{status:401});let s=await nB(n,r,e,t);return eF.NextResponse.json({text:s})}try{t=await nD()}catch{return eF.NextResponse.json({error:"OPENAI_API_KEY not configured"},{status:401})}let o=await t5(n,`recording.${r}`,{type:s.type}),l=await t.audio.transcriptions.create({file:o,model:"whisper-1"});return eF.NextResponse.json({text:l.text})}catch(t){let e=t.message||"Transcription failed";return eF.NextResponse.json({error:e},{status:502})}}e.s(["POST",()=>nW],14779);var nq=e.i(14779);let nU=new eI.AppRouteRouteModule({definition:{kind:eO.RouteKind.APP_ROUTE,page:"/api/transcribe/route",pathname:"/api/transcribe",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/transcribe/route.ts",nextConfigOutput:"standalone",userland:nq}),{workAsyncStorage:nH,workUnitAsyncStorage:nF,serverHooks:nX}=nU;function nK(){return(0,ek.patchFetch)({workAsyncStorage:nH,workUnitAsyncStorage:nF})}async function nJ(e,t,s){nU.isDev&&(0,eE.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let n="/api/transcribe/route";n=n.replace(/\/index$/,"")||"/";let r=await nU.prepare(e,t,{srcPage:n,multiZoneDraftMode:!1});if(!r)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:i,params:a,nextConfig:o,parsedUrl:l,isDraftMode:c,prerenderManifest:u,routerServerContext:h,isOnDemandRevalidate:d,revalidateOnlyGenerated:p,resolvedPathname:f,clientReferenceManifest:m,serverActionsManifest:g}=r,_=(0,eT.normalizeAppPath)(n),w=!!(u.dynamicRoutes[_]||u.routes[f]),y=async()=>((null==h?void 0:h.render404)?await h.render404(e,t,l,!1):t.end("This page could not be found"),null);if(w&&!c){let e=!!u.routes[f],t=u.dynamicRoutes[_];if(t&&!1===t.fallback&&!e){if(o.experimental.adapterPath)return await y();throw new eU.NoFallbackError}}let b=null;!w||nU.isDev||c||(b="/index"===(b=f)?"/":b);let v=!0===nU.isDev||!w,x=w&&!v;g&&m&&(0,eC.setManifestsSingleton)({page:n,clientReferenceManifest:m,serverActionsManifest:g});let S=e.method||"GET",$=(0,eP.getTracer)(),A=$.getActiveScopeSpan(),R={params:a,prerenderManifest:u,renderOpts:{experimental:{authInterrupts:!!o.experimental.authInterrupts},cacheComponents:!!o.cacheComponents,supportsDynamicResponse:v,incrementalCache:(0,eE.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:o.cacheLife,waitUntil:s.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>nU.onRequestError(e,t,n,r,h)},sharedContext:{buildId:i}},I=new eN.NodeNextRequest(e),O=new eN.NodeNextResponse(t),k=ej.NextRequestAdapter.fromNodeNextRequest(I,(0,ej.signalFromNodeResponse)(t));try{let r=async e=>nU.handle(k,R).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=$.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==eM.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=s.get("next.route");if(r){let t=`${S} ${r}`;e.setAttributes({"next.route":r,"http.route":r,"next.span_name":t}),e.updateName(t)}else e.updateName(`${S} ${n}`)}),i=!!(0,eE.getRequestMeta)(e,"minimalMode"),a=async a=>{var l,f;let m=async({previousCacheEntry:o})=>{try{if(!i&&d&&p&&!o)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await r(a);e.fetchMetrics=R.renderOpts.fetchMetrics;let l=R.renderOpts.pendingWaitUntil;l&&s.waitUntil&&(s.waitUntil(l),l=void 0);let c=R.renderOpts.collectedTags;if(!w)return await (0,eL.sendResponse)(I,O,n,R.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,eB.toNodeOutgoingHttpHeaders)(n.headers);c&&(t[eq.NEXT_CACHE_TAGS_HEADER]=c),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==R.renderOpts.collectedRevalidate&&!(R.renderOpts.collectedRevalidate>=eq.INFINITE_CACHE)&&R.renderOpts.collectedRevalidate,r=void 0===R.renderOpts.collectedExpire||R.renderOpts.collectedExpire>=eq.INFINITE_CACHE?void 0:R.renderOpts.collectedExpire;return{value:{kind:eH.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:r}}}}catch(t){throw(null==o?void 0:o.isStale)&&await nU.onRequestError(e,t,{routerKind:"App Router",routePath:n,routeType:"route",revalidateReason:(0,eD.getRevalidateReason)({isStaticGeneration:x,isOnDemandRevalidate:d})},!1,h),t}},g=await nU.handleResponse({req:e,nextConfig:o,cacheKey:b,routeKind:eO.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:u,isRoutePPREnabled:!1,isOnDemandRevalidate:d,revalidateOnlyGenerated:p,responseGenerator:m,waitUntil:s.waitUntil,isMinimalMode:i});if(!w)return null;if((null==g||null==(l=g.value)?void 0:l.kind)!==eH.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==g||null==(f=g.value)?void 0:f.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",d?"REVALIDATED":g.isMiss?"MISS":g.isStale?"STALE":"HIT"),c&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let _=(0,eB.fromNodeOutgoingHttpHeaders)(g.value.headers);return i&&w||_.delete(eq.NEXT_CACHE_TAGS_HEADER),!g.cacheControl||t.getHeader("Cache-Control")||_.get("Cache-Control")||_.set("Cache-Control",(0,eW.getCacheControlHeader)(g.cacheControl)),await (0,eL.sendResponse)(I,O,new Response(g.value.body,{headers:_,status:g.value.status||200})),null};A?await a(A):await $.withPropagatedContext(e.headers,()=>$.trace(eM.BaseServerSpan.handleRequest,{spanName:`${S} ${n}`,kind:eP.SpanKind.SERVER,attributes:{"http.method":S,"http.target":e.url}},a))}catch(t){if(t instanceof eU.NoFallbackError||await nU.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,eD.getRevalidateReason)({isStaticGeneration:x,isOnDemandRevalidate:d})},!1,h),w)throw t;return await (0,eL.sendResponse)(I,O,new Response(null,{status:500})),null}}e.s(["handler",()=>nJ,"patchFetch",()=>nK,"routeModule",()=>nU,"serverHooks",()=>nX,"workAsyncStorage",()=>nH,"workUnitAsyncStorage",()=>nF],99567)}];
10
10
 
11
11
  //# sourceMappingURL=node_modules_next_dist_esm_build_templates_app-route_ffc6c790.js.map
@@ -1 +1 @@
1
- <!DOCTYPE html><!--cut_BpEHnH8_V_vl0UOOW--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/chunks/43bfca92afbacd38.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/chunks/f4999889f2006fea.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/5f95863347fe47d9.js"/><script src="/_next/static/chunks/7de9141b1af425c3.js" async=""></script><script src="/_next/static/chunks/ef0dc6461e9250d8.js" async=""></script><script src="/_next/static/chunks/turbopack-4964158913ad5e72.js" async=""></script><script src="/_next/static/chunks/0452f599128364c9.js" async=""></script><script src="/_next/static/chunks/e24d6768d85df882.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><title>404: This page could not be found.</title><title>SlyCode 🦊</title><meta name="description" content="SlyCode Managed Projects"/><link rel="icon" href="/favicon.png"/><script>(function(){try{var t=localStorage.getItem('slycode-theme');if(t==='light')return;if(t==='dark'||window.matchMedia('(prefers-color-scheme:dark)').matches)document.documentElement.classList.add('dark')}catch(e){}})()</script><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body class="geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable jetbrains_mono_7d65b77b-module__VxV-Ta__variable font-sans antialiased"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/5f95863347fe47d9.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[1088,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"VoiceProvider\"]\n3:I[39756,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"default\"]\n4:I[37457,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"default\"]\n5:I[97367,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"OutletBoundary\"]\n6:\"$Sreact.suspense\"\n8:I[97367,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"ViewportBoundary\"]\na:I[97367,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"MetadataBoundary\"]\nc:I[68027,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"default\"]\n:HL[\"/_next/static/chunks/43bfca92afbacd38.css\",\"style\"]\n:HL[\"/_next/static/chunks/f4999889f2006fea.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"cut-BpEHnH8_V_vl0UOOW\",\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/chunks/43bfca92afbacd38.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/chunks/f4999889f2006fea.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/0452f599128364c9.js\",\"async\":true,\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-1\",{\"src\":\"/_next/static/chunks/e24d6768d85df882.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"suppressHydrationWarning\":true,\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"(function(){try{var t=localStorage.getItem('slycode-theme');if(t==='light')return;if(t==='dark'||window.matchMedia('(prefers-color-scheme:dark)').matches)document.documentElement.classList.add('dark')}catch(e){}})()\"}}]}],[\"$\",\"body\",null,{\"className\":\"geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable jetbrains_mono_7d65b77b-module__VxV-Ta__variable font-sans antialiased\",\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:style\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style\",\"children\":404}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style\",\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L5\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@7\"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"d:I[27201,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"IconMark\"]\n7:null\nb:[[\"$\",\"title\",\"0\",{\"children\":\"SlyCode 🦊\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"SlyCode Managed Projects\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/favicon.png\"}],[\"$\",\"$Ld\",\"3\",{}]]\n"])</script></body></html>
1
+ <!DOCTYPE html><!--QUrfyJ4_tKEk_x5K_NIKK--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/chunks/43bfca92afbacd38.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/chunks/f4999889f2006fea.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/5f95863347fe47d9.js"/><script src="/_next/static/chunks/7de9141b1af425c3.js" async=""></script><script src="/_next/static/chunks/ef0dc6461e9250d8.js" async=""></script><script src="/_next/static/chunks/turbopack-4964158913ad5e72.js" async=""></script><script src="/_next/static/chunks/0452f599128364c9.js" async=""></script><script src="/_next/static/chunks/e24d6768d85df882.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><title>404: This page could not be found.</title><title>SlyCode 🦊</title><meta name="description" content="SlyCode Managed Projects"/><link rel="icon" href="/favicon.png"/><script>(function(){try{var t=localStorage.getItem('slycode-theme');if(t==='light')return;if(t==='dark'||window.matchMedia('(prefers-color-scheme:dark)').matches)document.documentElement.classList.add('dark')}catch(e){}})()</script><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body class="geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable jetbrains_mono_7d65b77b-module__VxV-Ta__variable font-sans antialiased"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/5f95863347fe47d9.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[1088,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"VoiceProvider\"]\n3:I[39756,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"default\"]\n4:I[37457,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"default\"]\n5:I[97367,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"OutletBoundary\"]\n6:\"$Sreact.suspense\"\n8:I[97367,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"ViewportBoundary\"]\na:I[97367,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"MetadataBoundary\"]\nc:I[68027,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"default\"]\n:HL[\"/_next/static/chunks/43bfca92afbacd38.css\",\"style\"]\n:HL[\"/_next/static/chunks/f4999889f2006fea.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"QUrfyJ4-tKEk_x5K_NIKK\",\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/chunks/43bfca92afbacd38.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/chunks/f4999889f2006fea.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/0452f599128364c9.js\",\"async\":true,\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-1\",{\"src\":\"/_next/static/chunks/e24d6768d85df882.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"suppressHydrationWarning\":true,\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"(function(){try{var t=localStorage.getItem('slycode-theme');if(t==='light')return;if(t==='dark'||window.matchMedia('(prefers-color-scheme:dark)').matches)document.documentElement.classList.add('dark')}catch(e){}})()\"}}]}],[\"$\",\"body\",null,{\"className\":\"geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable jetbrains_mono_7d65b77b-module__VxV-Ta__variable font-sans antialiased\",\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:style\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style\",\"children\":404}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:1:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style\",\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L5\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@7\"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$6\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"d:I[27201,[\"/_next/static/chunks/0452f599128364c9.js\",\"/_next/static/chunks/e24d6768d85df882.js\"],\"IconMark\"]\n7:null\nb:[[\"$\",\"title\",\"0\",{\"children\":\"SlyCode 🦊\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"SlyCode Managed Projects\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/favicon.png\"}],[\"$\",\"$Ld\",\"3\",{}]]\n"])</script></body></html>