vibe64 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +1919 -1660
- package/bin/server.js +158 -111
- package/bin/upgrade-state.js +5783 -5605
- package/dist/assets/GithubBrowserTabs-BzJF4k9Y.js +1 -0
- package/dist/assets/{StudioErrorNotice-sQfmeR-z.js → StudioErrorNotice-BdllGqRy.js} +1 -1
- package/dist/assets/{Vibe64AsyncModuleState-Dx7YKRPp.js → Vibe64AsyncModuleState-Bi0TqlIu.js} +1 -1
- package/dist/assets/Vibe64AuthSettingsButton-BuvmwGiT.js +5 -0
- package/dist/assets/Vibe64AuthSettingsButton-M44SSmZ9.css +1 -0
- package/dist/assets/{Vibe64DashboardBackButton-yE6cyYg2.js → Vibe64DashboardBackButton-Ccd4hpD6.js} +1 -1
- package/dist/assets/Vibe64DashboardShell-D67m4aWz.js +1 -0
- package/dist/assets/{Vibe64DashboardShell-MBkUHjs-.css → Vibe64DashboardShell-De2mbdpI.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-BONJdxBS.js → Vibe64DatabaseWorkspace-D3uK1gDm.js} +3 -3
- package/dist/assets/{Vibe64DatabaseWorkspace-CR4pzzcf.css → Vibe64DatabaseWorkspace-DPDMxhAW.css} +1 -1
- package/dist/assets/Vibe64OutputControls-BfESn5kJ.js +8 -0
- package/dist/assets/Vibe64OutputControls-D2CCECo5.css +1 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-ByQlZbyO.js → Vibe64RepositoryWorkspace-0jAxvdA8.js} +2 -2
- package/dist/assets/{Vibe64RepositoryWorkspace-CVHcT93M.css → Vibe64RepositoryWorkspace-Agyt4O-V.css} +1 -1
- package/dist/assets/Vibe64SessionFiles-B3ONZrBL.css +1 -0
- package/dist/assets/Vibe64SessionFiles-BCOJ4QmR.js +41 -0
- package/dist/assets/{Vibe64TemporaryAiFixAction-BGlcrq4d.js → Vibe64TemporaryAiFixAction-DM2jpPbQ.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-Brlwdvqi.js → Vibe64UiStoryboardView-DP5af46a.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-zwlWlcZD.js → Vibe64UnavailableSessions-C7XwH1SS.js} +1 -1
- package/dist/assets/{_sessionId_-CvOkQbVy.js → _sessionId_-B1Ymr7c_.js} +1 -1
- package/dist/assets/{_sessionTool_-Dwod5ns9.js → _sessionTool_-DVYdREoI.js} +1 -1
- package/dist/assets/_slug_-CQseA9pt.css +1 -0
- package/dist/assets/_slug_-CYO2vjCd.js +24 -0
- package/dist/assets/{access-BVu5XYm2.js → access-Cb7dkN53.js} +1 -1
- package/dist/assets/app-BvgY7oVf.js +1 -0
- package/dist/assets/app-CZu7oxUO.css +1 -0
- package/dist/assets/{assistantRouting-CwbwfkwB.js → assistantRouting-B38ujQ7x.js} +1 -1
- package/dist/assets/{changes-olY8cnFK.js → changes-lsBcuikn.js} +1 -1
- package/dist/assets/client-CRI5CNKl.js +2 -0
- package/dist/assets/client-TGaWwOhc.css +1 -0
- package/dist/assets/conversation-CDEt9jBx.js +17 -0
- package/dist/assets/conversation-vxJGwmtW.css +1 -0
- package/dist/assets/{dashboard-BnXD-H4R.js → dashboard-D8HOAw46.js} +1 -1
- package/dist/assets/definitions-DLTX17nI.js +1 -0
- package/dist/assets/{env-DJhnLOH7.css → env-BzRtyO0w.css} +1 -1
- package/dist/assets/env-DJezQixO.js +1 -0
- package/dist/assets/health-BJvooRnJ.css +1 -0
- package/dist/assets/health-CtKdN_Nf.js +1 -0
- package/dist/assets/{history-BxlpB-YH.js → history-BdZFOtz4.js} +1 -1
- package/dist/assets/{incoming-BOxRVlOM.js → incoming-VsQNnL9m.js} +1 -1
- package/dist/assets/index-C-osVUKw.css +1 -0
- package/dist/assets/index-C4K3ntms.js +138 -0
- package/dist/assets/{integrations-BFltGDVI.js → integrations-CMQ9EDmt.js} +2 -2
- package/dist/assets/issues-DHpY5hSr.js +1 -0
- package/dist/assets/learning-DXlMuwzh.js +1 -0
- package/dist/assets/mdi-yXT-CQ6u.js +1 -0
- package/dist/assets/placement-NpX2s7u8.js +1 -0
- package/dist/assets/pull-requests-BcKNEUYH.js +1 -0
- package/dist/assets/{repository-JWLVST3D.js → repository-ClEgntHW.js} +1 -1
- package/dist/assets/roboto-latin-wght-normal-ccAYIvAh.woff2 +0 -0
- package/dist/assets/{session-C5Nj8Dlq.js → session-BlD46q-d.js} +1 -1
- package/dist/assets/settings-BwukeIKe.js +1 -0
- package/dist/assets/shared-BM2SV6fi.js +2 -0
- package/dist/assets/studioGateApi-DcCqiD9V.js +1 -0
- package/dist/assets/studioUrls-DmMMIScP.js +1 -0
- package/dist/assets/useArchivedVibe64Sessions-D5zUA-BC.js +1 -0
- package/dist/assets/useCommand-Bqxb-naz.js +1 -0
- package/dist/assets/useEndpointResource-DWoQ2keu.js +1 -0
- package/dist/assets/useRealtimeEvent-Bwapstla.js +1 -0
- package/dist/assets/{useUiFeedback-0FqKuZRP.js → useUiFeedback-BPBF_0bp.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-Dy6YTPQn.js +1 -0
- package/dist/assets/useVibe64DatabaseTools-d6L09ugW.js +1 -0
- package/dist/assets/useVibe64Learning-cNKTv64W.js +1 -0
- package/dist/assets/useVibe64ProjectScope-Bp1ImZlz.js +1 -0
- package/dist/assets/useVibe64SessionData-C_jqncih.js +1 -0
- package/dist/assets/useVibe64SessionSelection-uCEIWd3b.js +1 -0
- package/dist/assets/useVibe64SystemGraph-B4RmsC9Y.js +1 -0
- package/dist/assets/{useVibe64Terminal-BPnN25WH.js → useVibe64Terminal-BbghGR4x.js} +1 -1
- package/dist/assets/vibe64AssistantHost-BL1bnKm8.js +1 -0
- package/dist/assets/{vibe64SessionFocus-kqPOPaOH.js → vibe64SessionFocus-DSJKVuRN.js} +1 -1
- package/dist/assets/{vibe64SessionInfo-BHxtTrLX.js → vibe64SessionInfo-B_r1OMN0.js} +1 -1
- package/dist/assets/{vibe64SessionPanelModel-BMf64fv7.js → vibe64SessionPanelModel-DDorOuiL.js} +1 -1
- package/dist/assets/{vibe64SessionToolDefinitions-NfLd1HZI.js → vibe64SessionToolDefinitions-BualCK_5.js} +1 -1
- package/dist/index.html +21 -20
- package/docs/colleague-usage/account-profile-and-appearance.md +8 -2
- package/docs/colleague-usage/ai-accounts-and-routing.md +123 -15
- package/docs/colleague-usage/ai-onboarding.md +230 -0
- package/docs/colleague-usage/coding-agent-goal-pause.md +5 -5
- package/docs/colleague-usage/coding-agents.md +17 -0
- package/docs/colleague-usage/colleague-watches.md +4 -23
- package/docs/colleague-usage/colleague.md +10 -2
- package/docs/colleague-usage/connected-projects.md +2 -2
- package/docs/colleague-usage/conversation-context.md +2 -0
- package/docs/colleague-usage/dashboard-navigation.md +19 -27
- package/docs/colleague-usage/database.md +6 -11
- package/docs/colleague-usage/development-copies.md +2 -1
- package/docs/colleague-usage/development-env.md +6 -0
- package/docs/colleague-usage/github-work.md +9 -0
- package/docs/colleague-usage/health-checks.md +11 -5
- package/docs/colleague-usage/integrations.md +3 -1
- package/docs/colleague-usage/learning-code-questions.md +23 -51
- package/docs/colleague-usage/learning-course-catalogue.md +8 -6
- package/docs/colleague-usage/learning-environment.md +345 -0
- package/docs/colleague-usage/learning-history.md +70 -101
- package/docs/colleague-usage/learning-mode-ui.md +122 -214
- package/docs/colleague-usage/learning-practice-projects.md +168 -78
- package/docs/colleague-usage/learning-teacher-guide.md +48 -26
- package/docs/colleague-usage/learning-with-colleague.md +171 -216
- package/docs/colleague-usage/lesson-authoring.md +32 -24
- package/docs/colleague-usage/managed-app-access.md +7 -0
- package/docs/colleague-usage/message-delivery-recovery.md +7 -6
- package/docs/colleague-usage/preview-browser-checks.md +9 -1
- package/docs/colleague-usage/preview-starting-application.md +0 -1
- package/docs/colleague-usage/preview.md +9 -1
- package/docs/colleague-usage/project-messages.md +2 -2
- package/docs/colleague-usage/project-setup.md +9 -2
- package/docs/colleague-usage/running-vibe64-on-your-computer.md +61 -0
- package/docs/colleague-usage/sessions.md +25 -33
- package/docs/colleague-usage/teaching-content.md +11 -40
- package/docs/colleague-usage/temporary-chats.md +23 -2
- package/docs/colleague-usage/voice-chat.md +5 -10
- package/docs/colleague-usage/voice-face-and-speaking-voice.md +6 -8
- package/docs/colleague-usage/voice-recovery.md +3 -2
- package/docs/templates/learn-topic/README.md +6 -6
- package/docs/templates/learn-topic/training/lessons/TOPIC-01/lesson.json +28 -7
- package/docs/templates/learn-topic/training/lessons/TOPIC-01/notes.md +19 -0
- package/docs/templates/learn-topic/training/lessons/TOPIC-01/steps/check-understanding.md +3 -0
- package/docs/templates/learn-topic/training/lessons/TOPIC-01/steps/explain-idea.md +3 -0
- package/docs/templates/learn-topic/training/lessons/TOPIC-01/steps/try-it.md +3 -0
- package/docs/templates/learn-topic/training/outline.md +1 -1
- package/docs/training-content.md +179 -65
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/patterns/assistant-surface/PATTERN.md +3 -2
- package/node_modules/@jskit-ai/assistant-runtime/patterns/assistant-surface/example/integrations.json +3 -2
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/patterns/ai-connections/PATTERN.md +4 -3
- package/node_modules/@jskit-ai/connectors-catalog/src/shared/ai-models.json +0 -1
- package/node_modules/@local/vibe64-accounts/package.json +1 -0
- package/node_modules/@local/vibe64-colleague/package.json +2 -1
- package/node_modules/@local/vibe64-core/package.json +3 -0
- package/node_modules/@local/vibe64-execution/package.json +1 -0
- package/node_modules/@local/vibe64-execution/src/server/engines/stdioBridge.js +9 -9
- package/node_modules/@local/vibe64-genesis/README.md +10 -37
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +790 -779
- package/node_modules/@local/vibe64-genesis/package.json +1 -0
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +255 -0
- package/node_modules/@local/vibe64-genesis/src/server/index.js +473 -450
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +148 -148
- package/node_modules/@local/vibe64-project/package.json +2 -1
- package/node_modules/@local/vibe64-runtime/package.json +1 -2
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +526 -512
- package/node_modules/@local/vibe64-runtime/src/shared/assistantRoutingScores.json +0 -1
- package/node_modules/@local/vibe64-source-editor/package.json +1 -0
- package/node_modules/@local/vibe64-terminals/package.json +1 -0
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +129 -131
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1508 -1456
- package/node_modules/@local/vibe64-training/package.json +13 -27
- package/package.json +7 -7
- package/server.bundle.mjs +40946 -41456
- package/dist/assets/GithubBrowserTabs-DO5PHon-.js +0 -1
- package/dist/assets/GithubMarkdown-BQ6MfCDJ.js +0 -3
- package/dist/assets/GithubMarkdown-U7-j-qNI.css +0 -1
- package/dist/assets/Vibe64DashboardShell-CuCVMhOc.js +0 -1
- package/dist/assets/Vibe64OutputControls-DAAmA09l.js +0 -8
- package/dist/assets/Vibe64OutputControls-DPBsyDZM.css +0 -1
- package/dist/assets/Vibe64SessionFiles-B0u9HKdF.js +0 -107
- package/dist/assets/Vibe64SessionFiles-NjOMVwPR.css +0 -1
- package/dist/assets/_slug_-B31c15cc.css +0 -1
- package/dist/assets/_slug_-Dy35qLo1.js +0 -1
- package/dist/assets/app-DRXCcv05.css +0 -1
- package/dist/assets/app-zt7HwQKT.js +0 -1
- package/dist/assets/client-BrV4QPwG.js +0 -2
- package/dist/assets/client-C1bwIlu6.css +0 -1
- package/dist/assets/definitions-DaOPIkyB.js +0 -1
- package/dist/assets/env-DN0vW4EI.js +0 -1
- package/dist/assets/health-7oIQODer.css +0 -1
- package/dist/assets/health-Z6m96GDr.js +0 -1
- package/dist/assets/index-BUq-MczL.js +0 -86
- package/dist/assets/index-DtmBqE3h.css +0 -1
- package/dist/assets/issues-1iS5zoed.js +0 -1
- package/dist/assets/layout-BkWVNT37.js +0 -1
- package/dist/assets/mdi-C54lQ0i_.js +0 -1
- package/dist/assets/placement-DLsU3pCW.js +0 -1
- package/dist/assets/pull-requests-BJOwNL4k.js +0 -1
- package/dist/assets/settings-c273Ikrm.js +0 -1
- package/dist/assets/shared-YZb7ocaK.js +0 -2
- package/dist/assets/studioGateApi-DhA9IJGZ.js +0 -1
- package/dist/assets/studioUrls-Dj8rXeXO.js +0 -1
- package/dist/assets/useArchivedVibe64Sessions-CVZx2Rtm.js +0 -1
- package/dist/assets/useCommand-DWuxfAV0.js +0 -1
- package/dist/assets/useEndpointResource-MWVNfmMa.js +0 -1
- package/dist/assets/useVibe64ConversationLog-8cKh1eDm.js +0 -1
- package/dist/assets/useVibe64DatabaseTools-BcRG1s3i.js +0 -1
- package/dist/assets/useVibe64LearningMode-Bl0dGdCh.js +0 -28
- package/dist/assets/useVibe64LearningMode-C3PcXdVg.css +0 -1
- package/dist/assets/useVibe64ProjectScope-DOEVkBqX.js +0 -1
- package/dist/assets/useVibe64SessionData-DFTyLzci.js +0 -1
- package/dist/assets/useVibe64SessionSelection-j9lsllx4.js +0 -1
- package/dist/assets/useVibe64SystemGraph-tNkIwSBQ.js +0 -1
- package/dist/assets/vibe64AssistantHost-DdE_-lZF.js +0 -1
- package/dist/assets/vibe64LessonDashboard-DlKYjisq.js +0 -1
- package/dist/assets/vibe64ProjectScope.local-DqT6e5un.js +0 -1
- package/docs/colleague-usage/learning-chat-retention.md +0 -74
- package/docs/colleague-usage/learning-diagrams-and-voice.md +0 -97
- package/docs/colleague-usage/learning-lesson-watch.md +0 -95
- package/docs/colleague-usage/learning-native-session.md +0 -206
- package/docs/colleague-usage/learning-practical-exercises.md +0 -71
- package/docs/colleague-usage/learning-practical-gestures.md +0 -48
- package/docs/colleague-usage/learning-session-creation.md +0 -95
- package/docs/colleague-usage/lesson-practical-assessment.md +0 -54
- package/docs/colleague-usage/preview-lesson-presentation.md +0 -56
- package/docs/templates/learn-topic/training/lessons/TOPIC-01/lesson.md +0 -44
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var
|
|
5
|
-
enumerable:!(n=
|
|
6
|
-
exports={BINARY_TYPES:
|
|
3
|
+
var Xs=Object.create;var rn=Object.defineProperty;var Ys=Object.getOwnPropertyDescriptor;var Qs=Object.getOwnPropertyNames;var Zs=Object.getPrototypeOf,ei=Object.prototype.hasOwnProperty;var M=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){
|
|
4
|
+
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var W=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var ti=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qs(e))!ei.call(t,o)&&o!==r&&rn(t,o,{get:()=>e[o],
|
|
5
|
+
enumerable:!(n=Ys(e,o))||n.enumerable});return t};var ae=(t,e,r)=>(r=t!=null?Xs(Zs(t)):{},ti(e||!t||!t.__esModule?rn(r,"default",{value:t,enumerable:!0}):r,t));var Z=W((wl,cn)=>{"use strict";var sn=["nodebuffer","arraybuffer","fragments"],an=typeof Blob<"u";an&&sn.push("blob");cn.
|
|
6
|
+
exports={BINARY_TYPES:sn,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:an,
|
|
7
7
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
8
|
-
"websocket"),NOOP:()=>{}}});var
|
|
8
|
+
"websocket"),NOOP:()=>{}}});var Ue=W((yl,ct)=>{"use strict";var{EMPTY_BUFFER:ni}=Z(),Vt=Buffer[Symbol.species];function oi(t,e){if(t.length===0)return ni;
|
|
9
9
|
if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let o=0;o<t.length;o++){let s=t[o];r.set(s,n),n+=s.length}
|
|
10
|
-
return n<e?new
|
|
11
|
-
for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function
|
|
12
|
-
t.byteOffset+t.length)}function
|
|
13
|
-
e=new
|
|
14
|
-
{concat:
|
|
15
|
-
exports.mask=function(e,r,n,o,s){s<48?
|
|
16
|
-
r):t.unmask(e,r)}}catch{}});var
|
|
17
|
-
this[
|
|
18
|
-
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[
|
|
19
|
-
from([0,0,255,255]),
|
|
20
|
-
|
|
10
|
+
return n<e?new Vt(r.buffer,r.byteOffset,n):r}function dn(t,e,r,n,o){for(let s=0;s<o;s++)r[n+s]=t[s]^e[s&3]}function un(t,e){
|
|
11
|
+
for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function si(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
|
|
12
|
+
t.byteOffset+t.length)}function Gt(t){if(Gt.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
|
|
13
|
+
e=new Vt(t):ArrayBuffer.isView(t)?e=new Vt(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Gt.readOnly=!1),e}ct.exports=
|
|
14
|
+
{concat:oi,mask:dn,toArrayBuffer:si,toBuffer:Gt,unmask:un};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=M("bufferutil");ct.
|
|
15
|
+
exports.mask=function(e,r,n,o,s){s<48?dn(e,r,n,o,s):t.mask(e,r,n,o,s)},ct.exports.unmask=function(e,r){e.length<32?un(e,
|
|
16
|
+
r):t.unmask(e,r)}}catch{}});var fn=W((Il,pn)=>{"use strict";var ln=Symbol("kDone"),Wt=Symbol("kRun"),Kt=class{constructor(e){this[ln]=()=>{this.pending--,
|
|
17
|
+
this[Wt]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Wt]()}[Wt](){if(this.pending!==
|
|
18
|
+
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ln])}}};pn.exports=Kt});var Oe=W((Sl,vn)=>{"use strict";var qe=M("zlib"),hn=Ue(),ii=fn(),{kStatusCode:mn}=Z(),ai=Buffer[Symbol.species],ci=Buffer.
|
|
19
|
+
from([0,0,255,255]),ut=Symbol("permessage-deflate"),ee=Symbol("total-length"),Ce=Symbol("callback"),ce=Symbol("buffers"),
|
|
20
|
+
Ee=Symbol("error"),dt,Jt=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this.
|
|
21
21
|
_options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=
|
|
22
|
-
null,this._inflate=null,this.params=null,!
|
|
23
|
-
10;
|
|
22
|
+
null,this._inflate=null,this.params=null,!dt){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
|
|
23
|
+
10;dt=new ii(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
|
|
24
24
|
(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.
|
|
25
25
|
serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=
|
|
26
26
|
this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=
|
|
27
27
|
this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this.
|
|
28
|
-
_inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[
|
|
28
|
+
_inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ce];this._deflate.close(),this._deflate=
|
|
29
29
|
null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,
|
|
30
30
|
n=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===
|
|
31
31
|
!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits==
|
|
@@ -44,53 +44,53 @@ y a single value`);if(o=o[0],n==="client_max_window_bits"){if(o!==!0){let s=+o;i
|
|
|
44
44
|
"${n}": ${o}`)}else if(n==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`I\
|
|
45
45
|
nvalid value for parameter "${n}": ${o}`);o=s}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){
|
|
46
46
|
if(o!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else throw new Error(`Unknown parameter "${n}"`);
|
|
47
|
-
r[n]=o})}),e}decompress(e,r,n){
|
|
47
|
+
r[n]=o})}),e}decompress(e,r,n){dt.add(o=>{this._decompress(e,r,(s,i)=>{o(),n(s,i)})})}compress(e,r,n){dt.add(o=>{this._compress(
|
|
48
48
|
e,r,(s,i)=>{o(),n(s,i)})})}_decompress(e,r,n){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_\
|
|
49
|
-
window_bits`,i=typeof this.params[s]!="number"?
|
|
50
|
-
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[
|
|
51
|
-
_inflate.on("error",
|
|
52
|
-
this._inflate.flush(()=>{let s=this._inflate[
|
|
53
|
-
this._inflate[ce],this._inflate[
|
|
54
|
-
(this._inflate[
|
|
49
|
+
window_bits`,i=typeof this.params[s]!="number"?qe.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=qe.createInflateRaw(
|
|
50
|
+
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[ut]=this,this._inflate[ee]=0,this._inflate[ce]=[],this.
|
|
51
|
+
_inflate.on("error",ui),this._inflate.on("data",gn)}this._inflate[Ce]=n,this._inflate.write(e),r&&this._inflate.write(ci),
|
|
52
|
+
this._inflate.flush(()=>{let s=this._inflate[Ee];if(s){this._inflate.close(),this._inflate=null,n(s);return}let i=hn.concat(
|
|
53
|
+
this._inflate[ce],this._inflate[ee]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
|
|
54
|
+
(this._inflate[ee]=0,this._inflate[ce]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){
|
|
55
55
|
let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
|
|
56
|
-
|
|
57
|
-
this._deflate[
|
|
58
|
-
flush(
|
|
59
|
-
buffer,s.byteOffset,s.length-4)),this._deflate[
|
|
60
|
-
_context_takeover`]&&this._deflate.reset(),n(null,s)})}};
|
|
61
|
-
function
|
|
62
|
-
new RangeError("Max payload size exceeded"),this[
|
|
63
|
-
"data",
|
|
64
|
-
t)}});var
|
|
56
|
+
qe.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=qe.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
|
|
57
|
+
this._deflate[ee]=0,this._deflate[ce]=[],this._deflate.on("data",di)}this._deflate[Ce]=n,this._deflate.write(e),this._deflate.
|
|
58
|
+
flush(qe.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=hn.concat(this._deflate[ce],this._deflate[ee]);r&&(s=new ai(s.
|
|
59
|
+
buffer,s.byteOffset,s.length-4)),this._deflate[Ce]=null,this._deflate[ee]=0,this._deflate[ce]=[],r&&this.params[`${o}_no\
|
|
60
|
+
_context_takeover`]&&this._deflate.reset(),n(null,s)})}};vn.exports=Jt;function di(t){this[ce].push(t),this[ee]+=t.length}
|
|
61
|
+
function gn(t){if(this[ee]+=t.length,this[ut]._maxPayload<1||this[ee]<=this[ut]._maxPayload){this[ce].push(t);return}this[Ee]=
|
|
62
|
+
new RangeError("Max payload size exceeded"),this[Ee].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ee][mn]=1009,this.removeListener(
|
|
63
|
+
"data",gn),this.reset()}function ui(t){if(this[ut]._inflate=null,this[Ee]){this[Ce](this[Ee]);return}t[mn]=1007,this[Ce](
|
|
64
|
+
t)}});var Re=W((xl,lt)=>{"use strict";var{isUtf8:wn}=M("buffer"),{hasBlob:li}=Z(),pi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
65
65
|
0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
66
|
-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function
|
|
67
|
-
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function
|
|
66
|
+
1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function fi(t){return t>=
|
|
67
|
+
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Xt(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===
|
|
68
68
|
0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){
|
|
69
69
|
if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;
|
|
70
70
|
r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&
|
|
71
|
-
240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function
|
|
71
|
+
240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function hi(t){return li&&typeof t=="o\
|
|
72
72
|
bject"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]===
|
|
73
|
-
"Blob"||t[Symbol.toStringTag]==="File")}
|
|
74
|
-
exports.isValidUTF8=function(t){return t.length<24?
|
|
75
|
-
|
|
76
|
-
{concat:
|
|
77
|
-
|
|
78
|
-
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||
|
|
73
|
+
"Blob"||t[Symbol.toStringTag]==="File")}lt.exports={isBlob:hi,isValidStatusCode:fi,isValidUTF8:Xt,tokenChars:pi};if(wn)lt.
|
|
74
|
+
exports.isValidUTF8=function(t){return t.length<24?Xt(t):wn(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=M("utf-8-validate");
|
|
75
|
+
lt.exports.isValidUTF8=function(e){return e.length<32?Xt(e):t(e)}}catch{}});var tr=W((Tl,_n)=>{"use strict";var{Writable:mi}=M("stream"),yn=Oe(),{BINARY_TYPES:gi,EMPTY_BUFFER:In,kStatusCode:vi,kWebSocket:wi}=Z(),
|
|
76
|
+
{concat:Yt,toArrayBuffer:yi,unmask:Ii}=Ue(),{isValidStatusCode:Si,isValidUTF8:Sn}=Re(),pt=Buffer[Symbol.species],J=0,xn=1,
|
|
77
|
+
Tn=2,bn=3,Qt=4,Zt=5,ft=6,er=class extends mi{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
|
|
78
|
+
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||gi[0],this._extensions=e.extensions||{},this._isServer=
|
|
79
79
|
!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|
|
|
80
|
-
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[
|
|
80
|
+
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[wi]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
|
|
81
81
|
!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=
|
|
82
|
-
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=
|
|
83
|
-
if(this._opcode===8&&this._state==
|
|
82
|
+
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=J}_write(e,r,n){
|
|
83
|
+
if(this._opcode===8&&this._state==J)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
|
|
84
84
|
n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=
|
|
85
85
|
e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this.
|
|
86
|
-
_buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new
|
|
87
|
-
e,n.length-e),new
|
|
88
|
-
r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new
|
|
89
|
-
e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case
|
|
90
|
-
break;case
|
|
91
|
-
this.getData(e);break;case
|
|
86
|
+
_buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new pt(n.buffer,n.byteOffset+
|
|
87
|
+
e,n.length-e),new pt(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],o=r.length-e;e>=n.length?
|
|
88
|
+
r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new pt(n.buffer,n.byteOffset+
|
|
89
|
+
e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case J:this.getInfo(e);
|
|
90
|
+
break;case xn:this.getPayloadLength16(e);break;case Tn:this.getPayloadLength64(e);break;case bn:this.getMask();break;case Qt:
|
|
91
|
+
this.getData(e);break;case Zt:case ft:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
|
|
92
92
|
2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be\
|
|
93
|
-
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[
|
|
93
|
+
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[yn.extensionName]){
|
|
94
94
|
let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&
|
|
95
95
|
128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let o=this.createError(RangeError,"\
|
|
96
96
|
RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,
|
|
@@ -104,609 +104,623 @@ LOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcod
|
|
|
104
104
|
ID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,
|
|
105
105
|
this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(
|
|
106
106
|
o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");
|
|
107
|
-
e(o);return}this._payloadLength===126?this._state=
|
|
107
|
+
e(o);return}this._payloadLength===126?this._state=xn:this._payloadLength===127?this._state=Tn:this.haveLength(e)}getPayloadLength16(e){
|
|
108
108
|
if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){
|
|
109
109
|
if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let o=this.
|
|
110
110
|
createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD\
|
|
111
111
|
_LENGTH");e(o);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&
|
|
112
112
|
this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>
|
|
113
113
|
0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}
|
|
114
|
-
this._masked?this._state=
|
|
115
|
-
4),this._state=
|
|
114
|
+
this._masked?this._state=bn:this._state=Qt}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
|
|
115
|
+
4),this._state=Qt}getData(e){let r=In;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
|
|
116
116
|
return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
|
|
117
|
-
|
|
117
|
+
Ii(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
|
|
118
118
|
let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}if(this.
|
|
119
|
-
_compressed){this._state=
|
|
120
|
-
push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[
|
|
119
|
+
_compressed){this._state=Zt,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
|
|
120
|
+
push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[yn.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return r(
|
|
121
121
|
o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(
|
|
122
122
|
RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(i);return}this._fragments.push(s)}
|
|
123
|
-
this.dataMessage(r),this._state===
|
|
123
|
+
this.dataMessage(r),this._state===J&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=J;return}let r=this._messageLength,
|
|
124
124
|
n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=
|
|
125
|
-
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=
|
|
126
|
-
_binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=
|
|
127
|
-
|
|
128
|
-
!
|
|
129
|
-
this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=
|
|
130
|
-
age",o,!1),this._state=
|
|
131
|
-
emit("conclude",1005,
|
|
132
|
-
tatus code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let o=new
|
|
133
|
-
_skipUTF8Validation&&!
|
|
134
|
-
this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=
|
|
135
|
-
9?"ping":"pong",e),this._state=
|
|
136
|
-
|
|
137
|
-
r);return Error.captureStackTrace(i,this.createError),i.code=s,i[
|
|
138
|
-
|
|
139
|
-
"kByteLength"),
|
|
125
|
+
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Yt(n,r):this._binaryType==="arraybuffer"?o=yi(Yt(n,r)):this.
|
|
126
|
+
_binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=J):(this._state=
|
|
127
|
+
ft,setImmediate(()=>{this.emit("message",o,!0),this._state=J,this.startLoop(e)}))}else{let o=Yt(n,r);if(!this._skipUTF8Validation&&
|
|
128
|
+
!Sn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===Zt||
|
|
129
|
+
this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=J):(this._state=ft,setImmediate(()=>{this.emit("mess\
|
|
130
|
+
age",o,!1),this._state=J,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
|
|
131
|
+
emit("conclude",1005,In),this.end();else{let n=e.readUInt16BE(0);if(!Si(n)){let s=this.createError(RangeError,`invalid s\
|
|
132
|
+
tatus code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let o=new pt(e.buffer,e.byteOffset+2,e.length-2);if(!this.
|
|
133
|
+
_skipUTF8Validation&&!Sn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(s);return}
|
|
134
|
+
this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=J;return}this._allowSynchronousEvents?(this.emit(this._opcode===
|
|
135
|
+
9?"ping":"pong",e),this._state=J):(this._state=ft,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
|
|
136
|
+
J,this.startLoop(r)}))}createError(e,r,n,o,s){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:
|
|
137
|
+
r);return Error.captureStackTrace(i,this.createError),i.code=s,i[vi]=o,i}};_n.exports=er});var or=W((_l,En)=>{"use strict";var{Duplex:bl}=M("stream"),{randomFillSync:xi}=M("crypto"),{types:{isUint8Array:Ti}}=M("util"),
|
|
138
|
+
An=Oe(),{EMPTY_BUFFER:bi,kWebSocket:_i,NOOP:Ai}=Z(),{isBlob:Pe,isValidStatusCode:Ci}=Re(),{mask:Cn,toBuffer:me}=Ue(),X=Symbol(
|
|
139
|
+
"kByteLength"),Ei=Buffer.alloc(4),ht=8*1024,ge,ke=ht,Y=0,Oi=1,Ri=2,rr=class t{constructor(e,r,n){this._extensions=r||{},
|
|
140
140
|
n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this.
|
|
141
|
-
_bufferedBytes=0,this._queue=[],this._state=
|
|
142
|
-
(n=r.maskBuffer||
|
|
143
|
-
|
|
144
|
-
i)&&r[
|
|
141
|
+
_bufferedBytes=0,this._queue=[],this._state=Y,this.onerror=Ai,this[_i]=void 0}static frame(e,r){let n,o=!1,s=2,i=!1;r.mask&&
|
|
142
|
+
(n=r.maskBuffer||Ei,r.generateMask?r.generateMask(n):(ke===ht&&(ge===void 0&&(ge=Buffer.alloc(ht)),xi(ge,0,ht),ke=0),n[0]=
|
|
143
|
+
ge[ke++],n[1]=ge[ke++],n[2]=ge[ke++],n[3]=ge[ke++]),i=(n[0]|n[1]|n[2]|n[3])===0,s=6);let a;typeof e=="string"?(!r.mask||
|
|
144
|
+
i)&&r[X]!==void 0?a=r[X]:(e=Buffer.from(e),a=e.length):(a=e.length,o=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
|
|
145
145
|
a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(d[0]|=64),d[1]=c,
|
|
146
146
|
c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),r.mask?(d[1]|=128,d[s-4]=n[0],d[s-3]=n[1],d[s-2]=
|
|
147
|
-
n[2],d[s-1]=n[3],i?[d,e]:o?(
|
|
148
|
-
if(typeof e!="number"||!
|
|
147
|
+
n[2],d[s-1]=n[3],i?[d,e]:o?(Cn(e,n,d,s,a),[d]):(Cn(e,n,e,0,a),[d,e])):[d,e]}close(e,r,n,o){let s;if(e===void 0)s=bi;else{
|
|
148
|
+
if(typeof e!="number"||!Ci(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.
|
|
149
149
|
length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The m\
|
|
150
150
|
essage must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof r=="string")s.write(
|
|
151
|
-
r,2);else if(
|
|
151
|
+
r,2);else if(Ti(r))s.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[X]:s.
|
|
152
152
|
length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==
|
|
153
|
-
|
|
154
|
-
byteLength(e),s=!1):
|
|
155
|
-
ust not be greater than 125 bytes");let i={[
|
|
156
|
-
opcode:9,readOnly:s,rsv1:!1};
|
|
157
|
-
this._state!==
|
|
158
|
-
string"?(o=Buffer.byteLength(e),s=!1):
|
|
159
|
-
"The data size must not be greater than 125 bytes");let i={[
|
|
160
|
-
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};
|
|
161
|
-
e,!1,i,n):this._state!==
|
|
162
|
-
extensionName],s=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):
|
|
163
|
-
|
|
153
|
+
Y?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,r,n){let o,s;if(typeof e=="string"?(o=Buffer.
|
|
154
|
+
byteLength(e),s=!1):Pe(e)?(o=e.size,s=!1):(e=me(e),o=e.length,s=me.readOnly),o>125)throw new RangeError("The data size m\
|
|
155
|
+
ust not be greater than 125 bytes");let i={[X]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,
|
|
156
|
+
opcode:9,readOnly:s,rsv1:!1};Pe(e)?this._state!==Y?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):
|
|
157
|
+
this._state!==Y?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}pong(e,r,n){let o,s;if(typeof e=="\
|
|
158
|
+
string"?(o=Buffer.byteLength(e),s=!1):Pe(e)?(o=e.size,s=!1):(e=me(e),o=e.length,s=me.readOnly),o>125)throw new RangeError(
|
|
159
|
+
"The data size must not be greater than 125 bytes");let i={[X]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this.
|
|
160
|
+
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};Pe(e)?this._state!==Y?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(
|
|
161
|
+
e,!1,i,n):this._state!==Y?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}send(e,r,n){let o=this._extensions[An.
|
|
162
|
+
extensionName],s=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Pe(e)?(a=e.size,c=!1):(e=
|
|
163
|
+
me(e),a=e.length,c=me.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_contex\
|
|
164
164
|
t_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),r.fin&&(this._firstFragment=
|
|
165
|
-
!0);let d={[
|
|
166
|
-
|
|
167
|
-
_state!==
|
|
168
|
-
_bufferedBytes+=n[
|
|
169
|
-
closed while the blob was being read");process.nextTick(
|
|
170
|
-
dispatch(i,r,n,o):(this._state=
|
|
171
|
-
if(!r){this.sendFrame(t.frame(e,n),o);return}let s=this._extensions[
|
|
172
|
-
|
|
173
|
-
pressed");
|
|
174
|
-
dequeue()})}dequeue(){for(;this._state===
|
|
175
|
-
Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][
|
|
165
|
+
!0);let d={[X]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
|
|
166
|
+
Pe(e)?this._state!==Y?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this.
|
|
167
|
+
_state!==Y?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,r,n,o){this.
|
|
168
|
+
_bufferedBytes+=n[X],this._state=Ri,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was \
|
|
169
|
+
closed while the blob was being read");process.nextTick(nr,this,a,o);return}this._bufferedBytes-=n[X];let i=me(s);r?this.
|
|
170
|
+
dispatch(i,r,n,o):(this._state=Y,this.sendFrame(t.frame(i,n),o),this.dequeue())}).catch(s=>{process.nextTick(Pi,this,s,o)})}dispatch(e,r,n,o){
|
|
171
|
+
if(!r){this.sendFrame(t.frame(e,n),o);return}let s=this._extensions[An.extensionName];this._bufferedBytes+=n[X],this._state=
|
|
172
|
+
Oi,s.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
|
|
173
|
+
pressed");nr(this,c,o);return}this._bufferedBytes-=n[X],this._state=Y,n.readOnly=!1,this.sendFrame(t.frame(a,n),o),this.
|
|
174
|
+
dequeue()})}dequeue(){for(;this._state===Y&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][X],
|
|
175
|
+
Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][X],this._queue.push(e)}sendFrame(e,r){e.length===
|
|
176
176
|
2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],
|
|
177
|
-
r)}};
|
|
178
|
-
length-1];typeof s=="function"&&s(e)}}function
|
|
179
|
-
"kError"),
|
|
180
|
-
this[
|
|
181
|
-
arget",{enumerable:!0});Object.defineProperty(
|
|
182
|
-
super(e),this[
|
|
183
|
-
return this[
|
|
184
|
-
{enumerable:!0});Object.defineProperty(
|
|
185
|
-
an",{enumerable:!0});var
|
|
186
|
-
r.message===void 0?"":r.message}get error(){return this[
|
|
187
|
-
"error",{enumerable:!0});Object.defineProperty(
|
|
188
|
-
super(e),this[
|
|
189
|
-
var
|
|
190
|
-
age")n=function(s,i){let a=new
|
|
191
|
-
let a=new
|
|
192
|
-
e,this,a)};else if(t==="error")n=function(s){let i=new
|
|
193
|
-
"open")n=function(){let s=new
|
|
194
|
-
this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[
|
|
195
|
-
|
|
196
|
-
t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var
|
|
197
|
-
let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,
|
|
198
|
-
|
|
199
|
-
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${
|
|
200
|
-
|
|
201
|
-
if(u===-1&&
|
|
202
|
-
`Unexpected character at index ${
|
|
203
|
-
c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,
|
|
204
|
-
if(
|
|
205
|
-
1)c===-1&&(c=
|
|
206
|
-
index ${
|
|
207
|
-
d===9))u===-1&&(u=
|
|
208
|
-
(u=
|
|
209
|
-
|
|
210
|
-
"Unexpected end of input");u===-1&&(u=
|
|
211
|
-
|
|
212
|
-
r
|
|
213
|
-
|
|
214
|
-
{Duplex:
|
|
215
|
-
EMPTY_BUFFER:
|
|
216
|
-
removeEventListener:
|
|
217
|
-
NG","OPEN","CLOSING","CLOSED"],
|
|
218
|
-
_binaryType=
|
|
177
|
+
r)}};En.exports=rr;function nr(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let o=t._queue[n],s=o[o.
|
|
178
|
+
length-1];typeof s=="function"&&s(e)}}function Pi(t,e,r){nr(t,e,r),t.onerror(e)}});var zn=W((Al,Dn)=>{"use strict";var{kForOnEventAttribute:Be,kListener:sr}=Z(),On=Symbol("kCode"),Rn=Symbol("kData"),Pn=Symbol(
|
|
179
|
+
"kError"),kn=Symbol("kMessage"),Mn=Symbol("kReason"),Me=Symbol("kTarget"),Nn=Symbol("kType"),jn=Symbol("kWasClean"),te=class{constructor(e){
|
|
180
|
+
this[Me]=null,this[Nn]=e}get target(){return this[Me]}get type(){return this[Nn]}};Object.defineProperty(te.prototype,"t\
|
|
181
|
+
arget",{enumerable:!0});Object.defineProperty(te.prototype,"type",{enumerable:!0});var ve=class extends te{constructor(e,r={}){
|
|
182
|
+
super(e),this[On]=r.code===void 0?0:r.code,this[Mn]=r.reason===void 0?"":r.reason,this[jn]=r.wasClean===void 0?!1:r.wasClean}get code(){
|
|
183
|
+
return this[On]}get reason(){return this[Mn]}get wasClean(){return this[jn]}};Object.defineProperty(ve.prototype,"code",
|
|
184
|
+
{enumerable:!0});Object.defineProperty(ve.prototype,"reason",{enumerable:!0});Object.defineProperty(ve.prototype,"wasCle\
|
|
185
|
+
an",{enumerable:!0});var Ne=class extends te{constructor(e,r={}){super(e),this[Pn]=r.error===void 0?null:r.error,this[kn]=
|
|
186
|
+
r.message===void 0?"":r.message}get error(){return this[Pn]}get message(){return this[kn]}};Object.defineProperty(Ne.prototype,
|
|
187
|
+
"error",{enumerable:!0});Object.defineProperty(Ne.prototype,"message",{enumerable:!0});var He=class extends te{constructor(e,r={}){
|
|
188
|
+
super(e),this[Rn]=r.data===void 0?null:r.data}get data(){return this[Rn]}};Object.defineProperty(He.prototype,"data",{enumerable:!0});
|
|
189
|
+
var ki={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Be]&&o[sr]===e&&!o[Be])return;let n;if(t==="mess\
|
|
190
|
+
age")n=function(s,i){let a=new He("message",{data:i?s:s.toString()});a[Me]=this,mt(e,this,a)};else if(t==="close")n=function(s,i){
|
|
191
|
+
let a=new ve("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Me]=this,mt(
|
|
192
|
+
e,this,a)};else if(t==="error")n=function(s){let i=new Ne("error",{error:s,message:s.message});i[Me]=this,mt(e,this,i)};else if(t===
|
|
193
|
+
"open")n=function(){let s=new te("open");s[Me]=this,mt(e,this,s)};else return;n[Be]=!!r[Be],n[sr]=e,r.once?this.once(t,n):
|
|
194
|
+
this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[sr]===e&&!r[Be]){this.removeListener(t,r);break}}};
|
|
195
|
+
Dn.exports={CloseEvent:ve,ErrorEvent:Ne,Event:te,EventTarget:ki,MessageEvent:He};function mt(t,e,r){typeof t=="object"&&
|
|
196
|
+
t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var gt=W((Cl,Ln)=>{"use strict";var{tokenChars:Ve}=Re();function Q(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Mi(t){
|
|
197
|
+
let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,f=0;for(;f<t.length;f++)if(d=t.charCodeAt(
|
|
198
|
+
f),i===void 0)if(u===-1&&Ve[d]===1)c===-1&&(c=f);else if(f!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=f);else if(d===59||d===
|
|
199
|
+
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let g=t.slice(c,u);d===44?(Q(e,g,
|
|
200
|
+
r),r=Object.create(null)):i=g,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)
|
|
201
|
+
if(u===-1&&Ve[d]===1)c===-1&&(c=f);else if(d===32||d===9)u===-1&&c!==-1&&(u=f);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
|
|
202
|
+
`Unexpected character at index ${f}`);u===-1&&(u=f),Q(r,t.slice(c,u),!0),d===44&&(Q(e,i,r),r=Object.create(null),i=void 0),
|
|
203
|
+
c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,f),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(o){
|
|
204
|
+
if(Ve[d]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);c===-1?c=f:n||(n=!0),o=!1}else if(s)if(Ve[d]===
|
|
205
|
+
1)c===-1&&(c=f);else if(d===34&&c!==-1)s=!1,u=f;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
|
|
206
|
+
index ${f}`);else if(d===34&&t.charCodeAt(f-1)===61)s=!0;else if(u===-1&&Ve[d]===1)c===-1&&(c=f);else if(c!==-1&&(d===32||
|
|
207
|
+
d===9))u===-1&&(u=f);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&
|
|
208
|
+
(u=f);let g=t.slice(c,u);n&&(g=g.replace(/\\/g,""),n=!1),Q(r,a,g),d===44&&(Q(e,i,r),r=Object.create(null),i=void 0),a=void 0,
|
|
209
|
+
c=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
|
|
210
|
+
"Unexpected end of input");u===-1&&(u=f);let l=t.slice(c,u);return i===void 0?Q(e,l,r):(a===void 0?Q(r,l,!0):n?Q(r,a,l.replace(
|
|
211
|
+
/\\/g,"")):Q(r,a,l),Q(e,i,r)),e}function Ni(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),
|
|
212
|
+
r.map(n=>[e].concat(Object.keys(n).map(o=>{let s=n[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join(
|
|
213
|
+
"; ")})).join("; ")).join(", ")}).join(", ")}Ln.exports={format:Ni,parse:Mi}});var It=W((Rl,Xn)=>{"use strict";var ji=M("events"),Di=M("https"),zi=M("http"),Un=M("net"),Li=M("tls"),{randomBytes:Fi,createHash:$i}=M("crypto"),
|
|
214
|
+
{Duplex:El,Readable:Ol}=M("stream"),{URL:ir}=M("url"),de=Oe(),Ui=tr(),qi=or(),{isBlob:Bi}=Re(),{BINARY_TYPES:Fn,CLOSE_TIMEOUT:Hi,
|
|
215
|
+
EMPTY_BUFFER:vt,GUID:Vi,kForOnEventAttribute:ar,kListener:Gi,kStatusCode:Wi,kWebSocket:L,NOOP:qn}=Z(),{EventTarget:{addEventListener:Ki,
|
|
216
|
+
removeEventListener:Ji}}=zn(),{format:Xi,parse:Yi}=gt(),{toBuffer:Qi}=Ue(),Bn=Symbol("kAborted"),cr=[8,13],re=["CONNECTI\
|
|
217
|
+
NG","OPEN","CLOSING","CLOSED"],Zi=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends ji{constructor(e,r,n){super(),this.
|
|
218
|
+
_binaryType=Fn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=vt,this._closeTimer=
|
|
219
219
|
null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=
|
|
220
220
|
null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?
|
|
221
|
-
r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),
|
|
222
|
-
n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){
|
|
221
|
+
r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),Hn(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=
|
|
222
|
+
n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Fn.includes(e)&&(this._binaryType=
|
|
223
223
|
e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+
|
|
224
224
|
this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){
|
|
225
225
|
return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){
|
|
226
|
-
return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let o=new
|
|
226
|
+
return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let o=new Ui(
|
|
227
227
|
{allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,
|
|
228
228
|
maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),
|
|
229
|
-
s=new
|
|
230
|
-
o.on("conclude",
|
|
231
|
-
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",
|
|
232
|
-
"end",
|
|
229
|
+
s=new qi(e,this._extensions,n.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[L]=this,s[L]=this,e[L]=this,
|
|
230
|
+
o.on("conclude",ra),o.on("drain",na),o.on("error",oa),o.on("message",sa),o.on("ping",ia),o.on("pong",aa),s.onerror=ca,e.
|
|
231
|
+
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Wn),e.on("data",yt),e.on(
|
|
232
|
+
"end",Kn),e.on("error",Jn),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
|
|
233
233
|
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[de.extensionName]&&this._extensions[de.extensionName].
|
|
234
234
|
cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){
|
|
235
|
-
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
235
|
+
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){K(this,this._req,"WebSocket was closed before the conn\
|
|
236
236
|
ection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver.
|
|
237
237
|
_writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,
|
|
238
238
|
n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),
|
|
239
|
-
|
|
239
|
+
Gn(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){
|
|
240
240
|
if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="func\
|
|
241
241
|
tion"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
242
|
-
|
|
242
|
+
dr(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||vt,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)
|
|
243
243
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="\
|
|
244
|
-
function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
245
|
-
(r=!this._isServer),this._sender.pong(e||
|
|
244
|
+
function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){dr(this,e,n);return}r===void 0&&
|
|
245
|
+
(r=!this._isServer),this._sender.pong(e||vt,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
|
|
246
246
|
_paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)
|
|
247
247
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="numbe\
|
|
248
|
-
r"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
249
|
-
compress:!0,fin:!0,...r};this._extensions[de.extensionName]||(o.compress=!1),this._sender.send(e||
|
|
250
|
-
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
248
|
+
r"&&(e=e.toString()),this.readyState!==t.OPEN){dr(this,e,n);return}let o={binary:typeof e!="string",mask:!this._isServer,
|
|
249
|
+
compress:!0,fin:!0,...r};this._extensions[de.extensionName]||(o.compress=!1),this._sender.send(e||vt,o,n)}terminate(){if(this.
|
|
250
|
+
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){K(this,this._req,"WebSocket was closed before the connection w\
|
|
251
251
|
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(k,"CO\
|
|
252
|
-
NNECTING",{enumerable:!0,value:
|
|
253
|
-
value:
|
|
254
|
-
k.prototype,"OPEN",{enumerable:!0,value:
|
|
255
|
-
"CLOSING")});Object.defineProperty(k.prototype,"CLOSING",{enumerable:!0,value:
|
|
256
|
-
k,"CLOSED",{enumerable:!0,value:
|
|
252
|
+
NNECTING",{enumerable:!0,value:re.indexOf("CONNECTING")});Object.defineProperty(k.prototype,"CONNECTING",{enumerable:!0,
|
|
253
|
+
value:re.indexOf("CONNECTING")});Object.defineProperty(k,"OPEN",{enumerable:!0,value:re.indexOf("OPEN")});Object.defineProperty(
|
|
254
|
+
k.prototype,"OPEN",{enumerable:!0,value:re.indexOf("OPEN")});Object.defineProperty(k,"CLOSING",{enumerable:!0,value:re.indexOf(
|
|
255
|
+
"CLOSING")});Object.defineProperty(k.prototype,"CLOSING",{enumerable:!0,value:re.indexOf("CLOSING")});Object.defineProperty(
|
|
256
|
+
k,"CLOSED",{enumerable:!0,value:re.indexOf("CLOSED")});Object.defineProperty(k.prototype,"CLOSED",{enumerable:!0,value:re.
|
|
257
257
|
indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
|
|
258
258
|
defineProperty(k.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(k.prototype,
|
|
259
|
-
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[
|
|
260
|
-
listeners(t))if(r[
|
|
261
|
-
prototype.addEventListener=
|
|
262
|
-
autoPong:!0,closeTimeout:
|
|
259
|
+
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[ar])return e[Gi];return null},set(e){for(let r of this.
|
|
260
|
+
listeners(t))if(r[ar]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[ar]:!0})}})});k.
|
|
261
|
+
prototype.addEventListener=Ki;k.prototype.removeEventListener=Ji;Xn.exports=k;function Hn(t,e,r,n){let o={allowSynchronousEvents:!0,
|
|
262
|
+
autoPong:!0,closeTimeout:Hi,protocolVersion:cr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
|
|
263
263
|
perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,
|
|
264
|
-
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!
|
|
265
|
-
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${
|
|
266
|
-
", ")})`);let s;if(e instanceof
|
|
264
|
+
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!cr.includes(
|
|
265
|
+
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${cr.join(
|
|
266
|
+
", ")})`);let s;if(e instanceof ir)s=e;else try{s=new ir(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol===
|
|
267
267
|
"http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),t._url=s.href;let i=s.protocol==="wss:",a=s.protocol===
|
|
268
268
|
"ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws\
|
|
269
|
-
+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let
|
|
270
|
-
c);if(t._redirects===0)throw
|
|
271
|
-
|
|
269
|
+
+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let x=new SyntaxError(
|
|
270
|
+
c);if(t._redirects===0)throw x;wt(t,x);return}let d=i?443:80,u=Fi(16).toString("base64"),f=i?Di.request:zi.request,l=new Set,
|
|
271
|
+
g;if(o.createConnection=o.createConnection||(i?ta:ea),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
|
|
272
272
|
startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec\
|
|
273
273
|
-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
|
|
274
|
-
(
|
|
275
|
-
offer()})),r.length){for(let
|
|
276
|
-
uplicated subprotocol was specified");
|
|
274
|
+
(g=new de({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Xi({[de.extensionName]:g.
|
|
275
|
+
offer()})),r.length){for(let x of r){if(typeof x!="string"||!Zi.test(x)||l.has(x))throw new SyntaxError("An invalid or d\
|
|
276
|
+
uplicated subprotocol was specified");l.add(x)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<
|
|
277
277
|
13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}\
|
|
278
|
-
:${s.password}`),a){let
|
|
279
|
-
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let
|
|
280
|
-
headers:{}},
|
|
281
|
-
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!
|
|
282
|
-
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,
|
|
283
|
-
o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),
|
|
284
|
-
t._redirects&&t.emit("redirect",t.url,
|
|
285
|
-
timed out")}),
|
|
286
|
-
statusCode;if(
|
|
287
|
-
return}
|
|
288
|
-
t.emit("unexpected-response",
|
|
289
|
-
emit("upgrade",
|
|
290
|
-
"websocket"){
|
|
291
|
-
socket-accept"]!==
|
|
292
|
-
void 0?
|
|
293
|
-
size&&(
|
|
294
|
-
if(
|
|
295
|
-
try{
|
|
296
|
-
extensionName){
|
|
297
|
-
|
|
278
|
+
:${s.password}`),a){let x=o.path.split(":");o.socketPath=x[0],o.path=x[1]}let S;if(o.followRedirects){if(t._redirects===
|
|
279
|
+
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let x=n&&n.headers;if(n={...n,
|
|
280
|
+
headers:{}},x)for(let[O,P]of Object.entries(x))n.headers[O.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let x=a?
|
|
281
|
+
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!x||
|
|
282
|
+
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,x||delete o.headers.host,o.auth=void 0)}
|
|
283
|
+
o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),S=t._req=f(o),
|
|
284
|
+
t._redirects&&t.emit("redirect",t.url,S)}else S=t._req=f(o);o.timeout&&S.on("timeout",()=>{K(t,S,"Opening handshake has \
|
|
285
|
+
timed out")}),S.on("error",x=>{S===null||S[Bn]||(S=t._req=null,wt(t,x))}),S.on("response",x=>{let O=x.headers.location,P=x.
|
|
286
|
+
statusCode;if(O&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){K(t,S,"Maximum redirects exceeded");
|
|
287
|
+
return}S.abort();let D;try{D=new ir(O,e)}catch{let F=new SyntaxError(`Invalid URL: ${O}`);wt(t,F);return}Hn(t,D,r,n)}else
|
|
288
|
+
t.emit("unexpected-response",S,x)||K(t,S,`Unexpected server response: ${x.statusCode}`)}),S.on("upgrade",(x,O,P)=>{if(t.
|
|
289
|
+
emit("upgrade",x),t.readyState!==k.CONNECTING)return;S=t._req=null;let D=x.headers.upgrade;if(D===void 0||D.toLowerCase()!==
|
|
290
|
+
"websocket"){K(t,O,"Invalid Upgrade header");return}let N=$i("sha1").update(u+Vi).digest("base64");if(x.headers["sec-web\
|
|
291
|
+
socket-accept"]!==N){K(t,O,"Invalid Sec-WebSocket-Accept header");return}let F=x.headers["sec-websocket-protocol"],q;if(F!==
|
|
292
|
+
void 0?l.size?l.has(F)||(q="Server sent an invalid subprotocol"):q="Server sent a subprotocol but none was requested":l.
|
|
293
|
+
size&&(q="Server sent no subprotocol"),q){K(t,O,q);return}F&&(t._protocol=F);let V=x.headers["sec-websocket-extensions"];
|
|
294
|
+
if(V!==void 0){if(!g){K(t,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let G;
|
|
295
|
+
try{G=Yi(V)}catch{K(t,O,"Invalid Sec-WebSocket-Extensions header");return}let oe=Object.keys(G);if(oe.length!==1||oe[0]!==
|
|
296
|
+
de.extensionName){K(t,O,"Server indicated an extension that was not requested");return}try{g.accept(G[de.extensionName])}catch{
|
|
297
|
+
K(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[de.extensionName]=g}t.setSocket(O,P,{allowSynchronousEvents:o.
|
|
298
298
|
allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
|
|
299
|
-
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(
|
|
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 n=new Error(r);Error.captureStackTrace(n,
|
|
303
|
-
destroyed&&e.socket.destroy(),process.nextTick(
|
|
304
|
-
se",t.emitClose.bind(t)))}function
|
|
305
|
-
t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${
|
|
306
|
-
nextTick(r,n)}}function
|
|
307
|
-
(r._socket.removeListener("data",
|
|
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[
|
|
299
|
+
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,t):S.end()}function wt(t,e){t._readyState=
|
|
300
|
+
k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function ea(t){return t.path=t.socketPath,Un.connect(t)}function ta(t){
|
|
301
|
+
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Un.isIP(t.host)?"":t.host),Li.connect(t)}function K(t,e,r){
|
|
302
|
+
t._readyState=k.CLOSING;let n=new Error(r);Error.captureStackTrace(n,K),e.setHeader?(e[Bn]=!0,e.abort(),e.socket&&!e.socket.
|
|
303
|
+
destroyed&&e.socket.destroy(),process.nextTick(wt,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("clo\
|
|
304
|
+
se",t.emitClose.bind(t)))}function dr(t,e,r){if(e){let n=Bi(e)?e.size:Qi(e).length;t._socket?t._sender._bufferedBytes+=n:
|
|
305
|
+
t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${re[t.readyState]})`);process.
|
|
306
|
+
nextTick(r,n)}}function ra(t,e){let r=this[L];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[L]!==void 0&&
|
|
307
|
+
(r._socket.removeListener("data",yt),process.nextTick(Vn,r._socket),t===1005?r.close():r.close(t,e))}function na(){let t=this[L];
|
|
308
|
+
t.isPaused||t._socket.resume()}function oa(t){let e=this[L];e._socket[L]!==void 0&&(e._socket.removeListener("data",yt),
|
|
309
|
+
process.nextTick(Vn,e._socket),e.close(t[Wi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function $n(){this[L].
|
|
310
|
+
emitClose()}function sa(t,e){this[L].emit("message",t,e)}function ia(t){let e=this[L];e._autoPong&&e.pong(t,!this._isServer,
|
|
311
|
+
qn),e.emit("ping",t)}function aa(t){this[L].emit("pong",t)}function Vn(t){t.resume()}function ca(t){let e=this[L];e.readyState!==
|
|
312
|
+
k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,Gn(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
|
|
313
|
+
e.emit("error",t)))}function Gn(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Wn(){
|
|
314
|
+
let t=this[L];if(this.removeListener("close",Wn),this.removeListener("data",yt),this.removeListener("end",Kn),t._readyState=
|
|
315
315
|
k.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.
|
|
316
|
-
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[
|
|
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
|
|
318
|
+
"error",$n),t._receiver.on("finish",$n))}function yt(t){this[L]._receiver.write(t)||this.pause()}function Kn(){let t=this[L];
|
|
319
|
+
t._readyState=k.CLOSING,t._receiver.end(),this.end()}function Jn(){let t=this[L];this.removeListener("error",Jn),this.on(
|
|
320
|
+
"error",qn),t&&(t._readyState=k.CLOSING,this.destroy())}});var eo=W((kl,Zn)=>{"use strict";var Pl=It(),{Duplex:da}=M("stream");function Yn(t){t.emit("close")}function ua(){!this.destroyed&&
|
|
321
|
+
this._writableState.finished&&this.destroy()}function Qn(t){this.removeListener("error",Qn),this.destroy(),this.listenerCount(
|
|
322
|
+
"error")===0&&this.emit("error",t)}function la(t,e){let r=!0,n=new da({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
|
|
323
323
|
return t.on("message",function(s,i){let a=!i&&n._readableState.objectMode?s.toString():s;n.push(a)||t.pause()}),t.once("\
|
|
324
324
|
error",function(s){n.destroyed||(r=!1,n.destroy(s))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(o,s){
|
|
325
|
-
if(t.readyState===t.CLOSED){s(o),process.nextTick(
|
|
326
|
-
lose",function(){i||s(o),process.nextTick(
|
|
325
|
+
if(t.readyState===t.CLOSED){s(o),process.nextTick(Yn,n);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
|
|
326
|
+
lose",function(){i||s(o),process.nextTick(Yn,n)}),r&&t.terminate()},n._final=function(o){if(t.readyState===t.CONNECTING){
|
|
327
327
|
t.once("open",function(){n._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),n._readableState.
|
|
328
328
|
endEmitted&&n.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},
|
|
329
329
|
n._write=function(o,s,i){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(o,s,i)});return}t.send(o,i)},
|
|
330
|
-
n.on("end",
|
|
331
|
-
let i=t.charCodeAt(o);if(n===-1&&
|
|
330
|
+
n.on("end",ua),n.on("error",Qn),n}Zn.exports=la});var ur=W((Ml,to)=>{"use strict";var{tokenChars:pa}=Re();function fa(t){let e=new Set,r=-1,n=-1,o=0;for(o;o<t.length;o++){
|
|
331
|
+
let i=t.charCodeAt(o);if(n===-1&&pa[i]===1)r===-1&&(r=o);else if(o!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=o);else if(i===
|
|
332
332
|
44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);n===-1&&(n=o);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(
|
|
333
333
|
`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
|
|
334
334
|
if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let s=t.slice(r,o);if(e.has(s))throw new SyntaxError(
|
|
335
|
-
`The "${s}" subprotocol is duplicated`);return e.add(s),e}
|
|
336
|
-
|
|
335
|
+
`The "${s}" subprotocol is duplicated`);return e.add(s),e}to.exports={parse:fa}});var co=W((jl,ao)=>{"use strict";var ha=M("events"),St=M("http"),{Duplex:Nl}=M("stream"),{createHash:ma}=M("crypto"),ro=gt(),
|
|
336
|
+
we=Oe(),ga=ur(),va=It(),{CLOSE_TIMEOUT:wa,GUID:ya,kWebSocket:Ia}=Z(),Sa=/^[+/0-9A-Za-z]{22}==$/,no=0,oo=1,io=2,lr=class extends ha{constructor(e,r){
|
|
337
337
|
if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*
|
|
338
|
-
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:
|
|
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:wa,verifyClient:null,
|
|
339
|
+
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:va,...e},e.port==null&&!e.server&&!e.noServer||
|
|
340
340
|
e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server"\
|
|
341
|
-
, or "noServer" options must be specified');if(e.port!=null?(this._server=
|
|
341
|
+
, or "noServer" options must be specified');if(e.port!=null?(this._server=St.createServer((n,o)=>{let s=St.STATUS_CODES[426];
|
|
342
342
|
o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(e.port,e.host,e.
|
|
343
343
|
backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=
|
|
344
|
-
|
|
344
|
+
xa(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
|
|
345
345
|
o,s,i,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=
|
|
346
|
-
!1),this.options=e,this._state=
|
|
347
|
-
er" mode');return this._server?this._server.address():null}close(e){if(this._state===
|
|
348
|
-
"The server is not running"))}),process.nextTick(
|
|
349
|
-
|
|
350
|
-
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(
|
|
351
|
-
_server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{
|
|
346
|
+
!1),this.options=e,this._state=no}address(){if(this.options.noServer)throw new Error('The server is operating in "noServ\
|
|
347
|
+
er" mode');return this._server?this._server.address():null}close(e){if(this._state===io){e&&this.once("close",()=>{e(new Error(
|
|
348
|
+
"The server is not running"))}),process.nextTick(Ge,this);return}if(e&&this.once("close",e),this._state!==oo)if(this._state=
|
|
349
|
+
oo,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=
|
|
350
|
+
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ge,this):process.nextTick(Ge,this);else{let r=this.
|
|
351
|
+
_server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ge(this)})}}shouldHandle(e){if(this.
|
|
352
352
|
options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,o){
|
|
353
|
-
r.on("error",
|
|
354
|
-
"GET"){
|
|
355
|
-
lid Upgrade header");return}if(s===void 0||!
|
|
356
|
-
if(a!==13&&a!==8){
|
|
357
|
-
if(!this.shouldHandle(e)){
|
|
358
|
-
c)}catch{
|
|
359
|
-
if(this.options.perMessageDeflate&&u!==void 0){let
|
|
360
|
-
options.maxPayload});try{let
|
|
361
|
-
|
|
353
|
+
r.on("error",so);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
|
|
354
|
+
"GET"){ye(this,e,r,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){ye(this,e,r,400,"Inva\
|
|
355
|
+
lid Upgrade header");return}if(s===void 0||!Sa.test(s)){ye(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}
|
|
356
|
+
if(a!==13&&a!==8){ye(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
|
|
357
|
+
if(!this.shouldHandle(e)){We(r,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=ga.parse(
|
|
358
|
+
c)}catch{ye(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],f={};
|
|
359
|
+
if(this.options.perMessageDeflate&&u!==void 0){let l=new we({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
|
|
360
|
+
options.maxPayload});try{let g=ro.parse(u);g[we.extensionName]&&(l.accept(g[we.extensionName]),f[we.extensionName]=l)}catch{
|
|
361
|
+
ye(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let l={
|
|
362
362
|
origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.
|
|
363
|
-
options.verifyClient.length===2){this.options.verifyClient(
|
|
364
|
-
|
|
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")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let
|
|
369
|
-
handleProtocols(n,o):n.values().next().value;
|
|
370
|
-
let
|
|
363
|
+
options.verifyClient.length===2){this.options.verifyClient(l,(g,S,x,O)=>{if(!g)return We(r,S||401,x,O);this.completeUpgrade(
|
|
364
|
+
f,s,d,e,r,n,o)});return}if(!this.options.verifyClient(l))return We(r,401)}this.completeUpgrade(f,s,d,e,r,n,o)}completeUpgrade(e,r,n,o,s,i,a){
|
|
365
|
+
if(!s.readable||!s.writable)return s.destroy();if(s[Ia])throw new Error("server.handleUpgrade() was called more than onc\
|
|
366
|
+
e with the same socket, possibly due to a misconfiguration");if(this._state>no)return We(s,503);let d=["HTTP/1.1 101 Swi\
|
|
367
|
+
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ma("sha1").update(r+ya).digest("ba\
|
|
368
|
+
se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let f=this.options.handleProtocols?this.options.
|
|
369
|
+
handleProtocols(n,o):n.values().next().value;f&&(d.push(`Sec-WebSocket-Protocol: ${f}`),u._protocol=f)}if(e[we.extensionName]){
|
|
370
|
+
let f=e[we.extensionName].params,l=ro.format({[we.extensionName]:[f]});d.push(`Sec-WebSocket-Extensions: ${l}`),u._extensions=
|
|
371
371
|
e}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
372
372
|
`).join(`\r
|
|
373
|
-
`)),s.removeListener("error",
|
|
373
|
+
`)),s.removeListener("error",so),u.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
|
|
374
374
|
options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.
|
|
375
375
|
options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&
|
|
376
|
-
!this.clients.size&&process.nextTick(
|
|
377
|
-
r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function
|
|
378
|
-
function
|
|
379
|
-
l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${
|
|
376
|
+
!this.clients.size&&process.nextTick(Ge,this)})),a(u,o)}};ao.exports=lr;function xa(t,e){for(let r of Object.keys(e))t.on(
|
|
377
|
+
r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function Ge(t){t._state=io,t.emit("close")}
|
|
378
|
+
function so(){this.destroy()}function We(t,e,r,n){r=r||St.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/htm\
|
|
379
|
+
l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${St.STATUS_CODES[e]}\r
|
|
380
380
|
`+Object.keys(n).map(o=>`${o}: ${n[o]}`).join(`\r
|
|
381
381
|
`)+`\r
|
|
382
382
|
\r
|
|
383
|
-
`+r)}function
|
|
384
|
-
"wsClientError",i,r,e)}else
|
|
383
|
+
`+r)}function ye(t,e,r,n,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,ye),t.emit(
|
|
384
|
+
"wsClientError",i,r,e)}else We(r,n,o,s)}});function A(t){return String(t??"").trim()}function $(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var ol=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
|
|
385
385
|
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var B=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
386
|
-
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),
|
|
387
|
-
B.COMPLETED,B.FAILED,B.INTERRUPTED,B.TIMED_OUT]),
|
|
388
|
-
rename as
|
|
386
|
+
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),cl=new Set(Object.values(B)),dl=new Set([B.CANCELLED,
|
|
387
|
+
B.COMPLETED,B.FAILED,B.INTERRUPTED,B.TIMED_OUT]),ri=new Set([B.ACTIVE,B.FINALIZING,B.STARTING]);var Ta=ae(eo(),1),ba=ae(gt(),1),_a=ae(Oe(),1),Aa=ae(tr(),1),Ca=ae(or(),1),Ea=ae(ur(),1),Oa=ae(It(),1),Ra=ae(co(),1);import{createHash as uo}from"node:crypto";import{execFile as ka}from"node:child_process";import{open as Ma,readFile as Bl,
|
|
388
|
+
rename as Hl,rm as Vl,writeFile as Gl}from"node:fs/promises";import fr from"node:path";import{promisify as Na}from"node:util";var Xl=Na(ka);var ja=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
389
389
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
390
390
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
391
391
|
ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
|
|
392
|
-
"unified_exec_zsh_fork","view_image"]);function
|
|
393
|
-
31||r===127})}function
|
|
394
|
-
Object.prototype||e===null}function
|
|
395
|
-
t))
|
|
392
|
+
"unified_exec_zsh_fork","view_image"]);function xt(t=""){return Array.from(String(t)).some(e=>{let r=e.codePointAt(0);return r<=
|
|
393
|
+
31||r===127})}function lo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===
|
|
394
|
+
Object.prototype||e===null}function po(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.values(
|
|
395
|
+
t))po(e);return Object.freeze(t)}function Da(t="",e={}){let r=new Error(A(t)||"Codex cannot prove the helper execution p\
|
|
396
396
|
olicy.");r.code="codex_policy_unenforceable",r.details=Object.freeze({...e});for(let[n,o]of Object.entries(r.details))["\
|
|
397
|
-
code","details","message","name"].includes(n)||(r[n]=o);return r}function
|
|
398
|
-
51.0",disabledFeatures:r=
|
|
399
|
-
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:
|
|
400
|
-
1024}={},createError:
|
|
401
|
-
f8")}catch{throw
|
|
402
|
-
n oversized ${
|
|
403
|
-
annot verify the app-server connection generation.");let
|
|
404
|
-
|
|
405
|
-
currentHelperExecutionContext!="function")throw
|
|
406
|
-
currentHelperExecutionContext(),
|
|
407
|
-
|
|
408
|
-
{accountIdentitySignature:
|
|
409
|
-
if(!
|
|
410
|
-
let
|
|
411
|
-
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return
|
|
412
|
-
"function")throw
|
|
413
|
-
let
|
|
414
|
-
er version. Update Codex and retry.",{minimumVersion:e});let
|
|
415
|
-
-1&&
|
|
416
|
-
nd retry.`,{actualVersion:
|
|
417
|
-
|
|
418
|
-
if(
|
|
419
|
-
configuration.");let
|
|
420
|
-
ceived an oversized or invalid MCP server inventory.");return
|
|
421
|
-
!Array.isArray(
|
|
422
|
-
"Codex helper execution received an unexpected hook inventory.");let v
|
|
423
|
-
isArray(
|
|
424
|
-
an incomplete hook inventory.");if(
|
|
425
|
-
ry has errors.",{hookErrorCount:
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
include_permissions_instructions:!1,...
|
|
434
|
-
fromEntries(
|
|
397
|
+
code","details","message","name"].includes(n)||(r[n]=o);return r}function za({clientName:t="jskit",minimumVersion:e="0.1\
|
|
398
|
+
51.0",disabledFeatures:r=ja,limits:{userAgentMaxLength:n=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
|
|
399
|
+
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:f=512*
|
|
400
|
+
1024}={},createError:l=Da}={}){let g=new WeakSet;function S(v,y,I){let p=0;try{p=Buffer.byteLength(JSON.stringify(v),"ut\
|
|
401
|
+
f8")}catch{throw l(`Codex helper execution received an invalid ${I}.`)}if(p>y)throw l(`Codex helper execution received a\
|
|
402
|
+
n oversized ${I}.`)}function x(v){if(typeof v?.currentConnectionGeneration!="function")throw l("Codex helper execution c\
|
|
403
|
+
annot verify the app-server connection generation.");let y=v.currentConnectionGeneration();if(!Number.isSafeInteger(y)||
|
|
404
|
+
y<=0)throw l("Codex helper execution found no active app-server connection.");return y}async function O(v){if(typeof v?.
|
|
405
|
+
currentHelperExecutionContext!="function")throw l("Codex helper execution requires its dedicated isolated provider.");let y=await v.
|
|
406
|
+
currentHelperExecutionContext(),I=A(y?.cwd),p=A(y?.accountIdentitySignature);if(y?.executionMode!=="helper"||!I||!fr.isAbsolute(
|
|
407
|
+
I)||!/^sha256:[a-f0-9]{64}$/u.test(p))throw l("Codex helper runtime isolation could not be verified.");return Object.freeze(
|
|
408
|
+
{accountIdentitySignature:p,cwd:I,executionMode:"helper"})}function P(v=""){let y=A(v).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
|
|
409
|
+
if(!y)return null;let I=y.slice(1).map(p=>Number.parseInt(p,10));return I.every(Number.isSafeInteger)?I:null}function D(v=""){
|
|
410
|
+
let y=A(v);if(!y||y.length>n||xt(y))return null;let I=`${t}/`;if(!y.startsWith(I))return null;let p=y.slice(I.length).match(
|
|
411
|
+
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return p?P(p[1]):null}function N(v){if(typeof v?.currentServerInfo!=
|
|
412
|
+
"function")throw l("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
|
|
413
|
+
let y=A(v.currentServerInfo()?.userAgent),I=D(y);if(!I)throw l("Codex helper execution received an unrecognised app-serv\
|
|
414
|
+
er version. Update Codex and retry.",{minimumVersion:e});let p=I.join("."),h=P(e),m=I.findIndex((w,b)=>w!==h[b]);if(m!==
|
|
415
|
+
-1&&I[m]<h[m])throw l(`Codex helper execution requires app-server ${e} or newer; current version is ${p}. Update Codex a\
|
|
416
|
+
nd retry.`,{actualVersion:p,minimumVersion:e});return Object.freeze({minimumVersion:e,version:p})}function F(v=null){if(!lo(
|
|
417
|
+
v?.config))throw l("Codex helper execution could not read the effective app-server configuration.");let y=v.config.mcp_servers;
|
|
418
|
+
if(y==null)return[];if(S(y,i,"MCP configuration"),!lo(y))throw l("Codex helper execution received an invalid MCP server \
|
|
419
|
+
configuration.");let I=Object.keys(y);if(I.length>o||I.some(p=>!p||p.length>s||xt(p)))throw l("Codex helper execution re\
|
|
420
|
+
ceived an oversized or invalid MCP server inventory.");return I.sort()}function q(v=null,y=""){if(S(v,f,"hook inventory"),
|
|
421
|
+
!Array.isArray(v?.data))throw l("Codex helper execution could not enumerate app-server hooks.");if(v.data.length!==1)throw l(
|
|
422
|
+
"Codex helper execution received an unexpected hook inventory.");let I=v.data[0];if(A(I?.cwd)!==y||A(I?.cwd).length>d||!Array.
|
|
423
|
+
isArray(I.hooks)||!Array.isArray(I.errors)||I.hooks.length>a||I.errors.length>c)throw l("Codex helper execution received\
|
|
424
|
+
an incomplete hook inventory.");if(I.errors.length>0)throw l("Codex helper execution cannot continue while hook discove\
|
|
425
|
+
ry has errors.",{hookErrorCount:I.errors.length});let p=I.hooks.map(m=>{let w=A(m?.key),b=A(m?.currentHash),_=A(m?.handlerType),
|
|
426
|
+
R=A(m?.sourcePath);if(!w||[w,b,_,R].some(E=>E.length>d||xt(E)))throw l("Codex helper execution found an invalid hook inv\
|
|
427
|
+
entory entry.");if(m?.isManaged===!0&&m?.enabled===!0)throw l("Codex helper execution cannot disable a managed hook.");return{
|
|
428
|
+
currentHash:b,enabled:m?.enabled===!0,handlerType:_,isManaged:m?.isManaged===!0,key:w,sourcePath:R}}).sort((m,w)=>m.key.
|
|
429
|
+
localeCompare(w.key)),h=JSON.stringify(p);if(h.length>u)throw l("Codex helper execution received an oversized hook inven\
|
|
430
|
+
tory.");return{fingerprint:h,hookKeys:p.filter(m=>!m.isManaged).map(m=>m.key)}}function V({effort:v="",summary:y="",hookKeys:I=[],
|
|
431
|
+
mcpServerNames:p=[]}={}){let h={features:Object.fromEntries(r.map(w=>[w,!1])),hooks:{state:Object.fromEntries(I.map(w=>[
|
|
432
|
+
w,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
|
|
433
|
+
include_permissions_instructions:!1,...v?{model_reasoning_effort:v}:{},...y?{model_reasoning_summary:y}:{},mcp_servers:Object.
|
|
434
|
+
fromEntries(p.map(w=>[w,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
|
|
435
435
|
mcp:{enabled:!1},skills:{enabled:!1}},project_doc_max_bytes:0,shell_environment_policy:{inherit:"none",set:{}},skills:{include_instructions:!1},
|
|
436
|
-
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},
|
|
437
|
-
|
|
438
|
-
unction")throw
|
|
439
|
-
{cwd:
|
|
440
|
-
listHooks([
|
|
441
|
-
|
|
442
|
-
hookKeys,mcpServerNames:
|
|
443
|
-
[...
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
let
|
|
447
|
-
ot retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:
|
|
448
|
-
!0,
|
|
449
|
-
await
|
|
450
|
-
deleteThread!="function")throw
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
thread:
|
|
455
|
-
"function"||typeof
|
|
456
|
-
-server thread.");let
|
|
457
|
-
|
|
458
|
-
config.model_reasoning_summary});if(!
|
|
459
|
-
|
|
460
|
-
configResult:
|
|
461
|
-
hookKeys,mcpServerNames:
|
|
462
|
-
systemPrompt:
|
|
463
|
-
null,dynamicTools:[],environments:[],model:
|
|
464
|
-
return{...
|
|
465
|
-
baseInstructions,config:
|
|
466
|
-
sandbox:
|
|
467
|
-
environments:[],model:
|
|
468
|
-
none"};return
|
|
469
|
-
inspect:
|
|
470
|
-
start:
|
|
471
|
-
1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",u=""){let
|
|
472
|
-
n is unavailable. Reconnect Codex and retry.");return
|
|
473
|
-
Codex authentication value",maxLength:
|
|
474
|
-
_auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`sha256:${
|
|
475
|
-
"sha256").update(`${e}\0`,"utf8").update(
|
|
476
|
-
return
|
|
477
|
-
try{u=await
|
|
478
|
-
ed Codex authentication record is invalid. Reconnect Codex and retry.");let
|
|
479
|
-
bytesRead:
|
|
480
|
-
selected Codex authentication record is too large. Reconnect Codex and retry.");let
|
|
481
|
-
"utf8"));if(
|
|
482
|
-
dex_helper_auth_`)?
|
|
483
|
-
Reconnect Codex and retry.")}finally{await u?.close?.().catch(()=>null)}}async function c(d={}){let u=
|
|
484
|
-
if(!u||!
|
|
485
|
-
ct Codex and retry.");let
|
|
486
|
-
|
|
487
|
-
ccess token",maxLength:
|
|
488
|
-
return Object.freeze({accessToken:
|
|
489
|
-
|
|
490
|
-
{apiKey:
|
|
436
|
+
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},m=po(h);return g.add(
|
|
437
|
+
m),m}async function G(v,{effort:y="",summary:I=""}={}){if(N(v),typeof v?.readConfig!="function"||typeof v?.listHooks!="f\
|
|
438
|
+
unction")throw l("Codex helper execution cannot inventory configuration and hooks.");let p=await O(v),h=x(v),m=await v.readConfig(
|
|
439
|
+
{cwd:p.cwd,includeLayers:!1});if(x(v)!==h)throw l("Codex app-server reconnected during helper policy verification.");let w=await v.
|
|
440
|
+
listHooks([p.cwd]);if(x(v)!==h)throw l("Codex app-server reconnected during helper policy verification.");let b=F(m),_=q(
|
|
441
|
+
w,p.cwd);return Object.freeze({accountIdentitySignature:p.accountIdentitySignature,config:V({effort:y,summary:I,hookKeys:_.
|
|
442
|
+
hookKeys,mcpServerNames:b}),connectionGeneration:h,executionCwd:p.cwd,hookFingerprint:_.fingerprint,hookKeys:Object.freeze(
|
|
443
|
+
[..._.hookKeys]),mcpServerNames:Object.freeze([...b])})}function oe(v=null,y=null){return v?.accountIdentitySignature===
|
|
444
|
+
y?.accountIdentitySignature&&v?.connectionGeneration===y?.connectionGeneration&&v?.executionCwd===y?.executionCwd&&v?.hookFingerprint===
|
|
445
|
+
y?.hookFingerprint&&JSON.stringify(v?.mcpServerNames||[])===JSON.stringify(y?.mcpServerNames||[])}function se(v,y,I=""){
|
|
446
|
+
let p=A(I);if(!y)return v.codexAppServerHelperThreadId=p,v.codexAppServerHelperThreadRetired=!0,v;let h=l("Codex could n\
|
|
447
|
+
ot retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:p});return h.codexAppServerHelperThreadCleanupRequired=
|
|
448
|
+
!0,h.codexAppServerHelperThreadId=p,h}async function be({error:v=null,provider:y=null,threadId:I=""}={}){let p=null;try{
|
|
449
|
+
await y.deleteThread(I)}catch(h){p=h}throw se(v,p,I)}async function qt(v,y){if(typeof v?.startThread!="function"||typeof v?.
|
|
450
|
+
deleteThread!="function")throw l("Codex helper execution cannot own and clean up its app-server thread.");let I=await y(),
|
|
451
|
+
p=await v.startThread(I.settings),h=A(p?.id);if(!h)throw l("Codex app-server did not return a helper thread id.");try{let m=await G(
|
|
452
|
+
v,{effort:I.enforcement.config.model_reasoning_effort,summary:I.enforcement.config.model_reasoning_summary});if(!oe(I.enforcement,
|
|
453
|
+
m))throw l("Codex execution surfaces changed while the helper thread was starting.");return Object.freeze({enforcement:m,
|
|
454
|
+
thread:p,threadId:h})}catch(m){await be({error:m,provider:v,threadId:h})}}async function nt(v,y,I){if(typeof v?.resumeThread!=
|
|
455
|
+
"function"||typeof v?.deleteThread!="function")throw l("Codex helper execution cannot safely resume and clean up its app\
|
|
456
|
+
-server thread.");let p=A(y);if(!p)throw l("Codex helper resume requires a controller-owned thread id.");let h=await I(),
|
|
457
|
+
m=h.enforcement,w=await v.resumeThread(p,h.settings);try{let b=await G(v,{effort:m.config.model_reasoning_effort,summary:m.
|
|
458
|
+
config.model_reasoning_summary});if(!oe(m,b))throw l("Codex execution surfaces changed while the helper thread was resum\
|
|
459
|
+
ing.");return Object.freeze({enforcement:b,thread:w,threadId:p})}catch(b){await be({error:b,provider:v,threadId:p})}}function Bt({
|
|
460
|
+
configResult:v,hookResult:y,workdir:I,effort:p="",summary:h=""}){let m=F(v),w=q(y,I);return V({effort:p,summary:h,hookKeys:w.
|
|
461
|
+
hookKeys,mcpServerNames:m})}function he({approvalPolicy:v,baseInstructions:y,config:I,cwd:p,effectiveSettings:h,sandbox:m,
|
|
462
|
+
systemPrompt:w}){return{allowProviderModelFallback:!1,approvalPolicy:v,baseInstructions:y,config:I,cwd:p,systemPrompt:w||
|
|
463
|
+
null,dynamicTools:[],environments:[],model:h.model,runtimeWorkspaceRoots:[],sandbox:m,selectedCapabilityRoots:[]}}function ot(v,y){
|
|
464
|
+
return{...v,sessionStartSource:"startup",threadSource:y}}function _e(v){return{approvalPolicy:v.approvalPolicy,baseInstructions:v.
|
|
465
|
+
baseInstructions,config:v.config,cwd:v.cwd,systemPrompt:v.systemPrompt,model:v.model,runtimeWorkspaceRoots:v.runtimeWorkspaceRoots,
|
|
466
|
+
sandbox:v.sandbox}}function st({approvalPolicy:v,cwd:y,effectiveSettings:I,outputSchema:p}){let h={approvalPolicy:v,cwd:y,
|
|
467
|
+
environments:[],model:I.model,outputSchema:p,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
|
|
468
|
+
none"};return I.request.reasoning&&(h.effort=I.thinking),h}return Object.freeze({assertCompatibility:N,executionContext:O,
|
|
469
|
+
inspect:G,configuration:Bt,hasConfiguration:v=>g.has(v),threadSettings:he,threadStartSettings:ot,threadResumeSettings:_e,
|
|
470
|
+
turnSettings:st,start:qt,resume:nt})}var Yl=za();var pr=1024*1024,La=256*1024,fo=512,Fa=128,$a=16*1024;function ho({errorPrefix:t="",identityNamespace:e="codex-account-v\
|
|
471
|
+
1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",u=""){let f=new Error(A(u)||"Codex helper authenticatio\
|
|
472
|
+
n is unavailable. Reconnect Codex and retry.");return f.code=A(d)||`${t}codex_helper_auth_unavailable`,f}function o(d,{label:u="\
|
|
473
|
+
Codex authentication value",maxLength:f=0}={}){if(typeof d!="string"||d.length===0||d.length>f)throw n(`${t}codex_helper\
|
|
474
|
+
_auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`sha256:${uo(
|
|
475
|
+
"sha256").update(`${e}\0`,"utf8").update(A(d),"utf8").update("\0","utf8").update(String(u||""),"utf8").digest("hex")}`}function i(d=""){
|
|
476
|
+
return uo("sha256").update(`${r}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){let u=null;
|
|
477
|
+
try{u=await Ma(d,"r");let f=await u.stat();if(!f.isFile()||f.size>pr)throw n(`${t}codex_helper_auth_invalid`,"The select\
|
|
478
|
+
ed Codex authentication record is invalid. Reconnect Codex and retry.");let l=Buffer.alloc(pr+1),g=0;for(;g<l.length;){let{
|
|
479
|
+
bytesRead:x}=await u.read(l,g,l.length-g,null);if(x===0)break;g+=x}if(g>pr)throw n(`${t}codex_helper_auth_invalid`,"The \
|
|
480
|
+
selected Codex authentication record is too large. Reconnect Codex and retry.");let S=JSON.parse(l.subarray(0,g).toString(
|
|
481
|
+
"utf8"));if(!$(S))throw new Error("invalid authentication record");return S}catch(f){throw f?.code?.startsWith?.(`${t}co\
|
|
482
|
+
dex_helper_auth_`)?f:n(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. \
|
|
483
|
+
Reconnect Codex and retry.")}finally{await u?.close?.().catch(()=>null)}}async function c(d={}){let u=A(d.toolHomeSource);
|
|
484
|
+
if(!u||!fr.isAbsolute(u))throw n(`${t}codex_helper_auth_unavailable`,"The selected Codex account is unavailable. Reconne\
|
|
485
|
+
ct Codex and retry.");let f=await a(fr.join(u,".codex","auth.json")),l=A(f.auth_mode).toLowerCase();if(l==="chatgpt"){let g=$(
|
|
486
|
+
f.tokens)?f.tokens:{},S=o(g.account_id,{label:"Codex account identity",maxLength:fo}),x=o(g.access_token,{label:"Codex a\
|
|
487
|
+
ccess token",maxLength:La}),O=g.chatgpt_plan_type??g.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:Fa});
|
|
488
|
+
return Object.freeze({accessToken:x,accountId:S,authMode:"chatgpt",identitySignature:s("chatgpt",S),planType:P,secretSignature:i(
|
|
489
|
+
x)})}if(["apikey","api_key"].includes(l)){let g=o(f.OPENAI_API_KEY,{label:"Codex API key",maxLength:$a});return Object.freeze(
|
|
490
|
+
{apiKey:g,authMode:"apiKey",identitySignature:s("apiKey",g),secretSignature:i(g)})}throw n(`${t}codex_helper_auth_invali\
|
|
491
491
|
d`,"The selected Codex authentication mode is unsupported. Reconnect Codex and retry.")}return{error:n,identitySignature:s,
|
|
492
|
-
readRecord:a,readSelected:c}}import{mkdtemp as
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
function p
|
|
498
|
-
|
|
499
|
-
kill(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
(
|
|
511
|
-
|
|
512
|
-
let
|
|
513
|
-
w
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
for(let
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
"
|
|
528
|
-
w.pid),
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
status
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
w,
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
492
|
+
readRecord:a,readSelected:c}}import{execFile as Ua,spawn as ep}from"node:child_process";import{mkdtemp as rp,open as np,readFile as hr,readdir as qa,rm as op}from"node:fs/promises";import{setTimeout as mo}from"node:timers/promises";import{promisify as Ba}from"node:util";var Ha=Ba(Ua);async function Va(t){
|
|
493
|
+
let{stdout:e}=await Ha("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function mr({runtimeTokenEnvironmentName:t="JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION\
|
|
494
|
+
_COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable",platform:o=process.platform,ps:s=Va}={}){
|
|
495
|
+
let a=o==="darwin"?100:25,c=1,d=Object.freeze({linux:"linux-proc",darwin:"darwin"}),u=d[o]||"",f=Object.freeze({RUNNING:"\
|
|
496
|
+
running",STOPPED:"stopped"}),l=Object.freeze({ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"\
|
|
497
|
+
mismatch"});function g(p,h){let m=Number(p);return Number.isSafeInteger(m)&&m>0?m:h}function S(p={}){return!!(Number.isSafeInteger(
|
|
498
|
+
Number(p.pid))&&Number(p.pid)>0&&F(p.processIdentity)&&[f.RUNNING,f.STOPPED].includes(p.processState))}function x(p){let h=Number(
|
|
499
|
+
p);if(!Number.isSafeInteger(h)||h<=0)return!1;try{return process.kill(h,0),!0}catch{return!1}}function O(p){let h=Number(
|
|
500
|
+
p);if(!Number.isSafeInteger(h)||h<=0)return!1;if(process.platform==="win32")return x(h);try{return process.kill(-h,0),!0}catch{
|
|
501
|
+
return!1}}function P(p,h){let m=Number(p),w=process.platform==="win32"?m:-m;try{return process.kill(w,h),!0}catch(b){if(![
|
|
502
|
+
"ESRCH","EPERM"].includes(String(b?.code||"")))throw b;return!1}}function D(p=""){let h=String(p||""),m=h.lastIndexOf(")");
|
|
503
|
+
if(m<0)return null;let w=h.slice(m+1).trim().split(/\s+/u),b=String(w[0]||""),_=Number(w[1]),R=Number(w[2]),E=String(w[19]||
|
|
504
|
+
"");return!/^[A-Z]$/u.test(b)||!Number.isSafeInteger(_)||_<0||!Number.isSafeInteger(R)||R<=0||!/^\d+$/u.test(E)?null:{parentPid:_,
|
|
505
|
+
processGroupId:R,startTimeTicks:E,state:b}}function N(p={}){let h=$(p)?p:{};return{commandHash:A(h.commandHash),platform:A(
|
|
506
|
+
h.platform),runtimeToken:A(h.runtimeToken),startTimeTicks:A(h.startTimeTicks),version:Number(h.version||0)}}function F(p={}){
|
|
507
|
+
let h=N(p);return!!(h.version===c&&Object.values(d).includes(h.platform)&&/^[a-f0-9]{12}$/u.test(h.commandHash)&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.
|
|
508
|
+
test(h.runtimeToken)&&/^\d+$/u.test(h.startTimeTicks))}function q(p=[],h=""){let m=p.find(w=>w.startsWith(`${h}=`));return m?
|
|
509
|
+
m.slice(h.length+1):""}async function V(){let p=[],h=await qa("/proc",{withFileTypes:!0}).catch(()=>[]);for(let m of h){
|
|
510
|
+
if(!m.isDirectory()||!/^\d+$/u.test(m.name))continue;let w=Number(m.name),b=await hr(`/proc/${m.name}/stat`,"utf8").catch(
|
|
511
|
+
()=>""),_=D(b);if(!_||_.state==="Z")continue;let R=null,E=!0;try{R=await hr(`/proc/${m.name}/environ`)}catch(C){if(String(
|
|
512
|
+
C?.code||"")==="ENOENT")continue;E=!1}let j=E?R.toString("utf8").split("\0"):[];p.push({..._,commandHash:q(j,e),environmentReadable:E,
|
|
513
|
+
pid:w,runtimeToken:q(j,t)})}return p}let G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oe(p=""){
|
|
514
|
+
let h=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.exec(String(p).trim()),m=h?G.indexOf(h[1]):-1;
|
|
515
|
+
if(m<0)return"";let[,,w,b,_,R,E]=h.map(Number);return String(Date.UTC(E,m,w,b,_,R)/1e3)}function se(p=""){let h=new Map;
|
|
516
|
+
for(let m of String(p).split(`
|
|
517
|
+
`)){let w=/^\s*(\d+) (.*)$/u.exec(m);w&&h.set(Number(w[1]),w[2])}return h}function be(p,h){if(p===void 0||!h?.startsWith(
|
|
518
|
+
p))return null;let m=h.slice(p.length).split(/\s+/u).filter(w=>/^[^=\s]+=/u.test(w));return m.length?m:null}async function qt(){
|
|
519
|
+
let p=process.getuid(),h=["-x","-U",String(p),"-ww","-o","pid=,command="],[m,w,b]=await Promise.all([s(["-ax","-o","pid=\
|
|
520
|
+
,pgid=,uid=,stat=,lstart="]),s(h),s(["-E",...h])]),_=se(w),R=se(b),E=[];for(let j of String(m).split(`
|
|
521
|
+
`)){let C=/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+[\d:]{8}\s+\d{4})\s*$/u.exec(j);if(!C||C[4].startsWith(
|
|
522
|
+
"Z"))continue;let Ae=Number(C[1]),ie=Number(C[3])===p?be(_.get(Ae),R.get(Ae)):null;E.push({commandHash:q(ie||[],e),environmentReadable:!!ie,
|
|
523
|
+
pid:Ae,processGroupId:Number(C[2]),runtimeToken:q(ie||[],t),startTimeTicks:oe(C[5])})}return E}function nt(p={}){let h=Object.
|
|
524
|
+
values(l).includes(p?.status)?p.status:l.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(p?.processGroupIds)?
|
|
525
|
+
p.processGroupIds:[]).map(Number).filter(m=>Number.isSafeInteger(m)&&m>0))],status:h}}async function Bt(p={}){if(!S(p))return{
|
|
526
|
+
processGroupIds:[],status:l.INVALID};if(p.processState===f.STOPPED)return{processGroupIds:[],status:l.ABSENT};let h=p.processIdentity,
|
|
527
|
+
m=h.platform!==u?null:o==="darwin"?await qt().catch(()=>null):await V();if(!m)return{processGroupIds:[],status:l.AMBIGUOUS};
|
|
528
|
+
let w=Number(p.pid),b=m.filter(({processGroupId:C})=>C===w),_=[],R=b.some(({environmentReadable:C})=>!C);for(let C of m)
|
|
529
|
+
C.environmentReadable&&C.runtimeToken===h.runtimeToken&&C.commandHash===h.commandHash&&_.push(C);let E=_.find(({pid:C})=>C===
|
|
530
|
+
w);if(E&&E.startTimeTicks!==h.startTimeTicks)return{processGroupIds:[],status:l.AMBIGUOUS};if(_.length===0)return R?{processGroupIds:[],
|
|
531
|
+
status:l.AMBIGUOUS}:{processGroupIds:[],status:b.length>0||O(w)?l.MISMATCH:l.ABSENT};let j=[...new Set(_.map(({processGroupId:C})=>C))];
|
|
532
|
+
for(let C of j)if(m.filter(ie=>ie.processGroupId===C).some(ie=>!ie.environmentReadable||!_.some(({pid:Js})=>Js===ie.pid)))
|
|
533
|
+
return{processGroupIds:[],status:l.AMBIGUOUS};return b.some(C=>!_.some(({pid:Ae})=>Ae===C.pid))?{processGroupIds:[],status:l.
|
|
534
|
+
AMBIGUOUS}:{processGroupIds:j,status:l.EXACT}}async function he(p={},h={}){let m=typeof h.processIdentityInspector=="fun\
|
|
535
|
+
ction"?h.processIdentityInspector:Bt;return nt(await m(p))}async function ot(p={},h={},m=0){let w=Date.now()+m,b=await he(
|
|
536
|
+
p,h);for(;Date.now()<w&&b.status===l.EXACT;)await mo(100),b=await he(p,h);return b}async function _e(p={},h={}){let m=g(
|
|
537
|
+
h.processIdentitySettleTimeoutMs,1e3),w=g(h.processIdentitySettlePollMs,a),b=Date.now()+m,_=await he(p,h);for(;_.status===
|
|
538
|
+
l.AMBIGUOUS&&Date.now()<b;)await mo(Math.min(w,Math.max(1,b-Date.now()))),_=await he(p,h);return _}async function st(p={},h="\
|
|
539
|
+
SIGTERM",m={}){let w=typeof m.signalProcessGroup=="function"?m.signalProcessGroup:P,b=await _e(p,m);if(b.status!==l.EXACT)
|
|
540
|
+
return{inspection:b,signaledProcessGroups:[]};let _=Number(p.pid),R=[...b.processGroupIds.filter(j=>j!==_),...b.processGroupIds.
|
|
541
|
+
filter(j=>j===_)],E=[];for(let j of R){let C=await _e(p,m);if(C.status===l.ABSENT||C.status===l.MISMATCH)return{inspection:C,
|
|
542
|
+
signaledProcessGroups:E};if(C.status!==l.EXACT)return{inspection:C,signaledProcessGroups:E};C.processGroupIds.includes(j)&&
|
|
543
|
+
(w(j,h),E.push(j))}return{inspection:await _e(p,m),signaledProcessGroups:E}}async function v(p={},h={}){if(!S(p))return{
|
|
544
|
+
identityStatus:l.INVALID,processExitVerified:!1,stopped:!1};if(p.processState===f.STOPPED&&p.processExitVerifiedAt)return{
|
|
545
|
+
alreadyStopped:!0,identityStatus:l.ABSENT,processExitVerified:!0,stopped:!1};let m=await _e(p,h);if(m.status===l.ABSENT||
|
|
546
|
+
m.status===l.MISMATCH)return{identityStatus:m.status,processExitVerified:!0,stopped:!1};if(m.status!==l.EXACT)return{identityStatus:m.
|
|
547
|
+
status,processExitVerified:!1,stopped:!1};let w=await st(p,"SIGTERM",h);if(w.inspection.status===l.AMBIGUOUS)return{identityStatus:w.
|
|
548
|
+
inspection.status,processExitVerified:!1,signaledProcessGroups:w.signaledProcessGroups,stopped:!1};let b=await ot(p,h,g(
|
|
549
|
+
h.termTimeoutMs,3e3)),_=[...w.signaledProcessGroups];if(b.status===l.EXACT){let E=await st(p,"SIGKILL",h);if(_=[...new Set(
|
|
550
|
+
[..._,...E.signaledProcessGroups])],E.inspection.status===l.AMBIGUOUS)return{identityStatus:E.inspection.status,processExitVerified:!1,
|
|
551
|
+
signaledProcessGroups:_,stopped:!1};b=await ot(p,h,g(h.killTimeoutMs,1e3))}let R=[l.ABSENT,l.MISMATCH].includes(b.status);
|
|
552
|
+
return{descendantProcessGroups:_.filter(E=>E!==Number(p.pid)),identityStatus:b.status,pid:Number(p.pid),processExitVerified:R,
|
|
553
|
+
signaledProcessGroups:_,stopped:R&&_.length>0}}async function y(p){if(o!=="darwin")return D(await hr(`/proc/${p}/stat`,"\
|
|
554
|
+
utf8").catch(()=>""));let h=String(await s(["-o","pgid=,lstart=","-p",String(p)]).catch(()=>"")),m=/^\s*(\d+)\s+(.+?)\s*$/u.
|
|
555
|
+
exec(h);return m?{processGroupId:Number(m[1]),startTimeTicks:oe(m[2])}:null}async function I({commandHash:p="",pid:h=null,
|
|
556
|
+
reportedIdentity:m=null,runtimeToken:w=""}={}){let b=A(p),_=A(w),R=N(m);if(F(R)&&R.commandHash===b&&R.runtimeToken===_)return R;
|
|
557
|
+
let E=Number(h),j=u&&Number.isSafeInteger(E)&&E>0?await y(E):null;if(!j?.startTimeTicks||j.processGroupId!==E){let C=new Error(
|
|
558
|
+
`${r} process identity could not be captured.`);throw C.code=n,C}return{commandHash:b,platform:u,runtimeToken:_,startTimeTicks:j.
|
|
559
|
+
startTimeTicks,version:c}}return Object.freeze({normalize:N,isValid:F,normalizeInspection:nt,capture:I,inspect:he,stop:v,
|
|
560
|
+
isProcessAlive:x})}var Tt=(t,e,r,n={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(r),...n}),Ga=Object.freeze([Object.freeze(
|
|
547
561
|
{id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
|
|
548
|
-
webSearch:!1,models:Object.freeze([
|
|
549
|
-
|
|
562
|
+
webSearch:!1,models:Object.freeze([Tt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
|
|
563
|
+
Tt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0})])}),Object.freeze({id:"zai-coding-plan",baseUrl:"h\
|
|
550
564
|
ttps://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,webSearch:!1,models:Object.
|
|
551
|
-
freeze([
|
|
565
|
+
freeze([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai",
|
|
552
566
|
baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,webSearch:!1,
|
|
553
|
-
models:Object.freeze([
|
|
554
|
-
return
|
|
555
|
-
deepseek:
|
|
556
|
-
UNREACHABLE:"unreachable"}),
|
|
557
|
-
SUSPECT:"suspect"})
|
|
558
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
559
|
-
in",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
560
|
-
versionName:"1.0.0"});var
|
|
561
|
-
"metadata","migrations","runtime","vite"]);var
|
|
562
|
-
|
|
567
|
+
models:Object.freeze([Tt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function Ie(t){
|
|
568
|
+
return Ga.find(e=>e.id===t)||null}var lp=32*1024*1024,pp=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
|
|
569
|
+
deepseek:Ie("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":Ie("zai-coding-plan").baseUrl,zai:Ie("zai").baseUrl});var vp=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexProcess.js",import.meta.url).href;var bp=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),_p=mr();var Ka=Object.freeze({UNIX:"unix"});var Ap=process.platform==="linux"?107:103,Cp=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
570
|
+
UNREACHABLE:"unreachable"}),Ep=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
|
|
571
|
+
SUSPECT:"suspect"}),Ja=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),Op=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
|
|
572
|
+
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var ff=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),hf=ho().error;var mf=32*1024,gf=2*1024*1024;var vf=64*1024,wf=2*1024*1024,yf=4*1024*1024;import{createRequire as xc}from"node:module";var Sc=new URL("./../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var Ih=xc(Sc);var xh=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function U(t,{fallback:e=""}={}){return String(t||"").trim()||e}function Qe(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var Th=Object.freeze(["bundled","dev_server"]),bh=Object.freeze(["capacitor"]),_h=Object.freeze({callbackPath:"/auth/log\
|
|
573
|
+
in",customScheme:"",appLinkDomains:Object.freeze([])}),Ah=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
|
|
574
|
+
versionName:"1.0.0"});var Dh=new URL("./../../../@jskit-ai/kernel/server/support/appConfigFiles.js",import.meta.url).href;var Vh=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Gh=Object.freeze(["capabilities","kind",
|
|
575
|
+
"metadata","migrations","runtime","vite"]);var _r="/api",nm=`${_r}/`,om=`${_r}/docs`,sm=`${_r}/realtime`;var gm=Object.freeze(["compact","medium","expanded"]);var hg=64*1024;var Rt=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
576
|
+
mg=new Set(Object.values(Rt)),gg=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
|
|
563
577
|
jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
564
|
-
|
|
578
|
+
vg=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),wg=Object.freeze(["accountIde\
|
|
565
579
|
ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
|
|
566
|
-
Hash","terminalEnvHash","toolHomeSource","transport"]),
|
|
567
|
-
|
|
568
|
-
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function
|
|
569
|
-
let{items:r}=e;if(
|
|
570
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
571
|
-
if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(
|
|
580
|
+
Hash","terminalEnvHash","toolHomeSource","transport"]),yg=Object.freeze(["userAgent"]);function H(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
581
|
+
Uc(e)}function Uc(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function Ar(t){return t!==null&&typeof t=="object"&&H(t.structure)&&H(t.operations)&&typeof t.validateWith=="function"&&
|
|
582
|
+
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Pt(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
583
|
+
let{items:r}=e;if(Ar(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!="string")throw new Error(`Array field "${t}\
|
|
584
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Ze(t,e){
|
|
585
|
+
if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(Ar(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!=
|
|
572
586
|
"string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
|
|
573
|
-
t.`);return{kind:"definition",definition:r}}function
|
|
587
|
+
t.`);return{kind:"definition",definition:r}}function kt(t,e){let r=Object.hasOwn(e,"schema"),n=Object.hasOwn(e,"values"),
|
|
574
588
|
o=Object.hasOwn(e,"additionalProperties");if(r&&n)throw new Error(`Object field "${t}" cannot define both schema and val\
|
|
575
589
|
ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
|
|
576
590
|
if(n&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
|
|
577
|
-
s: true.`);if(r){if(!
|
|
578
|
-
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return n?{kind:"map",valuesConfig:
|
|
579
|
-
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function
|
|
580
|
-
|
|
581
|
-
$`,
|
|
582
|
-
))?${
|
|
583
|
-
0)}function
|
|
584
|
-
1&&o<=12&&s>=1&&s<=
|
|
585
|
-
`temporalPrecision for "${e}" must be a non-negative integer.`);return r}}function
|
|
586
|
-
t.length<=e}function
|
|
587
|
-
if(typeof t!="string")return!1;let r=
|
|
588
|
-
let r=
|
|
589
|
-
"":`(?:\\.\\d{1,${t}})?`}function
|
|
590
|
-
return`^${
|
|
591
|
-
test(t))r=Number(t);else return null;return!Number.isSafeInteger(r)||r<-e||r>e?null:r===0?0:r}var
|
|
592
|
-
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function
|
|
593
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
594
|
-
let o=r?
|
|
591
|
+
s: true.`);if(r){if(!Ar(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
|
|
592
|
+
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Ze(
|
|
593
|
+
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function De(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}var Cr="^(?:0|-?[1-9]\\d*)$",Go="\\d{4}",Wo="0[1-9]|1[0-2]",Ko="0[1-9]|[12]\\d|3[01]",Jo="[01]\\d|2[0-3]",ze="[0-5]\\d",
|
|
594
|
+
Mt=`(?:${Jo}):${ze}`,Xo=`(?:Z|[+-](?:${Jo}):${ze})`,Yo=`(${Go})-(${Wo})-(${Ko})`,Qo=`${Go}-(?:${Wo})-(?:${Ko})`,Zo=`^${Qo}\
|
|
595
|
+
$`,qc=new RegExp(`^${Yo}$`),Bc=new RegExp(`^${Mt}(?::${ze}(?:\\.(\\d+))?)?$`),Hc=new RegExp(`^${Yo}T${Mt}:${ze}(?:\\.(\\d+\
|
|
596
|
+
))?${Xo}$`),Vc=new RegExp(Cr),Gc=[31,28,31,30,31,30,31,31,30,31,30,31];function Wc(t){return t%4===0&&(t%100!==0||t%400===
|
|
597
|
+
0)}function Kc(t,e){return e===2?Wc(t)?29:28:Gc[e-1]}function es(t,e,r){let n=Number(t),o=Number(e),s=Number(r);return o>=
|
|
598
|
+
1&&o<=12&&s>=1&&s<=Kc(n,o)}function et(t,e){let r=t.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
|
|
599
|
+
`temporalPrecision for "${e}" must be a non-negative integer.`);return r}}function ts(t,e){return t===void 0?!0:e===void 0||
|
|
600
|
+
t.length<=e}function rs(t){if(typeof t!="string")return!1;let e=qc.exec(t);return e!==null&&es(e[1],e[2],e[3])}function ns(t,e){
|
|
601
|
+
if(typeof t!="string")return!1;let r=Bc.exec(t);return r!==null&&ts(r[1],e)}function os(t,e){if(typeof t!="string")return!1;
|
|
602
|
+
let r=Hc.exec(t);return r===null?!1:es(r[1],r[2],r[3])&&ts(r[4],e)}function ss(t){return t===void 0?"(?:\\.\\d+)?":t===0?
|
|
603
|
+
"":`(?:\\.\\d{1,${t}})?`}function is(t,e){let r=et(t,e);return`^${Mt}(?::${ze}${ss(r)})?$`}function as(t,e){let r=et(t,e);
|
|
604
|
+
return`^${Qo}T${Mt}:${ze}${ss(r)}${Xo}$`}function Er(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&Vc.
|
|
605
|
+
test(t))r=Number(t);else return null;return!Number.isSafeInteger(r)||r<-e||r>e?null:r===0?0:r}var Jc=new Set(["__proto__","prototype","constructor"]);function T(t,e,r){Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Xc(t,e){if(Jc.
|
|
606
|
+
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function Yc(t){return typeof t!="string"?t:t.replace(
|
|
607
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Or(t,e,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
608
|
+
let o=r?Yc(t):t;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${e}() expects a non-empty \
|
|
595
609
|
dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
|
|
596
|
-
for(let i of s)
|
|
597
|
-
|
|
598
|
-
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:
|
|
599
|
-
none:()=>({type:
|
|
610
|
+
for(let i of s)Xc(i,e);return s}var Qc="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",Rr=["object","array","string","number","boolean"],
|
|
611
|
+
Pr=Symbol("json-rest-schema.exportContext"),Zc=["true","1","yes","y","on"],ed=["false","0","no","n","off"];function cs(t){
|
|
612
|
+
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:Cr}]}}function Se(t,e){return{[fe]:{[t]:e}}}var td={
|
|
613
|
+
none:()=>({type:Rr}),blob:()=>({type:Rr}),serialize:()=>({type:Rr}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
600
614
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
601
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
602
|
-
type:"string",format:"date-time",pattern:
|
|
603
|
-
fieldName:e})=>({type:"string",pattern:
|
|
604
|
-
let e=new Set([...
|
|
615
|
+
eger","string"]}),epochMilliseconds:()=>cs(864e13),epochSeconds:()=>cs(864e10),dateTime:({definition:t,fieldName:e})=>({
|
|
616
|
+
type:"string",format:"date-time",pattern:as(t,e)}),date:()=>({type:"string",format:"date",pattern:Zo}),time:({definition:t,
|
|
617
|
+
fieldName:e})=>({type:"string",pattern:is(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
|
|
618
|
+
let e=new Set([...Zc,String(t.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...ed,String(t.stringFalseWhen||
|
|
605
619
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...r,...e]}]}},
|
|
606
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
620
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},rd={minLength:({definition:t,parameterValue:e})=>t.
|
|
607
621
|
type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
|
|
608
|
-
definition:t,parameterValue:e})=>
|
|
622
|
+
definition:t,parameterValue:e})=>De(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>De(t)?{maximum:e}:null,pattern:({
|
|
609
623
|
definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
|
|
610
624
|
enum:t}),notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({parameterValue:t})=>t?
|
|
611
|
-
|
|
612
|
-
"transforms",{length:t}),unsigned:({parameterValue:t})=>t?
|
|
613
|
-
"metadata",{precision:t}),scale:({parameterValue:t})=>
|
|
625
|
+
Se("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Se("transforms",{lowercase:!0}):null,length:({parameterValue:t})=>Se(
|
|
626
|
+
"transforms",{length:t}),unsigned:({parameterValue:t})=>t?Se("metadata",{unsigned:!0}):null,precision:({parameterValue:t})=>Se(
|
|
627
|
+
"metadata",{precision:t}),scale:({parameterValue:t})=>Se("metadata",{scale:t}),temporalPrecision:({parameterValue:t})=>Se(
|
|
614
628
|
"metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null};
|
|
615
|
-
function
|
|
616
|
-
isArray(n)&&!Array.isArray(o)){
|
|
629
|
+
function jr(t,e){for(let r of Object.keys(e)){let n=e[r],o=t[r];if(n&&o&&typeof n=="object"&&typeof o=="object"&&!Array.
|
|
630
|
+
isArray(n)&&!Array.isArray(o)){jr(o,n);continue}t[r]=n}}function nd(t,e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(
|
|
617
631
|
"JSON Schema export hooks must return an object or null.");for(let r of Object.keys(e)){if(r===fe&&t[r]&&typeof t[r]=="o\
|
|
618
|
-
bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){
|
|
619
|
-
let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function
|
|
632
|
+
bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){jr(t[r],e[r]);continue}t[r]=e[r]}}function od(t,e){
|
|
633
|
+
let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function sd(t,e){
|
|
620
634
|
if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);let r=t.types[e.type];if(typeof r.
|
|
621
|
-
toJsonSchema=="function")return r.toJsonSchema;let n=
|
|
622
|
-
ed to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
623
|
-
let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=
|
|
624
|
-
`Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function
|
|
635
|
+
toJsonSchema=="function")return r.toJsonSchema;let n=td[e.type];if(!n)throw new Error(`Type '${e.type}' cannot be export\
|
|
636
|
+
ed to JSON Schema without a toJsonSchema hook.`);return n}function id(t,e,r){if(!Object.hasOwn(t.validators,e))return null;
|
|
637
|
+
let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=rd[e];if(o)return o;throw new Error(
|
|
638
|
+
`Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function ds(t){if(t===
|
|
625
639
|
void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(`Unsupported JSON Schema expo\
|
|
626
|
-
rt mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
627
|
-
let r=
|
|
640
|
+
rt mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function ad(t,e={}){if(e.mode!==void 0&&e.operation!==void 0){
|
|
641
|
+
let r=ds(e.mode);if(r!==e.operation)throw new Error(`Conflicting JSON Schema export options: mode '${r}' does not match \
|
|
628
642
|
operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))throw new Error(`Unkn\
|
|
629
|
-
own JSON Schema export operation '${e.operation}'.`);return e.operation}return
|
|
630
|
-
void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};let r=
|
|
631
|
-
e);return{operationName:r,operation:t.operations[r]}}function
|
|
632
|
-
definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function
|
|
633
|
-
nodes:[],nextDefinitionId:1,rootNode:null}}function
|
|
634
|
-
"")||"operation"}function
|
|
635
|
-
t)?{allOf:[t]}:t}function
|
|
636
|
-
o)||null}function
|
|
637
|
-
root:s=!1}={}){let i=
|
|
638
|
-
operation:n,additionalProperties:o,status:"new",definitionName:s?null:
|
|
639
|
-
c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function
|
|
640
|
-
if(t.status==="building")return{$ref:t.pointer};let r=
|
|
641
|
-
{});let n=
|
|
642
|
-
definitions[t.definitionName]=n,{$ref:t.pointer})}function
|
|
643
|
-
i?{$ref:"#"}:
|
|
644
|
-
let s={},i=[];for(let[c,d]of Object.entries(t.structure))
|
|
645
|
-
c);let a={type:"object",properties:s,additionalProperties:o};return i.length>0&&(a.required=i),a}function
|
|
646
|
-
let i=
|
|
643
|
+
own JSON Schema export operation '${e.operation}'.`);return e.operation}return ds(e.mode)}function cd(t,e={}){if(e.operationName!==
|
|
644
|
+
void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};let r=ad(t,
|
|
645
|
+
e);return{operationName:r,operation:t.operations[r]}}function dd(t={}){let e={...t};return Object.defineProperty(e,Pr,{value:{
|
|
646
|
+
definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function jt(t={}){return t[Pr]?t[Pr]:{definitions:{},
|
|
647
|
+
nodes:[],nextDefinitionId:1,rootNode:null}}function ud(t){return String(t).replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,
|
|
648
|
+
"")||"operation"}function kr(t){return H(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}function Nt(t){return kr(
|
|
649
|
+
t)?{allOf:[t]}:t}function ld(t,e,r,n,o){return t.nodes.find(s=>s.schema===e&&s.operationName===r&&s.operation===n&&s.additionalProperties===
|
|
650
|
+
o)||null}function pd(t,e){let r=ud(e),n=`SchemaNode_${t.nextDefinitionId}_${r}`;return t.nextDefinitionId+=1,n}function us(t,e,r,n,o,{
|
|
651
|
+
root:s=!1}={}){let i=jt(e),a=ld(i,t,r,n,o);if(a)return s&&(a.pointer="#",i.rootNode=a),a;let c={schema:t,operationName:r,
|
|
652
|
+
operation:n,additionalProperties:o,status:"new",definitionName:s?null:pd(i,r),pointer:s?"#":null};return s?i.rootNode=c:
|
|
653
|
+
c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function ls(t,e){if(t.status==="built")return{$ref:t.pointer};
|
|
654
|
+
if(t.status==="building")return{$ref:t.pointer};let r=jt(e);t.status="building",t.pointer!=="#"&&(r.definitions[t.definitionName]=
|
|
655
|
+
{});let n=fd(t.schema,e,t.operationName,t.operation,t.additionalProperties);return t.status="built",t.pointer==="#"?n:(r.
|
|
656
|
+
definitions[t.definitionName]=n,{$ref:t.pointer})}function Dr(t,e,r,n,o=!1){let s=jt(e),i=us(t,e,r,n,o);return s.rootNode===
|
|
657
|
+
i?{$ref:"#"}:ls(i,e)}function tt(t,{referenceBacked:e=!1}={}){return{schema:t,referenceBacked:e}}function fd(t,e,r,n,o=!1){
|
|
658
|
+
let s={},i=[];for(let[c,d]of Object.entries(t.structure))T(s,c,zr(t,c,d,e,r,n)),n.enforceRequired&&d.required===!0&&i.push(
|
|
659
|
+
c);let a={type:"object",properties:s,additionalProperties:o};return i.length>0&&(a.required=i),a}function hd(t,e,r,n,o,s){
|
|
660
|
+
let i=Pt(e,r);if(!i)return null;if(i.kind==="schema")return{...Nt(Dr(i.schema,n,"replace",i.schema.operations.replace,!1)),
|
|
647
661
|
[fe]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,"schema")?"replace":o,c=a==="replace"?t.operations.
|
|
648
|
-
replace:s;return
|
|
649
|
-
ma")return{...
|
|
650
|
-
"object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return
|
|
651
|
-
definition,n,a,c)}function
|
|
652
|
-
n,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return
|
|
653
|
-
if(a.kind==="map")return
|
|
662
|
+
replace:s;return zr(t,`${e}[]`,r.items,n,a,c)}function md(t,e,r,n,o,s){let i=Ze(e,r);if(!i)return null;if(i.kind==="sche\
|
|
663
|
+
ma")return{...Nt(Dr(i.schema,n,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=i.definition.type===
|
|
664
|
+
"object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return zr(t,`${e}.*`,i.
|
|
665
|
+
definition,n,a,c)}function gd(t,e,r,n,o,s){if(r.type==="object"){let a=kt(e,r);if(a.kind==="nested")return tt(Dr(a.schema,
|
|
666
|
+
n,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return tt({type:"object",additionalProperties:!0});
|
|
667
|
+
if(a.kind==="map")return tt({type:"object",additionalProperties:md(t,e,r,n,o,s)})}let i=sd(t,r)({schema:t,fieldName:e,definition:r,
|
|
654
668
|
operation:o,mode:o,options:n});if(!i||typeof i!="object"||Array.isArray(i))throw new Error(`Type '${r.type}' on field '${e}\
|
|
655
|
-
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=
|
|
656
|
-
referenceBacked:
|
|
657
|
-
operation:o,mode:o,options:n},a=
|
|
658
|
-
keys(r)){if(
|
|
659
|
-
parameterValue:r[
|
|
660
|
-
type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let
|
|
661
|
-
defaultTo!="function"){let
|
|
662
|
-
options:{},settings:t._buildOperationSettings(o,s,{})});if(Object.keys(
|
|
663
|
-
throw new Error(`defaultTo for "${e}" is invalid (${
|
|
664
|
-
return
|
|
665
|
-
!1:r.additionalProperties,i=
|
|
666
|
-
length>0&&(c.definitions=i.definitions),c}function
|
|
667
|
-
|
|
668
|
-
.${String(e)}`}function
|
|
669
|
-
startsWith(r)?t.slice(r.length):null}function
|
|
670
|
-
{...n,field:o})}return r}function
|
|
671
|
-
o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||
|
|
672
|
-
return e}function
|
|
673
|
-
function
|
|
669
|
+
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=hd(t,e,r,n,o,s);if(a)return tt({...i,items:a},{
|
|
670
|
+
referenceBacked:kr(i)})}return tt(i,{referenceBacked:kr(i)})}function zr(t,e,r,n,o,s){let i={schema:t,fieldName:e,definition:r,
|
|
671
|
+
operation:o,mode:o,options:n},a=gd(t,e,r,n,o,s),c=a.referenceBacked?Nt(a.schema):{...a.schema},d={castType:r.type};for(let l of Object.
|
|
672
|
+
keys(r)){if(l==="type"||!Object.hasOwn(t.validators,l))continue;let g=id(t,l,e);if(!g)continue;let S=g({...i,parameterName:l,
|
|
673
|
+
parameterValue:r[l],fieldSchema:{...c}});S&&nd(c,S)}c[fe]&&(jr(d,c[fe]),delete c[fe]);let u=[];r.nullable===!0&&u.push({
|
|
674
|
+
type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let f=Nt(od(c,u));if(r.defaultTo!==void 0&&s.applyDefaults)if(typeof r.
|
|
675
|
+
defaultTo!="function"){let l=t._normalizeDefault(r,r.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},
|
|
676
|
+
options:{},settings:t._buildOperationSettings(o,s,{})});if(Object.keys(l.errors).length>0){let g=Object.values(l.errors)[0];
|
|
677
|
+
throw new Error(`defaultTo for "${e}" is invalid (${g.code}).`)}f.default=l.value}else d.defaults={providedByFunction:!0};
|
|
678
|
+
return f[fe]=d,f}function ps(t,e={}){let r=dd(e),{operationName:n,operation:o}=cd(t,r),s=r.additionalProperties===void 0?
|
|
679
|
+
!1:r.additionalProperties,i=jt(r),a=us(t,r,n,o,s,{root:!0}),c={$schema:Qc,...ls(a,r)};return Object.keys(i.definitions).
|
|
680
|
+
length>0&&(c.definitions=i.definitions),c}function fs(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function qr(t){return t instanceof
|
|
681
|
+
$e}function vd(){return{self:!1,children:{}}}function hs(t){return Object.keys(t.children).length>0}function xe(t,e){return`${t}\
|
|
682
|
+
.${String(e)}`}function Is(t,e){return t===""?String(e):xe(t,e)}function ms(t,e){if(t===e)return"";let r=`${e}.`;return t.
|
|
683
|
+
startsWith(r)?t.slice(r.length):null}function Le(t,e){let r={};for(let n of Object.values(t)){let o=xe(e,n.field);T(r,o,
|
|
684
|
+
{...n,field:o})}return r}function $r(t){return Or(t,"validatePath")}function gs(t){let e={};for(let r of t){let n=$r(r),
|
|
685
|
+
o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||T(o,i,vd()),s===n.length-1&&(o[i].self=!0),o=o[i].children}}
|
|
686
|
+
return e}function wd(t,e){let r=t;for(let n of e){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
|
|
687
|
+
function Dt(t){return t===null?!0:Array.isArray(t)||H(t)?Object.keys(t).length>0:t!==void 0}function vs(t){return[...t].
|
|
674
688
|
sort((e,r)=>{let n=/^[0-9]+$/.test(e),o=/^[0-9]+$/.test(r);return n&&o?Number(e)-Number(r):n?-1:o?1:e.localeCompare(r)})}
|
|
675
|
-
function
|
|
689
|
+
function yd(t){return/^[0-9]+$/.test(t)}function Id(t,e=new WeakMap){if(e.has(t))return e.get(t);let r=Object.create($e.
|
|
676
690
|
prototype);return e.set(t,r),r.structure=null,r.types=t.types,r.validators=t.validators,r.operations=t.operations,r.structure=
|
|
677
|
-
|
|
678
|
-
"object")return t;if(
|
|
691
|
+
Lt(zt(t.structure,e)),r._installOperationMethods(),Object.freeze(r)}function zt(t,e=new WeakMap){if(t===null||typeof t!=
|
|
692
|
+
"object")return t;if(qr(t))return Id(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let n=new RegExp(
|
|
679
693
|
t.source,t.flags);return n.lastIndex=t.lastIndex,n}if(e.has(t))return e.get(t);if(Array.isArray(t)){let n=[];e.set(t,n);
|
|
680
|
-
for(let o of t)n.push(
|
|
681
|
-
o,e));return r}function
|
|
682
|
-
isArray(t))for(let r of t)
|
|
683
|
-
return
|
|
684
|
-
t.structure,n))return null;let s=t.structure[n];if(o.length<1)return s;let i=
|
|
685
|
-
if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:
|
|
686
|
-
"array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[s,...i]=r;if(!
|
|
687
|
-
n,s);return o.kind==="schema"?i.length<1?null:
|
|
688
|
-
function
|
|
694
|
+
for(let o of t)n.push(zt(o,e));return n}if(!H(t))return t;let r={};e.set(t,r);for(let[n,o]of Object.entries(t))T(r,n,zt(
|
|
695
|
+
o,e));return r}function Lt(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||qr(t))return t;if(e.add(t),Array.
|
|
696
|
+
isArray(t))for(let r of t)Lt(r,e);else for(let r of Reflect.ownKeys(t))Lt(t[r],e);return Object.freeze(t)}function Lr(t){
|
|
697
|
+
return Lt(zt(t))}function Ur(t,e,r=""){if(!qr(t)||!Array.isArray(e)||e.length<1)return null;let[n,...o]=e;if(!Object.hasOwn(
|
|
698
|
+
t.structure,n))return null;let s=t.structure[n];if(o.length<1)return s;let i=Is(r,n);return Ss(t,s,o,i)}function Ss(t,e,r,n){
|
|
699
|
+
if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:Ur(o.schema,r,n)}if(e?.type===
|
|
700
|
+
"array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[s,...i]=r;if(!yd(s))return null;let a=xe(
|
|
701
|
+
n,s);return o.kind==="schema"?i.length<1?null:Ur(o.schema,i,a):i.length<1?o.definition:Ss(t,o.definition,i,a)}return null}
|
|
702
|
+
function Fe(t,e){let r={...t};if(Array.isArray(t.skipFields)){let n=t.skipFields.map(o=>ms(o,e)).filter(o=>o!==null&&o!==
|
|
689
703
|
"");n.length>0?r.skipFields=n:delete r.skipFields}if(H(t.skipParams)){let n={};for(let[o,s]of Object.entries(t.skipParams)){
|
|
690
|
-
let i=
|
|
704
|
+
let i=ms(o,e);i===null||i===""||T(n,i,s)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var Sd=Object.
|
|
691
705
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
692
706
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
693
707
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
694
|
-
function
|
|
695
|
-
", ")}.`)}function
|
|
696
|
-
must define ${r} as a boolean.`)}function
|
|
697
|
-
eration "${t}" must be an object.`);return
|
|
698
|
-
pplyDefaults"),
|
|
708
|
+
function ws(t,e,r,n){let o=e[r];if(!n.includes(o))throw new Error(`Operation "${t}" must define ${r} as one of: ${n.join(
|
|
709
|
+
", ")}.`)}function Fr(t,e,r,n=!0){let o=e[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
|
|
710
|
+
must define ${r} as a boolean.`)}function xd(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
|
|
711
|
+
eration "${t}" must be an object.`);return ws(t,e,"targetFields",["schema","input"]),Fr(t,e,"enforceRequired"),Fr(t,e,"a\
|
|
712
|
+
pplyDefaults"),ws(t,e,"outputFields",["validated","input"]),Fr(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
|
|
699
713
|
targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
|
|
700
|
-
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function
|
|
714
|
+
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function Td(t={}){if(typeof t!="object"||t===null||Array.
|
|
701
715
|
isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[r,n]of Object.entries(
|
|
702
|
-
|
|
703
|
-
null);for(let[r,n]of Object.entries(t))
|
|
704
|
-
delete e.mode,e}var
|
|
705
|
-
|
|
716
|
+
Sd))T(e,r,n);for(let[r,n]of Object.entries(t))T(e,r,xd(r,n));return Object.freeze(e)}function ys(t){let e=Object.create(
|
|
717
|
+
null);for(let[r,n]of Object.entries(t))T(e,r,n);return Object.freeze(e)}function bd(t){let e={...t};return delete e.operation,
|
|
718
|
+
delete e.mode,e}var $e=class{constructor(e,r,n,o={}){this.structure=e,this.types=ys(r),this.validators=ys(n),this.operations=
|
|
719
|
+
Td(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could not be cas\
|
|
706
720
|
t to the required type.")}_paramError(e,r,n,o={}){let s=new Error(n);return s.errorObject={field:e,code:r,message:n,params:o},
|
|
707
721
|
s}_paramToBeSkipped(e,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(e))}_fieldToBeSkipped(e,r){
|
|
708
|
-
return Array.isArray(r.skipFields)&&r.skipFields.includes(e)}_mergeErrors(e,r){for(let[n,o]of Object.entries(r))
|
|
709
|
-
let r={};return
|
|
722
|
+
return Array.isArray(r.skipFields)&&r.skipFields.includes(e)}_mergeErrors(e,r){for(let[n,o]of Object.entries(r))T(e,n,o)}_singleErrorMap(e){
|
|
723
|
+
let r={};return T(r,e.field,e),r}_assertSupportedOptions(e={}){if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("U\
|
|
710
724
|
nsupported validation option `onlyObjectValues`. Call `patch()` directly.");if(Object.hasOwn(e,"mode"))throw new Error("\
|
|
711
725
|
Unsupported validation option `mode`. Call `validateWith()` or an operation method directly.");if(Object.hasOwn(e,"opera\
|
|
712
726
|
tion"))throw new Error("Unsupported validation option `operation`. Call `validateWith()` or an operation method directly\
|
|
@@ -717,136 +731,136 @@ isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(e,r){if(!H(r))thro
|
|
|
717
731
|
ct input.`)}_resolvePathValidationRequest(e={}){let r=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
|
|
718
732
|
hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
719
733
|
oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
|
|
720
|
-
return{operationName:r,operation:n,validationOptions:
|
|
734
|
+
return{operationName:r,operation:n,validationOptions:bd(e)}}_buildOperationResult(e,r,n){let o={};for(let s of n.outputFieldNames){
|
|
721
735
|
if(!Object.hasOwn(this.structure,s))continue;let i=n.isFieldPresent(s);(r[s]!==void 0||i&&e[s]===null||n.defaultedFields.
|
|
722
|
-
has(s))&&(!i&&!n.defaultedFields.has(s)||
|
|
723
|
-
return
|
|
736
|
+
has(s))&&(!i&&!n.defaultedFields.has(s)||T(o,s,r[s]))}return o}_resolveObjectFieldMode(e,r){return kt(e,r)}_resolveArrayItemsConfig(e,r){
|
|
737
|
+
return Pt(e,r)}_resolveObjectValuesConfig(e,r){return Ze(e,r)}_buildArrayItemSettings(e,r){return e.type==="object"&&Object.
|
|
724
738
|
hasOwn(e,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(e,r,n,o,s,i,a,c){let d=e.
|
|
725
739
|
nullable===!0||a.nullable===!0,u=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
|
|
726
|
-
`No casting function for type: ${e.type}`);let
|
|
740
|
+
`No casting function for type: ${e.type}`);let f=this.types[e.type];if(r===null)return d?(T(o,s,null),{errors:{},shouldContinue:!1}):
|
|
727
741
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
728
|
-
if(r===""&&u)return
|
|
742
|
+
if(r===""&&u)return T(o,s,null),{errors:{},shouldContinue:!1};let l={schema:this,definition:e,value:r,fieldName:n,object:o,
|
|
729
743
|
objectBeforeCast:i,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
730
|
-
nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(
|
|
731
|
-
n,
|
|
732
|
-
s,
|
|
733
|
-
errors:{},context:
|
|
744
|
+
nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(g,S,x)=>{throw this._paramError(
|
|
745
|
+
n,g,S,x)}};try{let g=f(l);if(fs(g))throw new Error(`Type handler for "${e.type}" must be synchronous.`);g!==void 0&&(T(o,
|
|
746
|
+
s,g),l.value=g)}catch(g){if(g.errorObject)return{errors:this._singleErrorMap(g.errorObject),shouldContinue:!1};throw g}return{
|
|
747
|
+
errors:{},context:l,shouldContinue:!0}}_runFieldValidators(e,r,n,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
|
|
734
748
|
_paramToBeSkipped(a,i.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
|
|
735
|
-
a,s.parameterValue=e[a];let d=c(s);if(
|
|
736
|
-
(
|
|
749
|
+
a,s.parameterValue=e[a];let d=c(s);if(fs(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
|
|
750
|
+
(T(n,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,r,n,o,s,i,a,c){
|
|
737
751
|
let d=this._castValue(e,r,n,o,s,i,a,c);if(Object.keys(d.errors).length>0)return d.errors;if(!d.shouldContinue)return{};let{
|
|
738
|
-
context:u}=d,
|
|
752
|
+
context:u}=d,f=this._validateNestedValue(e,n,o,s,a,c);return Object.keys(f).length>0?f:(u.value=o[s],this._runFieldValidators(
|
|
739
753
|
e,n,o,s,u,a))}_normalizeDefault(e,r,{fieldPath:n,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
|
|
740
|
-
let d={...o};return
|
|
754
|
+
let d={...o};return T(d,s,r),{errors:this._normalizeAndValidateValue(e,r,n,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,r,n,o,s,i){
|
|
741
755
|
if(e.type==="object"){let c=this._resolveObjectFieldMode(r,e);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
742
756
|
c,r,n,o,s,i):c.kind==="map"?this._validateObjectValues(r,n,o,c.valuesConfig,s,i):{}}if(e.type!=="array")return{};let a=this.
|
|
743
757
|
_resolveArrayItemsConfig(r,e);return a?this._validateArrayItems(r,n,o,a,s,i):{}}_validateNestedObjectSchema(e,r,n,o,s,i){
|
|
744
758
|
let a=n[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
|
|
745
|
-
i.operationName,i.operation,c,
|
|
746
|
-
a,e.schema,d.validatedObject):d.validatedObject),
|
|
747
|
-
entries(e))Object.hasOwn(r.structure,o)&&
|
|
748
|
-
keys(e)){if(!Object.hasOwn(r.structure,s)){
|
|
749
|
-
n))Object.hasOwn(o,s)||
|
|
750
|
-
keys(a)){let
|
|
751
|
-
_mergeErrors(d,this._singleErrorMap(this._typeError(
|
|
752
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,
|
|
753
|
-
d,
|
|
754
|
-
definition,i));this._mergeErrors(d,
|
|
755
|
-
c.length;u++){let
|
|
756
|
-
this._mergeErrors(d,this._singleErrorMap(this._typeError(
|
|
757
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[u],
|
|
758
|
-
d,
|
|
759
|
-
o.definition,i));this._mergeErrors(d,
|
|
759
|
+
i.operationName,i.operation,c,Fe(s,r));return T(n,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
760
|
+
a,e.schema,d.validatedObject):d.validatedObject),Le(d.errors,r)}_extractKnownObjectFields(e,r){let n={};for(let[o,s]of Object.
|
|
761
|
+
entries(e))Object.hasOwn(r.structure,o)&&T(n,o,s);return n}_mergeKnownAndPassthroughObjectFields(e,r,n){let o={};for(let s of Object.
|
|
762
|
+
keys(e)){if(!Object.hasOwn(r.structure,s)){T(o,s,e[s]);continue}Object.hasOwn(n,s)&&T(o,s,n[s])}for(let[s,i]of Object.entries(
|
|
763
|
+
n))Object.hasOwn(o,s)||T(o,s,i);return o}_validateObjectValues(e,r,n,o,s,i){let a=r[n],c={...a},d={};T(r,n,c);for(let u of Object.
|
|
764
|
+
keys(a)){let f=xe(e,u);if(this._fieldToBeSkipped(f,s))continue;let l=c[u];if(l===void 0){i.rejectExplicitUndefined?this.
|
|
765
|
+
_mergeErrors(d,this._singleErrorMap(this._typeError(f).errorObject)):delete c[u];continue}if(o.kind==="schema"){let S=o.
|
|
766
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,l,Fe(s,f));T(c,u,S.validatedObject),this._mergeErrors(
|
|
767
|
+
d,Le(S.errors,f));continue}let g=this._normalizeAndValidateValue(o.definition,l,f,c,u,a,s,this._buildArrayItemSettings(o.
|
|
768
|
+
definition,i));this._mergeErrors(d,g)}return d}_validateArrayItems(e,r,n,o,s,i){let a=r[n],c=a.slice(),d={};T(r,n,c);for(let u=0;u<
|
|
769
|
+
c.length;u++){let f=xe(e,u);if(this._fieldToBeSkipped(f,s))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){i.rejectExplicitUndefined?
|
|
770
|
+
this._mergeErrors(d,this._singleErrorMap(this._typeError(f).errorObject)):delete c[u];continue}if(o.kind==="schema"){let g=o.
|
|
771
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[u],Fe(s,f));T(c,u,g.validatedObject),this._mergeErrors(
|
|
772
|
+
d,Le(g.errors,f));continue}let l=this._normalizeAndValidateValue(o.definition,c[u],f,c,u,a,s,this._buildArrayItemSettings(
|
|
773
|
+
o.definition,i));this._mergeErrors(d,l)}return d}_validateField(e,r,n,o,s){if(!Object.hasOwn(this.structure,e))return{};
|
|
760
774
|
let i=this.structure[e];if(this._fieldToBeSkipped(e,o))return{};let a=s.isFieldPresent(e),c=r[e],d=c===void 0;return s.enforceRequired&&
|
|
761
775
|
i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
|
|
762
776
|
Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
|
|
763
777
|
_normalizeAndValidateValue(i,c,e,n,e,r,o,s):{}}_validateWithOperation(e,r,n,o){this._assertSupportedOptions(o);let s={},
|
|
764
|
-
i={...n},a=this._buildOperationSettings(e,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||
|
|
778
|
+
i={...n},a=this._buildOperationSettings(e,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||T(s,c,{field:c,
|
|
765
779
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
|
|
766
780
|
c,n,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
767
781
|
this.structure[c].defaultTo!==void 0){let d=this.structure[c],u=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
|
|
768
|
-
|
|
769
|
-
_mergeErrors(s,
|
|
770
|
-
_buildOperationResult(n,i,a),errors:s}}_validateSelectedTree(e,r,n,o,s=""){let i={},a={};for(let c of
|
|
771
|
-
let d=
|
|
782
|
+
f=this._normalizeDefault(d,u,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
783
|
+
_mergeErrors(s,f.errors),Object.keys(f.errors).length>0)continue;T(i,c,f.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
784
|
+
_buildOperationResult(n,i,a),errors:s}}_validateSelectedTree(e,r,n,o,s=""){let i={},a={};for(let c of vs(Object.keys(e))){
|
|
785
|
+
let d=Is(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let u=this._validateSelectedField(
|
|
772
786
|
c,e[c],r,a,n,o,d);this._mergeErrors(i,u)}return{validatedObject:a,errors:i}}_validateSelectedField(e,r,n,o,s,i,a){if(!Object.
|
|
773
|
-
hasOwn(this.structure,e))return{};let c=this.structure[e],d=r.self===!0,u=
|
|
774
|
-
let
|
|
775
|
-
a)&&this._mergeErrors(
|
|
776
|
-
c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,
|
|
777
|
-
currentObject:o,containerKey:e,objectBeforeCast:n,options:s,settings:i});this._mergeErrors(
|
|
778
|
-
length===0&&
|
|
779
|
-
a).errorObject):{};let
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
787
|
+
hasOwn(this.structure,e))return{};let c=this.structure[e],d=r.self===!0,u=hs(r);if(this._fieldToBeSkipped(a,s))return{};
|
|
788
|
+
let f=Object.hasOwn(n,e),l=n[e],g={};if(!f){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
|
|
789
|
+
a)&&this._mergeErrors(g,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
|
|
790
|
+
c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,D=this._normalizeDefault(c,P,{fieldPath:a,
|
|
791
|
+
currentObject:o,containerKey:e,objectBeforeCast:n,options:s,settings:i});this._mergeErrors(g,D.errors),Object.keys(D.errors).
|
|
792
|
+
length===0&&T(o,e,D.value)}return g}if(l===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
793
|
+
a).errorObject):{};let S={[e]:l};if(d){let P=this._normalizeAndValidateValue(c,l,a,S,e,n,s,i);return Object.hasOwn(S,e)&&
|
|
794
|
+
S[e]!==void 0?T(o,e,S[e]):S[e]===null&&T(o,e,null),P}if(!u)return{};let x=this._castValue(c,l,a,S,e,n,s,i);if(Object.keys(
|
|
795
|
+
x.errors).length>0)return x.errors;if(!x.shouldContinue)return{};let O=this._validateSelectedDescendants(c,r.children,a,
|
|
796
|
+
S,e,s,i);return Dt(S[e])&&T(o,e,S[e]),O}_validateSelectedDescendants(e,r,n,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
783
797
|
n,e);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let d=o[s];if(!H(
|
|
784
|
-
d))return{};let u=c.schema._validateSelectedTree(r,d,
|
|
785
|
-
|
|
798
|
+
d))return{};let u=c.schema._validateSelectedTree(r,d,Fe(i,n),{...a,defaultedFields:new Set});return T(o,s,u.validatedObject),
|
|
799
|
+
Le(u.errors,n)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(n,e);if(!c)throw new Error(`Schema path "${n}" d\
|
|
786
800
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,s,c,r,i,a)}throw new Error(
|
|
787
801
|
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(e,r,n,o,s,i,a){let c=[],d=r[n],
|
|
788
|
-
u={};
|
|
789
|
-
id because array segments must use numeric indexes.`);let
|
|
790
|
-
|
|
791
|
-
if(P===void 0){
|
|
792
|
-
let
|
|
793
|
-
this._mergeErrors(u,
|
|
794
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
795
|
-
this._mergeErrors(u,
|
|
796
|
-
o.definition,P,
|
|
797
|
-
continue}if(!
|
|
798
|
-
u
|
|
799
|
-
i,
|
|
802
|
+
u={};T(r,n,c);for(let f of vs(Object.keys(s))){if(!/^[0-9]+$/.test(f))throw new Error(`Schema path "${xe(e,f)}" is inval\
|
|
803
|
+
id because array segments must use numeric indexes.`);let l=Number(f),g=xe(e,l),S=s[f],x=S.self===!0,O=hs(S);if(this._fieldToBeSkipped(
|
|
804
|
+
g,i))continue;if(!Object.hasOwn(d,l)){x&&a.rejectExplicitUndefined&&T(u,g,this._typeError(g).errorObject);continue}let P=d[l];
|
|
805
|
+
if(P===void 0){x&&a.rejectExplicitUndefined&&T(u,g,this._typeError(g).errorObject);continue}if(o.kind==="schema"){if(x){
|
|
806
|
+
let G=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,Fe(i,g));Dt(G.validatedObject)&&T(c,l,G.validatedObject),
|
|
807
|
+
this._mergeErrors(u,Le(G.errors,g));continue}if(!O)continue;let V=o.schema._validateSelectedTree(S.children,P,Fe(i,g),{...a,
|
|
808
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Dt(V.validatedObject)&&T(c,l,V.validatedObject),
|
|
809
|
+
this._mergeErrors(u,Le(V.errors,g));continue}let D=this._buildArrayItemSettings(o.definition,a),N=[P];if(x){let V=this._normalizeAndValidateValue(
|
|
810
|
+
o.definition,P,g,N,0,d,i,D);Object.hasOwn(N,0)&&N[0]!==void 0?T(c,l,N[0]):N[0]===null&&T(c,l,null),this._mergeErrors(u,V);
|
|
811
|
+
continue}if(!O)continue;let F=this._castValue(o.definition,P,g,N,0,d,i,D);if(Object.keys(F.errors).length>0){this._mergeErrors(
|
|
812
|
+
u,F.errors);continue}if(!F.shouldContinue)continue;let q=this._validateSelectedDescendants(o.definition,S.children,g,N,0,
|
|
813
|
+
i,D);Dt(N[0])&&T(c,l,N[0]),this._mergeErrors(u,q)}return u}validateWith(e,r,n={}){if(!Object.hasOwn(this.operations,e))throw new Error(
|
|
800
814
|
`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,r),this._validateWithOperation(
|
|
801
|
-
e,o,r,n)}validateAt(e,r,n={}){this._assertPlainObjectInput("validateAt",r);let o
|
|
802
|
-
_resolvePathValidationRequest(n),c=this._validateSelectedTree(
|
|
815
|
+
e,o,r,n)}validateAt(e,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=$r(e),{operationName:s,operation:i,validationOptions:a}=this.
|
|
816
|
+
_resolvePathValidationRequest(n),c=this._validateSelectedTree(gs([e]),r,a,this._buildOperationSettings(s,i,r));return{validatedValue:wd(
|
|
803
817
|
c.validatedObject,o),errors:c.errors}}validatePaths(e,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
804
818
|
isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
805
|
-
operation:s,validationOptions:i}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(
|
|
819
|
+
operation:s,validationOptions:i}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(gs(e),r,i,this.
|
|
806
820
|
_buildOperationSettings(o,s,r))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
|
|
807
821
|
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(r,n={})=>this.validateWith(e,r,n)}}toJsonSchema(e={}){
|
|
808
|
-
return
|
|
809
|
-
"")throw new Error("Field path must be a non-empty string.");let r=
|
|
810
|
-
let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):
|
|
811
|
-
let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&
|
|
812
|
-
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=
|
|
813
|
-
|
|
814
|
-
"object"||typeof t=="function")&&typeof t.then=="function"}function
|
|
822
|
+
return ps(this,e)}getFieldDefinitions(){return Lr(this.structure)}getFieldDefinition(e){if(typeof e!="string"||e.trim()===
|
|
823
|
+
"")throw new Error("Field path must be a non-empty string.");let r=Ur(this,$r(e.trim()));return r===null?null:Lr(r)}getFieldMessages(e){
|
|
824
|
+
let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):Lr(r.messages)}cleanup(e,r){
|
|
825
|
+
let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&T(n,o,e[o]);return n}};var{parse:Bw,stringify:_d}=JSON,{keys:Hw}=Object,Ad=String,Cd="string";var xs="object",Ed=(t,e)=>e;var Ts=(t,e,r)=>{let n=Ad(e.push(r)-1);return t.set(r,n),n};var bs=(t,e,r)=>{let n=e&&typeof e===xs?(u,f)=>u===""||-1<e.indexOf(u)?f:void 0:e||Ed,o=new Map,s=[],i=[],a=+Ts(o,s,n.call(
|
|
826
|
+
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=_d(s[a++],d,r);return"["+i.join(",")+"]";function d(u,f){if(c)return c=!c,
|
|
827
|
+
f;let l=n.call(this,u,f);switch(typeof l){case xs:if(l===null)return l;case Cd:return o.get(l)||Ts(o,s,l)}return l}};var Rd=new Set(["true","1","yes","y","on"]),Pd=new Set(["false","0","no","n","off"]);function kd(t){return t!==null&&(typeof t==
|
|
828
|
+
"object"||typeof t=="function")&&typeof t.then=="function"}function _s(t){if(typeof t=="number")return Number.isFinite(t)?
|
|
815
829
|
t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
|
|
816
|
-
if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function
|
|
830
|
+
if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function Br(t,e){if(Object.is(t,e))return!0;
|
|
817
831
|
if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
|
|
818
832
|
source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
|
|
819
|
-
e.length)return!1;for(let o=0;o<t.length;o++)if(!
|
|
833
|
+
e.length)return!1;for(let o=0;o<t.length;o++)if(!Br(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
|
|
820
834
|
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let r=Object.keys(t),n=Object.keys(
|
|
821
|
-
e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!
|
|
835
|
+
e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!Br(t[o],e[o]))return!1;return!0}var Md={install(t){
|
|
822
836
|
let{addType:e,addValidator:r}=t;e("none",n=>n.value),e("file",n=>{let o=n.value;o==null&&n.throwTypeError();let s=typeof o;
|
|
823
837
|
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),
|
|
824
838
|
e("string",n=>{let o=n.value;if(o==null)return"";let s=typeof o;if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();
|
|
825
|
-
return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),e("blob",n=>n.value),e("number",n=>{let o=
|
|
826
|
-
null&&n.throwTypeError(),o}),e("integer",n=>{let o=
|
|
827
|
-
o}),e("epochMilliseconds",n=>{let o=
|
|
828
|
-
n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=
|
|
829
|
-
value,o)||n.throwTypeError(),n.value}),e("date",n=>(
|
|
830
|
-
n.fieldName);return
|
|
839
|
+
return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),e("blob",n=>n.value),e("number",n=>{let o=_s(n.value);return o===
|
|
840
|
+
null&&n.throwTypeError(),o}),e("integer",n=>{let o=_s(n.value);return(o===null||!Number.isInteger(o))&&n.throwTypeError(),
|
|
841
|
+
o}),e("epochMilliseconds",n=>{let o=Er(n.value,864e13);return o===null&&n.throwTypeError(),o}),e("epochSeconds",n=>{let o=Er(
|
|
842
|
+
n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=et(n.definition,n.fieldName);return os(n.
|
|
843
|
+
value,o)||n.throwTypeError(),n.value}),e("date",n=>(rs(n.value)||n.throwTypeError(),n.value)),e("time",n=>{let o=et(n.definition,
|
|
844
|
+
n.fieldName);return ns(n.value,o)||n.throwTypeError(),n.value}),e("array",n=>n.definition.type==="array"&&!Array.isArray(
|
|
831
845
|
n.value)?[n.value]:n.value),e("object",n=>(H(n.value)||n.throwTypeError(),n.value)),e("serialize",n=>{try{return JSON.stringify(
|
|
832
|
-
n.value)}catch{try{return
|
|
846
|
+
n.value)}catch{try{return bs(n.value)}catch{n.throwTypeError()}}}),e("boolean",n=>{if(typeof n.value=="boolean")return n.
|
|
833
847
|
value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
|
|
834
848
|
"bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
|
|
835
849
|
n.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
836
|
-
i=n.value.trim().toLowerCase(),a=new Set([...
|
|
850
|
+
i=n.value.trim().toLowerCase(),a=new Set([...Pd,o]),c=new Set([...Rd,s]);if(a.has(i))return!1;if(c.has(i))return!0}n.throwTypeError()}),
|
|
837
851
|
e("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
|
|
838
852
|
value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
|
|
839
853
|
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let s=Number(o);return Number.isSafeInteger(
|
|
840
854
|
s)||n.throwTypeError(),s}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.
|
|
841
855
|
toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGTH",`Length must be at least ${n.parameterValue}\
|
|
842
|
-
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&
|
|
856
|
+
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&De(n.definition)&&
|
|
843
857
|
typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("MIN_VALUE",`Value must be at least ${n.parameterValue}\
|
|
844
858
|
.`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.toString&&
|
|
845
859
|
n.value.toString().length>n.parameterValue&&n.throwParamError("MAX_LENGTH",`Length must be no more than ${n.parameterValue}\
|
|
846
|
-
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&
|
|
860
|
+
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&De(n.definition)&&
|
|
847
861
|
typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError("MAX_VALUE",`Value must be no more than ${n.parameterValue}\
|
|
848
862
|
.`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.isArray(n.parameterValue))throw new Error(`Enum for ${n.
|
|
849
|
-
fieldName} must be an array.`);n.parameterValue.some(s=>
|
|
863
|
+
fieldName} must be an array.`);n.parameterValue.some(s=>Br(s,n.value))||n.throwParamError("ENUM_VALUE","Value must match\
|
|
850
864
|
one of the allowed enum values.",{allowed:n.parameterValue})}),r("pattern",n=>{if(n.value===void 0||n.definition.type!==
|
|
851
865
|
"string"||typeof n.value!="string")return;let o=n.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
852
866
|
"string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${n.fieldName} must be a string or RegExp.`);s.test(n.value)||
|
|
@@ -854,7 +868,7 @@ n.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
854
868
|
parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
|
|
855
869
|
fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
|
|
856
870
|
"validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
|
|
857
|
-
let o=n.parameterValue(n.value,n.object,n);if(
|
|
871
|
+
let o=n.parameterValue(n.value,n.object,n);if(kd(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
|
|
858
872
|
ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
|
|
859
873
|
ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
|
|
860
874
|
th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
|
|
@@ -863,100 +877,100 @@ ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).leng
|
|
|
863
877
|
typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r(
|
|
864
878
|
"unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.
|
|
865
879
|
type!=="dateTime")throw new Error(`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r(
|
|
866
|
-
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},
|
|
867
|
-
unction")throw new Error(`Type handler for '${e}' must be a function.`);
|
|
868
|
-
on")throw new Error(`Validator handler for '${e}' must be a function.`);
|
|
869
|
-
for(let[r,n]of Object.entries(t))
|
|
870
|
-
gin must have an install method.");t.install(e)}function
|
|
871
|
-
freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
872
|
-
"object"&&typeof t!="function")return null;let e=
|
|
880
|
+
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},As=Md;var Os=new WeakMap,Rs=new WeakMap,Ps=Symbol.for("json-rest-schema.registry-metadata");function Nd(t,e,r){if(typeof r!="f\
|
|
881
|
+
unction")throw new Error(`Type handler for '${e}' must be a function.`);T(t,e,r)}function jd(t,e,r){if(typeof r!="functi\
|
|
882
|
+
on")throw new Error(`Validator handler for '${e}' must be a function.`);T(t,e,r)}function Ft(t={}){let e=Object.create(null);
|
|
883
|
+
for(let[r,n]of Object.entries(t))T(e,r,n);return e}function Dd(t,e){if(typeof t.install!="function")throw new Error("Plu\
|
|
884
|
+
gin must have an install method.");t.install(e)}function Cs(t,e,r){Os.set(t,e),Rs.set(t,r),Object.defineProperty(t,Ps,{value:Object.
|
|
885
|
+
freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function zd(t){if(!t||typeof t!=
|
|
886
|
+
"object"&&typeof t!="function")return null;let e=Os.get(t),r=Rs.get(t);if(e&&r)return{types:e,validators:r};let n=t[Ps];
|
|
873
887
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
874
888
|
typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
|
|
875
889
|
nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
|
|
876
|
-
validators}:null}function
|
|
877
|
-
for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!
|
|
878
|
-
conflicting ${r} "${n}".`);
|
|
879
|
-
e)};let o=Object.create(null),s=Object.create(null);for(let i of n){let a=
|
|
880
|
-
ust be schema instances or schema factories created by json-rest-schema.");
|
|
881
|
-
ator")}return{types:o,validators:s}}function
|
|
882
|
-
let c=new
|
|
883
|
-
|
|
884
|
-
{types:a.types,validators:a.validators,installCore:!1})},r&&s.use(
|
|
885
|
-
t))
|
|
890
|
+
validators}:null}function Ld(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Fd(t,e){return t===e}function Es(t,e,r){
|
|
891
|
+
for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!Fd(t[n],o))throw new Error(`Cannot merge schema factories with\
|
|
892
|
+
conflicting ${r} "${n}".`);T(t,n,o)}}function $d(t,e,r){let n=Ld(r).filter(Boolean);if(n.length<1)return{types:Ft(t),validators:Ft(
|
|
893
|
+
e)};let o=Object.create(null),s=Object.create(null);for(let i of n){let a=zd(i);if(!a)throw new Error("Factory sources m\
|
|
894
|
+
ust be schema instances or schema factories created by json-rest-schema.");Es(o,a.types,"type"),Es(s,a.validators,"valid\
|
|
895
|
+
ator")}return{types:o,validators:s}}function ks({types:t={},validators:e={},installCore:r=!0}={}){let n=Ft(t),o=Ft(e),s=(i,a={})=>{
|
|
896
|
+
let c=new $e(i,n,o,a.operations);return Cs(c,n,o),c};return Cs(s,n,o),s.addType=(i,a)=>{Nd(n,i,a)},s.addValidator=(i,a)=>{
|
|
897
|
+
jd(o,i,a)},s.use=i=>{Dd(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{let a=$d(n,o,i);return ks(
|
|
898
|
+
{types:a.types,validators:a.validators,installCore:!1})},r&&s.use(As),s}var ne=ks({installCore:!0});function Te(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let r of Object.getOwnPropertyNames(
|
|
899
|
+
t))Te(t[r],e);return Object.freeze(t)}var py=Object.freeze({REQUIRED:"required",TYPE_CAST_FAILED:"default",NOT_NULLABLE:"default",MIN_LENGTH:"minLength",MAX_LENGTH:"\
|
|
886
900
|
maxLength",MIN_VALUE:"min",MAX_VALUE:"max",PATTERN:"pattern",ENUM_VALUE:"enum",FIELD_NOT_ALLOWED:"additionalProperties",
|
|
887
|
-
CUSTOM_VALIDATOR_FAILED:"default"});var
|
|
888
|
-
mode:"patch"});var
|
|
889
|
-
{...
|
|
890
|
-
ng."}}}),mode:"patch"});var
|
|
901
|
+
CUSTOM_VALIDATOR_FAILED:"default"});var qd=ne({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Bd=Object.freeze({schema:qd,
|
|
902
|
+
mode:"patch"});var Ns=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),Hd=Object.freeze(
|
|
903
|
+
{...Ns,nullable:!0});var js="^[1-9][0-9]*$",Hr=Te({type:"string",minLength:1,pattern:js});var Gd=Te({...Hr,nullable:!0});var Wd=Te({schema:ne({recordId:{...Hr,required:!0,messages:{pattern:"Record id must be a canonical positive integer stri\
|
|
904
|
+
ng."}}}),mode:"patch"});var lI=Object.freeze([/^(?:let me|i(?:'|’)ll|i will|i(?:'|’)m going to|i am going to)\s+(?:(?:first|now|quickly)\s+)*(?:analy[sz]e|call|check|confirm|do|execute|fetch|find|inspect|investigate|load|look up|open|prepare|query|read|retrieve|review|run|search|summarize|test|try|use|verify)\b/iu,
|
|
891
905
|
/^(?:analy[sz]ing|calling|checking|confirming|executing|fetching|finding|inspecting|investigating|loading|looking up|opening|preparing|querying|reading|retrieving|reviewing|running|searching|summarizing|testing|trying|using|verifying)\b/iu,
|
|
892
|
-
/^(?:one moment|please wait)\b/iu]);var
|
|
893
|
-
toolName:{type:"string",maxLength:256,required:!1},arguments:{type:"string",maxLength:
|
|
906
|
+
/^(?:one moment|please wait)\b/iu]);var Zd=256*1024,xI=ne({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:16e3,required:!1},
|
|
907
|
+
toolName:{type:"string",maxLength:256,required:!1},arguments:{type:"string",maxLength:Zd,required:!1}});var kI=16*1024*1024;var jI=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var AS=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
894
908
|
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
895
|
-
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var
|
|
909
|
+
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var YS=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
896
910
|
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
897
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var
|
|
898
|
-
if(!
|
|
899
|
-
freeze({});if(!
|
|
900
|
-
for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!
|
|
901
|
-
must be a JavaScript identifier.`);let a=
|
|
902
|
-
" more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function
|
|
911
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var ex=2*1024*1024,tx=32*1024*1024,rx=2*1024*1024;var zs=/^[a-z][a-z0-9_.-]*$/u,au=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function Ls(t,e){let r=String(t||"").trim().toLowerCase();
|
|
912
|
+
if(!zs.test(r))throw new TypeError(`${e} must match ${zs.toString()}.`);return r}function Wr(t,e){if(t==null)return Object.
|
|
913
|
+
freeze({});if(!Qe(t))throw new TypeError(`${e} must be an object mapping local names to capability ids.`);let r={},n=new Set;
|
|
914
|
+
for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!au.test(i))throw new TypeError(`${e} local name "${i}" \
|
|
915
|
+
must be a JavaScript identifier.`);let a=Ls(s,`${e}.${i}`);if(n.has(a))throw new TypeError(`${e} declares capability "${a}\
|
|
916
|
+
" more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function cu(t){let e=new Map;for(let[r,n]of Object.entries(t))
|
|
903
917
|
for(let o of Object.keys(n)){if(e.has(o))throw new TypeError(`Provider local name "${o}" is declared by both ${e.get(o)}\
|
|
904
|
-
and ${r}.`);e.set(o,r)}}function
|
|
905
|
-
be a function when provided.`);return t}function
|
|
906
|
-
shutdown:i=null}={}){let a=
|
|
907
|
-
{requires:c,optional:d,provides:u});let
|
|
908
|
-
freeze({id:a,requires:c,optional:d,provides:u,setup:
|
|
909
|
-
tration is closed after the first payload is resolved.");let u=
|
|
918
|
+
and ${r}.`);e.set(o,r)}}function Kr(t,e){if(t==null)return null;if(typeof t!="function")throw new TypeError(`${e} must \
|
|
919
|
+
be a function when provided.`);return t}function Ut({id:t,requires:e={},optional:r={},provides:n={},setup:o,boot:s=null,
|
|
920
|
+
shutdown:i=null}={}){let a=Ls(t,"Provider id"),c=Wr(e,`${a}.requires`),d=Wr(r,`${a}.optional`),u=Wr(n,`${a}.provides`);cu(
|
|
921
|
+
{requires:c,optional:d,provides:u});let f=Kr(o,`${a}.setup`);if(!f)throw new TypeError(`${a}.setup is required.`);return Object.
|
|
922
|
+
freeze({id:a,requires:c,optional:d,provides:u,setup:f,boot:Kr(s,`${a}.boot`),shutdown:Kr(i,`${a}.shutdown`)})}var Fs="public";function $s(){let t=[],e=new Set,r=!1;function n({id:a,order:c=0,contribute:d}={}){if(r)throw new Error("Bootstrap regis\
|
|
923
|
+
tration is closed after the first payload is resolved.");let u=U(a);if(!u)throw new TypeError("Bootstrap contributor id \
|
|
910
924
|
is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${u}" requires contribute().`);if(e.has(
|
|
911
925
|
u))throw new Error(`Bootstrap contributor "${u}" is duplicated.`);return e.add(u),t.push(Object.freeze({id:u,order:Number.
|
|
912
|
-
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((u,
|
|
913
|
-
(u,
|
|
914
|
-
freeze({...
|
|
926
|
+
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((u,f)=>({entry:u,index:f})).sort(
|
|
927
|
+
(u,f)=>u.entry.order-f.entry.order||u.index-f.index).map(({entry:u})=>u);for(let u of d){let f=await u.contribute(Object.
|
|
928
|
+
freeze({...Qe(a)?a:{},payload:Object.freeze({...c})}));c={...c,...Qe(f)?f:{}}}return Object.freeze(c)}function s(){return Object.
|
|
915
929
|
freeze({sealed:r,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:n,resolve:o,diagnostics:s});
|
|
916
|
-
return i}var
|
|
917
|
-
http:t}){let e
|
|
918
|
-
pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await e.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:e}}});function
|
|
930
|
+
return i}var du=Ut({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({
|
|
931
|
+
http:t}){let e=$s();return t.router.register("GET","/api/bootstrap",{auth:Fs,meta:{tags:["bootstrap"],summary:"Resolve a\
|
|
932
|
+
pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await e.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:e}}});function uu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Event listener must be an object.");let e=String(
|
|
919
933
|
t.id||"").trim();if(!e)throw new TypeError("Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(
|
|
920
934
|
`Event listener "${e}" requires handle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event \
|
|
921
935
|
listener "${e}" matches must be a function when provided.`);return Object.freeze({id:e,handle:t.handle,matches:typeof t.
|
|
922
|
-
matches=="function"?t.matches:null})}function
|
|
936
|
+
matches=="function"?t.matches:null})}function lu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pub\
|
|
923
937
|
lished event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is req\
|
|
924
|
-
uired.");return Object.freeze({...t,type:e})}function
|
|
925
|
-
`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function n(i){let a=
|
|
938
|
+
uired.");return Object.freeze({...t,type:e})}function Us(){let t=[],e=new Set;function r(i){let a=uu(i);if(e.has(a.id))throw new Error(
|
|
939
|
+
`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function n(i){let a=lu(i);for(let c of t)
|
|
926
940
|
c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.freeze(t.
|
|
927
|
-
map(i=>i.id))})}let s=Object.freeze({register:r,publish:n,diagnostics:o});return s}var
|
|
928
|
-
events:"runtime.events"},setup(){return{events:
|
|
929
|
-
execute:"assistant_action_execute"}),
|
|
941
|
+
map(i=>i.id))})}let s=Object.freeze({register:r,publish:n,diagnostics:o});return s}var pu=Ut({id:"runtime.events",provides:{
|
|
942
|
+
events:"runtime.events"},setup(){return{events:Us()}}});var qs=20,qx=32*1024,Bx=48*1024,Jr=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
943
|
+
execute:"assistant_action_execute"}),Xr=Object.freeze({type:"object",additionalProperties:!0}),hu=Object.freeze({type:"o\
|
|
930
944
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
931
945
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
932
946
|
ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
|
|
933
|
-
limit:{type:"integer",minimum:1,maximum:
|
|
934
|
-
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:
|
|
947
|
+
limit:{type:"integer",minimum:1,maximum:qs,description:"Maximum compact matches to return."}}}),mu=Object.freeze({type:"\
|
|
948
|
+
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:qs,items:{
|
|
935
949
|
type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
|
|
936
950
|
tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
|
|
937
|
-
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),
|
|
938
|
-
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),
|
|
951
|
+
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),gu=Object.freeze({type:"object",additionalProperties:!1,required:[
|
|
952
|
+
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),vu=Object.
|
|
939
953
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
|
|
940
954
|
chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
|
|
941
|
-
string"},inputSchema:
|
|
942
|
-
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:
|
|
955
|
+
string"},inputSchema:Xr,outputSchema:Xr}}),wu=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
956
|
+
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Xr}}),yu=Object.
|
|
943
957
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
944
|
-
g"},version:{type:"integer",minimum:1},result:{}}}),
|
|
958
|
+
g"},version:{type:"integer",minimum:1},result:{}}}),Bs=Object.freeze([Object.freeze({name:Jr.search,description:"Discove\
|
|
945
959
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
946
960
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
947
|
-
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:
|
|
948
|
-
outputSchema:
|
|
949
|
-
e action before executing it.",parameters:
|
|
950
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:
|
|
961
|
+
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:hu,
|
|
962
|
+
outputSchema:mu}),Object.freeze({name:Jr.contract,description:"Load the exact input and output contract for one availabl\
|
|
963
|
+
e action before executing it.",parameters:gu,outputSchema:vu}),Object.freeze({name:Jr.execute,description:"Execute one a\
|
|
964
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:wu,outputSchema:yu})]);var ST=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var _T=256*1024;var AT=2*1024*1024;var CT=Bs.map(({name:t,description:e,parameters:r})=>({type:"function",function:{name:t,description:e,parameters:r}}));function Yr({resolveConversation:t,readInstructions:e}={}){if(typeof t!="function")throw new TypeError("Conversation hoo\
|
|
951
965
|
k delivery requires a binding resolver.");return async function(n){if(n.scope!=="session")return{kind:"unclaimed"};let o=await t(
|
|
952
966
|
n);if(!o)return{kind:"unclaimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError(
|
|
953
967
|
"Unknown conversation instruction delivery mode.");if(typeof e!="function")throw new TypeError("Hook delivery requires a\
|
|
954
968
|
n instruction resolver.");let s=await e(o,n);if(typeof s!="string"||!s.trim())throw new TypeError("Managed conversation \
|
|
955
|
-
instructions are unavailable.");return{kind:"delivery",text:s}}}var
|
|
969
|
+
instructions are unavailable.");return{kind:"delivery",text:s}}}var Kb=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
956
970
|
allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
957
971
|
test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
|
|
958
|
-
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as
|
|
959
|
-
freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),
|
|
972
|
+
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as Fu}from"node:fs/promises";import Qr from"node:path";var $u=Object.freeze(["main","temporary"]),Gs=Object.
|
|
973
|
+
freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),Uu=64*1024,__=Object.freeze(["When\
|
|
960
974
|
user input is necessary, ask no more than three concise, high-impact questions at once.","Put multiple questions on sep\
|
|
961
975
|
arate lines as `[1] Question`, `[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answe\
|
|
962
976
|
rs:` and a short bullet list directly beneath its own question, before the next one; never collect several questions' an\
|
|
@@ -970,99 +984,96 @@ Possible answers:
|
|
|
970
984
|
[2] Tell the main agent before changes?
|
|
971
985
|
Possible answers:
|
|
972
986
|
- Yes, tell main first
|
|
973
|
-
- No, proceed independently`]),
|
|
987
|
+
- No, proceed independently`]),A_=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
|
|
974
988
|
start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
|
|
975
989
|
nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
|
|
976
990
|
ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
|
|
977
991
|
words. If unconfigured, ask which existing accounts (email/login/user ID) represent admin and other required roles, and \
|
|
978
992
|
the default. Reuse prior answers; wait for their choices before configuring access. Never infer admin rights from names \
|
|
979
|
-
or the Vibe64 viewer.","Offer
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
{
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
993
|
+
or the Vibe64 viewer.","Offer an application-owned adapter declared in the Outputs `#### Preview identity` block (`vibe6\
|
|
994
|
+
4-helper spec outputs` and `vibe64-helper spec preview-identity-command`), and save the named selectors the person gives\
|
|
995
|
+
or confirms with `vibe64-helper preview identities save` (`vibe64-helper spec preview-identities`); you may propose the\
|
|
996
|
+
m from existing app accounts, then verify each with `vibe64-helper preview browser identity <name>`. Use existing sessio\
|
|
997
|
+
ns/permissions, reject missing/disabled accounts, and disable the adapter without Vibe64\u2019s per-run enable flag and secre\
|
|
998
|
+
t. Do not create users, change roles, reset passwords or weaken production auth for import. Verify the selected account\u2019\
|
|
999
|
+
s actual Preview access; a saved selector is insufficient. If deferred/declined, explain access remains unconfigured and\
|
|
1000
|
+
continue independent setup work without repeated credential requests. Public/non-web apps need no adapter.","Use `vibe6\
|
|
1001
|
+
4-helper preview status`, `screenshot`, `logs`, and `browser eval` (Playwright code on stdin) for rendered inspection.",
|
|
1002
|
+
"The top Preview toolbar Stop and `vibe64-helper preview stop` stop this session's application and managed browser, not \
|
|
1003
|
+
chat or source. Status reports the saved stopped choice. A status read, screenshot, browser inspection, source edit or s\
|
|
1004
|
+
ession reopening is not permission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start.\
|
|
1005
|
+
Scoped browser tests restore the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-hel\
|
|
1006
|
+
per preview inspect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.got\
|
|
1007
|
+
o(new URL('/your-path', preview.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity\
|
|
1008
|
+
and is not a browser-navigation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper play\
|
|
1009
|
+
wright` only for an existing configured project suite; report a platform or project-test blocker rather than installing \
|
|
1010
|
+
another browser or changing its dependencies.","For browser evidence, batch related actions and assertions, return only \
|
|
1011
|
+
needed values and inspect relevant locators or regions; screenshot at meaningful visual checkpoints or failures, not aft\
|
|
1012
|
+
er every click. Reuse the managed browser when test isolation permits. Preserve required viewport, identity and security\
|
|
1013
|
+
checks; use existing automated cases for repeat verification.","For browser tests that write or reset data, inspect `vi\
|
|
1014
|
+
be64-helper preview targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target\
|
|
1015
|
+
<declared-test-target> test <suite arguments>` or `vibe64-helper playwright --target <declared-test-target> npm-run <sc\
|
|
1016
|
+
ript>`. Vibe64 starts that web target, waits for readiness, uses its declared application identity, and restores the pre\
|
|
1017
|
+
vious Preview when the command finishes or is cancelled; report restoration failures.","A target name is not proof of te\
|
|
1018
|
+
st isolation. Before running a destructive suite, the application must verify the server's actual test database and supp\
|
|
1019
|
+
ress real email, invoices, payments, and other external effects. Keep managed Env unchanged. The test launcher and its p\
|
|
1020
|
+
review-identity command must use the same database. Follow the application's declared test resources and never invent a \
|
|
1021
|
+
database name. Never spoof safety checks by changing only the test runner's environment.","If no suitable test target ex\
|
|
1022
|
+
ists, add one through the project's existing Outputs contract and application-owned test scripts within authorized scope\
|
|
1023
|
+
, keeping normal Preview as default. Validate the exact disposable database before resetting it, prepare fixtures before\
|
|
1024
|
+
reporting readiness, and make Playwright use the started target's URL, which Vibe64 supplies as PLAYWRIGHT_BASE_URL, wi\
|
|
1025
|
+
thout starting another server. If the required test resources or external-effect controls are missing, report that speci\
|
|
1026
|
+
fic blocker. Use `vibe64-helper preview ensure --target <id> --wait --json` only to deliberately select an interactive t\
|
|
1027
|
+
arget; it stays selected until changed. If browser startup is slow, measure migrations, fixtures and server startup befo\
|
|
1028
|
+
re retrying or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local arti\
|
|
1029
|
+
facts and preserve exit status. Report counts, duration, failed cases, actionable errors and artifact paths. Read only n\
|
|
1030
|
+
eeded failure excerpts, not full passing/JSON/TAP/request/trace/image output. Retain startup, resource and Preview-resto\
|
|
1031
|
+
ration errors even if tests pass, and trailing wrapper diagnostics separately from JSON. Do not rerun for output or rere\
|
|
1032
|
+
ad unchanged logs; inspect on new output, changed state or a concrete blocker.","Batch related browser tests in one mana\
|
|
1033
|
+
ged suite (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensure/r\
|
|
1034
|
+
estart or target changes during a suite or restoration. Wait on the original execution, including background runs, throu\
|
|
1035
|
+
gh cleanup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input or an imme\
|
|
1036
|
+
diate check); read-only status/logs stay available. Before live inspection, confirm `vibe64-helper playwright status` ha\
|
|
1037
|
+
s no active run and `vibe64-helper preview status` is ready on the restored target. To stop, read suite status then run \
|
|
1038
|
+
`vibe64-helper playwright cancel <run-id>`, which waits for cleanup/restoration; retry it if cleanup needs attention. Ne\
|
|
1039
|
+
ver kill individual test/Preview PIDs or change locks. Launcher exit alone does not prove tests stopped. Recheck current\
|
|
1040
|
+
status before reporting a busy blocker.","If a managed command reports kernel task denials or a resource incident, reta\
|
|
1041
|
+
in its diagnostic and incident ID when reporting the blocker. Ask the platform operator to inspect that resource evidenc\
|
|
1042
|
+
e before retrying; do not increase test timeouts or weaken assertions to work around a process/thread limit. A generic b\
|
|
1043
|
+
rowser timeout without resource evidence does not establish a platform cause."]),C_=Object.freeze(["Each managed shell c\
|
|
1044
|
+
ommand receives current development Env from Vibe64, including declared resource bindings; use them in ordinary commands\
|
|
1045
|
+
. Do not build environment injection or copy managed credentials into source. Resource provisioning and application migr\
|
|
1046
|
+
ations remain separate preparation steps.","Use `vibe64-helper env status [development|production|all]` to inspect confi\
|
|
1047
|
+
gured key names without revealing values.","Pipe an available value to `vibe64-helper env set <development|production> <\
|
|
1048
|
+
KEY> [--secret]`; never put values in arguments, logs, or repository files. Use empty stdin only when the user requested\
|
|
1049
|
+
an empty value.","Keep development and production values separate. Never invent credentials, copy a value between scope\
|
|
1050
|
+
s without explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected \
|
|
1051
|
+
scope and key names, never their values, and claim success only when the command succeeded.","Store a secret the applica\
|
|
1052
|
+
tion needs generated (such as an application key) by generating it with the framework's own generator and piping it to `\
|
|
1053
|
+
vibe64-helper env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file\
|
|
1054
|
+
from Env."]);function Zr(t=""){return String(t??"").trim()}function en(t,e){if(!t||typeof t!="object"||Array.isArray(t))
|
|
1055
|
+
throw new TypeError(`${e} must be an object.`);return t}function rt(t,e,r){let n=new Set(e),o=Object.keys(t).filter(s=>!n.
|
|
1056
|
+
has(s));if(o.length>0)throw new TypeError(`${r} contains unsupported fields: ${o.join(", ")}.`)}function qu(t){if(rt(t,[
|
|
1057
|
+
"conversationKind","scope","session","hostGuidance"],"Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!=
|
|
1058
|
+
"string"||Buffer.byteLength(t.hostGuidance,"utf8")>1024))throw new TypeError("Vibe64 host guidance must be bounded text \
|
|
1059
|
+
supplied by the host.");if(!$u.includes(t.conversationKind))throw new TypeError("Vibe64 session context has an unknown c\
|
|
1060
|
+
onversationKind.");let e=en(t.session,"Vibe64 session capabilities");rt(e,Gs,"Vibe64 session capabilities");let r=Object.
|
|
1061
|
+
fromEntries(Gs.map(n=>{if(typeof e[n]!="boolean")throw new TypeError(`Vibe64 session capability ${n} must be boolean.`);
|
|
1062
|
+
return[n,e[n]]}));return{conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:
|
|
1063
|
+
{},session:r}}function Bu(t){rt(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").
|
|
1064
|
+
trim();if(!e||e.length>Uu)throw new TypeError("Vibe64 ephemeral context requires bounded stableContext.");return{scope:"\
|
|
1065
|
+
ephemeral",stableContext:e}}function Hu(t){if(t.scope==="session")return qu(t);if(t.scope==="ephemeral")return Bu(t);throw new TypeError(
|
|
1066
|
+
"The Vibe64 driver supports session and ephemeral scopes only.")}async function Ws(t={},{readRegistry:e=Fu,workdir:r=""}={}){let n=en(t,"Vibe64 host resolver request");if(rt(n,["data","\
|
|
1053
1067
|
providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(n.scope))throw new TypeError(
|
|
1054
|
-
"The Vibe64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=
|
|
1055
|
-
resolver data");
|
|
1068
|
+
"The Vibe64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=en(n.data,"Vibe64 host \
|
|
1069
|
+
resolver data");rt(o,["registryPath"],"Vibe64 host resolver data");let s=Zr(o.registryPath);if(!Qr.isAbsolute(s))throw new TypeError(
|
|
1056
1070
|
"Vibe64 host resolver data requires an absolute registryPath.");let i=JSON.parse(await e(s,"utf8"));if(!Array.isArray(i?.
|
|
1057
|
-
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=
|
|
1071
|
+
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=Zr(n.providerSessionId);
|
|
1058
1072
|
if(n.parentSessionIds!==void 0&&(!Array.isArray(n.parentSessionIds)||n.parentSessionIds.length>32||n.parentSessionIds.some(
|
|
1059
|
-
|
|
1060
|
-
[]].filter(Boolean).map(
|
|
1061
|
-
u.workdir&&
|
|
1062
|
-
t directory.");
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
tion input exceeds 256 KiB.");var Hs=JSON.parse(Xr);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1067
|
-
process.stdout.write(await t(Hs))}else{let t=Gr({resolveConversation:async e=>await Bs(e,{workdir:process.cwd()})?{delivery:"\
|
|
1068
|
-
native"}:null});process.stdout.write(JSON.stringify(await t(Hs)))}
|
|
1073
|
+
l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[c,...n.parentSessionIds||
|
|
1074
|
+
[]].filter(Boolean).map(l=>a.find(g=>Zr(g?.upstreamSessionId)===l)).find(Boolean),f=u?.promptContext;if(!f)return null;if(r&&
|
|
1075
|
+
u.workdir&&Qr.resolve(r)!==Qr.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
1076
|
+
t directory.");return Hu(f)}var tn="";for await(let t of process.stdin)if(tn+=t,Buffer.byteLength(tn)>256*1024)throw new Error("Conversation instruc\
|
|
1077
|
+
tion input exceeds 256 KiB.");var Ks=JSON.parse(tn);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1078
|
+
process.stdout.write(await t(Ks))}else{let t=Yr({resolveConversation:async e=>await Ws(e,{workdir:process.cwd()})?{delivery:"\
|
|
1079
|
+
native"}:null});process.stdout.write(JSON.stringify(await t(Ks)))}
|