vibe64 0.1.34 → 0.1.36

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 (207) hide show
  1. package/bin/run.js +1919 -1660
  2. package/bin/server.js +158 -111
  3. package/bin/upgrade-state.js +5783 -5605
  4. package/dist/assets/GithubBrowserTabs-BzJF4k9Y.js +1 -0
  5. package/dist/assets/{StudioErrorNotice-sQfmeR-z.js → StudioErrorNotice-BdllGqRy.js} +1 -1
  6. package/dist/assets/{Vibe64AsyncModuleState-Dx7YKRPp.js → Vibe64AsyncModuleState-Bi0TqlIu.js} +1 -1
  7. package/dist/assets/Vibe64AuthSettingsButton-BuvmwGiT.js +5 -0
  8. package/dist/assets/Vibe64AuthSettingsButton-M44SSmZ9.css +1 -0
  9. package/dist/assets/{Vibe64DashboardBackButton-yE6cyYg2.js → Vibe64DashboardBackButton-Ccd4hpD6.js} +1 -1
  10. package/dist/assets/Vibe64DashboardShell-D67m4aWz.js +1 -0
  11. package/dist/assets/{Vibe64DashboardShell-MBkUHjs-.css → Vibe64DashboardShell-De2mbdpI.css} +1 -1
  12. package/dist/assets/{Vibe64DatabaseWorkspace-BONJdxBS.js → Vibe64DatabaseWorkspace-D3uK1gDm.js} +3 -3
  13. package/dist/assets/{Vibe64DatabaseWorkspace-CR4pzzcf.css → Vibe64DatabaseWorkspace-DPDMxhAW.css} +1 -1
  14. package/dist/assets/Vibe64OutputControls-BfESn5kJ.js +8 -0
  15. package/dist/assets/Vibe64OutputControls-D2CCECo5.css +1 -0
  16. package/dist/assets/{Vibe64RepositoryWorkspace-ByQlZbyO.js → Vibe64RepositoryWorkspace-0jAxvdA8.js} +2 -2
  17. package/dist/assets/{Vibe64RepositoryWorkspace-CVHcT93M.css → Vibe64RepositoryWorkspace-Agyt4O-V.css} +1 -1
  18. package/dist/assets/Vibe64SessionFiles-B3ONZrBL.css +1 -0
  19. package/dist/assets/Vibe64SessionFiles-BCOJ4QmR.js +41 -0
  20. package/dist/assets/{Vibe64TemporaryAiFixAction-BGlcrq4d.js → Vibe64TemporaryAiFixAction-DM2jpPbQ.js} +1 -1
  21. package/dist/assets/{Vibe64UiStoryboardView-Brlwdvqi.js → Vibe64UiStoryboardView-DP5af46a.js} +1 -1
  22. package/dist/assets/{Vibe64UnavailableSessions-zwlWlcZD.js → Vibe64UnavailableSessions-C7XwH1SS.js} +1 -1
  23. package/dist/assets/{_sessionId_-CvOkQbVy.js → _sessionId_-B1Ymr7c_.js} +1 -1
  24. package/dist/assets/{_sessionTool_-Dwod5ns9.js → _sessionTool_-DVYdREoI.js} +1 -1
  25. package/dist/assets/_slug_-CQseA9pt.css +1 -0
  26. package/dist/assets/_slug_-CYO2vjCd.js +24 -0
  27. package/dist/assets/{access-BVu5XYm2.js → access-Cb7dkN53.js} +1 -1
  28. package/dist/assets/app-BvgY7oVf.js +1 -0
  29. package/dist/assets/app-CZu7oxUO.css +1 -0
  30. package/dist/assets/{assistantRouting-CwbwfkwB.js → assistantRouting-B38ujQ7x.js} +1 -1
  31. package/dist/assets/{changes-olY8cnFK.js → changes-lsBcuikn.js} +1 -1
  32. package/dist/assets/client-CRI5CNKl.js +2 -0
  33. package/dist/assets/client-TGaWwOhc.css +1 -0
  34. package/dist/assets/conversation-CDEt9jBx.js +17 -0
  35. package/dist/assets/conversation-vxJGwmtW.css +1 -0
  36. package/dist/assets/{dashboard-BnXD-H4R.js → dashboard-D8HOAw46.js} +1 -1
  37. package/dist/assets/definitions-DLTX17nI.js +1 -0
  38. package/dist/assets/{env-DJhnLOH7.css → env-BzRtyO0w.css} +1 -1
  39. package/dist/assets/env-DJezQixO.js +1 -0
  40. package/dist/assets/health-BJvooRnJ.css +1 -0
  41. package/dist/assets/health-CtKdN_Nf.js +1 -0
  42. package/dist/assets/{history-BxlpB-YH.js → history-BdZFOtz4.js} +1 -1
  43. package/dist/assets/{incoming-BOxRVlOM.js → incoming-VsQNnL9m.js} +1 -1
  44. package/dist/assets/index-C-osVUKw.css +1 -0
  45. package/dist/assets/index-C4K3ntms.js +138 -0
  46. package/dist/assets/{integrations-BFltGDVI.js → integrations-CMQ9EDmt.js} +2 -2
  47. package/dist/assets/issues-DHpY5hSr.js +1 -0
  48. package/dist/assets/learning-DXlMuwzh.js +1 -0
  49. package/dist/assets/mdi-yXT-CQ6u.js +1 -0
  50. package/dist/assets/placement-NpX2s7u8.js +1 -0
  51. package/dist/assets/pull-requests-BcKNEUYH.js +1 -0
  52. package/dist/assets/{repository-JWLVST3D.js → repository-ClEgntHW.js} +1 -1
  53. package/dist/assets/roboto-latin-wght-normal-ccAYIvAh.woff2 +0 -0
  54. package/dist/assets/{session-C5Nj8Dlq.js → session-BlD46q-d.js} +1 -1
  55. package/dist/assets/settings-BwukeIKe.js +1 -0
  56. package/dist/assets/shared-BM2SV6fi.js +2 -0
  57. package/dist/assets/studioGateApi-DcCqiD9V.js +1 -0
  58. package/dist/assets/studioUrls-DmMMIScP.js +1 -0
  59. package/dist/assets/useArchivedVibe64Sessions-D5zUA-BC.js +1 -0
  60. package/dist/assets/useCommand-Bqxb-naz.js +1 -0
  61. package/dist/assets/useEndpointResource-DWoQ2keu.js +1 -0
  62. package/dist/assets/useRealtimeEvent-Bwapstla.js +1 -0
  63. package/dist/assets/{useUiFeedback-0FqKuZRP.js → useUiFeedback-BPBF_0bp.js} +1 -1
  64. package/dist/assets/useVibe64ConversationLog-Dy6YTPQn.js +1 -0
  65. package/dist/assets/useVibe64DatabaseTools-d6L09ugW.js +1 -0
  66. package/dist/assets/useVibe64Learning-cNKTv64W.js +1 -0
  67. package/dist/assets/useVibe64ProjectScope-Bp1ImZlz.js +1 -0
  68. package/dist/assets/useVibe64SessionData-C_jqncih.js +1 -0
  69. package/dist/assets/useVibe64SessionSelection-uCEIWd3b.js +1 -0
  70. package/dist/assets/useVibe64SystemGraph-B4RmsC9Y.js +1 -0
  71. package/dist/assets/{useVibe64Terminal-BPnN25WH.js → useVibe64Terminal-BbghGR4x.js} +1 -1
  72. package/dist/assets/vibe64AssistantHost-BL1bnKm8.js +1 -0
  73. package/dist/assets/{vibe64SessionFocus-kqPOPaOH.js → vibe64SessionFocus-DSJKVuRN.js} +1 -1
  74. package/dist/assets/{vibe64SessionInfo-BHxtTrLX.js → vibe64SessionInfo-B_r1OMN0.js} +1 -1
  75. package/dist/assets/{vibe64SessionPanelModel-BMf64fv7.js → vibe64SessionPanelModel-DDorOuiL.js} +1 -1
  76. package/dist/assets/{vibe64SessionToolDefinitions-NfLd1HZI.js → vibe64SessionToolDefinitions-BualCK_5.js} +1 -1
  77. package/dist/index.html +21 -20
  78. package/docs/colleague-usage/account-profile-and-appearance.md +8 -2
  79. package/docs/colleague-usage/ai-accounts-and-routing.md +123 -15
  80. package/docs/colleague-usage/ai-onboarding.md +230 -0
  81. package/docs/colleague-usage/coding-agent-goal-pause.md +5 -5
  82. package/docs/colleague-usage/coding-agents.md +17 -0
  83. package/docs/colleague-usage/colleague-watches.md +4 -23
  84. package/docs/colleague-usage/colleague.md +10 -2
  85. package/docs/colleague-usage/connected-projects.md +2 -2
  86. package/docs/colleague-usage/conversation-context.md +2 -0
  87. package/docs/colleague-usage/dashboard-navigation.md +19 -27
  88. package/docs/colleague-usage/database.md +6 -11
  89. package/docs/colleague-usage/development-copies.md +2 -1
  90. package/docs/colleague-usage/development-env.md +6 -0
  91. package/docs/colleague-usage/github-work.md +9 -0
  92. package/docs/colleague-usage/health-checks.md +11 -5
  93. package/docs/colleague-usage/integrations.md +3 -1
  94. package/docs/colleague-usage/learning-code-questions.md +23 -51
  95. package/docs/colleague-usage/learning-course-catalogue.md +8 -6
  96. package/docs/colleague-usage/learning-environment.md +345 -0
  97. package/docs/colleague-usage/learning-history.md +70 -101
  98. package/docs/colleague-usage/learning-mode-ui.md +122 -214
  99. package/docs/colleague-usage/learning-practice-projects.md +168 -78
  100. package/docs/colleague-usage/learning-teacher-guide.md +48 -26
  101. package/docs/colleague-usage/learning-with-colleague.md +171 -216
  102. package/docs/colleague-usage/lesson-authoring.md +32 -24
  103. package/docs/colleague-usage/managed-app-access.md +7 -0
  104. package/docs/colleague-usage/message-delivery-recovery.md +7 -6
  105. package/docs/colleague-usage/preview-browser-checks.md +9 -1
  106. package/docs/colleague-usage/preview-starting-application.md +0 -1
  107. package/docs/colleague-usage/preview.md +9 -1
  108. package/docs/colleague-usage/project-messages.md +2 -2
  109. package/docs/colleague-usage/project-setup.md +9 -2
  110. package/docs/colleague-usage/running-vibe64-on-your-computer.md +61 -0
  111. package/docs/colleague-usage/sessions.md +25 -33
  112. package/docs/colleague-usage/teaching-content.md +11 -40
  113. package/docs/colleague-usage/temporary-chats.md +23 -2
  114. package/docs/colleague-usage/voice-chat.md +5 -10
  115. package/docs/colleague-usage/voice-face-and-speaking-voice.md +6 -8
  116. package/docs/colleague-usage/voice-recovery.md +3 -2
  117. package/docs/templates/learn-topic/README.md +6 -6
  118. package/docs/templates/learn-topic/training/lessons/TOPIC-01/lesson.json +28 -7
  119. package/docs/templates/learn-topic/training/lessons/TOPIC-01/notes.md +19 -0
  120. package/docs/templates/learn-topic/training/lessons/TOPIC-01/steps/check-understanding.md +3 -0
  121. package/docs/templates/learn-topic/training/lessons/TOPIC-01/steps/explain-idea.md +3 -0
  122. package/docs/templates/learn-topic/training/lessons/TOPIC-01/steps/try-it.md +3 -0
  123. package/docs/templates/learn-topic/training/outline.md +1 -1
  124. package/docs/training-content.md +179 -65
  125. package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
  126. package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
  127. package/node_modules/@jskit-ai/assistant-runtime/patterns/assistant-surface/PATTERN.md +3 -2
  128. package/node_modules/@jskit-ai/assistant-runtime/patterns/assistant-surface/example/integrations.json +3 -2
  129. package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
  130. package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
  131. package/node_modules/@jskit-ai/connectors-catalog/patterns/ai-connections/PATTERN.md +4 -3
  132. package/node_modules/@jskit-ai/connectors-catalog/src/shared/ai-models.json +0 -1
  133. package/node_modules/@local/vibe64-accounts/package.json +1 -0
  134. package/node_modules/@local/vibe64-colleague/package.json +2 -1
  135. package/node_modules/@local/vibe64-core/package.json +3 -0
  136. package/node_modules/@local/vibe64-execution/package.json +1 -0
  137. package/node_modules/@local/vibe64-execution/src/server/engines/stdioBridge.js +9 -9
  138. package/node_modules/@local/vibe64-genesis/README.md +10 -37
  139. package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +790 -779
  140. package/node_modules/@local/vibe64-genesis/package.json +1 -0
  141. package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +255 -0
  142. package/node_modules/@local/vibe64-genesis/src/server/index.js +473 -450
  143. package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +148 -148
  144. package/node_modules/@local/vibe64-project/package.json +2 -1
  145. package/node_modules/@local/vibe64-runtime/package.json +1 -2
  146. package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +526 -512
  147. package/node_modules/@local/vibe64-runtime/src/shared/assistantRoutingScores.json +0 -1
  148. package/node_modules/@local/vibe64-source-editor/package.json +1 -0
  149. package/node_modules/@local/vibe64-terminals/package.json +1 -0
  150. package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +129 -131
  151. package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1508 -1456
  152. package/node_modules/@local/vibe64-training/package.json +13 -27
  153. package/package.json +7 -7
  154. package/server.bundle.mjs +40946 -41456
  155. package/dist/assets/GithubBrowserTabs-DO5PHon-.js +0 -1
  156. package/dist/assets/GithubMarkdown-BQ6MfCDJ.js +0 -3
  157. package/dist/assets/GithubMarkdown-U7-j-qNI.css +0 -1
  158. package/dist/assets/Vibe64DashboardShell-CuCVMhOc.js +0 -1
  159. package/dist/assets/Vibe64OutputControls-DAAmA09l.js +0 -8
  160. package/dist/assets/Vibe64OutputControls-DPBsyDZM.css +0 -1
  161. package/dist/assets/Vibe64SessionFiles-B0u9HKdF.js +0 -107
  162. package/dist/assets/Vibe64SessionFiles-NjOMVwPR.css +0 -1
  163. package/dist/assets/_slug_-B31c15cc.css +0 -1
  164. package/dist/assets/_slug_-Dy35qLo1.js +0 -1
  165. package/dist/assets/app-DRXCcv05.css +0 -1
  166. package/dist/assets/app-zt7HwQKT.js +0 -1
  167. package/dist/assets/client-BrV4QPwG.js +0 -2
  168. package/dist/assets/client-C1bwIlu6.css +0 -1
  169. package/dist/assets/definitions-DaOPIkyB.js +0 -1
  170. package/dist/assets/env-DN0vW4EI.js +0 -1
  171. package/dist/assets/health-7oIQODer.css +0 -1
  172. package/dist/assets/health-Z6m96GDr.js +0 -1
  173. package/dist/assets/index-BUq-MczL.js +0 -86
  174. package/dist/assets/index-DtmBqE3h.css +0 -1
  175. package/dist/assets/issues-1iS5zoed.js +0 -1
  176. package/dist/assets/layout-BkWVNT37.js +0 -1
  177. package/dist/assets/mdi-C54lQ0i_.js +0 -1
  178. package/dist/assets/placement-DLsU3pCW.js +0 -1
  179. package/dist/assets/pull-requests-BJOwNL4k.js +0 -1
  180. package/dist/assets/settings-c273Ikrm.js +0 -1
  181. package/dist/assets/shared-YZb7ocaK.js +0 -2
  182. package/dist/assets/studioGateApi-DhA9IJGZ.js +0 -1
  183. package/dist/assets/studioUrls-Dj8rXeXO.js +0 -1
  184. package/dist/assets/useArchivedVibe64Sessions-CVZx2Rtm.js +0 -1
  185. package/dist/assets/useCommand-DWuxfAV0.js +0 -1
  186. package/dist/assets/useEndpointResource-MWVNfmMa.js +0 -1
  187. package/dist/assets/useVibe64ConversationLog-8cKh1eDm.js +0 -1
  188. package/dist/assets/useVibe64DatabaseTools-BcRG1s3i.js +0 -1
  189. package/dist/assets/useVibe64LearningMode-Bl0dGdCh.js +0 -28
  190. package/dist/assets/useVibe64LearningMode-C3PcXdVg.css +0 -1
  191. package/dist/assets/useVibe64ProjectScope-DOEVkBqX.js +0 -1
  192. package/dist/assets/useVibe64SessionData-DFTyLzci.js +0 -1
  193. package/dist/assets/useVibe64SessionSelection-j9lsllx4.js +0 -1
  194. package/dist/assets/useVibe64SystemGraph-tNkIwSBQ.js +0 -1
  195. package/dist/assets/vibe64AssistantHost-DdE_-lZF.js +0 -1
  196. package/dist/assets/vibe64LessonDashboard-DlKYjisq.js +0 -1
  197. package/dist/assets/vibe64ProjectScope.local-DqT6e5un.js +0 -1
  198. package/docs/colleague-usage/learning-chat-retention.md +0 -74
  199. package/docs/colleague-usage/learning-diagrams-and-voice.md +0 -97
  200. package/docs/colleague-usage/learning-lesson-watch.md +0 -95
  201. package/docs/colleague-usage/learning-native-session.md +0 -206
  202. package/docs/colleague-usage/learning-practical-exercises.md +0 -71
  203. package/docs/colleague-usage/learning-practical-gestures.md +0 -48
  204. package/docs/colleague-usage/learning-session-creation.md +0 -95
  205. package/docs/colleague-usage/lesson-practical-assessment.md +0 -54
  206. package/docs/colleague-usage/preview-lesson-presentation.md +0 -56
  207. package/docs/templates/learn-topic/training/lessons/TOPIC-01/lesson.md +0 -44
