vibe64 0.1.58 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +1070 -1054
- package/bin/server.js +392 -376
- package/bin/upgrade-state.js +4439 -4420
- package/dist/assets/{GithubBrowserTabs-D_nMB5Y1.js → GithubBrowserTabs-Vv-64NIg.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-BgO_aeUg.js → LocalDatabaseServer-rolg-sXl.js} +1 -1
- package/dist/assets/SelectField-DwWoHC2p.js +1 -0
- package/dist/assets/{ShellOutlet-Cr8SJs7s.js → ShellOutlet-Clsh2qYP.js} +1 -1
- package/dist/assets/Vibe64AuthSettingsButton-BICxvZDm.js +5 -0
- package/dist/assets/{Vibe64AuthSettingsButton-DRTKdimW.css → Vibe64AuthSettingsButton-DbL7Ukry.css} +1 -1
- package/dist/assets/{Vibe64ConversationLog-DtOgxPNR.js → Vibe64ConversationLog-K6aUo3q1.js} +4 -4
- package/dist/assets/{Vibe64ConversationLog-NH61odld.css → Vibe64ConversationLog-ksf1U6PP.css} +1 -1
- package/dist/assets/{Vibe64DashboardShell-DhPE6H3P.js → Vibe64DashboardShell-C_wkAaSb.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-Bpnbjs4l.css → Vibe64DashboardShell-D0GNI4V8.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-cfn8TTxQ.css → Vibe64DatabaseWorkspace-De4sbXAN.css} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-CHV0cd3l.js → Vibe64DatabaseWorkspace-Dy88t2ZX.js} +2 -2
- package/dist/assets/Vibe64FileArea-BU5rPyqx.js +1 -0
- package/dist/assets/{Vibe64FileArea-mydNQQl8.css → Vibe64FileArea-ZEzsvLt2.css} +1 -1
- package/dist/assets/Vibe64OutputControls-Z2K52QCc.js +8 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-DUSMn4pR.js → Vibe64RepositoryWorkspace-CWw4w5SA.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-BXt__PJL.js → Vibe64SessionFiles-DI8ZH6aF.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-NyG6niQM.js → Vibe64SessionSourceEditor-BVfoXgmZ.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-CtlJWiCY.css → Vibe64UiStoryboardView-BYLWabXY.css} +1 -1
- package/dist/assets/Vibe64UiStoryboardView-C-99xlAo.js +8 -0
- package/dist/assets/{Vibe64UnavailableSessions-CCPWJo8e.js → Vibe64UnavailableSessions-BRB2bUR_.js} +1 -1
- package/dist/assets/{_pageId_-D54CqzqG.js → _pageId_-DPJ8pvUs.js} +1 -1
- package/dist/assets/{_sessionId_-CW044RVi.js → _sessionId_-CiU1Awul.js} +1 -1
- package/dist/assets/_slug_-C5yeqlpL.js +14 -0
- package/dist/assets/{_slug_-WWvJTLoc.css → _slug_-Vy_1jrpy.css} +1 -1
- package/dist/assets/access-BH1OsqPS.css +1 -0
- package/dist/assets/access-Cq6GEVhT.js +1 -0
- package/dist/assets/{app-D9FegZf0.js → app-BKwP6m9e.js} +1 -1
- package/dist/assets/{assistantRouting-D4SnnxJn.js → assistantRouting-BS0ZW5Ki.js} +1 -1
- package/dist/assets/{changes-DtfJc780.js → changes-DT8e3wYn.js} +1 -1
- package/dist/assets/{client-Dra4Vp3A.js → client-BHa4BumO.js} +2 -2
- package/dist/assets/{client-DnjkdG6K.js → client-B_iZQVU8.js} +1 -1
- package/dist/assets/{client-BBqNv4HL.js → client-C-Rw8t8y.js} +1 -1
- package/dist/assets/{client-B8u2_Svv.css → client-CM6TGZc9.css} +1 -1
- package/dist/assets/{client-DuDOzb5A.js → client-Cf6iimPy.js} +2 -2
- package/dist/assets/{client-mU-LObHG.js → client-DWPSlYBq.js} +1 -1
- package/dist/assets/{conversation-QpMeXw70.js → conversation-CsB1b1JZ.js} +1 -1
- package/dist/assets/{conversation-La-pkh5h.css → conversation-DA_fbJJD.css} +1 -1
- package/dist/assets/{dashboard-B26QwE6y.js → dashboard-DRwBugiR.js} +1 -1
- package/dist/assets/{english-definitions-I9tIXY2u.js → english-definitions-Bi3yaDu7.js} +1 -1
- package/dist/assets/{env-BXsvM592.js → env-ObiVMW6f.js} +1 -1
- package/dist/assets/errorMessageHelpers-BjIt31kK.js +1 -0
- package/dist/assets/{errors-DErd0NON.js → errors-D17nJYne.js} +1 -1
- package/dist/assets/{health-C4WtefLm.js → health-Ev-UBIsw.js} +1 -1
- package/dist/assets/history-BSIuLgnI.css +1 -0
- package/dist/assets/history-U6UcbKBZ.js +1 -0
- package/dist/assets/{httpClient-BRO3GqjU.js → httpClient-Bwitq9Xf.js} +1 -1
- package/dist/assets/i18n-BkxO7BMl.js +1 -0
- package/dist/assets/index-Ctygjyf8.css +1 -0
- package/dist/assets/index-Wcdz2Rey.js +134 -0
- package/dist/assets/{integrations-CQNJxkMu.js → integrations-BHURBo17.js} +3 -3
- package/dist/assets/{integrations-CrI893NK.css → integrations-Bo_beIy3.css} +1 -1
- package/dist/assets/issues-D4Asc_wa.css +1 -0
- package/dist/assets/issues-DEzrDqDU.js +1 -0
- package/dist/assets/{learning-0cINHUSN.js → learning-BrBAyLFt.js} +1 -1
- package/dist/assets/{pages-DbF-yXqO.js → pages-5jaEclQo.js} +1 -1
- package/dist/assets/{pages-CIKw99GN.js → pages-BTk_FkDr.js} +1 -1
- package/dist/assets/{pathname-DOqQPPVa.js → pathname-JHQIKk21.js} +1 -1
- package/dist/assets/{placement-BAaZQhAh.js → placement-1lT0lW3-.js} +1 -1
- package/dist/assets/{placement-Lk1Lpy6s.js → placement-B2V88UDJ.js} +1 -1
- package/dist/assets/{project-files-CklWobqZ.js → project-files-CTGwnBh7.js} +1 -1
- package/dist/assets/publish-BYZ7KRzq.js +3 -0
- package/dist/assets/{publish-DOybV3Qz.css → publish-C9O0tDPB.css} +1 -1
- package/dist/assets/{pull-requests-ybnixBv0.js → pull-requests-C-puL4SG.js} +1 -1
- package/dist/assets/{pull-requests-DnEm9m_1.css → pull-requests-DgWKsMdI.css} +1 -1
- package/dist/assets/{repository-wJZei_NJ.js → repository-DknGo0hr.js} +1 -1
- package/dist/assets/settings-BKZcbISO.css +1 -0
- package/dist/assets/settings-BmOQ1NnW.js +1 -0
- package/dist/assets/{shared-X5MxTHwl.js → shared-B6plZPQ_.js} +1 -1
- package/dist/assets/{studioGateApi-CHIdcQvD.js → studioGateApi-UqmdV50W.js} +1 -1
- package/dist/assets/{studioUrls-oIU1Eq_t.js → studioUrls-k_pQIuPs.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-DI9ow2ds.js +1 -0
- package/dist/assets/useCommand-YOAaO5Wz.js +1 -0
- package/dist/assets/{useEndpointResource-61E93qP-.js → useEndpointResource-CmMwteuX.js} +1 -1
- package/dist/assets/{usePaths-B-QGqa_I.js → usePaths-CvUbx5-V.js} +1 -1
- package/dist/assets/{useUiFeedback-CycH_fvY.js → useUiFeedback-Bixow9mW.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-BkcPA64C.js +2 -0
- package/dist/assets/{useVibe64Learning-DZCyrfpy.js → useVibe64Learning-RE4HXHqo.js} +1 -1
- package/dist/assets/{useVibe64SessionData-rBvWMqyc.js → useVibe64SessionData-Df7M5k1M.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-C546mBu8.js → useVibe64SessionSelection-B0USk6X6.js} +1 -1
- package/dist/assets/validators-HqYRjxEO.js +1 -0
- package/dist/assets/{vibe64FileUpload-D0Lv2mMJ.js → vibe64FileUpload-BDkcaUyk.js} +1 -1
- package/dist/assets/vibe64GithubProject-CJneIo5O.js +1 -0
- package/dist/assets/vibe64RepositoryRealtime-DKSXVg1B.js +1 -0
- package/dist/assets/vibe64SessionFocus-BJLy8eTE.js +1 -0
- package/dist/assets/vibe64SessionFocus-DdYRpG72.css +1 -0
- package/dist/index.html +26 -24
- package/docs/colleague-usage/ai-tasks.md +15 -4
- package/docs/colleague-usage/coding-agent-recovery.md +3 -1
- package/docs/colleague-usage/coding-agents.md +19 -1
- package/docs/colleague-usage/connected-repositories.md +16 -4
- package/docs/colleague-usage/files.md +2 -1
- package/docs/colleague-usage/github-work.md +50 -11
- package/docs/colleague-usage/health-checks.md +1 -1
- package/docs/colleague-usage/preview-browser-checks.md +3 -0
- package/docs/colleague-usage/preview.md +29 -0
- package/docs/colleague-usage/project-messages.md +3 -2
- package/docs/colleague-usage/project-settings.md +3 -0
- package/docs/colleague-usage/session-archive.md +9 -0
- package/docs/colleague-usage/sessions.md +5 -4
- package/docs/colleague-usage/temporary-chats.md +4 -3
- package/docs/colleague-usage/usage-map.md +3 -2
- package/docs/colleague-usage/workspace-preparation.md +12 -0
- package/node_modules/@jskit-ai/agent/CHANGELOG.md +5 -0
- package/node_modules/@jskit-ai/agent/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +8 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +4 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-core/README.md +4 -0
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +7 -0
- package/node_modules/@jskit-ai/kernel/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +428 -423
- package/node_modules/@local/vibe64-genesis/bin/genesis +17 -11
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +830 -816
- package/node_modules/@local/vibe64-genesis/src/server/index.js +533 -519
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +172 -169
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +490 -479
- package/node_modules/@local/vibe64-source-editor/src/server/searchIndexWorker.js +12 -11
- package/node_modules/@local/vibe64-system-graph/README.md +9 -5
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +262 -252
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1060 -1018
- package/node_modules/json-rest-schema/README.md +3 -1
- package/node_modules/json-rest-schema/package.json +1 -1
- package/package.json +17 -17
- package/server.bundle.mjs +43046 -42780
- package/dist/assets/Vibe64AuthSettingsButton-Bx9patil.js +0 -5
- package/dist/assets/Vibe64FileArea-DIDyAUvD.js +0 -1
- package/dist/assets/Vibe64OutputControls-mNWUWLSm.js +0 -8
- package/dist/assets/Vibe64UiStoryboardView-BXH2MSWn.js +0 -8
- package/dist/assets/_slug_-CRtFhc0A.js +0 -14
- package/dist/assets/access-ChMLRErk.js +0 -1
- package/dist/assets/access-Cm2lrMF6.css +0 -1
- package/dist/assets/errorMessageHelpers-L2GsOwCP.js +0 -1
- package/dist/assets/history-BhqQz5jH.css +0 -1
- package/dist/assets/history-HHPFoNi3.js +0 -1
- package/dist/assets/index-BBfSvf2i.css +0 -1
- package/dist/assets/index-Bvd00puv.js +0 -134
- package/dist/assets/issues-BHr_nI-9.js +0 -1
- package/dist/assets/issues-CpBRQTQ_.css +0 -1
- package/dist/assets/publish-Cot797YN.js +0 -3
- package/dist/assets/settings-DJByC5Wb.js +0 -1
- package/dist/assets/settings-bEkDjn0Y.css +0 -1
- package/dist/assets/useArchivedVibe64Sessions-B-DtXrk-.js +0 -1
- package/dist/assets/useCommand-D96utlVe.js +0 -1
- package/dist/assets/useVibe64ConversationLog-BVANhCHq.js +0 -2
- package/dist/assets/validators-B3YzM6px.js +0 -1
- package/dist/assets/vibe64GithubProject-DNl0aDcC.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-BPsE5l5E.js +0 -1
- package/dist/assets/vibe64SessionFocus-CxX2nK6F.js +0 -1
- package/dist/assets/vibe64SessionFocus-DW73PN_o.css +0 -1
package/bin/run.js
CHANGED
|
@@ -1,304 +1,310 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
ditor/src/server/agentSpecs.js",import.meta.url).href,
|
|
5
|
-
[{name:"integration-setup-command",title:"Integration setup command protocol and integrations.json",text:
|
|
3
|
+
var ql=Object.defineProperty;var g=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var xi=(e,t)=>{for(var r in t)ql(e,r,{get:t[r],enumerable:!0})};import{readFile as Xl}from"node:fs/promises";var Kl,Li,Mi,Di=g(()=>{Kl=new URL("./../node_modules/@local/vibe64-source-e\
|
|
4
|
+
ditor/src/server/agentSpecs.js",import.meta.url).href,Li=e=>()=>Xl(new URL(`../../docs/${e}`,Kl),"utf8"),Mi=Object.freeze(
|
|
5
|
+
[{name:"integration-setup-command",title:"Integration setup command protocol and integrations.json",text:Li("application\
|
|
6
6
|
-integration-setup.md")},{name:"integration-payments-laravel",title:"Implementing the integration setup payment operatio\
|
|
7
|
-
ns in Laravel",text:
|
|
8
|
-
return!!(e&&typeof e=="object"&&!Array.isArray(e))}var
|
|
9
|
-
dBack","unknown"])});function dr(e){return B(e)?{...e}:{}}var
|
|
7
|
+
ns in Laravel",text:Li("application-payments-laravel.md")}])});var Ot,ur,Ql,lr,Ui=g(()=>{Ot="email",ur="login",Ql="user-id",lr=Object.freeze([Ot,ur,Ql])});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 Vw,G=g(()=>{Vw=Object.freeze(["none","pending","committed","rolle\
|
|
9
|
+
dBack","unknown"])});function dr(e){return B(e)?{...e}:{}}var An=g(()=>{G()});var ae,pr=g(()=>{An();ae=class extends Error{constructor(t,r,n={}){super(r,n.cause===void 0?void 0:{cause:n.cause}),this.
|
|
10
10
|
name="AppError",this.status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=dr(n.params),
|
|
11
11
|
n.messageCode&&(this.messageCode=String(n.messageCode),this.messageParams=dr(n.messageParams)),this.details=n.details,this.
|
|
12
|
-
headers=n.headers||{}}}});var
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
headers=n.headers||{}}}});var Vi=g(()=>{G()});var Gi=g(()=>{G()});function Y(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||
|
|
13
|
+
ed(t)}function ed(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}
|
|
14
|
+
var tt=g(()=>{});function On(e){return e!==null&&typeof e=="object"&&Y(e.structure)&&Y(e.operations)&&typeof e.validateWith=="function"&&
|
|
15
15
|
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function mr(e,t){if(!Object.hasOwn(t,"items"))return null;
|
|
16
|
-
let{items:r}=t;if(
|
|
17
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
18
|
-
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(
|
|
16
|
+
let{items:r}=t;if(On(r))return{kind:"schema",schema:r};if(!Y(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 Pt(e,t){
|
|
18
|
+
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(On(r))return{kind:"schema",schema:r};if(!Y(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
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
|
-
s: true.`);if(r){if(!
|
|
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
|
|
27
|
-
()
|
|
28
|
-
let n
|
|
24
|
+
s: true.`);if(r){if(!On(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:Pt(
|
|
26
|
+
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}var Pn=g(()=>{tt()});function rt(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}function Rn(e,t=""){
|
|
27
|
+
if(Y(e))for(let[r,n]of Object.entries(e)){if(!Y(n))continue;let o=t?`${t}.${r}`:r;for(let i of["minItems","maxItems"]){if(!Object.
|
|
28
|
+
hasOwn(n,i))continue;let s=n[i];if(n.type!=="array"||!Number.isInteger(s)||s<0)throw new Error(`Field "${o}" ${i} must b\
|
|
29
|
+
e a non-negative integer on an array field.`)}if(n.minItems>n.maxItems)throw new Error(`Field "${o}" minItems (${n.minItems}\
|
|
30
|
+
) is above its maxItems (${n.maxItems}).`);n.type==="array"&&Y(n.items)&&typeof n.items.type=="string"&&Rn({"[]":n.items},
|
|
31
|
+
o)}}var hr=g(()=>{tt()});function sd(e){return e%4===0&&(e%100!==0||e%400===0)}function ad(e,t){return t===2?sd(e)?29:28:id[t-1]}function Ki(e,t,r){
|
|
32
|
+
let n=Number(e),o=Number(t),i=Number(r);return o>=1&&o<=12&&i>=1&&i<=ad(n,o)}function Rt(e,t){let r=e.temporalPrecision;
|
|
29
33
|
if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(`temporalPrecision for "${t}" must be a non-negative integer\
|
|
30
|
-
.`);return r}}function
|
|
31
|
-
let t=
|
|
32
|
-
null&&
|
|
33
|
-
|
|
34
|
-
return`^${
|
|
35
|
-
let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&
|
|
36
|
-
r)||r<-t||r>t?null:r===0?0:r}var
|
|
37
|
-
\\d{4}",
|
|
38
|
-
](?:${
|
|
39
|
-
new RegExp(`^${
|
|
40
|
-
|
|
41
|
-
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function
|
|
42
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
43
|
-
let o=r?
|
|
34
|
+
.`);return r}}function Xi(e,t){return e===void 0?!0:t===void 0||e.length<=t}function Qi(e){if(typeof e!="string")return!1;
|
|
35
|
+
let t=td.exec(e);return t!==null&&Ki(t[1],t[2],t[3])}function Zi(e,t){if(typeof e!="string")return!1;let r=rd.exec(e);return r!==
|
|
36
|
+
null&&Xi(r[1],t)}function es(e,t){if(typeof e!="string")return!1;let r=nd.exec(e);return r===null?!1:Ki(r[1],r[2],r[3])&&
|
|
37
|
+
Xi(r[4],t)}function ts(e){return e===void 0?"(?:\\.\\d+)?":e===0?"":`(?:\\.\\d{1,${e}})?`}function rs(e,t){let r=Rt(e,t);
|
|
38
|
+
return`^${gr}(?::${nt}${ts(r)})?$`}function ns(e,t){let r=Rt(e,t);return`^${Yi}T${gr}:${nt}${ts(r)}${qi}$`}function Cn(e,t){
|
|
39
|
+
let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&od.test(e))r=Number(e);else return null;return!Number.isSafeInteger(
|
|
40
|
+
r)||r<-t||r>t?null:r===0?0:r}var Nn,Bi,Hi,zi,Fi,nt,gr,qi,Wi,Yi,Ji,td,rd,nd,od,id,kn=g(()=>{Nn="^(?:0|-?[1-9]\\d*)$",Bi="\
|
|
41
|
+
\\d{4}",Hi="0[1-9]|1[0-2]",zi="0[1-9]|[12]\\d|3[01]",Fi="[01]\\d|2[0-3]",nt="[0-5]\\d",gr=`(?:${Fi}):${nt}`,qi=`(?:Z|[+-\
|
|
42
|
+
](?:${Fi}):${nt})`,Wi=`(${Bi})-(${Hi})-(${zi})`,Yi=`${Bi}-(?:${Hi})-(?:${zi})`,Ji=`^${Yi}$`,td=new RegExp(`^${Wi}$`),rd=
|
|
43
|
+
new RegExp(`^${gr}(?::${nt}(?:\\.(\\d+))?)?$`),nd=new RegExp(`^${Wi}T${gr}:${nt}(?:\\.(\\d+))?${qi}$`),od=new RegExp(Nn),
|
|
44
|
+
id=[31,28,31,30,31,30,31,31,30,31,30,31]});function P(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function ud(e,t){if(cd.
|
|
45
|
+
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function ld(e){return typeof e!="string"?e:e.replace(
|
|
46
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function xn(e,t,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
47
|
+
let o=r?ld(e):e;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${t}() expects a non-empty \
|
|
44
48
|
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)
|
|
46
|
-
[
|
|
47
|
-
ject"&&!Array.isArray(n)&&!Array.isArray(o)){
|
|
49
|
+
for(let s of i)ud(s,t);return i}var cd,Nt=g(()=>{cd=new Set(["__proto__","prototype","constructor"])});function os(e){return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Nn}]}}function Me(e,t){return{
|
|
50
|
+
[Te]:{[e]:t}}}function Un(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\
|
|
51
|
+
ject"&&!Array.isArray(n)&&!Array.isArray(o)){Un(o,n);continue}e[r]=n}}function gd(e,t){if(!t||typeof t!="object"||Array.
|
|
48
52
|
isArray(t))throw new Error("JSON Schema export hooks must return an object or null.");for(let r of Object.keys(t)){if(r===
|
|
49
|
-
|
|
50
|
-
e[r]=t[r]}}function
|
|
51
|
-
1?e:{anyOf:n}}function
|
|
52
|
-
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n=
|
|
53
|
-
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
54
|
-
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=
|
|
53
|
+
Te&&e[r]&&typeof e[r]=="object"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){Un(e[r],t[r]);continue}
|
|
54
|
+
e[r]=t[r]}}function wd(e,t){let n=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return n.length===
|
|
55
|
+
1?e:{anyOf:n}}function yd(e,t){if(!Object.hasOwn(e.types,t.type))throw new Error(`No casting function for type: ${t.type}`);
|
|
56
|
+
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n=fd[t.type];if(!n)throw new Error(
|
|
57
|
+
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function _d(e,t,r){if(!Object.
|
|
58
|
+
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=hd[t];
|
|
55
59
|
if(o)return o;throw new Error(`Validator '${t}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
56
|
-
hook.`)}function
|
|
57
|
-
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
58
|
-
void 0&&t.operation!==void 0){let r=
|
|
60
|
+
hook.`)}function is(e){if(e===void 0)return"create";if(["create","replace","patch"].includes(e))return e;throw new Error(
|
|
61
|
+
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function Ed(e,t={}){if(t.mode!==
|
|
62
|
+
void 0&&t.operation!==void 0){let r=is(t.mode);if(r!==t.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
59
63
|
s: mode '${r}' does not match operation '${t.operation}'.`)}if(t.operation!==void 0){if(!Object.hasOwn(e.operations,t.operation))
|
|
60
|
-
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return
|
|
64
|
+
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return is(t.mode)}function bd(e,t={}){
|
|
61
65
|
if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
|
|
62
|
-
let r=
|
|
63
|
-
t,
|
|
64
|
-
e[
|
|
65
|
-
"_").replace(/^_+|_+$/g,"")||"operation"}function
|
|
66
|
-
function
|
|
67
|
-
r&&i.operation===n&&i.additionalProperties===o)||null}function
|
|
68
|
-
return e.nextDefinitionId+=1,n}function
|
|
66
|
+
let r=Ed(e,t);return{operationName:r,operation:e.operations[r]}}function vd(e={}){let t={...e};return Object.defineProperty(
|
|
67
|
+
t,jn,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function yr(e={}){return e[jn]?
|
|
68
|
+
e[jn]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function Sd(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
|
|
69
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function Ln(e){return Y(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
|
|
70
|
+
function wr(e){return Ln(e)?{allOf:[e]}:e}function Id(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
|
|
71
|
+
r&&i.operation===n&&i.additionalProperties===o)||null}function Td(e,t){let r=Sd(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
72
|
+
return e.nextDefinitionId+=1,n}function ss(e,t,r,n,o,{root:i=!1}={}){let s=yr(t),a=Id(s,e,r,n,o);if(a)return i&&(a.pointer=
|
|
69
73
|
"#",s.rootNode=a),a;let c={schema:e,operationName:r,operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
70
|
-
|
|
71
|
-
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=
|
|
72
|
-
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=
|
|
73
|
-
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function
|
|
74
|
-
let i=
|
|
75
|
-
referenceBacked:t}}function
|
|
74
|
+
Td(s,r),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function as(e,t){
|
|
75
|
+
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=yr(t);e.status="build\
|
|
76
|
+
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=Ad(e.schema,t,e.operationName,e.operation,e.additionalProperties);
|
|
77
|
+
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function Vn(e,t,r,n,o=!1){
|
|
78
|
+
let i=yr(t),s=ss(e,t,r,n,o);return i.rootNode===s?{$ref:"#"}:as(s,t)}function Ct(e,{referenceBacked:t=!1}={}){return{schema:e,
|
|
79
|
+
referenceBacked:t}}function Ad(e,t,r,n,o=!1){let i={},s=[];for(let[c,u]of Object.entries(e.structure))P(i,c,Gn(e,c,u,t,r,
|
|
76
80
|
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
|
|
78
|
-
n,"replace",s.schema.operations.replace,!1)),[
|
|
79
|
-
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return
|
|
80
|
-
let s=
|
|
81
|
-
[
|
|
82
|
-
place"?e.operations.replace:i;return
|
|
83
|
-
t,r);if(a.kind==="nested")return Ct(
|
|
84
|
-
"opaque")return Ct({type:"object",additionalProperties:!0});if(a.kind==="map")return Ct({type:"object",additionalProperties:
|
|
85
|
-
e,t,r,n,o,i)})}let s=
|
|
81
|
+
0&&(a.required=s),a}function Od(e,t,r,n,o,i){let s=mr(t,r);if(!s)return null;if(s.kind==="schema")return{...wr(Vn(s.schema,
|
|
82
|
+
n,"replace",s.schema.operations.replace,!1)),[Te]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,
|
|
83
|
+
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return Gn(e,`${t}[]`,r.items,n,a,c)}function Pd(e,t,r,n,o,i){
|
|
84
|
+
let s=Pt(t,r);if(!s)return null;if(s.kind==="schema")return{...wr(Vn(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
85
|
+
[Te]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="re\
|
|
86
|
+
place"?e.operations.replace:i;return Gn(e,`${t}.*`,s.definition,n,a,c)}function Rd(e,t,r,n,o,i){if(r.type==="object"){let a=fr(
|
|
87
|
+
t,r);if(a.kind==="nested")return Ct(Vn(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
88
|
+
"opaque")return Ct({type:"object",additionalProperties:!0});if(a.kind==="map")return Ct({type:"object",additionalProperties:Pd(
|
|
89
|
+
e,t,r,n,o,i)})}let s=yd(e,r)({schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n});if(!s||typeof s!="object"||
|
|
86
90
|
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=
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
continue;let h=
|
|
91
|
-
c[
|
|
92
|
-
let m=
|
|
91
|
+
"array"){let a=Od(e,t,r,n,o,i);if(a)return Ct({...s,items:a},{referenceBacked:Ln(s)})}return Ct(s,{referenceBacked:Ln(s)})}
|
|
92
|
+
function Gn(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n},a=Rd(e,t,r,n,o,i),c=a.referenceBacked?
|
|
93
|
+
wr(a.schema):{...a.schema},u={castType:r.type};for(let f of Object.keys(r)){if(f==="type"||!Object.hasOwn(e.validators,f))
|
|
94
|
+
continue;let h=_d(e,f,t);if(!h)continue;let y=h({...s,parameterName:f,parameterValue:r[f],fieldSchema:{...c}});y&&gd(c,y)}
|
|
95
|
+
c[Te]&&(Un(u,c[Te]),delete c[Te]);let l=[];r.nullable===!0&&l.push({type:"null"}),r.nullOnEmpty===!0&&l.push({const:""});
|
|
96
|
+
let m=wr(wd(c,l));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.defaultTo!="function"){let f=e._normalizeDefault(
|
|
93
97
|
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
94
98
|
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
|
-
nvalid (${h.code}).`)}m.default=f.value}else u.defaults={providedByFunction:!0};return m[
|
|
96
|
-
t),{operationName:n,operation:o}=
|
|
97
|
-
o,i,{root:!0}),c={$schema:
|
|
98
|
-
|
|
99
|
-
ema"
|
|
100
|
-
"y","on"],
|
|
99
|
+
nvalid (${h.code}).`)}m.default=f.value}else u.defaults={providedByFunction:!0};return m[Te]=u,m}function cs(e,t={}){let r=vd(
|
|
100
|
+
t),{operationName:n,operation:o}=bd(e,r),i=r.additionalProperties===void 0?!1:r.additionalProperties,s=yr(r),a=ss(e,r,n,
|
|
101
|
+
o,i,{root:!0}),c={$schema:dd,...as(a,r)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}var dd,
|
|
102
|
+
Te,$n,jn,pd,md,fd,hd,us=g(()=>{Pn();hr();kn();tt();Nt();dd="http://json-schema.org/draft-07/schema#",Te="x-json-rest-sch\
|
|
103
|
+
ema",$n=["object","array","string","number","boolean"],jn=Symbol("json-rest-schema.exportContext"),pd=["true","1","yes",
|
|
104
|
+
"y","on"],md=["false","0","no","n","off"];fd={none:()=>({type:$n}),blob:()=>({type:$n}),serialize:()=>({type:$n}),object:()=>({
|
|
101
105
|
type:"object"}),array:()=>({type:"array"}),file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["n\
|
|
102
|
-
umber","string"]}),integer:()=>({type:["integer","string"]}),epochMilliseconds:()=>
|
|
103
|
-
dateTime:({definition:e,fieldName:t})=>({type:"string",format:"date-time",pattern:
|
|
104
|
-
date",pattern:
|
|
105
|
-
strictBoolean===!0)return{type:"boolean"};let t=new Set([...
|
|
106
|
-
[...
|
|
107
|
-
{type:"string",enum:[...r,...t]}]}},id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
106
|
+
umber","string"]}),integer:()=>({type:["integer","string"]}),epochMilliseconds:()=>os(864e13),epochSeconds:()=>os(864e10),
|
|
107
|
+
dateTime:({definition:e,fieldName:t})=>({type:"string",format:"date-time",pattern:ns(e,t)}),date:()=>({type:"string",format:"\
|
|
108
|
+
date",pattern:Ji}),time:({definition:e,fieldName:t})=>({type:"string",pattern:rs(e,t)}),boolean:({definition:e})=>{if(e.
|
|
109
|
+
strictBoolean===!0)return{type:"boolean"};let t=new Set([...pd,String(e.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set(
|
|
110
|
+
[...md,String(e.stringFalseWhen||"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},
|
|
111
|
+
{type:"string",enum:[...r,...t]}]}},id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},hd={minLength:({
|
|
108
112
|
definition:e,parameterValue:t})=>e.type==="string"?{minLength:t}:null,maxLength:({definition:e,parameterValue:t})=>e.type===
|
|
109
|
-
"string"?{maxLength:t}:null,min:({definition:e,parameterValue:t})=>
|
|
113
|
+
"string"?{maxLength:t}:null,min:({definition:e,parameterValue:t})=>rt(e)?{minimum:t}:null,max:({definition:e,parameterValue:t})=>rt(
|
|
110
114
|
e)?{maximum:t}:null,pattern:({definition:e,parameterValue:t})=>e.type==="string"?{pattern:t instanceof RegExp?t.source:t}:
|
|
111
|
-
null,enum:({parameterValue:e})=>({enum:e}),
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
o=
|
|
122
|
-
|
|
123
|
-
function
|
|
115
|
+
null,enum:({parameterValue:e})=>({enum:e}),minItems:({definition:e,parameterValue:t})=>e.type==="array"?{minItems:t}:null,
|
|
116
|
+
maxItems:({definition:e,parameterValue:t})=>e.type==="array"?{maxItems:t}:null,notEmpty:({parameterValue:e,definition:t})=>!e||
|
|
117
|
+
t.type==="array"?null:{minLength:1},uppercase:({parameterValue:e})=>e?Me("transforms",{uppercase:!0}):null,lowercase:({parameterValue:e})=>e?
|
|
118
|
+
Me("transforms",{lowercase:!0}):null,length:({parameterValue:e})=>Me("transforms",{length:e}),unsigned:({parameterValue:e})=>e?
|
|
119
|
+
Me("metadata",{unsigned:!0}):null,precision:({parameterValue:e})=>Me("metadata",{precision:e}),scale:({parameterValue:e})=>Me(
|
|
120
|
+
"metadata",{scale:e}),temporalPrecision:({parameterValue:e})=>Me("metadata",{temporalPrecision:e}),strictBoolean:()=>null,
|
|
121
|
+
required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null}});function ls(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Wn(e){return e instanceof
|
|
122
|
+
st}function Nd(){return{self:!1,children:{}}}function ds(e){return Object.keys(e.children).length>0}function De(e,t){return`${e}\
|
|
123
|
+
.${String(t)}`}function ws(e,t){return e===""?String(t):De(e,t)}function ps(e,t){if(e===t)return"";let r=`${t}.`;return e.
|
|
124
|
+
startsWith(r)?e.slice(r.length):null}function ot(e,t){let r={};for(let n of Object.values(e)){let o=De(t,n.field);P(r,o,
|
|
125
|
+
{...n,field:o})}return r}function Fn(e){return xn(e,"validatePath")}function ms(e){let t={};for(let r of e){let n=Fn(r),
|
|
126
|
+
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||P(o,s,Nd()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
127
|
+
return t}function Cd(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}
|
|
128
|
+
function _r(e){return e===null?!0:Array.isArray(e)||Y(e)?Object.keys(e).length>0:e!==void 0}function fs(e){return[...e].
|
|
124
129
|
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
|
-
function
|
|
130
|
+
function kd(e){return/^[0-9]+$/.test(e)}function xd(e,t=new WeakMap){if(t.has(e))return t.get(e);let r=Object.create(st.
|
|
126
131
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
127
|
-
Er(
|
|
128
|
-
"object")return e;if(
|
|
132
|
+
br(Er(e.structure,t)),r._installOperationMethods(),Object.freeze(r)}function Er(e,t=new WeakMap){if(e===null||typeof e!=
|
|
133
|
+
"object")return e;if(Wn(e))return xd(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
129
134
|
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 Er(
|
|
134
|
-
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=
|
|
135
|
-
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:
|
|
136
|
-
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!
|
|
137
|
-
n,i);return o.kind==="schema"?s.length<1?null:
|
|
138
|
-
function
|
|
139
|
-
"");n.length>0?r.skipFields=n:delete r.skipFields}if(
|
|
140
|
-
let s=
|
|
141
|
-
let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(", ")}.`)}function
|
|
135
|
+
for(let o of e)n.push(Er(o,t));return n}if(!Y(e))return e;let r={};t.set(e,r);for(let[n,o]of Object.entries(e))P(r,n,Er(
|
|
136
|
+
o,t));return r}function br(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||Wn(e))return e;if(t.add(e),Array.
|
|
137
|
+
isArray(e))for(let r of e)br(r,t);else for(let r of Reflect.ownKeys(e))br(e[r],t);return Object.freeze(e)}function Bn(e){
|
|
138
|
+
return br(Er(e))}function qn(e,t,r=""){if(!Wn(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;if(!Object.hasOwn(
|
|
139
|
+
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=ws(r,n);return ys(e,i,o,s)}function ys(e,t,r,n){
|
|
140
|
+
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:qn(o.schema,r,n)}if(t?.type===
|
|
141
|
+
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!kd(i))return null;let a=De(
|
|
142
|
+
n,i);return o.kind==="schema"?s.length<1?null:qn(o.schema,s,a):s.length<1?o.definition:ys(e,o.definition,s,a)}return null}
|
|
143
|
+
function it(e,t){let r={...e};if(Array.isArray(e.skipFields)){let n=e.skipFields.map(o=>ps(o,t)).filter(o=>o!==null&&o!==
|
|
144
|
+
"");n.length>0?r.skipFields=n:delete r.skipFields}if(Y(e.skipParams)){let n={};for(let[o,i]of Object.entries(e.skipParams)){
|
|
145
|
+
let s=ps(o,t);s===null||s===""||P(n,s,i)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}function hs(e,t,r,n){
|
|
146
|
+
let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(", ")}.`)}function zn(e,t,r,n=!0){
|
|
142
147
|
let o=t[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${e}" must define ${r} as a boolean.`)}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
145
|
-
["validated","input"]),
|
|
148
|
+
function jd(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`Operation "${e}" must be an object.`);
|
|
149
|
+
return hs(e,t,"targetFields",["schema","input"]),zn(e,t,"enforceRequired"),zn(e,t,"applyDefaults"),hs(e,t,"outputFields",
|
|
150
|
+
["validated","input"]),zn(e,t,"rejectExplicitUndefined",!1),Object.freeze({targetFields:t.targetFields,enforceRequired:t.
|
|
146
151
|
enforceRequired,applyDefaults:t.applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.rejectExplicitUndefined===
|
|
147
|
-
void 0?!0:t.rejectExplicitUndefined})}function
|
|
148
|
-
"Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
149
|
-
entries(e))
|
|
150
|
-
e))
|
|
151
|
-
()=>{
|
|
152
|
-
outputFields:"validated",rejectExplicitUndefined:!0}),replace:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
153
|
-
outputFields:"validated",rejectExplicitUndefined:!0}),patch:Object.freeze({targetFields:"input",enforceRequired:!1,
|
|
154
|
-
outputFields:"input",rejectExplicitUndefined:!0})});
|
|
155
|
-
validators=
|
|
156
|
-
|
|
157
|
-
{field:t,code:r,message:n,params:o},i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null
|
|
158
|
-
r[n].includes(t))}_fieldToBeSkipped(t,r){return Array.isArray(r.skipFields)&&r.skipFields.includes(
|
|
159
|
-
for(let[n,o]of Object.entries(r))
|
|
152
|
+
void 0?!0:t.rejectExplicitUndefined})}function Ld(e={}){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(
|
|
153
|
+
"Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries($d))P(t,r,n);for(let[r,n]of Object.
|
|
154
|
+
entries(e))P(t,r,jd(r,n));return Object.freeze(t)}function gs(e){let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
155
|
+
e))P(t,r,n);return Object.freeze(t)}function Md(e){let t={...e};return delete t.operation,delete t.mode,t}var Hn,$d,st,_s=g(
|
|
156
|
+
()=>{us();Pn();Nt();tt();hr();Hn=new WeakMap;$d=Object.freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
157
|
+
applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),replace:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
158
|
+
applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),patch:Object.freeze({targetFields:"input",enforceRequired:!1,
|
|
159
|
+
applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});st=class{constructor(t,r,n,o={}){Rn(t),this.structure=
|
|
160
|
+
t,this.types=gs(r),this.validators=gs(n),this.operations=Ld(o),this._installOperationMethods()}_typeError(t){return this.
|
|
161
|
+
_paramError(t,"TYPE_CAST_FAILED","Value could not be cast to the required type.")}_paramError(t,r,n,o={}){let i=new Error(
|
|
162
|
+
n);return i.errorObject={field:t,code:r,message:n,params:o},i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?
|
|
163
|
+
!1:!!(Array.isArray(r[n])&&r[n].includes(t))}_fieldToBeSkipped(t,r){return Array.isArray(r.skipFields)&&r.skipFields.includes(
|
|
164
|
+
t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))P(t,n,o)}_singleErrorMap(t){let r={};return P(r,t.field,t),r}_assertSupportedOptions(t={}){
|
|
160
165
|
if(Object.hasOwn(t,"onlyObjectValues"))throw new Error("Unsupported validation option `onlyObjectValues`. Call `patch()`\
|
|
161
166
|
directly.");if(Object.hasOwn(t,"mode"))throw new Error("Unsupported validation option `mode`. Call `validateWith()` or \
|
|
162
167
|
an operation method directly.");if(Object.hasOwn(t,"operation"))throw new Error("Unsupported validation option `operatio\
|
|
163
168
|
n`. Call `validateWith()` or an operation method directly.")}_buildOperationSettings(t,r,n){return{operationName:t,operation:r,
|
|
164
169
|
targetFieldNames:r.targetFields==="input"?Object.keys(n):Object.keys(this.structure),outputFieldNames:r.outputFields==="\
|
|
165
170
|
input"?Object.keys(n):Object.keys(this.structure),enforceRequired:r.enforceRequired,applyDefaults:r.applyDefaults,rejectExplicitUndefined:r.
|
|
166
|
-
rejectExplicitUndefined,defaultedFields:new Set,isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!
|
|
171
|
+
rejectExplicitUndefined,defaultedFields:new Set,isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!Y(
|
|
167
172
|
r))throw new Error(`${t}() expects a plain object input.`)}_resolvePathValidationRequest(t={}){let r=t.operation??t.mode??
|
|
168
173
|
"patch";if(Object.hasOwn(t,"operation")&&Object.hasOwn(t,"mode")&&t.operation!==t.mode)throw new Error("Path validation \
|
|
169
174
|
options `operation` and `mode` must match when both are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(
|
|
170
|
-
`Unknown operation "${r}".`);let n=this.operations[r];return{operationName:r,operation:n,validationOptions:
|
|
175
|
+
`Unknown operation "${r}".`);let n=this.operations[r];return{operationName:r,operation:n,validationOptions:Md(t)}}_buildOperationResult(t,r,n){
|
|
171
176
|
let o={};for(let i of n.outputFieldNames){if(!Object.hasOwn(this.structure,i))continue;let s=n.isFieldPresent(i);(r[i]!==
|
|
172
|
-
void 0||s&&t[i]===null||n.defaultedFields.has(i))&&(!s&&!n.defaultedFields.has(i)||
|
|
173
|
-
return fr(t,r)}_resolveArrayItemsConfig(t,r){return mr(t,r)}_resolveObjectValuesConfig(t,r){return
|
|
177
|
+
void 0||s&&t[i]===null||n.defaultedFields.has(i))&&(!s&&!n.defaultedFields.has(i)||P(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){
|
|
178
|
+
return fr(t,r)}_resolveArrayItemsConfig(t,r){return mr(t,r)}_resolveObjectValuesConfig(t,r){return Pt(t,r)}_buildArrayItemSettings(t,r){
|
|
174
179
|
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
180
|
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
|
-
`No casting function for type: ${t.type}`);let m=this.types[t.type];if(r===null)return u?(
|
|
181
|
+
`No casting function for type: ${t.type}`);let m=this.types[t.type];if(r===null)return u?(P(o,i,null),{errors:{},shouldContinue:!1}):
|
|
177
182
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
178
|
-
if(r===""&&l)return
|
|
183
|
+
if(r===""&&l)return P(o,i,null),{errors:{},shouldContinue:!1};let f={schema:this,definition:t,value:r,fieldName:n,object:o,
|
|
179
184
|
objectBeforeCast:s,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
180
|
-
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(h,y,
|
|
181
|
-
n,h,y,
|
|
185
|
+
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(h,y,I)=>{throw this._paramError(
|
|
186
|
+
n,h,y,I)}};try{let h=m(f);if(ls(h))throw new Error(`Type handler for "${t.type}" must be synchronous.`);h!==void 0&&(P(o,
|
|
182
187
|
i,h),f.value=h)}catch(h){if(h.errorObject)return{errors:this._singleErrorMap(h.errorObject),shouldContinue:!1};throw h}return{
|
|
183
188
|
errors:{},context:f,shouldContinue:!0}}_runFieldValidators(t,r,n,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
|
|
184
189
|
_paramToBeSkipped(a,s.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{i.parameterName=
|
|
185
|
-
a,i.parameterValue=t[a];let u=c(i);if(
|
|
186
|
-
(
|
|
190
|
+
a,i.parameterValue=t[a];let u=c(i);if(ls(u))throw new Error(`Validator handler for "${a}" must be synchronous.`);u!==void 0&&
|
|
191
|
+
(P(n,o,u),i.value=u)}catch(u){if(u.errorObject)return this._singleErrorMap(u.errorObject);throw u}}return{}}_normalizeAndValidateValue(t,r,n,o,i,s,a,c){
|
|
187
192
|
let u=this._castValue(t,r,n,o,i,s,a,c);if(Object.keys(u.errors).length>0)return u.errors;if(!u.shouldContinue)return{};let{
|
|
188
193
|
context:l}=u,m=this._validateNestedValue(t,n,o,i,a,c);return Object.keys(m).length>0?m:(l.value=o[i],this._runFieldValidators(
|
|
189
194
|
t,n,o,i,l,a))}_normalizeDefault(t,r,{fieldPath:n,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
|
|
190
|
-
let u={...o};return
|
|
195
|
+
let u={...o};return P(u,i,r),{errors:this._normalizeAndValidateValue(t,r,n,u,i,s,a,c),value:u[i]}}_validateNestedValue(t,r,n,o,i,s){
|
|
191
196
|
if(t.type==="object"){let c=this._resolveObjectFieldMode(r,t);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
192
197
|
c,r,n,o,i,s):c.kind==="map"?this._validateObjectValues(r,n,o,c.valuesConfig,i,s):{}}if(t.type!=="array")return{};let a=this.
|
|
193
198
|
_resolveArrayItemsConfig(r,t);return a?this._validateArrayItems(r,n,o,a,i,s):{}}_validateNestedObjectSchema(t,r,n,o,i,s){
|
|
194
199
|
let a=n[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,u=t.schema._validateWithOperation(
|
|
195
|
-
s.operationName,s.operation,c,
|
|
196
|
-
a,t.schema,u.validatedObject):u.validatedObject),
|
|
197
|
-
entries(t))Object.hasOwn(r.structure,o)&&
|
|
198
|
-
keys(t)){if(!Object.hasOwn(r.structure,i)){
|
|
199
|
-
n))Object.hasOwn(o,i)||
|
|
200
|
+
s.operationName,s.operation,c,it(i,r));return P(n,o,t.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
201
|
+
a,t.schema,u.validatedObject):u.validatedObject),ot(u.errors,r)}_extractKnownObjectFields(t,r){let n={};for(let[o,i]of Object.
|
|
202
|
+
entries(t))Object.hasOwn(r.structure,o)&&P(n,o,i);return n}_mergeKnownAndPassthroughObjectFields(t,r,n){let o={};for(let i of Object.
|
|
203
|
+
keys(t)){if(!Object.hasOwn(r.structure,i)){P(o,i,t[i]);continue}Object.hasOwn(n,i)&&P(o,i,n[i])}for(let[i,s]of Object.entries(
|
|
204
|
+
n))Object.hasOwn(o,i)||P(o,i,s);return o}_validateObjectValues(t,r,n,o,i,s){let a=r[n],c={...a},u={};P(r,n,c);for(let l of Object.
|
|
200
205
|
keys(a)){let m=De(t,l);if(this._fieldToBeSkipped(m,i))continue;let f=c[l];if(f===void 0){s.rejectExplicitUndefined?this.
|
|
201
206
|
_mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let y=o.
|
|
202
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,f,
|
|
203
|
-
u,
|
|
204
|
-
definition,s));this._mergeErrors(u,h)}return u}_validateArrayItems(t,r,n,o,i,s){let a=r[n],c=a.slice(),u={};
|
|
207
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,f,it(i,m));P(c,l,y.validatedObject),this._mergeErrors(
|
|
208
|
+
u,ot(y.errors,m));continue}let h=this._normalizeAndValidateValue(o.definition,f,m,c,l,a,i,this._buildArrayItemSettings(o.
|
|
209
|
+
definition,s));this._mergeErrors(u,h)}return u}_validateArrayItems(t,r,n,o,i,s){let a=r[n],c=a.slice(),u={};P(r,n,c);for(let l=0;l<
|
|
205
210
|
c.length;l++){let m=De(t,l);if(this._fieldToBeSkipped(m,i))continue;if(!Object.hasOwn(a,l)||c[l]===void 0){s.rejectExplicitUndefined?
|
|
206
211
|
this._mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let h=o.
|
|
207
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],
|
|
208
|
-
u,
|
|
212
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],it(i,m));P(c,l,h.validatedObject),this._mergeErrors(
|
|
213
|
+
u,ot(h.errors,m));continue}let f=this._normalizeAndValidateValue(o.definition,c[l],m,c,l,a,i,this._buildArrayItemSettings(
|
|
209
214
|
o.definition,s));this._mergeErrors(u,f)}return u}_validateField(t,r,n,o,i){if(!Object.hasOwn(this.structure,t))return{};
|
|
210
215
|
let s=this.structure[t];if(this._fieldToBeSkipped(t,o))return{};let a=i.isFieldPresent(t),c=r[t],u=c===void 0;return i.enforceRequired&&
|
|
211
216
|
s.required&&(!a||u)&&!this._paramToBeSkipped("required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"\
|
|
212
217
|
Field is required",params:{}}):a?u?i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(t).errorObject):{}:this.
|
|
213
218
|
_normalizeAndValidateValue(s,c,t,n,t,r,o,i):{}}_validateWithOperation(t,r,n,o){this._assertSupportedOptions(o);let i={},
|
|
214
|
-
s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||
|
|
219
|
+
s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||P(i,c,{field:c,
|
|
215
220
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let u=this._validateField(
|
|
216
221
|
c,n,s,o,a);this._mergeErrors(i,u)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
217
222
|
this.structure[c].defaultTo!==void 0){let u=this.structure[c],l=typeof u.defaultTo=="function"?u.defaultTo():u.defaultTo,
|
|
218
223
|
m=this._normalizeDefault(u,l,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
219
|
-
_mergeErrors(i,m.errors),Object.keys(m.errors).length>0)continue;
|
|
220
|
-
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of
|
|
221
|
-
let u=
|
|
224
|
+
_mergeErrors(i,m.errors),Object.keys(m.errors).length>0)continue;P(s,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
225
|
+
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of fs(Object.keys(t))){
|
|
226
|
+
let u=ws(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${u}".`);let l=this._validateSelectedField(
|
|
222
227
|
c,t[c],r,a,n,o,u);this._mergeErrors(s,l)}return{validatedObject:a,errors:s}}_validateSelectedField(t,r,n,o,i,s,a){if(!Object.
|
|
223
|
-
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=
|
|
228
|
+
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=ds(r);if(this._fieldToBeSkipped(a,i))return{};
|
|
224
229
|
let m=Object.hasOwn(n,t),f=n[t],h={};if(!m){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("required",i.skipParams,
|
|
225
230
|
a)&&this._mergeErrors(h,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),u&&s.applyDefaults&&
|
|
226
231
|
c.defaultTo!==void 0){let d=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,p=this._normalizeDefault(c,d,{fieldPath:a,
|
|
227
232
|
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(h,p.errors),Object.keys(p.errors).
|
|
228
|
-
length===0&&
|
|
233
|
+
length===0&&P(o,t,p.value)}return h}if(f===void 0)return u&&s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
229
234
|
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
|
-
y[t]!==void 0?
|
|
231
|
-
|
|
232
|
-
y,t,i,s);return
|
|
233
|
-
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!
|
|
234
|
-
u))return{};let l=c.schema._validateSelectedTree(r,u,
|
|
235
|
-
|
|
235
|
+
y[t]!==void 0?P(o,t,y[t]):y[t]===null&&P(o,t,null),d}if(!l)return{};let I=this._castValue(c,f,a,y,t,n,i,s);if(Object.keys(
|
|
236
|
+
I.errors).length>0)return I.errors;if(!I.shouldContinue)return{};let S=this._validateSelectedDescendants(c,r.children,a,
|
|
237
|
+
y,t,i,s);return _r(y[t])&&P(o,t,y[t]),S}_validateSelectedDescendants(t,r,n,o,i,s,a){if(t.type==="object"){let c=this._resolveObjectFieldMode(
|
|
238
|
+
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!Y(
|
|
239
|
+
u))return{};let l=c.schema._validateSelectedTree(r,u,it(s,n),{...a,defaultedFields:new Set});return P(o,i,l.validatedObject),
|
|
240
|
+
ot(l.errors,n)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(n,t);if(!c)throw new Error(`Schema path "${n}" d\
|
|
236
241
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,i,c,r,s,a)}throw new Error(
|
|
237
242
|
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],u=r[n],
|
|
238
|
-
l={};
|
|
239
|
-
id because array segments must use numeric indexes.`);let f=Number(m),h=De(t,f),y=i[m],
|
|
240
|
-
h,s))continue;if(!Object.hasOwn(u,f)){
|
|
241
|
-
if(d===void 0){
|
|
242
|
-
let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,d,
|
|
243
|
-
this._mergeErrors(l,
|
|
244
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
245
|
-
this._mergeErrors(l,
|
|
246
|
-
o.definition,d,h,_,0,u,s,p);Object.hasOwn(_,0)&&_[0]!==void 0?
|
|
243
|
+
l={};P(r,n,c);for(let m of fs(Object.keys(i))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${De(t,m)}" is inval\
|
|
244
|
+
id because array segments must use numeric indexes.`);let f=Number(m),h=De(t,f),y=i[m],I=y.self===!0,S=ds(y);if(this._fieldToBeSkipped(
|
|
245
|
+
h,s))continue;if(!Object.hasOwn(u,f)){I&&a.rejectExplicitUndefined&&P(l,h,this._typeError(h).errorObject);continue}let d=u[f];
|
|
246
|
+
if(d===void 0){I&&a.rejectExplicitUndefined&&P(l,h,this._typeError(h).errorObject);continue}if(o.kind==="schema"){if(I){
|
|
247
|
+
let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,d,it(s,h));_r(E.validatedObject)&&P(c,f,E.validatedObject),
|
|
248
|
+
this._mergeErrors(l,ot(E.errors,h));continue}if(!S)continue;let w=o.schema._validateSelectedTree(y.children,d,it(s,h),{...a,
|
|
249
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});_r(w.validatedObject)&&P(c,f,w.validatedObject),
|
|
250
|
+
this._mergeErrors(l,ot(w.errors,h));continue}let p=this._buildArrayItemSettings(o.definition,a),_=[d];if(I){let w=this._normalizeAndValidateValue(
|
|
251
|
+
o.definition,d,h,_,0,u,s,p);Object.hasOwn(_,0)&&_[0]!==void 0?P(c,f,_[0]):_[0]===null&&P(c,f,null),this._mergeErrors(l,w);
|
|
247
252
|
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
253
|
l,b.errors);continue}if(!b.shouldContinue)continue;let v=this._validateSelectedDescendants(o.definition,y.children,h,_,0,
|
|
249
|
-
s,p);
|
|
254
|
+
s,p);_r(_[0])&&P(c,f,_[0]),this._mergeErrors(l,v)}return l}validateWith(t,r,n={}){if(!Object.hasOwn(this.operations,t))throw new Error(
|
|
250
255
|
`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(t,r),this._validateWithOperation(
|
|
251
|
-
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=
|
|
252
|
-
_resolvePathValidationRequest(n),c=this._validateSelectedTree(
|
|
256
|
+
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=Fn(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
257
|
+
_resolvePathValidationRequest(n),c=this._validateSelectedTree(ms([t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:Cd(
|
|
253
258
|
c.validatedObject,o),errors:c.errors}}validatePaths(t,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
254
259
|
isArray(t)||t.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
255
|
-
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(
|
|
260
|
+
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(ms(t),r,s,this.
|
|
256
261
|
_buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.keys(this.operations)){if(t in this)throw new Error(
|
|
257
262
|
`Operation name "${t}" is reserved and cannot be used as a schema method.`);this[t]=(r,n={})=>this.validateWith(t,r,n)}}toJsonSchema(t={}){
|
|
258
|
-
return
|
|
259
|
-
"")throw new Error("Field path must be a non-empty string.");let r=
|
|
260
|
-
let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
261
|
-
let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
return cs(this,t)}getFieldDefinitions(){return Hn.has(this)||Hn.set(this,Bn(this.structure)),Hn.get(this)}getFieldDefinition(t){
|
|
264
|
+
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=qn(this,Fn(t.trim()));
|
|
265
|
+
return r===null?null:Bn(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
266
|
+
messages===null?Object.freeze({}):Bn(r.messages)}cleanup(t,r){let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,
|
|
267
|
+
o)&&this.structure[o][r]&&P(n,o,t[o]);return n}}});var hy,Dd,gy,Ud,Vd,Es,Gd,bs,vs,Ss=g(()=>{({parse:hy,stringify:Dd}=JSON),{keys:gy}=Object,Ud=String,Vd="string",Es="objec\
|
|
268
|
+
t",Gd=(e,t)=>t,bs=(e,t,r)=>{let n=Ud(t.push(r)-1);return e.set(r,n),n},vs=(e,t,r)=>{let n=t&&typeof t===Es?(l,m)=>l===""||
|
|
269
|
+
-1<t.indexOf(l)?m:void 0:t||Gd,o=new Map,i=[],s=[],a=+bs(o,i,n.call({"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=Dd(i[a++],
|
|
270
|
+
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 Es:if(f===
|
|
271
|
+
null)return f;case Vd:return o.get(f)||bs(o,i,f)}return f}}});function Fd(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Is(e){if(typeof e==
|
|
266
272
|
"number")return Number.isFinite(e)?e:null;if(typeof e=="bigint"){let t=Number(e);return Number.isSafeInteger(t)?t:null}if(typeof e==
|
|
267
|
-
"string"){let t=e.trim();if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function
|
|
273
|
+
"string"){let t=e.trim();if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function Yn(e,t){
|
|
268
274
|
if(Object.is(e,t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&
|
|
269
275
|
t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(
|
|
270
|
-
e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!
|
|
276
|
+
e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Yn(e[o],t[o]))return!1;return!0}if(e===
|
|
271
277
|
null||t===null||typeof e!="object"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=Object.
|
|
272
|
-
keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!
|
|
273
|
-
return!0}var
|
|
274
|
-
no","n","off"]);
|
|
278
|
+
keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!Yn(e[o],t[o]))return!1;
|
|
279
|
+
return!0}var Hd,zd,qd,Ts,As=g(()=>{Ss();hr();kn();tt();Hd=new Set(["true","1","yes","y","on"]),zd=new Set(["false","0","\
|
|
280
|
+
no","n","off"]);qd={install(e){let{addType:t,addValidator:r}=e;t("none",n=>n.value),t("file",n=>{let o=n.value;o==null&&
|
|
275
281
|
n.throwTypeError();let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?
|
|
276
282
|
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
283
|
mber"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),
|
|
278
|
-
t("number",n=>{let o=
|
|
279
|
-
!Number.isInteger(o))&&n.throwTypeError(),o}),t("epochMilliseconds",n=>{let o=
|
|
280
|
-
o}),t("epochSeconds",n=>{let o=
|
|
281
|
-
n.fieldName);return
|
|
282
|
-
"time",n=>{let o=
|
|
283
|
-
type==="array"&&!Array.isArray(n.value)?[n.value]:n.value),t("object",n=>(
|
|
284
|
-
|
|
284
|
+
t("number",n=>{let o=Is(n.value);return o===null&&n.throwTypeError(),o}),t("integer",n=>{let o=Is(n.value);return(o===null||
|
|
285
|
+
!Number.isInteger(o))&&n.throwTypeError(),o}),t("epochMilliseconds",n=>{let o=Cn(n.value,864e13);return o===null&&n.throwTypeError(),
|
|
286
|
+
o}),t("epochSeconds",n=>{let o=Cn(n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=Rt(n.definition,
|
|
287
|
+
n.fieldName);return es(n.value,o)||n.throwTypeError(),n.value}),t("date",n=>(Qi(n.value)||n.throwTypeError(),n.value)),t(
|
|
288
|
+
"time",n=>{let o=Rt(n.definition,n.fieldName);return Zi(n.value,o)||n.throwTypeError(),n.value}),t("array",n=>n.definition.
|
|
289
|
+
type==="array"&&!Array.isArray(n.value)?[n.value]:n.value),t("object",n=>(Y(n.value)||n.throwTypeError(),n.value)),t("se\
|
|
290
|
+
rialize",n=>{try{return JSON.stringify(n.value)}catch{try{return vs(n.value)}catch{n.throwTypeError()}}}),t("boolean",n=>{
|
|
285
291
|
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;
|
|
286
292
|
n.throwTypeError()}if(typeof n.value=="bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.
|
|
287
293
|
value=="string"){let o=String(n.definition.stringFalseWhen||"false").trim().toLowerCase(),i=String(n.definition.stringTrueWhen||
|
|
288
|
-
"true").trim().toLowerCase(),s=n.value.trim().toLowerCase(),a=new Set([...
|
|
294
|
+
"true").trim().toLowerCase(),s=n.value.trim().toLowerCase(),a=new Set([...zd,o]),c=new Set([...Hd,i]);if(a.has(s))return!1;
|
|
289
295
|
if(c.has(s))return!0}n.throwTypeError()}),t("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>
|
|
290
296
|
0)return n.value;n.throwTypeError()}if(typeof n.value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))
|
|
291
297
|
return Number(n.value);n.throwTypeError()}if(typeof n.value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();
|
|
292
298
|
let i=Number(o);return Number.isSafeInteger(i)||n.throwTypeError(),i}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&
|
|
293
299
|
n.definition.type==="string"&&n.value.toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGT\
|
|
294
300
|
H",`Length must be at least ${n.parameterValue} characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),
|
|
295
|
-
r("min",n=>{n.value!==void 0&&
|
|
301
|
+
r("min",n=>{n.value!==void 0&&rt(n.definition)&&typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("M\
|
|
296
302
|
IN_VALUE",`Value must be at least ${n.parameterValue}.`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==
|
|
297
303
|
void 0&&n.definition.type==="string"&&n.value.toString&&n.value.toString().length>n.parameterValue&&n.throwParamError("M\
|
|
298
304
|
AX_LENGTH",`Length must be no more than ${n.parameterValue} characters.`,{max:n.parameterValue,actual:n.value.toString().
|
|
299
|
-
length})}),r("max",n=>{n.value!==void 0&&
|
|
305
|
+
length})}),r("max",n=>{n.value!==void 0&&rt(n.definition)&&typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError(
|
|
300
306
|
"MAX_VALUE",`Value must be no more than ${n.parameterValue}.`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.
|
|
301
|
-
isArray(n.parameterValue))throw new Error(`Enum for ${n.fieldName} must be an array.`);n.parameterValue.some(i=>
|
|
307
|
+
isArray(n.parameterValue))throw new Error(`Enum for ${n.fieldName} must be an array.`);n.parameterValue.some(i=>Yn(i,n.value))||
|
|
302
308
|
n.throwParamError("ENUM_VALUE","Value must match one of the allowed enum values.",{allowed:n.parameterValue})}),r("patte\
|
|
303
309
|
rn",n=>{if(n.value===void 0||n.definition.type!=="string"||typeof n.value!="string")return;let o=n.parameterValue,i=o instanceof
|
|
304
310
|
RegExp?new RegExp(o.source,o.flags):typeof o=="string"?new RegExp(o):null;if(!i)throw new Error(`Pattern for ${n.fieldName}\
|
|
@@ -306,51 +312,55 @@ RegExp?new RegExp(o.source,o.flags):typeof o=="string"?new RegExp(o):null;if(!i)
|
|
|
306
312
|
{pattern:i.source})}),r("strictBoolean",n=>{if(n.parameterValue){if(n.definition.type!=="boolean")throw new Error(`stric\
|
|
307
313
|
tBoolean can only be used on boolean fields (${n.fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("\
|
|
308
314
|
STRICT_BOOLEAN","Value must be a boolean.")}}),r("validator",n=>{if(typeof n.parameterValue!="function")throw new Error(
|
|
309
|
-
`Validator for ${n.fieldName} must be a function.`);let o=n.parameterValue(n.value,n.object,n);if(
|
|
315
|
+
`Validator for ${n.fieldName} must be a function.`);let o=n.parameterValue(n.value,n.object,n);if(Fd(o))throw new Error(
|
|
310
316
|
`Custom validator for "${n.fieldName}" must be synchronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FA\
|
|
311
317
|
ILED",o)}),r("uppercase",n=>{if(typeof n.value=="string")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value==
|
|
312
318
|
"string")return n.value.toLowerCase()}),r("length",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);
|
|
313
319
|
Number.isInteger(Number(n.valueBeforeCast))&&String(n.valueBeforeCast).length>n.parameterValue&&n.throwParamError("RANGE\
|
|
314
320
|
_EXCEEDED","Numeric value is out of the allowed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).
|
|
315
|
-
length})}),r("
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
"
|
|
323
|
-
|
|
324
|
-
|
|
321
|
+
length})}),r("minItems",n=>{Array.isArray(n.value)&&n.value.length<n.parameterValue&&n.throwParamError("MIN_ITEMS",`Must\
|
|
322
|
+
have at least ${n.parameterValue} items.`,{min:n.parameterValue,actual:n.value.length})}),r("maxItems",n=>{Array.isArray(
|
|
323
|
+
n.value)&&n.value.length>n.parameterValue&&n.throwParamError("MAX_ITEMS",`Must have no more than ${n.parameterValue} ite\
|
|
324
|
+
ms.`,{max:n.parameterValue,actual:n.value.length})}),r("notEmpty",n=>{n.parameterValue&&typeof n.value=="string"&&n.value===
|
|
325
|
+
""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r("unsigned",()=>{}),r("precision",()=>{}),
|
|
326
|
+
r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.type!=="dateTime")throw new Error(
|
|
327
|
+
`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r("nullable",()=>{}),r("nullOnEmpty",
|
|
328
|
+
()=>{}),r("defaultTo",()=>{})}},Ts=qd});var Os=g(()=>{Nt()});function Wd(e,t,r){if(typeof r!="function")throw new Error(`Type handler for '${t}' must be a function.`);P(e,t,r)}function Yd(e,t,r){
|
|
329
|
+
if(typeof r!="function")throw new Error(`Validator handler for '${t}' must be a function.`);P(e,t,r)}function Sr(e={}){let t=Object.
|
|
330
|
+
create(null);for(let[r,n]of Object.entries(e))P(t,r,n);return t}function Ps(e,t){if(typeof e.install!="function")throw new Error(
|
|
331
|
+
"Plugin must have an install method.");e.install(t)}function Rs(e,t,r){Cs.set(e,t),ks.set(e,r),Object.defineProperty(e,xs,
|
|
332
|
+
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function Jd(e){if(!e||
|
|
333
|
+
typeof e!="object"&&typeof e!="function")return null;let t=Cs.get(e),r=ks.get(e);if(t&&r)return{types:t,validators:r};let n=e[xs];
|
|
325
334
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
326
335
|
typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.validators=="object"&&typeof e.create=="fu\
|
|
327
336
|
nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
|
|
328
|
-
validators}:null}function
|
|
329
|
-
|
|
330
|
-
conflicting ${r} "${n}".`)
|
|
331
|
-
t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
let c=new
|
|
335
|
-
|
|
336
|
-
{types:a.types,validators:a.validators,installCore:!1})},r&&
|
|
337
|
-
|
|
338
|
-
|
|
337
|
+
validators}:null}function Kd(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function Ns(e,t,r){for(let[n,o]of Object.
|
|
338
|
+
entries(t)){if(Object.hasOwn(e,n)&&e[n]!==o){if(vr.has(o))continue;if(!vr.has(e[n]))throw new Error(`Cannot merge schema\
|
|
339
|
+
factories with conflicting ${r} "${n}".`)}P(e,n,o)}}function Xd(e,t,r){let n=Kd(r).filter(Boolean);if(n.length<1)return{
|
|
340
|
+
types:Sr(e),validators:Sr(t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=Jd(s);if(!a)throw new Error(
|
|
341
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");Ns(o,a.types,"type"),Ns(i,a.
|
|
342
|
+
validators,"validator")}return{types:o,validators:i}}function $s({types:e={},validators:t={},installCore:r=!0}={}){let n=Sr(
|
|
343
|
+
e),o=Sr(t),i=(s,a={})=>{let c=new st(s,n,o,a.operations);return Rs(c,n,o),c};return Rs(i,n,o),i.addType=(s,a)=>{Wd(n,s,a)},
|
|
344
|
+
i.addValidator=(s,a)=>{Yd(o,s,a)},i.use=s=>{Ps(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
|
|
345
|
+
let a=Xd(n,o,s);return $s({types:a.types,validators:a.validators,installCore:!1})},r&&Ps(Ts,{addType:(s,a)=>{vr.add(a),i.
|
|
346
|
+
addType(s,a)},addValidator:(s,a)=>{vr.add(a),i.addValidator(s,a)}}),i}var Cs,ks,xs,vr,$,Ue=g(()=>{_s();As();Os();Nt();Cs=
|
|
347
|
+
new WeakMap,ks=new WeakMap,xs=Symbol.for("json-rest-schema.registry-metadata"),vr=new WeakSet;$=$s({installCore:!0})});var My,js=g(()=>{Ue();G();My=Object.freeze({schema:$({}),mode:"replace"})});var Ls=g(()=>{G();Gi();pr();js()});function ep(e){return String(e||"").trim().toLowerCase()}function Xn(e,t){let r=ep(e);if(!Ms.test(r))throw new TypeError(
|
|
348
|
+
`${t} must match ${Ms.toString()}.`);return r}function Jn(e,t){if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(
|
|
339
349
|
`${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(!
|
|
350
|
+
o||"").trim();if(!Zd.test(s))throw new TypeError(`${t} local name "${s}" must be a JavaScript identifier.`);let a=Xn(i,`${t}\
|
|
341
351
|
.${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
|
|
352
|
+
freeze(r)}function tp(e,t,r){if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(`${r}.hints must be an obj\
|
|
343
353
|
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=
|
|
354
|
+
e)){let a=Xn(i,`${r}.hints key`);if(!n.has(a))throw new TypeError(`${r}.hints names "${a}", which the provider does not \
|
|
345
355
|
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
|
|
356
|
+
egister.`);o[a]=s.trim()}return Object.freeze(o)}function rp(e){let t=new Map;for(let[r,n]of Object.entries(e))for(let o of Object.
|
|
347
357
|
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
|
|
349
|
-
ovided.`);return e}function
|
|
350
|
-
let c=
|
|
351
|
-
provides:m});let f=
|
|
352
|
-
optional:l,provides:m,hints:
|
|
353
|
-
G();
|
|
358
|
+
r)}}function Kn(e,t){if(e==null)return null;if(typeof e!="function")throw new TypeError(`${t} must be a function when pr\
|
|
359
|
+
ovided.`);return e}function Ir({id:e,requires:t={},optional:r={},provides:n={},hints:o={},setup:i,boot:s=null,shutdown:a=null}={}){
|
|
360
|
+
let c=Xn(e,"Provider id"),u=Jn(t,`${c}.requires`),l=Jn(r,`${c}.optional`),m=Jn(n,`${c}.provides`);rp({requires:u,optional:l,
|
|
361
|
+
provides:m});let f=Kn(i,`${c}.setup`);if(!f)throw new TypeError(`${c}.setup is required.`);return Object.freeze({id:c,requires:u,
|
|
362
|
+
optional:l,provides:m,hints:tp(o,u,c),setup:f,boot:Kn(s,`${c}.boot`),shutdown:Kn(a,`${c}.shutdown`)})}var Ms,Zd,Qn=g(()=>{
|
|
363
|
+
G();Ms=/^[a-z][a-z0-9_.-]*$/u,Zd=/^[A-Za-z_$][A-Za-z0-9_$]*$/u});var Ds,Us=g(()=>{Ds="public"});var Vs=g(()=>{});var Bs=g(()=>{G()});var np,Hs,zs=g(()=>{Vs();Bs();np="/api",Hs=`${np}/bootstrap`});function Zn(){let e=[],t=new Set,r=!1;function n({id:a,order:c=0,contribute:u}={}){if(r)throw new Error("Bootstrap regis\
|
|
354
364
|
tration is closed after the first payload is resolved.");let l=V(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
355
365
|
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
|
|
356
366
|
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
|
|
@@ -358,92 +368,92 @@ isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u
|
|
|
358
368
|
(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
369
|
freeze({...B(a)?a:{},payload:Object.freeze({...c})}));c={...c,...B(m)?m:{}}}return Object.freeze(c)}function i(){return Object.
|
|
360
370
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
361
|
-
return s}var
|
|
362
|
-
untime.bootstrap"},setup({http:e}){let t=
|
|
371
|
+
return s}var eo=g(()=>{G()});var op,Fs=g(()=>{Qn();Us();zs();eo();op=Ir({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"r\
|
|
372
|
+
untime.bootstrap"},setup({http:e}){let t=Zn();return e.router.register("GET",Hs,{auth:Ds,meta:{tags:["bootstrap"],summary:"\
|
|
363
373
|
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
|
|
374
|
+
{bootstrap:t}}})});function ip(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
375
|
"Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
|
|
366
376
|
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
|
|
377
|
+
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function sp(e){if(!B(e))throw new TypeError(
|
|
368
378
|
"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
|
|
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=
|
|
379
|
+
required.");return Object.freeze({...e,type:t})}function to(){let e=[],t=new Set;function r(s){let a=ip(s);if(t.has(a.id))
|
|
380
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=sp(s);
|
|
371
381
|
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
|
|
382
|
+
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var ro=g(()=>{G()});var ap,qs=g(()=>{Qn();ro();ap=Ir({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:to()}}})});var Tr=g(()=>{pr();Vi();Ls();Fs();eo();qs();ro()});var Ws=g(()=>{});function Ys(e,t={}){let{missingStatus:r=404}=t,n=e?.errors?.[0]?.code||e?.code||"";return n==="vibe64_session_not_found"?
|
|
373
383
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
374
384
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
375
385
|
64_project_source_lock_timeout"||n==="vibe64_development_database_scope_busy"||n==="vibe64_project_session_policy_lock_t\
|
|
376
386
|
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
|
|
378
|
-
|
|
387
|
+
tup_running"?409:e?.ok===!1?400:200}var Js=g(()=>{});function Ve(e,t,r={}){let{status:n=Ys({ok:!1,code:t}),...o}=r;return new ae(n,e,{...o,code:t})}var Ks=g(()=>{Tr();G();Ws();
|
|
388
|
+
Js()});import cp from"node:crypto";function up(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=String(t.type||"").trim();
|
|
379
389
|
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===
|
|
381
|
-
64_preview_identity_selector_missing");if(r===
|
|
382
|
-
nvalid.","vibe64_preview_identity_email_invalid");if(r!==
|
|
390
|
+
let n=String(t.value||"").trim(),o=r===Ot?n.toLowerCase():n;if(!o)throw Ve("Preview identity selector is missing.","vibe\
|
|
391
|
+
64_preview_identity_selector_missing");if(r===Ot&&(!o.includes("@")||o.length>320))throw Ve("Preview identity email is i\
|
|
392
|
+
nvalid.","vibe64_preview_identity_email_invalid");if(r!==Ot&&o.length>256)throw Ve(r===ur?"Preview identity login is inv\
|
|
383
393
|
alid.":"Preview identity user id is invalid.",r===ur?"vibe64_preview_identity_login_invalid":"vibe64_preview_identity_us\
|
|
384
|
-
er_id_invalid");return{type:r,value:o}}function
|
|
394
|
+
er_id_invalid");return{type:r,value:o}}function ea(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};if(Object.hasOwn(
|
|
385
395
|
t,"subject"))throw Ve("Preview identity login requires an explicit application selector.","vibe64_preview_identity_subje\
|
|
386
|
-
ct_unsupported");let r=String(t.operation||le).trim();if(![le,
|
|
387
|
-
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===le?{selector:
|
|
388
|
-
|
|
389
|
-
guest","you"]),
|
|
390
|
-
function
|
|
391
|
-
command failed.",{code:t,params:n})}function
|
|
392
|
-
targetHref:n=""}=t,o=
|
|
393
|
-
"Application preview identity target must use HTTP.");return{operation:o.operation,protocol:
|
|
394
|
-
operation===le?{subject:
|
|
396
|
+
ct_unsupported");let r=String(t.operation||le).trim();if(![le,at].includes(r))throw Ve("Preview identity operation is in\
|
|
397
|
+
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===le?{selector:up(t.selector)}:{}}}var U_,le,
|
|
398
|
+
at,Xs,Qs,Zs,V_,no=g(()=>{Ui();Ks();U_=cp.randomBytes(32),le="login-as",at="logout",Xs="selector",Qs=new Set(["default","\
|
|
399
|
+
guest","you"]),Zs=32,V_=Object.freeze(["projectScope","sessionSourceRoot","sessionId","targetHref","terminalSessionId"])});var kt,oo=g(()=>{kt="vibe64_preview_token"});import{randomUUID as lp}from"node:crypto";import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as ta}from"@local/vibe64-genesis/server";
|
|
400
|
+
function ct(e="",t="vibe64_preview_identity_command_failed",r=502,n={}){return new ae(r,e||"Application preview identity\
|
|
401
|
+
command failed.",{code:t,params:n})}function pp(e={}){return{kind:Xs,selector:e.selector}}function na(e={},t={}){let{requestId:r=lp(),
|
|
402
|
+
targetHref:n=""}=t,o=ea(e),i=String(n||"").trim(),s=new URL(i);if(!["http:","https:"].includes(s.protocol))throw new Error(
|
|
403
|
+
"Application preview identity target must use HTTP.");return{operation:o.operation,protocol:ta,requestId:String(r),...o.
|
|
404
|
+
operation===le?{subject:pp(o)}:{},target:{href:s.toString(),origin:s.origin}}}function mp(e=[]){if(!Array.isArray(e))throw ct(
|
|
395
405
|
"Application preview identity command returned invalid cookies.","vibe64_preview_identity_command_cookies_invalid");let t=e;
|
|
396
|
-
if(t.length>
|
|
406
|
+
if(t.length>io)throw ct("Application preview identity command returned too many cookies.","vibe64_preview_identity_comma\
|
|
397
407
|
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)>
|
|
399
|
-
test(o))throw
|
|
400
|
-
_cookie_invalid",502,{cookie:n+1});return o})}function
|
|
408
|
+
0,s)).trim();if(!o||Buffer.byteLength(o)>so||/[\r\n]/u.test(o)||s<1||!dp.test(a)||a===xt||a.startsWith(`${xt}_`)||/(?:^|;)\s*domain\s*=/iu.
|
|
409
|
+
test(o))throw ct(`Application preview identity command returned invalid cookie ${n+1}.`,"vibe64_preview_identity_command\
|
|
410
|
+
_cookie_invalid",502,{cookie:n+1});return o})}function fp(e=null){if(!e||typeof e!="object"||Array.isArray(e))return null;
|
|
401
411
|
let t={displayName:String(e.displayName||e.name||"").trim().slice(0,256),email:String(e.email||"").trim().toLowerCase().
|
|
402
412
|
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
|
|
404
|
-
requestId:n=""}=t;if(!e||typeof e!="object"||Array.isArray(e))throw
|
|
405
|
-
valid JSON.","vibe64_preview_identity_command_json_invalid");if(e.protocol!==
|
|
406
|
-
typeof e.ok!="boolean")throw
|
|
407
|
-
eview_identity_command_response_invalid");let o=
|
|
413
|
+
e.username||"").trim().slice(0,256)};return Object.values(t).some(Boolean)?t:null}function hp(e={},t={}){let{operation:r=le,
|
|
414
|
+
requestId:n=""}=t;if(!e||typeof e!="object"||Array.isArray(e))throw ct("Application preview identity command returned in\
|
|
415
|
+
valid JSON.","vibe64_preview_identity_command_json_invalid");if(e.protocol!==ta||String(e.requestId||"")!==String(n||"")||
|
|
416
|
+
typeof e.ok!="boolean")throw ct("Application preview identity command returned an invalid protocol response.","vibe64_pr\
|
|
417
|
+
eview_identity_command_response_invalid");let o=mp(e.setCookie);if(e.ok===!1){let a=Number(e.statusCode);return{code:String(
|
|
408
418
|
e.code||"vibe64_preview_identity_application_rejected").trim().slice(0,128),error:String(e.error||"Application preview i\
|
|
409
419
|
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===
|
|
420
|
+
a>=400&&a<600?a:400}}let i=r===at||e.signedOut===!0,s=i?null:fp(e.identity);if(o.length<1||!i&&!s)throw ct("Application \
|
|
411
421
|
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
|
|
413
|
-
512*1024,
|
|
422
|
+
ing");return{identity:s,ok:!0,setCookie:o,signedOut:i,statusCode:200}}var ra,io,so,xt,dp,Y_,oa=g(()=>{Tr();no();oo();ra=
|
|
423
|
+
512*1024,io=64,so=16*1024,xt=kt,dp=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;Y_=Object.freeze({normalizePreviewIdentityCommandResponse:hp})});var ia=g(()=>{});function sa(e=""){return _p.find(t=>t.pattern.test(String(e)))?.kind||""}function vp(e){if(!be(e)||e.startsWith("/")||e.
|
|
414
424
|
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"]),
|
|
419
|
-
1024*1024,
|
|
425
|
+
modules")}var gp,X_,wp,yp,ca,$t,Q_,Z_,eE,_p,Ep,bp,Ar,be,aa,tE,rE,ua=g(()=>{gp="vibe64.usage-trace.v1",X_=Object.freeze({
|
|
426
|
+
directory:"VIBE64_USAGE_RECORDING_DIR",sourceRoot:"VIBE64_USAGE_SOURCE_ROOT",targetKind:"VIBE64_USAGE_TARGET_KIND"}),wp=
|
|
427
|
+
Object.freeze(["starting","recording","stopping","stopped","failed","unavailable"]),yp=Object.freeze(["person","time-lim\
|
|
428
|
+
it","request-limit","size-limit","target-exited","session-ended","error"]),ca=Object.freeze(["nodejs","python","php"]),$t=
|
|
429
|
+
1024*1024,Q_=Object.freeze({durationMs:600*1e3,capturedRequests:2e3,hitsBytesPerProcess:16*$t,hitsBytesPerRecording:32*$t,
|
|
420
430
|
proxyRequestLines:2e4,interactions:500,bufferedBytesPerProcess:64*$t,flushIntervalMs:1e3,flushEntries:2e3,traceLineBytes:64*
|
|
421
|
-
1024,indexBytes:4*$t,plumbingShare:.8,plumbingMinimumRequests:3}),
|
|
422
|
-
60*1e3}),
|
|
431
|
+
1024,indexBytes:4*$t,plumbingShare:.8,plumbingMinimumRequests:3}),Z_=Object.freeze({maxRecordings:10,maxBytes:64*$t,maxAgeMs:10080*
|
|
432
|
+
60*1e3}),eE=Object.freeze(["click","enter","submit"]),_p=Object.freeze([Object.freeze({kind:"request",pattern:/^r_[0-9]{6}$/u}),
|
|
423
433
|
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})]),
|
|
425
|
-
isSafeInteger(e)&&e>=0,be=e=>typeof e=="string"&&e.length>0,
|
|
426
|
-
e.column)&&e.column>0;
|
|
427
|
-
e.pid)&&e.pid>0&&be(e.startedAt),tracer:e=>
|
|
428
|
-
function:e=>
|
|
434
|
+
freeze({kind:"background",pattern:/^bg_[0-9]+$/u})]),Ep=/^sha256:[0-9a-f]{64}$/u,bp=Object.freeze(["ready","idle"]);Ar=e=>Number.
|
|
435
|
+
isSafeInteger(e)&&e>=0,be=e=>typeof e=="string"&&e.length>0,aa=e=>!!e&&Number.isSafeInteger(e.line)&&e.line>0&&Number.isSafeInteger(
|
|
436
|
+
e.column)&&e.column>0;tE=Object.freeze({header:e=>e.schema===gp&&ca.includes(e.runtime)&&be(e.runtimeVersion)&&Number.isSafeInteger(
|
|
437
|
+
e.pid)&&e.pid>0&&be(e.startedAt),tracer:e=>bp.includes(e.state),file:e=>Ar(e.fileIndex)&&vp(e.path)&&Ep.test(e.hash||""),
|
|
438
|
+
function:e=>Ar(e.functionIndex)&&Ar(e.fileIndex)&&typeof e.name=="string"&&aa(e.start)&&aa(e.end),scope:e=>sa(e.scope)===
|
|
429
439
|
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=>
|
|
440
|
+
e.kind)),hits:e=>sa(e.scope)!==""&&Array.isArray(e.counts)&&e.counts.every(t=>Array.isArray(t)&&t.length===2&&Ar(t[0])&&
|
|
431
441
|
(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
|
|
442
|
+
e.reason)}),rE=Object.freeze({USAGE_RECORDING_STATES:wp,USAGE_RECORDING_STOP_REASONS:yp,USAGE_TRACER_RUNTIMES:ca})});function Sp(e=""){try{let t=new URL(e),r=t.protocol==="https:",n=t.port||(r?"443":"80");return`${r?"__Host-":""}${la}_${n}`}catch{
|
|
443
|
+
return la}}function Ip(e="",t={}){let{proxyOrigin:r="",targetOrigin:n=""}=t,o=String(e||"").trim();if(!o||!r||!n)return o;
|
|
434
444
|
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=
|
|
445
|
+
i.pathname,s.search=Tp(i.search),s.hash=i.hash,s.toString())}catch{return o}}function Tp(e=""){let t=String(e||"");if(!t||
|
|
436
446
|
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
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
11",
|
|
442
|
-
73/"}),
|
|
443
|
-
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),
|
|
444
|
-
user_not_found",error:"No active user has that email.",statusCode:404,setCookie:[]}),
|
|
445
|
-
entity-command",title:"Preview identity command protocol",exampleRequest:
|
|
446
|
-
identity command protocol (\`${
|
|
447
|
+
s=i<0?o:o.slice(0,i);return Ap(s)!==kt});return n.length>0?`?${n.join("&")}`:""}function Ap(e=""){try{return decodeURIComponent(
|
|
448
|
+
String(e||"").replace(/\+/gu," "))}catch{return String(e||"")}}var la,da,lE,pa=g(()=>{ia();ua();oo();la=kt,da=/^vibe64-launch-[a-f0-9]{12}$/u;
|
|
449
|
+
lE=Object.freeze({previewTokenCookieName:Sp,proxiedLocation:Ip})});import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as Or}from"@local/vibe64-genesis/server";var ao,ma,co,fa,ha,ga,wa,ya=g(()=>{
|
|
450
|
+
no();oa();pa();ao=e=>JSON.stringify(e,null,2),ma=lr.map(e=>`\`${e}\``).join(", "),co="6f1c2a7e-3d4b-4c55-9a10-2b7d8e9f0a\
|
|
451
|
+
11",fa=na({operation:le,selector:{type:"email",value:"admin@example.com"}},{requestId:co,targetHref:"http://127.0.0.1:51\
|
|
452
|
+
73/"}),ha=Object.freeze({protocol:Or,requestId:co,ok:!0,setCookie:["app_session=abc123; Path=/; HttpOnly; SameSite=Lax"],
|
|
453
|
+
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),ga=Object.freeze({protocol:Or,requestId:co,ok:!1,code:"\
|
|
454
|
+
user_not_found",error:"No active user has that email.",statusCode:404,setCookie:[]}),wa=Object.freeze([{name:"preview-id\
|
|
455
|
+
entity-command",title:"Preview identity command protocol",exampleRequest:fa,exampleResponses:[ha,ga],text:()=>`# Preview\
|
|
456
|
+
identity command protocol (\`${Or}\`)
|
|
447
457
|
|
|
448
458
|
An application-owned executable, declared under an Outputs web target's \`#### Preview identity\` block (grammar: \`vibe64-\
|
|
449
459
|
helper spec outputs\`), that signs the Preview browser in as an existing application account or signs it out. Vibe64 neve\
|
|
@@ -457,51 +467,51 @@ adds only the Enabled and Secret names, not the project's Env values, so the com
|
|
|
457
467
|
ration itself (for example its generated environment file). For an enabled run the declared Enabled environment name is \
|
|
458
468
|
\`true\` and the Secret environment name holds a fresh per-run secret. Keep the exchange disabled unless both are present;\
|
|
459
469
|
it is a development-preview control, never a production sign-in API.
|
|
460
|
-
- stdin: one JSON request line. stdout: one JSON response (at most ${
|
|
470
|
+
- stdin: one JSON request line. stdout: one JSON response (at most ${ra} bytes). Exit 0 after writing the response; a no\
|
|
461
471
|
n-zero exit or timeout fails the exchange. Write diagnostics to stderr.
|
|
462
472
|
- Use the same database and configuration as the server behind \`target.origin\` (for a test target, its test database).
|
|
463
473
|
- A JSKIT application's executable can call \`runManagedPreviewIdentityCommand\` from \`@jskit-ai/auth-web/server/managedPr\
|
|
464
474
|
eviewIdentity\`. Pass it the application's environment, this protocol and the Preview's launch hostnames, since it reads \
|
|
465
475
|
no environment on its own and its defaults are JSKIT's neutral protocol and loopback only: \`runManagedPreviewIdentityCom\
|
|
466
|
-
mand({ env: process.env, protocol: "${
|
|
476
|
+
mand({ env: process.env, protocol: "${Or}", localHostnames: [${da}] })\`.
|
|
467
477
|
|
|
468
478
|
## Request
|
|
469
479
|
|
|
470
|
-
- \`operation\`: \`${le}\` or \`${
|
|
480
|
+
- \`operation\`: \`${le}\` or \`${at}\`.
|
|
471
481
|
- \`protocol\`, \`requestId\`: echo both in the response.
|
|
472
|
-
- \`subject\` (${le} only): \`{"kind":"selector","selector":{"type":\u2026,"value":\u2026}}\` with type ${
|
|
482
|
+
- \`subject\` (${le} only): \`{"kind":"selector","selector":{"type":\u2026,"value":\u2026}}\` with type ${ma}. Email val\
|
|
473
483
|
ues arrive lowercased.
|
|
474
484
|
- \`target\`: \`{"href","origin"}\` of the application page the cookies are for.
|
|
475
485
|
|
|
476
486
|
\`\`\`json
|
|
477
|
-
${
|
|
487
|
+
${ao(fa)}
|
|
478
488
|
\`\`\`
|
|
479
489
|
|
|
480
490
|
## Response
|
|
481
491
|
|
|
482
492
|
- Always: \`protocol\`, the same \`requestId\`, boolean \`ok\`, and \`setCookie\`: an array of complete Set-Cookie header values\
|
|
483
|
-
(at most ${
|
|
493
|
+
(at most ${io}, each at most ${so} bytes, no line breaks, no \`Domain\` attribute, never named \`${xt}\` or \`${xt}_*\`)\
|
|
484
494
|
.
|
|
485
495
|
- \`ok: true\`: at least one cookie. For ${le}, \`identity\` with at least one of \`displayName\`, \`email\`, \`login\`, \`userId\
|
|
486
|
-
\`, \`username\`. For ${
|
|
496
|
+
\`, \`username\`. For ${at} (or \`"signedOut": true\`), the cookies that clear the session.
|
|
487
497
|
- \`ok: false\`: \`code\` (at most 128 characters), \`error\` (a person-readable reason, at most 2000), \`statusCode\` 400 throu\
|
|
488
498
|
gh 599 (default 400), optional \`signedOut\`, and \`setCookie\` (may be empty).
|
|
489
499
|
|
|
490
500
|
\`\`\`json
|
|
491
|
-
${
|
|
501
|
+
${ao(ha)}
|
|
492
502
|
\`\`\`
|
|
493
503
|
|
|
494
504
|
\`\`\`json
|
|
495
|
-
${
|
|
505
|
+
${ao(ga)}
|
|
496
506
|
\`\`\`
|
|
497
507
|
`},{name:"preview-identities",title:"Managed app identities",text:()=>`# Managed app identities
|
|
498
508
|
|
|
499
509
|
The ordered list of named existing application accounts that Preview and managed Playwright can sign in as through the a\
|
|
500
510
|
pplication's Preview identity command (\`vibe64-helper spec preview-identity-command\`).
|
|
501
511
|
|
|
502
|
-
- Each entry has a \`name\`, a selector \`type\` (${
|
|
503
|
-
e, start with a lowercase letter and use at most 64 lowercase letters, digits, \`_\` or \`-\`; ${[...
|
|
504
|
-
join(", ")} are reserved. At most ${
|
|
512
|
+
- Each entry has a \`name\`, a selector \`type\` (${ma}) and the application's \`value\` for that account. Names are uniqu\
|
|
513
|
+
e, start with a lowercase letter and use at most 64 lowercase letters, digits, \`_\` or \`-\`; ${[...Qs].map(e=>`\`${e}\``).
|
|
514
|
+
join(", ")} are reserved. At most ${Zs} entries; the first is the default.
|
|
505
515
|
- Entries are selectors only, never passwords. A saved entry does not prove that the account exists or can reach a page:\
|
|
506
516
|
verify the selected account's actual Preview access.
|
|
507
517
|
- Read the list and the Stack's declared types with \`vibe64-helper preview identities\`; \`vibe64-helper preview status\` s\
|
|
@@ -520,31 +530,31 @@ Entry shape:
|
|
|
520
530
|
\`\`\`json
|
|
521
531
|
{"name":"admin","type":"email","value":"admin@example.com"}
|
|
522
532
|
\`\`\`
|
|
523
|
-
`}])});var
|
|
524
|
-
function
|
|
525
|
-
cts:",...
|
|
526
|
-
`)}async function
|
|
533
|
+
`}])});var Ea={};xi(Ea,{__testables:()=>Cp,runAgentSpecCli:()=>Np});import{readFile as Pp}from"node:fs/promises";import{VIBE64_GENESIS_AGENT_SPECS as Rp}from"@local/vibe64-genesis/server/agentSpecs";
|
|
534
|
+
function _a(){let e=Math.max(...Pr.map(({name:t})=>t.length));return["Usage: vibe64 spec <name>","","Vibe64-owned contra\
|
|
535
|
+
cts:",...Pr.map(({name:t,title:r})=>` ${t.padEnd(e)} ${r}`)].join(`
|
|
536
|
+
`)}async function Np(e=[],{write:t=n=>process.stdout.write(`${n.trimEnd()}
|
|
527
537
|
`),writeError:r=n=>process.stderr.write(`${n.trimEnd()}
|
|
528
|
-
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(
|
|
538
|
+
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(_a()),0;let o=e.length===1&&Pr.find(i=>i.name===n);return o?(t(await o.
|
|
529
539
|
text()),0):(r(`Unknown Vibe64 spec: ${e.join(" ")}.
|
|
530
540
|
|
|
531
|
-
${
|
|
532
|
-
freeze([...
|
|
533
|
-
e",text:()=>
|
|
534
|
-
e))Ae(e[r],t);return Object.freeze(e)}var jt=g(()=>{});function
|
|
541
|
+
${_a()}`),2)}var Op,Pr,Cp,ba=g(()=>{Di();ya();Op=new URL("./../server/lib/agentSpecCli.js",import.meta.url).href,Pr=Object.
|
|
542
|
+
freeze([...Rp,...wa,...Mi,{name:"training-content",title:"Teaching content format for vibe64 training validate and bundl\
|
|
543
|
+
e",text:()=>Pp(new URL("../../docs/training-content.md",Op),"utf8")}]);Cp=Object.freeze({VIBE64_AGENT_SPECS:Pr})});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(
|
|
544
|
+
e))Ae(e[r],t);return Object.freeze(e)}var jt=g(()=>{});function Rr(e){return!!e&&typeof e=="object"&&jp.every(t=>typeof e[t]=="function")}function Sa(e=null,{defaultMode:t="cr\
|
|
535
545
|
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
|
|
538
|
-
getFieldMessages(r)):{}}function
|
|
539
|
-
e,r.join(".")))}function
|
|
546
|
+
call(n,"mode")?V(n.mode).toLowerCase():"";if(!i)return o;if(!kp.has(i))throw new TypeError(`${r} must be one of: create,\
|
|
547
|
+
replace, patch.`);return i}function Ia(e=null,t=""){let r=V(t);if(!r)return{};let n=te(e);return Rr(n.schema)?te(n.schema.
|
|
548
|
+
getFieldMessages(r)):{}}function Lp(e=null,t=""){let r=V(t).split(".").filter(Boolean);return r.length<2?{}:(r.pop(),Ia(
|
|
549
|
+
e,r.join(".")))}function va(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
550
|
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
|
|
551
|
+
function Mp(e,t,r=null){let n=V(t?.code).toUpperCase(),o=xp[n]||{},i=te(t?.params),s=Ia(r,e),a=n==="FIELD_NOT_ALLOWED"&&
|
|
552
|
+
Object.keys(s).length<1?Lp(r,e):s,c=va(a,o.messageKey)||va(a,"default");if(c)return c.code?{message:c.message,code:c.code,
|
|
543
553
|
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"]),
|
|
554
|
+
message:u};let l=V(t?.code);return l?{message:l}:{...$p,params:{}}}function uo(e={},t=null){let r=te(e),n={},o={};for(let[
|
|
555
|
+
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}=Mp(
|
|
556
|
+
a,s,t);n[a]=c,u&&(o[a]={code:u,params:l})}return{fieldErrors:n,fieldErrorCodes:o}}var kp,xp,$p,jp,lo=g(()=>{G();kp=new Set(
|
|
557
|
+
["create","replace","patch"]),xp=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},
|
|
548
558
|
TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",
|
|
549
559
|
code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},
|
|
550
560
|
MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kern\
|
|
@@ -554,23 +564,23 @@ messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{message
|
|
|
554
564
|
.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{
|
|
555
565
|
messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{
|
|
556
566
|
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(!
|
|
562
|
-
be a json-rest-schema schema instance.`);let o={schema:n.schema},i=V(r).toLowerCase();return o.mode=
|
|
563
|
-
"patch",context:`${t}.mode`}),Object.freeze(o)}function
|
|
564
|
-
e,{context:r,defaultMode:n});return o?o.schema[o.mode](t):null}var Lt=g(()=>{G();
|
|
565
|
-
freeze({schema:
|
|
566
|
-
|
|
567
|
-
e,o?{cause:o}:void 0);if(e===
|
|
567
|
+
on.field.notEmpty"}}),$p=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),jp=Object.freeze(["c\
|
|
568
|
+
reate","replace","patch","toJsonSchema"])});function Dp(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&(Object.prototype.hasOwnProperty.call(e,"schema")||Object.
|
|
569
|
+
prototype.hasOwnProperty.call(e,"mode"))}function Nr(e,{context:t="schema definition",defaultMode:r=""}={}){if(e==null)return null;
|
|
570
|
+
if(!Dp(e))throw new TypeError(`${t} must be a schema definition object.`);let n=te(e);if(!Object.prototype.hasOwnProperty.
|
|
571
|
+
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!Rr(n.schema))throw new TypeError(`${t}.schema must \
|
|
572
|
+
be a json-rest-schema schema instance.`);let o={schema:n.schema},i=V(r).toLowerCase();return o.mode=Sa(n,{defaultMode:i||
|
|
573
|
+
"patch",context:`${t}.mode`}),Object.freeze(o)}function po(e,t,{context:r="schema definition",defaultMode:n=""}={}){let o=Nr(
|
|
574
|
+
e,{context:r,defaultMode:n});return o?o.schema[o.mode](t):null}var Lt=g(()=>{G();lo()});var Ta=g(()=>{Ue();G();jt();Lt()});var Aa=g(()=>{Ue();jt();Lt()});var Up,Vp,Oa=g(()=>{Ue();Up=$({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Vp=Object.
|
|
575
|
+
freeze({schema:Up,mode:"patch"})});var Pa,Gp,Ra=g(()=>{Pa=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),
|
|
576
|
+
Gp=Object.freeze({...Pa,nullable:!0})});var Na=g(()=>{G()});function ka({message:e=Ca,fieldErrors:t=null,fieldErrorCodes:r=null,errors:n=null,cause:o,statusCode:i=null}={}){let s=new Error(
|
|
577
|
+
e,o?{cause:o}:void 0);if(e===Ca&&(s.messageCode="kernel.validation.schemaFailed",s.messageParams={}),Number.isInteger(i)&&
|
|
568
578
|
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
579
|
a),s.details={...s.details||{},fieldErrors:t,...a?{fieldErrorCodes:a}:{}}}else n!=null&&(s.details={...s.details||{},errors:n});
|
|
570
|
-
return s}function
|
|
571
|
-
e,t,{defaultMode:r==="output"?"replace":"patch",context:n}),{fieldErrors:s,fieldErrorCodes:a}=
|
|
572
|
-
s).length>0)throw
|
|
573
|
-
|
|
580
|
+
return s}function mo(e,t,{phase:r="input",context:n="schema definition",statusCode:o=null}={}){if(e==null)return t;let i=po(
|
|
581
|
+
e,t,{defaultMode:r==="output"?"replace":"patch",context:n}),{fieldErrors:s,fieldErrorCodes:a}=uo(i.errors,e);if(Object.keys(
|
|
582
|
+
s).length>0)throw ka({fieldErrors:s,fieldErrorCodes:a,statusCode:o});return i.validatedObject??t}var Ca,xa=g(()=>{G();Lt();
|
|
583
|
+
Ca="Schema validation failed."});var qE,$a=g(()=>{G();qE=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.val\
|
|
574
584
|
idation.type"},{keyword:"minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.max\
|
|
575
585
|
Length"},{keyword:"minimum",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"\
|
|
576
586
|
exclusiveMinimum",code:"kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusi\
|
|
@@ -582,89 +592,89 @@ tion.maxItems"},{keyword:"additionalItems",code:"kernel.validation.additionalIte
|
|
|
582
592
|
kernel.validation.maxProperties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"\
|
|
583
593
|
propertyNames",code:"kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",
|
|
584
594
|
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
|
|
586
|
-
|
|
587
|
-
id must be a canonical positive integer string."}}}}),mode:"patch"})});var
|
|
588
|
-
let n=
|
|
589
|
-
s.`);return n}var N,M,H,
|
|
595
|
+
map(({keyword:e,code:t})=>[e,t]))});var ja,fo,Bp,Hp,La=g(()=>{Ue();jt();ja="^[1-9][0-9]*$",fo=Ae({type:"string",minLength:1,pattern:ja}),Bp=Ae({...fo,nullable:!0}),
|
|
596
|
+
Hp=Ae({schema:$({recordId:{...fo,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record\
|
|
597
|
+
id must be a canonical positive integer string."}}}}),mode:"patch"})});var Ma=g(()=>{G()});var Cr=g(()=>{Ue();An();Ta();Aa();Oa();Ra();Na();lo();Lt();xa();$a();La();Ma()});import{isDeepStrictEqual as zp}from"node:util";function xr(e,t){let r=Kp.get(e?.schemaVersion)||Ua;return ce(r,e,t)}function ce(e,t,r){
|
|
598
|
+
let n=mo({schema:e,mode:"create"},t,{context:r});if(!zp(t,n))throw new Error(`${r}: unknown fields or noncanonical value\
|
|
599
|
+
s.`);return n}var N,M,H,kr,Fp,qp,Da,Ua,Wp,Va,Yp,Jp,Kp,me,$r,jr,Ga,ut=g(()=>{Cr();N={type:"string",required:!0,noTrim:!0,
|
|
590
600
|
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),
|
|
601
|
+
isArray(r)&&r.length>t?`Expected at most ${t} items.`:void 0}),kr={type:"integer",required:!0,enum:[1]},Fp=H($({code:M}),
|
|
602
|
+
24),qp=$({id:M,kind:{...N,enum:["answer","practical"]},required:{type:"boolean",required:!0},rubric:N,evidence:{type:"ob\
|
|
593
603
|
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}})}})
|
|
604
|
+
explanationRequired:{type:"boolean",required:!1},files:{...H(N,8),required:!1,minLength:1}})}}),Da={code:M,title:N,prerequisites:Fp,
|
|
595
605
|
estimatedMinutes:{type:"integer",required:!0,min:1,max:180},visuals:H($({id:M,descriptor:N}),12),exercise:{type:"object",
|
|
596
606
|
required:!1,schema:$({kind:{...N,enum:["bundled"]},source:N,reuse:{...N,enum:["attempt","sequence"]},sequenceId:{...M,required:!1},
|
|
597
607
|
sequenceMode:{...N,required:!1,enum:["create","continue"]}})},checks:{...H($({id:M,file:N,assets:{...H(N,32),required:!1},
|
|
598
608
|
kind:{...N,required:!1,enum:["response","code"]},timeoutSeconds:{type:"integer",required:!1,min:1,max:60}}),12),required:!1},
|
|
599
609
|
appRoutes:{...H($({method:{...N,enum:["POST","PUT","PATCH","DELETE"]},path:{...N,maxLength:128,pattern:"^/[A-Za-z0-9._~:\
|
|
600
|
-
/-]*$"}}),16),required:!1}},
|
|
610
|
+
/-]*$"}}),16),required:!1}},Ua=$({schemaVersion:kr,...Da,document:N,assessments:H(qp,32)}),Wp=$({id:M,title:N,body:N,required:{
|
|
601
611
|
type:"boolean",required:!0},visual:{type:"object",required:!1,schema:$({id:M,play:{...H($({name:M,parameters:{type:"obje\
|
|
602
612
|
ct",required:!0}}),16),required:!1}})},guide:{type:"object",required:!1,schema:$({target:M,navigate:{type:"boolean",required:!1},
|
|
603
613
|
filePath:{...N,required:!1,maxLength:512},caption:{...N,required:!1}})},check:{type:"object",required:!0,schema:$({kind:{
|
|
604
614
|
...N,enum:["auto","choice","review","self","fact","none"]},check:{...M,required:!1},fact:{...M,required:!1},files:{...H(
|
|
605
615
|
N,8),required:!1},question:{...N,required:!1,maxLength:2e3},options:{...H(N,8),required:!1},answer:{...H({type:"integer",
|
|
606
616
|
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}})}}),
|
|
608
|
-
r",required:!0,enum:[2]},...
|
|
609
|
-
io","project"]}}),
|
|
617
|
+
onversation"]},2),required:!1}})}}),Va={...Da,notes:{...N,required:!1},steps:H(Wp,32)},Yp=$({schemaVersion:{type:"intege\
|
|
618
|
+
r",required:!0,enum:[2]},...Va}),Jp=$({schemaVersion:{type:"integer",required:!0,enum:[3]},...Va,stage:{...N,enum:["stud\
|
|
619
|
+
io","project"]}}),Kp=new Map([[1,Ua],[2,Yp],[3,Jp]]),me=e=>e?.schemaVersion===2||e?.schemaVersion===3;$r=$({schemaVersion:kr,
|
|
610
620
|
topicId:M,domainId:M,title:N,status:{...N,enum:["preview","released"]},outline:N,prerequisites:H($({topicId:M}),24),lessons:H(
|
|
611
621
|
$({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}}),
|
|
622
|
+
M,64),required:!1},activities:{...H(M,64),required:!1},facts:{...H(M,64),required:!1}}),jr=$({schemaVersion:kr,courseId:M,
|
|
613
623
|
title:N,release:N,status:{...N,enum:["preview","released"]},topics:H($({topicId:M,release:N}),32),orientation:{...M,required:!1}}),
|
|
614
|
-
|
|
624
|
+
Ga=$({schemaVersion:kr,id:M,title:N,svg:N,controller:N,assets:{...H(N,32),required:!1},initialState:M,states:H(M,32),description:{
|
|
615
625
|
...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
|
|
617
|
-
test(e.id||""))throw re("A place needs a lowercase id.");let t=`Place ${e.id}`;if(!
|
|
618
|
-
bel.`);if(!
|
|
626
|
+
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 rm(e){if(!B(e)||!Se.
|
|
627
|
+
test(e.id||""))throw re("A place needs a lowercase id.");let t=`Place ${e.id}`;if(!za(e.label))throw re(`${t} needs a la\
|
|
628
|
+
bel.`);if(!Xp.has(e.scope))throw re(`${t} scope is studio or project.`);let r=e.who??"everyone";if(!Qp.has(r))throw re(`${t}\
|
|
619
629
|
who is everyone or owner.`);let n=e.open??null;if(n!==null){let i=Object.keys(n||{}).sort().join(",");if(!(i==="pane"||
|
|
620
630
|
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
631
|
test(n.route):i==="learning"&&n.learning===!0))throw re(`${t} opens a project pane, a studio /app route, Courses, or not\
|
|
622
|
-
hing.`)}if(!Array.isArray(e.steps)||!e.steps.length||e.steps.length>6||e.steps.some(i=>!Se.test(i?.id||"")||!
|
|
632
|
+
hing.`)}if(!Array.isArray(e.steps)||!e.steps.length||e.steps.length>6||e.steps.some(i=>!Se.test(i?.id||"")||!za(i.label))||
|
|
623
633
|
e.steps.at(-1).id!==e.id)throw re(`${t} needs 1 to 6 labelled steps ending with itself.`);let o=e.shown??(n?.pane?[{pane:n.
|
|
624
634
|
pane,...n.databaseView?{databaseView:n.databaseView}:{}}]:n?.route?[{route:n.route}]:[]);if(!Array.isArray(o)||o.some(i=>!B(
|
|
625
635
|
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
636
|
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
637
|
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
|
|
638
|
+
...e.event?{event:e.event}:{}})}function nm(e){if(!B(e)||!Se.test(e.id||""))throw re("An activity needs a lowercase id.");
|
|
629
639
|
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
640
|
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
|
|
632
|
-
stringify(h)===JSON.stringify(y);function a({places:h=[],activities:y=[],facts:
|
|
641
|
+
{}})}function go(){return!1}function yo({places:e=Zp,activities:t=em,facts:r=tm}={}){let n=new Map,o=new Map,i=new Set,s=(h,y)=>JSON.
|
|
642
|
+
stringify(h)===JSON.stringify(y);function a({places:h=[],activities:y=[],facts:I=[]}={}){let S=h.map(rm),d=y.map(nm);for(let p of[
|
|
633
643
|
...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
|
-
n.has(p.id))throw re(`${p.id} is already registered with another meaning.`);for(let p of
|
|
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
|
|
644
|
+
n.has(p.id))throw re(`${p.id} is already registered with another meaning.`);for(let p of I)if(!Se.test(p||""))throw re("\
|
|
645
|
+
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 I)i.add(p)}a({places:e,
|
|
636
646
|
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
647
|
h)}function m(){return[...n.values()]}function f(){return new Set([...[...o.values()].map(h=>h.event),...[...n.values()].
|
|
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:
|
|
639
|
-
declaredPlace:
|
|
648
|
+
filter(h=>h.event).map(h=>h.event)])}return Object.freeze({register:a,place:c,activity:u,hasFact:l,places:m,events:f,declared:go,
|
|
649
|
+
declaredPlace:go,declaredActivity:go})}function Lr({places:e=[],activities:t=[],facts:r=[]}={}){let n=yo(),o=new Set(n.places().
|
|
640
650
|
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
651
|
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
652
|
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,
|
|
643
653
|
place:n.place,activity:n.activity,hasFact:l,places:n.places,events:n.events,declared:u,declaredPlace:a,declaredActivity:c})}
|
|
644
|
-
function Oe(e,t,r){return new ae(422,e,{code:t,params:r})}function
|
|
654
|
+
function Oe(e,t,r){return new ae(422,e,{code:t,params:r})}function Fa(e={},t=Ge){let r=typeof e.target=="string"?t.place(
|
|
645
655
|
e.target):null,n=!r&&t.declaredPlace(e.target);if(!r&&!n){let c=t.places().map(u=>u.id).join(", ");throw Oe(`Use one of \
|
|
646
656
|
this installation's guide places: ${c}.`,"VIBE64_TRAINING_GUIDE_INVALID",{places:c})}let o=e.target,i=e.navigate??!1,s=e.
|
|
647
657
|
highlight??!0;if(typeof i!="boolean"||typeof s!="boolean")throw Oe("navigate and highlight are booleans.","VIBE64_TRAINI\
|
|
648
658
|
NG_GUIDE_FLAGS_INVALID");if(!i&&!s)throw Oe("Point at the place (highlight) or open it (navigate); this request does nei\
|
|
649
659
|
ther.","VIBE64_TRAINING_GUIDE_ACTION_MISSING");if(i&&o==="dashboard")throw Oe("Dashboard has no single view to open. Poi\
|
|
650
660
|
nt at it, or open one Dashboard section such as files or database-erd.","VIBE64_TRAINING_GUIDE_DASHBOARD_UNOPENABLE");if(i&&
|
|
651
|
-
r&&!
|
|
661
|
+
r&&!om(r))throw Oe(`${r.label} has no view to open; point at it instead.`,"VIBE64_TRAINING_GUIDE_PLACE_UNOPENABLE",{place:r.
|
|
652
662
|
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
|
-
e files place.","VIBE64_TRAINING_GUIDE_FILE_PATH_MISPLACED");if(typeof e.filePath!="string"||!
|
|
663
|
+
e files place.","VIBE64_TRAINING_GUIDE_FILE_PATH_MISPLACED");if(typeof e.filePath!="string"||!_o.test(e.filePath))throw Oe(
|
|
654
664
|
"Use a relative practice project file path without '..'.","VIBE64_TRAINING_GUIDE_FILE_PATH_INVALID");a.filePath=e.filePath}
|
|
655
|
-
if(e.caption!==void 0){if(typeof e.caption!="string"||!e.caption.trim()||e.caption.length>
|
|
656
|
-
1 to ${
|
|
665
|
+
if(e.caption!==void 0){if(typeof e.caption!="string"||!e.caption.trim()||e.caption.length>wo)throw Oe(`Use a caption of \
|
|
666
|
+
1 to ${wo} characters.`,"VIBE64_TRAINING_GUIDE_CAPTION_INVALID",{limit:wo});a.caption=e.caption.trim()}return a}function qa(e,t={},r=Ge){
|
|
657
667
|
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
|
|
668
|
+
ring"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}function im(e,t=Ge){let r=new Set,n=new Set,o=new Set;
|
|
659
669
|
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
670
|
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,
|
|
663
|
-
owner"]),z=(e,t)=>Object.freeze({id:e,label:t}),
|
|
664
|
-
"Database"),
|
|
665
|
-
steps:[
|
|
666
|
-
project",open:{pane:"database",databaseView:"erd"},steps:[ve,
|
|
667
|
-
a",scope:"project",open:{pane:"database",databaseView:"data"},steps:[ve,
|
|
671
|
+
kind==="fact"&&o.add(e.check.fact),{places:[...r],activities:[...n],facts:[...o]}}var Se,Xp,Qp,z,Ba,ve,Ha,ho,Zp,em,tm,za,
|
|
672
|
+
Ge,_o,wo,om,Rb,Mr=g(()=>{pr();G();Se=/^[a-z][a-z0-9-]{0,63}$/u,Xp=new Set(["studio","project"]),Qp=new Set(["everyone","\
|
|
673
|
+
owner"]),z=(e,t)=>Object.freeze({id:e,label:t}),Ba=z("preview","Preview"),ve=z("dashboard","Dashboard"),Ha=z("database",
|
|
674
|
+
"Database"),ho=z("account-menu","Account menu"),Zp=[{id:"preview",label:"Preview",scope:"project",open:{pane:"preview"},
|
|
675
|
+
steps:[Ba]},{id:"dashboard",label:"Dashboard",scope:"project",open:null,steps:[ve]},{id:"database-erd",label:"ERD",scope:"\
|
|
676
|
+
project",open:{pane:"database",databaseView:"erd"},steps:[ve,Ha,z("database-erd","ERD")]},{id:"database-data",label:"Dat\
|
|
677
|
+
a",scope:"project",open:{pane:"database",databaseView:"data"},steps:[ve,Ha,z("database-data","Data")]},{id:"files",label:"\
|
|
668
678
|
Files",scope:"project",open:{pane:"files"},steps:[ve,z("files","Files")]},{id:"changes",label:"Current changes",scope:"p\
|
|
669
679
|
roject",open:{pane:"changes"},steps:[ve,z("changes","Current changes")]},{id:"git-log",label:"Git log",scope:"project",open:{
|
|
670
680
|
pane:"repository"},steps:[ve,z("git-log","Git log")]},{id:"session-info",label:"Session info",scope:"project",open:{pane:"\
|
|
@@ -672,56 +682,56 @@ session"},steps:[ve,z("session-info","Session info")]},{id:"architecture",label:
|
|
|
672
682
|
system"},steps:[ve,z("architecture","Architecture")]},{id:"publish",label:"Publish",scope:"project",open:{pane:"publish"},
|
|
673
683
|
steps:[ve,z("publish","Publish")]},{id:"chat",label:"Coding chat",scope:"project",open:null,shown:[{pane:"chat"},{chatVisible:!0}],
|
|
674
684
|
steps:[z("chat","Coding chat")]},{id:"save",label:"Save",scope:"project",open:null,event:"saved",steps:[z("save","Save")]},
|
|
675
|
-
{id:"reload-preview",label:"Reload preview",scope:"project",open:null,event:"preview-reloaded",steps:[
|
|
685
|
+
{id:"reload-preview",label:"Reload preview",scope:"project",open:null,event:"preview-reloaded",steps:[Ba,z("reload-previ\
|
|
676
686
|
ew","Reload preview")]},{id:"learning",label:"Learning",scope:"studio",open:{learning:!0},shown:[],event:"learn-toggled",
|
|
677
687
|
steps:[z("learning","Learning")]},{id:"lesson",label:"Lesson",scope:"studio",open:null,shown:[{pane:"lesson"}],steps:[z(
|
|
678
688
|
"lesson","Lesson")]},{id:"lesson-bar",label:"Lesson step bar",scope:"studio",open:null,steps:[z("lesson-bar","Lesson ste\
|
|
679
689
|
p bar")]},{id:"courses",label:"Courses",scope:"studio",open:null,shown:[{learningOpen:!0}],steps:[z("courses","Courses")]},
|
|
680
690
|
{id:"colleague",label:"Colleague",scope:"studio",open:null,event:"colleague-opened",steps:[z("colleague","Colleague")]},
|
|
681
|
-
{id:"account-menu",label:"Account menu",scope:"studio",open:null,steps:[
|
|
682
|
-
ngs",scope:"studio",open:null,steps:[
|
|
683
|
-
studio",open:null,steps:[
|
|
691
|
+
{id:"account-menu",label:"Account menu",scope:"studio",open:null,steps:[ho]},{id:"account-settings",label:"Account setti\
|
|
692
|
+
ngs",scope:"studio",open:null,steps:[ho,z("account-settings","Account settings")]},{id:"ai-setup",label:"AI setup",scope:"\
|
|
693
|
+
studio",open:null,steps:[ho,z("ai-setup","AI setup")]}],em=[{id:"send-message",event:"message-sent",place:"chat"},{id:"a\
|
|
684
694
|
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"}],
|
|
686
|
-
e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;Ge=
|
|
687
|
-
|
|
695
|
+
-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],tm=["ai-ready"];za=
|
|
696
|
+
e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;Ge=yo({facts:[]});_o=/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\u0000-\u001f\\]{1,512}$/u,
|
|
697
|
+
wo=256;om=e=>!!e?.open;Rb=Object.freeze({createLearningVocabulary:yo,lessonStepNeeds:im})});function ne(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_BEATS_INVALID"})}function mm(e,t,r){let n=um.exec(
|
|
688
698
|
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
699
|
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
700
|
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
701
|
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"&&!
|
|
693
|
-
othing the learner can do or be at.`);if(o==="check"&&!
|
|
694
|
-
if(s!==void 0){if(!
|
|
695
|
-
"send-message"?
|
|
696
|
-
...u.text.matchAll(
|
|
697
|
-
ed prompt of at most ${
|
|
702
|
+
a path.`);if(o==="show"&&!pm(i,r))throw ne(`${c} names an unknown place.`);if(o==="do"&&!dm(i,r))throw ne(`${c} names n\
|
|
703
|
+
othing the learner can do or be at.`);if(o==="check"&&!Eo[i])throw ne(`${c} must be check auto, review, done or fact.`);
|
|
704
|
+
if(s!==void 0){if(!_o.test(s))throw ne(`${c} needs a relative practice project file path without '..'.`);u.path=s}let l=i===
|
|
705
|
+
"send-message"?am:sm;if(u.text.length>l)throw ne(`${c} text is longer than ${l} characters.`);if(i==="send-message"){let m=[
|
|
706
|
+
...u.text.matchAll(lm)].map(f=>f[1].trim());if(m.length!==1||!m[0]||m[0].length>Ya)throw ne(`${c} needs exactly one quot\
|
|
707
|
+
ed prompt of at most ${Ya} characters.`);u.prompt=m[0]}return u}function Dr(e,t=Ge){let r=String(e??""),n=cm.exec(r);if(!n)
|
|
698
708
|
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
709
|
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
710
|
slice(0,i.index).split(`
|
|
701
|
-
`).map(u=>u.trim()).filter(Boolean);if(!s.length||s.length>
|
|
702
|
-
map((u,l)=>
|
|
711
|
+
`).map(u=>u.trim()).filter(Boolean);if(!s.length||s.length>Wa)throw ne(`a beats block holds 1 to ${Wa} beats.`);let a=s.
|
|
712
|
+
map((u,l)=>mm(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
713
|
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
|
|
706
|
-
scope==="project":!t.declared(e.target)}var
|
|
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(!
|
|
714
|
+
`),beats:a}}function fm(e,t=Ge){if(!e||e.kind==="check")return"";let r=t.activity(e.target);return r?r.place||"":e.target}
|
|
715
|
+
function Ja(e,t=Ge){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(fm(e,t));return r?r.
|
|
716
|
+
scope==="project":!t.declared(e.target)}var Wa,sm,Ya,am,Eo,cm,um,lm,dm,pm,bo=g(()=>{Mr();Wa=8,sm=160,Ya=500,am=600,Eo=Object.
|
|
717
|
+
freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),cm=/^```beats[ \t]*$/mu,um=/^(show|do|check)[ \t]+([a-z][a-z-]*)(?:[ \t]+([^:]+?))?[ \t]*(?::[ \t]*(.*))?$/u,
|
|
718
|
+
lm=/["“]([^"“”]+)["”]/gu;dm=(e,t)=>!!(t.activity(e)||t.place(e)?.event||qa(e,{},t)!==null||t.declared(e)),pm=(e,t)=>!!(t.
|
|
719
|
+
place(e)||t.declaredPlace(e))});import{createHash as hm}from"node:crypto";function K(e){return hm("sha256").update(e).digest("hex")}var lt=g(()=>{});import{lstat as gm,readFile as wm,readdir as ym,realpath as Ka}from"node:fs/promises";import ie from"node:path";function fe(e,t,r){
|
|
720
|
+
let n=new Set;for(let o of e){let i=t?o[t]:o;if(!Ur(i)||n.has(i))throw new Error(`${r}: invalid or duplicate ID ${i}.`);
|
|
711
721
|
n.add(i)}return n}function L(e){return Array.isArray(e)?`[${e.map(L).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(
|
|
712
|
-
e).sort().map(t=>`${JSON.stringify(t)}:${L(e[t])}`).join(",")}}`:JSON.stringify(e)}function
|
|
722
|
+
e).sort().map(t=>`${JSON.stringify(t)}:${L(e[t])}`).join(",")}}`:JSON.stringify(e)}function Qa(e,t){let r=e.get(t.path);
|
|
713
723
|
if(r&&(r.sha256!==t.sha256||r.bytes!==t.bytes))throw new Error(`Source changed between lesson snapshots: ${t.path}. Vali\
|
|
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)
|
|
715
|
-
async function
|
|
724
|
+
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)Qa(t,n);return[...t.values()]}
|
|
725
|
+
async function _m(e){let t=await Ka(e);async function r(i,s=t){if(typeof i!="string"||!i||i.includes("\\")||ie.isAbsolute(
|
|
716
726
|
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
|
-
`..${ie.sep}`)||ie.isAbsolute(c))throw new Error(`Path escapes topic: ${i}.`);if(await
|
|
727
|
+
`..${ie.sep}`)||ie.isAbsolute(c))throw new Error(`Path escapes topic: ${i}.`);if(await Ka(a)!==a)throw new Error(`Symlin\
|
|
718
728
|
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
|
|
729
|
+
i,s),c=await gm(a.filename);if(!c.isFile()||c.size>1024*1024)throw new Error(`Expected a regular file of at most 1 MiB: ${a.
|
|
730
|
+
relative}.`);return{...a,bytes:await wm(a.filename)}}async function o(i,s=t){let a=await n(i,s);return{...a,value:JSON.parse(
|
|
731
|
+
a.bytes.toString("utf8"))}}return Object.freeze({root:t,resolve:r,read:n,json:o})}function Em(e){let t=new Map(e.map(i=>[
|
|
722
732
|
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
733
|
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
|
|
734
|
+
i),r.add(i)}for(let i of e)o(i.code)}function bm(e,t,r,n){r(t);let o=t.bytes.toString("utf8");fe(e.assessments,"id","Ass\
|
|
725
735
|
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
736
|
id}"></a>$`,"mu").test(o)||a!==i.id)throw new Error(`Missing explicit rubric anchor for ${i.id}.`);if(i.kind==="practica\
|
|
727
737
|
l"&&!i.evidence)throw new Error(`Practical assessment ${i.id} needs an evidence producer.`);if(i.kind==="answer"&&i.evidence)
|
|
@@ -732,41 +742,41 @@ check&&!["exercise","code"].includes(i.evidence.producer))throw new Error(`Only
|
|
|
732
742
|
d check: ${i.id}.`);let u=(e.checks||[]).find(l=>l.id===i.evidence?.check)?.kind||"response";if(i.evidence?.producer==="\
|
|
733
743
|
code"){if(!e.exercise||!i.evidence.check||u!=="code"||!i.evidence.files?.length)throw new Error(`Code assessment ${i.id}\
|
|
734
744
|
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
|
|
745
|
+
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function vm(e,t,r,n,o,i){let s=a=>{throw new Error(
|
|
736
746
|
`Lesson ${n}: ${a}`)};e.schemaVersion===3&&e.stage==="project"&&!e.exercise&&s("a project lesson needs its exercise (a p\
|
|
737
747
|
ractice project)."),e.steps.length||s("needs at least one step."),fe(e.steps,"id","Steps"),e.steps.some(a=>a.required)||
|
|
738
748
|
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} \
|
|
739
|
-
shows undeclared visual ${a.visual.id}.`);for(let y of a.visual.play||[]){let
|
|
749
|
+
shows undeclared visual ${a.visual.id}.`);for(let y of a.visual.play||[]){let I=h.commands.find(d=>d.name===y.name);I||s(
|
|
740
750
|
`${c} plays undeclared command ${y.name}.`);let S=y.parameters;(!S||typeof S!="object"||Array.isArray(S))&&s(`${c} comma\
|
|
741
|
-
nd ${y.name} needs a parameters object.`);for(let[d,p]of Object.entries(S)){let _=
|
|
751
|
+
nd ${y.name} needs a parameters object.`);for(let[d,p]of Object.entries(S)){let _=I.parameters.find(b=>b.name===d);_||s(
|
|
742
752
|
`${c} command ${y.name} has undeclared parameter ${d}.`),(typeof p!="string"||p.length>_.maxLength)&&s(`${c} command ${y.
|
|
743
|
-
name} parameter ${d} must be a string of at most ${_.maxLength} characters.`)}for(let d of
|
|
744
|
-
hasOwn(S,d.name)&&s(`${c} command ${y.name} needs parameter ${d.name}.`)}}if(a.guide){let{caption:h,...y}=a.guide;try{
|
|
745
|
-
y,i)}catch(
|
|
746
|
-
target} needs the lesson's exercise (a practice project).`)}let u=null;try{({beats:u}=
|
|
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(
|
|
748
|
-
kind==="check");h&&
|
|
749
|
-
let y=u.find(
|
|
753
|
+
name} parameter ${d} must be a string of at most ${_.maxLength} characters.`)}for(let d of I.parameters)d.required&&!Object.
|
|
754
|
+
hasOwn(S,d.name)&&s(`${c} command ${y.name} needs parameter ${d.name}.`)}}if(a.guide){let{caption:h,...y}=a.guide;try{Fa(
|
|
755
|
+
y,i)}catch(I){s(`${c} guide: ${I.message}`)}i.place(a.guide.target)?.scope==="project"&&!e.exercise&&s(`${c} guide ${a.guide.
|
|
756
|
+
target} needs the lesson's exercise (a practice project).`)}let u=null;try{({beats:u}=Dr(o.get(a.body),i))}catch(h){s(`${c}\
|
|
757
|
+
beats: ${h.message}`)}if(u){a.guide&&s(`${c} has both beats and a guide; its beats replace the guide.`);let h=u.find(I=>I.
|
|
758
|
+
kind==="check");h&&Eo[h.target]!==a.check.kind&&s(`${c} beat check ${h.target} does not match its ${a.check.kind} check.`);
|
|
759
|
+
let y=u.find(I=>Ja(I,i));y&&!e.exercise&&s(`${c} beat ${y.kind} ${y.target} needs the lesson's exercise (a practice proj\
|
|
750
760
|
ect).`)}let l=a.check,m={auto:["check","files"],choice:["question","options","answer"],review:["rubric","evidence"],fact:[
|
|
751
761
|
"fact"],self:[],none:[]}[l.kind],f=Object.keys(l).filter(h=>h!=="kind"&&!m.includes(h));if(f.length&&s(`${c} ${l.kind} c\
|
|
752
762
|
heck cannot declare ${f.join(", ")}.`),l.kind==="none"&&a.required&&s(`${c} has no check and cannot be required.`),l.kind===
|
|
753
763
|
"fact"&&(e.schemaVersion!==3&&s(`${c} fact check needs lesson format 3.`),(!l.fact||!i.hasFact(l.fact))&&s(`${c} checks \
|
|
754
764
|
an unknown fact; declare a host's fact in the topic's facts.`)),l.kind==="auto"){(!l.check||!r.has(l.check))&&s(`${c} na\
|
|
755
765
|
mes an unknown check.`),e.exercise||s(`${c} runs a declared check and needs the lesson's exercise.`);let h=e.checks.find(
|
|
756
|
-
|
|
766
|
+
I=>I.id===l.check),y=l.files||[];(h.kind==="code"?y.length<1||y.length>8:y.length)&&s(`${c} ${h.kind==="code"?"code chec\
|
|
757
767
|
k needs 1-8 exercise files":"names files, but only a code check edits files"}.`)}if(l.kind==="review"){l.rubric?.trim()||
|
|
758
768
|
s(`${c} review needs its rubric.`),e.exercise||s(`${c} reviews practice work and needs the lesson's exercise.`);let h=l.
|
|
759
769
|
evidence||["changes"];(h[0]!=="changes"||h.length>2||h.length===2&&h[1]!=="conversation")&&s(`${c} review evidence is ["\
|
|
760
|
-
changes"] or ["changes", "conversation"].`)}if(l.kind==="choice"){let{question:h,options:y,answer:
|
|
761
|
-
choice needs question, options and answer.`),(y.length<2||y.length>8)&&s(`${c} choice needs 2-8 options.`),(!
|
|
762
|
-
new Set(
|
|
763
|
-
tions.`)}}}async function
|
|
770
|
+
changes"] or ["changes", "conversation"].`)}if(l.kind==="choice"){let{question:h,options:y,answer:I}=l;(!h||!y||!I)&&s(`${c}\
|
|
771
|
+
choice needs question, options and answer.`),(y.length<2||y.length>8)&&s(`${c} choice needs 2-8 options.`),(!I.length||
|
|
772
|
+
new Set(I).size!==I.length||I.some(S=>S>=y.length))&&s(`${c} choice answer must list unique option indexes within its op\
|
|
773
|
+
tions.`)}}}async function Sm(e,t,{authoring:r,installed:n,vocabulary:o}){let i=await e.json(t.descriptor),s=xr(i.value,t.
|
|
764
774
|
code);if(s.code!==t.code)throw new Error(`Lesson code mismatch: ${t.code}.`);if(r&&s.schemaVersion!==3)throw new Error(`\
|
|
765
775
|
Lesson ${t.code} uses retired lesson format ${s.schemaVersion}. Author it in format 3 with steps and its stage.`);let a=ie.
|
|
766
|
-
dirname(i.filename),c=new Map;function u(d){if(
|
|
776
|
+
dirname(i.filename),c=new Map;function u(d){if(Qa(c,{path:d.relative,sha256:K(d.bytes),bytes:d.bytes.length}),c.size>512||
|
|
767
777
|
[...c.values()].reduce((p,_)=>p+_.bytes,0)>32*1024*1024)throw new Error(`Lesson ${t.code} exceeds bundle limits.`)}u(i);
|
|
768
778
|
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&&
|
|
779
|
+
checks||[]){u(await e.read(d.file,a));for(let p of d.assets||[])u(await e.read(p,a))}if(s.schemaVersion===1&&bm(s,await e.
|
|
770
780
|
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
781
|
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
782
|
code} can declare app routes only with its exercise.`);let h=new Set;for(let d of s.appRoutes||[]){if(d.path!=="/"&&!d.path.
|
|
@@ -775,159 +785,159 @@ slice(1).split("/").every(_=>_===":id"||/^[A-Za-z0-9._~-]+$/u.test(_)))throw new
|
|
|
775
785
|
.`);h.add(p)}for(let d of s.checks||[])if(d.timeoutSeconds!==void 0&&d.kind!=="code")throw new Error(`Only a code check \
|
|
776
786
|
declares a timeout: ${d.id}.`);if(s.schemaVersion===1&&!s.assessments.some(d=>d.required))throw new Error(`Lesson ${t.code}\
|
|
777
787
|
needs a required assessment.`);fe(s.visuals,"id","Visuals");let y=new Map;for(let d of s.visuals){let p=await e.json(d.
|
|
778
|
-
descriptor,a),_=ce(
|
|
788
|
+
descriptor,a),_=ce(Ga,p.value,d.id);if(_.id!==d.id)throw new Error(`Visual ID mismatch: ${d.id}.`);let b=fe(_.states,null,
|
|
779
789
|
"Visual states");if(!b.has(_.initialState))throw new Error(`Unknown initial visual state: ${_.initialState}.`);fe(_.commands,
|
|
780
790
|
"name","Visual commands");for(let w of _.commands)if(fe(w.parameters,"name","Command parameters"),w.completionState!=="u\
|
|
781
791
|
nchanged"&&!b.has(w.completionState))throw new Error(`Unknown completion state: ${w.name}.`);u(p),y.set(_.id,_);let v=ie.
|
|
782
792
|
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
793
|
exercise){let d=s.exercise;if(d.reuse==="sequence"){if(!d.sequenceId||!d.sequenceMode)throw new Error(`Invalid exercise \
|
|
784
794
|
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
|
|
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
|
|
788
|
-
read(E);u(
|
|
795
|
+
if(d.sequenceId&&!Ur(d.sequenceId))throw new Error("Invalid exercise sequence ID.");let p=await e.resolve(d.source,a);async function _(v){
|
|
796
|
+
for(let w of(await ym(v,{withFileTypes:!0})).sort((E,A)=>E.name<A.name?-1:E.name>A.name?1:0)){if(Xa.has(w.name))continue;
|
|
797
|
+
let E=ie.relative(e.root,ie.join(v,w.name)),A=await e.resolve(E);if(w.isDirectory())await _(A.filename);else{let T=await e.
|
|
798
|
+
read(E);u(T),l.add(T.relative)}}}await _(p.filename);let b=s.schemaVersion===1?s.assessments.map(v=>[`Code assessment ${v.
|
|
789
799
|
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
|
-
split("/");if(E.includes("\\")||ie.posix.isAbsolute(E)||A.some(
|
|
800
|
+
split("/");if(E.includes("\\")||ie.posix.isAbsolute(E)||A.some(T=>!T||T==="."||T===".."||Xa.has(T))||!c.has(p.relative?`${p.
|
|
791
801
|
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
|
|
802
|
+
throw new Error(`${v} repeats a declared file.`)}}let I="";if(me(s))try{vm(s,y,f,t.code,m,o)}catch(d){if(!n)throw d;I=d.
|
|
793
803
|
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
|
-
lesson:s,manifest:S,hash:
|
|
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(!
|
|
804
|
+
lesson:s,manifest:S,hash:K(L(S)),descriptorPath:i.relative,served:l,...I?{problem:I}:{}}}async function He(e,t={}){let{authoring:r=!1,
|
|
805
|
+
installed:n=!1}=t,o=await _m(e),i=await o.json("package.json");if(!/^learn-[a-z0-9-]+$/u.test(i.value.name||"")||!/^\d+\.\d+\.\d+$/u.
|
|
806
|
+
test(i.value.version||""))throw new Error("Topic package needs a learn- name and an exact release version.");let s=ce($r,
|
|
807
|
+
i.value.vibe64Training,"Topic");if(!Ur(s.topicId)||!Ur(s.domainId))throw new Error("Invalid topic or domain ID.");let a=await o.
|
|
798
808
|
read(s.outline);if(fe(s.lessons,"code","Lessons"),fe(s.prerequisites,"topicId","Topic prerequisites"),!s.lessons.length)
|
|
799
809
|
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:
|
|
802
|
-
required:y.required})}for(let{descriptorPath:y,lesson:
|
|
803
|
-
ptor cannot also be a step body, notes, visual or exercise file.`);
|
|
804
|
-
code:S}of
|
|
805
|
-
t precede ${
|
|
806
|
-
lesson.code} requires draft ${S}.`)}let m=new Map;for(let{lesson:y,descriptorPath:
|
|
807
|
-
"sequence")continue;let d=(await o.resolve(y.exercise.source,ie.dirname(ie.join(o.root,
|
|
810
|
+
throw new Error("A released topic contains required draft lessons.");let c=Lr(s),u=[],l=new Set;for(let y of s.lessons){
|
|
811
|
+
let{served:I,...S}=await Sm(o,y,{authoring:r,installed:n,vocabulary:c});for(let d of I)l.add(d);u.push({...S,status:y.status,
|
|
812
|
+
required:y.required})}for(let{descriptorPath:y,lesson:I}of u)if(me(I)&&l.has(y))throw new Error(`Lesson ${I.code} descri\
|
|
813
|
+
ptor cannot also be a step body, notes, visual or exercise file.`);Em(u.map(y=>y.lesson));for(let[y,I]of u.entries())for(let{
|
|
814
|
+
code:S}of I.lesson.prerequisites){let d=u.findIndex(p=>p.lesson.code===S);if(d>=y)throw new Error(`Prerequisite ${S} mus\
|
|
815
|
+
t precede ${I.lesson.code}.`);if(I.status==="published"&&u[d].status!=="published")throw new Error(`Published lesson ${I.
|
|
816
|
+
lesson.code} requires draft ${S}.`)}let m=new Map;for(let{lesson:y,descriptorPath:I,status:S}of u){if(y.exercise?.reuse!==
|
|
817
|
+
"sequence")continue;let d=(await o.resolve(y.exercise.source,ie.dirname(ie.join(o.root,I)))).relative,p=m.get(y.exercise.
|
|
808
818
|
sequenceId);if(y.exercise.sequenceMode==="create"){if(p)throw new Error(`Invalid create/continue sequence: ${y.code}.`);
|
|
809
819
|
m.set(y.exercise.sequenceId,{source:d,status:S})}else if(!p||p.source!==d||S==="published"&&p.status!=="published")throw new Error(
|
|
810
|
-
`Invalid create/continue sequence: ${y.code}.`)}let f=[i,a].map(y=>({path:y.relative,sha256:
|
|
811
|
-
h={schemaVersion:1,topic:s,release:i.value.version,files:f,lessons:u.map(({lesson:y,hash:
|
|
812
|
-
code,hash:
|
|
813
|
-
topicHash:
|
|
814
|
-
test(e)});import{execFile as
|
|
815
|
-
import{promisify as
|
|
816
|
-
":")){let r=new Error("A valid OS username is required.");throw r.code="vibe64_invalid_os_username",r}return t}function
|
|
820
|
+
`Invalid create/continue sequence: ${y.code}.`)}let f=[i,a].map(y=>({path:y.relative,sha256:K(y.bytes),bytes:y.bytes.length})),
|
|
821
|
+
h={schemaVersion:1,topic:s,release:i.value.version,files:f,lessons:u.map(({lesson:y,hash:I,status:S,required:d})=>({code:y.
|
|
822
|
+
code,hash:I,status:S,required:d}))};return Be([h,...u.map(y=>y.manifest)]),{topic:s,release:i.value.version,bundles:u,topicManifest:h,
|
|
823
|
+
topicHash:K(L(h))}}var Xa,Ur,dt=g(()=>{ut();Mr();bo();lt();Xa=new Set([".git","node_modules",".genesis"]),Ur=e=>/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u.
|
|
824
|
+
test(e)});import{execFile as Im}from"node:child_process";import{readFile as Tm}from"node:fs/promises";import vo from"node:os";import Am from"node:path";
|
|
825
|
+
import{promisify as Om}from"node:util";function ec(e=""){let t=V(e);if(!t||t.includes("/")||t.includes("\\")||t.includes(
|
|
826
|
+
":")){let r=new Error("A valid OS username is required.");throw r.code="vibe64_invalid_os_username",r}return t}function tc([
|
|
817
827
|
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
828
|
s)||!Number.isSafeInteger(a)?null:{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),
|
|
819
|
-
uid:s,username:String(e||"")}}function
|
|
820
|
-
t[3],t[4],t[5],t[6]])}function
|
|
821
|
-
split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);o&&(r[o[1]]=o[2].trim())}return
|
|
822
|
-
dir,r.shell])}).filter(Boolean)}async function
|
|
823
|
-
string"?n:n?.stdout)||"")}function Mt({homedir:e=
|
|
824
|
-
env.USER||process.env.LOGNAME),o=
|
|
829
|
+
uid:s,username:String(e||"")}}function So(e=""){let t=String(e||"").trim().split(":");return t.length<7?null:tc([t[0],t[2],
|
|
830
|
+
t[3],t[4],t[5],t[6]])}function Rm(e=""){return String(e||"").split(/\r?\n[\t ]*\r?\n/u).map(t=>{let r={};for(let n of t.
|
|
831
|
+
split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);o&&(r[o[1]]=o[2].trim())}return tc([r.name,r.uid,r.gid,r.gecos,r.
|
|
832
|
+
dir,r.shell])}).filter(Boolean)}async function Za(e,t,r){let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="\
|
|
833
|
+
string"?n:n?.stdout)||"")}function Mt({homedir:e=vo.homedir,userInfo:t=vo.userInfo}={}){let r=t(),n=V(r?.username||process.
|
|
834
|
+
env.USER||process.env.LOGNAME),o=Am.resolve(String(r?.homedir||e()||""));return{displayName:String(r?.username||n),gid:Number.
|
|
825
835
|
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
|
|
836
|
+
async function Vr(e="",{execFileFn:t=Pm,platform:r=process.platform,readFileFn:n=Tm,userInfo:o=vo.userInfo}={}){let i=ec(
|
|
827
837
|
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
838
|
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
|
-
"/etc/passwd","utf8").catch(()=>"")).split(/\r?\n/u).map(
|
|
830
|
-
n"){let a=Mt({userInfo:o});if(a.username===i)return a;[s]=
|
|
831
|
-
s=
|
|
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=
|
|
834
|
-
t);if(!r||!n)return!1;let o=
|
|
835
|
-
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ue(e={}){return Object.fromEntries(Object.entries(
|
|
836
|
-
([t,r])=>[
|
|
837
|
-
[e]){let o=
|
|
838
|
-
isFinite(t)?t:0}function
|
|
839
|
-
return{displayName:
|
|
840
|
-
Mt())}async function
|
|
841
|
-
username,USER:r.username,XDG_CACHE_HOME:
|
|
842
|
-
join(r.home,".local","share")}}function
|
|
843
|
-
getuid=="function"?process.getuid():null}}var
|
|
839
|
+
"/etc/passwd","utf8").catch(()=>"")).split(/\r?\n/u).map(So).find(f=>f?.username===i);if(m)return m}}let s;if(r==="darwi\
|
|
840
|
+
n"){let a=Mt({userInfo:o});if(a.username===i)return a;[s]=Rm(await Za(t,"dscacheutil",["-q","user","-a","name",i]))}else
|
|
841
|
+
s=So((await Za(t,"getent",["passwd",i])).split(/\r?\n/u)[0]);if(!s||s.username!==i){let a=new Error(`OS user was not fou\
|
|
842
|
+
nd: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var Pm,Yb,Gr=g(()=>{G();Pm=Om(Im);Yb=Object.freeze({parsePasswdLine:So})});var rc=g(()=>{Gr();G()});import Br from"node:path";function R(e=""){return String(e??"").trim()}function Io(e=null){let t=Number(e);return Number.
|
|
843
|
+
isSafeInteger(t)&&t>=0?t:null}function C(e=""){let t=R(e);return t?Br.resolve(t):""}function Pe(e="",t=""){let r=C(e),n=C(
|
|
844
|
+
t);if(!r||!n)return!1;let o=Br.relative(r,n);return o!==".."&&!o.startsWith(`..${Br.sep}`)&&!Br.isAbsolute(o)}function J(e={}){
|
|
845
|
+
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ue(e={}){return Object.fromEntries(Object.entries(J(e)).map(
|
|
846
|
+
([t,r])=>[R(t),String(r??"")]).filter(([t])=>!!t))}function ze(e=[]){let t=[],r=new Set;for(let n of Array.isArray(e)?e:
|
|
847
|
+
[e]){let o=R(n);!o||r.has(o)||(r.add(o),t.push(o))}return t}function pt(e){let t=Date.parse(String(e||"").trim());return Number.
|
|
848
|
+
isFinite(t)?t:0}function Ie(...e){for(let t of e){let r=R(t);if(r)return r}return""}var q=g(()=>{});import Nm from"node:os";import To from"node:path";function Ao(e={}){let t=R(e.username),r=C(e.home||(t?`/home/${t}`:Nm.homedir()));
|
|
849
|
+
return{displayName:R(e.displayName||t),gid:Io(e.gid),home:r,shell:R(e.shell),uid:Io(e.uid),username:t}}function Oo(){return Ao(
|
|
850
|
+
Mt())}async function Po(e="",t={}){return Ao(await Vr(e,t))}function Dt(e={},t={}){let r=Ao(e);return{...t,HOME:r.home,LOGNAME:r.
|
|
851
|
+
username,USER:r.username,XDG_CACHE_HOME:To.join(r.home,".cache"),XDG_CONFIG_HOME:To.join(r.home,".config"),XDG_DATA_HOME:To.
|
|
852
|
+
join(r.home,".local","share")}}function nc(){return{gid:typeof process.getgid=="function"?process.getgid():null,uid:typeof process.
|
|
853
|
+
getuid=="function"?process.getuid():null}}var mt=g(()=>{Gr();q()});function Cm(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
854
|
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=
|
|
846
|
-
`)).trim();return{code:
|
|
847
|
-
Number(s):null,signal:
|
|
848
|
-
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof f=="boolean"?{retryable:f}:{}}}function
|
|
849
|
-
d",r={}){let n=
|
|
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
|
|
855
|
+
let h=Cm(r),y=String(u||""),I=String(c||""),S=String(o||[y,I].filter(Boolean).join(`
|
|
856
|
+
`)).trim();return{code:R(e),error:R(t),exitCode:h,ok:n===null?h===0:n===!0,output:S,pid:Number.isSafeInteger(Number(s))?
|
|
857
|
+
Number(s):null,signal:R(a),stderr:I,stdout:y,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...m&&typeof m=="obje\
|
|
858
|
+
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof f=="boolean"?{retryable:f}:{}}}function X(e="",t="vibe64_command_faile\
|
|
859
|
+
d",r={}){let n=R(e)||"Vibe64 command failed.";return Ut({...r,code:t,error:n,exitCode:1,ok:!1,output:R(r.output)||n,stderr:r.
|
|
860
|
+
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}var Fe=g(()=>{q()});import{spawn as km}from"node:child_process";import{statSync as xm}from"node:fs";import $m from"node:path";import{StringDecoder as jm}from"node:string_decoder";
|
|
861
|
+
import{stripVTControlCharacters as Lm}from"node:util";function ac(e){return e.replaceAll(Um,t=>{if(ic[t]!==void 0)return ic[t];
|
|
862
|
+
let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.toString(16)}`})}function Vm(e){return Lm(
|
|
853
863
|
e).split(`
|
|
854
|
-
`).map(
|
|
855
|
-
`)}function
|
|
856
|
-
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function
|
|
857
|
-
return r;try{if(!
|
|
864
|
+
`).map(ac).join(`
|
|
865
|
+
`)}function Gm(e,t){return[e,...t].map(r=>{let n=ac(String(r));return Dm.test(n)?n:process.platform==="win32"?`"${n.replaceAll(
|
|
866
|
+
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function Bm(e,t){let r=String(e?.message??e);if(t===process.cwd())
|
|
867
|
+
return r;try{if(!xm(t).isDirectory())return`The "cwd" option is not a directory: ${t}.
|
|
858
868
|
${r}`}catch(n){return`The "cwd" option is invalid: ${t}.
|
|
859
869
|
${n.message}
|
|
860
|
-
${r}`}return r}function
|
|
870
|
+
${r}`}return r}function Hm(e){let t=e.forcefullyTerminated?` and was forcefully terminated after ${sc} milliseconds`:"";
|
|
861
871
|
if(e.timedOut)return`Command timed out after ${e.timeout} milliseconds${t}`;if(e.maxBuffer)return`Command's ${e.maxBuffer.
|
|
862
872
|
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
|
|
873
|
+
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=Mm[e.signal];return`Command was killed with ${e.signal}${r?` (${r})`:
|
|
874
|
+
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function zm(e){let t=e.spawnError?
|
|
875
|
+
Vm(Bm(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${Hm(e)}: ${e.commandLine}${t?`
|
|
876
|
+
${t}`:""}`}function Ro(e,t){let r=new jm(e),n=[],o=0,i=!1;return{write(s){if(i)return!1;let a=r.write(s);return o+a.length>
|
|
867
877
|
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
|
-
i=!0}return n.join("")}}}function
|
|
869
|
-
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:
|
|
870
|
-
f=
|
|
871
|
-
h={commandLine:
|
|
872
|
-
y=!1,
|
|
873
|
-
()=>{!y&&f.kill("SIGKILL")&&(h.forcefullyTerminated=!0)},
|
|
878
|
+
i=!0}return n.join("")}}}function cc(e,t,{cwd:r="",env:n={},input:o=void 0,maxBuffer:i=oc,onOutput:s=null,outputEncoding:a="\
|
|
879
|
+
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:oc,l={all:Ro(a,u*2),stderr:Ro(a,u),stdout:Ro(a,u)},m=o!=null,
|
|
880
|
+
f=km(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[m?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
881
|
+
h={commandLine:Gm(e,t),cwd:$m.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
882
|
+
y=!1,I=null,S=()=>{};f.on("error",v=>{h.spawnError||=v,f.pid===void 0&&S()});let d=()=>{y||!f.kill("SIGTERM")||I||(I=setTimeout(
|
|
883
|
+
()=>{!y&&f.kill("SIGKILL")&&(h.forcefullyTerminated=!0)},sc))},p=(v,w)=>E=>{if(l.all.write(E),l[v].write(E)||(h.maxBuffer||=
|
|
874
884
|
{limit:u,stream:v,unit:"characters"},w.destroy()),typeof s=="function")try{s(String(E||""))}catch{}};f.stdout&&f.stdout.
|
|
875
885
|
on("data",p("stdout",f.stdout)),f.stderr&&f.stderr.on("data",p("stderr",f.stderr)),m&&f.stdin&&(f.stdin.on("error",()=>{}),
|
|
876
886
|
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
|
-
y=!0,clearTimeout(_),clearTimeout(
|
|
878
|
-
|
|
879
|
-
shortMessage:
|
|
880
|
-
once("close",S)}),kill:v=>f.kill(v),pid:f.pid}}var
|
|
887
|
+
y=!0,clearTimeout(_),clearTimeout(I);let A=h.spawnError?{}:{exitCode:typeof w=="number"&&w>=0?w:void 0,signal:E||void 0},
|
|
888
|
+
T=h.spawnError||h.timedOut||h.maxBuffer||A.exitCode!==0;v({all:l.all.text(),code:h.spawnError?.code,exitCode:A.exitCode,
|
|
889
|
+
shortMessage:T?zm({...h,...A}):"",signal:A.signal,stderr:l.stderr.text(),stdout:l.stdout.text(),timedOut:h.timedOut})},f.
|
|
890
|
+
once("close",S)}),kill:v=>f.kill(v),pid:f.pid}}var oc,sc,Mm,Dm,Um,ic,uc=g(()=>{oc=1e8,sc=5e3,Mm=Object.freeze({SIGABRT:"\
|
|
881
891
|
Aborted",SIGALRM:"Timeout or timer",SIGHUP:"Terminal closed",SIGINT:"User interruption with CTRL-C",SIGKILL:"Forced term\
|
|
882
892
|
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"),
|
|
885
|
-
import
|
|
886
|
-
let t=
|
|
893
|
+
Termination",SIGUSR1:"Application-specific signal",SIGUSR2:"Application-specific signal"}),Dm=/^[\w./-]+$/u,Um=new RegExp(
|
|
894
|
+
"\\p{Separator}|\\p{Other}","gu"),ic=Object.freeze({" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"})});import{spawn as pc}from"node:child_process";import{mkdir as qm,open as Wm,readdir as Ym,readFile as Jm}from"node:fs/promises";
|
|
895
|
+
import Km from"node:path";import{fileURLToPath as Xm}from"node:url";function tf(e){if(process.platform!=="win32"){if(!de){
|
|
896
|
+
let t=pc(process.execPath,[ef],{cwd:"/",detached:!0,stdio:["pipe","ignore","ignore"]});t.once("error",()=>{de===t&&(de=null)}),
|
|
887
897
|
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
898
|
r.scopeEmpty!==!0&&r.pid!==e&&t.stdin.write(`+${r.pid}
|
|
889
899
|
`)}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}),
|
|
893
|
-
!0,i(s))};e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function
|
|
894
|
-
try{o=await
|
|
895
|
-
detached:!0,env:n,stdio:i});await
|
|
896
|
-
s.pid)),s.once("exit",()=>{!
|
|
897
|
-
s.unref(),Ut({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return
|
|
900
|
+
`)}}function rf(e){de&&(de.stdin.write(`-${e}
|
|
901
|
+
`),![...qe.values()].some(t=>t.scopeEmpty!==!0)&&(de.stdin.end(),de=null))}async function nf(e=""){return e?(await qm(Km.
|
|
902
|
+
dirname(e),{recursive:!0}),Wm(e,"w",384)):null}async function of(e){return new Promise((t,r)=>{let n=!1,o=(i,s)=>{n||(n=
|
|
903
|
+
!0,i(s))};e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function mc(e={},t={}){let{cwd:r="",env:n={}}=t,o=null;
|
|
904
|
+
try{o=await nf(e.logPath);let i=o?["ignore",o.fd,o.fd]:["ignore","ignore","ignore"],s=pc(e.command,e.args,{cwd:r||void 0,
|
|
905
|
+
detached:!0,env:n,stdio:i});await of(s);let a=e.execution?.id||"";return a&&(qe.set(a,{child:s,pid:Number(s.pid)}),tf(Number(
|
|
906
|
+
s.pid)),s.once("exit",()=>{!Hr(s.pid)&&qe.has(a)&&(qe.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),rf(Number(s.pid)))})),
|
|
907
|
+
s.unref(),Ut({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return X(i?.
|
|
898
908
|
message||"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{
|
|
899
|
-
await o?.close().catch(()=>null)}}function
|
|
909
|
+
await o?.close().catch(()=>null)}}function Hr(e=null){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;if(process.
|
|
900
910
|
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
|
|
911
|
+
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function lc(e=null,t="SIGTERM"){if(!Hr(e))return!1;try{
|
|
902
912
|
return process.platform==="win32"?[...qe.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),
|
|
903
|
-
!0}catch(r){if(r?.code==="ESRCH")return!1;throw r}}async function
|
|
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
|
|
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
|
|
907
|
-
let r=Date.now()+Math.max(0,Number(t)||0);for(;
|
|
908
|
-
async function
|
|
909
|
-
(
|
|
910
|
-
cution/src/server/engines/detached.js",import.meta.url).href,qe=new Map,
|
|
911
|
-
|
|
912
|
-
outputEncoding:u="utf8",signal:l=null,timeout:m=15e3}=r,f,h,y,
|
|
913
|
-
if(l?.aborted)return
|
|
914
|
-
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});
|
|
915
|
-
A=
|
|
913
|
+
!0}catch(r){if(r?.code==="ESRCH")return!1;throw r}}async function fc(e=null,t=10){let r=Number(e);if(process.platform!==
|
|
914
|
+
"linux"||!Number.isSafeInteger(r)||r<=0)return[];let n=[];for(let o of await Ym("/proc").catch(()=>[])){if(n.length>=t)break;
|
|
915
|
+
if(!/^\d+$/u.test(o))continue;let i=await Jm(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(
|
|
916
|
+
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 dc(e=null,t=0){
|
|
917
|
+
let r=Date.now()+Math.max(0,Number(t)||0);for(;Hr(e)&&Date.now()<r;)await new Promise(n=>setTimeout(n,25));return!Hr(e)}
|
|
918
|
+
async function zr(e=null,t={}){let{killTimeoutMs:r=Zm,termTimeoutMs:n=Qm}=t;lc(e,"SIGTERM");let o=await dc(e,n);return o||
|
|
919
|
+
(lc(e,"SIGKILL"),o=await dc(e,r)),o}var Fm,qe,Qm,Zm,ef,de,Vt=g(()=>{Fe();Fm=new URL("./../node_modules/@local/vibe64-exe\
|
|
920
|
+
cution/src/server/engines/detached.js",import.meta.url).href,qe=new Map,Qm=3e3,Zm=1e3,ef=Xm(new URL("./detachedReaper.js",
|
|
921
|
+
Fm)),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,
|
|
922
|
+
outputEncoding:u="utf8",signal:l=null,timeout:m=15e3}=r,f,h,y,I=null,S=Promise.withResolvers(),d=()=>{y||=h(),y.then(S.resolve)};
|
|
923
|
+
if(l?.aborted)return X("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let b=cc(e,t,{cwd:n,env:o,input:s,
|
|
924
|
+
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});I=Number(b.pid);let v;h=()=>{if(!v){let A;process.platform!=="win32"?
|
|
925
|
+
A=zr(I).catch(()=>!1):(b.kill("SIGKILL"),A=b.completion.then(()=>!0)),v=A.then(T=>(T||(v=null),T))}return v},i?.id&&hc.set(
|
|
916
926
|
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
927
|
b.completion:{exitCode:1})]),E=typeof w.exitCode=="number"?w.exitCode:1;f=Ut({code:w.timedOut===!0?"vibe64_command_captu\
|
|
918
928
|
re_timed_out":w.code?"vibe64_command_capture_failed":"",error:E===0?"":w.shortMessage,exitCode:E,output:w.all||(E===0?"":
|
|
919
929
|
w.shortMessage),outputEncoding:u,signal:w.signal,stderr:w.stderr,stdout:w.stdout,timedOut:w.timedOut===!0,execution:i})}catch(b){
|
|
920
|
-
f=
|
|
921
|
-
if(!await(y||h?.()||!0)){let b=await
|
|
922
|
-
"The command finished",w=b.length?`: ${b.map(E=>`${E.command} (pid ${E.pid})`).join(", ")} still running`:"";return{...
|
|
930
|
+
f=X(b.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{l?.removeEventListener("abort",d)}
|
|
931
|
+
if(!await(y||h?.()||!0)){let b=await fc(I),v=f?.timedOut?"The command timed out":l?.aborted?"The command was cancelled":
|
|
932
|
+
"The command finished",w=b.length?`: ${b.map(E=>`${E.command} (pid ${E.pid})`).join(", ")} still running`:"";return{...X(
|
|
923
933
|
`${v}, and its execution scope did not become empty${w}.`,"vibe64_execution_drain_failed",{execution:i,output:f?.output,
|
|
924
934
|
outputEncoding:u,signal:f?.signal,stderr:f?.stderr,stdout:f?.stdout,timedOut:f?.timedOut}),remainingProcesses:b}}i?.id&&
|
|
925
|
-
|
|
926
|
-
execution:_,outputEncoding:u}):_?{...f,execution:_}:f}var
|
|
927
|
-
sharedCacheRoot:"",execHelperPath:"",sharedGroupAccess:!1})});function
|
|
928
|
-
r running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}function
|
|
929
|
-
...e,schema:
|
|
930
|
-
and",args:s=[]}={}){return
|
|
935
|
+
hc.delete(i.id);let _=i&&{...i,state:"finished"};return l?.aborted?X("Command cancelled.","vibe64_command_cancelled",{...f,
|
|
936
|
+
execution:_,outputEncoding:u}):_?{...f,execution:_}:f}var hc,Bt=g(()=>{Fe();uc();Vt();hc=new Map});function he(){return globalThis[sf]||af}var sf,af,Re=g(()=>{sf=Symbol.for("vibe64.hostProfile"),af=Object.freeze({runtimePackRoot:"",
|
|
937
|
+
sharedCacheRoot:"",execHelperPath:"",sharedGroupAccess:!1})});function No(e=""){let t=String(e||"").trim()||he().execHelperPath;if(!t){let r=new Error("This computer has no helper fo\
|
|
938
|
+
r running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}function gc(e={}){return{
|
|
939
|
+
...e,schema:cf,schemaVersion:uf}}function Fr({actor:e={},command:t="",cwd:r="",env:n={},input:o,operation:i="vibe64-comm\
|
|
940
|
+
and",args:s=[]}={}){return gc({args:Array.isArray(s)?s.map(a=>String(a)):[],command:t,cwd:r,env:n,gid:e.user?.gid,home:e.
|
|
931
941
|
user?.home,inputBase64:o==null?"":Buffer.isBuffer(o)?o.toString("base64"):Buffer.from(String(o)).toString("base64"),operation:i,
|
|
932
942
|
uid:e.user?.uid,username:e.user?.username})}function Ht(e={}){return e.mode==="pty"&&e.envPolicy==="auth"&&!["assistant",
|
|
933
943
|
"codex"].includes(e.purpose)?"account-auth-terminal":e.purpose==="codex"&&e.mode==="capture"&&e.envPolicy==="auth"||e.purpose===
|
|
@@ -936,87 +946,87 @@ uid:e.user?.uid,username:e.user?.username})}function Ht(e={}){return e.mode==="p
|
|
|
936
946
|
includes(e.execution?.operationId)||e.mode==="capture"&&e.execution?.kind==="assistant"&&e.execution?.operationId==="ope\
|
|
937
947
|
ncode-catalog"?"opencode-app-server":e.purpose==="account"?"account-status":e.purpose==="github"?"github-workflow-comman\
|
|
938
948
|
d":e.purpose==="github-api"?"github-api-command":e.purpose==="workspace-cache"?"workspace-cache-command":e.purpose==="he\
|
|
939
|
-
alth"?"health-status":"vibe64-command"}async function
|
|
949
|
+
alth"?"health-status":"vibe64-command"}async function Co(e={},{env:t,helperPath:r="",maxBuffer:n=void 0,outputEncoding:o="\
|
|
940
950
|
utf8",runCapture:i=Gt,signal:s=null,timeout:a=15e3}){let c={env:t,input:`${JSON.stringify(e)}
|
|
941
951
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
942
|
-
udo",["-n",
|
|
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
|
|
946
|
-
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var
|
|
947
|
-
function
|
|
948
|
-
let n=String(e||"").trim();if(!n||!
|
|
949
|
-
th.`,r);return n}function
|
|
952
|
+
udo",["-n",No(r),"execute"],c)}var cf,uf,qr=g(()=>{Bt();Re();cf="vibe64.exec-helper.payload",uf=1});import{createRequire as df}from"node:module";var lf,Rv,wc=g(()=>{lf=new URL("./../node_modules/@jskit-ai/kernel/server/s\
|
|
953
|
+
upport/symlinkSafeRequire.js",import.meta.url).href,Rv=df(lf)});var jv,Lv,Mv,Dv,yc=g(()=>{G();jv=Object.freeze(["bundled","dev_server"]),Lv=Object.freeze(["capacitor"]),Mv=Object.freeze(
|
|
954
|
+
{callbackPath:"/auth/login",customScheme:"",appLinkDomains:Object.freeze([])}),Dv=Object.freeze({packageName:"",minSdk:26,
|
|
955
|
+
targetSdk:35,versionCode:1,versionName:"1.0.0"})});var _c=g(()=>{G();yc()});var ko=g(()=>{});var xo=g(()=>{});var Ec=g(()=>{ko();G();xo()});var bc=g(()=>{});var nS,oS,vc=g(()=>{jt();G();bc();ko();nS=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),oS=Object.
|
|
956
|
+
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var $o=g(()=>{G()});import ff from"node:child_process";import{constants as jo}from"node:fs";import{open as hf}from"node:fs/promises";import Lo from"node:path";
|
|
957
|
+
function Mo(e="",t=Do){let r=new Error(e||"Exclusive file lock failed.");return r.code=t,r}function Sc(e="",t="path",r=Do){
|
|
958
|
+
let n=String(e||"").trim();if(!n||!Lo.isAbsolute(n)||Lo.normalize(n)!==n)throw Mo(`${t} must be a normalized absolute pa\
|
|
959
|
+
th.`,r);return n}function wf(e,t){return new Promise((r,n)=>{let o=ff.spawn("/usr/bin/flock",["--exclusive","--nonblock",
|
|
950
960
|
"3"],{cwd:t,env:{PATH:"/usr/bin:/bin"},stdio:["ignore","ignore","pipe",e]}),i="";o.stderr.on("data",s=>{i=`${i}${String(
|
|
951
|
-
s||"")}`.slice(-4096)}),o.once("error",n),o.once("close",s=>r({status:s,stderr:i.trim()}))})}async function
|
|
952
|
-
errorCode:r=
|
|
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
|
|
956
|
-
lock_failed",
|
|
957
|
-
session?.metadata?.session_git_command_actor_user_key)}async function
|
|
958
|
-
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await
|
|
959
|
-
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:
|
|
961
|
+
s||"")}`.slice(-4096)}),o.once("error",n),o.once("close",s=>r({status:s,stderr:i.trim()}))})}async function ft(e="",{cwd:t="",
|
|
962
|
+
errorCode:r=Do}={}){let n=Sc(e,"lockPath",r),o=t?Sc(t,"cwd",r):Lo.dirname(n),i=await hf(n,jo.O_CREAT|jo.O_NOFOLLOW|jo.O_RDWR,
|
|
963
|
+
432),s;try{s=await wf(i.fd,o)}catch(c){throw await i.close().catch(()=>null),Mo(c?.message||String(c||"Exclusive file lo\
|
|
964
|
+
ck failed."),r)}if(s.status!==0){if(await i.close(),s.status===gf)return null;throw Mo(`Exclusive file lock process fail\
|
|
965
|
+
ed${s.stderr?`: ${s.stderr}`:"."}`,r)}let a=!1;return async()=>{a||(a=!0,await i.close())}}var Do,gf,Ic=g(()=>{Do="file_\
|
|
966
|
+
lock_failed",gf=1});var yf,mS,Tc=g(()=>{yf="jskit-client-build",mS=new RegExp(`<meta name="${yf}" content="([0-9a-f]+)"`,"u")});import Ef from"node:path";var _S,Ac=g(()=>{Tc();$o();_S=Ef.join("dist","index.html")});var Wr=g(()=>{wc();_c();Ec();xo();vc();$o();Ic();Ac()});var Oc=g(()=>{Wr()});function bf(e={}){return Ie(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
967
|
+
session?.metadata?.session_git_command_actor_user_key)}async function Pc(e={}){let t=R(e.actor)||"daemon";if(t==="app"&&
|
|
968
|
+
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await Po(e.applicationAccount)};
|
|
969
|
+
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:Oo()};let r=bf(e);if(!r){let n=new Error(
|
|
960
970
|
"A user key is required for real-user command execution.");throw n.code="vibe64_command_actor_user_required",n}return{actor:t,
|
|
961
|
-
credentialScope:"user",requiresRealUser:!0,user:await
|
|
962
|
-
user?.gid}function
|
|
963
|
-
if(!e.requiresRealUser)return;let n=C(t.session?.sourceRoot||t.session?.sourcePath),o=C(r);if(!n||!o||!
|
|
971
|
+
credentialScope:"user",requiresRealUser:!0,user:await Po(r)}}var Rc=g(()=>{q();mt()});import Nc from"node:path";function ht(e={}){let t=nc();return t.uid===null||t.gid===null||t.uid===e.user?.uid&&t.gid===e.
|
|
972
|
+
user?.gid}function Uo(){return!!he().execHelperPath}function Yr(e={}){return e.requiresRealUser?Uo()||!ht(e):!1}function Cc(e={},t={},r=""){
|
|
973
|
+
if(!e.requiresRealUser)return;let n=C(t.session?.sourceRoot||t.session?.sourcePath),o=C(r);if(!n||!o||!Pe(n,o))return;let i=new Error(
|
|
964
974
|
"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
|
-
mand_managed_source_real_user_forbidden",i}function
|
|
966
|
-
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&
|
|
967
|
-
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var
|
|
975
|
+
mand_managed_source_real_user_forbidden",i}function kc(e={},t={}){let r=C(e.user?.home),n=C(t.HOME),o=C(t.VIBE64_CREDENTIAL_HOME);
|
|
976
|
+
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&Nc.resolve(r)!==Nc.resolve(n)){let i=new Error("Command HOME does not match t\
|
|
977
|
+
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var Jr=g(()=>{mt();Re();q()});function Kr(...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,Xr=g(()=>{
|
|
968
978
|
q();zt=Object.freeze(["DATABASE_URL","DB_CLIENT","DB_DATABASE","DB_HOST","DB_NAME","DB_PASSWORD","DB_PORT","DB_USER","DB\
|
|
969
979
|
_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
|
|
972
|
-
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function
|
|
973
|
-
o=
|
|
980
|
+
R","VIBE64_MYSQL_USER"])});import{spawn as vf,spawnSync as Sf}from"node:child_process";import{createHash as If}from"node:crypto";import{statSync as Uc}from"node:fs";
|
|
981
|
+
import{stat as Vc}from"node:fs/promises";import Qr from"node:path";function $c(e="",t="vibe64"){return R(e).toLowerCase().
|
|
982
|
+
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function Of(...e){for(let t of e){let r=J(t),n=J(r.user),
|
|
983
|
+
o=Ie(r.name,r.userName,r.user_name,r.gitUserName,r.git_user_name,n.name,n.userName,n.user_name),i=Ie(r.email,r.userEmail,
|
|
974
984
|
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
|
|
976
|
-
t.login,t.username),n=
|
|
977
|
-
committerName:r,source:"github"}}function
|
|
978
|
-
authorEmail:`${r}@${n}${
|
|
979
|
-
fallback"}}function
|
|
980
|
-
isDirectory()?t:""}catch{return""}}async function
|
|
981
|
-
t:""}function
|
|
982
|
-
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=
|
|
983
|
-
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:
|
|
984
|
-
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?
|
|
985
|
-
null}}function
|
|
985
|
+
committerEmail:i,committerName:o,source:"configured"}}return null}function Pf(e={}){let t=J(e),r=Ie(t.name,t.displayName,
|
|
986
|
+
t.login,t.username),n=Ie(t.email,t.publicEmail,t.verifiedEmail);return!r||!n?null:{authorEmail:n,authorName:r,committerEmail:n,
|
|
987
|
+
committerName:r,source:"github"}}function Rf({workspace:e="",userKey:t=""}={}){let r=$c(t,"user"),n=$c(e,"local");return{
|
|
988
|
+
authorEmail:`${r}@${n}${xc}`,authorName:`${r} via Vibe64`,committerEmail:`vibe64@${n}${xc}`,committerName:"Vibe64",source:"\
|
|
989
|
+
fallback"}}function Vo(e=""){let t=R(e);return t&&Qr.isAbsolute(t)?t:""}function jc(e=""){let t=Vo(e);try{return t&&Uc(t).
|
|
990
|
+
isDirectory()?t:""}catch{return""}}async function Lc(e=""){let t=Vo(e);return t&&await Vc(t).then(r=>r.isDirectory(),()=>!1)?
|
|
991
|
+
t:""}function Hc(e=""){let t={};for(let r of String(e||"").split(`
|
|
992
|
+
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=R(n[2]))}return t}function zc(e,t){return{
|
|
993
|
+
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:Tf}}function Mc(e,t){let r=Sf("git",Gc,{...zc(e,t),encoding:"\
|
|
994
|
+
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?Hc(r.stdout):
|
|
995
|
+
null}}function Dc(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=vf("git",Gc,zc(e,t));s.stdout.setEncoding(
|
|
986
996
|
"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
|
-
values:null}:{transient:!1,values:a===0||a===1?
|
|
988
|
-
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function
|
|
989
|
-
env.PATH||e.PATH}}function
|
|
990
|
-
e.HOME),r=
|
|
991
|
-
g"):""].filter(Boolean)}async function
|
|
992
|
-
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function
|
|
993
|
-
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}function
|
|
994
|
-
([o],[i])=>o<i?-1:o>i?1:0);return
|
|
995
|
-
await
|
|
996
|
-
function
|
|
997
|
-
values:o.values}}function
|
|
998
|
-
r&&We.delete(o);return null}async function
|
|
999
|
-
read).values;let a={expiresAt:i+
|
|
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([
|
|
1004
|
-
typeof t!="object"?null:
|
|
1005
|
-
null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function
|
|
1006
|
-
project:r={},session:n={}}){let o=
|
|
1007
|
-
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||
|
|
1008
|
-
let i=
|
|
1009
|
-
t.VIBE64_RUNTIME_NAMESPACE),userKey:
|
|
1010
|
-
LOGNAME)})}async function
|
|
1011
|
-
{})||
|
|
1012
|
-
return
|
|
1013
|
-
ME",Je="GIT_AUTHOR_EMAIL",Ke="GIT_COMMITTER_NAME",Xe="GIT_COMMITTER_EMAIL",
|
|
1014
|
-
"--get-regexp","^user\\.(name|email)$"],
|
|
997
|
+
values:null}:{transient:!1,values:a===0||a===1?Hc(n):null}))})}function Fc(e=null){return!e?.name||!e?.email?null:{authorEmail:e.
|
|
998
|
+
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function qc(e={}){return{...e,PATH:process.
|
|
999
|
+
env.PATH||e.PATH}}function Wc(e={}){if(Object.hasOwn(e,"GIT_CONFIG_GLOBAL"))return[String(e.GIT_CONFIG_GLOBAL)];let t=Vo(
|
|
1000
|
+
e.HOME),r=R(e.XDG_CONFIG_HOME)||(t?Qr.join(t,".config"):"");return[r?Qr.join(r,"git","config"):"",t?Qr.join(t,".gitconfi\
|
|
1001
|
+
g"):""].filter(Boolean)}async function Nf(e={}){return(await Promise.all(Wc(e).map(r=>Vc(r).then(n=>`${n.ino}:${n.size}:${n.
|
|
1002
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function Cf(e={}){return Wc(e).map(t=>{try{let r=Uc(t);return`${r.ino}\
|
|
1003
|
+
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}function Yc(e,t,r){let n=Object.entries(r).sort(
|
|
1004
|
+
([o],[i])=>o<i?-1:o>i?1:0);return If("sha256").update(JSON.stringify([e,t,n])).digest("hex")}async function kf(e,t,r){let n=e?
|
|
1005
|
+
await Dc(e,r):null;if(n?.values)return n;let o=await Dc(t,r);return{transient:!!(n?.transient||o.transient),values:o.values}}
|
|
1006
|
+
function xf(e,t,r){let n=e?Mc(e,r):null;if(n?.values)return n;let o=Mc(t,r);return{transient:!!(n?.transient||o.transient),
|
|
1007
|
+
values:o.values}}function Jc(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<=
|
|
1008
|
+
r&&We.delete(o);return null}async function $f(e,t,r){let n=Yc(e,t,r),o=await Nf(r),i=Date.now(),s=Jc(n,o,i);if(s)return(await s.
|
|
1009
|
+
read).values;let a={expiresAt:i+Bc,read:kf(e,t,r),revision:o};We.set(n,a);let c=await a.read;return c.transient?We.get(n)===
|
|
1010
|
+
a&&We.delete(n):a.values=c.values,c.values}function jf(e,t,r){let n=Yc(e,t,r),o=Cf(r),i=Date.now(),s=Jc(n,o,i);if(s&&Object.
|
|
1011
|
+
hasOwn(s,"values"))return s.values;let a=xf(e,t,r);return a.transient||We.set(n,{expiresAt:i+Bc,read:Promise.resolve(a),
|
|
1012
|
+
revision:o,values:a.values}),a.values}async function Lf({cwd:e="",env:t=null}={}){if(!t||typeof t!="object")return null;
|
|
1013
|
+
let[r,n]=await Promise.all([Lc(e),Lc(t.HOME)]);return Fc(await $f(r,n,qc(t)))}function Mf({cwd:e="",env:t=null}={}){return!t||
|
|
1014
|
+
typeof t!="object"?null:Fc(jf(jc(e),jc(t.HOME),qc(t)))}function Df(e={}){let t=J(e),r=R(t.name),n=R(t.email);return!r||!n?
|
|
1015
|
+
null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function Kc({env:e,personGitIdentity:t=null,
|
|
1016
|
+
project:r={},session:n={}}){let o=J(n.metadata);return Of(r.gitIdentity,r.config?.git,n.gitIdentity,o.git_identity,{name:e.
|
|
1017
|
+
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||Df(t)}function Xc({actor:e={},env:t,project:r={},session:n={},userKey:o=""}){
|
|
1018
|
+
let i=J(n.metadata);return Pf(r.githubUser||n.githubUser||i.github_user)||Rf({workspace:Ie(r.workspace,t.VIBE64_WORKSPACE,
|
|
1019
|
+
t.VIBE64_RUNTIME_NAMESPACE),userKey:Ie(o,e.user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.
|
|
1020
|
+
LOGNAME)})}async function Uf(e){return Kc(e)||await Lf(e.gitConfig||{})||Xc(e)}function Vf(e){return Kc(e)||Mf(e.gitConfig||
|
|
1021
|
+
{})||Xc(e)}function Qc(e){return{[Je]:e.authorEmail,[Ye]:e.authorName,[Xe]:e.committerEmail,[Ke]:e.committerName}}async function Zc(e){
|
|
1022
|
+
return Qc(await Uf(e))}function eu(e){return Qc(Vf(e))}var Ye,Je,Ke,Xe,xc,Tf,Gc,Bc,Af,We,gt=g(()=>{q();Ye="GIT_AUTHOR_NA\
|
|
1023
|
+
ME",Je="GIT_AUTHOR_EMAIL",Ke="GIT_COMMITTER_NAME",Xe="GIT_COMMITTER_EMAIL",xc=".users.vibe64.invalid",Tf=2e3,Gc=["config",
|
|
1024
|
+
"--get-regexp","^user\\.(name|email)$"],Bc=3e4,Af=['git config --global user.name "Your Name"','git config --global user\
|
|
1015
1025
|
.email "you@example.com"'].join(`
|
|
1016
|
-
`);We=new Map});import
|
|
1017
|
-
|
|
1018
|
-
let e=
|
|
1019
|
-
|
|
1026
|
+
`);We=new Map});import Go from"node:path";function Q({root:e=""}={}){return C(e||he().runtimePackRoot)}function Ho(e=""){let t=Q();return(t?
|
|
1027
|
+
wt[R(e)]?.binDirs||[]:[]).map(n=>Go.join(t,n))}function tu(){let e=Q();return e?[Go.join(e,"guard-bin")]:[]}function zo(){
|
|
1028
|
+
let e=Q();return e?[Go.join(e,"policy-bin")]:[]}function Gf(e=""){let t=R(e);return[...wt[t]?.managedCommands||[]]}var wt,
|
|
1029
|
+
Bo,uI,ge=g(()=>{q();Re();wt=Object.freeze({awsebcli:{binDirs:["awsebcli/bin"],managedCommands:["eb"]},bubblewrap:{binDirs:[
|
|
1020
1030
|
"bubblewrap/bin"],managedCommands:[]},bun:{binDirs:["bun/bin"],dependencyFiles:["package.json","bun.lock","bun.lockb","p\
|
|
1021
1031
|
ackage-lock.json"],managedCommands:["bun"]},composer:{binDirs:["composer/bin"],dependencyFiles:["composer.json","compose\
|
|
1022
1032
|
r.lock"],managedCommands:["composer"]},cpp:{binDirs:["cpp/bin"],dependencyFiles:["CMakeLists.txt","vcpkg.json","vcpkg-co\
|
|
@@ -1045,275 +1055,275 @@ tor-clis/lib/node_modules/opencode-ai/package.json"],managedCommands:["claude","
|
|
|
1045
1055
|
in"],managedCommands:["php"]},playwright:{binDirs:["playwright/bin"],identityPaths:["playwright/runtime.env","playwright\
|
|
1046
1056
|
/browsers"],managedCommands:["playwright"]},postgresql:{binDirs:["postgresql/bin"],managedCommands:["initdb","pg_ctl","p\
|
|
1047
1057
|
g_isready","postgres","psql"]},ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:[
|
|
1048
|
-
"sqlite3"]}}),
|
|
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=
|
|
1052
|
-
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!
|
|
1053
|
-
`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function
|
|
1054
|
-
r=C(he().sharedCacheRoot),n=
|
|
1055
|
-
{[
|
|
1056
|
-
ATH",
|
|
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);
|
|
1060
|
-
"deployment"?o:{...o,...
|
|
1058
|
+
"sqlite3"]}}),Bo=Object.freeze(["operator-clis","node26","git","gh","mysql","mariadb","postgresql","sqlite","ripgrep","b\
|
|
1059
|
+
ubblewrap","bun","php","composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);uI=
|
|
1060
|
+
Object.freeze({runtimePackManagedCommands:Gf})});import{readFileSync as Bf}from"node:fs";import ru from"node:path";function qf({runtimePackRoot:e=""}={}){let t=Q({root:e});
|
|
1061
|
+
if(!t)return"";let r=ru.join(t,nu,zf),n;try{n=Bf(r,"utf8")}catch(i){if(i?.code==="ENOENT")return"";throw i}let o=n.split(
|
|
1062
|
+
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!Ff.test(o[0]))throw new Error(
|
|
1063
|
+
`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function ou({runtimePackRoot:e=""}={}){let t=Q({root:e}),
|
|
1064
|
+
r=C(he().sharedCacheRoot),n=qf({runtimePackRoot:t});return{...r?{[Zr]:r}:{},...t?{[Ft]:ru.join(t,nu,Hf),[Fo]:"1"}:{},...n?
|
|
1065
|
+
{[qo]:n}:{}}}var Zr,Ft,Fo,qo,nu,Hf,zf,Ff,qt=g(()=>{q();Re();ge();Zr="VIBE64_SHARED_CACHE_ROOT",Ft="PLAYWRIGHT_BROWSERS_P\
|
|
1066
|
+
ATH",Fo="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",qo="VIBE64_PLAYWRIGHT_VERSION",nu="playwright",Hf="browsers",zf="runtime.env",
|
|
1067
|
+
Ff=/^\d+\.\d+\.\d+$/u});function yt(e={}){for(let t of Object.keys(ue(e)))if(Wf.has(t)||t.startsWith("XDG_")){let r=new Error(`Vibe64 command ca\
|
|
1068
|
+
llers cannot provide execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function en(e={},t={}){
|
|
1069
|
+
let{envPolicy:r="session"}=t,n=ue(e);yt(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!Yf.has(i)));return r===
|
|
1070
|
+
"deployment"?o:{...o,...Kr(n)}}var Wf,Yf,tn=g(()=>{q();Xr();gt();qt();Wf=new Set(["HOME","LOGNAME","PATH","TMPDIR","USER",
|
|
1061
1071
|
"VIBE64_EXECUTION_ID","VIBE64_MANAGED_EXECUTION_REQUIRED","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIM\
|
|
1062
|
-
E_DIR"]),
|
|
1072
|
+
E_DIR"]),Yf=new Set([...zt,Je,Ye,Xe,Ke,Ft,Fo,qo,Zr])});function Jf(e=""){let t=C(e);return t==="/home"||t.startsWith("/home/")}function iu({actor:e={},request:t={}}={}){let r=t.
|
|
1063
1073
|
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
1074
|
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&&
|
|
1066
|
-
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=
|
|
1075
|
+
_mismatch",a}if(!e.requiresRealUser&&Jf(n)&&o&&!Pe(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
1076
|
+
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=R(r.username||e.user?.username);
|
|
1067
1077
|
return{...Dt({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n}),...C(r.cacheRoot)?{XDG_CACHE_HOME:C(r.cacheRoot)}:{},...C(r.
|
|
1068
1078
|
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
|
|
1070
|
-
isAbsolute(o))continue;let i=
|
|
1079
|
+
r.stateRoot)}:{}}}var su=g(()=>{mt();q()});import au from"node:path";function Zf(e=[]){let t=new Set,r=[];for(let n of Array.isArray(e)?e:[e]){let o=R(n);if(!o||!au.
|
|
1080
|
+
isAbsolute(o))continue;let i=au.resolve(o);t.has(i)||(t.add(i),r.push(i))}return r}function Wt(e={},t=[]){let r={...e&&typeof e==
|
|
1071
1081
|
"object"&&!Array.isArray(e)?e:{}},n=Number.parseInt(String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?
|
|
1072
|
-
n:0;for(let i of Array.isArray(t)?t:[]){let s=
|
|
1073
|
-
i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),r}function
|
|
1074
|
-
function
|
|
1075
|
-
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function
|
|
1076
|
-
return Wt(e,
|
|
1077
|
-
var
|
|
1078
|
-
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),
|
|
1079
|
-
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),
|
|
1082
|
+
n:0;for(let i of Array.isArray(t)?t:[]){let s=R(i?.key);s&&(r[`GIT_CONFIG_KEY_${o}`]=s,r[`GIT_CONFIG_VALUE_${o}`]=String(
|
|
1083
|
+
i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),r}function cu(e=[]){return Zf(e).map(t=>({key:"safe.directory",value:t}))}
|
|
1084
|
+
function uu(e={},t=[]){return Wt(e,cu(t))}function eh(e=[]){return cu(e).flatMap(t=>["-c",`${t.key}=${t.value}`])}function Wo(){
|
|
1085
|
+
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function Yo(e={}){return Wt(e,Kf)}function th(e={}){
|
|
1086
|
+
return Wt(e,Xf)}function rh(e={}){return Wt(e,Qf)}function lu(e={}){return th(Yo(e))}function du(e={}){return rh(Yo(e))}
|
|
1087
|
+
var Kf,Xf,Qf,OI,pu=g(()=>{q();Kf=Object.freeze([{key:"url.https://github.com/.insteadOf",value:"git@github.com:"},{key:"\
|
|
1088
|
+
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),Xf=Object.freeze([{key:"credential.https://github.co\
|
|
1089
|
+
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),Qf=Object.freeze([{key:"credential.https://github.com.helper",
|
|
1080
1090
|
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
|
|
1083
|
-
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=
|
|
1084
|
-
github-https"||e.purpose==="github")&&(r=
|
|
1085
|
-
BE64_GIT_AUTH_TOKEN"});import
|
|
1086
|
-
function
|
|
1087
|
-
()=>{q();ge();
|
|
1088
|
-
function Yt(e=""){return String(e||"").split(":").map(
|
|
1089
|
-
t)}catch{return!1}})}function
|
|
1090
|
-
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function
|
|
1091
|
+
OI=Object.freeze({applyGitConfigEntriesToEnv:Wt,githubSshToHttpsGitEnv:Yo,gitSafeDirectoryArgs:eh})});function oh(e={}){if(!e.gitAuthToken){let t=new Error("Token-backed GitHub transport requires a gitAuthToken.");throw t.
|
|
1092
|
+
code="vibe64_command_git_auth_token_required",t}return du({...Wo(),GIT_TERMINAL_PROMPT:"0",[nh]:e.gitAuthToken})}function mu({
|
|
1093
|
+
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=oh(e):(e.gitTransport==="\
|
|
1094
|
+
github-https"||e.purpose==="github")&&(r=lu({...t,...Wo()})),uu(r,e.gitSafeDirectories||[])}var nh,fu=g(()=>{pu();nh="VI\
|
|
1095
|
+
BE64_GIT_AUTH_TOKEN"});import hu from"node:path";function gu({env:e={}}={}){return Q()?C(e[Jo])||(C(e.HOME)?hu.join(C(e.HOME),".local"):""):""}
|
|
1096
|
+
function wu(e={}){let t=gu(e);return t?{[Jo]:t}:{}}function yu(e={}){let t=gu(e);return t?[hu.join(t,"bin")]:[]}var Jo,Ko=g(
|
|
1097
|
+
()=>{q();ge();Jo="NPM_CONFIG_PREFIX"});import{existsSync as ih,readdirSync as sh}from"node:fs";import ah from"node:os";import Ne from"node:path";import rn from"node:process";
|
|
1098
|
+
function Yt(e=""){return String(e||"").split(":").map(R).filter(Boolean)}function Eu(e=[]){return e.filter(t=>{try{return ih(
|
|
1099
|
+
t)}catch{return!1}})}function _u(e="",t=/^$/u){try{return sh(e).filter(r=>t.test(r)).sort((r,n)=>Number(/\d+/u.exec(n)?.[0]||
|
|
1100
|
+
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function ch(e){if(Q())return[];let t=String(e.HOME||ah.homedir()||"");
|
|
1091
1101
|
if(!Ne.isAbsolute(t))return[];let r=Ne.isAbsolute(String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:Ne.join(t,".local/share"),
|
|
1092
|
-
n=Ne.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:Ne.join(r,"mise");return
|
|
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[...Yt(
|
|
1095
|
-
[...
|
|
1096
|
-
t=>[...
|
|
1097
|
-
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return ze([...Yt(o.join(":")),...
|
|
1098
|
-
i=>
|
|
1099
|
-
Jt="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"});import
|
|
1100
|
-
e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!
|
|
1101
|
-
!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function
|
|
1102
|
-
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function
|
|
1103
|
-
envPolicy==="deployment"?(
|
|
1104
|
-
oyment"?[]:t.envPolicy==="project"?
|
|
1105
|
-
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=
|
|
1106
|
-
t.XDG_RUNTIME_DIR||"").trim(),c={...Dt(e.user,
|
|
1107
|
-
...
|
|
1108
|
-
l=
|
|
1109
|
-
shimDirs||[]});return{...u,PATH:l,...
|
|
1102
|
+
n=Ne.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:Ne.join(r,"mise");return Eu([Ne.join(t,".local/bin"),Ne.join(
|
|
1103
|
+
n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",".bun/bin"].map(o=>Ne.join(t,o))])}function uh(){if(Q())return[];
|
|
1104
|
+
let e=["/opt/homebrew","/usr/local"];return[...Yt(rn.env.PATH),...rn.platform==="darwin"?["/opt/homebrew/bin"]:[],...Eu(
|
|
1105
|
+
[..._u("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`/usr/lib/postgresql/${t}/bin`),...rn.platform==="darwin"?e.flatMap(
|
|
1106
|
+
t=>[..._u(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function bu({
|
|
1107
|
+
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return ze([...Yt(o.join(":")),...zo(),...n.flatMap(
|
|
1108
|
+
i=>Ho(i)),...tu(),...Yt(t||(r?"":e.PATH)),...ch(rn.env),...Yt(r),...uh(),...Yt(Jt)]).join(":")}var Jt,nn=g(()=>{q();ge();
|
|
1109
|
+
Jt="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"});import lh from"node:path";function mh(e={}){return Object.fromEntries(Object.entries(e&&typeof e=="object"&&!Array.isArray(
|
|
1110
|
+
e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!dh.has(t)&&!ph.has(t)&&!t.startsWith("GIT_")&&
|
|
1111
|
+
!t.startsWith("GH_")&&!t.startsWith("XDG_")))}function Xo(e={}){return e.envPolicy==="deployment"?[e.project?.deploymentEnv,
|
|
1112
|
+
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function fh(e={}){return Xo(e).reduce((t,r)=>e.
|
|
1113
|
+
envPolicy==="deployment"?(yt(r),{...t,...ue(r)}):{...t,...en(r,e)},{})}function hh(e={},t={}){return t.envPolicy==="depl\
|
|
1114
|
+
oyment"?[]:t.envPolicy==="project"?Xo(t):[e,...Xo(t),t.project?.databaseEnv,t.session?.databaseEnv]}function vu({actor:e={},
|
|
1115
|
+
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=ou(),s=en(n.env,n),a=String(
|
|
1116
|
+
t.XDG_RUNTIME_DIR||"").trim(),c={...Dt(e.user,mh(t)),...ht(e)&&lh.isAbsolute(a)?{XDG_RUNTIME_DIR:a}:{},...Kr(...hh(t,n)),
|
|
1117
|
+
...fh(n),...mu({actor:e,request:n}),...s,...iu({actor:e,request:n}),...i},u={...c,...wu({env:c}),VIBE64_DECLARED_RUNTIMES:o},
|
|
1118
|
+
l=bu({env:u,existingPath:[...yu({env:u}),u.PATH].filter(Boolean).join(":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.
|
|
1119
|
+
shimDirs||[]});return{...u,PATH:l,...Q()?{}:{VIBE64_TOOL_PATH:l}}}function Su({actor:e={},baseEnv:t,request:r={}},n){return{
|
|
1110
1120
|
actor:e,env:t,gitConfig:{cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.
|
|
1111
|
-
userKey}}async function
|
|
1112
|
-
resolvedGitIdentityEnv||
|
|
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>
|
|
1118
|
-
"running"||e.status==="closing"}function
|
|
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=
|
|
1121
|
+
userKey}}async function Iu(e){let t=vu(e);return{...t,...await Zc(Su(e,t))}}function Qo(e){let t=vu(e);return{...t,...e.
|
|
1122
|
+
resolvedGitIdentityEnv||eu(Su(e,t))}}var dh,ph,Zo=g(()=>{Jr();mt();Xr();tn();Xr();su();fu();gt();gt();qt();Ko();nn();ge();
|
|
1123
|
+
q();dh=new Set([...zt,Je,Ye,Xe,Ke,"HOME","LOGNAME","PATH","USER","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG\
|
|
1124
|
+
_RUNTIME_DIR"]),ph=new Set(["NODE_ENV"])});import{Buffer as gh}from"node:buffer";function Au(){return{code:"terminal_session_not_found",error:"Terminal session not\
|
|
1125
|
+
found.",ok:!1}}function Ce(e=""){return String(e||"default").trim()||"default"}function an(e){let t=String(e||""),r=t.length;
|
|
1126
|
+
for(let n=0;n<wh&&(r=t.lastIndexOf(`
|
|
1127
|
+
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>Tu&&(t=t.slice(t.length-Tu)),t}function Kt(e={}){return e.status===
|
|
1128
|
+
"running"||e.status==="closing"}function ei(e={}){return Kt(e)||e.status==="exited"}function Pu(e,t){try{return t(ke(e))===
|
|
1129
|
+
!0}catch{return!1}}function _h(e=0){let t=Math.floor(Number(e||0));return Number.isFinite(t)&&t>0?t:0}function Eh(e="",t={}){
|
|
1130
|
+
let{outputLimit:r=0}=t,n=String(e||""),o=_h(r);return!o||n.length<=o?{output:n,outputTruncated:!1}:{output:n.slice(n.length-
|
|
1131
|
+
o),outputTruncated:!0}}function ke(e,t={}){let r=Eh(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||on,
|
|
1122
1132
|
createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exitCode,inputVersion:e.inputVersion||0,lastInputAt:e.
|
|
1123
1133
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
1124
1134
|
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),
|
|
1128
|
-
e);return r>0?Math.max(0,Number(t)-r):0}function
|
|
1129
|
-
e.detachedCleanupTimer=null)}var
|
|
1130
|
-
60*1e3,
|
|
1131
|
-
metadata:e.metadata,type:"metadata"}),ke(e))}function
|
|
1135
|
+
sn,status:e.status}}function Ru(e=""){return gh.byteLength(String(e||""),"utf8")}function Xt(e=0){let t=Math.floor(Number(
|
|
1136
|
+
e));return!Number.isFinite(t)||t<0?0:Math.min(t,yh)}function bh(e={}){return Math.max(pt(e.lastSubscriberDetachedAt),pt(
|
|
1137
|
+
e.lastInputAt),pt(e.lastOutputAt),pt(e.createdAt))}function ti(e={},t=Date.now()){if(e.subscribers?.size)return 0;let r=bh(
|
|
1138
|
+
e);return r>0?Math.max(0,Number(t)-r):0}function cn(e={}){e.detachedCleanupTimer&&(clearTimeout(e.detachedCleanupTimer),
|
|
1139
|
+
e.detachedCleanupTimer=null)}var Tu,wh,on,sn,sT,yh,aT,Ou,_t=g(()=>{q();Tu=256*1024,wh=300,on=100,sn=28,sT=600*1e3,yh=1440*
|
|
1140
|
+
60*1e3,aT=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "});Ou=new Map});function Nu(e,t={}){return!e||!t||typeof t!="object"||Array.isArray(t)?ke(e):(e.metadata={...e.metadata||{},...t},we(e,{
|
|
1141
|
+
metadata:e.metadata,type:"metadata"}),ke(e))}function Cu(e,t=""){let r=Ru(t);r<1||(e.outputVersion=Number(e.outputVersion||
|
|
1132
1142
|
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
|
|
1143
|
+
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function vh(e){let t=String(e?.code||""),r=String(e?.message||
|
|
1144
|
+
e||"Terminal PTY error.");return{code:t,message:r}}function ku(e,t){if(!e)return;let r=vh(t);e.lastWriteErrorAt=new Date().
|
|
1135
1145
|
toISOString(),e.lastWriteErrorCode=r.code,e.lastWriteError=r.message,console.warn("Vibe64 terminal PTY write error.",{code:r.
|
|
1136
1146
|
code,id:e.id,metadata:e.metadata||{},message:r.message,namespace:e.namespace||""}),we(e,{code:r.code,error:r.message,type:"\
|
|
1137
|
-
error"})}function
|
|
1147
|
+
error"})}function xu(e){let t=e?.terminal?._writeStream;!t||typeof t.on!="function"||t.on("error",r=>{ku(e,r)})}function $u(e,t,r=t){
|
|
1138
1148
|
let n=`\r
|
|
1139
1149
|
[studio] ${r}\r
|
|
1140
|
-
`;e.closeError=t,e.output=
|
|
1150
|
+
`;e.closeError=t,e.output=an(`${e.output}${n}`),we(e,{chunk:n,type:"output"}),we(e,{error:t,type:"error"})}async function ju(e,{
|
|
1141
1151
|
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
|
-
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t
|
|
1152
|
+
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,$u(e,a,`${o}: ${a}`),c}}function Qe(e,t){let r=`${String(
|
|
1143
1153
|
t?.code||"terminal_cleanup_failed")}:${String(t?.message||"")}`;return e.reportedLifecycleFailures||=new Set,e.reportedLifecycleFailures.
|
|
1144
|
-
has(r)||(e.reportedLifecycleFailures.add(r)
|
|
1154
|
+
has(r)||(e.reportedLifecycleFailures.add(r),$u(e,String(t?.message||t||"Terminal cleanup failed."))),t}function un(e,t=[]){
|
|
1145
1155
|
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
|
|
1147
|
-
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>
|
|
1156
|
+
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function Sh(e,t){
|
|
1157
|
+
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>ju(e,{code:"terminal_stop_hook_failed",flag:"\
|
|
1148
1158
|
stopHookStarted",hook:"onStop",label:"Terminal stop failed",payload:{id:e.id,output:e.output,reason:t,status:e.status}}))),
|
|
1149
|
-
e.stopHookCompletion}function
|
|
1159
|
+
e.stopHookCompletion}function ri(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>ju(
|
|
1150
1160
|
e,{code:"terminal_close_hook_failed",flag:"closeHookStarted",hook:"onClose",label:"Terminal finalization failed",payload:{
|
|
1151
|
-
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function
|
|
1152
|
-
"exited"&&(e.status="exited",we(e,{closeError:e.closeError||"",exitCode:e.exitCode,status:e.status,type:"status"}))}function
|
|
1153
|
-
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await
|
|
1161
|
+
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function ni(e){e.status!==
|
|
1162
|
+
"exited"&&(e.status="exited",we(e,{closeError:e.closeError||"",exitCode:e.exitCode,status:e.status,type:"status"}))}function oi(e){
|
|
1163
|
+
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await zr(e.terminal.pid)){
|
|
1154
1164
|
let t=new Error(`Terminal execution scope did not become empty: ${e.id}`);throw t.code="terminal_execution_drain_failed",
|
|
1155
|
-
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function
|
|
1156
|
-
Qe(e,t)}try{await Promise.all([
|
|
1165
|
+
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function Lu(e){try{await e.scopeDrainCompletion}catch(t){
|
|
1166
|
+
Qe(e,t)}try{await Promise.all([ri(e,e.stopReason||"exit"),e.stopHookCompletion])}catch(t){Qe(e,t)}ni(e)}async function ii(e,t="\
|
|
1157
1167
|
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(
|
|
1168
|
+
ing",we(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(Sh(e,e.stopReason),!e.processExited&&!e.killStarted){
|
|
1159
1169
|
e.killStarted=!0;try{e.terminal.kill()}catch(n){e.killStarted=!1;let o=n instanceof Error?n:new Error(String(n||"Termina\
|
|
1160
|
-
l process could not be killed."));o.code||="terminal_kill_failed",r.push(Qe(e,o))}}try{await
|
|
1161
|
-
n))}return{failures:r}}var
|
|
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=
|
|
1166
|
-
()=>{
|
|
1167
|
-
let n=Math.max(0,r-
|
|
1168
|
-
let{namespace:r="default"}=t,n=
|
|
1169
|
-
let s=[];if(
|
|
1170
|
+
l process could not be killed."));o.code||="terminal_kill_failed",r.push(Qe(e,o))}}try{await oi(e)}catch(n){r.push(Qe(e,
|
|
1171
|
+
n))}return{failures:r}}var si=g(()=>{Vt();_t()});function Th(e="default"){return Ih.get(Ce(e))||null}function Mu(e="default"){let t=Th(e);return t?{code:t.code,error:t.error,
|
|
1172
|
+
ok:!1}:null}var Ih,Du=g(()=>{_t();Ih=new Map});function Et(e){return Ze.get(Ce(e))||Ou}function Uu(e){let t=Ce(e);return Ze.has(t)||Ze.set(t,new Map),Ze.get(t)}function Vu(e,t,r){
|
|
1173
|
+
e.delete(r);let n=Ce(t);e.size<1&&Ze.get(n)===e&&Ze.delete(n)}function Ah(e=""){let t=String(e||"");return[...Ze.keys()].
|
|
1174
|
+
filter(r=>r.startsWith(t))}function ln({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){let n=e?[Ce(e)]:Ah(t),
|
|
1175
|
+
o=[];for(let i of n){let s=Et(i);for(let a of s.values())r&&!Kt(a)||o.push({namespace:i,session:a})}return o}var Ze,ai=g(
|
|
1176
|
+
()=>{_t();Ze=new Map});function dn(e={},t="default"){if(cn(e),!ei(e)||e.subscribers?.size)return;let r=Xt(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
1177
|
+
let n=Math.max(0,r-ti(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,Oh({namespace:t})},n)}async function ci(e,t={}){
|
|
1178
|
+
let{namespace:r="default"}=t,n=Et(r),o=n.get(e);if(!o)return{ok:!0,closed:!1};if(o.closePromise)return o.closePromise;let i=(async()=>{
|
|
1179
|
+
let s=[];if(cn(o),!o.processExited){let u=await ii(o,"close");if(u.failures.length)throw un(o,u.failures)}try{await o.exitCompletion}catch(u){
|
|
1170
1180
|
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&&
|
|
1181
|
+
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&ni(o),s.length>0)throw un(o,[...s,...c]);return Vu(n,r,e),{
|
|
1172
1182
|
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(!
|
|
1175
|
-
r.id,{namespace:t})}}}var
|
|
1176
|
-
filter:e,namespacePrefix:t}){return
|
|
1183
|
+
o.closePromise===i&&(o.closePromise=null)}}async function Oh({namespace:e}){for(let{namespace:t,session:r}of ln({namespace:e})){
|
|
1184
|
+
if(!ei(r)||r.subscribers?.size)continue;let n=Xt(r.detachedIdleTimeoutMs);if(!(n<1)){if(ti(r)<n){dn(r,t);continue}await ci(
|
|
1185
|
+
r.id,{namespace:t})}}}var ui=g(()=>{q();si();ai();_t()});import Rh from"node:crypto";import{createRequire as Nh}from"node:module";function li(){}function Ch(){return!0}function xh({
|
|
1186
|
+
filter:e,namespacePrefix:t}){return ln({namespacePrefix:t,runningOnly:!0}).filter(r=>Pu(r.session,e)).length}function Gu({
|
|
1177
1187
|
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(
|
|
1180
|
-
if(_)return ke(_);let b=Number(i||0),v=c||a;if(b>0&&
|
|
1188
|
+
runningLimitFilter:u=Ch,onClose:l=li,onOutput:m=li,onStop:f=li,reuseRunning:h=!1,detachedIdleTimeoutMs:y=0}){let I=Mu(a);
|
|
1189
|
+
if(I)return I;let S=Et(a),d=Rh.randomUUID(),p=typeof h=="function"?h:()=>!!h,_=h?[...S.values()].find(F=>Kt(F)&&p(F)):null;
|
|
1190
|
+
if(_)return ke(_);let b=Number(i||0),v=c||a;if(b>0&&xh({filter:u,namespacePrefix:v})>=b)return{ok:!1,code:"terminal_limi\
|
|
1181
1191
|
t",error:`Terminal limit reached (${b}).`};let w=typeof o=="function"?o({id:d,namespace:a}):o,E=typeof e=="function"?e({
|
|
1182
|
-
env:w,id:d,namespace:a}):e,A=typeof r=="function"?r({args:E,env:w,id:d,namespace:a}):r,
|
|
1183
|
-
env:w,id:d,namespace:a}):s,O=
|
|
1184
|
-
F=>{U=F}),k={id:d,closeHookCompletion:null,closePromise:null,commandPreview:A,cols:
|
|
1192
|
+
env:w,id:d,namespace:a}):e,A=typeof r=="function"?r({args:E,env:w,id:d,namespace:a}):r,T=typeof s=="function"?s({args:E,
|
|
1193
|
+
env:w,id:d,namespace:a}):s,O=kh("node-pty").spawn(t,E,{cols:on,cwd:n,env:J(w),name:"xterm-color",rows:sn}),U,x=new Promise(
|
|
1194
|
+
F=>{U=F}),k={id:d,closeHookCompletion:null,closePromise:null,commandPreview:A,cols:on,createdAt:new Date().toISOString(),
|
|
1185
1195
|
cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:Xt(y),exitCompletion:x,exitCode:null,lastSubscriberAttachedAt:"",lastSubscriberDetachedAt:new Date().
|
|
1186
|
-
toISOString(),metadata:
|
|
1196
|
+
toISOString(),metadata:T&&typeof T=="object"&&!Array.isArray(T)?T:{},onClose:l,onStop:f,inputVersion:0,lastInputAt:"",lastInputBytes:0,
|
|
1187
1197
|
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
|
|
1198
|
+
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:U,rows:sn,status:"running",stopHookCompletion:null,
|
|
1199
|
+
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:O};return xu(k),O.onData(F=>{Cu(k,F),k.output=an(k.output+
|
|
1190
1200
|
F),we(k,{chunk:F,lastOutputAt:k.lastOutputAt,outputVersion:k.outputVersion,type:"output"});try{m({chunk:F,output:k.output,
|
|
1191
|
-
session:ke(k),updateMetadata(
|
|
1192
|
-
we(k,{error:pe,type:"error"})}
|
|
1193
|
-
k),we(k,{exitCode:F,status:k.status,type:"status"}),
|
|
1194
|
-
d,k),
|
|
1195
|
-
ke(i,{outputLimit:n}):
|
|
1196
|
-
execution/src/server/engines/terminalSessions.js",import.meta.url).href;Nh
|
|
1197
|
-
function
|
|
1198
|
-
r real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=
|
|
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:Ht(e)});return
|
|
1203
|
-
`,{mode:384}),["-n",
|
|
1204
|
-
command:e.command,cwd:n,env:a}}async function
|
|
1205
|
-
{},{onClose:a=
|
|
1201
|
+
session:ke(k),updateMetadata(ee){return Nu(k,ee)}})}catch(ee){let pe=String(ee?.message||ee||"Terminal output hook faile\
|
|
1202
|
+
d.");we(k,{error:pe,type:"error"})}dn(k,a)}),O.onExit(({exitCode:F})=>{k.processExited=!0,k.exitCode=F,k.status="closing",
|
|
1203
|
+
oi(k),we(k,{exitCode:F,status:k.status,type:"status"}),ri(k,k.stopReason||"exit"),k.resolveExitCompletion(),Lu(k)}),Uu(a).
|
|
1204
|
+
set(d,k),dn(k,a),$h(d,{namespace:a})}function $h(e,t={}){let{namespace:r="default",outputLimit:n=0}=t,i=Et(r).get(e);return i?
|
|
1205
|
+
ke(i,{outputLimit:n}):Au()}var Ph,kh,Bu=g(()=>{q();_t();si();Du();ui();ai();Ph=new URL("./../node_modules/@local/vibe64-\
|
|
1206
|
+
execution/src/server/engines/terminalSessions.js",import.meta.url).href;kh=Nh(Ph)});import{randomUUID as jh}from"node:crypto";import{mkdirSync as Lh,writeFileSync as Mh}from"node:fs";import di from"node:path";
|
|
1207
|
+
function Dh(){}function Uh(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root is required fo\
|
|
1208
|
+
r real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=di.join(di.resolve(t),
|
|
1209
|
+
"exec-helper-payloads");return Lh(r,{mode:448,recursive:!0}),di.join(r,`${process.pid}-${Date.now()}-${jh()}.json`)}function Vh(e,t){
|
|
1210
|
+
let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return Yr(r)?{args:(c={})=>{let u=Uh(s.helperPayloadRoot),
|
|
1211
|
+
l=typeof e.args=="function"?e.args(c):e.args,m=Fr({actor:r,args:l,command:e.command,cwd:n,env:typeof a=="function"?a(c):
|
|
1212
|
+
a,input:e.input,operation:Ht(e)});return Mh(u,`${JSON.stringify(m)}
|
|
1213
|
+
`,{mode:384}),["-n",No(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||Jt}}:{args:e.args,
|
|
1214
|
+
command:e.command,cwd:n,env:a}}async function zu(e={},t={}){let{actor:r,cwd:n,env:o,resolveEnv:i}=t;try{let s=e.terminal||
|
|
1215
|
+
{},{onClose:a=Dh}=s,c=e.execution?.id||"",u=Vh(e,{actor:r,cwd:n,env:o,resolveEnv:i}),l=Gu({args:u.args,command:u.command,
|
|
1206
1216
|
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
1207
1217
|
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async m=>{try{await a(m)}finally{
|
|
1208
|
-
c&&
|
|
1209
|
-
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&
|
|
1210
|
-
execution:e.execution}:l}catch(s){return
|
|
1211
|
-
{execution:e.execution})}}var
|
|
1212
|
-
resolveLinks:n=!0}=t,o=
|
|
1213
|
-
c,o));if(s.length>0){if(!n)return o;let c=
|
|
1214
|
-
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var
|
|
1215
|
-
id Vibe64 command request.");return r.code=t,r}function xe(e="",t=[],r="",n="value"){let o=
|
|
1216
|
-
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function
|
|
1218
|
+
c&&Hu.set(c,{id:m.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
1219
|
+
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&Hu.set(c,{id:l.id,namespace:s.namespace}),l?.ok===!0?{...l,
|
|
1220
|
+
execution:e.execution}:l}catch(s){return X(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
1221
|
+
{execution:e.execution})}}var Hu,pi=g(()=>{Fe();nn();Bu();ui();qr();Jr();Hu=new Map});import{realpathSync as Fu}from"node:fs";function Gh(e=""){return C(e||process.cwd())}function qu(e="",t={}){let{allowedRoots:r=[],
|
|
1222
|
+
resolveLinks:n=!0}=t,o=Gh(e),i=(Array.isArray(r)?r:[r]).map(C).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>Pe(
|
|
1223
|
+
c,o));if(s.length>0){if(!n)return o;let c=Fu(o);if(s.some(u=>Pe(Fu(u),c)))return c}let a=new Error("Vibe64 command cwd i\
|
|
1224
|
+
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var Wu=g(()=>{q()});import{randomUUID as Bh}from"node:crypto";function oe(e="",t="vibe64_command_request_invalid"){let r=new Error(e||"Inval\
|
|
1225
|
+
id Vibe64 command request.");return r.code=t,r}function xe(e="",t=[],r="",n="value"){let o=R(e)||r;if(!t.includes(o))throw oe(
|
|
1226
|
+
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function eg(e=[],t={}){let{
|
|
1217
1227
|
mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw oe("Function-valued command args are only supported for \
|
|
1218
1228
|
PTY commands.","vibe64_command_args_function_requires_pty");return e}return(Array.isArray(e)?e:[e]).map(n=>String(n??""))}
|
|
1219
|
-
function
|
|
1229
|
+
function tg(e={},t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw oe("Function-valued command e\
|
|
1220
1230
|
nv is only supported for PTY commands.","vibe64_command_env_function_requires_pty");return{env:{},envFactory:e}}let n=ue(
|
|
1221
|
-
e);return
|
|
1222
|
-
let t=
|
|
1223
|
-
maxRunning:t.maxRunning,metadata:t.metadata,namespace:
|
|
1224
|
-
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function
|
|
1225
|
-
let t=
|
|
1226
|
-
gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?Number(t.gid??t.hostGid):null,home:r,scope:
|
|
1227
|
-
uid:Number.isSafeInteger(Number(t.uid??t.hostUid))?Number(t.uid??t.hostUid):null,username:
|
|
1228
|
-
t.userKey)}:{}}function
|
|
1229
|
-
capture",purpose:t="terminal"}={}){return t==="preview"?"preview":e==="pty"?"terminal":"job"}function
|
|
1231
|
+
e);return yt(n),{env:n,envFactory:null}}function mi(e=[]){return(Array.isArray(e)?e:[e]).map(C).filter(Boolean)}function rg(e={}){
|
|
1232
|
+
let t=J(e);return{commandPreview:t.commandPreview,detachedIdleTimeoutMs:t.detachedIdleTimeoutMs,helperPayloadRoot:C(t.helperPayloadRoot),
|
|
1233
|
+
maxRunning:t.maxRunning,metadata:t.metadata,namespace:R(t.namespace),namespaceLimitPrefix:R(t.namespaceLimitPrefix),onClose:t.
|
|
1234
|
+
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function ng(e={}){
|
|
1235
|
+
let t=J(e),r=C(t.home||t.toolHomeSource);return r?{cacheRoot:C(t.cacheRoot),configRoot:C(t.configRoot),dataRoot:C(t.dataRoot),
|
|
1236
|
+
gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?Number(t.gid??t.hostGid):null,home:r,scope:R(t.scope),stateRoot:C(t.stateRoot),
|
|
1237
|
+
uid:Number.isSafeInteger(Number(t.uid??t.hostUid))?Number(t.uid??t.hostUid):null,username:R(t.username||t.ownerUserKey||
|
|
1238
|
+
t.userKey)}:{}}function og(e="capture"){return e==="detached"?"service":e==="pty"?"interactive":"finite"}function ig({mode:e="\
|
|
1239
|
+
capture",purpose:t="terminal"}={}){return t==="preview"?"preview":e==="pty"?"terminal":"job"}function bt(e=""){let t=R(e);
|
|
1230
1240
|
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
|
-
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function
|
|
1232
|
-
purpose:o="terminal",session:i={}}=t,s=
|
|
1233
|
-
|
|
1234
|
-
throw oe(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_execution_lifecycle_incompatible");let u=
|
|
1241
|
+
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function Ju(e={},t={}){let{mode:r="capture",project:n={},
|
|
1242
|
+
purpose:o="terminal",session:i={}}=t,s=J(e),a=xe(s.kind,Kh,ig({mode:r,purpose:o}),"execution_kind"),c=xe(s.lifecycle,Xh,
|
|
1243
|
+
og(r),"execution_lifecycle");if(r==="detached"&&c!=="service"||r==="pty"&&c!=="interactive"||r==="capture"&&c!=="finite")
|
|
1244
|
+
throw oe(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_execution_lifecycle_incompatible");let u=bt(
|
|
1235
1245
|
s.ownerId||i.sessionId);if(c==="service"&&!u)throw oe("Service execution requires a durable owner id.","vibe64_execution\
|
|
1236
1246
|
_owner_required");let l=s.resourceProfile;if(l!=null&&(!l||typeof l!="object"||Object.keys(l).some(m=>!["key","compatibi\
|
|
1237
1247
|
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
1248
|
"")||!["development","test","production"].includes(l.environment)))throw oe("Invalid activity resource profile identity.",
|
|
1239
|
-
"vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.freeze({...l})}:{},controlGenerationId:
|
|
1240
|
-
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:
|
|
1241
|
-
id:
|
|
1242
|
-
projectSlug:
|
|
1249
|
+
"vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.freeze({...l})}:{},controlGenerationId:bt(
|
|
1250
|
+
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:sg(s.workflowId)},
|
|
1251
|
+
id:Bh(),kind:a,label:R(s.label),lifecycle:c,operationId:bt(s.operationId),ownerId:u,parentExecutionId:bt(s.parentExecutionId),
|
|
1252
|
+
projectSlug:bt(s.projectSlug||n.slug||n.projectSlug),sessionId:bt(s.sessionId||i.sessionId)})}function sg(e){if(typeof e!=
|
|
1243
1253
|
"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)?
|
|
1246
|
-
imes"),n=
|
|
1247
|
-
|
|
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,
|
|
1251
|
-
Vibe64 runtime: ${h}.`,"vibe64_command_runtime_unsupported");let c=
|
|
1254
|
+
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function ag(e=""){return Zh.has(
|
|
1255
|
+
e)?Bo:[]}function Yu(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function cg(e={},t=""){let r=Yu(e,"runt\
|
|
1256
|
+
imes"),n=Yu(e,"runtime");if(!r&&!n)return ze(ag(t));let o=r?e.runtimes:e.runtime;return ze((Array.isArray(o)?o:[o]).map(
|
|
1257
|
+
R).filter(Boolean))}function Ku(e={}){let t=J(e),r=R(t.command);if(!r)throw oe("A command is required.","vibe64_command_\
|
|
1258
|
+
required");let n=xe(t.mode,qh,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))throw oe(
|
|
1259
|
+
"Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=ue(t.baseEnv),i=tg(t.env,
|
|
1260
|
+
{mode:n}),s=xe(t.purpose,Fh,"terminal","purpose"),a=cg(t,s);for(let h of a)if(!Object.hasOwn(wt,h))throw oe(`Unsupported\
|
|
1261
|
+
Vibe64 runtime: ${h}.`,"vibe64_command_runtime_unsupported");let c=J(t.project),u=J(t.session),l=t.releaseEnvironmentFile??
|
|
1252
1262
|
"";if(typeof l!="string"||l&&(!l.startsWith("/")||/[\r\n\0]/u.test(l)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="de\
|
|
1253
1263
|
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw oe("Release environment files require a\
|
|
1254
1264
|
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let m=t.usageRecordingPreload??
|
|
1255
1265
|
"";if(typeof m!="string"||m&&(!m.startsWith("/")||/[\s"'\\\0]/u.test(m)||!["preview","output"].includes(s)||t.actor==="a\
|
|
1256
1266
|
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&&(!
|
|
1267
|
+
ding_preload_invalid");let f=t.applicationAccount??"";if(typeof f!="string"||f&&(!zh.test(f)||t.actor!=="app"||n!=="capt\
|
|
1258
1268
|
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:
|
|
1262
|
-
t.credentialHome),gitAuthToken:
|
|
1263
|
-
t.personGitIdentity?.email),name:
|
|
1269
|
+
return{actor:xe(t.actor,Hh,"daemon","actor"),applicationAccount:f,allowedRoots:mi(t.allowedRoots),args:eg(t.args,{mode:n}),
|
|
1270
|
+
baseEnv:o,command:r,cwd:C(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,envPolicy:xe(t.envPolicy,Yh,"session",
|
|
1271
|
+
"env_policy"),releaseEnvironmentFile:l,execution:Ju(t.execution,{mode:n,project:c,purpose:s,session:u}),credentialHome:ng(
|
|
1272
|
+
t.credentialHome),gitAuthToken:R(t.gitAuthToken),gitSafeDirectories:mi(t.gitSafeDirectories),personGitIdentity:{email:R(
|
|
1273
|
+
t.personGitIdentity?.email),name:R(t.personGitIdentity?.name)},gitTransport:xe(t.gitTransport,Jh,"none","git_transport"),
|
|
1264
1274
|
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:
|
|
1268
|
-
0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:
|
|
1269
|
-
q();
|
|
1275
|
+
t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):Qh,mode:n,onOutput:typeof t.onOutput=="function"?t.onOutput:null,
|
|
1276
|
+
outputEncoding:xe(t.outputEncoding,Wh,"utf8","output_encoding"),project:c,purpose:s,runtimes:a,session:u,signal:t.signal??
|
|
1277
|
+
null,shimDirs:mi(t.shimDirs),terminal:rg(t.terminal),timeout:Number.isSafeInteger(Number(t.timeout))&&Number(t.timeout)>
|
|
1278
|
+
0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:R(t.userKey)}}var Hh,zh,Fh,qh,Wh,Yh,Jh,Kh,Xh,Qh,Zh,sA,Xu=g(()=>{
|
|
1279
|
+
q();tn();ge();Hh=Object.freeze(["daemon","owner-user","named-user","app"]),zh=/^[a-z_][a-z0-9_-]{0,31}$/u,Fh=Object.freeze(
|
|
1270
1280
|
["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
|
-
()=>{Bt();Vt();
|
|
1277
|
-
function
|
|
1281
|
+
"workspace-cache","source"]),qh=Object.freeze(["capture","pty","detached"]),Wh=Object.freeze(["utf8","base64"]),Yh=Object.
|
|
1282
|
+
freeze(["session","project","preview","auth","deployment"]),Jh=Object.freeze(["none","github-https","github-token"]),Kh=
|
|
1283
|
+
Object.freeze(["assistant","browser","control","job","preview","service","terminal"]),Xh=Object.freeze(["finite","intera\
|
|
1284
|
+
ctive","service"]),Qh=1e3*1e3*100,Zh=new Set(["assistant","codex","deployment","output","preview","source","terminal"]);
|
|
1285
|
+
sA=Object.freeze({normalizeExecutionDescriptor:Ju})});function fi(){return ug}function pn(e){return["1","true"].includes(String(e[Qu]||"").trim().toLowerCase())}var ug,Qu,mn=g(
|
|
1286
|
+
()=>{Bt();Vt();pi();Fe();ug=null,Qu="VIBE64_MANAGED_EXECUTION_REQUIRED"});import{realpathSync as Zu,statSync as dg}from"node:fs";import $e from"node:path";import{fileURLToPath as pg}from"node:url";
|
|
1287
|
+
function mg(e){let t=[$e.resolve($e.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=$e.dirname(e);t.
|
|
1278
1288
|
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[
|
|
1280
|
-
|
|
1281
|
-
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var
|
|
1282
|
-
"./../node_modules/@local/vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href});function
|
|
1283
|
-
e_environment_unavailable",{execution:e.execution}):e.applicationAccount?
|
|
1284
|
-
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function
|
|
1285
|
-
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=
|
|
1286
|
-
u=s;o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?
|
|
1287
|
-
e.mode==="detached"?r.requiresRealUser&&(!
|
|
1288
|
-
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):
|
|
1289
|
-
{...await
|
|
1289
|
+
r=>{try{return[Zu(r)]}catch{return[]}})}function el(e="",t=pg(lg)){try{if($e.resolve(e)===e&&Zu(e)===e&&dg(e).isFile()&&
|
|
1290
|
+
mg(t).some(r=>e.startsWith(`${r}${$e.sep}`)))return`--import=${e}`}catch{}throw Object.assign(new Error("The usage recor\
|
|
1291
|
+
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var lg,tl=g(()=>{lg=new URL(
|
|
1292
|
+
"./../node_modules/@local/vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href});function rl(e){return e.releaseEnvironmentFile?X("Release environment execution requires a managed host.","vibe64_releas\
|
|
1293
|
+
e_environment_unavailable",{execution:e.execution}):e.applicationAccount?X("Application account execution requires a man\
|
|
1294
|
+
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function fg(e,t={}){let{actor:r,
|
|
1295
|
+
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=rl(e);if(a)return a;if(e.usageRecordingPreload){let c=el(e.usageRecordingPreload),
|
|
1296
|
+
u=s;o={...o,NODE_OPTIONS:c},s=l=>({...u(l),NODE_OPTIONS:c})}return e.mode==="pty"?zu(e,{actor:r,cwd:n,env:o,resolveEnv:s}):
|
|
1297
|
+
e.mode==="detached"?r.requiresRealUser&&(!ht(r)||i)?X("Detached real-user command execution is unsupported when the help\
|
|
1298
|
+
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):mc(e,{actor:r,cwd:n,env:o}):i?
|
|
1299
|
+
{...await Co(Fr({actor:r,args:e.args,command:e.command,cwd:n,env:o,input:e.input,operation:Ht(e)}),{env:process.env,maxBuffer:e.
|
|
1290
1300
|
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:Gt(e.command,e.args,
|
|
1291
1301
|
{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 Qt(e={}){let t=null;try{if(t=
|
|
1293
|
-
d cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await
|
|
1294
|
-
...t.baseEnv}:{...t.baseEnv},o=(d={})=>({...d,VIBE64_EXECUTION_ID:t.execution.id}),i=
|
|
1295
|
-
r),u=!(!!i||s||
|
|
1302
|
+
signal:e.signal,timeout:e.timeout})}async function Qt(e={}){let t=null;try{if(t=Ku(e),t.signal?.aborted)return X("Comman\
|
|
1303
|
+
d cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await Pc(t),n=t.inheritProcessEnv?{...process.env,
|
|
1304
|
+
...t.baseEnv}:{...t.baseEnv},o=(d={})=>({...d,VIBE64_EXECUTION_ID:t.execution.id}),i=fi(),s=pn(n)||pn(process.env),a=Yr(
|
|
1305
|
+
r),u=!(!!i||s||Uo())&&ht(r)?[n.PATH,process.env.PATH].filter(Boolean).join(":"):"",l=o(await Iu({actor:r,baseEnv:n,localPath:u,
|
|
1296
1306
|
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Je,Ye,Xe,Ke].map(d=>[d,l[d]]));
|
|
1297
|
-
|
|
1298
|
-
args=="function"?t.args(d):t.args,y=(d={})=>o(t.envFactory?
|
|
1299
|
-
...t,env:t.envFactory(d),envFactory:null}}):l),
|
|
1300
|
-
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:f,env:l,resolveArgs:h,resolveEnv:y,runLocal:
|
|
1301
|
-
(s?
|
|
1302
|
-
ilable",{execution:t.execution,retryable:!1}):
|
|
1303
|
-
64_command_failed",{execution:t?.execution})}}var
|
|
1304
|
-
|
|
1305
|
-
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,
|
|
1306
|
-
6e4,
|
|
1307
|
-
e||"").trim();return
|
|
1308
|
-
function
|
|
1309
|
-
r)&&
|
|
1310
|
-
"darwin"&&
|
|
1311
|
-
"brew"&&!o&&["git","cpp"].includes(
|
|
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?
|
|
1314
|
-
|
|
1307
|
+
kc(r,l);let f=qu(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});Cc(r,t,f);let h=(d={})=>typeof t.
|
|
1308
|
+
args=="function"?t.args(d):t.args,y=(d={})=>o(t.envFactory?Qo({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:m,request:{
|
|
1309
|
+
...t,env:t.envFactory(d),envFactory:null}}):l),I=(d=t,p={})=>fg(d,{actor:r,cwd:f,env:l,requiresHelper:a,resolveEnv:y,...p});
|
|
1310
|
+
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:f,env:l,resolveArgs:h,resolveEnv:y,runLocal:I});let S=rl(t);return S||
|
|
1311
|
+
(s?X("Managed execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unava\
|
|
1312
|
+
ilable",{execution:t.execution,retryable:!1}):I())}catch(r){return X(r?.message||"Vibe64 command failed.",r?.code||"vibe\
|
|
1313
|
+
64_command_failed",{execution:t?.execution})}}var fn=g(()=>{Rc();Zo();gt();Bt();qr();Vt();pi();Wu();Jr();Xu();Fe();mn();
|
|
1314
|
+
tl()});import{fileURLToPath as gg}from"node:url";var hg,MA,DA,UA,VA,nl=g(()=>{Re();hg=new URL("./../node_modules/@local/vibe64-\
|
|
1315
|
+
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,MA=gg(new URL("./gitTurnCheckpointCommand.js",hg)),DA=15*
|
|
1316
|
+
6e4,UA=512*1024*1024,VA=1024*1024*1024});var HA,ol=g(()=>{q();HA=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"])});var il=g(()=>{});import{existsSync as wg}from"node:fs";import hn from"node:path";import sl from"node:process";function hi(e=""){let t=String(
|
|
1317
|
+
e||"").trim();return _g[t]||t}function cl({platform:e=sl.platform,aptGet:t=!1}={}){return e==="darwin"?"brew":t?"apt":""}
|
|
1318
|
+
function Eg(e,t=Jt){return[...String(e.PATH||"").split(hn.delimiter),...String(t||"").split(hn.delimiter)].some(r=>hn.isAbsolute(
|
|
1319
|
+
r)&&wg(hn.join(r,"apt-get")))}function wn({env:e,platform:t=sl.platform,systemPath:r}){return cl({platform:t,aptGet:t!==
|
|
1320
|
+
"darwin"&&Eg(e,r)})}function yn(e="",t={}){let{family:r="",mise:n=!1,xcode:o=!0}=t,i=gn[hi(e)];if(!i)return null;if(r===
|
|
1321
|
+
"brew"&&!o&&["git","cpp"].includes(hi(e)))return{command:"xcode-select --install",sudo:!1,note:""};let s=i.any||i[r]||"";
|
|
1322
|
+
if(!s&&i.mise&&(s=n?`mise use -g ${i.mise}`:`${yg} && ~/.local/bin/mise use -g ${i.mise}`),!s)return null;let a=s.startsWith(
|
|
1323
|
+
"sudo ")||r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?al:""}}var al,yg,KA,gn,_g,XA,Zt=g(()=>{nn();
|
|
1324
|
+
al="You'll be asked for your computer password. Nothing shows while you type.",yg="curl -fsSL https://mise.run | sh",KA=
|
|
1315
1325
|
Object.freeze({linux:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-linux.md",darwin:"\
|
|
1316
|
-
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),
|
|
1326
|
+
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),gn=Object.freeze({claude:{
|
|
1317
1327
|
name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://claude.ai/i\
|
|
1318
1328
|
nstall.sh | bash"},codex:{name:"Codex",run:[["codex"]],guideUrl:"https://github.com/openai/codex",any:"curl -fsSL https:\
|
|
1319
1329
|
//chatgpt.com/codex/install.sh | sh"},opencode:{name:"opencode",run:[["opencode"]],guideUrl:"https://opencode.ai/docs/",
|
|
@@ -1337,17 +1347,17 @@ rl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -fsSL https
|
|
|
1337
1347
|
ild tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/install_ruby\
|
|
1338
1348
|
_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"sudo apt i\
|
|
1339
1349
|
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
|
|
1350
|
+
brew install pkg-config libyaml openssl@3 gmp"}}),_g=Object.freeze({composer:"php"});XA=Object.freeze({SUDO_NOTE:al,localToolFamily:cl})});function ul({env:e,platform:t,systemPath:r}){return yn("git",{family:wn({env:e,platform:t,systemPath:r})})?.command||""}
|
|
1351
|
+
function bg(e={}){return[e.error,e.stderr,e.output].filter(Boolean).join(`
|
|
1352
|
+
`)}function vg(e,t){let r=bg(e);if(/spawn(?:Sync)? git ENOENT|(?:^|\s)git: (?:command )?not found/mu.test(r)){let n=ul(t);
|
|
1343
1353
|
return{code:"vibe64_git_missing",installCommand:n,message:n?`Git isn't installed on this computer. Install it with: ${n}`:
|
|
1344
1354
|
"Git isn't installed on this computer. Install Git, then try again."}}return/unknown option [`']initial-branch/u.test(r)?
|
|
1345
|
-
{code:"vibe64_git_too_old",installCommand:
|
|
1355
|
+
{code:"vibe64_git_too_old",installCommand:ul(t),message:"This Git is too old for Vibe64. Update Git to version 2.28 or n\
|
|
1346
1356
|
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
1357
|
test(r)?{code:"vibe64_git_signing_failed",installCommand:"",message:"Your Git is set to sign every commit, and signing d\
|
|
1348
1358
|
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
|
|
1350
|
-
backups.git",
|
|
1359
|
+
s and is unlocked, then try again."}:null}var eO,ll=g(()=>{Zt();eO=Object.freeze({describeGitFailure:vg})});var gi=g(()=>{});import dl from"node:path";function Tg(e=""){return e?dl.join(dl.dirname(e),pl):""}var pl,ml,Ig,iO,sO,fl=g(()=>{gi();pl="\
|
|
1360
|
+
backups.git",ml="vibe64-atomic",Ig=`backup_canonical_ref() {
|
|
1351
1361
|
vibe64_backup_repository="$1"
|
|
1352
1362
|
vibe64_source_repository="$2"
|
|
1353
1363
|
vibe64_source_ref="$3"
|
|
@@ -1365,13 +1375,13 @@ r "$vibe64_backup_repository" rev-parse --verify "$vibe64_backup_ref"
|
|
|
1365
1375
|
' "$vibe64_source_ref" >&2
|
|
1366
1376
|
return 1
|
|
1367
1377
|
fi
|
|
1368
|
-
}`,
|
|
1378
|
+
}`,iO=`#!/bin/sh
|
|
1369
1379
|
set -eu
|
|
1370
1380
|
|
|
1371
1381
|
zero_object=0000000000000000000000000000000000000000
|
|
1372
1382
|
git_dir="$(git rev-parse --absolute-git-dir)"
|
|
1373
1383
|
repository_root="$(dirname "$git_dir")"
|
|
1374
|
-
backup_repository="$repository_root/${
|
|
1384
|
+
backup_repository="$repository_root/${pl}"
|
|
1375
1385
|
if [ -L "$repository_root" ] || [ -L "$backup_repository" ] || [ -L "$repository_root/mutation.lock" ]; then
|
|
1376
1386
|
printf '[vibe64] Canonical repository storage must not use symlinked role paths.
|
|
1377
1387
|
' >&2
|
|
@@ -1380,7 +1390,7 @@ fi
|
|
|
1380
1390
|
exec 8>"$repository_root/mutation.lock"
|
|
1381
1391
|
flock -x 8
|
|
1382
1392
|
|
|
1383
|
-
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${
|
|
1393
|
+
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${ml}" ]; then
|
|
1384
1394
|
printf '[vibe64] Canonical repository pushes must use the Vibe64 atomic mutation path.
|
|
1385
1395
|
' >&2
|
|
1386
1396
|
exit 1
|
|
@@ -1391,7 +1401,7 @@ if [ "$(git --git-dir "$backup_repository" rev-parse --is-bare-repository 2>/dev
|
|
|
1391
1401
|
exit 1
|
|
1392
1402
|
fi
|
|
1393
1403
|
|
|
1394
|
-
${
|
|
1404
|
+
${Ig}
|
|
1395
1405
|
|
|
1396
1406
|
updates_file="$(mktemp "$repository_root/.pre-receive.XXXXXX")"
|
|
1397
1407
|
cleanup_updates_file() {
|
|
@@ -1439,55 +1449,61 @@ while read -r old_object _new_object ref_name; do
|
|
|
1439
1449
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
1440
1450
|
fi
|
|
1441
1451
|
done <"$updates_file"
|
|
1442
|
-
`;
|
|
1443
|
-
wserWorkerSource.js",import.meta.url).href});var
|
|
1452
|
+
`;sO=Object.freeze({CANONICAL_REPOSITORY_PUSH_OPTION:ml,canonicalRepositoryBackupPath:Tg})});var hl=g(()=>{qt();ge()});var wi=g(()=>{});var gl=g(()=>{});var wl=g(()=>{});var yi=g(()=>{});var wO,yl=g(()=>{gl();wl();yi();wO=new URL("./../node_modules/@local/vibe64-execution/src/server/runtime/agentPreviewBro\
|
|
1453
|
+
wserWorkerSource.js",import.meta.url).href});var Og,_l=g(()=>{Og=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms\
|
|
1444
1454
|
>]"," vibe64-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [\
|
|
1445
|
-
--json]"," vibe64-helper preview
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
" vibe64-helper preview browser
|
|
1450
|
-
vibe64-helper preview identities
|
|
1451
|
-
|
|
1452
|
-
-identity <default|guest|configured-name>] test [playwright test
|
|
1453
|
-
|
|
1454
|
-
status/ensure/restart/stop --json: ready, stoppedIntent, stale,
|
|
1455
|
-
}, currentPage {url, route, title, observedAt}, terminal {id, status,
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1455
|
+
--json]"," vibe64-helper preview open <path> [--json]"," vibe64-helper preview inspect-url"," vibe64-helper preview s\
|
|
1456
|
+
creenshot [--output <path>]"," vibe64-helper preview browser ensure"," vibe64-helper preview browser eval < playwright\
|
|
1457
|
+
-code.js"," vibe64-helper preview browser identity <default|guest|configured-name>"," vibe64-helper preview browser st\
|
|
1458
|
+
orage-state <default|guest|configured-name> --output <new-path>"," vibe64-helper preview browser screenshot [--output <\
|
|
1459
|
+
path>]"," vibe64-helper preview browser status"," vibe64-helper preview browser reset"," vibe64-helper preview browse\
|
|
1460
|
+
r close"," vibe64-helper preview identities"," vibe64-helper preview identities save < identities.json"," vibe64-help\
|
|
1461
|
+
er preview logs [--lines <count>] [--json]"," vibe64-helper preview restart [--wait] [--json] [--timeout-ms <ms>]"," v\
|
|
1462
|
+
ibe64-helper playwright [--target <target-id>] [--identity <default|guest|configured-name>] test [playwright test argume\
|
|
1463
|
+
nts]"," vibe64-helper playwright [--target <target-id>] [--identity <default|guest|configured-name>] npm-run <package-s\
|
|
1464
|
+
cript> [-- script arguments]","","JSON output:"," status/ensure/restart/stop --json: ready, stoppedIntent, stale, outpu\
|
|
1465
|
+
tTargetId, endpoints.browser {url, hostname, port}, currentPage {url, route, title, observedAt}, terminal {id, status, r\
|
|
1466
|
+
unning, exitCode, command, createdAt}, defaultIdentity, identities [{name, type}], identityTypes, diagnostics {latest, l\
|
|
1467
|
+
og, directApplicationEndpoint}."," open --json: path, moved (how many of the person's open Previews moved to it), error\
|
|
1468
|
+
s (why one that answered did not move)."," screenshot: outputPath, byteLength, sha256, capturedAt, url, title, width, h\
|
|
1469
|
+
eight, luminance, darkPixelPercentage, domTextLength, domTextSummary."," browser eval: result (the code's JSON-safe ret\
|
|
1470
|
+
urn value), logs [{level, values}] from console, url (the page afterwards)."," identities: the project's Managed app id\
|
|
1471
|
+
entities [{name, type, value}] (first is the default) and the Stack's declared Preview identity types.",' identities sa\
|
|
1472
|
+
ve: replaces the whole ordered list with the JSON array on stdin (or {"identities": [...]}); each type must be declared.\
|
|
1473
|
+
Save only names and accounts the person asked for or confirmed; never create app accounts or change roles for this. The\
|
|
1474
|
+
n verify each with preview browser identity <name>.'," browser storage-state: writes the identity's Playwright storage \
|
|
1475
|
+
state to a new file at --output; the interactive browser keeps its identity.","","When the person asks to see a page, ru\
|
|
1476
|
+
n preview open with its path inside the app (/orders/42?tab=notes): it moves every Preview pane they have open for this \
|
|
1477
|
+
session to that page, as their Preview address box would, and they see a note that the AI opened it. Only paths starting\
|
|
1478
|
+
with a single / are accepted, never other sites. If it reports moved: 0, give them the path to type into the Preview ad\
|
|
1479
|
+
dress box instead. Your own browser commands never move their pane.","Screenshot commands emit JSON metadata for a uniqu\
|
|
1480
|
+
ely named, immutable PNG.","For browser navigation, use preview inspect-url or the status Browser URL; these use the man\
|
|
1481
|
+
aged Preview proxy.","Inside browser eval, navigate with await page.goto(new URL('/your-path', preview.url).href).","The\
|
|
1482
|
+
direct application endpoint in diagnostics bypasses Preview identity; do not use it for interactive browsing.","The bro\
|
|
1483
|
+
wser keeps its page between browser commands. After each command the page keeps running for 30 seconds, then pauses (no \
|
|
1484
|
+
timers, animations or network handling) until the next browser command. For a longer wait, wait inside the command, for \
|
|
1485
|
+
example with await page.waitForSelector(...).","Five minutes after the last browser command ends, the browser closes; th\
|
|
1486
|
+
e next command opens a fresh page, so select its identity again if needed.","Managed Playwright suites and live preview \
|
|
1487
|
+
browser actions are sequential. Wait on the suite through cleanup and restoration before browser actions or Preview ensu\
|
|
1488
|
+
re/restart/target changes; confirm playwright status has no active run and preview status is ready. Read-only status and\
|
|
1489
|
+
logs are safe during a suite.","For background commands, wait on the existing execution/session with about a 30-second \
|
|
1490
|
+
window where supported: set yield_time_ms: 30000 for an empty command poll. Reserve shorter waits for interactive input \
|
|
1491
|
+
or a specific immediate check; do not repeatedly reread empty or unchanged logs between brief waits.","This is the canon\
|
|
1492
|
+
ical preview server for the configured primary application.","Do not start a duplicate copy of that application on anoth\
|
|
1493
|
+
er port.","A distinct secondary application explicitly requested by the user, such as a reference app, may run separatel\
|
|
1494
|
+
y without replacing this preview."].join(`
|
|
1479
1495
|
`)+`
|
|
1480
|
-
`});var
|
|
1481
|
-
-execution/src/server/conversationExecution.js",import.meta.url).href,
|
|
1496
|
+
`});var El=g(()=>{});import{fileURLToPath as kg}from"node:url";var Cg,PO,bl=g(()=>{fn();mn();Re();Cg=new URL("./../node_modules/@local/vibe64\
|
|
1497
|
+
-execution/src/server/conversationExecution.js",import.meta.url).href,PO=kg(new URL("./engines/stdioBridge.js",Cg))});var $O,vl=g(()=>{fn();Zt();ge();$O=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$nam\
|
|
1482
1498
|
e" 2>/dev/null) || continue'," case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /us\
|
|
1483
1499
|
r/bin/*) continue ;; esac; fi',` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1484
|
-
`)});var
|
|
1485
|
-
any:n}=
|
|
1486
|
-
ge();
|
|
1500
|
+
`)});var xg,Sl=g(()=>{Zt();ge();xg=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,
|
|
1501
|
+
any:n}=gn[e];return[e,Object.freeze({name:t,guideUrl:r,install:n})]})))});import{execFile as $g}from"node:child_process";import{promisify as jg}from"node:util";var GO,Il=g(()=>{GO=jg($g)});var Tl=g(()=>{Gr();rc();mt();qr();Oc();fn();Bt();Fe();mn();nl();Zo();ol();il();tn();Ko();gt();ll();gi();fl();q();qt();Re();
|
|
1502
|
+
ge();hl();wi();yl();yi();_l();El();bl();Zt();vl();Sl();Il();wi()});import{realpath as Al}from"node:fs/promises";async function er(e){let t=await Al(e),r=async(c,u="utf8",l={})=>{let{input:m,
|
|
1487
1503
|
maxBuffer:f=1024*1024}=l,h=await Qt({actor:"daemon",allowedRoots:[t],args:["-C",t,...c],command:"git",cwd:t,envPolicy:"p\
|
|
1488
1504
|
roject",gitSafeDirectories:[t],input:m,maxBuffer:f,mode:"capture",outputEncoding:u,purpose:"source",runtimes:["git"],timeout:6e4});
|
|
1489
1505
|
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
|
-
ase64"?Buffer.from(h.stdout,"base64"):h.stdout.trim()};if(await
|
|
1506
|
+
ase64"?Buffer.from(h.stdout,"base64"):h.stdout.trim()};if(await Al(await r(["rev-parse","--show-toplevel"]))!==t)throw new Error(
|
|
1491
1507
|
"Choose the topic repository root.");let n=await r(["rev-parse","HEAD"]);if(await r(["status","--porcelain","--untracked\
|
|
1492
1508
|
-files=all"]))throw new Error("Commit the topic content before generating a pinned course manifest.");let o=await He(t),
|
|
1493
1509
|
i=JSON.parse(await r(["show",`${n}:package.json`])),s=String(i.repository?.url||"").match(/^https:\/\/github\.com\/([a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+)\.git$/u)?.[1];
|
|
@@ -1495,20 +1511,20 @@ if(!s)throw new Error("Topic package needs its canonical https://github.com/<own
|
|
|
1495
1511
|
let a=Be([o.topicManifest,...o.bundles.map(c=>c.manifest)]);for(let c=0;c<a.length;){let u=c,l=0;do l+=a[u].bytes+Buffer.
|
|
1496
1512
|
byteLength(a[u].path)+128,u+=1;while(u<a.length&&l+a[u].bytes+Buffer.byteLength(a[u].path)+128<=1024*1024);let m=a.slice(
|
|
1497
1513
|
c,u),f=await r(["cat-file","--batch","-Z"],"base64",{input:m.map(y=>`${n}:${y.path}\0`).join(""),maxBuffer:2*1024*1024}),
|
|
1498
|
-
h=0;for(let y of m){let
|
|
1499
|
-
h,
|
|
1514
|
+
h=0;for(let y of m){let I=f.indexOf(0,h),S=I<0?null:/^(?:[a-f0-9]{40}|[a-f0-9]{64}) blob (0|[1-9][0-9]*)$/u.exec(f.subarray(
|
|
1515
|
+
h,I).toString("ascii")),d=S?Number(S[1]):-1,p=I+1+d;if(d!==y.bytes||f[p]!==0||K(f.subarray(I+1,p))!==y.sha256)throw new Error(
|
|
1500
1516
|
`Topic input differs from its pinned commit: ${y.path}.`);h=p+1}if(h!==f.length)throw new Error("Unexpected trailing dat\
|
|
1501
1517
|
a while reading the pinned topic.");c=u}if(await r(["rev-parse","HEAD"])!==n||await r(["status","--porcelain","--untrack\
|
|
1502
1518
|
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 tr(e,t){let r=ce(
|
|
1519
|
+
release:o.release,repository:s,commit:n,topicManifest:o.topicManifest,topicHash:o.topicHash}}function tr(e,t){let r=ce(jr,
|
|
1504
1520
|
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
1521
|
"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
1522
|
throw new Error(`Duplicate course topic: ${i.topicId}.`);n.add(i.topicId);let s=t.filter(l=>l.topicId===i.topicId&&l.release===
|
|
1507
1523
|
i.release);if(s.length!==1)throw new Error(`Resolve exactly one pinned topic release: ${i.topicId}@${i.release}.`);let a=s[0];
|
|
1508
1524
|
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
1525
|
`Topic requires a repository and immutable commit: ${i.topicId}.`);let c=a.topicManifest;if(!c||c.schemaVersion!==1||c.topic?.
|
|
1510
|
-
topicId!==i.topicId||c.release!==i.release||
|
|
1511
|
-
topicId}.`);if(ce(
|
|
1526
|
+
topicId!==i.topicId||c.release!==i.release||K(L(c))!==a.topicHash)throw new Error(`Topic manifest identity mismatch: ${i.
|
|
1527
|
+
topicId}.`);if(ce($r,c.topic,i.topicId),r.status==="released"&&c.topic.status!=="released")throw new Error(`Released cou\
|
|
1512
1528
|
rse requires a released topic: ${i.topicId}.`);let u=c.topic.lessons;if(!Array.isArray(u)||!u.length||!Array.isArray(c.lessons)||
|
|
1513
1529
|
u.length!==c.lessons.length)throw new Error(`Incomplete whole-topic inventory: ${i.topicId}.`);for(let[l,m]of u.entries()){
|
|
1514
1530
|
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,142 +1533,142 @@ throw new Error(`Changed whole-topic order or lesson identity: ${i.topicId}.`);i
|
|
|
1517
1533
|
repository:a.repository,commit:a.commit,manifestHash:a.topicHash,lessons:c.lessons.map(l=>({...l}))}});if(r.orientation!==
|
|
1518
1534
|
void 0&&!o.some(i=>i.lessons.some(s=>s.code===r.orientation&&s.status==="published")))throw new Error(`Course orientatio\
|
|
1519
1535
|
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
|
|
1521
|
-
return
|
|
1522
|
-
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var
|
|
1536
|
+
status:r.status,topics:o}}var _n=g(()=>{Tl();dt();ut();lt()});function vt(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 En(e,t,r=409,n={}){
|
|
1537
|
+
return vt(e,t,{...n,statusCode:r})}function ye(e,t,r,n){return vt(e,t,{statusCode:r,cause:n})}function _i(e,t,r){return Object.
|
|
1538
|
+
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var LR,bn=g(()=>{Tr();LR=128*1024});var Ol=g(()=>{});import{lstat as Lg,readFile as Mg,readdir as Dg,realpath as Ug}from"node:fs/promises";import D from"node:path";function Ei(e){
|
|
1523
1539
|
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)||!
|
|
1540
|
+
e}function et(e,t={}){let r=ce(Gg,e,"Installed topic pin");if(!je.test(r.topicId)||!bi.test(r.commit)||r.topicId!==(t.topicId??
|
|
1541
|
+
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!Vg.test(r.repository)||!nr.test(r.topicHash))
|
|
1526
1542
|
throw new Error("Installed pin does not match the requested topic, commit or canonical source identity.");if(r.topicHash!==
|
|
1527
1543
|
(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
|
|
1544
|
+
let r=await Lg(e);if(r.isSymbolicLink()||await Ug(e)!==e)throw new Error("Installed content cannot use symlink or direct\
|
|
1529
1545
|
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 or(o,!0);for(let i of await
|
|
1546
|
+
e"}.`);return r}async function St(e,t){if((await or(e,!1)).size>t)throw new Error(`Installed file exceeds its ${t}-byte \
|
|
1547
|
+
limit.`);let n=await Mg(e);if(n.length>t)throw new Error(`Installed file exceeds its ${t}-byte limit.`);return n}async function Bg(e){
|
|
1548
|
+
let t=[],r=0;async function n(o){await or(o,!0);for(let i of await Dg(o,{withFileTypes:!0})){if(++r>65536)throw new Error(
|
|
1533
1549
|
"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
|
|
1535
|
-
function
|
|
1536
|
-
te server-owned system root.");let r=D.resolve(e),n=new Map;function o(d){return
|
|
1550
|
+
t.push(D.relative(e,s).split(D.sep).join("/")))}}return await n(e),t.sort()}function ir({systemRoot:e}){return zg(e,Hg)}
|
|
1551
|
+
function zg(e,t){if(typeof e!="string"||!e||!D.isAbsolute(e))throw new Error("Installed teaching content needs an absolu\
|
|
1552
|
+
te server-owned system root.");let r=D.resolve(e),n=new Map;function o(d){return En(`Lesson ${d.lesson.code} ("${d.lesson.
|
|
1537
1553
|
title}") cannot be taught by this version of Vibe64: ${d.problem} Update the course in Courses, or ask its authors for a\
|
|
1538
1554
|
fixed release.`,"VIBE64_TRAINING_LESSON_UNUSABLE",422,{params:{lessonCode:d.lesson.code,lessonTitle:d.lesson.title,problem:d.
|
|
1539
|
-
problem}})}async function i(d={}){let p=await s(d);return{...p,bundles:p.bundles.map(_=>({..._,lesson:
|
|
1540
|
-
topicId:d,commit:p,topicHash:_}={}){if(typeof d!="string"||typeof p!="string"||!je.test(d)||!
|
|
1555
|
+
problem}})}async function i(d={}){let p=await s(d);return{...p,bundles:p.bundles.map(_=>({..._,lesson:Ei(_.lesson)}))}}async function s({
|
|
1556
|
+
topicId:d,commit:p,topicHash:_}={}){if(typeof d!="string"||typeof p!="string"||!je.test(d)||!bi.test(p))throw new Error(
|
|
1541
1557
|
"Choose a valid topic ID and its exact 40-character lowercase Git commit.");if(typeof _!="string"||!nr.test(_))throw new Error(
|
|
1542
1558
|
"Provide the trusted 64-character topic hash from the course or saved attempt.");let b=JSON.stringify([d,p,_]),v=n.get(b);
|
|
1543
1559
|
return v||(v=a({topicId:d,commit:p,topicHash:_}).finally(()=>n.delete(b)),n.set(b,v)),structuredClone(await v)}async function a({
|
|
1544
1560
|
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 or(se,!0);let A=et(JSON.parse((await
|
|
1546
|
-
topicHash:_}),
|
|
1561
|
+
r,b,v,w,E])await or(se,!0);let A=et(JSON.parse((await St(D.join(E,"pin.json"),4096)).toString("utf8")),{topicId:d,commit:p,
|
|
1562
|
+
topicHash:_}),T=JSON.parse((await St(D.join(E,"bundle.json"),32*1024*1024)).toString("utf8")),O=D.join(E,"files"),U=await Bg(
|
|
1547
1563
|
O),x=await He(O,{installed:!0}),k={schemaVersion:1,topic:x.topic,release:x.release,topicHash:x.topicHash,topicManifest:x.
|
|
1548
|
-
topicManifest,lessons:x.bundles.map(({lesson:se,hash:Ee,status:
|
|
1549
|
-
required:
|
|
1564
|
+
topicManifest,lessons:x.bundles.map(({lesson:se,hash:Ee,status:Hl,required:zl,manifest:Fl})=>({code:se.code,hash:Ee,status:Hl,
|
|
1565
|
+
required:zl,manifest:Fl}))};if(L(T)!==L(k))throw new Error("Installed bundle is incomplete, reordered, unsupported or ch\
|
|
1550
1566
|
anged from its source files.");if(x.topic.topicId!==A.topicId||x.release!==A.release||x.topicHash!==A.topicHash)throw new Error(
|
|
1551
1567
|
"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
|
|
1553
|
-
O,"package.json"),1024*1024),pe=F.find(se=>se.path==="package.json");if(
|
|
1554
|
-
"Installed source changed during reading.");if(JSON.parse(
|
|
1568
|
+
L(F.map(se=>se.path).sort()))throw new Error("Installed snapshot has missing or unrecorded files.");let ee=await St(D.join(
|
|
1569
|
+
O,"package.json"),1024*1024),pe=F.find(se=>se.path==="package.json");if(ee.length!==pe.bytes||K(ee)!==pe.sha256)throw new Error(
|
|
1570
|
+
"Installed source changed during reading.");if(JSON.parse(ee.toString("utf8")).repository?.url!==`https://github.com/${A.
|
|
1555
1571
|
repository}.git`)throw new Error("Installed package repository URL differs from its canonical pin.");return{pin:A,...x}}catch(b){
|
|
1556
1572
|
let v=["ENOENT","ENOTDIR"].includes(b.code),w=new Error(v?`Pinned teaching content ${d}@${p} is missing. Ask the owner t\
|
|
1557
1573
|
o install that exact revision.`:`Pinned teaching content ${d}@${p} is invalid: ${b.message} Ask the owner to reinstall t\
|
|
1558
1574
|
he verified snapshot.`,{cause:b});throw w.code=v?"VIBE64_TRAINING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",w}}
|
|
1559
1575
|
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
1576
|
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
|
|
1562
|
-
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:E,bytes:
|
|
1563
|
-
topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof d!="string"||!je.test(d)||typeof p!="string"||!
|
|
1577
|
+
ecorded installed file.");let T=await St(w,1024*1024);if(T.length!==A.bytes||K(T)!==A.sha256)throw new Error("Installed \
|
|
1578
|
+
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:E,bytes:T}}async function u({
|
|
1579
|
+
topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof d!="string"||!je.test(d)||typeof p!="string"||!bi.
|
|
1564
1580
|
test(p)||typeof _!="string"||!nr.test(_)||typeof b!="string"||!je.test(b)||typeof v!="string"||!nr.test(v))throw new Error(
|
|
1565
1581
|
"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
|
-
|
|
1567
|
-
"utf8")),{topicId:d,commit:p,topicHash:_}),U=JSON.parse((await
|
|
1568
|
-
x=U.topicManifest;if(!x||
|
|
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),
|
|
1570
|
-
lessons.find(Ee=>Ee.code===b);if(!k||!F||!
|
|
1571
|
-
differs from the trusted content hash.");if(!t(k.status))throw new Error(`Lesson ${b} is draft and cannot be taught.
|
|
1572
|
-
|
|
1573
|
-
se=
|
|
1574
|
-
|
|
1575
|
-
Ask the owner to restore the exact snapshot.`,{cause:w});throw E.code=["ENOENT","ENOTDIR"].includes(w.code)?"
|
|
1576
|
-
|
|
1577
|
-
p.lesson)}}async function m({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof b!="
|
|
1578
|
-
"string"||!je.test(b)||!nr.test(v))throw new Error("Choose a declared lesson code and its exact 64-
|
|
1579
|
-
|
|
1580
|
-
`Lesson ${b} is not declared in this pinned topic.`);if(!t(E.status))throw new Error(`Lesson ${b} is
|
|
1581
|
-
taught. Choose a published lesson.`);if(E.hash!==v)throw new Error(`Lesson ${b} content hash changed.
|
|
1582
|
-
pinned revision or explicitly start a new attempt.`);if(E.problem)throw o(E);let A=Object.fromEntries(["
|
|
1583
|
-
|
|
1584
|
-
descriptorPath,declarations:A}}async function f(d={}){let p=await l(d),_=D.dirname(p.descriptorPath);
|
|
1585
|
-
let O=await c(p,_,
|
|
1586
|
-
|
|
1587
|
-
O=[];for(let U of p.lesson.steps){let{body:x,beats:k}=
|
|
1588
|
-
{}})}return{...p,steps:O,...p.lesson.notes===void 0?{}:{notesText:(await b(p.lesson.notes)).text},
|
|
1589
|
-
schemaVersion!==1)throw new Error(`Lesson ${p.lesson.code} uses an unsupported format.`);let w=await b(
|
|
1590
|
-
E=p.lesson.assessments.map(
|
|
1591
|
-
index})).sort((
|
|
1592
|
-
E[O+1]?.position??w.text.length)}));return{...p,document:w,rubrics:A,visuals:v}}async function h({
|
|
1593
|
-
"string"||!je.test(d))throw new Error("Choose a declared step ID.");let{pin:_,lesson:b,hash:v}=await m(
|
|
1594
|
-
`Lesson ${b.code} has no steps.`);let w=b.steps.find(E=>E.id===d);if(!w)throw new Error(`
|
|
1595
|
-
is pinned lesson.`);if(w.check.kind!=="choice")throw new Error(`Step ${d} is not a choice
|
|
1596
|
-
code,lessonHash:v,stepId:d,answer:[...w.check.answer]}}async function y({topicId:d,commit:p,
|
|
1597
|
-
visualId:w}={}){if(typeof w!="string"||!je.test(w))throw new Error("Choose a
|
|
1598
|
-
commit:p,topicHash:_,lessonCode:b,lessonHash:v}),A=E.visuals.find(k=>k.id===w);
|
|
1599
|
-
|
|
1600
|
-
O=await c(E,
|
|
1601
|
-
k));return{pin:E.pin,lessonCode:E.lesson.code,lessonHash:E.hash,...A,
|
|
1602
|
-
commit:p,topicHash:_,lessonCode:b,lessonHash:v,checkId:w}={}){if(typeof w!=
|
|
1603
|
-
a declared check ID.");let E=await f({topicId:d,commit:p,topicHash:_,lessonCode:b,
|
|
1604
|
-
x=>x.id===w);if(!A)throw new Error(`Check ${w} is not declared in this pinned
|
|
1605
|
-
O=await c(E,
|
|
1606
|
-
hash,check:A,file:O,assets:U}}async function S({topicId:d,commit:p,topicHash:_,
|
|
1607
|
-
admissionOnly:E=!1}={}){if(E===!0&&w!==!0)throw new TypeError("Admission
|
|
1608
|
-
|
|
1609
|
-
new Error(`Lesson ${b} has no declared bundled exercise.`),{code:"
|
|
1610
|
-
D.posix.dirname(
|
|
1611
|
-
if(w===!0)return x;let k=U==="."?"":`${U}/`,F=[];for(let
|
|
1612
|
-
path.slice(k.length),cr=await c(
|
|
1613
|
-
readLesson:f,readAdmissionIdentity:u,readVisual:y,readCheck:
|
|
1614
|
-
Gg,
|
|
1615
|
-
|
|
1616
|
-
schemaVersion:{type:"integer",required:!0,enum:[1]},topicId:{...rr,maxLength:64},release:rr,
|
|
1617
|
-
maxLength:40},topicHash:{...rr,maxLength:64}});
|
|
1618
|
-
import
|
|
1619
|
-
throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function
|
|
1620
|
-
relative(e,t);return!r||r!==".."&&!r.startsWith(`..${
|
|
1621
|
-
await
|
|
1582
|
+
T=D.join(A,p);for(let Ee of[r,w,E,A,T])await or(Ee,!0);let O=et(JSON.parse((await St(D.join(T,"pin.json"),4096)).toString(
|
|
1583
|
+
"utf8")),{topicId:d,commit:p,topicHash:_}),U=JSON.parse((await St(D.join(T,"bundle.json"),32*1024*1024)).toString("utf8")),
|
|
1584
|
+
x=U.topicManifest;if(!x||K(L(x))!==_||x.topic.topicId!==d||x.release!==O.release)throw new Error("Installed topic manife\
|
|
1585
|
+
st differs from the trusted identity.");let k=x.lessons.find(Ee=>Ee.code===b),F=x.topic.lessons.find(Ee=>Ee.code===b),ee=U.
|
|
1586
|
+
lessons.find(Ee=>Ee.code===b);if(!k||!F||!ee||k.hash!==v||K(L(ee.manifest))!==v)throw new Error("Installed lesson manife\
|
|
1587
|
+
st differs from the trusted content hash.");if(!t(k.status))throw new Error(`Lesson ${b} is draft and cannot be taught. \
|
|
1588
|
+
Choose a published lesson.`);let pe={pin:O,manifest:ee.manifest,hash:v,descriptorPath:F.descriptor},cr=await c(pe,".",F.
|
|
1589
|
+
descriptor),se=xr(JSON.parse(cr.bytes.toString("utf8")),b);if(se.code!==b)throw new Error("Installed lesson descriptor i\
|
|
1590
|
+
dentity changed.");return{...pe,lesson:Ei(se)}}catch(w){let E=new Error(`Pinned teaching identity ${d}@${p} is invalid: ${w.
|
|
1591
|
+
message} Ask the owner to restore the exact snapshot.`,{cause:w});throw E.code=["ENOENT","ENOTDIR"].includes(w.code)?"VI\
|
|
1592
|
+
BE64_TRAINING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",E}}async function l(d={}){let p=await m(d);return{...p,
|
|
1593
|
+
lesson:Ei(p.lesson)}}async function m({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof b!="strin\
|
|
1594
|
+
g"||typeof v!="string"||!je.test(b)||!nr.test(v))throw new Error("Choose a declared lesson code and its exact 64-charact\
|
|
1595
|
+
er lowercase content hash.");let w=await s({topicId:d,commit:p,topicHash:_}),E=w.bundles.find(T=>T.lesson.code===b);if(!E)
|
|
1596
|
+
throw new Error(`Lesson ${b} is not declared in this pinned topic.`);if(!t(E.status))throw new Error(`Lesson ${b} is dra\
|
|
1597
|
+
ft and cannot be taught. Choose a published lesson.`);if(E.hash!==v)throw new Error(`Lesson ${b} content hash changed. R\
|
|
1598
|
+
esume its exact pinned revision or explicitly start a new attempt.`);if(E.problem)throw o(E);let A=Object.fromEntries(["\
|
|
1599
|
+
places","activities","facts"].map(T=>[T,[...w.topic[T]||[]]]));return{pin:w.pin,lesson:E.lesson,manifest:E.manifest,hash:E.
|
|
1600
|
+
hash,descriptorPath:E.descriptorPath,declarations:A}}async function f(d={}){let p=await l(d),_=D.dirname(p.descriptorPath);
|
|
1601
|
+
async function b(T){let O=await c(p,_,T);return{path:O.path,text:O.bytes.toString("utf8")}}let v=[];for(let T of p.lesson.
|
|
1602
|
+
visuals){let O=await b(T.descriptor);v.push({id:T.id,descriptorPath:O.path,visual:JSON.parse(O.text)})}if(me(p.lesson)){
|
|
1603
|
+
let T=Lr(p.declarations),O=[];for(let U of p.lesson.steps){let{body:x,beats:k}=Dr((await b(U.body)).text,T);O.push({...U,
|
|
1604
|
+
bodyText:x,...k?{beats:k}:{}})}return{...p,steps:O,...p.lesson.notes===void 0?{}:{notesText:(await b(p.lesson.notes)).text},
|
|
1605
|
+
visuals:v}}if(p.lesson.schemaVersion!==1)throw new Error(`Lesson ${p.lesson.code} uses an unsupported format.`);let w=await b(
|
|
1606
|
+
p.lesson.document),E=p.lesson.assessments.map(T=>({id:T.id,reference:T.rubric,position:new RegExp(`^<a id="${T.id}"></a>\
|
|
1607
|
+
$`,"mu").exec(w.text).index})).sort((T,O)=>T.position-O.position),A=E.map((T,O)=>({id:T.id,reference:T.reference,text:w.
|
|
1608
|
+
text.slice(T.position,E[O+1]?.position??w.text.length)}));return{...p,document:w,rubrics:A,visuals:v}}async function h({
|
|
1609
|
+
stepId:d,...p}={}){if(typeof d!="string"||!je.test(d))throw new Error("Choose a declared step ID.");let{pin:_,lesson:b,hash:v}=await m(
|
|
1610
|
+
p);if(!me(b))throw new Error(`Lesson ${b.code} has no steps.`);let w=b.steps.find(E=>E.id===d);if(!w)throw new Error(`St\
|
|
1611
|
+
ep ${d} is not declared in this pinned lesson.`);if(w.check.kind!=="choice")throw new Error(`Step ${d} is not a choice s\
|
|
1612
|
+
tep.`);return{pin:_,lessonCode:b.code,lessonHash:v,stepId:d,answer:[...w.check.answer]}}async function y({topicId:d,commit:p,
|
|
1613
|
+
topicHash:_,lessonCode:b,lessonHash:v,visualId:w}={}){if(typeof w!="string"||!je.test(w))throw new Error("Choose a decla\
|
|
1614
|
+
red visual ID.");let E=await f({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}),A=E.visuals.find(k=>k.id===w);
|
|
1615
|
+
if(!A)throw vt(`Visual ${w} is not declared in this pinned lesson.`,"VIBE64_TRAINING_VISUAL_UNDECLARED",{statusCode:400,
|
|
1616
|
+
params:{visualId:w}});let T=D.dirname(A.descriptorPath),O=await c(E,T,A.visual.svg),U=await c(E,T,A.visual.controller),x=[];
|
|
1617
|
+
for(let k of A.visual.assets||[])x.push(await c(E,T,k));return{pin:E.pin,lessonCode:E.lesson.code,lessonHash:E.hash,...A,
|
|
1618
|
+
svg:O,controller:U,assets:x}}async function I({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v,checkId:w}={}){if(typeof w!=
|
|
1619
|
+
"string"||!je.test(w))throw new Error("Choose a declared check ID.");let E=await f({topicId:d,commit:p,topicHash:_,lessonCode:b,
|
|
1620
|
+
lessonHash:v}),A=E.lesson.checks?.find(x=>x.id===w);if(!A)throw new Error(`Check ${w} is not declared in this pinned les\
|
|
1621
|
+
son.`);let T=D.dirname(E.descriptorPath),O=await c(E,T,A.file),U=[];for(let x of A.assets||[])U.push(await c(E,T,x));return{
|
|
1622
|
+
pin:E.pin,lessonCode:E.lesson.code,lessonHash:E.hash,check:A,file:O,assets:U}}async function S({topicId:d,commit:p,topicHash:_,
|
|
1623
|
+
lessonCode:b,lessonHash:v,metadataOnly:w=!1,admissionOnly:E=!1}={}){if(E===!0&&w!==!0)throw new TypeError("Admission rea\
|
|
1624
|
+
ds cannot supply exercise content.");let T=await(E===!0?u:w===!0?l:f)({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}),
|
|
1625
|
+
O=T.lesson.exercise;if(!O)throw Object.assign(new Error(`Lesson ${b} has no declared bundled exercise.`),{code:"VIBE64_T\
|
|
1626
|
+
RAINING_EXERCISE_MISSING"});let U=D.posix.join(D.posix.dirname(T.descriptorPath),O.source),x={pin:T.pin,lessonCode:T.lesson.
|
|
1627
|
+
code,lessonHash:T.hash,exercise:O,sourcePath:U};if(w===!0)return x;let k=U==="."?"":`${U}/`,F=[];for(let ee of T.manifest.
|
|
1628
|
+
files){if(!ee.path.startsWith(k))continue;let pe=ee.path.slice(k.length),cr=await c(T,U,pe);F.push({path:pe,bytes:cr.bytes})}
|
|
1629
|
+
return{...x,files:F}}return Object.freeze({readTopic:i,readLesson:f,readAdmissionIdentity:u,readVisual:y,readCheck:I,readExercise:S,
|
|
1630
|
+
readChoiceAnswer:h})}var je,bi,nr,Vg,rr,Gg,Hg,vi=g(()=>{Cr();dt();ut();bo();Mr();Ol();lt();bn();je=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,
|
|
1631
|
+
bi=/^[a-f0-9]{40}$/u,nr=/^[a-f0-9]{64}$/u,Vg=/^[a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+$/u,rr={type:"string",required:!0,noTrim:!0,
|
|
1632
|
+
minLength:1,maxLength:256},Gg=$({schemaVersion:{type:"integer",required:!0,enum:[1]},topicId:{...rr,maxLength:64},release:rr,
|
|
1633
|
+
repository:rr,commit:{...rr,maxLength:40},topicHash:{...rr,maxLength:64}});Hg=e=>e==="published"});import{randomUUID as Fg}from"node:crypto";import{lstat as qg,mkdir as Ii,realpath as Wg,rename as Yg,rm as Jg,writeFile as Kg}from"node:fs/promises";
|
|
1634
|
+
import Z from"node:path";function Pl(e,t){if(typeof e!="string"||!Z.isAbsolute(e)||Z.resolve(e)!==e||e===Z.parse(e).root)
|
|
1635
|
+
throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function Rl(e,t){let r=Z.
|
|
1636
|
+
relative(e,t);return!r||r!==".."&&!r.startsWith(`..${Z.sep}`)&&!Z.isAbsolute(r)}async function _e(e,t,r=!0){let n;try{n=
|
|
1637
|
+
await qg(e)}catch(o){if(r&&o.code==="ENOENT")return null;throw o}if(n.isSymbolicLink()||await Wg(e)!==e)throw new Error(
|
|
1622
1638
|
"Training installation cannot use symlink or directory aliases.");if(t?!n.isDirectory():!n.isFile())throw new Error(`Tra\
|
|
1623
1639
|
ining installation needs a regular ${t?"directory":"file"}: ${e}.`);if(!t&&(n.nlink!==1||n.size!==0))throw new Error("Tr\
|
|
1624
|
-
aining installation lock must be an unaliased empty regular file; inspect it before retrying.");return n}async function
|
|
1625
|
-
let r=
|
|
1626
|
-
code!=="EEXIST")throw t}await _e(e,!0,!1)}function
|
|
1627
|
-
pshot conflicts with the approved owner pin. Keep existing content and check the exact source revision.")}async function
|
|
1628
|
-
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await er(e);
|
|
1629
|
-
commit:i,topicHash:s},t)}function
|
|
1630
|
-
sourceRoot:o,pin:i}={}){let s={...et(i)};
|
|
1631
|
-
throw new Error("Trusted topic source must be separate from the training installation namespace.");let c=
|
|
1632
|
-
nt"),u=
|
|
1633
|
-
await
|
|
1640
|
+
aining installation lock must be an unaliased empty regular file; inspect it before retrying.");return n}async function vn(e,t=!1){
|
|
1641
|
+
let r=Z.dirname(e);return r!==e&&await vn(r,t),_e(e,!0,t)}async function Xg(e){try{await Ii(e,{mode:448})}catch(t){if(t.
|
|
1642
|
+
code!=="EEXIST")throw t}await _e(e,!0,!1)}function Sn(e,t){if(L(e)!==L(t))throw new Error("Topic source or installed sna\
|
|
1643
|
+
pshot conflicts with the approved owner pin. Keep existing content and check the exact source revision.")}async function Si(e,t){
|
|
1644
|
+
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await er(e);Sn({schemaVersion:1,topicId:r,release:n,repository:o,
|
|
1645
|
+
commit:i,topicHash:s},t)}function Nl({systemRoot:e}){let t=Pl(e,"Training system root"),r=ir({systemRoot:t});async function n({
|
|
1646
|
+
sourceRoot:o,pin:i}={}){let s={...et(i)};Pl(o,"Trusted topic source root");let a=Z.join(t,"training");if(Rl(o,a)||Rl(a,o))
|
|
1647
|
+
throw new Error("Trusted topic source must be separate from the training installation namespace.");let c=Z.join(a,"conte\
|
|
1648
|
+
nt"),u=Z.join(c,s.topicId),l=Z.join(u,s.commit),m=Z.join(a,".install-locks"),f=Z.join(m,`${s.topicId}-${s.commit}.lock`);
|
|
1649
|
+
await vn(t);let h=await vn(o,!0);for(let d of[a,c,u,m])await _e(d,!0);if(await _e(f,!1),await _e(l,!0))Sn((await r.readTopic(
|
|
1634
1650
|
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
|
|
1651
|
+
talling its pin.");await Si(o,s)}for(let d of[a,c,u,m])await Xg(d);let I=await ft(f);if(!I)throw En("This topic revision\
|
|
1636
1652
|
is being installed. Retry after the current owner operation finishes.","VIBE64_TRAINING_INSTALL_BUSY");let S;try{await _e(
|
|
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
|
|
1638
|
-
...v}}await
|
|
1639
|
-
"content",s.topicId);await
|
|
1640
|
-
await
|
|
1653
|
+
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 Sn(v.pin,s),{installed:!1,
|
|
1654
|
+
...v}}await vn(o),await Si(o,s);let d=Z.join(a,`.install-${Fg()}`);await Ii(d,{mode:448}),S=d;let p=Z.join(S,"training",
|
|
1655
|
+
"content",s.topicId);await Ii(p,{recursive:!0,mode:448});let _=Z.join(p,s.commit);if(await Ti(["bundle",o,_],{write(){}}),
|
|
1656
|
+
await Si(o,s),await Kg(Z.join(_,"pin.json"),`${L(s)}
|
|
1641
1657
|
`,{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
|
|
1643
|
-
s);return
|
|
1644
|
-
freeze({installTopic:n})}var
|
|
1645
|
-
import
|
|
1646
|
-
mode:n});let s=
|
|
1647
|
-
o!==void 0&&await
|
|
1658
|
+
ination appeared during installation. Keep it unchanged and retry the verified pin.");await Yg(_,l);let b=await r.readTopic(
|
|
1659
|
+
s);return Sn(b.pin,s),{installed:!0,...b}}finally{try{S&&await Jg(S,{recursive:!0,force:!0})}finally{await I()}}}return Object.
|
|
1660
|
+
freeze({installTopic:n})}var Cl=g(()=>{Wr();_n();Ai();dt();bn();vi()});import{randomUUID as Qg}from"node:crypto";import{chmod as Zg,mkdir as ew,rename as tw,rm as rw,writeFile as nw}from"node:fs/promises";
|
|
1661
|
+
import Oi from"node:path";async function ow(e,t,r={}){let{directoryMode:n,fileMode:o}=r,i=Oi.dirname(e);await ew(i,{recursive:!0,
|
|
1662
|
+
mode:n});let s=Oi.join(i,`.${Oi.basename(e)}.${process.pid}.${Qg()}.tmp`);try{await nw(s,t,{encoding:"utf8",flag:"wx",mode:o}),
|
|
1663
|
+
o!==void 0&&await Zg(s,o),await tw(s,e)}finally{await rw(s,{force:!0})}}async function kl(e,t,r={}){await ow(e,`${JSON.stringify(
|
|
1648
1664
|
t,null,2)}
|
|
1649
|
-
`,r)}var
|
|
1665
|
+
`,r)}var xl=g(()=>{});import{lstat as iw,mkdir as sw,readFile as aw,realpath as cw}from"node:fs/promises";import Le from"node:path";function Ri(e){
|
|
1650
1666
|
if(!Number.isSafeInteger(e)||e<0)throw new Error("Supply the expected revision from a fresh installed catalogue read.")}
|
|
1651
|
-
function
|
|
1667
|
+
function Ni({systemRoot:e}){if(typeof e!="string"||!Le.isAbsolute(e)||Le.resolve(e)!==e||e===Le.parse(e).root)throw new Error(
|
|
1652
1668
|
"Installed catalogue needs a canonical absolute, non-root server-owned system root.");let t=Le.join(e,"training"),r=Le.join(
|
|
1653
1669
|
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
|
|
1655
|
-
"ENOENT")continue;throw w}let v=_!==r&&_!==n;if(b.isSymbolicLink()||await
|
|
1670
|
+
_),_!==Le.dirname(_);_=Le.dirname(_));let d=!1,p=null;for(let _ of[...S,r,n]){let b;try{b=await iw(_)}catch(w){if(w.code===
|
|
1671
|
+
"ENOENT")continue;throw w}let v=_!==r&&_!==n;if(b.isSymbolicLink()||await cw(_)!==_||(v?!b.isDirectory():!b.isFile()||b.
|
|
1656
1672
|
nlink!==1))throw new Error("Installed catalogue paths must be canonical directories and unaliased regular files.");if(_===
|
|
1657
1673
|
e&&(d=!0),_===r&&(p=b),_===n&&b.size!==0)throw new Error("Installed catalogue lock contains unexplained data. Inspect it\
|
|
1658
1674
|
; do not unlink it.")}return{rootExists:d,catalogueStat:p}}async function s(S){let d=S.lock.topics;if(!Array.isArray(d)||
|
|
@@ -1660,46 +1676,46 @@ d.length!==S.course.topics.length||d.length>32)throw new Error("The approved cou
|
|
|
1660
1676
|
le topic in order.");let p=[],_=[],b=[];for(let w of d){let E=et({schemaVersion:1,topicId:w?.topicId,release:w?.release,
|
|
1661
1677
|
repository:w?.repository,commit:w?.commit,topicHash:w?.manifestHash}),A=await o.readTopic(E);if(L(A.pin)!==L(E))throw new Error(
|
|
1662
1678
|
"Installed topic identity differs from the approved course lock.");b.push({topicId:E.topicId,release:E.release,title:A.topicManifest.
|
|
1663
|
-
topic.title});for(let
|
|
1679
|
+
topic.title});for(let T of A.bundles)_.push({topicId:E.topicId,topicRelease:E.release,code:T.lesson.code,hash:T.hash,title:T.
|
|
1664
1680
|
lesson.title});p.push({topicId:A.pin.topicId,release:A.release,repository:A.pin.repository,commit:A.pin.commit,topicManifest:A.
|
|
1665
1681
|
topicManifest,topicHash:A.topicHash})}let v=tr(S.course,p);if(L(S.lock)!==L(v))throw new Error("The approved course lock\
|
|
1666
1682
|
differs from the complete installed topic inventory. Regenerate and review its exact release.");return{lessonTitles:_,topicTitles:b}}
|
|
1667
1683
|
async function a({includeLessonTitles:S=!1}={}){if(typeof S!="boolean")throw new TypeError("Lesson title projection requ\
|
|
1668
1684
|
ires an explicit Boolean read option.");try{let{catalogueStat:d}=await i();if(!d)return{schemaVersion:1,revision:0,courses:[]};
|
|
1669
|
-
if(d.size>
|
|
1670
|
-
"Installed catalogue exceeds its 1 MiB limit.");let _=ce(
|
|
1685
|
+
if(d.size>Pi)throw new Error("Installed catalogue exceeds its 1 MiB limit.");let p=await aw(r);if(p.length>Pi)throw new Error(
|
|
1686
|
+
"Installed catalogue exceeds its 1 MiB limit.");let _=ce(uw,JSON.parse(p.toString("utf8")),"Installed catalogue");if(_.courses.
|
|
1671
1687
|
length&&_.revision<1)throw new Error("Installed catalogue revision conflicts with its course inventory.");let b=new Set;
|
|
1672
1688
|
for(let v of _.courses){let w=`${v.course.courseId}@${v.course.release}`;if(b.has(w))throw new Error("Installed catalogu\
|
|
1673
1689
|
e contains duplicate course releases.");b.add(w);let{lessonTitles:E,topicTitles:A}=await s(v);S&&Object.assign(v,{lessonTitles:E,
|
|
1674
|
-
topicTitles:A})}return _}catch(d){throw
|
|
1690
|
+
topicTitles:A})}return _}catch(d){throw _i(`Installed catalogue is invalid: ${d.message} Keep existing state and ask the\
|
|
1675
1691
|
owner to restore the exact approved catalogue or pinned content. No automatic repair was performed.`,"VIBE64_TRAINING_C\
|
|
1676
1692
|
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
|
|
1693
|
+
tem root before changing the catalogue.");try{await sw(t,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}await i();let d=await ft(
|
|
1678
1694
|
n);if(!d)throw ye("Installed catalogue is being updated. Retry after the current owner operation finishes.","VIBE64_TRAI\
|
|
1679
1695
|
NING_CATALOGUE_BUSY",409);return d}function u(S,d){if(S.revision!==d)throw ye("Installed catalogue changed. Read its cur\
|
|
1680
1696
|
rent revision before deliberately retrying this enablement change.","VIBE64_TRAINING_CATALOGUE_REVISION_CONFLICT",409)}async function l(S,d){
|
|
1681
1697
|
if(S.revision===Number.MAX_SAFE_INTEGER)throw new Error("Installed catalogue reached its revision limit. No change was w\
|
|
1682
1698
|
ritten.");let p={...S,revision:S.revision+1};if(Buffer.byteLength(`${JSON.stringify(p,null,2)}
|
|
1683
|
-
`)>
|
|
1684
|
-
fileMode:384})}catch(_){throw
|
|
1699
|
+
`)>Pi)throw new Error("Installed catalogue exceeds its 1 MiB limit. No change was written.");try{await kl(r,p,{directoryMode:448,
|
|
1700
|
+
fileMode:384})}catch(_){throw _i("Catalogue save was not confirmed; atomic rename may already have succeeded. Read the c\
|
|
1685
1701
|
urrent catalogue before deliberately retrying. Do not assume the course changed or remained unchanged.","VIBE64_TRAINING\
|
|
1686
1702
|
_CATALOGUE_SAVE_UNCONFIRMED",_)}return{revision:p.revision,entry:d,changed:!0}}async function m({course:S,lock:d,expectedRevision:p}={}){
|
|
1687
|
-
|
|
1703
|
+
Ri(p);let _=structuredClone(ce($l,{course:S,lock:d,enabled:!0},"Approved installed course"));await a(),await s(_);let b=await c();
|
|
1688
1704
|
try{let v=await a();u(v,p),await s(_);let w=v.courses.find(E=>E.course.courseId===_.course.courseId&&E.course.release===
|
|
1689
1705
|
_.course.release);if(w){if(L(w.course)!==L(_.course)||L(w.lock)!==L(_.lock))throw ye("This installed course release is i\
|
|
1690
1706
|
mmutable. Resume its approved pin or publish and approve a different course release.","VIBE64_TRAINING_COURSE_RELEASE_CO\
|
|
1691
1707
|
NFLICT",409);return w.enabled?{revision:v.revision,entry:w,changed:!1}:(w.enabled=!0,await l(v,w))}if(v.courses.length>=
|
|
1692
1708
|
sr)throw new Error("Installed catalogue reached its 16 course-release limit. Remove a release with vibe64 training remov\
|
|
1693
1709
|
e-course to free a place; no release was removed.");return v.courses.push(_),await l(v,_)}finally{await b()}}async function f({
|
|
1694
|
-
courseId:S,release:d,expectedRevision:p},_){if(
|
|
1710
|
+
courseId:S,release:d,expectedRevision:p},_){if(Ri(p),typeof S!="string"||!/^[a-z][a-z0-9-]{0,63}$/u.test(S)||typeof d!="\
|
|
1695
1711
|
string"||!/^\d+\.\d+\.\d+$/u.test(d))throw new Error(`${_?"Remove":"Disable"} an exact installed course ID and three-par\
|
|
1696
1712
|
t release.`);if(!(await a()).courses.some(w=>w.course.courseId===S&&w.course.release===d))throw ye("This course release \
|
|
1697
1713
|
is not installed in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_MISSING",404);let v=await c();
|
|
1698
1714
|
try{let w=await a();u(w,p);let E=w.courses.find(A=>A.course.courseId===S&&A.course.release===d);if(!E)throw ye("This cou\
|
|
1699
1715
|
rse release is no longer in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_REMOVED",
|
|
1700
1716
|
404);return _?(w.courses=w.courses.filter(A=>A!==E),await l(w,E)):E.enabled?(E.enabled=!1,await l(w,E)):{revision:w.revision,
|
|
1701
|
-
entry:E,changed:!1}}finally{await v()}}let h=S=>f(S,!1),y=S=>f(S,!0);async function
|
|
1702
|
-
|
|
1717
|
+
entry:E,changed:!1}}finally{await v()}}let h=S=>f(S,!1),y=S=>f(S,!0);async function I({title:S,topics:d,expectedRevision:p}){
|
|
1718
|
+
Ri(p);let _=typeof S=="string"?S.trim():"";if(!_||_.length>120)throw ye("Name the course with 1 to 120 characters.","VIB\
|
|
1703
1719
|
E64_TRAINING_COURSE_NAME_INVALID",400);if(!Array.isArray(d)||!d.length||d.length>32||new Set(d.map(O=>`${O?.topicId}@${O?.
|
|
1704
1720
|
release}`)).size!==d.length||new Set(d.map(O=>O?.topicId)).size!==d.length)throw ye("Choose 1 to 32 different whole topi\
|
|
1705
1721
|
cs for the course.","VIBE64_TRAINING_COURSE_TOPICS_INVALID",400);let b=await a(),v=b.courses.filter(O=>O.enabled&&O.course.
|
|
@@ -1709,96 +1725,96 @@ choose an installed topic.`,"VIBE64_TRAINING_COURSE_TOPIC_UNAVAILABLE",404);let
|
|
|
1709
1725
|
topicId:U.topicId,release:U.release,repository:U.repository,commit:U.commit,topicHash:U.manifestHash}));w.push({topicId:x.
|
|
1710
1726
|
pin.topicId,release:x.release,repository:x.pin.repository,commit:x.pin.commit,topicManifest:x.topicManifest,topicHash:x.
|
|
1711
1727
|
topicHash})}let A={schemaVersion:1,courseId:`custom-${_.toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"").
|
|
1712
|
-
slice(0,48).replace(/-+$/u,"")||
|
|
1713
|
-
topicId,release:O.release}))},
|
|
1714
|
-
ourse with this name already exists. Choose another name.","VIBE64_TRAINING_COURSE_EXISTS",409);if(!
|
|
1715
|
-
sr)throw
|
|
1728
|
+
slice(0,48).replace(/-+$/u,"")||K(_).slice(0,12)}`,title:_,release:"1.0.0",status:"released",topics:d.map(O=>({topicId:O.
|
|
1729
|
+
topicId,release:O.release}))},T=b.courses.find(O=>O.course.courseId===A.courseId);if(T&&L(T.course)!==L(A))throw ye("A c\
|
|
1730
|
+
ourse with this name already exists. Choose another name.","VIBE64_TRAINING_COURSE_EXISTS",409);if(!T&&b.courses.length>=
|
|
1731
|
+
sr)throw vt(`This installation already has ${sr} course releases. No course was created.`,"VIBE64_TRAINING_COURSE_CREATE\
|
|
1716
1732
|
_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:
|
|
1718
|
-
|
|
1719
|
-
type:"boolean",required:!0}}),
|
|
1720
|
-
min:0,max:Number.MAX_SAFE_INTEGER},courses:H(
|
|
1721
|
-
import W from"node:path";import{randomUUID as
|
|
1733
|
+
enableCourse:m,disableCourse:h,removeCourse:y,createCourse:I})}var sr,Pi,$l,uw,jl=g(()=>{Cr();Wr();xl();_n();dt();ut();vi();
|
|
1734
|
+
bn();lt();sr=16,Pi=1024*1024,$l=$({course:{type:"object",required:!0,schema:jr},lock:{type:"object",required:!0},enabled:{
|
|
1735
|
+
type:"boolean",required:!0}}),uw=$({schemaVersion:{type:"integer",required:!0,enum:[1]},revision:{type:"integer",required:!0,
|
|
1736
|
+
min:0,max:Number.MAX_SAFE_INTEGER},courses:H($l,sr)})});var Dl={};xi(Dl,{runTrainingCli:()=>Ti});import{mkdir as Ll,readFile as In,realpath as It,rename as lw,rm as Ml,writeFile as Ci}from"node:fs/promises";
|
|
1737
|
+
import W from"node:path";import{randomUUID as dw}from"node:crypto";async function Ti(e,{write:t=r=>console.log(r)}={}){if(e[0]===
|
|
1722
1738
|
"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
|
|
1724
|
-
schemaVersion:1,topicId:m,release:f,repository:h,commit:y,topicHash:
|
|
1739
|
+
pic-directory> <system-root>");let l=await It(c),{topicId:m,release:f,repository:h,commit:y,topicHash:I}=await er(l),S={
|
|
1740
|
+
schemaVersion:1,topicId:m,release:f,repository:h,commit:y,topicHash:I},d=await Nl({systemRoot:W.resolve(u)}).installTopic(
|
|
1725
1741
|
{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
|
-
urses"){if(e.length!==2||!e[1])throw new Error("Usage: vibe64 training installed-courses <system-root>");let c=await
|
|
1742
|
+
urses"){if(e.length!==2||!e[1])throw new Error("Usage: vibe64 training installed-courses <system-root>");let c=await Ni(
|
|
1727
1743
|
{systemRoot:W.resolve(e[1])}).readCatalogue();return t(JSON.stringify({ok:!0,...c},null,2)),0}if(["enable-course","disab\
|
|
1728
1744
|
le-course","remove-course"].includes(e[0])){let[c,u,l,m,f]=e;if(e.length!==5||!u||!l||!m||!/^(0|[1-9][0-9]*)$/u.test(f||
|
|
1729
1745
|
"")||!Number.isSafeInteger(Number(f)))throw new Error(c==="enable-course"?"Usage: vibe64 training enable-course <course.\
|
|
1730
1746
|
json> <course.lock.json> <system-root> <expected-revision>":`Usage: vibe64 training ${c} <courseId> <release> <system-ro\
|
|
1731
|
-
ot> <expected-revision>`);let h=
|
|
1732
|
-
parse(await
|
|
1733
|
-
urse":"disableCourse"]({courseId:u,release:l,expectedRevision:y});return t(JSON.stringify({ok:!0,...
|
|
1747
|
+
ot> <expected-revision>`);let h=Ni({systemRoot:W.resolve(m)}),y=Number(f),I=c==="enable-course"?await h.enableCourse({course:JSON.
|
|
1748
|
+
parse(await In(u,"utf8")),lock:JSON.parse(await In(l,"utf8")),expectedRevision:y}):await h[c==="remove-course"?"removeCo\
|
|
1749
|
+
urse":"disableCourse"]({courseId:u,release:l,expectedRevision:y});return t(JSON.stringify({ok:!0,...I},null,2)),0}if(e[0]===
|
|
1734
1750
|
"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
|
|
1751
|
+
n> <committed-topic-directory...>");let l=await It(c),m=W.join(await It(W.dirname(W.resolve(c))),"course.lock.json");if(m===
|
|
1736
1752
|
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
|
|
1753
|
+
let f=JSON.parse(await In(l,"utf8")),h=[];for(let S of u){let d=await It(S),p=W.relative(d,m);if(!p||!p.startsWith(`..${W.
|
|
1738
1754
|
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 er(d))}let y=tr(f,h),
|
|
1740
|
-
`,{flag:"wx"}),await
|
|
1755
|
+
d,{authoring:!0}),h.push(await er(d))}let y=tr(f,h),I=`${m}.tmp-${dw()}`;try{await Ci(I,`${L(y)}
|
|
1756
|
+
`,{flag:"wx"}),await lw(I,m)}finally{await Ml(I,{force:!0})}return t(JSON.stringify({ok:!0,courseId:y.courseId,status:y.
|
|
1741
1757
|
status,lockPath:m,topics:y.topics.length},null,2)),0}let[r,n,o]=e;if(!["validate","bundle"].includes(r)||!n||r==="bundle"&&
|
|
1742
1758
|
!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
|
|
1759
|
+
ectory> <new-output-directory>");let i=await It(n),s=await He(i,{authoring:r==="validate"}),a={schemaVersion:1,topic:s.topic,
|
|
1744
1760
|
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
|
|
1761
|
+
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 It(
|
|
1746
1762
|
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
|
-
"Bundle output must be outside the source topic.");await
|
|
1748
|
-
for(let f of m){let h=await
|
|
1749
|
-
path}. Validate and retry.`);let y=W.join(u,"files",f.path);await
|
|
1750
|
-
await
|
|
1751
|
-
`,{flag:"wx"})}catch(m){throw await
|
|
1763
|
+
"Bundle output must be outside the source topic.");await Ll(u);try{let m=Be([s.topicManifest,...s.bundles.map(f=>f.manifest)]);
|
|
1764
|
+
for(let f of m){let h=await In(W.join(i,f.path));if(K(h)!==f.sha256)throw new Error(`Source changed during bundling: ${f.
|
|
1765
|
+
path}. Validate and retry.`);let y=W.join(u,"files",f.path);await Ll(W.dirname(y),{recursive:!0}),await Ci(y,h,{flag:"wx"})}
|
|
1766
|
+
await Ci(W.join(u,"bundle.json"),`${L(a)}
|
|
1767
|
+
`,{flag:"wx"})}catch(m){throw await Ml(u,{recursive:!0,force:!0}),m}}return t(JSON.stringify({ok:!0,topicId:s.topic.topicId,
|
|
1752
1768
|
status:s.topic.status,lessons:s.bundles.map(({lesson:c,hash:u,status:l})=>({code:c.code,hash:u,status:l,schemaVersion:c.
|
|
1753
|
-
schemaVersion,...c.stage?{stage:c.stage}:{},...me(c)?{steps:c.steps.length}:{}}))},null,2)),0}var
|
|
1754
|
-
|
|
1755
|
-
import ar from"node:path";import{fileURLToPath as
|
|
1756
|
-
resolve(String(e||""));try{return t(r)}catch{return r}}function
|
|
1757
|
-
return n
|
|
1758
|
-
return`'${String(e).replaceAll("'","'\\''")}'`}function
|
|
1759
|
-
"${String(e).replaceAll('"','\\"')}"`}function
|
|
1760
|
-
...t}={}){return
|
|
1761
|
-
env,osReleaseText:t=
|
|
1762
|
-
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function
|
|
1763
|
-
return[Tt(e),Tt(t),...r.map(n=>Tt(n))].join(" ")}function
|
|
1769
|
+
schemaVersion,...c.stage?{stage:c.stage}:{},...me(c)?{steps:c.steps.length}:{}}))},null,2)),0}var Ai=g(()=>{dt();ut();_n();
|
|
1770
|
+
Cl();jl();lt()});import{spawn as Ul}from"node:child_process";import{readFileSync as mw}from"node:fs";import{release as Tn}from"node:os";import j from"node:process";
|
|
1771
|
+
import ar from"node:path";import{fileURLToPath as fw}from"node:url";import{realpathSync as Wl}from"node:fs";import Yl from"node:path";import Jl from"node:process";function $i(e,t){let r=Yl.
|
|
1772
|
+
resolve(String(e||""));try{return t(r)}catch{return r}}function ji({entrypointPath:e,argv:t=Jl.argv,realpath:r=Wl}){let n=t[1];
|
|
1773
|
+
return n?$i(n,r)===$i(e,r):!1}var pw=new URL("./run.js",import.meta.url).href,Vl=fw(pw),Gl=ar.dirname(Vl),At=ar.join(Gl,"server.js");function Tt(e=""){
|
|
1774
|
+
return`'${String(e).replaceAll("'","'\\''")}'`}function hw(e=""){return JSON.stringify(String(e))}function ki(e=""){return`\
|
|
1775
|
+
"${String(e).replaceAll('"','\\"')}"`}function gw(e="",t=[]){return[ki(e),...t.map(r=>ki(r))].join(" ")}function ww({entrypointPath:e=Vl,
|
|
1776
|
+
...t}={}){return ji({entrypointPath:e,...t})}function Bl(e=j.cwd()){return ar.basename(e)||"target"}function yw({env:e=j.
|
|
1777
|
+
env,osReleaseText:t=Tn(),platform:r=j.platform}={}){return r!=="linux"?!1:String(e.WSL_DISTRO_NAME||e.WSL_INTEROP||"").trim()?
|
|
1778
|
+
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function _w({nodePath:e=j.execPath,serverPath:t=At,serverArgs:r=[]}={}){
|
|
1779
|
+
return[Tt(e),Tt(t),...r.map(n=>Tt(n))].join(" ")}function Ew({cwd:e=j.cwd(),nodePath:t=j.execPath,serverArgs:r=[],serverPath:n=At,
|
|
1764
1780
|
title:o=`Vibe64 - ${ar.basename(j.cwd())||"target"}`}={}){return["finish_vibe64_terminal() {",' status="$1"',' message\
|
|
1765
1781
|
="$2"',' if [ "$status" -ne 0 ]; then',` printf '\\n%s Exit status %s. Press Enter to close this terminal...' "$messa\
|
|
1766
1782
|
ge" "$status"`," IFS= read -r _"," fi",' exit "$status"',"}",`cd ${Tt(e)}`,"status=$?",'if [ "$status" -ne 0 ]; the\
|
|
1767
1783
|
n',' finish_vibe64_terminal "$status" "Vibe64 could not enter the target directory."',"fi",`printf '\\033]0;%s\\007' ${Tt(
|
|
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 - ${
|
|
1772
|
-
return[{command:"wt.exe",args:["new-window","--title",n,"wsl.exe",...o]},{command:"cmd.exe",args:["/d","/c",`start ${
|
|
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 ${
|
|
1784
|
+
o)}`,_w({nodePath:t,serverArgs:r,serverPath:n}),'finish_vibe64_terminal "$?" "Vibe64 server exited."'].join(`
|
|
1785
|
+
`)}function bw(e=""){return`printf %s ${Buffer.from(String(e||""),"utf8").toString("base64")} | base64 -d | bash`}function vw({
|
|
1786
|
+
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",bw(t)]}function Sw({
|
|
1787
|
+
cwd:e=j.cwd(),env:t=j.env,shellScript:r="",title:n=`Vibe64 - ${Bl(e)}`}={}){let o=vw({distroName:t.WSL_DISTRO_NAME,shellScript:r});
|
|
1788
|
+
return[{command:"wt.exe",args:["new-window","--title",n,"wsl.exe",...o]},{command:"cmd.exe",args:["/d","/c",`start ${ki(
|
|
1789
|
+
n)} ${gw("wsl.exe",o)}`]}]}function Iw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Tn(),platform:o=j.
|
|
1790
|
+
platform,serverArgs:i=[],serverPath:s=At}={}){let a=`Vibe64 - ${Bl(e)}`,c=Ew({cwd:e,nodePath:r,serverArgs:i,serverPath:s,
|
|
1791
|
+
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${hw(
|
|
1776
1792
|
c)}`,"end tell"].join(`
|
|
1777
1793
|
`)]}];let u=[t.TERMINAL?{command:t.TERMINAL,args:["-e","bash","-lc",c]}:null,{command:"x-terminal-emulator",args:["-e","\
|
|
1778
1794
|
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 ${Tt(c)}`]},{command:"xterm",args:["-e","bash","-lc",c]}].filter(Boolean);return
|
|
1780
|
-
{env:t,osReleaseText:n,platform:o})?[...
|
|
1781
|
-
(n,o)=>{let i=
|
|
1782
|
-
cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=
|
|
1783
|
-
let a=
|
|
1795
|
+
xfce4-terminal",args:["--command",`bash -lc ${Tt(c)}`]},{command:"xterm",args:["-e","bash","-lc",c]}].filter(Boolean);return yw(
|
|
1796
|
+
{env:t,osReleaseText:n,platform:o})?[...Sw({cwd:e,env:t,shellScript:c,title:a}),...u]:u}function Tw(e,t=[],r={}){return new Promise(
|
|
1797
|
+
(n,o)=>{let i=Ul(e,t,{...r,detached:!0,stdio:"ignore"});i.once("error",o),i.once("spawn",()=>{i.unref(),n(i)})})}async function Aw({
|
|
1798
|
+
cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Tn(),platform:o=j.platform,serverArgs:i=[],serverPath:s=At}={}){
|
|
1799
|
+
let a=Iw({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),c=[];for(let u of a)try{return await Tw(
|
|
1784
1800
|
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
|
|
1801
|
+
started.")}async function Ow({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,serverArgs:n=[],serverPath:o=At}={}){let i=Ul(
|
|
1786
1802
|
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=
|
|
1803
|
+
return}s(Number(c||0))})})}function Pw(e=ar.join(Gl,"..","package.json")){try{return/^\D*(\d+)/u.exec(String(JSON.parse(
|
|
1804
|
+
mw(e,"utf8")).engines?.node||""))?.[1]||""}catch{return""}}function Rw(e=j.platform){return`https://github.com/mobily-en\
|
|
1805
|
+
terprises/vibe64/blob/main/docs/colleague-usage/${e==="darwin"?"set-up-macos":"set-up-linux"}.md`}function Nw({platform:e=j.
|
|
1806
|
+
platform,nodeVersion:t=j.versions.node,requiredMajor:r=Pw()}={}){if(e==="win32")return["Vibe64 runs on Windows inside WS\
|
|
1791
1807
|
L2 (Ubuntu), not in PowerShell or Command Prompt.","Step by step: https://github.com/mobily-enterprises/vibe64/blob/main\
|
|
1792
1808
|
/docs/colleague-usage/set-up-windows.md"].join(`
|
|
1793
1809
|
`);let n=String(t||"").split(".")[0];return r&&n!==r?[`Vibe64 needs Node.js ${r}; this is Node.js ${t}.`,`To install it \
|
|
1794
1810
|
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=
|
|
1811
|
+
en a new terminal and run npx vibe64 again:",`${Rw(e)}#nodejs-and-mise`].join(`
|
|
1812
|
+
`):""}async function Cw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=Tn(),platform:o=j.platform,serverArgs:i=j.
|
|
1813
|
+
argv.slice(2),serverPath:s=At}={}){try{return await Aw({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),
|
|
1798
1814
|
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.`),
|
|
1800
|
-
then(({runAgentSpecCli:n})=>n(j.argv.slice(3))),training:()=>Promise.resolve().then(()=>(
|
|
1801
|
-
j.argv.slice(3)))},t=
|
|
1802
|
-
n}).catch(n=>{console.error("Failed to run Vibe64:",n),j.exitCode=1})}export{
|
|
1803
|
-
Tt as quoteShellArg,
|
|
1804
|
-
|
|
1815
|
+
in this terminal instead.`),Ow({cwd:e,env:t,nodePath:r,serverArgs:i,serverPath:s})}}if(ww()){let e={spec:()=>Promise.resolve().then(()=>(ba(),Ea)).
|
|
1816
|
+
then(({runAgentSpecCli:n})=>n(j.argv.slice(3))),training:()=>Promise.resolve().then(()=>(Ai(),Dl)).then(({runTrainingCli:n})=>n(
|
|
1817
|
+
j.argv.slice(3)))},t=Nw();t&&(console.error(t),j.exit(1)),(Object.hasOwn(e,j.argv[2])?e[j.argv[2]]():Cw()).then(n=>{j.exitCode=
|
|
1818
|
+
n}).catch(n=>{console.error("Failed to run Vibe64:",n),j.exitCode=1})}export{At as SERVER_ENTRYPOINT,ww as isDirectCliExecution,yw as isWslEnvironment,Aw as launchInNewTerminal,Nw as launcherProblem,
|
|
1819
|
+
Tt as quoteShellArg,Cw as runLauncher,_w as serverShellCommand,Bl as targetNameFromCwd,Iw as terminalLaunchCandidates,Ew as terminalShellScript,
|
|
1820
|
+
vw as wslServerCommandArgs,Sw as wslTerminalLaunchCandidates};
|