vibe64 0.1.59 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +1070 -1054
- package/bin/server.js +392 -376
- package/bin/upgrade-state.js +4439 -4420
- package/dist/assets/{GithubBrowserTabs-D_nMB5Y1.js → GithubBrowserTabs-Vv-64NIg.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-BgO_aeUg.js → LocalDatabaseServer-rolg-sXl.js} +1 -1
- package/dist/assets/SelectField-DwWoHC2p.js +1 -0
- package/dist/assets/{ShellOutlet-Cr8SJs7s.js → ShellOutlet-Clsh2qYP.js} +1 -1
- package/dist/assets/Vibe64AuthSettingsButton-BICxvZDm.js +5 -0
- package/dist/assets/{Vibe64AuthSettingsButton-DRTKdimW.css → Vibe64AuthSettingsButton-DbL7Ukry.css} +1 -1
- package/dist/assets/{Vibe64ConversationLog-DtOgxPNR.js → Vibe64ConversationLog-K6aUo3q1.js} +4 -4
- package/dist/assets/{Vibe64ConversationLog-NH61odld.css → Vibe64ConversationLog-ksf1U6PP.css} +1 -1
- package/dist/assets/{Vibe64DashboardShell-DhPE6H3P.js → Vibe64DashboardShell-C_wkAaSb.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-Bpnbjs4l.css → Vibe64DashboardShell-D0GNI4V8.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-cfn8TTxQ.css → Vibe64DatabaseWorkspace-De4sbXAN.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-CHV0cd3l.js → Vibe64DatabaseWorkspace-Dy88t2ZX.js} +2 -2
- package/dist/assets/Vibe64FileArea-BU5rPyqx.js +1 -0
- package/dist/assets/{Vibe64FileArea-mydNQQl8.css → Vibe64FileArea-ZEzsvLt2.css} +1 -1
- package/dist/assets/Vibe64OutputControls-Z2K52QCc.js +8 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-DUSMn4pR.js → Vibe64RepositoryWorkspace-CWw4w5SA.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-BXt__PJL.js → Vibe64SessionFiles-DI8ZH6aF.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-NyG6niQM.js → Vibe64SessionSourceEditor-BVfoXgmZ.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-CtlJWiCY.css → Vibe64UiStoryboardView-BYLWabXY.css} +1 -1
- package/dist/assets/Vibe64UiStoryboardView-C-99xlAo.js +8 -0
- package/dist/assets/{Vibe64UnavailableSessions-CCPWJo8e.js → Vibe64UnavailableSessions-BRB2bUR_.js} +1 -1
- package/dist/assets/{_pageId_-D54CqzqG.js → _pageId_-DPJ8pvUs.js} +1 -1
- package/dist/assets/{_sessionId_-CW044RVi.js → _sessionId_-CiU1Awul.js} +1 -1
- package/dist/assets/_slug_-C5yeqlpL.js +14 -0
- package/dist/assets/{_slug_-WWvJTLoc.css → _slug_-Vy_1jrpy.css} +1 -1
- package/dist/assets/access-BH1OsqPS.css +1 -0
- package/dist/assets/access-Cq6GEVhT.js +1 -0
- package/dist/assets/{app-D9FegZf0.js → app-BKwP6m9e.js} +1 -1
- package/dist/assets/{assistantRouting-D4SnnxJn.js → assistantRouting-BS0ZW5Ki.js} +1 -1
- package/dist/assets/{changes-DtfJc780.js → changes-DT8e3wYn.js} +1 -1
- package/dist/assets/{client-Dra4Vp3A.js → client-BHa4BumO.js} +2 -2
- package/dist/assets/{client-DnjkdG6K.js → client-B_iZQVU8.js} +1 -1
- package/dist/assets/{client-BBqNv4HL.js → client-C-Rw8t8y.js} +1 -1
- package/dist/assets/{client-B8u2_Svv.css → client-CM6TGZc9.css} +1 -1
- package/dist/assets/{client-DuDOzb5A.js → client-Cf6iimPy.js} +2 -2
- package/dist/assets/{client-mU-LObHG.js → client-DWPSlYBq.js} +1 -1
- package/dist/assets/{conversation-QpMeXw70.js → conversation-CsB1b1JZ.js} +1 -1
- package/dist/assets/{conversation-La-pkh5h.css → conversation-DA_fbJJD.css} +1 -1
- package/dist/assets/{dashboard-B26QwE6y.js → dashboard-DRwBugiR.js} +1 -1
- package/dist/assets/{english-definitions-I9tIXY2u.js → english-definitions-Bi3yaDu7.js} +1 -1
- package/dist/assets/{env-BXsvM592.js → env-ObiVMW6f.js} +1 -1
- package/dist/assets/errorMessageHelpers-BjIt31kK.js +1 -0
- package/dist/assets/{errors-DErd0NON.js → errors-D17nJYne.js} +1 -1
- package/dist/assets/{health-C4WtefLm.js → health-Ev-UBIsw.js} +1 -1
- package/dist/assets/history-BSIuLgnI.css +1 -0
- package/dist/assets/history-U6UcbKBZ.js +1 -0
- package/dist/assets/{httpClient-BRO3GqjU.js → httpClient-Bwitq9Xf.js} +1 -1
- package/dist/assets/i18n-BkxO7BMl.js +1 -0
- package/dist/assets/index-Ctygjyf8.css +1 -0
- package/dist/assets/index-Wcdz2Rey.js +134 -0
- package/dist/assets/{integrations-CQNJxkMu.js → integrations-BHURBo17.js} +3 -3
- package/dist/assets/{integrations-CrI893NK.css → integrations-Bo_beIy3.css} +1 -1
- package/dist/assets/issues-D4Asc_wa.css +1 -0
- package/dist/assets/issues-DEzrDqDU.js +1 -0
- package/dist/assets/{learning-0cINHUSN.js → learning-BrBAyLFt.js} +1 -1
- package/dist/assets/{pages-DbF-yXqO.js → pages-5jaEclQo.js} +1 -1
- package/dist/assets/{pages-CIKw99GN.js → pages-BTk_FkDr.js} +1 -1
- package/dist/assets/{pathname-DOqQPPVa.js → pathname-JHQIKk21.js} +1 -1
- package/dist/assets/{placement-BAaZQhAh.js → placement-1lT0lW3-.js} +1 -1
- package/dist/assets/{placement-Lk1Lpy6s.js → placement-B2V88UDJ.js} +1 -1
- package/dist/assets/{project-files-CklWobqZ.js → project-files-CTGwnBh7.js} +1 -1
- package/dist/assets/publish-BYZ7KRzq.js +3 -0
- package/dist/assets/{publish-DOybV3Qz.css → publish-C9O0tDPB.css} +1 -1
- package/dist/assets/{pull-requests-ybnixBv0.js → pull-requests-C-puL4SG.js} +1 -1
- package/dist/assets/{pull-requests-DnEm9m_1.css → pull-requests-DgWKsMdI.css} +1 -1
- package/dist/assets/{repository-wJZei_NJ.js → repository-DknGo0hr.js} +1 -1
- package/dist/assets/settings-BKZcbISO.css +1 -0
- package/dist/assets/settings-BmOQ1NnW.js +1 -0
- package/dist/assets/{shared-X5MxTHwl.js → shared-B6plZPQ_.js} +1 -1
- package/dist/assets/{studioGateApi-CHIdcQvD.js → studioGateApi-UqmdV50W.js} +1 -1
- package/dist/assets/{studioUrls-oIU1Eq_t.js → studioUrls-k_pQIuPs.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-DI9ow2ds.js +1 -0
- package/dist/assets/useCommand-YOAaO5Wz.js +1 -0
- package/dist/assets/{useEndpointResource-61E93qP-.js → useEndpointResource-CmMwteuX.js} +1 -1
- package/dist/assets/{usePaths-B-QGqa_I.js → usePaths-CvUbx5-V.js} +1 -1
- package/dist/assets/{useUiFeedback-CycH_fvY.js → useUiFeedback-Bixow9mW.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-BkcPA64C.js +2 -0
- package/dist/assets/{useVibe64Learning-DZCyrfpy.js → useVibe64Learning-RE4HXHqo.js} +1 -1
- package/dist/assets/{useVibe64SessionData-rBvWMqyc.js → useVibe64SessionData-Df7M5k1M.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-C546mBu8.js → useVibe64SessionSelection-B0USk6X6.js} +1 -1
- package/dist/assets/validators-HqYRjxEO.js +1 -0
- package/dist/assets/{vibe64FileUpload-D0Lv2mMJ.js → vibe64FileUpload-BDkcaUyk.js} +1 -1
- package/dist/assets/vibe64GithubProject-CJneIo5O.js +1 -0
- package/dist/assets/vibe64RepositoryRealtime-DKSXVg1B.js +1 -0
- package/dist/assets/vibe64SessionFocus-BJLy8eTE.js +1 -0
- package/dist/assets/vibe64SessionFocus-DdYRpG72.css +1 -0
- package/dist/index.html +26 -24
- package/docs/colleague-usage/ai-tasks.md +15 -4
- package/docs/colleague-usage/coding-agent-recovery.md +3 -1
- package/docs/colleague-usage/coding-agents.md +19 -1
- package/docs/colleague-usage/connected-repositories.md +16 -4
- package/docs/colleague-usage/files.md +2 -1
- package/docs/colleague-usage/github-work.md +50 -11
- package/docs/colleague-usage/health-checks.md +1 -1
- package/docs/colleague-usage/preview-browser-checks.md +3 -0
- package/docs/colleague-usage/preview.md +29 -0
- package/docs/colleague-usage/project-messages.md +3 -2
- package/docs/colleague-usage/project-settings.md +3 -0
- package/docs/colleague-usage/session-archive.md +9 -0
- package/docs/colleague-usage/sessions.md +5 -4
- package/docs/colleague-usage/temporary-chats.md +4 -3
- package/docs/colleague-usage/usage-map.md +3 -2
- package/docs/colleague-usage/workspace-preparation.md +12 -0
- package/node_modules/@jskit-ai/agent/CHANGELOG.md +5 -0
- package/node_modules/@jskit-ai/agent/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +8 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +4 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-core/README.md +4 -0
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +7 -0
- package/node_modules/@jskit-ai/kernel/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +428 -423
- package/node_modules/@local/vibe64-genesis/bin/genesis +17 -11
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +830 -816
- package/node_modules/@local/vibe64-genesis/src/server/index.js +533 -519
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +172 -169
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +490 -479
- package/node_modules/@local/vibe64-source-editor/src/server/searchIndexWorker.js +12 -11
- package/node_modules/@local/vibe64-system-graph/README.md +9 -5
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +262 -252
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1060 -1018
- package/node_modules/json-rest-schema/README.md +3 -1
- package/node_modules/json-rest-schema/package.json +1 -1
- package/package.json +17 -17
- package/server.bundle.mjs +43046 -42782
- package/dist/assets/Vibe64AuthSettingsButton-Bx9patil.js +0 -5
- package/dist/assets/Vibe64FileArea-DIDyAUvD.js +0 -1
- package/dist/assets/Vibe64OutputControls-mNWUWLSm.js +0 -8
- package/dist/assets/Vibe64UiStoryboardView-BXH2MSWn.js +0 -8
- package/dist/assets/_slug_-CRtFhc0A.js +0 -14
- package/dist/assets/access-ChMLRErk.js +0 -1
- package/dist/assets/access-Cm2lrMF6.css +0 -1
- package/dist/assets/errorMessageHelpers-L2GsOwCP.js +0 -1
- package/dist/assets/history-BhqQz5jH.css +0 -1
- package/dist/assets/history-HHPFoNi3.js +0 -1
- package/dist/assets/index-BBfSvf2i.css +0 -1
- package/dist/assets/index-Bvd00puv.js +0 -134
- package/dist/assets/issues-BHr_nI-9.js +0 -1
- package/dist/assets/issues-CpBRQTQ_.css +0 -1
- package/dist/assets/publish-Cot797YN.js +0 -3
- package/dist/assets/settings-DJByC5Wb.js +0 -1
- package/dist/assets/settings-bEkDjn0Y.css +0 -1
- package/dist/assets/useArchivedVibe64Sessions-B-DtXrk-.js +0 -1
- package/dist/assets/useCommand-D96utlVe.js +0 -1
- package/dist/assets/useVibe64ConversationLog-BVANhCHq.js +0 -2
- package/dist/assets/validators-B3YzM6px.js +0 -1
- package/dist/assets/vibe64GithubProject-DNl0aDcC.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-BPsE5l5E.js +0 -1
- package/dist/assets/vibe64SessionFocus-CxX2nK6F.js +0 -1
- package/dist/assets/vibe64SessionFocus-DW73PN_o.css +0 -1
|
@@ -1,291 +1,298 @@
|
|
|
1
1
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=
|
|
4
|
-
(this.messageCode=String(n.messageCode),this.messageParams=
|
|
5
|
-
{}}};function
|
|
6
|
-
|
|
7
|
-
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function
|
|
8
|
-
let{items:r}=t;if(
|
|
9
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
10
|
-
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(
|
|
2
|
+
var wm=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function h(e,{fallback:t=""}={}){return String(e||"").trim()||t}function oe(e){return String(e??"").trim()}function F(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function yr(e){return F(e)?{...e}:{}}var te=class extends Error{constructor(t,r,n={}){super(r,n.cause===void 0?void 0:{cause:n.cause}),this.name="AppError",this.
|
|
3
|
+
status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=yr(n.params),n.messageCode&&
|
|
4
|
+
(this.messageCode=String(n.messageCode),this.messageParams=yr(n.messageParams)),this.details=n.details,this.headers=n.headers||
|
|
5
|
+
{}}};function $(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||
|
|
6
|
+
Va(t)}function Va(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}function wr(e){return e!==null&&typeof e=="object"&&$(e.structure)&&$(e.operations)&&typeof e.validateWith=="function"&&
|
|
7
|
+
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function Et(e,t){if(!Object.hasOwn(t,"items"))return null;
|
|
8
|
+
let{items:r}=t;if(wr(r))return{kind:"schema",schema:r};if(!$(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
9
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Xe(e,t){
|
|
10
|
+
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(wr(r))return{kind:"schema",schema:r};if(!$(r)||typeof r.type!=
|
|
11
11
|
"string")throw new Error(`Object field "${e}" must define values as either a Schema instance or a field definition objec\
|
|
12
|
-
t.`);return{kind:"definition",definition:r}}function
|
|
12
|
+
t.`);return{kind:"definition",definition:r}}function vt(e,t){let r=Object.hasOwn(t,"schema"),n=Object.hasOwn(t,"values"),
|
|
13
13
|
o=Object.hasOwn(t,"additionalProperties");if(r&&n)throw new Error(`Object field "${e}" cannot define both schema and val\
|
|
14
14
|
ues.`);if(o&&t.additionalProperties!==!0)throw new Error(`Object field "${e}" only supports additionalProperties: true.`);
|
|
15
15
|
if(n&&t.additionalProperties===!0)throw new Error(`Object field "${e}" cannot define both values and additionalPropertie\
|
|
16
|
-
s: true.`);if(r){if(!
|
|
17
|
-
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:
|
|
18
|
-
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
16
|
+
s: true.`);if(r){if(!wr(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
|
|
17
|
+
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Xe(
|
|
18
|
+
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function ke(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}function br(e,t=""){
|
|
19
|
+
if($(e))for(let[r,n]of Object.entries(e)){if(!$(n))continue;let o=t?`${t}.${r}`:r;for(let i of["minItems","maxItems"]){if(!Object.
|
|
20
|
+
hasOwn(n,i))continue;let s=n[i];if(n.type!=="array"||!Number.isInteger(s)||s<0)throw new Error(`Field "${o}" ${i} must b\
|
|
21
|
+
e a non-negative integer on an array field.`)}if(n.minItems>n.maxItems)throw new Error(`Field "${o}" minItems (${n.minItems}\
|
|
22
|
+
) is above its maxItems (${n.maxItems}).`);n.type==="array"&&$(n.items)&&typeof n.items.type=="string"&&br({"[]":n.items},
|
|
23
|
+
o)}}var Er="^(?:0|-?[1-9]\\d*)$",Qn="\\d{4}",Zn="0[1-9]|1[0-2]",eo="0[1-9]|[12]\\d|3[01]",to="[01]\\d|2[0-3]",Ne="[0-5]\\d",
|
|
24
|
+
St=`(?:${to}):${Ne}`,ro=`(?:Z|[+-](?:${to}):${Ne})`,no=`(${Qn})-(${Zn})-(${eo})`,oo=`${Qn}-(?:${Zn})-(?:${eo})`,io=`^${oo}\
|
|
25
|
+
$`,za=new RegExp(`^${no}$`),Fa=new RegExp(`^${St}(?::${Ne}(?:\\.(\\d+))?)?$`),Wa=new RegExp(`^${no}T${St}:${Ne}(?:\\.(\\d+\
|
|
26
|
+
))?${ro}$`),qa=new RegExp(Er),Ya=[31,28,31,30,31,30,31,31,30,31,30,31];function Ka(e){return e%4===0&&(e%100!==0||e%400===
|
|
27
|
+
0)}function Ja(e,t){return t===2?Ka(e)?29:28:Ya[t-1]}function so(e,t,r){let n=Number(e),o=Number(t),i=Number(r);return o>=
|
|
28
|
+
1&&o<=12&&i>=1&&i<=Ja(n,o)}function Qe(e,t){let r=e.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
|
|
29
|
+
`temporalPrecision for "${t}" must be a non-negative integer.`);return r}}function ao(e,t){return e===void 0?!0:t===void 0||
|
|
30
|
+
e.length<=t}function co(e){if(typeof e!="string")return!1;let t=za.exec(e);return t!==null&&so(t[1],t[2],t[3])}function uo(e,t){
|
|
31
|
+
if(typeof e!="string")return!1;let r=Fa.exec(e);return r!==null&&ao(r[1],t)}function lo(e,t){if(typeof e!="string")return!1;
|
|
32
|
+
let r=Wa.exec(e);return r===null?!1:so(r[1],r[2],r[3])&&ao(r[4],t)}function po(e){return e===void 0?"(?:\\.\\d+)?":e===0?
|
|
33
|
+
"":`(?:\\.\\d{1,${e}})?`}function mo(e,t){let r=Qe(e,t);return`^${St}(?::${Ne}${po(r)})?$`}function fo(e,t){let r=Qe(e,t);
|
|
34
|
+
return`^${oo}T${St}:${Ne}${po(r)}${ro}$`}function vr(e,t){let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&qa.
|
|
35
|
+
test(e))r=Number(e);else return null;return!Number.isSafeInteger(r)||r<-t||r>t?null:r===0?0:r}var Xa=new Set(["__proto__","prototype","constructor"]);function b(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Qa(e,t){if(Xa.
|
|
36
|
+
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function Za(e){return typeof e!="string"?e:e.replace(
|
|
37
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Sr(e,t,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
38
|
+
let o=r?Za(e):e;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${t}() expects a non-empty \
|
|
34
39
|
dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${t}() received an invalid path "${o}".`);
|
|
35
|
-
for(let s of i)
|
|
36
|
-
|
|
37
|
-
return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:
|
|
38
|
-
none:()=>({type:
|
|
40
|
+
for(let s of i)Qa(s,t);return i}var ec="http://json-schema.org/draft-07/schema#",ie="x-json-rest-schema",Tr=["object","array","string","number","boolean"],
|
|
41
|
+
Or=Symbol("json-rest-schema.exportContext"),tc=["true","1","yes","y","on"],rc=["false","0","no","n","off"];function ho(e){
|
|
42
|
+
return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Er}]}}function ge(e,t){return{[ie]:{[e]:t}}}var nc={
|
|
43
|
+
none:()=>({type:Tr}),blob:()=>({type:Tr}),serialize:()=>({type:Tr}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
39
44
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
40
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
41
|
-
type:"string",format:"date-time",pattern:
|
|
42
|
-
fieldName:t})=>({type:"string",pattern:
|
|
43
|
-
let t=new Set([...
|
|
45
|
+
eger","string"]}),epochMilliseconds:()=>ho(864e13),epochSeconds:()=>ho(864e10),dateTime:({definition:e,fieldName:t})=>({
|
|
46
|
+
type:"string",format:"date-time",pattern:fo(e,t)}),date:()=>({type:"string",format:"date",pattern:io}),time:({definition:e,
|
|
47
|
+
fieldName:t})=>({type:"string",pattern:mo(e,t)}),boolean:({definition:e})=>{if(e.strictBoolean===!0)return{type:"boolean"};
|
|
48
|
+
let t=new Set([...tc,String(e.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...rc,String(e.stringFalseWhen||
|
|
44
49
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...r,...t]}]}},
|
|
45
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
50
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},oc={minLength:({definition:e,parameterValue:t})=>e.
|
|
46
51
|
type==="string"?{minLength:t}:null,maxLength:({definition:e,parameterValue:t})=>e.type==="string"?{maxLength:t}:null,min:({
|
|
47
|
-
definition:e,parameterValue:t})=>
|
|
52
|
+
definition:e,parameterValue:t})=>ke(e)?{minimum:t}:null,max:({definition:e,parameterValue:t})=>ke(e)?{maximum:t}:null,pattern:({
|
|
48
53
|
definition:e,parameterValue:t})=>e.type==="string"?{pattern:t instanceof RegExp?t.source:t}:null,enum:({parameterValue:e})=>({
|
|
49
|
-
enum:e}),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"metadata",{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
t)
|
|
71
|
-
|
|
72
|
-
nodes:[],nextDefinitionId:1,rootNode:null}}function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{});let
|
|
81
|
-
definitions[e.definitionName]=
|
|
82
|
-
|
|
83
|
-
let i=
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
n,o,i
|
|
92
|
-
if(a.kind==="
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
o=
|
|
111
|
-
|
|
112
|
-
function
|
|
54
|
+
enum:e}),minItems:({definition:e,parameterValue:t})=>e.type==="array"?{minItems:t}:null,maxItems:({definition:e,parameterValue:t})=>e.
|
|
55
|
+
type==="array"?{maxItems:t}:null,notEmpty:({parameterValue:e,definition:t})=>!e||t.type==="array"?null:{minLength:1},uppercase:({
|
|
56
|
+
parameterValue:e})=>e?ge("transforms",{uppercase:!0}):null,lowercase:({parameterValue:e})=>e?ge("transforms",{lowercase:!0}):
|
|
57
|
+
null,length:({parameterValue:e})=>ge("transforms",{length:e}),unsigned:({parameterValue:e})=>e?ge("metadata",{unsigned:!0}):
|
|
58
|
+
null,precision:({parameterValue:e})=>ge("metadata",{precision:e}),scale:({parameterValue:e})=>ge("metadata",{scale:e}),temporalPrecision:({
|
|
59
|
+
parameterValue:e})=>ge("metadata",{temporalPrecision:e}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
|
|
60
|
+
defaultTo:()=>null};function Pr(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];if(n&&o&&typeof n=="object"&&typeof o==
|
|
61
|
+
"object"&&!Array.isArray(n)&&!Array.isArray(o)){Pr(o,n);continue}e[r]=n}}function ic(e,t){if(!t||typeof t!="object"||Array.
|
|
62
|
+
isArray(t))throw new Error("JSON Schema export hooks must return an object or null.");for(let r of Object.keys(t)){if(r===
|
|
63
|
+
ie&&e[r]&&typeof e[r]=="object"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){Pr(e[r],t[r]);continue}
|
|
64
|
+
e[r]=t[r]}}function sc(e,t){let n=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return n.length===
|
|
65
|
+
1?e:{anyOf:n}}function ac(e,t){if(!Object.hasOwn(e.types,t.type))throw new Error(`No casting function for type: ${t.type}`);
|
|
66
|
+
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n=nc[t.type];if(!n)throw new Error(
|
|
67
|
+
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function cc(e,t,r){if(!Object.
|
|
68
|
+
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=oc[t];
|
|
69
|
+
if(o)return o;throw new Error(`Validator '${t}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
70
|
+
hook.`)}function go(e){if(e===void 0)return"create";if(["create","replace","patch"].includes(e))return e;throw new Error(
|
|
71
|
+
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function uc(e,t={}){if(t.mode!==
|
|
72
|
+
void 0&&t.operation!==void 0){let r=go(t.mode);if(r!==t.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
73
|
+
s: mode '${r}' does not match operation '${t.operation}'.`)}if(t.operation!==void 0){if(!Object.hasOwn(e.operations,t.operation))
|
|
74
|
+
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return go(t.mode)}function lc(e,t={}){
|
|
75
|
+
if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
|
|
76
|
+
let r=uc(e,t);return{operationName:r,operation:e.operations[r]}}function dc(e={}){let t={...e};return Object.defineProperty(
|
|
77
|
+
t,Or,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function Ot(e={}){return e[Or]?
|
|
78
|
+
e[Or]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function pc(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
|
|
79
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function Ar(e){return $(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
|
|
80
|
+
function Tt(e){return Ar(e)?{allOf:[e]}:e}function mc(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
|
|
81
|
+
r&&i.operation===n&&i.additionalProperties===o)||null}function fc(e,t){let r=pc(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
82
|
+
return e.nextDefinitionId+=1,n}function _o(e,t,r,n,o,{root:i=!1}={}){let s=Ot(t),a=mc(s,e,r,n,o);if(a)return i&&(a.pointer=
|
|
83
|
+
"#",s.rootNode=a),a;let c={schema:e,operationName:r,operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
84
|
+
fc(s,r),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function yo(e,t){
|
|
85
|
+
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=Ot(t);e.status="build\
|
|
86
|
+
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=hc(e.schema,t,e.operationName,e.operation,e.additionalProperties);
|
|
87
|
+
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function Cr(e,t,r,n,o=!1){
|
|
88
|
+
let i=Ot(t),s=_o(e,t,r,n,o);return i.rootNode===s?{$ref:"#"}:yo(s,t)}function Ze(e,{referenceBacked:t=!1}={}){return{schema:e,
|
|
89
|
+
referenceBacked:t}}function hc(e,t,r,n,o=!1){let i={},s=[];for(let[c,u]of Object.entries(e.structure))b(i,c,kr(e,c,u,t,r,
|
|
90
|
+
n)),n.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
|
|
91
|
+
0&&(a.required=s),a}function gc(e,t,r,n,o,i){let s=Et(t,r);if(!s)return null;if(s.kind==="schema")return{...Tt(Cr(s.schema,
|
|
92
|
+
n,"replace",s.schema.operations.replace,!1)),[ie]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,
|
|
93
|
+
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return kr(e,`${t}[]`,r.items,n,a,c)}function _c(e,t,r,n,o,i){
|
|
94
|
+
let s=Xe(t,r);if(!s)return null;if(s.kind==="schema")return{...Tt(Cr(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
95
|
+
[ie]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="re\
|
|
96
|
+
place"?e.operations.replace:i;return kr(e,`${t}.*`,s.definition,n,a,c)}function yc(e,t,r,n,o,i){if(r.type==="object"){let a=vt(
|
|
97
|
+
t,r);if(a.kind==="nested")return Ze(Cr(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
98
|
+
"opaque")return Ze({type:"object",additionalProperties:!0});if(a.kind==="map")return Ze({type:"object",additionalProperties:_c(
|
|
99
|
+
e,t,r,n,o,i)})}let s=ac(e,r)({schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n});if(!s||typeof s!="object"||
|
|
100
|
+
Array.isArray(s))throw new Error(`Type '${r.type}' on field '${t}' returned an invalid JSON Schema fragment.`);if(r.type===
|
|
101
|
+
"array"){let a=gc(e,t,r,n,o,i);if(a)return Ze({...s,items:a},{referenceBacked:Ar(s)})}return Ze(s,{referenceBacked:Ar(s)})}
|
|
102
|
+
function kr(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n},a=yc(e,t,r,n,o,i),c=a.referenceBacked?
|
|
103
|
+
Tt(a.schema):{...a.schema},u={castType:r.type};for(let d of Object.keys(r)){if(d==="type"||!Object.hasOwn(e.validators,d))
|
|
104
|
+
continue;let m=cc(e,d,t);if(!m)continue;let f=m({...s,parameterName:d,parameterValue:r[d],fieldSchema:{...c}});f&&ic(c,f)}
|
|
105
|
+
c[ie]&&(Pr(u,c[ie]),delete c[ie]);let l=[];r.nullable===!0&&l.push({type:"null"}),r.nullOnEmpty===!0&&l.push({const:""});
|
|
106
|
+
let p=Tt(sc(c,l));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.defaultTo!="function"){let d=e._normalizeDefault(
|
|
107
|
+
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
108
|
+
o,i,{})});if(Object.keys(d.errors).length>0){let m=Object.values(d.errors)[0];throw new Error(`defaultTo for "${t}" is i\
|
|
109
|
+
nvalid (${m.code}).`)}p.default=d.value}else u.defaults={providedByFunction:!0};return p[ie]=u,p}function wo(e,t={}){let r=dc(
|
|
110
|
+
t),{operationName:n,operation:o}=lc(e,r),i=r.additionalProperties===void 0?!1:r.additionalProperties,s=Ot(r),a=_o(e,r,n,
|
|
111
|
+
o,i,{root:!0}),c={$schema:ec,...yo(a,r)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}function bo(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function jr(e){return e instanceof
|
|
112
|
+
Me}function wc(){return{self:!1,children:{}}}function Eo(e){return Object.keys(e.children).length>0}function _e(e,t){return`${e}\
|
|
113
|
+
.${String(t)}`}function Io(e,t){return e===""?String(t):_e(e,t)}function vo(e,t){if(e===t)return"";let r=`${t}.`;return e.
|
|
114
|
+
startsWith(r)?e.slice(r.length):null}function xe(e,t){let r={};for(let n of Object.values(e)){let o=_e(t,n.field);b(r,o,
|
|
115
|
+
{...n,field:o})}return r}function Mr(e){return Sr(e,"validatePath")}function So(e){let t={};for(let r of e){let n=Mr(r),
|
|
116
|
+
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||b(o,s,wc()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
117
|
+
return t}function bc(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
|
|
118
|
+
function At(e){return e===null?!0:Array.isArray(e)||$(e)?Object.keys(e).length>0:e!==void 0}function To(e){return[...e].
|
|
113
119
|
sort((t,r)=>{let n=/^[0-9]+$/.test(t),o=/^[0-9]+$/.test(r);return n&&o?Number(t)-Number(r):n?-1:o?1:t.localeCompare(r)})}
|
|
114
|
-
function
|
|
120
|
+
function Ec(e){return/^[0-9]+$/.test(e)}function vc(e,t=new WeakMap){if(t.has(e))return t.get(e);let r=Object.create(Me.
|
|
115
121
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
116
|
-
|
|
117
|
-
"object")return e;if(
|
|
122
|
+
Rt(It(e.structure,t)),r._installOperationMethods(),Object.freeze(r)}function It(e,t=new WeakMap){if(e===null||typeof e!=
|
|
123
|
+
"object")return e;if(jr(e))return vc(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
118
124
|
e.source,e.flags);return n.lastIndex=e.lastIndex,n}if(t.has(e))return t.get(e);if(Array.isArray(e)){let n=[];t.set(e,n);
|
|
119
|
-
for(let o of e)n.push(
|
|
120
|
-
o,t));return r}function
|
|
121
|
-
isArray(e))for(let r of e)
|
|
122
|
-
return
|
|
123
|
-
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=
|
|
124
|
-
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:
|
|
125
|
-
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!
|
|
126
|
-
n,i);return o.kind==="schema"?s.length<1?null:
|
|
127
|
-
function
|
|
128
|
-
"");n.length>0?r.skipFields=n:delete r.skipFields}if(
|
|
129
|
-
let s=
|
|
125
|
+
for(let o of e)n.push(It(o,t));return n}if(!$(e))return e;let r={};t.set(e,r);for(let[n,o]of Object.entries(e))b(r,n,It(
|
|
126
|
+
o,t));return r}function Rt(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||jr(e))return e;if(t.add(e),Array.
|
|
127
|
+
isArray(e))for(let r of e)Rt(r,t);else for(let r of Reflect.ownKeys(e))Rt(e[r],t);return Object.freeze(e)}function Nr(e){
|
|
128
|
+
return Rt(It(e))}var xr=new WeakMap;function Lr(e,t,r=""){if(!jr(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;
|
|
129
|
+
if(!Object.hasOwn(e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=Io(r,n);return Ro(e,i,o,s)}
|
|
130
|
+
function Ro(e,t,r,n){if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:Lr(o.schema,
|
|
131
|
+
r,n)}if(t?.type==="array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!Ec(i))return null;
|
|
132
|
+
let a=_e(n,i);return o.kind==="schema"?s.length<1?null:Lr(o.schema,s,a):s.length<1?o.definition:Ro(e,o.definition,s,a)}return null}
|
|
133
|
+
function $e(e,t){let r={...e};if(Array.isArray(e.skipFields)){let n=e.skipFields.map(o=>vo(o,t)).filter(o=>o!==null&&o!==
|
|
134
|
+
"");n.length>0?r.skipFields=n:delete r.skipFields}if($(e.skipParams)){let n={};for(let[o,i]of Object.entries(e.skipParams)){
|
|
135
|
+
let s=vo(o,t);s===null||s===""||b(n,s,i)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var Sc=Object.
|
|
130
136
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
131
137
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
132
138
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
133
|
-
function
|
|
134
|
-
", ")}.`)}function
|
|
135
|
-
must define ${r} as a boolean.`)}function
|
|
136
|
-
eration "${e}" must be an object.`);return
|
|
137
|
-
pplyDefaults"),
|
|
139
|
+
function Oo(e,t,r,n){let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(
|
|
140
|
+
", ")}.`)}function $r(e,t,r,n=!0){let o=t[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${e}"\
|
|
141
|
+
must define ${r} as a boolean.`)}function Tc(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`Op\
|
|
142
|
+
eration "${e}" must be an object.`);return Oo(e,t,"targetFields",["schema","input"]),$r(e,t,"enforceRequired"),$r(e,t,"a\
|
|
143
|
+
pplyDefaults"),Oo(e,t,"outputFields",["validated","input"]),$r(e,t,"rejectExplicitUndefined",!1),Object.freeze({targetFields:t.
|
|
138
144
|
targetFields,enforceRequired:t.enforceRequired,applyDefaults:t.applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.
|
|
139
|
-
rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}function
|
|
145
|
+
rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}function Oc(e={}){if(typeof e!="object"||e===null||Array.
|
|
140
146
|
isArray(e))throw new Error("Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
141
|
-
|
|
142
|
-
null);for(let[r,n]of Object.entries(e))
|
|
143
|
-
delete t.mode,t}var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(t))}_fieldToBeSkipped(t,r){
|
|
147
|
-
return Array.isArray(r.skipFields)&&r.skipFields.includes(t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))
|
|
148
|
-
let r={};return
|
|
147
|
+
Sc))b(t,r,n);for(let[r,n]of Object.entries(e))b(t,r,Tc(r,n));return Object.freeze(t)}function Ao(e){let t=Object.create(
|
|
148
|
+
null);for(let[r,n]of Object.entries(e))b(t,r,n);return Object.freeze(t)}function Ac(e){let t={...e};return delete t.operation,
|
|
149
|
+
delete t.mode,t}var Me=class{constructor(t,r,n,o={}){br(t),this.structure=t,this.types=Ao(r),this.validators=Ao(n),this.
|
|
150
|
+
operations=Oc(o),this._installOperationMethods()}_typeError(t){return this._paramError(t,"TYPE_CAST_FAILED","Value could\
|
|
151
|
+
not be cast to the required type.")}_paramError(t,r,n,o={}){let i=new Error(n);return i.errorObject={field:t,code:r,message:n,
|
|
152
|
+
params:o},i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(t))}_fieldToBeSkipped(t,r){
|
|
153
|
+
return Array.isArray(r.skipFields)&&r.skipFields.includes(t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))b(t,n,o)}_singleErrorMap(t){
|
|
154
|
+
let r={};return b(r,t.field,t),r}_assertSupportedOptions(t={}){if(Object.hasOwn(t,"onlyObjectValues"))throw new Error("U\
|
|
149
155
|
nsupported validation option `onlyObjectValues`. Call `patch()` directly.");if(Object.hasOwn(t,"mode"))throw new Error("\
|
|
150
156
|
Unsupported validation option `mode`. Call `validateWith()` or an operation method directly.");if(Object.hasOwn(t,"opera\
|
|
151
157
|
tion"))throw new Error("Unsupported validation option `operation`. Call `validateWith()` or an operation method directly\
|
|
152
158
|
.")}_buildOperationSettings(t,r,n){return{operationName:t,operation:r,targetFieldNames:r.targetFields==="input"?Object.keys(
|
|
153
159
|
n):Object.keys(this.structure),outputFieldNames:r.outputFields==="input"?Object.keys(n):Object.keys(this.structure),enforceRequired:r.
|
|
154
160
|
enforceRequired,applyDefaults:r.applyDefaults,rejectExplicitUndefined:r.rejectExplicitUndefined,defaultedFields:new Set,
|
|
155
|
-
isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(
|
|
161
|
+
isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!$(r))throw new Error(`${t}() expects a plain obje\
|
|
156
162
|
ct input.`)}_resolvePathValidationRequest(t={}){let r=t.operation??t.mode??"patch";if(Object.hasOwn(t,"operation")&&Object.
|
|
157
163
|
hasOwn(t,"mode")&&t.operation!==t.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
158
164
|
oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
|
|
159
|
-
return{operationName:r,operation:n,validationOptions:
|
|
165
|
+
return{operationName:r,operation:n,validationOptions:Ac(t)}}_buildOperationResult(t,r,n){let o={};for(let i of n.outputFieldNames){
|
|
160
166
|
if(!Object.hasOwn(this.structure,i))continue;let s=n.isFieldPresent(i);(r[i]!==void 0||s&&t[i]===null||n.defaultedFields.
|
|
161
|
-
has(i))&&(!s&&!n.defaultedFields.has(i)||
|
|
162
|
-
return
|
|
167
|
+
has(i))&&(!s&&!n.defaultedFields.has(i)||b(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){return vt(t,r)}_resolveArrayItemsConfig(t,r){
|
|
168
|
+
return Et(t,r)}_resolveObjectValuesConfig(t,r){return Xe(t,r)}_buildArrayItemSettings(t,r){return t.type==="object"&&Object.
|
|
163
169
|
hasOwn(t,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(t,r,n,o,i,s,a,c){let u=t.
|
|
164
170
|
nullable===!0||a.nullable===!0,l=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,t.type))throw new Error(
|
|
165
|
-
`No casting function for type: ${t.type}`);let
|
|
171
|
+
`No casting function for type: ${t.type}`);let p=this.types[t.type];if(r===null)return u?(b(o,i,null),{errors:{},shouldContinue:!1}):
|
|
166
172
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
167
|
-
if(r===""&&l)return
|
|
173
|
+
if(r===""&&l)return b(o,i,null),{errors:{},shouldContinue:!1};let d={schema:this,definition:t,value:r,fieldName:n,object:o,
|
|
168
174
|
objectBeforeCast:s,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
169
|
-
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(
|
|
170
|
-
n,
|
|
171
|
-
i,
|
|
175
|
+
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(m,f,g)=>{throw this._paramError(
|
|
176
|
+
n,m,f,g)}};try{let m=p(d);if(bo(m))throw new Error(`Type handler for "${t.type}" must be synchronous.`);m!==void 0&&(b(o,
|
|
177
|
+
i,m),d.value=m)}catch(m){if(m.errorObject)return{errors:this._singleErrorMap(m.errorObject),shouldContinue:!1};throw m}return{
|
|
172
178
|
errors:{},context:d,shouldContinue:!0}}_runFieldValidators(t,r,n,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
|
|
173
179
|
_paramToBeSkipped(a,s.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{i.parameterName=
|
|
174
|
-
a,i.parameterValue=t[a];let u=c(i);if(
|
|
175
|
-
(
|
|
180
|
+
a,i.parameterValue=t[a];let u=c(i);if(bo(u))throw new Error(`Validator handler for "${a}" must be synchronous.`);u!==void 0&&
|
|
181
|
+
(b(n,o,u),i.value=u)}catch(u){if(u.errorObject)return this._singleErrorMap(u.errorObject);throw u}}return{}}_normalizeAndValidateValue(t,r,n,o,i,s,a,c){
|
|
176
182
|
let u=this._castValue(t,r,n,o,i,s,a,c);if(Object.keys(u.errors).length>0)return u.errors;if(!u.shouldContinue)return{};let{
|
|
177
|
-
context:l}=u,
|
|
183
|
+
context:l}=u,p=this._validateNestedValue(t,n,o,i,a,c);return Object.keys(p).length>0?p:(l.value=o[i],this._runFieldValidators(
|
|
178
184
|
t,n,o,i,l,a))}_normalizeDefault(t,r,{fieldPath:n,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
|
|
179
|
-
let u={...o};return
|
|
185
|
+
let u={...o};return b(u,i,r),{errors:this._normalizeAndValidateValue(t,r,n,u,i,s,a,c),value:u[i]}}_validateNestedValue(t,r,n,o,i,s){
|
|
180
186
|
if(t.type==="object"){let c=this._resolveObjectFieldMode(r,t);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
181
187
|
c,r,n,o,i,s):c.kind==="map"?this._validateObjectValues(r,n,o,c.valuesConfig,i,s):{}}if(t.type!=="array")return{};let a=this.
|
|
182
188
|
_resolveArrayItemsConfig(r,t);return a?this._validateArrayItems(r,n,o,a,i,s):{}}_validateNestedObjectSchema(t,r,n,o,i,s){
|
|
183
189
|
let a=n[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,u=t.schema._validateWithOperation(
|
|
184
|
-
s.operationName,s.operation,c
|
|
185
|
-
a,t.schema,u.validatedObject):u.validatedObject),
|
|
186
|
-
entries(t))Object.hasOwn(r.structure,o)&&
|
|
187
|
-
keys(t)){if(!Object.hasOwn(r.structure,i)){
|
|
188
|
-
n))Object.hasOwn(o,i)||
|
|
189
|
-
keys(a)){let
|
|
190
|
-
_mergeErrors(u,this._singleErrorMap(this._typeError(
|
|
191
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,d
|
|
192
|
-
u,
|
|
193
|
-
definition,s));this._mergeErrors(u,
|
|
194
|
-
c.length;l++){let
|
|
195
|
-
this._mergeErrors(u,this._singleErrorMap(this._typeError(
|
|
196
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[l]
|
|
197
|
-
u,
|
|
190
|
+
s.operationName,s.operation,c,$e(i,r));return b(n,o,t.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
191
|
+
a,t.schema,u.validatedObject):u.validatedObject),xe(u.errors,r)}_extractKnownObjectFields(t,r){let n={};for(let[o,i]of Object.
|
|
192
|
+
entries(t))Object.hasOwn(r.structure,o)&&b(n,o,i);return n}_mergeKnownAndPassthroughObjectFields(t,r,n){let o={};for(let i of Object.
|
|
193
|
+
keys(t)){if(!Object.hasOwn(r.structure,i)){b(o,i,t[i]);continue}Object.hasOwn(n,i)&&b(o,i,n[i])}for(let[i,s]of Object.entries(
|
|
194
|
+
n))Object.hasOwn(o,i)||b(o,i,s);return o}_validateObjectValues(t,r,n,o,i,s){let a=r[n],c={...a},u={};b(r,n,c);for(let l of Object.
|
|
195
|
+
keys(a)){let p=_e(t,l);if(this._fieldToBeSkipped(p,i))continue;let d=c[l];if(d===void 0){s.rejectExplicitUndefined?this.
|
|
196
|
+
_mergeErrors(u,this._singleErrorMap(this._typeError(p).errorObject)):delete c[l];continue}if(o.kind==="schema"){let f=o.
|
|
197
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,d,$e(i,p));b(c,l,f.validatedObject),this._mergeErrors(
|
|
198
|
+
u,xe(f.errors,p));continue}let m=this._normalizeAndValidateValue(o.definition,d,p,c,l,a,i,this._buildArrayItemSettings(o.
|
|
199
|
+
definition,s));this._mergeErrors(u,m)}return u}_validateArrayItems(t,r,n,o,i,s){let a=r[n],c=a.slice(),u={};b(r,n,c);for(let l=0;l<
|
|
200
|
+
c.length;l++){let p=_e(t,l);if(this._fieldToBeSkipped(p,i))continue;if(!Object.hasOwn(a,l)||c[l]===void 0){s.rejectExplicitUndefined?
|
|
201
|
+
this._mergeErrors(u,this._singleErrorMap(this._typeError(p).errorObject)):delete c[l];continue}if(o.kind==="schema"){let m=o.
|
|
202
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],$e(i,p));b(c,l,m.validatedObject),this._mergeErrors(
|
|
203
|
+
u,xe(m.errors,p));continue}let d=this._normalizeAndValidateValue(o.definition,c[l],p,c,l,a,i,this._buildArrayItemSettings(
|
|
198
204
|
o.definition,s));this._mergeErrors(u,d)}return u}_validateField(t,r,n,o,i){if(!Object.hasOwn(this.structure,t))return{};
|
|
199
205
|
let s=this.structure[t];if(this._fieldToBeSkipped(t,o))return{};let a=i.isFieldPresent(t),c=r[t],u=c===void 0;return i.enforceRequired&&
|
|
200
206
|
s.required&&(!a||u)&&!this._paramToBeSkipped("required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"\
|
|
201
207
|
Field is required",params:{}}):a?u?i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(t).errorObject):{}:this.
|
|
202
208
|
_normalizeAndValidateValue(s,c,t,n,t,r,o,i):{}}_validateWithOperation(t,r,n,o){this._assertSupportedOptions(o);let i={},
|
|
203
|
-
s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||
|
|
209
|
+
s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||b(i,c,{field:c,
|
|
204
210
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let u=this._validateField(
|
|
205
211
|
c,n,s,o,a);this._mergeErrors(i,u)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
206
212
|
this.structure[c].defaultTo!==void 0){let u=this.structure[c],l=typeof u.defaultTo=="function"?u.defaultTo():u.defaultTo,
|
|
207
|
-
|
|
208
|
-
_mergeErrors(i,
|
|
209
|
-
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of
|
|
210
|
-
let u=
|
|
213
|
+
p=this._normalizeDefault(u,l,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
214
|
+
_mergeErrors(i,p.errors),Object.keys(p.errors).length>0)continue;b(s,c,p.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
215
|
+
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of To(Object.keys(t))){
|
|
216
|
+
let u=Io(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${u}".`);let l=this._validateSelectedField(
|
|
211
217
|
c,t[c],r,a,n,o,u);this._mergeErrors(s,l)}return{validatedObject:a,errors:s}}_validateSelectedField(t,r,n,o,i,s,a){if(!Object.
|
|
212
|
-
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=
|
|
213
|
-
let
|
|
214
|
-
a)&&this._mergeErrors(
|
|
215
|
-
c.defaultTo!==void 0){let _=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,
|
|
216
|
-
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(
|
|
217
|
-
length===0&&
|
|
218
|
+
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=Eo(r);if(this._fieldToBeSkipped(a,i))return{};
|
|
219
|
+
let p=Object.hasOwn(n,t),d=n[t],m={};if(!p){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("required",i.skipParams,
|
|
220
|
+
a)&&this._mergeErrors(m,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),u&&s.applyDefaults&&
|
|
221
|
+
c.defaultTo!==void 0){let _=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,S=this._normalizeDefault(c,_,{fieldPath:a,
|
|
222
|
+
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(m,S.errors),Object.keys(S.errors).
|
|
223
|
+
length===0&&b(o,t,S.value)}return m}if(d===void 0)return u&&s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
218
224
|
a).errorObject):{};let f={[t]:d};if(u){let _=this._normalizeAndValidateValue(c,d,a,f,t,n,i,s);return Object.hasOwn(f,t)&&
|
|
219
|
-
f[t]!==void 0?
|
|
220
|
-
g.errors).length>0)return g.errors;if(!g.shouldContinue)return{};let
|
|
221
|
-
f,t,i,s);return
|
|
222
|
-
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(
|
|
223
|
-
u))return{};let l=c.schema._validateSelectedTree(r,u
|
|
224
|
-
|
|
225
|
+
f[t]!==void 0?b(o,t,f[t]):f[t]===null&&b(o,t,null),_}if(!l)return{};let g=this._castValue(c,d,a,f,t,n,i,s);if(Object.keys(
|
|
226
|
+
g.errors).length>0)return g.errors;if(!g.shouldContinue)return{};let y=this._validateSelectedDescendants(c,r.children,a,
|
|
227
|
+
f,t,i,s);return At(f[t])&&b(o,t,f[t]),y}_validateSelectedDescendants(t,r,n,o,i,s,a){if(t.type==="object"){let c=this._resolveObjectFieldMode(
|
|
228
|
+
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!$(
|
|
229
|
+
u))return{};let l=c.schema._validateSelectedTree(r,u,$e(s,n),{...a,defaultedFields:new Set});return b(o,i,l.validatedObject),
|
|
230
|
+
xe(l.errors,n)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(n,t);if(!c)throw new Error(`Schema path "${n}" d\
|
|
225
231
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,i,c,r,s,a)}throw new Error(
|
|
226
232
|
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],u=r[n],
|
|
227
|
-
l={};
|
|
228
|
-
id because array segments must use numeric indexes.`);let d=Number(
|
|
229
|
-
|
|
230
|
-
if(_===void 0){g&&a.rejectExplicitUndefined&&
|
|
231
|
-
let C=o.schema._validateWithOperation("replace",o.schema.operations.replace,_
|
|
232
|
-
this._mergeErrors(l,
|
|
233
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
234
|
-
this._mergeErrors(l,
|
|
235
|
-
o.definition,_,
|
|
236
|
-
continue}if(!
|
|
237
|
-
l,
|
|
238
|
-
s,
|
|
233
|
+
l={};b(r,n,c);for(let p of To(Object.keys(i))){if(!/^[0-9]+$/.test(p))throw new Error(`Schema path "${_e(t,p)}" is inval\
|
|
234
|
+
id because array segments must use numeric indexes.`);let d=Number(p),m=_e(t,d),f=i[p],g=f.self===!0,y=Eo(f);if(this._fieldToBeSkipped(
|
|
235
|
+
m,s))continue;if(!Object.hasOwn(u,d)){g&&a.rejectExplicitUndefined&&b(l,m,this._typeError(m).errorObject);continue}let _=u[d];
|
|
236
|
+
if(_===void 0){g&&a.rejectExplicitUndefined&&b(l,m,this._typeError(m).errorObject);continue}if(o.kind==="schema"){if(g){
|
|
237
|
+
let C=o.schema._validateWithOperation("replace",o.schema.operations.replace,_,$e(s,m));At(C.validatedObject)&&b(c,d,C.validatedObject),
|
|
238
|
+
this._mergeErrors(l,xe(C.errors,m));continue}if(!y)continue;let T=o.schema._validateSelectedTree(f.children,_,$e(s,m),{...a,
|
|
239
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});At(T.validatedObject)&&b(c,d,T.validatedObject),
|
|
240
|
+
this._mergeErrors(l,xe(T.errors,m));continue}let S=this._buildArrayItemSettings(o.definition,a),A=[_];if(g){let T=this._normalizeAndValidateValue(
|
|
241
|
+
o.definition,_,m,A,0,u,s,S);Object.hasOwn(A,0)&&A[0]!==void 0?b(c,d,A[0]):A[0]===null&&b(c,d,null),this._mergeErrors(l,T);
|
|
242
|
+
continue}if(!y)continue;let I=this._castValue(o.definition,_,m,A,0,u,s,S);if(Object.keys(I.errors).length>0){this._mergeErrors(
|
|
243
|
+
l,I.errors);continue}if(!I.shouldContinue)continue;let P=this._validateSelectedDescendants(o.definition,f.children,m,A,0,
|
|
244
|
+
s,S);At(A[0])&&b(c,d,A[0]),this._mergeErrors(l,P)}return l}validateWith(t,r,n={}){if(!Object.hasOwn(this.operations,t))throw new Error(
|
|
239
245
|
`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(t,r),this._validateWithOperation(
|
|
240
|
-
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=
|
|
241
|
-
_resolvePathValidationRequest(n),c=this._validateSelectedTree(
|
|
246
|
+
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Mr(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
247
|
+
_resolvePathValidationRequest(n),c=this._validateSelectedTree(So([t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:bc(
|
|
242
248
|
c.validatedObject,o),errors:c.errors}}validatePaths(t,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
243
249
|
isArray(t)||t.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
244
|
-
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(
|
|
250
|
+
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(So(t),r,s,this.
|
|
245
251
|
_buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.keys(this.operations)){if(t in this)throw new Error(
|
|
246
252
|
`Operation name "${t}" is reserved and cannot be used as a schema method.`);this[t]=(r,n={})=>this.validateWith(t,r,n)}}toJsonSchema(t={}){
|
|
247
|
-
return
|
|
248
|
-
"")throw new Error("Field path must be a non-empty string.");let r=
|
|
249
|
-
let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
250
|
-
let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,
|
|
251
|
-
{
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
return wo(this,t)}getFieldDefinitions(){return xr.has(this)||xr.set(this,Nr(this.structure)),xr.get(this)}getFieldDefinition(t){
|
|
254
|
+
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=Lr(this,Mr(t.trim()));
|
|
255
|
+
return r===null?null:Nr(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
256
|
+
messages===null?Object.freeze({}):Nr(r.messages)}cleanup(t,r){let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,
|
|
257
|
+
o)&&this.structure[o][r]&&b(n,o,t[o]);return n}};var{parse:Ym,stringify:Ic}=JSON,{keys:Km}=Object,Rc=String,Pc="string";var Po="object",Cc=(e,t)=>t;var Co=(e,t,r)=>{let n=Rc(t.push(r)-1);return e.set(r,n),n};var ko=(e,t,r)=>{let n=t&&typeof t===Po?(l,p)=>l===""||-1<t.indexOf(l)?p:void 0:t||Cc,o=new Map,i=[],s=[],a=+Co(o,i,n.call(
|
|
258
|
+
{"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=Ic(i[a++],u,r);return"["+s.join(",")+"]";function u(l,p){if(c)return c=!c,
|
|
259
|
+
p;let d=n.call(this,l,p);switch(typeof d){case Po:if(d===null)return d;case Pc:return o.get(d)||Co(o,i,d)}return d}};var Nc=new Set(["true","1","yes","y","on"]),xc=new Set(["false","0","no","n","off"]);function $c(e){return e!==null&&(typeof e==
|
|
260
|
+
"object"||typeof e=="function")&&typeof e.then=="function"}function No(e){if(typeof e=="number")return Number.isFinite(e)?
|
|
254
261
|
e:null;if(typeof e=="bigint"){let t=Number(e);return Number.isSafeInteger(t)?t:null}if(typeof e=="string"){let t=e.trim();
|
|
255
|
-
if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function
|
|
262
|
+
if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function Dr(e,t){if(Object.is(e,t))return!0;
|
|
256
263
|
if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.
|
|
257
264
|
source===t.source&&e.flags===t.flags;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==
|
|
258
|
-
t.length)return!1;for(let o=0;o<e.length;o++)if(!
|
|
265
|
+
t.length)return!1;for(let o=0;o<e.length;o++)if(!Dr(e[o],t[o]))return!1;return!0}if(e===null||t===null||typeof e!="objec\
|
|
259
266
|
t"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=Object.keys(e),n=Object.keys(
|
|
260
|
-
t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!
|
|
267
|
+
t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!Dr(e[o],t[o]))return!1;return!0}var Mc={install(e){
|
|
261
268
|
let{addType:t,addValidator:r}=e;t("none",n=>n.value),t("file",n=>{let o=n.value;o==null&&n.throwTypeError();let i=typeof o;
|
|
262
269
|
if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),
|
|
263
270
|
t("string",n=>{let o=n.value;if(o==null)return"";let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();
|
|
264
|
-
return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),t("number",n=>{let o=
|
|
265
|
-
null&&n.throwTypeError(),o}),t("integer",n=>{let o=
|
|
266
|
-
o}),t("epochMilliseconds",n=>{let o=
|
|
267
|
-
n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=
|
|
268
|
-
value,o)||n.throwTypeError(),n.value}),t("date",n=>(
|
|
269
|
-
n.fieldName);return
|
|
270
|
-
n.value)?[n.value]:n.value),t("object",n=>(
|
|
271
|
-
n.value)}catch{try{return
|
|
271
|
+
return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),t("number",n=>{let o=No(n.value);return o===
|
|
272
|
+
null&&n.throwTypeError(),o}),t("integer",n=>{let o=No(n.value);return(o===null||!Number.isInteger(o))&&n.throwTypeError(),
|
|
273
|
+
o}),t("epochMilliseconds",n=>{let o=vr(n.value,864e13);return o===null&&n.throwTypeError(),o}),t("epochSeconds",n=>{let o=vr(
|
|
274
|
+
n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=Qe(n.definition,n.fieldName);return lo(n.
|
|
275
|
+
value,o)||n.throwTypeError(),n.value}),t("date",n=>(co(n.value)||n.throwTypeError(),n.value)),t("time",n=>{let o=Qe(n.definition,
|
|
276
|
+
n.fieldName);return uo(n.value,o)||n.throwTypeError(),n.value}),t("array",n=>n.definition.type==="array"&&!Array.isArray(
|
|
277
|
+
n.value)?[n.value]:n.value),t("object",n=>($(n.value)||n.throwTypeError(),n.value)),t("serialize",n=>{try{return JSON.stringify(
|
|
278
|
+
n.value)}catch{try{return ko(n.value)}catch{n.throwTypeError()}}}),t("boolean",n=>{if(typeof n.value=="boolean")return n.
|
|
272
279
|
value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
|
|
273
280
|
"bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
|
|
274
281
|
n.definition.stringFalseWhen||"false").trim().toLowerCase(),i=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
275
|
-
s=n.value.trim().toLowerCase(),a=new Set([...
|
|
282
|
+
s=n.value.trim().toLowerCase(),a=new Set([...xc,o]),c=new Set([...Nc,i]);if(a.has(s))return!1;if(c.has(s))return!0}n.throwTypeError()}),
|
|
276
283
|
t("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
|
|
277
284
|
value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
|
|
278
285
|
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let i=Number(o);return Number.isSafeInteger(
|
|
279
286
|
i)||n.throwTypeError(),i}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.
|
|
280
287
|
toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGTH",`Length must be at least ${n.parameterValue}\
|
|
281
|
-
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&
|
|
288
|
+
characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),r("min",n=>{n.value!==void 0&&ke(n.definition)&&
|
|
282
289
|
typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("MIN_VALUE",`Value must be at least ${n.parameterValue}\
|
|
283
290
|
.`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==void 0&&n.definition.type==="string"&&n.value.toString&&
|
|
284
291
|
n.value.toString().length>n.parameterValue&&n.throwParamError("MAX_LENGTH",`Length must be no more than ${n.parameterValue}\
|
|
285
|
-
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&
|
|
292
|
+
characters.`,{max:n.parameterValue,actual:n.value.toString().length})}),r("max",n=>{n.value!==void 0&&ke(n.definition)&&
|
|
286
293
|
typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError("MAX_VALUE",`Value must be no more than ${n.parameterValue}\
|
|
287
294
|
.`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.isArray(n.parameterValue))throw new Error(`Enum for ${n.
|
|
288
|
-
fieldName} must be an array.`);n.parameterValue.some(i=>
|
|
295
|
+
fieldName} must be an array.`);n.parameterValue.some(i=>Dr(i,n.value))||n.throwParamError("ENUM_VALUE","Value must match\
|
|
289
296
|
one of the allowed enum values.",{allowed:n.parameterValue})}),r("pattern",n=>{if(n.value===void 0||n.definition.type!==
|
|
290
297
|
"string"||typeof n.value!="string")return;let o=n.parameterValue,i=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
291
298
|
"string"?new RegExp(o):null;if(!i)throw new Error(`Pattern for ${n.fieldName} must be a string or RegExp.`);i.test(n.value)||
|
|
@@ -293,264 +300,268 @@ n.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
293
300
|
parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
|
|
294
301
|
fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
|
|
295
302
|
"validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
|
|
296
|
-
let o=n.parameterValue(n.value,n.object,n);if(
|
|
303
|
+
let o=n.parameterValue(n.value,n.object,n);if($c(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
|
|
297
304
|
ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
|
|
298
305
|
ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
|
|
299
306
|
th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
|
|
300
307
|
String(n.valueBeforeCast).length>n.parameterValue&&n.throwParamError("RANGE_EXCEEDED","Numeric value is out of the allow\
|
|
301
|
-
ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).length})}),r("
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).length})}),r("minItems",n=>{Array.isArray(n.
|
|
309
|
+
value)&&n.value.length<n.parameterValue&&n.throwParamError("MIN_ITEMS",`Must have at least ${n.parameterValue} items.`,{
|
|
310
|
+
min:n.parameterValue,actual:n.value.length})}),r("maxItems",n=>{Array.isArray(n.value)&&n.value.length>n.parameterValue&&
|
|
311
|
+
n.throwParamError("MAX_ITEMS",`Must have no more than ${n.parameterValue} items.`,{max:n.parameterValue,actual:n.value.length})}),
|
|
312
|
+
r("notEmpty",n=>{n.parameterValue&&typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot b\
|
|
313
|
+
e empty.")}),r("required",()=>{}),r("unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{
|
|
314
|
+
if(n.definition.type!=="time"&&n.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
|
|
315
|
+
e or dateTime fields (${n.fieldName}).`)}),r("nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},xo=Mc;var jo=new WeakMap,Do=new WeakMap,Uo=Symbol.for("json-rest-schema.registry-metadata"),Pt=new WeakSet;function Lc(e,t,r){
|
|
316
|
+
if(typeof r!="function")throw new Error(`Type handler for '${t}' must be a function.`);b(e,t,r)}function jc(e,t,r){if(typeof r!=
|
|
317
|
+
"function")throw new Error(`Validator handler for '${t}' must be a function.`);b(e,t,r)}function Ct(e={}){let t=Object.create(
|
|
318
|
+
null);for(let[r,n]of Object.entries(e))b(t,r,n);return t}function $o(e,t){if(typeof e.install!="function")throw new Error(
|
|
319
|
+
"Plugin must have an install method.");e.install(t)}function Mo(e,t,r){jo.set(e,t),Do.set(e,r),Object.defineProperty(e,Uo,
|
|
320
|
+
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function Dc(e){if(!e||
|
|
321
|
+
typeof e!="object"&&typeof e!="function")return null;let t=jo.get(e),r=Do.get(e);if(t&&r)return{types:t,validators:r};let n=e[Uo];
|
|
312
322
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
313
323
|
typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.validators=="object"&&typeof e.create=="fu\
|
|
314
324
|
nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
|
|
315
|
-
validators}:null}function
|
|
316
|
-
|
|
317
|
-
conflicting ${r} "${n}".`)
|
|
318
|
-
t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
let c=new
|
|
322
|
-
|
|
323
|
-
{types:a.types,validators:a.validators,installCore:!1})},r
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
325
|
+
validators}:null}function Uc(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function Lo(e,t,r){for(let[n,o]of Object.
|
|
326
|
+
entries(t)){if(Object.hasOwn(e,n)&&e[n]!==o){if(Pt.has(o))continue;if(!Pt.has(e[n]))throw new Error(`Cannot merge schema\
|
|
327
|
+
factories with conflicting ${r} "${n}".`)}b(e,n,o)}}function Bc(e,t,r){let n=Uc(r).filter(Boolean);if(n.length<1)return{
|
|
328
|
+
types:Ct(e),validators:Ct(t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=Dc(s);if(!a)throw new Error(
|
|
329
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");Lo(o,a.types,"type"),Lo(i,a.
|
|
330
|
+
validators,"validator")}return{types:o,validators:i}}function Bo({types:e={},validators:t={},installCore:r=!0}={}){let n=Ct(
|
|
331
|
+
e),o=Ct(t),i=(s,a={})=>{let c=new Me(s,n,o,a.operations);return Mo(c,n,o),c};return Mo(i,n,o),i.addType=(s,a)=>{Lc(n,s,a)},
|
|
332
|
+
i.addValidator=(s,a)=>{jc(o,s,a)},i.use=s=>{$o(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
|
|
333
|
+
let a=Bc(n,o,s);return Bo({types:a.types,validators:a.validators,installCore:!1})},r&&$o(xo,{addType:(s,a)=>{Pt.add(a),i.
|
|
334
|
+
addType(s,a)},addValidator:(s,a)=>{Pt.add(a),i.addValidator(s,a)}}),i}var Go=Bo({installCore:!0});var _f=Object.freeze({schema:Go({}),mode:"replace"});var Ho=/^[a-z][a-z0-9_.-]*$/u,Hc=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function Vc(e){return String(e||"").trim().toLowerCase()}
|
|
335
|
+
function Gr(e,t){let r=Vc(e);if(!Ho.test(r))throw new TypeError(`${t} must match ${Ho.toString()}.`);return r}function Ur(e,t){
|
|
336
|
+
if(e==null)return Object.freeze({});if(!F(e))throw new TypeError(`${t} must be an object mapping local names to capabili\
|
|
337
|
+
ty ids.`);let r={},n=new Set;for(let[o,i]of Object.entries(e)){let s=String(o||"").trim();if(!Hc.test(s))throw new TypeError(
|
|
338
|
+
`${t} local name "${s}" must be a JavaScript identifier.`);let a=Gr(i,`${t}.${s}`);if(n.has(a))throw new TypeError(`${t}\
|
|
339
|
+
declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.freeze(r)}function zc(e,t,r){if(e==null)return Object.
|
|
340
|
+
freeze({});if(!F(e))throw new TypeError(`${r}.hints must be an object mapping required capability ids to what to registe\
|
|
341
|
+
r.`);let n=new Set(Object.values(t)),o={};for(let[i,s]of Object.entries(e)){let a=Gr(i,`${r}.hints key`);if(!n.has(a))throw new TypeError(
|
|
331
342
|
`${r}.hints names "${a}", which the provider does not require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${r}\
|
|
332
|
-
.hints["${a}"] must be the text that says what to register.`);o[a]=s.trim()}return Object.freeze(o)}function
|
|
343
|
+
.hints["${a}"] must be the text that says what to register.`);o[a]=s.trim()}return Object.freeze(o)}function Fc(e){let t=new Map;
|
|
333
344
|
for(let[r,n]of Object.entries(e))for(let o of Object.keys(n)){if(t.has(o))throw new TypeError(`Provider local name "${o}\
|
|
334
|
-
" is declared by both ${t.get(o)} and ${r}.`);t.set(o,r)}}function
|
|
335
|
-
throw new TypeError(`${t} must be a function when provided.`);return e}function
|
|
336
|
-
hints:o={},setup:i,boot:s=null,shutdown:a=null}={}){let c=
|
|
337
|
-
nal`),
|
|
338
|
-
`${c}.setup is required.`);return Object.freeze({id:c,requires:u,optional:l,provides:
|
|
339
|
-
`${c}.boot`),shutdown:
|
|
345
|
+
" is declared by both ${t.get(o)} and ${r}.`);t.set(o,r)}}function Br(e,t){if(e==null)return null;if(typeof e!="function")
|
|
346
|
+
throw new TypeError(`${t} must be a function when provided.`);return e}function Nt({id:e,requires:t={},optional:r={},provides:n={},
|
|
347
|
+
hints:o={},setup:i,boot:s=null,shutdown:a=null}={}){let c=Gr(e,"Provider id"),u=Ur(t,`${c}.requires`),l=Ur(r,`${c}.optio\
|
|
348
|
+
nal`),p=Ur(n,`${c}.provides`);Fc({requires:u,optional:l,provides:p});let d=Br(i,`${c}.setup`);if(!d)throw new TypeError(
|
|
349
|
+
`${c}.setup is required.`);return Object.freeze({id:c,requires:u,optional:l,provides:p,hints:zc(o,u,c),setup:d,boot:Br(s,
|
|
350
|
+
`${c}.boot`),shutdown:Br(a,`${c}.shutdown`)})}var Vo="public";var Wc="/api",Fo=`${Wc}/bootstrap`;function Hr(){let e=[],t=new Set,r=!1;function n({id:a,order:c=0,contribute:u}={}){if(r)throw new Error("Bootstrap regis\
|
|
340
351
|
tration is closed after the first payload is resolved.");let l=h(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
341
352
|
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
|
|
342
353
|
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
|
|
343
|
-
isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u=e.map((l,
|
|
344
|
-
(l,
|
|
345
|
-
freeze({...
|
|
354
|
+
isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u=e.map((l,p)=>({entry:l,index:p})).sort(
|
|
355
|
+
(l,p)=>l.entry.order-p.entry.order||l.index-p.index).map(({entry:l})=>l);for(let l of u){let p=await l.contribute(Object.
|
|
356
|
+
freeze({...F(a)?a:{},payload:Object.freeze({...c})}));c={...c,...F(p)?p:{}}}return Object.freeze(c)}function i(){return Object.
|
|
346
357
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
347
|
-
return s}var
|
|
348
|
-
let t
|
|
349
|
-
async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:t}}});function
|
|
358
|
+
return s}var qc=Nt({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:e}){
|
|
359
|
+
let t=Hr();return e.router.register("GET",Fo,{auth:Vo,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
|
|
360
|
+
async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:t}}});function Yc(e){if(!F(e))throw new TypeError("Event listener must be an object.");let t=String(e.id||"").trim();if(!t)throw new TypeError(
|
|
350
361
|
"Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
|
|
351
362
|
dle().`);if(e.matches!=null&&typeof e.matches!="function")throw new TypeError(`Event listener "${t}" matches must be a f\
|
|
352
|
-
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function
|
|
363
|
+
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function Kc(e){if(!F(e))throw new TypeError(
|
|
353
364
|
"Published event must be an object.");let t=String(e.type||"").trim();if(!t)throw new TypeError("Published event type is\
|
|
354
|
-
required.");return Object.freeze({...e,type:t})}function
|
|
355
|
-
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=
|
|
365
|
+
required.");return Object.freeze({...e,type:t})}function Vr(){let e=[],t=new Set;function r(s){let a=Yc(s);if(t.has(a.id))
|
|
366
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=Kc(s);
|
|
356
367
|
for(let c of e)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
357
|
-
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var
|
|
358
|
-
import{promisify as
|
|
359
|
-
name is required.");throw r.code="vibe64_invalid_os_username",r}return t}function
|
|
368
|
+
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var Jc=Nt({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:Vr()}}});import{execFile as Xc}from"node:child_process";import{readFile as Qc}from"node:fs/promises";import zr from"node:os";import Zc from"node:path";
|
|
369
|
+
import{promisify as eu}from"node:util";var tu=eu(Xc);function qo(e=""){let t=h(e);if(!t||t.includes("/")||t.includes("\\")||t.includes(":")){let r=new Error("A valid OS user\
|
|
370
|
+
name is required.");throw r.code="vibe64_invalid_os_username",r}return t}function Yo([e,t,r,n,o,i]=[]){if(!/^\d+$/u.test(
|
|
360
371
|
t)||!/^\d+$/u.test(r))return null;let s=Number(t),a=Number(r);return!Number.isSafeInteger(s)||!Number.isSafeInteger(a)?null:
|
|
361
|
-
{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),uid:s,username:String(e||"")}}function
|
|
362
|
-
let t=String(e||"").trim().split(":");return t.length<7?null:
|
|
372
|
+
{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),uid:s,username:String(e||"")}}function Fr(e=""){
|
|
373
|
+
let t=String(e||"").trim().split(":");return t.length<7?null:Yo([t[0],t[2],t[3],t[4],t[5],t[6]])}function ru(e=""){return String(
|
|
363
374
|
e||"").split(/\r?\n[\t ]*\r?\n/u).map(t=>{let r={};for(let n of t.split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);
|
|
364
|
-
o&&(r[o[1]]=o[2].trim())}return
|
|
365
|
-
let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="string"?n:n?.stdout)||"")}function
|
|
366
|
-
userInfo:t=
|
|
375
|
+
o&&(r[o[1]]=o[2].trim())}return Yo([r.name,r.uid,r.gid,r.gecos,r.dir,r.shell])}).filter(Boolean)}async function Wo(e,t,r){
|
|
376
|
+
let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="string"?n:n?.stdout)||"")}function et({homedir:e=zr.homedir,
|
|
377
|
+
userInfo:t=zr.userInfo}={}){let r=t(),n=h(r?.username||process.env.USER||process.env.LOGNAME),o=Zc.resolve(String(r?.homedir||
|
|
367
378
|
e()||""));return{displayName:String(r?.username||n),gid:Number.isSafeInteger(r?.gid)?r.gid:null,home:o,shell:String(r?.shell||
|
|
368
|
-
""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}async function
|
|
369
|
-
readFileFn:n=
|
|
379
|
+
""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}async function xt(e="",{execFileFn:t=tu,platform:r=process.platform,
|
|
380
|
+
readFileFn:n=Qc,userInfo:o=zr.userInfo}={}){let i=qo(e);if(r==="linux"&&!/^\d+$/u.test(i)){let c=[...(await n("/etc/nssw\
|
|
370
381
|
itch.conf","utf8").catch(()=>"")).matchAll(/^[\t ]*passwd[\t ]*:[\t ]*([^#\r\n]*)/gmu)],u=c.length===1?c[0][1].trim().split(
|
|
371
|
-
/\s+/u):[];if(u[0]==="files"&&(u.length===1||/^[a-z_][a-z0-9_-]*$/iu.test(u[1]))){let
|
|
372
|
-
()=>"")).split(/\r?\n/u).map(
|
|
373
|
-
username===i)return a;[s]=
|
|
382
|
+
/\s+/u):[];if(u[0]==="files"&&(u.length===1||/^[a-z_][a-z0-9_-]*$/iu.test(u[1]))){let p=(await n("/etc/passwd","utf8").catch(
|
|
383
|
+
()=>"")).split(/\r?\n/u).map(Fr).find(d=>d?.username===i);if(p)return p}}let s;if(r==="darwin"){let a=et({userInfo:o});if(a.
|
|
384
|
+
username===i)return a;[s]=ru(await Wo(t,"dscacheutil",["-q","user","-a","name",i]))}else s=Fr((await Wo(t,"getent",["pas\
|
|
374
385
|
swd",i])).split(/\r?\n/u)[0]);if(!s||s.username!==i){let a=new Error(`OS user was not found: ${i}`);throw a.code="vibe64\
|
|
375
|
-
_os_user_not_found",a}return s}var
|
|
376
|
-
isSafeInteger(t)&&t>=0?t:null}function v(e=""){let t=
|
|
377
|
-
t);if(!r||!n)return!1;let o
|
|
378
|
-
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function
|
|
379
|
-
([t,r])=>[
|
|
380
|
-
[e]){let o=
|
|
381
|
-
isFinite(t)?t:0}function ne(...e){for(let t of e){let r=
|
|
382
|
-
gid:
|
|
383
|
-
return
|
|
384
|
-
join(r.home,".cache"),XDG_CONFIG_HOME:
|
|
386
|
+
_os_user_not_found",a}return s}var mh=Object.freeze({parsePasswdLine:Fr});import nu from"node:os";import qr from"node:path";import $t from"node:path";function E(e=""){return String(e??"").trim()}function Wr(e=null){let t=Number(e);return Number.
|
|
387
|
+
isSafeInteger(t)&&t>=0?t:null}function v(e=""){let t=E(e);return t?$t.resolve(t):""}function se(e="",t=""){let r=v(e),n=v(
|
|
388
|
+
t);if(!r||!n)return!1;let o=$t.relative(r,n);return o!==".."&&!o.startsWith(`..${$t.sep}`)&&!$t.isAbsolute(o)}function M(e={}){
|
|
389
|
+
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function W(e={}){return Object.fromEntries(Object.entries(M(e)).map(
|
|
390
|
+
([t,r])=>[E(t),String(r??"")]).filter(([t])=>!!t))}function ye(e=[]){let t=[],r=new Set;for(let n of Array.isArray(e)?e:
|
|
391
|
+
[e]){let o=E(n);!o||r.has(o)||(r.add(o),t.push(o))}return t}function Le(e){let t=Date.parse(String(e||"").trim());return Number.
|
|
392
|
+
isFinite(t)?t:0}function ne(...e){for(let t of e){let r=E(t);if(r)return r}return""}function Yr(e={}){let t=E(e.username),r=v(e.home||(t?`/home/${t}`:nu.homedir()));return{displayName:E(e.displayName||t),
|
|
393
|
+
gid:Wr(e.gid),home:r,shell:E(e.shell),uid:Wr(e.uid),username:t}}function Kr(){return Yr(et())}async function Jr(e="",t={}){
|
|
394
|
+
return Yr(await xt(e,t))}function tt(e={},t={}){let r=Yr(e);return{...t,HOME:r.home,LOGNAME:r.username,USER:r.username,XDG_CACHE_HOME:qr.
|
|
395
|
+
join(r.home,".cache"),XDG_CONFIG_HOME:qr.join(r.home,".config"),XDG_DATA_HOME:qr.join(r.home,".local","share")}}function Ko(){
|
|
385
396
|
return{gid:typeof process.getgid=="function"?process.getgid():null,uid:typeof process.getuid=="function"?process.getuid():
|
|
386
|
-
null}}function
|
|
387
|
-
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:l=!1,execution:
|
|
388
|
-
let
|
|
389
|
-
`)).trim();return{code:
|
|
390
|
-
Number(s):null,signal:
|
|
391
|
-
ct"&&!Array.isArray(
|
|
392
|
-
d",r={}){let n=
|
|
393
|
-
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}import{spawn as
|
|
394
|
-
import{stripVTControlCharacters as
|
|
397
|
+
null}}function ou(e=0){let t=Number(e);return Number.isSafeInteger(t)?t:1}function rt({code:e="",error:t="",exitCode:r=0,ok:n=null,
|
|
398
|
+
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:l=!1,execution:p=null,retryable:d=null}={}){
|
|
399
|
+
let m=ou(r),f=String(u||""),g=String(c||""),y=String(o||[f,g].filter(Boolean).join(`
|
|
400
|
+
`)).trim();return{code:E(e),error:E(t),exitCode:m,ok:n===null?m===0:n===!0,output:y,pid:Number.isSafeInteger(Number(s))?
|
|
401
|
+
Number(s):null,signal:E(a),stderr:g,stdout:f,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...p&&typeof p=="obje\
|
|
402
|
+
ct"&&!Array.isArray(p)?{execution:p}:{},...typeof d=="boolean"?{retryable:d}:{}}}function L(e="",t="vibe64_command_faile\
|
|
403
|
+
d",r={}){let n=E(e)||"Vibe64 command failed.";return rt({...r,code:t,error:n,exitCode:1,ok:!1,output:E(r.output)||n,stderr:r.
|
|
404
|
+
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}import{spawn as iu}from"node:child_process";import{statSync as su}from"node:fs";import au from"node:path";import{StringDecoder as cu}from"node:string_decoder";
|
|
405
|
+
import{stripVTControlCharacters as uu}from"node:util";var Jo=1e8,Qo=5e3,lu=Object.freeze({SIGABRT:"Aborted",SIGALRM:"Tim\
|
|
395
406
|
eout or timer",SIGHUP:"Terminal closed",SIGINT:"User interruption with CTRL-C",SIGKILL:"Forced termination",SIGPIPE:"Bro\
|
|
396
407
|
ken pipe or socket",SIGQUIT:"User interruption with CTRL-\\",SIGSEGV:"Segmentation fault",SIGTERM:"Termination",SIGUSR1:"\
|
|
397
|
-
Application-specific signal",SIGUSR2:"Application-specific signal"}),
|
|
398
|
-
her}","gu"),
|
|
399
|
-
|
|
400
|
-
toString(16)}`})}function
|
|
401
|
-
`).map(
|
|
402
|
-
`)}function
|
|
403
|
-
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function
|
|
404
|
-
return r;try{if(!
|
|
408
|
+
Application-specific signal",SIGUSR2:"Application-specific signal"}),du=/^[\w./-]+$/u,pu=new RegExp("\\p{Separator}|\\p{Ot\
|
|
409
|
+
her}","gu"),Xo=Object.freeze({" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"});function Zo(e){return e.replaceAll(
|
|
410
|
+
pu,t=>{if(Xo[t]!==void 0)return Xo[t];let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.
|
|
411
|
+
toString(16)}`})}function mu(e){return uu(e).split(`
|
|
412
|
+
`).map(Zo).join(`
|
|
413
|
+
`)}function fu(e,t){return[e,...t].map(r=>{let n=Zo(String(r));return du.test(n)?n:process.platform==="win32"?`"${n.replaceAll(
|
|
414
|
+
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function hu(e,t){let r=String(e?.message??e);if(t===process.cwd())
|
|
415
|
+
return r;try{if(!su(t).isDirectory())return`The "cwd" option is not a directory: ${t}.
|
|
405
416
|
${r}`}catch(n){return`The "cwd" option is invalid: ${t}.
|
|
406
417
|
${n.message}
|
|
407
|
-
${r}`}return r}function
|
|
418
|
+
${r}`}return r}function gu(e){let t=e.forcefullyTerminated?` and was forcefully terminated after ${Qo} milliseconds`:"";
|
|
408
419
|
if(e.timedOut)return`Command timed out after ${e.timeout} milliseconds${t}`;if(e.maxBuffer)return`Command's ${e.maxBuffer.
|
|
409
420
|
stream} was larger than ${e.maxBuffer.limit} ${e.maxBuffer.unit}${t}`;if(e.spawnError?.code!==void 0)return`Command fail\
|
|
410
|
-
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=
|
|
411
|
-
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function
|
|
412
|
-
|
|
413
|
-
${t}`:""}`}function
|
|
421
|
+
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=lu[e.signal];return`Command was killed with ${e.signal}${r?` (${r})`:
|
|
422
|
+
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function _u(e){let t=e.spawnError?
|
|
423
|
+
mu(hu(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${gu(e)}: ${e.commandLine}${t?`
|
|
424
|
+
${t}`:""}`}function Xr(e,t){let r=new cu(e),n=[],o=0,i=!1;return{write(s){if(i)return!1;let a=r.write(s);return o+a.length>
|
|
414
425
|
t?(n.push(a.slice(0,t-o)),o=t,i=!0,!1):(n.push(a),o+=a.length,!0)},text(){if(!i){let s=r.end();s&&n.push(s.slice(0,t-o)),
|
|
415
|
-
i=!0}return n.join("")}}}function
|
|
416
|
-
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:
|
|
417
|
-
d=
|
|
418
|
-
|
|
419
|
-
f=!1,g=null,
|
|
420
|
-
()=>{!f&&d.kill("SIGKILL")&&(
|
|
421
|
-
{limit:u,stream:P,unit:"characters"},
|
|
422
|
-
on("data",
|
|
423
|
-
d.stdin.end(o));let
|
|
424
|
-
f=!0,clearTimeout(
|
|
425
|
-
|
|
426
|
-
shortMessage:
|
|
427
|
-
once("close",
|
|
428
|
-
import
|
|
429
|
-
|
|
430
|
-
[
|
|
431
|
-
t&&(
|
|
426
|
+
i=!0}return n.join("")}}}function ei(e,t,{cwd:r="",env:n={},input:o=void 0,maxBuffer:i=Jo,onOutput:s=null,outputEncoding:a="\
|
|
427
|
+
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:Jo,l={all:Xr(a,u*2),stderr:Xr(a,u),stdout:Xr(a,u)},p=o!=null,
|
|
428
|
+
d=iu(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[p?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
429
|
+
m={commandLine:fu(e,t),cwd:au.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
430
|
+
f=!1,g=null,y=()=>{};d.on("error",P=>{m.spawnError||=P,d.pid===void 0&&y()});let _=()=>{f||!d.kill("SIGTERM")||g||(g=setTimeout(
|
|
431
|
+
()=>{!f&&d.kill("SIGKILL")&&(m.forcefullyTerminated=!0)},Qo))},S=(P,T)=>C=>{if(l.all.write(C),l[P].write(C)||(m.maxBuffer||=
|
|
432
|
+
{limit:u,stream:P,unit:"characters"},T.destroy()),typeof s=="function")try{s(String(C||""))}catch{}};d.stdout&&d.stdout.
|
|
433
|
+
on("data",S("stdout",d.stdout)),d.stderr&&d.stderr.on("data",S("stderr",d.stderr)),p&&d.stdin&&(d.stdin.on("error",()=>{}),
|
|
434
|
+
d.stdin.end(o));let A=c>0?setTimeout(()=>{m.timedOut=!0,_()},c):null;return{completion:new Promise(P=>{y=(T,C)=>{if(f)return;
|
|
435
|
+
f=!0,clearTimeout(A),clearTimeout(g);let N=m.spawnError?{}:{exitCode:typeof T=="number"&&T>=0?T:void 0,signal:C||void 0},
|
|
436
|
+
J=m.spawnError||m.timedOut||m.maxBuffer||N.exitCode!==0;P({all:l.all.text(),code:m.spawnError?.code,exitCode:N.exitCode,
|
|
437
|
+
shortMessage:J?_u({...m,...N}):"",signal:N.signal,stderr:l.stderr.text(),stdout:l.stdout.text(),timedOut:m.timedOut})},d.
|
|
438
|
+
once("close",y)}),kill:P=>d.kill(P),pid:d.pid}}import{spawn as ni}from"node:child_process";import{mkdir as wu,open as bu,readdir as Eu,readFile as vu}from"node:fs/promises";
|
|
439
|
+
import Su from"node:path";import{fileURLToPath as Tu}from"node:url";var yu=new URL("./../../../vibe64-execution/src/server/engines/detached.js",import.meta.url).href,we=new Map,Ou=3e3,Au=1e3,
|
|
440
|
+
Iu=Tu(new URL("./detachedReaper.js",yu)),X=null;function Ru(e){if(process.platform!=="win32"){if(!X){let t=ni(process.execPath,
|
|
441
|
+
[Iu],{cwd:"/",detached:!0,stdio:["pipe","ignore","ignore"]});t.once("error",()=>{X===t&&(X=null)}),t.once("exit",()=>{X===
|
|
442
|
+
t&&(X=null)}),t.stdin.on("error",()=>{}),t.unref(),t.stdin.unref(),X=t;for(let r of we.values())r.scopeEmpty!==!0&&r.pid!==
|
|
432
443
|
e&&t.stdin.write(`+${r.pid}
|
|
433
|
-
`)}
|
|
434
|
-
`)}}function
|
|
435
|
-
`),![...
|
|
436
|
-
e),{recursive:!0}),
|
|
437
|
-
e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function
|
|
438
|
-
await
|
|
439
|
-
env:n,stdio:i});await
|
|
440
|
-
s.once("exit",()=>{!
|
|
441
|
-
|
|
444
|
+
`)}X.stdin.write(`+${e}
|
|
445
|
+
`)}}function Pu(e){X&&(X.stdin.write(`-${e}
|
|
446
|
+
`),![...we.values()].some(t=>t.scopeEmpty!==!0)&&(X.stdin.end(),X=null))}async function Cu(e=""){return e?(await wu(Su.dirname(
|
|
447
|
+
e),{recursive:!0}),bu(e,"w",384)):null}async function ku(e){return new Promise((t,r)=>{let n=!1,o=(i,s)=>{n||(n=!0,i(s))};
|
|
448
|
+
e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function oi(e={},t={}){let{cwd:r="",env:n={}}=t,o=null;try{o=
|
|
449
|
+
await Cu(e.logPath);let i=o?["ignore",o.fd,o.fd]:["ignore","ignore","ignore"],s=ni(e.command,e.args,{cwd:r||void 0,detached:!0,
|
|
450
|
+
env:n,stdio:i});await ku(s);let a=e.execution?.id||"";return a&&(we.set(a,{child:s,pid:Number(s.pid)}),Ru(Number(s.pid)),
|
|
451
|
+
s.once("exit",()=>{!Mt(s.pid)&&we.has(a)&&(we.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),Pu(Number(s.pid)))})),s.unref(),
|
|
452
|
+
rt({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return L(i?.message||
|
|
442
453
|
"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{await o?.
|
|
443
|
-
close().catch(()=>null)}}function
|
|
444
|
-
"win32"){let r=[...
|
|
445
|
-
kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function
|
|
446
|
-
"win32"?[...
|
|
447
|
-
"ESRCH")return!1;throw r}}async function
|
|
448
|
-
r)||r<=0)return[];let n=[];for(let o of await
|
|
449
|
-
let i=await
|
|
450
|
-
r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}return n}async function
|
|
451
|
-
now()+Math.max(0,Number(t)||0);for(;
|
|
452
|
-
let{killTimeoutMs:r=
|
|
453
|
-
r)),o}var
|
|
454
|
-
outputEncoding:u="utf8",signal:l=null,timeout:
|
|
455
|
-
if(l?.aborted)return L("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let
|
|
456
|
-
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:
|
|
457
|
-
N=
|
|
458
|
-
i.id,
|
|
459
|
-
|
|
460
|
-
re_timed_out":
|
|
461
|
-
|
|
462
|
-
d=L(
|
|
463
|
-
if(!await(f||
|
|
464
|
-
"The command finished",
|
|
465
|
-
`${P}, and its execution scope did not become empty${
|
|
466
|
-
outputEncoding:u,signal:d?.signal,stderr:d?.stderr,stdout:d?.stdout,timedOut:d?.timedOut}),remainingProcesses:
|
|
467
|
-
|
|
468
|
-
execution:
|
|
469
|
-
for("vibe64.hostProfile"),
|
|
470
|
-
cHelperPath"],
|
|
471
|
-
|
|
472
|
-
function
|
|
473
|
-
throw new TypeError(`Unknown host profile setting: ${t.join(", ")}.`);let r={...
|
|
474
|
-
"string"||r[o]&&!
|
|
454
|
+
close().catch(()=>null)}}function Mt(e=null){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;if(process.platform===
|
|
455
|
+
"win32"){let r=[...we.values()].find(n=>n.pid===t);return r?.child?.exitCode===null&&r?.child?.signalCode===null}try{return process.
|
|
456
|
+
kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function ti(e=null,t="SIGTERM"){if(!Mt(e))return!1;try{return process.platform===
|
|
457
|
+
"win32"?[...we.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),!0}catch(r){if(r?.code===
|
|
458
|
+
"ESRCH")return!1;throw r}}async function ii(e=null,t=10){let r=Number(e);if(process.platform!=="linux"||!Number.isSafeInteger(
|
|
459
|
+
r)||r<=0)return[];let n=[];for(let o of await Eu("/proc").catch(()=>[])){if(n.length>=t)break;if(!/^\d+$/u.test(o))continue;
|
|
460
|
+
let i=await vu(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(s+2).split(" ");Number(a[2])!==
|
|
461
|
+
r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}return n}async function ri(e=null,t=0){let r=Date.
|
|
462
|
+
now()+Math.max(0,Number(t)||0);for(;Mt(e)&&Date.now()<r;)await new Promise(n=>setTimeout(n,25));return!Mt(e)}async function Lt(e=null,t={}){
|
|
463
|
+
let{killTimeoutMs:r=Au,termTimeoutMs:n=Ou}=t;ti(e,"SIGTERM");let o=await ri(e,n);return o||(ti(e,"SIGKILL"),o=await ri(e,
|
|
464
|
+
r)),o}var si=new Map;async function be(e="",t=[],r={}){let{cwd:n="",env:o={},execution:i=null,input:s=void 0,maxBuffer:a=void 0,onOutput:c=null,
|
|
465
|
+
outputEncoding:u="utf8",signal:l=null,timeout:p=15e3}=r,d,m,f,g=null,y=Promise.withResolvers(),_=()=>{f||=m(),f.then(y.resolve)};
|
|
466
|
+
if(l?.aborted)return L("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let I=ei(e,t,{cwd:n,env:o,input:s,
|
|
467
|
+
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:p});g=Number(I.pid);let P;m=()=>{if(!P){let N;process.platform!=="win32"?
|
|
468
|
+
N=Lt(g).catch(()=>!1):(I.kill("SIGKILL"),N=I.completion.then(()=>!0)),P=N.then(J=>(J||(P=null),J))}return P},i?.id&&si.set(
|
|
469
|
+
i.id,m),l?.addEventListener("abort",_,{once:!0}),l?.aborted&&_();let T=await Promise.race([I.completion,y.promise.then(N=>N?
|
|
470
|
+
I.completion:{exitCode:1})]),C=typeof T.exitCode=="number"?T.exitCode:1;d=rt({code:T.timedOut===!0?"vibe64_command_captu\
|
|
471
|
+
re_timed_out":T.code?"vibe64_command_capture_failed":"",error:C===0?"":T.shortMessage,exitCode:C,output:T.all||(C===0?"":
|
|
472
|
+
T.shortMessage),outputEncoding:u,signal:T.signal,stderr:T.stderr,stdout:T.stdout,timedOut:T.timedOut===!0,execution:i})}catch(I){
|
|
473
|
+
d=L(I.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{l?.removeEventListener("abort",_)}
|
|
474
|
+
if(!await(f||m?.()||!0)){let I=await ii(g),P=d?.timedOut?"The command timed out":l?.aborted?"The command was cancelled":
|
|
475
|
+
"The command finished",T=I.length?`: ${I.map(C=>`${C.command} (pid ${C.pid})`).join(", ")} still running`:"";return{...L(
|
|
476
|
+
`${P}, and its execution scope did not become empty${T}.`,"vibe64_execution_drain_failed",{execution:i,output:d?.output,
|
|
477
|
+
outputEncoding:u,signal:d?.signal,stderr:d?.stderr,stdout:d?.stdout,timedOut:d?.timedOut}),remainingProcesses:I}}i?.id&&
|
|
478
|
+
si.delete(i.id);let A=i&&{...i,state:"finished"};return l?.aborted?L("Command cancelled.","vibe64_command_cancelled",{...d,
|
|
479
|
+
execution:A,outputEncoding:u}):A?{...d,execution:A}:d}import Nu from"node:path";import ai from"node:process";import{isMainThread as xu}from"node:worker_threads";var Qr=Symbol.
|
|
480
|
+
for("vibe64.hostProfile"),nt=Symbol.for("vibe64.hostProfile.previousUmask"),$u=["runtimePackRoot","sharedCacheRoot","exe\
|
|
481
|
+
cHelperPath"],jt=Object.freeze({runtimePackRoot:"",sharedCacheRoot:"",execHelperPath:"",sharedGroupAccess:!1});function ci(e){
|
|
482
|
+
xu&&(e&&!(nt in globalThis)?globalThis[nt]=ai.umask(7):!e&&nt in globalThis&&(ai.umask(globalThis[nt]),delete globalThis[nt]))}
|
|
483
|
+
function Zr(e=null){if(e===null)return delete globalThis[Qr],ci(!1),jt;let t=Object.keys(e).filter(o=>!(o in jt));if(t.length)
|
|
484
|
+
throw new TypeError(`Unknown host profile setting: ${t.join(", ")}.`);let r={...jt,...e};for(let o of $u)if(typeof r[o]!=
|
|
485
|
+
"string"||r[o]&&!Nu.isAbsolute(r[o]))throw new TypeError(`Host profile ${o} must be an absolute path or empty.`);if(typeof r.
|
|
475
486
|
sharedGroupAccess!="boolean")throw new TypeError("Host profile sharedGroupAccess must be true or false.");let n=Object.freeze(
|
|
476
|
-
r);return globalThis[
|
|
487
|
+
r);return globalThis[Qr]=n,ci(n.sharedGroupAccess),n}function Q(){return globalThis[Qr]||jt}var Mu="vibe64.exec-helper.payload",Lu=1;function en(e=""){let t=String(e||"").trim()||Q().execHelperPath;if(!t){let r=new Error(
|
|
477
488
|
"This computer has no helper for running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}
|
|
478
|
-
function
|
|
479
|
-
operation:i="vibe64-command",args:s=[]}={}){return
|
|
489
|
+
function ui(e={}){return{...e,schema:Mu,schemaVersion:Lu}}function Dt({actor:e={},command:t="",cwd:r="",env:n={},input:o,
|
|
490
|
+
operation:i="vibe64-command",args:s=[]}={}){return ui({args:Array.isArray(s)?s.map(a=>String(a)):[],command:t,cwd:r,env:n,
|
|
480
491
|
gid:e.user?.gid,home:e.user?.home,inputBase64:o==null?"":Buffer.isBuffer(o)?o.toString("base64"):Buffer.from(String(o)).
|
|
481
|
-
toString("base64"),operation:i,uid:e.user?.uid,username:e.user?.username})}function
|
|
492
|
+
toString("base64"),operation:i,uid:e.user?.uid,username:e.user?.username})}function ot(e={}){return e.mode==="pty"&&e.envPolicy===
|
|
482
493
|
"auth"&&!["assistant","codex"].includes(e.purpose)?"account-auth-terminal":e.purpose==="codex"&&e.mode==="capture"&&e.envPolicy===
|
|
483
494
|
"auth"||e.purpose==="codex"&&e.mode==="detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"?"c\
|
|
484
495
|
odex-app-server":e.mode==="detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"&&["opencode-ca\
|
|
485
496
|
talog","opencode-server"].includes(e.execution?.operationId)||e.mode==="capture"&&e.execution?.kind==="assistant"&&e.execution?.
|
|
486
497
|
operationId==="opencode-catalog"?"opencode-app-server":e.purpose==="account"?"account-status":e.purpose==="github"?"gith\
|
|
487
498
|
ub-workflow-command":e.purpose==="github-api"?"github-api-command":e.purpose==="workspace-cache"?"workspace-cache-comman\
|
|
488
|
-
d":e.purpose==="health"?"health-status":"vibe64-command"}async function
|
|
489
|
-
outputEncoding:o="utf8",runCapture:i=
|
|
499
|
+
d":e.purpose==="health"?"health-status":"vibe64-command"}async function tn(e={},{env:t,helperPath:r="",maxBuffer:n=void 0,
|
|
500
|
+
outputEncoding:o="utf8",runCapture:i=be,signal:s=null,timeout:a=15e3}){let c={env:t,input:`${JSON.stringify(e)}
|
|
490
501
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
491
|
-
udo",["-n",
|
|
492
|
-
in",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
493
|
-
versionName:"1.0.0"});var
|
|
494
|
-
"metadata","migrations","runtime","vite"]);import
|
|
495
|
-
session?.metadata?.session_git_command_actor_user_key)}async function
|
|
496
|
-
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await
|
|
497
|
-
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:
|
|
502
|
+
udo",["-n",en(r),"execute"],c)}import{createRequire as Du}from"node:module";var ju=new URL("./../../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var Xh=Du(ju);var ng=Object.freeze(["bundled","dev_server"]),og=Object.freeze(["capacitor"]),ig=Object.freeze({callbackPath:"/auth/log\
|
|
503
|
+
in",customScheme:"",appLinkDomains:Object.freeze([])}),sg=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
|
|
504
|
+
versionName:"1.0.0"});var Ig=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Rg=Object.freeze(["capabilities","kind",
|
|
505
|
+
"metadata","migrations","runtime","vite"]);import Vu from"node:path";var Gu="jskit-client-build",xg=new RegExp(`<meta name="${Gu}" content="([0-9a-f]+)"`,"u");var Ug=Vu.join("dist","index.html");function Fu(e={}){return ne(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
506
|
+
session?.metadata?.session_git_command_actor_user_key)}async function li(e={}){let t=E(e.actor)||"daemon";if(t==="app"&&
|
|
507
|
+
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await Jr(e.applicationAccount)};
|
|
508
|
+
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:Kr()};let r=Fu(e);if(!r){let n=new Error(
|
|
498
509
|
"A user key is required for real-user command execution.");throw n.code="vibe64_command_actor_user_required",n}return{actor:t,
|
|
499
|
-
credentialScope:"user",requiresRealUser:!0,user:await
|
|
500
|
-
execHelperPath}function
|
|
501
|
-
return;let n=v(t.session?.sourceRoot||t.session?.sourcePath),o=v(r);if(!n||!o||!
|
|
510
|
+
credentialScope:"user",requiresRealUser:!0,user:await Jr(r)}}import $l from"node:path";import di from"node:path";function je(e={}){let t=Ko();return t.uid===null||t.gid===null||t.uid===e.user?.uid&&t.gid===e.user?.gid}function rn(){return!!Q().
|
|
511
|
+
execHelperPath}function Ut(e={}){return e.requiresRealUser?rn()||!je(e):!1}function pi(e={},t={},r=""){if(!e.requiresRealUser)
|
|
512
|
+
return;let n=v(t.session?.sourceRoot||t.session?.sourcePath),o=v(r);if(!n||!o||!se(n,o))return;let i=new Error("Commands\
|
|
502
513
|
in a session's source must run as the editor's own user, not as a person's account.");throw i.code="vibe64_command_mana\
|
|
503
|
-
ged_source_real_user_forbidden",i}function
|
|
504
|
-
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&
|
|
505
|
-
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var
|
|
514
|
+
ged_source_real_user_forbidden",i}function mi(e={},t={}){let r=v(e.user?.home),n=v(t.HOME),o=v(t.VIBE64_CREDENTIAL_HOME);
|
|
515
|
+
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&di.resolve(r)!==di.resolve(n)){let i=new Error("Command HOME does not match t\
|
|
516
|
+
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var it=Object.freeze(["DATABASE_URL","DB_CLIENT","DB_DATABASE","DB_HOST","DB_NAME","DB_PASSWORD","DB_PORT","DB_USER","DB\
|
|
506
517
|
_USERNAME","MYSQL_DATABASE","MYSQL_HOST","MYSQL_PWD","MYSQL_TCP_PORT","PGDATABASE","PGHOST","PGPASSWORD","PGPORT","PGUSE\
|
|
507
|
-
R","VIBE64_MYSQL_USER"]);function
|
|
508
|
-
return t}import{spawn as
|
|
509
|
-
import{stat as
|
|
510
|
-
d",
|
|
518
|
+
R","VIBE64_MYSQL_USER"]);function Bt(...e){let t={};for(let r of e){let n=W(r);for(let o of it)n[o]!==void 0&&(t[o]=n[o])}
|
|
519
|
+
return t}import{spawn as Wu,spawnSync as qu}from"node:child_process";import{createHash as Yu}from"node:crypto";import{statSync as wi}from"node:fs";
|
|
520
|
+
import{stat as bi}from"node:fs/promises";import Gt from"node:path";var ve="GIT_AUTHOR_NAME",Se="GIT_AUTHOR_EMAIL",Te="GIT_COMMITTER_NAME",Oe="GIT_COMMITTER_EMAIL",nn=".users.vibe64.invali\
|
|
521
|
+
d",Ku=2e3,Ei=["config","--get-regexp","^user\\.(name|email)$"],vi=3e4,Ju=['git config --global user.name "Your Name"','g\
|
|
511
522
|
it config --global user.email "you@example.com"'].join(`
|
|
512
|
-
`);function
|
|
513
|
-
t}function
|
|
523
|
+
`);function fi(e="",t="vibe64"){return E(e).toLowerCase().replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||
|
|
524
|
+
t}function Xu(...e){for(let t of e){let r=M(t),n=M(r.user),o=ne(r.name,r.userName,r.user_name,r.gitUserName,r.git_user_name,
|
|
514
525
|
n.name,n.userName,n.user_name),i=ne(r.email,r.userEmail,r.user_email,r.gitUserEmail,r.git_user_email,n.email,n.userEmail,
|
|
515
526
|
n.user_email);if(o&&i)return{authorEmail:i,authorName:o,committerEmail:i,committerName:o,source:"configured"}}return null}
|
|
516
|
-
function
|
|
517
|
-
!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"github"}}function
|
|
518
|
-
let r=
|
|
519
|
-
64@${n}${
|
|
520
|
-
let t=
|
|
521
|
-
t).then(r=>r.isDirectory(),()=>!1)?t:""}function
|
|
522
|
-
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=
|
|
523
|
-
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:
|
|
524
|
-
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?
|
|
525
|
-
null}}function
|
|
527
|
+
function Qu(e={}){let t=M(e),r=ne(t.name,t.displayName,t.login,t.username),n=ne(t.email,t.publicEmail,t.verifiedEmail);return!r||
|
|
528
|
+
!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"github"}}function Zu({workspace:e="",userKey:t=""}={}){
|
|
529
|
+
let r=fi(t,"user"),n=fi(e,"local");return{authorEmail:`${r}@${n}${nn}`,authorName:`${r} via Vibe64`,committerEmail:`vibe\
|
|
530
|
+
64@${n}${nn}`,committerName:"Vibe64",source:"fallback"}}function on(e=""){let t=E(e);return t&&Gt.isAbsolute(t)?t:""}function hi(e=""){
|
|
531
|
+
let t=on(e);try{return t&&wi(t).isDirectory()?t:""}catch{return""}}async function gi(e=""){let t=on(e);return t&&await bi(
|
|
532
|
+
t).then(r=>r.isDirectory(),()=>!1)?t:""}function Si(e=""){let t={};for(let r of String(e||"").split(`
|
|
533
|
+
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=E(n[2]))}return t}function Ti(e,t){return{
|
|
534
|
+
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:Ku}}function _i(e,t){let r=qu("git",Ei,{...Ti(e,t),encoding:"\
|
|
535
|
+
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?Si(r.stdout):
|
|
536
|
+
null}}function yi(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=Wu("git",Ei,Ti(e,t));s.stdout.setEncoding(
|
|
526
537
|
"utf8"),s.stdout.on("data",a=>{n+=a}),s.once("error",()=>i({transient:!0,values:null})),s.once("close",(a,c)=>i(c?{transient:!0,
|
|
527
|
-
values:null}:{transient:!1,values:a===0||a===1?
|
|
528
|
-
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function
|
|
529
|
-
env.PATH||e.PATH}}function
|
|
530
|
-
e.HOME),r=
|
|
531
|
-
g"):""].filter(Boolean)}async function
|
|
532
|
-
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function
|
|
533
|
-
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}var
|
|
534
|
-
entries(r).sort(([o],[i])=>o<i?-1:o>i?1:0);return
|
|
535
|
-
let n=e?await
|
|
536
|
-
values}}function
|
|
537
|
-
transient),values:o.values}}function
|
|
538
|
-
i.expiresAt<=r&&
|
|
539
|
-
if(s)return(await s.read).values;let a={expiresAt:i+
|
|
540
|
-
transient?
|
|
541
|
-
s=
|
|
542
|
-
read:Promise.resolve(a),revision:o,values:a.values}),a.values}async function
|
|
543
|
-
"object")return null;let[r,n]=await Promise.all([
|
|
544
|
-
env:t=null}={}){return!t||typeof t!="object"?null:
|
|
545
|
-
n=
|
|
546
|
-
return
|
|
547
|
-
metadata);return
|
|
548
|
-
|
|
549
|
-
n.githubUser||i.github_user)||
|
|
550
|
-
user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.LOGNAME)})}async function
|
|
551
|
-
e)||await
|
|
552
|
-
authorEmail,[
|
|
553
|
-
return
|
|
538
|
+
values:null}:{transient:!1,values:a===0||a===1?Si(n):null}))})}function Oi(e=null){return!e?.name||!e?.email?null:{authorEmail:e.
|
|
539
|
+
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function Ai(e={}){return{...e,PATH:process.
|
|
540
|
+
env.PATH||e.PATH}}function Ii(e={}){if(Object.hasOwn(e,"GIT_CONFIG_GLOBAL"))return[String(e.GIT_CONFIG_GLOBAL)];let t=on(
|
|
541
|
+
e.HOME),r=E(e.XDG_CONFIG_HOME)||(t?Gt.join(t,".config"):"");return[r?Gt.join(r,"git","config"):"",t?Gt.join(t,".gitconfi\
|
|
542
|
+
g"):""].filter(Boolean)}async function el(e={}){return(await Promise.all(Ii(e).map(r=>bi(r).then(n=>`${n.ino}:${n.size}:${n.
|
|
543
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function tl(e={}){return Ii(e).map(t=>{try{let r=wi(t);return`${r.ino}\
|
|
544
|
+
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}var Ee=new Map;function Ri(e,t,r){let n=Object.
|
|
545
|
+
entries(r).sort(([o],[i])=>o<i?-1:o>i?1:0);return Yu("sha256").update(JSON.stringify([e,t,n])).digest("hex")}async function rl(e,t,r){
|
|
546
|
+
let n=e?await yi(e,r):null;if(n?.values)return n;let o=await yi(t,r);return{transient:!!(n?.transient||o.transient),values:o.
|
|
547
|
+
values}}function nl(e,t,r){let n=e?_i(e,r):null;if(n?.values)return n;let o=_i(t,r);return{transient:!!(n?.transient||o.
|
|
548
|
+
transient),values:o.values}}function Pi(e,t,r){let n=Ee.get(e);if(n&&n.revision===t&&n.expiresAt>r)return n;for(let[o,i]of Ee)
|
|
549
|
+
i.expiresAt<=r&&Ee.delete(o);return null}async function ol(e,t,r){let n=Ri(e,t,r),o=await el(r),i=Date.now(),s=Pi(n,o,i);
|
|
550
|
+
if(s)return(await s.read).values;let a={expiresAt:i+vi,read:rl(e,t,r),revision:o};Ee.set(n,a);let c=await a.read;return c.
|
|
551
|
+
transient?Ee.get(n)===a&&Ee.delete(n):a.values=c.values,c.values}function il(e,t,r){let n=Ri(e,t,r),o=tl(r),i=Date.now(),
|
|
552
|
+
s=Pi(n,o,i);if(s&&Object.hasOwn(s,"values"))return s.values;let a=nl(e,t,r);return a.transient||Ee.set(n,{expiresAt:i+vi,
|
|
553
|
+
read:Promise.resolve(a),revision:o,values:a.values}),a.values}async function sl({cwd:e="",env:t=null}={}){if(!t||typeof t!=
|
|
554
|
+
"object")return null;let[r,n]=await Promise.all([gi(e),gi(t.HOME)]);return Oi(await ol(r,n,Ai(t)))}function al({cwd:e="",
|
|
555
|
+
env:t=null}={}){return!t||typeof t!="object"?null:Oi(il(hi(e),hi(t.HOME),Ai(t)))}function cl(e={}){let t=M(e),r=E(t.name),
|
|
556
|
+
n=E(t.email);return!r||!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function sn(e=""){
|
|
557
|
+
return E(e).toLowerCase().endsWith(nn)}function Ci({env:e,personGitIdentity:t=null,project:r={},session:n={}}){let o=M(n.
|
|
558
|
+
metadata);return Xu(r.gitIdentity,r.config?.git,n.gitIdentity,o.git_identity,{name:e.VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||
|
|
559
|
+
cl(t)}function ki({actor:e={},env:t,project:r={},session:n={},userKey:o=""}){let i=M(n.metadata);return Qu(r.githubUser||
|
|
560
|
+
n.githubUser||i.github_user)||Zu({workspace:ne(r.workspace,t.VIBE64_WORKSPACE,t.VIBE64_RUNTIME_NAMESPACE),userKey:ne(o,e.
|
|
561
|
+
user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.LOGNAME)})}async function ul(e){return Ci(
|
|
562
|
+
e)||await sl(e.gitConfig||{})||ki(e)}function ll(e){return Ci(e)||al(e.gitConfig||{})||ki(e)}function Ni(e){return{[Se]:e.
|
|
563
|
+
authorEmail,[ve]:e.authorName,[Oe]:e.committerEmail,[Te]:e.committerName}}async function xi(e){return Ni(await ul(e))}function $i(e){
|
|
564
|
+
return Ni(ll(e))}import{readFileSync as pl}from"node:fs";import Li from"node:path";import an from"node:path";var De=Object.freeze({awsebcli:{binDirs:["awsebcli/bin"],managedCommands:["eb"]},bubblewrap:{binDirs:["bubblewrap/bin"],
|
|
554
565
|
managedCommands:[]},bun:{binDirs:["bun/bin"],dependencyFiles:["package.json","bun.lock","bun.lockb","package-lock.json"],
|
|
555
566
|
managedCommands:["bun"]},composer:{binDirs:["composer/bin"],dependencyFiles:["composer.json","composer.lock"],managedCommands:[
|
|
556
567
|
"composer"]},cpp:{binDirs:["cpp/bin"],dependencyFiles:["CMakeLists.txt","vcpkg.json","vcpkg-configuration.json","conanfi\
|
|
@@ -578,325 +589,325 @@ i/claude-code/package.json","operator-clis/lib/node_modules/@openai/codex/packag
|
|
|
578
589
|
opencode-ai/package.json"],managedCommands:["claude","codex","opencode"]},php:{binDirs:["php/bin"],managedCommands:["php"]},
|
|
579
590
|
playwright:{binDirs:["playwright/bin"],identityPaths:["playwright/runtime.env","playwright/browsers"],managedCommands:["\
|
|
580
591
|
playwright"]},postgresql:{binDirs:["postgresql/bin"],managedCommands:["initdb","pg_ctl","pg_isready","postgres","psql"]},
|
|
581
|
-
ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:["sqlite3"]}}),
|
|
592
|
+
ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:["sqlite3"]}}),cn=Object.
|
|
582
593
|
freeze(["operator-clis","node26","git","gh","mysql","mariadb","postgresql","sqlite","ripgrep","bubblewrap","bun","php","\
|
|
583
|
-
composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);function
|
|
584
|
-
return v(e||
|
|
585
|
-
let e=
|
|
586
|
-
let t=
|
|
587
|
-
GHT_VERSION",
|
|
588
|
-
let t=
|
|
589
|
-
let o=n.split(/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!
|
|
590
|
-
o[0]))throw new Error(`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function
|
|
591
|
-
let t=
|
|
592
|
-
[
|
|
593
|
-
ACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIME_DIR"]),
|
|
594
|
-
for(let t of Object.keys(
|
|
595
|
-
e execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function
|
|
596
|
-
session"}=t,n=
|
|
597
|
-
{...o,...
|
|
594
|
+
composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);function j({root:e=""}={}){
|
|
595
|
+
return v(e||Q().runtimePackRoot)}function un(e=""){let t=j();return(t?De[E(e)]?.binDirs||[]:[]).map(n=>an.join(t,n))}function Mi(){
|
|
596
|
+
let e=j();return e?[an.join(e,"guard-bin")]:[]}function ln(){let e=j();return e?[an.join(e,"policy-bin")]:[]}function dl(e=""){
|
|
597
|
+
let t=E(e);return[...De[t]?.managedCommands||[]]}var P_=Object.freeze({runtimePackManagedCommands:dl});var Ht="VIBE64_SHARED_CACHE_ROOT",st="PLAYWRIGHT_BROWSERS_PATH",dn="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",pn="VIBE64_PLAYWRI\
|
|
598
|
+
GHT_VERSION",ji="playwright",ml="browsers",fl="runtime.env",hl=/^\d+\.\d+\.\d+$/u;function gl({runtimePackRoot:e=""}={}){
|
|
599
|
+
let t=j({root:e});if(!t)return"";let r=Li.join(t,ji,fl),n;try{n=pl(r,"utf8")}catch(i){if(i?.code==="ENOENT")return"";throw i}
|
|
600
|
+
let o=n.split(/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!hl.test(
|
|
601
|
+
o[0]))throw new Error(`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function Di({runtimePackRoot:e=""}={}){
|
|
602
|
+
let t=j({root:e}),r=v(Q().sharedCacheRoot),n=gl({runtimePackRoot:t});return{...r?{[Ht]:r}:{},...t?{[st]:Li.join(t,ji,ml),
|
|
603
|
+
[dn]:"1"}:{},...n?{[pn]:n}:{}}}var _l=new Set(["HOME","LOGNAME","PATH","TMPDIR","USER","VIBE64_EXECUTION_ID","VIBE64_MANAGED_EXECUTION_REQUIRED","XDG_C\
|
|
604
|
+
ACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIME_DIR"]),yl=new Set([...it,Se,ve,Oe,Te,st,dn,pn,Ht]);function Ue(e={}){
|
|
605
|
+
for(let t of Object.keys(W(e)))if(_l.has(t)||t.startsWith("XDG_")){let r=new Error(`Vibe64 command callers cannot provid\
|
|
606
|
+
e execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function Vt(e={},t={}){let{envPolicy:r="\
|
|
607
|
+
session"}=t,n=W(e);Ue(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!yl.has(i)));return r==="deployment"?o:
|
|
608
|
+
{...o,...Bt(n)}}function wl(e=""){let t=v(e);return t==="/home"||t.startsWith("/home/")}function Ui({actor:e={},request:t={}}={}){let r=t.
|
|
598
609
|
credentialHome||{},n=v(r.home);if(!n)return{};let o=v(e.user?.home);if(e.requiresRealUser&&o&&n!==o){let a=new Error("Co\
|
|
599
610
|
mmand credential home must match the resolved real-user actor home.");throw a.code="vibe64_command_credential_home_actor\
|
|
600
|
-
_mismatch",a}if(!e.requiresRealUser&&
|
|
601
|
-
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=
|
|
602
|
-
return{...
|
|
611
|
+
_mismatch",a}if(!e.requiresRealUser&&wl(n)&&o&&!se(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
612
|
+
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=E(r.username||e.user?.username);
|
|
613
|
+
return{...tt({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n}),...v(r.cacheRoot)?{XDG_CACHE_HOME:v(r.cacheRoot)}:{},...v(r.
|
|
603
614
|
configRoot)?{XDG_CONFIG_HOME:v(r.configRoot)}:{},...v(r.dataRoot)?{XDG_DATA_HOME:v(r.dataRoot)}:{},...v(r.stateRoot)?{XDG_STATE_HOME:v(
|
|
604
|
-
r.stateRoot)}:{}}}import
|
|
605
|
-
steadOf",value:"ssh://git@github.com/"}]),
|
|
606
|
-
/env gh auth git-credential"}]),
|
|
607
|
-
get) printf '%s\\n' username=x-access-token "password=\${VIBE64_GIT_AUTH_TOKEN}" ;; esac; }; f`}]);function
|
|
608
|
-
r=[];for(let n of Array.isArray(e)?e:[e]){let o=
|
|
609
|
-
add(i),r.push(i))}return r}function
|
|
610
|
-
String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?n:0;for(let i of Array.isArray(t)?t:[]){let s=
|
|
615
|
+
r.stateRoot)}:{}}}import Bi from"node:path";var bl=Object.freeze([{key:"url.https://github.com/.insteadOf",value:"git@github.com:"},{key:"url.https://github.com/.in\
|
|
616
|
+
steadOf",value:"ssh://git@github.com/"}]),El=Object.freeze([{key:"credential.https://github.com.helper",value:"!/usr/bin\
|
|
617
|
+
/env gh auth git-credential"}]),vl=Object.freeze([{key:"credential.https://github.com.helper",value:`!f() { case "$1" in\
|
|
618
|
+
get) printf '%s\\n' username=x-access-token "password=\${VIBE64_GIT_AUTH_TOKEN}" ;; esac; }; f`}]);function Sl(e=[]){let t=new Set,
|
|
619
|
+
r=[];for(let n of Array.isArray(e)?e:[e]){let o=E(n);if(!o||!Bi.isAbsolute(o))continue;let i=Bi.resolve(o);t.has(i)||(t.
|
|
620
|
+
add(i),r.push(i))}return r}function at(e={},t=[]){let r={...e&&typeof e=="object"&&!Array.isArray(e)?e:{}},n=Number.parseInt(
|
|
621
|
+
String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?n:0;for(let i of Array.isArray(t)?t:[]){let s=E(i?.key);
|
|
611
622
|
s&&(r[`GIT_CONFIG_KEY_${o}`]=s,r[`GIT_CONFIG_VALUE_${o}`]=String(i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),
|
|
612
|
-
r}function
|
|
613
|
-
return
|
|
614
|
-
0",PAGER:"cat"}}function
|
|
615
|
-
return
|
|
616
|
-
gitSafeDirectoryArgs:
|
|
617
|
-
ires a gitAuthToken.");throw t.code="vibe64_command_git_auth_token_required",t}return
|
|
618
|
-
[
|
|
619
|
-
-token"?r=
|
|
620
|
-
[])}import
|
|
621
|
-
function
|
|
622
|
-
map(
|
|
623
|
-
try{return
|
|
624
|
-
function
|
|
625
|
-
String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:
|
|
626
|
-
|
|
627
|
-
".bun/bin"].map(o=>
|
|
628
|
-
PATH),...
|
|
629
|
-
/usr/lib/postgresql/${t}/bin`),...
|
|
630
|
-
map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function
|
|
631
|
-
shimDirs:o=[]}){return
|
|
632
|
-
...
|
|
633
|
-
_RUNTIME_DIR"]),
|
|
634
|
-
!Array.isArray(e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!
|
|
635
|
-
"GIT_")&&!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function
|
|
636
|
-
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function
|
|
637
|
-
envPolicy==="deployment"?(
|
|
638
|
-
yment"?[]:t.envPolicy==="project"?
|
|
639
|
-
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=
|
|
640
|
-
t.XDG_RUNTIME_DIR||"").trim(),c={...
|
|
641
|
-
...
|
|
642
|
-
l=
|
|
643
|
-
shimDirs||[]});return{...u,PATH:l,...
|
|
623
|
+
r}function Gi(e=[]){return Sl(e).map(t=>({key:"safe.directory",value:t}))}function Hi(e={},t=[]){return at(e,Gi(t))}function Tl(e=[]){
|
|
624
|
+
return Gi(e).flatMap(t=>["-c",`${t.key}=${t.value}`])}function mn(){return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"\
|
|
625
|
+
0",PAGER:"cat"}}function fn(e={}){return at(e,bl)}function Ol(e={}){return at(e,El)}function Al(e={}){return at(e,vl)}function Vi(e={}){
|
|
626
|
+
return Ol(fn(e))}function zi(e={}){return Al(fn(e))}var q_=Object.freeze({applyGitConfigEntriesToEnv:at,githubSshToHttpsGitEnv:fn,
|
|
627
|
+
gitSafeDirectoryArgs:Tl});var Il="VIBE64_GIT_AUTH_TOKEN";function Rl(e={}){if(!e.gitAuthToken){let t=new Error("Token-backed GitHub transport requ\
|
|
628
|
+
ires a gitAuthToken.");throw t.code="vibe64_command_git_auth_token_required",t}return zi({...mn(),GIT_TERMINAL_PROMPT:"0",
|
|
629
|
+
[Il]:e.gitAuthToken})}function Fi({request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github\
|
|
630
|
+
-token"?r=Rl(e):(e.gitTransport==="github-https"||e.purpose==="github")&&(r=Vi({...t,...mn()})),Hi(r,e.gitSafeDirectories||
|
|
631
|
+
[])}import Wi from"node:path";var hn="NPM_CONFIG_PREFIX";function qi({env:e={}}={}){return j()?v(e[hn])||(v(e.HOME)?Wi.join(v(e.HOME),".local"):""):""}
|
|
632
|
+
function Yi(e={}){let t=qi(e);return t?{[hn]:t}:{}}function Ki(e={}){let t=qi(e);return t?[Wi.join(t,"bin")]:[]}import{existsSync as Pl,readdirSync as Cl}from"node:fs";import kl from"node:os";import ae from"node:path";import zt from"node:process";var ut="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";function ct(e=""){return String(e||"").split(":").
|
|
633
|
+
map(E).filter(Boolean)}function Xi(e=[]){return e.filter(t=>{try{return Pl(t)}catch{return!1}})}function Ji(e="",t=/^$/u){
|
|
634
|
+
try{return Cl(e).filter(r=>t.test(r)).sort((r,n)=>Number(/\d+/u.exec(n)?.[0]||0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}
|
|
635
|
+
function Nl(e){if(j())return[];let t=String(e.HOME||kl.homedir()||"");if(!ae.isAbsolute(t))return[];let r=ae.isAbsolute(
|
|
636
|
+
String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:ae.join(t,".local/share"),n=ae.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:
|
|
637
|
+
ae.join(r,"mise");return Xi([ae.join(t,".local/bin"),ae.join(n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",
|
|
638
|
+
".bun/bin"].map(o=>ae.join(t,o))])}function xl(){if(j())return[];let e=["/opt/homebrew","/usr/local"];return[...ct(zt.env.
|
|
639
|
+
PATH),...zt.platform==="darwin"?["/opt/homebrew/bin"]:[],...Xi([...Ji("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`\
|
|
640
|
+
/usr/lib/postgresql/${t}/bin`),...zt.platform==="darwin"?e.flatMap(t=>[...Ji(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).
|
|
641
|
+
map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function Qi({env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],
|
|
642
|
+
shimDirs:o=[]}){return ye([...ct(o.join(":")),...ln(),...n.flatMap(i=>un(i)),...Mi(),...ct(t||(r?"":e.PATH)),...Nl(zt.env),
|
|
643
|
+
...ct(r),...xl(),...ct(ut)]).join(":")}var Ml=new Set([...it,Se,ve,Oe,Te,"HOME","LOGNAME","PATH","USER","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG\
|
|
644
|
+
_RUNTIME_DIR"]),Ll=new Set(["NODE_ENV"]);function jl(e={}){return Object.fromEntries(Object.entries(e&&typeof e=="object"&&
|
|
645
|
+
!Array.isArray(e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!Ml.has(t)&&!Ll.has(t)&&!t.startsWith(
|
|
646
|
+
"GIT_")&&!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function gn(e={}){return e.envPolicy==="deployment"?[e.project?.deploymentEnv,
|
|
647
|
+
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function Dl(e={}){return gn(e).reduce((t,r)=>e.
|
|
648
|
+
envPolicy==="deployment"?(Ue(r),{...t,...W(r)}):{...t,...Vt(r,e)},{})}function Ul(e={},t={}){return t.envPolicy==="deplo\
|
|
649
|
+
yment"?[]:t.envPolicy==="project"?gn(t):[e,...gn(t),t.project?.databaseEnv,t.session?.databaseEnv]}function Zi({actor:e={},
|
|
650
|
+
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=Di(),s=Vt(n.env,n),a=String(
|
|
651
|
+
t.XDG_RUNTIME_DIR||"").trim(),c={...tt(e.user,jl(t)),...je(e)&&$l.isAbsolute(a)?{XDG_RUNTIME_DIR:a}:{},...Bt(...Ul(t,n)),
|
|
652
|
+
...Dl(n),...Fi({actor:e,request:n}),...s,...Ui({actor:e,request:n}),...i},u={...c,...Yi({env:c}),VIBE64_DECLARED_RUNTIMES:o},
|
|
653
|
+
l=Qi({env:u,existingPath:[...Ki({env:u}),u.PATH].filter(Boolean).join(":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.
|
|
654
|
+
shimDirs||[]});return{...u,PATH:l,...j()?{}:{VIBE64_TOOL_PATH:l}}}function es({actor:e={},baseEnv:t,request:r={}},n){return{
|
|
644
655
|
actor:e,env:t,gitConfig:{cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.
|
|
645
|
-
userKey}}async function
|
|
646
|
-
resolvedGitIdentityEnv
|
|
647
|
-
terminal_session_not_found",error:"Terminal session not found.",ok:!1}}function
|
|
648
|
-
"default"}var
|
|
649
|
-
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>
|
|
650
|
-
"running"||e.status==="closing"}function
|
|
651
|
-
!0}catch{return!1}}function
|
|
652
|
-
let{outputLimit:r=0}=t,n=String(e||""),o=
|
|
653
|
-
o),outputTruncated:!0}}function
|
|
656
|
+
userKey}}async function ts(e){let t=Zi(e);return{...t,...await xi(es(e,t))}}function _n(e){let t=Zi(e);return{...t,...e.
|
|
657
|
+
resolvedGitIdentityEnv||$i(es(e,t))}}import{randomUUID as id}from"node:crypto";import{mkdirSync as sd,writeFileSync as ad}from"node:fs";import An from"node:path";import Zl from"node:crypto";import{createRequire as ed}from"node:module";import{Buffer as Bl}from"node:buffer";var rs=256*1024,Gl=300,Ft=100,Wt=28;var Ay=600*1e3,Hl=1440*60*1e3,Iy=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "});function ns(){return{code:"\
|
|
658
|
+
terminal_session_not_found",error:"Terminal session not found.",ok:!1}}function ce(e=""){return String(e||"default").trim()||
|
|
659
|
+
"default"}var os=new Map;function qt(e){let t=String(e||""),r=t.length;for(let n=0;n<Gl&&(r=t.lastIndexOf(`
|
|
660
|
+
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>rs&&(t=t.slice(t.length-rs)),t}function lt(e={}){return e.status===
|
|
661
|
+
"running"||e.status==="closing"}function yn(e={}){return lt(e)||e.status==="exited"}function is(e,t){try{return t(ue(e))===
|
|
662
|
+
!0}catch{return!1}}function Vl(e=0){let t=Math.floor(Number(e||0));return Number.isFinite(t)&&t>0?t:0}function zl(e="",t={}){
|
|
663
|
+
let{outputLimit:r=0}=t,n=String(e||""),o=Vl(r);return!o||n.length<=o?{output:n,outputTruncated:!1}:{output:n.slice(n.length-
|
|
664
|
+
o),outputTruncated:!0}}function ue(e,t={}){let r=zl(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||Ft,
|
|
654
665
|
createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exitCode,inputVersion:e.inputVersion||0,lastInputAt:e.
|
|
655
666
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
656
667
|
metadata:e.metadata||{},output:r.output,outputTruncated:r.outputTruncated,outputVersion:e.outputVersion||0,rows:e.rows||
|
|
657
|
-
|
|
658
|
-
max(
|
|
659
|
-
if(e.subscribers?.size)return 0;let r=
|
|
660
|
-
(clearTimeout(e.detachedCleanupTimer),e.detachedCleanupTimer=null)}function
|
|
661
|
-
metadata:e.metadata,type:"metadata"}),
|
|
662
|
-
e.lastOutputBytes=r)}function
|
|
663
|
-
delete(r)}}function
|
|
664
|
-
function
|
|
668
|
+
Wt,status:e.status}}function ss(e=""){return Bl.byteLength(String(e||""),"utf8")}function dt(e=0){let t=Math.floor(Number(e));return!Number.isFinite(t)||t<0?0:Math.min(t,Hl)}function Fl(e={}){return Math.
|
|
669
|
+
max(Le(e.lastSubscriberDetachedAt),Le(e.lastInputAt),Le(e.lastOutputAt),Le(e.createdAt))}function wn(e={},t=Date.now()){
|
|
670
|
+
if(e.subscribers?.size)return 0;let r=Fl(e);return r>0?Math.max(0,Number(t)-r):0}function Yt(e={}){e.detachedCleanupTimer&&
|
|
671
|
+
(clearTimeout(e.detachedCleanupTimer),e.detachedCleanupTimer=null)}function as(e,t={}){return!e||!t||typeof t!="object"||Array.isArray(t)?ue(e):(e.metadata={...e.metadata||{},...t},re(e,{
|
|
672
|
+
metadata:e.metadata,type:"metadata"}),ue(e))}function cs(e,t=""){let r=ss(t);r<1||(e.outputVersion=Number(e.outputVersion||0)+1,e.lastOutputAt=new Date().toISOString(),
|
|
673
|
+
e.lastOutputBytes=r)}function re(e,t){if(e?.subscribers?.size)for(let r of[...e.subscribers])try{r(t)}catch{e.subscribers.
|
|
674
|
+
delete(r)}}function Wl(e){let t=String(e?.code||""),r=String(e?.message||e||"Terminal PTY error.");return{code:t,message:r}}
|
|
675
|
+
function us(e,t){if(!e)return;let r=Wl(t);e.lastWriteErrorAt=new Date().toISOString(),e.lastWriteErrorCode=r.code,e.lastWriteError=
|
|
665
676
|
r.message,console.warn("Vibe64 terminal PTY write error.",{code:r.code,id:e.id,metadata:e.metadata||{},message:r.message,
|
|
666
|
-
namespace:e.namespace||""}),
|
|
667
|
-
!t||typeof t.on!="function"||t.on("error",r=>{
|
|
677
|
+
namespace:e.namespace||""}),re(e,{code:r.code,error:r.message,type:"error"})}function ls(e){let t=e?.terminal?._writeStream;
|
|
678
|
+
!t||typeof t.on!="function"||t.on("error",r=>{us(e,r)})}function ds(e,t,r=t){let n=`\r
|
|
668
679
|
[studio] ${r}\r
|
|
669
|
-
`;e.closeError=t,e.output=
|
|
680
|
+
`;e.closeError=t,e.output=qt(`${e.output}${n}`),re(e,{chunk:n,type:"output"}),re(e,{error:t,type:"error"})}async function ps(e,{
|
|
670
681
|
code:t,flag:r,hook:n,label:o,payload:i}){if(e[r])return null;e[r]=!0;try{return await e[n](i),null}catch(s){let a=String(
|
|
671
|
-
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,
|
|
682
|
+
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,ds(e,a,`${o}: ${a}`),c}}function Ae(e,t){let r=`${String(
|
|
672
683
|
t?.code||"terminal_cleanup_failed")}:${String(t?.message||"")}`;return e.reportedLifecycleFailures||=new Set,e.reportedLifecycleFailures.
|
|
673
|
-
has(r)||(e.reportedLifecycleFailures.add(r),
|
|
684
|
+
has(r)||(e.reportedLifecycleFailures.add(r),ds(e,String(t?.message||t||"Terminal cleanup failed."))),t}function Kt(e,t=[]){
|
|
674
685
|
let r=new AggregateError(t,`Terminal session could not close cleanly: ${e.id}`);return r.code=t.some(n=>String(n?.code||
|
|
675
|
-
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function
|
|
676
|
-
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>
|
|
686
|
+
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function ql(e,t){
|
|
687
|
+
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>ps(e,{code:"terminal_stop_hook_failed",flag:"\
|
|
677
688
|
stopHookStarted",hook:"onStop",label:"Terminal stop failed",payload:{id:e.id,output:e.output,reason:t,status:e.status}}))),
|
|
678
|
-
e.stopHookCompletion}function
|
|
689
|
+
e.stopHookCompletion}function bn(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>ps(
|
|
679
690
|
e,{code:"terminal_close_hook_failed",flag:"closeHookStarted",hook:"onClose",label:"Terminal finalization failed",payload:{
|
|
680
|
-
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function
|
|
681
|
-
"exited"&&(e.status="exited",
|
|
682
|
-
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await
|
|
691
|
+
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function En(e){e.status!==
|
|
692
|
+
"exited"&&(e.status="exited",re(e,{closeError:e.closeError||"",exitCode:e.exitCode,status:e.status,type:"status"}))}function vn(e){
|
|
693
|
+
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await Lt(e.terminal.pid)){
|
|
683
694
|
let t=new Error(`Terminal execution scope did not become empty: ${e.id}`);throw t.code="terminal_execution_drain_failed",
|
|
684
|
-
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function
|
|
685
|
-
|
|
695
|
+
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function ms(e){try{await e.scopeDrainCompletion}catch(t){
|
|
696
|
+
Ae(e,t)}try{await Promise.all([bn(e,e.stopReason||"exit"),e.stopHookCompletion])}catch(t){Ae(e,t)}En(e)}async function Sn(e,t="\
|
|
686
697
|
stop"){if(!e||e.processExited)return{failures:[]};e.stopReason||=String(t||"stop"),e.status==="running"&&(e.status="clos\
|
|
687
|
-
ing",
|
|
698
|
+
ing",re(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(ql(e,e.stopReason),!e.processExited&&!e.killStarted){
|
|
688
699
|
e.killStarted=!0;try{e.terminal.kill()}catch(n){e.killStarted=!1;let o=n instanceof Error?n:new Error(String(n||"Termina\
|
|
689
|
-
l process could not be killed."));o.code||="terminal_kill_failed",r.push(
|
|
690
|
-
n))}return{failures:r}}var
|
|
691
|
-
ok:!1}:null}var
|
|
692
|
-
get(t)}function
|
|
693
|
-
"");return[...
|
|
694
|
-
let n=e?[
|
|
695
|
-
return o}function
|
|
696
|
-
let n=Math.max(0,r-
|
|
697
|
-
let{namespace:r="default"}=t,n=
|
|
698
|
-
let s=[];if(
|
|
699
|
-
s.push(
|
|
700
|
-
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&
|
|
700
|
+
l process could not be killed."));o.code||="terminal_kill_failed",r.push(Ae(e,o))}}try{await vn(e)}catch(n){r.push(Ae(e,
|
|
701
|
+
n))}return{failures:r}}var Yl=new Map;function Kl(e="default"){return Yl.get(ce(e))||null}function fs(e="default"){let t=Kl(e);return t?{code:t.code,error:t.error,
|
|
702
|
+
ok:!1}:null}var Ie=new Map;function Be(e){return Ie.get(ce(e))||os}function hs(e){let t=ce(e);return Ie.has(t)||Ie.set(t,new Map),Ie.
|
|
703
|
+
get(t)}function gs(e,t,r){e.delete(r);let n=ce(t);e.size<1&&Ie.get(n)===e&&Ie.delete(n)}function Jl(e=""){let t=String(e||
|
|
704
|
+
"");return[...Ie.keys()].filter(r=>r.startsWith(t))}function Jt({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){
|
|
705
|
+
let n=e?[ce(e)]:Jl(t),o=[];for(let i of n){let s=Be(i);for(let a of s.values())r&&!lt(a)||o.push({namespace:i,session:a})}
|
|
706
|
+
return o}function Xt(e={},t="default"){if(Yt(e),!yn(e)||e.subscribers?.size)return;let r=dt(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
707
|
+
let n=Math.max(0,r-wn(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,Xl({namespace:t})},n)}async function Tn(e,t={}){
|
|
708
|
+
let{namespace:r="default"}=t,n=Be(r),o=n.get(e);if(!o)return{ok:!0,closed:!1};if(o.closePromise)return o.closePromise;let i=(async()=>{
|
|
709
|
+
let s=[];if(Yt(o),!o.processExited){let u=await Sn(o,"close");if(u.failures.length)throw Kt(o,u.failures)}try{await o.exitCompletion}catch(u){
|
|
710
|
+
s.push(Ae(o,u))}try{await o.scopeDrainCompletion}catch(u){s.push(Ae(o,u))}let c=(await Promise.all([o.stopHookCompletion,
|
|
711
|
+
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&En(o),s.length>0)throw Kt(o,[...s,...c]);return gs(n,r,e),{
|
|
701
712
|
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(u=>String(u?.message||u))}:{}}})();o.closePromise=i;try{return await i}finally{
|
|
702
|
-
o.closePromise===i&&(o.closePromise=null)}}async function
|
|
703
|
-
let n=
|
|
704
|
-
function
|
|
705
|
-
fault",namespaceLimitPrefix:c="",runningLimitFilter:u=
|
|
706
|
-
let g=
|
|
707
|
-
|
|
708
|
-
terminal_limit",error:`Terminal limit reached (${
|
|
709
|
-
function"?e({env:
|
|
710
|
-
n"?s({args:C,env:
|
|
711
|
-
|
|
712
|
-
toISOString(),cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:
|
|
713
|
-
lastSubscriberDetachedAt:new Date().toISOString(),metadata:
|
|
713
|
+
o.closePromise===i&&(o.closePromise=null)}}async function Xl({namespace:e}){for(let{namespace:t,session:r}of Jt({namespace:e})){if(!yn(r)||r.subscribers?.size)continue;
|
|
714
|
+
let n=dt(r.detachedIdleTimeoutMs);if(!(n<1)){if(wn(r)<n){Xt(r,t);continue}await Tn(r.id,{namespace:t})}}}var Ql=new URL("./../../../vibe64-execution/src/server/engines/terminalSessions.js",import.meta.url).href;function On(){}
|
|
715
|
+
function td(){return!0}var rd=ed(Ql);function nd({filter:e,namespacePrefix:t}){return Jt({namespacePrefix:t,runningOnly:!0}).filter(r=>is(r.session,e)).length}function _s({args:e,command:t,commandPreview:r,cwd:n=process.cwd(),env:o={},maxRunning:i=0,metadata:s={},namespace:a="de\
|
|
716
|
+
fault",namespaceLimitPrefix:c="",runningLimitFilter:u=td,onClose:l=On,onOutput:p=On,onStop:d=On,reuseRunning:m=!1,detachedIdleTimeoutMs:f=0}){
|
|
717
|
+
let g=fs(a);if(g)return g;let y=Be(a),_=Zl.randomUUID(),S=typeof m=="function"?m:()=>!!m,A=m?[...y.values()].find(z=>lt(
|
|
718
|
+
z)&&S(z)):null;if(A)return ue(A);let I=Number(i||0),P=c||a;if(I>0&&nd({filter:u,namespacePrefix:P})>=I)return{ok:!1,code:"\
|
|
719
|
+
terminal_limit",error:`Terminal limit reached (${I}).`};let T=typeof o=="function"?o({id:_,namespace:a}):o,C=typeof e=="\
|
|
720
|
+
function"?e({env:T,id:_,namespace:a}):e,N=typeof r=="function"?r({args:C,env:T,id:_,namespace:a}):r,J=typeof s=="functio\
|
|
721
|
+
n"?s({args:C,env:T,id:_,namespace:a}):s,_r=rd("node-pty").spawn(t,C,{cols:Ft,cwd:n,env:M(T),name:"xterm-color",rows:Wt}),
|
|
722
|
+
Xn,Ba=new Promise(z=>{Xn=z}),k={id:_,closeHookCompletion:null,closePromise:null,commandPreview:N,cols:Ft,createdAt:new Date().
|
|
723
|
+
toISOString(),cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:dt(f),exitCompletion:Ba,exitCode:null,lastSubscriberAttachedAt:"",
|
|
724
|
+
lastSubscriberDetachedAt:new Date().toISOString(),metadata:J&&typeof J=="object"&&!Array.isArray(J)?J:{},onClose:l,onStop:d,
|
|
714
725
|
inputVersion:0,lastInputAt:"",lastInputBytes:0,lastOutputAt:"",lastOutputBytes:0,lastWriteError:"",lastWriteErrorAt:"",lastWriteErrorCode:"",
|
|
715
|
-
output:"",outputVersion:0,processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:
|
|
716
|
-
status:"running",stopHookCompletion:null,scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:
|
|
717
|
-
k),
|
|
718
|
-
type:"output"});try{
|
|
719
|
-
|
|
720
|
-
!0,k.exitCode=
|
|
721
|
-
|
|
722
|
-
r).get(e);return i?
|
|
723
|
-
is required for real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=
|
|
724
|
-
|
|
725
|
-
.json`)}function
|
|
726
|
-
let u=
|
|
727
|
-
env:typeof a=="function"?a(c):a,input:e.input,operation:
|
|
728
|
-
`,{mode:384}),["-n",
|
|
729
|
-
command:e.command,cwd:n,env:a}}async function
|
|
730
|
-
{},{onClose:a=
|
|
726
|
+
output:"",outputVersion:0,processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:Xn,rows:Wt,
|
|
727
|
+
status:"running",stopHookCompletion:null,scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:_r};return ls(
|
|
728
|
+
k),_r.onData(z=>{cs(k,z),k.output=qt(k.output+z),re(k,{chunk:z,lastOutputAt:k.lastOutputAt,outputVersion:k.outputVersion,
|
|
729
|
+
type:"output"});try{p({chunk:z,output:k.output,session:ue(k),updateMetadata(bt){return as(k,bt)}})}catch(bt){let Ga=String(
|
|
730
|
+
bt?.message||bt||"Terminal output hook failed.");re(k,{error:Ga,type:"error"})}Xt(k,a)}),_r.onExit(({exitCode:z})=>{k.processExited=
|
|
731
|
+
!0,k.exitCode=z,k.status="closing",vn(k),re(k,{exitCode:z,status:k.status,type:"status"}),bn(k,k.stopReason||"exit"),k.resolveExitCompletion(),
|
|
732
|
+
ms(k)}),hs(a).set(_,k),Xt(k,a),od(_,{namespace:a})}function od(e,t={}){let{namespace:r="default",outputLimit:n=0}=t,i=Be(
|
|
733
|
+
r).get(e);return i?ue(i,{outputLimit:n}):ns()}function cd(){}var ys=new Map;function ud(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root\
|
|
734
|
+
is required for real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=An.join(
|
|
735
|
+
An.resolve(t),"exec-helper-payloads");return sd(r,{mode:448,recursive:!0}),An.join(r,`${process.pid}-${Date.now()}-${id()}\
|
|
736
|
+
.json`)}function ld(e,t){let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return Ut(r)?{args:(c={})=>{
|
|
737
|
+
let u=ud(s.helperPayloadRoot),l=typeof e.args=="function"?e.args(c):e.args,p=Dt({actor:r,args:l,command:e.command,cwd:n,
|
|
738
|
+
env:typeof a=="function"?a(c):a,input:e.input,operation:ot(e)});return ad(u,`${JSON.stringify(p)}
|
|
739
|
+
`,{mode:384}),["-n",en(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||ut}}:{args:e.args,
|
|
740
|
+
command:e.command,cwd:n,env:a}}async function ws(e={},t={}){let{actor:r,cwd:n,env:o,resolveEnv:i}=t;try{let s=e.terminal||
|
|
741
|
+
{},{onClose:a=cd}=s,c=e.execution?.id||"",u=ld(e,{actor:r,cwd:n,env:o,resolveEnv:i}),l=_s({args:u.args,command:u.command,
|
|
731
742
|
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
732
|
-
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async
|
|
733
|
-
c&&
|
|
734
|
-
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&
|
|
743
|
+
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async p=>{try{await a(p)}finally{
|
|
744
|
+
c&&ys.set(c,{id:p.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
745
|
+
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&ys.set(c,{id:l.id,namespace:s.namespace}),l?.ok===!0?{...l,
|
|
735
746
|
execution:e.execution}:l}catch(s){return L(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
736
|
-
{execution:e.execution})}}import{realpathSync as
|
|
737
|
-
isArray(r)?r:[r]).map(v).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>
|
|
738
|
-
let c=
|
|
739
|
-
code="vibe64_command_cwd_outside_allowed_roots",a}import{randomUUID as
|
|
747
|
+
{execution:e.execution})}}import{realpathSync as bs}from"node:fs";function dd(e=""){return v(e||process.cwd())}function Es(e="",t={}){let{allowedRoots:r=[],resolveLinks:n=!0}=t,o=dd(e),i=(Array.
|
|
748
|
+
isArray(r)?r:[r]).map(v).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>se(c,o));if(s.length>0){if(!n)return o;
|
|
749
|
+
let c=bs(o);if(s.some(u=>se(bs(u),c)))return c}let a=new Error("Vibe64 command cwd is outside the allowed roots.");throw a.
|
|
750
|
+
code="vibe64_command_cwd_outside_allowed_roots",a}import{randomUUID as pd}from"node:crypto";var md=Object.freeze(["daemon","owner-user","named-user","app"]),fd=/^[a-z_][a-z0-9_-]{0,31}$/u,hd=Object.freeze(["accou\
|
|
740
751
|
nt","assistant","terminal","codex","github","github-api","source-editor","preview","output","deployment","health","works\
|
|
741
|
-
pace-cache","source"]),
|
|
742
|
-
["session","project","preview","auth","deployment"]),
|
|
743
|
-
freeze(["assistant","browser","control","job","preview","service","terminal"]),
|
|
744
|
-
"service"]),
|
|
745
|
-
vibe64_command_request_invalid"){let r=new Error(e||"Invalid Vibe64 command request.");return r.code=t,r}function
|
|
746
|
-
value"){let o=
|
|
747
|
-
_unsupported`);return o}function
|
|
752
|
+
pace-cache","source"]),gd=Object.freeze(["capture","pty","detached"]),_d=Object.freeze(["utf8","base64"]),yd=Object.freeze(
|
|
753
|
+
["session","project","preview","auth","deployment"]),wd=Object.freeze(["none","github-https","github-token"]),bd=Object.
|
|
754
|
+
freeze(["assistant","browser","control","job","preview","service","terminal"]),Ed=Object.freeze(["finite","interactive",
|
|
755
|
+
"service"]),vd=1e3*1e3*100,Sd=new Set(["assistant","codex","deployment","output","preview","source","terminal"]);function B(e="",t="\
|
|
756
|
+
vibe64_command_request_invalid"){let r=new Error(e||"Invalid Vibe64 command request.");return r.code=t,r}function le(e="",t=[],r="",n="\
|
|
757
|
+
value"){let o=E(e)||r;if(!t.includes(o))throw B(`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}\
|
|
758
|
+
_unsupported`);return o}function Td(e=[],t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw B("Fu\
|
|
748
759
|
nction-valued command args are only supported for PTY commands.","vibe64_command_args_function_requires_pty");return e}return(Array.
|
|
749
|
-
isArray(e)?e:[e]).map(n=>String(n??""))}function
|
|
750
|
-
pty")throw
|
|
751
|
-
return{env:{},envFactory:e}}let n=
|
|
752
|
-
[e]).map(v).filter(Boolean)}function
|
|
753
|
-
detachedIdleTimeoutMs,helperPayloadRoot:v(t.helperPayloadRoot),maxRunning:t.maxRunning,metadata:t.metadata,namespace:
|
|
754
|
-
namespace),namespaceLimitPrefix:
|
|
755
|
-
reuseRunning,runningLimitFilter:t.runningLimitFilter}}function
|
|
760
|
+
isArray(e)?e:[e]).map(n=>String(n??""))}function Od(e={},t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="\
|
|
761
|
+
pty")throw B("Function-valued command env is only supported for PTY commands.","vibe64_command_env_function_requires_pty");
|
|
762
|
+
return{env:{},envFactory:e}}let n=W(e);return Ue(n),{env:n,envFactory:null}}function In(e=[]){return(Array.isArray(e)?e:
|
|
763
|
+
[e]).map(v).filter(Boolean)}function Ad(e={}){let t=M(e);return{commandPreview:t.commandPreview,detachedIdleTimeoutMs:t.
|
|
764
|
+
detachedIdleTimeoutMs,helperPayloadRoot:v(t.helperPayloadRoot),maxRunning:t.maxRunning,metadata:t.metadata,namespace:E(t.
|
|
765
|
+
namespace),namespaceLimitPrefix:E(t.namespaceLimitPrefix),onClose:t.onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.
|
|
766
|
+
reuseRunning,runningLimitFilter:t.runningLimitFilter}}function Id(e={}){let t=M(e),r=v(t.home||t.toolHomeSource);return r?
|
|
756
767
|
{cacheRoot:v(t.cacheRoot),configRoot:v(t.configRoot),dataRoot:v(t.dataRoot),gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?
|
|
757
|
-
Number(t.gid??t.hostGid):null,home:r,scope:
|
|
758
|
-
hostUid))?Number(t.uid??t.hostUid):null,username:
|
|
759
|
-
"detached"?"service":e==="pty"?"interactive":"finite"}function
|
|
760
|
-
"preview"?"preview":e==="pty"?"terminal":"job"}function
|
|
761
|
-
test(t))throw
|
|
762
|
-
let{mode:r="capture",project:n={},purpose:o="terminal",session:i={}}=t,s
|
|
763
|
-
cution_kind"),c=
|
|
764
|
-
tive"||r==="capture"&&c!=="finite")throw
|
|
765
|
-
ecution_lifecycle_incompatible");let u=
|
|
768
|
+
Number(t.gid??t.hostGid):null,home:r,scope:E(t.scope),stateRoot:v(t.stateRoot),uid:Number.isSafeInteger(Number(t.uid??t.
|
|
769
|
+
hostUid))?Number(t.uid??t.hostUid):null,username:E(t.username||t.ownerUserKey||t.userKey)}:{}}function Rd(e="capture"){return e===
|
|
770
|
+
"detached"?"service":e==="pty"?"interactive":"finite"}function Pd({mode:e="capture",purpose:t="terminal"}={}){return t===
|
|
771
|
+
"preview"?"preview":e==="pty"?"terminal":"job"}function Ge(e=""){let t=E(e);if(!t)return"";if(!/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,254}[A-Za-z0-9])?$/u.
|
|
772
|
+
test(t))throw B(`Invalid Vibe64 execution identifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function Ss(e={},t={}){
|
|
773
|
+
let{mode:r="capture",project:n={},purpose:o="terminal",session:i={}}=t,s=M(e),a=le(s.kind,bd,Pd({mode:r,purpose:o}),"exe\
|
|
774
|
+
cution_kind"),c=le(s.lifecycle,Ed,Rd(r),"execution_lifecycle");if(r==="detached"&&c!=="service"||r==="pty"&&c!=="interac\
|
|
775
|
+
tive"||r==="capture"&&c!=="finite")throw B(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_ex\
|
|
776
|
+
ecution_lifecycle_incompatible");let u=Ge(s.ownerId||i.sessionId);if(c==="service"&&!u)throw B("Service execution requir\
|
|
766
777
|
es a durable owner id.","vibe64_execution_owner_required");let l=s.resourceProfile;if(l!=null&&(!l||typeof l!="object"||
|
|
767
|
-
Object.keys(l).some(
|
|
768
|
-
"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||"")||!["development","test","production"].includes(l.environment)))throw
|
|
778
|
+
Object.keys(l).some(p=>!["key","compatibilityKey","environment"].includes(p))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(l.key||
|
|
779
|
+
"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||"")||!["development","test","production"].includes(l.environment)))throw B(
|
|
769
780
|
"Invalid activity resource profile identity.","vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.
|
|
770
|
-
freeze({...l})}:{},controlGenerationId:
|
|
771
|
-
""?{}:{workflowId:
|
|
772
|
-
parentExecutionId:
|
|
773
|
-
i.sessionId)})}function
|
|
774
|
-
test(e))throw
|
|
775
|
-
return
|
|
776
|
-
e,"runtimes"),n=
|
|
777
|
-
map(
|
|
778
|
-
nd_required");let n=
|
|
779
|
-
throw
|
|
780
|
-
t.env,{mode:n}),s=
|
|
781
|
-
orted Vibe64 runtime: ${
|
|
781
|
+
freeze({...l})}:{},controlGenerationId:Ge(s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===
|
|
782
|
+
""?{}:{workflowId:Cd(s.workflowId)},id:pd(),kind:a,label:E(s.label),lifecycle:c,operationId:Ge(s.operationId),ownerId:u,
|
|
783
|
+
parentExecutionId:Ge(s.parentExecutionId),projectSlug:Ge(s.projectSlug||n.slug||n.projectSlug),sessionId:Ge(s.sessionId||
|
|
784
|
+
i.sessionId)})}function Cd(e){if(typeof e!="string"||!/^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/iu.
|
|
785
|
+
test(e))throw B("Execution requires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function kd(e=""){
|
|
786
|
+
return Sd.has(e)?cn:[]}function vs(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function Nd(e={},t=""){let r=vs(
|
|
787
|
+
e,"runtimes"),n=vs(e,"runtime");if(!r&&!n)return ye(kd(t));let o=r?e.runtimes:e.runtime;return ye((Array.isArray(o)?o:[o]).
|
|
788
|
+
map(E).filter(Boolean))}function Ts(e={}){let t=M(e),r=E(t.command);if(!r)throw B("A command is required.","vibe64_comma\
|
|
789
|
+
nd_required");let n=le(t.mode,gd,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))
|
|
790
|
+
throw B("Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=W(t.baseEnv),i=Od(
|
|
791
|
+
t.env,{mode:n}),s=le(t.purpose,hd,"terminal","purpose"),a=Nd(t,s);for(let m of a)if(!Object.hasOwn(De,m))throw B(`Unsupp\
|
|
792
|
+
orted Vibe64 runtime: ${m}.`,"vibe64_command_runtime_unsupported");let c=M(t.project),u=M(t.session),l=t.releaseEnvironmentFile??
|
|
782
793
|
"";if(typeof l!="string"||l&&(!l.startsWith("/")||/[\r\n\0]/u.test(l)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="de\
|
|
783
|
-
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw
|
|
784
|
-
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let
|
|
785
|
-
"";if(typeof
|
|
786
|
-
pp"))throw
|
|
787
|
-
ing_preload_invalid");let d=t.applicationAccount??"";if(typeof d!="string"||d&&(!
|
|
788
|
-
re"))throw
|
|
789
|
-
return{actor:
|
|
790
|
-
baseEnv:o,command:r,cwd:v(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:
|
|
791
|
-
"env_policy"),releaseEnvironmentFile:l,execution:
|
|
792
|
-
t.credentialHome),gitAuthToken:
|
|
793
|
-
t.personGitIdentity?.email),name:
|
|
794
|
+
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw B("Release environment files require a \
|
|
795
|
+
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let p=t.usageRecordingPreload??
|
|
796
|
+
"";if(typeof p!="string"||p&&(!p.startsWith("/")||/[\s"'\\\0]/u.test(p)||!["preview","output"].includes(s)||t.actor==="a\
|
|
797
|
+
pp"))throw B("A usage recording preload belongs only to a Preview or Output target launch.","vibe64_command_usage_record\
|
|
798
|
+
ing_preload_invalid");let d=t.applicationAccount??"";if(typeof d!="string"||d&&(!fd.test(d)||t.actor!=="app"||n!=="captu\
|
|
799
|
+
re"))throw B("Application accounts run only finite application commands.","vibe64_command_application_account_invalid");
|
|
800
|
+
return{actor:le(t.actor,md,"daemon","actor"),applicationAccount:d,allowedRoots:In(t.allowedRoots),args:Td(t.args,{mode:n}),
|
|
801
|
+
baseEnv:o,command:r,cwd:v(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:le(t.envPolicy,yd,"session",
|
|
802
|
+
"env_policy"),releaseEnvironmentFile:l,execution:Ss(t.execution,{mode:n,project:c,purpose:s,session:u}),credentialHome:Id(
|
|
803
|
+
t.credentialHome),gitAuthToken:E(t.gitAuthToken),gitSafeDirectories:In(t.gitSafeDirectories),personGitIdentity:{email:E(
|
|
804
|
+
t.personGitIdentity?.email),name:E(t.personGitIdentity?.name)},gitTransport:le(t.gitTransport,wd,"none","git_transport"),
|
|
794
805
|
inheritProcessEnv:!l&&t.inheritProcessEnv!==!1,input:t.input,logPath:v(t.logPath),maxBuffer:Number.isSafeInteger(Number(
|
|
795
|
-
t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):
|
|
796
|
-
outputEncoding:
|
|
797
|
-
null,shimDirs:
|
|
798
|
-
0?Number(t.timeout):15e3,usageRecordingPreload:
|
|
799
|
-
var
|
|
800
|
-
|
|
801
|
-
_modules/@local/vibe64-usage-recording/runtime/node")),
|
|
802
|
-
|
|
803
|
-
startsWith(`${r}${
|
|
804
|
-
of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}function
|
|
806
|
+
t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):vd,mode:n,onOutput:typeof t.onOutput=="function"?t.onOutput:null,
|
|
807
|
+
outputEncoding:le(t.outputEncoding,_d,"utf8","output_encoding"),project:c,purpose:s,runtimes:a,session:u,signal:t.signal??
|
|
808
|
+
null,shimDirs:In(t.shimDirs),terminal:Ad(t.terminal),timeout:Number.isSafeInteger(Number(t.timeout))&&Number(t.timeout)>
|
|
809
|
+
0?Number(t.timeout):15e3,usageRecordingPreload:p,userKey:E(t.userKey)}}var Aw=Object.freeze({normalizeExecutionDescriptor:Ss});var xd=null,Os="VIBE64_MANAGED_EXECUTION_REQUIRED";function Rn(){return xd}function Qt(e){return["1","true"].includes(String(e[Os]||"").trim().toLowerCase())}import{realpathSync as As,statSync as Md}from"node:fs";import de from"node:path";import{fileURLToPath as Ld}from"node:url";
|
|
810
|
+
var $d=new URL("./../../../vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href;function jd(e){let t=[
|
|
811
|
+
de.resolve(de.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=de.dirname(e);t.push(de.join(r,"node\
|
|
812
|
+
_modules/@local/vibe64-usage-recording/runtime/node")),de.dirname(r)!==r;r=de.dirname(r));return t.flatMap(r=>{try{return[
|
|
813
|
+
As(r)]}catch{return[]}})}function Is(e="",t=Ld($d)){try{if(de.resolve(e)===e&&As(e)===e&&Md(e).isFile()&&jd(t).some(r=>e.
|
|
814
|
+
startsWith(`${r}${de.sep}`)))return`--import=${e}`}catch{}throw Object.assign(new Error("The usage recorder is not part \
|
|
815
|
+
of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}function Rs(e){return e.releaseEnvironmentFile?L("Release environment execution requires a managed host.","vibe64_releas\
|
|
805
816
|
e_environment_unavailable",{execution:e.execution}):e.applicationAccount?L("Application account execution requires a man\
|
|
806
|
-
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function
|
|
807
|
-
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=
|
|
808
|
-
u=s;o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?
|
|
809
|
-
e.mode==="detached"?r.requiresRealUser&&(!
|
|
810
|
-
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):
|
|
811
|
-
{...await
|
|
812
|
-
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:
|
|
817
|
+
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function Dd(e,t={}){let{actor:r,
|
|
818
|
+
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=Rs(e);if(a)return a;if(e.usageRecordingPreload){let c=Is(e.usageRecordingPreload),
|
|
819
|
+
u=s;o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?ws(e,{actor:r,cwd:n,env:o,resolveEnv:s}):
|
|
820
|
+
e.mode==="detached"?r.requiresRealUser&&(!je(r)||i)?L("Detached real-user command execution is unsupported when the help\
|
|
821
|
+
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):oi(e,{actor:r,cwd:n,env:o}):i?
|
|
822
|
+
{...await tn(Dt({actor:r,args:e.args,command:e.command,cwd:n,env:o,input:e.input,operation:ot(e)}),{env:process.env,maxBuffer:e.
|
|
823
|
+
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:be(e.command,e.args,
|
|
813
824
|
{cwd:n,env:o,execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,onOutput:e.onOutput,outputEncoding:e.outputEncoding,
|
|
814
|
-
signal:e.signal,timeout:e.timeout})}async function x(e={}){let t=null;try{if(t=
|
|
815
|
-
cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await
|
|
816
|
-
...t.baseEnv}:{...t.baseEnv},o=(_={})=>({..._,VIBE64_EXECUTION_ID:t.execution.id}),i=
|
|
817
|
-
r),u=!(!!i||s||
|
|
818
|
-
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),
|
|
819
|
-
|
|
820
|
-
args=="function"?t.args(_):t.args,f=(_={})=>o(t.envFactory?
|
|
821
|
-
...t,env:t.envFactory(_),envFactory:null}}):l),g=(_=t,
|
|
822
|
-
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:d,env:l,resolveArgs:
|
|
825
|
+
signal:e.signal,timeout:e.timeout})}async function x(e={}){let t=null;try{if(t=Ts(e),t.signal?.aborted)return L("Command\
|
|
826
|
+
cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await li(t),n=t.inheritProcessEnv?{...process.env,
|
|
827
|
+
...t.baseEnv}:{...t.baseEnv},o=(_={})=>({..._,VIBE64_EXECUTION_ID:t.execution.id}),i=Rn(),s=Qt(n)||Qt(process.env),a=Ut(
|
|
828
|
+
r),u=!(!!i||s||rn())&&je(r)?[n.PATH,process.env.PATH].filter(Boolean).join(":"):"",l=o(await ts({actor:r,baseEnv:n,localPath:u,
|
|
829
|
+
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),p=Object.fromEntries([Se,ve,Oe,Te].map(_=>[_,l[_]]));
|
|
830
|
+
mi(r,l);let d=Es(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});pi(r,t,d);let m=(_={})=>typeof t.
|
|
831
|
+
args=="function"?t.args(_):t.args,f=(_={})=>o(t.envFactory?_n({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:p,request:{
|
|
832
|
+
...t,env:t.envFactory(_),envFactory:null}}):l),g=(_=t,S={})=>Dd(_,{actor:r,cwd:d,env:l,requiresHelper:a,resolveEnv:f,...S});
|
|
833
|
+
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:d,env:l,resolveArgs:m,resolveEnv:f,runLocal:g});let y=Rs(t);return y||
|
|
823
834
|
(s?L("Managed execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unava\
|
|
824
835
|
ilable",{execution:t.execution,retryable:!1}):g())}catch(r){return L(r?.message||"Vibe64 command failed.",r?.code||"vibe\
|
|
825
|
-
64_command_failed",{execution:t?.execution})}}import{createHash as
|
|
826
|
-
import
|
|
827
|
-
ed","completed","failed","interrupted"]),
|
|
836
|
+
64_command_failed",{execution:t?.execution})}}import{createHash as Bd}from"node:crypto";import{lstat as ks,mkdir as Gd,mkdtemp as Hd,readdir as Vd,rm as Ns,statfs as zd}from"node:fs/promises";
|
|
837
|
+
import q from"node:path";import{fileURLToPath as Fd}from"node:url";var Ud=new URL("./../../../vibe64-execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,Wd=3e4;var sb=Fd(new URL("./gitTurnCheckpointCommand.js",Ud)),qd=15*6e4,Yd=512*1024*1024,Kd=1024*1024*1024,xs=new Set(["cancell\
|
|
838
|
+
ed","completed","failed","interrupted"]),Zt=new Map;async function pt({outerTurnId:e="",outcome:t="completed",project:r={},
|
|
828
839
|
runCommand:n,sessionId:o="",temporaryDiskBudgetBytes:i,temporaryDiskReserveBytes:s,timestamp:a="",worktreePath:c=""}={}){
|
|
829
|
-
let u=
|
|
830
|
-
project:r,refs:l,runCommand:n,temporaryDiskBudgetBytes:i,temporaryDiskReserveBytes:s}))}async function
|
|
831
|
-
let s=await
|
|
832
|
-
refs:r,runCommand:n});let a=await V(n,e.worktreePath,["rev-parse","--verify","HEAD"],{project:t}),c=await
|
|
833
|
-
project:t,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:e.worktreePath}),u=await
|
|
834
|
-
e.worktreePath,{project:t});for(let l=0;;l+=1){let
|
|
835
|
-
d=
|
|
840
|
+
let u=tp({outerTurnId:e,outcome:t,sessionId:o,timestamp:a,worktreePath:c}),l=Pn(u);return Ms(u.worktreePath,()=>Jd({identity:u,
|
|
841
|
+
project:r,refs:l,runCommand:n,temporaryDiskBudgetBytes:i,temporaryDiskReserveBytes:s}))}async function Jd({identity:e={},project:t={},refs:r={},runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i}={}){
|
|
842
|
+
let s=await He(n,e.worktreePath,["rev-parse","--verify",r.turnRef],{project:t});if(s)return Cs({commit:s,identity:e,project:t,
|
|
843
|
+
refs:r,runCommand:n});let a=await V(n,e.worktreePath,["rev-parse","--verify","HEAD"],{project:t}),c=await $s({baseCommit:a,
|
|
844
|
+
project:t,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:e.worktreePath}),u=await Bs(n,
|
|
845
|
+
e.worktreePath,{project:t});for(let l=0;;l+=1){let p=await He(n,e.worktreePath,["rev-parse","--verify",r.latestRef],{project:t}),
|
|
846
|
+
d=p||a,m=await V(n,e.worktreePath,["commit-tree",c,"-p",d],{env:rp(e.timestamp),input:Us(e),project:t});try{await V(n,e.
|
|
836
847
|
worktreePath,["update-ref","--stdin"],{input:`start
|
|
837
|
-
create ${r.turnRef} ${
|
|
838
|
-
update ${r.latestRef} ${
|
|
848
|
+
create ${r.turnRef} ${m}
|
|
849
|
+
update ${r.latestRef} ${m} ${p||u}
|
|
839
850
|
prepare
|
|
840
851
|
commit
|
|
841
|
-
`,project:t})}catch(f){let g=await
|
|
842
|
-
identity:e,project:t,refs:r,runCommand:n});let
|
|
843
|
-
if(l>=2||
|
|
844
|
-
outcome:e.outcome,sessionId:e.sessionId,tree:c,turnRef:r.turnRef}}}async function
|
|
845
|
-
runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=
|
|
846
|
-
ePath"));return
|
|
847
|
-
worktreePath:a}))}async function
|
|
848
|
-
temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=
|
|
849
|
-
bsolute-git-dir"],{project:r}),u=
|
|
850
|
-
join(u,".tree-")),
|
|
851
|
-
let
|
|
852
|
-
temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:a}),await V(n,a,["add","-A","--",...
|
|
853
|
-
{env:{...d,GIT_LITERAL_PATHSPECS:"1"},project:r}),await V(n,a,["write-tree"],{env:d,project:r})}finally{await
|
|
854
|
-
recursive:!0})}}async function
|
|
855
|
-
isDirectory()&&n.name.startsWith(".tree-")).map(async n=>{let o=
|
|
856
|
-
t-i.mtimeMs>
|
|
857
|
-
Promise.resolve()).catch(()=>null).then(t),i=o.then(()=>null,()=>null).finally(()=>{
|
|
858
|
-
set(r,i),o}async function
|
|
852
|
+
`,project:t})}catch(f){let g=await He(n,e.worktreePath,["rev-parse","--verify",r.turnRef],{project:t});if(g)return Cs({commit:g,
|
|
853
|
+
identity:e,project:t,refs:r,runCommand:n});let y=await He(n,e.worktreePath,["rev-parse","--verify",r.latestRef],{project:t});
|
|
854
|
+
if(l>=2||y===p)throw f;continue}return{baseCommit:d,commit:m,created:!0,latestRef:r.latestRef,ok:!0,outerTurnId:e.outerTurnId,
|
|
855
|
+
outcome:e.outcome,sessionId:e.sessionId,tree:c,turnRef:r.turnRef}}}async function Z({baseCommit:e="HEAD",paths:t=[],project:r={},
|
|
856
|
+
runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=q.resolve(Re(s,"worktre\
|
|
857
|
+
ePath"));return Ms(a,()=>$s({baseCommit:e,paths:t,project:r,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,
|
|
858
|
+
worktreePath:a}))}async function $s({baseCommit:e="HEAD",paths:t=[],project:r={},runCommand:n,temporaryDiskBudgetBytes:o,
|
|
859
|
+
temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=q.resolve(Re(s,"worktreePath")),c=await V(n,a,["rev-parse","--a\
|
|
860
|
+
bsolute-git-dir"],{project:r}),u=q.join(c,"vibe64-checkpoints");await Gd(u,{recursive:!0}),await Xd(u);let l=await Hd(q.
|
|
861
|
+
join(u,".tree-")),p=q.join(l,"index");try{let d={GIT_INDEX_FILE:p};await V(n,a,["read-tree",e||"HEAD"],{env:d,project:r});
|
|
862
|
+
let m=Array.isArray(t)?t.map(f=>String(f||"")).filter(Boolean):[];return await Qd({gitDirectory:c,paths:m,project:r,runCommand:n,
|
|
863
|
+
temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:a}),await V(n,a,["add","-A","--",...m.length>0?m:["."]],
|
|
864
|
+
{env:{...d,GIT_LITERAL_PATHSPECS:"1"},project:r}),await V(n,a,["write-tree"],{env:d,project:r})}finally{await Ns(l,{force:!0,
|
|
865
|
+
recursive:!0})}}async function Xd(e=""){let t=Date.now(),r=await Vd(e,{withFileTypes:!0});await Promise.all(r.filter(n=>n.
|
|
866
|
+
isDirectory()&&n.name.startsWith(".tree-")).map(async n=>{let o=q.join(e,n.name),i=await ks(o).catch(()=>null);i?.isDirectory()&&
|
|
867
|
+
t-i.mtimeMs>qd&&await Ns(o,{force:!0,recursive:!0})}))}function Ms(e="",t=async()=>null){let r=q.resolve(e),o=(Zt.get(r)||
|
|
868
|
+
Promise.resolve()).catch(()=>null).then(t),i=o.then(()=>null,()=>null).finally(()=>{Zt.get(r)===i&&Zt.delete(r)});return Zt.
|
|
869
|
+
set(r,i),o}async function Qd({gitDirectory:e="",paths:t=[],project:r={},runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,
|
|
859
870
|
worktreePath:s=""}={}){let a=t.length>0?t:["."],[c,u,l]=await Promise.all([V(n,s,["diff","--name-only","-z","HEAD","--",
|
|
860
|
-
...a],{project:r}),V(n,s,["ls-files","--others","--exclude-standard","-z","--",...a],{project:r}),
|
|
861
|
-
[...
|
|
862
|
-
|
|
863
|
-
invalid");let C=await
|
|
864
|
-
0),path:
|
|
865
|
-
l.bavail)*Number(l.bsize)),
|
|
866
|
-
P.path)).slice(0,5).map(
|
|
867
|
-
changed, unignored files may need about ${f} temporary bytes; the safe budget is ${
|
|
871
|
+
...a],{project:r}),V(n,s,["ls-files","--others","--exclude-standard","-z","--",...a],{project:r}),zd(e)]),p=[...new Set(
|
|
872
|
+
[...Ps(c),...Ps(u)])],d=[];for(let I of p){let P=q.resolve(s,I),T=q.relative(s,P);if(T===".."||T.startsWith(`..${q.sep}`)||
|
|
873
|
+
q.isAbsolute(T))throw Pe("Git returned a checkpoint candidate outside the session source.","vibe64_checkpoint_candidate_\
|
|
874
|
+
invalid");let C=await ks(P).catch(N=>N?.code==="ENOENT"?null:Promise.reject(N));C?.isFile()&&d.push({bytes:Number(C.size||
|
|
875
|
+
0),path:T})}let m=d.reduce((I,P)=>I+P.bytes,0),f=Math.min(Number.MAX_SAFE_INTEGER,m*2),g=Zd(o),y=ep(i),_=Math.max(0,Number(
|
|
876
|
+
l.bavail)*Number(l.bsize)),S=Math.min(g,Math.max(0,_-y));if(f<=S)return;let A=d.sort((I,P)=>P.bytes-I.bytes||I.path.localeCompare(
|
|
877
|
+
P.path)).slice(0,5).map(I=>`${I.path} (${I.bytes} bytes)`).join(", ");throw Pe([`Vibe64 refused this checkpoint because \
|
|
878
|
+
changed, unignored files may need about ${f} temporary bytes; the safe budget is ${S} bytes.`,A?`Largest candidates: ${A}\
|
|
868
879
|
.`:"","Keep needed files in place and add generated or local-only artifacts to .gitignore, or ask an operator to review \
|
|
869
|
-
the checkpoint disk budget."].filter(Boolean).join(" "),"vibe64_checkpoint_disk_budget_exceeded")}function
|
|
870
|
-
e||"").split("\0").filter(Boolean)}function
|
|
871
|
-
|
|
872
|
-
e===""?t:e,i=Number(o===void 0||o===""?r:o);return Number.isSafeInteger(i)&&i>=n?i:r}async function
|
|
873
|
-
project:r={},refs:n={},runCommand:o}={}){let i=await V(o,t.worktreePath,["show","-s","--format=%B",e],{project:r}),s=[...
|
|
874
|
-
find(u=>i===
|
|
880
|
+
the checkpoint disk budget."].filter(Boolean).join(" "),"vibe64_checkpoint_disk_budget_exceeded")}function Ps(e=""){return String(
|
|
881
|
+
e||"").split("\0").filter(Boolean)}function Zd(e){return Ls(e,process.env.VIBE64_CHECKPOINT_TEMPORARY_DISK_BUDGET_BYTES,
|
|
882
|
+
Yd,1)}function ep(e){return Ls(e,process.env.VIBE64_CHECKPOINT_DISK_RESERVE_BYTES,Kd,0)}function Ls(e,t,r,n){let o=e==null||
|
|
883
|
+
e===""?t:e,i=Number(o===void 0||o===""?r:o);return Number.isSafeInteger(i)&&i>=n?i:r}async function Cs({commit:e="",identity:t={},
|
|
884
|
+
project:r={},refs:n={},runCommand:o}={}){let i=await V(o,t.worktreePath,["show","-s","--format=%B",e],{project:r}),s=[...xs].
|
|
885
|
+
find(u=>i===Us({...t,outcome:u}).trim());if(!s)throw Pe("Existing Vibe64 turn checkpoint does not match its durable turn\
|
|
875
886
|
identity.","vibe64_checkpoint_identity_mismatch");let a=await V(o,t.worktreePath,["rev-parse",`${e}^{tree}`],{project:r});
|
|
876
|
-
if(!await
|
|
887
|
+
if(!await He(o,t.worktreePath,["rev-parse","--verify",n.latestRef],{project:r})){let u=await Bs(o,t.worktreePath,{project:r});
|
|
877
888
|
await V(o,t.worktreePath,["update-ref",n.latestRef,e,u],{project:r})}return{baseCommit:await V(o,t.worktreePath,["rev-pa\
|
|
878
889
|
rse",`${e}^`],{project:r}),commit:e,created:!1,latestRef:n.latestRef,ok:!0,outerTurnId:t.outerTurnId,outcome:s,sessionId:t.
|
|
879
|
-
sessionId,tree:a,turnRef:n.turnRef}}function
|
|
880
|
-
let i=
|
|
881
|
-
"vibe64_checkpoint_outcome_invalid");let s=
|
|
882
|
-
eckpoint timestamp must be an ISO date.","vibe64_checkpoint_timestamp_invalid");let a=
|
|
883
|
-
outerTurnId:
|
|
884
|
-
function
|
|
885
|
-
return`refs/vibe64/checkpoints/${
|
|
886
|
-
function
|
|
890
|
+
sessionId,tree:a,turnRef:n.turnRef}}function tp({outerTurnId:e="",outcome:t="completed",sessionId:r="",timestamp:n="",worktreePath:o=""}={}){
|
|
891
|
+
let i=Re(t,"outcome").toLowerCase();if(!xs.has(i))throw Pe(`Unsupported Vibe64 turn checkpoint outcome: ${i||"(empty)"}.`,
|
|
892
|
+
"vibe64_checkpoint_outcome_invalid");let s=Re(n,"timestamp");if(!Number.isFinite(Date.parse(s)))throw Pe("Vibe64 turn ch\
|
|
893
|
+
eckpoint timestamp must be an ISO date.","vibe64_checkpoint_timestamp_invalid");let a=q.resolve(Re(o,"worktreePath"));return{
|
|
894
|
+
outerTurnId:Re(e,"outerTurnId"),outcome:i,sessionId:Re(r,"sessionId"),timestamp:new Date(s).toISOString(),worktreePath:a}}
|
|
895
|
+
function Pn(e={}){let t=js(e.sessionId),r=Ds(e.outerTurnId);return{latestRef:`${t}/latest`,turnRef:`${t}/${r}`}}function js(e=""){
|
|
896
|
+
return`refs/vibe64/checkpoints/${Ds(e)}`}function Ds(e=""){return Bd("sha256").update(String(e)).digest("hex").slice(0,32)}
|
|
897
|
+
function Us(e={}){return[`vibe64 checkpoint: session ${e.sessionId} turn ${e.outerTurnId}`,"","Vibe64-Checkpoint: true",
|
|
887
898
|
`Vibe64-Session: ${e.sessionId}`,`Vibe64-Outer-Turn: ${e.outerTurnId}`,`Vibe64-Turn-Outcome: ${e.outcome}`,""].join(`
|
|
888
|
-
`)}function
|
|
889
|
-
e,t,["rev-parse","--show-object-format"],{project:n});return"0".repeat(o==="sha256"?64:40)}async function
|
|
890
|
-
let o=await
|
|
891
|
-
r,n);if(o.ok!==!0)throw
|
|
892
|
-
"vibe64_checkpoint_git_failed");return String(o.stdout||"").trim()}function
|
|
899
|
+
`)}function rp(e=""){return{GIT_AUTHOR_DATE:e,GIT_COMMITTER_DATE:e}}async function Bs(e,t,r={}){let{project:n={}}=r,o=await He(
|
|
900
|
+
e,t,["rev-parse","--show-object-format"],{project:n});return"0".repeat(o==="sha256"?64:40)}async function He(e,t,r,n={}){
|
|
901
|
+
let o=await Gs(e,t,r,n);return o.ok===!0?String(o.stdout||"").trim():""}async function V(e,t,r,n={}){let o=await Gs(e,t,
|
|
902
|
+
r,n);if(o.ok!==!0)throw Pe(String(o.stderr||o.stdout||o.output||o.error||"Git checkpoint command failed.").trim(),o.code||
|
|
903
|
+
"vibe64_checkpoint_git_failed");return String(o.stdout||"").trim()}function Gs(e,t,r,n={}){let{env:o={},input:i,project:s={}}=n;
|
|
893
904
|
return e({actor:"daemon",allowedRoots:[t],args:r,command:"git",cwd:t,env:o,envPolicy:"session",gitSafeDirectories:[t],input:i,
|
|
894
|
-
mode:"capture",project:s,purpose:"source",runtimes:["git"],timeout
|
|
895
|
-
trim(),n=Array.from(r).some(o=>{let i=o.codePointAt(0);return i<=31||i===127});if(!r||r.length>512||n)throw
|
|
905
|
+
mode:"capture",project:s,purpose:"source",runtimes:["git"],timeout:Wd})}function Re(e="",t="value"){let r=String(e||"").
|
|
906
|
+
trim(),n=Array.from(r).some(o=>{let i=o.codePointAt(0);return i<=31||i===127});if(!r||r.length>512||n)throw Pe(`Vibe64 t\
|
|
896
907
|
urn checkpoint ${t} is invalid.`,`vibe64_checkpoint_${t.replaceAll(/[^A-Za-z0-9]+/gu,"_").toLowerCase()}_invalid`);return r}
|
|
897
|
-
function
|
|
898
|
-
|
|
899
|
-
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),
|
|
908
|
+
function Pe(e="",t="vibe64_checkpoint_failed"){let r=new Error(e||"Vibe64 turn checkpoint failed.");return r.code=t,r}var ub=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"]);import{existsSync as np}from"node:fs";import er from"node:path";import Hs from"node:process";var Vs="You'll be asked for your computer password. Nothing shows while you type.",op="curl -fsSL https://mise.run | sh",
|
|
909
|
+
gb=Object.freeze({linux:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-linux.md",darwin:"\
|
|
910
|
+
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),tr=Object.freeze({claude:{
|
|
900
911
|
name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://claude.ai/i\
|
|
901
912
|
nstall.sh | bash"},codex:{name:"Codex",run:[["codex"]],guideUrl:"https://github.com/openai/codex",any:"curl -fsSL https:\
|
|
902
913
|
//chatgpt.com/codex/install.sh | sh"},opencode:{name:"opencode",run:[["opencode"]],guideUrl:"https://opencode.ai/docs/",
|
|
@@ -920,23 +931,23 @@ rl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -fsSL https
|
|
|
920
931
|
ild tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/install_ruby\
|
|
921
932
|
_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"sudo apt i\
|
|
922
933
|
nstall build-essential pkg-config libyaml-dev libssl-dev zlib1g-dev libpq-dev default-libmysqlclient-dev libgmp-dev",brew:"\
|
|
923
|
-
brew install pkg-config libyaml openssl@3 gmp"}}),
|
|
924
|
-
trim();return
|
|
925
|
-
return[...String(e.PATH||"").split(
|
|
926
|
-
r,"apt-get")))}function
|
|
927
|
-
r)})}function
|
|
928
|
-
it","cpp"].includes(
|
|
929
|
-
(s=n?`mise use -g ${i.mise}`:`${
|
|
930
|
-
r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?
|
|
931
|
-
function
|
|
932
|
-
`)}function
|
|
934
|
+
brew install pkg-config libyaml openssl@3 gmp"}}),ip=Object.freeze({composer:"php"});function Cn(e=""){let t=String(e||"").
|
|
935
|
+
trim();return ip[t]||t}function zs({platform:e=Hs.platform,aptGet:t=!1}={}){return e==="darwin"?"brew":t?"apt":""}function sp(e,t=ut){
|
|
936
|
+
return[...String(e.PATH||"").split(er.delimiter),...String(t||"").split(er.delimiter)].some(r=>er.isAbsolute(r)&&np(er.join(
|
|
937
|
+
r,"apt-get")))}function rr({env:e,platform:t=Hs.platform,systemPath:r}){return zs({platform:t,aptGet:t!=="darwin"&&sp(e,
|
|
938
|
+
r)})}function nr(e="",t={}){let{family:r="",mise:n=!1,xcode:o=!0}=t,i=tr[Cn(e)];if(!i)return null;if(r==="brew"&&!o&&["g\
|
|
939
|
+
it","cpp"].includes(Cn(e)))return{command:"xcode-select --install",sudo:!1,note:""};let s=i.any||i[r]||"";if(!s&&i.mise&&
|
|
940
|
+
(s=n?`mise use -g ${i.mise}`:`${op} && ~/.local/bin/mise use -g ${i.mise}`),!s)return null;let a=s.startsWith("sudo ")||
|
|
941
|
+
r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?Vs:""}}var _b=Object.freeze({SUDO_NOTE:Vs,localToolFamily:zs});function Fs({env:e,platform:t,systemPath:r}){return nr("git",{family:rr({env:e,platform:t,systemPath:r})})?.command||""}
|
|
942
|
+
function ap(e={}){return[e.error,e.stderr,e.output].filter(Boolean).join(`
|
|
943
|
+
`)}function cp(e,t){let r=ap(e);if(/spawn(?:Sync)? git ENOENT|(?:^|\s)git: (?:command )?not found/mu.test(r)){let n=Fs(t);
|
|
933
944
|
return{code:"vibe64_git_missing",installCommand:n,message:n?`Git isn't installed on this computer. Install it with: ${n}`:
|
|
934
945
|
"Git isn't installed on this computer. Install Git, then try again."}}return/unknown option [`']initial-branch/u.test(r)?
|
|
935
|
-
{code:"vibe64_git_too_old",installCommand:
|
|
946
|
+
{code:"vibe64_git_too_old",installCommand:Fs(t),message:"This Git is too old for Vibe64. Update Git to version 2.28 or n\
|
|
936
947
|
ewer, then try again."}:/gpg failed to sign|failed to sign the data|signing failed|couldn't (?:load|find) (?:public )?key|incorrect passphrase/iu.
|
|
937
948
|
test(r)?{code:"vibe64_git_signing_failed",installCommand:"",message:"Your Git is set to sign every commit, and signing d\
|
|
938
949
|
idn't work here. Vibe64 can't type a key passphrase for you. Make one signed commit in a terminal to check your key work\
|
|
939
|
-
s and is unlocked, then try again."}:null}var
|
|
950
|
+
s and is unlocked, then try again."}:null}var bb=Object.freeze({describeGitFailure:cp});import Ws from"node:path";var qs="backups.git",Ys="vibe64-atomic",lp=`backup_canonical_ref() {
|
|
940
951
|
vibe64_backup_repository="$1"
|
|
941
952
|
vibe64_source_repository="$2"
|
|
942
953
|
vibe64_source_ref="$3"
|
|
@@ -954,13 +965,13 @@ r "$vibe64_backup_repository" rev-parse --verify "$vibe64_backup_ref"
|
|
|
954
965
|
' "$vibe64_source_ref" >&2
|
|
955
966
|
return 1
|
|
956
967
|
fi
|
|
957
|
-
}`,
|
|
968
|
+
}`,Ob=`#!/bin/sh
|
|
958
969
|
set -eu
|
|
959
970
|
|
|
960
971
|
zero_object=0000000000000000000000000000000000000000
|
|
961
972
|
git_dir="$(git rev-parse --absolute-git-dir)"
|
|
962
973
|
repository_root="$(dirname "$git_dir")"
|
|
963
|
-
backup_repository="$repository_root/${
|
|
974
|
+
backup_repository="$repository_root/${qs}"
|
|
964
975
|
if [ -L "$repository_root" ] || [ -L "$backup_repository" ] || [ -L "$repository_root/mutation.lock" ]; then
|
|
965
976
|
printf '[vibe64] Canonical repository storage must not use symlinked role paths.
|
|
966
977
|
' >&2
|
|
@@ -969,7 +980,7 @@ fi
|
|
|
969
980
|
exec 8>"$repository_root/mutation.lock"
|
|
970
981
|
flock -x 8
|
|
971
982
|
|
|
972
|
-
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${
|
|
983
|
+
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${Ys}" ]; then
|
|
973
984
|
printf '[vibe64] Canonical repository pushes must use the Vibe64 atomic mutation path.
|
|
974
985
|
' >&2
|
|
975
986
|
exit 1
|
|
@@ -980,7 +991,7 @@ if [ "$(git --git-dir "$backup_repository" rev-parse --is-bare-repository 2>/dev
|
|
|
980
991
|
exit 1
|
|
981
992
|
fi
|
|
982
993
|
|
|
983
|
-
${
|
|
994
|
+
${lp}
|
|
984
995
|
|
|
985
996
|
updates_file="$(mktemp "$repository_root/.pre-receive.XXXXXX")"
|
|
986
997
|
cleanup_updates_file() {
|
|
@@ -1028,7 +1039,7 @@ while read -r old_object _new_object ref_name; do
|
|
|
1028
1039
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
1029
1040
|
fi
|
|
1030
1041
|
done <"$updates_file"
|
|
1031
|
-
`,
|
|
1042
|
+
`,Ks=`set -euo pipefail
|
|
1032
1043
|
mirror_path="$1"
|
|
1033
1044
|
remote_url="$2"
|
|
1034
1045
|
|
|
@@ -1116,382 +1127,413 @@ case "$remote_head_ref" in
|
|
|
1116
1127
|
esac
|
|
1117
1128
|
printf '[studio] Refreshed GitHub mirror for %s.
|
|
1118
1129
|
' "$remote_url"
|
|
1119
|
-
`;function
|
|
1120
|
-
freeze({CANONICAL_REPOSITORY_PUSH_OPTION:
|
|
1130
|
+
`;function dp(e=""){return e?Ws.join(Ws.dirname(e),qs):""}function kn({mirrorPath:e="",remoteUrl:t=""}={}){return["bash","-c",Ks,"vibe64-github-mirror-refresh",e,t]}var Ab=Object.
|
|
1131
|
+
freeze({CANONICAL_REPOSITORY_PUSH_OPTION:Ys,canonicalRepositoryBackupPath:dp});var jb=new URL("./../../../vibe64-execution/src/server/runtime/agentPreviewBrowserWorkerSource.js",import.meta.url).href;var mp=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms>]"," vibe64\
|
|
1121
1132
|
-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [--json]"," v\
|
|
1122
|
-
ibe64-helper preview
|
|
1123
|
-
|
|
1124
|
-
|guest|configured-name>"," vibe64-helper preview browser storage-state
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
preview restart [--wait] [--json] [--timeout-ms <ms>]"," vibe64-helper
|
|
1129
|
-
default|guest|configured-name>] test [playwright test arguments]","
|
|
1130
|
-
identity <default|guest|configured-name>] npm-run <package-script> [--
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
.","
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1133
|
+
ibe64-helper preview open <path> [--json]"," vibe64-helper preview inspect-url"," vibe64-helper preview screenshot [--\
|
|
1134
|
+
output <path>]"," vibe64-helper preview browser ensure"," vibe64-helper preview browser eval < playwright-code.js"," \
|
|
1135
|
+
vibe64-helper preview browser identity <default|guest|configured-name>"," vibe64-helper preview browser storage-state <\
|
|
1136
|
+
default|guest|configured-name> --output <new-path>"," vibe64-helper preview browser screenshot [--output <path>]"," vi\
|
|
1137
|
+
be64-helper preview browser status"," vibe64-helper preview browser reset"," vibe64-helper preview browser close"," v\
|
|
1138
|
+
ibe64-helper preview identities"," vibe64-helper preview identities save < identities.json"," vibe64-helper preview lo\
|
|
1139
|
+
gs [--lines <count>] [--json]"," vibe64-helper preview restart [--wait] [--json] [--timeout-ms <ms>]"," vibe64-helper \
|
|
1140
|
+
playwright [--target <target-id>] [--identity <default|guest|configured-name>] test [playwright test arguments]"," vibe\
|
|
1141
|
+
64-helper playwright [--target <target-id>] [--identity <default|guest|configured-name>] npm-run <package-script> [-- sc\
|
|
1142
|
+
ript arguments]","","JSON output:"," status/ensure/restart/stop --json: ready, stoppedIntent, stale, outputTargetId, en\
|
|
1143
|
+
dpoints.browser {url, hostname, port}, currentPage {url, route, title, observedAt}, terminal {id, status, running, exitC\
|
|
1144
|
+
ode, command, createdAt}, defaultIdentity, identities [{name, type}], identityTypes, diagnostics {latest, log, directApp\
|
|
1145
|
+
licationEndpoint}."," open --json: path, moved (how many of the person's open Previews moved to it), errors (why one th\
|
|
1146
|
+
at answered did not move)."," screenshot: outputPath, byteLength, sha256, capturedAt, url, title, width, height, lumina\
|
|
1147
|
+
nce, darkPixelPercentage, domTextLength, domTextSummary."," browser eval: result (the code's JSON-safe return value), l\
|
|
1148
|
+
ogs [{level, values}] from console, url (the page afterwards)."," identities: the project's Managed app identities [{na\
|
|
1149
|
+
me, type, value}] (first is the default) and the Stack's declared Preview identity types.",' identities save: replaces \
|
|
1150
|
+
the whole ordered list with the JSON array on stdin (or {"identities": [...]}); each type must be declared. Save only na\
|
|
1151
|
+
mes and accounts the person asked for or confirmed; never create app accounts or change roles for this. Then verify each\
|
|
1152
|
+
with preview browser identity <name>.'," browser storage-state: writes the identity's Playwright storage state to a ne\
|
|
1153
|
+
w file at --output; the interactive browser keeps its identity.","","When the person asks to see a page, run preview ope\
|
|
1154
|
+
n with its path inside the app (/orders/42?tab=notes): it moves every Preview pane they have open for this session to th\
|
|
1155
|
+
at page, as their Preview address box would, and they see a note that the AI opened it. Only paths starting with a singl\
|
|
1156
|
+
e / are accepted, never other sites. If it reports moved: 0, give them the path to type into the Preview address box ins\
|
|
1157
|
+
tead. Your own browser commands never move their pane.","Screenshot commands emit JSON metadata for a uniquely named, im\
|
|
1158
|
+
mutable PNG.","For browser navigation, use preview inspect-url or the status Browser URL; these use the managed Preview \
|
|
1159
|
+
proxy.","Inside browser eval, navigate with await page.goto(new URL('/your-path', preview.url).href).","The direct appli\
|
|
1160
|
+
cation endpoint in diagnostics bypasses Preview identity; do not use it for interactive browsing.","The browser keeps it\
|
|
1161
|
+
s page between browser commands. After each command the page keeps running for 30 seconds, then pauses (no timers, anima\
|
|
1162
|
+
tions or network handling) until the next browser command. For a longer wait, wait inside the command, for example with \
|
|
1163
|
+
await page.waitForSelector(...).","Five minutes after the last browser command ends, the browser closes; the next comman\
|
|
1164
|
+
d opens a fresh page, so select its identity again if needed.","Managed Playwright suites and live preview browser actio\
|
|
1165
|
+
ns are sequential. Wait on the suite through cleanup and restoration before browser actions or Preview ensure/restart/ta\
|
|
1166
|
+
rget changes; confirm playwright status has no active run and preview status is ready. Read-only status and logs are saf\
|
|
1167
|
+
e during a suite.","For background commands, wait on the existing execution/session with about a 30-second window where \
|
|
1168
|
+
supported: set yield_time_ms: 30000 for an empty command poll. Reserve shorter waits for interactive input or a specific\
|
|
1169
|
+
immediate check; do not repeatedly reread empty or unchanged logs between brief waits.","This is the canonical preview \
|
|
1170
|
+
server for the configured primary application.","Do not start a duplicate copy of that application on another port.","A \
|
|
1171
|
+
distinct secondary application explicitly requested by the user, such as a reference app, may run separately without rep\
|
|
1172
|
+
lacing this preview."].join(`
|
|
1156
1173
|
`)+`
|
|
1157
|
-
`;import{fileURLToPath as
|
|
1158
|
-
engines/stdioBridge.js",
|
|
1174
|
+
`;import{fileURLToPath as yp}from"node:url";var _p=new URL("./../../../vibe64-execution/src/server/conversationExecution.js",import.meta.url).href,Yb=yp(new URL("./\
|
|
1175
|
+
engines/stdioBridge.js",_p));var eE=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$name" 2>/dev/null) || continue',
|
|
1159
1176
|
" case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /usr/bin/*) continue ;; esac; fi',
|
|
1160
1177
|
` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1161
|
-
`);var
|
|
1162
|
-
e,Object.freeze({name:t,guideUrl:r,install:n})]})));import{execFile as
|
|
1178
|
+
`);var wp=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,any:n}=tr[e];return[
|
|
1179
|
+
e,Object.freeze({name:t,guideUrl:r,install:n})]})));import{execFile as bp}from"node:child_process";import{promisify as Ep}from"node:util";var aE=Ep(bp);import Ta from"node:crypto";function Js(e,t={}){let{missingStatus:r=404}=t,n=e?.errors?.[0]?.code||e?.code||"";return n==="vibe64_session_not_found"?
|
|
1163
1180
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
1164
1181
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
1165
1182
|
64_project_source_lock_timeout"||n==="vibe64_development_database_scope_busy"||n==="vibe64_project_session_policy_lock_t\
|
|
1166
1183
|
imeout"||n==="vibe64_session_creation_limit"||n==="vibe64_workspace_setup_retry_not_available"||n==="vibe64_workspace_se\
|
|
1167
|
-
tup_running"?409:e?.ok===!1?400:200}function
|
|
1168
|
-
it","canonicalCommit"]);function
|
|
1169
|
-
e.repository?.mode)!==
|
|
1170
|
-
.");return{...e,repository:{...e.repository,defaultBranch:s}}}return e}let n;try{n=JSON.parse(r)}catch{}let o=
|
|
1184
|
+
tup_running"?409:e?.ok===!1?400:200}function Xs(e,t,r={}){let{status:n=Js({ok:!1,code:t}),...o}=r;return new te(n,e,{...o,code:t})}var Y="github",Ve="managed_git",D="local_source";function or(e=""){let t=oe(e).toLowerCase().replace(/[-\s]+/gu,"_");return t===Y||t===Ve||t===D?t:""}function Qs(e="",t=""){let r=new Error(t);return r.code=e,r}var dS=Object.freeze(["repository","branch","path","baseComm\
|
|
1185
|
+
it","canonicalCommit"]);function Nn(e,t){let r=t?.metadata?.github_pull_request;if(!r){let s=t?.metadata?.repository_branch;if(s&&or(e.repositoryMode||
|
|
1186
|
+
e.repository?.mode)!==D){if(!Zs(s))throw Qs("vibe64_session_branch_invalid","This session's repository branch is invalid\
|
|
1187
|
+
.");return{...e,repository:{...e.repository,defaultBranch:s}}}return e}let n;try{n=JSON.parse(r)}catch{}let o=oe(e.githubRepository?.
|
|
1171
1188
|
fullName||e.repository?.github?.fullName);if(!n||n.baseRepository!==o||!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u.test(n.headRepository||
|
|
1172
|
-
"")||!
|
|
1189
|
+
"")||!Zs(n.headBranch)||e.repositoryMode===Ve)throw Qs("vibe64_pull_request_authority_invalid","This session's pull requ\
|
|
1173
1190
|
est source is invalid. Its Save destination could not be verified.");let i={fullName:n.headRepository,cloneUrl:`https://\
|
|
1174
1191
|
github.com/${n.headRepository}.git`};return{...e,githubMirrorPath:n.headRepository===o?e.githubMirrorPath:"",githubRepository:i,
|
|
1175
|
-
repositoryMode:
|
|
1192
|
+
repositoryMode:Y,repository:{mode:Y,defaultBranch:n.headBranch,github:i}}}function Zs(e){return typeof e=="string"&&e.length>
|
|
1176
1193
|
0&&e.length<=255&&!["@","HEAD"].includes(e)&&!e.startsWith("-")&&!e.endsWith(".")&&!/[\s~^:?*[\\]/u.test(e)&&!e.includes(
|
|
1177
1194
|
"..")&&!e.includes("@{")&&![...e].some(t=>t.charCodeAt(0)<32||t.charCodeAt(0)===127)&&e.split("/").every(t=>t&&!t.startsWith(
|
|
1178
|
-
".")&&!t.endsWith(".lock"))}function
|
|
1179
|
-
projectSlug,i=r.repository?.defaultBranch;return n===
|
|
1180
|
-
|
|
1181
|
-
warn:40,error:50,fatal:60,silent:1/0});function
|
|
1182
|
-
return e==="behind"||e==="diverged"?"rebase":"none"}import
|
|
1195
|
+
".")&&!t.endsWith(".lock"))}function ea(e={},t={}){let r=Nn(e,t),n=or(r.repositoryMode||r.repository?.mode),o=r.slug||r.
|
|
1196
|
+
projectSlug,i=r.repository?.defaultBranch;return n===Y?o=r.githubRepository?.fullName||r.repository?.github?.fullName:n===
|
|
1197
|
+
D&&(o=r.sourceRoot,i=t.metadata?.local_source_branch||i),{sessionId:oe(t.sessionId),mode:n,repository:oe(o),branch:oe(i)}}var xn="warn";var Op=Object.freeze(["fatal","error","warn","info","debug","trace","silent"]),ta=Object.freeze({trace:10,debug:20,info:30,
|
|
1198
|
+
warn:40,error:50,fatal:60,silent:1/0});function ra(e="",t=xn){let r=String(e||"").trim().toLowerCase();return Op.includes(r)?r:t}function Ap(e="info",t=xn){let r=ra(e,""),n=ra(t,xn);return!r||n==="silent"?!1:ta[r]>=ta[n]}var fS=Object.freeze({isVibe64LogLevelEnabled:Ap});function na(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:0}function mt(e=0,t=0){let r=na(e),n=na(t);return r>0&&n>0?"diverged":n>0?"behind":r>0?"ahead":"current"}function ft(e=""){
|
|
1199
|
+
return e==="behind"||e==="diverged"?"rebase":"none"}import oa from"node:path";var sa="%H%x00%P%x00%an%x00%ae%x00%aI%x00%s",$n=200,aa=500,ir=800,Pp=5e3;function ca(e=""){let t=String(e||"").split("\0"),
|
|
1183
1200
|
r=[];for(let n=0;n+5<t.length;n+=6){let o=h(t[n]);if(!o)continue;let i=h(t[n+1]).split(/\s+/u).filter(Boolean);r.push({author:h(
|
|
1184
1201
|
t[n+2]),authorEmail:h(t[n+3]),committedAt:h(t[n+4]),commit:o,isMerge:i.length>1,message:h(t[n+5]),parents:i,shortCommit:o.
|
|
1185
|
-
slice(0,8)})}return r}function
|
|
1186
|
-
min(n,r):t}function
|
|
1187
|
-
let i=/^[CR]/u.test(o)?t[n++]:"",s=t[n++];s&&r.set(s,{path:s,...i?{previousPath:i}:{},status:o.slice(0,1)})}return r}function
|
|
1188
|
-
let t=h(e);if(t==="-")return null;let r=Number.parseInt(t,10);return Number.isSafeInteger(r)&&r>=0?r:0}function
|
|
1202
|
+
slice(0,8)})}return r}function ua(e,t,r){let n=Number.parseInt(String(e??""),10);return Number.isSafeInteger(n)&&n>0?Math.
|
|
1203
|
+
min(n,r):t}function ht(e=""){let t=String(e||"").split("\0"),r=new Map;for(let n=0;n<t.length;){let o=h(t[n++]);if(!o)continue;
|
|
1204
|
+
let i=/^[CR]/u.test(o)?t[n++]:"",s=t[n++];s&&r.set(s,{path:s,...i?{previousPath:i}:{},status:o.slice(0,1)})}return r}function ia(e=""){
|
|
1205
|
+
let t=h(e);if(t==="-")return null;let r=Number.parseInt(t,10);return Number.isSafeInteger(r)&&r>=0?r:0}function Cp(e=""){
|
|
1189
1206
|
let t=String(e||"").split("\0"),r=new Map;for(let n=0;n<t.length;){let o=t[n++];if(!o)continue;let i=o.indexOf(" "),s=o.
|
|
1190
|
-
indexOf(" ",i+1),a=o.slice(s+1),c=!a;c&&(n+=1);let u=c?t[n++]:a;u&&r.set(u,{added:
|
|
1191
|
-
1,s))})}return r}function
|
|
1192
|
-
sort((n,o)=>n.path.localeCompare(o.path))}function
|
|
1207
|
+
indexOf(" ",i+1),a=o.slice(s+1),c=!a;c&&(n+=1);let u=c?t[n++]:a;u&&r.set(u,{added:ia(o.slice(0,i)),deleted:ia(o.slice(i+
|
|
1208
|
+
1,s))})}return r}function la(e="",t=""){let r=Cp(t);return[...ht(e).values()].map(n=>({...n,...r.get(n.path)||{added:0,deleted:0}})).
|
|
1209
|
+
sort((n,o)=>n.path.localeCompare(o.path))}function da(e,{offset:t=0,limit:r,defaultLimit:n,maxLimit:o}){let i=ua(r,n,o),
|
|
1193
1210
|
s=Math.max(0,Number.parseInt(String(t??""),10)||0);return{items:e.slice(s,s+i),limit:i,offset:s,totalCount:e.length,truncated:s+
|
|
1194
|
-
i<e.length}}function
|
|
1211
|
+
i<e.length}}function pa(e,t){let r=String(e||"").replaceAll(`\r
|
|
1195
1212
|
`,`
|
|
1196
1213
|
`).split(`
|
|
1197
|
-
`),n=
|
|
1198
|
-
`),lineLimit:n,shownLines:Math.min(r.length,n),totalLines:r.length,truncated:r.length>n}}function
|
|
1199
|
-
e||"");if(!t||t.includes("\0")||
|
|
1200
|
-
"Choose a changed project file.","vibe64_session_change_path_invalid");return t}function
|
|
1201
|
-
"\\$&");return[`:(literal)${e}`,`:(glob,exclude)${t}/**`]}import
|
|
1202
|
-
import{fileURLToPath as
|
|
1203
|
-
"object"&&!Array.isArray(r)?{...r}:{},a=new
|
|
1204
|
-
assign(a,s),a}function
|
|
1205
|
-
repositoryMode:e.mode,sessionId:e.sessionId}}function H(e,t={},r={},n={}){let{label:o="Session repository work",operationId:i=
|
|
1206
|
-
randomUUID()}=n;if(e?.[
|
|
1214
|
+
`),n=ua(t,ir,Pp);return{diff:r.slice(0,n).join(`
|
|
1215
|
+
`),lineLimit:n,shownLines:Math.min(r.length,n),totalLines:r.length,truncated:r.length>n}}function Mn(e=""){let t=String(
|
|
1216
|
+
e||"");if(!t||t.includes("\0")||oa.posix.isAbsolute(t)||oa.posix.normalize(t)!==t||t===".."||t.startsWith("../"))throw Xs(
|
|
1217
|
+
"Choose a changed project file.","vibe64_session_change_path_invalid");return t}function ma(e){let t=e.replace(/[*?[\]\\]/gu,
|
|
1218
|
+
"\\$&");return[`:(literal)${e}`,`:(glob,exclude)${t}/**`]}import ha from"node:crypto";import{mkdtemp as ga,readdir as jp,rm as jn}from"node:fs/promises";import pe from"node:path";
|
|
1219
|
+
import{fileURLToPath as Dp}from"node:url";import kp from"node:crypto";import gt from"node:path";import{setTimeout as Np}from"node:timers/promises";var Ln=12e4,fa=Symbol("vibe64-session-work-command-scope");function O(e,t,r={},n={}){let{status:o=409,...i}=n,s=r&&typeof r==
|
|
1220
|
+
"object"&&!Array.isArray(r)?{...r}:{},a=new te(o,e||"Vibe64 could not save this session.",{...i,code:t,details:s});return Object.
|
|
1221
|
+
assign(a,s),a}function G(e={},t={}){return{ownerUserKey:h(t.ownerUserKey||t.githubRepository?.owner),projectRoot:e.worktreePath,
|
|
1222
|
+
repositoryMode:e.mode,sessionId:e.sessionId}}function H(e,t={},r={},n={}){let{label:o="Session repository work",operationId:i=kp.
|
|
1223
|
+
randomUUID()}=n;if(e?.[fa])return e;let s=h(r.slug||r.projectSlug),a=Promise.resolve(),c=(u={})=>{let l=a.then(()=>e({...u,
|
|
1207
1224
|
execution:{...u.execution||{},kind:"job",label:o,lifecycle:"finite",operationId:h(i),ownerId:t.sessionId,projectSlug:s,sessionId:t.
|
|
1208
1225
|
sessionId},project:{...u.project||{},...s?{slug:s}:{}},session:{...u.session||{},sessionId:t.sessionId}}));return a=l.then(
|
|
1209
|
-
()=>{},()=>{}),l};return Object.defineProperty(c,
|
|
1210
|
-
commandOptions:s={},cwd:a=t.worktreePath,env:c={},input:u,project:l={}}=o,
|
|
1211
|
-
mode===
|
|
1212
|
-
t.remoteUrl)]:[],...i.flatMap(d=>{let
|
|
1213
|
-
command:r,cwd:a,env:c,envPolicy:"session",gitSafeDirectories:
|
|
1214
|
-
startsWith("github")?"github":"source",runtimes:s.gitTransport==="github-https"?["git","gh"]:["git"],timeout:
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1226
|
+
()=>{},()=>{}),l};return Object.defineProperty(c,fa,{value:!0}),c}async function _t(e,t,r,n,o={}){let{additionalAllowedRoots:i=[],
|
|
1227
|
+
commandOptions:s={},cwd:a=t.worktreePath,env:c={},input:u,project:l={}}=o,p=[t.worktreePath,gt.dirname(t.worktreePath),...t.
|
|
1228
|
+
mode===D?[t.standaloneSourceRoot,gt.dirname(t.standaloneSourceRoot)]:[],...gt.isAbsolute(t.remoteUrl)?[t.remoteUrl,gt.dirname(
|
|
1229
|
+
t.remoteUrl)]:[],...i.flatMap(d=>{let m=h(d);return m?[m,gt.dirname(m)]:[]})];return e({actor:"daemon",allowedRoots:p,args:n,
|
|
1230
|
+
command:r,cwd:a,env:c,envPolicy:"session",gitSafeDirectories:p,input:u,mode:"capture",project:G(t,l),purpose:s.gitTransport?.
|
|
1231
|
+
startsWith("github")?"github":"source",runtimes:s.gitTransport==="github-https"?["git","gh"]:["git"],timeout:Ln,...s})}var xp=100,
|
|
1232
|
+
$p=100;function Mp(e){return e?.ok!==!0&&/index\.lock'?: File exists/u.test(String(e?.stderr||e?.output||""))}async function w(e,t,r,n={}){
|
|
1233
|
+
let{required:o=!0,...i}=n,s=await _t(e,t,"git",r,i);for(let a=0;a<xp&&Mp(s);a+=1)await Np($p),s=await _t(e,t,"git",r,i);
|
|
1234
|
+
if(o&&s?.ok!==!0)throw O(h(s?.stderr||s?.stdout||s?.output||s?.error)||"Git Save command failed.",h(s?.code)||"vibe64_se\
|
|
1235
|
+
ssion_save_git_failed",{gitArgs:r},{status:500});return s}function ze(e={}){return h(e.stdout||e.output)}async function R(e,t,r,n={}){
|
|
1236
|
+
return ze(await w(e,t,r,n))}async function sr(e,t,r,n={}){let o=await w(e,t,r,{...n,required:!1});return o?.ok===!0?ze(o):
|
|
1237
|
+
""}var Lp=new URL("./sessionWorkGit.js",import.meta.url).href,aT=Dp(new URL("./sessionWorkOperationCommand.js",Lp)),_a=".vi\
|
|
1238
|
+
be64-derived-worktree-",Up=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function ar(e=""){return Up.test(String(e??""))}function Fe(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(h).filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function Bp(e={}){
|
|
1239
|
+
return e.metadata&&typeof e.metadata=="object"?e.metadata:{}}function U(e={},t={}){t=Nn(t,e);let r=Bp(e),n=or(t.repositoryMode||
|
|
1240
|
+
t.repository?.mode),o=h(t.repository?.defaultBranch);if(n===D&&r.local_source_branch&&h(r.local_source_branch)!==o)throw O(
|
|
1222
1241
|
`This session belongs to ${h(r.local_source_branch)}. Switch the project folder back to that branch before saving or upd\
|
|
1223
1242
|
ating it.`,"vibe64_session_local_branch_changed");let i=h(e.sourcePath||r.source_path),s=h(e.sessionId),a=h(r.base_commit),
|
|
1224
|
-
c=h(r.canonical_commit)||a,u=n===
|
|
1243
|
+
c=h(r.canonical_commit)||a,u=n===D?h(t.sourceRoot):"";if(!n||!o||!i||!s||!a||n===D&&!u)throw O("Session Save requires a \
|
|
1225
1244
|
complete repository mode, branch, session source, base commit, and authority.","vibe64_session_save_context_incomplete");
|
|
1226
|
-
let l=n===
|
|
1245
|
+
let l=n===Y?h(t.githubRepository?.cloneUrl||t.repository?.github?.cloneUrl):n===Ve?h(t.canonicalRepositoryPath):u;if(!l)
|
|
1227
1246
|
throw O("Session Save cannot find the canonical repository authority.","vibe64_session_save_authority_missing");return Object.
|
|
1228
1247
|
freeze({baseCommit:a,branch:o,lastCanonicalCommit:c,mode:n,githubMirrorPath:h(t.githubMirrorPath),repositoryFullName:h(t.
|
|
1229
1248
|
githubRepository?.fullName||t.repository?.github?.fullName),githubMirrorOptional:!!r.github_pull_request||t.githubMirrorOptional===
|
|
1230
|
-
!0,remoteUrl:l,sessionId:s,standaloneSourceRoot:u,worktreePath:i})}async function
|
|
1231
|
-
|
|
1232
|
-
t,["rev-list","--count",`${r}..${n}`],o));return Number.isSafeInteger(
|
|
1233
|
-
e,t,["rev-parse","--verify",`${r}^{tree}`],n)}async function K(e,t,r,n,o={}){
|
|
1234
|
-
"--is-ancestor",r,n],{...o,required:!1}))?.ok===!0}async function
|
|
1235
|
-
let[i,s]=await Promise.all([K(e,t,r,n,o),K(e,t,t.baseCommit,n,o)]);return!i||s}
|
|
1236
|
-
all([
|
|
1237
|
-
lastCanonicalCommit}^{commit}`],r):"",
|
|
1238
|
-
o,i].filter(Boolean))a!==s&&await K(e,t,s,a,r)&&(s=a);return s}async function
|
|
1239
|
-
worktreeTree:i,reconcileHistory:s=!1},a={}){let[c,u]=await Promise.all([
|
|
1240
|
-
canonicalTree:u,changeBaseCommit:n,changeBaseTree:u,changedPaths:[],sessionMatchesCanonical:!0};
|
|
1241
|
-
merge-base",n,o],a),
|
|
1242
|
-
changeBaseTree:
|
|
1243
|
-
"--branch",t.branch],r)}function
|
|
1244
|
-
digest("hex").slice(0,32)}/${r}`}function
|
|
1245
|
-
h(r)&&await
|
|
1246
|
-
"--verify",`${r}^{commit}`],n);return await
|
|
1247
|
-
checkpointTree:o,commandOptions:i,project:s,virtualCommit:a="",explicitBase:c=!1}){let u=a||await
|
|
1248
|
-
message:"Vibe64 session rebase input",project:s,tree:o}),l=await
|
|
1249
|
-
[],"--messages","--name-only","-z",n,u],{commandOptions:i,project:s,required:!1}),
|
|
1250
|
-
"\0"),d=h(
|
|
1251
|
-
the conflicting files for review.","vibe64_session_update_merge_invalid");if(l?.ok!==!0){let
|
|
1252
|
-
shift();if(!f)break;
|
|
1253
|
-
version.","vibe64_session_update_merge_invalid");return{conflictPaths:[...new Set(
|
|
1254
|
-
mergedTree:"",virtualCommit:u}}return{conflictPaths:[],conflictTree:"",mergedTree:d,virtualCommit:u}}function
|
|
1255
|
-
conflictPaths:n,project:o}){return
|
|
1256
|
-
baseCommit:r,commandOptions:n,message:o,project:i,tree:s}){return
|
|
1249
|
+
!0,remoteUrl:l,sessionId:s,standaloneSourceRoot:u,worktreePath:i})}async function fe(e,t,r,n,o={}){let i=await w(e,t,["diff-tree","--no-commit-id","--name-status","-r","-z",r,n],o);return ht(
|
|
1250
|
+
i.stdout||i.output)}async function cr(e,t,r,n,o={}){return[...(await fe(e,t,r,n,o)).keys()].sort((i,s)=>i.localeCompare(
|
|
1251
|
+
s))}async function We(e,t,r,n,o={}){let i=Number(await R(e,t,["rev-list","--count",`${r}..${n}`],o));return Number.isSafeInteger(
|
|
1252
|
+
i)&&i>=0?i:0}async function me(e,t,r,n={}){return R(e,t,["rev-parse","--verify",`${r}^{tree}`],n)}async function K(e,t,r,n,o={}){
|
|
1253
|
+
return r===n?!0:(await w(e,t,["merge-base","--is-ancestor",r,n],{...o,required:!1}))?.ok===!0}async function Ce(e,t,r,n,o={}){
|
|
1254
|
+
if(await K(e,t,t.baseCommit,r,o))return!1;let[i,s]=await Promise.all([K(e,t,r,n,o),K(e,t,t.baseCommit,n,o)]);return!i||s}
|
|
1255
|
+
async function ur(e,t,r={}){let[n,o,i]=await Promise.all([sr(e,t,["rev-parse","--verify",`${ya(t)}^{commit}`],r),t.lastCanonicalCommit?
|
|
1256
|
+
await sr(e,t,["rev-parse","--verify",`${t.lastCanonicalCommit}^{commit}`],r):"",R(e,t,["rev-parse","--verify",`${t.baseCommit}\
|
|
1257
|
+
^{commit}`],r)]),s=n||o||i;for(let a of[o,i].filter(Boolean))a!==s&&await K(e,t,s,a,r)&&(s=a);return s}async function qe(e,t,{
|
|
1258
|
+
baseCommit:r,canonicalCommit:n,sessionHead:o,worktreeTree:i,reconcileHistory:s=!1},a={}){let[c,u]=await Promise.all([me(
|
|
1259
|
+
e,t,r,a),me(e,t,n,a)]);if(i===u)return{baseTree:c,canonicalTree:u,changeBaseCommit:n,changeBaseTree:u,changedPaths:[],sessionMatchesCanonical:!0};
|
|
1260
|
+
let l=s?r:await R(e,t,["merge-base",n,o],a),p=l===n?u:await me(e,t,l,a),d=i===p?[]:await cr(e,t,l,i,a);return{baseTree:c,
|
|
1261
|
+
canonicalTree:u,changeBaseCommit:l,changeBaseTree:p,changedPaths:d,sessionMatchesCanonical:i===u}}async function Ye(e,t,r){
|
|
1262
|
+
await w(e,t,["check-ref-format","--branch",t.branch],r)}function lr(e,t,r){return`refs/vibe64/save/${ha.createHash("sha2\
|
|
1263
|
+
56").update(`${e.sessionId}\0${t}`).digest("hex").slice(0,32)}/${r}`}function dr(e,t){return lr(e,t,"prepared")}function ya(e){return`refs/vibe64/canonical/${ha.createHash("sha256").update(e.branch).digest("hex").slice(0,32)}`}async function yt(e,t,r,n={}){
|
|
1264
|
+
h(r)&&await w(e,t,["update-ref","-d",r],{...n,required:!1})}async function ee(e,t,r,n={}){let o=await R(e,t,["rev-parse",
|
|
1265
|
+
"--verify",`${r}^{commit}`],n);return await w(e,t,["update-ref",ya(t),o],n),o}async function wa(e,t,{baseCommit:r,canonicalCommit:n,
|
|
1266
|
+
checkpointTree:o,commandOptions:i,project:s,virtualCommit:a="",explicitBase:c=!1}){let u=a||await pr(e,t,{baseCommit:r,commandOptions:i,
|
|
1267
|
+
message:"Vibe64 session rebase input",project:s,tree:o}),l=await w(e,t,["merge-tree","--write-tree",...c?[`--merge-base=${r}`]:
|
|
1268
|
+
[],"--messages","--name-only","-z",n,u],{commandOptions:i,project:s,required:!1}),p=String(l?.stdout||l?.output||"").split(
|
|
1269
|
+
"\0"),d=h(p.shift());if(!ar(d))throw O(l?.ok===!0?"Git did not produce a valid rebased tree.":"Vibe64 could not prepare \
|
|
1270
|
+
the conflicting files for review.","vibe64_session_update_merge_invalid");if(l?.ok!==!0){let m=[];for(;p.length>0;){let f=p.
|
|
1271
|
+
shift();if(!f)break;m.push(f)}if(!m.length)throw O("Vibe64 could not identify which files conflict with the latest saved\
|
|
1272
|
+
version.","vibe64_session_update_merge_invalid");return{conflictPaths:[...new Set(m)].sort((f,g)=>f.localeCompare(g)),conflictTree:d,
|
|
1273
|
+
mergedTree:"",virtualCommit:u}}return{conflictPaths:[],conflictTree:"",mergedTree:d,virtualCommit:u}}function ba(e,t,{conflictTree:r,
|
|
1274
|
+
conflictPaths:n,project:o}){return Z({baseCommit:r,paths:n,project:G(t,o),runCommand:e,worktreePath:t.worktreePath})}async function pr(e,t,{
|
|
1275
|
+
baseCommit:r,commandOptions:n,message:o,project:i,tree:s}){return R(e,t,["commit-tree",s,"-p",r],{commandOptions:n,input:`${h(
|
|
1257
1276
|
o)||"Vibe64 virtual commit"}
|
|
1258
|
-
`,project:i})}async function
|
|
1259
|
-
n);if(!a.length)return s;let c=await
|
|
1260
|
-
join(c,"index")},
|
|
1261
|
-
let
|
|
1262
|
-
exec(String(
|
|
1263
|
-
pdate-index","--force-remove","--",d],{...
|
|
1264
|
-
recursive:!0})}}async function
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
e,t,["worktree","remove","--force",
|
|
1272
|
-
|
|
1273
|
-
e,t,["fetch","--no-tags","origin",`+refs/heads/${t.branch}:${o}`],n);let i=await
|
|
1274
|
-
e,t,i,n).then(s=>({canonicalBranch:"",commit:s}))}finally{await
|
|
1277
|
+
`,project:i})}async function mr(e,t,{commandOptions:r,derivedArtifactPaths:n=[],project:o,sourceCommit:i,tree:s}){let a=Fe(
|
|
1278
|
+
n);if(!a.length)return s;let c=await ga(pe.join(pe.dirname(t.worktreePath),".vibe64-derived-index-")),l={GIT_INDEX_FILE:pe.
|
|
1279
|
+
join(c,"index")},p={additionalAllowedRoots:[c],commandOptions:r,env:l,project:o};try{await w(e,t,["read-tree",s],p);for(let d of a){
|
|
1280
|
+
let m=await w(e,t,["ls-tree","-z",i,"--",d],{commandOptions:r,project:o}),f=/^(\d+)\s+\S+\s+([a-f0-9]{40}|[a-f0-9]{64})\t([^\0]+)\0$/u.
|
|
1281
|
+
exec(String(m.stdout||""));f&&f[3]===d?await w(e,t,["update-index","--add","--cacheinfo",f[1],f[2],d],p):await w(e,t,["u\
|
|
1282
|
+
pdate-index","--force-remove","--",d],{...p,required:!1})}return await R(e,t,["write-tree"],p)}finally{await jn(c,{force:!0,
|
|
1283
|
+
recursive:!0})}}async function Gp(e,t,r){let n=pe.dirname(t.worktreePath),o=(await jp(n).catch(()=>[])).filter(i=>i.startsWith(
|
|
1284
|
+
_a));if(o.length){for(let i of o)await jn(pe.join(n,i),{force:!0,recursive:!0});await w(e,t,["worktree","prune"],{...r,required:!1})}}async function fr(e,t,{baseCommit:r,commandOptions:n,derivedArtifactPaths:o=[],project:i,refreshDerivedArtifacts:s,tree:a}){
|
|
1285
|
+
if(!Fe(o).length)return{tree:a};await Gp(e,t,{commandOptions:n,project:i});let u=await pr(e,t,{baseCommit:r,commandOptions:n,
|
|
1286
|
+
message:"Vibe64 derived artifact input",project:i,tree:a}),l=await ga(pe.join(pe.dirname(t.worktreePath),_a)),p=pe.join(
|
|
1287
|
+
l,"source"),d={additionalAllowedRoots:[l,p],commandOptions:n,project:i},m=!1;try{await w(e,t,["worktree","add","--detach",
|
|
1288
|
+
p,u],d),m=!0;try{await s({projectRoot:p})}catch(f){return{derivedArtifactsKept:{code:String(f?.code||f?.name||"vibe64_de\
|
|
1289
|
+
rived_artifacts_unavailable"),message:String(f?.message||f)},tree:a}}return{tree:await Z({baseCommit:"HEAD",project:G(t,
|
|
1290
|
+
i),runCommand:e,worktreePath:p})}}finally{m&&await w(e,t,["worktree","remove","--force",p],{...d,required:!1}),await jn(
|
|
1291
|
+
l,{force:!0,recursive:!0}),await w(e,t,["worktree","prune"],{commandOptions:n,project:i,required:!1})}}async function Hp(e,t,r,n){await w(e,t,["remote","set-url","origin",t.remoteUrl],n);let o=lr(t,r,"canonical");try{await w(
|
|
1292
|
+
e,t,["fetch","--no-tags","origin",`+refs/heads/${t.branch}:${o}`],n);let i=await R(e,t,["rev-parse","--verify",o],n);return ee(
|
|
1293
|
+
e,t,i,n).then(s=>({canonicalBranch:"",commit:s}))}finally{await yt(e,t,o,n)}}async function Dn(e,t,r){if(await R(e,t,["b\
|
|
1275
1294
|
ranch","--show-current"],{...r,cwd:t.standaloneSourceRoot})!==t.branch)throw O(`The project baseline must have ${t.branch}\
|
|
1276
|
-
checked out before Save.`,"vibe64_session_save_local_branch_mismatch");if(await
|
|
1295
|
+
checked out before Save.`,"vibe64_session_save_local_branch_mismatch");if(await R(e,t,["status","--porcelain","--untrac\
|
|
1277
1296
|
ked-files=all"],{...r,cwd:t.standaloneSourceRoot}))throw O("The local project baseline has unsaved work. Save cannot ove\
|
|
1278
1297
|
rwrite it.","vibe64_session_save_local_authority_dirty");for(let i of["MERGE_HEAD","CHERRY_PICK_HEAD","REVERT_HEAD","REB\
|
|
1279
|
-
ASE_HEAD"])if((await
|
|
1280
|
-
"The local project baseline has an unfinished Git operation.","vibe64_session_save_local_operation_in_progress");return
|
|
1281
|
-
e,t,["rev-parse","--verify","HEAD"],{...r,cwd:t.standaloneSourceRoot})}async function
|
|
1282
|
-
["fetch","--no-tags",t.standaloneSourceRoot,`+refs/heads/${t.branch}:${i}`],n);let s=await
|
|
1298
|
+
ASE_HEAD"])if((await w(e,t,["rev-parse","--verify","-q",i],{...r,cwd:t.standaloneSourceRoot,required:!1}))?.ok===!0)throw O(
|
|
1299
|
+
"The local project baseline has an unfinished Git operation.","vibe64_session_save_local_operation_in_progress");return R(
|
|
1300
|
+
e,t,["rev-parse","--verify","HEAD"],{...r,cwd:t.standaloneSourceRoot})}async function Ke(e,t,r,n){if(t.mode!==D)return Hp(e,t,r,n);let o=await Dn(e,t,n),i=lr(t,r,"canonical");try{await w(e,t,
|
|
1301
|
+
["fetch","--no-tags",t.standaloneSourceRoot,`+refs/heads/${t.branch}:${i}`],n);let s=await R(e,t,["rev-parse","--verify",
|
|
1283
1302
|
i],n);if(s!==o)throw O("The local project baseline changed while Vibe64 was reading it.","vibe64_session_save_authority_\
|
|
1284
|
-
changed_during_read");return
|
|
1285
|
-
|
|
1286
|
-
|
|
1303
|
+
changed_during_read");return ee(e,t,s,n).then(a=>({canonicalBranch:"",commit:a}))}finally{await yt(e,t,i,n)}}function he(){}import{lstat as Vp,mkdir as zp,mkdtemp as Fp,rm as Wp}from"node:fs/promises";import hr from"node:path";var Bn="vibe64_session_worktree_written",qp="vibe64_session_update_worktree_changed",Yp="vibe64_session_update_ignored_f\
|
|
1304
|
+
ile",Kp="vibe64_session_update_head_moved";function Je(e,t,r,{baseCommit:n="HEAD",paths:o=[]}={}){return Z({baseCommit:n,
|
|
1305
|
+
paths:o,project:G(t,r),runCommand:e,worktreePath:t.worktreePath})}function Un(e){let t=e.slice(0,3).join(", ");return e.
|
|
1306
|
+
length>3?`${t} and ${e.length-3} more`:t}async function Jp(e,t){let r=[...t.values()].filter(o=>o.status==="A").map(o=>o.
|
|
1307
|
+
path);return(await Promise.all(r.map(async o=>{let i=await Vp(hr.join(e.worktreePath,o)).catch(()=>null);return i&&!i.isDirectory()?
|
|
1308
|
+
o:""}))).filter(Boolean)}async function Gn(e,t,r,n,o={}){let i=await fe(e,t,r,n,o),s=hr.join(await R(e,t,["rev-parse","-\
|
|
1309
|
+
-absolute-git-dir"],o),"vibe64-checkpoints");await zp(s,{recursive:!0});let a=await Fp(hr.join(s,".tree-switch-")),c={...o,
|
|
1310
|
+
additionalAllowedRoots:[a],env:{GIT_INDEX_FILE:hr.join(a,"index")}};try{await w(e,t,["read-tree",r],c),await w(e,t,["upd\
|
|
1311
|
+
ate-index","-q","--refresh"],c);let u=await w(e,t,["diff-files","--name-status","-z"],c),p=[...ht(u.stdout||u.output).values()].
|
|
1312
|
+
filter(g=>i.has(g.path)&&!(g.status==="D"&&i.get(g.path).status==="D")).map(g=>g.path),d=await Jp(t,i),m=d.length?await w(
|
|
1313
|
+
e,t,["check-ignore","--no-index","--stdin","-z"],{...o,input:`${d.join("\0")}\0`,required:!1}):null,f=String(m?.stdout||
|
|
1314
|
+
m?.output||"").split("\0").filter(Boolean);if(f.length)throw O(`Update would replace ${Un(f)}, which Git ignores in this\
|
|
1315
|
+
session, so it stopped and changed nothing. Move or rename ${f.length===1?"that file":"those files"}, then try Update a\
|
|
1316
|
+
gain.`,Yp,{ignoredPaths:f});if(p.push(...d),p.length)throw O(`Files changed while the session was being switched (${Un(p)}\
|
|
1317
|
+
).`,Bn,{changedPaths:p});await w(e,t,["read-tree","-m","-u",r,n],c)}finally{await Wp(a,{force:!0,recursive:!0})}}async function Hn(e,t,r,{
|
|
1318
|
+
from:n,options:o,to:i}){let s=await fe(e,t,n,i,o),a=new Map;for(let c=0;c<3;c+=1){let u=await Je(e,t,r);if(a=await fe(e,
|
|
1319
|
+
t,n,u,o),[...s.keys()].every(d=>a.has(d)))return{changes:s,moved:!0,writes:a};let l=[...a.values()].filter(d=>!(d.status===
|
|
1320
|
+
"D"&&s.get(d.path)?.status==="D")).map(d=>d.path),p=i;if(l.length)try{p=await Je(e,t,r,{baseCommit:i,paths:l})}catch(d){
|
|
1321
|
+
if(await Je(e,t,r)===u)throw d;continue}try{return await Gn(e,t,u,p,o),{changes:s,moved:!0,writes:a}}catch{}}return{changes:s,
|
|
1322
|
+
moved:!1,writes:a}}function Vn(e=[],{undone:t=!0}={}){let r=e.length?` (${Un(e)})`:"";return O(t?`A file changed while U\
|
|
1323
|
+
pdate ran${r}, so Update stopped and put this session back as it was, keeping every change. Nothing was lost. Try Update\
|
|
1324
|
+
again.`:`Files kept changing while Update ran${r}, so this session stays updated and keeps every file as last written. \
|
|
1325
|
+
Nothing was lost. Check those files before saving.`,qp,{changedPaths:e,undone:t})}function Ea(){return O("A Git commit w\
|
|
1326
|
+
as made in this session while Update ran, so Update stopped and left every file as it is, some perhaps already updated. \
|
|
1327
|
+
Nothing was lost. Try Update again.",Kp,{undone:!1})}async function va(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,
|
|
1328
|
+
mergedTree:i,oldHead:s,oldIndexTree:a,options:c,project:u,switched:l,updatedPathStatuses:p}){let d=()=>R(e,t,["rev-parse",
|
|
1329
|
+
"HEAD"],c).catch(()=>""),m=async()=>(await w(e,t,["read-tree","HEAD"],{...c,required:!1}),{headMoved:!0,undone:!1,written:[]}),
|
|
1330
|
+
f=await d();if(f!==s&&f!==r)return m();let g;if(l){let S=await Hn(e,t,u,{from:i,options:c,to:n});l=!S.moved,g=[...S.writes.
|
|
1331
|
+
keys()].filter(A=>S.changes.has(A))}else{let S=await Je(e,t,u);g=[...(await fe(e,t,o,S,c)).keys()].filter(A=>p.has(A))}let[
|
|
1332
|
+
y,_]=l?[r,s]:[s,r];return f===_&&await w(e,t,["update-ref","HEAD",y,_],{...c,required:!1}),await d()!==y?m():(l&&await ee(
|
|
1333
|
+
e,t,r,c).catch(he),(l||f===r)&&await w(e,t,["read-tree",l?r:a],{...c,required:!1}),{undone:!l,written:g})}var zn=5;async function Qp(e,t,r,n,o={}){let i=await w(e,t,["log","--topo-order",`--max-count=${zn+1}`,"-z",`--format=${sa}`,`${r}\
|
|
1334
|
+
..${n}`],o),s=ca(String(i.stdout||i.output||""));return{incomingVersions:s.slice(0,zn),incomingVersionsTruncated:s.length>
|
|
1335
|
+
zn}}function Zp(e={}){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=Array.isArray(e.conflictPaths)?[...new Set(
|
|
1287
1336
|
e.conflictPaths.map(String).filter(Boolean))].sort((n,o)=>n.localeCompare(o)):[],r={baseCommit:h(e.baseCommit),canonicalCommit:h(
|
|
1288
1337
|
e.canonicalCommit),checkpointTree:h(e.checkpointTree),conflictPaths:t,conflictTree:h(e.conflictTree),reviewId:h(e.reviewId),
|
|
1289
1338
|
oldHead:h(e.oldHead),oldIndexTree:h(e.oldIndexTree)};return Object.values(r).some(n=>Array.isArray(n)?n.length===0:!n)?null:
|
|
1290
|
-
r}function
|
|
1339
|
+
r}function em(e=[],t=""){let r=e.length,n=e.slice(0,3).join(", "),o=r>3?` and ${r-3} more`:"",i=t?` in connected reposit\
|
|
1291
1340
|
ory ${t}`:"";return`${r} ${r===1?"file":"files"}${i} ${r===1?"needs":"need"} review before this session can update: ${n}${o}\
|
|
1292
1341
|
. Resolve ${r===1?"it":"them"} manually or with AI, then use Review resolved conflicts to apply Update. Fix it with AI c\
|
|
1293
|
-
an help with the repair.`}function
|
|
1294
|
-
conflictPaths,conflictRecovery:e})}async function
|
|
1295
|
-
let s=o?
|
|
1296
|
-
ndexTree"].every(u=>s[u]===r[u])&&r.conflictPaths.every(u=>a.has(u)))||o!==s.reviewId)throw
|
|
1297
|
-
async function
|
|
1298
|
-
o,r);n=H(n,i,r,{label:"Checking repository for updates",operationId:t}),await
|
|
1299
|
-
n,i,t,{commandOptions:e,project:r}),a=s.commit,[c,u]=await Promise.all([
|
|
1300
|
-
commandOptions:e,project:r}),
|
|
1301
|
-
n,i,a,c,{commandOptions:e,project:r});if(l&&i.mode!==
|
|
1302
|
-
ession's starting version.","vibe64_session_update_history_diverged");let
|
|
1303
|
-
sessionHead:c,worktreeTree:u,changedPaths:(await
|
|
1304
|
-
[d,
|
|
1305
|
-
{commandOptions:e,project:r}),
|
|
1306
|
-
project:r}):{incomingVersions:[],incomingVersionsTruncated:!1};return{ahead:d,baseCommit:i.baseCommit,behind:
|
|
1307
|
-
canonicalSource:{authority:i.mode,commit:a,ref:`refs/heads/${s.canonicalBranch||i.branch}`,...i.mode===
|
|
1308
|
-
remoteUrl}},..._,ok:!0,operationId:t,reconciled:!l&&f,...
|
|
1309
|
-
sessionHead:c,sessionMatchesCanonical:u===g,updateAvailable:l||!f,updateStrategy:
|
|
1310
|
-
oldHead:c,oldIndexTree:u,project:l}){
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
p!==c&&await y(e,t,["update-ref","HEAD",c,p],{commandOptions:i,project:l,required:!1}),await y(e,t,["read-tree",u],{commandOptions:i,
|
|
1319
|
-
project:l,required:!1}),d}}async function pa({commandOptions:e={},operationId:t,project:r={},runCommand:n=x,session:o={}}={}){
|
|
1320
|
-
let i=U(o,r);await We(n,i,{commandOptions:e,project:r});let s=await lt({outerTurnId:`update:${t}`,outcome:"completed",project:D(
|
|
1342
|
+
an help with the repair.`}function Sa(e){return O(em(e.conflictPaths),"vibe64_session_update_conflict",{conflictPaths:e.
|
|
1343
|
+
conflictPaths,conflictRecovery:e})}async function tm(e,t,{currentRecovery:r,previousRecovery:n,reviewedConflictId:o,project:i}){
|
|
1344
|
+
let s=o?Zp(n):null;if(!s)throw Sa(r);let a=new Set(s.conflictPaths);if(!(["baseCommit","canonicalCommit","oldHead","oldI\
|
|
1345
|
+
ndexTree"].every(u=>s[u]===r[u])&&r.conflictPaths.every(u=>a.has(u)))||o!==s.reviewId)throw Sa(r);return ba(e,t,{...r,project:i})}
|
|
1346
|
+
async function Oa({commandOptions:e={},operationId:t=Ta.randomUUID(),project:r={},runCommand:n=x,session:o={}}={}){let i=U(
|
|
1347
|
+
o,r);n=H(n,i,r,{label:"Checking repository for updates",operationId:t}),await Ye(n,i,{commandOptions:e,project:r});let s=await Ke(
|
|
1348
|
+
n,i,t,{commandOptions:e,project:r}),a=s.commit,[c,u]=await Promise.all([R(n,i,["rev-parse","--verify","HEAD^{commit}"],{
|
|
1349
|
+
commandOptions:e,project:r}),Z({baseCommit:"HEAD",project:G(i,r),runCommand:n,worktreePath:i.worktreePath})]),l=await Ce(
|
|
1350
|
+
n,i,a,c,{commandOptions:e,project:r});if(l&&i.mode!==D)throw O("The saved project history no longer descends from this s\
|
|
1351
|
+
ession's starting version.","vibe64_session_update_history_diverged");let p=l?{baseCommit:i.baseCommit,canonicalCommit:a,
|
|
1352
|
+
sessionHead:c,worktreeTree:u,changedPaths:(await cr(n,i,i.baseCommit,u,{commandOptions:e,project:r})).slice(0,100)}:null,
|
|
1353
|
+
[d,m,f,g]=await Promise.all([We(n,i,a,c,{commandOptions:e,project:r}),We(n,i,c,a,{commandOptions:e,project:r}),K(n,i,a,c,
|
|
1354
|
+
{commandOptions:e,project:r}),me(n,i,a,{commandOptions:e,project:r})]),y=mt(d,m),_=m>0?await Qp(n,i,c,a,{commandOptions:e,
|
|
1355
|
+
project:r}):{incomingVersions:[],incomingVersionsTruncated:!1};return{ahead:d,baseCommit:i.baseCommit,behind:m,canonicalCommit:a,
|
|
1356
|
+
canonicalSource:{authority:i.mode,commit:a,ref:`refs/heads/${s.canonicalBranch||i.branch}`,...i.mode===D?{}:{repository:i.
|
|
1357
|
+
remoteUrl}},..._,ok:!0,operationId:t,reconciled:!l&&f,...p?{historyReview:p}:{},repositoryMode:i.mode,relationship:y,sessionCurrent:f,
|
|
1358
|
+
sessionHead:c,sessionMatchesCanonical:u===g,updateAvailable:l||!f,updateStrategy:ft(y)}}async function rm(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,commandOptions:i,mergedCommit:s,mergedTree:a,
|
|
1359
|
+
oldHead:c,oldIndexTree:u,project:l}){let p={commandOptions:i,project:l},d=await fe(e,t,o,a,p),m=!1;try{await Gn(e,t,n,s,
|
|
1360
|
+
p),m=!0,await w(e,t,["update-ref","HEAD",r,c],p),await w(e,t,["read-tree",r],p);let f=await Je(e,t,l),g=(await cr(e,t,a,
|
|
1361
|
+
f,p)).filter(y=>d.has(y));if(g.length)throw Vn(g);return await ee(e,t,r,p),{currentTree:f,reconciled:!0,status:"updated",
|
|
1362
|
+
updatedPathCount:d.size,updatedPaths:[...d.keys()].sort((y,_)=>y.localeCompare(_)).slice(0,50)}}catch(f){let{headMoved:g,
|
|
1363
|
+
undone:y,written:_}=await va(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,mergedTree:a,oldHead:c,oldIndexTree:u,
|
|
1364
|
+
options:p,project:l,switched:m,updatedPathStatuses:d});throw g?Ea():!y||_.length||f?.code===Bn?Vn(_.length?_:f?.changedPaths||
|
|
1365
|
+
[],{undone:y}):f}}async function Aa({commandOptions:e={},operationId:t,project:r={},runCommand:n=x,session:o={}}={}){let i=U(
|
|
1366
|
+
o,r);await Ye(n,i,{commandOptions:e,project:r});let s=await pt({outerTurnId:`update:${t}`,outcome:"completed",project:G(
|
|
1321
1367
|
i,r),runCommand:n,sessionId:i.sessionId,timestamp:new Date().toISOString(),worktreePath:i.worktreePath}),[a,c]=await Promise.
|
|
1322
|
-
all([
|
|
1323
|
-
checkpointCommit:s.commit,checkpointTree:s.tree,oldHead:a,oldIndexTree:c}}async function
|
|
1368
|
+
all([R(n,i,["rev-parse","HEAD"],{commandOptions:e,project:r}),R(n,i,["write-tree"],{commandOptions:e,project:r})]);return{
|
|
1369
|
+
checkpointCommit:s.commit,checkpointTree:s.tree,oldHead:a,oldIndexTree:c}}async function Ia({checkpoint:e={},commandOptions:t={},
|
|
1324
1370
|
conflictRecovery:r=null,derivedArtifactPaths:n=[],historyReview:o=null,operationId:i,project:s={},reviewedConflictId:a="",
|
|
1325
|
-
runCommand:c=x,session:u={}}={}){let l=U(u,s),{checkpointCommit:
|
|
1326
|
-
c,l,i,{commandOptions:t,project:s}),
|
|
1371
|
+
runCommand:c=x,session:u={}}={}){let l=U(u,s),{checkpointCommit:p,checkpointTree:d,oldHead:m,oldIndexTree:f}=e,{commit:g}=await Ke(
|
|
1372
|
+
c,l,i,{commandOptions:t,project:s}),y=await Ce(c,l,g,m,{commandOptions:t,project:s});if(y||o){if(l.mode!==D)throw O("The\
|
|
1327
1373
|
saved project history no longer descends from this session's starting version.","vibe64_session_update_history_diverged");
|
|
1328
|
-
let
|
|
1329
|
-
baseCommit&&r.canonicalCommit===g&&r.oldHead===
|
|
1374
|
+
let T={baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:m,worktreeTree:d};if(!(a&&r?.reviewId===a&&r.baseCommit===l.
|
|
1375
|
+
baseCommit&&r.canonicalCommit===g&&r.oldHead===m&&r.oldIndexTree===f)&&(!o||Object.entries(T).some(([N,J])=>o[N]!==J)))throw O(
|
|
1330
1376
|
"The project history was rewritten. Open Repository, check for updates, then review and reconcile this session.","vibe64\
|
|
1331
|
-
_session_history_review_required")}let _=await
|
|
1332
|
-
reconcileHistory:
|
|
1333
|
-
|
|
1334
|
-
changeBaseCommit:_.changeBaseCommit,checkpointCommit:
|
|
1335
|
-
repositoryMode:l.mode,sessionCurrent:
|
|
1336
|
-
canonicalTree;if(
|
|
1337
|
-
C=await
|
|
1377
|
+
_session_history_review_required")}let _=await qe(c,l,{baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:m,worktreeTree:d,
|
|
1378
|
+
reconcileHistory:y},{commandOptions:t,project:s}),S=new Set(Fe(n)),A=_.changedPaths.filter(T=>!S.has(T)),I=await K(c,l,g,
|
|
1379
|
+
m,{commandOptions:t,project:s});if(I&&!y)return{baseCommit:l.baseCommit,canonicalCommit:g,canonicalTree:_.canonicalTree,
|
|
1380
|
+
changeBaseCommit:_.changeBaseCommit,checkpointCommit:p,checkpointTree:d,currentTree:d,ok:!0,operationId:i,mode:l.mode,reconciled:!0,
|
|
1381
|
+
repositoryMode:l.mode,sessionCurrent:I,sessionMatchesCanonical:_.sessionMatchesCanonical,status:"already_current"};let P=_.
|
|
1382
|
+
canonicalTree;if(A.length){let T=await mr(c,l,{commandOptions:t,derivedArtifactPaths:n,project:s,sourceCommit:g,tree:d}),
|
|
1383
|
+
C=await wa(c,l,{baseCommit:_.changeBaseCommit,explicitBase:y,canonicalCommit:g,checkpointTree:T,commandOptions:t,project:s}),
|
|
1338
1384
|
N=C.conflictPaths.length>0?{baseCommit:_.changeBaseCommit,canonicalCommit:g,checkpointTree:d,conflictPaths:C.conflictPaths,
|
|
1339
|
-
conflictTree:C.conflictTree,oldHead:
|
|
1385
|
+
conflictTree:C.conflictTree,oldHead:m,oldIndexTree:f,reviewId:Ta.randomUUID()}:null;P=N?await tm(c,l,{currentRecovery:N,
|
|
1340
1386
|
previousRecovery:r,reviewedConflictId:a,project:s}):C.mergedTree}return{...e,baseCommit:l.baseCommit,canonicalCommit:g,canonicalTree:_.
|
|
1341
1387
|
canonicalTree,changeBaseCommit:_.changeBaseCommit,mergedSourceTree:P,mode:l.mode,operationId:i,repositoryMode:l.mode,sessionCurrent:!0,
|
|
1342
|
-
...
|
|
1343
|
-
prepared:r={},project:n={},refreshDerivedArtifacts:o,runCommand:i=x,session:s={}}={}){let a=U(s,n),c
|
|
1344
|
-
canonicalCommit,commandOptions:e,derivedArtifactPaths:t,project:n,refreshDerivedArtifacts:o,
|
|
1345
|
-
r.canonicalTree?r.canonicalCommit:await
|
|
1346
|
-
|
|
1347
|
-
project:r={},runCommand:n=x,session:o={}}={}){let i=U(o,r),s=await
|
|
1348
|
-
ok:!0,...s}}import{access as
|
|
1349
|
-
ebase","rebase-apply"],["cherry-pick or revert","sequencer"]];async function
|
|
1388
|
+
...A.length?{}:{sessionMatchesCanonical:!0},status:"prepared"}}async function Ra({commandOptions:e={},derivedArtifactPaths:t=[],
|
|
1389
|
+
prepared:r={},project:n={},refreshDerivedArtifacts:o,runCommand:i=x,session:s={}}={}){let a=U(s,n),{derivedArtifactsKept:c,
|
|
1390
|
+
tree:u}=await fr(i,a,{baseCommit:r.canonicalCommit,commandOptions:e,derivedArtifactPaths:t,project:n,refreshDerivedArtifacts:o,
|
|
1391
|
+
tree:r.mergedSourceTree}),l=u===r.canonicalTree?r.canonicalCommit:await pr(i,a,{baseCommit:r.canonicalCommit,commandOptions:e,
|
|
1392
|
+
message:"Vibe64 session update result",project:n,tree:u});return{...r,...c?{derivedArtifactsKept:c}:{},mergedCommit:l,mergedTree:u}}
|
|
1393
|
+
async function Pa({commandOptions:e={},prepared:t={},project:r={},runCommand:n=x,session:o={}}={}){let i=U(o,r),s=await rm(
|
|
1394
|
+
n,i,{...t,commandOptions:e,project:r});return{...t,ok:!0,...s}}import{access as nm}from"node:fs/promises";import om from"node:path";var Wn=[["merge","MERGE_HEAD"],["cherry-pick","CHERRY_PICK_HEAD"],["revert","REVERT_HEAD"],["rebase","rebase-merge"],["r\
|
|
1395
|
+
ebase","rebase-apply"],["cherry-pick or revert","sequencer"]];async function Ca({commandOptions:e={},project:t={},runCommand:r=x,
|
|
1350
1396
|
session:n={},targetCommit:o=""}={}){let i=U(n,t);r=H(r,i,t,{label:"Checking a failed session update"});let s={commandOptions:e,
|
|
1351
|
-
project:t},[a,c,u,l]=await Promise.all([
|
|
1352
|
-
flatMap(([,
|
|
1353
|
-
c,a,s),
|
|
1354
|
-
`),
|
|
1355
|
-
find((
|
|
1356
|
-
l.split("\0").filter(Boolean).map(
|
|
1357
|
-
"-z",r,n],o),
|
|
1358
|
-
s.output)}async function
|
|
1397
|
+
project:t},[a,c,u,l]=await Promise.all([R(r,i,["rev-parse","--verify","HEAD^{commit}"],s),ur(r,i,s),R(r,i,["rev-parse",...Wn.
|
|
1398
|
+
flatMap(([,S])=>["--git-path",S])],s),R(r,i,["ls-files","--unmerged","-z"],s)]),p=h(o),[d,m,f]=await Promise.all([K(r,i,
|
|
1399
|
+
c,a,s),Ce(r,i,c,a,s),ar(p)?K(r,i,p,a,s):!1]),g=u.split(`
|
|
1400
|
+
`),y=await Promise.all(Wn.map((S,A)=>!g[A]||nm(om.resolve(i.worktreePath,g[A])).then(()=>!0,I=>I?.code!=="ENOENT"))),_=Wn.
|
|
1401
|
+
find((S,A)=>y[A]);return{canonicalCommit:c,gitOperation:_?.[0]||"",sessionHead:a,targetInHead:f,unmergedPaths:[...new Set(
|
|
1402
|
+
l.split("\0").filter(Boolean).map(S=>S.slice(S.indexOf(" ")+1)))].sort(),updateNeeded:m||!d}}import Ma from"node:crypto";async function im(e,t,r,n,o={}){let[i,s]=await Promise.all([w(e,t,["diff-tree","--no-commit-id","-r","-M","--name-status",
|
|
1403
|
+
"-z",r,n],o),w(e,t,["diff-tree","--no-commit-id","-r","-M","--numstat","-z",r,n],o)]);return la(i.stdout||i.output,s.stdout||
|
|
1404
|
+
s.output)}async function ka(e,t,r,n,o={}){let{commandOptions:i={},lineLimit:s=ir,project:a={}}=o,c=Mn(n);if(!r.changedPaths.
|
|
1359
1405
|
includes(c))throw O("That file is not part of the current saved-work difference.","vibe64_session_change_not_found",{},{
|
|
1360
|
-
status:404});let u=await
|
|
1361
|
-
r.worktreeTree,"--",...
|
|
1362
|
-
changeBaseCommit,...
|
|
1363
|
-
derivedArtifactPaths:t=[],includeInitialDiff:r=!0,limit:n
|
|
1364
|
-
let u=U(a,i);s=H(s,u,i,{label:"Inspecting session changes"});let l=await
|
|
1365
|
-
runCommand:s,session:a,worktreeTree:c}),
|
|
1366
|
-
{commandOptions:e,project:i}).then(
|
|
1367
|
-
offset:o}),g=r&&f.offset===0&&
|
|
1368
|
-
initialDiff:g,...f}}async function
|
|
1369
|
-
runCommand:i=x,session:s={}}={}){let a=
|
|
1370
|
-
derivedArtifactPaths:t,project:o,runCommand:i,session:s});return
|
|
1406
|
+
status:404});let u=await w(e,t,["--no-literal-pathspecs","diff","--no-ext-diff","--find-renames","--unified=3",r.changeBaseCommit,
|
|
1407
|
+
r.worktreeTree,"--",...ma(c)],{commandOptions:i,project:a});return{canonicalCommit:r.canonicalCommit,changeBaseCommit:r.
|
|
1408
|
+
changeBaseCommit,...pa(u.stdout||u.output,s),ok:!0,path:c,worktreeTree:r.worktreeTree}}async function gr({commandOptions:e={},
|
|
1409
|
+
derivedArtifactPaths:t=[],includeInitialDiff:r=!0,limit:n=$n,offset:o=0,project:i={},runCommand:s=x,session:a={},worktreeTree:c=""}={}){
|
|
1410
|
+
let u=U(a,i);s=H(s,u,i,{label:"Inspecting session changes"});let l=await wt({commandOptions:e,derivedArtifactPaths:t,project:i,
|
|
1411
|
+
runCommand:s,session:a,worktreeTree:c}),p=new Set(l.changedPaths),d=l.unsaved?await im(s,u,l.changeBaseCommit,l.worktreeTree,
|
|
1412
|
+
{commandOptions:e,project:i}).then(y=>y.filter(_=>p.has(_.path))):[],{items:m,...f}=da(d,{defaultLimit:$n,limit:n,maxLimit:aa,
|
|
1413
|
+
offset:o}),g=r&&f.offset===0&&m.length>0?await ka(s,u,l,m[0].path,{commandOptions:e,project:i}):null;return{...l,files:m,
|
|
1414
|
+
initialDiff:g,...f}}async function qn({commandOptions:e={},derivedArtifactPaths:t=[],lineLimit:r=ir,path:n="",project:o={},
|
|
1415
|
+
runCommand:i=x,session:s={}}={}){let a=Mn(n),c=U(s,o);i=H(i,c,o,{label:"Inspecting a session change"});let u=await wt({commandOptions:e,
|
|
1416
|
+
derivedArtifactPaths:t,project:o,runCommand:i,session:s});return ka(i,c,u,a,{commandOptions:e,lineLimit:r,project:o})}async function wt({
|
|
1371
1417
|
commandOptions:e={},derivedArtifactPaths:t=[],project:r={},runCommand:n=x,session:o={},worktreeTree:i=""}={}){let s=U(o,
|
|
1372
|
-
r);n=H(n,s,r,{label:"Inspecting session work"});let a=h(i)||await
|
|
1373
|
-
worktreePath}),[c,u,l,
|
|
1374
|
-
mmit}"],{commandOptions:e,project:r}),
|
|
1375
|
-
"-z"],{commandOptions:e,project:r}),
|
|
1376
|
-
all([
|
|
1377
|
-
{commandOptions:e,project:r}),
|
|
1378
|
-
project:r})]),
|
|
1379
|
-
|
|
1380
|
-
changeBaseCommit:g.changeBaseCommit,changeBaseTree:g.changeBaseTree,changedPaths:_,destination:
|
|
1381
|
-
mode,ok:!0,repositoryMode:s.mode,relationship:
|
|
1382
|
-
tree:a,updateAvailable:f>0,updateStrategy:
|
|
1383
|
-
worktreePath}}import
|
|
1384
|
-
ave requires an assistant-generated commit subject.","vibe64_session_save_message_required",{},{status:400});return
|
|
1418
|
+
r);n=H(n,s,r,{label:"Inspecting session work"});let a=h(i)||await Z({baseCommit:"HEAD",project:G(s,r),runCommand:n,worktreePath:s.
|
|
1419
|
+
worktreePath}),[c,u,l,p]=await Promise.all([ur(n,s,{commandOptions:e,project:r}),R(n,s,["rev-parse","--verify","HEAD^{co\
|
|
1420
|
+
mmit}"],{commandOptions:e,project:r}),R(n,s,["status","--porcelain=v1","--untracked-files=all","--ignore-submodules=none",
|
|
1421
|
+
"-z"],{commandOptions:e,project:r}),R(n,s,["rev-parse","--show-toplevel"],{commandOptions:e,project:r})]),[d,m,f,g]=await Promise.
|
|
1422
|
+
all([R(n,s,["rev-parse",`${u}^{tree}`],{commandOptions:e,project:r}),We(n,s,c,u,{commandOptions:e,project:r}),We(n,s,u,c,
|
|
1423
|
+
{commandOptions:e,project:r}),qe(n,s,{baseCommit:s.baseCommit,canonicalCommit:c,sessionHead:u,worktreeTree:a},{commandOptions:e,
|
|
1424
|
+
project:r})]),y=new Set((Array.isArray(t)?t:[]).map(h).filter(Boolean)),_=g.changedPaths.filter(I=>!y.has(I)),S=mt(m,f),
|
|
1425
|
+
A=l.length===0;return{ahead:m,baseCommit:s.baseCommit,behind:f,branch:s.branch,canonicalCommit:c,canonicalTree:g.canonicalTree,
|
|
1426
|
+
changeBaseCommit:g.changeBaseCommit,changeBaseTree:g.changeBaseTree,changedPaths:_,destination:ea(r,o),dirty:a!==d||!A,mode:s.
|
|
1427
|
+
mode,ok:!0,repositoryMode:s.mode,relationship:S,sessionMatchesCanonical:_.length===0,sessionHead:u,sessionId:s.sessionId,
|
|
1428
|
+
tree:a,updateAvailable:f>0,updateStrategy:ft(S),unsaved:_.length>0,worktreeClean:A,worktreeTree:a,worktreeTopLevel:p,worktreePath:s.
|
|
1429
|
+
worktreePath}}import sm from"node:path";async function Na(e,t,{canonicalCommit:r,commandOptions:n,mergedTree:o,message:i,project:s}){let a=h(i);if(!a)throw O("S\
|
|
1430
|
+
ave requires an assistant-generated commit subject.","vibe64_session_save_message_required",{},{status:400});return R(e,
|
|
1385
1431
|
t,["commit-tree",o,"-p",r],{commandOptions:n,input:`${a}
|
|
1386
|
-
`,project:s})}async function
|
|
1387
|
-
if(await
|
|
1388
|
-
d");await
|
|
1389
|
-
cwd:t.standaloneSourceRoot});let l=await
|
|
1390
|
-
t,l,o),l}let s=["push"];t.mode===
|
|
1391
|
-
let a;i();try{a=await
|
|
1432
|
+
`,project:s})}async function xa(e,t,{canonicalCommit:r,saveCommit:n},o){let{onPublicationAttempt:i=he}=o;if(t.mode===D){
|
|
1433
|
+
if(await Dn(e,t,o)!==r)throw O("The local project baseline advanced during Save.","vibe64_session_save_authority_advance\
|
|
1434
|
+
d");await w(e,t,["fetch",t.worktreePath,n],{...o,cwd:t.standaloneSourceRoot}),i(),await w(e,t,["merge","--ff-only",n],{...o,
|
|
1435
|
+
cwd:t.standaloneSourceRoot});let l=await R(e,t,["rev-parse","HEAD"],{...o,cwd:t.standaloneSourceRoot});return await ee(e,
|
|
1436
|
+
t,l,o),l}let s=["push"];t.mode===Ve&&s.push("--push-option=vibe64-atomic"),s.push("origin",`${n}:refs/heads/${t.branch}`);
|
|
1437
|
+
let a;i();try{a=await w(e,t,s,{...o,required:!1})}catch(u){a={ok:!1,code:u.code,error:u.message}}let c;try{c=(await R(e,
|
|
1392
1438
|
t,["ls-remote","--heads","origin",`refs/heads/${t.branch}`],o)).split(/\s+/u)[0]||""}catch(u){throw O(`Save publication \
|
|
1393
1439
|
could not be confirmed. Inspect work to recover the prepared commit before retrying. ${h(u.message)}`,"vibe64_session_sa\
|
|
1394
1440
|
ve_publication_unknown",{},{messageCode:"vibe64_session_save_publication_unconfirmed",messageParams:{reason:h(u.message)}})}
|
|
1395
|
-
if(c===n)return await
|
|
1441
|
+
if(c===n)return await ee(e,t,c,o),c;if(a?.ok!==!0){if(c&&c!==r)throw O("The saved branch changed while Save was pushing \
|
|
1396
1442
|
your changes. Update this session, then save again.","vibe64_session_save_update_required",{canonicalCommit:c,reconciledCommit:r,
|
|
1397
1443
|
updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed_during_push"});let u=h(a?.stderr||a?.stdout||a?.output||
|
|
1398
|
-
a?.error)||"Git Save publication failed.";throw t.mode===
|
|
1444
|
+
a?.error)||"Git Save publication failed.";throw t.mode===Y&&/changes must be made through a pull request/iu.test(u)?O(`G\
|
|
1399
1445
|
itHub requires a pull request to update ${t.branch}. Your work remains in this session.
|
|
1400
1446
|
|
|
1401
1447
|
${u}`,"vibe64_pull_request_required"):O(u,h(a?.code)||"vibe64_session_save_git_failed",{},{status:500})}throw O("Canonic\
|
|
1402
|
-
al repository verification did not return the commit Vibe64 pushed.","vibe64_session_save_verification_failed")}function
|
|
1448
|
+
al repository verification did not return the commit Vibe64 pushed.","vibe64_session_save_verification_failed")}function $a(e,t,r,n,o){
|
|
1403
1449
|
return{attempted:o,branch:e.branch,code:r,kind:"github_mirror",message:"Your work was saved, but Vibe64 could not refres\
|
|
1404
1450
|
h its local clone cache. A later session or Save will retry it.",reason:n,retryable:!0,status:"retryable",verifiedCommit:t}}
|
|
1405
|
-
async function
|
|
1406
|
-
status:"not_applicable"};let s=t.githubMirrorPath,a=(c,u)
|
|
1407
|
-
kind:"none",retryable:!1,status:"not_applicable"};if(!s||!
|
|
1408
|
-
issing","configuration_missing");try{let[c,...u]=
|
|
1451
|
+
async function Yn(e,t,r,n={}){let{commandOptions:o={},project:i={}}=n;if(t.mode!==Y)return{attempted:!1,kind:"none",retryable:!1,
|
|
1452
|
+
status:"not_applicable"};let s=t.githubMirrorPath,a=(c,u)=>$a(t,r,c,u,!!s);if(!s&&t.githubMirrorOptional)return{attempted:!1,
|
|
1453
|
+
kind:"none",retryable:!1,status:"not_applicable"};if(!s||!sm.isAbsolute(s))return a("vibe64_session_save_github_mirror_m\
|
|
1454
|
+
issing","configuration_missing");try{let[c,...u]=kn({mirrorPath:s,remoteUrl:t.remoteUrl}),l=await _t(e,t,c,u,{additionalAllowedRoots:[
|
|
1409
1455
|
s],commandOptions:o,project:i});if(l?.ok!==!0)return a(h(l?.code)||"vibe64_session_save_github_mirror_refresh_failed","r\
|
|
1410
|
-
efresh_failed");let
|
|
1411
|
-
["--git-dir",s,"rev-parse","--verify",`refs/heads/${t.branch}^{commit}`],
|
|
1412
|
-
gin"],
|
|
1456
|
+
efresh_failed");let p={additionalAllowedRoots:[s],commandOptions:o,project:i,required:!1},[d,m]=await Promise.all([w(e,t,
|
|
1457
|
+
["--git-dir",s,"rev-parse","--verify",`refs/heads/${t.branch}^{commit}`],p),w(e,t,["--git-dir",s,"remote","get-url","ori\
|
|
1458
|
+
gin"],p)]),f=d?.ok===!0?ze(d):"",g=m?.ok===!0?ze(m):"";return f!==r||g!==t.remoteUrl?{...a("vibe64_session_save_github_m\
|
|
1413
1459
|
irror_verification_failed","verification_failed"),mirrorCommit:f}:{attempted:!0,branch:t.branch,kind:"github_mirror",mirrorCommit:f,
|
|
1414
1460
|
retryable:!1,status:"current",verifiedCommit:r}}catch{return a("vibe64_session_save_github_mirror_refresh_failed","refre\
|
|
1415
|
-
sh_interrupted")}}async function
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
project:i}
|
|
1422
|
-
|
|
1423
|
-
["
|
|
1424
|
-
|
|
1425
|
-
commandOptions:
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
baseCommit,branch:t.branch,checkpointCommit:s.commit,checkpointTree:s.tree,mode:t.mode,operationId:o,sessionHead:a}}async function Sa({
|
|
1429
|
-
commandOptions:e={},derivedArtifactPaths:t=[],limit:r=40,operationId:n=Ea.randomUUID(),project:o={},runCommand:i=x,session:s={}}={}){
|
|
1430
|
-
let a=U(s,o);i=H(i,a,o,{label:"Capturing work for Save",operationId:n});let c=await va(i,a,{commandOptions:e,operationId:n,
|
|
1431
|
-
project:o}),u=await lr({commandOptions:e,derivedArtifactPaths:t,includeInitialDiff:!1,limit:r,project:o,runCommand:i,session:s,
|
|
1461
|
+
sh_interrupted")}}async function Kn(e,t,{checkpointTree:r,commandOptions:n,project:o,saveCommit:i,sessionHead:s=""}){let a={
|
|
1462
|
+
commandOptions:n,project:o},c=await R(e,t,["rev-parse","HEAD"],a);if(c===i)return{reconciled:!0,status:"saved"};if(s&&c!==
|
|
1463
|
+
s)return{reconciled:!1,status:"published_needs_reconcile"};let{changes:u,moved:l,writes:p}=await Hn(e,t,o,{from:r,options:a,
|
|
1464
|
+
to:i}),d=p.size,m=await w(e,t,["update-ref","HEAD",i,c],{...a,required:!1});return m.ok!==!0?{error:h(m.stderr||m.output||
|
|
1465
|
+
m.error),reconciled:!1,status:"published_needs_reconcile",unsavedPathCount:d}:(await w(e,t,["read-tree",i],{...a,required:!1}),
|
|
1466
|
+
{reconciled:!0,refreshedPaths:l?[...u.keys()].filter(f=>!p.has(f)).sort():[],status:"saved",unsavedPathCount:d})}async function am(e,t,r,n,o={}){let i=dr(t,r);return await w(e,t,["update-ref",i,n],o),i}async function La(e,t,r={}){let{
|
|
1467
|
+
commandOptions:n={},operationId:o,project:i={}}=r;await Ye(e,t,{commandOptions:n,project:i});let s=await pt({outerTurnId:`\
|
|
1468
|
+
save:${o}`,outcome:"completed",project:G(t,i),runCommand:e,sessionId:t.sessionId,timestamp:new Date().toISOString(),worktreePath:t.
|
|
1469
|
+
worktreePath}),a=await R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:n,project:i});return{baseCommit:t.
|
|
1470
|
+
baseCommit,branch:t.branch,checkpointCommit:s.commit,checkpointTree:s.tree,mode:t.mode,operationId:o,sessionHead:a}}async function ja({
|
|
1471
|
+
commandOptions:e={},derivedArtifactPaths:t=[],limit:r=40,operationId:n=Ma.randomUUID(),project:o={},runCommand:i=x,session:s={}}={}){
|
|
1472
|
+
let a=U(s,o);i=H(i,a,o,{label:"Capturing work for Save",operationId:n});let c=await La(i,a,{commandOptions:e,operationId:n,
|
|
1473
|
+
project:o}),u=await gr({commandOptions:e,derivedArtifactPaths:t,includeInitialDiff:!1,limit:r,project:o,runCommand:i,session:s,
|
|
1432
1474
|
worktreeTree:c.checkpointTree});if(!u.totalCount)throw O("This session has no work to save.","vibe64_session_save_no_cha\
|
|
1433
|
-
nges");return{changes:u,checkpoint:c}}async function
|
|
1475
|
+
nges");return{changes:u,checkpoint:c}}async function cm(e,t,r,n={}){let{commandOptions:o={},operationId:i,project:s={}}=n,
|
|
1434
1476
|
a=h(r?.checkpointCommit),c=h(r?.checkpointTree);if(!a||!c||h(r?.operationId)!==h(i)||h(r?.baseCommit)!==t.baseCommit||h(
|
|
1435
1477
|
r?.branch)!==t.branch||h(r?.mode)!==t.mode)throw O("Save cannot verify the captured worktree. Capture and name the work \
|
|
1436
|
-
again.","vibe64_session_save_checkpoint_invalid");if(await
|
|
1478
|
+
again.","vibe64_session_save_checkpoint_invalid");if(await me(e,t,a,{commandOptions:o,project:s})!==c)throw O("Save cann\
|
|
1437
1479
|
ot verify the captured worktree. Capture and name the work again.","vibe64_session_save_checkpoint_invalid");let l=h(r?.
|
|
1438
|
-
sessionHead),
|
|
1480
|
+
sessionHead),p=l?await R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:s}):"";if(l&&p!==l)throw O(
|
|
1439
1481
|
"The session history changed while Vibe64 was naming this work. Save was not started; try again.","vibe64_session_save_m\
|
|
1440
|
-
essage_stale");return r}async function
|
|
1441
|
-
operationId:a,project:c={},refreshDerivedArtifacts:u}=r,l=h(n.checkpointTree),[
|
|
1442
|
-
project:c}),
|
|
1482
|
+
essage_stale");return r}async function um(e,t,r={}){let{checkpoint:n={},commandOptions:o={},derivedArtifactPaths:i=[],message:s="",
|
|
1483
|
+
operationId:a,project:c={},refreshDerivedArtifacts:u}=r,l=h(n.checkpointTree),[p,d]=await Promise.all([Ke(e,t,a,{commandOptions:o,
|
|
1484
|
+
project:c}),R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:c})]),m=p.commit;if(await Ce(e,t,m,
|
|
1443
1485
|
d,{commandOptions:o,project:c}))throw O("Canonical history no longer descends from this session's saved base.","vibe64_s\
|
|
1444
|
-
ession_save_history_diverged");let f=await K(e,t,
|
|
1445
|
-
saved branch has changed. Update this session before saving its work.","vibe64_session_save_update_required",{canonicalCommit:
|
|
1446
|
-
reconciledCommit:t.baseCommit,updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed"});let g=await
|
|
1447
|
-
{baseCommit:t.baseCommit,canonicalCommit:
|
|
1448
|
-
_=g.changedPaths.filter(
|
|
1449
|
-
hanges");let
|
|
1450
|
-
commandOptions:o,derivedArtifactPaths:i,project:c,refreshDerivedArtifacts:u,tree:
|
|
1451
|
-
|
|
1452
|
-
=%ae",
|
|
1453
|
-
|
|
1454
|
-
prepared:i={},project:s={}}=r;return
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1486
|
+
ession_save_history_diverged");let f=await K(e,t,m,d,{commandOptions:o,project:c});if(m!==t.baseCommit&&!f)throw O("The \
|
|
1487
|
+
saved branch has changed. Update this session before saving its work.","vibe64_session_save_update_required",{canonicalCommit:m,
|
|
1488
|
+
reconciledCommit:t.baseCommit,updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed"});let g=await qe(e,t,
|
|
1489
|
+
{baseCommit:t.baseCommit,canonicalCommit:m,sessionHead:d,worktreeTree:l},{commandOptions:o,project:c}),y=new Set(Fe(i)),
|
|
1490
|
+
_=g.changedPaths.filter(N=>!y.has(N));if(!_.length)throw O("This session has no work to save.","vibe64_session_save_no_c\
|
|
1491
|
+
hanges");let S=await mr(e,t,{commandOptions:o,derivedArtifactPaths:i,project:c,sourceCommit:m,tree:l}),{derivedArtifactsKept:A,
|
|
1492
|
+
tree:I}=await fr(e,t,{baseCommit:m,commandOptions:o,derivedArtifactPaths:i,project:c,refreshDerivedArtifacts:u,tree:S}),
|
|
1493
|
+
P=await Na(e,t,{canonicalCommit:m,commandOptions:o,mergedTree:I,message:s,project:c}),T=await am(e,t,a,P,{commandOptions:o,
|
|
1494
|
+
project:c}),C=await R(e,t,["show","-s","--format=%ae",P],{commandOptions:o,project:c});return{canonicalCommit:m,changeBaseCommit:g.
|
|
1495
|
+
changeBaseCommit,changedPaths:_,...A?{derivedArtifactsKept:A}:{},mergedTree:I,preparedRef:T,saveCommit:P,standInIdentity:sn(
|
|
1496
|
+
C)}}async function lm(e,t,r={}){let{commandOptions:n={},onPublicationAttempt:o,prepared:i={},project:s={}}=r;return xa(e,
|
|
1497
|
+
t,{canonicalCommit:h(i.canonicalCommit),saveCommit:h(i.saveCommit)},{commandOptions:n,onPublicationAttempt:o,project:s})}
|
|
1498
|
+
function dm(e,t,r,n,o){return{baseCommit:e.baseCommit,cacheMaintenance:o.cacheMaintenance,canonicalCommit:r.canonicalCommit,
|
|
1499
|
+
changeBaseCommit:r.changeBaseCommit,changedPaths:r.changedPaths,checkpointCommit:t.checkpointCommit,...r.derivedArtifactsKept?
|
|
1500
|
+
{derivedArtifactsKept:r.derivedArtifactsKept}:{},checkpointTree:t.checkpointTree,mergedTree:r.mergedTree,mode:e.mode,ok:!0,
|
|
1501
|
+
operationId:t.operationId,preparedRef:r.preparedRef,saveCommit:r.saveCommit,sessionHead:t.sessionHead,standInIdentity:r.
|
|
1502
|
+
standInIdentity===!0,status:o.status,verifiedCommit:n,...o}}function pm(e,t){return e.mode!==Y?{attempted:!1,kind:"none",
|
|
1503
|
+
retryable:!1,status:"not_applicable"}:{attempted:!1,branch:e.branch,kind:"github_mirror",retryable:!1,status:"deferred",
|
|
1504
|
+
verifiedCommit:t}}async function Jn({commandOptions:e={},operationId:t="",project:r={},runCommand:n=x,session:o={},verifiedCommit:i=""}={}){
|
|
1505
|
+
let s=U(o,r);return n=H(n,s,r,{label:"Maintaining saved repository cache",operationId:t}),Yn(n,s,h(i),{commandOptions:e,
|
|
1506
|
+
project:r})}async function mm(e,t,r,n={}){h(r)&&await yt(e,t,dr(t,r),n)}async function Da({checkpoint:e=null,commandOptions:t={},deferCacheMaintenance:r=!1,derivedArtifactPaths:n=[],message:o="",
|
|
1507
|
+
operationId:i=Ma.randomUUID(),project:s={},refreshDerivedArtifacts:a,runCommand:c=x,runProjectSourceExclusive:u=async d=>d(),
|
|
1508
|
+
onProgress:l=he,session:p={}}={}){let d=U(p,s);return c=H(c,d,s,{label:"Saving session work",operationId:i}),await l({kind:"\
|
|
1465
1509
|
lock",message:"Waiting for exclusive repository access.",stage:"repository-lock"}),u(async()=>{await l({baseCommit:d.baseCommit,
|
|
1466
1510
|
branch:d.branch,kind:"checkpoint",message:"Capturing the complete session worktree.",mode:d.mode,operationId:i,stage:"ch\
|
|
1467
|
-
eckpointing"});let
|
|
1468
|
-
|
|
1469
|
-
checkpointTree,kind:"checkpoint",message:"Session checkpoint captured.",stage:"checkpointed"}),
|
|
1470
|
-
message:"Reading the current canonical branch.",stage:"canonical-reading"});let f=await
|
|
1471
|
-
derivedArtifactPaths:n,message:o,operationId:i,project:s,refreshDerivedArtifacts:a}),g=!1,
|
|
1472
|
-
canonicalCommit,kind:"canonical",message:"Canonical branch read.",stage:"
|
|
1473
|
-
canonicalCommit,kind:"publish",mergedTree:f.mergedTree,message:"Save
|
|
1474
|
-
prepared"}),await l({kind:"publish",message:"Pushing the Save commit.",
|
|
1475
|
-
onPublicationAttempt(){g=!0},prepared:f,project:s})}catch(
|
|
1476
|
-
{commandOptions:t,project:s}),
|
|
1477
|
-
await l({kind:"reconcile",message:"Reconciling the
|
|
1478
|
-
c,d,{
|
|
1479
|
-
sessionHead:
|
|
1480
|
-
return
|
|
1481
|
-
|
|
1482
|
-
sessionId}`})}var
|
|
1483
|
-
return
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
String(t||""),Buffer.byteLength(e)>Fp)throw new Error("Session repository operation input is too large.");return JSON.parse(
|
|
1491
|
-
e||"{}")}function Jp(e){return{error:{code:String(e?.code||"vibe64_session_work_operation_failed"),details:e?.details&&typeof e.
|
|
1511
|
+
eckpointing"});let m;e?(await Ye(c,d,{commandOptions:t,project:s}),m=await cm(c,d,e,{commandOptions:t,operationId:i,project:s})):
|
|
1512
|
+
m=await La(c,d,{commandOptions:t,operationId:i,project:s}),await l({checkpointCommit:m.checkpointCommit,checkpointTree:m.
|
|
1513
|
+
checkpointTree,kind:"checkpoint",message:"Session checkpoint captured.",sessionHead:m.sessionHead,stage:"checkpointed"}),
|
|
1514
|
+
await l({kind:"canonical",message:"Reading the current canonical branch.",stage:"canonical-reading"});let f=await um(c,d,
|
|
1515
|
+
{checkpoint:m,commandOptions:t,derivedArtifactPaths:n,message:o,operationId:i,project:s,refreshDerivedArtifacts:a}),g=!1,
|
|
1516
|
+
y;try{await l({expectedCanonicalCommit:f.canonicalCommit,kind:"canonical",message:"Canonical branch read.",stage:"canoni\
|
|
1517
|
+
cal-read"}),await l({expectedCanonicalCommit:f.canonicalCommit,kind:"publish",mergedTree:f.mergedTree,message:"Save comm\
|
|
1518
|
+
it prepared.",proposedCommit:f.saveCommit,stage:"prepared"}),await l({kind:"publish",message:"Pushing the Save commit.",
|
|
1519
|
+
stage:"publishing"}),y=await lm(c,d,{commandOptions:t,onPublicationAttempt(){g=!0},prepared:f,project:s})}catch(A){throw g||
|
|
1520
|
+
await w(c,d,["update-ref","-d",f.preparedRef,f.saveCommit],{commandOptions:t,project:s}),A}await l({kind:"publish",message:"\
|
|
1521
|
+
Canonical Save commit verified.",stage:"published",verifiedCommit:y}),await l({kind:"reconcile",message:"Reconciling the\
|
|
1522
|
+
session onto the saved commit.",stage:"reconciling"});let _=await Kn(c,d,{checkpointTree:m.checkpointTree,commandOptions:t,
|
|
1523
|
+
project:s,saveCommit:f.saveCommit,sessionHead:m.sessionHead}),S=r?pm(d,y):await Jn({commandOptions:t,operationId:i,project:s,
|
|
1524
|
+
runCommand:c,session:p,verifiedCommit:y});return S.retryable===!0&&await l({cacheMaintenance:S,kind:"cache-warning",message:S.
|
|
1525
|
+
message,stage:"cache-maintenance-warning"}),r||await mm(c,d,i,{commandOptions:t,project:s}),dm(d,m,f,y,{cacheMaintenance:S,
|
|
1526
|
+
..._})},{operation:`save-session:${d.sessionId}`})}var fm=1024*1024,hm={"change-diff":qn,changes:gr,"check-updates":Oa,save:async e=>{let{refreshGenesisCities:t}=await import("@local/vibe64-genesis/server");
|
|
1527
|
+
return Da({...e,deferCacheMaintenance:!0,refreshDerivedArtifacts:t})},"save-maintenance":Jn,"save-message":ja,work:wt,"u\
|
|
1528
|
+
pdate-failure":Ca,"update-checkpoint":Aa,"update-prepare":Ia,"update-derived":async e=>{let{refreshGenesisCities:t}=await import("@local/vibe64-genesis/server");
|
|
1529
|
+
return Ra({...e,refreshDerivedArtifacts:t})},"update-apply":Pa},Ua=new AbortController;function gm(e={}){return be(e.command,
|
|
1530
|
+
e.args,{cwd:e.cwd,env:{...process.env,...e.env||{}},execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,outputEncoding:e.
|
|
1531
|
+
outputEncoding,signal:Ua.signal,timeout:e.timeout})}async function _m(){let e="";for await(let t of process.stdin)if(e+=
|
|
1532
|
+
String(t||""),Buffer.byteLength(e)>fm)throw new Error("Session repository operation input is too large.");return JSON.parse(
|
|
1533
|
+
e||"{}")}function ym(e){return{error:{code:String(e?.code||"vibe64_session_work_operation_failed"),details:e?.details&&typeof e.
|
|
1492
1534
|
details=="object"&&!Array.isArray(e.details)?e.details:{},message:String(e?.message||"Session repository operation faile\
|
|
1493
|
-
d."),...e?.messageCode?{messageCode:e.messageCode,messageParams:e.messageParams}:{},status:e instanceof
|
|
1494
|
-
ok:!1}}try{let e=await
|
|
1535
|
+
d."),...e?.messageCode?{messageCode:e.messageCode,messageParams:e.messageParams}:{},status:e instanceof te?e.status:500},
|
|
1536
|
+
ok:!1}}try{let e=await _m();e?.stoppable===!0&&process.once("SIGTERM",()=>Ua.abort()),Zr(e?.hostProfile||null);let t=hm[String(
|
|
1495
1537
|
e?.operation||"")];if(!t){let n=new Error("Unsupported session repository operation.");throw n.code="vibe64_session_work\
|
|
1496
|
-
_operation_unsupported",n}let r=await t({...e.input&&typeof e.input=="object"?e.input:{},runCommand:
|
|
1497
|
-
write(JSON.stringify({ok:!0,value:r}))}catch(e){process.stdout.write(JSON.stringify(
|
|
1538
|
+
_operation_unsupported",n}let r=await t({...e.input&&typeof e.input=="object"?e.input:{},runCommand:gm});process.stdout.
|
|
1539
|
+
write(JSON.stringify({ok:!0,value:r}))}catch(e){process.stdout.write(JSON.stringify(ym(e))),process.exitCode=1}
|