@@ -1,31 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
3
- var Vs=Object.create;var Zr=Object.defineProperty;var Gs=Object.getOwnPropertyDescriptor;var Ws=Object.getOwnPropertyNames;var Ks=Object.getPrototypeOf,Js=Object.prototype.hasOwnProperty;var N=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){
4
- if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var G=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Xs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ws(e))!Js.call(t,o)&&o!==r&&Zr(t,o,{get:()=>e[o],
5
- enumerable:!(n=Gs(e,o))||n.enumerable});return t};var ae=(t,e,r)=>(r=t!=null?Vs(Ks(t)):{},Xs(e||!t||!t.__esModule?Zr(r,"default",{value:t,enumerable:!0}):r,t));var te=G((dl,on)=>{"use strict";var rn=["nodebuffer","arraybuffer","fragments"],nn=typeof Blob<"u";nn&&rn.push("blob");on.
6
- exports={BINARY_TYPES:rn,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:nn,
3
+ var Xs=Object.create;var rn=Object.defineProperty;var Ys=Object.getOwnPropertyDescriptor;var Qs=Object.getOwnPropertyNames;var Zs=Object.getPrototypeOf,ei=Object.prototype.hasOwnProperty;var M=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){
4
+ if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var W=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var ti=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qs(e))!ei.call(t,o)&&o!==r&&rn(t,o,{get:()=>e[o],
5
+ enumerable:!(n=Ys(e,o))||n.enumerable});return t};var ae=(t,e,r)=>(r=t!=null?Xs(Zs(t)):{},ti(e||!t||!t.__esModule?rn(r,"default",{value:t,enumerable:!0}):r,t));var Z=W((wl,cn)=>{"use strict";var sn=["nodebuffer","arraybuffer","fragments"],an=typeof Blob<"u";an&&sn.push("blob");cn.
6
+ exports={BINARY_TYPES:sn,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:an,
7
7
  kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
8
- "websocket"),NOOP:()=>{}}});var $e=G((ul,nt)=>{"use strict";var{EMPTY_BUFFER:Qs}=te(),Ft=Buffer[Symbol.species];function Zs(t,e){if(t.length===0)return Qs;
8
+ "websocket"),NOOP:()=>{}}});var Ue=W((yl,ct)=>{"use strict";var{EMPTY_BUFFER:ni}=Z(),Vt=Buffer[Symbol.species];function oi(t,e){if(t.length===0)return ni;
9
9
  if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let o=0;o<t.length;o++){let s=t[o];r.set(s,n),n+=s.length}
10
- return n<e?new Ft(r.buffer,r.byteOffset,n):r}function sn(t,e,r,n,o){for(let s=0;s<o;s++)r[n+s]=t[s]^e[s&3]}function an(t,e){
11
- for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function ei(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
12
- t.byteOffset+t.length)}function $t(t){if($t.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
13
- e=new Ft(t):ArrayBuffer.isView(t)?e=new Ft(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),$t.readOnly=!1),e}nt.exports=
14
- {concat:Zs,mask:sn,toArrayBuffer:ei,toBuffer:$t,unmask:an};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=N("bufferutil");nt.
15
- exports.mask=function(e,r,n,o,s){s<48?sn(e,r,n,o,s):t.mask(e,r,n,o,s)},nt.exports.unmask=function(e,r){e.length<32?an(e,
16
- r):t.unmask(e,r)}}catch{}});var un=G((ll,dn)=>{"use strict";var cn=Symbol("kDone"),Ut=Symbol("kRun"),qt=class{constructor(e){this[cn]=()=>{this.pending--,
17
- this[Ut]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ut]()}[Ut](){if(this.pending!==
18
- this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[cn])}}};dn.exports=qt});var Ce=G((pl,hn)=>{"use strict";var Ue=N("zlib"),ln=$e(),ti=un(),{kStatusCode:pn}=te(),ri=Buffer[Symbol.species],ni=Buffer.
19
- from([0,0,255,255]),st=Symbol("permessage-deflate"),re=Symbol("total-length"),_e=Symbol("callback"),ce=Symbol("buffers"),
20
- Ae=Symbol("error"),ot,Bt=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this.
10
+ return n<e?new Vt(r.buffer,r.byteOffset,n):r}function dn(t,e,r,n,o){for(let s=0;s<o;s++)r[n+s]=t[s]^e[s&3]}function un(t,e){
11
+ for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function si(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
12
+ t.byteOffset+t.length)}function Gt(t){if(Gt.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
13
+ e=new Vt(t):ArrayBuffer.isView(t)?e=new Vt(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Gt.readOnly=!1),e}ct.exports=
14
+ {concat:oi,mask:dn,toArrayBuffer:si,toBuffer:Gt,unmask:un};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=M("bufferutil");ct.
15
+ exports.mask=function(e,r,n,o,s){s<48?dn(e,r,n,o,s):t.mask(e,r,n,o,s)},ct.exports.unmask=function(e,r){e.length<32?un(e,
16
+ r):t.unmask(e,r)}}catch{}});var fn=W((Il,pn)=>{"use strict";var ln=Symbol("kDone"),Wt=Symbol("kRun"),Kt=class{constructor(e){this[ln]=()=>{this.pending--,
17
+ this[Wt]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Wt]()}[Wt](){if(this.pending!==
18
+ this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ln])}}};pn.exports=Kt});var Oe=W((Sl,vn)=>{"use strict";var qe=M("zlib"),hn=Ue(),ii=fn(),{kStatusCode:mn}=Z(),ai=Buffer[Symbol.species],ci=Buffer.
19
+ from([0,0,255,255]),ut=Symbol("permessage-deflate"),ee=Symbol("total-length"),Ce=Symbol("callback"),ce=Symbol("buffers"),
20
+ Ee=Symbol("error"),dt,Jt=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this.
21
21
  _options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=
22
- null,this._inflate=null,this.params=null,!ot){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
23
- 10;ot=new ti(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
22
+ null,this._inflate=null,this.params=null,!dt){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
23
+ 10;dt=new ii(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
24
24
  (e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.
25
25
  serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=
26
26
  this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=
27
27
  this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this.
28
- _inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[_e];this._deflate.close(),this._deflate=
28
+ _inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ce];this._deflate.close(),this._deflate=
29
29
  null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,
30
30
  n=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===
31
31
  !1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits==
@@ -44,53 +44,53 @@ y a single value`);if(o=o[0],n==="client_max_window_bits"){if(o!==!0){let s=+o;i
44
44
  "${n}": ${o}`)}else if(n==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`I\
45
45
  nvalid value for parameter "${n}": ${o}`);o=s}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){
46
46
  if(o!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else throw new Error(`Unknown parameter "${n}"`);
47
- r[n]=o})}),e}decompress(e,r,n){ot.add(o=>{this._decompress(e,r,(s,i)=>{o(),n(s,i)})})}compress(e,r,n){ot.add(o=>{this._compress(
47
+ r[n]=o})}),e}decompress(e,r,n){dt.add(o=>{this._decompress(e,r,(s,i)=>{o(),n(s,i)})})}compress(e,r,n){dt.add(o=>{this._compress(
48
48
  e,r,(s,i)=>{o(),n(s,i)})})}_decompress(e,r,n){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_\
49
- window_bits`,i=typeof this.params[s]!="number"?Ue.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ue.createInflateRaw(
50
- {...this._options.zlibInflateOptions,windowBits:i}),this._inflate[st]=this,this._inflate[re]=0,this._inflate[ce]=[],this.
51
- _inflate.on("error",si),this._inflate.on("data",fn)}this._inflate[_e]=n,this._inflate.write(e),r&&this._inflate.write(ni),
52
- this._inflate.flush(()=>{let s=this._inflate[Ae];if(s){this._inflate.close(),this._inflate=null,n(s);return}let i=ln.concat(
53
- this._inflate[ce],this._inflate[re]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
54
- (this._inflate[re]=0,this._inflate[ce]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){
49
+ window_bits`,i=typeof this.params[s]!="number"?qe.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=qe.createInflateRaw(
50
+ {...this._options.zlibInflateOptions,windowBits:i}),this._inflate[ut]=this,this._inflate[ee]=0,this._inflate[ce]=[],this.
51
+ _inflate.on("error",ui),this._inflate.on("data",gn)}this._inflate[Ce]=n,this._inflate.write(e),r&&this._inflate.write(ci),
52
+ this._inflate.flush(()=>{let s=this._inflate[Ee];if(s){this._inflate.close(),this._inflate=null,n(s);return}let i=hn.concat(
53
+ this._inflate[ce],this._inflate[ee]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
54
+ (this._inflate[ee]=0,this._inflate[ce]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){
55
55
  let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
56
- Ue.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ue.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
57
- this._deflate[re]=0,this._deflate[ce]=[],this._deflate.on("data",oi)}this._deflate[_e]=n,this._deflate.write(e),this._deflate.
58
- flush(Ue.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=ln.concat(this._deflate[ce],this._deflate[re]);r&&(s=new ri(s.
59
- buffer,s.byteOffset,s.length-4)),this._deflate[_e]=null,this._deflate[re]=0,this._deflate[ce]=[],r&&this.params[`${o}_no\
60
- _context_takeover`]&&this._deflate.reset(),n(null,s)})}};hn.exports=Bt;function oi(t){this[ce].push(t),this[re]+=t.length}
61
- function fn(t){if(this[re]+=t.length,this[st]._maxPayload<1||this[re]<=this[st]._maxPayload){this[ce].push(t);return}this[Ae]=
62
- new RangeError("Max payload size exceeded"),this[Ae].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ae][pn]=1009,this.removeListener(
63
- "data",fn),this.reset()}function si(t){if(this[st]._inflate=null,this[Ae]){this[_e](this[Ae]);return}t[pn]=1007,this[_e](
64
- t)}});var Ee=G((fl,it)=>{"use strict";var{isUtf8:mn}=N("buffer"),{hasBlob:ii}=te(),ai=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
56
+ qe.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=qe.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
57
+ this._deflate[ee]=0,this._deflate[ce]=[],this._deflate.on("data",di)}this._deflate[Ce]=n,this._deflate.write(e),this._deflate.
58
+ flush(qe.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=hn.concat(this._deflate[ce],this._deflate[ee]);r&&(s=new ai(s.
59
+ buffer,s.byteOffset,s.length-4)),this._deflate[Ce]=null,this._deflate[ee]=0,this._deflate[ce]=[],r&&this.params[`${o}_no\
60
+ _context_takeover`]&&this._deflate.reset(),n(null,s)})}};vn.exports=Jt;function di(t){this[ce].push(t),this[ee]+=t.length}
61
+ function gn(t){if(this[ee]+=t.length,this[ut]._maxPayload<1||this[ee]<=this[ut]._maxPayload){this[ce].push(t);return}this[Ee]=
62
+ new RangeError("Max payload size exceeded"),this[Ee].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ee][mn]=1009,this.removeListener(
63
+ "data",gn),this.reset()}function ui(t){if(this[ut]._inflate=null,this[Ee]){this[Ce](this[Ee]);return}t[mn]=1007,this[Ce](
64
+ t)}});var Re=W((xl,lt)=>{"use strict";var{isUtf8:wn}=M("buffer"),{hasBlob:li}=Z(),pi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
65
65
  0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
66
- 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function ci(t){return t>=
67
- 1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Ht(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===
66
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function fi(t){return t>=
67
+ 1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Xt(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===
68
68
  0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){
69
69
  if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;
70
70
  r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&
71
- 240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function di(t){return ii&&typeof t=="o\
71
+ 240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function hi(t){return li&&typeof t=="o\
72
72
  bject"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]===
73
- "Blob"||t[Symbol.toStringTag]==="File")}it.exports={isBlob:di,isValidStatusCode:ci,isValidUTF8:Ht,tokenChars:ai};if(mn)it.
74
- exports.isValidUTF8=function(t){return t.length<24?Ht(t):mn(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=N("utf-8-validate");
75
- it.exports.isValidUTF8=function(e){return e.length<32?Ht(e):t(e)}}catch{}});var Jt=G((hl,xn)=>{"use strict";var{Writable:ui}=N("stream"),gn=Ce(),{BINARY_TYPES:li,EMPTY_BUFFER:vn,kStatusCode:pi,kWebSocket:fi}=te(),
76
- {concat:Vt,toArrayBuffer:hi,unmask:mi}=$e(),{isValidStatusCode:gi,isValidUTF8:wn}=Ee(),at=Buffer[Symbol.species],X=0,yn=1,
77
- In=2,Sn=3,Gt=4,Wt=5,ct=6,Kt=class extends ui{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
78
- void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||li[0],this._extensions=e.extensions||{},this._isServer=
73
+ "Blob"||t[Symbol.toStringTag]==="File")}lt.exports={isBlob:hi,isValidStatusCode:fi,isValidUTF8:Xt,tokenChars:pi};if(wn)lt.
74
+ exports.isValidUTF8=function(t){return t.length<24?Xt(t):wn(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=M("utf-8-validate");
75
+ lt.exports.isValidUTF8=function(e){return e.length<32?Xt(e):t(e)}}catch{}});var tr=W((Tl,_n)=>{"use strict";var{Writable:mi}=M("stream"),yn=Oe(),{BINARY_TYPES:gi,EMPTY_BUFFER:In,kStatusCode:vi,kWebSocket:wi}=Z(),
76
+ {concat:Yt,toArrayBuffer:yi,unmask:Ii}=Ue(),{isValidStatusCode:Si,isValidUTF8:Sn}=Re(),pt=Buffer[Symbol.species],J=0,xn=1,
77
+ Tn=2,bn=3,Qt=4,Zt=5,ft=6,er=class extends mi{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
78
+ void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||gi[0],this._extensions=e.extensions||{},this._isServer=
79
79
  !!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|
80
- 0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[fi]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
80
+ 0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[wi]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
81
81
  !1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=
82
- 0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=X}_write(e,r,n){
83
- if(this._opcode===8&&this._state==X)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
82
+ 0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=J}_write(e,r,n){
83
+ if(this._opcode===8&&this._state==J)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
84
84
  n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=
85
85
  e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this.
86
- _buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new at(n.buffer,n.byteOffset+
87
- e,n.length-e),new at(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],o=r.length-e;e>=n.length?
88
- r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new at(n.buffer,n.byteOffset+
89
- e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case X:this.getInfo(e);
90
- break;case yn:this.getPayloadLength16(e);break;case In:this.getPayloadLength64(e);break;case Sn:this.getMask();break;case Gt:
91
- this.getData(e);break;case Wt:case ct:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
86
+ _buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new pt(n.buffer,n.byteOffset+
87
+ e,n.length-e),new pt(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],o=r.length-e;e>=n.length?
88
+ r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new pt(n.buffer,n.byteOffset+
89
+ e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case J:this.getInfo(e);
90
+ break;case xn:this.getPayloadLength16(e);break;case Tn:this.getPayloadLength64(e);break;case bn:this.getMask();break;case Qt:
91
+ this.getData(e);break;case Zt:case ft:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
92
92
  2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be\
93
- clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[gn.extensionName]){
93
+ clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[yn.extensionName]){
94
94
  let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&
95
95
  128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let o=this.createError(RangeError,"\
96
96
  RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,
@@ -104,609 +104,623 @@ LOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcod
104
104
  ID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,
105
105
  this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(
106
106
  o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");
107
- e(o);return}this._payloadLength===126?this._state=yn:this._payloadLength===127?this._state=In:this.haveLength(e)}getPayloadLength16(e){
107
+ e(o);return}this._payloadLength===126?this._state=xn:this._payloadLength===127?this._state=Tn:this.haveLength(e)}getPayloadLength16(e){
108
108
  if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){
109
109
  if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let o=this.
110
110
  createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD\
111
111
  _LENGTH");e(o);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&
112
112
  this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>
113
113
  0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}
114
- this._masked?this._state=Sn:this._state=Gt}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
115
- 4),this._state=Gt}getData(e){let r=vn;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
114
+ this._masked?this._state=bn:this._state=Qt}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
115
+ 4),this._state=Qt}getData(e){let r=In;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
116
116
  return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
117
- mi(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
117
+ Ii(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
118
118
  let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}if(this.
119
- _compressed){this._state=Wt,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
120
- push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[gn.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return r(
119
+ _compressed){this._state=Zt,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
120
+ push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[yn.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return r(
121
121
  o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(
122
122
  RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(i);return}this._fragments.push(s)}
123
- this.dataMessage(r),this._state===X&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=X;return}let r=this._messageLength,
123
+ this.dataMessage(r),this._state===J&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=J;return}let r=this._messageLength,
124
124
  n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=
125
- [],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Vt(n,r):this._binaryType==="arraybuffer"?o=hi(Vt(n,r)):this.
126
- _binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=X):(this._state=
127
- ct,setImmediate(()=>{this.emit("message",o,!0),this._state=X,this.startLoop(e)}))}else{let o=Vt(n,r);if(!this._skipUTF8Validation&&
128
- !wn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===Wt||
129
- this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=X):(this._state=ct,setImmediate(()=>{this.emit("mess\
130
- age",o,!1),this._state=X,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
131
- emit("conclude",1005,vn),this.end();else{let n=e.readUInt16BE(0);if(!gi(n)){let s=this.createError(RangeError,`invalid s\
132
- tatus code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let o=new at(e.buffer,e.byteOffset+2,e.length-2);if(!this.
133
- _skipUTF8Validation&&!wn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(s);return}
134
- this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=X;return}this._allowSynchronousEvents?(this.emit(this._opcode===
135
- 9?"ping":"pong",e),this._state=X):(this._state=ct,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
136
- X,this.startLoop(r)}))}createError(e,r,n,o,s){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:
137
- r);return Error.captureStackTrace(i,this.createError),i.code=s,i[pi]=o,i}};xn.exports=Kt});var Qt=G((gl,_n)=>{"use strict";var{Duplex:ml}=N("stream"),{randomFillSync:vi}=N("crypto"),{types:{isUint8Array:wi}}=N("util"),
138
- Tn=Ce(),{EMPTY_BUFFER:yi,kWebSocket:Ii,NOOP:Si}=te(),{isBlob:Oe,isValidStatusCode:xi}=Ee(),{mask:bn,toBuffer:he}=$e(),Y=Symbol(
139
- "kByteLength"),Ti=Buffer.alloc(4),dt=8*1024,me,Re=dt,Q=0,bi=1,_i=2,Xt=class t{constructor(e,r,n){this._extensions=r||{},
125
+ [],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Yt(n,r):this._binaryType==="arraybuffer"?o=yi(Yt(n,r)):this.
126
+ _binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=J):(this._state=
127
+ ft,setImmediate(()=>{this.emit("message",o,!0),this._state=J,this.startLoop(e)}))}else{let o=Yt(n,r);if(!this._skipUTF8Validation&&
128
+ !Sn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===Zt||
129
+ this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=J):(this._state=ft,setImmediate(()=>{this.emit("mess\
130
+ age",o,!1),this._state=J,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
131
+ emit("conclude",1005,In),this.end();else{let n=e.readUInt16BE(0);if(!Si(n)){let s=this.createError(RangeError,`invalid s\
132
+ tatus code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let o=new pt(e.buffer,e.byteOffset+2,e.length-2);if(!this.
133
+ _skipUTF8Validation&&!Sn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(s);return}
134
+ this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=J;return}this._allowSynchronousEvents?(this.emit(this._opcode===
135
+ 9?"ping":"pong",e),this._state=J):(this._state=ft,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
136
+ J,this.startLoop(r)}))}createError(e,r,n,o,s){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:
137
+ r);return Error.captureStackTrace(i,this.createError),i.code=s,i[vi]=o,i}};_n.exports=er});var or=W((_l,En)=>{"use strict";var{Duplex:bl}=M("stream"),{randomFillSync:xi}=M("crypto"),{types:{isUint8Array:Ti}}=M("util"),
138
+ An=Oe(),{EMPTY_BUFFER:bi,kWebSocket:_i,NOOP:Ai}=Z(),{isBlob:Pe,isValidStatusCode:Ci}=Re(),{mask:Cn,toBuffer:me}=Ue(),X=Symbol(
139
+ "kByteLength"),Ei=Buffer.alloc(4),ht=8*1024,ge,ke=ht,Y=0,Oi=1,Ri=2,rr=class t{constructor(e,r,n){this._extensions=r||{},
140
140
  n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this.
141
- _bufferedBytes=0,this._queue=[],this._state=Q,this.onerror=Si,this[Ii]=void 0}static frame(e,r){let n,o=!1,s=2,i=!1;r.mask&&
142
- (n=r.maskBuffer||Ti,r.generateMask?r.generateMask(n):(Re===dt&&(me===void 0&&(me=Buffer.alloc(dt)),vi(me,0,dt),Re=0),n[0]=
143
- me[Re++],n[1]=me[Re++],n[2]=me[Re++],n[3]=me[Re++]),i=(n[0]|n[1]|n[2]|n[3])===0,s=6);let a;typeof e=="string"?(!r.mask||
144
- i)&&r[Y]!==void 0?a=r[Y]:(e=Buffer.from(e),a=e.length):(a=e.length,o=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
141
+ _bufferedBytes=0,this._queue=[],this._state=Y,this.onerror=Ai,this[_i]=void 0}static frame(e,r){let n,o=!1,s=2,i=!1;r.mask&&
142
+ (n=r.maskBuffer||Ei,r.generateMask?r.generateMask(n):(ke===ht&&(ge===void 0&&(ge=Buffer.alloc(ht)),xi(ge,0,ht),ke=0),n[0]=
143
+ ge[ke++],n[1]=ge[ke++],n[2]=ge[ke++],n[3]=ge[ke++]),i=(n[0]|n[1]|n[2]|n[3])===0,s=6);let a;typeof e=="string"?(!r.mask||
144
+ i)&&r[X]!==void 0?a=r[X]:(e=Buffer.from(e),a=e.length):(a=e.length,o=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
145
145
  a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(d[0]|=64),d[1]=c,
146
146
  c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),r.mask?(d[1]|=128,d[s-4]=n[0],d[s-3]=n[1],d[s-2]=
147
- n[2],d[s-1]=n[3],i?[d,e]:o?(bn(e,n,d,s,a),[d]):(bn(e,n,e,0,a),[d,e])):[d,e]}close(e,r,n,o){let s;if(e===void 0)s=yi;else{
148
- if(typeof e!="number"||!xi(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.
147
+ n[2],d[s-1]=n[3],i?[d,e]:o?(Cn(e,n,d,s,a),[d]):(Cn(e,n,e,0,a),[d,e])):[d,e]}close(e,r,n,o){let s;if(e===void 0)s=bi;else{
148
+ if(typeof e!="number"||!Ci(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.
149
149
  length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The m\
150
150
  essage must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof r=="string")s.write(
151
- r,2);else if(wi(r))s.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[Y]:s.
151
+ r,2);else if(Ti(r))s.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[X]:s.
152
152
  length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==
153
- Q?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,r,n){let o,s;if(typeof e=="string"?(o=Buffer.
154
- byteLength(e),s=!1):Oe(e)?(o=e.size,s=!1):(e=he(e),o=e.length,s=he.readOnly),o>125)throw new RangeError("The data size m\
155
- ust not be greater than 125 bytes");let i={[Y]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,
156
- opcode:9,readOnly:s,rsv1:!1};Oe(e)?this._state!==Q?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):
157
- this._state!==Q?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}pong(e,r,n){let o,s;if(typeof e=="\
158
- string"?(o=Buffer.byteLength(e),s=!1):Oe(e)?(o=e.size,s=!1):(e=he(e),o=e.length,s=he.readOnly),o>125)throw new RangeError(
159
- "The data size must not be greater than 125 bytes");let i={[Y]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this.
160
- _maskBuffer,opcode:10,readOnly:s,rsv1:!1};Oe(e)?this._state!==Q?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(
161
- e,!1,i,n):this._state!==Q?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}send(e,r,n){let o=this._extensions[Tn.
162
- extensionName],s=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Oe(e)?(a=e.size,c=!1):(e=
163
- he(e),a=e.length,c=he.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_contex\
153
+ Y?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,r,n){let o,s;if(typeof e=="string"?(o=Buffer.
154
+ byteLength(e),s=!1):Pe(e)?(o=e.size,s=!1):(e=me(e),o=e.length,s=me.readOnly),o>125)throw new RangeError("The data size m\
155
+ ust not be greater than 125 bytes");let i={[X]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,
156
+ opcode:9,readOnly:s,rsv1:!1};Pe(e)?this._state!==Y?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):
157
+ this._state!==Y?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}pong(e,r,n){let o,s;if(typeof e=="\
158
+ string"?(o=Buffer.byteLength(e),s=!1):Pe(e)?(o=e.size,s=!1):(e=me(e),o=e.length,s=me.readOnly),o>125)throw new RangeError(
159
+ "The data size must not be greater than 125 bytes");let i={[X]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this.
160
+ _maskBuffer,opcode:10,readOnly:s,rsv1:!1};Pe(e)?this._state!==Y?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(
161
+ e,!1,i,n):this._state!==Y?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}send(e,r,n){let o=this._extensions[An.
162
+ extensionName],s=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Pe(e)?(a=e.size,c=!1):(e=
163
+ me(e),a=e.length,c=me.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_contex\
164
164
  t_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),r.fin&&(this._firstFragment=
165
- !0);let d={[Y]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
166
- Oe(e)?this._state!==Q?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this.
167
- _state!==Q?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,r,n,o){this.
168
- _bufferedBytes+=n[Y],this._state=_i,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was \
169
- closed while the blob was being read");process.nextTick(Yt,this,a,o);return}this._bufferedBytes-=n[Y];let i=he(s);r?this.
170
- dispatch(i,r,n,o):(this._state=Q,this.sendFrame(t.frame(i,n),o),this.dequeue())}).catch(s=>{process.nextTick(Ai,this,s,o)})}dispatch(e,r,n,o){
171
- if(!r){this.sendFrame(t.frame(e,n),o);return}let s=this._extensions[Tn.extensionName];this._bufferedBytes+=n[Y],this._state=
172
- bi,s.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
173
- pressed");Yt(this,c,o);return}this._bufferedBytes-=n[Y],this._state=Q,n.readOnly=!1,this.sendFrame(t.frame(a,n),o),this.
174
- dequeue()})}dequeue(){for(;this._state===Q&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Y],
175
- Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Y],this._queue.push(e)}sendFrame(e,r){e.length===
165
+ !0);let d={[X]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
166
+ Pe(e)?this._state!==Y?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this.
167
+ _state!==Y?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,r,n,o){this.
168
+ _bufferedBytes+=n[X],this._state=Ri,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was \
169
+ closed while the blob was being read");process.nextTick(nr,this,a,o);return}this._bufferedBytes-=n[X];let i=me(s);r?this.
170
+ dispatch(i,r,n,o):(this._state=Y,this.sendFrame(t.frame(i,n),o),this.dequeue())}).catch(s=>{process.nextTick(Pi,this,s,o)})}dispatch(e,r,n,o){
171
+ if(!r){this.sendFrame(t.frame(e,n),o);return}let s=this._extensions[An.extensionName];this._bufferedBytes+=n[X],this._state=
172
+ Oi,s.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
173
+ pressed");nr(this,c,o);return}this._bufferedBytes-=n[X],this._state=Y,n.readOnly=!1,this.sendFrame(t.frame(a,n),o),this.
174
+ dequeue()})}dequeue(){for(;this._state===Y&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][X],
175
+ Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][X],this._queue.push(e)}sendFrame(e,r){e.length===
176
176
  2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],
177
- r)}};_n.exports=Xt;function Yt(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let o=t._queue[n],s=o[o.
178
- length-1];typeof s=="function"&&s(e)}}function Ai(t,e,r){Yt(t,e,r),t.onerror(e)}});var Nn=G((vl,Mn)=>{"use strict";var{kForOnEventAttribute:qe,kListener:Zt}=te(),An=Symbol("kCode"),Cn=Symbol("kData"),En=Symbol(
179
- "kError"),On=Symbol("kMessage"),Rn=Symbol("kReason"),Pe=Symbol("kTarget"),Pn=Symbol("kType"),kn=Symbol("kWasClean"),ne=class{constructor(e){
180
- this[Pe]=null,this[Pn]=e}get target(){return this[Pe]}get type(){return this[Pn]}};Object.defineProperty(ne.prototype,"t\
181
- arget",{enumerable:!0});Object.defineProperty(ne.prototype,"type",{enumerable:!0});var ge=class extends ne{constructor(e,r={}){
182
- super(e),this[An]=r.code===void 0?0:r.code,this[Rn]=r.reason===void 0?"":r.reason,this[kn]=r.wasClean===void 0?!1:r.wasClean}get code(){
183
- return this[An]}get reason(){return this[Rn]}get wasClean(){return this[kn]}};Object.defineProperty(ge.prototype,"code",
184
- {enumerable:!0});Object.defineProperty(ge.prototype,"reason",{enumerable:!0});Object.defineProperty(ge.prototype,"wasCle\
185
- an",{enumerable:!0});var ke=class extends ne{constructor(e,r={}){super(e),this[En]=r.error===void 0?null:r.error,this[On]=
186
- r.message===void 0?"":r.message}get error(){return this[En]}get message(){return this[On]}};Object.defineProperty(ke.prototype,
187
- "error",{enumerable:!0});Object.defineProperty(ke.prototype,"message",{enumerable:!0});var Be=class extends ne{constructor(e,r={}){
188
- super(e),this[Cn]=r.data===void 0?null:r.data}get data(){return this[Cn]}};Object.defineProperty(Be.prototype,"data",{enumerable:!0});
189
- var Ci={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[qe]&&o[Zt]===e&&!o[qe])return;let n;if(t==="mess\
190
- age")n=function(s,i){let a=new Be("message",{data:i?s:s.toString()});a[Pe]=this,ut(e,this,a)};else if(t==="close")n=function(s,i){
191
- let a=new ge("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Pe]=this,ut(
192
- e,this,a)};else if(t==="error")n=function(s){let i=new ke("error",{error:s,message:s.message});i[Pe]=this,ut(e,this,i)};else if(t===
193
- "open")n=function(){let s=new ne("open");s[Pe]=this,ut(e,this,s)};else return;n[qe]=!!r[qe],n[Zt]=e,r.once?this.once(t,n):
194
- this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Zt]===e&&!r[qe]){this.removeListener(t,r);break}}};
195
- Mn.exports={CloseEvent:ge,ErrorEvent:ke,Event:ne,EventTarget:Ci,MessageEvent:Be};function ut(t,e,r){typeof t=="object"&&
196
- t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var lt=G((wl,jn)=>{"use strict";var{tokenChars:He}=Ee();function ee(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Ei(t){
197
- let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,l=0;for(;l<t.length;l++)if(d=t.charCodeAt(
198
- l),i===void 0)if(u===-1&&He[d]===1)c===-1&&(c=l);else if(l!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=l);else if(d===59||d===
199
- 44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);u===-1&&(u=l);let h=t.slice(c,u);d===44?(ee(e,
200
- h,r),r=Object.create(null)):i=h,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${l}`);else if(a===void 0)
201
- if(u===-1&&He[d]===1)c===-1&&(c=l);else if(d===32||d===9)u===-1&&c!==-1&&(u=l);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
202
- `Unexpected character at index ${l}`);u===-1&&(u=l),ee(r,t.slice(c,u),!0),d===44&&(ee(e,i,r),r=Object.create(null),i=void 0),
203
- c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,l),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${l}`);else if(o){
204
- if(He[d]!==1)throw new SyntaxError(`Unexpected character at index ${l}`);c===-1?c=l:n||(n=!0),o=!1}else if(s)if(He[d]===
205
- 1)c===-1&&(c=l);else if(d===34&&c!==-1)s=!1,u=l;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
206
- index ${l}`);else if(d===34&&t.charCodeAt(l-1)===61)s=!0;else if(u===-1&&He[d]===1)c===-1&&(c=l);else if(c!==-1&&(d===32||
207
- d===9))u===-1&&(u=l);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);u===-1&&
208
- (u=l);let h=t.slice(c,u);n&&(h=h.replace(/\\/g,""),n=!1),ee(r,a,h),d===44&&(ee(e,i,r),r=Object.create(null),i=void 0),a=
209
- void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${l}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
210
- "Unexpected end of input");u===-1&&(u=l);let p=t.slice(c,u);return i===void 0?ee(e,p,r):(a===void 0?ee(r,p,!0):n?ee(r,a,
211
- p.replace(/\\/g,"")):ee(r,a,p),ee(e,i,r)),e}function Oi(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(
212
- r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(o=>{let s=n[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}\
213
- =${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jn.exports={format:Oi,parse:Ei}});var mt=G((Sl,Wn)=>{"use strict";var Ri=N("events"),Pi=N("https"),ki=N("http"),Ln=N("net"),Mi=N("tls"),{randomBytes:Ni,createHash:ji}=N("crypto"),
214
- {Duplex:yl,Readable:Il}=N("stream"),{URL:er}=N("url"),de=Ce(),Di=Jt(),zi=Qt(),{isBlob:Li}=Ee(),{BINARY_TYPES:Dn,CLOSE_TIMEOUT:Fi,
215
- EMPTY_BUFFER:pt,GUID:$i,kForOnEventAttribute:tr,kListener:Ui,kStatusCode:qi,kWebSocket:z,NOOP:Fn}=te(),{EventTarget:{addEventListener:Bi,
216
- removeEventListener:Hi}}=Nn(),{format:Vi,parse:Gi}=lt(),{toBuffer:Wi}=$e(),$n=Symbol("kAborted"),rr=[8,13],oe=["CONNECTI\
217
- NG","OPEN","CLOSING","CLOSED"],Ki=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends Ri{constructor(e,r,n){super(),this.
218
- _binaryType=Dn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pt,this._closeTimer=
177
+ r)}};En.exports=rr;function nr(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let o=t._queue[n],s=o[o.
178
+ length-1];typeof s=="function"&&s(e)}}function Pi(t,e,r){nr(t,e,r),t.onerror(e)}});var zn=W((Al,Dn)=>{"use strict";var{kForOnEventAttribute:Be,kListener:sr}=Z(),On=Symbol("kCode"),Rn=Symbol("kData"),Pn=Symbol(
179
+ "kError"),kn=Symbol("kMessage"),Mn=Symbol("kReason"),Me=Symbol("kTarget"),Nn=Symbol("kType"),jn=Symbol("kWasClean"),te=class{constructor(e){
180
+ this[Me]=null,this[Nn]=e}get target(){return this[Me]}get type(){return this[Nn]}};Object.defineProperty(te.prototype,"t\
181
+ arget",{enumerable:!0});Object.defineProperty(te.prototype,"type",{enumerable:!0});var ve=class extends te{constructor(e,r={}){
182
+ super(e),this[On]=r.code===void 0?0:r.code,this[Mn]=r.reason===void 0?"":r.reason,this[jn]=r.wasClean===void 0?!1:r.wasClean}get code(){
183
+ return this[On]}get reason(){return this[Mn]}get wasClean(){return this[jn]}};Object.defineProperty(ve.prototype,"code",
184
+ {enumerable:!0});Object.defineProperty(ve.prototype,"reason",{enumerable:!0});Object.defineProperty(ve.prototype,"wasCle\
185
+ an",{enumerable:!0});var Ne=class extends te{constructor(e,r={}){super(e),this[Pn]=r.error===void 0?null:r.error,this[kn]=
186
+ r.message===void 0?"":r.message}get error(){return this[Pn]}get message(){return this[kn]}};Object.defineProperty(Ne.prototype,
187
+ "error",{enumerable:!0});Object.defineProperty(Ne.prototype,"message",{enumerable:!0});var He=class extends te{constructor(e,r={}){
188
+ super(e),this[Rn]=r.data===void 0?null:r.data}get data(){return this[Rn]}};Object.defineProperty(He.prototype,"data",{enumerable:!0});
189
+ var ki={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Be]&&o[sr]===e&&!o[Be])return;let n;if(t==="mess\
190
+ age")n=function(s,i){let a=new He("message",{data:i?s:s.toString()});a[Me]=this,mt(e,this,a)};else if(t==="close")n=function(s,i){
191
+ let a=new ve("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Me]=this,mt(
192
+ e,this,a)};else if(t==="error")n=function(s){let i=new Ne("error",{error:s,message:s.message});i[Me]=this,mt(e,this,i)};else if(t===
193
+ "open")n=function(){let s=new te("open");s[Me]=this,mt(e,this,s)};else return;n[Be]=!!r[Be],n[sr]=e,r.once?this.once(t,n):
194
+ this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[sr]===e&&!r[Be]){this.removeListener(t,r);break}}};
195
+ Dn.exports={CloseEvent:ve,ErrorEvent:Ne,Event:te,EventTarget:ki,MessageEvent:He};function mt(t,e,r){typeof t=="object"&&
196
+ t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var gt=W((Cl,Ln)=>{"use strict";var{tokenChars:Ve}=Re();function Q(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Mi(t){
197
+ let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,f=0;for(;f<t.length;f++)if(d=t.charCodeAt(
198
+ f),i===void 0)if(u===-1&&Ve[d]===1)c===-1&&(c=f);else if(f!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=f);else if(d===59||d===
199
+ 44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let g=t.slice(c,u);d===44?(Q(e,g,
200
+ r),r=Object.create(null)):i=g,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)
201
+ if(u===-1&&Ve[d]===1)c===-1&&(c=f);else if(d===32||d===9)u===-1&&c!==-1&&(u=f);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
202
+ `Unexpected character at index ${f}`);u===-1&&(u=f),Q(r,t.slice(c,u),!0),d===44&&(Q(e,i,r),r=Object.create(null),i=void 0),
203
+ c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,f),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(o){
204
+ if(Ve[d]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);c===-1?c=f:n||(n=!0),o=!1}else if(s)if(Ve[d]===
205
+ 1)c===-1&&(c=f);else if(d===34&&c!==-1)s=!1,u=f;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
206
+ index ${f}`);else if(d===34&&t.charCodeAt(f-1)===61)s=!0;else if(u===-1&&Ve[d]===1)c===-1&&(c=f);else if(c!==-1&&(d===32||
207
+ d===9))u===-1&&(u=f);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&
208
+ (u=f);let g=t.slice(c,u);n&&(g=g.replace(/\\/g,""),n=!1),Q(r,a,g),d===44&&(Q(e,i,r),r=Object.create(null),i=void 0),a=void 0,
209
+ c=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
210
+ "Unexpected end of input");u===-1&&(u=f);let l=t.slice(c,u);return i===void 0?Q(e,l,r):(a===void 0?Q(r,l,!0):n?Q(r,a,l.replace(
211
+ /\\/g,"")):Q(r,a,l),Q(e,i,r)),e}function Ni(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),
212
+ r.map(n=>[e].concat(Object.keys(n).map(o=>{let s=n[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join(
213
+ "; ")})).join("; ")).join(", ")}).join(", ")}Ln.exports={format:Ni,parse:Mi}});var It=W((Rl,Xn)=>{"use strict";var ji=M("events"),Di=M("https"),zi=M("http"),Un=M("net"),Li=M("tls"),{randomBytes:Fi,createHash:$i}=M("crypto"),
214
+ {Duplex:El,Readable:Ol}=M("stream"),{URL:ir}=M("url"),de=Oe(),Ui=tr(),qi=or(),{isBlob:Bi}=Re(),{BINARY_TYPES:Fn,CLOSE_TIMEOUT:Hi,
215
+ EMPTY_BUFFER:vt,GUID:Vi,kForOnEventAttribute:ar,kListener:Gi,kStatusCode:Wi,kWebSocket:L,NOOP:qn}=Z(),{EventTarget:{addEventListener:Ki,
216
+ removeEventListener:Ji}}=zn(),{format:Xi,parse:Yi}=gt(),{toBuffer:Qi}=Ue(),Bn=Symbol("kAborted"),cr=[8,13],re=["CONNECTI\
217
+ NG","OPEN","CLOSING","CLOSED"],Zi=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends ji{constructor(e,r,n){super(),this.
218
+ _binaryType=Fn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=vt,this._closeTimer=
219
219
  null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=
220
220
  null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?
221
- r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),Un(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=
222
- n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Dn.includes(e)&&(this._binaryType=
221
+ r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),Hn(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=
222
+ n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Fn.includes(e)&&(this._binaryType=
223
223
  e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+
224
224
  this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){
225
225
  return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){
226
- return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let o=new Di(
226
+ return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let o=new Ui(
227
227
  {allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,
228
228
  maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),
229
- s=new zi(e,this._extensions,n.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[z]=this,s[z]=this,e[z]=this,
230
- o.on("conclude",Yi),o.on("drain",Qi),o.on("error",Zi),o.on("message",ea),o.on("ping",ta),o.on("pong",ra),s.onerror=na,e.
231
- setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Hn),e.on("data",ht),e.on(
232
- "end",Vn),e.on("error",Gn),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
229
+ s=new qi(e,this._extensions,n.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[L]=this,s[L]=this,e[L]=this,
230
+ o.on("conclude",ra),o.on("drain",na),o.on("error",oa),o.on("message",sa),o.on("ping",ia),o.on("pong",aa),s.onerror=ca,e.
231
+ setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Wn),e.on("data",yt),e.on(
232
+ "end",Kn),e.on("error",Jn),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
233
233
  this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[de.extensionName]&&this._extensions[de.extensionName].
234
234
  cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){
235
- if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){W(this,this._req,"WebSocket was closed before the conn\
235
+ if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){K(this,this._req,"WebSocket was closed before the conn\
236
236
  ection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver.
237
237
  _writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,
238
238
  n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),
239
- Bn(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){
239
+ Gn(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){
240
240
  if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="func\
241
241
  tion"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
242
- nr(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||pt,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)
242
+ dr(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||vt,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)
243
243
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="\
244
- function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){nr(this,e,n);return}r===void 0&&
245
- (r=!this._isServer),this._sender.pong(e||pt,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
244
+ function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){dr(this,e,n);return}r===void 0&&
245
+ (r=!this._isServer),this._sender.pong(e||vt,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
246
246
  _paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)
247
247
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="numbe\
248
- r"&&(e=e.toString()),this.readyState!==t.OPEN){nr(this,e,n);return}let o={binary:typeof e!="string",mask:!this._isServer,
249
- compress:!0,fin:!0,...r};this._extensions[de.extensionName]||(o.compress=!1),this._sender.send(e||pt,o,n)}terminate(){if(this.
250
- readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){W(this,this._req,"WebSocket was closed before the connection w\
248
+ r"&&(e=e.toString()),this.readyState!==t.OPEN){dr(this,e,n);return}let o={binary:typeof e!="string",mask:!this._isServer,
249
+ compress:!0,fin:!0,...r};this._extensions[de.extensionName]||(o.compress=!1),this._sender.send(e||vt,o,n)}terminate(){if(this.
250
+ readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){K(this,this._req,"WebSocket was closed before the connection w\
251
251
  as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(k,"CO\
252
- NNECTING",{enumerable:!0,value:oe.indexOf("CONNECTING")});Object.defineProperty(k.prototype,"CONNECTING",{enumerable:!0,
253
- value:oe.indexOf("CONNECTING")});Object.defineProperty(k,"OPEN",{enumerable:!0,value:oe.indexOf("OPEN")});Object.defineProperty(
254
- k.prototype,"OPEN",{enumerable:!0,value:oe.indexOf("OPEN")});Object.defineProperty(k,"CLOSING",{enumerable:!0,value:oe.indexOf(
255
- "CLOSING")});Object.defineProperty(k.prototype,"CLOSING",{enumerable:!0,value:oe.indexOf("CLOSING")});Object.defineProperty(
256
- k,"CLOSED",{enumerable:!0,value:oe.indexOf("CLOSED")});Object.defineProperty(k.prototype,"CLOSED",{enumerable:!0,value:oe.
252
+ NNECTING",{enumerable:!0,value:re.indexOf("CONNECTING")});Object.defineProperty(k.prototype,"CONNECTING",{enumerable:!0,
253
+ value:re.indexOf("CONNECTING")});Object.defineProperty(k,"OPEN",{enumerable:!0,value:re.indexOf("OPEN")});Object.defineProperty(
254
+ k.prototype,"OPEN",{enumerable:!0,value:re.indexOf("OPEN")});Object.defineProperty(k,"CLOSING",{enumerable:!0,value:re.indexOf(
255
+ "CLOSING")});Object.defineProperty(k.prototype,"CLOSING",{enumerable:!0,value:re.indexOf("CLOSING")});Object.defineProperty(
256
+ k,"CLOSED",{enumerable:!0,value:re.indexOf("CLOSED")});Object.defineProperty(k.prototype,"CLOSED",{enumerable:!0,value:re.
257
257
  indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
258
258
  defineProperty(k.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(k.prototype,
259
- `on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[tr])return e[Ui];return null},set(e){for(let r of this.
260
- listeners(t))if(r[tr]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[tr]:!0})}})});k.
261
- prototype.addEventListener=Bi;k.prototype.removeEventListener=Hi;Wn.exports=k;function Un(t,e,r,n){let o={allowSynchronousEvents:!0,
262
- autoPong:!0,closeTimeout:Fi,protocolVersion:rr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
259
+ `on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[ar])return e[Gi];return null},set(e){for(let r of this.
260
+ listeners(t))if(r[ar]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[ar]:!0})}})});k.
261
+ prototype.addEventListener=Ki;k.prototype.removeEventListener=Ji;Xn.exports=k;function Hn(t,e,r,n){let o={allowSynchronousEvents:!0,
262
+ autoPong:!0,closeTimeout:Hi,protocolVersion:cr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
263
263
  perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,
264
- method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!rr.includes(
265
- o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${rr.join(
266
- ", ")})`);let s;if(e instanceof er)s=e;else try{s=new er(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol===
264
+ method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!cr.includes(
265
+ o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${cr.join(
266
+ ", ")})`);let s;if(e instanceof ir)s=e;else try{s=new ir(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol===
267
267
  "http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),t._url=s.href;let i=s.protocol==="wss:",a=s.protocol===
268
268
  "ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws\
269
- +unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let S=new SyntaxError(
270
- c);if(t._redirects===0)throw S;ft(t,S);return}let d=i?443:80,u=Ni(16).toString("base64"),l=i?Pi.request:ki.request,p=new Set,
271
- h;if(o.createConnection=o.createConnection||(i?Xi:Ji),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
269
+ +unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let x=new SyntaxError(
270
+ c);if(t._redirects===0)throw x;wt(t,x);return}let d=i?443:80,u=Fi(16).toString("base64"),f=i?Di.request:zi.request,l=new Set,
271
+ g;if(o.createConnection=o.createConnection||(i?ta:ea),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
272
272
  startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec\
273
273
  -WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
274
- (h=new de({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Vi({[de.extensionName]:h.
275
- offer()})),r.length){for(let S of r){if(typeof S!="string"||!Ki.test(S)||p.has(S))throw new SyntaxError("An invalid or d\
276
- uplicated subprotocol was specified");p.add(S)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<
274
+ (g=new de({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Xi({[de.extensionName]:g.
275
+ offer()})),r.length){for(let x of r){if(typeof x!="string"||!Zi.test(x)||l.has(x))throw new SyntaxError("An invalid or d\
276
+ uplicated subprotocol was specified");l.add(x)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<
277
277
  13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}\
278
- :${s.password}`),a){let S=o.path.split(":");o.socketPath=S[0],o.path=S[1]}let I;if(o.followRedirects){if(t._redirects===
279
- 0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let S=n&&n.headers;if(n={...n,
280
- headers:{}},S)for(let[C,P]of Object.entries(S))n.headers[C.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let S=a?
281
- t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!S||
282
- t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,S||delete o.headers.host,o.auth=void 0)}
283
- o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),I=t._req=l(o),
284
- t._redirects&&t.emit("redirect",t.url,I)}else I=t._req=l(o);o.timeout&&I.on("timeout",()=>{W(t,I,"Opening handshake has \
285
- timed out")}),I.on("error",S=>{I===null||I[$n]||(I=t._req=null,ft(t,S))}),I.on("response",S=>{let C=S.headers.location,P=S.
286
- statusCode;if(C&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){W(t,I,"Maximum redirects exceeded");
287
- return}I.abort();let j;try{j=new er(C,e)}catch{let $=new SyntaxError(`Invalid URL: ${C}`);ft(t,$);return}Un(t,j,r,n)}else
288
- t.emit("unexpected-response",I,S)||W(t,I,`Unexpected server response: ${S.statusCode}`)}),I.on("upgrade",(S,C,P)=>{if(t.
289
- emit("upgrade",S),t.readyState!==k.CONNECTING)return;I=t._req=null;let j=S.headers.upgrade;if(j===void 0||j.toLowerCase()!==
290
- "websocket"){W(t,C,"Invalid Upgrade header");return}let L=ji("sha1").update(u+$i).digest("base64");if(S.headers["sec-web\
291
- socket-accept"]!==L){W(t,C,"Invalid Sec-WebSocket-Accept header");return}let $=S.headers["sec-websocket-protocol"],K;if($!==
292
- void 0?p.size?p.has($)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":p.
293
- size&&(K="Server sent no subprotocol"),K){W(t,C,K);return}$&&(t._protocol=$);let F=S.headers["sec-websocket-extensions"];
294
- if(F!==void 0){if(!h){W(t,C,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let V;
295
- try{V=Gi(F)}catch{W(t,C,"Invalid Sec-WebSocket-Extensions header");return}let Z=Object.keys(V);if(Z.length!==1||Z[0]!==de.
296
- extensionName){W(t,C,"Server indicated an extension that was not requested");return}try{h.accept(V[de.extensionName])}catch{
297
- W(t,C,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[de.extensionName]=h}t.setSocket(C,P,{allowSynchronousEvents:o.
278
+ :${s.password}`),a){let x=o.path.split(":");o.socketPath=x[0],o.path=x[1]}let S;if(o.followRedirects){if(t._redirects===
279
+ 0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let x=n&&n.headers;if(n={...n,
280
+ headers:{}},x)for(let[O,P]of Object.entries(x))n.headers[O.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let x=a?
281
+ t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!x||
282
+ t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,x||delete o.headers.host,o.auth=void 0)}
283
+ o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),S=t._req=f(o),
284
+ t._redirects&&t.emit("redirect",t.url,S)}else S=t._req=f(o);o.timeout&&S.on("timeout",()=>{K(t,S,"Opening handshake has \
285
+ timed out")}),S.on("error",x=>{S===null||S[Bn]||(S=t._req=null,wt(t,x))}),S.on("response",x=>{let O=x.headers.location,P=x.
286
+ statusCode;if(O&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){K(t,S,"Maximum redirects exceeded");
287
+ return}S.abort();let D;try{D=new ir(O,e)}catch{let F=new SyntaxError(`Invalid URL: ${O}`);wt(t,F);return}Hn(t,D,r,n)}else
288
+ t.emit("unexpected-response",S,x)||K(t,S,`Unexpected server response: ${x.statusCode}`)}),S.on("upgrade",(x,O,P)=>{if(t.
289
+ emit("upgrade",x),t.readyState!==k.CONNECTING)return;S=t._req=null;let D=x.headers.upgrade;if(D===void 0||D.toLowerCase()!==
290
+ "websocket"){K(t,O,"Invalid Upgrade header");return}let N=$i("sha1").update(u+Vi).digest("base64");if(x.headers["sec-web\
291
+ socket-accept"]!==N){K(t,O,"Invalid Sec-WebSocket-Accept header");return}let F=x.headers["sec-websocket-protocol"],q;if(F!==
292
+ void 0?l.size?l.has(F)||(q="Server sent an invalid subprotocol"):q="Server sent a subprotocol but none was requested":l.
293
+ size&&(q="Server sent no subprotocol"),q){K(t,O,q);return}F&&(t._protocol=F);let V=x.headers["sec-websocket-extensions"];
294
+ if(V!==void 0){if(!g){K(t,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let G;
295
+ try{G=Yi(V)}catch{K(t,O,"Invalid Sec-WebSocket-Extensions header");return}let oe=Object.keys(G);if(oe.length!==1||oe[0]!==
296
+ de.extensionName){K(t,O,"Server indicated an extension that was not requested");return}try{g.accept(G[de.extensionName])}catch{
297
+ K(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[de.extensionName]=g}t.setSocket(O,P,{allowSynchronousEvents:o.
298
298
  allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
299
- maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(I,t):I.end()}function ft(t,e){t._readyState=
300
- k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ji(t){return t.path=t.socketPath,Ln.connect(t)}function Xi(t){
301
- return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ln.isIP(t.host)?"":t.host),Mi.connect(t)}function W(t,e,r){
302
- t._readyState=k.CLOSING;let n=new Error(r);Error.captureStackTrace(n,W),e.setHeader?(e[$n]=!0,e.abort(),e.socket&&!e.socket.
303
- destroyed&&e.socket.destroy(),process.nextTick(ft,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("clo\
304
- se",t.emitClose.bind(t)))}function nr(t,e,r){if(e){let n=Li(e)?e.size:Wi(e).length;t._socket?t._sender._bufferedBytes+=n:
305
- t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${oe[t.readyState]})`);process.
306
- nextTick(r,n)}}function Yi(t,e){let r=this[z];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[z]!==void 0&&
307
- (r._socket.removeListener("data",ht),process.nextTick(qn,r._socket),t===1005?r.close():r.close(t,e))}function Qi(){let t=this[z];
308
- t.isPaused||t._socket.resume()}function Zi(t){let e=this[z];e._socket[z]!==void 0&&(e._socket.removeListener("data",ht),
309
- process.nextTick(qn,e._socket),e.close(t[qi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function zn(){this[z].
310
- emitClose()}function ea(t,e){this[z].emit("message",t,e)}function ta(t){let e=this[z];e._autoPong&&e.pong(t,!this._isServer,
311
- Fn),e.emit("ping",t)}function ra(t){this[z].emit("pong",t)}function qn(t){t.resume()}function na(t){let e=this[z];e.readyState!==
312
- k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,Bn(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
313
- e.emit("error",t)))}function Bn(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Hn(){
314
- let t=this[z];if(this.removeListener("close",Hn),this.removeListener("data",ht),this.removeListener("end",Vn),t._readyState=
299
+ maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,t):S.end()}function wt(t,e){t._readyState=
300
+ k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function ea(t){return t.path=t.socketPath,Un.connect(t)}function ta(t){
301
+ return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Un.isIP(t.host)?"":t.host),Li.connect(t)}function K(t,e,r){
302
+ t._readyState=k.CLOSING;let n=new Error(r);Error.captureStackTrace(n,K),e.setHeader?(e[Bn]=!0,e.abort(),e.socket&&!e.socket.
303
+ destroyed&&e.socket.destroy(),process.nextTick(wt,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("clo\
304
+ se",t.emitClose.bind(t)))}function dr(t,e,r){if(e){let n=Bi(e)?e.size:Qi(e).length;t._socket?t._sender._bufferedBytes+=n:
305
+ t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${re[t.readyState]})`);process.
306
+ nextTick(r,n)}}function ra(t,e){let r=this[L];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[L]!==void 0&&
307
+ (r._socket.removeListener("data",yt),process.nextTick(Vn,r._socket),t===1005?r.close():r.close(t,e))}function na(){let t=this[L];
308
+ t.isPaused||t._socket.resume()}function oa(t){let e=this[L];e._socket[L]!==void 0&&(e._socket.removeListener("data",yt),
309
+ process.nextTick(Vn,e._socket),e.close(t[Wi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function $n(){this[L].
310
+ emitClose()}function sa(t,e){this[L].emit("message",t,e)}function ia(t){let e=this[L];e._autoPong&&e.pong(t,!this._isServer,
311
+ qn),e.emit("ping",t)}function aa(t){this[L].emit("pong",t)}function Vn(t){t.resume()}function ca(t){let e=this[L];e.readyState!==
312
+ k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,Gn(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
313
+ e.emit("error",t)))}function Gn(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Wn(){
314
+ let t=this[L];if(this.removeListener("close",Wn),this.removeListener("data",yt),this.removeListener("end",Kn),t._readyState=
315
315
  k.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.
316
- length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[z]=void 0,clearTimeout(
316
+ length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[L]=void 0,clearTimeout(
317
317
  t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
318
- "error",zn),t._receiver.on("finish",zn))}function ht(t){this[z]._receiver.write(t)||this.pause()}function Vn(){let t=this[z];
319
- t._readyState=k.CLOSING,t._receiver.end(),this.end()}function Gn(){let t=this[z];this.removeListener("error",Gn),this.on(
320
- "error",Fn),t&&(t._readyState=k.CLOSING,this.destroy())}});var Yn=G((Tl,Xn)=>{"use strict";var xl=mt(),{Duplex:oa}=N("stream");function Kn(t){t.emit("close")}function sa(){!this.destroyed&&
321
- this._writableState.finished&&this.destroy()}function Jn(t){this.removeListener("error",Jn),this.destroy(),this.listenerCount(
322
- "error")===0&&this.emit("error",t)}function ia(t,e){let r=!0,n=new oa({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
318
+ "error",$n),t._receiver.on("finish",$n))}function yt(t){this[L]._receiver.write(t)||this.pause()}function Kn(){let t=this[L];
319
+ t._readyState=k.CLOSING,t._receiver.end(),this.end()}function Jn(){let t=this[L];this.removeListener("error",Jn),this.on(
320
+ "error",qn),t&&(t._readyState=k.CLOSING,this.destroy())}});var eo=W((kl,Zn)=>{"use strict";var Pl=It(),{Duplex:da}=M("stream");function Yn(t){t.emit("close")}function ua(){!this.destroyed&&
321
+ this._writableState.finished&&this.destroy()}function Qn(t){this.removeListener("error",Qn),this.destroy(),this.listenerCount(
322
+ "error")===0&&this.emit("error",t)}function la(t,e){let r=!0,n=new da({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
323
323
  return t.on("message",function(s,i){let a=!i&&n._readableState.objectMode?s.toString():s;n.push(a)||t.pause()}),t.once("\
324
324
  error",function(s){n.destroyed||(r=!1,n.destroy(s))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(o,s){
325
- if(t.readyState===t.CLOSED){s(o),process.nextTick(Kn,n);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
326
- lose",function(){i||s(o),process.nextTick(Kn,n)}),r&&t.terminate()},n._final=function(o){if(t.readyState===t.CONNECTING){
325
+ if(t.readyState===t.CLOSED){s(o),process.nextTick(Yn,n);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
326
+ lose",function(){i||s(o),process.nextTick(Yn,n)}),r&&t.terminate()},n._final=function(o){if(t.readyState===t.CONNECTING){
327
327
  t.once("open",function(){n._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),n._readableState.
328
328
  endEmitted&&n.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},
329
329
  n._write=function(o,s,i){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(o,s,i)});return}t.send(o,i)},
330
- n.on("end",sa),n.on("error",Jn),n}Xn.exports=ia});var or=G((bl,Qn)=>{"use strict";var{tokenChars:aa}=Ee();function ca(t){let e=new Set,r=-1,n=-1,o=0;for(o;o<t.length;o++){
331
- let i=t.charCodeAt(o);if(n===-1&&aa[i]===1)r===-1&&(r=o);else if(o!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=o);else if(i===
330
+ n.on("end",ua),n.on("error",Qn),n}Zn.exports=la});var ur=W((Ml,to)=>{"use strict";var{tokenChars:pa}=Re();function fa(t){let e=new Set,r=-1,n=-1,o=0;for(o;o<t.length;o++){
331
+ let i=t.charCodeAt(o);if(n===-1&&pa[i]===1)r===-1&&(r=o);else if(o!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=o);else if(i===
332
332
  44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);n===-1&&(n=o);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(
333
333
  `The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
334
334
  if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let s=t.slice(r,o);if(e.has(s))throw new SyntaxError(
335
- `The "${s}" subprotocol is duplicated`);return e.add(s),e}Qn.exports={parse:ca}});var so=G((Al,oo)=>{"use strict";var da=N("events"),gt=N("http"),{Duplex:_l}=N("stream"),{createHash:ua}=N("crypto"),Zn=lt(),
336
- ve=Ce(),la=or(),pa=mt(),{CLOSE_TIMEOUT:fa,GUID:ha,kWebSocket:ma}=te(),ga=/^[+/0-9A-Za-z]{22}==$/,eo=0,to=1,no=2,sr=class extends da{constructor(e,r){
335
+ `The "${s}" subprotocol is duplicated`);return e.add(s),e}to.exports={parse:fa}});var co=W((jl,ao)=>{"use strict";var ha=M("events"),St=M("http"),{Duplex:Nl}=M("stream"),{createHash:ma}=M("crypto"),ro=gt(),
336
+ we=Oe(),ga=ur(),va=It(),{CLOSE_TIMEOUT:wa,GUID:ya,kWebSocket:Ia}=Z(),Sa=/^[+/0-9A-Za-z]{22}==$/,no=0,oo=1,io=2,lr=class extends ha{constructor(e,r){
337
337
  if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*
338
- 1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:fa,verifyClient:null,
339
- noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:pa,...e},e.port==null&&!e.server&&!e.noServer||
338
+ 1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:wa,verifyClient:null,
339
+ noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:va,...e},e.port==null&&!e.server&&!e.noServer||
340
340
  e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server"\
341
- , or "noServer" options must be specified');if(e.port!=null?(this._server=gt.createServer((n,o)=>{let s=gt.STATUS_CODES[426];
341
+ , or "noServer" options must be specified');if(e.port!=null?(this._server=St.createServer((n,o)=>{let s=St.STATUS_CODES[426];
342
342
  o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(e.port,e.host,e.
343
343
  backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=
344
- va(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
344
+ xa(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
345
345
  o,s,i,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=
346
- !1),this.options=e,this._state=eo}address(){if(this.options.noServer)throw new Error('The server is operating in "noServ\
347
- er" mode');return this._server?this._server.address():null}close(e){if(this._state===no){e&&this.once("close",()=>{e(new Error(
348
- "The server is not running"))}),process.nextTick(Ve,this);return}if(e&&this.once("close",e),this._state!==to)if(this._state=
349
- to,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=
350
- null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ve,this):process.nextTick(Ve,this);else{let r=this.
351
- _server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ve(this)})}}shouldHandle(e){if(this.
346
+ !1),this.options=e,this._state=no}address(){if(this.options.noServer)throw new Error('The server is operating in "noServ\
347
+ er" mode');return this._server?this._server.address():null}close(e){if(this._state===io){e&&this.once("close",()=>{e(new Error(
348
+ "The server is not running"))}),process.nextTick(Ge,this);return}if(e&&this.once("close",e),this._state!==oo)if(this._state=
349
+ oo,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=
350
+ null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ge,this):process.nextTick(Ge,this);else{let r=this.
351
+ _server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ge(this)})}}shouldHandle(e){if(this.
352
352
  options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,o){
353
- r.on("error",ro);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
354
- "GET"){we(this,e,r,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){we(this,e,r,400,"Inva\
355
- lid Upgrade header");return}if(s===void 0||!ga.test(s)){we(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}
356
- if(a!==13&&a!==8){we(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
357
- if(!this.shouldHandle(e)){Ge(r,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=la.parse(
358
- c)}catch{we(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],l={};
359
- if(this.options.perMessageDeflate&&u!==void 0){let p=new ve({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
360
- options.maxPayload});try{let h=Zn.parse(u);h[ve.extensionName]&&(p.accept(h[ve.extensionName]),l[ve.extensionName]=p)}catch{
361
- we(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={
353
+ r.on("error",so);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
354
+ "GET"){ye(this,e,r,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){ye(this,e,r,400,"Inva\
355
+ lid Upgrade header");return}if(s===void 0||!Sa.test(s)){ye(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}
356
+ if(a!==13&&a!==8){ye(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
357
+ if(!this.shouldHandle(e)){We(r,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=ga.parse(
358
+ c)}catch{ye(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],f={};
359
+ if(this.options.perMessageDeflate&&u!==void 0){let l=new we({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
360
+ options.maxPayload});try{let g=ro.parse(u);g[we.extensionName]&&(l.accept(g[we.extensionName]),f[we.extensionName]=l)}catch{
361
+ ye(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let l={
362
362
  origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.
363
- options.verifyClient.length===2){this.options.verifyClient(p,(h,I,S,C)=>{if(!h)return Ge(r,I||401,S,C);this.completeUpgrade(
364
- l,s,d,e,r,n,o)});return}if(!this.options.verifyClient(p))return Ge(r,401)}this.completeUpgrade(l,s,d,e,r,n,o)}completeUpgrade(e,r,n,o,s,i,a){
365
- if(!s.readable||!s.writable)return s.destroy();if(s[ma])throw new Error("server.handleUpgrade() was called more than onc\
366
- e with the same socket, possibly due to a misconfiguration");if(this._state>eo)return Ge(s,503);let d=["HTTP/1.1 101 Swi\
367
- tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ua("sha1").update(r+ha).digest("ba\
368
- se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let l=this.options.handleProtocols?this.options.
369
- handleProtocols(n,o):n.values().next().value;l&&(d.push(`Sec-WebSocket-Protocol: ${l}`),u._protocol=l)}if(e[ve.extensionName]){
370
- let l=e[ve.extensionName].params,p=Zn.format({[ve.extensionName]:[l]});d.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=
363
+ options.verifyClient.length===2){this.options.verifyClient(l,(g,S,x,O)=>{if(!g)return We(r,S||401,x,O);this.completeUpgrade(
364
+ f,s,d,e,r,n,o)});return}if(!this.options.verifyClient(l))return We(r,401)}this.completeUpgrade(f,s,d,e,r,n,o)}completeUpgrade(e,r,n,o,s,i,a){
365
+ if(!s.readable||!s.writable)return s.destroy();if(s[Ia])throw new Error("server.handleUpgrade() was called more than onc\
366
+ e with the same socket, possibly due to a misconfiguration");if(this._state>no)return We(s,503);let d=["HTTP/1.1 101 Swi\
367
+ tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ma("sha1").update(r+ya).digest("ba\
368
+ se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let f=this.options.handleProtocols?this.options.
369
+ handleProtocols(n,o):n.values().next().value;f&&(d.push(`Sec-WebSocket-Protocol: ${f}`),u._protocol=f)}if(e[we.extensionName]){
370
+ let f=e[we.extensionName].params,l=ro.format({[we.extensionName]:[f]});d.push(`Sec-WebSocket-Extensions: ${l}`),u._extensions=
371
371
  e}this.emit("headers",d,o),s.write(d.concat(`\r
372
372
  `).join(`\r
373
- `)),s.removeListener("error",ro),u.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
373
+ `)),s.removeListener("error",so),u.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
374
374
  options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.
375
375
  options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&
376
- !this.clients.size&&process.nextTick(Ve,this)})),a(u,o)}};oo.exports=sr;function va(t,e){for(let r of Object.keys(e))t.on(
377
- r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function Ve(t){t._state=no,t.emit("close")}
378
- function ro(){this.destroy()}function Ge(t,e,r,n){r=r||gt.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/htm\
379
- l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${gt.STATUS_CODES[e]}\r
376
+ !this.clients.size&&process.nextTick(Ge,this)})),a(u,o)}};ao.exports=lr;function xa(t,e){for(let r of Object.keys(e))t.on(
377
+ r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function Ge(t){t._state=io,t.emit("close")}
378
+ function so(){this.destroy()}function We(t,e,r,n){r=r||St.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/htm\
379
+ l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${St.STATUS_CODES[e]}\r
380
380
  `+Object.keys(n).map(o=>`${o}: ${n[o]}`).join(`\r
381
381
  `)+`\r
382
382
  \r
383
- `+r)}function we(t,e,r,n,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,we),t.emit(
384
- "wsClientError",i,r,e)}else Ge(r,n,o,s)}});function _(t){return String(t??"").trim()}function U(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var Ju=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
383
+ `+r)}function ye(t,e,r,n,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,ye),t.emit(
384
+ "wsClientError",i,r,e)}else We(r,n,o,s)}});function A(t){return String(t??"").trim()}function $(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var ol=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
385
385
  "truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var B=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
386
- INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),Zu=new Set(Object.values(B)),el=new Set([B.CANCELLED,
387
- B.COMPLETED,B.FAILED,B.INTERRUPTED,B.TIMED_OUT]),Ys=new Set([B.ACTIVE,B.FINALIZING,B.STARTING]);var wa=ae(Yn(),1),ya=ae(lt(),1),Ia=ae(Ce(),1),Sa=ae(Jt(),1),xa=ae(Qt(),1),Ta=ae(or(),1),ba=ae(mt(),1),_a=ae(so(),1);import{createHash as io}from"node:crypto";import{execFile as Ca}from"node:child_process";import{open as Ea,readFile as Nl,
388
- rename as jl,rm as Dl,writeFile as zl}from"node:fs/promises";import ar from"node:path";import{promisify as Oa}from"node:util";var Ul=Oa(Ca);var Ra=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
386
+ INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),cl=new Set(Object.values(B)),dl=new Set([B.CANCELLED,
387
+ B.COMPLETED,B.FAILED,B.INTERRUPTED,B.TIMED_OUT]),ri=new Set([B.ACTIVE,B.FINALIZING,B.STARTING]);var Ta=ae(eo(),1),ba=ae(gt(),1),_a=ae(Oe(),1),Aa=ae(tr(),1),Ca=ae(or(),1),Ea=ae(ur(),1),Oa=ae(It(),1),Ra=ae(co(),1);import{createHash as uo}from"node:crypto";import{execFile as ka}from"node:child_process";import{open as Ma,readFile as Bl,
388
+ rename as Hl,rm as Vl,writeFile as Gl}from"node:fs/promises";import fr from"node:path";import{promisify as Na}from"node:util";var Xl=Na(ka);var ja=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
389
389
  code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
390
390
  "in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
391
391
  ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
392
- "unified_exec_zsh_fork","view_image"]);function vt(t=""){return Array.from(String(t)).some(e=>{let r=e.codePointAt(0);return r<=
393
- 31||r===127})}function ao(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===
394
- Object.prototype||e===null}function co(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.values(
395
- t))co(e);return Object.freeze(t)}function Pa(t="",e={}){let r=new Error(_(t)||"Codex cannot prove the helper execution p\
392
+ "unified_exec_zsh_fork","view_image"]);function xt(t=""){return Array.from(String(t)).some(e=>{let r=e.codePointAt(0);return r<=
393
+ 31||r===127})}function lo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===
394
+ Object.prototype||e===null}function po(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.values(
395
+ t))po(e);return Object.freeze(t)}function Da(t="",e={}){let r=new Error(A(t)||"Codex cannot prove the helper execution p\
396
396
  olicy.");r.code="codex_policy_unenforceable",r.details=Object.freeze({...e});for(let[n,o]of Object.entries(r.details))["\
397
- code","details","message","name"].includes(n)||(r[n]=o);return r}function ka({clientName:t="jskit",minimumVersion:e="0.1\
398
- 51.0",disabledFeatures:r=Ra,limits:{userAgentMaxLength:n=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
399
- 1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:l=512*
400
- 1024}={},createError:p=Pa}={}){let h=new WeakSet;function I(f,m,v){let g=0;try{g=Buffer.byteLength(JSON.stringify(f),"ut\
401
- f8")}catch{throw p(`Codex helper execution received an invalid ${v}.`)}if(g>m)throw p(`Codex helper execution received a\
402
- n oversized ${v}.`)}function S(f){if(typeof f?.currentConnectionGeneration!="function")throw p("Codex helper execution c\
403
- annot verify the app-server connection generation.");let m=f.currentConnectionGeneration();if(!Number.isSafeInteger(m)||
404
- m<=0)throw p("Codex helper execution found no active app-server connection.");return m}async function C(f){if(typeof f?.
405
- currentHelperExecutionContext!="function")throw p("Codex helper execution requires its dedicated isolated provider.");let m=await f.
406
- currentHelperExecutionContext(),v=_(m?.cwd),g=_(m?.accountIdentitySignature);if(m?.executionMode!=="helper"||!v||!ar.isAbsolute(
407
- v)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw p("Codex helper runtime isolation could not be verified.");return Object.freeze(
408
- {accountIdentitySignature:g,cwd:v,executionMode:"helper"})}function P(f=""){let m=_(f).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
409
- if(!m)return null;let v=m.slice(1).map(g=>Number.parseInt(g,10));return v.every(Number.isSafeInteger)?v:null}function j(f=""){
410
- let m=_(f);if(!m||m.length>n||vt(m))return null;let v=`${t}/`;if(!m.startsWith(v))return null;let g=m.slice(v.length).match(
411
- /^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?P(g[1]):null}function L(f){if(typeof f?.currentServerInfo!=
412
- "function")throw p("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
413
- let m=_(f.currentServerInfo()?.userAgent),v=j(m);if(!v)throw p("Codex helper execution received an unrecognised app-serv\
414
- er version. Update Codex and retry.",{minimumVersion:e});let g=v.join("."),A=P(e),b=v.findIndex((M,J)=>M!==A[J]);if(b!==
415
- -1&&v[b]<A[b])throw p(`Codex helper execution requires app-server ${e} or newer; current version is ${g}. Update Codex a\
416
- nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function $(f=null){if(!ao(
417
- f?.config))throw p("Codex helper execution could not read the effective app-server configuration.");let m=f.config.mcp_servers;
418
- if(m==null)return[];if(I(m,i,"MCP configuration"),!ao(m))throw p("Codex helper execution received an invalid MCP server \
419
- configuration.");let v=Object.keys(m);if(v.length>o||v.some(g=>!g||g.length>s||vt(g)))throw p("Codex helper execution re\
420
- ceived an oversized or invalid MCP server inventory.");return v.sort()}function K(f=null,m=""){if(I(f,l,"hook inventory"),
421
- !Array.isArray(f?.data))throw p("Codex helper execution could not enumerate app-server hooks.");if(f.data.length!==1)throw p(
422
- "Codex helper execution received an unexpected hook inventory.");let v=f.data[0];if(_(v?.cwd)!==m||_(v?.cwd).length>d||!Array.
423
- isArray(v.hooks)||!Array.isArray(v.errors)||v.hooks.length>a||v.errors.length>c)throw p("Codex helper execution received\
424
- an incomplete hook inventory.");if(v.errors.length>0)throw p("Codex helper execution cannot continue while hook discove\
425
- ry has errors.",{hookErrorCount:v.errors.length});let g=v.hooks.map(b=>{let M=_(b?.key),J=_(b?.currentHash),be=_(b?.handlerType),
426
- Yr=_(b?.sourcePath);if(!M||[M,J,be,Yr].some(Qr=>Qr.length>d||vt(Qr)))throw p("Codex helper execution found an invalid ho\
427
- ok inventory entry.");if(b?.isManaged===!0&&b?.enabled===!0)throw p("Codex helper execution cannot disable a managed hoo\
428
- k.");return{currentHash:J,enabled:b?.enabled===!0,handlerType:be,isManaged:b?.isManaged===!0,key:M,sourcePath:Yr}}).sort(
429
- (b,M)=>b.key.localeCompare(M.key)),A=JSON.stringify(g);if(A.length>u)throw p("Codex helper execution received an oversiz\
430
- ed hook inventory.");return{fingerprint:A,hookKeys:g.filter(b=>!b.isManaged).map(b=>b.key)}}function F({effort:f="",summary:m="",
431
- hookKeys:v=[],mcpServerNames:g=[]}={}){let A={features:Object.fromEntries(r.map(M=>[M,!1])),hooks:{state:Object.fromEntries(
432
- v.map(M=>[M,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
433
- include_permissions_instructions:!1,...f?{model_reasoning_effort:f}:{},...m?{model_reasoning_summary:m}:{},mcp_servers:Object.
434
- fromEntries(g.map(M=>[M,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
397
+ code","details","message","name"].includes(n)||(r[n]=o);return r}function za({clientName:t="jskit",minimumVersion:e="0.1\
398
+ 51.0",disabledFeatures:r=ja,limits:{userAgentMaxLength:n=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
399
+ 1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:f=512*
400
+ 1024}={},createError:l=Da}={}){let g=new WeakSet;function S(v,y,I){let p=0;try{p=Buffer.byteLength(JSON.stringify(v),"ut\
401
+ f8")}catch{throw l(`Codex helper execution received an invalid ${I}.`)}if(p>y)throw l(`Codex helper execution received a\
402
+ n oversized ${I}.`)}function x(v){if(typeof v?.currentConnectionGeneration!="function")throw l("Codex helper execution c\
403
+ annot verify the app-server connection generation.");let y=v.currentConnectionGeneration();if(!Number.isSafeInteger(y)||
404
+ y<=0)throw l("Codex helper execution found no active app-server connection.");return y}async function O(v){if(typeof v?.
405
+ currentHelperExecutionContext!="function")throw l("Codex helper execution requires its dedicated isolated provider.");let y=await v.
406
+ currentHelperExecutionContext(),I=A(y?.cwd),p=A(y?.accountIdentitySignature);if(y?.executionMode!=="helper"||!I||!fr.isAbsolute(
407
+ I)||!/^sha256:[a-f0-9]{64}$/u.test(p))throw l("Codex helper runtime isolation could not be verified.");return Object.freeze(
408
+ {accountIdentitySignature:p,cwd:I,executionMode:"helper"})}function P(v=""){let y=A(v).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
409
+ if(!y)return null;let I=y.slice(1).map(p=>Number.parseInt(p,10));return I.every(Number.isSafeInteger)?I:null}function D(v=""){
410
+ let y=A(v);if(!y||y.length>n||xt(y))return null;let I=`${t}/`;if(!y.startsWith(I))return null;let p=y.slice(I.length).match(
411
+ /^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return p?P(p[1]):null}function N(v){if(typeof v?.currentServerInfo!=
412
+ "function")throw l("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
413
+ let y=A(v.currentServerInfo()?.userAgent),I=D(y);if(!I)throw l("Codex helper execution received an unrecognised app-serv\
414
+ er version. Update Codex and retry.",{minimumVersion:e});let p=I.join("."),h=P(e),m=I.findIndex((w,b)=>w!==h[b]);if(m!==
415
+ -1&&I[m]<h[m])throw l(`Codex helper execution requires app-server ${e} or newer; current version is ${p}. Update Codex a\
416
+ nd retry.`,{actualVersion:p,minimumVersion:e});return Object.freeze({minimumVersion:e,version:p})}function F(v=null){if(!lo(
417
+ v?.config))throw l("Codex helper execution could not read the effective app-server configuration.");let y=v.config.mcp_servers;
418
+ if(y==null)return[];if(S(y,i,"MCP configuration"),!lo(y))throw l("Codex helper execution received an invalid MCP server \
419
+ configuration.");let I=Object.keys(y);if(I.length>o||I.some(p=>!p||p.length>s||xt(p)))throw l("Codex helper execution re\
420
+ ceived an oversized or invalid MCP server inventory.");return I.sort()}function q(v=null,y=""){if(S(v,f,"hook inventory"),
421
+ !Array.isArray(v?.data))throw l("Codex helper execution could not enumerate app-server hooks.");if(v.data.length!==1)throw l(
422
+ "Codex helper execution received an unexpected hook inventory.");let I=v.data[0];if(A(I?.cwd)!==y||A(I?.cwd).length>d||!Array.
423
+ isArray(I.hooks)||!Array.isArray(I.errors)||I.hooks.length>a||I.errors.length>c)throw l("Codex helper execution received\
424
+ an incomplete hook inventory.");if(I.errors.length>0)throw l("Codex helper execution cannot continue while hook discove\
425
+ ry has errors.",{hookErrorCount:I.errors.length});let p=I.hooks.map(m=>{let w=A(m?.key),b=A(m?.currentHash),_=A(m?.handlerType),
426
+ R=A(m?.sourcePath);if(!w||[w,b,_,R].some(E=>E.length>d||xt(E)))throw l("Codex helper execution found an invalid hook inv\
427
+ entory entry.");if(m?.isManaged===!0&&m?.enabled===!0)throw l("Codex helper execution cannot disable a managed hook.");return{
428
+ currentHash:b,enabled:m?.enabled===!0,handlerType:_,isManaged:m?.isManaged===!0,key:w,sourcePath:R}}).sort((m,w)=>m.key.
429
+ localeCompare(w.key)),h=JSON.stringify(p);if(h.length>u)throw l("Codex helper execution received an oversized hook inven\
430
+ tory.");return{fingerprint:h,hookKeys:p.filter(m=>!m.isManaged).map(m=>m.key)}}function V({effort:v="",summary:y="",hookKeys:I=[],
431
+ mcpServerNames:p=[]}={}){let h={features:Object.fromEntries(r.map(w=>[w,!1])),hooks:{state:Object.fromEntries(I.map(w=>[
432
+ w,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
433
+ include_permissions_instructions:!1,...v?{model_reasoning_effort:v}:{},...y?{model_reasoning_summary:y}:{},mcp_servers:Object.
434
+ fromEntries(p.map(w=>[w,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
435
435
  mcp:{enabled:!1},skills:{enabled:!1}},project_doc_max_bytes:0,shell_environment_policy:{inherit:"none",set:{}},skills:{include_instructions:!1},
436
- tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},b=co(A);return h.add(
437
- b),b}async function V(f,{effort:m="",summary:v=""}={}){if(L(f),typeof f?.readConfig!="function"||typeof f?.listHooks!="f\
438
- unction")throw p("Codex helper execution cannot inventory configuration and hooks.");let g=await C(f),A=S(f),b=await f.readConfig(
439
- {cwd:g.cwd,includeLayers:!1});if(S(f)!==A)throw p("Codex app-server reconnected during helper policy verification.");let M=await f.
440
- listHooks([g.cwd]);if(S(f)!==A)throw p("Codex app-server reconnected during helper policy verification.");let J=$(b),be=K(
441
- M,g.cwd);return Object.freeze({accountIdentitySignature:g.accountIdentitySignature,config:F({effort:m,summary:v,hookKeys:be.
442
- hookKeys,mcpServerNames:J}),connectionGeneration:A,executionCwd:g.cwd,hookFingerprint:be.fingerprint,hookKeys:Object.freeze(
443
- [...be.hookKeys]),mcpServerNames:Object.freeze([...J])})}function Z(f=null,m=null){return f?.accountIdentitySignature===
444
- m?.accountIdentitySignature&&f?.connectionGeneration===m?.connectionGeneration&&f?.executionCwd===m?.executionCwd&&f?.hookFingerprint===
445
- m?.hookFingerprint&&JSON.stringify(f?.mcpServerNames||[])===JSON.stringify(m?.mcpServerNames||[])}function ie(f,m,v=""){
446
- let g=_(v);if(!m)return f.codexAppServerHelperThreadId=g,f.codexAppServerHelperThreadRetired=!0,f;let A=p("Codex could n\
447
- ot retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return A.codexAppServerHelperThreadCleanupRequired=
448
- !0,A.codexAppServerHelperThreadId=g,A}async function Te({error:f=null,provider:m=null,threadId:v=""}={}){let g=null;try{
449
- await m.deleteThread(v)}catch(A){g=A}throw ie(f,g,v)}async function zt(f,m){if(typeof f?.startThread!="function"||typeof f?.
450
- deleteThread!="function")throw p("Codex helper execution cannot own and clean up its app-server thread.");let v=await m(),
451
- g=await f.startThread(v.settings),A=_(g?.id);if(!A)throw p("Codex app-server did not return a helper thread id.");try{let b=await V(
452
- f,{effort:v.enforcement.config.model_reasoning_effort,summary:v.enforcement.config.model_reasoning_summary});if(!Z(v.enforcement,
453
- b))throw p("Codex execution surfaces changed while the helper thread was starting.");return Object.freeze({enforcement:b,
454
- thread:g,threadId:A})}catch(b){await Te({error:b,provider:f,threadId:A})}}async function w(f,m,v){if(typeof f?.resumeThread!=
455
- "function"||typeof f?.deleteThread!="function")throw p("Codex helper execution cannot safely resume and clean up its app\
456
- -server thread.");let g=_(m);if(!g)throw p("Codex helper resume requires a controller-owned thread id.");let A=await v(),
457
- b=A.enforcement,M=await f.resumeThread(g,A.settings);try{let J=await V(f,{effort:b.config.model_reasoning_effort,summary:b.
458
- config.model_reasoning_summary});if(!Z(b,J))throw p("Codex execution surfaces changed while the helper thread was resumi\
459
- ng.");return Object.freeze({enforcement:J,thread:M,threadId:g})}catch(J){await Te({error:J,provider:f,threadId:g})}}function y({
460
- configResult:f,hookResult:m,workdir:v,effort:g="",summary:A=""}){let b=$(f),M=K(m,v);return F({effort:g,summary:A,hookKeys:M.
461
- hookKeys,mcpServerNames:b})}function T({approvalPolicy:f,baseInstructions:m,config:v,cwd:g,effectiveSettings:A,sandbox:b,
462
- systemPrompt:M}){return{allowProviderModelFallback:!1,approvalPolicy:f,baseInstructions:m,config:v,cwd:g,systemPrompt:M||
463
- null,dynamicTools:[],environments:[],model:A.model,runtimeWorkspaceRoots:[],sandbox:b,selectedCapabilityRoots:[]}}function R(f,m){
464
- return{...f,sessionStartSource:"startup",threadSource:m}}function E(f){return{approvalPolicy:f.approvalPolicy,baseInstructions:f.
465
- baseInstructions,config:f.config,cwd:f.cwd,systemPrompt:f.systemPrompt,model:f.model,runtimeWorkspaceRoots:f.runtimeWorkspaceRoots,
466
- sandbox:f.sandbox}}function O({approvalPolicy:f,cwd:m,effectiveSettings:v,outputSchema:g}){let A={approvalPolicy:f,cwd:m,
467
- environments:[],model:v.model,outputSchema:g,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
468
- none"};return v.request.reasoning&&(A.effort=v.thinking),A}return Object.freeze({assertCompatibility:L,executionContext:C,
469
- inspect:V,configuration:y,hasConfiguration:f=>h.has(f),threadSettings:T,threadStartSettings:R,threadResumeSettings:E,turnSettings:O,
470
- start:zt,resume:w})}var ql=ka();var ir=1024*1024,Ma=256*1024,uo=512,Na=128,ja=16*1024;function lo({errorPrefix:t="",identityNamespace:e="codex-account-v\
471
- 1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",u=""){let l=new Error(_(u)||"Codex helper authenticatio\
472
- n is unavailable. Reconnect Codex and retry.");return l.code=_(d)||`${t}codex_helper_auth_unavailable`,l}function o(d,{label:u="\
473
- Codex authentication value",maxLength:l=0}={}){if(typeof d!="string"||d.length===0||d.length>l)throw n(`${t}codex_helper\
474
- _auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`sha256:${io(
475
- "sha256").update(`${e}\0`,"utf8").update(_(d),"utf8").update("\0","utf8").update(String(u||""),"utf8").digest("hex")}`}function i(d=""){
476
- return io("sha256").update(`${r}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){let u=null;
477
- try{u=await Ea(d,"r");let l=await u.stat();if(!l.isFile()||l.size>ir)throw n(`${t}codex_helper_auth_invalid`,"The select\
478
- ed Codex authentication record is invalid. Reconnect Codex and retry.");let p=Buffer.alloc(ir+1),h=0;for(;h<p.length;){let{
479
- bytesRead:S}=await u.read(p,h,p.length-h,null);if(S===0)break;h+=S}if(h>ir)throw n(`${t}codex_helper_auth_invalid`,"The \
480
- selected Codex authentication record is too large. Reconnect Codex and retry.");let I=JSON.parse(p.subarray(0,h).toString(
481
- "utf8"));if(!U(I))throw new Error("invalid authentication record");return I}catch(l){throw l?.code?.startsWith?.(`${t}co\
482
- dex_helper_auth_`)?l:n(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. \
483
- Reconnect Codex and retry.")}finally{await u?.close?.().catch(()=>null)}}async function c(d={}){let u=_(d.toolHomeSource);
484
- if(!u||!ar.isAbsolute(u))throw n(`${t}codex_helper_auth_unavailable`,"The selected Codex account is unavailable. Reconne\
485
- ct Codex and retry.");let l=await a(ar.join(u,".codex","auth.json")),p=_(l.auth_mode).toLowerCase();if(p==="chatgpt"){let h=U(
486
- l.tokens)?l.tokens:{},I=o(h.account_id,{label:"Codex account identity",maxLength:uo}),S=o(h.access_token,{label:"Codex a\
487
- ccess token",maxLength:Ma}),C=h.chatgpt_plan_type??h.plan_type,P=C==null||C===""?"":o(C,{label:"Codex plan type",maxLength:Na});
488
- return Object.freeze({accessToken:S,accountId:I,authMode:"chatgpt",identitySignature:s("chatgpt",I),planType:P,secretSignature:i(
489
- S)})}if(["apikey","api_key"].includes(p)){let h=o(l.OPENAI_API_KEY,{label:"Codex API key",maxLength:ja});return Object.freeze(
490
- {apiKey:h,authMode:"apiKey",identitySignature:s("apiKey",h),secretSignature:i(h)})}throw n(`${t}codex_helper_auth_invali\
436
+ tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},m=po(h);return g.add(
437
+ m),m}async function G(v,{effort:y="",summary:I=""}={}){if(N(v),typeof v?.readConfig!="function"||typeof v?.listHooks!="f\
438
+ unction")throw l("Codex helper execution cannot inventory configuration and hooks.");let p=await O(v),h=x(v),m=await v.readConfig(
439
+ {cwd:p.cwd,includeLayers:!1});if(x(v)!==h)throw l("Codex app-server reconnected during helper policy verification.");let w=await v.
440
+ listHooks([p.cwd]);if(x(v)!==h)throw l("Codex app-server reconnected during helper policy verification.");let b=F(m),_=q(
441
+ w,p.cwd);return Object.freeze({accountIdentitySignature:p.accountIdentitySignature,config:V({effort:y,summary:I,hookKeys:_.
442
+ hookKeys,mcpServerNames:b}),connectionGeneration:h,executionCwd:p.cwd,hookFingerprint:_.fingerprint,hookKeys:Object.freeze(
443
+ [..._.hookKeys]),mcpServerNames:Object.freeze([...b])})}function oe(v=null,y=null){return v?.accountIdentitySignature===
444
+ y?.accountIdentitySignature&&v?.connectionGeneration===y?.connectionGeneration&&v?.executionCwd===y?.executionCwd&&v?.hookFingerprint===
445
+ y?.hookFingerprint&&JSON.stringify(v?.mcpServerNames||[])===JSON.stringify(y?.mcpServerNames||[])}function se(v,y,I=""){
446
+ let p=A(I);if(!y)return v.codexAppServerHelperThreadId=p,v.codexAppServerHelperThreadRetired=!0,v;let h=l("Codex could n\
447
+ ot retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:p});return h.codexAppServerHelperThreadCleanupRequired=
448
+ !0,h.codexAppServerHelperThreadId=p,h}async function be({error:v=null,provider:y=null,threadId:I=""}={}){let p=null;try{
449
+ await y.deleteThread(I)}catch(h){p=h}throw se(v,p,I)}async function qt(v,y){if(typeof v?.startThread!="function"||typeof v?.
450
+ deleteThread!="function")throw l("Codex helper execution cannot own and clean up its app-server thread.");let I=await y(),
451
+ p=await v.startThread(I.settings),h=A(p?.id);if(!h)throw l("Codex app-server did not return a helper thread id.");try{let m=await G(
452
+ v,{effort:I.enforcement.config.model_reasoning_effort,summary:I.enforcement.config.model_reasoning_summary});if(!oe(I.enforcement,
453
+ m))throw l("Codex execution surfaces changed while the helper thread was starting.");return Object.freeze({enforcement:m,
454
+ thread:p,threadId:h})}catch(m){await be({error:m,provider:v,threadId:h})}}async function nt(v,y,I){if(typeof v?.resumeThread!=
455
+ "function"||typeof v?.deleteThread!="function")throw l("Codex helper execution cannot safely resume and clean up its app\
456
+ -server thread.");let p=A(y);if(!p)throw l("Codex helper resume requires a controller-owned thread id.");let h=await I(),
457
+ m=h.enforcement,w=await v.resumeThread(p,h.settings);try{let b=await G(v,{effort:m.config.model_reasoning_effort,summary:m.
458
+ config.model_reasoning_summary});if(!oe(m,b))throw l("Codex execution surfaces changed while the helper thread was resum\
459
+ ing.");return Object.freeze({enforcement:b,thread:w,threadId:p})}catch(b){await be({error:b,provider:v,threadId:p})}}function Bt({
460
+ configResult:v,hookResult:y,workdir:I,effort:p="",summary:h=""}){let m=F(v),w=q(y,I);return V({effort:p,summary:h,hookKeys:w.
461
+ hookKeys,mcpServerNames:m})}function he({approvalPolicy:v,baseInstructions:y,config:I,cwd:p,effectiveSettings:h,sandbox:m,
462
+ systemPrompt:w}){return{allowProviderModelFallback:!1,approvalPolicy:v,baseInstructions:y,config:I,cwd:p,systemPrompt:w||
463
+ null,dynamicTools:[],environments:[],model:h.model,runtimeWorkspaceRoots:[],sandbox:m,selectedCapabilityRoots:[]}}function ot(v,y){
464
+ return{...v,sessionStartSource:"startup",threadSource:y}}function _e(v){return{approvalPolicy:v.approvalPolicy,baseInstructions:v.
465
+ baseInstructions,config:v.config,cwd:v.cwd,systemPrompt:v.systemPrompt,model:v.model,runtimeWorkspaceRoots:v.runtimeWorkspaceRoots,
466
+ sandbox:v.sandbox}}function st({approvalPolicy:v,cwd:y,effectiveSettings:I,outputSchema:p}){let h={approvalPolicy:v,cwd:y,
467
+ environments:[],model:I.model,outputSchema:p,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
468
+ none"};return I.request.reasoning&&(h.effort=I.thinking),h}return Object.freeze({assertCompatibility:N,executionContext:O,
469
+ inspect:G,configuration:Bt,hasConfiguration:v=>g.has(v),threadSettings:he,threadStartSettings:ot,threadResumeSettings:_e,
470
+ turnSettings:st,start:qt,resume:nt})}var Yl=za();var pr=1024*1024,La=256*1024,fo=512,Fa=128,$a=16*1024;function ho({errorPrefix:t="",identityNamespace:e="codex-account-v\
471
+ 1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",u=""){let f=new Error(A(u)||"Codex helper authenticatio\
472
+ n is unavailable. Reconnect Codex and retry.");return f.code=A(d)||`${t}codex_helper_auth_unavailable`,f}function o(d,{label:u="\
473
+ Codex authentication value",maxLength:f=0}={}){if(typeof d!="string"||d.length===0||d.length>f)throw n(`${t}codex_helper\
474
+ _auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`sha256:${uo(
475
+ "sha256").update(`${e}\0`,"utf8").update(A(d),"utf8").update("\0","utf8").update(String(u||""),"utf8").digest("hex")}`}function i(d=""){
476
+ return uo("sha256").update(`${r}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){let u=null;
477
+ try{u=await Ma(d,"r");let f=await u.stat();if(!f.isFile()||f.size>pr)throw n(`${t}codex_helper_auth_invalid`,"The select\
478
+ ed Codex authentication record is invalid. Reconnect Codex and retry.");let l=Buffer.alloc(pr+1),g=0;for(;g<l.length;){let{
479
+ bytesRead:x}=await u.read(l,g,l.length-g,null);if(x===0)break;g+=x}if(g>pr)throw n(`${t}codex_helper_auth_invalid`,"The \
480
+ selected Codex authentication record is too large. Reconnect Codex and retry.");let S=JSON.parse(l.subarray(0,g).toString(
481
+ "utf8"));if(!$(S))throw new Error("invalid authentication record");return S}catch(f){throw f?.code?.startsWith?.(`${t}co\
482
+ dex_helper_auth_`)?f:n(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. \
483
+ Reconnect Codex and retry.")}finally{await u?.close?.().catch(()=>null)}}async function c(d={}){let u=A(d.toolHomeSource);
484
+ if(!u||!fr.isAbsolute(u))throw n(`${t}codex_helper_auth_unavailable`,"The selected Codex account is unavailable. Reconne\
485
+ ct Codex and retry.");let f=await a(fr.join(u,".codex","auth.json")),l=A(f.auth_mode).toLowerCase();if(l==="chatgpt"){let g=$(
486
+ f.tokens)?f.tokens:{},S=o(g.account_id,{label:"Codex account identity",maxLength:fo}),x=o(g.access_token,{label:"Codex a\
487
+ ccess token",maxLength:La}),O=g.chatgpt_plan_type??g.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:Fa});
488
+ return Object.freeze({accessToken:x,accountId:S,authMode:"chatgpt",identitySignature:s("chatgpt",S),planType:P,secretSignature:i(
489
+ x)})}if(["apikey","api_key"].includes(l)){let g=o(f.OPENAI_API_KEY,{label:"Codex API key",maxLength:$a});return Object.freeze(
490
+ {apiKey:g,authMode:"apiKey",identitySignature:s("apiKey",g),secretSignature:i(g)})}throw n(`${t}codex_helper_auth_invali\
491
491
  d`,"The selected Codex authentication mode is unsupported. Reconnect Codex and retry.")}return{error:n,identitySignature:s,
492
- readRecord:a,readSelected:c}}import{mkdtemp as Vl,open as Gl,readFile as cr,readdir as Da,rm as Wl}from"node:fs/promises";import{setTimeout as po}from"node:timers/promises";function dr({runtimeTokenEnvironmentName:t="JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION\
493
- _COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable"}={}){let a="linux-proc",c=Object.
494
- freeze({RUNNING:"running",STOPPED:"stopped"}),d=Object.freeze({ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"\
495
- invalid",MISMATCH:"mismatch"});function u(w,y){let T=Number(w);return Number.isSafeInteger(T)&&T>0?T:y}function l(w={}){
496
- return!!(Number.isSafeInteger(Number(w.pid))&&Number(w.pid)>0&&P(w.processIdentity)&&[c.RUNNING,c.STOPPED].includes(w.processState))}
497
- function p(w){let y=Number(w);if(!Number.isSafeInteger(y)||y<=0)return!1;try{return process.kill(y,0),!0}catch{return!1}}
498
- function h(w){let y=Number(w);if(!Number.isSafeInteger(y)||y<=0)return!1;if(process.platform==="win32")return p(y);try{return process.
499
- kill(-y,0),!0}catch{return!1}}function I(w,y){let T=Number(w),R=process.platform==="win32"?T:-T;try{return process.kill(
500
- R,y),!0}catch(E){if(!["ESRCH","EPERM"].includes(String(E?.code||"")))throw E;return!1}}function S(w=""){let y=String(w||
501
- ""),T=y.lastIndexOf(")");if(T<0)return null;let R=y.slice(T+1).trim().split(/\s+/u),E=String(R[0]||""),O=Number(R[1]),f=Number(
502
- R[2]),m=String(R[19]||"");return!/^[A-Z]$/u.test(E)||!Number.isSafeInteger(O)||O<0||!Number.isSafeInteger(f)||f<=0||!/^\d+$/u.
503
- test(m)?null:{parentPid:O,processGroupId:f,startTimeTicks:m,state:E}}function C(w={}){let y=U(w)?w:{};return{commandHash:_(
504
- y.commandHash),platform:_(y.platform),runtimeToken:_(y.runtimeToken),startTimeTicks:_(y.startTimeTicks),version:Number(y.
505
- version||0)}}function P(w={}){let y=C(w);return!!(y.version===1&&y.platform===a&&/^[a-f0-9]{12}$/u.test(y.commandHash)&&
506
- /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(y.runtimeToken)&&/^\d+$/u.test(y.startTimeTicks))}
507
- function j(w=Buffer.alloc(0),y=""){let T=`${y}=`;for(let R of w.toString("utf8").split("\0"))if(R.startsWith(T))return R.
508
- slice(T.length);return""}async function L(){let w=[],y=await Da("/proc",{withFileTypes:!0}).catch(()=>[]);for(let T of y){
509
- if(!T.isDirectory()||!/^\d+$/u.test(T.name))continue;let R=Number(T.name),E=await cr(`/proc/${T.name}/stat`,"utf8").catch(
510
- ()=>""),O=S(E);if(!O||O.state==="Z")continue;let f=null,m=!0;try{f=await cr(`/proc/${T.name}/environ`)}catch(v){if(String(
511
- v?.code||"")==="ENOENT")continue;m=!1}w.push({...O,environment:f,environmentReadable:m,pid:R})}return w}function $(w={}){
512
- let y=Object.values(d).includes(w?.status)?w.status:d.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(w?.processGroupIds)?
513
- w.processGroupIds:[]).map(Number).filter(T=>Number.isSafeInteger(T)&&T>0))],status:y}}async function K(w={}){if(!l(w))return{
514
- processGroupIds:[],status:d.INVALID};if(w.processState===c.STOPPED)return{processGroupIds:[],status:d.ABSENT};if(process.
515
- platform!=="linux")return{processGroupIds:[],status:d.AMBIGUOUS};let y=w.processIdentity,T=await L(),R=Number(w.pid),E=T.
516
- filter(({processGroupId:g})=>g===R),O=[],f=E.some(({environmentReadable:g})=>!g);for(let g of T){if(!g.environmentReadable)
517
- continue;let A=j(g.environment,t),b=j(g.environment,e);A===y.runtimeToken&&b===y.commandHash&&O.push(g)}let m=O.find(({pid:g})=>g===
518
- R);if(m&&m.startTimeTicks!==y.startTimeTicks)return{processGroupIds:[],status:d.AMBIGUOUS};if(O.length===0)return f?{processGroupIds:[],
519
- status:d.AMBIGUOUS}:{processGroupIds:[],status:E.length>0||h(R)?d.MISMATCH:d.ABSENT};let v=[...new Set(O.map(({processGroupId:g})=>g))];
520
- for(let g of v)if(T.filter(b=>b.processGroupId===g).some(b=>!b.environmentReadable||!O.some(({pid:M})=>M===b.pid)))return{
521
- processGroupIds:[],status:d.AMBIGUOUS};return E.some(g=>!O.some(({pid:A})=>A===g.pid))?{processGroupIds:[],status:d.AMBIGUOUS}:
522
- {processGroupIds:v,status:d.EXACT}}async function F(w={},y={}){let T=typeof y.processIdentityInspector=="function"?y.processIdentityInspector:
523
- K;return $(await T(w))}async function V(w={},y={},T=0){let R=Date.now()+T,E=await F(w,y);for(;Date.now()<R&&E.status===d.
524
- EXACT;)await po(100),E=await F(w,y);return E}async function Z(w={},y={}){let T=u(y.processIdentitySettleTimeoutMs,1e3),R=u(
525
- y.processIdentitySettlePollMs,25),E=Date.now()+T,O=await F(w,y);for(;O.status===d.AMBIGUOUS&&Date.now()<E;)await po(Math.
526
- min(R,Math.max(1,E-Date.now()))),O=await F(w,y);return O}async function ie(w={},y="SIGTERM",T={}){let R=typeof T.signalProcessGroup==
527
- "function"?T.signalProcessGroup:I,E=await Z(w,T);if(E.status!==d.EXACT)return{inspection:E,signaledProcessGroups:[]};let O=Number(
528
- w.pid),f=[...E.processGroupIds.filter(v=>v!==O),...E.processGroupIds.filter(v=>v===O)],m=[];for(let v of f){let g=await Z(
529
- w,T);if(g.status===d.ABSENT||g.status===d.MISMATCH)return{inspection:g,signaledProcessGroups:m};if(g.status!==d.EXACT)return{
530
- inspection:g,signaledProcessGroups:m};g.processGroupIds.includes(v)&&(R(v,y),m.push(v))}return{inspection:await Z(w,T),signaledProcessGroups:m}}
531
- async function Te(w={},y={}){if(!l(w))return{identityStatus:d.INVALID,processExitVerified:!1,stopped:!1};if(w.processState===
532
- c.STOPPED&&w.processExitVerifiedAt)return{alreadyStopped:!0,identityStatus:d.ABSENT,processExitVerified:!0,stopped:!1};let T=await Z(
533
- w,y);if(T.status===d.ABSENT||T.status===d.MISMATCH)return{identityStatus:T.status,processExitVerified:!0,stopped:!1};if(T.
534
- status!==d.EXACT)return{identityStatus:T.status,processExitVerified:!1,stopped:!1};let R=await ie(w,"SIGTERM",y);if(R.inspection.
535
- status===d.AMBIGUOUS)return{identityStatus:R.inspection.status,processExitVerified:!1,signaledProcessGroups:R.signaledProcessGroups,
536
- stopped:!1};let E=await V(w,y,u(y.termTimeoutMs,3e3)),O=[...R.signaledProcessGroups];if(E.status===d.EXACT){let m=await ie(
537
- w,"SIGKILL",y);if(O=[...new Set([...O,...m.signaledProcessGroups])],m.inspection.status===d.AMBIGUOUS)return{identityStatus:m.
538
- inspection.status,processExitVerified:!1,signaledProcessGroups:O,stopped:!1};E=await V(w,y,u(y.killTimeoutMs,1e3))}let f=[
539
- d.ABSENT,d.MISMATCH].includes(E.status);return{descendantProcessGroups:O.filter(m=>m!==Number(w.pid)),identityStatus:E.status,
540
- pid:Number(w.pid),processExitVerified:f,signaledProcessGroups:O,stopped:f&&O.length>0}}async function zt({commandHash:w="",
541
- pid:y=null,reportedIdentity:T=null,runtimeToken:R=""}={}){let E=_(w),O=_(R),f=C(T);if(P(f)&&f.commandHash===E&&f.runtimeToken===
542
- O)return f;let m=Number(y);if(process.platform!=="linux"||!Number.isSafeInteger(m)||m<=0){let g=new Error(`${r} process \
543
- identity could not be captured.`);throw g.code=n,g}let v=S(await cr(`/proc/${m}/stat`,"utf8").catch(()=>""));if(!v||v.processGroupId!==
544
- m){let g=new Error(`${r} process identity could not be captured.`);throw g.code=n,g}return{commandHash:E,platform:a,runtimeToken:O,
545
- startTimeTicks:v.startTimeTicks,version:1}}return Object.freeze({normalize:C,isValid:P,normalizeInspection:$,capture:zt,
546
- inspect:F,stop:Te,isProcessAlive:p})}var wt=(t,e,r,n={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(r),...n}),za=Object.freeze([Object.freeze(
492
+ readRecord:a,readSelected:c}}import{execFile as Ua,spawn as ep}from"node:child_process";import{mkdtemp as rp,open as np,readFile as hr,readdir as qa,rm as op}from"node:fs/promises";import{setTimeout as mo}from"node:timers/promises";import{promisify as Ba}from"node:util";var Ha=Ba(Ua);async function Va(t){
493
+ let{stdout:e}=await Ha("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function mr({runtimeTokenEnvironmentName:t="JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION\
494
+ _COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable",platform:o=process.platform,ps:s=Va}={}){
495
+ let a=o==="darwin"?100:25,c=1,d=Object.freeze({linux:"linux-proc",darwin:"darwin"}),u=d[o]||"",f=Object.freeze({RUNNING:"\
496
+ running",STOPPED:"stopped"}),l=Object.freeze({ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"\
497
+ mismatch"});function g(p,h){let m=Number(p);return Number.isSafeInteger(m)&&m>0?m:h}function S(p={}){return!!(Number.isSafeInteger(
498
+ Number(p.pid))&&Number(p.pid)>0&&F(p.processIdentity)&&[f.RUNNING,f.STOPPED].includes(p.processState))}function x(p){let h=Number(
499
+ p);if(!Number.isSafeInteger(h)||h<=0)return!1;try{return process.kill(h,0),!0}catch{return!1}}function O(p){let h=Number(
500
+ p);if(!Number.isSafeInteger(h)||h<=0)return!1;if(process.platform==="win32")return x(h);try{return process.kill(-h,0),!0}catch{
501
+ return!1}}function P(p,h){let m=Number(p),w=process.platform==="win32"?m:-m;try{return process.kill(w,h),!0}catch(b){if(![
502
+ "ESRCH","EPERM"].includes(String(b?.code||"")))throw b;return!1}}function D(p=""){let h=String(p||""),m=h.lastIndexOf(")");
503
+ if(m<0)return null;let w=h.slice(m+1).trim().split(/\s+/u),b=String(w[0]||""),_=Number(w[1]),R=Number(w[2]),E=String(w[19]||
504
+ "");return!/^[A-Z]$/u.test(b)||!Number.isSafeInteger(_)||_<0||!Number.isSafeInteger(R)||R<=0||!/^\d+$/u.test(E)?null:{parentPid:_,
505
+ processGroupId:R,startTimeTicks:E,state:b}}function N(p={}){let h=$(p)?p:{};return{commandHash:A(h.commandHash),platform:A(
506
+ h.platform),runtimeToken:A(h.runtimeToken),startTimeTicks:A(h.startTimeTicks),version:Number(h.version||0)}}function F(p={}){
507
+ let h=N(p);return!!(h.version===c&&Object.values(d).includes(h.platform)&&/^[a-f0-9]{12}$/u.test(h.commandHash)&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.
508
+ test(h.runtimeToken)&&/^\d+$/u.test(h.startTimeTicks))}function q(p=[],h=""){let m=p.find(w=>w.startsWith(`${h}=`));return m?
509
+ m.slice(h.length+1):""}async function V(){let p=[],h=await qa("/proc",{withFileTypes:!0}).catch(()=>[]);for(let m of h){
510
+ if(!m.isDirectory()||!/^\d+$/u.test(m.name))continue;let w=Number(m.name),b=await hr(`/proc/${m.name}/stat`,"utf8").catch(
511
+ ()=>""),_=D(b);if(!_||_.state==="Z")continue;let R=null,E=!0;try{R=await hr(`/proc/${m.name}/environ`)}catch(C){if(String(
512
+ C?.code||"")==="ENOENT")continue;E=!1}let j=E?R.toString("utf8").split("\0"):[];p.push({..._,commandHash:q(j,e),environmentReadable:E,
513
+ pid:w,runtimeToken:q(j,t)})}return p}let G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oe(p=""){
514
+ let h=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.exec(String(p).trim()),m=h?G.indexOf(h[1]):-1;
515
+ if(m<0)return"";let[,,w,b,_,R,E]=h.map(Number);return String(Date.UTC(E,m,w,b,_,R)/1e3)}function se(p=""){let h=new Map;
516
+ for(let m of String(p).split(`
517
+ `)){let w=/^\s*(\d+) (.*)$/u.exec(m);w&&h.set(Number(w[1]),w[2])}return h}function be(p,h){if(p===void 0||!h?.startsWith(
518
+ p))return null;let m=h.slice(p.length).split(/\s+/u).filter(w=>/^[^=\s]+=/u.test(w));return m.length?m:null}async function qt(){
519
+ let p=process.getuid(),h=["-x","-U",String(p),"-ww","-o","pid=,command="],[m,w,b]=await Promise.all([s(["-ax","-o","pid=\
520
+ ,pgid=,uid=,stat=,lstart="]),s(h),s(["-E",...h])]),_=se(w),R=se(b),E=[];for(let j of String(m).split(`
521
+ `)){let C=/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+[\d:]{8}\s+\d{4})\s*$/u.exec(j);if(!C||C[4].startsWith(
522
+ "Z"))continue;let Ae=Number(C[1]),ie=Number(C[3])===p?be(_.get(Ae),R.get(Ae)):null;E.push({commandHash:q(ie||[],e),environmentReadable:!!ie,
523
+ pid:Ae,processGroupId:Number(C[2]),runtimeToken:q(ie||[],t),startTimeTicks:oe(C[5])})}return E}function nt(p={}){let h=Object.
524
+ values(l).includes(p?.status)?p.status:l.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(p?.processGroupIds)?
525
+ p.processGroupIds:[]).map(Number).filter(m=>Number.isSafeInteger(m)&&m>0))],status:h}}async function Bt(p={}){if(!S(p))return{
526
+ processGroupIds:[],status:l.INVALID};if(p.processState===f.STOPPED)return{processGroupIds:[],status:l.ABSENT};let h=p.processIdentity,
527
+ m=h.platform!==u?null:o==="darwin"?await qt().catch(()=>null):await V();if(!m)return{processGroupIds:[],status:l.AMBIGUOUS};
528
+ let w=Number(p.pid),b=m.filter(({processGroupId:C})=>C===w),_=[],R=b.some(({environmentReadable:C})=>!C);for(let C of m)
529
+ C.environmentReadable&&C.runtimeToken===h.runtimeToken&&C.commandHash===h.commandHash&&_.push(C);let E=_.find(({pid:C})=>C===
530
+ w);if(E&&E.startTimeTicks!==h.startTimeTicks)return{processGroupIds:[],status:l.AMBIGUOUS};if(_.length===0)return R?{processGroupIds:[],
531
+ status:l.AMBIGUOUS}:{processGroupIds:[],status:b.length>0||O(w)?l.MISMATCH:l.ABSENT};let j=[...new Set(_.map(({processGroupId:C})=>C))];
532
+ for(let C of j)if(m.filter(ie=>ie.processGroupId===C).some(ie=>!ie.environmentReadable||!_.some(({pid:Js})=>Js===ie.pid)))
533
+ return{processGroupIds:[],status:l.AMBIGUOUS};return b.some(C=>!_.some(({pid:Ae})=>Ae===C.pid))?{processGroupIds:[],status:l.
534
+ AMBIGUOUS}:{processGroupIds:j,status:l.EXACT}}async function he(p={},h={}){let m=typeof h.processIdentityInspector=="fun\
535
+ ction"?h.processIdentityInspector:Bt;return nt(await m(p))}async function ot(p={},h={},m=0){let w=Date.now()+m,b=await he(
536
+ p,h);for(;Date.now()<w&&b.status===l.EXACT;)await mo(100),b=await he(p,h);return b}async function _e(p={},h={}){let m=g(
537
+ h.processIdentitySettleTimeoutMs,1e3),w=g(h.processIdentitySettlePollMs,a),b=Date.now()+m,_=await he(p,h);for(;_.status===
538
+ l.AMBIGUOUS&&Date.now()<b;)await mo(Math.min(w,Math.max(1,b-Date.now()))),_=await he(p,h);return _}async function st(p={},h="\
539
+ SIGTERM",m={}){let w=typeof m.signalProcessGroup=="function"?m.signalProcessGroup:P,b=await _e(p,m);if(b.status!==l.EXACT)
540
+ return{inspection:b,signaledProcessGroups:[]};let _=Number(p.pid),R=[...b.processGroupIds.filter(j=>j!==_),...b.processGroupIds.
541
+ filter(j=>j===_)],E=[];for(let j of R){let C=await _e(p,m);if(C.status===l.ABSENT||C.status===l.MISMATCH)return{inspection:C,
542
+ signaledProcessGroups:E};if(C.status!==l.EXACT)return{inspection:C,signaledProcessGroups:E};C.processGroupIds.includes(j)&&
543
+ (w(j,h),E.push(j))}return{inspection:await _e(p,m),signaledProcessGroups:E}}async function v(p={},h={}){if(!S(p))return{
544
+ identityStatus:l.INVALID,processExitVerified:!1,stopped:!1};if(p.processState===f.STOPPED&&p.processExitVerifiedAt)return{
545
+ alreadyStopped:!0,identityStatus:l.ABSENT,processExitVerified:!0,stopped:!1};let m=await _e(p,h);if(m.status===l.ABSENT||
546
+ m.status===l.MISMATCH)return{identityStatus:m.status,processExitVerified:!0,stopped:!1};if(m.status!==l.EXACT)return{identityStatus:m.
547
+ status,processExitVerified:!1,stopped:!1};let w=await st(p,"SIGTERM",h);if(w.inspection.status===l.AMBIGUOUS)return{identityStatus:w.
548
+ inspection.status,processExitVerified:!1,signaledProcessGroups:w.signaledProcessGroups,stopped:!1};let b=await ot(p,h,g(
549
+ h.termTimeoutMs,3e3)),_=[...w.signaledProcessGroups];if(b.status===l.EXACT){let E=await st(p,"SIGKILL",h);if(_=[...new Set(
550
+ [..._,...E.signaledProcessGroups])],E.inspection.status===l.AMBIGUOUS)return{identityStatus:E.inspection.status,processExitVerified:!1,
551
+ signaledProcessGroups:_,stopped:!1};b=await ot(p,h,g(h.killTimeoutMs,1e3))}let R=[l.ABSENT,l.MISMATCH].includes(b.status);
552
+ return{descendantProcessGroups:_.filter(E=>E!==Number(p.pid)),identityStatus:b.status,pid:Number(p.pid),processExitVerified:R,
553
+ signaledProcessGroups:_,stopped:R&&_.length>0}}async function y(p){if(o!=="darwin")return D(await hr(`/proc/${p}/stat`,"\
554
+ utf8").catch(()=>""));let h=String(await s(["-o","pgid=,lstart=","-p",String(p)]).catch(()=>"")),m=/^\s*(\d+)\s+(.+?)\s*$/u.
555
+ exec(h);return m?{processGroupId:Number(m[1]),startTimeTicks:oe(m[2])}:null}async function I({commandHash:p="",pid:h=null,
556
+ reportedIdentity:m=null,runtimeToken:w=""}={}){let b=A(p),_=A(w),R=N(m);if(F(R)&&R.commandHash===b&&R.runtimeToken===_)return R;
557
+ let E=Number(h),j=u&&Number.isSafeInteger(E)&&E>0?await y(E):null;if(!j?.startTimeTicks||j.processGroupId!==E){let C=new Error(
558
+ `${r} process identity could not be captured.`);throw C.code=n,C}return{commandHash:b,platform:u,runtimeToken:_,startTimeTicks:j.
559
+ startTimeTicks,version:c}}return Object.freeze({normalize:N,isValid:F,normalizeInspection:nt,capture:I,inspect:he,stop:v,
560
+ isProcessAlive:x})}var Tt=(t,e,r,n={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(r),...n}),Ga=Object.freeze([Object.freeze(
547
561
  {id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
548
- webSearch:!1,models:Object.freeze([wt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
549
- wt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0})])}),Object.freeze({id:"zai-coding-plan",baseUrl:"h\
562
+ webSearch:!1,models:Object.freeze([Tt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
563
+ Tt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0})])}),Object.freeze({id:"zai-coding-plan",baseUrl:"h\
550
564
  ttps://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,webSearch:!1,models:Object.
551
- freeze([wt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai",
565
+ freeze([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai",
552
566
  baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,webSearch:!1,
553
- models:Object.freeze([wt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function ye(t){
554
- return za.find(e=>e.id===t)||null}var Zl=32*1024*1024,ep=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
555
- deepseek:ye("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":ye("zai-coding-plan").baseUrl,zai:ye("zai").baseUrl});var sp=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexProcess.js",import.meta.url).href;var pp=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),fp=dr();var Fa=Object.freeze({UNIX:"unix"});var hp=process.platform==="linux"?107:103,mp=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
556
- UNREACHABLE:"unreachable"}),gp=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
557
- SUSPECT:"suspect"}),$a=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),vp=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
558
- ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var ef=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),tf=lo().error;var rf=32*1024,nf=2*1024*1024;var of=64*1024,sf=2*1024*1024,af=4*1024*1024;import{createRequire as fc}from"node:module";var pc=new URL("./../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var ch=fc(pc);var uh=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function q(t,{fallback:e=""}={}){return String(t||"").trim()||e}function Ye(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var lh=Object.freeze(["bundled","dev_server"]),ph=Object.freeze(["capacitor"]),fh=Object.freeze({callbackPath:"/auth/log\
559
- in",customScheme:"",appLinkDomains:Object.freeze([])}),hh=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
560
- versionName:"1.0.0"});var bh=new URL("./../../../@jskit-ai/kernel/server/support/appConfigFiles.js",import.meta.url).href;var Mh=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Nh=Object.freeze(["capabilities","kind",
561
- "metadata","migrations","runtime","vite"]);var yr="/api",Vh=`${yr}/`,Gh=`${yr}/docs`,Wh=`${yr}/realtime`;var om=Object.freeze(["compact","medium","expanded"]);var rg=64*1024;var _t=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
562
- ng=new Set(Object.values(_t)),og=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
567
+ models:Object.freeze([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function Ie(t){
568
+ return Ga.find(e=>e.id===t)||null}var lp=32*1024*1024,pp=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
569
+ deepseek:Ie("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":Ie("zai-coding-plan").baseUrl,zai:Ie("zai").baseUrl});var vp=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexProcess.js",import.meta.url).href;var bp=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),_p=mr();var Ka=Object.freeze({UNIX:"unix"});var Ap=process.platform==="linux"?107:103,Cp=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
570
+ UNREACHABLE:"unreachable"}),Ep=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
571
+ SUSPECT:"suspect"}),Ja=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),Op=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
572
+ ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var ff=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),hf=ho().error;var mf=32*1024,gf=2*1024*1024;var vf=64*1024,wf=2*1024*1024,yf=4*1024*1024;import{createRequire as xc}from"node:module";var Sc=new URL("./../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var Ih=xc(Sc);var xh=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function U(t,{fallback:e=""}={}){return String(t||"").trim()||e}function Qe(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var Th=Object.freeze(["bundled","dev_server"]),bh=Object.freeze(["capacitor"]),_h=Object.freeze({callbackPath:"/auth/log\
573
+ in",customScheme:"",appLinkDomains:Object.freeze([])}),Ah=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
574
+ versionName:"1.0.0"});var Dh=new URL("./../../../@jskit-ai/kernel/server/support/appConfigFiles.js",import.meta.url).href;var Vh=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Gh=Object.freeze(["capabilities","kind",
575
+ "metadata","migrations","runtime","vite"]);var _r="/api",nm=`${_r}/`,om=`${_r}/docs`,sm=`${_r}/realtime`;var gm=Object.freeze(["compact","medium","expanded"]);var hg=64*1024;var Rt=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
576
+ mg=new Set(Object.values(Rt)),gg=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
563
577
  jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
564
- sg=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),ig=Object.freeze(["accountIde\
578
+ vg=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),wg=Object.freeze(["accountIde\
565
579
  ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
566
- Hash","terminalEnvHash","toolHomeSource","transport"]),ag=Object.freeze(["userAgent"]);function H(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
567
- kc(e)}function kc(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function Ir(t){return t!==null&&typeof t=="object"&&H(t.structure)&&H(t.operations)&&typeof t.validateWith=="function"&&
568
- typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function At(t,e){if(!Object.hasOwn(e,"items"))return null;
569
- let{items:r}=e;if(Ir(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!="string")throw new Error(`Array field "${t}\
570
- " must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Qe(t,e){
571
- if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(Ir(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!=
580
+ Hash","terminalEnvHash","toolHomeSource","transport"]),yg=Object.freeze(["userAgent"]);function H(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
581
+ Uc(e)}function Uc(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function Ar(t){return t!==null&&typeof t=="object"&&H(t.structure)&&H(t.operations)&&typeof t.validateWith=="function"&&
582
+ typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Pt(t,e){if(!Object.hasOwn(e,"items"))return null;
583
+ let{items:r}=e;if(Ar(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!="string")throw new Error(`Array field "${t}\
584
+ " must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Ze(t,e){
585
+ if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(Ar(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!=
572
586
  "string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
573
- t.`);return{kind:"definition",definition:r}}function Ct(t,e){let r=Object.hasOwn(e,"schema"),n=Object.hasOwn(e,"values"),
587
+ t.`);return{kind:"definition",definition:r}}function kt(t,e){let r=Object.hasOwn(e,"schema"),n=Object.hasOwn(e,"values"),
574
588
  o=Object.hasOwn(e,"additionalProperties");if(r&&n)throw new Error(`Object field "${t}" cannot define both schema and val\
575
589
  ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
576
590
  if(n&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
577
- s: true.`);if(r){if(!Ir(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
578
- kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Qe(
579
- t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ne(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}var Sr="^(?:0|-?[1-9]\\d*)$",Bo="\\d{4}",Ho="0[1-9]|1[0-2]",Vo="0[1-9]|[12]\\d|3[01]",Go="[01]\\d|2[0-3]",je="[0-5]\\d",
580
- Et=`(?:${Go}):${je}`,Wo=`(?:Z|[+-](?:${Go}):${je})`,Ko=`(${Bo})-(${Ho})-(${Vo})`,Jo=`${Bo}-(?:${Ho})-(?:${Vo})`,Xo=`^${Jo}\
581
- $`,Mc=new RegExp(`^${Ko}$`),Nc=new RegExp(`^${Et}(?::${je}(?:\\.(\\d+))?)?$`),jc=new RegExp(`^${Ko}T${Et}:${je}(?:\\.(\\d+\
582
- ))?${Wo}$`),Dc=new RegExp(Sr),zc=[31,28,31,30,31,30,31,31,30,31,30,31];function Lc(t){return t%4===0&&(t%100!==0||t%400===
583
- 0)}function Fc(t,e){return e===2?Lc(t)?29:28:zc[e-1]}function Yo(t,e,r){let n=Number(t),o=Number(e),s=Number(r);return o>=
584
- 1&&o<=12&&s>=1&&s<=Fc(n,o)}function Ze(t,e){let r=t.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
585
- `temporalPrecision for "${e}" must be a non-negative integer.`);return r}}function Qo(t,e){return t===void 0?!0:e===void 0||
586
- t.length<=e}function Zo(t){if(typeof t!="string")return!1;let e=Mc.exec(t);return e!==null&&Yo(e[1],e[2],e[3])}function es(t,e){
587
- if(typeof t!="string")return!1;let r=Nc.exec(t);return r!==null&&Qo(r[1],e)}function ts(t,e){if(typeof t!="string")return!1;
588
- let r=jc.exec(t);return r===null?!1:Yo(r[1],r[2],r[3])&&Qo(r[4],e)}function rs(t){return t===void 0?"(?:\\.\\d+)?":t===0?
589
- "":`(?:\\.\\d{1,${t}})?`}function ns(t,e){let r=Ze(t,e);return`^${Et}(?::${je}${rs(r)})?$`}function os(t,e){let r=Ze(t,e);
590
- return`^${Jo}T${Et}:${je}${rs(r)}${Wo}$`}function xr(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&Dc.
591
- test(t))r=Number(t);else return null;return!Number.isSafeInteger(r)||r<-e||r>e?null:r===0?0:r}var $c=new Set(["__proto__","prototype","constructor"]);function x(t,e,r){Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Uc(t,e){if($c.
592
- has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function qc(t){return typeof t!="string"?t:t.replace(
593
- /\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Tr(t,e,{normalize:r=!1,allowEmpty:n=!1}={}){
594
- let o=r?qc(t):t;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${e}() expects a non-empty \
591
+ s: true.`);if(r){if(!Ar(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
592
+ kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Ze(
593
+ t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function De(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}var Cr="^(?:0|-?[1-9]\\d*)$",Go="\\d{4}",Wo="0[1-9]|1[0-2]",Ko="0[1-9]|[12]\\d|3[01]",Jo="[01]\\d|2[0-3]",ze="[0-5]\\d",
594
+ Mt=`(?:${Jo}):${ze}`,Xo=`(?:Z|[+-](?:${Jo}):${ze})`,Yo=`(${Go})-(${Wo})-(${Ko})`,Qo=`${Go}-(?:${Wo})-(?:${Ko})`,Zo=`^${Qo}\
595
+ $`,qc=new RegExp(`^${Yo}$`),Bc=new RegExp(`^${Mt}(?::${ze}(?:\\.(\\d+))?)?$`),Hc=new RegExp(`^${Yo}T${Mt}:${ze}(?:\\.(\\d+\
596
+ ))?${Xo}$`),Vc=new RegExp(Cr),Gc=[31,28,31,30,31,30,31,31,30,31,30,31];function Wc(t){return t%4===0&&(t%100!==0||t%400===
597
+ 0)}function Kc(t,e){return e===2?Wc(t)?29:28:Gc[e-1]}function es(t,e,r){let n=Number(t),o=Number(e),s=Number(r);return o>=
598
+ 1&&o<=12&&s>=1&&s<=Kc(n,o)}function et(t,e){let r=t.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
599
+ `temporalPrecision for "${e}" must be a non-negative integer.`);return r}}function ts(t,e){return t===void 0?!0:e===void 0||
600
+ t.length<=e}function rs(t){if(typeof t!="string")return!1;let e=qc.exec(t);return e!==null&&es(e[1],e[2],e[3])}function ns(t,e){
601
+ if(typeof t!="string")return!1;let r=Bc.exec(t);return r!==null&&ts(r[1],e)}function os(t,e){if(typeof t!="string")return!1;
602
+ let r=Hc.exec(t);return r===null?!1:es(r[1],r[2],r[3])&&ts(r[4],e)}function ss(t){return t===void 0?"(?:\\.\\d+)?":t===0?
603
+ "":`(?:\\.\\d{1,${t}})?`}function is(t,e){let r=et(t,e);return`^${Mt}(?::${ze}${ss(r)})?$`}function as(t,e){let r=et(t,e);
604
+ return`^${Qo}T${Mt}:${ze}${ss(r)}${Xo}$`}function Er(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&Vc.
605
+ test(t))r=Number(t);else return null;return!Number.isSafeInteger(r)||r<-e||r>e?null:r===0?0:r}var Jc=new Set(["__proto__","prototype","constructor"]);function T(t,e,r){Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Xc(t,e){if(Jc.
606
+ has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function Yc(t){return typeof t!="string"?t:t.replace(
607
+ /\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Or(t,e,{normalize:r=!1,allowEmpty:n=!1}={}){
608
+ let o=r?Yc(t):t;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${e}() expects a non-empty \
595
609
  dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
596
- for(let i of s)Uc(i,e);return s}var Bc="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",br=["object","array","string","number","boolean"],
597
- _r=Symbol("json-rest-schema.exportContext"),Hc=["true","1","yes","y","on"],Vc=["false","0","no","n","off"];function ss(t){
598
- return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:Sr}]}}function Ie(t,e){return{[fe]:{[t]:e}}}var Gc={
599
- none:()=>({type:br}),blob:()=>({type:br}),serialize:()=>({type:br}),object:()=>({type:"object"}),array:()=>({type:"array"}),
610
+ for(let i of s)Xc(i,e);return s}var Qc="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",Rr=["object","array","string","number","boolean"],
611
+ Pr=Symbol("json-rest-schema.exportContext"),Zc=["true","1","yes","y","on"],ed=["false","0","no","n","off"];function cs(t){
612
+ return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:Cr}]}}function Se(t,e){return{[fe]:{[t]:e}}}var td={
613
+ none:()=>({type:Rr}),blob:()=>({type:Rr}),serialize:()=>({type:Rr}),object:()=>({type:"object"}),array:()=>({type:"array"}),
600
614
  file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
601
- eger","string"]}),epochMilliseconds:()=>ss(864e13),epochSeconds:()=>ss(864e10),dateTime:({definition:t,fieldName:e})=>({
602
- type:"string",format:"date-time",pattern:os(t,e)}),date:()=>({type:"string",format:"date",pattern:Xo}),time:({definition:t,
603
- fieldName:e})=>({type:"string",pattern:ns(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
604
- let e=new Set([...Hc,String(t.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...Vc,String(t.stringFalseWhen||
615
+ eger","string"]}),epochMilliseconds:()=>cs(864e13),epochSeconds:()=>cs(864e10),dateTime:({definition:t,fieldName:e})=>({
616
+ type:"string",format:"date-time",pattern:as(t,e)}),date:()=>({type:"string",format:"date",pattern:Zo}),time:({definition:t,
617
+ fieldName:e})=>({type:"string",pattern:is(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
618
+ let e=new Set([...Zc,String(t.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...ed,String(t.stringFalseWhen||
605
619
  "false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...r,...e]}]}},
606
- id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},Wc={minLength:({definition:t,parameterValue:e})=>t.
620
+ id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},rd={minLength:({definition:t,parameterValue:e})=>t.
607
621
  type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
608
- definition:t,parameterValue:e})=>Ne(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ne(t)?{maximum:e}:null,pattern:({
622
+ definition:t,parameterValue:e})=>De(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>De(t)?{maximum:e}:null,pattern:({
609
623
  definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
610
624
  enum:t}),notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({parameterValue:t})=>t?
611
- Ie("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Ie("transforms",{lowercase:!0}):null,length:({parameterValue:t})=>Ie(
612
- "transforms",{length:t}),unsigned:({parameterValue:t})=>t?Ie("metadata",{unsigned:!0}):null,precision:({parameterValue:t})=>Ie(
613
- "metadata",{precision:t}),scale:({parameterValue:t})=>Ie("metadata",{scale:t}),temporalPrecision:({parameterValue:t})=>Ie(
625
+ Se("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Se("transforms",{lowercase:!0}):null,length:({parameterValue:t})=>Se(
626
+ "transforms",{length:t}),unsigned:({parameterValue:t})=>t?Se("metadata",{unsigned:!0}):null,precision:({parameterValue:t})=>Se(
627
+ "metadata",{precision:t}),scale:({parameterValue:t})=>Se("metadata",{scale:t}),temporalPrecision:({parameterValue:t})=>Se(
614
628
  "metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null};
615
- function Or(t,e){for(let r of Object.keys(e)){let n=e[r],o=t[r];if(n&&o&&typeof n=="object"&&typeof o=="object"&&!Array.
616
- isArray(n)&&!Array.isArray(o)){Or(o,n);continue}t[r]=n}}function Kc(t,e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(
629
+ function jr(t,e){for(let r of Object.keys(e)){let n=e[r],o=t[r];if(n&&o&&typeof n=="object"&&typeof o=="object"&&!Array.
630
+ isArray(n)&&!Array.isArray(o)){jr(o,n);continue}t[r]=n}}function nd(t,e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(
617
631
  "JSON Schema export hooks must return an object or null.");for(let r of Object.keys(e)){if(r===fe&&t[r]&&typeof t[r]=="o\
618
- bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){Or(t[r],e[r]);continue}t[r]=e[r]}}function Jc(t,e){
619
- let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function Xc(t,e){
632
+ bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){jr(t[r],e[r]);continue}t[r]=e[r]}}function od(t,e){
633
+ let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function sd(t,e){
620
634
  if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);let r=t.types[e.type];if(typeof r.
621
- toJsonSchema=="function")return r.toJsonSchema;let n=Gc[e.type];if(!n)throw new Error(`Type '${e.type}' cannot be export\
622
- ed to JSON Schema without a toJsonSchema hook.`);return n}function Yc(t,e,r){if(!Object.hasOwn(t.validators,e))return null;
623
- let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=Wc[e];if(o)return o;throw new Error(
624
- `Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function is(t){if(t===
635
+ toJsonSchema=="function")return r.toJsonSchema;let n=td[e.type];if(!n)throw new Error(`Type '${e.type}' cannot be export\
636
+ ed to JSON Schema without a toJsonSchema hook.`);return n}function id(t,e,r){if(!Object.hasOwn(t.validators,e))return null;
637
+ let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=rd[e];if(o)return o;throw new Error(
638
+ `Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function ds(t){if(t===
625
639
  void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(`Unsupported JSON Schema expo\
626
- rt mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function Qc(t,e={}){if(e.mode!==void 0&&e.operation!==void 0){
627
- let r=is(e.mode);if(r!==e.operation)throw new Error(`Conflicting JSON Schema export options: mode '${r}' does not match \
640
+ rt mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function ad(t,e={}){if(e.mode!==void 0&&e.operation!==void 0){
641
+ let r=ds(e.mode);if(r!==e.operation)throw new Error(`Conflicting JSON Schema export options: mode '${r}' does not match \
628
642
  operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))throw new Error(`Unkn\
629
- own JSON Schema export operation '${e.operation}'.`);return e.operation}return is(e.mode)}function Zc(t,e={}){if(e.operationName!==
630
- void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};let r=Qc(t,
631
- e);return{operationName:r,operation:t.operations[r]}}function ed(t={}){let e={...t};return Object.defineProperty(e,_r,{value:{
632
- definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function Rt(t={}){return t[_r]?t[_r]:{definitions:{},
633
- nodes:[],nextDefinitionId:1,rootNode:null}}function td(t){return String(t).replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,
634
- "")||"operation"}function Ar(t){return H(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}function Ot(t){return Ar(
635
- t)?{allOf:[t]}:t}function rd(t,e,r,n,o){return t.nodes.find(s=>s.schema===e&&s.operationName===r&&s.operation===n&&s.additionalProperties===
636
- o)||null}function nd(t,e){let r=td(e),n=`SchemaNode_${t.nextDefinitionId}_${r}`;return t.nextDefinitionId+=1,n}function as(t,e,r,n,o,{
637
- root:s=!1}={}){let i=Rt(e),a=rd(i,t,r,n,o);if(a)return s&&(a.pointer="#",i.rootNode=a),a;let c={schema:t,operationName:r,
638
- operation:n,additionalProperties:o,status:"new",definitionName:s?null:nd(i,r),pointer:s?"#":null};return s?i.rootNode=c:
639
- c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function cs(t,e){if(t.status==="built")return{$ref:t.pointer};
640
- if(t.status==="building")return{$ref:t.pointer};let r=Rt(e);t.status="building",t.pointer!=="#"&&(r.definitions[t.definitionName]=
641
- {});let n=od(t.schema,e,t.operationName,t.operation,t.additionalProperties);return t.status="built",t.pointer==="#"?n:(r.
642
- definitions[t.definitionName]=n,{$ref:t.pointer})}function Rr(t,e,r,n,o=!1){let s=Rt(e),i=as(t,e,r,n,o);return s.rootNode===
643
- i?{$ref:"#"}:cs(i,e)}function et(t,{referenceBacked:e=!1}={}){return{schema:t,referenceBacked:e}}function od(t,e,r,n,o=!1){
644
- let s={},i=[];for(let[c,d]of Object.entries(t.structure))x(s,c,Pr(t,c,d,e,r,n)),n.enforceRequired&&d.required===!0&&i.push(
645
- c);let a={type:"object",properties:s,additionalProperties:o};return i.length>0&&(a.required=i),a}function sd(t,e,r,n,o,s){
646
- let i=At(e,r);if(!i)return null;if(i.kind==="schema")return{...Ot(Rr(i.schema,n,"replace",i.schema.operations.replace,!1)),
643
+ own JSON Schema export operation '${e.operation}'.`);return e.operation}return ds(e.mode)}function cd(t,e={}){if(e.operationName!==
644
+ void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};let r=ad(t,
645
+ e);return{operationName:r,operation:t.operations[r]}}function dd(t={}){let e={...t};return Object.defineProperty(e,Pr,{value:{
646
+ definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function jt(t={}){return t[Pr]?t[Pr]:{definitions:{},
647
+ nodes:[],nextDefinitionId:1,rootNode:null}}function ud(t){return String(t).replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,
648
+ "")||"operation"}function kr(t){return H(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}function Nt(t){return kr(
649
+ t)?{allOf:[t]}:t}function ld(t,e,r,n,o){return t.nodes.find(s=>s.schema===e&&s.operationName===r&&s.operation===n&&s.additionalProperties===
650
+ o)||null}function pd(t,e){let r=ud(e),n=`SchemaNode_${t.nextDefinitionId}_${r}`;return t.nextDefinitionId+=1,n}function us(t,e,r,n,o,{
651
+ root:s=!1}={}){let i=jt(e),a=ld(i,t,r,n,o);if(a)return s&&(a.pointer="#",i.rootNode=a),a;let c={schema:t,operationName:r,
652
+ operation:n,additionalProperties:o,status:"new",definitionName:s?null:pd(i,r),pointer:s?"#":null};return s?i.rootNode=c:
653
+ c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function ls(t,e){if(t.status==="built")return{$ref:t.pointer};
654
+ if(t.status==="building")return{$ref:t.pointer};let r=jt(e);t.status="building",t.pointer!=="#"&&(r.definitions[t.definitionName]=
655
+ {});let n=fd(t.schema,e,t.operationName,t.operation,t.additionalProperties);return t.status="built",t.pointer==="#"?n:(r.
656
+ definitions[t.definitionName]=n,{$ref:t.pointer})}function Dr(t,e,r,n,o=!1){let s=jt(e),i=us(t,e,r,n,o);return s.rootNode===
657
+ i?{$ref:"#"}:ls(i,e)}function tt(t,{referenceBacked:e=!1}={}){return{schema:t,referenceBacked:e}}function fd(t,e,r,n,o=!1){
658
+ let s={},i=[];for(let[c,d]of Object.entries(t.structure))T(s,c,zr(t,c,d,e,r,n)),n.enforceRequired&&d.required===!0&&i.push(
659
+ c);let a={type:"object",properties:s,additionalProperties:o};return i.length>0&&(a.required=i),a}function hd(t,e,r,n,o,s){
660
+ let i=Pt(e,r);if(!i)return null;if(i.kind==="schema")return{...Nt(Dr(i.schema,n,"replace",i.schema.operations.replace,!1)),
647
661
  [fe]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,"schema")?"replace":o,c=a==="replace"?t.operations.
648
- replace:s;return Pr(t,`${e}[]`,r.items,n,a,c)}function id(t,e,r,n,o,s){let i=Qe(e,r);if(!i)return null;if(i.kind==="sche\
649
- ma")return{...Ot(Rr(i.schema,n,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=i.definition.type===
650
- "object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return Pr(t,`${e}.*`,i.
651
- definition,n,a,c)}function ad(t,e,r,n,o,s){if(r.type==="object"){let a=Ct(e,r);if(a.kind==="nested")return et(Rr(a.schema,
652
- n,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return et({type:"object",additionalProperties:!0});
653
- if(a.kind==="map")return et({type:"object",additionalProperties:id(t,e,r,n,o,s)})}let i=Xc(t,r)({schema:t,fieldName:e,definition:r,
662
+ replace:s;return zr(t,`${e}[]`,r.items,n,a,c)}function md(t,e,r,n,o,s){let i=Ze(e,r);if(!i)return null;if(i.kind==="sche\
663
+ ma")return{...Nt(Dr(i.schema,n,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=i.definition.type===
664
+ "object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return zr(t,`${e}.*`,i.
665
+ definition,n,a,c)}function gd(t,e,r,n,o,s){if(r.type==="object"){let a=kt(e,r);if(a.kind==="nested")return tt(Dr(a.schema,
666
+ n,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return tt({type:"object",additionalProperties:!0});
667
+ if(a.kind==="map")return tt({type:"object",additionalProperties:md(t,e,r,n,o,s)})}let i=sd(t,r)({schema:t,fieldName:e,definition:r,
654
668
  operation:o,mode:o,options:n});if(!i||typeof i!="object"||Array.isArray(i))throw new Error(`Type '${r.type}' on field '${e}\
655
- ' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=sd(t,e,r,n,o,s);if(a)return et({...i,items:a},{
656
- referenceBacked:Ar(i)})}return et(i,{referenceBacked:Ar(i)})}function Pr(t,e,r,n,o,s){let i={schema:t,fieldName:e,definition:r,
657
- operation:o,mode:o,options:n},a=ad(t,e,r,n,o,s),c=a.referenceBacked?Ot(a.schema):{...a.schema},d={castType:r.type};for(let p of Object.
658
- keys(r)){if(p==="type"||!Object.hasOwn(t.validators,p))continue;let h=Yc(t,p,e);if(!h)continue;let I=h({...i,parameterName:p,
659
- parameterValue:r[p],fieldSchema:{...c}});I&&Kc(c,I)}c[fe]&&(Or(d,c[fe]),delete c[fe]);let u=[];r.nullable===!0&&u.push({
660
- type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let l=Ot(Jc(c,u));if(r.defaultTo!==void 0&&s.applyDefaults)if(typeof r.
661
- defaultTo!="function"){let p=t._normalizeDefault(r,r.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},
662
- options:{},settings:t._buildOperationSettings(o,s,{})});if(Object.keys(p.errors).length>0){let h=Object.values(p.errors)[0];
663
- throw new Error(`defaultTo for "${e}" is invalid (${h.code}).`)}l.default=p.value}else d.defaults={providedByFunction:!0};
664
- return l[fe]=d,l}function ds(t,e={}){let r=ed(e),{operationName:n,operation:o}=Zc(t,r),s=r.additionalProperties===void 0?
665
- !1:r.additionalProperties,i=Rt(r),a=as(t,r,n,o,s,{root:!0}),c={$schema:Bc,...cs(a,r)};return Object.keys(i.definitions).
666
- length>0&&(c.definitions=i.definitions),c}function us(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Dr(t){return t instanceof
667
- Le}function cd(){return{self:!1,children:{}}}function ls(t){return Object.keys(t.children).length>0}function Se(t,e){return`${t}\
668
- .${String(e)}`}function vs(t,e){return t===""?String(e):Se(t,e)}function ps(t,e){if(t===e)return"";let r=`${e}.`;return t.
669
- startsWith(r)?t.slice(r.length):null}function De(t,e){let r={};for(let n of Object.values(t)){let o=Se(e,n.field);x(r,o,
670
- {...n,field:o})}return r}function Nr(t){return Tr(t,"validatePath")}function fs(t){let e={};for(let r of t){let n=Nr(r),
671
- o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||x(o,i,cd()),s===n.length-1&&(o[i].self=!0),o=o[i].children}}
672
- return e}function dd(t,e){let r=t;for(let n of e){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
673
- function Pt(t){return t===null?!0:Array.isArray(t)||H(t)?Object.keys(t).length>0:t!==void 0}function hs(t){return[...t].
669
+ ' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=hd(t,e,r,n,o,s);if(a)return tt({...i,items:a},{
670
+ referenceBacked:kr(i)})}return tt(i,{referenceBacked:kr(i)})}function zr(t,e,r,n,o,s){let i={schema:t,fieldName:e,definition:r,
671
+ operation:o,mode:o,options:n},a=gd(t,e,r,n,o,s),c=a.referenceBacked?Nt(a.schema):{...a.schema},d={castType:r.type};for(let l of Object.
672
+ keys(r)){if(l==="type"||!Object.hasOwn(t.validators,l))continue;let g=id(t,l,e);if(!g)continue;let S=g({...i,parameterName:l,
673
+ parameterValue:r[l],fieldSchema:{...c}});S&&nd(c,S)}c[fe]&&(jr(d,c[fe]),delete c[fe]);let u=[];r.nullable===!0&&u.push({
674
+ type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let f=Nt(od(c,u));if(r.defaultTo!==void 0&&s.applyDefaults)if(typeof r.
675
+ defaultTo!="function"){let l=t._normalizeDefault(r,r.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},
676
+ options:{},settings:t._buildOperationSettings(o,s,{})});if(Object.keys(l.errors).length>0){let g=Object.values(l.errors)[0];
677
+ throw new Error(`defaultTo for "${e}" is invalid (${g.code}).`)}f.default=l.value}else d.defaults={providedByFunction:!0};
678
+ return f[fe]=d,f}function ps(t,e={}){let r=dd(e),{operationName:n,operation:o}=cd(t,r),s=r.additionalProperties===void 0?
679
+ !1:r.additionalProperties,i=jt(r),a=us(t,r,n,o,s,{root:!0}),c={$schema:Qc,...ls(a,r)};return Object.keys(i.definitions).
680
+ length>0&&(c.definitions=i.definitions),c}function fs(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function qr(t){return t instanceof
681
+ $e}function vd(){return{self:!1,children:{}}}function hs(t){return Object.keys(t.children).length>0}function xe(t,e){return`${t}\
682
+ .${String(e)}`}function Is(t,e){return t===""?String(e):xe(t,e)}function ms(t,e){if(t===e)return"";let r=`${e}.`;return t.
683
+ startsWith(r)?t.slice(r.length):null}function Le(t,e){let r={};for(let n of Object.values(t)){let o=xe(e,n.field);T(r,o,
684
+ {...n,field:o})}return r}function $r(t){return Or(t,"validatePath")}function gs(t){let e={};for(let r of t){let n=$r(r),
685
+ o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||T(o,i,vd()),s===n.length-1&&(o[i].self=!0),o=o[i].children}}
686
+ return e}function wd(t,e){let r=t;for(let n of e){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
687
+ function Dt(t){return t===null?!0:Array.isArray(t)||H(t)?Object.keys(t).length>0:t!==void 0}function vs(t){return[...t].
674
688
  sort((e,r)=>{let n=/^[0-9]+$/.test(e),o=/^[0-9]+$/.test(r);return n&&o?Number(e)-Number(r):n?-1:o?1:e.localeCompare(r)})}
675
- function ud(t){return/^[0-9]+$/.test(t)}function ld(t,e=new WeakMap){if(e.has(t))return e.get(t);let r=Object.create(Le.
689
+ function yd(t){return/^[0-9]+$/.test(t)}function Id(t,e=new WeakMap){if(e.has(t))return e.get(t);let r=Object.create($e.
676
690
  prototype);return e.set(t,r),r.structure=null,r.types=t.types,r.validators=t.validators,r.operations=t.operations,r.structure=
677
- Mt(kt(t.structure,e)),r._installOperationMethods(),Object.freeze(r)}function kt(t,e=new WeakMap){if(t===null||typeof t!=
678
- "object")return t;if(Dr(t))return ld(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let n=new RegExp(
691
+ Lt(zt(t.structure,e)),r._installOperationMethods(),Object.freeze(r)}function zt(t,e=new WeakMap){if(t===null||typeof t!=
692
+ "object")return t;if(qr(t))return Id(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let n=new RegExp(
679
693
  t.source,t.flags);return n.lastIndex=t.lastIndex,n}if(e.has(t))return e.get(t);if(Array.isArray(t)){let n=[];e.set(t,n);
680
- for(let o of t)n.push(kt(o,e));return n}if(!H(t))return t;let r={};e.set(t,r);for(let[n,o]of Object.entries(t))x(r,n,kt(
681
- o,e));return r}function Mt(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Dr(t))return t;if(e.add(t),Array.
682
- isArray(t))for(let r of t)Mt(r,e);else for(let r of Reflect.ownKeys(t))Mt(t[r],e);return Object.freeze(t)}function kr(t){
683
- return Mt(kt(t))}function jr(t,e,r=""){if(!Dr(t)||!Array.isArray(e)||e.length<1)return null;let[n,...o]=e;if(!Object.hasOwn(
684
- t.structure,n))return null;let s=t.structure[n];if(o.length<1)return s;let i=vs(r,n);return ws(t,s,o,i)}function ws(t,e,r,n){
685
- if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:jr(o.schema,r,n)}if(e?.type===
686
- "array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[s,...i]=r;if(!ud(s))return null;let a=Se(
687
- n,s);return o.kind==="schema"?i.length<1?null:jr(o.schema,i,a):i.length<1?o.definition:ws(t,o.definition,i,a)}return null}
688
- function ze(t,e){let r={...t};if(Array.isArray(t.skipFields)){let n=t.skipFields.map(o=>ps(o,e)).filter(o=>o!==null&&o!==
694
+ for(let o of t)n.push(zt(o,e));return n}if(!H(t))return t;let r={};e.set(t,r);for(let[n,o]of Object.entries(t))T(r,n,zt(
695
+ o,e));return r}function Lt(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||qr(t))return t;if(e.add(t),Array.
696
+ isArray(t))for(let r of t)Lt(r,e);else for(let r of Reflect.ownKeys(t))Lt(t[r],e);return Object.freeze(t)}function Lr(t){
697
+ return Lt(zt(t))}function Ur(t,e,r=""){if(!qr(t)||!Array.isArray(e)||e.length<1)return null;let[n,...o]=e;if(!Object.hasOwn(
698
+ t.structure,n))return null;let s=t.structure[n];if(o.length<1)return s;let i=Is(r,n);return Ss(t,s,o,i)}function Ss(t,e,r,n){
699
+ if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:Ur(o.schema,r,n)}if(e?.type===
700
+ "array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[s,...i]=r;if(!yd(s))return null;let a=xe(
701
+ n,s);return o.kind==="schema"?i.length<1?null:Ur(o.schema,i,a):i.length<1?o.definition:Ss(t,o.definition,i,a)}return null}
702
+ function Fe(t,e){let r={...t};if(Array.isArray(t.skipFields)){let n=t.skipFields.map(o=>ms(o,e)).filter(o=>o!==null&&o!==
689
703
  "");n.length>0?r.skipFields=n:delete r.skipFields}if(H(t.skipParams)){let n={};for(let[o,s]of Object.entries(t.skipParams)){
690
- let i=ps(o,e);i===null||i===""||x(n,i,s)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var pd=Object.
704
+ let i=ms(o,e);i===null||i===""||T(n,i,s)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var Sd=Object.
691
705
  freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
692
706
  replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
693
707
  patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
694
- function ms(t,e,r,n){let o=e[r];if(!n.includes(o))throw new Error(`Operation "${t}" must define ${r} as one of: ${n.join(
695
- ", ")}.`)}function Mr(t,e,r,n=!0){let o=e[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
696
- must define ${r} as a boolean.`)}function fd(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
697
- eration "${t}" must be an object.`);return ms(t,e,"targetFields",["schema","input"]),Mr(t,e,"enforceRequired"),Mr(t,e,"a\
698
- pplyDefaults"),ms(t,e,"outputFields",["validated","input"]),Mr(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
708
+ function ws(t,e,r,n){let o=e[r];if(!n.includes(o))throw new Error(`Operation "${t}" must define ${r} as one of: ${n.join(
709
+ ", ")}.`)}function Fr(t,e,r,n=!0){let o=e[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
710
+ must define ${r} as a boolean.`)}function xd(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
711
+ eration "${t}" must be an object.`);return ws(t,e,"targetFields",["schema","input"]),Fr(t,e,"enforceRequired"),Fr(t,e,"a\
712
+ pplyDefaults"),ws(t,e,"outputFields",["validated","input"]),Fr(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
699
713
  targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
700
- rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function hd(t={}){if(typeof t!="object"||t===null||Array.
714
+ rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function Td(t={}){if(typeof t!="object"||t===null||Array.
701
715
  isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[r,n]of Object.entries(
702
- pd))x(e,r,n);for(let[r,n]of Object.entries(t))x(e,r,fd(r,n));return Object.freeze(e)}function gs(t){let e=Object.create(
703
- null);for(let[r,n]of Object.entries(t))x(e,r,n);return Object.freeze(e)}function md(t){let e={...t};return delete e.operation,
704
- delete e.mode,e}var Le=class{constructor(e,r,n,o={}){this.structure=e,this.types=gs(r),this.validators=gs(n),this.operations=
705
- hd(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could not be cas\
716
+ Sd))T(e,r,n);for(let[r,n]of Object.entries(t))T(e,r,xd(r,n));return Object.freeze(e)}function ys(t){let e=Object.create(
717
+ null);for(let[r,n]of Object.entries(t))T(e,r,n);return Object.freeze(e)}function bd(t){let e={...t};return delete e.operation,
718
+ delete e.mode,e}var $e=class{constructor(e,r,n,o={}){this.structure=e,this.types=ys(r),this.validators=ys(n),this.operations=
719
+ Td(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could not be cas\
706
720
  t to the required type.")}_paramError(e,r,n,o={}){let s=new Error(n);return s.errorObject={field:e,code:r,message:n,params:o},
707
721
  s}_paramToBeSkipped(e,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(e))}_fieldToBeSkipped(e,r){
708
- return Array.isArray(r.skipFields)&&r.skipFields.includes(e)}_mergeErrors(e,r){for(let[n,o]of Object.entries(r))x(e,n,o)}_singleErrorMap(e){
709
- let r={};return x(r,e.field,e),r}_assertSupportedOptions(e={}){if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("U\
722
+ return Array.isArray(r.skipFields)&&r.skipFields.includes(e)}_mergeErrors(e,r){for(let[n,o]of Object.entries(r))T(e,n,o)}_singleErrorMap(e){
723
+ let r={};return T(r,e.field,e),r}_assertSupportedOptions(e={}){if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("U\
710
724
  nsupported validation option `onlyObjectValues`. Call `patch()` directly.");if(Object.hasOwn(e,"mode"))throw new Error("\
711
725
  Unsupported validation option `mode`. Call `validateWith()` or an operation method directly.");if(Object.hasOwn(e,"opera\
712
726
  tion"))throw new Error("Unsupported validation option `operation`. Call `validateWith()` or an operation method directly\
@@ -717,136 +731,136 @@ isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(e,r){if(!H(r))thro
717
731
  ct input.`)}_resolvePathValidationRequest(e={}){let r=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
718
732
  hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
719
733
  oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
720
- return{operationName:r,operation:n,validationOptions:md(e)}}_buildOperationResult(e,r,n){let o={};for(let s of n.outputFieldNames){
734
+ return{operationName:r,operation:n,validationOptions:bd(e)}}_buildOperationResult(e,r,n){let o={};for(let s of n.outputFieldNames){
721
735
  if(!Object.hasOwn(this.structure,s))continue;let i=n.isFieldPresent(s);(r[s]!==void 0||i&&e[s]===null||n.defaultedFields.
722
- has(s))&&(!i&&!n.defaultedFields.has(s)||x(o,s,r[s]))}return o}_resolveObjectFieldMode(e,r){return Ct(e,r)}_resolveArrayItemsConfig(e,r){
723
- return At(e,r)}_resolveObjectValuesConfig(e,r){return Qe(e,r)}_buildArrayItemSettings(e,r){return e.type==="object"&&Object.
736
+ has(s))&&(!i&&!n.defaultedFields.has(s)||T(o,s,r[s]))}return o}_resolveObjectFieldMode(e,r){return kt(e,r)}_resolveArrayItemsConfig(e,r){
737
+ return Pt(e,r)}_resolveObjectValuesConfig(e,r){return Ze(e,r)}_buildArrayItemSettings(e,r){return e.type==="object"&&Object.
724
738
  hasOwn(e,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(e,r,n,o,s,i,a,c){let d=e.
725
739
  nullable===!0||a.nullable===!0,u=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
726
- `No casting function for type: ${e.type}`);let l=this.types[e.type];if(r===null)return d?(x(o,s,null),{errors:{},shouldContinue:!1}):
740
+ `No casting function for type: ${e.type}`);let f=this.types[e.type];if(r===null)return d?(T(o,s,null),{errors:{},shouldContinue:!1}):
727
741
  {errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
728
- if(r===""&&u)return x(o,s,null),{errors:{},shouldContinue:!1};let p={schema:this,definition:e,value:r,fieldName:n,object:o,
742
+ if(r===""&&u)return T(o,s,null),{errors:{},shouldContinue:!1};let l={schema:this,definition:e,value:r,fieldName:n,object:o,
729
743
  objectBeforeCast:i,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
730
- nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(h,I,S)=>{throw this._paramError(
731
- n,h,I,S)}};try{let h=l(p);if(us(h))throw new Error(`Type handler for "${e.type}" must be synchronous.`);h!==void 0&&(x(o,
732
- s,h),p.value=h)}catch(h){if(h.errorObject)return{errors:this._singleErrorMap(h.errorObject),shouldContinue:!1};throw h}return{
733
- errors:{},context:p,shouldContinue:!0}}_runFieldValidators(e,r,n,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
744
+ nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(g,S,x)=>{throw this._paramError(
745
+ n,g,S,x)}};try{let g=f(l);if(fs(g))throw new Error(`Type handler for "${e.type}" must be synchronous.`);g!==void 0&&(T(o,
746
+ s,g),l.value=g)}catch(g){if(g.errorObject)return{errors:this._singleErrorMap(g.errorObject),shouldContinue:!1};throw g}return{
747
+ errors:{},context:l,shouldContinue:!0}}_runFieldValidators(e,r,n,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
734
748
  _paramToBeSkipped(a,i.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
735
- a,s.parameterValue=e[a];let d=c(s);if(us(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
736
- (x(n,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,r,n,o,s,i,a,c){
749
+ a,s.parameterValue=e[a];let d=c(s);if(fs(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
750
+ (T(n,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,r,n,o,s,i,a,c){
737
751
  let d=this._castValue(e,r,n,o,s,i,a,c);if(Object.keys(d.errors).length>0)return d.errors;if(!d.shouldContinue)return{};let{
738
- context:u}=d,l=this._validateNestedValue(e,n,o,s,a,c);return Object.keys(l).length>0?l:(u.value=o[s],this._runFieldValidators(
752
+ context:u}=d,f=this._validateNestedValue(e,n,o,s,a,c);return Object.keys(f).length>0?f:(u.value=o[s],this._runFieldValidators(
739
753
  e,n,o,s,u,a))}_normalizeDefault(e,r,{fieldPath:n,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
740
- let d={...o};return x(d,s,r),{errors:this._normalizeAndValidateValue(e,r,n,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,r,n,o,s,i){
754
+ let d={...o};return T(d,s,r),{errors:this._normalizeAndValidateValue(e,r,n,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,r,n,o,s,i){
741
755
  if(e.type==="object"){let c=this._resolveObjectFieldMode(r,e);return c.kind==="nested"?this._validateNestedObjectSchema(
742
756
  c,r,n,o,s,i):c.kind==="map"?this._validateObjectValues(r,n,o,c.valuesConfig,s,i):{}}if(e.type!=="array")return{};let a=this.
743
757
  _resolveArrayItemsConfig(r,e);return a?this._validateArrayItems(r,n,o,a,s,i):{}}_validateNestedObjectSchema(e,r,n,o,s,i){
744
758
  let a=n[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
745
- i.operationName,i.operation,c,ze(s,r));return x(n,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
746
- a,e.schema,d.validatedObject):d.validatedObject),De(d.errors,r)}_extractKnownObjectFields(e,r){let n={};for(let[o,s]of Object.
747
- entries(e))Object.hasOwn(r.structure,o)&&x(n,o,s);return n}_mergeKnownAndPassthroughObjectFields(e,r,n){let o={};for(let s of Object.
748
- keys(e)){if(!Object.hasOwn(r.structure,s)){x(o,s,e[s]);continue}Object.hasOwn(n,s)&&x(o,s,n[s])}for(let[s,i]of Object.entries(
749
- n))Object.hasOwn(o,s)||x(o,s,i);return o}_validateObjectValues(e,r,n,o,s,i){let a=r[n],c={...a},d={};x(r,n,c);for(let u of Object.
750
- keys(a)){let l=Se(e,u);if(this._fieldToBeSkipped(l,s))continue;let p=c[u];if(p===void 0){i.rejectExplicitUndefined?this.
751
- _mergeErrors(d,this._singleErrorMap(this._typeError(l).errorObject)):delete c[u];continue}if(o.kind==="schema"){let I=o.
752
- schema._validateWithOperation("replace",o.schema.operations.replace,p,ze(s,l));x(c,u,I.validatedObject),this._mergeErrors(
753
- d,De(I.errors,l));continue}let h=this._normalizeAndValidateValue(o.definition,p,l,c,u,a,s,this._buildArrayItemSettings(o.
754
- definition,i));this._mergeErrors(d,h)}return d}_validateArrayItems(e,r,n,o,s,i){let a=r[n],c=a.slice(),d={};x(r,n,c);for(let u=0;u<
755
- c.length;u++){let l=Se(e,u);if(this._fieldToBeSkipped(l,s))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){i.rejectExplicitUndefined?
756
- this._mergeErrors(d,this._singleErrorMap(this._typeError(l).errorObject)):delete c[u];continue}if(o.kind==="schema"){let h=o.
757
- schema._validateWithOperation("replace",o.schema.operations.replace,c[u],ze(s,l));x(c,u,h.validatedObject),this._mergeErrors(
758
- d,De(h.errors,l));continue}let p=this._normalizeAndValidateValue(o.definition,c[u],l,c,u,a,s,this._buildArrayItemSettings(
759
- o.definition,i));this._mergeErrors(d,p)}return d}_validateField(e,r,n,o,s){if(!Object.hasOwn(this.structure,e))return{};
759
+ i.operationName,i.operation,c,Fe(s,r));return T(n,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
760
+ a,e.schema,d.validatedObject):d.validatedObject),Le(d.errors,r)}_extractKnownObjectFields(e,r){let n={};for(let[o,s]of Object.
761
+ entries(e))Object.hasOwn(r.structure,o)&&T(n,o,s);return n}_mergeKnownAndPassthroughObjectFields(e,r,n){let o={};for(let s of Object.
762
+ keys(e)){if(!Object.hasOwn(r.structure,s)){T(o,s,e[s]);continue}Object.hasOwn(n,s)&&T(o,s,n[s])}for(let[s,i]of Object.entries(
763
+ n))Object.hasOwn(o,s)||T(o,s,i);return o}_validateObjectValues(e,r,n,o,s,i){let a=r[n],c={...a},d={};T(r,n,c);for(let u of Object.
764
+ keys(a)){let f=xe(e,u);if(this._fieldToBeSkipped(f,s))continue;let l=c[u];if(l===void 0){i.rejectExplicitUndefined?this.
765
+ _mergeErrors(d,this._singleErrorMap(this._typeError(f).errorObject)):delete c[u];continue}if(o.kind==="schema"){let S=o.
766
+ schema._validateWithOperation("replace",o.schema.operations.replace,l,Fe(s,f));T(c,u,S.validatedObject),this._mergeErrors(
767
+ d,Le(S.errors,f));continue}let g=this._normalizeAndValidateValue(o.definition,l,f,c,u,a,s,this._buildArrayItemSettings(o.
768
+ definition,i));this._mergeErrors(d,g)}return d}_validateArrayItems(e,r,n,o,s,i){let a=r[n],c=a.slice(),d={};T(r,n,c);for(let u=0;u<
769
+ c.length;u++){let f=xe(e,u);if(this._fieldToBeSkipped(f,s))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){i.rejectExplicitUndefined?
770
+ this._mergeErrors(d,this._singleErrorMap(this._typeError(f).errorObject)):delete c[u];continue}if(o.kind==="schema"){let g=o.
771
+ schema._validateWithOperation("replace",o.schema.operations.replace,c[u],Fe(s,f));T(c,u,g.validatedObject),this._mergeErrors(
772
+ d,Le(g.errors,f));continue}let l=this._normalizeAndValidateValue(o.definition,c[u],f,c,u,a,s,this._buildArrayItemSettings(
773
+ o.definition,i));this._mergeErrors(d,l)}return d}_validateField(e,r,n,o,s){if(!Object.hasOwn(this.structure,e))return{};
760
774
  let i=this.structure[e];if(this._fieldToBeSkipped(e,o))return{};let a=s.isFieldPresent(e),c=r[e],d=c===void 0;return s.enforceRequired&&
761
775
  i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
762
776
  Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
763
777
  _normalizeAndValidateValue(i,c,e,n,e,r,o,s):{}}_validateWithOperation(e,r,n,o){this._assertSupportedOptions(o);let s={},
764
- i={...n},a=this._buildOperationSettings(e,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||x(s,c,{field:c,
778
+ i={...n},a=this._buildOperationSettings(e,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||T(s,c,{field:c,
765
779
  code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
766
780
  c,n,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
767
781
  this.structure[c].defaultTo!==void 0){let d=this.structure[c],u=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
768
- l=this._normalizeDefault(d,u,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
769
- _mergeErrors(s,l.errors),Object.keys(l.errors).length>0)continue;x(i,c,l.value),a.defaultedFields.add(c)}}return{validatedObject:this.
770
- _buildOperationResult(n,i,a),errors:s}}_validateSelectedTree(e,r,n,o,s=""){let i={},a={};for(let c of hs(Object.keys(e))){
771
- let d=vs(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let u=this._validateSelectedField(
782
+ f=this._normalizeDefault(d,u,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
783
+ _mergeErrors(s,f.errors),Object.keys(f.errors).length>0)continue;T(i,c,f.value),a.defaultedFields.add(c)}}return{validatedObject:this.
784
+ _buildOperationResult(n,i,a),errors:s}}_validateSelectedTree(e,r,n,o,s=""){let i={},a={};for(let c of vs(Object.keys(e))){
785
+ let d=Is(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let u=this._validateSelectedField(
772
786
  c,e[c],r,a,n,o,d);this._mergeErrors(i,u)}return{validatedObject:a,errors:i}}_validateSelectedField(e,r,n,o,s,i,a){if(!Object.
773
- hasOwn(this.structure,e))return{};let c=this.structure[e],d=r.self===!0,u=ls(r);if(this._fieldToBeSkipped(a,s))return{};
774
- let l=Object.hasOwn(n,e),p=n[e],h={};if(!l){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
775
- a)&&this._mergeErrors(h,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
776
- c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,j=this._normalizeDefault(c,P,{fieldPath:a,
777
- currentObject:o,containerKey:e,objectBeforeCast:n,options:s,settings:i});this._mergeErrors(h,j.errors),Object.keys(j.errors).
778
- length===0&&x(o,e,j.value)}return h}if(p===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
779
- a).errorObject):{};let I={[e]:p};if(d){let P=this._normalizeAndValidateValue(c,p,a,I,e,n,s,i);return Object.hasOwn(I,e)&&
780
- I[e]!==void 0?x(o,e,I[e]):I[e]===null&&x(o,e,null),P}if(!u)return{};let S=this._castValue(c,p,a,I,e,n,s,i);if(Object.keys(
781
- S.errors).length>0)return S.errors;if(!S.shouldContinue)return{};let C=this._validateSelectedDescendants(c,r.children,a,
782
- I,e,s,i);return Pt(I[e])&&x(o,e,I[e]),C}_validateSelectedDescendants(e,r,n,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
787
+ hasOwn(this.structure,e))return{};let c=this.structure[e],d=r.self===!0,u=hs(r);if(this._fieldToBeSkipped(a,s))return{};
788
+ let f=Object.hasOwn(n,e),l=n[e],g={};if(!f){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
789
+ a)&&this._mergeErrors(g,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
790
+ c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,D=this._normalizeDefault(c,P,{fieldPath:a,
791
+ currentObject:o,containerKey:e,objectBeforeCast:n,options:s,settings:i});this._mergeErrors(g,D.errors),Object.keys(D.errors).
792
+ length===0&&T(o,e,D.value)}return g}if(l===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
793
+ a).errorObject):{};let S={[e]:l};if(d){let P=this._normalizeAndValidateValue(c,l,a,S,e,n,s,i);return Object.hasOwn(S,e)&&
794
+ S[e]!==void 0?T(o,e,S[e]):S[e]===null&&T(o,e,null),P}if(!u)return{};let x=this._castValue(c,l,a,S,e,n,s,i);if(Object.keys(
795
+ x.errors).length>0)return x.errors;if(!x.shouldContinue)return{};let O=this._validateSelectedDescendants(c,r.children,a,
796
+ S,e,s,i);return Dt(S[e])&&T(o,e,S[e]),O}_validateSelectedDescendants(e,r,n,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
783
797
  n,e);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let d=o[s];if(!H(
784
- d))return{};let u=c.schema._validateSelectedTree(r,d,ze(i,n),{...a,defaultedFields:new Set});return x(o,s,u.validatedObject),
785
- De(u.errors,n)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(n,e);if(!c)throw new Error(`Schema path "${n}" d\
798
+ d))return{};let u=c.schema._validateSelectedTree(r,d,Fe(i,n),{...a,defaultedFields:new Set});return T(o,s,u.validatedObject),
799
+ Le(u.errors,n)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(n,e);if(!c)throw new Error(`Schema path "${n}" d\
786
800
  oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,s,c,r,i,a)}throw new Error(
787
801
  `Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(e,r,n,o,s,i,a){let c=[],d=r[n],
788
- u={};x(r,n,c);for(let l of hs(Object.keys(s))){if(!/^[0-9]+$/.test(l))throw new Error(`Schema path "${Se(e,l)}" is inval\
789
- id because array segments must use numeric indexes.`);let p=Number(l),h=Se(e,p),I=s[l],S=I.self===!0,C=ls(I);if(this._fieldToBeSkipped(
790
- h,i))continue;if(!Object.hasOwn(d,p)){S&&a.rejectExplicitUndefined&&x(u,h,this._typeError(h).errorObject);continue}let P=d[p];
791
- if(P===void 0){S&&a.rejectExplicitUndefined&&x(u,h,this._typeError(h).errorObject);continue}if(o.kind==="schema"){if(S){
792
- let V=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,ze(i,h));Pt(V.validatedObject)&&x(c,p,V.validatedObject),
793
- this._mergeErrors(u,De(V.errors,h));continue}if(!C)continue;let F=o.schema._validateSelectedTree(I.children,P,ze(i,h),{...a,
794
- operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Pt(F.validatedObject)&&x(c,p,F.validatedObject),
795
- this._mergeErrors(u,De(F.errors,h));continue}let j=this._buildArrayItemSettings(o.definition,a),L=[P];if(S){let F=this._normalizeAndValidateValue(
796
- o.definition,P,h,L,0,d,i,j);Object.hasOwn(L,0)&&L[0]!==void 0?x(c,p,L[0]):L[0]===null&&x(c,p,null),this._mergeErrors(u,F);
797
- continue}if(!C)continue;let $=this._castValue(o.definition,P,h,L,0,d,i,j);if(Object.keys($.errors).length>0){this._mergeErrors(
798
- u,$.errors);continue}if(!$.shouldContinue)continue;let K=this._validateSelectedDescendants(o.definition,I.children,h,L,0,
799
- i,j);Pt(L[0])&&x(c,p,L[0]),this._mergeErrors(u,K)}return u}validateWith(e,r,n={}){if(!Object.hasOwn(this.operations,e))throw new Error(
802
+ u={};T(r,n,c);for(let f of vs(Object.keys(s))){if(!/^[0-9]+$/.test(f))throw new Error(`Schema path "${xe(e,f)}" is inval\
803
+ id because array segments must use numeric indexes.`);let l=Number(f),g=xe(e,l),S=s[f],x=S.self===!0,O=hs(S);if(this._fieldToBeSkipped(
804
+ g,i))continue;if(!Object.hasOwn(d,l)){x&&a.rejectExplicitUndefined&&T(u,g,this._typeError(g).errorObject);continue}let P=d[l];
805
+ if(P===void 0){x&&a.rejectExplicitUndefined&&T(u,g,this._typeError(g).errorObject);continue}if(o.kind==="schema"){if(x){
806
+ let G=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,Fe(i,g));Dt(G.validatedObject)&&T(c,l,G.validatedObject),
807
+ this._mergeErrors(u,Le(G.errors,g));continue}if(!O)continue;let V=o.schema._validateSelectedTree(S.children,P,Fe(i,g),{...a,
808
+ operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Dt(V.validatedObject)&&T(c,l,V.validatedObject),
809
+ this._mergeErrors(u,Le(V.errors,g));continue}let D=this._buildArrayItemSettings(o.definition,a),N=[P];if(x){let V=this._normalizeAndValidateValue(
810
+ o.definition,P,g,N,0,d,i,D);Object.hasOwn(N,0)&&N[0]!==void 0?T(c,l,N[0]):N[0]===null&&T(c,l,null),this._mergeErrors(u,V);
811
+ continue}if(!O)continue;let F=this._castValue(o.definition,P,g,N,0,d,i,D);if(Object.keys(F.errors).length>0){this._mergeErrors(
812
+ u,F.errors);continue}if(!F.shouldContinue)continue;let q=this._validateSelectedDescendants(o.definition,S.children,g,N,0,
813
+ i,D);Dt(N[0])&&T(c,l,N[0]),this._mergeErrors(u,q)}return u}validateWith(e,r,n={}){if(!Object.hasOwn(this.operations,e))throw new Error(
800
814
  `Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,r),this._validateWithOperation(
801
- e,o,r,n)}validateAt(e,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Nr(e),{operationName:s,operation:i,validationOptions:a}=this.
802
- _resolvePathValidationRequest(n),c=this._validateSelectedTree(fs([e]),r,a,this._buildOperationSettings(s,i,r));return{validatedValue:dd(
815
+ e,o,r,n)}validateAt(e,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=$r(e),{operationName:s,operation:i,validationOptions:a}=this.
816
+ _resolvePathValidationRequest(n),c=this._validateSelectedTree(gs([e]),r,a,this._buildOperationSettings(s,i,r));return{validatedValue:wd(
803
817
  c.validatedObject,o),errors:c.errors}}validatePaths(e,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
804
818
  isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
805
- operation:s,validationOptions:i}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(fs(e),r,i,this.
819
+ operation:s,validationOptions:i}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(gs(e),r,i,this.
806
820
  _buildOperationSettings(o,s,r))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
807
821
  `Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(r,n={})=>this.validateWith(e,r,n)}}toJsonSchema(e={}){
808
- return ds(this,e)}getFieldDefinitions(){return kr(this.structure)}getFieldDefinition(e){if(typeof e!="string"||e.trim()===
809
- "")throw new Error("Field path must be a non-empty string.");let r=jr(this,Nr(e.trim()));return r===null?null:kr(r)}getFieldMessages(e){
810
- let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):kr(r.messages)}cleanup(e,r){
811
- let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&x(n,o,e[o]);return n}};var{parse:Pw,stringify:gd}=JSON,{keys:kw}=Object,vd=String,wd="string";var ys="object",yd=(t,e)=>e;var Is=(t,e,r)=>{let n=vd(e.push(r)-1);return t.set(r,n),n};var Ss=(t,e,r)=>{let n=e&&typeof e===ys?(u,l)=>u===""||-1<e.indexOf(u)?l:void 0:e||yd,o=new Map,s=[],i=[],a=+Is(o,s,n.call(
812
- {"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=gd(s[a++],d,r);return"["+i.join(",")+"]";function d(u,l){if(c)return c=!c,
813
- l;let p=n.call(this,u,l);switch(typeof p){case ys:if(p===null)return p;case wd:return o.get(p)||Is(o,s,p)}return p}};var Sd=new Set(["true","1","yes","y","on"]),xd=new Set(["false","0","no","n","off"]);function Td(t){return t!==null&&(typeof t==
814
- "object"||typeof t=="function")&&typeof t.then=="function"}function xs(t){if(typeof t=="number")return Number.isFinite(t)?
822
+ return ps(this,e)}getFieldDefinitions(){return Lr(this.structure)}getFieldDefinition(e){if(typeof e!="string"||e.trim()===
823
+ "")throw new Error("Field path must be a non-empty string.");let r=Ur(this,$r(e.trim()));return r===null?null:Lr(r)}getFieldMessages(e){
824
+ let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):Lr(r.messages)}cleanup(e,r){
825
+ let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&T(n,o,e[o]);return n}};var{parse:Bw,stringify:_d}=JSON,{keys:Hw}=Object,Ad=String,Cd="string";var xs="object",Ed=(t,e)=>e;var Ts=(t,e,r)=>{let n=Ad(e.push(r)-1);return t.set(r,n),n};var bs=(t,e,r)=>{let n=e&&typeof e===xs?(u,f)=>u===""||-1<e.indexOf(u)?f:void 0:e||Ed,o=new Map,s=[],i=[],a=+Ts(o,s,n.call(
826
+ {"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=_d(s[a++],d,r);return"["+i.join(",")+"]";function d(u,f){if(c)return c=!c,
827
+ f;let l=n.call(this,u,f);switch(typeof l){case xs:if(l===null)return l;case Cd:return o.get(l)||Ts(o,s,l)}return l}};var Rd=new Set(["true","1","yes","y","on"]),Pd=new Set(["false","0","no","n","off"]);function kd(t){return t!==null&&(typeof t==
828
+ "object"||typeof t=="function")&&typeof t.then=="function"}function _s(t){if(typeof t=="number")return Number.isFinite(t)?
815
829
  t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
816
- if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function zr(t,e){if(Object.is(t,e))return!0;
830
+ if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function Br(t,e){if(Object.is(t,e))return!0;
817
831
  if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
818
832
  source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
819
- e.length)return!1;for(let o=0;o<t.length;o++)if(!zr(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
833
+ e.length)return!1;for(let o=0;o<t.length;o++)if(!Br(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
820
834
  t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let r=Object.keys(t),n=Object.keys(
821
- e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!zr(t[o],e[o]))return!1;return!0}var bd={install(t){
835
+ e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!Br(t[o],e[o]))return!1;return!0}var Md={install(t){
822
836
  let{addType:e,addValidator:r}=t;e("none",n=>n.value),e("file",n=>{let o=n.value;o==null&&n.throwTypeError();let s=typeof o;
823
837
  if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),
824
838
  e("string",n=>{let o=n.value;if(o==null)return"";let s=typeof o;if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();
825
- return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),e("blob",n=>n.value),e("number",n=>{let o=xs(n.value);return o===
826
- null&&n.throwTypeError(),o}),e("integer",n=>{let o=xs(n.value);return(o===null||!Number.isInteger(o))&&n.throwTypeError(),
827
- o}),e("epochMilliseconds",n=>{let o=xr(n.value,864e13);return o===null&&n.throwTypeError(),o}),e("epochSeconds",n=>{let o=xr(
828
- n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=Ze(n.definition,n.fieldName);return ts(n.
829
- value,o)||n.throwTypeError(),n.value}),e("date",n=>(Zo(n.value)||n.throwTypeError(),n.value)),e("time",n=>{let o=Ze(n.definition,
830
- n.fieldName);return es(n.value,o)||n.throwTypeError(),n.value}),e("array",n=>n.definition.type==="array"&&!Array.isArray(
839
+ return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),e("blob",n=>n.value),e("number",n=>{let o=_s(n.value);return o===
840
+ null&&n.throwTypeError(),o}),e("integer",n=>{let o=_s(n.value);return(o===null||!Number.isInteger(o))&&n.throwTypeError(),
841
+ o}),e("epochMilliseconds",n=>{let o=Er(n.value,864e13);return o===null&&n.throwTypeError(),o}),e("epochSeconds",n=>{let o=Er(
842
+ n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=et(n.definition,n.fieldName);return os(n.
843
+ value,o)||n.throwTypeError(),n.value}),e("date",n=>(rs(n.value)||n.throwTypeError(),n.value)),e("time",n=>{let o=et(n.definition,
844
+ n.fieldName);return ns(n.value,o)||n.throwTypeError(),n.value}),e("array",n=>n.definition.type==="array"&&!Array.isArray(
831
845
  n.value)?[n.value]:n.value),e("object",n=>(H(n.value)||n.throwTypeError(),n.value)),e("serialize",n=>{try{return JSON.stringify(
832
- n.value)}catch{try{return Ss(n.value)}catch{n.throwTypeError()}}}),e("boolean",n=>{if(typeof n.value=="boolean")return n.
846
+ n.value)}catch{try{return bs(n.value)}catch{n.throwTypeError()}}}),e("boolean",n=>{if(typeof n.value=="boolean")return n.
833
847
  value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
834
848
  "bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
835
849
  n.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
836
- i=n.value.trim().toLowerCase(),a=new Set([...xd,o]),c=new Set([...Sd,s]);if(a.has(i))return!1;if(c.has(i))return!0}n.throwTypeError()}),
850
+ i=n.value.trim().toLowerCase(),a=new Set([...Pd,o]),c=new Set([...Rd,s]);if(a.has(i))return!1;if(c.has(i))return!0}n.throwTypeError()}),
837
851
  e("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
838
852
  value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
839
853
  value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let s=Number(o);return Number.isSafeInteger(
840
854
  s)||n.throwTypeError(),s}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.
841
855
  toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGTH",`Length must be at least ${n.parameterValue}\
842
- characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&Ne(n.definition)&&
856
+ characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&De(n.definition)&&
843
857
  typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("MIN_VALUE",`Value must be at least ${n.parameterValue}\
844
858
  .`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.toString&&
845
859
  n.value.toString().length>n.parameterValue&&n.throwParamError("MAX_LENGTH",`Length must be no more than ${n.parameterValue}\
846
- characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&Ne(n.definition)&&
860
+ characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&De(n.definition)&&
847
861
  typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError("MAX_VALUE",`Value must be no more than ${n.parameterValue}\
848
862
  .`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.isArray(n.parameterValue))throw new Error(`Enum for ${n.
849
- fieldName} must be an array.`);n.parameterValue.some(s=>zr(s,n.value))||n.throwParamError("ENUM_VALUE","Value must match\
863
+ fieldName} must be an array.`);n.parameterValue.some(s=>Br(s,n.value))||n.throwParamError("ENUM_VALUE","Value must match\
850
864
  one of the allowed enum values.",{allowed:n.parameterValue})}),r("pattern",n=>{if(n.value===void 0||n.definition.type!==
851
865
  "string"||typeof n.value!="string")return;let o=n.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
852
866
  "string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${n.fieldName} must be a string or RegExp.`);s.test(n.value)||
@@ -854,7 +868,7 @@ n.throwParamError("PATTERN","Value does not match the required pattern.",{patter
854
868
  parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
855
869
  fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
856
870
  "validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
857
- let o=n.parameterValue(n.value,n.object,n);if(Td(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
871
+ let o=n.parameterValue(n.value,n.object,n);if(kd(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
858
872
  ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
859
873
  ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
860
874
  th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
@@ -863,100 +877,100 @@ ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).leng
863
877
  typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r(
864
878
  "unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.
865
879
  type!=="dateTime")throw new Error(`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r(
866
- "nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},Ts=bd;var As=new WeakMap,Cs=new WeakMap,Es=Symbol.for("json-rest-schema.registry-metadata");function _d(t,e,r){if(typeof r!="f\
867
- unction")throw new Error(`Type handler for '${e}' must be a function.`);x(t,e,r)}function Ad(t,e,r){if(typeof r!="functi\
868
- on")throw new Error(`Validator handler for '${e}' must be a function.`);x(t,e,r)}function Nt(t={}){let e=Object.create(null);
869
- for(let[r,n]of Object.entries(t))x(e,r,n);return e}function Cd(t,e){if(typeof t.install!="function")throw new Error("Plu\
870
- gin must have an install method.");t.install(e)}function bs(t,e,r){As.set(t,e),Cs.set(t,r),Object.defineProperty(t,Es,{value:Object.
871
- freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function Ed(t){if(!t||typeof t!=
872
- "object"&&typeof t!="function")return null;let e=As.get(t),r=Cs.get(t);if(e&&r)return{types:e,validators:r};let n=t[Es];
880
+ "nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},As=Md;var Os=new WeakMap,Rs=new WeakMap,Ps=Symbol.for("json-rest-schema.registry-metadata");function Nd(t,e,r){if(typeof r!="f\
881
+ unction")throw new Error(`Type handler for '${e}' must be a function.`);T(t,e,r)}function jd(t,e,r){if(typeof r!="functi\
882
+ on")throw new Error(`Validator handler for '${e}' must be a function.`);T(t,e,r)}function Ft(t={}){let e=Object.create(null);
883
+ for(let[r,n]of Object.entries(t))T(e,r,n);return e}function Dd(t,e){if(typeof t.install!="function")throw new Error("Plu\
884
+ gin must have an install method.");t.install(e)}function Cs(t,e,r){Os.set(t,e),Rs.set(t,r),Object.defineProperty(t,Ps,{value:Object.
885
+ freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function zd(t){if(!t||typeof t!=
886
+ "object"&&typeof t!="function")return null;let e=Os.get(t),r=Rs.get(t);if(e&&r)return{types:e,validators:r};let n=t[Ps];
873
887
  return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
874
888
  typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
875
889
  nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
876
- validators}:null}function Od(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Rd(t,e){return t===e}function _s(t,e,r){
877
- for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!Rd(t[n],o))throw new Error(`Cannot merge schema factories with\
878
- conflicting ${r} "${n}".`);x(t,n,o)}}function Pd(t,e,r){let n=Od(r).filter(Boolean);if(n.length<1)return{types:Nt(t),validators:Nt(
879
- e)};let o=Object.create(null),s=Object.create(null);for(let i of n){let a=Ed(i);if(!a)throw new Error("Factory sources m\
880
- ust be schema instances or schema factories created by json-rest-schema.");_s(o,a.types,"type"),_s(s,a.validators,"valid\
881
- ator")}return{types:o,validators:s}}function Os({types:t={},validators:e={},installCore:r=!0}={}){let n=Nt(t),o=Nt(e),s=(i,a={})=>{
882
- let c=new Le(i,n,o,a.operations);return bs(c,n,o),c};return bs(s,n,o),s.addType=(i,a)=>{_d(n,i,a)},s.addValidator=(i,a)=>{
883
- Ad(o,i,a)},s.use=i=>{Cd(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{let a=Pd(n,o,i);return Os(
884
- {types:a.types,validators:a.validators,installCore:!1})},r&&s.use(Ts),s}var se=Os({installCore:!0});function xe(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let r of Object.getOwnPropertyNames(
885
- t))xe(t[r],e);return Object.freeze(t)}var ey=Object.freeze({REQUIRED:"required",TYPE_CAST_FAILED:"default",NOT_NULLABLE:"default",MIN_LENGTH:"minLength",MAX_LENGTH:"\
890
+ validators}:null}function Ld(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Fd(t,e){return t===e}function Es(t,e,r){
891
+ for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!Fd(t[n],o))throw new Error(`Cannot merge schema factories with\
892
+ conflicting ${r} "${n}".`);T(t,n,o)}}function $d(t,e,r){let n=Ld(r).filter(Boolean);if(n.length<1)return{types:Ft(t),validators:Ft(
893
+ e)};let o=Object.create(null),s=Object.create(null);for(let i of n){let a=zd(i);if(!a)throw new Error("Factory sources m\
894
+ ust be schema instances or schema factories created by json-rest-schema.");Es(o,a.types,"type"),Es(s,a.validators,"valid\
895
+ ator")}return{types:o,validators:s}}function ks({types:t={},validators:e={},installCore:r=!0}={}){let n=Ft(t),o=Ft(e),s=(i,a={})=>{
896
+ let c=new $e(i,n,o,a.operations);return Cs(c,n,o),c};return Cs(s,n,o),s.addType=(i,a)=>{Nd(n,i,a)},s.addValidator=(i,a)=>{
897
+ jd(o,i,a)},s.use=i=>{Dd(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{let a=$d(n,o,i);return ks(
898
+ {types:a.types,validators:a.validators,installCore:!1})},r&&s.use(As),s}var ne=ks({installCore:!0});function Te(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let r of Object.getOwnPropertyNames(
899
+ t))Te(t[r],e);return Object.freeze(t)}var py=Object.freeze({REQUIRED:"required",TYPE_CAST_FAILED:"default",NOT_NULLABLE:"default",MIN_LENGTH:"minLength",MAX_LENGTH:"\
886
900
  maxLength",MIN_VALUE:"min",MAX_VALUE:"max",PATTERN:"pattern",ENUM_VALUE:"enum",FIELD_NOT_ALLOWED:"additionalProperties",
887
- CUSTOM_VALIDATOR_FAILED:"default"});var Md=se({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Nd=Object.freeze({schema:Md,
888
- mode:"patch"});var Ps=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),jd=Object.freeze(
889
- {...Ps,nullable:!0});var ks="^[1-9][0-9]*$",Lr=xe({type:"string",minLength:1,pattern:ks});var zd=xe({...Lr,nullable:!0});var Ld=xe({schema:se({recordId:{...Lr,required:!0,messages:{pattern:"Record id must be a canonical positive integer stri\
890
- ng."}}}),mode:"patch"});var Zy=Object.freeze([/^(?:let me|i(?:'|’)ll|i will|i(?:'|’)m going to|i am going to)\s+(?:(?:first|now|quickly)\s+)*(?:analy[sz]e|call|check|confirm|do|execute|fetch|find|inspect|investigate|load|look up|open|prepare|query|read|retrieve|review|run|search|summarize|test|try|use|verify)\b/iu,
901
+ CUSTOM_VALIDATOR_FAILED:"default"});var qd=ne({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Bd=Object.freeze({schema:qd,
902
+ mode:"patch"});var Ns=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),Hd=Object.freeze(
903
+ {...Ns,nullable:!0});var js="^[1-9][0-9]*$",Hr=Te({type:"string",minLength:1,pattern:js});var Gd=Te({...Hr,nullable:!0});var Wd=Te({schema:ne({recordId:{...Hr,required:!0,messages:{pattern:"Record id must be a canonical positive integer stri\
904
+ ng."}}}),mode:"patch"});var lI=Object.freeze([/^(?:let me|i(?:'|’)ll|i will|i(?:'|’)m going to|i am going to)\s+(?:(?:first|now|quickly)\s+)*(?:analy[sz]e|call|check|confirm|do|execute|fetch|find|inspect|investigate|load|look up|open|prepare|query|read|retrieve|review|run|search|summarize|test|try|use|verify)\b/iu,
891
905
  /^(?:analy[sz]ing|calling|checking|confirming|executing|fetching|finding|inspecting|investigating|loading|looking up|opening|preparing|querying|reading|retrieving|reviewing|running|searching|summarizing|testing|trying|using|verifying)\b/iu,
892
- /^(?:one moment|please wait)\b/iu]);var Hd=256*1024,uI=se({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:16e3,required:!1},
893
- toolName:{type:"string",maxLength:256,required:!1},arguments:{type:"string",maxLength:Hd,required:!1}});var II=16*1024*1024;var TI=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var hS=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
906
+ /^(?:one moment|please wait)\b/iu]);var Zd=256*1024,xI=ne({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:16e3,required:!1},
907
+ toolName:{type:"string",maxLength:256,required:!1},arguments:{type:"string",maxLength:Zd,required:!1}});var kI=16*1024*1024;var jI=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var AS=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
894
908
  resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
895
- cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var FS=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
909
+ cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var YS=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
896
910
  resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
897
- cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var qS=2*1024*1024,BS=32*1024*1024,HS=2*1024*1024;var Ns=/^[a-z][a-z0-9_.-]*$/u,Qd=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function js(t,e){let r=String(t||"").trim().toLowerCase();
898
- if(!Ns.test(r))throw new TypeError(`${e} must match ${Ns.toString()}.`);return r}function Ur(t,e){if(t==null)return Object.
899
- freeze({});if(!Ye(t))throw new TypeError(`${e} must be an object mapping local names to capability ids.`);let r={},n=new Set;
900
- for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!Qd.test(i))throw new TypeError(`${e} local name "${i}" \
901
- must be a JavaScript identifier.`);let a=js(s,`${e}.${i}`);if(n.has(a))throw new TypeError(`${e} declares capability "${a}\
902
- " more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function Zd(t){let e=new Map;for(let[r,n]of Object.entries(t))
911
+ cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var ex=2*1024*1024,tx=32*1024*1024,rx=2*1024*1024;var zs=/^[a-z][a-z0-9_.-]*$/u,au=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function Ls(t,e){let r=String(t||"").trim().toLowerCase();
912
+ if(!zs.test(r))throw new TypeError(`${e} must match ${zs.toString()}.`);return r}function Wr(t,e){if(t==null)return Object.
913
+ freeze({});if(!Qe(t))throw new TypeError(`${e} must be an object mapping local names to capability ids.`);let r={},n=new Set;
914
+ for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!au.test(i))throw new TypeError(`${e} local name "${i}" \
915
+ must be a JavaScript identifier.`);let a=Ls(s,`${e}.${i}`);if(n.has(a))throw new TypeError(`${e} declares capability "${a}\
916
+ " more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function cu(t){let e=new Map;for(let[r,n]of Object.entries(t))
903
917
  for(let o of Object.keys(n)){if(e.has(o))throw new TypeError(`Provider local name "${o}" is declared by both ${e.get(o)}\
904
- and ${r}.`);e.set(o,r)}}function qr(t,e){if(t==null)return null;if(typeof t!="function")throw new TypeError(`${e} must \
905
- be a function when provided.`);return t}function Dt({id:t,requires:e={},optional:r={},provides:n={},setup:o,boot:s=null,
906
- shutdown:i=null}={}){let a=js(t,"Provider id"),c=Ur(e,`${a}.requires`),d=Ur(r,`${a}.optional`),u=Ur(n,`${a}.provides`);Zd(
907
- {requires:c,optional:d,provides:u});let l=qr(o,`${a}.setup`);if(!l)throw new TypeError(`${a}.setup is required.`);return Object.
908
- freeze({id:a,requires:c,optional:d,provides:u,setup:l,boot:qr(s,`${a}.boot`),shutdown:qr(i,`${a}.shutdown`)})}var Ds="public";function zs(){let t=[],e=new Set,r=!1;function n({id:a,order:c=0,contribute:d}={}){if(r)throw new Error("Bootstrap regis\
909
- tration is closed after the first payload is resolved.");let u=q(a);if(!u)throw new TypeError("Bootstrap contributor id \
918
+ and ${r}.`);e.set(o,r)}}function Kr(t,e){if(t==null)return null;if(typeof t!="function")throw new TypeError(`${e} must \
919
+ be a function when provided.`);return t}function Ut({id:t,requires:e={},optional:r={},provides:n={},setup:o,boot:s=null,
920
+ shutdown:i=null}={}){let a=Ls(t,"Provider id"),c=Wr(e,`${a}.requires`),d=Wr(r,`${a}.optional`),u=Wr(n,`${a}.provides`);cu(
921
+ {requires:c,optional:d,provides:u});let f=Kr(o,`${a}.setup`);if(!f)throw new TypeError(`${a}.setup is required.`);return Object.
922
+ freeze({id:a,requires:c,optional:d,provides:u,setup:f,boot:Kr(s,`${a}.boot`),shutdown:Kr(i,`${a}.shutdown`)})}var Fs="public";function $s(){let t=[],e=new Set,r=!1;function n({id:a,order:c=0,contribute:d}={}){if(r)throw new Error("Bootstrap regis\
923
+ tration is closed after the first payload is resolved.");let u=U(a);if(!u)throw new TypeError("Bootstrap contributor id \
910
924
  is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${u}" requires contribute().`);if(e.has(
911
925
  u))throw new Error(`Bootstrap contributor "${u}" is duplicated.`);return e.add(u),t.push(Object.freeze({id:u,order:Number.
912
- isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((u,l)=>({entry:u,index:l})).sort(
913
- (u,l)=>u.entry.order-l.entry.order||u.index-l.index).map(({entry:u})=>u);for(let u of d){let l=await u.contribute(Object.
914
- freeze({...Ye(a)?a:{},payload:Object.freeze({...c})}));c={...c,...Ye(l)?l:{}}}return Object.freeze(c)}function s(){return Object.
926
+ isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((u,f)=>({entry:u,index:f})).sort(
927
+ (u,f)=>u.entry.order-f.entry.order||u.index-f.index).map(({entry:u})=>u);for(let u of d){let f=await u.contribute(Object.
928
+ freeze({...Qe(a)?a:{},payload:Object.freeze({...c})}));c={...c,...Qe(f)?f:{}}}return Object.freeze(c)}function s(){return Object.
915
929
  freeze({sealed:r,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:n,resolve:o,diagnostics:s});
916
- return i}var eu=Dt({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({
917
- http:t}){let e=zs();return t.router.register("GET","/api/bootstrap",{auth:Ds,meta:{tags:["bootstrap"],summary:"Resolve a\
918
- pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await e.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:e}}});function tu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Event listener must be an object.");let e=String(
930
+ return i}var du=Ut({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({
931
+ http:t}){let e=$s();return t.router.register("GET","/api/bootstrap",{auth:Fs,meta:{tags:["bootstrap"],summary:"Resolve a\
932
+ pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await e.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:e}}});function uu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Event listener must be an object.");let e=String(
919
933
  t.id||"").trim();if(!e)throw new TypeError("Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(
920
934
  `Event listener "${e}" requires handle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event \
921
935
  listener "${e}" matches must be a function when provided.`);return Object.freeze({id:e,handle:t.handle,matches:typeof t.
922
- matches=="function"?t.matches:null})}function ru(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pub\
936
+ matches=="function"?t.matches:null})}function lu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pub\
923
937
  lished event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is req\
924
- uired.");return Object.freeze({...t,type:e})}function Ls(){let t=[],e=new Set;function r(i){let a=tu(i);if(e.has(a.id))throw new Error(
925
- `Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function n(i){let a=ru(i);for(let c of t)
938
+ uired.");return Object.freeze({...t,type:e})}function Us(){let t=[],e=new Set;function r(i){let a=uu(i);if(e.has(a.id))throw new Error(
939
+ `Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function n(i){let a=lu(i);for(let c of t)
926
940
  c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.freeze(t.
927
- map(i=>i.id))})}let s=Object.freeze({register:r,publish:n,diagnostics:o});return s}var nu=Dt({id:"runtime.events",provides:{
928
- events:"runtime.events"},setup(){return{events:Ls()}}});var Fs=20,Rx=32*1024,Px=48*1024,Br=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
929
- execute:"assistant_action_execute"}),Hr=Object.freeze({type:"object",additionalProperties:!0}),su=Object.freeze({type:"o\
941
+ map(i=>i.id))})}let s=Object.freeze({register:r,publish:n,diagnostics:o});return s}var pu=Ut({id:"runtime.events",provides:{
942
+ events:"runtime.events"},setup(){return{events:Us()}}});var qs=20,qx=32*1024,Bx=48*1024,Jr=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
943
+ execute:"assistant_action_execute"}),Xr=Object.freeze({type:"object",additionalProperties:!0}),hu=Object.freeze({type:"o\
930
944
  bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
931
945
  ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
932
946
  ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
933
- limit:{type:"integer",minimum:1,maximum:Fs,description:"Maximum compact matches to return."}}}),iu=Object.freeze({type:"\
934
- object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Fs,items:{
947
+ limit:{type:"integer",minimum:1,maximum:qs,description:"Maximum compact matches to return."}}}),mu=Object.freeze({type:"\
948
+ object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:qs,items:{
935
949
  type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
936
950
  tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
937
- string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),au=Object.freeze({type:"object",additionalProperties:!1,required:[
938
- "actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),cu=Object.
951
+ string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),gu=Object.freeze({type:"object",additionalProperties:!1,required:[
952
+ "actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),vu=Object.
939
953
  freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
940
954
  chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
941
- string"},inputSchema:Hr,outputSchema:Hr}}),du=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
942
- "input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Hr}}),uu=Object.
955
+ string"},inputSchema:Xr,outputSchema:Xr}}),wu=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
956
+ "input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Xr}}),yu=Object.
943
957
  freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
944
- g"},version:{type:"integer",minimum:1},result:{}}}),Vr=Object.freeze([Object.freeze({name:Br.search,description:"Discove\
958
+ g"},version:{type:"integer",minimum:1},result:{}}}),Bs=Object.freeze([Object.freeze({name:Jr.search,description:"Discove\
945
959
  r application actions available to the current user and surface, including list, search, and query operations for multip\
946
960
  le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
947
- query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:su,
948
- outputSchema:iu}),Object.freeze({name:Br.contract,description:"Load the exact input and output contract for one availabl\
949
- e action before executing it.",parameters:au,outputSchema:cu}),Object.freeze({name:Br.execute,description:"Execute one a\
950
- vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:du,outputSchema:uu})]);var aT=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var lT=256*1024;var pT=2*1024*1024;var fT=Object.fromEntries(Vr.map(t=>[t.name,"allow"]));var hT=Vr.map(({name:t,description:e,parameters:r})=>({type:"function",function:{name:t,description:e,parameters:r}}));function Gr({resolveConversation:t,readInstructions:e}={}){if(typeof t!="function")throw new TypeError("Conversation hoo\
961
+ query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:hu,
962
+ outputSchema:mu}),Object.freeze({name:Jr.contract,description:"Load the exact input and output contract for one availabl\
963
+ e action before executing it.",parameters:gu,outputSchema:vu}),Object.freeze({name:Jr.execute,description:"Execute one a\
964
+ vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:wu,outputSchema:yu})]);var ST=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var _T=256*1024;var AT=2*1024*1024;var CT=Bs.map(({name:t,description:e,parameters:r})=>({type:"function",function:{name:t,description:e,parameters:r}}));function Yr({resolveConversation:t,readInstructions:e}={}){if(typeof t!="function")throw new TypeError("Conversation hoo\
951
965
  k delivery requires a binding resolver.");return async function(n){if(n.scope!=="session")return{kind:"unclaimed"};let o=await t(
952
966
  n);if(!o)return{kind:"unclaimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError(
953
967
  "Unknown conversation instruction delivery mode.");if(typeof e!="function")throw new TypeError("Hook delivery requires a\
954
968
  n instruction resolver.");let s=await e(o,n);if(typeof s!="string"||!s.trim())throw new TypeError("Managed conversation \
955
- instructions are unavailable.");return{kind:"delivery",text:s}}}var jb=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
969
+ instructions are unavailable.");return{kind:"delivery",text:s}}}var Kb=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
956
970
  allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
957
971
  test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
958
- commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as Ru}from"node:fs/promises";import Wr from"node:path";var Pu=Object.freeze(["main","temporary"]),qs=Object.
959
- freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),ku=64*1024,p_=Object.freeze(["When\
972
+ commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as Fu}from"node:fs/promises";import Qr from"node:path";var $u=Object.freeze(["main","temporary"]),Gs=Object.
973
+ freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),Uu=64*1024,__=Object.freeze(["When\
960
974
  user input is necessary, ask no more than three concise, high-impact questions at once.","Put multiple questions on sep\
961
975
  arate lines as `[1] Question`, `[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answe\
962
976
  rs:` and a short bullet list directly beneath its own question, before the next one; never collect several questions' an\
@@ -970,99 +984,96 @@ Possible answers:
970
984
  [2] Tell the main agent before changes?
971
985
  Possible answers:
972
986
  - Yes, tell main first
973
- - No, proceed independently`]),f_=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
987
+ - No, proceed independently`]),A_=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
974
988
  start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
975
989
  nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
976
990
  ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
977
991
  words. If unconfigured, ask which existing accounts (email/login/user ID) represent admin and other required roles, and \
978
992
  the default. Reuse prior answers; wait for their choices before configuring access. Never infer admin rights from names \
979
- or the Vibe64 viewer.","Offer the application-owned `vibe64.preview-identity.command.v1` adapter in Outputs Preview iden\
980
- tity, and guide named selectors through Dashboard > App access > Managed app access. Use existing sessions/permissions, \
981
- reject missing/disabled accounts, and disable the adapter without Vibe64\u2019s per-run enable flag and secret. Do not create\
982
- users, change roles, reset passwords or weaken production auth for import. Verify the selected account\u2019s actual Preview\
983
- access; a saved selector is insufficient. If deferred/declined, explain access remains unconfigured and continue indepe\
984
- ndent setup work without repeated credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview\
985
- status`, `screenshot`, `logs`, and `browser eval` (Playwright code on stdin) for rendered inspection.","The top Preview\
986
- toolbar Stop and `vibe64-helper preview stop` stop this session's application and managed browser, not chat or source. \
987
- Status reports the saved stopped choice. A status read, screenshot, browser inspection, source edit or session reopening\
988
- is not permission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start. Scoped browser \
989
- tests restore the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-helper preview insp\
990
- ect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your\
991
- -path', preview.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity and is not a br\
992
- owser-navigation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper playwright` only for\
993
- an existing configured project suite; report a platform or project-test blocker rather than installing another browser \
994
- or changing its dependencies.","For browser evidence, batch related actions and assertions, return only needed values an\
995
- d inspect relevant locators or regions; screenshot at meaningful visual checkpoints or failures, not after every click. \
996
- Reuse the managed browser when test isolation permits. Preserve required viewport, identity and security checks; use exi\
997
- sting automated cases for repeat verification.","For browser tests that write or reset data, inspect `vibe64-helper prev\
998
- iew targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target <declared-test-\
999
- target> test <suite arguments>` or `vibe64-helper playwright --target <declared-test-target> npm-run <script>`. Vibe64 s\
1000
- tarts that web target, waits for readiness, uses its declared application identity, and restores the previous Preview wh\
1001
- en the command finishes or is cancelled; report restoration failures.","A target name is not proof of test isolation. Be\
1002
- fore running a destructive suite, the application must verify the server's actual test database and suppress real email,\
1003
- invoices, payments, and other external effects. Keep managed Env unchanged. The test launcher and its preview-identity \
1004
- command must use the same database. Use a declared BROWSER_TEST_DB_NAME for reusable browser fixtures, separate from dis\
1005
- posable TEST_DB_NAME. Never spoof safety checks by changing DB_NAME only in the test runner.","If no suitable test targe\
1006
- t exists, add one through the project's existing Outputs contract and application-owned test scripts within authorized s\
1007
- cope, keeping normal Preview as default. Validate the exact disposable database before resetting it, prepare fixtures be\
1008
- fore reporting readiness, and make Playwright use PLAYWRIGHT_BASE_URL without starting another server. If the required t\
1009
- est resources or external-effect controls are missing, report that specific blocker. Use `vibe64-helper preview ensure -\
1010
- -target <id> --wait --json` only to deliberately select an interactive target; it stays selected until changed.","Keep r\
1011
- outine browser startup incremental: reuse the isolated test schema, apply only pending migrations, and reset fixture dat\
1012
- a deterministically. Do not drop and rebuild the database or run a production frontend build for every focused browser c\
1013
- heck. Keep fresh-schema migration checks separate. If startup is slow, measure migrations, fixtures, and server startup \
1014
- before retrying or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local \
1015
- artifacts and preserve exit status. Report counts, duration, failed cases, actionable errors and artifact paths. Read on\
1016
- ly needed failure excerpts, not full passing/JSON/TAP/request/trace/image output. Retain startup, resource and Preview-r\
1017
- estoration errors even if tests pass, and trailing wrapper diagnostics separately from JSON. Do not rerun for output or \
1018
- reread unchanged logs; inspect on new output, changed state or a concrete blocker.","Batch related browser tests in one \
1019
- managed suite (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensu\
1020
- re/restart or target changes during a suite or restoration. Wait on the original execution, including background runs, t\
1021
- hrough cleanup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input or an \
1022
- immediate check); read-only status/logs stay available. Before live inspection, confirm `vibe64-helper playwright status\
1023
- ` has no active run and `vibe64-helper preview status` is ready on the restored target. To stop, read suite status then \
1024
- run `vibe64-helper playwright cancel <run-id>`, which waits for cleanup/restoration; retry it if cleanup needs attention\
1025
- . Never kill individual test/Preview PIDs or change locks. Launcher exit alone does not prove tests stopped. Recheck cur\
1026
- rent status before reporting a busy blocker.","If a managed command reports kernel task denials or a resource incident, \
1027
- retain its diagnostic and incident ID when reporting the blocker. Ask the platform operator to inspect that resource evi\
1028
- dence before retrying; do not increase test timeouts or weaken assertions to work around a process/thread limit. A gener\
1029
- ic browser timeout without resource evidence does not establish a platform cause."]),h_=Object.freeze(["Each managed she\
1030
- ll command receives current development Env from Vibe64, including declared resource bindings; use them in ordinary comm\
1031
- ands. Do not build environment injection or copy managed credentials into source. Resource provisioning and application \
1032
- migrations remain separate preparation steps.","Use `vibe64-helper env status [development|production|all]` to inspect c\
1033
- onfigured key names without revealing values.","Pipe an available value to `vibe64-helper env set <development|productio\
1034
- n> <KEY> [--secret]`; never put values in arguments, logs, or repository files. Use empty stdin only when the user reque\
1035
- sted an empty value.","Keep development and production values separate. Never invent credentials, copy a value between s\
1036
- copes without explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affec\
1037
- ted scope and key names, never their values, and claim success only when the command succeeded.","When declared, TEST_DB\
1038
- _NAME is the exact disposable integration database and BROWSER_TEST_DB_NAME is a separate reusable browser-fixture datab\
1039
- ase whose migration ledger survives routine runs. Follow the application\u2019s declared test resources; never reset DB_NAME,\
1040
- share these test identities, or invent a database name."]);function Kr(t=""){return String(t??"").trim()}function Jr(t,e){
1041
- if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object.`);return t}function Fe(t,e,r){let n=new Set(
1042
- e),o=Object.keys(t).filter(s=>!n.has(s));if(o.length>0)throw new TypeError(`${r} contains unsupported fields: ${o.join("\
1043
- , ")}.`)}function Mu(t){if(Fe(t,["conversationKind","scope","session","hostGuidance"],"Vibe64 session context"),t.hostGuidance!==
1044
- void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,"utf8")>1024))throw new TypeError("Vibe64 hos\
1045
- t guidance must be bounded text supplied by the host.");if(!Pu.includes(t.conversationKind))throw new TypeError("Vibe64 \
1046
- session context has an unknown conversationKind.");let e=Jr(t.session,"Vibe64 session capabilities");Fe(e,qs,"Vibe64 ses\
1047
- sion capabilities");let r=Object.fromEntries(qs.map(n=>{if(typeof e[n]!="boolean")throw new TypeError(`Vibe64 session ca\
1048
- pability ${n} must be boolean.`);return[n,e[n]]}));return{conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?
1049
- {hostGuidance:t.hostGuidance}:{},session:r}}function Nu(t){Fe(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(
1050
- t.stableContext||"").trim();if(!e||e.length>ku)throw new TypeError("Vibe64 ephemeral context requires bounded stableCont\
1051
- ext.");return{scope:"ephemeral",stableContext:e}}function ju(t){if(t.scope==="session")return Mu(t);if(t.scope==="epheme\
1052
- ral")return Nu(t);throw new TypeError("The Vibe64 driver supports session and ephemeral scopes only.")}async function Bs(t={},{readRegistry:e=Ru,workdir:r=""}={}){let n=Jr(t,"Vibe64 host resolver request");if(Fe(n,["data","\
993
+ or the Vibe64 viewer.","Offer an application-owned adapter declared in the Outputs `#### Preview identity` block (`vibe6\
994
+ 4-helper spec outputs` and `vibe64-helper spec preview-identity-command`), and save the named selectors the person gives\
995
+ or confirms with `vibe64-helper preview identities save` (`vibe64-helper spec preview-identities`); you may propose the\
996
+ m from existing app accounts, then verify each with `vibe64-helper preview browser identity <name>`. Use existing sessio\
997
+ ns/permissions, reject missing/disabled accounts, and disable the adapter without Vibe64\u2019s per-run enable flag and secre\
998
+ t. Do not create users, change roles, reset passwords or weaken production auth for import. Verify the selected account\u2019\
999
+ s actual Preview access; a saved selector is insufficient. If deferred/declined, explain access remains unconfigured and\
1000
+ continue independent setup work without repeated credential requests. Public/non-web apps need no adapter.","Use `vibe6\
1001
+ 4-helper preview status`, `screenshot`, `logs`, and `browser eval` (Playwright code on stdin) for rendered inspection.",
1002
+ "The top Preview toolbar Stop and `vibe64-helper preview stop` stop this session's application and managed browser, not \
1003
+ chat or source. Status reports the saved stopped choice. A status read, screenshot, browser inspection, source edit or s\
1004
+ ession reopening is not permission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start.\
1005
+ Scoped browser tests restore the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-hel\
1006
+ per preview inspect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.got\
1007
+ o(new URL('/your-path', preview.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity\
1008
+ and is not a browser-navigation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper play\
1009
+ wright` only for an existing configured project suite; report a platform or project-test blocker rather than installing \
1010
+ another browser or changing its dependencies.","For browser evidence, batch related actions and assertions, return only \
1011
+ needed values and inspect relevant locators or regions; screenshot at meaningful visual checkpoints or failures, not aft\
1012
+ er every click. Reuse the managed browser when test isolation permits. Preserve required viewport, identity and security\
1013
+ checks; use existing automated cases for repeat verification.","For browser tests that write or reset data, inspect `vi\
1014
+ be64-helper preview targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target\
1015
+ <declared-test-target> test <suite arguments>` or `vibe64-helper playwright --target <declared-test-target> npm-run <sc\
1016
+ ript>`. Vibe64 starts that web target, waits for readiness, uses its declared application identity, and restores the pre\
1017
+ vious Preview when the command finishes or is cancelled; report restoration failures.","A target name is not proof of te\
1018
+ st isolation. Before running a destructive suite, the application must verify the server's actual test database and supp\
1019
+ ress real email, invoices, payments, and other external effects. Keep managed Env unchanged. The test launcher and its p\
1020
+ review-identity command must use the same database. Follow the application's declared test resources and never invent a \
1021
+ database name. Never spoof safety checks by changing only the test runner's environment.","If no suitable test target ex\
1022
+ ists, add one through the project's existing Outputs contract and application-owned test scripts within authorized scope\
1023
+ , keeping normal Preview as default. Validate the exact disposable database before resetting it, prepare fixtures before\
1024
+ reporting readiness, and make Playwright use the started target's URL, which Vibe64 supplies as PLAYWRIGHT_BASE_URL, wi\
1025
+ thout starting another server. If the required test resources or external-effect controls are missing, report that speci\
1026
+ fic blocker. Use `vibe64-helper preview ensure --target <id> --wait --json` only to deliberately select an interactive t\
1027
+ arget; it stays selected until changed. If browser startup is slow, measure migrations, fixtures and server startup befo\
1028
+ re retrying or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local arti\
1029
+ facts and preserve exit status. Report counts, duration, failed cases, actionable errors and artifact paths. Read only n\
1030
+ eeded failure excerpts, not full passing/JSON/TAP/request/trace/image output. Retain startup, resource and Preview-resto\
1031
+ ration errors even if tests pass, and trailing wrapper diagnostics separately from JSON. Do not rerun for output or rere\
1032
+ ad unchanged logs; inspect on new output, changed state or a concrete blocker.","Batch related browser tests in one mana\
1033
+ ged suite (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensure/r\
1034
+ estart or target changes during a suite or restoration. Wait on the original execution, including background runs, throu\
1035
+ gh cleanup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input or an imme\
1036
+ diate check); read-only status/logs stay available. Before live inspection, confirm `vibe64-helper playwright status` ha\
1037
+ s no active run and `vibe64-helper preview status` is ready on the restored target. To stop, read suite status then run \
1038
+ `vibe64-helper playwright cancel <run-id>`, which waits for cleanup/restoration; retry it if cleanup needs attention. Ne\
1039
+ ver kill individual test/Preview PIDs or change locks. Launcher exit alone does not prove tests stopped. Recheck current\
1040
+ status before reporting a busy blocker.","If a managed command reports kernel task denials or a resource incident, reta\
1041
+ in its diagnostic and incident ID when reporting the blocker. Ask the platform operator to inspect that resource evidenc\
1042
+ e before retrying; do not increase test timeouts or weaken assertions to work around a process/thread limit. A generic b\
1043
+ rowser timeout without resource evidence does not establish a platform cause."]),C_=Object.freeze(["Each managed shell c\
1044
+ ommand receives current development Env from Vibe64, including declared resource bindings; use them in ordinary commands\
1045
+ . Do not build environment injection or copy managed credentials into source. Resource provisioning and application migr\
1046
+ ations remain separate preparation steps.","Use `vibe64-helper env status [development|production|all]` to inspect confi\
1047
+ gured key names without revealing values.","Pipe an available value to `vibe64-helper env set <development|production> <\
1048
+ KEY> [--secret]`; never put values in arguments, logs, or repository files. Use empty stdin only when the user requested\
1049
+ an empty value.","Keep development and production values separate. Never invent credentials, copy a value between scope\
1050
+ s without explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected \
1051
+ scope and key names, never their values, and claim success only when the command succeeded.","Store a secret the applica\
1052
+ tion needs generated (such as an application key) by generating it with the framework's own generator and piping it to `\
1053
+ vibe64-helper env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file\
1054
+ from Env."]);function Zr(t=""){return String(t??"").trim()}function en(t,e){if(!t||typeof t!="object"||Array.isArray(t))
1055
+ throw new TypeError(`${e} must be an object.`);return t}function rt(t,e,r){let n=new Set(e),o=Object.keys(t).filter(s=>!n.
1056
+ has(s));if(o.length>0)throw new TypeError(`${r} contains unsupported fields: ${o.join(", ")}.`)}function qu(t){if(rt(t,[
1057
+ "conversationKind","scope","session","hostGuidance"],"Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!=
1058
+ "string"||Buffer.byteLength(t.hostGuidance,"utf8")>1024))throw new TypeError("Vibe64 host guidance must be bounded text \
1059
+ supplied by the host.");if(!$u.includes(t.conversationKind))throw new TypeError("Vibe64 session context has an unknown c\
1060
+ onversationKind.");let e=en(t.session,"Vibe64 session capabilities");rt(e,Gs,"Vibe64 session capabilities");let r=Object.
1061
+ fromEntries(Gs.map(n=>{if(typeof e[n]!="boolean")throw new TypeError(`Vibe64 session capability ${n} must be boolean.`);
1062
+ return[n,e[n]]}));return{conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:
1063
+ {},session:r}}function Bu(t){rt(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").
1064
+ trim();if(!e||e.length>Uu)throw new TypeError("Vibe64 ephemeral context requires bounded stableContext.");return{scope:"\
1065
+ ephemeral",stableContext:e}}function Hu(t){if(t.scope==="session")return qu(t);if(t.scope==="ephemeral")return Bu(t);throw new TypeError(
1066
+ "The Vibe64 driver supports session and ephemeral scopes only.")}async function Ws(t={},{readRegistry:e=Fu,workdir:r=""}={}){let n=en(t,"Vibe64 host resolver request");if(rt(n,["data","\
1053
1067
  providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(n.scope))throw new TypeError(
1054
- "The Vibe64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=Jr(n.data,"Vibe64 host \
1055
- resolver data");Fe(o,["registryPath"],"Vibe64 host resolver data");let s=Kr(o.registryPath);if(!Wr.isAbsolute(s))throw new TypeError(
1068
+ "The Vibe64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=en(n.data,"Vibe64 host \
1069
+ resolver data");rt(o,["registryPath"],"Vibe64 host resolver data");let s=Zr(o.registryPath);if(!Qr.isAbsolute(s))throw new TypeError(
1056
1070
  "Vibe64 host resolver data requires an absolute registryPath.");let i=JSON.parse(await e(s,"utf8"));if(!Array.isArray(i?.
1057
- sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=Kr(n.providerSessionId);
1071
+ sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=Zr(n.providerSessionId);
1058
1072
  if(n.parentSessionIds!==void 0&&(!Array.isArray(n.parentSessionIds)||n.parentSessionIds.length>32||n.parentSessionIds.some(
1059
- p=>typeof p!="string"||!p.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[c,...n.parentSessionIds||
1060
- []].filter(Boolean).map(p=>a.find(h=>Kr(h?.upstreamSessionId)===p)).find(Boolean),l=u?.promptContext;if(!l)return null;if(r&&
1061
- u.workdir&&Wr.resolve(r)!==Wr.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
1062
- t directory.");if(l.scope==="learning"){if(Fe(l,["scope","instructions"],"Vibe64 learning context"),u.conversation?.nativeTools!==
1063
- !1)throw new TypeError("Learning instructions require the restricted native conversation binding.");let p=l.instructions;
1064
- if(typeof p!="string"||!p.trim()||Buffer.byteLength(p)>128*1024)throw new TypeError("Learning native context requires bo\
1065
- unded nonempty teaching instructions.");return{scope:"learning",instructions:p}}return ju(l)}var Xr="";for await(let t of process.stdin)if(Xr+=t,Buffer.byteLength(Xr)>256*1024)throw new Error("Conversation instruc\
1066
- tion input exceeds 256 KiB.");var Hs=JSON.parse(Xr);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
1067
- process.stdout.write(await t(Hs))}else{let t=Gr({resolveConversation:async e=>await Bs(e,{workdir:process.cwd()})?{delivery:"\
1068
- native"}:null});process.stdout.write(JSON.stringify(await t(Hs)))}
1073
+ l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[c,...n.parentSessionIds||
1074
+ []].filter(Boolean).map(l=>a.find(g=>Zr(g?.upstreamSessionId)===l)).find(Boolean),f=u?.promptContext;if(!f)return null;if(r&&
1075
+ u.workdir&&Qr.resolve(r)!==Qr.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
1076
+ t directory.");return Hu(f)}var tn="";for await(let t of process.stdin)if(tn+=t,Buffer.byteLength(tn)>256*1024)throw new Error("Conversation instruc\
1077
+ tion input exceeds 256 KiB.");var Ks=JSON.parse(tn);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
1078
+ process.stdout.write(await t(Ks))}else{let t=Yr({resolveConversation:async e=>await Ws(e,{workdir:process.cwd()})?{delivery:"\
1079
+ native"}:null});process.stdout.write(JSON.stringify(await t(Ks)))}