vibe64 0.1.32 → 0.1.34
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 +1717 -1648
- package/bin/server.js +81 -68
- package/bin/upgrade-state.js +5438 -5189
- package/dist/assets/{GithubBrowserTabs-2bEGbRAs.js → GithubBrowserTabs-DO5PHon-.js} +1 -1
- package/dist/assets/GithubMarkdown-BQ6MfCDJ.js +3 -0
- package/dist/assets/GithubMarkdown-U7-j-qNI.css +1 -0
- package/dist/assets/StudioErrorNotice-sQfmeR-z.js +1 -0
- package/dist/assets/VAlert-P256xaE0.js +1 -0
- package/dist/assets/VAutocomplete-BDb95qJX.js +1 -0
- package/dist/assets/VAvatar-9ilDR2r2.css +1 -0
- package/dist/assets/VAvatar-DPzqDH4r.js +1 -0
- package/dist/assets/VBtn-B2MBK2DL.js +1 -0
- package/dist/assets/VCard-mXy0k4aS.js +1 -0
- package/dist/assets/VCheckbox-C7A1ZW4D.js +1 -0
- package/dist/assets/VChip-CcI-Oo2J.js +1 -0
- package/dist/assets/VDialog-Bu3EfKb1.js +1 -0
- package/dist/assets/VDivider-BMEqUoAB.js +1 -0
- package/dist/assets/VExpansionPanels-Dgjrop0V.js +1 -0
- package/dist/assets/VMenu-C_x18lwb.js +1 -0
- package/dist/assets/VOverlay-CeMZurIN.js +1 -0
- package/dist/assets/VRadioGroup-CUu2-KIP.js +1 -0
- package/dist/assets/VRow-Cpw7OHQV.js +1 -0
- package/dist/assets/{VSelect-DY-ZuBJJ.js → VSelect-DL3HaA5m.js} +1 -1
- package/dist/assets/VSheet-DZWsu0kL.js +1 -0
- package/dist/assets/VSkeletonLoader-CttxM1tw.js +1 -0
- package/dist/assets/VSpacer-Dhmsvk4t.js +1 -0
- package/dist/assets/{VSwitch-Bm1bwl2V.js → VSwitch-BRHeDJkH.js} +1 -1
- package/dist/assets/VTextField-BR2eZeFT.js +1 -0
- package/dist/assets/VTextarea-DbqamXJd.js +1 -0
- package/dist/assets/Vibe64AsyncModuleState-Dx7YKRPp.js +1 -0
- package/dist/assets/Vibe64DashboardBackButton-DD9UR77P.css +1 -0
- package/dist/assets/Vibe64DashboardBackButton-yE6cyYg2.js +1 -0
- package/dist/assets/Vibe64DashboardPageHeader-BXQR00HK.js +1 -0
- package/dist/assets/Vibe64DashboardPageHeader-Gm1IvlHx.css +1 -0
- package/dist/assets/Vibe64DashboardShell-CuCVMhOc.js +1 -0
- package/dist/assets/Vibe64DashboardShell-MBkUHjs-.css +1 -0
- package/dist/assets/Vibe64DatabaseWorkspace-BONJdxBS.js +18 -0
- package/dist/assets/{Vibe64DatabaseWorkspace-C39Jvver.css → Vibe64DatabaseWorkspace-CR4pzzcf.css} +1 -1
- package/dist/assets/Vibe64OutputControls-DAAmA09l.js +8 -0
- package/dist/assets/{Vibe64OutputControls-CsZFv12r.css → Vibe64OutputControls-DPBsyDZM.css} +1 -1
- package/dist/assets/{Vibe64RepositoryWorkspace-ebUaYOU4.js → Vibe64RepositoryWorkspace-ByQlZbyO.js} +2 -2
- package/dist/assets/{Vibe64RepositoryWorkspace-Cqm6TOFk.css → Vibe64RepositoryWorkspace-CVHcT93M.css} +1 -1
- package/dist/assets/Vibe64SessionFiles-B0u9HKdF.js +107 -0
- package/dist/assets/Vibe64SessionFiles-NjOMVwPR.css +1 -0
- package/dist/assets/Vibe64TemporaryAiFixAction-BGlcrq4d.js +1 -0
- package/dist/assets/Vibe64UiStoryboardView-3WXph5bz.css +1 -0
- package/dist/assets/Vibe64UiStoryboardView-Brlwdvqi.js +7 -0
- package/dist/assets/Vibe64UnavailableSessions-zwlWlcZD.js +1 -0
- package/dist/assets/_sessionId_-CvOkQbVy.js +1 -0
- package/dist/assets/{_sessionTool_-B39BIzzZ.js → _sessionTool_-Dwod5ns9.js} +1 -1
- package/dist/assets/_slug_-B31c15cc.css +1 -0
- package/dist/assets/_slug_-Dy35qLo1.js +1 -0
- package/dist/assets/access-BVu5XYm2.js +1 -0
- package/dist/assets/app-DRXCcv05.css +1 -0
- package/dist/assets/app-zt7HwQKT.js +1 -0
- package/dist/assets/assistantRouting-CwbwfkwB.js +3 -0
- package/dist/assets/{changes-ByjS7QGx.js → changes-olY8cnFK.js} +1 -1
- package/dist/assets/{client-C-tpoG6F.js → client-BrV4QPwG.js} +1 -1
- package/dist/assets/createSimpleFunctional-CZTGuNuR.js +1 -0
- package/dist/assets/dashboard-BnXD-H4R.js +1 -0
- package/dist/assets/definitions-DaOPIkyB.js +1 -0
- package/dist/assets/env-DJhnLOH7.css +1 -0
- package/dist/assets/env-DN0vW4EI.js +1 -0
- package/dist/assets/{error-DFKtZBJ8.js → error-DgrgRbJJ.js} +1 -1
- package/dist/assets/{error-DE4zo8Lk.js → error-Dug56can.js} +1 -1
- package/dist/assets/health-7oIQODer.css +1 -0
- package/dist/assets/health-Z6m96GDr.js +1 -0
- package/dist/assets/history-BOwbCRQP.css +1 -0
- package/dist/assets/history-BxlpB-YH.js +1 -0
- package/dist/assets/incoming-BOxRVlOM.js +2 -0
- package/dist/assets/incoming-DWDrmxyH.css +1 -0
- package/dist/assets/index-BUq-MczL.js +86 -0
- package/dist/assets/{index-D4MsP3dq.css → index-DtmBqE3h.css} +1 -1
- package/dist/assets/{integrations-B4txOZfY.js → integrations-BFltGDVI.js} +1 -1
- package/dist/assets/issues-1iS5zoed.js +1 -0
- package/dist/assets/issues-XnpGgdmn.css +1 -0
- package/dist/assets/layout-BkWVNT37.js +1 -0
- package/dist/assets/lazy-NHSwD9FS.js +1 -0
- package/dist/assets/mdi-C54lQ0i_.js +1 -0
- package/dist/assets/{pages-BW2l8fNe.js → pages-DuMgH61T.js} +1 -1
- package/dist/assets/{placement-JxzrmUR3.js → placement-CwTqWLQH.js} +1 -1
- package/dist/assets/placement-DLsU3pCW.js +1 -0
- package/dist/assets/pull-requests-BJOwNL4k.js +1 -0
- package/dist/assets/pull-requests-CdbhyFOv.css +1 -0
- package/dist/assets/{repository-BTC3lkrh.js → repository-JWLVST3D.js} +1 -1
- package/dist/assets/{VAvatar-CAFvgSUo.js → ripple-BVltMmyV.js} +2 -2
- package/dist/assets/ripple-DqhAt1Ze.css +1 -0
- package/dist/assets/runtime-core.esm-bundler-DGXg_mpN.js +3 -0
- package/dist/assets/{session-CG-TUCJt.css → session-5qADMzDP.css} +1 -1
- package/dist/assets/session-C5Nj8Dlq.js +1 -0
- package/dist/assets/settings-BopLnpB0.css +1 -0
- package/dist/assets/settings-c273Ikrm.js +1 -0
- package/dist/assets/ssrBoot-Rlh6kLbD.js +1 -0
- package/dist/assets/{studioGateApi-C0GvzVlt.js → studioGateApi-DhA9IJGZ.js} +1 -1
- package/dist/assets/{studioUrls-CIab-Axb.js → studioUrls-Dj8rXeXO.js} +1 -1
- package/dist/assets/{useApi-BPuI6ZR9-Dr8wK_Co.js → useApi-BPuI6ZR9-CFWU1m37.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-CVZx2Rtm.js +1 -0
- package/dist/assets/useCommand-DWuxfAV0.js +1 -0
- package/dist/assets/useEndpointResource-MWVNfmMa.js +1 -0
- package/dist/assets/{usePaths-DVTieF_G.js → usePaths-Db88-HOm.js} +1 -1
- package/dist/assets/{useUiFeedback-Tzi-PRlX.js → useUiFeedback-0FqKuZRP.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-8cKh1eDm.js +1 -0
- package/dist/assets/useVibe64DatabaseTools-BcRG1s3i.js +1 -0
- package/dist/assets/useVibe64LearningMode-Bl0dGdCh.js +28 -0
- package/dist/assets/useVibe64LearningMode-C3PcXdVg.css +1 -0
- package/dist/assets/useVibe64ProjectScope-DOEVkBqX.js +1 -0
- package/dist/assets/useVibe64SessionData-DFTyLzci.js +1 -0
- package/dist/assets/useVibe64SessionSelection-j9lsllx4.js +1 -0
- package/dist/assets/useVibe64SystemGraph-tNkIwSBQ.js +1 -0
- package/dist/assets/{useVibe64Terminal-C2XJ9Y1K.js → useVibe64Terminal-BPnN25WH.js} +1 -1
- package/dist/assets/vibe64AssistantHost-DdE_-lZF.js +1 -0
- package/dist/assets/vibe64LessonDashboard-DlKYjisq.js +1 -0
- package/dist/assets/vibe64ProjectScope.local-DqT6e5un.js +1 -0
- package/dist/assets/vibe64RepositoryRealtime-DXk0Jai3.js +1 -0
- package/dist/assets/vibe64SessionFocus-OJ2toBd9.css +1 -0
- package/dist/assets/vibe64SessionFocus-kqPOPaOH.js +1 -0
- package/dist/assets/{vibe64SessionInfo-D8l22MFm.js → vibe64SessionInfo-BHxtTrLX.js} +1 -1
- package/dist/assets/vibe64SessionToolDefinitions-NfLd1HZI.js +1 -0
- package/dist/assets/vue-flow-core-BlVEnES8.js +26 -0
- package/dist/index.html +51 -48
- package/docs/colleague-usage/account-profile-and-appearance.md +29 -0
- package/docs/colleague-usage/ai-accounts-and-routing.md +23 -4
- package/docs/colleague-usage/ai-balance-and-allowance.md +4 -0
- package/docs/colleague-usage/architecture-explanations.md +99 -0
- package/docs/colleague-usage/auto-workflow.md +49 -11
- package/docs/colleague-usage/coding-agent-failures.md +94 -0
- package/docs/colleague-usage/coding-agent-goal-pause.md +110 -0
- package/docs/colleague-usage/coding-agent-goals.md +140 -38
- package/docs/colleague-usage/coding-agent-history.md +20 -2
- package/docs/colleague-usage/coding-agent-recovery.md +136 -0
- package/docs/colleague-usage/coding-agents.md +138 -150
- package/docs/colleague-usage/colleague-recovery.md +28 -5
- package/docs/colleague-usage/colleague-upgrade-recovery.md +4 -0
- package/docs/colleague-usage/colleague-watches.md +84 -0
- package/docs/colleague-usage/colleague.md +18 -34
- package/docs/colleague-usage/connected-contributions.md +196 -0
- package/docs/colleague-usage/connected-projects.md +196 -0
- package/docs/colleague-usage/conversation-context.md +67 -1
- package/docs/colleague-usage/dashboard-navigation.md +79 -5
- package/docs/colleague-usage/database.md +11 -0
- package/docs/colleague-usage/developing-vibe64.md +137 -0
- package/docs/colleague-usage/development-copies.md +20 -0
- package/docs/colleague-usage/development-env.md +34 -0
- package/docs/colleague-usage/file-interfaces.md +156 -0
- package/docs/colleague-usage/github-work.md +88 -1
- package/docs/colleague-usage/health-checks.md +32 -0
- package/docs/colleague-usage/incoming-changes.md +94 -0
- package/docs/colleague-usage/learning-chat-retention.md +11 -2
- package/docs/colleague-usage/learning-code-questions.md +55 -0
- package/docs/colleague-usage/learning-course-catalogue.md +118 -0
- package/docs/colleague-usage/learning-diagrams-and-voice.md +97 -0
- package/docs/colleague-usage/learning-history.md +17 -9
- package/docs/colleague-usage/learning-lesson-watch.md +95 -0
- package/docs/colleague-usage/learning-mode-ui.md +187 -85
- package/docs/colleague-usage/learning-native-session.md +12 -10
- package/docs/colleague-usage/learning-practical-exercises.md +71 -0
- package/docs/colleague-usage/learning-practical-gestures.md +18 -1
- package/docs/colleague-usage/learning-practice-projects.md +55 -4
- package/docs/colleague-usage/learning-session-creation.md +7 -7
- package/docs/colleague-usage/learning-teacher-guide.md +52 -0
- package/docs/colleague-usage/learning-with-colleague.md +59 -80
- package/docs/colleague-usage/lesson-authoring.md +12 -4
- package/docs/colleague-usage/lesson-practical-assessment.md +3 -1
- package/docs/colleague-usage/managed-app-access.md +6 -0
- package/docs/colleague-usage/message-delivery-recovery.md +56 -0
- package/docs/colleague-usage/plans.md +14 -7
- package/docs/colleague-usage/preview-browser-checks.md +61 -0
- package/docs/colleague-usage/preview-lesson-presentation.md +56 -0
- package/docs/colleague-usage/preview-starting-application.md +92 -0
- package/docs/colleague-usage/preview.md +70 -96
- package/docs/colleague-usage/project-architecture.md +229 -0
- package/docs/colleague-usage/project-language-tools.md +31 -0
- package/docs/colleague-usage/project-messages.md +106 -0
- package/docs/colleague-usage/project-settings.md +22 -0
- package/docs/colleague-usage/project-setup.md +29 -2
- package/docs/colleague-usage/session-terminal.md +42 -0
- package/docs/colleague-usage/sessions.md +122 -52
- package/docs/colleague-usage/teaching-content.md +12 -6
- package/docs/colleague-usage/temporary-chat-context.md +29 -0
- package/docs/colleague-usage/temporary-chats.md +95 -2
- package/docs/colleague-usage/voice-chat.md +10 -43
- package/docs/colleague-usage/voice-face-and-speaking-voice.md +73 -0
- package/docs/colleague-usage/workspace-preparation.md +89 -0
- package/docs/training-content.md +208 -7
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/README.md +29 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/resource-crud-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-core/package.json +1 -0
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +280 -272
- package/node_modules/@local/vibe64-genesis/README.md +15 -0
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +879 -1225
- package/node_modules/@local/vibe64-genesis/package.json +2 -1
- package/node_modules/@local/vibe64-genesis/src/server/index.js +496 -418
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +165 -146
- package/node_modules/@local/vibe64-runtime/src/server/agentSessionCommandHook.js +8 -8
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +128 -129
- package/node_modules/@local/vibe64-system-graph/README.md +136 -6
- package/node_modules/@local/vibe64-terminals/package.json +3 -0
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1527 -1326
- package/node_modules/@local/vibe64-training/package.json +6 -1
- package/node_modules/@local/vibe64-voice/package.json +1 -0
- package/package.json +16 -16
- package/server.bundle.mjs +42853 -40268
- package/dist/assets/StudioErrorNotice-Ccjvcn9C.js +0 -1
- package/dist/assets/VAlert-B7ciJKQL.js +0 -1
- package/dist/assets/VAutocomplete-QjMk5d_j.js +0 -1
- package/dist/assets/VAvatar-nHaK192T.css +0 -1
- package/dist/assets/VBtn-Kl_qcBsy.js +0 -1
- package/dist/assets/VCard-nrJPeo91.js +0 -1
- package/dist/assets/VCheckbox-DTRAWOIf.js +0 -1
- package/dist/assets/VChip-Dfs5jX0f.js +0 -1
- package/dist/assets/VDialog-Dt1VjJg1.js +0 -1
- package/dist/assets/VDivider-DFsS0OTx.js +0 -1
- package/dist/assets/VExpansionPanels-CYKU0cAr.js +0 -1
- package/dist/assets/VMenu-BLxobsuU.js +0 -1
- package/dist/assets/VOverlay-BvFVZKNS.js +0 -1
- package/dist/assets/VRadioGroup-DzQzpCfg.js +0 -1
- package/dist/assets/VRow-BR2RMCM1.js +0 -1
- package/dist/assets/VSheet-BA95RNmA.js +0 -1
- package/dist/assets/VSkeletonLoader-hpJqr0HL.js +0 -1
- package/dist/assets/VSpacer-B1l1hVvU.js +0 -1
- package/dist/assets/VTextField-CA_p3N4d.js +0 -1
- package/dist/assets/VTextarea-NyCqY4h5.js +0 -1
- package/dist/assets/Vibe64AsyncModuleState-DEFlqJ97.js +0 -1
- package/dist/assets/Vibe64DashboardShell-BNv2I-P8.js +0 -1
- package/dist/assets/Vibe64DashboardShell-w20wNTGW.css +0 -1
- package/dist/assets/Vibe64DatabaseWorkspace-CuY5lN1o.js +0 -43
- package/dist/assets/Vibe64OutputControls-D2JuYlYU.js +0 -8
- package/dist/assets/Vibe64SessionFiles-C-rWehq_.js +0 -34
- package/dist/assets/Vibe64SessionFiles-Dsr6KQNP.css +0 -1
- package/dist/assets/Vibe64SubsystemsView-BvdU_o6H.css +0 -1
- package/dist/assets/Vibe64SubsystemsView-DJCjSzQM.js +0 -1
- package/dist/assets/Vibe64SystemWorldView-B91ioQaO.js +0 -4312
- package/dist/assets/Vibe64SystemWorldView-BXiQ7_Qb.css +0 -1
- package/dist/assets/Vibe64UnavailableSessions-OvnoD3ZB.js +0 -1
- package/dist/assets/_sessionId_-JTvMh54L.js +0 -1
- package/dist/assets/_slug_-DP_heCDa.js +0 -1
- package/dist/assets/_slug_-DmBZGb0q.css +0 -1
- package/dist/assets/access-C8GQIS19.js +0 -1
- package/dist/assets/app-B83lF61Y.js +0 -1
- package/dist/assets/app-ByLIQ3SB.css +0 -1
- package/dist/assets/assistantRouting-TDtryU6o.js +0 -1
- package/dist/assets/createSimpleFunctional-DPIT6zsT.js +0 -1
- package/dist/assets/dashboard-CWGFPojJ.js +0 -1
- package/dist/assets/definitions-BeLcvOW3.js +0 -1
- package/dist/assets/display-BLmcO-5p.js +0 -1
- package/dist/assets/env-7bqFyF_E.css +0 -1
- package/dist/assets/env-BVwxNL8M.js +0 -1
- package/dist/assets/health-BzNhp7r8.js +0 -1
- package/dist/assets/health-DoHTXTGx.css +0 -1
- package/dist/assets/history-BPeZGofK.js +0 -1
- package/dist/assets/history-iMQxp5AR.css +0 -1
- package/dist/assets/httpClient-BaaZuFvF.js +0 -1
- package/dist/assets/index-5sKwLHOH.js +0 -86
- package/dist/assets/issues-DCEhGlfn.css +0 -1
- package/dist/assets/issues-wby50y9b.js +0 -3
- package/dist/assets/layout-YCn17mK1.js +0 -1
- package/dist/assets/lazy-CvQfXeLg.js +0 -1
- package/dist/assets/mdi-C31_SZp-.js +0 -1
- package/dist/assets/placement-C4R2t6rl.js +0 -1
- package/dist/assets/pull-requests-BNK6mq2u.css +0 -1
- package/dist/assets/pull-requests-lNQAigaC.js +0 -1
- package/dist/assets/runtime-core.esm-bundler-DMrccYS5.js +0 -3
- package/dist/assets/session-D38nzG41.js +0 -1
- package/dist/assets/settings-CFyUJ_kR.js +0 -1
- package/dist/assets/settings-vWsAEoE9.css +0 -1
- package/dist/assets/useArchivedVibe64Sessions-C2DSq2Z4.js +0 -1
- package/dist/assets/useCommand-BzThFLYP.js +0 -1
- package/dist/assets/useEndpointResource-C2KD4Ub_.js +0 -1
- package/dist/assets/useVibe64ConversationLog-CMUlXJtU.js +0 -1
- package/dist/assets/useVibe64DatabaseTools-DBcKhm6B.js +0 -1
- package/dist/assets/useVibe64LearningMode-BPRWM5Rp.js +0 -28
- package/dist/assets/useVibe64LearningMode-PJUv0O25.css +0 -1
- package/dist/assets/useVibe64SessionData-CdtJbAIx.js +0 -1
- package/dist/assets/useVibe64SessionSelection-aR0f6xVT.js +0 -1
- package/dist/assets/useVibe64SystemGraph-DeTPBn0e.js +0 -1
- package/dist/assets/vibe64AssistantHost-Dgyz4TrT.js +0 -1
- package/dist/assets/vibe64ProjectScope.local-GOSMVDRi.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-t5Al8BlU.js +0 -1
- package/dist/assets/vibe64SessionFocus-CcN6Grgw.js +0 -1
- package/dist/assets/vibe64SessionFocus-ChabllPA.css +0 -1
- package/dist/assets/vibe64SessionToolDefinitions-BaO1DEup.js +0 -1
- /package/dist/assets/{vibe64RepositoryRealtime-D_mq1dFE.css → Vibe64TemporaryAiFixAction-D_mq1dFE.css} +0 -0
|
@@ -1,32 +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
|
-
|
|
6
|
-
|
|
7
|
-
exports={BINARY_TYPES:wo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:yo,
|
|
3
|
+
var Vs=Object.create;var Zr=Object.defineProperty;var Gs=Object.getOwnPropertyDescriptor;var Ws=Object.getOwnPropertyNames;var Ks=Object.getPrototypeOf,Js=Object.prototype.hasOwnProperty;var N=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){
|
|
4
|
+
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var G=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Xs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ws(e))!Js.call(t,o)&&o!==r&&Zr(t,o,{get:()=>e[o],
|
|
5
|
+
enumerable:!(n=Gs(e,o))||n.enumerable});return t};var ae=(t,e,r)=>(r=t!=null?Vs(Ks(t)):{},Xs(e||!t||!t.__esModule?Zr(r,"default",{value:t,enumerable:!0}):r,t));var te=G((dl,on)=>{"use strict";var rn=["nodebuffer","arraybuffer","fragments"],nn=typeof Blob<"u";nn&&rn.push("blob");on.
|
|
6
|
+
exports={BINARY_TYPES:rn,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:nn,
|
|
8
7
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
9
|
-
"websocket"),NOOP:()=>{}}});var
|
|
10
|
-
if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let o=0;o<t.length;o++){let
|
|
11
|
-
return n<e?new
|
|
12
|
-
for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function
|
|
13
|
-
t.byteOffset+t.length)}function
|
|
14
|
-
e=new
|
|
15
|
-
{concat:
|
|
16
|
-
exports.mask=function(e,r,n,o,
|
|
17
|
-
r):t.unmask(e,r)}}catch{}});var
|
|
18
|
-
this[
|
|
19
|
-
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[
|
|
20
|
-
from([0,0,255,255]),
|
|
21
|
-
|
|
8
|
+
"websocket"),NOOP:()=>{}}});var $e=G((ul,nt)=>{"use strict";var{EMPTY_BUFFER:Qs}=te(),Ft=Buffer[Symbol.species];function Zs(t,e){if(t.length===0)return Qs;
|
|
9
|
+
if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let o=0;o<t.length;o++){let s=t[o];r.set(s,n),n+=s.length}
|
|
10
|
+
return n<e?new Ft(r.buffer,r.byteOffset,n):r}function sn(t,e,r,n,o){for(let s=0;s<o;s++)r[n+s]=t[s]^e[s&3]}function an(t,e){
|
|
11
|
+
for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function ei(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
|
|
12
|
+
t.byteOffset+t.length)}function $t(t){if($t.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
|
|
13
|
+
e=new Ft(t):ArrayBuffer.isView(t)?e=new Ft(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),$t.readOnly=!1),e}nt.exports=
|
|
14
|
+
{concat:Zs,mask:sn,toArrayBuffer:ei,toBuffer:$t,unmask:an};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=N("bufferutil");nt.
|
|
15
|
+
exports.mask=function(e,r,n,o,s){s<48?sn(e,r,n,o,s):t.mask(e,r,n,o,s)},nt.exports.unmask=function(e,r){e.length<32?an(e,
|
|
16
|
+
r):t.unmask(e,r)}}catch{}});var un=G((ll,dn)=>{"use strict";var cn=Symbol("kDone"),Ut=Symbol("kRun"),qt=class{constructor(e){this[cn]=()=>{this.pending--,
|
|
17
|
+
this[Ut]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ut]()}[Ut](){if(this.pending!==
|
|
18
|
+
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[cn])}}};dn.exports=qt});var Ce=G((pl,hn)=>{"use strict";var Ue=N("zlib"),ln=$e(),ti=un(),{kStatusCode:pn}=te(),ri=Buffer[Symbol.species],ni=Buffer.
|
|
19
|
+
from([0,0,255,255]),st=Symbol("permessage-deflate"),re=Symbol("total-length"),_e=Symbol("callback"),ce=Symbol("buffers"),
|
|
20
|
+
Ae=Symbol("error"),ot,Bt=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this.
|
|
22
21
|
_options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=
|
|
23
|
-
null,this._inflate=null,this.params=null
|
|
24
|
-
10
|
|
22
|
+
null,this._inflate=null,this.params=null,!ot){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
|
|
23
|
+
10;ot=new ti(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
|
|
25
24
|
(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.
|
|
26
25
|
serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=
|
|
27
26
|
this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=
|
|
28
27
|
this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this.
|
|
29
|
-
_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[_e];this._deflate.close(),this._deflate=
|
|
30
29
|
null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,
|
|
31
30
|
n=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===
|
|
32
31
|
!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits==
|
|
@@ -40,58 +39,58 @@ typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=th
|
|
|
40
39
|
_options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.
|
|
41
40
|
clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){
|
|
42
41
|
return e.forEach(r=>{Object.keys(r).forEach(n=>{let o=r[n];if(o.length>1)throw new Error(`Parameter "${n}" must have onl\
|
|
43
|
-
y a single value`);if(o=o[0],n==="client_max_window_bits"){if(o!==!0){let
|
|
44
|
-
`Invalid value for parameter "${n}": ${o}`);o=
|
|
45
|
-
"${n}": ${o}`)}else if(n==="server_max_window_bits"){let
|
|
46
|
-
nvalid value for parameter "${n}": ${o}`);o=
|
|
42
|
+
y a single value`);if(o=o[0],n==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(
|
|
43
|
+
`Invalid value for parameter "${n}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter\
|
|
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
|
+
nvalid value for parameter "${n}": ${o}`);o=s}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){
|
|
47
46
|
if(o!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else throw new Error(`Unknown parameter "${n}"`);
|
|
48
|
-
r[n]=o})}),e}decompress(e,r,n){
|
|
49
|
-
e,r,(i
|
|
50
|
-
window_bits`,
|
|
51
|
-
{...this._options.zlibInflateOptions,windowBits:
|
|
52
|
-
_inflate.on("error",
|
|
53
|
-
this._inflate.flush(()=>{let
|
|
54
|
-
this._inflate[
|
|
55
|
-
(this._inflate[
|
|
56
|
-
let o=this._isServer?"server":"client";if(!this._deflate){let
|
|
57
|
-
|
|
58
|
-
this._deflate[
|
|
59
|
-
flush(
|
|
60
|
-
buffer,
|
|
61
|
-
_context_takeover`]&&this._deflate.reset(),n(null,
|
|
62
|
-
function
|
|
63
|
-
new RangeError("Max payload size exceeded"),this[
|
|
64
|
-
"data",
|
|
65
|
-
t)}});var
|
|
47
|
+
r[n]=o})}),e}decompress(e,r,n){ot.add(o=>{this._decompress(e,r,(s,i)=>{o(),n(s,i)})})}compress(e,r,n){ot.add(o=>{this._compress(
|
|
48
|
+
e,r,(s,i)=>{o(),n(s,i)})})}_decompress(e,r,n){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_\
|
|
49
|
+
window_bits`,i=typeof this.params[s]!="number"?Ue.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ue.createInflateRaw(
|
|
50
|
+
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[st]=this,this._inflate[re]=0,this._inflate[ce]=[],this.
|
|
51
|
+
_inflate.on("error",si),this._inflate.on("data",fn)}this._inflate[_e]=n,this._inflate.write(e),r&&this._inflate.write(ni),
|
|
52
|
+
this._inflate.flush(()=>{let s=this._inflate[Ae];if(s){this._inflate.close(),this._inflate=null,n(s);return}let i=ln.concat(
|
|
53
|
+
this._inflate[ce],this._inflate[re]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
|
|
54
|
+
(this._inflate[re]=0,this._inflate[ce]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){
|
|
55
|
+
let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
|
|
56
|
+
Ue.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ue.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
|
|
57
|
+
this._deflate[re]=0,this._deflate[ce]=[],this._deflate.on("data",oi)}this._deflate[_e]=n,this._deflate.write(e),this._deflate.
|
|
58
|
+
flush(Ue.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=ln.concat(this._deflate[ce],this._deflate[re]);r&&(s=new ri(s.
|
|
59
|
+
buffer,s.byteOffset,s.length-4)),this._deflate[_e]=null,this._deflate[re]=0,this._deflate[ce]=[],r&&this.params[`${o}_no\
|
|
60
|
+
_context_takeover`]&&this._deflate.reset(),n(null,s)})}};hn.exports=Bt;function oi(t){this[ce].push(t),this[re]+=t.length}
|
|
61
|
+
function fn(t){if(this[re]+=t.length,this[st]._maxPayload<1||this[re]<=this[st]._maxPayload){this[ce].push(t);return}this[Ae]=
|
|
62
|
+
new RangeError("Max payload size exceeded"),this[Ae].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ae][pn]=1009,this.removeListener(
|
|
63
|
+
"data",fn),this.reset()}function si(t){if(this[st]._inflate=null,this[Ae]){this[_e](this[Ae]);return}t[pn]=1007,this[_e](
|
|
64
|
+
t)}});var Ee=G((fl,it)=>{"use strict";var{isUtf8:mn}=N("buffer"),{hasBlob:ii}=te(),ai=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
66
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,
|
|
67
|
-
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
|
|
68
|
-
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 ci(t){return t>=
|
|
67
|
+
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Ht(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===
|
|
69
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){
|
|
70
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;
|
|
71
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]&
|
|
72
|
-
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 di(t){return ii&&typeof t=="o\
|
|
73
72
|
bject"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]===
|
|
74
|
-
"Blob"||t[Symbol.toStringTag]==="File")}
|
|
75
|
-
exports.isValidUTF8=function(t){return t.length<24?
|
|
76
|
-
|
|
77
|
-
{concat:
|
|
78
|
-
|
|
79
|
-
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||
|
|
73
|
+
"Blob"||t[Symbol.toStringTag]==="File")}it.exports={isBlob:di,isValidStatusCode:ci,isValidUTF8:Ht,tokenChars:ai};if(mn)it.
|
|
74
|
+
exports.isValidUTF8=function(t){return t.length<24?Ht(t):mn(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=N("utf-8-validate");
|
|
75
|
+
it.exports.isValidUTF8=function(e){return e.length<32?Ht(e):t(e)}}catch{}});var Jt=G((hl,xn)=>{"use strict";var{Writable:ui}=N("stream"),gn=Ce(),{BINARY_TYPES:li,EMPTY_BUFFER:vn,kStatusCode:pi,kWebSocket:fi}=te(),
|
|
76
|
+
{concat:Vt,toArrayBuffer:hi,unmask:mi}=$e(),{isValidStatusCode:gi,isValidUTF8:wn}=Ee(),at=Buffer[Symbol.species],X=0,yn=1,
|
|
77
|
+
In=2,Sn=3,Gt=4,Wt=5,ct=6,Kt=class extends ui{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
|
|
78
|
+
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||li[0],this._extensions=e.extensions||{},this._isServer=
|
|
80
79
|
!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|
|
|
81
|
-
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[
|
|
80
|
+
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[fi]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
|
|
82
81
|
!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=
|
|
83
|
-
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=
|
|
84
|
-
if(this._opcode===8&&this._state==
|
|
82
|
+
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=X}_write(e,r,n){
|
|
83
|
+
if(this._opcode===8&&this._state==X)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
|
|
85
84
|
n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=
|
|
86
85
|
e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this.
|
|
87
|
-
_buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new
|
|
88
|
-
e,n.length-e),new
|
|
89
|
-
r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new
|
|
90
|
-
e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case
|
|
91
|
-
break;case
|
|
92
|
-
this.getData(e);break;case
|
|
86
|
+
_buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new at(n.buffer,n.byteOffset+
|
|
87
|
+
e,n.length-e),new at(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],o=r.length-e;e>=n.length?
|
|
88
|
+
r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new at(n.buffer,n.byteOffset+
|
|
89
|
+
e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case X:this.getInfo(e);
|
|
90
|
+
break;case yn:this.getPayloadLength16(e);break;case In:this.getPayloadLength64(e);break;case Sn:this.getMask();break;case Gt:
|
|
91
|
+
this.getData(e);break;case Wt:case ct:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
|
|
93
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\
|
|
94
|
-
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[gn.extensionName]){
|
|
95
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]&
|
|
96
95
|
128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let o=this.createError(RangeError,"\
|
|
97
96
|
RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,
|
|
@@ -105,1209 +104,757 @@ LOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcod
|
|
|
105
104
|
ID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,
|
|
106
105
|
this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(
|
|
107
106
|
o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");
|
|
108
|
-
e(o);return}this._payloadLength===126?this._state=
|
|
107
|
+
e(o);return}this._payloadLength===126?this._state=yn:this._payloadLength===127?this._state=In:this.haveLength(e)}getPayloadLength16(e){
|
|
109
108
|
if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){
|
|
110
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.
|
|
111
110
|
createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD\
|
|
112
111
|
_LENGTH");e(o);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&
|
|
113
112
|
this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>
|
|
114
113
|
0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}
|
|
115
|
-
this._masked?this._state=
|
|
116
|
-
4),this._state=
|
|
114
|
+
this._masked?this._state=Sn:this._state=Gt}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
|
|
115
|
+
4),this._state=Gt}getData(e){let r=vn;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
|
|
117
116
|
return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
|
|
118
|
-
|
|
117
|
+
mi(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
|
|
119
118
|
let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}if(this.
|
|
120
|
-
_compressed){this._state=
|
|
121
|
-
push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[
|
|
122
|
-
o);if(
|
|
123
|
-
RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(
|
|
124
|
-
this.dataMessage(r),this._state===
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
"kByteLength"),_c=Buffer.alloc(4),Ht=8*1024,je,ot=Ht,de=0,Ac=1,Ec=2,$r=class t{constructor(e,r,n){this._extensions=r||{},
|
|
119
|
+
_compressed){this._state=Wt,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
|
|
120
|
+
push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[gn.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return r(
|
|
121
|
+
o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(
|
|
122
|
+
RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(i);return}this._fragments.push(s)}
|
|
123
|
+
this.dataMessage(r),this._state===X&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=X;return}let r=this._messageLength,
|
|
124
|
+
n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=
|
|
125
|
+
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Vt(n,r):this._binaryType==="arraybuffer"?o=hi(Vt(n,r)):this.
|
|
126
|
+
_binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=X):(this._state=
|
|
127
|
+
ct,setImmediate(()=>{this.emit("message",o,!0),this._state=X,this.startLoop(e)}))}else{let o=Vt(n,r);if(!this._skipUTF8Validation&&
|
|
128
|
+
!wn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===Wt||
|
|
129
|
+
this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=X):(this._state=ct,setImmediate(()=>{this.emit("mess\
|
|
130
|
+
age",o,!1),this._state=X,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
|
|
131
|
+
emit("conclude",1005,vn),this.end();else{let n=e.readUInt16BE(0);if(!gi(n)){let s=this.createError(RangeError,`invalid s\
|
|
132
|
+
tatus code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(s);return}let o=new at(e.buffer,e.byteOffset+2,e.length-2);if(!this.
|
|
133
|
+
_skipUTF8Validation&&!wn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(s);return}
|
|
134
|
+
this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=X;return}this._allowSynchronousEvents?(this.emit(this._opcode===
|
|
135
|
+
9?"ping":"pong",e),this._state=X):(this._state=ct,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
|
|
136
|
+
X,this.startLoop(r)}))}createError(e,r,n,o,s){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:
|
|
137
|
+
r);return Error.captureStackTrace(i,this.createError),i.code=s,i[pi]=o,i}};xn.exports=Kt});var Qt=G((gl,_n)=>{"use strict";var{Duplex:ml}=N("stream"),{randomFillSync:vi}=N("crypto"),{types:{isUint8Array:wi}}=N("util"),
|
|
138
|
+
Tn=Ce(),{EMPTY_BUFFER:yi,kWebSocket:Ii,NOOP:Si}=te(),{isBlob:Oe,isValidStatusCode:xi}=Ee(),{mask:bn,toBuffer:he}=$e(),Y=Symbol(
|
|
139
|
+
"kByteLength"),Ti=Buffer.alloc(4),dt=8*1024,me,Re=dt,Q=0,bi=1,_i=2,Xt=class t{constructor(e,r,n){this._extensions=r||{},
|
|
142
140
|
n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this.
|
|
143
|
-
_bufferedBytes=0,this._queue=[],this._state=
|
|
144
|
-
(n=r.maskBuffer||
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if(typeof e!="number"||!
|
|
151
|
-
length)
|
|
152
|
-
essage must not be greater than 123 bytes");if(
|
|
153
|
-
r,2);else if(
|
|
141
|
+
_bufferedBytes=0,this._queue=[],this._state=Q,this.onerror=Si,this[Ii]=void 0}static frame(e,r){let n,o=!1,s=2,i=!1;r.mask&&
|
|
142
|
+
(n=r.maskBuffer||Ti,r.generateMask?r.generateMask(n):(Re===dt&&(me===void 0&&(me=Buffer.alloc(dt)),vi(me,0,dt),Re=0),n[0]=
|
|
143
|
+
me[Re++],n[1]=me[Re++],n[2]=me[Re++],n[3]=me[Re++]),i=(n[0]|n[1]|n[2]|n[3])===0,s=6);let a;typeof e=="string"?(!r.mask||
|
|
144
|
+
i)&&r[Y]!==void 0?a=r[Y]:(e=Buffer.from(e),a=e.length):(a=e.length,o=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
|
|
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
|
+
c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),r.mask?(d[1]|=128,d[s-4]=n[0],d[s-3]=n[1],d[s-2]=
|
|
147
|
+
n[2],d[s-1]=n[3],i?[d,e]:o?(bn(e,n,d,s,a),[d]):(bn(e,n,e,0,a),[d,e])):[d,e]}close(e,r,n,o){let s;if(e===void 0)s=yi;else{
|
|
148
|
+
if(typeof e!="number"||!xi(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.
|
|
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
|
+
essage must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof r=="string")s.write(
|
|
151
|
+
r,2);else if(wi(r))s.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[Y]:s.
|
|
154
152
|
length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==
|
|
155
|
-
|
|
156
|
-
byteLength(e),
|
|
157
|
-
ust not be greater than 125 bytes");let
|
|
158
|
-
opcode:9,readOnly:
|
|
159
|
-
this._state!==
|
|
160
|
-
|
|
161
|
-
"The data size must not be greater than 125 bytes");let
|
|
162
|
-
_maskBuffer,opcode:10,readOnly:
|
|
163
|
-
e,!1,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
{enumerable:!0});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
let
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
"
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
_binaryType=Yo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Wt,this._closeTimer=
|
|
153
|
+
Q?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,r,n){let o,s;if(typeof e=="string"?(o=Buffer.
|
|
154
|
+
byteLength(e),s=!1):Oe(e)?(o=e.size,s=!1):(e=he(e),o=e.length,s=he.readOnly),o>125)throw new RangeError("The data size m\
|
|
155
|
+
ust not be greater than 125 bytes");let i={[Y]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,
|
|
156
|
+
opcode:9,readOnly:s,rsv1:!1};Oe(e)?this._state!==Q?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):
|
|
157
|
+
this._state!==Q?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}pong(e,r,n){let o,s;if(typeof e=="\
|
|
158
|
+
string"?(o=Buffer.byteLength(e),s=!1):Oe(e)?(o=e.size,s=!1):(e=he(e),o=e.length,s=he.readOnly),o>125)throw new RangeError(
|
|
159
|
+
"The data size must not be greater than 125 bytes");let i={[Y]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this.
|
|
160
|
+
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};Oe(e)?this._state!==Q?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(
|
|
161
|
+
e,!1,i,n):this._state!==Q?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}send(e,r,n){let o=this._extensions[Tn.
|
|
162
|
+
extensionName],s=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Oe(e)?(a=e.size,c=!1):(e=
|
|
163
|
+
he(e),a=e.length,c=he.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_contex\
|
|
164
|
+
t_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),r.fin&&(this._firstFragment=
|
|
165
|
+
!0);let d={[Y]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
|
|
166
|
+
Oe(e)?this._state!==Q?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this.
|
|
167
|
+
_state!==Q?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,r,n,o){this.
|
|
168
|
+
_bufferedBytes+=n[Y],this._state=_i,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was \
|
|
169
|
+
closed while the blob was being read");process.nextTick(Yt,this,a,o);return}this._bufferedBytes-=n[Y];let i=he(s);r?this.
|
|
170
|
+
dispatch(i,r,n,o):(this._state=Q,this.sendFrame(t.frame(i,n),o),this.dequeue())}).catch(s=>{process.nextTick(Ai,this,s,o)})}dispatch(e,r,n,o){
|
|
171
|
+
if(!r){this.sendFrame(t.frame(e,n),o);return}let s=this._extensions[Tn.extensionName];this._bufferedBytes+=n[Y],this._state=
|
|
172
|
+
bi,s.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
|
|
173
|
+
pressed");Yt(this,c,o);return}this._bufferedBytes-=n[Y],this._state=Q,n.readOnly=!1,this.sendFrame(t.frame(a,n),o),this.
|
|
174
|
+
dequeue()})}dequeue(){for(;this._state===Q&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Y],
|
|
175
|
+
Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Y],this._queue.push(e)}sendFrame(e,r){e.length===
|
|
176
|
+
2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],
|
|
177
|
+
r)}};_n.exports=Xt;function Yt(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let o=t._queue[n],s=o[o.
|
|
178
|
+
length-1];typeof s=="function"&&s(e)}}function Ai(t,e,r){Yt(t,e,r),t.onerror(e)}});var Nn=G((vl,Mn)=>{"use strict";var{kForOnEventAttribute:qe,kListener:Zt}=te(),An=Symbol("kCode"),Cn=Symbol("kData"),En=Symbol(
|
|
179
|
+
"kError"),On=Symbol("kMessage"),Rn=Symbol("kReason"),Pe=Symbol("kTarget"),Pn=Symbol("kType"),kn=Symbol("kWasClean"),ne=class{constructor(e){
|
|
180
|
+
this[Pe]=null,this[Pn]=e}get target(){return this[Pe]}get type(){return this[Pn]}};Object.defineProperty(ne.prototype,"t\
|
|
181
|
+
arget",{enumerable:!0});Object.defineProperty(ne.prototype,"type",{enumerable:!0});var ge=class extends ne{constructor(e,r={}){
|
|
182
|
+
super(e),this[An]=r.code===void 0?0:r.code,this[Rn]=r.reason===void 0?"":r.reason,this[kn]=r.wasClean===void 0?!1:r.wasClean}get code(){
|
|
183
|
+
return this[An]}get reason(){return this[Rn]}get wasClean(){return this[kn]}};Object.defineProperty(ge.prototype,"code",
|
|
184
|
+
{enumerable:!0});Object.defineProperty(ge.prototype,"reason",{enumerable:!0});Object.defineProperty(ge.prototype,"wasCle\
|
|
185
|
+
an",{enumerable:!0});var ke=class extends ne{constructor(e,r={}){super(e),this[En]=r.error===void 0?null:r.error,this[On]=
|
|
186
|
+
r.message===void 0?"":r.message}get error(){return this[En]}get message(){return this[On]}};Object.defineProperty(ke.prototype,
|
|
187
|
+
"error",{enumerable:!0});Object.defineProperty(ke.prototype,"message",{enumerable:!0});var Be=class extends ne{constructor(e,r={}){
|
|
188
|
+
super(e),this[Cn]=r.data===void 0?null:r.data}get data(){return this[Cn]}};Object.defineProperty(Be.prototype,"data",{enumerable:!0});
|
|
189
|
+
var Ci={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[qe]&&o[Zt]===e&&!o[qe])return;let n;if(t==="mess\
|
|
190
|
+
age")n=function(s,i){let a=new Be("message",{data:i?s:s.toString()});a[Pe]=this,ut(e,this,a)};else if(t==="close")n=function(s,i){
|
|
191
|
+
let a=new ge("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Pe]=this,ut(
|
|
192
|
+
e,this,a)};else if(t==="error")n=function(s){let i=new ke("error",{error:s,message:s.message});i[Pe]=this,ut(e,this,i)};else if(t===
|
|
193
|
+
"open")n=function(){let s=new ne("open");s[Pe]=this,ut(e,this,s)};else return;n[qe]=!!r[qe],n[Zt]=e,r.once?this.once(t,n):
|
|
194
|
+
this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Zt]===e&&!r[qe]){this.removeListener(t,r);break}}};
|
|
195
|
+
Mn.exports={CloseEvent:ge,ErrorEvent:ke,Event:ne,EventTarget:Ci,MessageEvent:Be};function ut(t,e,r){typeof t=="object"&&
|
|
196
|
+
t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var lt=G((wl,jn)=>{"use strict";var{tokenChars:He}=Ee();function ee(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Ei(t){
|
|
197
|
+
let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,l=0;for(;l<t.length;l++)if(d=t.charCodeAt(
|
|
198
|
+
l),i===void 0)if(u===-1&&He[d]===1)c===-1&&(c=l);else if(l!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=l);else if(d===59||d===
|
|
199
|
+
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);u===-1&&(u=l);let h=t.slice(c,u);d===44?(ee(e,
|
|
200
|
+
h,r),r=Object.create(null)):i=h,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${l}`);else if(a===void 0)
|
|
201
|
+
if(u===-1&&He[d]===1)c===-1&&(c=l);else if(d===32||d===9)u===-1&&c!==-1&&(u=l);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
|
|
202
|
+
`Unexpected character at index ${l}`);u===-1&&(u=l),ee(r,t.slice(c,u),!0),d===44&&(ee(e,i,r),r=Object.create(null),i=void 0),
|
|
203
|
+
c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,l),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${l}`);else if(o){
|
|
204
|
+
if(He[d]!==1)throw new SyntaxError(`Unexpected character at index ${l}`);c===-1?c=l:n||(n=!0),o=!1}else if(s)if(He[d]===
|
|
205
|
+
1)c===-1&&(c=l);else if(d===34&&c!==-1)s=!1,u=l;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
|
|
206
|
+
index ${l}`);else if(d===34&&t.charCodeAt(l-1)===61)s=!0;else if(u===-1&&He[d]===1)c===-1&&(c=l);else if(c!==-1&&(d===32||
|
|
207
|
+
d===9))u===-1&&(u=l);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);u===-1&&
|
|
208
|
+
(u=l);let h=t.slice(c,u);n&&(h=h.replace(/\\/g,""),n=!1),ee(r,a,h),d===44&&(ee(e,i,r),r=Object.create(null),i=void 0),a=
|
|
209
|
+
void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${l}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
|
|
210
|
+
"Unexpected end of input");u===-1&&(u=l);let p=t.slice(c,u);return i===void 0?ee(e,p,r):(a===void 0?ee(r,p,!0):n?ee(r,a,
|
|
211
|
+
p.replace(/\\/g,"")):ee(r,a,p),ee(e,i,r)),e}function Oi(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(
|
|
212
|
+
r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(o=>{let s=n[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}\
|
|
213
|
+
=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jn.exports={format:Oi,parse:Ei}});var mt=G((Sl,Wn)=>{"use strict";var Ri=N("events"),Pi=N("https"),ki=N("http"),Ln=N("net"),Mi=N("tls"),{randomBytes:Ni,createHash:ji}=N("crypto"),
|
|
214
|
+
{Duplex:yl,Readable:Il}=N("stream"),{URL:er}=N("url"),de=Ce(),Di=Jt(),zi=Qt(),{isBlob:Li}=Ee(),{BINARY_TYPES:Dn,CLOSE_TIMEOUT:Fi,
|
|
215
|
+
EMPTY_BUFFER:pt,GUID:$i,kForOnEventAttribute:tr,kListener:Ui,kStatusCode:qi,kWebSocket:z,NOOP:Fn}=te(),{EventTarget:{addEventListener:Bi,
|
|
216
|
+
removeEventListener:Hi}}=Nn(),{format:Vi,parse:Gi}=lt(),{toBuffer:Wi}=$e(),$n=Symbol("kAborted"),rr=[8,13],oe=["CONNECTI\
|
|
217
|
+
NG","OPEN","CLOSING","CLOSED"],Ki=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends Ri{constructor(e,r,n){super(),this.
|
|
218
|
+
_binaryType=Dn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pt,this._closeTimer=
|
|
222
219
|
null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=
|
|
223
220
|
null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?
|
|
224
|
-
r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),
|
|
225
|
-
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]),Un(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=
|
|
222
|
+
n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Dn.includes(e)&&(this._binaryType=
|
|
226
223
|
e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+
|
|
227
224
|
this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){
|
|
228
225
|
return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){
|
|
229
|
-
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 Di(
|
|
230
227
|
{allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,
|
|
231
228
|
maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),
|
|
232
|
-
|
|
233
|
-
o.on("conclude",
|
|
234
|
-
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",
|
|
235
|
-
"end",
|
|
236
|
-
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[
|
|
229
|
+
s=new zi(e,this._extensions,n.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[z]=this,s[z]=this,e[z]=this,
|
|
230
|
+
o.on("conclude",Yi),o.on("drain",Qi),o.on("error",Zi),o.on("message",ea),o.on("ping",ta),o.on("pong",ra),s.onerror=na,e.
|
|
231
|
+
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Hn),e.on("data",ht),e.on(
|
|
232
|
+
"end",Vn),e.on("error",Gn),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
|
|
233
|
+
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[de.extensionName]&&this._extensions[de.extensionName].
|
|
237
234
|
cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){
|
|
238
|
-
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
235
|
+
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){W(this,this._req,"WebSocket was closed before the conn\
|
|
239
236
|
ection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver.
|
|
240
237
|
_writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,
|
|
241
238
|
n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),
|
|
242
|
-
|
|
239
|
+
Bn(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){
|
|
243
240
|
if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="func\
|
|
244
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){
|
|
245
|
-
|
|
242
|
+
nr(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||pt,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)
|
|
246
243
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="\
|
|
247
|
-
function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
248
|
-
(r=!this._isServer),this._sender.pong(e||
|
|
244
|
+
function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){nr(this,e,n);return}r===void 0&&
|
|
245
|
+
(r=!this._isServer),this._sender.pong(e||pt,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
|
|
249
246
|
_paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)
|
|
250
247
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="numbe\
|
|
251
|
-
r"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
252
|
-
compress:!0,fin:!0,...r};this._extensions[
|
|
253
|
-
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
254
|
-
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(
|
|
255
|
-
NNECTING",{enumerable:!0,value:
|
|
256
|
-
value:
|
|
257
|
-
|
|
258
|
-
"CLOSING")});Object.defineProperty(
|
|
259
|
-
|
|
248
|
+
r"&&(e=e.toString()),this.readyState!==t.OPEN){nr(this,e,n);return}let o={binary:typeof e!="string",mask:!this._isServer,
|
|
249
|
+
compress:!0,fin:!0,...r};this._extensions[de.extensionName]||(o.compress=!1),this._sender.send(e||pt,o,n)}terminate(){if(this.
|
|
250
|
+
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){W(this,this._req,"WebSocket was closed before the connection w\
|
|
251
|
+
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(k,"CO\
|
|
252
|
+
NNECTING",{enumerable:!0,value:oe.indexOf("CONNECTING")});Object.defineProperty(k.prototype,"CONNECTING",{enumerable:!0,
|
|
253
|
+
value:oe.indexOf("CONNECTING")});Object.defineProperty(k,"OPEN",{enumerable:!0,value:oe.indexOf("OPEN")});Object.defineProperty(
|
|
254
|
+
k.prototype,"OPEN",{enumerable:!0,value:oe.indexOf("OPEN")});Object.defineProperty(k,"CLOSING",{enumerable:!0,value:oe.indexOf(
|
|
255
|
+
"CLOSING")});Object.defineProperty(k.prototype,"CLOSING",{enumerable:!0,value:oe.indexOf("CLOSING")});Object.defineProperty(
|
|
256
|
+
k,"CLOSED",{enumerable:!0,value:oe.indexOf("CLOSED")});Object.defineProperty(k.prototype,"CLOSED",{enumerable:!0,value:oe.
|
|
260
257
|
indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
|
|
261
|
-
defineProperty(
|
|
262
|
-
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[
|
|
263
|
-
listeners(t))if(r[
|
|
264
|
-
prototype.addEventListener=
|
|
265
|
-
autoPong:!0,closeTimeout:
|
|
258
|
+
defineProperty(k.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(k.prototype,
|
|
259
|
+
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[tr])return e[Ui];return null},set(e){for(let r of this.
|
|
260
|
+
listeners(t))if(r[tr]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[tr]:!0})}})});k.
|
|
261
|
+
prototype.addEventListener=Bi;k.prototype.removeEventListener=Hi;Wn.exports=k;function Un(t,e,r,n){let o={allowSynchronousEvents:!0,
|
|
262
|
+
autoPong:!0,closeTimeout:Fi,protocolVersion:rr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
|
|
266
263
|
perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,
|
|
267
|
-
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!
|
|
268
|
-
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${
|
|
269
|
-
", ")})`);let
|
|
270
|
-
"http:"?
|
|
271
|
-
"ws+unix:",
|
|
272
|
-
+unix:"`:a&&!
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
startsWith("[")?
|
|
276
|
-
-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=
|
|
277
|
-
(
|
|
278
|
-
offer()})),r.length){for(let S of r){if(typeof S!="string"||!
|
|
279
|
-
uplicated subprotocol was specified");
|
|
280
|
-
13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(
|
|
281
|
-
:${
|
|
282
|
-
0){t._originalIpc=a,t._originalSecure=
|
|
283
|
-
headers:{}},S)for(let[
|
|
284
|
-
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:
|
|
285
|
-
t._originalSecure&&!
|
|
286
|
-
o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),I=t._req=
|
|
287
|
-
t._redirects&&t.emit("redirect",t.url,I)}else I=t._req=
|
|
288
|
-
timed out")}),I.on("error",S=>{I===null||I[
|
|
289
|
-
statusCode;if(
|
|
290
|
-
return}I.abort();let
|
|
291
|
-
t.emit("unexpected-response",I,S)||
|
|
292
|
-
emit("upgrade",S),t.readyState!==
|
|
293
|
-
"websocket"){
|
|
294
|
-
socket-accept"]!==
|
|
295
|
-
void 0?
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
264
|
+
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!rr.includes(
|
|
265
|
+
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${rr.join(
|
|
266
|
+
", ")})`);let s;if(e instanceof er)s=e;else try{s=new er(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol===
|
|
267
|
+
"http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),t._url=s.href;let i=s.protocol==="wss:",a=s.protocol===
|
|
268
|
+
"ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws\
|
|
269
|
+
+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let S=new SyntaxError(
|
|
270
|
+
c);if(t._redirects===0)throw S;ft(t,S);return}let d=i?443:80,u=Ni(16).toString("base64"),l=i?Pi.request:ki.request,p=new Set,
|
|
271
|
+
h;if(o.createConnection=o.createConnection||(i?Xi:Ji),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
|
|
272
|
+
startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec\
|
|
273
|
+
-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
|
|
274
|
+
(h=new de({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Vi({[de.extensionName]:h.
|
|
275
|
+
offer()})),r.length){for(let S of r){if(typeof S!="string"||!Ki.test(S)||p.has(S))throw new SyntaxError("An invalid or d\
|
|
276
|
+
uplicated subprotocol was specified");p.add(S)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<
|
|
277
|
+
13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}\
|
|
278
|
+
:${s.password}`),a){let S=o.path.split(":");o.socketPath=S[0],o.path=S[1]}let I;if(o.followRedirects){if(t._redirects===
|
|
279
|
+
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let S=n&&n.headers;if(n={...n,
|
|
280
|
+
headers:{}},S)for(let[C,P]of Object.entries(S))n.headers[C.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let S=a?
|
|
281
|
+
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!S||
|
|
282
|
+
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,S||delete o.headers.host,o.auth=void 0)}
|
|
283
|
+
o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),I=t._req=l(o),
|
|
284
|
+
t._redirects&&t.emit("redirect",t.url,I)}else I=t._req=l(o);o.timeout&&I.on("timeout",()=>{W(t,I,"Opening handshake has \
|
|
285
|
+
timed out")}),I.on("error",S=>{I===null||I[$n]||(I=t._req=null,ft(t,S))}),I.on("response",S=>{let C=S.headers.location,P=S.
|
|
286
|
+
statusCode;if(C&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){W(t,I,"Maximum redirects exceeded");
|
|
287
|
+
return}I.abort();let j;try{j=new er(C,e)}catch{let $=new SyntaxError(`Invalid URL: ${C}`);ft(t,$);return}Un(t,j,r,n)}else
|
|
288
|
+
t.emit("unexpected-response",I,S)||W(t,I,`Unexpected server response: ${S.statusCode}`)}),I.on("upgrade",(S,C,P)=>{if(t.
|
|
289
|
+
emit("upgrade",S),t.readyState!==k.CONNECTING)return;I=t._req=null;let j=S.headers.upgrade;if(j===void 0||j.toLowerCase()!==
|
|
290
|
+
"websocket"){W(t,C,"Invalid Upgrade header");return}let L=ji("sha1").update(u+$i).digest("base64");if(S.headers["sec-web\
|
|
291
|
+
socket-accept"]!==L){W(t,C,"Invalid Sec-WebSocket-Accept header");return}let $=S.headers["sec-websocket-protocol"],K;if($!==
|
|
292
|
+
void 0?p.size?p.has($)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":p.
|
|
293
|
+
size&&(K="Server sent no subprotocol"),K){W(t,C,K);return}$&&(t._protocol=$);let F=S.headers["sec-websocket-extensions"];
|
|
294
|
+
if(F!==void 0){if(!h){W(t,C,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let V;
|
|
295
|
+
try{V=Gi(F)}catch{W(t,C,"Invalid Sec-WebSocket-Extensions header");return}let Z=Object.keys(V);if(Z.length!==1||Z[0]!==de.
|
|
296
|
+
extensionName){W(t,C,"Server indicated an extension that was not requested");return}try{h.accept(V[de.extensionName])}catch{
|
|
297
|
+
W(t,C,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[de.extensionName]=h}t.setSocket(C,P,{allowSynchronousEvents:o.
|
|
301
298
|
allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
|
|
302
|
-
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(I,t):I.end()}function
|
|
303
|
-
|
|
304
|
-
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=
|
|
305
|
-
t._readyState=
|
|
306
|
-
destroyed&&e.socket.destroy(),process.nextTick(
|
|
307
|
-
se",t.emitClose.bind(t)))}function
|
|
308
|
-
t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${
|
|
309
|
-
nextTick(r,n)}}function
|
|
310
|
-
(r._socket.removeListener("data",
|
|
311
|
-
t.isPaused||t._socket.resume()}function
|
|
312
|
-
process.nextTick(
|
|
313
|
-
emitClose()}function
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
e.emit("error",t)))}function
|
|
317
|
-
let t=this[
|
|
318
|
-
|
|
319
|
-
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[
|
|
299
|
+
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(I,t):I.end()}function ft(t,e){t._readyState=
|
|
300
|
+
k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ji(t){return t.path=t.socketPath,Ln.connect(t)}function Xi(t){
|
|
301
|
+
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ln.isIP(t.host)?"":t.host),Mi.connect(t)}function W(t,e,r){
|
|
302
|
+
t._readyState=k.CLOSING;let n=new Error(r);Error.captureStackTrace(n,W),e.setHeader?(e[$n]=!0,e.abort(),e.socket&&!e.socket.
|
|
303
|
+
destroyed&&e.socket.destroy(),process.nextTick(ft,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("clo\
|
|
304
|
+
se",t.emitClose.bind(t)))}function nr(t,e,r){if(e){let n=Li(e)?e.size:Wi(e).length;t._socket?t._sender._bufferedBytes+=n:
|
|
305
|
+
t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${oe[t.readyState]})`);process.
|
|
306
|
+
nextTick(r,n)}}function Yi(t,e){let r=this[z];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[z]!==void 0&&
|
|
307
|
+
(r._socket.removeListener("data",ht),process.nextTick(qn,r._socket),t===1005?r.close():r.close(t,e))}function Qi(){let t=this[z];
|
|
308
|
+
t.isPaused||t._socket.resume()}function Zi(t){let e=this[z];e._socket[z]!==void 0&&(e._socket.removeListener("data",ht),
|
|
309
|
+
process.nextTick(qn,e._socket),e.close(t[qi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function zn(){this[z].
|
|
310
|
+
emitClose()}function ea(t,e){this[z].emit("message",t,e)}function ta(t){let e=this[z];e._autoPong&&e.pong(t,!this._isServer,
|
|
311
|
+
Fn),e.emit("ping",t)}function ra(t){this[z].emit("pong",t)}function qn(t){t.resume()}function na(t){let e=this[z];e.readyState!==
|
|
312
|
+
k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,Bn(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
|
|
313
|
+
e.emit("error",t)))}function Bn(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Hn(){
|
|
314
|
+
let t=this[z];if(this.removeListener("close",Hn),this.removeListener("data",ht),this.removeListener("end",Vn),t._readyState=
|
|
315
|
+
k.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.
|
|
316
|
+
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[z]=void 0,clearTimeout(
|
|
320
317
|
t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
|
|
321
|
-
"error",
|
|
322
|
-
t._readyState=
|
|
323
|
-
"error",
|
|
324
|
-
this._writableState.finished&&this.destroy()}function
|
|
325
|
-
"error")===0&&this.emit("error",t)}function
|
|
326
|
-
return t.on("message",function(i
|
|
327
|
-
error",function(
|
|
328
|
-
if(t.readyState===t.CLOSED){
|
|
329
|
-
lose",function(){s
|
|
318
|
+
"error",zn),t._receiver.on("finish",zn))}function ht(t){this[z]._receiver.write(t)||this.pause()}function Vn(){let t=this[z];
|
|
319
|
+
t._readyState=k.CLOSING,t._receiver.end(),this.end()}function Gn(){let t=this[z];this.removeListener("error",Gn),this.on(
|
|
320
|
+
"error",Fn),t&&(t._readyState=k.CLOSING,this.destroy())}});var Yn=G((Tl,Xn)=>{"use strict";var xl=mt(),{Duplex:oa}=N("stream");function Kn(t){t.emit("close")}function sa(){!this.destroyed&&
|
|
321
|
+
this._writableState.finished&&this.destroy()}function Jn(t){this.removeListener("error",Jn),this.destroy(),this.listenerCount(
|
|
322
|
+
"error")===0&&this.emit("error",t)}function ia(t,e){let r=!0,n=new oa({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
|
|
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
|
+
error",function(s){n.destroyed||(r=!1,n.destroy(s))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(o,s){
|
|
325
|
+
if(t.readyState===t.CLOSED){s(o),process.nextTick(Kn,n);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
|
|
326
|
+
lose",function(){i||s(o),process.nextTick(Kn,n)}),r&&t.terminate()},n._final=function(o){if(t.readyState===t.CONNECTING){
|
|
330
327
|
t.once("open",function(){n._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),n._readableState.
|
|
331
328
|
endEmitted&&n.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},
|
|
332
|
-
n._write=function(o,i
|
|
333
|
-
n.on("end",
|
|
334
|
-
let
|
|
329
|
+
n._write=function(o,s,i){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(o,s,i)});return}t.send(o,i)},
|
|
330
|
+
n.on("end",sa),n.on("error",Jn),n}Xn.exports=ia});var or=G((bl,Qn)=>{"use strict";var{tokenChars:aa}=Ee();function ca(t){let e=new Set,r=-1,n=-1,o=0;for(o;o<t.length;o++){
|
|
331
|
+
let i=t.charCodeAt(o);if(n===-1&&aa[i]===1)r===-1&&(r=o);else if(o!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=o);else if(i===
|
|
335
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(
|
|
336
333
|
`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
|
|
337
|
-
if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let
|
|
338
|
-
`The "${
|
|
339
|
-
|
|
334
|
+
if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let s=t.slice(r,o);if(e.has(s))throw new SyntaxError(
|
|
335
|
+
`The "${s}" subprotocol is duplicated`);return e.add(s),e}Qn.exports={parse:ca}});var so=G((Al,oo)=>{"use strict";var da=N("events"),gt=N("http"),{Duplex:_l}=N("stream"),{createHash:ua}=N("crypto"),Zn=lt(),
|
|
336
|
+
ve=Ce(),la=or(),pa=mt(),{CLOSE_TIMEOUT:fa,GUID:ha,kWebSocket:ma}=te(),ga=/^[+/0-9A-Za-z]{22}==$/,eo=0,to=1,no=2,sr=class extends da{constructor(e,r){
|
|
340
337
|
if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*
|
|
341
|
-
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:
|
|
342
|
-
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:
|
|
338
|
+
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:fa,verifyClient:null,
|
|
339
|
+
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:pa,...e},e.port==null&&!e.server&&!e.noServer||
|
|
343
340
|
e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server"\
|
|
344
|
-
, or "noServer" options must be specified');if(e.port!=null?(this._server=
|
|
345
|
-
o.writeHead(426,{"Content-Length":
|
|
341
|
+
, or "noServer" options must be specified');if(e.port!=null?(this._server=gt.createServer((n,o)=>{let s=gt.STATUS_CODES[426];
|
|
342
|
+
o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(e.port,e.host,e.
|
|
346
343
|
backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=
|
|
347
|
-
|
|
348
|
-
o,i,
|
|
349
|
-
!1),this.options=e,this._state=
|
|
350
|
-
er" mode');return this._server?this._server.address():null}close(e){if(this._state===
|
|
351
|
-
"The server is not running"))}),process.nextTick(
|
|
352
|
-
|
|
353
|
-
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(
|
|
354
|
-
_server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{
|
|
344
|
+
va(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
|
|
345
|
+
o,s,i,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=
|
|
346
|
+
!1),this.options=e,this._state=eo}address(){if(this.options.noServer)throw new Error('The server is operating in "noServ\
|
|
347
|
+
er" mode');return this._server?this._server.address():null}close(e){if(this._state===no){e&&this.once("close",()=>{e(new Error(
|
|
348
|
+
"The server is not running"))}),process.nextTick(Ve,this);return}if(e&&this.once("close",e),this._state!==to)if(this._state=
|
|
349
|
+
to,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=
|
|
350
|
+
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ve,this):process.nextTick(Ve,this);else{let r=this.
|
|
351
|
+
_server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ve(this)})}}shouldHandle(e){if(this.
|
|
355
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){
|
|
356
|
-
r.on("error",
|
|
357
|
-
"GET"){
|
|
358
|
-
lid Upgrade header");return}if(
|
|
359
|
-
if(a!==13&&a!==8){
|
|
360
|
-
if(!this.shouldHandle(e)){
|
|
361
|
-
|
|
362
|
-
if(this.options.perMessageDeflate&&u!==void 0){let
|
|
363
|
-
options.maxPayload});try{let
|
|
364
|
-
|
|
353
|
+
r.on("error",ro);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
|
|
354
|
+
"GET"){we(this,e,r,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){we(this,e,r,400,"Inva\
|
|
355
|
+
lid Upgrade header");return}if(s===void 0||!ga.test(s)){we(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}
|
|
356
|
+
if(a!==13&&a!==8){we(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
|
|
357
|
+
if(!this.shouldHandle(e)){Ge(r,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=la.parse(
|
|
358
|
+
c)}catch{we(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],l={};
|
|
359
|
+
if(this.options.perMessageDeflate&&u!==void 0){let p=new ve({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
|
|
360
|
+
options.maxPayload});try{let h=Zn.parse(u);h[ve.extensionName]&&(p.accept(h[ve.extensionName]),l[ve.extensionName]=p)}catch{
|
|
361
|
+
we(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={
|
|
365
362
|
origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.
|
|
366
|
-
options.verifyClient.length===2){this.options.verifyClient(
|
|
367
|
-
|
|
368
|
-
if(!
|
|
369
|
-
e with the same socket, possibly due to a misconfiguration");if(this._state>
|
|
370
|
-
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${
|
|
371
|
-
se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let
|
|
372
|
-
handleProtocols(n,o):n.values().next().value;
|
|
373
|
-
let
|
|
374
|
-
e}this.emit("headers",
|
|
363
|
+
options.verifyClient.length===2){this.options.verifyClient(p,(h,I,S,C)=>{if(!h)return Ge(r,I||401,S,C);this.completeUpgrade(
|
|
364
|
+
l,s,d,e,r,n,o)});return}if(!this.options.verifyClient(p))return Ge(r,401)}this.completeUpgrade(l,s,d,e,r,n,o)}completeUpgrade(e,r,n,o,s,i,a){
|
|
365
|
+
if(!s.readable||!s.writable)return s.destroy();if(s[ma])throw new Error("server.handleUpgrade() was called more than onc\
|
|
366
|
+
e with the same socket, possibly due to a misconfiguration");if(this._state>eo)return Ge(s,503);let d=["HTTP/1.1 101 Swi\
|
|
367
|
+
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ua("sha1").update(r+ha).digest("ba\
|
|
368
|
+
se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let l=this.options.handleProtocols?this.options.
|
|
369
|
+
handleProtocols(n,o):n.values().next().value;l&&(d.push(`Sec-WebSocket-Protocol: ${l}`),u._protocol=l)}if(e[ve.extensionName]){
|
|
370
|
+
let l=e[ve.extensionName].params,p=Zn.format({[ve.extensionName]:[l]});d.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=
|
|
371
|
+
e}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
375
372
|
`).join(`\r
|
|
376
|
-
`)),
|
|
373
|
+
`)),s.removeListener("error",ro),u.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
|
|
377
374
|
options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.
|
|
378
375
|
options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&
|
|
379
|
-
!this.clients.size&&process.nextTick(
|
|
380
|
-
r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function
|
|
381
|
-
function
|
|
382
|
-
l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${
|
|
376
|
+
!this.clients.size&&process.nextTick(Ve,this)})),a(u,o)}};oo.exports=sr;function va(t,e){for(let r of Object.keys(e))t.on(
|
|
377
|
+
r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function Ve(t){t._state=no,t.emit("close")}
|
|
378
|
+
function ro(){this.destroy()}function Ge(t,e,r,n){r=r||gt.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/htm\
|
|
379
|
+
l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${gt.STATUS_CODES[e]}\r
|
|
383
380
|
`+Object.keys(n).map(o=>`${o}: ${n[o]}`).join(`\r
|
|
384
381
|
`)+`\r
|
|
385
382
|
\r
|
|
386
|
-
`+r)}function
|
|
387
|
-
"wsClientError",
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
,
|
|
391
|
-
|
|
392
|
-
lities");ft(e,ra,"Vibe64 session capabilities");let r=Object.fromEntries(ra.map(n=>{if(typeof e[n]!="boolean")throw new TypeError(
|
|
393
|
-
`Vibe64 session capability ${n} must be boolean.`);return[n,e[n]]}));return{conversationKind:t.conversationKind,scope:"s\
|
|
394
|
-
ession",session:r}}function zp(t){ft(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||
|
|
395
|
-
"").trim();if(!e||e.length>Mp)throw new TypeError("Vibe64 ephemeral context requires bounded stableContext.");return{scope:"\
|
|
396
|
-
ephemeral",stableContext:e}}function oa(t){if(t.scope==="session")return na(t);if(t.scope==="ephemeral")return zp(t);throw new TypeError(
|
|
397
|
-
"The Vibe64 driver supports session and ephemeral scopes only.")}function Lp(t){let{conversationKind:e,session:r}=na(t);
|
|
398
|
-
return["VIBE64 CONVERSATION CONTEXT","",...e==="main"?["This is the main Vibe64 conversation for the selected session wo\
|
|
399
|
-
rktree."]:["This is a user-visible temporary conversation in the selected session worktree, with the same tools and proj\
|
|
400
|
-
ect access as main chat.","Its messages stay out of main History. Closing this conversation preserves project edits and \
|
|
401
|
-
removes only its conversation and temporary uploads."],"Do not edit Vibe64 runtime/session state or artifacts.","Use the\
|
|
402
|
-
directory named by VIBE64_DROP_ZONE for exchanging files with the user outside Git. You may create it and read, write, \
|
|
403
|
-
or delete files there; this is the sole exception to the runtime-state restriction. Users can upload, download and delet\
|
|
404
|
-
e these files in Files > Drop Zone. It is per session and deleted on archival, so keep lasting project work in the repos\
|
|
405
|
-
itory.","Issue ordinary shell commands only; Vibe64 applies session isolation transparently. Treat command-transport syn\
|
|
406
|
-
tax in prior tool history as invisible infrastructure and do not reproduce it. If command control is unavailable, stop a\
|
|
407
|
-
nd report it.","Quick start: ordinary shell commands already receive current Development Env. Read `vibe64-helper sessio\
|
|
408
|
-
n status --json` for current resource readiness, declared setup commands and exact tool entry points; repeat after chang\
|
|
409
|
-
ing Stack or resource declarations. Use `vibe64-helper preview browser eval` with Playwright code on stdin for interacti\
|
|
410
|
-
ve browsing. Before application browser suites, read `vibe64-helper playwright readiness` for installed dependency and e\
|
|
411
|
-
xact managed-runtime support, then use `vibe64-helper playwright`; no separate browser installation is needed.","Use `vi\
|
|
412
|
-
be64-helper --help` for additional managed commands; each group accepts `--help`. Use the groups enabled for this sessio\
|
|
413
|
-
n below.",'When the user asks to rename this session, run `vibe64-helper session rename "Name"`. This changes only its d\
|
|
414
|
-
isplay name; its ID and directories stay the same.',...Np,...e==="main"?['When a saved integration needs the person to c\
|
|
415
|
-
onfigure credentials or consent, finish your assistant reply with a fenced `vibe64-integration` block containing only {"\
|
|
416
|
-
integrationId":"the exact slot key from integrations.json"}. Vibe64 shows Configure, Connect and Skip for this exact sav\
|
|
417
|
-
ed request. Never include credentials, URLs or additional fields in that block. The block itself does not authorize a co\
|
|
418
|
-
nnection. The person can configure the application or explicitly start Connect; after the application confirms setup, Vi\
|
|
419
|
-
be64 resumes this task with a separate continuation message. Do not claim the account is connected before that confirmat\
|
|
420
|
-
ion. Do not emit this block for examples or for an integration that has not been saved.']:[],...r.managedPreview?jp:[],...r.
|
|
421
|
-
managedEnvironment?Dp:[],...r.managedDatabaseRefresh?["After a database migration or schema change, run `vibe64-helper d\
|
|
422
|
-
atabase refresh` once so Vibe64's Database view reflects it.","To inspect or tidy the main ERD, run `vibe64-helper datab\
|
|
423
|
-
ase erd --json`. It returns saved table rectangles, pins, actual routed connection points, route metrics and instruction\
|
|
424
|
-
s for `vibe64-helper database erd apply --json` with a revision-checked batch of table moves on stdin. Use those operati\
|
|
425
|
-
ons to change diagram presentation without editing database schema or records. Inspect the resulting paths before claimi\
|
|
426
|
-
ng improvement; this layout is separate from Overview configuration.","When data-overview.json exists in project source,\
|
|
427
|
-
maintain its main actors and explicit supporting-table groups as the schema changes. Use `vibe64-helper database overvi\
|
|
428
|
-
ew --json` for the current schema, grouping, coverage and exact format instructions. Preserve authored groupings, classi\
|
|
429
|
-
fy new tables, fix renamed/removed references, and check coverage afterward. When asked to create a Data overview, use t\
|
|
430
|
-
he same command and relevant application source; no one-hop membership rule applies. Never invent foreign keys or cardin\
|
|
431
|
-
alities."]:[],...r.managedGit?["Use the managed `git` and `gh` commands on PATH. Do not bypass them with host binaries, \
|
|
432
|
-
a stripped PATH, or alternate credentials.","For GitHub-hosted attachments and inline images in issues (tickets), pull r\
|
|
433
|
-
equests or comments, always use authenticated managed `gh api` with the original attachment URL. Save the response to a \
|
|
434
|
-
local file and inspect it before reporting what it contains. Do not use unauthenticated curl/wget, User-Agent experiment\
|
|
435
|
-
s, or extract credentials for a separate HTTP client. An unauthenticated 404 does not prove a private attachment is miss\
|
|
436
|
-
ing. This rule applies to GitHub-hosted attachments, not arbitrary external links.","After changing GitHub issues, comme\
|
|
437
|
-
nts, labels or pull requests, run `vibe64-helper github refresh` once so Vibe64's Issues/PR view reflects it.","When lin\
|
|
438
|
-
king an issue in this project's repository, run `vibe64-helper github issue-link <number>` and use its returned Vibe64 p\
|
|
439
|
-
ath exactly as the primary Markdown link destination, including the /app prefix. Ordinary links to Vibe64 pages navigate\
|
|
440
|
-
in-app without reloading, whether root-relative or full URLs on the current origin. You may include the GitHub URL as a\
|
|
441
|
-
secondary link. Do not guess the project slug or host; issues in other repositories keep their GitHub links.","Report a\
|
|
442
|
-
uthentication or transport failures directly; do not inspect credentials or invent another login path.","When a managed \
|
|
443
|
-
Git/GitHub command fails, tell the user which requested action failed, which earlier work is confirmed complete, what re\
|
|
444
|
-
mains undone or unconfirmed, and the next safe action. Retain the reported failure stage, execution budget and execution\
|
|
445
|
-
reference when provided; do not expose credentials or dump raw output unnecessarily.","A timeout or transport failure d\
|
|
446
|
-
oes not establish invalid authentication, exhausted AI quota, a GitHub outage or a suspension problem. Separate recorded\
|
|
447
|
-
facts from hypotheses; say the cause is unknown when it is unproven. Recommend reconnection only when the reported erro\
|
|
448
|
-
r explicitly calls for it.","If the diagnostic says commandSubmitted=false, the requested Git/GitHub action was not atte\
|
|
449
|
-
mpted. After an execution timeout, lost response or unreadable response, its effects remain unconfirmed: use a read-only\
|
|
450
|
-
check of the affected Git/GitHub state before repeating any write. Never claim that a comment was posted or not posted,\
|
|
451
|
-
or that a push succeeded or failed, solely from those errors. If verification is unavailable, report the outcome as unk\
|
|
452
|
-
nown and stop; do not repeat the write or claim it was safely rolled back."]:[]].join(`
|
|
453
|
-
`)}function Be(t={}){let e=wr(t,"Vibe64 driver input"),r=oa(e);return r.scope==="session"?Lp(r):r.stableContext}async function ia(t={},{
|
|
454
|
-
readRegistry:e=Pp,workdir:r=""}={}){let n=wr(t,"Vibe64 host resolver request");if(ft(n,["data","providerSessionId","pare\
|
|
455
|
-
ntSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(n.scope))throw new TypeError("The Vi\
|
|
456
|
-
be64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=wr(n.data,"Vibe64 host resolve\
|
|
457
|
-
r data");ft(o,["registryPath"],"Vibe64 host resolver data");let i=Ln(o.registryPath);if(!zn.isAbsolute(i))throw new TypeError(
|
|
458
|
-
"Vibe64 host resolver data requires an absolute registryPath.");let s=JSON.parse(await e(i,"utf8"));if(!Array.isArray(s?.
|
|
459
|
-
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=s.sessions,d=Ln(n.providerSessionId);
|
|
460
|
-
if(n.parentSessionIds!==void 0&&(!Array.isArray(n.parentSessionIds)||n.parentSessionIds.length>32||n.parentSessionIds.some(
|
|
461
|
-
l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[d,...n.parentSessionIds||
|
|
462
|
-
[]].filter(Boolean).map(l=>a.find(f=>Ln(f?.upstreamSessionId)===l)).find(Boolean),p=u?.promptContext;if(!p)return null;if(r&&
|
|
463
|
-
u.workdir&&zn.resolve(r)!==zn.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
464
|
-
t directory.");if(p.scope==="learning"){if(ft(p,["scope","instructions"],"Vibe64 learning context"),u.conversation?.nativeTools!==
|
|
465
|
-
!1)throw new TypeError("Learning instructions require the restricted native conversation binding.");let l=p.instructions;
|
|
466
|
-
if(typeof l!="string"||!l.trim()||Buffer.byteLength(l)>128*1024)throw new TypeError("Learning native context requires bo\
|
|
467
|
-
unded nonempty teaching instructions.");return{scope:"learning",instructions:l}}return oa(p)}var kp,ra,Mp,Np,jp,Dp,yr=he(
|
|
468
|
-
()=>{kp=Object.freeze(["main","temporary"]),ra=Object.freeze(["managedDatabaseRefresh","managedEnvironment","managedGit",
|
|
469
|
-
"managedPreview"]),Mp=64*1024,Np=Object.freeze(["When user input is necessary, ask no more than three concise, high-impa\
|
|
470
|
-
ct questions at once.","Put multiple questions on separate lines as `[1] Question`, `[2] Question`, and so on.","For a s\
|
|
471
|
-
mall fixed set of useful choices, finish with `Possible answers:` and a short bullet list; the user may always type a di\
|
|
472
|
-
fferent answer."]),jp=Object.freeze(["The Vibe64-managed preview is the canonical application server; do not start a dup\
|
|
473
|
-
licate server on another port.","Use `vibe64-helper preview status`, `screenshot`, `logs`, and `browser eval` for render\
|
|
474
|
-
ed inspection. Pass Playwright code to `vibe64-helper preview browser eval` on stdin.","For interactive navigation, use \
|
|
475
|
-
the proxy URL from `vibe64-helper preview inspect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside bro\
|
|
476
|
-
wser eval, use `await page.goto(new URL('/your-path', preview.url).href)`. The direct application endpoint under diagnos\
|
|
477
|
-
tics bypasses Preview identity and is not a browser-navigation URL.","Use the managed preview browser for interactive br\
|
|
478
|
-
owsing. Use `vibe64-helper playwright` only for an existing configured project suite, and report a platform or project-t\
|
|
479
|
-
est blocker rather than installing another browser or changing its dependencies.","For browser evidence, batch related a\
|
|
480
|
-
ctions and assertions and return only the needed values. Inspect relevant locators or page regions; use screenshots at m\
|
|
481
|
-
eaningful visual checkpoints or failures instead of after every click. Reuse the managed browser when test isolation per\
|
|
482
|
-
mits. Preserve required viewport, identity and security checks; use existing automated cases for repeat verification.","\
|
|
483
|
-
For browser tests that write or reset data, inspect `vibe64-helper preview targets --json` and the project's `genesis/st\
|
|
484
|
-
ack.md` Outputs. Run `vibe64-helper playwright --target <declared-test-target> test <suite arguments>` or `vibe64-helper\
|
|
485
|
-
playwright --target <declared-test-target> npm-run <script>`. Vibe64 starts that web target, waits for readiness, uses \
|
|
486
|
-
its declared application identity, and restores the previous Preview when the command finishes or is cancelled; report r\
|
|
487
|
-
estoration failures.","A target name is not proof of test isolation. Before running a destructive suite, the application\
|
|
488
|
-
must verify the server's actual test database and suppress real email, invoices, payments, and other external effects. \
|
|
489
|
-
Keep managed Env unchanged. The test launcher and its preview-identity command must use the same database. When the proj\
|
|
490
|
-
ect declares BROWSER_TEST_DB_NAME, use it for reusable browser fixtures, separate from disposable TEST_DB_NAME. Never sp\
|
|
491
|
-
oof safety checks by changing DB_NAME only in the test runner.","If no suitable test target exists, add one through the \
|
|
492
|
-
project's existing Outputs contract and application-owned test scripts within the user's authorized scope. Keep normal P\
|
|
493
|
-
review as the default. Validate the exact disposable database before resetting it, prepare fixtures before reporting rea\
|
|
494
|
-
diness, and make Playwright use PLAYWRIGHT_BASE_URL without starting another server. If the required test resources or e\
|
|
495
|
-
xternal-effect controls are missing, report that specific blocker. Use `vibe64-helper preview ensure --target <id> --wai\
|
|
496
|
-
t --json` only for deliberate interactive target selection; it leaves that target selected until changed.","Keep routine\
|
|
497
|
-
browser startup incremental: reuse the isolated test schema, apply only pending migrations, and reset fixture data dete\
|
|
498
|
-
rministically. Do not drop and rebuild the database or run a production frontend build for every focused browser check. \
|
|
499
|
-
Keep fresh-schema migration checks separate, and batch related cases into one suite invocation. If startup is slow, meas\
|
|
500
|
-
ure migrations, fixtures, and server startup before retrying or extending deadlines.","Keep test output small: select th\
|
|
501
|
-
e relevant file and cases, capture stdout and stderr to local artifacts, and preserve the command's exit status. Return \
|
|
502
|
-
counts, duration, failed case names, a short actionable error, and artifact paths. Read only relevant failure excerpts; \
|
|
503
|
-
do not dump passing assertions, full JSON/TAP reports, request logs, traces, or screenshots into context. Keep startup, \
|
|
504
|
-
resource and Preview-restoration errors even when tests pass. If the wrapper appends diagnostics after JSON, parse the J\
|
|
505
|
-
SON object and retain the trailing diagnostics separately. Wait on the existing run; do not rerun to recover output or r\
|
|
506
|
-
epeatedly print unchanged logs. When a command returns an execution/session identifier, use its existing wait operation \
|
|
507
|
-
with about a 30-second wait window where supported: for an empty command poll, set yield_time_ms: 30000. Reserve shorter\
|
|
508
|
-
waits for interactive input or a specific immediate check. Do not alternate brief waits with commands that reread empty\
|
|
509
|
-
or unchanged logs; inspect status or failure excerpts when there is new output, a changed state, or a specific blocker \
|
|
510
|
-
to diagnose.","Run related browser tests in one managed suite command: Preview switches once for the entire batch and re\
|
|
511
|
-
stores once afterward, not between tests or workers. Managed suites and live Preview browser actions are sequential: do \
|
|
512
|
-
not run `vibe64-helper preview browser` actions, Preview ensure/restart, or target changes while a suite is active or re\
|
|
513
|
-
storing. Wait on the original command, including cleanup and restoration; if it runs in the background, wait on that sam\
|
|
514
|
-
e execution before starting a live browser check. Read-only status and logs remain available during the suite. After com\
|
|
515
|
-
pletion, confirm `vibe64-helper playwright status` has no active run and `vibe64-helper preview status` reports the rest\
|
|
516
|
-
ored Preview ready before live inspection. To stop a suite, read `vibe64-helper playwright status`, then run `vibe64-hel\
|
|
517
|
-
per playwright cancel <run-id>`. Cancellation waits for managed process cleanup and Preview restoration. Retry that same\
|
|
518
|
-
cancellation if cleanup needs attention. Do not kill individual test or Preview PIDs or change internal locks. Launcher\
|
|
519
|
-
exit alone does not prove the managed test stopped. Recheck live status before reporting a blocker; do not repeat an ea\
|
|
520
|
-
rlier busy response as current evidence.","If a managed command reports kernel task denials or a resource incident, reta\
|
|
521
|
-
in its diagnostic and incident ID when reporting the blocker. Ask the platform operator to inspect that resource evidenc\
|
|
522
|
-
e before retrying; do not increase test timeouts or weaken assertions to work around a process/thread limit. A generic b\
|
|
523
|
-
rowser timeout without resource evidence does not establish a platform cause.","Describe only rendered browser evidence;\
|
|
524
|
-
if managed preview is unavailable, report that blocker instead of starting a replacement."]),Dp=Object.freeze(["Each ma\
|
|
525
|
-
naged shell command receives current development Env from Vibe64, including existing declared resource bindings. Use tho\
|
|
526
|
-
se variables in ordinary application commands; do not build environment injection or copy managed credentials into sourc\
|
|
527
|
-
e. Resource provisioning and application migrations remain separate preparation steps.","Use `vibe64-helper env status [\
|
|
528
|
-
development|production|all]` to inspect configured key names without revealing values.","Pipe an available value to `vib\
|
|
529
|
-
e64-helper env set <development|production> <KEY> [--secret]`; never put values in arguments, logs, or repository files.\
|
|
530
|
-
Use empty stdin only when the user requested an empty value.","Keep development and production values separate. Never i\
|
|
531
|
-
nvent credentials, copy a value between scopes without explicit direction, or edit Vibe64 runtime/session storage.","Aft\
|
|
532
|
-
er an Env mutation, report only the affected scope and key names, never their values, and claim success only when the co\
|
|
533
|
-
mmand succeeded.","When declared, TEST_DB_NAME is the exact disposable integration database and BROWSER_TEST_DB_NAME is \
|
|
534
|
-
a separate reusable browser-fixture database whose migration ledger survives routine runs. Follow the application\u2019s decl\
|
|
535
|
-
ared test resources; never reset DB_NAME, share these test identities, or invent a database name."])});import{mkdir as $p,mkdtemp as Fp,readFile as Up,rename as qp,rm as Bp,writeFile as Hp}from"node:fs/promises";import Vp from"node:os";
|
|
536
|
-
import $n from"node:path";async function sa(t=""){let e=t||await Fp($n.join(Vp.tmpdir(),"vibe64-genesis-context-"));await $p(
|
|
537
|
-
e,{recursive:!0,mode:448});let r=$n.join(e,"sessions.json"),n=new Map;try{let a=JSON.parse(await Up(r,"utf8"));for(let d of a.
|
|
538
|
-
sessions)Be(d.promptContext),n.set(d.upstreamSessionId,d)}catch(a){if(a.code!=="ENOENT")throw a}let o=Promise.resolve(),
|
|
539
|
-
i=!1;async function s(a){let d=$n.join(e,"sessions.tmp");await Hp(d,JSON.stringify({sessions:[...a.values()]}),{mode:384}),
|
|
540
|
-
await qp(d,r)}return await s(n),{registryPath:r,get(a){return structuredClone(n.get(a))},async register(a,d,c=""){if(i)throw new Error(
|
|
541
|
-
"The Genesis host context registry is closed.");if(typeof a!="string"||!a.trim())throw new TypeError("Genesis host conte\
|
|
542
|
-
xt requires a native conversation ID.");let u=structuredClone(d);Be(u);let p={upstreamSessionId:a,workdir:c,promptContext:u},
|
|
543
|
-
l=o.catch(()=>{}).then(async()=>{if(JSON.stringify(n.get(a))===JSON.stringify(p))return;let f=new Map(n);f.set(a,p),await s(
|
|
544
|
-
f),n=f});o=l,await l},async close(){i=!0,await o.catch(()=>{}),n.clear(),t||await Bp(e,{recursive:!0,force:!0})}}}var aa=he(
|
|
545
|
-
()=>{yr()});import{createHash as Gp}from"node:crypto";import Fn from"node:path";function M(t,e,r,n,o={}){throw new Ir(t,r,{path:e,...n===
|
|
546
|
-
void 0?{}:{line:n},...o})}function ee(t,e,r,n,o){return(typeof t!="string"||!t.trim()||/[\0\r\n]/u.test(t))&&M(e,r,`${n}\
|
|
547
|
-
must be one non-empty line.`,o),t.trim()}function Wp(t){let e=[...String(t||"").matchAll(/`([^`\r\n]+)`/gu)];return e.length===
|
|
548
|
-
0||e.map(r=>r[0]).join(" ")!==t?null:e.map(r=>r[1])}function He(t,e,r,n,o,{count:i,maximum:s=64}={}){let a=Wp(t);if(!a||
|
|
549
|
-
a.length>s||i!==void 0&&a.length!==i||a.some(d=>d.length>4096||/[\0\r\n]/u.test(d))){let d=i===void 0?"separate non-empt\
|
|
550
|
-
y":`exactly ${i}`;M(e,r,`${n} must contain ${d} backticked ${i===1?"value":"values"}.`,o)}return a}function Kp(t=""){return typeof t==
|
|
551
|
-
"string"&&!!t&&!/[\s\0{}]/u.test(t)&&!Fn.isAbsolute(t)&&!t.split(/[\\/]/u).includes("..")}function ue(t,e,r,n,o){let i=He(
|
|
552
|
-
t,e,r,n,o);return Kp(i[0])||M(e,r,`${n} must begin with a safe executable.`,o),i}function Jp(t=""){return typeof t=="str\
|
|
553
|
-
ing"&&!!t&&!/[\0\r\n\\]/u.test(t)&&!Fn.posix.isAbsolute(t)&&Fn.posix.normalize(t)===t&&!t.split("/").some(e=>!e||e==="..")}
|
|
554
|
-
function ae(t,e,r,n,o,{allowRoot:i=!0}={}){return(!Jp(t)||!i&&t===".")&&M(e,r,`${n} must be a canonical project-relative\
|
|
555
|
-
path.`,o),t}function le(t,e,r,n,o){let i=He(t,e,r,n,o);return i.some(s=>!/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(s))&&M(e,r,
|
|
556
|
-
`${n} must use lowercase technology ids separated into backticked values.`,o),new Set(i).size!==i.length&&M(e,r,`${n} co\
|
|
557
|
-
ntains a duplicate technology id.`,o),i}function qn(t,e,r,n,o){let i=ee(t,e,r,n,o);return(!i.startsWith("/")||i.startsWith(
|
|
558
|
-
"//")||/[\\?#]/u.test(i))&&M(e,r,`${n} must begin with one slash and contain no query or fragment.`,o),i}function Sr(t,e,r,n,o){
|
|
559
|
-
let i=t.match(/^- Ready when: `GET` `([^`\r\n]+)` returns `([0-9]{3})`$/u);i||M(e,r,`${n} must use \`- Ready when: \`GET\` \
|
|
560
|
-
\`/path\` returns \`200\`\`.`,o);let s=Number(i[2]);return(!Number.isInteger(s)||s<200||s>399)&&M(e,r,`${n} status must \
|
|
561
|
-
be from 200 through 399.`,o),{kind:"http",method:"GET",path:qn(i[1],e,r,`${n} path`,o),status:s}}function Un(t){return Array.
|
|
562
|
-
isArray(t)?t.map(Un):t&&typeof t=="object"?Object.fromEntries(Object.keys(t).sort().map(e=>[e,Un(t[e])])):t}function ve(t){
|
|
563
|
-
let e=`${JSON.stringify(Un(t),null,2)}
|
|
564
|
-
`;return`sha256:${Gp("sha256").update(e).digest("hex")}`}function Ve(t={},e={},r="operation"){if(t.stackHash!==e.stackHash)
|
|
565
|
-
throw new Ir("VIBE64_STACK_CHANGED",`The Stack changed while Vibe64 inspected its ${r}. Retry the operation.`)}function Ge(t=[]){
|
|
566
|
-
return[...new Set(t)].sort()}function ce(t=[]){let e=t.map(r=>r.trim()).filter(Boolean);return e.length===1&&e[0]==="- N\
|
|
567
|
-
othing."}var Ir,We=he(()=>{Ir=class extends Error{constructor(e,r,n=void 0){super(r),this.name="Vibe64StackOperationErro\
|
|
568
|
-
r",this.code=e,n!==void 0&&(this.details=n)}}});function te(t,e,r,n={}){M(Me,t,e,r,n)}function Yp(t,e,r){let n=He(t.slice(da.length),Me,e,"Deployment Recreate on restor\
|
|
569
|
-
e paths",r);return n.some(o=>o.startsWith("/")||o.includes("\\")||o.includes("***")||/[?[\]{}!]/u.test(o)||o.split("/").
|
|
570
|
-
some(i=>!i||[".",".."].includes(i)))&&te(e,"Deployment Recreate on restore paths must be canonical project-relative glob\
|
|
571
|
-
s using only * and ** wildcards.",r),new Set(n).size!==n.length&&te(e,"Deployment contains a duplicate Recreate on resto\
|
|
572
|
-
re path.",r),n}function Qp(t,e,r){return{label:ee(t[2],Me,e,"Deployment step label",r),argv:ue(t[3],Me,e,"Deployment com\
|
|
573
|
-
mand",r),role:t[1].toLowerCase()}}function Bn(){return{version:1,artifact:{disposablePaths:[]},workdir:".",runtimeRequirements:[],
|
|
574
|
-
readiness:null,steps:[]}}function Gn(t,{path:e="genesis/stack.md#Deployment"}={}){if(Array.isArray(t)||te(e,"Deployment \
|
|
575
|
-
must be supplied as exact Stack section lines."),ce(t))return Bn();let r=Bn(),n=new Set;for(let i=0;i<t.length;i+=1){let s=t[i].
|
|
576
|
-
trim();if(!s)continue;let a=i+1;if(s.startsWith("- Workdir: ")){n.has("workdir")&&te(e,"Duplicate Deployment Workdir.",a),
|
|
577
|
-
n.add("workdir");let c=He(s.slice(11),Me,e,"Deployment Workdir",a,{count:1})[0];r.workdir=ae(c,Me,e,"Deployment workdir",
|
|
578
|
-
a);continue}if(s.startsWith("- Runtimes: ")){n.has("runtimes")&&te(e,"Duplicate Deployment Runtimes.",a),n.add("runtimes"),
|
|
579
|
-
r.runtimeRequirements=le(s.slice(12),Me,e,"Deployment runtimes",a);continue}if(s.startsWith(da)){n.has("restore-paths")&&
|
|
580
|
-
te(e,"Duplicate Deployment Recreate on restore entry.",a),n.add("restore-paths"),r.artifact.disposablePaths=Yp(s,e,a);continue}
|
|
581
|
-
if(s.startsWith("- Ready when: ")){n.has("readiness")&&te(e,"Duplicate Deployment Ready when.",a),n.add("readiness"),r.readiness=
|
|
582
|
-
Sr(s,Me,e,"Deployment readiness",a);continue}let d=s.match(Xp);if(d){r.steps.push(Qp(d,e,a));continue}te(e,`Unknown Depl\
|
|
583
|
-
oyment entry: ${s}.`,a)}r.steps.length===0&&te(e,"## Deployment needs at least one command or exactly `- Nothing.`."),(r.
|
|
584
|
-
steps.filter(({role:i})=>i==="serve").length!==1||r.steps.at(-1).role!=="serve")&&te(e,"Deployment needs exactly one fin\
|
|
585
|
-
al Serve step.");for(let i=1;i<r.steps.length;i+=1)ca[r.steps[i].role]<ca[r.steps[i-1].role]&&te(e,"Deployment steps mus\
|
|
586
|
-
t be ordered Prepare, Build, Migrate, then Serve.");return r.readiness||te(e,"Deployment needs one Ready when entry."),r.
|
|
587
|
-
artifact.disposablePaths.length>0&&!r.steps.some(({role:i})=>i==="prepare")&&te(e,"Deployment may recreate paths on rest\
|
|
588
|
-
ore only when it declares a Prepare step."),r}function ua({environment:t={},section:e={}}={}){Ve(e,t,"Deployment section");
|
|
589
|
-
let r=[...e.diagnostics||[]],n=Bn();e.status==="ready"&&(n=Gn(e.lines));let o=r.length>0?"blocked":n.steps.length>0?"rea\
|
|
590
|
-
dy":"unconfigured",i={version:n.version,artifact:n.artifact,workdir:n.workdir,runtimeRequirements:n.runtimeRequirements,
|
|
591
|
-
readiness:n.readiness,steps:n.steps};return{contract:Hn,status:o,stackHash:e.stackHash,recipeHash:o==="ready"?ve(i):"",components:[
|
|
592
|
-
...e.components||[]],source:e.source||null,runtimeRequirements:Ge(n.runtimeRequirements),resources:structuredClone(t.resources||
|
|
593
|
-
[]),...i,diagnostics:r}}var Hn,Vn,Me,Xp,da,ca,la=he(()=>{We();Hn="vibe64.application-deployment.v1",Vn="Deployment",Me="\
|
|
594
|
-
VIBE64_DEPLOYMENT_INVALID",Xp=/^- (Prepare|Build|Migrate|Serve) `([^`\r\n]+)`:[ \t]+(.+)$/u,da="- Recreate on restore: ",
|
|
595
|
-
ca=Object.freeze({prepare:0,build:1,migrate:2,serve:3})});function x(t,e,r,n={}){M(q,t,e,r,n)}function Jn(t,e,r,n){let o=ee(t,q,e,r,n);return Zp.test(o)||x(e,`${r} must use lower\
|
|
596
|
-
case letters, digits, and single hyphens.`,n),o}function ma(t,e,r,n,o,i){return He(t.slice(e.length),q,r,n,o,i)}function we(t,e,r,n,o){
|
|
597
|
-
return ma(t,e,r,n,o,{count:1})[0]}function lf(t,e,r,n){let o=ue(t,q,e,r,n);for(let i of o)i.replace(Wn,"").includes("{pa\
|
|
598
|
-
rameter:")&&x(e,`${r} has an invalid {parameter:id} placeholder.`,n),[...i.matchAll(Wn)].some(s=>!["host","port"].includes(
|
|
599
|
-
s[1])&&!/^parameter:[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(s[1]))&&x(e,`${r} supports only {host}, {port}, and {parameter:id} \
|
|
600
|
-
placeholders.`,n);return o}function K(t,e,r,n,o,i){t.seen.has(e)&&x(n,`Duplicate ${i}.`,o),t.seen.add(e),t[e]=r}function pf(t,e,r){
|
|
601
|
-
return{id:Jn(t[1],e,"Output target id",r),label:ee(t[2],q,e,"Output target label",r),default:!1,mode:"",workdir:".",runtimeRequirements:[],
|
|
602
|
-
steps:[],presentation:null,previewIdentity:null,downloads:[],parameters:[],seen:new Set,line:r}}function ff(t,e,r,n){if(e===
|
|
603
|
-
"- Required."){K(t,"required",!0,r,n,"Parameter Required entry");return}for(let[o,i]of[["Default","default"],["Descripti\
|
|
604
|
-
on","description"]]){let s=`- ${o}: `;if(e.startsWith(s)){let a=we(e,s,r,`Parameter ${o}`,n);K(t,i,a,r,n,`Parameter ${o}\
|
|
605
|
-
entry`);return}}x(r,`Unknown Outputs parameter entry: ${e}.`,n)}function ha(t,e={}){let r=t.parameters||[],n=i=>M("VIBE\
|
|
606
|
-
64_OUTPUT_PARAMETERS_INVALID","Outputs",i);(!e||typeof e!="object"||Array.isArray(e))&&n("Output parameters must be an o\
|
|
607
|
-
bject of text values.");let o=new Set(r.map(({id:i})=>i));for(let i of Object.keys(e))o.has(i)||n(`Unknown output parame\
|
|
608
|
-
ter: ${i}.`);return Object.fromEntries(r.map(i=>{let s=Object.hasOwn(e,i.id)?e[i.id]:i.default;return(typeof s!="string"||
|
|
609
|
-
s.length>4096||/[\0\r\n]/u.test(s))&&n(`${i.label} must be a single line of text, at most 4096 characters.`),i.required&&
|
|
610
|
-
!s.trim()&&n(`${i.label} is required.`),[i.id,s]}))}function mf(t){return{kind:"",preferredPort:null,urlPath:"/",readiness:null,
|
|
611
|
-
seen:new Set,line:t}}function hf(t,e,r){return{id:Jn(t[1],e,"Download id",r),path:"",name:"",mediaType:"",seen:new Set,line:r}}
|
|
612
|
-
function gf(t,e,r){/^[0-9]+$/u.test(t)||x(e,"Web presentation preferred port must be an integer from 1024 through 65535.",
|
|
613
|
-
r);let n=Number(t);return(!Number.isSafeInteger(n)||n<1024||n>65535)&&x(e,"Web presentation preferred port must be an in\
|
|
614
|
-
teger from 1024 through 65535.",r),n}function vf(t,e,r,n){if(e.startsWith("- Data: ")){let i=we(e,"- Data: ",r,"Output t\
|
|
615
|
-
arget Data",n);["development","test"].includes(i)||x(r,"Output target Data must be `development` or `test`.",n),K(t,"dat\
|
|
616
|
-
aMode",i,r,n,"output target Data entry");return}if(e==="- Default."){K(t,"default",!0,r,n,"output target Default entry");
|
|
617
|
-
return}if(e.startsWith("- Mode: ")){let i=we(e,"- Mode: ",r,"Output target Mode",n);cf.has(i)||x(r,"Output target Mode m\
|
|
618
|
-
ust be `interactive` or `finite`.",n),K(t,"mode",i,r,n,"output target Mode entry");return}if(e.startsWith("- Workdir: ")){
|
|
619
|
-
K(t,"workdir",ae(we(e,"- Workdir: ",r,"Output target Workdir",n),q,r,"Output target workdir",n),r,n,"output target Workd\
|
|
620
|
-
ir entry");return}if(e.startsWith("- Runtimes: ")){K(t,"runtimeRequirements",le(e.slice(12),q,r,"Output target runtimes",
|
|
621
|
-
n),r,n,"output target Runtimes entry");return}let o=e.match(/^- (Prepare|Build|Run) `([^`\r\n]+)`:[ \t]+(.+)$/u);if(o){let i=o[1].
|
|
622
|
-
toLowerCase(),s=lf(o[3],r,"Output step command",n);i!=="run"&&s.some(a=>/\{(?:host|port)\}/u.test(a))&&x(r,"Only a web p\
|
|
623
|
-
resentation's Run step may use {host} or {port} placeholders.",n),t.steps.push({label:ee(o[2],q,r,"Output step label",n),
|
|
624
|
-
argv:s,role:i});return}x(r,`Unknown Outputs target entry: ${e}.`,n)}function wf(t,e,r,n){if(e.startsWith("- Kind: ")){let o=we(
|
|
625
|
-
e,"- Kind: ",r,"Presentation Kind",n);df.has(o)||x(r,"Presentation Kind must be `terminal` or `web`.",n),K(t,"kind",o,r,
|
|
626
|
-
n,"Presentation Kind entry");return}if(e.startsWith("- Preferred port: ")){K(t,"preferredPort",gf(we(e,"- Preferred port\
|
|
627
|
-
: ",r,"Web presentation Preferred port",n),r,n),r,n,"Presentation Preferred port entry");return}if(e.startsWith("- URL p\
|
|
628
|
-
ath: ")){K(t,"urlPath",qn(we(e,"- URL path: ",r,"Web presentation URL path",n),q,r,"Web presentation URL path",n),r,n,"P\
|
|
629
|
-
resentation URL path entry");return}if(e.startsWith("- Ready when: ")){K(t,"readiness",Sr(e,q,r,"Web presentation readin\
|
|
630
|
-
ess",n),r,n,"Presentation Ready when entry");return}x(r,`Unknown Presentation entry: ${e}.`,n)}function yf(t,e,r){let n=ee(
|
|
631
|
-
t,q,e,"Download Name",r);return(n.length>255||[".",".."].includes(n)||/[\\/\0]/u.test(n)||n.trim()!==n)&&x(e,"Download N\
|
|
632
|
-
ame must be a safe filename without path separators.",r),n}function If(t,e,r){let n=ee(t,q,e,"Download Media type",r);return(n.
|
|
633
|
-
length>127||!of.test(n))&&x(e,"Download Media type must be a lowercase type/subtype value.",r),n}function Sf(t,e,r,n){if(e.
|
|
634
|
-
startsWith("- Path: ")){K(t,"path",ae(we(e,"- Path: ",r,"Download Path",n),q,r,"Download path",n,{allowRoot:!1}),r,n,"Do\
|
|
635
|
-
wnload Path entry");return}if(e.startsWith("- Name: ")){K(t,"name",yf(we(e,"- Name: ",r,"Download Name",n),r,n),r,n,"Dow\
|
|
636
|
-
nload Name entry");return}if(e.startsWith("- Media type: ")){K(t,"mediaType",If(we(e,"- Media type: ",r,"Download Media \
|
|
637
|
-
type",n),r,n),r,n,"Download Media type entry");return}x(r,`Unknown Download entry: ${e}.`,n)}function xf(t,e,r){for(let[
|
|
638
|
-
n,o]of[["path","Path"],["name","Name"],["mediaType","Media type"]])t[n]||x(e,`Output target ${r} Download ${t.id} needs ${o}\
|
|
639
|
-
.`,t.line);return{id:t.id,path:t.path,name:t.name,mediaType:t.mediaType}}function pa(t,e,r,n){if(t===void 0)return"";let o=ee(
|
|
640
|
-
t,q,e,`Preview identity ${r} environment name`,n);return(!nf.test(o)||sf.has(o)||o.startsWith("XDG_"))&&x(e,`Preview ide\
|
|
641
|
-
ntity ${r} environment name is invalid.`,n),o}function Tf(t){return{seen:new Set,line:t}}function bf(t,e,r,n){let o=uf.find(
|
|
642
|
-
([c])=>e.startsWith(c));o||x(r,`Unknown Preview identity entry: ${e}.`,n);let[i,s,a]=o,d=ma(e,i,r,`Preview identity ${a}`,
|
|
643
|
-
n);!["command","identityTypes","runtimes"].includes(s)&&d.length!==1&&x(r,`Preview identity ${a} accepts exactly one val\
|
|
644
|
-
ue.`,n),K(t,s,d,r,n,`Preview identity ${a} entry`)}function _f(t,e,r){for(let[c,u]of[["command","Command"],["protocol","\
|
|
645
|
-
Protocol"],["identityTypes","Identity types"]])t[c]||x(e,`Output target ${r} Preview identity needs ${u}.`,t.line);let n=t.
|
|
646
|
-
command.map(c=>`\`${c}\``).join(" "),o=ue(n,q,e,"Preview identity command",t.line);(!o[0].includes("/")||o[0].includes("\
|
|
647
|
-
\\")||o[0].split("/").some(c=>!c||[".",".."].includes(c))||o.some(c=>/\{(?:host|port)\}/u.test(c)))&&x(e,"Preview identi\
|
|
648
|
-
ty command must use a literal app-owned project-relative executable.",t.line);let i=t.protocol[0];i!==xr&&x(e,`Preview i\
|
|
649
|
-
dentity protocol must be ${xr}.`,t.line);let s=[...new Set(t.identityTypes.map(c=>(af.has(c)||x(e,`Unsupported preview i\
|
|
650
|
-
dentity type: ${c}.`,t.line),c)))];s.length!==t.identityTypes.length&&x(e,"Preview identity types must not contain dupli\
|
|
651
|
-
cates.",t.line);let a={enabled:pa(t.enabledEnvironment?.[0],e,"enabled",t.line),secret:pa(t.secretEnvironment?.[0],e,"se\
|
|
652
|
-
cret",t.line)};a.enabled&&a.enabled===a.secret&&x(e,"Preview identity enabled and secret environment names must differ.",
|
|
653
|
-
t.line);let d=1e4;if(t.timeoutMs){let c=t.timeoutMs[0];/^[0-9]+$/u.test(c)||x(e,"Preview identity Timeout ms must be fro\
|
|
654
|
-
m 1 through 30000.",t.line),d=Number(c),(!Number.isSafeInteger(d)||d<1||d>3e4)&&x(e,"Preview identity Timeout ms must be\
|
|
655
|
-
from 1 through 30000.",t.line)}return{command:o,environment:a,identityTypes:s,protocol:i,runtimes:t.runtimes?le(t.runtimes.
|
|
656
|
-
map(c=>`\`${c}\``).join(" "),q,e,"Preview identity runtimes",t.line):[],timeoutMs:d}}function Af(t,e,r){return t.kind||x(
|
|
657
|
-
e,`Output target ${r} Presentation needs Kind.`,t.line),t.kind==="terminal"?((t.preferredPort!==null||t.readiness||t.seen.
|
|
658
|
-
has("urlPath"))&&x(e,`Output target ${r} terminal Presentation accepts only Kind.`,t.line),{kind:"terminal"}):(t.readiness||
|
|
659
|
-
x(e,`Output target ${r} web Presentation needs one Ready when entry.`,t.line),{kind:"web",preferredPort:t.preferredPort,
|
|
660
|
-
urlPath:t.urlPath,readiness:t.readiness})}function fa(t,e){t.mode||x(e,`Output target ${t.id} needs one Mode entry.`,t.line),
|
|
661
|
-
t.steps.length===0&&x(e,`Output target ${t.id} needs at least one step.`,t.line);let r={prepare:0,build:1,run:2};for(let c=1;c<
|
|
662
|
-
t.steps.length;c+=1)r[t.steps[c].role]<r[t.steps[c-1].role]&&x(e,`Output target ${t.id} steps must be ordered Prepare, B\
|
|
663
|
-
uild, then Run.`,t.line);let n=t.steps.filter(({role:c})=>c==="run"),o=t.downloads.map(c=>xf(c,e,t.id));new Set(o.map(({
|
|
664
|
-
id:c})=>c)).size!==o.length&&x(e,`Output target ${t.id} contains a duplicate Download id.`,t.line),t.mode==="finite"?((n.
|
|
665
|
-
length>0||t.presentation||t.previewIdentity)&&x(e,`Finite output target ${t.id} cannot have Run, Presentation, or Previe\
|
|
666
|
-
w identity entries.`,t.line),o.length===0&&x(e,`Finite output target ${t.id} needs at least one Download.`,t.line)):n.length!==
|
|
667
|
-
1||t.steps.at(-1).role!=="run"?x(e,`Interactive output target ${t.id} needs exactly one final Run step.`,t.line):t.presentation||
|
|
668
|
-
x(e,`Interactive output target ${t.id} needs one Presentation.`,t.line);let i=t.presentation?Af(t.presentation,e,t.id):null,
|
|
669
|
-
s=t.steps.flatMap(({argv:c})=>c.flatMap(u=>[...u.matchAll(Wn)].map(p=>p[1])));s.some(c=>["host","port"].includes(c))&&i?.
|
|
670
|
-
kind!=="web"&&x(e,"Only a web output target may use {host} or {port} placeholders.",t.line);let a=t.parameters.map(({seen:c,
|
|
671
|
-
...u})=>u),d=new Set(a.map(({id:c})=>c));(a.length>16||d.size!==a.length)&&x(e,`Output target ${t.id} may declare at mos\
|
|
672
|
-
t 16 parameters with unique ids.`,t.line);for(let c of s.filter(u=>u.startsWith("parameter:"))){let u=c.slice(10);d.has(
|
|
673
|
-
u)||x(e,`Undeclared output parameter: ${u}.`,t.line)}for(let c of a)s.includes(`parameter:${c.id}`)||x(e,`Output paramet\
|
|
674
|
-
er ${c.id} must be used in a step command.`,t.line);return t.previewIdentity&&i?.kind!=="web"&&x(e,"Only a web output ta\
|
|
675
|
-
rget may declare Preview identity.",t.line),{id:t.id,label:t.label,default:t.default,mode:t.mode,workdir:t.workdir,runtimeRequirements:t.
|
|
676
|
-
runtimeRequirements,...t.dataMode?{dataMode:t.dataMode}:{},steps:t.steps,presentation:i,downloads:o,...a.length?{parameters:a}:
|
|
677
|
-
{},...t.previewIdentity?{previewIdentity:_f(t.previewIdentity,e,t.id)}:{}}}function kt(t,{path:e="genesis/stack.md#Outpu\
|
|
678
|
-
ts"}={}){if(Array.isArray(t)||x(e,"Outputs must be supplied as exact Stack section lines."),ce(t))return{version:1,targets:[]};
|
|
679
|
-
let r=[],n=null,o="target",i=null;for(let a=0;a<t.length;a+=1){let d=t[a].trim();if(!d)continue;let c=a+1,u=d.match(ef);
|
|
680
|
-
if(u){n&&r.push(fa(n,e)),n=pf(u,e,c),o="target",i=null;continue}n||x(e,"## Outputs must begin with a Target heading.",c);
|
|
681
|
-
let p=d.match(tf);if(p){let f={id:Jn(p[1],e,"Parameter id",c),label:ee(p[2],q,e,"Parameter label",c),default:"",description:"",
|
|
682
|
-
required:!1,seen:new Set};n.parameters.push(f),o="parameter",i=f;continue}if(d==="#### Presentation"){n.presentation&&x(
|
|
683
|
-
e,"Presentation must appear at most once below an output target.",c),n.presentation=mf(c),o="presentation",i=n.presentation;
|
|
684
|
-
continue}if(d==="#### Preview identity"){n.previewIdentity&&x(e,"Preview identity must appear at most once below an outp\
|
|
685
|
-
ut target.",c),n.previewIdentity=Tf(c),o="previewIdentity",i=n.previewIdentity;continue}let l=d.match(rf);if(l){let f=hf(
|
|
686
|
-
l,e,c);n.downloads.push(f),o="download",i=f;continue}o==="parameter"?ff(i,d,e,c):o==="presentation"?wf(i,d,e,c):o==="pre\
|
|
687
|
-
viewIdentity"?bf(i,d,e,c):o==="download"?Sf(i,d,e,c):vf(n,d,e,c)}n&&r.push(fa(n,e)),r.length===0&&x(e,"## Outputs needs \
|
|
688
|
-
at least one Target or exactly `- Nothing.`.");let s=r.map(({id:a})=>a);return new Set(s).size!==s.length&&x(e,"Outputs \
|
|
689
|
-
contains a duplicate target id."),r.filter(({default:a})=>a).length>1&&x(e,"Outputs may declare at most one default targ\
|
|
690
|
-
et."),{version:1,targets:r}}function ga({environment:t={},section:e={}}={}){Ve(e,t,"Outputs section");let r=[...e.diagnostics||
|
|
691
|
-
[]],n=[...t.diagnostics||[]],o={version:1,targets:[]};e.status==="ready"&&(o=kt(e.lines));let i=n.length===0?null:n.map(
|
|
692
|
-
({message:c})=>c).join(" "),s=o.targets.map(c=>({...c,source:e.source||null,available:r.length===0&&n.length===0,disabledReason:i})),
|
|
693
|
-
a=[...r,...n],d="ready";return a.length>0?d="blocked":s.length===0&&(d="unconfigured"),{contract:Kn,status:d,stackHash:e.
|
|
694
|
-
stackHash,components:[...e.components||[]],environmentDefaults:structuredClone(t.environmentDefaults||[]),runtimeRequirements:Ge(
|
|
695
|
-
s.flatMap(c=>c.runtimeRequirements)),resources:structuredClone(t.resources||[]),targets:s,diagnostics:a}}var Kn,Pt,xr,q,
|
|
696
|
-
Zp,Wn,ef,tf,rf,nf,of,sf,af,cf,df,uf,Xn=he(()=>{We();Kn="vibe64.outputs.v1",Pt="Outputs",xr="vibe64.preview-identity.comm\
|
|
697
|
-
and.v1",q="VIBE64_OUTPUTS_INVALID",Zp=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,Wn=/\{([a-z][a-z0-9:-]*)\}/gu,ef=/^### Target `([^`\r\n]+)`:[ \t]+(.+)$/u,
|
|
698
|
-
tf=/^#### Parameter `([^`\r\n]+)`:[ \t]+(.+)$/u,rf=/^#### Download `([^`\r\n]+)`$/u,nf=/^[A-Z_][A-Z0-9_]*$/u,of=/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/u,
|
|
699
|
-
sf=new Set(["HOME","LOGNAME","NODE_OPTIONS","PATH","TMPDIR","USER"]),af=new Set(["email","login","user-id"]),cf=new Set(
|
|
700
|
-
["finite","interactive"]),df=new Set(["terminal","web"]),uf=[["- Command: ","command","Command"],["- Protocol: ","protoc\
|
|
701
|
-
ol","Protocol"],["- Identity types: ","identityTypes","Identity types"],["- Enabled environment: ","enabledEnvironment",
|
|
702
|
-
"Enabled environment"],["- Secret environment: ","secretEnvironment","Secret environment"],["- Runtimes: ","runtimes","R\
|
|
703
|
-
untimes"],["- Timeout ms: ","timeoutMs","Timeout ms"]]});function Yn(t){if(Array.isArray(t)||M(Ke,Je,"Expected exact Project services section lines."),ce(t))return[];let e=[];for(let[
|
|
704
|
-
r,n]of t.entries()){let o=n.trim();if(!o)continue;let i=r+1,s=o.match(/^- Start `([a-z][a-z0-9-]{0,63})` with (.+?): (.+)$/u);
|
|
705
|
-
s||M(Ke,Je,"Use: - Start `service-id` with `runtime` [in `workdir`]: `command` `argument`...",i),e.some(({id:d})=>d===s[1])&&
|
|
706
|
-
M(Ke,Je,"Duplicate project service id.",i);let a=s[2].match(/^(.*?) in `([^`\r\n]+)`$/u);e.push({id:s[1],runtimeRequirements:le(
|
|
707
|
-
a?a[1]:s[2],Ke,Je,"Service runtimes",i),workdir:ae(a?.[2]||".",Ke,Je,"Service workdir",i),argv:ue(s[3],Ke,Je,"Service co\
|
|
708
|
-
mmand",i)})}return e.length||M(Ke,Je,"Declare a service or exactly `- Nothing.`."),e}function wa(t={}){let e=t.status===
|
|
709
|
-
"ready"?Yn(t.lines):[];return{contract:Ef,status:t.status==="blocked"?"blocked":e.length?"ready":"unconfigured",services:e,
|
|
710
|
-
recipeHash:e.length?ve(e):"",diagnostics:t.diagnostics||[]}}var va,Ef,Ke,Je,ya=he(()=>{We();va="Project services",Ef="vi\
|
|
711
|
-
be64.project-services.v1",Ke="VIBE64_PROJECT_SERVICES_INVALID",Je="genesis/stack.md#Project services"});import{access as Cf}from"node:fs/promises";import Ia from"node:path";function Qn(t,e,r,n={}){M(mt,t,e,r,n)}function Mt(t,{
|
|
712
|
-
path:e="genesis/stack.md#Workspace setup"}={}){if(Array.isArray(t)||Qn(e,"Workspace setup must be supplied as exact Stac\
|
|
713
|
-
k section lines."),ce(t))return[];let r=[];for(let n=0;n<t.length;n+=1){let o=t[n].trim();if(!o)continue;let i=n+1,s=o.match(
|
|
714
|
-
Of);s||Qn(e,"Every Workspace setup entry must use: - Prepare `label` with `runtime` [in `workdir`] [when|if `path` exist\
|
|
715
|
-
s]: `command` `argument`...",i,{observed:o});let a=s[2].match(Rf),d=a?null:s[2].match(Pf),c=a?a[1]:d?d[1]:s[2],u=a?.[2]||
|
|
716
|
-
d?.[2]||"",p=c.match(kf),l=p?p[1]:c,f=p?p[2]:".";r.push({label:ee(s[1],mt,e,"Workspace setup step label",i),argv:ue(s[3],
|
|
717
|
-
mt,e,"Workspace setup command",i),runtimeRequirements:le(l,mt,e,"Workspace setup runtimes",i),workdir:ae(f,mt,e,"Workspa\
|
|
718
|
-
ce setup workdir",i),...u?{condition:{pathExists:ae(u,mt,e,"Workspace setup condition path",i,{allowRoot:!1}),onMissing:a?
|
|
719
|
-
"wait":"skip"}}:{}})}return r.length===0&&Qn(e,"## Workspace setup needs at least one Prepare entry or exactly `- Nothin\
|
|
720
|
-
g.`."),r}async function Mf(t,e){try{return await Cf(Ia.join(t,e)),!0}catch(r){if(["ENOENT","ENOTDIR"].includes(r?.code))
|
|
721
|
-
return!1;throw r}}async function Sa({projectRoot:t,section:e={}}={}){let r=[...e.diagnostics||[]],n=[];e.status==="ready"&&
|
|
722
|
-
(n=Mt(e.lines));let o=[],i=[],s=Ia.resolve(t);if(r.length===0)for(let l of n){if(!l.condition||await Mf(s,l.condition.pathExists)){
|
|
723
|
-
o.push(l);continue}l.condition.onMissing==="wait"&&i.push(l.condition.pathExists)}if(i.length>0){let l=Ge(i);r.push({code:"\
|
|
724
|
-
VIBE64_WORKSPACE_SETUP_WAITING",message:`Workspace setup is waiting for project ${l.length===1?"path":"paths"}: ${l.join(
|
|
725
|
-
", ")}.`,details:{paths:l}})}let a=r.some(({code:l})=>l==="VIBE64_WORKSPACE_SETUP_WAITING"),d=r.some(({code:l})=>l!=="VI\
|
|
726
|
-
BE64_WORKSPACE_SETUP_WAITING"),c="unconfigured";d?c="blocked":!a&&o.length>0&&(c="ready");let u=o.map(({condition:l,...f})=>f),
|
|
727
|
-
p={version:1,steps:u};return{contract:Zn,status:c,stackHash:e.stackHash,recipeHash:c==="ready"?ve(p):"",components:[...e.
|
|
728
|
-
components||[]],source:e.source||null,runtimeRequirements:Ge(u.flatMap(l=>l.runtimeRequirements)),steps:u,diagnostics:r}}
|
|
729
|
-
var Zn,ht,mt,Of,Rf,Pf,kf,eo=he(()=>{We();Zn="vibe64.workspace-setup.v1",ht="Workspace setup",mt="VIBE64_WORKSPACE_SETUP_\
|
|
730
|
-
INVALID",Of=/^- Prepare `([^`\r\n]+)` with (.+?):[ \t]+(.+)$/u,Rf=/^(.*?)[ \t]+when `([^`\r\n]+)` exists$/u,Pf=/^(.*?)[ \t]+if `([^`\r\n]+)` exists$/u,
|
|
731
|
-
kf=/^(.*?)[ \t]+in `([^`\r\n]+)`$/u});function pe(t,e,r){M(Ta,t,e,r)}function to(t,e,r,n,o){let i=t.get(e),s=t.get(r);return(i===void 0||s===void 0||i>s)&&pe(
|
|
732
|
-
n,"Each resource phase requires typical and high estimates, with typical no greater than high.",o),{typicalBytes:i,highBytes:s}}
|
|
733
|
-
function no(t,{path:e="genesis/stack.md#Resource estimates",targets:r=[],hasWorkspaceSetup:n=!1}={}){(!Array.isArray(t)||
|
|
734
|
-
t.length>2048||t.some(c=>typeof c!="string")||Buffer.byteLength(t.join(`
|
|
735
|
-
`),"utf8")>64*1024)&&pe(e,"Resource estimates must be exact Stack section lines within 64 KiB and 2048 lines.");let o={version:1,
|
|
736
|
-
outputs:[],workspaceSetup:null};if(ce(t))return o;let i=new Map(r.map(c=>[c.id,c])),s=new Set,a=null;function d(){if(!a)
|
|
737
|
-
return;let{targetId:c,mode:u,fields:p,line:l}=a;if(u==="interactive"){(p.has("typical")||p.has("high"))&&pe(e,"Interacti\
|
|
738
|
-
ve outputs require separate Startup and Running estimates.",l),o.outputs.push({targetId:c,mode:u,startup:to(p,"startupTy\
|
|
739
|
-
pical","startupHigh",e,l),running:to(p,"runningTypical","runningHigh",e,l)});return}(p.size!==2||!p.has("typical")||!p.has(
|
|
740
|
-
"high"))&&pe(e,"Finite outputs and Workspace setup require only Typical MiB and High MiB.",l);let f=to(p,"typical","high",
|
|
741
|
-
e,l);c?o.outputs.push({targetId:c,mode:u,execution:f}):o.workspaceSetup=f}for(let c=0;c<t.length;c+=1){let u=t[c].trim(),
|
|
742
|
-
p=c+1;if(!u)continue;let l=u.match(/^### Output `([a-z0-9]+(?:-[a-z0-9]+)*)`$/u);if(l||u==="### Workspace setup"){d();let A=l?.[1]||
|
|
743
|
-
"",k=A?`output:${A}`:"workspace-setup";s.has(k)&&pe(e,"Resource estimates contains a duplicate operation.",p),s.add(k);let D=i.
|
|
744
|
-
get(A);A&&!["interactive","finite"].includes(D?.mode)&&pe(e,`Resource estimate references an undeclared output: ${A}.`,p),
|
|
745
|
-
!A&&!n&&pe(e,"Resource estimate references undeclared Workspace setup steps.",p),a={targetId:A,mode:D?.mode||"setup",fields:new Map,
|
|
746
|
-
line:p};continue}let f=u.match(/^- ([A-Za-z ]+): `([1-9][0-9]*)`$/u),I=f&&jf.get(f[1]);(!a||!I)&&pe(e,"Expected an Outpu\
|
|
747
|
-
t or Workspace setup heading followed by positive integer MiB estimates.",p),a.fields.has(I)&&pe(e,`Duplicate resource f\
|
|
748
|
-
ield: ${f[1]}.`,p);let S=Number(f[2]);(!Number.isSafeInteger(S)||S>xa)&&pe(e,`Resource estimates must be between 1 and ${xa}\
|
|
749
|
-
MiB.`,p),a.fields.set(I,S*Nf)}return d(),s.size===0&&pe(e,"Resource estimates needs an operation or exactly `- Nothing.\
|
|
750
|
-
`."),o}function Tr({section:t={},outputsSection:e={},workspaceSetupSection:r={}}={}){Ve(t,e,"Resource estimates and Outp\
|
|
751
|
-
uts"),Ve(t,r,"Resource estimates and Workspace setup");let n=[...t.diagnostics||[]],o={version:1,outputs:[],workspaceSetup:null};
|
|
752
|
-
if(t.status==="ready"&&n.length===0)try{o=no(t.lines,{targets:e.status==="ready"?kt(e.lines).targets:[],hasWorkspaceSetup:r.
|
|
753
|
-
status==="ready"&&Mt(r.lines).length>0})}catch(s){if(s?.name!=="Vibe64StackOperationError")throw s;n.push({code:Ta,message:s.
|
|
754
|
-
message,details:{...s.details,causeCode:s.code}})}let i=n.length>0?"invalid":o.outputs.length>0||o.workspaceSetup?"ready":
|
|
755
|
-
"unconfigured";return{contract:ro,status:i,stackHash:t.stackHash,sectionHash:t.sectionHash||"",estimatesHash:i==="ready"?
|
|
756
|
-
ve(o):"",source:t.source||null,outputs:o.outputs,workspaceSetup:o.workspaceSetup,fallbackReason:i==="invalid"?"invalid-e\
|
|
757
|
-
stimates":i==="unconfigured"?"not-declared":null,diagnostics:n}}var ro,Nt,Ta,Nf,xa,jf,ba=he(()=>{Xn();eo();We();ro="vibe\
|
|
758
|
-
64.resource-estimates.v1",Nt="Resource estimates",Ta="VIBE64_RESOURCE_ESTIMATES_INVALID",Nf=1024*1024,xa=1024*1024,jf=new Map(
|
|
759
|
-
[["Startup typical MiB","startupTypical"],["Startup high MiB","startupHigh"],["Running typical MiB","runningTypical"],["\
|
|
760
|
-
Running high MiB","runningHigh"],["Typical MiB","typical"],["High MiB","high"]])});function so(t,{path:e="genesis/stack.md#Integration setup"}={}){if(Array.isArray(t)||M(jt,e,"Integration setup requires \
|
|
761
|
-
exact Stack section lines."),ce(t))return null;let r=t.map(o=>o.trim()).filter(Boolean),n=r.length===1&&r[0].match(/^- Command with (.+?) in `([^`\r\n]+)`: (.+)$/u);
|
|
762
|
-
return n||M(jt,e,"Integration setup requires exactly one entry: - Command with `runtime` in `workdir`: `command` `argume\
|
|
763
|
-
nt`...; or - Nothing."),{argv:ue(n[3],jt,e,"Integration setup command"),workdir:ae(n[2],jt,e,"Integration setup workdir"),
|
|
764
|
-
runtimeRequirements:le(n[1],jt,e,"Integration setup runtimes")}}function _a({section:t={}}={}){let e=[...t.diagnostics||
|
|
765
|
-
[]],r=t.status==="ready"&&e.length===0?so(t.lines):null;return{contract:oo,status:e.length?"blocked":r?"ready":"unconfig\
|
|
766
|
-
ured",stackHash:t.stackHash,recipeHash:r?ve({version:1,command:r}):"",source:t.source||null,components:[...t.components||
|
|
767
|
-
[]],command:r,diagnostics:e}}var oo,io,jt,Aa=he(()=>{We();oo="vibe64.integration-setup.v1",io="Integration setup",jt="VI\
|
|
768
|
-
BE64_INTEGRATION_SETUP_INVALID"});var Ba={};Ya(Ba,{GENESIS_BLUEPRINT_PATH:()=>om,GENESIS_DERIVED_ARTIFACT_PATHS:()=>Im,GENESIS_MACHINE_CITY_PATH:()=>Fa,GENESIS_PROGRAM_CITY_PATH:()=>Ua,
|
|
769
|
-
HOST_CONTEXT_RESOLVER_DATA_ENV:()=>Ra,HOST_CONTEXT_RESOLVER_ENV:()=>Pa,VIBE64_APPLICATION_DEPLOYMENT_CONTRACT:()=>Hn,VIBE64_APPLICATION_DEPLOYMENT_SECTION:()=>Vn,
|
|
770
|
-
VIBE64_INTEGRATION_SETUP_CONTRACT:()=>oo,VIBE64_INTEGRATION_SETUP_SECTION:()=>io,VIBE64_OUTPUTS_CONTRACT:()=>Kn,VIBE64_OUTPUTS_SECTION:()=>Pt,
|
|
771
|
-
VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL:()=>xr,VIBE64_RESOURCE_ESTIMATES_CONTRACT:()=>ro,VIBE64_RESOURCE_ESTIMATES_SECTION:()=>Nt,
|
|
772
|
-
VIBE64_WORKSPACE_SETUP_CONTRACT:()=>Zn,VIBE64_WORKSPACE_SETUP_SECTION:()=>ht,addGenesisStack:()=>pm,applyGenesisTemplate:()=>Em,
|
|
773
|
-
assertGenesisPromptTask:()=>lo,genesisCommandShimDirectory:()=>po,genesisPackageBinDirectory:()=>ja,genesisParserEnvironment:()=>dm,
|
|
774
|
-
genesisPromptRequest:()=>Na,genesisPromptTask:()=>Ma,initializeGenesisProject:()=>fm,inspectGenesisAgentIntegrations:()=>vm,
|
|
775
|
-
inspectGenesisCollaboration:()=>Om,inspectGenesisDerivedArtifacts:()=>za,inspectGenesisEngineering:()=>Cm,inspectGenesisEnvironment:()=>bm,
|
|
776
|
-
inspectGenesisProject:()=>_m,inspectGenesisProjectFormat:()=>qa,inspectGenesisSkills:()=>mm,inspectGenesisStackComponents:()=>xm,
|
|
777
|
-
inspectGenesisStackSection:()=>Y,inspectGenesisSubsystems:()=>wm,inspectVibe64Deployment:()=>Tm,inspectVibe64IntegrationSetup:()=>Mm,
|
|
778
|
-
inspectVibe64Outputs:()=>km,inspectVibe64ProjectServices:()=>Nm,inspectVibe64ResourceEstimates:()=>Dm,inspectVibe64WorkspaceSetup:()=>jm,
|
|
779
|
-
listGenesisTemplates:()=>Am,parseVibe64DeploymentLines:()=>Gn,parseVibe64IntegrationSetupLines:()=>so,parseVibe64OutputsLines:()=>kt,
|
|
780
|
-
parseVibe64ProjectServicesLines:()=>Yn,parseVibe64ResourceEstimatesLines:()=>no,parseVibe64WorkspaceSetupLines:()=>Mt,refreshGenesisCities:()=>ym,
|
|
781
|
-
renderGenesisPrompt:()=>zm,resolveVibe64OutputParameters:()=>ha,setGenesisCollaboration:()=>Pm,setGenesisEngineeringProfile:()=>Rm,
|
|
782
|
-
syncGenesisAgentIntegrations:()=>gm,syncGenesisSkills:()=>hm,vibe64ConversationInstructions:()=>Sm,vibe64Driver:()=>Be,vibe64HostContextEnvironment:()=>$f,
|
|
783
|
-
vibe64HostContextRegistry:()=>Oa,vibe64HostContextResolverPath:()=>Da,withGenesisCommandShim:()=>um});import{existsSync as Ea}from"node:fs";
|
|
784
|
-
import{readFile as zf}from"node:fs/promises";import{createRequire as Lf}from"node:module";import ye from"node:path";import*as co from"genesis-compiler";
|
|
785
|
-
async function Oa(t){if(!ye.isAbsolute(t||""))throw new TypeError("Genesis host context requires an absolute runtime roo\
|
|
786
|
-
t.");let e=ye.join(t,"genesis-context");if(!br.has(e)){let r=sa(e).catch(n=>{throw br.delete(e),n});br.set(e,r)}return br.
|
|
787
|
-
get(e)}async function $f(t){let e=await Oa(t);return{[Pa]:Da(),[Ra]:JSON.stringify({registryPath:e.registryPath}),GENESIS_TURN_CONTEXT_ENABLED:"\
|
|
788
|
-
0"}}function Xe(t=""){return String(t||"").trim()}function lo(t,{required:e=!1}={}){let r=Xe(t);if(!r&&!e)return"";if(!cm.
|
|
789
|
-
has(r))throw new TypeError(r?`Unknown Genesis prompt task: ${r}.`:"Genesis prompt actions require an explicit task.");return r}
|
|
790
|
-
function Ma(t={}){return lo(t.genesisTask)||"work"}function Na(t={},e={}){return[t.conversationRequest,t.feedback,t.request,
|
|
791
|
-
t.plan,t.description,e.label].map(Xe).find(Boolean)||"Continue the requested project work."}function dm(t={}){return Qf(
|
|
792
|
-
t)}function ja(){let t=(Ca.resolve.paths("genesis-compiler")||[]).find(e=>Ea(ye.join(e,"genesis-compiler"))&&Ea(ye.join(
|
|
793
|
-
e,".bin","genesis")));if(!t)throw new Error("The installed Genesis compiler executable could not be located.");return ye.
|
|
794
|
-
join(t,".bin")}function po(){let t=Ca.resolve("@local/vibe64-genesis/server");return ye.resolve(ye.dirname(t),"../../bin")}
|
|
795
|
-
function Da(){return ye.resolve(po(),"vibe64-genesis-host-context")}function um(t=[]){let e=po(),r=ja();return[...(Array.
|
|
796
|
-
isArray(t)?t:[]).filter(o=>![e,r].includes(Xe(o))),e]}function lm(t={},{prompt:e=!1}={}){return{...t,...e?{hiddenStackPieces:sm}:
|
|
797
|
-
{},stackPackages:am}}function pm(t={}){return X(Ff,t)}function fm(t={}){return X(Bf,t)}function mm(t={}){return X(Kf,t)}
|
|
798
|
-
function hm(t={}){return X(rm,t)}function gm(t={}){return X(tm,t)}function vm(t={}){return X(Wf,t)}function wm(t={}){return X(
|
|
799
|
-
Xf,t)}function ym(t={}){return X(qf,t)}function za(){let t=Vf();if(t?.contract!==re.derivedArtifacts)throw new Error(`Ge\
|
|
800
|
-
nesis returned ${t?.contract||"no contract identity"}; expected ${re.derivedArtifacts}.`);let e=Array.isArray(t.artifacts)?
|
|
801
|
-
t.artifacts:[];if(!e.length||e.some(r=>!Xe(r?.path)))throw new Error("Genesis returned an invalid derived-artifact contr\
|
|
802
|
-
act.");return{...t,artifacts:e.map(r=>({...r}))}}async function X(t,e={},r={}){let n=Xe(e.projectRoot);if(!n||!ye.isAbsolute(
|
|
803
|
-
n))throw new TypeError("Genesis operations require an explicit absolute projectRoot.");return nm(n,()=>t(lm(e,r)))}async function Sm({
|
|
804
|
-
workdir:t,promptContext:e}){let r=Be(e);return e.scope==="ephemeral"?r:(await X(co.projectSessionContext,{projectRoot:t,
|
|
805
|
-
hostDriver:Be,hostDriverInput:e})).output}async function fe(t,e,r={}){let n=await X(t,r);if(n?.contract!==e)throw new Error(
|
|
806
|
-
`Genesis returned ${n?.contract||"no contract identity"}; expected ${e}.`);return n}function Y(t,e={}){return fe(r=>Jf({
|
|
807
|
-
...r,name:t}),re.stackSection,e)}async function xm(t={}){if((await qa(t)).status!=="current")throw Object.assign(new Error(
|
|
808
|
-
"The project needs a current Genesis format before its Stack can be inspected."),{code:"vibe64_stack_format_required"});
|
|
809
|
-
await zf(ye.join(t.projectRoot,"genesis/stack.md"),"utf8");let r=await Y(ht,t);return{components:r.components,stackHash:r.
|
|
810
|
-
stackHash}}async function Tm(t={}){let[e,r]=await Promise.all([Y(Vn,t),fe(uo,re.environment,t)]);return ua({environment:r,
|
|
811
|
-
section:e})}function bm(t={}){return fe(uo,re.environment,t)}function _m(t={}){return fe(ka,re.projectInspection,t)}function Am(t={}){
|
|
812
|
-
return fe(Yf,re.templates,t)}function Em(t={}){return fe(Uf,re.templateApplication,t)}function Cm(t={}){return fe(Gf,re.
|
|
813
|
-
engineering,t)}function Om(t={}){return fe(Hf,re.collaboration,t)}async function qa(t={}){let e=await X(ka,t);if(!Xe(e?.
|
|
814
|
-
projectFormat?.status))throw new Error("Genesis did not return a project-format status.");return{...e.projectFormat}}function Rm(t={}){
|
|
815
|
-
return fe(em,re.engineering,t)}function Pm(t={}){return fe(Zf,re.collaboration,t)}async function km(t={}){let[e,r,n,o]=await Promise.
|
|
816
|
-
all([Y(Pt,t),fe(uo,re.environment,t),Y(Nt,t),Y(ht,t)]);return{...ga({environment:r,section:e}),resourceEstimates:Tr({section:n,
|
|
817
|
-
outputsSection:e,workspaceSetupSection:o})}}async function Mm(t={}){let e=await Y(io,t);return _a({section:e})}async function Nm(t={}){
|
|
818
|
-
return wa(await Y(va,t))}async function jm(t={}){let[e,r,n]=await Promise.all([Y(ht,t),Y(Nt,t),Y(Pt,t)]);return{...await Sa(
|
|
819
|
-
{projectRoot:t.projectRoot,section:e}),resourceEstimates:Tr({section:r,outputsSection:n,workspaceSetupSection:e})}}async function Dm(t={}){
|
|
820
|
-
let[e,r,n]=await Promise.all([Y(Nt,t),Y(Pt,t),Y(ht,t)]);return Tr({section:e,outputsSection:r,workspaceSetupSection:n})}
|
|
821
|
-
async function zm({action:t={},environment:e=process.env,input:r={},projectRoot:n}={}){let o=Ma(t),i=Na(r,t),s=o,a;try{a=
|
|
822
|
-
await X(ao,{environment:e,projectRoot:n,request:i,sessionContextInstalled:!0,task:s},{prompt:!0})}catch(c){if(c?.code===
|
|
823
|
-
"BLUEPRINT_INVALID"&&o!=="blueprint")s="blueprint",a=await X(ao,{environment:e,projectRoot:n,request:i,sessionContextInstalled:!0,
|
|
824
|
-
task:s},{prompt:!0});else if(c?.code==="BLUEPRINT_REQUIRED"&&o!=="start")s="start",a=await X(ao,{environment:e,projectRoot:n,
|
|
825
|
-
request:i,sessionContextInstalled:!0,task:s},{prompt:!0});else throw c}let d=lo(a.task)||s;return{context:{genesis:!0,requestedTask:o,
|
|
826
|
-
task:d,verificationCommands:a.verificationCommands,warnings:a.warnings},originalPrompt:i,prompt:a.prompt,promptId:Xe(t.promptId||
|
|
827
|
-
t.id)||d}}var Df,Ca,br,re,Ra,Pa,Ff,Uf,ao,qf,Bf,Hf,Vf,Gf,uo,ka,Wf,Kf,Jf,Xf,Yf,Qf,Zf,em,tm,rm,nm,om,im,sm,am,cm,La,Im,$a,Fa,
|
|
828
|
-
Ua,Ha=he(()=>{aa();la();Xn();ya();eo();yr();ba();Aa();Df=new URL("./../src/server/index.js",import.meta.url).href,Ca=Lf(
|
|
829
|
-
Df),br=new Map;({GENESIS_CONTRACTS:re,HOST_CONTEXT_RESOLVER_DATA_ENV:Ra,HOST_CONTEXT_RESOLVER_ENV:Pa,addStack:Ff,applyTemplate:Uf,
|
|
830
|
-
generatePrompt:ao,indexCodebase:qf,initialize:Bf,inspectCollaboration:Hf,inspectDerivedArtifacts:Vf,inspectEngineering:Gf,
|
|
831
|
-
inspectEnvironment:uo,inspectProject:ka,inspectAgentIntegrations:Wf,inspectSkills:Kf,inspectStackSection:Jf,inspectSubsystems:Xf,
|
|
832
|
-
listTemplates:Yf,parserEnvironment:Qf,setCollaboration:Zf,setEngineeringProfile:em,syncAgentIntegrations:tm,syncSkills:rm,
|
|
833
|
-
withTrustedGitRepository:nm}=co),om="genesis/blueprint.md",im=!1,sm=Object.freeze(["vue",...im?[]:["jskit-postgresql","p\
|
|
834
|
-
ostgresql"]]),am=Object.freeze(["genesis-stack"]),cm=new Set(["adopt","blueprint","describe","deslop","program","review",
|
|
835
|
-
"start","work"]);La=za(),Im=Object.freeze(La.artifacts.map(t=>t.path)),$a=new Map(La.artifacts.map(t=>[t.id,t])),Fa=$a.get(
|
|
836
|
-
"machine-city")?.path,Ua=$a.get("program-city")?.path;if(!Fa||!Ua)throw new Error("Genesis did not declare both City pro\
|
|
837
|
-
jection artifacts.")});function E(t){return String(t??"").trim()}function H(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var Km=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
|
|
838
|
-
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var G=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
839
|
-
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),Qm=new Set(Object.values(G)),Zm=new Set([G.CANCELLED,
|
|
840
|
-
G.COMPLETED,G.FAILED,G.INTERRUPTED,G.TIMED_OUT]),Za=new Set([G.ACTIVE,G.FINALIZING,G.STARTING]);var Id=Ae(pi(),1),Sd=Ae(Gt(),1),xd=Ae(tt(),1),Td=Ae(Lr(),1),bd=Ae(Ur(),1),_d=Ae(Wr(),1),Ad=Ae(Xt(),1),Ed=Ae(Ii(),1);import{createHash as Si}from"node:crypto";import{execFile as Od}from"node:child_process";import{open as Rd,rename as Mh,
|
|
841
|
-
rm as Nh,writeFile as jh}from"node:fs/promises";import Xr from"node:path";import{promisify as Pd}from"node:util";var $h=Pd(Od);var kd=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
383
|
+
`+r)}function we(t,e,r,n,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,we),t.emit(
|
|
384
|
+
"wsClientError",i,r,e)}else Ge(r,n,o,s)}});function _(t){return String(t??"").trim()}function U(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var Ju=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
|
|
385
|
+
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var B=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
386
|
+
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),Zu=new Set(Object.values(B)),el=new Set([B.CANCELLED,
|
|
387
|
+
B.COMPLETED,B.FAILED,B.INTERRUPTED,B.TIMED_OUT]),Ys=new Set([B.ACTIVE,B.FINALIZING,B.STARTING]);var wa=ae(Yn(),1),ya=ae(lt(),1),Ia=ae(Ce(),1),Sa=ae(Jt(),1),xa=ae(Qt(),1),Ta=ae(or(),1),ba=ae(mt(),1),_a=ae(so(),1);import{createHash as io}from"node:crypto";import{execFile as Ca}from"node:child_process";import{open as Ea,readFile as Nl,
|
|
388
|
+
rename as jl,rm as Dl,writeFile as zl}from"node:fs/promises";import ar from"node:path";import{promisify as Oa}from"node:util";var Ul=Oa(Ca);var Ra=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
842
389
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
843
390
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
844
391
|
ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
|
|
845
|
-
"unified_exec_zsh_fork","view_image"]);function
|
|
846
|
-
31||r===127})}function
|
|
847
|
-
Object.prototype||e===null}function
|
|
848
|
-
t))
|
|
392
|
+
"unified_exec_zsh_fork","view_image"]);function vt(t=""){return Array.from(String(t)).some(e=>{let r=e.codePointAt(0);return r<=
|
|
393
|
+
31||r===127})}function ao(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===
|
|
394
|
+
Object.prototype||e===null}function co(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.values(
|
|
395
|
+
t))co(e);return Object.freeze(t)}function Pa(t="",e={}){let r=new Error(_(t)||"Codex cannot prove the helper execution p\
|
|
849
396
|
olicy.");r.code="codex_policy_unenforceable",r.details=Object.freeze({...e});for(let[n,o]of Object.entries(r.details))["\
|
|
850
|
-
code","details","message","name"].includes(n)||(r[n]=o);return r}function
|
|
851
|
-
51.0",disabledFeatures:r=
|
|
852
|
-
1024,hookMaxCount:a=256,hookErrorMaxCount:
|
|
853
|
-
1024}={},createError:
|
|
854
|
-
f8")}catch{throw
|
|
855
|
-
n oversized ${v}.`)}function S(
|
|
856
|
-
annot verify the app-server connection generation.");let
|
|
857
|
-
|
|
858
|
-
currentHelperExecutionContext!="function")throw
|
|
859
|
-
currentHelperExecutionContext(),v=
|
|
860
|
-
v)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw
|
|
861
|
-
{accountIdentitySignature:g,cwd:v,executionMode:"helper"})}function
|
|
862
|
-
if(!
|
|
863
|
-
let
|
|
864
|
-
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?
|
|
865
|
-
"function")throw
|
|
866
|
-
let
|
|
867
|
-
er version. Update Codex and retry.",{minimumVersion:e});let g=v.join("."),
|
|
868
|
-
-1&&v[
|
|
869
|
-
nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function
|
|
870
|
-
|
|
871
|
-
if(
|
|
872
|
-
configuration.");let v=Object.keys(
|
|
873
|
-
ceived an oversized or invalid MCP server inventory.");return v.sort()}function
|
|
874
|
-
!Array.isArray(
|
|
875
|
-
"Codex helper execution received an unexpected hook inventory.");let v=
|
|
876
|
-
isArray(v.hooks)||!Array.isArray(v.errors)||v.hooks.length>a||v.errors.length>
|
|
877
|
-
an incomplete hook inventory.");if(v.errors.length>0)throw
|
|
878
|
-
ry has errors.",{hookErrorCount:v.errors.length});let g=v.hooks.map(
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
(
|
|
883
|
-
ed hook inventory.");return{fingerprint:
|
|
884
|
-
hookKeys:v=[],mcpServerNames:g=[]}={}){let
|
|
885
|
-
v.map(
|
|
886
|
-
include_permissions_instructions:!1,...
|
|
887
|
-
fromEntries(g.map(
|
|
397
|
+
code","details","message","name"].includes(n)||(r[n]=o);return r}function ka({clientName:t="jskit",minimumVersion:e="0.1\
|
|
398
|
+
51.0",disabledFeatures:r=Ra,limits:{userAgentMaxLength:n=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
|
|
399
|
+
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:l=512*
|
|
400
|
+
1024}={},createError:p=Pa}={}){let h=new WeakSet;function I(f,m,v){let g=0;try{g=Buffer.byteLength(JSON.stringify(f),"ut\
|
|
401
|
+
f8")}catch{throw p(`Codex helper execution received an invalid ${v}.`)}if(g>m)throw p(`Codex helper execution received a\
|
|
402
|
+
n oversized ${v}.`)}function S(f){if(typeof f?.currentConnectionGeneration!="function")throw p("Codex helper execution c\
|
|
403
|
+
annot verify the app-server connection generation.");let m=f.currentConnectionGeneration();if(!Number.isSafeInteger(m)||
|
|
404
|
+
m<=0)throw p("Codex helper execution found no active app-server connection.");return m}async function C(f){if(typeof f?.
|
|
405
|
+
currentHelperExecutionContext!="function")throw p("Codex helper execution requires its dedicated isolated provider.");let m=await f.
|
|
406
|
+
currentHelperExecutionContext(),v=_(m?.cwd),g=_(m?.accountIdentitySignature);if(m?.executionMode!=="helper"||!v||!ar.isAbsolute(
|
|
407
|
+
v)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw p("Codex helper runtime isolation could not be verified.");return Object.freeze(
|
|
408
|
+
{accountIdentitySignature:g,cwd:v,executionMode:"helper"})}function P(f=""){let m=_(f).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
|
|
409
|
+
if(!m)return null;let v=m.slice(1).map(g=>Number.parseInt(g,10));return v.every(Number.isSafeInteger)?v:null}function j(f=""){
|
|
410
|
+
let m=_(f);if(!m||m.length>n||vt(m))return null;let v=`${t}/`;if(!m.startsWith(v))return null;let g=m.slice(v.length).match(
|
|
411
|
+
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?P(g[1]):null}function L(f){if(typeof f?.currentServerInfo!=
|
|
412
|
+
"function")throw p("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
|
|
413
|
+
let m=_(f.currentServerInfo()?.userAgent),v=j(m);if(!v)throw p("Codex helper execution received an unrecognised app-serv\
|
|
414
|
+
er version. Update Codex and retry.",{minimumVersion:e});let g=v.join("."),A=P(e),b=v.findIndex((M,J)=>M!==A[J]);if(b!==
|
|
415
|
+
-1&&v[b]<A[b])throw p(`Codex helper execution requires app-server ${e} or newer; current version is ${g}. Update Codex a\
|
|
416
|
+
nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function $(f=null){if(!ao(
|
|
417
|
+
f?.config))throw p("Codex helper execution could not read the effective app-server configuration.");let m=f.config.mcp_servers;
|
|
418
|
+
if(m==null)return[];if(I(m,i,"MCP configuration"),!ao(m))throw p("Codex helper execution received an invalid MCP server \
|
|
419
|
+
configuration.");let v=Object.keys(m);if(v.length>o||v.some(g=>!g||g.length>s||vt(g)))throw p("Codex helper execution re\
|
|
420
|
+
ceived an oversized or invalid MCP server inventory.");return v.sort()}function K(f=null,m=""){if(I(f,l,"hook inventory"),
|
|
421
|
+
!Array.isArray(f?.data))throw p("Codex helper execution could not enumerate app-server hooks.");if(f.data.length!==1)throw p(
|
|
422
|
+
"Codex helper execution received an unexpected hook inventory.");let v=f.data[0];if(_(v?.cwd)!==m||_(v?.cwd).length>d||!Array.
|
|
423
|
+
isArray(v.hooks)||!Array.isArray(v.errors)||v.hooks.length>a||v.errors.length>c)throw p("Codex helper execution received\
|
|
424
|
+
an incomplete hook inventory.");if(v.errors.length>0)throw p("Codex helper execution cannot continue while hook discove\
|
|
425
|
+
ry has errors.",{hookErrorCount:v.errors.length});let g=v.hooks.map(b=>{let M=_(b?.key),J=_(b?.currentHash),be=_(b?.handlerType),
|
|
426
|
+
Yr=_(b?.sourcePath);if(!M||[M,J,be,Yr].some(Qr=>Qr.length>d||vt(Qr)))throw p("Codex helper execution found an invalid ho\
|
|
427
|
+
ok inventory entry.");if(b?.isManaged===!0&&b?.enabled===!0)throw p("Codex helper execution cannot disable a managed hoo\
|
|
428
|
+
k.");return{currentHash:J,enabled:b?.enabled===!0,handlerType:be,isManaged:b?.isManaged===!0,key:M,sourcePath:Yr}}).sort(
|
|
429
|
+
(b,M)=>b.key.localeCompare(M.key)),A=JSON.stringify(g);if(A.length>u)throw p("Codex helper execution received an oversiz\
|
|
430
|
+
ed hook inventory.");return{fingerprint:A,hookKeys:g.filter(b=>!b.isManaged).map(b=>b.key)}}function F({effort:f="",summary:m="",
|
|
431
|
+
hookKeys:v=[],mcpServerNames:g=[]}={}){let A={features:Object.fromEntries(r.map(M=>[M,!1])),hooks:{state:Object.fromEntries(
|
|
432
|
+
v.map(M=>[M,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
|
|
433
|
+
include_permissions_instructions:!1,...f?{model_reasoning_effort:f}:{},...m?{model_reasoning_summary:m}:{},mcp_servers:Object.
|
|
434
|
+
fromEntries(g.map(M=>[M,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
|
|
888
435
|
mcp:{enabled:!1},skills:{enabled:!1}},project_doc_max_bytes:0,shell_environment_policy:{inherit:"none",set:{}},skills:{include_instructions:!1},
|
|
889
|
-
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},
|
|
890
|
-
|
|
891
|
-
unction")throw
|
|
892
|
-
{cwd:g.cwd,includeLayers:!1});if(S(
|
|
893
|
-
listHooks([g.cwd]);if(S(
|
|
894
|
-
|
|
895
|
-
hookKeys,mcpServerNames:
|
|
896
|
-
[...
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
let g=
|
|
900
|
-
ot retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return
|
|
901
|
-
!0,
|
|
902
|
-
await
|
|
903
|
-
deleteThread!="function")throw
|
|
904
|
-
g=await
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
thread:g,threadId:
|
|
908
|
-
"function"||typeof
|
|
909
|
-
-server thread.");let g=
|
|
910
|
-
|
|
911
|
-
config.model_reasoning_summary});if(!
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
hookKeys
|
|
915
|
-
|
|
916
|
-
null,dynamicTools:[],environments:[],model:
|
|
917
|
-
return{...
|
|
918
|
-
baseInstructions,config:
|
|
919
|
-
sandbox:
|
|
436
|
+
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},b=co(A);return h.add(
|
|
437
|
+
b),b}async function V(f,{effort:m="",summary:v=""}={}){if(L(f),typeof f?.readConfig!="function"||typeof f?.listHooks!="f\
|
|
438
|
+
unction")throw p("Codex helper execution cannot inventory configuration and hooks.");let g=await C(f),A=S(f),b=await f.readConfig(
|
|
439
|
+
{cwd:g.cwd,includeLayers:!1});if(S(f)!==A)throw p("Codex app-server reconnected during helper policy verification.");let M=await f.
|
|
440
|
+
listHooks([g.cwd]);if(S(f)!==A)throw p("Codex app-server reconnected during helper policy verification.");let J=$(b),be=K(
|
|
441
|
+
M,g.cwd);return Object.freeze({accountIdentitySignature:g.accountIdentitySignature,config:F({effort:m,summary:v,hookKeys:be.
|
|
442
|
+
hookKeys,mcpServerNames:J}),connectionGeneration:A,executionCwd:g.cwd,hookFingerprint:be.fingerprint,hookKeys:Object.freeze(
|
|
443
|
+
[...be.hookKeys]),mcpServerNames:Object.freeze([...J])})}function Z(f=null,m=null){return f?.accountIdentitySignature===
|
|
444
|
+
m?.accountIdentitySignature&&f?.connectionGeneration===m?.connectionGeneration&&f?.executionCwd===m?.executionCwd&&f?.hookFingerprint===
|
|
445
|
+
m?.hookFingerprint&&JSON.stringify(f?.mcpServerNames||[])===JSON.stringify(m?.mcpServerNames||[])}function ie(f,m,v=""){
|
|
446
|
+
let g=_(v);if(!m)return f.codexAppServerHelperThreadId=g,f.codexAppServerHelperThreadRetired=!0,f;let A=p("Codex could n\
|
|
447
|
+
ot retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return A.codexAppServerHelperThreadCleanupRequired=
|
|
448
|
+
!0,A.codexAppServerHelperThreadId=g,A}async function Te({error:f=null,provider:m=null,threadId:v=""}={}){let g=null;try{
|
|
449
|
+
await m.deleteThread(v)}catch(A){g=A}throw ie(f,g,v)}async function zt(f,m){if(typeof f?.startThread!="function"||typeof f?.
|
|
450
|
+
deleteThread!="function")throw p("Codex helper execution cannot own and clean up its app-server thread.");let v=await m(),
|
|
451
|
+
g=await f.startThread(v.settings),A=_(g?.id);if(!A)throw p("Codex app-server did not return a helper thread id.");try{let b=await V(
|
|
452
|
+
f,{effort:v.enforcement.config.model_reasoning_effort,summary:v.enforcement.config.model_reasoning_summary});if(!Z(v.enforcement,
|
|
453
|
+
b))throw p("Codex execution surfaces changed while the helper thread was starting.");return Object.freeze({enforcement:b,
|
|
454
|
+
thread:g,threadId:A})}catch(b){await Te({error:b,provider:f,threadId:A})}}async function w(f,m,v){if(typeof f?.resumeThread!=
|
|
455
|
+
"function"||typeof f?.deleteThread!="function")throw p("Codex helper execution cannot safely resume and clean up its app\
|
|
456
|
+
-server thread.");let g=_(m);if(!g)throw p("Codex helper resume requires a controller-owned thread id.");let A=await v(),
|
|
457
|
+
b=A.enforcement,M=await f.resumeThread(g,A.settings);try{let J=await V(f,{effort:b.config.model_reasoning_effort,summary:b.
|
|
458
|
+
config.model_reasoning_summary});if(!Z(b,J))throw p("Codex execution surfaces changed while the helper thread was resumi\
|
|
459
|
+
ng.");return Object.freeze({enforcement:J,thread:M,threadId:g})}catch(J){await Te({error:J,provider:f,threadId:g})}}function y({
|
|
460
|
+
configResult:f,hookResult:m,workdir:v,effort:g="",summary:A=""}){let b=$(f),M=K(m,v);return F({effort:g,summary:A,hookKeys:M.
|
|
461
|
+
hookKeys,mcpServerNames:b})}function T({approvalPolicy:f,baseInstructions:m,config:v,cwd:g,effectiveSettings:A,sandbox:b,
|
|
462
|
+
systemPrompt:M}){return{allowProviderModelFallback:!1,approvalPolicy:f,baseInstructions:m,config:v,cwd:g,systemPrompt:M||
|
|
463
|
+
null,dynamicTools:[],environments:[],model:A.model,runtimeWorkspaceRoots:[],sandbox:b,selectedCapabilityRoots:[]}}function R(f,m){
|
|
464
|
+
return{...f,sessionStartSource:"startup",threadSource:m}}function E(f){return{approvalPolicy:f.approvalPolicy,baseInstructions:f.
|
|
465
|
+
baseInstructions,config:f.config,cwd:f.cwd,systemPrompt:f.systemPrompt,model:f.model,runtimeWorkspaceRoots:f.runtimeWorkspaceRoots,
|
|
466
|
+
sandbox:f.sandbox}}function O({approvalPolicy:f,cwd:m,effectiveSettings:v,outputSchema:g}){let A={approvalPolicy:f,cwd:m,
|
|
920
467
|
environments:[],model:v.model,outputSchema:g,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
|
|
921
|
-
none"};return v.request.reasoning&&(
|
|
922
|
-
inspect:
|
|
923
|
-
start:
|
|
924
|
-
1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(
|
|
925
|
-
n is unavailable. Reconnect Codex and retry.");return
|
|
926
|
-
Codex authentication value",maxLength:
|
|
927
|
-
_auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return
|
|
928
|
-
"sha256").update(`${e}\0`,"utf8").update(
|
|
929
|
-
return
|
|
930
|
-
try{u=await
|
|
931
|
-
ed Codex authentication record is invalid. Reconnect Codex and retry.");let
|
|
932
|
-
bytesRead:S}=await u.read(
|
|
933
|
-
selected Codex authentication record is too large. Reconnect Codex and retry.");let I=JSON.parse(
|
|
934
|
-
"utf8"));if(!
|
|
935
|
-
dex_helper_auth_`)?
|
|
936
|
-
Reconnect Codex and retry.")}finally{await u?.close?.().catch(()=>null)}}async function d
|
|
937
|
-
if(!u||!
|
|
938
|
-
ct Codex and retry.");let
|
|
939
|
-
|
|
940
|
-
ccess token",maxLength:
|
|
941
|
-
return Object.freeze({accessToken:S,accountId:I,authMode:"chatgpt",identitySignature:
|
|
942
|
-
S)})}if(["apikey","api_key"].includes(
|
|
943
|
-
{apiKey:
|
|
944
|
-
d`,"The selected Codex authentication mode is unsupported. Reconnect Codex and retry.")}return{error:n,identitySignature:
|
|
945
|
-
readRecord:a,readSelected:
|
|
946
|
-
_COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable"}={}){let a="linux-proc",
|
|
947
|
-
freeze({RUNNING:"running",STOPPED:"stopped"}),
|
|
948
|
-
invalid",MISMATCH:"mismatch"});function u(w,y){let
|
|
949
|
-
return!!(Number.isSafeInteger(Number(w.pid))&&Number(w.pid)>0&&
|
|
950
|
-
function
|
|
951
|
-
function
|
|
952
|
-
kill(-y,0),!0}catch{return!1}}function I(w,y){let
|
|
953
|
-
|
|
954
|
-
""),
|
|
955
|
-
|
|
956
|
-
test(
|
|
957
|
-
y.commandHash),platform:
|
|
958
|
-
version||0)}}function
|
|
468
|
+
none"};return v.request.reasoning&&(A.effort=v.thinking),A}return Object.freeze({assertCompatibility:L,executionContext:C,
|
|
469
|
+
inspect:V,configuration:y,hasConfiguration:f=>h.has(f),threadSettings:T,threadStartSettings:R,threadResumeSettings:E,turnSettings:O,
|
|
470
|
+
start:zt,resume:w})}var ql=ka();var ir=1024*1024,Ma=256*1024,uo=512,Na=128,ja=16*1024;function lo({errorPrefix:t="",identityNamespace:e="codex-account-v\
|
|
471
|
+
1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",u=""){let l=new Error(_(u)||"Codex helper authenticatio\
|
|
472
|
+
n is unavailable. Reconnect Codex and retry.");return l.code=_(d)||`${t}codex_helper_auth_unavailable`,l}function o(d,{label:u="\
|
|
473
|
+
Codex authentication value",maxLength:l=0}={}){if(typeof d!="string"||d.length===0||d.length>l)throw n(`${t}codex_helper\
|
|
474
|
+
_auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`sha256:${io(
|
|
475
|
+
"sha256").update(`${e}\0`,"utf8").update(_(d),"utf8").update("\0","utf8").update(String(u||""),"utf8").digest("hex")}`}function i(d=""){
|
|
476
|
+
return io("sha256").update(`${r}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){let u=null;
|
|
477
|
+
try{u=await Ea(d,"r");let l=await u.stat();if(!l.isFile()||l.size>ir)throw n(`${t}codex_helper_auth_invalid`,"The select\
|
|
478
|
+
ed Codex authentication record is invalid. Reconnect Codex and retry.");let p=Buffer.alloc(ir+1),h=0;for(;h<p.length;){let{
|
|
479
|
+
bytesRead:S}=await u.read(p,h,p.length-h,null);if(S===0)break;h+=S}if(h>ir)throw n(`${t}codex_helper_auth_invalid`,"The \
|
|
480
|
+
selected Codex authentication record is too large. Reconnect Codex and retry.");let I=JSON.parse(p.subarray(0,h).toString(
|
|
481
|
+
"utf8"));if(!U(I))throw new Error("invalid authentication record");return I}catch(l){throw l?.code?.startsWith?.(`${t}co\
|
|
482
|
+
dex_helper_auth_`)?l:n(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. \
|
|
483
|
+
Reconnect Codex and retry.")}finally{await u?.close?.().catch(()=>null)}}async function c(d={}){let u=_(d.toolHomeSource);
|
|
484
|
+
if(!u||!ar.isAbsolute(u))throw n(`${t}codex_helper_auth_unavailable`,"The selected Codex account is unavailable. Reconne\
|
|
485
|
+
ct Codex and retry.");let l=await a(ar.join(u,".codex","auth.json")),p=_(l.auth_mode).toLowerCase();if(p==="chatgpt"){let h=U(
|
|
486
|
+
l.tokens)?l.tokens:{},I=o(h.account_id,{label:"Codex account identity",maxLength:uo}),S=o(h.access_token,{label:"Codex a\
|
|
487
|
+
ccess token",maxLength:Ma}),C=h.chatgpt_plan_type??h.plan_type,P=C==null||C===""?"":o(C,{label:"Codex plan type",maxLength:Na});
|
|
488
|
+
return Object.freeze({accessToken:S,accountId:I,authMode:"chatgpt",identitySignature:s("chatgpt",I),planType:P,secretSignature:i(
|
|
489
|
+
S)})}if(["apikey","api_key"].includes(p)){let h=o(l.OPENAI_API_KEY,{label:"Codex API key",maxLength:ja});return Object.freeze(
|
|
490
|
+
{apiKey:h,authMode:"apiKey",identitySignature:s("apiKey",h),secretSignature:i(h)})}throw n(`${t}codex_helper_auth_invali\
|
|
491
|
+
d`,"The selected Codex authentication mode is unsupported. Reconnect Codex and retry.")}return{error:n,identitySignature:s,
|
|
492
|
+
readRecord:a,readSelected:c}}import{mkdtemp as Vl,open as Gl,readFile as cr,readdir as Da,rm as Wl}from"node:fs/promises";import{setTimeout as po}from"node:timers/promises";function dr({runtimeTokenEnvironmentName:t="JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION\
|
|
493
|
+
_COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable"}={}){let a="linux-proc",c=Object.
|
|
494
|
+
freeze({RUNNING:"running",STOPPED:"stopped"}),d=Object.freeze({ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"\
|
|
495
|
+
invalid",MISMATCH:"mismatch"});function u(w,y){let T=Number(w);return Number.isSafeInteger(T)&&T>0?T:y}function l(w={}){
|
|
496
|
+
return!!(Number.isSafeInteger(Number(w.pid))&&Number(w.pid)>0&&P(w.processIdentity)&&[c.RUNNING,c.STOPPED].includes(w.processState))}
|
|
497
|
+
function p(w){let y=Number(w);if(!Number.isSafeInteger(y)||y<=0)return!1;try{return process.kill(y,0),!0}catch{return!1}}
|
|
498
|
+
function h(w){let y=Number(w);if(!Number.isSafeInteger(y)||y<=0)return!1;if(process.platform==="win32")return p(y);try{return process.
|
|
499
|
+
kill(-y,0),!0}catch{return!1}}function I(w,y){let T=Number(w),R=process.platform==="win32"?T:-T;try{return process.kill(
|
|
500
|
+
R,y),!0}catch(E){if(!["ESRCH","EPERM"].includes(String(E?.code||"")))throw E;return!1}}function S(w=""){let y=String(w||
|
|
501
|
+
""),T=y.lastIndexOf(")");if(T<0)return null;let R=y.slice(T+1).trim().split(/\s+/u),E=String(R[0]||""),O=Number(R[1]),f=Number(
|
|
502
|
+
R[2]),m=String(R[19]||"");return!/^[A-Z]$/u.test(E)||!Number.isSafeInteger(O)||O<0||!Number.isSafeInteger(f)||f<=0||!/^\d+$/u.
|
|
503
|
+
test(m)?null:{parentPid:O,processGroupId:f,startTimeTicks:m,state:E}}function C(w={}){let y=U(w)?w:{};return{commandHash:_(
|
|
504
|
+
y.commandHash),platform:_(y.platform),runtimeToken:_(y.runtimeToken),startTimeTicks:_(y.startTimeTicks),version:Number(y.
|
|
505
|
+
version||0)}}function P(w={}){let y=C(w);return!!(y.version===1&&y.platform===a&&/^[a-f0-9]{12}$/u.test(y.commandHash)&&
|
|
959
506
|
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(y.runtimeToken)&&/^\d+$/u.test(y.startTimeTicks))}
|
|
960
|
-
function
|
|
961
|
-
slice(
|
|
962
|
-
if(!
|
|
963
|
-
()=>""),
|
|
964
|
-
v?.code||"")==="ENOENT")continue;
|
|
965
|
-
let y=Object.values(
|
|
966
|
-
w.processGroupIds:[]).map(Number).filter(
|
|
967
|
-
processGroupIds:[],status:
|
|
968
|
-
platform!=="linux")return{processGroupIds:[],status:
|
|
969
|
-
filter(({processGroupId:g})=>g===
|
|
970
|
-
continue;let
|
|
971
|
-
|
|
972
|
-
status:
|
|
973
|
-
for(let g of v)if(
|
|
974
|
-
processGroupIds:[],status:
|
|
975
|
-
{processGroupIds:v,status:
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
"function"?
|
|
981
|
-
w.pid),
|
|
982
|
-
w,
|
|
983
|
-
inspection:g,signaledProcessGroups:
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
pid:y=null,reportedIdentity:
|
|
995
|
-
|
|
996
|
-
identity could not be captured.`);throw g.code=n,g}let v=S(await
|
|
997
|
-
|
|
998
|
-
startTimeTicks:v.startTimeTicks,version:1}}return Object.freeze({normalize:
|
|
999
|
-
inspect:
|
|
507
|
+
function j(w=Buffer.alloc(0),y=""){let T=`${y}=`;for(let R of w.toString("utf8").split("\0"))if(R.startsWith(T))return R.
|
|
508
|
+
slice(T.length);return""}async function L(){let w=[],y=await Da("/proc",{withFileTypes:!0}).catch(()=>[]);for(let T of y){
|
|
509
|
+
if(!T.isDirectory()||!/^\d+$/u.test(T.name))continue;let R=Number(T.name),E=await cr(`/proc/${T.name}/stat`,"utf8").catch(
|
|
510
|
+
()=>""),O=S(E);if(!O||O.state==="Z")continue;let f=null,m=!0;try{f=await cr(`/proc/${T.name}/environ`)}catch(v){if(String(
|
|
511
|
+
v?.code||"")==="ENOENT")continue;m=!1}w.push({...O,environment:f,environmentReadable:m,pid:R})}return w}function $(w={}){
|
|
512
|
+
let y=Object.values(d).includes(w?.status)?w.status:d.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(w?.processGroupIds)?
|
|
513
|
+
w.processGroupIds:[]).map(Number).filter(T=>Number.isSafeInteger(T)&&T>0))],status:y}}async function K(w={}){if(!l(w))return{
|
|
514
|
+
processGroupIds:[],status:d.INVALID};if(w.processState===c.STOPPED)return{processGroupIds:[],status:d.ABSENT};if(process.
|
|
515
|
+
platform!=="linux")return{processGroupIds:[],status:d.AMBIGUOUS};let y=w.processIdentity,T=await L(),R=Number(w.pid),E=T.
|
|
516
|
+
filter(({processGroupId:g})=>g===R),O=[],f=E.some(({environmentReadable:g})=>!g);for(let g of T){if(!g.environmentReadable)
|
|
517
|
+
continue;let A=j(g.environment,t),b=j(g.environment,e);A===y.runtimeToken&&b===y.commandHash&&O.push(g)}let m=O.find(({pid:g})=>g===
|
|
518
|
+
R);if(m&&m.startTimeTicks!==y.startTimeTicks)return{processGroupIds:[],status:d.AMBIGUOUS};if(O.length===0)return f?{processGroupIds:[],
|
|
519
|
+
status:d.AMBIGUOUS}:{processGroupIds:[],status:E.length>0||h(R)?d.MISMATCH:d.ABSENT};let v=[...new Set(O.map(({processGroupId:g})=>g))];
|
|
520
|
+
for(let g of v)if(T.filter(b=>b.processGroupId===g).some(b=>!b.environmentReadable||!O.some(({pid:M})=>M===b.pid)))return{
|
|
521
|
+
processGroupIds:[],status:d.AMBIGUOUS};return E.some(g=>!O.some(({pid:A})=>A===g.pid))?{processGroupIds:[],status:d.AMBIGUOUS}:
|
|
522
|
+
{processGroupIds:v,status:d.EXACT}}async function F(w={},y={}){let T=typeof y.processIdentityInspector=="function"?y.processIdentityInspector:
|
|
523
|
+
K;return $(await T(w))}async function V(w={},y={},T=0){let R=Date.now()+T,E=await F(w,y);for(;Date.now()<R&&E.status===d.
|
|
524
|
+
EXACT;)await po(100),E=await F(w,y);return E}async function Z(w={},y={}){let T=u(y.processIdentitySettleTimeoutMs,1e3),R=u(
|
|
525
|
+
y.processIdentitySettlePollMs,25),E=Date.now()+T,O=await F(w,y);for(;O.status===d.AMBIGUOUS&&Date.now()<E;)await po(Math.
|
|
526
|
+
min(R,Math.max(1,E-Date.now()))),O=await F(w,y);return O}async function ie(w={},y="SIGTERM",T={}){let R=typeof T.signalProcessGroup==
|
|
527
|
+
"function"?T.signalProcessGroup:I,E=await Z(w,T);if(E.status!==d.EXACT)return{inspection:E,signaledProcessGroups:[]};let O=Number(
|
|
528
|
+
w.pid),f=[...E.processGroupIds.filter(v=>v!==O),...E.processGroupIds.filter(v=>v===O)],m=[];for(let v of f){let g=await Z(
|
|
529
|
+
w,T);if(g.status===d.ABSENT||g.status===d.MISMATCH)return{inspection:g,signaledProcessGroups:m};if(g.status!==d.EXACT)return{
|
|
530
|
+
inspection:g,signaledProcessGroups:m};g.processGroupIds.includes(v)&&(R(v,y),m.push(v))}return{inspection:await Z(w,T),signaledProcessGroups:m}}
|
|
531
|
+
async function Te(w={},y={}){if(!l(w))return{identityStatus:d.INVALID,processExitVerified:!1,stopped:!1};if(w.processState===
|
|
532
|
+
c.STOPPED&&w.processExitVerifiedAt)return{alreadyStopped:!0,identityStatus:d.ABSENT,processExitVerified:!0,stopped:!1};let T=await Z(
|
|
533
|
+
w,y);if(T.status===d.ABSENT||T.status===d.MISMATCH)return{identityStatus:T.status,processExitVerified:!0,stopped:!1};if(T.
|
|
534
|
+
status!==d.EXACT)return{identityStatus:T.status,processExitVerified:!1,stopped:!1};let R=await ie(w,"SIGTERM",y);if(R.inspection.
|
|
535
|
+
status===d.AMBIGUOUS)return{identityStatus:R.inspection.status,processExitVerified:!1,signaledProcessGroups:R.signaledProcessGroups,
|
|
536
|
+
stopped:!1};let E=await V(w,y,u(y.termTimeoutMs,3e3)),O=[...R.signaledProcessGroups];if(E.status===d.EXACT){let m=await ie(
|
|
537
|
+
w,"SIGKILL",y);if(O=[...new Set([...O,...m.signaledProcessGroups])],m.inspection.status===d.AMBIGUOUS)return{identityStatus:m.
|
|
538
|
+
inspection.status,processExitVerified:!1,signaledProcessGroups:O,stopped:!1};E=await V(w,y,u(y.killTimeoutMs,1e3))}let f=[
|
|
539
|
+
d.ABSENT,d.MISMATCH].includes(E.status);return{descendantProcessGroups:O.filter(m=>m!==Number(w.pid)),identityStatus:E.status,
|
|
540
|
+
pid:Number(w.pid),processExitVerified:f,signaledProcessGroups:O,stopped:f&&O.length>0}}async function zt({commandHash:w="",
|
|
541
|
+
pid:y=null,reportedIdentity:T=null,runtimeToken:R=""}={}){let E=_(w),O=_(R),f=C(T);if(P(f)&&f.commandHash===E&&f.runtimeToken===
|
|
542
|
+
O)return f;let m=Number(y);if(process.platform!=="linux"||!Number.isSafeInteger(m)||m<=0){let g=new Error(`${r} process \
|
|
543
|
+
identity could not be captured.`);throw g.code=n,g}let v=S(await cr(`/proc/${m}/stat`,"utf8").catch(()=>""));if(!v||v.processGroupId!==
|
|
544
|
+
m){let g=new Error(`${r} process identity could not be captured.`);throw g.code=n,g}return{commandHash:E,platform:a,runtimeToken:O,
|
|
545
|
+
startTimeTicks:v.startTimeTicks,version:1}}return Object.freeze({normalize:C,isValid:P,normalizeInspection:$,capture:zt,
|
|
546
|
+
inspect:F,stop:Te,isProcessAlive:p})}var wt=(t,e,r,n={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(r),...n}),za=Object.freeze([Object.freeze(
|
|
1000
547
|
{id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
|
|
1001
|
-
webSearch:!1,models:Object.freeze([
|
|
1002
|
-
|
|
548
|
+
webSearch:!1,models:Object.freeze([wt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
|
|
549
|
+
wt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0})])}),Object.freeze({id:"zai-coding-plan",baseUrl:"h\
|
|
1003
550
|
ttps://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,webSearch:!1,models:Object.
|
|
1004
|
-
freeze([
|
|
551
|
+
freeze([wt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai",
|
|
1005
552
|
baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,webSearch:!1,
|
|
1006
|
-
models:Object.freeze([
|
|
1007
|
-
return
|
|
1008
|
-
deepseek
|
|
1009
|
-
UNREACHABLE:"unreachable"}),
|
|
1010
|
-
SUSPECT:"suspect"})
|
|
1011
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
1012
|
-
in",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
1013
|
-
versionName:"1.0.0"});var
|
|
1014
|
-
"metadata","migrations","runtime","vite"]);var
|
|
1015
|
-
|
|
553
|
+
models:Object.freeze([wt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function ye(t){
|
|
554
|
+
return za.find(e=>e.id===t)||null}var Zl=32*1024*1024,ep=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
|
|
555
|
+
deepseek:ye("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":ye("zai-coding-plan").baseUrl,zai:ye("zai").baseUrl});var sp=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexProcess.js",import.meta.url).href;var pp=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),fp=dr();var Fa=Object.freeze({UNIX:"unix"});var hp=process.platform==="linux"?107:103,mp=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
556
|
+
UNREACHABLE:"unreachable"}),gp=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
|
|
557
|
+
SUSPECT:"suspect"}),$a=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),vp=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
|
|
558
|
+
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var ef=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),tf=lo().error;var rf=32*1024,nf=2*1024*1024;var of=64*1024,sf=2*1024*1024,af=4*1024*1024;import{createRequire as fc}from"node:module";var pc=new URL("./../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var ch=fc(pc);var uh=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function q(t,{fallback:e=""}={}){return String(t||"").trim()||e}function Ye(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}var lh=Object.freeze(["bundled","dev_server"]),ph=Object.freeze(["capacitor"]),fh=Object.freeze({callbackPath:"/auth/log\
|
|
559
|
+
in",customScheme:"",appLinkDomains:Object.freeze([])}),hh=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
|
|
560
|
+
versionName:"1.0.0"});var bh=new URL("./../../../@jskit-ai/kernel/server/support/appConfigFiles.js",import.meta.url).href;var Mh=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Nh=Object.freeze(["capabilities","kind",
|
|
561
|
+
"metadata","migrations","runtime","vite"]);var yr="/api",Vh=`${yr}/`,Gh=`${yr}/docs`,Wh=`${yr}/realtime`;var om=Object.freeze(["compact","medium","expanded"]);var rg=64*1024;var _t=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
562
|
+
ng=new Set(Object.values(_t)),og=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
|
|
1016
563
|
jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
1017
|
-
|
|
564
|
+
sg=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),ig=Object.freeze(["accountIde\
|
|
1018
565
|
ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
|
|
1019
|
-
Hash","terminalEnvHash","toolHomeSource","transport"]),
|
|
1020
|
-
|
|
1021
|
-
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function
|
|
1022
|
-
let{items:r}=e;if(
|
|
1023
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
1024
|
-
if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(
|
|
566
|
+
Hash","terminalEnvHash","toolHomeSource","transport"]),ag=Object.freeze(["userAgent"]);function H(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
567
|
+
kc(e)}function kc(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function Ir(t){return t!==null&&typeof t=="object"&&H(t.structure)&&H(t.operations)&&typeof t.validateWith=="function"&&
|
|
568
|
+
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function At(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
569
|
+
let{items:r}=e;if(Ir(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!="string")throw new Error(`Array field "${t}\
|
|
570
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Qe(t,e){
|
|
571
|
+
if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(Ir(r))return{kind:"schema",schema:r};if(!H(r)||typeof r.type!=
|
|
1025
572
|
"string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
|
|
1026
|
-
t.`);return{kind:"definition",definition:r}}function
|
|
573
|
+
t.`);return{kind:"definition",definition:r}}function Ct(t,e){let r=Object.hasOwn(e,"schema"),n=Object.hasOwn(e,"values"),
|
|
1027
574
|
o=Object.hasOwn(e,"additionalProperties");if(r&&n)throw new Error(`Object field "${t}" cannot define both schema and val\
|
|
1028
575
|
ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
|
|
1029
576
|
if(n&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
|
|
1030
|
-
s: true.`);if(r){if(!
|
|
1031
|
-
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return n?{kind:"map",valuesConfig:
|
|
1032
|
-
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function
|
|
1033
|
-
|
|
1034
|
-
$`,
|
|
1035
|
-
))?${
|
|
1036
|
-
0)}function
|
|
1037
|
-
1&&o<=12&&
|
|
1038
|
-
`temporalPrecision for "${e}" must be a non-negative integer.`);return r}}function
|
|
1039
|
-
t.length<=e}function
|
|
1040
|
-
if(typeof t!="string")return!1;let r=
|
|
1041
|
-
let r=
|
|
1042
|
-
"":`(?:\\.\\d{1,${t}})?`}function
|
|
1043
|
-
return`^${
|
|
1044
|
-
test(t))r=Number(t);else return null;return!Number.isSafeInteger(r)||r<-e||r>e?null:r===0?0:r}var
|
|
1045
|
-
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function
|
|
1046
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
1047
|
-
let o=r?
|
|
1048
|
-
dotted path string.`)}let
|
|
1049
|
-
for(let
|
|
1050
|
-
|
|
1051
|
-
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:
|
|
1052
|
-
none:()=>({type:
|
|
577
|
+
s: true.`);if(r){if(!Ir(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
|
|
578
|
+
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Qe(
|
|
579
|
+
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ne(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}var Sr="^(?:0|-?[1-9]\\d*)$",Bo="\\d{4}",Ho="0[1-9]|1[0-2]",Vo="0[1-9]|[12]\\d|3[01]",Go="[01]\\d|2[0-3]",je="[0-5]\\d",
|
|
580
|
+
Et=`(?:${Go}):${je}`,Wo=`(?:Z|[+-](?:${Go}):${je})`,Ko=`(${Bo})-(${Ho})-(${Vo})`,Jo=`${Bo}-(?:${Ho})-(?:${Vo})`,Xo=`^${Jo}\
|
|
581
|
+
$`,Mc=new RegExp(`^${Ko}$`),Nc=new RegExp(`^${Et}(?::${je}(?:\\.(\\d+))?)?$`),jc=new RegExp(`^${Ko}T${Et}:${je}(?:\\.(\\d+\
|
|
582
|
+
))?${Wo}$`),Dc=new RegExp(Sr),zc=[31,28,31,30,31,30,31,31,30,31,30,31];function Lc(t){return t%4===0&&(t%100!==0||t%400===
|
|
583
|
+
0)}function Fc(t,e){return e===2?Lc(t)?29:28:zc[e-1]}function Yo(t,e,r){let n=Number(t),o=Number(e),s=Number(r);return o>=
|
|
584
|
+
1&&o<=12&&s>=1&&s<=Fc(n,o)}function Ze(t,e){let r=t.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
|
|
585
|
+
`temporalPrecision for "${e}" must be a non-negative integer.`);return r}}function Qo(t,e){return t===void 0?!0:e===void 0||
|
|
586
|
+
t.length<=e}function Zo(t){if(typeof t!="string")return!1;let e=Mc.exec(t);return e!==null&&Yo(e[1],e[2],e[3])}function es(t,e){
|
|
587
|
+
if(typeof t!="string")return!1;let r=Nc.exec(t);return r!==null&&Qo(r[1],e)}function ts(t,e){if(typeof t!="string")return!1;
|
|
588
|
+
let r=jc.exec(t);return r===null?!1:Yo(r[1],r[2],r[3])&&Qo(r[4],e)}function rs(t){return t===void 0?"(?:\\.\\d+)?":t===0?
|
|
589
|
+
"":`(?:\\.\\d{1,${t}})?`}function ns(t,e){let r=Ze(t,e);return`^${Et}(?::${je}${rs(r)})?$`}function os(t,e){let r=Ze(t,e);
|
|
590
|
+
return`^${Jo}T${Et}:${je}${rs(r)}${Wo}$`}function xr(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&Dc.
|
|
591
|
+
test(t))r=Number(t);else return null;return!Number.isSafeInteger(r)||r<-e||r>e?null:r===0?0:r}var $c=new Set(["__proto__","prototype","constructor"]);function x(t,e,r){Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Uc(t,e){if($c.
|
|
592
|
+
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function qc(t){return typeof t!="string"?t:t.replace(
|
|
593
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Tr(t,e,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
594
|
+
let o=r?qc(t):t;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${e}() expects a non-empty \
|
|
595
|
+
dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
|
|
596
|
+
for(let i of s)Uc(i,e);return s}var Bc="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",br=["object","array","string","number","boolean"],
|
|
597
|
+
_r=Symbol("json-rest-schema.exportContext"),Hc=["true","1","yes","y","on"],Vc=["false","0","no","n","off"];function ss(t){
|
|
598
|
+
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:Sr}]}}function Ie(t,e){return{[fe]:{[t]:e}}}var Gc={
|
|
599
|
+
none:()=>({type:br}),blob:()=>({type:br}),serialize:()=>({type:br}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
1053
600
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
1054
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
1055
|
-
type:"string",format:"date-time",pattern:
|
|
1056
|
-
fieldName:e})=>({type:"string",pattern:
|
|
1057
|
-
let e=new Set([...
|
|
601
|
+
eger","string"]}),epochMilliseconds:()=>ss(864e13),epochSeconds:()=>ss(864e10),dateTime:({definition:t,fieldName:e})=>({
|
|
602
|
+
type:"string",format:"date-time",pattern:os(t,e)}),date:()=>({type:"string",format:"date",pattern:Xo}),time:({definition:t,
|
|
603
|
+
fieldName:e})=>({type:"string",pattern:ns(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
|
|
604
|
+
let e=new Set([...Hc,String(t.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...Vc,String(t.stringFalseWhen||
|
|
1058
605
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...r,...e]}]}},
|
|
1059
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
606
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},Wc={minLength:({definition:t,parameterValue:e})=>t.
|
|
1060
607
|
type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
|
|
1061
|
-
definition:t,parameterValue:e})=>
|
|
608
|
+
definition:t,parameterValue:e})=>Ne(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ne(t)?{maximum:e}:null,pattern:({
|
|
1062
609
|
definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
|
|
1063
610
|
enum:t}),notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({parameterValue:t})=>t?
|
|
1064
|
-
|
|
1065
|
-
"transforms",{length:t}),unsigned:({parameterValue:t})=>t?
|
|
1066
|
-
"metadata",{precision:t}),scale:({parameterValue:t})=>
|
|
611
|
+
Ie("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Ie("transforms",{lowercase:!0}):null,length:({parameterValue:t})=>Ie(
|
|
612
|
+
"transforms",{length:t}),unsigned:({parameterValue:t})=>t?Ie("metadata",{unsigned:!0}):null,precision:({parameterValue:t})=>Ie(
|
|
613
|
+
"metadata",{precision:t}),scale:({parameterValue:t})=>Ie("metadata",{scale:t}),temporalPrecision:({parameterValue:t})=>Ie(
|
|
1067
614
|
"metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null};
|
|
1068
|
-
function
|
|
1069
|
-
isArray(n)&&!Array.isArray(o)){
|
|
1070
|
-
"JSON Schema export hooks must return an object or null.");for(let r of Object.keys(e)){if(r===
|
|
1071
|
-
bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){
|
|
1072
|
-
let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function
|
|
615
|
+
function Or(t,e){for(let r of Object.keys(e)){let n=e[r],o=t[r];if(n&&o&&typeof n=="object"&&typeof o=="object"&&!Array.
|
|
616
|
+
isArray(n)&&!Array.isArray(o)){Or(o,n);continue}t[r]=n}}function Kc(t,e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(
|
|
617
|
+
"JSON Schema export hooks must return an object or null.");for(let r of Object.keys(e)){if(r===fe&&t[r]&&typeof t[r]=="o\
|
|
618
|
+
bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){Or(t[r],e[r]);continue}t[r]=e[r]}}function Jc(t,e){
|
|
619
|
+
let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function Xc(t,e){
|
|
1073
620
|
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.
|
|
1074
|
-
toJsonSchema=="function")return r.toJsonSchema;let n=
|
|
1075
|
-
ed to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
1076
|
-
let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=
|
|
1077
|
-
`Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function
|
|
621
|
+
toJsonSchema=="function")return r.toJsonSchema;let n=Gc[e.type];if(!n)throw new Error(`Type '${e.type}' cannot be export\
|
|
622
|
+
ed to JSON Schema without a toJsonSchema hook.`);return n}function Yc(t,e,r){if(!Object.hasOwn(t.validators,e))return null;
|
|
623
|
+
let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=Wc[e];if(o)return o;throw new Error(
|
|
624
|
+
`Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function is(t){if(t===
|
|
1078
625
|
void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(`Unsupported JSON Schema expo\
|
|
1079
|
-
rt mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
1080
|
-
let r=
|
|
626
|
+
rt mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function Qc(t,e={}){if(e.mode!==void 0&&e.operation!==void 0){
|
|
627
|
+
let r=is(e.mode);if(r!==e.operation)throw new Error(`Conflicting JSON Schema export options: mode '${r}' does not match \
|
|
1081
628
|
operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))throw new Error(`Unkn\
|
|
1082
|
-
own JSON Schema export operation '${e.operation}'.`);return e.operation}return
|
|
1083
|
-
void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};let r=
|
|
1084
|
-
e);return{operationName:r,operation:t.operations[r]}}function
|
|
1085
|
-
definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function
|
|
1086
|
-
nodes:[],nextDefinitionId:1,rootNode:null}}function
|
|
1087
|
-
"")||"operation"}function
|
|
1088
|
-
t)?{allOf:[t]}:t}function
|
|
1089
|
-
o)||null}function
|
|
1090
|
-
root:
|
|
1091
|
-
operation:n,additionalProperties:o,status:"new",definitionName:
|
|
1092
|
-
|
|
1093
|
-
if(t.status==="building")return{$ref:t.pointer};let r=
|
|
1094
|
-
{});let n=
|
|
1095
|
-
definitions[t.definitionName]=n,{$ref:t.pointer})}function
|
|
1096
|
-
|
|
1097
|
-
let
|
|
1098
|
-
|
|
1099
|
-
let
|
|
1100
|
-
[
|
|
1101
|
-
replace:
|
|
1102
|
-
ma")return{...
|
|
1103
|
-
"object"&&Object.hasOwn(
|
|
1104
|
-
definition,n,a,
|
|
1105
|
-
n,o,
|
|
1106
|
-
if(a.kind==="map")return
|
|
1107
|
-
operation:o,mode:o,options:n});if(!
|
|
1108
|
-
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=
|
|
1109
|
-
referenceBacked:
|
|
1110
|
-
operation:o,mode:o,options:n},a=
|
|
1111
|
-
keys(r)){if(
|
|
1112
|
-
parameterValue:r[
|
|
1113
|
-
type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let
|
|
1114
|
-
defaultTo!="function"){let
|
|
1115
|
-
options:{},settings:t._buildOperationSettings(o,
|
|
1116
|
-
throw new Error(`defaultTo for "${e}" is invalid (${
|
|
1117
|
-
return
|
|
1118
|
-
!1:r.additionalProperties,
|
|
1119
|
-
length>0&&(
|
|
1120
|
-
|
|
1121
|
-
.${String(e)}`}function
|
|
1122
|
-
startsWith(r)?t.slice(r.length):null}function
|
|
1123
|
-
{...n,field:o})}return r}function
|
|
1124
|
-
o=e;for(let
|
|
1125
|
-
return e}function
|
|
1126
|
-
function
|
|
629
|
+
own JSON Schema export operation '${e.operation}'.`);return e.operation}return is(e.mode)}function Zc(t,e={}){if(e.operationName!==
|
|
630
|
+
void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};let r=Qc(t,
|
|
631
|
+
e);return{operationName:r,operation:t.operations[r]}}function ed(t={}){let e={...t};return Object.defineProperty(e,_r,{value:{
|
|
632
|
+
definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function Rt(t={}){return t[_r]?t[_r]:{definitions:{},
|
|
633
|
+
nodes:[],nextDefinitionId:1,rootNode:null}}function td(t){return String(t).replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,
|
|
634
|
+
"")||"operation"}function Ar(t){return H(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}function Ot(t){return Ar(
|
|
635
|
+
t)?{allOf:[t]}:t}function rd(t,e,r,n,o){return t.nodes.find(s=>s.schema===e&&s.operationName===r&&s.operation===n&&s.additionalProperties===
|
|
636
|
+
o)||null}function nd(t,e){let r=td(e),n=`SchemaNode_${t.nextDefinitionId}_${r}`;return t.nextDefinitionId+=1,n}function as(t,e,r,n,o,{
|
|
637
|
+
root:s=!1}={}){let i=Rt(e),a=rd(i,t,r,n,o);if(a)return s&&(a.pointer="#",i.rootNode=a),a;let c={schema:t,operationName:r,
|
|
638
|
+
operation:n,additionalProperties:o,status:"new",definitionName:s?null:nd(i,r),pointer:s?"#":null};return s?i.rootNode=c:
|
|
639
|
+
c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function cs(t,e){if(t.status==="built")return{$ref:t.pointer};
|
|
640
|
+
if(t.status==="building")return{$ref:t.pointer};let r=Rt(e);t.status="building",t.pointer!=="#"&&(r.definitions[t.definitionName]=
|
|
641
|
+
{});let n=od(t.schema,e,t.operationName,t.operation,t.additionalProperties);return t.status="built",t.pointer==="#"?n:(r.
|
|
642
|
+
definitions[t.definitionName]=n,{$ref:t.pointer})}function Rr(t,e,r,n,o=!1){let s=Rt(e),i=as(t,e,r,n,o);return s.rootNode===
|
|
643
|
+
i?{$ref:"#"}:cs(i,e)}function et(t,{referenceBacked:e=!1}={}){return{schema:t,referenceBacked:e}}function od(t,e,r,n,o=!1){
|
|
644
|
+
let s={},i=[];for(let[c,d]of Object.entries(t.structure))x(s,c,Pr(t,c,d,e,r,n)),n.enforceRequired&&d.required===!0&&i.push(
|
|
645
|
+
c);let a={type:"object",properties:s,additionalProperties:o};return i.length>0&&(a.required=i),a}function sd(t,e,r,n,o,s){
|
|
646
|
+
let i=At(e,r);if(!i)return null;if(i.kind==="schema")return{...Ot(Rr(i.schema,n,"replace",i.schema.operations.replace,!1)),
|
|
647
|
+
[fe]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,"schema")?"replace":o,c=a==="replace"?t.operations.
|
|
648
|
+
replace:s;return Pr(t,`${e}[]`,r.items,n,a,c)}function id(t,e,r,n,o,s){let i=Qe(e,r);if(!i)return null;if(i.kind==="sche\
|
|
649
|
+
ma")return{...Ot(Rr(i.schema,n,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=i.definition.type===
|
|
650
|
+
"object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return Pr(t,`${e}.*`,i.
|
|
651
|
+
definition,n,a,c)}function ad(t,e,r,n,o,s){if(r.type==="object"){let a=Ct(e,r);if(a.kind==="nested")return et(Rr(a.schema,
|
|
652
|
+
n,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return et({type:"object",additionalProperties:!0});
|
|
653
|
+
if(a.kind==="map")return et({type:"object",additionalProperties:id(t,e,r,n,o,s)})}let i=Xc(t,r)({schema:t,fieldName:e,definition:r,
|
|
654
|
+
operation:o,mode:o,options:n});if(!i||typeof i!="object"||Array.isArray(i))throw new Error(`Type '${r.type}' on field '${e}\
|
|
655
|
+
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=sd(t,e,r,n,o,s);if(a)return et({...i,items:a},{
|
|
656
|
+
referenceBacked:Ar(i)})}return et(i,{referenceBacked:Ar(i)})}function Pr(t,e,r,n,o,s){let i={schema:t,fieldName:e,definition:r,
|
|
657
|
+
operation:o,mode:o,options:n},a=ad(t,e,r,n,o,s),c=a.referenceBacked?Ot(a.schema):{...a.schema},d={castType:r.type};for(let p of Object.
|
|
658
|
+
keys(r)){if(p==="type"||!Object.hasOwn(t.validators,p))continue;let h=Yc(t,p,e);if(!h)continue;let I=h({...i,parameterName:p,
|
|
659
|
+
parameterValue:r[p],fieldSchema:{...c}});I&&Kc(c,I)}c[fe]&&(Or(d,c[fe]),delete c[fe]);let u=[];r.nullable===!0&&u.push({
|
|
660
|
+
type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let l=Ot(Jc(c,u));if(r.defaultTo!==void 0&&s.applyDefaults)if(typeof r.
|
|
661
|
+
defaultTo!="function"){let p=t._normalizeDefault(r,r.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},
|
|
662
|
+
options:{},settings:t._buildOperationSettings(o,s,{})});if(Object.keys(p.errors).length>0){let h=Object.values(p.errors)[0];
|
|
663
|
+
throw new Error(`defaultTo for "${e}" is invalid (${h.code}).`)}l.default=p.value}else d.defaults={providedByFunction:!0};
|
|
664
|
+
return l[fe]=d,l}function ds(t,e={}){let r=ed(e),{operationName:n,operation:o}=Zc(t,r),s=r.additionalProperties===void 0?
|
|
665
|
+
!1:r.additionalProperties,i=Rt(r),a=as(t,r,n,o,s,{root:!0}),c={$schema:Bc,...cs(a,r)};return Object.keys(i.definitions).
|
|
666
|
+
length>0&&(c.definitions=i.definitions),c}function us(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Dr(t){return t instanceof
|
|
667
|
+
Le}function cd(){return{self:!1,children:{}}}function ls(t){return Object.keys(t.children).length>0}function Se(t,e){return`${t}\
|
|
668
|
+
.${String(e)}`}function vs(t,e){return t===""?String(e):Se(t,e)}function ps(t,e){if(t===e)return"";let r=`${e}.`;return t.
|
|
669
|
+
startsWith(r)?t.slice(r.length):null}function De(t,e){let r={};for(let n of Object.values(t)){let o=Se(e,n.field);x(r,o,
|
|
670
|
+
{...n,field:o})}return r}function Nr(t){return Tr(t,"validatePath")}function fs(t){let e={};for(let r of t){let n=Nr(r),
|
|
671
|
+
o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||x(o,i,cd()),s===n.length-1&&(o[i].self=!0),o=o[i].children}}
|
|
672
|
+
return e}function dd(t,e){let r=t;for(let n of e){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
|
|
673
|
+
function Pt(t){return t===null?!0:Array.isArray(t)||H(t)?Object.keys(t).length>0:t!==void 0}function hs(t){return[...t].
|
|
1127
674
|
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)})}
|
|
1128
|
-
function
|
|
675
|
+
function ud(t){return/^[0-9]+$/.test(t)}function ld(t,e=new WeakMap){if(e.has(t))return e.get(t);let r=Object.create(Le.
|
|
1129
676
|
prototype);return e.set(t,r),r.structure=null,r.types=t.types,r.validators=t.validators,r.operations=t.operations,r.structure=
|
|
1130
|
-
|
|
1131
|
-
"object")return t;if(
|
|
677
|
+
Mt(kt(t.structure,e)),r._installOperationMethods(),Object.freeze(r)}function kt(t,e=new WeakMap){if(t===null||typeof t!=
|
|
678
|
+
"object")return t;if(Dr(t))return ld(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let n=new RegExp(
|
|
1132
679
|
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);
|
|
1133
|
-
for(let o of t)n.push(
|
|
1134
|
-
o,e));return r}function
|
|
1135
|
-
isArray(t))for(let r of t)
|
|
1136
|
-
return
|
|
1137
|
-
t.structure,n))return null;let
|
|
1138
|
-
if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:
|
|
1139
|
-
"array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[i
|
|
1140
|
-
n,
|
|
1141
|
-
function
|
|
1142
|
-
"");n.length>0?r.skipFields=n:delete r.skipFields}if(
|
|
1143
|
-
let
|
|
680
|
+
for(let o of t)n.push(kt(o,e));return n}if(!H(t))return t;let r={};e.set(t,r);for(let[n,o]of Object.entries(t))x(r,n,kt(
|
|
681
|
+
o,e));return r}function Mt(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Dr(t))return t;if(e.add(t),Array.
|
|
682
|
+
isArray(t))for(let r of t)Mt(r,e);else for(let r of Reflect.ownKeys(t))Mt(t[r],e);return Object.freeze(t)}function kr(t){
|
|
683
|
+
return Mt(kt(t))}function jr(t,e,r=""){if(!Dr(t)||!Array.isArray(e)||e.length<1)return null;let[n,...o]=e;if(!Object.hasOwn(
|
|
684
|
+
t.structure,n))return null;let s=t.structure[n];if(o.length<1)return s;let i=vs(r,n);return ws(t,s,o,i)}function ws(t,e,r,n){
|
|
685
|
+
if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:jr(o.schema,r,n)}if(e?.type===
|
|
686
|
+
"array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[s,...i]=r;if(!ud(s))return null;let a=Se(
|
|
687
|
+
n,s);return o.kind==="schema"?i.length<1?null:jr(o.schema,i,a):i.length<1?o.definition:ws(t,o.definition,i,a)}return null}
|
|
688
|
+
function ze(t,e){let r={...t};if(Array.isArray(t.skipFields)){let n=t.skipFields.map(o=>ps(o,e)).filter(o=>o!==null&&o!==
|
|
689
|
+
"");n.length>0?r.skipFields=n:delete r.skipFields}if(H(t.skipParams)){let n={};for(let[o,s]of Object.entries(t.skipParams)){
|
|
690
|
+
let i=ps(o,e);i===null||i===""||x(n,i,s)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var pd=Object.
|
|
1144
691
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
1145
692
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
1146
693
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
1147
|
-
function
|
|
1148
|
-
", ")}.`)}function
|
|
1149
|
-
must define ${r} as a boolean.`)}function
|
|
1150
|
-
eration "${t}" must be an object.`);return
|
|
1151
|
-
pplyDefaults"),
|
|
694
|
+
function ms(t,e,r,n){let o=e[r];if(!n.includes(o))throw new Error(`Operation "${t}" must define ${r} as one of: ${n.join(
|
|
695
|
+
", ")}.`)}function Mr(t,e,r,n=!0){let o=e[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
|
|
696
|
+
must define ${r} as a boolean.`)}function fd(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
|
|
697
|
+
eration "${t}" must be an object.`);return ms(t,e,"targetFields",["schema","input"]),Mr(t,e,"enforceRequired"),Mr(t,e,"a\
|
|
698
|
+
pplyDefaults"),ms(t,e,"outputFields",["validated","input"]),Mr(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
|
|
1152
699
|
targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
|
|
1153
|
-
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function
|
|
700
|
+
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function hd(t={}){if(typeof t!="object"||t===null||Array.
|
|
1154
701
|
isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[r,n]of Object.entries(
|
|
1155
|
-
|
|
1156
|
-
null);for(let[r,n]of Object.entries(t))
|
|
1157
|
-
delete e.mode,e}var
|
|
1158
|
-
|
|
1159
|
-
t to the required type.")}_paramError(e,r,n,o={}){let
|
|
1160
|
-
|
|
1161
|
-
return Array.isArray(r.skipFields)&&r.skipFields.includes(e)}_mergeErrors(e,r){for(let[n,o]of Object.entries(r))
|
|
1162
|
-
let r={};return
|
|
702
|
+
pd))x(e,r,n);for(let[r,n]of Object.entries(t))x(e,r,fd(r,n));return Object.freeze(e)}function gs(t){let e=Object.create(
|
|
703
|
+
null);for(let[r,n]of Object.entries(t))x(e,r,n);return Object.freeze(e)}function md(t){let e={...t};return delete e.operation,
|
|
704
|
+
delete e.mode,e}var Le=class{constructor(e,r,n,o={}){this.structure=e,this.types=gs(r),this.validators=gs(n),this.operations=
|
|
705
|
+
hd(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could not be cas\
|
|
706
|
+
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
|
+
s}_paramToBeSkipped(e,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(e))}_fieldToBeSkipped(e,r){
|
|
708
|
+
return Array.isArray(r.skipFields)&&r.skipFields.includes(e)}_mergeErrors(e,r){for(let[n,o]of Object.entries(r))x(e,n,o)}_singleErrorMap(e){
|
|
709
|
+
let r={};return x(r,e.field,e),r}_assertSupportedOptions(e={}){if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("U\
|
|
1163
710
|
nsupported validation option `onlyObjectValues`. Call `patch()` directly.");if(Object.hasOwn(e,"mode"))throw new Error("\
|
|
1164
711
|
Unsupported validation option `mode`. Call `validateWith()` or an operation method directly.");if(Object.hasOwn(e,"opera\
|
|
1165
712
|
tion"))throw new Error("Unsupported validation option `operation`. Call `validateWith()` or an operation method directly\
|
|
1166
713
|
.")}_buildOperationSettings(e,r,n){return{operationName:e,operation:r,targetFieldNames:r.targetFields==="input"?Object.keys(
|
|
1167
714
|
n):Object.keys(this.structure),outputFieldNames:r.outputFields==="input"?Object.keys(n):Object.keys(this.structure),enforceRequired:r.
|
|
1168
715
|
enforceRequired,applyDefaults:r.applyDefaults,rejectExplicitUndefined:r.rejectExplicitUndefined,defaultedFields:new Set,
|
|
1169
|
-
isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(e,r){if(!
|
|
716
|
+
isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(e,r){if(!H(r))throw new Error(`${e}() expects a plain obje\
|
|
1170
717
|
ct input.`)}_resolvePathValidationRequest(e={}){let r=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
|
|
1171
718
|
hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
1172
719
|
oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
|
|
1173
|
-
return{operationName:r,operation:n,validationOptions:
|
|
1174
|
-
if(!Object.hasOwn(this.structure,
|
|
1175
|
-
has(
|
|
1176
|
-
return
|
|
1177
|
-
hasOwn(e,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(e,r,n,o,i,
|
|
720
|
+
return{operationName:r,operation:n,validationOptions:md(e)}}_buildOperationResult(e,r,n){let o={};for(let s of n.outputFieldNames){
|
|
721
|
+
if(!Object.hasOwn(this.structure,s))continue;let i=n.isFieldPresent(s);(r[s]!==void 0||i&&e[s]===null||n.defaultedFields.
|
|
722
|
+
has(s))&&(!i&&!n.defaultedFields.has(s)||x(o,s,r[s]))}return o}_resolveObjectFieldMode(e,r){return Ct(e,r)}_resolveArrayItemsConfig(e,r){
|
|
723
|
+
return At(e,r)}_resolveObjectValuesConfig(e,r){return Qe(e,r)}_buildArrayItemSettings(e,r){return e.type==="object"&&Object.
|
|
724
|
+
hasOwn(e,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(e,r,n,o,s,i,a,c){let d=e.
|
|
1178
725
|
nullable===!0||a.nullable===!0,u=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
|
|
1179
|
-
`No casting function for type: ${e.type}`);let
|
|
726
|
+
`No casting function for type: ${e.type}`);let l=this.types[e.type];if(r===null)return d?(x(o,s,null),{errors:{},shouldContinue:!1}):
|
|
1180
727
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
1181
|
-
if(r===""&&u)return
|
|
1182
|
-
objectBeforeCast:
|
|
1183
|
-
nullable:
|
|
1184
|
-
n,
|
|
1185
|
-
|
|
1186
|
-
errors:{},context:
|
|
1187
|
-
_paramToBeSkipped(a,
|
|
1188
|
-
a,
|
|
1189
|
-
(
|
|
1190
|
-
let
|
|
1191
|
-
context:u}=
|
|
1192
|
-
e,n,o,
|
|
1193
|
-
let
|
|
1194
|
-
if(e.type==="object"){let
|
|
1195
|
-
|
|
1196
|
-
_resolveArrayItemsConfig(r,e);return a?this._validateArrayItems(r,n,o,a,i
|
|
1197
|
-
let a=n[o],
|
|
1198
|
-
|
|
1199
|
-
a,e.schema,
|
|
1200
|
-
entries(e))Object.hasOwn(r.structure,o)&&
|
|
1201
|
-
keys(e)){if(!Object.hasOwn(r.structure,
|
|
1202
|
-
n))Object.hasOwn(o,
|
|
1203
|
-
keys(a)){let
|
|
1204
|
-
_mergeErrors(
|
|
1205
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,
|
|
1206
|
-
|
|
1207
|
-
definition,
|
|
1208
|
-
|
|
1209
|
-
this._mergeErrors(
|
|
1210
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,
|
|
1211
|
-
|
|
1212
|
-
o.definition,
|
|
1213
|
-
let
|
|
1214
|
-
|
|
1215
|
-
Field is required",params:{}}):a?
|
|
1216
|
-
_normalizeAndValidateValue(
|
|
1217
|
-
|
|
1218
|
-
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let
|
|
1219
|
-
|
|
1220
|
-
this.structure[
|
|
1221
|
-
|
|
1222
|
-
_mergeErrors(
|
|
1223
|
-
_buildOperationResult(n,
|
|
1224
|
-
let
|
|
1225
|
-
|
|
1226
|
-
hasOwn(this.structure,e))return{};let
|
|
1227
|
-
let
|
|
1228
|
-
a)&&this._mergeErrors(
|
|
1229
|
-
|
|
1230
|
-
currentObject:o,containerKey:e,objectBeforeCast:n,options:
|
|
1231
|
-
length===0&&
|
|
1232
|
-
a).errorObject):{};let I={[e]:
|
|
1233
|
-
I[e]!==void 0?
|
|
1234
|
-
S.errors).length>0)return S.errors;if(!S.shouldContinue)return{};let
|
|
1235
|
-
I,e,i
|
|
1236
|
-
n,e);if(
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,
|
|
1240
|
-
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(e,r,n,o,i,
|
|
1241
|
-
u={};
|
|
1242
|
-
id because array segments must use numeric indexes.`);let
|
|
1243
|
-
|
|
1244
|
-
if(
|
|
1245
|
-
let
|
|
1246
|
-
this._mergeErrors(u,
|
|
1247
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
1248
|
-
this._mergeErrors(u,
|
|
1249
|
-
o.definition,
|
|
1250
|
-
continue}if(!
|
|
1251
|
-
u
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
e,o,r,n)}validateAt(e,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=
|
|
1255
|
-
_resolvePathValidationRequest(n),
|
|
1256
|
-
|
|
728
|
+
if(r===""&&u)return x(o,s,null),{errors:{},shouldContinue:!1};let p={schema:this,definition:e,value:r,fieldName:n,object:o,
|
|
729
|
+
objectBeforeCast:i,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
730
|
+
nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(h,I,S)=>{throw this._paramError(
|
|
731
|
+
n,h,I,S)}};try{let h=l(p);if(us(h))throw new Error(`Type handler for "${e.type}" must be synchronous.`);h!==void 0&&(x(o,
|
|
732
|
+
s,h),p.value=h)}catch(h){if(h.errorObject)return{errors:this._singleErrorMap(h.errorObject),shouldContinue:!1};throw h}return{
|
|
733
|
+
errors:{},context:p,shouldContinue:!0}}_runFieldValidators(e,r,n,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
|
|
734
|
+
_paramToBeSkipped(a,i.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
|
|
735
|
+
a,s.parameterValue=e[a];let d=c(s);if(us(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
|
|
736
|
+
(x(n,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,r,n,o,s,i,a,c){
|
|
737
|
+
let d=this._castValue(e,r,n,o,s,i,a,c);if(Object.keys(d.errors).length>0)return d.errors;if(!d.shouldContinue)return{};let{
|
|
738
|
+
context:u}=d,l=this._validateNestedValue(e,n,o,s,a,c);return Object.keys(l).length>0?l:(u.value=o[s],this._runFieldValidators(
|
|
739
|
+
e,n,o,s,u,a))}_normalizeDefault(e,r,{fieldPath:n,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
|
|
740
|
+
let d={...o};return x(d,s,r),{errors:this._normalizeAndValidateValue(e,r,n,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,r,n,o,s,i){
|
|
741
|
+
if(e.type==="object"){let c=this._resolveObjectFieldMode(r,e);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
742
|
+
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
|
+
_resolveArrayItemsConfig(r,e);return a?this._validateArrayItems(r,n,o,a,s,i):{}}_validateNestedObjectSchema(e,r,n,o,s,i){
|
|
744
|
+
let a=n[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
|
|
745
|
+
i.operationName,i.operation,c,ze(s,r));return x(n,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
746
|
+
a,e.schema,d.validatedObject):d.validatedObject),De(d.errors,r)}_extractKnownObjectFields(e,r){let n={};for(let[o,s]of Object.
|
|
747
|
+
entries(e))Object.hasOwn(r.structure,o)&&x(n,o,s);return n}_mergeKnownAndPassthroughObjectFields(e,r,n){let o={};for(let s of Object.
|
|
748
|
+
keys(e)){if(!Object.hasOwn(r.structure,s)){x(o,s,e[s]);continue}Object.hasOwn(n,s)&&x(o,s,n[s])}for(let[s,i]of Object.entries(
|
|
749
|
+
n))Object.hasOwn(o,s)||x(o,s,i);return o}_validateObjectValues(e,r,n,o,s,i){let a=r[n],c={...a},d={};x(r,n,c);for(let u of Object.
|
|
750
|
+
keys(a)){let l=Se(e,u);if(this._fieldToBeSkipped(l,s))continue;let p=c[u];if(p===void 0){i.rejectExplicitUndefined?this.
|
|
751
|
+
_mergeErrors(d,this._singleErrorMap(this._typeError(l).errorObject)):delete c[u];continue}if(o.kind==="schema"){let I=o.
|
|
752
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,p,ze(s,l));x(c,u,I.validatedObject),this._mergeErrors(
|
|
753
|
+
d,De(I.errors,l));continue}let h=this._normalizeAndValidateValue(o.definition,p,l,c,u,a,s,this._buildArrayItemSettings(o.
|
|
754
|
+
definition,i));this._mergeErrors(d,h)}return d}_validateArrayItems(e,r,n,o,s,i){let a=r[n],c=a.slice(),d={};x(r,n,c);for(let u=0;u<
|
|
755
|
+
c.length;u++){let l=Se(e,u);if(this._fieldToBeSkipped(l,s))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){i.rejectExplicitUndefined?
|
|
756
|
+
this._mergeErrors(d,this._singleErrorMap(this._typeError(l).errorObject)):delete c[u];continue}if(o.kind==="schema"){let h=o.
|
|
757
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[u],ze(s,l));x(c,u,h.validatedObject),this._mergeErrors(
|
|
758
|
+
d,De(h.errors,l));continue}let p=this._normalizeAndValidateValue(o.definition,c[u],l,c,u,a,s,this._buildArrayItemSettings(
|
|
759
|
+
o.definition,i));this._mergeErrors(d,p)}return d}_validateField(e,r,n,o,s){if(!Object.hasOwn(this.structure,e))return{};
|
|
760
|
+
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
|
+
i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
|
|
762
|
+
Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
|
|
763
|
+
_normalizeAndValidateValue(i,c,e,n,e,r,o,s):{}}_validateWithOperation(e,r,n,o){this._assertSupportedOptions(o);let s={},
|
|
764
|
+
i={...n},a=this._buildOperationSettings(e,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||x(s,c,{field:c,
|
|
765
|
+
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
|
|
766
|
+
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
|
+
this.structure[c].defaultTo!==void 0){let d=this.structure[c],u=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
|
|
768
|
+
l=this._normalizeDefault(d,u,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
769
|
+
_mergeErrors(s,l.errors),Object.keys(l.errors).length>0)continue;x(i,c,l.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
770
|
+
_buildOperationResult(n,i,a),errors:s}}_validateSelectedTree(e,r,n,o,s=""){let i={},a={};for(let c of hs(Object.keys(e))){
|
|
771
|
+
let d=vs(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let u=this._validateSelectedField(
|
|
772
|
+
c,e[c],r,a,n,o,d);this._mergeErrors(i,u)}return{validatedObject:a,errors:i}}_validateSelectedField(e,r,n,o,s,i,a){if(!Object.
|
|
773
|
+
hasOwn(this.structure,e))return{};let c=this.structure[e],d=r.self===!0,u=ls(r);if(this._fieldToBeSkipped(a,s))return{};
|
|
774
|
+
let l=Object.hasOwn(n,e),p=n[e],h={};if(!l){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
|
|
775
|
+
a)&&this._mergeErrors(h,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
|
|
776
|
+
c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,j=this._normalizeDefault(c,P,{fieldPath:a,
|
|
777
|
+
currentObject:o,containerKey:e,objectBeforeCast:n,options:s,settings:i});this._mergeErrors(h,j.errors),Object.keys(j.errors).
|
|
778
|
+
length===0&&x(o,e,j.value)}return h}if(p===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
779
|
+
a).errorObject):{};let I={[e]:p};if(d){let P=this._normalizeAndValidateValue(c,p,a,I,e,n,s,i);return Object.hasOwn(I,e)&&
|
|
780
|
+
I[e]!==void 0?x(o,e,I[e]):I[e]===null&&x(o,e,null),P}if(!u)return{};let S=this._castValue(c,p,a,I,e,n,s,i);if(Object.keys(
|
|
781
|
+
S.errors).length>0)return S.errors;if(!S.shouldContinue)return{};let C=this._validateSelectedDescendants(c,r.children,a,
|
|
782
|
+
I,e,s,i);return Pt(I[e])&&x(o,e,I[e]),C}_validateSelectedDescendants(e,r,n,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
783
|
+
n,e);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let d=o[s];if(!H(
|
|
784
|
+
d))return{};let u=c.schema._validateSelectedTree(r,d,ze(i,n),{...a,defaultedFields:new Set});return x(o,s,u.validatedObject),
|
|
785
|
+
De(u.errors,n)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(n,e);if(!c)throw new Error(`Schema path "${n}" d\
|
|
786
|
+
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,s,c,r,i,a)}throw new Error(
|
|
787
|
+
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(e,r,n,o,s,i,a){let c=[],d=r[n],
|
|
788
|
+
u={};x(r,n,c);for(let l of hs(Object.keys(s))){if(!/^[0-9]+$/.test(l))throw new Error(`Schema path "${Se(e,l)}" is inval\
|
|
789
|
+
id because array segments must use numeric indexes.`);let p=Number(l),h=Se(e,p),I=s[l],S=I.self===!0,C=ls(I);if(this._fieldToBeSkipped(
|
|
790
|
+
h,i))continue;if(!Object.hasOwn(d,p)){S&&a.rejectExplicitUndefined&&x(u,h,this._typeError(h).errorObject);continue}let P=d[p];
|
|
791
|
+
if(P===void 0){S&&a.rejectExplicitUndefined&&x(u,h,this._typeError(h).errorObject);continue}if(o.kind==="schema"){if(S){
|
|
792
|
+
let V=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,ze(i,h));Pt(V.validatedObject)&&x(c,p,V.validatedObject),
|
|
793
|
+
this._mergeErrors(u,De(V.errors,h));continue}if(!C)continue;let F=o.schema._validateSelectedTree(I.children,P,ze(i,h),{...a,
|
|
794
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Pt(F.validatedObject)&&x(c,p,F.validatedObject),
|
|
795
|
+
this._mergeErrors(u,De(F.errors,h));continue}let j=this._buildArrayItemSettings(o.definition,a),L=[P];if(S){let F=this._normalizeAndValidateValue(
|
|
796
|
+
o.definition,P,h,L,0,d,i,j);Object.hasOwn(L,0)&&L[0]!==void 0?x(c,p,L[0]):L[0]===null&&x(c,p,null),this._mergeErrors(u,F);
|
|
797
|
+
continue}if(!C)continue;let $=this._castValue(o.definition,P,h,L,0,d,i,j);if(Object.keys($.errors).length>0){this._mergeErrors(
|
|
798
|
+
u,$.errors);continue}if(!$.shouldContinue)continue;let K=this._validateSelectedDescendants(o.definition,I.children,h,L,0,
|
|
799
|
+
i,j);Pt(L[0])&&x(c,p,L[0]),this._mergeErrors(u,K)}return u}validateWith(e,r,n={}){if(!Object.hasOwn(this.operations,e))throw new Error(
|
|
800
|
+
`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,r),this._validateWithOperation(
|
|
801
|
+
e,o,r,n)}validateAt(e,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Nr(e),{operationName:s,operation:i,validationOptions:a}=this.
|
|
802
|
+
_resolvePathValidationRequest(n),c=this._validateSelectedTree(fs([e]),r,a,this._buildOperationSettings(s,i,r));return{validatedValue:dd(
|
|
803
|
+
c.validatedObject,o),errors:c.errors}}validatePaths(e,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
1257
804
|
isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
1258
|
-
operation:
|
|
1259
|
-
_buildOperationSettings(o,
|
|
805
|
+
operation:s,validationOptions:i}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(fs(e),r,i,this.
|
|
806
|
+
_buildOperationSettings(o,s,r))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
|
|
1260
807
|
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(r,n={})=>this.validateWith(e,r,n)}}toJsonSchema(e={}){
|
|
1261
|
-
return
|
|
1262
|
-
"")throw new Error("Field path must be a non-empty string.");let r=
|
|
1263
|
-
let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):
|
|
1264
|
-
let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&
|
|
1265
|
-
{"":t},"",t)),
|
|
1266
|
-
|
|
1267
|
-
"object"||typeof t=="function")&&typeof t.then=="function"}function
|
|
808
|
+
return ds(this,e)}getFieldDefinitions(){return kr(this.structure)}getFieldDefinition(e){if(typeof e!="string"||e.trim()===
|
|
809
|
+
"")throw new Error("Field path must be a non-empty string.");let r=jr(this,Nr(e.trim()));return r===null?null:kr(r)}getFieldMessages(e){
|
|
810
|
+
let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):kr(r.messages)}cleanup(e,r){
|
|
811
|
+
let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&x(n,o,e[o]);return n}};var{parse:Pw,stringify:gd}=JSON,{keys:kw}=Object,vd=String,wd="string";var ys="object",yd=(t,e)=>e;var Is=(t,e,r)=>{let n=vd(e.push(r)-1);return t.set(r,n),n};var Ss=(t,e,r)=>{let n=e&&typeof e===ys?(u,l)=>u===""||-1<e.indexOf(u)?l:void 0:e||yd,o=new Map,s=[],i=[],a=+Is(o,s,n.call(
|
|
812
|
+
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=gd(s[a++],d,r);return"["+i.join(",")+"]";function d(u,l){if(c)return c=!c,
|
|
813
|
+
l;let p=n.call(this,u,l);switch(typeof p){case ys:if(p===null)return p;case wd:return o.get(p)||Is(o,s,p)}return p}};var Sd=new Set(["true","1","yes","y","on"]),xd=new Set(["false","0","no","n","off"]);function Td(t){return t!==null&&(typeof t==
|
|
814
|
+
"object"||typeof t=="function")&&typeof t.then=="function"}function xs(t){if(typeof t=="number")return Number.isFinite(t)?
|
|
1268
815
|
t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
|
|
1269
|
-
if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function
|
|
816
|
+
if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function zr(t,e){if(Object.is(t,e))return!0;
|
|
1270
817
|
if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
|
|
1271
818
|
source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
|
|
1272
|
-
e.length)return!1;for(let o=0;o<t.length;o++)if(!
|
|
819
|
+
e.length)return!1;for(let o=0;o<t.length;o++)if(!zr(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
|
|
1273
820
|
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let r=Object.keys(t),n=Object.keys(
|
|
1274
|
-
e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!
|
|
1275
|
-
let{addType:e,addValidator:r}=t;e("none",n=>n.value),e("file",n=>{let o=n.value;o==null&&n.throwTypeError();let
|
|
1276
|
-
if(
|
|
1277
|
-
e("string",n=>{let o=n.value;if(o==null)return"";let
|
|
1278
|
-
return n.definition.noTrim?
|
|
1279
|
-
null&&n.throwTypeError(),o}),e("integer",n=>{let o=
|
|
1280
|
-
o}),e("epochMilliseconds",n=>{let o=
|
|
1281
|
-
n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=
|
|
1282
|
-
value,o)||n.throwTypeError(),n.value}),e("date",n=>(
|
|
1283
|
-
n.fieldName);return
|
|
1284
|
-
n.value)?[n.value]:n.value),e("object",n=>(
|
|
1285
|
-
n.value)}catch{try{return
|
|
821
|
+
e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!zr(t[o],e[o]))return!1;return!0}var bd={install(t){
|
|
822
|
+
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
|
+
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),
|
|
824
|
+
e("string",n=>{let o=n.value;if(o==null)return"";let s=typeof o;if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();
|
|
825
|
+
return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),e("blob",n=>n.value),e("number",n=>{let o=xs(n.value);return o===
|
|
826
|
+
null&&n.throwTypeError(),o}),e("integer",n=>{let o=xs(n.value);return(o===null||!Number.isInteger(o))&&n.throwTypeError(),
|
|
827
|
+
o}),e("epochMilliseconds",n=>{let o=xr(n.value,864e13);return o===null&&n.throwTypeError(),o}),e("epochSeconds",n=>{let o=xr(
|
|
828
|
+
n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=Ze(n.definition,n.fieldName);return ts(n.
|
|
829
|
+
value,o)||n.throwTypeError(),n.value}),e("date",n=>(Zo(n.value)||n.throwTypeError(),n.value)),e("time",n=>{let o=Ze(n.definition,
|
|
830
|
+
n.fieldName);return es(n.value,o)||n.throwTypeError(),n.value}),e("array",n=>n.definition.type==="array"&&!Array.isArray(
|
|
831
|
+
n.value)?[n.value]:n.value),e("object",n=>(H(n.value)||n.throwTypeError(),n.value)),e("serialize",n=>{try{return JSON.stringify(
|
|
832
|
+
n.value)}catch{try{return Ss(n.value)}catch{n.throwTypeError()}}}),e("boolean",n=>{if(typeof n.value=="boolean")return n.
|
|
1286
833
|
value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
|
|
1287
834
|
"bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
|
|
1288
|
-
n.definition.stringFalseWhen||"false").trim().toLowerCase(),
|
|
1289
|
-
|
|
835
|
+
n.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
836
|
+
i=n.value.trim().toLowerCase(),a=new Set([...xd,o]),c=new Set([...Sd,s]);if(a.has(i))return!1;if(c.has(i))return!0}n.throwTypeError()}),
|
|
1290
837
|
e("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
|
|
1291
838
|
value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
|
|
1292
|
-
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let
|
|
1293
|
-
|
|
839
|
+
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let s=Number(o);return Number.isSafeInteger(
|
|
840
|
+
s)||n.throwTypeError(),s}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.
|
|
1294
841
|
toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGTH",`Length must be at least ${n.parameterValue}\
|
|
1295
|
-
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&
|
|
842
|
+
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&Ne(n.definition)&&
|
|
1296
843
|
typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("MIN_VALUE",`Value must be at least ${n.parameterValue}\
|
|
1297
844
|
.`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.toString&&
|
|
1298
845
|
n.value.toString().length>n.parameterValue&&n.throwParamError("MAX_LENGTH",`Length must be no more than ${n.parameterValue}\
|
|
1299
|
-
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&
|
|
846
|
+
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&Ne(n.definition)&&
|
|
1300
847
|
typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError("MAX_VALUE",`Value must be no more than ${n.parameterValue}\
|
|
1301
848
|
.`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.isArray(n.parameterValue))throw new Error(`Enum for ${n.
|
|
1302
|
-
fieldName} must be an array.`);n.parameterValue.some(
|
|
849
|
+
fieldName} must be an array.`);n.parameterValue.some(s=>zr(s,n.value))||n.throwParamError("ENUM_VALUE","Value must match\
|
|
1303
850
|
one of the allowed enum values.",{allowed:n.parameterValue})}),r("pattern",n=>{if(n.value===void 0||n.definition.type!==
|
|
1304
|
-
"string"||typeof n.value!="string")return;let o=n.parameterValue,
|
|
1305
|
-
"string"?new RegExp(o):null;if(!
|
|
1306
|
-
n.throwParamError("PATTERN","Value does not match the required pattern.",{pattern:
|
|
851
|
+
"string"||typeof n.value!="string")return;let o=n.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
852
|
+
"string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${n.fieldName} must be a string or RegExp.`);s.test(n.value)||
|
|
853
|
+
n.throwParamError("PATTERN","Value does not match the required pattern.",{pattern:s.source})}),r("strictBoolean",n=>{if(n.
|
|
1307
854
|
parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
|
|
1308
855
|
fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
|
|
1309
856
|
"validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
|
|
1310
|
-
let o=n.parameterValue(n.value,n.object,n);if(
|
|
857
|
+
let o=n.parameterValue(n.value,n.object,n);if(Td(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
|
|
1311
858
|
ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
|
|
1312
859
|
ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
|
|
1313
860
|
th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
|
|
@@ -1316,99 +863,206 @@ ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).leng
|
|
|
1316
863
|
typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r(
|
|
1317
864
|
"unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.
|
|
1318
865
|
type!=="dateTime")throw new Error(`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r(
|
|
1319
|
-
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},
|
|
1320
|
-
unction")throw new Error(`Type handler for '${e}' must be a function.`);
|
|
1321
|
-
on")throw new Error(`Validator handler for '${e}' must be a function.`);
|
|
1322
|
-
for(let[r,n]of Object.entries(t))
|
|
1323
|
-
gin must have an install method.");t.install(e)}function
|
|
1324
|
-
freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
1325
|
-
"object"&&typeof t!="function")return null;let e=
|
|
866
|
+
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},Ts=bd;var As=new WeakMap,Cs=new WeakMap,Es=Symbol.for("json-rest-schema.registry-metadata");function _d(t,e,r){if(typeof r!="f\
|
|
867
|
+
unction")throw new Error(`Type handler for '${e}' must be a function.`);x(t,e,r)}function Ad(t,e,r){if(typeof r!="functi\
|
|
868
|
+
on")throw new Error(`Validator handler for '${e}' must be a function.`);x(t,e,r)}function Nt(t={}){let e=Object.create(null);
|
|
869
|
+
for(let[r,n]of Object.entries(t))x(e,r,n);return e}function Cd(t,e){if(typeof t.install!="function")throw new Error("Plu\
|
|
870
|
+
gin must have an install method.");t.install(e)}function bs(t,e,r){As.set(t,e),Cs.set(t,r),Object.defineProperty(t,Es,{value:Object.
|
|
871
|
+
freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function Ed(t){if(!t||typeof t!=
|
|
872
|
+
"object"&&typeof t!="function")return null;let e=As.get(t),r=Cs.get(t);if(e&&r)return{types:e,validators:r};let n=t[Es];
|
|
1326
873
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
1327
874
|
typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
|
|
1328
875
|
nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
|
|
1329
|
-
validators}:null}function
|
|
1330
|
-
for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!
|
|
1331
|
-
conflicting ${r} "${n}".`);
|
|
1332
|
-
e)};let o=Object.create(null),
|
|
1333
|
-
ust be schema instances or schema factories created by json-rest-schema.")
|
|
1334
|
-
ator")}return{types:o,validators:
|
|
1335
|
-
let
|
|
1336
|
-
|
|
1337
|
-
{types:a.types,validators:a.validators,installCore:!1})},r&&
|
|
1338
|
-
t))
|
|
876
|
+
validators}:null}function Od(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Rd(t,e){return t===e}function _s(t,e,r){
|
|
877
|
+
for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!Rd(t[n],o))throw new Error(`Cannot merge schema factories with\
|
|
878
|
+
conflicting ${r} "${n}".`);x(t,n,o)}}function Pd(t,e,r){let n=Od(r).filter(Boolean);if(n.length<1)return{types:Nt(t),validators:Nt(
|
|
879
|
+
e)};let o=Object.create(null),s=Object.create(null);for(let i of n){let a=Ed(i);if(!a)throw new Error("Factory sources m\
|
|
880
|
+
ust be schema instances or schema factories created by json-rest-schema.");_s(o,a.types,"type"),_s(s,a.validators,"valid\
|
|
881
|
+
ator")}return{types:o,validators:s}}function Os({types:t={},validators:e={},installCore:r=!0}={}){let n=Nt(t),o=Nt(e),s=(i,a={})=>{
|
|
882
|
+
let c=new Le(i,n,o,a.operations);return bs(c,n,o),c};return bs(s,n,o),s.addType=(i,a)=>{_d(n,i,a)},s.addValidator=(i,a)=>{
|
|
883
|
+
Ad(o,i,a)},s.use=i=>{Cd(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{let a=Pd(n,o,i);return Os(
|
|
884
|
+
{types:a.types,validators:a.validators,installCore:!1})},r&&s.use(Ts),s}var se=Os({installCore:!0});function xe(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let r of Object.getOwnPropertyNames(
|
|
885
|
+
t))xe(t[r],e);return Object.freeze(t)}var ey=Object.freeze({REQUIRED:"required",TYPE_CAST_FAILED:"default",NOT_NULLABLE:"default",MIN_LENGTH:"minLength",MAX_LENGTH:"\
|
|
1339
886
|
maxLength",MIN_VALUE:"min",MAX_VALUE:"max",PATTERN:"pattern",ENUM_VALUE:"enum",FIELD_NOT_ALLOWED:"additionalProperties",
|
|
1340
|
-
CUSTOM_VALIDATOR_FAILED:"default"});var
|
|
1341
|
-
mode:"patch"});var
|
|
1342
|
-
{...
|
|
1343
|
-
ng."}}}),mode:"patch"});var
|
|
887
|
+
CUSTOM_VALIDATOR_FAILED:"default"});var Md=se({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Nd=Object.freeze({schema:Md,
|
|
888
|
+
mode:"patch"});var Ps=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),jd=Object.freeze(
|
|
889
|
+
{...Ps,nullable:!0});var ks="^[1-9][0-9]*$",Lr=xe({type:"string",minLength:1,pattern:ks});var zd=xe({...Lr,nullable:!0});var Ld=xe({schema:se({recordId:{...Lr,required:!0,messages:{pattern:"Record id must be a canonical positive integer stri\
|
|
890
|
+
ng."}}}),mode:"patch"});var Zy=Object.freeze([/^(?:let me|i(?:'|’)ll|i will|i(?:'|’)m going to|i am going to)\s+(?:(?:first|now|quickly)\s+)*(?:analy[sz]e|call|check|confirm|do|execute|fetch|find|inspect|investigate|load|look up|open|prepare|query|read|retrieve|review|run|search|summarize|test|try|use|verify)\b/iu,
|
|
1344
891
|
/^(?: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,
|
|
1345
|
-
/^(?:one moment|please wait)\b/iu]);var
|
|
1346
|
-
toolName:{type:"string",maxLength:256,required:!1},arguments:{type:"string",maxLength:
|
|
892
|
+
/^(?:one moment|please wait)\b/iu]);var Hd=256*1024,uI=se({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:16e3,required:!1},
|
|
893
|
+
toolName:{type:"string",maxLength:256,required:!1},arguments:{type:"string",maxLength:Hd,required:!1}});var II=16*1024*1024;var TI=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var hS=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
1347
894
|
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
1348
|
-
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var
|
|
1349
|
-
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!
|
|
1350
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var
|
|
1351
|
-
if(!
|
|
1352
|
-
freeze({});if(!
|
|
1353
|
-
for(let[o,
|
|
1354
|
-
must be a JavaScript identifier.`);let a=
|
|
1355
|
-
" more than once.`);n.add(a),r[
|
|
895
|
+
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var FS=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
896
|
+
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
897
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var qS=2*1024*1024,BS=32*1024*1024,HS=2*1024*1024;var Ns=/^[a-z][a-z0-9_.-]*$/u,Qd=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function js(t,e){let r=String(t||"").trim().toLowerCase();
|
|
898
|
+
if(!Ns.test(r))throw new TypeError(`${e} must match ${Ns.toString()}.`);return r}function Ur(t,e){if(t==null)return Object.
|
|
899
|
+
freeze({});if(!Ye(t))throw new TypeError(`${e} must be an object mapping local names to capability ids.`);let r={},n=new Set;
|
|
900
|
+
for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!Qd.test(i))throw new TypeError(`${e} local name "${i}" \
|
|
901
|
+
must be a JavaScript identifier.`);let a=js(s,`${e}.${i}`);if(n.has(a))throw new TypeError(`${e} declares capability "${a}\
|
|
902
|
+
" more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function Zd(t){let e=new Map;for(let[r,n]of Object.entries(t))
|
|
1356
903
|
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)}\
|
|
1357
|
-
and ${r}.`);e.set(o,r)}}function
|
|
1358
|
-
be a function when provided.`);return t}function
|
|
1359
|
-
shutdown:
|
|
1360
|
-
{requires:
|
|
1361
|
-
freeze({id:a,requires:
|
|
1362
|
-
tration is closed after the first payload is resolved.");let u=
|
|
1363
|
-
is required.");if(typeof
|
|
904
|
+
and ${r}.`);e.set(o,r)}}function qr(t,e){if(t==null)return null;if(typeof t!="function")throw new TypeError(`${e} must \
|
|
905
|
+
be a function when provided.`);return t}function Dt({id:t,requires:e={},optional:r={},provides:n={},setup:o,boot:s=null,
|
|
906
|
+
shutdown:i=null}={}){let a=js(t,"Provider id"),c=Ur(e,`${a}.requires`),d=Ur(r,`${a}.optional`),u=Ur(n,`${a}.provides`);Zd(
|
|
907
|
+
{requires:c,optional:d,provides:u});let l=qr(o,`${a}.setup`);if(!l)throw new TypeError(`${a}.setup is required.`);return Object.
|
|
908
|
+
freeze({id:a,requires:c,optional:d,provides:u,setup:l,boot:qr(s,`${a}.boot`),shutdown:qr(i,`${a}.shutdown`)})}var Ds="public";function zs(){let t=[],e=new Set,r=!1;function n({id:a,order:c=0,contribute:d}={}){if(r)throw new Error("Bootstrap regis\
|
|
909
|
+
tration is closed after the first payload is resolved.");let u=q(a);if(!u)throw new TypeError("Bootstrap contributor id \
|
|
910
|
+
is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${u}" requires contribute().`);if(e.has(
|
|
1364
911
|
u))throw new Error(`Bootstrap contributor "${u}" is duplicated.`);return e.add(u),t.push(Object.freeze({id:u,order:Number.
|
|
1365
|
-
isFinite(
|
|
1366
|
-
(u,
|
|
1367
|
-
freeze({...
|
|
1368
|
-
freeze({sealed:r,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let
|
|
1369
|
-
return
|
|
1370
|
-
http:t}){let e=
|
|
1371
|
-
pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await e.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:e}}});function
|
|
912
|
+
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((u,l)=>({entry:u,index:l})).sort(
|
|
913
|
+
(u,l)=>u.entry.order-l.entry.order||u.index-l.index).map(({entry:u})=>u);for(let u of d){let l=await u.contribute(Object.
|
|
914
|
+
freeze({...Ye(a)?a:{},payload:Object.freeze({...c})}));c={...c,...Ye(l)?l:{}}}return Object.freeze(c)}function s(){return Object.
|
|
915
|
+
freeze({sealed:r,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:n,resolve:o,diagnostics:s});
|
|
916
|
+
return i}var eu=Dt({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({
|
|
917
|
+
http:t}){let e=zs();return t.router.register("GET","/api/bootstrap",{auth:Ds,meta:{tags:["bootstrap"],summary:"Resolve a\
|
|
918
|
+
pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await e.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:e}}});function tu(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Event listener must be an object.");let e=String(
|
|
1372
919
|
t.id||"").trim();if(!e)throw new TypeError("Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(
|
|
1373
920
|
`Event listener "${e}" requires handle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event \
|
|
1374
921
|
listener "${e}" matches must be a function when provided.`);return Object.freeze({id:e,handle:t.handle,matches:typeof t.
|
|
1375
|
-
matches=="function"?t.matches:null})}function
|
|
922
|
+
matches=="function"?t.matches:null})}function ru(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pub\
|
|
1376
923
|
lished event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is req\
|
|
1377
|
-
uired.");return Object.freeze({...t,type:e})}function
|
|
1378
|
-
`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),
|
|
1379
|
-
|
|
1380
|
-
map(
|
|
1381
|
-
events:"runtime.events"},setup(){return{events:
|
|
1382
|
-
execute:"assistant_action_execute"}),
|
|
924
|
+
uired.");return Object.freeze({...t,type:e})}function Ls(){let t=[],e=new Set;function r(i){let a=tu(i);if(e.has(a.id))throw new Error(
|
|
925
|
+
`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function n(i){let a=ru(i);for(let c of t)
|
|
926
|
+
c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.freeze(t.
|
|
927
|
+
map(i=>i.id))})}let s=Object.freeze({register:r,publish:n,diagnostics:o});return s}var nu=Dt({id:"runtime.events",provides:{
|
|
928
|
+
events:"runtime.events"},setup(){return{events:Ls()}}});var Fs=20,Rx=32*1024,Px=48*1024,Br=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
929
|
+
execute:"assistant_action_execute"}),Hr=Object.freeze({type:"object",additionalProperties:!0}),su=Object.freeze({type:"o\
|
|
1383
930
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
1384
931
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
1385
932
|
ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
|
|
1386
|
-
limit:{type:"integer",minimum:1,maximum:
|
|
1387
|
-
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:
|
|
933
|
+
limit:{type:"integer",minimum:1,maximum:Fs,description:"Maximum compact matches to return."}}}),iu=Object.freeze({type:"\
|
|
934
|
+
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Fs,items:{
|
|
1388
935
|
type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
|
|
1389
936
|
tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
|
|
1390
|
-
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),
|
|
1391
|
-
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),
|
|
937
|
+
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),au=Object.freeze({type:"object",additionalProperties:!1,required:[
|
|
938
|
+
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),cu=Object.
|
|
1392
939
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
|
|
1393
940
|
chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
|
|
1394
|
-
string"},inputSchema:
|
|
1395
|
-
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:
|
|
941
|
+
string"},inputSchema:Hr,outputSchema:Hr}}),du=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
942
|
+
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Hr}}),uu=Object.
|
|
1396
943
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
1397
|
-
g"},version:{type:"integer",minimum:1},result:{}}}),
|
|
944
|
+
g"},version:{type:"integer",minimum:1},result:{}}}),Vr=Object.freeze([Object.freeze({name:Br.search,description:"Discove\
|
|
1398
945
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
1399
946
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
1400
|
-
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:
|
|
1401
|
-
outputSchema:
|
|
1402
|
-
e action before executing it.",parameters:
|
|
1403
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:
|
|
947
|
+
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:su,
|
|
948
|
+
outputSchema:iu}),Object.freeze({name:Br.contract,description:"Load the exact input and output contract for one availabl\
|
|
949
|
+
e action before executing it.",parameters:au,outputSchema:cu}),Object.freeze({name:Br.execute,description:"Execute one a\
|
|
950
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:du,outputSchema:uu})]);var aT=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var lT=256*1024;var pT=2*1024*1024;var fT=Object.fromEntries(Vr.map(t=>[t.name,"allow"]));var hT=Vr.map(({name:t,description:e,parameters:r})=>({type:"function",function:{name:t,description:e,parameters:r}}));function Gr({resolveConversation:t,readInstructions:e}={}){if(typeof t!="function")throw new TypeError("Conversation hoo\
|
|
1404
951
|
k delivery requires a binding resolver.");return async function(n){if(n.scope!=="session")return{kind:"unclaimed"};let o=await t(
|
|
1405
952
|
n);if(!o)return{kind:"unclaimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError(
|
|
1406
953
|
"Unknown conversation instruction delivery mode.");if(typeof e!="function")throw new TypeError("Hook delivery requires a\
|
|
1407
|
-
n instruction resolver.");let
|
|
1408
|
-
instructions are unavailable.");return{kind:"delivery",text:
|
|
954
|
+
n instruction resolver.");let s=await e(o,n);if(typeof s!="string"||!s.trim())throw new TypeError("Managed conversation \
|
|
955
|
+
instructions are unavailable.");return{kind:"delivery",text:s}}}var jb=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
1409
956
|
allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
1410
957
|
test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
|
|
1411
|
-
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
958
|
+
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as Ru}from"node:fs/promises";import Wr from"node:path";var Pu=Object.freeze(["main","temporary"]),qs=Object.
|
|
959
|
+
freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),ku=64*1024,p_=Object.freeze(["When\
|
|
960
|
+
user input is necessary, ask no more than three concise, high-impact questions at once.","Put multiple questions on sep\
|
|
961
|
+
arate lines as `[1] Question`, `[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answe\
|
|
962
|
+
rs:` and a short bullet list directly beneath its own question, before the next one; never collect several questions' an\
|
|
963
|
+
swers into one trailing list.","Each bullet is one distinct, complete answer: Yes and No are separate bullets; never joi\
|
|
964
|
+
n alternatives with a slash or `or`. Omit the list for free-text answers. The user may always type a different answer.",
|
|
965
|
+
`Example:
|
|
966
|
+
[1] Which density?
|
|
967
|
+
Possible answers:
|
|
968
|
+
- Compact
|
|
969
|
+
- Comfortable
|
|
970
|
+
[2] Tell the main agent before changes?
|
|
971
|
+
Possible answers:
|
|
972
|
+
- Yes, tell main first
|
|
973
|
+
- No, proceed independently`]),f_=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
|
|
974
|
+
start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
|
|
975
|
+
nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
|
|
976
|
+
ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
|
|
977
|
+
words. If unconfigured, ask which existing accounts (email/login/user ID) represent admin and other required roles, and \
|
|
978
|
+
the default. Reuse prior answers; wait for their choices before configuring access. Never infer admin rights from names \
|
|
979
|
+
or the Vibe64 viewer.","Offer the application-owned `vibe64.preview-identity.command.v1` adapter in Outputs Preview iden\
|
|
980
|
+
tity, and guide named selectors through Dashboard > App access > Managed app access. Use existing sessions/permissions, \
|
|
981
|
+
reject missing/disabled accounts, and disable the adapter without Vibe64\u2019s per-run enable flag and secret. Do not create\
|
|
982
|
+
users, change roles, reset passwords or weaken production auth for import. Verify the selected account\u2019s actual Preview\
|
|
983
|
+
access; a saved selector is insufficient. If deferred/declined, explain access remains unconfigured and continue indepe\
|
|
984
|
+
ndent setup work without repeated credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview\
|
|
985
|
+
status`, `screenshot`, `logs`, and `browser eval` (Playwright code on stdin) for rendered inspection.","The top Preview\
|
|
986
|
+
toolbar Stop and `vibe64-helper preview stop` stop this session's application and managed browser, not chat or source. \
|
|
987
|
+
Status reports the saved stopped choice. A status read, screenshot, browser inspection, source edit or session reopening\
|
|
988
|
+
is not permission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start. Scoped browser \
|
|
989
|
+
tests restore the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-helper preview insp\
|
|
990
|
+
ect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your\
|
|
991
|
+
-path', preview.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity and is not a br\
|
|
992
|
+
owser-navigation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper playwright` only for\
|
|
993
|
+
an existing configured project suite; report a platform or project-test blocker rather than installing another browser \
|
|
994
|
+
or changing its dependencies.","For browser evidence, batch related actions and assertions, return only needed values an\
|
|
995
|
+
d inspect relevant locators or regions; screenshot at meaningful visual checkpoints or failures, not after every click. \
|
|
996
|
+
Reuse the managed browser when test isolation permits. Preserve required viewport, identity and security checks; use exi\
|
|
997
|
+
sting automated cases for repeat verification.","For browser tests that write or reset data, inspect `vibe64-helper prev\
|
|
998
|
+
iew targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target <declared-test-\
|
|
999
|
+
target> test <suite arguments>` or `vibe64-helper playwright --target <declared-test-target> npm-run <script>`. Vibe64 s\
|
|
1000
|
+
tarts that web target, waits for readiness, uses its declared application identity, and restores the previous Preview wh\
|
|
1001
|
+
en the command finishes or is cancelled; report restoration failures.","A target name is not proof of test isolation. Be\
|
|
1002
|
+
fore running a destructive suite, the application must verify the server's actual test database and suppress real email,\
|
|
1003
|
+
invoices, payments, and other external effects. Keep managed Env unchanged. The test launcher and its preview-identity \
|
|
1004
|
+
command must use the same database. Use a declared BROWSER_TEST_DB_NAME for reusable browser fixtures, separate from dis\
|
|
1005
|
+
posable TEST_DB_NAME. Never spoof safety checks by changing DB_NAME only in the test runner.","If no suitable test targe\
|
|
1006
|
+
t exists, add one through the project's existing Outputs contract and application-owned test scripts within authorized s\
|
|
1007
|
+
cope, keeping normal Preview as default. Validate the exact disposable database before resetting it, prepare fixtures be\
|
|
1008
|
+
fore reporting readiness, and make Playwright use PLAYWRIGHT_BASE_URL without starting another server. If the required t\
|
|
1009
|
+
est resources or external-effect controls are missing, report that specific blocker. Use `vibe64-helper preview ensure -\
|
|
1010
|
+
-target <id> --wait --json` only to deliberately select an interactive target; it stays selected until changed.","Keep r\
|
|
1011
|
+
outine browser startup incremental: reuse the isolated test schema, apply only pending migrations, and reset fixture dat\
|
|
1012
|
+
a deterministically. Do not drop and rebuild the database or run a production frontend build for every focused browser c\
|
|
1013
|
+
heck. Keep fresh-schema migration checks separate. If startup is slow, measure migrations, fixtures, and server startup \
|
|
1014
|
+
before retrying or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local \
|
|
1015
|
+
artifacts and preserve exit status. Report counts, duration, failed cases, actionable errors and artifact paths. Read on\
|
|
1016
|
+
ly needed failure excerpts, not full passing/JSON/TAP/request/trace/image output. Retain startup, resource and Preview-r\
|
|
1017
|
+
estoration errors even if tests pass, and trailing wrapper diagnostics separately from JSON. Do not rerun for output or \
|
|
1018
|
+
reread unchanged logs; inspect on new output, changed state or a concrete blocker.","Batch related browser tests in one \
|
|
1019
|
+
managed suite (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensu\
|
|
1020
|
+
re/restart or target changes during a suite or restoration. Wait on the original execution, including background runs, t\
|
|
1021
|
+
hrough cleanup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input or an \
|
|
1022
|
+
immediate check); read-only status/logs stay available. Before live inspection, confirm `vibe64-helper playwright status\
|
|
1023
|
+
` has no active run and `vibe64-helper preview status` is ready on the restored target. To stop, read suite status then \
|
|
1024
|
+
run `vibe64-helper playwright cancel <run-id>`, which waits for cleanup/restoration; retry it if cleanup needs attention\
|
|
1025
|
+
. Never kill individual test/Preview PIDs or change locks. Launcher exit alone does not prove tests stopped. Recheck cur\
|
|
1026
|
+
rent status before reporting a busy blocker.","If a managed command reports kernel task denials or a resource incident, \
|
|
1027
|
+
retain its diagnostic and incident ID when reporting the blocker. Ask the platform operator to inspect that resource evi\
|
|
1028
|
+
dence before retrying; do not increase test timeouts or weaken assertions to work around a process/thread limit. A gener\
|
|
1029
|
+
ic browser timeout without resource evidence does not establish a platform cause."]),h_=Object.freeze(["Each managed she\
|
|
1030
|
+
ll command receives current development Env from Vibe64, including declared resource bindings; use them in ordinary comm\
|
|
1031
|
+
ands. Do not build environment injection or copy managed credentials into source. Resource provisioning and application \
|
|
1032
|
+
migrations remain separate preparation steps.","Use `vibe64-helper env status [development|production|all]` to inspect c\
|
|
1033
|
+
onfigured key names without revealing values.","Pipe an available value to `vibe64-helper env set <development|productio\
|
|
1034
|
+
n> <KEY> [--secret]`; never put values in arguments, logs, or repository files. Use empty stdin only when the user reque\
|
|
1035
|
+
sted an empty value.","Keep development and production values separate. Never invent credentials, copy a value between s\
|
|
1036
|
+
copes without explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affec\
|
|
1037
|
+
ted scope and key names, never their values, and claim success only when the command succeeded.","When declared, TEST_DB\
|
|
1038
|
+
_NAME is the exact disposable integration database and BROWSER_TEST_DB_NAME is a separate reusable browser-fixture datab\
|
|
1039
|
+
ase whose migration ledger survives routine runs. Follow the application\u2019s declared test resources; never reset DB_NAME,\
|
|
1040
|
+
share these test identities, or invent a database name."]);function Kr(t=""){return String(t??"").trim()}function Jr(t,e){
|
|
1041
|
+
if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object.`);return t}function Fe(t,e,r){let n=new Set(
|
|
1042
|
+
e),o=Object.keys(t).filter(s=>!n.has(s));if(o.length>0)throw new TypeError(`${r} contains unsupported fields: ${o.join("\
|
|
1043
|
+
, ")}.`)}function Mu(t){if(Fe(t,["conversationKind","scope","session","hostGuidance"],"Vibe64 session context"),t.hostGuidance!==
|
|
1044
|
+
void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,"utf8")>1024))throw new TypeError("Vibe64 hos\
|
|
1045
|
+
t guidance must be bounded text supplied by the host.");if(!Pu.includes(t.conversationKind))throw new TypeError("Vibe64 \
|
|
1046
|
+
session context has an unknown conversationKind.");let e=Jr(t.session,"Vibe64 session capabilities");Fe(e,qs,"Vibe64 ses\
|
|
1047
|
+
sion capabilities");let r=Object.fromEntries(qs.map(n=>{if(typeof e[n]!="boolean")throw new TypeError(`Vibe64 session ca\
|
|
1048
|
+
pability ${n} must be boolean.`);return[n,e[n]]}));return{conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?
|
|
1049
|
+
{hostGuidance:t.hostGuidance}:{},session:r}}function Nu(t){Fe(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(
|
|
1050
|
+
t.stableContext||"").trim();if(!e||e.length>ku)throw new TypeError("Vibe64 ephemeral context requires bounded stableCont\
|
|
1051
|
+
ext.");return{scope:"ephemeral",stableContext:e}}function ju(t){if(t.scope==="session")return Mu(t);if(t.scope==="epheme\
|
|
1052
|
+
ral")return Nu(t);throw new TypeError("The Vibe64 driver supports session and ephemeral scopes only.")}async function Bs(t={},{readRegistry:e=Ru,workdir:r=""}={}){let n=Jr(t,"Vibe64 host resolver request");if(Fe(n,["data","\
|
|
1053
|
+
providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(n.scope))throw new TypeError(
|
|
1054
|
+
"The Vibe64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=Jr(n.data,"Vibe64 host \
|
|
1055
|
+
resolver data");Fe(o,["registryPath"],"Vibe64 host resolver data");let s=Kr(o.registryPath);if(!Wr.isAbsolute(s))throw new TypeError(
|
|
1056
|
+
"Vibe64 host resolver data requires an absolute registryPath.");let i=JSON.parse(await e(s,"utf8"));if(!Array.isArray(i?.
|
|
1057
|
+
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=Kr(n.providerSessionId);
|
|
1058
|
+
if(n.parentSessionIds!==void 0&&(!Array.isArray(n.parentSessionIds)||n.parentSessionIds.length>32||n.parentSessionIds.some(
|
|
1059
|
+
p=>typeof p!="string"||!p.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[c,...n.parentSessionIds||
|
|
1060
|
+
[]].filter(Boolean).map(p=>a.find(h=>Kr(h?.upstreamSessionId)===p)).find(Boolean),l=u?.promptContext;if(!l)return null;if(r&&
|
|
1061
|
+
u.workdir&&Wr.resolve(r)!==Wr.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
1062
|
+
t directory.");if(l.scope==="learning"){if(Fe(l,["scope","instructions"],"Vibe64 learning context"),u.conversation?.nativeTools!==
|
|
1063
|
+
!1)throw new TypeError("Learning instructions require the restricted native conversation binding.");let p=l.instructions;
|
|
1064
|
+
if(typeof p!="string"||!p.trim()||Buffer.byteLength(p)>128*1024)throw new TypeError("Learning native context requires bo\
|
|
1065
|
+
unded nonempty teaching instructions.");return{scope:"learning",instructions:p}}return ju(l)}var Xr="";for await(let t of process.stdin)if(Xr+=t,Buffer.byteLength(Xr)>256*1024)throw new Error("Conversation instruc\
|
|
1066
|
+
tion input exceeds 256 KiB.");var Hs=JSON.parse(Xr);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1067
|
+
process.stdout.write(await t(Hs))}else{let t=Gr({resolveConversation:async e=>await Bs(e,{workdir:process.cwd()})?{delivery:"\
|
|
1068
|
+
native"}:null});process.stdout.write(JSON.stringify(await t(Hs)))}
|