vibe64 0.1.65 → 0.1.67

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 (153) hide show
  1. package/bin/run.js +2004 -1363
  2. package/bin/server.js +282 -276
  3. package/bin/upgrade-state.js +4673 -4470
  4. package/dist/assets/{GithubBrowserTabs-D21Nl3QI.js → GithubBrowserTabs-CW3GBeJu.js} +1 -1
  5. package/dist/assets/{LocalDatabaseServer-POxY1K1U.js → LocalDatabaseServer-DYh3UF9q.js} +1 -1
  6. package/dist/assets/{SelectField-Dezd0B3y.js → SelectField-Df50ZFLj.js} +1 -1
  7. package/dist/assets/{ShellOutlet-DfF9vsWA.js → ShellOutlet-DkLdtzJW.js} +1 -1
  8. package/dist/assets/{Vibe64AuthSettingsButton-I3ufyScN.js → Vibe64AuthSettingsButton-Cksj7FS6.js} +1 -1
  9. package/dist/assets/{Vibe64AuthSettingsButton-DFfFPrd7.css → Vibe64AuthSettingsButton-DfKYI6ZS.css} +1 -1
  10. package/dist/assets/{Vibe64ConversationLog-C04oOQ2g.js → Vibe64ConversationLog-BC0eDtUP.js} +1 -1
  11. package/dist/assets/{Vibe64DashboardShell-BbrOUmRD.js → Vibe64DashboardShell-DX5dOXAB.js} +1 -1
  12. package/dist/assets/{Vibe64DatabaseWorkspace-VPEM2o1v.js → Vibe64DatabaseWorkspace-8i-RDc9y.js} +1 -1
  13. package/dist/assets/{Vibe64FileArea-C_nC2bPk.js → Vibe64FileArea-EK5yUio3.js} +1 -1
  14. package/dist/assets/{Vibe64OutputControls-DTO3Fw3x.js → Vibe64OutputControls--LB4G83q.js} +1 -1
  15. package/dist/assets/{Vibe64RepositoryWorkspace-B8xcCOvL.js → Vibe64RepositoryWorkspace-D6uJCype.js} +1 -1
  16. package/dist/assets/{Vibe64SessionFiles-Cb9Mxsyq.js → Vibe64SessionFiles-DVHGc7hd.js} +1 -1
  17. package/dist/assets/{Vibe64SessionSourceEditor-CVQ3NRjh.js → Vibe64SessionSourceEditor-Bws5ihr-.js} +1 -1
  18. package/dist/assets/{Vibe64UiStoryboardView-BV4JFgcZ.js → Vibe64UiStoryboardView-BmABkyG4.js} +1 -1
  19. package/dist/assets/{Vibe64UnavailableSessions-DGQAxYE-.js → Vibe64UnavailableSessions-C6Bkwsqk.js} +1 -1
  20. package/dist/assets/{_pageId_-CkG15vv4.js → _pageId_-FjW-3sqF.js} +1 -1
  21. package/dist/assets/{_sessionId_-Bka3RUmK.js → _sessionId_-4cH83Bfi.js} +1 -1
  22. package/dist/assets/_slug_-Cazfy5ui.js +14 -0
  23. package/dist/assets/_slug_-DQDycgFK.css +1 -0
  24. package/dist/assets/{access-Xo3unxGO.js → access-mxcxtn7b.js} +1 -1
  25. package/dist/assets/{app-B0spNegd.js → app-8zP_FAuO.js} +1 -1
  26. package/dist/assets/assistantRouting-Bbxguvre.js +3 -0
  27. package/dist/assets/{changes-DFv4tuoO.js → changes-cmlEyHug.js} +1 -1
  28. package/dist/assets/{client-4uCr4dYG.js → client-BJBzomgt.js} +1 -1
  29. package/dist/assets/{client-CVuXqm4b.js → client-C1i-bIgL.js} +1 -1
  30. package/dist/assets/{client-Dlg1kjjO.js → client-C7yZ1hEm.js} +1 -1
  31. package/dist/assets/{client-CevjVK2b.js → client-CQ49uWhR.js} +1 -1
  32. package/dist/assets/{client-DR0w56e8.js → client-D46Uu-YO.js} +2 -2
  33. package/dist/assets/{client-BjMjS6lX.js → client-DKNTl1to.js} +2 -2
  34. package/dist/assets/{conversation-OkWbkHjm.js → conversation-CFJRkeTj.js} +3 -3
  35. package/dist/assets/{conversation-DReMq0MF.css → conversation-COcuIkcD.css} +1 -1
  36. package/dist/assets/conversation-CexAK3Qk.js +1 -0
  37. package/dist/assets/{dashboard-CAca9MQn.js → dashboard-CMtWKazq.js} +1 -1
  38. package/dist/assets/{english-definitions-BtX8KA5g.js → english-definitions-DiyU9O9D.js} +1 -1
  39. package/dist/assets/{env-DrNyBVkB.js → env-LUc22Wgd.js} +1 -1
  40. package/dist/assets/{error-BqMxhgpB.js → error-BccdQn04.js} +1 -1
  41. package/dist/assets/{error-BQ7r64JO.js → error-DPDAz9Td.js} +1 -1
  42. package/dist/assets/{errorMessageHelpers-B49LyMJi.js → errorMessageHelpers-G32Hjqfm.js} +1 -1
  43. package/dist/assets/{health-B5yTW5Tt.js → health-CfMjMJFf.js} +1 -1
  44. package/dist/assets/{history-S3anp6xg.js → history-hX_kNskf.js} +1 -1
  45. package/dist/assets/{httpClient-Bwitq9Xf.js → httpClient-C71X5grL.js} +1 -1
  46. package/dist/assets/{i18n-BuXRXGaO.js → i18n-5EHeMSvt.js} +1 -1
  47. package/dist/assets/{i18n-DQPYjuW7.js → i18n-BSfPKqM3.js} +1 -1
  48. package/dist/assets/{i18n-Dm74yE_M.js → i18n-Dq-ep9n7.js} +1 -1
  49. package/dist/assets/index-BJWiPV6i.css +1 -0
  50. package/dist/assets/index-FVeEbKiO.js +134 -0
  51. package/dist/assets/{integrations-C7dj7el_.js → integrations-Ccb8EOEO.js} +14 -15
  52. package/dist/assets/{integrations-CwgrZgmM.css → integrations-CtnIjM1Y.css} +1 -1
  53. package/dist/assets/{issues-OkV4v4GX.js → issues-Bxtt7oqi.js} +1 -1
  54. package/dist/assets/{learning-lW9nBGjT.js → learning-BUx9jo91.js} +1 -1
  55. package/dist/assets/{pages-shOT9IVe.js → pages-D43zM2UW.js} +1 -1
  56. package/dist/assets/{project-files-D_K1N0JF.js → project-files-BX3zZCcl.js} +1 -1
  57. package/dist/assets/{publish-Bxe4ZCqe.js → publish-DatierL2.js} +1 -1
  58. package/dist/assets/{pull-requests-CQvk0TeH.js → pull-requests-DNkOjcuy.js} +1 -1
  59. package/dist/assets/{repository-CI2CqDwF.js → repository-0EKOcyTL.js} +1 -1
  60. package/dist/assets/{settings-DIVrFrs4.js → settings-DbR9JIc3.js} +1 -1
  61. package/dist/assets/{studioGateApi-UqmdV50W.js → studioGateApi-B9EUTtMx.js} +1 -1
  62. package/dist/assets/{studioUrls-k_pQIuPs.js → studioUrls-BR4ZL-TN.js} +1 -1
  63. package/dist/assets/{useArchivedVibe64Sessions-BkWrTOzg.js → useArchivedVibe64Sessions-B8VDhA9F.js} +1 -1
  64. package/dist/assets/useAssistantAttachments-C9kAnWqw.js +2 -0
  65. package/dist/assets/useCommand-CfqxMb4C.js +1 -0
  66. package/dist/assets/{useEndpointResource-DZTjr9gg.js → useEndpointResource-BwGXpV2u.js} +1 -1
  67. package/dist/assets/{useUiFeedback-BU4NyMq8.js → useUiFeedback-8Wvg7A_S.js} +1 -1
  68. package/dist/assets/{useVibe64ConversationLog-BADhWyNY.js → useVibe64ConversationLog-7wgLlKG5.js} +2 -2
  69. package/dist/assets/useVibe64Learning-DkneotqS.js +5 -0
  70. package/dist/assets/{useVibe64SessionData-DvFvAJC-.js → useVibe64SessionData-DuJ-dHR8.js} +1 -1
  71. package/dist/assets/{useVibe64SessionSelection-BukDTAxb.js → useVibe64SessionSelection-BwjtqeIR.js} +1 -1
  72. package/dist/assets/{vibe64FileUpload-BDkcaUyk.js → vibe64FileUpload-D_rOa1R8.js} +1 -1
  73. package/dist/assets/{vibe64RepositoryRealtime-DX2DEqIz.js → vibe64RepositoryRealtime-CVGNqwxz.js} +1 -1
  74. package/dist/assets/vibe64SavedEnvValues-CCZew0j7.js +1 -0
  75. package/dist/assets/{vibe64SessionFocus-CzuP3qPT.js → vibe64SessionFocus-B4diopOJ.js} +1 -1
  76. package/dist/index.html +23 -23
  77. package/docs/colleague-usage/ai-accounts.md +7 -7
  78. package/docs/colleague-usage/ai-model-setups.md +1 -1
  79. package/docs/colleague-usage/ai-tasks.md +2 -1
  80. package/docs/colleague-usage/auto-workflow.md +67 -44
  81. package/docs/colleague-usage/chat-settings.md +115 -114
  82. package/docs/colleague-usage/coding-agent-goal-pause.md +34 -12
  83. package/docs/colleague-usage/coding-agent-goals.md +33 -16
  84. package/docs/colleague-usage/coding-agent-history.md +9 -0
  85. package/docs/colleague-usage/coding-agent-questions.md +7 -0
  86. package/docs/colleague-usage/coding-agent-recovery.md +3 -0
  87. package/docs/colleague-usage/coding-agents.md +10 -4
  88. package/docs/colleague-usage/connected-repositories.md +4 -1
  89. package/docs/colleague-usage/developing-vibe64.md +11 -5
  90. package/docs/colleague-usage/development-env.md +74 -32
  91. package/docs/colleague-usage/github-work.md +39 -5
  92. package/docs/colleague-usage/integrations.md +2 -2
  93. package/docs/colleague-usage/main-chat-approvals.md +7 -6
  94. package/docs/colleague-usage/message-delivery-recovery.md +1 -1
  95. package/docs/colleague-usage/passes.md +260 -0
  96. package/docs/colleague-usage/plans.md +27 -16
  97. package/docs/colleague-usage/session-timeline.md +93 -0
  98. package/docs/colleague-usage/temporary-chats.md +6 -0
  99. package/docs/colleague-usage/ui-pass.md +30 -32
  100. package/docs/colleague-usage/workspace-preparation.md +51 -0
  101. package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +12 -0
  102. package/node_modules/@jskit-ai/assistant-core/locales/en.json +2 -0
  103. package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
  104. package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +5 -0
  105. package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
  106. package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
  107. package/node_modules/@jskit-ai/connector-google-calendar/CHANGELOG.md +1 -0
  108. package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
  109. package/node_modules/@jskit-ai/connector-google-calendar/patterns/calendar-cli/example/.env.example +1 -0
  110. package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1 -0
  111. package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
  112. package/node_modules/@jskit-ai/connectors-catalog/patterns/api-key-connection/PATTERN.md +4 -1
  113. package/node_modules/@jskit-ai/connectors-catalog/patterns/oauth-connection/PATTERN.md +3 -1
  114. package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
  115. package/node_modules/@jskit-ai/connectors-core/README.md +3 -1
  116. package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
  117. package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +1 -0
  118. package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
  119. package/node_modules/@jskit-ai/kernel/CHANGELOG.md +6 -0
  120. package/node_modules/@jskit-ai/kernel/package.json +3 -4
  121. package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +1 -0
  122. package/node_modules/@jskit-ai/payments-core/locales/en.json +1 -1
  123. package/node_modules/@jskit-ai/payments-core/package.json +1 -1
  124. package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
  125. package/node_modules/@jskit-ai/realtime/package.json +1 -1
  126. package/node_modules/@jskit-ai/realtime/patterns/realtime-application/example/.env.example +1 -0
  127. package/node_modules/@jskit-ai/resource-core/package.json +1 -1
  128. package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
  129. package/node_modules/@local/vibe64-core/package.json +2 -0
  130. package/node_modules/@local/vibe64-execution/package.json +1 -0
  131. package/node_modules/@local/vibe64-execution/src/host/execHelper.js +715 -666
  132. package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +989 -847
  133. package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +129 -107
  134. package/node_modules/@local/vibe64-genesis/src/server/index.js +632 -614
  135. package/node_modules/@local/vibe64-genesis/src/server/packaging.js +27 -28
  136. package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +172 -162
  137. package/node_modules/@local/vibe64-runtime/package.json +1 -0
  138. package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +1042 -898
  139. package/node_modules/@local/vibe64-terminals/package.json +2 -1
  140. package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +560 -420
  141. package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +586 -581
  142. package/package.json +15 -15
  143. package/server.bundle.mjs +44592 -44103
  144. package/dist/assets/_slug_-7Oo7pGKn.js +0 -14
  145. package/dist/assets/_slug_-BaxjtsgP.css +0 -1
  146. package/dist/assets/assistantRouting-B9cub38g.js +0 -3
  147. package/dist/assets/conversation-D7T_us2O.js +0 -1
  148. package/dist/assets/index-DSyb-mRJ.css +0 -1
  149. package/dist/assets/index-JBqyg0mr.js +0 -134
  150. package/dist/assets/useAssistantAttachments-DqlNFiha.js +0 -2
  151. package/dist/assets/useCommand-D-MIMmhp.js +0 -1
  152. package/dist/assets/useVibe64Learning-CbsI-XHB.js +0 -5
  153. package/dist/assets/vibe64SavedEnvValues-CgfMvj_h.js +0 -1
@@ -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 Yi=Object.create;var Zn=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var Qi=Object.getOwnPropertyNames;var ea=Object.getPrototypeOf,ta=Object.prototype.hasOwnProperty;var M=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){
4
- if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var ra=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qi(e))!ta.call(t,o)&&o!==n&&Zn(t,o,{get:()=>e[o],
5
- enumerable:!(r=Zi(e,o))||r.enumerable});return t};var ce=(t,e,n)=>(n=t!=null?Yi(ea(t)):{},ra(e||!t||!t.__esModule?Zn(n,"default",{value:t,enumerable:!0}):n,t));var te=$((Im,so)=>{"use strict";var no=["nodebuffer","arraybuffer","fragments"],oo=typeof Blob<"u";oo&&no.push("blob");so.
6
- exports={BINARY_TYPES:no,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:oo,
3
+ var Xa=Object.create;var _o=Object.defineProperty;var Ya=Object.getOwnPropertyDescriptor;var Za=Object.getOwnPropertyNames;var Qa=Object.getPrototypeOf,ec=Object.prototype.hasOwnProperty;var U=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){
4
+ if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var X=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var tc=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Za(e))!ec.call(t,o)&&o!==n&&_o(t,o,{get:()=>e[o],
5
+ enumerable:!(r=Ya(e,o))||r.enumerable});return t};var fe=(t,e,n)=>(n=t!=null?Xa(Qa(t)):{},tc(e||!t||!t.__esModule?_o(n,"default",{value:t,enumerable:!0}):n,t));var ie=X((Wh,No)=>{"use strict";var Po=["nodebuffer","arraybuffer","fragments"],ko=typeof Blob<"u";ko&&Po.push("blob");No.
6
+ exports={BINARY_TYPES:Po,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ko,
7
7
  kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
8
- "websocket"),NOOP:()=>{}}});var Ye=$((Sm,_t)=>{"use strict";var{EMPTY_BUFFER:va}=te(),gr=Buffer[Symbol.species];function wa(t,e){if(t.length===0)return va;
8
+ "websocket"),NOOP:()=>{}}});var st=X((Kh,Mt)=>{"use strict";var{EMPTY_BUFFER:gc}=ie(),Or=Buffer[Symbol.species];function vc(t,e){if(t.length===0)return gc;
9
9
  if(t.length===1)return t[0];let n=Buffer.allocUnsafe(e),r=0;for(let o=0;o<t.length;o++){let s=t[o];n.set(s,r),r+=s.length}
10
- return r<e?new gr(n.buffer,n.byteOffset,r):n}function io(t,e,n,r,o){for(let s=0;s<o;s++)n[r+s]=t[s]^e[s&3]}function ao(t,e){
11
- for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function ya(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
12
- t.byteOffset+t.length)}function vr(t){if(vr.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
13
- e=new gr(t):ArrayBuffer.isView(t)?e=new gr(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),vr.readOnly=!1),e}_t.exports=
14
- {concat:wa,mask:io,toArrayBuffer:ya,toBuffer:vr,unmask:ao};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=M("bufferutil");_t.
15
- exports.mask=function(e,n,r,o,s){s<48?io(e,n,r,o,s):t.mask(e,n,r,o,s)},_t.exports.unmask=function(e,n){e.length<32?ao(e,
16
- n):t.unmask(e,n)}}catch{}});var lo=$((xm,uo)=>{"use strict";var co=Symbol("kDone"),wr=Symbol("kRun"),yr=class{constructor(e){this[co]=()=>{this.pending--,
17
- this[wr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[wr]()}[wr](){if(this.pending!==
18
- this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[co])}}};uo.exports=yr});var Re=$((Tm,ho)=>{"use strict";var Ze=M("zlib"),po=Ye(),Ia=lo(),{kStatusCode:fo}=te(),Sa=Buffer[Symbol.species],xa=Buffer.
19
- from([0,0,255,255]),At=Symbol("permessage-deflate"),re=Symbol("total-length"),Ee=Symbol("callback"),ue=Symbol("buffers"),
20
- Oe=Symbol("error"),Ct,Ir=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this.
10
+ return r<e?new Or(n.buffer,n.byteOffset,r):n}function Mo(t,e,n,r,o){for(let s=0;s<o;s++)n[r+s]=t[s]^e[s&3]}function jo(t,e){
11
+ for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function wc(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
12
+ t.byteOffset+t.length)}function Rr(t){if(Rr.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
13
+ e=new Or(t):ArrayBuffer.isView(t)?e=new Or(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Rr.readOnly=!1),e}Mt.exports=
14
+ {concat:vc,mask:Mo,toArrayBuffer:wc,toBuffer:Rr,unmask:jo};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=U("bufferutil");Mt.
15
+ exports.mask=function(e,n,r,o,s){s<48?Mo(e,n,r,o,s):t.mask(e,n,r,o,s)},Mt.exports.unmask=function(e,n){e.length<32?jo(e,
16
+ n):t.unmask(e,n)}}catch{}});var Lo=X((Jh,zo)=>{"use strict";var Do=Symbol("kDone"),Pr=Symbol("kRun"),kr=class{constructor(e){this[Do]=()=>{this.pending--,
17
+ this[Pr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Pr]()}[Pr](){if(this.pending!==
18
+ this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Do])}}};zo.exports=kr});var De=X((Xh,$o)=>{"use strict";var it=U("zlib"),Uo=st(),yc=Lo(),{kStatusCode:Fo}=ie(),Ic=Buffer[Symbol.species],Sc=Buffer.
19
+ from([0,0,255,255]),Dt=Symbol("permessage-deflate"),ae=Symbol("total-length"),Me=Symbol("callback"),he=Symbol("buffers"),
20
+ je=Symbol("error"),jt,Nr=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,!Ct){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
23
- 10;Ct=new Ia(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
22
+ null,this._inflate=null,this.params=null,!jt){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
23
+ 10;jt=new yc(n)}}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[Ee];this._deflate.close(),this._deflate=
28
+ _inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Me];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 n=this._options,
30
30
  r=e.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===
31
31
  !1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits==
