vibe64 0.1.57 → 0.1.58
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 +585 -585
- package/bin/server.js +169 -169
- package/bin/upgrade-state.js +1161 -1161
- package/dist/assets/{GithubBrowserTabs-DfRzbuSv.js → GithubBrowserTabs-D_nMB5Y1.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-7LqUsfAQ.js → LocalDatabaseServer-BgO_aeUg.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-DGm_9G9A.js → Vibe64AuthSettingsButton-Bx9patil.js} +1 -1
- package/dist/assets/{Vibe64ConversationLog-DlwCuaVi.js → Vibe64ConversationLog-DtOgxPNR.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-CZ5cMJ9k.js → Vibe64DashboardShell-DhPE6H3P.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-DfZpwSzB.js → Vibe64DatabaseWorkspace-CHV0cd3l.js} +1 -1
- package/dist/assets/{Vibe64OutputControls-CkXzIhro.js → Vibe64OutputControls-mNWUWLSm.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-BZQwcfGG.js → Vibe64SessionFiles-BXt__PJL.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-CSX0GD_w.js → Vibe64SessionSourceEditor-NyG6niQM.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-Tml9lmTO.js → Vibe64UiStoryboardView-BXH2MSWn.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-D1LJQ7jc.js → Vibe64UnavailableSessions-CCPWJo8e.js} +1 -1
- package/dist/assets/{_pageId_-myxTAoqm.js → _pageId_-D54CqzqG.js} +1 -1
- package/dist/assets/{_sessionId_-BM4eQHUu.js → _sessionId_-CW044RVi.js} +1 -1
- package/dist/assets/{_slug_-C1Zt2FsE.js → _slug_-CRtFhc0A.js} +5 -5
- package/dist/assets/{_slug_-BvyD0DHo.css → _slug_-WWvJTLoc.css} +1 -1
- package/dist/assets/{access-DbK06uO7.js → access-ChMLRErk.js} +1 -1
- package/dist/assets/{app-D35Na9o5.js → app-D9FegZf0.js} +1 -1
- package/dist/assets/assistantRouting-D4SnnxJn.js +3 -0
- package/dist/assets/{client-C5sPrfkm.js → client-BBqNv4HL.js} +1 -1
- package/dist/assets/{client-CjNw-kf-.js → client-DnjkdG6K.js} +1 -1
- package/dist/assets/{client-DT3BbWpI.js → client-Dra4Vp3A.js} +2 -2
- package/dist/assets/{client-BTq67t0Y.js → client-DuDOzb5A.js} +2 -2
- package/dist/assets/{client-CkV1cE5C.js → client-mU-LObHG.js} +1 -1
- package/dist/assets/{dashboard-CbOtBwwu.js → dashboard-B26QwE6y.js} +1 -1
- package/dist/assets/{english-definitions--F8iwoB9.js → english-definitions-I9tIXY2u.js} +1 -1
- package/dist/assets/{env-BxyHxFmS.js → env-BXsvM592.js} +1 -1
- package/dist/assets/{health-Bnnb6E2j.js → health-C4WtefLm.js} +1 -1
- package/dist/assets/{history-1Xemjfmv.js → history-HHPFoNi3.js} +1 -1
- package/dist/assets/index-BBfSvf2i.css +1 -0
- package/dist/assets/{index-Btrr1DGq.js → index-Bvd00puv.js} +3 -3
- package/dist/assets/{integrations-hQJR-UJM.js → integrations-CQNJxkMu.js} +1 -1
- package/dist/assets/{issues-0y_naQdl.js → issues-BHr_nI-9.js} +1 -1
- package/dist/assets/{learning-CG0NUB8v.js → learning-0cINHUSN.js} +1 -1
- package/dist/assets/{pages-CHjGYtFn.js → pages-CIKw99GN.js} +1 -1
- package/dist/assets/{project-files-S6i36bSy.js → project-files-CklWobqZ.js} +1 -1
- package/dist/assets/{publish-BmfmLaWn.js → publish-Cot797YN.js} +1 -1
- package/dist/assets/{pull-requests-COBi3Wfj.js → pull-requests-ybnixBv0.js} +1 -1
- package/dist/assets/{settings-D0U9Lxsg.js → settings-DJByC5Wb.js} +1 -1
- package/dist/assets/{useArchivedVibe64Sessions-DQcmDT-k.js → useArchivedVibe64Sessions-B-DtXrk-.js} +1 -1
- package/dist/assets/{useVibe64ConversationLog-yo2ewb9G.js → useVibe64ConversationLog-BVANhCHq.js} +2 -2
- package/dist/assets/{useVibe64SessionData-DngAc96i.js → useVibe64SessionData-rBvWMqyc.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-Cxt1pCjM.js → useVibe64SessionSelection-C546mBu8.js} +1 -1
- package/dist/assets/{vibe64SessionFocus-CQraoYFY.js → vibe64SessionFocus-CxX2nK6F.js} +1 -1
- package/dist/assets/vibe64SessionFocus-DW73PN_o.css +1 -0
- package/dist/index.html +5 -5
- package/docs/colleague-usage/auto-workflow.md +2 -2
- package/docs/colleague-usage/chat-settings.md +7 -3
- package/docs/colleague-usage/coding-agents.md +10 -0
- package/docs/colleague-usage/sessions.md +2 -1
- package/docs/colleague-usage/ui-pass.md +8 -8
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +2 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-core/README.md +8 -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 +3 -0
- package/node_modules/@jskit-ai/kernel/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +2 -0
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +2 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/CHANGELOG.md +5 -0
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/patterns/table-resource/PATTERN.md +7 -4
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-execution/src/server/gitTurnCheckpointCommand.js +145 -530
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +89 -89
- package/node_modules/@local/vibe64-genesis/src/server/index.js +270 -267
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +41 -41
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +66 -66
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +318 -318
- package/package.json +14 -14
- package/server.bundle.mjs +33438 -33403
- package/dist/assets/assistantRouting--Xm-hai_.js +0 -3
- package/dist/assets/index-CmzEKG3z.css +0 -1
- package/dist/assets/vibe64SessionFocus-CcHYt9SU.css +0 -1
package/bin/run.js
CHANGED
|
@@ -4,45 +4,45 @@ var Bl=Object.defineProperty;var g=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(
|
|
|
4
4
|
ditor/src/server/agentSpecs.js",import.meta.url).href,xi=e=>()=>Wl(new URL(`../../docs/${e}`,ql),"utf8"),$i=Object.freeze(
|
|
5
5
|
[{name:"integration-setup-command",title:"Integration setup command protocol and integrations.json",text:xi("application\
|
|
6
6
|
-integration-setup.md")},{name:"integration-payments-laravel",title:"Implementing the integration setup payment operatio\
|
|
7
|
-
ns in Laravel",text:xi("application-payments-laravel.md")}])});var
|
|
8
|
-
return!!(e&&typeof e=="object"&&!Array.isArray(e))}var
|
|
9
|
-
dBack","unknown"])});function
|
|
10
|
-
name="AppError",this.status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=
|
|
11
|
-
n.messageCode&&(this.messageCode=String(n.messageCode),this.messageParams=
|
|
7
|
+
ns in Laravel",text:xi("application-payments-laravel.md")}])});var At,ur,Yl,lr,Li=g(()=>{At="email",ur="login",Yl="user-id",lr=Object.freeze([At,ur,Yl])});function V(e,{fallback:t=""}={}){return String(e||"").trim()||t}function te(e,{fallback:t={}}={}){return B(e)?e:{...t}}function B(e){
|
|
8
|
+
return!!(e&&typeof e=="object"&&!Array.isArray(e))}var Dw,G=g(()=>{Dw=Object.freeze(["none","pending","committed","rolle\
|
|
9
|
+
dBack","unknown"])});function dr(e){return B(e)?{...e}:{}}var Tn=g(()=>{G()});var ae,pr=g(()=>{Tn();ae=class extends Error{constructor(t,r,n={}){super(r,n.cause===void 0?void 0:{cause:n.cause}),this.
|
|
10
|
+
name="AppError",this.status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=dr(n.params),
|
|
11
|
+
n.messageCode&&(this.messageCode=String(n.messageCode),this.messageParams=dr(n.messageParams)),this.details=n.details,this.
|
|
12
12
|
headers=n.headers||{}}}});var Mi=g(()=>{G()});var Di=g(()=>{G()});function ee(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===
|
|
13
13
|
null||Kl(t)}function Kl(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===
|
|
14
|
-
0}var
|
|
15
|
-
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function
|
|
14
|
+
0}var Ot=g(()=>{});function In(e){return e!==null&&typeof e=="object"&&ee(e.structure)&&ee(e.operations)&&typeof e.validateWith=="function"&&
|
|
15
|
+
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function mr(e,t){if(!Object.hasOwn(t,"items"))return null;
|
|
16
16
|
let{items:r}=t;if(In(r))return{kind:"schema",schema:r};if(!ee(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
17
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
17
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Rt(e,t){
|
|
18
18
|
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(In(r))return{kind:"schema",schema:r};if(!ee(r)||typeof r.type!=
|
|
19
19
|
"string")throw new Error(`Object field "${e}" must define values as either a Schema instance or a field definition objec\
|
|
20
|
-
t.`);return{kind:"definition",definition:r}}function
|
|
20
|
+
t.`);return{kind:"definition",definition:r}}function fr(e,t){let r=Object.hasOwn(t,"schema"),n=Object.hasOwn(t,"values"),
|
|
21
21
|
o=Object.hasOwn(t,"additionalProperties");if(r&&n)throw new Error(`Object field "${e}" cannot define both schema and val\
|
|
22
22
|
ues.`);if(o&&t.additionalProperties!==!0)throw new Error(`Object field "${e}" only supports additionalProperties: true.`);
|
|
23
23
|
if(n&&t.additionalProperties===!0)throw new Error(`Object field "${e}" cannot define both values and additionalPropertie\
|
|
24
24
|
s: true.`);if(r){if(!In(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
|
|
25
|
-
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:
|
|
26
|
-
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}var An=g(()=>{
|
|
25
|
+
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Rt(
|
|
26
|
+
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}var An=g(()=>{Ot()});function tt(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}var On=g(
|
|
27
27
|
()=>{});function rd(e){return e%4===0&&(e%100!==0||e%400===0)}function nd(e,t){return t===2?rd(e)?29:28:td[t-1]}function Wi(e,t,r){
|
|
28
|
-
let n=Number(e),o=Number(t),i=Number(r);return o>=1&&o<=12&&i>=1&&i<=nd(n,o)}function
|
|
28
|
+
let n=Number(e),o=Number(t),i=Number(r);return o>=1&&o<=12&&i>=1&&i<=nd(n,o)}function Pt(e,t){let r=e.temporalPrecision;
|
|
29
29
|
if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(`temporalPrecision for "${t}" must be a non-negative integer\
|
|
30
30
|
.`);return r}}function Yi(e,t){return e===void 0?!0:t===void 0||e.length<=t}function Ji(e){if(typeof e!="string")return!1;
|
|
31
31
|
let t=Xl.exec(e);return t!==null&&Wi(t[1],t[2],t[3])}function Ki(e,t){if(typeof e!="string")return!1;let r=Ql.exec(e);return r!==
|
|
32
32
|
null&&Yi(r[1],t)}function Xi(e,t){if(typeof e!="string")return!1;let r=Zl.exec(e);return r===null?!1:Wi(r[1],r[2],r[3])&&
|
|
33
|
-
Yi(r[4],t)}function Qi(e){return e===void 0?"(?:\\.\\d+)?":e===0?"":`(?:\\.\\d{1,${e}})?`}function Zi(e,t){let r=
|
|
34
|
-
return`^${
|
|
33
|
+
Yi(r[4],t)}function Qi(e){return e===void 0?"(?:\\.\\d+)?":e===0?"":`(?:\\.\\d{1,${e}})?`}function Zi(e,t){let r=Pt(e,t);
|
|
34
|
+
return`^${hr}(?::${rt}${Qi(r)})?$`}function es(e,t){let r=Pt(e,t);return`^${Fi}T${hr}:${rt}${Qi(r)}${Hi}$`}function Pn(e,t){
|
|
35
35
|
let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&ed.test(e))r=Number(e);else return null;return!Number.isSafeInteger(
|
|
36
|
-
r)||r<-t||r>t?null:r===0?0:r}var Rn,Ui,Vi,Gi,Bi,rt,
|
|
37
|
-
\\d{4}",Vi="0[1-9]|1[0-2]",Gi="0[1-9]|[12]\\d|3[01]",Bi="[01]\\d|2[0-3]",rt="[0-5]\\d",
|
|
36
|
+
r)||r<-t||r>t?null:r===0?0:r}var Rn,Ui,Vi,Gi,Bi,rt,hr,Hi,zi,Fi,qi,Xl,Ql,Zl,ed,td,Nn=g(()=>{Rn="^(?:0|-?[1-9]\\d*)$",Ui="\
|
|
37
|
+
\\d{4}",Vi="0[1-9]|1[0-2]",Gi="0[1-9]|[12]\\d|3[01]",Bi="[01]\\d|2[0-3]",rt="[0-5]\\d",hr=`(?:${Bi}):${rt}`,Hi=`(?:Z|[+-\
|
|
38
38
|
](?:${Bi}):${rt})`,zi=`(${Ui})-(${Vi})-(${Gi})`,Fi=`${Ui}-(?:${Vi})-(?:${Gi})`,qi=`^${Fi}$`,Xl=new RegExp(`^${zi}$`),Ql=
|
|
39
|
-
new RegExp(`^${
|
|
39
|
+
new RegExp(`^${hr}(?::${rt}(?:\\.(\\d+))?)?$`),Zl=new RegExp(`^${zi}T${hr}:${rt}(?:\\.(\\d+))?${Hi}$`),ed=new RegExp(Rn),
|
|
40
40
|
td=[31,28,31,30,31,30,31,31,30,31,30,31]});function R(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function id(e,t){if(od.
|
|
41
41
|
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function sd(e){return typeof e!="string"?e:e.replace(
|
|
42
42
|
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Cn(e,t,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
43
43
|
let o=r?sd(e):e;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${t}() expects a non-empty \
|
|
44
44
|
dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${t}() received an invalid path "${o}".`);
|
|
45
|
-
for(let s of i)id(s,t);return i}var od,
|
|
45
|
+
for(let s of i)id(s,t);return i}var od,Nt=g(()=>{od=new Set(["__proto__","prototype","constructor"])});function ts(e){return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Rn}]}}function Me(e,t){return{
|
|
46
46
|
[Ie]:{[e]:t}}}function Mn(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];if(n&&o&&typeof n=="object"&&typeof o=="ob\
|
|
47
47
|
ject"&&!Array.isArray(n)&&!Array.isArray(o)){Mn(o,n);continue}e[r]=n}}function pd(e,t){if(!t||typeof t!="object"||Array.
|
|
48
48
|
isArray(t))throw new Error("JSON Schema export hooks must return an object or null.");for(let r of Object.keys(t)){if(r===
|
|
@@ -60,42 +60,42 @@ s: mode '${r}' does not match operation '${t.operation}'.`)}if(t.operation!==voi
|
|
|
60
60
|
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return rs(t.mode)}function wd(e,t={}){
|
|
61
61
|
if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
|
|
62
62
|
let r=gd(e,t);return{operationName:r,operation:e.operations[r]}}function yd(e={}){let t={...e};return Object.defineProperty(
|
|
63
|
-
t,xn,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function
|
|
63
|
+
t,xn,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function wr(e={}){return e[xn]?
|
|
64
64
|
e[xn]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function _d(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
|
|
65
65
|
"_").replace(/^_+|_+$/g,"")||"operation"}function $n(e){return ee(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
|
|
66
|
-
function
|
|
66
|
+
function gr(e){return $n(e)?{allOf:[e]}:e}function Ed(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
|
|
67
67
|
r&&i.operation===n&&i.additionalProperties===o)||null}function bd(e,t){let r=_d(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
68
|
-
return e.nextDefinitionId+=1,n}function ns(e,t,r,n,o,{root:i=!1}={}){let s=
|
|
68
|
+
return e.nextDefinitionId+=1,n}function ns(e,t,r,n,o,{root:i=!1}={}){let s=wr(t),a=Ed(s,e,r,n,o);if(a)return i&&(a.pointer=
|
|
69
69
|
"#",s.rootNode=a),a;let c={schema:e,operationName:r,operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
70
70
|
bd(s,r),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function os(e,t){
|
|
71
|
-
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=
|
|
71
|
+
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=wr(t);e.status="build\
|
|
72
72
|
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=vd(e.schema,t,e.operationName,e.operation,e.additionalProperties);
|
|
73
73
|
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function Dn(e,t,r,n,o=!1){
|
|
74
|
-
let i=
|
|
74
|
+
let i=wr(t),s=ns(e,t,r,n,o);return i.rootNode===s?{$ref:"#"}:os(s,t)}function Ct(e,{referenceBacked:t=!1}={}){return{schema:e,
|
|
75
75
|
referenceBacked:t}}function vd(e,t,r,n,o=!1){let i={},s=[];for(let[c,u]of Object.entries(e.structure))R(i,c,Un(e,c,u,t,r,
|
|
76
76
|
n)),n.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
|
|
77
|
-
0&&(a.required=s),a}function Sd(e,t,r,n,o,i){let s=
|
|
77
|
+
0&&(a.required=s),a}function Sd(e,t,r,n,o,i){let s=mr(t,r);if(!s)return null;if(s.kind==="schema")return{...gr(Dn(s.schema,
|
|
78
78
|
n,"replace",s.schema.operations.replace,!1)),[Ie]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,
|
|
79
79
|
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return Un(e,`${t}[]`,r.items,n,a,c)}function Td(e,t,r,n,o,i){
|
|
80
|
-
let s=
|
|
80
|
+
let s=Rt(t,r);if(!s)return null;if(s.kind==="schema")return{...gr(Dn(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
81
81
|
[Ie]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="re\
|
|
82
|
-
place"?e.operations.replace:i;return Un(e,`${t}.*`,s.definition,n,a,c)}function Id(e,t,r,n,o,i){if(r.type==="object"){let a=
|
|
83
|
-
t,r);if(a.kind==="nested")return
|
|
84
|
-
"opaque")return
|
|
82
|
+
place"?e.operations.replace:i;return Un(e,`${t}.*`,s.definition,n,a,c)}function Id(e,t,r,n,o,i){if(r.type==="object"){let a=fr(
|
|
83
|
+
t,r);if(a.kind==="nested")return Ct(Dn(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
84
|
+
"opaque")return Ct({type:"object",additionalProperties:!0});if(a.kind==="map")return Ct({type:"object",additionalProperties:Td(
|
|
85
85
|
e,t,r,n,o,i)})}let s=fd(e,r)({schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n});if(!s||typeof s!="object"||
|
|
86
86
|
Array.isArray(s))throw new Error(`Type '${r.type}' on field '${t}' returned an invalid JSON Schema fragment.`);if(r.type===
|
|
87
|
-
"array"){let a=Sd(e,t,r,n,o,i);if(a)return
|
|
87
|
+
"array"){let a=Sd(e,t,r,n,o,i);if(a)return Ct({...s,items:a},{referenceBacked:$n(s)})}return Ct(s,{referenceBacked:$n(s)})}
|
|
88
88
|
function Un(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n},a=Id(e,t,r,n,o,i),c=a.referenceBacked?
|
|
89
|
-
|
|
89
|
+
gr(a.schema):{...a.schema},u={castType:r.type};for(let f of Object.keys(r)){if(f==="type"||!Object.hasOwn(e.validators,f))
|
|
90
90
|
continue;let h=hd(e,f,t);if(!h)continue;let y=h({...s,parameterName:f,parameterValue:r[f],fieldSchema:{...c}});y&&pd(c,y)}
|
|
91
91
|
c[Ie]&&(Mn(u,c[Ie]),delete c[Ie]);let l=[];r.nullable===!0&&l.push({type:"null"}),r.nullOnEmpty===!0&&l.push({const:""});
|
|
92
|
-
let m=
|
|
92
|
+
let m=gr(md(c,l));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.defaultTo!="function"){let f=e._normalizeDefault(
|
|
93
93
|
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
94
94
|
o,i,{})});if(Object.keys(f.errors).length>0){let h=Object.values(f.errors)[0];throw new Error(`defaultTo for "${t}" is i\
|
|
95
95
|
nvalid (${h.code}).`)}m.default=f.value}else u.defaults={providedByFunction:!0};return m[Ie]=u,m}function is(e,t={}){let r=yd(
|
|
96
|
-
t),{operationName:n,operation:o}=wd(e,r),i=r.additionalProperties===void 0?!1:r.additionalProperties,s=
|
|
96
|
+
t),{operationName:n,operation:o}=wd(e,r),i=r.additionalProperties===void 0?!1:r.additionalProperties,s=wr(r),a=ns(e,r,n,
|
|
97
97
|
o,i,{root:!0}),c={$schema:ad,...os(a,r)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}var ad,
|
|
98
|
-
Ie,kn,xn,cd,ud,ld,dd,ss=g(()=>{An();On();Nn();
|
|
98
|
+
Ie,kn,xn,cd,ud,ld,dd,ss=g(()=>{An();On();Nn();Ot();Nt();ad="http://json-schema.org/draft-07/schema#",Ie="x-json-rest-sch\
|
|
99
99
|
ema",kn=["object","array","string","number","boolean"],xn=Symbol("json-rest-schema.exportContext"),cd=["true","1","yes",
|
|
100
100
|
"y","on"],ud=["false","0","no","n","off"];ld={none:()=>({type:kn}),blob:()=>({type:kn}),serialize:()=>({type:kn}),object:()=>({
|
|
101
101
|
type:"object"}),array:()=>({type:"array"}),file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["n\
|
|
@@ -120,17 +120,17 @@ startsWith(r)?e.slice(r.length):null}function nt(e,t){let r={};for(let n of Obje
|
|
|
120
120
|
{...n,field:o})}return r}function Bn(e){return Cn(e,"validatePath")}function ls(e){let t={};for(let r of e){let n=Bn(r),
|
|
121
121
|
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||R(o,s,Ad()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
122
122
|
return t}function Od(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}
|
|
123
|
-
function
|
|
123
|
+
function yr(e){return e===null?!0:Array.isArray(e)||ee(e)?Object.keys(e).length>0:e!==void 0}function ds(e){return[...e].
|
|
124
124
|
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)})}
|
|
125
125
|
function Rd(e){return/^[0-9]+$/.test(e)}function Pd(e,t=new WeakMap){if(t.has(e))return t.get(e);let r=Object.create(it.
|
|
126
126
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
127
|
-
|
|
127
|
+
Er(_r(e.structure,t)),r._installOperationMethods(),Object.freeze(r)}function _r(e,t=new WeakMap){if(e===null||typeof e!=
|
|
128
128
|
"object")return e;if(zn(e))return Pd(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
129
129
|
e.source,e.flags);return n.lastIndex=e.lastIndex,n}if(t.has(e))return t.get(e);if(Array.isArray(e)){let n=[];t.set(e,n);
|
|
130
|
-
for(let o of e)n.push(
|
|
131
|
-
o,t));return r}function
|
|
132
|
-
isArray(e))for(let r of e)
|
|
133
|
-
return
|
|
130
|
+
for(let o of e)n.push(_r(o,t));return n}if(!ee(e))return e;let r={};t.set(e,r);for(let[n,o]of Object.entries(e))R(r,n,_r(
|
|
131
|
+
o,t));return r}function Er(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||zn(e))return e;if(t.add(e),Array.
|
|
132
|
+
isArray(e))for(let r of e)Er(r,t);else for(let r of Reflect.ownKeys(e))Er(e[r],t);return Object.freeze(e)}function Vn(e){
|
|
133
|
+
return Er(_r(e))}function Hn(e,t,r=""){if(!zn(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;if(!Object.hasOwn(
|
|
134
134
|
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=fs(r,n);return hs(e,i,o,s)}function hs(e,t,r,n){
|
|
135
135
|
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:Hn(o.schema,r,n)}if(t?.type===
|
|
136
136
|
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!Rd(i))return null;let a=De(
|
|
@@ -148,7 +148,7 @@ void 0?!0:t.rejectExplicitUndefined})}function kd(e={}){if(typeof e!="object"||e
|
|
|
148
148
|
"Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(Nd))R(t,r,n);for(let[r,n]of Object.
|
|
149
149
|
entries(e))R(t,r,Cd(r,n));return Object.freeze(t)}function ms(e){let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
150
150
|
e))R(t,r,n);return Object.freeze(t)}function xd(e){let t={...e};return delete t.operation,delete t.mode,t}var Nd,it,gs=g(
|
|
151
|
-
()=>{ss();An();
|
|
151
|
+
()=>{ss();An();Nt();Ot();Nd=Object.freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,
|
|
152
152
|
outputFields:"validated",rejectExplicitUndefined:!0}),replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,
|
|
153
153
|
outputFields:"validated",rejectExplicitUndefined:!0}),patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,
|
|
154
154
|
outputFields:"input",rejectExplicitUndefined:!0})});it=class{constructor(t,r,n,o={}){this.structure=t,this.types=ms(r),this.
|
|
@@ -170,7 +170,7 @@ options `operation` and `mode` must match when both are provided.");if(!Object.h
|
|
|
170
170
|
`Unknown operation "${r}".`);let n=this.operations[r];return{operationName:r,operation:n,validationOptions:xd(t)}}_buildOperationResult(t,r,n){
|
|
171
171
|
let o={};for(let i of n.outputFieldNames){if(!Object.hasOwn(this.structure,i))continue;let s=n.isFieldPresent(i);(r[i]!==
|
|
172
172
|
void 0||s&&t[i]===null||n.defaultedFields.has(i))&&(!s&&!n.defaultedFields.has(i)||R(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){
|
|
173
|
-
return
|
|
173
|
+
return fr(t,r)}_resolveArrayItemsConfig(t,r){return mr(t,r)}_resolveObjectValuesConfig(t,r){return Rt(t,r)}_buildArrayItemSettings(t,r){
|
|
174
174
|
return t.type==="object"&&Object.hasOwn(t,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(t,r,n,o,i,s,a,c){
|
|
175
175
|
let u=t.nullable===!0||a.nullable===!0,l=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,t.type))throw new Error(
|
|
176
176
|
`No casting function for type: ${t.type}`);let m=this.types[t.type];if(r===null)return u?(R(o,i,null),{errors:{},shouldContinue:!1}):
|
|
@@ -229,7 +229,7 @@ length===0&&R(o,t,p.value)}return h}if(f===void 0)return u&&s.rejectExplicitUnde
|
|
|
229
229
|
a).errorObject):{};let y={[t]:f};if(u){let d=this._normalizeAndValidateValue(c,f,a,y,t,n,i,s);return Object.hasOwn(y,t)&&
|
|
230
230
|
y[t]!==void 0?R(o,t,y[t]):y[t]===null&&R(o,t,null),d}if(!l)return{};let T=this._castValue(c,f,a,y,t,n,i,s);if(Object.keys(
|
|
231
231
|
T.errors).length>0)return T.errors;if(!T.shouldContinue)return{};let S=this._validateSelectedDescendants(c,r.children,a,
|
|
232
|
-
y,t,i,s);return
|
|
232
|
+
y,t,i,s);return yr(y[t])&&R(o,t,y[t]),S}_validateSelectedDescendants(t,r,n,o,i,s,a){if(t.type==="object"){let c=this._resolveObjectFieldMode(
|
|
233
233
|
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!ee(
|
|
234
234
|
u))return{};let l=c.schema._validateSelectedTree(r,u,ot(s,n),{...a,defaultedFields:new Set});return R(o,i,l.validatedObject),
|
|
235
235
|
nt(l.errors,n)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(n,t);if(!c)throw new Error(`Schema path "${n}" d\
|
|
@@ -239,14 +239,14 @@ l={};R(r,n,c);for(let m of ds(Object.keys(i))){if(!/^[0-9]+$/.test(m))throw new
|
|
|
239
239
|
id because array segments must use numeric indexes.`);let f=Number(m),h=De(t,f),y=i[m],T=y.self===!0,S=cs(y);if(this._fieldToBeSkipped(
|
|
240
240
|
h,s))continue;if(!Object.hasOwn(u,f)){T&&a.rejectExplicitUndefined&&R(l,h,this._typeError(h).errorObject);continue}let d=u[f];
|
|
241
241
|
if(d===void 0){T&&a.rejectExplicitUndefined&&R(l,h,this._typeError(h).errorObject);continue}if(o.kind==="schema"){if(T){
|
|
242
|
-
let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,d,ot(s,h));
|
|
242
|
+
let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,d,ot(s,h));yr(E.validatedObject)&&R(c,f,E.validatedObject),
|
|
243
243
|
this._mergeErrors(l,nt(E.errors,h));continue}if(!S)continue;let w=o.schema._validateSelectedTree(y.children,d,ot(s,h),{...a,
|
|
244
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
244
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});yr(w.validatedObject)&&R(c,f,w.validatedObject),
|
|
245
245
|
this._mergeErrors(l,nt(w.errors,h));continue}let p=this._buildArrayItemSettings(o.definition,a),_=[d];if(T){let w=this._normalizeAndValidateValue(
|
|
246
246
|
o.definition,d,h,_,0,u,s,p);Object.hasOwn(_,0)&&_[0]!==void 0?R(c,f,_[0]):_[0]===null&&R(c,f,null),this._mergeErrors(l,w);
|
|
247
247
|
continue}if(!S)continue;let b=this._castValue(o.definition,d,h,_,0,u,s,p);if(Object.keys(b.errors).length>0){this._mergeErrors(
|
|
248
248
|
l,b.errors);continue}if(!b.shouldContinue)continue;let v=this._validateSelectedDescendants(o.definition,y.children,h,_,0,
|
|
249
|
-
s,p);
|
|
249
|
+
s,p);yr(_[0])&&R(c,f,_[0]),this._mergeErrors(l,v)}return l}validateWith(t,r,n={}){if(!Object.hasOwn(this.operations,t))throw new Error(
|
|
250
250
|
`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(t,r),this._validateWithOperation(
|
|
251
251
|
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Bn(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
252
252
|
_resolvePathValidationRequest(n),c=this._validateSelectedTree(ls([t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:Od(
|
|
@@ -258,7 +258,7 @@ _buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.k
|
|
|
258
258
|
return is(this,t)}getFieldDefinitions(){return Vn(this.structure)}getFieldDefinition(t){if(typeof t!="string"||t.trim()===
|
|
259
259
|
"")throw new Error("Field path must be a non-empty string.");let r=Hn(this,Bn(t.trim()));return r===null?null:Vn(r)}getFieldMessages(t){
|
|
260
260
|
let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):Vn(r.messages)}cleanup(t,r){
|
|
261
|
-
let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&R(n,o,t[o]);return n}}});var
|
|
261
|
+
let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&R(n,o,t[o]);return n}}});var dy,$d,py,jd,Ld,ws,Md,ys,_s,Es=g(()=>{({parse:dy,stringify:$d}=JSON),{keys:py}=Object,jd=String,Ld="string",ws="objec\
|
|
262
262
|
t",Md=(e,t)=>t,ys=(e,t,r)=>{let n=jd(t.push(r)-1);return e.set(r,n),n},_s=(e,t,r)=>{let n=t&&typeof t===ws?(l,m)=>l===""||
|
|
263
263
|
-1<t.indexOf(l)?m:void 0:t||Md,o=new Map,i=[],s=[],a=+ys(o,i,n.call({"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=$d(i[a++],
|
|
264
264
|
u,r);return"["+s.join(",")+"]";function u(l,m){if(c)return c=!c,m;let f=n.call(this,l,m);switch(typeof f){case ws:if(f===
|
|
@@ -270,16 +270,16 @@ t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(Array.isArr
|
|
|
270
270
|
e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Fn(e[o],t[o]))return!1;return!0}if(e===
|
|
271
271
|
null||t===null||typeof e!="object"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=Object.
|
|
272
272
|
keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!Fn(e[o],t[o]))return!1;
|
|
273
|
-
return!0}var Ud,Vd,Bd,vs,Ss=g(()=>{Es();On();Nn();
|
|
273
|
+
return!0}var Ud,Vd,Bd,vs,Ss=g(()=>{Es();On();Nn();Ot();Ud=new Set(["true","1","yes","y","on"]),Vd=new Set(["false","0","\
|
|
274
274
|
no","n","off"]);Bd={install(e){let{addType:t,addValidator:r}=e;t("none",n=>n.value),t("file",n=>{let o=n.value;o==null&&
|
|
275
275
|
n.throwTypeError();let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?
|
|
276
276
|
s:s.trim()}n.throwTypeError()}),t("string",n=>{let o=n.value;if(o==null)return"";let i=typeof o;if(i==="string"||i==="nu\
|
|
277
277
|
mber"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),
|
|
278
278
|
t("number",n=>{let o=bs(n.value);return o===null&&n.throwTypeError(),o}),t("integer",n=>{let o=bs(n.value);return(o===null||
|
|
279
279
|
!Number.isInteger(o))&&n.throwTypeError(),o}),t("epochMilliseconds",n=>{let o=Pn(n.value,864e13);return o===null&&n.throwTypeError(),
|
|
280
|
-
o}),t("epochSeconds",n=>{let o=Pn(n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=
|
|
280
|
+
o}),t("epochSeconds",n=>{let o=Pn(n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=Pt(n.definition,
|
|
281
281
|
n.fieldName);return Xi(n.value,o)||n.throwTypeError(),n.value}),t("date",n=>(Ji(n.value)||n.throwTypeError(),n.value)),t(
|
|
282
|
-
"time",n=>{let o=
|
|
282
|
+
"time",n=>{let o=Pt(n.definition,n.fieldName);return Ki(n.value,o)||n.throwTypeError(),n.value}),t("array",n=>n.definition.
|
|
283
283
|
type==="array"&&!Array.isArray(n.value)?[n.value]:n.value),t("object",n=>(ee(n.value)||n.throwTypeError(),n.value)),t("s\
|
|
284
284
|
erialize",n=>{try{return JSON.stringify(n.value)}catch{try{return _s(n.value)}catch{n.throwTypeError()}}}),t("boolean",n=>{
|
|
285
285
|
if(typeof n.value=="boolean")return n.value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;
|
|
@@ -316,8 +316,8 @@ length})}),r("notEmpty",n=>{n.parameterValue&&typeof n.value=="string"&&n.value=
|
|
|
316
316
|
ld cannot be empty.")}),r("required",()=>{}),r("unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPre\
|
|
317
317
|
cision",n=>{if(n.definition.type!=="time"&&n.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be\
|
|
318
318
|
used on time or dateTime fields (${n.fieldName}).`)}),r("nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},
|
|
319
|
-
vs=Bd});var Ts=g(()=>{
|
|
320
|
-
if(typeof r!="function")throw new Error(`Validator handler for '${t}' must be a function.`);R(e,t,r)}function
|
|
319
|
+
vs=Bd});var Ts=g(()=>{Nt()});function Hd(e,t,r){if(typeof r!="function")throw new Error(`Type handler for '${t}' must be a function.`);R(e,t,r)}function zd(e,t,r){
|
|
320
|
+
if(typeof r!="function")throw new Error(`Validator handler for '${t}' must be a function.`);R(e,t,r)}function br(e={}){let t=Object.
|
|
321
321
|
create(null);for(let[r,n]of Object.entries(e))R(t,r,n);return t}function Fd(e,t){if(typeof e.install!="function")throw new Error(
|
|
322
322
|
"Plugin must have an install method.");e.install(t)}function Is(e,t,r){Os.set(e,t),Rs.set(e,r),Object.defineProperty(e,Ps,
|
|
323
323
|
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function qd(e){if(!e||
|
|
@@ -327,30 +327,30 @@ typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.va
|
|
|
327
327
|
nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
|
|
328
328
|
validators}:null}function Wd(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function Yd(e,t){return e===t}function As(e,t,r){
|
|
329
329
|
for(let[n,o]of Object.entries(t)){if(Object.hasOwn(e,n)&&!Yd(e[n],o))throw new Error(`Cannot merge schema factories with\
|
|
330
|
-
conflicting ${r} "${n}".`);R(e,n,o)}}function Jd(e,t,r){let n=Wd(r).filter(Boolean);if(n.length<1)return{types:
|
|
330
|
+
conflicting ${r} "${n}".`);R(e,n,o)}}function Jd(e,t,r){let n=Wd(r).filter(Boolean);if(n.length<1)return{types:br(e),validators:br(
|
|
331
331
|
t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=qd(s);if(!a)throw new Error("Factory sources m\
|
|
332
332
|
ust be schema instances or schema factories created by json-rest-schema.");As(o,a.types,"type"),As(i,a.validators,"valid\
|
|
333
|
-
ator")}return{types:o,validators:i}}function Ns({types:e={},validators:t={},installCore:r=!0}={}){let n=
|
|
333
|
+
ator")}return{types:o,validators:i}}function Ns({types:e={},validators:t={},installCore:r=!0}={}){let n=br(e),o=br(t),i=(s,a={})=>{
|
|
334
334
|
let c=new it(s,n,o,a.operations);return Is(c,n,o),c};return Is(i,n,o),i.addType=(s,a)=>{Hd(n,s,a)},i.addValidator=(s,a)=>{
|
|
335
335
|
zd(o,s,a)},i.use=s=>{Fd(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{let a=Jd(n,o,s);return Ns(
|
|
336
|
-
{types:a.types,validators:a.validators,installCore:!1})},r&&i.use(vs),i}var Os,Rs,Ps,$,Ue=g(()=>{gs();Ss();Ts();
|
|
337
|
-
new WeakMap,Rs=new WeakMap,Ps=Symbol.for("json-rest-schema.registry-metadata");$=Ns({installCore:!0})});var
|
|
338
|
-
.`);return r}function qn(e,t){if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(
|
|
339
|
-
|
|
340
|
-
if(!Xd.test(s))throw new TypeError(`${t} local name "${s}" must be a JavaScript identifier.`);let a=Yn(i,`${t}
|
|
341
|
-
has(a))throw new TypeError(`${t} declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.
|
|
342
|
-
if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(`${r}.hints must be an
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
"string"||!s.trim())throw new TypeError(`${r}.hints["${a}"] must be the text that says what to
|
|
346
|
-
return Object.freeze(o)}function
|
|
347
|
-
has(o))throw new TypeError(`Provider local name "${o}" is declared by both ${t.get(o)} and ${r}.`);t.set(o,
|
|
348
|
-
if(e==null)return null;if(typeof e!="function")throw new TypeError(`${t} must be a function when
|
|
349
|
-
id:e,requires:t={},optional:r={},provides:n={},hints:o={},setup:i,boot:s=null,shutdown:a=null}={}){
|
|
350
|
-
id"),u=qn(t,`${c}.requires`),l=qn(r,`${c}.optional`),m=qn(n,`${c}.provides`);
|
|
351
|
-
i,`${c}.setup`);if(!f)throw new TypeError(`${c}.setup is required.`);return Object.freeze({id:c,requires:u,
|
|
352
|
-
hints:
|
|
353
|
-
Xd=/^[A-Za-z_$][A-Za-z0-9_$]*$/u});var $s,js=g(()=>{$s="public"});var Ls=g(()=>{});var Ds=g(()=>{G()});var
|
|
336
|
+
{types:a.types,validators:a.validators,installCore:!1})},r&&i.use(vs),i}var Os,Rs,Ps,$,Ue=g(()=>{gs();Ss();Ts();Nt();Os=
|
|
337
|
+
new WeakMap,Rs=new WeakMap,Ps=Symbol.for("json-rest-schema.registry-metadata");$=Ns({installCore:!0})});var xy,Cs=g(()=>{Ue();G();xy=Object.freeze({schema:$({}),mode:"replace"})});var ks=g(()=>{G();Di();pr();Cs()});function Qd(e){return String(e||"").trim().toLowerCase()}function Yn(e,t){let r=Qd(e);if(!xs.test(r))throw new TypeError(
|
|
338
|
+
`${t} must match ${xs.toString()}.`);return r}function qn(e,t){if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(
|
|
339
|
+
`${t} must be an object mapping local names to capability ids.`);let r={},n=new Set;for(let[o,i]of Object.entries(e)){let s=String(
|
|
340
|
+
o||"").trim();if(!Xd.test(s))throw new TypeError(`${t} local name "${s}" must be a JavaScript identifier.`);let a=Yn(i,`${t}\
|
|
341
|
+
.${s}`);if(n.has(a))throw new TypeError(`${t} declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.
|
|
342
|
+
freeze(r)}function Zd(e,t,r){if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(`${r}.hints must be an obj\
|
|
343
|
+
ect mapping required capability ids to what to register.`);let n=new Set(Object.values(t)),o={};for(let[i,s]of Object.entries(
|
|
344
|
+
e)){let a=Yn(i,`${r}.hints key`);if(!n.has(a))throw new TypeError(`${r}.hints names "${a}", which the provider does not \
|
|
345
|
+
require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${r}.hints["${a}"] must be the text that says what to r\
|
|
346
|
+
egister.`);o[a]=s.trim()}return Object.freeze(o)}function ep(e){let t=new Map;for(let[r,n]of Object.entries(e))for(let o of Object.
|
|
347
|
+
keys(n)){if(t.has(o))throw new TypeError(`Provider local name "${o}" is declared by both ${t.get(o)} and ${r}.`);t.set(o,
|
|
348
|
+
r)}}function Wn(e,t){if(e==null)return null;if(typeof e!="function")throw new TypeError(`${t} must be a function when pr\
|
|
349
|
+
ovided.`);return e}function vr({id:e,requires:t={},optional:r={},provides:n={},hints:o={},setup:i,boot:s=null,shutdown:a=null}={}){
|
|
350
|
+
let c=Yn(e,"Provider id"),u=qn(t,`${c}.requires`),l=qn(r,`${c}.optional`),m=qn(n,`${c}.provides`);ep({requires:u,optional:l,
|
|
351
|
+
provides:m});let f=Wn(i,`${c}.setup`);if(!f)throw new TypeError(`${c}.setup is required.`);return Object.freeze({id:c,requires:u,
|
|
352
|
+
optional:l,provides:m,hints:Zd(o,u,c),setup:f,boot:Wn(s,`${c}.boot`),shutdown:Wn(a,`${c}.shutdown`)})}var xs,Xd,Jn=g(()=>{
|
|
353
|
+
G();xs=/^[a-z][a-z0-9_.-]*$/u,Xd=/^[A-Za-z_$][A-Za-z0-9_$]*$/u});var $s,js=g(()=>{$s="public"});var Ls=g(()=>{});var Ds=g(()=>{G()});var tp,Us,Vs=g(()=>{Ls();Ds();tp="/api",Us=`${tp}/bootstrap`});function Kn(){let e=[],t=new Set,r=!1;function n({id:a,order:c=0,contribute:u}={}){if(r)throw new Error("Bootstrap regis\
|
|
354
354
|
tration is closed after the first payload is resolved.");let l=V(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
355
355
|
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
|
|
356
356
|
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
|
|
@@ -358,92 +358,92 @@ isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u
|
|
|
358
358
|
(l,m)=>l.entry.order-m.entry.order||l.index-m.index).map(({entry:l})=>l);for(let l of u){let m=await l.contribute(Object.
|
|
359
359
|
freeze({...B(a)?a:{},payload:Object.freeze({...c})}));c={...c,...B(m)?m:{}}}return Object.freeze(c)}function i(){return Object.
|
|
360
360
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
361
|
-
return s}var Xn=g(()=>{G()});var
|
|
361
|
+
return s}var Xn=g(()=>{G()});var rp,Gs=g(()=>{Jn();js();Vs();Xn();rp=vr({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"r\
|
|
362
362
|
untime.bootstrap"},setup({http:e}){let t=Kn();return e.router.register("GET",Us,{auth:$s,meta:{tags:["bootstrap"],summary:"\
|
|
363
363
|
Resolve app bootstrap payload"}},async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),
|
|
364
|
-
{bootstrap:t}}})});function
|
|
364
|
+
{bootstrap:t}}})});function np(e){if(!B(e))throw new TypeError("Event listener must be an object.");let t=String(e.id||"").trim();if(!t)throw new TypeError(
|
|
365
365
|
"Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
|
|
366
366
|
dle().`);if(e.matches!=null&&typeof e.matches!="function")throw new TypeError(`Event listener "${t}" matches must be a f\
|
|
367
|
-
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function
|
|
367
|
+
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function op(e){if(!B(e))throw new TypeError(
|
|
368
368
|
"Published event must be an object.");let t=String(e.type||"").trim();if(!t)throw new TypeError("Published event type is\
|
|
369
|
-
required.");return Object.freeze({...e,type:t})}function Qn(){let e=[],t=new Set;function r(s){let a=
|
|
370
|
-
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=
|
|
369
|
+
required.");return Object.freeze({...e,type:t})}function Qn(){let e=[],t=new Set;function r(s){let a=np(s);if(t.has(a.id))
|
|
370
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=op(s);
|
|
371
371
|
for(let c of e)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
372
|
-
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var Zn=g(()=>{G()});var
|
|
372
|
+
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var Zn=g(()=>{G()});var ip,Bs=g(()=>{Jn();Zn();ip=vr({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:Qn()}}})});var Sr=g(()=>{pr();Mi();ks();Gs();Xn();Bs();Zn()});var Hs=g(()=>{});function zs(e,t={}){let{missingStatus:r=404}=t,n=e?.errors?.[0]?.code||e?.code||"";return n==="vibe64_session_not_found"?
|
|
373
373
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
374
374
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
375
375
|
64_project_source_lock_timeout"||n==="vibe64_development_database_scope_busy"||n==="vibe64_project_session_policy_lock_t\
|
|
376
376
|
imeout"||n==="vibe64_session_creation_limit"||n==="vibe64_workspace_setup_retry_not_available"||n==="vibe64_workspace_se\
|
|
377
|
-
tup_running"?409:e?.ok===!1?400:200}var Fs=g(()=>{});function Ve(e,t,r={}){let{status:n=zs({ok:!1,code:t}),...o}=r;return new ae(n,e,{...o,code:t})}var qs=g(()=>{
|
|
378
|
-
Fs()});import
|
|
379
|
-
if(!
|
|
380
|
-
let n=String(t.value||"").trim(),o=r===
|
|
381
|
-
64_preview_identity_selector_missing");if(r===
|
|
382
|
-
nvalid.","vibe64_preview_identity_email_invalid");if(r!==
|
|
383
|
-
alid.":"Preview identity user id is invalid.",r===
|
|
377
|
+
tup_running"?409:e?.ok===!1?400:200}var Fs=g(()=>{});function Ve(e,t,r={}){let{status:n=zs({ok:!1,code:t}),...o}=r;return new ae(n,e,{...o,code:t})}var qs=g(()=>{Sr();G();Hs();
|
|
378
|
+
Fs()});import sp from"node:crypto";function ap(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=String(t.type||"").trim();
|
|
379
|
+
if(!lr.includes(r))throw Ve("Preview identity selector type is invalid.","vibe64_preview_identity_selector_type_invalid");
|
|
380
|
+
let n=String(t.value||"").trim(),o=r===At?n.toLowerCase():n;if(!o)throw Ve("Preview identity selector is missing.","vibe\
|
|
381
|
+
64_preview_identity_selector_missing");if(r===At&&(!o.includes("@")||o.length>320))throw Ve("Preview identity email is i\
|
|
382
|
+
nvalid.","vibe64_preview_identity_email_invalid");if(r!==At&&o.length>256)throw Ve(r===ur?"Preview identity login is inv\
|
|
383
|
+
alid.":"Preview identity user id is invalid.",r===ur?"vibe64_preview_identity_login_invalid":"vibe64_preview_identity_us\
|
|
384
384
|
er_id_invalid");return{type:r,value:o}}function Ks(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};if(Object.hasOwn(
|
|
385
385
|
t,"subject"))throw Ve("Preview identity login requires an explicit application selector.","vibe64_preview_identity_subje\
|
|
386
386
|
ct_unsupported");let r=String(t.operation||le).trim();if(![le,st].includes(r))throw Ve("Preview identity operation is in\
|
|
387
|
-
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===le?{selector:
|
|
388
|
-
st,Ws,Ys,Js,
|
|
389
|
-
guest","you"]),Js=32,
|
|
387
|
+
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===le?{selector:ap(t.selector)}:{}}}var j_,le,
|
|
388
|
+
st,Ws,Ys,Js,L_,eo=g(()=>{Li();qs();j_=sp.randomBytes(32),le="login-as",st="logout",Ws="selector",Ys=new Set(["default","\
|
|
389
|
+
guest","you"]),Js=32,L_=Object.freeze(["projectScope","sessionSourceRoot","sessionId","targetHref","terminalSessionId"])});var kt,to=g(()=>{kt="vibe64_preview_token"});import{randomUUID as cp}from"node:crypto";import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as Xs}from"@local/vibe64-genesis/server";
|
|
390
390
|
function at(e="",t="vibe64_preview_identity_command_failed",r=502,n={}){return new ae(r,e||"Application preview identity\
|
|
391
|
-
command failed.",{code:t,params:n})}function
|
|
391
|
+
command failed.",{code:t,params:n})}function lp(e={}){return{kind:Ws,selector:e.selector}}function Zs(e={},t={}){let{requestId:r=cp(),
|
|
392
392
|
targetHref:n=""}=t,o=Ks(e),i=String(n||"").trim(),s=new URL(i);if(!["http:","https:"].includes(s.protocol))throw new Error(
|
|
393
393
|
"Application preview identity target must use HTTP.");return{operation:o.operation,protocol:Xs,requestId:String(r),...o.
|
|
394
|
-
operation===le?{subject:
|
|
394
|
+
operation===le?{subject:lp(o)}:{},target:{href:s.toString(),origin:s.origin}}}function dp(e=[]){if(!Array.isArray(e))throw at(
|
|
395
395
|
"Application preview identity command returned invalid cookies.","vibe64_preview_identity_command_cookies_invalid");let t=e;
|
|
396
396
|
if(t.length>ro)throw at("Application preview identity command returned too many cookies.","vibe64_preview_identity_comma\
|
|
397
397
|
nd_cookies_too_many");return t.map((r,n)=>{let o=String(r||""),i=o.split(";",1)[0]||"",s=i.indexOf("="),a=(s<0?i:i.slice(
|
|
398
|
-
0,s)).trim();if(!o||Buffer.byteLength(o)>no||/[\r\n]/u.test(o)||s<1||!
|
|
398
|
+
0,s)).trim();if(!o||Buffer.byteLength(o)>no||/[\r\n]/u.test(o)||s<1||!up.test(a)||a===xt||a.startsWith(`${xt}_`)||/(?:^|;)\s*domain\s*=/iu.
|
|
399
399
|
test(o))throw at(`Application preview identity command returned invalid cookie ${n+1}.`,"vibe64_preview_identity_command\
|
|
400
|
-
_cookie_invalid",502,{cookie:n+1});return o})}function
|
|
400
|
+
_cookie_invalid",502,{cookie:n+1});return o})}function pp(e=null){if(!e||typeof e!="object"||Array.isArray(e))return null;
|
|
401
401
|
let t={displayName:String(e.displayName||e.name||"").trim().slice(0,256),email:String(e.email||"").trim().toLowerCase().
|
|
402
402
|
slice(0,320),login:String(e.login||"").trim().slice(0,256),userId:String(e.userId||e.id||"").trim().slice(0,256),username:String(
|
|
403
|
-
e.username||"").trim().slice(0,256)};return Object.values(t).some(Boolean)?t:null}function
|
|
403
|
+
e.username||"").trim().slice(0,256)};return Object.values(t).some(Boolean)?t:null}function mp(e={},t={}){let{operation:r=le,
|
|
404
404
|
requestId:n=""}=t;if(!e||typeof e!="object"||Array.isArray(e))throw at("Application preview identity command returned in\
|
|
405
405
|
valid JSON.","vibe64_preview_identity_command_json_invalid");if(e.protocol!==Xs||String(e.requestId||"")!==String(n||"")||
|
|
406
406
|
typeof e.ok!="boolean")throw at("Application preview identity command returned an invalid protocol response.","vibe64_pr\
|
|
407
|
-
eview_identity_command_response_invalid");let o=
|
|
407
|
+
eview_identity_command_response_invalid");let o=dp(e.setCookie);if(e.ok===!1){let a=Number(e.statusCode);return{code:String(
|
|
408
408
|
e.code||"vibe64_preview_identity_application_rejected").trim().slice(0,128),error:String(e.error||"Application preview i\
|
|
409
409
|
dentity was rejected.").trim().slice(0,2e3),ok:!1,setCookie:o,signedOut:e.signedOut===!0,statusCode:Number.isInteger(a)&&
|
|
410
|
-
a>=400&&a<600?a:400}}let i=r===st||e.signedOut===!0,s=i?null:
|
|
410
|
+
a>=400&&a<600?a:400}}let i=r===st||e.signedOut===!0,s=i?null:pp(e.identity);if(o.length<1||!i&&!s)throw at("Application \
|
|
411
411
|
preview identity command did not return an authenticated browser session.","vibe64_preview_identity_command_session_miss\
|
|
412
|
-
ing");return{identity:s,ok:!0,setCookie:o,signedOut:i,statusCode:200}}var Qs,ro,no
|
|
413
|
-
512*1024,ro=64,no=16*1024
|
|
412
|
+
ing");return{identity:s,ok:!0,setCookie:o,signedOut:i,statusCode:200}}var Qs,ro,no,xt,up,z_,ea=g(()=>{Sr();eo();to();Qs=
|
|
413
|
+
512*1024,ro=64,no=16*1024,xt=kt,up=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;z_=Object.freeze({normalizePreviewIdentityCommandResponse:mp})});var ta=g(()=>{});function ra(e=""){return wp.find(t=>t.pattern.test(String(e)))?.kind||""}function Ep(e){if(!be(e)||e.startsWith("/")||e.
|
|
414
414
|
includes("\\")||e.includes("\0"))return!1;let t=e.split("/");return t.every(r=>r&&r!=="."&&r!=="..")&&!t.includes("node_\
|
|
415
|
-
modules")}var
|
|
416
|
-
directory:"VIBE64_USAGE_RECORDING_DIR",sourceRoot:"VIBE64_USAGE_SOURCE_ROOT",targetKind:"VIBE64_USAGE_TARGET_KIND"}),
|
|
417
|
-
Object.freeze(["starting","recording","stopping","stopped","failed","unavailable"]),
|
|
418
|
-
it","request-limit","size-limit","target-exited","session-ended","error"]),oa=Object.freeze(["nodejs","python","php"])
|
|
419
|
-
1024*1024,
|
|
420
|
-
proxyRequestLines:2e4,interactions:500,bufferedBytesPerProcess:64
|
|
421
|
-
1024,indexBytes:4
|
|
422
|
-
60*1e3}),
|
|
415
|
+
modules")}var fp,W_,hp,gp,oa,$t,Y_,J_,K_,wp,yp,_p,Tr,be,na,X_,Q_,ia=g(()=>{fp="vibe64.usage-trace.v1",W_=Object.freeze({
|
|
416
|
+
directory:"VIBE64_USAGE_RECORDING_DIR",sourceRoot:"VIBE64_USAGE_SOURCE_ROOT",targetKind:"VIBE64_USAGE_TARGET_KIND"}),hp=
|
|
417
|
+
Object.freeze(["starting","recording","stopping","stopped","failed","unavailable"]),gp=Object.freeze(["person","time-lim\
|
|
418
|
+
it","request-limit","size-limit","target-exited","session-ended","error"]),oa=Object.freeze(["nodejs","python","php"]),$t=
|
|
419
|
+
1024*1024,Y_=Object.freeze({durationMs:600*1e3,capturedRequests:2e3,hitsBytesPerProcess:16*$t,hitsBytesPerRecording:32*$t,
|
|
420
|
+
proxyRequestLines:2e4,interactions:500,bufferedBytesPerProcess:64*$t,flushIntervalMs:1e3,flushEntries:2e3,traceLineBytes:64*
|
|
421
|
+
1024,indexBytes:4*$t,plumbingShare:.8,plumbingMinimumRequests:3}),J_=Object.freeze({maxRecordings:10,maxBytes:64*$t,maxAgeMs:10080*
|
|
422
|
+
60*1e3}),K_=Object.freeze(["click","enter","submit"]),wp=Object.freeze([Object.freeze({kind:"request",pattern:/^r_[0-9]{6}$/u}),
|
|
423
423
|
Object.freeze({kind:"local-request",pattern:/^l_[0-9]+_[0-9]+$/u}),Object.freeze({kind:"run",pattern:/^run_[0-9]+$/u}),Object.
|
|
424
|
-
freeze({kind:"background",pattern:/^bg_[0-9]+$/u})]),
|
|
424
|
+
freeze({kind:"background",pattern:/^bg_[0-9]+$/u})]),yp=/^sha256:[0-9a-f]{64}$/u,_p=Object.freeze(["ready","idle"]);Tr=e=>Number.
|
|
425
425
|
isSafeInteger(e)&&e>=0,be=e=>typeof e=="string"&&e.length>0,na=e=>!!e&&Number.isSafeInteger(e.line)&&e.line>0&&Number.isSafeInteger(
|
|
426
|
-
e.column)&&e.column>0;
|
|
427
|
-
e.pid)&&e.pid>0&&be(e.startedAt),tracer:e=>
|
|
428
|
-
function:e=>
|
|
426
|
+
e.column)&&e.column>0;X_=Object.freeze({header:e=>e.schema===fp&&oa.includes(e.runtime)&&be(e.runtimeVersion)&&Number.isSafeInteger(
|
|
427
|
+
e.pid)&&e.pid>0&&be(e.startedAt),tracer:e=>_p.includes(e.state),file:e=>Tr(e.fileIndex)&&Ep(e.path)&&yp.test(e.hash||""),
|
|
428
|
+
function:e=>Tr(e.functionIndex)&&Tr(e.fileIndex)&&typeof e.name=="string"&&na(e.start)&&na(e.end),scope:e=>ra(e.scope)===
|
|
429
429
|
e.kind&&be(e.startedAt)&&(e.endedAt===void 0||be(e.endedAt))&&(e.label===void 0||be(e.label)&&["local-request","run"].includes(
|
|
430
|
-
e.kind)),hits:e=>ra(e.scope)!==""&&Array.isArray(e.counts)&&e.counts.every(t=>Array.isArray(t)&&t.length===2&&
|
|
430
|
+
e.kind)),hits:e=>ra(e.scope)!==""&&Array.isArray(e.counts)&&e.counts.every(t=>Array.isArray(t)&&t.length===2&&Tr(t[0])&&
|
|
431
431
|
(t[1]===null||Number.isSafeInteger(t[1])&&t[1]>0)),diagnostic:e=>be(e.code)&&(e.path===void 0||be(e.path)),truncated:e=>be(
|
|
432
|
-
e.reason)}),
|
|
433
|
-
return sa}}function
|
|
432
|
+
e.reason)}),Q_=Object.freeze({USAGE_RECORDING_STATES:hp,USAGE_RECORDING_STOP_REASONS:gp,USAGE_TRACER_RUNTIMES:oa})});function bp(e=""){try{let t=new URL(e),r=t.protocol==="https:",n=t.port||(r?"443":"80");return`${r?"__Host-":""}${sa}_${n}`}catch{
|
|
433
|
+
return sa}}function vp(e="",t={}){let{proxyOrigin:r="",targetOrigin:n=""}=t,o=String(e||"").trim();if(!o||!r||!n)return o;
|
|
434
434
|
try{let i=new URL(o,n),s=new URL(r),a=new URL(n);return a.protocol=s.protocol,i.origin!==n&&i.origin!==a.origin?o:(s.pathname=
|
|
435
|
-
i.pathname,s.search=
|
|
435
|
+
i.pathname,s.search=Sp(i.search),s.hash=i.hash,s.toString())}catch{return o}}function Sp(e=""){let t=String(e||"");if(!t||
|
|
436
436
|
t==="?")return"";let r=t.startsWith("?")?t.slice(1):t;if(!r)return"";let n=r.split("&").filter(o=>{let i=o.indexOf("="),
|
|
437
|
-
s=i<0?o:o.slice(0,i);return
|
|
438
|
-
String(e||"").replace(/\+/gu," "))}catch{return String(e||"")}}var sa,aa,
|
|
439
|
-
|
|
440
|
-
eo();ea();ca();oo=e=>JSON.stringify(e,null,2),ua=
|
|
437
|
+
s=i<0?o:o.slice(0,i);return Tp(s)!==kt});return n.length>0?`?${n.join("&")}`:""}function Tp(e=""){try{return decodeURIComponent(
|
|
438
|
+
String(e||"").replace(/\+/gu," "))}catch{return String(e||"")}}var sa,aa,sE,ca=g(()=>{ta();ia();to();sa=kt,aa=/^vibe64-launch-[a-f0-9]{12}$/u;
|
|
439
|
+
sE=Object.freeze({previewTokenCookieName:bp,proxiedLocation:vp})});import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as Ir}from"@local/vibe64-genesis/server";var oo,ua,io,la,da,pa,ma,fa=g(()=>{
|
|
440
|
+
eo();ea();ca();oo=e=>JSON.stringify(e,null,2),ua=lr.map(e=>`\`${e}\``).join(", "),io="6f1c2a7e-3d4b-4c55-9a10-2b7d8e9f0a\
|
|
441
441
|
11",la=Zs({operation:le,selector:{type:"email",value:"admin@example.com"}},{requestId:io,targetHref:"http://127.0.0.1:51\
|
|
442
|
-
73/"}),da=Object.freeze({protocol:
|
|
443
|
-
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),pa=Object.freeze({protocol:
|
|
442
|
+
73/"}),da=Object.freeze({protocol:Ir,requestId:io,ok:!0,setCookie:["app_session=abc123; Path=/; HttpOnly; SameSite=Lax"],
|
|
443
|
+
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),pa=Object.freeze({protocol:Ir,requestId:io,ok:!1,code:"\
|
|
444
444
|
user_not_found",error:"No active user has that email.",statusCode:404,setCookie:[]}),ma=Object.freeze([{name:"preview-id\
|
|
445
445
|
entity-command",title:"Preview identity command protocol",exampleRequest:la,exampleResponses:[da,pa],text:()=>`# Preview\
|
|
446
|
-
identity command protocol (\`${
|
|
446
|
+
identity command protocol (\`${Ir}\`)
|
|
447
447
|
|
|
448
448
|
An application-owned executable, declared under an Outputs web target's \`#### Preview identity\` block (grammar: \`vibe64-\
|
|
449
449
|
helper spec outputs\`), that signs the Preview browser in as an existing application account or signs it out. Vibe64 neve\
|
|
@@ -463,7 +463,7 @@ n-zero exit or timeout fails the exchange. Write diagnostics to stderr.
|
|
|
463
463
|
- A JSKIT application's executable can call \`runManagedPreviewIdentityCommand\` from \`@jskit-ai/auth-web/server/managedPr\
|
|
464
464
|
eviewIdentity\`. Pass it the application's environment, this protocol and the Preview's launch hostnames, since it reads \
|
|
465
465
|
no environment on its own and its defaults are JSKIT's neutral protocol and loopback only: \`runManagedPreviewIdentityCom\
|
|
466
|
-
mand({ env: process.env, protocol: "${
|
|
466
|
+
mand({ env: process.env, protocol: "${Ir}", localHostnames: [${aa}] })\`.
|
|
467
467
|
|
|
468
468
|
## Request
|
|
469
469
|
|
|
@@ -480,7 +480,7 @@ ${oo(la)}
|
|
|
480
480
|
## Response
|
|
481
481
|
|
|
482
482
|
- Always: \`protocol\`, the same \`requestId\`, boolean \`ok\`, and \`setCookie\`: an array of complete Set-Cookie header values\
|
|
483
|
-
(at most ${ro}, each at most ${no} bytes, no line breaks, no \`Domain\` attribute, never named \`${
|
|
483
|
+
(at most ${ro}, each at most ${no} bytes, no line breaks, no \`Domain\` attribute, never named \`${xt}\` or \`${xt}_*\`)\
|
|
484
484
|
.
|
|
485
485
|
- \`ok: true\`: at least one cookie. For ${le}, \`identity\` with at least one of \`displayName\`, \`email\`, \`login\`, \`userId\
|
|
486
486
|
\`, \`username\`. For ${st} (or \`"signedOut": true\`), the cookies that clear the session.
|
|
@@ -520,31 +520,31 @@ Entry shape:
|
|
|
520
520
|
\`\`\`json
|
|
521
521
|
{"name":"admin","type":"email","value":"admin@example.com"}
|
|
522
522
|
\`\`\`
|
|
523
|
-
`}])});var ga={};Ni(ga,{__testables:()=>
|
|
524
|
-
function ha(){let e=Math.max(...
|
|
525
|
-
cts:",...
|
|
526
|
-
`)}async function
|
|
523
|
+
`}])});var ga={};Ni(ga,{__testables:()=>Pp,runAgentSpecCli:()=>Rp});import{readFile as Ap}from"node:fs/promises";import{VIBE64_GENESIS_AGENT_SPECS as Op}from"@local/vibe64-genesis/server/agentSpecs";
|
|
524
|
+
function ha(){let e=Math.max(...Ar.map(({name:t})=>t.length));return["Usage: vibe64 spec <name>","","Vibe64-owned contra\
|
|
525
|
+
cts:",...Ar.map(({name:t,title:r})=>` ${t.padEnd(e)} ${r}`)].join(`
|
|
526
|
+
`)}async function Rp(e=[],{write:t=n=>process.stdout.write(`${n.trimEnd()}
|
|
527
527
|
`),writeError:r=n=>process.stderr.write(`${n.trimEnd()}
|
|
528
|
-
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(ha()),0;let o=e.length===1&&
|
|
528
|
+
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(ha()),0;let o=e.length===1&&Ar.find(i=>i.name===n);return o?(t(await o.
|
|
529
529
|
text()),0):(r(`Unknown Vibe64 spec: ${e.join(" ")}.
|
|
530
530
|
|
|
531
|
-
${ha()}`),2)}var
|
|
532
|
-
freeze([...
|
|
533
|
-
e",text:()=>
|
|
534
|
-
e))Ae(e[r],t);return Object.freeze(e)}var
|
|
531
|
+
${ha()}`),2)}var Ip,Ar,Pp,wa=g(()=>{ji();fa();Ip=new URL("./../server/lib/agentSpecCli.js",import.meta.url).href,Ar=Object.
|
|
532
|
+
freeze([...Op,...ma,...$i,{name:"training-content",title:"Teaching content format for vibe64 training validate and bundl\
|
|
533
|
+
e",text:()=>Ap(new URL("../../docs/training-content.md",Ip),"utf8")}]);Pp=Object.freeze({VIBE64_AGENT_SPECS:Ar})});function Ae(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e);for(let r of Object.getOwnPropertyNames(
|
|
534
|
+
e))Ae(e[r],t);return Object.freeze(e)}var jt=g(()=>{});function Or(e){return!!e&&typeof e=="object"&&xp.every(t=>typeof e[t]=="function")}function _a(e=null,{defaultMode:t="cr\
|
|
535
535
|
eate",context:r="schema definition.mode"}={}){let n=te(e),o=V(t).toLowerCase()||"create",i=Object.prototype.hasOwnProperty.
|
|
536
|
-
call(n,"mode")?V(n.mode).toLowerCase():"";if(!i)return o;if(!
|
|
537
|
-
replace, patch.`);return i}function Ea(e=null,t=""){let r=V(t);if(!r)return{};let n=te(e);return
|
|
538
|
-
getFieldMessages(r)):{}}function
|
|
536
|
+
call(n,"mode")?V(n.mode).toLowerCase():"";if(!i)return o;if(!Np.has(i))throw new TypeError(`${r} must be one of: create,\
|
|
537
|
+
replace, patch.`);return i}function Ea(e=null,t=""){let r=V(t);if(!r)return{};let n=te(e);return Or(n.schema)?te(n.schema.
|
|
538
|
+
getFieldMessages(r)):{}}function $p(e=null,t=""){let r=V(t).split(".").filter(Boolean);return r.length<2?{}:(r.pop(),Ea(
|
|
539
539
|
e,r.join(".")))}function ya(e,t){let r=t?e[t]:void 0;if(typeof r=="string"){let i=V(r);return i?{message:i}:null}if(!B(r))
|
|
540
540
|
return null;let n=V(r.message);if(!n)return null;let o=V(r.code);return o?{message:n,code:o,params:te(r.params)}:{message:n}}
|
|
541
|
-
function
|
|
542
|
-
Object.keys(s).length<1
|
|
541
|
+
function jp(e,t,r=null){let n=V(t?.code).toUpperCase(),o=Cp[n]||{},i=te(t?.params),s=Ea(r,e),a=n==="FIELD_NOT_ALLOWED"&&
|
|
542
|
+
Object.keys(s).length<1?$p(r,e):s,c=ya(a,o.messageKey)||ya(a,"default");if(c)return c.code?{message:c.message,code:c.code,
|
|
543
543
|
params:{...i,...c.params}}:{message:c.message};let u=V(t?.message);if(u)return o.code?{message:u,code:o.code,params:i}:{
|
|
544
|
-
message:u};let l=V(t?.code);return l?{message:l}:{...
|
|
545
|
-
i,s]of Object.entries(r)){let a=V(i);if(!a)continue;if(typeof s=="string"){n[a]=s;continue}let{message:c,code:u,params:l}
|
|
546
|
-
a,s,t);n[a]=c,u&&(o[a]={code:u,params:l})}return{fieldErrors:n,fieldErrorCodes:o}}var
|
|
547
|
-
["create","replace","patch"]),
|
|
544
|
+
message:u};let l=V(t?.code);return l?{message:l}:{...kp,params:{}}}function so(e={},t=null){let r=te(e),n={},o={};for(let[
|
|
545
|
+
i,s]of Object.entries(r)){let a=V(i);if(!a)continue;if(typeof s=="string"){n[a]=s;continue}let{message:c,code:u,params:l}=jp(
|
|
546
|
+
a,s,t);n[a]=c,u&&(o[a]={code:u,params:l})}return{fieldErrors:n,fieldErrorCodes:o}}var Np,Cp,kp,xp,ao=g(()=>{G();Np=new Set(
|
|
547
|
+
["create","replace","patch"]),Cp=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},
|
|
548
548
|
TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",
|
|
549
549
|
code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},
|
|
550
550
|
MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kern\
|
|
@@ -554,23 +554,23 @@ messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{message
|
|
|
554
554
|
.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{
|
|
555
555
|
messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{
|
|
556
556
|
messageKey:"default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validati\
|
|
557
|
-
on.field.notEmpty"}}),
|
|
558
|
-
reate","replace","patch","toJsonSchema"])});function
|
|
559
|
-
prototype.hasOwnProperty.call(e,"mode"))}function
|
|
560
|
-
if(!
|
|
561
|
-
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!
|
|
557
|
+
on.field.notEmpty"}}),kp=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),xp=Object.freeze(["c\
|
|
558
|
+
reate","replace","patch","toJsonSchema"])});function Lp(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&(Object.prototype.hasOwnProperty.call(e,"schema")||Object.
|
|
559
|
+
prototype.hasOwnProperty.call(e,"mode"))}function Rr(e,{context:t="schema definition",defaultMode:r=""}={}){if(e==null)return null;
|
|
560
|
+
if(!Lp(e))throw new TypeError(`${t} must be a schema definition object.`);let n=te(e);if(!Object.prototype.hasOwnProperty.
|
|
561
|
+
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!Or(n.schema))throw new TypeError(`${t}.schema must \
|
|
562
562
|
be a json-rest-schema schema instance.`);let o={schema:n.schema},i=V(r).toLowerCase();return o.mode=_a(n,{defaultMode:i||
|
|
563
|
-
"patch",context:`${t}.mode`}),Object.freeze(o)}function co(e,t,{context:r="schema definition",defaultMode:n=""}={}){let o=
|
|
564
|
-
e,{context:r,defaultMode:n});return o?o.schema[o.mode](t):null}var
|
|
565
|
-
freeze({schema:
|
|
566
|
-
|
|
563
|
+
"patch",context:`${t}.mode`}),Object.freeze(o)}function co(e,t,{context:r="schema definition",defaultMode:n=""}={}){let o=Rr(
|
|
564
|
+
e,{context:r,defaultMode:n});return o?o.schema[o.mode](t):null}var Lt=g(()=>{G();ao()});var ba=g(()=>{Ue();G();jt();Lt()});var va=g(()=>{Ue();jt();Lt()});var Mp,Dp,Sa=g(()=>{Ue();Mp=$({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Dp=Object.
|
|
565
|
+
freeze({schema:Mp,mode:"patch"})});var Ta,Up,Ia=g(()=>{Ta=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),
|
|
566
|
+
Up=Object.freeze({...Ta,nullable:!0})});var Aa=g(()=>{G()});function Ra({message:e=Oa,fieldErrors:t=null,fieldErrorCodes:r=null,errors:n=null,cause:o,statusCode:i=null}={}){let s=new Error(
|
|
567
567
|
e,o?{cause:o}:void 0);if(e===Oa&&(s.messageCode="kernel.validation.schemaFailed",s.messageParams={}),Number.isInteger(i)&&
|
|
568
568
|
i>=400&&i<=599&&(s.statusCode=i),B(t)){let a=B(r)&&Object.keys(r).length>0?r:null;s.fieldErrors=t,a&&(s.fieldErrorCodes=
|
|
569
569
|
a),s.details={...s.details||{},fieldErrors:t,...a?{fieldErrorCodes:a}:{}}}else n!=null&&(s.details={...s.details||{},errors:n});
|
|
570
570
|
return s}function uo(e,t,{phase:r="input",context:n="schema definition",statusCode:o=null}={}){if(e==null)return t;let i=co(
|
|
571
571
|
e,t,{defaultMode:r==="output"?"replace":"patch",context:n}),{fieldErrors:s,fieldErrorCodes:a}=so(i.errors,e);if(Object.keys(
|
|
572
|
-
s).length>0)throw Ra({fieldErrors:s,fieldErrorCodes:a,statusCode:o});return i.validatedObject??t}var Oa,Pa=g(()=>{G();
|
|
573
|
-
Oa="Schema validation failed."});var
|
|
572
|
+
s).length>0)throw Ra({fieldErrors:s,fieldErrorCodes:a,statusCode:o});return i.validatedObject??t}var Oa,Pa=g(()=>{G();Lt();
|
|
573
|
+
Oa="Schema validation failed."});var BE,Na=g(()=>{G();BE=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.val\
|
|
574
574
|
idation.type"},{keyword:"minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.max\
|
|
575
575
|
Length"},{keyword:"minimum",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"\
|
|
576
576
|
exclusiveMinimum",code:"kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusi\
|
|
@@ -582,40 +582,40 @@ tion.maxItems"},{keyword:"additionalItems",code:"kernel.validation.additionalIte
|
|
|
582
582
|
kernel.validation.maxProperties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"\
|
|
583
583
|
propertyNames",code:"kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",
|
|
584
584
|
code:"kernel.validation.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].
|
|
585
|
-
map(({keyword:e,code:t})=>[e,t]))});var Ca,lo,
|
|
586
|
-
|
|
587
|
-
id must be a canonical positive integer string."}}}}),mode:"patch"})});var xa=g(()=>{G()});var
|
|
588
|
-
let n=uo({schema:e,mode:"create"},t,{context:r});if(!
|
|
589
|
-
s.`);return n}var N,M,H,
|
|
585
|
+
map(({keyword:e,code:t})=>[e,t]))});var Ca,lo,Vp,Gp,ka=g(()=>{Ue();jt();Ca="^[1-9][0-9]*$",lo=Ae({type:"string",minLength:1,pattern:Ca}),Vp=Ae({...lo,nullable:!0}),
|
|
586
|
+
Gp=Ae({schema:$({recordId:{...lo,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record\
|
|
587
|
+
id must be a canonical positive integer string."}}}}),mode:"patch"})});var xa=g(()=>{G()});var Pr=g(()=>{Ue();Tn();ba();va();Sa();Ia();Aa();ao();Lt();Pa();Na();ka();xa()});import{isDeepStrictEqual as Bp}from"node:util";function Cr(e,t){let r=Yp.get(e?.schemaVersion)||ja;return ce(r,e,t)}function ce(e,t,r){
|
|
588
|
+
let n=uo({schema:e,mode:"create"},t,{context:r});if(!Bp(t,n))throw new Error(`${r}: unknown fields or noncanonical value\
|
|
589
|
+
s.`);return n}var N,M,H,Nr,Hp,zp,$a,ja,Fp,La,qp,Wp,Yp,me,kr,xr,Ma,ct=g(()=>{Pr();N={type:"string",required:!0,noTrim:!0,
|
|
590
590
|
minLength:1,maxLength:256},M={...N,maxLength:64},H=(e,t=100)=>({type:"array",required:!0,maxLength:t,items:e,validator:r=>Array.
|
|
591
|
-
isArray(r)&&r.length>t?`Expected at most ${t} items.`:void 0}),
|
|
592
|
-
24),
|
|
591
|
+
isArray(r)&&r.length>t?`Expected at most ${t} items.`:void 0}),Nr={type:"integer",required:!0,enum:[1]},Hp=H($({code:M}),
|
|
592
|
+
24),zp=$({id:M,kind:{...N,enum:["answer","practical"]},required:{type:"boolean",required:!0},rubric:N,evidence:{type:"ob\
|
|
593
593
|
ject",required:!1,schema:$({producer:{...N,enum:["workspace","colleague","exercise","code"]},operation:M,check:{...M,required:!1},
|
|
594
|
-
explanationRequired:{type:"boolean",required:!1},files:{...H(N,8),required:!1,minLength:1}})}}),$a={code:M,title:N,prerequisites:
|
|
594
|
+
explanationRequired:{type:"boolean",required:!1},files:{...H(N,8),required:!1,minLength:1}})}}),$a={code:M,title:N,prerequisites:Hp,
|
|
595
595
|
estimatedMinutes:{type:"integer",required:!0,min:1,max:180},visuals:H($({id:M,descriptor:N}),12),exercise:{type:"object",
|
|
596
596
|
required:!1,schema:$({kind:{...N,enum:["bundled"]},source:N,reuse:{...N,enum:["attempt","sequence"]},sequenceId:{...M,required:!1},
|
|
597
597
|
sequenceMode:{...N,required:!1,enum:["create","continue"]}})},checks:{...H($({id:M,file:N,assets:{...H(N,32),required:!1},
|
|
598
598
|
kind:{...N,required:!1,enum:["response","code"]},timeoutSeconds:{type:"integer",required:!1,min:1,max:60}}),12),required:!1},
|
|
599
599
|
appRoutes:{...H($({method:{...N,enum:["POST","PUT","PATCH","DELETE"]},path:{...N,maxLength:128,pattern:"^/[A-Za-z0-9._~:\
|
|
600
|
-
/-]*$"}}),16),required:!1}},ja=$({schemaVersion:
|
|
600
|
+
/-]*$"}}),16),required:!1}},ja=$({schemaVersion:Nr,...$a,document:N,assessments:H(zp,32)}),Fp=$({id:M,title:N,body:N,required:{
|
|
601
601
|
type:"boolean",required:!0},visual:{type:"object",required:!1,schema:$({id:M,play:{...H($({name:M,parameters:{type:"obje\
|
|
602
602
|
ct",required:!0}}),16),required:!1}})},guide:{type:"object",required:!1,schema:$({target:M,navigate:{type:"boolean",required:!1},
|
|
603
603
|
filePath:{...N,required:!1,maxLength:512},caption:{...N,required:!1}})},check:{type:"object",required:!0,schema:$({kind:{
|
|
604
604
|
...N,enum:["auto","choice","review","self","fact","none"]},check:{...M,required:!1},fact:{...M,required:!1},files:{...H(
|
|
605
605
|
N,8),required:!1},question:{...N,required:!1,maxLength:2e3},options:{...H(N,8),required:!1},answer:{...H({type:"integer",
|
|
606
606
|
required:!0,min:0,max:7},8),required:!1},rubric:{...N,required:!1,maxLength:600},evidence:{...H({...N,enum:["changes","c\
|
|
607
|
-
onversation"]},2),required:!1}})}}),La={...$a,notes:{...N,required:!1},steps:H(
|
|
608
|
-
r",required:!0,enum:[2]},...La}),
|
|
609
|
-
io","project"]}}),
|
|
607
|
+
onversation"]},2),required:!1}})}}),La={...$a,notes:{...N,required:!1},steps:H(Fp,32)},qp=$({schemaVersion:{type:"intege\
|
|
608
|
+
r",required:!0,enum:[2]},...La}),Wp=$({schemaVersion:{type:"integer",required:!0,enum:[3]},...La,stage:{...N,enum:["stud\
|
|
609
|
+
io","project"]}}),Yp=new Map([[1,ja],[2,qp],[3,Wp]]),me=e=>e?.schemaVersion===2||e?.schemaVersion===3;kr=$({schemaVersion:Nr,
|
|
610
610
|
topicId:M,domainId:M,title:N,status:{...N,enum:["preview","released"]},outline:N,prerequisites:H($({topicId:M}),24),lessons:H(
|
|
611
611
|
$({code:M,descriptor:N,status:{...N,enum:["draft","published"]},required:{type:"boolean",required:!0}}),64),places:{...H(
|
|
612
|
-
M,64),required:!1},activities:{...H(M,64),required:!1},facts:{...H(M,64),required:!1}})
|
|
612
|
+
M,64),required:!1},activities:{...H(M,64),required:!1},facts:{...H(M,64),required:!1}}),xr=$({schemaVersion:Nr,courseId:M,
|
|
613
613
|
title:N,release:N,status:{...N,enum:["preview","released"]},topics:H($({topicId:M,release:N}),32),orientation:{...M,required:!1}}),
|
|
614
|
-
Ma=$({schemaVersion:
|
|
614
|
+
Ma=$({schemaVersion:Nr,id:M,title:N,svg:N,controller:N,assets:{...H(N,32),required:!1},initialState:M,states:H(M,32),description:{
|
|
615
615
|
...N,maxLength:2e3},commands:H($({name:M,parameters:H($({name:M,required:{type:"boolean",required:!0},maxLength:{type:"i\
|
|
616
|
-
nteger",required:!0,min:1,max:256}}),8),completionState:M,description:{...N,maxLength:2e3}}),32)})});function re(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_VOCABULARY_INVALID"})}function
|
|
616
|
+
nteger",required:!0,min:1,max:256}}),8),completionState:M,description:{...N,maxLength:2e3}}),32)})});function re(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_VOCABULARY_INVALID"})}function em(e){if(!B(e)||!Se.
|
|
617
617
|
test(e.id||""))throw re("A place needs a lowercase id.");let t=`Place ${e.id}`;if(!Va(e.label))throw re(`${t} needs a la\
|
|
618
|
-
bel.`);if(!
|
|
618
|
+
bel.`);if(!Jp.has(e.scope))throw re(`${t} scope is studio or project.`);let r=e.who??"everyone";if(!Kp.has(r))throw re(`${t}\
|
|
619
619
|
who is everyone or owner.`);let n=e.open??null;if(n!==null){let i=Object.keys(n||{}).sort().join(",");if(!(i==="pane"||
|
|
620
620
|
i==="databaseView,pane"?e.scope==="project"&&Se.test(n.pane):i==="route"?e.scope==="studio"&&typeof n.route=="string"&&/^\/app(?:\/[a-z0-9-]+)*$/u.
|
|
621
621
|
test(n.route):i==="learning"&&n.learning===!0))throw re(`${t} opens a project pane, a studio /app route, Courses, or not\
|
|
@@ -625,18 +625,18 @@ pane,...n.databaseView?{databaseView:n.databaseView}:{}}]:n?.route?[{route:n.rou
|
|
|
625
625
|
i)||!Object.keys(i).length))throw re(`${t} shown is a list of page focus matchers.`);if(e.event!==void 0&&!Se.test(e.event))
|
|
626
626
|
throw re(`${t} event is a lowercase activity name.`);return Object.freeze({id:e.id,label:e.label,scope:e.scope,who:r,open:n&&
|
|
627
627
|
Object.freeze({...n}),steps:Object.freeze(e.steps.map(i=>z(i.id,i.label))),shown:Object.freeze(o.map(i=>Object.freeze({...i}))),
|
|
628
|
-
...e.event?{event:e.event}:{}})}function
|
|
628
|
+
...e.event?{event:e.event}:{}})}function tm(e){if(!B(e)||!Se.test(e.id||""))throw re("An activity needs a lowercase id.");
|
|
629
629
|
if(!Se.test(e.event||""))throw re(`Activity ${e.id} needs its page activity event.`);if(e.place!==void 0&&!Se.test(e.place))
|
|
630
630
|
throw re(`Activity ${e.id} place is a place id.`);return Object.freeze({id:e.id,event:e.event,...e.place?{place:e.place}:
|
|
631
|
-
{}})}function mo(){return!1}function ho({places:e=
|
|
632
|
-
stringify(h)===JSON.stringify(y);function a({places:h=[],activities:y=[],facts:T=[]}={}){let S=h.map(
|
|
631
|
+
{}})}function mo(){return!1}function ho({places:e=Xp,activities:t=Qp,facts:r=Zp}={}){let n=new Map,o=new Map,i=new Set,s=(h,y)=>JSON.
|
|
632
|
+
stringify(h)===JSON.stringify(y);function a({places:h=[],activities:y=[],facts:T=[]}={}){let S=h.map(em),d=y.map(tm);for(let p of[
|
|
633
633
|
...S,...d])if(n.has(p.id)&&!s(n.get(p.id),p)||o.has(p.id)&&!s(o.get(p.id),p)||S.includes(p)&&o.has(p.id)||d.includes(p)&&
|
|
634
634
|
n.has(p.id))throw re(`${p.id} is already registered with another meaning.`);for(let p of T)if(!Se.test(p||""))throw re("\
|
|
635
635
|
A fact needs a lowercase id.");for(let p of S)n.set(p.id,p);for(let p of d)o.set(p.id,p);for(let p of T)i.add(p)}a({places:e,
|
|
636
636
|
activities:t,facts:r});function c(h){return n.get(h)||null}function u(h){return o.get(h)||null}function l(h){return i.has(
|
|
637
637
|
h)}function m(){return[...n.values()]}function f(){return new Set([...[...o.values()].map(h=>h.event),...[...n.values()].
|
|
638
638
|
filter(h=>h.event).map(h=>h.event)])}return Object.freeze({register:a,place:c,activity:u,hasFact:l,places:m,events:f,declared:mo,
|
|
639
|
-
declaredPlace:mo,declaredActivity:mo})}function
|
|
639
|
+
declaredPlace:mo,declaredActivity:mo})}function $r({places:e=[],activities:t=[],facts:r=[]}={}){let n=ho(),o=new Set(n.places().
|
|
640
640
|
map(m=>m.id));for(let m of[...e,...t,...r])if(!Se.test(m||""))throw re(`Declared name ${m} is not a lowercase id.`);let i=new Set(
|
|
641
641
|
e.filter(m=>!o.has(m))),s=new Set(t.filter(m=>!n.activity(m)));function a(m){return i.has(m)}function c(m){return s.has(
|
|
642
642
|
m)}function u(m){return a(m)||c(m)}function l(m){return n.hasFact(m)||r.includes(m)}return Object.freeze({register:n.register,
|
|
@@ -648,20 +648,20 @@ highlight??!0;if(typeof i!="boolean"||typeof s!="boolean")throw Oe("navigate and
|
|
|
648
648
|
NG_GUIDE_FLAGS_INVALID");if(!i&&!s)throw Oe("Point at the place (highlight) or open it (navigate); this request does nei\
|
|
649
649
|
ther.","VIBE64_TRAINING_GUIDE_ACTION_MISSING");if(i&&o==="dashboard")throw Oe("Dashboard has no single view to open. Poi\
|
|
650
650
|
nt at it, or open one Dashboard section such as files or database-erd.","VIBE64_TRAINING_GUIDE_DASHBOARD_UNOPENABLE");if(i&&
|
|
651
|
-
r&&!
|
|
651
|
+
r&&!rm(r))throw Oe(`${r.label} has no view to open; point at it instead.`,"VIBE64_TRAINING_GUIDE_PLACE_UNOPENABLE",{place:r.
|
|
652
652
|
label});let a={target:o,navigate:i,highlight:s};if(e.filePath!==void 0){if(o!=="files")throw Oe("filePath is only for th\
|
|
653
653
|
e files place.","VIBE64_TRAINING_GUIDE_FILE_PATH_MISPLACED");if(typeof e.filePath!="string"||!go.test(e.filePath))throw Oe(
|
|
654
654
|
"Use a relative practice project file path without '..'.","VIBE64_TRAINING_GUIDE_FILE_PATH_INVALID");a.filePath=e.filePath}
|
|
655
655
|
if(e.caption!==void 0){if(typeof e.caption!="string"||!e.caption.trim()||e.caption.length>fo)throw Oe(`Use a caption of \
|
|
656
656
|
1 to ${fo} characters.`,"VIBE64_TRAINING_GUIDE_CAPTION_INVALID",{limit:fo});a.caption=e.caption.trim()}return a}function Ba(e,t={},r=Ge){
|
|
657
657
|
let n=r.place(e);return n?.shown.length?n.shown.some(o=>Object.entries(o).every(([i,s])=>i==="route"?typeof t.route=="st\
|
|
658
|
-
ring"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}function
|
|
658
|
+
ring"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}function nm(e,t=Ge){let r=new Set,n=new Set,o=new Set;
|
|
659
659
|
for(let i of Array.isArray(e?.beats)?e.beats:[]){if(i.kind==="check")continue;let s=t.activity(i.target);s||t.declaredActivity(
|
|
660
660
|
i.target)?(n.add(i.target),s?.place&&r.add(s.place)):r.add(i.target)}return e?.guide?.target&&r.add(e.guide.target),e?.check?.
|
|
661
|
-
kind==="fact"&&o.add(e.check.fact),{places:[...r],activities:[...n],facts:[...o]}}var Se,
|
|
662
|
-
Ge,go,fo,
|
|
661
|
+
kind==="fact"&&o.add(e.check.fact),{places:[...r],activities:[...n],facts:[...o]}}var Se,Jp,Kp,z,Da,ve,Ua,po,Xp,Qp,Zp,Va,
|
|
662
|
+
Ge,go,fo,rm,Ib,jr=g(()=>{pr();G();Se=/^[a-z][a-z0-9-]{0,63}$/u,Jp=new Set(["studio","project"]),Kp=new Set(["everyone","\
|
|
663
663
|
owner"]),z=(e,t)=>Object.freeze({id:e,label:t}),Da=z("preview","Preview"),ve=z("dashboard","Dashboard"),Ua=z("database",
|
|
664
|
-
"Database"),po=z("account-menu","Account menu"),
|
|
664
|
+
"Database"),po=z("account-menu","Account menu"),Xp=[{id:"preview",label:"Preview",scope:"project",open:{pane:"preview"},
|
|
665
665
|
steps:[Da]},{id:"dashboard",label:"Dashboard",scope:"project",open:null,steps:[ve]},{id:"database-erd",label:"ERD",scope:"\
|
|
666
666
|
project",open:{pane:"database",databaseView:"erd"},steps:[ve,Ua,z("database-erd","ERD")]},{id:"database-data",label:"Dat\
|
|
667
667
|
a",scope:"project",open:{pane:"database",databaseView:"data"},steps:[ve,Ua,z("database-data","Data")]},{id:"files",label:"\
|
|
@@ -680,48 +680,48 @@ p bar")]},{id:"courses",label:"Courses",scope:"studio",open:null,shown:[{learnin
|
|
|
680
680
|
{id:"colleague",label:"Colleague",scope:"studio",open:null,event:"colleague-opened",steps:[z("colleague","Colleague")]},
|
|
681
681
|
{id:"account-menu",label:"Account menu",scope:"studio",open:null,steps:[po]},{id:"account-settings",label:"Account setti\
|
|
682
682
|
ngs",scope:"studio",open:null,steps:[po,z("account-settings","Account settings")]},{id:"ai-setup",label:"AI setup",scope:"\
|
|
683
|
-
studio",open:null,steps:[po,z("ai-setup","AI setup")]}],
|
|
683
|
+
studio",open:null,steps:[po,z("ai-setup","AI setup")]}],Qp=[{id:"send-message",event:"message-sent",place:"chat"},{id:"a\
|
|
684
684
|
gent-finished",event:"agent-finished"},{id:"file-opened",event:"file-opened",place:"files"},{id:"app-pressed",event:"app\
|
|
685
|
-
-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],
|
|
685
|
+
-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],Zp=["ai-ready"];Va=
|
|
686
686
|
e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;Ge=ho({facts:[]});go=/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\u0000-\u001f\\]{1,512}$/u,
|
|
687
|
-
fo=256;
|
|
687
|
+
fo=256;rm=e=>!!e?.open;Ib=Object.freeze({createLearningVocabulary:ho,lessonStepNeeds:nm})});function ne(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_BEATS_INVALID"})}function dm(e,t,r){let n=am.exec(
|
|
688
688
|
e);if(!n)throw ne(`beat ${t} must read "<show|do|check> <target>: <text>".`);let[,o,i,s,a=""]=n,c=`beat ${t} (${o} ${i})`;
|
|
689
689
|
if(o==="check"&&i==="review"){if(a.trim()||s!==void 0)throw ne(`${c} takes no text: the bar shows the step's check.rubri\
|
|
690
690
|
c.`);return{kind:o,target:i,text:""}}if(!a.trim())throw ne(`${c} needs its text after the colon.`);let u={kind:o,target:i,
|
|
691
691
|
text:a.trim()};if(s!==void 0&&!(o==="do"&&i==="file-opened"))throw ne(`${c} takes no argument; only do file-opened names\
|
|
692
|
-
a path.`);if(o==="show"&&!
|
|
692
|
+
a path.`);if(o==="show"&&!lm(i,r))throw ne(`${c} names an unknown place.`);if(o==="do"&&!um(i,r))throw ne(`${c} names n\
|
|
693
693
|
othing the learner can do or be at.`);if(o==="check"&&!wo[i])throw ne(`${c} must be check auto, review, done or fact.`);
|
|
694
694
|
if(s!==void 0){if(!go.test(s))throw ne(`${c} needs a relative practice project file path without '..'.`);u.path=s}let l=i===
|
|
695
|
-
"send-message"?om
|
|
696
|
-
...u.text.matchAll(
|
|
697
|
-
ed prompt of at most ${za} characters.`);u.prompt=m[0]}return u}function
|
|
695
|
+
"send-message"?im:om;if(u.text.length>l)throw ne(`${c} text is longer than ${l} characters.`);if(i==="send-message"){let m=[
|
|
696
|
+
...u.text.matchAll(cm)].map(f=>f[1].trim());if(m.length!==1||!m[0]||m[0].length>za)throw ne(`${c} needs exactly one quot\
|
|
697
|
+
ed prompt of at most ${za} characters.`);u.prompt=m[0]}return u}function Lr(e,t=Ge){let r=String(e??""),n=sm.exec(r);if(!n)
|
|
698
698
|
return{body:r,beats:null};let o=r.slice(n.index+n[0].length),i=/^```[ \t]*$/mu.exec(o);if(!i)throw ne("the beats block i\
|
|
699
699
|
s not closed with ```.");if(o.slice(i.index+i[0].length).trim())throw ne("the beats block must end the step text.");let s=o.
|
|
700
700
|
slice(0,i.index).split(`
|
|
701
701
|
`).map(u=>u.trim()).filter(Boolean);if(!s.length||s.length>Ha)throw ne(`a beats block holds 1 to ${Ha} beats.`);let a=s.
|
|
702
|
-
map((u,l)=>
|
|
702
|
+
map((u,l)=>dm(u,l+1,t)),c=a.filter(u=>u.kind==="check");if(c.length>1||c.length&&a.at(-1).kind!=="check")throw ne("a ste\
|
|
703
703
|
p has at most one check beat, and it is the last.");return{body:r.slice(0,n.index).replace(/\s+$/u,`
|
|
704
|
-
`),beats:a}}function
|
|
705
|
-
function Fa(e,t=Ge){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(
|
|
706
|
-
scope==="project":!t.declared(e.target)}var Ha,
|
|
707
|
-
freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),
|
|
708
|
-
|
|
709
|
-
place(e)||t.declaredPlace(e))});import{createHash as
|
|
710
|
-
let n=new Set;for(let o of e){let i=t?o[t]:o;if(!
|
|
704
|
+
`),beats:a}}function pm(e,t=Ge){if(!e||e.kind==="check")return"";let r=t.activity(e.target);return r?r.place||"":e.target}
|
|
705
|
+
function Fa(e,t=Ge){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(pm(e,t));return r?r.
|
|
706
|
+
scope==="project":!t.declared(e.target)}var Ha,om,za,im,wo,sm,am,cm,um,lm,yo=g(()=>{jr();Ha=8,om=160,za=500,im=600,wo=Object.
|
|
707
|
+
freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),sm=/^```beats[ \t]*$/mu,am=/^(show|do|check)[ \t]+([a-z][a-z-]*)(?:[ \t]+([^:]+?))?[ \t]*(?::[ \t]*(.*))?$/u,
|
|
708
|
+
cm=/["“]([^"“”]+)["”]/gu;um=(e,t)=>!!(t.activity(e)||t.place(e)?.event||Ba(e,{},t)!==null||t.declared(e)),lm=(e,t)=>!!(t.
|
|
709
|
+
place(e)||t.declaredPlace(e))});import{createHash as mm}from"node:crypto";function J(e){return mm("sha256").update(e).digest("hex")}var ut=g(()=>{});import{lstat as fm,readFile as hm,readdir as gm,realpath as qa}from"node:fs/promises";import ie from"node:path";function fe(e,t,r){
|
|
710
|
+
let n=new Set;for(let o of e){let i=t?o[t]:o;if(!Mr(i)||n.has(i))throw new Error(`${r}: invalid or duplicate ID ${i}.`);
|
|
711
711
|
n.add(i)}return n}function L(e){return Array.isArray(e)?`[${e.map(L).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(
|
|
712
712
|
e).sort().map(t=>`${JSON.stringify(t)}:${L(e[t])}`).join(",")}}`:JSON.stringify(e)}function Ya(e,t){let r=e.get(t.path);
|
|
713
713
|
if(r&&(r.sha256!==t.sha256||r.bytes!==t.bytes))throw new Error(`Source changed between lesson snapshots: ${t.path}. Vali\
|
|
714
714
|
date and retry.`);e.set(t.path,t)}function Be(e){let t=new Map;for(let r of e)for(let n of r.files)Ya(t,n);return[...t.values()]}
|
|
715
|
-
async function
|
|
715
|
+
async function wm(e){let t=await qa(e);async function r(i,s=t){if(typeof i!="string"||!i||i.includes("\\")||ie.isAbsolute(
|
|
716
716
|
i))throw new Error(`Invalid topic-relative path: ${i}.`);let a=ie.resolve(s,i),c=ie.relative(t,a);if(c===".."||c.startsWith(
|
|
717
717
|
`..${ie.sep}`)||ie.isAbsolute(c))throw new Error(`Path escapes topic: ${i}.`);if(await qa(a)!==a)throw new Error(`Symlin\
|
|
718
718
|
k content is not supported: ${i}.`);return{filename:a,relative:c.split(ie.sep).join("/")}}async function n(i,s=t){let a=await r(
|
|
719
|
-
i,s),c=await
|
|
720
|
-
relative}.`);return{...a,bytes:await
|
|
721
|
-
a.bytes.toString("utf8"))}}return Object.freeze({root:t,resolve:r,read:n,json:o})}function
|
|
719
|
+
i,s),c=await fm(a.filename);if(!c.isFile()||c.size>1024*1024)throw new Error(`Expected a regular file of at most 1 MiB: ${a.
|
|
720
|
+
relative}.`);return{...a,bytes:await hm(a.filename)}}async function o(i,s=t){let a=await n(i,s);return{...a,value:JSON.parse(
|
|
721
|
+
a.bytes.toString("utf8"))}}return Object.freeze({root:t,resolve:r,read:n,json:o})}function ym(e){let t=new Map(e.map(i=>[
|
|
722
722
|
i.code,i])),r=new Set,n=new Set;function o(i){if(n.has(i))throw new Error(`Prerequisite cycle at ${i}.`);if(r.has(i))return;
|
|
723
723
|
let s=t.get(i);if(!s)throw new Error(`Unknown prerequisite ${i}.`);n.add(i);for(let a of s.prerequisites)o(a.code);n.delete(
|
|
724
|
-
i),r.add(i)}for(let i of e)o(i.code)}function
|
|
724
|
+
i),r.add(i)}for(let i of e)o(i.code)}function _m(e,t,r,n){r(t);let o=t.bytes.toString("utf8");fe(e.assessments,"id","Ass\
|
|
725
725
|
essments");for(let i of e.assessments){let[s,a,c]=i.rubric.split("#");if(s!==e.document||!a||c||!new RegExp(`^<a id="${i.
|
|
726
726
|
id}"></a>$`,"mu").test(o)||a!==i.id)throw new Error(`Missing explicit rubric anchor for ${i.id}.`);if(i.kind==="practica\
|
|
727
727
|
l"&&!i.evidence)throw new Error(`Practical assessment ${i.id} needs an evidence producer.`);if(i.kind==="answer"&&i.evidence)
|
|
@@ -732,7 +732,7 @@ check&&!["exercise","code"].includes(i.evidence.producer))throw new Error(`Only
|
|
|
732
732
|
d check: ${i.id}.`);let u=(e.checks||[]).find(l=>l.id===i.evidence?.check)?.kind||"response";if(i.evidence?.producer==="\
|
|
733
733
|
code"){if(!e.exercise||!i.evidence.check||u!=="code"||!i.evidence.files?.length)throw new Error(`Code assessment ${i.id}\
|
|
734
734
|
needs its declared exercise, files and a code check.`)}else if(i.evidence?.files||i.evidence?.check&&u==="code")throw new Error(
|
|
735
|
-
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function
|
|
735
|
+
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function Em(e,t,r,n,o,i){let s=a=>{throw new Error(
|
|
736
736
|
`Lesson ${n}: ${a}`)};e.schemaVersion===3&&e.stage==="project"&&!e.exercise&&s("a project lesson needs its exercise (a p\
|
|
737
737
|
ractice project)."),e.steps.length||s("needs at least one step."),fe(e.steps,"id","Steps"),e.steps.some(a=>a.required)||
|
|
738
738
|
s("needs a required step.");for(let a of e.steps){let c=`step ${a.id}`;if(a.visual){let h=t.get(a.visual.id);h||s(`${c} \
|
|
@@ -743,7 +743,7 @@ nd ${y.name} needs a parameters object.`);for(let[d,p]of Object.entries(S)){let
|
|
|
743
743
|
name} parameter ${d} must be a string of at most ${_.maxLength} characters.`)}for(let d of T.parameters)d.required&&!Object.
|
|
744
744
|
hasOwn(S,d.name)&&s(`${c} command ${y.name} needs parameter ${d.name}.`)}}if(a.guide){let{caption:h,...y}=a.guide;try{Ga(
|
|
745
745
|
y,i)}catch(T){s(`${c} guide: ${T.message}`)}i.place(a.guide.target)?.scope==="project"&&!e.exercise&&s(`${c} guide ${a.guide.
|
|
746
|
-
target} needs the lesson's exercise (a practice project).`)}let u=null;try{({beats:u}=
|
|
746
|
+
target} needs the lesson's exercise (a practice project).`)}let u=null;try{({beats:u}=Lr(o.get(a.body),i))}catch(h){s(`${c}\
|
|
747
747
|
beats: ${h.message}`)}if(u){a.guide&&s(`${c} has both beats and a guide; its beats replace the guide.`);let h=u.find(T=>T.
|
|
748
748
|
kind==="check");h&&wo[h.target]!==a.check.kind&&s(`${c} beat check ${h.target} does not match its ${a.check.kind} check.`);
|
|
749
749
|
let y=u.find(T=>Fa(T,i));y&&!e.exercise&&s(`${c} beat ${y.kind} ${y.target} needs the lesson's exercise (a practice proj\
|
|
@@ -760,13 +760,13 @@ evidence||["changes"];(h[0]!=="changes"||h.length>2||h.length===2&&h[1]!=="conve
|
|
|
760
760
|
changes"] or ["changes", "conversation"].`)}if(l.kind==="choice"){let{question:h,options:y,answer:T}=l;(!h||!y||!T)&&s(`${c}\
|
|
761
761
|
choice needs question, options and answer.`),(y.length<2||y.length>8)&&s(`${c} choice needs 2-8 options.`),(!T.length||
|
|
762
762
|
new Set(T).size!==T.length||T.some(S=>S>=y.length))&&s(`${c} choice answer must list unique option indexes within its op\
|
|
763
|
-
tions.`)}}}async function
|
|
763
|
+
tions.`)}}}async function bm(e,t,{authoring:r,installed:n,vocabulary:o}){let i=await e.json(t.descriptor),s=Cr(i.value,t.
|
|
764
764
|
code);if(s.code!==t.code)throw new Error(`Lesson code mismatch: ${t.code}.`);if(r&&s.schemaVersion!==3)throw new Error(`\
|
|
765
765
|
Lesson ${t.code} uses retired lesson format ${s.schemaVersion}. Author it in format 3 with steps and its stage.`);let a=ie.
|
|
766
766
|
dirname(i.filename),c=new Map;function u(d){if(Ya(c,{path:d.relative,sha256:J(d.bytes),bytes:d.bytes.length}),c.size>512||
|
|
767
767
|
[...c.values()].reduce((p,_)=>p+_.bytes,0)>32*1024*1024)throw new Error(`Lesson ${t.code} exceeds bundle limits.`)}u(i);
|
|
768
768
|
let l=new Set,m=new Map;fe(s.prerequisites,"code","Lesson prerequisites");let f=fe(s.checks||[],"id","Checks");for(let d of s.
|
|
769
|
-
checks||[]){u(await e.read(d.file,a));for(let p of d.assets||[])u(await e.read(p,a))}if(s.schemaVersion===1&&
|
|
769
|
+
checks||[]){u(await e.read(d.file,a));for(let p of d.assets||[])u(await e.read(p,a))}if(s.schemaVersion===1&&_m(s,await e.
|
|
770
770
|
read(s.document,a),u,f),me(s))for(let d of[s.notes,...new Set(s.steps.map(p=>p.body))]){if(d===void 0)continue;let p=await e.
|
|
771
771
|
read(d,a);u(p),l.add(p.relative),m.set(d,p.bytes.toString("utf8"))}if(s.appRoutes&&!s.exercise)throw new Error(`Lesson ${t.
|
|
772
772
|
code} can declare app routes only with its exercise.`);let h=new Set;for(let d of s.appRoutes||[]){if(d.path!=="/"&&!d.path.
|
|
@@ -782,25 +782,25 @@ nchanged"&&!b.has(w.completionState))throw new Error(`Unknown completion state:
|
|
|
782
782
|
dirname(p.filename);for(let w of[_.svg,_.controller,..._.assets||[]]){let E=await e.read(w,v);u(E),l.add(E.relative)}}if(s.
|
|
783
783
|
exercise){let d=s.exercise;if(d.reuse==="sequence"){if(!d.sequenceId||!d.sequenceMode)throw new Error(`Invalid exercise \
|
|
784
784
|
sequence for ${t.code}.`)}else if(d.sequenceId||d.sequenceMode)throw new Error(`Invalid exercise sequence for ${t.code}.`);
|
|
785
|
-
if(d.sequenceId&&!
|
|
786
|
-
for(let w of(await
|
|
785
|
+
if(d.sequenceId&&!Mr(d.sequenceId))throw new Error("Invalid exercise sequence ID.");let p=await e.resolve(d.source,a);async function _(v){
|
|
786
|
+
for(let w of(await gm(v,{withFileTypes:!0})).sort((E,A)=>E.name<A.name?-1:E.name>A.name?1:0)){if(Wa.has(w.name))continue;
|
|
787
787
|
let E=ie.relative(e.root,ie.join(v,w.name)),A=await e.resolve(E);if(w.isDirectory())await _(A.filename);else{let I=await e.
|
|
788
788
|
read(E);u(I),l.add(I.relative)}}}await _(p.filename);let b=s.schemaVersion===1?s.assessments.map(v=>[`Code assessment ${v.
|
|
789
789
|
id}`,v.evidence?.files||[]]):s.steps.map(v=>[`Code step ${v.id}`,v.check.files||[]]);for(let[v,w]of b){for(let E of w){let A=E.
|
|
790
790
|
split("/");if(E.includes("\\")||ie.posix.isAbsolute(E)||A.some(I=>!I||I==="."||I===".."||Wa.has(I))||!c.has(p.relative?`${p.
|
|
791
791
|
relative}/${E}`:E))throw new Error(`${v} names a file outside its bundled exercise: ${E}.`)}if(new Set(w).size!==w.length)
|
|
792
|
-
throw new Error(`${v} repeats a declared file.`)}}let T="";if(me(s))try{
|
|
792
|
+
throw new Error(`${v} repeats a declared file.`)}}let T="";if(me(s))try{Em(s,y,f,t.code,m,o)}catch(d){if(!n)throw d;T=d.
|
|
793
793
|
message}let S={schemaVersion:1,code:s.code,files:[...c.values()].sort((d,p)=>d.path<p.path?-1:d.path>p.path?1:0)};return{
|
|
794
794
|
lesson:s,manifest:S,hash:J(L(S)),descriptorPath:i.relative,served:l,...T?{problem:T}:{}}}async function He(e,t={}){let{authoring:r=!1,
|
|
795
|
-
installed:n=!1}=t,o=await
|
|
796
|
-
test(i.value.version||""))throw new Error("Topic package needs a learn- name and an exact release version.");let s=ce(
|
|
797
|
-
i.value.vibe64Training,"Topic");if(!
|
|
795
|
+
installed:n=!1}=t,o=await wm(e),i=await o.json("package.json");if(!/^learn-[a-z0-9-]+$/u.test(i.value.name||"")||!/^\d+\.\d+\.\d+$/u.
|
|
796
|
+
test(i.value.version||""))throw new Error("Topic package needs a learn- name and an exact release version.");let s=ce(kr,
|
|
797
|
+
i.value.vibe64Training,"Topic");if(!Mr(s.topicId)||!Mr(s.domainId))throw new Error("Invalid topic or domain ID.");let a=await o.
|
|
798
798
|
read(s.outline);if(fe(s.lessons,"code","Lessons"),fe(s.prerequisites,"topicId","Topic prerequisites"),!s.lessons.length)
|
|
799
799
|
throw new Error("A topic needs lessons.");if(s.status==="released"&&s.lessons.some(y=>y.required&&y.status!=="published"))
|
|
800
|
-
throw new Error("A released topic contains required draft lessons.");let c
|
|
801
|
-
let{served:T,...S}=await
|
|
800
|
+
throw new Error("A released topic contains required draft lessons.");let c=$r(s),u=[],l=new Set;for(let y of s.lessons){
|
|
801
|
+
let{served:T,...S}=await bm(o,y,{authoring:r,installed:n,vocabulary:c});for(let d of T)l.add(d);u.push({...S,status:y.status,
|
|
802
802
|
required:y.required})}for(let{descriptorPath:y,lesson:T}of u)if(me(T)&&l.has(y))throw new Error(`Lesson ${T.code} descri\
|
|
803
|
-
ptor cannot also be a step body, notes, visual or exercise file.`);
|
|
803
|
+
ptor cannot also be a step body, notes, visual or exercise file.`);ym(u.map(y=>y.lesson));for(let[y,T]of u.entries())for(let{
|
|
804
804
|
code:S}of T.lesson.prerequisites){let d=u.findIndex(p=>p.lesson.code===S);if(d>=y)throw new Error(`Prerequisite ${S} mus\
|
|
805
805
|
t precede ${T.lesson.code}.`);if(T.status==="published"&&u[d].status!=="published")throw new Error(`Published lesson ${T.
|
|
806
806
|
lesson.code} requires draft ${S}.`)}let m=new Map;for(let{lesson:y,descriptorPath:T,status:S}of u){if(y.exercise?.reuse!==
|
|
@@ -810,65 +810,65 @@ m.set(y.exercise.sequenceId,{source:d,status:S})}else if(!p||p.source!==d||S==="
|
|
|
810
810
|
`Invalid create/continue sequence: ${y.code}.`)}let f=[i,a].map(y=>({path:y.relative,sha256:J(y.bytes),bytes:y.bytes.length})),
|
|
811
811
|
h={schemaVersion:1,topic:s,release:i.value.version,files:f,lessons:u.map(({lesson:y,hash:T,status:S,required:d})=>({code:y.
|
|
812
812
|
code,hash:T,status:S,required:d}))};return Be([h,...u.map(y=>y.manifest)]),{topic:s,release:i.value.version,bundles:u,topicManifest:h,
|
|
813
|
-
topicHash:J(L(h))}}var Wa,
|
|
814
|
-
test(e)});import{execFile as
|
|
815
|
-
import{promisify as
|
|
813
|
+
topicHash:J(L(h))}}var Wa,Mr,lt=g(()=>{ct();jr();yo();ut();Wa=new Set([".git","node_modules",".genesis"]),Mr=e=>/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u.
|
|
814
|
+
test(e)});import{execFile as vm}from"node:child_process";import{readFile as Sm}from"node:fs/promises";import _o from"node:os";import Tm from"node:path";
|
|
815
|
+
import{promisify as Im}from"node:util";function Ka(e=""){let t=V(e);if(!t||t.includes("/")||t.includes("\\")||t.includes(
|
|
816
816
|
":")){let r=new Error("A valid OS username is required.");throw r.code="vibe64_invalid_os_username",r}return t}function Xa([
|
|
817
817
|
e,t,r,n,o,i]=[]){if(!/^\d+$/u.test(t)||!/^\d+$/u.test(r))return null;let s=Number(t),a=Number(r);return!Number.isSafeInteger(
|
|
818
818
|
s)||!Number.isSafeInteger(a)?null:{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),
|
|
819
819
|
uid:s,username:String(e||"")}}function Eo(e=""){let t=String(e||"").trim().split(":");return t.length<7?null:Xa([t[0],t[2],
|
|
820
|
-
t[3],t[4],t[5],t[6]])}function
|
|
820
|
+
t[3],t[4],t[5],t[6]])}function Om(e=""){return String(e||"").split(/\r?\n[\t ]*\r?\n/u).map(t=>{let r={};for(let n of t.
|
|
821
821
|
split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);o&&(r[o[1]]=o[2].trim())}return Xa([r.name,r.uid,r.gid,r.gecos,r.
|
|
822
822
|
dir,r.shell])}).filter(Boolean)}async function Ja(e,t,r){let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="\
|
|
823
|
-
string"?n:n?.stdout)||"")}function
|
|
824
|
-
env.USER||process.env.LOGNAME),o=
|
|
823
|
+
string"?n:n?.stdout)||"")}function Mt({homedir:e=_o.homedir,userInfo:t=_o.userInfo}={}){let r=t(),n=V(r?.username||process.
|
|
824
|
+
env.USER||process.env.LOGNAME),o=Tm.resolve(String(r?.homedir||e()||""));return{displayName:String(r?.username||n),gid:Number.
|
|
825
825
|
isSafeInteger(r?.gid)?r.gid:null,home:o,shell:String(r?.shell||""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}
|
|
826
|
-
async function
|
|
826
|
+
async function Dr(e="",{execFileFn:t=Am,platform:r=process.platform,readFileFn:n=Sm,userInfo:o=_o.userInfo}={}){let i=Ka(
|
|
827
827
|
e);if(r==="linux"&&!/^\d+$/u.test(i)){let c=[...(await n("/etc/nsswitch.conf","utf8").catch(()=>"")).matchAll(/^[\t ]*passwd[\t ]*:[\t ]*([^#\r\n]*)/gmu)],
|
|
828
828
|
u=c.length===1?c[0][1].trim().split(/\s+/u):[];if(u[0]==="files"&&(u.length===1||/^[a-z_][a-z0-9_-]*$/iu.test(u[1]))){let m=(await n(
|
|
829
829
|
"/etc/passwd","utf8").catch(()=>"")).split(/\r?\n/u).map(Eo).find(f=>f?.username===i);if(m)return m}}let s;if(r==="darwi\
|
|
830
|
-
n"){let a=
|
|
830
|
+
n"){let a=Mt({userInfo:o});if(a.username===i)return a;[s]=Om(await Ja(t,"dscacheutil",["-q","user","-a","name",i]))}else
|
|
831
831
|
s=Eo((await Ja(t,"getent",["passwd",i])).split(/\r?\n/u)[0]);if(!s||s.username!==i){let a=new Error(`OS user was not fou\
|
|
832
|
-
nd: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var
|
|
833
|
-
isSafeInteger(t)&&t>=0?t:null}function C(e=""){let t=P(e);return t?
|
|
834
|
-
t);if(!r||!n)return!1;let o=
|
|
832
|
+
nd: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var Am,zb,Ur=g(()=>{G();Am=Im(vm);zb=Object.freeze({parsePasswdLine:Eo})});var Qa=g(()=>{Ur();G()});import Vr from"node:path";function P(e=""){return String(e??"").trim()}function bo(e=null){let t=Number(e);return Number.
|
|
833
|
+
isSafeInteger(t)&&t>=0?t:null}function C(e=""){let t=P(e);return t?Vr.resolve(t):""}function Re(e="",t=""){let r=C(e),n=C(
|
|
834
|
+
t);if(!r||!n)return!1;let o=Vr.relative(r,n);return o!==".."&&!o.startsWith(`..${Vr.sep}`)&&!Vr.isAbsolute(o)}function Y(e={}){
|
|
835
835
|
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ue(e={}){return Object.fromEntries(Object.entries(Y(e)).map(
|
|
836
836
|
([t,r])=>[P(t),String(r??"")]).filter(([t])=>!!t))}function ze(e=[]){let t=[],r=new Set;for(let n of Array.isArray(e)?e:
|
|
837
837
|
[e]){let o=P(n);!o||r.has(o)||(r.add(o),t.push(o))}return t}function dt(e){let t=Date.parse(String(e||"").trim());return Number.
|
|
838
|
-
isFinite(t)?t:0}function Te(...e){for(let t of e){let r=P(t);if(r)return r}return""}var q=g(()=>{});import
|
|
838
|
+
isFinite(t)?t:0}function Te(...e){for(let t of e){let r=P(t);if(r)return r}return""}var q=g(()=>{});import Rm from"node:os";import vo from"node:path";function So(e={}){let t=P(e.username),r=C(e.home||(t?`/home/${t}`:Rm.homedir()));
|
|
839
839
|
return{displayName:P(e.displayName||t),gid:bo(e.gid),home:r,shell:P(e.shell),uid:bo(e.uid),username:t}}function To(){return So(
|
|
840
|
-
|
|
840
|
+
Mt())}async function Io(e="",t={}){return So(await Dr(e,t))}function Dt(e={},t={}){let r=So(e);return{...t,HOME:r.home,LOGNAME:r.
|
|
841
841
|
username,USER:r.username,XDG_CACHE_HOME:vo.join(r.home,".cache"),XDG_CONFIG_HOME:vo.join(r.home,".config"),XDG_DATA_HOME:vo.
|
|
842
842
|
join(r.home,".local","share")}}function Za(){return{gid:typeof process.getgid=="function"?process.getgid():null,uid:typeof process.
|
|
843
|
-
getuid=="function"?process.getuid():null}}var pt=g(()=>{
|
|
843
|
+
getuid=="function"?process.getuid():null}}var pt=g(()=>{Ur();q()});function Pm(e=0){let t=Number(e);return Number.isSafeInteger(t)?t:1}function Ut({code:e="",error:t="",exitCode:r=0,ok:n=null,
|
|
844
844
|
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:l=!1,execution:m=null,retryable:f=null}={}){
|
|
845
|
-
let h=
|
|
845
|
+
let h=Pm(r),y=String(u||""),T=String(c||""),S=String(o||[y,T].filter(Boolean).join(`
|
|
846
846
|
`)).trim();return{code:P(e),error:P(t),exitCode:h,ok:n===null?h===0:n===!0,output:S,pid:Number.isSafeInteger(Number(s))?
|
|
847
847
|
Number(s):null,signal:P(a),stderr:T,stdout:y,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...m&&typeof m=="obje\
|
|
848
848
|
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof f=="boolean"?{retryable:f}:{}}}function K(e="",t="vibe64_command_faile\
|
|
849
|
-
d",r={}){let n=P(e)||"Vibe64 command failed.";return
|
|
850
|
-
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}var Fe=g(()=>{q()});import{spawn as
|
|
851
|
-
import{stripVTControlCharacters as
|
|
852
|
-
let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.toString(16)}`})}function
|
|
849
|
+
d",r={}){let n=P(e)||"Vibe64 command failed.";return Ut({...r,code:t,error:n,exitCode:1,ok:!1,output:P(r.output)||n,stderr:r.
|
|
850
|
+
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}var Fe=g(()=>{q()});import{spawn as Nm}from"node:child_process";import{statSync as Cm}from"node:fs";import km from"node:path";import{StringDecoder as xm}from"node:string_decoder";
|
|
851
|
+
import{stripVTControlCharacters as $m}from"node:util";function nc(e){return e.replaceAll(Mm,t=>{if(tc[t]!==void 0)return tc[t];
|
|
852
|
+
let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.toString(16)}`})}function Dm(e){return $m(
|
|
853
853
|
e).split(`
|
|
854
854
|
`).map(nc).join(`
|
|
855
|
-
`)}function
|
|
856
|
-
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function
|
|
857
|
-
return r;try{if(!
|
|
855
|
+
`)}function Um(e,t){return[e,...t].map(r=>{let n=nc(String(r));return Lm.test(n)?n:process.platform==="win32"?`"${n.replaceAll(
|
|
856
|
+
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function Vm(e,t){let r=String(e?.message??e);if(t===process.cwd())
|
|
857
|
+
return r;try{if(!Cm(t).isDirectory())return`The "cwd" option is not a directory: ${t}.
|
|
858
858
|
${r}`}catch(n){return`The "cwd" option is invalid: ${t}.
|
|
859
859
|
${n.message}
|
|
860
|
-
${r}`}return r}function
|
|
860
|
+
${r}`}return r}function Gm(e){let t=e.forcefullyTerminated?` and was forcefully terminated after ${rc} milliseconds`:"";
|
|
861
861
|
if(e.timedOut)return`Command timed out after ${e.timeout} milliseconds${t}`;if(e.maxBuffer)return`Command's ${e.maxBuffer.
|
|
862
862
|
stream} was larger than ${e.maxBuffer.limit} ${e.maxBuffer.unit}${t}`;if(e.spawnError?.code!==void 0)return`Command fail\
|
|
863
|
-
ed with ${e.spawnError.code}${t}`;if(e.signal){let r
|
|
864
|
-
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function
|
|
865
|
-
|
|
866
|
-
${t}`:""}`}function Ao(e,t){let r=new
|
|
863
|
+
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=jm[e.signal];return`Command was killed with ${e.signal}${r?` (${r})`:
|
|
864
|
+
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function Bm(e){let t=e.spawnError?
|
|
865
|
+
Dm(Vm(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${Gm(e)}: ${e.commandLine}${t?`
|
|
866
|
+
${t}`:""}`}function Ao(e,t){let r=new xm(e),n=[],o=0,i=!1;return{write(s){if(i)return!1;let a=r.write(s);return o+a.length>
|
|
867
867
|
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)),
|
|
868
868
|
i=!0}return n.join("")}}}function oc(e,t,{cwd:r="",env:n={},input:o=void 0,maxBuffer:i=ec,onOutput:s=null,outputEncoding:a="\
|
|
869
869
|
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:ec,l={all:Ao(a,u*2),stderr:Ao(a,u),stdout:Ao(a,u)},m=o!=null,
|
|
870
|
-
f=
|
|
871
|
-
h={commandLine:
|
|
870
|
+
f=Nm(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[m?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
871
|
+
h={commandLine:Um(e,t),cwd:km.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
872
872
|
y=!1,T=null,S=()=>{};f.on("error",v=>{h.spawnError||=v,f.pid===void 0&&S()});let d=()=>{y||!f.kill("SIGTERM")||T||(T=setTimeout(
|
|
873
873
|
()=>{!y&&f.kill("SIGKILL")&&(h.forcefullyTerminated=!0)},rc))},p=(v,w)=>E=>{if(l.all.write(E),l[v].write(E)||(h.maxBuffer||=
|
|
874
874
|
{limit:u,stream:v,unit:"characters"},w.destroy()),typeof s=="function")try{s(String(E||""))}catch{}};f.stdout&&f.stdout.
|
|
@@ -876,45 +876,45 @@ on("data",p("stdout",f.stdout)),f.stderr&&f.stderr.on("data",p("stderr",f.stderr
|
|
|
876
876
|
f.stdin.end(o));let _=c>0?setTimeout(()=>{h.timedOut=!0,d()},c):null;return{completion:new Promise(v=>{S=(w,E)=>{if(y)return;
|
|
877
877
|
y=!0,clearTimeout(_),clearTimeout(T);let A=h.spawnError?{}:{exitCode:typeof w=="number"&&w>=0?w:void 0,signal:E||void 0},
|
|
878
878
|
I=h.spawnError||h.timedOut||h.maxBuffer||A.exitCode!==0;v({all:l.all.text(),code:h.spawnError?.code,exitCode:A.exitCode,
|
|
879
|
-
shortMessage:I?
|
|
880
|
-
once("close",S)}),kill:v=>f.kill(v),pid:f.pid}}var ec,rc
|
|
879
|
+
shortMessage:I?Bm({...h,...A}):"",signal:A.signal,stderr:l.stderr.text(),stdout:l.stdout.text(),timedOut:h.timedOut})},f.
|
|
880
|
+
once("close",S)}),kill:v=>f.kill(v),pid:f.pid}}var ec,rc,jm,Lm,Mm,tc,ic=g(()=>{ec=1e8,rc=5e3,jm=Object.freeze({SIGABRT:"\
|
|
881
881
|
Aborted",SIGALRM:"Timeout or timer",SIGHUP:"Terminal closed",SIGINT:"User interruption with CTRL-C",SIGKILL:"Forced term\
|
|
882
882
|
ination",SIGPIPE:"Broken pipe or socket",SIGQUIT:"User interruption with CTRL-\\",SIGSEGV:"Segmentation fault",SIGTERM:"\
|
|
883
|
-
Termination",SIGUSR1:"Application-specific signal",SIGUSR2:"Application-specific signal"}),
|
|
884
|
-
"\\p{Separator}|\\p{Other}","gu"),tc=Object.freeze({" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"})});import{spawn as cc}from"node:child_process";import{mkdir as
|
|
885
|
-
import
|
|
886
|
-
let t=cc(process.execPath,[
|
|
883
|
+
Termination",SIGUSR1:"Application-specific signal",SIGUSR2:"Application-specific signal"}),Lm=/^[\w./-]+$/u,Mm=new RegExp(
|
|
884
|
+
"\\p{Separator}|\\p{Other}","gu"),tc=Object.freeze({" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"})});import{spawn as cc}from"node:child_process";import{mkdir as zm,open as Fm,readdir as qm,readFile as Wm}from"node:fs/promises";
|
|
885
|
+
import Ym from"node:path";import{fileURLToPath as Jm}from"node:url";function Zm(e){if(process.platform!=="win32"){if(!de){
|
|
886
|
+
let t=cc(process.execPath,[Qm],{cwd:"/",detached:!0,stdio:["pipe","ignore","ignore"]});t.once("error",()=>{de===t&&(de=null)}),
|
|
887
887
|
t.once("exit",()=>{de===t&&(de=null)}),t.stdin.on("error",()=>{}),t.unref(),t.stdin.unref(),de=t;for(let r of qe.values())
|
|
888
888
|
r.scopeEmpty!==!0&&r.pid!==e&&t.stdin.write(`+${r.pid}
|
|
889
889
|
`)}de.stdin.write(`+${e}
|
|
890
|
-
`)}}function
|
|
891
|
-
`),![...qe.values()].some(t=>t.scopeEmpty!==!0)&&(de.stdin.end(),de=null))}async function
|
|
892
|
-
dirname(e),{recursive:!0}),
|
|
890
|
+
`)}}function ef(e){de&&(de.stdin.write(`-${e}
|
|
891
|
+
`),![...qe.values()].some(t=>t.scopeEmpty!==!0)&&(de.stdin.end(),de=null))}async function tf(e=""){return e?(await zm(Ym.
|
|
892
|
+
dirname(e),{recursive:!0}),Fm(e,"w",384)):null}async function rf(e){return new Promise((t,r)=>{let n=!1,o=(i,s)=>{n||(n=
|
|
893
893
|
!0,i(s))};e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function uc(e={},t={}){let{cwd:r="",env:n={}}=t,o=null;
|
|
894
|
-
try{o=await
|
|
895
|
-
detached:!0,env:n,stdio:i});await
|
|
896
|
-
s.pid)),s.once("exit",()=>{!
|
|
897
|
-
s.unref(),
|
|
894
|
+
try{o=await tf(e.logPath);let i=o?["ignore",o.fd,o.fd]:["ignore","ignore","ignore"],s=cc(e.command,e.args,{cwd:r||void 0,
|
|
895
|
+
detached:!0,env:n,stdio:i});await rf(s);let a=e.execution?.id||"";return a&&(qe.set(a,{child:s,pid:Number(s.pid)}),Zm(Number(
|
|
896
|
+
s.pid)),s.once("exit",()=>{!Gr(s.pid)&&qe.has(a)&&(qe.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),ef(Number(s.pid)))})),
|
|
897
|
+
s.unref(),Ut({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return K(i?.
|
|
898
898
|
message||"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{
|
|
899
|
-
await o?.close().catch(()=>null)}}function
|
|
899
|
+
await o?.close().catch(()=>null)}}function Gr(e=null){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;if(process.
|
|
900
900
|
platform==="win32"){let r=[...qe.values()].find(n=>n.pid===t);return r?.child?.exitCode===null&&r?.child?.signalCode===null}
|
|
901
|
-
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function sc(e=null,t="SIGTERM"){if(!
|
|
901
|
+
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function sc(e=null,t="SIGTERM"){if(!Gr(e))return!1;try{
|
|
902
902
|
return process.platform==="win32"?[...qe.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),
|
|
903
903
|
!0}catch(r){if(r?.code==="ESRCH")return!1;throw r}}async function lc(e=null,t=10){let r=Number(e);if(process.platform!==
|
|
904
|
-
"linux"||!Number.isSafeInteger(r)||r<=0)return[];let n=[];for(let o of await
|
|
905
|
-
if(!/^\d+$/u.test(o))continue;let i=await
|
|
904
|
+
"linux"||!Number.isSafeInteger(r)||r<=0)return[];let n=[];for(let o of await qm("/proc").catch(()=>[])){if(n.length>=t)break;
|
|
905
|
+
if(!/^\d+$/u.test(o))continue;let i=await Wm(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(
|
|
906
906
|
s+2).split(" ");Number(a[2])!==r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}return n}async function ac(e=null,t=0){
|
|
907
|
-
let r=Date.now()+Math.max(0,Number(t)||0);for(;
|
|
908
|
-
async function
|
|
909
|
-
(sc(e,"SIGKILL"),o=await ac(e,r)),o}var
|
|
910
|
-
cution/src/server/engines/detached.js",import.meta.url).href,qe=new Map,
|
|
911
|
-
|
|
907
|
+
let r=Date.now()+Math.max(0,Number(t)||0);for(;Gr(e)&&Date.now()<r;)await new Promise(n=>setTimeout(n,25));return!Gr(e)}
|
|
908
|
+
async function Br(e=null,t={}){let{killTimeoutMs:r=Xm,termTimeoutMs:n=Km}=t;sc(e,"SIGTERM");let o=await ac(e,n);return o||
|
|
909
|
+
(sc(e,"SIGKILL"),o=await ac(e,r)),o}var Hm,qe,Km,Xm,Qm,de,Vt=g(()=>{Fe();Hm=new URL("./../node_modules/@local/vibe64-exe\
|
|
910
|
+
cution/src/server/engines/detached.js",import.meta.url).href,qe=new Map,Km=3e3,Xm=1e3,Qm=Jm(new URL("./detachedReaper.js",
|
|
911
|
+
Hm)),de=null});async function Gt(e="",t=[],r={}){let{cwd:n="",env:o={},execution:i=null,input:s=void 0,maxBuffer:a=void 0,onOutput:c=null,
|
|
912
912
|
outputEncoding:u="utf8",signal:l=null,timeout:m=15e3}=r,f,h,y,T=null,S=Promise.withResolvers(),d=()=>{y||=h(),y.then(S.resolve)};
|
|
913
913
|
if(l?.aborted)return K("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let b=oc(e,t,{cwd:n,env:o,input:s,
|
|
914
914
|
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});T=Number(b.pid);let v;h=()=>{if(!v){let A;process.platform!=="win32"?
|
|
915
|
-
A=
|
|
915
|
+
A=Br(T).catch(()=>!1):(b.kill("SIGKILL"),A=b.completion.then(()=>!0)),v=A.then(I=>(I||(v=null),I))}return v},i?.id&&dc.set(
|
|
916
916
|
i.id,h),l?.addEventListener("abort",d,{once:!0}),l?.aborted&&d();let w=await Promise.race([b.completion,S.promise.then(A=>A?
|
|
917
|
-
b.completion:{exitCode:1})]),E=typeof w.exitCode=="number"?w.exitCode:1;f=
|
|
917
|
+
b.completion:{exitCode:1})]),E=typeof w.exitCode=="number"?w.exitCode:1;f=Ut({code:w.timedOut===!0?"vibe64_command_captu\
|
|
918
918
|
re_timed_out":w.code?"vibe64_command_capture_failed":"",error:E===0?"":w.shortMessage,exitCode:E,output:w.all||(E===0?"":
|
|
919
919
|
w.shortMessage),outputEncoding:u,signal:w.signal,stderr:w.stderr,stdout:w.stdout,timedOut:w.timedOut===!0,execution:i})}catch(b){
|
|
920
920
|
f=K(b.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{l?.removeEventListener("abort",d)}
|
|
@@ -923,13 +923,13 @@ if(!await(y||h?.()||!0)){let b=await lc(T),v=f?.timedOut?"The command timed out"
|
|
|
923
923
|
`${v}, and its execution scope did not become empty${w}.`,"vibe64_execution_drain_failed",{execution:i,output:f?.output,
|
|
924
924
|
outputEncoding:u,signal:f?.signal,stderr:f?.stderr,stdout:f?.stdout,timedOut:f?.timedOut}),remainingProcesses:b}}i?.id&&
|
|
925
925
|
dc.delete(i.id);let _=i&&{...i,state:"finished"};return l?.aborted?K("Command cancelled.","vibe64_command_cancelled",{...f,
|
|
926
|
-
execution:_,outputEncoding:u}):_?{...f,execution:_}:f}var dc,
|
|
926
|
+
execution:_,outputEncoding:u}):_?{...f,execution:_}:f}var dc,Bt=g(()=>{Fe();ic();Vt();dc=new Map});function he(){return globalThis[nf]||of}var nf,of,Pe=g(()=>{nf=Symbol.for("vibe64.hostProfile"),of=Object.freeze({runtimePackRoot:"",
|
|
927
927
|
sharedCacheRoot:"",execHelperPath:"",sharedGroupAccess:!1})});function Oo(e=""){let t=String(e||"").trim()||he().execHelperPath;if(!t){let r=new Error("This computer has no helper fo\
|
|
928
928
|
r running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}function pc(e={}){return{
|
|
929
|
-
...e,schema:
|
|
929
|
+
...e,schema:sf,schemaVersion:af}}function Hr({actor:e={},command:t="",cwd:r="",env:n={},input:o,operation:i="vibe64-comm\
|
|
930
930
|
and",args:s=[]}={}){return pc({args:Array.isArray(s)?s.map(a=>String(a)):[],command:t,cwd:r,env:n,gid:e.user?.gid,home:e.
|
|
931
931
|
user?.home,inputBase64:o==null?"":Buffer.isBuffer(o)?o.toString("base64"):Buffer.from(String(o)).toString("base64"),operation:i,
|
|
932
|
-
uid:e.user?.uid,username:e.user?.username})}function
|
|
932
|
+
uid:e.user?.uid,username:e.user?.username})}function Ht(e={}){return e.mode==="pty"&&e.envPolicy==="auth"&&!["assistant",
|
|
933
933
|
"codex"].includes(e.purpose)?"account-auth-terminal":e.purpose==="codex"&&e.mode==="capture"&&e.envPolicy==="auth"||e.purpose===
|
|
934
934
|
"codex"&&e.mode==="detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"?"codex-app-server":e.mode===
|
|
935
935
|
"detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"&&["opencode-catalog","opencode-server"].
|
|
@@ -937,86 +937,86 @@ includes(e.execution?.operationId)||e.mode==="capture"&&e.execution?.kind==="ass
|
|
|
937
937
|
ncode-catalog"?"opencode-app-server":e.purpose==="account"?"account-status":e.purpose==="github"?"github-workflow-comman\
|
|
938
938
|
d":e.purpose==="github-api"?"github-api-command":e.purpose==="workspace-cache"?"workspace-cache-command":e.purpose==="he\
|
|
939
939
|
alth"?"health-status":"vibe64-command"}async function Ro(e={},{env:t,helperPath:r="",maxBuffer:n=void 0,outputEncoding:o="\
|
|
940
|
-
utf8",runCapture:i=
|
|
940
|
+
utf8",runCapture:i=Gt,signal:s=null,timeout:a=15e3}){let c={env:t,input:`${JSON.stringify(e)}
|
|
941
941
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
942
|
-
udo",["-n",Oo(r),"execute"],c)}var
|
|
943
|
-
upport/symlinkSafeRequire.js",import.meta.url).href,
|
|
944
|
-
{callbackPath:"/auth/login",customScheme:"",appLinkDomains:Object.freeze([])})
|
|
945
|
-
targetSdk:35,versionCode:1,versionName:"1.0.0"})});var hc=g(()=>{G();fc()});var Po=g(()=>{});var No=g(()=>{});var gc=g(()=>{Po();G();No()});var wc=g(()=>{});var
|
|
946
|
-
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var Co=g(()=>{G()});import
|
|
942
|
+
udo",["-n",Oo(r),"execute"],c)}var sf,af,zr=g(()=>{Bt();Pe();sf="vibe64.exec-helper.payload",af=1});import{createRequire as uf}from"node:module";var cf,Iv,mc=g(()=>{cf=new URL("./../node_modules/@jskit-ai/kernel/server/s\
|
|
943
|
+
upport/symlinkSafeRequire.js",import.meta.url).href,Iv=uf(cf)});var Cv,kv,xv,$v,fc=g(()=>{G();Cv=Object.freeze(["bundled","dev_server"]),kv=Object.freeze(["capacitor"]),xv=Object.freeze(
|
|
944
|
+
{callbackPath:"/auth/login",customScheme:"",appLinkDomains:Object.freeze([])}),$v=Object.freeze({packageName:"",minSdk:26,
|
|
945
|
+
targetSdk:35,versionCode:1,versionName:"1.0.0"})});var hc=g(()=>{G();fc()});var Po=g(()=>{});var No=g(()=>{});var gc=g(()=>{Po();G();No()});var wc=g(()=>{});var Zv,eS,yc=g(()=>{jt();G();wc();Po();Zv=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),eS=Object.
|
|
946
|
+
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var Co=g(()=>{G()});import pf from"node:child_process";import{constants as ko}from"node:fs";import{open as mf}from"node:fs/promises";import xo from"node:path";
|
|
947
947
|
function $o(e="",t=jo){let r=new Error(e||"Exclusive file lock failed.");return r.code=t,r}function _c(e="",t="path",r=jo){
|
|
948
948
|
let n=String(e||"").trim();if(!n||!xo.isAbsolute(n)||xo.normalize(n)!==n)throw $o(`${t} must be a normalized absolute pa\
|
|
949
|
-
th.`,r);return n}function
|
|
949
|
+
th.`,r);return n}function hf(e,t){return new Promise((r,n)=>{let o=pf.spawn("/usr/bin/flock",["--exclusive","--nonblock",
|
|
950
950
|
"3"],{cwd:t,env:{PATH:"/usr/bin:/bin"},stdio:["ignore","ignore","pipe",e]}),i="";o.stderr.on("data",s=>{i=`${i}${String(
|
|
951
951
|
s||"")}`.slice(-4096)}),o.once("error",n),o.once("close",s=>r({status:s,stderr:i.trim()}))})}async function mt(e="",{cwd:t="",
|
|
952
|
-
errorCode:r=jo}={}){let n=_c(e,"lockPath",r),o=t?_c(t,"cwd",r):xo.dirname(n),i=await
|
|
953
|
-
432),s;try{s=await
|
|
954
|
-
ck failed."),r)}if(s.status!==0){if(await i.close(),s.status===
|
|
955
|
-
ed${s.stderr?`: ${s.stderr}`:"."}`,r)}let a=!1;return async()=>{a||(a=!0,await i.close())}}var jo,
|
|
956
|
-
lock_failed",
|
|
952
|
+
errorCode:r=jo}={}){let n=_c(e,"lockPath",r),o=t?_c(t,"cwd",r):xo.dirname(n),i=await mf(n,ko.O_CREAT|ko.O_NOFOLLOW|ko.O_RDWR,
|
|
953
|
+
432),s;try{s=await hf(i.fd,o)}catch(c){throw await i.close().catch(()=>null),$o(c?.message||String(c||"Exclusive file lo\
|
|
954
|
+
ck failed."),r)}if(s.status!==0){if(await i.close(),s.status===ff)return null;throw $o(`Exclusive file lock process fail\
|
|
955
|
+
ed${s.stderr?`: ${s.stderr}`:"."}`,r)}let a=!1;return async()=>{a||(a=!0,await i.close())}}var jo,ff,Ec=g(()=>{jo="file_\
|
|
956
|
+
lock_failed",ff=1});var gf,uS,bc=g(()=>{gf="jskit-client-build",uS=new RegExp(`<meta name="${gf}" content="([0-9a-f]+)"`,"u")});import yf from"node:path";var hS,vc=g(()=>{bc();Co();hS=yf.join("dist","index.html")});var Fr=g(()=>{mc();hc();gc();No();yc();Co();Ec();vc()});var Sc=g(()=>{Fr()});function _f(e={}){return Te(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
957
957
|
session?.metadata?.session_git_command_actor_user_key)}async function Tc(e={}){let t=P(e.actor)||"daemon";if(t==="app"&&
|
|
958
958
|
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await Io(e.applicationAccount)};
|
|
959
|
-
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:To()};let r=
|
|
959
|
+
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:To()};let r=_f(e);if(!r){let n=new Error(
|
|
960
960
|
"A user key is required for real-user command execution.");throw n.code="vibe64_command_actor_user_required",n}return{actor:t,
|
|
961
961
|
credentialScope:"user",requiresRealUser:!0,user:await Io(r)}}var Ic=g(()=>{q();pt()});import Ac from"node:path";function ft(e={}){let t=Za();return t.uid===null||t.gid===null||t.uid===e.user?.uid&&t.gid===e.
|
|
962
|
-
user?.gid}function Lo(){return!!he().execHelperPath}function
|
|
962
|
+
user?.gid}function Lo(){return!!he().execHelperPath}function qr(e={}){return e.requiresRealUser?Lo()||!ft(e):!1}function Oc(e={},t={},r=""){
|
|
963
963
|
if(!e.requiresRealUser)return;let n=C(t.session?.sourceRoot||t.session?.sourcePath),o=C(r);if(!n||!o||!Re(n,o))return;let i=new Error(
|
|
964
964
|
"Commands in a session's source must run as the editor's own user, not as a person's account.");throw i.code="vibe64_com\
|
|
965
965
|
mand_managed_source_real_user_forbidden",i}function Rc(e={},t={}){let r=C(e.user?.home),n=C(t.HOME),o=C(t.VIBE64_CREDENTIAL_HOME);
|
|
966
966
|
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&Ac.resolve(r)!==Ac.resolve(n)){let i=new Error("Command HOME does not match t\
|
|
967
|
-
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var
|
|
968
|
-
q();
|
|
967
|
+
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var Wr=g(()=>{pt();Pe();q()});function Yr(...e){let t={};for(let r of e){let n=ue(r);for(let o of zt)n[o]!==void 0&&(t[o]=n[o])}return t}var zt,Jr=g(()=>{
|
|
968
|
+
q();zt=Object.freeze(["DATABASE_URL","DB_CLIENT","DB_DATABASE","DB_HOST","DB_NAME","DB_PASSWORD","DB_PORT","DB_USER","DB\
|
|
969
969
|
_USERNAME","MYSQL_DATABASE","MYSQL_HOST","MYSQL_PWD","MYSQL_TCP_PORT","PGDATABASE","PGHOST","PGPASSWORD","PGPORT","PGUSE\
|
|
970
|
-
R","VIBE64_MYSQL_USER"])});import{spawn as
|
|
971
|
-
import{stat as Lc}from"node:fs/promises";import
|
|
972
|
-
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function
|
|
970
|
+
R","VIBE64_MYSQL_USER"])});import{spawn as Ef,spawnSync as bf}from"node:child_process";import{createHash as vf}from"node:crypto";import{statSync as jc}from"node:fs";
|
|
971
|
+
import{stat as Lc}from"node:fs/promises";import Kr from"node:path";function Nc(e="",t="vibe64"){return P(e).toLowerCase().
|
|
972
|
+
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function If(...e){for(let t of e){let r=Y(t),n=Y(r.user),
|
|
973
973
|
o=Te(r.name,r.userName,r.user_name,r.gitUserName,r.git_user_name,n.name,n.userName,n.user_name),i=Te(r.email,r.userEmail,
|
|
974
974
|
r.user_email,r.gitUserEmail,r.git_user_email,n.email,n.userEmail,n.user_email);if(o&&i)return{authorEmail:i,authorName:o,
|
|
975
|
-
committerEmail:i,committerName:o,source:"configured"}}return null}function
|
|
975
|
+
committerEmail:i,committerName:o,source:"configured"}}return null}function Af(e={}){let t=Y(e),r=Te(t.name,t.displayName,
|
|
976
976
|
t.login,t.username),n=Te(t.email,t.publicEmail,t.verifiedEmail);return!r||!n?null:{authorEmail:n,authorName:r,committerEmail:n,
|
|
977
|
-
committerName:r,source:"github"}}function
|
|
977
|
+
committerName:r,source:"github"}}function Of({workspace:e="",userKey:t=""}={}){let r=Nc(t,"user"),n=Nc(e,"local");return{
|
|
978
978
|
authorEmail:`${r}@${n}${Pc}`,authorName:`${r} via Vibe64`,committerEmail:`vibe64@${n}${Pc}`,committerName:"Vibe64",source:"\
|
|
979
|
-
fallback"}}function Mo(e=""){let t=P(e);return t&&
|
|
979
|
+
fallback"}}function Mo(e=""){let t=P(e);return t&&Kr.isAbsolute(t)?t:""}function Cc(e=""){let t=Mo(e);try{return t&&jc(t).
|
|
980
980
|
isDirectory()?t:""}catch{return""}}async function kc(e=""){let t=Mo(e);return t&&await Lc(t).then(r=>r.isDirectory(),()=>!1)?
|
|
981
981
|
t:""}function Uc(e=""){let t={};for(let r of String(e||"").split(`
|
|
982
982
|
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=P(n[2]))}return t}function Vc(e,t){return{
|
|
983
|
-
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:
|
|
983
|
+
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:Sf}}function xc(e,t){let r=bf("git",Mc,{...Vc(e,t),encoding:"\
|
|
984
984
|
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?Uc(r.stdout):
|
|
985
|
-
null}}function $c(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=
|
|
985
|
+
null}}function $c(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=Ef("git",Mc,Vc(e,t));s.stdout.setEncoding(
|
|
986
986
|
"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,
|
|
987
987
|
values:null}:{transient:!1,values:a===0||a===1?Uc(n):null}))})}function Gc(e=null){return!e?.name||!e?.email?null:{authorEmail:e.
|
|
988
988
|
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function Bc(e={}){return{...e,PATH:process.
|
|
989
989
|
env.PATH||e.PATH}}function Hc(e={}){if(Object.hasOwn(e,"GIT_CONFIG_GLOBAL"))return[String(e.GIT_CONFIG_GLOBAL)];let t=Mo(
|
|
990
|
-
e.HOME),r=P(e.XDG_CONFIG_HOME)||(t?
|
|
991
|
-
g"):""].filter(Boolean)}async function
|
|
992
|
-
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function
|
|
990
|
+
e.HOME),r=P(e.XDG_CONFIG_HOME)||(t?Kr.join(t,".config"):"");return[r?Kr.join(r,"git","config"):"",t?Kr.join(t,".gitconfi\
|
|
991
|
+
g"):""].filter(Boolean)}async function Rf(e={}){return(await Promise.all(Hc(e).map(r=>Lc(r).then(n=>`${n.ino}:${n.size}:${n.
|
|
992
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function Pf(e={}){return Hc(e).map(t=>{try{let r=jc(t);return`${r.ino}\
|
|
993
993
|
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}function zc(e,t,r){let n=Object.entries(r).sort(
|
|
994
|
-
([o],[i])=>o<i?-1:o>i?1:0);return
|
|
994
|
+
([o],[i])=>o<i?-1:o>i?1:0);return vf("sha256").update(JSON.stringify([e,t,n])).digest("hex")}async function Nf(e,t,r){let n=e?
|
|
995
995
|
await $c(e,r):null;if(n?.values)return n;let o=await $c(t,r);return{transient:!!(n?.transient||o.transient),values:o.values}}
|
|
996
|
-
function
|
|
996
|
+
function Cf(e,t,r){let n=e?xc(e,r):null;if(n?.values)return n;let o=xc(t,r);return{transient:!!(n?.transient||o.transient),
|
|
997
997
|
values:o.values}}function Fc(e,t,r){let n=We.get(e);if(n&&n.revision===t&&n.expiresAt>r)return n;for(let[o,i]of We)i.expiresAt<=
|
|
998
|
-
r&&We.delete(o);return null}async function
|
|
999
|
-
read).values;let a={expiresAt:i+Dc,read:
|
|
1000
|
-
a&&We.delete(n):a.values=c.values,c.values}function
|
|
1001
|
-
hasOwn(s,"values"))return s.values;let a=
|
|
1002
|
-
revision:o,values:a.values}),a.values}async function
|
|
1003
|
-
let[r,n]=await Promise.all([kc(e),kc(t.HOME)]);return Gc(await
|
|
1004
|
-
typeof t!="object"?null:Gc(
|
|
998
|
+
r&&We.delete(o);return null}async function kf(e,t,r){let n=zc(e,t,r),o=await Rf(r),i=Date.now(),s=Fc(n,o,i);if(s)return(await s.
|
|
999
|
+
read).values;let a={expiresAt:i+Dc,read:Nf(e,t,r),revision:o};We.set(n,a);let c=await a.read;return c.transient?We.get(n)===
|
|
1000
|
+
a&&We.delete(n):a.values=c.values,c.values}function xf(e,t,r){let n=zc(e,t,r),o=Pf(r),i=Date.now(),s=Fc(n,o,i);if(s&&Object.
|
|
1001
|
+
hasOwn(s,"values"))return s.values;let a=Cf(e,t,r);return a.transient||We.set(n,{expiresAt:i+Dc,read:Promise.resolve(a),
|
|
1002
|
+
revision:o,values:a.values}),a.values}async function $f({cwd:e="",env:t=null}={}){if(!t||typeof t!="object")return null;
|
|
1003
|
+
let[r,n]=await Promise.all([kc(e),kc(t.HOME)]);return Gc(await kf(r,n,Bc(t)))}function jf({cwd:e="",env:t=null}={}){return!t||
|
|
1004
|
+
typeof t!="object"?null:Gc(xf(Cc(e),Cc(t.HOME),Bc(t)))}function Lf(e={}){let t=Y(e),r=P(t.name),n=P(t.email);return!r||!n?
|
|
1005
1005
|
null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function qc({env:e,personGitIdentity:t=null,
|
|
1006
|
-
project:r={},session:n={}}){let o=Y(n.metadata);return
|
|
1007
|
-
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||
|
|
1008
|
-
let i=Y(n.metadata);return
|
|
1006
|
+
project:r={},session:n={}}){let o=Y(n.metadata);return If(r.gitIdentity,r.config?.git,n.gitIdentity,o.git_identity,{name:e.
|
|
1007
|
+
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||Lf(t)}function Wc({actor:e={},env:t,project:r={},session:n={},userKey:o=""}){
|
|
1008
|
+
let i=Y(n.metadata);return Af(r.githubUser||n.githubUser||i.github_user)||Of({workspace:Te(r.workspace,t.VIBE64_WORKSPACE,
|
|
1009
1009
|
t.VIBE64_RUNTIME_NAMESPACE),userKey:Te(o,e.user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.
|
|
1010
|
-
LOGNAME)})}async function
|
|
1010
|
+
LOGNAME)})}async function Mf(e){return qc(e)||await $f(e.gitConfig||{})||Wc(e)}function Df(e){return qc(e)||jf(e.gitConfig||
|
|
1011
1011
|
{})||Wc(e)}function Yc(e){return{[Je]:e.authorEmail,[Ye]:e.authorName,[Xe]:e.committerEmail,[Ke]:e.committerName}}async function Jc(e){
|
|
1012
|
-
return Yc(await
|
|
1013
|
-
ME",Je="GIT_AUTHOR_EMAIL",Ke="GIT_COMMITTER_NAME",Xe="GIT_COMMITTER_EMAIL",Pc=".users.vibe64.invalid",
|
|
1014
|
-
"--get-regexp","^user\\.(name|email)$"],Dc=3e4,
|
|
1012
|
+
return Yc(await Mf(e))}function Kc(e){return Yc(Df(e))}var Ye,Je,Ke,Xe,Pc,Sf,Mc,Dc,Tf,We,ht=g(()=>{q();Ye="GIT_AUTHOR_NA\
|
|
1013
|
+
ME",Je="GIT_AUTHOR_EMAIL",Ke="GIT_COMMITTER_NAME",Xe="GIT_COMMITTER_EMAIL",Pc=".users.vibe64.invalid",Sf=2e3,Mc=["config",
|
|
1014
|
+
"--get-regexp","^user\\.(name|email)$"],Dc=3e4,Tf=['git config --global user.name "Your Name"','git config --global user\
|
|
1015
1015
|
.email "you@example.com"'].join(`
|
|
1016
1016
|
`);We=new Map});import Do from"node:path";function X({root:e=""}={}){return C(e||he().runtimePackRoot)}function Vo(e=""){let t=X();return(t?
|
|
1017
1017
|
gt[P(e)]?.binDirs||[]:[]).map(n=>Do.join(t,n))}function Xc(){let e=X();return e?[Do.join(e,"guard-bin")]:[]}function Go(){
|
|
1018
|
-
let e=X();return e?[Do.join(e,"policy-bin")]:[]}function
|
|
1019
|
-
Uo,
|
|
1018
|
+
let e=X();return e?[Do.join(e,"policy-bin")]:[]}function Uf(e=""){let t=P(e);return[...gt[t]?.managedCommands||[]]}var gt,
|
|
1019
|
+
Uo,iT,ge=g(()=>{q();Pe();gt=Object.freeze({awsebcli:{binDirs:["awsebcli/bin"],managedCommands:["eb"]},bubblewrap:{binDirs:[
|
|
1020
1020
|
"bubblewrap/bin"],managedCommands:[]},bun:{binDirs:["bun/bin"],dependencyFiles:["package.json","bun.lock","bun.lockb","p\
|
|
1021
1021
|
ackage-lock.json"],managedCommands:["bun"]},composer:{binDirs:["composer/bin"],dependencyFiles:["composer.json","compose\
|
|
1022
1022
|
r.lock"],managedCommands:["composer"]},cpp:{binDirs:["cpp/bin"],dependencyFiles:["CMakeLists.txt","vcpkg.json","vcpkg-co\
|
|
@@ -1046,272 +1046,272 @@ in"],managedCommands:["php"]},playwright:{binDirs:["playwright/bin"],identityPat
|
|
|
1046
1046
|
/browsers"],managedCommands:["playwright"]},postgresql:{binDirs:["postgresql/bin"],managedCommands:["initdb","pg_ctl","p\
|
|
1047
1047
|
g_isready","postgres","psql"]},ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:[
|
|
1048
1048
|
"sqlite3"]}}),Uo=Object.freeze(["operator-clis","node26","git","gh","mysql","mariadb","postgresql","sqlite","ripgrep","b\
|
|
1049
|
-
ubblewrap","bun","php","composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);
|
|
1050
|
-
Object.freeze({runtimePackManagedCommands:
|
|
1051
|
-
if(!t)return"";let r=Qc.join(t,Zc,
|
|
1052
|
-
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!
|
|
1049
|
+
ubblewrap","bun","php","composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);iT=
|
|
1050
|
+
Object.freeze({runtimePackManagedCommands:Uf})});import{readFileSync as Vf}from"node:fs";import Qc from"node:path";function zf({runtimePackRoot:e=""}={}){let t=X({root:e});
|
|
1051
|
+
if(!t)return"";let r=Qc.join(t,Zc,Bf),n;try{n=Vf(r,"utf8")}catch(i){if(i?.code==="ENOENT")return"";throw i}let o=n.split(
|
|
1052
|
+
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!Hf.test(o[0]))throw new Error(
|
|
1053
1053
|
`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function eu({runtimePackRoot:e=""}={}){let t=X({root:e}),
|
|
1054
|
-
r=C(he().sharedCacheRoot),n=
|
|
1055
|
-
{[Ho]:n}:{}}}var
|
|
1056
|
-
ATH",Bo="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",Ho="VIBE64_PLAYWRIGHT_VERSION",Zc="playwright",
|
|
1057
|
-
|
|
1058
|
-
llers cannot provide execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function
|
|
1059
|
-
let{envPolicy:r="session"}=t,n=ue(e);wt(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!
|
|
1060
|
-
"deployment"?o:{...o,...
|
|
1054
|
+
r=C(he().sharedCacheRoot),n=zf({runtimePackRoot:t});return{...r?{[Xr]:r}:{},...t?{[Ft]:Qc.join(t,Zc,Gf),[Bo]:"1"}:{},...n?
|
|
1055
|
+
{[Ho]:n}:{}}}var Xr,Ft,Bo,Ho,Zc,Gf,Bf,Hf,qt=g(()=>{q();Pe();ge();Xr="VIBE64_SHARED_CACHE_ROOT",Ft="PLAYWRIGHT_BROWSERS_P\
|
|
1056
|
+
ATH",Bo="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",Ho="VIBE64_PLAYWRIGHT_VERSION",Zc="playwright",Gf="browsers",Bf="runtime.env",
|
|
1057
|
+
Hf=/^\d+\.\d+\.\d+$/u});function wt(e={}){for(let t of Object.keys(ue(e)))if(Ff.has(t)||t.startsWith("XDG_")){let r=new Error(`Vibe64 command ca\
|
|
1058
|
+
llers cannot provide execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function Qr(e={},t={}){
|
|
1059
|
+
let{envPolicy:r="session"}=t,n=ue(e);wt(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!qf.has(i)));return r===
|
|
1060
|
+
"deployment"?o:{...o,...Yr(n)}}var Ff,qf,Zr=g(()=>{q();Jr();ht();qt();Ff=new Set(["HOME","LOGNAME","PATH","TMPDIR","USER",
|
|
1061
1061
|
"VIBE64_EXECUTION_ID","VIBE64_MANAGED_EXECUTION_REQUIRED","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIM\
|
|
1062
|
-
E_DIR"]),
|
|
1062
|
+
E_DIR"]),qf=new Set([...zt,Je,Ye,Xe,Ke,Ft,Bo,Ho,Xr])});function Wf(e=""){let t=C(e);return t==="/home"||t.startsWith("/home/")}function tu({actor:e={},request:t={}}={}){let r=t.
|
|
1063
1063
|
credentialHome||{},n=C(r.home);if(!n)return{};let o=C(e.user?.home);if(e.requiresRealUser&&o&&n!==o){let a=new Error("Co\
|
|
1064
1064
|
mmand credential home must match the resolved real-user actor home.");throw a.code="vibe64_command_credential_home_actor\
|
|
1065
|
-
_mismatch",a}if(!e.requiresRealUser&&
|
|
1065
|
+
_mismatch",a}if(!e.requiresRealUser&&Wf(n)&&o&&!Re(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
1066
1066
|
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=P(r.username||e.user?.username);
|
|
1067
|
-
return{...
|
|
1067
|
+
return{...Dt({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n}),...C(r.cacheRoot)?{XDG_CACHE_HOME:C(r.cacheRoot)}:{},...C(r.
|
|
1068
1068
|
configRoot)?{XDG_CONFIG_HOME:C(r.configRoot)}:{},...C(r.dataRoot)?{XDG_DATA_HOME:C(r.dataRoot)}:{},...C(r.stateRoot)?{XDG_STATE_HOME:C(
|
|
1069
|
-
r.stateRoot)}:{}}}var ru=g(()=>{pt();q()});import nu from"node:path";function
|
|
1070
|
-
isAbsolute(o))continue;let i=nu.resolve(o);t.has(i)||(t.add(i),r.push(i))}return r}function
|
|
1069
|
+
r.stateRoot)}:{}}}var ru=g(()=>{pt();q()});import nu from"node:path";function Xf(e=[]){let t=new Set,r=[];for(let n of Array.isArray(e)?e:[e]){let o=P(n);if(!o||!nu.
|
|
1070
|
+
isAbsolute(o))continue;let i=nu.resolve(o);t.has(i)||(t.add(i),r.push(i))}return r}function Wt(e={},t=[]){let r={...e&&typeof e==
|
|
1071
1071
|
"object"&&!Array.isArray(e)?e:{}},n=Number.parseInt(String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?
|
|
1072
1072
|
n:0;for(let i of Array.isArray(t)?t:[]){let s=P(i?.key);s&&(r[`GIT_CONFIG_KEY_${o}`]=s,r[`GIT_CONFIG_VALUE_${o}`]=String(
|
|
1073
|
-
i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),r}function ou(e=[]){return
|
|
1074
|
-
function iu(e={},t=[]){return
|
|
1075
|
-
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function Fo(e={}){return
|
|
1076
|
-
return
|
|
1077
|
-
var
|
|
1078
|
-
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),
|
|
1079
|
-
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),
|
|
1073
|
+
i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),r}function ou(e=[]){return Xf(e).map(t=>({key:"safe.directory",value:t}))}
|
|
1074
|
+
function iu(e={},t=[]){return Wt(e,ou(t))}function Qf(e=[]){return ou(e).flatMap(t=>["-c",`${t.key}=${t.value}`])}function zo(){
|
|
1075
|
+
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function Fo(e={}){return Wt(e,Yf)}function Zf(e={}){
|
|
1076
|
+
return Wt(e,Jf)}function eh(e={}){return Wt(e,Kf)}function su(e={}){return Zf(Fo(e))}function au(e={}){return eh(Fo(e))}
|
|
1077
|
+
var Yf,Jf,Kf,ST,cu=g(()=>{q();Yf=Object.freeze([{key:"url.https://github.com/.insteadOf",value:"git@github.com:"},{key:"\
|
|
1078
|
+
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),Jf=Object.freeze([{key:"credential.https://github.co\
|
|
1079
|
+
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),Kf=Object.freeze([{key:"credential.https://github.com.helper",
|
|
1080
1080
|
value:`!f() { case "$1" in get) printf '%s\\n' username=x-access-token "password=\${VIBE64_GIT_AUTH_TOKEN}" ;; esac; }; f`}]);
|
|
1081
|
-
|
|
1082
|
-
code="vibe64_command_git_auth_token_required",t}return au({...zo(),GIT_TERMINAL_PROMPT:"0",[
|
|
1083
|
-
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=
|
|
1084
|
-
github-https"||e.purpose==="github")&&(r=su({...t,...zo()})),iu(r,e.gitSafeDirectories||[])}var
|
|
1081
|
+
ST=Object.freeze({applyGitConfigEntriesToEnv:Wt,githubSshToHttpsGitEnv:Fo,gitSafeDirectoryArgs:Qf})});function rh(e={}){if(!e.gitAuthToken){let t=new Error("Token-backed GitHub transport requires a gitAuthToken.");throw t.
|
|
1082
|
+
code="vibe64_command_git_auth_token_required",t}return au({...zo(),GIT_TERMINAL_PROMPT:"0",[th]:e.gitAuthToken})}function uu({
|
|
1083
|
+
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=rh(e):(e.gitTransport==="\
|
|
1084
|
+
github-https"||e.purpose==="github")&&(r=su({...t,...zo()})),iu(r,e.gitSafeDirectories||[])}var th,lu=g(()=>{cu();th="VI\
|
|
1085
1085
|
BE64_GIT_AUTH_TOKEN"});import du from"node:path";function pu({env:e={}}={}){return X()?C(e[qo])||(C(e.HOME)?du.join(C(e.HOME),".local"):""):""}
|
|
1086
1086
|
function mu(e={}){let t=pu(e);return t?{[qo]:t}:{}}function fu(e={}){let t=pu(e);return t?[du.join(t,"bin")]:[]}var qo,Wo=g(
|
|
1087
|
-
()=>{q();ge();qo="NPM_CONFIG_PREFIX"});import{existsSync as
|
|
1088
|
-
function
|
|
1089
|
-
t)}catch{return!1}})}function hu(e="",t=/^$/u){try{return
|
|
1090
|
-
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function
|
|
1087
|
+
()=>{q();ge();qo="NPM_CONFIG_PREFIX"});import{existsSync as nh,readdirSync as oh}from"node:fs";import ih from"node:os";import Ne from"node:path";import en from"node:process";
|
|
1088
|
+
function Yt(e=""){return String(e||"").split(":").map(P).filter(Boolean)}function gu(e=[]){return e.filter(t=>{try{return nh(
|
|
1089
|
+
t)}catch{return!1}})}function hu(e="",t=/^$/u){try{return oh(e).filter(r=>t.test(r)).sort((r,n)=>Number(/\d+/u.exec(n)?.[0]||
|
|
1090
|
+
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function sh(e){if(X())return[];let t=String(e.HOME||ih.homedir()||"");
|
|
1091
1091
|
if(!Ne.isAbsolute(t))return[];let r=Ne.isAbsolute(String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:Ne.join(t,".local/share"),
|
|
1092
1092
|
n=Ne.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:Ne.join(r,"mise");return gu([Ne.join(t,".local/bin"),Ne.join(
|
|
1093
|
-
n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",".bun/bin"].map(o=>Ne.join(t,o))])}function
|
|
1094
|
-
let e=["/opt/homebrew","/usr/local"];return[...
|
|
1095
|
-
[...hu("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`/usr/lib/postgresql/${t}/bin`),...
|
|
1093
|
+
n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",".bun/bin"].map(o=>Ne.join(t,o))])}function ah(){if(X())return[];
|
|
1094
|
+
let e=["/opt/homebrew","/usr/local"];return[...Yt(en.env.PATH),...en.platform==="darwin"?["/opt/homebrew/bin"]:[],...gu(
|
|
1095
|
+
[...hu("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`/usr/lib/postgresql/${t}/bin`),...en.platform==="darwin"?e.flatMap(
|
|
1096
1096
|
t=>[...hu(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function wu({
|
|
1097
|
-
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return ze([...
|
|
1098
|
-
i=>Vo(i)),...Xc(),...
|
|
1099
|
-
|
|
1100
|
-
e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!
|
|
1097
|
+
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return ze([...Yt(o.join(":")),...Go(),...n.flatMap(
|
|
1098
|
+
i=>Vo(i)),...Xc(),...Yt(t||(r?"":e.PATH)),...sh(en.env),...Yt(r),...ah(),...Yt(Jt)]).join(":")}var Jt,tn=g(()=>{q();ge();
|
|
1099
|
+
Jt="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"});import ch from"node:path";function dh(e={}){return Object.fromEntries(Object.entries(e&&typeof e=="object"&&!Array.isArray(
|
|
1100
|
+
e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!uh.has(t)&&!lh.has(t)&&!t.startsWith("GIT_")&&
|
|
1101
1101
|
!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function Yo(e={}){return e.envPolicy==="deployment"?[e.project?.deploymentEnv,
|
|
1102
|
-
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function
|
|
1103
|
-
envPolicy==="deployment"?(wt(r),{...t,...ue(r)}):{...t,...
|
|
1102
|
+
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function ph(e={}){return Yo(e).reduce((t,r)=>e.
|
|
1103
|
+
envPolicy==="deployment"?(wt(r),{...t,...ue(r)}):{...t,...Qr(r,e)},{})}function mh(e={},t={}){return t.envPolicy==="depl\
|
|
1104
1104
|
oyment"?[]:t.envPolicy==="project"?Yo(t):[e,...Yo(t),t.project?.databaseEnv,t.session?.databaseEnv]}function yu({actor:e={},
|
|
1105
|
-
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=eu(),s=
|
|
1106
|
-
t.XDG_RUNTIME_DIR||"").trim(),c={...
|
|
1107
|
-
...
|
|
1105
|
+
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=eu(),s=Qr(n.env,n),a=String(
|
|
1106
|
+
t.XDG_RUNTIME_DIR||"").trim(),c={...Dt(e.user,dh(t)),...ft(e)&&ch.isAbsolute(a)?{XDG_RUNTIME_DIR:a}:{},...Yr(...mh(t,n)),
|
|
1107
|
+
...ph(n),...uu({actor:e,request:n}),...s,...tu({actor:e,request:n}),...i},u={...c,...mu({env:c}),VIBE64_DECLARED_RUNTIMES:o},
|
|
1108
1108
|
l=wu({env:u,existingPath:[...fu({env:u}),u.PATH].filter(Boolean).join(":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.
|
|
1109
1109
|
shimDirs||[]});return{...u,PATH:l,...X()?{}:{VIBE64_TOOL_PATH:l}}}function _u({actor:e={},baseEnv:t,request:r={}},n){return{
|
|
1110
1110
|
actor:e,env:t,gitConfig:{cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.
|
|
1111
1111
|
userKey}}async function Eu(e){let t=yu(e);return{...t,...await Jc(_u(e,t))}}function Jo(e){let t=yu(e);return{...t,...e.
|
|
1112
|
-
resolvedGitIdentityEnv||Kc(_u(e,t))}}var
|
|
1113
|
-
q();
|
|
1114
|
-
_RUNTIME_DIR"]),
|
|
1115
|
-
found.",ok:!1}}function Ce(e=""){return String(e||"default").trim()||"default"}function
|
|
1116
|
-
for(let n=0;n<
|
|
1117
|
-
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>bu&&(t=t.slice(t.length-bu)),t}function
|
|
1118
|
-
"running"||e.status==="closing"}function Xo(e={}){return
|
|
1119
|
-
!0}catch{return!1}}function
|
|
1120
|
-
let{outputLimit:r=0}=t,n=String(e||""),o=
|
|
1121
|
-
o),outputTruncated:!0}}function ke(e,t={}){let r=
|
|
1112
|
+
resolvedGitIdentityEnv||Kc(_u(e,t))}}var uh,lh,Ko=g(()=>{Wr();pt();Jr();Zr();Jr();ru();lu();ht();ht();qt();Wo();tn();ge();
|
|
1113
|
+
q();uh=new Set([...zt,Je,Ye,Xe,Ke,"HOME","LOGNAME","PATH","USER","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG\
|
|
1114
|
+
_RUNTIME_DIR"]),lh=new Set(["NODE_ENV"])});import{Buffer as fh}from"node:buffer";function vu(){return{code:"terminal_session_not_found",error:"Terminal session not\
|
|
1115
|
+
found.",ok:!1}}function Ce(e=""){return String(e||"default").trim()||"default"}function on(e){let t=String(e||""),r=t.length;
|
|
1116
|
+
for(let n=0;n<hh&&(r=t.lastIndexOf(`
|
|
1117
|
+
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>bu&&(t=t.slice(t.length-bu)),t}function Kt(e={}){return e.status===
|
|
1118
|
+
"running"||e.status==="closing"}function Xo(e={}){return Kt(e)||e.status==="exited"}function Tu(e,t){try{return t(ke(e))===
|
|
1119
|
+
!0}catch{return!1}}function wh(e=0){let t=Math.floor(Number(e||0));return Number.isFinite(t)&&t>0?t:0}function yh(e="",t={}){
|
|
1120
|
+
let{outputLimit:r=0}=t,n=String(e||""),o=wh(r);return!o||n.length<=o?{output:n,outputTruncated:!1}:{output:n.slice(n.length-
|
|
1121
|
+
o),outputTruncated:!0}}function ke(e,t={}){let r=yh(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||rn,
|
|
1122
1122
|
createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exitCode,inputVersion:e.inputVersion||0,lastInputAt:e.
|
|
1123
1123
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
1124
1124
|
metadata:e.metadata||{},output:r.output,outputTruncated:r.outputTruncated,outputVersion:e.outputVersion||0,rows:e.rows||
|
|
1125
|
-
|
|
1126
|
-
e));return!Number.isFinite(t)||t<0?0:Math.min(t,
|
|
1127
|
-
e.lastInputAt),dt(e.lastOutputAt),dt(e.createdAt))}function Qo(e={},t=Date.now()){if(e.subscribers?.size)return 0;let r=
|
|
1128
|
-
e);return r>0?Math.max(0,Number(t)-r):0}function
|
|
1129
|
-
e.detachedCleanupTimer=null)}var bu,
|
|
1130
|
-
60*1e3,
|
|
1125
|
+
nn,status:e.status}}function Iu(e=""){return fh.byteLength(String(e||""),"utf8")}function Xt(e=0){let t=Math.floor(Number(
|
|
1126
|
+
e));return!Number.isFinite(t)||t<0?0:Math.min(t,gh)}function _h(e={}){return Math.max(dt(e.lastSubscriberDetachedAt),dt(
|
|
1127
|
+
e.lastInputAt),dt(e.lastOutputAt),dt(e.createdAt))}function Qo(e={},t=Date.now()){if(e.subscribers?.size)return 0;let r=_h(
|
|
1128
|
+
e);return r>0?Math.max(0,Number(t)-r):0}function sn(e={}){e.detachedCleanupTimer&&(clearTimeout(e.detachedCleanupTimer),
|
|
1129
|
+
e.detachedCleanupTimer=null)}var bu,hh,rn,nn,rI,gh,nI,Su,yt=g(()=>{q();bu=256*1024,hh=300,rn=100,nn=28,rI=600*1e3,gh=1440*
|
|
1130
|
+
60*1e3,nI=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "});Su=new Map});function Au(e,t={}){return!e||!t||typeof t!="object"||Array.isArray(t)?ke(e):(e.metadata={...e.metadata||{},...t},we(e,{
|
|
1131
1131
|
metadata:e.metadata,type:"metadata"}),ke(e))}function Ou(e,t=""){let r=Iu(t);r<1||(e.outputVersion=Number(e.outputVersion||
|
|
1132
1132
|
0)+1,e.lastOutputAt=new Date().toISOString(),e.lastOutputBytes=r)}function we(e,t){if(e?.subscribers?.size)for(let r of[
|
|
1133
|
-
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function
|
|
1134
|
-
e||"Terminal PTY error.");return{code:t,message:r}}function Ru(e,t){if(!e)return;let r=
|
|
1133
|
+
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function Eh(e){let t=String(e?.code||""),r=String(e?.message||
|
|
1134
|
+
e||"Terminal PTY error.");return{code:t,message:r}}function Ru(e,t){if(!e)return;let r=Eh(t);e.lastWriteErrorAt=new Date().
|
|
1135
1135
|
toISOString(),e.lastWriteErrorCode=r.code,e.lastWriteError=r.message,console.warn("Vibe64 terminal PTY write error.",{code:r.
|
|
1136
1136
|
code,id:e.id,metadata:e.metadata||{},message:r.message,namespace:e.namespace||""}),we(e,{code:r.code,error:r.message,type:"\
|
|
1137
1137
|
error"})}function Pu(e){let t=e?.terminal?._writeStream;!t||typeof t.on!="function"||t.on("error",r=>{Ru(e,r)})}function Nu(e,t,r=t){
|
|
1138
1138
|
let n=`\r
|
|
1139
1139
|
[studio] ${r}\r
|
|
1140
|
-
`;e.closeError=t,e.output=
|
|
1140
|
+
`;e.closeError=t,e.output=on(`${e.output}${n}`),we(e,{chunk:n,type:"output"}),we(e,{error:t,type:"error"})}async function Cu(e,{
|
|
1141
1141
|
code:t,flag:r,hook:n,label:o,payload:i}){if(e[r])return null;e[r]=!0;try{return await e[n](i),null}catch(s){let a=String(
|
|
1142
1142
|
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,Nu(e,a,`${o}: ${a}`),c}}function Qe(e,t){let r=`${String(
|
|
1143
1143
|
t?.code||"terminal_cleanup_failed")}:${String(t?.message||"")}`;return e.reportedLifecycleFailures||=new Set,e.reportedLifecycleFailures.
|
|
1144
|
-
has(r)||(e.reportedLifecycleFailures.add(r),Nu(e,String(t?.message||t||"Terminal cleanup failed."))),t}function
|
|
1144
|
+
has(r)||(e.reportedLifecycleFailures.add(r),Nu(e,String(t?.message||t||"Terminal cleanup failed."))),t}function an(e,t=[]){
|
|
1145
1145
|
let r=new AggregateError(t,`Terminal session could not close cleanly: ${e.id}`);return r.code=t.some(n=>String(n?.code||
|
|
1146
|
-
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function
|
|
1146
|
+
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function bh(e,t){
|
|
1147
1147
|
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>Cu(e,{code:"terminal_stop_hook_failed",flag:"\
|
|
1148
1148
|
stopHookStarted",hook:"onStop",label:"Terminal stop failed",payload:{id:e.id,output:e.output,reason:t,status:e.status}}))),
|
|
1149
1149
|
e.stopHookCompletion}function Zo(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>Cu(
|
|
1150
1150
|
e,{code:"terminal_close_hook_failed",flag:"closeHookStarted",hook:"onClose",label:"Terminal finalization failed",payload:{
|
|
1151
1151
|
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function ei(e){e.status!==
|
|
1152
1152
|
"exited"&&(e.status="exited",we(e,{closeError:e.closeError||"",exitCode:e.exitCode,status:e.status,type:"status"}))}function ti(e){
|
|
1153
|
-
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await
|
|
1153
|
+
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await Br(e.terminal.pid)){
|
|
1154
1154
|
let t=new Error(`Terminal execution scope did not become empty: ${e.id}`);throw t.code="terminal_execution_drain_failed",
|
|
1155
1155
|
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function ku(e){try{await e.scopeDrainCompletion}catch(t){
|
|
1156
1156
|
Qe(e,t)}try{await Promise.all([Zo(e,e.stopReason||"exit"),e.stopHookCompletion])}catch(t){Qe(e,t)}ei(e)}async function ri(e,t="\
|
|
1157
1157
|
stop"){if(!e||e.processExited)return{failures:[]};e.stopReason||=String(t||"stop"),e.status==="running"&&(e.status="clos\
|
|
1158
|
-
ing",we(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(
|
|
1158
|
+
ing",we(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(bh(e,e.stopReason),!e.processExited&&!e.killStarted){
|
|
1159
1159
|
e.killStarted=!0;try{e.terminal.kill()}catch(n){e.killStarted=!1;let o=n instanceof Error?n:new Error(String(n||"Termina\
|
|
1160
1160
|
l process could not be killed."));o.code||="terminal_kill_failed",r.push(Qe(e,o))}}try{await ti(e)}catch(n){r.push(Qe(e,
|
|
1161
|
-
n))}return{failures:r}}var ni=g(()=>{
|
|
1162
|
-
ok:!1}:null}var
|
|
1163
|
-
e.delete(r);let n=Ce(t);e.size<1&&Ze.get(n)===e&&Ze.delete(n)}function
|
|
1164
|
-
filter(r=>r.startsWith(t))}function
|
|
1165
|
-
o=[];for(let i of n){let s=_t(i);for(let a of s.values())r&&!
|
|
1166
|
-
()=>{yt();Ze=new Map});function
|
|
1167
|
-
let n=Math.max(0,r-Qo(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,
|
|
1161
|
+
n))}return{failures:r}}var ni=g(()=>{Vt();yt()});function Sh(e="default"){return vh.get(Ce(e))||null}function xu(e="default"){let t=Sh(e);return t?{code:t.code,error:t.error,
|
|
1162
|
+
ok:!1}:null}var vh,$u=g(()=>{yt();vh=new Map});function _t(e){return Ze.get(Ce(e))||Su}function ju(e){let t=Ce(e);return Ze.has(t)||Ze.set(t,new Map),Ze.get(t)}function Lu(e,t,r){
|
|
1163
|
+
e.delete(r);let n=Ce(t);e.size<1&&Ze.get(n)===e&&Ze.delete(n)}function Th(e=""){let t=String(e||"");return[...Ze.keys()].
|
|
1164
|
+
filter(r=>r.startsWith(t))}function cn({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){let n=e?[Ce(e)]:Th(t),
|
|
1165
|
+
o=[];for(let i of n){let s=_t(i);for(let a of s.values())r&&!Kt(a)||o.push({namespace:i,session:a})}return o}var Ze,oi=g(
|
|
1166
|
+
()=>{yt();Ze=new Map});function un(e={},t="default"){if(sn(e),!Xo(e)||e.subscribers?.size)return;let r=Xt(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
1167
|
+
let n=Math.max(0,r-Qo(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,Ih({namespace:t})},n)}async function ii(e,t={}){
|
|
1168
1168
|
let{namespace:r="default"}=t,n=_t(r),o=n.get(e);if(!o)return{ok:!0,closed:!1};if(o.closePromise)return o.closePromise;let i=(async()=>{
|
|
1169
|
-
let s=[];if(
|
|
1169
|
+
let s=[];if(sn(o),!o.processExited){let u=await ri(o,"close");if(u.failures.length)throw an(o,u.failures)}try{await o.exitCompletion}catch(u){
|
|
1170
1170
|
s.push(Qe(o,u))}try{await o.scopeDrainCompletion}catch(u){s.push(Qe(o,u))}let c=(await Promise.all([o.stopHookCompletion,
|
|
1171
|
-
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&ei(o),s.length>0)throw
|
|
1171
|
+
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&ei(o),s.length>0)throw an(o,[...s,...c]);return Lu(n,r,e),{
|
|
1172
1172
|
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(u=>String(u?.message||u))}:{}}})();o.closePromise=i;try{return await i}finally{
|
|
1173
|
-
o.closePromise===i&&(o.closePromise=null)}}async function
|
|
1174
|
-
if(!Xo(r)||r.subscribers?.size)continue;let n=
|
|
1175
|
-
r.id,{namespace:t})}}}var si=g(()=>{q();ni();oi();yt()});import
|
|
1176
|
-
filter:e,namespacePrefix:t}){return
|
|
1173
|
+
o.closePromise===i&&(o.closePromise=null)}}async function Ih({namespace:e}){for(let{namespace:t,session:r}of cn({namespace:e})){
|
|
1174
|
+
if(!Xo(r)||r.subscribers?.size)continue;let n=Xt(r.detachedIdleTimeoutMs);if(!(n<1)){if(Qo(r)<n){un(r,t);continue}await ii(
|
|
1175
|
+
r.id,{namespace:t})}}}var si=g(()=>{q();ni();oi();yt()});import Oh from"node:crypto";import{createRequire as Rh}from"node:module";function ai(){}function Ph(){return!0}function Ch({
|
|
1176
|
+
filter:e,namespacePrefix:t}){return cn({namespacePrefix:t,runningOnly:!0}).filter(r=>Tu(r.session,e)).length}function Mu({
|
|
1177
1177
|
args:e,command:t,commandPreview:r,cwd:n=process.cwd(),env:o={},maxRunning:i=0,metadata:s={},namespace:a="default",namespaceLimitPrefix:c="",
|
|
1178
|
-
runningLimitFilter:u=
|
|
1179
|
-
if(T)return T;let S=_t(a),d=
|
|
1180
|
-
if(_)return ke(_);let b=Number(i||0),v=c||a;if(b>0&&
|
|
1178
|
+
runningLimitFilter:u=Ph,onClose:l=ai,onOutput:m=ai,onStop:f=ai,reuseRunning:h=!1,detachedIdleTimeoutMs:y=0}){let T=xu(a);
|
|
1179
|
+
if(T)return T;let S=_t(a),d=Oh.randomUUID(),p=typeof h=="function"?h:()=>!!h,_=h?[...S.values()].find(F=>Kt(F)&&p(F)):null;
|
|
1180
|
+
if(_)return ke(_);let b=Number(i||0),v=c||a;if(b>0&&Ch({filter:u,namespacePrefix:v})>=b)return{ok:!1,code:"terminal_limi\
|
|
1181
1181
|
t",error:`Terminal limit reached (${b}).`};let w=typeof o=="function"?o({id:d,namespace:a}):o,E=typeof e=="function"?e({
|
|
1182
1182
|
env:w,id:d,namespace:a}):e,A=typeof r=="function"?r({args:E,env:w,id:d,namespace:a}):r,I=typeof s=="function"?s({args:E,
|
|
1183
|
-
env:w,id:d,namespace:a}):s,O=
|
|
1184
|
-
F=>{U=F}),k={id:d,closeHookCompletion:null,closePromise:null,commandPreview:A,cols:
|
|
1185
|
-
cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:
|
|
1183
|
+
env:w,id:d,namespace:a}):s,O=Nh("node-pty").spawn(t,E,{cols:rn,cwd:n,env:Y(w),name:"xterm-color",rows:nn}),U,x=new Promise(
|
|
1184
|
+
F=>{U=F}),k={id:d,closeHookCompletion:null,closePromise:null,commandPreview:A,cols:rn,createdAt:new Date().toISOString(),
|
|
1185
|
+
cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:Xt(y),exitCompletion:x,exitCode:null,lastSubscriberAttachedAt:"",lastSubscriberDetachedAt:new Date().
|
|
1186
1186
|
toISOString(),metadata:I&&typeof I=="object"&&!Array.isArray(I)?I:{},onClose:l,onStop:f,inputVersion:0,lastInputAt:"",lastInputBytes:0,
|
|
1187
1187
|
lastOutputAt:"",lastOutputBytes:0,lastWriteError:"",lastWriteErrorAt:"",lastWriteErrorCode:"",output:"",outputVersion:0,
|
|
1188
|
-
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:U,rows:
|
|
1189
|
-
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:O};return Pu(k),O.onData(F=>{Ou(k,F),k.output=
|
|
1188
|
+
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:U,rows:nn,status:"running",stopHookCompletion:null,
|
|
1189
|
+
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:O};return Pu(k),O.onData(F=>{Ou(k,F),k.output=on(k.output+
|
|
1190
1190
|
F),we(k,{chunk:F,lastOutputAt:k.lastOutputAt,outputVersion:k.outputVersion,type:"output"});try{m({chunk:F,output:k.output,
|
|
1191
1191
|
session:ke(k),updateMetadata(Z){return Au(k,Z)}})}catch(Z){let pe=String(Z?.message||Z||"Terminal output hook failed.");
|
|
1192
|
-
we(k,{error:pe,type:"error"})}
|
|
1192
|
+
we(k,{error:pe,type:"error"})}un(k,a)}),O.onExit(({exitCode:F})=>{k.processExited=!0,k.exitCode=F,k.status="closing",ti(
|
|
1193
1193
|
k),we(k,{exitCode:F,status:k.status,type:"status"}),Zo(k,k.stopReason||"exit"),k.resolveExitCompletion(),ku(k)}),ju(a).set(
|
|
1194
|
-
d,k),
|
|
1195
|
-
ke(i,{outputLimit:n}):vu()}var
|
|
1196
|
-
execution/src/server/engines/terminalSessions.js",import.meta.url).href;
|
|
1197
|
-
function
|
|
1194
|
+
d,k),un(k,a),kh(d,{namespace:a})}function kh(e,t={}){let{namespace:r="default",outputLimit:n=0}=t,i=_t(r).get(e);return i?
|
|
1195
|
+
ke(i,{outputLimit:n}):vu()}var Ah,Nh,Du=g(()=>{q();yt();ni();$u();si();oi();Ah=new URL("./../node_modules/@local/vibe64-\
|
|
1196
|
+
execution/src/server/engines/terminalSessions.js",import.meta.url).href;Nh=Rh(Ah)});import{randomUUID as xh}from"node:crypto";import{mkdirSync as $h,writeFileSync as jh}from"node:fs";import ci from"node:path";
|
|
1197
|
+
function Lh(){}function Mh(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root is required fo\
|
|
1198
1198
|
r real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=ci.join(ci.resolve(t),
|
|
1199
|
-
"exec-helper-payloads");return
|
|
1200
|
-
let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return
|
|
1201
|
-
l=typeof e.args=="function"?e.args(c):e.args,m=
|
|
1202
|
-
a,input:e.input,operation:
|
|
1203
|
-
`,{mode:384}),["-n",Oo(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||
|
|
1199
|
+
"exec-helper-payloads");return $h(r,{mode:448,recursive:!0}),ci.join(r,`${process.pid}-${Date.now()}-${xh()}.json`)}function Dh(e,t){
|
|
1200
|
+
let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return qr(r)?{args:(c={})=>{let u=Mh(s.helperPayloadRoot),
|
|
1201
|
+
l=typeof e.args=="function"?e.args(c):e.args,m=Hr({actor:r,args:l,command:e.command,cwd:n,env:typeof a=="function"?a(c):
|
|
1202
|
+
a,input:e.input,operation:Ht(e)});return jh(u,`${JSON.stringify(m)}
|
|
1203
|
+
`,{mode:384}),["-n",Oo(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||Jt}}:{args:e.args,
|
|
1204
1204
|
command:e.command,cwd:n,env:a}}async function Vu(e={},t={}){let{actor:r,cwd:n,env:o,resolveEnv:i}=t;try{let s=e.terminal||
|
|
1205
|
-
{},{onClose:a=
|
|
1205
|
+
{},{onClose:a=Lh}=s,c=e.execution?.id||"",u=Dh(e,{actor:r,cwd:n,env:o,resolveEnv:i}),l=Mu({args:u.args,command:u.command,
|
|
1206
1206
|
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
1207
1207
|
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async m=>{try{await a(m)}finally{
|
|
1208
1208
|
c&&Uu.set(c,{id:m.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
1209
1209
|
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&Uu.set(c,{id:l.id,namespace:s.namespace}),l?.ok===!0?{...l,
|
|
1210
1210
|
execution:e.execution}:l}catch(s){return K(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
1211
|
-
{execution:e.execution})}}var Uu,ui=g(()=>{Fe();
|
|
1212
|
-
resolveLinks:n=!0}=t,o=
|
|
1211
|
+
{execution:e.execution})}}var Uu,ui=g(()=>{Fe();tn();Du();si();zr();Wr();Uu=new Map});import{realpathSync as Gu}from"node:fs";function Uh(e=""){return C(e||process.cwd())}function Bu(e="",t={}){let{allowedRoots:r=[],
|
|
1212
|
+
resolveLinks:n=!0}=t,o=Uh(e),i=(Array.isArray(r)?r:[r]).map(C).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>Re(
|
|
1213
1213
|
c,o));if(s.length>0){if(!n)return o;let c=Gu(o);if(s.some(u=>Re(Gu(u),c)))return c}let a=new Error("Vibe64 command cwd i\
|
|
1214
|
-
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var Hu=g(()=>{q()});import{randomUUID as
|
|
1214
|
+
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var Hu=g(()=>{q()});import{randomUUID as Vh}from"node:crypto";function oe(e="",t="vibe64_command_request_invalid"){let r=new Error(e||"Inval\
|
|
1215
1215
|
id Vibe64 command request.");return r.code=t,r}function xe(e="",t=[],r="",n="value"){let o=P(e)||r;if(!t.includes(o))throw oe(
|
|
1216
|
-
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function
|
|
1216
|
+
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function Qh(e=[],t={}){let{
|
|
1217
1217
|
mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw oe("Function-valued command args are only supported for \
|
|
1218
1218
|
PTY commands.","vibe64_command_args_function_requires_pty");return e}return(Array.isArray(e)?e:[e]).map(n=>String(n??""))}
|
|
1219
|
-
function
|
|
1219
|
+
function Zh(e={},t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw oe("Function-valued command e\
|
|
1220
1220
|
nv is only supported for PTY commands.","vibe64_command_env_function_requires_pty");return{env:{},envFactory:e}}let n=ue(
|
|
1221
|
-
e);return wt(n),{env:n,envFactory:null}}function li(e=[]){return(Array.isArray(e)?e:[e]).map(C).filter(Boolean)}function
|
|
1221
|
+
e);return wt(n),{env:n,envFactory:null}}function li(e=[]){return(Array.isArray(e)?e:[e]).map(C).filter(Boolean)}function eg(e={}){
|
|
1222
1222
|
let t=Y(e);return{commandPreview:t.commandPreview,detachedIdleTimeoutMs:t.detachedIdleTimeoutMs,helperPayloadRoot:C(t.helperPayloadRoot),
|
|
1223
1223
|
maxRunning:t.maxRunning,metadata:t.metadata,namespace:P(t.namespace),namespaceLimitPrefix:P(t.namespaceLimitPrefix),onClose:t.
|
|
1224
|
-
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function
|
|
1224
|
+
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function tg(e={}){
|
|
1225
1225
|
let t=Y(e),r=C(t.home||t.toolHomeSource);return r?{cacheRoot:C(t.cacheRoot),configRoot:C(t.configRoot),dataRoot:C(t.dataRoot),
|
|
1226
1226
|
gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?Number(t.gid??t.hostGid):null,home:r,scope:P(t.scope),stateRoot:C(t.stateRoot),
|
|
1227
1227
|
uid:Number.isSafeInteger(Number(t.uid??t.hostUid))?Number(t.uid??t.hostUid):null,username:P(t.username||t.ownerUserKey||
|
|
1228
|
-
t.userKey)}:{}}function
|
|
1228
|
+
t.userKey)}:{}}function rg(e="capture"){return e==="detached"?"service":e==="pty"?"interactive":"finite"}function ng({mode:e="\
|
|
1229
1229
|
capture",purpose:t="terminal"}={}){return t==="preview"?"preview":e==="pty"?"terminal":"job"}function Et(e=""){let t=P(e);
|
|
1230
1230
|
if(!t)return"";if(!/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,254}[A-Za-z0-9])?$/u.test(t))throw oe(`Invalid Vibe64 execution ide\
|
|
1231
1231
|
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function Fu(e={},t={}){let{mode:r="capture",project:n={},
|
|
1232
|
-
purpose:o="terminal",session:i={}}=t,s=Y(e),a=xe(s.kind,
|
|
1233
|
-
|
|
1232
|
+
purpose:o="terminal",session:i={}}=t,s=Y(e),a=xe(s.kind,Yh,ng({mode:r,purpose:o}),"execution_kind"),c=xe(s.lifecycle,Jh,
|
|
1233
|
+
rg(r),"execution_lifecycle");if(r==="detached"&&c!=="service"||r==="pty"&&c!=="interactive"||r==="capture"&&c!=="finite")
|
|
1234
1234
|
throw oe(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_execution_lifecycle_incompatible");let u=Et(
|
|
1235
1235
|
s.ownerId||i.sessionId);if(c==="service"&&!u)throw oe("Service execution requires a durable owner id.","vibe64_execution\
|
|
1236
1236
|
_owner_required");let l=s.resourceProfile;if(l!=null&&(!l||typeof l!="object"||Object.keys(l).some(m=>!["key","compatibi\
|
|
1237
1237
|
lityKey","environment"].includes(m))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(l.key||"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||
|
|
1238
1238
|
"")||!["development","test","production"].includes(l.environment)))throw oe("Invalid activity resource profile identity.",
|
|
1239
1239
|
"vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.freeze({...l})}:{},controlGenerationId:Et(
|
|
1240
|
-
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:
|
|
1241
|
-
id:
|
|
1242
|
-
projectSlug:Et(s.projectSlug||n.slug||n.projectSlug),sessionId:Et(s.sessionId||i.sessionId)})}function
|
|
1240
|
+
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:og(s.workflowId)},
|
|
1241
|
+
id:Vh(),kind:a,label:P(s.label),lifecycle:c,operationId:Et(s.operationId),ownerId:u,parentExecutionId:Et(s.parentExecutionId),
|
|
1242
|
+
projectSlug:Et(s.projectSlug||n.slug||n.projectSlug),sessionId:Et(s.sessionId||i.sessionId)})}function og(e){if(typeof e!=
|
|
1243
1243
|
"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.test(e))throw oe("Execution req\
|
|
1244
|
-
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function
|
|
1245
|
-
e)?Uo:[]}function zu(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function
|
|
1246
|
-
imes"),n=zu(e,"runtime");if(!r&&!n)return ze(
|
|
1244
|
+
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function ig(e=""){return Xh.has(
|
|
1245
|
+
e)?Uo:[]}function zu(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function sg(e={},t=""){let r=zu(e,"runt\
|
|
1246
|
+
imes"),n=zu(e,"runtime");if(!r&&!n)return ze(ig(t));let o=r?e.runtimes:e.runtime;return ze((Array.isArray(o)?o:[o]).map(
|
|
1247
1247
|
P).filter(Boolean))}function qu(e={}){let t=Y(e),r=P(t.command);if(!r)throw oe("A command is required.","vibe64_command_\
|
|
1248
|
-
required");let n=xe(t.mode,
|
|
1249
|
-
"Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=ue(t.baseEnv),i=
|
|
1250
|
-
{mode:n}),s=xe(t.purpose,
|
|
1248
|
+
required");let n=xe(t.mode,zh,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))throw oe(
|
|
1249
|
+
"Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=ue(t.baseEnv),i=Zh(t.env,
|
|
1250
|
+
{mode:n}),s=xe(t.purpose,Hh,"terminal","purpose"),a=sg(t,s);for(let h of a)if(!Object.hasOwn(gt,h))throw oe(`Unsupported\
|
|
1251
1251
|
Vibe64 runtime: ${h}.`,"vibe64_command_runtime_unsupported");let c=Y(t.project),u=Y(t.session),l=t.releaseEnvironmentFile??
|
|
1252
1252
|
"";if(typeof l!="string"||l&&(!l.startsWith("/")||/[\r\n\0]/u.test(l)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="de\
|
|
1253
1253
|
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw oe("Release environment files require a\
|
|
1254
1254
|
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let m=t.usageRecordingPreload??
|
|
1255
1255
|
"";if(typeof m!="string"||m&&(!m.startsWith("/")||/[\s"'\\\0]/u.test(m)||!["preview","output"].includes(s)||t.actor==="a\
|
|
1256
1256
|
pp"))throw oe("A usage recording preload belongs only to a Preview or Output target launch.","vibe64_command_usage_recor\
|
|
1257
|
-
ding_preload_invalid");let f=t.applicationAccount??"";if(typeof f!="string"||f&&(!
|
|
1257
|
+
ding_preload_invalid");let f=t.applicationAccount??"";if(typeof f!="string"||f&&(!Bh.test(f)||t.actor!=="app"||n!=="capt\
|
|
1258
1258
|
ure"))throw oe("Application accounts run only finite application commands.","vibe64_command_application_account_invalid");
|
|
1259
|
-
return{actor:xe(t.actor,
|
|
1260
|
-
baseEnv:o,command:r,cwd:C(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:xe(t.envPolicy,
|
|
1261
|
-
"env_policy"),releaseEnvironmentFile:l,execution:Fu(t.execution,{mode:n,project:c,purpose:s,session:u}),credentialHome:
|
|
1259
|
+
return{actor:xe(t.actor,Gh,"daemon","actor"),applicationAccount:f,allowedRoots:li(t.allowedRoots),args:Qh(t.args,{mode:n}),
|
|
1260
|
+
baseEnv:o,command:r,cwd:C(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:xe(t.envPolicy,qh,"session",
|
|
1261
|
+
"env_policy"),releaseEnvironmentFile:l,execution:Fu(t.execution,{mode:n,project:c,purpose:s,session:u}),credentialHome:tg(
|
|
1262
1262
|
t.credentialHome),gitAuthToken:P(t.gitAuthToken),gitSafeDirectories:li(t.gitSafeDirectories),personGitIdentity:{email:P(
|
|
1263
|
-
t.personGitIdentity?.email),name:P(t.personGitIdentity?.name)},gitTransport:xe(t.gitTransport,
|
|
1263
|
+
t.personGitIdentity?.email),name:P(t.personGitIdentity?.name)},gitTransport:xe(t.gitTransport,Wh,"none","git_transport"),
|
|
1264
1264
|
inheritProcessEnv:!l&&t.inheritProcessEnv!==!1,input:t.input,logPath:C(t.logPath),maxBuffer:Number.isSafeInteger(Number(
|
|
1265
|
-
t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):
|
|
1266
|
-
outputEncoding:xe(t.outputEncoding,
|
|
1267
|
-
null,shimDirs:li(t.shimDirs),terminal:
|
|
1268
|
-
0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:P(t.userKey)}}var
|
|
1269
|
-
q();
|
|
1265
|
+
t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):Kh,mode:n,onOutput:typeof t.onOutput=="function"?t.onOutput:null,
|
|
1266
|
+
outputEncoding:xe(t.outputEncoding,Fh,"utf8","output_encoding"),project:c,purpose:s,runtimes:a,session:u,signal:t.signal??
|
|
1267
|
+
null,shimDirs:li(t.shimDirs),terminal:eg(t.terminal),timeout:Number.isSafeInteger(Number(t.timeout))&&Number(t.timeout)>
|
|
1268
|
+
0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:P(t.userKey)}}var Gh,Bh,Hh,zh,Fh,qh,Wh,Yh,Jh,Kh,Xh,rA,Wu=g(()=>{
|
|
1269
|
+
q();Zr();ge();Gh=Object.freeze(["daemon","owner-user","named-user","app"]),Bh=/^[a-z_][a-z0-9_-]{0,31}$/u,Hh=Object.freeze(
|
|
1270
1270
|
["account","assistant","terminal","codex","github","github-api","source-editor","preview","output","deployment","health",
|
|
1271
|
-
"workspace-cache","source"]),
|
|
1272
|
-
freeze(["session","project","preview","auth","deployment"]),
|
|
1273
|
-
Object.freeze(["assistant","browser","control","job","preview","service","terminal"]),
|
|
1274
|
-
ctive","service"]),
|
|
1275
|
-
|
|
1276
|
-
()=>{
|
|
1277
|
-
function
|
|
1271
|
+
"workspace-cache","source"]),zh=Object.freeze(["capture","pty","detached"]),Fh=Object.freeze(["utf8","base64"]),qh=Object.
|
|
1272
|
+
freeze(["session","project","preview","auth","deployment"]),Wh=Object.freeze(["none","github-https","github-token"]),Yh=
|
|
1273
|
+
Object.freeze(["assistant","browser","control","job","preview","service","terminal"]),Jh=Object.freeze(["finite","intera\
|
|
1274
|
+
ctive","service"]),Kh=1e3*1e3*100,Xh=new Set(["assistant","codex","deployment","output","preview","source","terminal"]);
|
|
1275
|
+
rA=Object.freeze({normalizeExecutionDescriptor:Fu})});function di(){return ag}function ln(e){return["1","true"].includes(String(e[Yu]||"").trim().toLowerCase())}var ag,Yu,dn=g(
|
|
1276
|
+
()=>{Bt();Vt();ui();Fe();ag=null,Yu="VIBE64_MANAGED_EXECUTION_REQUIRED"});import{realpathSync as Ju,statSync as ug}from"node:fs";import $e from"node:path";import{fileURLToPath as lg}from"node:url";
|
|
1277
|
+
function dg(e){let t=[$e.resolve($e.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=$e.dirname(e);t.
|
|
1278
1278
|
push($e.join(r,"node_modules/@local/vibe64-usage-recording/runtime/node")),$e.dirname(r)!==r;r=$e.dirname(r));return t.flatMap(
|
|
1279
|
-
r=>{try{return[Ju(r)]}catch{return[]}})}function Ku(e="",t=
|
|
1280
|
-
|
|
1281
|
-
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var
|
|
1279
|
+
r=>{try{return[Ju(r)]}catch{return[]}})}function Ku(e="",t=lg(cg)){try{if($e.resolve(e)===e&&Ju(e)===e&&ug(e).isFile()&&
|
|
1280
|
+
dg(t).some(r=>e.startsWith(`${r}${$e.sep}`)))return`--import=${e}`}catch{}throw Object.assign(new Error("The usage recor\
|
|
1281
|
+
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var cg,Xu=g(()=>{cg=new URL(
|
|
1282
1282
|
"./../node_modules/@local/vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href});function Qu(e){return e.releaseEnvironmentFile?K("Release environment execution requires a managed host.","vibe64_releas\
|
|
1283
1283
|
e_environment_unavailable",{execution:e.execution}):e.applicationAccount?K("Application account execution requires a man\
|
|
1284
|
-
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function
|
|
1284
|
+
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function pg(e,t={}){let{actor:r,
|
|
1285
1285
|
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=Qu(e);if(a)return a;if(e.usageRecordingPreload){let c=Ku(e.usageRecordingPreload),
|
|
1286
1286
|
u=s;o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?Vu(e,{actor:r,cwd:n,env:o,resolveEnv:s}):
|
|
1287
1287
|
e.mode==="detached"?r.requiresRealUser&&(!ft(r)||i)?K("Detached real-user command execution is unsupported when the help\
|
|
1288
1288
|
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):uc(e,{actor:r,cwd:n,env:o}):i?
|
|
1289
|
-
{...await Ro(
|
|
1290
|
-
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:
|
|
1289
|
+
{...await Ro(Hr({actor:r,args:e.args,command:e.command,cwd:n,env:o,input:e.input,operation:Ht(e)}),{env:process.env,maxBuffer:e.
|
|
1290
|
+
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:Gt(e.command,e.args,
|
|
1291
1291
|
{cwd:n,env:o,execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,onOutput:e.onOutput,outputEncoding:e.outputEncoding,
|
|
1292
|
-
signal:e.signal,timeout:e.timeout})}async function
|
|
1292
|
+
signal:e.signal,timeout:e.timeout})}async function Qt(e={}){let t=null;try{if(t=qu(e),t.signal?.aborted)return K("Comman\
|
|
1293
1293
|
d cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await Tc(t),n=t.inheritProcessEnv?{...process.env,
|
|
1294
|
-
...t.baseEnv}:{...t.baseEnv},o=(d={})=>({...d,VIBE64_EXECUTION_ID:t.execution.id}),i=di(),s=
|
|
1294
|
+
...t.baseEnv}:{...t.baseEnv},o=(d={})=>({...d,VIBE64_EXECUTION_ID:t.execution.id}),i=di(),s=ln(n)||ln(process.env),a=qr(
|
|
1295
1295
|
r),u=!(!!i||s||Lo())&&ft(r)?[n.PATH,process.env.PATH].filter(Boolean).join(":"):"",l=o(await Eu({actor:r,baseEnv:n,localPath:u,
|
|
1296
1296
|
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Je,Ye,Xe,Ke].map(d=>[d,l[d]]));
|
|
1297
1297
|
Rc(r,l);let f=Bu(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});Oc(r,t,f);let h=(d={})=>typeof t.
|
|
1298
1298
|
args=="function"?t.args(d):t.args,y=(d={})=>o(t.envFactory?Jo({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:m,request:{
|
|
1299
|
-
...t,env:t.envFactory(d),envFactory:null}}):l),T=(d=t,p={})=>
|
|
1299
|
+
...t,env:t.envFactory(d),envFactory:null}}):l),T=(d=t,p={})=>pg(d,{actor:r,cwd:f,env:l,requiresHelper:a,resolveEnv:y,...p});
|
|
1300
1300
|
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:f,env:l,resolveArgs:h,resolveEnv:y,runLocal:T});let S=Qu(t);return S||
|
|
1301
1301
|
(s?K("Managed execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unava\
|
|
1302
1302
|
ilable",{execution:t.execution,retryable:!1}):T())}catch(r){return K(r?.message||"Vibe64 command failed.",r?.code||"vibe\
|
|
1303
|
-
64_command_failed",{execution:t?.execution})}}var
|
|
1304
|
-
Xu()});import{fileURLToPath as
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
e||"").trim();return
|
|
1308
|
-
function
|
|
1309
|
-
r)&&
|
|
1310
|
-
"darwin"&&
|
|
1303
|
+
64_command_failed",{execution:t?.execution})}}var pn=g(()=>{Ic();Ko();ht();Bt();zr();Vt();ui();Hu();Wr();Wu();Fe();dn();
|
|
1304
|
+
Xu()});import{fileURLToPath as fg}from"node:url";var mg,xA,$A,jA,LA,Zu=g(()=>{Pe();mg=new URL("./../node_modules/@local/vibe64-\
|
|
1305
|
+
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,xA=fg(new URL("./gitTurnCheckpointCommand.js",mg)),$A=15*
|
|
1306
|
+
6e4,jA=512*1024*1024,LA=1024*1024*1024});var UA,el=g(()=>{q();UA=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"])});var tl=g(()=>{});import{existsSync as hg}from"node:fs";import mn from"node:path";import rl from"node:process";function pi(e=""){let t=String(
|
|
1307
|
+
e||"").trim();return wg[t]||t}function ol({platform:e=rl.platform,aptGet:t=!1}={}){return e==="darwin"?"brew":t?"apt":""}
|
|
1308
|
+
function yg(e,t=Jt){return[...String(e.PATH||"").split(mn.delimiter),...String(t||"").split(mn.delimiter)].some(r=>mn.isAbsolute(
|
|
1309
|
+
r)&&hg(mn.join(r,"apt-get")))}function hn({env:e,platform:t=rl.platform,systemPath:r}){return ol({platform:t,aptGet:t!==
|
|
1310
|
+
"darwin"&&yg(e,r)})}function gn(e="",t={}){let{family:r="",mise:n=!1,xcode:o=!0}=t,i=fn[pi(e)];if(!i)return null;if(r===
|
|
1311
1311
|
"brew"&&!o&&["git","cpp"].includes(pi(e)))return{command:"xcode-select --install",sudo:!1,note:""};let s=i.any||i[r]||"";
|
|
1312
|
-
if(!s&&i.mise&&(s=n?`mise use -g ${i.mise}`:`${
|
|
1313
|
-
"sudo ")||r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?nl:""}}var nl,
|
|
1314
|
-
nl="You'll be asked for your computer password. Nothing shows while you type.",
|
|
1312
|
+
if(!s&&i.mise&&(s=n?`mise use -g ${i.mise}`:`${gg} && ~/.local/bin/mise use -g ${i.mise}`),!s)return null;let a=s.startsWith(
|
|
1313
|
+
"sudo ")||r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?nl:""}}var nl,gg,qA,fn,wg,WA,Zt=g(()=>{tn();
|
|
1314
|
+
nl="You'll be asked for your computer password. Nothing shows while you type.",gg="curl -fsSL https://mise.run | sh",qA=
|
|
1315
1315
|
Object.freeze({linux:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-linux.md",darwin:"\
|
|
1316
1316
|
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),fn=Object.freeze({claude:{
|
|
1317
1317
|
name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://claude.ai/i\
|
|
@@ -1337,17 +1337,17 @@ rl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -fsSL https
|
|
|
1337
1337
|
ild tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/install_ruby\
|
|
1338
1338
|
_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"sudo apt i\
|
|
1339
1339
|
nstall build-essential pkg-config libyaml-dev libssl-dev zlib1g-dev libpq-dev default-libmysqlclient-dev libgmp-dev",brew:"\
|
|
1340
|
-
brew install pkg-config libyaml openssl@3 gmp"}}),
|
|
1341
|
-
function
|
|
1342
|
-
`)}function
|
|
1340
|
+
brew install pkg-config libyaml openssl@3 gmp"}}),wg=Object.freeze({composer:"php"});WA=Object.freeze({SUDO_NOTE:nl,localToolFamily:ol})});function il({env:e,platform:t,systemPath:r}){return gn("git",{family:hn({env:e,platform:t,systemPath:r})})?.command||""}
|
|
1341
|
+
function _g(e={}){return[e.error,e.stderr,e.output].filter(Boolean).join(`
|
|
1342
|
+
`)}function Eg(e,t){let r=_g(e);if(/spawn(?:Sync)? git ENOENT|(?:^|\s)git: (?:command )?not found/mu.test(r)){let n=il(t);
|
|
1343
1343
|
return{code:"vibe64_git_missing",installCommand:n,message:n?`Git isn't installed on this computer. Install it with: ${n}`:
|
|
1344
1344
|
"Git isn't installed on this computer. Install Git, then try again."}}return/unknown option [`']initial-branch/u.test(r)?
|
|
1345
1345
|
{code:"vibe64_git_too_old",installCommand:il(t),message:"This Git is too old for Vibe64. Update Git to version 2.28 or n\
|
|
1346
1346
|
ewer, then try again."}:/gpg failed to sign|failed to sign the data|signing failed|couldn't (?:load|find) (?:public )?key|incorrect passphrase/iu.
|
|
1347
1347
|
test(r)?{code:"vibe64_git_signing_failed",installCommand:"",message:"Your Git is set to sign every commit, and signing d\
|
|
1348
1348
|
idn't work here. Vibe64 can't type a key passphrase for you. Make one signed commit in a terminal to check your key work\
|
|
1349
|
-
s and is unlocked, then try again."}:null}var KA,sl=g(()=>{
|
|
1350
|
-
backups.git",ul="vibe64-atomic",
|
|
1349
|
+
s and is unlocked, then try again."}:null}var KA,sl=g(()=>{Zt();KA=Object.freeze({describeGitFailure:Eg})});var mi=g(()=>{});import al from"node:path";function Sg(e=""){return e?al.join(al.dirname(e),cl):""}var cl,ul,vg,tO,rO,ll=g(()=>{mi();cl="\
|
|
1350
|
+
backups.git",ul="vibe64-atomic",vg=`backup_canonical_ref() {
|
|
1351
1351
|
vibe64_backup_repository="$1"
|
|
1352
1352
|
vibe64_source_repository="$2"
|
|
1353
1353
|
vibe64_source_ref="$3"
|
|
@@ -1391,7 +1391,7 @@ if [ "$(git --git-dir "$backup_repository" rev-parse --is-bare-repository 2>/dev
|
|
|
1391
1391
|
exit 1
|
|
1392
1392
|
fi
|
|
1393
1393
|
|
|
1394
|
-
${
|
|
1394
|
+
${vg}
|
|
1395
1395
|
|
|
1396
1396
|
updates_file="$(mktemp "$repository_root/.pre-receive.XXXXXX")"
|
|
1397
1397
|
cleanup_updates_file() {
|
|
@@ -1439,8 +1439,8 @@ while read -r old_object _new_object ref_name; do
|
|
|
1439
1439
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
1440
1440
|
fi
|
|
1441
1441
|
done <"$updates_file"
|
|
1442
|
-
`;rO=Object.freeze({CANONICAL_REPOSITORY_PUSH_OPTION:ul,canonicalRepositoryBackupPath:
|
|
1443
|
-
wserWorkerSource.js",import.meta.url).href});var
|
|
1442
|
+
`;rO=Object.freeze({CANONICAL_REPOSITORY_PUSH_OPTION:ul,canonicalRepositoryBackupPath:Sg})});var dl=g(()=>{qt();ge()});var fi=g(()=>{});var pl=g(()=>{});var ml=g(()=>{});var hi=g(()=>{});var mO,fl=g(()=>{pl();ml();hi();mO=new URL("./../node_modules/@local/vibe64-execution/src/server/runtime/agentPreviewBro\
|
|
1443
|
+
wserWorkerSource.js",import.meta.url).href});var Ig,hl=g(()=>{Ig=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms\
|
|
1444
1444
|
>]"," vibe64-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [\
|
|
1445
1445
|
--json]"," vibe64-helper preview inspect-url"," vibe64-helper preview screenshot [--output <path>]"," vibe64-helper p\
|
|
1446
1446
|
review browser ensure"," vibe64-helper preview browser eval < playwright-code.js"," vibe64-helper preview browser iden\
|
|
@@ -1477,14 +1477,14 @@ y reread empty or unchanged logs between brief waits.","This is the canonical pr
|
|
|
1477
1477
|
application.","Do not start a duplicate copy of that application on another port.","A distinct secondary application exp\
|
|
1478
1478
|
licitly requested by the user, such as a reference app, may run separately without replacing this preview."].join(`
|
|
1479
1479
|
`)+`
|
|
1480
|
-
`});var gl=g(()=>{});import{fileURLToPath as
|
|
1481
|
-
-execution/src/server/conversationExecution.js",import.meta.url).href,TO=
|
|
1480
|
+
`});var gl=g(()=>{});import{fileURLToPath as Ng}from"node:url";var Pg,TO,wl=g(()=>{pn();dn();Pe();Pg=new URL("./../node_modules/@local/vibe64\
|
|
1481
|
+
-execution/src/server/conversationExecution.js",import.meta.url).href,TO=Ng(new URL("./engines/stdioBridge.js",Pg))});var NO,yl=g(()=>{pn();Zt();ge();NO=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$nam\
|
|
1482
1482
|
e" 2>/dev/null) || continue'," case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /us\
|
|
1483
1483
|
r/bin/*) continue ;; esac; fi',` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1484
|
-
`)});var
|
|
1485
|
-
any:n}=fn[e];return[e,Object.freeze({name:t,guideUrl:r,install:n})]})))});import{execFile as
|
|
1486
|
-
ge();dl();fi();fl();hi();hl();gl();wl();
|
|
1487
|
-
maxBuffer:f=1024*1024}=l,h=await
|
|
1484
|
+
`)});var Cg,_l=g(()=>{Zt();ge();Cg=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,
|
|
1485
|
+
any:n}=fn[e];return[e,Object.freeze({name:t,guideUrl:r,install:n})]})))});import{execFile as kg}from"node:child_process";import{promisify as xg}from"node:util";var MO,El=g(()=>{MO=xg(kg)});var bl=g(()=>{Ur();Qa();pt();zr();Sc();pn();Bt();Fe();dn();Zu();Ko();el();tl();Zr();Wo();ht();sl();mi();ll();q();qt();Pe();
|
|
1486
|
+
ge();dl();fi();fl();hi();hl();gl();wl();Zt();yl();_l();El();fi()});import{realpath as vl}from"node:fs/promises";async function er(e){let t=await vl(e),r=async(c,u="utf8",l={})=>{let{input:m,
|
|
1487
|
+
maxBuffer:f=1024*1024}=l,h=await Qt({actor:"daemon",allowedRoots:[t],args:["-C",t,...c],command:"git",cwd:t,envPolicy:"p\
|
|
1488
1488
|
roject",gitSafeDirectories:[t],input:m,maxBuffer:f,mode:"capture",outputEncoding:u,purpose:"source",runtimes:["git"],timeout:6e4});
|
|
1489
1489
|
if(h.ok!==!0)throw Object.assign(new Error(h.error||"Git could not read the pinned topic."),{code:h.code});return u==="b\
|
|
1490
1490
|
ase64"?Buffer.from(h.stdout,"base64"):h.stdout.trim()};if(await vl(await r(["rev-parse","--show-toplevel"]))!==t)throw new Error(
|
|
@@ -1500,7 +1500,7 @@ h,T).toString("ascii")),d=S?Number(S[1]):-1,p=T+1+d;if(d!==y.bytes||f[p]!==0||J(
|
|
|
1500
1500
|
`Topic input differs from its pinned commit: ${y.path}.`);h=p+1}if(h!==f.length)throw new Error("Unexpected trailing dat\
|
|
1501
1501
|
a while reading the pinned topic.");c=u}if(await r(["rev-parse","HEAD"])!==n||await r(["status","--porcelain","--untrack\
|
|
1502
1502
|
ed-files=all"]))throw new Error("Topic changed during manifest generation. Commit and retry.");return{topicId:o.topic.topicId,
|
|
1503
|
-
release:o.release,repository:s,commit:n,topicManifest:o.topicManifest,topicHash:o.topicHash}}function
|
|
1503
|
+
release:o.release,repository:s,commit:n,topicManifest:o.topicManifest,topicHash:o.topicHash}}function tr(e,t){let r=ce(xr,
|
|
1504
1504
|
e,"Course");if(!/^[a-z][a-z0-9-]{0,63}$/u.test(r.courseId)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!r.topics.length)throw new Error(
|
|
1505
1505
|
"Course needs an ID, exact release and at least one whole topic.");let n=new Set,o=r.topics.map(i=>{if(n.has(i.topicId))
|
|
1506
1506
|
throw new Error(`Duplicate course topic: ${i.topicId}.`);n.add(i.topicId);let s=t.filter(l=>l.topicId===i.topicId&&l.release===
|
|
@@ -1508,7 +1508,7 @@ i.release);if(s.length!==1)throw new Error(`Resolve exactly one pinned topic rel
|
|
|
1508
1508
|
if(!/^[a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+$/u.test(a.repository||"")||!/^[a-f0-9]{40}$/u.test(a.commit||""))throw new Error(
|
|
1509
1509
|
`Topic requires a repository and immutable commit: ${i.topicId}.`);let c=a.topicManifest;if(!c||c.schemaVersion!==1||c.topic?.
|
|
1510
1510
|
topicId!==i.topicId||c.release!==i.release||J(L(c))!==a.topicHash)throw new Error(`Topic manifest identity mismatch: ${i.
|
|
1511
|
-
topicId}.`);if(ce(
|
|
1511
|
+
topicId}.`);if(ce(kr,c.topic,i.topicId),r.status==="released"&&c.topic.status!=="released")throw new Error(`Released cou\
|
|
1512
1512
|
rse requires a released topic: ${i.topicId}.`);let u=c.topic.lessons;if(!Array.isArray(u)||!u.length||!Array.isArray(c.lessons)||
|
|
1513
1513
|
u.length!==c.lessons.length)throw new Error(`Incomplete whole-topic inventory: ${i.topicId}.`);for(let[l,m]of u.entries()){
|
|
1514
1514
|
let f=c.lessons[l];if(f.code!==m.code||f.status!==m.status||f.required!==m.required||!/^[a-f0-9]{64}$/u.test(f.hash||""))
|
|
@@ -1517,39 +1517,39 @@ throw new Error(`Changed whole-topic order or lesson identity: ${i.topicId}.`);i
|
|
|
1517
1517
|
repository:a.repository,commit:a.commit,manifestHash:a.topicHash,lessons:c.lessons.map(l=>({...l}))}});if(r.orientation!==
|
|
1518
1518
|
void 0&&!o.some(i=>i.lessons.some(s=>s.code===r.orientation&&s.status==="published")))throw new Error(`Course orientatio\
|
|
1519
1519
|
n ${r.orientation} must be a published lesson of the course.`);return{schemaVersion:1,courseId:r.courseId,release:r.release,
|
|
1520
|
-
status:r.status,topics:o}}var wn=g(()=>{bl();lt();ct();ut()});function
|
|
1521
|
-
return
|
|
1522
|
-
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var kP,_n=g(()=>{
|
|
1520
|
+
status:r.status,topics:o}}var wn=g(()=>{bl();lt();ct();ut()});function bt(e,t,r){let{statusCode:n,cause:o,...i}=r,s=new ae(n,e,{...i,code:t});return o&&(s.cause=o),s}function yn(e,t,r=409,n={}){
|
|
1521
|
+
return bt(e,t,{...n,statusCode:r})}function ye(e,t,r,n){return bt(e,t,{statusCode:r,cause:n})}function gi(e,t,r){return Object.
|
|
1522
|
+
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var kP,_n=g(()=>{Sr();kP=128*1024});var Sl=g(()=>{});import{lstat as $g,readFile as jg,readdir as Lg,realpath as Mg}from"node:fs/promises";import D from"node:path";function wi(e){
|
|
1523
1523
|
return me(e)?{...e,steps:e.steps.map(t=>{if(t.check.kind!=="choice")return t;let{answer:r,...n}=t.check;return{...t,check:n}})}:
|
|
1524
|
-
e}function et(e,t={}){let r=ce(
|
|
1525
|
-
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!
|
|
1524
|
+
e}function et(e,t={}){let r=ce(Ug,e,"Installed topic pin");if(!je.test(r.topicId)||!yi.test(r.commit)||r.topicId!==(t.topicId??
|
|
1525
|
+
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!Dg.test(r.repository)||!nr.test(r.topicHash))
|
|
1526
1526
|
throw new Error("Installed pin does not match the requested topic, commit or canonical source identity.");if(r.topicHash!==
|
|
1527
|
-
(t.topicHash??r.topicHash))throw new Error("Installed topic differs from the trusted course or attempt pin.");return r}async function
|
|
1528
|
-
let r=await
|
|
1527
|
+
(t.topicHash??r.topicHash))throw new Error("Installed topic differs from the trusted course or attempt pin.");return r}async function or(e,t){
|
|
1528
|
+
let r=await $g(e);if(r.isSymbolicLink()||await Mg(e)!==e)throw new Error("Installed content cannot use symlink or direct\
|
|
1529
1529
|
ory aliases.");if(t?!r.isDirectory():!r.isFile())throw new Error(`Installed content needs a regular ${t?"directory":"fil\
|
|
1530
|
-
e"}.`);return r}async function
|
|
1531
|
-
limit.`);let n=await
|
|
1532
|
-
let t=[],r=0;async function n(o){await
|
|
1533
|
-
"Installed snapshot exceeds 65536 directory entries.");let s=D.join(o,i.name);i.isDirectory()?await n(s):(await
|
|
1534
|
-
t.push(D.relative(e,s).split(D.sep).join("/")))}}return await n(e),t.sort()}function
|
|
1535
|
-
function
|
|
1530
|
+
e"}.`);return r}async function vt(e,t){if((await or(e,!1)).size>t)throw new Error(`Installed file exceeds its ${t}-byte \
|
|
1531
|
+
limit.`);let n=await jg(e);if(n.length>t)throw new Error(`Installed file exceeds its ${t}-byte limit.`);return n}async function Vg(e){
|
|
1532
|
+
let t=[],r=0;async function n(o){await or(o,!0);for(let i of await Lg(o,{withFileTypes:!0})){if(++r>65536)throw new Error(
|
|
1533
|
+
"Installed snapshot exceeds 65536 directory entries.");let s=D.join(o,i.name);i.isDirectory()?await n(s):(await or(s,!1),
|
|
1534
|
+
t.push(D.relative(e,s).split(D.sep).join("/")))}}return await n(e),t.sort()}function ir({systemRoot:e}){return Bg(e,Gg)}
|
|
1535
|
+
function Bg(e,t){if(typeof e!="string"||!e||!D.isAbsolute(e))throw new Error("Installed teaching content needs an absolu\
|
|
1536
1536
|
te server-owned system root.");let r=D.resolve(e),n=new Map;function o(d){return yn(`Lesson ${d.lesson.code} ("${d.lesson.
|
|
1537
1537
|
title}") cannot be taught by this version of Vibe64: ${d.problem} Update the course in Courses, or ask its authors for a\
|
|
1538
1538
|
fixed release.`,"VIBE64_TRAINING_LESSON_UNUSABLE",422,{params:{lessonCode:d.lesson.code,lessonTitle:d.lesson.title,problem:d.
|
|
1539
1539
|
problem}})}async function i(d={}){let p=await s(d);return{...p,bundles:p.bundles.map(_=>({..._,lesson:wi(_.lesson)}))}}async function s({
|
|
1540
1540
|
topicId:d,commit:p,topicHash:_}={}){if(typeof d!="string"||typeof p!="string"||!je.test(d)||!yi.test(p))throw new Error(
|
|
1541
|
-
"Choose a valid topic ID and its exact 40-character lowercase Git commit.");if(typeof _!="string"||!
|
|
1541
|
+
"Choose a valid topic ID and its exact 40-character lowercase Git commit.");if(typeof _!="string"||!nr.test(_))throw new Error(
|
|
1542
1542
|
"Provide the trusted 64-character topic hash from the course or saved attempt.");let b=JSON.stringify([d,p,_]),v=n.get(b);
|
|
1543
1543
|
return v||(v=a({topicId:d,commit:p,topicHash:_}).finally(()=>n.delete(b)),n.set(b,v)),structuredClone(await v)}async function a({
|
|
1544
1544
|
topicId:d,commit:p,topicHash:_}){try{let b=D.join(r,"training"),v=D.join(b,"content"),w=D.join(v,d),E=D.join(w,p);for(let se of[
|
|
1545
|
-
r,b,v,w,E])await
|
|
1546
|
-
topicHash:_}),I=JSON.parse((await
|
|
1545
|
+
r,b,v,w,E])await or(se,!0);let A=et(JSON.parse((await vt(D.join(E,"pin.json"),4096)).toString("utf8")),{topicId:d,commit:p,
|
|
1546
|
+
topicHash:_}),I=JSON.parse((await vt(D.join(E,"bundle.json"),32*1024*1024)).toString("utf8")),O=D.join(E,"files"),U=await Vg(
|
|
1547
1547
|
O),x=await He(O,{installed:!0}),k={schemaVersion:1,topic:x.topic,release:x.release,topicHash:x.topicHash,topicManifest:x.
|
|
1548
1548
|
topicManifest,lessons:x.bundles.map(({lesson:se,hash:Ee,status:Ul,required:Vl,manifest:Gl})=>({code:se.code,hash:Ee,status:Ul,
|
|
1549
1549
|
required:Vl,manifest:Gl}))};if(L(I)!==L(k))throw new Error("Installed bundle is incomplete, reordered, unsupported or ch\
|
|
1550
1550
|
anged from its source files.");if(x.topic.topicId!==A.topicId||x.release!==A.release||x.topicHash!==A.topicHash)throw new Error(
|
|
1551
1551
|
"Installed topic identity differs from its pin.");let F=Be([x.topicManifest,...x.bundles.map(se=>se.manifest)]);if(L(U)!==
|
|
1552
|
-
L(F.map(se=>se.path).sort()))throw new Error("Installed snapshot has missing or unrecorded files.");let Z=await
|
|
1552
|
+
L(F.map(se=>se.path).sort()))throw new Error("Installed snapshot has missing or unrecorded files.");let Z=await vt(D.join(
|
|
1553
1553
|
O,"package.json"),1024*1024),pe=F.find(se=>se.path==="package.json");if(Z.length!==pe.bytes||J(Z)!==pe.sha256)throw new Error(
|
|
1554
1554
|
"Installed source changed during reading.");if(JSON.parse(Z.toString("utf8")).repository?.url!==`https://github.com/${A.
|
|
1555
1555
|
repository}.git`)throw new Error("Installed package repository URL differs from its canonical pin.");return{pin:A,...x}}catch(b){
|
|
@@ -1558,24 +1558,24 @@ o install that exact revision.`:`Pinned teaching content ${d}@${p} is invalid: $
|
|
|
1558
1558
|
he verified snapshot.`,{cause:b});throw w.code=v?"VIBE64_TRAINING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",w}}
|
|
1559
1559
|
async function c({pin:d,manifest:p},_,b){let v=D.join(r,"training","content",d.topicId,d.commit,"files"),w=D.resolve(v,_,
|
|
1560
1560
|
b),E=D.relative(v,w).split(D.sep).join("/"),A=p.files.find(O=>O.path===E);if(!A)throw new Error("Lesson requested an unr\
|
|
1561
|
-
ecorded installed file.");let I=await
|
|
1561
|
+
ecorded installed file.");let I=await vt(w,1024*1024);if(I.length!==A.bytes||J(I)!==A.sha256)throw new Error("Installed \
|
|
1562
1562
|
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:E,bytes:I}}async function u({
|
|
1563
1563
|
topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof d!="string"||!je.test(d)||typeof p!="string"||!yi.
|
|
1564
|
-
test(p)||typeof _!="string"||!
|
|
1564
|
+
test(p)||typeof _!="string"||!nr.test(_)||typeof b!="string"||!je.test(b)||typeof v!="string"||!nr.test(v))throw new Error(
|
|
1565
1565
|
"Choose an exact pinned topic and lesson identity.");try{let w=D.join(r,"training"),E=D.join(w,"content"),A=D.join(E,d),
|
|
1566
|
-
I=D.join(A,p);for(let Ee of[r,w,E,A,I])await
|
|
1567
|
-
"utf8")),{topicId:d,commit:p,topicHash:_}),U=JSON.parse((await
|
|
1566
|
+
I=D.join(A,p);for(let Ee of[r,w,E,A,I])await or(Ee,!0);let O=et(JSON.parse((await vt(D.join(I,"pin.json"),4096)).toString(
|
|
1567
|
+
"utf8")),{topicId:d,commit:p,topicHash:_}),U=JSON.parse((await vt(D.join(I,"bundle.json"),32*1024*1024)).toString("utf8")),
|
|
1568
1568
|
x=U.topicManifest;if(!x||J(L(x))!==_||x.topic.topicId!==d||x.release!==O.release)throw new Error("Installed topic manife\
|
|
1569
1569
|
st differs from the trusted identity.");let k=x.lessons.find(Ee=>Ee.code===b),F=x.topic.lessons.find(Ee=>Ee.code===b),Z=U.
|
|
1570
1570
|
lessons.find(Ee=>Ee.code===b);if(!k||!F||!Z||k.hash!==v||J(L(Z.manifest))!==v)throw new Error("Installed lesson manifest\
|
|
1571
1571
|
differs from the trusted content hash.");if(!t(k.status))throw new Error(`Lesson ${b} is draft and cannot be taught. Ch\
|
|
1572
|
-
oose a published lesson.`);let pe={pin:O,manifest:Z.manifest,hash:v,descriptorPath:F.descriptor},
|
|
1573
|
-
se=
|
|
1572
|
+
oose a published lesson.`);let pe={pin:O,manifest:Z.manifest,hash:v,descriptorPath:F.descriptor},cr=await c(pe,".",F.descriptor),
|
|
1573
|
+
se=Cr(JSON.parse(cr.bytes.toString("utf8")),b);if(se.code!==b)throw new Error("Installed lesson descriptor identity chan\
|
|
1574
1574
|
ged.");return{...pe,lesson:wi(se)}}catch(w){let E=new Error(`Pinned teaching identity ${d}@${p} is invalid: ${w.message}\
|
|
1575
1575
|
Ask the owner to restore the exact snapshot.`,{cause:w});throw E.code=["ENOENT","ENOTDIR"].includes(w.code)?"VIBE64_TRA\
|
|
1576
1576
|
INING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",E}}async function l(d={}){let p=await m(d);return{...p,lesson:wi(
|
|
1577
1577
|
p.lesson)}}async function m({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof b!="string"||typeof v!=
|
|
1578
|
-
"string"||!je.test(b)||!
|
|
1578
|
+
"string"||!je.test(b)||!nr.test(v))throw new Error("Choose a declared lesson code and its exact 64-character lowercase c\
|
|
1579
1579
|
ontent hash.");let w=await s({topicId:d,commit:p,topicHash:_}),E=w.bundles.find(I=>I.lesson.code===b);if(!E)throw new Error(
|
|
1580
1580
|
`Lesson ${b} is not declared in this pinned topic.`);if(!t(E.status))throw new Error(`Lesson ${b} is draft and cannot be\
|
|
1581
1581
|
taught. Choose a published lesson.`);if(E.hash!==v)throw new Error(`Lesson ${b} content hash changed. Resume its exact \
|
|
@@ -1583,8 +1583,8 @@ pinned revision or explicitly start a new attempt.`);if(E.problem)throw o(E);let
|
|
|
1583
1583
|
ies","facts"].map(I=>[I,[...w.topic[I]||[]]]));return{pin:w.pin,lesson:E.lesson,manifest:E.manifest,hash:E.hash,descriptorPath:E.
|
|
1584
1584
|
descriptorPath,declarations:A}}async function f(d={}){let p=await l(d),_=D.dirname(p.descriptorPath);async function b(I){
|
|
1585
1585
|
let O=await c(p,_,I);return{path:O.path,text:O.bytes.toString("utf8")}}let v=[];for(let I of p.lesson.visuals){let O=await b(
|
|
1586
|
-
I.descriptor);v.push({id:I.id,descriptorPath:O.path,visual:JSON.parse(O.text)})}if(me(p.lesson)){let I
|
|
1587
|
-
O=[];for(let U of p.lesson.steps){let{body:x,beats:k}=
|
|
1586
|
+
I.descriptor);v.push({id:I.id,descriptorPath:O.path,visual:JSON.parse(O.text)})}if(me(p.lesson)){let I=$r(p.declarations),
|
|
1587
|
+
O=[];for(let U of p.lesson.steps){let{body:x,beats:k}=Lr((await b(U.body)).text,I);O.push({...U,bodyText:x,...k?{beats:k}:
|
|
1588
1588
|
{}})}return{...p,steps:O,...p.lesson.notes===void 0?{}:{notesText:(await b(p.lesson.notes)).text},visuals:v}}if(p.lesson.
|
|
1589
1589
|
schemaVersion!==1)throw new Error(`Lesson ${p.lesson.code} uses an unsupported format.`);let w=await b(p.lesson.document),
|
|
1590
1590
|
E=p.lesson.assessments.map(I=>({id:I.id,reference:I.rubric,position:new RegExp(`^<a id="${I.id}"></a>$`,"mu").exec(w.text).
|
|
@@ -1595,7 +1595,7 @@ E[O+1]?.position??w.text.length)}));return{...p,document:w,rubrics:A,visuals:v}}
|
|
|
1595
1595
|
is pinned lesson.`);if(w.check.kind!=="choice")throw new Error(`Step ${d} is not a choice step.`);return{pin:_,lessonCode:b.
|
|
1596
1596
|
code,lessonHash:v,stepId:d,answer:[...w.check.answer]}}async function y({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v,
|
|
1597
1597
|
visualId:w}={}){if(typeof w!="string"||!je.test(w))throw new Error("Choose a declared visual ID.");let E=await f({topicId:d,
|
|
1598
|
-
commit:p,topicHash:_,lessonCode:b,lessonHash:v}),A=E.visuals.find(k=>k.id===w);if(!A)throw
|
|
1598
|
+
commit:p,topicHash:_,lessonCode:b,lessonHash:v}),A=E.visuals.find(k=>k.id===w);if(!A)throw bt(`Visual ${w} is not declar\
|
|
1599
1599
|
ed in this pinned lesson.`,"VIBE64_TRAINING_VISUAL_UNDECLARED",{statusCode:400,params:{visualId:w}});let I=D.dirname(A.descriptorPath),
|
|
1600
1600
|
O=await c(E,I,A.visual.svg),U=await c(E,I,A.visual.controller),x=[];for(let k of A.visual.assets||[])x.push(await c(E,I,
|
|
1601
1601
|
k));return{pin:E.pin,lessonCode:E.lesson.code,lessonHash:E.hash,...A,svg:O,controller:U,assets:x}}async function T({topicId:d,
|
|
@@ -1609,50 +1609,50 @@ admissionOnly:E=!1}={}){if(E===!0&&w!==!0)throw new TypeError("Admission reads c
|
|
|
1609
1609
|
new Error(`Lesson ${b} has no declared bundled exercise.`),{code:"VIBE64_TRAINING_EXERCISE_MISSING"});let U=D.posix.join(
|
|
1610
1610
|
D.posix.dirname(I.descriptorPath),O.source),x={pin:I.pin,lessonCode:I.lesson.code,lessonHash:I.hash,exercise:O,sourcePath:U};
|
|
1611
1611
|
if(w===!0)return x;let k=U==="."?"":`${U}/`,F=[];for(let Z of I.manifest.files){if(!Z.path.startsWith(k))continue;let pe=Z.
|
|
1612
|
-
path.slice(k.length),
|
|
1613
|
-
readLesson:f,readAdmissionIdentity:u,readVisual:y,readCheck:T,readExercise:S,readChoiceAnswer:h})}var je,yi,
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
schemaVersion:{type:"integer",required:!0,enum:[1]},topicId:{...
|
|
1617
|
-
maxLength:40},topicHash:{...
|
|
1612
|
+
path.slice(k.length),cr=await c(I,U,pe);F.push({path:pe,bytes:cr.bytes})}return{...x,files:F}}return Object.freeze({readTopic:i,
|
|
1613
|
+
readLesson:f,readAdmissionIdentity:u,readVisual:y,readCheck:T,readExercise:S,readChoiceAnswer:h})}var je,yi,nr,Dg,rr,Ug,
|
|
1614
|
+
Gg,_i=g(()=>{Pr();lt();ct();yo();jr();Sl();ut();_n();je=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,yi=/^[a-f0-9]{40}$/u,nr=/^[a-f0-9]{64}$/u,
|
|
1615
|
+
Dg=/^[a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+$/u,rr={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},Ug=$({
|
|
1616
|
+
schemaVersion:{type:"integer",required:!0,enum:[1]},topicId:{...rr,maxLength:64},release:rr,repository:rr,commit:{...rr,
|
|
1617
|
+
maxLength:40},topicHash:{...rr,maxLength:64}});Gg=e=>e==="published"});import{randomUUID as Hg}from"node:crypto";import{lstat as zg,mkdir as bi,realpath as Fg,rename as qg,rm as Wg,writeFile as Yg}from"node:fs/promises";
|
|
1618
1618
|
import Q from"node:path";function Tl(e,t){if(typeof e!="string"||!Q.isAbsolute(e)||Q.resolve(e)!==e||e===Q.parse(e).root)
|
|
1619
1619
|
throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function Il(e,t){let r=Q.
|
|
1620
1620
|
relative(e,t);return!r||r!==".."&&!r.startsWith(`..${Q.sep}`)&&!Q.isAbsolute(r)}async function _e(e,t,r=!0){let n;try{n=
|
|
1621
|
-
await
|
|
1621
|
+
await zg(e)}catch(o){if(r&&o.code==="ENOENT")return null;throw o}if(n.isSymbolicLink()||await Fg(e)!==e)throw new Error(
|
|
1622
1622
|
"Training installation cannot use symlink or directory aliases.");if(t?!n.isDirectory():!n.isFile())throw new Error(`Tra\
|
|
1623
1623
|
ining installation needs a regular ${t?"directory":"file"}: ${e}.`);if(!t&&(n.nlink!==1||n.size!==0))throw new Error("Tr\
|
|
1624
1624
|
aining installation lock must be an unaliased empty regular file; inspect it before retrying.");return n}async function En(e,t=!1){
|
|
1625
|
-
let r=Q.dirname(e);return r!==e&&await En(r,t),_e(e,!0,t)}async function
|
|
1625
|
+
let r=Q.dirname(e);return r!==e&&await En(r,t),_e(e,!0,t)}async function Jg(e){try{await bi(e,{mode:448})}catch(t){if(t.
|
|
1626
1626
|
code!=="EEXIST")throw t}await _e(e,!0,!1)}function bn(e,t){if(L(e)!==L(t))throw new Error("Topic source or installed sna\
|
|
1627
1627
|
pshot conflicts with the approved owner pin. Keep existing content and check the exact source revision.")}async function Ei(e,t){
|
|
1628
|
-
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await
|
|
1629
|
-
commit:i,topicHash:s},t)}function Al({systemRoot:e}){let t=Tl(e,"Training system root"),r=
|
|
1628
|
+
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await er(e);bn({schemaVersion:1,topicId:r,release:n,repository:o,
|
|
1629
|
+
commit:i,topicHash:s},t)}function Al({systemRoot:e}){let t=Tl(e,"Training system root"),r=ir({systemRoot:t});async function n({
|
|
1630
1630
|
sourceRoot:o,pin:i}={}){let s={...et(i)};Tl(o,"Trusted topic source root");let a=Q.join(t,"training");if(Il(o,a)||Il(a,o))
|
|
1631
1631
|
throw new Error("Trusted topic source must be separate from the training installation namespace.");let c=Q.join(a,"conte\
|
|
1632
1632
|
nt"),u=Q.join(c,s.topicId),l=Q.join(u,s.commit),m=Q.join(a,".install-locks"),f=Q.join(m,`${s.topicId}-${s.commit}.lock`);
|
|
1633
1633
|
await En(t);let h=await En(o,!0);for(let d of[a,c,u,m])await _e(d,!0);if(await _e(f,!1),await _e(l,!0))bn((await r.readTopic(
|
|
1634
1634
|
s)).pin,s);else{if(!h)throw new Error("Trusted topic source is missing. Prepare the approved local repository before ins\
|
|
1635
|
-
talling its pin.");await Ei(o,s)}for(let d of[a,c,u,m])await
|
|
1635
|
+
talling its pin.");await Ei(o,s)}for(let d of[a,c,u,m])await Jg(d);let T=await mt(f);if(!T)throw yn("This topic revision\
|
|
1636
1636
|
is being installed. Retry after the current owner operation finishes.","VIBE64_TRAINING_INSTALL_BUSY");let S;try{await _e(
|
|
1637
1637
|
f,!1,!1);for(let v of[t,a,c,u,m])await _e(v,!0,!1);if(await _e(l,!0)){let v=await r.readTopic(s);return bn(v.pin,s),{installed:!1,
|
|
1638
|
-
...v}}await En(o),await Ei(o,s);let d=Q.join(a,`.install-${
|
|
1638
|
+
...v}}await En(o),await Ei(o,s);let d=Q.join(a,`.install-${Hg()}`);await bi(d,{mode:448}),S=d;let p=Q.join(S,"training",
|
|
1639
1639
|
"content",s.topicId);await bi(p,{recursive:!0,mode:448});let _=Q.join(p,s.commit);if(await vi(["bundle",o,_],{write(){}}),
|
|
1640
|
-
await Ei(o,s),await
|
|
1641
|
-
`,{flag:"wx",mode:384}),await
|
|
1642
|
-
ination appeared during installation. Keep it unchanged and retry the verified pin.");await
|
|
1643
|
-
s);return bn(b.pin,s),{installed:!0,...b}}finally{try{S&&await
|
|
1644
|
-
freeze({installTopic:n})}var Ol=g(()=>{
|
|
1645
|
-
import Ti from"node:path";async function
|
|
1646
|
-
mode:n});let s=Ti.join(i,`.${Ti.basename(e)}.${process.pid}.${
|
|
1647
|
-
o!==void 0&&await
|
|
1640
|
+
await Ei(o,s),await Yg(Q.join(_,"pin.json"),`${L(s)}
|
|
1641
|
+
`,{flag:"wx",mode:384}),await ir({systemRoot:S}).readTopic(s),await _e(u,!0,!1),await _e(l,!0))throw new Error("The dest\
|
|
1642
|
+
ination appeared during installation. Keep it unchanged and retry the verified pin.");await qg(_,l);let b=await r.readTopic(
|
|
1643
|
+
s);return bn(b.pin,s),{installed:!0,...b}}finally{try{S&&await Wg(S,{recursive:!0,force:!0})}finally{await T()}}}return Object.
|
|
1644
|
+
freeze({installTopic:n})}var Ol=g(()=>{Fr();wn();Si();lt();_n();_i()});import{randomUUID as Kg}from"node:crypto";import{chmod as Xg,mkdir as Qg,rename as Zg,rm as ew,writeFile as tw}from"node:fs/promises";
|
|
1645
|
+
import Ti from"node:path";async function rw(e,t,r={}){let{directoryMode:n,fileMode:o}=r,i=Ti.dirname(e);await Qg(i,{recursive:!0,
|
|
1646
|
+
mode:n});let s=Ti.join(i,`.${Ti.basename(e)}.${process.pid}.${Kg()}.tmp`);try{await tw(s,t,{encoding:"utf8",flag:"wx",mode:o}),
|
|
1647
|
+
o!==void 0&&await Xg(s,o),await Zg(s,e)}finally{await ew(s,{force:!0})}}async function Rl(e,t,r={}){await rw(e,`${JSON.stringify(
|
|
1648
1648
|
t,null,2)}
|
|
1649
|
-
`,r)}var Pl=g(()=>{});import{lstat as
|
|
1649
|
+
`,r)}var Pl=g(()=>{});import{lstat as nw,mkdir as ow,readFile as iw,realpath as sw}from"node:fs/promises";import Le from"node:path";function Ai(e){
|
|
1650
1650
|
if(!Number.isSafeInteger(e)||e<0)throw new Error("Supply the expected revision from a fresh installed catalogue read.")}
|
|
1651
1651
|
function Oi({systemRoot:e}){if(typeof e!="string"||!Le.isAbsolute(e)||Le.resolve(e)!==e||e===Le.parse(e).root)throw new Error(
|
|
1652
1652
|
"Installed catalogue needs a canonical absolute, non-root server-owned system root.");let t=Le.join(e,"training"),r=Le.join(
|
|
1653
|
-
t,"catalogue.json"),n=Le.join(t,"catalogue.lock"),o=
|
|
1654
|
-
_),_!==Le.dirname(_);_=Le.dirname(_));let d=!1,p=null;for(let _ of[...S,r,n]){let b;try{b=await
|
|
1655
|
-
"ENOENT")continue;throw w}let v=_!==r&&_!==n;if(b.isSymbolicLink()||await
|
|
1653
|
+
t,"catalogue.json"),n=Le.join(t,"catalogue.lock"),o=ir({systemRoot:e});async function i(){let S=[t];for(let _=e;S.unshift(
|
|
1654
|
+
_),_!==Le.dirname(_);_=Le.dirname(_));let d=!1,p=null;for(let _ of[...S,r,n]){let b;try{b=await nw(_)}catch(w){if(w.code===
|
|
1655
|
+
"ENOENT")continue;throw w}let v=_!==r&&_!==n;if(b.isSymbolicLink()||await sw(_)!==_||(v?!b.isDirectory():!b.isFile()||b.
|
|
1656
1656
|
nlink!==1))throw new Error("Installed catalogue paths must be canonical directories and unaliased regular files.");if(_===
|
|
1657
1657
|
e&&(d=!0),_===r&&(p=b),_===n&&b.size!==0)throw new Error("Installed catalogue lock contains unexplained data. Inspect it\
|
|
1658
1658
|
; do not unlink it.")}return{rootExists:d,catalogueStat:p}}async function s(S){let d=S.lock.topics;if(!Array.isArray(d)||
|
|
@@ -1662,19 +1662,19 @@ repository:w?.repository,commit:w?.commit,topicHash:w?.manifestHash}),A=await o.
|
|
|
1662
1662
|
"Installed topic identity differs from the approved course lock.");b.push({topicId:E.topicId,release:E.release,title:A.topicManifest.
|
|
1663
1663
|
topic.title});for(let I of A.bundles)_.push({topicId:E.topicId,topicRelease:E.release,code:I.lesson.code,hash:I.hash,title:I.
|
|
1664
1664
|
lesson.title});p.push({topicId:A.pin.topicId,release:A.release,repository:A.pin.repository,commit:A.pin.commit,topicManifest:A.
|
|
1665
|
-
topicManifest,topicHash:A.topicHash})}let v=
|
|
1665
|
+
topicManifest,topicHash:A.topicHash})}let v=tr(S.course,p);if(L(S.lock)!==L(v))throw new Error("The approved course lock\
|
|
1666
1666
|
differs from the complete installed topic inventory. Regenerate and review its exact release.");return{lessonTitles:_,topicTitles:b}}
|
|
1667
1667
|
async function a({includeLessonTitles:S=!1}={}){if(typeof S!="boolean")throw new TypeError("Lesson title projection requ\
|
|
1668
1668
|
ires an explicit Boolean read option.");try{let{catalogueStat:d}=await i();if(!d)return{schemaVersion:1,revision:0,courses:[]};
|
|
1669
|
-
if(d.size>Ii)throw new Error("Installed catalogue exceeds its 1 MiB limit.");let p=await
|
|
1670
|
-
"Installed catalogue exceeds its 1 MiB limit.");let _=ce(
|
|
1669
|
+
if(d.size>Ii)throw new Error("Installed catalogue exceeds its 1 MiB limit.");let p=await iw(r);if(p.length>Ii)throw new Error(
|
|
1670
|
+
"Installed catalogue exceeds its 1 MiB limit.");let _=ce(aw,JSON.parse(p.toString("utf8")),"Installed catalogue");if(_.courses.
|
|
1671
1671
|
length&&_.revision<1)throw new Error("Installed catalogue revision conflicts with its course inventory.");let b=new Set;
|
|
1672
1672
|
for(let v of _.courses){let w=`${v.course.courseId}@${v.course.release}`;if(b.has(w))throw new Error("Installed catalogu\
|
|
1673
1673
|
e contains duplicate course releases.");b.add(w);let{lessonTitles:E,topicTitles:A}=await s(v);S&&Object.assign(v,{lessonTitles:E,
|
|
1674
1674
|
topicTitles:A})}return _}catch(d){throw gi(`Installed catalogue is invalid: ${d.message} Keep existing state and ask the\
|
|
1675
1675
|
owner to restore the exact approved catalogue or pinned content. No automatic repair was performed.`,"VIBE64_TRAINING_C\
|
|
1676
1676
|
ATALOGUE_INVALID",d)}}async function c(){let{rootExists:S}=await i();if(!S)throw new Error("Prepare the server-owned sys\
|
|
1677
|
-
tem root before changing the catalogue.");try{await
|
|
1677
|
+
tem root before changing the catalogue.");try{await ow(t,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}await i();let d=await mt(
|
|
1678
1678
|
n);if(!d)throw ye("Installed catalogue is being updated. Retry after the current owner operation finishes.","VIBE64_TRAI\
|
|
1679
1679
|
NING_CATALOGUE_BUSY",409);return d}function u(S,d){if(S.revision!==d)throw ye("Installed catalogue changed. Read its cur\
|
|
1680
1680
|
rent revision before deliberately retrying this enablement change.","VIBE64_TRAINING_CATALOGUE_REVISION_CONFLICT",409)}async function l(S,d){
|
|
@@ -1689,7 +1689,7 @@ try{let v=await a();u(v,p),await s(_);let w=v.courses.find(E=>E.course.courseId=
|
|
|
1689
1689
|
_.course.release);if(w){if(L(w.course)!==L(_.course)||L(w.lock)!==L(_.lock))throw ye("This installed course release is i\
|
|
1690
1690
|
mmutable. Resume its approved pin or publish and approve a different course release.","VIBE64_TRAINING_COURSE_RELEASE_CO\
|
|
1691
1691
|
NFLICT",409);return w.enabled?{revision:v.revision,entry:w,changed:!1}:(w.enabled=!0,await l(v,w))}if(v.courses.length>=
|
|
1692
|
-
|
|
1692
|
+
sr)throw new Error("Installed catalogue reached its 16 course-release limit. Remove a release with vibe64 training remov\
|
|
1693
1693
|
e-course to free a place; no release was removed.");return v.courses.push(_),await l(v,_)}finally{await b()}}async function f({
|
|
1694
1694
|
courseId:S,release:d,expectedRevision:p},_){if(Ai(p),typeof S!="string"||!/^[a-z][a-z0-9-]{0,63}$/u.test(S)||typeof d!="\
|
|
1695
1695
|
string"||!/^\d+\.\d+\.\d+$/u.test(d))throw new Error(`${_?"Remove":"Disable"} an exact installed course ID and three-par\
|
|
@@ -1712,15 +1712,15 @@ topicHash})}let A={schemaVersion:1,courseId:`custom-${_.toLowerCase().replace(/[
|
|
|
1712
1712
|
slice(0,48).replace(/-+$/u,"")||J(_).slice(0,12)}`,title:_,release:"1.0.0",status:"released",topics:d.map(O=>({topicId:O.
|
|
1713
1713
|
topicId,release:O.release}))},I=b.courses.find(O=>O.course.courseId===A.courseId);if(I&&L(I.course)!==L(A))throw ye("A c\
|
|
1714
1714
|
ourse with this name already exists. Choose another name.","VIBE64_TRAINING_COURSE_EXISTS",409);if(!I&&b.courses.length>=
|
|
1715
|
-
|
|
1716
|
-
_LIMIT",{statusCode:409,params:{limit:
|
|
1717
|
-
enableCourse:m,disableCourse:h,removeCourse:y,createCourse:T})}var
|
|
1718
|
-
_n();ut();
|
|
1719
|
-
type:"boolean",required:!0}}),
|
|
1720
|
-
min:0,max:Number.MAX_SAFE_INTEGER},courses:H(Nl,
|
|
1721
|
-
import W from"node:path";import{randomUUID as
|
|
1715
|
+
sr)throw bt(`This installation already has ${sr} course releases. No course was created.`,"VIBE64_TRAINING_COURSE_CREATE\
|
|
1716
|
+
_LIMIT",{statusCode:409,params:{limit:sr}});return m({course:A,lock:tr(A,w),expectedRevision:p})}return Object.freeze({readCatalogue:a,
|
|
1717
|
+
enableCourse:m,disableCourse:h,removeCourse:y,createCourse:T})}var sr,Ii,Nl,aw,Cl=g(()=>{Pr();Fr();Pl();wn();lt();ct();_i();
|
|
1718
|
+
_n();ut();sr=16,Ii=1024*1024,Nl=$({course:{type:"object",required:!0,schema:xr},lock:{type:"object",required:!0},enabled:{
|
|
1719
|
+
type:"boolean",required:!0}}),aw=$({schemaVersion:{type:"integer",required:!0,enum:[1]},revision:{type:"integer",required:!0,
|
|
1720
|
+
min:0,max:Number.MAX_SAFE_INTEGER},courses:H(Nl,sr)})});var $l={};Ni($l,{runTrainingCli:()=>vi});import{mkdir as kl,readFile as vn,realpath as St,rename as cw,rm as xl,writeFile as Ri}from"node:fs/promises";
|
|
1721
|
+
import W from"node:path";import{randomUUID as uw}from"node:crypto";async function vi(e,{write:t=r=>console.log(r)}={}){if(e[0]===
|
|
1722
1722
|
"install-topic"){let[,c,u]=e;if(e.length!==3||!c||!u)throw new Error("Usage: vibe64 training install-topic <committed-to\
|
|
1723
|
-
pic-directory> <system-root>");let l=await
|
|
1723
|
+
pic-directory> <system-root>");let l=await St(c),{topicId:m,release:f,repository:h,commit:y,topicHash:T}=await er(l),S={
|
|
1724
1724
|
schemaVersion:1,topicId:m,release:f,repository:h,commit:y,topicHash:T},d=await Al({systemRoot:W.resolve(u)}).installTopic(
|
|
1725
1725
|
{sourceRoot:l,pin:S});return t(JSON.stringify({ok:!0,installed:d.installed,pin:d.pin},null,2)),0}if(e[0]==="installed-co\
|
|
1726
1726
|
urses"){if(e.length!==2||!e[1])throw new Error("Usage: vibe64 training installed-courses <system-root>");let c=await Oi(
|
|
@@ -1732,17 +1732,17 @@ ot> <expected-revision>`);let h=Oi({systemRoot:W.resolve(m)}),y=Number(f),T=c===
|
|
|
1732
1732
|
parse(await vn(u,"utf8")),lock:JSON.parse(await vn(l,"utf8")),expectedRevision:y}):await h[c==="remove-course"?"removeCo\
|
|
1733
1733
|
urse":"disableCourse"]({courseId:u,release:l,expectedRevision:y});return t(JSON.stringify({ok:!0,...T},null,2)),0}if(e[0]===
|
|
1734
1734
|
"publish-manifest"){let[,c,...u]=e;if(!c||!u.length)throw new Error("Usage: vibe64 training publish-manifest <course.jso\
|
|
1735
|
-
n> <committed-topic-directory...>");let l=await
|
|
1735
|
+
n> <committed-topic-directory...>");let l=await St(c),m=W.join(await St(W.dirname(W.resolve(c))),"course.lock.json");if(m===
|
|
1736
1736
|
l||W.basename(c)==="course.lock.json")throw new Error("Course lock output must not replace its input course descriptor.");
|
|
1737
|
-
let f=JSON.parse(await vn(l,"utf8")),h=[];for(let S of u){let d=await
|
|
1737
|
+
let f=JSON.parse(await vn(l,"utf8")),h=[];for(let S of u){let d=await St(S),p=W.relative(d,m);if(!p||!p.startsWith(`..${W.
|
|
1738
1738
|
sep}`)&&p!==".."&&!W.isAbsolute(p))throw new Error("Course lock output must be outside every pinned source topic.");await He(
|
|
1739
|
-
d,{authoring:!0}),h.push(await
|
|
1740
|
-
`,{flag:"wx"}),await
|
|
1739
|
+
d,{authoring:!0}),h.push(await er(d))}let y=tr(f,h),T=`${m}.tmp-${uw()}`;try{await Ri(T,`${L(y)}
|
|
1740
|
+
`,{flag:"wx"}),await cw(T,m)}finally{await xl(T,{force:!0})}return t(JSON.stringify({ok:!0,courseId:y.courseId,status:y.
|
|
1741
1741
|
status,lockPath:m,topics:y.topics.length},null,2)),0}let[r,n,o]=e;if(!["validate","bundle"].includes(r)||!n||r==="bundle"&&
|
|
1742
1742
|
!o||e.length!==(r==="bundle"?3:2))throw new Error("Usage: vibe64 training validate <topic-directory> | bundle <topic-dir\
|
|
1743
|
-
ectory> <new-output-directory>");let i=await
|
|
1743
|
+
ectory> <new-output-directory>");let i=await St(n),s=await He(i,{authoring:r==="validate"}),a={schemaVersion:1,topic:s.topic,
|
|
1744
1744
|
release:s.release,topicHash:s.topicHash,topicManifest:s.topicManifest,lessons:s.bundles.map(({lesson:c,hash:u,status:l,required:m,
|
|
1745
|
-
manifest:f})=>({code:c.code,hash:u,status:l,required:m,manifest:f}))};if(r==="bundle"){let c=W.resolve(o),u=W.join(await
|
|
1745
|
+
manifest:f})=>({code:c.code,hash:u,status:l,required:m,manifest:f}))};if(r==="bundle"){let c=W.resolve(o),u=W.join(await St(
|
|
1746
1746
|
W.dirname(c)),W.basename(c)),l=W.relative(i,u);if(!l||!l.startsWith(`..${W.sep}`)&&l!==".."&&!W.isAbsolute(l))throw new Error(
|
|
1747
1747
|
"Bundle output must be outside the source topic.");await kl(u);try{let m=Be([s.topicManifest,...s.bundles.map(f=>f.manifest)]);
|
|
1748
1748
|
for(let f of m){let h=await vn(W.join(i,f.path));if(J(h)!==f.sha256)throw new Error(`Source changed during bundling: ${f.
|
|
@@ -1751,54 +1751,54 @@ await Ri(W.join(u,"bundle.json"),`${L(a)}
|
|
|
1751
1751
|
`,{flag:"wx"})}catch(m){throw await xl(u,{recursive:!0,force:!0}),m}}return t(JSON.stringify({ok:!0,topicId:s.topic.topicId,
|
|
1752
1752
|
status:s.topic.status,lessons:s.bundles.map(({lesson:c,hash:u,status:l})=>({code:c.code,hash:u,status:l,schemaVersion:c.
|
|
1753
1753
|
schemaVersion,...c.stage?{stage:c.stage}:{},...me(c)?{steps:c.steps.length}:{}}))},null,2)),0}var Si=g(()=>{lt();ct();wn();
|
|
1754
|
-
Ol();Cl();ut()});import{spawn as jl}from"node:child_process";import{readFileSync as
|
|
1755
|
-
import
|
|
1754
|
+
Ol();Cl();ut()});import{spawn as jl}from"node:child_process";import{readFileSync as dw}from"node:fs";import{release as Sn}from"node:os";import j from"node:process";
|
|
1755
|
+
import ar from"node:path";import{fileURLToPath as pw}from"node:url";import{realpathSync as Hl}from"node:fs";import zl from"node:path";import Fl from"node:process";function Ci(e,t){let r=zl.
|
|
1756
1756
|
resolve(String(e||""));try{return t(r)}catch{return r}}function ki({entrypointPath:e,argv:t=Fl.argv,realpath:r=Hl}){let n=t[1];
|
|
1757
|
-
return n?Ci(n,r)===Ci(e,r):!1}var
|
|
1758
|
-
return`'${String(e).replaceAll("'","'\\''")}'`}function
|
|
1759
|
-
"${String(e).replaceAll('"','\\"')}"`}function
|
|
1760
|
-
...t}={}){return ki({entrypointPath:e,...t})}function Dl(e=j.cwd()){return
|
|
1757
|
+
return n?Ci(n,r)===Ci(e,r):!1}var lw=new URL("./run.js",import.meta.url).href,Ll=pw(lw),Ml=ar.dirname(Ll),It=ar.join(Ml,"server.js");function Tt(e=""){
|
|
1758
|
+
return`'${String(e).replaceAll("'","'\\''")}'`}function mw(e=""){return JSON.stringify(String(e))}function Pi(e=""){return`\
|
|
1759
|
+
"${String(e).replaceAll('"','\\"')}"`}function fw(e="",t=[]){return[Pi(e),...t.map(r=>Pi(r))].join(" ")}function hw({entrypointPath:e=Ll,
|
|
1760
|
+
...t}={}){return ki({entrypointPath:e,...t})}function Dl(e=j.cwd()){return ar.basename(e)||"target"}function gw({env:e=j.
|
|
1761
1761
|
env,osReleaseText:t=Sn(),platform:r=j.platform}={}){return r!=="linux"?!1:String(e.WSL_DISTRO_NAME||e.WSL_INTEROP||"").trim()?
|
|
1762
|
-
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function
|
|
1763
|
-
return[
|
|
1764
|
-
title:o=`Vibe64 - ${
|
|
1762
|
+
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function ww({nodePath:e=j.execPath,serverPath:t=It,serverArgs:r=[]}={}){
|
|
1763
|
+
return[Tt(e),Tt(t),...r.map(n=>Tt(n))].join(" ")}function yw({cwd:e=j.cwd(),nodePath:t=j.execPath,serverArgs:r=[],serverPath:n=It,
|
|
1764
|
+
title:o=`Vibe64 - ${ar.basename(j.cwd())||"target"}`}={}){return["finish_vibe64_terminal() {",' status="$1"',' message\
|
|
1765
1765
|
="$2"',' if [ "$status" -ne 0 ]; then',` printf '\\n%s Exit status %s. Press Enter to close this terminal...' "$messa\
|
|
1766
|
-
ge" "$status"`," IFS= read -r _"," fi",' exit "$status"',"}",`cd ${
|
|
1767
|
-
n',' finish_vibe64_terminal "$status" "Vibe64 could not enter the target directory."',"fi",`printf '\\033]0;%s\\007' ${
|
|
1768
|
-
o)}`,
|
|
1769
|
-
`)}function
|
|
1770
|
-
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",
|
|
1771
|
-
cwd:e=j.cwd(),env:t=j.env,shellScript:r="",title:n=`Vibe64 - ${Dl(e)}`}={}){let o=
|
|
1766
|
+
ge" "$status"`," IFS= read -r _"," fi",' exit "$status"',"}",`cd ${Tt(e)}`,"status=$?",'if [ "$status" -ne 0 ]; the\
|
|
1767
|
+
n',' finish_vibe64_terminal "$status" "Vibe64 could not enter the target directory."',"fi",`printf '\\033]0;%s\\007' ${Tt(
|
|
1768
|
+
o)}`,ww({nodePath:t,serverArgs:r,serverPath:n}),'finish_vibe64_terminal "$?" "Vibe64 server exited."'].join(`
|
|
1769
|
+
`)}function _w(e=""){return`printf %s ${Buffer.from(String(e||""),"utf8").toString("base64")} | base64 -d | bash`}function Ew({
|
|
1770
|
+
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",_w(t)]}function bw({
|
|
1771
|
+
cwd:e=j.cwd(),env:t=j.env,shellScript:r="",title:n=`Vibe64 - ${Dl(e)}`}={}){let o=Ew({distroName:t.WSL_DISTRO_NAME,shellScript:r});
|
|
1772
1772
|
return[{command:"wt.exe",args:["new-window","--title",n,"wsl.exe",...o]},{command:"cmd.exe",args:["/d","/c",`start ${Pi(
|
|
1773
|
-
n)} ${
|
|
1774
|
-
platform,serverArgs:i=[],serverPath:s=
|
|
1775
|
-
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${
|
|
1773
|
+
n)} ${fw("wsl.exe",o)}`]}]}function vw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Sn(),platform:o=j.
|
|
1774
|
+
platform,serverArgs:i=[],serverPath:s=It}={}){let a=`Vibe64 - ${Dl(e)}`,c=yw({cwd:e,nodePath:r,serverArgs:i,serverPath:s,
|
|
1775
|
+
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${mw(
|
|
1776
1776
|
c)}`,"end tell"].join(`
|
|
1777
1777
|
`)]}];let u=[t.TERMINAL?{command:t.TERMINAL,args:["-e","bash","-lc",c]}:null,{command:"x-terminal-emulator",args:["-e","\
|
|
1778
1778
|
bash","-lc",c]},{command:"gnome-terminal",args:["--","bash","-lc",c]},{command:"konsole",args:["-e","bash","-lc",c]},{command:"\
|
|
1779
|
-
xfce4-terminal",args:["--command",`bash -lc ${
|
|
1780
|
-
{env:t,osReleaseText:n,platform:o})?[...
|
|
1781
|
-
(n,o)=>{let i=jl(e,t,{...r,detached:!0,stdio:"ignore"});i.once("error",o),i.once("spawn",()=>{i.unref(),n(i)})})}async function
|
|
1782
|
-
cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Sn(),platform:o=j.platform,serverArgs:i=[],serverPath:s=
|
|
1783
|
-
let a=
|
|
1779
|
+
xfce4-terminal",args:["--command",`bash -lc ${Tt(c)}`]},{command:"xterm",args:["-e","bash","-lc",c]}].filter(Boolean);return gw(
|
|
1780
|
+
{env:t,osReleaseText:n,platform:o})?[...bw({cwd:e,env:t,shellScript:c,title:a}),...u]:u}function Sw(e,t=[],r={}){return new Promise(
|
|
1781
|
+
(n,o)=>{let i=jl(e,t,{...r,detached:!0,stdio:"ignore"});i.once("error",o),i.once("spawn",()=>{i.unref(),n(i)})})}async function Tw({
|
|
1782
|
+
cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Sn(),platform:o=j.platform,serverArgs:i=[],serverPath:s=It}={}){
|
|
1783
|
+
let a=vw({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),c=[];for(let u of a)try{return await Sw(
|
|
1784
1784
|
u.command,u.args,{cwd:e,env:t}),u}catch(l){c.push(l)}throw new AggregateError(c,"No supported terminal emulator could be\
|
|
1785
|
-
started.")}async function
|
|
1785
|
+
started.")}async function Iw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,serverArgs:n=[],serverPath:o=It}={}){let i=jl(
|
|
1786
1786
|
r,[o,...n],{cwd:e,env:t,stdio:"inherit"});return new Promise((s,a)=>{i.once("error",a),i.once("exit",(c,u)=>{if(u){s(1);
|
|
1787
|
-
return}s(Number(c||0))})})}function
|
|
1788
|
-
|
|
1789
|
-
terprises/vibe64/blob/main/docs/colleague-usage/${e==="darwin"?"set-up-macos":"set-up-linux"}.md`}function
|
|
1790
|
-
platform,nodeVersion:t=j.versions.node,requiredMajor:r=
|
|
1787
|
+
return}s(Number(c||0))})})}function Aw(e=ar.join(Ml,"..","package.json")){try{return/^\D*(\d+)/u.exec(String(JSON.parse(
|
|
1788
|
+
dw(e,"utf8")).engines?.node||""))?.[1]||""}catch{return""}}function Ow(e=j.platform){return`https://github.com/mobily-en\
|
|
1789
|
+
terprises/vibe64/blob/main/docs/colleague-usage/${e==="darwin"?"set-up-macos":"set-up-linux"}.md`}function Rw({platform:e=j.
|
|
1790
|
+
platform,nodeVersion:t=j.versions.node,requiredMajor:r=Aw()}={}){if(e==="win32")return["Vibe64 runs on Windows inside WS\
|
|
1791
1791
|
L2 (Ubuntu), not in PowerShell or Command Prompt.","Step by step: https://github.com/mobily-enterprises/vibe64/blob/main\
|
|
1792
1792
|
/docs/colleague-usage/set-up-windows.md"].join(`
|
|
1793
1793
|
`);let n=String(t||"").split(".")[0];return r&&n!==r?[`Vibe64 needs Node.js ${r}; this is Node.js ${t}.`,`To install it \
|
|
1794
1794
|
with mise, run: curl -fsSL https://mise.run | sh && ~/.local/bin/mise use -g node@${r}`,"Then add mise to your shell, op\
|
|
1795
|
-
en a new terminal and run npx vibe64 again:",`${
|
|
1796
|
-
`):""}async function
|
|
1797
|
-
argv.slice(2),serverPath:s=
|
|
1795
|
+
en a new terminal and run npx vibe64 again:",`${Ow(e)}#nodejs-and-mise`].join(`
|
|
1796
|
+
`):""}async function Pw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Sn(),platform:o=j.platform,serverArgs:i=j.
|
|
1797
|
+
argv.slice(2),serverPath:s=It}={}){try{return await Tw({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),
|
|
1798
1798
|
console.log("Vibe64 is starting in a new terminal window."),0}catch(a){return console.warn(`${a.message} Starting Vibe64\
|
|
1799
|
-
in this terminal instead.`),
|
|
1799
|
+
in this terminal instead.`),Iw({cwd:e,env:t,nodePath:r,serverArgs:i,serverPath:s})}}if(hw()){let e={spec:()=>Promise.resolve().then(()=>(wa(),ga)).
|
|
1800
1800
|
then(({runAgentSpecCli:n})=>n(j.argv.slice(3))),training:()=>Promise.resolve().then(()=>(Si(),$l)).then(({runTrainingCli:n})=>n(
|
|
1801
|
-
j.argv.slice(3)))},t=
|
|
1802
|
-
n}).catch(n=>{console.error("Failed to run Vibe64:",n),j.exitCode=1})}export{
|
|
1803
|
-
|
|
1804
|
-
|
|
1801
|
+
j.argv.slice(3)))},t=Rw();t&&(console.error(t),j.exit(1)),(Object.hasOwn(e,j.argv[2])?e[j.argv[2]]():Pw()).then(n=>{j.exitCode=
|
|
1802
|
+
n}).catch(n=>{console.error("Failed to run Vibe64:",n),j.exitCode=1})}export{It as SERVER_ENTRYPOINT,hw as isDirectCliExecution,gw as isWslEnvironment,Tw as launchInNewTerminal,Rw as launcherProblem,
|
|
1803
|
+
Tt as quoteShellArg,Pw as runLauncher,ww as serverShellCommand,Dl as targetNameFromCwd,vw as terminalLaunchCandidates,yw as terminalShellScript,
|
|
1804
|
+
Ew as wslServerCommandArgs,bw as wslTerminalLaunchCandidates};
|