vibe64 0.1.59 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +1228 -1210
- package/bin/server.js +392 -376
- package/bin/upgrade-state.js +4457 -4430
- package/dist/assets/{GithubBrowserTabs-D_nMB5Y1.js → GithubBrowserTabs-DAgQxPXI.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-BgO_aeUg.js → LocalDatabaseServer-m1G8ZS5i.js} +1 -1
- package/dist/assets/SelectField-DwWoHC2p.js +1 -0
- package/dist/assets/{ShellOutlet-Cr8SJs7s.js → ShellOutlet-CdjsJfg9.js} +1 -1
- package/dist/assets/Vibe64AuthSettingsButton-D3sB4BfM.js +5 -0
- package/dist/assets/{Vibe64AuthSettingsButton-DRTKdimW.css → Vibe64AuthSettingsButton-DFfFPrd7.css} +1 -1
- package/dist/assets/{Vibe64ConversationLog-DtOgxPNR.js → Vibe64ConversationLog-B-L5QsVr.js} +4 -4
- package/dist/assets/{Vibe64ConversationLog-NH61odld.css → Vibe64ConversationLog-ksf1U6PP.css} +1 -1
- package/dist/assets/{Vibe64DashboardShell-DhPE6H3P.js → Vibe64DashboardShell-CMzX3wRM.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-Bpnbjs4l.css → Vibe64DashboardShell-D0GNI4V8.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-cfn8TTxQ.css → Vibe64DatabaseWorkspace-De4sbXAN.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-CHV0cd3l.js → Vibe64DatabaseWorkspace-Dewhs6_T.js} +2 -2
- package/dist/assets/Vibe64DestinationButton-CdyyK9tj.js +1 -0
- package/dist/assets/Vibe64DestinationButton-ZxY1Lwie.css +1 -0
- package/dist/assets/Vibe64FileArea-DluZTu-c.js +1 -0
- package/dist/assets/{Vibe64FileArea-mydNQQl8.css → Vibe64FileArea-ZEzsvLt2.css} +1 -1
- package/dist/assets/Vibe64OutputControls-BfbdD25Y.js +8 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-DUSMn4pR.js → Vibe64RepositoryWorkspace-CBsySPXN.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-BXt__PJL.js → Vibe64SessionFiles--wtVe_KC.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-NyG6niQM.js → Vibe64SessionSourceEditor-BouH4fXC.js} +1 -1
- package/dist/assets/Vibe64UiStoryboardView--E04EEF8.js +8 -0
- package/dist/assets/{Vibe64UiStoryboardView-CtlJWiCY.css → Vibe64UiStoryboardView-DqLN6ofL.css} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-CCPWJo8e.js → Vibe64UnavailableSessions-94bFpxMK.js} +1 -1
- package/dist/assets/_pageId_-Ch4OpUkd.js +1 -0
- package/dist/assets/_sessionId_-7PyIUeUr.css +1 -0
- package/dist/assets/_sessionId_-DGT4d2La.js +1 -0
- package/dist/assets/{_sessionTool_-CKPNp5fF.js → _sessionTool_-CBf51mfK.js} +1 -1
- package/dist/assets/_sessionTool_-DiYoi-BF.css +1 -0
- package/dist/assets/_slug_-C8VNMRVH.js +14 -0
- package/dist/assets/_slug_-CZmGS16g.css +1 -0
- package/dist/assets/access-BAOx4iCS.js +1 -0
- package/dist/assets/access-BH1OsqPS.css +1 -0
- package/dist/assets/{app-D9FegZf0.js → app-Bs6-Hv23.js} +1 -1
- package/dist/assets/{assistantRouting-D4SnnxJn.js → assistantRouting-BS0ZW5Ki.js} +1 -1
- package/dist/assets/{changes-DtfJc780.js → changes-C6eMQ9YE.js} +1 -1
- package/dist/assets/{client-CUQfIUus.css → client-BBJzQIWS.css} +1 -1
- package/dist/assets/{client-BBqNv4HL.js → client-CIF5Y1Aj.js} +1 -1
- package/dist/assets/{client-B8u2_Svv.css → client-CM6TGZc9.css} +1 -1
- package/dist/assets/{client-DnjkdG6K.js → client-CVgL_ShV.js} +1 -1
- package/dist/assets/{client-DuDOzb5A.js → client-HWj_BNVZ.js} +2 -2
- package/dist/assets/{client-Dra4Vp3A.js → client-qAKnahkF.js} +2 -2
- package/dist/assets/{client-mU-LObHG.js → client-qpL_kR4u.js} +2 -2
- package/dist/assets/{conversation-QpMeXw70.js → conversation-DbF0OrZB.js} +3 -3
- package/dist/assets/{conversation-La-pkh5h.css → conversation-ZN3-8jbz.css} +1 -1
- package/dist/assets/{dashboard-B26QwE6y.js → dashboard-CzLsa0w0.js} +1 -1
- package/dist/assets/{english-definitions-I9tIXY2u.js → english-definitions-BA8v5wP1.js} +1 -1
- package/dist/assets/{env-BXsvM592.js → env-BqJ_GWbz.js} +1 -1
- package/dist/assets/{error-kdRkyK9x.js → error-BQ7r64JO.js} +1 -1
- package/dist/assets/{error-CX8_snYL.js → error-BqMxhgpB.js} +1 -1
- package/dist/assets/errorMessageHelpers-BjIt31kK.js +1 -0
- package/dist/assets/{errors-DErd0NON.js → errors-D17nJYne.js} +1 -1
- package/dist/assets/{health-C4WtefLm.js → health-CIqrHpVK.js} +1 -1
- package/dist/assets/history-BCjhpyP8.js +1 -0
- package/dist/assets/history-BSIuLgnI.css +1 -0
- package/dist/assets/{httpClient-BRO3GqjU.js → httpClient-Bwitq9Xf.js} +1 -1
- package/dist/assets/i18n-BkxO7BMl.js +1 -0
- package/dist/assets/{i18n-B5lc019_.js → i18n-Dm74yE_M.js} +1 -1
- package/dist/assets/index-Ctygjyf8.css +1 -0
- package/dist/assets/index-fXKdz8oR.js +134 -0
- package/dist/assets/{integrations-CrI893NK.css → integrations-CwgrZgmM.css} +1 -1
- package/dist/assets/{integrations-CQNJxkMu.js → integrations-cgbpgNNd.js} +12 -5
- package/dist/assets/issues-AhouA6nE.js +1 -0
- package/dist/assets/issues-D46llNv-.css +1 -0
- package/dist/assets/{learning-0cINHUSN.js → learning-DZXWgVEW.js} +1 -1
- package/dist/assets/{pages-DbF-yXqO.js → pages-5jaEclQo.js} +1 -1
- package/dist/assets/{pages-CIKw99GN.js → pages-BUUwIXBf.js} +1 -1
- package/dist/assets/{pathname-DOqQPPVa.js → pathname-JHQIKk21.js} +1 -1
- package/dist/assets/{placement-BAaZQhAh.js → placement-1lT0lW3-.js} +1 -1
- package/dist/assets/{placement-Lk1Lpy6s.js → placement-B2V88UDJ.js} +1 -1
- package/dist/assets/{project-files-CklWobqZ.js → project-files-BS2gdDSz.js} +1 -1
- package/dist/assets/publish-Bq_LPmX2.js +3 -0
- package/dist/assets/{publish-DOybV3Qz.css → publish-C9O0tDPB.css} +1 -1
- package/dist/assets/pull-requests-BvChbjCD.js +1 -0
- package/dist/assets/pull-requests-DtqrTix0.css +1 -0
- package/dist/assets/{repository-wJZei_NJ.js → repository-Dkow-18G.js} +1 -1
- package/dist/assets/settings-BKZcbISO.css +1 -0
- package/dist/assets/settings-r5RWQVzw.js +1 -0
- package/dist/assets/{shared-X5MxTHwl.js → shared-B6plZPQ_.js} +1 -1
- package/dist/assets/{studioGateApi-CHIdcQvD.js → studioGateApi-UqmdV50W.js} +1 -1
- package/dist/assets/{studioUrls-oIU1Eq_t.js → studioUrls-k_pQIuPs.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-C0MVJuyX.js +1 -0
- package/dist/assets/useAssistantAttachments-BkYZckgz.js +2 -0
- package/dist/assets/useCommand-CNDe8gM-.js +1 -0
- package/dist/assets/{useEndpointResource-61E93qP-.js → useEndpointResource-CmMwteuX.js} +1 -1
- package/dist/assets/{usePaths-B-QGqa_I.js → usePaths-CvUbx5-V.js} +1 -1
- package/dist/assets/{useUiFeedback-CycH_fvY.js → useUiFeedback-CWb6o71Z.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-CUWEZhnf.js +2 -0
- package/dist/assets/{useVibe64Learning-DZCyrfpy.js → useVibe64Learning-RE4HXHqo.js} +1 -1
- package/dist/assets/{useVibe64SessionData-rBvWMqyc.js → useVibe64SessionData-kGr7R7lG.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-C546mBu8.js → useVibe64SessionSelection-BZ7WnRv0.js} +1 -1
- package/dist/assets/validators-HqYRjxEO.js +1 -0
- package/dist/assets/{vibe64FileUpload-D0Lv2mMJ.js → vibe64FileUpload-BDkcaUyk.js} +1 -1
- package/dist/assets/vibe64GithubProject-CJneIo5O.js +1 -0
- package/dist/assets/vibe64RepositoryRealtime-R5QhcJ4H.js +1 -0
- package/dist/assets/vibe64SessionFocus-BCojr4E-.css +1 -0
- package/dist/assets/vibe64SessionFocus-CHKCMxcJ.js +1 -0
- package/dist/index.html +29 -27
- package/docs/colleague-usage/ai-tasks.md +15 -4
- package/docs/colleague-usage/back-navigation.md +16 -13
- package/docs/colleague-usage/coding-agent-goal-pause.md +15 -1
- package/docs/colleague-usage/coding-agent-goals.md +23 -3
- package/docs/colleague-usage/coding-agent-recovery.md +3 -1
- package/docs/colleague-usage/coding-agents.md +19 -1
- package/docs/colleague-usage/colleague-watches.md +1 -1
- package/docs/colleague-usage/connected-projects.md +1 -1
- package/docs/colleague-usage/connected-repositories.md +16 -4
- package/docs/colleague-usage/dashboard-navigation.md +14 -11
- package/docs/colleague-usage/database.md +1 -1
- package/docs/colleague-usage/development-env.md +21 -12
- package/docs/colleague-usage/files.md +2 -1
- package/docs/colleague-usage/github-work.md +51 -12
- package/docs/colleague-usage/health-checks.md +1 -1
- package/docs/colleague-usage/integrations.md +2 -2
- package/docs/colleague-usage/learning-teacher-guide.md +3 -2
- package/docs/colleague-usage/pages.md +1 -2
- package/docs/colleague-usage/preview-browser-checks.md +3 -0
- package/docs/colleague-usage/preview.md +29 -0
- package/docs/colleague-usage/project-messages.md +4 -3
- package/docs/colleague-usage/project-settings.md +3 -0
- package/docs/colleague-usage/session-archive.md +11 -0
- package/docs/colleague-usage/sessions.md +8 -7
- package/docs/colleague-usage/temporary-chats.md +4 -3
- package/docs/colleague-usage/ui-pass.md +1 -1
- package/docs/colleague-usage/usage-map.md +3 -2
- package/docs/colleague-usage/workspace-preparation.md +12 -0
- package/node_modules/@jskit-ai/agent/CHANGELOG.md +5 -0
- package/node_modules/@jskit-ai/agent/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +8 -0
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +4 -1
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +4 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/CHANGELOG.md +4 -0
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +2 -0
- package/node_modules/@jskit-ai/connectors-core/README.md +4 -0
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +8 -0
- package/node_modules/@jskit-ai/kernel/package.json +3 -1
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +2 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-ai-tasks/package.json +2 -1
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +463 -442
- package/node_modules/@local/vibe64-genesis/bin/genesis +17 -11
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +827 -813
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +93 -67
- package/node_modules/@local/vibe64-genesis/src/server/index.js +608 -584
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +180 -175
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +490 -479
- package/node_modules/@local/vibe64-source-editor/src/server/searchIndexWorker.js +12 -11
- package/node_modules/@local/vibe64-system-graph/README.md +9 -5
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +262 -252
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1026 -981
- package/node_modules/json-rest-schema/README.md +3 -1
- package/node_modules/json-rest-schema/package.json +1 -1
- package/package.json +17 -17
- package/server.bundle.mjs +43244 -42953
- package/dist/assets/Vibe64AuthSettingsButton-Bx9patil.js +0 -5
- package/dist/assets/Vibe64FileArea-DIDyAUvD.js +0 -1
- package/dist/assets/Vibe64OutputControls-mNWUWLSm.js +0 -8
- package/dist/assets/Vibe64UiStoryboardView-BXH2MSWn.js +0 -8
- package/dist/assets/_pageId_-D54CqzqG.js +0 -1
- package/dist/assets/_sessionId_-B5V2Fs2n.css +0 -1
- package/dist/assets/_sessionId_-CW044RVi.js +0 -1
- package/dist/assets/_sessionTool_-Be88HWbv.css +0 -1
- package/dist/assets/_slug_-CRtFhc0A.js +0 -14
- package/dist/assets/_slug_-WWvJTLoc.css +0 -1
- package/dist/assets/access-ChMLRErk.js +0 -1
- package/dist/assets/access-Cm2lrMF6.css +0 -1
- package/dist/assets/errorMessageHelpers-L2GsOwCP.js +0 -1
- package/dist/assets/history-BhqQz5jH.css +0 -1
- package/dist/assets/history-HHPFoNi3.js +0 -1
- package/dist/assets/index-BBfSvf2i.css +0 -1
- package/dist/assets/index-Bvd00puv.js +0 -134
- package/dist/assets/issues-BHr_nI-9.js +0 -1
- package/dist/assets/issues-CpBRQTQ_.css +0 -1
- package/dist/assets/publish-Cot797YN.js +0 -3
- package/dist/assets/pull-requests-DnEm9m_1.css +0 -1
- package/dist/assets/pull-requests-ybnixBv0.js +0 -1
- package/dist/assets/settings-DJByC5Wb.js +0 -1
- package/dist/assets/settings-bEkDjn0Y.css +0 -1
- package/dist/assets/useArchivedVibe64Sessions-B-DtXrk-.js +0 -1
- package/dist/assets/useAssistantAttachments-CkseokGM.js +0 -2
- package/dist/assets/useCommand-D96utlVe.js +0 -1
- package/dist/assets/useVibe64ConversationLog-BVANhCHq.js +0 -2
- package/dist/assets/validators-B3YzM6px.js +0 -1
- package/dist/assets/vibe64GithubProject-DNl0aDcC.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-BPsE5l5E.js +0 -1
- package/dist/assets/vibe64SessionFocus-CxX2nK6F.js +0 -1
- package/dist/assets/vibe64SessionFocus-DW73PN_o.css +0 -1
|
@@ -1,252 +1,252 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
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(
|
|
5
|
-
enumerable:!(
|
|
6
|
-
exports={BINARY_TYPES:
|
|
3
|
+
var Xi=Object.create;var Zn=Object.defineProperty;var Yi=Object.getOwnPropertyDescriptor;var Zi=Object.getOwnPropertyNames;var Qi=Object.getPrototypeOf,ea=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 ta=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zi(e))!ea.call(t,o)&&o!==n&&Zn(t,o,{get:()=>e[o],
|
|
5
|
+
enumerable:!(r=Yi(e,o))||r.enumerable});return t};var ce=(t,e,n)=>(n=t!=null?Xi(Qi(t)):{},ta(e||!t||!t.__esModule?Zn(n,"default",{value:t,enumerable:!0}):n,t));var te=$((wm,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,
|
|
7
7
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
8
|
-
"websocket"),NOOP:()=>{}}});var Ye=$((
|
|
9
|
-
if(t.length===1)return t[0];let
|
|
10
|
-
return
|
|
11
|
-
for(let
|
|
12
|
-
t.byteOffset+t.length)}function
|
|
13
|
-
e=new
|
|
14
|
-
{concat:
|
|
15
|
-
exports.mask=function(e,r,
|
|
16
|
-
|
|
17
|
-
this[
|
|
18
|
-
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[
|
|
19
|
-
from([0,0,255,255]),Et=Symbol("permessage-deflate"),re=Symbol("total-length"),
|
|
20
|
-
|
|
8
|
+
"websocket"),NOOP:()=>{}}});var Ye=$((ym,Ct)=>{"use strict";var{EMPTY_BUFFER:ga}=te(),gr=Buffer[Symbol.species];function va(t,e){if(t.length===0)return ga;
|
|
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 wa(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}Ct.exports=
|
|
14
|
+
{concat:va,mask:io,toArrayBuffer:wa,toBuffer:vr,unmask:ao};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=M("bufferutil");Ct.
|
|
15
|
+
exports.mask=function(e,n,r,o,s){s<48?io(e,n,r,o,s):t.mask(e,n,r,o,s)},Ct.exports.unmask=function(e,n){e.length<32?ao(e,
|
|
16
|
+
n):t.unmask(e,n)}}catch{}});var lo=$((Im,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=$((Sm,ho)=>{"use strict";var Ze=M("zlib"),po=Ye(),ya=lo(),{kStatusCode:fo}=te(),Ia=Buffer[Symbol.species],Sa=Buffer.
|
|
19
|
+
from([0,0,255,255]),Et=Symbol("permessage-deflate"),re=Symbol("total-length"),Ae=Symbol("callback"),ue=Symbol("buffers"),
|
|
20
|
+
Oe=Symbol("error"),_t,Ir=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,!_t){let
|
|
23
|
-
10;_t=new
|
|
22
|
+
null,this._inflate=null,this.params=null,!_t){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
|
|
23
|
+
10;_t=new ya(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[
|
|
29
|
-
null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let
|
|
30
|
-
|
|
31
|
-
!1||typeof
|
|
32
|
-
"number"&&(typeof o.client_max_window_bits=="number"?
|
|
33
|
-
if(!
|
|
34
|
-
!0),
|
|
35
|
-
|
|
36
|
-
!0||
|
|
37
|
-
!1&&
|
|
38
|
-
typeof this._options.clientMaxWindowBits=="number"&&(
|
|
39
|
-
_options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&
|
|
40
|
-
clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return
|
|
41
|
-
return e.forEach(
|
|
42
|
-
y a single value`);if(o=o[0],
|
|
43
|
-
`Invalid value for parameter "${
|
|
44
|
-
"${
|
|
45
|
-
nvalid value for parameter "${
|
|
46
|
-
if(o!==!0)throw new TypeError(`Invalid value for parameter "${
|
|
47
|
-
r
|
|
48
|
-
e,
|
|
28
|
+
_inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ae];this._deflate.close(),this._deflate=
|
|
29
|
+
null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let n=this._options,
|
|
30
|
+
r=e.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===
|
|
31
|
+
!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits==
|
|
32
|
+
"number"&&(typeof o.client_max_window_bits=="number"?n.clientMaxWindowBits>o.client_max_window_bits:!o.client_max_window_bits)));
|
|
33
|
+
if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=
|
|
34
|
+
!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=
|
|
35
|
+
n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===
|
|
36
|
+
!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let n=e[0];if(this._options.clientNoContextTakeover===
|
|
37
|
+
!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)
|
|
38
|
+
typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this.
|
|
39
|
+
_options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.
|
|
40
|
+
clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(e){
|
|
41
|
+
return e.forEach(n=>{Object.keys(n).forEach(r=>{let o=n[r];if(o.length>1)throw new Error(`Parameter "${r}" must have onl\
|
|
42
|
+
y a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(
|
|
43
|
+
`Invalid value for parameter "${r}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter\
|
|
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
|
+
nvalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){
|
|
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){_t.add(o=>{this._decompress(e,n,(s,i)=>{o(),r(s,i)})})}compress(e,n,r){_t.add(o=>{this._compress(
|
|
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
49
|
window_bits`,i=typeof this.params[s]!="number"?Ze.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ze.createInflateRaw(
|
|
50
50
|
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Et]=this,this._inflate[re]=0,this._inflate[ue]=[],this.
|
|
51
|
-
_inflate.on("error",
|
|
52
|
-
this._inflate.flush(()=>{let s=this._inflate[
|
|
51
|
+
_inflate.on("error",ba),this._inflate.on("data",mo)}this._inflate[Ae]=r,this._inflate.write(e),n&&this._inflate.write(Sa),
|
|
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
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]=[],
|
|
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){
|
|
55
55
|
let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
|
|
56
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",
|
|
58
|
-
flush(Ze.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=
|
|
59
|
-
buffer,s.byteOffset,s.length-4)),this._deflate[
|
|
60
|
-
_context_takeover`]&&this._deflate.reset(),
|
|
61
|
-
function
|
|
62
|
-
new RangeError("Max payload size exceeded"),this[
|
|
63
|
-
"data",
|
|
64
|
-
t)}});var
|
|
57
|
+
this._deflate[re]=0,this._deflate[ue]=[],this._deflate.on("data",xa)}this._deflate[Ae]=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 Ia(s.
|
|
59
|
+
buffer,s.byteOffset,s.length-4)),this._deflate[Ae]=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 xa(t){this[ue].push(t),this[re]+=t.length}
|
|
61
|
+
function mo(t){if(this[re]+=t.length,this[Et]._maxPayload<1||this[re]<=this[Et]._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[Et]._inflate=null,this[Oe]){this[Ae](this[Oe]);return}t[fo]=1007,this[Ae](
|
|
64
|
+
t)}});var Pe=$((xm,At)=>{"use strict";var{isUtf8:go}=M("buffer"),{hasBlob:Ta}=te(),Ca=[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
|
|
67
|
-
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function
|
|
68
|
-
0)
|
|
69
|
-
if(
|
|
70
|
-
|
|
71
|
-
240)===128||t[
|
|
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 _a(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)===
|
|
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
|
+
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
|
+
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 Ta&&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")}At.exports={isBlob:
|
|
74
|
-
exports.isValidUTF8=function(t){return t.length<24?
|
|
75
|
-
At.exports.isValidUTF8=function(e){return e.length<32?
|
|
76
|
-
{concat:
|
|
77
|
-
|
|
78
|
-
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||
|
|
73
|
+
"Blob"||t[Symbol.toStringTag]==="File")}At.exports={isBlob:Ea,isValidStatusCode:_a,isValidUTF8:Sr,tokenChars:Ca};if(go)At.
|
|
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
|
+
At.exports.isValidUTF8=function(e){return e.length<32?Sr(e):t(e)}}catch{}});var _r=$((bm,bo)=>{"use strict";var{Writable:Aa}=M("stream"),vo=Re(),{BINARY_TYPES:Oa,EMPTY_BUFFER:wo,kStatusCode:Ra,kWebSocket:Pa}=te(),
|
|
76
|
+
{concat:xr,toArrayBuffer:ka,unmask:Ma}=Ye(),{isValidStatusCode:Na,isValidUTF8:yo}=Pe(),Ot=Buffer[Symbol.species],G=0,Io=1,
|
|
77
|
+
So=2,xo=3,br=4,Tr=5,Rt=6,Cr=class extends Aa{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
|
|
78
|
+
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Oa[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[
|
|
80
|
+
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Pa]=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,r
|
|
83
|
-
if(this._opcode===8&&this._state==G)return
|
|
84
|
-
|
|
85
|
-
e.length,this._buffers.push(e),this.startLoop(
|
|
86
|
-
_buffers.shift();if(e<this._buffers[0].length){let
|
|
87
|
-
e,
|
|
88
|
-
|
|
89
|
-
e,
|
|
90
|
-
break;case
|
|
91
|
-
this.getData(e);break;case
|
|
92
|
-
2){this._loop=!1;return}let
|
|
93
|
-
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let
|
|
94
|
-
let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(
|
|
95
|
-
128)===128,this._opcode=
|
|
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){
|
|
84
|
+
r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=
|
|
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 br:
|
|
91
|
+
this.getData(e);break;case Tr:case Rt:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
|
|
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]){
|
|
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
|
+
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,
|
|
97
97
|
"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||
|
|
98
98
|
this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ER\
|
|
99
|
-
R_INVALID_OPCODE");e(o);return}this._compressed=
|
|
100
|
-
RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(
|
|
99
|
+
R_INVALID_OPCODE");e(o);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(
|
|
100
|
+
RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(r){let o=this.createError(RangeError,"RSV1 mu\
|
|
101
101
|
st be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===
|
|
102
102
|
1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAY\
|
|
103
103
|
LOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVAL\
|
|
104
|
-
ID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(
|
|
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=
|
|
107
|
+
e(o);return}this._payloadLength===126?this._state=Io:this._payloadLength===127?this._state=So: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
|
-
if(this._bufferedBytes<8){this._loop=!1;return}let
|
|
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
|
-
_LENGTH");e(o);return}this._payloadLength=
|
|
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
|
-
0)){let
|
|
114
|
-
this._masked?this._state=
|
|
115
|
-
4),this._state=
|
|
116
|
-
return}
|
|
117
|
-
|
|
118
|
-
let
|
|
119
|
-
_compressed){this._state=
|
|
120
|
-
push(
|
|
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=br}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
|
|
115
|
+
4),this._state=br}getData(e){let n=wo;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
|
|
116
|
+
return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
|
|
117
|
+
Ma(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
|
|
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=Tr,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(
|
|
121
121
|
o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(
|
|
122
|
-
RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
123
|
-
this.dataMessage(
|
|
124
|
-
|
|
125
|
-
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=
|
|
126
|
-
_binaryType==="blob"?o=new Blob(
|
|
127
|
-
Rt,setImmediate(()=>{this.emit("message",o,!0),this._state=G,this.startLoop(e)}))}else{let o=
|
|
128
|
-
!
|
|
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,
|
|
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=ka(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===Tr||
|
|
129
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,
|
|
131
|
-
emit("conclude",1005,
|
|
132
|
-
tatus code ${
|
|
133
|
-
_skipUTF8Validation&&!
|
|
134
|
-
this._loop=!1,this.emit("conclude",
|
|
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(!Na(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
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(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"kByteLength"),
|
|
140
|
-
|
|
141
|
-
_bufferedBytes=0,this._queue=[],this._state=Z,this.onerror=
|
|
142
|
-
(n
|
|
143
|
-
we[
|
|
144
|
-
i)&&
|
|
145
|
-
a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=
|
|
146
|
-
c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),
|
|
147
|
-
|
|
148
|
-
if(typeof e!="number"||!
|
|
149
|
-
length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(
|
|
150
|
-
essage must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof
|
|
151
|
-
|
|
152
|
-
length,fin:!0,generateMask:this._generateMask,mask:
|
|
153
|
-
Z?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,r
|
|
154
|
-
byteLength(e),s=!1):
|
|
155
|
-
ust not be greater than 125 bytes");let i={[W]:o,fin:!0,generateMask:this._generateMask,mask:
|
|
156
|
-
opcode:9,readOnly:s,rsv1:!1};
|
|
157
|
-
this._state!==Z?this.enqueue([this.dispatch,e,!1,i,
|
|
158
|
-
string"?(o=Buffer.byteLength(e),s=!1):
|
|
159
|
-
"The data size must not be greater than 125 bytes");let i={[W]:o,fin:!0,generateMask:this._generateMask,mask:
|
|
160
|
-
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};
|
|
161
|
-
e,!1,i,
|
|
162
|
-
extensionName],s=
|
|
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[Ra]=o,i}};bo.exports=Cr});var Or=$((Cm,_o)=>{"use strict";var{Duplex:Tm}=M("stream"),{randomFillSync:ja}=M("crypto"),{types:{isUint8Array:Da}}=M("util"),
|
|
138
|
+
To=Re(),{EMPTY_BUFFER:za,kWebSocket:La,NOOP:Ua}=te(),{isBlob:ke,isValidStatusCode:Fa}=Pe(),{mask:Co,toBuffer:ve}=Ye(),W=Symbol(
|
|
139
|
+
"kByteLength"),qa=Buffer.alloc(4),Pt=8*1024,we,Me=Pt,Z=0,$a=1,Ba=2,Er=class t{constructor(e,n,r){this._extensions=n||{},
|
|
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=Ua,this[La]=void 0}static frame(e,n){let r,o=!1,s=2,i=!1;n.mask&&
|
|
142
|
+
(r=n.maskBuffer||qa,n.generateMask?n.generateMask(r):(Me===Pt&&(we===void 0&&(we=Buffer.alloc(Pt)),ja(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):
|
|
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
|
+
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?(Co(e,r,d,s,a),[d]):(Co(e,r,e,0,a),[d,e])):[d,e]}close(e,n,r,o){let s;if(e===void 0)s=za;else{
|
|
148
|
+
if(typeof e!="number"||!Fa(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.
|
|
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
|
+
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(Da(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[W]:s.
|
|
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[To.
|
|
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
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),
|
|
165
|
-
!0);let d={[W]:a,fin:
|
|
166
|
-
|
|
167
|
-
_state!==Z?this.enqueue([this.dispatch,e,this._compress,d,
|
|
168
|
-
_bufferedBytes+=
|
|
169
|
-
closed while the blob was being read");process.nextTick(
|
|
170
|
-
dispatch(i,r,
|
|
171
|
-
if(!
|
|
172
|
-
|
|
173
|
-
pressed");
|
|
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=Ba,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(Ar,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(Ha,this,s,o)})}dispatch(e,n,r,o){
|
|
171
|
+
if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[To.extensionName];this._bufferedBytes+=r[W],this._state=
|
|
172
|
+
$a,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");Ar(this,c,o);return}this._bufferedBytes-=r[W],this._state=Z,r.readOnly=!1,this.sendFrame(t.frame(a,r),o),this.
|
|
174
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,
|
|
176
|
-
2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],
|
|
177
|
-
|
|
178
|
-
length-1];typeof s=="function"&&s(e)}}function
|
|
179
|
-
"kError"),
|
|
180
|
-
this[Ne]=null,this[
|
|
181
|
-
arget",{enumerable:!0});Object.defineProperty(ne.prototype,"type",{enumerable:!0});var ye=class extends ne{constructor(e,
|
|
182
|
-
super(e),this[
|
|
183
|
-
return this[
|
|
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)}};_o.exports=Er;function Ar(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 Ha(t,e,n){Ar(t,e,n),t.onerror(e)}});var jo=$((_m,No)=>{"use strict";var{kForOnEventAttribute:Qe,kListener:Rr}=te(),Eo=Symbol("kCode"),Ao=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[Eo]=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[Eo]}get reason(){return this[Po]}get wasClean(){return this[Mo]}};Object.defineProperty(ye.prototype,"code",
|
|
184
184
|
{enumerable:!0});Object.defineProperty(ye.prototype,"reason",{enumerable:!0});Object.defineProperty(ye.prototype,"wasCle\
|
|
185
|
-
an",{enumerable:!0});var
|
|
186
|
-
|
|
187
|
-
"error",{enumerable:!0});Object.defineProperty(
|
|
188
|
-
super(e),this[
|
|
189
|
-
var
|
|
190
|
-
age")
|
|
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[Ao]=n.data===void 0?null:n.data}get data(){return this[Ao]}};Object.defineProperty(et.prototype,"data",{enumerable:!0});
|
|
189
|
+
var Va={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
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")
|
|
193
|
-
"open")
|
|
194
|
-
this.on(t,
|
|
195
|
-
|
|
196
|
-
t.handleEvent?t.handleEvent.call(t,
|
|
197
|
-
let e=Object.create(null),
|
|
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:Va,MessageEvent:et};function kt(t,e,n){typeof t=="object"&&
|
|
196
|
+
t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Mt=$((Em,Do)=>{"use strict";var{tokenChars:tt}=Pe();function ee(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function Ga(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
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
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,
|
|
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
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(
|
|
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
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:
|
|
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
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
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
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);
|
|
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
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,
|
|
211
|
-
l.replace(/\\/g,"")):ee(
|
|
212
|
-
|
|
213
|
-
=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}
|
|
214
|
-
{Duplex:
|
|
215
|
-
EMPTY_BUFFER:
|
|
216
|
-
removeEventListener:
|
|
217
|
-
NG","OPEN","CLOSING","CLOSED"],
|
|
218
|
-
_binaryType=
|
|
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 Wa(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(
|
|
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:Wa,parse:Ga}});var zt=$((Rm,Ko)=>{"use strict";var Ka=M("events"),Ja=M("https"),Xa=M("http"),Uo=M("net"),Ya=M("tls"),{randomBytes:Za,createHash:Qa}=M("crypto"),
|
|
214
|
+
{Duplex:Am,Readable:Om}=M("stream"),{URL:Pr}=M("url"),le=Re(),ec=_r(),tc=Or(),{isBlob:rc}=Pe(),{BINARY_TYPES:zo,CLOSE_TIMEOUT:nc,
|
|
215
|
+
EMPTY_BUFFER:Nt,GUID:oc,kForOnEventAttribute:kr,kListener:sc,kStatusCode:ic,kWebSocket:L,NOOP:Fo}=te(),{EventTarget:{addEventListener:ac,
|
|
216
|
+
removeEventListener:cc}}=jo(),{format:dc,parse:uc}=Mt(),{toBuffer:lc}=Ye(),qo=Symbol("kAborted"),Mr=[8,13],oe=["CONNECTI\
|
|
217
|
+
NG","OPEN","CLOSING","CLOSED"],pc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends Ka{constructor(e,n,r){super(),this.
|
|
218
|
+
_binaryType=zo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Nt,this._closeTimer=
|
|
219
219
|
null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=
|
|
220
|
-
null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,
|
|
221
|
-
|
|
222
|
-
|
|
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=
|
|
223
223
|
e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+
|
|
224
224
|
this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){
|
|
225
225
|
return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){
|
|
226
|
-
return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r
|
|
227
|
-
{allowSynchronousEvents:
|
|
228
|
-
maxBufferedChunks:
|
|
229
|
-
s=new
|
|
230
|
-
o.on("conclude",
|
|
231
|
-
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),
|
|
232
|
-
"end",
|
|
226
|
+
return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,n,r){let o=new ec(
|
|
227
|
+
{allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,
|
|
228
|
+
maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),
|
|
229
|
+
s=new tc(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",hc),o.on("drain",gc),o.on("error",vc),o.on("message",wc),o.on("ping",yc),o.on("pong",Ic),s.onerror=Sc,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
233
|
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[le.extensionName]&&this._extensions[le.extensionName].
|
|
234
|
-
cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,
|
|
234
|
+
cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){
|
|
235
235
|
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){B(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
|
-
_writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
_writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,n,!this._isServer,
|
|
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){
|
|
240
240
|
if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="func\
|
|
241
|
-
tion"?(
|
|
242
|
-
Nr(this,e,
|
|
243
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(
|
|
244
|
-
function"&&(n
|
|
245
|
-
(
|
|
246
|
-
_paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r
|
|
247
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof
|
|
248
|
-
r"&&(e=e.toString()),this.readyState!==t.OPEN){Nr(this,e,
|
|
249
|
-
compress:!0,fin:!0,...
|
|
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)
|
|
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.
|
|
246
|
+
_paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,r){if(this.readyState===t.CONNECTING)
|
|
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
250
|
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){B(this,this._req,"WebSocket was closed before the connection w\
|
|
251
251
|
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(k,"CO\
|
|
252
252
|
NNECTING",{enumerable:!0,value:oe.indexOf("CONNECTING")});Object.defineProperty(k.prototype,"CONNECTING",{enumerable:!0,
|
|
@@ -256,143 +256,143 @@ k.prototype,"OPEN",{enumerable:!0,value:oe.indexOf("OPEN")});Object.defineProper
|
|
|
256
256
|
k,"CLOSED",{enumerable:!0,value:oe.indexOf("CLOSED")});Object.defineProperty(k.prototype,"CLOSED",{enumerable:!0,value:oe.
|
|
257
257
|
indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
|
|
258
258
|
defineProperty(k.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(k.prototype,
|
|
259
|
-
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[
|
|
260
|
-
listeners(t))if(
|
|
261
|
-
prototype.addEventListener=
|
|
262
|
-
autoPong:!0,closeTimeout:
|
|
263
|
-
perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...
|
|
264
|
-
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!
|
|
265
|
-
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${
|
|
266
|
-
", ")})`);let s;if(e instanceof
|
|
259
|
+
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[kr])return e[sc];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=ac;k.prototype.removeEventListener=cc;Ko.exports=k;function $o(t,e,n,r){let o={allowSynchronousEvents:!0,
|
|
262
|
+
autoPong:!0,closeTimeout:nc,protocolVersion:Mr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
|
|
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===
|
|
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 b=new SyntaxError(
|
|
270
|
-
c);if(t._redirects===0)throw b;jt(t,b);return}let d=i?443:80,p=
|
|
271
|
-
v;if(o.createConnection=o.createConnection||(i?
|
|
270
|
+
c);if(t._redirects===0)throw b;jt(t,b);return}let d=i?443:80,p=Za(16).toString("base64"),m=i?Ja.request:Xa.request,l=new Set,
|
|
271
|
+
v;if(o.createConnection=o.createConnection||(i?mc:fc),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
|
|
272
272
|
startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec\
|
|
273
273
|
-WebSocket-Key":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"]=
|
|
275
|
-
offer()})),
|
|
276
|
-
uplicated subprotocol was specified");l.add(b)}o.headers["Sec-WebSocket-Protocol"]=
|
|
274
|
+
(v=new le({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=dc({[le.extensionName]:v.
|
|
275
|
+
offer()})),n.length){for(let b of n){if(typeof b!="string"||!pc.test(b)||l.has(b))throw new SyntaxError("An invalid or d\
|
|
276
|
+
uplicated subprotocol was specified");l.add(b)}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
278
|
:${s.password}`),a){let b=o.path.split(":");o.socketPath=b[0],o.path=b[1]}let x;if(o.followRedirects){if(t._redirects===
|
|
279
|
-
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let b=
|
|
280
|
-
headers:{}},b)for(let[O,P]of Object.entries(b))
|
|
279
|
+
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let b=r&&r.headers;if(r={...r,
|
|
280
|
+
headers:{}},b)for(let[O,P]of Object.entries(b))r.headers[O.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let b=a?
|
|
281
281
|
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!b||
|
|
282
282
|
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,b||delete o.headers.host,o.auth=void 0)}
|
|
283
|
-
o.auth&&!
|
|
283
|
+
o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),x=t._req=m(o),
|
|
284
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",b=>{x===null||x[
|
|
285
|
+
timed out")}),x.on("error",b=>{x===null||x[qo]||(x=t._req=null,jt(t,b))}),x.on("response",b=>{let O=b.headers.location,P=b.
|
|
286
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
|
|
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
288
|
t.emit("unexpected-response",x,b)||B(t,x,`Unexpected server response: ${b.statusCode}`)}),x.on("upgrade",(b,O,P)=>{if(t.
|
|
289
289
|
emit("upgrade",b),t.readyState!==k.CONNECTING)return;x=t._req=null;let j=b.headers.upgrade;if(j===void 0||j.toLowerCase()!==
|
|
290
|
-
"websocket"){B(t,O,"Invalid Upgrade header");return}let D=
|
|
291
|
-
socket-accept"]!==D){B(t,O,"Invalid Sec-WebSocket-Accept header");return}let
|
|
292
|
-
void 0?l.size?l.has(
|
|
293
|
-
size&&(J="Server sent no subprotocol"),J){B(t,O,J);return}
|
|
290
|
+
"websocket"){B(t,O,"Invalid Upgrade header");return}let D=Qa("sha1").update(p+oc).digest("base64");if(b.headers["sec-web\
|
|
291
|
+
socket-accept"]!==D){B(t,O,"Invalid Sec-WebSocket-Accept header");return}let U=b.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=b.headers["sec-websocket-extensions"];
|
|
294
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=
|
|
295
|
+
try{q=uc(H)}catch{B(t,O,"Invalid Sec-WebSocket-Extensions header");return}let ae=Object.keys(q);if(ae.length!==1||ae[0]!==
|
|
296
296
|
le.extensionName){B(t,O,"Server indicated an extension that was not requested");return}try{v.accept(q[le.extensionName])}catch{
|
|
297
297
|
B(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[le.extensionName]=v}t.setSocket(O,P,{allowSynchronousEvents:o.
|
|
298
298
|
allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
|
|
299
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
|
|
301
|
-
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=
|
|
302
|
-
t._readyState=k.CLOSING;let
|
|
303
|
-
destroyed&&e.socket.destroy(),process.nextTick(jt,t,
|
|
304
|
-
se",t.emitClose.bind(t)))}function Nr(t,e,
|
|
305
|
-
t._bufferedAmount+=
|
|
306
|
-
nextTick(r
|
|
307
|
-
(
|
|
308
|
-
t.isPaused||t._socket.resume()}function
|
|
309
|
-
process.nextTick(
|
|
310
|
-
emitClose()}function
|
|
311
|
-
|
|
312
|
-
k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,
|
|
313
|
-
e.emit("error",t)))}function
|
|
314
|
-
let t=this[
|
|
300
|
+
k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function fc(t){return t.path=t.socketPath,Uo.connect(t)}function mc(t){
|
|
301
|
+
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Uo.isIP(t.host)?"":t.host),Ya.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=rc(e)?e.size:lc(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 hc(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 gc(){let t=this[L];
|
|
308
|
+
t.isPaused||t._socket.resume()}function vc(t){let e=this[L];e._socket[L]!==void 0&&(e._socket.removeListener("data",Dt),
|
|
309
|
+
process.nextTick(Bo,e._socket),e.close(t[ic])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Lo(){this[L].
|
|
310
|
+
emitClose()}function wc(t,e){this[L].emit("message",t,e)}function yc(t){let e=this[L];e._autoPong&&e.pong(t,!this._isServer,
|
|
311
|
+
Fo),e.emit("ping",t)}function Ic(t){this[L].emit("pong",t)}function Bo(t){t.resume()}function Sc(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
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[
|
|
316
|
+
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[L]=void 0,clearTimeout(
|
|
317
317
|
t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
|
|
318
|
-
"error",
|
|
319
|
-
t._readyState=k.CLOSING,t._receiver.end(),this.end()}function
|
|
320
|
-
"error",
|
|
321
|
-
this._writableState.finished&&this.destroy()}function
|
|
322
|
-
"error")===0&&this.emit("error",t)}function
|
|
323
|
-
return t.on("message",function(s,i){let a=!i&&
|
|
324
|
-
error",function(s){
|
|
325
|
-
if(t.readyState===t.CLOSED){s(o),process.nextTick(
|
|
326
|
-
lose",function(){i||s(o),process.nextTick(
|
|
327
|
-
t.once("open",function(){
|
|
328
|
-
endEmitted&&
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
let i=t.charCodeAt(o);if(
|
|
332
|
-
44){if(
|
|
333
|
-
`The "${a}" subprotocol is duplicated`);e.add(a),r
|
|
334
|
-
if(
|
|
335
|
-
`The "${s}" subprotocol is duplicated`);return e.add(s),e}
|
|
336
|
-
Ie=
|
|
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=$((km,Yo)=>{"use strict";var Pm=zt(),{Duplex:xc}=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 Tc(t,e){let n=!0,r=new xc({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
|
|
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
|
+
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){
|
|
327
|
+
t.once("open",function(){r._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),r._readableState.
|
|
328
|
+
endEmitted&&r.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},
|
|
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=Tc});var jr=$((Mm,Qo)=>{"use strict";var{tokenChars:Cc}=Pe();function _c(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===
|
|
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
|
+
`The "${a}" subprotocol is duplicated`);e.add(a),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
|
|
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:_c}});var is=$((jm,ss)=>{"use strict";var Ec=M("events"),Lt=M("http"),{Duplex:Nm}=M("stream"),{createHash:Ac}=M("crypto"),es=Mt(),
|
|
336
|
+
Ie=Re(),Oc=jr(),Rc=zt(),{CLOSE_TIMEOUT:Pc,GUID:kc,kWebSocket:Mc}=te(),Nc=/^[+/0-9A-Za-z]{22}==$/,ts=0,rs=1,os=2,Dr=class extends Ec{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:
|
|
339
|
-
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:
|
|
338
|
+
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Pc,verifyClient:null,
|
|
339
|
+
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Rc,...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((
|
|
341
|
+
, or "noServer" options must be specified');if(e.port!=null?(this._server=Lt.createServer((r,o)=>{let s=Lt.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
|
-
backlog,
|
|
344
|
-
|
|
345
|
-
o,s,i,
|
|
346
|
-
!1),this.options=e,this._state=
|
|
347
|
-
er" mode');return this._server?this._server.address():null}close(e){if(this._state===
|
|
348
|
-
"The server is not running"))}),process.nextTick(rt,this);return}if(e&&this.once("close",e),this._state!==
|
|
349
|
-
|
|
350
|
-
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(rt,this):process.nextTick(rt,this);else{let
|
|
351
|
-
_server;this._removeListeners(),this._removeListeners=this._server=null,
|
|
352
|
-
options.path){let
|
|
353
|
-
|
|
354
|
-
"GET"){Se(this,e,
|
|
355
|
-
lid Upgrade header");return}if(s===void 0||!
|
|
356
|
-
if(a!==13&&a!==8){Se(this,e,
|
|
357
|
-
if(!this.shouldHandle(e)){nt(
|
|
358
|
-
c)}catch{Se(this,e,
|
|
343
|
+
backlog,n)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=
|
|
344
|
+
jc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
|
|
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.
|
|
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||!Nc.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=Oc.parse(
|
|
358
|
+
c)}catch{Se(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],m={};
|
|
359
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=
|
|
361
|
-
Se(this,e,
|
|
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={
|
|
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,b,O)=>{if(!v)return nt(
|
|
364
|
-
m,s,d,e,r,
|
|
365
|
-
if(!s.readable||!s.writable)return s.destroy();if(s[
|
|
366
|
-
e with the same socket, possibly due to a misconfiguration");if(this._state>
|
|
367
|
-
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${
|
|
368
|
-
se64")}`],p=new this.options.WebSocket(null,void 0,this.options);if(
|
|
369
|
-
handleProtocols(
|
|
370
|
-
let m=e[Ie.extensionName].params,l=
|
|
363
|
+
options.verifyClient.length===2){this.options.verifyClient(l,(v,x,b,O)=>{if(!v)return nt(n,x||401,b,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[Mc])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: ${Ac("sha1").update(n+kc).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=
|
|
371
371
|
e}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
372
372
|
`).join(`\r
|
|
373
|
-
`)),s.removeListener("error",
|
|
373
|
+
`)),s.removeListener("error",ns),p.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
|
|
374
374
|
options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.
|
|
375
375
|
options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on("close",()=>{this.clients.delete(p),this._shouldEmitClose&&
|
|
376
|
-
!this.clients.size&&process.nextTick(rt,this)})),a(p,o)}};
|
|
377
|
-
|
|
378
|
-
function
|
|
379
|
-
l","Content-Length":Buffer.byteLength(
|
|
380
|
-
`+Object.keys(
|
|
376
|
+
!this.clients.size&&process.nextTick(rt,this)})),a(p,o)}};ss.exports=Dr;function jc(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
|
|
380
|
+
`+Object.keys(r).map(o=>`${o}: ${r[o]}`).join(`\r
|
|
381
381
|
`)+`\r
|
|
382
382
|
\r
|
|
383
|
-
`+
|
|
384
|
-
"wsClientError",i,
|
|
385
|
-
e===null}var
|
|
386
|
-
{text:"Assistant stopped with an error.",messageCode:"assistant.turn.failed"})});function It(t){return E(t)?{...t}:{}}var
|
|
387
|
-
status=Number(e)||500,this.statusCode=this.status,this.code=
|
|
388
|
-
(this.messageCode=String(
|
|
389
|
-
{}}};var
|
|
390
|
-
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var
|
|
391
|
-
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),
|
|
392
|
-
|
|
393
|
-
let{stdout:e}=await
|
|
394
|
-
JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION_COMMAND_HASH",label:
|
|
395
|
-
native_process_identity_unavailable",platform:o=process.platform,ps:s=
|
|
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 Bp=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function _(t,{fallback:e=""}={}){return String(t||"").trim()||e}function E(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 Vp=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 E(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 Sf=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"}),Af=new Set(Object.values(F)),Of=new Set([F.CANCELLED,
|
|
392
|
+
F.COMPLETED,F.FAILED,F.INTERRUPTED,F.TIMED_OUT]),Rf=new Set([F.ACTIVE,F.FINALIZING,F.STARTING]);import{execFile as na}from"node:child_process";import{readFile as fr,readdir as oa}from"node:fs/promises";import{setTimeout as eo}from"node:timers/promises";import{promisify as sa}from"node:util";var ia=sa(na);async function aa(t){
|
|
393
|
+
let{stdout:e}=await ia("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function bt({runtimeTokenEnvironmentName:t="\
|
|
394
|
+
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=aa}={}){let a=o==="darwin"?100:25,c=1,d=Object.freeze(
|
|
396
396
|
{linux:"linux-proc",darwin:"darwin"}),p=d[o]||"",m=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),l=Object.freeze(
|
|
397
397
|
{ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});function v(w={}){return!!(Number.
|
|
398
398
|
isSafeInteger(Number(w.pid))&&Number(w.pid)>0&&D(w.processIdentity)&&[m.RUNNING,m.STOPPED].includes(w.processState))}function x(w){
|
|
@@ -406,40 +406,40 @@ test(T)?null:{parentPid:y,processGroupId:S,startTimeTicks:T,state:g}}function j(
|
|
|
406
406
|
u.commandHash),platform:I(u.platform),runtimeToken:I(u.runtimeToken),startTimeTicks:I(u.startTimeTicks),version:Number(u.
|
|
407
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
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
|
|
410
|
-
let w=[],u=await
|
|
411
|
-
continue;let h=Number(f.name),g=await
|
|
412
|
-
let S=null,T=!0;try{S=await
|
|
413
|
-
S.toString("utf8").split("\0"):[];w.push({...y,commandHash:
|
|
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 oa("/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,T=!0;try{S=await fr(`/proc/${f.name}/environ`)}catch(A){if(String(A?.code||"")==="ENOENT")continue;T=!1}let R=T?
|
|
413
|
+
S.toString("utf8").split("\0"):[];w.push({...y,commandHash:U(R,e),environmentReadable:T,pid:h,runtimeToken:U(R,t)})}return w}
|
|
414
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
415
|
exec(String(w).trim()),f=u?H.indexOf(u[1]):-1;if(f<0)return"";let[,,h,g,y,S,T]=u.map(Number);return String(Date.UTC(T,f,
|
|
416
416
|
h,g,y,S)/1e3)}function ae(w=""){let u=new Map;for(let f of String(w).split(`
|
|
417
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
|
|
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
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
420
|
,pgid=,uid=,stat=,lstart="]),s(u),s(["-E",...u])]),y=ae(h),S=ae(g),T=[];for(let R of String(f).split(`
|
|
421
421
|
`)){let A=/^\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(!A||A[4].startsWith(
|
|
422
|
-
"Z"))continue;let X=Number(A[1]),Y=Number(A[3])===w?me(y.get(X),S.get(X)):null;T.push({commandHash:
|
|
423
|
-
pid:X,processGroupId:Number(A[2]),runtimeToken:
|
|
422
|
+
"Z"))continue;let X=Number(A[1]),Y=Number(A[3])===w?me(y.get(X),S.get(X)):null;T.push({commandHash:U(Y||[],e),environmentReadable:!!Y,
|
|
423
|
+
pid:X,processGroupId:Number(A[2]),runtimeToken:U(Y||[],t),startTimeTicks:q(A[5])})}return T}function ht(w){let u=Object.
|
|
424
424
|
values(l).includes(w?.status)?w.status:l.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(w?.processGroupIds)?
|
|
425
425
|
w.processGroupIds:[]).map(Number).filter(f=>Number.isSafeInteger(f)&&f>0))],status:u}}async function gt(w={}){if(!v(w))return{
|
|
426
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
|
|
427
|
+
f=u.platform!==p?null:o==="darwin"?await We().catch(()=>null):await J();if(!f)return{processGroupIds:[],status:l.AMBIGUOUS};
|
|
428
428
|
let h=Number(w.pid),g=f.filter(({processGroupId:A})=>A===h),y=[],S=g.some(({environmentReadable:A})=>!A);for(let A of f)
|
|
429
429
|
A.environmentReadable&&A.runtimeToken===u.runtimeToken&&A.commandHash===u.commandHash&&y.push(A);let T=y.find(({pid:A})=>A===
|
|
430
430
|
h);if(T&&T.startTimeTicks!==u.startTimeTicks)return{processGroupIds:[],status:l.AMBIGUOUS};if(y.length===0)return S?{processGroupIds:[],
|
|
431
431
|
status:l.AMBIGUOUS}:{processGroupIds:[],status:g.length>0||b(h)?l.MISMATCH:l.ABSENT};let R=[...new Set(y.map(({processGroupId:A})=>A))];
|
|
432
|
-
for(let A of R)if(f.filter(Y=>Y.processGroupId===A).some(Y=>!Y.environmentReadable||!y.some(({pid:
|
|
432
|
+
for(let A of R)if(f.filter(Y=>Y.processGroupId===A).some(Y=>!Y.environmentReadable||!y.some(({pid:Ji})=>Ji===Y.pid)))return{
|
|
433
433
|
processGroupIds:[],status:l.AMBIGUOUS};return g.some(A=>!y.some(({pid:X})=>X===A.pid))?{processGroupIds:[],status:l.AMBIGUOUS}:
|
|
434
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
|
|
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
436
|
g=await he(w,u);return g}async function _e(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
|
|
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
438
|
Date.now()))),y=await he(w,u);return y}async function wt(w={},u="SIGTERM",f={}){let h=f.signalProcessGroup??O,g=await _e(
|
|
439
439
|
w,f);if(g.status!==l.EXACT)return{inspection:g,signaledProcessGroups:[]};let y=Number(w.pid),S=[...g.processGroupIds.filter(
|
|
440
440
|
R=>R!==y),...g.processGroupIds.filter(R=>R===y)],T=[];for(let R of S){let A=await _e(w,f);if(A.status===l.ABSENT||A.status===
|
|
441
441
|
l.MISMATCH)return{inspection:A,signaledProcessGroups:T};if(A.status!==l.EXACT)return{inspection:A,signaledProcessGroups:T};
|
|
442
|
-
A.processGroupIds.includes(R)&&(h(R,u),T.push(R))}return{inspection:await _e(w,f),signaledProcessGroups:T}}async function
|
|
442
|
+
A.processGroupIds.includes(R)&&(h(R,u),T.push(R))}return{inspection:await _e(w,f),signaledProcessGroups:T}}async function ar(w={},u={}){
|
|
443
443
|
if(!v(w))return{identityStatus:l.INVALID,processExitVerified:!1,stopped:!1};if(w.processState===m.STOPPED&&w.processExitVerifiedAt)
|
|
444
444
|
return{alreadyStopped:!0,identityStatus:l.ABSENT,processExitVerified:!0,stopped:!1};let f=await _e(w,u);if(f.status===l.
|
|
445
445
|
ABSENT||f.status===l.MISMATCH)return{identityStatus:f.status,processExitVerified:!0,stopped:!1};if(f.status!==l.EXACT)return{
|
|
@@ -449,57 +449,57 @@ let g=await vt(w,u,V(u.termTimeoutMs,{fallback:3e3})),y=[...h.signaledProcessGro
|
|
|
449
449
|
w,"SIGKILL",u);if(y=[...new Set([...y,...T.signaledProcessGroups])],T.inspection.status===l.AMBIGUOUS)return{identityStatus:T.
|
|
450
450
|
inspection.status,processExitVerified:!1,signaledProcessGroups:y,stopped:!1};g=await vt(w,u,V(u.killTimeoutMs,{fallback:1e3}))}
|
|
451
451
|
let S=[l.ABSENT,l.MISMATCH].includes(g.status);return{descendantProcessGroups:y.filter(T=>T!==Number(w.pid)),identityStatus:g.
|
|
452
|
-
status,pid:Number(w.pid),processExitVerified:S,signaledProcessGroups:y,stopped:S&&y.length>0}}async function
|
|
453
|
-
"darwin")return P(await
|
|
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
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
|
|
456
|
-
S)&&S.commandHash===g&&S.runtimeToken===y)return S;let T=Number(u),R=p&&Number.isSafeInteger(T)&&T>0?await
|
|
457
|
-
startTimeTicks||R.processGroupId!==T){let A=new Error(`${
|
|
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 T=Number(u),R=p&&Number.isSafeInteger(T)&&T>0?await cr(T):null;if(!R?.
|
|
457
|
+
startTimeTicks||R.processGroupId!==T){let A=new Error(`${n} process identity could not be captured.`);throw A.code=r,A}return{
|
|
458
458
|
commandHash:g,platform:p,runtimeToken:y,startTimeTicks:R.startTimeTicks,version:c}}return Object.freeze({normalize:j,isValid:D,
|
|
459
|
-
normalizeInspection:ht,capture:
|
|
459
|
+
normalizeInspection:ht,capture:dr,inspect:he,stop:ar,isProcessAlive:x})}import{execFile as da}from"node:child_process";import{promisify as ua}from"node:util";var Gf=Object.freeze(["plugins","apps","daemon_auto_start"]);var Wf=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 Qf=ua(da);function ge(t=""){return Array.from(String(t)).some(e=>{let n=e.codePointAt(0);return n<=31||n===127})}var Tt=(t,e,n,r={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(n),...r}),la=Object.freeze([Object.freeze(
|
|
460
460
|
{id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
|
|
461
461
|
webSearch:!1,models:Object.freeze([Tt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
|
|
462
462
|
Tt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai-\
|
|
463
463
|
coding-plan",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
|
|
464
464
|
webSearch:!1,models:Object.freeze([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),
|
|
465
465
|
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([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function Je(t){return
|
|
467
|
-
deepseek:Je("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":Je("zai-coding-plan").baseUrl,zai:Je("zai").baseUrl});var
|
|
468
|
-
UNREACHABLE:"unreachable"}),
|
|
469
|
-
SUSPECT:"suspect"}),Xe=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),
|
|
470
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
471
|
-
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var
|
|
472
|
-
|
|
466
|
+
webSearch:!1,models:Object.freeze([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function Je(t){return la.find(e=>e.id===t)||null}var sm=32*1024*1024,im=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"}),gm=bt();var hr=Object.freeze({UNIX:"unix"});var fa=process.platform==="linux"?107:103,to=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
468
|
+
UNREACHABLE:"unreachable"}),ma=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 ha=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
|
|
471
|
+
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var Dc=ce(Zo(),1),zc=ce(Mt(),1),Lc=ce(Re(),1),Uc=ce(_r(),1),Fc=ce(Or(),1),qc=ce(jr(),1),$c=ce(zt(),1),Bc=ce(is(),1);var Dg=32*1024,zg=2*1024*1024;var Gt=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
472
|
+
sv=new Set(Object.values(Gt)),iv=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
|
|
473
473
|
jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
474
|
-
|
|
474
|
+
av=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),cv=Object.freeze(["accountIde\
|
|
475
475
|
ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
|
|
476
|
-
Hash","terminalEnvHash","toolHomeSource","transport"]),
|
|
476
|
+
Hash","terminalEnvHash","toolHomeSource","transport"]),dv=Object.freeze(["userAgent"]);import md from"node:path";var hd=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
477
477
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
478
478
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
479
479
|
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
|
|
481
|
-
values(t))
|
|
482
|
-
ution policy.");
|
|
483
|
-
["code","details","message","name"].includes(
|
|
484
|
-
.151.0",disabledFeatures:
|
|
480
|
+
"unified_exec_zsh_fork","view_image"]);function Cs(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.
|
|
481
|
+
values(t))Cs(e);return Object.freeze(t)}function gd(t="",e={}){let n=new Error(I(t)||"Codex cannot prove the helper exec\
|
|
482
|
+
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 vd({clientName:t="jskit",minimumVersion:e="0\
|
|
484
|
+
.151.0",disabledFeatures:n=hd,limits:{userAgentMaxLength:r=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
|
|
485
485
|
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:p=256*1024,hookResponseMaxBytes:m=512*
|
|
486
|
-
1024}={},createError:l=
|
|
486
|
+
1024}={},createError:l=gd}={}){let v=new WeakSet;function x(u,f,h){let g=0;try{g=Buffer.byteLength(JSON.stringify(u),"ut\
|
|
487
487
|
f8")}catch{throw l(`Codex helper execution received an invalid ${h}.`)}if(g>f)throw l(`Codex helper execution received a\
|
|
488
488
|
n oversized ${h}.`)}function b(u){if(typeof u?.currentConnectionGeneration!="function")throw l("Codex helper execution c\
|
|
489
489
|
annot verify the app-server connection generation.");let f=u.currentConnectionGeneration();if(!Number.isSafeInteger(f)||
|
|
490
490
|
f<=0)throw l("Codex helper execution found no active app-server connection.");return f}async function O(u){if(typeof u?.
|
|
491
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||!
|
|
492
|
+
currentHelperExecutionContext(),h=I(f?.cwd),g=I(f?.accountIdentitySignature);if(f?.executionMode!=="helper"||!h||!md.isAbsolute(
|
|
493
493
|
h)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw l("Codex helper runtime isolation could not be verified.");return Object.freeze(
|
|
494
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
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>
|
|
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
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
498
|
"function")throw l("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
|
|
499
499
|
let f=I(u.currentServerInfo()?.userAgent),h=j(f);if(!h)throw l("Codex helper execution received an unrecognised app-serv\
|
|
500
500
|
er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),y=P(e),S=h.findIndex((T,R)=>T!==y[R]);if(S!==
|
|
501
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
|
|
502
|
+
nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function U(u=null){if(!yt(
|
|
503
503
|
u?.config))throw l("Codex helper execution could not read the effective app-server configuration.");let f=u.config.mcp_servers;
|
|
504
504
|
if(f==null)return[];if(x(f,i,"MCP configuration"),!yt(f))throw l("Codex helper execution received an invalid MCP server \
|
|
505
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\
|
|
@@ -514,13 +514,13 @@ entory entry.");if(S?.isManaged===!0&&S?.enabled===!0)throw l("Codex helper exec
|
|
|
514
514
|
currentHash:R,enabled:S?.enabled===!0,handlerType:A,isManaged:S?.isManaged===!0,key:T,sourcePath:X}}).sort((S,T)=>S.key.
|
|
515
515
|
localeCompare(T.key)),y=JSON.stringify(g);if(y.length>p)throw l("Codex helper execution received an oversized hook inven\
|
|
516
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(
|
|
517
|
+
mcpServerNames:g=[]}={}){let y={features:Object.fromEntries(n.map(T=>[T,!1])),hooks:{state:Object.fromEntries(h.map(T=>[
|
|
518
518
|
T,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
|
|
519
519
|
include_permissions_instructions:!1,...u?{model_reasoning_effort:u}:{},...f?{model_reasoning_summary:f}:{},mcp_servers:Object.
|
|
520
520
|
fromEntries(g.map(T=>[T,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
|
|
521
521
|
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=
|
|
523
|
-
S),S}function q(u,f,h,{effort:g="",summary:y=""}={}){let S=
|
|
522
|
+
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},S=Cs(y);return v.add(
|
|
523
|
+
S),S}function q(u,f,h,{effort:g="",summary:y=""}={}){let S=U(u),T=J(f,h);return{mcpServerNames:S,hookState:T,config:H({effort:g,
|
|
524
524
|
summary:y,hookKeys:T.hookKeys,mcpServerNames:S})}}async function ae(u,{effort:f="",summary:h=""}={}){if(D(u),typeof u?.readConfig!=
|
|
525
525
|
"function"||typeof u?.listHooks!="function")throw l("Codex helper execution cannot inventory configuration and hooks.");
|
|
526
526
|
let g=await O(u),y=b(u),S=await u.readConfig({cwd:g.cwd,includeLayers:!1});if(b(u)!==y)throw l("Codex app-server reconne\
|
|
@@ -530,10 +530,10 @@ freeze({accountIdentitySignature:g.accountIdentitySignature,config:X,connectionG
|
|
|
530
530
|
fingerprint,hookKeys:Object.freeze([...A.hookKeys]),mcpServerNames:Object.freeze([...R])})}function me(u=null,f=null){return u?.
|
|
531
531
|
accountIdentitySignature===f?.accountIdentitySignature&&u?.connectionGeneration===f?.connectionGeneration&&u?.executionCwd===
|
|
532
532
|
f?.executionCwd&&u?.hookFingerprint===f?.hookFingerprint&&JSON.stringify(u?.mcpServerNames||[])===JSON.stringify(f?.mcpServerNames||
|
|
533
|
-
[])}function
|
|
533
|
+
[])}function We(u,f,h=""){let g=I(h);if(!f)return u.codexAppServerHelperThreadId=g,u.codexAppServerHelperThreadRetired=!0,
|
|
534
534
|
u;let y=l("Codex could not retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return y.
|
|
535
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
|
|
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
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
538
|
`Codex execution surfaces changed while the helper thread was ${y}.`);return Object.freeze({enforcement:S,thread:h,threadId:g})}catch(S){
|
|
539
539
|
await ht({error:S,provider:u,threadId:g})}}async function he(u,f){if(typeof u?.startThread!="function"||typeof u?.deleteThread!=
|
|
@@ -543,414 +543,425 @@ y,"starting")}async function vt(u,f,h){if(typeof u?.resumeThread!="function"||ty
|
|
|
543
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
544
|
r resume requires a controller-owned thread id.");let y=await h(),S=y.enforcement,T=await u.resumeThread(g,y.settings);return gt(
|
|
545
545
|
u,S,T,g,"resuming")}function _e(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
|
|
546
|
+
return q(u,f,h,{effort:g,summary:y}).config}function ar({approvalPolicy:u,baseInstructions:f,config:h,cwd:g,effectiveSettings:y,
|
|
547
547
|
sandbox:S,systemPrompt:T}){return{allowProviderModelFallback:!1,approvalPolicy:u,baseInstructions:f,config:h,cwd:g,systemPrompt:T||
|
|
548
|
-
null,dynamicTools:[],environments:[],model:y.model,runtimeWorkspaceRoots:[],sandbox:S,selectedCapabilityRoots:[]}}function
|
|
549
|
-
return{...u,sessionStartSource:"startup",threadSource:f}}function
|
|
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
550
|
baseInstructions,config:u.config,cwd:u.cwd,systemPrompt:u.systemPrompt,model:u.model,runtimeWorkspaceRoots:u.runtimeWorkspaceRoots,
|
|
551
551
|
sandbox:u.sandbox}}function w({approvalPolicy:u,cwd:f,effectiveSettings:h,outputSchema:g}){let y={approvalPolicy:u,cwd:f,
|
|
552
552
|
environments:[],model:h.model,outputSchema:g,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
|
|
553
553
|
none"};return h.request.reasoning&&(y.effort=h.thinking),y}return Object.freeze({assertCompatibility:D,executionContext:O,
|
|
554
|
-
inspect:ae,configuration:wt,hasConfiguration:_e,threadSettings:
|
|
555
|
-
start:he,resume:vt})}var
|
|
554
|
+
inspect:ae,configuration:wt,hasConfiguration:_e,threadSettings:ar,threadStartSettings:cr,threadResumeSettings:dr,turnSettings:w,
|
|
555
|
+
start:he,resume:vt})}var kv=vd();var eI=Object.freeze({PROVIDER_FAILURE:"provider_failure",RESPONSE_DELIVERY_FAILURE:"response_delivery_failure",SERVICE_RESTART:"\
|
|
556
556
|
service_restart",USER_CANCELLED:"user_cancelled",CONTROL_RECONFIGURATION:"control_reconfiguration",INTERRUPTED:"interrup\
|
|
557
|
-
ted"});var
|
|
557
|
+
ted"});var hI=Number.MAX_SAFE_INTEGER;var Dd=(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\
|
|
558
558
|
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
559
|
say plainly why.)`,markup:`(Check from ${t}: your last message contained raw markup, such as a tool call written out as\
|
|
560
560
|
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
|
-
what's left, then reply in plain words.)`,unsupported:e=>`(Check from ${t}: your reply says ${e.map(
|
|
561
|
+
what's left, then reply in plain words.)`,unsupported:e=>`(Check from ${t}: your reply says ${e.map(n=>`"${n}"`).join(",\
|
|
562
562
|
")}, 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
563
|
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
|
|
564
|
+
are above and what they did stays done. Carry on from where you got to, without redoing them, and finish the job.)"}}var zI=["You check an assistant's reply against a record of what its tools did while writing that reply.","List each sta\
|
|
565
565
|
tement in the reply that says something was done in this reply (made, saved, sent, attached, added, changed, deleted, bo\
|
|
566
566
|
oked, set up, fixed, run, tested) that the record doesn't support.","A claim is supported if a tool call and its answer \
|
|
567
567
|
in the record show it happened. Ignore plans, offers, questions, advice, facts about the person, things said to have hap\
|
|
568
568
|
pened earlier in the conversation, and descriptions of what a file or app contains.",'Reply with JSON only: {"unsupporte\
|
|
569
569
|
d": ["short quote of each unsupported claim"]}, with [] when every claim is supported.'].join(`
|
|
570
|
-
`);var
|
|
571
|
-
attachments:!1,tools:!1,nativeTools:!1});var
|
|
570
|
+
`);var dS=64*1024;var Zd="the app",gS=en(Zd);var wS=16*1024*1024;var xS=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var su=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
|
|
571
|
+
attachments:!1,tools:!1,nativeTools:!1});var Qx=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
572
572
|
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
573
|
-
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),
|
|
574
|
-
1",secretNamespace:
|
|
573
|
+
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),eb=Object.freeze({});var Ob=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexRuntime.js",import.meta.url).href;import{createHash as Us}from"node:crypto";import{open as Tu}from"node:fs/promises";import Fs from"node:path";var cn=1024*1024,Cu=256*1024,qs=512,_u=128,Eu=16*1024;function dn({errorPrefix:t="",identityNamespace:e="codex-account-v\
|
|
574
|
+
1",secretNamespace:n="codex-auth-secret-v1"}={}){function r(d="",p="",{messageCode:m}={}){let l=new Error(I(p)||"Codex h\
|
|
575
575
|
elper authentication is unavailable. Reconnect Codex and retry.");return l.code=I(d)||`${t}codex_helper_auth_unavailable`,
|
|
576
576
|
I(p)?m&&(l.messageCode=m):l.messageCode="assistant.codex.helperAuthUnavailable",l.messageCode&&(l.messageParams={}),l}function o(d,{
|
|
577
|
-
label:p="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw
|
|
577
|
+
label:p="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw r(`${t}cod\
|
|
578
578
|
ex_helper_auth_invalid`,`${p} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",p=""){return`\
|
|
579
|
-
sha256:${
|
|
580
|
-
"hex")}`}function i(d=""){return
|
|
581
|
-
let p=null;try{p=await
|
|
579
|
+
sha256:${Us("sha256").update(`${e}\0`,"utf8").update(I(d),"utf8").update("\0","utf8").update(String(p||""),"utf8").digest(
|
|
580
|
+
"hex")}`}function i(d=""){return Us("sha256").update(`${n}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){
|
|
581
|
+
let p=null;try{p=await Tu(d,"r");let m=await p.stat();if(!m.isFile()||m.size>cn)throw r(`${t}codex_helper_auth_invalid`,
|
|
582
582
|
"The selected Codex authentication record is invalid. Reconnect Codex and retry.",{messageCode:"assistant.codex.authReco\
|
|
583
|
-
rdInvalid"});let l=Buffer.alloc(
|
|
584
|
-
break;v+=b}if(v>
|
|
583
|
+
rdInvalid"});let l=Buffer.alloc(cn+1),v=0;for(;v<l.length;){let{bytesRead:b}=await p.read(l,v,l.length-v,null);if(b===0)
|
|
584
|
+
break;v+=b}if(v>cn)throw r(`${t}codex_helper_auth_invalid`,"The selected Codex authentication record is too large. Recon\
|
|
585
585
|
nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let x=JSON.parse(l.subarray(0,v).toString("ut\
|
|
586
586
|
f8"));if(!E(x))throw new Error("invalid authentication record");return x}catch(m){throw m?.code?.startsWith?.(`${t}codex\
|
|
587
|
-
_helper_auth_`)?m:
|
|
587
|
+
_helper_auth_`)?m:r(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. Rec\
|
|
588
588
|
onnect Codex and retry.",{messageCode:"assistant.codex.authRecordUnreadable"})}finally{await p?.close().catch(()=>null)}}
|
|
589
|
-
async function c(d={}){let p=I(d.toolHomeSource);if(!p||!
|
|
589
|
+
async function c(d={}){let p=I(d.toolHomeSource);if(!p||!Fs.isAbsolute(p))throw r(`${t}codex_helper_auth_unavailable`,"T\
|
|
590
590
|
he selected Codex account is unavailable. Reconnect Codex and retry.",{messageCode:"assistant.codex.accountUnavailable"});
|
|
591
|
-
let m=await a(
|
|
592
|
-
{},x=o(v.account_id,{label:"Codex account identity",maxLength:
|
|
593
|
-
O=v.chatgpt_plan_type??v.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:
|
|
591
|
+
let m=await a(Fs.join(p,".codex","auth.json")),l=I(m.auth_mode).toLowerCase();if(l==="chatgpt"){let v=E(m.tokens)?m.tokens:
|
|
592
|
+
{},x=o(v.account_id,{label:"Codex account identity",maxLength:qs}),b=o(v.access_token,{label:"Codex access token",maxLength:Cu}),
|
|
593
|
+
O=v.chatgpt_plan_type??v.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:_u});return Object.freeze(
|
|
594
594
|
{accessToken:b,accountId:x,authMode:"chatgpt",identitySignature:s("chatgpt",x),planType:P,secretSignature:i(b)})}if(["ap\
|
|
595
|
-
ikey","api_key"].includes(l)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:
|
|
596
|
-
authMode:"apiKey",identitySignature:s("apiKey",v),secretSignature:i(v)})}throw
|
|
595
|
+
ikey","api_key"].includes(l)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:Eu});return Object.freeze({apiKey:v,
|
|
596
|
+
authMode:"apiKey",identitySignature:s("apiKey",v),secretSignature:i(v)})}throw r(`${t}codex_helper_auth_invalid`,"The se\
|
|
597
597
|
lected Codex authentication mode is unsupported. Reconnect Codex and retry.",{messageCode:"assistant.codex.authModeUnsup\
|
|
598
|
-
ported"})}return Object.freeze({error:
|
|
598
|
+
ported"})}return Object.freeze({error:r,identitySignature:s,readRecord:a,readSelected:c})}var Xb=Object.freeze({label:"Checking the Codex sign-in",operationId:"codex-auth-preflight"});var nT=dn().error;var ET=4*1024*1024;var zC=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
599
599
|
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
600
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var
|
|
601
|
-
|
|
600
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var BC=2*1024*1024,HC=32*1024*1024,VC=2*1024*1024;function z(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
601
|
+
zu(e)}function zu(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function pn(t){return t!==null&&typeof t=="object"&&z(t.structure)&&z(t.operations)&&typeof t.validateWith=="function"&&
|
|
602
602
|
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Kt(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
603
|
-
let{items:
|
|
604
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:
|
|
605
|
-
if(!Object.hasOwn(e,"values"))return null;let{values:
|
|
603
|
+
let{items:n}=e;if(pn(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
|
|
604
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function lt(t,e){
|
|
605
|
+
if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(pn(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!=
|
|
606
606
|
"string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
|
|
607
|
-
t.`);return{kind:"definition",definition:
|
|
608
|
-
o=Object.hasOwn(e,"additionalProperties");if(r
|
|
607
|
+
t.`);return{kind:"definition",definition:n}}function Jt(t,e){let n=Object.hasOwn(e,"schema"),r=Object.hasOwn(e,"values"),
|
|
608
|
+
o=Object.hasOwn(e,"additionalProperties");if(n&&r)throw new Error(`Object field "${t}" cannot define both schema and val\
|
|
609
609
|
ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
|
|
610
|
-
if(
|
|
611
|
-
s: true.`);if(
|
|
612
|
-
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return
|
|
613
|
-
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
)
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
let
|
|
610
|
+
if(r&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
|
|
611
|
+
s: true.`);if(n){if(!pn(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
|
|
612
|
+
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:lt(
|
|
613
|
+
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 fn(t,e=""){
|
|
614
|
+
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.
|
|
615
|
+
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\
|
|
616
|
+
e a non-negative integer on an array field.`)}if(r.minItems>r.maxItems)throw new Error(`Field "${o}" minItems (${r.minItems}\
|
|
617
|
+
) is above its maxItems (${r.maxItems}).`);r.type==="array"&&z(r.items)&&typeof r.items.type=="string"&&fn({"[]":r.items},
|
|
618
|
+
o)}}var mn="^(?:0|-?[1-9]\\d*)$",$s="\\d{4}",Bs="0[1-9]|1[0-2]",Hs="0[1-9]|[12]\\d|3[01]",Vs="[01]\\d|2[0-3]",Fe="[0-5]\\d",
|
|
619
|
+
Xt=`(?:${Vs}):${Fe}`,Gs=`(?:Z|[+-](?:${Vs}):${Fe})`,Ws=`(${$s})-(${Bs})-(${Hs})`,Ks=`${$s}-(?:${Bs})-(?:${Hs})`,Js=`^${Ks}\
|
|
620
|
+
$`,Lu=new RegExp(`^${Ws}$`),Uu=new RegExp(`^${Xt}(?::${Fe}(?:\\.(\\d+))?)?$`),Fu=new RegExp(`^${Ws}T${Xt}:${Fe}(?:\\.(\\d+\
|
|
621
|
+
))?${Gs}$`),qu=new RegExp(mn),$u=[31,28,31,30,31,30,31,31,30,31,30,31];function Bu(t){return t%4===0&&(t%100!==0||t%400===
|
|
622
|
+
0)}function Hu(t,e){return e===2?Bu(t)?29:28:$u[e-1]}function Xs(t,e,n){let r=Number(t),o=Number(e),s=Number(n);return o>=
|
|
623
|
+
1&&o<=12&&s>=1&&s<=Hu(r,o)}function pt(t,e){let n=t.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(
|
|
624
|
+
`temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function Ys(t,e){return t===void 0?!0:e===void 0||
|
|
625
|
+
t.length<=e}function Zs(t){if(typeof t!="string")return!1;let e=Lu.exec(t);return e!==null&&Xs(e[1],e[2],e[3])}function Qs(t,e){
|
|
626
|
+
if(typeof t!="string")return!1;let n=Uu.exec(t);return n!==null&&Ys(n[1],e)}function ei(t,e){if(typeof t!="string")return!1;
|
|
627
|
+
let n=Fu.exec(t);return n===null?!1:Xs(n[1],n[2],n[3])&&Ys(n[4],e)}function ti(t){return t===void 0?"(?:\\.\\d+)?":t===0?
|
|
628
|
+
"":`(?:\\.\\d{1,${t}})?`}function ri(t,e){let n=pt(t,e);return`^${Xt}(?::${Fe}${ti(n)})?$`}function ni(t,e){let n=pt(t,e);
|
|
629
|
+
return`^${Ks}T${Xt}:${Fe}${ti(n)}${Gs}$`}function hn(t,e){let n;if(typeof t=="number")n=t;else if(typeof t=="string"&&qu.
|
|
630
|
+
test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var Vu=new Set(["__proto__","prototype","constructor"]);function C(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Gu(t,e){if(Vu.
|
|
631
|
+
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function Wu(t){return typeof t!="string"?t:t.replace(
|
|
632
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function gn(t,e,{normalize:n=!1,allowEmpty:r=!1}={}){
|
|
633
|
+
let o=n?Wu(t):t;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${e}() expects a non-empty \
|
|
629
634
|
dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
|
|
630
|
-
for(let i of s)
|
|
631
|
-
|
|
632
|
-
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:
|
|
633
|
-
none:()=>({type:
|
|
635
|
+
for(let i of s)Gu(i,e);return s}var Ku="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",vn=["object","array","string","number","boolean"],
|
|
636
|
+
wn=Symbol("json-rest-schema.exportContext"),Ju=["true","1","yes","y","on"],Xu=["false","0","no","n","off"];function oi(t){
|
|
637
|
+
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:mn}]}}function be(t,e){return{[fe]:{[t]:e}}}var Yu={
|
|
638
|
+
none:()=>({type:vn}),blob:()=>({type:vn}),serialize:()=>({type:vn}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
634
639
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
635
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
636
|
-
type:"string",format:"date-time",pattern:
|
|
637
|
-
fieldName:e})=>({type:"string",pattern:
|
|
638
|
-
let e=new Set([...
|
|
639
|
-
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...
|
|
640
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
640
|
+
eger","string"]}),epochMilliseconds:()=>oi(864e13),epochSeconds:()=>oi(864e10),dateTime:({definition:t,fieldName:e})=>({
|
|
641
|
+
type:"string",format:"date-time",pattern:ni(t,e)}),date:()=>({type:"string",format:"date",pattern:Js}),time:({definition:t,
|
|
642
|
+
fieldName:e})=>({type:"string",pattern:ri(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
|
|
643
|
+
let e=new Set([...Ju,String(t.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...Xu,String(t.stringFalseWhen||
|
|
644
|
+
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...n,...e]}]}},
|
|
645
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},Zu={minLength:({definition:t,parameterValue:e})=>t.
|
|
641
646
|
type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
|
|
642
|
-
definition:t,parameterValue:e})=>
|
|
647
|
+
definition:t,parameterValue:e})=>Ue(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ue(t)?{maximum:e}:null,pattern:({
|
|
643
648
|
definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
|
|
644
|
-
enum:t}),
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
"metadata",{
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
"
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
e)
|
|
666
|
-
|
|
667
|
-
nodes:[],nextDefinitionId:1,rootNode:null}}function
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
{});let n=
|
|
676
|
-
definitions[t.definitionName]=
|
|
677
|
-
|
|
678
|
-
let s=
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
n,o,s
|
|
687
|
-
if(a.kind==="
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
o=
|
|
706
|
-
|
|
707
|
-
function
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
o,e));return r}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
t
|
|
719
|
-
if(
|
|
720
|
-
"
|
|
721
|
-
n,
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
649
|
+
enum:t}),minItems:({definition:t,parameterValue:e})=>t.type==="array"?{minItems:e}:null,maxItems:({definition:t,parameterValue:e})=>t.
|
|
650
|
+
type==="array"?{maxItems:e}:null,notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({
|
|
651
|
+
parameterValue:t})=>t?be("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?be("transforms",{lowercase:!0}):
|
|
652
|
+
null,length:({parameterValue:t})=>be("transforms",{length:t}),unsigned:({parameterValue:t})=>t?be("metadata",{unsigned:!0}):
|
|
653
|
+
null,precision:({parameterValue:t})=>be("metadata",{precision:t}),scale:({parameterValue:t})=>be("metadata",{scale:t}),temporalPrecision:({
|
|
654
|
+
parameterValue:t})=>be("metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
|
|
655
|
+
defaultTo:()=>null};function xn(t,e){for(let n of Object.keys(e)){let r=e[n],o=t[n];if(r&&o&&typeof r=="object"&&typeof o==
|
|
656
|
+
"object"&&!Array.isArray(r)&&!Array.isArray(o)){xn(o,r);continue}t[n]=r}}function Qu(t,e){if(!e||typeof e!="object"||Array.
|
|
657
|
+
isArray(e))throw new Error("JSON Schema export hooks must return an object or null.");for(let n of Object.keys(e)){if(n===
|
|
658
|
+
fe&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){xn(t[n],e[n]);continue}
|
|
659
|
+
t[n]=e[n]}}function el(t,e){let r=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return r.length===
|
|
660
|
+
1?t:{anyOf:r}}function tl(t,e){if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);
|
|
661
|
+
let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=Yu[e.type];if(!r)throw new Error(
|
|
662
|
+
`Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function rl(t,e,n){if(!Object.
|
|
663
|
+
hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=Zu[e];
|
|
664
|
+
if(o)return o;throw new Error(`Validator '${e}' on field '${n}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
665
|
+
hook.`)}function si(t){if(t===void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(
|
|
666
|
+
`Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function nl(t,e={}){if(e.mode!==
|
|
667
|
+
void 0&&e.operation!==void 0){let n=si(e.mode);if(n!==e.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
668
|
+
s: mode '${n}' does not match operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))
|
|
669
|
+
throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return si(e.mode)}function ol(t,e={}){
|
|
670
|
+
if(e.operationName!==void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};
|
|
671
|
+
let n=nl(t,e);return{operationName:n,operation:t.operations[n]}}function sl(t={}){let e={...t};return Object.defineProperty(
|
|
672
|
+
e,wn,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function Zt(t={}){return t[wn]?
|
|
673
|
+
t[wn]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function il(t){return String(t).replace(/[^a-zA-Z0-9]+/g,
|
|
674
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function yn(t){return z(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}
|
|
675
|
+
function Yt(t){return yn(t)?{allOf:[t]}:t}function al(t,e,n,r,o){return t.nodes.find(s=>s.schema===e&&s.operationName===
|
|
676
|
+
n&&s.operation===r&&s.additionalProperties===o)||null}function cl(t,e){let n=il(e),r=`SchemaNode_${t.nextDefinitionId}_${n}`;
|
|
677
|
+
return t.nextDefinitionId+=1,r}function ii(t,e,n,r,o,{root:s=!1}={}){let i=Zt(e),a=al(i,t,n,r,o);if(a)return s&&(a.pointer=
|
|
678
|
+
"#",i.rootNode=a),a;let c={schema:t,operationName:n,operation:r,additionalProperties:o,status:"new",definitionName:s?null:
|
|
679
|
+
cl(i,n),pointer:s?"#":null};return s?i.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function ai(t,e){
|
|
680
|
+
if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=Zt(e);t.status="build\
|
|
681
|
+
ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=dl(t.schema,e,t.operationName,t.operation,t.additionalProperties);
|
|
682
|
+
return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function bn(t,e,n,r,o=!1){
|
|
683
|
+
let s=Zt(e),i=ii(t,e,n,r,o);return s.rootNode===i?{$ref:"#"}:ai(i,e)}function ft(t,{referenceBacked:e=!1}={}){return{schema:t,
|
|
684
|
+
referenceBacked:e}}function dl(t,e,n,r,o=!1){let s={},i=[];for(let[c,d]of Object.entries(t.structure))C(s,c,Tn(t,c,d,e,n,
|
|
685
|
+
r)),r.enforceRequired&&d.required===!0&&i.push(c);let a={type:"object",properties:s,additionalProperties:o};return i.length>
|
|
686
|
+
0&&(a.required=i),a}function ul(t,e,n,r,o,s){let i=Kt(e,n);if(!i)return null;if(i.kind==="schema")return{...Yt(bn(i.schema,
|
|
687
|
+
r,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
|
|
688
|
+
"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return Tn(t,`${e}[]`,n.items,r,a,c)}function ll(t,e,n,r,o,s){
|
|
689
|
+
let i=lt(e,n);if(!i)return null;if(i.kind==="schema")return{...Yt(bn(i.schema,r,"replace",i.schema.operations.replace,!1)),
|
|
690
|
+
[fe]:{castType:"object"}};let a=i.definition.type==="object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="re\
|
|
691
|
+
place"?t.operations.replace:s;return Tn(t,`${e}.*`,i.definition,r,a,c)}function pl(t,e,n,r,o,s){if(n.type==="object"){let a=Jt(
|
|
692
|
+
e,n);if(a.kind==="nested")return ft(bn(a.schema,r,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
693
|
+
"opaque")return ft({type:"object",additionalProperties:!0});if(a.kind==="map")return ft({type:"object",additionalProperties:ll(
|
|
694
|
+
t,e,n,r,o,s)})}let i=tl(t,n)({schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r});if(!i||typeof i!="object"||
|
|
695
|
+
Array.isArray(i))throw new Error(`Type '${n.type}' on field '${e}' returned an invalid JSON Schema fragment.`);if(n.type===
|
|
696
|
+
"array"){let a=ul(t,e,n,r,o,s);if(a)return ft({...i,items:a},{referenceBacked:yn(i)})}return ft(i,{referenceBacked:yn(i)})}
|
|
697
|
+
function Tn(t,e,n,r,o,s){let i={schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r},a=pl(t,e,n,r,o,s),c=a.referenceBacked?
|
|
698
|
+
Yt(a.schema):{...a.schema},d={castType:n.type};for(let l of Object.keys(n)){if(l==="type"||!Object.hasOwn(t.validators,l))
|
|
699
|
+
continue;let v=rl(t,l,e);if(!v)continue;let x=v({...i,parameterName:l,parameterValue:n[l],fieldSchema:{...c}});x&&Qu(c,x)}
|
|
700
|
+
c[fe]&&(xn(d,c[fe]),delete c[fe]);let p=[];n.nullable===!0&&p.push({type:"null"}),n.nullOnEmpty===!0&&p.push({const:""});
|
|
701
|
+
let m=Yt(el(c,p));if(n.defaultTo!==void 0&&s.applyDefaults)if(typeof n.defaultTo!="function"){let l=t._normalizeDefault(
|
|
702
|
+
n,n.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},options:{},settings:t._buildOperationSettings(
|
|
703
|
+
o,s,{})});if(Object.keys(l.errors).length>0){let v=Object.values(l.errors)[0];throw new Error(`defaultTo for "${e}" is i\
|
|
704
|
+
nvalid (${v.code}).`)}m.default=l.value}else d.defaults={providedByFunction:!0};return m[fe]=d,m}function ci(t,e={}){let n=sl(
|
|
705
|
+
e),{operationName:r,operation:o}=ol(t,n),s=n.additionalProperties===void 0?!1:n.additionalProperties,i=Zt(n),a=ii(t,n,r,
|
|
706
|
+
o,s,{root:!0}),c={$schema:Ku,...ai(a,n)};return Object.keys(i.definitions).length>0&&(c.definitions=i.definitions),c}function di(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Rn(t){return t instanceof
|
|
707
|
+
Be}function fl(){return{self:!1,children:{}}}function ui(t){return Object.keys(t.children).length>0}function Te(t,e){return`${t}\
|
|
708
|
+
.${String(e)}`}function gi(t,e){return t===""?String(e):Te(t,e)}function li(t,e){if(t===e)return"";let n=`${e}.`;return t.
|
|
709
|
+
startsWith(n)?t.slice(n.length):null}function qe(t,e){let n={};for(let r of Object.values(t)){let o=Te(e,r.field);C(n,o,
|
|
710
|
+
{...r,field:o})}return n}function An(t){return gn(t,"validatePath")}function pi(t){let e={};for(let n of t){let r=An(n),
|
|
711
|
+
o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||C(o,i,fl()),s===r.length-1&&(o[i].self=!0),o=o[i].children}}
|
|
712
|
+
return e}function ml(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}
|
|
713
|
+
function Qt(t){return t===null?!0:Array.isArray(t)||z(t)?Object.keys(t).length>0:t!==void 0}function fi(t){return[...t].
|
|
714
|
+
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)})}
|
|
715
|
+
function hl(t){return/^[0-9]+$/.test(t)}function gl(t,e=new WeakMap){if(e.has(t))return e.get(t);let n=Object.create(Be.
|
|
716
|
+
prototype);return e.set(t,n),n.structure=null,n.types=t.types,n.validators=t.validators,n.operations=t.operations,n.structure=
|
|
717
|
+
tr(er(t.structure,e)),n._installOperationMethods(),Object.freeze(n)}function er(t,e=new WeakMap){if(t===null||typeof t!=
|
|
718
|
+
"object")return t;if(Rn(t))return gl(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let r=new RegExp(
|
|
719
|
+
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);
|
|
720
|
+
for(let o of t)r.push(er(o,e));return r}if(!z(t))return t;let n={};e.set(t,n);for(let[r,o]of Object.entries(t))C(n,r,er(
|
|
721
|
+
o,e));return n}function tr(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Rn(t))return t;if(e.add(t),Array.
|
|
722
|
+
isArray(t))for(let n of t)tr(n,e);else for(let n of Reflect.ownKeys(t))tr(t[n],e);return Object.freeze(t)}function Cn(t){
|
|
723
|
+
return tr(er(t))}var _n=new WeakMap;function On(t,e,n=""){if(!Rn(t)||!Array.isArray(e)||e.length<1)return null;let[r,...o]=e;
|
|
724
|
+
if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=gi(n,r);return vi(t,s,o,i)}
|
|
725
|
+
function vi(t,e,n,r){if(e?.type==="object"){let o=t._resolveObjectFieldMode(r,e);return o.kind!=="nested"?null:On(o.schema,
|
|
726
|
+
n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.length<1)return null;let[s,...i]=n;if(!hl(s))return null;
|
|
727
|
+
let a=Te(r,s);return o.kind==="schema"?i.length<1?null:On(o.schema,i,a):i.length<1?o.definition:vi(t,o.definition,i,a)}return null}
|
|
728
|
+
function $e(t,e){let n={...t};if(Array.isArray(t.skipFields)){let r=t.skipFields.map(o=>li(o,e)).filter(o=>o!==null&&o!==
|
|
729
|
+
"");r.length>0?n.skipFields=r:delete n.skipFields}if(z(t.skipParams)){let r={};for(let[o,s]of Object.entries(t.skipParams)){
|
|
730
|
+
let i=li(o,e);i===null||i===""||C(r,i,s)}Object.keys(r).length>0?n.skipParams=r:delete n.skipParams}return n}var vl=Object.
|
|
725
731
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
726
732
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
727
733
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
728
|
-
function
|
|
729
|
-
", ")}.`)}function
|
|
730
|
-
must define ${
|
|
731
|
-
eration "${t}" must be an object.`);return
|
|
732
|
-
pplyDefaults"),
|
|
734
|
+
function mi(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(
|
|
735
|
+
", ")}.`)}function En(t,e,n,r=!0){let o=e[n];if(!(o===void 0&&!r)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
|
|
736
|
+
must define ${n} as a boolean.`)}function wl(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
|
|
737
|
+
eration "${t}" must be an object.`);return mi(t,e,"targetFields",["schema","input"]),En(t,e,"enforceRequired"),En(t,e,"a\
|
|
738
|
+
pplyDefaults"),mi(t,e,"outputFields",["validated","input"]),En(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
|
|
733
739
|
targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
|
|
734
|
-
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function
|
|
735
|
-
isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[r
|
|
736
|
-
|
|
737
|
-
null);for(let[r
|
|
738
|
-
delete e.mode,e}var
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
s}_paramToBeSkipped(e,r
|
|
742
|
-
return Array.isArray(
|
|
743
|
-
let
|
|
740
|
+
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function yl(t={}){if(typeof t!="object"||t===null||Array.
|
|
741
|
+
isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[n,r]of Object.entries(
|
|
742
|
+
vl))C(e,n,r);for(let[n,r]of Object.entries(t))C(e,n,wl(n,r));return Object.freeze(e)}function hi(t){let e=Object.create(
|
|
743
|
+
null);for(let[n,r]of Object.entries(t))C(e,n,r);return Object.freeze(e)}function Il(t){let e={...t};return delete e.operation,
|
|
744
|
+
delete e.mode,e}var Be=class{constructor(e,n,r,o={}){fn(e),this.structure=e,this.types=hi(n),this.validators=hi(r),this.
|
|
745
|
+
operations=yl(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could\
|
|
746
|
+
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,
|
|
747
|
+
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){
|
|
748
|
+
return Array.isArray(n.skipFields)&&n.skipFields.includes(e)}_mergeErrors(e,n){for(let[r,o]of Object.entries(n))C(e,r,o)}_singleErrorMap(e){
|
|
749
|
+
let n={};return C(n,e.field,e),n}_assertSupportedOptions(e={}){if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("U\
|
|
744
750
|
nsupported validation option `onlyObjectValues`. Call `patch()` directly.");if(Object.hasOwn(e,"mode"))throw new Error("\
|
|
745
751
|
Unsupported validation option `mode`. Call `validateWith()` or an operation method directly.");if(Object.hasOwn(e,"opera\
|
|
746
752
|
tion"))throw new Error("Unsupported validation option `operation`. Call `validateWith()` or an operation method directly\
|
|
747
|
-
.")}_buildOperationSettings(e,r
|
|
748
|
-
|
|
749
|
-
enforceRequired,applyDefaults:
|
|
750
|
-
isFieldPresent:o=>Object.hasOwn(
|
|
751
|
-
ct input.`)}_resolvePathValidationRequest(e={}){let
|
|
753
|
+
.")}_buildOperationSettings(e,n,r){return{operationName:e,operation:n,targetFieldNames:n.targetFields==="input"?Object.keys(
|
|
754
|
+
r):Object.keys(this.structure),outputFieldNames:n.outputFields==="input"?Object.keys(r):Object.keys(this.structure),enforceRequired:n.
|
|
755
|
+
enforceRequired,applyDefaults:n.applyDefaults,rejectExplicitUndefined:n.rejectExplicitUndefined,defaultedFields:new Set,
|
|
756
|
+
isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(!z(n))throw new Error(`${e}() expects a plain obje\
|
|
757
|
+
ct input.`)}_resolvePathValidationRequest(e={}){let n=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
|
|
752
758
|
hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
753
|
-
oth are provided.");if(!Object.hasOwn(this.operations,
|
|
754
|
-
return{operationName:
|
|
755
|
-
if(!Object.hasOwn(this.structure,s))continue;let i=
|
|
756
|
-
has(s))&&(!i&&!
|
|
757
|
-
return Kt(e,
|
|
758
|
-
hasOwn(e,"schema")?{...
|
|
759
|
+
oth are provided.");if(!Object.hasOwn(this.operations,n))throw new Error(`Unknown operation "${n}".`);let r=this.operations[n];
|
|
760
|
+
return{operationName:n,operation:r,validationOptions:Il(e)}}_buildOperationResult(e,n,r){let o={};for(let s of r.outputFieldNames){
|
|
761
|
+
if(!Object.hasOwn(this.structure,s))continue;let i=r.isFieldPresent(s);(n[s]!==void 0||i&&e[s]===null||r.defaultedFields.
|
|
762
|
+
has(s))&&(!i&&!r.defaultedFields.has(s)||C(o,s,n[s]))}return o}_resolveObjectFieldMode(e,n){return Jt(e,n)}_resolveArrayItemsConfig(e,n){
|
|
763
|
+
return Kt(e,n)}_resolveObjectValuesConfig(e,n){return lt(e,n)}_buildArrayItemSettings(e,n){return e.type==="object"&&Object.
|
|
764
|
+
hasOwn(e,"schema")?{...n,operationName:"replace",operation:this.operations.replace}:n}_castValue(e,n,r,o,s,i,a,c){let d=e.
|
|
759
765
|
nullable===!0||a.nullable===!0,p=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
|
|
760
|
-
`No casting function for type: ${e.type}`);let m=this.types[e.type];if(
|
|
761
|
-
{errors:this._singleErrorMap({field:
|
|
762
|
-
if(
|
|
763
|
-
objectBeforeCast:i,valueBeforeCast:
|
|
764
|
-
nullable:d||p,nullOnEmpty:p},throwTypeError:()=>{throw this._typeError(
|
|
765
|
-
|
|
766
|
+
`No casting function for type: ${e.type}`);let m=this.types[e.type];if(n===null)return d?(C(o,s,null),{errors:{},shouldContinue:!1}):
|
|
767
|
+
{errors:this._singleErrorMap({field:r,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
768
|
+
if(n===""&&p)return C(o,s,null),{errors:{},shouldContinue:!1};let l={schema:this,definition:e,value:n,fieldName:r,object:o,
|
|
769
|
+
objectBeforeCast:i,valueBeforeCast:n,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
770
|
+
nullable:d||p,nullOnEmpty:p},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(v,x,b)=>{throw this._paramError(
|
|
771
|
+
r,v,x,b)}};try{let v=m(l);if(di(v))throw new Error(`Type handler for "${e.type}" must be synchronous.`);v!==void 0&&(C(o,
|
|
766
772
|
s,v),l.value=v)}catch(v){if(v.errorObject)return{errors:this._singleErrorMap(v.errorObject),shouldContinue:!1};throw v}return{
|
|
767
|
-
errors:{},context:l,shouldContinue:!0}}_runFieldValidators(e,r,
|
|
768
|
-
_paramToBeSkipped(a,i.skipParams,
|
|
769
|
-
a,s.parameterValue=e[a];let d=c(s);if(
|
|
770
|
-
(C(
|
|
771
|
-
let d=this._castValue(e,r,
|
|
772
|
-
context:p}=d,m=this._validateNestedValue(e,
|
|
773
|
-
e,
|
|
774
|
-
let d={...o};return C(d,s,
|
|
775
|
-
if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
776
|
-
c,r,
|
|
777
|
-
_resolveArrayItemsConfig(
|
|
778
|
-
let a=
|
|
779
|
-
i.operationName,i.operation,c
|
|
780
|
-
a,e.schema,d.validatedObject):d.validatedObject),
|
|
781
|
-
entries(e))Object.hasOwn(
|
|
782
|
-
keys(e)){if(!Object.hasOwn(
|
|
783
|
-
|
|
773
|
+
errors:{},context:l,shouldContinue:!0}}_runFieldValidators(e,n,r,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
|
|
774
|
+
_paramToBeSkipped(a,i.skipParams,n)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
|
|
775
|
+
a,s.parameterValue=e[a];let d=c(s);if(di(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
|
|
776
|
+
(C(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){
|
|
777
|
+
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{
|
|
778
|
+
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(
|
|
779
|
+
e,r,o,s,p,a))}_normalizeDefault(e,n,{fieldPath:r,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
|
|
780
|
+
let d={...o};return C(d,s,n),{errors:this._normalizeAndValidateValue(e,n,r,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,n,r,o,s,i){
|
|
781
|
+
if(e.type==="object"){let c=this._resolveObjectFieldMode(n,e);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
782
|
+
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.
|
|
783
|
+
_resolveArrayItemsConfig(n,e);return a?this._validateArrayItems(n,r,o,a,s,i):{}}_validateNestedObjectSchema(e,n,r,o,s,i){
|
|
784
|
+
let a=r[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
|
|
785
|
+
i.operationName,i.operation,c,$e(s,n));return C(r,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
786
|
+
a,e.schema,d.validatedObject):d.validatedObject),qe(d.errors,n)}_extractKnownObjectFields(e,n){let r={};for(let[o,s]of Object.
|
|
787
|
+
entries(e))Object.hasOwn(n.structure,o)&&C(r,o,s);return r}_mergeKnownAndPassthroughObjectFields(e,n,r){let o={};for(let s of Object.
|
|
788
|
+
keys(e)){if(!Object.hasOwn(n.structure,s)){C(o,s,e[s]);continue}Object.hasOwn(r,s)&&C(o,s,r[s])}for(let[s,i]of Object.entries(
|
|
789
|
+
r))Object.hasOwn(o,s)||C(o,s,i);return o}_validateObjectValues(e,n,r,o,s,i){let a=n[r],c={...a},d={};C(n,r,c);for(let p of Object.
|
|
784
790
|
keys(a)){let m=Te(e,p);if(this._fieldToBeSkipped(m,s))continue;let l=c[p];if(l===void 0){i.rejectExplicitUndefined?this.
|
|
785
791
|
_mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[p];continue}if(o.kind==="schema"){let x=o.
|
|
786
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,l
|
|
787
|
-
d,
|
|
788
|
-
definition,i));this._mergeErrors(d,v)}return d}_validateArrayItems(e,r,
|
|
792
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,l,$e(s,m));C(c,p,x.validatedObject),this._mergeErrors(
|
|
793
|
+
d,qe(x.errors,m));continue}let v=this._normalizeAndValidateValue(o.definition,l,m,c,p,a,s,this._buildArrayItemSettings(o.
|
|
794
|
+
definition,i));this._mergeErrors(d,v)}return d}_validateArrayItems(e,n,r,o,s,i){let a=n[r],c=a.slice(),d={};C(n,r,c);for(let p=0;p<
|
|
789
795
|
c.length;p++){let m=Te(e,p);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(a,p)||c[p]===void 0){i.rejectExplicitUndefined?
|
|
790
796
|
this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[p];continue}if(o.kind==="schema"){let v=o.
|
|
791
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[p]
|
|
792
|
-
d,
|
|
793
|
-
o.definition,i));this._mergeErrors(d,l)}return d}_validateField(e,r,
|
|
794
|
-
let i=this.structure[e];if(this._fieldToBeSkipped(e,o))return{};let a=s.isFieldPresent(e),c=
|
|
797
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[p],$e(s,m));C(c,p,v.validatedObject),this._mergeErrors(
|
|
798
|
+
d,qe(v.errors,m));continue}let l=this._normalizeAndValidateValue(o.definition,c[p],m,c,p,a,s,this._buildArrayItemSettings(
|
|
799
|
+
o.definition,i));this._mergeErrors(d,l)}return d}_validateField(e,n,r,o,s){if(!Object.hasOwn(this.structure,e))return{};
|
|
800
|
+
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&&
|
|
795
801
|
i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
|
|
796
802
|
Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
|
|
797
|
-
_normalizeAndValidateValue(i,c,e,
|
|
798
|
-
i={...
|
|
803
|
+
_normalizeAndValidateValue(i,c,e,r,e,n,o,s):{}}_validateWithOperation(e,n,r,o){this._assertSupportedOptions(o);let s={},
|
|
804
|
+
i={...r},a=this._buildOperationSettings(e,n,r);for(let c of Object.keys(r))Object.hasOwn(this.structure,c)||C(s,c,{field:c,
|
|
799
805
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
|
|
800
|
-
c,
|
|
806
|
+
c,r,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
801
807
|
this.structure[c].defaultTo!==void 0){let d=this.structure[c],p=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
|
|
802
|
-
m=this._normalizeDefault(d,p,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:
|
|
808
|
+
m=this._normalizeDefault(d,p,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:r,options:o,settings:a});if(this.
|
|
803
809
|
_mergeErrors(s,m.errors),Object.keys(m.errors).length>0)continue;C(i,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
804
|
-
_buildOperationResult(
|
|
805
|
-
let d=
|
|
806
|
-
c,e[c],
|
|
807
|
-
hasOwn(this.structure,e))return{};let c=this.structure[e],d=
|
|
808
|
-
let m=Object.hasOwn(
|
|
810
|
+
_buildOperationResult(r,i,a),errors:s}}_validateSelectedTree(e,n,r,o,s=""){let i={},a={};for(let c of fi(Object.keys(e))){
|
|
811
|
+
let d=gi(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let p=this._validateSelectedField(
|
|
812
|
+
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.
|
|
813
|
+
hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,p=ui(n);if(this._fieldToBeSkipped(a,s))return{};
|
|
814
|
+
let m=Object.hasOwn(r,e),l=r[e],v={};if(!m){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
|
|
809
815
|
a)&&this._mergeErrors(v,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
|
|
810
816
|
c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,j=this._normalizeDefault(c,P,{fieldPath:a,
|
|
811
|
-
currentObject:o,containerKey:e,objectBeforeCast:
|
|
817
|
+
currentObject:o,containerKey:e,objectBeforeCast:r,options:s,settings:i});this._mergeErrors(v,j.errors),Object.keys(j.errors).
|
|
812
818
|
length===0&&C(o,e,j.value)}return v}if(l===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
813
|
-
a).errorObject):{};let x={[e]:l};if(d){let P=this._normalizeAndValidateValue(c,l,a,x,e,
|
|
814
|
-
x[e]!==void 0?C(o,e,x[e]):x[e]===null&&C(o,e,null),P}if(!p)return{};let b=this._castValue(c,l,a,x,e,
|
|
815
|
-
b.errors).length>0)return b.errors;if(!b.shouldContinue)return{};let O=this._validateSelectedDescendants(c,
|
|
816
|
-
x,e,s,i);return Qt(x[e])&&C(o,e,x[e]),O}_validateSelectedDescendants(e,r,
|
|
817
|
-
|
|
818
|
-
d))return{};let p=c.schema._validateSelectedTree(
|
|
819
|
-
|
|
820
|
-
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(
|
|
821
|
-
`Schema path "${
|
|
822
|
-
p={};C(r,
|
|
823
|
-
id because array segments must use numeric indexes.`);let l=Number(m),v=Te(e,l),x=s[m],b=x.self===!0,O=
|
|
819
|
+
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)&&
|
|
820
|
+
x[e]!==void 0?C(o,e,x[e]):x[e]===null&&C(o,e,null),P}if(!p)return{};let b=this._castValue(c,l,a,x,e,r,s,i);if(Object.keys(
|
|
821
|
+
b.errors).length>0)return b.errors;if(!b.shouldContinue)return{};let O=this._validateSelectedDescendants(c,n.children,a,
|
|
822
|
+
x,e,s,i);return Qt(x[e])&&C(o,e,x[e]),O}_validateSelectedDescendants(e,n,r,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
823
|
+
r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested field selection.`);let d=o[s];if(!z(
|
|
824
|
+
d))return{};let p=c.schema._validateSelectedTree(n,d,$e(i,r),{...a,defaultedFields:new Set});return C(o,s,p.validatedObject),
|
|
825
|
+
qe(p.errors,r)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(r,e);if(!c)throw new Error(`Schema path "${r}" d\
|
|
826
|
+
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(r,o,s,c,n,i,a)}throw new Error(
|
|
827
|
+
`Schema path "${r}" does not support nested field selection.`)}_validateSelectedArrayItems(e,n,r,o,s,i,a){let c=[],d=n[r],
|
|
828
|
+
p={};C(n,r,c);for(let m of fi(Object.keys(s))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${Te(e,m)}" is inval\
|
|
829
|
+
id because array segments must use numeric indexes.`);let l=Number(m),v=Te(e,l),x=s[m],b=x.self===!0,O=ui(x);if(this._fieldToBeSkipped(
|
|
824
830
|
v,i))continue;if(!Object.hasOwn(d,l)){b&&a.rejectExplicitUndefined&&C(p,v,this._typeError(v).errorObject);continue}let P=d[l];
|
|
825
831
|
if(P===void 0){b&&a.rejectExplicitUndefined&&C(p,v,this._typeError(v).errorObject);continue}if(o.kind==="schema"){if(b){
|
|
826
|
-
let q=o.schema._validateWithOperation("replace",o.schema.operations.replace,P
|
|
827
|
-
this._mergeErrors(p,
|
|
832
|
+
let q=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,$e(i,v));Qt(q.validatedObject)&&C(c,l,q.validatedObject),
|
|
833
|
+
this._mergeErrors(p,qe(q.errors,v));continue}if(!O)continue;let H=o.schema._validateSelectedTree(x.children,P,$e(i,v),{...a,
|
|
828
834
|
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Qt(H.validatedObject)&&C(c,l,H.validatedObject),
|
|
829
|
-
this._mergeErrors(p,
|
|
835
|
+
this._mergeErrors(p,qe(H.errors,v));continue}let j=this._buildArrayItemSettings(o.definition,a),D=[P];if(b){let H=this._normalizeAndValidateValue(
|
|
830
836
|
o.definition,P,v,D,0,d,i,j);Object.hasOwn(D,0)&&D[0]!==void 0?C(c,l,D[0]):D[0]===null&&C(c,l,null),this._mergeErrors(p,H);
|
|
831
|
-
continue}if(!O)continue;let
|
|
832
|
-
p,
|
|
833
|
-
i,j);Qt(D[0])&&C(c,l,D[0]),this._mergeErrors(p,J)}return p}validateWith(e,r
|
|
834
|
-
`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,
|
|
835
|
-
e,o,r
|
|
836
|
-
_resolvePathValidationRequest(
|
|
837
|
-
c.validatedObject,o),errors:c.errors}}validatePaths(e,r
|
|
837
|
+
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(
|
|
838
|
+
p,U.errors);continue}if(!U.shouldContinue)continue;let J=this._validateSelectedDescendants(o.definition,x.children,v,D,0,
|
|
839
|
+
i,j);Qt(D[0])&&C(c,l,D[0]),this._mergeErrors(p,J)}return p}validateWith(e,n,r={}){if(!Object.hasOwn(this.operations,e))throw new Error(
|
|
840
|
+
`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,n),this._validateWithOperation(
|
|
841
|
+
e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=An(e),{operationName:s,operation:i,validationOptions:a}=this.
|
|
842
|
+
_resolvePathValidationRequest(r),c=this._validateSelectedTree(pi([e]),n,a,this._buildOperationSettings(s,i,n));return{validatedValue:ml(
|
|
843
|
+
c.validatedObject,o),errors:c.errors}}validatePaths(e,n,r={}){if(this._assertPlainObjectInput("validatePaths",n),!Array.
|
|
838
844
|
isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
839
|
-
operation:s,validationOptions:i}=this._resolvePathValidationRequest(
|
|
840
|
-
_buildOperationSettings(o,s,
|
|
841
|
-
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(r
|
|
842
|
-
return
|
|
843
|
-
"")throw new Error("Field path must be a non-empty string.");let
|
|
844
|
-
let
|
|
845
|
-
let
|
|
846
|
-
{
|
|
847
|
-
|
|
848
|
-
|
|
845
|
+
operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(pi(e),n,i,this.
|
|
846
|
+
_buildOperationSettings(o,s,n))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
|
|
847
|
+
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(n,r={})=>this.validateWith(e,n,r)}}toJsonSchema(e={}){
|
|
848
|
+
return ci(this,e)}getFieldDefinitions(){return _n.has(this)||_n.set(this,Cn(this.structure)),_n.get(this)}getFieldDefinition(e){
|
|
849
|
+
if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=On(this,An(e.trim()));
|
|
850
|
+
return n===null?null:Cn(n)}getFieldMessages(e){let n=this.getFieldDefinition(e);return!n||typeof n.messages!="object"||n.
|
|
851
|
+
messages===null?Object.freeze({}):Cn(n.messages)}cleanup(e,n){let r={};for(let o of Object.keys(e))Object.hasOwn(this.structure,
|
|
852
|
+
o)&&this.structure[o][n]&&C(r,o,e[o]);return r}};var{parse:__,stringify:Sl}=JSON,{keys:E_}=Object,xl=String,bl="string";var wi="object",Tl=(t,e)=>e;var yi=(t,e,n)=>{let r=xl(e.push(n)-1);return t.set(n,r),r};var Ii=(t,e,n)=>{let r=e&&typeof e===wi?(p,m)=>p===""||-1<e.indexOf(p)?m:void 0:e||Tl,o=new Map,s=[],i=[],a=+yi(o,s,r.call(
|
|
853
|
+
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=Sl(s[a++],d,n);return"["+i.join(",")+"]";function d(p,m){if(c)return c=!c,
|
|
854
|
+
m;let l=r.call(this,p,m);switch(typeof l){case wi:if(l===null)return l;case bl:return o.get(l)||yi(o,s,l)}return l}};var _l=new Set(["true","1","yes","y","on"]),El=new Set(["false","0","no","n","off"]);function Al(t){return t!==null&&(typeof t==
|
|
855
|
+
"object"||typeof t=="function")&&typeof t.then=="function"}function Si(t){if(typeof t=="number")return Number.isFinite(t)?
|
|
849
856
|
t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
|
|
850
|
-
if(e==="")return null;let
|
|
857
|
+
if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function Pn(t,e){if(Object.is(t,e))return!0;
|
|
851
858
|
if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
|
|
852
859
|
source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
|
|
853
|
-
e.length)return!1;for(let o=0;o<t.length;o++)if(!
|
|
854
|
-
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let
|
|
855
|
-
e);if(
|
|
856
|
-
let{addType:e,addValidator:
|
|
857
|
-
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return
|
|
858
|
-
e("string",
|
|
859
|
-
return
|
|
860
|
-
null&&
|
|
861
|
-
o}),e("epochMilliseconds",
|
|
862
|
-
|
|
863
|
-
value,o)||
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
value;if(typeof
|
|
868
|
-
"bigint"){if(
|
|
869
|
-
|
|
870
|
-
i=
|
|
871
|
-
e("id",
|
|
872
|
-
value=="bigint"){if(
|
|
873
|
-
value=="string"){let o=
|
|
874
|
-
s)||
|
|
875
|
-
toString&&
|
|
876
|
-
characters.`,{min:
|
|
877
|
-
typeof
|
|
878
|
-
.`,{min:
|
|
879
|
-
|
|
880
|
-
characters.`,{max:
|
|
881
|
-
typeof
|
|
882
|
-
.`,{max:
|
|
883
|
-
fieldName} must be an array.`);
|
|
884
|
-
one of the allowed enum values.",{allowed:
|
|
885
|
-
"string"||typeof
|
|
886
|
-
"string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${
|
|
887
|
-
|
|
888
|
-
parameterValue){if(
|
|
889
|
-
fieldName}).`);typeof
|
|
890
|
-
"validator",
|
|
891
|
-
let o=
|
|
892
|
-
ronous.`);typeof o=="string"&&
|
|
893
|
-
ing")return
|
|
894
|
-
th",
|
|
895
|
-
String(
|
|
896
|
-
ed character range.",{max:
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
"
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
860
|
+
e.length)return!1;for(let o=0;o<t.length;o++)if(!Pn(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
|
|
861
|
+
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let n=Object.keys(t),r=Object.keys(
|
|
862
|
+
e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!Pn(t[o],e[o]))return!1;return!0}var Ol={install(t){
|
|
863
|
+
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;
|
|
864
|
+
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),
|
|
865
|
+
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();
|
|
866
|
+
return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=Si(r.value);return o===
|
|
867
|
+
null&&r.throwTypeError(),o}),e("integer",r=>{let o=Si(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
|
|
868
|
+
o}),e("epochMilliseconds",r=>{let o=hn(r.value,864e13);return o===null&&r.throwTypeError(),o}),e("epochSeconds",r=>{let o=hn(
|
|
869
|
+
r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=pt(r.definition,r.fieldName);return ei(r.
|
|
870
|
+
value,o)||r.throwTypeError(),r.value}),e("date",r=>(Zs(r.value)||r.throwTypeError(),r.value)),e("time",r=>{let o=pt(r.definition,
|
|
871
|
+
r.fieldName);return Qs(r.value,o)||r.throwTypeError(),r.value}),e("array",r=>r.definition.type==="array"&&!Array.isArray(
|
|
872
|
+
r.value)?[r.value]:r.value),e("object",r=>(z(r.value)||r.throwTypeError(),r.value)),e("serialize",r=>{try{return JSON.stringify(
|
|
873
|
+
r.value)}catch{try{return Ii(r.value)}catch{r.throwTypeError()}}}),e("boolean",r=>{if(typeof r.value=="boolean")return r.
|
|
874
|
+
value;if(typeof r.value=="number"){if(r.value===1)return!0;if(r.value===0)return!1;r.throwTypeError()}if(typeof r.value==
|
|
875
|
+
"bigint"){if(r.value===1n)return!0;if(r.value===0n)return!1;r.throwTypeError()}if(typeof r.value=="string"){let o=String(
|
|
876
|
+
r.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(r.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
877
|
+
i=r.value.trim().toLowerCase(),a=new Set([...El,o]),c=new Set([..._l,s]);if(a.has(i))return!1;if(c.has(i))return!0}r.throwTypeError()}),
|
|
878
|
+
e("id",r=>{if(typeof r.value=="number"){if(Number.isSafeInteger(r.value)&&r.value>0)return r.value;r.throwTypeError()}if(typeof r.
|
|
879
|
+
value=="bigint"){if(r.value>0n&&r.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(r.value);r.throwTypeError()}if(typeof r.
|
|
880
|
+
value=="string"){let o=r.value.trim();/^[1-9][0-9]*$/.test(o)||r.throwTypeError();let s=Number(o);return Number.isSafeInteger(
|
|
881
|
+
s)||r.throwTypeError(),s}r.throwTypeError()}),n("minLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.
|
|
882
|
+
toString&&r.value.toString().length<r.parameterValue&&r.throwParamError("MIN_LENGTH",`Length must be at least ${r.parameterValue}\
|
|
883
|
+
characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&Ue(r.definition)&&
|
|
884
|
+
typeof r.value=="number"&&r.value<r.parameterValue&&r.throwParamError("MIN_VALUE",`Value must be at least ${r.parameterValue}\
|
|
885
|
+
.`,{min:r.parameterValue,actual:r.value})}),n("maxLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.toString&&
|
|
886
|
+
r.value.toString().length>r.parameterValue&&r.throwParamError("MAX_LENGTH",`Length must be no more than ${r.parameterValue}\
|
|
887
|
+
characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&Ue(r.definition)&&
|
|
888
|
+
typeof r.value=="number"&&r.value>r.parameterValue&&r.throwParamError("MAX_VALUE",`Value must be no more than ${r.parameterValue}\
|
|
889
|
+
.`,{max:r.parameterValue,actual:r.value})}),n("enum",r=>{if(!Array.isArray(r.parameterValue))throw new Error(`Enum for ${r.
|
|
890
|
+
fieldName} must be an array.`);r.parameterValue.some(s=>Pn(s,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
|
|
891
|
+
one of the allowed enum values.",{allowed:r.parameterValue})}),n("pattern",r=>{if(r.value===void 0||r.definition.type!==
|
|
892
|
+
"string"||typeof r.value!="string")return;let o=r.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
893
|
+
"string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${r.fieldName} must be a string or RegExp.`);s.test(r.value)||
|
|
894
|
+
r.throwParamError("PATTERN","Value does not match the required pattern.",{pattern:s.source})}),n("strictBoolean",r=>{if(r.
|
|
895
|
+
parameterValue){if(r.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${r.
|
|
896
|
+
fieldName}).`);typeof r.valueBeforeCast!="boolean"&&r.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),n(
|
|
897
|
+
"validator",r=>{if(typeof r.parameterValue!="function")throw new Error(`Validator for ${r.fieldName} must be a function.`);
|
|
898
|
+
let o=r.parameterValue(r.value,r.object,r);if(Al(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
|
|
899
|
+
ronous.`);typeof o=="string"&&r.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),n("uppercase",r=>{if(typeof r.value=="str\
|
|
900
|
+
ing")return r.value.toUpperCase()}),n("lowercase",r=>{if(typeof r.value=="string")return r.value.toLowerCase()}),n("leng\
|
|
901
|
+
th",r=>{if(typeof r.value=="string")return r.value.substr(0,r.parameterValue);Number.isInteger(Number(r.valueBeforeCast))&&
|
|
902
|
+
String(r.valueBeforeCast).length>r.parameterValue&&r.throwParamError("RANGE_EXCEEDED","Numeric value is out of the allow\
|
|
903
|
+
ed character range.",{max:r.parameterValue,actual:String(r.valueBeforeCast).length})}),n("minItems",r=>{Array.isArray(r.
|
|
904
|
+
value)&&r.value.length<r.parameterValue&&r.throwParamError("MIN_ITEMS",`Must have at least ${r.parameterValue} items.`,{
|
|
905
|
+
min:r.parameterValue,actual:r.value.length})}),n("maxItems",r=>{Array.isArray(r.value)&&r.value.length>r.parameterValue&&
|
|
906
|
+
r.throwParamError("MAX_ITEMS",`Must have no more than ${r.parameterValue} items.`,{max:r.parameterValue,actual:r.value.length})}),
|
|
907
|
+
n("notEmpty",r=>{r.parameterValue&&typeof r.value=="string"&&r.value===""&&r.throwParamError("NOT_EMPTY","Field cannot b\
|
|
908
|
+
e empty.")}),n("required",()=>{}),n("unsigned",()=>{}),n("precision",()=>{}),n("scale",()=>{}),n("temporalPrecision",r=>{
|
|
909
|
+
if(r.definition.type!=="time"&&r.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
|
|
910
|
+
e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},xi=Ol;var _i=new WeakMap,Ei=new WeakMap,Ai=Symbol.for("json-rest-schema.registry-metadata"),rr=new WeakSet;function Rl(t,e,n){
|
|
911
|
+
if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);C(t,e,n)}function Pl(t,e,n){if(typeof n!=
|
|
912
|
+
"function")throw new Error(`Validator handler for '${e}' must be a function.`);C(t,e,n)}function nr(t={}){let e=Object.create(
|
|
913
|
+
null);for(let[n,r]of Object.entries(t))C(e,n,r);return e}function bi(t,e){if(typeof t.install!="function")throw new Error(
|
|
914
|
+
"Plugin must have an install method.");t.install(e)}function Ti(t,e,n){_i.set(t,e),Ei.set(t,n),Object.defineProperty(t,Ai,
|
|
915
|
+
{value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function kl(t){if(!t||
|
|
916
|
+
typeof t!="object"&&typeof t!="function")return null;let e=_i.get(t),n=Ei.get(t);if(e&&n)return{types:e,validators:n};let r=t[Ai];
|
|
917
|
+
return r&&typeof r.getTypes=="function"&&typeof r.getValidators=="function"?{types:r.getTypes(),validators:r.getValidators()}:
|
|
908
918
|
typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
|
|
909
919
|
nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
|
|
910
|
-
validators}:null}function
|
|
911
|
-
|
|
912
|
-
conflicting ${
|
|
913
|
-
e)};let o=Object.create(null),s=Object.create(null);for(let i of
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
let c=new
|
|
917
|
-
|
|
918
|
-
{types:a.types,validators:a.validators,installCore:!1})},
|
|
919
|
-
|
|
920
|
+
validators}:null}function Ml(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Ci(t,e,n){for(let[r,o]of Object.
|
|
921
|
+
entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(rr.has(o))continue;if(!rr.has(t[r]))throw new Error(`Cannot merge schema\
|
|
922
|
+
factories with conflicting ${n} "${r}".`)}C(t,r,o)}}function Nl(t,e,n){let r=Ml(n).filter(Boolean);if(r.length<1)return{
|
|
923
|
+
types:nr(t),validators:nr(e)};let o=Object.create(null),s=Object.create(null);for(let i of r){let a=kl(i);if(!a)throw new Error(
|
|
924
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");Ci(o,a.types,"type"),Ci(s,a.
|
|
925
|
+
validators,"validator")}return{types:o,validators:s}}function Oi({types:t={},validators:e={},installCore:n=!0}={}){let r=nr(
|
|
926
|
+
t),o=nr(e),s=(i,a={})=>{let c=new Be(i,r,o,a.operations);return Ti(c,r,o),c};return Ti(s,r,o),s.addType=(i,a)=>{Rl(r,i,a)},
|
|
927
|
+
s.addValidator=(i,a)=>{Pl(o,i,a)},s.use=i=>{bi(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{
|
|
928
|
+
let a=Nl(r,o,i);return Oi({types:a.types,validators:a.validators,installCore:!1})},n&&bi(xi,{addType:(i,a)=>{rr.add(a),s.
|
|
929
|
+
addType(i,a)},addValidator:(i,a)=>{rr.add(a),s.addValidator(i,a)}}),s}var Q=Oi({installCore:!0});var K_=Object.freeze({schema:Q({}),mode:"replace"});var Ri=/^[a-z][a-z0-9_.-]*$/u,Dl=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function zl(t){return String(t||"").trim().toLowerCase()}
|
|
930
|
+
function Nn(t,e){let n=zl(t);if(!Ri.test(n))throw new TypeError(`${e} must match ${Ri.toString()}.`);return n}function kn(t,e){
|
|
920
931
|
if(t==null)return Object.freeze({});if(!E(t))throw new TypeError(`${e} must be an object mapping local names to capabili\
|
|
921
|
-
ty ids.`);let
|
|
922
|
-
`${e} local name "${i}" must be a JavaScript identifier.`);let a=
|
|
923
|
-
declares capability "${a}" more than once.`);
|
|
924
|
-
freeze({});if(!E(t))throw new TypeError(`${
|
|
925
|
-
r.`);let
|
|
926
|
-
`${
|
|
927
|
-
.hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function
|
|
928
|
-
for(let[r
|
|
929
|
-
" is declared by both ${e.get(o)} and ${
|
|
930
|
-
throw new TypeError(`${e} must be a function when provided.`);return t}function
|
|
931
|
-
hints:o={},setup:s,boot:i=null,shutdown:a=null}={}){let c=
|
|
932
|
-
nal`),m=
|
|
933
|
-
`${c}.setup is required.`);return Object.freeze({id:c,requires:d,optional:p,provides:m,hints:
|
|
934
|
-
`${c}.boot`),shutdown:
|
|
932
|
+
ty ids.`);let n={},r=new Set;for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!Dl.test(i))throw new TypeError(
|
|
933
|
+
`${e} local name "${i}" must be a JavaScript identifier.`);let a=Nn(s,`${e}.${i}`);if(r.has(a))throw new TypeError(`${e}\
|
|
934
|
+
declares capability "${a}" more than once.`);r.add(a),n[i]=a}return Object.freeze(n)}function Ll(t,e,n){if(t==null)return Object.
|
|
935
|
+
freeze({});if(!E(t))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
|
|
936
|
+
r.`);let r=new Set(Object.values(e)),o={};for(let[s,i]of Object.entries(t)){let a=Nn(s,`${n}.hints key`);if(!r.has(a))throw new TypeError(
|
|
937
|
+
`${n}.hints names "${a}", which the provider does not require.`);if(typeof i!="string"||!i.trim())throw new TypeError(`${n}\
|
|
938
|
+
.hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function Ul(t){let e=new Map;
|
|
939
|
+
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}\
|
|
940
|
+
" is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function Mn(t,e){if(t==null)return null;if(typeof t!="function")
|
|
941
|
+
throw new TypeError(`${e} must be a function when provided.`);return t}function or({id:t,requires:e={},optional:n={},provides:r={},
|
|
942
|
+
hints:o={},setup:s,boot:i=null,shutdown:a=null}={}){let c=Nn(t,"Provider id"),d=kn(e,`${c}.requires`),p=kn(n,`${c}.optio\
|
|
943
|
+
nal`),m=kn(r,`${c}.provides`);Ul({requires:d,optional:p,provides:m});let l=Mn(s,`${c}.setup`);if(!l)throw new TypeError(
|
|
944
|
+
`${c}.setup is required.`);return Object.freeze({id:c,requires:d,optional:p,provides:m,hints:Ll(o,d,c),setup:l,boot:Mn(i,
|
|
945
|
+
`${c}.boot`),shutdown:Mn(a,`${c}.shutdown`)})}var Pi="public";var Fl="/api",ki=`${Fl}/bootstrap`;function Dn(){let t=[],e=new Set,n=!1;function r({id:a,order:c=0,contribute:d}={}){if(n)throw new Error("Bootstrap regis\
|
|
935
946
|
tration is closed after the first payload is resolved.");let p=_(a);if(!p)throw new TypeError("Bootstrap contributor id \
|
|
936
947
|
is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${p}" requires contribute().`);if(e.has(
|
|
937
948
|
p))throw new Error(`Bootstrap contributor "${p}" is duplicated.`);return e.add(p),t.push(Object.freeze({id:p,order:Number.
|
|
938
|
-
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){
|
|
949
|
+
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(
|
|
939
950
|
(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.
|
|
940
951
|
freeze({...E(a)?a:{},payload:Object.freeze({...c})}));c={...c,...E(m)?m:{}}}return Object.freeze(c)}function s(){return Object.
|
|
941
|
-
freeze({sealed:
|
|
942
|
-
return i}var
|
|
943
|
-
let e=
|
|
944
|
-
async(r
|
|
952
|
+
freeze({sealed:n,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:r,resolve:o,diagnostics:s});
|
|
953
|
+
return i}var ql=or({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:t}){
|
|
954
|
+
let e=Dn();return t.router.register("GET",ki,{auth:Pi,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
|
|
955
|
+
async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});function $l(t){if(!E(t))throw new TypeError("Event listener must be an object.");let e=String(t.id||"").trim();if(!e)throw new TypeError(
|
|
945
956
|
"Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(`Event listener "${e}" requires han\
|
|
946
957
|
dle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event listener "${e}" matches must be a f\
|
|
947
|
-
unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function
|
|
958
|
+
unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function Bl(t){if(!E(t))throw new TypeError(
|
|
948
959
|
"Published event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is\
|
|
949
|
-
required.");return Object.freeze({...t,type:e})}function
|
|
950
|
-
throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function
|
|
960
|
+
required.");return Object.freeze({...t,type:e})}function zn(){let t=[],e=new Set;function n(i){let a=$l(i);if(e.has(a.id))
|
|
961
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function r(i){let a=Bl(i);
|
|
951
962
|
for(let c of t)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
952
|
-
freeze(t.map(i=>i.id))})}let s=Object.freeze({register:
|
|
953
|
-
t))Ce(t[
|
|
963
|
+
freeze(t.map(i=>i.id))})}let s=Object.freeze({register:n,publish:r,diagnostics:o});return s}var Hl=or({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:zn()}}});function Ce(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let n of Object.getOwnPropertyNames(
|
|
964
|
+
t))Ce(t[n],e);return Object.freeze(t)}var UE=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},TYPE_CAST_FAILED:{messageKey:"\
|
|
954
965
|
default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",code:"kernel.validation.field\
|
|
955
966
|
.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},MAX_LENGTH:{messageKey:"maxL\
|
|
956
967
|
ength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kernel.validation.field.minItems"},
|
|
@@ -960,10 +971,10 @@ code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kern
|
|
|
960
971
|
messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"valida\
|
|
961
972
|
tor",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"\
|
|
962
973
|
default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validation.field.not\
|
|
963
|
-
Empty"}}),
|
|
964
|
-
ace","patch","toJsonSchema"]);var
|
|
965
|
-
mode:"patch"});var
|
|
966
|
-
{...
|
|
974
|
+
Empty"}}),FE=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),qE=Object.freeze(["create","repl\
|
|
975
|
+
ace","patch","toJsonSchema"]);var Kl=Q({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Jl=Object.freeze({schema:Kl,
|
|
976
|
+
mode:"patch"});var Ni=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),Xl=Object.freeze(
|
|
977
|
+
{...Ni,nullable:!0});var pA=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
|
|
967
978
|
minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.maxLength"},{keyword:"minimu\
|
|
968
979
|
m",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"exclusiveMinimum",code:"\
|
|
969
980
|
kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusiveMaximum"},{keyword:"mu\
|
|
@@ -975,32 +986,32 @@ additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems
|
|
|
975
986
|
perties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"propertyNames",code:"\
|
|
976
987
|
kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",code:"kernel.validat\
|
|
977
988
|
ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:t,code:e})=>[
|
|
978
|
-
t,e]));var
|
|
979
|
-
...
|
|
980
|
-
itive integer string."}}}}),mode:"patch"});var
|
|
981
|
-
execute:"assistant_action_execute"}),
|
|
989
|
+
t,e]));var ji="^[1-9][0-9]*$",Ln=Ce({type:"string",minLength:1,pattern:ji}),Zl=Ce({...Ln,nullable:!0}),Ql=Ce({schema:Q({recordId:{
|
|
990
|
+
...Ln,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
|
|
991
|
+
itive integer string."}}}}),mode:"patch"});var Di=20,aO=32*1024,cO=48*1024,Un=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
992
|
+
execute:"assistant_action_execute"}),Fn=Object.freeze({type:"object",additionalProperties:!0}),rp=Object.freeze({type:"o\
|
|
982
993
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
983
994
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
984
995
|
ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
|
|
985
|
-
limit:{type:"integer",minimum:1,maximum:
|
|
986
|
-
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:
|
|
996
|
+
limit:{type:"integer",minimum:1,maximum:Di,description:"Maximum compact matches to return."}}}),np=Object.freeze({type:"\
|
|
997
|
+
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Di,items:{
|
|
987
998
|
type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
|
|
988
999
|
tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
|
|
989
|
-
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),
|
|
990
|
-
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),
|
|
1000
|
+
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),op=Object.freeze({type:"object",additionalProperties:!1,required:[
|
|
1001
|
+
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),sp=Object.
|
|
991
1002
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
|
|
992
1003
|
chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
|
|
993
|
-
string"},inputSchema:
|
|
994
|
-
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:
|
|
1004
|
+
string"},inputSchema:Fn,outputSchema:Fn}}),ip=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
1005
|
+
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Fn}}),ap=Object.
|
|
995
1006
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
996
|
-
g"},version:{type:"integer",minimum:1},result:{}}}),
|
|
1007
|
+
g"},version:{type:"integer",minimum:1},result:{}}}),zi=Object.freeze([Object.freeze({name:Un.search,description:"Discove\
|
|
997
1008
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
998
1009
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
999
|
-
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:
|
|
1000
|
-
outputSchema:
|
|
1001
|
-
e action before executing it.",parameters:
|
|
1002
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:
|
|
1003
|
-
ersation_attachments_not_configured",messageCode:"assistant.conversation.attachmentsNotConfigured"})}});var
|
|
1010
|
+
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:rp,
|
|
1011
|
+
outputSchema:np}),Object.freeze({name:Un.contract,description:"Load the exact input and output contract for one availabl\
|
|
1012
|
+
e action before executing it.",parameters:op,outputSchema:sp}),Object.freeze({name:Un.execute,description:"Execute one a\
|
|
1013
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:ip,outputSchema:ap})]);var mR=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var IR=256*1024;var SR=2*1024*1024;var xR=zi.map(({name:t,description:e,parameters:n})=>({type:"function",function:{name:t,description:e,parameters:n}}));var ZR=Object.freeze({});var uP=Object.freeze([]);var Tp=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 yP=Object.freeze([{message:"This conversation exceeds the configured API history limit. Start another conversation o\
|
|
1004
1015
|
r increase the limit.",messageCode:"assistant.conversation.apiHistoryLimit"},{message:"The model reached its output toke\
|
|
1005
1016
|
n limit before completing the answer. Increase maxOutputTokens in the conversation limits.",messageCode:"assistant.conve\
|
|
1006
1017
|
rsation.outputTokenLimit"},{message:"The model stream ended without confirming its application tool calls.",messageCode:"\
|
|
@@ -1019,21 +1030,21 @@ t be saved. Restore storage access and retry saving.",messageCode:"assistant.con
|
|
|
1019
1030
|
Conversation progress could not be saved. Restore access to its storage before continuing.",messageCode:"assistant.conve\
|
|
1020
1031
|
rsation.progressUnsaved"},{message:"The conversation request exceeded its time limit.",messageCode:"assistant.conversati\
|
|
1021
1032
|
on.requestTimedOut"},{message:"Work stopped.",messageCode:"assistant.conversation.workStopped"},{message:"Stopped by use\
|
|
1022
|
-
r.",messageCode:"assistant.conversation.stoppedByUser"}]);var
|
|
1023
|
-
type:"string",maxLength:
|
|
1033
|
+
r.",messageCode:"assistant.conversation.stoppedByUser"}]);var Ve=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var ok=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}}),sk={type:"\
|
|
1024
1035
|
object",additionalProperties:!1,required:["kind","text","toolName","arguments"],properties:{kind:{type:"string",enum:["r\
|
|
1025
|
-
eply","tool"]},text:{type:"string",maxLength:
|
|
1026
|
-
first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:
|
|
1027
|
-
string",maxLength:
|
|
1028
|
-
readInstructions:e=
|
|
1029
|
-
ver.");return async function(
|
|
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 sM=Object.freeze({});function Np(){throw new TypeError("Hook delivery requires an instruction resolver.")}function Kn({resolveConversation:t,
|
|
1039
|
+
readInstructions:e=Np}){if(typeof t!="function")throw new TypeError("Conversation hook delivery requires a binding resol\
|
|
1040
|
+
ver.");return async function(r){if(r.scope!=="session")return{kind:"unclaimed"};let o=await t(r);if(!o)return{kind:"uncl\
|
|
1030
1041
|
aimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError("Unknown con\
|
|
1031
|
-
versation instruction delivery mode.");let s=await e(o,
|
|
1032
|
-
conversation instructions are unavailable.");return{kind:"delivery",text:s}}}var
|
|
1042
|
+
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 cM=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
1033
1044
|
allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
1034
1045
|
test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
|
|
1035
|
-
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as
|
|
1036
|
-
"managedPreview"])
|
|
1046
|
+
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as jp}from"node:fs/promises";import Jn from"node:path";function ir(t){return String(t||"").trim()}var Dp=Object.freeze(["main","temporary"]),Vi=Object.freeze(["managedDatabaseRefresh","managedEnvironment","managedGit",
|
|
1047
|
+
"managedPreview"]),Gi=Object.freeze(["managedPages"]),zp=64*1024,FM=Object.freeze(["When user input is necessary, ask no\
|
|
1037
1048
|
more than three concise, high-impact questions at once.","Put multiple questions on separate lines as `[1] Question`, `\
|
|
1038
1049
|
[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answers:` and a short bullet list dir\
|
|
1039
1050
|
ectly beneath its own question, before the next one; never collect several questions' answers into one trailing list.","\
|
|
@@ -1046,7 +1057,7 @@ Possible answers:
|
|
|
1046
1057
|
[2] Tell the main agent before changes?
|
|
1047
1058
|
Possible answers:
|
|
1048
1059
|
- Yes, tell main first
|
|
1049
|
-
- No, proceed independently`]),
|
|
1060
|
+
- No, proceed independently`]),qM=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
|
|
1050
1061
|
start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
|
|
1051
1062
|
nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
|
|
1052
1063
|
ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
|
|
@@ -1061,108 +1072,111 @@ eview-identities`), then verify each with `vibe64-helper preview browser identit
|
|
|
1061
1072
|
s per-run enable flag and secret. Do not create users, change roles, reset passwords or weaken production auth for impor\
|
|
1062
1073
|
t. If choices are deferred/declined, say access stays unconfigured and continue independent setup work without repeated \
|
|
1063
1074
|
credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview status`, `screenshot`, `logs`, an\
|
|
1064
|
-
d `browser eval` (Playwright code on stdin) for rendered inspection.","
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
t
|
|
1147
|
-
|
|
1148
|
-
"Vibe64 session
|
|
1149
|
-
|
|
1150
|
-
throw new TypeError(
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
"session"
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
"
|
|
1158
|
-
|
|
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."]),$M=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
|
+
BM=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]`; never put values in arguments, logs, or repository files. Use e\
|
|
1147
|
+
mpty stdin only when the user requested an empty value. The host decides whose session may change production values; whe\
|
|
1148
|
+
n it refuses, report its message instead of retrying.","When the person refers to a saved key, account or accounts hub, \
|
|
1149
|
+
run `vibe64-helper env saved` (names, descriptions and fields, never values) and link the matching field to the variable\
|
|
1150
|
+
the application reads with `vibe64-helper env link <development|production> <KEY> <saved-id> <field-id>` instead of ask\
|
|
1151
|
+
ing for the value.","Keep development and production values separate. Never invent credentials, copy a value between sco\
|
|
1152
|
+
pes without explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affecte\
|
|
1153
|
+
d scope and key names, never their values, and claim success only when the command succeeded.","Store a secret the appli\
|
|
1154
|
+
cation needs generated (such as an application key) by generating it with the framework's own generator and piping it to\
|
|
1155
|
+
`vibe64-helper env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that fi\
|
|
1156
|
+
le from Env."]);function Xn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object\
|
|
1157
|
+
.`);return t}function mt(t,e,n){let r=new Set(e),o=Object.keys(t).filter(s=>!r.has(s));if(o.length>0)throw new TypeError(
|
|
1158
|
+
`${n} contains unsupported fields: ${o.join(", ")}.`)}function Lp(t){if(mt(t,["conversationKind","scope","session","host\
|
|
1159
|
+
Guidance"],"Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,
|
|
1160
|
+
"utf8")>1024))throw new TypeError("Vibe64 host guidance must be bounded text supplied by the host.");if(!Dp.includes(t.conversationKind))
|
|
1161
|
+
throw new TypeError("Vibe64 session context has an unknown conversationKind.");let e=Xn(t.session,"Vibe64 session capabi\
|
|
1162
|
+
lities");mt(e,[...Vi,...Gi],"Vibe64 session capabilities");let n=Object.fromEntries(Vi.map(r=>{if(typeof e[r]!="boolean")
|
|
1163
|
+
throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);return[r,e[r]]}));for(let r of Gi){if(e[r]!==void 0&&
|
|
1164
|
+
typeof e[r]!="boolean")throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);e[r]===!0&&(n[r]=!0)}return{
|
|
1165
|
+
conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:n}}function Up(t){
|
|
1166
|
+
mt(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").trim();if(!e||e.length>zp)throw new TypeError(
|
|
1167
|
+
"Vibe64 ephemeral context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function Fp(t){if(t.
|
|
1168
|
+
scope==="session")return Lp(t);if(t.scope==="ephemeral")return Up(t);throw new TypeError("The Vibe64 driver supports ses\
|
|
1169
|
+
sion and ephemeral scopes only.")}async function Wi(t={},{readRegistry:e=jp,workdir:n=""}={}){let r=Xn(t,"Vibe64 host resolver request");if(mt(r,["data","\
|
|
1170
|
+
providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(r.scope))throw new TypeError(
|
|
1171
|
+
"The Vibe64 host resolver scope must be session or turn.");if(r.scope==="turn")return null;let o=Xn(r.data,"Vibe64 host \
|
|
1172
|
+
resolver data");mt(o,["registryPath"],"Vibe64 host resolver data");let s=ir(o.registryPath);if(!Jn.isAbsolute(s))throw new TypeError(
|
|
1159
1173
|
"Vibe64 host resolver data requires an absolute registryPath.");let i=JSON.parse(await e(s,"utf8"));if(!Array.isArray(i?.
|
|
1160
|
-
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=
|
|
1161
|
-
if(
|
|
1162
|
-
l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let p=[c,...
|
|
1163
|
-
[]].filter(Boolean).map(l=>a.find(v=>
|
|
1164
|
-
p.workdir&&
|
|
1165
|
-
t directory.");return
|
|
1166
|
-
tion input exceeds 256 KiB.");var
|
|
1167
|
-
process.stdout.write(await t(
|
|
1168
|
-
native"}:null});process.stdout.write(JSON.stringify(await t(
|
|
1174
|
+
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=ir(r.providerSessionId);
|
|
1175
|
+
if(r.parentSessionIds!==void 0&&(!Array.isArray(r.parentSessionIds)||r.parentSessionIds.length>32||r.parentSessionIds.some(
|
|
1176
|
+
l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let p=[c,...r.parentSessionIds||
|
|
1177
|
+
[]].filter(Boolean).map(l=>a.find(v=>ir(v?.upstreamSessionId)===l)).find(Boolean),m=p?.promptContext;if(!m)return null;if(n&&
|
|
1178
|
+
p.workdir&&Jn.resolve(n)!==Jn.resolve(p.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
1179
|
+
t directory.");return Fp(m)}var Yn="";for await(let t of process.stdin)if(Yn+=t,Buffer.byteLength(Yn)>256*1024)throw new Error("Conversation instruc\
|
|
1180
|
+
tion input exceeds 256 KiB.");var Ki=JSON.parse(Yn);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1181
|
+
process.stdout.write(await t(Ki))}else{let t=Kn({resolveConversation:async e=>await Wi(e,{workdir:process.cwd()})?{delivery:"\
|
|
1182
|
+
native"}:null});process.stdout.write(JSON.stringify(await t(Ki)))}
|