@@ -44,53 +44,53 @@ y a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;i
44
44
  "${r}": ${o}`)}else if(r==="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 "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){
46
46
  if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);
47
- n[r]=o})}),e}decompress(e,n,r){Ct.add(o=>{this._decompress(e,n,(s,i)=>{o(),r(s,i)})})}compress(e,n,r){Ct.add(o=>{this._compress(
47
+ n[r]=o})}),e}decompress(e,n,r){jt.add(o=>{this._decompress(e,n,(s,i)=>{o(),r(s,i)})})}compress(e,n,r){jt.add(o=>{this._compress(
48
48
  e,n,(s,i)=>{o(),r(s,i)})})}_decompress(e,n,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_\
49
- window_bits`,i=typeof this.params[s]!="number"?Ze.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ze.createInflateRaw(
50
- {...this._options.zlibInflateOptions,windowBits:i}),this._inflate[At]=this,this._inflate[re]=0,this._inflate[ue]=[],this.
51
- _inflate.on("error",ba),this._inflate.on("data",mo)}this._inflate[Ee]=r,this._inflate.write(e),n&&this._inflate.write(xa),
52
- this._inflate.flush(()=>{let s=this._inflate[Oe];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=po.concat(
53
- this._inflate[ue],this._inflate[re]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
54
- (this._inflate[re]=0,this._inflate[ue]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(e,n,r){
49
+ window_bits`,i=typeof this.params[s]!="number"?it.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=it.createInflateRaw(
50
+ {...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Dt]=this,this._inflate[ae]=0,this._inflate[he]=[],this.
51
+ _inflate.on("error",bc),this._inflate.on("data",qo)}this._inflate[Me]=r,this._inflate.write(e),n&&this._inflate.write(Sc),
52
+ this._inflate.flush(()=>{let s=this._inflate[je];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=Uo.concat(
53
+ this._inflate[he],this._inflate[ae]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
54
+ (this._inflate[ae]=0,this._inflate[he]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(e,n,r){
55
55
  let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
56
- Ze.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ze.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
57
- this._deflate[re]=0,this._deflate[ue]=[],this._deflate.on("data",Ta)}this._deflate[Ee]=r,this._deflate.write(e),this._deflate.
58
- flush(Ze.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=po.concat(this._deflate[ue],this._deflate[re]);n&&(s=new Sa(s.
59
- buffer,s.byteOffset,s.length-4)),this._deflate[Ee]=null,this._deflate[re]=0,this._deflate[ue]=[],n&&this.params[`${o}_no\
60
- _context_takeover`]&&this._deflate.reset(),r(null,s)})}};ho.exports=Ir;function Ta(t){this[ue].push(t),this[re]+=t.length}
61
- function mo(t){if(this[re]+=t.length,this[At]._maxPayload<1||this[re]<=this[At]._maxPayload){this[ue].push(t);return}this[Oe]=
62
- new RangeError("Max payload size exceeded"),this[Oe].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Oe][fo]=1009,this.removeListener(
63
- "data",mo),this.reset()}function ba(t){if(this[At]._inflate=null,this[Oe]){this[Ee](this[Oe]);return}t[fo]=1007,this[Ee](
64
- t)}});var Pe=$((bm,Et)=>{"use strict";var{isUtf8:go}=M("buffer"),{hasBlob:_a}=te(),Ca=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
56
+ it.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=it.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
57
+ this._deflate[ae]=0,this._deflate[he]=[],this._deflate.on("data",xc)}this._deflate[Me]=r,this._deflate.write(e),this._deflate.
58
+ flush(it.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Uo.concat(this._deflate[he],this._deflate[ae]);n&&(s=new Ic(s.
59
+ buffer,s.byteOffset,s.length-4)),this._deflate[Me]=null,this._deflate[ae]=0,this._deflate[he]=[],n&&this.params[`${o}_no\
60
+ _context_takeover`]&&this._deflate.reset(),r(null,s)})}};$o.exports=Nr;function xc(t){this[he].push(t),this[ae]+=t.length}
61
+ function qo(t){if(this[ae]+=t.length,this[Dt]._maxPayload<1||this[ae]<=this[Dt]._maxPayload){this[he].push(t);return}this[je]=
62
+ new RangeError("Max payload size exceeded"),this[je].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[je][Fo]=1009,this.removeListener(
63
+ "data",qo),this.reset()}function bc(t){if(this[Dt]._inflate=null,this[je]){this[Me](this[je]);return}t[Fo]=1007,this[Me](
64
+ t)}});var ze=X((Yh,zt)=>{"use strict";var{isUtf8:Bo}=U("buffer"),{hasBlob:Tc}=ie(),_c=[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 Aa(t){return t>=
67
- 1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Sr(t){let e=t.length,n=0;for(;n<e;)if((t[n]&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 Cc(t){return t>=
67
+ 1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Mr(t){let e=t.length,n=0;for(;n<e;)if((t[n]&128)===
68
68
  0)n++;else if((t[n]&224)===192){if(n+1===e||(t[n+1]&192)!==128||(t[n]&254)===192)return!1;n+=2}else if((t[n]&240)===224){
69
69
  if(n+2>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||t[n]===224&&(t[n+1]&224)===128||t[n]===237&&(t[n+1]&224)===160)return!1;
70
70
  n+=3}else if((t[n]&248)===240){if(n+3>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||(t[n+3]&192)!==128||t[n]===240&&(t[n+1]&
71
- 240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function Ea(t){return _a&&typeof t=="o\
71
+ 240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function Ac(t){return Tc&&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")}Et.exports={isBlob:Ea,isValidStatusCode:Aa,isValidUTF8:Sr,tokenChars:Ca};if(go)Et.
74
- exports.isValidUTF8=function(t){return t.length<24?Sr(t):go(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=M("utf-8-validate");
75
- Et.exports.isValidUTF8=function(e){return e.length<32?Sr(e):t(e)}}catch{}});var Cr=$((_m,To)=>{"use strict";var{Writable:Oa}=M("stream"),vo=Re(),{BINARY_TYPES:Ra,EMPTY_BUFFER:wo,kStatusCode:Pa,kWebSocket:ka}=te(),
76
- {concat:xr,toArrayBuffer:Ma,unmask:Na}=Ye(),{isValidStatusCode:ja,isValidUTF8:yo}=Pe(),Ot=Buffer[Symbol.species],G=0,Io=1,
77
- So=2,xo=3,Tr=4,br=5,Rt=6,_r=class extends Oa{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
78
- void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Ra[0],this._extensions=e.extensions||{},this._isServer=
73
+ "Blob"||t[Symbol.toStringTag]==="File")}zt.exports={isBlob:Ac,isValidStatusCode:Cc,isValidUTF8:Mr,tokenChars:_c};if(Bo)zt.
74
+ exports.isValidUTF8=function(t){return t.length<24?Mr(t):Bo(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=U("utf-8-validate");
75
+ zt.exports.isValidUTF8=function(e){return e.length<32?Mr(e):t(e)}}catch{}});var Ur=X((Zh,Xo)=>{"use strict";var{Writable:Ec}=U("stream"),Ho=De(),{BINARY_TYPES:Oc,EMPTY_BUFFER:Vo,kStatusCode:Rc,kWebSocket:Pc}=ie(),
76
+ {concat:jr,toArrayBuffer:kc,unmask:Nc}=st(),{isValidStatusCode:Mc,isValidUTF8:Go}=ze(),Lt=Buffer[Symbol.species],Z=0,Wo=1,
77
+ Ko=2,Jo=3,Dr=4,zr=5,Ut=6,Lr=class extends Ec{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
78
+ void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Oc[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[ka]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
80
+ 0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Pc]=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=G}_write(e,n,r){
83
- if(this._opcode===8&&this._state==G)return r();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=Z}_write(e,n,r){
83
+ if(this._opcode===8&&this._state==Z)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
84
84
  r(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(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this.
86
- _buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new Ot(r.buffer,r.byteOffset+
87
- e,r.length-e),new Ot(r.buffer,r.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let r=this._buffers[0],o=n.length-e;e>=r.length?
88
- n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),o),this._buffers[0]=new Ot(r.buffer,r.byteOffset+
89
- e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case G:this.getInfo(e);
90
- break;case Io:this.getPayloadLength16(e);break;case So:this.getPayloadLength64(e);break;case xo:this.getMask();break;case Tr:
91
- this.getData(e);break;case br:case Rt: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 r=this._buffers[0];return this._buffers[0]=new Lt(r.buffer,r.byteOffset+
87
+ e,r.length-e),new Lt(r.buffer,r.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let r=this._buffers[0],o=n.length-e;e>=r.length?
88
+ n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),o),this._buffers[0]=new Lt(r.buffer,r.byteOffset+
89
+ e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case Z:this.getInfo(e);
90
+ break;case Wo:this.getPayloadLength16(e);break;case Ko:this.getPayloadLength64(e);break;case Jo:this.getMask();break;case Dr:
91
+ this.getData(e);break;case zr:case Ut:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
92
92
  2){this._loop=!1;return}let n=this.consume(2);if((n[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 r=(n[0]&64)===64;if(r&&!this._extensions[vo.extensionName]){
93
+ clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let r=(n[0]&64)===64;if(r&&!this._extensions[Ho.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=(n[0]&
95
95
  128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){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,615 +104,617 @@ 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=(n[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=Io:this._payloadLength===127?this._state=So:this.haveLength(e)}getPayloadLength16(e){
107
+ e(o);return}this._payloadLength===126?this._state=Wo:this._payloadLength===127?this._state=Ko: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 n=this.consume(8),r=n.readUInt32BE(0);if(r>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=r*Math.pow(2,32)+n.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 n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(n);return}
114
- this._masked?this._state=xo:this._state=Tr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
115
- 4),this._state=Tr}getData(e){let n=wo;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
114
+ this._masked?this._state=Jo:this._state=Dr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
115
+ 4),this._state=Dr}getData(e){let n=Vo;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
116
116
  return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
117
- Na(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
117
+ Nc(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
118
118
  let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this.
119
- _compressed){this._state=br,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
120
- push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[vo.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return n(
119
+ _compressed){this._state=zr,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
120
+ push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[Ho.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return n(
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");n(i);return}this._fragments.push(s)}
123
- this.dataMessage(n),this._state===G&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=G;return}let n=this._messageLength,
123
+ this.dataMessage(n),this._state===Z&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=Z;return}let n=this._messageLength,
124
124
  r=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=xr(r,n):this._binaryType==="arraybuffer"?o=Ma(xr(r,n)):this.
126
- _binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=G):(this._state=
127
- Rt,setImmediate(()=>{this.emit("message",o,!0),this._state=G,this.startLoop(e)}))}else{let o=xr(r,n);if(!this._skipUTF8Validation&&
128
- !yo(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===br||
129
- this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=G):(this._state=Rt,setImmediate(()=>{this.emit("mess\
130
- age",o,!1),this._state=G,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
131
- emit("conclude",1005,wo),this.end();else{let r=e.readUInt16BE(0);if(!ja(r)){let s=this.createError(RangeError,`invalid s\
132
- tatus code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new Ot(e.buffer,e.byteOffset+2,e.length-2);if(!this.
133
- _skipUTF8Validation&&!yo(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}
134
- this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=G;return}this._allowSynchronousEvents?(this.emit(this._opcode===
135
- 9?"ping":"pong",e),this._state=G):(this._state=Rt,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
136
- G,this.startLoop(n)}))}createError(e,n,r,o,s){this._loop=!1,this._errored=!0;let i=new e(r?`Invalid WebSocket frame: ${n}`:
137
- n);return Error.captureStackTrace(i,this.createError),i.code=s,i[Pa]=o,i}};To.exports=_r});var Or=$((Am,Co)=>{"use strict";var{Duplex:Cm}=M("stream"),{randomFillSync:Da}=M("crypto"),{types:{isUint8Array:za}}=M("util"),
138
- bo=Re(),{EMPTY_BUFFER:La,kWebSocket:Ua,NOOP:Fa}=te(),{isBlob:ke,isValidStatusCode:qa}=Pe(),{mask:_o,toBuffer:ve}=Ye(),W=Symbol(
139
- "kByteLength"),$a=Buffer.alloc(4),Pt=8*1024,we,Me=Pt,Z=0,Ba=1,Ha=2,Ar=class t{constructor(e,n,r){this._extensions=n||{},
125
+ [],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=jr(r,n):this._binaryType==="arraybuffer"?o=kc(jr(r,n)):this.
126
+ _binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=Z):(this._state=
127
+ Ut,setImmediate(()=>{this.emit("message",o,!0),this._state=Z,this.startLoop(e)}))}else{let o=jr(r,n);if(!this._skipUTF8Validation&&
128
+ !Go(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===zr||
129
+ this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=Z):(this._state=Ut,setImmediate(()=>{this.emit("mess\
130
+ age",o,!1),this._state=Z,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
131
+ emit("conclude",1005,Vo),this.end();else{let r=e.readUInt16BE(0);if(!Mc(r)){let s=this.createError(RangeError,`invalid s\
132
+ tatus code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new Lt(e.buffer,e.byteOffset+2,e.length-2);if(!this.
133
+ _skipUTF8Validation&&!Go(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}
134
+ this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=Z;return}this._allowSynchronousEvents?(this.emit(this._opcode===
135
+ 9?"ping":"pong",e),this._state=Z):(this._state=Ut,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
136
+ Z,this.startLoop(n)}))}createError(e,n,r,o,s){this._loop=!1,this._errored=!0;let i=new e(r?`Invalid WebSocket frame: ${n}`:
137
+ n);return Error.captureStackTrace(i,this.createError),i.code=s,i[Rc]=o,i}};Xo.exports=Lr});var $r=X((eg,Qo)=>{"use strict";var{Duplex:Qh}=U("stream"),{randomFillSync:jc}=U("crypto"),{types:{isUint8Array:Dc}}=U("util"),
138
+ Yo=De(),{EMPTY_BUFFER:zc,kWebSocket:Lc,NOOP:Uc}=ie(),{isBlob:Le,isValidStatusCode:Fc}=ze(),{mask:Zo,toBuffer:be}=st(),Q=Symbol(
139
+ "kByteLength"),qc=Buffer.alloc(4),Ft=8*1024,Te,Ue=Ft,te=0,$c=1,Bc=2,Fr=class t{constructor(e,n,r){this._extensions=n||{},
140
140
  r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this.
141
- _bufferedBytes=0,this._queue=[],this._state=Z,this.onerror=Fa,this[Ua]=void 0}static frame(e,n){let r,o=!1,s=2,i=!1;n.mask&&
142
- (r=n.maskBuffer||$a,n.generateMask?n.generateMask(r):(Me===Pt&&(we===void 0&&(we=Buffer.alloc(Pt)),Da(we,0,Pt),Me=0),r[0]=
143
- we[Me++],r[1]=we[Me++],r[2]=we[Me++],r[3]=we[Me++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!n.mask||
144
- i)&&n[W]!==void 0?a=n[W]:(e=Buffer.from(e),a=e.length):(a=e.length,o=n.mask&&n.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
141
+ _bufferedBytes=0,this._queue=[],this._state=te,this.onerror=Uc,this[Lc]=void 0}static frame(e,n){let r,o=!1,s=2,i=!1;n.mask&&
142
+ (r=n.maskBuffer||qc,n.generateMask?n.generateMask(r):(Ue===Ft&&(Te===void 0&&(Te=Buffer.alloc(Ft)),jc(Te,0,Ft),Ue=0),r[0]=
143
+ Te[Ue++],r[1]=Te[Ue++],r[2]=Te[Ue++],r[3]=Te[Ue++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!n.mask||
144
+ i)&&n[Q]!==void 0?a=n[Q]:(e=Buffer.from(e),a=e.length):(a=e.length,o=n.mask&&n.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]=n.fin?n.opcode|128:n.opcode,n.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)),n.mask?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=
147
- r[2],d[s-1]=r[3],i?[d,e]:o?(_o(e,r,d,s,a),[d]):(_o(e,r,e,0,a),[d,e])):[d,e]}close(e,n,r,o){let s;if(e===void 0)s=La;else{
148
- if(typeof e!="number"||!qa(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.
147
+ r[2],d[s-1]=r[3],i?[d,e]:o?(Zo(e,r,d,s,a),[d]):(Zo(e,r,e,0,a),[d,e])):[d,e]}close(e,n,r,o){let s;if(e===void 0)s=zc;else{
148
+ if(typeof e!="number"||!Fc(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.
149
149
  length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(n);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 n=="string")s.write(
151
- n,2);else if(za(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[W]:s.
151
+ n,2);else if(Dc(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[Q]:s.
152
152
  length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==
153
- Z?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,n,r){let o,s;if(typeof e=="string"?(o=Buffer.
154
- byteLength(e),s=!1):ke(e)?(o=e.size,s=!1):(e=ve(e),o=e.length,s=ve.readOnly),o>125)throw new RangeError("The data size m\
155
- ust not be greater than 125 bytes");let i={[W]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,
156
- opcode:9,readOnly:s,rsv1:!1};ke(e)?this._state!==Z?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(e,!1,i,r):
157
- this._state!==Z?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}pong(e,n,r){let o,s;if(typeof e=="\
158
- string"?(o=Buffer.byteLength(e),s=!1):ke(e)?(o=e.size,s=!1):(e=ve(e),o=e.length,s=ve.readOnly),o>125)throw new RangeError(
159
- "The data size must not be greater than 125 bytes");let i={[W]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this.
160
- _maskBuffer,opcode:10,readOnly:s,rsv1:!1};ke(e)?this._state!==Z?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(
161
- e,!1,i,r):this._state!==Z?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}send(e,n,r){let o=this._extensions[bo.
162
- extensionName],s=n.binary?2:1,i=n.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):ke(e)?(a=e.size,c=!1):(e=
163
- ve(e),a=e.length,c=ve.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_contex\
164
- t_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),n.fin&&(this._firstFragment=
165
- !0);let d={[W]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
166
- ke(e)?this._state!==Z?this.enqueue([this.getBlobData,e,this._compress,d,r]):this.getBlobData(e,this._compress,d,r):this.
167
- _state!==Z?this.enqueue([this.dispatch,e,this._compress,d,r]):this.dispatch(e,this._compress,d,r)}getBlobData(e,n,r,o){this.
168
- _bufferedBytes+=r[W],this._state=Ha,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(Er,this,a,o);return}this._bufferedBytes-=r[W];let i=ve(s);n?this.
170
- dispatch(i,n,r,o):(this._state=Z,this.sendFrame(t.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(Va,this,s,o)})}dispatch(e,n,r,o){
171
- if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[bo.extensionName];this._bufferedBytes+=r[W],this._state=
172
- Ba,s.compress(e,r.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
173
- pressed");Er(this,c,o);return}this._bufferedBytes-=r[W],this._state=Z,r.readOnly=!1,this.sendFrame(t.frame(a,r),o),this.
174
- dequeue()})}dequeue(){for(;this._state===Z&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][W],
175
- Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][W],this._queue.push(e)}sendFrame(e,n){e.length===
176
- 2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.write(e[0],
177
- n)}};Co.exports=Ar;function Er(t,e,n){typeof n=="function"&&n(e);for(let r=0;r<t._queue.length;r++){let o=t._queue[r],s=o[o.
178
- length-1];typeof s=="function"&&s(e)}}function Va(t,e,n){Er(t,e,n),t.onerror(e)}});var jo=$((Em,No)=>{"use strict";var{kForOnEventAttribute:Qe,kListener:Rr}=te(),Ao=Symbol("kCode"),Eo=Symbol("kData"),Oo=Symbol(
179
- "kError"),Ro=Symbol("kMessage"),Po=Symbol("kReason"),Ne=Symbol("kTarget"),ko=Symbol("kType"),Mo=Symbol("kWasClean"),ne=class{constructor(e){
180
- this[Ne]=null,this[ko]=e}get target(){return this[Ne]}get type(){return this[ko]}};Object.defineProperty(ne.prototype,"t\
181
- arget",{enumerable:!0});Object.defineProperty(ne.prototype,"type",{enumerable:!0});var ye=class extends ne{constructor(e,n={}){
182
- super(e),this[Ao]=n.code===void 0?0:n.code,this[Po]=n.reason===void 0?"":n.reason,this[Mo]=n.wasClean===void 0?!1:n.wasClean}get code(){
183
- return this[Ao]}get reason(){return this[Po]}get wasClean(){return this[Mo]}};Object.defineProperty(ye.prototype,"code",
184
- {enumerable:!0});Object.defineProperty(ye.prototype,"reason",{enumerable:!0});Object.defineProperty(ye.prototype,"wasCle\
185
- an",{enumerable:!0});var je=class extends ne{constructor(e,n={}){super(e),this[Oo]=n.error===void 0?null:n.error,this[Ro]=
186
- n.message===void 0?"":n.message}get error(){return this[Oo]}get message(){return this[Ro]}};Object.defineProperty(je.prototype,
187
- "error",{enumerable:!0});Object.defineProperty(je.prototype,"message",{enumerable:!0});var et=class extends ne{constructor(e,n={}){
188
- super(e),this[Eo]=n.data===void 0?null:n.data}get data(){return this[Eo]}};Object.defineProperty(et.prototype,"data",{enumerable:!0});
189
- var Ga={addEventListener(t,e,n={}){for(let o of this.listeners(t))if(!n[Qe]&&o[Rr]===e&&!o[Qe])return;let r;if(t==="mess\
190
- age")r=function(s,i){let a=new et("message",{data:i?s:s.toString()});a[Ne]=this,kt(e,this,a)};else if(t==="close")r=function(s,i){
191
- let a=new ye("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Ne]=this,kt(
192
- e,this,a)};else if(t==="error")r=function(s){let i=new je("error",{error:s,message:s.message});i[Ne]=this,kt(e,this,i)};else if(t===
193
- "open")r=function(){let s=new ne("open");s[Ne]=this,kt(e,this,s)};else return;r[Qe]=!!n[Qe],r[Rr]=e,n.once?this.once(t,r):
194
- this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Rr]===e&&!n[Qe]){this.removeListener(t,n);break}}};
195
- No.exports={CloseEvent:ye,ErrorEvent:je,Event:ne,EventTarget:Ga,MessageEvent:et};function kt(t,e,n){typeof t=="object"&&
196
- t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Mt=$((Om,Do)=>{"use strict";var{tokenChars:tt}=Pe();function ee(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function Wa(t){
197
- let e=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,p=-1,m=0;for(;m<t.length;m++)if(d=t.charCodeAt(
198
- m),i===void 0)if(p===-1&&tt[d]===1)c===-1&&(c=m);else if(m!==0&&(d===32||d===9))p===-1&&c!==-1&&(p=m);else if(d===59||d===
199
- 44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);p===-1&&(p=m);let v=t.slice(c,p);d===44?(ee(e,
200
- v,n),n=Object.create(null)):i=v,c=p=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(a===void 0)
201
- if(p===-1&&tt[d]===1)c===-1&&(c=m);else if(d===32||d===9)p===-1&&c!==-1&&(p=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
202
- `Unexpected character at index ${m}`);p===-1&&(p=m),ee(n,t.slice(c,p),!0),d===44&&(ee(e,i,n),n=Object.create(null),i=void 0),
203
- c=p=-1}else if(d===61&&c!==-1&&p===-1)a=t.slice(c,m),c=p=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){
204
- if(tt[d]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);c===-1?c=m:r||(r=!0),o=!1}else if(s)if(tt[d]===
205
- 1)c===-1&&(c=m);else if(d===34&&c!==-1)s=!1,p=m;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
206
- index ${m}`);else if(d===34&&t.charCodeAt(m-1)===61)s=!0;else if(p===-1&&tt[d]===1)c===-1&&(c=m);else if(c!==-1&&(d===32||
207
- d===9))p===-1&&(p=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);p===-1&&
208
- (p=m);let v=t.slice(c,p);r&&(v=v.replace(/\\/g,""),r=!1),ee(n,a,v),d===44&&(ee(e,i,n),n=Object.create(null),i=void 0),a=
209
- void 0,c=p=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
210
- "Unexpected end of input");p===-1&&(p=m);let l=t.slice(c,p);return i===void 0?ee(e,l,n):(a===void 0?ee(n,l,!0):r?ee(n,a,
211
- l.replace(/\\/g,"")):ee(n,a,l),ee(e,i,n)),e}function Ka(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(
153
+ te?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,n,r){let o,s;if(typeof e=="string"?(o=Buffer.
154
+ byteLength(e),s=!1):Le(e)?(o=e.size,s=!1):(e=be(e),o=e.length,s=be.readOnly),o>125)throw new RangeError("The data size m\
155
+ ust not be greater than 125 bytes");let i={[Q]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,
156
+ opcode:9,readOnly:s,rsv1:!1};Le(e)?this._state!==te?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(e,!1,i,r):
157
+ this._state!==te?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}pong(e,n,r){let o,s;if(typeof e==
158
+ "string"?(o=Buffer.byteLength(e),s=!1):Le(e)?(o=e.size,s=!1):(e=be(e),o=e.length,s=be.readOnly),o>125)throw new RangeError(
159
+ "The data size must not be greater than 125 bytes");let i={[Q]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this.
160
+ _maskBuffer,opcode:10,readOnly:s,rsv1:!1};Le(e)?this._state!==te?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(
161
+ e,!1,i,r):this._state!==te?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}send(e,n,r){let o=this.
162
+ _extensions[Yo.extensionName],s=n.binary?2:1,i=n.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Le(e)?(a=
163
+ e.size,c=!1):(e=be(e),a=e.length,c=be.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"\
164
+ server_no_context_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),n.fin&&(this.
165
+ _firstFragment=!0);let d={[Q]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:s,
166
+ readOnly:c,rsv1:i};Le(e)?this._state!==te?this.enqueue([this.getBlobData,e,this._compress,d,r]):this.getBlobData(e,this.
167
+ _compress,d,r):this._state!==te?this.enqueue([this.dispatch,e,this._compress,d,r]):this.dispatch(e,this._compress,d,r)}getBlobData(e,n,r,o){
168
+ this._bufferedBytes+=r[Q],this._state=Bc,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket\
169
+ was closed while the blob was being read");process.nextTick(qr,this,a,o);return}this._bufferedBytes-=r[Q];let i=be(s);n?
170
+ this.dispatch(i,n,r,o):(this._state=te,this.sendFrame(t.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(Hc,this,
171
+ s,o)})}dispatch(e,n,r,o){if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[Yo.extensionName];this._bufferedBytes+=
172
+ r[Q],this._state=$c,s.compress(e,r.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while d\
173
+ ata was being compressed");qr(this,c,o);return}this._bufferedBytes-=r[Q],this._state=te,r.readOnly=!1,this.sendFrame(t.frame(
174
+ a,r),o),this.dequeue()})}dequeue(){for(;this._state===te&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=
175
+ e[3][Q],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Q],this._queue.push(e)}sendFrame(e,n){
176
+ e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.
177
+ write(e[0],n)}};Qo.exports=Fr;function qr(t,e,n){typeof n=="function"&&n(e);for(let r=0;r<t._queue.length;r++){let o=t._queue[r],
178
+ s=o[o.length-1];typeof s=="function"&&s(e)}}function Hc(t,e,n){qr(t,e,n),t.onerror(e)}});var cs=X((tg,as)=>{"use strict";var{kForOnEventAttribute:at,kListener:Br}=ie(),es=Symbol("kCode"),ts=Symbol("kData"),rs=Symbol(
179
+ "kError"),ns=Symbol("kMessage"),os=Symbol("kReason"),Fe=Symbol("kTarget"),ss=Symbol("kType"),is=Symbol("kWasClean"),ce=class{constructor(e){
180
+ this[Fe]=null,this[ss]=e}get target(){return this[Fe]}get type(){return this[ss]}};Object.defineProperty(ce.prototype,"t\
181
+ arget",{enumerable:!0});Object.defineProperty(ce.prototype,"type",{enumerable:!0});var _e=class extends ce{constructor(e,n={}){
182
+ super(e),this[es]=n.code===void 0?0:n.code,this[os]=n.reason===void 0?"":n.reason,this[is]=n.wasClean===void 0?!1:n.wasClean}get code(){
183
+ return this[es]}get reason(){return this[os]}get wasClean(){return this[is]}};Object.defineProperty(_e.prototype,"code",
184
+ {enumerable:!0});Object.defineProperty(_e.prototype,"reason",{enumerable:!0});Object.defineProperty(_e.prototype,"wasCle\
185
+ an",{enumerable:!0});var qe=class extends ce{constructor(e,n={}){super(e),this[rs]=n.error===void 0?null:n.error,this[ns]=
186
+ n.message===void 0?"":n.message}get error(){return this[rs]}get message(){return this[ns]}};Object.defineProperty(qe.prototype,
187
+ "error",{enumerable:!0});Object.defineProperty(qe.prototype,"message",{enumerable:!0});var ct=class extends ce{constructor(e,n={}){
188
+ super(e),this[ts]=n.data===void 0?null:n.data}get data(){return this[ts]}};Object.defineProperty(ct.prototype,"data",{enumerable:!0});
189
+ var Vc={addEventListener(t,e,n={}){for(let o of this.listeners(t))if(!n[at]&&o[Br]===e&&!o[at])return;let r;if(t==="mess\
190
+ age")r=function(s,i){let a=new ct("message",{data:i?s:s.toString()});a[Fe]=this,qt(e,this,a)};else if(t==="close")r=function(s,i){
191
+ let a=new _e("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Fe]=this,qt(
192
+ e,this,a)};else if(t==="error")r=function(s){let i=new qe("error",{error:s,message:s.message});i[Fe]=this,qt(e,this,i)};else if(t===
193
+ "open")r=function(){let s=new ce("open");s[Fe]=this,qt(e,this,s)};else return;r[at]=!!n[at],r[Br]=e,n.once?this.once(t,r):
194
+ this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Br]===e&&!n[at]){this.removeListener(t,n);break}}};
195
+ as.exports={CloseEvent:_e,ErrorEvent:qe,Event:ce,EventTarget:Vc,MessageEvent:ct};function qt(t,e,n){typeof t=="object"&&
196
+ t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var $t=X((rg,ds)=>{"use strict";var{tokenChars:dt}=ze();function oe(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function Gc(t){
197
+ let e=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,m=0;for(;m<t.length;m++)if(d=t.charCodeAt(
198
+ m),i===void 0)if(u===-1&&dt[d]===1)c===-1&&(c=m);else if(m!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=m);else if(d===59||d===
199
+ 44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);u===-1&&(u=m);let v=t.slice(c,u);d===44?(oe(e,
200
+ v,n),n=Object.create(null)):i=v,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(a===void 0)
201
+ if(u===-1&&dt[d]===1)c===-1&&(c=m);else if(d===32||d===9)u===-1&&c!==-1&&(u=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
202
+ `Unexpected character at index ${m}`);u===-1&&(u=m),oe(n,t.slice(c,u),!0),d===44&&(oe(e,i,n),n=Object.create(null),i=void 0),
203
+ c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,m),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){
204
+ if(dt[d]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);c===-1?c=m:r||(r=!0),o=!1}else if(s)if(dt[d]===
205
+ 1)c===-1&&(c=m);else if(d===34&&c!==-1)s=!1,u=m;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
206
+ index ${m}`);else if(d===34&&t.charCodeAt(m-1)===61)s=!0;else if(u===-1&&dt[d]===1)c===-1&&(c=m);else if(c!==-1&&(d===32||
207
+ d===9))u===-1&&(u=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);u===-1&&
208
+ (u=m);let v=t.slice(c,u);r&&(v=v.replace(/\\/g,""),r=!1),oe(n,a,v),d===44&&(oe(e,i,n),n=Object.create(null),i=void 0),a=
209
+ void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
210
+ "Unexpected end of input");u===-1&&(u=m);let p=t.slice(c,u);return i===void 0?oe(e,p,n):(a===void 0?oe(n,p,!0):r?oe(n,a,
211
+ p.replace(/\\/g,"")):oe(n,a,p),oe(e,i,n)),e}function Wc(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(
212
212
  n)||(n=[n]),n.map(r=>[e].concat(Object.keys(r).map(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}\
213
- =${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Do.exports={format:Ka,parse:Wa}});var zt=$((km,Ko)=>{"use strict";var Ja=M("events"),Xa=M("https"),Ya=M("http"),Uo=M("net"),Za=M("tls"),{randomBytes:Qa,createHash:ec}=M("crypto"),
214
- {Duplex:Rm,Readable:Pm}=M("stream"),{URL:Pr}=M("url"),le=Re(),tc=Cr(),rc=Or(),{isBlob:nc}=Pe(),{BINARY_TYPES:zo,CLOSE_TIMEOUT:oc,
215
- EMPTY_BUFFER:Nt,GUID:sc,kForOnEventAttribute:kr,kListener:ic,kStatusCode:ac,kWebSocket:L,NOOP:Fo}=te(),{EventTarget:{addEventListener:cc,
216
- removeEventListener:dc}}=jo(),{format:uc,parse:lc}=Mt(),{toBuffer:pc}=Ye(),qo=Symbol("kAborted"),Mr=[8,13],oe=["CONNECTI\
217
- NG","OPEN","CLOSING","CLOSED"],fc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends Ja{constructor(e,n,r){super(),this.
218
- _binaryType=zo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Nt,this._closeTimer=
213
+ =${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}ds.exports={format:Wc,parse:Gc}});var Gt=X((sg,Ss)=>{"use strict";var Kc=U("events"),Jc=U("https"),Xc=U("http"),ps=U("net"),Yc=U("tls"),{randomBytes:Zc,createHash:Qc}=U("crypto"),
214
+ {Duplex:ng,Readable:og}=U("stream"),{URL:Hr}=U("url"),ge=De(),ed=Ur(),td=$r(),{isBlob:rd}=ze(),{BINARY_TYPES:us,CLOSE_TIMEOUT:nd,
215
+ EMPTY_BUFFER:Bt,GUID:od,kForOnEventAttribute:Vr,kListener:sd,kStatusCode:id,kWebSocket:B,NOOP:fs}=ie(),{EventTarget:{addEventListener:ad,
216
+ removeEventListener:cd}}=cs(),{format:dd,parse:ud}=$t(),{toBuffer:ld}=st(),ms=Symbol("kAborted"),Gr=[8,13],de=["CONNECTI\
217
+ NG","OPEN","CLOSING","CLOSED"],pd=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,j=class t extends Kc{constructor(e,n,r){super(),this.
218
+ _binaryType=us[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bt,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,n===void 0?
221
- n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),$o(this,e,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=
222
- r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){zo.includes(e)&&(this._binaryType=
221
+ n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),hs(this,e,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=
222
+ r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){us.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,n,r){let o=new tc(
226
+ return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,n,r){let o=new ed(
227
227
  {allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,
228
228
  maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),
229
- s=new rc(e,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[L]=this,s[L]=this,e[L]=this,
230
- o.on("conclude",gc),o.on("drain",vc),o.on("error",wc),o.on("message",yc),o.on("ping",Ic),o.on("pong",Sc),s.onerror=xc,e.
231
- setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",Vo),e.on("data",Dt),e.on(
232
- "end",Go),e.on("error",Wo),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
233
- this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[le.extensionName]&&this._extensions[le.extensionName].
229
+ s=new td(e,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[B]=this,s[B]=this,e[B]=this,
230
+ o.on("conclude",hd),o.on("drain",gd),o.on("error",vd),o.on("message",wd),o.on("ping",yd),o.on("pong",Id),s.onerror=Sd,e.
231
+ setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",ws),e.on("data",Vt),e.on(
232
+ "end",ys),e.on("error",Is),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
233
+ this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ge.extensionName]&&this._extensions[ge.extensionName].
234
234
  cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){
235
- if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){B(this,this._req,"WebSocket was closed before the conn\
235
+ if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Y(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,n,!this._isServer,
238
238
  r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),
239
- Ho(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,r){
239
+ vs(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,r){
240
240
  if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="func\
241
241
  tion"?(r=e,e=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
242
- Nr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Nt,n,r)}pong(e,n,r){if(this.readyState===t.CONNECTING)
242
+ Wr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Bt,n,r)}pong(e,n,r){if(this.readyState===t.CONNECTING)
243
243
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=n=void 0):typeof n=="\
244
- function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Nr(this,e,r);return}n===void 0&&
245
- (n=!this._isServer),this._sender.pong(e||Nt,n,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
244
+ function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wr(this,e,r);return}n===void 0&&
245
+ (n=!this._isServer),this._sender.pong(e||Bt,n,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
246
246
  _paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,r){if(this.readyState===t.CONNECTING)
247
247
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof e=="numbe\
248
- r"&&(e=e.toString()),this.readyState!==t.OPEN){Nr(this,e,r);return}let o={binary:typeof e!="string",mask:!this._isServer,
249
- compress:!0,fin:!0,...n};this._extensions[le.extensionName]||(o.compress=!1),this._sender.send(e||Nt,o,r)}terminate(){if(this.
250
- readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){B(this,this._req,"WebSocket was closed before the connection w\
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.
248
+ r"&&(e=e.toString()),this.readyState!==t.OPEN){Wr(this,e,r);return}let o={binary:typeof e!="string",mask:!this._isServer,
249
+ compress:!0,fin:!0,...n};this._extensions[ge.extensionName]||(o.compress=!1),this._sender.send(e||Bt,o,r)}terminate(){if(this.
250
+ readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Y(this,this._req,"WebSocket was closed before the connection w\
251
+ as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(j,"CO\
252
+ NNECTING",{enumerable:!0,value:de.indexOf("CONNECTING")});Object.defineProperty(j.prototype,"CONNECTING",{enumerable:!0,
253
+ value:de.indexOf("CONNECTING")});Object.defineProperty(j,"OPEN",{enumerable:!0,value:de.indexOf("OPEN")});Object.defineProperty(
254
+ j.prototype,"OPEN",{enumerable:!0,value:de.indexOf("OPEN")});Object.defineProperty(j,"CLOSING",{enumerable:!0,value:de.indexOf(
255
+ "CLOSING")});Object.defineProperty(j.prototype,"CLOSING",{enumerable:!0,value:de.indexOf("CLOSING")});Object.defineProperty(
256
+ j,"CLOSED",{enumerable:!0,value:de.indexOf("CLOSED")});Object.defineProperty(j.prototype,"CLOSED",{enumerable:!0,value:de.
257
257
  indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
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[kr])return e[ic];return null},set(e){for(let n of this.
260
- listeners(t))if(n[kr]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[kr]:!0})}})});k.
261
- prototype.addEventListener=cc;k.prototype.removeEventListener=dc;Ko.exports=k;function $o(t,e,n,r){let o={allowSynchronousEvents:!0,
262
- autoPong:!0,closeTimeout:oc,protocolVersion:Mr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
258
+ defineProperty(j.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(j.prototype,
259
+ `on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Vr])return e[sd];return null},set(e){for(let n of this.
260
+ listeners(t))if(n[Vr]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[Vr]:!0})}})});j.
261
+ prototype.addEventListener=ad;j.prototype.removeEventListener=cd;Ss.exports=j;function hs(t,e,n,r){let o={allowSynchronousEvents:!0,
262
+ autoPong:!0,closeTimeout:nd,protocolVersion:Gr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
263
263
  perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,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,!Mr.includes(
265
- o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Mr.join(
266
- ", ")})`);let s;if(e instanceof Pr)s=e;else try{s=new Pr(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,!Gr.includes(
265
+ o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Gr.join(
266
+ ", ")})`);let s;if(e instanceof Hr)s=e;else try{s=new Hr(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
269
  +unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let T=new SyntaxError(
270
- c);if(t._redirects===0)throw T;jt(t,T);return}let d=i?443:80,p=Qa(16).toString("base64"),m=i?Xa.request:Ya.request,l=new Set,
271
- v;if(o.createConnection=o.createConnection||(i?hc:mc),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
270
+ c);if(t._redirects===0)throw T;Ht(t,T);return}let d=i?443:80,u=Zc(16).toString("base64"),m=i?Jc.request:Xc.request,p=new Set,
271
+ v;if(o.createConnection=o.createConnection||(i?md:fd),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
- -WebSocket-Key":p,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
274
- (v=new le({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=uc({[le.extensionName]:v.
275
- offer()})),n.length){for(let T of n){if(typeof T!="string"||!fc.test(T)||l.has(T))throw new SyntaxError("An invalid or d\
276
- uplicated subprotocol was specified");l.add(T)}o.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(o.origin&&(o.protocolVersion<
273
+ -WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
274
+ (v=new ge({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=dd({[ge.extensionName]:v.
275
+ offer()})),n.length){for(let T of n){if(typeof T!="string"||!pd.test(T)||p.has(T))throw new SyntaxError("An invalid or d\
276
+ uplicated subprotocol was specified");p.add(T)}o.headers["Sec-WebSocket-Protocol"]=n.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 T=o.path.split(":");o.socketPath=T[0],o.path=T[1]}let x;if(o.followRedirects){if(t._redirects===
278
+ :${s.password}`),a){let T=o.path.split(":");o.socketPath=T[0],o.path=T[1]}let y;if(o.followRedirects){if(t._redirects===
279
279
  0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let T=r&&r.headers;if(r={...r,
280
- headers:{}},T)for(let[O,P]of Object.entries(T))r.headers[O.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let T=a?
280
+ headers:{}},T)for(let[O,N]of Object.entries(T))r.headers[O.toLowerCase()]=N}else if(t.listenerCount("redirect")===0){let T=a?
281
281
  t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!T||
282
282
  t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,T||delete o.headers.host,o.auth=void 0)}
283
- o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),x=t._req=m(o),
284
- t._redirects&&t.emit("redirect",t.url,x)}else x=t._req=m(o);o.timeout&&x.on("timeout",()=>{B(t,x,"Opening handshake has \
285
- timed out")}),x.on("error",T=>{x===null||x[qo]||(x=t._req=null,jt(t,T))}),x.on("response",T=>{let O=T.headers.location,P=T.
286
- statusCode;if(O&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){B(t,x,"Maximum redirects exceeded");
287
- return}x.abort();let j;try{j=new Pr(O,e)}catch{let U=new SyntaxError(`Invalid URL: ${O}`);jt(t,U);return}$o(t,j,n,r)}else
288
- t.emit("unexpected-response",x,T)||B(t,x,`Unexpected server response: ${T.statusCode}`)}),x.on("upgrade",(T,O,P)=>{if(t.
289
- emit("upgrade",T),t.readyState!==k.CONNECTING)return;x=t._req=null;let j=T.headers.upgrade;if(j===void 0||j.toLowerCase()!==
290
- "websocket"){B(t,O,"Invalid Upgrade header");return}let D=ec("sha1").update(p+sc).digest("base64");if(T.headers["sec-web\
291
- socket-accept"]!==D){B(t,O,"Invalid Sec-WebSocket-Accept header");return}let U=T.headers["sec-websocket-protocol"],J;if(U!==
292
- void 0?l.size?l.has(U)||(J="Server sent an invalid subprotocol"):J="Server sent a subprotocol but none was requested":l.
293
- size&&(J="Server sent no subprotocol"),J){B(t,O,J);return}U&&(t._protocol=U);let H=T.headers["sec-websocket-extensions"];
294
- if(H!==void 0){if(!v){B(t,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let q;
295
- try{q=lc(H)}catch{B(t,O,"Invalid Sec-WebSocket-Extensions header");return}let ae=Object.keys(q);if(ae.length!==1||ae[0]!==
296
- le.extensionName){B(t,O,"Server indicated an extension that was not requested");return}try{v.accept(q[le.extensionName])}catch{
297
- B(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[le.extensionName]=v}t.setSocket(O,P,{allowSynchronousEvents:o.
283
+ o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),y=t._req=m(o),
284
+ t._redirects&&t.emit("redirect",t.url,y)}else y=t._req=m(o);o.timeout&&y.on("timeout",()=>{Y(t,y,"Opening handshake has \
285
+ timed out")}),y.on("error",T=>{y===null||y[ms]||(y=t._req=null,Ht(t,T))}),y.on("response",T=>{let O=T.headers.location,N=T.
286
+ statusCode;if(O&&o.followRedirects&&N>=300&&N<400){if(++t._redirects>o.maxRedirects){Y(t,y,"Maximum redirects exceeded");
287
+ return}y.abort();let z;try{z=new Hr(O,e)}catch{let q=new SyntaxError(`Invalid URL: ${O}`);Ht(t,q);return}hs(t,z,n,r)}else
288
+ t.emit("unexpected-response",y,T)||Y(t,y,`Unexpected server response: ${T.statusCode}`)}),y.on("upgrade",(T,O,N)=>{if(t.
289
+ emit("upgrade",T),t.readyState!==j.CONNECTING)return;y=t._req=null;let z=T.headers.upgrade;if(z===void 0||z.toLowerCase()!==
290
+ "websocket"){Y(t,O,"Invalid Upgrade header");return}let L=Qc("sha1").update(u+od).digest("base64");if(T.headers["sec-web\
291
+ socket-accept"]!==L){Y(t,O,"Invalid Sec-WebSocket-Accept header");return}let q=T.headers["sec-websocket-protocol"],H;if(q!==
292
+ void 0?p.size?p.has(q)||(H="Server sent an invalid subprotocol"):H="Server sent a subprotocol but none was requested":p.
293
+ size&&(H="Server sent no subprotocol"),H){Y(t,O,H);return}q&&(t._protocol=q);let R=T.headers["sec-websocket-extensions"];
294
+ if(R!==void 0){if(!v){Y(t,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;
295
+ try{P=ud(R)}catch{Y(t,O,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(P);if(A.length!==1||A[0]!==ge.
296
+ extensionName){Y(t,O,"Server indicated an extension that was not requested");return}try{v.accept(P[ge.extensionName])}catch{
297
+ Y(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ge.extensionName]=v}t.setSocket(O,N,{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(x,t):x.end()}function jt(t,e){t._readyState=
300
- k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function mc(t){return t.path=t.socketPath,Uo.connect(t)}function hc(t){
301
- return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Uo.isIP(t.host)?"":t.host),Za.connect(t)}function B(t,e,n){
302
- t._readyState=k.CLOSING;let r=new Error(n);Error.captureStackTrace(r,B),e.setHeader?(e[qo]=!0,e.abort(),e.socket&&!e.socket.
303
- destroyed&&e.socket.destroy(),process.nextTick(jt,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("clo\
304
- se",t.emitClose.bind(t)))}function Nr(t,e,n){if(e){let r=nc(e)?e.size:pc(e).length;t._socket?t._sender._bufferedBytes+=r:
305
- t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${oe[t.readyState]})`);process.
306
- nextTick(n,r)}}function gc(t,e){let n=this[L];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[L]!==void 0&&
307
- (n._socket.removeListener("data",Dt),process.nextTick(Bo,n._socket),t===1005?n.close():n.close(t,e))}function vc(){let t=this[L];
308
- t.isPaused||t._socket.resume()}function wc(t){let e=this[L];e._socket[L]!==void 0&&(e._socket.removeListener("data",Dt),
309
- process.nextTick(Bo,e._socket),e.close(t[ac])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Lo(){this[L].
310
- emitClose()}function yc(t,e){this[L].emit("message",t,e)}function Ic(t){let e=this[L];e._autoPong&&e.pong(t,!this._isServer,
311
- Fo),e.emit("ping",t)}function Sc(t){this[L].emit("pong",t)}function Bo(t){t.resume()}function xc(t){let e=this[L];e.readyState!==
312
- k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,Ho(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
313
- e.emit("error",t)))}function Ho(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Vo(){
314
- let t=this[L];if(this.removeListener("close",Vo),this.removeListener("data",Dt),this.removeListener("end",Go),t._readyState=
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[L]=void 0,clearTimeout(
299
+ maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(y,t):y.end()}function Ht(t,e){t._readyState=
300
+ j.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function fd(t){return t.path=t.socketPath,ps.connect(t)}function md(t){
301
+ return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=ps.isIP(t.host)?"":t.host),Yc.connect(t)}function Y(t,e,n){
302
+ t._readyState=j.CLOSING;let r=new Error(n);Error.captureStackTrace(r,Y),e.setHeader?(e[ms]=!0,e.abort(),e.socket&&!e.socket.
303
+ destroyed&&e.socket.destroy(),process.nextTick(Ht,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("clo\
304
+ se",t.emitClose.bind(t)))}function Wr(t,e,n){if(e){let r=rd(e)?e.size:ld(e).length;t._socket?t._sender._bufferedBytes+=r:
305
+ t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${de[t.readyState]})`);process.
306
+ nextTick(n,r)}}function hd(t,e){let n=this[B];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[B]!==void 0&&
307
+ (n._socket.removeListener("data",Vt),process.nextTick(gs,n._socket),t===1005?n.close():n.close(t,e))}function gd(){let t=this[B];
308
+ t.isPaused||t._socket.resume()}function vd(t){let e=this[B];e._socket[B]!==void 0&&(e._socket.removeListener("data",Vt),
309
+ process.nextTick(gs,e._socket),e.close(t[id])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function ls(){this[B].
310
+ emitClose()}function wd(t,e){this[B].emit("message",t,e)}function yd(t){let e=this[B];e._autoPong&&e.pong(t,!this._isServer,
311
+ fs),e.emit("ping",t)}function Id(t){this[B].emit("pong",t)}function gs(t){t.resume()}function Sd(t){let e=this[B];e.readyState!==
312
+ j.CLOSED&&(e.readyState===j.OPEN&&(e._readyState=j.CLOSING,vs(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
313
+ e.emit("error",t)))}function vs(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function ws(){
314
+ let t=this[B];if(this.removeListener("close",ws),this.removeListener("data",Vt),this.removeListener("end",ys),t._readyState=
315
+ j.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[B]=void 0,clearTimeout(
317
317
  t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
318
- "error",Lo),t._receiver.on("finish",Lo))}function Dt(t){this[L]._receiver.write(t)||this.pause()}function Go(){let t=this[L];
319
- t._readyState=k.CLOSING,t._receiver.end(),this.end()}function Wo(){let t=this[L];this.removeListener("error",Wo),this.on(
320
- "error",Fo),t&&(t._readyState=k.CLOSING,this.destroy())}});var Zo=$((Nm,Yo)=>{"use strict";var Mm=zt(),{Duplex:Tc}=M("stream");function Jo(t){t.emit("close")}function bc(){!this.destroyed&&
321
- this._writableState.finished&&this.destroy()}function Xo(t){this.removeListener("error",Xo),this.destroy(),this.listenerCount(
322
- "error")===0&&this.emit("error",t)}function _c(t,e){let n=!0,r=new Tc({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
318
+ "error",ls),t._receiver.on("finish",ls))}function Vt(t){this[B]._receiver.write(t)||this.pause()}function ys(){let t=this[B];
319
+ t._readyState=j.CLOSING,t._receiver.end(),this.end()}function Is(){let t=this[B];this.removeListener("error",Is),this.on(
320
+ "error",fs),t&&(t._readyState=j.CLOSING,this.destroy())}});var _s=X((ag,Ts)=>{"use strict";var ig=Gt(),{Duplex:xd}=U("stream");function xs(t){t.emit("close")}function bd(){!this.destroyed&&
321
+ this._writableState.finished&&this.destroy()}function bs(t){this.removeListener("error",bs),this.destroy(),this.listenerCount(
322
+ "error")===0&&this.emit("error",t)}function Td(t,e){let n=!0,r=new xd({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
323
323
  return t.on("message",function(s,i){let a=!i&&r._readableState.objectMode?s.toString():s;r.push(a)||t.pause()}),t.once("\
324
324
  error",function(s){r.destroyed||(n=!1,r.destroy(s))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(o,s){
325
- if(t.readyState===t.CLOSED){s(o),process.nextTick(Jo,r);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
326
- lose",function(){i||s(o),process.nextTick(Jo,r)}),n&&t.terminate()},r._final=function(o){if(t.readyState===t.CONNECTING){
325
+ if(t.readyState===t.CLOSED){s(o),process.nextTick(xs,r);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
326
+ lose",function(){i||s(o),process.nextTick(xs,r)}),n&&t.terminate()},r._final=function(o){if(t.readyState===t.CONNECTING){
327
327
  t.once("open",function(){r._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),r._readableState.
328
328
  endEmitted&&r.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},
329
329
  r._write=function(o,s,i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(o,s,i)});return}t.send(o,i)},
330
- r.on("end",bc),r.on("error",Xo),r}Yo.exports=_c});var jr=$((jm,Qo)=>{"use strict";var{tokenChars:Cc}=Pe();function Ac(t){let e=new Set,n=-1,r=-1,o=0;for(o;o<t.length;o++){
331
- let i=t.charCodeAt(o);if(r===-1&&Cc[i]===1)n===-1&&(n=o);else if(o!==0&&(i===32||i===9))r===-1&&n!==-1&&(r=o);else if(i===
330
+ r.on("end",bd),r.on("error",bs),r}Ts.exports=Td});var Kr=X((cg,Cs)=>{"use strict";var{tokenChars:_d}=ze();function Cd(t){let e=new Set,n=-1,r=-1,o=0;for(o;o<t.length;o++){
331
+ let i=t.charCodeAt(o);if(r===-1&&_d[i]===1)n===-1&&(n=o);else if(o!==0&&(i===32||i===9))r===-1&&n!==-1&&(r=o);else if(i===
332
332
  44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let a=t.slice(n,r);if(e.has(a))throw new SyntaxError(
333
333
  `The "${a}" subprotocol is duplicated`);e.add(a),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
334
334
  if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=t.slice(n,o);if(e.has(s))throw new SyntaxError(
335
- `The "${s}" subprotocol is duplicated`);return e.add(s),e}Qo.exports={parse:Ac}});var is=$((zm,ss)=>{"use strict";var Ec=M("events"),Lt=M("http"),{Duplex:Dm}=M("stream"),{createHash:Oc}=M("crypto"),es=Mt(),
336
- Ie=Re(),Rc=jr(),Pc=zt(),{CLOSE_TIMEOUT:kc,GUID:Mc,kWebSocket:Nc}=te(),jc=/^[+/0-9A-Za-z]{22}==$/,ts=0,rs=1,os=2,Dr=class extends Ec{constructor(e,n){
335
+ `The "${s}" subprotocol is duplicated`);return e.add(s),e}Cs.exports={parse:Cd}});var Ns=X((ug,ks)=>{"use strict";var Ad=U("events"),Wt=U("http"),{Duplex:dg}=U("stream"),{createHash:Ed}=U("crypto"),As=$t(),
336
+ Ce=De(),Od=Kr(),Rd=Gt(),{CLOSE_TIMEOUT:Pd,GUID:kd,kWebSocket:Nd}=ie(),Md=/^[+/0-9A-Za-z]{22}==$/,Es=0,Os=1,Ps=2,Jr=class extends Ad{constructor(e,n){
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:kc,verifyClient:null,
339
- noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Pc,...e},e.port==null&&!e.server&&!e.noServer||
338
+ 1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Pd,verifyClient:null,
339
+ noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Rd,...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=Lt.createServer((r,o)=>{let s=Lt.STATUS_CODES[426];
341
+ , or "noServer" options must be specified');if(e.port!=null?(this._server=Wt.createServer((r,o)=>{let s=Wt.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,n)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=
344
- Dc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
344
+ jd(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,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=
346
- !1),this.options=e,this._state=ts}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===os){e&&this.once("close",()=>{e(new Error(
348
- "The server is not running"))}),process.nextTick(rt,this);return}if(e&&this.once("close",e),this._state!==rs)if(this._state=
349
- rs,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(rt,this):process.nextTick(rt,this);else{let n=this.
351
- _server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{rt(this)})}}shouldHandle(e){if(this.
346
+ !1),this.options=e,this._state=Es}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===Ps){e&&this.once("close",()=>{e(new Error(
348
+ "The server is not running"))}),process.nextTick(ut,this);return}if(e&&this.once("close",e),this._state!==Os)if(this._state=
349
+ Os,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(ut,this):process.nextTick(ut,this);else{let n=this.
351
+ _server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{ut(this)})}}shouldHandle(e){if(this.
352
352
  options.path){let n=e.url.indexOf("?");if((n!==-1?e.url.slice(0,n):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,n,r,o){
353
- n.on("error",ns);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
354
- "GET"){Se(this,e,n,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Se(this,e,n,400,"Inva\
355
- lid Upgrade header");return}if(s===void 0||!jc.test(s)){Se(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}
356
- if(a!==13&&a!==8){Se(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
357
- if(!this.shouldHandle(e)){nt(n,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=Rc.parse(
358
- c)}catch{Se(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],m={};
359
- if(this.options.perMessageDeflate&&p!==void 0){let l=new Ie({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
360
- options.maxPayload});try{let v=es.parse(p);v[Ie.extensionName]&&(l.accept(v[Ie.extensionName]),m[Ie.extensionName]=l)}catch{
361
- Se(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let l={
353
+ n.on("error",Rs);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
354
+ "GET"){Ae(this,e,n,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Ae(this,e,n,400,"Inva\
355
+ lid Upgrade header");return}if(s===void 0||!Md.test(s)){Ae(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}
356
+ if(a!==13&&a!==8){Ae(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
357
+ if(!this.shouldHandle(e)){lt(n,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=Od.parse(
358
+ c)}catch{Ae(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],m={};
359
+ if(this.options.perMessageDeflate&&u!==void 0){let p=new Ce({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
360
+ options.maxPayload});try{let v=As.parse(u);v[Ce.extensionName]&&(p.accept(v[Ce.extensionName]),m[Ce.extensionName]=p)}catch{
361
+ Ae(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={
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(l,(v,x,T,O)=>{if(!v)return nt(n,x||401,T,O);this.completeUpgrade(
364
- m,s,d,e,n,r,o)});return}if(!this.options.verifyClient(l))return nt(n,401)}this.completeUpgrade(m,s,d,e,n,r,o)}completeUpgrade(e,n,r,o,s,i,a){
365
- if(!s.readable||!s.writable)return s.destroy();if(s[Nc])throw new Error("server.handleUpgrade() was called more than onc\
366
- e with the same socket, possibly due to a misconfiguration");if(this._state>ts)return nt(s,503);let d=["HTTP/1.1 101 Swi\
367
- tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Oc("sha1").update(n+Mc).digest("ba\
368
- se64")}`],p=new this.options.WebSocket(null,void 0,this.options);if(r.size){let m=this.options.handleProtocols?this.options.
369
- handleProtocols(r,o):r.values().next().value;m&&(d.push(`Sec-WebSocket-Protocol: ${m}`),p._protocol=m)}if(e[Ie.extensionName]){
370
- let m=e[Ie.extensionName].params,l=es.format({[Ie.extensionName]:[m]});d.push(`Sec-WebSocket-Extensions: ${l}`),p._extensions=
363
+ options.verifyClient.length===2){this.options.verifyClient(p,(v,y,T,O)=>{if(!v)return lt(n,y||401,T,O);this.completeUpgrade(
364
+ m,s,d,e,n,r,o)});return}if(!this.options.verifyClient(p))return lt(n,401)}this.completeUpgrade(m,s,d,e,n,r,o)}completeUpgrade(e,n,r,o,s,i,a){
365
+ if(!s.readable||!s.writable)return s.destroy();if(s[Nd])throw new Error("server.handleUpgrade() was called more than onc\
366
+ e with the same socket, possibly due to a misconfiguration");if(this._state>Es)return lt(s,503);let d=["HTTP/1.1 101 Swi\
367
+ tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ed("sha1").update(n+kd).digest("ba\
368
+ se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let m=this.options.handleProtocols?this.options.
369
+ handleProtocols(r,o):r.values().next().value;m&&(d.push(`Sec-WebSocket-Protocol: ${m}`),u._protocol=m)}if(e[Ce.extensionName]){
370
+ let m=e[Ce.extensionName].params,p=As.format({[Ce.extensionName]:[m]});d.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=
371
371
  e}this.emit("headers",d,o),s.write(d.concat(`\r
372
372
  `).join(`\r
373
- `)),s.removeListener("error",ns),p.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
373
+ `)),s.removeListener("error",Rs),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
- options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on("close",()=>{this.clients.delete(p),this._shouldEmitClose&&
376
- !this.clients.size&&process.nextTick(rt,this)})),a(p,o)}};ss.exports=Dr;function Dc(t,e){for(let n of Object.keys(e))t.on(
377
- n,e[n]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function rt(t){t._state=os,t.emit("close")}
378
- function ns(){this.destroy()}function nt(t,e,n,r){n=n||Lt.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/htm\
379
- l","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Lt.STATUS_CODES[e]}\r
375
+ options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&
376
+ !this.clients.size&&process.nextTick(ut,this)})),a(u,o)}};ks.exports=Jr;function jd(t,e){for(let n of Object.keys(e))t.on(
377
+ n,e[n]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function ut(t){t._state=Ps,t.emit("close")}
378
+ function Rs(){this.destroy()}function lt(t,e,n,r){n=n||Wt.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/htm\
379
+ l","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Wt.STATUS_CODES[e]}\r
380
380
  `+Object.keys(r).map(o=>`${o}: ${r[o]}`).join(`\r
381
381
  `)+`\r
382
382
  \r
383
- `+n)}function Se(t,e,n,r,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,Se),t.emit(
384
- "wsClientError",i,n,e)}else nt(n,r,o,s)}});function I(t){return String(t??"").trim()}function yt(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||
385
- e===null}var Vp=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function C(t,{fallback:e=""}={}){return String(t||"").trim()||e}function A(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function V(t,{fallback:e=0}={}){let n=Number(t);return!Number.isInteger(n)||n<1?e:n}var Wp=Object.freeze({interrupted:Object.freeze({text:"Stopped.",messageCode:"assistant.turn.stopped"}),failed:Object.freeze(
386
- {text:"Assistant stopped with an error.",messageCode:"assistant.turn.failed"})});function It(t){return A(t)?{...t}:{}}var N=class extends Error{constructor(e,n,r={}){super(n,r.cause===void 0?void 0:{cause:r.cause}),this.name="AppError",this.
387
- status=Number(e)||500,this.statusCode=this.status,this.code=r.code||"APP_ERROR",this.params=It(r.params),r.messageCode&&
388
- (this.messageCode=String(r.messageCode),this.messageParams=It(r.messageParams)),this.details=r.details,this.headers=r.headers||
389
- {}}};var Tf=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
390
- "truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var F=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
391
- INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),Rf=new Set(Object.values(F)),Pf=new Set([F.CANCELLED,
392
- F.COMPLETED,F.FAILED,F.INTERRUPTED,F.TIMED_OUT]),kf=new Set([F.ACTIVE,F.FINALIZING,F.STARTING]);import{execFile as oa}from"node:child_process";import{readFile as fr,readdir as sa}from"node:fs/promises";import{setTimeout as eo}from"node:timers/promises";import{promisify as ia}from"node:util";var aa=ia(oa);async function ca(t){
393
- let{stdout:e}=await aa("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function Tt({runtimeTokenEnvironmentName:t="\
383
+ `+n)}function Ae(t,e,n,r,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,Ae),t.emit(
384
+ "wsClientError",i,n,e)}else lt(n,r,o,s)}});function b(t){return String(t??"").trim()}function At(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||
385
+ e===null}var ym=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function w(t,{fallback:e=""}={}){return String(t||"").trim()||e}function ne(t,{fallback:e=""}={}){return w(t,{fallback:e}).toLowerCase()}function K(t,{fallback:e={}}={}){return x(t)?t:{...e}}function x(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function V(t,{fallback:e=0}={}){let n=Number(t);return!Number.isInteger(n)||n<1?e:n}function Et(t,{fallback:e=null}={}){return t==null?e:typeof t=="string"?t.trim()||e:typeof t=="number"?Number.isFinite(t)?
386
+ String(t):e:typeof t=="bigint"?String(t):e}var Sm=Object.freeze({interrupted:Object.freeze({text:"Stopped.",messageCode:"assistant.turn.stopped"}),failed:Object.freeze(
387
+ {text:"Assistant stopped with an error.",messageCode:"assistant.turn.failed"})});function Ot(t){return x(t)?{...t}:{}}var F=class extends Error{constructor(e,n,r={}){super(n,r.cause===void 0?void 0:{cause:r.cause}),this.name="AppError",this.
388
+ status=Number(e)||500,this.statusCode=this.status,this.code=r.code||"APP_ERROR",this.params=Ot(r.params),r.messageCode&&
389
+ (this.messageCode=String(r.messageCode),this.messageParams=Ot(r.messageParams)),this.details=r.details,this.headers=r.headers||
390
+ {}}};var Xm=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
391
+ "truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var G=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
392
+ INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),nh=new Set(Object.values(G)),oh=new Set([G.CANCELLED,
393
+ G.COMPLETED,G.FAILED,G.INTERRUPTED,G.TIMED_OUT]),sh=new Set([G.ACTIVE,G.FINALIZING,G.STARTING]);import{execFile as nc}from"node:child_process";import{readFile as Cr,readdir as oc}from"node:fs/promises";import{setTimeout as Ao}from"node:timers/promises";import{promisify as sc}from"node:util";var ic=sc(nc),Eo=32;async function ac(t){
394
+ let{stdout:e}=await ic("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function kt({runtimeTokenEnvironmentName:t="\
394
395
  JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION_COMMAND_HASH",label:n="Native",unavailableCode:r="\
395
- native_process_identity_unavailable",platform:o=process.platform,ps:s=ca}={}){let a=o==="darwin"?100:25,c=1,d=Object.freeze(
396
- {linux:"linux-proc",darwin:"darwin"}),p=d[o]||"",m=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),l=Object.freeze(
397
- {ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});function v(w={}){return!!(Number.
398
- isSafeInteger(Number(w.pid))&&Number(w.pid)>0&&D(w.processIdentity)&&[m.RUNNING,m.STOPPED].includes(w.processState))}function x(w){
399
- let u=Number(w);if(!Number.isSafeInteger(u)||u<=0)return!1;try{return process.kill(u,0),!0}catch{return!1}}function T(w){
400
- let u=Number(w);if(!Number.isSafeInteger(u)||u<=0)return!1;if(process.platform==="win32")return x(u);try{return process.
401
- kill(-u,0),!0}catch{return!1}}function O(w,u){let f=Number(w),h=process.platform==="win32"?f:-f;try{return process.kill(
402
- h,u),!0}catch(g){if(!["ESRCH","EPERM"].includes(String(g?.code||"")))throw g;return!1}}function P(w=""){let u=String(w||
403
- ""),f=u.lastIndexOf(")");if(f<0)return null;let h=u.slice(f+1).trim().split(/\s+/u),g=String(h[0]||""),y=Number(h[1]),S=Number(
404
- h[2]),b=String(h[19]||"");return!/^[A-Z]$/u.test(g)||!Number.isSafeInteger(y)||y<0||!Number.isSafeInteger(S)||S<=0||!/^\d+$/u.
405
- test(b)?null:{parentPid:y,processGroupId:S,startTimeTicks:b,state:g}}function j(w={}){let u=A(w)?w:{};return{commandHash:I(
406
- u.commandHash),platform:I(u.platform),runtimeToken:I(u.runtimeToken),startTimeTicks:I(u.startTimeTicks),version:Number(u.
407
- version||0)}}function D(w={}){let u=j(w);return!!(u.version===c&&Object.values(d).includes(u.platform)&&/^[a-f0-9]{12}$/u.
408
- test(u.commandHash)&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(u.runtimeToken)&&/^\d+$/u.
409
- test(u.startTimeTicks))}function U(w=[],u=""){let f=w.find(h=>h.startsWith(`${u}=`));return f?f.slice(u.length+1):""}async function J(){
410
- let w=[],u=await sa("/proc",{withFileTypes:!0}).catch(()=>[]);for(let f of u){if(!f.isDirectory()||!/^\d+$/u.test(f.name))
411
- continue;let h=Number(f.name),g=await fr(`/proc/${f.name}/stat`,"utf8").catch(()=>""),y=P(g);if(!y||y.state==="Z")continue;
412
- let S=null,b=!0;try{S=await fr(`/proc/${f.name}/environ`)}catch(E){if(String(E?.code||"")==="ENOENT")continue;b=!1}let R=b?
413
- S.toString("utf8").split("\0"):[];w.push({...y,commandHash:U(R,e),environmentReadable:b,pid:h,runtimeToken:U(R,t)})}return w}
414
- let H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function q(w=""){let u=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.
415
- exec(String(w).trim()),f=u?H.indexOf(u[1]):-1;if(f<0)return"";let[,,h,g,y,S,b]=u.map(Number);return String(Date.UTC(b,f,
416
- h,g,y,S)/1e3)}function ae(w=""){let u=new Map;for(let f of String(w).split(`
417
- `)){let h=/^\s*(\d+) (.*)$/u.exec(f);h&&u.set(Number(h[1]),h[2])}return u}function me(w,u){if(w===void 0||!u?.startsWith(
418
- w))return null;let f=u.slice(w.length).split(/\s+/u).filter(h=>/^[^=\s]+=/u.test(h));return f.length?f:null}async function We(){
419
- let w=process.getuid(),u=["-x","-U",String(w),"-ww","-o","pid=,command="],[f,h,g]=await Promise.all([s(["-ax","-o","pid=\
420
- ,pgid=,uid=,stat=,lstart="]),s(u),s(["-E",...u])]),y=ae(h),S=ae(g),b=[];for(let R of String(f).split(`
421
- `)){let E=/^\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(R);if(!E||E[4].startsWith(
422
- "Z"))continue;let X=Number(E[1]),Y=Number(E[3])===w?me(y.get(X),S.get(X)):null;b.push({commandHash:U(Y||[],e),environmentReadable:!!Y,
423
- pid:X,processGroupId:Number(E[2]),runtimeToken:U(Y||[],t),startTimeTicks:q(E[5])})}return b}function ht(w){let u=Object.
424
- values(l).includes(w?.status)?w.status:l.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(w?.processGroupIds)?
425
- w.processGroupIds:[]).map(Number).filter(f=>Number.isSafeInteger(f)&&f>0))],status:u}}async function gt(w={}){if(!v(w))return{
426
- processGroupIds:[],status:l.INVALID};if(w.processState===m.STOPPED)return{processGroupIds:[],status:l.ABSENT};let u=w.processIdentity,
427
- f=u.platform!==p?null:o==="darwin"?await We().catch(()=>null):await J();if(!f)return{processGroupIds:[],status:l.AMBIGUOUS};
428
- let h=Number(w.pid),g=f.filter(({processGroupId:E})=>E===h),y=[],S=g.some(({environmentReadable:E})=>!E);for(let E of f)
429
- E.environmentReadable&&E.runtimeToken===u.runtimeToken&&E.commandHash===u.commandHash&&y.push(E);let b=y.find(({pid:E})=>E===
430
- h);if(b&&b.startTimeTicks!==u.startTimeTicks)return{processGroupIds:[],status:l.AMBIGUOUS};if(y.length===0)return S?{processGroupIds:[],
431
- status:l.AMBIGUOUS}:{processGroupIds:[],status:g.length>0||T(h)?l.MISMATCH:l.ABSENT};let R=[...new Set(y.map(({processGroupId:E})=>E))];
432
- for(let E of R)if(f.filter(Y=>Y.processGroupId===E).some(Y=>!Y.environmentReadable||!y.some(({pid:Xi})=>Xi===Y.pid)))return{
433
- processGroupIds:[],status:l.AMBIGUOUS};return g.some(E=>!y.some(({pid:X})=>X===E.pid))?{processGroupIds:[],status:l.AMBIGUOUS}:
434
- {processGroupIds:R,status:l.EXACT}}async function he(w={},u={}){let f=u.processIdentityInspector??gt;return ht(await f(w))}
435
- async function vt(w={},u={},f=0){let h=Date.now()+f,g=await he(w,u);for(;Date.now()<h&&g.status===l.EXACT;)await eo(100),
436
- g=await he(w,u);return g}async function Ce(w={},u={}){let f=V(u.processIdentitySettleTimeoutMs,{fallback:1e3}),h=V(u.processIdentitySettlePollMs,
437
- {fallback:a}),g=Date.now()+f,y=await he(w,u);for(;y.status===l.AMBIGUOUS&&Date.now()<g;)await eo(Math.min(h,Math.max(1,g-
438
- Date.now()))),y=await he(w,u);return y}async function wt(w={},u="SIGTERM",f={}){let h=f.signalProcessGroup??O,g=await Ce(
439
- w,f);if(g.status!==l.EXACT)return{inspection:g,signaledProcessGroups:[]};let y=Number(w.pid),S=[...g.processGroupIds.filter(
440
- R=>R!==y),...g.processGroupIds.filter(R=>R===y)],b=[];for(let R of S){let E=await Ce(w,f);if(E.status===l.ABSENT||E.status===
441
- l.MISMATCH)return{inspection:E,signaledProcessGroups:b};if(E.status!==l.EXACT)return{inspection:E,signaledProcessGroups:b};
442
- E.processGroupIds.includes(R)&&(h(R,u),b.push(R))}return{inspection:await Ce(w,f),signaledProcessGroups:b}}async function ar(w={},u={}){
443
- if(!v(w))return{identityStatus:l.INVALID,processExitVerified:!1,stopped:!1};if(w.processState===m.STOPPED&&w.processExitVerifiedAt)
444
- return{alreadyStopped:!0,identityStatus:l.ABSENT,processExitVerified:!0,stopped:!1};let f=await Ce(w,u);if(f.status===l.
445
- ABSENT||f.status===l.MISMATCH)return{identityStatus:f.status,processExitVerified:!0,stopped:!1};if(f.status!==l.EXACT)return{
446
- identityStatus:f.status,processExitVerified:!1,stopped:!1};let h=await wt(w,"SIGTERM",u);if(h.inspection.status===l.AMBIGUOUS)
447
- return{identityStatus:h.inspection.status,processExitVerified:!1,signaledProcessGroups:h.signaledProcessGroups,stopped:!1};
448
- let g=await vt(w,u,V(u.termTimeoutMs,{fallback:3e3})),y=[...h.signaledProcessGroups];if(g.status===l.EXACT){let b=await wt(
449
- w,"SIGKILL",u);if(y=[...new Set([...y,...b.signaledProcessGroups])],b.inspection.status===l.AMBIGUOUS)return{identityStatus:b.
450
- inspection.status,processExitVerified:!1,signaledProcessGroups:y,stopped:!1};g=await vt(w,u,V(u.killTimeoutMs,{fallback:1e3}))}
451
- let S=[l.ABSENT,l.MISMATCH].includes(g.status);return{descendantProcessGroups:y.filter(b=>b!==Number(w.pid)),identityStatus:g.
452
- status,pid:Number(w.pid),processExitVerified:S,signaledProcessGroups:y,stopped:S&&y.length>0}}async function cr(w){if(o!==
453
- "darwin")return P(await fr(`/proc/${w}/stat`,"utf8").catch(()=>""));let u=String(await s(["-o","pgid=,lstart=","-p",String(
454
- w)]).catch(()=>"")),f=/^\s*(\d+)\s+(.+?)\s*$/u.exec(u);return f?{processGroupId:Number(f[1]),startTimeTicks:q(f[2])}:null}
455
- async function dr({commandHash:w="",pid:u=null,reportedIdentity:f=null,runtimeToken:h=""}={}){let g=I(w),y=I(h),S=j(f);if(D(
456
- S)&&S.commandHash===g&&S.runtimeToken===y)return S;let b=Number(u),R=p&&Number.isSafeInteger(b)&&b>0?await cr(b):null;if(!R?.
457
- startTimeTicks||R.processGroupId!==b){let E=new Error(`${n} process identity could not be captured.`);throw E.code=r,E}return{
458
- commandHash:g,platform:p,runtimeToken:y,startTimeTicks:R.startTimeTicks,version:c}}return Object.freeze({normalize:j,isValid:D,
459
- normalizeInspection:ht,capture:dr,inspect:he,stop:ar,isProcessAlive:x})}import{execFile as ua}from"node:child_process";import{promisify as la}from"node:util";var Kf=Object.freeze(["plugins","apps","daemon_auto_start"]);var Jf=Object.freeze([[".tmp",/^(?:plugins(?:$|[.-])|git-|bundled-marketplaces$)/u],["cache",/^(?:remote_plugin_catalog|codex_apps_tools|codex_apps_server_info|codex_app_directory|bundled_plugin_exclusions)$/u]]);var tm=la(ua);function ge(t=""){return Array.from(String(t)).some(e=>{let n=e.codePointAt(0);return n<=31||n===127})}var bt=(t,e,n,r={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(n),...r}),pa=Object.freeze([Object.freeze(
396
+ native_process_identity_unavailable",platform:o=process.platform,ps:s=ac}={}){let a=o==="darwin"?100:25,c=1,d=Object.freeze(
397
+ {linux:"linux-proc",darwin:"darwin"}),u=d[o]||"",m=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),p=Object.freeze(
398
+ {ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});function v(l={}){return!!(Number.
399
+ isSafeInteger(Number(l.pid))&&Number(l.pid)>0&&L(l.processIdentity)&&[m.RUNNING,m.STOPPED].includes(l.processState))}function y(l){
400
+ let f=Number(l);if(!Number.isSafeInteger(f)||f<=0)return!1;try{return process.kill(f,0),!0}catch{return!1}}function T(l){
401
+ let f=Number(l);if(!Number.isSafeInteger(f)||f<=0)return!1;if(process.platform==="win32")return y(f);try{return process.
402
+ kill(-f,0),!0}catch{return!1}}function O(l,f){let h=Number(l),g=process.platform==="win32"?h:-h;try{return process.kill(
403
+ g,f),!0}catch(I){if(!["ESRCH","EPERM"].includes(String(I?.code||"")))throw I;return!1}}function N(l=""){let f=String(l||
404
+ ""),h=f.lastIndexOf(")");if(h<0)return null;let g=f.slice(h+1).trim().split(/\s+/u),I=String(g[0]||""),S=Number(g[1]),C=Number(
405
+ g[2]),k=String(g[19]||"");return!/^[A-Z]$/u.test(I)||!Number.isSafeInteger(S)||S<0||!Number.isSafeInteger(C)||C<=0||!/^\d+$/u.
406
+ test(k)?null:{parentPid:S,processGroupId:C,startTimeTicks:k,state:I}}function z(l={}){let f=x(l)?l:{};return{commandHash:b(
407
+ f.commandHash),platform:b(f.platform),runtimeToken:b(f.runtimeToken),startTimeTicks:b(f.startTimeTicks),version:Number(f.
408
+ version||0)}}function L(l={}){let f=z(l);return!!(f.version===c&&Object.values(d).includes(f.platform)&&/^[a-f0-9]{12}$/u.
409
+ test(f.commandHash)&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(f.runtimeToken)&&/^\d+$/u.
410
+ test(f.startTimeTicks))}function q(l=[],f=""){let h=l.find(g=>g.startsWith(`${f}=`));return h?h.slice(f.length+1):""}async function H(l){
411
+ let f=await Cr(`/proc/${l}/stat`,"utf8").catch(()=>""),h=N(f);if(!h||h.state==="Z")return null;let g=null,I=!0;try{g=await Cr(
412
+ `/proc/${l}/environ`)}catch(C){if(String(C?.code||"")==="ENOENT")return null;I=!1}let S=I?g.toString("utf8").split("\0"):
413
+ [];return{...h,commandHash:q(S,e),environmentReadable:I,pid:Number(l),runtimeToken:q(S,t)}}async function R(){let l=(await oc(
414
+ "/proc",{withFileTypes:!0}).catch(()=>[])).filter(h=>h.isDirectory()&&/^\d+$/u.test(h.name)).map(h=>h.name),f=[];for(let h=0;h<
415
+ l.length;h+=Eo)for(let g of await Promise.all(l.slice(h,h+Eo).map(H)))g&&f.push(g);return f}let P=["Jan","Feb","Mar","Ap\
416
+ r","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(l=""){let f=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.
417
+ exec(String(l).trim()),h=f?P.indexOf(f[1]):-1;if(h<0)return"";let[,,g,I,S,C,k]=f.map(Number);return String(Date.UTC(k,h,
418
+ g,I,S,C)/1e3)}function M(l=""){let f=new Map;for(let h of String(l).split(`
419
+ `)){let g=/^\s*(\d+) (.*)$/u.exec(h);g&&f.set(Number(g[1]),g[2])}return f}function W(l,f){if(l===void 0||!f?.startsWith(
420
+ l))return null;let h=f.slice(l.length).split(/\s+/u).filter(g=>/^[^=\s]+=/u.test(g));return h.length?h:null}async function Ie(){
421
+ let l=process.getuid(),f=["-x","-U",String(l),"-ww","-o","pid=,command="],[h,g,I]=await Promise.all([s(["-ax","-o","pid=\
422
+ ,pgid=,uid=,stat=,lstart="]),s(f),s(["-E",...f])]),S=M(g),C=M(I),k=[];for(let D of String(h).split(`
423
+ `)){let E=/^\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(D);if(!E||E[4].startsWith(
424
+ "Z"))continue;let se=Number(E[1]),pe=Number(E[3])===l?W(S.get(se),C.get(se)):null;k.push({commandHash:q(pe||[],e),environmentReadable:!!pe,
425
+ pid:se,processGroupId:Number(E[2]),runtimeToken:q(pe||[],t),startTimeTicks:A(E[5])})}return k}function tt(l){let f=Object.
426
+ values(p).includes(l?.status)?l.status:p.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(l?.processGroupIds)?
427
+ l.processGroupIds:[]).map(Number).filter(h=>Number.isSafeInteger(h)&&h>0))],status:f}}async function yr(l={}){if(!v(l))return{
428
+ processGroupIds:[],status:p.INVALID};if(l.processState===m.STOPPED)return{processGroupIds:[],status:p.ABSENT};let f=l.processIdentity,
429
+ h=f.platform!==u?null:o==="darwin"?await Ie().catch(()=>null):await R();if(!h)return{processGroupIds:[],status:p.AMBIGUOUS};
430
+ let g=Number(l.pid),I=h.filter(({processGroupId:E})=>E===g),S=[],C=I.some(({environmentReadable:E})=>!E);for(let E of h)
431
+ E.environmentReadable&&E.runtimeToken===f.runtimeToken&&E.commandHash===f.commandHash&&S.push(E);let k=S.find(({pid:E})=>E===
432
+ g);if(k&&k.startTimeTicks!==f.startTimeTicks)return{processGroupIds:[],status:p.AMBIGUOUS};if(S.length===0)return C?{processGroupIds:[],
433
+ status:p.AMBIGUOUS}:{processGroupIds:[],status:I.length>0||T(g)?p.MISMATCH:p.ABSENT};let D=[...new Set(S.map(({processGroupId:E})=>E))];
434
+ for(let E of D)if(h.filter(pe=>pe.processGroupId===E).some(pe=>!pe.environmentReadable||!S.some(({pid:Ja})=>Ja===pe.pid)))
435
+ return{processGroupIds:[],status:p.AMBIGUOUS};return I.some(E=>!S.some(({pid:se})=>se===E.pid))?{processGroupIds:[],status:p.
436
+ AMBIGUOUS}:{processGroupIds:D,status:p.EXACT}}async function Se(l={},f={}){let h=f.processIdentityInspector??yr;return tt(
437
+ await h(l))}async function _t(l={},f={},h=0){let g=Date.now()+h,I=await Se(l,f);for(;Date.now()<g&&I.status===p.EXACT;)await Ao(
438
+ 100),I=await Se(l,f);return I}async function ke(l={},f={}){let h=V(f.processIdentitySettleTimeoutMs,{fallback:1e3}),g=V(
439
+ f.processIdentitySettlePollMs,{fallback:a}),I=Date.now()+h,S=await Se(l,f);for(;S.status===p.AMBIGUOUS&&Date.now()<I;)await Ao(
440
+ Math.min(g,Math.max(1,I-Date.now()))),S=await Se(l,f);return S}async function Ct(l={},f="SIGTERM",h={}){let g=h.signalProcessGroup??
441
+ O,I=await ke(l,h);if(I.status!==p.EXACT)return{inspection:I,signaledProcessGroups:[]};let S=Number(l.pid),C=[...I.processGroupIds.
442
+ filter(D=>D!==S),...I.processGroupIds.filter(D=>D===S)],k=[];for(let D of C){let E=await ke(l,h);if(E.status===p.ABSENT||
443
+ E.status===p.MISMATCH)return{inspection:E,signaledProcessGroups:k};if(E.status!==p.EXACT)return{inspection:E,signaledProcessGroups:k};
444
+ E.processGroupIds.includes(D)&&(g(D,f),k.push(D))}return{inspection:await ke(l,h),signaledProcessGroups:k}}async function Ir(l={},f={}){
445
+ if(!v(l))return{identityStatus:p.INVALID,processExitVerified:!1,stopped:!1};if(l.processState===m.STOPPED&&l.processExitVerifiedAt)
446
+ return{alreadyStopped:!0,identityStatus:p.ABSENT,processExitVerified:!0,stopped:!1};let h=await ke(l,f);if(h.status===p.
447
+ ABSENT||h.status===p.MISMATCH)return{identityStatus:h.status,processExitVerified:!0,stopped:!1};if(h.status!==p.EXACT)return{
448
+ identityStatus:h.status,processExitVerified:!1,stopped:!1};let g=await Ct(l,"SIGTERM",f);if(g.inspection.status===p.AMBIGUOUS)
449
+ return{identityStatus:g.inspection.status,processExitVerified:!1,signaledProcessGroups:g.signaledProcessGroups,stopped:!1};
450
+ let I=await _t(l,f,V(f.termTimeoutMs,{fallback:3e3})),S=[...g.signaledProcessGroups];if(I.status===p.EXACT){let k=await Ct(
451
+ l,"SIGKILL",f);if(S=[...new Set([...S,...k.signaledProcessGroups])],k.inspection.status===p.AMBIGUOUS)return{identityStatus:k.
452
+ inspection.status,processExitVerified:!1,signaledProcessGroups:S,stopped:!1};I=await _t(l,f,V(f.killTimeoutMs,{fallback:1e3}))}
453
+ let C=[p.ABSENT,p.MISMATCH].includes(I.status);return{descendantProcessGroups:S.filter(k=>k!==Number(l.pid)),identityStatus:I.
454
+ status,pid:Number(l.pid),processExitVerified:C,signaledProcessGroups:S,stopped:C&&S.length>0}}async function Sr(l){if(o!==
455
+ "darwin")return N(await Cr(`/proc/${l}/stat`,"utf8").catch(()=>""));let f=String(await s(["-o","pgid=,lstart=","-p",String(
456
+ l)]).catch(()=>"")),h=/^\s*(\d+)\s+(.+?)\s*$/u.exec(f);return h?{processGroupId:Number(h[1]),startTimeTicks:A(h[2])}:null}
457
+ async function xr({commandHash:l="",pid:f=null,reportedIdentity:h=null,runtimeToken:g=""}={}){let I=b(l),S=b(g),C=z(h);if(L(
458
+ C)&&C.commandHash===I&&C.runtimeToken===S)return C;let k=Number(f),D=u&&Number.isSafeInteger(k)&&k>0?await Sr(k):null;if(!D?.
459
+ startTimeTicks||D.processGroupId!==k){let E=new Error(`${n} process identity could not be captured.`);throw E.code=r,E}return{
460
+ commandHash:I,platform:u,runtimeToken:S,startTimeTicks:D.startTimeTicks,version:c}}return Object.freeze({normalize:z,isValid:L,
461
+ normalizeInspection:tt,capture:xr,inspect:Se,stop:Ir,isProcessAlive:y})}import{execFile as dc}from"node:child_process";import{promisify as uc}from"node:util";var Sh=Object.freeze(["plugins","apps","daemon_auto_start"]);var xh=Object.freeze([[".tmp",/^(?:plugins(?:$|[.-])|git-|bundled-marketplaces$)/u],["cache",/^(?:remote_plugin_catalog|codex_apps_tools|codex_apps_server_info|codex_app_directory|bundled_plugin_exclusions)$/u]]);var Eh=uc(dc);function xe(t=""){return Array.from(String(t)).some(e=>{let n=e.codePointAt(0);return n<=31||n===127})}var Nt=(t,e,n,r={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(n),...r}),lc=Object.freeze([Object.freeze(
460
462
  {id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
461
- webSearch:!1,models:Object.freeze([bt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
462
- bt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai-\
463
+ webSearch:!1,models:Object.freeze([Nt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
464
+ Nt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai-\
463
465
  coding-plan",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
464
- webSearch:!1,models:Object.freeze([bt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),
466
+ webSearch:!1,models:Object.freeze([Nt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),
465
467
  Object.freeze({id:"zai",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
466
- webSearch:!1,models:Object.freeze([bt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function Je(t){return pa.find(e=>e.id===t)||null}var am=32*1024*1024,cm=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
467
- deepseek:Je("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":Je("zai-coding-plan").baseUrl,zai:Je("zai").baseUrl});var mr=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),wm=Tt();var hr=Object.freeze({UNIX:"unix"});var ma=process.platform==="linux"?107:103,to=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
468
- UNREACHABLE:"unreachable"}),ha=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
469
- SUSPECT:"suspect"}),Xe=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),ro=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
470
- ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var ga=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
471
- commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var zc=ce(Zo(),1),Lc=ce(Mt(),1),Uc=ce(Re(),1),Fc=ce(Cr(),1),qc=ce(Or(),1),$c=ce(jr(),1),Bc=ce(zt(),1),Hc=ce(is(),1);var Lg=32*1024,Ug=2*1024*1024;var Gt=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
472
- av=new Set(Object.values(Gt)),cv=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
468
+ webSearch:!1,models:Object.freeze([Nt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function nt(t){return lc.find(e=>e.id===t)||null}var Mh=32*1024*1024,jh=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
469
+ deepseek:nt("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":nt("zai-coding-plan").baseUrl,zai:nt("zai").baseUrl});var Ar=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),Vh=kt();var Er=Object.freeze({UNIX:"unix"});var fc=process.platform==="linux"?107:103,Oo=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
470
+ UNREACHABLE:"unreachable"}),mc=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
471
+ SUSPECT:"suspect"}),ot=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),Ro=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
472
+ ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var hc=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
473
+ commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var Dd=fe(_s(),1),zd=fe($t(),1),Ld=fe(De(),1),Ud=fe(Ur(),1),Fd=fe($r(),1),qd=fe(Kr(),1),$d=fe(Gt(),1),Bd=fe(Ns(),1);var lw=32*1024,pw=2*1024*1024;var tr=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
474
+ Mw=new Set(Object.values(tr)),jw=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
473
475
  jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
474
- dv=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),uv=Object.freeze(["accountIde\
476
+ Dw=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),zw=Object.freeze(["accountIde\
475
477
  ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
476
- Hash","terminalEnvHash","toolHomeSource","transport"]),lv=Object.freeze(["userAgent"]);import hd from"node:path";var gd=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
478
+ Hash","terminalEnvHash","toolHomeSource","transport"]),Lw=Object.freeze(["userAgent"]);import mu from"node:path";var hu=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
477
479
  code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
478
480
  "in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
479
481
  ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
480
- "unified_exec_zsh_fork","view_image"]);function _s(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.
481
- values(t))_s(e);return Object.freeze(t)}function vd(t="",e={}){let n=new Error(I(t)||"Codex cannot prove the helper exec\
482
+ "unified_exec_zsh_fork","view_image"]);function Zs(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.
483
+ values(t))Zs(e);return Object.freeze(t)}function gu(t="",e={}){let n=new Error(b(t)||"Codex cannot prove the helper exec\
482
484
  ution policy.");n.code="codex_policy_unenforceable",n.details=Object.freeze({...e});for(let[r,o]of Object.entries(n.details))
483
- ["code","details","message","name"].includes(r)||(n[r]=o);return n}function wd({clientName:t="jskit",minimumVersion:e="0\
484
- .151.0",disabledFeatures:n=gd,limits:{userAgentMaxLength:r=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
485
- 1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:p=256*1024,hookResponseMaxBytes:m=512*
486
- 1024}={},createError:l=vd}={}){let v=new WeakSet;function x(u,f,h){let g=0;try{g=Buffer.byteLength(JSON.stringify(u),"ut\
487
- f8")}catch{throw l(`Codex helper execution received an invalid ${h}.`)}if(g>f)throw l(`Codex helper execution received a\
488
- n oversized ${h}.`)}function T(u){if(typeof u?.currentConnectionGeneration!="function")throw l("Codex helper execution c\
489
- annot verify the app-server connection generation.");let f=u.currentConnectionGeneration();if(!Number.isSafeInteger(f)||
490
- f<=0)throw l("Codex helper execution found no active app-server connection.");return f}async function O(u){if(typeof u?.
491
- currentHelperExecutionContext!="function")throw l("Codex helper execution requires its dedicated isolated provider.");let f=await u.
492
- currentHelperExecutionContext(),h=I(f?.cwd),g=I(f?.accountIdentitySignature);if(f?.executionMode!=="helper"||!h||!hd.isAbsolute(
493
- h)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw l("Codex helper runtime isolation could not be verified.");return Object.freeze(
494
- {accountIdentitySignature:g,cwd:h,executionMode:"helper"})}function P(u=""){let f=I(u).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
495
- if(!f)return null;let h=f.slice(1).map(g=>Number.parseInt(g,10));return h.every(Number.isSafeInteger)?h:null}function j(u=""){
496
- let f=I(u);if(!f||f.length>r||ge(f))return null;let h=`${t}/`;if(!f.startsWith(h))return null;let g=f.slice(h.length).match(
497
- /^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?P(g[1]):null}function D(u){if(typeof u?.currentServerInfo!=
498
- "function")throw l("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
499
- let f=I(u.currentServerInfo()?.userAgent),h=j(f);if(!h)throw l("Codex helper execution received an unrecognised app-serv\
500
- er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),y=P(e),S=h.findIndex((b,R)=>b!==y[R]);if(S!==
501
- -1&&h[S]<y[S])throw l(`Codex helper execution requires app-server ${e} or newer; current version is ${g}. Update Codex a\
502
- nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function U(u=null){if(!yt(
503
- u?.config))throw l("Codex helper execution could not read the effective app-server configuration.");let f=u.config.mcp_servers;
504
- if(f==null)return[];if(x(f,i,"MCP configuration"),!yt(f))throw l("Codex helper execution received an invalid MCP server \
505
- configuration.");let h=Object.keys(f);if(h.length>o||h.some(g=>!g||g.length>s||ge(g)))throw l("Codex helper execution re\
506
- ceived an oversized or invalid MCP server inventory.");return h.sort()}function J(u=null,f=""){if(x(u,m,"hook inventory"),
507
- !Array.isArray(u?.data))throw l("Codex helper execution could not enumerate app-server hooks.");if(u.data.length!==1)throw l(
508
- "Codex helper execution received an unexpected hook inventory.");let h=u.data[0];if(I(h?.cwd)!==f||I(h?.cwd).length>d||!Array.
509
- isArray(h.hooks)||!Array.isArray(h.errors)||h.hooks.length>a||h.errors.length>c)throw l("Codex helper execution received\
510
- an incomplete hook inventory.");if(h.errors.length>0)throw l("Codex helper execution cannot continue while hook discove\
511
- ry has errors.",{hookErrorCount:h.errors.length});let g=h.hooks.map(S=>{let b=I(S?.key),R=I(S?.currentHash),E=I(S?.handlerType),
512
- X=I(S?.sourcePath);if(!b||[b,R,E,X].some(Y=>Y.length>d||ge(Y)))throw l("Codex helper execution found an invalid hook inv\
513
- entory entry.");if(S?.isManaged===!0&&S?.enabled===!0)throw l("Codex helper execution cannot disable a managed hook.");return{
514
- currentHash:R,enabled:S?.enabled===!0,handlerType:E,isManaged:S?.isManaged===!0,key:b,sourcePath:X}}).sort((S,b)=>S.key.
515
- localeCompare(b.key)),y=JSON.stringify(g);if(y.length>p)throw l("Codex helper execution received an oversized hook inven\
516
- tory.");return{fingerprint:y,hookKeys:g.filter(S=>!S.isManaged).map(S=>S.key)}}function H({effort:u="",summary:f="",hookKeys:h=[],
517
- mcpServerNames:g=[]}={}){let y={features:Object.fromEntries(n.map(b=>[b,!1])),hooks:{state:Object.fromEntries(h.map(b=>[
518
- b,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
519
- include_permissions_instructions:!1,...u?{model_reasoning_effort:u}:{},...f?{model_reasoning_summary:f}:{},mcp_servers:Object.
520
- fromEntries(g.map(b=>[b,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
485
+ ["code","details","message","name"].includes(r)||(n[r]=o);return n}function vu({clientName:t="jskit",minimumVersion:e="0\
486
+ .151.0",disabledFeatures:n=hu,limits:{userAgentMaxLength:r=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
487
+ 1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:m=512*
488
+ 1024}={},createError:p=gu}={}){let v=new WeakSet;function y(l,f,h){let g=0;try{g=Buffer.byteLength(JSON.stringify(l),"ut\
489
+ f8")}catch{throw p(`Codex helper execution received an invalid ${h}.`)}if(g>f)throw p(`Codex helper execution received a\
490
+ n oversized ${h}.`)}function T(l){if(typeof l?.currentConnectionGeneration!="function")throw p("Codex helper execution c\
491
+ annot verify the app-server connection generation.");let f=l.currentConnectionGeneration();if(!Number.isSafeInteger(f)||
492
+ f<=0)throw p("Codex helper execution found no active app-server connection.");return f}async function O(l){if(typeof l?.
493
+ currentHelperExecutionContext!="function")throw p("Codex helper execution requires its dedicated isolated provider.");let f=await l.
494
+ currentHelperExecutionContext(),h=b(f?.cwd),g=b(f?.accountIdentitySignature);if(f?.executionMode!=="helper"||!h||!mu.isAbsolute(
495
+ h)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw p("Codex helper runtime isolation could not be verified.");return Object.freeze(
496
+ {accountIdentitySignature:g,cwd:h,executionMode:"helper"})}function N(l=""){let f=b(l).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
497
+ if(!f)return null;let h=f.slice(1).map(g=>Number.parseInt(g,10));return h.every(Number.isSafeInteger)?h:null}function z(l=""){
498
+ let f=b(l);if(!f||f.length>r||xe(f))return null;let h=`${t}/`;if(!f.startsWith(h))return null;let g=f.slice(h.length).match(
499
+ /^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?N(g[1]):null}function L(l){if(typeof l?.currentServerInfo!=
500
+ "function")throw p("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
501
+ let f=b(l.currentServerInfo()?.userAgent),h=z(f);if(!h)throw p("Codex helper execution received an unrecognised app-serv\
502
+ er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),I=N(e),S=h.findIndex((C,k)=>C!==I[k]);if(S!==
503
+ -1&&h[S]<I[S])throw p(`Codex helper execution requires app-server ${e} or newer; current version is ${g}. Update Codex a\
504
+ nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function q(l=null){if(!At(
505
+ l?.config))throw p("Codex helper execution could not read the effective app-server configuration.");let f=l.config.mcp_servers;
506
+ if(f==null)return[];if(y(f,i,"MCP configuration"),!At(f))throw p("Codex helper execution received an invalid MCP server \
507
+ configuration.");let h=Object.keys(f);if(h.length>o||h.some(g=>!g||g.length>s||xe(g)))throw p("Codex helper execution re\
508
+ ceived an oversized or invalid MCP server inventory.");return h.sort()}function H(l=null,f=""){if(y(l,m,"hook inventory"),
509
+ !Array.isArray(l?.data))throw p("Codex helper execution could not enumerate app-server hooks.");if(l.data.length!==1)throw p(
510
+ "Codex helper execution received an unexpected hook inventory.");let h=l.data[0];if(b(h?.cwd)!==f||b(h?.cwd).length>d||!Array.
511
+ isArray(h.hooks)||!Array.isArray(h.errors)||h.hooks.length>a||h.errors.length>c)throw p("Codex helper execution received\
512
+ an incomplete hook inventory.");if(h.errors.length>0)throw p("Codex helper execution cannot continue while hook discove\
513
+ ry has errors.",{hookErrorCount:h.errors.length});let g=h.hooks.map(S=>{let C=b(S?.key),k=b(S?.currentHash),D=b(S?.handlerType),
514
+ E=b(S?.sourcePath);if(!C||[C,k,D,E].some(se=>se.length>d||xe(se)))throw p("Codex helper execution found an invalid hook \
515
+ inventory entry.");if(S?.isManaged===!0&&S?.enabled===!0)throw p("Codex helper execution cannot disable a managed hook.");
516
+ return{currentHash:k,enabled:S?.enabled===!0,handlerType:D,isManaged:S?.isManaged===!0,key:C,sourcePath:E}}).sort((S,C)=>S.
517
+ key.localeCompare(C.key)),I=JSON.stringify(g);if(I.length>u)throw p("Codex helper execution received an oversized hook i\
518
+ nventory.");return{fingerprint:I,hookKeys:g.filter(S=>!S.isManaged).map(S=>S.key)}}function R({effort:l="",summary:f="",
519
+ hookKeys:h=[],mcpServerNames:g=[]}={}){let I={features:Object.fromEntries(n.map(C=>[C,!1])),hooks:{state:Object.fromEntries(
520
+ h.map(C=>[C,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
521
+ include_permissions_instructions:!1,...l?{model_reasoning_effort:l}:{},...f?{model_reasoning_summary:f}:{},mcp_servers:Object.
522
+ fromEntries(g.map(C=>[C,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
521
523
  mcp:{enabled:!1},skills:{enabled:!1}},project_doc_max_bytes:0,shell_environment_policy:{inherit:"none",set:{}},skills:{include_instructions:!1},
522
- tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},S=_s(y);return v.add(
523
- S),S}function q(u,f,h,{effort:g="",summary:y=""}={}){let S=U(u),b=J(f,h);return{mcpServerNames:S,hookState:b,config:H({effort:g,
524
- summary:y,hookKeys:b.hookKeys,mcpServerNames:S})}}async function ae(u,{effort:f="",summary:h=""}={}){if(D(u),typeof u?.readConfig!=
525
- "function"||typeof u?.listHooks!="function")throw l("Codex helper execution cannot inventory configuration and hooks.");
526
- let g=await O(u),y=T(u),S=await u.readConfig({cwd:g.cwd,includeLayers:!1});if(T(u)!==y)throw l("Codex app-server reconne\
527
- cted during helper policy verification.");let b=await u.listHooks([g.cwd]);if(T(u)!==y)throw l("Codex app-server reconne\
528
- cted during helper policy verification.");let{mcpServerNames:R,hookState:E,config:X}=q(S,b,g.cwd,{effort:f,summary:h});return Object.
529
- freeze({accountIdentitySignature:g.accountIdentitySignature,config:X,connectionGeneration:y,executionCwd:g.cwd,hookFingerprint:E.
530
- fingerprint,hookKeys:Object.freeze([...E.hookKeys]),mcpServerNames:Object.freeze([...R])})}function me(u=null,f=null){return u?.
531
- accountIdentitySignature===f?.accountIdentitySignature&&u?.connectionGeneration===f?.connectionGeneration&&u?.executionCwd===
532
- f?.executionCwd&&u?.hookFingerprint===f?.hookFingerprint&&JSON.stringify(u?.mcpServerNames||[])===JSON.stringify(f?.mcpServerNames||
533
- [])}function We(u,f,h=""){let g=I(h);if(!f)return u.codexAppServerHelperThreadId=g,u.codexAppServerHelperThreadRetired=!0,
534
- u;let y=l("Codex could not retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return y.
535
- codexAppServerHelperThreadCleanupRequired=!0,y.codexAppServerHelperThreadId=g,y}async function ht({error:u=null,provider:f=null,
536
- threadId:h=""}={}){let g=null;try{await f.deleteThread(h)}catch(y){g=y}throw We(u,g,h)}async function gt(u,f,h,g,y){try{
537
- let S=await ae(u,{effort:f.config.model_reasoning_effort,summary:f.config.model_reasoning_summary});if(!me(f,S))throw l(
538
- `Codex execution surfaces changed while the helper thread was ${y}.`);return Object.freeze({enforcement:S,thread:h,threadId:g})}catch(S){
539
- await ht({error:S,provider:u,threadId:g})}}async function he(u,f){if(typeof u?.startThread!="function"||typeof u?.deleteThread!=
540
- "function")throw l("Codex helper execution cannot own and clean up its app-server thread.");let h=await f(),g=await u.startThread(
541
- h.settings),y=I(g?.id);if(!y)throw l("Codex app-server did not return a helper thread id.");return gt(u,h.enforcement,g,
542
- y,"starting")}async function vt(u,f,h){if(typeof u?.resumeThread!="function"||typeof u?.deleteThread!="function")throw l(
543
- "Codex helper execution cannot safely resume and clean up its app-server thread.");let g=I(f);if(!g)throw l("Codex helpe\
544
- r resume requires a controller-owned thread id.");let y=await h(),S=y.enforcement,b=await u.resumeThread(g,y.settings);return gt(
545
- u,S,b,g,"resuming")}function Ce(u){return v.has(u)}function wt({configResult:u,hookResult:f,workdir:h,effort:g="",summary:y=""}){
546
- return q(u,f,h,{effort:g,summary:y}).config}function ar({approvalPolicy:u,baseInstructions:f,config:h,cwd:g,effectiveSettings:y,
547
- sandbox:S,systemPrompt:b}){return{allowProviderModelFallback:!1,approvalPolicy:u,baseInstructions:f,config:h,cwd:g,systemPrompt:b||
548
- null,dynamicTools:[],environments:[],model:y.model,runtimeWorkspaceRoots:[],sandbox:S,selectedCapabilityRoots:[]}}function cr(u,f){
549
- return{...u,sessionStartSource:"startup",threadSource:f}}function dr(u){return{approvalPolicy:u.approvalPolicy,baseInstructions:u.
550
- baseInstructions,config:u.config,cwd:u.cwd,systemPrompt:u.systemPrompt,model:u.model,runtimeWorkspaceRoots:u.runtimeWorkspaceRoots,
551
- sandbox:u.sandbox}}function w({approvalPolicy:u,cwd:f,effectiveSettings:h,outputSchema:g}){let y={approvalPolicy:u,cwd:f,
524
+ tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},S=Zs(I);return v.add(
525
+ S),S}function P(l,f,h,{effort:g="",summary:I=""}={}){let S=q(l),C=H(f,h);return{mcpServerNames:S,hookState:C,config:R({effort:g,
526
+ summary:I,hookKeys:C.hookKeys,mcpServerNames:S})}}async function A(l,{effort:f="",summary:h=""}={}){if(L(l),typeof l?.readConfig!=
527
+ "function"||typeof l?.listHooks!="function")throw p("Codex helper execution cannot inventory configuration and hooks.");
528
+ let g=await O(l),I=T(l),S=await l.readConfig({cwd:g.cwd,includeLayers:!1});if(T(l)!==I)throw p("Codex app-server reconne\
529
+ cted during helper policy verification.");let C=await l.listHooks([g.cwd]);if(T(l)!==I)throw p("Codex app-server reconne\
530
+ cted during helper policy verification.");let{mcpServerNames:k,hookState:D,config:E}=P(S,C,g.cwd,{effort:f,summary:h});return Object.
531
+ freeze({accountIdentitySignature:g.accountIdentitySignature,config:E,connectionGeneration:I,executionCwd:g.cwd,hookFingerprint:D.
532
+ fingerprint,hookKeys:Object.freeze([...D.hookKeys]),mcpServerNames:Object.freeze([...k])})}function M(l=null,f=null){return l?.
533
+ accountIdentitySignature===f?.accountIdentitySignature&&l?.connectionGeneration===f?.connectionGeneration&&l?.executionCwd===
534
+ f?.executionCwd&&l?.hookFingerprint===f?.hookFingerprint&&JSON.stringify(l?.mcpServerNames||[])===JSON.stringify(f?.mcpServerNames||
535
+ [])}function W(l,f,h=""){let g=b(h);if(!f)return l.codexAppServerHelperThreadId=g,l.codexAppServerHelperThreadRetired=!0,
536
+ l;let I=p("Codex could not retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return I.
537
+ codexAppServerHelperThreadCleanupRequired=!0,I.codexAppServerHelperThreadId=g,I}async function Ie({error:l=null,provider:f=null,
538
+ threadId:h=""}={}){let g=null;try{await f.deleteThread(h)}catch(I){g=I}throw W(l,g,h)}async function tt(l,f,h,g,I){try{let S=await A(
539
+ l,{effort:f.config.model_reasoning_effort,summary:f.config.model_reasoning_summary});if(!M(f,S))throw p(`Codex execution\
540
+ surfaces changed while the helper thread was ${I}.`);return Object.freeze({enforcement:S,thread:h,threadId:g})}catch(S){
541
+ await Ie({error:S,provider:l,threadId:g})}}async function yr(l,f){if(typeof l?.startThread!="function"||typeof l?.deleteThread!=
542
+ "function")throw p("Codex helper execution cannot own and clean up its app-server thread.");let h=await f(),g=await l.startThread(
543
+ h.settings),I=b(g?.id);if(!I)throw p("Codex app-server did not return a helper thread id.");return tt(l,h.enforcement,g,
544
+ I,"starting")}async function Se(l,f,h){if(typeof l?.resumeThread!="function"||typeof l?.deleteThread!="function")throw p(
545
+ "Codex helper execution cannot safely resume and clean up its app-server thread.");let g=b(f);if(!g)throw p("Codex helpe\
546
+ r resume requires a controller-owned thread id.");let I=await h(),S=I.enforcement,C=await l.resumeThread(g,I.settings);return tt(
547
+ l,S,C,g,"resuming")}function _t(l){return v.has(l)}function ke({configResult:l,hookResult:f,workdir:h,effort:g="",summary:I=""}){
548
+ return P(l,f,h,{effort:g,summary:I}).config}function Ct({approvalPolicy:l,baseInstructions:f,config:h,cwd:g,effectiveSettings:I,
549
+ sandbox:S,systemPrompt:C}){return{allowProviderModelFallback:!1,approvalPolicy:l,baseInstructions:f,config:h,cwd:g,systemPrompt:C||
550
+ null,dynamicTools:[],environments:[],model:I.model,runtimeWorkspaceRoots:[],sandbox:S,selectedCapabilityRoots:[]}}function Ir(l,f){
551
+ return{...l,sessionStartSource:"startup",threadSource:f}}function Sr(l){return{approvalPolicy:l.approvalPolicy,baseInstructions:l.
552
+ baseInstructions,config:l.config,cwd:l.cwd,systemPrompt:l.systemPrompt,model:l.model,runtimeWorkspaceRoots:l.runtimeWorkspaceRoots,
553
+ sandbox:l.sandbox}}function xr({approvalPolicy:l,cwd:f,effectiveSettings:h,outputSchema:g}){let I={approvalPolicy:l,cwd:f,
552
554
  environments:[],model:h.model,outputSchema:g,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
553
- none"};return h.request.reasoning&&(y.effort=h.thinking),y}return Object.freeze({assertCompatibility:D,executionContext:O,
554
- inspect:ae,configuration:wt,hasConfiguration:Ce,threadSettings:ar,threadStartSettings:cr,threadResumeSettings:dr,turnSettings:w,
555
- start:he,resume:vt})}var Nv=wd();var rI=Object.freeze({PROVIDER_FAILURE:"provider_failure",RESPONSE_DELIVERY_FAILURE:"response_delivery_failure",SERVICE_RESTART:"\
555
+ none"};return h.request.reasoning&&(I.effort=h.thinking),I}return Object.freeze({assertCompatibility:L,executionContext:O,
556
+ inspect:A,configuration:ke,hasConfiguration:_t,threadSettings:Ct,threadStartSettings:Ir,threadResumeSettings:Sr,turnSettings:xr,
557
+ start:yr,resume:Se})}var ay=vu();var OS=Object.freeze({PROVIDER_FAILURE:"provider_failure",RESPONSE_DELIVERY_FAILURE:"response_delivery_failure",SERVICE_RESTART:"\
556
558
  service_restart",USER_CANCELLED:"user_cancelled",CONTROL_RECONFIGURATION:"control_reconfiguration",INTERRUPTED:"interrup\
557
- ted"});var vI=Number.MAX_SAFE_INTEGER;var zd=(Number(process.env.AGENT_REPLY_MINUTES)||15)*60*1e3;function en(t){return{stoppedShort:`(Check from ${t}: your reply ended by saying what you'd do next, and then stopped, s\
559
+ ted"});var HS=Number.MAX_SAFE_INTEGER;var Du=(Number(process.env.AGENT_REPLY_MINUTES)||15)*60*1e3;function mn(t){return{stoppedShort:`(Check from ${t}: your reply ended by saying what you'd do next, and then stopped, s\
558
560
  o the person is left waiting. Carry on now with your tools and finish the job, then reply with the result. If you can't,\
559
561
  say plainly why.)`,markup:`(Check from ${t}: your last message contained raw markup, such as a tool call written out as\
560
562
  text or special tokens, so nothing in it ran and the person can't read it. Carry on now: call the tools properly to do \
561
563
  what's left, then reply in plain words.)`,unsupported:e=>`(Check from ${t}: your reply says ${e.map(n=>`"${n}"`).join(",\
562
564
  ")}, but no tool in this reply did that, so it hasn't happened. Do it now with the right tool, or answer again without \
563
565
  saying it's done.)`,resumed:"(This reply was interrupted part-way, when the server running it stopped. Your steps so far\
564
- are above and what they did stays done. Carry on from where you got to, without redoing them, and finish the job.)"}}var UI=["You check an assistant's reply against a record of what its tools did while writing that reply.","List each sta\
566
+ are above and what they did stays done. Carry on from where you got to, without redoing them, and finish the job.)"}}var px=["You check an assistant's reply against a record of what its tools did while writing that reply.","List each sta\
565
567
  tement in the reply that says something was done in this reply (made, saved, sent, attached, added, changed, deleted, bo\
566
568
  oked, set up, fixed, run, tested) that the record doesn't support.","A claim is supported if a tool call and its answer \
567
569
  in the record show it happened. Ignore plans, offers, questions, advice, facts about the person, things said to have hap\
568
570
  pened earlier in the conversation, and descriptions of what a file or app contains.",'Reply with JSON only: {"unsupporte\
569
571
  d": ["short quote of each unsupported claim"]}, with [] when every claim is supported.'].join(`
570
- `);var lS=64*1024;var Qd="the app",wS=en(Qd);var IS=16*1024*1024;function z(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
571
- eu(e)}function eu(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function on(t){return t!==null&&typeof t=="object"&&z(t.structure)&&z(t.operations)&&typeof t.validateWith=="function"&&
572
- typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Wt(t,e){if(!Object.hasOwn(e,"items"))return null;
573
- let{items:n}=e;if(on(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
574
- " must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function dt(t,e){
575
- if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(on(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!=
572
+ `);var Lx=64*1024;var Zu="the app",Vx=mn(Zu);var Wx=16*1024*1024;function $(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
573
+ Qu(e)}function Qu(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function wn(t){return t!==null&&typeof t=="object"&&$(t.structure)&&$(t.operations)&&typeof t.validateWith=="function"&&
574
+ typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function rr(t,e){if(!Object.hasOwn(e,"items"))return null;
575
+ let{items:n}=e;if(wn(n))return{kind:"schema",schema:n};if(!$(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
576
+ " must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function vt(t,e){
577
+ if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(wn(n))return{kind:"schema",schema:n};if(!$(n)||typeof n.type!=
576
578
  "string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
577
- t.`);return{kind:"definition",definition:n}}function Kt(t,e){let n=Object.hasOwn(e,"schema"),r=Object.hasOwn(e,"values"),
579
+ t.`);return{kind:"definition",definition:n}}function nr(t,e){let n=Object.hasOwn(e,"schema"),r=Object.hasOwn(e,"values"),
578
580
  o=Object.hasOwn(e,"additionalProperties");if(n&&r)throw new Error(`Object field "${t}" cannot define both schema and val\
579
581
  ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
580
582
  if(r&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
581
- s: true.`);if(n){if(!on(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
582
- kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:dt(
583
- t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ue(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}function sn(t,e=""){
584
- if(z(t))for(let[n,r]of Object.entries(t)){if(!z(r))continue;let o=e?`${e}.${n}`:n;for(let s of["minItems","maxItems"]){if(!Object.
583
+ s: true.`);if(n){if(!wn(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
584
+ kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:vt(
585
+ t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ve(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}function yn(t,e=""){
586
+ if($(t))for(let[n,r]of Object.entries(t)){if(!$(r))continue;let o=e?`${e}.${n}`:n;for(let s of["minItems","maxItems"]){if(!Object.
585
587
  hasOwn(r,s))continue;let i=r[s];if(r.type!=="array"||!Number.isInteger(i)||i<0)throw new Error(`Field "${o}" ${s} must b\
586
588
  e a non-negative integer on an array field.`)}if(r.minItems>r.maxItems)throw new Error(`Field "${o}" minItems (${r.minItems}\
587
- ) is above its maxItems (${r.maxItems}).`);r.type==="array"&&z(r.items)&&typeof r.items.type=="string"&&sn({"[]":r.items},
588
- o)}}var an="^(?:0|-?[1-9]\\d*)$",Ms="\\d{4}",Ns="0[1-9]|1[0-2]",js="0[1-9]|[12]\\d|3[01]",Ds="[01]\\d|2[0-3]",Fe="[0-5]\\d",
589
- Jt=`(?:${Ds}):${Fe}`,zs=`(?:Z|[+-](?:${Ds}):${Fe})`,Ls=`(${Ms})-(${Ns})-(${js})`,Us=`${Ms}-(?:${Ns})-(?:${js})`,Fs=`^${Us}\
590
- $`,tu=new RegExp(`^${Ls}$`),ru=new RegExp(`^${Jt}(?::${Fe}(?:\\.(\\d+))?)?$`),nu=new RegExp(`^${Ls}T${Jt}:${Fe}(?:\\.(\\d+\
591
- ))?${zs}$`),ou=new RegExp(an),su=[31,28,31,30,31,30,31,31,30,31,30,31];function iu(t){return t%4===0&&(t%100!==0||t%400===
592
- 0)}function au(t,e){return e===2?iu(t)?29:28:su[e-1]}function qs(t,e,n){let r=Number(t),o=Number(e),s=Number(n);return o>=
593
- 1&&o<=12&&s>=1&&s<=au(r,o)}function ut(t,e){let n=t.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(
594
- `temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function $s(t,e){return t===void 0?!0:e===void 0||
595
- t.length<=e}function Bs(t){if(typeof t!="string")return!1;let e=tu.exec(t);return e!==null&&qs(e[1],e[2],e[3])}function Hs(t,e){
596
- if(typeof t!="string")return!1;let n=ru.exec(t);return n!==null&&$s(n[1],e)}function Vs(t,e){if(typeof t!="string")return!1;
597
- let n=nu.exec(t);return n===null?!1:qs(n[1],n[2],n[3])&&$s(n[4],e)}function Gs(t){return t===void 0?"(?:\\.\\d+)?":t===0?
598
- "":`(?:\\.\\d{1,${t}})?`}function Ws(t,e){let n=ut(t,e);return`^${Jt}(?::${Fe}${Gs(n)})?$`}function Ks(t,e){let n=ut(t,e);
599
- return`^${Us}T${Jt}:${Fe}${Gs(n)}${zs}$`}function cn(t,e){let n;if(typeof t=="number")n=t;else if(typeof t=="string"&&ou.
600
- test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var cu=new Set(["__proto__","prototype","constructor"]);function _(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0})}function du(t,e){if(cu.
601
- has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function uu(t){return typeof t!="string"?t:t.replace(
602
- /\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function dn(t,e,{normalize:n=!1,allowEmpty:r=!1}={}){
603
- let o=n?uu(t):t;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${e}() expects a non-empty \
589
+ ) is above its maxItems (${r.maxItems}).`);r.type==="array"&&$(r.items)&&typeof r.items.type=="string"&&yn({"[]":r.items},
590
+ o)}}var In="^(?:0|-?[1-9]\\d*)$",ii="\\d{4}",ai="0[1-9]|1[0-2]",ci="0[1-9]|[12]\\d|3[01]",di="[01]\\d|2[0-3]",Ge="[0-5]\\d",
591
+ or=`(?:${di}):${Ge}`,ui=`(?:Z|[+-](?:${di}):${Ge})`,li=`(${ii})-(${ai})-(${ci})`,pi=`${ii}-(?:${ai})-(?:${ci})`,fi=`^${pi}\
592
+ $`,el=new RegExp(`^${li}$`),tl=new RegExp(`^${or}(?::${Ge}(?:\\.(\\d+))?)?$`),rl=new RegExp(`^${li}T${or}:${Ge}(?:\\.(\\d+\
593
+ ))?${ui}$`),nl=new RegExp(In),ol=[31,28,31,30,31,30,31,31,30,31,30,31];function sl(t){return t%4===0&&(t%100!==0||t%400===
594
+ 0)}function il(t,e){return e===2?sl(t)?29:28:ol[e-1]}function mi(t,e,n){let r=Number(t),o=Number(e),s=Number(n);return o>=
595
+ 1&&o<=12&&s>=1&&s<=il(r,o)}function wt(t,e){let n=t.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(
596
+ `temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function hi(t,e){return t===void 0?!0:e===void 0||
597
+ t.length<=e}function gi(t){if(typeof t!="string")return!1;let e=el.exec(t);return e!==null&&mi(e[1],e[2],e[3])}function vi(t,e){
598
+ if(typeof t!="string")return!1;let n=tl.exec(t);return n!==null&&hi(n[1],e)}function wi(t,e){if(typeof t!="string")return!1;
599
+ let n=rl.exec(t);return n===null?!1:mi(n[1],n[2],n[3])&&hi(n[4],e)}function yi(t){return t===void 0?"(?:\\.\\d+)?":t===0?
600
+ "":`(?:\\.\\d{1,${t}})?`}function Ii(t,e){let n=wt(t,e);return`^${or}(?::${Ge}${yi(n)})?$`}function Si(t,e){let n=wt(t,e);
601
+ return`^${pi}T${or}:${Ge}${yi(n)}${ui}$`}function Sn(t,e){let n;if(typeof t=="number")n=t;else if(typeof t=="string"&&nl.
602
+ test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var al=new Set(["__proto__","prototype","constructor"]);function _(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0})}function cl(t,e){if(al.
603
+ has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function dl(t){return typeof t!="string"?t:t.replace(
604
+ /\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function xn(t,e,{normalize:n=!1,allowEmpty:r=!1}={}){
605
+ let o=n?dl(t):t;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${e}() expects a non-empty \
604
606
  dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
605
- for(let i of s)du(i,e);return s}var lu="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",un=["object","array","string","number","boolean"],
606
- ln=Symbol("json-rest-schema.exportContext"),pu=["true","1","yes","y","on"],fu=["false","0","no","n","off"];function Js(t){
607
- return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:an}]}}function Te(t,e){return{[fe]:{[t]:e}}}var mu={
608
- none:()=>({type:un}),blob:()=>({type:un}),serialize:()=>({type:un}),object:()=>({type:"object"}),array:()=>({type:"array"}),
607
+ for(let i of s)cl(i,e);return s}var ul="http://json-schema.org/draft-07/schema#",we="x-json-rest-schema",bn=["object","array","string","number","boolean"],
608
+ Tn=Symbol("json-rest-schema.exportContext"),ll=["true","1","yes","y","on"],pl=["false","0","no","n","off"];function xi(t){
609
+ return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:In}]}}function Oe(t,e){return{[we]:{[t]:e}}}var fl={
610
+ none:()=>({type:bn}),blob:()=>({type:bn}),serialize:()=>({type:bn}),object:()=>({type:"object"}),array:()=>({type:"array"}),
609
611
  file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
610
- eger","string"]}),epochMilliseconds:()=>Js(864e13),epochSeconds:()=>Js(864e10),dateTime:({definition:t,fieldName:e})=>({
611
- type:"string",format:"date-time",pattern:Ks(t,e)}),date:()=>({type:"string",format:"date",pattern:Fs}),time:({definition:t,
612
- fieldName:e})=>({type:"string",pattern:Ws(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
613
- let e=new Set([...pu,String(t.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...fu,String(t.stringFalseWhen||
612
+ eger","string"]}),epochMilliseconds:()=>xi(864e13),epochSeconds:()=>xi(864e10),dateTime:({definition:t,fieldName:e})=>({
613
+ type:"string",format:"date-time",pattern:Si(t,e)}),date:()=>({type:"string",format:"date",pattern:fi}),time:({definition:t,
614
+ fieldName:e})=>({type:"string",pattern:Ii(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
615
+ let e=new Set([...ll,String(t.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...pl,String(t.stringFalseWhen||
614
616
  "false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...n,...e]}]}},
615
- id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},hu={minLength:({definition:t,parameterValue:e})=>t.
617
+ id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},ml={minLength:({definition:t,parameterValue:e})=>t.
616
618
  type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
617
- definition:t,parameterValue:e})=>Ue(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ue(t)?{maximum:e}:null,pattern:({
619
+ definition:t,parameterValue:e})=>Ve(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ve(t)?{maximum:e}:null,pattern:({
618
620
  definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
619
621
  enum:t}),minItems:({definition:t,parameterValue:e})=>t.type==="array"?{minItems:e}:null,maxItems:({definition:t,parameterValue:e})=>t.
620
622
  type==="array"?{maxItems:e}:null,notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({
621
- parameterValue:t})=>t?Te("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Te("transforms",{lowercase:!0}):
622
- null,length:({parameterValue:t})=>Te("transforms",{length:t}),unsigned:({parameterValue:t})=>t?Te("metadata",{unsigned:!0}):
623
- null,precision:({parameterValue:t})=>Te("metadata",{precision:t}),scale:({parameterValue:t})=>Te("metadata",{scale:t}),temporalPrecision:({
624
- parameterValue:t})=>Te("metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
625
- defaultTo:()=>null};function hn(t,e){for(let n of Object.keys(e)){let r=e[n],o=t[n];if(r&&o&&typeof r=="object"&&typeof o==
626
- "object"&&!Array.isArray(r)&&!Array.isArray(o)){hn(o,r);continue}t[n]=r}}function gu(t,e){if(!e||typeof e!="object"||Array.
623
+ parameterValue:t})=>t?Oe("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Oe("transforms",{lowercase:!0}):
624
+ null,length:({parameterValue:t})=>Oe("transforms",{length:t}),unsigned:({parameterValue:t})=>t?Oe("metadata",{unsigned:!0}):
625
+ null,precision:({parameterValue:t})=>Oe("metadata",{precision:t}),scale:({parameterValue:t})=>Oe("metadata",{scale:t}),temporalPrecision:({
626
+ parameterValue:t})=>Oe("metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
627
+ defaultTo:()=>null};function En(t,e){for(let n of Object.keys(e)){let r=e[n],o=t[n];if(r&&o&&typeof r=="object"&&typeof o==
628
+ "object"&&!Array.isArray(r)&&!Array.isArray(o)){En(o,r);continue}t[n]=r}}function hl(t,e){if(!e||typeof e!="object"||Array.
627
629
  isArray(e))throw new Error("JSON Schema export hooks must return an object or null.");for(let n of Object.keys(e)){if(n===
628
- fe&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){hn(t[n],e[n]);continue}
629
- t[n]=e[n]}}function vu(t,e){let r=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return r.length===
630
- 1?t:{anyOf:r}}function wu(t,e){if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);
631
- let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=mu[e.type];if(!r)throw new Error(
632
- `Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function yu(t,e,n){if(!Object.
633
- hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=hu[e];
630
+ we&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){En(t[n],e[n]);continue}
631
+ t[n]=e[n]}}function gl(t,e){let r=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return r.length===
632
+ 1?t:{anyOf:r}}function vl(t,e){if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);
633
+ let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=fl[e.type];if(!r)throw new Error(
634
+ `Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function wl(t,e,n){if(!Object.
635
+ hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=ml[e];
634
636
  if(o)return o;throw new Error(`Validator '${e}' on field '${n}' cannot be exported to JSON Schema without a toJsonSchema\
635
- hook.`)}function Xs(t){if(t===void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(
636
- `Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function Iu(t,e={}){if(e.mode!==
637
- void 0&&e.operation!==void 0){let n=Xs(e.mode);if(n!==e.operation)throw new Error(`Conflicting JSON Schema export option\
637
+ hook.`)}function bi(t){if(t===void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(
638
+ `Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function yl(t,e={}){if(e.mode!==
639
+ void 0&&e.operation!==void 0){let n=bi(e.mode);if(n!==e.operation)throw new Error(`Conflicting JSON Schema export option\
638
640
  s: mode '${n}' does not match operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))
639
- throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return Xs(e.mode)}function Su(t,e={}){
641
+ throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return bi(e.mode)}function Il(t,e={}){
640
642
  if(e.operationName!==void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};
641
- let n=Iu(t,e);return{operationName:n,operation:t.operations[n]}}function xu(t={}){let e={...t};return Object.defineProperty(
642
- e,ln,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function Yt(t={}){return t[ln]?
643
- t[ln]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function Tu(t){return String(t).replace(/[^a-zA-Z0-9]+/g,
644
- "_").replace(/^_+|_+$/g,"")||"operation"}function pn(t){return z(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}
645
- function Xt(t){return pn(t)?{allOf:[t]}:t}function bu(t,e,n,r,o){return t.nodes.find(s=>s.schema===e&&s.operationName===
646
- n&&s.operation===r&&s.additionalProperties===o)||null}function _u(t,e){let n=Tu(e),r=`SchemaNode_${t.nextDefinitionId}_${n}`;
647
- return t.nextDefinitionId+=1,r}function Ys(t,e,n,r,o,{root:s=!1}={}){let i=Yt(e),a=bu(i,t,n,r,o);if(a)return s&&(a.pointer=
643
+ let n=yl(t,e);return{operationName:n,operation:t.operations[n]}}function Sl(t={}){let e={...t};return Object.defineProperty(
644
+ e,Tn,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function ir(t={}){return t[Tn]?
645
+ t[Tn]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function xl(t){return String(t).replace(/[^a-zA-Z0-9]+/g,
646
+ "_").replace(/^_+|_+$/g,"")||"operation"}function _n(t){return $(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}
647
+ function sr(t){return _n(t)?{allOf:[t]}:t}function bl(t,e,n,r,o){return t.nodes.find(s=>s.schema===e&&s.operationName===
648
+ n&&s.operation===r&&s.additionalProperties===o)||null}function Tl(t,e){let n=xl(e),r=`SchemaNode_${t.nextDefinitionId}_${n}`;
649
+ return t.nextDefinitionId+=1,r}function Ti(t,e,n,r,o,{root:s=!1}={}){let i=ir(e),a=bl(i,t,n,r,o);if(a)return s&&(a.pointer=
648
650
  "#",i.rootNode=a),a;let c={schema:t,operationName:n,operation:r,additionalProperties:o,status:"new",definitionName:s?null:
649
- _u(i,n),pointer:s?"#":null};return s?i.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function Zs(t,e){
650
- if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=Yt(e);t.status="build\
651
- ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=Cu(t.schema,e,t.operationName,t.operation,t.additionalProperties);
652
- return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function gn(t,e,n,r,o=!1){
653
- let s=Yt(e),i=Ys(t,e,n,r,o);return s.rootNode===i?{$ref:"#"}:Zs(i,e)}function lt(t,{referenceBacked:e=!1}={}){return{schema:t,
654
- referenceBacked:e}}function Cu(t,e,n,r,o=!1){let s={},i=[];for(let[c,d]of Object.entries(t.structure))_(s,c,vn(t,c,d,e,n,
651
+ Tl(i,n),pointer:s?"#":null};return s?i.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function _i(t,e){
652
+ if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=ir(e);t.status="build\
653
+ ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=_l(t.schema,e,t.operationName,t.operation,t.additionalProperties);
654
+ return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function On(t,e,n,r,o=!1){
655
+ let s=ir(e),i=Ti(t,e,n,r,o);return s.rootNode===i?{$ref:"#"}:_i(i,e)}function yt(t,{referenceBacked:e=!1}={}){return{schema:t,
656
+ referenceBacked:e}}function _l(t,e,n,r,o=!1){let s={},i=[];for(let[c,d]of Object.entries(t.structure))_(s,c,Rn(t,c,d,e,n,
655
657
  r)),r.enforceRequired&&d.required===!0&&i.push(c);let a={type:"object",properties:s,additionalProperties:o};return i.length>
656
- 0&&(a.required=i),a}function Au(t,e,n,r,o,s){let i=Wt(e,n);if(!i)return null;if(i.kind==="schema")return{...Xt(gn(i.schema,
657
- r,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
658
- "schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return vn(t,`${e}[]`,n.items,r,a,c)}function Eu(t,e,n,r,o,s){
659
- let i=dt(e,n);if(!i)return null;if(i.kind==="schema")return{...Xt(gn(i.schema,r,"replace",i.schema.operations.replace,!1)),
660
- [fe]:{castType:"object"}};let a=i.definition.type==="object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="re\
661
- place"?t.operations.replace:s;return vn(t,`${e}.*`,i.definition,r,a,c)}function Ou(t,e,n,r,o,s){if(n.type==="object"){let a=Kt(
662
- e,n);if(a.kind==="nested")return lt(gn(a.schema,r,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
663
- "opaque")return lt({type:"object",additionalProperties:!0});if(a.kind==="map")return lt({type:"object",additionalProperties:Eu(
664
- t,e,n,r,o,s)})}let i=wu(t,n)({schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r});if(!i||typeof i!="object"||
658
+ 0&&(a.required=i),a}function Cl(t,e,n,r,o,s){let i=rr(e,n);if(!i)return null;if(i.kind==="schema")return{...sr(On(i.schema,
659
+ r,"replace",i.schema.operations.replace,!1)),[we]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
660
+ "schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return Rn(t,`${e}[]`,n.items,r,a,c)}function Al(t,e,n,r,o,s){
661
+ let i=vt(e,n);if(!i)return null;if(i.kind==="schema")return{...sr(On(i.schema,r,"replace",i.schema.operations.replace,!1)),
662
+ [we]:{castType:"object"}};let a=i.definition.type==="object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="re\
663
+ place"?t.operations.replace:s;return Rn(t,`${e}.*`,i.definition,r,a,c)}function El(t,e,n,r,o,s){if(n.type==="object"){let a=nr(
664
+ e,n);if(a.kind==="nested")return yt(On(a.schema,r,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
665
+ "opaque")return yt({type:"object",additionalProperties:!0});if(a.kind==="map")return yt({type:"object",additionalProperties:Al(
666
+ t,e,n,r,o,s)})}let i=vl(t,n)({schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r});if(!i||typeof i!="object"||
665
667
  Array.isArray(i))throw new Error(`Type '${n.type}' on field '${e}' returned an invalid JSON Schema fragment.`);if(n.type===
666
- "array"){let a=Au(t,e,n,r,o,s);if(a)return lt({...i,items:a},{referenceBacked:pn(i)})}return lt(i,{referenceBacked:pn(i)})}
667
- function vn(t,e,n,r,o,s){let i={schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r},a=Ou(t,e,n,r,o,s),c=a.referenceBacked?
668
- Xt(a.schema):{...a.schema},d={castType:n.type};for(let l of Object.keys(n)){if(l==="type"||!Object.hasOwn(t.validators,l))
669
- continue;let v=yu(t,l,e);if(!v)continue;let x=v({...i,parameterName:l,parameterValue:n[l],fieldSchema:{...c}});x&&gu(c,x)}
670
- c[fe]&&(hn(d,c[fe]),delete c[fe]);let p=[];n.nullable===!0&&p.push({type:"null"}),n.nullOnEmpty===!0&&p.push({const:""});
671
- let m=Xt(vu(c,p));if(n.defaultTo!==void 0&&s.applyDefaults)if(typeof n.defaultTo!="function"){let l=t._normalizeDefault(
668
+ "array"){let a=Cl(t,e,n,r,o,s);if(a)return yt({...i,items:a},{referenceBacked:_n(i)})}return yt(i,{referenceBacked:_n(i)})}
669
+ function Rn(t,e,n,r,o,s){let i={schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r},a=El(t,e,n,r,o,s),c=a.referenceBacked?
670
+ sr(a.schema):{...a.schema},d={castType:n.type};for(let p of Object.keys(n)){if(p==="type"||!Object.hasOwn(t.validators,p))
671
+ continue;let v=wl(t,p,e);if(!v)continue;let y=v({...i,parameterName:p,parameterValue:n[p],fieldSchema:{...c}});y&&hl(c,y)}
672
+ c[we]&&(En(d,c[we]),delete c[we]);let u=[];n.nullable===!0&&u.push({type:"null"}),n.nullOnEmpty===!0&&u.push({const:""});
673
+ let m=sr(gl(c,u));if(n.defaultTo!==void 0&&s.applyDefaults)if(typeof n.defaultTo!="function"){let p=t._normalizeDefault(
672
674
  n,n.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},options:{},settings:t._buildOperationSettings(
673
- o,s,{})});if(Object.keys(l.errors).length>0){let v=Object.values(l.errors)[0];throw new Error(`defaultTo for "${e}" is i\
674
- nvalid (${v.code}).`)}m.default=l.value}else d.defaults={providedByFunction:!0};return m[fe]=d,m}function Qs(t,e={}){let n=xu(
675
- e),{operationName:r,operation:o}=Su(t,n),s=n.additionalProperties===void 0?!1:n.additionalProperties,i=Yt(n),a=Ys(t,n,r,
676
- o,s,{root:!0}),c={$schema:lu,...Zs(a,n)};return Object.keys(i.definitions).length>0&&(c.definitions=i.definitions),c}function ei(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Tn(t){return t instanceof
677
- Be}function Ru(){return{self:!1,children:{}}}function ti(t){return Object.keys(t.children).length>0}function be(t,e){return`${t}\
678
- .${String(e)}`}function ai(t,e){return t===""?String(e):be(t,e)}function ri(t,e){if(t===e)return"";let n=`${e}.`;return t.
679
- startsWith(n)?t.slice(n.length):null}function qe(t,e){let n={};for(let r of Object.values(t)){let o=be(e,r.field);_(n,o,
680
- {...r,field:o})}return n}function Sn(t){return dn(t,"validatePath")}function ni(t){let e={};for(let n of t){let r=Sn(n),
681
- o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||_(o,i,Ru()),s===r.length-1&&(o[i].self=!0),o=o[i].children}}
682
- return e}function Pu(t,e){let n=t;for(let r of e){if(n==null||typeof n!="object"||!Object.hasOwn(n,r))return;n=n[r]}return n}
683
- function Zt(t){return t===null?!0:Array.isArray(t)||z(t)?Object.keys(t).length>0:t!==void 0}function oi(t){return[...t].
675
+ o,s,{})});if(Object.keys(p.errors).length>0){let v=Object.values(p.errors)[0];throw new Error(`defaultTo for "${e}" is i\
676
+ nvalid (${v.code}).`)}m.default=p.value}else d.defaults={providedByFunction:!0};return m[we]=d,m}function Ci(t,e={}){let n=Sl(
677
+ e),{operationName:r,operation:o}=Il(t,n),s=n.additionalProperties===void 0?!1:n.additionalProperties,i=ir(n),a=Ti(t,n,r,
678
+ o,s,{root:!0}),c={$schema:ul,..._i(a,n)};return Object.keys(i.definitions).length>0&&(c.definitions=i.definitions),c}function Ai(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Dn(t){return t instanceof
679
+ Je}function Ol(){return{self:!1,children:{}}}function Ei(t){return Object.keys(t.children).length>0}function Re(t,e){return`${t}\
680
+ .${String(e)}`}function Mi(t,e){return t===""?String(e):Re(t,e)}function Oi(t,e){if(t===e)return"";let n=`${e}.`;return t.
681
+ startsWith(n)?t.slice(n.length):null}function We(t,e){let n={};for(let r of Object.values(t)){let o=Re(e,r.field);_(n,o,
682
+ {...r,field:o})}return n}function Mn(t){return xn(t,"validatePath")}function Ri(t){let e={};for(let n of t){let r=Mn(n),
683
+ o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||_(o,i,Ol()),s===r.length-1&&(o[i].self=!0),o=o[i].children}}
684
+ return e}function Rl(t,e){let n=t;for(let r of e){if(n==null||typeof n!="object"||!Object.hasOwn(n,r))return;n=n[r]}return n}
685
+ function ar(t){return t===null?!0:Array.isArray(t)||$(t)?Object.keys(t).length>0:t!==void 0}function Pi(t){return[...t].
684
686
  sort((e,n)=>{let r=/^[0-9]+$/.test(e),o=/^[0-9]+$/.test(n);return r&&o?Number(e)-Number(n):r?-1:o?1:e.localeCompare(n)})}
685
- function ku(t){return/^[0-9]+$/.test(t)}function Mu(t,e=new WeakMap){if(e.has(t))return e.get(t);let n=Object.create(Be.
687
+ function Pl(t){return/^[0-9]+$/.test(t)}function kl(t,e=new WeakMap){if(e.has(t))return e.get(t);let n=Object.create(Je.
686
688
  prototype);return e.set(t,n),n.structure=null,n.types=t.types,n.validators=t.validators,n.operations=t.operations,n.structure=
687
- er(Qt(t.structure,e)),n._installOperationMethods(),Object.freeze(n)}function Qt(t,e=new WeakMap){if(t===null||typeof t!=
688
- "object")return t;if(Tn(t))return Mu(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let r=new RegExp(
689
+ dr(cr(t.structure,e)),n._installOperationMethods(),Object.freeze(n)}function cr(t,e=new WeakMap){if(t===null||typeof t!=
690
+ "object")return t;if(Dn(t))return kl(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let r=new RegExp(
689
691
  t.source,t.flags);return r.lastIndex=t.lastIndex,r}if(e.has(t))return e.get(t);if(Array.isArray(t)){let r=[];e.set(t,r);
690
- for(let o of t)r.push(Qt(o,e));return r}if(!z(t))return t;let n={};e.set(t,n);for(let[r,o]of Object.entries(t))_(n,r,Qt(
691
- o,e));return n}function er(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Tn(t))return t;if(e.add(t),Array.
692
- isArray(t))for(let n of t)er(n,e);else for(let n of Reflect.ownKeys(t))er(t[n],e);return Object.freeze(t)}function wn(t){
693
- return er(Qt(t))}var yn=new WeakMap;function xn(t,e,n=""){if(!Tn(t)||!Array.isArray(e)||e.length<1)return null;let[r,...o]=e;
694
- if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=ai(n,r);return ci(t,s,o,i)}
695
- function ci(t,e,n,r){if(e?.type==="object"){let o=t._resolveObjectFieldMode(r,e);return o.kind!=="nested"?null:xn(o.schema,
696
- n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.length<1)return null;let[s,...i]=n;if(!ku(s))return null;
697
- let a=be(r,s);return o.kind==="schema"?i.length<1?null:xn(o.schema,i,a):i.length<1?o.definition:ci(t,o.definition,i,a)}return null}
698
- function $e(t,e){let n={...t};if(Array.isArray(t.skipFields)){let r=t.skipFields.map(o=>ri(o,e)).filter(o=>o!==null&&o!==
699
- "");r.length>0?n.skipFields=r:delete n.skipFields}if(z(t.skipParams)){let r={};for(let[o,s]of Object.entries(t.skipParams)){
700
- let i=ri(o,e);i===null||i===""||_(r,i,s)}Object.keys(r).length>0?n.skipParams=r:delete n.skipParams}return n}var Nu=Object.
692
+ for(let o of t)r.push(cr(o,e));return r}if(!$(t))return t;let n={};e.set(t,n);for(let[r,o]of Object.entries(t))_(n,r,cr(
693
+ o,e));return n}function dr(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Dn(t))return t;if(e.add(t),Array.
694
+ isArray(t))for(let n of t)dr(n,e);else for(let n of Reflect.ownKeys(t))dr(t[n],e);return Object.freeze(t)}function Pn(t){
695
+ return dr(cr(t))}var kn=new WeakMap;function jn(t,e,n=""){if(!Dn(t)||!Array.isArray(e)||e.length<1)return null;let[r,...o]=e;
696
+ if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=Mi(n,r);return ji(t,s,o,i)}
697
+ function ji(t,e,n,r){if(e?.type==="object"){let o=t._resolveObjectFieldMode(r,e);return o.kind!=="nested"?null:jn(o.schema,
698
+ n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.length<1)return null;let[s,...i]=n;if(!Pl(s))return null;
699
+ let a=Re(r,s);return o.kind==="schema"?i.length<1?null:jn(o.schema,i,a):i.length<1?o.definition:ji(t,o.definition,i,a)}return null}
700
+ function Ke(t,e){let n={...t};if(Array.isArray(t.skipFields)){let r=t.skipFields.map(o=>Oi(o,e)).filter(o=>o!==null&&o!==
701
+ "");r.length>0?n.skipFields=r:delete n.skipFields}if($(t.skipParams)){let r={};for(let[o,s]of Object.entries(t.skipParams)){
702
+ let i=Oi(o,e);i===null||i===""||_(r,i,s)}Object.keys(r).length>0?n.skipParams=r:delete n.skipParams}return n}var Nl=Object.
701
703
  freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
702
704
  replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
703
705
  patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
704
- function si(t,e,n,r){let o=e[n];if(!r.includes(o))throw new Error(`Operation "${t}" must define ${n} as one of: ${r.join(
705
- ", ")}.`)}function In(t,e,n,r=!0){let o=e[n];if(!(o===void 0&&!r)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
706
- must define ${n} as a boolean.`)}function ju(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
707
- eration "${t}" must be an object.`);return si(t,e,"targetFields",["schema","input"]),In(t,e,"enforceRequired"),In(t,e,"a\
708
- pplyDefaults"),si(t,e,"outputFields",["validated","input"]),In(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
706
+ function ki(t,e,n,r){let o=e[n];if(!r.includes(o))throw new Error(`Operation "${t}" must define ${n} as one of: ${r.join(
707
+ ", ")}.`)}function Nn(t,e,n,r=!0){let o=e[n];if(!(o===void 0&&!r)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
708
+ must define ${n} as a boolean.`)}function Ml(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
709
+ eration "${t}" must be an object.`);return ki(t,e,"targetFields",["schema","input"]),Nn(t,e,"enforceRequired"),Nn(t,e,"a\
710
+ pplyDefaults"),ki(t,e,"outputFields",["validated","input"]),Nn(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
709
711
  targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
710
- rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function Du(t={}){if(typeof t!="object"||t===null||Array.
712
+ rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function jl(t={}){if(typeof t!="object"||t===null||Array.
711
713
  isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[n,r]of Object.entries(
712
- Nu))_(e,n,r);for(let[n,r]of Object.entries(t))_(e,n,ju(n,r));return Object.freeze(e)}function ii(t){let e=Object.create(
713
- null);for(let[n,r]of Object.entries(t))_(e,n,r);return Object.freeze(e)}function zu(t){let e={...t};return delete e.operation,
714
- delete e.mode,e}var Be=class{constructor(e,n,r,o={}){sn(e),this.structure=e,this.types=ii(n),this.validators=ii(r),this.
715
- operations=Du(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could\
714
+ Nl))_(e,n,r);for(let[n,r]of Object.entries(t))_(e,n,Ml(n,r));return Object.freeze(e)}function Ni(t){let e=Object.create(
715
+ null);for(let[n,r]of Object.entries(t))_(e,n,r);return Object.freeze(e)}function Dl(t){let e={...t};return delete e.operation,
716
+ delete e.mode,e}var Je=class{constructor(e,n,r,o={}){yn(e),this.structure=e,this.types=Ni(n),this.validators=Ni(r),this.
717
+ operations=jl(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could\
716
718
  not be cast to the required type.")}_paramError(e,n,r,o={}){let s=new Error(r);return s.errorObject={field:e,code:n,message:r,
717
719
  params:o},s}_paramToBeSkipped(e,n,r){return typeof n!="object"||n===null?!1:!!(Array.isArray(n[r])&&n[r].includes(e))}_fieldToBeSkipped(e,n){
718
720
  return Array.isArray(n.skipFields)&&n.skipFields.includes(e)}_mergeErrors(e,n){for(let[r,o]of Object.entries(n))_(e,r,o)}_singleErrorMap(e){
@@ -723,50 +725,50 @@ tion"))throw new Error("Unsupported validation option `operation`. Call `validat
723
725
  .")}_buildOperationSettings(e,n,r){return{operationName:e,operation:n,targetFieldNames:n.targetFields==="input"?Object.keys(
724
726
  r):Object.keys(this.structure),outputFieldNames:n.outputFields==="input"?Object.keys(r):Object.keys(this.structure),enforceRequired:n.
725
727
  enforceRequired,applyDefaults:n.applyDefaults,rejectExplicitUndefined:n.rejectExplicitUndefined,defaultedFields:new Set,
726
- isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(!z(n))throw new Error(`${e}() expects a plain obje\
728
+ isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(!$(n))throw new Error(`${e}() expects a plain obje\
727
729
  ct input.`)}_resolvePathValidationRequest(e={}){let n=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
728
730
  hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
729
731
  oth are provided.");if(!Object.hasOwn(this.operations,n))throw new Error(`Unknown operation "${n}".`);let r=this.operations[n];
730
- return{operationName:n,operation:r,validationOptions:zu(e)}}_buildOperationResult(e,n,r){let o={};for(let s of r.outputFieldNames){
732
+ return{operationName:n,operation:r,validationOptions:Dl(e)}}_buildOperationResult(e,n,r){let o={};for(let s of r.outputFieldNames){
731
733
  if(!Object.hasOwn(this.structure,s))continue;let i=r.isFieldPresent(s);(n[s]!==void 0||i&&e[s]===null||r.defaultedFields.
732
- has(s))&&(!i&&!r.defaultedFields.has(s)||_(o,s,n[s]))}return o}_resolveObjectFieldMode(e,n){return Kt(e,n)}_resolveArrayItemsConfig(e,n){
733
- return Wt(e,n)}_resolveObjectValuesConfig(e,n){return dt(e,n)}_buildArrayItemSettings(e,n){return e.type==="object"&&Object.
734
+ has(s))&&(!i&&!r.defaultedFields.has(s)||_(o,s,n[s]))}return o}_resolveObjectFieldMode(e,n){return nr(e,n)}_resolveArrayItemsConfig(e,n){
735
+ return rr(e,n)}_resolveObjectValuesConfig(e,n){return vt(e,n)}_buildArrayItemSettings(e,n){return e.type==="object"&&Object.
734
736
  hasOwn(e,"schema")?{...n,operationName:"replace",operation:this.operations.replace}:n}_castValue(e,n,r,o,s,i,a,c){let d=e.
735
- nullable===!0||a.nullable===!0,p=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
737
+ nullable===!0||a.nullable===!0,u=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
736
738
  `No casting function for type: ${e.type}`);let m=this.types[e.type];if(n===null)return d?(_(o,s,null),{errors:{},shouldContinue:!1}):
737
739
  {errors:this._singleErrorMap({field:r,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
738
- if(n===""&&p)return _(o,s,null),{errors:{},shouldContinue:!1};let l={schema:this,definition:e,value:n,fieldName:r,object:o,
740
+ if(n===""&&u)return _(o,s,null),{errors:{},shouldContinue:!1};let p={schema:this,definition:e,value:n,fieldName:r,object:o,
739
741
  objectBeforeCast:i,valueBeforeCast:n,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
740
- nullable:d||p,nullOnEmpty:p},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(v,x,T)=>{throw this._paramError(
741
- r,v,x,T)}};try{let v=m(l);if(ei(v))throw new Error(`Type handler for "${e.type}" must be synchronous.`);v!==void 0&&(_(o,
742
- s,v),l.value=v)}catch(v){if(v.errorObject)return{errors:this._singleErrorMap(v.errorObject),shouldContinue:!1};throw v}return{
743
- errors:{},context:l,shouldContinue:!0}}_runFieldValidators(e,n,r,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
742
+ nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(v,y,T)=>{throw this._paramError(
743
+ r,v,y,T)}};try{let v=m(p);if(Ai(v))throw new Error(`Type handler for "${e.type}" must be synchronous.`);v!==void 0&&(_(o,
744
+ s,v),p.value=v)}catch(v){if(v.errorObject)return{errors:this._singleErrorMap(v.errorObject),shouldContinue:!1};throw v}return{
745
+ errors:{},context:p,shouldContinue:!0}}_runFieldValidators(e,n,r,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
744
746
  _paramToBeSkipped(a,i.skipParams,n)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
745
- a,s.parameterValue=e[a];let d=c(s);if(ei(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
747
+ a,s.parameterValue=e[a];let d=c(s);if(Ai(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
746
748
  (_(r,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,n,r,o,s,i,a,c){
747
749
  let d=this._castValue(e,n,r,o,s,i,a,c);if(Object.keys(d.errors).length>0)return d.errors;if(!d.shouldContinue)return{};let{
748
- context:p}=d,m=this._validateNestedValue(e,r,o,s,a,c);return Object.keys(m).length>0?m:(p.value=o[s],this._runFieldValidators(
749
- e,r,o,s,p,a))}_normalizeDefault(e,n,{fieldPath:r,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
750
+ context:u}=d,m=this._validateNestedValue(e,r,o,s,a,c);return Object.keys(m).length>0?m:(u.value=o[s],this._runFieldValidators(
751
+ e,r,o,s,u,a))}_normalizeDefault(e,n,{fieldPath:r,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
750
752
  let d={...o};return _(d,s,n),{errors:this._normalizeAndValidateValue(e,n,r,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,n,r,o,s,i){
751
753
  if(e.type==="object"){let c=this._resolveObjectFieldMode(n,e);return c.kind==="nested"?this._validateNestedObjectSchema(
752
754
  c,n,r,o,s,i):c.kind==="map"?this._validateObjectValues(n,r,o,c.valuesConfig,s,i):{}}if(e.type!=="array")return{};let a=this.
753
755
  _resolveArrayItemsConfig(n,e);return a?this._validateArrayItems(n,r,o,a,s,i):{}}_validateNestedObjectSchema(e,n,r,o,s,i){
754
756
  let a=r[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
755
- i.operationName,i.operation,c,$e(s,n));return _(r,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
756
- a,e.schema,d.validatedObject):d.validatedObject),qe(d.errors,n)}_extractKnownObjectFields(e,n){let r={};for(let[o,s]of Object.
757
+ i.operationName,i.operation,c,Ke(s,n));return _(r,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
758
+ a,e.schema,d.validatedObject):d.validatedObject),We(d.errors,n)}_extractKnownObjectFields(e,n){let r={};for(let[o,s]of Object.
757
759
  entries(e))Object.hasOwn(n.structure,o)&&_(r,o,s);return r}_mergeKnownAndPassthroughObjectFields(e,n,r){let o={};for(let s of Object.
758
760
  keys(e)){if(!Object.hasOwn(n.structure,s)){_(o,s,e[s]);continue}Object.hasOwn(r,s)&&_(o,s,r[s])}for(let[s,i]of Object.entries(
759
- r))Object.hasOwn(o,s)||_(o,s,i);return o}_validateObjectValues(e,n,r,o,s,i){let a=n[r],c={...a},d={};_(n,r,c);for(let p of Object.
760
- keys(a)){let m=be(e,p);if(this._fieldToBeSkipped(m,s))continue;let l=c[p];if(l===void 0){i.rejectExplicitUndefined?this.
761
- _mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[p];continue}if(o.kind==="schema"){let x=o.
762
- schema._validateWithOperation("replace",o.schema.operations.replace,l,$e(s,m));_(c,p,x.validatedObject),this._mergeErrors(
763
- d,qe(x.errors,m));continue}let v=this._normalizeAndValidateValue(o.definition,l,m,c,p,a,s,this._buildArrayItemSettings(o.
764
- definition,i));this._mergeErrors(d,v)}return d}_validateArrayItems(e,n,r,o,s,i){let a=n[r],c=a.slice(),d={};_(n,r,c);for(let p=0;p<
765
- c.length;p++){let m=be(e,p);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(a,p)||c[p]===void 0){i.rejectExplicitUndefined?
766
- this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[p];continue}if(o.kind==="schema"){let v=o.
767
- schema._validateWithOperation("replace",o.schema.operations.replace,c[p],$e(s,m));_(c,p,v.validatedObject),this._mergeErrors(
768
- d,qe(v.errors,m));continue}let l=this._normalizeAndValidateValue(o.definition,c[p],m,c,p,a,s,this._buildArrayItemSettings(
769
- o.definition,i));this._mergeErrors(d,l)}return d}_validateField(e,n,r,o,s){if(!Object.hasOwn(this.structure,e))return{};
761
+ r))Object.hasOwn(o,s)||_(o,s,i);return o}_validateObjectValues(e,n,r,o,s,i){let a=n[r],c={...a},d={};_(n,r,c);for(let u of Object.
762
+ keys(a)){let m=Re(e,u);if(this._fieldToBeSkipped(m,s))continue;let p=c[u];if(p===void 0){i.rejectExplicitUndefined?this.
763
+ _mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[u];continue}if(o.kind==="schema"){let y=o.
764
+ schema._validateWithOperation("replace",o.schema.operations.replace,p,Ke(s,m));_(c,u,y.validatedObject),this._mergeErrors(
765
+ d,We(y.errors,m));continue}let v=this._normalizeAndValidateValue(o.definition,p,m,c,u,a,s,this._buildArrayItemSettings(o.
766
+ definition,i));this._mergeErrors(d,v)}return d}_validateArrayItems(e,n,r,o,s,i){let a=n[r],c=a.slice(),d={};_(n,r,c);for(let u=0;u<
767
+ c.length;u++){let m=Re(e,u);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){i.rejectExplicitUndefined?
768
+ this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[u];continue}if(o.kind==="schema"){let v=o.
769
+ schema._validateWithOperation("replace",o.schema.operations.replace,c[u],Ke(s,m));_(c,u,v.validatedObject),this._mergeErrors(
770
+ d,We(v.errors,m));continue}let p=this._normalizeAndValidateValue(o.definition,c[u],m,c,u,a,s,this._buildArrayItemSettings(
771
+ o.definition,i));this._mergeErrors(d,p)}return d}_validateField(e,n,r,o,s){if(!Object.hasOwn(this.structure,e))return{};
770
772
  let i=this.structure[e];if(this._fieldToBeSkipped(e,o))return{};let a=s.isFieldPresent(e),c=n[e],d=c===void 0;return s.enforceRequired&&
771
773
  i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
772
774
  Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
@@ -774,90 +776,90 @@ _normalizeAndValidateValue(i,c,e,r,e,n,o,s):{}}_validateWithOperation(e,n,r,o){t
774
776
  i={...r},a=this._buildOperationSettings(e,n,r);for(let c of Object.keys(r))Object.hasOwn(this.structure,c)||_(s,c,{field:c,
775
777
  code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
776
778
  c,r,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
777
- this.structure[c].defaultTo!==void 0){let d=this.structure[c],p=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
778
- m=this._normalizeDefault(d,p,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:r,options:o,settings:a});if(this.
779
+ this.structure[c].defaultTo!==void 0){let d=this.structure[c],u=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
780
+ m=this._normalizeDefault(d,u,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:r,options:o,settings:a});if(this.
779
781
  _mergeErrors(s,m.errors),Object.keys(m.errors).length>0)continue;_(i,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
780
- _buildOperationResult(r,i,a),errors:s}}_validateSelectedTree(e,n,r,o,s=""){let i={},a={};for(let c of oi(Object.keys(e))){
781
- let d=ai(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let p=this._validateSelectedField(
782
- c,e[c],n,a,r,o,d);this._mergeErrors(i,p)}return{validatedObject:a,errors:i}}_validateSelectedField(e,n,r,o,s,i,a){if(!Object.
783
- hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,p=ti(n);if(this._fieldToBeSkipped(a,s))return{};
784
- let m=Object.hasOwn(r,e),l=r[e],v={};if(!m){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
782
+ _buildOperationResult(r,i,a),errors:s}}_validateSelectedTree(e,n,r,o,s=""){let i={},a={};for(let c of Pi(Object.keys(e))){
783
+ let d=Mi(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let u=this._validateSelectedField(
784
+ c,e[c],n,a,r,o,d);this._mergeErrors(i,u)}return{validatedObject:a,errors:i}}_validateSelectedField(e,n,r,o,s,i,a){if(!Object.
785
+ hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,u=Ei(n);if(this._fieldToBeSkipped(a,s))return{};
786
+ let m=Object.hasOwn(r,e),p=r[e],v={};if(!m){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
785
787
  a)&&this._mergeErrors(v,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
786
- c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,j=this._normalizeDefault(c,P,{fieldPath:a,
787
- currentObject:o,containerKey:e,objectBeforeCast:r,options:s,settings:i});this._mergeErrors(v,j.errors),Object.keys(j.errors).
788
- length===0&&_(o,e,j.value)}return v}if(l===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
789
- a).errorObject):{};let x={[e]:l};if(d){let P=this._normalizeAndValidateValue(c,l,a,x,e,r,s,i);return Object.hasOwn(x,e)&&
790
- x[e]!==void 0?_(o,e,x[e]):x[e]===null&&_(o,e,null),P}if(!p)return{};let T=this._castValue(c,l,a,x,e,r,s,i);if(Object.keys(
788
+ c.defaultTo!==void 0){let N=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,z=this._normalizeDefault(c,N,{fieldPath:a,
789
+ currentObject:o,containerKey:e,objectBeforeCast:r,options:s,settings:i});this._mergeErrors(v,z.errors),Object.keys(z.errors).
790
+ length===0&&_(o,e,z.value)}return v}if(p===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
791
+ a).errorObject):{};let y={[e]:p};if(d){let N=this._normalizeAndValidateValue(c,p,a,y,e,r,s,i);return Object.hasOwn(y,e)&&
792
+ y[e]!==void 0?_(o,e,y[e]):y[e]===null&&_(o,e,null),N}if(!u)return{};let T=this._castValue(c,p,a,y,e,r,s,i);if(Object.keys(
791
793
  T.errors).length>0)return T.errors;if(!T.shouldContinue)return{};let O=this._validateSelectedDescendants(c,n.children,a,
792
- x,e,s,i);return Zt(x[e])&&_(o,e,x[e]),O}_validateSelectedDescendants(e,n,r,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
793
- r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested field selection.`);let d=o[s];if(!z(
794
- d))return{};let p=c.schema._validateSelectedTree(n,d,$e(i,r),{...a,defaultedFields:new Set});return _(o,s,p.validatedObject),
795
- qe(p.errors,r)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(r,e);if(!c)throw new Error(`Schema path "${r}" d\
794
+ y,e,s,i);return ar(y[e])&&_(o,e,y[e]),O}_validateSelectedDescendants(e,n,r,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
795
+ r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested field selection.`);let d=o[s];if(!$(
796
+ d))return{};let u=c.schema._validateSelectedTree(n,d,Ke(i,r),{...a,defaultedFields:new Set});return _(o,s,u.validatedObject),
797
+ We(u.errors,r)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(r,e);if(!c)throw new Error(`Schema path "${r}" d\
796
798
  oes not define array items for nested selection.`);return this._validateSelectedArrayItems(r,o,s,c,n,i,a)}throw new Error(
797
799
  `Schema path "${r}" does not support nested field selection.`)}_validateSelectedArrayItems(e,n,r,o,s,i,a){let c=[],d=n[r],
798
- p={};_(n,r,c);for(let m of oi(Object.keys(s))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${be(e,m)}" is inval\
799
- id because array segments must use numeric indexes.`);let l=Number(m),v=be(e,l),x=s[m],T=x.self===!0,O=ti(x);if(this._fieldToBeSkipped(
800
- v,i))continue;if(!Object.hasOwn(d,l)){T&&a.rejectExplicitUndefined&&_(p,v,this._typeError(v).errorObject);continue}let P=d[l];
801
- if(P===void 0){T&&a.rejectExplicitUndefined&&_(p,v,this._typeError(v).errorObject);continue}if(o.kind==="schema"){if(T){
802
- let q=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,$e(i,v));Zt(q.validatedObject)&&_(c,l,q.validatedObject),
803
- this._mergeErrors(p,qe(q.errors,v));continue}if(!O)continue;let H=o.schema._validateSelectedTree(x.children,P,$e(i,v),{...a,
804
- operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Zt(H.validatedObject)&&_(c,l,H.validatedObject),
805
- this._mergeErrors(p,qe(H.errors,v));continue}let j=this._buildArrayItemSettings(o.definition,a),D=[P];if(T){let H=this._normalizeAndValidateValue(
806
- o.definition,P,v,D,0,d,i,j);Object.hasOwn(D,0)&&D[0]!==void 0?_(c,l,D[0]):D[0]===null&&_(c,l,null),this._mergeErrors(p,H);
807
- continue}if(!O)continue;let U=this._castValue(o.definition,P,v,D,0,d,i,j);if(Object.keys(U.errors).length>0){this._mergeErrors(
808
- p,U.errors);continue}if(!U.shouldContinue)continue;let J=this._validateSelectedDescendants(o.definition,x.children,v,D,0,
809
- i,j);Zt(D[0])&&_(c,l,D[0]),this._mergeErrors(p,J)}return p}validateWith(e,n,r={}){if(!Object.hasOwn(this.operations,e))throw new Error(
800
+ u={};_(n,r,c);for(let m of Pi(Object.keys(s))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${Re(e,m)}" is inval\
801
+ id because array segments must use numeric indexes.`);let p=Number(m),v=Re(e,p),y=s[m],T=y.self===!0,O=Ei(y);if(this._fieldToBeSkipped(
802
+ v,i))continue;if(!Object.hasOwn(d,p)){T&&a.rejectExplicitUndefined&&_(u,v,this._typeError(v).errorObject);continue}let N=d[p];
803
+ if(N===void 0){T&&a.rejectExplicitUndefined&&_(u,v,this._typeError(v).errorObject);continue}if(o.kind==="schema"){if(T){
804
+ let P=o.schema._validateWithOperation("replace",o.schema.operations.replace,N,Ke(i,v));ar(P.validatedObject)&&_(c,p,P.validatedObject),
805
+ this._mergeErrors(u,We(P.errors,v));continue}if(!O)continue;let R=o.schema._validateSelectedTree(y.children,N,Ke(i,v),{...a,
806
+ operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});ar(R.validatedObject)&&_(c,p,R.validatedObject),
807
+ this._mergeErrors(u,We(R.errors,v));continue}let z=this._buildArrayItemSettings(o.definition,a),L=[N];if(T){let R=this._normalizeAndValidateValue(
808
+ o.definition,N,v,L,0,d,i,z);Object.hasOwn(L,0)&&L[0]!==void 0?_(c,p,L[0]):L[0]===null&&_(c,p,null),this._mergeErrors(u,R);
809
+ continue}if(!O)continue;let q=this._castValue(o.definition,N,v,L,0,d,i,z);if(Object.keys(q.errors).length>0){this._mergeErrors(
810
+ u,q.errors);continue}if(!q.shouldContinue)continue;let H=this._validateSelectedDescendants(o.definition,y.children,v,L,0,
811
+ i,z);ar(L[0])&&_(c,p,L[0]),this._mergeErrors(u,H)}return u}validateWith(e,n,r={}){if(!Object.hasOwn(this.operations,e))throw new Error(
810
812
  `Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,n),this._validateWithOperation(
811
- e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=Sn(e),{operationName:s,operation:i,validationOptions:a}=this.
812
- _resolvePathValidationRequest(r),c=this._validateSelectedTree(ni([e]),n,a,this._buildOperationSettings(s,i,n));return{validatedValue:Pu(
813
+ e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=Mn(e),{operationName:s,operation:i,validationOptions:a}=this.
814
+ _resolvePathValidationRequest(r),c=this._validateSelectedTree(Ri([e]),n,a,this._buildOperationSettings(s,i,n));return{validatedValue:Rl(
813
815
  c.validatedObject,o),errors:c.errors}}validatePaths(e,n,r={}){if(this._assertPlainObjectInput("validatePaths",n),!Array.
814
816
  isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
815
- operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(ni(e),n,i,this.
817
+ operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(Ri(e),n,i,this.
816
818
  _buildOperationSettings(o,s,n))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
817
819
  `Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(n,r={})=>this.validateWith(e,n,r)}}toJsonSchema(e={}){
818
- return Qs(this,e)}getFieldDefinitions(){return yn.has(this)||yn.set(this,wn(this.structure)),yn.get(this)}getFieldDefinition(e){
819
- if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=xn(this,Sn(e.trim()));
820
- return n===null?null:wn(n)}getFieldMessages(e){let n=this.getFieldDefinition(e);return!n||typeof n.messages!="object"||n.
821
- messages===null?Object.freeze({}):wn(n.messages)}cleanup(e,n){let r={};for(let o of Object.keys(e))Object.hasOwn(this.structure,
822
- o)&&this.structure[o][n]&&_(r,o,e[o]);return r}};var{parse:GS,stringify:Lu}=JSON,{keys:WS}=Object,Uu=String,Fu="string";var di="object",qu=(t,e)=>e;var ui=(t,e,n)=>{let r=Uu(e.push(n)-1);return t.set(n,r),r};var li=(t,e,n)=>{let r=e&&typeof e===di?(p,m)=>p===""||-1<e.indexOf(p)?m:void 0:e||qu,o=new Map,s=[],i=[],a=+ui(o,s,r.call(
823
- {"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=Lu(s[a++],d,n);return"["+i.join(",")+"]";function d(p,m){if(c)return c=!c,
824
- m;let l=r.call(this,p,m);switch(typeof l){case di:if(l===null)return l;case Fu:return o.get(l)||ui(o,s,l)}return l}};var Bu=new Set(["true","1","yes","y","on"]),Hu=new Set(["false","0","no","n","off"]);function Vu(t){return t!==null&&(typeof t==
825
- "object"||typeof t=="function")&&typeof t.then=="function"}function pi(t){if(typeof t=="number")return Number.isFinite(t)?
820
+ return Ci(this,e)}getFieldDefinitions(){return kn.has(this)||kn.set(this,Pn(this.structure)),kn.get(this)}getFieldDefinition(e){
821
+ if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=jn(this,Mn(e.trim()));
822
+ return n===null?null:Pn(n)}getFieldMessages(e){let n=this.getFieldDefinition(e);return!n||typeof n.messages!="object"||n.
823
+ messages===null?Object.freeze({}):Pn(n.messages)}cleanup(e,n){let r={};for(let o of Object.keys(e))Object.hasOwn(this.structure,
824
+ o)&&this.structure[o][n]&&_(r,o,e[o]);return r}};var{parse:hb,stringify:zl}=JSON,{keys:gb}=Object,Ll=String,Ul="string";var Di="object",Fl=(t,e)=>e;var zi=(t,e,n)=>{let r=Ll(e.push(n)-1);return t.set(n,r),r};var Li=(t,e,n)=>{let r=e&&typeof e===Di?(u,m)=>u===""||-1<e.indexOf(u)?m:void 0:e||Fl,o=new Map,s=[],i=[],a=+zi(o,s,r.call(
825
+ {"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=zl(s[a++],d,n);return"["+i.join(",")+"]";function d(u,m){if(c)return c=!c,
826
+ m;let p=r.call(this,u,m);switch(typeof p){case Di:if(p===null)return p;case Ul:return o.get(p)||zi(o,s,p)}return p}};var $l=new Set(["true","1","yes","y","on"]),Bl=new Set(["false","0","no","n","off"]);function Hl(t){return t!==null&&(typeof t==
827
+ "object"||typeof t=="function")&&typeof t.then=="function"}function Ui(t){if(typeof t=="number")return Number.isFinite(t)?
826
828
  t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
827
- if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function bn(t,e){if(Object.is(t,e))return!0;
829
+ if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function zn(t,e){if(Object.is(t,e))return!0;
828
830
  if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
829
831
  source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
830
- e.length)return!1;for(let o=0;o<t.length;o++)if(!bn(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
832
+ e.length)return!1;for(let o=0;o<t.length;o++)if(!zn(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
831
833
  t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let n=Object.keys(t),r=Object.keys(
832
- e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!bn(t[o],e[o]))return!1;return!0}var Gu={install(t){
834
+ e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!zn(t[o],e[o]))return!1;return!0}var Vl={install(t){
833
835
  let{addType:e,addValidator:n}=t;e("none",r=>r.value),e("file",r=>{let o=r.value;o==null&&r.throwTypeError();let s=typeof o;
834
836
  if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),
835
837
  e("string",r=>{let o=r.value;if(o==null)return"";let s=typeof o;if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();
836
- return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=pi(r.value);return o===
837
- null&&r.throwTypeError(),o}),e("integer",r=>{let o=pi(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
838
- o}),e("epochMilliseconds",r=>{let o=cn(r.value,864e13);return o===null&&r.throwTypeError(),o}),e("epochSeconds",r=>{let o=cn(
839
- r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=ut(r.definition,r.fieldName);return Vs(r.
840
- value,o)||r.throwTypeError(),r.value}),e("date",r=>(Bs(r.value)||r.throwTypeError(),r.value)),e("time",r=>{let o=ut(r.definition,
841
- r.fieldName);return Hs(r.value,o)||r.throwTypeError(),r.value}),e("array",r=>r.definition.type==="array"&&!Array.isArray(
842
- r.value)?[r.value]:r.value),e("object",r=>(z(r.value)||r.throwTypeError(),r.value)),e("serialize",r=>{try{return JSON.stringify(
843
- r.value)}catch{try{return li(r.value)}catch{r.throwTypeError()}}}),e("boolean",r=>{if(typeof r.value=="boolean")return r.
838
+ return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=Ui(r.value);return o===
839
+ null&&r.throwTypeError(),o}),e("integer",r=>{let o=Ui(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
840
+ o}),e("epochMilliseconds",r=>{let o=Sn(r.value,864e13);return o===null&&r.throwTypeError(),o}),e("epochSeconds",r=>{let o=Sn(
841
+ r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=wt(r.definition,r.fieldName);return wi(r.
842
+ value,o)||r.throwTypeError(),r.value}),e("date",r=>(gi(r.value)||r.throwTypeError(),r.value)),e("time",r=>{let o=wt(r.definition,
843
+ r.fieldName);return vi(r.value,o)||r.throwTypeError(),r.value}),e("array",r=>r.definition.type==="array"&&!Array.isArray(
844
+ r.value)?[r.value]:r.value),e("object",r=>($(r.value)||r.throwTypeError(),r.value)),e("serialize",r=>{try{return JSON.stringify(
845
+ r.value)}catch{try{return Li(r.value)}catch{r.throwTypeError()}}}),e("boolean",r=>{if(typeof r.value=="boolean")return r.
844
846
  value;if(typeof r.value=="number"){if(r.value===1)return!0;if(r.value===0)return!1;r.throwTypeError()}if(typeof r.value==
845
847
  "bigint"){if(r.value===1n)return!0;if(r.value===0n)return!1;r.throwTypeError()}if(typeof r.value=="string"){let o=String(
846
848
  r.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(r.definition.stringTrueWhen||"true").trim().toLowerCase(),
847
- i=r.value.trim().toLowerCase(),a=new Set([...Hu,o]),c=new Set([...Bu,s]);if(a.has(i))return!1;if(c.has(i))return!0}r.throwTypeError()}),
849
+ i=r.value.trim().toLowerCase(),a=new Set([...Bl,o]),c=new Set([...$l,s]);if(a.has(i))return!1;if(c.has(i))return!0}r.throwTypeError()}),
848
850
  e("id",r=>{if(typeof r.value=="number"){if(Number.isSafeInteger(r.value)&&r.value>0)return r.value;r.throwTypeError()}if(typeof r.
849
851
  value=="bigint"){if(r.value>0n&&r.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(r.value);r.throwTypeError()}if(typeof r.
850
852
  value=="string"){let o=r.value.trim();/^[1-9][0-9]*$/.test(o)||r.throwTypeError();let s=Number(o);return Number.isSafeInteger(
851
853
  s)||r.throwTypeError(),s}r.throwTypeError()}),n("minLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.
852
854
  toString&&r.value.toString().length<r.parameterValue&&r.throwParamError("MIN_LENGTH",`Length must be at least ${r.parameterValue}\
853
- characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&Ue(r.definition)&&
855
+ characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&Ve(r.definition)&&
854
856
  typeof r.value=="number"&&r.value<r.parameterValue&&r.throwParamError("MIN_VALUE",`Value must be at least ${r.parameterValue}\
855
857
  .`,{min:r.parameterValue,actual:r.value})}),n("maxLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.toString&&
856
858
  r.value.toString().length>r.parameterValue&&r.throwParamError("MAX_LENGTH",`Length must be no more than ${r.parameterValue}\
857
- characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&Ue(r.definition)&&
859
+ characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&Ve(r.definition)&&
858
860
  typeof r.value=="number"&&r.value>r.parameterValue&&r.throwParamError("MAX_VALUE",`Value must be no more than ${r.parameterValue}\
859
861
  .`,{max:r.parameterValue,actual:r.value})}),n("enum",r=>{if(!Array.isArray(r.parameterValue))throw new Error(`Enum for ${r.
860
- fieldName} must be an array.`);r.parameterValue.some(s=>bn(s,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
862
+ fieldName} must be an array.`);r.parameterValue.some(s=>zn(s,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
861
863
  one of the allowed enum values.",{allowed:r.parameterValue})}),n("pattern",r=>{if(r.value===void 0||r.definition.type!==
862
864
  "string"||typeof r.value!="string")return;let o=r.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
863
865
  "string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${r.fieldName} must be a string or RegExp.`);s.test(r.value)||
@@ -865,7 +867,7 @@ r.throwParamError("PATTERN","Value does not match the required pattern.",{patter
865
867
  parameterValue){if(r.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${r.
866
868
  fieldName}).`);typeof r.valueBeforeCast!="boolean"&&r.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),n(
867
869
  "validator",r=>{if(typeof r.parameterValue!="function")throw new Error(`Validator for ${r.fieldName} must be a function.`);
868
- let o=r.parameterValue(r.value,r.object,r);if(Vu(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
870
+ let o=r.parameterValue(r.value,r.object,r);if(Hl(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
869
871
  ronous.`);typeof o=="string"&&r.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),n("uppercase",r=>{if(typeof r.value=="str\
870
872
  ing")return r.value.toUpperCase()}),n("lowercase",r=>{if(typeof r.value=="string")return r.value.toLowerCase()}),n("leng\
871
873
  th",r=>{if(typeof r.value=="string")return r.value.substr(0,r.parameterValue);Number.isInteger(Number(r.valueBeforeCast))&&
@@ -877,74 +879,65 @@ r.throwParamError("MAX_ITEMS",`Must have no more than ${r.parameterValue} items.
877
879
  n("notEmpty",r=>{r.parameterValue&&typeof r.value=="string"&&r.value===""&&r.throwParamError("NOT_EMPTY","Field cannot b\
878
880
  e empty.")}),n("required",()=>{}),n("unsigned",()=>{}),n("precision",()=>{}),n("scale",()=>{}),n("temporalPrecision",r=>{
879
881
  if(r.definition.type!=="time"&&r.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
880
- e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},fi=Gu;var vi=new WeakMap,wi=new WeakMap,yi=Symbol.for("json-rest-schema.registry-metadata"),tr=new WeakSet;function Wu(t,e,n){
881
- if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);_(t,e,n)}function Ku(t,e,n){if(typeof n!=
882
- "function")throw new Error(`Validator handler for '${e}' must be a function.`);_(t,e,n)}function rr(t={}){let e=Object.create(
883
- null);for(let[n,r]of Object.entries(t))_(e,n,r);return e}function mi(t,e){if(typeof t.install!="function")throw new Error(
884
- "Plugin must have an install method.");t.install(e)}function hi(t,e,n){vi.set(t,e),wi.set(t,n),Object.defineProperty(t,yi,
885
- {value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function Ju(t){if(!t||
886
- typeof t!="object"&&typeof t!="function")return null;let e=vi.get(t),n=wi.get(t);if(e&&n)return{types:e,validators:n};let r=t[yi];
882
+ e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},Fi=Vl;var Hi=new WeakMap,Vi=new WeakMap,Gi=Symbol.for("json-rest-schema.registry-metadata"),ur=new WeakSet;function Gl(t,e,n){
883
+ if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);_(t,e,n)}function Wl(t,e,n){if(typeof n!=
884
+ "function")throw new Error(`Validator handler for '${e}' must be a function.`);_(t,e,n)}function lr(t={}){let e=Object.create(
885
+ null);for(let[n,r]of Object.entries(t))_(e,n,r);return e}function qi(t,e){if(typeof t.install!="function")throw new Error(
886
+ "Plugin must have an install method.");t.install(e)}function $i(t,e,n){Hi.set(t,e),Vi.set(t,n),Object.defineProperty(t,Gi,
887
+ {value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function Kl(t){if(!t||
888
+ typeof t!="object"&&typeof t!="function")return null;let e=Hi.get(t),n=Vi.get(t);if(e&&n)return{types:e,validators:n};let r=t[Gi];
887
889
  return r&&typeof r.getTypes=="function"&&typeof r.getValidators=="function"?{types:r.getTypes(),validators:r.getValidators()}:
888
890
  typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
889
891
  nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
890
- validators}:null}function Xu(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function gi(t,e,n){for(let[r,o]of Object.
891
- entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(tr.has(o))continue;if(!tr.has(t[r]))throw new Error(`Cannot merge schema\
892
- factories with conflicting ${n} "${r}".`)}_(t,r,o)}}function Yu(t,e,n){let r=Xu(n).filter(Boolean);if(r.length<1)return{
893
- types:rr(t),validators:rr(e)};let o=Object.create(null),s=Object.create(null);for(let i of r){let a=Ju(i);if(!a)throw new Error(
894
- "Factory sources must be schema instances or schema factories created by json-rest-schema.");gi(o,a.types,"type"),gi(s,a.
895
- validators,"validator")}return{types:o,validators:s}}function Ii({types:t={},validators:e={},installCore:n=!0}={}){let r=rr(
896
- t),o=rr(e),s=(i,a={})=>{let c=new Be(i,r,o,a.operations);return hi(c,r,o),c};return hi(s,r,o),s.addType=(i,a)=>{Wu(r,i,a)},
897
- s.addValidator=(i,a)=>{Ku(o,i,a)},s.use=i=>{mi(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{
898
- let a=Yu(r,o,i);return Ii({types:a.types,validators:a.validators,installCore:!1})},n&&mi(fi,{addType:(i,a)=>{tr.add(a),s.
899
- addType(i,a)},addValidator:(i,a)=>{tr.add(a),s.addValidator(i,a)}}),s}var Q=Ii({installCore:!0});var mx=Object.freeze({schema:Q({}),mode:"replace"});var Si=/^[a-z][a-z0-9_.-]*$/u,Qu=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function el(t){return String(t||"").trim().toLowerCase()}
900
- function An(t,e){let n=el(t);if(!Si.test(n))throw new TypeError(`${e} must match ${Si.toString()}.`);return n}function _n(t,e){
901
- if(t==null)return Object.freeze({});if(!A(t))throw new TypeError(`${e} must be an object mapping local names to capabili\
902
- ty ids.`);let n={},r=new Set;for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!Qu.test(i))throw new TypeError(
903
- `${e} local name "${i}" must be a JavaScript identifier.`);let a=An(s,`${e}.${i}`);if(r.has(a))throw new TypeError(`${e}\
904
- declares capability "${a}" more than once.`);r.add(a),n[i]=a}return Object.freeze(n)}function tl(t,e,n){if(t==null)return Object.
905
- freeze({});if(!A(t))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
906
- r.`);let r=new Set(Object.values(e)),o={};for(let[s,i]of Object.entries(t)){let a=An(s,`${n}.hints key`);if(!r.has(a))throw new TypeError(
907
- `${n}.hints names "${a}", which the provider does not require.`);if(typeof i!="string"||!i.trim())throw new TypeError(`${n}\
908
- .hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function rl(t){let e=new Map;
909
- for(let[n,r]of Object.entries(t))for(let o of Object.keys(r)){if(e.has(o))throw new TypeError(`Provider local name "${o}\
910
- " is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function Cn(t,e){if(t==null)return null;if(typeof t!="function")
911
- throw new TypeError(`${e} must be a function when provided.`);return t}function nr({id:t,requires:e={},optional:n={},provides:r={},
912
- hints:o={},setup:s,boot:i=null,shutdown:a=null}={}){let c=An(t,"Provider id"),d=_n(e,`${c}.requires`),p=_n(n,`${c}.optio\
913
- nal`),m=_n(r,`${c}.provides`);rl({requires:d,optional:p,provides:m});let l=Cn(s,`${c}.setup`);if(!l)throw new TypeError(
914
- `${c}.setup is required.`);return Object.freeze({id:c,requires:d,optional:p,provides:m,hints:tl(o,d,c),setup:l,boot:Cn(i,
915
- `${c}.boot`),shutdown:Cn(a,`${c}.shutdown`)})}var xi="public";var nl="/api",Ti=`${nl}/bootstrap`;function On(){let t=[],e=new Set,n=!1;function r({id:a,order:c=0,contribute:d}={}){if(n)throw new Error("Bootstrap regis\
916
- tration is closed after the first payload is resolved.");let p=C(a);if(!p)throw new TypeError("Bootstrap contributor id \
917
- is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${p}" requires contribute().`);if(e.has(
918
- p))throw new Error(`Bootstrap contributor "${p}" is duplicated.`);return e.add(p),t.push(Object.freeze({id:p,order:Number.
919
- isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){n=!0;let c={},d=t.map((p,m)=>({entry:p,index:m})).sort(
920
- (p,m)=>p.entry.order-m.entry.order||p.index-m.index).map(({entry:p})=>p);for(let p of d){let m=await p.contribute(Object.
921
- freeze({...A(a)?a:{},payload:Object.freeze({...c})}));c={...c,...A(m)?m:{}}}return Object.freeze(c)}function s(){return Object.
922
- freeze({sealed:n,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:r,resolve:o,diagnostics:s});
923
- return i}var ol=nr({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:t}){
924
- let e=On();return t.router.register("GET",Ti,{auth:xi,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
925
- async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});function sl(t){if(!A(t))throw new TypeError("Event listener must be an object.");let e=String(t.id||"").trim();if(!e)throw new TypeError(
926
- "Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(`Event listener "${e}" requires han\
927
- dle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event listener "${e}" matches must be a f\
928
- unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function il(t){if(!A(t))throw new TypeError(
929
- "Published event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is\
930
- required.");return Object.freeze({...t,type:e})}function Rn(){let t=[],e=new Set;function n(i){let a=sl(i);if(e.has(a.id))
931
- throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function r(i){let a=il(i);
932
- for(let c of t)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
933
- freeze(t.map(i=>i.id))})}let s=Object.freeze({register:n,publish:r,diagnostics:o});return s}var al=nr({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:Rn()}}});function _e(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let n of Object.getOwnPropertyNames(
934
- t))_e(t[n],e);return Object.freeze(t)}var sT=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},TYPE_CAST_FAILED:{messageKey:"\
935
- default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",code:"kernel.validation.field\
936
- .notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},MAX_LENGTH:{messageKey:"maxL\
937
- ength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kernel.validation.field.minItems"},
938
- MAX_ITEMS:{messageKey:"maxItems",code:"kernel.validation.field.maxItems"},MIN_VALUE:{messageKey:"min",code:"kernel.valid\
939
- ation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxValue"},PATTERN:{messageKey:"pattern",
940
- code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.validation.field.enumValue"},FIELD_NOT_ALLOWED:{
941
- messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"valida\
942
- tor",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"\
943
- default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validation.field.not\
944
- Empty"}}),iT=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),aT=Object.freeze(["create","repl\
945
- ace","patch","toJsonSchema"]);var ll=Q({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),pl=Object.freeze({schema:ll,
946
- mode:"patch"});var _i=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),fl=Object.freeze(
947
- {..._i,nullable:!0});var kT=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
892
+ validators}:null}function Jl(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Bi(t,e,n){for(let[r,o]of Object.
893
+ entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(ur.has(o))continue;if(!ur.has(t[r]))throw new Error(`Cannot merge schema\
894
+ factories with conflicting ${n} "${r}".`)}_(t,r,o)}}function Xl(t,e,n){let r=Jl(n).filter(Boolean);if(r.length<1)return{
895
+ types:lr(t),validators:lr(e)};let o=Object.create(null),s=Object.create(null);for(let i of r){let a=Kl(i);if(!a)throw new Error(
896
+ "Factory sources must be schema instances or schema factories created by json-rest-schema.");Bi(o,a.types,"type"),Bi(s,a.
897
+ validators,"validator")}return{types:o,validators:s}}function Wi({types:t={},validators:e={},installCore:n=!0}={}){let r=lr(
898
+ t),o=lr(e),s=(i,a={})=>{let c=new Je(i,r,o,a.operations);return $i(c,r,o),c};return $i(s,r,o),s.addType=(i,a)=>{Gl(r,i,a)},
899
+ s.addValidator=(i,a)=>{Wl(o,i,a)},s.use=i=>{qi(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{
900
+ let a=Xl(r,o,i);return Wi({types:a.types,validators:a.validators,installCore:!1})},n&&qi(Fi,{addType:(i,a)=>{ur.add(a),s.
901
+ addType(i,a)},addValidator:(i,a)=>{ur.add(a),s.addValidator(i,a)}}),s}var re=Wi({installCore:!0});function Pe(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let n of Object.getOwnPropertyNames(
902
+ t))Pe(t[n],e);return Object.freeze(t)}var Yl=new Set(["create","replace","patch"]),Zl=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.f\
903
+ ield.required"},TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"\
904
+ default",code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.mi\
905
+ nLength"},MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",
906
+ code:"kernel.validation.field.minItems"},MAX_ITEMS:{messageKey:"maxItems",code:"kernel.validation.field.maxItems"},MIN_VALUE:{
907
+ messageKey:"min",code:"kernel.validation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxV\
908
+ alue"},PATTERN:{messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.\
909
+ validation.field.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllow\
910
+ ed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validati\
911
+ on.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"\
912
+ default",code:"kernel.validation.field.notEmpty"}}),Ql=Object.freeze({code:"kernel.validation.invalid",message:"Invalid \
913
+ value."}),ep=Object.freeze(["create","replace","patch","toJsonSchema"]);function pr(t){return!!t&&typeof t=="object"&&ep.
914
+ every(e=>typeof t[e]=="function")}function Ji(t=null,{defaultMode:e="create",context:n="schema definition.mode"}={}){let r=K(t),o=w(e).toLowerCase()||"cre\
915
+ ate",s=Object.prototype.hasOwnProperty.call(r,"mode")?w(r.mode).toLowerCase():"";if(!s)return o;if(!Yl.has(s))throw new TypeError(
916
+ `${n} must be one of: create, replace, patch.`);return s}function Xi(t=null,e=""){let n=w(e);if(!n)return{};let r=K(t);return pr(r.schema)?K(r.schema.getFieldMessages(n)):{}}function tp(t=null,e=""){
917
+ let n=w(e).split(".").filter(Boolean);return n.length<2?{}:(n.pop(),Xi(t,n.join(".")))}function Ki(t,e){let n=e?t[e]:void 0;
918
+ if(typeof n=="string"){let s=w(n);return s?{message:s}:null}if(!x(n))return null;let r=w(n.message);if(!r)return null;let o=w(
919
+ n.code);return o?{message:r,code:o,params:K(n.params)}:{message:r}}function rp(t,e,n=null){let r=w(e?.code).toUpperCase(),
920
+ o=Zl[r]||{},s=K(e?.params),i=Xi(n,t),a=r==="FIELD_NOT_ALLOWED"&&Object.keys(i).length<1?tp(n,t):i,c=Ki(a,o.messageKey)||
921
+ Ki(a,"default");if(c)return c.code?{message:c.message,code:c.code,params:{...s,...c.params}}:{message:c.message};let d=w(
922
+ e?.message);if(d)return o.code?{message:d,code:o.code,params:s}:{message:d};let u=w(e?.code);return u?{message:u}:{...Ql,
923
+ params:{}}}function Ln(t={},e=null){let n=K(t),r={},o={};for(let[s,i]of Object.entries(n)){let a=w(s);if(!a)continue;if(typeof i==
924
+ "string"){r[a]=i;continue}let{message:c,code:d,params:u}=rp(a,i,e);r[a]=c,d&&(o[a]={code:d,params:u})}return{fieldErrors:r,
925
+ fieldErrorCodes:o}}function np(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&(Object.prototype.hasOwnProperty.call(t,"schema")||Object.
926
+ prototype.hasOwnProperty.call(t,"mode"))}function Xe(t,{context:e="schema definition",defaultMode:n=""}={}){if(t==null)return null;
927
+ if(!np(t))throw new TypeError(`${e} must be a schema definition object.`);let r=K(t);if(!Object.prototype.hasOwnProperty.
928
+ call(r,"schema"))throw new TypeError(`${e}.schema is required.`);if(!pr(r.schema))throw new TypeError(`${e}.schema must \
929
+ be a json-rest-schema schema instance.`);let o={schema:r.schema},s=w(n).toLowerCase();return o.mode=Ji(r,{defaultMode:s||
930
+ "patch",context:`${e}.mode`}),Object.freeze(o)}function Un(t,e,{context:n="schema definition",defaultMode:r=""}={}){let o=Xe(t,{context:n,defaultMode:r});return o?o.schema[o.
931
+ mode](e):null}var op=re({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),sp=Object.freeze({schema:op,
932
+ mode:"patch"});var Yi=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),ip=Object.freeze(
933
+ {...Yi,nullable:!0});var Zi="Schema validation failed.";function Qi({message:t=Zi,fieldErrors:e=null,fieldErrorCodes:n=null,errors:r=null,cause:o,
934
+ statusCode:s=null}={}){let i=new Error(t,o?{cause:o}:void 0);if(t===Zi&&(i.messageCode="kernel.validation.schemaFailed",
935
+ i.messageParams={}),Number.isInteger(s)&&s>=400&&s<=599&&(i.statusCode=s),x(e)){let a=x(n)&&Object.keys(n).length>0?n:null;
936
+ i.fieldErrors=e,a&&(i.fieldErrorCodes=a),i.details={...i.details||{},fieldErrors:e,...a?{fieldErrorCodes:a}:{}}}else r!=
937
+ null&&(i.details={...i.details||{},errors:r});return i}function It(t,e,{phase:n="input",context:r="schema definition",statusCode:o=null}={}){
938
+ if(t==null)return e;let s=Un(t,e,{defaultMode:n==="output"?"replace":"patch",context:r}),{fieldErrors:i,fieldErrorCodes:a}=Ln(
939
+ s.errors,t);if(Object.keys(i).length>0)throw Qi({fieldErrors:i,fieldErrorCodes:a,statusCode:o});return s.validatedObject??
940
+ e}var iT=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
948
941
  minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.maxLength"},{keyword:"minimu\
949
942
  m",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"exclusiveMinimum",code:"\
950
943
  kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusiveMaximum"},{keyword:"mu\
@@ -956,62 +949,211 @@ additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems
956
949
  perties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"propertyNames",code:"\
957
950
  kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",code:"kernel.validat\
958
951
  ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:t,code:e})=>[
959
- t,e]));var Ci="^[1-9][0-9]*$",Pn=_e({type:"string",minLength:1,pattern:Ci}),hl=_e({...Pn,nullable:!0}),gl=_e({schema:Q({recordId:{
960
- ...Pn,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
961
- itive integer string."}}}}),mode:"patch"});var Ai=20,yl=32*1024,Ei=48*1024,kn=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
962
- execute:"assistant_action_execute"}),Mn=Object.freeze({type:"object",additionalProperties:!0}),Il=Object.freeze({type:"o\
952
+ t,e]));var ea="^[1-9][0-9]*$",Fn=Pe({type:"string",minLength:1,pattern:ea}),ap=Pe({...Fn,nullable:!0}),cp=Pe({schema:re({recordId:{
953
+ ...Fn,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
954
+ itive integer string."}}}}),mode:"patch"});function ye(t){let e=Array.isArray(t)?t:[t],n=new Set;for(let r of e){let o=w(r);o&&n.add(o)}return[...n]}function ta(t=[],e=""){
955
+ let n=w(e);if(!n)return!0;let r=ye(t);if(r.includes("*")||r.includes(n))return!0;for(let o of r){if(!o.endsWith(".*"))continue;
956
+ let s=o.slice(0,-2);if(s&&n.startsWith(`${s}.`))return!0}return!1}function qn(t,e,n){if(t==="all"){let r=e.find(o=>!ta(n,
957
+ o));return r===void 0?null:{permission:r}}return e.some(r=>ta(n,r))?null:{requiredPermissions:e}}var St=/^[a-z][a-z0-9_.-]*$/u,lp=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function pp(t){return String(t||"").trim().toLowerCase()}
958
+ function Bn(t,e){let n=pp(t);if(!St.test(n))throw new TypeError(`${e} must match ${St.toString()}.`);return n}function fr(t,e){
959
+ if(t==null)return Object.freeze({});if(!x(t))throw new TypeError(`${e} must be an object mapping local names to capabili\
960
+ ty ids.`);let n={},r=new Set;for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!lp.test(i))throw new TypeError(
961
+ `${e} local name "${i}" must be a JavaScript identifier.`);let a=Bn(s,`${e}.${i}`);if(r.has(a))throw new TypeError(`${e}\
962
+ declares capability "${a}" more than once.`);r.add(a),n[i]=a}return Object.freeze(n)}function fp(t,e,n){if(t==null)return Object.
963
+ freeze({});if(!x(t))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
964
+ r.`);let r=new Set(Object.values(e)),o={};for(let[s,i]of Object.entries(t)){let a=Bn(s,`${n}.hints key`);if(!r.has(a))throw new TypeError(
965
+ `${n}.hints names "${a}", which the provider does not require.`);if(typeof i!="string"||!i.trim())throw new TypeError(`${n}\
966
+ .hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function mp(t){let e=new Map;
967
+ for(let[n,r]of Object.entries(t))for(let o of Object.keys(r)){if(e.has(o))throw new TypeError(`Provider local name "${o}\
968
+ " is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function hp(t,e,n){for(let r of Object.values(e))for(let[o,s]of Object.
969
+ entries(n))if(Object.values(s).includes(r))throw new TypeError(o==="provides"?`Provider "${t}" cannot late-require capab\
970
+ ility "${r}" that it provides.`:`Provider "${t}" names capability "${r}" under both late and ${o}.`)}function $n(t,e){if(t==
971
+ null)return null;if(typeof t!="function")throw new TypeError(`${e} must be a function when provided.`);return t}function Ye({
972
+ id:t,requires:e={},optional:n={},late:r={},provides:o={},hints:s={},setup:i,boot:a=null,shutdown:c=null}={}){let d=Bn(t,
973
+ "Provider id"),u=fr(e,`${d}.requires`),m=fr(n,`${d}.optional`),p=fr(r,`${d}.late`),v=fr(o,`${d}.provides`);mp({requires:u,
974
+ optional:m,late:p,provides:v}),hp(d,p,{provides:v,requires:u,optional:m});let y=$n(i,`${d}.setup`);if(!y)throw new TypeError(
975
+ `${d}.setup is required.`);return Object.freeze({id:d,requires:u,optional:m,late:p,provides:v,hints:fp(s,{...u,...p},d),
976
+ setup:y,boot:$n(a,`${d}.boot`),shutdown:$n(c,`${d}.shutdown`)})}var Hn=new WeakSet;function ra(t,e){return t===null||typeof t!="object"||Hn.has(t)||e.has(t)?!0:Object.isFrozen(t)?(e.add(
977
+ t),Reflect.ownKeys(t).every(n=>{let r=Object.getOwnPropertyDescriptor(t,n);return!Object.hasOwn(r,"value")||ra(r.value,e)})):
978
+ !1}function na(t){if(t===null||typeof t!="object"||Hn.has(t))return!0;if(!Object.isFrozen(t))return!1;let e=new Set;if(!ra(
979
+ t,e))return!1;for(let n of e)Hn.add(n);return!0}var gp=Object.freeze(["query","command","stream"]),ia=Object.freeze(["none","authenticated","all","any"]),vp=new Set(gp),
980
+ wp=new Set(ia),aa="create",ca=Object.freeze({required:!0,defaultMode:aa,refuseOneOf:!0}),J=class extends Error{constructor(e,n,r={}){
981
+ super(n),this.name="ActionRuntimeError",this.status=Number(e)||500,this.statusCode=this.status,this.code=String(r.code||
982
+ "ACTION_RUNTIME_ERROR"),this.params=r.params&&typeof r.params=="object"?{...r.params}:{},this.details=r.details,this.headers=
983
+ r.headers||{},this.cause=r.cause}};function da(t,{context:e="domain"}={}){let n=w(t).toLowerCase();if(!n)throw new Error(
984
+ `${e} is required.`);if(!St.test(n))throw new Error(`${e} must match ${St.toString()} (lowercase letters, digits, _, -, \
985
+ .).`);return n}function oa(t,e){let n=Array.isArray(t)?t:[],r=Array.from(new Set(n.map(o=>w(o).toLowerCase()).filter(Boolean)));
986
+ if(r.length<1)throw new Error(`Action definition ${e} must include at least one value.`);return r}function Vn(t){return t&&
987
+ typeof t.getFieldDefinitions=="function"?t.getFieldDefinitions():null}var sa=new WeakSet;function Gn(t,e,n=""){for(let[r,
988
+ o]of Object.entries(t))Wn(o,e,n?`${n}.${r}`:r)}function Wn(t,e,n){let r=Vn(t);if(r){Gn(r,e,n);return}if(x(t)){if(Object.
989
+ hasOwn(t,"oneOf"))throw new Error(`Action definition ${e} field "${n}" declares oneOf, which does not restrict its value\
990
+ ; list the allowed values with enum.`);Gn(Vn(t.schema)||{},e,n),Object.hasOwn(t,"items")&&Wn(t.items,e,`${n}[]`),Object.
991
+ hasOwn(t,"values")&&Wn(t.values,e,`${n}.*`)}}function Kn(t,e,{required:n=!1,defaultMode:r="",refuseOneOf:o=!1}={}){if(t==
992
+ null){if(!n)return null;throw new Error(`Action definition ${e} is required.`)}if(Array.isArray(t))throw new Error(`Acti\
993
+ on definition ${e} must be a single schema definition.`);if(!x(t))throw new Error(`Action definition ${e} must be a json\
994
+ -rest-schema schema definition.`);let s;try{s=Xe(t,{context:`Action definition ${e}`,defaultMode:r})}catch(i){throw new Error(
995
+ i?.message||`Action definition ${e} is invalid.`)}return o&&!sa.has(s.schema)&&(Gn(Vn(s.schema)||{},e),na(s.schema)&&sa.
996
+ add(s.schema)),s}function yp(t,e){if(t==null)return Object.freeze({require:"none",permissions:Object.freeze([]),message:"",
997
+ code:""});if(!x(t))throw new Error(`Action definition "${e}" permission must be an object when provided.`);let n=w(t.require||
998
+ "authenticated").toLowerCase();if(!wp.has(n))throw new Error(`Action definition "${e}" permission.require must be one of\
999
+ : ${ia.join(", ")}.`);return Object.freeze({require:n,permissions:Object.freeze(ye(t.permissions)),message:w(t.message),
1000
+ code:w(t.code)})}function Ip(t){if(t==null)return Object.freeze({});if(!x(t))throw new Error("Action definition extensio\
1001
+ ns must be an object when provided.");return Object.freeze({...t})}function Sp(t,e){if(t==null)return Object.freeze([]);
1002
+ if(!Array.isArray(t))throw new Error(`Action definition "${e}" events must be an array.`);return Object.freeze(t.map((n,r)=>{
1003
+ if(typeof n!="function")throw new Error(`Action definition "${e}" events[${r}] must be a function.`);return n}))}function xp(t,{
1004
+ contributorId:e="",contributorDomain:n=""}={}){let r=t&&typeof t=="object"?t:{},o=w(r.id);if(!o)throw new Error("Action \
1005
+ definition id is required.");let s=V(r.version,{fallback:1}),i=da(r.domain||n,{context:`Action definition "${o}" domain`}),
1006
+ a=w(r.kind||"command").toLowerCase();if(!vp.has(a))throw new Error(`Action definition "${o}" has unsupported kind "${a}"\
1007
+ .`);let c=oa(r.channels,"channels"),d=oa(r.surfaces,"surfaces");if(Object.hasOwn(r,"idempotency"))throw new Error(`Actio\
1008
+ n definition "${o}" declares idempotency. Action definitions no longer declare idempotency.`);if(typeof r.execute!="func\
1009
+ tion")throw new Error(`Action definition "${o}" execute handler is required.`);if(r.checkInput!=null&&typeof r.checkInput!=
1010
+ "function")throw new Error(`Action definition "${o}" checkInput must be a function when provided.`);return Object.freeze(
1011
+ {id:o,version:s,domain:i,kind:a,channels:c,surfaces:d,input:Kn(r.input,"input",ca),output:Kn(r.output,"output",{defaultMode:"\
1012
+ replace"}),permission:yp(r.permission,o),extensions:Ip(r.extensions),events:Sp(r.events,o),checkInput:r.checkInput??null,
1013
+ execute:r.execute,contributorId:w(e)})}function bp(t){let e=t&&typeof t=="object"?t:{},n=w(e.contributorId);if(!n)throw new Error(
1014
+ "Action contributor contributorId is required.");let r=da(e.domain,{context:`Action contributor "${n}" domain`}),s=(Array.
1015
+ isArray(e.actions)?e.actions:[]).map(i=>xp(i,{contributorId:n,contributorDomain:r}));return Object.freeze({contributorId:n,
1016
+ domain:r,actions:Object.freeze(s)})}function Tp(t,e){let n=e.input(t);return n===t.input?t:Object.freeze({...t,input:Kn(
1017
+ n,"input",ca)})}function ua(t,e){let{contributorId:n,domain:r,actions:o}=bp(t);return Object.freeze({contributorId:n,domain:r,
1018
+ actions:Object.freeze(o.map(s=>Object.freeze({declared:s,definition:Tp(s,e)})))})}function Jn(t,e){return`${w(t)}@v${V(e,
1019
+ {fallback:1})}`}function la(t){return t?.requestMeta?.request||null}function pa(t,e){let n=e||la(t);return t?.actor||n?.user||null}function Xn(t,e){
1020
+ return Et(pa(t,e)?.id)}var JT=Object.freeze({schema:re({}),mode:"replace"});function fa(t){let e=t.fieldErrorCodes||t.details?.fieldErrorCodes;return{fieldErrors:t.fieldErrors||t.details?.fieldErrors,
1021
+ ...x(e)?{fieldErrorCodes:e}:{}}}function Yn({details:t,cause:e}){return new J(400,"Validation failed.",{code:"ACTION_VAL\
1022
+ IDATION_FAILED",details:t,cause:e})}function ha(t,e){let n=ne(e.channel);if(!n||!t.channels.includes(n))throw new J(403,
1023
+ "Forbidden.",{code:"ACTION_CHANNEL_FORBIDDEN",details:{actionId:t.id,channel:n}})}function ga(t,e){let n=ne(e.surface),r=t.
1024
+ surfaces;if(!r.includes("*")&&(!n||!r.includes(n)))throw new J(403,"Forbidden.",{code:"ACTION_SURFACE_FORBIDDEN",details:{
1025
+ actionId:t.id,surface:n}})}function va(t,e){let{permission:n}=t,r=n.require;if(r==="none")return;if(Xn(e)==null)throw new J(
1026
+ 401,n.message||"Authentication required.",{code:n.code||"ACTION_AUTHENTICATION_REQUIRED",details:{actionId:t.id}});if(r===
1027
+ "authenticated")return;let s=n.permissions;if(s.length<1)return;let i=qn(r,s,ye(e.permissions));if(i)throw new J(403,n.message||
1028
+ "Forbidden.",{code:n.code||"ACTION_PERMISSION_DENIED",details:{actionId:t.id,...i}})}function ma(t){return x(t?.fieldErrors)||
1029
+ x(t?.details?.fieldErrors)}async function wa(t,e){let n;try{n=It(t.input,e,{phase:"input",context:`Action ${t.id} input`})}catch(r){
1030
+ throw ma(r)?Yn({details:fa(r),cause:r}):r?.code==="ACTION_VALIDATION_FAILED"?r:Yn({details:{error:String(r?.message||"In\
1031
+ valid input.")},cause:r})}if(t.checkInput)try{await t.checkInput(n)}catch(r){throw ma(r)?Yn({details:fa(r),cause:r}):r}return n}
1032
+ async function ya(t,e){if(!t.output)return e;try{return It(t.output,e,{phase:"output",context:`Action ${t.id} output`})}catch(n){
1033
+ throw new Error("Action output validation failed.",{cause:n})}}var _p=Object.freeze(["requestId","commandId","ip","userAgent"]);function Ia(t={}){let e=t&&typeof t=="object"?t:{},n={...e,
1034
+ request:e.request||null};for(let r of _p)n[r]=w(e[r]);return n}function Cp(t){return x(t)?{...t}:null}function Ap(t){let e=Cp(t);return e?(e.id==null&&(e.id=null),e):null}function Ep(t){
1035
+ let e=t&&typeof t=="object"?t:{};return{now:e.now instanceof Date?e.now:new Date,timezone:w(e.timezone),locale:w(e.locale)}}
1036
+ var Op=new Set(["actor","permissions","surface","channel","requestMeta","timeMeta"]);function Rp(t={}){let e={...t};for(let n of Op)
1037
+ delete e[n];return e}var Pp=Symbol("jskit.actions.unloggedExecution");function Zn(t){return!(t&&typeof t=="object"&&t[Pp]===!0)}function kp(t){return ne(t)||"internal"}function mr(t={}){let e=t&&
1038
+ typeof t=="object"?t:{},n=Rp(e);return Object.freeze({...n,actor:Ap(e.actor),permissions:ye(e.permissions),surface:ne(e.
1039
+ surface),channel:kp(e.channel),requestMeta:Ia(e.requestMeta),timeMeta:Ep(e.timeMeta)})}async function Np(t,e,n){for(let r of e){let o=await r(n),s=Array.isArray(o)?o:[o];for(let i of s)i!=null&&await t.publish(
1040
+ i)}}function Sa(t,{definition:e,context:n,outcome:r,startedAt:o,errorCode:s=null}){Zn(n)&&t.debug({action:e.id,version:e.
1041
+ version,channel:n.channel,surface:n.surface,requestId:n.requestMeta.requestId||null,durationMs:Date.now()-o,outcome:r,errorCode:s},
1042
+ "action.execution")}async function Qn({definition:t,declared:e,input:n,context:r,deps:o,events:s,logger:i,policy:a}){let c=mr(
1043
+ r),d=Date.now();try{ha(t,c),ga(t,c),va(t,c);let u=await wa(t,n),m=await a.execute(Object.freeze({definition:e,input:u,context:c,
1044
+ run:(v,y)=>t.execute(v,y,o)})),p=await ya(t,m);return await Np(s,t.events,Object.freeze({definition:t,input:u,result:p,context:c})),
1045
+ Sa(i,{definition:t,context:c,outcome:"success",startedAt:d}),p}catch(u){throw Sa(i,{definition:t,context:c,outcome:"fail\
1046
+ ure",startedAt:d,errorCode:String(u?.code||"ACTION_EXECUTION_FAILED").trim()}),u}}function to(t,e){let n=new Map;for(let{definition:r}of e.actions){let o=Jn(r.id,r.version),s=t.get(o)??n.get(o);if(s)throw new Error(
1047
+ `Action definition "${o}" is duplicated between contributors "${s.contributorId}" and "${e.contributorId}".`);n.set(o,r)}
1048
+ return n}function Mp(t){let e=[],n=new Map,r=new Map,o=new Map;for(let s of t){for(let[i,a]of to(n,s))n.set(i,a);for(let{
1049
+ definition:i,declared:a}of s.actions)o.set(i,a),e.push(i),r.has(i.id)||r.set(i.id,[]),r.get(i.id).push(i)}for(let s of r.
1050
+ values())s.sort((i,a)=>a.version-i.version);return{definitions:Object.freeze(e),byVersionKey:n,byActionId:r,declaredByDefinition:o}}
1051
+ function jp(t){let e=Number(t);if(!Number.isInteger(e)||e<1)throw new J(400,"Validation failed.",{code:"ACTION_VERSION_I\
1052
+ NVALID",details:{fieldErrors:{version:"version must be an integer >= 1."},fieldErrorCodes:{version:{code:"kernel.action.\
1053
+ versionInvalid",params:{}}}}});return e}function eo(t,e,n){let r=String(e||"").trim();if(!r)throw new J(400,"Validation \
1054
+ failed.",{code:"ACTION_ID_REQUIRED",details:{fieldErrors:{actionId:"actionId is required."},fieldErrorCodes:{actionId:{code:"\
1055
+ kernel.action.idRequired",params:{}}}}});if(n==null){let a=t.byActionId.get(r)||[];if(a.length<1)throw new J(404,"Not fo\
1056
+ und.",{code:"ACTION_NOT_FOUND",details:{actionId:r}});return a[0]}let o=jp(n),s=Jn(r,o),i=t.byVersionKey.get(s);if(!i)throw new J(
1057
+ 404,"Not found.",{code:"ACTION_NOT_FOUND",details:{actionId:r,version:o}});return i}function xa({contributors:t,events:e,
1058
+ logger:n,policy:r}){let o=Mp(t);async function s({actionId:d,version:u,input:m,context:p,deps:v}){let y=eo(o,d,u);return Qn(
1059
+ {definition:y,declared:o.declaredByDefinition.get(y),input:m,context:p,deps:v,events:e,logger:n,policy:r})}async function i({
1060
+ actionId:d,version:u,input:m,context:p,deps:v}){let y=eo(o,d,u);if(y.kind!=="stream")throw new J(400,"Validation failed.",
1061
+ {code:"ACTION_STREAM_KIND_REQUIRED",details:{actionId:y.id,version:y.version,kind:y.kind}});return Qn({definition:y,declared:o.
1062
+ declaredByDefinition.get(y),input:m,context:p,deps:v,events:e,logger:n,policy:r})}function a(){return o.definitions.slice()}
1063
+ function c(d,u=null){return eo(o,d,u)}return Object.freeze({execute:s,executeStream:i,listDefinitions:a,getDefinition:c})}var hr=Object.freeze({input(t){return t.input},execute({input:t,context:e,run:n}){return n(t,e)}});function Dp(t){if(!x(t))throw new TypeError("Event listener must be an object.");let e=String(t.id||"").trim();if(!e)throw new TypeError(
1064
+ "Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(`Event listener "${e}" requires han\
1065
+ dle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event listener "${e}" matches must be a f\
1066
+ unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function zp(t){if(!x(t))throw new TypeError(
1067
+ "Published event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is\
1068
+ required.");return Object.freeze({...t,type:e})}function xt(){let t=[],e=new Set;function n(i){let a=Dp(i);if(e.has(a.id))
1069
+ throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function r(i){let a=zp(i);
1070
+ for(let c of t)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
1071
+ freeze(t.map(i=>i.id))})}let s=Object.freeze({register:n,publish:r,diagnostics:o});return s}var ba=Object.freeze({debug(){},info(){},warn(){},error(){}});function Lp(t){if(!x(t))throw new TypeError("Action catalogue registration must be an action contributor object.");return t}
1072
+ function ro({events:t=xt(),logger:e=ba,policy:n=hr}={}){let r=[],o=[],s=new Set,i=new Map,a=null,c=!1;function d(R){if(c)
1073
+ throw new Error("Action catalogue registration is closed after discovery or execution begins.");let P=ua(Lp(R),n);for(let[
1074
+ A,M]of to(i,P))i.set(A,M);return r.push(P),H}function u({id:R,contribute:P}={}){if(c)throw new Error("Action catalogue r\
1075
+ egistration is closed after discovery or execution begins.");let A=String(R||"").trim();if(!A)throw new TypeError("Actio\
1076
+ n context contributor id is required.");if(typeof P!="function")throw new TypeError(`Action context contributor "${A}" r\
1077
+ equires contribute().`);if(s.has(A))throw new Error(`Action context contributor "${A}" is duplicated.`);return s.add(A),
1078
+ o.push(Object.freeze({id:A,contribute:P})),H}function m(){return c=!0,a??=xa({contributors:r,events:t,logger:e,policy:n}),
1079
+ a}function p(R,P){let A={...R};for(let[M,W]of Object.entries(x(P)?P:{}))M==="requestMeta"?A.requestMeta={...x(W)?W:{},...x(
1080
+ A.requestMeta)?A.requestMeta:{}}:Object.hasOwn(A,M)||(A[M]=W);return A}async function v({definition:R,input:P,context:A}){
1081
+ let M={...x(A)?A:{}};for(let W of o){let Ie=await W.contribute(Object.freeze({actionId:R?.id??null,version:R?.version??null,
1082
+ definition:R,input:Object.freeze({...x(P)?P:{}}),context:Object.freeze({...M})}));M=p(M,Ie)}return Object.freeze(M)}function y({
1083
+ actionId:R,version:P,input:A,context:M}){return v({definition:m().getDefinition(R,P),input:A,context:M})}async function T({
1084
+ input:R,context:P}={}){return c=!0,mr(await v({definition:null,input:R,context:P}))}async function O(R,P={}){let A=P&&typeof P==
1085
+ "object"?P:{},M=A.input&&typeof A.input=="object"?A.input:{},W=A.version==null?null:A.version,Ie=await y({actionId:A.actionId,
1086
+ version:W,input:M,context:A.context});return m()[R]({actionId:A.actionId,version:W,input:M,context:Ie,deps:x(A.deps)?A.deps:
1087
+ {}})}function N(R){return O("execute",R)}function z(R){return O("executeStream",R)}function L(){return m().listDefinitions()}
1088
+ function q(R,P=null){return m().getDefinition(R,P)}let H=Object.freeze({register:d,registerContextContributor:u,execute:N,
1089
+ executeStream:z,contextFor:T,listDefinitions:L,getDefinition:q});return H}var Up=Ye({id:"runtime.actions",requires:{events:"runtime.events",logger:"runtime.logger"},optional:{policy:"runtime.act\
1090
+ ions.policy"},provides:{actions:"runtime.actions"},setup({events:t,logger:e,policy:n}){return{actions:ro({events:t,logger:e,
1091
+ policy:n??hr})}}});var Ta="public";var qp="/api",_a=`${qp}/bootstrap`;function no(){let t=[],e=new Set,n=!1;function r({id:a,order:c=0,contribute:d}={}){if(n)throw new Error("Bootstrap regis\
1092
+ tration is closed after the first payload is resolved.");let u=w(a);if(!u)throw new TypeError("Bootstrap contributor id \
1093
+ is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${u}" requires contribute().`);if(e.has(
1094
+ u))throw new Error(`Bootstrap contributor "${u}" is duplicated.`);return e.add(u),t.push(Object.freeze({id:u,order:Number.
1095
+ isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){n=!0;let c={},d=t.map((u,m)=>({entry:u,index:m})).sort(
1096
+ (u,m)=>u.entry.order-m.entry.order||u.index-m.index).map(({entry:u})=>u);for(let u of d){let m=await u.contribute(Object.
1097
+ freeze({...x(a)?a:{},payload:Object.freeze({...c})}));c={...c,...x(m)?m:{}}}return Object.freeze(c)}function s(){return Object.
1098
+ freeze({sealed:n,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:r,resolve:o,diagnostics:s});
1099
+ return i}var $p=Ye({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:t}){
1100
+ let e=no();return t.router.register("GET",_a,{auth:Ta,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
1101
+ async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});var Bp=Ye({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:xt()}}});var Vp=8,$C=Object.freeze({notOffered:"This assistant does not keep unsaved tool calls out of what it saves, so it is no\
1102
+ t offered here.",discoveryOnly:"Only the discovery tools are offered here, and an unsaved action is never discoverable.",
1103
+ directLimit:`At most ${Vp} actions are offered directly beside action discovery.`});var Ca=20,Gp=32*1024,Aa=48*1024,oo=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
1104
+ execute:"assistant_action_execute"}),so=Object.freeze({type:"object",additionalProperties:!0}),Wp=Object.freeze({type:"o\
963
1105
  bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
964
1106
  ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
965
1107
  ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
966
- limit:{type:"integer",minimum:1,maximum:Ai,description:"Maximum compact matches to return."}}}),Sl=Object.freeze({type:"\
967
- object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Ai,items:{
1108
+ limit:{type:"integer",minimum:1,maximum:Ca,description:"Maximum compact matches to return."}}}),Kp=Object.freeze({type:"\
1109
+ object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Ca,items:{
968
1110
  type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
969
1111
  tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
970
- string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),xl=Object.freeze({type:"object",additionalProperties:!1,required:[
971
- "actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),Tl=Object.
1112
+ string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),Jp=Object.freeze({type:"object",additionalProperties:!1,required:[
1113
+ "actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),Xp=Object.
972
1114
  freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
973
1115
  chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
974
- string"},inputSchema:Mn,outputSchema:Mn}}),bl=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
975
- "input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Mn}}),_l=Object.
1116
+ string"},inputSchema:so,outputSchema:so}}),Yp=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
1117
+ "input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:so}}),Zp=Object.
976
1118
  freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
977
- g"},version:{type:"integer",minimum:1},result:{}}}),Oi=Object.freeze([Object.freeze({name:kn.search,description:"Discove\
1119
+ g"},version:{type:"integer",minimum:1},result:{}}}),Ea=Object.freeze([Object.freeze({name:oo.search,description:"Discove\
978
1120
  r application actions available to the current user and surface, including list, search, and query operations for multip\
979
1121
  le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
980
- query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:Il,
981
- outputSchema:Sl}),Object.freeze({name:kn.contract,description:"Load the exact input and output contract for one availabl\
982
- e action before executing it.",parameters:xl,outputSchema:Tl}),Object.freeze({name:kn.execute,description:"Execute one a\
983
- vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:bl,outputSchema:_l})]);var Rb=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var u_=new Error("A later Stop or turn superseded this Claude frame.");var kl=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
984
- attachments:!1,tools:!1,nativeTools:!1});var fC=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
1122
+ query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:Wp,
1123
+ outputSchema:Kp}),Object.freeze({name:oo.contract,description:"Load the exact input and output contract for one availabl\
1124
+ e action before executing it.",parameters:Jp,outputSchema:Xp}),Object.freeze({name:oo.execute,description:"Execute one a\
1125
+ vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:Yp,outputSchema:Zp})]);var GC=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var CA=new Error("A later Stop or turn superseded this Claude frame.");var sf=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
1126
+ attachments:!1,tools:!1,nativeTools:!1});var OE=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
985
1127
  resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
986
- cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),mC=Object.freeze({});var BC=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexRuntime.js",import.meta.url).href;import{createHash as Di}from"node:crypto";import{open as Yl}from"node:fs/promises";import zi from"node:path";var zn=1024*1024,Zl=256*1024,Li=512,Ql=128,ep=16*1024;function Ln({errorPrefix:t="",identityNamespace:e="codex-account-v\
987
- 1",secretNamespace:n="codex-auth-secret-v1"}={}){function r(d="",p="",{messageCode:m}={}){let l=new Error(I(p)||"Codex h\
988
- elper authentication is unavailable. Reconnect Codex and retry.");return l.code=I(d)||`${t}codex_helper_auth_unavailable`,
989
- I(p)?m&&(l.messageCode=m):l.messageCode="assistant.codex.helperAuthUnavailable",l.messageCode&&(l.messageParams={}),l}function o(d,{
990
- label:p="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw r(`${t}cod\
991
- ex_helper_auth_invalid`,`${p} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",p=""){return`\
992
- sha256:${Di("sha256").update(`${e}\0`,"utf8").update(I(d),"utf8").update("\0","utf8").update(String(p||""),"utf8").digest(
993
- "hex")}`}function i(d=""){return Di("sha256").update(`${n}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){
994
- let p=null;try{p=await Yl(d,"r");let m=await p.stat();if(!m.isFile()||m.size>zn)throw r(`${t}codex_helper_auth_invalid`,
1128
+ cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),RE=Object.freeze({});var sO=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexRuntime.js",import.meta.url).href;import{createHash as ja}from"node:crypto";import{open as _f}from"node:fs/promises";import Da from"node:path";var uo=1024*1024,Cf=256*1024,za=512,Af=128,Ef=16*1024;function lo({errorPrefix:t="",identityNamespace:e="codex-account-v\
1129
+ 1",secretNamespace:n="codex-auth-secret-v1"}={}){function r(d="",u="",{messageCode:m}={}){let p=new Error(b(u)||"Codex h\
1130
+ elper authentication is unavailable. Reconnect Codex and retry.");return p.code=b(d)||`${t}codex_helper_auth_unavailable`,
1131
+ b(u)?m&&(p.messageCode=m):p.messageCode="assistant.codex.helperAuthUnavailable",p.messageCode&&(p.messageParams={}),p}function o(d,{
1132
+ label:u="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw r(`${t}cod\
1133
+ ex_helper_auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`\
1134
+ sha256:${ja("sha256").update(`${e}\0`,"utf8").update(b(d),"utf8").update("\0","utf8").update(String(u||""),"utf8").digest(
1135
+ "hex")}`}function i(d=""){return ja("sha256").update(`${n}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){
1136
+ let u=null;try{u=await _f(d,"r");let m=await u.stat();if(!m.isFile()||m.size>uo)throw r(`${t}codex_helper_auth_invalid`,
995
1137
  "The selected Codex authentication record is invalid. Reconnect Codex and retry.",{messageCode:"assistant.codex.authReco\
996
- rdInvalid"});let l=Buffer.alloc(zn+1),v=0;for(;v<l.length;){let{bytesRead:T}=await p.read(l,v,l.length-v,null);if(T===0)
997
- break;v+=T}if(v>zn)throw r(`${t}codex_helper_auth_invalid`,"The selected Codex authentication record is too large. Recon\
998
- nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let x=JSON.parse(l.subarray(0,v).toString("ut\
999
- f8"));if(!A(x))throw new Error("invalid authentication record");return x}catch(m){throw m?.code?.startsWith?.(`${t}codex\
1138
+ rdInvalid"});let p=Buffer.alloc(uo+1),v=0;for(;v<p.length;){let{bytesRead:T}=await u.read(p,v,p.length-v,null);if(T===0)
1139
+ break;v+=T}if(v>uo)throw r(`${t}codex_helper_auth_invalid`,"The selected Codex authentication record is too large. Recon\
1140
+ nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let y=JSON.parse(p.subarray(0,v).toString("ut\
1141
+ f8"));if(!x(y))throw new Error("invalid authentication record");return y}catch(m){throw m?.code?.startsWith?.(`${t}codex\
1000
1142
  _helper_auth_`)?m:r(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. Rec\
1001
- onnect Codex and retry.",{messageCode:"assistant.codex.authRecordUnreadable"})}finally{await p?.close().catch(()=>null)}}
1002
- async function c(d={}){let p=I(d.toolHomeSource);if(!p||!zi.isAbsolute(p))throw r(`${t}codex_helper_auth_unavailable`,"T\
1143
+ onnect Codex and retry.",{messageCode:"assistant.codex.authRecordUnreadable"})}finally{await u?.close().catch(()=>null)}}
1144
+ async function c(d={}){let u=b(d.toolHomeSource);if(!u||!Da.isAbsolute(u))throw r(`${t}codex_helper_auth_unavailable`,"T\
1003
1145
  he selected Codex account is unavailable. Reconnect Codex and retry.",{messageCode:"assistant.codex.accountUnavailable"});
1004
- let m=await a(zi.join(p,".codex","auth.json")),l=I(m.auth_mode).toLowerCase();if(l==="chatgpt"){let v=A(m.tokens)?m.tokens:
1005
- {},x=o(v.account_id,{label:"Codex account identity",maxLength:Li}),T=o(v.access_token,{label:"Codex access token",maxLength:Zl}),
1006
- O=v.chatgpt_plan_type??v.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:Ql});return Object.freeze(
1007
- {accessToken:T,accountId:x,authMode:"chatgpt",identitySignature:s("chatgpt",x),planType:P,secretSignature:i(T)})}if(["ap\
1008
- ikey","api_key"].includes(l)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:ep});return Object.freeze({apiKey:v,
1146
+ let m=await a(Da.join(u,".codex","auth.json")),p=b(m.auth_mode).toLowerCase();if(p==="chatgpt"){let v=x(m.tokens)?m.tokens:
1147
+ {},y=o(v.account_id,{label:"Codex account identity",maxLength:za}),T=o(v.access_token,{label:"Codex access token",maxLength:Cf}),
1148
+ O=v.chatgpt_plan_type??v.plan_type,N=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:Af});return Object.freeze(
1149
+ {accessToken:T,accountId:y,authMode:"chatgpt",identitySignature:s("chatgpt",y),planType:N,secretSignature:i(T)})}if(["ap\
1150
+ ikey","api_key"].includes(p)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:Ef});return Object.freeze({apiKey:v,
1009
1151
  authMode:"apiKey",identitySignature:s("apiKey",v),secretSignature:i(v)})}throw r(`${t}codex_helper_auth_invalid`,"The se\
1010
1152
  lected Codex authentication mode is unsupported. Reconnect Codex and retry.",{messageCode:"assistant.codex.authModeUnsup\
1011
- ported"})}return Object.freeze({error:r,identitySignature:s,readRecord:a,readSelected:c})}var uA=Object.freeze({label:"Checking the Codex sign-in",operationId:"codex-auth-preflight"});var vA=Ln().error;var qA=4*1024*1024;var YE=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
1153
+ ported"})}return Object.freeze({error:r,identitySignature:s,readRecord:a,readSelected:c})}var CO=Object.freeze({label:"Checking the Codex sign-in",operationId:"codex-auth-preflight"});var NO=lo().error;var nR=4*1024*1024;var fP=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
1012
1154
  resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
1013
- cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var nO=2*1024*1024,oO=32*1024*1024,sO=2*1024*1024;var SR=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var AR=256*1024;var ER=2*1024*1024;var OR=Oi.map(({name:t,description:e,parameters:n})=>({type:"function",function:{name:t,description:e,parameters:n}}));var sP=Object.freeze({});var vP=Object.freeze([]);var Cp=Object.freeze({resolve(){throw new N(400,"File attachments are not configured for this conversation.",{code:"conv\
1014
- ersation_attachments_not_configured",messageCode:"assistant.conversation.attachmentsNotConfigured"})}});var CP=Object.freeze([{message:"This conversation exceeds the configured API history limit. Start another conversation o\
1155
+ cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var yP=2*1024*1024,IP=32*1024*1024,SP=2*1024*1024;var Uk=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var Vk=256*1024;var Gk=2*1024*1024;var Wk=Ea.map(({name:t,description:e,parameters:n})=>({type:"function",function:{name:t,description:e,parameters:n}}));var b0=Object.freeze({});var j0=Object.freeze([]);var em=Object.freeze({resolve(){throw new F(400,"File attachments are not configured for this conversation.",{code:"conv\
1156
+ ersation_attachments_not_configured",messageCode:"assistant.conversation.attachmentsNotConfigured"})}});var H0=Object.freeze([{message:"This conversation exceeds the configured API history limit. Start another conversation o\
1015
1157
  r increase the limit.",messageCode:"assistant.conversation.apiHistoryLimit"},{message:"The model reached its output toke\
1016
1158
  n limit before completing the answer. Increase maxOutputTokens in the conversation limits.",messageCode:"assistant.conve\
1017
1159
  rsation.outputTokenLimit"},{message:"The model stream ended without confirming its application tool calls.",messageCode:"\
@@ -1030,21 +1172,21 @@ t be saved. Restore storage access and retry saving.",messageCode:"assistant.con
1030
1172
  Conversation progress could not be saved. Restore access to its storage before continuing.",messageCode:"assistant.conve\
1031
1173
  rsation.progressUnsaved"},{message:"The conversation request exceeded its time limit.",messageCode:"assistant.conversati\
1032
1174
  on.requestTimedOut"},{message:"Work stopped.",messageCode:"assistant.conversation.workStopped"},{message:"Stopped by use\
1033
- r.",messageCode:"assistant.conversation.stoppedByUser"}]);var Ve=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var pk=Q({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:Ve.text,required:!1},toolName:{
1034
- type:"string",maxLength:Ve.toolName,required:!1},arguments:{type:"string",maxLength:Ve.arguments,required:!1}}),fk={type:"\
1175
+ r.",messageCode:"assistant.conversation.stoppedByUser"}]);var Qe=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var RN=re({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:Qe.text,required:!1},toolName:{
1176
+ type:"string",maxLength:Qe.toolName,required:!1},arguments:{type:"string",maxLength:Qe.arguments,required:!1}}),PN={type:"\
1035
1177
  object",additionalProperties:!1,required:["kind","text","toolName","arguments"],properties:{kind:{type:"string",enum:["r\
1036
- eply","tool"]},text:{type:"string",maxLength:Ve.text,description:"The final reply, or a brief progress sentence for the \
1037
- first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:Ve.toolName},arguments:{type:"\
1038
- string",maxLength:Ve.arguments}}};var fM=Object.freeze({});function Dp(){throw new TypeError("Hook delivery requires an instruction resolver.")}function Kn({resolveConversation:t,
1039
- readInstructions:e=Dp}){if(typeof t!="function")throw new TypeError("Conversation hook delivery requires a binding resol\
1178
+ eply","tool"]},text:{type:"string",maxLength:Qe.text,description:"The final reply, or a brief progress sentence for the \
1179
+ first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:Qe.toolName},arguments:{type:"\
1180
+ string",maxLength:Qe.arguments}}};var Pj=Object.freeze({});function um(){throw new TypeError("Hook delivery requires an instruction resolver.")}function So({resolveConversation:t,
1181
+ readInstructions:e=um}){if(typeof t!="function")throw new TypeError("Conversation hook delivery requires a binding resol\
1040
1182
  ver.");return async function(r){if(r.scope!=="session")return{kind:"unclaimed"};let o=await t(r);if(!o)return{kind:"uncl\
1041
1183
  aimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError("Unknown con\
1042
1184
  versation instruction delivery mode.");let s=await e(o,r);if(typeof s!="string"||!s.trim())throw new TypeError("Managed \
1043
- conversation instructions are unavailable.");return{kind:"delivery",text:s}}}var gM=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
1185
+ conversation instructions are unavailable.");return{kind:"delivery",text:s}}}var Mj=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
1044
1186
  allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
1045
1187
  test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
1046
- commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as zp}from"node:fs/promises";import Jn from"node:path";function ir(t){return String(t||"").trim()}var Lp=Object.freeze(["main","temporary"]),Gi=Object.freeze(["managedDatabaseRefresh","managedEnvironment","managedGit",
1047
- "managedPreview"]),Wi=Object.freeze(["managedPages"]),Up=64*1024,KM=Object.freeze(["When user input is necessary, ask no\
1188
+ commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as lm}from"node:fs/promises";import xo from"node:path";function wr(t){return String(t||"").trim()}var pm=Object.freeze(["main","temporary"]),Va=Object.freeze(["managedDatabaseRefresh","managedEnvironment","managedGit",
1189
+ "managedPreview"]),Ga=Object.freeze(["managedPages"]),fm=64*1024,pD=Object.freeze(["When user input is necessary, ask no\
1048
1190
  more than three concise, high-impact questions at once.","Put multiple questions on separate lines as `[1] Question`, `\
1049
1191
  [2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answers:` and a short bullet list dir\
1050
1192
  ectly beneath its own question, before the next one; never collect several questions' answers into one trailing list.","\
@@ -1057,7 +1199,7 @@ Possible answers:
1057
1199
  [2] Tell the main agent before changes?
1058
1200
  Possible answers:
1059
1201
  - Yes, tell main first
1060
- - No, proceed independently`]),JM=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
1202
+ - No, proceed independently`]),fD=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
1061
1203
  start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
1062
1204
  nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
1063
1205
  ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
@@ -1069,115 +1211,115 @@ from the app framework's own pattern as part of the work instead of merely offer
1069
1211
  or confirms (you may propose existing app accounts) with `vibe64-helper preview identities save` (`vibe64-helper spec pr\
1070
1212
  eview-identities`), then verify each with `vibe64-helper preview browser identity <name>`; a saved selector alone proves\
1071
1213
  no access. Use existing sessions/permissions, reject missing/disabled accounts, and disable the adapter without Vibe64\u2019\
1072
- s per-run enable flag and secret. Do not create users, change roles, reset passwords or weaken production auth for impor\
1073
- t. If choices are deferred/declined, say access stays unconfigured and continue independent setup work without repeated \
1074
- credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview status`, `screenshot`, `logs`, an\
1075
- d `browser eval` (Playwright code on stdin) for rendered inspection.","When the person asks to see a page of the app, ru\
1076
- n `vibe64-helper preview open <path>` with its path inside the app (for example `/orders/42?tab=notes`): it moves the Pr\
1077
- eview they have open to that page and says the AI opened it. Your managed browser is a separate copy and never moves the\
1078
- ir pane. If it reports `moved: 0`, give them the path to type into the Preview address box.","The top Preview toolbar St\
1079
- op and `vibe64-helper preview stop` stop this session's application and managed browser, not chat or source. Status repo\
1080
- rts the saved stopped choice. A status read, screenshot, browser inspection, source edit or session reopening is not per\
1081
- mission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start. Scoped browser tests resto\
1082
- re the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-helper preview inspect-url` or\
1083
- status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your-path', pre\
1084
- view.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity and is not a browser-navig\
1085
- ation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper playwright` only for an existin\
1086
- g configured project suite; never install another browser. Pin `@playwright/test` exactly to the `platformVersion` that \
1087
- `vibe64-helper playwright readiness` reports. The login state belongs to the host: pass `process.env.PLAYWRIGHT_STORAGE_\
1088
- STATE` unchanged to `use.storageState`, and never read, parse or edit that file or its cookies in the Playwright config \
1089
- (`vibe64-helper playwright` refuses such a config). If tests run signed out with it, that is a host defect: report it wi\
1090
- th the evidence; do not work around it.","For browser evidence, batch related actions and assertions, return only needed\
1091
- values and inspect relevant locators or regions; screenshot at meaningful checkpoints or failures, not after every clic\
1092
- k. Reuse the managed browser when isolation permits, keep required viewport, identity and security checks, and use exist\
1093
- ing automated cases for repeat verification.","For browser tests that write or reset data, inspect `vibe64-helper previe\
1094
- w targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target <declared-test-ta\
1095
- rget> test <suite arguments>` (or `npm-run <script>` in place of `test`). Vibe64 starts that web target, waits for readi\
1096
- ness, uses its declared application identity, and restores the previous Preview when the command finishes or is cancelle\
1097
- d; report restoration failures.","A target name is not proof of test isolation. Before running a destructive suite, the \
1098
- application must verify the server's actual test database and suppress real email, invoices, payments, and other externa\
1099
- l effects. Keep managed Env unchanged. The test launcher and its preview-identity command must use the same database. Fo\
1100
- llow the application's declared test resources and never invent a database name. Never spoof safety checks by changing o\
1101
- nly the test runner's environment.","If no suitable test target exists, add one through the project's existing Outputs c\
1102
- ontract and application-owned test scripts within authorized scope; normal Preview stays the default. Validate the exact\
1103
- disposable database before resetting it, prepare fixtures before reporting readiness, and make Playwright use PLAYWRIGH\
1104
- T_BASE_URL (the started target's URL) without starting another server. If test resources or external-effect controls are\
1105
- missing, report that blocker. `vibe64-helper preview ensure --target <id> --wait --json` deliberately selects an intera\
1106
- ctive target until changed. If browser startup is slow, measure migrations, fixtures and server startup before retrying \
1107
- or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local artifacts and ke\
1108
- ep exit status. Report counts, duration, failed cases, actionable errors and artifact paths, reading only needed failure\
1109
- excerpts. Retain startup, resource and Preview-restoration errors even if tests pass, and trailing wrapper diagnostics \
1110
- separately from JSON. Do not rerun for output or reread unchanged logs.","Batch related browser tests in one managed sui\
1111
- te (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensure/restart \
1112
- or target changes during a suite or restoration. Wait on the original execution, including background runs, through clea\
1113
- nup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input); read-only statu\
1114
- s/logs stay available. Before live inspection, confirm `vibe64-helper playwright status` shows no active run and `vibe64\
1115
- -helper preview status` is ready on the restored target. To stop, run `vibe64-helper playwright cancel <run-id>`, which \
1116
- waits for cleanup/restoration; retry if cleanup needs attention. Never kill test/Preview PIDs or change locks; launcher \
1117
- exit alone does not prove tests stopped. Recheck status before reporting a busy blocker.","If a managed command reports \
1118
- kernel task denials or a resource incident, report the blocker with its diagnostic and incident ID and ask the platform \
1119
- operator to inspect that evidence before retrying; never raise test timeouts or weaken assertions to work around a proce\
1120
- ss/thread limit. A generic browser timeout without resource evidence does not establish a platform cause."]),XM=Object.freeze(
1121
- ['Pages: `vibe64-helper pages publish <file.html|folder> [--title "Title"]` publishes an HTML page (one file, or a folde\
1122
- r with index.html and its own scripts, styles, data and images) that everyone with access to this project can open from \
1123
- Vibe64\'s Pages list; `vibe64-helper pages update <page-id> <file.html|folder>` gives a page a new version under the same\
1124
- link (it keeps ten; `vibe64-helper pages revert <page-id> <version>` brings one back); `vibe64-helper pages list` lists\
1125
- them. A page runs sandboxed and loads only its own files, never other addresses, CDNs or Vibe64 itself, so ship every s\
1126
- cript, style and data file inside it. Write page files outside the repository (for example in VIBE64_DROP_ZONE) unless t\
1127
- hey belong there. Give the printed link in the chat as a Markdown link; Vibe64 shows it as a card.',"Before writing a pa\
1128
- ge, read `vibe64-helper pages guide` in full and follow it: link `_vibe64/page.css` and build from its components (a hea\
1129
- der, summary tiles first, sections of cards, status pills, tables for comparisons, inline SVG charts), never a wall of t\
1130
- ext.",'After answering with a report, comparison, status or progress overview, dashboard, diagram, plan or review, end t\
1131
- he reply with a one-line offer, such as "Want this as a page everyone on the project can open?" (or, when a related page\
1132
- exists, offer to add it there). Make or change a page only once they say yes.',"When the person says the result is for \
1133
- other people (a colleague, the team, a client, a manager, a meeting) or that they will come back to it, make the page wi\
1134
- thout asking and give its link.","When a page's content will change over time (test results, progress, metrics), say the\
1135
- page can be kept up to date. When the person wants that, build it as the guide's \"A page that keeps itself up to date\" \
1136
- says: index.html for the layout, data.json for the numbers, then `vibe64-helper pages refresh <page-id>` with --every or\
1137
- --daily. Choose --command with a small script that writes data.json, which needs no AI, whenever a script can gather th\
1138
- e data; use --prompt only when gathering it needs judgement.","Before making a page, check `vibe64-helper pages list`: w\
1139
- hen a page about the same subject already exists, update it instead of making a new one.","Do not offer pages for quick \
1140
- answers, code changes, or documents that belong in the repository. Offer at most once per topic; do not nag.","Everyone \
1141
- with access to the project can open a page: never put secrets in one, or anything not every project member should see."]),
1142
- YM=Object.freeze(["Each managed shell command receives current development Env from Vibe64, including declared resource \
1143
- bindings; use them in ordinary commands. Do not build environment injection or copy managed credentials into source. Res\
1144
- ource provisioning and application migrations remain separate preparation steps.","Use `vibe64-helper env status [develo\
1145
- pment|production|all]` to inspect configured key names without revealing values.","Pipe an available value to `vibe64-he\
1146
- lper env set <development|production> <KEY> [--secret]`; it drops the one final newline that `echo` or a generator print\
1147
- s and stores every other character exactly. Never put values in arguments, logs, or repository files. Use empty stdin on\
1148
- ly when the user requested an empty value. The host decides whose session may change production values; when it refuses,\
1149
- report its message instead of retrying.","When the person refers to a saved key, account or accounts hub, run `vibe64-h\
1150
- elper env saved` (names, descriptions and fields, never values) and link the matching field to the variable the applicat\
1151
- ion reads with `vibe64-helper env link <development|production> <KEY> <saved-id> <field-id>` instead of asking for the v\
1152
- alue.","Keep development and production values separate. Never invent credentials, copy a value between scopes without e\
1153
- xplicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected scope and k\
1154
- ey names, never their values, and claim success only when the command succeeded.","Store a secret the application needs \
1155
- generated (such as an application key) by generating it with the framework's own generator and piping it to `vibe64-help\
1156
- er env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file from Env."]);
1157
- function Xn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object.`);return t}function mt(t,e,n){
1158
- let r=new Set(e),o=Object.keys(t).filter(s=>!r.has(s));if(o.length>0)throw new TypeError(`${n} contains unsupported fiel\
1159
- ds: ${o.join(", ")}.`)}function Fp(t){if(mt(t,["conversationKind","scope","session","hostGuidance"],"Vibe64 session cont\
1160
- ext"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,"utf8")>1024))throw new TypeError(
1161
- "Vibe64 host guidance must be bounded text supplied by the host.");if(!Lp.includes(t.conversationKind))throw new TypeError(
1162
- "Vibe64 session context has an unknown conversationKind.");let e=Xn(t.session,"Vibe64 session capabilities");mt(e,[...Gi,
1163
- ...Wi],"Vibe64 session capabilities");let n=Object.fromEntries(Gi.map(r=>{if(typeof e[r]!="boolean")throw new TypeError(
1164
- `Vibe64 session capability ${r} must be boolean.`);return[r,e[r]]}));for(let r of Wi){if(e[r]!==void 0&&typeof e[r]!="bo\
1165
- olean")throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);e[r]===!0&&(n[r]=!0)}return{conversationKind:t.
1166
- conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:n}}function qp(t){mt(t,["sco\
1167
- pe","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").trim();if(!e||e.length>Up)throw new TypeError(
1168
- "Vibe64 ephemeral context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function $p(t){if(t.
1169
- scope==="session")return Fp(t);if(t.scope==="ephemeral")return qp(t);throw new TypeError("The Vibe64 driver supports ses\
1170
- sion and ephemeral scopes only.")}async function Ki(t={},{readRegistry:e=zp,workdir:n=""}={}){let r=Xn(t,"Vibe64 host resolver request");if(mt(r,["data","\
1214
+ s per-run enable flag and secret. Do not create users, change roles, reset passwords or weaken the application's own aut\
1215
+ h for import. If choices are deferred/declined, say access stays unconfigured and continue independent setup work withou\
1216
+ t repeated credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview status`, `screenshot`,\
1217
+ `logs`, and `browser eval` (Playwright code on stdin) for rendered inspection.","When the person asks to see a page of \
1218
+ the app, run `vibe64-helper preview open <path>` with its path inside the app (for example `/orders/42?tab=notes`): it m\
1219
+ oves the Preview they have open to that page and says the AI opened it. Your managed browser is a separate copy and neve\
1220
+ r moves their pane. If it reports `moved: 0`, give them the path to type into the Preview address box.","The top Preview\
1221
+ toolbar Stop and `vibe64-helper preview stop` stop this session's application and managed browser, not chat or source. \
1222
+ Status reports the saved stopped choice. A status read, screenshot, browser inspection, source edit or session reopening\
1223
+ is not permission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start. Scoped browser \
1224
+ tests restore the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-helper preview insp\
1225
+ ect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your\
1226
+ -path', preview.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity and is not a br\
1227
+ owser-navigation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper playwright` only for\
1228
+ an existing configured project suite; never install another browser. Pin `@playwright/test` exactly to the `platformVer\
1229
+ sion` that `vibe64-helper playwright readiness` reports. The login state belongs to the host: pass `process.env.PLAYWRIG\
1230
+ HT_STORAGE_STATE` unchanged to `use.storageState`, and never read, parse or edit that file or its cookies in the Playwri\
1231
+ ght config (`vibe64-helper playwright` refuses such a config). If tests run signed out with it, that is a host defect: r\
1232
+ eport it with the evidence; do not work around it.","For browser evidence, batch related actions and assertions, return \
1233
+ only needed values and inspect relevant locators or regions; screenshot at meaningful checkpoints or failures, not after\
1234
+ every click. Reuse the managed browser when isolation permits, keep required viewport, identity and security checks, an\
1235
+ d use existing automated cases for repeat verification.","For browser tests that write or reset data, inspect `vibe64-he\
1236
+ lper preview targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target <decla\
1237
+ red-test-target> test <suite arguments>` (or `npm-run <script>` in place of `test`). Vibe64 starts that web target, wait\
1238
+ s for readiness, uses its declared application identity, and restores the previous Preview when the command finishes or \
1239
+ is cancelled; report restoration failures.","A target name is not proof of test isolation. Before running a destructive \
1240
+ suite, the application must verify the server's actual test database and suppress real email, invoices, payments, and ot\
1241
+ her external effects. Keep managed Env unchanged. The test launcher and its preview-identity command must use the same d\
1242
+ atabase. Follow the application's declared test resources and never invent a database name. Never spoof safety checks by\
1243
+ changing only the test runner's environment.","If no suitable test target exists, add one through the project's existin\
1244
+ g Outputs contract and application-owned test scripts within authorized scope; normal Preview stays the default. Validat\
1245
+ e the exact disposable database before resetting it, prepare fixtures before reporting readiness, and make Playwright us\
1246
+ e PLAYWRIGHT_BASE_URL (the started target's URL) without starting another server. If test resources or external-effect c\
1247
+ ontrols are missing, report that blocker. `vibe64-helper preview ensure --target <id> --wait --json` deliberately select\
1248
+ s an interactive target until changed. If browser startup is slow, measure migrations, fixtures and server startup befor\
1249
+ e retrying or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local artif\
1250
+ acts and keep exit status. Report counts, duration, failed cases, actionable errors and artifact paths, reading only nee\
1251
+ ded failure excerpts. Retain startup, resource and Preview-restoration errors even if tests pass, and trailing wrapper d\
1252
+ iagnostics separately from JSON. Do not rerun for output or reread unchanged logs.","Batch related browser tests in one \
1253
+ managed suite (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensu\
1254
+ re/restart or target changes during a suite or restoration. Wait on the original execution, including background runs, t\
1255
+ hrough cleanup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input); read\
1256
+ -only status/logs stay available. Before live inspection, confirm `vibe64-helper playwright status` shows no active run \
1257
+ and `vibe64-helper preview status` is ready on the restored target. To stop, run `vibe64-helper playwright cancel <run-i\
1258
+ d>`, which waits for cleanup/restoration; retry if cleanup needs attention. Never kill test/Preview PIDs or change locks\
1259
+ ; launcher exit alone does not prove tests stopped. Recheck status before reporting a busy blocker.","If a managed comma\
1260
+ nd reports kernel task denials or a resource incident, report the blocker with its diagnostic and incident ID and ask th\
1261
+ e platform operator to inspect that evidence before retrying; never raise test timeouts or weaken assertions to work aro\
1262
+ und a process/thread limit. A generic browser timeout without resource evidence does not establish a platform cause."]),
1263
+ mD=Object.freeze(['Pages: `vibe64-helper pages publish <file.html|folder> [--title "Title"]` publishes an HTML page (one\
1264
+ file, or a folder with index.html and its own scripts, styles, data and images) that everyone with access to this proje\
1265
+ ct can open from Vibe64\'s Pages list; `vibe64-helper pages update <page-id> <file.html|folder>` gives a page a new versi\
1266
+ on under the same link (it keeps ten; `vibe64-helper pages revert <page-id> <version>` brings one back); `vibe64-helper \
1267
+ pages list` lists them. A page runs sandboxed and loads only its own files, never other addresses, CDNs or Vibe64 itself\
1268
+ , so ship every script, style and data file inside it. Write page files outside the repository (for example in VIBE64_DR\
1269
+ OP_ZONE) unless they belong there. Give the printed link in the chat as a Markdown link; Vibe64 shows it as a card.',"Be\
1270
+ fore writing a page, read `vibe64-helper pages guide` in full and follow it: link `_vibe64/page.css` and build from its \
1271
+ components (a header, summary tiles first, sections of cards, status pills, tables for comparisons, inline SVG charts), \
1272
+ never a wall of text.",'After answering with a report, comparison, status or progress overview, dashboard, diagram, plan\
1273
+ or review, end the reply with a one-line offer, such as "Want this as a page everyone on the project can open?" (or, wh\
1274
+ en a related page exists, offer to add it there). Make or change a page only once they say yes.',"When the person says t\
1275
+ he result is for other people (a colleague, the team, a client, a manager, a meeting) or that they will come back to it,\
1276
+ make the page without asking and give its link.","When a page's content will change over time (test results, progress, \
1277
+ metrics), say the page can be kept up to date. When the person wants that, build it as the guide's \"A page that keeps it\
1278
+ self up to date\" says: index.html for the layout, data.json for the numbers, then `vibe64-helper pages refresh <page-id>\
1279
+ ` with --every or --daily. Choose --command with a small script that writes data.json, which needs no AI, whenever a scr\
1280
+ ipt can gather the data; use --prompt only when gathering it needs judgement.","Before making a page, check `vibe64-help\
1281
+ er pages list`: when a page about the same subject already exists, update it instead of making a new one.","Do not offer\
1282
+ pages for quick answers, code changes, or documents that belong in the repository. Offer at most once per topic; do not\
1283
+ nag.","Everyone with access to the project can open a page: never put secrets in one, or anything not every project mem\
1284
+ ber should see."]),hD=Object.freeze(["Each managed shell command receives current development Env from Vibe64, including\
1285
+ declared resource bindings; use them in ordinary commands. Do not build environment injection or copy managed credentia\
1286
+ ls into source. Resource provisioning and application migrations remain separate preparation steps.","Use `vibe64-helper\
1287
+ env status [development|staging|all]` to inspect configured key names without revealing values.","Pipe an available val\
1288
+ ue to `vibe64-helper env set <development|staging> <KEY> [--secret]`; it drops the one final newline that `echo` or a ge\
1289
+ nerator prints and stores every other character exactly. Never put values in arguments, logs, or repository files. Use e\
1290
+ mpty stdin only when the user requested an empty value. The host decides whose session may change staging values; when i\
1291
+ t refuses, report its message instead of retrying.","When the person refers to a saved key, account or accounts hub, run\
1292
+ `vibe64-helper env saved` (names, descriptions and fields, never values) and link the matching field to the variable th\
1293
+ e application reads with `vibe64-helper env link <development|staging> <KEY> <saved-id> <field-id>` instead of asking fo\
1294
+ r the value.","Keep development and staging values separate. Never invent credentials, copy a value between scopes witho\
1295
+ ut explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected scope a\
1296
+ nd key names, never their values, and claim success only when the command succeeded.","Store a secret the application ne\
1297
+ eds generated (such as an application key) by generating it with the framework's own generator and piping it to `vibe64-\
1298
+ helper env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file from E\
1299
+ nv."]);function bo(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object.`);return t}
1300
+ function Tt(t,e,n){let r=new Set(e),o=Object.keys(t).filter(s=>!r.has(s));if(o.length>0)throw new TypeError(`${n} contai\
1301
+ ns unsupported fields: ${o.join(", ")}.`)}function mm(t){if(Tt(t,["conversationKind","scope","session","hostGuidance"],"\
1302
+ Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,"ut\
1303
+ f8")>1024))throw new TypeError("Vibe64 host guidance must be bounded text supplied by the host.");if(!pm.includes(t.conversationKind))
1304
+ throw new TypeError("Vibe64 session context has an unknown conversationKind.");let e=bo(t.session,"Vibe64 session capabi\
1305
+ lities");Tt(e,[...Va,...Ga],"Vibe64 session capabilities");let n=Object.fromEntries(Va.map(r=>{if(typeof e[r]!="boolean")
1306
+ throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);return[r,e[r]]}));for(let r of Ga){if(e[r]!==void 0&&
1307
+ typeof e[r]!="boolean")throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);e[r]===!0&&(n[r]=!0)}return{
1308
+ conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:n}}function hm(t){
1309
+ Tt(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").trim();if(!e||e.length>fm)throw new TypeError(
1310
+ "Vibe64 ephemeral context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function gm(t){if(t.
1311
+ scope==="session")return mm(t);if(t.scope==="ephemeral")return hm(t);throw new TypeError("The Vibe64 driver supports ses\
1312
+ sion and ephemeral scopes only.")}async function Wa(t={},{readRegistry:e=lm,workdir:n=""}={}){let r=bo(t,"Vibe64 host resolver request");if(Tt(r,["data","\
1171
1313
  providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(r.scope))throw new TypeError(
1172
- "The Vibe64 host resolver scope must be session or turn.");if(r.scope==="turn")return null;let o=Xn(r.data,"Vibe64 host \
1173
- resolver data");mt(o,["registryPath"],"Vibe64 host resolver data");let s=ir(o.registryPath);if(!Jn.isAbsolute(s))throw new TypeError(
1314
+ "The Vibe64 host resolver scope must be session or turn.");if(r.scope==="turn")return null;let o=bo(r.data,"Vibe64 host \
1315
+ resolver data");Tt(o,["registryPath"],"Vibe64 host resolver data");let s=wr(o.registryPath);if(!xo.isAbsolute(s))throw new TypeError(
1174
1316
  "Vibe64 host resolver data requires an absolute registryPath.");let i=JSON.parse(await e(s,"utf8"));if(!Array.isArray(i?.
1175
- sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=ir(r.providerSessionId);
1317
+ sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=wr(r.providerSessionId);
1176
1318
  if(r.parentSessionIds!==void 0&&(!Array.isArray(r.parentSessionIds)||r.parentSessionIds.length>32||r.parentSessionIds.some(
1177
- l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let p=[c,...r.parentSessionIds||
1178
- []].filter(Boolean).map(l=>a.find(v=>ir(v?.upstreamSessionId)===l)).find(Boolean),m=p?.promptContext;if(!m)return null;if(n&&
1179
- p.workdir&&Jn.resolve(n)!==Jn.resolve(p.workdir))throw new Error("The managed conversation belongs to a different projec\
1180
- t directory.");return $p(m)}var Yn="";for await(let t of process.stdin)if(Yn+=t,Buffer.byteLength(Yn)>256*1024)throw new Error("Conversation instruc\
1181
- tion input exceeds 256 KiB.");var Ji=JSON.parse(Yn);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
1182
- process.stdout.write(await t(Ji))}else{let t=Kn({resolveConversation:async e=>await Ki(e,{workdir:process.cwd()})?{delivery:"\
1183
- native"}:null});process.stdout.write(JSON.stringify(await t(Ji)))}
1319
+ p=>typeof p!="string"||!p.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[c,...r.parentSessionIds||
1320
+ []].filter(Boolean).map(p=>a.find(v=>wr(v?.upstreamSessionId)===p)).find(Boolean),m=u?.promptContext;if(!m)return null;if(n&&
1321
+ u.workdir&&xo.resolve(n)!==xo.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
1322
+ t directory.");return gm(m)}var To="";for await(let t of process.stdin)if(To+=t,Buffer.byteLength(To)>256*1024)throw new Error("Conversation instruc\
1323
+ tion input exceeds 256 KiB.");var Ka=JSON.parse(To);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
1324
+ process.stdout.write(await t(Ka))}else{let t=So({resolveConversation:async e=>await Wa(e,{workdir:process.cwd()})?{delivery:"\
1325
+ native"}:null});process.stdout.write(JSON.stringify(await t(Ka)))}