vibe64 0.1.72 → 0.1.74
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/dist/assets/{GithubBrowserTabs-D8twaXtF.js → GithubBrowserTabs-__1ieC1c.js} +1 -1
- package/dist/assets/GithubBrowserTabs-__1ieC1c.js.br +0 -0
- package/dist/assets/GithubBrowserTabs-__1ieC1c.js.gz +0 -0
- package/dist/assets/LocalDatabaseServer-dK29B76L.js +2 -0
- package/dist/assets/LocalDatabaseServer-dK29B76L.js.br +0 -0
- package/dist/assets/LocalDatabaseServer-dK29B76L.js.gz +0 -0
- package/dist/assets/{Vibe64DashboardPageHeader-Bd4WMiDV.js → Vibe64DashboardPageHeader-DH1YCSF1.js} +1 -1
- package/dist/assets/Vibe64DashboardPageHeader-DH1YCSF1.js.br +0 -0
- package/dist/assets/Vibe64DashboardPageHeader-DH1YCSF1.js.gz +0 -0
- package/dist/assets/{Vibe64DatabaseWorkspace-CprnbQkL.js → Vibe64DatabaseWorkspace-csnEOYGD.js} +1 -1
- package/dist/assets/Vibe64DatabaseWorkspace-csnEOYGD.js.br +0 -0
- package/dist/assets/Vibe64DatabaseWorkspace-csnEOYGD.js.gz +0 -0
- package/dist/assets/{Vibe64FileArea-CcKMG84N.js → Vibe64FileArea-CeiAmwiT.js} +1 -1
- package/dist/assets/Vibe64FileArea-CeiAmwiT.js.br +0 -0
- package/dist/assets/Vibe64FileArea-CeiAmwiT.js.gz +0 -0
- package/dist/assets/{Vibe64OutputControls-D0l0i_kq.js → Vibe64OutputControls-nFkMTVFI.js} +1 -1
- package/dist/assets/Vibe64OutputControls-nFkMTVFI.js.br +0 -0
- package/dist/assets/Vibe64OutputControls-nFkMTVFI.js.gz +0 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-EkT8pmMV.js → Vibe64RepositoryWorkspace-BcGZsRIF.js} +1 -1
- package/dist/assets/Vibe64RepositoryWorkspace-BcGZsRIF.js.br +0 -0
- package/dist/assets/Vibe64RepositoryWorkspace-BcGZsRIF.js.gz +0 -0
- package/dist/assets/{Vibe64SessionFiles-Qk_kv1Q8.js → Vibe64SessionFiles-BrNoYV6c.js} +1 -1
- package/dist/assets/Vibe64SessionFiles-BrNoYV6c.js.br +0 -0
- package/dist/assets/Vibe64SessionFiles-BrNoYV6c.js.gz +0 -0
- package/dist/assets/{Vibe64SessionSourceEditor-oYTMnob5.js → Vibe64SessionSourceEditor-Pz9DR_lm.js} +1 -1
- package/dist/assets/Vibe64SessionSourceEditor-Pz9DR_lm.js.br +0 -0
- package/dist/assets/Vibe64SessionSourceEditor-Pz9DR_lm.js.gz +0 -0
- package/dist/assets/{Vibe64UiStoryboardView-BZh1b5Xt.js → Vibe64UiStoryboardView-D8Z-WkVp.js} +1 -1
- package/dist/assets/Vibe64UiStoryboardView-D8Z-WkVp.js.br +0 -0
- package/dist/assets/Vibe64UiStoryboardView-D8Z-WkVp.js.gz +0 -0
- package/dist/assets/{_pageId_-xB2NWBqF.js → _pageId_-DsnrOQFl.js} +1 -1
- package/dist/assets/{_sessionId_-g78evnUW.js → _sessionId_-DI83WzOB.js} +1 -1
- package/dist/assets/_sessionId_-DI83WzOB.js.br +0 -0
- package/dist/assets/_sessionId_-DI83WzOB.js.gz +0 -0
- package/dist/assets/{_sessionTool_-cw3WaYPb.js → _sessionTool_-BkRFpBKI.js} +1 -1
- package/dist/assets/{access-oIeDSza-.js → access-CD1NLU2z.js} +1 -1
- package/dist/assets/access-CD1NLU2z.js.br +0 -0
- package/dist/assets/access-CD1NLU2z.js.gz +0 -0
- package/dist/assets/{app-0jq6SFSn.js → app-NJHCyI2M.js} +1 -1
- package/dist/assets/app-NJHCyI2M.js.br +0 -0
- package/dist/assets/app-NJHCyI2M.js.gz +0 -0
- package/dist/assets/{changes-Db1dzMsx.js → changes-Bg5fn535.js} +1 -1
- package/dist/assets/{client-DW9uggbF.js → client-B5-KiJ_k.js} +2 -2
- package/dist/assets/client-B5-KiJ_k.js.br +0 -0
- package/dist/assets/client-B5-KiJ_k.js.gz +0 -0
- package/dist/assets/{client-Lmbw-Ygm.js → client-DHAysNQ_.js} +2 -2
- package/dist/assets/client-DHAysNQ_.js.br +0 -0
- package/dist/assets/client-DHAysNQ_.js.gz +0 -0
- package/dist/assets/{dashboard-CUnY0-1W.js → dashboard-Bzs2mNSD.js} +1 -1
- package/dist/assets/{english-definitions-DovEdEkp.js → english-definitions-jEDFqPtl.js} +1 -1
- package/dist/assets/english-definitions-jEDFqPtl.js.br +0 -0
- package/dist/assets/english-definitions-jEDFqPtl.js.gz +0 -0
- package/dist/assets/{env-CZritO-9.js → env-CuVAcxrg.js} +1 -1
- package/dist/assets/env-CuVAcxrg.js.br +0 -0
- package/dist/assets/env-CuVAcxrg.js.gz +0 -0
- package/dist/assets/{error-o4gXqrKI.js → error-vtsBf2sc.js} +1 -1
- package/dist/assets/error-vtsBf2sc.js.br +0 -0
- package/dist/assets/error-vtsBf2sc.js.gz +0 -0
- package/dist/assets/{fileTypes-Bqlch7JV.js → fileTypes-BtIfp_s4.js} +1 -1
- package/dist/assets/fileTypes-BtIfp_s4.js.br +0 -0
- package/dist/assets/fileTypes-BtIfp_s4.js.gz +0 -0
- package/dist/assets/{health-LP0Mz2qB.js → health-hZ8hCq4g.js} +1 -1
- package/dist/assets/health-hZ8hCq4g.js.br +0 -0
- package/dist/assets/health-hZ8hCq4g.js.gz +0 -0
- package/dist/assets/{history-DkjaInmh.js → history-BUD8OO2u.js} +1 -1
- package/dist/assets/history-BUD8OO2u.js.br +0 -0
- package/dist/assets/history-BUD8OO2u.js.gz +0 -0
- package/dist/assets/{index-C_LlHM8w.js → index-DW2-Y5r1.js} +4 -4
- package/dist/assets/index-DW2-Y5r1.js.br +0 -0
- package/dist/assets/index-DW2-Y5r1.js.gz +0 -0
- package/dist/assets/{integrations-C6_N7WwF.js → integrations-mJUuC1tA.js} +1 -1
- package/dist/assets/integrations-mJUuC1tA.js.br +0 -0
- package/dist/assets/{integrations-C6_N7WwF.js.gz → integrations-mJUuC1tA.js.gz} +0 -0
- package/dist/assets/{issues-DAJzymvp.js → issues-D6TrPRr_.js} +1 -1
- package/dist/assets/issues-D6TrPRr_.js.br +0 -0
- package/dist/assets/issues-D6TrPRr_.js.gz +0 -0
- package/dist/assets/{learning-6W-aGxBH.js → learning-DSNeeTtU.js} +1 -1
- package/dist/assets/{pages-BePUPkVf.js → pages-DpJxIaJ-.js} +1 -1
- package/dist/assets/{pages-C31UYhFG.js → pages-cUFHVIQj.js} +1 -1
- package/dist/assets/pages-cUFHVIQj.js.br +1 -0
- package/dist/assets/pages-cUFHVIQj.js.gz +0 -0
- package/dist/assets/{project-Bw_8Bd8D.js → project-D45_Rd6Y.js} +6 -6
- package/dist/assets/project-D45_Rd6Y.js.br +0 -0
- package/dist/assets/project-D45_Rd6Y.js.gz +0 -0
- package/dist/assets/{project-files-CdcCb8jL.js → project-files-DgvpUk1M.js} +1 -1
- package/dist/assets/project-files-DgvpUk1M.js.br +0 -0
- package/dist/assets/project-files-DgvpUk1M.js.gz +0 -0
- package/dist/assets/{project-shared-ShellOutlet-CVomMDvt.js → project-shared-ShellOutlet-eIh5yfRJ.js} +1 -1
- package/dist/assets/project-shared-ShellOutlet-eIh5yfRJ.js.br +0 -0
- package/dist/assets/project-shared-ShellOutlet-eIh5yfRJ.js.gz +0 -0
- package/dist/assets/{project-shared-VBottomSheet-Bu53ETe9.js → project-shared-VBottomSheet-XWVEiPmQ.js} +1 -1
- package/dist/assets/project-shared-VBottomSheet-XWVEiPmQ.js.br +0 -0
- package/dist/assets/project-shared-VBottomSheet-XWVEiPmQ.js.gz +0 -0
- package/dist/assets/{project-shared-VToolbar-Bd4xlEK-.js → project-shared-VToolbar-DKJZQDcP.js} +1 -1
- package/dist/assets/project-shared-VToolbar-DKJZQDcP.js.br +0 -0
- package/dist/assets/project-shared-VToolbar-DKJZQDcP.js.gz +0 -0
- package/dist/assets/{project-shared-pageNames-BVgvVg71.js → project-shared-pageNames-CWXyQBuT.js} +1 -1
- package/dist/assets/project-shared-pageNames-CWXyQBuT.js.br +0 -0
- package/dist/assets/project-shared-pageNames-CWXyQBuT.js.gz +0 -0
- package/dist/assets/{publish-a6jL_LlB.js → publish-BKAvPixQ.js} +1 -1
- package/dist/assets/publish-BKAvPixQ.js.br +0 -0
- package/dist/assets/publish-BKAvPixQ.js.gz +0 -0
- package/dist/assets/{pull-requests-DoyqPC5b.js → pull-requests-DycdPcXY.js} +1 -1
- package/dist/assets/pull-requests-DycdPcXY.js.br +0 -0
- package/dist/assets/pull-requests-DycdPcXY.js.gz +0 -0
- package/dist/assets/{repository-MUZOzMUA.js → repository-BugUartC.js} +1 -1
- package/dist/assets/{session-CtbSoHK-.js → session-B4iZufWI.js} +1 -1
- package/dist/assets/session-B4iZufWI.js.br +0 -0
- package/dist/assets/session-B4iZufWI.js.gz +0 -0
- package/dist/assets/{settings-BdbR3bEK.js → settings-BrO7TeLW.js} +1 -1
- package/dist/assets/settings-BrO7TeLW.js.br +0 -0
- package/dist/assets/settings-BrO7TeLW.js.gz +0 -0
- package/dist/assets/{useArchivedVibe64Sessions-DXTj9b9K.js → useArchivedVibe64Sessions-DdavJ9tr.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-DdavJ9tr.js.br +0 -0
- package/dist/assets/useArchivedVibe64Sessions-DdavJ9tr.js.gz +0 -0
- package/dist/assets/{vibe64AttachmentDownload-BODXLh6N.js → vibe64AttachmentDownload-DjRt5OfX.js} +1 -1
- package/dist/assets/{vibe64SavedEnvValues-BbuzhsJf.js → vibe64SavedEnvValues-YEXrs2xe.js} +1 -1
- package/dist/assets/{vue-flow-core-6H3SH19E.js → vue-flow-core-DzmtR5x-.js} +1 -1
- package/dist/assets/vue-flow-core-DzmtR5x-.js.br +0 -0
- package/dist/assets/vue-flow-core-DzmtR5x-.js.gz +0 -0
- package/dist/index.html +2 -2
- package/docs/colleague-usage/connected-projects.md +3 -0
- package/docs/colleague-usage/connected-repositories.md +16 -4
- package/docs/colleague-usage/workspace-preparation.md +9 -1
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/locales/en.json +2 -2
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/patterns/event-delivery/PATTERN.md +1 -1
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +2 -0
- package/node_modules/@jskit-ai/kernel/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/patterns/realtime-application/PATTERN.md +2 -2
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +496 -490
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +6 -6
- package/package.json +13 -13
- package/server.bundle.mjs +28596 -28568
- package/dist/assets/GithubBrowserTabs-D8twaXtF.js.br +0 -0
- package/dist/assets/GithubBrowserTabs-D8twaXtF.js.gz +0 -0
- package/dist/assets/LocalDatabaseServer-BjJgeNye.js +0 -2
- package/dist/assets/LocalDatabaseServer-BjJgeNye.js.br +0 -0
- package/dist/assets/LocalDatabaseServer-BjJgeNye.js.gz +0 -0
- package/dist/assets/Vibe64DashboardPageHeader-Bd4WMiDV.js.br +0 -0
- package/dist/assets/Vibe64DashboardPageHeader-Bd4WMiDV.js.gz +0 -0
- package/dist/assets/Vibe64DatabaseWorkspace-CprnbQkL.js.br +0 -0
- package/dist/assets/Vibe64DatabaseWorkspace-CprnbQkL.js.gz +0 -0
- package/dist/assets/Vibe64FileArea-CcKMG84N.js.br +0 -0
- package/dist/assets/Vibe64FileArea-CcKMG84N.js.gz +0 -0
- package/dist/assets/Vibe64OutputControls-D0l0i_kq.js.br +0 -0
- package/dist/assets/Vibe64OutputControls-D0l0i_kq.js.gz +0 -0
- package/dist/assets/Vibe64RepositoryWorkspace-EkT8pmMV.js.br +0 -0
- package/dist/assets/Vibe64RepositoryWorkspace-EkT8pmMV.js.gz +0 -0
- package/dist/assets/Vibe64SessionFiles-Qk_kv1Q8.js.br +0 -0
- package/dist/assets/Vibe64SessionFiles-Qk_kv1Q8.js.gz +0 -0
- package/dist/assets/Vibe64SessionSourceEditor-oYTMnob5.js.br +0 -0
- package/dist/assets/Vibe64SessionSourceEditor-oYTMnob5.js.gz +0 -0
- package/dist/assets/Vibe64UiStoryboardView-BZh1b5Xt.js.br +0 -0
- package/dist/assets/Vibe64UiStoryboardView-BZh1b5Xt.js.gz +0 -0
- package/dist/assets/_sessionId_-g78evnUW.js.br +0 -0
- package/dist/assets/_sessionId_-g78evnUW.js.gz +0 -0
- package/dist/assets/access-oIeDSza-.js.br +0 -0
- package/dist/assets/access-oIeDSza-.js.gz +0 -0
- package/dist/assets/app-0jq6SFSn.js.br +0 -0
- package/dist/assets/app-0jq6SFSn.js.gz +0 -0
- package/dist/assets/client-DW9uggbF.js.br +0 -0
- package/dist/assets/client-DW9uggbF.js.gz +0 -0
- package/dist/assets/client-Lmbw-Ygm.js.br +0 -0
- package/dist/assets/client-Lmbw-Ygm.js.gz +0 -0
- package/dist/assets/english-definitions-DovEdEkp.js.br +0 -0
- package/dist/assets/english-definitions-DovEdEkp.js.gz +0 -0
- package/dist/assets/env-CZritO-9.js.br +0 -0
- package/dist/assets/env-CZritO-9.js.gz +0 -0
- package/dist/assets/error-o4gXqrKI.js.br +0 -0
- package/dist/assets/error-o4gXqrKI.js.gz +0 -0
- package/dist/assets/fileTypes-Bqlch7JV.js.br +0 -0
- package/dist/assets/fileTypes-Bqlch7JV.js.gz +0 -0
- package/dist/assets/health-LP0Mz2qB.js.br +0 -0
- package/dist/assets/health-LP0Mz2qB.js.gz +0 -0
- package/dist/assets/history-DkjaInmh.js.br +0 -0
- package/dist/assets/history-DkjaInmh.js.gz +0 -0
- package/dist/assets/index-C_LlHM8w.js.br +0 -0
- package/dist/assets/index-C_LlHM8w.js.gz +0 -0
- package/dist/assets/integrations-C6_N7WwF.js.br +0 -0
- package/dist/assets/issues-DAJzymvp.js.br +0 -0
- package/dist/assets/issues-DAJzymvp.js.gz +0 -0
- package/dist/assets/pages-C31UYhFG.js.br +0 -0
- package/dist/assets/pages-C31UYhFG.js.gz +0 -0
- package/dist/assets/project-Bw_8Bd8D.js.br +0 -0
- package/dist/assets/project-Bw_8Bd8D.js.gz +0 -0
- package/dist/assets/project-files-CdcCb8jL.js.br +0 -0
- package/dist/assets/project-files-CdcCb8jL.js.gz +0 -0
- package/dist/assets/project-shared-ShellOutlet-CVomMDvt.js.br +0 -0
- package/dist/assets/project-shared-ShellOutlet-CVomMDvt.js.gz +0 -0
- package/dist/assets/project-shared-VBottomSheet-Bu53ETe9.js.br +0 -0
- package/dist/assets/project-shared-VBottomSheet-Bu53ETe9.js.gz +0 -0
- package/dist/assets/project-shared-VToolbar-Bd4xlEK-.js.br +0 -0
- package/dist/assets/project-shared-VToolbar-Bd4xlEK-.js.gz +0 -0
- package/dist/assets/project-shared-pageNames-BVgvVg71.js.br +0 -0
- package/dist/assets/project-shared-pageNames-BVgvVg71.js.gz +0 -0
- package/dist/assets/publish-a6jL_LlB.js.br +0 -0
- package/dist/assets/publish-a6jL_LlB.js.gz +0 -0
- package/dist/assets/pull-requests-DoyqPC5b.js.br +0 -0
- package/dist/assets/pull-requests-DoyqPC5b.js.gz +0 -0
- package/dist/assets/session-CtbSoHK-.js.br +0 -0
- package/dist/assets/session-CtbSoHK-.js.gz +0 -0
- package/dist/assets/settings-BdbR3bEK.js.br +0 -0
- package/dist/assets/settings-BdbR3bEK.js.gz +0 -0
- package/dist/assets/useArchivedVibe64Sessions-DXTj9b9K.js.br +0 -0
- package/dist/assets/useArchivedVibe64Sessions-DXTj9b9K.js.gz +0 -0
- package/dist/assets/vue-flow-core-6H3SH19E.js.br +0 -0
- package/dist/assets/vue-flow-core-6H3SH19E.js.gz +0 -0
|
@@ -1,429 +1,430 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
|
-
import E from"node:process";import{spawnSync as
|
|
4
|
-
fchmodSync as
|
|
5
|
-
unlinkSync as
|
|
6
|
-
import
|
|
7
|
-
realpathSync as
|
|
8
|
-
|
|
9
|
-
n.uid!==t||(n.mode&18)!==0)throw new Error("A Vibe64 registry is not a directory only root can change.")}catch(n){throw
|
|
10
|
-
r),n}return r}function
|
|
11
|
-
|
|
3
|
+
import E from"node:process";import{spawnSync as bn}from"node:child_process";import{createHash as Qi}from"node:crypto";import{closeSync as C,constants as Nn,
|
|
4
|
+
fchmodSync as es,fchownSync as ts,fstatSync as rs,lstatSync as Tn,openSync as At,readdirSync as cr,readFileSync as ns,rmSync as os,
|
|
5
|
+
unlinkSync as is}from"node:fs";import b from"node:path";import xn from"node:process";import{spawnSync as Ne}from"node:child_process";import{closeSync as Jo,mkdirSync as qo,rmSync as Fr,symlinkSync as Zo}from"node:fs";
|
|
6
|
+
import Pe from"node:path";import Pt from"node:process";import{closeSync as Re,constants as W,fstatSync as Vr,fsyncSync as Ho,lstatSync as Xo,mkdirSync as Yo,openSync as ke,readSync as zo,
|
|
7
|
+
realpathSync as Gr}from"node:fs";import Z from"node:path";var $=W.O_RDONLY|W.O_DIRECTORY|W.O_NOFOLLOW,it=W.O_WRONLY|W.O_CREAT|
|
|
8
|
+
W.O_EXCL|W.O_NOFOLLOW,Ko=W.O_RDONLY|W.O_NOFOLLOW|W.O_NONBLOCK;function H(e="",t=0){let r=ke(e,$);try{let n=Vr(r);if(!n.isDirectory()||
|
|
9
|
+
n.uid!==t||(n.mode&18)!==0)throw new Error("A Vibe64 registry is not a directory only root can change.")}catch(n){throw Re(
|
|
10
|
+
r),n}return r}function h(e,t=""){return Z.join(`/proc/self/fd/${e}`,t)}function st(e=""){let t=ke(e,$);try{Ho(t)}finally{
|
|
11
|
+
Re(t)}}function ue(e="",t=511){try{return Yo(e,{mode:t}),!0}catch(r){if(r?.code!=="EEXIST")throw r;return!1}}function ie(e=""){
|
|
12
12
|
let t=String(e);if(!t||t==="."||t===".."||/[/\0]/u.test(t))throw new Error("Vibe64 exec helper rejected an unsafe file n\
|
|
13
|
-
ame.");return t}function
|
|
14
|
-
r),r=o}}catch(n){throw
|
|
15
|
-
t)),Ko);try{let i=
|
|
13
|
+
ame.");return t}function Q(e="",t=[]){let r=ke(e,W.O_RDONLY|W.O_DIRECTORY);try{for(let n of t){let o=ke(h(r,ie(n)),$);Re(
|
|
14
|
+
r),r=o}}catch(n){throw Re(r),n}return r}function T(e,t="",{maxBytes:r=0,othersMayWrite:n=!0,uid:o=-1}={}){let s=ke(h(e,ie(
|
|
15
|
+
t)),Ko);try{let i=Vr(s);if(!i.isFile()||i.uid!==o||!n&&(i.mode&18)!==0)throw Object.assign(new Error("Vibe64 exec helper\
|
|
16
16
|
refused a file that is not its owner's regular file."),{code:"EVIBE64UNSAFEFILE"});let a=Buffer.alloc(r+1),c=0;for(;c<a.
|
|
17
17
|
length;){let l=zo(s,a,c,a.length-c,null);if(l===0)break;c+=l}if(c>r)throw Object.assign(new Error("Vibe64 exec helper re\
|
|
18
|
-
fused a file that is too large."),{code:"EVIBE64UNSAFEFILE"});return a.toString("utf8",0,c)}finally{
|
|
19
|
-
let r=String(e||"").trim(),n=String(t||"").trim();if(!r||!n)return[];let o=
|
|
20
|
-
o===".."||o.startsWith(`..${
|
|
21
|
-
let r=
|
|
22
|
-
r)}var $t=[".local","state","vibe64","users"],Dt=64*1024,Ct=/^[a-z][a-z0-9_-]{0,61}[a-z0-9]$/u,k="vibe64",D="v64d_",
|
|
18
|
+
fused a file that is too large."),{code:"EVIBE64UNSAFEFILE"});return a.toString("utf8",0,c)}finally{Re(s)}}function R(e="",t=""){
|
|
19
|
+
let r=String(e||"").trim(),n=String(t||"").trim();if(!r||!n)return[];let o=Z.relative(Z.resolve(r),Z.resolve(n));return!o||
|
|
20
|
+
o===".."||o.startsWith(`..${Z.sep}`)||Z.isAbsolute(o)?[]:o.split(Z.sep).filter(Boolean)}function N(e,{allowMissingLeaf:t=!1}={}){
|
|
21
|
+
let r=Z.resolve(e);if(t)try{Xo(r)}catch(n){if(n.code!=="ENOENT")throw n;return Z.join(Gr(Z.dirname(r)),Z.basename(r))}return Gr(
|
|
22
|
+
r)}var $t=[".local","state","vibe64","users"],Dt=64*1024,Ct=/^[a-z][a-z0-9_-]{0,61}[a-z0-9]$/u,k="vibe64",D="v64d_",ge="/va\
|
|
23
23
|
r/lib/vibe64",Qo=new Set(["root"]),ei="/etc/vibe64";function ti(e=Pt.env){let t=String(e.VIBE64_HOST_SETTINGS_ROOT??"");
|
|
24
|
-
if(!t)return ei;if(!
|
|
24
|
+
if(!t)return ei;if(!Pe.isAbsolute(t)||Pe.resolve(t)!==t||t==="/")throw new Error(`Vibe64 exec helper refused its setting\
|
|
25
25
|
s folder VIBE64_HOST_SETTINGS_ROOT=${JSON.stringify(t)}: it is not an absolute, normalized path other than /.`);return t}
|
|
26
|
-
var
|
|
26
|
+
var G=ti(),at="v64a_",be="/usr/sbin/nologin";function w(e=""){let t=String(e||"").trim();if(!t||/[/:\\\r\n]/u.test(t))throw new Error(
|
|
27
27
|
"Vibe64 exec helper rejected an unsafe username.");return t}function ri(e=""){if(!Ct.test(e))throw new Error("Vibe64 exe\
|
|
28
|
-
c helper rejected an unsupported username.")}function
|
|
29
|
-
nix accounts cannot be managed as app users.");if(e.startsWith(
|
|
28
|
+
c helper rejected an unsupported username.")}function le(e=""){if(ri(e),e.startsWith(D))throw new Error("Vibe64 daemon U\
|
|
29
|
+
nix accounts cannot be managed as app users.");if(e.startsWith(at))throw new Error("Vibe64 application accounts are neve\
|
|
30
30
|
r people.");if(Qo.has(e))throw new Error("Privileged Unix accounts cannot be managed as Vibe64 app users.")}function P(e=""){
|
|
31
31
|
let t=Ne("getent",["passwd",e],{encoding:"utf8"});if(t.status!==0)throw new Error(`OS user was not found: ${e}`);let n=String(
|
|
32
32
|
t.stdout||"").split(/\r?\n/u)[0].split(":");if(n.length<7||n[0]!==e)throw new Error(`OS user was not found: ${e}`);let o=Number(
|
|
33
33
|
n[2]),s=Number(n[3]);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(s))throw new Error(`OS user has invalid uid/gid:\
|
|
34
|
-
${e}`);return{gid:s,home:n[5],shell:n[6],uid:o,username:e}}function U(){let e=w(Pt.env.SUDO_USER||"");return P(e)}function
|
|
34
|
+
${e}`);return{gid:s,home:n[5],shell:n[6],uid:o,username:e}}function U(){let e=w(Pt.env.SUDO_USER||"");return P(e)}function $e(e=""){
|
|
35
35
|
let t=Ne("id",["-nG",e],{encoding:"utf8"});if(t.status!==0)throw new Error(`Could not read the groups of OS user ${e}.`);
|
|
36
|
-
return String(t.stdout||"").trim().split(/\s+/u)}function
|
|
37
|
-
`OS user is not enabled for the shared Vibe64 group: ${e}`)}function
|
|
36
|
+
return String(t.stdout||"").trim().split(/\s+/u)}function Wr(e="",t=""){let r=[];try{r=$e(e)}catch{}if(!r.includes(t))throw new Error(
|
|
37
|
+
`OS user is not enabled for the shared Vibe64 group: ${e}`)}function he(e=""){try{return P(e)}catch{return null}}function Ee(e=""){
|
|
38
38
|
let t=Ne("getent",["group",e],{encoding:"utf8"}),r=Number(String(t.stdout||"").split(":")[2]);if(t.status!==0||!Number.isSafeInteger(
|
|
39
39
|
r))throw new Error(`Required OS group was not found: ${e}`);return r}function Lt(e="files"){return e==="extrausers"?["--\
|
|
40
|
-
extrausers"]:[]}function
|
|
41
|
-
in the extra users database, where people sign in without a password: the helper creates no person with one here.");if(
|
|
40
|
+
extrausers"]:[]}function Hr(e="",t="",r="files",n=[]){if(r==="extrausers")throw new Error("This host keeps its accounts \
|
|
41
|
+
in the extra users database, where people sign in without a password: the helper creates no person with one here.");if(he(
|
|
42
42
|
e))throw new Error(`OS user already exists: ${e}`);if(!t||/[\r\n]/u.test(t))throw new Error("A valid initial password is\
|
|
43
43
|
required to create an OS user.");O("useradd",[...n,"--create-home","--user-group","--shell","/bin/bash",e]);let o=Ne("c\
|
|
44
44
|
hpasswd",{encoding:"utf8",input:`${e}:${t}
|
|
45
45
|
`});if(o.status!==0)throw new Error(String(o.stderr||o.stdout||"Could not set OS user password.").trim())}function jt(e="",t="",r="\
|
|
46
46
|
files"){if(r==="extrausers"){O("gpasswd",["--extrausers","-a",e,t]);return}O("usermod",["-a","-G",t,e])}var ni="/var/lib\
|
|
47
47
|
/extrausers";function Ut(e="",t="",r="files",{prefixParent:n="/run",run:o=O}={}){if(r!=="extrausers"){o("usermod",["--sh\
|
|
48
|
-
ell",t,e]);return}let s=
|
|
49
|
-
|
|
48
|
+
ell",t,e]);return}let s=Pe.join(n,`vibe64-accounts-${Pt.pid}`);Fr(s,{force:!0,recursive:!0}),qo(s,{mode:448});try{Zo(ni,
|
|
49
|
+
Pe.join(s,"etc")),o("usermod",["--prefix",s,"--shell",t,e])}finally{Fr(s,{force:!0,recursive:!0})}}function O(e="",t=[]){
|
|
50
50
|
let r=Ne(e,t,{encoding:"utf8"});if(r.status!==0)throw new Error(String(r.stderr||r.stdout||`${e} failed.`).trim());return String(
|
|
51
|
-
r.stdout||"").trim()}function
|
|
52
|
-
isSafeInteger(t)||t<0||t!==r)throw new Error(`Vibe64 exec helper ${e} mismatch.`)}function
|
|
53
|
-
let n=
|
|
51
|
+
r.stdout||"").trim()}function _(e="",t=[]){return Ne(e,t,{encoding:"utf8"})}function me(e="uid",t=null,r=null){if(!Number.
|
|
52
|
+
isSafeInteger(t)||t<0||t!==r)throw new Error(`Vibe64 exec helper ${e} mismatch.`)}function Xr(e={},t=""){let r=null;try{
|
|
53
|
+
let n=Q(e.home,$t);try{r=JSON.parse(T(n,`${t}.json`,{maxBytes:Dt,uid:e.uid}))}finally{Jo(n)}}catch{r=null}if(r?.username!==
|
|
54
54
|
t||r?.status!=="active")throw new Error("OS user is not enabled for Vibe64.")}function v(e=""){return e.startsWith(D)?e.
|
|
55
|
-
slice(D.length):e}function
|
|
56
|
-
statSync as ai}from"node:fs";import S from"node:path";import
|
|
55
|
+
slice(D.length):e}function De(e=""){return Pe.join(ge,v(w(e)),"tmp")}import{spawnSync as oi}from"node:child_process";import{closeSync as ii,existsSync as Ce,readFileSync as si,realpathSync as Bt,
|
|
56
|
+
statSync as ai}from"node:fs";import S from"node:path";import Yr from"node:process";var ct=new Set(["bash","gh","git"]),zr=/^[A-Za-z_][A-Za-z0-9_]*$/u,ci=new Set(["BASH_ENV","ENV","GCONV_PATH","GETCONF_DI\
|
|
57
57
|
R","GLIBC_TUNABLES","HOSTALIASES","LOCALDOMAIN","LD_AUDIT","LD_LIBRARY_PATH","LD_PRELOAD","LOCPATH","MALLOC_TRACE","NIS_\
|
|
58
|
-
PATH","NLSPATH","NODE_OPTIONS","RESOLV_HOST_CONF","RES_OPTIONS","TZDIR"]),
|
|
59
|
-
usr/bin:/sbin:/bin",ui=S.join(
|
|
58
|
+
PATH","NLSPATH","NODE_OPTIONS","RESOLV_HOST_CONF","RES_OPTIONS","TZDIR"]),Kr="/usr/local/sbin:/usr/local/bin:/usr/sbin:/\
|
|
59
|
+
usr/bin:/sbin:/bin",ui=S.join(G,"exec-helper.env"),li=16384;function Jr(e,t,r,n){return oi("/usr/bin/setpriv",["--no-new\
|
|
60
60
|
-privs","--","/usr/sbin/runuser","-u",e.username,"--","/usr/bin/env","--",`PATH=${n.env.PATH}`,t,...r],{...n,env:{...n.env,
|
|
61
|
-
PATH:
|
|
62
|
-
"").trim();if(!r)return S.join(
|
|
61
|
+
PATH:Kr}})}function Le(e={}){return`/run/vibe64-${v(w(e.username))}`}function qr(e="",t=X()){let r=String(t.VIBE64_AGENT_RUNTIME_ROOT||
|
|
62
|
+
"").trim();if(!r)return S.join(Le({username:e}),"vibe64","agent-providers");if(!S.isAbsolute(r)||S.resolve(r)!==r||r==="\
|
|
63
63
|
/")throw new Error("Vibe64 exec helper settings name a VIBE64_AGENT_RUNTIME_ROOT that is not an absolute, normalized fol\
|
|
64
|
-
der.");return S.join(r,v(w(e)))}function Se(e=""){return
|
|
65
|
-
t)}catch(n){if(n.code==="ENOENT")return{};throw n}try{return
|
|
66
|
-
if(n.code==="ENOENT")return{};throw n}finally{ii(r)}}function
|
|
64
|
+
der.");return S.join(r,v(w(e)))}function Se(e=""){return Zr(si(e,"utf8"))}function X(e=ui,t=0){let r;try{r=H(S.dirname(e),
|
|
65
|
+
t)}catch(n){if(n.code==="ENOENT")return{};throw n}try{return Zr(T(r,S.basename(e),{maxBytes:li,othersMayWrite:!1,uid:t}))}catch(n){
|
|
66
|
+
if(n.code==="ENOENT")return{};throw n}finally{ii(r)}}function ut(e=X()){let t=String(e.PATH||"").trim();if(!t)return Kr;
|
|
67
67
|
if(t.split(":").some(r=>!S.isAbsolute(r)))throw new Error("Vibe64 exec helper settings name a PATH folder that is not ab\
|
|
68
|
-
solute.");return t}function
|
|
68
|
+
solute.");return t}function Zr(e=""){let t={},r=u=>`
|
|
69
69
|
\r`.includes(u),n=u=>u===`
|
|
70
|
-
`||u==="\r",o="pre-key",s="",i="",a=0,c=u=>{i+=u,a=i.length},l=()=>{let u=s.trim();
|
|
70
|
+
`||u==="\r",o="pre-key",s="",i="",a=0,c=u=>{i+=u,a=i.length},l=()=>{let u=s.trim();zr.test(u)&&(t[u]=i.slice(0,a)),s="",
|
|
71
71
|
i="",a=0,o="pre-key"};for(let u of String(e))o==="pre-key"?u==="#"||u===";"?o="comment":r(u)||(s=u,o="key"):o==="key"?n(
|
|
72
72
|
u)?(s="",o="pre-key"):u==="="?o="pre-value":s+=u:o==="pre-value"||o==="value"?n(u)?l():u==="\\"?o="value-escape":o==="pr\
|
|
73
73
|
e-value"&&u==="'"?o="single":o==="pre-value"&&u==='"'?o="double":r(u)?o==="value"&&(i+=u):(c(u),o="value"):o==="value-es\
|
|
74
74
|
cape"?(n(u)||c(u),o="value"):o==="single"?u==="'"?o="pre-value":c(u):o==="double"?u==='"'?o="pre-value":u==="\\"?o="doub\
|
|
75
75
|
le-escape":c(u):o==="double-escape"?('"\\`$'.includes(u)?c(u):n(u)||c(`\\${u}`),o="double"):o==="comment"?u==="\\"?o="co\
|
|
76
76
|
mment-escape":n(u)&&(o="pre-key"):o="comment";return o!=="pre-key"&&o!=="key"&&o!=="comment"&&o!=="comment-escape"&&l(),
|
|
77
|
-
t}function
|
|
78
|
-
"workspace-cache-command"){let i=S.join(o.home,".local/state/vibe64/cache-maintenance"),a=
|
|
79
|
-
t||
|
|
77
|
+
t}function lt(e="",t="",{operation:r="",settings:n=void 0,targetUser:o={}}={}){if(r==="health-status")return De(t);if(r===
|
|
78
|
+
"workspace-cache-command"){let i=S.join(o.home,".local/state/vibe64/cache-maintenance"),a=N(e),c=R(i,a);if(o.username!==
|
|
79
|
+
t||N(i)!==i||a!==e||c.length!==1||!/^[a-z][a-z0-9-]*-[A-Za-z0-9]{6}$/u.test(c[0]))throw new Error("Cache maintenance req\
|
|
80
80
|
uires an owned workspace scratch directory.");return a}let s=String(e||"").trim();if(!s)return"/";if(r==="account-auth-t\
|
|
81
|
-
erminal"||r==="account-status"||r==="github-api-command")return pi(s,o);if(r==="vibe64-command"&&o.username===t){let i=
|
|
82
|
-
s),a=S.join(o.home,".local","state","vibe64","projects");if(
|
|
83
|
-
let c=S.join(o.home,".local","state","vibe64","colleague");if(
|
|
81
|
+
erminal"||r==="account-status"||r==="github-api-command")return pi(s,o);if(r==="vibe64-command"&&o.username===t){let i=N(
|
|
82
|
+
s),a=S.join(o.home,".local","state","vibe64","projects");if(Ce(a)){let u=N(a);if(i===u||i.startsWith(`${u}${S.sep}`))return i}
|
|
83
|
+
let c=S.join(o.home,".local","state","vibe64","colleague");if(Ce(c)){let u=R(N(c),i),m=u.at(-1)||"",p=u.length===4&&u[1]===
|
|
84
84
|
"learn"&&/^(lobby|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$/u.test(u[2]);if((u.length===2||p)&&/^[A-Za-z0-9_-]+$/u.
|
|
85
85
|
test(u[0])&&/^colleague_[a-f0-9]{32}$/u.test(m))return i}let l=S.join(o.home,".local","state","vibe64","training-sources");
|
|
86
|
-
if(
|
|
87
|
-
test(u[0]))return i}}if(r==="codex-app-server"||r==="opencode-app-server"){let i=
|
|
88
|
-
isSafeInteger(a)&&a>=0&&c.push(S.join("/run/user",String(a),"vibe64","agent-providers"));for(let l of c){if(!
|
|
89
|
-
let u=
|
|
90
|
-
test(p),f=r==="codex-app-server"&&m.length===1,
|
|
86
|
+
if(Ce(l)){let u=R(N(l),i);if(u.length===1&&/^(catalogue|topic)-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/u.
|
|
87
|
+
test(u[0]))return i}}if(r==="codex-app-server"||r==="opencode-app-server"){let i=N(s),a=Number(o.uid),c=[qr(t,n)];Number.
|
|
88
|
+
isSafeInteger(a)&&a>=0&&c.push(S.join("/run/user",String(a),"vibe64","agent-providers"));for(let l of c){if(!Ce(l))continue;
|
|
89
|
+
let u=N(l),m=R(u,i),p=m[0],d=r==="opencode-app-server"?p==="opencode":p==="codex-app-server"||/^codex-app-server-[a-f0-9]{12}$/u.
|
|
90
|
+
test(p),f=r==="codex-app-server"&&m.length===1,g=m.length===2&&m[1]==="workspace";if(d&&(f||g))return i}}return mi(s,t)}
|
|
91
91
|
function mi(e="",t=""){let r=String(e||"").trim();if(!r)throw new Error("Vibe64 exec helper rejected an empty managed pr\
|
|
92
|
-
oject path.");let n=
|
|
92
|
+
oject path.");let n=N(r),o=N(S.join("/var/lib/vibe64",v(t),"projects"));if(n.startsWith(`${o}${S.sep}`))return n;throw new Error(
|
|
93
93
|
"Vibe64 exec helper rejected a command path outside the owner project root.")}function pi(e="",t={}){let r=String(e||"").
|
|
94
94
|
trim(),n=String(t.home||"").trim();if(!r||!n)throw new Error("Vibe64 exec helper rejected an empty user command path.");
|
|
95
|
-
let o=
|
|
96
|
-
path outside the target user home.")}function
|
|
95
|
+
let o=N(r),s=N(n);if(o===s||o.startsWith(`${s}${S.sep}`))return o;throw new Error("Vibe64 exec helper rejected a command\
|
|
96
|
+
path outside the target user home.")}function Qr(e="",t=Yr.argv[1]){let r=String(e);try{let n=Bt(t),o=[S.resolve(S.dirname(
|
|
97
97
|
n),"../../../vibe64-usage-recording/runtime/node")];for(let i=S.dirname(n);o.push(S.join(i,"node_modules/@local/vibe64-u\
|
|
98
|
-
sage-recording/runtime/node")),S.dirname(i)!==i;i=S.dirname(i));let s=o.filter(i=>
|
|
98
|
+
sage-recording/runtime/node")),S.dirname(i)!==i;i=S.dirname(i));let s=o.filter(i=>Ce(i)).map(i=>Bt(i));if(S.isAbsolute(r)&&
|
|
99
99
|
!/[\s"'\\]/u.test(r)&&S.resolve(r)===r&&Bt(r)===r&&ai(r).isFile()&&s.some(i=>r.startsWith(`${i}${S.sep}`)))return`--impo\
|
|
100
|
-
rt=${r}`}catch{}throw new Error("Vibe64 exec helper rejected a usage recording preload outside its runtime.")}function
|
|
101
|
-
let s={TERM:
|
|
102
|
-
i.startsWith("DYLD_")||(s[i]=String(a));if(s.PATH||=
|
|
100
|
+
rt=${r}`}catch{}throw new Error("Vibe64 exec helper rejected a usage recording preload outside its runtime.")}function je(e={},t={},r="",n="",o=void 0){
|
|
101
|
+
let s={TERM:Yr.env.TERM||"xterm-256color"};for(let[i,a]of Object.entries(e))!zr.test(i)||ci.has(i)||i.startsWith("LD_")||
|
|
102
|
+
i.startsWith("DYLD_")||(s[i]=String(a));if(s.PATH||=ut(),n==="opencode-app-server"){let i=S.join(qr(r,o),"opencode");for(let a of[
|
|
103
103
|
"HOME","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_STATE_HOME"]){let c=String(e[a]||"").trim();if(!S.isAbsolute(
|
|
104
104
|
c)||R(i,c).length===0)throw new Error(`Vibe64 exec helper rejected OpenCode ${a} outside its provider runtime.`);s[a]=S.
|
|
105
105
|
resolve(c)}}else s.HOME=t.home,s.XDG_CACHE_HOME=S.join(t.home,".cache"),s.XDG_CONFIG_HOME=S.join(t.home,".config"),s.XDG_DATA_HOME=
|
|
106
|
-
S.join(t.home,".local","share");return s.LOGNAME=t.username,s.USER=t.username,s.TMPDIR=t.application?"/tmp"
|
|
107
|
-
mkdirSync as
|
|
108
|
-
import pt from"node:path";import
|
|
109
|
-
function te(e=
|
|
106
|
+
S.join(t.home,".local","share");return s.LOGNAME=t.username,s.USER=t.username,s.TMPDIR=t.application?"/tmp":De(r),s}import{spawnSync as wi}from"node:child_process";import{closeSync as se,fchmodSync as yi,fstatSync as Ai,fsyncSync as Vt,
|
|
107
|
+
mkdirSync as Ft,openSync as en,readdirSync as Oi,readFileSync as vi,realpathSync as _i,renameSync as tn,rmSync as Ni,writeFileSync as bi}from"node:fs";
|
|
108
|
+
import pt from"node:path";import rn from"node:process";import Ue from"node:path";import di from"node:process";var fi=Object.freeze(["files","extrausers"]),Be="/etc/systemd/system",gi="/etc/sudoers.d",hi=Ue.join(G,"staging-ssh"),Ei=/^(?:\/[A-Za-z0-9._+-]+)+$/u;
|
|
109
|
+
function te(e=X()){let t=String(e.VIBE64_ACCOUNT_DATABASE||"").trim()||"files";if(!fi.includes(t))throw new Error("This \
|
|
110
110
|
host's Vibe64 exec helper settings name an unknown account database (VIBE64_ACCOUNT_DATABASE): it is files or extrausers\
|
|
111
|
-
.");return t}var
|
|
112
|
-
"VIBE64_PERSON_ID_BAND",["UID_MIN","UID_MAX","GID_MIN","GID_MAX"]]]);function mt(e=
|
|
111
|
+
.");return t}var Si=Object.freeze([["VIBE64_SYSTEM_ID_BAND",["SYS_UID_MIN","SYS_UID_MAX","SYS_GID_MIN","SYS_GID_MAX"]],[
|
|
112
|
+
"VIBE64_PERSON_ID_BAND",["UID_MIN","UID_MAX","GID_MIN","GID_MAX"]]]);function mt(e=X()){return Si.flatMap(([t,[r,n,o,s]])=>{
|
|
113
113
|
let i=String(e[t]||"").trim();if(!i)return[];let a=/^([1-9][0-9]{0,4})-([1-9][0-9]{0,4})$/u.exec(i),[c,l]=a?[Number(a[1]),
|
|
114
114
|
Number(a[2])]:[0,0];if(!a||c>l||l>=65534)throw new Error(`This host's Vibe64 exec helper settings name a band of account\
|
|
115
115
|
numbers (${t}) that is not FIRST-LAST with FIRST no greater than LAST and both below 65534.`);return["-K",`${r}=${c}`,"\
|
|
116
|
-
-K",`${n}=${l}`,"-K",`${o}=${c}`,"-K",`${s}=${l}`]})}function
|
|
117
|
-
isAbsolute(n)||
|
|
118
|
-
that is not an absolute path other than /.`);return n}function
|
|
119
|
-
return
|
|
120
|
-
if(!r)return
|
|
121
|
-
|
|
122
|
-
alone.");return r}var
|
|
123
|
-
["adm","admin","disk","docker","incus","incus-admin","kmem","libvirt","lxd","root","shadow","staff","sudo","wheel"]);function
|
|
124
|
-
|
|
125
|
-
addToGroup:r=s=>jt(s,k,te()),resolveUser:n=P,...o}={}){
|
|
126
|
-
if(!t.startsWith(D))throw new Error("Only a workspace daemon acts as its people.");return
|
|
116
|
+
-K",`${n}=${l}`,"-K",`${o}=${c}`,"-K",`${s}=${l}`]})}function Gt(e,t,r){let n=String(e[t]||"").trim();if(!n)return r;if(!Ue.
|
|
117
|
+
isAbsolute(n)||Ue.resolve(n)!==n||n==="/")throw new Error(`This host's Vibe64 exec helper settings name a folder (${t}) \
|
|
118
|
+
that is not an absolute path other than /.`);return n}function V(e=X()){return Gt(e,"VIBE64_SYSTEMD_UNIT_ROOT",Be)}function Ge(e=X()){
|
|
119
|
+
return Gt(e,"VIBE64_SUDOERS_ROOT",gi)}function Te(e=X()){return Gt(e,"VIBE64_STAGING_KEYS_ROOT",hi)}function re(e=X(),t=di.
|
|
120
|
+
argv[1]){let r=String(e.VIBE64_EXEC_HELPER_COMMAND||"").trim();if(!r)return Ue.resolve(t);if(!Ei.test(r)||Ue.resolve(r)!==
|
|
121
|
+
r)throw new Error("This host's Vibe64 exec helper settings name a helper command (VIBE64_EXEC_HELPER_COMMAND) that is no\
|
|
122
|
+
t an absolute, normalized path of letters, digits and . _ + - alone.");return r}var Ht=pt.join(G,"people"),nn="vibe64.person-registration",Xt=4096,dt=3,Ti=pt.join(G,"person-sudo-commands"),xi=new Set(
|
|
123
|
+
["adm","admin","disk","docker","incus","incus-admin","kmem","libvirt","lxd","root","shadow","staff","sudo","wheel"]);function on(e="",t={},r=""){
|
|
124
|
+
le(r);let n=sn(U());if(Ee(k),e==="create-system-user"){Hr(r,String(t.password||""),te(),mt()),Kt(n,r);return}Mi(n,r)}function Mi(e="",t="",{
|
|
125
|
+
addToGroup:r=s=>jt(s,k,te()),resolveUser:n=P,...o}={}){ln(e,n(t),o),r(t)}function sn(e={}){let t=String(e.username||"");
|
|
126
|
+
if(!t.startsWith(D))throw new Error("Only a workspace daemon acts as its people.");return Ve(t.slice(D.length))}function Ve(e=""){
|
|
127
127
|
if(!/^[a-z][a-z0-9]{0,62}$/u.test(String(e)))throw new Error("Vibe64 exec helper rejected an invalid workspace name.");return e}
|
|
128
|
-
function
|
|
129
|
-
e);return t&&
|
|
130
|
-
registryRoot:
|
|
131
|
-
schema===
|
|
132
|
-
|
|
128
|
+
function pe(e="",{create:t=!1,registryRoot:r="",registryUid:n=0}={}){t&&Ft(r,{mode:493,recursive:!0});let o=H(r,n);try{let s=ie(
|
|
129
|
+
e);return t&&ue(h(o,s),493),H(h(o,s),n)}finally{se(o)}}function Ii(e="",t="",r={}){let n=r.registryUid??0,o;try{o=pe(e,{
|
|
130
|
+
registryRoot:Ht,...r})}catch{return null}try{let s=JSON.parse(T(o,`${t}.json`,{maxBytes:Xt,othersMayWrite:!1,uid:n}));return s?.
|
|
131
|
+
schema===nn&&s.schemaVersion===1&&s.username===t&&Number.isSafeInteger(s.uid)?{uid:s.uid,username:t}:null}catch{return null}finally{
|
|
132
|
+
se(o)}}function Yt(e,t={}){let r=`${ie(t.username)}.json`,n=`.${r}.${rn.pid}.tmp`,o=en(h(e,n),it,420);try{yi(o,420),bi(o,
|
|
133
133
|
`${JSON.stringify(t)}
|
|
134
|
-
`),
|
|
135
|
-
username})}function
|
|
134
|
+
`),Vt(o)}finally{se(o)}tn(h(e,n),h(e,r)),Vt(e)}function an(e,t={}){Yt(e,{schema:nn,schemaVersion:1,uid:t.uid,username:t.
|
|
135
|
+
username})}function cn(e=""){return Object.assign(new Error(e),{exitCode:dt})}function Wt(e=""){let t=(r,n)=>{let o=new RegExp(
|
|
136
136
|
`^[\\t ]*${r}[\\t ]+(\\d+)[\\t ]*$`,"mu").exec(String(e));return o?Number(o[1]):n};return{max:t("UID_MAX",6e4),min:t("UI\
|
|
137
|
-
D_MIN",1e3)}}function
|
|
137
|
+
D_MIN",1e3)}}function un(e={},{groups:t=[],loginUids:r=Wt(),resolveProgram:n=i=>i,sudoCommands:o=[],sudoListing:s=""}={}){
|
|
138
138
|
let{uid:i,username:a}=e;if(!Number.isSafeInteger(i)||i<r.min||i>r.max)return`${a} is a system account (uid ${i}), not a \
|
|
139
|
-
person's login.`;let c=t.find(l=>
|
|
139
|
+
person's login.`;let c=t.find(l=>xi.has(l));return c?`${a} is in the administrators' group ${c}.`:Ri(a,s,o,n)}function Ri(e="",t="",r=[],n=o=>o){
|
|
140
140
|
if(t.includes(`User ${e} is not allowed to run sudo on `))return"";let o=t.split(`
|
|
141
141
|
`),s=o.findIndex(u=>u.startsWith(`User ${e} may run the following commands on `)),i=s<0?[]:o.slice(s+1).filter(u=>u.trim()),
|
|
142
142
|
a=u=>{let[m,...p]=u.split(" ");try{return[n(m),...p].join(" ")}catch{return u}},c=new Set(r.map(a));return i.length>0&&i.
|
|
143
143
|
every(u=>{let m=/^ {4}\(root\) NOPASSWD: (.+)$/u.exec(u);return!!m&&m[1].split(", ").every(p=>c.has(a(p)))})?"":`${e} ha\
|
|
144
|
-
s sudo rules.`}function
|
|
145
|
-
let n=
|
|
144
|
+
s sudo rules.`}function ki(e=Ti,t=0){let r;try{r=en(pt.dirname(e),$)}catch(n){if(n.code==="ENOENT")return[];throw n}try{
|
|
145
|
+
let n=Ai(r);if(n.uid!==t||(n.mode&18)!==0)throw new Error("The Vibe64 person sudo commands are not in a directory only r\
|
|
146
146
|
oot can change.");return T(r,pt.basename(e),{maxBytes:4096,othersMayWrite:!1,uid:t}).split(`
|
|
147
|
-
`).map(o=>o.trim()).filter(Boolean)}catch(n){if(n.code==="ENOENT")return[];throw n}finally{
|
|
148
|
-
|
|
149
|
-
utf8",env:{COLUMNS:"100000",LANG:"C",LC_ALL:"C",PATH:"/usr/sbin:/usr/bin:/sbin:/bin"}});return{groups
|
|
150
|
-
resolveProgram:
|
|
151
|
-
throw
|
|
152
|
-
if(
|
|
147
|
+
`).map(o=>o.trim()).filter(Boolean)}catch(n){if(n.code==="ENOENT")return[];throw n}finally{se(r)}}function zt(){try{return Wt(
|
|
148
|
+
vi("/etc/login.defs","utf8"))}catch{return Wt()}}function Fe(e=""){let t=zt(),r=wi("/usr/bin/sudo",["-n","-l","-U",e],{encoding:"\
|
|
149
|
+
utf8",env:{COLUMNS:"100000",LANG:"C",LC_ALL:"C",PATH:"/usr/sbin:/usr/bin:/sbin:/bin"}});return{groups:$e(e),loginUids:t,
|
|
150
|
+
resolveProgram:_i,sudoCommands:ki(),sudoListing:r.error?"":String(r.stdout||"")}}function ft(e={},t={}){let r=un(e,t);if(r)
|
|
151
|
+
throw cn(`Vibe64 never runs commands as an administrator or system account: ${r}`)}function ln(e="",t={},{facts:r=Fe,...n}={}){
|
|
152
|
+
if(le(t.username),Ii(e,t.username,n)?.uid!==t.uid)throw cn(`OS user ${t.username} is not registered as a Vibe64 person o\
|
|
153
153
|
f workspace ${e}. A server administrator registers an existing account with: sudo ${re()} register-person ${e} ${t.username}`);
|
|
154
|
-
let s=r(t.username);return ft(t,s),s}function
|
|
155
|
-
S user is not enabled for the shared Vibe64 group: ${t.username}`);
|
|
156
|
-
i,k,te()),facts:n=
|
|
157
|
-
...s,create:!0});try{
|
|
158
|
-
report:o=i=>
|
|
159
|
-
`),resolveUser:s=P}={}){
|
|
160
|
-
registryUid:n})),{imported:[],refused:[]}}catch(p){if(p.code!=="ENOENT")throw p}let c=`.${e}.upgrading`;
|
|
161
|
-
recursive:!0}),
|
|
162
|
-
let f=t(p);if(!f.groups.includes(k))continue;let
|
|
163
|
-
as a Vibe64 person of ${e}: ${
|
|
164
|
-
of ${e}.`)}}finally{
|
|
165
|
-
try{t=
|
|
154
|
+
let s=r(t.username);return ft(t,s),s}function gt(e={},t={},r={}){if(!ln(sn(e),t,r).groups.includes(k))throw new Error(`O\
|
|
155
|
+
S user is not enabled for the shared Vibe64 group: ${t.username}`);Xr(e,t.username)}function Kt(e="",t="",{addToGroup:r=i=>jt(
|
|
156
|
+
i,k,te()),facts:n=Fe,resolveUser:o=P,...s}={}){Ve(e),le(t),o(`${D}${e}`);let i=o(t);ft(i,n(t));let a=pe(e,{registryRoot:Ht,
|
|
157
|
+
...s,create:!0});try{an(a,i)}finally{se(a)}return r(t),i}function mn(e="",{facts:t=Fe,registryRoot:r=Ht,registryUid:n=0,
|
|
158
|
+
report:o=i=>rn.stdout.write(`${i}
|
|
159
|
+
`),resolveUser:s=P}={}){Ve(e);let i=s(`${D}${e}`);Ft(r,{mode:493,recursive:!0});let a=H(r,n);try{try{return se(pe(e,{registryRoot:r,
|
|
160
|
+
registryUid:n})),{imported:[],refused:[]}}catch(p){if(p.code!=="ENOENT")throw p}let c=`.${e}.upgrading`;Ni(h(a,c),{force:!0,
|
|
161
|
+
recursive:!0}),Ft(h(a,c),{mode:493});let l=H(h(a,c),n),u=[],m=[];try{for(let p of Pi(i)){let d;try{le(p),d=s(p)}catch{continue}
|
|
162
|
+
let f=t(p);if(!f.groups.includes(k))continue;let g=un(d,f);if(g){m.push(p),o(`[vibe64-exec-helper] Not registering ${p} \
|
|
163
|
+
as a Vibe64 person of ${e}: ${g}`);continue}an(l,d),u.push(p),o(`[vibe64-exec-helper] Registered ${p} as a Vibe64 person\
|
|
164
|
+
of ${e}.`)}}finally{se(l)}return tn(h(a,c),h(a,e)),Vt(a),{imported:u,refused:m}}finally{se(a)}}function Pi(e={}){let t;
|
|
165
|
+
try{t=Q(e.home,$t)}catch(r){if(r.code==="ENOENT")return[];throw r}try{let r=[];for(let n of Oi(h(t)).sort()){let o=n.endsWith(
|
|
166
166
|
".json")?n.slice(0,-5):"";if(Ct.test(o))try{JSON.parse(T(t,n,{maxBytes:Dt,uid:e.uid}))?.username===o&&r.push(o)}catch{}}
|
|
167
|
-
return r}finally{
|
|
168
|
-
writeFileSync as
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if(!hn(e))return!1;try{return
|
|
180
|
-
keysRoot:o=
|
|
181
|
-
sudoersRoot:l}),
|
|
182
|
-
|
|
183
|
-
`,
|
|
167
|
+
return r}finally{se(t)}}import{closeSync as $i,fsyncSync as Di,lstatSync as Jt,mkdirSync as Ci,openSync as Li,renameSync as ji,unlinkSync as fn,
|
|
168
|
+
writeFileSync as Ui}from"node:fs";import de from"node:path";import Bi from"node:process";var ht="/bin/sh",qt=0,Zt=de.join(G,"production-ssh"),Gi="vibe64-production-";function Qt(e="",t=Te()){return de.join(t,e)}
|
|
169
|
+
function gn(e="",t=Ge()){return de.join(t,`vibe64-staging-${e}`)}function hn(e=""){try{return Jt(e),!0}catch(t){if(t?.code===
|
|
170
|
+
"ENOENT")return!1;throw t}}function Vi(e="",{preRenameKeysRoot:t=Zt,sudoersRoot:r=Ge()}={}){return[de.join(t,e),de.join(
|
|
171
|
+
r,`${Gi}${e}`)].filter(n=>hn(n))}function er(e="",t={}){let r=Vi(e,t);return r.length>0?`${e} still has ${r.join(" and ")}\
|
|
172
|
+
from before production access was renamed staging access. Root removes them, takes staging access back (staging-access \
|
|
173
|
+
revoke) and grants it again where the workspace owner allows it.`:""}function En(e="",t={}){let r=er(e,t);if(r)throw new Error(
|
|
174
|
+
`Vibe64 exec helper refused to change staging access: ${r}`)}function Et(e="",{keysRoot:t=Te(),rootUid:r=qt}={}){try{let n=Jt(
|
|
175
|
+
Qt(e,t));return n.isFile()&&n.uid===r&&(n.mode&18)===0}catch{return!1}}function Fi(e=Te(),t=qt){Ci(e,{mode:493,recursive:!0});
|
|
176
|
+
let r=Jt(e);if(!r.isDirectory()||r.uid!==t||(r.mode&18)!==0)throw new Error(`Vibe64 exec helper refused ${e}: it is not \
|
|
177
|
+
root's own folder.`)}function pn(e="",t="",r=420,n=null){let o=`${de.dirname(e)}/.${de.basename(e)}.${Bi.pid}`,s=Li(o,"w\
|
|
178
|
+
x",r);try{try{Ui(s,t),Di(s)}finally{$i(s)}n&&n(o),ji(o,e)}catch(i){try{fn(o)}catch{}throw i}st(de.dirname(e))}function dn(e=""){
|
|
179
|
+
if(!hn(e))return!1;try{return fn(e),!0}catch(t){if(t?.code==="ENOENT")return!1;throw t}}function Sn(e,t,r,{accountDatabase:n=te(),
|
|
180
|
+
keysRoot:o=Te(),prefixParent:s,preRenameKeysRoot:i=Zt,rootUid:a=qt,runRoot:c=O,sudoersRoot:l=Ge()}={}){En(e.username,{preRenameKeysRoot:i,
|
|
181
|
+
sudoersRoot:l}),Fi(o,a),pn(Qt(e.username,o),`command="${r} staging-shell",restrict,pty,from="127.0.0.1,::1" ${t} vibe64-\
|
|
182
|
+
staging
|
|
183
|
+
`,420),pn(gn(e.username,l),`${e.username} ALL=(root) NOPASSWD: ${r} staging-service *
|
|
184
|
+
`,288,u=>c("visudo",["-cqf",u])),e.shell!==ht&&Ut(e.username,ht,n,{prefixParent:s,run:c})}function Wi(e="",t=_){let r=t(
|
|
184
185
|
"atq",[]);if(r.status!==0)return;let n=String(r.stdout||"").split(`
|
|
185
186
|
`).map(o=>o.trim().split(/\s+/u)).filter(o=>o.length>1&&o.at(-1)===e).map(([o])=>o);n.length>0&&t("atrm",n)}function St(e,t,{
|
|
186
|
-
accountDatabase:r=te(),keysRoot:n=
|
|
187
|
-
|
|
188
|
-
run:i}),a("loginctl",["disable-linger",t]),a("loginctl",["terminate-user",t]),a("crontab",["-u",t,"-r"]),
|
|
189
|
-
e.home||"");if(!
|
|
190
|
-
s home to hide its private state.");return
|
|
191
|
-
"UMask=0077",...
|
|
192
|
-
function
|
|
193
|
-
a release service port.");return t}var
|
|
187
|
+
accountDatabase:r=te(),keysRoot:n=Te(),prefixParent:o,preRenameKeysRoot:s=Zt,runRoot:i=O,runRootAllowFailure:a=_,sudoersRoot:c=Ge()}={}){
|
|
188
|
+
En(t,{preRenameKeysRoot:s,sudoersRoot:c});let l=dn(Qt(t,n)),u=dn(gn(t,c));return e&&(e.shell!==be&&Ut(t,be,r,{prefixParent:o,
|
|
189
|
+
run:i}),a("loginctl",["disable-linger",t]),a("loginctl",["terminate-user",t]),a("crontab",["-u",t,"-r"]),Wi(t,a)),l||u}import{existsSync as zi}from"node:fs";import We from"node:path";import wn from"node:path";var Hi="editor-private",Xi=Object.freeze([".local","state","vibe64"]);function Yi(e={}){let t=String(
|
|
190
|
+
e.home||"");if(!wn.isAbsolute(t)||/[\r\n\s"\\]/u.test(t))throw new Error("Vibe64 exec helper needs the workspace daemon'\
|
|
191
|
+
s home to hide its private state.");return wn.join(t,...Xi,Hi)}function wt(e={}){return`InaccessiblePaths=-${Yi(e)}`}function tr(e={},{receiptRoot:t="",sandboxAllowances:r=[]}={}){return e.application?[`User=${e.username}`,`Group=${e.username}`,
|
|
192
|
+
"UMask=0077",...qi(e.application,[t],r)]:[`User=${e.username}`,`Group=${k}`,"SupplementaryGroups=nix-users","UMask=0007"]}
|
|
193
|
+
function rr(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<1024||t>65535)throw new Error("Vibe64 exec helper rejected\
|
|
194
|
+
a release service port.");return t}var nr=Object.freeze({fuse:Object.freeze({devices:Object.freeze(["/dev/fuse"]),namespaces:Object.
|
|
194
195
|
freeze(["user","mnt"]),systemCalls:Object.freeze(["@mount"])}),gvisor:Object.freeze({devices:Object.freeze([]),namespaces:Object.
|
|
195
|
-
freeze(["user","mnt","pid","ipc","uts","net"]),systemCalls:Object.freeze(["@mount","ptrace"])})}),
|
|
196
|
-
r","mnt","pid","ipc","uts","net"]);function
|
|
196
|
+
freeze(["user","mnt","pid","ipc","uts","net"]),systemCalls:Object.freeze(["@mount","ptrace"])})}),Ki=Object.freeze(["use\
|
|
197
|
+
r","mnt","pid","ipc","uts","net"]);function Ji(e=[]){let t=e.map(s=>{let i=nr[s];if(!i)throw new Error("Vibe64 exec help\
|
|
197
198
|
er rejected an unknown application sandbox allowance.");return i}),r=[...new Set(t.flatMap(s=>s.devices))],n=new Set(t.flatMap(
|
|
198
199
|
s=>s.namespaces)),o=[...new Set(t.flatMap(s=>s.systemCalls))];return{devices:r.flatMap(s=>[`DeviceAllow=${s} rw`,`BindPa\
|
|
199
|
-
ths=${s}`]),namespaces:n.size>0?`RestrictNamespaces=${
|
|
200
|
-
"SystemCallFilter=@system-service",...o].join(" ")}}function
|
|
200
|
+
ths=${s}`]),namespaces:n.size>0?`RestrictNamespaces=${Ki.filter(s=>n.has(s)).join(" ")}`:"RestrictNamespaces=yes",systemCalls:[
|
|
201
|
+
"SystemCallFilter=@system-service",...o].join(" ")}}function qi(e={},t=[],r=[]){let n=Ji(r);return["NoNewPrivileges=yes",
|
|
201
202
|
"PrivateTmp=yes","PrivateDevices=yes",...n.devices,"PrivateIPC=yes","TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev",
|
|
202
|
-
"ProtectSystem=strict",`ReadWritePaths=${[e.appRoot,e.databaseRoot,...t.filter(Boolean)].map(
|
|
203
|
+
"ProtectSystem=strict",`ReadWritePaths=${[e.appRoot,e.databaseRoot,...t.filter(Boolean)].map(Y).join(" ")}`,"ProtectHome\
|
|
203
204
|
=yes","ProtectProc=invisible","ProtectKernelTunables=yes","ProtectKernelModules=yes","ProtectKernelLogs=yes","ProtectCon\
|
|
204
205
|
trolGroups=yes",n.namespaces,"LockPersonality=yes","CapabilityBoundingSet=","RestrictAddressFamilies=AF_INET AF_INET6 AF\
|
|
205
|
-
_UNIX AF_NETLINK","SystemCallArchitectures=native",n.systemCalls,"SystemCallErrorNumber=EPERM",`InaccessiblePaths=${
|
|
206
|
-
function
|
|
207
|
-
function
|
|
208
|
-
vice workspace.");return
|
|
209
|
-
throw new Error("Vibe64 exec helper rejected an empty managed service path.");let n=
|
|
206
|
+
_UNIX AF_NETLINK","SystemCallArchitectures=native",n.systemCalls,"SystemCallErrorNumber=EPERM",`InaccessiblePaths=${G}`]}
|
|
207
|
+
function or(e="",t={},r="path"){let n=ir(e,t);if(!zi(n))throw new Error(`Vibe64 managed service ${r} does not exist.`);return n}
|
|
208
|
+
function yn(e={}){let t=w(e.username),r=v(t);if(!r)throw new Error("Vibe64 exec helper could not resolve the managed ser\
|
|
209
|
+
vice workspace.");return We.join("/var/lib/vibe64",r,"services")}function ir(e="",t={}){let r=String(e||"").trim();if(!r)
|
|
210
|
+
throw new Error("Vibe64 exec helper rejected an empty managed service path.");let n=N(r,{allowMissingLeaf:!0});if(R(N(yn(
|
|
210
211
|
t)),n).length>0)return n;throw new Error("Vibe64 exec helper rejected a managed service path outside the workspace servi\
|
|
211
|
-
ce root.")}function
|
|
212
|
+
ce root.")}function He(e="",t={}){let r=String(e||"").trim(),n=v(w(t.username));if(!t.username?.startsWith(D)||!r.startsWith(
|
|
212
213
|
`vibe64-release-${n}-`)||!r.endsWith(".service")||!/^[A-Za-z0-9_.@:-]+$/u.test(r)||r.includes("/")||r.includes(".."))throw new Error(
|
|
213
214
|
"Vibe64 exec helper rejected an unsafe deployment service unit name.");return r}function yt(e="",t={}){let r=String(e||"").
|
|
214
|
-
trim(),n=
|
|
215
|
+
trim(),n=We.basename(We.dirname(yn(t)));if(!r.startsWith(`vibe64-managed-${n}-`)||!r.endsWith(".service")||!/^[A-Za-z0-9_.@:-]+$/u.
|
|
215
216
|
test(r)||r.includes("/")||r.includes(".."))throw new Error("Vibe64 exec helper rejected an unsafe managed service unit n\
|
|
216
|
-
ame.");return r}function
|
|
217
|
-
helper rejected an unsupported managed service process model.");return t}function
|
|
218
|
-
|
|
219
|
-
"SupplementaryGroups=nix-users","UMask=0007",wt(e)]}function
|
|
220
|
-
e`,"MemoryAccounting=yes","IOAccounting=yes","TasksAccounting=yes","KillMode=control-group","OOMPolicy=stop"]}function
|
|
217
|
+
ame.");return r}function sr(e=""){let t=String(e||"").trim();if(t!=="forking"&&t!=="simple")throw new Error("Vibe64 exec\
|
|
218
|
+
helper rejected an unsupported managed service process model.");return t}function ar(e="",t={},r=V()){return We.join(r,
|
|
219
|
+
He(e,t))}function An(e="",t={},r=V()){return We.join(r,yt(e,t))}function Zi(e={}){return[`User=${Y(e.username)}`,`Group=${k}`,
|
|
220
|
+
"SupplementaryGroups=nix-users","UMask=0007",wt(e)]}function On(e={}){return[`Slice=vibe64-${v(w(e.username))}-work.slic\
|
|
221
|
+
e`,"MemoryAccounting=yes","IOAccounting=yes","TasksAccounting=yes","KillMode=control-group","OOMPolicy=stop"]}function vn({
|
|
221
222
|
environmentFile:e="",helperPath:t="",loopbackPort:r=0,owner:n={},requiredUnits:o=[],sandboxAllowances:s=[],servicePath:i="",
|
|
222
223
|
startScript:a="",unitName:c="",user:l={},workingDirectory:u=""}={}){let m=Array.isArray(o)?o:[];return["[Unit]",`Descrip\
|
|
223
224
|
tion=Vibe64 release service ${c}`,`After=${["network-online.target",...m].join(" ")}`,"Wants=network-online.target",...m.
|
|
224
|
-
length>0?[`Requires=${m.join(" ")}`]:[],"StartLimitIntervalSec=60","StartLimitBurst=5","","[Service]","Type=simple",...
|
|
225
|
-
l,{sandboxAllowances:s}),...
|
|
226
|
-
ctory=${
|
|
227
|
-
run-release-service "${
|
|
225
|
+
length>0?[`Requires=${m.join(" ")}`]:[],"StartLimitIntervalSec=60","StartLimitBurst=5","","[Service]","Type=simple",...tr(
|
|
226
|
+
l,{sandboxAllowances:s}),...On(n),`SocketBindAllow=tcp:${rr(r)}`,"SocketBindAllow=udp","SocketBindDeny=any",`WorkingDire\
|
|
227
|
+
ctory=${Y(u)}`,`Environment=PATH=${Y(i)}`,"Environment=TMPDIR=/tmp",`ExecStart=/usr/bin/setpriv --no-new-privs -- ${Y(t)}\
|
|
228
|
+
run-release-service "${Y(e)}" "${Y(a)}"`,"Restart=always","RestartSec=3","KillSignal=SIGTERM","TimeoutStopSec=30","","[\
|
|
228
229
|
Install]","WantedBy=multi-user.target",""].join(`
|
|
229
|
-
`)}function
|
|
230
|
-
let a=
|
|
231
|
-
e.target","","[Service]",`Type=${a}`,...
|
|
232
|
-
t=TMPDIR=${
|
|
230
|
+
`)}function _n({owner:e={},pidFile:t="",processModel:r="simple",servicePath:n="",startScript:o="",unitName:s="",workingDirectory:i=""}={}){
|
|
231
|
+
let a=sr(r);return["[Unit]",`Description=Vibe64 managed service ${s}`,"After=network-online.target","Wants=network-onlin\
|
|
232
|
+
e.target","","[Service]",`Type=${a}`,...Zi(e),...On(e),`WorkingDirectory=${Y(i)}`,`Environment=PATH=${Y(n)}`,`Environmen\
|
|
233
|
+
t=TMPDIR=${Y(De(e.username))}`,`ExecStart=${Y(o)}`,...a==="forking"?[`PIDFile=${Y(t)}`]:[],"Restart=on-failure","Restart\
|
|
233
234
|
Sec=3","TimeoutStartSec=90","TimeoutStopSec=30",""].join(`
|
|
234
|
-
`)}function
|
|
235
|
-
unsafe systemd value.");return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}var
|
|
236
|
-
|
|
235
|
+
`)}function Y(e=""){let t=String(e||"").trim();if(!t||/[\r\n]/u.test(t))throw new Error("Vibe64 exec helper rejected an \
|
|
236
|
+
unsafe systemd value.");return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}var Ye=new RegExp(`^${at}[a-f0-9]{12}$`,"u"),Ot=b.join(G,"applications"),Mn="vibe64.application-account",In=/^[a-z0-9][a-z0-9_-]{0,47}$/u,
|
|
237
|
+
ss=/^[A-Za-z0-9_-]{1,171}$/u,as=/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u,cs=100;function vt(e=X()){
|
|
237
238
|
let t=String(e.VIBE64_APPLICATION_AREA_ROOT||"").trim();if(!b.isAbsolute(t)||b.resolve(t)!==t||t==="/")throw new Error("\
|
|
238
|
-
This host's Vibe64 exec helper settings name no application area (VIBE64_APPLICATION_AREA_ROOT).");return t}function _t(e,t=
|
|
239
|
-
let r=Object.keys(
|
|
239
|
+
This host's Vibe64 exec helper settings name no application area (VIBE64_APPLICATION_AREA_ROOT).");return t}function _t(e,t=X()){
|
|
240
|
+
let r=Object.keys(nr),n=String(t.VIBE64_APPLICATION_SANDBOX_ALLOWANCES||"").split(/\s+/u).filter(Boolean);if(n.some(i=>!r.
|
|
240
241
|
includes(i)))throw new Error("This host's Vibe64 exec helper settings name an unknown application sandbox allowance (VIB\
|
|
241
242
|
E64_APPLICATION_SANDBOX_ALLOWANCES).");let o=e??[];if(!Array.isArray(o)||o.some(i=>typeof i!="string"||!r.includes(i))||
|
|
242
243
|
new Set(o).size!==o.length)throw new Error("Vibe64 exec helper rejected an application sandbox allowance it does not kno\
|
|
243
244
|
w.");let s=o.filter(i=>!n.includes(i));if(s.length>0)throw new Error(`Vibe64 exec helper refused application sandbox all\
|
|
244
245
|
owance ${s.join(", ")}: this host's owner does not permit it (VIBE64_APPLICATION_SANDBOX_ALLOWANCES).`);return[...o].sort()}
|
|
245
|
-
function
|
|
246
|
-
per rejected an unknown application account action.");let n=r==="ensure"?{account:
|
|
246
|
+
function Rn(e={}){let t=U(),r=String(e.action||"").trim();if(r!=="ensure"&&r!=="retire")throw new Error("Vibe64 exec hel\
|
|
247
|
+
per rejected an unknown application account action.");let n=r==="ensure"?{account:ms(t,e.project)}:ds(t,e.project);xn.stdout.
|
|
247
248
|
write(`${JSON.stringify({ok:!0,...n})}
|
|
248
|
-
`)}function
|
|
249
|
-
cation accounts.");return
|
|
250
|
-
split("/"),s=o.at(-1),i=o.length===4&&o[0]===".learning"&&
|
|
251
|
-
"-","")}`;if(!
|
|
249
|
+
`)}function kn(e={}){let t=String(e.username||"");if(!t.startsWith(D))throw new Error("Only a workspace daemon has appli\
|
|
250
|
+
cation accounts.");return Ve(t.slice(D.length))}function ze(e={},t="",{areaRoot:r=vt()}={}){let n=kn(e),o=String(t||"").
|
|
251
|
+
split("/"),s=o.at(-1),i=o.length===4&&o[0]===".learning"&&ss.test(o[1])&&as.test(o[2])&&s===`training-${o[2].replaceAll(
|
|
252
|
+
"-","")}`;if(!In.test(s)||o.length>1&&!i)throw new Error("Vibe64 exec helper rejected an invalid project name.");let a=b.
|
|
252
253
|
join(r,n,s);return{appRoot:b.join(a,"app"),areaRoot:r,databaseRoot:b.join(a,"database"),folder:o,handoverRoot:b.join(a,"\
|
|
253
|
-
handover"),home:b.join(a,"app","home"),project:s,projectRoot:a,username:`${
|
|
254
|
-
"hex").slice(0,12)}`,workspace:n}}function
|
|
255
|
-
e)}catch{}return{groupGid:r.status===0?Number(String(r.stdout).split(":")[2]):-1,groups:n,loginUids:t,preRenameStaging:
|
|
256
|
-
e),stagingAccess:Et(e)}}function
|
|
254
|
+
handover"),home:b.join(a,"app","home"),project:s,projectRoot:a,username:`${at}${Qi("sha256").update(`${n}\0${s}`).digest(
|
|
255
|
+
"hex").slice(0,12)}`,workspace:n}}function ur(e=""){let t=zt(),r=bn("getent",["group",e],{encoding:"utf8"}),n=[];try{n=$e(
|
|
256
|
+
e)}catch{}return{groupGid:r.status===0?Number(String(r.stdout).split(":")[2]):-1,groups:n,loginUids:t,preRenameStaging:er(
|
|
257
|
+
e),stagingAccess:Et(e)}}function lr(e={},t={},r={}){if(e.username!==t.username||!Number.isSafeInteger(e.uid)||e.uid<=0||
|
|
257
258
|
e.uid>=r.loginUids.min)return`${e.username} is not a system account.`;if(r.preRenameStaging)return r.preRenameStaging;let n=e.
|
|
258
|
-
shell===be||e.shell===
|
|
259
|
+
shell===be||e.shell===ht&&r.stagingAccess===!0;return e.home!==t.home||!n?`${e.username} does not have its application's\
|
|
259
260
|
home and no login.`:r.groupGid!==e.gid||r.groups.length!==1||r.groups[0]!==e.username?`${e.username} is in a group othe\
|
|
260
|
-
r than its own.`:""}function
|
|
261
|
-
try{o=
|
|
262
|
-
uid:n}));return s?.schema===
|
|
263
|
-
gid)&&
|
|
264
|
-
function
|
|
265
|
-
try{
|
|
266
|
-
gid:r,mode:n,uid:o},{verify:s=!0}={}){let i=
|
|
267
|
-
$);try{if(a)
|
|
261
|
+
r than its own.`:""}function mr(e="",t="",{registryRoot:r=Ot,registryUid:n=0}={}){if(!Ye.test(String(t)))return null;let o;
|
|
262
|
+
try{o=pe(e,{registryRoot:r,registryUid:n})}catch{return null}try{let s=JSON.parse(T(o,`${ie(t)}.json`,{maxBytes:Xt,othersMayWrite:!1,
|
|
263
|
+
uid:n}));return s?.schema===Mn&&s.schemaVersion===1&&s.username===t&&Number.isSafeInteger(s.uid)&&Number.isSafeInteger(s.
|
|
264
|
+
gid)&&In.test(String(s.project))?{gid:s.gid,project:s.project,uid:s.uid,username:t}:null}catch{return null}finally{C(o)}}
|
|
265
|
+
function Pn(e={},t={},{registryRoot:r=Ot,registryUid:n=0}={}){let o=pe(e.workspace,{create:!0,registryRoot:r,registryUid:n});
|
|
266
|
+
try{Yt(o,{gid:t.gid,project:e.project,schema:Mn,schemaVersion:1,uid:t.uid,username:e.username})}finally{C(o)}}function Xe(e,t="",{
|
|
267
|
+
gid:r,mode:n,uid:o},{verify:s=!0}={}){let i=h(e,ie(t)),a=ue(i,448);if(!a&&!s)return{created:a,descriptor:-1};let c=At(i,
|
|
268
|
+
$);try{if(a)ts(c,o,r),es(c,n);else if(s){let l=rs(c);if(l.uid!==o||l.gid!==r||n===457&&(l.mode&18)!==0)throw new Error(`\
|
|
268
269
|
The application area's ${t} directory is not the one the helper made.`)}return{created:a,descriptor:c}}catch(l){throw C(
|
|
269
|
-
c),l}}function
|
|
270
|
-
try{for(let s of[b.basename(e.areaRoot),e.workspace,e.project]){let i;n?i=
|
|
271
|
-
|
|
272
|
-
"setfacl",["-m",`u:${w(t.username)}:x`,`/proc/${
|
|
273
|
-
gid:r.gid,mode:448,uid:r.uid};a.push(
|
|
274
|
-
a.push(l),a.push(
|
|
275
|
-
for(let c of a)c>=0&&C(c)}}function
|
|
270
|
+
c),l}}function pr(e={},{areaGid:t=0,areaUid:r=0,create:n=!0}={}){let o=At(b.dirname(e.areaRoot),Nn.O_RDONLY|Nn.O_DIRECTORY);
|
|
271
|
+
try{for(let s of[b.basename(e.areaRoot),e.workspace,e.project]){let i;n?i=Xe(o,s,{gid:t,mode:457,uid:r}).descriptor:i=H(
|
|
272
|
+
h(o,ie(s)),r),C(o),o=i}return o}catch(s){throw C(o),s}}function us(e={},t={},r={},{areaGid:n=0,areaUid:o=0,grantDaemonSearch:s=i=>O(
|
|
273
|
+
"setfacl",["-m",`u:${w(t.username)}:x`,`/proc/${xn.pid}/fd/${i}`])}={}){let i=pr(e,{areaGid:n,areaUid:o}),a=[i];try{let c={
|
|
274
|
+
gid:r.gid,mode:448,uid:r.uid};a.push(Xe(i,"handover",{gid:r.gid,mode:1512,uid:t.uid}).descriptor);let l=Xe(i,"app",c).descriptor;
|
|
275
|
+
a.push(l),a.push(Xe(l,"home",c,{verify:!1}).descriptor);let u=Xe(i,"database",c);a.push(u.descriptor),u.created&&s(u.descriptor)}finally{
|
|
276
|
+
for(let c of a)c>=0&&C(c)}}function ls(e={},{applicationLimit:t,managedRoot:r,registryRoot:n,registryUid:o}){try{C(Q(b.join(
|
|
276
277
|
r,e.workspace),["projects",...e.folder]))}catch(i){throw["ELOOP","ENOENT","ENOTDIR"].includes(i.code)?new Error(`Vibe64 \
|
|
277
|
-
exec helper refused an application account: ${e.workspace} has no project ${e.folder.join("/")}.`):i}let s=0;try{let i=
|
|
278
|
-
e.workspace,{registryRoot:n,registryUid:o});try{s=
|
|
278
|
+
exec helper refused an application account: ${e.workspace} has no project ${e.folder.join("/")}.`):i}let s=0;try{let i=pe(
|
|
279
|
+
e.workspace,{registryRoot:n,registryUid:o});try{s=cr(h(i)).filter(a=>a.endsWith(".json")&&Ye.test(a.slice(0,-5))).length}finally{
|
|
279
280
|
C(i)}}catch(i){if(i.code!=="ENOENT")throw i}if(s>=t)throw new Error(`Vibe64 exec helper refused an application account: ${e.
|
|
280
|
-
workspace} already has ${t}, its limit. Retire unused ones first.`)}function
|
|
281
|
+
workspace} already has ${t}, its limit. Retire unused ones first.`)}function ms(e={},t="",{applicationLimit:r=cs,areaRoot:n=vt(),
|
|
281
282
|
createUser:o=m=>O("useradd",[...Lt(te()),...mt(),"--system","--user-group","--no-create-home","--home-dir",m.home,"--she\
|
|
282
|
-
ll",be,m.username]),facts:s=
|
|
283
|
-
t,{areaRoot:n}),p={registryRoot:a,registryUid:c},d=
|
|
283
|
+
ll",be,m.username]),facts:s=ur,managedRoot:i=ge,registryRoot:a=Ot,registryUid:c=0,resolveUser:l=he,...u}={}){let m=ze(e,
|
|
284
|
+
t,{areaRoot:n}),p={registryRoot:a,registryUid:c},d=mr(m.workspace,m.username,p),f=l(m.username);if(d){if(!f||f.uid!==d.uid||
|
|
284
285
|
f.gid!==d.gid||d.project!==m.project)throw new Error(`The registered application account ${m.username} is not the accoun\
|
|
285
|
-
t on this host.`)}else
|
|
286
|
-
"it was not created.";if(
|
|
287
|
-
|
|
288
|
-
username}}function
|
|
289
|
-
throw n}try{let n;try{n=At(
|
|
290
|
-
C(n)}}finally{C(r)}}function
|
|
291
|
-
facts:i=
|
|
292
|
-
unitUid:p=0}={}){let d=
|
|
293
|
-
if(y){let A=
|
|
286
|
+
t on this host.`)}else ls(m,{applicationLimit:r,managedRoot:i,...p}),f||(o(m),f=l(m.username));let g=f?lr(f,m,s(m.username)):
|
|
287
|
+
"it was not created.";if(g)throw new Error(`Vibe64 exec helper refused application account ${m.username}: ${g}`);return d||
|
|
288
|
+
Pn(m,f,p),us(m,e,f,u),{appRoot:m.appRoot,databaseRoot:m.databaseRoot,handoverRoot:m.handoverRoot,home:m.home,username:m.
|
|
289
|
+
username}}function ps(e={},{areaUid:t=0}={}){let r;try{r=pr(e,{areaUid:t,create:!1})}catch(n){if(n.code==="ENOENT")return[];
|
|
290
|
+
throw n}try{let n;try{n=At(h(r,"database"),$)}catch(o){if(o.code==="ENOENT")return[];throw o}try{return cr(h(n)).sort()}finally{
|
|
291
|
+
C(n)}}finally{C(r)}}function ds(e={},t="",{areaRoot:r=vt(),areaUid:n=0,deleteUser:o=d=>O("userdel",[...Lt(te()),d]),endStagingAccess:s=St,
|
|
292
|
+
facts:i=ur,registryRoot:a=Ot,registryUid:c=0,resolveUser:l=he,running:u=d=>bn("pgrep",["-U",String(d)]).status!==1,unitRoot:m=V(),
|
|
293
|
+
unitUid:p=0}={}){let d=ze(e,t,{areaRoot:r}),f={registryRoot:a,registryUid:c},g=mr(d.workspace,d.username,f),y=l(d.username);
|
|
294
|
+
if(y){let A=g&&g.uid!==y.uid?"it is not the registered account.":lr(y,d,i(d.username));if(A)throw new Error(`Vibe64 exec\
|
|
294
295
|
helper refused to retire application account ${d.username}: ${A}`);let I=Nt({unitRoot:m,unitUid:p,workspace:d.workspace}).
|
|
295
|
-
find(({lines:
|
|
296
|
-
is still installed. Remove it before retiring the application.`)}let M=
|
|
296
|
+
find(({lines:ot})=>ot.includes(`User=${d.username}`));if(I)throw new Error(`The application's release service ${I.name} \
|
|
297
|
+
is still installed. Remove it before retiring the application.`)}let M=ps(d,{areaUid:n});if(M.length>0)throw new Error(`\
|
|
297
298
|
The application's database directory still holds ${M.slice(0,5).join(", ")}${M.length>5?` and ${M.length-5} more`:""}. G\
|
|
298
|
-
ive its staging database back to the editor before retiring the application.`);let j=()=>{let A=
|
|
299
|
-
|
|
299
|
+
ive its staging database back to the editor before retiring the application.`);let j=()=>{let A=pe(d.workspace,f);try{is(
|
|
300
|
+
h(A,`${d.username}.json`))}finally{C(A)}},J=!!(g&&y);if(J&&j(),y&&u(y.uid))throw J&&Pn(d,y,f),new Error("The application\
|
|
300
301
|
still runs: its release service, or a staging login of its AI sessions. Stop its release service, and end its AI sessio\
|
|
301
|
-
ns' staging access, before retiring it.");y&&s(y,d.username);let
|
|
302
|
-
"ENOENT")throw A}if(
|
|
303
|
-
A)}}return
|
|
304
|
-
let r=
|
|
302
|
+
ns' staging access, before retiring it.");y&&s(y,d.username);let q=-1;try{q=pr(d,{areaUid:n,create:!1})}catch(A){if(A.code!==
|
|
303
|
+
"ENOENT")throw A}if(q>=0){C(q);let A=H(b.join(r,d.workspace),n);try{os(h(A,d.project),{force:!0,recursive:!0})}finally{C(
|
|
304
|
+
A)}}return g&&!J&&j(),y&&o(d.username),{retired:!!(y||g||q>=0)}}function dr(e="",t=()=>ns("/proc/self/mountinfo","utf8")){
|
|
305
|
+
let r=N(e),n={mountPoint:"",options:[]};for(let o of String(t()).split(`
|
|
305
306
|
`)){let[,,,,s="",i=""]=o.split(" "),a=s.replace(/\\([0-7]{3})/gu,(c,l)=>String.fromCharCode(Number.parseInt(l,8)));(a===
|
|
306
307
|
r||R(a,r).length>0)&&a.length>=n.mountPoint.length&&(n={mountPoint:a,options:i.split(",")})}if(!n.options.includes("nosu\
|
|
307
308
|
id"))throw new Error(`Vibe64 exec helper refused to run application code: this host's application area is not mounted no\
|
|
308
|
-
suid at ${r}, so a set-user-ID or set-group-ID file there would take effect. Host setup mounts it so.`)}function
|
|
309
|
-
areaRoot:r=vt(),facts:n=
|
|
310
|
-
is not an application account of this workspace.`);let l=
|
|
311
|
-
uid||c.gid!==u.gid?"it is not the registered account.":
|
|
312
|
-
lication account ${a}: ${m}`);return
|
|
313
|
-
home);for(let n of[t.appRoot,t.databaseRoot]){let o=
|
|
314
|
-
helper rejected an application command path outside its area.")}function
|
|
315
|
-
let s=String(e||""),[i="",a="",...c]=R(t.handoverRoot,s),l=
|
|
316
|
-
ases",i,"workspace")];if(!i||a!=="environment"||c.length>0||
|
|
309
|
+
suid at ${r}, so a set-user-ID or set-group-ID file there would take effect. Host setup mounts it so.`)}function xe(e={},t="",{
|
|
310
|
+
areaRoot:r=vt(),facts:n=ur,mountInfo:o,resolveUser:s=P,...i}={}){let a=w(t),c=mr(kn(e),a,i);if(!c)throw new Error(`${a} \
|
|
311
|
+
is not an application account of this workspace.`);let l=ze(e,c.project,{areaRoot:r}),u=s(a),m=l.username!==a||c.uid!==u.
|
|
312
|
+
uid||c.gid!==u.gid?"it is not the registered account.":lr(u,l,n(a));if(m)throw new Error(`Vibe64 exec helper refused app\
|
|
313
|
+
lication account ${a}: ${m}`);return dr(r,o),{...u,application:l}}function $n(e="",t={}){let r=N(String(e||"").trim()||t.
|
|
314
|
+
home);for(let n of[t.appRoot,t.databaseRoot]){let o=N(n);if(r===o||R(o,r).length>0)return r}throw new Error("Vibe64 exec\
|
|
315
|
+
helper rejected an application command path outside its area.")}function fr(e="",t={},{cwd:r="",daemonUid:n=-1,gid:o=-1}={}){
|
|
316
|
+
let s=String(e||""),[i="",a="",...c]=R(t.handoverRoot,s),l=Tn(s),u=[b.join(t.appRoot,"sources",i),b.join(t.appRoot,"rele\
|
|
317
|
+
ases",i,"workspace")];if(!i||a!=="environment"||c.length>0||N(s)!==s||!l.isFile()||l.uid!==n||l.gid!==o||(l.mode&23)!==0||
|
|
317
318
|
!u.some(m=>r===m||R(m,r).length>0))throw new Error("Release environment must belong to the application's selected releas\
|
|
318
|
-
e.");return s}function
|
|
319
|
+
e.");return s}function Dn(e={},t={},{daemonUid:r=-1,gid:n=-1}={}){let o=String(e.workingDirectory||""),s=fr(e.environmentFile,
|
|
319
320
|
t,{cwd:o,daemonUid:r,gid:n}),i=b.basename(b.dirname(s)),a=b.join(t.appRoot,"releases",i,"workspace"),c=R(a,o),l=String(e.
|
|
320
|
-
startScript||""),u=
|
|
321
|
+
startScript||""),u=Tn(l);if(b.resolve(o)!==o||o!==a&&c.length===0||l!==b.join(b.dirname(s),"start.sh")||!u.isFile()||u.uid!==
|
|
321
322
|
r||u.gid!==n||(u.mode&18)!==0||(u.mode&8)===0)throw new Error("A release service must run its own release's workspace an\
|
|
322
|
-
d start script.");try{C(
|
|
323
|
+
d start script.");try{C(Q(t.appRoot,["releases",i,"workspace",...c]))}catch(m){throw new Error(`A release service's work\
|
|
323
324
|
ing directory must be a real folder of its release's workspace: ${m.code||m.message}`)}return{environmentFile:s,startScript:l,
|
|
324
|
-
workingDirectory:o}}function Nt({unitRoot:e=
|
|
325
|
-
let s=[];for(let i of
|
|
325
|
+
workingDirectory:o}}function Nt({unitRoot:e=V(),unitUid:t=0,workspace:r=""}={}){let n=`vibe64-release-${r}-`,o=At(e,$);try{
|
|
326
|
+
let s=[];for(let i of cr(h(o)))if(!(!i.startsWith("vibe64-release-")||!i.endsWith(".service")))try{s.push({lines:T(o,i,{
|
|
326
327
|
maxBytes:64*1024,othersMayWrite:!1,uid:t}).split(`
|
|
327
328
|
`),name:i})}catch(a){if(!i.startsWith(n))continue;throw Object.assign(new Error(`Release unit ${i} of workspace ${r} is \
|
|
328
|
-
not a unit file root wrote: ${a.message}`),{code:a.code})}return s}finally{C(o)}}function
|
|
329
|
-
unitName:r="",unitRoot:n=
|
|
329
|
+
not a unit file root wrote: ${a.message}`),{code:a.code})}return s}finally{C(o)}}function Cn({loopbackPort:e=0,owner:t={},
|
|
330
|
+
unitName:r="",unitRoot:n=V(),unitUid:o=0,user:s={}}={}){let i=v(w(t.username)),a=String(s.application?.project||"").replace(
|
|
330
331
|
/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"");if(!a||!new RegExp(`^vibe64-release-${i}-${a}-[a-f0-9]{12}\\.service$`,"u").
|
|
331
332
|
test(r))throw new Error(`Release service ${r} is not named for application ${s.username}'s project.`);for(let{lines:c,name:l}of Nt(
|
|
332
333
|
{unitRoot:n,unitUid:o,workspace:i}))if(l===r){if(!c.includes(`User=${s.username}`))throw new Error(`Release service ${r}\
|
|
333
334
|
belongs to another account.`)}else if(c.includes(`SocketBindAllow=tcp:${e}`))throw new Error(`Port ${e} belongs to anot\
|
|
334
|
-
her release service.`)}import{closeSync as
|
|
335
|
-
|
|
336
|
-
tmp","managed-execution-payloads"],s=
|
|
337
|
-
4 exec helper rejected an unsafe managed execution payload path.");let i=
|
|
338
|
-
"Vibe64 exec helper refused a managed execution payload directory owned by another user.");let a=T(i,s,{maxBytes:
|
|
339
|
-
uid});return
|
|
340
|
-
"Vibe64 exec helper rejected a non-normalized execution payload.")}function
|
|
335
|
+
her release service.`)}import{closeSync as fs,fstatSync as gs,readSync as hs,unlinkSync as Es}from"node:fs";import gr from"node:path";var Ss=4*1024*1024,ws=1024*1024,Ln=4*Math.ceil(Ss/3)+ws,ys=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/u,As=64*1024,Os=10,vs=15e3,
|
|
336
|
+
_s="vibe64.exec-helper.payload",Ns=1;function jn(e="",t={},{managedRoot:r=ge}={}){let n=gr.join(r,v(w(t.username))),o=["\
|
|
337
|
+
tmp","managed-execution-payloads"],s=gr.basename(String(e));if(e!==gr.join(n,...o,s)||!ys.test(s))throw new Error("Vibe6\
|
|
338
|
+
4 exec helper rejected an unsafe managed execution payload path.");let i=Q(n,o);try{if(gs(i).uid!==t.uid)throw new Error(
|
|
339
|
+
"Vibe64 exec helper refused a managed execution payload directory owned by another user.");let a=T(i,s,{maxBytes:Ln,uid:t.
|
|
340
|
+
uid});return Es(h(i,s)),Gn(a)}finally{fs(i)}}function Un(e={}){if(e?.schema!==_s||e?.schemaVersion!==Ns)throw new Error(
|
|
341
|
+
"Vibe64 exec helper rejected a non-normalized execution payload.")}function Bn(){return Gn(bs())}function Gn(e=""){let t;
|
|
341
342
|
try{t=JSON.parse(e)}catch{throw new Error("Vibe64 exec helper payload is not valid JSON.")}if(!t||typeof t!="object"||Array.
|
|
342
|
-
isArray(t))throw new Error("Vibe64 exec helper payload must be a JSON object.");return t}function
|
|
343
|
-
allocUnsafe(
|
|
344
|
-
if(s===0)break;if(o+=s,o>
|
|
343
|
+
isArray(t))throw new Error("Vibe64 exec helper payload must be a JSON object.");return t}function bs(){let e=[],t=Buffer.
|
|
344
|
+
allocUnsafe(As),r=new Int32Array(new SharedArrayBuffer(4)),n=Date.now()+vs,o=0;for(;;)try{let s=hs(0,t,0,t.length,null);
|
|
345
|
+
if(s===0)break;if(o+=s,o>Ln)throw new Error("Vibe64 exec helper payload is too large.");e.push(Buffer.from(t.subarray(0,
|
|
345
346
|
s)))}catch(s){if(s?.code==="EINTR")continue;if((s?.code==="EAGAIN"||s?.code==="EWOULDBLOCK")&&Date.now()<n){Atomics.wait(
|
|
346
|
-
r,0,0,
|
|
347
|
-
its payload."):s}return Buffer.concat(e,o).toString("utf8")}import{spawn as
|
|
348
|
-
import{createConnection as
|
|
349
|
-
control","job","preview","service","terminal"]),
|
|
350
|
-
1024,
|
|
351
|
-
if(e.applicationAccount===!0){let i=
|
|
352
|
-
t.username),s=o===t.username?t:n(o);return
|
|
353
|
-
s.username,k),s}function
|
|
354
|
-
an invalid managed execution id.");return t.toLowerCase()}function
|
|
355
|
-
"Vibe64 exec helper rejected an unknown managed execution kind.");return t}function
|
|
356
|
-
if(!
|
|
347
|
+
r,0,0,Os);continue}throw s?.code==="EAGAIN"||s?.code==="EWOULDBLOCK"?new Error("Vibe64 exec helper timed out waiting for\
|
|
348
|
+
its payload."):s}return Buffer.concat(e,o).toString("utf8")}import{spawn as ea,spawnSync as ta}from"node:child_process";import{readFileSync as ra,unlinkSync as na}from"node:fs";import fe from"node:path";
|
|
349
|
+
import{createConnection as oa}from"node:net";import{constants as ia}from"node:os";import L from"node:process";var hr=/^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/iu,Ts=new Set(["assistant","browser","\
|
|
350
|
+
control","job","preview","service","terminal"]),xs=new Set(["capture","detached","pty"]),we=64*1024*1024,bt=1024*1024*1024*
|
|
351
|
+
1024,Vn=256*1024*1024,Ke=1024*1024*1024*1024,Je=8,qe=8192;function Fn(e={},t={},{assertInGroup:r=Wr,resolveUser:n=P}={}){
|
|
352
|
+
if(e.applicationAccount===!0){let i=xe(t,e.username);return me("uid",e.uid,i.uid),me("gid",e.gid,i.gid),i}let o=w(e.username||
|
|
353
|
+
t.username),s=o===t.username?t:n(o);return me("uid",e.uid,s.uid),me("gid",e.gid,s.gid),s.username!==t.username?gt(t,s):r(
|
|
354
|
+
s.username,k),s}function z(e=""){let t=String(e||"").trim();if(!hr.test(t))throw new Error("Vibe64 exec helper rejected \
|
|
355
|
+
an invalid managed execution id.");return t.toLowerCase()}function Wn(e=""){let t=String(e||"").trim();if(!Ts.has(t))throw new Error(
|
|
356
|
+
"Vibe64 exec helper rejected an unknown managed execution kind.");return t}function Hn(e=""){let t=String(e||"").trim();
|
|
357
|
+
if(!xs.has(t))throw new Error("Vibe64 exec helper rejected an unknown managed execution mode.");return t}function ne(e,t,r,n="\
|
|
357
358
|
value"){let o=Number(e);if(!Number.isSafeInteger(o)||o<t||o>r)throw new Error(`Vibe64 exec helper rejected an invalid ma\
|
|
358
|
-
naged execution ${n}.`);return o}function ye(e="",t={}){return`vibe64-exec-${v(w(t.username))}-${
|
|
359
|
-
.service`}function
|
|
360
|
-
readdirSync as
|
|
361
|
-
return
|
|
359
|
+
naged execution ${n}.`);return o}function ye(e="",t={}){return`vibe64-exec-${v(w(t.username))}-${z(e).replaceAll("-","")}\
|
|
360
|
+
.service`}function Ze(e={}){return`vibe64-${v(w(e.username))}-work.slice`}import{chmodSync as Ms,closeSync as Ae,fchmodSync as Sr,fchownSync as Qe,fstatSync as wr,mkdirSync as Xn,openSync as Me,
|
|
361
|
+
readdirSync as Is,renameSync as Rs,rmSync as ks,writeFileSync as Yn}from"node:fs";import et from"node:path";import Ps from"node:process";var $s=64*1024,Er="/run/vibe64-applications";function yr(e={},{create:t=!1}={}){t&&(ue(Er),Ms(Er,457));let r=v(w(e.username));
|
|
362
|
+
return zn(et.join(Er,r),{create:t,mode:457})}function Tt(e={}){let t=Ar(e),r;try{r=yr(e)}catch(o){throw t.close(),o}let n=[
|
|
362
363
|
t,r];return{close:()=>n.forEach(o=>o.close()),entries:()=>n.flatMap(o=>o.entries()),remove:o=>n.forEach(s=>s.remove(o)),
|
|
363
|
-
result:o=>n.map(s=>s.result(o)).find(s=>s.executionId)||{}}}function
|
|
364
|
-
|
|
364
|
+
result:o=>n.map(s=>s.result(o)).find(s=>s.executionId)||{}}}function Ar(e={},{create:t=!1,gid:r=null}={}){let n=Le(e);return t&&
|
|
365
|
+
Ds(n,{gid:r,uid:e.uid}),zn(et.join(n,"executions"),{create:t,gid:t?r:0,legacyUid:e.uid,uid:0})}function Ds(e="",{gid:t=null,
|
|
365
366
|
uid:r=null}={}){if(!Number.isSafeInteger(r)||r<0||!Number.isSafeInteger(t)||t<0)throw new Error("Vibe64 exec helper need\
|
|
366
|
-
s the daemon's uid and the shared group's gid.");
|
|
367
|
-
t),(o.mode&4095)!==1512&&
|
|
368
|
-
helper has no execution receipt directory.")},entries:()=>[],remove(){},result:()=>({})}),
|
|
369
|
-
"ENOTDIR","ENXIO","EVIBE64UNSAFEFILE"]);function
|
|
370
|
-
e,o);let i;try{i=
|
|
371
|
-
"Vibe64 exec helper refused an execution receipt directory owned by another user.");t&&(
|
|
372
|
-
i),a}return{close:()=>Ae(i),entries:()=>
|
|
373
|
-
l=-1;try{l=
|
|
374
|
-
ged-execution.result"&&u.schemaVersion===1&&u.executionId===c?u:{}}catch(u){if(u instanceof SyntaxError||
|
|
375
|
-
return{};throw u}finally{l>=0&&Ae(l)}},create(a="",c={},l={},{privateDirectory:u=!1}={}){let m=
|
|
376
|
-
let d=
|
|
377
|
-
Ae(y)}f.VIBE64_EXECUTION_PRIVATE_DIR=
|
|
367
|
+
s the daemon's uid and the shared group's gid.");ue(e,488);let n=Me(e,$);try{let o=wr(n);(o.uid!==r||o.gid!==t)&&Qe(n,r,
|
|
368
|
+
t),(o.mode&4095)!==1512&&Sr(n,1512)}finally{Ae(n)}}var Cs=Object.freeze({close(){},create(){throw new Error("Vibe64 exec\
|
|
369
|
+
helper has no execution receipt directory.")},entries:()=>[],remove(){},result:()=>({})}),Ls=new Set(["ENOENT","ELOOP",
|
|
370
|
+
"ENOTDIR","ENXIO","EVIBE64UNSAFEFILE"]);function zn(e="",{create:t=!1,gid:r=0,legacyUid:n=0,mode:o=488,uid:s=0}={}){t&&ue(
|
|
371
|
+
e,o);let i;try{i=Me(e,$)}catch(a){if(!t&&a?.code==="ENOENT")return Cs;throw a}try{let a=wr(i).uid;if(a!==s&&a!==n)throw new Error(
|
|
372
|
+
"Vibe64 exec helper refused an execution receipt directory owned by another user.");t&&(Qe(i,s,r),Sr(i,o))}catch(a){throw Ae(
|
|
373
|
+
i),a}return{close:()=>Ae(i),entries:()=>Is(h(i)),remove:a=>ks(h(i,z(a)),{force:!0,recursive:!0}),result(a=""){let c=z(a),
|
|
374
|
+
l=-1;try{l=Me(h(i,c),$);let u=JSON.parse(T(l,"result.json",{maxBytes:$s,uid:wr(l).uid}));return u?.schema==="vibe64.mana\
|
|
375
|
+
ged-execution.result"&&u.schemaVersion===1&&u.executionId===c?u:{}}catch(u){if(u instanceof SyntaxError||Ls.has(u?.code))
|
|
376
|
+
return{};throw u}finally{l>=0&&Ae(l)}},create(a="",c={},l={},{privateDirectory:u=!1}={}){let m=z(a),p=h(i,m);Xn(p,{mode:448});
|
|
377
|
+
let d=Me(p,$);try{let f={...l.env};if(u){Xn(h(d,"private"),{mode:448});let y=Me(h(d,"private"),$);try{Qe(y,c.uid,c.gid)}finally{
|
|
378
|
+
Ae(y)}f.VIBE64_EXECUTION_PRIVATE_DIR=et.join(e,m,"private")}let g=Me(h(d,"command.json"),it,384);try{Yn(g,`${JSON.stringify(
|
|
378
379
|
{...l,env:f,schema:"vibe64.managed-execution.command",schemaVersion:1})}
|
|
379
|
-
`),
|
|
380
|
-
let r=Tt(e);try{return r.result(t)}finally{r.close()}}function
|
|
381
|
-
pid}`;
|
|
382
|
-
`,{flag:"wx",mode:384}),
|
|
383
|
-
import
|
|
384
|
-
writeFileSync as
|
|
380
|
+
`),Sr(g,384),Qe(g,c.uid,c.gid)}finally{Ae(g)}Qe(d,c.uid,c.gid)}finally{Ae(d)}return et.join(e,m)}}}function Kn(e={},t=""){
|
|
381
|
+
let r=Tt(e);try{return r.result(t)}finally{r.close()}}function Jn(e="",t={}){let r=et.join(e,"result.json"),n=`${r}.tmp-${Ps.
|
|
382
|
+
pid}`;Yn(n,`${JSON.stringify({...t,schema:"vibe64.managed-execution.result",schemaVersion:1})}
|
|
383
|
+
`,{flag:"wx",mode:384}),Rs(n,r)}import{spawnSync as to}from"node:child_process";import{existsSync as no,readFileSync as rt}from"node:fs";import ee from"node:path";
|
|
384
|
+
import Ks from"node:process";import{closeSync as js,lstatSync as Us,mkdirSync as Bs,openSync as Gs,readFileSync as Oe,renameSync as Vs,unlinkSync as qn,
|
|
385
|
+
writeFileSync as Fs}from"node:fs";import B from"node:path";import Zn from"node:process";function Qn(e={},{memoryMaxBytes:t=0,tasksMax:r=0}={},{read:n=Oe,run:o=O,runAllowFailure:s=_}={}){let i=Ze(e);Hs(i,{memoryMaxBytes:t,
|
|
385
386
|
tasksMax:r},n)||(s("systemctl",["is-active","--quiet",i]).status!==0&&o("systemctl",["start",i]),o("systemctl",["set-pro\
|
|
386
387
|
perty","--runtime",i,`MemoryMax=${t}`,`TasksMax=${r}`,"MemoryAccounting=yes","IOAccounting=yes","TasksAccounting=yes"]))}
|
|
387
|
-
function
|
|
388
|
-
slice(0,n+1).join("-")}.slice`))}function
|
|
388
|
+
function Ws(e=""){let t=String(e).replace(/\.slice$/u,"").split("-");return B.join("/sys/fs/cgroup",...t.map((r,n)=>`${t.
|
|
389
|
+
slice(0,n+1).join("-")}.slice`))}function Hs(e="",{memoryMaxBytes:t=0,tasksMax:r=0}={},n=Oe){let o=Ws(e);try{let s=String(
|
|
389
390
|
n(B.join(o,"cgroup.controllers"),"utf8")).trim().split(/\s+/u),i=Number(String(n(B.join(o,"memory.max"),"utf8")).trim()),
|
|
390
391
|
a=Number(String(n(B.join(o,"pids.max"),"utf8")).trim());return["memory","io","pids"].every(c=>s.includes(c))&&Number.isSafeInteger(
|
|
391
|
-
i)&&i<=t&&t-i<4096&&a===r}catch{return!1}}function
|
|
392
|
+
i)&&i<=t&&t-i<4096&&a===r}catch{return!1}}function _r(e={},t={}){let r=z(e.id);for(let a of[e.projectKey,e.sessionKey])if(typeof a!=
|
|
392
393
|
"string"||!/^[a-f0-9]{64}$/u.test(a))throw new Error("Vibe64 exec helper rejected an invalid workflow accounting identit\
|
|
393
394
|
y.");let n=w(t.username);if(!n.startsWith(D))throw new Error("Managed workflow accounting requires a workspace daemon ow\
|
|
394
395
|
ner.");let o=v(n);if(!/^[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/u.test(o))throw new Error("Invalid managed workflow workspace\
|
|
395
396
|
identity.");let s=`vibe64-${o}-work-p${e.projectKey}.slice`,i=`${s.slice(0,-6)}-s${e.sessionKey}.slice`;return{id:r,workspace:o,
|
|
396
397
|
projectKey:e.projectKey,sessionKey:e.sessionKey,projectUnit:s,sessionUnit:i,unitName:`${i.slice(0,-6)}-w${r.replaceAll("\
|
|
397
|
-
-","")}.slice`}}function
|
|
398
|
-
parse(Oe(
|
|
399
|
-
"Invalid managed workflow result identity.");return t}catch(t){if(t.code==="ENOENT")return null;throw t}}function
|
|
400
|
-
let r=
|
|
401
|
-
let i=
|
|
402
|
-
result directory.")}let n=`${r}.tmp-${
|
|
398
|
+
-","")}.slice`}}function Nr(e){return B.join("/run/vibe64-workflows",e.workspace,`${e.id}.json`)}function Xs(e){try{let t=JSON.
|
|
399
|
+
parse(Oe(Nr(e),"utf8"));if(t.schema!=="vibe64.managed-workflow.result.v1"||t.unitName!==e.unitName||t.id!==e.id)throw new Error(
|
|
400
|
+
"Invalid managed workflow result identity.");return t}catch(t){if(t.code==="ENOENT")return null;throw t}}function Ys(e,t){
|
|
401
|
+
let r=Nr(e);for(let s of["/run/vibe64-workflows",B.dirname(r)]){try{Bs(s,{mode:448})}catch(a){if(a.code!=="EEXIST")throw a}
|
|
402
|
+
let i=Us(s);if(!i.isDirectory()||i.isSymbolicLink()||i.uid!==0||(i.mode&63)!==0)throw new Error("Unsafe managed workflow\
|
|
403
|
+
result directory.")}let n=`${r}.tmp-${Zn.pid}`,o=Gs(n,"wx",384);try{try{Fs(o,`${JSON.stringify({...t,schema:"vibe64.man\
|
|
403
404
|
aged-workflow.result.v1"})}
|
|
404
|
-
`)}finally{
|
|
405
|
-
pt write and cleanup failed.")}throw s}}function ae(e){let t=
|
|
405
|
+
`)}finally{js(o)}Vs(n,r)}catch(s){try{qn(n)}catch(i){if(i.code!=="ENOENT")throw new AggregateError([s,i],"Workflow recei\
|
|
406
|
+
pt write and cleanup failed.")}throw s}}function ae(e){let t=_("systemctl",["show",e.unitName,"--no-pager","--property=L\
|
|
406
407
|
oadState,ActiveState,ControlGroup,MemoryMax,TasksMax"]),r=Object.fromEntries(String(t.stdout||"").trim().split(`
|
|
407
408
|
`).map(i=>{let a=i.indexOf("=");return[i.slice(0,a),i.slice(a+1)]})),n=String(r.ControlGroup||"");if(n&&(B.posix.basename(
|
|
408
409
|
n)!==e.unitName||!n.includes(`/vibe64-${e.workspace}-work.slice/`)))throw new Error("Managed workflow group does not bel\
|
|
409
410
|
ong to its workspace.");let o={id:e.id,unitName:e.unitName,activeState:r.ActiveState||"unknown",controlGroup:n,memoryMaxBytes:x(
|
|
410
411
|
r.MemoryMax),tasksMax:x(r.TasksMax),...xt(n?B.join("/sys/fs/cgroup",n):"")};t.status===0&&r.ActiveState==="inactive"&&!n&&
|
|
411
|
-
(o.scopeEmpty=!0);let s=
|
|
412
|
+
(o.scopeEmpty=!0);let s=Xs(e);return s?{...s,activeState:o.activeState,controlGroup:o.controlGroup}:o}function x(e){return typeof e==
|
|
412
413
|
"string"&&/^[0-9]+$/u.test(e.trim())&&Number.isSafeInteger(Number(e))?Number(e):null}function xt(e=""){function t(a){if(!e)
|
|
413
414
|
return"";try{return Oe(B.join(e,a),"utf8")}catch(c){if(c.code==="ENOENT"||c.code==="ENODEV")return"";throw c}}function r(a){
|
|
414
415
|
return Object.fromEntries(t(a).trim().split(`
|
|
415
416
|
`).map(c=>{let[l,u]=c.trim().split(/\s+/u);return[l,x(u)]}))}let n=r("memory.events"),o=r("memory.stat"),s=r("cgroup.eve\
|
|
416
|
-
nts"),i=t("memory.pressure");return{sampledAt:new Date().toISOString(),sampledMonotonicMs:Number(
|
|
417
|
+
nts"),i=t("memory.pressure");return{sampledAt:new Date().toISOString(),sampledMonotonicMs:Number(Zn.hrtime.bigint()/1000000n),
|
|
417
418
|
scopeEmpty:s.populated===0?!0:s.populated===1?!1:null,memoryCurrentBytes:x(t("memory.current")),memoryPeakBytes:x(t("mem\
|
|
418
419
|
ory.peak")),memorySwapCurrentBytes:x(t("memory.swap.current")),memoryAnonBytes:o.anon??null,memoryFileBytes:o.file??null,
|
|
419
420
|
memoryKernelBytes:o.kernel??null,swapInPages:o.pswpin??null,swapOutPages:o.pswpout??null,memoryPressureSomeTotalUsec:x(/^some\s+.*\btotal=([0-9]+)(?:\s|$)/mu.
|
|
420
421
|
exec(i)?.[1]),oomCount:n.oom??null,oomKillCount:n.oom_kill??null,limitHitCount:n.max??null,reclaimCount:n.high??null,tasksCurrent:x(
|
|
421
|
-
t("pids.current")),peakScope:"workflow-lifetime"}}function
|
|
422
|
-
"workflow-inspect")return{ok:!0,...ae(r)};if(n==="workflow-grow"||n==="workflow-limits")return
|
|
422
|
+
t("pids.current")),peakScope:"workflow-lifetime"}}function eo(e,t){let r=_r(e.workflow,t),n=String(e.action||"");if(n===
|
|
423
|
+
"workflow-inspect")return{ok:!0,...ae(r)};if(n==="workflow-grow"||n==="workflow-limits")return zs(e,r,t);if(n==="workflo\
|
|
423
424
|
w-forget"){let o=ae(r);if(o.scopeEmpty!==!0||o.activeState!=="inactive")throw new Error("Only a completed workflow recei\
|
|
424
|
-
pt can be acknowledged.");try{
|
|
425
|
-
ate"){let o=ne(e.memoryMaxBytes,we,
|
|
426
|
-
mctl",["show",
|
|
425
|
+
pt can be acknowledged.");try{qn(Nr(r))}catch(s){if(s.code!=="ENOENT")throw s}return{ok:!0,id:r.id}}if(n==="workflow-cre\
|
|
426
|
+
ate"){let o=ne(e.memoryMaxBytes,we,Ke,"workflow memory limit"),s=ne(e.tasksMax,Je,qe,"workflow task limit"),i=x(O("syste\
|
|
427
|
+
mctl",["show",Ze(t),"--property=MemoryMax","--value"]));if(i===null||o>i)throw new Error("Vibe64 exec helper rejected a \
|
|
427
428
|
workflow above its proven work-slice memory limit.");let a=ae(r);if(a.finishedAt)throw new Error("A completed workflow i\
|
|
428
429
|
dentity cannot be reused.");if(a.activeState==="active"){if(a.memoryMaxBytes!==o||a.tasksMax!==s)throw new Error("An act\
|
|
429
430
|
ive workflow cannot be reconfigured by retrying creation.");return{ok:!0,...a}}O("busctl",["--system","call","org.freede\
|
|
@@ -432,9 +433,9 @@ unitName,"fail","5","MemoryMax","t",String(o),"TasksMax","t",String(s),"MemoryAc
|
|
|
432
433
|
"true","TasksAccounting","b","true","0"]),O("systemctl",["start",r.unitName]);let c=ae(r);if(c.memoryMaxBytes!==o||c.tasksMax!==
|
|
433
434
|
s||c.scopeEmpty!==!0)throw new Error("Managed workflow creation could not prove its limits and empty accounting group.");
|
|
434
435
|
return{ok:!0,...c}}if(n==="workflow-finish"){let o=ae(r);if(!o.finishedAt){if(o.scopeEmpty!==!0)return{ok:!1,code:"workf\
|
|
435
|
-
low_not_empty",...o};
|
|
436
|
+
low_not_empty",...o};Ys(r,{...o,finishedAt:new Date().toISOString()})}let s=_("systemctl",["stop",r.unitName]),i=ae(r);if(i.
|
|
436
437
|
activeState!=="inactive"||i.controlGroup||i.scopeEmpty!==!0)throw new Error(String(s.stderr||"Managed workflow group did\
|
|
437
|
-
not stop.").trim());return{ok:!0,...i}}throw new Error("Vibe64 exec helper rejected an unknown workflow action.")}function
|
|
438
|
+
not stop.").trim());return{ok:!0,...i}}throw new Error("Vibe64 exec helper rejected an unknown workflow action.")}function Or(e,t,r,n){
|
|
438
439
|
let o=Object.fromEntries(O("systemctl",["show",e,"--no-pager","--property=ActiveState,ControlGroup,MemoryMax"]).split(`
|
|
439
440
|
`).map(c=>{let l=c.indexOf("=");return[c.slice(0,l),c.slice(l+1)]}));if(o.ActiveState!=="active"||o.ControlGroup!==t)throw new Error(
|
|
440
441
|
"Memory growth requires the same active, owned accounting group.");let s=x(Oe(B.join("/sys/fs/cgroup",t,"memory.max"),"u\
|
|
@@ -442,79 +443,79 @@ tf8")),i=x(o.MemoryMax);if(i===null||s!==Math.floor(i/r)*r)throw new Error("The
|
|
|
442
443
|
fied.");let a=Oe(B.join("/sys/fs/cgroup",t,"memory.high"),"utf8").trim();if(a!=="max"&&(x(a)===null||n>Number(a)))throw Object.
|
|
443
444
|
assign(new Error("Memory growth is blocked by the target's memory.high limit."),{limitingGroup:{controlGroup:t,limit:"me\
|
|
444
445
|
mory.high",maximumBytes:x(a),requestedBytes:n??null}});return{unitName:e,controlGroup:t,memoryMaxBytes:i,effectiveMemoryMaxBytes:s,
|
|
445
|
-
memoryHighBytes:a==="max"?null:x(a)}}function
|
|
446
|
+
memoryHighBytes:a==="max"?null:x(a)}}function vr(e,t){let r=[];for(let n=B.posix.dirname(e);n!=="/";n=B.posix.dirname(n)){
|
|
446
447
|
let o={controlGroup:n};for(let[s,i]of[["memory.max","memoryMaxBytes"],["memory.high","memoryHighBytes"]]){let a=Oe(B.join(
|
|
447
448
|
"/sys/fs/cgroup",n,s),"utf8").trim(),c=a==="max"?null:x(a);if(a!=="max"&&(c===null||t>c))throw Object.assign(new Error(`\
|
|
448
449
|
Memory growth is blocked by an ancestor ${s} limit.`),{limitingGroup:{controlGroup:n,limit:s,maximumBytes:c,requestedBytes:t}});
|
|
449
|
-
o[i]=c}r.push(o)}return r}function
|
|
450
|
+
o[i]=c}r.push(o)}return r}function zs(e,t,r){let n=e.action==="workflow-limits",o=!1,s=[],i=[],a=[],c=[],l=null;try{let u=ae(
|
|
450
451
|
t);if(u.activeState!=="active"||!u.controlGroup||u.finishedAt)throw new Error("Memory growth requires an active workflow\
|
|
451
|
-
.");let m=ne(e.memoryMaxBytes,we,
|
|
452
|
+
.");let m=ne(e.memoryMaxBytes,we,Ke,"workflow memory limit");if(!Array.isArray(e.executions)||e.executions.length>128)throw new Error(
|
|
452
453
|
"Memory growth requires a bounded list of owned executions.");if(l=x(O("getconf",["PAGESIZE"])),!l||l>we)throw new Error(
|
|
453
454
|
"The kernel memory limit granularity is unavailable.");a=[{unitName:t.unitName,controlGroup:u.controlGroup,memoryMaxBytes:Math.
|
|
454
|
-
floor(m/l)*l,expectedMemoryMaxBytes:e.expectedMemoryMaxBytes}];for(let p of e.executions){let d=ye(p?.id,r);if(a.some(
|
|
455
|
+
floor(m/l)*l,expectedMemoryMaxBytes:e.expectedMemoryMaxBytes}];for(let p of e.executions){let d=ye(p?.id,r);if(a.some(g=>g.
|
|
455
456
|
unitName===d))throw new Error("Duplicate memory growth execution.");let f=ne(p.memoryMaxBytes,we,bt,"execution memory li\
|
|
456
457
|
mit");if(f>m)throw new Error("Execution memory growth exceeds its workflow allowance.");a.push({unitName:d,controlGroup:`${u.
|
|
457
|
-
controlGroup}/${d}`,memoryMaxBytes:Math.floor(f/l)*l,expectedMemoryMaxBytes:p.expectedMemoryMaxBytes})}if(s=a.map(p=>
|
|
458
|
-
p.unitName,p.controlGroup,l,n?void 0:p.memoryMaxBytes)),n)return{ok:!0,id:t.id,pageSizeBytes:l,before:s,after:s,ancestors:
|
|
458
|
+
controlGroup}/${d}`,memoryMaxBytes:Math.floor(f/l)*l,expectedMemoryMaxBytes:p.expectedMemoryMaxBytes})}if(s=a.map(p=>Or(
|
|
459
|
+
p.unitName,p.controlGroup,l,n?void 0:p.memoryMaxBytes)),n)return{ok:!0,id:t.id,pageSizeBytes:l,before:s,after:s,ancestors:vr(
|
|
459
460
|
u.controlGroup)};for(let[p,d]of a.entries())if(d.expectedMemoryMaxBytes!==s[p].memoryMaxBytes||d.memoryMaxBytes<s[p].effectiveMemoryMaxBytes)
|
|
460
|
-
throw new Error("Memory growth cannot lower a live limit or apply to stale limits.");c=
|
|
461
|
+
throw new Error("Memory growth cannot lower a live limit or apply to stale limits.");c=vr(u.controlGroup,a[0].memoryMaxBytes);
|
|
461
462
|
for(let[p,d]of a.entries())s[p].memoryMaxBytes!==d.memoryMaxBytes&&(o=!0,O("systemctl",["set-property","--runtime",d.unitName,
|
|
462
|
-
`MemoryMax=${d.memoryMaxBytes}`]));if(i=a.map(p=>
|
|
463
|
+
`MemoryMax=${d.memoryMaxBytes}`]));if(i=a.map(p=>Or(p.unitName,p.controlGroup,l,p.memoryMaxBytes)),c=vr(u.controlGroup,a[0].
|
|
463
464
|
memoryMaxBytes),!i.every((p,d)=>p.memoryMaxBytes===a[d].memoryMaxBytes))throw new Error("Memory growth readback did not \
|
|
464
465
|
match the requested limits.");return{ok:!0,id:t.id,changeState:o?"applied":"unchanged",pageSizeBytes:l,before:s,after:i,
|
|
465
|
-
ancestors:c}}catch(u){let m="unchanged";return o&&(i=a.map(p=>{try{return
|
|
466
|
+
ancestors:c}}catch(u){let m="unchanged";return o&&(i=a.map(p=>{try{return Or(p.unitName,p.controlGroup,l)}catch{return null}}),
|
|
466
467
|
m=i.some(p=>p===null)?"unknown":i.every((p,d)=>p.memoryMaxBytes===s[d].memoryMaxBytes)?"unchanged":"partial"),{ok:!1,id:t.
|
|
467
468
|
id,code:"workflow_memory_growth_failed",changeState:m,error:String(u?.message||u),limitingGroup:u?.limitingGroup??null,pageSizeBytes:l,
|
|
468
|
-
before:s,after:i,ancestors:c}}}var
|
|
469
|
-
`).find(i=>i.startsWith("0::")),t=String(e||"").slice(3).replace(/^\/+/,""),r=t?ee.join("/sys/fs/cgroup",t):"";if(!r||!
|
|
470
|
-
r))return{};let n=
|
|
471
|
-
r),cpuUsageNSec:String(Number(n.usage_usec||0)*1e3),ioReadBytes:String(s.readBytes),ioWriteBytes:String(s.writeBytes),memoryCurrent:
|
|
472
|
-
ee.join(r,"memory.current")),memoryPeak:
|
|
473
|
-
oomKillCount:String(Number(o.oom_kill||0)),taskLimit:
|
|
474
|
-
r,"pids.peak"))}}function
|
|
475
|
-
code==="ENOENT")return"0";throw t}}function
|
|
469
|
+
before:s,after:i,ancestors:c}}}var br=15e3,Js=4096;function oo(){let e=String(rt("/proc/self/cgroup","utf8")||"").split(`
|
|
470
|
+
`).find(i=>i.startsWith("0::")),t=String(e||"").slice(3).replace(/^\/+/,""),r=t?ee.join("/sys/fs/cgroup",t):"";if(!r||!no(
|
|
471
|
+
r))return{};let n=ro(ee.join(r,"cpu.stat")),o=ro(ee.join(r,"memory.events")),s=qs(ee.join(r,"io.stat"));return{resourceCounters:xt(
|
|
472
|
+
r),cpuUsageNSec:String(Number(n.usage_usec||0)*1e3),ioReadBytes:String(s.readBytes),ioWriteBytes:String(s.writeBytes),memoryCurrent:tt(
|
|
473
|
+
ee.join(r,"memory.current")),memoryPeak:tt(ee.join(r,"memory.peak")),memorySwapCurrent:tt(ee.join(r,"memory.swap.current")),
|
|
474
|
+
oomKillCount:String(Number(o.oom_kill||0)),taskLimit:io(r),tasksCurrent:tt(ee.join(r,"pids.current")),tasksPeak:tt(ee.join(
|
|
475
|
+
r,"pids.peak"))}}function tt(e=""){try{let t=String(rt(e,"utf8")||"0").trim();return/^[0-9]+$/u.test(t)?t:"0"}catch(t){if(t?.
|
|
476
|
+
code==="ENOENT")return"0";throw t}}function io(e,t=rt){if(!e)return null;try{let r=a=>{try{return x(/^max\s+(\d+)$/mu.exec(
|
|
476
477
|
t(ee.join(e,a),"utf8"))?.[1])}catch{return null}},n=r("pids.events.local"),o=r("pids.events"),s=n>0?n:o;if(!(s>0))return null;
|
|
477
478
|
let i=t("/proc/self/mountinfo","utf8").split(`
|
|
478
479
|
`).find(a=>a.split(" ")[4]==="/sys/fs/cgroup"&&a.includes(" - cgroup2 "));return{source:"cgroup-pids-events",count:s,scope:n>
|
|
479
|
-
0&&i&&!i.split(/[ ,]/u).includes("pids_localevents")?"execution":"unknown"}}catch{return null}}function
|
|
480
|
-
fromEntries(String(
|
|
481
|
-
n||"")?[[r,n]]:[]}))}catch(t){if(t?.code==="ENOENT")return{};throw t}}function
|
|
480
|
+
0&&i&&!i.split(/[ ,]/u).includes("pids_localevents")?"execution":"unknown"}}catch{return null}}function ro(e=""){try{return Object.
|
|
481
|
+
fromEntries(String(rt(e,"utf8")||"").split(/\r?\n/u).flatMap(t=>{let[r,n]=t.trim().split(/\s+/u);return r&&/^[0-9]+$/u.test(
|
|
482
|
+
n||"")?[[r,n]]:[]}))}catch(t){if(t?.code==="ENOENT")return{};throw t}}function qs(e=""){let t="";try{t=rt(e,"utf8")}catch(o){
|
|
482
483
|
if(o?.code==="ENOENT")return{readBytes:0,writeBytes:0};throw o}let r=0,n=0;for(let o of String(t||"").split(/\r?\n/u))for(let s of o.
|
|
483
484
|
trim().split(/\s+/u).slice(1)){let[i,a]=s.split("=");i==="rbytes"&&(r+=Number(a||0)),i==="wbytes"&&(n+=Number(a||0))}return{
|
|
484
|
-
readBytes:r,writeBytes:n}}function
|
|
485
|
+
readBytes:r,writeBytes:n}}function so(e="",t="",r={},{query:n=_,readResult:o=Kn}={}){let s=n("systemctl",["show",e,"--no\
|
|
485
486
|
-pager","--timestamp=us+utc","--property=LoadState,ActiveState,SubState,Result,ExecMainCode,ExecMainStatus,ExecMainStart\
|
|
486
487
|
Timestamp,ExecMainExitTimestamp,MainPID,ControlGroup,MemoryCurrent,MemoryPeak,MemorySwapCurrent,TasksCurrent,TasksMax,CP\
|
|
487
488
|
UUsageNSec,IOReadBytes,IOWriteBytes"]),i={};for(let y of String(s.stdout||"").split(/\r?\n/u)){let M=y.indexOf("=");M>0&&
|
|
488
489
|
(i[y.slice(0,M)]=y.slice(M+1))}i.LoadState==="not-found"&&(i={LoadState:"not-found"});let a=String(i.ControlGroup||"").trim(),
|
|
489
|
-
c=a?ee.join("/sys/fs/cgroup",a.replace(/^\/+/,"")):"",l=xt(c),u=c&&
|
|
490
|
-
""),d=Number.isFinite(p)?"runner":"systemd",f=Number.isFinite(p)?p:Date.parse(i.ExecMainExitTimestamp||""),
|
|
490
|
+
c=a?ee.join("/sys/fs/cgroup",a.replace(/^\/+/,"")):"",l=xt(c),u=c&&no(c)?l.scopeEmpty:!0,m=t?o(r,t):{},p=Date.parse(m.exitObservedAt||
|
|
491
|
+
""),d=Number.isFinite(p)?"runner":"systemd",f=Number.isFinite(p)?p:Date.parse(i.ExecMainExitTimestamp||""),g=Number.isFinite(
|
|
491
492
|
f)&&f>0&&f<=Date.now()?new Date(f).toISOString():"";return{resourceCounters:m.resourceCounters||l,activeState:String(i.ActiveState||
|
|
492
493
|
(m.executionId?"inactive":"unknown")),controlGroup:a,cpuUsageNSec:ce(i.CPUUsageNSec,m.cpuUsageNSec),execMainCode:String(
|
|
493
|
-
i.ExecMainCode||m.execMainCode||""),execMainStatus:String(i.ExecMainStatus||m.execMainStatus||""),exitObservedAt:
|
|
494
|
+
i.ExecMainCode||m.execMainCode||""),execMainStatus:String(i.ExecMainStatus||m.execMainStatus||""),exitObservedAt:g,exitTimeSource:g?
|
|
494
495
|
d:"",ioReadBytes:ce(i.IOReadBytes,m.ioReadBytes),ioWriteBytes:ce(i.IOWriteBytes,m.ioWriteBytes),loadState:String(i.LoadState&&
|
|
495
496
|
i.LoadState!=="not-found"?i.LoadState:m.executionId?"recorded":"not-found"),mainPid:String(i.MainPID||"0"),memoryCurrent:ce(
|
|
496
497
|
i.MemoryCurrent,m.memoryCurrent),memoryPeak:ce(i.MemoryPeak,m.memoryPeak),memorySwapCurrent:ce(i.MemorySwapCurrent,m.memorySwapCurrent),
|
|
497
|
-
oomKillCount:ce(m.oomKillCount),taskLimit:m.taskLimit||
|
|
498
|
+
oomKillCount:ce(m.oomKillCount),taskLimit:m.taskLimit||io(c),result:String(i.Result||m.result||""),signal:String(m.signal||
|
|
498
499
|
""),controllerLeaseClosed:m.controllerLeaseClosed===!0,scopeEmpty:u,startedAt:i.ExecMainStartTimestamp||m.startedAt||"",
|
|
499
500
|
subState:String(i.SubState||"unknown"),tasksCurrent:ce(i.TasksCurrent,m.tasksCurrent),tasksPeak:ce(m.tasksPeak),tasksMax:String(
|
|
500
501
|
i.TasksMax||"0"),unitName:e}}function ce(...e){return String(e.reduce((t,r)=>{let n=Number(r);return Number.isFinite(n)&&
|
|
501
|
-
n>t?n:t},0))}function
|
|
502
|
-
if((n.result==="oom-kill"||Number(n.oomKillCount)>0)&&i>0&&a>=i){let c=Math.min(Date.now(),a+1e3),l=
|
|
502
|
+
n>t?n:t},0))}function ao(e="",t="",r={}){let n=so(e,t,r),o=null,s=n.taskLimit,i=Date.parse(n.startedAt),a=Date.parse(n.exitObservedAt);
|
|
503
|
+
if((n.result==="oom-kill"||Number(n.oomKillCount)>0)&&i>0&&a>=i){let c=Math.min(Date.now(),a+1e3),l=to("journalctl",["-k",
|
|
503
504
|
"--boot=0","--no-pager","--output=json","--output-fields=__REALTIME_TIMESTAMP,__SEQNUM_ID,__SEQNUM,_BOOT_ID,_SOURCE_MONO\
|
|
504
505
|
TONIC_TIMESTAMP,MESSAGE","--lines=65","--case-sensitive=yes",`--since=@${i/1e3}`,`--until=@${c/1e3}`,`--grep=^oom-kill:|\
|
|
505
506
|
^/[^,]*/${e.replaceAll(".","\\.")}(?:/[^,]*)?,task=`],{encoding:"utf8",timeout:2e3,maxBuffer:128*1024});!l.error&&l.status===
|
|
506
|
-
0&&(o=
|
|
507
|
-
a>=i){let c=Math.min(Date.now(),a+1e3),l=
|
|
507
|
+
0&&(o=Qs(l.stdout,{unitName:e,workspace:v(r.username),startedAt:i,until:c}))}if(!s&&n.result&&n.result!=="success"&&i>0&&
|
|
508
|
+
a>=i){let c=Math.min(Date.now(),a+1e3),l=to("journalctl",["-k","--boot=0","--no-pager","--output=json","--output-fields=\
|
|
508
509
|
__REALTIME_TIMESTAMP,MESSAGE","--lines=65","--case-sensitive=yes",`--since=@${i/1e3}`,`--until=@${c/1e3}`,`--grep=^cgrou\
|
|
509
510
|
p: fork rejected by pids controller in /.*${e.replaceAll(".","\\.")}(?:/|$)`],{encoding:"utf8",timeout:2e3,maxBuffer:128*
|
|
510
|
-
1024});!l.error&&l.status===0&&(s=
|
|
511
|
+
1024});!l.error&&l.status===0&&(s=Zs(l.stdout,{unitName:e,workspace:v(r.username),startedAt:i,until:c}))}Ks.stdout.write(
|
|
511
512
|
`${JSON.stringify({executionId:t,ok:!0,...n,oomBoundary:o,taskLimit:s})}
|
|
512
|
-
`)}function
|
|
513
|
+
`)}function Zs(e,{unitName:t,workspace:r,startedAt:n,until:o}){if(typeof e!="string"||Buffer.byteLength(e)>128*1024)return null;
|
|
513
514
|
let s=e.trim().split(/\r?\n/u);if(s.length>64)return null;for(let i of s){let a;try{a=JSON.parse(i)}catch{continue}let c=Number(
|
|
514
515
|
a?.__REALTIME_TIMESTAMP)/1e3;if(!Number.isFinite(c)||c<n||c>o)continue;let l=typeof a.MESSAGE=="string"&&/^cgroup: fork rejected by pids controller in (\/[a-zA-Z0-9_./-]{1,2048})$/u.
|
|
515
516
|
exec(a.MESSAGE)?.[1];if(!l)continue;let u=l.split("/"),m=u.indexOf(`vibe64-${r}-work.slice`);if(!(u[1]!=="vibe64.slice"||
|
|
516
517
|
m<2||u.indexOf(t)<=m||u.some((p,d)=>d>0&&(!p||p==="."||p===".."))))return{source:"kernel-journal",scope:"unknown",count:null,
|
|
517
|
-
recordedAt:new Date(c).toISOString()}}return null}function
|
|
518
|
+
recordedAt:new Date(c).toISOString()}}return null}function Qs(e,{unitName:t,workspace:r,startedAt:n,until:o}){if(typeof e!=
|
|
518
519
|
"string"||Buffer.byteLength(e)>128*1024)return null;let s=e.trim().split(/\r?\n/u);if(s.length>64)return null;let i=s.flatMap(
|
|
519
520
|
c=>{try{return[JSON.parse(c)]}catch{return[]}}),a=null;for(let c of i){let l=Number(c?.__REALTIME_TIMESTAMP)/1e3;if(!Number.
|
|
520
521
|
isFinite(l)||l<n||l>o)continue;let u=c.MESSAGE;if(typeof u=="string"&&u.startsWith("oom-kill:")&&u.endsWith(",task_memcg\
|
|
@@ -523,249 +524,254 @@ isFinite(l)||l<n||l>o)continue;let u=c.MESSAGE;if(typeof u=="string"&&u.startsWi
|
|
|
523
524
|
1&&Number(I._SOURCE_MONOTONIC_TIMESTAMP)>=Number(c._SOURCE_MONOTONIC_TIMESTAMP)&&Number(I._SOURCE_MONOTONIC_TIMESTAMP)-Number(
|
|
524
525
|
c._SOURCE_MONOTONIC_TIMESTAMP)<=1e6&&/^\/[a-zA-Z0-9_./-]+,task=[^,]+,pid=\d+,uid=\d+$/u.test(I.MESSAGE||""));A&&(u+=A.MESSAGE)}
|
|
525
526
|
let m=typeof u=="string"&&u.match(/^oom-kill:constraint=(CONSTRAINT_[A-Z_]+),.*?,(?:oom_memcg=(\/[^,]+)|(global_oom)),task_memcg=(\/[^,]+),task=/u);
|
|
526
|
-
if(!m)continue;let[,p,d,f,
|
|
527
|
-
ce"||M<2||j<=M||y.some((A,I)=>I>0&&(A==="."||A===".."||!/^[a-zA-Z0-9_.-]+$/u.test(A))))continue;let
|
|
528
|
-
_NONE"&&f)
|
|
529
|
-
0,j+1).join("/");
|
|
527
|
+
if(!m)continue;let[,p,d,f,g]=m,y=g.split("/"),M=y.indexOf(`vibe64-${r}-work.slice`),j=y.indexOf(t);if(y[1]!=="vibe64.sli\
|
|
528
|
+
ce"||M<2||j<=M||y.some((A,I)=>I>0&&(A==="."||A===".."||!/^[a-zA-Z0-9_.-]+$/u.test(A))))continue;let J;if(p==="CONSTRAINT\
|
|
529
|
+
_NONE"&&f)J="host";else if(p==="CONSTRAINT_MEMCG"&&d&&(g===d||g.startsWith(`${d}/`))){let A=d.split("/").at(-1),I=y.slice(
|
|
530
|
+
0,j+1).join("/");J=d===I||d.startsWith(`${I}/`)?"execution":A===`vibe64-${r}-work.slice`?"workspace_work":A===`vibe64-${r}\
|
|
530
531
|
.slice`?"workspace":A==="vibe64.slice"?"platform":/-work-p[a-f0-9]{64}-s[a-f0-9]{64}-w[a-f0-9]{32}\.slice$/u.test(A)?"wo\
|
|
531
532
|
rkflow":/-work-p[a-f0-9]{64}-s[a-f0-9]{64}\.slice$/u.test(A)?"session":/-work-p[a-f0-9]{64}\.slice$/u.test(A)?"project":
|
|
532
|
-
"ancestor"}else return null;let
|
|
533
|
-
nel-journal",scope:
|
|
533
|
+
"ancestor"}else return null;let q=d||"";if(a&&a.cgroup!==q)return null;(!a||l>Date.parse(a.recordedAt))&&(a={source:"ker\
|
|
534
|
+
nel-journal",scope:J,cgroup:q,recordedAt:new Date(l).toISOString()})}return a}function co(e){if(e==null)return br;if(!Number.
|
|
534
535
|
isSafeInteger(e)||e<0)throw new Error("Vibe64 exec helper rejected an invalid managed execution stop timeout.");return Math.
|
|
535
|
-
min(e,
|
|
536
|
+
min(e,br)}function uo(e="",t="",r={},{termTimeoutMs:n=br,run:o=_,readState:s=()=>so(e,t,r),removeRuntime:i=()=>{let l=Tt(
|
|
536
537
|
r);try{l.remove(t)}finally{l.close()}},now:a=Date.now,wait:c=l=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,
|
|
537
538
|
0,l)}={}){let l=s();l.scopeEmpty||o("systemctl",["stop","--no-block",e]);let u=a()+n,m=l.scopeEmpty?l:s();for(;!m.scopeEmpty&&
|
|
538
539
|
a()<u;)c(25),m=s();return m.scopeEmpty||o("systemctl",["kill","--kill-who=all","--signal=SIGKILL",e]),l.scopeEmpty||(o("\
|
|
539
540
|
systemctl",["stop",e]),m=s()),m.scopeEmpty&&(i(),o("systemctl",["reset-failed",e])),{executionId:t,ok:m.scopeEmpty,scopeEmpty:m.
|
|
540
|
-
scopeEmpty,stopped:l.scopeEmpty===!1,...m}}function
|
|
541
|
-
-plain","--no-legend","--full",`vibe64-exec-${v(w(e.username))}-*.service`]),openReceipts:n=()=>Tt(e),resetFailed:o=s=>
|
|
542
|
-
"systemctl",["reset-failed",...s])}={}){if(!Array.isArray(t)||t.length>
|
|
543
|
-
bounded list of the executions to keep.");let s=new Set(t.map(m=>ye(
|
|
541
|
+
scopeEmpty,stopped:l.scopeEmpty===!1,...m}}function lo(e={},t=[],{listUnits:r=()=>_("systemctl",["list-units","--all","-\
|
|
542
|
+
-plain","--no-legend","--full",`vibe64-exec-${v(w(e.username))}-*.service`]),openReceipts:n=()=>Tt(e),resetFailed:o=s=>_(
|
|
543
|
+
"systemctl",["reset-failed",...s])}={}){if(!Array.isArray(t)||t.length>Js)throw new Error("Vibe64 exec helper requires a\
|
|
544
|
+
bounded list of the executions to keep.");let s=new Set(t.map(m=>ye(z(m),e))),i=r();if(i.error||i.status!==0)throw new Error(
|
|
544
545
|
"Vibe64 exec helper could not list the workspace's execution units.");let a=new Set,c=[];for(let m of String(i.stdout||"").
|
|
545
546
|
split(/\r?\n/u)){let[p="",,d=""]=m.trim().split(/\s+/u);!p||s.has(p)||(d==="failed"?c.push(p):d!=="inactive"&&a.add(p))}
|
|
546
547
|
let l=0,u=n();try{for(let m of u.entries()){if(!hr.test(m)||m!==m.toLowerCase())continue;let p=ye(m,e);s.has(p)||a.has(p)||
|
|
547
548
|
(u.remove(m),l+=1)}}finally{u.close()}for(let m=0;m<c.length;m+=256)o(c.slice(m,m+256));return{ok:!0,released:l,reset:c.
|
|
548
|
-
length}}var
|
|
549
|
-
"workflow-")){let
|
|
550
|
-
`),
|
|
551
|
-
`);return}let o=
|
|
552
|
-
e.termTimeoutMs)});L.stdout.write(`${JSON.stringify(
|
|
553
|
-
`),
|
|
554
|
-
on action.");let i=
|
|
549
|
+
length}}var mo="resource-controller.sock",Tr=5e3,sa=5e3;function fo(e={}){let t=U(),r=Ee(k),n=String(e.action||"").trim();if(n.startsWith(
|
|
550
|
+
"workflow-")){let F=eo(e,t);L.stdout.write(`${JSON.stringify(F)}
|
|
551
|
+
`),F.ok!==!0&&(L.exitCode=1);return}if(n==="release-ended"){L.stdout.write(`${JSON.stringify(lo(t,e.keepExecutionIds))}
|
|
552
|
+
`);return}let o=z(e.executionId),s=ye(o,t);if(n==="inspect"){ao(s,o,t);return}if(n==="stop"){let F=uo(s,o,t,{termTimeoutMs:co(
|
|
553
|
+
e.termTimeoutMs)});L.stdout.write(`${JSON.stringify(F)}
|
|
554
|
+
`),F.scopeEmpty||L.exit(1);return}if(n!=="start")throw new Error("Vibe64 exec helper rejected an unknown managed executi\
|
|
555
|
+
on action.");let i=Hn(e.mode),a=Wn(e.kind),c=String(e.lifecycle||"").trim();if(c!==(i==="capture"?"finite":i==="pty"?"in\
|
|
555
556
|
teractive":"service"))throw new Error("Vibe64 exec helper rejected a managed execution lifecycle mismatch.");let u=ho(e.
|
|
556
|
-
controllerLeaseName,c,t),m=
|
|
557
|
-
s only finite commands.");let d=String(e.commandOperation||"").trim(),f=p
|
|
558
|
-
targetUser:m}),
|
|
559
|
-
nvalid managed execution command.");if(!p&&m.username!==t.username&&!
|
|
560
|
-
helper rejected an unsupported real-user managed command.");let y=Array.isArray(e.args)?e.args.map(
|
|
557
|
+
controllerLeaseName,c,t),m=Fn(e,t),p=m.application||null;if(p&&i!=="capture")throw new Error("An application account run\
|
|
558
|
+
s only finite commands.");let d=String(e.commandOperation||"").trim(),f=p?$n(e.cwd||"",p):lt(e.cwd||"",t.username,{operation:d,
|
|
559
|
+
targetUser:m}),g=String(e.command||"").trim();if(!g||/[\r\n]/u.test(g))throw new Error("Vibe64 exec helper rejected an i\
|
|
560
|
+
nvalid managed execution command.");if(!p&&m.username!==t.username&&!ct.has(fe.basename(g)))throw new Error("Vibe64 exec\
|
|
561
|
+
helper rejected an unsupported real-user managed command.");let y=Array.isArray(e.args)?e.args.map(F=>String(F)):[],M=je(
|
|
561
562
|
e.env||{},m,t.username,d);if(e.usageRecordingPreload){if(p)throw new Error("An application account does not run the usag\
|
|
562
|
-
e recorder.");M.NODE_OPTIONS=
|
|
563
|
-
lease environment requires an application's own execution.");j=
|
|
563
|
+
e recorder.");M.NODE_OPTIONS=Qr(e.usageRecordingPreload)}let j="";if(e.releaseEnvironmentFile){if(!p)throw new Error("Re\
|
|
564
|
+
lease environment requires an application's own execution.");j=fr(e.releaseEnvironmentFile,p,{cwd:f,daemonUid:t.uid,gid:m.
|
|
564
565
|
gid})}if(e.sandboxAllowances!==void 0&&!p)throw new Error("Sandbox allowances require an application's own execution.");
|
|
565
|
-
let
|
|
566
|
-
e.workMemoryMaxBytes,
|
|
567
|
-
"Vibe64 exec helper rejected an execution limit above its work-slice limit.");let
|
|
568
|
-
t),
|
|
569
|
-
n execution without its active workflow group.");if(
|
|
570
|
-
er rejected an execution limit above its workflow limit.");
|
|
571
|
-
|
|
566
|
+
let J=p?_t(e.sandboxAllowances):[],q=ne(e.memoryMaxBytes,we,bt,"memory limit"),A=ne(e.tasksMax,Je,qe,"task limit"),I=ne(
|
|
567
|
+
e.workMemoryMaxBytes,Vn,Ke,"work-slice memory limit"),ot=ne(e.workTasksMax,Je,qe,"work-slice task limit");if(q>I||A>ot)throw new Error(
|
|
568
|
+
"Vibe64 exec helper rejected an execution limit above its work-slice limit.");let Ur=Ze(t);if(e.workflow){let F=_r(e.workflow,
|
|
569
|
+
t),Ie=ae(F);if(Ie.activeState!=="active"||!Ie.controlGroup||Ie.finishedAt)throw new Error("Vibe64 exec helper rejected a\
|
|
570
|
+
n execution without its active workflow group.");if(q>Ie.memoryMaxBytes||A>Ie.tasksMax)throw new Error("Vibe64 exec help\
|
|
571
|
+
er rejected an execution limit above its workflow limit.");Ur=F.unitName}else Qn(t,{memoryMaxBytes:I,tasksMax:ot});let kt=p?
|
|
572
|
+
yr(t,{create:!0}):Ar(t,{create:!0,gid:r}),Br=kt.create(o,m,{...p?{application:!0}:{},args:y,command:g,controllerLeaseName:u,
|
|
572
573
|
cwd:f,env:M,inputBase64:String(e.inputBase64||""),inputPresent:e.inputPresent===!0,...j?{releaseEnvironmentFile:j}:{},executionId:o},
|
|
573
|
-
{privateDirectory:i==="detached"}),Vo=fe.join(
|
|
574
|
-
c",`--slice=${
|
|
575
|
-
--property=${
|
|
574
|
+
{privateDirectory:i==="detached"}),Vo=fe.join(Br,"command.json"),Fo=re(),Wo=["--quiet",`--unit=${s}`,"--service-type=exe\
|
|
575
|
+
c",`--slice=${Ur}`,`--property=Description=Vibe64 ${a} execution`,...tr(m,{receiptRoot:Br,sandboxAllowances:J}).map(F=>`\
|
|
576
|
+
--property=${F}`),...p?[]:[`--property=${wt(t)}`],`--property=WorkingDirectory=${f}`,"--property=KillMode=control-group",
|
|
576
577
|
"--property=ExitType=cgroup","--property=OOMPolicy=stop","--property=MemoryAccounting=yes","--property=IOAccounting=yes",
|
|
577
|
-
"--property=TasksAccounting=yes",`--property=MemoryMax=${
|
|
578
|
+
"--property=TasksAccounting=yes",`--property=MemoryMax=${q}`,`--property=TasksMax=${A}`,"--property=TimeoutStopSec=10s",
|
|
578
579
|
...i==="capture"?["--property=LogLevelMax=notice","--wait","--pipe"]:[],...i==="pty"?["--wait","--pty"]:[],...m.username!==
|
|
579
|
-
t.username?["/usr/bin/setpriv","--no-new-privs","--"]:[],Fo,"run-managed",Vo],_e=
|
|
580
|
+
t.username?["/usr/bin/setpriv","--no-new-privs","--"]:[],Fo,"run-managed",Vo],_e=ta("systemd-run",Wo,{stdio:"inherit"});
|
|
580
581
|
if((i!=="detached"||_e.error||_e.status!==0)&&kt.remove(o),kt.close(),_e.error)throw _e.error;L.exit(typeof _e.status=="\
|
|
581
|
-
number"?_e.status:1)}async function
|
|
582
|
+
number"?_e.status:1)}async function go(e=""){let t=fe.resolve(String(e||"")),r=ra(t,"utf8");na(t);let n=JSON.parse(r);if(n?.
|
|
582
583
|
schema!=="vibe64.managed-execution.command"||n?.schemaVersion!==1)throw new Error("Vibe64 managed execution runner rejec\
|
|
583
584
|
ted an invalid payload.");let o=String(n.command||"").trim();if(!o||/[\r\n]/u.test(o))throw new Error("Vibe64 managed ex\
|
|
584
|
-
ecution runner rejected an invalid command.");let s=ho(n.controllerLeaseName,n.controllerLeaseName?"service":""),i=s?await
|
|
585
|
-
s):null;L.umask(n.application===!0?63:7);let a=null,c=null,l=!1,u=()=>{l=!0,a&&c===null&&(c=
|
|
586
|
-
toISOString(),p="";try{a=
|
|
587
|
-
|
|
585
|
+
ecution runner rejected an invalid command.");let s=ho(n.controllerLeaseName,n.controllerLeaseName?"service":""),i=s?await aa(
|
|
586
|
+
s):null;L.umask(n.application===!0?63:7);let a=null,c=null,l=!1,u=()=>{l=!0,a&&c===null&&(c=po(a))};i?.once("close",u);let m=new Date().
|
|
587
|
+
toISOString(),p="";try{a=ea(o,Array.isArray(n.args)?n.args.map(String):[],{cwd:String(n.cwd||"/"),detached:!!i,env:n.releaseEnvironmentFile?
|
|
588
|
+
je({...L.env,...Se(n.releaseEnvironmentFile),...n.env},{application:n.application===!0,home:n.env.HOME,username:n.env.USER},
|
|
588
589
|
n.env.USER):n.env&&typeof n.env=="object"&&!Array.isArray(n.env)?n.env:{},stdio:n.inputPresent===!0?["pipe","inherit","i\
|
|
589
|
-
nherit"]:"inherit"}),n.inputPresent===!0&&a.stdin.end(Buffer.from(String(n.inputBase64||""),"base64")),l&&(c=
|
|
590
|
-
(
|
|
591
|
-
PE"&&y(j)}),a.once("close",(j,
|
|
592
|
-
status=="number"?d.status:1;
|
|
590
|
+
nherit"]:"inherit"}),n.inputPresent===!0&&a.stdin.end(Buffer.from(String(n.inputBase64||""),"base64")),l&&(c=po(a));let d=await new Promise(
|
|
591
|
+
(g,y)=>{let M="";a.once("exit",()=>{M=new Date().toISOString()}),a.once("error",y),a.stdin?.on("error",j=>{j.code!=="EPI\
|
|
592
|
+
PE"&&y(j)}),a.once("close",(j,J)=>g({signal:J,status:j,exitObservedAt:M}))});c!==null&&await ca(a,c.startedAt);let f=typeof d.
|
|
593
|
+
status=="number"?d.status:1;Jn(fe.dirname(t),{...oo(),...l?{controllerLeaseClosed:!0}:{},executionId:z(n.executionId),startedAt:m,
|
|
593
594
|
exitObservedAt:d.exitObservedAt,execMainCode:d.signal?"killed":"exited",execMainStatus:d.signal||String(f),result:d.signal?
|
|
594
|
-
"signal":f===0?"success":"exit-code",signal:String(d.signal||"")}),p=d.signal||"",L.exitCode=p?128+(
|
|
595
|
+
"signal":f===0?"success":"exit-code",signal:String(d.signal||"")}),p=d.signal||"",L.exitCode=p?128+(ia.signals[p]||0):f}finally{
|
|
595
596
|
c!==null&&clearTimeout(c.timer),i?.off("close",u),i?.destroy()}p&&i&&L.kill(L.pid,p)}function ho(e="",t="",r=null){let n=String(
|
|
596
597
|
e||"");if(t!=="service"){if(n)throw new Error("Vibe64 exec helper rejected a controller lease on a finite execution.");return""}
|
|
597
|
-
if(!(r?n===fe.join(
|
|
598
|
-
er rejected an invalid managed service controller lease.");return n}function
|
|
598
|
+
if(!(r?n===fe.join(Le(r),mo):fe.isAbsolute(n)&&fe.resolve(n)===n&&fe.basename(n)===mo))throw new Error("Vibe64 exec help\
|
|
599
|
+
er rejected an invalid managed service controller lease.");return n}function aa(e=""){return new Promise((t,r)=>{let n=oa(
|
|
599
600
|
{path:e}),o=setTimeout(()=>{n.destroy(),r(new Error("Vibe64 managed service could not attach to its controller lease."))},
|
|
600
601
|
3e3);o.unref(),n.once("connect",()=>{clearTimeout(o),n.removeListener("error",s),n.on("error",()=>n.destroy()),t(n)}),n.
|
|
601
602
|
once("error",s);function s(i){clearTimeout(o),n.destroy(),r(new Error(`Vibe64 managed service controller lease is unavai\
|
|
602
|
-
lable: ${i?.code||i}`))}})}function
|
|
603
|
-
return r.unref(),{startedAt:t,timer:r}}async function
|
|
603
|
+
lable: ${i?.code||i}`))}})}function po(e=null){let t=Date.now();xr(e,"SIGTERM");let r=setTimeout(()=>xr(e,"SIGKILL"),Tr);
|
|
604
|
+
return r.unref(),{startedAt:t,timer:r}}async function ca(e,t){let r=!1;for(;ua(e);){let n=Date.now()-t;if(n>=Tr+sa){L.stderr.
|
|
604
605
|
write(`Vibe64 managed service process tree did not stop after SIGKILL.
|
|
605
|
-
`);return}!r&&n>=
|
|
606
|
-
pid);if(!Number.isSafeInteger(t)||t<=1)return!1;try{return L.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function
|
|
606
|
+
`);return}!r&&n>=Tr&&(xr(e,"SIGKILL"),r=!0),await new Promise(o=>setTimeout(o,25))}}function ua(e=null){let t=Number(e?.
|
|
607
|
+
pid);if(!Number.isSafeInteger(t)||t<=1)return!1;try{return L.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function xr(e=null,t="\
|
|
607
608
|
SIGTERM"){let r=Number(e?.pid);if(!(!Number.isSafeInteger(r)||r<=1))try{L.kill(-r,t)}catch(n){if(n?.code==="ESRCH")return;
|
|
608
609
|
try{e.kill(t)}catch(o){o?.code!=="ESRCH"&&L.stderr.write(`Vibe64 managed service process tree could not be stopped.
|
|
609
|
-
`)}}}import{spawnSync as
|
|
610
|
-
import
|
|
611
|
-
import ve from"node:path";import
|
|
612
|
-
t);return}if(r==="remove"){
|
|
613
|
-
deployment service action.");let o=
|
|
614
|
-
sandboxAllowances),a=[...new Set((Array.isArray(e.requiredUnits)?e.requiredUnits:[]).map(p=>yt(p,t)))],c=
|
|
615
|
-
l=
|
|
616
|
-
owner:t,requiredUnits:a,sandboxAllowances:i,servicePath:
|
|
617
|
-
unitPath:u,unitRoot:l})}var yo=80,
|
|
618
|
-
if(!Number.isSafeInteger(e)||e<1||e>
|
|
619
|
-
if(t&&!
|
|
620
|
-
|
|
621
|
-
-property=ActiveState,SubState,Result,ExecMainCode,ExecMainStatus,NRestarts"]),s=
|
|
610
|
+
`)}}}import{spawnSync as Cr}from"node:child_process";import{existsSync as Na,readFileSync as Lr,readlinkSync as jr}from"node:fs";
|
|
611
|
+
import ba from"node:os";import $r from"node:path";import K from"node:process";import{closeSync as Mt,fsyncSync as la,openSync as ma,readdirSync as pa,readFileSync as So,unlinkSync as Rr,writeFileSync as da}from"node:fs";
|
|
612
|
+
import ve from"node:path";import oe from"node:process";var fa=64;function wo(e={}){let t=U();Ee(k);let r=String(e.action||"").trim(),n=He(e.unitName,t);if(r==="inspect"){ha(n,
|
|
613
|
+
t);return}if(r==="remove"){_a(n,t);return}if(r!=="install-start")throw new Error("Vibe64 exec helper rejected an unknown\
|
|
614
|
+
deployment service action.");let o=xe(t,e.applicationAccount),s=Dn(e,o.application,{daemonUid:t.uid,gid:o.gid}),i=_t(e.
|
|
615
|
+
sandboxAllowances),a=[...new Set((Array.isArray(e.requiredUnits)?e.requiredUnits:[]).map(p=>yt(p,t)))],c=rr(e.loopbackPort),
|
|
616
|
+
l=V();Cn({loopbackPort:c,owner:t,unitName:n,unitRoot:l,user:o});let u=ar(n,t,l),m=vn({...s,helperPath:re(),loopbackPort:c,
|
|
617
|
+
owner:t,requiredUnits:a,sandboxAllowances:i,servicePath:ut(),unitName:n,user:o});vo({activation:"restart",unit:m,unitName:n,
|
|
618
|
+
unitPath:u,unitRoot:l})}var yo=80,Eo=5e3,ga=/^[0-9A-Za-z][0-9A-Za-z :.+-]{0,63}$/u;function Ao({lines:e=yo,since:t=""}={}){
|
|
619
|
+
if(!Number.isSafeInteger(e)||e<1||e>Eo)throw new Error(`Vibe64 exec helper reads 1 to ${Eo} lines of a service's output.`);
|
|
620
|
+
if(t&&!ga.test(t))throw new Error("Vibe64 exec helper rejected a service output start time.");return{lines:e,since:t}}function ha(e="",t={}){
|
|
621
|
+
He(e,t),It(e)}function It(e="",{lines:t=yo,since:r="",timestamps:n=!1}={}){let o=O("systemctl",["show",e,"--no-pager","-\
|
|
622
|
+
-property=ActiveState,SubState,Result,ExecMainCode,ExecMainStatus,NRestarts"]),s=_("journalctl",["--unit",e,"--no-pager",
|
|
622
623
|
n?"--output=short-iso":"--output=cat",`--lines=${t}`,...r?[`--since=${r}`]:[]]),i=String(s.stdout||s.stderr||"").trim();
|
|
623
|
-
|
|
624
|
+
oe.stdout.write(["Service state:",o,...i?["","Recent service output:",i]:[]].join(`
|
|
624
625
|
`)+`
|
|
625
|
-
`)}function Oo(e={}){let t=U();Ee(k);let r=String(e.action||"").trim(),n=yt(e.unitName,t);if(r==="stop"){
|
|
626
|
-
`${JSON.stringify(
|
|
627
|
-
`);return}if(r
|
|
628
|
-
|
|
629
|
-
t
|
|
630
|
-
|
|
631
|
-
|
|
626
|
+
`)}function Oo(e={}){let t=U();Ee(k);let r=String(e.action||"").trim(),n=yt(e.unitName,t);if(r==="stop"){oe.stdout.write(
|
|
627
|
+
`${JSON.stringify(Ea(n))}
|
|
628
|
+
`);return}if(r==="restart"){oe.stdout.write(`${JSON.stringify(Sa(n))}
|
|
629
|
+
`);return}if(r!=="install-start")throw new Error("Vibe64 exec helper rejected an unknown managed service action.");let o=or(
|
|
630
|
+
e.workingDirectory,t,"workingDirectory"),s=or(e.startScript,t,"startScript"),i=sr(e.processModel),a=i==="forking"?ir(e.pidFile,
|
|
631
|
+
t):"",c=V(),l=An(n,t,c),u=_n({owner:t,pidFile:a,processModel:i,servicePath:ut(),startScript:s,unitName:n,workingDirectory:o});
|
|
632
|
+
wa({owner:t,pidFile:a,unitName:n}),vo({activation:"start",enable:!1,unit:u,unitName:n,unitPath:l,unitRoot:c})}function Ea(e="",{
|
|
633
|
+
query:t=_}={}){let r=i=>String(t("systemctl",["is-active",i]).stdout||"").trim(),n=i=>i==="inactive"||i==="failed",o=String(
|
|
632
634
|
t("systemctl",["show",e,"--property=RequiredBy","--value"]).stdout||"").split(/\s+/u).filter(Boolean).filter(i=>!n(r(i)));
|
|
633
|
-
if(o.length>0)return{ok:!0,requiredBy:o,state:"required"};let s=!n(r(e));return s&&
|
|
634
|
-
["is-enabled",e]).stdout||"").trim()==="enabled"&&
|
|
635
|
-
function
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
e.
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
"
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
635
|
+
if(o.length>0)return{ok:!0,requiredBy:o,state:"required"};let s=!n(r(e));return s&&Ir(t,["stop",e]),String(t("systemctl",
|
|
636
|
+
["is-enabled",e]).stdout||"").trim()==="enabled"&&Ir(t,["disable",e]),{ok:!0,requiredBy:[],state:s?"stopped":"inactive"}}
|
|
637
|
+
function Sa(e="",{query:t=_}={}){if(String(t("systemctl",["show",e,"--property=LoadState","--value"]).stdout||"").trim()!==
|
|
638
|
+
"loaded")return{ok:!0,restarted:[],state:"absent"};let r=o=>o==="inactive"||o==="failed",n=String(t("systemctl",["show",
|
|
639
|
+
e,"--property=RequiredBy","--value"]).stdout||"").split(/\s+/u).filter(Boolean).filter(o=>!r(String(t("systemctl",["is-a\
|
|
640
|
+
ctive",o]).stdout||"").trim()));return Ir(t,["restart",e]),{ok:!0,restarted:n,state:"restarted"}}function Ir(e,t=[]){let r=e(
|
|
641
|
+
"systemctl",t);if(r.status!==0)throw new Error(String(r.stderr||r.stdout||`systemctl ${t[0]} failed.`).trim())}function wa({
|
|
642
|
+
owner:e={},pidFile:t="",unitName:r="",workspaceRoot:n=ve.join(ge,v(w(e.username)))}={}){let o=t?Aa(t,e,n):null;if(o)try{
|
|
643
|
+
ya(o,e,r)}finally{o.close()}}function ya(e,t={},r=""){let n=e.read();if(n===null)return;if(!/^[1-9][0-9]*$/u.test(n))throw new Error(
|
|
644
|
+
"Vibe64 managed service PID file is invalid.");let o=Number(n);if(!Number.isSafeInteger(o)||o<=1)throw new Error("Vibe64\
|
|
645
|
+
managed service PID is invalid.");if(!Mr(o)){e.remove(n);return}let s=Oa(o);if(s===null){e.remove(n);return}if(s!==t.uid)
|
|
646
|
+
throw new Error("Vibe64 managed service PID belongs to another OS user.");if(va(o,r))return;try{oe.kill(o,"SIGTERM")}catch(c){
|
|
647
|
+
if(c?.code==="ESRCH"){e.remove(n);return}throw c}let i=Date.now()+3e4,a=new Int32Array(new SharedArrayBuffer(4));for(;Mr(
|
|
648
|
+
o)&&Date.now()<i;)Atomics.wait(a,0,0,100);if(Mr(o))throw new Error("Vibe64 managed service process did not stop cleanly \
|
|
649
|
+
during ownership transfer.");e.remove(n)}function Aa(e="",t={},r=""){let n=R(N(r),ve.dirname(e));if(n.length===0)throw new Error(
|
|
650
|
+
"Vibe64 exec helper rejected a managed service PID file outside its workspace.");let o;try{o=Q(r,n)}catch(a){if(a?.code===
|
|
651
|
+
"ENOENT")return null;throw a}let s=ve.basename(e),i=()=>{try{return T(o,s,{maxBytes:fa,uid:t.uid}).trim()}catch(a){if(a?.
|
|
652
|
+
code==="ENOENT")return null;throw a}};return{close:()=>Mt(o),read:i,remove(a=""){i()===a&&Rr(h(o,s))}}}function Mr(e=0){
|
|
653
|
+
try{return oe.kill(e,0),!0}catch(t){if(t?.code==="ESRCH")return!1;throw t}}function Oa(e=0){let t="";try{t=So(`/proc/${e}\
|
|
654
|
+
/status`,"utf8")}catch(o){if(o?.code==="ENOENT")return null;throw o}let r=String(t||"").match(/^Uid:\s+([0-9]+)/mu),n=Number(
|
|
655
|
+
r?.[1]);if(!Number.isSafeInteger(n))throw new Error("Vibe64 managed service process UID is unavailable.");return n}function va(e=0,t=""){
|
|
656
|
+
let r=`/${t}`,n="";try{n=So(`/proc/${e}/cgroup`,"utf8")}catch(o){if(o?.code==="ENOENT")return!1;throw o}return String(n||
|
|
657
|
+
"").split(`
|
|
658
|
+
`).some(o=>o.trim().endsWith(r))}function vo({activation:e="start",enable:t=!0,rootUid:r=0,run:n=O,runAllowFailure:o=_,unit:s="",
|
|
659
|
+
unitName:i="",unitPath:a="",unitRoot:c=V()}={}){if(e!=="start"&&e!=="restart")throw new Error("Vibe64 exec helper reject\
|
|
660
|
+
ed an unsupported systemd activation.");let l=c!==Be;l&&Mt(_o(c,r));let u=`${a}.tmp-${oe.pid}`,m=ma(u,"w",420);try{da(m,
|
|
661
|
+
s),la(m)}finally{Mt(m)}try{n("mv",[u,a])}catch(p){try{Rr(u)}catch{}throw p}st(ve.dirname(a)),l&&n("systemctl",[t?"enable":
|
|
656
662
|
"link","--runtime",a]),n("systemctl",["daemon-reload"]),t&&!l&&n("systemctl",["enable",i]),o("systemctl",["reset-failed",
|
|
657
|
-
i]);try{n("systemctl",[e,i])}catch(p){throw o("systemctl",["stop",i]),p}}function _o(e="",t=0){try{return
|
|
663
|
+
i]);try{n("systemctl",[e,i])}catch(p){throw o("systemctl",["stop",i]),p}}function _o(e="",t=0){try{return H(e,t)}catch(r){
|
|
658
664
|
throw new Error(`Vibe64 exec helper refused unit folder ${e}: it is not a folder only root can change${r.code?` (${r.code}\
|
|
659
|
-
)`:""}.`)}}function
|
|
660
|
-
ime"],e]),
|
|
661
|
-
mon-reload"])}function No({rootUid:e=0,runAllowFailure:t=
|
|
665
|
+
)`:""}.`)}}function _a(e="",t={},r=V()){He(e,t),_("systemctl",["stop",e]),_("systemctl",["disable",...r===Be?[]:["--runt\
|
|
666
|
+
ime"],e]),_("systemctl",["reset-failed",e]);try{Rr(ar(e,t,r))}catch(n){if(n?.code!=="ENOENT")throw n}O("systemctl",["dae\
|
|
667
|
+
mon-reload"])}function No({rootUid:e=0,runAllowFailure:t=_,unitRoot:r=V()}={}){if(r===Be)return;let n=[],o=(a,c)=>{let l=t(
|
|
662
668
|
"systemctl",a);return l.status===0?!0:(n.push(`${c}: ${String(l.stderr||l.stdout||`systemctl ${a[0]} failed.`).trim()}`),
|
|
663
|
-
!1)},s=[],i=_o(r,e);try{for(let a of
|
|
669
|
+
!1)},s=[],i=_o(r,e);try{for(let a of pa(h(i)).sort()){let c=/^vibe64-(release|managed)-[A-Za-z0-9_.@:-]+\.service$/u.exec(
|
|
664
670
|
a)?.[1];if(!c)continue;try{T(i,a,{maxBytes:64*1024,othersMayWrite:!1,uid:e})}catch(u){n.push(`${a}: not a unit file root\
|
|
665
671
|
wrote (${u.code||u.message})`);continue}let l=c==="release";o([l?"enable":"link","--runtime",ve.join(r,a)],a)&&l&&s.push(
|
|
666
672
|
a)}}finally{Mt(i)}o(["daemon-reload"],"daemon-reload");for(let a of s)o(["start","--no-block",a],a);if(n.length>0)throw new Error(
|
|
667
673
|
`Vibe64 exec helper could not relink every unit in ${r}:
|
|
668
674
|
${n.join(`
|
|
669
|
-
`)}`)}function bo(e="",t=""){if(
|
|
670
|
-
exec-helper run-release-service <environment-file> <start-script>");
|
|
671
|
-
424b4456d9802ca8333ed424a":"closed","8d45620c1a4348dbb17410da57c60c66":"opened"}),
|
|
672
|
-
|
|
673
|
-
freeze(["/usr/lib/openssh/sftp-server","/usr/libexec/openssh/sftp-server","/usr/lib/sftp-server"]),
|
|
674
|
-
xo="/usr/bin/nsenter";function
|
|
675
|
-
`)}function $o(e={}){let t=U(),r=String(e.action||"").trim(),n=
|
|
676
|
-
"").trim();if(!
|
|
677
|
-
|
|
678
|
-
n.username)});return}if(r==="activity"){
|
|
679
|
-
ec helper rejected an unknown staging access action.")}function Mo(e=[],t=
|
|
680
|
-
t=json",`--lines=${
|
|
681
|
-
`).filter(Boolean);return{entries:n.slice(-
|
|
682
|
-
return Number.isFinite(a)?[{at:new Date(a).toISOString(),entry:i}]:[]}catch{return[]}}),olderOmitted:n.length>
|
|
683
|
-
runRootAllowFailure:t=
|
|
675
|
+
`)}`)}function bo(e="",t=""){if(oe.argv.length!==5||!ve.isAbsolute(e)||!ve.isAbsolute(t))throw new Error("Usage: vibe64-\
|
|
676
|
+
exec-helper run-release-service <environment-file> <start-script>");dr(oe.cwd()),oe.execve(t,[t],{...oe.env,...Se(e)})}var Ta=/^ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI[A-Za-z0-9+/]{43}$/u,Po="vibe64-staging",kr=500,xa=Object.freeze({"3354939\
|
|
677
|
+
424b4456d9802ca8333ed424a":"closed","8d45620c1a4348dbb17410da57c60c66":"opened"}),Ma=200,Ia=/^[A-Za-z0-9._:-]{1,128}$/u,
|
|
678
|
+
Ra=/^[A-Za-z0-9]{1,32}$/u,nt=Object.freeze(["/bin/bash","--noprofile","--norc"]),ka='[ "$#" -eq 0 ] || exec "$@"',To=Object.
|
|
679
|
+
freeze(["/usr/lib/openssh/sftp-server","/usr/libexec/openssh/sftp-server","/usr/lib/sftp-server"]),Pa=/ run-release-service "((?:[^"\\]|\\.)*)" "((?:[^"\\]|\\.)*)"$/u,
|
|
680
|
+
xo="/usr/bin/nsenter";function Pr(e){K.stdout.write(`${JSON.stringify({ok:!0,...e})}
|
|
681
|
+
`)}function $o(e={}){let t=U(),r=String(e.action||"").trim(),n=ze(t,e.project);if(r==="grant"){let o=String(e.publicKey||
|
|
682
|
+
"").trim();if(!Ta.test(o))throw new Error("Vibe64 exec helper accepts one ssh-ed25519 public key for staging access.");Sn(
|
|
683
|
+
xe(t,n.username),o,re()),Pr({account:n.username});return}if(r==="revoke"){Pr({account:n.username,revoked:St(he(n.username),
|
|
684
|
+
n.username)});return}if(r==="activity"){Pr({account:n.username,...$a(he(n.username))});return}throw new Error("Vibe64 ex\
|
|
685
|
+
ec helper rejected an unknown staging access action.")}function Mo(e=[],t=_){let r=t("journalctl",["--no-pager","--outpu\
|
|
686
|
+
t=json",`--lines=${kr+1}`,...e]),n=String(r.stdout||"").split(`
|
|
687
|
+
`).filter(Boolean);return{entries:n.slice(-kr).flatMap(s=>{try{let i=JSON.parse(s),a=Number(i.__REALTIME_TIMESTAMP)/1e3;
|
|
688
|
+
return Number.isFinite(a)?[{at:new Date(a).toISOString(),entry:i}]:[]}catch{return[]}}),olderOmitted:n.length>kr}}function $a(e,{
|
|
689
|
+
runRootAllowFailure:t=_}={}){if(!e)return{entries:[],olderOmitted:{host:!1,login:!1}};let r=Mo(["_UID=0","_SYSTEMD_UNIT=\
|
|
684
690
|
systemd-logind.service",`USER_ID=${e.username}`],t),n=Mo([`SYSLOG_IDENTIFIER=${Po}`,`_UID=${e.uid}`],t);return{entries:[
|
|
685
|
-
...r.entries.flatMap(({at:s,entry:i})=>{let a=
|
|
691
|
+
...r.entries.flatMap(({at:s,entry:i})=>{let a=xa[i.MESSAGE_ID];return a&&typeof i.SESSION_ID=="string"?[{at:s,event:a,login:i.
|
|
686
692
|
SESSION_ID,source:"host"}]:[]}),...n.entries.flatMap(({at:s,entry:i})=>typeof i.MESSAGE=="string"?[{at:s,message:i.MESSAGE,
|
|
687
|
-
source:"login"}]:[])].sort((s,i)=>s.at.localeCompare(i.at)),olderOmitted:{host:r.olderOmitted,login:n.olderOmitted}}}function
|
|
688
|
-
return e.replace(/\\(.)/gu,"$1")}function Io(e=[],t=""){let r=e.find(n=>n.startsWith(t));return r?
|
|
689
|
-
""}function Do(e,{isActive:t=n
|
|
690
|
-
({lines:i})=>i.includes(`User=${e}`)),o=n.find(({name:i})=>t(i))||n.at(-1);if(!o)return null;let s=
|
|
693
|
+
source:"login"}]:[])].sort((s,i)=>s.at.localeCompare(i.at)),olderOmitted:{host:r.olderOmitted,login:n.olderOmitted}}}function Dr(e=""){
|
|
694
|
+
return e.replace(/\\(.)/gu,"$1")}function Io(e=[],t=""){let r=e.find(n=>n.startsWith(t));return r?Dr(r.slice(t.length)):
|
|
695
|
+
""}function Do(e,{isActive:t=n=>Cr("systemctl",["is-active","--quiet",n]).status===0,units:r=()=>Nt()}={}){let n=r().filter(
|
|
696
|
+
({lines:i})=>i.includes(`User=${e}`)),o=n.find(({name:i})=>t(i))||n.at(-1);if(!o)return null;let s=Pa.exec(o.lines.find(
|
|
691
697
|
i=>i.startsWith("ExecStart="))||"");if(!s)throw new Error(`Release unit ${o.name} does not start a Vibe64 release servic\
|
|
692
|
-
e.`);return{environmentFile:
|
|
693
|
-
o.lines,"WorkingDirectory=")}}function
|
|
698
|
+
e.`);return{environmentFile:Dr(s[1]),name:o.name,path:Io(o.lines,"Environment=PATH="),startScript:Dr(s[2]),workingDirectory:Io(
|
|
699
|
+
o.lines,"WorkingDirectory=")}}function Da(e=""){return Object.fromEntries(["enter","logs","restart","status"].map(t=>[`B\
|
|
694
700
|
ASH_FUNC_staging-${t}%%`,`() { sudo -n ${e} staging-service ${t} "$@"
|
|
695
|
-
}`]))}function
|
|
701
|
+
}`]))}function Ca(e="",t=To.find(r=>Na(r))){if(!e)return{argv:[...nt],sftp:!1};let r=e.trim().split(/\s+/u)[0];if(r==="i\
|
|
696
702
|
nternal-sftp"||To.includes(r)){if(!t)throw new Error("This host has no SFTP server for scp and sftp.");return{argv:[t],sftp:!0}}
|
|
697
|
-
return{argv:[...
|
|
698
|
-
`).includes(
|
|
699
|
-
env,helperPath:t=re()}={}){let r=
|
|
700
|
-
aging login starts here.");let n=Do(r);n||(
|
|
703
|
+
return{argv:[...nt,"-c",e],sftp:!1}}function Co(e=""){return Lr(e,"utf8").split(`
|
|
704
|
+
`).includes(ka)}function Ro(e={}){Cr("logger",["--tag",Po,"--",JSON.stringify(e)],{stdio:"ignore"})}function Lo({env:e=K.
|
|
705
|
+
env,helperPath:t=re()}={}){let r=ba.userInfo().username;if(!Ye.test(r))throw new Error("Only an application account's st\
|
|
706
|
+
aging login starts here.");let n=Do(r);n||(K.stderr.write(`This project has no release installed on this host, so there \
|
|
701
707
|
is no staging to enter. Publish it first.
|
|
702
|
-
`),
|
|
703
|
-
""),a={login:
|
|
704
|
-
BASH_ENV,delete c.ENV;let l
|
|
705
|
-
[n.startScript,...l.argv]:l.argv,p=Date.now();for(let
|
|
706
|
-
env:{...c,PATH:n.path||e.PATH||"",...Se(n.environmentFile),...
|
|
707
|
-
status=="number"?d.status:1;Ro({...a,durationMs:Date.now()-p,event:"end",exitCode:f}),
|
|
708
|
+
`),K.exit(1));let o=String(e.SSH_ORIGINAL_COMMAND||""),s=String(e.VIBE64_AGENT_ENV_COMMAND_SESSION_ID||""),i=String(e.XDG_SESSION_ID||
|
|
709
|
+
""),a={login:Ra.test(i)?i:"",release:$r.basename($r.dirname(n.environmentFile)),session:Ia.test(s)?s:""},c={...e};delete c.
|
|
710
|
+
BASH_ENV,delete c.ENV;let l=Ca(o);Ro({...a,command:o.slice(0,2e3),event:"start"});let[u,...m]=!l.sftp&&Co(n.startScript)?
|
|
711
|
+
[n.startScript,...l.argv]:l.argv,p=Date.now();for(let g of["SIGINT","SIGQUIT"])K.on(g,()=>{});let d=Cr(u,m,{cwd:n.workingDirectory,
|
|
712
|
+
env:{...c,PATH:n.path||e.PATH||"",...Se(n.environmentFile),...Da(t),VIBE64_RELEASE_UNIT:n.name},stdio:"inherit"}),f=typeof d.
|
|
713
|
+
status=="number"?d.status:1;Ro({...a,durationMs:Date.now()-p,event:"end",exitCode:f}),K.exit(f)}function Rt(){return new Error(
|
|
708
714
|
["Usage, inside a staging login:"," staging-logs [--lines <n>] [--since <time>] the live release service's newest out\
|
|
709
715
|
put (200 lines)"," staging-status its state and newest output"," staging-restart \
|
|
710
716
|
restart it, then show its state"," staging-enter [command...] run the comman\
|
|
711
717
|
d, or a shell, where the running service"," runs: the files it sees, its \
|
|
712
718
|
own mounts included"].join(`
|
|
713
|
-
`))}function
|
|
719
|
+
`))}function La(e=[]){let t={};for(let r=0;r<e.length;r+=1){let[n,o]=e[r].includes("=")?[e[r].slice(0,e[r].indexOf("=")),
|
|
714
720
|
e[r].slice(e[r].indexOf("=")+1)]:[e[r],void 0];if(!["--lines","--since"].includes(n)||n in t)throw Rt();let s=o??e[r+1];
|
|
715
721
|
if(s===void 0)throw Rt();o===void 0&&(r+=1),t[n]=s}if(t["--lines"]!==void 0&&!/^\d{1,4}$/u.test(t["--lines"]))throw Rt();
|
|
716
|
-
return Ao({lines:t["--lines"]===void 0?
|
|
717
|
-
let r=w(t.SUDO_USER||"");if(!
|
|
722
|
+
return Ao({lines:t["--lines"]===void 0?Ma:Number(t["--lines"]),since:t["--since"]||""})}function jo(e=[],{env:t=K.env}={}){
|
|
723
|
+
let r=w(t.SUDO_USER||"");if(!Ye.test(r)||String(P(r).uid)!==String(t.SUDO_UID||""))throw new Error("Only an application \
|
|
718
724
|
account's staging login may use staging-service.");if(!Et(r))throw new Error("AI sessions may not use this staging now: \
|
|
719
725
|
the workspace owner has turned that off.");let n=Do(r);if(!n)throw new Error("This project has no release installed on t\
|
|
720
|
-
his host.");let[o="",...s]=e;if(o==="enter"){
|
|
721
|
-
{...
|
|
722
|
-
["restart",n.name]),It(n.name,{lines:20,timestamps:!0})}function
|
|
726
|
+
his host.");let[o="",...s]=e;if(o==="enter"){Ga(n,P(r),s[0]==="--"?s.slice(1):s,{env:t});return}if(o==="logs"){It(n.name,
|
|
727
|
+
{...La(s),timestamps:!0});return}if(s.length>0||!["restart","status"].includes(o))throw Rt();o==="restart"&&O("systemctl",
|
|
728
|
+
["restart",n.name]),It(n.name,{lines:20,timestamps:!0})}function ja({command:e=[],env:t={},helperPath:r="",mountNamespace:n="",
|
|
723
729
|
pid:o=0,unit:s={},user:i={},userNamespace:a=null}={}){let c=a||i;return{args:[xo,`--target=${o}`,"--mount",...a?["--user"]:
|
|
724
730
|
[],`--setgid=${c.gid}`,`--setuid=${c.uid}`,"--",r,"staging-enter",n,s.environmentFile,s.startScript,s.workingDirectory,...e],
|
|
725
|
-
env:{HOME:i.home,LANG:t.LANG||"C.UTF-8",LOGNAME:i.username,PATH:s.path||t.PATH||"",SHELL:
|
|
731
|
+
env:{HOME:i.home,LANG:t.LANG||"C.UTF-8",LOGNAME:i.username,PATH:s.path||t.PATH||"",SHELL:nt[0],TERM:t.TERM||"dumb",USER:i.
|
|
726
732
|
username,VIBE64_RELEASE_UNIT:s.name},file:xo}}function ko(e="",t=-1){for(let r of String(e).split(`
|
|
727
|
-
`)){let[n,o,s]=r.trim().split(/\s+/u).map(Number);if(t>=o&&t<o+s)return n+t-o}return null}function
|
|
728
|
-
o),read:n=o=>
|
|
733
|
+
`)){let[n,o,s]=r.trim().split(/\s+/u).map(Number);if(t>=o&&t<o+s)return n+t-o}return null}function Ua(e,t,{link:r=o=>jr(
|
|
734
|
+
o),read:n=o=>Lr(o,"utf8")}={}){if(r(`/proc/${e}/ns/user`)===r("/proc/self/ns/user"))return null;let o={gid:ko(n(`/proc/${e}\
|
|
729
735
|
/gid_map`),t.gid),uid:ko(n(`/proc/${e}/uid_map`),t.uid)};if(o.uid===null||o.gid===null)throw new Error("The live release\
|
|
730
736
|
service runs in a user namespace of its own that does not include its account, so staging-enter cannot join it.");return o}
|
|
731
|
-
function
|
|
732
|
-
`).find(n=>n.startsWith("0::"));return r?r.slice(3):""}catch{return""}}function
|
|
733
|
-
execve(c,l,u),link:s=c=>
|
|
737
|
+
function Ba(e,t){try{let r=t(`/proc/${e}/cgroup`).split(`
|
|
738
|
+
`).find(n=>n.startsWith("0::"));return r?r.slice(3):""}catch{return""}}function Ga(e={},t={},r=[],{env:n=K.env,execve:o=(c,l,u)=>K.
|
|
739
|
+
execve(c,l,u),link:s=c=>jr(c),read:i=c=>Lr(c,"utf8"),runRoot:a=O}={}){let c=Object.fromEntries(a("systemctl",["show",e.name,
|
|
734
740
|
"--property=MainPID","--property=ControlGroup"]).split(`
|
|
735
|
-
`).map(
|
|
741
|
+
`).map(g=>[g.slice(0,g.indexOf("=")),g.slice(g.indexOf("=")+1)])),l=Number(c.MainPID);if(!Number.isSafeInteger(l)||l<=0)
|
|
736
742
|
throw new Error(`The live release service ${e.name} is not running, so there is nothing to enter. staging-status shows w\
|
|
737
|
-
hy; staging-restart starts it again.`);let u=()=>{let
|
|
743
|
+
hy; staging-restart starts it again.`);let u=()=>{let g=Ba(l,i);return!!c.ControlGroup&&(g===c.ControlGroup||g.startsWith(
|
|
738
744
|
`${c.ControlGroup}/`))},m=new Error(`The live release service ${e.name} changed while staging-enter started; try again.`);
|
|
739
|
-
if(!u())throw m;let p=s(`/proc/${l}/ns/mnt`),d=
|
|
740
|
-
mountNamespace:p,pid:l,unit:e,user:t,userNamespace:d});o(f.file,f.args,f.env)}function
|
|
741
|
-
[...
|
|
742
|
-
env:s=
|
|
745
|
+
if(!u())throw m;let p=s(`/proc/${l}/ns/mnt`),d=Ua(l,t,{link:s,read:i});if(!u())throw m;let f=ja({command:r,env:n,helperPath:re(),
|
|
746
|
+
mountNamespace:p,pid:l,unit:e,user:t,userNamespace:d});o(f.file,f.args,f.env)}function Va(e=[],t=""){let r=e.length>0?e:
|
|
747
|
+
[...nt];return t?[t,...r]:e.length>0?[...nt,"-c",'exec "$@"',"staging-enter",...e]:r}function Uo([e="",t="",r="",n="",...o]=[],{
|
|
748
|
+
env:s=K.env,link:i=a=>jr(a)}={}){if(!/^mnt:\[\d+\]$/u.test(e)||![t,r,n].every(l=>$r.isAbsolute(l)))throw new Error("Only\
|
|
743
749
|
staging-enter, in an application account's staging login, starts here.");if(i("/proc/self/ns/mnt")!==e)throw new Error(
|
|
744
|
-
"staging-enter did not reach the live release service: its main process changed meanwhile. Try again.");
|
|
745
|
-
...c]=
|
|
750
|
+
"staging-enter did not reach the live release service: its main process changed meanwhile. Try again.");K.chdir(n);let[a,
|
|
751
|
+
...c]=Va(o,Co(r)?r:"");K.execve(a,[a,...c],{...s,...Se(t)})}var Fa=new Set(["account-auth-terminal","application-account","account-status","codex-app-server","create-system-user","\
|
|
746
752
|
deployment-service","enable-system-user","github-api-command","github-toolchain","github-workflow-command","health-statu\
|
|
747
753
|
s","managed-execution","managed-service","opencode-app-server","staging-access","vibe64-command","workspace-cache-comman\
|
|
748
754
|
d"]),Bo=Object.freeze({"production-access":"staging-access","production-enter":"staging-enter","production-service":"sta\
|
|
749
755
|
ging-service","production-shell":"staging-shell"});function Go(e=""){if(Object.hasOwn(Bo,e))throw new Error(`Vibe64 exec\
|
|
750
|
-
helper has no ${e}: production access was renamed staging access, so use ${Bo[e]}.`)}async function
|
|
751
|
-
"run-managed"){await
|
|
756
|
+
helper has no ${e}: production access was renamed staging access, so use ${Bo[e]}.`)}async function Wa(){if(E.argv[2]===
|
|
757
|
+
"run-managed"){await go(E.argv[3]||"");return}if(E.argv[2]==="run-release-service"){bo(E.argv[3]||"",E.argv[4]||"");return}
|
|
752
758
|
if(Go(E.argv[2]),E.argv[2]==="staging-shell"&&E.argv.length===3){Lo();return}if(E.argv[2]==="staging-service"){jo(E.argv.
|
|
753
759
|
slice(3));return}if(E.argv[2]==="staging-enter"){Uo(E.argv.slice(3));return}if(E.argv[2]==="upgrade-person-registry"){if(E.
|
|
754
|
-
argv.length!==4)throw new Error("Usage: vibe64-exec-helper upgrade-person-registry <workspace>");
|
|
760
|
+
argv.length!==4)throw new Error("Usage: vibe64-exec-helper upgrade-person-registry <workspace>");mn(E.argv[3]);return}if(E.
|
|
755
761
|
argv[2]==="register-person"){if(E.argv.length!==5)throw new Error("Usage: vibe64-exec-helper register-person <workspace>\
|
|
756
|
-
<username>");
|
|
762
|
+
<username>");Kt(E.argv[3],E.argv[4]);return}if(E.argv[2]==="relink-units"){if(E.argv.length!==3)throw new Error("Usage:\
|
|
757
763
|
vibe64-exec-helper relink-units");No();return}if(E.argv[2]==="check-person"){if(E.argv.length!==4)throw new Error("Usag\
|
|
758
|
-
e: vibe64-exec-helper check-person <username>");
|
|
759
|
-
ute"||E.argv.length>4)throw new Error("Usage: vibe64-exec-helper execute [payload-json-file]");let e=E.argv[3]||"",t=e?
|
|
760
|
-
e,U()):
|
|
764
|
+
e: vibe64-exec-helper check-person <username>");le(E.argv[3]),ft(P(E.argv[3]),Fe(E.argv[3]));return}if(E.argv[2]!=="exec\
|
|
765
|
+
ute"||E.argv.length>4)throw new Error("Usage: vibe64-exec-helper execute [payload-json-file]");let e=E.argv[3]||"",t=e?jn(
|
|
766
|
+
e,U()):Bn();Un(t);let r=String(t.operation||"").trim();if(Go(r),!Fa.has(r))throw new Error("Vibe64 exec helper rejected \
|
|
761
767
|
an unknown operation.");if(e&&r!=="managed-execution")throw new Error("Vibe64 exec helper accepts a payload file only fo\
|
|
762
768
|
r a managed execution.");if(r==="deployment-service"){wo(t);return}if(r==="managed-service"){Oo(t);return}if(r==="manage\
|
|
763
|
-
d-execution"){
|
|
764
|
-
if(r==="create-system-user"||r==="enable-system-user"){
|
|
765
|
-
has(o))throw new Error("Vibe64 exec helper rejected an unknown command.");let s=P(n);
|
|
766
|
-
s.gid);let i=U();
|
|
769
|
+
d-execution"){fo(t);return}if(r==="application-account"){Rn(t);return}if(r==="staging-access"){$o(t);return}let n=w(t.username);
|
|
770
|
+
if(r==="create-system-user"||r==="enable-system-user"){on(r,t,n);return}le(n);let o=String(t.command||"").trim();if(!ct.
|
|
771
|
+
has(o))throw new Error("Vibe64 exec helper rejected an unknown command.");let s=P(n);me("uid",t.uid,s.uid),me("gid",t.gid,
|
|
772
|
+
s.gid);let i=U();gt(i,s);let a=lt(t.cwd||"",i.username,{operation:r,targetUser:s}),c=je(t.env||{},s,i.username,r),l=Array.
|
|
767
773
|
isArray(t.args)?t.args.map(p=>String(p)):[],u=t.inputBase64?Buffer.from(String(t.inputBase64),"base64"):void 0;E.umask(7);
|
|
768
|
-
let m=
|
|
769
|
-
error;E.exit(typeof m.status=="number"?m.status:1)}import.meta.main&&
|
|
774
|
+
let m=Jr(s,o,l,{cwd:a,env:c,...u===void 0?{stdio:"inherit"}:{input:u,stdio:["pipe","inherit","inherit"]}});if(m.error)throw m.
|
|
775
|
+
error;E.exit(typeof m.status=="number"?m.status:1)}import.meta.main&&Wa().catch(e=>{E.stderr.write(`${String(e?.message||
|
|
770
776
|
e)}
|
|
771
777
|
`),E.exit(e?.exitCode===dt?dt:2)});
|