vibe64 0.1.60 → 0.1.61
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 +549 -547
- package/bin/upgrade-state.js +113 -105
- package/dist/assets/{GithubBrowserTabs-Vv-64NIg.js → GithubBrowserTabs-DAgQxPXI.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-rolg-sXl.js → LocalDatabaseServer-m1G8ZS5i.js} +1 -1
- package/dist/assets/{ShellOutlet-Clsh2qYP.js → ShellOutlet-CdjsJfg9.js} +1 -1
- package/dist/assets/Vibe64AuthSettingsButton-D3sB4BfM.js +5 -0
- package/dist/assets/{Vibe64AuthSettingsButton-DbL7Ukry.css → Vibe64AuthSettingsButton-DFfFPrd7.css} +1 -1
- package/dist/assets/{Vibe64ConversationLog-K6aUo3q1.js → Vibe64ConversationLog-B-L5QsVr.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-C_wkAaSb.js → Vibe64DashboardShell-CMzX3wRM.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-Dy88t2ZX.js → Vibe64DatabaseWorkspace-Dewhs6_T.js} +1 -1
- package/dist/assets/Vibe64DestinationButton-CdyyK9tj.js +1 -0
- package/dist/assets/Vibe64DestinationButton-ZxY1Lwie.css +1 -0
- package/dist/assets/{Vibe64FileArea-BU5rPyqx.js → Vibe64FileArea-DluZTu-c.js} +1 -1
- package/dist/assets/{Vibe64OutputControls-Z2K52QCc.js → Vibe64OutputControls-BfbdD25Y.js} +1 -1
- package/dist/assets/{Vibe64RepositoryWorkspace-CWw4w5SA.js → Vibe64RepositoryWorkspace-CBsySPXN.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-DI8ZH6aF.js → Vibe64SessionFiles--wtVe_KC.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-BVfoXgmZ.js → Vibe64SessionSourceEditor-BouH4fXC.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-C-99xlAo.js → Vibe64UiStoryboardView--E04EEF8.js} +2 -2
- package/dist/assets/{Vibe64UiStoryboardView-BYLWabXY.css → Vibe64UiStoryboardView-DqLN6ofL.css} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-BRB2bUR_.js → Vibe64UnavailableSessions-94bFpxMK.js} +1 -1
- package/dist/assets/_pageId_-Ch4OpUkd.js +1 -0
- package/dist/assets/_sessionId_-7PyIUeUr.css +1 -0
- package/dist/assets/_sessionId_-DGT4d2La.js +1 -0
- package/dist/assets/{_sessionTool_-CKPNp5fF.js → _sessionTool_-CBf51mfK.js} +1 -1
- package/dist/assets/_sessionTool_-DiYoi-BF.css +1 -0
- package/dist/assets/{_slug_-C5yeqlpL.js → _slug_-C8VNMRVH.js} +6 -6
- package/dist/assets/_slug_-CZmGS16g.css +1 -0
- package/dist/assets/{access-Cq6GEVhT.js → access-BAOx4iCS.js} +1 -1
- package/dist/assets/{app-BKwP6m9e.js → app-Bs6-Hv23.js} +1 -1
- package/dist/assets/{changes-DT8e3wYn.js → changes-C6eMQ9YE.js} +1 -1
- package/dist/assets/{client-CUQfIUus.css → client-BBJzQIWS.css} +1 -1
- package/dist/assets/{client-C-Rw8t8y.js → client-CIF5Y1Aj.js} +1 -1
- package/dist/assets/{client-B_iZQVU8.js → client-CVgL_ShV.js} +1 -1
- package/dist/assets/{client-Cf6iimPy.js → client-HWj_BNVZ.js} +2 -2
- package/dist/assets/{client-BHa4BumO.js → client-qAKnahkF.js} +2 -2
- package/dist/assets/{client-DWPSlYBq.js → client-qpL_kR4u.js} +2 -2
- package/dist/assets/{conversation-CsB1b1JZ.js → conversation-DbF0OrZB.js} +3 -3
- package/dist/assets/{conversation-DA_fbJJD.css → conversation-ZN3-8jbz.css} +1 -1
- package/dist/assets/{dashboard-DRwBugiR.js → dashboard-CzLsa0w0.js} +1 -1
- package/dist/assets/{english-definitions-Bi3yaDu7.js → english-definitions-BA8v5wP1.js} +1 -1
- package/dist/assets/{env-ObiVMW6f.js → env-BqJ_GWbz.js} +1 -1
- package/dist/assets/{error-kdRkyK9x.js → error-BQ7r64JO.js} +1 -1
- package/dist/assets/{error-CX8_snYL.js → error-BqMxhgpB.js} +1 -1
- package/dist/assets/{health-Ev-UBIsw.js → health-CIqrHpVK.js} +1 -1
- package/dist/assets/{history-U6UcbKBZ.js → history-BCjhpyP8.js} +1 -1
- package/dist/assets/{i18n-B5lc019_.js → i18n-Dm74yE_M.js} +1 -1
- package/dist/assets/{index-Wcdz2Rey.js → index-fXKdz8oR.js} +5 -5
- package/dist/assets/{integrations-Bo_beIy3.css → integrations-CwgrZgmM.css} +1 -1
- package/dist/assets/{integrations-BHURBo17.js → integrations-cgbpgNNd.js} +11 -4
- package/dist/assets/issues-AhouA6nE.js +1 -0
- package/dist/assets/issues-D46llNv-.css +1 -0
- package/dist/assets/{learning-BrBAyLFt.js → learning-DZXWgVEW.js} +1 -1
- package/dist/assets/{pages-BTk_FkDr.js → pages-BUUwIXBf.js} +1 -1
- package/dist/assets/{project-files-CTGwnBh7.js → project-files-BS2gdDSz.js} +1 -1
- package/dist/assets/{publish-BYZ7KRzq.js → publish-Bq_LPmX2.js} +1 -1
- package/dist/assets/pull-requests-BvChbjCD.js +1 -0
- package/dist/assets/pull-requests-DtqrTix0.css +1 -0
- package/dist/assets/{repository-DknGo0hr.js → repository-Dkow-18G.js} +1 -1
- package/dist/assets/{settings-BmOQ1NnW.js → settings-r5RWQVzw.js} +1 -1
- package/dist/assets/{useArchivedVibe64Sessions-DI9ow2ds.js → useArchivedVibe64Sessions-C0MVJuyX.js} +1 -1
- package/dist/assets/useAssistantAttachments-BkYZckgz.js +2 -0
- package/dist/assets/{useCommand-YOAaO5Wz.js → useCommand-CNDe8gM-.js} +1 -1
- package/dist/assets/{useUiFeedback-Bixow9mW.js → useUiFeedback-CWb6o71Z.js} +1 -1
- package/dist/assets/{useVibe64ConversationLog-BkcPA64C.js → useVibe64ConversationLog-CUWEZhnf.js} +2 -2
- package/dist/assets/{useVibe64SessionData-Df7M5k1M.js → useVibe64SessionData-kGr7R7lG.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-B0USk6X6.js → useVibe64SessionSelection-BZ7WnRv0.js} +1 -1
- package/dist/assets/vibe64RepositoryRealtime-R5QhcJ4H.js +1 -0
- package/dist/assets/vibe64SessionFocus-BCojr4E-.css +1 -0
- package/dist/assets/vibe64SessionFocus-CHKCMxcJ.js +1 -0
- package/dist/index.html +10 -10
- package/docs/colleague-usage/back-navigation.md +16 -13
- package/docs/colleague-usage/coding-agent-goal-pause.md +15 -1
- package/docs/colleague-usage/coding-agent-goals.md +23 -3
- package/docs/colleague-usage/colleague-watches.md +1 -1
- package/docs/colleague-usage/connected-projects.md +1 -1
- package/docs/colleague-usage/dashboard-navigation.md +14 -11
- package/docs/colleague-usage/database.md +1 -1
- package/docs/colleague-usage/development-env.md +21 -12
- package/docs/colleague-usage/github-work.md +1 -1
- package/docs/colleague-usage/integrations.md +2 -2
- package/docs/colleague-usage/learning-teacher-guide.md +3 -2
- package/docs/colleague-usage/pages.md +1 -2
- package/docs/colleague-usage/project-messages.md +1 -1
- package/docs/colleague-usage/session-archive.md +3 -1
- package/docs/colleague-usage/sessions.md +3 -3
- package/docs/colleague-usage/ui-pass.md +1 -1
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +4 -1
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/CHANGELOG.md +4 -0
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/kernel/package.json +3 -1
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +2 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-ai-tasks/package.json +2 -1
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +484 -468
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +59 -59
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +93 -67
- package/node_modules/@local/vibe64-genesis/src/server/index.js +463 -453
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +60 -58
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +285 -282
- package/package.json +14 -14
- package/server.bundle.mjs +26461 -26434
- package/dist/assets/Vibe64AuthSettingsButton-BICxvZDm.js +0 -5
- package/dist/assets/_pageId_-DPJ8pvUs.js +0 -1
- package/dist/assets/_sessionId_-B5V2Fs2n.css +0 -1
- package/dist/assets/_sessionId_-CiU1Awul.js +0 -1
- package/dist/assets/_sessionTool_-Be88HWbv.css +0 -1
- package/dist/assets/_slug_-Vy_1jrpy.css +0 -1
- package/dist/assets/issues-D4Asc_wa.css +0 -1
- package/dist/assets/issues-DEzrDqDU.js +0 -1
- package/dist/assets/pull-requests-C-puL4SG.js +0 -1
- package/dist/assets/pull-requests-DgWKsMdI.css +0 -1
- package/dist/assets/useAssistantAttachments-CkseokGM.js +0 -2
- package/dist/assets/vibe64RepositoryRealtime-DKSXVg1B.js +0 -1
- package/dist/assets/vibe64SessionFocus-BJLy8eTE.js +0 -1
- package/dist/assets/vibe64SessionFocus-DdYRpG72.css +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
2
|
-
var
|
|
3
|
-
status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=
|
|
4
|
-
(this.messageCode=String(n.messageCode),this.messageParams=
|
|
2
|
+
var ym=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 wr(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=wr(n.params),n.messageCode&&
|
|
4
|
+
(this.messageCode=String(n.messageCode),this.messageParams=wr(n.messageParams)),this.details=n.details,this.headers=n.headers||
|
|
5
5
|
{}}};function $(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||
|
|
6
|
-
Va(t)}function Va(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}function
|
|
6
|
+
Va(t)}function Va(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}function yr(e){return e!==null&&typeof e=="object"&&$(e.structure)&&$(e.operations)&&typeof e.validateWith=="function"&&
|
|
7
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(
|
|
8
|
+
let{items:r}=t;if(yr(r))return{kind:"schema",schema:r};if(!$(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
9
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(
|
|
10
|
+
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(yr(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
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(!
|
|
16
|
+
s: true.`);if(r){if(!yr(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
|
|
17
17
|
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Xe(
|
|
18
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
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.
|
|
@@ -81,11 +81,11 @@ function Tt(e){return Ar(e)?{allOf:[e]}:e}function mc(e,t,r,n,o){return e.nodes.
|
|
|
81
81
|
r&&i.operation===n&&i.additionalProperties===o)||null}function fc(e,t){let r=pc(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
82
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
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
|
|
84
|
+
fc(s,r),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function wo(e,t){
|
|
85
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
86
|
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=hc(e.schema,t,e.operationName,e.operation,e.additionalProperties);
|
|
87
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:"#"}:
|
|
88
|
+
let i=Ot(t),s=_o(e,t,r,n,o);return i.rootNode===s?{$ref:"#"}:wo(s,t)}function Ze(e,{referenceBacked:t=!1}={}){return{schema:e,
|
|
89
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
90
|
n)),n.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
|
|
91
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,
|
|
@@ -93,27 +93,27 @@ n,"replace",s.schema.operations.replace,!1)),[ie]:{castType:"object"}};let a=r.i
|
|
|
93
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
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
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
|
|
96
|
+
place"?e.operations.replace:i;return kr(e,`${t}.*`,s.definition,n,a,c)}function wc(e,t,r,n,o,i){if(r.type==="object"){let a=vt(
|
|
97
97
|
t,r);if(a.kind==="nested")return Ze(Cr(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
98
98
|
"opaque")return Ze({type:"object",additionalProperties:!0});if(a.kind==="map")return Ze({type:"object",additionalProperties:_c(
|
|
99
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
100
|
Array.isArray(s))throw new Error(`Type '${r.type}' on field '${t}' returned an invalid JSON Schema fragment.`);if(r.type===
|
|
101
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=
|
|
102
|
+
function kr(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n},a=wc(e,t,r,n,o,i),c=a.referenceBacked?
|
|
103
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
|
|
104
|
+
continue;let p=cc(e,d,t);if(!p)continue;let f=p({...s,parameterName:d,parameterValue:r[d],fieldSchema:{...c}});f&&ic(c,f)}
|
|
105
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
|
|
106
|
+
let m=Tt(sc(c,l));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.defaultTo!="function"){let d=e._normalizeDefault(
|
|
107
107
|
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
108
|
-
o,i,{})});if(Object.keys(d.errors).length>0){let
|
|
109
|
-
nvalid (${
|
|
108
|
+
o,i,{})});if(Object.keys(d.errors).length>0){let p=Object.values(d.errors)[0];throw new Error(`defaultTo for "${t}" is i\
|
|
109
|
+
nvalid (${p.code}).`)}m.default=d.value}else u.defaults={providedByFunction:!0};return m[ie]=u,m}function yo(e,t={}){let r=dc(
|
|
110
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,...
|
|
112
|
-
Me}function
|
|
111
|
+
o,i,{root:!0}),c={$schema:ec,...wo(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 yc(){return{self:!1,children:{}}}function Eo(e){return Object.keys(e.children).length>0}function _e(e,t){return`${e}\
|
|
113
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
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
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,
|
|
116
|
+
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||b(o,s,yc()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
117
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
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].
|
|
119
119
|
sort((t,r)=>{let n=/^[0-9]+$/.test(t),o=/^[0-9]+$/.test(r);return n&&o?Number(t)-Number(r):n?-1:o?1:t.localeCompare(r)})}
|
|
@@ -168,19 +168,19 @@ has(i))&&(!s&&!n.defaultedFields.has(i)||b(o,i,r[i]))}return o}_resolveObjectFie
|
|
|
168
168
|
return Et(t,r)}_resolveObjectValuesConfig(t,r){return Xe(t,r)}_buildArrayItemSettings(t,r){return t.type==="object"&&Object.
|
|
169
169
|
hasOwn(t,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(t,r,n,o,i,s,a,c){let u=t.
|
|
170
170
|
nullable===!0||a.nullable===!0,l=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,t.type))throw new Error(
|
|
171
|
-
`No casting function for type: ${t.type}`);let
|
|
171
|
+
`No casting function for type: ${t.type}`);let m=this.types[t.type];if(r===null)return u?(b(o,i,null),{errors:{},shouldContinue:!1}):
|
|
172
172
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
173
173
|
if(r===""&&l)return b(o,i,null),{errors:{},shouldContinue:!1};let d={schema:this,definition:t,value:r,fieldName:n,object:o,
|
|
174
174
|
objectBeforeCast:s,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
175
|
-
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(
|
|
176
|
-
n,
|
|
177
|
-
i,
|
|
175
|
+
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(p,f,g)=>{throw this._paramError(
|
|
176
|
+
n,p,f,g)}};try{let p=m(d);if(bo(p))throw new Error(`Type handler for "${t.type}" must be synchronous.`);p!==void 0&&(b(o,
|
|
177
|
+
i,p),d.value=p)}catch(p){if(p.errorObject)return{errors:this._singleErrorMap(p.errorObject),shouldContinue:!1};throw p}return{
|
|
178
178
|
errors:{},context:d,shouldContinue:!0}}_runFieldValidators(t,r,n,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
|
|
179
179
|
_paramToBeSkipped(a,s.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{i.parameterName=
|
|
180
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
181
|
(b(n,o,u),i.value=u)}catch(u){if(u.errorObject)return this._singleErrorMap(u.errorObject);throw u}}return{}}_normalizeAndValidateValue(t,r,n,o,i,s,a,c){
|
|
182
182
|
let u=this._castValue(t,r,n,o,i,s,a,c);if(Object.keys(u.errors).length>0)return u.errors;if(!u.shouldContinue)return{};let{
|
|
183
|
-
context:l}=u,
|
|
183
|
+
context:l}=u,m=this._validateNestedValue(t,n,o,i,a,c);return Object.keys(m).length>0?m:(l.value=o[i],this._runFieldValidators(
|
|
184
184
|
t,n,o,i,l,a))}_normalizeDefault(t,r,{fieldPath:n,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
|
|
185
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){
|
|
186
186
|
if(t.type==="object"){let c=this._resolveObjectFieldMode(r,t);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
@@ -192,15 +192,15 @@ a,t.schema,u.validatedObject):u.validatedObject),xe(u.errors,r)}_extractKnownObj
|
|
|
192
192
|
entries(t))Object.hasOwn(r.structure,o)&&b(n,o,i);return n}_mergeKnownAndPassthroughObjectFields(t,r,n){let o={};for(let i of Object.
|
|
193
193
|
keys(t)){if(!Object.hasOwn(r.structure,i)){b(o,i,t[i]);continue}Object.hasOwn(n,i)&&b(o,i,n[i])}for(let[i,s]of Object.entries(
|
|
194
194
|
n))Object.hasOwn(o,i)||b(o,i,s);return o}_validateObjectValues(t,r,n,o,i,s){let a=r[n],c={...a},u={};b(r,n,c);for(let l of Object.
|
|
195
|
-
keys(a)){let
|
|
196
|
-
_mergeErrors(u,this._singleErrorMap(this._typeError(
|
|
197
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,d,$e(i,
|
|
198
|
-
u,xe(f.errors,
|
|
199
|
-
definition,s));this._mergeErrors(u,
|
|
200
|
-
c.length;l++){let
|
|
201
|
-
this._mergeErrors(u,this._singleErrorMap(this._typeError(
|
|
202
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],$e(i,
|
|
203
|
-
u,xe(
|
|
195
|
+
keys(a)){let m=_e(t,l);if(this._fieldToBeSkipped(m,i))continue;let d=c[l];if(d===void 0){s.rejectExplicitUndefined?this.
|
|
196
|
+
_mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let f=o.
|
|
197
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,d,$e(i,m));b(c,l,f.validatedObject),this._mergeErrors(
|
|
198
|
+
u,xe(f.errors,m));continue}let p=this._normalizeAndValidateValue(o.definition,d,m,c,l,a,i,this._buildArrayItemSettings(o.
|
|
199
|
+
definition,s));this._mergeErrors(u,p)}return u}_validateArrayItems(t,r,n,o,i,s){let a=r[n],c=a.slice(),u={};b(r,n,c);for(let l=0;l<
|
|
200
|
+
c.length;l++){let m=_e(t,l);if(this._fieldToBeSkipped(m,i))continue;if(!Object.hasOwn(a,l)||c[l]===void 0){s.rejectExplicitUndefined?
|
|
201
|
+
this._mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let p=o.
|
|
202
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],$e(i,m));b(c,l,p.validatedObject),this._mergeErrors(
|
|
203
|
+
u,xe(p.errors,m));continue}let d=this._normalizeAndValidateValue(o.definition,c[l],m,c,l,a,i,this._buildArrayItemSettings(
|
|
204
204
|
o.definition,s));this._mergeErrors(u,d)}return u}_validateField(t,r,n,o,i){if(!Object.hasOwn(this.structure,t))return{};
|
|
205
205
|
let s=this.structure[t];if(this._fieldToBeSkipped(t,o))return{};let a=i.isFieldPresent(t),c=r[t],u=c===void 0;return i.enforceRequired&&
|
|
206
206
|
s.required&&(!a||u)&&!this._paramToBeSkipped("required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"\
|
|
@@ -210,37 +210,37 @@ s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Objec
|
|
|
210
210
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let u=this._validateField(
|
|
211
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)&&
|
|
212
212
|
this.structure[c].defaultTo!==void 0){let u=this.structure[c],l=typeof u.defaultTo=="function"?u.defaultTo():u.defaultTo,
|
|
213
|
-
|
|
214
|
-
_mergeErrors(i,
|
|
213
|
+
m=this._normalizeDefault(u,l,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
214
|
+
_mergeErrors(i,m.errors),Object.keys(m.errors).length>0)continue;b(s,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
215
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
216
|
let u=Io(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${u}".`);let l=this._validateSelectedField(
|
|
217
217
|
c,t[c],r,a,n,o,u);this._mergeErrors(s,l)}return{validatedObject:a,errors:s}}_validateSelectedField(t,r,n,o,i,s,a){if(!Object.
|
|
218
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
|
|
220
|
-
a)&&this._mergeErrors(
|
|
219
|
+
let m=Object.hasOwn(n,t),d=n[t],p={};if(!m){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("required",i.skipParams,
|
|
220
|
+
a)&&this._mergeErrors(p,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),u&&s.applyDefaults&&
|
|
221
221
|
c.defaultTo!==void 0){let _=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,S=this._normalizeDefault(c,_,{fieldPath:a,
|
|
222
|
-
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(
|
|
223
|
-
length===0&&b(o,t,S.value)}return
|
|
222
|
+
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(p,S.errors),Object.keys(S.errors).
|
|
223
|
+
length===0&&b(o,t,S.value)}return p}if(d===void 0)return u&&s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
224
224
|
a).errorObject):{};let f={[t]:d};if(u){let _=this._normalizeAndValidateValue(c,d,a,f,t,n,i,s);return Object.hasOwn(f,t)&&
|
|
225
225
|
f[t]!==void 0?b(o,t,f[t]):f[t]===null&&b(o,t,null),_}if(!l)return{};let g=this._castValue(c,d,a,f,t,n,i,s);if(Object.keys(
|
|
226
|
-
g.errors).length>0)return g.errors;if(!g.shouldContinue)return{};let
|
|
227
|
-
f,t,i,s);return At(f[t])&&b(o,t,f[t]),
|
|
226
|
+
g.errors).length>0)return g.errors;if(!g.shouldContinue)return{};let w=this._validateSelectedDescendants(c,r.children,a,
|
|
227
|
+
f,t,i,s);return At(f[t])&&b(o,t,f[t]),w}_validateSelectedDescendants(t,r,n,o,i,s,a){if(t.type==="object"){let c=this._resolveObjectFieldMode(
|
|
228
228
|
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!$(
|
|
229
229
|
u))return{};let l=c.schema._validateSelectedTree(r,u,$e(s,n),{...a,defaultedFields:new Set});return b(o,i,l.validatedObject),
|
|
230
230
|
xe(l.errors,n)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(n,t);if(!c)throw new Error(`Schema path "${n}" d\
|
|
231
231
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,i,c,r,s,a)}throw new Error(
|
|
232
232
|
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],u=r[n],
|
|
233
|
-
l={};b(r,n,c);for(let
|
|
234
|
-
id because array segments must use numeric indexes.`);let d=Number(
|
|
235
|
-
|
|
236
|
-
if(_===void 0){g&&a.rejectExplicitUndefined&&b(l,
|
|
237
|
-
let C=o.schema._validateWithOperation("replace",o.schema.operations.replace,_,$e(s,
|
|
238
|
-
this._mergeErrors(l,xe(C.errors,
|
|
233
|
+
l={};b(r,n,c);for(let m of To(Object.keys(i))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${_e(t,m)}" is inval\
|
|
234
|
+
id because array segments must use numeric indexes.`);let d=Number(m),p=_e(t,d),f=i[m],g=f.self===!0,w=Eo(f);if(this._fieldToBeSkipped(
|
|
235
|
+
p,s))continue;if(!Object.hasOwn(u,d)){g&&a.rejectExplicitUndefined&&b(l,p,this._typeError(p).errorObject);continue}let _=u[d];
|
|
236
|
+
if(_===void 0){g&&a.rejectExplicitUndefined&&b(l,p,this._typeError(p).errorObject);continue}if(o.kind==="schema"){if(g){
|
|
237
|
+
let C=o.schema._validateWithOperation("replace",o.schema.operations.replace,_,$e(s,p));At(C.validatedObject)&&b(c,d,C.validatedObject),
|
|
238
|
+
this._mergeErrors(l,xe(C.errors,p));continue}if(!w)continue;let T=o.schema._validateSelectedTree(f.children,_,$e(s,p),{...a,
|
|
239
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,
|
|
241
|
-
o.definition,_,
|
|
242
|
-
continue}if(!
|
|
243
|
-
l,I.errors);continue}if(!I.shouldContinue)continue;let P=this._validateSelectedDescendants(o.definition,f.children,
|
|
240
|
+
this._mergeErrors(l,xe(T.errors,p));continue}let S=this._buildArrayItemSettings(o.definition,a),A=[_];if(g){let T=this._normalizeAndValidateValue(
|
|
241
|
+
o.definition,_,p,A,0,u,s,S);Object.hasOwn(A,0)&&A[0]!==void 0?b(c,d,A[0]):A[0]===null&&b(c,d,null),this._mergeErrors(l,T);
|
|
242
|
+
continue}if(!w)continue;let I=this._castValue(o.definition,_,p,A,0,u,s,S);if(Object.keys(I.errors).length>0){this._mergeErrors(
|
|
243
|
+
l,I.errors);continue}if(!I.shouldContinue)continue;let P=this._validateSelectedDescendants(o.definition,f.children,p,A,0,
|
|
244
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(
|
|
245
245
|
`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(t,r),this._validateWithOperation(
|
|
246
246
|
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Mr(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
@@ -250,13 +250,13 @@ isArray(t)||t.length===0)throw new Error("validatePaths() expects a non-empty ar
|
|
|
250
250
|
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(So(t),r,s,this.
|
|
251
251
|
_buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.keys(this.operations)){if(t in this)throw new Error(
|
|
252
252
|
`Operation name "${t}" is reserved and cannot be used as a schema method.`);this[t]=(r,n={})=>this.validateWith(t,r,n)}}toJsonSchema(t={}){
|
|
253
|
-
return
|
|
253
|
+
return yo(this,t)}getFieldDefinitions(){return xr.has(this)||xr.set(this,Nr(this.structure)),xr.get(this)}getFieldDefinition(t){
|
|
254
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
255
|
return r===null?null:Nr(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
256
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,
|
|
258
|
-
{"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=Ic(i[a++],u,r);return"["+s.join(",")+"]";function u(l,
|
|
259
|
-
|
|
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,m)=>l===""||-1<t.indexOf(l)?m: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,m){if(c)return c=!c,
|
|
259
|
+
m;let d=n.call(this,l,m);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
260
|
"object"||typeof e=="function")&&typeof e.then=="function"}function No(e){if(typeof e=="number")return Number.isFinite(e)?
|
|
261
261
|
e:null;if(typeof e=="bigint"){let t=Number(e);return Number.isSafeInteger(t)?t:null}if(typeof e=="string"){let t=e.trim();
|
|
262
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;
|
|
@@ -345,15 +345,15 @@ for(let[r,n]of Object.entries(e))for(let o of Object.keys(n)){if(t.has(o))throw
|
|
|
345
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
346
|
throw new TypeError(`${t} must be a function when provided.`);return e}function Nt({id:e,requires:t={},optional:r={},provides:n={},
|
|
347
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`),
|
|
349
|
-
`${c}.setup is required.`);return Object.freeze({id:c,requires:u,optional:l,provides:
|
|
348
|
+
nal`),m=Ur(n,`${c}.provides`);Fc({requires:u,optional:l,provides:m});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:m,hints:zc(o,u,c),setup:d,boot:Br(s,
|
|
350
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\
|
|
351
351
|
tration is closed after the first payload is resolved.");let l=h(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
352
352
|
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
|
|
353
353
|
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
|
|
354
|
-
isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u=e.map((l,
|
|
355
|
-
(l,
|
|
356
|
-
freeze({...F(a)?a:{},payload:Object.freeze({...c})}));c={...c,...F(
|
|
354
|
+
isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u=e.map((l,m)=>({entry:l,index:m})).sort(
|
|
355
|
+
(l,m)=>l.entry.order-m.entry.order||l.index-m.index).map(({entry:l})=>l);for(let l of u){let m=await l.contribute(Object.
|
|
356
|
+
freeze({...F(a)?a:{},payload:Object.freeze({...c})}));c={...c,...F(m)?m:{}}}return Object.freeze(c)}function i(){return Object.
|
|
357
357
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
358
358
|
return s}var qc=Nt({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:e}){
|
|
359
359
|
let t=Hr();return e.router.register("GET",Fo,{auth:Vo,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
|
|
@@ -379,15 +379,15 @@ e()||""));return{displayName:String(r?.username||n),gid:Number.isSafeInteger(r?.
|
|
|
379
379
|
""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}async function xt(e="",{execFileFn:t=tu,platform:r=process.platform,
|
|
380
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\
|
|
381
381
|
itch.conf","utf8").catch(()=>"")).matchAll(/^[\t ]*passwd[\t ]*:[\t ]*([^#\r\n]*)/gmu)],u=c.length===1?c[0][1].trim().split(
|
|
382
|
-
/\s+/u):[];if(u[0]==="files"&&(u.length===1||/^[a-z_][a-z0-9_-]*$/iu.test(u[1]))){let
|
|
383
|
-
()=>"")).split(/\r?\n/u).map(Fr).find(d=>d?.username===i);if(
|
|
382
|
+
/\s+/u):[];if(u[0]==="files"&&(u.length===1||/^[a-z_][a-z0-9_-]*$/iu.test(u[1]))){let m=(await n("/etc/passwd","utf8").catch(
|
|
383
|
+
()=>"")).split(/\r?\n/u).map(Fr).find(d=>d?.username===i);if(m)return m}}let s;if(r==="darwin"){let a=et({userInfo:o});if(a.
|
|
384
384
|
username===i)return a;[s]=ru(await Wo(t,"dscacheutil",["-q","user","-a","name",i]))}else s=Fr((await Wo(t,"getent",["pas\
|
|
385
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\
|
|
386
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
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
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
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
|
|
390
|
+
([t,r])=>[E(t),String(r??"")]).filter(([t])=>!!t))}function we(e=[]){let t=[],r=new Set;for(let n of Array.isArray(e)?e:
|
|
391
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
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
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={}){
|
|
@@ -395,11 +395,11 @@ return Yr(await xt(e,t))}function tt(e={},t={}){let r=Yr(e);return{...t,HOME:r.h
|
|
|
395
395
|
join(r.home,".cache"),XDG_CONFIG_HOME:qr.join(r.home,".config"),XDG_DATA_HOME:qr.join(r.home,".local","share")}}function Ko(){
|
|
396
396
|
return{gid:typeof process.getgid=="function"?process.getgid():null,uid:typeof process.getuid=="function"?process.getuid():
|
|
397
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:
|
|
399
|
-
let
|
|
400
|
-
`)).trim();return{code:E(e),error:E(t),exitCode:
|
|
401
|
-
Number(s):null,signal:E(a),stderr:g,stdout:f,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...
|
|
402
|
-
ct"&&!Array.isArray(
|
|
398
|
+
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:l=!1,execution:m=null,retryable:d=null}={}){
|
|
399
|
+
let p=ou(r),f=String(u||""),g=String(c||""),w=String(o||[f,g].filter(Boolean).join(`
|
|
400
|
+
`)).trim();return{code:E(e),error:E(t),exitCode:p,ok:n===null?p===0:n===!0,output:w,pid:Number.isSafeInteger(Number(s))?
|
|
401
|
+
Number(s):null,signal:E(a),stderr:g,stdout:f,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...m&&typeof m=="obje\
|
|
402
|
+
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof d=="boolean"?{retryable:d}:{}}}function L(e="",t="vibe64_command_faile\
|
|
403
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
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
405
|
import{stripVTControlCharacters as uu}from"node:util";var Jo=1e8,Qo=5e3,lu=Object.freeze({SIGABRT:"Aborted",SIGALRM:"Tim\
|
|
@@ -424,37 +424,37 @@ mu(hu(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${gu(e)}:
|
|
|
424
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>
|
|
425
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)),
|
|
426
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)},
|
|
428
|
-
d=iu(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[
|
|
429
|
-
|
|
430
|
-
f=!1,g=null,
|
|
431
|
-
()=>{!f&&d.kill("SIGKILL")&&(
|
|
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)},m=o!=null,
|
|
428
|
+
d=iu(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[m?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
429
|
+
p={commandLine:fu(e,t),cwd:au.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
430
|
+
f=!1,g=null,w=()=>{};d.on("error",P=>{p.spawnError||=P,d.pid===void 0&&w()});let _=()=>{f||!d.kill("SIGTERM")||g||(g=setTimeout(
|
|
431
|
+
()=>{!f&&d.kill("SIGKILL")&&(p.forcefullyTerminated=!0)},Qo))},S=(P,T)=>C=>{if(l.all.write(C),l[P].write(C)||(p.maxBuffer||=
|
|
432
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)),
|
|
434
|
-
d.stdin.end(o));let A=c>0?setTimeout(()=>{
|
|
435
|
-
f=!0,clearTimeout(A),clearTimeout(g);let N=
|
|
436
|
-
J=
|
|
437
|
-
shortMessage:J?_u({...
|
|
438
|
-
once("close",
|
|
439
|
-
import Su from"node:path";import{fileURLToPath as Tu}from"node:url";var
|
|
440
|
-
Iu=Tu(new URL("./detachedReaper.js",
|
|
433
|
+
on("data",S("stdout",d.stdout)),d.stderr&&d.stderr.on("data",S("stderr",d.stderr)),m&&d.stdin&&(d.stdin.on("error",()=>{}),
|
|
434
|
+
d.stdin.end(o));let A=c>0?setTimeout(()=>{p.timedOut=!0,_()},c):null;return{completion:new Promise(P=>{w=(T,C)=>{if(f)return;
|
|
435
|
+
f=!0,clearTimeout(A),clearTimeout(g);let N=p.spawnError?{}:{exitCode:typeof T=="number"&&T>=0?T:void 0,signal:C||void 0},
|
|
436
|
+
J=p.spawnError||p.timedOut||p.maxBuffer||N.exitCode!==0;P({all:l.all.text(),code:p.spawnError?.code,exitCode:N.exitCode,
|
|
437
|
+
shortMessage:J?_u({...p,...N}):"",signal:N.signal,stderr:l.stderr.text(),stdout:l.stdout.text(),timedOut:p.timedOut})},d.
|
|
438
|
+
once("close",w)}),kill:P=>d.kill(P),pid:d.pid}}import{spawn as ni}from"node:child_process";import{mkdir as yu,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 wu=new URL("./../../../vibe64-execution/src/server/engines/detached.js",import.meta.url).href,ye=new Map,Ou=3e3,Au=1e3,
|
|
440
|
+
Iu=Tu(new URL("./detachedReaper.js",wu)),X=null;function Ru(e){if(process.platform!=="win32"){if(!X){let t=ni(process.execPath,
|
|
441
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
|
|
442
|
+
t&&(X=null)}),t.stdin.on("error",()=>{}),t.unref(),t.stdin.unref(),X=t;for(let r of ye.values())r.scopeEmpty!==!0&&r.pid!==
|
|
443
443
|
e&&t.stdin.write(`+${r.pid}
|
|
444
444
|
`)}X.stdin.write(`+${e}
|
|
445
445
|
`)}}function Pu(e){X&&(X.stdin.write(`-${e}
|
|
446
|
-
`),![...
|
|
446
|
+
`),![...ye.values()].some(t=>t.scopeEmpty!==!0)&&(X.stdin.end(),X=null))}async function Cu(e=""){return e?(await yu(Su.dirname(
|
|
447
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
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
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&&(
|
|
451
|
-
s.once("exit",()=>{!Mt(s.pid)&&
|
|
450
|
+
env:n,stdio:i});await ku(s);let a=e.execution?.id||"";return a&&(ye.set(a,{child:s,pid:Number(s.pid)}),Ru(Number(s.pid)),
|
|
451
|
+
s.once("exit",()=>{!Mt(s.pid)&&ye.has(a)&&(ye.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),Pu(Number(s.pid)))})),s.unref(),
|
|
452
452
|
rt({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return L(i?.message||
|
|
453
453
|
"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{await o?.
|
|
454
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=[...
|
|
455
|
+
"win32"){let r=[...ye.values()].find(n=>n.pid===t);return r?.child?.exitCode===null&&r?.child?.signalCode===null}try{return process.
|
|
456
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"?[...
|
|
457
|
+
"win32"?[...ye.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),!0}catch(r){if(r?.code===
|
|
458
458
|
"ESRCH")return!1;throw r}}async function ii(e=null,t=10){let r=Number(e);if(process.platform!=="linux"||!Number.isSafeInteger(
|
|
459
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
460
|
let i=await vu(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(s+2).split(" ");Number(a[2])!==
|
|
@@ -462,16 +462,16 @@ r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}retur
|
|
|
462
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
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
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:
|
|
465
|
+
outputEncoding:u="utf8",signal:l=null,timeout:m=15e3}=r,d,p,f,g=null,w=Promise.withResolvers(),_=()=>{f||=p(),f.then(w.resolve)};
|
|
466
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:
|
|
467
|
+
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});g=Number(I.pid);let P;p=()=>{if(!P){let N;process.platform!=="win32"?
|
|
468
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,
|
|
469
|
+
i.id,p),l?.addEventListener("abort",_,{once:!0}),l?.aborted&&_();let T=await Promise.race([I.completion,w.promise.then(N=>N?
|
|
470
470
|
I.completion:{exitCode:1})]),C=typeof T.exitCode=="number"?T.exitCode:1;d=rt({code:T.timedOut===!0?"vibe64_command_captu\
|
|
471
471
|
re_timed_out":T.code?"vibe64_command_capture_failed":"",error:C===0?"":T.shortMessage,exitCode:C,output:T.all||(C===0?"":
|
|
472
472
|
T.shortMessage),outputEncoding:u,signal:T.signal,stderr:T.stderr,stdout:T.stdout,timedOut:T.timedOut===!0,execution:i})}catch(I){
|
|
473
473
|
d=L(I.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{l?.removeEventListener("abort",_)}
|
|
474
|
-
if(!await(f||
|
|
474
|
+
if(!await(f||p?.()||!0)){let I=await ii(g),P=d?.timedOut?"The command timed out":l?.aborted?"The command was cancelled":
|
|
475
475
|
"The command finished",T=I.length?`: ${I.map(C=>`${C.command} (pid ${C.pid})`).join(", ")} still running`:"";return{...L(
|
|
476
476
|
`${P}, and its execution scope did not become empty${T}.`,"vibe64_execution_drain_failed",{execution:i,output:d?.output,
|
|
477
477
|
outputEncoding:u,signal:d?.signal,stderr:d?.stderr,stdout:d?.stdout,timedOut:d?.timedOut}),remainingProcesses:I}}i?.id&&
|
|
@@ -516,7 +516,7 @@ if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&di.resolve(r)!==di.resolve(n)){let i=
|
|
|
516
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\
|
|
517
517
|
_USERNAME","MYSQL_DATABASE","MYSQL_HOST","MYSQL_PWD","MYSQL_TCP_PORT","PGDATABASE","PGHOST","PGPASSWORD","PGPORT","PGUSE\
|
|
518
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
|
|
519
|
+
return t}import{spawn as Wu,spawnSync as qu}from"node:child_process";import{createHash as Yu}from"node:crypto";import{statSync as yi}from"node:fs";
|
|
520
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
521
|
d",Ku=2e3,Ei=["config","--get-regexp","^user\\.(name|email)$"],vi=3e4,Ju=['git config --global user.name "Your Name"','g\
|
|
522
522
|
it config --global user.email "you@example.com"'].join(`
|
|
@@ -528,22 +528,22 @@ function Qu(e={}){let t=M(e),r=ne(t.name,t.displayName,t.login,t.username),n=ne(
|
|
|
528
528
|
!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"github"}}function Zu({workspace:e="",userKey:t=""}={}){
|
|
529
529
|
let r=fi(t,"user"),n=fi(e,"local");return{authorEmail:`${r}@${n}${nn}`,authorName:`${r} via Vibe64`,committerEmail:`vibe\
|
|
530
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&&
|
|
531
|
+
let t=on(e);try{return t&&yi(t).isDirectory()?t:""}catch{return""}}async function gi(e=""){let t=on(e);return t&&await bi(
|
|
532
532
|
t).then(r=>r.isDirectory(),()=>!1)?t:""}function Si(e=""){let t={};for(let r of String(e||"").split(`
|
|
533
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
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
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
|
|
536
|
+
null}}function wi(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(
|
|
537
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,
|
|
538
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
539
|
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function Ai(e={}){return{...e,PATH:process.
|
|
540
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
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
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=
|
|
543
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function tl(e={}){return Ii(e).map(t=>{try{let r=yi(t);return`${r.ino}\
|
|
544
544
|
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}var Ee=new Map;function Ri(e,t,r){let n=Object.
|
|
545
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
|
|
546
|
+
let n=e?await wi(e,r):null;if(n?.values)return n;let o=await wi(t,r);return{transient:!!(n?.transient||o.transient),values:o.
|
|
547
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
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
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);
|
|
@@ -601,14 +601,14 @@ let o=n.split(/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.
|
|
|
601
601
|
o[0]))throw new Error(`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function Di({runtimePackRoot:e=""}={}){
|
|
602
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
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"]),
|
|
604
|
+
ACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIME_DIR"]),wl=new Set([...it,Se,ve,Oe,Te,st,dn,pn,Ht]);function Ue(e={}){
|
|
605
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
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])=>!
|
|
608
|
-
{...o,...Bt(n)}}function
|
|
607
|
+
session"}=t,n=W(e);Ue(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!wl.has(i)));return r==="deployment"?o:
|
|
608
|
+
{...o,...Bt(n)}}function yl(e=""){let t=v(e);return t==="/home"||t.startsWith("/home/")}function Ui({actor:e={},request:t={}}={}){let r=t.
|
|
609
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\
|
|
610
610
|
mmand credential home must match the resolved real-user actor home.");throw a.code="vibe64_command_credential_home_actor\
|
|
611
|
-
_mismatch",a}if(!e.requiresRealUser&&
|
|
611
|
+
_mismatch",a}if(!e.requiresRealUser&&yl(n)&&o&&!se(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
612
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
613
|
return{...tt({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n}),...v(r.cacheRoot)?{XDG_CACHE_HOME:v(r.cacheRoot)}:{},...v(r.
|
|
614
614
|
configRoot)?{XDG_CONFIG_HOME:v(r.configRoot)}:{},...v(r.dataRoot)?{XDG_DATA_HOME:v(r.dataRoot)}:{},...v(r.stateRoot)?{XDG_STATE_HOME:v(
|
|
@@ -639,7 +639,7 @@ ae.join(r,"mise");return Xi([ae.join(t,".local/bin"),ae.join(n,"shims"),...[".cl
|
|
|
639
639
|
PATH),...zt.platform==="darwin"?["/opt/homebrew/bin"]:[],...Xi([...Ji("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`\
|
|
640
640
|
/usr/lib/postgresql/${t}/bin`),...zt.platform==="darwin"?e.flatMap(t=>[...Ji(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).
|
|
641
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
|
|
642
|
+
shimDirs:o=[]}){return we([...ct(o.join(":")),...ln(),...n.flatMap(i=>un(i)),...Mi(),...ct(t||(r?"":e.PATH)),...Nl(zt.env),
|
|
643
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
644
|
_RUNTIME_DIR"]),Ll=new Set(["NODE_ENV"]);function jl(e={}){return Object.fromEntries(Object.entries(e&&typeof e=="object"&&
|
|
645
645
|
!Array.isArray(e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!Ml.has(t)&&!Ll.has(t)&&!t.startsWith(
|
|
@@ -654,11 +654,11 @@ l=Qi({env:u,existingPath:[...Ki({env:u}),u.PATH].filter(Boolean).join(":"),inher
|
|
|
654
654
|
shimDirs||[]});return{...u,PATH:l,...j()?{}:{VIBE64_TOOL_PATH:l}}}function es({actor:e={},baseEnv:t,request:r={}},n){return{
|
|
655
655
|
actor:e,env:t,gitConfig:{cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.
|
|
656
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
|
|
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 Aw=600*1e3,Hl=1440*60*1e3,Iw=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "});function ns(){return{code:"\
|
|
658
658
|
terminal_session_not_found",error:"Terminal session not found.",ok:!1}}function ce(e=""){return String(e||"default").trim()||
|
|
659
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
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
|
|
661
|
+
"running"||e.status==="closing"}function wn(e={}){return lt(e)||e.status==="exited"}function is(e,t){try{return t(ue(e))===
|
|
662
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
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
664
|
o),outputTruncated:!0}}function ue(e,t={}){let r=zl(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||Ft,
|
|
@@ -666,7 +666,7 @@ createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exi
|
|
|
666
666
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
667
667
|
metadata:e.metadata||{},output:r.output,outputTruncated:r.outputTruncated,outputVersion:e.outputVersion||0,rows:e.rows||
|
|
668
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
|
|
669
|
+
max(Le(e.lastSubscriberDetachedAt),Le(e.lastInputAt),Le(e.lastOutputAt),Le(e.createdAt))}function yn(e={},t=Date.now()){
|
|
670
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
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
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(),
|
|
@@ -703,18 +703,18 @@ ok:!1}:null}var Ie=new Map;function Be(e){return Ie.get(ce(e))||os}function hs(e
|
|
|
703
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
704
|
"");return[...Ie.keys()].filter(r=>r.startsWith(t))}function Jt({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){
|
|
705
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),!
|
|
707
|
-
let n=Math.max(0,r-
|
|
706
|
+
return o}function Xt(e={},t="default"){if(Yt(e),!wn(e)||e.subscribers?.size)return;let r=dt(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
707
|
+
let n=Math.max(0,r-yn(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,Xl({namespace:t})},n)}async function Tn(e,t={}){
|
|
708
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
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
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
711
|
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&En(o),s.length>0)throw Kt(o,[...s,...c]);return gs(n,r,e),{
|
|
712
712
|
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(u=>String(u?.message||u))}:{}}})();o.closePromise=i;try{return await i}finally{
|
|
713
|
-
o.closePromise===i&&(o.closePromise=null)}}async function Xl({namespace:e}){for(let{namespace:t,session:r}of Jt({namespace:e})){if(!
|
|
714
|
-
let n=dt(r.detachedIdleTimeoutMs);if(!(n<1)){if(
|
|
713
|
+
o.closePromise===i&&(o.closePromise=null)}}async function Xl({namespace:e}){for(let{namespace:t,session:r}of Jt({namespace:e})){if(!wn(r)||r.subscribers?.size)continue;
|
|
714
|
+
let n=dt(r.detachedIdleTimeoutMs);if(!(n<1)){if(yn(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
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:
|
|
717
|
-
let g=fs(a);if(g)return g;let
|
|
716
|
+
fault",namespaceLimitPrefix:c="",runningLimitFilter:u=td,onClose:l=On,onOutput:m=On,onStop:d=On,reuseRunning:p=!1,detachedIdleTimeoutMs:f=0}){
|
|
717
|
+
let g=fs(a);if(g)return g;let w=Be(a),_=Zl.randomUUID(),S=typeof p=="function"?p:()=>!!p,A=p?[...w.values()].find(z=>lt(
|
|
718
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
719
|
terminal_limit",error:`Terminal limit reached (${I}).`};let T=typeof o=="function"?o({id:_,namespace:a}):o,C=typeof e=="\
|
|
720
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\
|
|
@@ -726,31 +726,31 @@ inputVersion:0,lastInputAt:"",lastInputBytes:0,lastOutputAt:"",lastOutputBytes:0
|
|
|
726
726
|
output:"",outputVersion:0,processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:Xn,rows:Wt,
|
|
727
727
|
status:"running",stopHookCompletion:null,scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:_r};return ls(
|
|
728
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{
|
|
729
|
+
type:"output"});try{m({chunk:z,output:k.output,session:ue(k),updateMetadata(bt){return as(k,bt)}})}catch(bt){let Ga=String(
|
|
730
730
|
bt?.message||bt||"Terminal output hook failed.");re(k,{error:Ga,type:"error"})}Xt(k,a)}),_r.onExit(({exitCode:z})=>{k.processExited=
|
|
731
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
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
|
|
733
|
+
r).get(e);return i?ue(i,{outputLimit:n}):ns()}function cd(){}var ws=new Map;function ud(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root\
|
|
734
734
|
is required for real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=An.join(
|
|
735
735
|
An.resolve(t),"exec-helper-payloads");return sd(r,{mode:448,recursive:!0}),An.join(r,`${process.pid}-${Date.now()}-${id()}\
|
|
736
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,
|
|
738
|
-
env:typeof a=="function"?a(c):a,input:e.input,operation:ot(e)});return ad(u,`${JSON.stringify(
|
|
737
|
+
let u=ud(s.helperPayloadRoot),l=typeof e.args=="function"?e.args(c):e.args,m=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(m)}
|
|
739
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
|
|
740
|
+
command:e.command,cwd:n,env:a}}async function ys(e={},t={}){let{actor:r,cwd:n,env:o,resolveEnv:i}=t;try{let s=e.terminal||
|
|
741
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,
|
|
742
742
|
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
743
|
-
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async
|
|
744
|
-
c&&
|
|
745
|
-
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&
|
|
743
|
+
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async m=>{try{await a(m)}finally{
|
|
744
|
+
c&&ws.set(c,{id:m.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
745
|
+
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&ws.set(c,{id:l.id,namespace:s.namespace}),l?.ok===!0?{...l,
|
|
746
746
|
execution:e.execution}:l}catch(s){return L(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
747
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
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
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
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\
|
|
751
751
|
nt","assistant","terminal","codex","github","github-api","source-editor","preview","output","deployment","health","works\
|
|
752
|
-
pace-cache","source"]),gd=Object.freeze(["capture","pty","detached"]),_d=Object.freeze(["utf8","base64"]),
|
|
753
|
-
["session","project","preview","auth","deployment"]),
|
|
752
|
+
pace-cache","source"]),gd=Object.freeze(["capture","pty","detached"]),_d=Object.freeze(["utf8","base64"]),wd=Object.freeze(
|
|
753
|
+
["session","project","preview","auth","deployment"]),yd=Object.freeze(["none","github-https","github-token"]),bd=Object.
|
|
754
754
|
freeze(["assistant","browser","control","job","preview","service","terminal"]),Ed=Object.freeze(["finite","interactive",
|
|
755
755
|
"service"]),vd=1e3*1e3*100,Sd=new Set(["assistant","codex","deployment","output","preview","source","terminal"]);function B(e="",t="\
|
|
756
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="\
|
|
@@ -775,7 +775,7 @@ cution_kind"),c=le(s.lifecycle,Ed,Rd(r),"execution_lifecycle");if(r==="detached"
|
|
|
775
775
|
tive"||r==="capture"&&c!=="finite")throw B(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_ex\
|
|
776
776
|
ecution_lifecycle_incompatible");let u=Ge(s.ownerId||i.sessionId);if(c==="service"&&!u)throw B("Service execution requir\
|
|
777
777
|
es a durable owner id.","vibe64_execution_owner_required");let l=s.resourceProfile;if(l!=null&&(!l||typeof l!="object"||
|
|
778
|
-
Object.keys(l).some(
|
|
778
|
+
Object.keys(l).some(m=>!["key","compatibilityKey","environment"].includes(m))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(l.key||
|
|
779
779
|
"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||"")||!["development","test","production"].includes(l.environment)))throw B(
|
|
780
780
|
"Invalid activity resource profile identity.","vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.
|
|
781
781
|
freeze({...l})}:{},controlGenerationId:Ge(s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===
|
|
@@ -784,29 +784,32 @@ parentExecutionId:Ge(s.parentExecutionId),projectSlug:Ge(s.projectSlug||n.slug||
|
|
|
784
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
785
|
test(e))throw B("Execution requires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function kd(e=""){
|
|
786
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
|
|
787
|
+
e,"runtimes"),n=vs(e,"runtime");if(!r&&!n)return we(kd(t));let o=r?e.runtimes:e.runtime;return we((Array.isArray(o)?o:[o]).
|
|
788
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
789
|
nd_required");let n=le(t.mode,gd,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))
|
|
790
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
|
|
792
|
-
orted Vibe64 runtime: ${
|
|
791
|
+
t.env,{mode:n}),s=le(t.purpose,hd,"terminal","purpose"),a=Nd(t,s);for(let f of a)if(!Object.hasOwn(De,f))throw B(`Unsupp\
|
|
792
|
+
orted Vibe64 runtime: ${f}.`,"vibe64_command_runtime_unsupported");let c=M(t.project),u=M(t.session),l=t.releaseEnvironmentFile??
|
|
793
793
|
"";if(typeof l!="string"||l&&(!l.startsWith("/")||/[\r\n\0]/u.test(l)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="de\
|
|
794
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
|
|
796
|
-
"";if(typeof
|
|
795
|
+
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let m=t.usageRecordingPreload??
|
|
796
|
+
"";if(typeof m!="string"||m&&(!m.startsWith("/")||/[\s"'\\\0]/u.test(m)||!["preview","output"].includes(s)||t.actor==="a\
|
|
797
797
|
pp"))throw B("A usage recording preload belongs only to a Preview or Output target launch.","vibe64_command_usage_record\
|
|
798
798
|
ing_preload_invalid");let d=t.applicationAccount??"";if(typeof d!="string"||d&&(!fd.test(d)||t.actor!=="app"||n!=="captu\
|
|
799
799
|
re"))throw B("Application accounts run only finite application commands.","vibe64_command_application_account_invalid");
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
"
|
|
803
|
-
t.
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
t.
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
800
|
+
let p=t.sandboxAllowances??[];if(!Array.isArray(p)||p.some(f=>typeof f!="string"||!/^[a-z][a-z0-9-]*$/u.test(f))||new Set(
|
|
801
|
+
p).size!==p.length||p.length>0&&!d)throw B("Sandbox allowances belong only to an application account's own commands.","v\
|
|
802
|
+
ibe64_command_sandbox_allowances_invalid");return{actor:le(t.actor,md,"daemon","actor"),applicationAccount:d,allowedRoots:In(
|
|
803
|
+
t.allowedRoots),args:Td(t.args,{mode:n}),baseEnv:o,command:r,cwd:v(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,
|
|
804
|
+
envPolicy:le(t.envPolicy,wd,"session","env_policy"),releaseEnvironmentFile:l,sandboxAllowances:[...p],execution:Ss(t.execution,
|
|
805
|
+
{mode:n,project:c,purpose:s,session:u}),credentialHome:Id(t.credentialHome),gitAuthToken:E(t.gitAuthToken),gitSafeDirectories:In(
|
|
806
|
+
t.gitSafeDirectories),personGitIdentity:{email:E(t.personGitIdentity?.email),name:E(t.personGitIdentity?.name)},gitTransport:le(
|
|
807
|
+
t.gitTransport,yd,"none","git_transport"),inheritProcessEnv:!l&&t.inheritProcessEnv!==!1,input:t.input,logPath:v(t.logPath),
|
|
808
|
+
maxBuffer:Number.isSafeInteger(Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):vd,mode:n,onOutput:typeof t.
|
|
809
|
+
onOutput=="function"?t.onOutput:null,outputEncoding:le(t.outputEncoding,_d,"utf8","output_encoding"),project:c,purpose:s,
|
|
810
|
+
runtimes:a,session:u,signal:t.signal??null,shimDirs:In(t.shimDirs),terminal:Ad(t.terminal),timeout:Number.isSafeInteger(
|
|
811
|
+
Number(t.timeout))&&Number(t.timeout)>0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:E(t.userKey)}}var Ay=Object.
|
|
812
|
+
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
813
|
var $d=new URL("./../../../vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href;function jd(e){let t=[
|
|
811
814
|
de.resolve(de.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=de.dirname(e);t.push(de.join(r,"node\
|
|
812
815
|
_modules/@local/vibe64-usage-recording/runtime/node")),de.dirname(r)!==r;r=de.dirname(r));return t.flatMap(r=>{try{return[
|
|
@@ -816,7 +819,7 @@ of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}
|
|
|
816
819
|
e_environment_unavailable",{execution:e.execution}):e.applicationAccount?L("Application account execution requires a man\
|
|
817
820
|
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function Dd(e,t={}){let{actor:r,
|
|
818
821
|
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"?
|
|
822
|
+
u=s;o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?ys(e,{actor:r,cwd:n,env:o,resolveEnv:s}):
|
|
820
823
|
e.mode==="detached"?r.requiresRealUser&&(!je(r)||i)?L("Detached real-user command execution is unsupported when the help\
|
|
821
824
|
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):oi(e,{actor:r,cwd:n,env:o}):i?
|
|
822
825
|
{...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.
|
|
@@ -826,11 +829,11 @@ signal:e.signal,timeout:e.timeout})}async function x(e={}){let t=null;try{if(t=T
|
|
|
826
829
|
cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await li(t),n=t.inheritProcessEnv?{...process.env,
|
|
827
830
|
...t.baseEnv}:{...t.baseEnv},o=(_={})=>({..._,VIBE64_EXECUTION_ID:t.execution.id}),i=Rn(),s=Qt(n)||Qt(process.env),a=Ut(
|
|
828
831
|
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})),
|
|
830
|
-
mi(r,l);let d=Es(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});pi(r,t,d);let
|
|
831
|
-
args=="function"?t.args(_):t.args,f=(_={})=>o(t.envFactory?_n({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:
|
|
832
|
+
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Se,ve,Oe,Te].map(_=>[_,l[_]]));
|
|
833
|
+
mi(r,l);let d=Es(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});pi(r,t,d);let p=(_={})=>typeof t.
|
|
834
|
+
args=="function"?t.args(_):t.args,f=(_={})=>o(t.envFactory?_n({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:m,request:{
|
|
832
835
|
...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:
|
|
836
|
+
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:d,env:l,resolveArgs:p,resolveEnv:f,runLocal:g});let w=Rs(t);return w||
|
|
834
837
|
(s?L("Managed execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unava\
|
|
835
838
|
ilable",{execution:t.execution,retryable:!1}):g())}catch(r){return L(r?.message||"Vibe64 command failed.",r?.code||"vibe\
|
|
836
839
|
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";
|
|
@@ -842,25 +845,25 @@ project:r,refs:l,runCommand:n,temporaryDiskBudgetBytes:i,temporaryDiskReserveByt
|
|
|
842
845
|
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
846
|
refs:r,runCommand:n});let a=await V(n,e.worktreePath,["rev-parse","--verify","HEAD"],{project:t}),c=await $s({baseCommit:a,
|
|
844
847
|
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
|
|
846
|
-
d=
|
|
848
|
+
e.worktreePath,{project:t});for(let l=0;;l+=1){let m=await He(n,e.worktreePath,["rev-parse","--verify",r.latestRef],{project:t}),
|
|
849
|
+
d=m||a,p=await V(n,e.worktreePath,["commit-tree",c,"-p",d],{env:rp(e.timestamp),input:Us(e),project:t});try{await V(n,e.
|
|
847
850
|
worktreePath,["update-ref","--stdin"],{input:`start
|
|
848
|
-
create ${r.turnRef} ${
|
|
849
|
-
update ${r.latestRef} ${
|
|
851
|
+
create ${r.turnRef} ${p}
|
|
852
|
+
update ${r.latestRef} ${p} ${m||u}
|
|
850
853
|
prepare
|
|
851
854
|
commit
|
|
852
855
|
`,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
|
|
854
|
-
if(l>=2||
|
|
856
|
+
identity:e,project:t,refs:r,runCommand:n});let w=await He(n,e.worktreePath,["rev-parse","--verify",r.latestRef],{project:t});
|
|
857
|
+
if(l>=2||w===m)throw f;continue}return{baseCommit:d,commit:p,created:!0,latestRef:r.latestRef,ok:!0,outerTurnId:e.outerTurnId,
|
|
855
858
|
outcome:e.outcome,sessionId:e.sessionId,tree:c,turnRef:r.turnRef}}}async function Z({baseCommit:e="HEAD",paths:t=[],project:r={},
|
|
856
859
|
runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=q.resolve(Re(s,"worktre\
|
|
857
860
|
ePath"));return Ms(a,()=>$s({baseCommit:e,paths:t,project:r,runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,
|
|
858
861
|
worktreePath:a}))}async function $s({baseCommit:e="HEAD",paths:t=[],project:r={},runCommand:n,temporaryDiskBudgetBytes:o,
|
|
859
862
|
temporaryDiskReserveBytes:i,worktreePath:s=""}={}){let a=q.resolve(Re(s,"worktreePath")),c=await V(n,a,["rev-parse","--a\
|
|
860
863
|
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-")),
|
|
862
|
-
let
|
|
863
|
-
temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:a}),await V(n,a,["add","-A","--",...
|
|
864
|
+
join(u,".tree-")),m=q.join(l,"index");try{let d={GIT_INDEX_FILE:m};await V(n,a,["read-tree",e||"HEAD"],{env:d,project:r});
|
|
865
|
+
let p=Array.isArray(t)?t.map(f=>String(f||"")).filter(Boolean):[];return await Qd({gitDirectory:c,paths:p,project:r,runCommand:n,
|
|
866
|
+
temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,worktreePath:a}),await V(n,a,["add","-A","--",...p.length>0?p:["."]],
|
|
864
867
|
{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
868
|
recursive:!0})}}async function Xd(e=""){let t=Date.now(),r=await Vd(e,{withFileTypes:!0});await Promise.all(r.filter(n=>n.
|
|
866
869
|
isDirectory()&&n.name.startsWith(".tree-")).map(async n=>{let o=q.join(e,n.name),i=await ks(o).catch(()=>null);i?.isDirectory()&&
|
|
@@ -868,12 +871,12 @@ t-i.mtimeMs>qd&&await Ns(o,{force:!0,recursive:!0})}))}function Ms(e="",t=async(
|
|
|
868
871
|
Promise.resolve()).catch(()=>null).then(t),i=o.then(()=>null,()=>null).finally(()=>{Zt.get(r)===i&&Zt.delete(r)});return Zt.
|
|
869
872
|
set(r,i),o}async function Qd({gitDirectory:e="",paths:t=[],project:r={},runCommand:n,temporaryDiskBudgetBytes:o,temporaryDiskReserveBytes:i,
|
|
870
873
|
worktreePath:s=""}={}){let a=t.length>0?t:["."],[c,u,l]=await Promise.all([V(n,s,["diff","--name-only","-z","HEAD","--",
|
|
871
|
-
...a],{project:r}),V(n,s,["ls-files","--others","--exclude-standard","-z","--",...a],{project:r}),zd(e)]),
|
|
872
|
-
[...Ps(c),...Ps(u)])],d=[];for(let I of
|
|
874
|
+
...a],{project:r}),V(n,s,["ls-files","--others","--exclude-standard","-z","--",...a],{project:r}),zd(e)]),m=[...new Set(
|
|
875
|
+
[...Ps(c),...Ps(u)])],d=[];for(let I of m){let P=q.resolve(s,I),T=q.relative(s,P);if(T===".."||T.startsWith(`..${q.sep}`)||
|
|
873
876
|
q.isAbsolute(T))throw Pe("Git returned a checkpoint candidate outside the session source.","vibe64_checkpoint_candidate_\
|
|
874
877
|
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
|
|
876
|
-
l.bavail)*Number(l.bsize)),S=Math.min(g,Math.max(0,_-
|
|
878
|
+
0),path:T})}let p=d.reduce((I,P)=>I+P.bytes,0),f=Math.min(Number.MAX_SAFE_INTEGER,p*2),g=Zd(o),w=ep(i),_=Math.max(0,Number(
|
|
879
|
+
l.bavail)*Number(l.bsize)),S=Math.min(g,Math.max(0,_-w));if(f<=S)return;let A=d.sort((I,P)=>P.bytes-I.bytes||I.path.localeCompare(
|
|
877
880
|
P.path)).slice(0,5).map(I=>`${I.path} (${I.bytes} bytes)`).join(", ");throw Pe([`Vibe64 refused this checkpoint because \
|
|
878
881
|
changed, unignored files may need about ${f} temporary bytes; the safe budget is ${S} bytes.`,A?`Largest candidates: ${A}\
|
|
879
882
|
.`:"","Keep needed files in place and add generated or local-only artifacts to .gitignore, or ask an operator to review \
|
|
@@ -1171,11 +1174,11 @@ server for the configured primary application.","Do not start a duplicate copy o
|
|
|
1171
1174
|
distinct secondary application explicitly requested by the user, such as a reference app, may run separately without rep\
|
|
1172
1175
|
lacing this preview."].join(`
|
|
1173
1176
|
`)+`
|
|
1174
|
-
`;import{fileURLToPath as
|
|
1177
|
+
`;import{fileURLToPath as wp}from"node:url";var _p=new URL("./../../../vibe64-execution/src/server/conversationExecution.js",import.meta.url).href,Yb=wp(new URL("./\
|
|
1175
1178
|
engines/stdioBridge.js",_p));var eE=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$name" 2>/dev/null) || continue',
|
|
1176
1179
|
" case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /usr/bin/*) continue ;; esac; fi',
|
|
1177
1180
|
` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1178
|
-
`);var
|
|
1181
|
+
`);var yp=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,any:n}=tr[e];return[
|
|
1179
1182
|
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"?
|
|
1180
1183
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
1181
1184
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
@@ -1224,16 +1227,16 @@ randomUUID()}=n;if(e?.[fa])return e;let s=h(r.slug||r.projectSlug),a=Promise.res
|
|
|
1224
1227
|
execution:{...u.execution||{},kind:"job",label:o,lifecycle:"finite",operationId:h(i),ownerId:t.sessionId,projectSlug:s,sessionId:t.
|
|
1225
1228
|
sessionId},project:{...u.project||{},...s?{slug:s}:{}},session:{...u.session||{},sessionId:t.sessionId}}));return a=l.then(
|
|
1226
1229
|
()=>{},()=>{}),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,
|
|
1230
|
+
commandOptions:s={},cwd:a=t.worktreePath,env:c={},input:u,project:l={}}=o,m=[t.worktreePath,gt.dirname(t.worktreePath),...t.
|
|
1228
1231
|
mode===D?[t.standaloneSourceRoot,gt.dirname(t.standaloneSourceRoot)]:[],...gt.isAbsolute(t.remoteUrl)?[t.remoteUrl,gt.dirname(
|
|
1229
|
-
t.remoteUrl)]:[],...i.flatMap(d=>{let
|
|
1230
|
-
command:r,cwd:a,env:c,envPolicy:"session",gitSafeDirectories:
|
|
1232
|
+
t.remoteUrl)]:[],...i.flatMap(d=>{let p=h(d);return p?[p,gt.dirname(p)]:[]})];return e({actor:"daemon",allowedRoots:m,args:n,
|
|
1233
|
+
command:r,cwd:a,env:c,envPolicy:"session",gitSafeDirectories:m,input:u,mode:"capture",project:G(t,l),purpose:s.gitTransport?.
|
|
1231
1234
|
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
|
|
1235
|
+
$p=100;function Mp(e){return e?.ok!==!0&&/index\.lock'?: File exists/u.test(String(e?.stderr||e?.output||""))}async function y(e,t,r,n={}){
|
|
1233
1236
|
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
1237
|
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
1238
|
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
|
|
1239
|
+
return ze(await y(e,t,r,n))}async function sr(e,t,r,n={}){let o=await y(e,t,r,{...n,required:!1});return o?.ok===!0?ze(o):
|
|
1237
1240
|
""}var Lp=new URL("./sessionWorkGit.js",import.meta.url).href,aT=Dp(new URL("./sessionWorkOperationCommand.js",Lp)),_a=".vi\
|
|
1238
1241
|
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
1242
|
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||
|
|
@@ -1246,91 +1249,91 @@ let l=n===Y?h(t.githubRepository?.cloneUrl||t.repository?.github?.cloneUrl):n===
|
|
|
1246
1249
|
throw O("Session Save cannot find the canonical repository authority.","vibe64_session_save_authority_missing");return Object.
|
|
1247
1250
|
freeze({baseCommit:a,branch:o,lastCanonicalCommit:c,mode:n,githubMirrorPath:h(t.githubMirrorPath),repositoryFullName:h(t.
|
|
1248
1251
|
githubRepository?.fullName||t.repository?.github?.fullName),githubMirrorOptional:!!r.github_pull_request||t.githubMirrorOptional===
|
|
1249
|
-
!0,remoteUrl:l,sessionId:s,standaloneSourceRoot:u,worktreePath:i})}async function fe(e,t,r,n,o={}){let i=await
|
|
1252
|
+
!0,remoteUrl:l,sessionId:s,standaloneSourceRoot:u,worktreePath:i})}async function fe(e,t,r,n,o={}){let i=await y(e,t,["diff-tree","--no-commit-id","--name-status","-r","-z",r,n],o);return ht(
|
|
1250
1253
|
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
1254
|
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
1255
|
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
|
|
1256
|
+
return r===n?!0:(await y(e,t,["merge-base","--is-ancestor",r,n],{...o,required:!1}))?.ok===!0}async function Ce(e,t,r,n,o={}){
|
|
1254
1257
|
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",`${
|
|
1258
|
+
async function ur(e,t,r={}){let[n,o,i]=await Promise.all([sr(e,t,["rev-parse","--verify",`${wa(t)}^{commit}`],r),t.lastCanonicalCommit?
|
|
1256
1259
|
await sr(e,t,["rev-parse","--verify",`${t.lastCanonicalCommit}^{commit}`],r):"",R(e,t,["rev-parse","--verify",`${t.baseCommit}\
|
|
1257
1260
|
^{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
1261
|
baseCommit:r,canonicalCommit:n,sessionHead:o,worktreeTree:i,reconcileHistory:s=!1},a={}){let[c,u]=await Promise.all([me(
|
|
1259
1262
|
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),
|
|
1261
|
-
canonicalTree:u,changeBaseCommit:l,changeBaseTree:
|
|
1262
|
-
await
|
|
1263
|
-
56").update(`${e.sessionId}\0${t}`).digest("hex").slice(0,32)}/${r}`}function dr(e,t){return lr(e,t,"prepared")}function
|
|
1264
|
-
h(r)&&await
|
|
1265
|
-
"--verify",`${r}^{commit}`],n);return await
|
|
1263
|
+
let l=s?r:await R(e,t,["merge-base",n,o],a),m=l===n?u:await me(e,t,l,a),d=i===m?[]:await cr(e,t,l,i,a);return{baseTree:c,
|
|
1264
|
+
canonicalTree:u,changeBaseCommit:l,changeBaseTree:m,changedPaths:d,sessionMatchesCanonical:i===u}}async function Ye(e,t,r){
|
|
1265
|
+
await y(e,t,["check-ref-format","--branch",t.branch],r)}function lr(e,t,r){return`refs/vibe64/save/${ha.createHash("sha2\
|
|
1266
|
+
56").update(`${e.sessionId}\0${t}`).digest("hex").slice(0,32)}/${r}`}function dr(e,t){return lr(e,t,"prepared")}function wa(e){return`refs/vibe64/canonical/${ha.createHash("sha256").update(e.branch).digest("hex").slice(0,32)}`}async function wt(e,t,r,n={}){
|
|
1267
|
+
h(r)&&await y(e,t,["update-ref","-d",r],{...n,required:!1})}async function ee(e,t,r,n={}){let o=await R(e,t,["rev-parse",
|
|
1268
|
+
"--verify",`${r}^{commit}`],n);return await y(e,t,["update-ref",wa(t),o],n),o}async function ya(e,t,{baseCommit:r,canonicalCommit:n,
|
|
1266
1269
|
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
|
|
1268
|
-
[],"--messages","--name-only","-z",n,u],{commandOptions:i,project:s,required:!1}),
|
|
1269
|
-
"\0"),d=h(
|
|
1270
|
-
the conflicting files for review.","vibe64_session_update_merge_invalid");if(l?.ok!==!0){let
|
|
1271
|
-
shift();if(!f)break;
|
|
1272
|
-
version.","vibe64_session_update_merge_invalid");return{conflictPaths:[...new Set(
|
|
1270
|
+
message:"Vibe64 session rebase input",project:s,tree:o}),l=await y(e,t,["merge-tree","--write-tree",...c?[`--merge-base=${r}`]:
|
|
1271
|
+
[],"--messages","--name-only","-z",n,u],{commandOptions:i,project:s,required:!1}),m=String(l?.stdout||l?.output||"").split(
|
|
1272
|
+
"\0"),d=h(m.shift());if(!ar(d))throw O(l?.ok===!0?"Git did not produce a valid rebased tree.":"Vibe64 could not prepare \
|
|
1273
|
+
the conflicting files for review.","vibe64_session_update_merge_invalid");if(l?.ok!==!0){let p=[];for(;m.length>0;){let f=m.
|
|
1274
|
+
shift();if(!f)break;p.push(f)}if(!p.length)throw O("Vibe64 could not identify which files conflict with the latest saved\
|
|
1275
|
+
version.","vibe64_session_update_merge_invalid");return{conflictPaths:[...new Set(p)].sort((f,g)=>f.localeCompare(g)),conflictTree:d,
|
|
1273
1276
|
mergedTree:"",virtualCommit:u}}return{conflictPaths:[],conflictTree:"",mergedTree:d,virtualCommit:u}}function ba(e,t,{conflictTree:r,
|
|
1274
1277
|
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
1278
|
baseCommit:r,commandOptions:n,message:o,project:i,tree:s}){return R(e,t,["commit-tree",s,"-p",r],{commandOptions:n,input:`${h(
|
|
1276
1279
|
o)||"Vibe64 virtual commit"}
|
|
1277
1280
|
`,project:i})}async function mr(e,t,{commandOptions:r,derivedArtifactPaths:n=[],project:o,sourceCommit:i,tree:s}){let a=Fe(
|
|
1278
1281
|
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")},
|
|
1280
|
-
let
|
|
1281
|
-
exec(String(
|
|
1282
|
-
pdate-index","--force-remove","--",d],{...
|
|
1282
|
+
join(c,"index")},m={additionalAllowedRoots:[c],commandOptions:r,env:l,project:o};try{await y(e,t,["read-tree",s],m);for(let d of a){
|
|
1283
|
+
let p=await y(e,t,["ls-tree","-z",i,"--",d],{commandOptions:r,project:o}),f=/^(\d+)\s+\S+\s+([a-f0-9]{40}|[a-f0-9]{64})\t([^\0]+)\0$/u.
|
|
1284
|
+
exec(String(p.stdout||""));f&&f[3]===d?await y(e,t,["update-index","--add","--cacheinfo",f[1],f[2],d],m):await y(e,t,["u\
|
|
1285
|
+
pdate-index","--force-remove","--",d],{...m,required:!1})}return await R(e,t,["write-tree"],m)}finally{await jn(c,{force:!0,
|
|
1283
1286
|
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
|
|
1287
|
+
_a));if(o.length){for(let i of o)await jn(pe.join(n,i),{force:!0,recursive:!0});await y(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
1288
|
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)),
|
|
1287
|
-
l,"source"),d={additionalAllowedRoots:[l,
|
|
1288
|
-
|
|
1289
|
+
message:"Vibe64 derived artifact input",project:i,tree:a}),l=await ga(pe.join(pe.dirname(t.worktreePath),_a)),m=pe.join(
|
|
1290
|
+
l,"source"),d={additionalAllowedRoots:[l,m],commandOptions:n,project:i},p=!1;try{await y(e,t,["worktree","add","--detach",
|
|
1291
|
+
m,u],d),p=!0;try{await s({projectRoot:m})}catch(f){return{derivedArtifactsKept:{code:String(f?.code||f?.name||"vibe64_de\
|
|
1289
1292
|
rived_artifacts_unavailable"),message:String(f?.message||f)},tree:a}}return{tree:await Z({baseCommit:"HEAD",project:G(t,
|
|
1290
|
-
i),runCommand:e,worktreePath:
|
|
1291
|
-
l,{force:!0,recursive:!0}),await
|
|
1293
|
+
i),runCommand:e,worktreePath:m})}}finally{p&&await y(e,t,["worktree","remove","--force",m],{...d,required:!1}),await jn(
|
|
1294
|
+
l,{force:!0,recursive:!0}),await y(e,t,["worktree","prune"],{commandOptions:n,project:i,required:!1})}}async function Hp(e,t,r,n){await y(e,t,["remote","set-url","origin",t.remoteUrl],n);let o=lr(t,r,"canonical");try{await y(
|
|
1292
1295
|
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
|
|
1296
|
+
e,t,i,n).then(s=>({canonicalBranch:"",commit:s}))}finally{await wt(e,t,o,n)}}async function Dn(e,t,r){if(await R(e,t,["b\
|
|
1294
1297
|
ranch","--show-current"],{...r,cwd:t.standaloneSourceRoot})!==t.branch)throw O(`The project baseline must have ${t.branch}\
|
|
1295
1298
|
checked out before Save.`,"vibe64_session_save_local_branch_mismatch");if(await R(e,t,["status","--porcelain","--untrac\
|
|
1296
1299
|
ked-files=all"],{...r,cwd:t.standaloneSourceRoot}))throw O("The local project baseline has unsaved work. Save cannot ove\
|
|
1297
1300
|
rwrite it.","vibe64_session_save_local_authority_dirty");for(let i of["MERGE_HEAD","CHERRY_PICK_HEAD","REVERT_HEAD","REB\
|
|
1298
|
-
ASE_HEAD"])if((await
|
|
1301
|
+
ASE_HEAD"])if((await y(e,t,["rev-parse","--verify","-q",i],{...r,cwd:t.standaloneSourceRoot,required:!1}))?.ok===!0)throw O(
|
|
1299
1302
|
"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
|
|
1303
|
+
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 y(e,t,
|
|
1301
1304
|
["fetch","--no-tags",t.standaloneSourceRoot,`+refs/heads/${t.branch}:${i}`],n);let s=await R(e,t,["rev-parse","--verify",
|
|
1302
1305
|
i],n);if(s!==o)throw O("The local project baseline changed while Vibe64 was reading it.","vibe64_session_save_authority_\
|
|
1303
|
-
changed_during_read");return ee(e,t,s,n).then(a=>({canonicalBranch:"",commit:a}))}finally{await
|
|
1306
|
+
changed_during_read");return ee(e,t,s,n).then(a=>({canonicalBranch:"",commit:a}))}finally{await wt(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
1307
|
ile",Kp="vibe64_session_update_head_moved";function Je(e,t,r,{baseCommit:n="HEAD",paths:o=[]}={}){return Z({baseCommit:n,
|
|
1305
1308
|
paths:o,project:G(t,r),runCommand:e,worktreePath:t.worktreePath})}function Un(e){let t=e.slice(0,3).join(", ");return e.
|
|
1306
1309
|
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
1310
|
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
1311
|
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
1312
|
-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
|
|
1311
|
-
ate-index","-q","--refresh"],c);let u=await
|
|
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),
|
|
1313
|
-
e,t,["check-ignore","--no-index","--stdin","-z"],{...o,input:`${d.join("\0")}\0`,required:!1}):null,f=String(
|
|
1314
|
-
|
|
1313
|
+
additionalAllowedRoots:[a],env:{GIT_INDEX_FILE:hr.join(a,"index")}};try{await y(e,t,["read-tree",r],c),await y(e,t,["upd\
|
|
1314
|
+
ate-index","-q","--refresh"],c);let u=await y(e,t,["diff-files","--name-status","-z"],c),m=[...ht(u.stdout||u.output).values()].
|
|
1315
|
+
filter(g=>i.has(g.path)&&!(g.status==="D"&&i.get(g.path).status==="D")).map(g=>g.path),d=await Jp(t,i),p=d.length?await y(
|
|
1316
|
+
e,t,["check-ignore","--no-index","--stdin","-z"],{...o,input:`${d.join("\0")}\0`,required:!1}):null,f=String(p?.stdout||
|
|
1317
|
+
p?.output||"").split("\0").filter(Boolean);if(f.length)throw O(`Update would replace ${Un(f)}, which Git ignores in this\
|
|
1315
1318
|
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(
|
|
1317
|
-
).`,Bn,{changedPaths:
|
|
1319
|
+
gain.`,Yp,{ignoredPaths:f});if(m.push(...d),m.length)throw O(`Files changed while the session was being switched (${Un(m)}\
|
|
1320
|
+
).`,Bn,{changedPaths:m});await y(e,t,["read-tree","-m","-u",r,n],c)}finally{await Wp(a,{force:!0,recursive:!0})}}async function Hn(e,t,r,{
|
|
1318
1321
|
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
1322
|
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),
|
|
1321
|
-
if(await Je(e,t,r)===u)throw d;continue}try{return await Gn(e,t,u,
|
|
1323
|
+
"D"&&s.get(d.path)?.status==="D")).map(d=>d.path),m=i;if(l.length)try{m=await Je(e,t,r,{baseCommit:i,paths:l})}catch(d){
|
|
1324
|
+
if(await Je(e,t,r)===u)throw d;continue}try{return await Gn(e,t,u,m,o),{changes:s,moved:!0,writes:a}}catch{}}return{changes:s,
|
|
1322
1325
|
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
1326
|
pdate ran${r}, so Update stopped and put this session back as it was, keeping every change. Nothing was lost. Try Update\
|
|
1324
1327
|
again.`:`Files kept changing while Update ran${r}, so this session stays updated and keeps every file as last written. \
|
|
1325
1328
|
Nothing was lost. Check those files before saving.`,qp,{changedPaths:e,undone:t})}function Ea(){return O("A Git commit w\
|
|
1326
1329
|
as made in this session while Update ran, so Update stopped and left every file as it is, some perhaps already updated. \
|
|
1327
1330
|
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:
|
|
1329
|
-
"HEAD"],c).catch(()=>""),
|
|
1330
|
-
f=await d();if(f!==s&&f!==r)return
|
|
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=>
|
|
1332
|
-
|
|
1333
|
-
e,t,r,c).catch(he),(l||f===r)&&await
|
|
1331
|
+
mergedTree:i,oldHead:s,oldIndexTree:a,options:c,project:u,switched:l,updatedPathStatuses:m}){let d=()=>R(e,t,["rev-parse",
|
|
1332
|
+
"HEAD"],c).catch(()=>""),p=async()=>(await y(e,t,["read-tree","HEAD"],{...c,required:!1}),{headMoved:!0,undone:!1,written:[]}),
|
|
1333
|
+
f=await d();if(f!==s&&f!==r)return p();let g;if(l){let S=await Hn(e,t,u,{from:i,options:c,to:n});l=!S.moved,g=[...S.writes.
|
|
1334
|
+
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=>m.has(A))}let[
|
|
1335
|
+
w,_]=l?[r,s]:[s,r];return f===_&&await y(e,t,["update-ref","HEAD",w,_],{...c,required:!1}),await d()!==w?p():(l&&await ee(
|
|
1336
|
+
e,t,r,c).catch(he),(l||f===r)&&await y(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 y(e,t,["log","--topo-order",`--max-count=${zn+1}`,"-z",`--format=${sa}`,`${r}\
|
|
1334
1337
|
..${n}`],o),s=ca(String(i.stdout||i.output||""));return{incomingVersions:s.slice(0,zn),incomingVersionsTruncated:s.length>
|
|
1335
1338
|
zn}}function Zp(e={}){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=Array.isArray(e.conflictPaths)?[...new Set(
|
|
1336
1339
|
e.conflictPaths.map(String).filter(Boolean))].sort((n,o)=>n.localeCompare(o)):[],r={baseCommit:h(e.baseCommit),canonicalCommit:h(
|
|
@@ -1348,41 +1351,41 @@ o,r);n=H(n,i,r,{label:"Checking repository for updates",operationId:t}),await Ye
|
|
|
1348
1351
|
n,i,t,{commandOptions:e,project:r}),a=s.commit,[c,u]=await Promise.all([R(n,i,["rev-parse","--verify","HEAD^{commit}"],{
|
|
1349
1352
|
commandOptions:e,project:r}),Z({baseCommit:"HEAD",project:G(i,r),runCommand:n,worktreePath:i.worktreePath})]),l=await Ce(
|
|
1350
1353
|
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
|
|
1354
|
+
ession's starting version.","vibe64_session_update_history_diverged");let m=l?{baseCommit:i.baseCommit,canonicalCommit:a,
|
|
1352
1355
|
sessionHead:c,worktreeTree:u,changedPaths:(await cr(n,i,i.baseCommit,u,{commandOptions:e,project:r})).slice(0,100)}:null,
|
|
1353
|
-
[d,
|
|
1354
|
-
{commandOptions:e,project:r}),me(n,i,a,{commandOptions:e,project:r})]),
|
|
1355
|
-
project:r}):{incomingVersions:[],incomingVersionsTruncated:!1};return{ahead:d,baseCommit:i.baseCommit,behind:
|
|
1356
|
+
[d,p,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,
|
|
1357
|
+
{commandOptions:e,project:r}),me(n,i,a,{commandOptions:e,project:r})]),w=mt(d,p),_=p>0?await Qp(n,i,c,a,{commandOptions:e,
|
|
1358
|
+
project:r}):{incomingVersions:[],incomingVersionsTruncated:!1};return{ahead:d,baseCommit:i.baseCommit,behind:p,canonicalCommit:a,
|
|
1356
1359
|
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,...
|
|
1358
|
-
sessionHead:c,sessionMatchesCanonical:u===g,updateAvailable:l||!f,updateStrategy:ft(
|
|
1359
|
-
oldHead:c,oldIndexTree:u,project:l}){let
|
|
1360
|
-
|
|
1361
|
-
f,
|
|
1362
|
-
updatedPathCount:d.size,updatedPaths:[...d.keys()].sort((
|
|
1363
|
-
undone:
|
|
1364
|
-
options:
|
|
1365
|
-
[],{undone:
|
|
1360
|
+
remoteUrl}},..._,ok:!0,operationId:t,reconciled:!l&&f,...m?{historyReview:m}:{},repositoryMode:i.mode,relationship:w,sessionCurrent:f,
|
|
1361
|
+
sessionHead:c,sessionMatchesCanonical:u===g,updateAvailable:l||!f,updateStrategy:ft(w)}}async function rm(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,commandOptions:i,mergedCommit:s,mergedTree:a,
|
|
1362
|
+
oldHead:c,oldIndexTree:u,project:l}){let m={commandOptions:i,project:l},d=await fe(e,t,o,a,m),p=!1;try{await Gn(e,t,n,s,
|
|
1363
|
+
m),p=!0,await y(e,t,["update-ref","HEAD",r,c],m),await y(e,t,["read-tree",r],m);let f=await Je(e,t,l),g=(await cr(e,t,a,
|
|
1364
|
+
f,m)).filter(w=>d.has(w));if(g.length)throw Vn(g);return await ee(e,t,r,m),{currentTree:f,reconciled:!0,status:"updated",
|
|
1365
|
+
updatedPathCount:d.size,updatedPaths:[...d.keys()].sort((w,_)=>w.localeCompare(_)).slice(0,50)}}catch(f){let{headMoved:g,
|
|
1366
|
+
undone:w,written:_}=await va(e,t,{canonicalCommit:r,checkpointCommit:n,checkpointTree:o,mergedTree:a,oldHead:c,oldIndexTree:u,
|
|
1367
|
+
options:m,project:l,switched:p,updatedPathStatuses:d});throw g?Ea():!w||_.length||f?.code===Bn?Vn(_.length?_:f?.changedPaths||
|
|
1368
|
+
[],{undone:w}):f}}async function Aa({commandOptions:e={},operationId:t,project:r={},runCommand:n=x,session:o={}}={}){let i=U(
|
|
1366
1369
|
o,r);await Ye(n,i,{commandOptions:e,project:r});let s=await pt({outerTurnId:`update:${t}`,outcome:"completed",project:G(
|
|
1367
1370
|
i,r),runCommand:n,sessionId:i.sessionId,timestamp:new Date().toISOString(),worktreePath:i.worktreePath}),[a,c]=await Promise.
|
|
1368
1371
|
all([R(n,i,["rev-parse","HEAD"],{commandOptions:e,project:r}),R(n,i,["write-tree"],{commandOptions:e,project:r})]);return{
|
|
1369
1372
|
checkpointCommit:s.commit,checkpointTree:s.tree,oldHead:a,oldIndexTree:c}}async function Ia({checkpoint:e={},commandOptions:t={},
|
|
1370
1373
|
conflictRecovery:r=null,derivedArtifactPaths:n=[],historyReview:o=null,operationId:i,project:s={},reviewedConflictId:a="",
|
|
1371
|
-
runCommand:c=x,session:u={}}={}){let l=U(u,s),{checkpointCommit:
|
|
1372
|
-
c,l,i,{commandOptions:t,project:s}),
|
|
1374
|
+
runCommand:c=x,session:u={}}={}){let l=U(u,s),{checkpointCommit:m,checkpointTree:d,oldHead:p,oldIndexTree:f}=e,{commit:g}=await Ke(
|
|
1375
|
+
c,l,i,{commandOptions:t,project:s}),w=await Ce(c,l,g,p,{commandOptions:t,project:s});if(w||o){if(l.mode!==D)throw O("The\
|
|
1373
1376
|
saved project history no longer descends from this session's starting version.","vibe64_session_update_history_diverged");
|
|
1374
|
-
let T={baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:
|
|
1375
|
-
baseCommit&&r.canonicalCommit===g&&r.oldHead===
|
|
1377
|
+
let T={baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:p,worktreeTree:d};if(!(a&&r?.reviewId===a&&r.baseCommit===l.
|
|
1378
|
+
baseCommit&&r.canonicalCommit===g&&r.oldHead===p&&r.oldIndexTree===f)&&(!o||Object.entries(T).some(([N,J])=>o[N]!==J)))throw O(
|
|
1376
1379
|
"The project history was rewritten. Open Repository, check for updates, then review and reconcile this session.","vibe64\
|
|
1377
|
-
_session_history_review_required")}let _=await qe(c,l,{baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:
|
|
1378
|
-
reconcileHistory:
|
|
1379
|
-
|
|
1380
|
-
changeBaseCommit:_.changeBaseCommit,checkpointCommit:
|
|
1380
|
+
_session_history_review_required")}let _=await qe(c,l,{baseCommit:l.baseCommit,canonicalCommit:g,sessionHead:p,worktreeTree:d,
|
|
1381
|
+
reconcileHistory:w},{commandOptions:t,project:s}),S=new Set(Fe(n)),A=_.changedPaths.filter(T=>!S.has(T)),I=await K(c,l,g,
|
|
1382
|
+
p,{commandOptions:t,project:s});if(I&&!w)return{baseCommit:l.baseCommit,canonicalCommit:g,canonicalTree:_.canonicalTree,
|
|
1383
|
+
changeBaseCommit:_.changeBaseCommit,checkpointCommit:m,checkpointTree:d,currentTree:d,ok:!0,operationId:i,mode:l.mode,reconciled:!0,
|
|
1381
1384
|
repositoryMode:l.mode,sessionCurrent:I,sessionMatchesCanonical:_.sessionMatchesCanonical,status:"already_current"};let P=_.
|
|
1382
1385
|
canonicalTree;if(A.length){let T=await mr(c,l,{commandOptions:t,derivedArtifactPaths:n,project:s,sourceCommit:g,tree:d}),
|
|
1383
|
-
C=await
|
|
1386
|
+
C=await ya(c,l,{baseCommit:_.changeBaseCommit,explicitBase:w,canonicalCommit:g,checkpointTree:T,commandOptions:t,project:s}),
|
|
1384
1387
|
N=C.conflictPaths.length>0?{baseCommit:_.changeBaseCommit,canonicalCommit:g,checkpointTree:d,conflictPaths:C.conflictPaths,
|
|
1385
|
-
conflictTree:C.conflictTree,oldHead:
|
|
1388
|
+
conflictTree:C.conflictTree,oldHead:p,oldIndexTree:f,reviewId:Ta.randomUUID()}:null;P=N?await tm(c,l,{currentRecovery:N,
|
|
1386
1389
|
previousRecovery:r,reviewedConflictId:a,project:s}):C.mergedTree}return{...e,baseCommit:l.baseCommit,canonicalCommit:g,canonicalTree:_.
|
|
1387
1390
|
canonicalTree,changeBaseCommit:_.changeBaseCommit,mergedSourceTree:P,mode:l.mode,operationId:i,repositoryMode:l.mode,sessionCurrent:!0,
|
|
1388
1391
|
...A.length?{}:{sessionMatchesCanonical:!0},status:"prepared"}}async function Ra({commandOptions:e={},derivedArtifactPaths:t=[],
|
|
@@ -1395,46 +1398,46 @@ n,i,{...t,commandOptions:e,project:r});return{...t,ok:!0,...s}}import{access as
|
|
|
1395
1398
|
ebase","rebase-apply"],["cherry-pick or revert","sequencer"]];async function Ca({commandOptions:e={},project:t={},runCommand:r=x,
|
|
1396
1399
|
session:n={},targetCommit:o=""}={}){let i=U(n,t);r=H(r,i,t,{label:"Checking a failed session update"});let s={commandOptions:e,
|
|
1397
1400
|
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)]),
|
|
1399
|
-
c,a,s),Ce(r,i,c,a,s),ar(
|
|
1400
|
-
`),
|
|
1401
|
-
find((S,A)=>
|
|
1402
|
-
l.split("\0").filter(Boolean).map(S=>S.slice(S.indexOf(" ")+1)))].sort(),updateNeeded:
|
|
1403
|
-
"-z",r,n],o),
|
|
1401
|
+
flatMap(([,S])=>["--git-path",S])],s),R(r,i,["ls-files","--unmerged","-z"],s)]),m=h(o),[d,p,f]=await Promise.all([K(r,i,
|
|
1402
|
+
c,a,s),Ce(r,i,c,a,s),ar(m)?K(r,i,m,a,s):!1]),g=u.split(`
|
|
1403
|
+
`),w=await Promise.all(Wn.map((S,A)=>!g[A]||nm(om.resolve(i.worktreePath,g[A])).then(()=>!0,I=>I?.code!=="ENOENT"))),_=Wn.
|
|
1404
|
+
find((S,A)=>w[A]);return{canonicalCommit:c,gitOperation:_?.[0]||"",sessionHead:a,targetInHead:f,unmergedPaths:[...new Set(
|
|
1405
|
+
l.split("\0").filter(Boolean).map(S=>S.slice(S.indexOf(" ")+1)))].sort(),updateNeeded:p||!d}}import Ma from"node:crypto";async function im(e,t,r,n,o={}){let[i,s]=await Promise.all([y(e,t,["diff-tree","--no-commit-id","-r","-M","--name-status",
|
|
1406
|
+
"-z",r,n],o),y(e,t,["diff-tree","--no-commit-id","-r","-M","--numstat","-z",r,n],o)]);return la(i.stdout||i.output,s.stdout||
|
|
1404
1407
|
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.
|
|
1405
1408
|
includes(c))throw O("That file is not part of the current saved-work difference.","vibe64_session_change_not_found",{},{
|
|
1406
|
-
status:404});let u=await
|
|
1409
|
+
status:404});let u=await y(e,t,["--no-literal-pathspecs","diff","--no-ext-diff","--find-renames","--unified=3",r.changeBaseCommit,
|
|
1407
1410
|
r.worktreeTree,"--",...ma(c)],{commandOptions:i,project:a});return{canonicalCommit:r.canonicalCommit,changeBaseCommit:r.
|
|
1408
1411
|
changeBaseCommit,...pa(u.stdout||u.output,s),ok:!0,path:c,worktreeTree:r.worktreeTree}}async function gr({commandOptions:e={},
|
|
1409
1412
|
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
|
|
1411
|
-
runCommand:s,session:a,worktreeTree:c}),
|
|
1412
|
-
{commandOptions:e,project:i}).then(
|
|
1413
|
-
offset:o}),g=r&&f.offset===0&&
|
|
1413
|
+
let u=U(a,i);s=H(s,u,i,{label:"Inspecting session changes"});let l=await yt({commandOptions:e,derivedArtifactPaths:t,project:i,
|
|
1414
|
+
runCommand:s,session:a,worktreeTree:c}),m=new Set(l.changedPaths),d=l.unsaved?await im(s,u,l.changeBaseCommit,l.worktreeTree,
|
|
1415
|
+
{commandOptions:e,project:i}).then(w=>w.filter(_=>m.has(_.path))):[],{items:p,...f}=da(d,{defaultLimit:$n,limit:n,maxLimit:aa,
|
|
1416
|
+
offset:o}),g=r&&f.offset===0&&p.length>0?await ka(s,u,l,p[0].path,{commandOptions:e,project:i}):null;return{...l,files:p,
|
|
1414
1417
|
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
|
|
1416
|
-
derivedArtifactPaths:t,project:o,runCommand:i,session:s});return ka(i,c,u,a,{commandOptions:e,lineLimit:r,project:o})}async function
|
|
1418
|
+
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 yt({commandOptions:e,
|
|
1419
|
+
derivedArtifactPaths:t,project:o,runCommand:i,session:s});return ka(i,c,u,a,{commandOptions:e,lineLimit:r,project:o})}async function yt({
|
|
1417
1420
|
commandOptions:e={},derivedArtifactPaths:t=[],project:r={},runCommand:n=x,session:o={},worktreeTree:i=""}={}){let s=U(o,
|
|
1418
1421
|
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,
|
|
1422
|
+
worktreePath}),[c,u,l,m]=await Promise.all([ur(n,s,{commandOptions:e,project:r}),R(n,s,["rev-parse","--verify","HEAD^{co\
|
|
1420
1423
|
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,
|
|
1424
|
+
"-z"],{commandOptions:e,project:r}),R(n,s,["rev-parse","--show-toplevel"],{commandOptions:e,project:r})]),[d,p,f,g]=await Promise.
|
|
1422
1425
|
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
1426
|
{commandOptions:e,project:r}),qe(n,s,{baseCommit:s.baseCommit,canonicalCommit:c,sessionHead:u,worktreeTree:a},{commandOptions:e,
|
|
1424
|
-
project:r})]),
|
|
1425
|
-
A=l.length===0;return{ahead:
|
|
1427
|
+
project:r})]),w=new Set((Array.isArray(t)?t:[]).map(h).filter(Boolean)),_=g.changedPaths.filter(I=>!w.has(I)),S=mt(p,f),
|
|
1428
|
+
A=l.length===0;return{ahead:p,baseCommit:s.baseCommit,behind:f,branch:s.branch,canonicalCommit:c,canonicalTree:g.canonicalTree,
|
|
1426
1429
|
changeBaseCommit:g.changeBaseCommit,changeBaseTree:g.changeBaseTree,changedPaths:_,destination:ea(r,o),dirty:a!==d||!A,mode:s.
|
|
1427
1430
|
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:
|
|
1431
|
+
tree:a,updateAvailable:f>0,updateStrategy:ft(S),unsaved:_.length>0,worktreeClean:A,worktreeTree:a,worktreeTopLevel:m,worktreePath:s.
|
|
1429
1432
|
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
1433
|
ave requires an assistant-generated commit subject.","vibe64_session_save_message_required",{},{status:400});return R(e,
|
|
1431
1434
|
t,["commit-tree",o,"-p",r],{commandOptions:n,input:`${a}
|
|
1432
1435
|
`,project:s})}async function xa(e,t,{canonicalCommit:r,saveCommit:n},o){let{onPublicationAttempt:i=he}=o;if(t.mode===D){
|
|
1433
1436
|
if(await Dn(e,t,o)!==r)throw O("The local project baseline advanced during Save.","vibe64_session_save_authority_advance\
|
|
1434
|
-
d");await
|
|
1437
|
+
d");await y(e,t,["fetch",t.worktreePath,n],{...o,cwd:t.standaloneSourceRoot}),i(),await y(e,t,["merge","--ff-only",n],{...o,
|
|
1435
1438
|
cwd:t.standaloneSourceRoot});let l=await R(e,t,["rev-parse","HEAD"],{...o,cwd:t.standaloneSourceRoot});return await ee(e,
|
|
1436
1439
|
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
|
|
1440
|
+
let a;i();try{a=await y(e,t,s,{...o,required:!1})}catch(u){a={ok:!1,code:u.code,error:u.message}}let c;try{c=(await R(e,
|
|
1438
1441
|
t,["ls-remote","--heads","origin",`refs/heads/${t.branch}`],o)).split(/\s+/u)[0]||""}catch(u){throw O(`Save publication \
|
|
1439
1442
|
could not be confirmed. Inspect work to recover the prepared commit before retrying. ${h(u.message)}`,"vibe64_session_sa\
|
|
1440
1443
|
ve_publication_unknown",{},{messageCode:"vibe64_session_save_publication_unconfirmed",messageParams:{reason:h(u.message)}})}
|
|
@@ -1453,17 +1456,17 @@ status:"not_applicable"};let s=t.githubMirrorPath,a=(c,u)=>$a(t,r,c,u,!!s);if(!s
|
|
|
1453
1456
|
kind:"none",retryable:!1,status:"not_applicable"};if(!s||!sm.isAbsolute(s))return a("vibe64_session_save_github_mirror_m\
|
|
1454
1457
|
issing","configuration_missing");try{let[c,...u]=kn({mirrorPath:s,remoteUrl:t.remoteUrl}),l=await _t(e,t,c,u,{additionalAllowedRoots:[
|
|
1455
1458
|
s],commandOptions:o,project:i});if(l?.ok!==!0)return a(h(l?.code)||"vibe64_session_save_github_mirror_refresh_failed","r\
|
|
1456
|
-
efresh_failed");let
|
|
1457
|
-
["--git-dir",s,"rev-parse","--verify",`refs/heads/${t.branch}^{commit}`],
|
|
1458
|
-
gin"],
|
|
1459
|
+
efresh_failed");let m={additionalAllowedRoots:[s],commandOptions:o,project:i,required:!1},[d,p]=await Promise.all([y(e,t,
|
|
1460
|
+
["--git-dir",s,"rev-parse","--verify",`refs/heads/${t.branch}^{commit}`],m),y(e,t,["--git-dir",s,"remote","get-url","ori\
|
|
1461
|
+
gin"],m)]),f=d?.ok===!0?ze(d):"",g=p?.ok===!0?ze(p):"";return f!==r||g!==t.remoteUrl?{...a("vibe64_session_save_github_m\
|
|
1459
1462
|
irror_verification_failed","verification_failed"),mirrorCommit:f}:{attempted:!0,branch:t.branch,kind:"github_mirror",mirrorCommit:f,
|
|
1460
1463
|
retryable:!1,status:"current",verifiedCommit:r}}catch{return a("vibe64_session_save_github_mirror_refresh_failed","refre\
|
|
1461
1464
|
sh_interrupted")}}async function Kn(e,t,{checkpointTree:r,commandOptions:n,project:o,saveCommit:i,sessionHead:s=""}){let a={
|
|
1462
1465
|
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:
|
|
1464
|
-
to:i}),d=
|
|
1465
|
-
|
|
1466
|
-
{reconciled:!0,refreshedPaths:l?[...u.keys()].filter(f=>!
|
|
1466
|
+
s)return{reconciled:!1,status:"published_needs_reconcile"};let{changes:u,moved:l,writes:m}=await Hn(e,t,o,{from:r,options:a,
|
|
1467
|
+
to:i}),d=m.size,p=await y(e,t,["update-ref","HEAD",i,c],{...a,required:!1});return p.ok!==!0?{error:h(p.stderr||p.output||
|
|
1468
|
+
p.error),reconciled:!1,status:"published_needs_reconcile",unsavedPathCount:d}:(await y(e,t,["read-tree",i],{...a,required:!1}),
|
|
1469
|
+
{reconciled:!0,refreshedPaths:l?[...u.keys()].filter(f=>!m.has(f)).sort():[],status:"saved",unsavedPathCount:d})}async function am(e,t,r,n,o={}){let i=dr(t,r);return await y(e,t,["update-ref",i,n],o),i}async function La(e,t,r={}){let{
|
|
1467
1470
|
commandOptions:n={},operationId:o,project:i={}}=r;await Ye(e,t,{commandOptions:n,project:i});let s=await pt({outerTurnId:`\
|
|
1468
1471
|
save:${o}`,outcome:"completed",project:G(t,i),runCommand:e,sessionId:t.sessionId,timestamp:new Date().toISOString(),worktreePath:t.
|
|
1469
1472
|
worktreePath}),a=await R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:n,project:i});return{baseCommit:t.
|
|
@@ -1477,21 +1480,21 @@ a=h(r?.checkpointCommit),c=h(r?.checkpointTree);if(!a||!c||h(r?.operationId)!==h
|
|
|
1477
1480
|
r?.branch)!==t.branch||h(r?.mode)!==t.mode)throw O("Save cannot verify the captured worktree. Capture and name the work \
|
|
1478
1481
|
again.","vibe64_session_save_checkpoint_invalid");if(await me(e,t,a,{commandOptions:o,project:s})!==c)throw O("Save cann\
|
|
1479
1482
|
ot verify the captured worktree. Capture and name the work again.","vibe64_session_save_checkpoint_invalid");let l=h(r?.
|
|
1480
|
-
sessionHead),
|
|
1483
|
+
sessionHead),m=l?await R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:s}):"";if(l&&m!==l)throw O(
|
|
1481
1484
|
"The session history changed while Vibe64 was naming this work. Save was not started; try again.","vibe64_session_save_m\
|
|
1482
1485
|
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),[
|
|
1484
|
-
project:c}),R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:c})]),m
|
|
1486
|
+
operationId:a,project:c={},refreshDerivedArtifacts:u}=r,l=h(n.checkpointTree),[m,d]=await Promise.all([Ke(e,t,a,{commandOptions:o,
|
|
1487
|
+
project:c}),R(e,t,["rev-parse","--verify","HEAD^{commit}"],{commandOptions:o,project:c})]),p=m.commit;if(await Ce(e,t,p,
|
|
1485
1488
|
d,{commandOptions:o,project:c}))throw O("Canonical history no longer descends from this session's saved base.","vibe64_s\
|
|
1486
|
-
ession_save_history_diverged");let f=await K(e,t,
|
|
1487
|
-
saved branch has changed. Update this session before saving its work.","vibe64_session_save_update_required",{canonicalCommit:
|
|
1489
|
+
ession_save_history_diverged");let f=await K(e,t,p,d,{commandOptions:o,project:c});if(p!==t.baseCommit&&!f)throw O("The \
|
|
1490
|
+
saved branch has changed. Update this session before saving its work.","vibe64_session_save_update_required",{canonicalCommit:p,
|
|
1488
1491
|
reconciledCommit:t.baseCommit,updateRequired:!0},{messageCode:"vibe64_session_save_branch_changed"});let g=await qe(e,t,
|
|
1489
|
-
{baseCommit:t.baseCommit,canonicalCommit:
|
|
1490
|
-
_=g.changedPaths.filter(N=>!
|
|
1491
|
-
hanges");let S=await mr(e,t,{commandOptions:o,derivedArtifactPaths:i,project:c,sourceCommit:
|
|
1492
|
-
tree:I}=await fr(e,t,{baseCommit:
|
|
1493
|
-
P=await Na(e,t,{canonicalCommit:
|
|
1494
|
-
project:c}),C=await R(e,t,["show","-s","--format=%ae",P],{commandOptions:o,project:c});return{canonicalCommit:
|
|
1492
|
+
{baseCommit:t.baseCommit,canonicalCommit:p,sessionHead:d,worktreeTree:l},{commandOptions:o,project:c}),w=new Set(Fe(i)),
|
|
1493
|
+
_=g.changedPaths.filter(N=>!w.has(N));if(!_.length)throw O("This session has no work to save.","vibe64_session_save_no_c\
|
|
1494
|
+
hanges");let S=await mr(e,t,{commandOptions:o,derivedArtifactPaths:i,project:c,sourceCommit:p,tree:l}),{derivedArtifactsKept:A,
|
|
1495
|
+
tree:I}=await fr(e,t,{baseCommit:p,commandOptions:o,derivedArtifactPaths:i,project:c,refreshDerivedArtifacts:u,tree:S}),
|
|
1496
|
+
P=await Na(e,t,{canonicalCommit:p,commandOptions:o,mergedTree:I,message:s,project:c}),T=await am(e,t,a,P,{commandOptions:o,
|
|
1497
|
+
project:c}),C=await R(e,t,["show","-s","--format=%ae",P],{commandOptions:o,project:c});return{canonicalCommit:p,changeBaseCommit:g.
|
|
1495
1498
|
changeBaseCommit,changedPaths:_,...A?{derivedArtifactsKept:A}:{},mergedTree:I,preparedRef:T,saveCommit:P,standInIdentity:sn(
|
|
1496
1499
|
C)}}async function lm(e,t,r={}){let{commandOptions:n={},onPublicationAttempt:o,prepared:i={},project:s={}}=r;return xa(e,
|
|
1497
1500
|
t,{canonicalCommit:h(i.canonicalCommit),saveCommit:h(i.saveCommit)},{commandOptions:n,onPublicationAttempt:o,project:s})}
|
|
@@ -1503,37 +1506,37 @@ standInIdentity===!0,status:o.status,verifiedCommit:n,...o}}function pm(e,t){ret
|
|
|
1503
1506
|
retryable:!1,status:"not_applicable"}:{attempted:!1,branch:e.branch,kind:"github_mirror",retryable:!1,status:"deferred",
|
|
1504
1507
|
verifiedCommit:t}}async function Jn({commandOptions:e={},operationId:t="",project:r={},runCommand:n=x,session:o={},verifiedCommit:i=""}={}){
|
|
1505
1508
|
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
|
|
1509
|
+
project:r})}async function mm(e,t,r,n={}){h(r)&&await wt(e,t,dr(t,r),n)}async function Da({checkpoint:e=null,commandOptions:t={},deferCacheMaintenance:r=!1,derivedArtifactPaths:n=[],message:o="",
|
|
1507
1510
|
operationId:i=Ma.randomUUID(),project:s={},refreshDerivedArtifacts:a,runCommand:c=x,runProjectSourceExclusive:u=async d=>d(),
|
|
1508
|
-
onProgress:l=he,session:
|
|
1511
|
+
onProgress:l=he,session:m={}}={}){let d=U(m,s);return c=H(c,d,s,{label:"Saving session work",operationId:i}),await l({kind:"\
|
|
1509
1512
|
lock",message:"Waiting for exclusive repository access.",stage:"repository-lock"}),u(async()=>{await l({baseCommit:d.baseCommit,
|
|
1510
1513
|
branch:d.branch,kind:"checkpoint",message:"Capturing the complete session worktree.",mode:d.mode,operationId:i,stage:"ch\
|
|
1511
|
-
eckpointing"});let
|
|
1512
|
-
|
|
1513
|
-
checkpointTree,kind:"checkpoint",message:"Session checkpoint captured.",sessionHead:
|
|
1514
|
+
eckpointing"});let p;e?(await Ye(c,d,{commandOptions:t,project:s}),p=await cm(c,d,e,{commandOptions:t,operationId:i,project:s})):
|
|
1515
|
+
p=await La(c,d,{commandOptions:t,operationId:i,project:s}),await l({checkpointCommit:p.checkpointCommit,checkpointTree:p.
|
|
1516
|
+
checkpointTree,kind:"checkpoint",message:"Session checkpoint captured.",sessionHead:p.sessionHead,stage:"checkpointed"}),
|
|
1514
1517
|
await l({kind:"canonical",message:"Reading the current canonical branch.",stage:"canonical-reading"});let f=await um(c,d,
|
|
1515
|
-
{checkpoint:
|
|
1516
|
-
|
|
1518
|
+
{checkpoint:p,commandOptions:t,derivedArtifactPaths:n,message:o,operationId:i,project:s,refreshDerivedArtifacts:a}),g=!1,
|
|
1519
|
+
w;try{await l({expectedCanonicalCommit:f.canonicalCommit,kind:"canonical",message:"Canonical branch read.",stage:"canoni\
|
|
1517
1520
|
cal-read"}),await l({expectedCanonicalCommit:f.canonicalCommit,kind:"publish",mergedTree:f.mergedTree,message:"Save comm\
|
|
1518
1521
|
it prepared.",proposedCommit:f.saveCommit,stage:"prepared"}),await l({kind:"publish",message:"Pushing the Save commit.",
|
|
1519
|
-
stage:"publishing"}),
|
|
1520
|
-
await
|
|
1521
|
-
Canonical Save commit verified.",stage:"published",verifiedCommit:
|
|
1522
|
-
session onto the saved commit.",stage:"reconciling"});let _=await Kn(c,d,{checkpointTree:
|
|
1523
|
-
project:s,saveCommit:f.saveCommit,sessionHead:
|
|
1524
|
-
runCommand:c,session:
|
|
1525
|
-
message,stage:"cache-maintenance-warning"}),r||await mm(c,d,i,{commandOptions:t,project:s}),dm(d,
|
|
1522
|
+
stage:"publishing"}),w=await lm(c,d,{commandOptions:t,onPublicationAttempt(){g=!0},prepared:f,project:s})}catch(A){throw g||
|
|
1523
|
+
await y(c,d,["update-ref","-d",f.preparedRef,f.saveCommit],{commandOptions:t,project:s}),A}await l({kind:"publish",message:"\
|
|
1524
|
+
Canonical Save commit verified.",stage:"published",verifiedCommit:w}),await l({kind:"reconcile",message:"Reconciling the\
|
|
1525
|
+
session onto the saved commit.",stage:"reconciling"});let _=await Kn(c,d,{checkpointTree:p.checkpointTree,commandOptions:t,
|
|
1526
|
+
project:s,saveCommit:f.saveCommit,sessionHead:p.sessionHead}),S=r?pm(d,w):await Jn({commandOptions:t,operationId:i,project:s,
|
|
1527
|
+
runCommand:c,session:m,verifiedCommit:w});return S.retryable===!0&&await l({cacheMaintenance:S,kind:"cache-warning",message:S.
|
|
1528
|
+
message,stage:"cache-maintenance-warning"}),r||await mm(c,d,i,{commandOptions:t,project:s}),dm(d,p,f,w,{cacheMaintenance:S,
|
|
1526
1529
|
..._})},{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:
|
|
1530
|
+
return Da({...e,deferCacheMaintenance:!0,refreshDerivedArtifacts:t})},"save-maintenance":Jn,"save-message":ja,work:yt,"u\
|
|
1528
1531
|
pdate-failure":Ca,"update-checkpoint":Aa,"update-prepare":Ia,"update-derived":async e=>{let{refreshGenesisCities:t}=await import("@local/vibe64-genesis/server");
|
|
1529
1532
|
return Ra({...e,refreshDerivedArtifacts:t})},"update-apply":Pa},Ua=new AbortController;function gm(e={}){return be(e.command,
|
|
1530
1533
|
e.args,{cwd:e.cwd,env:{...process.env,...e.env||{}},execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,outputEncoding:e.
|
|
1531
1534
|
outputEncoding,signal:Ua.signal,timeout:e.timeout})}async function _m(){let e="";for await(let t of process.stdin)if(e+=
|
|
1532
1535
|
String(t||""),Buffer.byteLength(e)>fm)throw new Error("Session repository operation input is too large.");return JSON.parse(
|
|
1533
|
-
e||"{}")}function
|
|
1536
|
+
e||"{}")}function wm(e){return{error:{code:String(e?.code||"vibe64_session_work_operation_failed"),details:e?.details&&typeof e.
|
|
1534
1537
|
details=="object"&&!Array.isArray(e.details)?e.details:{},message:String(e?.message||"Session repository operation faile\
|
|
1535
1538
|
d."),...e?.messageCode?{messageCode:e.messageCode,messageParams:e.messageParams}:{},status:e instanceof te?e.status:500},
|
|
1536
1539
|
ok:!1}}try{let e=await _m();e?.stoppable===!0&&process.once("SIGTERM",()=>Ua.abort()),Zr(e?.hostProfile||null);let t=hm[String(
|
|
1537
1540
|
e?.operation||"")];if(!t){let n=new Error("Unsupported session repository operation.");throw n.code="vibe64_session_work\
|
|
1538
1541
|
_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(
|
|
1542
|
+
write(JSON.stringify({ok:!0,value:r}))}catch(e){process.stdout.write(JSON.stringify(wm(e))),process.exitCode=1}
|