vibe64 0.1.64 → 0.1.66
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 +823 -820
- package/bin/server.js +200 -197
- package/bin/upgrade-state.js +4192 -4064
- package/dist/assets/{GithubBrowserTabs-Cf6ce1lO.js → GithubBrowserTabs-Bf5z_PiF.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-0VGIcy5Q.js → LocalDatabaseServer-CcfGbn7H.js} +1 -1
- package/dist/assets/{SelectField-RGWl_ms9.js → SelectField-Df50ZFLj.js} +1 -1
- package/dist/assets/{ShellOutlet-CdjsJfg9.js → ShellOutlet-DPyl05um.js} +1 -1
- package/dist/assets/{StudioErrorNotice-CCT_T6mT.js → StudioErrorNotice-vDR4qneB.js} +1 -1
- package/dist/assets/{VAutocomplete-BnpXAJGa.js → VAutocomplete-NpBcbYkR.js} +1 -1
- package/dist/assets/VBtn-Com1gNEe.js +1 -0
- package/dist/assets/{VCard-BFqQSnAE.js → VCard-DY_DdI8Z.js} +1 -1
- package/dist/assets/{VCheckbox-BK0ss4F4.js → VCheckbox-CkezAf4Z.js} +1 -1
- package/dist/assets/{VCheckboxBtn-DDlYJnth.js → VCheckboxBtn-8g4R-c2w.js} +1 -1
- package/dist/assets/{VChip-D2IukBZw.js → VChip-tORFnf7z.js} +1 -1
- package/dist/assets/{VDialog-BCIrX462.js → VDialog-CapFiCqp.js} +1 -1
- package/dist/assets/{VExpansionPanels-BHw1Id_o.js → VExpansionPanels-B6U2XdWH.js} +1 -1
- package/dist/assets/{VMenu-Bql3E6DV.js → VMenu-CO6B6LWk.js} +1 -1
- package/dist/assets/{VOverlay-EPzW7eVB.js → VOverlay-CrfaXCOL.js} +1 -1
- package/dist/assets/{VRadioGroup-CL3HTmyT.js → VRadioGroup-BrPW6foD.js} +1 -1
- package/dist/assets/{VRow-Dz87sIhY.js → VRow-DHETsEMn.js} +1 -1
- package/dist/assets/{VSelect-Ch00dyiM.js → VSelect-gYJ6qrBP.js} +1 -1
- package/dist/assets/{VSheet-D5wAuyc2.js → VSheet-_Grtwpfz.js} +1 -1
- package/dist/assets/{VSkeletonLoader-Bl9P5wdh.js → VSkeletonLoader-CQXCEJsR.js} +1 -1
- package/dist/assets/VSpacer-VLYDmg7o.js +1 -0
- package/dist/assets/{VSwitch-DftK1EyR.js → VSwitch-ffi-Y2TU.js} +1 -1
- package/dist/assets/{VTable-DHazU0Xx.js → VTable-Cver5Vl3.js} +1 -1
- package/dist/assets/{VTextField-B9R7EIjg.js → VTextField-DP6b7Qaf.js} +1 -1
- package/dist/assets/{VTextarea-CMgyRNk-.js → VTextarea-7mdIF4I0.js} +1 -1
- package/dist/assets/{VToolbar-C8ydxLzq.js → VToolbar-CYz3lneF.js} +1 -1
- package/dist/assets/{Vibe64AsyncModuleState-9bN0_H45.js → Vibe64AsyncModuleState-CO1rMrtD.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-BGtVvQq0.js → Vibe64AuthSettingsButton-CxJoeOhz.js} +1 -1
- package/dist/assets/{Vibe64ConversationLog-Cv_BE9yH.js → Vibe64ConversationLog-jDb_ZvIF.js} +1 -1
- package/dist/assets/{Vibe64DashboardPageHeader-xfRLZ94G.js → Vibe64DashboardPageHeader-CobvMlFm.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-B3TN3NBS.js → Vibe64DashboardShell-Ce1PNB37.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-CU0jCfP_.js → Vibe64DatabaseWorkspace-DiZDKEpx.js} +1 -1
- package/dist/assets/{Vibe64DestinationButton-CdyyK9tj.js → Vibe64DestinationButton-B4Zz4a7J.js} +1 -1
- package/dist/assets/{Vibe64FileArea-BWl-q11N.js → Vibe64FileArea-uRnIJ0Vp.js} +1 -1
- package/dist/assets/{Vibe64OutputControls-DnfGKZHs.js → Vibe64OutputControls-BF5kh2_h.js} +1 -1
- package/dist/assets/{Vibe64RepositoryWorkspace-3UKN_pPs.js → Vibe64RepositoryWorkspace-D6uJCype.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-B1U6XSWQ.js → Vibe64SessionFiles-CxgPB8RR.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-De1QyTOd.js → Vibe64SessionSourceEditor-yaVu279S.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-JRGcklim.js → Vibe64UiStoryboardView-DhbHkz8K.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-Bd_-gPuL.js → Vibe64UnavailableSessions-MmPF-Db1.js} +1 -1
- package/dist/assets/{_pageId_-DIPouI7Z.js → _pageId_-Zif-veil.js} +1 -1
- package/dist/assets/{_sessionId_-qH7uIGNl.js → _sessionId_-DOge-7SB.js} +1 -1
- package/dist/assets/_slug_-C71iAiR0.js +14 -0
- package/dist/assets/_slug_-CF1TPDUv.css +1 -0
- package/dist/assets/{access-O4hOM9ov.js → access-DQcblrWN.js} +1 -1
- package/dist/assets/{app-CXljwZ0u.js → app-CzApKPmq.js} +1 -1
- package/dist/assets/assistantRouting-CqIiQy21.js +3 -0
- package/dist/assets/{changes-C5gleyWS.js → changes-cmlEyHug.js} +1 -1
- package/dist/assets/{client-DMEf6RSZ.js → client-13v_yX07.js} +1 -1
- package/dist/assets/{client-CI-o7ITq.js → client-5JUUGxRd.js} +2 -2
- package/dist/assets/{client-4uCr4dYG.js → client-BJBzomgt.js} +1 -1
- package/dist/assets/{client-Do8szX_w.js → client-C8ZjqGdQ.js} +2 -2
- package/dist/assets/{client-fF-hq8nJ.js → client-Dl6I6IVb.js} +1 -1
- package/dist/assets/{client-BRcncaFt.js → client-Dv4scw6i.js} +1 -1
- package/dist/assets/{conversation-DiL2PEct.js → conversation-CFJRkeTj.js} +3 -3
- package/dist/assets/{conversation-RscSzQxq.css → conversation-COcuIkcD.css} +1 -1
- package/dist/assets/conversation-CexAK3Qk.js +1 -0
- package/dist/assets/{dashboard-BWlG0Nli.js → dashboard-Dm_xwwqU.js} +1 -1
- package/dist/assets/{english-definitions-DcuZfQ4p.js → english-definitions-DwTf_alg.js} +1 -1
- package/dist/assets/{env-D3DVC-Gd.js → env-B7wB5nBn.js} +1 -1
- package/dist/assets/{error-BQ7r64JO.js → error-CtOws2EC.js} +1 -1
- package/dist/assets/{error-BqMxhgpB.js → error-HfzrYwkQ.js} +1 -1
- package/dist/assets/errorMessageHelpers-G32Hjqfm.js +1 -0
- package/dist/assets/{fileTypes-2k5HCkMT.js → fileTypes-iPZyrJA1.js} +1 -1
- package/dist/assets/{health-B9ZoQC78.js → health-DIkOkzPe.js} +1 -1
- package/dist/assets/{history-BrWT8DRp.js → history-Ch597NiY.js} +1 -1
- package/dist/assets/{httpClient-Bwitq9Xf.js → httpClient-C71X5grL.js} +1 -1
- package/dist/assets/{i18n-BuXRXGaO.js → i18n-5EHeMSvt.js} +1 -1
- package/dist/assets/{i18n-BkxO7BMl.js → i18n-BSfPKqM3.js} +1 -1
- package/dist/assets/{i18n-Dm74yE_M.js → i18n-DcNQE3tT.js} +1 -1
- package/dist/assets/index-C-6c5Af1.css +1 -0
- package/dist/assets/index-DcKFCaBZ.js +134 -0
- package/dist/assets/{integrations-C4p_QTuv.js → integrations-CoNhnGvq.js} +1 -1
- package/dist/assets/{issues-KxOOLtSM.js → issues-Cem4Yt47.js} +1 -1
- package/dist/assets/{layout-B_cpKP4k.js → layout-DMZV-nbg.js} +1 -1
- package/dist/assets/{lazy-vXRXMwYF.js → lazy-mtFmsnct.js} +1 -1
- package/dist/assets/{learning-BWqH7wag.js → learning-CU2QyHrj.js} +1 -1
- package/dist/assets/{pages-DcNh-g_z.js → pages-BzA58NoR.js} +1 -1
- package/dist/assets/{project-files-C3a_vnA4.js → project-files-BBKjl3wZ.js} +1 -1
- package/dist/assets/{publish-B1f2baHh.js → publish-UFjblZA3.js} +1 -1
- package/dist/assets/{pull-requests-BHq5Yafl.js → pull-requests-DibGk1GB.js} +1 -1
- package/dist/assets/{repository-DMBew8kp.js → repository-0EKOcyTL.js} +1 -1
- package/dist/assets/{session-B5MoHBVk.js → session-FRkCCzYt.js} +1 -1
- package/dist/assets/{settings-DDpgGhWO.js → settings-BjOnPYwD.js} +1 -1
- package/dist/assets/{studioGateApi-UqmdV50W.js → studioGateApi-B9EUTtMx.js} +1 -1
- package/dist/assets/{studioUrls-k_pQIuPs.js → studioUrls-BR4ZL-TN.js} +1 -1
- package/dist/assets/{useArchivedVibe64Sessions-C5Qguyob.js → useArchivedVibe64Sessions-CXKRFR2f.js} +1 -1
- package/dist/assets/useAssistantAttachments-C9kAnWqw.js +2 -0
- package/dist/assets/useCommand-yOr3U8KF.js +1 -0
- package/dist/assets/useEndpointResource-BwGXpV2u.js +1 -0
- package/dist/assets/useUiFeedback--0dLsslR.js +1 -0
- package/dist/assets/{useVibe64ConversationLog-BZ5g9Jp7.js → useVibe64ConversationLog-BB5tVtkt.js} +2 -2
- package/dist/assets/{useVibe64Learning-DiLAIKbI.js → useVibe64Learning-iAAH83uG.js} +1 -1
- package/dist/assets/{useVibe64SessionData-D9d4NfDo.js → useVibe64SessionData-BSYF_TgH.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-DT1rJVvx.js → useVibe64SessionSelection-CxZ3uEAf.js} +1 -1
- package/dist/assets/{vibe64FileUpload-BDkcaUyk.js → vibe64FileUpload-D_rOa1R8.js} +1 -1
- package/dist/assets/vibe64RepositoryRealtime-CRAyGyRD.css +1 -0
- package/dist/assets/vibe64RepositoryRealtime-CVGNqwxz.js +1 -0
- package/dist/assets/{vibe64SessionFocus-CLtCTOxq.js → vibe64SessionFocus-DGSVXipO.js} +1 -1
- package/dist/index.html +45 -45
- package/docs/colleague-usage/ai-tasks.md +9 -1
- package/docs/colleague-usage/auto-workflow.md +6 -3
- package/docs/colleague-usage/coding-agent-goal-pause.md +34 -12
- package/docs/colleague-usage/coding-agent-goals.md +46 -23
- package/docs/colleague-usage/coding-agent-questions.md +7 -0
- package/docs/colleague-usage/coding-agents.md +22 -8
- package/docs/colleague-usage/connected-repositories.md +4 -1
- package/docs/colleague-usage/github-work.md +36 -3
- package/docs/colleague-usage/passes.md +86 -0
- package/docs/colleague-usage/project-messages.md +4 -1
- package/docs/colleague-usage/ui-pass.md +4 -0
- package/docs/colleague-usage/workspace-preparation.md +51 -0
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +13 -0
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +7 -4
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +2 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/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 +6 -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/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-core/package.json +1 -0
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +914 -773
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +69 -63
- package/node_modules/@local/vibe64-genesis/src/server/index.js +450 -440
- package/node_modules/@local/vibe64-genesis/src/server/packaging.js +27 -28
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +63 -55
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +1044 -901
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +560 -420
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +453 -450
- package/package.json +15 -15
- package/server.bundle.mjs +43357 -43007
- package/dist/assets/VBtn-2vbH580C.js +0 -1
- package/dist/assets/VSpacer-GgPR_AzN.js +0 -1
- package/dist/assets/_slug_-CZmGS16g.css +0 -1
- package/dist/assets/_slug_-CaHlSQ8I.js +0 -14
- package/dist/assets/assistantRouting-BS0ZW5Ki.js +0 -3
- package/dist/assets/conversation-D7T_us2O.js +0 -1
- package/dist/assets/errorMessageHelpers-BjIt31kK.js +0 -1
- package/dist/assets/index-Ctygjyf8.css +0 -1
- package/dist/assets/index-HrVsvggI.js +0 -134
- package/dist/assets/useAssistantAttachments-DvEl7gX6.js +0 -2
- package/dist/assets/useCommand-CNDe8gM-.js +0 -1
- package/dist/assets/useEndpointResource-CmMwteuX.js +0 -1
- package/dist/assets/useUiFeedback-CWb6o71Z.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-kSshUn2K.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-rnWlv9jw.css +0 -1
package/bin/run.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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,Li=e=>()=>
|
|
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
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:Li("application-payments-laravel.md")}])});var Ot,
|
|
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 re(e,{fallback:t={}}={}){return B(e)?e:{...t}}function B(e){
|
|
8
|
+
return!!(e&&typeof e=="object"&&!Array.isArray(e))}var Gw,G=g(()=>{Gw=Object.freeze(["none","pending","committed","rolle\
|
|
9
|
+
dBack","unknown"])});function dr(e){return B(e)?{...e}:{}}var On=g(()=>{G()});var ae,pr=g(()=>{On();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
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
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
|
|
14
|
+
var tt=g(()=>{});function Pn(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(
|
|
16
|
+
let{items:r}=t;if(Pn(r))return{kind:"schema",schema:r};if(!Y(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
17
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(
|
|
18
|
+
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(Pn(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(!
|
|
24
|
+
s: true.`);if(r){if(!Pn(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
|
|
25
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
|
|
26
|
+
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}var Rn=g(()=>{tt()});function rt(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}function Nn(e,t=""){
|
|
27
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
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
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"&&
|
|
30
|
+
) is above its maxItems (${n.maxItems}).`);n.type==="array"&&Y(n.items)&&typeof n.items.type=="string"&&Nn({"[]":n.items},
|
|
31
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
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;
|
|
33
33
|
if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(`temporalPrecision for "${t}" must be a non-negative integer\
|
|
@@ -35,22 +35,22 @@ if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(`temporalPrecision f
|
|
|
35
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
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
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
|
|
38
|
+
return`^${gr}(?::${nt}${ts(r)})?$`}function ns(e,t){let r=Rt(e,t);return`^${Yi}T${gr}:${nt}${ts(r)}${qi}$`}function kn(e,t){
|
|
39
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
|
|
40
|
+
r)||r<-t||r>t?null:r===0?0:r}var Cn,Bi,Hi,zi,Fi,nt,gr,qi,Wi,Yi,Ji,td,rd,nd,od,id,xn=g(()=>{Cn="^(?:0|-?[1-9]\\d*)$",Bi="\
|
|
41
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
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(
|
|
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
|
|
45
|
-
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function
|
|
46
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
47
|
-
let o=r?
|
|
43
|
+
new RegExp(`^${gr}(?::${nt}(?:\\.(\\d+))?)?$`),nd=new RegExp(`^${Wi}T${gr}:${nt}(?:\\.(\\d+))?${qi}$`),od=new RegExp(Cn),
|
|
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 $n(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 \
|
|
48
48
|
dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${t}() received an invalid path "${o}".`);
|
|
49
|
-
for(let s of i)
|
|
50
|
-
[Te]:{[e]:t}}}function
|
|
51
|
-
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:Cn}]}}function Me(e,t){return{
|
|
50
|
+
[Te]:{[e]:t}}}function Vn(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)){Vn(o,n);continue}e[r]=n}}function gd(e,t){if(!t||typeof t!="object"||Array.
|
|
52
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===
|
|
53
|
-
Te&&e[r]&&typeof e[r]=="object"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){
|
|
53
|
+
Te&&e[r]&&typeof e[r]=="object"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){Vn(e[r],t[r]);continue}
|
|
54
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
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
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(
|
|
@@ -64,44 +64,44 @@ s: mode '${r}' does not match operation '${t.operation}'.`)}if(t.operation!==voi
|
|
|
64
64
|
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return is(t.mode)}function bd(e,t={}){
|
|
65
65
|
if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
|
|
66
66
|
let r=Ed(e,t);return{operationName:r,operation:e.operations[r]}}function vd(e={}){let t={...e};return Object.defineProperty(
|
|
67
|
-
t,
|
|
68
|
-
e[
|
|
69
|
-
"_").replace(/^_+|_+$/g,"")||"operation"}function
|
|
70
|
-
function wr(e){return
|
|
67
|
+
t,Ln,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function yr(e={}){return e[Ln]?
|
|
68
|
+
e[Ln]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function Sd(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
|
|
69
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function Mn(e){return Y(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
|
|
70
|
+
function wr(e){return Mn(e)?{allOf:[e]}:e}function Id(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
|
|
71
71
|
r&&i.operation===n&&i.additionalProperties===o)||null}function Td(e,t){let r=Sd(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
72
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=
|
|
73
73
|
"#",s.rootNode=a),a;let c={schema:e,operationName:r,operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
74
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
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
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
|
|
77
|
+
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function Gn(e,t,r,n,o=!1){
|
|
78
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,
|
|
80
|
-
n)),n.enforceRequired&&
|
|
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(
|
|
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,Bn(e,c,u,t,r,
|
|
80
|
+
n)),n.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
|
|
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(Gn(s.schema,
|
|
82
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
|
|
84
|
-
let s=Pt(t,r);if(!s)return null;if(s.kind==="schema")return{...wr(
|
|
83
|
+
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return Bn(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(Gn(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
85
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
|
|
87
|
-
t,r);if(a.kind==="nested")return Ct(
|
|
86
|
+
place"?e.operations.replace:i;return Bn(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(Gn(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
88
88
|
"opaque")return Ct({type:"object",additionalProperties:!0});if(a.kind==="map")return Ct({type:"object",additionalProperties:Pd(
|
|
89
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"||
|
|
90
90
|
Array.isArray(s))throw new Error(`Type '${r.type}' on field '${t}' returned an invalid JSON Schema fragment.`);if(r.type===
|
|
91
|
-
"array"){let a=Od(e,t,r,n,o,i);if(a)return Ct({...s,items:a},{referenceBacked:
|
|
92
|
-
function
|
|
93
|
-
wr(a.schema):{...a.schema},
|
|
94
|
-
continue;let
|
|
95
|
-
c[Te]&&(
|
|
96
|
-
let m=wr(wd(c,
|
|
91
|
+
"array"){let a=Od(e,t,r,n,o,i);if(a)return Ct({...s,items:a},{referenceBacked:Mn(s)})}return Ct(s,{referenceBacked:Mn(s)})}
|
|
92
|
+
function Bn(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 h of Object.keys(r)){if(h==="type"||!Object.hasOwn(e.validators,h))
|
|
94
|
+
continue;let f=_d(e,h,t);if(!f)continue;let w=f({...s,parameterName:h,parameterValue:r[h],fieldSchema:{...c}});w&&gd(c,w)}
|
|
95
|
+
c[Te]&&(Vn(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 h=e._normalizeDefault(
|
|
97
97
|
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
98
|
-
o,i,{})});if(Object.keys(
|
|
99
|
-
nvalid (${
|
|
98
|
+
o,i,{})});if(Object.keys(h.errors).length>0){let f=Object.values(h.errors)[0];throw new Error(`defaultTo for "${t}" is i\
|
|
99
|
+
nvalid (${f.code}).`)}m.default=h.value}else u.defaults={providedByFunction:!0};return m[Te]=u,m}function cs(e,t={}){let r=vd(
|
|
100
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
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
|
|
103
|
-
ema"
|
|
104
|
-
"y","on"],md=["false","0","no","n","off"];fd={none:()=>({type
|
|
102
|
+
Te,jn,Ln,pd,md,fd,hd,us=g(()=>{Rn();hr();xn();tt();Nt();dd="http://json-schema.org/draft-07/schema#",Te="x-json-rest-sch\
|
|
103
|
+
ema",jn=["object","array","string","number","boolean"],Ln=Symbol("json-rest-schema.exportContext"),pd=["true","1","yes",
|
|
104
|
+
"y","on"],md=["false","0","no","n","off"];fd={none:()=>({type:jn}),blob:()=>({type:jn}),serialize:()=>({type:jn}),object:()=>({
|
|
105
105
|
type:"object"}),array:()=>({type:"array"}),file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["n\
|
|
106
106
|
umber","string"]}),integer:()=>({type:["integer","string"]}),epochMilliseconds:()=>os(864e13),epochSeconds:()=>os(864e10),
|
|
107
107
|
dateTime:({definition:e,fieldName:t})=>({type:"string",format:"date-time",pattern:ns(e,t)}),date:()=>({type:"string",format:"\
|
|
@@ -118,11 +118,11 @@ t.type==="array"?null:{minLength:1},uppercase:({parameterValue:e})=>e?Me("transf
|
|
|
118
118
|
Me("transforms",{lowercase:!0}):null,length:({parameterValue:e})=>Me("transforms",{length:e}),unsigned:({parameterValue:e})=>e?
|
|
119
119
|
Me("metadata",{unsigned:!0}):null,precision:({parameterValue:e})=>Me("metadata",{precision:e}),scale:({parameterValue:e})=>Me(
|
|
120
120
|
"metadata",{scale:e}),temporalPrecision:({parameterValue:e})=>Me("metadata",{temporalPrecision:e}),strictBoolean:()=>null,
|
|
121
|
-
required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null}});function
|
|
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 Yn(e){return e instanceof
|
|
122
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
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
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
|
|
125
|
+
{...n,field:o})}return r}function qn(e){return $n(e,"validatePath")}function ms(e){let t={};for(let r of e){let n=qn(r),
|
|
126
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
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
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].
|
|
@@ -130,33 +130,33 @@ sort((t,r)=>{let n=/^[0-9]+$/.test(t),o=/^[0-9]+$/.test(r);return n&&o?Number(t)
|
|
|
130
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.
|
|
131
131
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
132
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(
|
|
133
|
+
"object")return e;if(Yn(e))return xd(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
134
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);
|
|
135
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)||
|
|
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
|
|
138
|
-
return br(Er(e))}function
|
|
136
|
+
o,t));return r}function br(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||Yn(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 Hn(e){
|
|
138
|
+
return br(Er(e))}function Wn(e,t,r=""){if(!Yn(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;if(!Object.hasOwn(
|
|
139
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:
|
|
140
|
+
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:Wn(o.schema,r,n)}if(t?.type===
|
|
141
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:
|
|
142
|
+
n,i);return o.kind==="schema"?s.length<1?null:Wn(o.schema,s,a):s.length<1?o.definition:ys(e,o.definition,s,a)}return null}
|
|
143
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
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
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
|
|
146
|
+
let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(", ")}.`)}function Fn(e,t,r,n=!0){
|
|
147
147
|
let o=t[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${e}" must define ${r} as a boolean.`)}
|
|
148
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"]),
|
|
150
|
-
["validated","input"]),
|
|
149
|
+
return hs(e,t,"targetFields",["schema","input"]),Fn(e,t,"enforceRequired"),Fn(e,t,"applyDefaults"),hs(e,t,"outputFields",
|
|
150
|
+
["validated","input"]),Fn(e,t,"rejectExplicitUndefined",!1),Object.freeze({targetFields:t.targetFields,enforceRequired:t.
|
|
151
151
|
enforceRequired,applyDefaults:t.applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.rejectExplicitUndefined===
|
|
152
152
|
void 0?!0:t.rejectExplicitUndefined})}function Ld(e={}){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(
|
|
153
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
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
|
|
156
|
-
()=>{
|
|
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 zn,$d,st,_s=g(
|
|
156
|
+
()=>{us();Rn();Nt();tt();hr();zn=new WeakMap;$d=Object.freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
157
157
|
applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),replace:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
158
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={}){
|
|
159
|
+
applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});st=class{constructor(t,r,n,o={}){Nn(t),this.structure=
|
|
160
160
|
t,this.types=gs(r),this.validators=gs(n),this.operations=Ld(o),this._installOperationMethods()}_typeError(t){return this.
|
|
161
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
162
|
n);return i.errorObject={field:t,code:r,message:n,params:o},i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?
|
|
@@ -177,113 +177,113 @@ let o={};for(let i of n.outputFieldNames){if(!Object.hasOwn(this.structure,i))co
|
|
|
177
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
178
|
return fr(t,r)}_resolveArrayItemsConfig(t,r){return mr(t,r)}_resolveObjectValuesConfig(t,r){return Pt(t,r)}_buildArrayItemSettings(t,r){
|
|
179
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){
|
|
180
|
-
let
|
|
181
|
-
`No casting function for type: ${t.type}`);let m=this.types[t.type];if(r===null)return
|
|
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(
|
|
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}):
|
|
182
182
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
183
|
-
if(r===""&&
|
|
183
|
+
if(r===""&&l)return P(o,i,null),{errors:{},shouldContinue:!1};let h={schema:this,definition:t,value:r,fieldName:n,object:o,
|
|
184
184
|
objectBeforeCast:s,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
185
|
-
nullable:l
|
|
186
|
-
n,
|
|
187
|
-
i,
|
|
188
|
-
errors:{},context:
|
|
185
|
+
nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(f,w,I)=>{throw this._paramError(
|
|
186
|
+
n,f,w,I)}};try{let f=m(h);if(ls(f))throw new Error(`Type handler for "${t.type}" must be synchronous.`);f!==void 0&&(P(o,
|
|
187
|
+
i,f),h.value=f)}catch(f){if(f.errorObject)return{errors:this._singleErrorMap(f.errorObject),shouldContinue:!1};throw f}return{
|
|
188
|
+
errors:{},context:h,shouldContinue:!0}}_runFieldValidators(t,r,n,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
|
|
189
189
|
_paramToBeSkipped(a,s.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{i.parameterName=
|
|
190
|
-
a,i.parameterValue=t[a];let
|
|
191
|
-
(P(n,o,
|
|
192
|
-
let
|
|
193
|
-
context:
|
|
194
|
-
t,n,o,i,
|
|
195
|
-
let
|
|
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){
|
|
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{
|
|
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(
|
|
194
|
+
t,n,o,i,l,a))}_normalizeDefault(t,r,{fieldPath:n,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
|
|
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){
|
|
196
196
|
if(t.type==="object"){let c=this._resolveObjectFieldMode(r,t);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
197
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.
|
|
198
198
|
_resolveArrayItemsConfig(r,t);return a?this._validateArrayItems(r,n,o,a,i,s):{}}_validateNestedObjectSchema(t,r,n,o,i,s){
|
|
199
|
-
let a=n[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,
|
|
199
|
+
let a=n[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,u=t.schema._validateWithOperation(
|
|
200
200
|
s.operationName,s.operation,c,it(i,r));return P(n,o,t.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
201
|
-
a,t.schema,
|
|
201
|
+
a,t.schema,u.validatedObject):u.validatedObject),ot(u.errors,r)}_extractKnownObjectFields(t,r){let n={};for(let[o,i]of Object.
|
|
202
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
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},
|
|
205
|
-
keys(a)){let m=De(t,
|
|
206
|
-
_mergeErrors(
|
|
207
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,
|
|
208
|
-
|
|
209
|
-
definition,s));this._mergeErrors(
|
|
210
|
-
c.length;
|
|
211
|
-
this._mergeErrors(
|
|
212
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[
|
|
213
|
-
|
|
214
|
-
o.definition,s));this._mergeErrors(
|
|
215
|
-
let s=this.structure[t];if(this._fieldToBeSkipped(t,o))return{};let a=i.isFieldPresent(t),c=r[t],
|
|
216
|
-
s.required&&(!a||
|
|
217
|
-
Field is required",params:{}}):a?
|
|
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.
|
|
205
|
+
keys(a)){let m=De(t,l);if(this._fieldToBeSkipped(m,i))continue;let h=c[l];if(h===void 0){s.rejectExplicitUndefined?this.
|
|
206
|
+
_mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let w=o.
|
|
207
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,h,it(i,m));P(c,l,w.validatedObject),this._mergeErrors(
|
|
208
|
+
u,ot(w.errors,m));continue}let f=this._normalizeAndValidateValue(o.definition,h,m,c,l,a,i,this._buildArrayItemSettings(o.
|
|
209
|
+
definition,s));this._mergeErrors(u,f)}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<
|
|
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?
|
|
211
|
+
this._mergeErrors(u,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let f=o.
|
|
212
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],it(i,m));P(c,l,f.validatedObject),this._mergeErrors(
|
|
213
|
+
u,ot(f.errors,m));continue}let h=this._normalizeAndValidateValue(o.definition,c[l],m,c,l,a,i,this._buildArrayItemSettings(
|
|
214
|
+
o.definition,s));this._mergeErrors(u,h)}return u}_validateField(t,r,n,o,i){if(!Object.hasOwn(this.structure,t))return{};
|
|
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&&
|
|
216
|
+
s.required&&(!a||u)&&!this._paramToBeSkipped("required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"\
|
|
217
|
+
Field is required",params:{}}):a?u?i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(t).errorObject):{}:this.
|
|
218
218
|
_normalizeAndValidateValue(s,c,t,n,t,r,o,i):{}}_validateWithOperation(t,r,n,o){this._assertSupportedOptions(o);let i={},
|
|
219
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,
|
|
220
|
-
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let
|
|
221
|
-
c,n,s,o,a);this._mergeErrors(i,
|
|
222
|
-
this.structure[c].defaultTo!==void 0){let
|
|
223
|
-
m=this._normalizeDefault(l,
|
|
220
|
+
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let u=this._validateField(
|
|
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)&&
|
|
222
|
+
this.structure[c].defaultTo!==void 0){let u=this.structure[c],l=typeof u.defaultTo=="function"?u.defaultTo():u.defaultTo,
|
|
223
|
+
m=this._normalizeDefault(u,l,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
224
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
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
|
|
227
|
-
c,t[c],r,a,n,o,
|
|
228
|
-
hasOwn(this.structure,t))return{};let c=this.structure[t],
|
|
229
|
-
let m=Object.hasOwn(n,t),
|
|
230
|
-
a)&&this._mergeErrors(
|
|
226
|
+
let u=ws(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${u}".`);let l=this._validateSelectedField(
|
|
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.
|
|
228
|
+
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,l=ds(r);if(this._fieldToBeSkipped(a,i))return{};
|
|
229
|
+
let m=Object.hasOwn(n,t),h=n[t],f={};if(!m){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("required",i.skipParams,
|
|
230
|
+
a)&&this._mergeErrors(f,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),u&&s.applyDefaults&&
|
|
231
231
|
c.defaultTo!==void 0){let d=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,p=this._normalizeDefault(c,d,{fieldPath:a,
|
|
232
|
-
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(
|
|
233
|
-
length===0&&P(o,t,p.value)}return
|
|
234
|
-
a).errorObject):{};let w={[t]:
|
|
235
|
-
w[t]!==void 0?P(o,t,w[t]):w[t]===null&&P(o,t,null),d}if(!
|
|
232
|
+
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(f,p.errors),Object.keys(p.errors).
|
|
233
|
+
length===0&&P(o,t,p.value)}return f}if(h===void 0)return u&&s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
234
|
+
a).errorObject):{};let w={[t]:h};if(u){let d=this._normalizeAndValidateValue(c,h,a,w,t,n,i,s);return Object.hasOwn(w,t)&&
|
|
235
|
+
w[t]!==void 0?P(o,t,w[t]):w[t]===null&&P(o,t,null),d}if(!l)return{};let I=this._castValue(c,h,a,w,t,n,i,s);if(Object.keys(
|
|
236
236
|
I.errors).length>0)return I.errors;if(!I.shouldContinue)return{};let S=this._validateSelectedDescendants(c,r.children,a,
|
|
237
237
|
w,t,i,s);return _r(w[t])&&P(o,t,w[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
|
|
239
|
-
|
|
240
|
-
ot(
|
|
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\
|
|
241
241
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,i,c,r,s,a)}throw new Error(
|
|
242
|
-
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],
|
|
243
|
-
|
|
244
|
-
id because array segments must use numeric indexes.`);let
|
|
245
|
-
|
|
246
|
-
if(d===void 0){I&&a.rejectExplicitUndefined&&P(
|
|
247
|
-
let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,d,it(s,
|
|
248
|
-
this._mergeErrors(
|
|
249
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});_r(y.validatedObject)&&P(c,
|
|
250
|
-
this._mergeErrors(
|
|
251
|
-
o.definition,d,
|
|
252
|
-
continue}if(!S)continue;let b=this._castValue(o.definition,d,
|
|
253
|
-
|
|
254
|
-
s,p);_r(_[0])&&P(c,
|
|
242
|
+
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],u=r[n],
|
|
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 h=Number(m),f=De(t,h),w=i[m],I=w.self===!0,S=ds(w);if(this._fieldToBeSkipped(
|
|
245
|
+
f,s))continue;if(!Object.hasOwn(u,h)){I&&a.rejectExplicitUndefined&&P(l,f,this._typeError(f).errorObject);continue}let d=u[h];
|
|
246
|
+
if(d===void 0){I&&a.rejectExplicitUndefined&&P(l,f,this._typeError(f).errorObject);continue}if(o.kind==="schema"){if(I){
|
|
247
|
+
let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,d,it(s,f));_r(E.validatedObject)&&P(c,h,E.validatedObject),
|
|
248
|
+
this._mergeErrors(l,ot(E.errors,f));continue}if(!S)continue;let y=o.schema._validateSelectedTree(w.children,d,it(s,f),{...a,
|
|
249
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});_r(y.validatedObject)&&P(c,h,y.validatedObject),
|
|
250
|
+
this._mergeErrors(l,ot(y.errors,f));continue}let p=this._buildArrayItemSettings(o.definition,a),_=[d];if(I){let y=this._normalizeAndValidateValue(
|
|
251
|
+
o.definition,d,f,_,0,u,s,p);Object.hasOwn(_,0)&&_[0]!==void 0?P(c,h,_[0]):_[0]===null&&P(c,h,null),this._mergeErrors(l,y);
|
|
252
|
+
continue}if(!S)continue;let b=this._castValue(o.definition,d,f,_,0,u,s,p);if(Object.keys(b.errors).length>0){this._mergeErrors(
|
|
253
|
+
l,b.errors);continue}if(!b.shouldContinue)continue;let v=this._validateSelectedDescendants(o.definition,w.children,f,_,0,
|
|
254
|
+
s,p);_r(_[0])&&P(c,h,_[0]),this._mergeErrors(l,v)}return l}validateWith(t,r,n={}){if(!Object.hasOwn(this.operations,t))throw new Error(
|
|
255
255
|
`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(t,r),this._validateWithOperation(
|
|
256
|
-
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=
|
|
256
|
+
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=qn(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
257
257
|
_resolvePathValidationRequest(n),c=this._validateSelectedTree(ms([t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:Cd(
|
|
258
258
|
c.validatedObject,o),errors:c.errors}}validatePaths(t,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
259
259
|
isArray(t)||t.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
260
260
|
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(ms(t),r,s,this.
|
|
261
261
|
_buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.keys(this.operations)){if(t in this)throw new Error(
|
|
262
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={}){
|
|
263
|
-
return cs(this,t)}getFieldDefinitions(){return
|
|
264
|
-
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=
|
|
265
|
-
return r===null?null:
|
|
266
|
-
messages===null?Object.freeze({}):
|
|
267
|
-
o)&&this.structure[o][r]&&P(n,o,t[o]);return n}}});var
|
|
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?(
|
|
269
|
-
-1<t.indexOf(
|
|
270
|
-
|
|
271
|
-
null)return
|
|
263
|
+
return cs(this,t)}getFieldDefinitions(){return zn.has(this)||zn.set(this,Hn(this.structure)),zn.get(this)}getFieldDefinition(t){
|
|
264
|
+
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=Wn(this,qn(t.trim()));
|
|
265
|
+
return r===null?null:Hn(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
266
|
+
messages===null?Object.freeze({}):Hn(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 gy,Dd,wy,Ud,Vd,Es,Gd,bs,vs,Ss=g(()=>{({parse:gy,stringify:Dd}=JSON),{keys:wy}=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 h=n.call(this,l,m);switch(typeof h){case Es:if(h===
|
|
271
|
+
null)return h;case Vd:return o.get(h)||bs(o,i,h)}return h}}});function Fd(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Is(e){if(typeof e==
|
|
272
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==
|
|
273
|
-
"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 Jn(e,t){
|
|
274
274
|
if(Object.is(e,t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&
|
|
275
275
|
t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(
|
|
276
|
-
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(!Jn(e[o],t[o]))return!1;return!0}if(e===
|
|
277
277
|
null||t===null||typeof e!="object"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=Object.
|
|
278
|
-
keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!
|
|
279
|
-
return!0}var Hd,zd,qd,Ts,As=g(()=>{Ss();hr();
|
|
278
|
+
keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!Jn(e[o],t[o]))return!1;
|
|
279
|
+
return!0}var Hd,zd,qd,Ts,As=g(()=>{Ss();hr();xn();tt();Hd=new Set(["true","1","yes","y","on"]),zd=new Set(["false","0","\
|
|
280
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&&
|
|
281
281
|
n.throwTypeError();let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?
|
|
282
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\
|
|
283
283
|
mber"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),
|
|
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=
|
|
286
|
-
o}),t("epochSeconds",n=>{let o=
|
|
285
|
+
!Number.isInteger(o))&&n.throwTypeError(),o}),t("epochMilliseconds",n=>{let o=kn(n.value,864e13);return o===null&&n.throwTypeError(),
|
|
286
|
+
o}),t("epochSeconds",n=>{let o=kn(n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=Rt(n.definition,
|
|
287
287
|
n.fieldName);return es(n.value,o)||n.throwTypeError(),n.value}),t("date",n=>(Qi(n.value)||n.throwTypeError(),n.value)),t(
|
|
288
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
289
|
type==="array"&&!Array.isArray(n.value)?[n.value]:n.value),t("object",n=>(Y(n.value)||n.throwTypeError(),n.value)),t("se\
|
|
@@ -304,7 +304,7 @@ void 0&&n.definition.type==="string"&&n.value.toString&&n.value.toString().lengt
|
|
|
304
304
|
AX_LENGTH",`Length must be no more than ${n.parameterValue} characters.`,{max:n.parameterValue,actual:n.value.toString().
|
|
305
305
|
length})}),r("max",n=>{n.value!==void 0&&rt(n.definition)&&typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError(
|
|
306
306
|
"MAX_VALUE",`Value must be no more than ${n.parameterValue}.`,{max:n.parameterValue,actual:n.value})}),r("enum",n=>{if(!Array.
|
|
307
|
-
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=>Jn(i,n.value))||
|
|
308
308
|
n.throwParamError("ENUM_VALUE","Value must match one of the allowed enum values.",{allowed:n.parameterValue})}),r("patte\
|
|
309
309
|
rn",n=>{if(n.value===void 0||n.definition.type!=="string"||typeof n.value!="string")return;let o=n.parameterValue,i=o instanceof
|
|
310
310
|
RegExp?new RegExp(o.source,o.flags):typeof o=="string"?new RegExp(o):null;if(!i)throw new Error(`Pattern for ${n.fieldName}\
|
|
@@ -344,8 +344,8 @@ e),o=Sr(t),i=(s,a={})=>{let c=new st(s,n,o,a.operations);return Rs(c,n,o),c};ret
|
|
|
344
344
|
i.addValidator=(s,a)=>{Yd(o,s,a)},i.use=s=>{Ps(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
|
|
345
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
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
|
|
348
|
-
`${t} must match ${Ms.toString()}.`);return r}function
|
|
347
|
+
new WeakMap,ks=new WeakMap,xs=Symbol.for("json-rest-schema.registry-metadata"),vr=new WeakSet;$=$s({installCore:!0})});var Dy,js=g(()=>{Ue();G();Dy=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 Ir(e,t){if(e==null)return Object.freeze({});if(!B(e))throw new TypeError(
|
|
349
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(
|
|
350
350
|
o||"").trim();if(!Zd.test(s))throw new TypeError(`${t} local name "${s}" must be a JavaScript identifier.`);let a=Xn(i,`${t}\
|
|
351
351
|
.${s}`);if(n.has(a))throw new TypeError(`${t} declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.
|
|
@@ -355,105 +355,108 @@ e)){let a=Xn(i,`${r}.hints key`);if(!n.has(a))throw new TypeError(`${r}.hints na
|
|
|
355
355
|
require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${r}.hints["${a}"] must be the text that says what to r\
|
|
356
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.
|
|
357
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,
|
|
358
|
-
r)}}function
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
u))
|
|
367
|
-
|
|
368
|
-
|
|
358
|
+
r)}}function np(e,t,r){for(let n of Object.values(t))for(let[o,i]of Object.entries(r))if(Object.values(i).includes(n))throw new TypeError(
|
|
359
|
+
o==="provides"?`Provider "${e}" cannot late-require capability "${n}" that it provides.`:`Provider "${e}" names capabili\
|
|
360
|
+
ty "${n}" under both late and ${o}.`)}function Kn(e,t){if(e==null)return null;if(typeof e!="function")throw new TypeError(
|
|
361
|
+
`${t} must be a function when provided.`);return e}function Tr({id:e,requires:t={},optional:r={},late:n={},provides:o={},
|
|
362
|
+
hints:i={},setup:s,boot:a=null,shutdown:c=null}={}){let u=Xn(e,"Provider id"),l=Ir(t,`${u}.requires`),m=Ir(r,`${u}.optio\
|
|
363
|
+
nal`),h=Ir(n,`${u}.late`),f=Ir(o,`${u}.provides`);rp({requires:l,optional:m,late:h,provides:f}),np(u,h,{provides:f,requires:l,
|
|
364
|
+
optional:m});let w=Kn(s,`${u}.setup`);if(!w)throw new TypeError(`${u}.setup is required.`);return Object.freeze({id:u,requires:l,
|
|
365
|
+
optional:m,late:h,provides:f,hints:tp(i,{...l,...h},u),setup:w,boot:Kn(a,`${u}.boot`),shutdown:Kn(c,`${u}.shutdown`)})}var Ms,
|
|
366
|
+
Zd,Qn=g(()=>{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 op,Hs,zs=g(()=>{Vs();Bs();op="/api",Hs=`${op}/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\
|
|
367
|
+
tration is closed after the first payload is resolved.");let l=V(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
368
|
+
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
|
|
369
|
+
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
|
|
370
|
+
isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u=e.map((l,m)=>({entry:l,index:m})).sort(
|
|
371
|
+
(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.
|
|
369
372
|
freeze({...B(a)?a:{},payload:Object.freeze({...c})}));c={...c,...B(m)?m:{}}}return Object.freeze(c)}function i(){return Object.
|
|
370
373
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
371
|
-
return s}var eo=g(()=>{G()});var
|
|
374
|
+
return s}var eo=g(()=>{G()});var ip,Fs=g(()=>{Qn();Us();zs();eo();ip=Tr({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"r\
|
|
372
375
|
untime.bootstrap"},setup({http:e}){let t=Zn();return e.router.register("GET",Hs,{auth:Ds,meta:{tags:["bootstrap"],summary:"\
|
|
373
376
|
Resolve app bootstrap payload"}},async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),
|
|
374
|
-
{bootstrap:t}}})});function
|
|
377
|
+
{bootstrap:t}}})});function sp(e){if(!B(e))throw new TypeError("Event listener must be an object.");let t=String(e.id||"").trim();if(!t)throw new TypeError(
|
|
375
378
|
"Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
|
|
376
379
|
dle().`);if(e.matches!=null&&typeof e.matches!="function")throw new TypeError(`Event listener "${t}" matches must be a f\
|
|
377
|
-
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function
|
|
380
|
+
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function ap(e){if(!B(e))throw new TypeError(
|
|
378
381
|
"Published event must be an object.");let t=String(e.type||"").trim();if(!t)throw new TypeError("Published event type is\
|
|
379
|
-
required.");return Object.freeze({...e,type:t})}function to(){let e=[],t=new Set;function r(s){let a=
|
|
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=
|
|
382
|
+
required.");return Object.freeze({...e,type:t})}function to(){let e=[],t=new Set;function r(s){let a=sp(s);if(t.has(a.id))
|
|
383
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=ap(s);
|
|
381
384
|
for(let c of e)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
382
|
-
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var ro=g(()=>{G()});var
|
|
385
|
+
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var ro=g(()=>{G()});var cp,qs=g(()=>{Qn();ro();cp=Tr({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:to()}}})});var Ar=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"?
|
|
383
386
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
384
387
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
385
388
|
64_project_source_lock_timeout"||n==="vibe64_development_database_scope_busy"||n==="vibe64_project_session_policy_lock_t\
|
|
386
389
|
imeout"||n==="vibe64_session_creation_limit"||n==="vibe64_workspace_setup_retry_not_available"||n==="vibe64_workspace_se\
|
|
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(()=>{
|
|
388
|
-
Js()});import
|
|
389
|
-
if(!
|
|
390
|
+
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(()=>{Ar();G();Ws();
|
|
391
|
+
Js()});import up from"node:crypto";function lp(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=String(t.type||"").trim();
|
|
392
|
+
if(!lr.includes(r))throw Ve("Preview identity selector type is invalid.","vibe64_preview_identity_selector_type_invalid");
|
|
390
393
|
let n=String(t.value||"").trim(),o=r===Ot?n.toLowerCase():n;if(!o)throw Ve("Preview identity selector is missing.","vibe\
|
|
391
394
|
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===
|
|
393
|
-
alid.":"Preview identity user id is invalid.",r===
|
|
395
|
+
nvalid.","vibe64_preview_identity_email_invalid");if(r!==Ot&&o.length>256)throw Ve(r===ur?"Preview identity login is inv\
|
|
396
|
+
alid.":"Preview identity user id is invalid.",r===ur?"vibe64_preview_identity_login_invalid":"vibe64_preview_identity_us\
|
|
394
397
|
er_id_invalid");return{type:r,value:o}}function ea(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};if(Object.hasOwn(
|
|
395
398
|
t,"subject"))throw Ve("Preview identity login requires an explicit application selector.","vibe64_preview_identity_subje\
|
|
396
|
-
ct_unsupported");let r=String(t.operation||
|
|
397
|
-
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===
|
|
398
|
-
at,Xs,Qs,Zs,
|
|
399
|
-
guest","you"]),Zs=32,
|
|
399
|
+
ct_unsupported");let r=String(t.operation||le).trim();if(![le,at].includes(r))throw Ve("Preview identity operation is in\
|
|
400
|
+
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===le?{selector:lp(t.selector)}:{}}}var V_,le,
|
|
401
|
+
at,Xs,Qs,Zs,G_,no=g(()=>{Ui();Ks();V_=up.randomBytes(32),le="login-as",at="logout",Xs="selector",Qs=new Set(["default","\
|
|
402
|
+
guest","you"]),Zs=32,G_=Object.freeze(["projectScope","sessionSourceRoot","sessionId","targetHref","terminalSessionId"])});var kt,oo=g(()=>{kt="vibe64_preview_token"});import{randomUUID as dp}from"node:crypto";import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as ta}from"@local/vibe64-genesis/server";
|
|
400
403
|
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
|
|
404
|
+
command failed.",{code:t,params:n})}function mp(e={}){return{kind:Xs,selector:e.selector}}function na(e={},t={}){let{requestId:r=dp(),
|
|
402
405
|
targetHref:n=""}=t,o=ea(e),i=String(n||"").trim(),s=new URL(i);if(!["http:","https:"].includes(s.protocol))throw new Error(
|
|
403
406
|
"Application preview identity target must use HTTP.");return{operation:o.operation,protocol:ta,requestId:String(r),...o.
|
|
404
|
-
operation===
|
|
407
|
+
operation===le?{subject:mp(o)}:{},target:{href:s.toString(),origin:s.origin}}}function fp(e=[]){if(!Array.isArray(e))throw ct(
|
|
405
408
|
"Application preview identity command returned invalid cookies.","vibe64_preview_identity_command_cookies_invalid");let t=e;
|
|
406
409
|
if(t.length>io)throw ct("Application preview identity command returned too many cookies.","vibe64_preview_identity_comma\
|
|
407
410
|
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(
|
|
408
|
-
0,s)).trim();if(!o||Buffer.byteLength(o)>so||/[\r\n]/u.test(o)||s<1||!
|
|
411
|
+
0,s)).trim();if(!o||Buffer.byteLength(o)>so||/[\r\n]/u.test(o)||s<1||!pp.test(a)||a===xt||a.startsWith(`${xt}_`)||/(?:^|;)\s*domain\s*=/iu.
|
|
409
412
|
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
|
|
413
|
+
_cookie_invalid",502,{cookie:n+1});return o})}function hp(e=null){if(!e||typeof e!="object"||Array.isArray(e))return null;
|
|
411
414
|
let t={displayName:String(e.displayName||e.name||"").trim().slice(0,256),email:String(e.email||"").trim().toLowerCase().
|
|
412
415
|
slice(0,320),login:String(e.login||"").trim().slice(0,256),userId:String(e.userId||e.id||"").trim().slice(0,256),username:String(
|
|
413
|
-
e.username||"").trim().slice(0,256)};return Object.values(t).some(Boolean)?t:null}function
|
|
416
|
+
e.username||"").trim().slice(0,256)};return Object.values(t).some(Boolean)?t:null}function gp(e={},t={}){let{operation:r=le,
|
|
414
417
|
requestId:n=""}=t;if(!e||typeof e!="object"||Array.isArray(e))throw ct("Application preview identity command returned in\
|
|
415
418
|
valid JSON.","vibe64_preview_identity_command_json_invalid");if(e.protocol!==ta||String(e.requestId||"")!==String(n||"")||
|
|
416
419
|
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=
|
|
420
|
+
eview_identity_command_response_invalid");let o=fp(e.setCookie);if(e.ok===!1){let a=Number(e.statusCode);return{code:String(
|
|
418
421
|
e.code||"vibe64_preview_identity_application_rejected").trim().slice(0,128),error:String(e.error||"Application preview i\
|
|
419
422
|
dentity was rejected.").trim().slice(0,2e3),ok:!1,setCookie:o,signedOut:e.signedOut===!0,statusCode:Number.isInteger(a)&&
|
|
420
|
-
a>=400&&a<600?a:400}}let i=r===at||e.signedOut===!0,s=i?null:
|
|
423
|
+
a>=400&&a<600?a:400}}let i=r===at||e.signedOut===!0,s=i?null:hp(e.identity);if(o.length<1||!i&&!s)throw ct("Application \
|
|
421
424
|
preview identity command did not return an authenticated browser session.","vibe64_preview_identity_command_session_miss\
|
|
422
|
-
ing");return{identity:s,ok:!0,setCookie:o,signedOut:i,statusCode:200}}var ra,io,so,xt,
|
|
423
|
-
512*1024,io=64,so=16*1024,xt=kt,
|
|
425
|
+
ing");return{identity:s,ok:!0,setCookie:o,signedOut:i,statusCode:200}}var ra,io,so,xt,pp,J_,oa=g(()=>{Ar();no();oo();ra=
|
|
426
|
+
512*1024,io=64,so=16*1024,xt=kt,pp=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;J_=Object.freeze({normalizePreviewIdentityCommandResponse:gp})});var ia=g(()=>{});function sa(e=""){return Ep.find(t=>t.pattern.test(String(e)))?.kind||""}function Sp(e){if(!be(e)||e.startsWith("/")||e.
|
|
424
427
|
includes("\\")||e.includes("\0"))return!1;let t=e.split("/");return t.every(r=>r&&r!=="."&&r!=="..")&&!t.includes("node_\
|
|
425
|
-
modules")}var
|
|
426
|
-
directory:"VIBE64_USAGE_RECORDING_DIR",sourceRoot:"VIBE64_USAGE_SOURCE_ROOT",targetKind:"VIBE64_USAGE_TARGET_KIND"}),
|
|
427
|
-
Object.freeze(["starting","recording","stopping","stopped","failed","unavailable"]),
|
|
428
|
+
modules")}var wp,Q_,yp,_p,ca,$t,Z_,eE,tE,Ep,bp,vp,Or,be,aa,rE,nE,ua=g(()=>{wp="vibe64.usage-trace.v1",Q_=Object.freeze({
|
|
429
|
+
directory:"VIBE64_USAGE_RECORDING_DIR",sourceRoot:"VIBE64_USAGE_SOURCE_ROOT",targetKind:"VIBE64_USAGE_TARGET_KIND"}),yp=
|
|
430
|
+
Object.freeze(["starting","recording","stopping","stopped","failed","unavailable"]),_p=Object.freeze(["person","time-lim\
|
|
428
431
|
it","request-limit","size-limit","target-exited","session-ended","error"]),ca=Object.freeze(["nodejs","python","php"]),$t=
|
|
429
|
-
1024*1024,
|
|
432
|
+
1024*1024,Z_=Object.freeze({durationMs:600*1e3,capturedRequests:2e3,hitsBytesPerProcess:16*$t,hitsBytesPerRecording:32*$t,
|
|
430
433
|
proxyRequestLines:2e4,interactions:500,bufferedBytesPerProcess:64*$t,flushIntervalMs:1e3,flushEntries:2e3,traceLineBytes:64*
|
|
431
|
-
1024,indexBytes:4*$t,plumbingShare:.8,plumbingMinimumRequests:3}),
|
|
432
|
-
60*1e3}),
|
|
434
|
+
1024,indexBytes:4*$t,plumbingShare:.8,plumbingMinimumRequests:3}),eE=Object.freeze({maxRecordings:10,maxBytes:64*$t,maxAgeMs:10080*
|
|
435
|
+
60*1e3}),tE=Object.freeze(["click","enter","submit"]),Ep=Object.freeze([Object.freeze({kind:"request",pattern:/^r_[0-9]{6}$/u}),
|
|
433
436
|
Object.freeze({kind:"local-request",pattern:/^l_[0-9]+_[0-9]+$/u}),Object.freeze({kind:"run",pattern:/^run_[0-9]+$/u}),Object.
|
|
434
|
-
freeze({kind:"background",pattern:/^bg_[0-9]+$/u})]),
|
|
437
|
+
freeze({kind:"background",pattern:/^bg_[0-9]+$/u})]),bp=/^sha256:[0-9a-f]{64}$/u,vp=Object.freeze(["ready","idle"]);Or=e=>Number.
|
|
435
438
|
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;
|
|
437
|
-
e.pid)&&e.pid>0&&be(e.startedAt),tracer:e=>
|
|
438
|
-
function:e=>
|
|
439
|
+
e.column)&&e.column>0;rE=Object.freeze({header:e=>e.schema===wp&&ca.includes(e.runtime)&&be(e.runtimeVersion)&&Number.isSafeInteger(
|
|
440
|
+
e.pid)&&e.pid>0&&be(e.startedAt),tracer:e=>vp.includes(e.state),file:e=>Or(e.fileIndex)&&Sp(e.path)&&bp.test(e.hash||""),
|
|
441
|
+
function:e=>Or(e.functionIndex)&&Or(e.fileIndex)&&typeof e.name=="string"&&aa(e.start)&&aa(e.end),scope:e=>sa(e.scope)===
|
|
439
442
|
e.kind&&be(e.startedAt)&&(e.endedAt===void 0||be(e.endedAt))&&(e.label===void 0||be(e.label)&&["local-request","run"].includes(
|
|
440
|
-
e.kind)),hits:e=>sa(e.scope)!==""&&Array.isArray(e.counts)&&e.counts.every(t=>Array.isArray(t)&&t.length===2&&
|
|
443
|
+
e.kind)),hits:e=>sa(e.scope)!==""&&Array.isArray(e.counts)&&e.counts.every(t=>Array.isArray(t)&&t.length===2&&Or(t[0])&&
|
|
441
444
|
(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(
|
|
442
|
-
e.reason)}),
|
|
443
|
-
return
|
|
445
|
+
e.reason)}),nE=Object.freeze({USAGE_RECORDING_STATES:yp,USAGE_RECORDING_STOP_REASONS:_p,USAGE_TRACER_RUNTIMES:ca})});function Ip(e=""){try{let t=new URL(e),r=t.protocol==="https:",n=t.port||(r?"443":"80");return`${r?"__Host-":""}${la}_${n}`}catch{
|
|
446
|
+
return la}}function Tp(e="",t={}){let{proxyOrigin:r="",targetOrigin:n=""}=t,o=String(e||"").trim();if(!o||!r||!n)return o;
|
|
444
447
|
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=
|
|
445
|
-
i.pathname,s.search=
|
|
448
|
+
i.pathname,s.search=Ap(i.search),s.hash=i.hash,s.toString())}catch{return o}}function Ap(e=""){let t=String(e||"");if(!t||
|
|
446
449
|
t==="?")return"";let r=t.startsWith("?")?t.slice(1):t;if(!r)return"";let n=r.split("&").filter(o=>{let i=o.indexOf("="),
|
|
447
|
-
s=i<0?o:o.slice(0,i);return
|
|
448
|
-
String(e||"").replace(/\+/gu," "))}catch{return String(e||"")}}var
|
|
449
|
-
|
|
450
|
-
no();oa();pa();ao=e=>JSON.stringify(e,null,2),ma=
|
|
451
|
-
11",fa=na({operation:
|
|
452
|
-
73/"}),ha=Object.freeze({protocol:
|
|
453
|
-
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),ga=Object.freeze({protocol:
|
|
450
|
+
s=i<0?o:o.slice(0,i);return Op(s)!==kt});return n.length>0?`?${n.join("&")}`:""}function Op(e=""){try{return decodeURIComponent(
|
|
451
|
+
String(e||"").replace(/\+/gu," "))}catch{return String(e||"")}}var la,da,dE,pa=g(()=>{ia();ua();oo();la=kt,da=/^vibe64-launch-[a-f0-9]{12}$/u;
|
|
452
|
+
dE=Object.freeze({previewTokenCookieName:Ip,proxiedLocation:Tp})});import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as Pr}from"@local/vibe64-genesis/server";var ao,ma,co,fa,ha,ga,wa,ya=g(()=>{
|
|
453
|
+
no();oa();pa();ao=e=>JSON.stringify(e,null,2),ma=lr.map(e=>`\`${e}\``).join(", "),co="6f1c2a7e-3d4b-4c55-9a10-2b7d8e9f0a\
|
|
454
|
+
11",fa=na({operation:le,selector:{type:"email",value:"admin@example.com"}},{requestId:co,targetHref:"http://127.0.0.1:51\
|
|
455
|
+
73/"}),ha=Object.freeze({protocol:Pr,requestId:co,ok:!0,setCookie:["app_session=abc123; Path=/; HttpOnly; SameSite=Lax"],
|
|
456
|
+
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),ga=Object.freeze({protocol:Pr,requestId:co,ok:!1,code:"\
|
|
454
457
|
user_not_found",error:"No active user has that email.",statusCode:404,setCookie:[]}),wa=Object.freeze([{name:"preview-id\
|
|
455
458
|
entity-command",title:"Preview identity command protocol",exampleRequest:fa,exampleResponses:[ha,ga],text:()=>`# Preview\
|
|
456
|
-
identity command protocol (\`${
|
|
459
|
+
identity command protocol (\`${Pr}\`)
|
|
457
460
|
|
|
458
461
|
An application-owned executable, declared under an Outputs web target's \`#### Preview identity\` block (grammar: \`vibe64-\
|
|
459
462
|
helper spec outputs\`), that signs the Preview browser in as an existing application account or signs it out. Vibe64 neve\
|
|
@@ -473,13 +476,13 @@ n-zero exit or timeout fails the exchange. Write diagnostics to stderr.
|
|
|
473
476
|
- A JSKIT application's executable can call \`runManagedPreviewIdentityCommand\` from \`@jskit-ai/auth-web/server/managedPr\
|
|
474
477
|
eviewIdentity\`. Pass it the application's environment, this protocol and the Preview's launch hostnames, since it reads \
|
|
475
478
|
no environment on its own and its defaults are JSKIT's neutral protocol and loopback only: \`runManagedPreviewIdentityCom\
|
|
476
|
-
mand({ env: process.env, protocol: "${
|
|
479
|
+
mand({ env: process.env, protocol: "${Pr}", localHostnames: [${da}] })\`.
|
|
477
480
|
|
|
478
481
|
## Request
|
|
479
482
|
|
|
480
|
-
- \`operation\`: \`${
|
|
483
|
+
- \`operation\`: \`${le}\` or \`${at}\`.
|
|
481
484
|
- \`protocol\`, \`requestId\`: echo both in the response.
|
|
482
|
-
- \`subject\` (${
|
|
485
|
+
- \`subject\` (${le} only): \`{"kind":"selector","selector":{"type":\u2026,"value":\u2026}}\` with type ${ma}. Email val\
|
|
483
486
|
ues arrive lowercased.
|
|
484
487
|
- \`target\`: \`{"href","origin"}\` of the application page the cookies are for.
|
|
485
488
|
|
|
@@ -492,7 +495,7 @@ ${ao(fa)}
|
|
|
492
495
|
- Always: \`protocol\`, the same \`requestId\`, boolean \`ok\`, and \`setCookie\`: an array of complete Set-Cookie header values\
|
|
493
496
|
(at most ${io}, each at most ${so} bytes, no line breaks, no \`Domain\` attribute, never named \`${xt}\` or \`${xt}_*\`)\
|
|
494
497
|
.
|
|
495
|
-
- \`ok: true\`: at least one cookie. For ${
|
|
498
|
+
- \`ok: true\`: at least one cookie. For ${le}, \`identity\` with at least one of \`displayName\`, \`email\`, \`login\`, \`userId\
|
|
496
499
|
\`, \`username\`. For ${at} (or \`"signedOut": true\`), the cookies that clear the session.
|
|
497
500
|
- \`ok: false\`: \`code\` (at most 128 characters), \`error\` (a person-readable reason, at most 2000), \`statusCode\` 400 throu\
|
|
498
501
|
gh 599 (default 400), optional \`signedOut\`, and \`setCookie\` (may be empty).
|
|
@@ -530,31 +533,31 @@ Entry shape:
|
|
|
530
533
|
\`\`\`json
|
|
531
534
|
{"name":"admin","type":"email","value":"admin@example.com"}
|
|
532
535
|
\`\`\`
|
|
533
|
-
`}])});var Ea={};xi(Ea,{__testables:()=>
|
|
534
|
-
function _a(){let e=Math.max(...
|
|
535
|
-
cts:",...
|
|
536
|
-
`)}async function
|
|
536
|
+
`}])});var Ea={};xi(Ea,{__testables:()=>kp,runAgentSpecCli:()=>Cp});import{readFile as Rp}from"node:fs/promises";import{VIBE64_GENESIS_AGENT_SPECS as Np}from"@local/vibe64-genesis/server/agentSpecs";
|
|
537
|
+
function _a(){let e=Math.max(...Rr.map(({name:t})=>t.length));return["Usage: vibe64 spec <name>","","Vibe64-owned contra\
|
|
538
|
+
cts:",...Rr.map(({name:t,title:r})=>` ${t.padEnd(e)} ${r}`)].join(`
|
|
539
|
+
`)}async function Cp(e=[],{write:t=n=>process.stdout.write(`${n.trimEnd()}
|
|
537
540
|
`),writeError:r=n=>process.stderr.write(`${n.trimEnd()}
|
|
538
|
-
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(_a()),0;let o=e.length===1&&
|
|
541
|
+
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(_a()),0;let o=e.length===1&&Rr.find(i=>i.name===n);return o?(t(await o.
|
|
539
542
|
text()),0):(r(`Unknown Vibe64 spec: ${e.join(" ")}.
|
|
540
543
|
|
|
541
|
-
${_a()}`),2)}var
|
|
542
|
-
freeze([...
|
|
543
|
-
e",text:()=>
|
|
544
|
-
e))Ae(e[r],t);return Object.freeze(e)}var jt=g(()=>{});function
|
|
544
|
+
${_a()}`),2)}var Pp,Rr,kp,ba=g(()=>{Di();ya();Pp=new URL("./../server/lib/agentSpecCli.js",import.meta.url).href,Rr=Object.
|
|
545
|
+
freeze([...Np,...wa,...Mi,{name:"training-content",title:"Teaching content format for vibe64 training validate and bundl\
|
|
546
|
+
e",text:()=>Rp(new URL("../../docs/training-content.md",Pp),"utf8")}]);kp=Object.freeze({VIBE64_AGENT_SPECS:Rr})});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(
|
|
547
|
+
e))Ae(e[r],t);return Object.freeze(e)}var jt=g(()=>{});function Nr(e){return!!e&&typeof e=="object"&&Lp.every(t=>typeof e[t]=="function")}function Sa(e=null,{defaultMode:t="cr\
|
|
545
548
|
eate",context:r="schema definition.mode"}={}){let n=re(e),o=V(t).toLowerCase()||"create",i=Object.prototype.hasOwnProperty.
|
|
546
|
-
call(n,"mode")?V(n.mode).toLowerCase():"";if(!i)return o;if(!
|
|
547
|
-
replace, patch.`);return i}function Ia(e=null,t=""){let r=V(t);if(!r)return{};let n=re(e);return
|
|
548
|
-
getFieldMessages(r)):{}}function
|
|
549
|
+
call(n,"mode")?V(n.mode).toLowerCase():"";if(!i)return o;if(!xp.has(i))throw new TypeError(`${r} must be one of: create,\
|
|
550
|
+
replace, patch.`);return i}function Ia(e=null,t=""){let r=V(t);if(!r)return{};let n=re(e);return Nr(n.schema)?re(n.schema.
|
|
551
|
+
getFieldMessages(r)):{}}function Mp(e=null,t=""){let r=V(t).split(".").filter(Boolean);return r.length<2?{}:(r.pop(),Ia(
|
|
549
552
|
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))
|
|
550
553
|
return null;let n=V(r.message);if(!n)return null;let o=V(r.code);return o?{message:n,code:o,params:re(r.params)}:{message:n}}
|
|
551
|
-
function
|
|
552
|
-
Object.keys(s).length<1?
|
|
553
|
-
params:{...i,...c.params}}:{message:c.message};let
|
|
554
|
-
message:
|
|
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:
|
|
556
|
-
a,s,t);n[a]=c,
|
|
557
|
-
["create","replace","patch"])
|
|
554
|
+
function Dp(e,t,r=null){let n=V(t?.code).toUpperCase(),o=$p[n]||{},i=re(t?.params),s=Ia(r,e),a=n==="FIELD_NOT_ALLOWED"&&
|
|
555
|
+
Object.keys(s).length<1?Mp(r,e):s,c=va(a,o.messageKey)||va(a,"default");if(c)return c.code?{message:c.message,code:c.code,
|
|
556
|
+
params:{...i,...c.params}}:{message:c.message};let u=V(t?.message);if(u)return o.code?{message:u,code:o.code,params:i}:{
|
|
557
|
+
message:u};let l=V(t?.code);return l?{message:l}:{...jp,params:{}}}function uo(e={},t=null){let r=re(e),n={},o={};for(let[
|
|
558
|
+
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}=Dp(
|
|
559
|
+
a,s,t);n[a]=c,u&&(o[a]={code:u,params:l})}return{fieldErrors:n,fieldErrorCodes:o}}var xp,$p,jp,Lp,lo=g(()=>{G();xp=new Set(
|
|
560
|
+
["create","replace","patch"]),$p=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},
|
|
558
561
|
TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",
|
|
559
562
|
code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},
|
|
560
563
|
MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kern\
|
|
@@ -564,23 +567,23 @@ messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{message
|
|
|
564
567
|
.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{
|
|
565
568
|
messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{
|
|
566
569
|
messageKey:"default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validati\
|
|
567
|
-
on.field.notEmpty"}})
|
|
568
|
-
reate","replace","patch","toJsonSchema"])});function
|
|
569
|
-
prototype.hasOwnProperty.call(e,"mode"))}function
|
|
570
|
-
if(!
|
|
571
|
-
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!
|
|
570
|
+
on.field.notEmpty"}}),jp=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),Lp=Object.freeze(["c\
|
|
571
|
+
reate","replace","patch","toJsonSchema"])});function Up(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&(Object.prototype.hasOwnProperty.call(e,"schema")||Object.
|
|
572
|
+
prototype.hasOwnProperty.call(e,"mode"))}function Cr(e,{context:t="schema definition",defaultMode:r=""}={}){if(e==null)return null;
|
|
573
|
+
if(!Up(e))throw new TypeError(`${t} must be a schema definition object.`);let n=re(e);if(!Object.prototype.hasOwnProperty.
|
|
574
|
+
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!Nr(n.schema))throw new TypeError(`${t}.schema must \
|
|
572
575
|
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=
|
|
574
|
-
e,{context:r,defaultMode:n});return o?o.schema[o.mode](t):null}var Lt=g(()=>{G();
|
|
575
|
-
freeze({schema:
|
|
576
|
-
|
|
576
|
+
"patch",context:`${t}.mode`}),Object.freeze(o)}function po(e,t,{context:r="schema definition",defaultMode:n=""}={}){let o=Cr(
|
|
577
|
+
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 Vp,Gp,Oa=g(()=>{Ue();Vp=$({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Gp=Object.
|
|
578
|
+
freeze({schema:Vp,mode:"patch"})});var Pa,Bp,Ra=g(()=>{Pa=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),
|
|
579
|
+
Bp=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
580
|
e,o?{cause:o}:void 0);if(e===Ca&&(s.messageCode="kernel.validation.schemaFailed",s.messageParams={}),Number.isInteger(i)&&
|
|
578
581
|
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=
|
|
579
582
|
a),s.details={...s.details||{},fieldErrors:t,...a?{fieldErrorCodes:a}:{}}}else n!=null&&(s.details={...s.details||{},errors:n});
|
|
580
583
|
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}=
|
|
584
|
+
e,t,{defaultMode:r==="output"?"replace":"patch",context:n}),{fieldErrors:s,fieldErrorCodes:a}=uo(i.errors,e);if(Object.keys(
|
|
582
585
|
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
|
|
586
|
+
Ca="Schema validation failed."});var WE,$a=g(()=>{G();WE=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.val\
|
|
584
587
|
idation.type"},{keyword:"minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.max\
|
|
585
588
|
Length"},{keyword:"minimum",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"\
|
|
586
589
|
exclusiveMinimum",code:"kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusi\
|
|
@@ -592,40 +595,40 @@ tion.maxItems"},{keyword:"additionalItems",code:"kernel.validation.additionalIte
|
|
|
592
595
|
kernel.validation.maxProperties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"\
|
|
593
596
|
propertyNames",code:"kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",
|
|
594
597
|
code:"kernel.validation.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].
|
|
595
|
-
map(({keyword:e,code:t})=>[e,t]))});var ja,fo,
|
|
596
|
-
|
|
597
|
-
id must be a canonical positive integer string."}}}}),mode:"patch"})});var Ma=g(()=>{G()});var
|
|
598
|
-
let n=mo({schema:e,mode:"create"},t,{context:r});if(!
|
|
599
|
-
s.`);return n}var N,M,H,
|
|
598
|
+
map(({keyword:e,code:t})=>[e,t]))});var ja,fo,Hp,zp,La=g(()=>{Ue();jt();ja="^[1-9][0-9]*$",fo=Ae({type:"string",minLength:1,pattern:ja}),Hp=Ae({...fo,nullable:!0}),
|
|
599
|
+
zp=Ae({schema:$({recordId:{...fo,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record\
|
|
600
|
+
id must be a canonical positive integer string."}}}}),mode:"patch"})});var Ma=g(()=>{G()});var kr=g(()=>{Ue();On();Ta();Aa();Oa();Ra();Na();lo();Lt();xa();$a();La();Ma()});import{isDeepStrictEqual as Fp}from"node:util";function $r(e,t){let r=Xp.get(e?.schemaVersion)||Ua;return ce(r,e,t)}function ce(e,t,r){
|
|
601
|
+
let n=mo({schema:e,mode:"create"},t,{context:r});if(!Fp(t,n))throw new Error(`${r}: unknown fields or noncanonical value\
|
|
602
|
+
s.`);return n}var N,M,H,xr,qp,Wp,Da,Ua,Yp,Va,Jp,Kp,Xp,me,jr,Lr,Ga,ut=g(()=>{kr();N={type:"string",required:!0,noTrim:!0,
|
|
600
603
|
minLength:1,maxLength:256},M={...N,maxLength:64},H=(e,t=100)=>({type:"array",required:!0,maxLength:t,items:e,validator:r=>Array.
|
|
601
|
-
isArray(r)&&r.length>t?`Expected at most ${t} items.`:void 0}),
|
|
602
|
-
24),
|
|
604
|
+
isArray(r)&&r.length>t?`Expected at most ${t} items.`:void 0}),xr={type:"integer",required:!0,enum:[1]},qp=H($({code:M}),
|
|
605
|
+
24),Wp=$({id:M,kind:{...N,enum:["answer","practical"]},required:{type:"boolean",required:!0},rubric:N,evidence:{type:"ob\
|
|
603
606
|
ject",required:!1,schema:$({producer:{...N,enum:["workspace","colleague","exercise","code"]},operation:M,check:{...M,required:!1},
|
|
604
|
-
explanationRequired:{type:"boolean",required:!1},files:{...H(N,8),required:!1,minLength:1}})}}),Da={code:M,title:N,prerequisites:
|
|
607
|
+
explanationRequired:{type:"boolean",required:!1},files:{...H(N,8),required:!1,minLength:1}})}}),Da={code:M,title:N,prerequisites:qp,
|
|
605
608
|
estimatedMinutes:{type:"integer",required:!0,min:1,max:180},visuals:H($({id:M,descriptor:N}),12),exercise:{type:"object",
|
|
606
609
|
required:!1,schema:$({kind:{...N,enum:["bundled"]},source:N,reuse:{...N,enum:["attempt","sequence"]},sequenceId:{...M,required:!1},
|
|
607
610
|
sequenceMode:{...N,required:!1,enum:["create","continue"]}})},checks:{...H($({id:M,file:N,assets:{...H(N,32),required:!1},
|
|
608
611
|
kind:{...N,required:!1,enum:["response","code"]},timeoutSeconds:{type:"integer",required:!1,min:1,max:60}}),12),required:!1},
|
|
609
612
|
appRoutes:{...H($({method:{...N,enum:["POST","PUT","PATCH","DELETE"]},path:{...N,maxLength:128,pattern:"^/[A-Za-z0-9._~:\
|
|
610
|
-
/-]*$"}}),16),required:!1}},Ua=$({schemaVersion:
|
|
613
|
+
/-]*$"}}),16),required:!1}},Ua=$({schemaVersion:xr,...Da,document:N,assessments:H(Wp,32)}),Yp=$({id:M,title:N,body:N,required:{
|
|
611
614
|
type:"boolean",required:!0},visual:{type:"object",required:!1,schema:$({id:M,play:{...H($({name:M,parameters:{type:"obje\
|
|
612
615
|
ct",required:!0}}),16),required:!1}})},guide:{type:"object",required:!1,schema:$({target:M,navigate:{type:"boolean",required:!1},
|
|
613
616
|
filePath:{...N,required:!1,maxLength:512},caption:{...N,required:!1}})},check:{type:"object",required:!0,schema:$({kind:{
|
|
614
617
|
...N,enum:["auto","choice","review","self","fact","none"]},check:{...M,required:!1},fact:{...M,required:!1},files:{...H(
|
|
615
618
|
N,8),required:!1},question:{...N,required:!1,maxLength:2e3},options:{...H(N,8),required:!1},answer:{...H({type:"integer",
|
|
616
619
|
required:!0,min:0,max:7},8),required:!1},rubric:{...N,required:!1,maxLength:600},evidence:{...H({...N,enum:["changes","c\
|
|
617
|
-
onversation"]},2),required:!1}})}}),Va={...Da,notes:{...N,required:!1},steps:H(
|
|
618
|
-
r",required:!0,enum:[2]},...Va}),
|
|
619
|
-
io","project"]}}),
|
|
620
|
+
onversation"]},2),required:!1}})}}),Va={...Da,notes:{...N,required:!1},steps:H(Yp,32)},Jp=$({schemaVersion:{type:"intege\
|
|
621
|
+
r",required:!0,enum:[2]},...Va}),Kp=$({schemaVersion:{type:"integer",required:!0,enum:[3]},...Va,stage:{...N,enum:["stud\
|
|
622
|
+
io","project"]}}),Xp=new Map([[1,Ua],[2,Jp],[3,Kp]]),me=e=>e?.schemaVersion===2||e?.schemaVersion===3;jr=$({schemaVersion:xr,
|
|
620
623
|
topicId:M,domainId:M,title:N,status:{...N,enum:["preview","released"]},outline:N,prerequisites:H($({topicId:M}),24),lessons:H(
|
|
621
624
|
$({code:M,descriptor:N,status:{...N,enum:["draft","published"]},required:{type:"boolean",required:!0}}),64),places:{...H(
|
|
622
|
-
M,64),required:!1},activities:{...H(M,64),required:!1},facts:{...H(M,64),required:!1}}),
|
|
625
|
+
M,64),required:!1},activities:{...H(M,64),required:!1},facts:{...H(M,64),required:!1}}),Lr=$({schemaVersion:xr,courseId:M,
|
|
623
626
|
title:N,release:N,status:{...N,enum:["preview","released"]},topics:H($({topicId:M,release:N}),32),orientation:{...M,required:!1}}),
|
|
624
|
-
Ga=$({schemaVersion:
|
|
627
|
+
Ga=$({schemaVersion:xr,id:M,title:N,svg:N,controller:N,assets:{...H(N,32),required:!1},initialState:M,states:H(M,32),description:{
|
|
625
628
|
...N,maxLength:2e3},commands:H($({name:M,parameters:H($({name:M,required:{type:"boolean",required:!0},maxLength:{type:"i\
|
|
626
|
-
nteger",required:!0,min:1,max:256}}),8),completionState:M,description:{...N,maxLength:2e3}}),32)})});function ne(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_VOCABULARY_INVALID"})}function
|
|
629
|
+
nteger",required:!0,min:1,max:256}}),8),completionState:M,description:{...N,maxLength:2e3}}),32)})});function ne(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_VOCABULARY_INVALID"})}function nm(e){if(!B(e)||!Se.
|
|
627
630
|
test(e.id||""))throw ne("A place needs a lowercase id.");let t=`Place ${e.id}`;if(!za(e.label))throw ne(`${t} needs a la\
|
|
628
|
-
bel.`);if(!
|
|
631
|
+
bel.`);if(!Qp.has(e.scope))throw ne(`${t} scope is studio or project.`);let r=e.who??"everyone";if(!Zp.has(r))throw ne(`${t}\
|
|
629
632
|
who is everyone or owner.`);let n=e.open??null;if(n!==null){let i=Object.keys(n||{}).sort().join(",");if(!(i==="pane"||
|
|
630
633
|
i==="databaseView,pane"?e.scope==="project"&&Se.test(n.pane):i==="route"?e.scope==="studio"&&typeof n.route=="string"&&/^\/app(?:\/[a-z0-9-]+)*$/u.
|
|
631
634
|
test(n.route):i==="learning"&&n.learning===!0))throw ne(`${t} opens a project pane, a studio /app route, Courses, or not\
|
|
@@ -635,43 +638,43 @@ pane,...n.databaseView?{databaseView:n.databaseView}:{}}]:n?.route?[{route:n.rou
|
|
|
635
638
|
i)||!Object.keys(i).length))throw ne(`${t} shown is a list of page focus matchers.`);if(e.event!==void 0&&!Se.test(e.event))
|
|
636
639
|
throw ne(`${t} event is a lowercase activity name.`);return Object.freeze({id:e.id,label:e.label,scope:e.scope,who:r,open:n&&
|
|
637
640
|
Object.freeze({...n}),steps:Object.freeze(e.steps.map(i=>z(i.id,i.label))),shown:Object.freeze(o.map(i=>Object.freeze({...i}))),
|
|
638
|
-
...e.event?{event:e.event}:{}})}function
|
|
641
|
+
...e.event?{event:e.event}:{}})}function om(e){if(!B(e)||!Se.test(e.id||""))throw ne("An activity needs a lowercase id.");
|
|
639
642
|
if(!Se.test(e.event||""))throw ne(`Activity ${e.id} needs its page activity event.`);if(e.place!==void 0&&!Se.test(e.place))
|
|
640
643
|
throw ne(`Activity ${e.id} place is a place id.`);return Object.freeze({id:e.id,event:e.event,...e.place?{place:e.place}:
|
|
641
|
-
{}})}function go(){return!1}function yo({places:e=
|
|
642
|
-
stringify(
|
|
644
|
+
{}})}function go(){return!1}function yo({places:e=em,activities:t=tm,facts:r=rm}={}){let n=new Map,o=new Map,i=new Set,s=(f,w)=>JSON.
|
|
645
|
+
stringify(f)===JSON.stringify(w);function a({places:f=[],activities:w=[],facts:I=[]}={}){let S=f.map(nm),d=w.map(om);for(let p of[
|
|
643
646
|
...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)&&
|
|
644
647
|
n.has(p.id))throw ne(`${p.id} is already registered with another meaning.`);for(let p of I)if(!Se.test(p||""))throw ne("\
|
|
645
648
|
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,
|
|
646
|
-
activities:t,facts:r});function c(
|
|
647
|
-
|
|
648
|
-
filter(
|
|
649
|
-
declaredPlace:go,declaredActivity:go})}function
|
|
649
|
+
activities:t,facts:r});function c(f){return n.get(f)||null}function u(f){return o.get(f)||null}function l(f){return i.has(
|
|
650
|
+
f)}function m(){return[...n.values()]}function h(){return new Set([...[...o.values()].map(f=>f.event),...[...n.values()].
|
|
651
|
+
filter(f=>f.event).map(f=>f.event)])}return Object.freeze({register:a,place:c,activity:u,hasFact:l,places:m,events:h,declared:go,
|
|
652
|
+
declaredPlace:go,declaredActivity:go})}function Mr({places:e=[],activities:t=[],facts:r=[]}={}){let n=yo(),o=new Set(n.places().
|
|
650
653
|
map(m=>m.id));for(let m of[...e,...t,...r])if(!Se.test(m||""))throw ne(`Declared name ${m} is not a lowercase id.`);let i=new Set(
|
|
651
654
|
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(
|
|
652
|
-
m)}function
|
|
653
|
-
place:n.place,activity:n.activity,hasFact:
|
|
655
|
+
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,
|
|
656
|
+
place:n.place,activity:n.activity,hasFact:l,places:n.places,events:n.events,declared:u,declaredPlace:a,declaredActivity:c})}
|
|
654
657
|
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(
|
|
655
|
-
e.target):null,n=!r&&t.declaredPlace(e.target);if(!r&&!n){let c=t.places().map(
|
|
658
|
+
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 \
|
|
656
659
|
this installation's guide places: ${c}.`,"VIBE64_TRAINING_GUIDE_INVALID",{places:c})}let o=e.target,i=e.navigate??!1,s=e.
|
|
657
660
|
highlight??!0;if(typeof i!="boolean"||typeof s!="boolean")throw Oe("navigate and highlight are booleans.","VIBE64_TRAINI\
|
|
658
661
|
NG_GUIDE_FLAGS_INVALID");if(!i&&!s)throw Oe("Point at the place (highlight) or open it (navigate); this request does nei\
|
|
659
662
|
ther.","VIBE64_TRAINING_GUIDE_ACTION_MISSING");if(i&&o==="dashboard")throw Oe("Dashboard has no single view to open. Poi\
|
|
660
663
|
nt at it, or open one Dashboard section such as files or database-erd.","VIBE64_TRAINING_GUIDE_DASHBOARD_UNOPENABLE");if(i&&
|
|
661
|
-
r&&!
|
|
664
|
+
r&&!im(r))throw Oe(`${r.label} has no view to open; point at it instead.`,"VIBE64_TRAINING_GUIDE_PLACE_UNOPENABLE",{place:r.
|
|
662
665
|
label});let a={target:o,navigate:i,highlight:s};if(e.filePath!==void 0){if(o!=="files")throw Oe("filePath is only for th\
|
|
663
666
|
e files place.","VIBE64_TRAINING_GUIDE_FILE_PATH_MISPLACED");if(typeof e.filePath!="string"||!_o.test(e.filePath))throw Oe(
|
|
664
667
|
"Use a relative practice project file path without '..'.","VIBE64_TRAINING_GUIDE_FILE_PATH_INVALID");a.filePath=e.filePath}
|
|
665
668
|
if(e.caption!==void 0){if(typeof e.caption!="string"||!e.caption.trim()||e.caption.length>wo)throw Oe(`Use a caption of \
|
|
666
669
|
1 to ${wo} characters.`,"VIBE64_TRAINING_GUIDE_CAPTION_INVALID",{limit:wo});a.caption=e.caption.trim()}return a}function qa(e,t={},r=Ge){
|
|
667
670
|
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\
|
|
668
|
-
ring"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}function
|
|
671
|
+
ring"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}function sm(e,t=Ge){let r=new Set,n=new Set,o=new Set;
|
|
669
672
|
for(let i of Array.isArray(e?.beats)?e.beats:[]){if(i.kind==="check")continue;let s=t.activity(i.target);s||t.declaredActivity(
|
|
670
673
|
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?.
|
|
671
|
-
kind==="fact"&&o.add(e.check.fact),{places:[...r],activities:[...n],facts:[...o]}}var Se,
|
|
672
|
-
Ge,_o,wo,
|
|
674
|
+
kind==="fact"&&o.add(e.check.fact),{places:[...r],activities:[...n],facts:[...o]}}var Se,Qp,Zp,z,Ba,ve,Ha,ho,em,tm,rm,za,
|
|
675
|
+
Ge,_o,wo,im,Nb,Dr=g(()=>{pr();G();Se=/^[a-z][a-z0-9-]{0,63}$/u,Qp=new Set(["studio","project"]),Zp=new Set(["everyone","\
|
|
673
676
|
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"),
|
|
677
|
+
"Database"),ho=z("account-menu","Account menu"),em=[{id:"preview",label:"Preview",scope:"project",open:{pane:"preview"},
|
|
675
678
|
steps:[Ba]},{id:"dashboard",label:"Dashboard",scope:"project",open:null,steps:[ve]},{id:"database-erd",label:"ERD",scope:"\
|
|
676
679
|
project",open:{pane:"database",databaseView:"erd"},steps:[ve,Ha,z("database-erd","ERD")]},{id:"database-data",label:"Dat\
|
|
677
680
|
a",scope:"project",open:{pane:"database",databaseView:"data"},steps:[ve,Ha,z("database-data","Data")]},{id:"files",label:"\
|
|
@@ -690,48 +693,48 @@ p bar")]},{id:"courses",label:"Courses",scope:"studio",open:null,shown:[{learnin
|
|
|
690
693
|
{id:"colleague",label:"Colleague",scope:"studio",open:null,event:"colleague-opened",steps:[z("colleague","Colleague")]},
|
|
691
694
|
{id:"account-menu",label:"Account menu",scope:"studio",open:null,steps:[ho]},{id:"account-settings",label:"Account setti\
|
|
692
695
|
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")]}],
|
|
696
|
+
studio",open:null,steps:[ho,z("ai-setup","AI setup")]}],tm=[{id:"send-message",event:"message-sent",place:"chat"},{id:"a\
|
|
694
697
|
gent-finished",event:"agent-finished"},{id:"file-opened",event:"file-opened",place:"files"},{id:"app-pressed",event:"app\
|
|
695
|
-
-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],
|
|
698
|
+
-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],rm=["ai-ready"];za=
|
|
696
699
|
e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;Ge=yo({facts:[]});_o=/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\u0000-\u001f\\]{1,512}$/u,
|
|
697
|
-
wo=256;
|
|
700
|
+
wo=256;im=e=>!!e?.open;Nb=Object.freeze({createLearningVocabulary:yo,lessonStepNeeds:sm})});function oe(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_BEATS_INVALID"})}function fm(e,t,r){let n=lm.exec(
|
|
698
701
|
e);if(!n)throw oe(`beat ${t} must read "<show|do|check> <target>: <text>".`);let[,o,i,s,a=""]=n,c=`beat ${t} (${o} ${i})`;
|
|
699
702
|
if(o==="check"&&i==="review"){if(a.trim()||s!==void 0)throw oe(`${c} takes no text: the bar shows the step's check.rubri\
|
|
700
|
-
c.`);return{kind:o,target:i,text:""}}if(!a.trim())throw oe(`${c} needs its text after the colon.`);let
|
|
703
|
+
c.`);return{kind:o,target:i,text:""}}if(!a.trim())throw oe(`${c} needs its text after the colon.`);let u={kind:o,target:i,
|
|
701
704
|
text:a.trim()};if(s!==void 0&&!(o==="do"&&i==="file-opened"))throw oe(`${c} takes no argument; only do file-opened names\
|
|
702
|
-
a path.`);if(o==="show"&&!
|
|
705
|
+
a path.`);if(o==="show"&&!mm(i,r))throw oe(`${c} names an unknown place.`);if(o==="do"&&!pm(i,r))throw oe(`${c} names n\
|
|
703
706
|
othing the learner can do or be at.`);if(o==="check"&&!Eo[i])throw oe(`${c} must be check auto, review, done or fact.`);
|
|
704
|
-
if(s!==void 0){if(!_o.test(s))throw oe(`${c} needs a relative practice project file path without '..'.`);
|
|
705
|
-
"send-message"?am
|
|
706
|
-
...
|
|
707
|
-
ed prompt of at most ${Ya} characters.`);
|
|
707
|
+
if(s!==void 0){if(!_o.test(s))throw oe(`${c} needs a relative practice project file path without '..'.`);u.path=s}let l=i===
|
|
708
|
+
"send-message"?cm:am;if(u.text.length>l)throw oe(`${c} text is longer than ${l} characters.`);if(i==="send-message"){let m=[
|
|
709
|
+
...u.text.matchAll(dm)].map(h=>h[1].trim());if(m.length!==1||!m[0]||m[0].length>Ya)throw oe(`${c} needs exactly one quot\
|
|
710
|
+
ed prompt of at most ${Ya} characters.`);u.prompt=m[0]}return u}function Ur(e,t=Ge){let r=String(e??""),n=um.exec(r);if(!n)
|
|
708
711
|
return{body:r,beats:null};let o=r.slice(n.index+n[0].length),i=/^```[ \t]*$/mu.exec(o);if(!i)throw oe("the beats block i\
|
|
709
712
|
s not closed with ```.");if(o.slice(i.index+i[0].length).trim())throw oe("the beats block must end the step text.");let s=o.
|
|
710
713
|
slice(0,i.index).split(`
|
|
711
|
-
`).map(
|
|
712
|
-
map((l
|
|
714
|
+
`).map(u=>u.trim()).filter(Boolean);if(!s.length||s.length>Wa)throw oe(`a beats block holds 1 to ${Wa} beats.`);let a=s.
|
|
715
|
+
map((u,l)=>fm(u,l+1,t)),c=a.filter(u=>u.kind==="check");if(c.length>1||c.length&&a.at(-1).kind!=="check")throw oe("a ste\
|
|
713
716
|
p has at most one check beat, and it is the last.");return{body:r.slice(0,n.index).replace(/\s+$/u,`
|
|
714
|
-
`),beats:a}}function
|
|
715
|
-
function Ja(e,t=Ge){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(
|
|
716
|
-
scope==="project":!t.declared(e.target)}var Wa,
|
|
717
|
-
freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),
|
|
718
|
-
|
|
719
|
-
place(e)||t.declaredPlace(e))});import{createHash as
|
|
720
|
-
let n=new Set;for(let o of e){let i=t?o[t]:o;if(!
|
|
717
|
+
`),beats:a}}function hm(e,t=Ge){if(!e||e.kind==="check")return"";let r=t.activity(e.target);return r?r.place||"":e.target}
|
|
718
|
+
function Ja(e,t=Ge){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(hm(e,t));return r?r.
|
|
719
|
+
scope==="project":!t.declared(e.target)}var Wa,am,Ya,cm,Eo,um,lm,dm,pm,mm,bo=g(()=>{Dr();Wa=8,am=160,Ya=500,cm=600,Eo=Object.
|
|
720
|
+
freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),um=/^```beats[ \t]*$/mu,lm=/^(show|do|check)[ \t]+([a-z][a-z-]*)(?:[ \t]+([^:]+?))?[ \t]*(?::[ \t]*(.*))?$/u,
|
|
721
|
+
dm=/["“]([^"“”]+)["”]/gu;pm=(e,t)=>!!(t.activity(e)||t.place(e)?.event||qa(e,{},t)!==null||t.declared(e)),mm=(e,t)=>!!(t.
|
|
722
|
+
place(e)||t.declaredPlace(e))});import{createHash as gm}from"node:crypto";function K(e){return gm("sha256").update(e).digest("hex")}var lt=g(()=>{});import{lstat as wm,readFile as ym,readdir as _m,realpath as Ka}from"node:fs/promises";import ie from"node:path";function fe(e,t,r){
|
|
723
|
+
let n=new Set;for(let o of e){let i=t?o[t]:o;if(!Vr(i)||n.has(i))throw new Error(`${r}: invalid or duplicate ID ${i}.`);
|
|
721
724
|
n.add(i)}return n}function L(e){return Array.isArray(e)?`[${e.map(L).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(
|
|
722
725
|
e).sort().map(t=>`${JSON.stringify(t)}:${L(e[t])}`).join(",")}}`:JSON.stringify(e)}function Qa(e,t){let r=e.get(t.path);
|
|
723
726
|
if(r&&(r.sha256!==t.sha256||r.bytes!==t.bytes))throw new Error(`Source changed between lesson snapshots: ${t.path}. Vali\
|
|
724
727
|
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
|
|
728
|
+
async function Em(e){let t=await Ka(e);async function r(i,s=t){if(typeof i!="string"||!i||i.includes("\\")||ie.isAbsolute(
|
|
726
729
|
i))throw new Error(`Invalid topic-relative path: ${i}.`);let a=ie.resolve(s,i),c=ie.relative(t,a);if(c===".."||c.startsWith(
|
|
727
730
|
`..${ie.sep}`)||ie.isAbsolute(c))throw new Error(`Path escapes topic: ${i}.`);if(await Ka(a)!==a)throw new Error(`Symlin\
|
|
728
731
|
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(
|
|
729
|
-
i,s),c=await
|
|
730
|
-
relative}.`);return{...a,bytes:await
|
|
731
|
-
a.bytes.toString("utf8"))}}return Object.freeze({root:t,resolve:r,read:n,json:o})}function
|
|
732
|
+
i,s),c=await wm(a.filename);if(!c.isFile()||c.size>1024*1024)throw new Error(`Expected a regular file of at most 1 MiB: ${a.
|
|
733
|
+
relative}.`);return{...a,bytes:await ym(a.filename)}}async function o(i,s=t){let a=await n(i,s);return{...a,value:JSON.parse(
|
|
734
|
+
a.bytes.toString("utf8"))}}return Object.freeze({root:t,resolve:r,read:n,json:o})}function bm(e){let t=new Map(e.map(i=>[
|
|
732
735
|
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;
|
|
733
736
|
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(
|
|
734
|
-
i),r.add(i)}for(let i of e)o(i.code)}function
|
|
737
|
+
i),r.add(i)}for(let i of e)o(i.code)}function vm(e,t,r,n){r(t);let o=t.bytes.toString("utf8");fe(e.assessments,"id","Ass\
|
|
735
738
|
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.
|
|
736
739
|
id}"></a>$`,"mu").test(o)||a!==i.id)throw new Error(`Missing explicit rubric anchor for ${i.id}.`);if(i.kind==="practica\
|
|
737
740
|
l"&&!i.evidence)throw new Error(`Practical assessment ${i.id} needs an evidence producer.`);if(i.kind==="answer"&&i.evidence)
|
|
@@ -739,204 +742,204 @@ throw new Error(`Answer assessment ${i.id} uses its admitted answer, not a pract
|
|
|
739
742
|
has(i.evidence.check))throw new Error(`Unknown check for ${i.id}.`);if(i.evidence?.producer==="exercise"&&(!e.exercise||
|
|
740
743
|
!i.evidence.check))throw new Error(`Exercise assessment ${i.id} needs its declared exercise and check.`);if(i.evidence?.
|
|
741
744
|
check&&!["exercise","code"].includes(i.evidence.producer))throw new Error(`Only exercise or code evidence runs a declare\
|
|
742
|
-
d check: ${i.id}.`);let
|
|
743
|
-
code"){if(!e.exercise||!i.evidence.check||
|
|
744
|
-
needs its declared exercise, files and a code check.`)}else if(i.evidence?.files||i.evidence?.check&&
|
|
745
|
-
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function
|
|
745
|
+
d check: ${i.id}.`);let u=(e.checks||[]).find(l=>l.id===i.evidence?.check)?.kind||"response";if(i.evidence?.producer==="\
|
|
746
|
+
code"){if(!e.exercise||!i.evidence.check||u!=="code"||!i.evidence.files?.length)throw new Error(`Code assessment ${i.id}\
|
|
747
|
+
needs its declared exercise, files and a code check.`)}else if(i.evidence?.files||i.evidence?.check&&u==="code")throw new Error(
|
|
748
|
+
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function Sm(e,t,r,n,o,i){let s=a=>{throw new Error(
|
|
746
749
|
`Lesson ${n}: ${a}`)};e.schemaVersion===3&&e.stage==="project"&&!e.exercise&&s("a project lesson needs its exercise (a p\
|
|
747
750
|
ractice project)."),e.steps.length||s("needs at least one step."),fe(e.steps,"id","Steps"),e.steps.some(a=>a.required)||
|
|
748
|
-
s("needs a required step.");for(let a of e.steps){let c=`step ${a.id}`;if(a.visual){let
|
|
749
|
-
shows undeclared visual ${a.visual.id}.`);for(let w of a.visual.play||[]){let I=
|
|
751
|
+
s("needs a required step.");for(let a of e.steps){let c=`step ${a.id}`;if(a.visual){let f=t.get(a.visual.id);f||s(`${c} \
|
|
752
|
+
shows undeclared visual ${a.visual.id}.`);for(let w of a.visual.play||[]){let I=f.commands.find(d=>d.name===w.name);I||s(
|
|
750
753
|
`${c} plays undeclared command ${w.name}.`);let S=w.parameters;(!S||typeof S!="object"||Array.isArray(S))&&s(`${c} comma\
|
|
751
754
|
nd ${w.name} needs a parameters object.`);for(let[d,p]of Object.entries(S)){let _=I.parameters.find(b=>b.name===d);_||s(
|
|
752
755
|
`${c} command ${w.name} has undeclared parameter ${d}.`),(typeof p!="string"||p.length>_.maxLength)&&s(`${c} command ${w.
|
|
753
756
|
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 ${w.name} needs parameter ${d.name}.`)}}if(a.guide){let{caption:
|
|
757
|
+
hasOwn(S,d.name)&&s(`${c} command ${w.name} needs parameter ${d.name}.`)}}if(a.guide){let{caption:f,...w}=a.guide;try{Fa(
|
|
755
758
|
w,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
|
|
757
|
-
beats: ${
|
|
758
|
-
kind==="check");
|
|
759
|
-
let w=
|
|
760
|
-
ect).`)}let
|
|
761
|
-
"fact"],self:[],none:[]}[
|
|
762
|
-
heck cannot declare ${
|
|
763
|
-
"fact"&&(e.schemaVersion!==3&&s(`${c} fact check needs lesson format 3.`),(!
|
|
764
|
-
an unknown fact; declare a host's fact in the topic's facts.`)),
|
|
765
|
-
mes an unknown check.`),e.exercise||s(`${c} runs a declared check and needs the lesson's exercise.`);let
|
|
766
|
-
I=>I.id===
|
|
767
|
-
k needs 1-8 exercise files":"names files, but only a code check edits files"}.`)}if(
|
|
768
|
-
s(`${c} review needs its rubric.`),e.exercise||s(`${c} reviews practice work and needs the lesson's exercise.`);let
|
|
769
|
-
evidence||["changes"];(
|
|
770
|
-
changes"] or ["changes", "conversation"].`)}if(
|
|
759
|
+
target} needs the lesson's exercise (a practice project).`)}let u=null;try{({beats:u}=Ur(o.get(a.body),i))}catch(f){s(`${c}\
|
|
760
|
+
beats: ${f.message}`)}if(u){a.guide&&s(`${c} has both beats and a guide; its beats replace the guide.`);let f=u.find(I=>I.
|
|
761
|
+
kind==="check");f&&Eo[f.target]!==a.check.kind&&s(`${c} beat check ${f.target} does not match its ${a.check.kind} check.`);
|
|
762
|
+
let w=u.find(I=>Ja(I,i));w&&!e.exercise&&s(`${c} beat ${w.kind} ${w.target} needs the lesson's exercise (a practice proj\
|
|
763
|
+
ect).`)}let l=a.check,m={auto:["check","files"],choice:["question","options","answer"],review:["rubric","evidence"],fact:[
|
|
764
|
+
"fact"],self:[],none:[]}[l.kind],h=Object.keys(l).filter(f=>f!=="kind"&&!m.includes(f));if(h.length&&s(`${c} ${l.kind} c\
|
|
765
|
+
heck cannot declare ${h.join(", ")}.`),l.kind==="none"&&a.required&&s(`${c} has no check and cannot be required.`),l.kind===
|
|
766
|
+
"fact"&&(e.schemaVersion!==3&&s(`${c} fact check needs lesson format 3.`),(!l.fact||!i.hasFact(l.fact))&&s(`${c} checks \
|
|
767
|
+
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\
|
|
768
|
+
mes an unknown check.`),e.exercise||s(`${c} runs a declared check and needs the lesson's exercise.`);let f=e.checks.find(
|
|
769
|
+
I=>I.id===l.check),w=l.files||[];(f.kind==="code"?w.length<1||w.length>8:w.length)&&s(`${c} ${f.kind==="code"?"code chec\
|
|
770
|
+
k needs 1-8 exercise files":"names files, but only a code check edits files"}.`)}if(l.kind==="review"){l.rubric?.trim()||
|
|
771
|
+
s(`${c} review needs its rubric.`),e.exercise||s(`${c} reviews practice work and needs the lesson's exercise.`);let f=l.
|
|
772
|
+
evidence||["changes"];(f[0]!=="changes"||f.length>2||f.length===2&&f[1]!=="conversation")&&s(`${c} review evidence is ["\
|
|
773
|
+
changes"] or ["changes", "conversation"].`)}if(l.kind==="choice"){let{question:f,options:w,answer:I}=l;(!f||!w||!I)&&s(`${c}\
|
|
771
774
|
choice needs question, options and answer.`),(w.length<2||w.length>8)&&s(`${c} choice needs 2-8 options.`),(!I.length||
|
|
772
775
|
new Set(I).size!==I.length||I.some(S=>S>=w.length))&&s(`${c} choice answer must list unique option indexes within its op\
|
|
773
|
-
tions.`)}}}async function
|
|
776
|
+
tions.`)}}}async function Im(e,t,{authoring:r,installed:n,vocabulary:o}){let i=await e.json(t.descriptor),s=$r(i.value,t.
|
|
774
777
|
code);if(s.code!==t.code)throw new Error(`Lesson code mismatch: ${t.code}.`);if(r&&s.schemaVersion!==3)throw new Error(`\
|
|
775
778
|
Lesson ${t.code} uses retired lesson format ${s.schemaVersion}. Author it in format 3 with steps and its stage.`);let a=ie.
|
|
776
|
-
dirname(i.filename),c=new Map;function
|
|
777
|
-
[...c.values()].reduce((p,_)=>p+_.bytes,0)>32*1024*1024)throw new Error(`Lesson ${t.code} exceeds bundle limits.`)}
|
|
778
|
-
let
|
|
779
|
-
checks||[]){
|
|
780
|
-
read(s.document,a),
|
|
781
|
-
read(d,a);
|
|
782
|
-
code} can declare app routes only with its exercise.`);let
|
|
779
|
+
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||
|
|
780
|
+
[...c.values()].reduce((p,_)=>p+_.bytes,0)>32*1024*1024)throw new Error(`Lesson ${t.code} exceeds bundle limits.`)}u(i);
|
|
781
|
+
let l=new Set,m=new Map;fe(s.prerequisites,"code","Lesson prerequisites");let h=fe(s.checks||[],"id","Checks");for(let d of s.
|
|
782
|
+
checks||[]){u(await e.read(d.file,a));for(let p of d.assets||[])u(await e.read(p,a))}if(s.schemaVersion===1&&vm(s,await e.
|
|
783
|
+
read(s.document,a),u,h),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.
|
|
784
|
+
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.
|
|
785
|
+
code} can declare app routes only with its exercise.`);let f=new Set;for(let d of s.appRoutes||[]){if(d.path!=="/"&&!d.path.
|
|
783
786
|
slice(1).split("/").every(_=>_===":id"||/^[A-Za-z0-9._~-]+$/u.test(_)))throw new Error(`Invalid app route path for ${t.code}\
|
|
784
|
-
: ${d.path}.`);let p=`${d.method} ${d.path}`;if(
|
|
785
|
-
.`);
|
|
787
|
+
: ${d.path}.`);let p=`${d.method} ${d.path}`;if(f.has(p))throw new Error(`Lesson ${t.code} has a duplicate app route: ${p}\
|
|
788
|
+
.`);f.add(p)}for(let d of s.checks||[])if(d.timeoutSeconds!==void 0&&d.kind!=="code")throw new Error(`Only a code check \
|
|
786
789
|
declares a timeout: ${d.id}.`);if(s.schemaVersion===1&&!s.assessments.some(d=>d.required))throw new Error(`Lesson ${t.code}\
|
|
787
790
|
needs a required assessment.`);fe(s.visuals,"id","Visuals");let w=new Map;for(let d of s.visuals){let p=await e.json(d.
|
|
788
791
|
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,
|
|
789
792
|
"Visual states");if(!b.has(_.initialState))throw new Error(`Unknown initial visual state: ${_.initialState}.`);fe(_.commands,
|
|
790
793
|
"name","Visual commands");for(let y of _.commands)if(fe(y.parameters,"name","Command parameters"),y.completionState!=="u\
|
|
791
|
-
nchanged"&&!b.has(y.completionState))throw new Error(`Unknown completion state: ${y.name}.`);
|
|
792
|
-
dirname(p.filename);for(let y of[_.svg,_.controller,..._.assets||[]]){let E=await e.read(y,v);
|
|
794
|
+
nchanged"&&!b.has(y.completionState))throw new Error(`Unknown completion state: ${y.name}.`);u(p),w.set(_.id,_);let v=ie.
|
|
795
|
+
dirname(p.filename);for(let y of[_.svg,_.controller,..._.assets||[]]){let E=await e.read(y,v);u(E),l.add(E.relative)}}if(s.
|
|
793
796
|
exercise){let d=s.exercise;if(d.reuse==="sequence"){if(!d.sequenceId||!d.sequenceMode)throw new Error(`Invalid exercise \
|
|
794
797
|
sequence for ${t.code}.`)}else if(d.sequenceId||d.sequenceMode)throw new Error(`Invalid exercise sequence for ${t.code}.`);
|
|
795
|
-
if(d.sequenceId&&!
|
|
796
|
-
for(let y of(await
|
|
798
|
+
if(d.sequenceId&&!Vr(d.sequenceId))throw new Error("Invalid exercise sequence ID.");let p=await e.resolve(d.source,a);async function _(v){
|
|
799
|
+
for(let y of(await _m(v,{withFileTypes:!0})).sort((E,A)=>E.name<A.name?-1:E.name>A.name?1:0)){if(Xa.has(y.name))continue;
|
|
797
800
|
let E=ie.relative(e.root,ie.join(v,y.name)),A=await e.resolve(E);if(y.isDirectory())await _(A.filename);else{let T=await e.
|
|
798
|
-
read(E);
|
|
801
|
+
read(E);u(T),l.add(T.relative)}}}await _(p.filename);let b=s.schemaVersion===1?s.assessments.map(v=>[`Code assessment ${v.
|
|
799
802
|
id}`,v.evidence?.files||[]]):s.steps.map(v=>[`Code step ${v.id}`,v.check.files||[]]);for(let[v,y]of b){for(let E of y){let A=E.
|
|
800
803
|
split("/");if(E.includes("\\")||ie.posix.isAbsolute(E)||A.some(T=>!T||T==="."||T===".."||Xa.has(T))||!c.has(p.relative?`${p.
|
|
801
804
|
relative}/${E}`:E))throw new Error(`${v} names a file outside its bundled exercise: ${E}.`)}if(new Set(y).size!==y.length)
|
|
802
|
-
throw new Error(`${v} repeats a declared file.`)}}let I="";if(me(s))try{
|
|
805
|
+
throw new Error(`${v} repeats a declared file.`)}}let I="";if(me(s))try{Sm(s,w,h,t.code,m,o)}catch(d){if(!n)throw d;I=d.
|
|
803
806
|
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{
|
|
804
|
-
lesson:s,manifest:S,hash:K(L(S)),descriptorPath:i.relative,served:
|
|
805
|
-
installed:n=!1}=t,o=await
|
|
806
|
-
test(i.value.version||""))throw new Error("Topic package needs a learn- name and an exact release version.");let s=ce(
|
|
807
|
-
i.value.vibe64Training,"Topic");if(!
|
|
807
|
+
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,
|
|
808
|
+
installed:n=!1}=t,o=await Em(e),i=await o.json("package.json");if(!/^learn-[a-z0-9-]+$/u.test(i.value.name||"")||!/^\d+\.\d+\.\d+$/u.
|
|
809
|
+
test(i.value.version||""))throw new Error("Topic package needs a learn- name and an exact release version.");let s=ce(jr,
|
|
810
|
+
i.value.vibe64Training,"Topic");if(!Vr(s.topicId)||!Vr(s.domainId))throw new Error("Invalid topic or domain ID.");let a=await o.
|
|
808
811
|
read(s.outline);if(fe(s.lessons,"code","Lessons"),fe(s.prerequisites,"topicId","Topic prerequisites"),!s.lessons.length)
|
|
809
812
|
throw new Error("A topic needs lessons.");if(s.status==="released"&&s.lessons.some(w=>w.required&&w.status!=="published"))
|
|
810
|
-
throw new Error("A released topic contains required draft lessons.");let c=
|
|
811
|
-
let{served:I,...S}=await
|
|
812
|
-
required:w.required})}for(let{descriptorPath:w,lesson:I}of
|
|
813
|
-
ptor cannot also be a step body, notes, visual or exercise file.`);
|
|
814
|
-
code:S}of I.lesson.prerequisites){let d=
|
|
815
|
-
t precede ${I.lesson.code}.`);if(I.status==="published"&&
|
|
816
|
-
lesson.code} requires draft ${S}.`)}let m=new Map;for(let{lesson:w,descriptorPath:I,status:S}of
|
|
813
|
+
throw new Error("A released topic contains required draft lessons.");let c=Mr(s),u=[],l=new Set;for(let w of s.lessons){
|
|
814
|
+
let{served:I,...S}=await Im(o,w,{authoring:r,installed:n,vocabulary:c});for(let d of I)l.add(d);u.push({...S,status:w.status,
|
|
815
|
+
required:w.required})}for(let{descriptorPath:w,lesson:I}of u)if(me(I)&&l.has(w))throw new Error(`Lesson ${I.code} descri\
|
|
816
|
+
ptor cannot also be a step body, notes, visual or exercise file.`);bm(u.map(w=>w.lesson));for(let[w,I]of u.entries())for(let{
|
|
817
|
+
code:S}of I.lesson.prerequisites){let d=u.findIndex(p=>p.lesson.code===S);if(d>=w)throw new Error(`Prerequisite ${S} mus\
|
|
818
|
+
t precede ${I.lesson.code}.`);if(I.status==="published"&&u[d].status!=="published")throw new Error(`Published lesson ${I.
|
|
819
|
+
lesson.code} requires draft ${S}.`)}let m=new Map;for(let{lesson:w,descriptorPath:I,status:S}of u){if(w.exercise?.reuse!==
|
|
817
820
|
"sequence")continue;let d=(await o.resolve(w.exercise.source,ie.dirname(ie.join(o.root,I)))).relative,p=m.get(w.exercise.
|
|
818
821
|
sequenceId);if(w.exercise.sequenceMode==="create"){if(p)throw new Error(`Invalid create/continue sequence: ${w.code}.`);
|
|
819
822
|
m.set(w.exercise.sequenceId,{source:d,status:S})}else if(!p||p.source!==d||S==="published"&&p.status!=="published")throw new Error(
|
|
820
|
-
`Invalid create/continue sequence: ${w.code}.`)}let
|
|
821
|
-
|
|
822
|
-
code,hash:I,status:S,required:d}))};return Be([
|
|
823
|
-
topicHash:K(L(
|
|
824
|
-
test(e)});import{execFile as
|
|
825
|
-
import{promisify as
|
|
823
|
+
`Invalid create/continue sequence: ${w.code}.`)}let h=[i,a].map(w=>({path:w.relative,sha256:K(w.bytes),bytes:w.bytes.length})),
|
|
824
|
+
f={schemaVersion:1,topic:s,release:i.value.version,files:h,lessons:u.map(({lesson:w,hash:I,status:S,required:d})=>({code:w.
|
|
825
|
+
code,hash:I,status:S,required:d}))};return Be([f,...u.map(w=>w.manifest)]),{topic:s,release:i.value.version,bundles:u,topicManifest:f,
|
|
826
|
+
topicHash:K(L(f))}}var Xa,Vr,dt=g(()=>{ut();Dr();bo();lt();Xa=new Set([".git","node_modules",".genesis"]),Vr=e=>/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u.
|
|
827
|
+
test(e)});import{execFile as Tm}from"node:child_process";import{readFile as Am}from"node:fs/promises";import vo from"node:os";import Om from"node:path";
|
|
828
|
+
import{promisify as Pm}from"node:util";function ec(e=""){let t=V(e);if(!t||t.includes("/")||t.includes("\\")||t.includes(
|
|
826
829
|
":")){let r=new Error("A valid OS username is required.");throw r.code="vibe64_invalid_os_username",r}return t}function tc([
|
|
827
830
|
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(
|
|
828
831
|
s)||!Number.isSafeInteger(a)?null:{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),
|
|
829
832
|
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
|
|
833
|
+
t[3],t[4],t[5],t[6]])}function Nm(e=""){return String(e||"").split(/\r?\n[\t ]*\r?\n/u).map(t=>{let r={};for(let n of t.
|
|
831
834
|
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
835
|
dir,r.shell])}).filter(Boolean)}async function Za(e,t,r){let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="\
|
|
833
836
|
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=
|
|
837
|
+
env.USER||process.env.LOGNAME),o=Om.resolve(String(r?.homedir||e()||""));return{displayName:String(r?.username||n),gid:Number.
|
|
835
838
|
isSafeInteger(r?.gid)?r.gid:null,home:o,shell:String(r?.shell||""),uid:Number.isSafeInteger(r?.uid)?r.uid:null,username:n}}
|
|
836
|
-
async function
|
|
839
|
+
async function Gr(e="",{execFileFn:t=Rm,platform:r=process.platform,readFileFn:n=Am,userInfo:o=vo.userInfo}={}){let i=ec(
|
|
837
840
|
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)],
|
|
838
|
-
|
|
839
|
-
"/etc/passwd","utf8").catch(()=>"")).split(/\r?\n/u).map(So).find(
|
|
840
|
-
n"){let a=Mt({userInfo:o});if(a.username===i)return a;[s]=
|
|
841
|
+
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(
|
|
842
|
+
"/etc/passwd","utf8").catch(()=>"")).split(/\r?\n/u).map(So).find(h=>h?.username===i);if(m)return m}}let s;if(r==="darwi\
|
|
843
|
+
n"){let a=Mt({userInfo:o});if(a.username===i)return a;[s]=Nm(await Za(t,"dscacheutil",["-q","user","-a","name",i]))}else
|
|
841
844
|
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
|
|
843
|
-
isSafeInteger(t)&&t>=0?t:null}function C(e=""){let t=R(e);return t?
|
|
844
|
-
t);if(!r||!n)return!1;let o=
|
|
845
|
-
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function
|
|
845
|
+
nd: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var Rm,Jb,Br=g(()=>{G();Rm=Pm(Tm);Jb=Object.freeze({parsePasswdLine:So})});var rc=g(()=>{Br();G()});import Hr from"node:path";function R(e=""){return String(e??"").trim()}function Io(e=null){let t=Number(e);return Number.
|
|
846
|
+
isSafeInteger(t)&&t>=0?t:null}function C(e=""){let t=R(e);return t?Hr.resolve(t):""}function Pe(e="",t=""){let r=C(e),n=C(
|
|
847
|
+
t);if(!r||!n)return!1;let o=Hr.relative(r,n);return o!==".."&&!o.startsWith(`..${Hr.sep}`)&&!Hr.isAbsolute(o)}function J(e={}){
|
|
848
|
+
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ue(e={}){return Object.fromEntries(Object.entries(J(e)).map(
|
|
846
849
|
([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
850
|
[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
|
|
851
|
+
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 Cm from"node:os";import To from"node:path";function Ao(e={}){let t=R(e.username),r=C(e.home||(t?`/home/${t}`:Cm.homedir()));
|
|
849
852
|
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
|
|
853
|
+
Mt())}async function Po(e="",t={}){return Ao(await Gr(e,t))}function Dt(e={},t={}){let r=Ao(e);return{...t,HOME:r.home,LOGNAME:r.
|
|
851
854
|
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
855
|
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(()=>{
|
|
854
|
-
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:
|
|
855
|
-
let
|
|
856
|
-
`)).trim();return{code:R(e),error:R(t),exitCode:
|
|
857
|
-
Number(s):null,signal:R(a),stderr:I,stdout:w,...i==="base64"?{outputEncoding:i}:{},timedOut:
|
|
858
|
-
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof
|
|
856
|
+
getuid=="function"?process.getuid():null}}var mt=g(()=>{Br();q()});function km(e=0){let t=Number(e);return Number.isSafeInteger(t)?t:1}function Ut({code:e="",error:t="",exitCode:r=0,ok:n=null,
|
|
857
|
+
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:l=!1,execution:m=null,retryable:h=null}={}){
|
|
858
|
+
let f=km(r),w=String(u||""),I=String(c||""),S=String(o||[w,I].filter(Boolean).join(`
|
|
859
|
+
`)).trim();return{code:R(e),error:R(t),exitCode:f,ok:n===null?f===0:n===!0,output:S,pid:Number.isSafeInteger(Number(s))?
|
|
860
|
+
Number(s):null,signal:R(a),stderr:I,stdout:w,...i==="base64"?{outputEncoding:i}:{},timedOut:l===!0,...m&&typeof m=="obje\
|
|
861
|
+
ct"&&!Array.isArray(m)?{execution:m}:{},...typeof h=="boolean"?{retryable:h}:{}}}function X(e="",t="vibe64_command_faile\
|
|
859
862
|
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
|
|
861
|
-
import{stripVTControlCharacters as
|
|
862
|
-
let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.toString(16)}`})}function
|
|
863
|
+
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}var Fe=g(()=>{q()});import{spawn as xm}from"node:child_process";import{statSync as $m}from"node:fs";import jm from"node:path";import{StringDecoder as Lm}from"node:string_decoder";
|
|
864
|
+
import{stripVTControlCharacters as Mm}from"node:util";function ac(e){return e.replaceAll(Vm,t=>{if(ic[t]!==void 0)return ic[t];
|
|
865
|
+
let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.toString(16)}`})}function Gm(e){return Mm(
|
|
863
866
|
e).split(`
|
|
864
867
|
`).map(ac).join(`
|
|
865
|
-
`)}function
|
|
866
|
-
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function
|
|
867
|
-
return r;try{if(
|
|
868
|
+
`)}function Bm(e,t){return[e,...t].map(r=>{let n=ac(String(r));return Um.test(n)?n:process.platform==="win32"?`"${n.replaceAll(
|
|
869
|
+
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function Hm(e,t){let r=String(e?.message??e);if(t===process.cwd())
|
|
870
|
+
return r;try{if(!$m(t).isDirectory())return`The "cwd" option is not a directory: ${t}.
|
|
868
871
|
${r}`}catch(n){return`The "cwd" option is invalid: ${t}.
|
|
869
872
|
${n.message}
|
|
870
|
-
${r}`}return r}function
|
|
873
|
+
${r}`}return r}function zm(e){let t=e.forcefullyTerminated?` and was forcefully terminated after ${sc} milliseconds`:"";
|
|
871
874
|
if(e.timedOut)return`Command timed out after ${e.timeout} milliseconds${t}`;if(e.maxBuffer)return`Command's ${e.maxBuffer.
|
|
872
875
|
stream} was larger than ${e.maxBuffer.limit} ${e.maxBuffer.unit}${t}`;if(e.spawnError?.code!==void 0)return`Command fail\
|
|
873
|
-
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=
|
|
874
|
-
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function
|
|
875
|
-
|
|
876
|
-
${t}`:""}`}function Ro(e,t){let r=new
|
|
876
|
+
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=Dm[e.signal];return`Command was killed with ${e.signal}${r?` (${r})`:
|
|
877
|
+
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function Fm(e){let t=e.spawnError?
|
|
878
|
+
Gm(Hm(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${zm(e)}: ${e.commandLine}${t?`
|
|
879
|
+
${t}`:""}`}function Ro(e,t){let r=new Lm(e),n=[],o=0,i=!1;return{write(s){if(i)return!1;let a=r.write(s);return o+a.length>
|
|
877
880
|
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)),
|
|
878
881
|
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
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
w=!1,I=null,S=()=>{};
|
|
883
|
-
()=>{!w&&
|
|
884
|
-
{limit:
|
|
885
|
-
on("data",p("stdout",
|
|
886
|
-
|
|
887
|
-
w=!0,clearTimeout(_),clearTimeout(I);let A=
|
|
888
|
-
T=
|
|
889
|
-
shortMessage:T?
|
|
890
|
-
once("close",S)}),kill:v=>
|
|
882
|
+
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,
|
|
883
|
+
h=xm(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[m?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
884
|
+
f={commandLine:Bm(e,t),cwd:jm.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
885
|
+
w=!1,I=null,S=()=>{};h.on("error",v=>{f.spawnError||=v,h.pid===void 0&&S()});let d=()=>{w||!h.kill("SIGTERM")||I||(I=setTimeout(
|
|
886
|
+
()=>{!w&&h.kill("SIGKILL")&&(f.forcefullyTerminated=!0)},sc))},p=(v,y)=>E=>{if(l.all.write(E),l[v].write(E)||(f.maxBuffer||=
|
|
887
|
+
{limit:u,stream:v,unit:"characters"},y.destroy()),typeof s=="function")try{s(String(E||""))}catch{}};h.stdout&&h.stdout.
|
|
888
|
+
on("data",p("stdout",h.stdout)),h.stderr&&h.stderr.on("data",p("stderr",h.stderr)),m&&h.stdin&&(h.stdin.on("error",()=>{}),
|
|
889
|
+
h.stdin.end(o));let _=c>0?setTimeout(()=>{f.timedOut=!0,d()},c):null;return{completion:new Promise(v=>{S=(y,E)=>{if(w)return;
|
|
890
|
+
w=!0,clearTimeout(_),clearTimeout(I);let A=f.spawnError?{}:{exitCode:typeof y=="number"&&y>=0?y:void 0,signal:E||void 0},
|
|
891
|
+
T=f.spawnError||f.timedOut||f.maxBuffer||A.exitCode!==0;v({all:l.all.text(),code:f.spawnError?.code,exitCode:A.exitCode,
|
|
892
|
+
shortMessage:T?Fm({...f,...A}):"",signal:A.signal,stderr:l.stderr.text(),stdout:l.stdout.text(),timedOut:f.timedOut})},h.
|
|
893
|
+
once("close",S)}),kill:v=>h.kill(v),pid:h.pid}}var oc,sc,Dm,Um,Vm,ic,uc=g(()=>{oc=1e8,sc=5e3,Dm=Object.freeze({SIGABRT:"\
|
|
891
894
|
Aborted",SIGALRM:"Timeout or timer",SIGHUP:"Terminal closed",SIGINT:"User interruption with CTRL-C",SIGKILL:"Forced term\
|
|
892
895
|
ination",SIGPIPE:"Broken pipe or socket",SIGQUIT:"User interruption with CTRL-\\",SIGSEGV:"Segmentation fault",SIGTERM:"\
|
|
893
|
-
Termination",SIGUSR1:"Application-specific signal",SIGUSR2:"Application-specific signal"}),
|
|
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
|
|
895
|
-
import
|
|
896
|
-
let t=pc(process.execPath,[
|
|
896
|
+
Termination",SIGUSR1:"Application-specific signal",SIGUSR2:"Application-specific signal"}),Um=/^[\w./-]+$/u,Vm=new RegExp(
|
|
897
|
+
"\\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 Wm,open as Ym,readdir as Jm,readFile as Km}from"node:fs/promises";
|
|
898
|
+
import Xm from"node:path";import{fileURLToPath as Qm}from"node:url";function rf(e){if(process.platform!=="win32"){if(!de){
|
|
899
|
+
let t=pc(process.execPath,[tf],{cwd:"/",detached:!0,stdio:["pipe","ignore","ignore"]});t.once("error",()=>{de===t&&(de=null)}),
|
|
897
900
|
t.once("exit",()=>{de===t&&(de=null)}),t.stdin.on("error",()=>{}),t.unref(),t.stdin.unref(),de=t;for(let r of qe.values())
|
|
898
901
|
r.scopeEmpty!==!0&&r.pid!==e&&t.stdin.write(`+${r.pid}
|
|
899
902
|
`)}de.stdin.write(`+${e}
|
|
900
|
-
`)}}function
|
|
901
|
-
`),![...qe.values()].some(t=>t.scopeEmpty!==!0)&&(de.stdin.end(),de=null))}async function
|
|
902
|
-
dirname(e),{recursive:!0}),
|
|
903
|
+
`)}}function nf(e){de&&(de.stdin.write(`-${e}
|
|
904
|
+
`),![...qe.values()].some(t=>t.scopeEmpty!==!0)&&(de.stdin.end(),de=null))}async function of(e=""){return e?(await Wm(Xm.
|
|
905
|
+
dirname(e),{recursive:!0}),Ym(e,"w",384)):null}async function sf(e){return new Promise((t,r)=>{let n=!1,o=(i,s)=>{n||(n=
|
|
903
906
|
!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
|
|
905
|
-
detached:!0,env:n,stdio:i});await
|
|
906
|
-
s.pid)),s.once("exit",()=>{!
|
|
907
|
+
try{o=await of(e.logPath);let i=o?["ignore",o.fd,o.fd]:["ignore","ignore","ignore"],s=pc(e.command,e.args,{cwd:r||void 0,
|
|
908
|
+
detached:!0,env:n,stdio:i});await sf(s);let a=e.execution?.id||"";return a&&(qe.set(a,{child:s,pid:Number(s.pid)}),rf(Number(
|
|
909
|
+
s.pid)),s.once("exit",()=>{!zr(s.pid)&&qe.has(a)&&(qe.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),nf(Number(s.pid)))})),
|
|
907
910
|
s.unref(),Ut({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return X(i?.
|
|
908
911
|
message||"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{
|
|
909
|
-
await o?.close().catch(()=>null)}}function
|
|
912
|
+
await o?.close().catch(()=>null)}}function zr(e=null){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;if(process.
|
|
910
913
|
platform==="win32"){let r=[...qe.values()].find(n=>n.pid===t);return r?.child?.exitCode===null&&r?.child?.signalCode===null}
|
|
911
|
-
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function
|
|
914
|
+
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function lc(e=null,t="SIGTERM"){if(!zr(e))return!1;try{
|
|
912
915
|
return process.platform==="win32"?[...qe.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),
|
|
913
916
|
!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
|
|
915
|
-
if(!/^\d+$/u.test(o))continue;let i=await
|
|
917
|
+
"linux"||!Number.isSafeInteger(r)||r<=0)return[];let n=[];for(let o of await Jm("/proc").catch(()=>[])){if(n.length>=t)break;
|
|
918
|
+
if(!/^\d+$/u.test(o))continue;let i=await Km(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(
|
|
916
919
|
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(;
|
|
918
|
-
async function
|
|
919
|
-
(
|
|
920
|
-
cution/src/server/engines/detached.js",import.meta.url).href,qe=new Map,
|
|
921
|
-
|
|
922
|
-
outputEncoding:
|
|
923
|
-
if(
|
|
924
|
-
maxBuffer:a,onOutput:c,outputEncoding:
|
|
925
|
-
A=
|
|
926
|
-
i.id,
|
|
927
|
-
b.completion:{exitCode:1})]),E=typeof y.exitCode=="number"?y.exitCode:1;
|
|
920
|
+
let r=Date.now()+Math.max(0,Number(t)||0);for(;zr(e)&&Date.now()<r;)await new Promise(n=>setTimeout(n,25));return!zr(e)}
|
|
921
|
+
async function Fr(e=null,t={}){let{killTimeoutMs:r=ef,termTimeoutMs:n=Zm}=t;lc(e,"SIGTERM");let o=await dc(e,n);return o||
|
|
922
|
+
(lc(e,"SIGKILL"),o=await dc(e,r)),o}var qm,qe,Zm,ef,tf,de,Vt=g(()=>{Fe();qm=new URL("./../node_modules/@local/vibe64-exe\
|
|
923
|
+
cution/src/server/engines/detached.js",import.meta.url).href,qe=new Map,Zm=3e3,ef=1e3,tf=Qm(new URL("./detachedReaper.js",
|
|
924
|
+
qm)),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,
|
|
925
|
+
outputEncoding:u="utf8",signal:l=null,timeout:m=15e3}=r,h,f,w,I=null,S=Promise.withResolvers(),d=()=>{w||=f(),w.then(S.resolve)};
|
|
926
|
+
if(l?.aborted)return X("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let b=cc(e,t,{cwd:n,env:o,input:s,
|
|
927
|
+
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:m});I=Number(b.pid);let v;f=()=>{if(!v){let A;process.platform!=="win32"?
|
|
928
|
+
A=Fr(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(
|
|
929
|
+
i.id,f),l?.addEventListener("abort",d,{once:!0}),l?.aborted&&d();let y=await Promise.race([b.completion,S.promise.then(A=>A?
|
|
930
|
+
b.completion:{exitCode:1})]),E=typeof y.exitCode=="number"?y.exitCode:1;h=Ut({code:y.timedOut===!0?"vibe64_command_captu\
|
|
928
931
|
re_timed_out":y.code?"vibe64_command_capture_failed":"",error:E===0?"":y.shortMessage,exitCode:E,output:y.all||(E===0?"":
|
|
929
|
-
y.shortMessage),outputEncoding:
|
|
930
|
-
|
|
931
|
-
if(!await(w||
|
|
932
|
+
y.shortMessage),outputEncoding:u,signal:y.signal,stderr:y.stderr,stdout:y.stdout,timedOut:y.timedOut===!0,execution:i})}catch(b){
|
|
933
|
+
h=X(b.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{l?.removeEventListener("abort",d)}
|
|
934
|
+
if(!await(w||f?.()||!0)){let b=await fc(I),v=h?.timedOut?"The command timed out":l?.aborted?"The command was cancelled":
|
|
932
935
|
"The command finished",y=b.length?`: ${b.map(E=>`${E.command} (pid ${E.pid})`).join(", ")} still running`:"";return{...X(
|
|
933
|
-
`${v}, and its execution scope did not become empty${y}.`,"vibe64_execution_drain_failed",{execution:i,output:
|
|
934
|
-
outputEncoding:
|
|
935
|
-
hc.delete(i.id);let _=i&&{...i,state:"finished"};return
|
|
936
|
-
execution:_,outputEncoding:
|
|
936
|
+
`${v}, and its execution scope did not become empty${y}.`,"vibe64_execution_drain_failed",{execution:i,output:h?.output,
|
|
937
|
+
outputEncoding:u,signal:h?.signal,stderr:h?.stderr,stdout:h?.stdout,timedOut:h?.timedOut}),remainingProcesses:b}}i?.id&&
|
|
938
|
+
hc.delete(i.id);let _=i&&{...i,state:"finished"};return l?.aborted?X("Command cancelled.","vibe64_command_cancelled",{...h,
|
|
939
|
+
execution:_,outputEncoding:u}):_?{...h,execution:_}:h}var hc,Bt=g(()=>{Fe();uc();Vt();hc=new Map});function he(){return globalThis[af]||cf}var af,cf,Re=g(()=>{af=Symbol.for("vibe64.hostProfile"),cf=Object.freeze({runtimePackRoot:"",
|
|
937
940
|
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
941
|
r running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}function gc(e={}){return{
|
|
939
|
-
...e,schema:
|
|
942
|
+
...e,schema:uf,schemaVersion:lf}}function qr({actor:e={},command:t="",cwd:r="",env:n={},input:o,operation:i="vibe64-comm\
|
|
940
943
|
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.
|
|
941
944
|
user?.home,inputBase64:o==null?"":Buffer.isBuffer(o)?o.toString("base64"):Buffer.from(String(o)).toString("base64"),operation:i,
|
|
942
945
|
uid:e.user?.uid,username:e.user?.username})}function Ht(e={}){return e.mode==="pty"&&e.envPolicy==="auth"&&!["assistant",
|
|
@@ -949,83 +952,83 @@ d":e.purpose==="github-api"?"github-api-command":e.purpose==="workspace-cache"?"
|
|
|
949
952
|
alth"?"health-status":"vibe64-command"}async function Co(e={},{env:t,helperPath:r="",maxBuffer:n=void 0,outputEncoding:o="\
|
|
950
953
|
utf8",runCapture:i=Gt,signal:s=null,timeout:a=15e3}){let c={env:t,input:`${JSON.stringify(e)}
|
|
951
954
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
952
|
-
udo",["-n",No(r),"execute"],c)}var
|
|
953
|
-
upport/symlinkSafeRequire.js",import.meta.url).href,
|
|
954
|
-
{callbackPath:"/auth/login",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
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
|
|
956
|
-
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var $o=g(()=>{G()});import
|
|
955
|
+
udo",["-n",No(r),"execute"],c)}var uf,lf,Wr=g(()=>{Bt();Re();uf="vibe64.exec-helper.payload",lf=1});import{createRequire as pf}from"node:module";var df,Nv,wc=g(()=>{df=new URL("./../node_modules/@jskit-ai/kernel/server/s\
|
|
956
|
+
upport/symlinkSafeRequire.js",import.meta.url).href,Nv=pf(df)});var Lv,Mv,Dv,Uv,yc=g(()=>{G();Lv=Object.freeze(["bundled","dev_server"]),Mv=Object.freeze(["capacitor"]),Dv=Object.freeze(
|
|
957
|
+
{callbackPath:"/auth/login",customScheme:"",appLinkDomains:Object.freeze([])}),Uv=Object.freeze({packageName:"",minSdk:26,
|
|
958
|
+
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 oS,iS,vc=g(()=>{jt();G();bc();ko();oS=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),iS=Object.
|
|
959
|
+
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var $o=g(()=>{G()});import hf from"node:child_process";import{constants as jo}from"node:fs";import{open as gf}from"node:fs/promises";import Lo from"node:path";
|
|
957
960
|
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
961
|
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
|
|
962
|
+
th.`,r);return n}function yf(e,t){return new Promise((r,n)=>{let o=hf.spawn("/usr/bin/flock",["--exclusive","--nonblock",
|
|
960
963
|
"3"],{cwd:t,env:{PATH:"/usr/bin:/bin"},stdio:["ignore","ignore","pipe",e]}),i="";o.stderr.on("data",s=>{i=`${i}${String(
|
|
961
964
|
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
|
|
963
|
-
432),s;try{s=await
|
|
964
|
-
ck failed."),r)}if(s.status!==0){if(await i.close(),s.status===
|
|
965
|
-
ed${s.stderr?`: ${s.stderr}`:"."}`,r)}let a=!1;return async()=>{a||(a=!0,await i.close())}}var Do,
|
|
966
|
-
lock_failed",
|
|
965
|
+
errorCode:r=Do}={}){let n=Sc(e,"lockPath",r),o=t?Sc(t,"cwd",r):Lo.dirname(n),i=await gf(n,jo.O_CREAT|jo.O_NOFOLLOW|jo.O_RDWR,
|
|
966
|
+
432),s;try{s=await yf(i.fd,o)}catch(c){throw await i.close().catch(()=>null),Mo(c?.message||String(c||"Exclusive file lo\
|
|
967
|
+
ck failed."),r)}if(s.status!==0){if(await i.close(),s.status===wf)return null;throw Mo(`Exclusive file lock process fail\
|
|
968
|
+
ed${s.stderr?`: ${s.stderr}`:"."}`,r)}let a=!1;return async()=>{a||(a=!0,await i.close())}}var Do,wf,Ic=g(()=>{Do="file_\
|
|
969
|
+
lock_failed",wf=1});var _f,fS,Tc=g(()=>{_f="jskit-client-build",fS=new RegExp(`<meta name="${_f}" content="([0-9a-f]+)"`,"u")});import bf from"node:path";var ES,Ac=g(()=>{Tc();$o();ES=bf.join("dist","index.html")});var Yr=g(()=>{wc();_c();Ec();xo();vc();$o();Ic();Ac()});var Oc=g(()=>{Yr()});function vf(e={}){return Ie(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
967
970
|
session?.metadata?.session_git_command_actor_user_key)}async function Pc(e={}){let t=R(e.actor)||"daemon";if(t==="app"&&
|
|
968
971
|
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=
|
|
972
|
+
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:Oo()};let r=vf(e);if(!r){let n=new Error(
|
|
970
973
|
"A user key is required for real-user command execution.");throw n.code="vibe64_command_actor_user_required",n}return{actor:t,
|
|
971
974
|
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
|
|
975
|
+
user?.gid}function Uo(){return!!he().execHelperPath}function Jr(e={}){return e.requiresRealUser?Uo()||!ht(e):!1}function Cc(e={},t={},r=""){
|
|
973
976
|
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(
|
|
974
977
|
"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\
|
|
975
978
|
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
979
|
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
|
|
980
|
+
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var Kr=g(()=>{mt();Re();q()});function Xr(...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,Qr=g(()=>{
|
|
978
981
|
q();zt=Object.freeze(["DATABASE_URL","DB_CLIENT","DB_DATABASE","DB_HOST","DB_NAME","DB_PASSWORD","DB_PORT","DB_USER","DB\
|
|
979
982
|
_USERNAME","MYSQL_DATABASE","MYSQL_HOST","MYSQL_PWD","MYSQL_TCP_PORT","PGDATABASE","PGHOST","PGPASSWORD","PGPORT","PGUSE\
|
|
980
|
-
R","VIBE64_MYSQL_USER"])});import{spawn as
|
|
981
|
-
import{stat as Vc}from"node:fs/promises";import
|
|
982
|
-
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function
|
|
983
|
+
R","VIBE64_MYSQL_USER"])});import{spawn as Sf,spawnSync as If}from"node:child_process";import{createHash as Tf}from"node:crypto";import{statSync as Uc}from"node:fs";
|
|
984
|
+
import{stat as Vc}from"node:fs/promises";import Zr from"node:path";function $c(e="",t="vibe64"){return R(e).toLowerCase().
|
|
985
|
+
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function Pf(...e){for(let t of e){let r=J(t),n=J(r.user),
|
|
983
986
|
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,
|
|
984
987
|
r.user_email,r.gitUserEmail,r.git_user_email,n.email,n.userEmail,n.user_email);if(o&&i)return{authorEmail:i,authorName:o,
|
|
985
|
-
committerEmail:i,committerName:o,source:"configured"}}return null}function
|
|
988
|
+
committerEmail:i,committerName:o,source:"configured"}}return null}function Rf(e={}){let t=J(e),r=Ie(t.name,t.displayName,
|
|
986
989
|
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
|
|
990
|
+
committerName:r,source:"github"}}function Nf({workspace:e="",userKey:t=""}={}){let r=$c(t,"user"),n=$c(e,"local");return{
|
|
988
991
|
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&&
|
|
992
|
+
fallback"}}function Vo(e=""){let t=R(e);return t&&Zr.isAbsolute(t)?t:""}function jc(e=""){let t=Vo(e);try{return t&&Uc(t).
|
|
990
993
|
isDirectory()?t:""}catch{return""}}async function Lc(e=""){let t=Vo(e);return t&&await Vc(t).then(r=>r.isDirectory(),()=>!1)?
|
|
991
994
|
t:""}function Hc(e=""){let t={};for(let r of String(e||"").split(`
|
|
992
995
|
`)){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:
|
|
996
|
+
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:Af}}function Mc(e,t){let r=If("git",Gc,{...zc(e,t),encoding:"\
|
|
994
997
|
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=
|
|
998
|
+
null}}function Dc(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=Sf("git",Gc,zc(e,t));s.stdout.setEncoding(
|
|
996
999
|
"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,
|
|
997
1000
|
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
1001
|
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function qc(e={}){return{...e,PATH:process.
|
|
999
1002
|
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?
|
|
1001
|
-
g"):""].filter(Boolean)}async function
|
|
1002
|
-
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function
|
|
1003
|
+
e.HOME),r=R(e.XDG_CONFIG_HOME)||(t?Zr.join(t,".config"):"");return[r?Zr.join(r,"git","config"):"",t?Zr.join(t,".gitconfi\
|
|
1004
|
+
g"):""].filter(Boolean)}async function Cf(e={}){return(await Promise.all(Wc(e).map(r=>Vc(r).then(n=>`${n.ino}:${n.size}:${n.
|
|
1005
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function kf(e={}){return Wc(e).map(t=>{try{let r=Uc(t);return`${r.ino}\
|
|
1003
1006
|
:${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
|
|
1007
|
+
([o],[i])=>o<i?-1:o>i?1:0);return Tf("sha256").update(JSON.stringify([e,t,n])).digest("hex")}async function xf(e,t,r){let n=e?
|
|
1005
1008
|
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
|
|
1009
|
+
function $f(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
1010
|
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
|
|
1009
|
-
read).values;let a={expiresAt:i+Bc,read:
|
|
1010
|
-
a&&We.delete(n):a.values=c.values,c.values}function
|
|
1011
|
-
hasOwn(s,"values"))return s.values;let a
|
|
1012
|
-
revision:o,values:a.values}),a.values}async function
|
|
1013
|
-
let[r,n]=await Promise.all([Lc(e),Lc(t.HOME)]);return Fc(await
|
|
1014
|
-
typeof t!="object"?null:Fc(
|
|
1011
|
+
r&&We.delete(o);return null}async function jf(e,t,r){let n=Yc(e,t,r),o=await Cf(r),i=Date.now(),s=Jc(n,o,i);if(s)return(await s.
|
|
1012
|
+
read).values;let a={expiresAt:i+Bc,read:xf(e,t,r),revision:o};We.set(n,a);let c=await a.read;return c.transient?We.get(n)===
|
|
1013
|
+
a&&We.delete(n):a.values=c.values,c.values}function Lf(e,t,r){let n=Yc(e,t,r),o=kf(r),i=Date.now(),s=Jc(n,o,i);if(s&&Object.
|
|
1014
|
+
hasOwn(s,"values"))return s.values;let a=$f(e,t,r);return a.transient||We.set(n,{expiresAt:i+Bc,read:Promise.resolve(a),
|
|
1015
|
+
revision:o,values:a.values}),a.values}async function Mf({cwd:e="",env:t=null}={}){if(!t||typeof t!="object")return null;
|
|
1016
|
+
let[r,n]=await Promise.all([Lc(e),Lc(t.HOME)]);return Fc(await jf(r,n,qc(t)))}function Df({cwd:e="",env:t=null}={}){return!t||
|
|
1017
|
+
typeof t!="object"?null:Fc(Lf(jc(e),jc(t.HOME),qc(t)))}function Uf(e={}){let t=J(e),r=R(t.name),n=R(t.email);return!r||!n?
|
|
1015
1018
|
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
|
|
1017
|
-
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||
|
|
1018
|
-
let i=J(n.metadata);return
|
|
1019
|
+
project:r={},session:n={}}){let o=J(n.metadata);return Pf(r.gitIdentity,r.config?.git,n.gitIdentity,o.git_identity,{name:e.
|
|
1020
|
+
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||Uf(t)}function Xc({actor:e={},env:t,project:r={},session:n={},userKey:o=""}){
|
|
1021
|
+
let i=J(n.metadata);return Rf(r.githubUser||n.githubUser||i.github_user)||Nf({workspace:Ie(r.workspace,t.VIBE64_WORKSPACE,
|
|
1019
1022
|
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
|
|
1023
|
+
LOGNAME)})}async function Vf(e){return Kc(e)||await Mf(e.gitConfig||{})||Xc(e)}function Gf(e){return Kc(e)||Df(e.gitConfig||
|
|
1021
1024
|
{})||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
|
|
1023
|
-
ME",Je="GIT_AUTHOR_EMAIL",Ke="GIT_COMMITTER_NAME",Xe="GIT_COMMITTER_EMAIL",xc=".users.vibe64.invalid",
|
|
1024
|
-
"--get-regexp","^user\\.(name|email)$"],Bc=3e4,
|
|
1025
|
+
return Qc(await Vf(e))}function eu(e){return Qc(Gf(e))}var Ye,Je,Ke,Xe,xc,Af,Gc,Bc,Of,We,gt=g(()=>{q();Ye="GIT_AUTHOR_NA\
|
|
1026
|
+
ME",Je="GIT_AUTHOR_EMAIL",Ke="GIT_COMMITTER_NAME",Xe="GIT_COMMITTER_EMAIL",xc=".users.vibe64.invalid",Af=2e3,Gc=["config",
|
|
1027
|
+
"--get-regexp","^user\\.(name|email)$"],Bc=3e4,Of=['git config --global user.name "Your Name"','git config --global user\
|
|
1025
1028
|
.email "you@example.com"'].join(`
|
|
1026
1029
|
`);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
|
|
1028
|
-
let e=Q();return e?[Go.join(e,"policy-bin")]:[]}function
|
|
1030
|
+
wt[R(e)]?.binDirs||[]:[]).map(n=>Go.join(t,n))}function tu(){let e=Q();return e?[Go.join(e,"guard-bin")]:[]}function zo(){
|
|
1031
|
+
let e=Q();return e?[Go.join(e,"policy-bin")]:[]}function Bf(e=""){let t=R(e);return[...wt[t]?.managedCommands||[]]}var wt,
|
|
1029
1032
|
Bo,lI,ge=g(()=>{q();Re();wt=Object.freeze({awsebcli:{binDirs:["awsebcli/bin"],managedCommands:["eb"]},bubblewrap:{binDirs:[
|
|
1030
1033
|
"bubblewrap/bin"],managedCommands:[]},bun:{binDirs:["bun/bin"],dependencyFiles:["package.json","bun.lock","bun.lockb","p\
|
|
1031
1034
|
ackage-lock.json"],managedCommands:["bun"]},composer:{binDirs:["composer/bin"],dependencyFiles:["composer.json","compose\
|
|
@@ -1057,275 +1060,275 @@ in"],managedCommands:["php"]},playwright:{binDirs:["playwright/bin"],identityPat
|
|
|
1057
1060
|
g_isready","postgres","psql"]},ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:[
|
|
1058
1061
|
"sqlite3"]}}),Bo=Object.freeze(["operator-clis","node26","git","gh","mysql","mariadb","postgresql","sqlite","ripgrep","b\
|
|
1059
1062
|
ubblewrap","bun","php","composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);lI=
|
|
1060
|
-
Object.freeze({runtimePackManagedCommands:
|
|
1061
|
-
if(!t)return"";let r=
|
|
1062
|
-
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!
|
|
1063
|
-
`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function
|
|
1064
|
-
r=C(he().sharedCacheRoot),n=
|
|
1065
|
-
{[qo]:n}:{}}}var
|
|
1066
|
-
ATH",Fo="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",qo="VIBE64_PLAYWRIGHT_VERSION",
|
|
1067
|
-
|
|
1068
|
-
llers cannot provide execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function
|
|
1069
|
-
let{envPolicy:r="session"}=t,n=
|
|
1070
|
-
"deployment"?o:{...o,...
|
|
1063
|
+
Object.freeze({runtimePackManagedCommands:Bf})});import{readFileSync as Hf}from"node:fs";import ru from"node:path";function Wf({runtimePackRoot:e=""}={}){let t=Q({root:e});
|
|
1064
|
+
if(!t)return"";let r=ru.join(t,nu,Ff),n;try{n=Hf(r,"utf8")}catch(i){if(i?.code==="ENOENT")return"";throw i}let o=n.split(
|
|
1065
|
+
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!qf.test(o[0]))throw new Error(
|
|
1066
|
+
`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function ou({runtimePackRoot:e=""}={}){let t=Q({root:e}),
|
|
1067
|
+
r=C(he().sharedCacheRoot),n=Wf({runtimePackRoot:t});return{...r?{[en]:r}:{},...t?{[Ft]:ru.join(t,nu,zf),[Fo]:"1"}:{},...n?
|
|
1068
|
+
{[qo]:n}:{}}}var en,Ft,Fo,qo,nu,zf,Ff,qf,qt=g(()=>{q();Re();ge();en="VIBE64_SHARED_CACHE_ROOT",Ft="PLAYWRIGHT_BROWSERS_P\
|
|
1069
|
+
ATH",Fo="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",qo="VIBE64_PLAYWRIGHT_VERSION",nu="playwright",zf="browsers",Ff="runtime.env",
|
|
1070
|
+
qf=/^\d+\.\d+\.\d+$/u});function yt(e={}){for(let t of Object.keys(ue(e)))if(Yf.has(t)||t.startsWith("XDG_")){let r=new Error(`Vibe64 command ca\
|
|
1071
|
+
llers cannot provide execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function tn(e={},t={}){
|
|
1072
|
+
let{envPolicy:r="session"}=t,n=ue(e);yt(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!Jf.has(i)));return r===
|
|
1073
|
+
"deployment"?o:{...o,...Xr(n)}}var Yf,Jf,rn=g(()=>{q();Qr();gt();qt();Yf=new Set(["HOME","LOGNAME","PATH","TMPDIR","USER",
|
|
1071
1074
|
"VIBE64_EXECUTION_ID","VIBE64_MANAGED_EXECUTION_REQUIRED","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIM\
|
|
1072
|
-
E_DIR"]),
|
|
1075
|
+
E_DIR"]),Jf=new Set([...zt,Je,Ye,Xe,Ke,Ft,Fo,qo,en])});function Kf(e=""){let t=C(e);return t==="/home"||t.startsWith("/home/")}function iu({actor:e={},request:t={}}={}){let r=t.
|
|
1073
1076
|
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\
|
|
1074
1077
|
mmand credential home must match the resolved real-user actor home.");throw a.code="vibe64_command_credential_home_actor\
|
|
1075
|
-
_mismatch",a}if(!e.requiresRealUser&&
|
|
1078
|
+
_mismatch",a}if(!e.requiresRealUser&&Kf(n)&&o&&!Pe(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
1076
1079
|
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=R(r.username||e.user?.username);
|
|
1077
1080
|
return{...Dt({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n}),...C(r.cacheRoot)?{XDG_CACHE_HOME:C(r.cacheRoot)}:{},...C(r.
|
|
1078
1081
|
configRoot)?{XDG_CONFIG_HOME:C(r.configRoot)}:{},...C(r.dataRoot)?{XDG_DATA_HOME:C(r.dataRoot)}:{},...C(r.stateRoot)?{XDG_STATE_HOME:C(
|
|
1079
|
-
r.stateRoot)}:{}}}var
|
|
1080
|
-
isAbsolute(o))continue;let i=
|
|
1082
|
+
r.stateRoot)}:{}}}var su=g(()=>{mt();q()});import au from"node:path";function eh(e=[]){let t=new Set,r=[];for(let n of Array.isArray(e)?e:[e]){let o=R(n);if(!o||!au.
|
|
1083
|
+
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==
|
|
1081
1084
|
"object"&&!Array.isArray(e)?e:{}},n=Number.parseInt(String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?
|
|
1082
1085
|
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
|
|
1084
|
-
function
|
|
1085
|
-
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function Yo(e={}){return Wt(e,
|
|
1086
|
-
return Wt(e,
|
|
1087
|
-
var
|
|
1088
|
-
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),
|
|
1089
|
-
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),
|
|
1086
|
+
i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),r}function cu(e=[]){return eh(e).map(t=>({key:"safe.directory",value:t}))}
|
|
1087
|
+
function uu(e={},t=[]){return Wt(e,cu(t))}function th(e=[]){return cu(e).flatMap(t=>["-c",`${t.key}=${t.value}`])}function Wo(){
|
|
1088
|
+
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function Yo(e={}){return Wt(e,Xf)}function rh(e={}){
|
|
1089
|
+
return Wt(e,Qf)}function nh(e={}){return Wt(e,Zf)}function lu(e={}){return rh(Yo(e))}function du(e={}){return nh(Yo(e))}
|
|
1090
|
+
var Xf,Qf,Zf,PI,pu=g(()=>{q();Xf=Object.freeze([{key:"url.https://github.com/.insteadOf",value:"git@github.com:"},{key:"\
|
|
1091
|
+
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),Qf=Object.freeze([{key:"credential.https://github.co\
|
|
1092
|
+
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),Zf=Object.freeze([{key:"credential.https://github.com.helper",
|
|
1090
1093
|
value:`!f() { case "$1" in get) printf '%s\\n' username=x-access-token "password=\${VIBE64_GIT_AUTH_TOKEN}" ;; esac; }; f`}]);
|
|
1091
|
-
|
|
1092
|
-
code="vibe64_command_git_auth_token_required",t}return
|
|
1093
|
-
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=
|
|
1094
|
-
github-https"||e.purpose==="github")&&(r=
|
|
1095
|
-
BE64_GIT_AUTH_TOKEN"});import
|
|
1096
|
-
function
|
|
1097
|
-
()=>{q();ge();Jo="NPM_CONFIG_PREFIX"});import{existsSync as
|
|
1098
|
-
function Yt(e=""){return String(e||"").split(":").map(R).filter(Boolean)}function
|
|
1099
|
-
t)}catch{return!1}})}function
|
|
1100
|
-
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function
|
|
1094
|
+
PI=Object.freeze({applyGitConfigEntriesToEnv:Wt,githubSshToHttpsGitEnv:Yo,gitSafeDirectoryArgs:th})});function ih(e={}){if(!e.gitAuthToken){let t=new Error("Token-backed GitHub transport requires a gitAuthToken.");throw t.
|
|
1095
|
+
code="vibe64_command_git_auth_token_required",t}return du({...Wo(),GIT_TERMINAL_PROMPT:"0",[oh]:e.gitAuthToken})}function mu({
|
|
1096
|
+
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=ih(e):(e.gitTransport==="\
|
|
1097
|
+
github-https"||e.purpose==="github")&&(r=lu({...t,...Wo()})),uu(r,e.gitSafeDirectories||[])}var oh,fu=g(()=>{pu();oh="VI\
|
|
1098
|
+
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"):""):""}
|
|
1099
|
+
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(
|
|
1100
|
+
()=>{q();ge();Jo="NPM_CONFIG_PREFIX"});import{existsSync as sh,readdirSync as ah}from"node:fs";import ch from"node:os";import Ne from"node:path";import nn from"node:process";
|
|
1101
|
+
function Yt(e=""){return String(e||"").split(":").map(R).filter(Boolean)}function Eu(e=[]){return e.filter(t=>{try{return sh(
|
|
1102
|
+
t)}catch{return!1}})}function _u(e="",t=/^$/u){try{return ah(e).filter(r=>t.test(r)).sort((r,n)=>Number(/\d+/u.exec(n)?.[0]||
|
|
1103
|
+
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function uh(e){if(Q())return[];let t=String(e.HOME||ch.homedir()||"");
|
|
1101
1104
|
if(!Ne.isAbsolute(t))return[];let r=Ne.isAbsolute(String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:Ne.join(t,".local/share"),
|
|
1102
|
-
n=Ne.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:Ne.join(r,"mise");return
|
|
1105
|
+
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
1106
|
n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",".bun/bin"].map(o=>Ne.join(t,o))])}function lh(){if(Q())return[];
|
|
1104
|
-
let e=["/opt/homebrew","/usr/local"];return[...Yt(
|
|
1105
|
-
[...
|
|
1106
|
-
t=>[...
|
|
1107
|
+
let e=["/opt/homebrew","/usr/local"];return[...Yt(nn.env.PATH),...nn.platform==="darwin"?["/opt/homebrew/bin"]:[],...Eu(
|
|
1108
|
+
[..._u("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`/usr/lib/postgresql/${t}/bin`),...nn.platform==="darwin"?e.flatMap(
|
|
1109
|
+
t=>[..._u(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function bu({
|
|
1107
1110
|
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return ze([...Yt(o.join(":")),...zo(),...n.flatMap(
|
|
1108
|
-
i=>Ho(i)),...
|
|
1109
|
-
Jt="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"});import
|
|
1110
|
-
e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!
|
|
1111
|
+
i=>Ho(i)),...tu(),...Yt(t||(r?"":e.PATH)),...uh(nn.env),...Yt(r),...lh(),...Yt(Jt)]).join(":")}var Jt,on=g(()=>{q();ge();
|
|
1112
|
+
Jt="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"});import dh from"node:path";function fh(e={}){return Object.fromEntries(Object.entries(e&&typeof e=="object"&&!Array.isArray(
|
|
1113
|
+
e)?e:{}).map(([t,r])=>[String(t||"").trim(),String(r??"")]).filter(([t])=>t&&!ph.has(t)&&!mh.has(t)&&!t.startsWith("GIT_")&&
|
|
1111
1114
|
!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
|
|
1113
|
-
envPolicy==="deployment"?(yt(r),{...t,...
|
|
1114
|
-
oyment"?[]:t.envPolicy==="project"?Xo(t):[e,...Xo(t),t.project?.databaseEnv,t.session?.databaseEnv]}function
|
|
1115
|
-
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=
|
|
1116
|
-
t.XDG_RUNTIME_DIR||"").trim(),c={...Dt(e.user,
|
|
1117
|
-
...
|
|
1118
|
-
|
|
1119
|
-
shimDirs||[]});return{...
|
|
1115
|
+
e.project?.deployment?.env]:[e.project?.runtimeConfigEnv,e.project?.databaseEnv]}function hh(e={}){return Xo(e).reduce((t,r)=>e.
|
|
1116
|
+
envPolicy==="deployment"?(yt(r),{...t,...ue(r)}):{...t,...tn(r,e)},{})}function gh(e={},t={}){return t.envPolicy==="depl\
|
|
1117
|
+
oyment"?[]:t.envPolicy==="project"?Xo(t):[e,...Xo(t),t.project?.databaseEnv,t.session?.databaseEnv]}function vu({actor:e={},
|
|
1118
|
+
baseEnv:t,localPath:r="",request:n={}}){let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=ou(),s=tn(n.env,n),a=String(
|
|
1119
|
+
t.XDG_RUNTIME_DIR||"").trim(),c={...Dt(e.user,fh(t)),...ht(e)&&dh.isAbsolute(a)?{XDG_RUNTIME_DIR:a}:{},...Xr(...gh(t,n)),
|
|
1120
|
+
...hh(n),...mu({actor:e,request:n}),...s,...iu({actor:e,request:n}),...i},u={...c,...wu({env:c}),VIBE64_DECLARED_RUNTIMES:o},
|
|
1121
|
+
l=bu({env:u,existingPath:[...yu({env:u}),u.PATH].filter(Boolean).join(":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.
|
|
1122
|
+
shimDirs||[]});return{...u,PATH:l,...Q()?{}:{VIBE64_TOOL_PATH:l}}}function Su({actor:e={},baseEnv:t,request:r={}},n){return{
|
|
1120
1123
|
actor:e,env:t,gitConfig:{cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.
|
|
1121
|
-
userKey}}async function
|
|
1122
|
-
resolvedGitIdentityEnv||
|
|
1123
|
-
q();
|
|
1124
|
-
_RUNTIME_DIR"]),
|
|
1125
|
-
found.",ok:!1}}function Ce(e=""){return String(e||"default").trim()||"default"}function
|
|
1126
|
-
for(let n=0;n<
|
|
1127
|
-
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>
|
|
1128
|
-
"running"||e.status==="closing"}function ei(e={}){return Kt(e)||e.status==="exited"}function
|
|
1129
|
-
!0}catch{return!1}}function
|
|
1130
|
-
let{outputLimit:r=0}=t,n=String(e||""),o=
|
|
1131
|
-
o),outputTruncated:!0}}function ke(e,t={}){let r=
|
|
1124
|
+
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.
|
|
1125
|
+
resolvedGitIdentityEnv||eu(Su(e,t))}}var ph,mh,Zo=g(()=>{Kr();mt();Qr();rn();Qr();su();fu();gt();gt();qt();Ko();on();ge();
|
|
1126
|
+
q();ph=new Set([...zt,Je,Ye,Xe,Ke,"HOME","LOGNAME","PATH","USER","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG\
|
|
1127
|
+
_RUNTIME_DIR"]),mh=new Set(["NODE_ENV"])});import{Buffer as wh}from"node:buffer";function Au(){return{code:"terminal_session_not_found",error:"Terminal session not\
|
|
1128
|
+
found.",ok:!1}}function Ce(e=""){return String(e||"default").trim()||"default"}function cn(e){let t=String(e||""),r=t.length;
|
|
1129
|
+
for(let n=0;n<yh&&(r=t.lastIndexOf(`
|
|
1130
|
+
`,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===
|
|
1131
|
+
"running"||e.status==="closing"}function ei(e={}){return Kt(e)||e.status==="exited"}function Pu(e,t){try{return t(ke(e))===
|
|
1132
|
+
!0}catch{return!1}}function Eh(e=0){let t=Math.floor(Number(e||0));return Number.isFinite(t)&&t>0?t:0}function bh(e="",t={}){
|
|
1133
|
+
let{outputLimit:r=0}=t,n=String(e||""),o=Eh(r);return!o||n.length<=o?{output:n,outputTruncated:!1}:{output:n.slice(n.length-
|
|
1134
|
+
o),outputTruncated:!0}}function ke(e,t={}){let r=bh(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||sn,
|
|
1132
1135
|
createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exitCode,inputVersion:e.inputVersion||0,lastInputAt:e.
|
|
1133
1136
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
1134
1137
|
metadata:e.metadata||{},output:r.output,outputTruncated:r.outputTruncated,outputVersion:e.outputVersion||0,rows:e.rows||
|
|
1135
|
-
|
|
1136
|
-
e));return!Number.isFinite(t)||t<0?0:Math.min(t,
|
|
1137
|
-
e.lastInputAt),pt(e.lastOutputAt),pt(e.createdAt))}function ti(e={},t=Date.now()){if(e.subscribers?.size)return 0;let r=
|
|
1138
|
-
e);return r>0?Math.max(0,Number(t)-r):0}function
|
|
1139
|
-
e.detachedCleanupTimer=null)}var
|
|
1140
|
-
60*1e3,
|
|
1141
|
-
metadata:e.metadata,type:"metadata"}),ke(e))}function
|
|
1138
|
+
an,status:e.status}}function Ru(e=""){return wh.byteLength(String(e||""),"utf8")}function Xt(e=0){let t=Math.floor(Number(
|
|
1139
|
+
e));return!Number.isFinite(t)||t<0?0:Math.min(t,_h)}function vh(e={}){return Math.max(pt(e.lastSubscriberDetachedAt),pt(
|
|
1140
|
+
e.lastInputAt),pt(e.lastOutputAt),pt(e.createdAt))}function ti(e={},t=Date.now()){if(e.subscribers?.size)return 0;let r=vh(
|
|
1141
|
+
e);return r>0?Math.max(0,Number(t)-r):0}function un(e={}){e.detachedCleanupTimer&&(clearTimeout(e.detachedCleanupTimer),
|
|
1142
|
+
e.detachedCleanupTimer=null)}var Tu,yh,sn,an,aT,_h,cT,Ou,_t=g(()=>{q();Tu=256*1024,yh=300,sn=100,an=28,aT=600*1e3,_h=1440*
|
|
1143
|
+
60*1e3,cT=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,{
|
|
1144
|
+
metadata:e.metadata,type:"metadata"}),ke(e))}function Cu(e,t=""){let r=Ru(t);r<1||(e.outputVersion=Number(e.outputVersion||
|
|
1142
1145
|
0)+1,e.lastOutputAt=new Date().toISOString(),e.lastOutputBytes=r)}function we(e,t){if(e?.subscribers?.size)for(let r of[
|
|
1143
|
-
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function
|
|
1144
|
-
e||"Terminal PTY error.");return{code:t,message:r}}function
|
|
1146
|
+
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function Sh(e){let t=String(e?.code||""),r=String(e?.message||
|
|
1147
|
+
e||"Terminal PTY error.");return{code:t,message:r}}function ku(e,t){if(!e)return;let r=Sh(t);e.lastWriteErrorAt=new Date().
|
|
1145
1148
|
toISOString(),e.lastWriteErrorCode=r.code,e.lastWriteError=r.message,console.warn("Vibe64 terminal PTY write error.",{code:r.
|
|
1146
1149
|
code,id:e.id,metadata:e.metadata||{},message:r.message,namespace:e.namespace||""}),we(e,{code:r.code,error:r.message,type:"\
|
|
1147
|
-
error"})}function
|
|
1150
|
+
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){
|
|
1148
1151
|
let n=`\r
|
|
1149
1152
|
[studio] ${r}\r
|
|
1150
|
-
`;e.closeError=t,e.output=
|
|
1153
|
+
`;e.closeError=t,e.output=cn(`${e.output}${n}`),we(e,{chunk:n,type:"output"}),we(e,{error:t,type:"error"})}async function ju(e,{
|
|
1151
1154
|
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(
|
|
1152
|
-
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,$
|
|
1155
|
+
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(
|
|
1153
1156
|
t?.code||"terminal_cleanup_failed")}:${String(t?.message||"")}`;return e.reportedLifecycleFailures||=new Set,e.reportedLifecycleFailures.
|
|
1154
|
-
has(r)||(e.reportedLifecycleFailures.add(r),$
|
|
1157
|
+
has(r)||(e.reportedLifecycleFailures.add(r),$u(e,String(t?.message||t||"Terminal cleanup failed."))),t}function ln(e,t=[]){
|
|
1155
1158
|
let r=new AggregateError(t,`Terminal session could not close cleanly: ${e.id}`);return r.code=t.some(n=>String(n?.code||
|
|
1156
|
-
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function
|
|
1157
|
-
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>
|
|
1159
|
+
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function Ih(e,t){
|
|
1160
|
+
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>ju(e,{code:"terminal_stop_hook_failed",flag:"\
|
|
1158
1161
|
stopHookStarted",hook:"onStop",label:"Terminal stop failed",payload:{id:e.id,output:e.output,reason:t,status:e.status}}))),
|
|
1159
|
-
e.stopHookCompletion}function ri(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>
|
|
1162
|
+
e.stopHookCompletion}function ri(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>ju(
|
|
1160
1163
|
e,{code:"terminal_close_hook_failed",flag:"closeHookStarted",hook:"onClose",label:"Terminal finalization failed",payload:{
|
|
1161
1164
|
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function ni(e){e.status!==
|
|
1162
1165
|
"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
|
|
1166
|
+
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await Fr(e.terminal.pid)){
|
|
1164
1167
|
let t=new Error(`Terminal execution scope did not become empty: ${e.id}`);throw t.code="terminal_execution_drain_failed",
|
|
1165
|
-
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function
|
|
1168
|
+
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function Lu(e){try{await e.scopeDrainCompletion}catch(t){
|
|
1166
1169
|
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="\
|
|
1167
1170
|
stop"){if(!e||e.processExited)return{failures:[]};e.stopReason||=String(t||"stop"),e.status==="running"&&(e.status="clos\
|
|
1168
|
-
ing",we(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(
|
|
1171
|
+
ing",we(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(Ih(e,e.stopReason),!e.processExited&&!e.killStarted){
|
|
1169
1172
|
e.killStarted=!0;try{e.terminal.kill()}catch(n){e.killStarted=!1;let o=n instanceof Error?n:new Error(String(n||"Termina\
|
|
1170
1173
|
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
|
|
1172
|
-
ok:!1}:null}var
|
|
1173
|
-
e.delete(r);let n=Ce(t);e.size<1&&Ze.get(n)===e&&Ze.delete(n)}function
|
|
1174
|
-
filter(r=>r.startsWith(t))}function
|
|
1174
|
+
n))}return{failures:r}}var si=g(()=>{Vt();_t()});function Ah(e="default"){return Th.get(Ce(e))||null}function Mu(e="default"){let t=Ah(e);return t?{code:t.code,error:t.error,
|
|
1175
|
+
ok:!1}:null}var Th,Du=g(()=>{_t();Th=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){
|
|
1176
|
+
e.delete(r);let n=Ce(t);e.size<1&&Ze.get(n)===e&&Ze.delete(n)}function Oh(e=""){let t=String(e||"");return[...Ze.keys()].
|
|
1177
|
+
filter(r=>r.startsWith(t))}function dn({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){let n=e?[Ce(e)]:Oh(t),
|
|
1175
1178
|
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
|
|
1177
|
-
let n=Math.max(0,r-ti(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,
|
|
1179
|
+
()=>{_t();Ze=new Map});function pn(e={},t="default"){if(un(e),!ei(e)||e.subscribers?.size)return;let r=Xt(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
1180
|
+
let n=Math.max(0,r-ti(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,Ph({namespace:t})},n)}async function ci(e,t={}){
|
|
1178
1181
|
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(
|
|
1180
|
-
s.push(Qe(o,
|
|
1181
|
-
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&ni(o),s.length>0)throw ln(o,[...s,...c]);return
|
|
1182
|
-
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(
|
|
1183
|
-
o.closePromise===i&&(o.closePromise=null)}}async function
|
|
1184
|
-
if(!ei(r)||r.subscribers?.size)continue;let n=Xt(r.detachedIdleTimeoutMs);if(!(n<1)){if(ti(r)<n){
|
|
1185
|
-
r.id,{namespace:t})}}}var
|
|
1186
|
-
filter:e,namespacePrefix:t}){return
|
|
1182
|
+
let s=[];if(un(o),!o.processExited){let u=await ii(o,"close");if(u.failures.length)throw ln(o,u.failures)}try{await o.exitCompletion}catch(u){
|
|
1183
|
+
s.push(Qe(o,u))}try{await o.scopeDrainCompletion}catch(u){s.push(Qe(o,u))}let c=(await Promise.all([o.stopHookCompletion,
|
|
1184
|
+
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&ni(o),s.length>0)throw ln(o,[...s,...c]);return Vu(n,r,e),{
|
|
1185
|
+
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(u=>String(u?.message||u))}:{}}})();o.closePromise=i;try{return await i}finally{
|
|
1186
|
+
o.closePromise===i&&(o.closePromise=null)}}async function Ph({namespace:e}){for(let{namespace:t,session:r}of dn({namespace:e})){
|
|
1187
|
+
if(!ei(r)||r.subscribers?.size)continue;let n=Xt(r.detachedIdleTimeoutMs);if(!(n<1)){if(ti(r)<n){pn(r,t);continue}await ci(
|
|
1188
|
+
r.id,{namespace:t})}}}var ui=g(()=>{q();si();ai();_t()});import Nh from"node:crypto";import{createRequire as Ch}from"node:module";function li(){}function kh(){return!0}function $h({
|
|
1189
|
+
filter:e,namespacePrefix:t}){return dn({namespacePrefix:t,runningOnly:!0}).filter(r=>Pu(r.session,e)).length}function Gu({
|
|
1187
1190
|
args:e,command:t,commandPreview:r,cwd:n=process.cwd(),env:o={},maxRunning:i=0,metadata:s={},namespace:a="default",namespaceLimitPrefix:c="",
|
|
1188
|
-
runningLimitFilter:
|
|
1189
|
-
if(I)return I;let S=Et(a),d=
|
|
1190
|
-
if(_)return ke(_);let b=Number(i||0),v=c||a;if(b>0
|
|
1191
|
+
runningLimitFilter:u=kh,onClose:l=li,onOutput:m=li,onStop:h=li,reuseRunning:f=!1,detachedIdleTimeoutMs:w=0}){let I=Mu(a);
|
|
1192
|
+
if(I)return I;let S=Et(a),d=Nh.randomUUID(),p=typeof f=="function"?f:()=>!!f,_=f?[...S.values()].find(F=>Kt(F)&&p(F)):null;
|
|
1193
|
+
if(_)return ke(_);let b=Number(i||0),v=c||a;if(b>0&&$h({filter:u,namespacePrefix:v})>=b)return{ok:!1,code:"terminal_limi\
|
|
1191
1194
|
t",error:`Terminal limit reached (${b}).`};let y=typeof o=="function"?o({id:d,namespace:a}):o,E=typeof e=="function"?e({
|
|
1192
1195
|
env:y,id:d,namespace:a}):e,A=typeof r=="function"?r({args:E,env:y,id:d,namespace:a}):r,T=typeof s=="function"?s({args:E,
|
|
1193
|
-
env:y,id:d,namespace:a}):s,O=
|
|
1194
|
-
F=>{U=F}),k={id:d,closeHookCompletion:null,closePromise:null,commandPreview:A,cols:
|
|
1196
|
+
env:y,id:d,namespace:a}):s,O=xh("node-pty").spawn(t,E,{cols:sn,cwd:n,env:J(y),name:"xterm-color",rows:an}),U,x=new Promise(
|
|
1197
|
+
F=>{U=F}),k={id:d,closeHookCompletion:null,closePromise:null,commandPreview:A,cols:sn,createdAt:new Date().toISOString(),
|
|
1195
1198
|
cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:Xt(w),exitCompletion:x,exitCode:null,lastSubscriberAttachedAt:"",lastSubscriberDetachedAt:new Date().
|
|
1196
|
-
toISOString(),metadata:T&&typeof T=="object"&&!Array.isArray(T)?T:{},onClose:
|
|
1199
|
+
toISOString(),metadata:T&&typeof T=="object"&&!Array.isArray(T)?T:{},onClose:l,onStop:h,inputVersion:0,lastInputAt:"",lastInputBytes:0,
|
|
1197
1200
|
lastOutputAt:"",lastOutputBytes:0,lastWriteError:"",lastWriteErrorAt:"",lastWriteErrorCode:"",output:"",outputVersion:0,
|
|
1198
|
-
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:U,rows:
|
|
1199
|
-
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:O};return
|
|
1201
|
+
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:U,rows:an,status:"running",stopHookCompletion:null,
|
|
1202
|
+
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:O};return xu(k),O.onData(F=>{Cu(k,F),k.output=cn(k.output+
|
|
1200
1203
|
F),we(k,{chunk:F,lastOutputAt:k.lastOutputAt,outputVersion:k.outputVersion,type:"output"});try{m({chunk:F,output:k.output,
|
|
1201
|
-
session:ke(k),updateMetadata(ee){return
|
|
1202
|
-
d.");we(k,{error:pe,type:"error"})}
|
|
1203
|
-
oi(k),we(k,{exitCode:F,status:k.status,type:"status"}),ri(k,k.stopReason||"exit"),k.resolveExitCompletion(),
|
|
1204
|
-
set(d,k),
|
|
1205
|
-
ke(i,{outputLimit:n}):
|
|
1206
|
-
execution/src/server/engines/terminalSessions.js",import.meta.url).href;
|
|
1207
|
-
function
|
|
1204
|
+
session:ke(k),updateMetadata(ee){return Nu(k,ee)}})}catch(ee){let pe=String(ee?.message||ee||"Terminal output hook faile\
|
|
1205
|
+
d.");we(k,{error:pe,type:"error"})}pn(k,a)}),O.onExit(({exitCode:F})=>{k.processExited=!0,k.exitCode=F,k.status="closing",
|
|
1206
|
+
oi(k),we(k,{exitCode:F,status:k.status,type:"status"}),ri(k,k.stopReason||"exit"),k.resolveExitCompletion(),Lu(k)}),Uu(a).
|
|
1207
|
+
set(d,k),pn(k,a),jh(d,{namespace:a})}function jh(e,t={}){let{namespace:r="default",outputLimit:n=0}=t,i=Et(r).get(e);return i?
|
|
1208
|
+
ke(i,{outputLimit:n}):Au()}var Rh,xh,Bu=g(()=>{q();_t();si();Du();ui();ai();Rh=new URL("./../node_modules/@local/vibe64-\
|
|
1209
|
+
execution/src/server/engines/terminalSessions.js",import.meta.url).href;xh=Ch(Rh)});import{randomUUID as Lh}from"node:crypto";import{mkdirSync as Mh,writeFileSync as Dh}from"node:fs";import di from"node:path";
|
|
1210
|
+
function Uh(){}function Vh(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root is required fo\
|
|
1208
1211
|
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
|
|
1210
|
-
let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return
|
|
1211
|
-
|
|
1212
|
-
a,input:e.input,operation:Ht(e)});return
|
|
1213
|
-
`,{mode:384}),["-n",No(),"execute",
|
|
1214
|
-
command:e.command,cwd:n,env:a}}async function
|
|
1215
|
-
{},{onClose:a=
|
|
1216
|
-
commandPreview:s.commandPreview,cwd:
|
|
1212
|
+
"exec-helper-payloads");return Mh(r,{mode:448,recursive:!0}),di.join(r,`${process.pid}-${Date.now()}-${Lh()}.json`)}function Gh(e,t){
|
|
1213
|
+
let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return Jr(r)?{args:(c={})=>{let u=Vh(s.helperPayloadRoot),
|
|
1214
|
+
l=typeof e.args=="function"?e.args(c):e.args,m=qr({actor:r,args:l,command:e.command,cwd:n,env:typeof a=="function"?a(c):
|
|
1215
|
+
a,input:e.input,operation:Ht(e)});return Dh(u,`${JSON.stringify(m)}
|
|
1216
|
+
`,{mode:384}),["-n",No(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||Jt}}:{args:e.args,
|
|
1217
|
+
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||
|
|
1218
|
+
{},{onClose:a=Uh}=s,c=e.execution?.id||"",u=Gh(e,{actor:r,cwd:n,env:o,resolveEnv:i}),l=Gu({args:u.args,command:u.command,
|
|
1219
|
+
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
1217
1220
|
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async m=>{try{await a(m)}finally{
|
|
1218
|
-
c&&
|
|
1219
|
-
runningLimitFilter:s.runningLimitFilter});return
|
|
1220
|
-
execution:e.execution}:
|
|
1221
|
-
{execution:e.execution})}}var
|
|
1222
|
-
resolveLinks:n=!0}=t,o=
|
|
1223
|
-
c,o));if(s.length>0){if(!n)return o;let c=
|
|
1224
|
-
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var
|
|
1221
|
+
c&&Hu.set(c,{id:m.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
1222
|
+
runningLimitFilter:s.runningLimitFilter});return l?.ok===!0&&c&&Hu.set(c,{id:l.id,namespace:s.namespace}),l?.ok===!0?{...l,
|
|
1223
|
+
execution:e.execution}:l}catch(s){return X(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
1224
|
+
{execution:e.execution})}}var Hu,pi=g(()=>{Fe();on();Bu();ui();Wr();Kr();Hu=new Map});import{realpathSync as Fu}from"node:fs";function Bh(e=""){return C(e||process.cwd())}function qu(e="",t={}){let{allowedRoots:r=[],
|
|
1225
|
+
resolveLinks:n=!0}=t,o=Bh(e),i=(Array.isArray(r)?r:[r]).map(C).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>Pe(
|
|
1226
|
+
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\
|
|
1227
|
+
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var Wu=g(()=>{q()});import{randomUUID as Hh}from"node:crypto";function te(e="",t="vibe64_command_request_invalid"){let r=new Error(e||"Inval\
|
|
1225
1228
|
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 te(
|
|
1226
|
-
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function
|
|
1229
|
+
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function tg(e=[],t={}){let{
|
|
1227
1230
|
mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw te("Function-valued command args are only supported for \
|
|
1228
1231
|
PTY commands.","vibe64_command_args_function_requires_pty");return e}return(Array.isArray(e)?e:[e]).map(n=>String(n??""))}
|
|
1229
|
-
function
|
|
1230
|
-
nv is only supported for PTY commands.","vibe64_command_env_function_requires_pty");return{env:{},envFactory:e}}let n=
|
|
1231
|
-
e);return yt(n),{env:n,envFactory:null}}function mi(e=[]){return(Array.isArray(e)?e:[e]).map(C).filter(Boolean)}function
|
|
1232
|
+
function rg(e={},t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw te("Function-valued command e\
|
|
1233
|
+
nv is only supported for PTY commands.","vibe64_command_env_function_requires_pty");return{env:{},envFactory:e}}let n=ue(
|
|
1234
|
+
e);return yt(n),{env:n,envFactory:null}}function mi(e=[]){return(Array.isArray(e)?e:[e]).map(C).filter(Boolean)}function ng(e={}){
|
|
1232
1235
|
let t=J(e);return{commandPreview:t.commandPreview,detachedIdleTimeoutMs:t.detachedIdleTimeoutMs,helperPayloadRoot:C(t.helperPayloadRoot),
|
|
1233
1236
|
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
|
|
1237
|
+
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function og(e={}){
|
|
1235
1238
|
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
1239
|
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
1240
|
uid:Number.isSafeInteger(Number(t.uid??t.hostUid))?Number(t.uid??t.hostUid):null,username:R(t.username||t.ownerUserKey||
|
|
1238
|
-
t.userKey)}:{}}function
|
|
1241
|
+
t.userKey)}:{}}function ig(e="capture"){return e==="detached"?"service":e==="pty"?"interactive":"finite"}function sg({mode:e="\
|
|
1239
1242
|
capture",purpose:t="terminal"}={}){return t==="preview"?"preview":e==="pty"?"terminal":"job"}function bt(e=""){let t=R(e);
|
|
1240
1243
|
if(!t)return"";if(!/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,254}[A-Za-z0-9])?$/u.test(t))throw te(`Invalid Vibe64 execution ide\
|
|
1241
|
-
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function
|
|
1242
|
-
purpose:o="terminal",session:i={}}=t,s=J(e),a=xe(s.kind,
|
|
1243
|
-
|
|
1244
|
-
throw te(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_execution_lifecycle_incompatible");let
|
|
1245
|
-
s.ownerId||i.sessionId);if(c==="service"&&!
|
|
1246
|
-
_owner_required");let
|
|
1247
|
-
lityKey","environment"].includes(m))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(
|
|
1248
|
-
"")||!["development","test","production"].includes(
|
|
1249
|
-
"vibe64_resource_profile_invalid");return Object.freeze({...
|
|
1250
|
-
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:
|
|
1251
|
-
id:
|
|
1252
|
-
projectSlug:bt(s.projectSlug||n.slug||n.projectSlug),sessionId:bt(s.sessionId||i.sessionId)})}function
|
|
1244
|
+
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function Ju(e={},t={}){let{mode:r="capture",project:n={},
|
|
1245
|
+
purpose:o="terminal",session:i={}}=t,s=J(e),a=xe(s.kind,Xh,sg({mode:r,purpose:o}),"execution_kind"),c=xe(s.lifecycle,Qh,
|
|
1246
|
+
ig(r),"execution_lifecycle");if(r==="detached"&&c!=="service"||r==="pty"&&c!=="interactive"||r==="capture"&&c!=="finite")
|
|
1247
|
+
throw te(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_execution_lifecycle_incompatible");let u=bt(
|
|
1248
|
+
s.ownerId||i.sessionId);if(c==="service"&&!u)throw te("Service execution requires a durable owner id.","vibe64_execution\
|
|
1249
|
+
_owner_required");let l=s.resourceProfile;if(l!=null&&(!l||typeof l!="object"||Object.keys(l).some(m=>!["key","compatibi\
|
|
1250
|
+
lityKey","environment"].includes(m))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(l.key||"")||!/^[a-f0-9]{64}$/u.test(l.compatibilityKey||
|
|
1251
|
+
"")||!["development","test","production"].includes(l.environment)))throw te("Invalid activity resource profile identity.",
|
|
1252
|
+
"vibe64_resource_profile_invalid");return Object.freeze({...l?{resourceProfile:Object.freeze({...l})}:{},controlGenerationId:bt(
|
|
1253
|
+
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:ag(s.workflowId)},
|
|
1254
|
+
id:Hh(),kind:a,label:R(s.label),lifecycle:c,operationId:bt(s.operationId),ownerId:u,parentExecutionId:bt(s.parentExecutionId),
|
|
1255
|
+
projectSlug:bt(s.projectSlug||n.slug||n.projectSlug),sessionId:bt(s.sessionId||i.sessionId)})}function ag(e){if(typeof e!=
|
|
1253
1256
|
"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 te("Execution req\
|
|
1254
|
-
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function
|
|
1255
|
-
e)?Bo:[]}function
|
|
1256
|
-
imes"),n=
|
|
1257
|
-
R).filter(Boolean))}function
|
|
1258
|
-
required");let n=xe(t.mode,
|
|
1259
|
-
"Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=
|
|
1260
|
-
{mode:n}),s=xe(t.purpose,
|
|
1261
|
-
Vibe64 runtime: ${w}.`,"vibe64_command_runtime_unsupported");let c=J(t.project),
|
|
1262
|
-
"";if(typeof
|
|
1257
|
+
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function cg(e=""){return eg.has(
|
|
1258
|
+
e)?Bo:[]}function Yu(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function ug(e={},t=""){let r=Yu(e,"runt\
|
|
1259
|
+
imes"),n=Yu(e,"runtime");if(!r&&!n)return ze(cg(t));let o=r?e.runtimes:e.runtime;return ze((Array.isArray(o)?o:[o]).map(
|
|
1260
|
+
R).filter(Boolean))}function Ku(e={}){let t=J(e),r=R(t.command);if(!r)throw te("A command is required.","vibe64_command_\
|
|
1261
|
+
required");let n=xe(t.mode,Wh,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))throw te(
|
|
1262
|
+
"Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=ue(t.baseEnv),i=rg(t.env,
|
|
1263
|
+
{mode:n}),s=xe(t.purpose,qh,"terminal","purpose"),a=ug(t,s);for(let w of a)if(!Object.hasOwn(wt,w))throw te(`Unsupported\
|
|
1264
|
+
Vibe64 runtime: ${w}.`,"vibe64_command_runtime_unsupported");let c=J(t.project),u=J(t.session),l=t.releaseEnvironmentFile??
|
|
1265
|
+
"";if(typeof l!="string"||l&&(!l.startsWith("/")||/[\r\n\0]/u.test(l)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="de\
|
|
1263
1266
|
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw te("Release environment files require a\
|
|
1264
1267
|
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let m=t.usageRecordingPreload??
|
|
1265
1268
|
"";if(typeof m!="string"||m&&(!m.startsWith("/")||/[\s"'\\\0]/u.test(m)||!["preview","output"].includes(s)||t.actor==="a\
|
|
1266
1269
|
pp"))throw te("A usage recording preload belongs only to a Preview or Output target launch.","vibe64_command_usage_recor\
|
|
1267
|
-
ding_preload_invalid");let
|
|
1270
|
+
ding_preload_invalid");let h=t.applicationAccount??"";if(typeof h!="string"||h&&(!Fh.test(h)||t.actor!=="app"||n!=="capt\
|
|
1268
1271
|
ure"))throw te("Application accounts run only finite application commands.","vibe64_command_application_account_invalid");
|
|
1269
|
-
let
|
|
1270
|
-
|
|
1271
|
-
vibe64_command_sandbox_allowances_invalid");return{actor:xe(t.actor,
|
|
1272
|
-
t.allowedRoots),args:
|
|
1273
|
-
envPolicy:xe(t.envPolicy,
|
|
1274
|
-
{mode:n,project:c,purpose:s,session:
|
|
1272
|
+
let f=t.sandboxAllowances??[];if(!Array.isArray(f)||f.some(w=>typeof w!="string"||!/^[a-z][a-z0-9-]*$/u.test(w))||new Set(
|
|
1273
|
+
f).size!==f.length||f.length>0&&!h)throw te("Sandbox allowances belong only to an application account's own commands.","\
|
|
1274
|
+
vibe64_command_sandbox_allowances_invalid");return{actor:xe(t.actor,zh,"daemon","actor"),applicationAccount:h,allowedRoots:mi(
|
|
1275
|
+
t.allowedRoots),args:tg(t.args,{mode:n}),baseEnv:o,command:r,cwd:C(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,
|
|
1276
|
+
envPolicy:xe(t.envPolicy,Jh,"session","env_policy"),releaseEnvironmentFile:l,sandboxAllowances:[...f],execution:Ju(t.execution,
|
|
1277
|
+
{mode:n,project:c,purpose:s,session:u}),credentialHome:og(t.credentialHome),gitAuthToken:R(t.gitAuthToken),gitSafeDirectories:mi(
|
|
1275
1278
|
t.gitSafeDirectories),personGitIdentity:{email:R(t.personGitIdentity?.email),name:R(t.personGitIdentity?.name)},gitTransport:xe(
|
|
1276
|
-
t.gitTransport,
|
|
1277
|
-
maxBuffer:Number.isSafeInteger(Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):
|
|
1278
|
-
onOutput=="function"?t.onOutput:null,outputEncoding:xe(t.outputEncoding,
|
|
1279
|
-
runtimes:a,session:
|
|
1280
|
-
Number(t.timeout))&&Number(t.timeout)>0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:R(t.userKey)}}var
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
loyment","health","workspace-cache","source"]),
|
|
1284
|
-
base64"]),
|
|
1285
|
-
"github-token"]),
|
|
1286
|
-
["finite","interactive","service"]),
|
|
1287
|
-
ce","terminal"]);
|
|
1288
|
-
()=>{Bt();Vt();pi();Fe();lg=null,
|
|
1289
|
-
function
|
|
1279
|
+
t.gitTransport,Kh,"none","git_transport"),inheritProcessEnv:!l&&t.inheritProcessEnv!==!1,input:t.input,logPath:C(t.logPath),
|
|
1280
|
+
maxBuffer:Number.isSafeInteger(Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):Zh,mode:n,onOutput:typeof t.
|
|
1281
|
+
onOutput=="function"?t.onOutput:null,outputEncoding:xe(t.outputEncoding,Yh,"utf8","output_encoding"),project:c,purpose:s,
|
|
1282
|
+
runtimes:a,session:u,signal:t.signal??null,shimDirs:mi(t.shimDirs),terminal:ng(t.terminal),timeout:Number.isSafeInteger(
|
|
1283
|
+
Number(t.timeout))&&Number(t.timeout)>0?Number(t.timeout):15e3,usageRecordingPreload:m,userKey:R(t.userKey)}}var zh,Fh,qh,
|
|
1284
|
+
Wh,Yh,Jh,Kh,Xh,Qh,Zh,eg,aA,Xu=g(()=>{q();rn();ge();zh=Object.freeze(["daemon","owner-user","named-user","app"]),Fh=/^[a-z_][a-z0-9_-]{0,31}$/u,
|
|
1285
|
+
qh=Object.freeze(["account","assistant","terminal","codex","github","github-api","source-editor","preview","output","dep\
|
|
1286
|
+
loyment","health","workspace-cache","source"]),Wh=Object.freeze(["capture","pty","detached"]),Yh=Object.freeze(["utf8","\
|
|
1287
|
+
base64"]),Jh=Object.freeze(["session","project","preview","auth","deployment"]),Kh=Object.freeze(["none","github-https",
|
|
1288
|
+
"github-token"]),Xh=Object.freeze(["assistant","browser","control","job","preview","service","terminal"]),Qh=Object.freeze(
|
|
1289
|
+
["finite","interactive","service"]),Zh=1e3*1e3*100,eg=new Set(["assistant","codex","deployment","output","preview","sour\
|
|
1290
|
+
ce","terminal"]);aA=Object.freeze({normalizeExecutionDescriptor:Ju})});function fi(){return lg}function mn(e){return["1","true"].includes(String(e[Qu]||"").trim().toLowerCase())}var lg,Qu,fn=g(
|
|
1291
|
+
()=>{Bt();Vt();pi();Fe();lg=null,Qu="VIBE64_MANAGED_EXECUTION_REQUIRED"});import{realpathSync as Zu,statSync as pg}from"node:fs";import $e from"node:path";import{fileURLToPath as mg}from"node:url";
|
|
1292
|
+
function fg(e){let t=[$e.resolve($e.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=$e.dirname(e);t.
|
|
1290
1293
|
push($e.join(r,"node_modules/@local/vibe64-usage-recording/runtime/node")),$e.dirname(r)!==r;r=$e.dirname(r));return t.flatMap(
|
|
1291
|
-
r=>{try{return[
|
|
1292
|
-
|
|
1293
|
-
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var
|
|
1294
|
-
"./../node_modules/@local/vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href});function
|
|
1294
|
+
r=>{try{return[Zu(r)]}catch{return[]}})}function el(e="",t=mg(dg)){try{if($e.resolve(e)===e&&Zu(e)===e&&pg(e).isFile()&&
|
|
1295
|
+
fg(t).some(r=>e.startsWith(`${r}${$e.sep}`)))return`--import=${e}`}catch{}throw Object.assign(new Error("The usage recor\
|
|
1296
|
+
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var dg,tl=g(()=>{dg=new URL(
|
|
1297
|
+
"./../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\
|
|
1295
1298
|
e_environment_unavailable",{execution:e.execution}):e.applicationAccount?X("Application account execution requires a man\
|
|
1296
|
-
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function
|
|
1297
|
-
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=
|
|
1298
|
-
|
|
1299
|
+
aged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function hg(e,t={}){let{actor:r,
|
|
1300
|
+
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=rl(e);if(a)return a;if(e.usageRecordingPreload){let c=el(e.usageRecordingPreload),
|
|
1301
|
+
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}):
|
|
1299
1302
|
e.mode==="detached"?r.requiresRealUser&&(!ht(r)||i)?X("Detached real-user command execution is unsupported when the help\
|
|
1300
1303
|
er is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):mc(e,{actor:r,cwd:n,env:o}):i?
|
|
1301
|
-
{...await Co(
|
|
1304
|
+
{...await Co(qr({actor:r,args:e.args,command:e.command,cwd:n,env:o,input:e.input,operation:Ht(e)}),{env:process.env,maxBuffer:e.
|
|
1302
1305
|
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:Gt(e.command,e.args,
|
|
1303
1306
|
{cwd:n,env:o,execution:e.execution,input:e.input,maxBuffer:e.maxBuffer,onOutput:e.onOutput,outputEncoding:e.outputEncoding,
|
|
1304
|
-
signal:e.signal,timeout:e.timeout})}async function Qt(e={}){let t=null;try{if(t=
|
|
1307
|
+
signal:e.signal,timeout:e.timeout})}async function Qt(e={}){let t=null;try{if(t=Ku(e),t.signal?.aborted)return X("Comman\
|
|
1305
1308
|
d cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await Pc(t),n=t.inheritProcessEnv?{...process.env,
|
|
1306
|
-
...t.baseEnv}:{...t.baseEnv},o=(d={})=>({...d,VIBE64_EXECUTION_ID:t.execution.id}),i=fi(),s=
|
|
1307
|
-
r),
|
|
1308
|
-
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Je,Ye,Xe,Ke].map(d=>[d,
|
|
1309
|
-
kc(r,
|
|
1310
|
-
args=="function"?t.args(d):t.args,w=(d={})=>o(t.envFactory?Qo({actor:r,baseEnv:n,localPath:
|
|
1311
|
-
...t,env:t.envFactory(d),envFactory:null}}):
|
|
1312
|
-
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:
|
|
1309
|
+
...t.baseEnv}:{...t.baseEnv},o=(d={})=>({...d,VIBE64_EXECUTION_ID:t.execution.id}),i=fi(),s=mn(n)||mn(process.env),a=Jr(
|
|
1310
|
+
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,
|
|
1311
|
+
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),m=Object.fromEntries([Je,Ye,Xe,Ke].map(d=>[d,l[d]]));
|
|
1312
|
+
kc(r,l);let h=qu(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});Cc(r,t,h);let f=(d={})=>typeof t.
|
|
1313
|
+
args=="function"?t.args(d):t.args,w=(d={})=>o(t.envFactory?Qo({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:m,request:{
|
|
1314
|
+
...t,env:t.envFactory(d),envFactory:null}}):l),I=(d=t,p={})=>hg(d,{actor:r,cwd:h,env:l,requiresHelper:a,resolveEnv:w,...p});
|
|
1315
|
+
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:h,env:l,resolveArgs:f,resolveEnv:w,runLocal:I});let S=rl(t);return S||
|
|
1313
1316
|
(s?X("Managed execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unava\
|
|
1314
1317
|
ilable",{execution:t.execution,retryable:!1}):I())}catch(r){return X(r?.message||"Vibe64 command failed.",r?.code||"vibe\
|
|
1315
|
-
64_command_failed",{execution:t?.execution})}}var
|
|
1316
|
-
|
|
1317
|
-
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,
|
|
1318
|
-
6e4,
|
|
1319
|
-
e||"").trim();return
|
|
1320
|
-
function
|
|
1321
|
-
r)&&
|
|
1322
|
-
"darwin"&&
|
|
1318
|
+
64_command_failed",{execution:t?.execution})}}var hn=g(()=>{Rc();Zo();gt();Bt();Wr();Vt();pi();Wu();Kr();Xu();Fe();fn();
|
|
1319
|
+
tl()});import{fileURLToPath as wg}from"node:url";var gg,DA,UA,VA,GA,nl=g(()=>{Re();gg=new URL("./../node_modules/@local/vibe64-\
|
|
1320
|
+
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,DA=wg(new URL("./gitTurnCheckpointCommand.js",gg)),UA=15*
|
|
1321
|
+
6e4,VA=512*1024*1024,GA=1024*1024*1024});var zA,ol=g(()=>{q();zA=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"])});var il=g(()=>{});import{existsSync as yg}from"node:fs";import gn from"node:path";import sl from"node:process";function hi(e=""){let t=String(
|
|
1322
|
+
e||"").trim();return Eg[t]||t}function cl({platform:e=sl.platform,aptGet:t=!1}={}){return e==="darwin"?"brew":t?"apt":""}
|
|
1323
|
+
function bg(e,t=Jt){return[...String(e.PATH||"").split(gn.delimiter),...String(t||"").split(gn.delimiter)].some(r=>gn.isAbsolute(
|
|
1324
|
+
r)&&yg(gn.join(r,"apt-get")))}function yn({env:e,platform:t=sl.platform,systemPath:r}){return cl({platform:t,aptGet:t!==
|
|
1325
|
+
"darwin"&&bg(e,r)})}function _n(e="",t={}){let{family:r="",mise:n=!1,xcode:o=!0}=t,i=wn[hi(e)];if(!i)return null;if(r===
|
|
1323
1326
|
"brew"&&!o&&["git","cpp"].includes(hi(e)))return{command:"xcode-select --install",sudo:!1,note:""};let s=i.any||i[r]||"";
|
|
1324
|
-
if(!s&&i.mise&&(s=n?`mise use -g ${i.mise}`:`${
|
|
1325
|
-
"sudo ")||r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?
|
|
1326
|
-
|
|
1327
|
+
if(!s&&i.mise&&(s=n?`mise use -g ${i.mise}`:`${_g} && ~/.local/bin/mise use -g ${i.mise}`),!s)return null;let a=s.startsWith(
|
|
1328
|
+
"sudo ")||r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?al:""}}var al,_g,XA,wn,Eg,QA,Zt=g(()=>{on();
|
|
1329
|
+
al="You'll be asked for your computer password. Nothing shows while you type.",_g="curl -fsSL https://mise.run | sh",XA=
|
|
1327
1330
|
Object.freeze({linux:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-linux.md",darwin:"\
|
|
1328
|
-
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),
|
|
1331
|
+
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),wn=Object.freeze({claude:{
|
|
1329
1332
|
name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://claude.ai/i\
|
|
1330
1333
|
nstall.sh | bash"},codex:{name:"Codex",run:[["codex"]],guideUrl:"https://github.com/openai/codex",any:"curl -fsSL https:\
|
|
1331
1334
|
//chatgpt.com/codex/install.sh | sh"},opencode:{name:"opencode",run:[["opencode"]],guideUrl:"https://opencode.ai/docs/",
|
|
@@ -1349,17 +1352,17 @@ rl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -fsSL https
|
|
|
1349
1352
|
ild tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/install_ruby\
|
|
1350
1353
|
_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"sudo apt i\
|
|
1351
1354
|
nstall build-essential pkg-config libyaml-dev libssl-dev zlib1g-dev libpq-dev default-libmysqlclient-dev libgmp-dev",brew:"\
|
|
1352
|
-
brew install pkg-config libyaml openssl@3 gmp"}}),
|
|
1353
|
-
function
|
|
1354
|
-
`)}function
|
|
1355
|
+
brew install pkg-config libyaml openssl@3 gmp"}}),Eg=Object.freeze({composer:"php"});QA=Object.freeze({SUDO_NOTE:al,localToolFamily:cl})});function ul({env:e,platform:t,systemPath:r}){return _n("git",{family:yn({env:e,platform:t,systemPath:r})})?.command||""}
|
|
1356
|
+
function vg(e={}){return[e.error,e.stderr,e.output].filter(Boolean).join(`
|
|
1357
|
+
`)}function Sg(e,t){let r=vg(e);if(/spawn(?:Sync)? git ENOENT|(?:^|\s)git: (?:command )?not found/mu.test(r)){let n=ul(t);
|
|
1355
1358
|
return{code:"vibe64_git_missing",installCommand:n,message:n?`Git isn't installed on this computer. Install it with: ${n}`:
|
|
1356
1359
|
"Git isn't installed on this computer. Install Git, then try again."}}return/unknown option [`']initial-branch/u.test(r)?
|
|
1357
|
-
{code:"vibe64_git_too_old",installCommand:
|
|
1360
|
+
{code:"vibe64_git_too_old",installCommand:ul(t),message:"This Git is too old for Vibe64. Update Git to version 2.28 or n\
|
|
1358
1361
|
ewer, then try again."}:/gpg failed to sign|failed to sign the data|signing failed|couldn't (?:load|find) (?:public )?key|incorrect passphrase/iu.
|
|
1359
1362
|
test(r)?{code:"vibe64_git_signing_failed",installCommand:"",message:"Your Git is set to sign every commit, and signing d\
|
|
1360
1363
|
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\
|
|
1361
|
-
s and is unlocked, then try again."}:null}var
|
|
1362
|
-
backups.git",
|
|
1364
|
+
s and is unlocked, then try again."}:null}var tO,ll=g(()=>{Zt();tO=Object.freeze({describeGitFailure:Sg})});var gi=g(()=>{});import dl from"node:path";function Ag(e=""){return e?dl.join(dl.dirname(e),pl):""}var pl,ml,Tg,sO,aO,fl=g(()=>{gi();pl="\
|
|
1365
|
+
backups.git",ml="vibe64-atomic",Tg=`backup_canonical_ref() {
|
|
1363
1366
|
vibe64_backup_repository="$1"
|
|
1364
1367
|
vibe64_source_repository="$2"
|
|
1365
1368
|
vibe64_source_ref="$3"
|
|
@@ -1377,13 +1380,13 @@ r "$vibe64_backup_repository" rev-parse --verify "$vibe64_backup_ref"
|
|
|
1377
1380
|
' "$vibe64_source_ref" >&2
|
|
1378
1381
|
return 1
|
|
1379
1382
|
fi
|
|
1380
|
-
}`,
|
|
1383
|
+
}`,sO=`#!/bin/sh
|
|
1381
1384
|
set -eu
|
|
1382
1385
|
|
|
1383
1386
|
zero_object=0000000000000000000000000000000000000000
|
|
1384
1387
|
git_dir="$(git rev-parse --absolute-git-dir)"
|
|
1385
1388
|
repository_root="$(dirname "$git_dir")"
|
|
1386
|
-
backup_repository="$repository_root/${
|
|
1389
|
+
backup_repository="$repository_root/${pl}"
|
|
1387
1390
|
if [ -L "$repository_root" ] || [ -L "$backup_repository" ] || [ -L "$repository_root/mutation.lock" ]; then
|
|
1388
1391
|
printf '[vibe64] Canonical repository storage must not use symlinked role paths.
|
|
1389
1392
|
' >&2
|
|
@@ -1392,7 +1395,7 @@ fi
|
|
|
1392
1395
|
exec 8>"$repository_root/mutation.lock"
|
|
1393
1396
|
flock -x 8
|
|
1394
1397
|
|
|
1395
|
-
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${
|
|
1398
|
+
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${ml}" ]; then
|
|
1396
1399
|
printf '[vibe64] Canonical repository pushes must use the Vibe64 atomic mutation path.
|
|
1397
1400
|
' >&2
|
|
1398
1401
|
exit 1
|
|
@@ -1403,7 +1406,7 @@ if [ "$(git --git-dir "$backup_repository" rev-parse --is-bare-repository 2>/dev
|
|
|
1403
1406
|
exit 1
|
|
1404
1407
|
fi
|
|
1405
1408
|
|
|
1406
|
-
${
|
|
1409
|
+
${Tg}
|
|
1407
1410
|
|
|
1408
1411
|
updates_file="$(mktemp "$repository_root/.pre-receive.XXXXXX")"
|
|
1409
1412
|
cleanup_updates_file() {
|
|
@@ -1451,8 +1454,8 @@ while read -r old_object _new_object ref_name; do
|
|
|
1451
1454
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
1452
1455
|
fi
|
|
1453
1456
|
done <"$updates_file"
|
|
1454
|
-
`;
|
|
1455
|
-
wserWorkerSource.js",import.meta.url).href});var
|
|
1457
|
+
`;aO=Object.freeze({CANONICAL_REPOSITORY_PUSH_OPTION:ml,canonicalRepositoryBackupPath:Ag})});var hl=g(()=>{qt();ge()});var wi=g(()=>{});var gl=g(()=>{});var wl=g(()=>{});var yi=g(()=>{});var yO,yl=g(()=>{gl();wl();yi();yO=new URL("./../node_modules/@local/vibe64-execution/src/server/runtime/agentPreviewBro\
|
|
1458
|
+
wserWorkerSource.js",import.meta.url).href});var Pg,_l=g(()=>{Pg=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms\
|
|
1456
1459
|
>]"," vibe64-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [\
|
|
1457
1460
|
--json]"," vibe64-helper preview open <path> [--json]"," vibe64-helper preview inspect-url"," vibe64-helper preview s\
|
|
1458
1461
|
creenshot [--output <path>]"," vibe64-helper preview browser ensure"," vibe64-helper preview browser eval < playwright\
|
|
@@ -1495,63 +1498,63 @@ ical preview server for the configured primary application.","Do not start a dup
|
|
|
1495
1498
|
er port.","A distinct secondary application explicitly requested by the user, such as a reference app, may run separatel\
|
|
1496
1499
|
y without replacing this preview."].join(`
|
|
1497
1500
|
`)+`
|
|
1498
|
-
`});var
|
|
1499
|
-
-execution/src/server/conversationExecution.js",import.meta.url).href,
|
|
1501
|
+
`});var El=g(()=>{});import{fileURLToPath as xg}from"node:url";var kg,RO,bl=g(()=>{hn();fn();Re();kg=new URL("./../node_modules/@local/vibe64\
|
|
1502
|
+
-execution/src/server/conversationExecution.js",import.meta.url).href,RO=xg(new URL("./engines/stdioBridge.js",kg))});var jO,vl=g(()=>{hn();Zt();ge();jO=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$nam\
|
|
1500
1503
|
e" 2>/dev/null) || continue'," case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /us\
|
|
1501
1504
|
r/bin/*) continue ;; esac; fi',` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1502
|
-
`)});var
|
|
1503
|
-
any:n}=
|
|
1504
|
-
ge();
|
|
1505
|
-
maxBuffer:
|
|
1506
|
-
roject",gitSafeDirectories:[t],input:m,maxBuffer:
|
|
1507
|
-
if(
|
|
1508
|
-
ase64"?Buffer.from(
|
|
1505
|
+
`)});var $g,Sl=g(()=>{Zt();ge();$g=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,
|
|
1506
|
+
any:n}=wn[e];return[e,Object.freeze({name:t,guideUrl:r,install:n})]})))});import{execFile as jg}from"node:child_process";import{promisify as Lg}from"node:util";var BO,Il=g(()=>{BO=Lg(jg)});var Tl=g(()=>{Br();rc();mt();Wr();Oc();hn();Bt();Fe();fn();nl();Zo();ol();il();rn();Ko();gt();ll();gi();fl();q();qt();Re();
|
|
1507
|
+
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,
|
|
1508
|
+
maxBuffer:h=1024*1024}=l,f=await Qt({actor:"daemon",allowedRoots:[t],args:["-C",t,...c],command:"git",cwd:t,envPolicy:"p\
|
|
1509
|
+
roject",gitSafeDirectories:[t],input:m,maxBuffer:h,mode:"capture",outputEncoding:u,purpose:"source",runtimes:["git"],timeout:6e4});
|
|
1510
|
+
if(f.ok!==!0)throw Object.assign(new Error(f.error||"Git could not read the pinned topic."),{code:f.code});return u==="b\
|
|
1511
|
+
ase64"?Buffer.from(f.stdout,"base64"):f.stdout.trim()};if(await Al(await r(["rev-parse","--show-toplevel"]))!==t)throw new Error(
|
|
1509
1512
|
"Choose the topic repository root.");let n=await r(["rev-parse","HEAD"]);if(await r(["status","--porcelain","--untracked\
|
|
1510
1513
|
-files=all"]))throw new Error("Commit the topic content before generating a pinned course manifest.");let o=await He(t),
|
|
1511
1514
|
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];
|
|
1512
1515
|
if(!s)throw new Error("Topic package needs its canonical https://github.com/<owner>/learn-<topic>.git repository URL.");
|
|
1513
|
-
let a=Be([o.topicManifest,...o.bundles.map(c=>c.manifest)]);for(let c=0;c<a.length;){let
|
|
1514
|
-
byteLength(a[
|
|
1515
|
-
c,
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
`Topic input differs from its pinned commit: ${w.path}.`);
|
|
1519
|
-
a while reading the pinned topic.");c=
|
|
1516
|
+
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.
|
|
1517
|
+
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(
|
|
1518
|
+
c,u),h=await r(["cat-file","--batch","-Z"],"base64",{input:m.map(w=>`${n}:${w.path}\0`).join(""),maxBuffer:2*1024*1024}),
|
|
1519
|
+
f=0;for(let w of m){let I=h.indexOf(0,f),S=I<0?null:/^(?:[a-f0-9]{40}|[a-f0-9]{64}) blob (0|[1-9][0-9]*)$/u.exec(h.subarray(
|
|
1520
|
+
f,I).toString("ascii")),d=S?Number(S[1]):-1,p=I+1+d;if(d!==w.bytes||h[p]!==0||K(h.subarray(I+1,p))!==w.sha256)throw new Error(
|
|
1521
|
+
`Topic input differs from its pinned commit: ${w.path}.`);f=p+1}if(f!==h.length)throw new Error("Unexpected trailing dat\
|
|
1522
|
+
a while reading the pinned topic.");c=u}if(await r(["rev-parse","HEAD"])!==n||await r(["status","--porcelain","--untrack\
|
|
1520
1523
|
ed-files=all"]))throw new Error("Topic changed during manifest generation. Commit and retry.");return{topicId:o.topic.topicId,
|
|
1521
|
-
release:o.release,repository:s,commit:n,topicManifest:o.topicManifest,topicHash:o.topicHash}}function tr(e,t){let r=ce(
|
|
1524
|
+
release:o.release,repository:s,commit:n,topicManifest:o.topicManifest,topicHash:o.topicHash}}function tr(e,t){let r=ce(Lr,
|
|
1522
1525
|
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(
|
|
1523
1526
|
"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))
|
|
1524
|
-
throw new Error(`Duplicate course topic: ${i.topicId}.`);n.add(i.topicId);let s=t.filter(
|
|
1527
|
+
throw new Error(`Duplicate course topic: ${i.topicId}.`);n.add(i.topicId);let s=t.filter(l=>l.topicId===i.topicId&&l.release===
|
|
1525
1528
|
i.release);if(s.length!==1)throw new Error(`Resolve exactly one pinned topic release: ${i.topicId}@${i.release}.`);let a=s[0];
|
|
1526
1529
|
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(
|
|
1527
1530
|
`Topic requires a repository and immutable commit: ${i.topicId}.`);let c=a.topicManifest;if(!c||c.schemaVersion!==1||c.topic?.
|
|
1528
1531
|
topicId!==i.topicId||c.release!==i.release||K(L(c))!==a.topicHash)throw new Error(`Topic manifest identity mismatch: ${i.
|
|
1529
|
-
topicId}.`);if(ce(
|
|
1530
|
-
rse requires a released topic: ${i.topicId}.`);let
|
|
1531
|
-
|
|
1532
|
-
let
|
|
1533
|
-
throw new Error(`Changed whole-topic order or lesson identity: ${i.topicId}.`);if(r.status==="released"&&
|
|
1534
|
-
"published")throw new Error(`Released course includes required draft: ${
|
|
1535
|
-
repository:a.repository,commit:a.commit,manifestHash:a.topicHash,lessons:c.lessons.map(
|
|
1532
|
+
topicId}.`);if(ce(jr,c.topic,i.topicId),r.status==="released"&&c.topic.status!=="released")throw new Error(`Released cou\
|
|
1533
|
+
rse requires a released topic: ${i.topicId}.`);let u=c.topic.lessons;if(!Array.isArray(u)||!u.length||!Array.isArray(c.lessons)||
|
|
1534
|
+
u.length!==c.lessons.length)throw new Error(`Incomplete whole-topic inventory: ${i.topicId}.`);for(let[l,m]of u.entries()){
|
|
1535
|
+
let h=c.lessons[l];if(h.code!==m.code||h.status!==m.status||h.required!==m.required||!/^[a-f0-9]{64}$/u.test(h.hash||""))
|
|
1536
|
+
throw new Error(`Changed whole-topic order or lesson identity: ${i.topicId}.`);if(r.status==="released"&&h.required&&h.status!==
|
|
1537
|
+
"published")throw new Error(`Released course includes required draft: ${h.code}.`)}return{topicId:i.topicId,release:i.release,
|
|
1538
|
+
repository:a.repository,commit:a.commit,manifestHash:a.topicHash,lessons:c.lessons.map(l=>({...l}))}});if(r.orientation!==
|
|
1536
1539
|
void 0&&!o.some(i=>i.lessons.some(s=>s.code===r.orientation&&s.status==="published")))throw new Error(`Course orientatio\
|
|
1537
1540
|
n ${r.orientation} must be a published lesson of the course.`);return{schemaVersion:1,courseId:r.courseId,release:r.release,
|
|
1538
|
-
status:r.status,topics:o}}var
|
|
1541
|
+
status:r.status,topics:o}}var En=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 bn(e,t,r=409,n={}){
|
|
1539
1542
|
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.
|
|
1540
|
-
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var
|
|
1543
|
+
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var MR,vn=g(()=>{Ar();MR=128*1024});var Ol=g(()=>{});import{lstat as Mg,readFile as Dg,readdir as Ug,realpath as Vg}from"node:fs/promises";import D from"node:path";function Ei(e){
|
|
1541
1544
|
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}})}:
|
|
1542
|
-
e}function et(e,t={}){let r=ce(
|
|
1543
|
-
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!
|
|
1545
|
+
e}function et(e,t={}){let r=ce(Bg,e,"Installed topic pin");if(!je.test(r.topicId)||!bi.test(r.commit)||r.topicId!==(t.topicId??
|
|
1546
|
+
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!Gg.test(r.repository)||!nr.test(r.topicHash))
|
|
1544
1547
|
throw new Error("Installed pin does not match the requested topic, commit or canonical source identity.");if(r.topicHash!==
|
|
1545
1548
|
(t.topicHash??r.topicHash))throw new Error("Installed topic differs from the trusted course or attempt pin.");return r}async function or(e,t){
|
|
1546
|
-
let r=await
|
|
1549
|
+
let r=await Mg(e);if(r.isSymbolicLink()||await Vg(e)!==e)throw new Error("Installed content cannot use symlink or direct\
|
|
1547
1550
|
ory aliases.");if(t?!r.isDirectory():!r.isFile())throw new Error(`Installed content needs a regular ${t?"directory":"fil\
|
|
1548
1551
|
e"}.`);return r}async function St(e,t){if((await or(e,!1)).size>t)throw new Error(`Installed file exceeds its ${t}-byte \
|
|
1549
|
-
limit.`);let n=await
|
|
1550
|
-
let t=[],r=0;async function n(o){await or(o,!0);for(let i of await
|
|
1552
|
+
limit.`);let n=await Dg(e);if(n.length>t)throw new Error(`Installed file exceeds its ${t}-byte limit.`);return n}async function Hg(e){
|
|
1553
|
+
let t=[],r=0;async function n(o){await or(o,!0);for(let i of await Ug(o,{withFileTypes:!0})){if(++r>65536)throw new Error(
|
|
1551
1554
|
"Installed snapshot exceeds 65536 directory entries.");let s=D.join(o,i.name);i.isDirectory()?await n(s):(await or(s,!1),
|
|
1552
|
-
t.push(D.relative(e,s).split(D.sep).join("/")))}}return await n(e),t.sort()}function ir({systemRoot:e}){return
|
|
1553
|
-
function
|
|
1554
|
-
te server-owned system root.");let r=D.resolve(e),n=new Map;function o(d){return
|
|
1555
|
+
t.push(D.relative(e,s).split(D.sep).join("/")))}}return await n(e),t.sort()}function ir({systemRoot:e}){return Fg(e,zg)}
|
|
1556
|
+
function Fg(e,t){if(typeof e!="string"||!e||!D.isAbsolute(e))throw new Error("Installed teaching content needs an absolu\
|
|
1557
|
+
te server-owned system root.");let r=D.resolve(e),n=new Map;function o(d){return bn(`Lesson ${d.lesson.code} ("${d.lesson.
|
|
1555
1558
|
title}") cannot be taught by this version of Vibe64: ${d.problem} Update the course in Courses, or ask its authors for a\
|
|
1556
1559
|
fixed release.`,"VIBE64_TRAINING_LESSON_UNUSABLE",422,{params:{lessonCode:d.lesson.code,lessonTitle:d.lesson.title,problem:d.
|
|
1557
1560
|
problem}})}async function i(d={}){let p=await s(d);return{...p,bundles:p.bundles.map(_=>({..._,lesson:Ei(_.lesson)}))}}async function s({
|
|
@@ -1561,10 +1564,10 @@ topicId:d,commit:p,topicHash:_}={}){if(typeof d!="string"||typeof p!="string"||!
|
|
|
1561
1564
|
return v||(v=a({topicId:d,commit:p,topicHash:_}).finally(()=>n.delete(b)),n.set(b,v)),structuredClone(await v)}async function a({
|
|
1562
1565
|
topicId:d,commit:p,topicHash:_}){try{let b=D.join(r,"training"),v=D.join(b,"content"),y=D.join(v,d),E=D.join(y,p);for(let se of[
|
|
1563
1566
|
r,b,v,y,E])await or(se,!0);let A=et(JSON.parse((await St(D.join(E,"pin.json"),4096)).toString("utf8")),{topicId:d,commit:p,
|
|
1564
|
-
topicHash:_}),T=JSON.parse((await St(D.join(E,"bundle.json"),32*1024*1024)).toString("utf8")),O=D.join(E,"files"),U=await
|
|
1567
|
+
topicHash:_}),T=JSON.parse((await St(D.join(E,"bundle.json"),32*1024*1024)).toString("utf8")),O=D.join(E,"files"),U=await Hg(
|
|
1565
1568
|
O),x=await He(O,{installed:!0}),k={schemaVersion:1,topic:x.topic,release:x.release,topicHash:x.topicHash,topicManifest:x.
|
|
1566
|
-
topicManifest,lessons:x.bundles.map(({lesson:se,hash:Ee,status:
|
|
1567
|
-
required:
|
|
1569
|
+
topicManifest,lessons:x.bundles.map(({lesson:se,hash:Ee,status:Hl,required:zl,manifest:Fl})=>({code:se.code,hash:Ee,status:Hl,
|
|
1570
|
+
required:zl,manifest:Fl}))};if(L(T)!==L(k))throw new Error("Installed bundle is incomplete, reordered, unsupported or ch\
|
|
1568
1571
|
anged from its source files.");if(x.topic.topicId!==A.topicId||x.release!==A.release||x.topicHash!==A.topicHash)throw new Error(
|
|
1569
1572
|
"Installed topic identity differs from its pin.");let F=Be([x.topicManifest,...x.bundles.map(se=>se.manifest)]);if(L(U)!==
|
|
1570
1573
|
L(F.map(se=>se.path).sort()))throw new Error("Installed snapshot has missing or unrecorded files.");let ee=await St(D.join(
|
|
@@ -1577,7 +1580,7 @@ he verified snapshot.`,{cause:b});throw y.code=v?"VIBE64_TRAINING_CONTENT_MISSIN
|
|
|
1577
1580
|
async function c({pin:d,manifest:p},_,b){let v=D.join(r,"training","content",d.topicId,d.commit,"files"),y=D.resolve(v,_,
|
|
1578
1581
|
b),E=D.relative(v,y).split(D.sep).join("/"),A=p.files.find(O=>O.path===E);if(!A)throw new Error("Lesson requested an unr\
|
|
1579
1582
|
ecorded installed file.");let T=await St(y,1024*1024);if(T.length!==A.bytes||K(T)!==A.sha256)throw new Error("Installed \
|
|
1580
|
-
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:E,bytes:T}}async function
|
|
1583
|
+
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:E,bytes:T}}async function u({
|
|
1581
1584
|
topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof d!="string"||!je.test(d)||typeof p!="string"||!bi.
|
|
1582
1585
|
test(p)||typeof _!="string"||!nr.test(_)||typeof b!="string"||!je.test(b)||typeof v!="string"||!nr.test(v))throw new Error(
|
|
1583
1586
|
"Choose an exact pinned topic and lesson identity.");try{let y=D.join(r,"training"),E=D.join(y,"content"),A=D.join(E,d),
|
|
@@ -1588,10 +1591,10 @@ st differs from the trusted identity.");let k=x.lessons.find(Ee=>Ee.code===b),F=
|
|
|
1588
1591
|
lessons.find(Ee=>Ee.code===b);if(!k||!F||!ee||k.hash!==v||K(L(ee.manifest))!==v)throw new Error("Installed lesson manife\
|
|
1589
1592
|
st differs from the trusted content hash.");if(!t(k.status))throw new Error(`Lesson ${b} is draft and cannot be taught. \
|
|
1590
1593
|
Choose a published lesson.`);let pe={pin:O,manifest:ee.manifest,hash:v,descriptorPath:F.descriptor},cr=await c(pe,".",F.
|
|
1591
|
-
descriptor),se
|
|
1594
|
+
descriptor),se=$r(JSON.parse(cr.bytes.toString("utf8")),b);if(se.code!==b)throw new Error("Installed lesson descriptor i\
|
|
1592
1595
|
dentity changed.");return{...pe,lesson:Ei(se)}}catch(y){let E=new Error(`Pinned teaching identity ${d}@${p} is invalid: ${y.
|
|
1593
1596
|
message} Ask the owner to restore the exact snapshot.`,{cause:y});throw E.code=["ENOENT","ENOTDIR"].includes(y.code)?"VI\
|
|
1594
|
-
BE64_TRAINING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",E}}async function
|
|
1597
|
+
BE64_TRAINING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",E}}async function l(d={}){let p=await m(d);return{...p,
|
|
1595
1598
|
lesson:Ei(p.lesson)}}async function m({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}={}){if(typeof b!="strin\
|
|
1596
1599
|
g"||typeof v!="string"||!je.test(b)||!nr.test(v))throw new Error("Choose a declared lesson code and its exact 64-charact\
|
|
1597
1600
|
er lowercase content hash.");let y=await s({topicId:d,commit:p,topicHash:_}),E=y.bundles.find(T=>T.lesson.code===b);if(!E)
|
|
@@ -1599,78 +1602,78 @@ throw new Error(`Lesson ${b} is not declared in this pinned topic.`);if(!t(E.sta
|
|
|
1599
1602
|
ft and cannot be taught. Choose a published lesson.`);if(E.hash!==v)throw new Error(`Lesson ${b} content hash changed. R\
|
|
1600
1603
|
esume its exact pinned revision or explicitly start a new attempt.`);if(E.problem)throw o(E);let A=Object.fromEntries(["\
|
|
1601
1604
|
places","activities","facts"].map(T=>[T,[...y.topic[T]||[]]]));return{pin:y.pin,lesson:E.lesson,manifest:E.manifest,hash:E.
|
|
1602
|
-
hash,descriptorPath:E.descriptorPath,declarations:A}}async function
|
|
1605
|
+
hash,descriptorPath:E.descriptorPath,declarations:A}}async function h(d={}){let p=await l(d),_=D.dirname(p.descriptorPath);
|
|
1603
1606
|
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.
|
|
1604
1607
|
visuals){let O=await b(T.descriptor);v.push({id:T.id,descriptorPath:O.path,visual:JSON.parse(O.text)})}if(me(p.lesson)){
|
|
1605
|
-
let T=
|
|
1608
|
+
let T=Mr(p.declarations),O=[];for(let U of p.lesson.steps){let{body:x,beats:k}=Ur((await b(U.body)).text,T);O.push({...U,
|
|
1606
1609
|
bodyText:x,...k?{beats:k}:{}})}return{...p,steps:O,...p.lesson.notes===void 0?{}:{notesText:(await b(p.lesson.notes)).text},
|
|
1607
1610
|
visuals:v}}if(p.lesson.schemaVersion!==1)throw new Error(`Lesson ${p.lesson.code} uses an unsupported format.`);let y=await b(
|
|
1608
1611
|
p.lesson.document),E=p.lesson.assessments.map(T=>({id:T.id,reference:T.rubric,position:new RegExp(`^<a id="${T.id}"></a>\
|
|
1609
1612
|
$`,"mu").exec(y.text).index})).sort((T,O)=>T.position-O.position),A=E.map((T,O)=>({id:T.id,reference:T.reference,text:y.
|
|
1610
|
-
text.slice(T.position,E[O+1]?.position??y.text.length)}));return{...p,document:y,rubrics:A,visuals:v}}async function
|
|
1613
|
+
text.slice(T.position,E[O+1]?.position??y.text.length)}));return{...p,document:y,rubrics:A,visuals:v}}async function f({
|
|
1611
1614
|
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(
|
|
1612
1615
|
p);if(!me(b))throw new Error(`Lesson ${b.code} has no steps.`);let y=b.steps.find(E=>E.id===d);if(!y)throw new Error(`St\
|
|
1613
1616
|
ep ${d} is not declared in this pinned lesson.`);if(y.check.kind!=="choice")throw new Error(`Step ${d} is not a choice s\
|
|
1614
1617
|
tep.`);return{pin:_,lessonCode:b.code,lessonHash:v,stepId:d,answer:[...y.check.answer]}}async function w({topicId:d,commit:p,
|
|
1615
1618
|
topicHash:_,lessonCode:b,lessonHash:v,visualId:y}={}){if(typeof y!="string"||!je.test(y))throw new Error("Choose a decla\
|
|
1616
|
-
red visual ID.");let E=await
|
|
1619
|
+
red visual ID.");let E=await h({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}),A=E.visuals.find(k=>k.id===y);
|
|
1617
1620
|
if(!A)throw vt(`Visual ${y} is not declared in this pinned lesson.`,"VIBE64_TRAINING_VISUAL_UNDECLARED",{statusCode:400,
|
|
1618
1621
|
params:{visualId:y}});let T=D.dirname(A.descriptorPath),O=await c(E,T,A.visual.svg),U=await c(E,T,A.visual.controller),x=[];
|
|
1619
1622
|
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,
|
|
1620
1623
|
svg:O,controller:U,assets:x}}async function I({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v,checkId:y}={}){if(typeof y!=
|
|
1621
|
-
"string"||!je.test(y))throw new Error("Choose a declared check ID.");let E=await
|
|
1624
|
+
"string"||!je.test(y))throw new Error("Choose a declared check ID.");let E=await h({topicId:d,commit:p,topicHash:_,lessonCode:b,
|
|
1622
1625
|
lessonHash:v}),A=E.lesson.checks?.find(x=>x.id===y);if(!A)throw new Error(`Check ${y} is not declared in this pinned les\
|
|
1623
1626
|
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{
|
|
1624
1627
|
pin:E.pin,lessonCode:E.lesson.code,lessonHash:E.hash,check:A,file:O,assets:U}}async function S({topicId:d,commit:p,topicHash:_,
|
|
1625
1628
|
lessonCode:b,lessonHash:v,metadataOnly:y=!1,admissionOnly:E=!1}={}){if(E===!0&&y!==!0)throw new TypeError("Admission rea\
|
|
1626
|
-
ds cannot supply exercise content.");let T=await(E===!0?
|
|
1629
|
+
ds cannot supply exercise content.");let T=await(E===!0?u:y===!0?l:h)({topicId:d,commit:p,topicHash:_,lessonCode:b,lessonHash:v}),
|
|
1627
1630
|
O=T.lesson.exercise;if(!O)throw Object.assign(new Error(`Lesson ${b} has no declared bundled exercise.`),{code:"VIBE64_T\
|
|
1628
1631
|
RAINING_EXERCISE_MISSING"});let U=D.posix.join(D.posix.dirname(T.descriptorPath),O.source),x={pin:T.pin,lessonCode:T.lesson.
|
|
1629
1632
|
code,lessonHash:T.hash,exercise:O,sourcePath:U};if(y===!0)return x;let k=U==="."?"":`${U}/`,F=[];for(let ee of T.manifest.
|
|
1630
1633
|
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})}
|
|
1631
|
-
return{...x,files:F}}return Object.freeze({readTopic:i,readLesson:
|
|
1632
|
-
readChoiceAnswer:
|
|
1633
|
-
bi=/^[a-f0-9]{40}$/u,nr=/^[a-f0-9]{64}$/u,
|
|
1634
|
-
minLength:1,maxLength:256},
|
|
1635
|
-
repository:rr,commit:{...rr,maxLength:40},topicHash:{...rr,maxLength:64}});
|
|
1636
|
-
import Z from"node:path";function
|
|
1637
|
-
throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function
|
|
1634
|
+
return{...x,files:F}}return Object.freeze({readTopic:i,readLesson:h,readAdmissionIdentity:u,readVisual:w,readCheck:I,readExercise:S,
|
|
1635
|
+
readChoiceAnswer:f})}var je,bi,nr,Gg,rr,Bg,zg,vi=g(()=>{kr();dt();ut();bo();Dr();Ol();lt();vn();je=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,
|
|
1636
|
+
bi=/^[a-f0-9]{40}$/u,nr=/^[a-f0-9]{64}$/u,Gg=/^[a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+$/u,rr={type:"string",required:!0,noTrim:!0,
|
|
1637
|
+
minLength:1,maxLength:256},Bg=$({schemaVersion:{type:"integer",required:!0,enum:[1]},topicId:{...rr,maxLength:64},release:rr,
|
|
1638
|
+
repository:rr,commit:{...rr,maxLength:40},topicHash:{...rr,maxLength:64}});zg=e=>e==="published"});import{randomUUID as qg}from"node:crypto";import{lstat as Wg,mkdir as Ii,realpath as Yg,rename as Jg,rm as Kg,writeFile as Xg}from"node:fs/promises";
|
|
1639
|
+
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)
|
|
1640
|
+
throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function Rl(e,t){let r=Z.
|
|
1638
1641
|
relative(e,t);return!r||r!==".."&&!r.startsWith(`..${Z.sep}`)&&!Z.isAbsolute(r)}async function _e(e,t,r=!0){let n;try{n=
|
|
1639
|
-
await
|
|
1642
|
+
await Wg(e)}catch(o){if(r&&o.code==="ENOENT")return null;throw o}if(n.isSymbolicLink()||await Yg(e)!==e)throw new Error(
|
|
1640
1643
|
"Training installation cannot use symlink or directory aliases.");if(t?!n.isDirectory():!n.isFile())throw new Error(`Tra\
|
|
1641
1644
|
ining installation needs a regular ${t?"directory":"file"}: ${e}.`);if(!t&&(n.nlink!==1||n.size!==0))throw new Error("Tr\
|
|
1642
|
-
aining installation lock must be an unaliased empty regular file; inspect it before retrying.");return n}async function
|
|
1643
|
-
let r=Z.dirname(e);return r!==e&&await
|
|
1644
|
-
code!=="EEXIST")throw t}await _e(e,!0,!1)}function
|
|
1645
|
+
aining installation lock must be an unaliased empty regular file; inspect it before retrying.");return n}async function Sn(e,t=!1){
|
|
1646
|
+
let r=Z.dirname(e);return r!==e&&await Sn(r,t),_e(e,!0,t)}async function Qg(e){try{await Ii(e,{mode:448})}catch(t){if(t.
|
|
1647
|
+
code!=="EEXIST")throw t}await _e(e,!0,!1)}function In(e,t){if(L(e)!==L(t))throw new Error("Topic source or installed sna\
|
|
1645
1648
|
pshot conflicts with the approved owner pin. Keep existing content and check the exact source revision.")}async function Si(e,t){
|
|
1646
|
-
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await er(e);
|
|
1647
|
-
commit:i,topicHash:s},t)}function
|
|
1648
|
-
sourceRoot:o,pin:i}={}){let s={...et(i)};
|
|
1649
|
+
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await er(e);In({schemaVersion:1,topicId:r,release:n,repository:o,
|
|
1650
|
+
commit:i,topicHash:s},t)}function Nl({systemRoot:e}){let t=Pl(e,"Training system root"),r=ir({systemRoot:t});async function n({
|
|
1651
|
+
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))
|
|
1649
1652
|
throw new Error("Trusted topic source must be separate from the training installation namespace.");let c=Z.join(a,"conte\
|
|
1650
|
-
nt"),
|
|
1651
|
-
await
|
|
1652
|
-
s)).pin,s);else{if(!
|
|
1653
|
-
talling its pin.");await Si(o,s)}for(let d of[a,c,
|
|
1653
|
+
nt"),u=Z.join(c,s.topicId),l=Z.join(u,s.commit),m=Z.join(a,".install-locks"),h=Z.join(m,`${s.topicId}-${s.commit}.lock`);
|
|
1654
|
+
await Sn(t);let f=await Sn(o,!0);for(let d of[a,c,u,m])await _e(d,!0);if(await _e(h,!1),await _e(l,!0))In((await r.readTopic(
|
|
1655
|
+
s)).pin,s);else{if(!f)throw new Error("Trusted topic source is missing. Prepare the approved local repository before ins\
|
|
1656
|
+
talling its pin.");await Si(o,s)}for(let d of[a,c,u,m])await Qg(d);let I=await ft(h);if(!I)throw bn("This topic revision\
|
|
1654
1657
|
is being installed. Retry after the current owner operation finishes.","VIBE64_TRAINING_INSTALL_BUSY");let S;try{await _e(
|
|
1655
|
-
|
|
1656
|
-
...v}}await
|
|
1658
|
+
h,!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 In(v.pin,s),{installed:!1,
|
|
1659
|
+
...v}}await Sn(o),await Si(o,s);let d=Z.join(a,`.install-${qg()}`);await Ii(d,{mode:448}),S=d;let p=Z.join(S,"training",
|
|
1657
1660
|
"content",s.topicId);await Ii(p,{recursive:!0,mode:448});let _=Z.join(p,s.commit);if(await Ti(["bundle",o,_],{write(){}}),
|
|
1658
|
-
await Si(o,s),await
|
|
1659
|
-
`,{flag:"wx",mode:384}),await ir({systemRoot:S}).readTopic(s),await _e(
|
|
1660
|
-
ination appeared during installation. Keep it unchanged and retry the verified pin.");await
|
|
1661
|
-
s);return
|
|
1662
|
-
freeze({installTopic:n})}var
|
|
1663
|
-
import Oi from"node:path";async function
|
|
1664
|
-
mode:n});let s=Oi.join(i,`.${Oi.basename(e)}.${process.pid}.${
|
|
1665
|
-
o!==void 0&&await
|
|
1661
|
+
await Si(o,s),await Xg(Z.join(_,"pin.json"),`${L(s)}
|
|
1662
|
+
`,{flag:"wx",mode:384}),await ir({systemRoot:S}).readTopic(s),await _e(u,!0,!1),await _e(l,!0))throw new Error("The dest\
|
|
1663
|
+
ination appeared during installation. Keep it unchanged and retry the verified pin.");await Jg(_,l);let b=await r.readTopic(
|
|
1664
|
+
s);return In(b.pin,s),{installed:!0,...b}}finally{try{S&&await Kg(S,{recursive:!0,force:!0})}finally{await I()}}}return Object.
|
|
1665
|
+
freeze({installTopic:n})}var Cl=g(()=>{Yr();En();Ai();dt();vn();vi()});import{randomUUID as Zg}from"node:crypto";import{chmod as ew,mkdir as tw,rename as rw,rm as nw,writeFile as ow}from"node:fs/promises";
|
|
1666
|
+
import Oi from"node:path";async function iw(e,t,r={}){let{directoryMode:n,fileMode:o}=r,i=Oi.dirname(e);await tw(i,{recursive:!0,
|
|
1667
|
+
mode:n});let s=Oi.join(i,`.${Oi.basename(e)}.${process.pid}.${Zg()}.tmp`);try{await ow(s,t,{encoding:"utf8",flag:"wx",mode:o}),
|
|
1668
|
+
o!==void 0&&await ew(s,o),await rw(s,e)}finally{await nw(s,{force:!0})}}async function kl(e,t,r={}){await iw(e,`${JSON.stringify(
|
|
1666
1669
|
t,null,2)}
|
|
1667
|
-
`,r)}var
|
|
1670
|
+
`,r)}var xl=g(()=>{});import{lstat as sw,mkdir as aw,readFile as cw,realpath as uw}from"node:fs/promises";import Le from"node:path";function Ri(e){
|
|
1668
1671
|
if(!Number.isSafeInteger(e)||e<0)throw new Error("Supply the expected revision from a fresh installed catalogue read.")}
|
|
1669
1672
|
function Ni({systemRoot:e}){if(typeof e!="string"||!Le.isAbsolute(e)||Le.resolve(e)!==e||e===Le.parse(e).root)throw new Error(
|
|
1670
1673
|
"Installed catalogue needs a canonical absolute, non-root server-owned system root.");let t=Le.join(e,"training"),r=Le.join(
|
|
1671
1674
|
t,"catalogue.json"),n=Le.join(t,"catalogue.lock"),o=ir({systemRoot:e});async function i(){let S=[t];for(let _=e;S.unshift(
|
|
1672
|
-
_),_!==Le.dirname(_);_=Le.dirname(_));let d=!1,p=null;for(let _ of[...S,r,n]){let b;try{b=await
|
|
1673
|
-
"ENOENT")continue;throw y}let v=_!==r&&_!==n;if(b.isSymbolicLink()||await
|
|
1675
|
+
_),_!==Le.dirname(_);_=Le.dirname(_));let d=!1,p=null;for(let _ of[...S,r,n]){let b;try{b=await sw(_)}catch(y){if(y.code===
|
|
1676
|
+
"ENOENT")continue;throw y}let v=_!==r&&_!==n;if(b.isSymbolicLink()||await uw(_)!==_||(v?!b.isDirectory():!b.isFile()||b.
|
|
1674
1677
|
nlink!==1))throw new Error("Installed catalogue paths must be canonical directories and unaliased regular files.");if(_===
|
|
1675
1678
|
e&&(d=!0),_===r&&(p=b),_===n&&b.size!==0)throw new Error("Installed catalogue lock contains unexplained data. Inspect it\
|
|
1676
1679
|
; do not unlink it.")}return{rootExists:d,catalogueStat:p}}async function s(S){let d=S.lock.topics;if(!Array.isArray(d)||
|
|
@@ -1684,7 +1687,7 @@ topicManifest,topicHash:A.topicHash})}let v=tr(S.course,p);if(L(S.lock)!==L(v))t
|
|
|
1684
1687
|
differs from the complete installed topic inventory. Regenerate and review its exact release.");return{lessonTitles:_,topicTitles:b}}
|
|
1685
1688
|
async function a({includeLessonTitles:S=!1}={}){if(typeof S!="boolean")throw new TypeError("Lesson title projection requ\
|
|
1686
1689
|
ires an explicit Boolean read option.");try{let{catalogueStat:d}=await i();if(!d)return{schemaVersion:1,revision:0,courses:[]};
|
|
1687
|
-
if(d.size>Pi)throw new Error("Installed catalogue exceeds its 1 MiB limit.");let p=await
|
|
1690
|
+
if(d.size>Pi)throw new Error("Installed catalogue exceeds its 1 MiB limit.");let p=await cw(r);if(p.length>Pi)throw new Error(
|
|
1688
1691
|
"Installed catalogue exceeds its 1 MiB limit.");let _=ce(lw,JSON.parse(p.toString("utf8")),"Installed catalogue");if(_.courses.
|
|
1689
1692
|
length&&_.revision<1)throw new Error("Installed catalogue revision conflicts with its course inventory.");let b=new Set;
|
|
1690
1693
|
for(let v of _.courses){let y=`${v.course.courseId}@${v.course.release}`;if(b.has(y))throw new Error("Installed catalogu\
|
|
@@ -1692,31 +1695,31 @@ e contains duplicate course releases.");b.add(y);let{lessonTitles:E,topicTitles:
|
|
|
1692
1695
|
topicTitles:A})}return _}catch(d){throw _i(`Installed catalogue is invalid: ${d.message} Keep existing state and ask the\
|
|
1693
1696
|
owner to restore the exact approved catalogue or pinned content. No automatic repair was performed.`,"VIBE64_TRAINING_C\
|
|
1694
1697
|
ATALOGUE_INVALID",d)}}async function c(){let{rootExists:S}=await i();if(!S)throw new Error("Prepare the server-owned sys\
|
|
1695
|
-
tem root before changing the catalogue.");try{await
|
|
1698
|
+
tem root before changing the catalogue.");try{await aw(t,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}await i();let d=await ft(
|
|
1696
1699
|
n);if(!d)throw ye("Installed catalogue is being updated. Retry after the current owner operation finishes.","VIBE64_TRAI\
|
|
1697
|
-
NING_CATALOGUE_BUSY",409);return d}function
|
|
1698
|
-
rent revision before deliberately retrying this enablement change.","VIBE64_TRAINING_CATALOGUE_REVISION_CONFLICT",409)}async function
|
|
1700
|
+
NING_CATALOGUE_BUSY",409);return d}function u(S,d){if(S.revision!==d)throw ye("Installed catalogue changed. Read its cur\
|
|
1701
|
+
rent revision before deliberately retrying this enablement change.","VIBE64_TRAINING_CATALOGUE_REVISION_CONFLICT",409)}async function l(S,d){
|
|
1699
1702
|
if(S.revision===Number.MAX_SAFE_INTEGER)throw new Error("Installed catalogue reached its revision limit. No change was w\
|
|
1700
1703
|
ritten.");let p={...S,revision:S.revision+1};if(Buffer.byteLength(`${JSON.stringify(p,null,2)}
|
|
1701
|
-
`)>Pi)throw new Error("Installed catalogue exceeds its 1 MiB limit. No change was written.");try{await
|
|
1704
|
+
`)>Pi)throw new Error("Installed catalogue exceeds its 1 MiB limit. No change was written.");try{await kl(r,p,{directoryMode:448,
|
|
1702
1705
|
fileMode:384})}catch(_){throw _i("Catalogue save was not confirmed; atomic rename may already have succeeded. Read the c\
|
|
1703
1706
|
urrent catalogue before deliberately retrying. Do not assume the course changed or remained unchanged.","VIBE64_TRAINING\
|
|
1704
1707
|
_CATALOGUE_SAVE_UNCONFIRMED",_)}return{revision:p.revision,entry:d,changed:!0}}async function m({course:S,lock:d,expectedRevision:p}={}){
|
|
1705
|
-
Ri(p);let _=structuredClone(ce($
|
|
1706
|
-
try{let v=await a();
|
|
1708
|
+
Ri(p);let _=structuredClone(ce($l,{course:S,lock:d,enabled:!0},"Approved installed course"));await a(),await s(_);let b=await c();
|
|
1709
|
+
try{let v=await a();u(v,p),await s(_);let y=v.courses.find(E=>E.course.courseId===_.course.courseId&&E.course.release===
|
|
1707
1710
|
_.course.release);if(y){if(L(y.course)!==L(_.course)||L(y.lock)!==L(_.lock))throw ye("This installed course release is i\
|
|
1708
1711
|
mmutable. Resume its approved pin or publish and approve a different course release.","VIBE64_TRAINING_COURSE_RELEASE_CO\
|
|
1709
|
-
NFLICT",409);return y.enabled?{revision:v.revision,entry:y,changed:!1}:(y.enabled=!0,await
|
|
1712
|
+
NFLICT",409);return y.enabled?{revision:v.revision,entry:y,changed:!1}:(y.enabled=!0,await l(v,y))}if(v.courses.length>=
|
|
1710
1713
|
sr)throw new Error("Installed catalogue reached its 16 course-release limit. Remove a release with vibe64 training remov\
|
|
1711
|
-
e-course to free a place; no release was removed.");return v.courses.push(_),await
|
|
1714
|
+
e-course to free a place; no release was removed.");return v.courses.push(_),await l(v,_)}finally{await b()}}async function h({
|
|
1712
1715
|
courseId:S,release:d,expectedRevision:p},_){if(Ri(p),typeof S!="string"||!/^[a-z][a-z0-9-]{0,63}$/u.test(S)||typeof d!="\
|
|
1713
1716
|
string"||!/^\d+\.\d+\.\d+$/u.test(d))throw new Error(`${_?"Remove":"Disable"} an exact installed course ID and three-par\
|
|
1714
1717
|
t release.`);if(!(await a()).courses.some(y=>y.course.courseId===S&&y.course.release===d))throw ye("This course release \
|
|
1715
1718
|
is not installed in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_MISSING",404);let v=await c();
|
|
1716
|
-
try{let y=await a();
|
|
1719
|
+
try{let y=await a();u(y,p);let E=y.courses.find(A=>A.course.courseId===S&&A.course.release===d);if(!E)throw ye("This cou\
|
|
1717
1720
|
rse release is no longer in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_REMOVED",
|
|
1718
|
-
404);return _?(y.courses=y.courses.filter(A=>A!==E),await
|
|
1719
|
-
entry:E,changed:!1}}finally{await v()}}let
|
|
1721
|
+
404);return _?(y.courses=y.courses.filter(A=>A!==E),await l(y,E)):E.enabled?(E.enabled=!1,await l(y,E)):{revision:y.revision,
|
|
1722
|
+
entry:E,changed:!1}}finally{await v()}}let f=S=>h(S,!1),w=S=>h(S,!0);async function I({title:S,topics:d,expectedRevision:p}){
|
|
1720
1723
|
Ri(p);let _=typeof S=="string"?S.trim():"";if(!_||_.length>120)throw ye("Name the course with 1 to 120 characters.","VIB\
|
|
1721
1724
|
E64_TRAINING_COURSE_NAME_INVALID",400);if(!Array.isArray(d)||!d.length||d.length>32||new Set(d.map(O=>`${O?.topicId}@${O?.
|
|
1722
1725
|
release}`)).size!==d.length||new Set(d.map(O=>O?.topicId)).size!==d.length)throw ye("Choose 1 to 32 different whole topi\
|
|
@@ -1732,91 +1735,91 @@ topicId,release:O.release}))},T=b.courses.find(O=>O.course.courseId===A.courseId
|
|
|
1732
1735
|
ourse with this name already exists. Choose another name.","VIBE64_TRAINING_COURSE_EXISTS",409);if(!T&&b.courses.length>=
|
|
1733
1736
|
sr)throw vt(`This installation already has ${sr} course releases. No course was created.`,"VIBE64_TRAINING_COURSE_CREATE\
|
|
1734
1737
|
_LIMIT",{statusCode:409,params:{limit:sr}});return m({course:A,lock:tr(A,y),expectedRevision:p})}return Object.freeze({readCatalogue:a,
|
|
1735
|
-
enableCourse:m,disableCourse:
|
|
1736
|
-
|
|
1738
|
+
enableCourse:m,disableCourse:f,removeCourse:w,createCourse:I})}var sr,Pi,$l,lw,jl=g(()=>{kr();Yr();xl();En();dt();ut();vi();
|
|
1739
|
+
vn();lt();sr=16,Pi=1024*1024,$l=$({course:{type:"object",required:!0,schema:Lr},lock:{type:"object",required:!0},enabled:{
|
|
1737
1740
|
type:"boolean",required:!0}}),lw=$({schemaVersion:{type:"integer",required:!0,enum:[1]},revision:{type:"integer",required:!0,
|
|
1738
|
-
min:0,max:Number.MAX_SAFE_INTEGER},courses:H($
|
|
1739
|
-
import W from"node:path";import{randomUUID as
|
|
1740
|
-
"install-topic"){let[,c,
|
|
1741
|
-
pic-directory> <system-root>");let
|
|
1742
|
-
schemaVersion:1,topicId:m,release:
|
|
1743
|
-
{sourceRoot:
|
|
1741
|
+
min:0,max:Number.MAX_SAFE_INTEGER},courses:H($l,sr)})});var Dl={};xi(Dl,{runTrainingCli:()=>Ti});import{mkdir as Ll,readFile as Tn,realpath as It,rename as dw,rm as Ml,writeFile as Ci}from"node:fs/promises";
|
|
1742
|
+
import W from"node:path";import{randomUUID as pw}from"node:crypto";async function Ti(e,{write:t=r=>console.log(r)}={}){if(e[0]===
|
|
1743
|
+
"install-topic"){let[,c,u]=e;if(e.length!==3||!c||!u)throw new Error("Usage: vibe64 training install-topic <committed-to\
|
|
1744
|
+
pic-directory> <system-root>");let l=await It(c),{topicId:m,release:h,repository:f,commit:w,topicHash:I}=await er(l),S={
|
|
1745
|
+
schemaVersion:1,topicId:m,release:h,repository:f,commit:w,topicHash:I},d=await Nl({systemRoot:W.resolve(u)}).installTopic(
|
|
1746
|
+
{sourceRoot:l,pin:S});return t(JSON.stringify({ok:!0,installed:d.installed,pin:d.pin},null,2)),0}if(e[0]==="installed-co\
|
|
1744
1747
|
urses"){if(e.length!==2||!e[1])throw new Error("Usage: vibe64 training installed-courses <system-root>");let c=await Ni(
|
|
1745
1748
|
{systemRoot:W.resolve(e[1])}).readCatalogue();return t(JSON.stringify({ok:!0,...c},null,2)),0}if(["enable-course","disab\
|
|
1746
|
-
le-course","remove-course"].includes(e[0])){let[c,l,
|
|
1747
|
-
"")||!Number.isSafeInteger(Number(
|
|
1749
|
+
le-course","remove-course"].includes(e[0])){let[c,u,l,m,h]=e;if(e.length!==5||!u||!l||!m||!/^(0|[1-9][0-9]*)$/u.test(h||
|
|
1750
|
+
"")||!Number.isSafeInteger(Number(h)))throw new Error(c==="enable-course"?"Usage: vibe64 training enable-course <course.\
|
|
1748
1751
|
json> <course.lock.json> <system-root> <expected-revision>":`Usage: vibe64 training ${c} <courseId> <release> <system-ro\
|
|
1749
|
-
ot> <expected-revision>`);let
|
|
1750
|
-
parse(await
|
|
1751
|
-
urse":"disableCourse"]({courseId:
|
|
1752
|
-
"publish-manifest"){let[,c,...
|
|
1753
|
-
n> <committed-topic-directory...>");let
|
|
1754
|
-
|
|
1755
|
-
let
|
|
1752
|
+
ot> <expected-revision>`);let f=Ni({systemRoot:W.resolve(m)}),w=Number(h),I=c==="enable-course"?await f.enableCourse({course:JSON.
|
|
1753
|
+
parse(await Tn(u,"utf8")),lock:JSON.parse(await Tn(l,"utf8")),expectedRevision:w}):await f[c==="remove-course"?"removeCo\
|
|
1754
|
+
urse":"disableCourse"]({courseId:u,release:l,expectedRevision:w});return t(JSON.stringify({ok:!0,...I},null,2)),0}if(e[0]===
|
|
1755
|
+
"publish-manifest"){let[,c,...u]=e;if(!c||!u.length)throw new Error("Usage: vibe64 training publish-manifest <course.jso\
|
|
1756
|
+
n> <committed-topic-directory...>");let l=await It(c),m=W.join(await It(W.dirname(W.resolve(c))),"course.lock.json");if(m===
|
|
1757
|
+
l||W.basename(c)==="course.lock.json")throw new Error("Course lock output must not replace its input course descriptor.");
|
|
1758
|
+
let h=JSON.parse(await Tn(l,"utf8")),f=[];for(let S of u){let d=await It(S),p=W.relative(d,m);if(!p||!p.startsWith(`..${W.
|
|
1756
1759
|
sep}`)&&p!==".."&&!W.isAbsolute(p))throw new Error("Course lock output must be outside every pinned source topic.");await He(
|
|
1757
|
-
d,{authoring:!0}),
|
|
1758
|
-
`,{flag:"wx"}),await
|
|
1760
|
+
d,{authoring:!0}),f.push(await er(d))}let w=tr(h,f),I=`${m}.tmp-${pw()}`;try{await Ci(I,`${L(w)}
|
|
1761
|
+
`,{flag:"wx"}),await dw(I,m)}finally{await Ml(I,{force:!0})}return t(JSON.stringify({ok:!0,courseId:w.courseId,status:w.
|
|
1759
1762
|
status,lockPath:m,topics:w.topics.length},null,2)),0}let[r,n,o]=e;if(!["validate","bundle"].includes(r)||!n||r==="bundle"&&
|
|
1760
1763
|
!o||e.length!==(r==="bundle"?3:2))throw new Error("Usage: vibe64 training validate <topic-directory> | bundle <topic-dir\
|
|
1761
1764
|
ectory> <new-output-directory>");let i=await It(n),s=await He(i,{authoring:r==="validate"}),a={schemaVersion:1,topic:s.topic,
|
|
1762
|
-
release:s.release,topicHash:s.topicHash,topicManifest:s.topicManifest,lessons:s.bundles.map(({lesson:c,hash:
|
|
1763
|
-
manifest:
|
|
1764
|
-
W.dirname(c)),W.basename(c)),
|
|
1765
|
-
"Bundle output must be outside the source topic.");await
|
|
1766
|
-
for(let
|
|
1767
|
-
path}. Validate and retry.`);let w=W.join(
|
|
1768
|
-
await Ci(W.join(
|
|
1769
|
-
`,{flag:"wx"})}catch(m){throw await
|
|
1770
|
-
status:s.topic.status,lessons:s.bundles.map(({lesson:c,hash:
|
|
1771
|
-
schemaVersion,...c.stage?{stage:c.stage}:{},...me(c)?{steps:c.steps.length}:{}}))},null,2)),0}var Ai=g(()=>{dt();
|
|
1772
|
-
|
|
1773
|
-
import ar from"node:path";import{fileURLToPath as
|
|
1774
|
-
resolve(String(e||""));try{return t(r)}catch{return r}}function ji({entrypointPath:e,argv:t=
|
|
1775
|
-
return n?$i(n,r)===$i(e,r):!1}var
|
|
1776
|
-
return`'${String(e).replaceAll("'","'\\''")}'`}function
|
|
1777
|
-
"${String(e).replaceAll('"','\\"')}"`}function
|
|
1778
|
-
...t}={}){return ji({entrypointPath:e,...t})}function
|
|
1779
|
-
env,osReleaseText:t=
|
|
1780
|
-
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function
|
|
1781
|
-
return[Tt(e),Tt(t),...r.map(n=>Tt(n))].join(" ")}function
|
|
1765
|
+
release:s.release,topicHash:s.topicHash,topicManifest:s.topicManifest,lessons:s.bundles.map(({lesson:c,hash:u,status:l,required:m,
|
|
1766
|
+
manifest:h})=>({code:c.code,hash:u,status:l,required:m,manifest:h}))};if(r==="bundle"){let c=W.resolve(o),u=W.join(await It(
|
|
1767
|
+
W.dirname(c)),W.basename(c)),l=W.relative(i,u);if(!l||!l.startsWith(`..${W.sep}`)&&l!==".."&&!W.isAbsolute(l))throw new Error(
|
|
1768
|
+
"Bundle output must be outside the source topic.");await Ll(u);try{let m=Be([s.topicManifest,...s.bundles.map(h=>h.manifest)]);
|
|
1769
|
+
for(let h of m){let f=await Tn(W.join(i,h.path));if(K(f)!==h.sha256)throw new Error(`Source changed during bundling: ${h.
|
|
1770
|
+
path}. Validate and retry.`);let w=W.join(u,"files",h.path);await Ll(W.dirname(w),{recursive:!0}),await Ci(w,f,{flag:"wx"})}
|
|
1771
|
+
await Ci(W.join(u,"bundle.json"),`${L(a)}
|
|
1772
|
+
`,{flag:"wx"})}catch(m){throw await Ml(u,{recursive:!0,force:!0}),m}}return t(JSON.stringify({ok:!0,topicId:s.topic.topicId,
|
|
1773
|
+
status:s.topic.status,lessons:s.bundles.map(({lesson:c,hash:u,status:l})=>({code:c.code,hash:u,status:l,schemaVersion:c.
|
|
1774
|
+
schemaVersion,...c.stage?{stage:c.stage}:{},...me(c)?{steps:c.steps.length}:{}}))},null,2)),0}var Ai=g(()=>{dt();ut();En();
|
|
1775
|
+
Cl();jl();lt()});import{spawn as Ul}from"node:child_process";import{readFileSync as fw}from"node:fs";import{release as An}from"node:os";import j from"node:process";
|
|
1776
|
+
import ar from"node:path";import{fileURLToPath as hw}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.
|
|
1777
|
+
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];
|
|
1778
|
+
return n?$i(n,r)===$i(e,r):!1}var mw=new URL("./run.js",import.meta.url).href,Vl=hw(mw),Gl=ar.dirname(Vl),At=ar.join(Gl,"server.js");function Tt(e=""){
|
|
1779
|
+
return`'${String(e).replaceAll("'","'\\''")}'`}function gw(e=""){return JSON.stringify(String(e))}function ki(e=""){return`\
|
|
1780
|
+
"${String(e).replaceAll('"','\\"')}"`}function ww(e="",t=[]){return[ki(e),...t.map(r=>ki(r))].join(" ")}function yw({entrypointPath:e=Vl,
|
|
1781
|
+
...t}={}){return ji({entrypointPath:e,...t})}function Bl(e=j.cwd()){return ar.basename(e)||"target"}function _w({env:e=j.
|
|
1782
|
+
env,osReleaseText:t=An(),platform:r=j.platform}={}){return r!=="linux"?!1:String(e.WSL_DISTRO_NAME||e.WSL_INTEROP||"").trim()?
|
|
1783
|
+
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function Ew({nodePath:e=j.execPath,serverPath:t=At,serverArgs:r=[]}={}){
|
|
1784
|
+
return[Tt(e),Tt(t),...r.map(n=>Tt(n))].join(" ")}function bw({cwd:e=j.cwd(),nodePath:t=j.execPath,serverArgs:r=[],serverPath:n=At,
|
|
1782
1785
|
title:o=`Vibe64 - ${ar.basename(j.cwd())||"target"}`}={}){return["finish_vibe64_terminal() {",' status="$1"',' message\
|
|
1783
1786
|
="$2"',' if [ "$status" -ne 0 ]; then',` printf '\\n%s Exit status %s. Press Enter to close this terminal...' "$messa\
|
|
1784
1787
|
ge" "$status"`," IFS= read -r _"," fi",' exit "$status"',"}",`cd ${Tt(e)}`,"status=$?",'if [ "$status" -ne 0 ]; the\
|
|
1785
1788
|
n',' finish_vibe64_terminal "$status" "Vibe64 could not enter the target directory."',"fi",`printf '\\033]0;%s\\007' ${Tt(
|
|
1786
|
-
o)}`,
|
|
1787
|
-
`)}function
|
|
1788
|
-
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",
|
|
1789
|
-
cwd:e=j.cwd(),env:t=j.env,shellScript:r="",title:n=`Vibe64 - ${
|
|
1789
|
+
o)}`,Ew({nodePath:t,serverArgs:r,serverPath:n}),'finish_vibe64_terminal "$?" "Vibe64 server exited."'].join(`
|
|
1790
|
+
`)}function vw(e=""){return`printf %s ${Buffer.from(String(e||""),"utf8").toString("base64")} | base64 -d | bash`}function Sw({
|
|
1791
|
+
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",vw(t)]}function Iw({
|
|
1792
|
+
cwd:e=j.cwd(),env:t=j.env,shellScript:r="",title:n=`Vibe64 - ${Bl(e)}`}={}){let o=Sw({distroName:t.WSL_DISTRO_NAME,shellScript:r});
|
|
1790
1793
|
return[{command:"wt.exe",args:["new-window","--title",n,"wsl.exe",...o]},{command:"cmd.exe",args:["/d","/c",`start ${ki(
|
|
1791
|
-
n)} ${
|
|
1792
|
-
platform,serverArgs:i=[],serverPath:s=At}={}){let a=`Vibe64 - ${
|
|
1793
|
-
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${
|
|
1794
|
+
n)} ${ww("wsl.exe",o)}`]}]}function Tw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=An(),platform:o=j.
|
|
1795
|
+
platform,serverArgs:i=[],serverPath:s=At}={}){let a=`Vibe64 - ${Bl(e)}`,c=bw({cwd:e,nodePath:r,serverArgs:i,serverPath:s,
|
|
1796
|
+
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${gw(
|
|
1794
1797
|
c)}`,"end tell"].join(`
|
|
1795
|
-
`)]}];let
|
|
1798
|
+
`)]}];let u=[t.TERMINAL?{command:t.TERMINAL,args:["-e","bash","-lc",c]}:null,{command:"x-terminal-emulator",args:["-e","\
|
|
1796
1799
|
bash","-lc",c]},{command:"gnome-terminal",args:["--","bash","-lc",c]},{command:"konsole",args:["-e","bash","-lc",c]},{command:"\
|
|
1797
|
-
xfce4-terminal",args:["--command",`bash -lc ${Tt(c)}`]},{command:"xterm",args:["-e","bash","-lc",c]}].filter(Boolean);return
|
|
1798
|
-
{env:t,osReleaseText:n,platform:o})?[...
|
|
1799
|
-
(n,o)=>{let i=
|
|
1800
|
-
cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=
|
|
1801
|
-
let a=
|
|
1802
|
-
|
|
1803
|
-
started.")}async function
|
|
1804
|
-
r,[o,...n],{cwd:e,env:t,stdio:"inherit"});return new Promise((s,a)=>{i.once("error",a),i.once("exit",(c,
|
|
1805
|
-
return}s(Number(c||0))})})}function
|
|
1806
|
-
|
|
1807
|
-
terprises/vibe64/blob/main/docs/colleague-usage/${e==="darwin"?"set-up-macos":"set-up-linux"}.md`}function
|
|
1808
|
-
platform,nodeVersion:t=j.versions.node,requiredMajor:r=
|
|
1800
|
+
xfce4-terminal",args:["--command",`bash -lc ${Tt(c)}`]},{command:"xterm",args:["-e","bash","-lc",c]}].filter(Boolean);return _w(
|
|
1801
|
+
{env:t,osReleaseText:n,platform:o})?[...Iw({cwd:e,env:t,shellScript:c,title:a}),...u]:u}function Aw(e,t=[],r={}){return new Promise(
|
|
1802
|
+
(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 Ow({
|
|
1803
|
+
cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=An(),platform:o=j.platform,serverArgs:i=[],serverPath:s=At}={}){
|
|
1804
|
+
let a=Tw({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),c=[];for(let u of a)try{return await Aw(
|
|
1805
|
+
u.command,u.args,{cwd:e,env:t}),u}catch(l){c.push(l)}throw new AggregateError(c,"No supported terminal emulator could be\
|
|
1806
|
+
started.")}async function Pw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,serverArgs:n=[],serverPath:o=At}={}){let i=Ul(
|
|
1807
|
+
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);
|
|
1808
|
+
return}s(Number(c||0))})})}function Rw(e=ar.join(Gl,"..","package.json")){try{return/^\D*(\d+)/u.exec(String(JSON.parse(
|
|
1809
|
+
fw(e,"utf8")).engines?.node||""))?.[1]||""}catch{return""}}function Nw(e=j.platform){return`https://github.com/mobily-en\
|
|
1810
|
+
terprises/vibe64/blob/main/docs/colleague-usage/${e==="darwin"?"set-up-macos":"set-up-linux"}.md`}function Cw({platform:e=j.
|
|
1811
|
+
platform,nodeVersion:t=j.versions.node,requiredMajor:r=Rw()}={}){if(e==="win32")return["Vibe64 runs on Windows inside WS\
|
|
1809
1812
|
L2 (Ubuntu), not in PowerShell or Command Prompt.","Step by step: https://github.com/mobily-enterprises/vibe64/blob/main\
|
|
1810
1813
|
/docs/colleague-usage/set-up-windows.md"].join(`
|
|
1811
1814
|
`);let n=String(t||"").split(".")[0];return r&&n!==r?[`Vibe64 needs Node.js ${r}; this is Node.js ${t}.`,`To install it \
|
|
1812
1815
|
with mise, run: curl -fsSL https://mise.run | sh && ~/.local/bin/mise use -g node@${r}`,"Then add mise to your shell, op\
|
|
1813
|
-
en a new terminal and run npx vibe64 again:",`${
|
|
1814
|
-
`):""}async function
|
|
1815
|
-
argv.slice(2),serverPath:s=At}={}){try{return await
|
|
1816
|
+
en a new terminal and run npx vibe64 again:",`${Nw(e)}#nodejs-and-mise`].join(`
|
|
1817
|
+
`):""}async function kw({cwd:e=j.cwd(),env:t=j.env,nodePath:r=j.execPath,osReleaseText:n=An(),platform:o=j.platform,serverArgs:i=j.
|
|
1818
|
+
argv.slice(2),serverPath:s=At}={}){try{return await Ow({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),
|
|
1816
1819
|
console.log("Vibe64 is starting in a new terminal window."),0}catch(a){return console.warn(`${a.message} Starting Vibe64\
|
|
1817
|
-
in this terminal instead.`),
|
|
1818
|
-
then(({runAgentSpecCli:n})=>n(j.argv.slice(3))),training:()=>Promise.resolve().then(()=>(Ai(),
|
|
1819
|
-
j.argv.slice(3)))},t=
|
|
1820
|
-
n}).catch(n=>{console.error("Failed to run Vibe64:",n),j.exitCode=1})}export{At as SERVER_ENTRYPOINT,
|
|
1821
|
-
Tt as quoteShellArg,
|
|
1822
|
-
|
|
1820
|
+
in this terminal instead.`),Pw({cwd:e,env:t,nodePath:r,serverArgs:i,serverPath:s})}}if(yw()){let e={spec:()=>Promise.resolve().then(()=>(ba(),Ea)).
|
|
1821
|
+
then(({runAgentSpecCli:n})=>n(j.argv.slice(3))),training:()=>Promise.resolve().then(()=>(Ai(),Dl)).then(({runTrainingCli:n})=>n(
|
|
1822
|
+
j.argv.slice(3)))},t=Cw();t&&(console.error(t),j.exit(1)),(Object.hasOwn(e,j.argv[2])?e[j.argv[2]]():kw()).then(n=>{j.exitCode=
|
|
1823
|
+
n}).catch(n=>{console.error("Failed to run Vibe64:",n),j.exitCode=1})}export{At as SERVER_ENTRYPOINT,yw as isDirectCliExecution,_w as isWslEnvironment,Ow as launchInNewTerminal,Cw as launcherProblem,
|
|
1824
|
+
Tt as quoteShellArg,kw as runLauncher,Ew as serverShellCommand,Bl as targetNameFromCwd,Tw as terminalLaunchCandidates,bw as terminalShellScript,
|
|
1825
|
+
Sw as wslServerCommandArgs,Iw as wslTerminalLaunchCandidates};
|