vibe64 0.1.78 → 0.1.80
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 +1523 -1512
- package/bin/server.js +100 -98
- package/bin/upgrade-state.js +3288 -3277
- package/dist/assets/{GithubBrowserTabs-B2r19V0U.js → GithubBrowserTabs-d5SRhPw-.js} +1 -1
- package/dist/assets/GithubBrowserTabs-d5SRhPw-.js.br +0 -0
- package/dist/assets/GithubBrowserTabs-d5SRhPw-.js.gz +0 -0
- package/dist/assets/{LocalDatabaseServer-Ck9nZrGW.js → LocalDatabaseServer-CIAX_Xx8.js} +1 -1
- package/dist/assets/LocalDatabaseServer-CIAX_Xx8.js.br +0 -0
- package/dist/assets/LocalDatabaseServer-CIAX_Xx8.js.gz +0 -0
- package/dist/assets/{Vibe64DashboardPageHeader-C4iTKeE0.js → Vibe64DashboardPageHeader-CyYFBVSw.js} +1 -1
- package/dist/assets/Vibe64DashboardPageHeader-CyYFBVSw.js.br +0 -0
- package/dist/assets/Vibe64DashboardPageHeader-CyYFBVSw.js.gz +0 -0
- package/dist/assets/{Vibe64DatabaseWorkspace-ChA-2QPU.js → Vibe64DatabaseWorkspace-Dep64whC.js} +1 -1
- package/dist/assets/Vibe64DatabaseWorkspace-Dep64whC.js.br +0 -0
- package/dist/assets/{Vibe64DatabaseWorkspace-ChA-2QPU.js.gz → Vibe64DatabaseWorkspace-Dep64whC.js.gz} +0 -0
- package/dist/assets/{Vibe64FileArea-DBEJsJSq.js → Vibe64FileArea-r9PP5pT7.js} +1 -1
- package/dist/assets/Vibe64FileArea-r9PP5pT7.js.br +0 -0
- package/dist/assets/Vibe64FileArea-r9PP5pT7.js.gz +0 -0
- package/dist/assets/Vibe64OutputControls-B6wjUtLL.js +8 -0
- package/dist/assets/Vibe64OutputControls-B6wjUtLL.js.br +0 -0
- package/dist/assets/Vibe64OutputControls-B6wjUtLL.js.gz +0 -0
- package/dist/assets/{Vibe64OutputControls-aQCEvUL2.css → Vibe64OutputControls-gSUdkqME.css} +1 -1
- package/dist/assets/Vibe64OutputControls-gSUdkqME.css.br +0 -0
- package/dist/assets/Vibe64OutputControls-gSUdkqME.css.gz +0 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-sT07hHPs.js → Vibe64RepositoryWorkspace-C_ez14Jz.js} +1 -1
- package/dist/assets/Vibe64RepositoryWorkspace-C_ez14Jz.js.br +0 -0
- package/dist/assets/Vibe64RepositoryWorkspace-C_ez14Jz.js.gz +0 -0
- package/dist/assets/{Vibe64SessionFiles-Djef01EV.js → Vibe64SessionFiles-CJPrBsND.js} +1 -1
- package/dist/assets/Vibe64SessionFiles-CJPrBsND.js.br +0 -0
- package/dist/assets/Vibe64SessionFiles-CJPrBsND.js.gz +0 -0
- package/dist/assets/{Vibe64SessionSourceEditor-CIGBLYYN.js → Vibe64SessionSourceEditor-CwE0Y-ka.js} +1 -1
- package/dist/assets/Vibe64SessionSourceEditor-CwE0Y-ka.js.br +0 -0
- package/dist/assets/Vibe64SessionSourceEditor-CwE0Y-ka.js.gz +0 -0
- package/dist/assets/{Vibe64UiStoryboardView-CjkWoB8b.js → Vibe64UiStoryboardView-COViVA_8.js} +1 -1
- package/dist/assets/Vibe64UiStoryboardView-COViVA_8.js.br +0 -0
- package/dist/assets/Vibe64UiStoryboardView-COViVA_8.js.gz +0 -0
- package/dist/assets/{_pageId_-BTjeqgTN.js → _pageId_-DuE37c72.js} +1 -1
- package/dist/assets/{_sessionId_-C7Jh2bL4.js → _sessionId_-T6qoKZhb.js} +1 -1
- package/dist/assets/_sessionId_-T6qoKZhb.js.br +0 -0
- package/dist/assets/_sessionId_-T6qoKZhb.js.gz +0 -0
- package/dist/assets/{_sessionTool_-DITdXCS4.js → _sessionTool_-B-b_DFay.js} +1 -1
- package/dist/assets/{access-DIaPNdxr.js → access-Dx-76I4I.js} +1 -1
- package/dist/assets/access-Dx-76I4I.js.br +0 -0
- package/dist/assets/access-Dx-76I4I.js.gz +0 -0
- package/dist/assets/{app-mELSmS67.js → app-BM5ppUKY.js} +1 -1
- package/dist/assets/app-BM5ppUKY.js.br +0 -0
- package/dist/assets/app-BM5ppUKY.js.gz +0 -0
- package/dist/assets/{changes-DlxKdjdP.js → changes-CI15aJ2s.js} +1 -1
- package/dist/assets/{client-CL02nP02.js → client-CtgiCplj.js} +2 -2
- package/dist/assets/client-CtgiCplj.js.br +0 -0
- package/dist/assets/client-CtgiCplj.js.gz +0 -0
- package/dist/assets/{client-CLpGzGwX.js → client-wU-vn9Gt.js} +2 -2
- package/dist/assets/client-wU-vn9Gt.js.br +0 -0
- package/dist/assets/client-wU-vn9Gt.js.gz +0 -0
- package/dist/assets/{dashboard-km-kuDid.js → dashboard-DD-Kz8sQ.js} +1 -1
- package/dist/assets/{english-definitions-CMICWgdF.js → english-definitions-B-puV4oO.js} +1 -1
- package/dist/assets/english-definitions-B-puV4oO.js.br +0 -0
- package/dist/assets/english-definitions-B-puV4oO.js.gz +0 -0
- package/dist/assets/{env-DjkxkxdX.js → env-CsRMp84w.js} +1 -1
- package/dist/assets/env-CsRMp84w.js.br +0 -0
- package/dist/assets/env-CsRMp84w.js.gz +0 -0
- package/dist/assets/{error-C7q1-2bC.js → error-CL5AgVRX.js} +1 -1
- package/dist/assets/error-CL5AgVRX.js.br +0 -0
- package/dist/assets/error-CL5AgVRX.js.gz +0 -0
- package/dist/assets/{fileTypes-Dbn0qwKS.js → fileTypes-CFECKFVN.js} +1 -1
- package/dist/assets/fileTypes-CFECKFVN.js.br +0 -0
- package/dist/assets/fileTypes-CFECKFVN.js.gz +0 -0
- package/dist/assets/{health-BwJ6Z251.js → health-4aQl5EcU.js} +1 -1
- package/dist/assets/health-4aQl5EcU.js.br +0 -0
- package/dist/assets/health-4aQl5EcU.js.gz +0 -0
- package/dist/assets/{history-D2TywQVv.js → history-B5Sor4EE.js} +1 -1
- package/dist/assets/history-B5Sor4EE.js.br +0 -0
- package/dist/assets/history-B5Sor4EE.js.gz +0 -0
- package/dist/assets/{index-D14nUmm7.js → index-BAvE8_Ib.js} +5 -5
- package/dist/assets/index-BAvE8_Ib.js.br +0 -0
- package/dist/assets/index-BAvE8_Ib.js.gz +0 -0
- package/dist/assets/{integrations-BZFXW2Cp.js → integrations-DksSxQbj.js} +96 -10
- package/dist/assets/integrations-DksSxQbj.js.br +0 -0
- package/dist/assets/integrations-DksSxQbj.js.gz +0 -0
- package/dist/assets/{issues-CLvbBTek.js → issues-DK2L8AHT.js} +1 -1
- package/dist/assets/issues-DK2L8AHT.js.br +0 -0
- package/dist/assets/issues-DK2L8AHT.js.gz +0 -0
- package/dist/assets/{learning-DwytxEXC.js → learning-DeuGeINY.js} +1 -1
- package/dist/assets/{packages-BeiF8W7l.js → packages-Du3QFyu-.js} +1 -1
- package/dist/assets/packages-Du3QFyu-.js.br +0 -0
- package/dist/assets/packages-Du3QFyu-.js.gz +0 -0
- package/dist/assets/{pages-BIRQk4b8.js → pages-CBvnECLI.js} +1 -1
- package/dist/assets/{pages-BnAyUdL4.js → pages-D3MpRYy4.js} +1 -1
- package/dist/assets/pages-D3MpRYy4.js.br +0 -0
- package/dist/assets/pages-D3MpRYy4.js.gz +0 -0
- package/dist/assets/{project-GnljGud1.js → project-BFylqlOt.js} +13 -13
- package/dist/assets/project-BFylqlOt.js.br +0 -0
- package/dist/assets/project-BFylqlOt.js.gz +0 -0
- package/dist/assets/project-BZ-FhyDR.css +1 -0
- package/dist/assets/project-BZ-FhyDR.css.br +0 -0
- package/dist/assets/project-BZ-FhyDR.css.gz +0 -0
- package/dist/assets/{project-files-e4-Q65vT.js → project-files-CHgBwX2E.js} +1 -1
- package/dist/assets/project-files-CHgBwX2E.js.br +0 -0
- package/dist/assets/project-files-CHgBwX2E.js.gz +0 -0
- package/dist/assets/{project-shared-ShellOutlet-DKYDipmC.js → project-shared-ShellOutlet-CIoqgO35.js} +1 -1
- package/dist/assets/project-shared-ShellOutlet-CIoqgO35.js.br +0 -0
- package/dist/assets/project-shared-ShellOutlet-CIoqgO35.js.gz +0 -0
- package/dist/assets/{project-shared-VBottomSheet-BSE28ENQ.js → project-shared-VBottomSheet-Bezz1r7A.js} +1 -1
- package/dist/assets/project-shared-VBottomSheet-Bezz1r7A.js.br +0 -0
- package/dist/assets/project-shared-VBottomSheet-Bezz1r7A.js.gz +0 -0
- package/dist/assets/{project-shared-VToolbar-CrezJP9z.js → project-shared-VToolbar-DmXu_VIt.js} +1 -1
- package/dist/assets/project-shared-VToolbar-DmXu_VIt.js.br +0 -0
- package/dist/assets/project-shared-VToolbar-DmXu_VIt.js.gz +0 -0
- package/dist/assets/{project-shared-pageNames-6Jz0BfbS.js → project-shared-pageNames-BiomB55Q.js} +1 -1
- package/dist/assets/project-shared-pageNames-BiomB55Q.js.br +0 -0
- package/dist/assets/project-shared-pageNames-BiomB55Q.js.gz +0 -0
- package/dist/assets/{pull-requests-DH9gWw10.js → pull-requests-CPBGulVu.js} +1 -1
- package/dist/assets/pull-requests-CPBGulVu.js.br +0 -0
- package/dist/assets/pull-requests-CPBGulVu.js.gz +0 -0
- package/dist/assets/{repository-BNltUuvb.js → repository-CWDpx49H.js} +1 -1
- package/dist/assets/{session-Ck9aH4Yl.js → session-D2z1O4Y4.js} +1 -1
- package/dist/assets/session-D2z1O4Y4.js.br +0 -0
- package/dist/assets/session-D2z1O4Y4.js.gz +0 -0
- package/dist/assets/{settings-D8Ofbk56.js → settings-BZRdBSb9.js} +1 -1
- package/dist/assets/settings-BZRdBSb9.js.br +0 -0
- package/dist/assets/settings-BZRdBSb9.js.gz +0 -0
- package/dist/assets/{useArchivedVibe64Sessions-LIZjeLbd.js → useArchivedVibe64Sessions-C3jJk531.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-C3jJk531.js.br +0 -0
- package/dist/assets/useArchivedVibe64Sessions-C3jJk531.js.gz +0 -0
- package/dist/assets/{vibe64AttachmentDownload-1_XfvfYp.js → vibe64AttachmentDownload-DcLsJc9X.js} +1 -1
- package/dist/assets/{vibe64SavedEnvValues-Bs7r4xWE.js → vibe64SavedEnvValues-hAfcxHhJ.js} +1 -1
- package/dist/assets/{vue-flow-core-iwGljzru.js → vue-flow-core-BwhpINSc.js} +1 -1
- package/dist/assets/vue-flow-core-BwhpINSc.js.br +0 -0
- package/dist/assets/vue-flow-core-BwhpINSc.js.gz +0 -0
- package/dist/index.html +2 -2
- package/docs/colleague-usage/ai-accounts.md +4 -4
- package/docs/colleague-usage/ai-tasks.md +3 -2
- package/docs/colleague-usage/auto-workflow.md +99 -43
- package/docs/colleague-usage/chat-settings.md +46 -44
- package/docs/colleague-usage/coding-agents.md +8 -5
- package/docs/colleague-usage/connected-projects.md +196 -48
- package/docs/colleague-usage/connected-repositories.md +50 -6
- package/docs/colleague-usage/development-env.md +2 -2
- package/docs/colleague-usage/github-work.md +3 -3
- package/docs/colleague-usage/main-chat-approvals.md +2 -2
- package/docs/colleague-usage/passes.md +177 -156
- package/docs/colleague-usage/plans.md +121 -38
- package/docs/colleague-usage/preview-starting-application.md +6 -0
- package/docs/colleague-usage/preview-stop-and-restart.md +51 -0
- package/docs/colleague-usage/preview.md +10 -37
- package/docs/colleague-usage/ui-pass.md +32 -22
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +5 -0
- package/node_modules/@jskit-ai/payments-core/README.md +72 -8
- package/node_modules/@jskit-ai/payments-core/contracts/configuration.schema.json +56 -1
- package/node_modules/@jskit-ai/payments-core/contracts/conformance.json +484 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +17 -5
- package/node_modules/@jskit-ai/payments-core/package.json +2 -1
- package/node_modules/@local/vibe64-execution/package.json +1 -0
- package/node_modules/@local/vibe64-genesis/README.md +12 -0
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +96 -96
- package/node_modules/@local/vibe64-genesis/package.json +2 -1
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +182 -174
- package/node_modules/@local/vibe64-genesis/src/server/index.js +573 -569
- package/node_modules/@local/vibe64-project/package.json +1 -0
- package/node_modules/@local/vibe64-terminals/package.json +1 -0
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +900 -890
- package/node_modules/chokidar/LICENSE +21 -0
- package/node_modules/chokidar/README.md +305 -0
- package/node_modules/chokidar/package.json +14 -0
- package/node_modules/readdirp/LICENSE +21 -0
- package/node_modules/readdirp/README.md +122 -0
- package/node_modules/readdirp/package.json +9 -0
- package/package.json +11 -7
- package/server.bundle.mjs +46995 -45449
- package/dist/assets/GithubBrowserTabs-B2r19V0U.js.br +0 -0
- package/dist/assets/GithubBrowserTabs-B2r19V0U.js.gz +0 -0
- package/dist/assets/LocalDatabaseServer-Ck9nZrGW.js.br +0 -0
- package/dist/assets/LocalDatabaseServer-Ck9nZrGW.js.gz +0 -0
- package/dist/assets/Vibe64DashboardPageHeader-C4iTKeE0.js.br +0 -0
- package/dist/assets/Vibe64DashboardPageHeader-C4iTKeE0.js.gz +0 -0
- package/dist/assets/Vibe64DatabaseWorkspace-ChA-2QPU.js.br +0 -0
- package/dist/assets/Vibe64FileArea-DBEJsJSq.js.br +0 -0
- package/dist/assets/Vibe64FileArea-DBEJsJSq.js.gz +0 -0
- package/dist/assets/Vibe64OutputControls-DpFdKIO2.js +0 -8
- package/dist/assets/Vibe64OutputControls-DpFdKIO2.js.br +0 -0
- package/dist/assets/Vibe64OutputControls-DpFdKIO2.js.gz +0 -0
- package/dist/assets/Vibe64OutputControls-aQCEvUL2.css.br +0 -0
- package/dist/assets/Vibe64OutputControls-aQCEvUL2.css.gz +0 -0
- package/dist/assets/Vibe64RepositoryWorkspace-sT07hHPs.js.br +0 -0
- package/dist/assets/Vibe64RepositoryWorkspace-sT07hHPs.js.gz +0 -0
- package/dist/assets/Vibe64SessionFiles-Djef01EV.js.br +0 -0
- package/dist/assets/Vibe64SessionFiles-Djef01EV.js.gz +0 -0
- package/dist/assets/Vibe64SessionSourceEditor-CIGBLYYN.js.br +0 -0
- package/dist/assets/Vibe64SessionSourceEditor-CIGBLYYN.js.gz +0 -0
- package/dist/assets/Vibe64UiStoryboardView-CjkWoB8b.js.br +0 -0
- package/dist/assets/Vibe64UiStoryboardView-CjkWoB8b.js.gz +0 -0
- package/dist/assets/_sessionId_-C7Jh2bL4.js.br +0 -0
- package/dist/assets/_sessionId_-C7Jh2bL4.js.gz +0 -0
- package/dist/assets/access-DIaPNdxr.js.br +0 -0
- package/dist/assets/access-DIaPNdxr.js.gz +0 -0
- package/dist/assets/app-mELSmS67.js.br +0 -0
- package/dist/assets/app-mELSmS67.js.gz +0 -0
- package/dist/assets/client-CL02nP02.js.br +0 -0
- package/dist/assets/client-CL02nP02.js.gz +0 -0
- package/dist/assets/client-CLpGzGwX.js.br +0 -0
- package/dist/assets/client-CLpGzGwX.js.gz +0 -0
- package/dist/assets/english-definitions-CMICWgdF.js.br +0 -0
- package/dist/assets/english-definitions-CMICWgdF.js.gz +0 -0
- package/dist/assets/env-DjkxkxdX.js.br +0 -0
- package/dist/assets/env-DjkxkxdX.js.gz +0 -0
- package/dist/assets/error-C7q1-2bC.js.br +0 -0
- package/dist/assets/error-C7q1-2bC.js.gz +0 -0
- package/dist/assets/fileTypes-Dbn0qwKS.js.br +0 -0
- package/dist/assets/fileTypes-Dbn0qwKS.js.gz +0 -0
- package/dist/assets/health-BwJ6Z251.js.br +0 -0
- package/dist/assets/health-BwJ6Z251.js.gz +0 -0
- package/dist/assets/history-D2TywQVv.js.br +0 -0
- package/dist/assets/history-D2TywQVv.js.gz +0 -0
- package/dist/assets/index-D14nUmm7.js.br +0 -0
- package/dist/assets/index-D14nUmm7.js.gz +0 -0
- package/dist/assets/integrations-BZFXW2Cp.js.br +0 -0
- package/dist/assets/integrations-BZFXW2Cp.js.gz +0 -0
- package/dist/assets/issues-CLvbBTek.js.br +0 -0
- package/dist/assets/issues-CLvbBTek.js.gz +0 -0
- package/dist/assets/packages-BeiF8W7l.js.br +0 -0
- package/dist/assets/packages-BeiF8W7l.js.gz +0 -0
- package/dist/assets/pages-BnAyUdL4.js.br +0 -3
- package/dist/assets/pages-BnAyUdL4.js.gz +0 -0
- package/dist/assets/project-GnljGud1.js.br +0 -0
- package/dist/assets/project-GnljGud1.js.gz +0 -0
- package/dist/assets/project-W_VltXAt.css +0 -1
- package/dist/assets/project-W_VltXAt.css.br +0 -0
- package/dist/assets/project-W_VltXAt.css.gz +0 -0
- package/dist/assets/project-files-e4-Q65vT.js.br +0 -0
- package/dist/assets/project-files-e4-Q65vT.js.gz +0 -0
- package/dist/assets/project-shared-ShellOutlet-DKYDipmC.js.br +0 -0
- package/dist/assets/project-shared-ShellOutlet-DKYDipmC.js.gz +0 -0
- package/dist/assets/project-shared-VBottomSheet-BSE28ENQ.js.br +0 -0
- package/dist/assets/project-shared-VBottomSheet-BSE28ENQ.js.gz +0 -0
- package/dist/assets/project-shared-VToolbar-CrezJP9z.js.br +0 -0
- package/dist/assets/project-shared-VToolbar-CrezJP9z.js.gz +0 -0
- package/dist/assets/project-shared-pageNames-6Jz0BfbS.js.br +0 -0
- package/dist/assets/project-shared-pageNames-6Jz0BfbS.js.gz +0 -0
- package/dist/assets/pull-requests-DH9gWw10.js.br +0 -0
- package/dist/assets/pull-requests-DH9gWw10.js.gz +0 -0
- package/dist/assets/session-Ck9aH4Yl.js.br +0 -0
- package/dist/assets/session-Ck9aH4Yl.js.gz +0 -0
- package/dist/assets/settings-D8Ofbk56.js.br +0 -0
- package/dist/assets/settings-D8Ofbk56.js.gz +0 -0
- package/dist/assets/useArchivedVibe64Sessions-LIZjeLbd.js.br +0 -0
- package/dist/assets/useArchivedVibe64Sessions-LIZjeLbd.js.gz +0 -0
- package/dist/assets/vue-flow-core-iwGljzru.js.br +0 -0
- package/dist/assets/vue-flow-core-iwGljzru.js.gz +0 -0
|
@@ -1,153 +1,153 @@
|
|
|
1
1
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
2
|
-
var
|
|
3
|
-
status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=
|
|
4
|
-
(this.messageCode=String(n.messageCode),this.messageParams=
|
|
2
|
+
var Vm=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function h(e,{fallback:t=""}={}){return String(e||"").trim()||t}function ie(e){return String(e??"").trim()}function W(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Er(e){return W(e)?{...e}:{}}var re=class extends Error{constructor(t,r,n={}){super(r,n.cause===void 0?void 0:{cause:n.cause}),this.name="AppError",this.
|
|
3
|
+
status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=Er(n.params),n.messageCode&&
|
|
4
|
+
(this.messageCode=String(n.messageCode),this.messageParams=Er(n.messageParams)),this.details=n.details,this.headers=n.headers||
|
|
5
5
|
{}}};function $(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||
|
|
6
|
-
|
|
7
|
-
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function
|
|
8
|
-
let{items:r}=t;if(
|
|
9
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
10
|
-
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(
|
|
6
|
+
Za(t)}function Za(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}function vr(e){return e!==null&&typeof e=="object"&&$(e.structure)&&$(e.operations)&&typeof e.validateWith=="function"&&
|
|
7
|
+
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function vt(e,t){if(!Object.hasOwn(t,"items"))return null;
|
|
8
|
+
let{items:r}=t;if(vr(r))return{kind:"schema",schema:r};if(!$(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
9
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Qe(e,t){
|
|
10
|
+
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(vr(r))return{kind:"schema",schema:r};if(!$(r)||typeof r.type!=
|
|
11
11
|
"string")throw new Error(`Object field "${e}" must define values as either a Schema instance or a field definition objec\
|
|
12
|
-
t.`);return{kind:"definition",definition:r}}function
|
|
12
|
+
t.`);return{kind:"definition",definition:r}}function St(e,t){let r=Object.hasOwn(t,"schema"),n=Object.hasOwn(t,"values"),
|
|
13
13
|
o=Object.hasOwn(t,"additionalProperties");if(r&&n)throw new Error(`Object field "${e}" cannot define both schema and val\
|
|
14
14
|
ues.`);if(o&&t.additionalProperties!==!0)throw new Error(`Object field "${e}" only supports additionalProperties: true.`);
|
|
15
15
|
if(n&&t.additionalProperties===!0)throw new Error(`Object field "${e}" cannot define both values and additionalPropertie\
|
|
16
|
-
s: true.`);if(r){if(!
|
|
17
|
-
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:
|
|
18
|
-
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function
|
|
16
|
+
s: true.`);if(r){if(!vr(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
|
|
17
|
+
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Qe(
|
|
18
|
+
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ne(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}function Sr(e,t=""){
|
|
19
19
|
if($(e))for(let[r,n]of Object.entries(e)){if(!$(n))continue;let o=t?`${t}.${r}`:r;for(let i of["minItems","maxItems"]){if(!Object.
|
|
20
20
|
hasOwn(n,i))continue;let s=n[i];if(n.type!=="array"||!Number.isInteger(s)||s<0)throw new Error(`Field "${o}" ${i} must b\
|
|
21
21
|
e a non-negative integer on an array field.`)}if(n.minItems>n.maxItems)throw new Error(`Field "${o}" minItems (${n.minItems}\
|
|
22
|
-
) is above its maxItems (${n.maxItems}).`);n.type==="array"&&$(n.items)&&typeof n.items.type=="string"&&
|
|
23
|
-
o)}}var
|
|
24
|
-
|
|
25
|
-
$`,
|
|
26
|
-
))?${
|
|
27
|
-
0)}function
|
|
28
|
-
1&&o<=12&&i>=1&&i<=
|
|
29
|
-
`temporalPrecision for "${t}" must be a non-negative integer.`);return r}}function
|
|
30
|
-
e.length<=t}function
|
|
31
|
-
if(typeof e!="string")return!1;let r=
|
|
32
|
-
let r=
|
|
33
|
-
"":`(?:\\.\\d{1,${e}})?`}function
|
|
34
|
-
return`^${
|
|
35
|
-
test(e))r=Number(e);else return null;return!Number.isSafeInteger(r)||r<-t||r>t?null:r===0?0:r}var
|
|
36
|
-
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function
|
|
37
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
38
|
-
let o=r?
|
|
22
|
+
) is above its maxItems (${n.maxItems}).`);n.type==="array"&&$(n.items)&&typeof n.items.type=="string"&&Sr({"[]":n.items},
|
|
23
|
+
o)}}var Tr="^(?:0|-?[1-9]\\d*)$",ro="\\d{4}",no="0[1-9]|1[0-2]",oo="0[1-9]|[12]\\d|3[01]",io="[01]\\d|2[0-3]",xe="[0-5]\\d",
|
|
24
|
+
Tt=`(?:${io}):${xe}`,so=`(?:Z|[+-](?:${io}):${xe})`,ao=`(${ro})-(${no})-(${oo})`,co=`${ro}-(?:${no})-(?:${oo})`,uo=`^${co}\
|
|
25
|
+
$`,ec=new RegExp(`^${ao}$`),tc=new RegExp(`^${Tt}(?::${xe}(?:\\.(\\d+))?)?$`),rc=new RegExp(`^${ao}T${Tt}:${xe}(?:\\.(\\d+\
|
|
26
|
+
))?${so}$`),nc=new RegExp(Tr),oc=[31,28,31,30,31,30,31,31,30,31,30,31];function ic(e){return e%4===0&&(e%100!==0||e%400===
|
|
27
|
+
0)}function sc(e,t){return t===2?ic(e)?29:28:oc[t-1]}function lo(e,t,r){let n=Number(e),o=Number(t),i=Number(r);return o>=
|
|
28
|
+
1&&o<=12&&i>=1&&i<=sc(n,o)}function Ze(e,t){let r=e.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
|
|
29
|
+
`temporalPrecision for "${t}" must be a non-negative integer.`);return r}}function po(e,t){return e===void 0?!0:t===void 0||
|
|
30
|
+
e.length<=t}function mo(e){if(typeof e!="string")return!1;let t=ec.exec(e);return t!==null&&lo(t[1],t[2],t[3])}function fo(e,t){
|
|
31
|
+
if(typeof e!="string")return!1;let r=tc.exec(e);return r!==null&&po(r[1],t)}function ho(e,t){if(typeof e!="string")return!1;
|
|
32
|
+
let r=rc.exec(e);return r===null?!1:lo(r[1],r[2],r[3])&&po(r[4],t)}function go(e){return e===void 0?"(?:\\.\\d+)?":e===0?
|
|
33
|
+
"":`(?:\\.\\d{1,${e}})?`}function _o(e,t){let r=Ze(e,t);return`^${Tt}(?::${xe}${go(r)})?$`}function wo(e,t){let r=Ze(e,t);
|
|
34
|
+
return`^${co}T${Tt}:${xe}${go(r)}${so}$`}function Or(e,t){let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&nc.
|
|
35
|
+
test(e))r=Number(e);else return null;return!Number.isSafeInteger(r)||r<-t||r>t?null:r===0?0:r}var ac=new Set(["__proto__","prototype","constructor"]);function b(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function cc(e,t){if(ac.
|
|
36
|
+
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function uc(e){return typeof e!="string"?e:e.replace(
|
|
37
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Ar(e,t,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
38
|
+
let o=r?uc(e):e;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${t}() expects a non-empty \
|
|
39
39
|
dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${t}() received an invalid path "${o}".`);
|
|
40
|
-
for(let s of i)
|
|
41
|
-
|
|
42
|
-
return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:
|
|
43
|
-
none:()=>({type:
|
|
40
|
+
for(let s of i)cc(s,t);return i}var lc="http://json-schema.org/draft-07/schema#",se="x-json-rest-schema",Ir=["object","array","string","number","boolean"],
|
|
41
|
+
Rr=Symbol("json-rest-schema.exportContext"),dc=["true","1","yes","y","on"],pc=["false","0","no","n","off"];function yo(e){
|
|
42
|
+
return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Tr}]}}function _e(e,t){return{[se]:{[e]:t}}}var mc={
|
|
43
|
+
none:()=>({type:Ir}),blob:()=>({type:Ir}),serialize:()=>({type:Ir}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
44
44
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
45
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
46
|
-
type:"string",format:"date-time",pattern:
|
|
47
|
-
fieldName:t})=>({type:"string",pattern:
|
|
48
|
-
let t=new Set([...
|
|
45
|
+
eger","string"]}),epochMilliseconds:()=>yo(864e13),epochSeconds:()=>yo(864e10),dateTime:({definition:e,fieldName:t})=>({
|
|
46
|
+
type:"string",format:"date-time",pattern:wo(e,t)}),date:()=>({type:"string",format:"date",pattern:uo}),time:({definition:e,
|
|
47
|
+
fieldName:t})=>({type:"string",pattern:_o(e,t)}),boolean:({definition:e})=>{if(e.strictBoolean===!0)return{type:"boolean"};
|
|
48
|
+
let t=new Set([...dc,String(e.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...pc,String(e.stringFalseWhen||
|
|
49
49
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...r,...t]}]}},
|
|
50
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
50
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},fc={minLength:({definition:e,parameterValue:t})=>e.
|
|
51
51
|
type==="string"?{minLength:t}:null,maxLength:({definition:e,parameterValue:t})=>e.type==="string"?{maxLength:t}:null,min:({
|
|
52
|
-
definition:e,parameterValue:t})=>
|
|
52
|
+
definition:e,parameterValue:t})=>Ne(e)?{minimum:t}:null,max:({definition:e,parameterValue:t})=>Ne(e)?{maximum:t}:null,pattern:({
|
|
53
53
|
definition:e,parameterValue:t})=>e.type==="string"?{pattern:t instanceof RegExp?t.source:t}:null,enum:({parameterValue:e})=>({
|
|
54
54
|
enum:e}),minItems:({definition:e,parameterValue:t})=>e.type==="array"?{minItems:t}:null,maxItems:({definition:e,parameterValue:t})=>e.
|
|
55
55
|
type==="array"?{maxItems:t}:null,notEmpty:({parameterValue:e,definition:t})=>!e||t.type==="array"?null:{minLength:1},uppercase:({
|
|
56
|
-
parameterValue:e})=>e?
|
|
57
|
-
null,length:({parameterValue:e})=>
|
|
58
|
-
null,precision:({parameterValue:e})=>
|
|
59
|
-
parameterValue:e})=>
|
|
60
|
-
defaultTo:()=>null};function
|
|
61
|
-
"object"&&!Array.isArray(n)&&!Array.isArray(o)){
|
|
56
|
+
parameterValue:e})=>e?_e("transforms",{uppercase:!0}):null,lowercase:({parameterValue:e})=>e?_e("transforms",{lowercase:!0}):
|
|
57
|
+
null,length:({parameterValue:e})=>_e("transforms",{length:e}),unsigned:({parameterValue:e})=>e?_e("metadata",{unsigned:!0}):
|
|
58
|
+
null,precision:({parameterValue:e})=>_e("metadata",{precision:e}),scale:({parameterValue:e})=>_e("metadata",{scale:e}),temporalPrecision:({
|
|
59
|
+
parameterValue:e})=>_e("metadata",{temporalPrecision:e}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
|
|
60
|
+
defaultTo:()=>null};function Nr(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];if(n&&o&&typeof n=="object"&&typeof o==
|
|
61
|
+
"object"&&!Array.isArray(n)&&!Array.isArray(o)){Nr(o,n);continue}e[r]=n}}function hc(e,t){if(!t||typeof t!="object"||Array.
|
|
62
62
|
isArray(t))throw new Error("JSON Schema export hooks must return an object or null.");for(let r of Object.keys(t)){if(r===
|
|
63
|
-
|
|
64
|
-
e[r]=t[r]}}function
|
|
65
|
-
1?e:{anyOf:n}}function
|
|
66
|
-
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n=
|
|
67
|
-
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
68
|
-
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=
|
|
63
|
+
se&&e[r]&&typeof e[r]=="object"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){Nr(e[r],t[r]);continue}
|
|
64
|
+
e[r]=t[r]}}function gc(e,t){let n=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return n.length===
|
|
65
|
+
1?e:{anyOf:n}}function _c(e,t){if(!Object.hasOwn(e.types,t.type))throw new Error(`No casting function for type: ${t.type}`);
|
|
66
|
+
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n=mc[t.type];if(!n)throw new Error(
|
|
67
|
+
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function wc(e,t,r){if(!Object.
|
|
68
|
+
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=fc[t];
|
|
69
69
|
if(o)return o;throw new Error(`Validator '${t}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
70
|
-
hook.`)}function
|
|
71
|
-
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
72
|
-
void 0&&t.operation!==void 0){let r=
|
|
70
|
+
hook.`)}function bo(e){if(e===void 0)return"create";if(["create","replace","patch"].includes(e))return e;throw new Error(
|
|
71
|
+
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function yc(e,t={}){if(t.mode!==
|
|
72
|
+
void 0&&t.operation!==void 0){let r=bo(t.mode);if(r!==t.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
73
73
|
s: mode '${r}' does not match operation '${t.operation}'.`)}if(t.operation!==void 0){if(!Object.hasOwn(e.operations,t.operation))
|
|
74
|
-
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return
|
|
74
|
+
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return bo(t.mode)}function bc(e,t={}){
|
|
75
75
|
if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
|
|
76
|
-
let r=
|
|
77
|
-
t,
|
|
78
|
-
e[
|
|
79
|
-
"_").replace(/^_+|_+$/g,"")||"operation"}function
|
|
80
|
-
function
|
|
81
|
-
r&&i.operation===n&&i.additionalProperties===o)||null}function
|
|
82
|
-
return e.nextDefinitionId+=1,n}function
|
|
76
|
+
let r=yc(e,t);return{operationName:r,operation:e.operations[r]}}function Ec(e={}){let t={...e};return Object.defineProperty(
|
|
77
|
+
t,Rr,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function At(e={}){return e[Rr]?
|
|
78
|
+
e[Rr]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function vc(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
|
|
79
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function Pr(e){return $(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
|
|
80
|
+
function Ot(e){return Pr(e)?{allOf:[e]}:e}function Sc(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
|
|
81
|
+
r&&i.operation===n&&i.additionalProperties===o)||null}function Tc(e,t){let r=vc(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
82
|
+
return e.nextDefinitionId+=1,n}function Eo(e,t,r,n,o,{root:i=!1}={}){let s=At(t),a=Sc(s,e,r,n,o);if(a)return i&&(a.pointer=
|
|
83
83
|
"#",s.rootNode=a),a;let c={schema:e,operationName:r,operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
84
|
-
|
|
85
|
-
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=
|
|
86
|
-
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=
|
|
87
|
-
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function
|
|
88
|
-
let i=
|
|
89
|
-
referenceBacked:t}}function
|
|
84
|
+
Tc(s,r),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function vo(e,t){
|
|
85
|
+
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=At(t);e.status="build\
|
|
86
|
+
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=Oc(e.schema,t,e.operationName,e.operation,e.additionalProperties);
|
|
87
|
+
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function xr(e,t,r,n,o=!1){
|
|
88
|
+
let i=At(t),s=Eo(e,t,r,n,o);return i.rootNode===s?{$ref:"#"}:vo(s,t)}function et(e,{referenceBacked:t=!1}={}){return{schema:e,
|
|
89
|
+
referenceBacked:t}}function Oc(e,t,r,n,o=!1){let i={},s=[];for(let[c,u]of Object.entries(e.structure))b(i,c,$r(e,c,u,t,r,
|
|
90
90
|
n)),n.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
|
|
91
|
-
0&&(a.required=s),a}function
|
|
92
|
-
n,"replace",s.schema.operations.replace,!1)),[
|
|
93
|
-
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return
|
|
94
|
-
let s=
|
|
95
|
-
[
|
|
96
|
-
place"?e.operations.replace:i;return
|
|
97
|
-
t,r);if(a.kind==="nested")return
|
|
98
|
-
"opaque")return
|
|
99
|
-
e,t,r,n,o,i)})}let s=
|
|
91
|
+
0&&(a.required=s),a}function Ac(e,t,r,n,o,i){let s=vt(t,r);if(!s)return null;if(s.kind==="schema")return{...Ot(xr(s.schema,
|
|
92
|
+
n,"replace",s.schema.operations.replace,!1)),[se]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,
|
|
93
|
+
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return $r(e,`${t}[]`,r.items,n,a,c)}function Ic(e,t,r,n,o,i){
|
|
94
|
+
let s=Qe(t,r);if(!s)return null;if(s.kind==="schema")return{...Ot(xr(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
95
|
+
[se]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="re\
|
|
96
|
+
place"?e.operations.replace:i;return $r(e,`${t}.*`,s.definition,n,a,c)}function Rc(e,t,r,n,o,i){if(r.type==="object"){let a=St(
|
|
97
|
+
t,r);if(a.kind==="nested")return et(xr(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
98
|
+
"opaque")return et({type:"object",additionalProperties:!0});if(a.kind==="map")return et({type:"object",additionalProperties:Ic(
|
|
99
|
+
e,t,r,n,o,i)})}let s=_c(e,r)({schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n});if(!s||typeof s!="object"||
|
|
100
100
|
Array.isArray(s))throw new Error(`Type '${r.type}' on field '${t}' returned an invalid JSON Schema fragment.`);if(r.type===
|
|
101
|
-
"array"){let a=
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
continue;let p=
|
|
105
|
-
c[
|
|
106
|
-
let m=
|
|
101
|
+
"array"){let a=Ac(e,t,r,n,o,i);if(a)return et({...s,items:a},{referenceBacked:Pr(s)})}return et(s,{referenceBacked:Pr(s)})}
|
|
102
|
+
function $r(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n},a=Rc(e,t,r,n,o,i),c=a.referenceBacked?
|
|
103
|
+
Ot(a.schema):{...a.schema},u={castType:r.type};for(let d of Object.keys(r)){if(d==="type"||!Object.hasOwn(e.validators,d))
|
|
104
|
+
continue;let p=wc(e,d,t);if(!p)continue;let f=p({...s,parameterName:d,parameterValue:r[d],fieldSchema:{...c}});f&&hc(c,f)}
|
|
105
|
+
c[se]&&(Nr(u,c[se]),delete c[se]);let l=[];r.nullable===!0&&l.push({type:"null"}),r.nullOnEmpty===!0&&l.push({const:""});
|
|
106
|
+
let m=Ot(gc(c,l));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.defaultTo!="function"){let d=e._normalizeDefault(
|
|
107
107
|
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
108
108
|
o,i,{})});if(Object.keys(d.errors).length>0){let p=Object.values(d.errors)[0];throw new Error(`defaultTo for "${t}" is i\
|
|
109
|
-
nvalid (${p.code}).`)}m.default=d.value}else u.defaults={providedByFunction:!0};return m[
|
|
110
|
-
t),{operationName:n,operation:o}=
|
|
111
|
-
o,i,{root:!0}),c={$schema:
|
|
112
|
-
|
|
113
|
-
.${String(t)}`}function
|
|
114
|
-
startsWith(r)?e.slice(r.length):null}function
|
|
115
|
-
{...n,field:o})}return r}function
|
|
116
|
-
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||b(o,s,
|
|
117
|
-
return t}function
|
|
118
|
-
function
|
|
109
|
+
nvalid (${p.code}).`)}m.default=d.value}else u.defaults={providedByFunction:!0};return m[se]=u,m}function So(e,t={}){let r=Ec(
|
|
110
|
+
t),{operationName:n,operation:o}=bc(e,r),i=r.additionalProperties===void 0?!1:r.additionalProperties,s=At(r),a=Eo(e,r,n,
|
|
111
|
+
o,i,{root:!0}),c={$schema:lc,...vo(a,r)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}function To(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Gr(e){return e instanceof
|
|
112
|
+
Le}function Pc(){return{self:!1,children:{}}}function Oo(e){return Object.keys(e.children).length>0}function we(e,t){return`${e}\
|
|
113
|
+
.${String(t)}`}function ko(e,t){return e===""?String(t):we(e,t)}function Ao(e,t){if(e===t)return"";let r=`${t}.`;return e.
|
|
114
|
+
startsWith(r)?e.slice(r.length):null}function $e(e,t){let r={};for(let n of Object.values(e)){let o=we(t,n.field);b(r,o,
|
|
115
|
+
{...n,field:o})}return r}function Dr(e){return Ar(e,"validatePath")}function Io(e){let t={};for(let r of e){let n=Dr(r),
|
|
116
|
+
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||b(o,s,Pc()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
117
|
+
return t}function Cc(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
|
|
118
|
+
function It(e){return e===null?!0:Array.isArray(e)||$(e)?Object.keys(e).length>0:e!==void 0}function Ro(e){return[...e].
|
|
119
119
|
sort((t,r)=>{let n=/^[0-9]+$/.test(t),o=/^[0-9]+$/.test(r);return n&&o?Number(t)-Number(r):n?-1:o?1:t.localeCompare(r)})}
|
|
120
|
-
function
|
|
120
|
+
function kc(e){return/^[0-9]+$/.test(e)}function Nc(e,t=new WeakMap){if(t.has(e))return t.get(e);let r=Object.create(Le.
|
|
121
121
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
122
|
-
Pt(
|
|
123
|
-
"object")return e;if(
|
|
122
|
+
Pt(Rt(e.structure,t)),r._installOperationMethods(),Object.freeze(r)}function Rt(e,t=new WeakMap){if(e===null||typeof e!=
|
|
123
|
+
"object")return e;if(Gr(e))return Nc(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
124
124
|
e.source,e.flags);return n.lastIndex=e.lastIndex,n}if(t.has(e))return t.get(e);if(Array.isArray(e)){let n=[];t.set(e,n);
|
|
125
|
-
for(let o of e)n.push(
|
|
126
|
-
o,t));return r}function Pt(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||
|
|
127
|
-
isArray(e))for(let r of e)Pt(r,t);else for(let r of Reflect.ownKeys(e))Pt(e[r],t);return Object.freeze(e)}function
|
|
128
|
-
return Pt(
|
|
129
|
-
if(!Object.hasOwn(e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=
|
|
130
|
-
function
|
|
131
|
-
r,n)}if(t?.type==="array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!
|
|
132
|
-
let a=
|
|
133
|
-
function
|
|
125
|
+
for(let o of e)n.push(Rt(o,t));return n}if(!$(e))return e;let r={};t.set(e,r);for(let[n,o]of Object.entries(e))b(r,n,Rt(
|
|
126
|
+
o,t));return r}function Pt(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||Gr(e))return e;if(t.add(e),Array.
|
|
127
|
+
isArray(e))for(let r of e)Pt(r,t);else for(let r of Reflect.ownKeys(e))Pt(e[r],t);return Object.freeze(e)}function Mr(e){
|
|
128
|
+
return Pt(Rt(e))}var Lr=new WeakMap;function Ur(e,t,r=""){if(!Gr(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;
|
|
129
|
+
if(!Object.hasOwn(e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=ko(r,n);return No(e,i,o,s)}
|
|
130
|
+
function No(e,t,r,n){if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:Ur(o.schema,
|
|
131
|
+
r,n)}if(t?.type==="array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!kc(i))return null;
|
|
132
|
+
let a=we(n,i);return o.kind==="schema"?s.length<1?null:Ur(o.schema,s,a):s.length<1?o.definition:No(e,o.definition,s,a)}return null}
|
|
133
|
+
function Me(e,t){let r={...e};if(Array.isArray(e.skipFields)){let n=e.skipFields.map(o=>Ao(o,t)).filter(o=>o!==null&&o!==
|
|
134
134
|
"");n.length>0?r.skipFields=n:delete r.skipFields}if($(e.skipParams)){let n={};for(let[o,i]of Object.entries(e.skipParams)){
|
|
135
|
-
let s=
|
|
135
|
+
let s=Ao(o,t);s===null||s===""||b(n,s,i)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var xc=Object.
|
|
136
136
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
137
137
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
138
138
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
139
|
-
function
|
|
140
|
-
", ")}.`)}function
|
|
141
|
-
must define ${r} as a boolean.`)}function
|
|
142
|
-
eration "${e}" must be an object.`);return
|
|
143
|
-
pplyDefaults"),
|
|
139
|
+
function Po(e,t,r,n){let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(
|
|
140
|
+
", ")}.`)}function jr(e,t,r,n=!0){let o=t[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${e}"\
|
|
141
|
+
must define ${r} as a boolean.`)}function $c(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`Op\
|
|
142
|
+
eration "${e}" must be an object.`);return Po(e,t,"targetFields",["schema","input"]),jr(e,t,"enforceRequired"),jr(e,t,"a\
|
|
143
|
+
pplyDefaults"),Po(e,t,"outputFields",["validated","input"]),jr(e,t,"rejectExplicitUndefined",!1),Object.freeze({targetFields:t.
|
|
144
144
|
targetFields,enforceRequired:t.enforceRequired,applyDefaults:t.applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.
|
|
145
|
-
rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}function
|
|
145
|
+
rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}function Mc(e={}){if(typeof e!="object"||e===null||Array.
|
|
146
146
|
isArray(e))throw new Error("Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
147
|
-
|
|
148
|
-
null);for(let[r,n]of Object.entries(e))b(t,r,n);return Object.freeze(t)}function
|
|
149
|
-
delete t.mode,t}var
|
|
150
|
-
operations=
|
|
147
|
+
xc))b(t,r,n);for(let[r,n]of Object.entries(e))b(t,r,$c(r,n));return Object.freeze(t)}function Co(e){let t=Object.create(
|
|
148
|
+
null);for(let[r,n]of Object.entries(e))b(t,r,n);return Object.freeze(t)}function Lc(e){let t={...e};return delete t.operation,
|
|
149
|
+
delete t.mode,t}var Le=class{constructor(t,r,n,o={}){Sr(t),this.structure=t,this.types=Co(r),this.validators=Co(n),this.
|
|
150
|
+
operations=Mc(o),this._installOperationMethods()}_typeError(t){return this._paramError(t,"TYPE_CAST_FAILED","Value could\
|
|
151
151
|
not be cast to the required type.")}_paramError(t,r,n,o={}){let i=new Error(n);return i.errorObject={field:t,code:r,message:n,
|
|
152
152
|
params:o},i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(t))}_fieldToBeSkipped(t,r){
|
|
153
153
|
return Array.isArray(r.skipFields)&&r.skipFields.includes(t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))b(t,n,o)}_singleErrorMap(t){
|
|
@@ -162,10 +162,10 @@ isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!$(r))thro
|
|
|
162
162
|
ct input.`)}_resolvePathValidationRequest(t={}){let r=t.operation??t.mode??"patch";if(Object.hasOwn(t,"operation")&&Object.
|
|
163
163
|
hasOwn(t,"mode")&&t.operation!==t.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
164
164
|
oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
|
|
165
|
-
return{operationName:r,operation:n,validationOptions:
|
|
165
|
+
return{operationName:r,operation:n,validationOptions:Lc(t)}}_buildOperationResult(t,r,n){let o={};for(let i of n.outputFieldNames){
|
|
166
166
|
if(!Object.hasOwn(this.structure,i))continue;let s=n.isFieldPresent(i);(r[i]!==void 0||s&&t[i]===null||n.defaultedFields.
|
|
167
|
-
has(i))&&(!s&&!n.defaultedFields.has(i)||b(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){return
|
|
168
|
-
return
|
|
167
|
+
has(i))&&(!s&&!n.defaultedFields.has(i)||b(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){return St(t,r)}_resolveArrayItemsConfig(t,r){
|
|
168
|
+
return vt(t,r)}_resolveObjectValuesConfig(t,r){return Qe(t,r)}_buildArrayItemSettings(t,r){return t.type==="object"&&Object.
|
|
169
169
|
hasOwn(t,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(t,r,n,o,i,s,a,c){let u=t.
|
|
170
170
|
nullable===!0||a.nullable===!0,l=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,t.type))throw new Error(
|
|
171
171
|
`No casting function for type: ${t.type}`);let m=this.types[t.type];if(r===null)return u?(b(o,i,null),{errors:{},shouldContinue:!1}):
|
|
@@ -173,11 +173,11 @@ nullable===!0||a.nullable===!0,l=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Obje
|
|
|
173
173
|
if(r===""&&l)return b(o,i,null),{errors:{},shouldContinue:!1};let d={schema:this,definition:t,value:r,fieldName:n,object:o,
|
|
174
174
|
objectBeforeCast:s,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
175
175
|
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(p,f,g)=>{throw this._paramError(
|
|
176
|
-
n,p,f,g)}};try{let p=m(d);if(
|
|
176
|
+
n,p,f,g)}};try{let p=m(d);if(To(p))throw new Error(`Type handler for "${t.type}" must be synchronous.`);p!==void 0&&(b(o,
|
|
177
177
|
i,p),d.value=p)}catch(p){if(p.errorObject)return{errors:this._singleErrorMap(p.errorObject),shouldContinue:!1};throw p}return{
|
|
178
178
|
errors:{},context:d,shouldContinue:!0}}_runFieldValidators(t,r,n,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
|
|
179
179
|
_paramToBeSkipped(a,s.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{i.parameterName=
|
|
180
|
-
a,i.parameterValue=t[a];let u=c(i);if(
|
|
180
|
+
a,i.parameterValue=t[a];let u=c(i);if(To(u))throw new Error(`Validator handler for "${a}" must be synchronous.`);u!==void 0&&
|
|
181
181
|
(b(n,o,u),i.value=u)}catch(u){if(u.errorObject)return this._singleErrorMap(u.errorObject);throw u}}return{}}_normalizeAndValidateValue(t,r,n,o,i,s,a,c){
|
|
182
182
|
let u=this._castValue(t,r,n,o,i,s,a,c);if(Object.keys(u.errors).length>0)return u.errors;if(!u.shouldContinue)return{};let{
|
|
183
183
|
context:l}=u,m=this._validateNestedValue(t,n,o,i,a,c);return Object.keys(m).length>0?m:(l.value=o[i],this._runFieldValidators(
|
|
@@ -187,20 +187,20 @@ if(t.type==="object"){let c=this._resolveObjectFieldMode(r,t);return c.kind==="n
|
|
|
187
187
|
c,r,n,o,i,s):c.kind==="map"?this._validateObjectValues(r,n,o,c.valuesConfig,i,s):{}}if(t.type!=="array")return{};let a=this.
|
|
188
188
|
_resolveArrayItemsConfig(r,t);return a?this._validateArrayItems(r,n,o,a,i,s):{}}_validateNestedObjectSchema(t,r,n,o,i,s){
|
|
189
189
|
let a=n[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,u=t.schema._validateWithOperation(
|
|
190
|
-
s.operationName,s.operation,c
|
|
191
|
-
a,t.schema,u.validatedObject):u.validatedObject)
|
|
190
|
+
s.operationName,s.operation,c,Me(i,r));return b(n,o,t.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
191
|
+
a,t.schema,u.validatedObject):u.validatedObject),$e(u.errors,r)}_extractKnownObjectFields(t,r){let n={};for(let[o,i]of Object.
|
|
192
192
|
entries(t))Object.hasOwn(r.structure,o)&&b(n,o,i);return n}_mergeKnownAndPassthroughObjectFields(t,r,n){let o={};for(let i of Object.
|
|
193
193
|
keys(t)){if(!Object.hasOwn(r.structure,i)){b(o,i,t[i]);continue}Object.hasOwn(n,i)&&b(o,i,n[i])}for(let[i,s]of Object.entries(
|
|
194
194
|
n))Object.hasOwn(o,i)||b(o,i,s);return o}_validateObjectValues(t,r,n,o,i,s){let a=r[n],c={...a},u={};b(r,n,c);for(let l of Object.
|
|
195
|
-
keys(a)){let m=
|
|
195
|
+
keys(a)){let m=we(t,l);if(this._fieldToBeSkipped(m,i))continue;let d=c[l];if(d===void 0){s.rejectExplicitUndefined?this.
|
|
196
196
|
_mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let f=o.
|
|
197
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,d
|
|
198
|
-
u
|
|
197
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,d,Me(i,m));b(c,l,f.validatedObject),this._mergeErrors(
|
|
198
|
+
u,$e(f.errors,m));continue}let p=this._normalizeAndValidateValue(o.definition,d,m,c,l,a,i,this._buildArrayItemSettings(o.
|
|
199
199
|
definition,s));this._mergeErrors(u,p)}return u}_validateArrayItems(t,r,n,o,i,s){let a=r[n],c=a.slice(),u={};b(r,n,c);for(let l=0;l<
|
|
200
|
-
c.length;l++){let m=
|
|
200
|
+
c.length;l++){let m=we(t,l);if(this._fieldToBeSkipped(m,i))continue;if(!Object.hasOwn(a,l)||c[l]===void 0){s.rejectExplicitUndefined?
|
|
201
201
|
this._mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let p=o.
|
|
202
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[l]
|
|
203
|
-
u
|
|
202
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],Me(i,m));b(c,l,p.validatedObject),this._mergeErrors(
|
|
203
|
+
u,$e(p.errors,m));continue}let d=this._normalizeAndValidateValue(o.definition,c[l],m,c,l,a,i,this._buildArrayItemSettings(
|
|
204
204
|
o.definition,s));this._mergeErrors(u,d)}return u}_validateField(t,r,n,o,i){if(!Object.hasOwn(this.structure,t))return{};
|
|
205
205
|
let s=this.structure[t];if(this._fieldToBeSkipped(t,o))return{};let a=i.isFieldPresent(t),c=r[t],u=c===void 0;return i.enforceRequired&&
|
|
206
206
|
s.required&&(!a||u)&&!this._paramToBeSkipped("required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"\
|
|
@@ -212,10 +212,10 @@ c,n,s,o,a);this._mergeErrors(i,u)}if(a.applyDefaults){for(let c of Object.keys(t
|
|
|
212
212
|
this.structure[c].defaultTo!==void 0){let u=this.structure[c],l=typeof u.defaultTo=="function"?u.defaultTo():u.defaultTo,
|
|
213
213
|
m=this._normalizeDefault(u,l,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
214
214
|
_mergeErrors(i,m.errors),Object.keys(m.errors).length>0)continue;b(s,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
215
|
-
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of
|
|
216
|
-
let u=
|
|
215
|
+
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of Ro(Object.keys(t))){
|
|
216
|
+
let u=ko(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${u}".`);let l=this._validateSelectedField(
|
|
217
217
|
c,t[c],r,a,n,o,u);this._mergeErrors(s,l)}return{validatedObject:a,errors:s}}_validateSelectedField(t,r,n,o,i,s,a){if(!Object.
|
|
218
|
-
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=
|
|
218
|
+
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=Oo(r);if(this._fieldToBeSkipped(a,i))return{};
|
|
219
219
|
let m=Object.hasOwn(n,t),d=n[t],p={};if(!m){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("required",i.skipParams,
|
|
220
220
|
a)&&this._mergeErrors(p,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),u&&s.applyDefaults&&
|
|
221
221
|
c.defaultTo!==void 0){let _=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,S=this._normalizeDefault(c,_,{fieldPath:a,
|
|
@@ -224,75 +224,75 @@ length===0&&b(o,t,S.value)}return p}if(d===void 0)return u&&s.rejectExplicitUnde
|
|
|
224
224
|
a).errorObject):{};let f={[t]:d};if(u){let _=this._normalizeAndValidateValue(c,d,a,f,t,n,i,s);return Object.hasOwn(f,t)&&
|
|
225
225
|
f[t]!==void 0?b(o,t,f[t]):f[t]===null&&b(o,t,null),_}if(!l)return{};let g=this._castValue(c,d,a,f,t,n,i,s);if(Object.keys(
|
|
226
226
|
g.errors).length>0)return g.errors;if(!g.shouldContinue)return{};let w=this._validateSelectedDescendants(c,r.children,a,
|
|
227
|
-
f,t,i,s);return
|
|
227
|
+
f,t,i,s);return It(f[t])&&b(o,t,f[t]),w}_validateSelectedDescendants(t,r,n,o,i,s,a){if(t.type==="object"){let c=this._resolveObjectFieldMode(
|
|
228
228
|
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!$(
|
|
229
|
-
u))return{};let l=c.schema._validateSelectedTree(r,u
|
|
230
|
-
|
|
229
|
+
u))return{};let l=c.schema._validateSelectedTree(r,u,Me(s,n),{...a,defaultedFields:new Set});return b(o,i,l.validatedObject),
|
|
230
|
+
$e(l.errors,n)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(n,t);if(!c)throw new Error(`Schema path "${n}" d\
|
|
231
231
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,i,c,r,s,a)}throw new Error(
|
|
232
232
|
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],u=r[n],
|
|
233
|
-
l={};b(r,n,c);for(let m of
|
|
234
|
-
id because array segments must use numeric indexes.`);let d=Number(m),p=
|
|
233
|
+
l={};b(r,n,c);for(let m of Ro(Object.keys(i))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${we(t,m)}" is inval\
|
|
234
|
+
id because array segments must use numeric indexes.`);let d=Number(m),p=we(t,d),f=i[m],g=f.self===!0,w=Oo(f);if(this._fieldToBeSkipped(
|
|
235
235
|
p,s))continue;if(!Object.hasOwn(u,d)){g&&a.rejectExplicitUndefined&&b(l,p,this._typeError(p).errorObject);continue}let _=u[d];
|
|
236
236
|
if(_===void 0){g&&a.rejectExplicitUndefined&&b(l,p,this._typeError(p).errorObject);continue}if(o.kind==="schema"){if(g){
|
|
237
|
-
let C=o.schema._validateWithOperation("replace",o.schema.operations.replace,_
|
|
238
|
-
this._mergeErrors(l
|
|
239
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
240
|
-
this._mergeErrors(l
|
|
237
|
+
let C=o.schema._validateWithOperation("replace",o.schema.operations.replace,_,Me(s,p));It(C.validatedObject)&&b(c,d,C.validatedObject),
|
|
238
|
+
this._mergeErrors(l,$e(C.errors,p));continue}if(!w)continue;let T=o.schema._validateSelectedTree(f.children,_,Me(s,p),{...a,
|
|
239
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});It(T.validatedObject)&&b(c,d,T.validatedObject),
|
|
240
|
+
this._mergeErrors(l,$e(T.errors,p));continue}let S=this._buildArrayItemSettings(o.definition,a),A=[_];if(g){let T=this._normalizeAndValidateValue(
|
|
241
241
|
o.definition,_,p,A,0,u,s,S);Object.hasOwn(A,0)&&A[0]!==void 0?b(c,d,A[0]):A[0]===null&&b(c,d,null),this._mergeErrors(l,T);
|
|
242
242
|
continue}if(!w)continue;let I=this._castValue(o.definition,_,p,A,0,u,s,S);if(Object.keys(I.errors).length>0){this._mergeErrors(
|
|
243
|
-
l,I.errors);continue}if(!I.shouldContinue)continue;let
|
|
244
|
-
s,S);
|
|
243
|
+
l,I.errors);continue}if(!I.shouldContinue)continue;let P=this._validateSelectedDescendants(o.definition,f.children,p,A,0,
|
|
244
|
+
s,S);It(A[0])&&b(c,d,A[0]),this._mergeErrors(l,P)}return l}validateWith(t,r,n={}){if(!Object.hasOwn(this.operations,t))throw new Error(
|
|
245
245
|
`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(t,r),this._validateWithOperation(
|
|
246
|
-
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=
|
|
247
|
-
_resolvePathValidationRequest(n),c=this._validateSelectedTree(
|
|
246
|
+
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Dr(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
247
|
+
_resolvePathValidationRequest(n),c=this._validateSelectedTree(Io([t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:Cc(
|
|
248
248
|
c.validatedObject,o),errors:c.errors}}validatePaths(t,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
249
249
|
isArray(t)||t.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
250
|
-
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(
|
|
250
|
+
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(Io(t),r,s,this.
|
|
251
251
|
_buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.keys(this.operations)){if(t in this)throw new Error(
|
|
252
252
|
`Operation name "${t}" is reserved and cannot be used as a schema method.`);this[t]=(r,n={})=>this.validateWith(t,r,n)}}toJsonSchema(t={}){
|
|
253
|
-
return
|
|
254
|
-
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=
|
|
255
|
-
return r===null?null:
|
|
256
|
-
messages===null?Object.freeze({}):
|
|
257
|
-
o)&&this.structure[o][r]&&b(n,o,t[o]);return n}};var{parse:
|
|
258
|
-
{"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=
|
|
259
|
-
m;let d=n.call(this,l,m);switch(typeof d){case
|
|
260
|
-
"object"||typeof e=="function")&&typeof e.then=="function"}function
|
|
253
|
+
return So(this,t)}getFieldDefinitions(){return Lr.has(this)||Lr.set(this,Mr(this.structure)),Lr.get(this)}getFieldDefinition(t){
|
|
254
|
+
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=Ur(this,Dr(t.trim()));
|
|
255
|
+
return r===null?null:Mr(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
256
|
+
messages===null?Object.freeze({}):Mr(r.messages)}cleanup(t,r){let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,
|
|
257
|
+
o)&&this.structure[o][r]&&b(n,o,t[o]);return n}};var{parse:yf,stringify:jc}=JSON,{keys:bf}=Object,Dc=String,Uc="string";var xo="object",Gc=(e,t)=>t;var $o=(e,t,r)=>{let n=Dc(t.push(r)-1);return e.set(r,n),n};var Mo=(e,t,r)=>{let n=t&&typeof t===xo?(l,m)=>l===""||-1<t.indexOf(l)?m:void 0:t||Gc,o=new Map,i=[],s=[],a=+$o(o,i,n.call(
|
|
258
|
+
{"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=jc(i[a++],u,r);return"["+s.join(",")+"]";function u(l,m){if(c)return c=!c,
|
|
259
|
+
m;let d=n.call(this,l,m);switch(typeof d){case xo:if(d===null)return d;case Uc:return o.get(d)||$o(o,i,d)}return d}};var Bc=new Set(["true","1","yes","y","on"]),Vc=new Set(["false","0","no","n","off"]);function zc(e){return e!==null&&(typeof e==
|
|
260
|
+
"object"||typeof e=="function")&&typeof e.then=="function"}function Lo(e){if(typeof e=="number")return Number.isFinite(e)?
|
|
261
261
|
e:null;if(typeof e=="bigint"){let t=Number(e);return Number.isSafeInteger(t)?t:null}if(typeof e=="string"){let t=e.trim();
|
|
262
|
-
if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function
|
|
262
|
+
if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function Hr(e,t){if(Object.is(e,t))return!0;
|
|
263
263
|
if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.
|
|
264
264
|
source===t.source&&e.flags===t.flags;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==
|
|
265
|
-
t.length)return!1;for(let o=0;o<e.length;o++)if(!
|
|
265
|
+
t.length)return!1;for(let o=0;o<e.length;o++)if(!Hr(e[o],t[o]))return!1;return!0}if(e===null||t===null||typeof e!="objec\
|
|
266
266
|
t"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=Object.keys(e),n=Object.keys(
|
|
267
|
-
t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!
|
|
267
|
+
t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!Hr(e[o],t[o]))return!1;return!0}var Fc={install(e){
|
|
268
268
|
let{addType:t,addValidator:r}=e;t("none",n=>n.value),t("file",n=>{let o=n.value;o==null&&n.throwTypeError();let i=typeof o;
|
|
269
269
|
if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),
|
|
270
270
|
t("string",n=>{let o=n.value;if(o==null)return"";let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();
|
|
271
|
-
return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),t("number",n=>{let o
|
|
272
|
-
null&&n.throwTypeError(),o}),t("integer",n=>{let o
|
|
273
|
-
o}),t("epochMilliseconds",n=>{let o=
|
|
274
|
-
n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=
|
|
275
|
-
value,o)||n.throwTypeError(),n.value}),t("date",n=>(
|
|
276
|
-
n.fieldName);return
|
|
271
|
+
return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),t("number",n=>{let o=Lo(n.value);return o===
|
|
272
|
+
null&&n.throwTypeError(),o}),t("integer",n=>{let o=Lo(n.value);return(o===null||!Number.isInteger(o))&&n.throwTypeError(),
|
|
273
|
+
o}),t("epochMilliseconds",n=>{let o=Or(n.value,864e13);return o===null&&n.throwTypeError(),o}),t("epochSeconds",n=>{let o=Or(
|
|
274
|
+
n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=Ze(n.definition,n.fieldName);return ho(n.
|
|
275
|
+
value,o)||n.throwTypeError(),n.value}),t("date",n=>(mo(n.value)||n.throwTypeError(),n.value)),t("time",n=>{let o=Ze(n.definition,
|
|
276
|
+
n.fieldName);return fo(n.value,o)||n.throwTypeError(),n.value}),t("array",n=>n.definition.type==="array"&&!Array.isArray(
|
|
277
277
|
n.value)?[n.value]:n.value),t("object",n=>($(n.value)||n.throwTypeError(),n.value)),t("serialize",n=>{try{return JSON.stringify(
|
|
278
|
-
n.value)}catch{try{return
|
|
278
|
+
n.value)}catch{try{return Mo(n.value)}catch{n.throwTypeError()}}}),t("boolean",n=>{if(typeof n.value=="boolean")return n.
|
|
279
279
|
value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
|
|
280
280
|
"bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
|
|
281
281
|
n.definition.stringFalseWhen||"false").trim().toLowerCase(),i=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
282
|
-
s=n.value.trim().toLowerCase(),a=new Set([...
|
|
282
|
+
s=n.value.trim().toLowerCase(),a=new Set([...Vc,o]),c=new Set([...Bc,i]);if(a.has(s))return!1;if(c.has(s))return!0}n.throwTypeError()}),
|
|
283
283
|
t("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
|
|
284
284
|
value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
|
|
285
285
|
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let i=Number(o);return Number.isSafeInteger(
|
|
286
286
|
i)||n.throwTypeError(),i}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.
|
|
287
287
|
toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGTH",`Length must be at least ${n.parameterValue}\
|
|
288
|
-
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&
|
|
288
|
+
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&Ne(n.definition)&&
|
|
289
289
|
typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("MIN_VALUE",`Value must be at least ${n.parameterValue}\
|
|
290
290
|
.`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.toString&&
|
|
291
291
|
n.value.toString().length>n.parameterValue&&n.throwParamError("MAX_LENGTH",`Length must be no more than ${n.parameterValue}\
|
|
292
|
-
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&
|
|
292
|
+
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&Ne(n.definition)&&
|
|
293
293
|
typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError("MAX_VALUE",`Value must be no more than ${n.parameterValue}\
|
|
294
294
|
.`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.isArray(n.parameterValue))throw new Error(`Enum for ${n.
|
|
295
|
-
fieldName} must be an array.`);n.parameterValue.some(i=>
|
|
295
|
+
fieldName} must be an array.`);n.parameterValue.some(i=>Hr(i,n.value))||n.throwParamError("ENUM_VALUE","Value must match\
|
|
296
296
|
one of the allowed enum values.",{allowed:n.parameterValue})}),r("pattern",n=>{if(n.value===void 0||n.definition.type!==
|
|
297
297
|
"string"||typeof n.value!="string")return;let o=n.parameterValue,i=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
298
298
|
"string"?new RegExp(o):null;if(!i)throw new Error(`Pattern for ${n.fieldName} must be a string or RegExp.`);i.test(n.value)||
|
|
@@ -300,7 +300,7 @@ n.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
300
300
|
parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
|
|
301
301
|
fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
|
|
302
302
|
"validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
|
|
303
|
-
let o=n.parameterValue(n.value,n.object,n);if(
|
|
303
|
+
let o=n.parameterValue(n.value,n.object,n);if(zc(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
|
|
304
304
|
ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
|
|
305
305
|
ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
|
|
306
306
|
th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
|
|
@@ -312,45 +312,45 @@ n.throwParamError("MAX_ITEMS",`Must have no more than ${n.parameterValue} items.
|
|
|
312
312
|
r("notEmpty",n=>{n.parameterValue&&typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot b\
|
|
313
313
|
e empty.")}),r("required",()=>{}),r("unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{
|
|
314
314
|
if(n.definition.type!=="time"&&n.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
|
|
315
|
-
e or dateTime fields (${n.fieldName}).`)}),r("nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},
|
|
316
|
-
if(typeof r!="function")throw new Error(`Type handler for '${t}' must be a function.`);b(e,t,r)}function
|
|
317
|
-
"function")throw new Error(`Validator handler for '${t}' must be a function.`);b(e,t,r)}function
|
|
318
|
-
null);for(let[r,n]of Object.entries(e))b(t,r,n);return t}function
|
|
319
|
-
"Plugin must have an install method.");e.install(t)}function
|
|
320
|
-
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
321
|
-
typeof e!="object"&&typeof e!="function")return null;let t=
|
|
315
|
+
e or dateTime fields (${n.fieldName}).`)}),r("nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},jo=Fc;var Ho=new WeakMap,Bo=new WeakMap,Vo=Symbol.for("json-rest-schema.registry-metadata"),Ct=new WeakSet;function Wc(e,t,r){
|
|
316
|
+
if(typeof r!="function")throw new Error(`Type handler for '${t}' must be a function.`);b(e,t,r)}function qc(e,t,r){if(typeof r!=
|
|
317
|
+
"function")throw new Error(`Validator handler for '${t}' must be a function.`);b(e,t,r)}function kt(e={}){let t=Object.create(
|
|
318
|
+
null);for(let[r,n]of Object.entries(e))b(t,r,n);return t}function Do(e,t){if(typeof e.install!="function")throw new Error(
|
|
319
|
+
"Plugin must have an install method.");e.install(t)}function Uo(e,t,r){Ho.set(e,t),Bo.set(e,r),Object.defineProperty(e,Vo,
|
|
320
|
+
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function Yc(e){if(!e||
|
|
321
|
+
typeof e!="object"&&typeof e!="function")return null;let t=Ho.get(e),r=Bo.get(e);if(t&&r)return{types:t,validators:r};let n=e[Vo];
|
|
322
322
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
323
323
|
typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.validators=="object"&&typeof e.create=="fu\
|
|
324
324
|
nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
|
|
325
|
-
validators}:null}function
|
|
326
|
-
entries(t)){if(Object.hasOwn(e,n)&&e[n]!==o){if(
|
|
327
|
-
factories with conflicting ${r} "${n}".`)}b(e,n,o)}}function
|
|
328
|
-
types:
|
|
329
|
-
"Factory sources must be schema instances or schema factories created by json-rest-schema.");
|
|
330
|
-
validators,"validator")}return{types:o,validators:i}}function
|
|
331
|
-
e),o=
|
|
332
|
-
i.addValidator=(s,a)=>{
|
|
333
|
-
let a=
|
|
334
|
-
addType(s,a)},addValidator:(s,a)=>{
|
|
335
|
-
function
|
|
325
|
+
validators}:null}function Kc(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function Go(e,t,r){for(let[n,o]of Object.
|
|
326
|
+
entries(t)){if(Object.hasOwn(e,n)&&e[n]!==o){if(Ct.has(o))continue;if(!Ct.has(e[n]))throw new Error(`Cannot merge schema\
|
|
327
|
+
factories with conflicting ${r} "${n}".`)}b(e,n,o)}}function Jc(e,t,r){let n=Kc(r).filter(Boolean);if(n.length<1)return{
|
|
328
|
+
types:kt(e),validators:kt(t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=Yc(s);if(!a)throw new Error(
|
|
329
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");Go(o,a.types,"type"),Go(i,a.
|
|
330
|
+
validators,"validator")}return{types:o,validators:i}}function zo({types:e={},validators:t={},installCore:r=!0}={}){let n=kt(
|
|
331
|
+
e),o=kt(t),i=(s,a={})=>{let c=new Le(s,n,o,a.operations);return Uo(c,n,o),c};return Uo(i,n,o),i.addType=(s,a)=>{Wc(n,s,a)},
|
|
332
|
+
i.addValidator=(s,a)=>{qc(o,s,a)},i.use=s=>{Do(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
|
|
333
|
+
let a=Jc(n,o,s);return zo({types:a.types,validators:a.validators,installCore:!1})},r&&Do(jo,{addType:(s,a)=>{Ct.add(a),i.
|
|
334
|
+
addType(s,a)},addValidator:(s,a)=>{Ct.add(a),i.addValidator(s,a)}}),i}var Fo=zo({installCore:!0});var Hf=Object.freeze({schema:Fo({}),mode:"replace"});var Wo=/^[a-z][a-z0-9_.-]*$/u,Qc=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function Zc(e){return String(e||"").trim().toLowerCase()}
|
|
335
|
+
function Vr(e,t){let r=Zc(e);if(!Wo.test(r))throw new TypeError(`${t} must match ${Wo.toString()}.`);return r}function xt(e,t){
|
|
336
336
|
if(e==null)return Object.freeze({});if(!W(e))throw new TypeError(`${t} must be an object mapping local names to capabili\
|
|
337
|
-
ty ids.`);let r={},n=new Set;for(let[o,i]of Object.entries(e)){let s=String(o||"").trim();if(!
|
|
338
|
-
`${t} local name "${s}" must be a JavaScript identifier.`);let a=
|
|
339
|
-
declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.freeze(r)}function
|
|
337
|
+
ty ids.`);let r={},n=new Set;for(let[o,i]of Object.entries(e)){let s=String(o||"").trim();if(!Qc.test(s))throw new TypeError(
|
|
338
|
+
`${t} local name "${s}" must be a JavaScript identifier.`);let a=Vr(i,`${t}.${s}`);if(n.has(a))throw new TypeError(`${t}\
|
|
339
|
+
declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.freeze(r)}function eu(e,t,r){if(e==null)return Object.
|
|
340
340
|
freeze({});if(!W(e))throw new TypeError(`${r}.hints must be an object mapping required capability ids to what to registe\
|
|
341
|
-
r.`);let n=new Set(Object.values(t)),o={};for(let[i,s]of Object.entries(e)){let a=
|
|
341
|
+
r.`);let n=new Set(Object.values(t)),o={};for(let[i,s]of Object.entries(e)){let a=Vr(i,`${r}.hints key`);if(!n.has(a))throw new TypeError(
|
|
342
342
|
`${r}.hints names "${a}", which the provider does not require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${r}\
|
|
343
|
-
.hints["${a}"] must be the text that says what to register.`);o[a]=s.trim()}return Object.freeze(o)}function
|
|
343
|
+
.hints["${a}"] must be the text that says what to register.`);o[a]=s.trim()}return Object.freeze(o)}function tu(e){let t=new Map;
|
|
344
344
|
for(let[r,n]of Object.entries(e))for(let o of Object.keys(n)){if(t.has(o))throw new TypeError(`Provider local name "${o}\
|
|
345
|
-
" is declared by both ${t.get(o)} and ${r}.`);t.set(o,r)}}function
|
|
345
|
+
" is declared by both ${t.get(o)} and ${r}.`);t.set(o,r)}}function ru(e,t,r){for(let n of Object.values(t))for(let[o,i]of Object.
|
|
346
346
|
entries(r))if(Object.values(i).includes(n))throw new TypeError(o==="provides"?`Provider "${e}" cannot late-require capab\
|
|
347
347
|
ility "${n}" that it provides.`:`Provider "${e}" names capability "${n}" under both late and ${o}.`)}function Br(e,t){if(e==
|
|
348
|
-
null)return null;if(typeof e!="function")throw new TypeError(`${t} must be a function when provided.`);return e}function
|
|
349
|
-
id:e,requires:t={},optional:r={},late:n={},provides:o={},hints:i={},setup:s,boot:a=null,shutdown:c=null}={}){let u=
|
|
350
|
-
"Provider id"),l=
|
|
351
|
-
optional:m,late:d,provides:p}),
|
|
352
|
-
`${u}.setup is required.`);return Object.freeze({id:u,requires:l,optional:m,late:d,provides:p,hints:
|
|
353
|
-
setup:f,boot:Br(a,`${u}.boot`),shutdown:Br(c,`${u}.shutdown`)})}var
|
|
348
|
+
null)return null;if(typeof e!="function")throw new TypeError(`${t} must be a function when provided.`);return e}function $t({
|
|
349
|
+
id:e,requires:t={},optional:r={},late:n={},provides:o={},hints:i={},setup:s,boot:a=null,shutdown:c=null}={}){let u=Vr(e,
|
|
350
|
+
"Provider id"),l=xt(t,`${u}.requires`),m=xt(r,`${u}.optional`),d=xt(n,`${u}.late`),p=xt(o,`${u}.provides`);tu({requires:l,
|
|
351
|
+
optional:m,late:d,provides:p}),ru(u,d,{provides:p,requires:l,optional:m});let f=Br(s,`${u}.setup`);if(!f)throw new TypeError(
|
|
352
|
+
`${u}.setup is required.`);return Object.freeze({id:u,requires:l,optional:m,late:d,provides:p,hints:eu(i,{...l,...d},u),
|
|
353
|
+
setup:f,boot:Br(a,`${u}.boot`),shutdown:Br(c,`${u}.shutdown`)})}var qo="public";var nu="/api",Ko=`${nu}/bootstrap`;function zr(){let e=[],t=new Set,r=!1;function n({id:a,order:c=0,contribute:u}={}){if(r)throw new Error("Bootstrap regis\
|
|
354
354
|
tration is closed after the first payload is resolved.");let l=h(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
355
355
|
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
|
|
356
356
|
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
|
|
@@ -358,221 +358,221 @@ isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u
|
|
|
358
358
|
(l,m)=>l.entry.order-m.entry.order||l.index-m.index).map(({entry:l})=>l);for(let l of u){let m=await l.contribute(Object.
|
|
359
359
|
freeze({...W(a)?a:{},payload:Object.freeze({...c})}));c={...c,...W(m)?m:{}}}return Object.freeze(c)}function i(){return Object.
|
|
360
360
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
361
|
-
return s}var
|
|
362
|
-
let t=
|
|
363
|
-
async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:t}}});function
|
|
361
|
+
return s}var ou=$t({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:e}){
|
|
362
|
+
let t=zr();return e.router.register("GET",Ko,{auth:qo,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
|
|
363
|
+
async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:t}}});function iu(e){if(!W(e))throw new TypeError("Event listener must be an object.");let t=String(e.id||"").trim();if(!t)throw new TypeError(
|
|
364
364
|
"Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
|
|
365
365
|
dle().`);if(e.matches!=null&&typeof e.matches!="function")throw new TypeError(`Event listener "${t}" matches must be a f\
|
|
366
|
-
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function
|
|
366
|
+
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function su(e){if(!W(e))throw new TypeError(
|
|
367
367
|
"Published event must be an object.");let t=String(e.type||"").trim();if(!t)throw new TypeError("Published event type is\
|
|
368
|
-
required.");return Object.freeze({...e,type:t})}function
|
|
369
|
-
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=
|
|
368
|
+
required.");return Object.freeze({...e,type:t})}function Fr(){let e=[],t=new Set;function r(s){let a=iu(s);if(t.has(a.id))
|
|
369
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=su(s);
|
|
370
370
|
for(let c of e)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
371
|
-
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var
|
|
372
|
-
import{promisify as
|
|
373
|
-
name is required.");throw r.code="vibe64_invalid_os_username",r}return t}function
|
|
371
|
+
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var au=$t({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:Fr()}}});import{execFile as cu}from"node:child_process";import{readFile as uu}from"node:fs/promises";import Wr from"node:os";import lu from"node:path";
|
|
372
|
+
import{promisify as du}from"node:util";var pu=du(cu);function Xo(e=""){let t=h(e);if(!t||t.includes("/")||t.includes("\\")||t.includes(":")){let r=new Error("A valid OS user\
|
|
373
|
+
name is required.");throw r.code="vibe64_invalid_os_username",r}return t}function Qo([e,t,r,n,o,i]=[]){if(!/^\d+$/u.test(
|
|
374
374
|
t)||!/^\d+$/u.test(r))return null;let s=Number(t),a=Number(r);return!Number.isSafeInteger(s)||!Number.isSafeInteger(a)?null:
|
|
375
|
-
{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),uid:s,username:String(e||"")}}function
|
|
376
|
-
let t=String(e||"").trim().split(":");return t.length<7?null:
|
|
375
|
+
{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),uid:s,username:String(e||"")}}function qr(e=""){
|
|
376
|
+
let t=String(e||"").trim().split(":");return t.length<7?null:Qo([t[0],t[2],t[3],t[4],t[5],t[6]])}function mu(e=""){return String(
|
|
377
377
|
e||"").split(/\r?\n[\t ]*\r?\n/u).map(t=>{let r={};for(let n of t.split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);
|
|
378
|
-
o&&(r[o[1]]=o[2].trim())}return
|
|
379
|
-
let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="string"?n:n?.stdout)||"")}function
|
|
380
|
-
userInfo:t=
|
|
378
|
+
o&&(r[o[1]]=o[2].trim())}return Qo([r.name,r.uid,r.gid,r.gecos,r.dir,r.shell])}).filter(Boolean)}async function Jo(e,t,r){
|
|
379
|
+
let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="string"?n:n?.stdout)||"")}function tt({homedir:e=Wr.homedir,
|
|
380
|
+
userInfo:t=Wr.userInfo}={}){let r=t(),n=h(r?.username||process.env.USER||process.env.LOGNAME),o=lu.resolve(String(r?.homedir||
|
|
381
381
|
e()||""));return{displayName:String(r?.username||n),gid:Number.isSafeInteger(r?.gid)?r.gid:null,home:o,shell:String(r?.shell||
|
|
382
|
-
""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}async function
|
|
383
|
-
readFileFn:n=
|
|
382
|
+
""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}async function Mt(e="",{execFileFn:t=pu,platform:r=process.platform,
|
|
383
|
+
readFileFn:n=uu,userInfo:o=Wr.userInfo}={}){let i=Xo(e);if(r==="linux"&&!/^\d+$/u.test(i)){let c=[...(await n("/etc/nssw\
|
|
384
384
|
itch.conf","utf8").catch(()=>"")).matchAll(/^[\t ]*passwd[\t ]*:[\t ]*([^#\r\n]*)/gmu)],u=c.length===1?c[0][1].trim().split(
|
|
385
385
|
/\s+/u):[];if(u[0]==="files"&&(u.length===1||/^[a-z_][a-z0-9_-]*$/iu.test(u[1]))){let m=(await n("/etc/passwd","utf8").catch(
|
|
386
|
-
()=>"")).split(/\r?\n/u).map(
|
|
387
|
-
username===i)return a;[s]=
|
|
388
|
-
swd",i]).catch(c=>{if(c?.code===2)return"";throw c});s=
|
|
389
|
-
OS user was not found: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var
|
|
390
|
-
isSafeInteger(t)&&t>=0?t:null}function v(e=""){let t=E(e);return t?
|
|
391
|
-
t);if(!r||!n)return!1;let o=
|
|
386
|
+
()=>"")).split(/\r?\n/u).map(qr).find(d=>d?.username===i);if(m)return m}}let s;if(r==="darwin"){let a=tt({userInfo:o});if(a.
|
|
387
|
+
username===i)return a;[s]=mu(await Jo(t,"dscacheutil",["-q","user","-a","name",i]))}else{let a=await Jo(t,"getent",["pas\
|
|
388
|
+
swd",i]).catch(c=>{if(c?.code===2)return"";throw c});s=qr(a.split(/\r?\n/u)[0])}if(!s||s.username!==i){let a=new Error(`\
|
|
389
|
+
OS user was not found: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var jh=Object.freeze({parsePasswdLine:qr});import fu from"node:os";import Kr from"node:path";import Lt from"node:path";function E(e=""){return String(e??"").trim()}function Yr(e=null){let t=Number(e);return Number.
|
|
390
|
+
isSafeInteger(t)&&t>=0?t:null}function v(e=""){let t=E(e);return t?Lt.resolve(t):""}function ae(e="",t=""){let r=v(e),n=v(
|
|
391
|
+
t);if(!r||!n)return!1;let o=Lt.relative(r,n);return o!==".."&&!o.startsWith(`..${Lt.sep}`)&&!Lt.isAbsolute(o)}function M(e={}){
|
|
392
392
|
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function q(e={}){return Object.fromEntries(Object.entries(M(e)).map(
|
|
393
|
-
([t,r])=>[E(t),String(r??"")]).filter(([t])=>!!t))}function
|
|
394
|
-
[e]){let o=E(n);!o||r.has(o)||(r.add(o),t.push(o))}return t}function
|
|
395
|
-
isFinite(t)?t:0}function
|
|
396
|
-
gid:
|
|
397
|
-
return
|
|
398
|
-
join(r.home,".cache"),XDG_CONFIG_HOME:
|
|
393
|
+
([t,r])=>[E(t),String(r??"")]).filter(([t])=>!!t))}function ye(e=[]){let t=[],r=new Set;for(let n of Array.isArray(e)?e:
|
|
394
|
+
[e]){let o=E(n);!o||r.has(o)||(r.add(o),t.push(o))}return t}function je(e){let t=Date.parse(String(e||"").trim());return Number.
|
|
395
|
+
isFinite(t)?t:0}function oe(...e){for(let t of e){let r=E(t);if(r)return r}return""}function Jr(e={}){let t=E(e.username),r=v(e.home||(t?`/home/${t}`:fu.homedir()));return{displayName:E(e.displayName||t),
|
|
396
|
+
gid:Yr(e.gid),home:r,shell:E(e.shell),uid:Yr(e.uid),username:t}}function Xr(){return Jr(tt())}async function Qr(e="",t={}){
|
|
397
|
+
return Jr(await Mt(e,t))}function rt(e={},t={}){let r=Jr(e);return{...t,HOME:r.home,LOGNAME:r.username,USER:r.username,XDG_CACHE_HOME:Kr.
|
|
398
|
+
join(r.home,".cache"),XDG_CONFIG_HOME:Kr.join(r.home,".config"),XDG_DATA_HOME:Kr.join(r.home,".local","share")}}function Zo(){
|
|
399
399
|
return{gid:typeof process.getgid=="function"?process.getgid():null,uid:typeof process.getuid=="function"?process.getuid():
|
|
400
|
-
null}}function
|
|
400
|
+
null}}function hu(e=0){let t=Number(e);return Number.isSafeInteger(t)?t:1}function nt({code:e="",error:t="",exitCode:r=0,ok:n=null,
|
|
401
401
|
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:l=!1,execution:m=null,retryable:d=null}={}){
|
|
402
|
-
let p=
|
|
402
|
+
let p=hu(r),f=String(u||""),g=String(c||""),w=String(o||[f,g].filter(Boolean).join(`
|
|
403
403
|
`)).trim();return{code:E(e),error:E(t),exitCode:p,ok:n===null?p===0:n===!0,output:w,pid:Number.isSafeInteger(Number(s))?
|
|
404
404
|
Number(s):null,signal:E(a),stderr:g,stdout:f,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...m&&typeof m=="obje\
|
|
405
405
|
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof d=="boolean"?{retryable:d}:{}}}function L(e="",t="vibe64_command_faile\
|
|
406
|
-
d",r={}){let n=E(e)||"Vibe64 command failed.";return
|
|
407
|
-
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}import{spawn as
|
|
408
|
-
import{stripVTControlCharacters as
|
|
406
|
+
d",r={}){let n=E(e)||"Vibe64 command failed.";return nt({...r,code:t,error:n,exitCode:1,ok:!1,output:E(r.output)||n,stderr:r.
|
|
407
|
+
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}import{spawn as gu}from"node:child_process";import{statSync as _u}from"node:fs";import wu from"node:path";import{StringDecoder as yu}from"node:string_decoder";
|
|
408
|
+
import{stripVTControlCharacters as bu}from"node:util";var ei=1e8,ri=5e3,Eu=Object.freeze({SIGABRT:"Aborted",SIGALRM:"Tim\
|
|
409
409
|
eout or timer",SIGHUP:"Terminal closed",SIGINT:"User interruption with CTRL-C",SIGKILL:"Forced termination",SIGPIPE:"Bro\
|
|
410
410
|
ken pipe or socket",SIGQUIT:"User interruption with CTRL-\\",SIGSEGV:"Segmentation fault",SIGTERM:"Termination",SIGUSR1:"\
|
|
411
|
-
Application-specific signal",SIGUSR2:"Application-specific signal"}),
|
|
412
|
-
her}","gu"),
|
|
413
|
-
|
|
414
|
-
toString(16)}`})}function
|
|
415
|
-
`).map(
|
|
416
|
-
`)}function
|
|
417
|
-
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function
|
|
418
|
-
return r;try{if(!
|
|
411
|
+
Application-specific signal",SIGUSR2:"Application-specific signal"}),vu=/^[\w./-]+$/u,Su=new RegExp("\\p{Separator}|\\p{Ot\
|
|
412
|
+
her}","gu"),ti=Object.freeze({" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"});function ni(e){return e.replaceAll(
|
|
413
|
+
Su,t=>{if(ti[t]!==void 0)return ti[t];let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.
|
|
414
|
+
toString(16)}`})}function Tu(e){return bu(e).split(`
|
|
415
|
+
`).map(ni).join(`
|
|
416
|
+
`)}function Ou(e,t){return[e,...t].map(r=>{let n=ni(String(r));return vu.test(n)?n:process.platform==="win32"?`"${n.replaceAll(
|
|
417
|
+
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function Au(e,t){let r=String(e?.message??e);if(t===process.cwd())
|
|
418
|
+
return r;try{if(!_u(t).isDirectory())return`The "cwd" option is not a directory: ${t}.
|
|
419
419
|
${r}`}catch(n){return`The "cwd" option is invalid: ${t}.
|
|
420
420
|
${n.message}
|
|
421
|
-
${r}`}return r}function
|
|
421
|
+
${r}`}return r}function Iu(e){let t=e.forcefullyTerminated?` and was forcefully terminated after ${ri} milliseconds`:"";
|
|
422
422
|
if(e.timedOut)return`Command timed out after ${e.timeout} milliseconds${t}`;if(e.maxBuffer)return`Command's ${e.maxBuffer.
|
|
423
423
|
stream} was larger than ${e.maxBuffer.limit} ${e.maxBuffer.unit}${t}`;if(e.spawnError?.code!==void 0)return`Command fail\
|
|
424
|
-
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=
|
|
425
|
-
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function
|
|
426
|
-
|
|
427
|
-
${t}`:""}`}function
|
|
424
|
+
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=Eu[e.signal];return`Command was killed with ${e.signal}${r?` (${r})`:
|
|
425
|
+
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function Ru(e){let t=e.spawnError?
|
|
426
|
+
Tu(Au(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${Iu(e)}: ${e.commandLine}${t?`
|
|
427
|
+
${t}`:""}`}function Zr(e,t){let r=new yu(e),n=[],o=0,i=!1;return{write(s){if(i)return!1;let a=r.write(s);return o+a.length>
|
|
428
428
|
t?(n.push(a.slice(0,t-o)),o=t,i=!0,!1):(n.push(a),o+=a.length,!0)},text(){if(!i){let s=r.end();s&&n.push(s.slice(0,t-o)),
|
|
429
|
-
i=!0}return n.join("")}}}function
|
|
430
|
-
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:
|
|
431
|
-
d=
|
|
432
|
-
p={commandLine:
|
|
433
|
-
f=!1,g=null,w=()=>{};d.on("error",
|
|
434
|
-
()=>{!f&&d.kill("SIGKILL")&&(p.forcefullyTerminated=!0)},
|
|
435
|
-
{limit:u,stream:
|
|
429
|
+
i=!0}return n.join("")}}}function oi(e,t,{cwd:r="",env:n={},input:o=void 0,maxBuffer:i=ei,onOutput:s=null,outputEncoding:a="\
|
|
430
|
+
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:ei,l={all:Zr(a,u*2),stderr:Zr(a,u),stdout:Zr(a,u)},m=o!=null,
|
|
431
|
+
d=gu(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[m?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
432
|
+
p={commandLine:Ou(e,t),cwd:wu.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
433
|
+
f=!1,g=null,w=()=>{};d.on("error",P=>{p.spawnError||=P,d.pid===void 0&&w()});let _=()=>{f||!d.kill("SIGTERM")||g||(g=setTimeout(
|
|
434
|
+
()=>{!f&&d.kill("SIGKILL")&&(p.forcefullyTerminated=!0)},ri))},S=(P,T)=>C=>{if(l.all.write(C),l[P].write(C)||(p.maxBuffer||=
|
|
435
|
+
{limit:u,stream:P,unit:"characters"},T.destroy()),typeof s=="function")try{s(String(C||""))}catch{}};d.stdout&&d.stdout.
|
|
436
436
|
on("data",S("stdout",d.stdout)),d.stderr&&d.stderr.on("data",S("stderr",d.stderr)),m&&d.stdin&&(d.stdin.on("error",()=>{}),
|
|
437
|
-
d.stdin.end(o));let A=c>0?setTimeout(()=>{p.timedOut=!0,_()},c):null;return{completion:new Promise(
|
|
437
|
+
d.stdin.end(o));let A=c>0?setTimeout(()=>{p.timedOut=!0,_()},c):null;return{completion:new Promise(P=>{w=(T,C)=>{if(f)return;
|
|
438
438
|
f=!0,clearTimeout(A),clearTimeout(g);let N=p.spawnError?{}:{exitCode:typeof T=="number"&&T>=0?T:void 0,signal:C||void 0},
|
|
439
|
-
|
|
440
|
-
shortMessage:
|
|
441
|
-
once("close",w)}),kill:
|
|
442
|
-
import
|
|
443
|
-
|
|
444
|
-
[
|
|
445
|
-
t&&(
|
|
439
|
+
Q=p.spawnError||p.timedOut||p.maxBuffer||N.exitCode!==0;P({all:l.all.text(),code:p.spawnError?.code,exitCode:N.exitCode,
|
|
440
|
+
shortMessage:Q?Ru({...p,...N}):"",signal:N.signal,stderr:l.stderr.text(),stdout:l.stdout.text(),timedOut:p.timedOut})},d.
|
|
441
|
+
once("close",w)}),kill:P=>d.kill(P),pid:d.pid}}import{spawn as ai}from"node:child_process";import{mkdir as Cu,open as ku,readdir as Nu,readFile as xu}from"node:fs/promises";
|
|
442
|
+
import $u from"node:path";import{fileURLToPath as Mu}from"node:url";var Pu=new URL("./../../../vibe64-execution/src/server/engines/detached.js",import.meta.url).href,be=new Map,Lu=3e3,ju=1e3,
|
|
443
|
+
Du=Mu(new URL("./detachedReaper.js",Pu)),Z=null;function Uu(e){if(process.platform!=="win32"){if(!Z){let t=ai(process.execPath,
|
|
444
|
+
[Du],{cwd:"/",detached:!0,stdio:["pipe","ignore","ignore"]});t.once("error",()=>{Z===t&&(Z=null)}),t.once("exit",()=>{Z===
|
|
445
|
+
t&&(Z=null)}),t.stdin.on("error",()=>{}),t.unref(),t.stdin.unref(),Z=t;for(let r of be.values())r.scopeEmpty!==!0&&r.pid!==
|
|
446
446
|
e&&t.stdin.write(`+${r.pid}
|
|
447
|
-
`)}
|
|
448
|
-
`)}}function
|
|
449
|
-
`),![...
|
|
450
|
-
e),{recursive:!0}),
|
|
451
|
-
e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function
|
|
452
|
-
await
|
|
453
|
-
env:n,stdio:i});await
|
|
454
|
-
s.once("exit",()=>{!
|
|
455
|
-
|
|
447
|
+
`)}Z.stdin.write(`+${e}
|
|
448
|
+
`)}}function Gu(e){Z&&(Z.stdin.write(`-${e}
|
|
449
|
+
`),![...be.values()].some(t=>t.scopeEmpty!==!0)&&(Z.stdin.end(),Z=null))}async function Hu(e=""){return e?(await Cu($u.dirname(
|
|
450
|
+
e),{recursive:!0}),ku(e,"w",384)):null}async function Bu(e){return new Promise((t,r)=>{let n=!1,o=(i,s)=>{n||(n=!0,i(s))};
|
|
451
|
+
e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function ci(e={},t={}){let{cwd:r="",env:n={}}=t,o=null;try{o=
|
|
452
|
+
await Hu(e.logPath);let i=o?["ignore",o.fd,o.fd]:["ignore","ignore","ignore"],s=ai(e.command,e.args,{cwd:r||void 0,detached:!0,
|
|
453
|
+
env:n,stdio:i});await Bu(s);let a=e.execution?.id||"";return a&&(be.set(a,{child:s,pid:Number(s.pid)}),Uu(Number(s.pid)),
|
|
454
|
+
s.once("exit",()=>{!jt(s.pid)&&be.has(a)&&(be.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),Gu(Number(s.pid)))})),s.unref(),
|
|
455
|
+
nt({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return L(i?.message||
|
|
456
456
|
"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{await o?.
|
|
457
|
-
close().catch(()=>null)}}function
|
|
458
|
-
"win32"){let r=[...
|
|
459
|
-
kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function
|
|
460
|
-
"win32"?[...
|
|
461
|
-
"ESRCH")return!1;throw r}}async function
|
|
462
|
-
r)||r<=0)return[];let n=[];for(let o of await
|
|
463
|
-
let i=await
|
|
464
|
-
r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}return n}async function
|
|
465
|
-
now()+Math.max(0,Number(t)||0);for(;
|
|
466
|
-
let{killTimeoutMs:r=
|
|
467
|
-
r)),o}var
|
|
457
|
+
close().catch(()=>null)}}function jt(e=null){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;if(process.platform===
|
|
458
|
+
"win32"){let r=[...be.values()].find(n=>n.pid===t);return r?.child?.exitCode===null&&r?.child?.signalCode===null}try{return process.
|
|
459
|
+
kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function ii(e=null,t="SIGTERM"){if(!jt(e))return!1;try{return process.platform===
|
|
460
|
+
"win32"?[...be.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),!0}catch(r){if(r?.code===
|
|
461
|
+
"ESRCH")return!1;throw r}}async function ui(e=null,t=10){let r=Number(e);if(process.platform!=="linux"||!Number.isSafeInteger(
|
|
462
|
+
r)||r<=0)return[];let n=[];for(let o of await Nu("/proc").catch(()=>[])){if(n.length>=t)break;if(!/^\d+$/u.test(o))continue;
|
|
463
|
+
let i=await xu(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(s+2).split(" ");Number(a[2])!==
|
|
464
|
+
r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}return n}async function si(e=null,t=0){let r=Date.
|
|
465
|
+
now()+Math.max(0,Number(t)||0);for(;jt(e)&&Date.now()<r;)await new Promise(n=>setTimeout(n,25));return!jt(e)}async function Dt(e=null,t={}){
|
|
466
|
+
let{killTimeoutMs:r=ju,termTimeoutMs:n=Lu}=t;ii(e,"SIGTERM");let o=await si(e,n);return o||(ii(e,"SIGKILL"),o=await si(e,
|
|
467
|
+
r)),o}var li=new Map;async function Ee(e="",t=[],r={}){let{cwd:n="",env:o={},execution:i=null,input:s=void 0,maxBuffer:a=void 0,onOutput:c=null,
|
|
468
468
|
outputEncoding:u="utf8",signal:l=null,timeout:m=15e3}=r,d,p,f,g=null,w=Promise.withResolvers(),_=()=>{f||=p(),f.then(w.resolve)};
|
|
469
|
-
if(l?.aborted)return L("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let I=
|
|
470
|
-
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});g=Number(I.pid);let
|
|
471
|
-
N=
|
|
469
|
+
if(l?.aborted)return L("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let I=oi(e,t,{cwd:n,env:o,input:s,
|
|
470
|
+
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});g=Number(I.pid);let P;p=()=>{if(!P){let N;process.platform!=="win32"?
|
|
471
|
+
N=Dt(g).catch(()=>!1):(I.kill("SIGKILL"),N=I.completion.then(()=>!0)),P=N.then(Q=>(Q||(P=null),Q))}return P},i?.id&&li.set(
|
|
472
472
|
i.id,p),l?.addEventListener("abort",_,{once:!0}),l?.aborted&&_();let T=await Promise.race([I.completion,w.promise.then(N=>N?
|
|
473
|
-
I.completion:{exitCode:1})]),C=typeof T.exitCode=="number"?T.exitCode:1;d=
|
|
473
|
+
I.completion:{exitCode:1})]),C=typeof T.exitCode=="number"?T.exitCode:1;d=nt({code:T.timedOut===!0?"vibe64_command_captu\
|
|
474
474
|
re_timed_out":T.code?"vibe64_command_capture_failed":"",error:C===0?"":T.shortMessage,exitCode:C,output:T.all||(C===0?"":
|
|
475
475
|
T.shortMessage),outputEncoding:u,signal:T.signal,stderr:T.stderr,stdout:T.stdout,timedOut:T.timedOut===!0,execution:i})}catch(I){
|
|
476
476
|
d=L(I.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{l?.removeEventListener("abort",_)}
|
|
477
|
-
if(!await(f||p?.()||!0)){let I=await
|
|
477
|
+
if(!await(f||p?.()||!0)){let I=await ui(g),P=d?.timedOut?"The command timed out":l?.aborted?"The command was cancelled":
|
|
478
478
|
"The command finished",T=I.length?`: ${I.map(C=>`${C.command} (pid ${C.pid})`).join(", ")} still running`:"";return{...L(
|
|
479
|
-
`${
|
|
479
|
+
`${P}, and its execution scope did not become empty${T}.`,"vibe64_execution_drain_failed",{execution:i,output:d?.output,
|
|
480
480
|
outputEncoding:u,signal:d?.signal,stderr:d?.stderr,stdout:d?.stdout,timedOut:d?.timedOut}),remainingProcesses:I}}i?.id&&
|
|
481
|
-
|
|
482
|
-
execution:A,outputEncoding:u}):A?{...d,execution:A}:d}import
|
|
483
|
-
for("vibe64.hostProfile"),
|
|
484
|
-
cHelperPath"],
|
|
485
|
-
function
|
|
486
|
-
var
|
|
481
|
+
li.delete(i.id);let A=i&&{...i,state:"finished"};return l?.aborted?L("Command cancelled.","vibe64_command_cancelled",{...d,
|
|
482
|
+
execution:A,outputEncoding:u}):A?{...d,execution:A}:d}import Vu from"node:path";import di from"node:process";import{isMainThread as zu}from"node:worker_threads";var en=Symbol.
|
|
483
|
+
for("vibe64.hostProfile"),ot=Symbol.for("vibe64.hostProfile.previousUmask"),Fu=["runtimePackRoot","sharedCacheRoot","exe\
|
|
484
|
+
cHelperPath"],Ut=Object.freeze({runtimePackRoot:"",sharedCacheRoot:"",loginEnvironment:null,execHelperPath:"",sharedGroupAccess:!1});
|
|
485
|
+
function pi(e){zu&&(e&&!(ot in globalThis)?globalThis[ot]=di.umask(7):!e&&ot in globalThis&&(di.umask(globalThis[ot]),delete globalThis[ot]))}
|
|
486
|
+
var Wu=/^(?:\/(?:%u|[A-Za-z0-9._-])+)+$/u;function mi(e,t){if(typeof e!="string"||!Wu.test(e)||e.split("/").includes("..")||
|
|
487
487
|
e.replaceAll("%u","").includes("%"))throw new TypeError(`Host profile loginEnvironment ${t} must be an absolute path, "%\
|
|
488
|
-
u" standing for the login.`);return e}function
|
|
488
|
+
u" standing for the login.`);return e}function qu(e){if(e===null)return null;let{env:t,path:r}=e||{};if(typeof e!="objec\
|
|
489
489
|
t"||Object.keys(e).some(i=>i!=="env"&&i!=="path")||!t||typeof t!="object"||Array.isArray(t)||!Array.isArray(r))throw new TypeError(
|
|
490
490
|
"Host profile loginEnvironment must be null or { env, path }.");let n=Object.keys(t),o=n.find(i=>!/^[A-Z][A-Z0-9_]*$/u.test(
|
|
491
491
|
i)||["HOME","LOGNAME","PATH","TMPDIR","USER","XDG_RUNTIME_DIR"].includes(i));if(o!==void 0)throw new TypeError(`Host pro\
|
|
492
|
-
file loginEnvironment cannot set ${o}.`);return Object.freeze({env:Object.freeze(Object.fromEntries(n.map(i=>[i,
|
|
493
|
-
i)]))),path:Object.freeze(r.map(i=>
|
|
494
|
-
|
|
495
|
-
")}.`);let r={...
|
|
492
|
+
file loginEnvironment cannot set ${o}.`);return Object.freeze({env:Object.freeze(Object.fromEntries(n.map(i=>[i,mi(t[i],
|
|
493
|
+
i)]))),path:Object.freeze(r.map(i=>mi(i,"path")))})}function tn(e=null){if(e===null)return delete globalThis[en],pi(!1),
|
|
494
|
+
Ut;let t=Object.keys(e).filter(o=>!(o in Ut));if(t.length)throw new TypeError(`Unknown host profile setting: ${t.join(",\
|
|
495
|
+
")}.`);let r={...Ut,...e};for(let o of Fu)if(typeof r[o]!="string"||r[o]&&!Vu.isAbsolute(r[o]))throw new TypeError(`Hos\
|
|
496
496
|
t profile ${o} must be an absolute path or empty.`);if(typeof r.sharedGroupAccess!="boolean")throw new TypeError("Host p\
|
|
497
|
-
rofile sharedGroupAccess must be true or false.");r.loginEnvironment=
|
|
498
|
-
n,
|
|
497
|
+
rofile sharedGroupAccess must be true or false.");r.loginEnvironment=qu(r.loginEnvironment);let n=Object.freeze(r);return globalThis[en]=
|
|
498
|
+
n,pi(n.sharedGroupAccess),n}function G(){return globalThis[en]||Ut}var Yu="vibe64.exec-helper.payload",Ku=1;function rn(e=""){let t=String(e||"").trim()||G().execHelperPath;if(!t){let r=new Error(
|
|
499
499
|
"This computer has no helper for running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}
|
|
500
|
-
function
|
|
501
|
-
operation:i="vibe64-command",args:s=[]}={}){return
|
|
500
|
+
function fi(e={}){return{...e,schema:Yu,schemaVersion:Ku}}function Gt({actor:e={},command:t="",cwd:r="",env:n={},input:o,
|
|
501
|
+
operation:i="vibe64-command",args:s=[]}={}){return fi({args:Array.isArray(s)?s.map(a=>String(a)):[],command:t,cwd:r,env:n,
|
|
502
502
|
gid:e.user?.gid,home:e.user?.home,inputBase64:o==null?"":Buffer.isBuffer(o)?o.toString("base64"):Buffer.from(String(o)).
|
|
503
|
-
toString("base64"),operation:i,uid:e.user?.uid,username:e.user?.username})}function
|
|
503
|
+
toString("base64"),operation:i,uid:e.user?.uid,username:e.user?.username})}function it(e={}){return e.mode==="pty"&&e.envPolicy===
|
|
504
504
|
"auth"&&!["assistant","codex"].includes(e.purpose)?"account-auth-terminal":e.purpose==="codex"&&e.mode==="capture"&&e.envPolicy===
|
|
505
505
|
"auth"||e.purpose==="codex"&&e.mode==="detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"?"c\
|
|
506
506
|
odex-app-server":e.mode==="detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"&&["opencode-ca\
|
|
507
507
|
talog","opencode-server"].includes(e.execution?.operationId)||e.mode==="capture"&&e.execution?.kind==="assistant"&&e.execution?.
|
|
508
508
|
operationId==="opencode-catalog"?"opencode-app-server":e.purpose==="account"?"account-status":e.purpose==="github"?"gith\
|
|
509
509
|
ub-workflow-command":e.purpose==="github-api"?"github-api-command":e.purpose==="workspace-cache"?"workspace-cache-comman\
|
|
510
|
-
d":e.purpose==="health"?"health-status":"vibe64-command"}async function
|
|
511
|
-
outputEncoding:o="utf8",runCapture:i=
|
|
510
|
+
d":e.purpose==="health"?"health-status":"vibe64-command"}async function nn(e={},{env:t,helperPath:r="",maxBuffer:n=void 0,
|
|
511
|
+
outputEncoding:o="utf8",runCapture:i=Ee,signal:s=null,timeout:a=15e3}){let c={env:t,input:`${JSON.stringify(e)}
|
|
512
512
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
513
|
-
udo",["-n",
|
|
514
|
-
in",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
515
|
-
versionName:"1.0.0"});var
|
|
516
|
-
"metadata","migrations","runtime","vite"]);import
|
|
517
|
-
session?.metadata?.session_git_command_actor_user_key)}async function
|
|
518
|
-
e.stagingAccount)return{actor:t,stagingAccount:!0,credentialScope:t,requiresRealUser:!1,user:await
|
|
519
|
-
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:
|
|
513
|
+
udo",["-n",rn(r),"execute"],c)}import{createRequire as Xu}from"node:module";var Ju=new URL("./../../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var Eg=Xu(Ju);var Ig=Object.freeze(["bundled","dev_server"]),Rg=Object.freeze(["capacitor"]),Pg=Object.freeze({callbackPath:"/auth/log\
|
|
514
|
+
in",customScheme:"",appLinkDomains:Object.freeze([])}),Cg=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
|
|
515
|
+
versionName:"1.0.0"});var Xg=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Qg=Object.freeze(["capabilities","kind",
|
|
516
|
+
"metadata","migrations","runtime","vite"]);import rl from"node:path";var el="jskit-client-build",n_=new RegExp(`<meta name="${el}" content="([0-9a-f]+)"`,"u");var u_=rl.join("dist","index.html");function ol(e={}){return oe(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
517
|
+
session?.metadata?.session_git_command_actor_user_key)}async function hi(e={}){let t=E(e.actor)||"daemon";if(t==="app"&&
|
|
518
|
+
e.stagingAccount)return{actor:t,stagingAccount:!0,credentialScope:t,requiresRealUser:!1,user:await Qr(e.stagingAccount)};
|
|
519
|
+
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:Xr()};let r=ol(e);if(!r){let n=new Error(
|
|
520
520
|
"A user key is required for real-user command execution.");throw n.code="vibe64_command_actor_user_required",n}return{actor:t,
|
|
521
|
-
credentialScope:"user",requiresRealUser:!0,user:await
|
|
522
|
-
execHelperPath}function
|
|
523
|
-
return;let n=v(t.session?.sourceRoot||t.session?.sourcePath),o=v(r);if(!n||!o||!
|
|
521
|
+
credentialScope:"user",requiresRealUser:!0,user:await Qr(r)}}import Zl from"node:os";import yn from"node:path";import gi from"node:path";function De(e={}){let t=Zo();return t.uid===null||t.gid===null||t.uid===e.user?.uid&&t.gid===e.user?.gid}function on(){return!!G().
|
|
522
|
+
execHelperPath}function Ht(e={}){return e.requiresRealUser?on()||!De(e):!1}function _i(e={},t={},r=""){if(!e.requiresRealUser)
|
|
523
|
+
return;let n=v(t.session?.sourceRoot||t.session?.sourcePath),o=v(r);if(!n||!o||!ae(n,o))return;let i=new Error("Commands\
|
|
524
524
|
in a session's source must run as the editor's own user, not as a person's account.");throw i.code="vibe64_command_mana\
|
|
525
|
-
ged_source_real_user_forbidden",i}function
|
|
526
|
-
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&
|
|
527
|
-
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var
|
|
525
|
+
ged_source_real_user_forbidden",i}function wi(e={},t={}){let r=v(e.user?.home),n=v(t.HOME),o=v(t.VIBE64_CREDENTIAL_HOME);
|
|
526
|
+
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&gi.resolve(r)!==gi.resolve(n)){let i=new Error("Command HOME does not match t\
|
|
527
|
+
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var st=Object.freeze(["DATABASE_URL","DB_CLIENT","DB_DATABASE","DB_HOST","DB_NAME","DB_PASSWORD","DB_PORT","DB_USER","DB\
|
|
528
528
|
_USERNAME","MYSQL_DATABASE","MYSQL_HOST","MYSQL_PWD","MYSQL_TCP_PORT","PGDATABASE","PGHOST","PGPASSWORD","PGPORT","PGUSE\
|
|
529
|
-
R","VIBE64_MYSQL_USER"]);function
|
|
530
|
-
return t}import{spawn as
|
|
531
|
-
import{stat as
|
|
532
|
-
d",
|
|
529
|
+
R","VIBE64_MYSQL_USER"]);function Bt(...e){let t={};for(let r of e){let n=q(r);for(let o of st)n[o]!==void 0&&(t[o]=n[o])}
|
|
530
|
+
return t}import{spawn as il,spawnSync as sl}from"node:child_process";import{createHash as al}from"node:crypto";import{statSync as Ti}from"node:fs";
|
|
531
|
+
import{stat as Oi}from"node:fs/promises";import Vt from"node:path";var Se="GIT_AUTHOR_NAME",Te="GIT_AUTHOR_EMAIL",Oe="GIT_COMMITTER_NAME",Ae="GIT_COMMITTER_EMAIL",sn=".users.vibe64.invali\
|
|
532
|
+
d",cl=2e3,Ai=["config","--get-regexp","^user\\.(name|email)$"],Ii=3e4,ul=['git config --global user.name "Your Name"','g\
|
|
533
533
|
it config --global user.email "you@example.com"'].join(`
|
|
534
|
-
`);function
|
|
535
|
-
t}function
|
|
536
|
-
n.name,n.userName,n.user_name),i=
|
|
534
|
+
`);function yi(e="",t="vibe64"){return E(e).toLowerCase().replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||
|
|
535
|
+
t}function ll(...e){for(let t of e){let r=M(t),n=M(r.user),o=oe(r.name,r.userName,r.user_name,r.gitUserName,r.git_user_name,
|
|
536
|
+
n.name,n.userName,n.user_name),i=oe(r.email,r.userEmail,r.user_email,r.gitUserEmail,r.git_user_email,n.email,n.userEmail,
|
|
537
537
|
n.user_email);if(o&&i)return{authorEmail:i,authorName:o,committerEmail:i,committerName:o,source:"configured"}}return null}
|
|
538
|
-
function
|
|
539
|
-
!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"github"}}function
|
|
540
|
-
let r=
|
|
541
|
-
64@${n}${
|
|
542
|
-
let t=
|
|
543
|
-
t).then(r=>r.isDirectory(),()=>!1)?t:""}function
|
|
544
|
-
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=E(n[2]))}return t}function
|
|
545
|
-
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:
|
|
546
|
-
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?
|
|
547
|
-
null}}function
|
|
538
|
+
function dl(e={}){let t=M(e),r=oe(t.name,t.displayName,t.login,t.username),n=oe(t.email,t.publicEmail,t.verifiedEmail);return!r||
|
|
539
|
+
!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"github"}}function pl({workspace:e="",userKey:t=""}={}){
|
|
540
|
+
let r=yi(t,"user"),n=yi(e,"local");return{authorEmail:`${r}@${n}${sn}`,authorName:`${r} via Vibe64`,committerEmail:`vibe\
|
|
541
|
+
64@${n}${sn}`,committerName:"Vibe64",source:"fallback"}}function an(e=""){let t=E(e);return t&&Vt.isAbsolute(t)?t:""}function bi(e=""){
|
|
542
|
+
let t=an(e);try{return t&&Ti(t).isDirectory()?t:""}catch{return""}}async function Ei(e=""){let t=an(e);return t&&await Oi(
|
|
543
|
+
t).then(r=>r.isDirectory(),()=>!1)?t:""}function Ri(e=""){let t={};for(let r of String(e||"").split(`
|
|
544
|
+
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=E(n[2]))}return t}function Pi(e,t){return{
|
|
545
|
+
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:cl}}function vi(e,t){let r=sl("git",Ai,{...Pi(e,t),encoding:"\
|
|
546
|
+
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?Ri(r.stdout):
|
|
547
|
+
null}}function Si(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=il("git",Ai,Pi(e,t));s.stdout.setEncoding(
|
|
548
548
|
"utf8"),s.stdout.on("data",a=>{n+=a}),s.once("error",()=>i({transient:!0,values:null})),s.once("close",(a,c)=>i(c?{transient:!0,
|
|
549
|
-
values:null}:{transient:!1,values:a===0||a===1?
|
|
550
|
-
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function
|
|
551
|
-
env.PATH||e.PATH}}function
|
|
552
|
-
e.HOME),r=E(e.XDG_CONFIG_HOME)||(t?
|
|
553
|
-
g"):""].filter(Boolean)}async function
|
|
554
|
-
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function
|
|
555
|
-
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}var
|
|
556
|
-
entries(r).sort(([o],[i])=>o<i?-1:o>i?1:0);return
|
|
557
|
-
let n=e?await
|
|
558
|
-
values}}function
|
|
559
|
-
transient),values:o.values}}function
|
|
560
|
-
i.expiresAt<=r&&
|
|
561
|
-
if(s)return(await s.read).values;let a={expiresAt:i+
|
|
562
|
-
transient?
|
|
563
|
-
s
|
|
564
|
-
read:Promise.resolve(a),revision:o,values:a.values}),a.values}async function
|
|
565
|
-
"object")return null;let[r,n]=await Promise.all([
|
|
566
|
-
env:t=null}={}){return!t||typeof t!="object"?null:
|
|
567
|
-
n=E(t.email);return!r||!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function
|
|
568
|
-
return E(e).toLowerCase().endsWith(
|
|
569
|
-
metadata);return
|
|
570
|
-
|
|
571
|
-
n.githubUser||i.github_user)||
|
|
572
|
-
user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.LOGNAME)})}async function
|
|
573
|
-
e)||await
|
|
574
|
-
authorEmail,[
|
|
575
|
-
return
|
|
549
|
+
values:null}:{transient:!1,values:a===0||a===1?Ri(n):null}))})}function Ci(e=null){return!e?.name||!e?.email?null:{authorEmail:e.
|
|
550
|
+
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function ki(e={}){return{...e,PATH:process.
|
|
551
|
+
env.PATH||e.PATH}}function Ni(e={}){if(Object.hasOwn(e,"GIT_CONFIG_GLOBAL"))return[String(e.GIT_CONFIG_GLOBAL)];let t=an(
|
|
552
|
+
e.HOME),r=E(e.XDG_CONFIG_HOME)||(t?Vt.join(t,".config"):"");return[r?Vt.join(r,"git","config"):"",t?Vt.join(t,".gitconfi\
|
|
553
|
+
g"):""].filter(Boolean)}async function ml(e={}){return(await Promise.all(Ni(e).map(r=>Oi(r).then(n=>`${n.ino}:${n.size}:${n.
|
|
554
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function fl(e={}){return Ni(e).map(t=>{try{let r=Ti(t);return`${r.ino}\
|
|
555
|
+
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}var ve=new Map;function xi(e,t,r){let n=Object.
|
|
556
|
+
entries(r).sort(([o],[i])=>o<i?-1:o>i?1:0);return al("sha256").update(JSON.stringify([e,t,n])).digest("hex")}async function hl(e,t,r){
|
|
557
|
+
let n=e?await Si(e,r):null;if(n?.values)return n;let o=await Si(t,r);return{transient:!!(n?.transient||o.transient),values:o.
|
|
558
|
+
values}}function gl(e,t,r){let n=e?vi(e,r):null;if(n?.values)return n;let o=vi(t,r);return{transient:!!(n?.transient||o.
|
|
559
|
+
transient),values:o.values}}function $i(e,t,r){let n=ve.get(e);if(n&&n.revision===t&&n.expiresAt>r)return n;for(let[o,i]of ve)
|
|
560
|
+
i.expiresAt<=r&&ve.delete(o);return null}async function _l(e,t,r){let n=xi(e,t,r),o=await ml(r),i=Date.now(),s=$i(n,o,i);
|
|
561
|
+
if(s)return(await s.read).values;let a={expiresAt:i+Ii,read:hl(e,t,r),revision:o};ve.set(n,a);let c=await a.read;return c.
|
|
562
|
+
transient?ve.get(n)===a&&ve.delete(n):a.values=c.values,c.values}function wl(e,t,r){let n=xi(e,t,r),o=fl(r),i=Date.now(),
|
|
563
|
+
s=$i(n,o,i);if(s&&Object.hasOwn(s,"values"))return s.values;let a=gl(e,t,r);return a.transient||ve.set(n,{expiresAt:i+Ii,
|
|
564
|
+
read:Promise.resolve(a),revision:o,values:a.values}),a.values}async function yl({cwd:e="",env:t=null}={}){if(!t||typeof t!=
|
|
565
|
+
"object")return null;let[r,n]=await Promise.all([Ei(e),Ei(t.HOME)]);return Ci(await _l(r,n,ki(t)))}function bl({cwd:e="",
|
|
566
|
+
env:t=null}={}){return!t||typeof t!="object"?null:Ci(wl(bi(e),bi(t.HOME),ki(t)))}function El(e={}){let t=M(e),r=E(t.name),
|
|
567
|
+
n=E(t.email);return!r||!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function cn(e=""){
|
|
568
|
+
return E(e).toLowerCase().endsWith(sn)}function Mi({env:e,personGitIdentity:t=null,project:r={},session:n={}}){let o=M(n.
|
|
569
|
+
metadata);return ll(r.gitIdentity,r.config?.git,n.gitIdentity,o.git_identity,{name:e.VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||
|
|
570
|
+
El(t)}function Li({actor:e={},env:t,project:r={},session:n={},userKey:o=""}){let i=M(n.metadata);return dl(r.githubUser||
|
|
571
|
+
n.githubUser||i.github_user)||pl({workspace:oe(r.workspace,t.VIBE64_WORKSPACE,t.VIBE64_RUNTIME_NAMESPACE),userKey:oe(o,e.
|
|
572
|
+
user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.LOGNAME)})}async function vl(e){return Mi(
|
|
573
|
+
e)||await yl(e.gitConfig||{})||Li(e)}function Sl(e){return Mi(e)||bl(e.gitConfig||{})||Li(e)}function ji(e){return{[Te]:e.
|
|
574
|
+
authorEmail,[Se]:e.authorName,[Ae]:e.committerEmail,[Oe]:e.committerName}}async function Di(e){return ji(await vl(e))}function Ui(e){
|
|
575
|
+
return ji(Sl(e))}import{readFileSync as Ol}from"node:fs";import Hi from"node:path";import un from"node:path";var Ue=Object.freeze({awsebcli:{binDirs:["awsebcli/bin"],managedCommands:["eb"]},bubblewrap:{binDirs:["bubblewrap/bin"],
|
|
576
576
|
managedCommands:[]},bun:{binDirs:["bun/bin"],dependencyFiles:["package.json","bun.lock","bun.lockb","package-lock.json"],
|
|
577
577
|
managedCommands:["bun"]},composer:{binDirs:["composer/bin"],dependencyFiles:["composer.json","composer.lock"],managedCommands:[
|
|
578
578
|
"composer"]},cpp:{binDirs:["cpp/bin"],dependencyFiles:["CMakeLists.txt","vcpkg.json","vcpkg-configuration.json","conanfi\
|
|
@@ -600,333 +600,341 @@ i/claude-code/package.json","operator-clis/lib/node_modules/@openai/codex/packag
|
|
|
600
600
|
opencode-ai/package.json"],managedCommands:["claude","codex","opencode"]},php:{binDirs:["php/bin"],managedCommands:["php"]},
|
|
601
601
|
playwright:{binDirs:["playwright/bin"],identityPaths:["playwright/runtime.env","playwright/browsers"],managedCommands:["\
|
|
602
602
|
playwright"]},postgresql:{binDirs:["postgresql/bin"],managedCommands:["initdb","pg_ctl","pg_isready","postgres","psql"]},
|
|
603
|
-
ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:["sqlite3"]}}),
|
|
603
|
+
ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:["sqlite3"]}}),ln=Object.
|
|
604
604
|
freeze(["operator-clis","node26","git","gh","mysql","mariadb","postgresql","sqlite","ripgrep","bubblewrap","bun","php","\
|
|
605
605
|
composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);function j({root:e=""}={}){
|
|
606
|
-
return v(e||
|
|
607
|
-
let e=j();return e?[
|
|
608
|
-
let t=E(e);return[...
|
|
609
|
-
R_DOWNLOAD",
|
|
610
|
-
runtimePackRoot:e=""}={}){let t=j({root:e});if(!t)return"";let r=
|
|
606
|
+
return v(e||G().runtimePackRoot)}function dn(e=""){let t=j();return(t?Ue[E(e)]?.binDirs||[]:[]).map(n=>un.join(t,n))}function Gi(){
|
|
607
|
+
let e=j();return e?[un.join(e,"guard-bin")]:[]}function pn(){let e=j();return e?[un.join(e,"policy-bin")]:[]}function Tl(e=""){
|
|
608
|
+
let t=E(e);return[...Ue[t]?.managedCommands||[]]}var Z_=Object.freeze({runtimePackManagedCommands:Tl});var zt="VIBE64_SHARED_CACHE_ROOT",Al="VIBE64_RUNTIME_PACK_ROOT",at="PLAYWRIGHT_BROWSERS_PATH",mn="PLAYWRIGHT_SKIP_BROWSE\
|
|
609
|
+
R_DOWNLOAD",fn="VIBE64_PLAYWRIGHT_VERSION",Bi="playwright",Il="browsers",Rl="runtime.env",Pl=/^\d+\.\d+\.\d+$/u;function Cl({
|
|
610
|
+
runtimePackRoot:e=""}={}){let t=j({root:e});if(!t)return"";let r=Hi.join(t,Bi,Rl),n;try{n=Ol(r,"utf8")}catch(i){if(i?.code===
|
|
611
611
|
"ENOENT")return"";throw i}let o=n.split(/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());
|
|
612
|
-
if(o.length!==1||!
|
|
613
|
-
runtimePackRoot:e=""}={}){let t=j({root:e}),r=v(
|
|
614
|
-
{[
|
|
615
|
-
ACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIME_DIR"]),
|
|
616
|
-
for(let t of Object.keys(q(e)))if(
|
|
617
|
-
e execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function
|
|
618
|
-
session"}=t,n=q(e);
|
|
619
|
-
...
|
|
612
|
+
if(o.length!==1||!Pl.test(o[0]))throw new Error(`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function Vi({
|
|
613
|
+
runtimePackRoot:e=""}={}){let t=j({root:e}),r=v(G().sharedCacheRoot),n=Cl({runtimePackRoot:t});return{...r?{[zt]:r}:{},...t?
|
|
614
|
+
{[Al]:t,[at]:Hi.join(t,Bi,Il),[mn]:"1"}:{},...n?{[fn]:n}:{}}}var kl=new Set(["HOME","LOGNAME","PATH","TMPDIR","USER","VIBE64_EXECUTION_ID","VIBE64_MANAGED_EXECUTION_REQUIRED","XDG_C\
|
|
615
|
+
ACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIME_DIR"]),Nl=new Set([...st,Te,Se,Ae,Oe,at,mn,fn,zt]);function Ge(e={}){
|
|
616
|
+
for(let t of Object.keys(q(e)))if(kl.has(t)||t.startsWith("XDG_")){let r=new Error(`Vibe64 command callers cannot provid\
|
|
617
|
+
e execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function Ft(e={},t={}){let{envPolicy:r="\
|
|
618
|
+
session"}=t,n=q(e);Ge(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!Nl.has(i)));return r==="staging"?o:{...o,
|
|
619
|
+
...Bt(n)}}function xl(e=""){let t=v(e);return t==="/home"||t.startsWith("/home/")}function zi({actor:e={},request:t={}}={}){let r=t.
|
|
620
620
|
credentialHome||{},n=v(r.home);if(!n)return{};let o=v(e.user?.home);if(e.requiresRealUser&&o&&n!==o){let a=new Error("Co\
|
|
621
621
|
mmand credential home must match the resolved real-user actor home.");throw a.code="vibe64_command_credential_home_actor\
|
|
622
|
-
_mismatch",a}if(!e.requiresRealUser&&
|
|
622
|
+
_mismatch",a}if(!e.requiresRealUser&&xl(n)&&o&&!ae(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
623
623
|
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=E(r.username||e.user?.username),
|
|
624
|
-
s=
|
|
624
|
+
s=rt({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n});if(o&&n===o)for(let a of["XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DA\
|
|
625
625
|
TA_HOME"])delete s[a];return{...s,...v(r.cacheRoot)?{XDG_CACHE_HOME:v(r.cacheRoot)}:{},...v(r.configRoot)?{XDG_CONFIG_HOME:v(
|
|
626
|
-
r.configRoot)}:{},...v(r.dataRoot)?{XDG_DATA_HOME:v(r.dataRoot)}:{},...v(r.stateRoot)?{XDG_STATE_HOME:v(r.stateRoot)}:{}}}import
|
|
627
|
-
steadOf",value:"ssh://git@github.com/"}]),
|
|
628
|
-
/env gh auth git-credential"}]),
|
|
629
|
-
get) printf '%s\\n' username=x-access-token "password=\${VIBE64_GIT_AUTH_TOKEN}" ;; esac; }; f`}]);function
|
|
630
|
-
r=[];for(let n of Array.isArray(e)?e:[e]){let o=E(n);if(!o||!
|
|
631
|
-
add(i),r.push(i))}return r}function
|
|
626
|
+
r.configRoot)}:{},...v(r.dataRoot)?{XDG_DATA_HOME:v(r.dataRoot)}:{},...v(r.stateRoot)?{XDG_STATE_HOME:v(r.stateRoot)}:{}}}import Fi from"node:path";var $l=Object.freeze([{key:"url.https://github.com/.insteadOf",value:"git@github.com:"},{key:"url.https://github.com/.in\
|
|
627
|
+
steadOf",value:"ssh://git@github.com/"}]),Ml=Object.freeze([{key:"credential.https://github.com.helper",value:"!/usr/bin\
|
|
628
|
+
/env gh auth git-credential"}]),Ll=Object.freeze([{key:"credential.https://github.com.helper",value:`!f() { case "$1" in\
|
|
629
|
+
get) printf '%s\\n' username=x-access-token "password=\${VIBE64_GIT_AUTH_TOKEN}" ;; esac; }; f`}]);function jl(e=[]){let t=new Set,
|
|
630
|
+
r=[];for(let n of Array.isArray(e)?e:[e]){let o=E(n);if(!o||!Fi.isAbsolute(o))continue;let i=Fi.resolve(o);t.has(i)||(t.
|
|
631
|
+
add(i),r.push(i))}return r}function ct(e={},t=[]){let r={...e&&typeof e=="object"&&!Array.isArray(e)?e:{}},n=Number.parseInt(
|
|
632
632
|
String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?n:0;for(let i of Array.isArray(t)?t:[]){let s=E(i?.key);
|
|
633
633
|
s&&(r[`GIT_CONFIG_KEY_${o}`]=s,r[`GIT_CONFIG_VALUE_${o}`]=String(i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),
|
|
634
|
-
r}function
|
|
635
|
-
return
|
|
636
|
-
0",PAGER:"cat"}}function
|
|
637
|
-
return
|
|
638
|
-
gitSafeDirectoryArgs:
|
|
639
|
-
ires a gitAuthToken.");throw t.code="vibe64_command_git_auth_token_required",t}return
|
|
640
|
-
[
|
|
641
|
-
-token"?r=
|
|
642
|
-
[])}import
|
|
643
|
-
|
|
634
|
+
r}function Wi(e=[]){return jl(e).map(t=>({key:"safe.directory",value:t}))}function qi(e={},t=[]){return ct(e,Wi(t))}function Dl(e=[]){
|
|
635
|
+
return Wi(e).flatMap(t=>["-c",`${t.key}=${t.value}`])}function hn(){return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"\
|
|
636
|
+
0",PAGER:"cat"}}function gn(e={}){return ct(e,$l)}function Ul(e={}){return ct(e,Ml)}function Gl(e={}){return ct(e,Ll)}function Yi(e={}){
|
|
637
|
+
return Ul(gn(e))}function Ki(e={}){return Gl(gn(e))}var _w=Object.freeze({applyGitConfigEntriesToEnv:ct,githubSshToHttpsGitEnv:gn,
|
|
638
|
+
gitSafeDirectoryArgs:Dl});var Hl="VIBE64_GIT_AUTH_TOKEN";function Bl(e={}){if(!e.gitAuthToken){let t=new Error("Token-backed GitHub transport requ\
|
|
639
|
+
ires a gitAuthToken.");throw t.code="vibe64_command_git_auth_token_required",t}return Ki({...hn(),GIT_TERMINAL_PROMPT:"0",
|
|
640
|
+
[Hl]:e.gitAuthToken})}function Ji({request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github\
|
|
641
|
+
-token"?r=Bl(e):(e.gitTransport==="github-https"||e.purpose==="github")&&(r=Yi({...t,...hn()})),qi(r,e.gitSafeDirectories||
|
|
642
|
+
[])}import{existsSync as Wt,readlinkSync as Vl}from"node:fs";import zl from"node:os";import Y from"node:path";var Xi=".development/gradle-home",Qi="init.d/vibe64-connected.init.gradle.kts",Fl="current";function Zi(){let e=v(G().sharedCacheRoot),
|
|
643
|
+
t=v(process.env.XDG_CACHE_HOME)||Y.join(zl.homedir(),".cache");return e?Y.join(e,"gradle-ro-dep-cache"):Y.join(t,"vibe64",
|
|
644
|
+
"gradle-ro-dep-cache")}function Wl(e){let t=v(e);for(;t;){if(Wt(Y.join(t,".git")))return t;let r=Y.dirname(t);if(r===t)return"";
|
|
645
|
+
t=r}return""}function ql(){let e=Zi(),t="";try{t=Y.join(e,Y.basename(Vl(Y.join(e,Fl))))}catch{return""}return Wt(Y.join(
|
|
646
|
+
t,"modules-2"))?t:""}function es(e){let t=Wl(e);if(!t)return{};let r=Y.join(t,Xi);if(!Wt(Y.join(r,Qi)))return{};let n=ql();
|
|
647
|
+
return{GRADLE_USER_HOME:r,...n?{GRADLE_RO_DEP_CACHE:n}:{}}}function ts(e){let t=String(e.GRADLE_USER_HOME||"");if(!t.endsWith(
|
|
648
|
+
`/${Xi}`)||Wt(Y.join(t,Qi)))return e;let{GRADLE_USER_HOME:r,GRADLE_RO_DEP_CACHE:n,...o}=e;return n&&!String(n).startsWith(
|
|
649
|
+
`${Zi()}/`)?{...o,GRADLE_RO_DEP_CACHE:n}:o}import rs from"node:path";var _n="NPM_CONFIG_PREFIX";function ns({env:e={}}={}){return j()?v(e[_n])||(v(e.HOME)?rs.join(v(e.HOME),".local"):""):""}
|
|
650
|
+
function os(e={}){let t=ns(e);return t?{[_n]:t}:{}}function is(e={}){let t=ns(e);return t?[rs.join(t,"bin")]:[]}function wn(e=""){let t=G().loginEnvironment;if(!t)return{env:{},path:[]};let r=String(e||"");if(!/^[a-z_][a-z0-9_-]{0,31}$/u.
|
|
644
651
|
test(r))throw new TypeError(`The host's tool homes need a command's login; "${r}" is not one.`);let n=o=>o.replaceAll("%\
|
|
645
|
-
u",r);return{env:Object.fromEntries(Object.entries(t.env).map(([o,i])=>[o,n(i)])),path:t.path.map(n)}}import{existsSync as
|
|
646
|
-
map(E).filter(Boolean)}function
|
|
647
|
-
try{return
|
|
648
|
-
function
|
|
649
|
-
String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:
|
|
650
|
-
|
|
651
|
-
".bun/bin"].map(o=>
|
|
652
|
-
PATH),...
|
|
653
|
-
/usr/lib/postgresql/${t}/bin`),...
|
|
654
|
-
map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function
|
|
655
|
-
shimDirs:o=[]}){return
|
|
656
|
-
...
|
|
657
|
-
_RUNTIME_DIR"]),
|
|
658
|
-
return e.envPolicy==="staging"||e.purpose==="staging"||e.stagingAccount?{}:{APP_ENV:"development"}}function
|
|
659
|
-
purpose==="preview"?{NODE_ENV:"development"}:{}}function
|
|
660
|
-
"object"&&!Array.isArray(e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!
|
|
661
|
-
!t.startsWith("GIT_")&&!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function
|
|
662
|
-
project?.stagingEnv,e.project?.staging?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function
|
|
663
|
-
e).reduce((t,r)=>e.envPolicy==="staging"?(
|
|
664
|
-
"staging"?[]:t.envPolicy==="project"?
|
|
665
|
-
t.filter(n=>
|
|
666
|
-
/(.)\/+$/u,"$1"))).join(":")}function
|
|
667
|
-
n.runtimes.join(":"):"",i=
|
|
668
|
-
path:[]}:
|
|
669
|
-
|
|
670
|
-
d=
|
|
671
|
-
runtimes,shimDirs:n.shimDirs||[]}),p=u.path.length?
|
|
672
|
-
function
|
|
673
|
-
personGitIdentity,project:r.project,session:r.session,userKey:r.userKey}}async function
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
"
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
652
|
+
u",r);return{env:Object.fromEntries(Object.entries(t.env).map(([o,i])=>[o,n(i)])),path:t.path.map(n)}}import{existsSync as Yl,readdirSync as Kl}from"node:fs";import Jl from"node:os";import ce from"node:path";import qt from"node:process";var lt="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";function ut(e=""){return String(e||"").split(":").
|
|
653
|
+
map(E).filter(Boolean)}function as(e=[]){return e.filter(t=>{try{return Yl(t)}catch{return!1}})}function ss(e="",t=/^$/u){
|
|
654
|
+
try{return Kl(e).filter(r=>t.test(r)).sort((r,n)=>Number(/\d+/u.exec(n)?.[0]||0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}
|
|
655
|
+
function Xl(e){if(j())return[];let t=String(e.HOME||Jl.homedir()||"");if(!ce.isAbsolute(t))return[];let r=ce.isAbsolute(
|
|
656
|
+
String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:ce.join(t,".local/share"),n=ce.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:
|
|
657
|
+
ce.join(r,"mise");return as([ce.join(t,".local/bin"),ce.join(n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",
|
|
658
|
+
".bun/bin"].map(o=>ce.join(t,o))])}function Ql(){if(j())return[];let e=["/opt/homebrew","/usr/local"];return[...ut(qt.env.
|
|
659
|
+
PATH),...qt.platform==="darwin"?["/opt/homebrew/bin"]:[],...as([...ss("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`\
|
|
660
|
+
/usr/lib/postgresql/${t}/bin`),...qt.platform==="darwin"?e.flatMap(t=>[...ss(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).
|
|
661
|
+
map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function cs({env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],
|
|
662
|
+
shimDirs:o=[]}){return ye([...ut(o.join(":")),...pn(),...n.flatMap(i=>dn(i)),...Gi(),...ut(t||(r?"":e.PATH)),...Xl(qt.env),
|
|
663
|
+
...ut(r),...Ql(),...ut(lt)]).join(":")}var ed=new Set([...st,Te,Se,Ae,Oe,"HOME","LOGNAME","PATH","USER","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG\
|
|
664
|
+
_RUNTIME_DIR"]),td=new Set(["APP_ENV","NODE_ENV"]),rd="AUTH_";function nd(e){return td.has(e)||e.startsWith(rd)}function od(e={}){
|
|
665
|
+
return e.envPolicy==="staging"||e.purpose==="staging"||e.stagingAccount?{}:{APP_ENV:"development"}}function id(e={}){return e.
|
|
666
|
+
purpose==="preview"?{NODE_ENV:"development"}:{}}function sd(e={}){return Object.fromEntries(Object.entries(e&&typeof e==
|
|
667
|
+
"object"&&!Array.isArray(e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!ed.has(t)&&!nd(t)&&
|
|
668
|
+
!t.startsWith("GIT_")&&!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function bn(e={}){return e.envPolicy==="staging"?[e.
|
|
669
|
+
project?.stagingEnv,e.project?.staging?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function ad(e={}){return bn(
|
|
670
|
+
e).reduce((t,r)=>e.envPolicy==="staging"?(Ge(r),{...t,...q(r)}):{...t,...Ft(r,e)},{})}function cd(e={},t={}){return t.envPolicy===
|
|
671
|
+
"staging"?[]:t.envPolicy==="project"?bn(t):[e,...bn(t),t.project?.databaseEnv,t.session?.databaseEnv]}function ud(e,t){let r=new Set(
|
|
672
|
+
t.filter(n=>yn.isAbsolute(String(n||""))).map(n=>yn.join(n,".local","bin")));return e.split(":").filter(n=>!r.has(n.replace(
|
|
673
|
+
/(.)\/+$/u,"$1"))).join(":")}function us({actor:e={},baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?
|
|
674
|
+
n.runtimes.join(":"):"",i=Vi(),s=Ft(n.env,n),a=String(t.XDG_RUNTIME_DIR||"").trim(),c=rt(e.user),u=e.stagingAccount?{env:{},
|
|
675
|
+
path:[]}:wn(c.USER),l=ts({...c,...sd(t),...u.env,...De(e)&&yn.isAbsolute(a)?{XDG_RUNTIME_DIR:a}:{},...id(n),...Bt(...cd(
|
|
676
|
+
t,n)),...ad(n),...Ji({actor:e,request:n}),...es(n.cwd),...s,...zi({actor:e,request:n}),...i,...od(n)}),m={...l,...os({env:l}),
|
|
677
|
+
VIBE64_DECLARED_RUNTIMES:o},d=cs({env:m,existingPath:[...new Set([...u.path,...is({env:m})]),m.PATH].filter(Boolean).join(
|
|
678
|
+
":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.shimDirs||[]}),p=u.path.length?ud(d,[m.HOME,Zl.homedir()]):d;return{
|
|
679
|
+
...m,PATH:p,...j()?{}:{VIBE64_TOOL_PATH:p}}}function ls({actor:e={},baseEnv:t,request:r={}},n){return{actor:e,env:t,gitConfig:{
|
|
680
|
+
cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.userKey}}async function ds(e){
|
|
681
|
+
let t=us(e);return{...t,...await Di(ls(e,t))}}function En(e){let t=us(e);return{...t,...e.resolvedGitIdentityEnv||Ui(ls(
|
|
682
|
+
e,t))}}import{randomUUID as Pd}from"node:crypto";import{mkdirSync as Cd,writeFileSync as kd}from"node:fs";import Cn from"node:path";import Sd from"node:crypto";import{createRequire as Td}from"node:module";import{Buffer as ld}from"node:buffer";var ps=256*1024,dd=300,Yt=100,Kt=28;var ay=600*1e3,pd=1440*60*1e3,cy=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "});function ms(){return{code:"\
|
|
683
|
+
terminal_session_not_found",error:"Terminal session not found.",ok:!1}}function ue(e=""){return String(e||"default").trim()||
|
|
684
|
+
"default"}var fs=new Map;function Jt(e){let t=String(e||""),r=t.length;for(let n=0;n<dd&&(r=t.lastIndexOf(`
|
|
685
|
+
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>ps&&(t=t.slice(t.length-ps)),t}function dt(e={}){return e.status===
|
|
686
|
+
"running"||e.status==="closing"}function vn(e={}){return dt(e)||e.status==="exited"}function hs(e,t){try{return t(le(e))===
|
|
687
|
+
!0}catch{return!1}}function md(e=0){let t=Math.floor(Number(e||0));return Number.isFinite(t)&&t>0?t:0}function fd(e="",t={}){
|
|
688
|
+
let{outputLimit:r=0}=t,n=String(e||""),o=md(r);return!o||n.length<=o?{output:n,outputTruncated:!1}:{output:n.slice(n.length-
|
|
689
|
+
o),outputTruncated:!0}}function le(e,t={}){let r=fd(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||Yt,
|
|
682
690
|
createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exitCode,inputVersion:e.inputVersion||0,lastInputAt:e.
|
|
683
691
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
684
692
|
metadata:e.metadata||{},output:r.output,outputTruncated:r.outputTruncated,outputVersion:e.outputVersion||0,rows:e.rows||
|
|
685
|
-
|
|
686
|
-
max(
|
|
687
|
-
if(e.subscribers?.size)return 0;let r=
|
|
688
|
-
(clearTimeout(e.detachedCleanupTimer),e.detachedCleanupTimer=null)}function
|
|
689
|
-
metadata:e.metadata,type:"metadata"}),
|
|
690
|
-
e.lastOutputBytes=r)}function
|
|
691
|
-
delete(r)}}function
|
|
692
|
-
function
|
|
693
|
+
Kt,status:e.status}}function gs(e=""){return ld.byteLength(String(e||""),"utf8")}function pt(e=0){let t=Math.floor(Number(e));return!Number.isFinite(t)||t<0?0:Math.min(t,pd)}function hd(e={}){return Math.
|
|
694
|
+
max(je(e.lastSubscriberDetachedAt),je(e.lastInputAt),je(e.lastOutputAt),je(e.createdAt))}function Sn(e={},t=Date.now()){
|
|
695
|
+
if(e.subscribers?.size)return 0;let r=hd(e);return r>0?Math.max(0,Number(t)-r):0}function Xt(e={}){e.detachedCleanupTimer&&
|
|
696
|
+
(clearTimeout(e.detachedCleanupTimer),e.detachedCleanupTimer=null)}function _s(e,t={}){return!e||!t||typeof t!="object"||Array.isArray(t)?le(e):(e.metadata={...e.metadata||{},...t},ne(e,{
|
|
697
|
+
metadata:e.metadata,type:"metadata"}),le(e))}function ws(e,t=""){let r=gs(t);r<1||(e.outputVersion=Number(e.outputVersion||0)+1,e.lastOutputAt=new Date().toISOString(),
|
|
698
|
+
e.lastOutputBytes=r)}function ne(e,t){if(e?.subscribers?.size)for(let r of[...e.subscribers])try{r(t)}catch{e.subscribers.
|
|
699
|
+
delete(r)}}function gd(e){let t=String(e?.code||""),r=String(e?.message||e||"Terminal PTY error.");return{code:t,message:r}}
|
|
700
|
+
function ys(e,t){if(!e)return;let r=gd(t);e.lastWriteErrorAt=new Date().toISOString(),e.lastWriteErrorCode=r.code,e.lastWriteError=
|
|
693
701
|
r.message,console.warn("Vibe64 terminal PTY write error.",{code:r.code,id:e.id,metadata:e.metadata||{},message:r.message,
|
|
694
|
-
namespace:e.namespace||""}),
|
|
695
|
-
!t||typeof t.on!="function"||t.on("error",r=>{
|
|
702
|
+
namespace:e.namespace||""}),ne(e,{code:r.code,error:r.message,type:"error"})}function bs(e){let t=e?.terminal?._writeStream;
|
|
703
|
+
!t||typeof t.on!="function"||t.on("error",r=>{ys(e,r)})}function Es(e,t,r=t){let n=`\r
|
|
696
704
|
[studio] ${r}\r
|
|
697
|
-
`;e.closeError=t,e.output=
|
|
705
|
+
`;e.closeError=t,e.output=Jt(`${e.output}${n}`),ne(e,{chunk:n,type:"output"}),ne(e,{error:t,type:"error"})}async function vs(e,{
|
|
698
706
|
code:t,flag:r,hook:n,label:o,payload:i}){if(e[r])return null;e[r]=!0;try{return await e[n](i),null}catch(s){let a=String(
|
|
699
|
-
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,
|
|
707
|
+
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,Es(e,a,`${o}: ${a}`),c}}function Ie(e,t){let r=`${String(
|
|
700
708
|
t?.code||"terminal_cleanup_failed")}:${String(t?.message||"")}`;return e.reportedLifecycleFailures||=new Set,e.reportedLifecycleFailures.
|
|
701
|
-
has(r)||(e.reportedLifecycleFailures.add(r),
|
|
709
|
+
has(r)||(e.reportedLifecycleFailures.add(r),Es(e,String(t?.message||t||"Terminal cleanup failed."))),t}function Qt(e,t=[]){
|
|
702
710
|
let r=new AggregateError(t,`Terminal session could not close cleanly: ${e.id}`);return r.code=t.some(n=>String(n?.code||
|
|
703
|
-
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function
|
|
704
|
-
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>
|
|
711
|
+
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function _d(e,t){
|
|
712
|
+
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>vs(e,{code:"terminal_stop_hook_failed",flag:"\
|
|
705
713
|
stopHookStarted",hook:"onStop",label:"Terminal stop failed",payload:{id:e.id,output:e.output,reason:t,status:e.status}}))),
|
|
706
|
-
e.stopHookCompletion}function
|
|
714
|
+
e.stopHookCompletion}function Tn(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>vs(
|
|
707
715
|
e,{code:"terminal_close_hook_failed",flag:"closeHookStarted",hook:"onClose",label:"Terminal finalization failed",payload:{
|
|
708
|
-
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function
|
|
709
|
-
"exited"&&(e.status="exited",
|
|
710
|
-
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await
|
|
716
|
+
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function On(e){e.status!==
|
|
717
|
+
"exited"&&(e.status="exited",ne(e,{closeError:e.closeError||"",exitCode:e.exitCode,status:e.status,type:"status"}))}function An(e){
|
|
718
|
+
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await Dt(e.terminal.pid)){
|
|
711
719
|
let t=new Error(`Terminal execution scope did not become empty: ${e.id}`);throw t.code="terminal_execution_drain_failed",
|
|
712
|
-
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function
|
|
713
|
-
|
|
720
|
+
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function Ss(e){try{await e.scopeDrainCompletion}catch(t){
|
|
721
|
+
Ie(e,t)}try{await Promise.all([Tn(e,e.stopReason||"exit"),e.stopHookCompletion])}catch(t){Ie(e,t)}On(e)}async function In(e,t="\
|
|
714
722
|
stop"){if(!e||e.processExited)return{failures:[]};e.stopReason||=String(t||"stop"),e.status==="running"&&(e.status="clos\
|
|
715
|
-
ing",
|
|
723
|
+
ing",ne(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(_d(e,e.stopReason),!e.processExited&&!e.killStarted){
|
|
716
724
|
e.killStarted=!0;try{e.terminal.kill()}catch(n){e.killStarted=!1;let o=n instanceof Error?n:new Error(String(n||"Termina\
|
|
717
|
-
l process could not be killed."));o.code||="terminal_kill_failed",r.push(
|
|
718
|
-
n))}return{failures:r}}var
|
|
719
|
-
ok:!1}:null}var
|
|
720
|
-
get(t)}function
|
|
721
|
-
"");return[...
|
|
722
|
-
let n=e?[
|
|
723
|
-
return o}function
|
|
724
|
-
let n=Math.max(0,r-
|
|
725
|
-
let{namespace:r="default"}=t,n=
|
|
726
|
-
let s=[];if(
|
|
727
|
-
s.push(
|
|
728
|
-
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&
|
|
725
|
+
l process could not be killed."));o.code||="terminal_kill_failed",r.push(Ie(e,o))}}try{await An(e)}catch(n){r.push(Ie(e,
|
|
726
|
+
n))}return{failures:r}}var wd=new Map;function yd(e="default"){return wd.get(ue(e))||null}function Ts(e="default"){let t=yd(e);return t?{code:t.code,error:t.error,
|
|
727
|
+
ok:!1}:null}var Re=new Map;function He(e){return Re.get(ue(e))||fs}function Os(e){let t=ue(e);return Re.has(t)||Re.set(t,new Map),Re.
|
|
728
|
+
get(t)}function As(e,t,r){e.delete(r);let n=ue(t);e.size<1&&Re.get(n)===e&&Re.delete(n)}function bd(e=""){let t=String(e||
|
|
729
|
+
"");return[...Re.keys()].filter(r=>r.startsWith(t))}function Zt({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){
|
|
730
|
+
let n=e?[ue(e)]:bd(t),o=[];for(let i of n){let s=He(i);for(let a of s.values())r&&!dt(a)||o.push({namespace:i,session:a})}
|
|
731
|
+
return o}function er(e={},t="default"){if(Xt(e),!vn(e)||e.subscribers?.size)return;let r=pt(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
732
|
+
let n=Math.max(0,r-Sn(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,Ed({namespace:t})},n)}async function Rn(e,t={}){
|
|
733
|
+
let{namespace:r="default"}=t,n=He(r),o=n.get(e);if(!o)return{ok:!0,closed:!1};if(o.closePromise)return o.closePromise;let i=(async()=>{
|
|
734
|
+
let s=[];if(Xt(o),!o.processExited){let u=await In(o,"close");if(u.failures.length)throw Qt(o,u.failures)}try{await o.exitCompletion}catch(u){
|
|
735
|
+
s.push(Ie(o,u))}try{await o.scopeDrainCompletion}catch(u){s.push(Ie(o,u))}let c=(await Promise.all([o.stopHookCompletion,
|
|
736
|
+
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&On(o),s.length>0)throw Qt(o,[...s,...c]);return As(n,r,e),{
|
|
729
737
|
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(u=>String(u?.message||u))}:{}}})();o.closePromise=i;try{return await i}finally{
|
|
730
|
-
o.closePromise===i&&(o.closePromise=null)}}async function
|
|
731
|
-
let n=
|
|
732
|
-
function
|
|
733
|
-
fault",namespaceLimitPrefix:c="",runningLimitFilter:u=
|
|
734
|
-
let g=
|
|
735
|
-
F)&&S(F)):null;if(A)return
|
|
738
|
+
o.closePromise===i&&(o.closePromise=null)}}async function Ed({namespace:e}){for(let{namespace:t,session:r}of Zt({namespace:e})){if(!vn(r)||r.subscribers?.size)continue;
|
|
739
|
+
let n=pt(r.detachedIdleTimeoutMs);if(!(n<1)){if(Sn(r)<n){er(r,t);continue}await Rn(r.id,{namespace:t})}}}var vd=new URL("./../../../vibe64-execution/src/server/engines/terminalSessions.js",import.meta.url).href;function Pn(){}
|
|
740
|
+
function Od(){return!0}var Ad=Td(vd);function Id({filter:e,namespacePrefix:t}){return Zt({namespacePrefix:t,runningOnly:!0}).filter(r=>hs(r.session,e)).length}function Is({args:e,command:t,commandPreview:r,cwd:n=process.cwd(),env:o={},maxRunning:i=0,metadata:s={},namespace:a="de\
|
|
741
|
+
fault",namespaceLimitPrefix:c="",runningLimitFilter:u=Od,onClose:l=Pn,onOutput:m=Pn,onStop:d=Pn,reuseRunning:p=!1,detachedIdleTimeoutMs:f=0}){
|
|
742
|
+
let g=Ts(a);if(g)return g;let w=He(a),_=Sd.randomUUID(),S=typeof p=="function"?p:()=>!!p,A=p?[...w.values()].find(F=>dt(
|
|
743
|
+
F)&&S(F)):null;if(A)return le(A);let I=Number(i||0),P=c||a;if(I>0&&Id({filter:u,namespacePrefix:P})>=I)return{ok:!1,code:"\
|
|
736
744
|
terminal_limit",error:`Terminal limit reached (${I}).`};let T=typeof o=="function"?o({id:_,namespace:a}):o,C=typeof e=="\
|
|
737
|
-
function"?e({env:T,id:_,namespace:a}):e,N=typeof r=="function"?r({args:C,env:T,id:_,namespace:a}):r,
|
|
738
|
-
n"?s({args:C,env:T,id:_,namespace:a}):s,
|
|
739
|
-
|
|
740
|
-
toISOString(),cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:
|
|
741
|
-
lastSubscriberDetachedAt:new Date().toISOString(),metadata:
|
|
745
|
+
function"?e({env:T,id:_,namespace:a}):e,N=typeof r=="function"?r({args:C,env:T,id:_,namespace:a}):r,Q=typeof s=="functio\
|
|
746
|
+
n"?s({args:C,env:T,id:_,namespace:a}):s,br=Ad("node-pty").spawn(t,C,{cols:Yt,cwd:n,env:M(T),name:"xterm-color",rows:Kt}),
|
|
747
|
+
to,Ja=new Promise(F=>{to=F}),k={id:_,closeHookCompletion:null,closePromise:null,commandPreview:N,cols:Yt,createdAt:new Date().
|
|
748
|
+
toISOString(),cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:pt(f),exitCompletion:Ja,exitCode:null,lastSubscriberAttachedAt:"",
|
|
749
|
+
lastSubscriberDetachedAt:new Date().toISOString(),metadata:Q&&typeof Q=="object"&&!Array.isArray(Q)?Q:{},onClose:l,onStop:d,
|
|
742
750
|
inputVersion:0,lastInputAt:"",lastInputBytes:0,lastOutputAt:"",lastOutputBytes:0,lastWriteError:"",lastWriteErrorAt:"",lastWriteErrorCode:"",
|
|
743
|
-
output:"",outputVersion:0,processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:
|
|
744
|
-
status:"running",stopHookCompletion:null,scopeDrainCompletion:null,namespace:a,subscribers:new Set,
|
|
745
|
-
k),
|
|
746
|
-
type:"output"});try{m({chunk:F,output:k.output,session:
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
r).get(e);return i?
|
|
751
|
-
is required for real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=
|
|
752
|
-
|
|
753
|
-
.json`)}function
|
|
754
|
-
let u=
|
|
755
|
-
env:typeof a=="function"?a(c):a,input:e.input,operation:
|
|
756
|
-
`,{mode:384}),["-n",
|
|
757
|
-
command:e.command,cwd:n,env:a}}async function
|
|
758
|
-
{},{onClose:a=
|
|
751
|
+
output:"",outputVersion:0,processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:to,rows:Kt,
|
|
752
|
+
status:"running",stopHookCompletion:null,scopeDrainCompletion:null,exitSettledCompletion:null,namespace:a,subscribers:new Set,
|
|
753
|
+
terminal:br};return bs(k),br.onData(F=>{ws(k,F),k.output=Jt(k.output+F),ne(k,{chunk:F,lastOutputAt:k.lastOutputAt,outputVersion:k.
|
|
754
|
+
outputVersion,type:"output"});try{m({chunk:F,output:k.output,session:le(k),updateMetadata(Et){return _s(k,Et)}})}catch(Et){
|
|
755
|
+
let Xa=String(Et?.message||Et||"Terminal output hook failed.");ne(k,{error:Xa,type:"error"})}er(k,a)}),br.onExit(({exitCode:F})=>{
|
|
756
|
+
k.processExited=!0,k.exitCode=F,k.status="closing",An(k),ne(k,{exitCode:F,status:k.status,type:"status"}),Tn(k,k.stopReason||
|
|
757
|
+
"exit"),k.resolveExitCompletion(),k.exitSettledCompletion=Ss(k)}),Os(a).set(_,k),er(k,a),Rd(_,{namespace:a})}function Rd(e,t={}){
|
|
758
|
+
let{namespace:r="default",outputLimit:n=0}=t,i=He(r).get(e);return i?le(i,{outputLimit:n}):ms()}function Nd(){}var Rs=new Map;function xd(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root\
|
|
759
|
+
is required for real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=Cn.join(
|
|
760
|
+
Cn.resolve(t),"exec-helper-payloads");return Cd(r,{mode:448,recursive:!0}),Cn.join(r,`${process.pid}-${Date.now()}-${Pd()}\
|
|
761
|
+
.json`)}function $d(e,t){let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return Ht(r)?{args:(c={})=>{
|
|
762
|
+
let u=xd(s.helperPayloadRoot),l=typeof e.args=="function"?e.args(c):e.args,m=Gt({actor:r,args:l,command:e.command,cwd:n,
|
|
763
|
+
env:typeof a=="function"?a(c):a,input:e.input,operation:it(e)});return kd(u,`${JSON.stringify(m)}
|
|
764
|
+
`,{mode:384}),["-n",rn(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||lt}}:{args:e.args,
|
|
765
|
+
command:e.command,cwd:n,env:a}}async function Ps(e={},t={}){let{actor:r,cwd:n,env:o,resolveEnv:i}=t;try{let s=e.terminal||
|
|
766
|
+
{},{onClose:a=Nd}=s,c=e.execution?.id||"",u=$d(e,{actor:r,cwd:n,env:o,resolveEnv:i}),l=Is({args:u.args,command:u.command,
|
|
759
767
|
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
760
768
|
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async m=>{try{await a(m)}finally{
|
|
761
|
-
c&&
|
|
762
|
-
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&
|
|
769
|
+
c&&Rs.set(c,{id:m.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
770
|
+
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&Rs.set(c,{id:l.id,namespace:s.namespace}),l?.ok===!0?{...l,
|
|
763
771
|
execution:e.execution}:l}catch(s){return L(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
764
|
-
{execution:e.execution})}}import{realpathSync as
|
|
765
|
-
isArray(r)?r:[r]).map(v).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>
|
|
766
|
-
let c=
|
|
767
|
-
code="vibe64_command_cwd_outside_allowed_roots",a}import{randomUUID as
|
|
772
|
+
{execution:e.execution})}}import{realpathSync as Cs}from"node:fs";function Md(e=""){return v(e||process.cwd())}function ks(e="",t={}){let{allowedRoots:r=[],resolveLinks:n=!0}=t,o=Md(e),i=(Array.
|
|
773
|
+
isArray(r)?r:[r]).map(v).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>ae(c,o));if(s.length>0){if(!n)return o;
|
|
774
|
+
let c=Cs(o);if(s.some(u=>ae(Cs(u),c)))return c}let a=new Error("Vibe64 command cwd is outside the allowed roots.");throw a.
|
|
775
|
+
code="vibe64_command_cwd_outside_allowed_roots",a}import{randomUUID as Ld}from"node:crypto";var jd=Object.freeze(["daemon","owner-user","named-user","app"]),Dd=/^[a-z_][a-z0-9_-]{0,31}$/u,Ud=Object.freeze(["accou\
|
|
768
776
|
nt","assistant","terminal","codex","github","github-api","source-editor","preview","output","staging","health","workspac\
|
|
769
|
-
e-cache","source"]),
|
|
770
|
-
["session","project","preview","auth","staging"]),
|
|
771
|
-
["assistant","browser","control","job","preview","service","terminal"]),
|
|
772
|
-
e"])
|
|
773
|
-
vibe64_command_request_invalid"){let r=new Error(e||"Invalid Vibe64 command request.");return r.code=t,r}function
|
|
774
|
-
value"){let o=E(e)||r;if(!t.includes(o))throw
|
|
775
|
-
_unsupported`);return o}function
|
|
777
|
+
e-cache","source"]),Gd=Object.freeze(["capture","pty","detached"]),Hd=Object.freeze(["utf8","base64"]),Bd=Object.freeze(
|
|
778
|
+
["session","project","preview","auth","staging"]),Vd=Object.freeze(["none","github-https","github-token"]),zd=Object.freeze(
|
|
779
|
+
["assistant","browser","control","job","preview","service","terminal"]),Fd=Object.freeze(["finite","interactive","servic\
|
|
780
|
+
e"]),Wd=1e3*1e3*100,qd=new Set(["assistant","codex","staging","output","preview","source","terminal"]);function H(e="",t="\
|
|
781
|
+
vibe64_command_request_invalid"){let r=new Error(e||"Invalid Vibe64 command request.");return r.code=t,r}function de(e="",t=[],r="",n="\
|
|
782
|
+
value"){let o=E(e)||r;if(!t.includes(o))throw H(`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}\
|
|
783
|
+
_unsupported`);return o}function Yd(e=[],t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw H("Fu\
|
|
776
784
|
nction-valued command args are only supported for PTY commands.","vibe64_command_args_function_requires_pty");return e}return(Array.
|
|
777
|
-
isArray(e)?e:[e]).map(n=>String(n??""))}function
|
|
778
|
-
pty")throw
|
|
779
|
-
return{env:{},envFactory:e}}let n=q(e);return
|
|
780
|
-
[e]).map(v).filter(Boolean)}function
|
|
785
|
+
isArray(e)?e:[e]).map(n=>String(n??""))}function Kd(e={},t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="\
|
|
786
|
+
pty")throw H("Function-valued command env is only supported for PTY commands.","vibe64_command_env_function_requires_pty");
|
|
787
|
+
return{env:{},envFactory:e}}let n=q(e);return Ge(n),{env:n,envFactory:null}}function kn(e=[]){return(Array.isArray(e)?e:
|
|
788
|
+
[e]).map(v).filter(Boolean)}function Jd(e={}){let t=M(e);return{commandPreview:t.commandPreview,detachedIdleTimeoutMs:t.
|
|
781
789
|
detachedIdleTimeoutMs,helperPayloadRoot:v(t.helperPayloadRoot),maxRunning:t.maxRunning,metadata:t.metadata,namespace:E(t.
|
|
782
790
|
namespace),namespaceLimitPrefix:E(t.namespaceLimitPrefix),onClose:t.onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.
|
|
783
|
-
reuseRunning,runningLimitFilter:t.runningLimitFilter}}function
|
|
791
|
+
reuseRunning,runningLimitFilter:t.runningLimitFilter}}function Xd(e={}){let t=M(e),r=v(t.home||t.toolHomeSource);return r?
|
|
784
792
|
{cacheRoot:v(t.cacheRoot),configRoot:v(t.configRoot),dataRoot:v(t.dataRoot),gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?
|
|
785
793
|
Number(t.gid??t.hostGid):null,home:r,scope:E(t.scope),stateRoot:v(t.stateRoot),uid:Number.isSafeInteger(Number(t.uid??t.
|
|
786
|
-
hostUid))?Number(t.uid??t.hostUid):null,username:E(t.username||t.ownerUserKey||t.userKey)}:{}}function
|
|
787
|
-
"detached"?"service":e==="pty"?"interactive":"finite"}function
|
|
788
|
-
"preview"?"preview":e==="pty"?"terminal":"job"}function
|
|
789
|
-
test(t))throw
|
|
790
|
-
let{mode:r="capture",project:n={},purpose:o="terminal",session:i={}}=t,s=M(e),a=
|
|
791
|
-
cution_kind"),c=
|
|
792
|
-
tive"||r==="capture"&&c!=="finite")throw
|
|
793
|
-
ecution_lifecycle_incompatible");let u=
|
|
794
|
+
hostUid))?Number(t.uid??t.hostUid):null,username:E(t.username||t.ownerUserKey||t.userKey)}:{}}function Qd(e="capture"){return e===
|
|
795
|
+
"detached"?"service":e==="pty"?"interactive":"finite"}function Zd({mode:e="capture",purpose:t="terminal"}={}){return t===
|
|
796
|
+
"preview"?"preview":e==="pty"?"terminal":"job"}function Be(e=""){let t=E(e);if(!t)return"";if(!/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,254}[A-Za-z0-9])?$/u.
|
|
797
|
+
test(t))throw H(`Invalid Vibe64 execution identifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function xs(e={},t={}){
|
|
798
|
+
let{mode:r="capture",project:n={},purpose:o="terminal",session:i={}}=t,s=M(e),a=de(s.kind,zd,Zd({mode:r,purpose:o}),"exe\
|
|
799
|
+
cution_kind"),c=de(s.lifecycle,Fd,Qd(r),"execution_lifecycle");if(r==="detached"&&c!=="service"||r==="pty"&&c!=="interac\
|
|
800
|
+
tive"||r==="capture"&&c!=="finite")throw H(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_ex\
|
|
801
|
+
ecution_lifecycle_incompatible");let u=Be(s.ownerId||i.sessionId);if(c==="service"&&!u)throw H("Service execution requir\
|
|
794
802
|
es a durable owner id.","vibe64_execution_owner_required");let l=s.resourceProfile;if(l!=null&&(!l||typeof l!="object"||
|
|
795
803
|
Object.keys(l).some(m=>!["key","compatibilityKey","environment"].includes(m))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(l.key||
|
|
796
|
-
"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||"")||!["development","test","staging"].includes(l.environment)))throw
|
|
804
|
+
"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||"")||!["development","test","staging"].includes(l.environment)))throw H(
|
|
797
805
|
"Invalid activity resource profile identity.","vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.
|
|
798
|
-
freeze({...l})}:{},controlGenerationId:
|
|
799
|
-
""?{}:{workflowId:
|
|
800
|
-
parentExecutionId:
|
|
801
|
-
i.sessionId)})}function
|
|
802
|
-
test(e))throw
|
|
803
|
-
return
|
|
804
|
-
e,"runtimes"),n=
|
|
805
|
-
map(E).filter(Boolean))}function
|
|
806
|
-
nd_required");let n=
|
|
807
|
-
throw
|
|
808
|
-
t.env,{mode:n}),s=
|
|
806
|
+
freeze({...l})}:{},controlGenerationId:Be(s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===
|
|
807
|
+
""?{}:{workflowId:ep(s.workflowId)},id:Ld(),kind:a,label:E(s.label),lifecycle:c,operationId:Be(s.operationId),ownerId:u,
|
|
808
|
+
parentExecutionId:Be(s.parentExecutionId),projectSlug:Be(s.projectSlug||n.slug||n.projectSlug),sessionId:Be(s.sessionId||
|
|
809
|
+
i.sessionId)})}function ep(e){if(typeof e!="string"||!/^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/iu.
|
|
810
|
+
test(e))throw H("Execution requires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function tp(e=""){
|
|
811
|
+
return qd.has(e)?ln:[]}function Ns(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function rp(e={},t=""){let r=Ns(
|
|
812
|
+
e,"runtimes"),n=Ns(e,"runtime");if(!r&&!n)return ye(tp(t));let o=r?e.runtimes:e.runtime;return ye((Array.isArray(o)?o:[o]).
|
|
813
|
+
map(E).filter(Boolean))}function $s(e={}){let t=M(e),r=E(t.command);if(!r)throw H("A command is required.","vibe64_comma\
|
|
814
|
+
nd_required");let n=de(t.mode,Gd,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))
|
|
815
|
+
throw H("Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=q(t.baseEnv),i=Kd(
|
|
816
|
+
t.env,{mode:n}),s=de(t.purpose,Ud,"terminal","purpose"),a=rp(t,s);for(let f of a)if(!Object.hasOwn(Ue,f))throw H(`Unsupp\
|
|
809
817
|
orted Vibe64 runtime: ${f}.`,"vibe64_command_runtime_unsupported");let c=M(t.project),u=M(t.session),l=t.stagingEnvironmentFile??
|
|
810
818
|
"";if(typeof l!="string"||l&&(!l.startsWith("/")||/[\r\n\0]/u.test(l)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="st\
|
|
811
|
-
aging"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw
|
|
819
|
+
aging"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw H("Staging environment files require a fin\
|
|
812
820
|
ite staging command without caller Env.","vibe64_command_staging_environment_invalid");let m=t.usageRecordingPreload??"";
|
|
813
821
|
if(typeof m!="string"||m&&(!m.startsWith("/")||/[\s"'\\\0]/u.test(m)||!["preview","output"].includes(s)||t.actor==="app"))
|
|
814
|
-
throw
|
|
815
|
-
reload_invalid");let d=t.stagingAccount??"";if(typeof d!="string"||d&&(!
|
|
822
|
+
throw H("A usage recording preload belongs only to a Preview or Output target launch.","vibe64_command_usage_recording_p\
|
|
823
|
+
reload_invalid");let d=t.stagingAccount??"";if(typeof d!="string"||d&&(!Dd.test(d)||t.actor!=="app"||n!=="capture"))throw H(
|
|
816
824
|
"Staging accounts run only finite application commands.","vibe64_command_staging_account_invalid");let p=t.sandboxAllowances??
|
|
817
825
|
[];if(!Array.isArray(p)||p.some(f=>typeof f!="string"||!/^[a-z][a-z0-9-]*$/u.test(f))||new Set(p).size!==p.length||p.length>
|
|
818
|
-
0&&!d)throw
|
|
819
|
-
nvalid");return{actor:
|
|
820
|
-
baseEnv:o,command:r,cwd:v(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:
|
|
821
|
-
"env_policy"),stagingEnvironmentFile:l,sandboxAllowances:[...p],execution:
|
|
822
|
-
credentialHome:
|
|
823
|
-
email:E(t.personGitIdentity?.email),name:E(t.personGitIdentity?.name)},gitTransport:
|
|
826
|
+
0&&!d)throw H("Sandbox allowances belong only to a staging account's own commands.","vibe64_command_sandbox_allowances_i\
|
|
827
|
+
nvalid");return{actor:de(t.actor,jd,"daemon","actor"),stagingAccount:d,allowedRoots:kn(t.allowedRoots),args:Yd(t.args,{mode:n}),
|
|
828
|
+
baseEnv:o,command:r,cwd:v(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:de(t.envPolicy,Bd,"session",
|
|
829
|
+
"env_policy"),stagingEnvironmentFile:l,sandboxAllowances:[...p],execution:xs(t.execution,{mode:n,project:c,purpose:s,session:u}),
|
|
830
|
+
credentialHome:Xd(t.credentialHome),gitAuthToken:E(t.gitAuthToken),gitSafeDirectories:kn(t.gitSafeDirectories),personGitIdentity:{
|
|
831
|
+
email:E(t.personGitIdentity?.email),name:E(t.personGitIdentity?.name)},gitTransport:de(t.gitTransport,Vd,"none","git_tra\
|
|
824
832
|
nsport"),inheritProcessEnv:!l&&t.inheritProcessEnv!==!1,input:t.input,logPath:v(t.logPath),maxBuffer:Number.isSafeInteger(
|
|
825
|
-
Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer)
|
|
826
|
-
null,outputEncoding:
|
|
827
|
-
null,shimDirs:
|
|
828
|
-
0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:E(t.userKey)}}var
|
|
829
|
-
var
|
|
830
|
-
|
|
831
|
-
_modules/@local/vibe64-usage-recording/runtime/node")),
|
|
832
|
-
|
|
833
|
-
startsWith(`${r}${
|
|
834
|
-
of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}function
|
|
833
|
+
Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):Wd,mode:n,onOutput:typeof t.onOutput=="function"?t.onOutput:
|
|
834
|
+
null,outputEncoding:de(t.outputEncoding,Hd,"utf8","output_encoding"),project:c,purpose:s,runtimes:a,session:u,signal:t.signal??
|
|
835
|
+
null,shimDirs:kn(t.shimDirs),terminal:Jd(t.terminal),timeout:Number.isSafeInteger(Number(t.timeout))&&Number(t.timeout)>
|
|
836
|
+
0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:E(t.userKey)}}var ab=Object.freeze({normalizeExecutionDescriptor:xs});var np=null,Ms="VIBE64_MANAGED_EXECUTION_REQUIRED";function Nn(){return np}function tr(e){return["1","true"].includes(String(e[Ms]||"").trim().toLowerCase())}import{realpathSync as Ls,statSync as ip}from"node:fs";import pe from"node:path";import{fileURLToPath as sp}from"node:url";
|
|
837
|
+
var op=new URL("./../../../vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href;function ap(e){let t=[
|
|
838
|
+
pe.resolve(pe.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=pe.dirname(e);t.push(pe.join(r,"node\
|
|
839
|
+
_modules/@local/vibe64-usage-recording/runtime/node")),pe.dirname(r)!==r;r=pe.dirname(r));return t.flatMap(r=>{try{return[
|
|
840
|
+
Ls(r)]}catch{return[]}})}function js(e="",t=sp(op)){try{if(pe.resolve(e)===e&&Ls(e)===e&&ip(e).isFile()&&ap(t).some(r=>e.
|
|
841
|
+
startsWith(`${r}${pe.sep}`)))return`--import=${e}`}catch{}throw Object.assign(new Error("The usage recorder is not part \
|
|
842
|
+
of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}function Ds(e){return e.stagingEnvironmentFile?L("Staging environment execution requires a managed host.","vibe64_stagin\
|
|
835
843
|
g_environment_unavailable",{execution:e.execution}):e.stagingAccount?L("Staging account execution requires a managed hos\
|
|
836
|
-
t.","vibe64_staging_account_unavailable",{execution:e.execution}):null}async function
|
|
837
|
-
requiresHelper:i,resolveEnv:s}=t,a=
|
|
838
|
-
o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?
|
|
839
|
-
mode==="detached"?r.requiresRealUser&&(!
|
|
840
|
-
is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):
|
|
841
|
-
|
|
842
|
-
outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:
|
|
844
|
+
t.","vibe64_staging_account_unavailable",{execution:e.execution}):null}async function cp(e,t={}){let{actor:r,cwd:n,env:o,
|
|
845
|
+
requiresHelper:i,resolveEnv:s}=t,a=Ds(e);if(a)return a;if(e.usageRecordingPreload){let c=js(e.usageRecordingPreload),u=s;
|
|
846
|
+
o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?Ps(e,{actor:r,cwd:n,env:o,resolveEnv:s}):e.
|
|
847
|
+
mode==="detached"?r.requiresRealUser&&(!De(r)||i)?L("Detached real-user command execution is unsupported when the helper\
|
|
848
|
+
is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):ci(e,{actor:r,cwd:n,env:o}):i?{...await nn(
|
|
849
|
+
Gt({actor:r,args:e.args,command:e.command,cwd:n,env:o,input:e.input,operation:it(e)}),{env:process.env,maxBuffer:e.maxBuffer,
|
|
850
|
+
outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:Ee(e.command,e.args,{cwd:n,env:o,
|
|
843
851
|
execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,onOutput:e.onOutput,outputEncoding:e.outputEncoding,signal:e.signal,
|
|
844
|
-
timeout:e.timeout})}async function x(e={}){let t=null;try{if(t
|
|
845
|
-
be64_command_cancelled",{execution:t.execution});let r=await
|
|
846
|
-
...t.baseEnv},o=(_={})=>({..._,VIBE64_EXECUTION_ID:t.execution.id}),i=
|
|
847
|
-
|
|
848
|
-
stagingEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Se,
|
|
849
|
-
t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.stagingAccount});
|
|
850
|
-
args(_):t.args,f=(_={})=>o(t.envFactory?
|
|
851
|
-
_),envFactory:null}}):l),g=(_=t,S={})=>
|
|
852
|
-
runCommand(t,{actor:r,baseEnv:n,cwd:d,env:l,resolveArgs:p,resolveEnv:f,runLocal:g});let w=
|
|
852
|
+
timeout:e.timeout})}async function x(e={}){let t=null;try{if(t=$s(e),t.signal?.aborted)return L("Command cancelled.","vi\
|
|
853
|
+
be64_command_cancelled",{execution:t.execution});let r=await hi(t),n=t.inheritProcessEnv?{...process.env,...t.baseEnv}:{
|
|
854
|
+
...t.baseEnv},o=(_={})=>({..._,VIBE64_EXECUTION_ID:t.execution.id}),i=Nn(),s=tr(n)||tr(process.env),a=Ht(r),u=!(!!i||s||
|
|
855
|
+
on())&&De(r)?[n.PATH,process.env.PATH].filter(Boolean).join(":"):"",l=o(await ds({actor:r,baseEnv:n,localPath:u,request:t.
|
|
856
|
+
stagingEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Te,Se,Ae,Oe].map(_=>[_,l[_]]));wi(r,l);let d=ks(
|
|
857
|
+
t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.stagingAccount});_i(r,t,d);let p=(_={})=>typeof t.args=="function"?t.
|
|
858
|
+
args(_):t.args,f=(_={})=>o(t.envFactory?En({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:m,request:{...t,env:t.envFactory(
|
|
859
|
+
_),envFactory:null}}):l),g=(_=t,S={})=>cp(_,{actor:r,cwd:d,env:l,requiresHelper:a,resolveEnv:f,...S});if(i)return await i.
|
|
860
|
+
runCommand(t,{actor:r,baseEnv:n,cwd:d,env:l,resolveArgs:p,resolveEnv:f,runLocal:g});let w=Ds(t);return w||(s?L("Managed \
|
|
853
861
|
execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unavailable",{execution:t.
|
|
854
862
|
execution,retryable:!1}):g())}catch(r){return L(r?.message||"Vibe64 command failed.",r?.code||"vibe64_command_failed",{execution:t?.
|
|
855
|
-
execution})}}import{createHash as
|
|
856
|
-
import
|
|
857
|
-
ed","completed","failed","interrupted"]),
|
|
863
|
+
execution})}}import{createHash as lp}from"node:crypto";import{lstat as Hs,mkdir as dp,mkdtemp as pp,readdir as mp,rm as Bs,statfs as fp}from"node:fs/promises";
|
|
864
|
+
import K from"node:path";import{fileURLToPath as hp}from"node:url";var up=new URL("./../../../vibe64-execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,gp=3e4;var Hb=hp(new URL("./gitTurnCheckpointCommand.js",up)),_p=15*6e4,wp=512*1024*1024,yp=1024*1024*1024,Vs=new Set(["cancell\
|
|
865
|
+
ed","completed","failed","interrupted"]),rr=new Map;async function mt({outerTurnId:e="",outcome:t="completed",project:r={},
|
|
858
866
|
runCommand:n,sessionId:o="",temporaryDiskBudgetBytes:i,temporaryDiskReserveBytes:s,timestamp:a="",worktreePath:c=""}={}){
|
|
859
|
-
let u=
|
|
860
|
-
project:r,refs:l,runCommand:n,temporaryDiskBudgetBytes:i,temporaryDiskReserveBytes:s}))}async function
|
|
861
|
-
let s=await
|
|
862
|
-
refs:r,runCommand:n});let a=await z(n,e.worktreePath,["rev-parse","--verify","HEAD"],{project:t}),c=await
|
|
863
|
-
project:t,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:e.worktreePath}),u=await
|
|
864
|
-
e.worktreePath,{project:t});for(let l=0;;l+=1){let m=await
|
|
865
|
-
d=m||a,p=await z(n,e.worktreePath,["commit-tree",c,"-p",d],{env:
|
|
867
|
+
let u=Op({outerTurnId:e,outcome:t,sessionId:o,timestamp:a,worktreePath:c}),l=xn(u);return Fs(u.worktreePath,()=>bp({identity:u,
|
|
868
|
+
project:r,refs:l,runCommand:n,temporaryDiskBudgetBytes:i,temporaryDiskReserveBytes:s}))}async function bp({identity:e={},project:t={},refs:r={},runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i}={}){
|
|
869
|
+
let s=await Ve(n,e.worktreePath,["rev-parse","--verify",r.turnRef],{project:t});if(s)return Gs({commit:s,identity:e,project:t,
|
|
870
|
+
refs:r,runCommand:n});let a=await z(n,e.worktreePath,["rev-parse","--verify","HEAD"],{project:t}),c=await zs({baseCommit:a,
|
|
871
|
+
project:t,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:e.worktreePath}),u=await Js(n,
|
|
872
|
+
e.worktreePath,{project:t});for(let l=0;;l+=1){let m=await Ve(n,e.worktreePath,["rev-parse","--verify",r.latestRef],{project:t}),
|
|
873
|
+
d=m||a,p=await z(n,e.worktreePath,["commit-tree",c,"-p",d],{env:Ap(e.timestamp),input:Ks(e),project:t});try{await z(n,e.
|
|
866
874
|
worktreePath,["update-ref","--stdin"],{input:`start
|
|
867
875
|
create ${r.turnRef} ${p}
|
|
868
876
|
update ${r.latestRef} ${p} ${m||u}
|
|
869
877
|
prepare
|
|
870
878
|
commit
|
|
871
|
-
`,project:t})}catch(f){let g=await
|
|
872
|
-
identity:e,project:t,refs:r,runCommand:n});let w=await
|
|
879
|
+
`,project:t})}catch(f){let g=await Ve(n,e.worktreePath,["rev-parse","--verify",r.turnRef],{project:t});if(g)return Gs({commit:g,
|
|
880
|
+
identity:e,project:t,refs:r,runCommand:n});let w=await Ve(n,e.worktreePath,["rev-parse","--verify",r.latestRef],{project:t});
|
|
873
881
|
if(l>=2||w===m)throw f;continue}return{baseCommit:d,commit:p,created:!0,latestRef:r.latestRef,ok:!0,outerTurnId:e.outerTurnId,
|
|
874
|
-
outcome:e.outcome,sessionId:e.sessionId,tree:c,turnRef:r.turnRef}}}async function
|
|
875
|
-
runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=
|
|
876
|
-
ePath"));return
|
|
877
|
-
worktreePath:a}))}async function
|
|
878
|
-
temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=
|
|
879
|
-
bsolute-git-dir"],{project:r}),u=
|
|
880
|
-
join(u,".tree-")),m=
|
|
881
|
-
let p=Array.isArray(t)?t.map(f=>String(f||"")).filter(Boolean):[];return await
|
|
882
|
+
outcome:e.outcome,sessionId:e.sessionId,tree:c,turnRef:r.turnRef}}}async function ee({baseCommit:e="HEAD",paths:t=[],project:r={},
|
|
883
|
+
runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=K.resolve(Pe(s,"worktre\
|
|
884
|
+
ePath"));return Fs(a,()=>zs({baseCommit:e,paths:t,project:r,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,
|
|
885
|
+
worktreePath:a}))}async function zs({baseCommit:e="HEAD",paths:t=[],project:r={},runCommand:n,temporaryDiskBudgetBytes:o,
|
|
886
|
+
temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=K.resolve(Pe(s,"worktreePath")),c=await z(n,a,["rev-parse","--a\
|
|
887
|
+
bsolute-git-dir"],{project:r}),u=K.join(c,"vibe64-checkpoints");await dp(u,{recursive:!0}),await Ep(u);let l=await pp(K.
|
|
888
|
+
join(u,".tree-")),m=K.join(l,"index");try{let d={GIT_INDEX_FILE:m};await z(n,a,["read-tree",e||"HEAD"],{env:d,project:r});
|
|
889
|
+
let p=Array.isArray(t)?t.map(f=>String(f||"")).filter(Boolean):[];return await vp({gitDirectory:c,paths:p,project:r,runCommand:n,
|
|
882
890
|
temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:a}),await z(n,a,["add","-A","--",...p.length>0?p:["."]],
|
|
883
|
-
{env:{...d,GIT_LITERAL_PATHSPECS:"1"},project:r}),await z(n,a,["write-tree"],{env:d,project:r})}finally{await
|
|
884
|
-
recursive:!0})}}async function
|
|
885
|
-
isDirectory()&&n.name.startsWith(".tree-")).map(async n=>{let o=
|
|
886
|
-
t-i.mtimeMs>
|
|
887
|
-
Promise.resolve()).catch(()=>null).then(t),i=o.then(()=>null,()=>null).finally(()=>{
|
|
888
|
-
set(r,i),o}async function
|
|
891
|
+
{env:{...d,GIT_LITERAL_PATHSPECS:"1"},project:r}),await z(n,a,["write-tree"],{env:d,project:r})}finally{await Bs(l,{force:!0,
|
|
892
|
+
recursive:!0})}}async function Ep(e=""){let t=Date.now(),r=await mp(e,{withFileTypes:!0});await Promise.all(r.filter(n=>n.
|
|
893
|
+
isDirectory()&&n.name.startsWith(".tree-")).map(async n=>{let o=K.join(e,n.name),i=await Hs(o).catch(()=>null);i?.isDirectory()&&
|
|
894
|
+
t-i.mtimeMs>_p&&await Bs(o,{force:!0,recursive:!0})}))}function Fs(e="",t=async()=>null){let r=K.resolve(e),o=(rr.get(r)||
|
|
895
|
+
Promise.resolve()).catch(()=>null).then(t),i=o.then(()=>null,()=>null).finally(()=>{rr.get(r)===i&&rr.delete(r)});return rr.
|
|
896
|
+
set(r,i),o}async function vp({gitDirectory:e="",paths:t=[],project:r={},runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,
|
|
889
897
|
worktreePath:s=""}={}){let a=t.length>0?t:["."],[c,u,l]=await Promise.all([z(n,s,["diff","--name-only","-z","HEAD","--",
|
|
890
|
-
...a],{project:r}),z(n,s,["ls-files","--others","--exclude-standard","-z","--",...a],{project:r}),
|
|
891
|
-
[...
|
|
892
|
-
|
|
893
|
-
invalid");let C=await
|
|
894
|
-
0),path:T})}let p=d.reduce((I,
|
|
895
|
-
l.bavail)*Number(l.bsize)),S=Math.min(g,Math.max(0,_-w));if(f<=S)return;let A=d.sort((I,
|
|
896
|
-
|
|
898
|
+
...a],{project:r}),z(n,s,["ls-files","--others","--exclude-standard","-z","--",...a],{project:r}),fp(e)]),m=[...new Set(
|
|
899
|
+
[...Us(c),...Us(u)])],d=[];for(let I of m){let P=K.resolve(s,I),T=K.relative(s,P);if(T===".."||T.startsWith(`..${K.sep}`)||
|
|
900
|
+
K.isAbsolute(T))throw Ce("Git returned a checkpoint candidate outside the session source.","vibe64_checkpoint_candidate_\
|
|
901
|
+
invalid");let C=await Hs(P).catch(N=>N?.code==="ENOENT"?null:Promise.reject(N));C?.isFile()&&d.push({bytes:Number(C.size||
|
|
902
|
+
0),path:T})}let p=d.reduce((I,P)=>I+P.bytes,0),f=Math.min(Number.MAX_SAFE_INTEGER,p*2),g=Sp(o),w=Tp(i),_=Math.max(0,Number(
|
|
903
|
+
l.bavail)*Number(l.bsize)),S=Math.min(g,Math.max(0,_-w));if(f<=S)return;let A=d.sort((I,P)=>P.bytes-I.bytes||I.path.localeCompare(
|
|
904
|
+
P.path)).slice(0,5).map(I=>`${I.path} (${I.bytes} bytes)`).join(", ");throw Ce([`Vibe64 refused this checkpoint because \
|
|
897
905
|
changed, unignored files may need about ${f} temporary bytes; the safe budget is ${S} bytes.`,A?`Largest candidates: ${A}\
|
|
898
906
|
.`:"","Keep needed files in place and add generated or local-only artifacts to .gitignore, or ask an operator to review \
|
|
899
|
-
the checkpoint disk budget."].filter(Boolean).join(" "),"vibe64_checkpoint_disk_budget_exceeded")}function
|
|
900
|
-
e||"").split("\0").filter(Boolean)}function
|
|
901
|
-
|
|
902
|
-
e===""?t:e,i=Number(o===void 0||o===""?r:o);return Number.isSafeInteger(i)&&i>=n?i:r}async function
|
|
903
|
-
project:r={},refs:n={},runCommand:o}={}){let i=await z(o,t.worktreePath,["show","-s","--format=%B",e],{project:r}),s=[...
|
|
904
|
-
find(u=>i===
|
|
907
|
+
the checkpoint disk budget."].filter(Boolean).join(" "),"vibe64_checkpoint_disk_budget_exceeded")}function Us(e=""){return String(
|
|
908
|
+
e||"").split("\0").filter(Boolean)}function Sp(e){return Ws(e,process.env.VIBE64_CHECKPOINT_TEMPORARY_DISK_BUDGET_BYTES,
|
|
909
|
+
wp,1)}function Tp(e){return Ws(e,process.env.VIBE64_CHECKPOINT_DISK_RESERVE_BYTES,yp,0)}function Ws(e,t,r,n){let o=e==null||
|
|
910
|
+
e===""?t:e,i=Number(o===void 0||o===""?r:o);return Number.isSafeInteger(i)&&i>=n?i:r}async function Gs({commit:e="",identity:t={},
|
|
911
|
+
project:r={},refs:n={},runCommand:o}={}){let i=await z(o,t.worktreePath,["show","-s","--format=%B",e],{project:r}),s=[...Vs].
|
|
912
|
+
find(u=>i===Ks({...t,outcome:u}).trim());if(!s)throw Ce("Existing Vibe64 turn checkpoint does not match its durable turn\
|
|
905
913
|
identity.","vibe64_checkpoint_identity_mismatch");let a=await z(o,t.worktreePath,["rev-parse",`${e}^{tree}`],{project:r});
|
|
906
|
-
if(!await
|
|
914
|
+
if(!await Ve(o,t.worktreePath,["rev-parse","--verify",n.latestRef],{project:r})){let u=await Js(o,t.worktreePath,{project:r});
|
|
907
915
|
await z(o,t.worktreePath,["update-ref",n.latestRef,e,u],{project:r})}return{baseCommit:await z(o,t.worktreePath,["rev-pa\
|
|
908
916
|
rse",`${e}^`],{project:r}),commit:e,created:!1,latestRef:n.latestRef,ok:!0,outerTurnId:t.outerTurnId,outcome:s,sessionId:t.
|
|
909
|
-
sessionId,tree:a,turnRef:n.turnRef}}function
|
|
910
|
-
let i=Pe(t,"outcome").toLowerCase();if(!
|
|
911
|
-
"vibe64_checkpoint_outcome_invalid");let s=Pe(n,"timestamp");if(!Number.isFinite(Date.parse(s)))throw
|
|
912
|
-
eckpoint timestamp must be an ISO date.","vibe64_checkpoint_timestamp_invalid");let a=
|
|
917
|
+
sessionId,tree:a,turnRef:n.turnRef}}function Op({outerTurnId:e="",outcome:t="completed",sessionId:r="",timestamp:n="",worktreePath:o=""}={}){
|
|
918
|
+
let i=Pe(t,"outcome").toLowerCase();if(!Vs.has(i))throw Ce(`Unsupported Vibe64 turn checkpoint outcome: ${i||"(empty)"}.`,
|
|
919
|
+
"vibe64_checkpoint_outcome_invalid");let s=Pe(n,"timestamp");if(!Number.isFinite(Date.parse(s)))throw Ce("Vibe64 turn ch\
|
|
920
|
+
eckpoint timestamp must be an ISO date.","vibe64_checkpoint_timestamp_invalid");let a=K.resolve(Pe(o,"worktreePath"));return{
|
|
913
921
|
outerTurnId:Pe(e,"outerTurnId"),outcome:i,sessionId:Pe(r,"sessionId"),timestamp:new Date(s).toISOString(),worktreePath:a}}
|
|
914
|
-
function
|
|
915
|
-
return`refs/vibe64/checkpoints/${
|
|
916
|
-
function
|
|
922
|
+
function xn(e={}){let t=qs(e.sessionId),r=Ys(e.outerTurnId);return{latestRef:`${t}/latest`,turnRef:`${t}/${r}`}}function qs(e=""){
|
|
923
|
+
return`refs/vibe64/checkpoints/${Ys(e)}`}function Ys(e=""){return lp("sha256").update(String(e)).digest("hex").slice(0,32)}
|
|
924
|
+
function Ks(e={}){return[`vibe64 checkpoint: session ${e.sessionId} turn ${e.outerTurnId}`,"","Vibe64-Checkpoint: true",
|
|
917
925
|
`Vibe64-Session: ${e.sessionId}`,`Vibe64-Outer-Turn: ${e.outerTurnId}`,`Vibe64-Turn-Outcome: ${e.outcome}`,""].join(`
|
|
918
|
-
`)}function
|
|
919
|
-
e,t,["rev-parse","--show-object-format"],{project:n});return"0".repeat(o==="sha256"?64:40)}async function
|
|
920
|
-
let o=await
|
|
921
|
-
r,n);if(o.ok!==!0)throw
|
|
922
|
-
"vibe64_checkpoint_git_failed");return String(o.stdout||"").trim()}function
|
|
926
|
+
`)}function Ap(e=""){return{GIT_AUTHOR_DATE:e,GIT_COMMITTER_DATE:e}}async function Js(e,t,r={}){let{project:n={}}=r,o=await Ve(
|
|
927
|
+
e,t,["rev-parse","--show-object-format"],{project:n});return"0".repeat(o==="sha256"?64:40)}async function Ve(e,t,r,n={}){
|
|
928
|
+
let o=await Xs(e,t,r,n);return o.ok===!0?String(o.stdout||"").trim():""}async function z(e,t,r,n={}){let o=await Xs(e,t,
|
|
929
|
+
r,n);if(o.ok!==!0)throw Ce(String(o.stderr||o.stdout||o.output||o.error||"Git checkpoint command failed.").trim(),o.code||
|
|
930
|
+
"vibe64_checkpoint_git_failed");return String(o.stdout||"").trim()}function Xs(e,t,r,n={}){let{env:o={},input:i,project:s={}}=n;
|
|
923
931
|
return e({actor:"daemon",allowedRoots:[t],args:r,command:"git",cwd:t,env:o,envPolicy:"session",gitSafeDirectories:[t],input:i,
|
|
924
|
-
mode:"capture",project:s,purpose:"source",runtimes:["git"],timeout:
|
|
925
|
-
trim(),n=Array.from(r).some(o=>{let i=o.codePointAt(0);return i<=31||i===127});if(!r||r.length>512||n)throw
|
|
932
|
+
mode:"capture",project:s,purpose:"source",runtimes:["git"],timeout:gp})}function Pe(e="",t="value"){let r=String(e||"").
|
|
933
|
+
trim(),n=Array.from(r).some(o=>{let i=o.codePointAt(0);return i<=31||i===127});if(!r||r.length>512||n)throw Ce(`Vibe64 t\
|
|
926
934
|
urn checkpoint ${t} is invalid.`,`vibe64_checkpoint_${t.replaceAll(/[^A-Za-z0-9]+/gu,"_").toLowerCase()}_invalid`);return r}
|
|
927
|
-
function
|
|
928
|
-
|
|
929
|
-
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),
|
|
935
|
+
function Ce(e="",t="vibe64_checkpoint_failed"){let r=new Error(e||"Vibe64 turn checkpoint failed.");return r.code=t,r}var zb=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"]);import{existsSync as Ip}from"node:fs";import nr from"node:path";import Qs from"node:process";var Zs="You'll be asked for your computer password. Nothing shows while you type.",Rp="curl -fsSL https://mise.run | sh",
|
|
936
|
+
Xb=Object.freeze({linux:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-linux.md",darwin:"\
|
|
937
|
+
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),or=Object.freeze({claude:{
|
|
930
938
|
name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://claude.ai/i\
|
|
931
939
|
nstall.sh | bash"},codex:{name:"Codex",run:[["codex"]],guideUrl:"https://github.com/openai/codex",any:"curl -fsSL https:\
|
|
932
940
|
//chatgpt.com/codex/install.sh | sh"},opencode:{name:"opencode",run:[["opencode"]],guideUrl:"https://opencode.ai/docs/",
|
|
@@ -950,23 +958,23 @@ rl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -fsSL https
|
|
|
950
958
|
ild tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/install_ruby\
|
|
951
959
|
_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"sudo apt i\
|
|
952
960
|
nstall build-essential pkg-config libyaml-dev libssl-dev zlib1g-dev libpq-dev default-libmysqlclient-dev libgmp-dev",brew:"\
|
|
953
|
-
brew install pkg-config libyaml openssl@3 gmp"}}),
|
|
954
|
-
trim();return
|
|
955
|
-
return[...String(e.PATH||"").split(
|
|
956
|
-
r,"apt-get")))}function
|
|
957
|
-
r)})}function
|
|
958
|
-
it","cpp"].includes(
|
|
959
|
-
(s=n?`mise use -g ${i.mise}`:`${
|
|
960
|
-
r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?
|
|
961
|
-
function
|
|
962
|
-
`)}function
|
|
961
|
+
brew install pkg-config libyaml openssl@3 gmp"}}),Pp=Object.freeze({composer:"php"});function $n(e=""){let t=String(e||"").
|
|
962
|
+
trim();return Pp[t]||t}function ea({platform:e=Qs.platform,aptGet:t=!1}={}){return e==="darwin"?"brew":t?"apt":""}function Cp(e,t=lt){
|
|
963
|
+
return[...String(e.PATH||"").split(nr.delimiter),...String(t||"").split(nr.delimiter)].some(r=>nr.isAbsolute(r)&&Ip(nr.join(
|
|
964
|
+
r,"apt-get")))}function ir({env:e,platform:t=Qs.platform,systemPath:r}){return ea({platform:t,aptGet:t!=="darwin"&&Cp(e,
|
|
965
|
+
r)})}function sr(e="",t={}){let{family:r="",mise:n=!1,xcode:o=!0}=t,i=or[$n(e)];if(!i)return null;if(r==="brew"&&!o&&["g\
|
|
966
|
+
it","cpp"].includes($n(e)))return{command:"xcode-select --install",sudo:!1,note:""};let s=i.any||i[r]||"";if(!s&&i.mise&&
|
|
967
|
+
(s=n?`mise use -g ${i.mise}`:`${Rp} && ~/.local/bin/mise use -g ${i.mise}`),!s)return null;let a=s.startsWith("sudo ")||
|
|
968
|
+
r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?Zs:""}}var Qb=Object.freeze({SUDO_NOTE:Zs,localToolFamily:ea});function ta({env:e,platform:t,systemPath:r}){return sr("git",{family:ir({env:e,platform:t,systemPath:r})})?.command||""}
|
|
969
|
+
function kp(e={}){return[e.error,e.stderr,e.output].filter(Boolean).join(`
|
|
970
|
+
`)}function Np(e,t){let r=kp(e);if(/spawn(?:Sync)? git ENOENT|(?:^|\s)git: (?:command )?not found/mu.test(r)){let n=ta(t);
|
|
963
971
|
return{code:"vibe64_git_missing",installCommand:n,message:n?`Git isn't installed on this computer. Install it with: ${n}`:
|
|
964
972
|
"Git isn't installed on this computer. Install Git, then try again."}}return/unknown option [`']initial-branch/u.test(r)?
|
|
965
|
-
{code:"vibe64_git_too_old",installCommand:
|
|
973
|
+
{code:"vibe64_git_too_old",installCommand:ta(t),message:"This Git is too old for Vibe64. Update Git to version 2.28 or n\
|
|
966
974
|
ewer, then try again."}:/gpg failed to sign|failed to sign the data|signing failed|couldn't (?:load|find) (?:public )?key|incorrect passphrase/iu.
|
|
967
975
|
test(r)?{code:"vibe64_git_signing_failed",installCommand:"",message:"Your Git is set to sign every commit, and signing d\
|
|
968
976
|
idn't work here. Vibe64 can't type a key passphrase for you. Make one signed commit in a terminal to check your key work\
|
|
969
|
-
s and is unlocked, then try again."}:null}var
|
|
977
|
+
s and is unlocked, then try again."}:null}var tE=Object.freeze({describeGitFailure:Np});import ra from"node:path";var na="backups.git",oa="vibe64-atomic",$p=`backup_canonical_ref() {
|
|
970
978
|
vibe64_backup_repository="$1"
|
|
971
979
|
vibe64_source_repository="$2"
|
|
972
980
|
vibe64_source_ref="$3"
|
|
@@ -984,13 +992,13 @@ r "$vibe64_backup_repository" rev-parse --verify "$vibe64_backup_ref"
|
|
|
984
992
|
' "$vibe64_source_ref" >&2
|
|
985
993
|
return 1
|
|
986
994
|
fi
|
|
987
|
-
}`,
|
|
995
|
+
}`,sE=`#!/bin/sh
|
|
988
996
|
set -eu
|
|
989
997
|
|
|
990
998
|
zero_object=0000000000000000000000000000000000000000
|
|
991
999
|
git_dir="$(git rev-parse --absolute-git-dir)"
|
|
992
1000
|
repository_root="$(dirname "$git_dir")"
|
|
993
|
-
backup_repository="$repository_root/${
|
|
1001
|
+
backup_repository="$repository_root/${na}"
|
|
994
1002
|
if [ -L "$repository_root" ] || [ -L "$backup_repository" ] || [ -L "$repository_root/mutation.lock" ]; then
|
|
995
1003
|
printf '[vibe64] Canonical repository storage must not use symlinked role paths.
|
|
996
1004
|
' >&2
|
|
@@ -999,7 +1007,7 @@ fi
|
|
|
999
1007
|
exec 8>"$repository_root/mutation.lock"
|
|
1000
1008
|
flock -x 8
|
|
1001
1009
|
|
|
1002
|
-
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${
|
|
1010
|
+
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${oa}" ]; then
|
|
1003
1011
|
printf '[vibe64] Canonical repository pushes must use the Vibe64 atomic mutation path.
|
|
1004
1012
|
' >&2
|
|
1005
1013
|
exit 1
|
|
@@ -1010,7 +1018,7 @@ if [ "$(git --git-dir "$backup_repository" rev-parse --is-bare-repository 2>/dev
|
|
|
1010
1018
|
exit 1
|
|
1011
1019
|
fi
|
|
1012
1020
|
|
|
1013
|
-
${
|
|
1021
|
+
${$p}
|
|
1014
1022
|
|
|
1015
1023
|
updates_file="$(mktemp "$repository_root/.pre-receive.XXXXXX")"
|
|
1016
1024
|
cleanup_updates_file() {
|
|
@@ -1058,7 +1066,7 @@ while read -r old_object _new_object ref_name; do
|
|
|
1058
1066
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
1059
1067
|
fi
|
|
1060
1068
|
done <"$updates_file"
|
|
1061
|
-
`,
|
|
1069
|
+
`,ia=`set -euo pipefail
|
|
1062
1070
|
mirror_path="$1"
|
|
1063
1071
|
remote_url="$2"
|
|
1064
1072
|
|
|
@@ -1146,8 +1154,8 @@ case "$remote_head_ref" in
|
|
|
1146
1154
|
esac
|
|
1147
1155
|
printf '[studio] Refreshed GitHub mirror for %s.
|
|
1148
1156
|
' "$remote_url"
|
|
1149
|
-
`;function
|
|
1150
|
-
freeze({CANONICAL_REPOSITORY_PUSH_OPTION:
|
|
1157
|
+
`;function Mp(e=""){return e?ra.join(ra.dirname(e),na):""}function Mn({mirrorPath:e="",remoteUrl:t=""}={}){return["bash","-c",ia,"vibe64-github-mirror-refresh",e,t]}var aE=Object.
|
|
1158
|
+
freeze({CANONICAL_REPOSITORY_PUSH_OPTION:oa,canonicalRepositoryBackupPath:Mp});var wE=new URL("./../../../vibe64-execution/src/server/runtime/agentPreviewBrowserWorkerSource.js",import.meta.url).href;var jp=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms>]"," vibe64\
|
|
1151
1159
|
-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [--json]"," v\
|
|
1152
1160
|
ibe64-helper preview open <path> [--json]"," vibe64-helper preview inspect-url"," vibe64-helper preview screenshot [--\
|
|
1153
1161
|
output <path>]"," vibe64-helper preview browser ensure"," vibe64-helper preview browser eval < playwright-code.js"," \
|
|
@@ -1180,379 +1188,381 @@ cation endpoint in diagnostics bypasses Preview identity; do not use it for inte
|
|
|
1180
1188
|
s page between browser commands. After each command the page keeps running for 30 seconds, then pauses (no timers, anima\
|
|
1181
1189
|
tions or network handling) until the next browser command. For a longer wait, wait inside the command, for example with \
|
|
1182
1190
|
await page.waitForSelector(...).","Five minutes after the last browser command ends, the browser closes; the next comman\
|
|
1183
|
-
d opens a fresh page, so select its identity again if needed.","
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1191
|
+
d opens a fresh page, so select its identity again if needed.","ensure/restart --wait waits for the run it started and f\
|
|
1192
|
+
ollows a newer run of the same target that replaced it to readiness; it fails at once when that run exits, or goes with \
|
|
1193
|
+
nothing of its target in its place.","Managed Playwright suites and live preview browser actions are sequential. Wait on\
|
|
1194
|
+
the suite through cleanup and restoration before browser actions or Preview ensure/restart/target changes; confirm play\
|
|
1195
|
+
wright status has no active run and preview status is ready. Read-only status and logs are safe during a suite.","For ba\
|
|
1196
|
+
ckground commands, wait on the existing execution/session with about a 30-second window where supported: set yield_time_\
|
|
1197
|
+
ms: 30000 for an empty command poll. Reserve shorter waits for interactive input or a specific immediate check; do not r\
|
|
1198
|
+
epeatedly reread empty or unchanged logs between brief waits.","This is the canonical preview server for the configured \
|
|
1199
|
+
primary application.","Do not start a duplicate copy of that application on another port.","A distinct secondary applica\
|
|
1200
|
+
tion explicitly requested by the user, such as a reference app, may run separately without replacing this preview."].join(
|
|
1201
|
+
`
|
|
1192
1202
|
`)+`
|
|
1193
|
-
`;import{fileURLToPath as
|
|
1194
|
-
engines/stdioBridge.js",
|
|
1203
|
+
`;import{fileURLToPath as Bp}from"node:url";var Hp=new URL("./../../../vibe64-execution/src/server/conversationExecution.js",import.meta.url).href,PE=Bp(new URL("./\
|
|
1204
|
+
engines/stdioBridge.js",Hp));var ME=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$name" 2>/dev/null) || continue',
|
|
1195
1205
|
" case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /usr/bin/*) continue ;; esac; fi',
|
|
1196
1206
|
` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1197
|
-
`);var
|
|
1198
|
-
e,Object.freeze({name:t,guideUrl:r,install:n})]})));import{execFile as
|
|
1207
|
+
`);var Vp=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,any:n}=or[e];return[
|
|
1208
|
+
e,Object.freeze({name:t,guideUrl:r,install:n})]})));import{execFile as zp}from"node:child_process";import{promisify as Fp}from"node:util";var BE=Fp(zp);import $a from"node:crypto";function sa(e,t={}){let{missingStatus:r=404}=t,n=e?.errors?.[0]?.code||e?.code||"";return n==="vibe64_session_not_found"?
|
|
1199
1209
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
1200
1210
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
1201
1211
|
64_project_source_lock_timeout"||n==="vibe64_development_database_scope_busy"||n==="vibe64_project_session_policy_lock_t\
|
|
1202
1212
|
imeout"||n==="vibe64_session_creation_limit"||n==="vibe64_workspace_setup_retry_not_available"||n==="vibe64_workspace_se\
|
|
1203
|
-
tup_running"?409:e?.ok===!1?400:200}function
|
|
1204
|
-
it","canonicalCommit"]);function
|
|
1205
|
-
e.repository?.mode)!==D){if(!
|
|
1206
|
-
.");return{...e,repository:{...e.repository,defaultBranch:s}}}return e}let n;try{n=JSON.parse(r)}catch{}let o=
|
|
1213
|
+
tup_running"?409:e?.ok===!1?400:200}function aa(e,t,r={}){let{status:n=sa({ok:!1,code:t}),...o}=r;return new re(n,e,{...o,code:t})}var J="github",ze="managed_git",D="local_source";function ar(e=""){let t=ie(e).toLowerCase().replace(/[-\s]+/gu,"_");return t===J||t===ze||t===D?t:""}function ca(e="",t=""){let r=new Error(t);return r.code=e,r}var qS=Object.freeze(["repository","branch","path","baseComm\
|
|
1214
|
+
it","canonicalCommit"]);function Ln(e,t){let r=t?.metadata?.github_pull_request;if(!r){let s=t?.metadata?.repository_branch;if(s&&ar(e.repositoryMode||
|
|
1215
|
+
e.repository?.mode)!==D){if(!ua(s))throw ca("vibe64_session_branch_invalid","This session's repository branch is invalid\
|
|
1216
|
+
.");return{...e,repository:{...e.repository,defaultBranch:s}}}return e}let n;try{n=JSON.parse(r)}catch{}let o=ie(e.githubRepository?.
|
|
1207
1217
|
fullName||e.repository?.github?.fullName);if(!n||n.baseRepository!==o||!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u.test(n.headRepository||
|
|
1208
|
-
"")||!
|
|
1218
|
+
"")||!ua(n.headBranch)||e.repositoryMode===ze)throw ca("vibe64_pull_request_authority_invalid","This session's pull requ\
|
|
1209
1219
|
est source is invalid. Its Save destination could not be verified.");let i={fullName:n.headRepository,cloneUrl:`https://\
|
|
1210
1220
|
github.com/${n.headRepository}.git`};return{...e,githubMirrorPath:n.headRepository===o?e.githubMirrorPath:"",githubRepository:i,
|
|
1211
|
-
repositoryMode:
|
|
1221
|
+
repositoryMode:J,repository:{mode:J,defaultBranch:n.headBranch,github:i}}}function ua(e){return typeof e=="string"&&e.length>
|
|
1212
1222
|
0&&e.length<=255&&!["@","HEAD"].includes(e)&&!e.startsWith("-")&&!e.endsWith(".")&&!/[\s~^:?*[\\]/u.test(e)&&!e.includes(
|
|
1213
1223
|
"..")&&!e.includes("@{")&&![...e].some(t=>t.charCodeAt(0)<32||t.charCodeAt(0)===127)&&e.split("/").every(t=>t&&!t.startsWith(
|
|
1214
|
-
".")&&!t.endsWith(".lock"))}function
|
|
1215
|
-
projectSlug,i=r.repository?.defaultBranch;return n===
|
|
1216
|
-
D&&(o=r.sourceRoot,i=t.metadata?.local_source_branch||i),{sessionId:
|
|
1217
|
-
warn:40,error:50,fatal:60,silent:1/0});function
|
|
1218
|
-
return e==="behind"||e==="diverged"?"rebase":"none"}import
|
|
1224
|
+
".")&&!t.endsWith(".lock"))}function la(e={},t={}){let r=Ln(e,t),n=ar(r.repositoryMode||r.repository?.mode),o=r.slug||r.
|
|
1225
|
+
projectSlug,i=r.repository?.defaultBranch;return n===J?o=r.githubRepository?.fullName||r.repository?.github?.fullName:n===
|
|
1226
|
+
D&&(o=r.sourceRoot,i=t.metadata?.local_source_branch||i),{sessionId:ie(t.sessionId),mode:n,repository:ie(o),branch:ie(i)}}var jn="warn";var Kp=Object.freeze(["fatal","error","warn","info","debug","trace","silent"]),da=Object.freeze({trace:10,debug:20,info:30,
|
|
1227
|
+
warn:40,error:50,fatal:60,silent:1/0});function pa(e="",t=jn){let r=String(e||"").trim().toLowerCase();return Kp.includes(r)?r:t}function Jp(e="info",t=jn){let r=pa(e,""),n=pa(t,jn);return!r||n==="silent"?!1:da[r]>=da[n]}var JS=Object.freeze({isVibe64LogLevelEnabled:Jp});function ma(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:0}function ft(e=0,t=0){let r=ma(e),n=ma(t);return r>0&&n>0?"diverged":n>0?"behind":r>0?"ahead":"current"}function ht(e=""){
|
|
1228
|
+
return e==="behind"||e==="diverged"?"rebase":"none"}import fa from"node:path";var ga="%H%x00%P%x00%an%x00%ae%x00%aI%x00%s",Dn=200,_a=500,cr=800,Zp=5e3;function wa(e=""){let t=String(e||"").split("\0"),
|
|
1219
1229
|
r=[];for(let n=0;n+5<t.length;n+=6){let o=h(t[n]);if(!o)continue;let i=h(t[n+1]).split(/\s+/u).filter(Boolean);r.push({author:h(
|
|
1220
1230
|
t[n+2]),authorEmail:h(t[n+3]),committedAt:h(t[n+4]),commit:o,isMerge:i.length>1,message:h(t[n+5]),parents:i,shortCommit:o.
|
|
1221
|
-
slice(0,8)})}return r}function
|
|
1222
|
-
min(n,r):t}function
|
|
1223
|
-
let i=/^[CR]/u.test(o)?t[n++]:"",s=t[n++];s&&r.set(s,{path:s,...i?{previousPath:i}:{},status:o.slice(0,1)})}return r}function
|
|
1224
|
-
let t=h(e);if(t==="-")return null;let r=Number.parseInt(t,10);return Number.isSafeInteger(r)&&r>=0?r:0}function
|
|
1231
|
+
slice(0,8)})}return r}function ya(e,t,r){let n=Number.parseInt(String(e??""),10);return Number.isSafeInteger(n)&&n>0?Math.
|
|
1232
|
+
min(n,r):t}function gt(e=""){let t=String(e||"").split("\0"),r=new Map;for(let n=0;n<t.length;){let o=h(t[n++]);if(!o)continue;
|
|
1233
|
+
let i=/^[CR]/u.test(o)?t[n++]:"",s=t[n++];s&&r.set(s,{path:s,...i?{previousPath:i}:{},status:o.slice(0,1)})}return r}function ha(e=""){
|
|
1234
|
+
let t=h(e);if(t==="-")return null;let r=Number.parseInt(t,10);return Number.isSafeInteger(r)&&r>=0?r:0}function em(e=""){
|
|
1225
1235
|
let t=String(e||"").split("\0"),r=new Map;for(let n=0;n<t.length;){let o=t[n++];if(!o)continue;let i=o.indexOf(" "),s=o.
|
|
1226
|
-
indexOf(" ",i+1),a=o.slice(s+1),c=!a;c&&(n+=1);let u=c?t[n++]:a;u&&r.set(u,{added:
|
|
1227
|
-
1,s))})}return r}function
|
|
1228
|
-
sort((n,o)=>n.path.localeCompare(o.path))}function
|
|
1236
|
+
indexOf(" ",i+1),a=o.slice(s+1),c=!a;c&&(n+=1);let u=c?t[n++]:a;u&&r.set(u,{added:ha(o.slice(0,i)),deleted:ha(o.slice(i+
|
|
1237
|
+
1,s))})}return r}function ba(e="",t=""){let r=em(t);return[...gt(e).values()].map(n=>({...n,...r.get(n.path)||{added:0,deleted:0}})).
|
|
1238
|
+
sort((n,o)=>n.path.localeCompare(o.path))}function Ea(e,{offset:t=0,limit:r,defaultLimit:n,maxLimit:o}){let i=ya(r,n,o),
|
|
1229
1239
|
s=Math.max(0,Number.parseInt(String(t??""),10)||0);return{items:e.slice(s,s+i),limit:i,offset:s,totalCount:e.length,truncated:s+
|
|
1230
|
-
i<e.length}}function
|
|
1240
|
+
i<e.length}}function va(e,t){let r=String(e||"").replaceAll(`\r
|
|
1231
1241
|
`,`
|
|
1232
1242
|
`).split(`
|
|
1233
|
-
`),n=
|
|
1234
|
-
`),lineLimit:n,shownLines:Math.min(r.length,n),totalLines:r.length,truncated:r.length>n}}function
|
|
1235
|
-
e||"");if(!t||t.includes("\0")||
|
|
1236
|
-
"Choose a changed project file.","vibe64_session_change_path_invalid");return t}function
|
|
1237
|
-
"\\$&");return[`:(literal)${e}`,`:(glob,exclude)${t}/**`]}import
|
|
1238
|
-
import{fileURLToPath as
|
|
1239
|
-
"object"&&!Array.isArray(r)?{...r}:{},a=new
|
|
1240
|
-
assign(a,s),a}function
|
|
1241
|
-
repositoryMode:e.mode,sessionId:e.sessionId}}function
|
|
1242
|
-
randomUUID()}=n;if(e?.[
|
|
1243
|
+
`),n=ya(t,cr,Zp);return{diff:r.slice(0,n).join(`
|
|
1244
|
+
`),lineLimit:n,shownLines:Math.min(r.length,n),totalLines:r.length,truncated:r.length>n}}function Un(e=""){let t=String(
|
|
1245
|
+
e||"");if(!t||t.includes("\0")||fa.posix.isAbsolute(t)||fa.posix.normalize(t)!==t||t===".."||t.startsWith("../"))throw aa(
|
|
1246
|
+
"Choose a changed project file.","vibe64_session_change_path_invalid");return t}function Sa(e){let t=e.replace(/[*?[\]\\]/gu,
|
|
1247
|
+
"\\$&");return[`:(literal)${e}`,`:(glob,exclude)${t}/**`]}import Oa from"node:crypto";import{mkdtemp as Aa,readdir as am,rm as Hn}from"node:fs/promises";import me from"node:path";
|
|
1248
|
+
import{fileURLToPath as cm}from"node:url";import tm from"node:crypto";import _t from"node:path";import{setTimeout as rm}from"node:timers/promises";var Gn=12e4,Ta=Symbol("vibe64-session-work-command-scope");function O(e,t,r={},n={}){let{status:o=409,...i}=n,s=r&&typeof r==
|
|
1249
|
+
"object"&&!Array.isArray(r)?{...r}:{},a=new re(o,e||"Vibe64 could not save this session.",{...i,code:t,details:s});return Object.
|
|
1250
|
+
assign(a,s),a}function B(e={},t={}){return{ownerUserKey:h(t.ownerUserKey||t.githubRepository?.owner),projectRoot:e.worktreePath,
|
|
1251
|
+
repositoryMode:e.mode,sessionId:e.sessionId}}function V(e,t={},r={},n={}){let{label:o="Session repository work",operationId:i=tm.
|
|
1252
|
+
randomUUID()}=n;if(e?.[Ta])return e;let s=h(r.slug||r.projectSlug),a=Promise.resolve(),c=(u={})=>{let l=a.then(()=>e({...u,
|
|
1243
1253
|
execution:{...u.execution||{},kind:"job",label:o,lifecycle:"finite",operationId:h(i),ownerId:t.sessionId,projectSlug:s,sessionId:t.
|
|
1244
1254
|
sessionId},project:{...u.project||{},...s?{slug:s}:{}},session:{...u.session||{},sessionId:t.sessionId}}));return a=l.then(
|
|
1245
|
-
()=>{},()=>{}),l};return Object.defineProperty(c,
|
|
1246
|
-
commandOptions:s={},cwd:a=t.worktreePath,env:c={},input:u,project:l={}}=o,m=[t.worktreePath,
|
|
1247
|
-
mode===D?[t.standaloneSourceRoot,
|
|
1248
|
-
t.remoteUrl)]:[],...i.flatMap(d=>{let p=h(d);return p?[p,
|
|
1249
|
-
command:r,cwd:a,env:c,envPolicy:"session",gitSafeDirectories:m,input:u,mode:"capture",project:
|
|
1250
|
-
startsWith("github")?"github":"source",runtimes:s.gitTransport==="github-https"?["git","gh"]:["git"],timeout:
|
|
1251
|
-
|
|
1252
|
-
let{required:o=!0,...i}=n,s=await
|
|
1255
|
+
()=>{},()=>{}),l};return Object.defineProperty(c,Ta,{value:!0}),c}async function wt(e,t,r,n,o={}){let{additionalAllowedRoots:i=[],
|
|
1256
|
+
commandOptions:s={},cwd:a=t.worktreePath,env:c={},input:u,project:l={}}=o,m=[t.worktreePath,_t.dirname(t.worktreePath),...t.
|
|
1257
|
+
mode===D?[t.standaloneSourceRoot,_t.dirname(t.standaloneSourceRoot)]:[],..._t.isAbsolute(t.remoteUrl)?[t.remoteUrl,_t.dirname(
|
|
1258
|
+
t.remoteUrl)]:[],...i.flatMap(d=>{let p=h(d);return p?[p,_t.dirname(p)]:[]})];return e({actor:"daemon",allowedRoots:m,args:n,
|
|
1259
|
+
command:r,cwd:a,env:c,envPolicy:"session",gitSafeDirectories:m,input:u,mode:"capture",project:B(t,l),purpose:s.gitTransport?.
|
|
1260
|
+
startsWith("github")?"github":"source",runtimes:s.gitTransport==="github-https"?["git","gh"]:["git"],timeout:Gn,...s})}var nm=100,
|
|
1261
|
+
om=100;function im(e){return e?.ok!==!0&&/index\.lock'?: File exists/u.test(String(e?.stderr||e?.output||""))}async function y(e,t,r,n={}){
|
|
1262
|
+
let{required:o=!0,...i}=n,s=await wt(e,t,"git",r,i);for(let a=0;a<nm&&im(s);a+=1)await rm(om),s=await wt(e,t,"git",r,i);
|
|
1253
1263
|
if(o&&s?.ok!==!0)throw O(h(s?.stderr||s?.stdout||s?.output||s?.error)||"Git Save command failed.",h(s?.code)||"vibe64_se\
|
|
1254
|
-
ssion_save_git_failed",{gitArgs:r},{status:500});return s}function
|
|
1255
|
-
return
|
|
1256
|
-
""}var
|
|
1257
|
-
be64-derived-worktree-",
|
|
1258
|
-
return e.metadata&&typeof e.metadata=="object"?e.metadata:{}}function U(e={},t={}){t
|
|
1264
|
+
ssion_save_git_failed",{gitArgs:r},{status:500});return s}function Fe(e={}){return h(e.stdout||e.output)}async function R(e,t,r,n={}){
|
|
1265
|
+
return Fe(await y(e,t,r,n))}async function ur(e,t,r,n={}){let o=await y(e,t,r,{...n,required:!1});return o?.ok===!0?Fe(o):
|
|
1266
|
+
""}var sm=new URL("./sessionWorkGit.js",import.meta.url).href,VT=cm(new URL("./sessionWorkOperationCommand.js",sm)),Ia=".vi\
|
|
1267
|
+
be64-derived-worktree-",um=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function lr(e=""){return um.test(String(e??""))}function We(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(h).filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function lm(e={}){
|
|
1268
|
+
return e.metadata&&typeof e.metadata=="object"?e.metadata:{}}function U(e={},t={}){t=Ln(t,e);let r=lm(e),n=ar(t.repositoryMode||
|
|
1259
1269
|
t.repository?.mode),o=h(t.repository?.defaultBranch);if(n===D&&r.local_source_branch&&h(r.local_source_branch)!==o)throw O(
|
|
1260
1270
|
`This session belongs to ${h(r.local_source_branch)}. Switch the project folder back to that branch before saving or upd\
|
|
1261
1271
|
ating it.`,"vibe64_session_local_branch_changed");let i=h(e.sourcePath||r.source_path),s=h(e.sessionId),a=h(r.base_commit),
|
|
1262
1272
|
c=h(r.canonical_commit)||a,u=n===D?h(t.sourceRoot):"";if(!n||!o||!i||!s||!a||n===D&&!u)throw O("Session Save requires a \
|
|
1263
1273
|
complete repository mode, branch, session source, base commit, and authority.","vibe64_session_save_context_incomplete");
|
|
1264
|
-
let l=n===
|
|
1274
|
+
let l=n===J?h(t.githubRepository?.cloneUrl||t.repository?.github?.cloneUrl):n===ze?h(t.canonicalRepositoryPath):u;if(!l)
|
|
1265
1275
|
throw O("Session Save cannot find the canonical repository authority.","vibe64_session_save_authority_missing");return Object.
|
|
1266
1276
|
freeze({baseCommit:a,branch:o,lastCanonicalCommit:c,mode:n,githubMirrorPath:h(t.githubMirrorPath),repositoryFullName:h(t.
|
|
1267
1277
|
githubRepository?.fullName||t.repository?.github?.fullName),githubMirrorOptional:!!r.github_pull_request||t.githubMirrorOptional===
|
|
1268
|
-
!0,remoteUrl:l,sessionId:s,standaloneSourceRoot:u,worktreePath:i})}async function
|
|
1269
|
-
i.stdout||i.output)}async function
|
|
1270
|
-
s))}async function
|
|
1271
|
-
i)&&i>=0?i:0}async function
|
|
1272
|
-
return r===n?!0:(await y(e,t,["merge-base","--is-ancestor",r,n],{...o,required:!1}))?.ok===!0}async function
|
|
1273
|
-
if(await
|
|
1274
|
-
async function
|
|
1275
|
-
await
|
|
1276
|
-
^{commit}`],r)]),s=n||o||i;for(let a of[o,i].filter(Boolean))a!==s&&await
|
|
1277
|
-
baseCommit:r,canonicalCommit:n,sessionHead:o,worktreeTree:i,reconcileHistory:s=!1},a={}){let[c,u]=await Promise.all([
|
|
1278
|
-
e,t,r,a),
|
|
1279
|
-
let l=s?r:await
|
|
1280
|
-
canonicalTree:u,changeBaseCommit:l,changeBaseTree:m,changedPaths:d,sessionMatchesCanonical:i===u}}async function
|
|
1281
|
-
await y(e,t,["check-ref-format","--branch",t.branch],r)}function
|
|
1282
|
-
56").update(`${e.sessionId}\0${t}`).digest("hex").slice(0,32)}/${r}`}function
|
|
1283
|
-
h(r)&&await y(e,t,["update-ref","-d",r],{...n,required:!1})}async function
|
|
1284
|
-
"--verify",`${r}^{commit}`],n);return await y(e,t,["update-ref",
|
|
1285
|
-
checkpointTree:o,commandOptions:i,project:s,virtualCommit:a="",explicitBase:c=!1}){let u=a||await
|
|
1278
|
+
!0,remoteUrl:l,sessionId:s,standaloneSourceRoot:u,worktreePath:i})}async function he(e,t,r,n,o={}){let i=await y(e,t,["diff-tree","--no-commit-id","--name-status","-r","-z",r,n],o);return gt(
|
|
1279
|
+
i.stdout||i.output)}async function dr(e,t,r,n,o={}){return[...(await he(e,t,r,n,o)).keys()].sort((i,s)=>i.localeCompare(
|
|
1280
|
+
s))}async function qe(e,t,r,n,o={}){let i=Number(await R(e,t,["rev-list","--count",`${r}..${n}`],o));return Number.isSafeInteger(
|
|
1281
|
+
i)&&i>=0?i:0}async function fe(e,t,r,n={}){return R(e,t,["rev-parse","--verify",`${r}^{tree}`],n)}async function X(e,t,r,n,o={}){
|
|
1282
|
+
return r===n?!0:(await y(e,t,["merge-base","--is-ancestor",r,n],{...o,required:!1}))?.ok===!0}async function ke(e,t,r,n,o={}){
|
|
1283
|
+
if(await X(e,t,t.baseCommit,r,o))return!1;let[i,s]=await Promise.all([X(e,t,r,n,o),X(e,t,t.baseCommit,n,o)]);return!i||s}
|
|
1284
|
+
async function pr(e,t,r={}){let[n,o,i]=await Promise.all([ur(e,t,["rev-parse","--verify",`${Ra(t)}^{commit}`],r),t.lastCanonicalCommit?
|
|
1285
|
+
await ur(e,t,["rev-parse","--verify",`${t.lastCanonicalCommit}^{commit}`],r):"",R(e,t,["rev-parse","--verify",`${t.baseCommit}\
|
|
1286
|
+
^{commit}`],r)]),s=n||o||i;for(let a of[o,i].filter(Boolean))a!==s&&await X(e,t,s,a,r)&&(s=a);return s}async function Ye(e,t,{
|
|
1287
|
+
baseCommit:r,canonicalCommit:n,sessionHead:o,worktreeTree:i,reconcileHistory:s=!1},a={}){let[c,u]=await Promise.all([fe(
|
|
1288
|
+
e,t,r,a),fe(e,t,n,a)]);if(i===u)return{baseTree:c,canonicalTree:u,changeBaseCommit:n,changeBaseTree:u,changedPaths:[],sessionMatchesCanonical:!0};
|
|
1289
|
+
let l=s?r:await R(e,t,["merge-base",n,o],a),m=l===n?u:await fe(e,t,l,a),d=i===m?[]:await dr(e,t,l,i,a);return{baseTree:c,
|
|
1290
|
+
canonicalTree:u,changeBaseCommit:l,changeBaseTree:m,changedPaths:d,sessionMatchesCanonical:i===u}}async function Ke(e,t,r){
|
|
1291
|
+
await y(e,t,["check-ref-format","--branch",t.branch],r)}function mr(e,t,r){return`refs/vibe64/save/${Oa.createHash("sha2\
|
|
1292
|
+
56").update(`${e.sessionId}\0${t}`).digest("hex").slice(0,32)}/${r}`}function fr(e,t){return mr(e,t,"prepared")}function Ra(e){return`refs/vibe64/canonical/${Oa.createHash("sha256").update(e.branch).digest("hex").slice(0,32)}`}async function yt(e,t,r,n={}){
|
|
1293
|
+
h(r)&&await y(e,t,["update-ref","-d",r],{...n,required:!1})}async function te(e,t,r,n={}){let o=await R(e,t,["rev-parse",
|
|
1294
|
+
"--verify",`${r}^{commit}`],n);return await y(e,t,["update-ref",Ra(t),o],n),o}async function Pa(e,t,{baseCommit:r,canonicalCommit:n,
|
|
1295
|
+
checkpointTree:o,commandOptions:i,project:s,virtualCommit:a="",explicitBase:c=!1}){let u=a||await hr(e,t,{baseCommit:r,commandOptions:i,
|
|
1286
1296
|
message:"Vibe64 session rebase input",project:s,tree:o}),l=await y(e,t,["merge-tree","--write-tree",...c?[`--merge-base=${r}`]:
|
|
1287
1297
|
[],"--messages","--name-only","-z",n,u],{commandOptions:i,project:s,required:!1}),m=String(l?.stdout||l?.output||"").split(
|
|
1288
|
-
"\0"),d=h(m.shift());if(!
|
|
1298
|
+
"\0"),d=h(m.shift());if(!lr(d))throw O(l?.ok===!0?"Git did not produce a valid rebased tree.":"Vibe64 could not prepare \
|
|
1289
1299
|
the conflicting files for review.","vibe64_session_update_merge_invalid");if(l?.ok!==!0){let p=[];for(;m.length>0;){let f=m.
|
|
1290
1300
|
shift();if(!f)break;p.push(f)}if(!p.length)throw O("Vibe64 could not identify which files conflict with the latest saved\
|
|
1291
1301
|
version.","vibe64_session_update_merge_invalid");return{conflictPaths:[...new Set(p)].sort((f,g)=>f.localeCompare(g)),conflictTree:d,
|
|
1292
|
-
mergedTree:"",virtualCommit:u}}return{conflictPaths:[],conflictTree:"",mergedTree:d,virtualCommit:u}}function
|
|
1293
|
-
conflictPaths:n,project:o}){return
|
|
1294
|
-
baseCommit:r,commandOptions:n,message:o,project:i,tree:s}){return
|
|
1302
|
+
mergedTree:"",virtualCommit:u}}return{conflictPaths:[],conflictTree:"",mergedTree:d,virtualCommit:u}}function Ca(e,t,{conflictTree:r,
|
|
1303
|
+
conflictPaths:n,project:o}){return ee({baseCommit:r,paths:n,project:B(t,o),runCommand:e,worktreePath:t.worktreePath})}async function hr(e,t,{
|
|
1304
|
+
baseCommit:r,commandOptions:n,message:o,project:i,tree:s}){return R(e,t,["commit-tree",s,"-p",r],{commandOptions:n,input:`${h(
|
|
1295
1305
|
o)||"Vibe64 virtual commit"}
|
|
1296
|
-
`,project:i})}async function
|
|
1297
|
-
n);if(!a.length)return s;let c=await
|
|
1306
|
+
`,project:i})}async function gr(e,t,{commandOptions:r,derivedArtifactPaths:n=[],project:o,sourceCommit:i,tree:s}){let a=We(
|
|
1307
|
+
n);if(!a.length)return s;let c=await Aa(me.join(me.dirname(t.worktreePath),".vibe64-derived-index-")),l={GIT_INDEX_FILE:me.
|
|
1298
1308
|
join(c,"index")},m={additionalAllowedRoots:[c],commandOptions:r,env:l,project:o};try{await y(e,t,["read-tree",s],m);for(let d of a){
|
|
1299
1309
|
let p=await y(e,t,["ls-tree","-z",i,"--",d],{commandOptions:r,project:o}),f=/^(\d+)\s+\S+\s+([a-f0-9]{40}|[a-f0-9]{64})\t([^\0]+)\0$/u.
|
|
1300
1310
|
exec(String(p.stdout||""));f&&f[3]===d?await y(e,t,["update-index","--add","--cacheinfo",f[1],f[2],d],m):await y(e,t,["u\
|
|
1301
|
-
pdate-index","--force-remove","--",d],{...m,required:!1})}return await
|
|
1302
|
-
recursive:!0})}}async function
|
|
1303
|
-
|
|
1304
|
-
if(!
|
|
1305
|
-
message:"Vibe64 derived artifact input",project:i,tree:a}),l=await
|
|
1311
|
+
pdate-index","--force-remove","--",d],{...m,required:!1})}return await R(e,t,["write-tree"],m)}finally{await Hn(c,{force:!0,
|
|
1312
|
+
recursive:!0})}}async function dm(e,t,r){let n=me.dirname(t.worktreePath),o=(await am(n).catch(()=>[])).filter(i=>i.startsWith(
|
|
1313
|
+
Ia));if(o.length){for(let i of o)await Hn(me.join(n,i),{force:!0,recursive:!0});await y(e,t,["worktree","prune"],{...r,required:!1})}}async function _r(e,t,{baseCommit:r,commandOptions:n,derivedArtifactPaths:o=[],project:i,refreshDerivedArtifacts:s,tree:a}){
|
|
1314
|
+
if(!We(o).length)return{tree:a};await dm(e,t,{commandOptions:n,project:i});let u=await hr(e,t,{baseCommit:r,commandOptions:n,
|
|
1315
|
+
message:"Vibe64 derived artifact input",project:i,tree:a}),l=await Aa(me.join(me.dirname(t.worktreePath),Ia)),m=me.join(
|
|
1306
1316
|
l,"source"),d={additionalAllowedRoots:[l,m],commandOptions:n,project:i},p=!1;try{await y(e,t,["worktree","add","--detach",
|
|
1307
1317
|
m,u],d),p=!0;try{await s({projectRoot:m})}catch(f){return{derivedArtifactsKept:{code:String(f?.code||f?.name||"vibe64_de\
|
|
1308
|
-
rived_artifacts_unavailable"),message:String(f?.message||f)},tree:a}}return{tree:await
|
|
1309
|
-
i),runCommand:e,worktreePath:m})}}finally{p&&await y(e,t,["worktree","remove","--force",m],{...d,required:!1}),await
|
|
1310
|
-
l,{force:!0,recursive:!0}),await y(e,t,["worktree","prune"],{commandOptions:n,project:i,required:!1})}}async function
|
|
1311
|
-
e,t,["fetch","--no-tags","origin",`+refs/heads/${t.branch}:${o}`],n);let i=await
|
|
1312
|
-
e,t,i,n).then(s=>({canonicalBranch:"",commit:s}))}finally{await
|
|
1318
|
+
rived_artifacts_unavailable"),message:String(f?.message||f)},tree:a}}return{tree:await ee({baseCommit:"HEAD",project:B(t,
|
|
1319
|
+
i),runCommand:e,worktreePath:m})}}finally{p&&await y(e,t,["worktree","remove","--force",m],{...d,required:!1}),await Hn(
|
|
1320
|
+
l,{force:!0,recursive:!0}),await y(e,t,["worktree","prune"],{commandOptions:n,project:i,required:!1})}}async function pm(e,t,r,n){await y(e,t,["remote","set-url","origin",t.remoteUrl],n);let o=mr(t,r,"canonical");try{await y(
|
|
1321
|
+
e,t,["fetch","--no-tags","origin",`+refs/heads/${t.branch}:${o}`],n);let i=await R(e,t,["rev-parse","--verify",o],n);return te(
|
|
1322
|
+
e,t,i,n).then(s=>({canonicalBranch:"",commit:s}))}finally{await yt(e,t,o,n)}}async function Bn(e,t,r){if(await R(e,t,["b\
|
|
1313
1323
|
ranch","--show-current"],{...r,cwd:t.standaloneSourceRoot})!==t.branch)throw O(`The project baseline must have ${t.branch}\
|
|
1314
|
-
checked out before Save.`,"vibe64_session_save_local_branch_mismatch");if(await
|
|
1324
|
+
checked out before Save.`,"vibe64_session_save_local_branch_mismatch");if(await R(e,t,["status","--porcelain","--untrac\
|
|
1315
1325
|
ked-files=all"],{...r,cwd:t.standaloneSourceRoot}))throw O("The local project baseline has unsaved work. Save cannot ove\
|
|
1316
1326
|
rwrite it.","vibe64_session_save_local_authority_dirty");for(let i of["MERGE_HEAD","CHERRY_PICK_HEAD","REVERT_HEAD","REB\
|
|
1317
1327
|
ASE_HEAD"])if((await y(e,t,["rev-parse","--verify","-q",i],{...r,cwd:t.standaloneSourceRoot,required:!1}))?.ok===!0)throw O(
|
|
1318
|
-
"The local project baseline has an unfinished Git operation.","vibe64_session_save_local_operation_in_progress");return
|
|
1319
|
-
e,t,["rev-parse","--verify","HEAD"],{...r,cwd:t.standaloneSourceRoot})}async function
|
|
1320
|
-
["fetch","--no-tags",t.standaloneSourceRoot,`+refs/heads/${t.branch}:${i}`],n);let s=await
|
|
1328
|
+
"The local project baseline has an unfinished Git operation.","vibe64_session_save_local_operation_in_progress");return R(
|
|
1329
|
+
e,t,["rev-parse","--verify","HEAD"],{...r,cwd:t.standaloneSourceRoot})}async function Je(e,t,r,n){if(t.mode!==D)return pm(e,t,r,n);let o=await Bn(e,t,n),i=mr(t,r,"canonical");try{await y(e,t,
|
|
1330
|
+
["fetch","--no-tags",t.standaloneSourceRoot,`+refs/heads/${t.branch}:${i}`],n);let s=await R(e,t,["rev-parse","--verify",
|
|
1321
1331
|
i],n);if(s!==o)throw O("The local project baseline changed while Vibe64 was reading it.","vibe64_session_save_authority_\
|
|
1322
|
-
changed_during_read");return
|
|
1323
|
-
ile",
|
|
1324
|
-
paths:o,project:
|
|
1325
|
-
length>3?`${t} and ${e.length-3} more`:t}async function
|
|
1326
|
-
path);return(await Promise.all(r.map(async o=>{let i=await
|
|
1327
|
-
o:""}))).filter(Boolean)}async function
|
|
1328
|
-
-absolute-git-dir"],o),"vibe64-checkpoints");await
|
|
1329
|
-
additionalAllowedRoots:[a],env:{GIT_INDEX_FILE:
|
|
1330
|
-
ate-index","-q","--refresh"],c);let u=await y(e,t,["diff-files","--name-status","-z"],c),m=[...
|
|
1331
|
-
filter(g=>i.has(g.path)&&!(g.status==="D"&&i.get(g.path).status==="D")).map(g=>g.path),d=await
|
|
1332
|
+
changed_during_read");return te(e,t,s,n).then(a=>({canonicalBranch:"",commit:a}))}finally{await yt(e,t,i,n)}}function ge(){}import{lstat as mm,mkdir as fm,mkdtemp as hm,rm as gm}from"node:fs/promises";import wr from"node:path";var zn="vibe64_session_worktree_written",_m="vibe64_session_update_worktree_changed",wm="vibe64_session_update_ignored_f\
|
|
1333
|
+
ile",ym="vibe64_session_update_head_moved";function Xe(e,t,r,{baseCommit:n="HEAD",paths:o=[]}={}){return ee({baseCommit:n,
|
|
1334
|
+
paths:o,project:B(t,r),runCommand:e,worktreePath:t.worktreePath})}function Vn(e){let t=e.slice(0,3).join(", ");return e.
|
|
1335
|
+
length>3?`${t} and ${e.length-3} more`:t}async function bm(e,t){let r=[...t.values()].filter(o=>o.status==="A").map(o=>o.
|
|
1336
|
+
path);return(await Promise.all(r.map(async o=>{let i=await mm(wr.join(e.worktreePath,o)).catch(()=>null);return i&&!i.isDirectory()?
|
|
1337
|
+
o:""}))).filter(Boolean)}async function Fn(e,t,r,n,o={}){let i=await he(e,t,r,n,o),s=wr.join(await R(e,t,["rev-parse","-\
|
|
1338
|
+
-absolute-git-dir"],o),"vibe64-checkpoints");await fm(s,{recursive:!0});let a=await hm(wr.join(s,".tree-switch-")),c={...o,
|
|
1339
|
+
additionalAllowedRoots:[a],env:{GIT_INDEX_FILE:wr.join(a,"index")}};try{await y(e,t,["read-tree",r],c),await y(e,t,["upd\
|
|
1340
|
+
ate-index","-q","--refresh"],c);let u=await y(e,t,["diff-files","--name-status","-z"],c),m=[...gt(u.stdout||u.output).values()].
|
|
1341
|
+
filter(g=>i.has(g.path)&&!(g.status==="D"&&i.get(g.path).status==="D")).map(g=>g.path),d=await bm(t,i),p=d.length?await y(
|
|
1332
1342
|
e,t,["check-ignore","--no-index","--stdin","-z"],{...o,input:`${d.join("\0")}\0`,required:!1}):null,f=String(p?.stdout||
|
|
1333
|
-
p?.output||"").split("\0").filter(Boolean);if(f.length)throw O(`Update would replace ${
|
|
1343
|
+
p?.output||"").split("\0").filter(Boolean);if(f.length)throw O(`Update would replace ${Vn(f)}, which Git ignores in this\
|
|
1334
1344
|
session, so it stopped and changed nothing. Move or rename ${f.length===1?"that file":"those files"}, then try Update a\
|
|
1335
|
-
gain.`,
|
|
1336
|
-
).`,
|
|
1337
|
-
from:n,options:o,to:i}){let s=await
|
|
1345
|
+
gain.`,wm,{ignoredPaths:f});if(m.push(...d),m.length)throw O(`Files changed while the session was being switched (${Vn(m)}\
|
|
1346
|
+
).`,zn,{changedPaths:m});await y(e,t,["read-tree","-m","-u",r,n],c)}finally{await gm(a,{force:!0,recursive:!0})}}async function Wn(e,t,r,{
|
|
1347
|
+
from:n,options:o,to:i}){let s=await he(e,t,n,i,o),a=new Map;for(let c=0;c<3;c+=1){let u=await Xe(e,t,r);if(a=await he(e,
|
|
1338
1348
|
t,n,u,o),[...s.keys()].every(d=>a.has(d)))return{changes:s,moved:!0,writes:a};let l=[...a.values()].filter(d=>!(d.status===
|
|
1339
|
-
"D"&&s.get(d.path)?.status==="D")).map(d=>d.path),m=i;if(l.length)try{m=await
|
|
1340
|
-
if(await
|
|
1341
|
-
moved:!1,writes:a}}function
|
|
1349
|
+
"D"&&s.get(d.path)?.status==="D")).map(d=>d.path),m=i;if(l.length)try{m=await Xe(e,t,r,{baseCommit:i,paths:l})}catch(d){
|
|
1350
|
+
if(await Xe(e,t,r)===u)throw d;continue}try{return await Fn(e,t,u,m,o),{changes:s,moved:!0,writes:a}}catch{}}return{changes:s,
|
|
1351
|
+
moved:!1,writes:a}}function qn(e=[],{undone:t=!0}={}){let r=e.length?` (${Vn(e)})`:"";return O(t?`A file changed while U\
|
|
1342
1352
|
pdate ran${r}, so Update stopped and put this session back as it was, keeping every change. Nothing was lost. Try Update\
|
|
1343
1353
|
again.`:`Files kept changing while Update ran${r}, so this session stays updated and keeps every file as last written. \
|
|
1344
|
-
Nothing was lost. Check those files before saving.`,
|
|
1354
|
+
Nothing was lost. Check those files before saving.`,_m,{changedPaths:e,undone:t})}function ka(){return O("A Git commit w\
|
|
1345
1355
|
as made in this session while Update ran, so Update stopped and left every file as it is, some perhaps already updated. \
|
|
1346
|
-
Nothing was lost. Try Update again.",
|
|
1347
|
-
mergedTree:i,oldHead:s,oldIndexTree:a,options:c,project:u,switched:l,updatedPathStatuses:m}){let d=()=>
|
|
1356
|
+
Nothing was lost. Try Update again.",ym,{undone:!1})}async function Na(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,
|
|
1357
|
+
mergedTree:i,oldHead:s,oldIndexTree:a,options:c,project:u,switched:l,updatedPathStatuses:m}){let d=()=>R(e,t,["rev-parse",
|
|
1348
1358
|
"HEAD"],c).catch(()=>""),p=async()=>(await y(e,t,["read-tree","HEAD"],{...c,required:!1}),{headMoved:!0,undone:!1,written:[]}),
|
|
1349
|
-
f=await d();if(f!==s&&f!==r)return p();let g;if(l){let S=await
|
|
1350
|
-
keys()].filter(A=>S.changes.has(A))}else{let S=await
|
|
1351
|
-
w,_]=l?[r,s]:[s,r];return f===_&&await y(e,t,["update-ref","HEAD",w,_],{...c,required:!1}),await d()!==w?p():(l&&await
|
|
1352
|
-
e,t,r,c).catch(
|
|
1353
|
-
..${n}`],o),s=
|
|
1354
|
-
|
|
1359
|
+
f=await d();if(f!==s&&f!==r)return p();let g;if(l){let S=await Wn(e,t,u,{from:i,options:c,to:n});l=!S.moved,g=[...S.writes.
|
|
1360
|
+
keys()].filter(A=>S.changes.has(A))}else{let S=await Xe(e,t,u);g=[...(await he(e,t,o,S,c)).keys()].filter(A=>m.has(A))}let[
|
|
1361
|
+
w,_]=l?[r,s]:[s,r];return f===_&&await y(e,t,["update-ref","HEAD",w,_],{...c,required:!1}),await d()!==w?p():(l&&await te(
|
|
1362
|
+
e,t,r,c).catch(ge),(l||f===r)&&await y(e,t,["read-tree",l?r:a],{...c,required:!1}),{undone:!l,written:g})}var Yn=5;async function vm(e,t,r,n,o={}){let i=await y(e,t,["log","--topo-order",`--max-count=${Yn+1}`,"-z",`--format=${ga}`,`${r}\
|
|
1363
|
+
..${n}`],o),s=wa(String(i.stdout||i.output||""));return{incomingVersions:s.slice(0,Yn),incomingVersionsTruncated:s.length>
|
|
1364
|
+
Yn}}function Sm(e={}){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=Array.isArray(e.conflictPaths)?[...new Set(
|
|
1355
1365
|
e.conflictPaths.map(String).filter(Boolean))].sort((n,o)=>n.localeCompare(o)):[],r={baseCommit:h(e.baseCommit),canonicalCommit:h(
|
|
1356
1366
|
e.canonicalCommit),checkpointTree:h(e.checkpointTree),conflictPaths:t,conflictTree:h(e.conflictTree),reviewId:h(e.reviewId),
|
|
1357
1367
|
oldHead:h(e.oldHead),oldIndexTree:h(e.oldIndexTree)};return Object.values(r).some(n=>Array.isArray(n)?n.length===0:!n)?null:
|
|
1358
|
-
r}function
|
|
1368
|
+
r}function Tm(e=[],t=""){let r=e.length,n=e.slice(0,3).join(", "),o=r>3?` and ${r-3} more`:"",i=t?` in connected reposit\
|
|
1359
1369
|
ory ${t}`:"";return`${r} ${r===1?"file":"files"}${i} ${r===1?"needs":"need"} review before this session can update: ${n}${o}\
|
|
1360
1370
|
. Resolve ${r===1?"it":"them"} manually or with AI, then use Review resolved conflicts to apply Update. Fix it with AI c\
|
|
1361
|
-
an help with the repair.`}function
|
|
1362
|
-
conflictPaths,conflictRecovery:e})}async function
|
|
1363
|
-
let s=o?
|
|
1364
|
-
ndexTree"].every(u=>s[u]===r[u])&&r.conflictPaths.every(u=>a.has(u)))||o!==s.reviewId)throw
|
|
1365
|
-
async function
|
|
1366
|
-
o,r);n=
|
|
1367
|
-
n,i,t,{commandOptions:e,project:r}),a=s.commit,[c,u]=await Promise.all([
|
|
1368
|
-
commandOptions:e,project:r}),
|
|
1371
|
+
an help with the repair.`}function xa(e){return O(Tm(e.conflictPaths),"vibe64_session_update_conflict",{conflictPaths:e.
|
|
1372
|
+
conflictPaths,conflictRecovery:e})}async function Om(e,t,{currentRecovery:r,previousRecovery:n,reviewedConflictId:o,project:i}){
|
|
1373
|
+
let s=o?Sm(n):null;if(!s)throw xa(r);let a=new Set(s.conflictPaths);if(!(["baseCommit","canonicalCommit","oldHead","oldI\
|
|
1374
|
+
ndexTree"].every(u=>s[u]===r[u])&&r.conflictPaths.every(u=>a.has(u)))||o!==s.reviewId)throw xa(r);return Ca(e,t,{...r,project:i})}
|
|
1375
|
+
async function Ma({commandOptions:e={},operationId:t=$a.randomUUID(),project:r={},runCommand:n=x,session:o={}}={}){let i=U(
|
|
1376
|
+
o,r);n=V(n,i,r,{label:"Checking repository for updates",operationId:t}),await Ke(n,i,{commandOptions:e,project:r});let s=await Je(
|
|
1377
|
+
n,i,t,{commandOptions:e,project:r}),a=s.commit,[c,u]=await Promise.all([R(n,i,["rev-parse","--verify","HEAD^{commit}"],{
|
|
1378
|
+
commandOptions:e,project:r}),ee({baseCommit:"HEAD",project:B(i,r),runCommand:n,worktreePath:i.worktreePath})]),l=await ke(
|
|
1369
1379
|
n,i,a,c,{commandOptions:e,project:r});if(l&&i.mode!==D)throw O("The saved project history no longer descends from this s\
|
|
1370
1380
|
ession's starting version.","vibe64_session_update_history_diverged");let m=l?{baseCommit:i.baseCommit,canonicalCommit:a,
|
|
1371
|
-
sessionHead:c,worktreeTree:u,changedPaths:(await
|
|
1372
|
-
[d,p,f,g]=await Promise.all([
|
|
1373
|
-
{commandOptions:e,project:r}),
|
|
1381
|
+
sessionHead:c,worktreeTree:u,changedPaths:(await dr(n,i,i.baseCommit,u,{commandOptions:e,project:r})).slice(0,100)}:null,
|
|
1382
|
+
[d,p,f,g]=await Promise.all([qe(n,i,a,c,{commandOptions:e,project:r}),qe(n,i,c,a,{commandOptions:e,project:r}),X(n,i,a,c,
|
|
1383
|
+
{commandOptions:e,project:r}),fe(n,i,a,{commandOptions:e,project:r})]),w=ft(d,p),_=p>0?await vm(n,i,c,a,{commandOptions:e,
|
|
1374
1384
|
project:r}):{incomingVersions:[],incomingVersionsTruncated:!1};return{ahead:d,baseCommit:i.baseCommit,behind:p,canonicalCommit:a,
|
|
1375
1385
|
canonicalSource:{authority:i.mode,commit:a,ref:`refs/heads/${s.canonicalBranch||i.branch}`,...i.mode===D?{}:{repository:i.
|
|
1376
1386
|
remoteUrl}},..._,ok:!0,operationId:t,reconciled:!l&&f,...m?{historyReview:m}:{},repositoryMode:i.mode,relationship:w,sessionCurrent:f,
|
|
1377
|
-
sessionHead:c,sessionMatchesCanonical:u===g,updateAvailable:l||!f,updateStrategy:
|
|
1378
|
-
oldHead:c,oldIndexTree:u,project:l}){let m={commandOptions:i,project:l},d=await
|
|
1379
|
-
m),p=!0,await y(e,t,["update-ref","HEAD",r,c],m),await y(e,t,["read-tree",r],m);let f=await
|
|
1380
|
-
f,m)).filter(w=>d.has(w));if(g.length)throw
|
|
1387
|
+
sessionHead:c,sessionMatchesCanonical:u===g,updateAvailable:l||!f,updateStrategy:ht(w)}}async function Am(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,commandOptions:i,mergedCommit:s,mergedTree:a,
|
|
1388
|
+
oldHead:c,oldIndexTree:u,project:l}){let m={commandOptions:i,project:l},d=await he(e,t,o,a,m),p=!1;try{await Fn(e,t,n,s,
|
|
1389
|
+
m),p=!0,await y(e,t,["update-ref","HEAD",r,c],m),await y(e,t,["read-tree",r],m);let f=await Xe(e,t,l),g=(await dr(e,t,a,
|
|
1390
|
+
f,m)).filter(w=>d.has(w));if(g.length)throw qn(g);return await te(e,t,r,m),{currentTree:f,reconciled:!0,status:"updated",
|
|
1381
1391
|
updatedPathCount:d.size,updatedPaths:[...d.keys()].sort((w,_)=>w.localeCompare(_)).slice(0,50)}}catch(f){let{headMoved:g,
|
|
1382
|
-
undone:w,written:_}=await
|
|
1383
|
-
options:m,project:l,switched:p,updatedPathStatuses:d});throw g?
|
|
1384
|
-
[],{undone:w}):f}}async function
|
|
1385
|
-
o,r);await
|
|
1392
|
+
undone:w,written:_}=await Na(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,mergedTree:a,oldHead:c,oldIndexTree:u,
|
|
1393
|
+
options:m,project:l,switched:p,updatedPathStatuses:d});throw g?ka():!w||_.length||f?.code===zn?qn(_.length?_:f?.changedPaths||
|
|
1394
|
+
[],{undone:w}):f}}async function La({commandOptions:e={},operationId:t,project:r={},runCommand:n=x,session:o={}}={}){let i=U(
|
|
1395
|
+
o,r);await Ke(n,i,{commandOptions:e,project:r});let s=await mt({outerTurnId:`update:${t}`,outcome:"completed",project:B(
|
|
1386
1396
|
i,r),runCommand:n,sessionId:i.sessionId,timestamp:new Date().toISOString(),worktreePath:i.worktreePath}),[a,c]=await Promise.
|
|
1387
|
-
all([
|
|
1388
|
-
checkpointCommit:s.commit,checkpointTree:s.tree,oldHead:a,oldIndexTree:c}}async function
|
|
1397
|
+
all([R(n,i,["rev-parse","HEAD"],{commandOptions:e,project:r}),R(n,i,["write-tree"],{commandOptions:e,project:r})]);return{
|
|
1398
|
+
checkpointCommit:s.commit,checkpointTree:s.tree,oldHead:a,oldIndexTree:c}}async function ja({checkpoint:e={},commandOptions:t={},
|
|
1389
1399
|
conflictRecovery:r=null,derivedArtifactPaths:n=[],historyReview:o=null,operationId:i,project:s={},reviewedConflictId:a="",
|
|
1390
|
-
runCommand:c=x,session:u={}}={}){let l=U(u,s),{checkpointCommit:m,checkpointTree:d,oldHead:p,oldIndexTree:f}=e,{commit:g}=await
|
|
1391
|
-
c,l,i,{commandOptions:t,project:s}),w=await
|
|
1400
|
+
runCommand:c=x,session:u={}}={}){let l=U(u,s),{checkpointCommit:m,checkpointTree:d,oldHead:p,oldIndexTree:f}=e,{commit:g}=await Je(
|
|
1401
|
+
c,l,i,{commandOptions:t,project:s}),w=await ke(c,l,g,p,{commandOptions:t,project:s});if(w||o){if(l.mode!==D)throw O("The\
|
|
1392
1402
|
saved project history no longer descends from this session's starting version.","vibe64_session_update_history_diverged");
|
|
1393
1403
|
let T={baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:p,worktreeTree:d};if(!(a&&r?.reviewId===a&&r.baseCommit===l.
|
|
1394
|
-
baseCommit&&r.canonicalCommit===g&&r.oldHead===p&&r.oldIndexTree===f)&&(!o||Object.entries(T).some(([N,
|
|
1404
|
+
baseCommit&&r.canonicalCommit===g&&r.oldHead===p&&r.oldIndexTree===f)&&(!o||Object.entries(T).some(([N,Q])=>o[N]!==Q)))throw O(
|
|
1395
1405
|
"The project history was rewritten. Open Repository, check for updates, then review and reconcile this session.","vibe64\
|
|
1396
|
-
_session_history_review_required")}let _=await
|
|
1397
|
-
reconcileHistory:w},{commandOptions:t,project:s}),S=new Set(
|
|
1406
|
+
_session_history_review_required")}let _=await Ye(c,l,{baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:p,worktreeTree:d,
|
|
1407
|
+
reconcileHistory:w},{commandOptions:t,project:s}),S=new Set(We(n)),A=_.changedPaths.filter(T=>!S.has(T)),I=await X(c,l,g,
|
|
1398
1408
|
p,{commandOptions:t,project:s});if(I&&!w)return{baseCommit:l.baseCommit,canonicalCommit:g,canonicalTree:_.canonicalTree,
|
|
1399
1409
|
changeBaseCommit:_.changeBaseCommit,checkpointCommit:m,checkpointTree:d,currentTree:d,ok:!0,operationId:i,mode:l.mode,reconciled:!0,
|
|
1400
|
-
repositoryMode:l.mode,sessionCurrent:I,sessionMatchesCanonical:_.sessionMatchesCanonical,status:"already_current"};let
|
|
1401
|
-
canonicalTree;if(A.length){let T=await
|
|
1402
|
-
C=await
|
|
1410
|
+
repositoryMode:l.mode,sessionCurrent:I,sessionMatchesCanonical:_.sessionMatchesCanonical,status:"already_current"};let P=_.
|
|
1411
|
+
canonicalTree;if(A.length){let T=await gr(c,l,{commandOptions:t,derivedArtifactPaths:n,project:s,sourceCommit:g,tree:d}),
|
|
1412
|
+
C=await Pa(c,l,{baseCommit:_.changeBaseCommit,explicitBase:w,canonicalCommit:g,checkpointTree:T,commandOptions:t,project:s}),
|
|
1403
1413
|
N=C.conflictPaths.length>0?{baseCommit:_.changeBaseCommit,canonicalCommit:g,checkpointTree:d,conflictPaths:C.conflictPaths,
|
|
1404
|
-
conflictTree:C.conflictTree,oldHead:p,oldIndexTree:f,reviewId
|
|
1414
|
+
conflictTree:C.conflictTree,oldHead:p,oldIndexTree:f,reviewId:$a.randomUUID()}:null;P=N?await Om(c,l,{currentRecovery:N,
|
|
1405
1415
|
previousRecovery:r,reviewedConflictId:a,project:s}):C.mergedTree}return{...e,baseCommit:l.baseCommit,canonicalCommit:g,canonicalTree:_.
|
|
1406
|
-
canonicalTree,changeBaseCommit:_.changeBaseCommit,mergedSourceTree:
|
|
1407
|
-
...A.length?{}:{sessionMatchesCanonical:!0},status:"prepared"}}async function
|
|
1416
|
+
canonicalTree,changeBaseCommit:_.changeBaseCommit,mergedSourceTree:P,mode:l.mode,operationId:i,repositoryMode:l.mode,sessionCurrent:!0,
|
|
1417
|
+
...A.length?{}:{sessionMatchesCanonical:!0},status:"prepared"}}async function Da({commandOptions:e={},derivedArtifactPaths:t=[],
|
|
1408
1418
|
prepared:r={},project:n={},refreshDerivedArtifacts:o,runCommand:i=x,session:s={}}={}){let a=U(s,n),{derivedArtifactsKept:c,
|
|
1409
|
-
tree:u}=await
|
|
1410
|
-
tree:r.mergedSourceTree}),l=u===r.canonicalTree?r.canonicalCommit:await
|
|
1419
|
+
tree:u}=await _r(i,a,{baseCommit:r.canonicalCommit,commandOptions:e,derivedArtifactPaths:t,project:n,refreshDerivedArtifacts:o,
|
|
1420
|
+
tree:r.mergedSourceTree}),l=u===r.canonicalTree?r.canonicalCommit:await hr(i,a,{baseCommit:r.canonicalCommit,commandOptions:e,
|
|
1411
1421
|
message:"Vibe64 session update result",project:n,tree:u});return{...r,...c?{derivedArtifactsKept:c}:{},mergedCommit:l,mergedTree:u}}
|
|
1412
|
-
async function
|
|
1413
|
-
n,i,{...t,commandOptions:e,project:r});return{...t,ok:!0,...s}}import{access as
|
|
1414
|
-
ebase","rebase-apply"],["cherry-pick or revert","sequencer"]];async function
|
|
1415
|
-
session:n={},targetCommit:o=""}={}){let i=U(n,t);r=
|
|
1416
|
-
project:t},[a,c,u,l]=await Promise.all([
|
|
1417
|
-
flatMap(([,S])=>["--git-path",S])],s),
|
|
1418
|
-
c,a,s),
|
|
1419
|
-
`),w=await Promise.all(
|
|
1422
|
+
async function Ua({commandOptions:e={},prepared:t={},project:r={},runCommand:n=x,session:o={}}={}){let i=U(o,r),s=await Am(
|
|
1423
|
+
n,i,{...t,commandOptions:e,project:r});return{...t,ok:!0,...s}}import{access as Im}from"node:fs/promises";import Rm from"node:path";var Jn=[["merge","MERGE_HEAD"],["cherry-pick","CHERRY_PICK_HEAD"],["revert","REVERT_HEAD"],["rebase","rebase-merge"],["r\
|
|
1424
|
+
ebase","rebase-apply"],["cherry-pick or revert","sequencer"]];async function Ga({commandOptions:e={},project:t={},runCommand:r=x,
|
|
1425
|
+
session:n={},targetCommit:o=""}={}){let i=U(n,t);r=V(r,i,t,{label:"Checking a failed session update"});let s={commandOptions:e,
|
|
1426
|
+
project:t},[a,c,u,l]=await Promise.all([R(r,i,["rev-parse","--verify","HEAD^{commit}"],s),pr(r,i,s),R(r,i,["rev-parse",...Jn.
|
|
1427
|
+
flatMap(([,S])=>["--git-path",S])],s),R(r,i,["ls-files","--unmerged","-z"],s)]),m=h(o),[d,p,f]=await Promise.all([X(r,i,
|
|
1428
|
+
c,a,s),ke(r,i,c,a,s),lr(m)?X(r,i,m,a,s):!1]),g=u.split(`
|
|
1429
|
+
`),w=await Promise.all(Jn.map((S,A)=>!g[A]||Im(Rm.resolve(i.worktreePath,g[A])).then(()=>!0,I=>I?.code!=="ENOENT"))),_=Jn.
|
|
1420
1430
|
find((S,A)=>w[A]);return{canonicalCommit:c,gitOperation:_?.[0]||"",sessionHead:a,targetInHead:f,unmergedPaths:[...new Set(
|
|
1421
|
-
l.split("\0").filter(Boolean).map(S=>S.slice(S.indexOf(" ")+1)))].sort(),updateNeeded:p||!d}}import
|
|
1422
|
-
"-z",r,n],o),y(e,t,["diff-tree","--no-commit-id","-r","-M","--numstat","-z",r,n],o)]);return
|
|
1423
|
-
s.output)}async function
|
|
1431
|
+
l.split("\0").filter(Boolean).map(S=>S.slice(S.indexOf(" ")+1)))].sort(),updateNeeded:p||!d}}import Fa from"node:crypto";async function Pm(e,t,r,n,o={}){let[i,s]=await Promise.all([y(e,t,["diff-tree","--no-commit-id","-r","-M","--name-status",
|
|
1432
|
+
"-z",r,n],o),y(e,t,["diff-tree","--no-commit-id","-r","-M","--numstat","-z",r,n],o)]);return ba(i.stdout||i.output,s.stdout||
|
|
1433
|
+
s.output)}async function Ha(e,t,r,n,o={}){let{commandOptions:i={},lineLimit:s=cr,project:a={}}=o,c=Un(n);if(!r.changedPaths.
|
|
1424
1434
|
includes(c))throw O("That file is not part of the current saved-work difference.","vibe64_session_change_not_found",{},{
|
|
1425
1435
|
status:404});let u=await y(e,t,["--no-literal-pathspecs","diff","--no-ext-diff","--find-renames","--unified=3",r.changeBaseCommit,
|
|
1426
|
-
r.worktreeTree,"--",...
|
|
1427
|
-
changeBaseCommit,...
|
|
1428
|
-
derivedArtifactPaths:t=[],includeInitialDiff:r=!0,limit:n=
|
|
1429
|
-
let u=U(a,i);s=
|
|
1430
|
-
runCommand:s,session:a,worktreeTree:c}),m=new Set(l.changedPaths),d=l.unsaved?await
|
|
1431
|
-
{commandOptions:e,project:i}).then(w=>w.filter(_=>m.has(_.path))):[],{items:p,...f}=
|
|
1432
|
-
offset:o}),g=r&&f.offset===0&&p.length>0?await
|
|
1433
|
-
initialDiff:g,...f}}async function
|
|
1434
|
-
runCommand:i=x,session:s={}}={}){let a=
|
|
1435
|
-
derivedArtifactPaths:t,project:o,runCommand:i,session:s});return
|
|
1436
|
+
r.worktreeTree,"--",...Sa(c)],{commandOptions:i,project:a});return{canonicalCommit:r.canonicalCommit,changeBaseCommit:r.
|
|
1437
|
+
changeBaseCommit,...va(u.stdout||u.output,s),ok:!0,path:c,worktreeTree:r.worktreeTree}}async function yr({commandOptions:e={},
|
|
1438
|
+
derivedArtifactPaths:t=[],includeInitialDiff:r=!0,limit:n=Dn,offset:o=0,project:i={},runCommand:s=x,session:a={},worktreeTree:c=""}={}){
|
|
1439
|
+
let u=U(a,i);s=V(s,u,i,{label:"Inspecting session changes"});let l=await bt({commandOptions:e,derivedArtifactPaths:t,project:i,
|
|
1440
|
+
runCommand:s,session:a,worktreeTree:c}),m=new Set(l.changedPaths),d=l.unsaved?await Pm(s,u,l.changeBaseCommit,l.worktreeTree,
|
|
1441
|
+
{commandOptions:e,project:i}).then(w=>w.filter(_=>m.has(_.path))):[],{items:p,...f}=Ea(d,{defaultLimit:Dn,limit:n,maxLimit:_a,
|
|
1442
|
+
offset:o}),g=r&&f.offset===0&&p.length>0?await Ha(s,u,l,p[0].path,{commandOptions:e,project:i}):null;return{...l,files:p,
|
|
1443
|
+
initialDiff:g,...f}}async function Xn({commandOptions:e={},derivedArtifactPaths:t=[],lineLimit:r=cr,path:n="",project:o={},
|
|
1444
|
+
runCommand:i=x,session:s={}}={}){let a=Un(n),c=U(s,o);i=V(i,c,o,{label:"Inspecting a session change"});let u=await bt({commandOptions:e,
|
|
1445
|
+
derivedArtifactPaths:t,project:o,runCommand:i,session:s});return Ha(i,c,u,a,{commandOptions:e,lineLimit:r,project:o})}async function bt({
|
|
1436
1446
|
commandOptions:e={},derivedArtifactPaths:t=[],project:r={},runCommand:n=x,session:o={},worktreeTree:i=""}={}){let s=U(o,
|
|
1437
|
-
r);n=
|
|
1438
|
-
worktreePath}),[c,u,l,m]=await Promise.all([
|
|
1439
|
-
mmit}"],{commandOptions:e,project:r}),
|
|
1440
|
-
"-z"],{commandOptions:e,project:r}),
|
|
1441
|
-
all([
|
|
1442
|
-
{commandOptions:e,project:r}),
|
|
1443
|
-
project:r})]),w=new Set((Array.isArray(t)?t:[]).map(h).filter(Boolean)),_=g.changedPaths.filter(I=>!w.has(I)),S=
|
|
1447
|
+
r);n=V(n,s,r,{label:"Inspecting session work"});let a=h(i)||await ee({baseCommit:"HEAD",project:B(s,r),runCommand:n,worktreePath:s.
|
|
1448
|
+
worktreePath}),[c,u,l,m]=await Promise.all([pr(n,s,{commandOptions:e,project:r}),R(n,s,["rev-parse","--verify","HEAD^{co\
|
|
1449
|
+
mmit}"],{commandOptions:e,project:r}),R(n,s,["status","--porcelain=v1","--untracked-files=all","--ignore-submodules=none",
|
|
1450
|
+
"-z"],{commandOptions:e,project:r}),R(n,s,["rev-parse","--show-toplevel"],{commandOptions:e,project:r})]),[d,p,f,g]=await Promise.
|
|
1451
|
+
all([R(n,s,["rev-parse",`${u}^{tree}`],{commandOptions:e,project:r}),qe(n,s,c,u,{commandOptions:e,project:r}),qe(n,s,u,c,
|
|
1452
|
+
{commandOptions:e,project:r}),Ye(n,s,{baseCommit:s.baseCommit,canonicalCommit:c,sessionHead:u,worktreeTree:a},{commandOptions:e,
|
|
1453
|
+
project:r})]),w=new Set((Array.isArray(t)?t:[]).map(h).filter(Boolean)),_=g.changedPaths.filter(I=>!w.has(I)),S=ft(p,f),
|
|
1444
1454
|
A=l.length===0;return{ahead:p,baseCommit:s.baseCommit,behind:f,branch:s.branch,canonicalCommit:c,canonicalTree:g.canonicalTree,
|
|
1445
|
-
changeBaseCommit:g.changeBaseCommit,changeBaseTree:g.changeBaseTree,changedPaths:_,destination:
|
|
1455
|
+
changeBaseCommit:g.changeBaseCommit,changeBaseTree:g.changeBaseTree,changedPaths:_,destination:la(r,o),dirty:a!==d||!A,mode:s.
|
|
1446
1456
|
mode,ok:!0,repositoryMode:s.mode,relationship:S,sessionMatchesCanonical:_.length===0,sessionHead:u,sessionId:s.sessionId,
|
|
1447
|
-
tree:a,updateAvailable:f>0,updateStrategy:
|
|
1448
|
-
worktreePath}}import
|
|
1449
|
-
ave requires an assistant-generated commit subject.","vibe64_session_save_message_required",{},{status:400});return
|
|
1457
|
+
tree:a,updateAvailable:f>0,updateStrategy:ht(S),unsaved:_.length>0,worktreeClean:A,worktreeTree:a,worktreeTopLevel:m,worktreePath:s.
|
|
1458
|
+
worktreePath}}import Cm from"node:path";async function Ba(e,t,{canonicalCommit:r,commandOptions:n,mergedTree:o,message:i,project:s}){let a=h(i);if(!a)throw O("S\
|
|
1459
|
+
ave requires an assistant-generated commit subject.","vibe64_session_save_message_required",{},{status:400});return R(e,
|
|
1450
1460
|
t,["commit-tree",o,"-p",r],{commandOptions:n,input:`${a}
|
|
1451
|
-
`,project:s})}async function
|
|
1461
|
+
`,project:s})}async function Va(e,t,{canonicalCommit:r,saveCommit:n},o){let{onPublicationAttempt:i=ge}=o;if(t.mode===D){
|
|
1452
1462
|
if(await Bn(e,t,o)!==r)throw O("The local project baseline advanced during Save.","vibe64_session_save_authority_advance\
|
|
1453
1463
|
d");await y(e,t,["fetch",t.worktreePath,n],{...o,cwd:t.standaloneSourceRoot}),i(),await y(e,t,["merge","--ff-only",n],{...o,
|
|
1454
|
-
cwd:t.standaloneSourceRoot});let l=await
|
|
1455
|
-
t,l,o),l}let s=["push"];t.mode===
|
|
1456
|
-
let a;i();try{a=await y(e,t,s,{...o,required:!1})}catch(u){a={ok:!1,code:u.code,error:u.message}}let c;try{c=(await
|
|
1464
|
+
cwd:t.standaloneSourceRoot});let l=await R(e,t,["rev-parse","HEAD"],{...o,cwd:t.standaloneSourceRoot});return await te(e,
|
|
1465
|
+
t,l,o),l}let s=["push"];t.mode===ze&&s.push("--push-option=vibe64-atomic"),s.push("origin",`${n}:refs/heads/${t.branch}`);
|
|
1466
|
+
let a;i();try{a=await y(e,t,s,{...o,required:!1})}catch(u){a={ok:!1,code:u.code,error:u.message}}let c;try{c=(await R(e,
|
|
1457
1467
|
t,["ls-remote","--heads","origin",`refs/heads/${t.branch}`],o)).split(/\s+/u)[0]||""}catch(u){throw O(`Save publication \
|
|
1458
1468
|
could not be confirmed. Inspect work to recover the prepared commit before retrying. ${h(u.message)}`,"vibe64_session_sa\
|
|
1459
1469
|
ve_publication_unknown",{},{messageCode:"vibe64_session_save_publication_unconfirmed",messageParams:{reason:h(u.message)}})}
|
|
1460
|
-
if(c===n)return await
|
|
1470
|
+
if(c===n)return await te(e,t,c,o),c;if(a?.ok!==!0){if(c&&c!==r)throw O("The saved branch changed while Save was pushing \
|
|
1461
1471
|
your changes. Update this session, then save again.","vibe64_session_save_update_required",{canonicalCommit:c,reconciledCommit:r,
|
|
1462
1472
|
updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed_during_push"});let u=h(a?.stderr||a?.stdout||a?.output||
|
|
1463
|
-
a?.error)||"Git Save publication failed.";throw t.mode===
|
|
1473
|
+
a?.error)||"Git Save publication failed.";throw t.mode===J&&/changes must be made through a pull request/iu.test(u)?O(`G\
|
|
1464
1474
|
itHub requires a pull request to update ${t.branch}. Your work remains in this session.
|
|
1465
1475
|
|
|
1466
1476
|
${u}`,"vibe64_pull_request_required"):O(u,h(a?.code)||"vibe64_session_save_git_failed",{},{status:500})}throw O("Canonic\
|
|
1467
|
-
al repository verification did not return the commit Vibe64 pushed.","vibe64_session_save_verification_failed")}function
|
|
1477
|
+
al repository verification did not return the commit Vibe64 pushed.","vibe64_session_save_verification_failed")}function za(e,t,r,n,o){
|
|
1468
1478
|
return{attempted:o,branch:e.branch,code:r,kind:"github_mirror",message:"Your work was saved, but Vibe64 could not refres\
|
|
1469
1479
|
h its local clone cache. A later session or Save will retry it.",reason:n,retryable:!0,status:"retryable",verifiedCommit:t}}
|
|
1470
|
-
async function
|
|
1471
|
-
status:"not_applicable"};let s=t.githubMirrorPath,a=(c,u)=>
|
|
1472
|
-
kind:"none",retryable:!1,status:"not_applicable"};if(!s||!
|
|
1473
|
-
issing","configuration_missing");try{let[c,...u]=
|
|
1480
|
+
async function Qn(e,t,r,n={}){let{commandOptions:o={},project:i={}}=n;if(t.mode!==J)return{attempted:!1,kind:"none",retryable:!1,
|
|
1481
|
+
status:"not_applicable"};let s=t.githubMirrorPath,a=(c,u)=>za(t,r,c,u,!!s);if(!s&&t.githubMirrorOptional)return{attempted:!1,
|
|
1482
|
+
kind:"none",retryable:!1,status:"not_applicable"};if(!s||!Cm.isAbsolute(s))return a("vibe64_session_save_github_mirror_m\
|
|
1483
|
+
issing","configuration_missing");try{let[c,...u]=Mn({mirrorPath:s,remoteUrl:t.remoteUrl}),l=await wt(e,t,c,u,{additionalAllowedRoots:[
|
|
1474
1484
|
s],commandOptions:o,project:i});if(l?.ok!==!0)return a(h(l?.code)||"vibe64_session_save_github_mirror_refresh_failed","r\
|
|
1475
1485
|
efresh_failed");let m={additionalAllowedRoots:[s],commandOptions:o,project:i,required:!1},[d,p]=await Promise.all([y(e,t,
|
|
1476
1486
|
["--git-dir",s,"rev-parse","--verify",`refs/heads/${t.branch}^{commit}`],m),y(e,t,["--git-dir",s,"remote","get-url","ori\
|
|
1477
|
-
gin"],m)]),f=d?.ok===!0?
|
|
1487
|
+
gin"],m)]),f=d?.ok===!0?Fe(d):"",g=p?.ok===!0?Fe(p):"";return f!==r||g!==t.remoteUrl?{...a("vibe64_session_save_github_m\
|
|
1478
1488
|
irror_verification_failed","verification_failed"),mirrorCommit:f}:{attempted:!0,branch:t.branch,kind:"github_mirror",mirrorCommit:f,
|
|
1479
1489
|
retryable:!1,status:"current",verifiedCommit:r}}catch{return a("vibe64_session_save_github_mirror_refresh_failed","refre\
|
|
1480
|
-
sh_interrupted")}}async function
|
|
1481
|
-
commandOptions:n,project:o},c=await
|
|
1482
|
-
s)return{reconciled:!1,status:"published_needs_reconcile"};let{changes:u,moved:l,writes:m}=await
|
|
1490
|
+
sh_interrupted")}}async function Zn(e,t,{checkpointTree:r,commandOptions:n,project:o,saveCommit:i,sessionHead:s=""}){let a={
|
|
1491
|
+
commandOptions:n,project:o},c=await R(e,t,["rev-parse","HEAD"],a);if(c===i)return{reconciled:!0,status:"saved"};if(s&&c!==
|
|
1492
|
+
s)return{reconciled:!1,status:"published_needs_reconcile"};let{changes:u,moved:l,writes:m}=await Wn(e,t,o,{from:r,options:a,
|
|
1483
1493
|
to:i}),d=m.size,p=await y(e,t,["update-ref","HEAD",i,c],{...a,required:!1});return p.ok!==!0?{error:h(p.stderr||p.output||
|
|
1484
1494
|
p.error),reconciled:!1,status:"published_needs_reconcile",unsavedPathCount:d}:(await y(e,t,["read-tree",i],{...a,required:!1}),
|
|
1485
|
-
{reconciled:!0,refreshedPaths:l?[...u.keys()].filter(f=>!m.has(f)).sort():[],status:"saved",unsavedPathCount:d})}async function
|
|
1486
|
-
commandOptions:n={},operationId:o,project:i={}}=r;await
|
|
1487
|
-
save:${o}`,outcome:"completed",project:
|
|
1488
|
-
worktreePath}),a=await
|
|
1489
|
-
baseCommit,branch:t.branch,checkpointCommit:s.commit,checkpointTree:s.tree,mode:t.mode,operationId:o,sessionHead:a}}async function
|
|
1490
|
-
commandOptions:e={},derivedArtifactPaths:t=[],limit:r=40,operationId:n=
|
|
1491
|
-
let a=U(s,o);i=
|
|
1492
|
-
project:o}),u=await
|
|
1495
|
+
{reconciled:!0,refreshedPaths:l?[...u.keys()].filter(f=>!m.has(f)).sort():[],status:"saved",unsavedPathCount:d})}async function km(e,t,r,n,o={}){let i=fr(t,r);return await y(e,t,["update-ref",i,n],o),i}async function Wa(e,t,r={}){let{
|
|
1496
|
+
commandOptions:n={},operationId:o,project:i={}}=r;await Ke(e,t,{commandOptions:n,project:i});let s=await mt({outerTurnId:`\
|
|
1497
|
+
save:${o}`,outcome:"completed",project:B(t,i),runCommand:e,sessionId:t.sessionId,timestamp:new Date().toISOString(),worktreePath:t.
|
|
1498
|
+
worktreePath}),a=await R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:n,project:i});return{baseCommit:t.
|
|
1499
|
+
baseCommit,branch:t.branch,checkpointCommit:s.commit,checkpointTree:s.tree,mode:t.mode,operationId:o,sessionHead:a}}async function qa({
|
|
1500
|
+
commandOptions:e={},derivedArtifactPaths:t=[],limit:r=40,operationId:n=Fa.randomUUID(),project:o={},runCommand:i=x,session:s={}}={}){
|
|
1501
|
+
let a=U(s,o);i=V(i,a,o,{label:"Capturing work for Save",operationId:n});let c=await Wa(i,a,{commandOptions:e,operationId:n,
|
|
1502
|
+
project:o}),u=await yr({commandOptions:e,derivedArtifactPaths:t,includeInitialDiff:!1,limit:r,project:o,runCommand:i,session:s,
|
|
1493
1503
|
worktreeTree:c.checkpointTree});if(!u.totalCount)throw O("This session has no work to save.","vibe64_session_save_no_cha\
|
|
1494
|
-
nges");return{changes:u,checkpoint:c}}async function
|
|
1504
|
+
nges");return{changes:u,checkpoint:c}}async function Nm(e,t,r,n={}){let{commandOptions:o={},operationId:i,project:s={}}=n,
|
|
1495
1505
|
a=h(r?.checkpointCommit),c=h(r?.checkpointTree);if(!a||!c||h(r?.operationId)!==h(i)||h(r?.baseCommit)!==t.baseCommit||h(
|
|
1496
1506
|
r?.branch)!==t.branch||h(r?.mode)!==t.mode)throw O("Save cannot verify the captured worktree. Capture and name the work \
|
|
1497
|
-
again.","vibe64_session_save_checkpoint_invalid");if(await
|
|
1507
|
+
again.","vibe64_session_save_checkpoint_invalid");if(await fe(e,t,a,{commandOptions:o,project:s})!==c)throw O("Save cann\
|
|
1498
1508
|
ot verify the captured worktree. Capture and name the work again.","vibe64_session_save_checkpoint_invalid");let l=h(r?.
|
|
1499
|
-
sessionHead),m=l?await
|
|
1509
|
+
sessionHead),m=l?await R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:s}):"";if(l&&m!==l)throw O(
|
|
1500
1510
|
"The session history changed while Vibe64 was naming this work. Save was not started; try again.","vibe64_session_save_m\
|
|
1501
|
-
essage_stale");return r}async function
|
|
1502
|
-
operationId:a,project:c={},refreshDerivedArtifacts:u}=r,l=h(n.checkpointTree),[m,d]=await Promise.all([
|
|
1503
|
-
project:c}),
|
|
1511
|
+
essage_stale");return r}async function xm(e,t,r={}){let{checkpoint:n={},commandOptions:o={},derivedArtifactPaths:i=[],message:s="",
|
|
1512
|
+
operationId:a,project:c={},refreshDerivedArtifacts:u}=r,l=h(n.checkpointTree),[m,d]=await Promise.all([Je(e,t,a,{commandOptions:o,
|
|
1513
|
+
project:c}),R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:c})]),p=m.commit;if(await ke(e,t,p,
|
|
1504
1514
|
d,{commandOptions:o,project:c}))throw O("Canonical history no longer descends from this session's saved base.","vibe64_s\
|
|
1505
|
-
ession_save_history_diverged");let f=await
|
|
1515
|
+
ession_save_history_diverged");let f=await X(e,t,p,d,{commandOptions:o,project:c});if(p!==t.baseCommit&&!f)throw O("The \
|
|
1506
1516
|
saved branch has changed. Update this session before saving its work.","vibe64_session_save_update_required",{canonicalCommit:p,
|
|
1507
|
-
reconciledCommit:t.baseCommit,updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed"});let g=await
|
|
1508
|
-
{baseCommit:t.baseCommit,canonicalCommit:p,sessionHead:d,worktreeTree:l},{commandOptions:o,project:c}),w=new Set(
|
|
1517
|
+
reconciledCommit:t.baseCommit,updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed"});let g=await Ye(e,t,
|
|
1518
|
+
{baseCommit:t.baseCommit,canonicalCommit:p,sessionHead:d,worktreeTree:l},{commandOptions:o,project:c}),w=new Set(We(i)),
|
|
1509
1519
|
_=g.changedPaths.filter(N=>!w.has(N));if(!_.length)throw O("This session has no work to save.","vibe64_session_save_no_c\
|
|
1510
|
-
hanges");let S=await
|
|
1511
|
-
tree:I}=await
|
|
1512
|
-
|
|
1513
|
-
project:c}),C=await
|
|
1514
|
-
changeBaseCommit,changedPaths:_,...A?{derivedArtifactsKept:A}:{},mergedTree:I,preparedRef:T,saveCommit:
|
|
1515
|
-
C)}}async function
|
|
1520
|
+
hanges");let S=await gr(e,t,{commandOptions:o,derivedArtifactPaths:i,project:c,sourceCommit:p,tree:l}),{derivedArtifactsKept:A,
|
|
1521
|
+
tree:I}=await _r(e,t,{baseCommit:p,commandOptions:o,derivedArtifactPaths:i,project:c,refreshDerivedArtifacts:u,tree:S}),
|
|
1522
|
+
P=await Ba(e,t,{canonicalCommit:p,commandOptions:o,mergedTree:I,message:s,project:c}),T=await km(e,t,a,P,{commandOptions:o,
|
|
1523
|
+
project:c}),C=await R(e,t,["show","-s","--format=%ae",P],{commandOptions:o,project:c});return{canonicalCommit:p,changeBaseCommit:g.
|
|
1524
|
+
changeBaseCommit,changedPaths:_,...A?{derivedArtifactsKept:A}:{},mergedTree:I,preparedRef:T,saveCommit:P,standInIdentity:cn(
|
|
1525
|
+
C)}}async function $m(e,t,r={}){let{commandOptions:n={},onPublicationAttempt:o,prepared:i={},project:s={}}=r;return Va(e,
|
|
1516
1526
|
t,{canonicalCommit:h(i.canonicalCommit),saveCommit:h(i.saveCommit)},{commandOptions:n,onPublicationAttempt:o,project:s})}
|
|
1517
|
-
function
|
|
1527
|
+
function Mm(e,t,r,n,o){return{baseCommit:e.baseCommit,cacheMaintenance:o.cacheMaintenance,canonicalCommit:r.canonicalCommit,
|
|
1518
1528
|
changeBaseCommit:r.changeBaseCommit,changedPaths:r.changedPaths,checkpointCommit:t.checkpointCommit,...r.derivedArtifactsKept?
|
|
1519
1529
|
{derivedArtifactsKept:r.derivedArtifactsKept}:{},checkpointTree:t.checkpointTree,mergedTree:r.mergedTree,mode:e.mode,ok:!0,
|
|
1520
1530
|
operationId:t.operationId,preparedRef:r.preparedRef,saveCommit:r.saveCommit,sessionHead:t.sessionHead,standInIdentity:r.
|
|
1521
|
-
standInIdentity===!0,status:o.status,verifiedCommit:n,...o}}function
|
|
1531
|
+
standInIdentity===!0,status:o.status,verifiedCommit:n,...o}}function Lm(e,t){return e.mode!==J?{attempted:!1,kind:"none",
|
|
1522
1532
|
retryable:!1,status:"not_applicable"}:{attempted:!1,branch:e.branch,kind:"github_mirror",retryable:!1,status:"deferred",
|
|
1523
|
-
verifiedCommit:t}}async function
|
|
1524
|
-
let s=U(o,r);return n=
|
|
1525
|
-
project:r})}async function
|
|
1526
|
-
operationId:i=
|
|
1527
|
-
onProgress:l=
|
|
1533
|
+
verifiedCommit:t}}async function eo({commandOptions:e={},operationId:t="",project:r={},runCommand:n=x,session:o={},verifiedCommit:i=""}={}){
|
|
1534
|
+
let s=U(o,r);return n=V(n,s,r,{label:"Maintaining saved repository cache",operationId:t}),Qn(n,s,h(i),{commandOptions:e,
|
|
1535
|
+
project:r})}async function jm(e,t,r,n={}){h(r)&&await yt(e,t,fr(t,r),n)}async function Ya({checkpoint:e=null,commandOptions:t={},deferCacheMaintenance:r=!1,derivedArtifactPaths:n=[],message:o="",
|
|
1536
|
+
operationId:i=Fa.randomUUID(),project:s={},refreshDerivedArtifacts:a,runCommand:c=x,runProjectSourceExclusive:u=async d=>d(),
|
|
1537
|
+
onProgress:l=ge,session:m={}}={}){let d=U(m,s);return c=V(c,d,s,{label:"Saving session work",operationId:i}),await l({kind:"\
|
|
1528
1538
|
lock",message:"Waiting for exclusive repository access.",stage:"repository-lock"}),u(async()=>{await l({baseCommit:d.baseCommit,
|
|
1529
1539
|
branch:d.branch,kind:"checkpoint",message:"Capturing the complete session worktree.",mode:d.mode,operationId:i,stage:"ch\
|
|
1530
|
-
eckpointing"});let p;e?(await
|
|
1531
|
-
p=await
|
|
1540
|
+
eckpointing"});let p;e?(await Ke(c,d,{commandOptions:t,project:s}),p=await Nm(c,d,e,{commandOptions:t,operationId:i,project:s})):
|
|
1541
|
+
p=await Wa(c,d,{commandOptions:t,operationId:i,project:s}),await l({checkpointCommit:p.checkpointCommit,checkpointTree:p.
|
|
1532
1542
|
checkpointTree,kind:"checkpoint",message:"Session checkpoint captured.",sessionHead:p.sessionHead,stage:"checkpointed"}),
|
|
1533
|
-
await l({kind:"canonical",message:"Reading the current canonical branch.",stage:"canonical-reading"});let f=await
|
|
1543
|
+
await l({kind:"canonical",message:"Reading the current canonical branch.",stage:"canonical-reading"});let f=await xm(c,d,
|
|
1534
1544
|
{checkpoint:p,commandOptions:t,derivedArtifactPaths:n,message:o,operationId:i,project:s,refreshDerivedArtifacts:a}),g=!1,
|
|
1535
1545
|
w;try{await l({expectedCanonicalCommit:f.canonicalCommit,kind:"canonical",message:"Canonical branch read.",stage:"canoni\
|
|
1536
1546
|
cal-read"}),await l({expectedCanonicalCommit:f.canonicalCommit,kind:"publish",mergedTree:f.mergedTree,message:"Save comm\
|
|
1537
1547
|
it prepared.",proposedCommit:f.saveCommit,stage:"prepared"}),await l({kind:"publish",message:"Pushing the Save commit.",
|
|
1538
|
-
stage:"publishing"}),w=await
|
|
1548
|
+
stage:"publishing"}),w=await $m(c,d,{commandOptions:t,onPublicationAttempt(){g=!0},prepared:f,project:s})}catch(A){throw g||
|
|
1539
1549
|
await y(c,d,["update-ref","-d",f.preparedRef,f.saveCommit],{commandOptions:t,project:s}),A}await l({kind:"publish",message:"\
|
|
1540
1550
|
Canonical Save commit verified.",stage:"published",verifiedCommit:w}),await l({kind:"reconcile",message:"Reconciling the\
|
|
1541
|
-
session onto the saved commit.",stage:"reconciling"});let _=await
|
|
1542
|
-
project:s,saveCommit:f.saveCommit,sessionHead:p.sessionHead}),S=r?
|
|
1551
|
+
session onto the saved commit.",stage:"reconciling"});let _=await Zn(c,d,{checkpointTree:p.checkpointTree,commandOptions:t,
|
|
1552
|
+
project:s,saveCommit:f.saveCommit,sessionHead:p.sessionHead}),S=r?Lm(d,w):await eo({commandOptions:t,operationId:i,project:s,
|
|
1543
1553
|
runCommand:c,session:m,verifiedCommit:w});return S.retryable===!0&&await l({cacheMaintenance:S,kind:"cache-warning",message:S.
|
|
1544
|
-
message,stage:"cache-maintenance-warning"}),r||await
|
|
1545
|
-
..._})},{operation:`save-session:${d.sessionId}`})}var
|
|
1546
|
-
return
|
|
1547
|
-
pdate-failure":
|
|
1548
|
-
return
|
|
1554
|
+
message,stage:"cache-maintenance-warning"}),r||await jm(c,d,i,{commandOptions:t,project:s}),Mm(d,p,f,w,{cacheMaintenance:S,
|
|
1555
|
+
..._})},{operation:`save-session:${d.sessionId}`})}var Dm=1024*1024,Um={"change-diff":Xn,changes:yr,"check-updates":Ma,save:async e=>{let{refreshGenesisCities:t}=await import("@local/vibe64-genesis/server");
|
|
1556
|
+
return Ya({...e,deferCacheMaintenance:!0,refreshDerivedArtifacts:t})},"save-maintenance":eo,"save-message":qa,work:bt,"u\
|
|
1557
|
+
pdate-failure":Ga,"update-checkpoint":La,"update-prepare":ja,"update-derived":async e=>{let{refreshGenesisCities:t}=await import("@local/vibe64-genesis/server");
|
|
1558
|
+
return Da({...e,refreshDerivedArtifacts:t})},"update-apply":Ua},Ka=new AbortController;function Gm(e={}){return Ee(e.command,
|
|
1549
1559
|
e.args,{cwd:e.cwd,env:{...process.env,...e.env||{}},execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,outputEncoding:e.
|
|
1550
|
-
outputEncoding,signal:
|
|
1551
|
-
String(t||""),Buffer.byteLength(e)>
|
|
1552
|
-
e||"{}")}function
|
|
1560
|
+
outputEncoding,signal:Ka.signal,timeout:e.timeout})}async function Hm(){let e="";for await(let t of process.stdin)if(e+=
|
|
1561
|
+
String(t||""),Buffer.byteLength(e)>Dm)throw new Error("Session repository operation input is too large.");return JSON.parse(
|
|
1562
|
+
e||"{}")}function Bm(e){return{error:{code:String(e?.code||"vibe64_session_work_operation_failed"),details:e?.details&&typeof e.
|
|
1553
1563
|
details=="object"&&!Array.isArray(e.details)?e.details:{},message:String(e?.message||"Session repository operation faile\
|
|
1554
|
-
d."),...e?.messageCode?{messageCode:e.messageCode,messageParams:e.messageParams}:{},status:e instanceof
|
|
1555
|
-
ok:!1}}try{let e=await
|
|
1564
|
+
d."),...e?.messageCode?{messageCode:e.messageCode,messageParams:e.messageParams}:{},status:e instanceof re?e.status:500},
|
|
1565
|
+
ok:!1}}try{let e=await Hm();e?.stoppable===!0&&process.once("SIGTERM",()=>Ka.abort()),tn(e?.hostProfile||null);let t=Um[String(
|
|
1556
1566
|
e?.operation||"")];if(!t){let n=new Error("Unsupported session repository operation.");throw n.code="vibe64_session_work\
|
|
1557
|
-
_operation_unsupported",n}let r=await t({...e.input&&typeof e.input=="object"?e.input:{},runCommand:
|
|
1558
|
-
write(JSON.stringify({ok:!0,value:r}))}catch(e){process.stdout.write(JSON.stringify(
|
|
1567
|
+
_operation_unsupported",n}let r=await t({...e.input&&typeof e.input=="object"?e.input:{},runCommand:Gm});process.stdout.
|
|
1568
|
+
write(JSON.stringify({ok:!0,value:r}))}catch(e){process.stdout.write(JSON.stringify(Bm(e))),process.exitCode=1}
|