vibe64 0.1.65 → 0.1.67
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 +2004 -1363
- package/bin/server.js +282 -276
- package/bin/upgrade-state.js +4673 -4470
- package/dist/assets/{GithubBrowserTabs-D21Nl3QI.js → GithubBrowserTabs-CW3GBeJu.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-POxY1K1U.js → LocalDatabaseServer-DYh3UF9q.js} +1 -1
- package/dist/assets/{SelectField-Dezd0B3y.js → SelectField-Df50ZFLj.js} +1 -1
- package/dist/assets/{ShellOutlet-DfF9vsWA.js → ShellOutlet-DkLdtzJW.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-I3ufyScN.js → Vibe64AuthSettingsButton-Cksj7FS6.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-DFfFPrd7.css → Vibe64AuthSettingsButton-DfKYI6ZS.css} +1 -1
- package/dist/assets/{Vibe64ConversationLog-C04oOQ2g.js → Vibe64ConversationLog-BC0eDtUP.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-BbrOUmRD.js → Vibe64DashboardShell-DX5dOXAB.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-VPEM2o1v.js → Vibe64DatabaseWorkspace-8i-RDc9y.js} +1 -1
- package/dist/assets/{Vibe64FileArea-C_nC2bPk.js → Vibe64FileArea-EK5yUio3.js} +1 -1
- package/dist/assets/{Vibe64OutputControls-DTO3Fw3x.js → Vibe64OutputControls--LB4G83q.js} +1 -1
- package/dist/assets/{Vibe64RepositoryWorkspace-B8xcCOvL.js → Vibe64RepositoryWorkspace-D6uJCype.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-Cb9Mxsyq.js → Vibe64SessionFiles-DVHGc7hd.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-CVQ3NRjh.js → Vibe64SessionSourceEditor-Bws5ihr-.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-BV4JFgcZ.js → Vibe64UiStoryboardView-BmABkyG4.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-DGQAxYE-.js → Vibe64UnavailableSessions-C6Bkwsqk.js} +1 -1
- package/dist/assets/{_pageId_-CkG15vv4.js → _pageId_-FjW-3sqF.js} +1 -1
- package/dist/assets/{_sessionId_-Bka3RUmK.js → _sessionId_-4cH83Bfi.js} +1 -1
- package/dist/assets/_slug_-Cazfy5ui.js +14 -0
- package/dist/assets/_slug_-DQDycgFK.css +1 -0
- package/dist/assets/{access-Xo3unxGO.js → access-mxcxtn7b.js} +1 -1
- package/dist/assets/{app-B0spNegd.js → app-8zP_FAuO.js} +1 -1
- package/dist/assets/assistantRouting-Bbxguvre.js +3 -0
- package/dist/assets/{changes-DFv4tuoO.js → changes-cmlEyHug.js} +1 -1
- package/dist/assets/{client-4uCr4dYG.js → client-BJBzomgt.js} +1 -1
- package/dist/assets/{client-CVuXqm4b.js → client-C1i-bIgL.js} +1 -1
- package/dist/assets/{client-Dlg1kjjO.js → client-C7yZ1hEm.js} +1 -1
- package/dist/assets/{client-CevjVK2b.js → client-CQ49uWhR.js} +1 -1
- package/dist/assets/{client-DR0w56e8.js → client-D46Uu-YO.js} +2 -2
- package/dist/assets/{client-BjMjS6lX.js → client-DKNTl1to.js} +2 -2
- package/dist/assets/{conversation-OkWbkHjm.js → conversation-CFJRkeTj.js} +3 -3
- package/dist/assets/{conversation-DReMq0MF.css → conversation-COcuIkcD.css} +1 -1
- package/dist/assets/conversation-CexAK3Qk.js +1 -0
- package/dist/assets/{dashboard-CAca9MQn.js → dashboard-CMtWKazq.js} +1 -1
- package/dist/assets/{english-definitions-BtX8KA5g.js → english-definitions-DiyU9O9D.js} +1 -1
- package/dist/assets/{env-DrNyBVkB.js → env-LUc22Wgd.js} +1 -1
- package/dist/assets/{error-BqMxhgpB.js → error-BccdQn04.js} +1 -1
- package/dist/assets/{error-BQ7r64JO.js → error-DPDAz9Td.js} +1 -1
- package/dist/assets/{errorMessageHelpers-B49LyMJi.js → errorMessageHelpers-G32Hjqfm.js} +1 -1
- package/dist/assets/{health-B5yTW5Tt.js → health-CfMjMJFf.js} +1 -1
- package/dist/assets/{history-S3anp6xg.js → history-hX_kNskf.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-DQPYjuW7.js → i18n-BSfPKqM3.js} +1 -1
- package/dist/assets/{i18n-Dm74yE_M.js → i18n-Dq-ep9n7.js} +1 -1
- package/dist/assets/index-BJWiPV6i.css +1 -0
- package/dist/assets/index-FVeEbKiO.js +134 -0
- package/dist/assets/{integrations-C7dj7el_.js → integrations-Ccb8EOEO.js} +14 -15
- package/dist/assets/{integrations-CwgrZgmM.css → integrations-CtnIjM1Y.css} +1 -1
- package/dist/assets/{issues-OkV4v4GX.js → issues-Bxtt7oqi.js} +1 -1
- package/dist/assets/{learning-lW9nBGjT.js → learning-BUx9jo91.js} +1 -1
- package/dist/assets/{pages-shOT9IVe.js → pages-D43zM2UW.js} +1 -1
- package/dist/assets/{project-files-D_K1N0JF.js → project-files-BX3zZCcl.js} +1 -1
- package/dist/assets/{publish-Bxe4ZCqe.js → publish-DatierL2.js} +1 -1
- package/dist/assets/{pull-requests-CQvk0TeH.js → pull-requests-DNkOjcuy.js} +1 -1
- package/dist/assets/{repository-CI2CqDwF.js → repository-0EKOcyTL.js} +1 -1
- package/dist/assets/{settings-DIVrFrs4.js → settings-DbR9JIc3.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-BkWrTOzg.js → useArchivedVibe64Sessions-B8VDhA9F.js} +1 -1
- package/dist/assets/useAssistantAttachments-C9kAnWqw.js +2 -0
- package/dist/assets/useCommand-CfqxMb4C.js +1 -0
- package/dist/assets/{useEndpointResource-DZTjr9gg.js → useEndpointResource-BwGXpV2u.js} +1 -1
- package/dist/assets/{useUiFeedback-BU4NyMq8.js → useUiFeedback-8Wvg7A_S.js} +1 -1
- package/dist/assets/{useVibe64ConversationLog-BADhWyNY.js → useVibe64ConversationLog-7wgLlKG5.js} +2 -2
- package/dist/assets/useVibe64Learning-DkneotqS.js +5 -0
- package/dist/assets/{useVibe64SessionData-DvFvAJC-.js → useVibe64SessionData-DuJ-dHR8.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-BukDTAxb.js → useVibe64SessionSelection-BwjtqeIR.js} +1 -1
- package/dist/assets/{vibe64FileUpload-BDkcaUyk.js → vibe64FileUpload-D_rOa1R8.js} +1 -1
- package/dist/assets/{vibe64RepositoryRealtime-DX2DEqIz.js → vibe64RepositoryRealtime-CVGNqwxz.js} +1 -1
- package/dist/assets/vibe64SavedEnvValues-CCZew0j7.js +1 -0
- package/dist/assets/{vibe64SessionFocus-CzuP3qPT.js → vibe64SessionFocus-B4diopOJ.js} +1 -1
- package/dist/index.html +23 -23
- package/docs/colleague-usage/ai-accounts.md +7 -7
- package/docs/colleague-usage/ai-model-setups.md +1 -1
- package/docs/colleague-usage/ai-tasks.md +2 -1
- package/docs/colleague-usage/auto-workflow.md +67 -44
- package/docs/colleague-usage/chat-settings.md +115 -114
- package/docs/colleague-usage/coding-agent-goal-pause.md +34 -12
- package/docs/colleague-usage/coding-agent-goals.md +33 -16
- package/docs/colleague-usage/coding-agent-history.md +9 -0
- package/docs/colleague-usage/coding-agent-questions.md +7 -0
- package/docs/colleague-usage/coding-agent-recovery.md +3 -0
- package/docs/colleague-usage/coding-agents.md +10 -4
- package/docs/colleague-usage/connected-repositories.md +4 -1
- package/docs/colleague-usage/developing-vibe64.md +11 -5
- package/docs/colleague-usage/development-env.md +74 -32
- package/docs/colleague-usage/github-work.md +39 -5
- package/docs/colleague-usage/integrations.md +2 -2
- package/docs/colleague-usage/main-chat-approvals.md +7 -6
- package/docs/colleague-usage/message-delivery-recovery.md +1 -1
- package/docs/colleague-usage/passes.md +260 -0
- package/docs/colleague-usage/plans.md +27 -16
- package/docs/colleague-usage/session-timeline.md +93 -0
- package/docs/colleague-usage/temporary-chats.md +6 -0
- package/docs/colleague-usage/ui-pass.md +30 -32
- package/docs/colleague-usage/workspace-preparation.md +51 -0
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +12 -0
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +2 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +5 -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/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/patterns/calendar-cli/example/.env.example +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/patterns/api-key-connection/PATTERN.md +4 -1
- package/node_modules/@jskit-ai/connectors-catalog/patterns/oauth-connection/PATTERN.md +3 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-core/README.md +3 -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 +3 -4
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +1 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/patterns/realtime-application/example/.env.example +1 -0
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-core/package.json +2 -0
- package/node_modules/@local/vibe64-execution/package.json +1 -0
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +715 -666
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +989 -847
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +129 -107
- package/node_modules/@local/vibe64-genesis/src/server/index.js +632 -614
- package/node_modules/@local/vibe64-genesis/src/server/packaging.js +27 -28
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +172 -162
- package/node_modules/@local/vibe64-runtime/package.json +1 -0
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +1042 -898
- package/node_modules/@local/vibe64-terminals/package.json +2 -1
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +560 -420
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +586 -581
- package/package.json +15 -15
- package/server.bundle.mjs +44592 -44103
- package/dist/assets/_slug_-7Oo7pGKn.js +0 -14
- package/dist/assets/_slug_-BaxjtsgP.css +0 -1
- package/dist/assets/assistantRouting-B9cub38g.js +0 -3
- package/dist/assets/conversation-D7T_us2O.js +0 -1
- package/dist/assets/index-DSyb-mRJ.css +0 -1
- package/dist/assets/index-JBqyg0mr.js +0 -134
- package/dist/assets/useAssistantAttachments-DqlNFiha.js +0 -2
- package/dist/assets/useCommand-D-MIMmhp.js +0 -1
- package/dist/assets/useVibe64Learning-CbsI-XHB.js +0 -5
- package/dist/assets/vibe64SavedEnvValues-CgfMvj_h.js +0 -1
package/bin/run.js
CHANGED
|
@@ -1,310 +1,313 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
[{
|
|
3
|
+
var ag=Object.create;var Bo=Object.defineProperty;var cg=Object.getOwnPropertyDescriptor;var ug=Object.getOwnPropertyNames;var lg=Object.getPrototypeOf,dg=Object.prototype.hasOwnProperty;var X=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){
|
|
4
|
+
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var b=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var z=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},zo=(e,t)=>{for(var r in t)
|
|
5
|
+
Bo(e,r,{get:t[r],enumerable:!0})},fg=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ug(t))!dg.call(
|
|
6
|
+
e,o)&&o!==r&&Bo(e,o,{get:()=>t[o],enumerable:!(n=cg(t,o))||n.enumerable});return e};var pg=(e,t,r)=>(r=e!=null?ag(lg(e)):{},fg(t||!e||!e.__esModule?Bo(r,"default",{value:e,enumerable:!0}):r,e));import{readFile as wg}from"node:fs/promises";var yg,Qa,ec,tc=b(()=>{yg=new URL("./../node_modules/@local/vibe64-source-e\
|
|
7
|
+
ditor/src/server/agentSpecs.js",import.meta.url).href,Qa=e=>()=>wg(new URL(`../../docs/${e}`,yg),"utf8"),ec=Object.freeze(
|
|
8
|
+
[{name:"integration-setup-command",title:"Integration setup command protocol and integrations.json",text:Qa("application\
|
|
6
9
|
-integration-setup.md")},{name:"integration-payments-laravel",title:"Implementing the integration setup payment operatio\
|
|
7
|
-
ns in Laravel",text:
|
|
8
|
-
return!!(e&&typeof e=="object"&&!Array.isArray(e))}var
|
|
9
|
-
|
|
10
|
-
name="AppError",this.status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=
|
|
11
|
-
n.messageCode&&(this.messageCode=String(n.messageCode),this.messageParams=
|
|
12
|
-
headers=n.headers||{}}}});var
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function
|
|
16
|
-
let{items:r}=t;if(
|
|
17
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function
|
|
18
|
-
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(
|
|
10
|
+
ns in Laravel",text:Qa("application-payments-laravel.md")}])});var tr,Yr,_g,Jr,rc=b(()=>{tr="email",Yr="login",_g="user-id",Jr=Object.freeze([tr,Yr,_g])});function F(e,{fallback:t=""}={}){return String(e||"").trim()||t}function St(e){return String(e??"").trim()}function ue(e,{
|
|
11
|
+
fallback:t={}}={}){return H(e)?e:{...t}}function H(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}var KA,U=b(()=>{
|
|
12
|
+
KA=Object.freeze(["none","pending","committed","rolledBack","unknown"])});function Kr(e){return H(e)?{...e}:{}}var Go=b(()=>{U()});var ie,Xr=b(()=>{Go();ie=class extends Error{constructor(t,r,n={}){super(r,n.cause===void 0?void 0:{cause:n.cause}),this.
|
|
13
|
+
name="AppError",this.status=Number(t)||500,this.statusCode=this.status,this.code=n.code||"APP_ERROR",this.params=Kr(n.params),
|
|
14
|
+
n.messageCode&&(this.messageCode=String(n.messageCode),this.messageParams=Kr(n.messageParams)),this.details=n.details,this.
|
|
15
|
+
headers=n.headers||{}}}});var nc=b(()=>{U()});var oc=b(()=>{U()});function Q(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||
|
|
16
|
+
Eg(t)}function Eg(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}
|
|
17
|
+
var vt=b(()=>{});function Fo(e){return e!==null&&typeof e=="object"&&Q(e.structure)&&Q(e.operations)&&typeof e.validateWith=="function"&&
|
|
18
|
+
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function Zr(e,t){if(!Object.hasOwn(t,"items"))return null;
|
|
19
|
+
let{items:r}=t;if(Fo(r))return{kind:"schema",schema:r};if(!Q(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
20
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function rr(e,t){
|
|
21
|
+
if(!Object.hasOwn(t,"values"))return null;let{values:r}=t;if(Fo(r))return{kind:"schema",schema:r};if(!Q(r)||typeof r.type!=
|
|
19
22
|
"string")throw new Error(`Object field "${e}" must define values as either a Schema instance or a field definition objec\
|
|
20
|
-
t.`);return{kind:"definition",definition:r}}function
|
|
23
|
+
t.`);return{kind:"definition",definition:r}}function Qr(e,t){let r=Object.hasOwn(t,"schema"),n=Object.hasOwn(t,"values"),
|
|
21
24
|
o=Object.hasOwn(t,"additionalProperties");if(r&&n)throw new Error(`Object field "${e}" cannot define both schema and val\
|
|
22
25
|
ues.`);if(o&&t.additionalProperties!==!0)throw new Error(`Object field "${e}" only supports additionalProperties: true.`);
|
|
23
26
|
if(n&&t.additionalProperties===!0)throw new Error(`Object field "${e}" cannot define both values and additionalPropertie\
|
|
24
|
-
s: true.`);if(r){if(!
|
|
25
|
-
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:
|
|
26
|
-
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}var
|
|
27
|
-
if(
|
|
27
|
+
s: true.`);if(r){if(!Fo(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
|
|
28
|
+
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:rr(
|
|
29
|
+
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}var Ho=b(()=>{vt()});function Tt(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}function qo(e,t=""){
|
|
30
|
+
if(Q(e))for(let[r,n]of Object.entries(e)){if(!Q(n))continue;let o=t?`${t}.${r}`:r;for(let i of["minItems","maxItems"]){if(!Object.
|
|
28
31
|
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
32
|
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"&&
|
|
31
|
-
o)}}var
|
|
32
|
-
let n=Number(e),o=Number(t),i=Number(r);return o>=1&&o<=12&&i>=1&&i<=
|
|
33
|
+
) is above its maxItems (${n.maxItems}).`);n.type==="array"&&Q(n.items)&&typeof n.items.type=="string"&&qo({"[]":n.items},
|
|
34
|
+
o)}}var en=b(()=>{vt()});function Rg(e){return e%4===0&&(e%100!==0||e%400===0)}function Ag(e,t){return t===2?Rg(e)?29:28:Og[t-1]}function pc(e,t,r){
|
|
35
|
+
let n=Number(e),o=Number(t),i=Number(r);return o>=1&&o<=12&&i>=1&&i<=Ag(n,o)}function nr(e,t){let r=e.temporalPrecision;
|
|
33
36
|
if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(`temporalPrecision for "${t}" must be a non-negative integer\
|
|
34
|
-
.`);return r}}function
|
|
35
|
-
let t=
|
|
36
|
-
null&&
|
|
37
|
-
|
|
38
|
-
return`^${
|
|
39
|
-
let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&
|
|
40
|
-
r)||r<-t||r>t?null:r===0?0:r}var
|
|
41
|
-
\\d{4}",
|
|
42
|
-
](?:${
|
|
43
|
-
new RegExp(`^${
|
|
44
|
-
|
|
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?
|
|
37
|
+
.`);return r}}function mc(e,t){return e===void 0?!0:t===void 0||e.length<=t}function hc(e){if(typeof e!="string")return!1;
|
|
38
|
+
let t=Sg.exec(e);return t!==null&&pc(t[1],t[2],t[3])}function gc(e,t){if(typeof e!="string")return!1;let r=vg.exec(e);return r!==
|
|
39
|
+
null&&mc(r[1],t)}function yc(e,t){if(typeof e!="string")return!1;let r=Tg.exec(e);return r===null?!1:pc(r[1],r[2],r[3])&&
|
|
40
|
+
mc(r[4],t)}function wc(e){return e===void 0?"(?:\\.\\d+)?":e===0?"":`(?:\\.\\d{1,${e}})?`}function _c(e,t){let r=nr(e,t);
|
|
41
|
+
return`^${tn}(?::${It}${wc(r)})?$`}function bc(e,t){let r=nr(e,t);return`^${dc}T${tn}:${It}${wc(r)}${uc}$`}function Yo(e,t){
|
|
42
|
+
let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&Ig.test(e))r=Number(e);else return null;return!Number.isSafeInteger(
|
|
43
|
+
r)||r<-t||r>t?null:r===0?0:r}var Wo,ic,sc,ac,cc,It,tn,uc,lc,dc,fc,Sg,vg,Tg,Ig,Og,Jo=b(()=>{Wo="^(?:0|-?[1-9]\\d*)$",ic="\
|
|
44
|
+
\\d{4}",sc="0[1-9]|1[0-2]",ac="0[1-9]|[12]\\d|3[01]",cc="[01]\\d|2[0-3]",It="[0-5]\\d",tn=`(?:${cc}):${It}`,uc=`(?:Z|[+-\
|
|
45
|
+
](?:${cc}):${It})`,lc=`(${ic})-(${sc})-(${ac})`,dc=`${ic}-(?:${sc})-(?:${ac})`,fc=`^${dc}$`,Sg=new RegExp(`^${lc}$`),vg=
|
|
46
|
+
new RegExp(`^${tn}(?::${It}(?:\\.(\\d+))?)?$`),Tg=new RegExp(`^${lc}T${tn}:${It}(?:\\.(\\d+))?${uc}$`),Ig=new RegExp(Wo),
|
|
47
|
+
Og=[31,28,31,30,31,30,31,31,30,31,30,31]});function N(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Cg(e,t){if(Pg.
|
|
48
|
+
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function Ng(e){return typeof e!="string"?e:e.replace(
|
|
49
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Ko(e,t,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
50
|
+
let o=r?Ng(e):e;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${t}() expects a non-empty \
|
|
48
51
|
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
|
-
[
|
|
51
|
-
ject"&&!Array.isArray(n)&&!Array.isArray(o)){
|
|
52
|
+
for(let s of i)Cg(s,t);return i}var Pg,or=b(()=>{Pg=new Set(["__proto__","prototype","constructor"])});function Ec(e){return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Wo}]}}function et(e,t){return{
|
|
53
|
+
[De]:{[e]:t}}}function ri(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\
|
|
54
|
+
ject"&&!Array.isArray(n)&&!Array.isArray(o)){ri(o,n);continue}e[r]=n}}function Mg(e,t){if(!t||typeof t!="object"||Array.
|
|
52
55
|
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
|
-
|
|
54
|
-
e[r]=t[r]}}function
|
|
55
|
-
1?e:{anyOf:n}}function
|
|
56
|
-
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n
|
|
57
|
-
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
58
|
-
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=
|
|
56
|
+
De&&e[r]&&typeof e[r]=="object"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){ri(e[r],t[r]);continue}
|
|
57
|
+
e[r]=t[r]}}function Dg(e,t){let n=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return n.length===
|
|
58
|
+
1?e:{anyOf:n}}function Vg(e,t){if(!Object.hasOwn(e.types,t.type))throw new Error(`No casting function for type: ${t.type}`);
|
|
59
|
+
let r=e.types[t.type];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let n=$g[t.type];if(!n)throw new Error(
|
|
60
|
+
`Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return n}function Ug(e,t,r){if(!Object.
|
|
61
|
+
hasOwn(e.validators,t))return null;let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=Lg[t];
|
|
59
62
|
if(o)return o;throw new Error(`Validator '${t}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
60
|
-
hook.`)}function
|
|
61
|
-
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
62
|
-
void 0&&t.operation!==void 0){let r=
|
|
63
|
+
hook.`)}function Sc(e){if(e===void 0)return"create";if(["create","replace","patch"].includes(e))return e;throw new Error(
|
|
64
|
+
`Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function Bg(e,t={}){if(t.mode!==
|
|
65
|
+
void 0&&t.operation!==void 0){let r=Sc(t.mode);if(r!==t.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
63
66
|
s: mode '${r}' does not match operation '${t.operation}'.`)}if(t.operation!==void 0){if(!Object.hasOwn(e.operations,t.operation))
|
|
64
|
-
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return
|
|
67
|
+
throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return Sc(t.mode)}function zg(e,t={}){
|
|
65
68
|
if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
|
|
66
|
-
let r=
|
|
67
|
-
t,
|
|
68
|
-
e[
|
|
69
|
-
"_").replace(/^_+|_+$/g,"")||"operation"}function
|
|
70
|
-
function
|
|
71
|
-
r&&i.operation===n&&i.additionalProperties===o)||null}function
|
|
72
|
-
return e.nextDefinitionId+=1,n}function
|
|
69
|
+
let r=Bg(e,t);return{operationName:r,operation:e.operations[r]}}function Gg(e={}){let t={...e};return Object.defineProperty(
|
|
70
|
+
t,Zo,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function nn(e={}){return e[Zo]?
|
|
71
|
+
e[Zo]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function Fg(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
|
|
72
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function Qo(e){return Q(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
|
|
73
|
+
function rn(e){return Qo(e)?{allOf:[e]}:e}function Hg(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
|
|
74
|
+
r&&i.operation===n&&i.additionalProperties===o)||null}function qg(e,t){let r=Fg(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;
|
|
75
|
+
return e.nextDefinitionId+=1,n}function vc(e,t,r,n,o,{root:i=!1}={}){let s=nn(t),a=Hg(s,e,r,n,o);if(a)return i&&(a.pointer=
|
|
73
76
|
"#",s.rootNode=a),a;let c={schema:e,operationName:r,operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
74
|
-
|
|
75
|
-
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=
|
|
76
|
-
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=
|
|
77
|
-
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function
|
|
78
|
-
let i=
|
|
79
|
-
referenceBacked:t}}function
|
|
80
|
-
n)),n.enforceRequired&&
|
|
81
|
-
0&&(a.required=s),a}function
|
|
82
|
-
n,"replace",s.schema.operations.replace,!1)),[
|
|
83
|
-
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return
|
|
84
|
-
let s=
|
|
85
|
-
[
|
|
86
|
-
place"?e.operations.replace:i;return
|
|
87
|
-
t,r);if(a.kind==="nested")return
|
|
88
|
-
"opaque")return
|
|
89
|
-
e,t,r,n,o,i)})}let s=
|
|
77
|
+
qg(s,r),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function Tc(e,t){
|
|
78
|
+
if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let r=nn(t);e.status="build\
|
|
79
|
+
ing",e.pointer!=="#"&&(r.definitions[e.definitionName]={});let n=Wg(e.schema,t,e.operationName,e.operation,e.additionalProperties);
|
|
80
|
+
return e.status="built",e.pointer==="#"?n:(r.definitions[e.definitionName]=n,{$ref:e.pointer})}function ni(e,t,r,n,o=!1){
|
|
81
|
+
let i=nn(t),s=vc(e,t,r,n,o);return i.rootNode===s?{$ref:"#"}:Tc(s,t)}function ir(e,{referenceBacked:t=!1}={}){return{schema:e,
|
|
82
|
+
referenceBacked:t}}function Wg(e,t,r,n,o=!1){let i={},s=[];for(let[c,u]of Object.entries(e.structure))N(i,c,oi(e,c,u,t,r,
|
|
83
|
+
n)),n.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
|
|
84
|
+
0&&(a.required=s),a}function Yg(e,t,r,n,o,i){let s=Zr(t,r);if(!s)return null;if(s.kind==="schema")return{...rn(ni(s.schema,
|
|
85
|
+
n,"replace",s.schema.operations.replace,!1)),[De]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,
|
|
86
|
+
"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return oi(e,`${t}[]`,r.items,n,a,c)}function Jg(e,t,r,n,o,i){
|
|
87
|
+
let s=rr(t,r);if(!s)return null;if(s.kind==="schema")return{...rn(ni(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
88
|
+
[De]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="re\
|
|
89
|
+
place"?e.operations.replace:i;return oi(e,`${t}.*`,s.definition,n,a,c)}function Kg(e,t,r,n,o,i){if(r.type==="object"){let a=Qr(
|
|
90
|
+
t,r);if(a.kind==="nested")return ir(ni(a.schema,n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
91
|
+
"opaque")return ir({type:"object",additionalProperties:!0});if(a.kind==="map")return ir({type:"object",additionalProperties:Jg(
|
|
92
|
+
e,t,r,n,o,i)})}let s=Vg(e,r)({schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n});if(!s||typeof s!="object"||
|
|
90
93
|
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=
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
continue;let h=
|
|
95
|
-
c[
|
|
96
|
-
let
|
|
94
|
+
"array"){let a=Yg(e,t,r,n,o,i);if(a)return ir({...s,items:a},{referenceBacked:Qo(s)})}return ir(s,{referenceBacked:Qo(s)})}
|
|
95
|
+
function oi(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,operation:o,mode:o,options:n},a=Kg(e,t,r,n,o,i),c=a.referenceBacked?
|
|
96
|
+
rn(a.schema):{...a.schema},u={castType:r.type};for(let g of Object.keys(r)){if(g==="type"||!Object.hasOwn(e.validators,g))
|
|
97
|
+
continue;let h=Ug(e,g,t);if(!h)continue;let l=h({...s,parameterName:g,parameterValue:r[g],fieldSchema:{...c}});l&&Mg(c,l)}
|
|
98
|
+
c[De]&&(ri(u,c[De]),delete c[De]);let d=[];r.nullable===!0&&d.push({type:"null"}),r.nullOnEmpty===!0&&d.push({const:""});
|
|
99
|
+
let p=rn(Dg(c,d));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.defaultTo!="function"){let g=e._normalizeDefault(
|
|
97
100
|
r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(
|
|
98
|
-
o,i,{})});if(Object.keys(
|
|
99
|
-
nvalid (${h.code}).`)}
|
|
100
|
-
t),{operationName:n,operation:o}=
|
|
101
|
-
o,i,{root:!0}),c={$schema:
|
|
102
|
-
|
|
103
|
-
ema"
|
|
104
|
-
"y","on"],
|
|
101
|
+
o,i,{})});if(Object.keys(g.errors).length>0){let h=Object.values(g.errors)[0];throw new Error(`defaultTo for "${t}" is i\
|
|
102
|
+
nvalid (${h.code}).`)}p.default=g.value}else u.defaults={providedByFunction:!0};return p[De]=u,p}function Ic(e,t={}){let r=Gg(
|
|
103
|
+
t),{operationName:n,operation:o}=zg(e,r),i=r.additionalProperties===void 0?!1:r.additionalProperties,s=nn(r),a=vc(e,r,n,
|
|
104
|
+
o,i,{root:!0}),c={$schema:jg,...Tc(a,r)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}var jg,
|
|
105
|
+
De,Xo,Zo,xg,kg,$g,Lg,Oc=b(()=>{Ho();en();Jo();vt();or();jg="http://json-schema.org/draft-07/schema#",De="x-json-rest-sch\
|
|
106
|
+
ema",Xo=["object","array","string","number","boolean"],Zo=Symbol("json-rest-schema.exportContext"),xg=["true","1","yes",
|
|
107
|
+
"y","on"],kg=["false","0","no","n","off"];$g={none:()=>({type:Xo}),blob:()=>({type:Xo}),serialize:()=>({type:Xo}),object:()=>({
|
|
105
108
|
type:"object"}),array:()=>({type:"array"}),file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["n\
|
|
106
|
-
umber","string"]}),integer:()=>({type:["integer","string"]}),epochMilliseconds:()=>
|
|
107
|
-
dateTime:({definition:e,fieldName:t})=>({type:"string",format:"date-time",pattern:
|
|
108
|
-
date",pattern:
|
|
109
|
-
strictBoolean===!0)return{type:"boolean"};let t=new Set([...
|
|
110
|
-
[...
|
|
111
|
-
{type:"string",enum:[...r,...t]}]}},id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
109
|
+
umber","string"]}),integer:()=>({type:["integer","string"]}),epochMilliseconds:()=>Ec(864e13),epochSeconds:()=>Ec(864e10),
|
|
110
|
+
dateTime:({definition:e,fieldName:t})=>({type:"string",format:"date-time",pattern:bc(e,t)}),date:()=>({type:"string",format:"\
|
|
111
|
+
date",pattern:fc}),time:({definition:e,fieldName:t})=>({type:"string",pattern:_c(e,t)}),boolean:({definition:e})=>{if(e.
|
|
112
|
+
strictBoolean===!0)return{type:"boolean"};let t=new Set([...xg,String(e.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set(
|
|
113
|
+
[...kg,String(e.stringFalseWhen||"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},
|
|
114
|
+
{type:"string",enum:[...r,...t]}]}},id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},Lg={minLength:({
|
|
112
115
|
definition:e,parameterValue:t})=>e.type==="string"?{minLength:t}:null,maxLength:({definition:e,parameterValue:t})=>e.type===
|
|
113
|
-
"string"?{maxLength:t}:null,min:({definition:e,parameterValue:t})=>
|
|
116
|
+
"string"?{maxLength:t}:null,min:({definition:e,parameterValue:t})=>Tt(e)?{minimum:t}:null,max:({definition:e,parameterValue:t})=>Tt(
|
|
114
117
|
e)?{maximum:t}:null,pattern:({definition:e,parameterValue:t})=>e.type==="string"?{pattern:t instanceof RegExp?t.source:t}:
|
|
115
118
|
null,enum:({parameterValue:e})=>({enum:e}),minItems:({definition:e,parameterValue:t})=>e.type==="array"?{minItems:t}:null,
|
|
116
119
|
maxItems:({definition:e,parameterValue:t})=>e.type==="array"?{maxItems:t}:null,notEmpty:({parameterValue:e,definition:t})=>!e||
|
|
117
|
-
t.type==="array"?null:{minLength:1},uppercase:({parameterValue:e})=>e?
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"metadata",{scale:e}),temporalPrecision:({parameterValue:e})=>
|
|
121
|
-
required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null}});function
|
|
122
|
-
|
|
123
|
-
.${String(t)}`}function
|
|
124
|
-
startsWith(r)?e.slice(r.length):null}function
|
|
125
|
-
{...n,field:o})}return r}function
|
|
126
|
-
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||
|
|
127
|
-
return t}function
|
|
128
|
-
function
|
|
120
|
+
t.type==="array"?null:{minLength:1},uppercase:({parameterValue:e})=>e?et("transforms",{uppercase:!0}):null,lowercase:({parameterValue:e})=>e?
|
|
121
|
+
et("transforms",{lowercase:!0}):null,length:({parameterValue:e})=>et("transforms",{length:e}),unsigned:({parameterValue:e})=>e?
|
|
122
|
+
et("metadata",{unsigned:!0}):null,precision:({parameterValue:e})=>et("metadata",{precision:e}),scale:({parameterValue:e})=>et(
|
|
123
|
+
"metadata",{scale:e}),temporalPrecision:({parameterValue:e})=>et("metadata",{temporalPrecision:e}),strictBoolean:()=>null,
|
|
124
|
+
required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null}});function Rc(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function li(e){return e instanceof
|
|
125
|
+
At}function Xg(){return{self:!1,children:{}}}function Ac(e){return Object.keys(e.children).length>0}function tt(e,t){return`${e}\
|
|
126
|
+
.${String(t)}`}function kc(e,t){return e===""?String(t):tt(e,t)}function Pc(e,t){if(e===t)return"";let r=`${t}.`;return e.
|
|
127
|
+
startsWith(r)?e.slice(r.length):null}function Ot(e,t){let r={};for(let n of Object.values(e)){let o=tt(t,n.field);N(r,o,
|
|
128
|
+
{...n,field:o})}return r}function ci(e){return Ko(e,"validatePath")}function Cc(e){let t={};for(let r of e){let n=ci(r),
|
|
129
|
+
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||N(o,s,Xg()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
130
|
+
return t}function Zg(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}
|
|
131
|
+
function on(e){return e===null?!0:Array.isArray(e)||Q(e)?Object.keys(e).length>0:e!==void 0}function Nc(e){return[...e].
|
|
129
132
|
sort((t,r)=>{let n=/^[0-9]+$/.test(t),o=/^[0-9]+$/.test(r);return n&&o?Number(t)-Number(r):n?-1:o?1:t.localeCompare(r)})}
|
|
130
|
-
function
|
|
133
|
+
function Qg(e){return/^[0-9]+$/.test(e)}function ey(e,t=new WeakMap){if(t.has(e))return t.get(e);let r=Object.create(At.
|
|
131
134
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
132
|
-
|
|
133
|
-
"object")return e;if(
|
|
135
|
+
an(sn(e.structure,t)),r._installOperationMethods(),Object.freeze(r)}function sn(e,t=new WeakMap){if(e===null||typeof e!=
|
|
136
|
+
"object")return e;if(li(e))return ey(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
134
137
|
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
|
-
for(let o of e)n.push(
|
|
136
|
-
o,t));return r}function
|
|
137
|
-
isArray(e))for(let r of e)
|
|
138
|
-
return
|
|
139
|
-
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=
|
|
140
|
-
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:
|
|
141
|
-
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!
|
|
142
|
-
n,i);return o.kind==="schema"?s.length<1?null:
|
|
143
|
-
function
|
|
144
|
-
"");n.length>0?r.skipFields=n:delete r.skipFields}if(
|
|
145
|
-
let s=
|
|
146
|
-
let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(", ")}.`)}function
|
|
138
|
+
for(let o of e)n.push(sn(o,t));return n}if(!Q(e))return e;let r={};t.set(e,r);for(let[n,o]of Object.entries(e))N(r,n,sn(
|
|
139
|
+
o,t));return r}function an(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||li(e))return e;if(t.add(e),Array.
|
|
140
|
+
isArray(e))for(let r of e)an(r,t);else for(let r of Reflect.ownKeys(e))an(e[r],t);return Object.freeze(e)}function ii(e){
|
|
141
|
+
return an(sn(e))}function ui(e,t,r=""){if(!li(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;if(!Object.hasOwn(
|
|
142
|
+
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=kc(r,n);return $c(e,i,o,s)}function $c(e,t,r,n){
|
|
143
|
+
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:ui(o.schema,r,n)}if(t?.type===
|
|
144
|
+
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!Qg(i))return null;let a=tt(
|
|
145
|
+
n,i);return o.kind==="schema"?s.length<1?null:ui(o.schema,s,a):s.length<1?o.definition:$c(e,o.definition,s,a)}return null}
|
|
146
|
+
function Rt(e,t){let r={...e};if(Array.isArray(e.skipFields)){let n=e.skipFields.map(o=>Pc(o,t)).filter(o=>o!==null&&o!==
|
|
147
|
+
"");n.length>0?r.skipFields=n:delete r.skipFields}if(Q(e.skipParams)){let n={};for(let[o,i]of Object.entries(e.skipParams)){
|
|
148
|
+
let s=Pc(o,t);s===null||s===""||N(n,s,i)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}function jc(e,t,r,n){
|
|
149
|
+
let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(", ")}.`)}function ai(e,t,r,n=!0){
|
|
147
150
|
let o=t[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${e}" must define ${r} as a boolean.`)}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
150
|
-
["validated","input"]),
|
|
151
|
+
function ry(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`Operation "${e}" must be an object.`);
|
|
152
|
+
return jc(e,t,"targetFields",["schema","input"]),ai(e,t,"enforceRequired"),ai(e,t,"applyDefaults"),jc(e,t,"outputFields",
|
|
153
|
+
["validated","input"]),ai(e,t,"rejectExplicitUndefined",!1),Object.freeze({targetFields:t.targetFields,enforceRequired:t.
|
|
151
154
|
enforceRequired,applyDefaults:t.applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.rejectExplicitUndefined===
|
|
152
|
-
void 0?!0:t.rejectExplicitUndefined})}function
|
|
153
|
-
"Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
154
|
-
entries(e))
|
|
155
|
-
e))
|
|
156
|
-
()=>{
|
|
155
|
+
void 0?!0:t.rejectExplicitUndefined})}function ny(e={}){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(
|
|
156
|
+
"Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(ty))N(t,r,n);for(let[r,n]of Object.
|
|
157
|
+
entries(e))N(t,r,ry(r,n));return Object.freeze(t)}function xc(e){let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
158
|
+
e))N(t,r,n);return Object.freeze(t)}function oy(e){let t={...e};return delete t.operation,delete t.mode,t}var si,ty,At,Lc=b(
|
|
159
|
+
()=>{Oc();Ho();or();vt();en();si=new WeakMap;ty=Object.freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
157
160
|
applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),replace:Object.freeze({targetFields:"schema",enforceRequired:!0,
|
|
158
161
|
applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),patch:Object.freeze({targetFields:"input",enforceRequired:!1,
|
|
159
|
-
applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
160
|
-
t,this.types=
|
|
162
|
+
applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});At=class{constructor(t,r,n,o={}){qo(t),this.structure=
|
|
163
|
+
t,this.types=xc(r),this.validators=xc(n),this.operations=ny(o),this._installOperationMethods()}_typeError(t){return this.
|
|
161
164
|
_paramError(t,"TYPE_CAST_FAILED","Value could not be cast to the required type.")}_paramError(t,r,n,o={}){let i=new Error(
|
|
162
165
|
n);return i.errorObject={field:t,code:r,message:n,params:o},i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?
|
|
163
166
|
!1:!!(Array.isArray(r[n])&&r[n].includes(t))}_fieldToBeSkipped(t,r){return Array.isArray(r.skipFields)&&r.skipFields.includes(
|
|
164
|
-
t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))
|
|
167
|
+
t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))N(t,n,o)}_singleErrorMap(t){let r={};return N(r,t.field,t),r}_assertSupportedOptions(t={}){
|
|
165
168
|
if(Object.hasOwn(t,"onlyObjectValues"))throw new Error("Unsupported validation option `onlyObjectValues`. Call `patch()`\
|
|
166
169
|
directly.");if(Object.hasOwn(t,"mode"))throw new Error("Unsupported validation option `mode`. Call `validateWith()` or \
|
|
167
170
|
an operation method directly.");if(Object.hasOwn(t,"operation"))throw new Error("Unsupported validation option `operatio\
|
|
168
171
|
n`. Call `validateWith()` or an operation method directly.")}_buildOperationSettings(t,r,n){return{operationName:t,operation:r,
|
|
169
172
|
targetFieldNames:r.targetFields==="input"?Object.keys(n):Object.keys(this.structure),outputFieldNames:r.outputFields==="\
|
|
170
173
|
input"?Object.keys(n):Object.keys(this.structure),enforceRequired:r.enforceRequired,applyDefaults:r.applyDefaults,rejectExplicitUndefined:r.
|
|
171
|
-
rejectExplicitUndefined,defaultedFields:new Set,isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!
|
|
174
|
+
rejectExplicitUndefined,defaultedFields:new Set,isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!Q(
|
|
172
175
|
r))throw new Error(`${t}() expects a plain object input.`)}_resolvePathValidationRequest(t={}){let r=t.operation??t.mode??
|
|
173
176
|
"patch";if(Object.hasOwn(t,"operation")&&Object.hasOwn(t,"mode")&&t.operation!==t.mode)throw new Error("Path validation \
|
|
174
177
|
options `operation` and `mode` must match when both are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(
|
|
175
|
-
`Unknown operation "${r}".`);let n=this.operations[r];return{operationName:r,operation:n,validationOptions:
|
|
178
|
+
`Unknown operation "${r}".`);let n=this.operations[r];return{operationName:r,operation:n,validationOptions:oy(t)}}_buildOperationResult(t,r,n){
|
|
176
179
|
let o={};for(let i of n.outputFieldNames){if(!Object.hasOwn(this.structure,i))continue;let s=n.isFieldPresent(i);(r[i]!==
|
|
177
|
-
void 0||s&&t[i]===null||n.defaultedFields.has(i))&&(!s&&!n.defaultedFields.has(i)||
|
|
178
|
-
return
|
|
180
|
+
void 0||s&&t[i]===null||n.defaultedFields.has(i))&&(!s&&!n.defaultedFields.has(i)||N(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){
|
|
181
|
+
return Qr(t,r)}_resolveArrayItemsConfig(t,r){return Zr(t,r)}_resolveObjectValuesConfig(t,r){return rr(t,r)}_buildArrayItemSettings(t,r){
|
|
179
182
|
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
|
|
183
|
+
let u=t.nullable===!0||a.nullable===!0,d=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,t.type))throw new Error(
|
|
184
|
+
`No casting function for type: ${t.type}`);let p=this.types[t.type];if(r===null)return u?(N(o,i,null),{errors:{},shouldContinue:!1}):
|
|
182
185
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
183
|
-
if(r===""&&
|
|
186
|
+
if(r===""&&d)return N(o,i,null),{errors:{},shouldContinue:!1};let g={schema:this,definition:t,value:r,fieldName:n,object:o,
|
|
184
187
|
objectBeforeCast:s,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
185
|
-
nullable:
|
|
186
|
-
n,h,w
|
|
187
|
-
i,h),
|
|
188
|
-
errors:{},context:
|
|
188
|
+
nullable:u||d,nullOnEmpty:d},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(h,l,w)=>{throw this._paramError(
|
|
189
|
+
n,h,l,w)}};try{let h=p(g);if(Rc(h))throw new Error(`Type handler for "${t.type}" must be synchronous.`);h!==void 0&&(N(o,
|
|
190
|
+
i,h),g.value=h)}catch(h){if(h.errorObject)return{errors:this._singleErrorMap(h.errorObject),shouldContinue:!1};throw h}return{
|
|
191
|
+
errors:{},context:g,shouldContinue:!0}}_runFieldValidators(t,r,n,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
|
|
189
192
|
_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
|
-
(
|
|
192
|
-
let
|
|
193
|
-
context:
|
|
194
|
-
t,n,o,i,
|
|
195
|
-
let
|
|
193
|
+
a,i.parameterValue=t[a];let u=c(i);if(Rc(u))throw new Error(`Validator handler for "${a}" must be synchronous.`);u!==void 0&&
|
|
194
|
+
(N(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){
|
|
195
|
+
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{
|
|
196
|
+
context:d}=u,p=this._validateNestedValue(t,n,o,i,a,c);return Object.keys(p).length>0?p:(d.value=o[i],this._runFieldValidators(
|
|
197
|
+
t,n,o,i,d,a))}_normalizeDefault(t,r,{fieldPath:n,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
|
|
198
|
+
let u={...o};return N(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
199
|
if(t.type==="object"){let c=this._resolveObjectFieldMode(r,t);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
197
200
|
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
201
|
_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,
|
|
200
|
-
s.operationName,s.operation,c,
|
|
201
|
-
a,t.schema,
|
|
202
|
-
entries(t))Object.hasOwn(r.structure,o)&&
|
|
203
|
-
keys(t)){if(!Object.hasOwn(r.structure,i)){
|
|
204
|
-
n))Object.hasOwn(o,i)||
|
|
205
|
-
keys(a)){let
|
|
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?
|
|
202
|
+
let a=n[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,u=t.schema._validateWithOperation(
|
|
203
|
+
s.operationName,s.operation,c,Rt(i,r));return N(n,o,t.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
204
|
+
a,t.schema,u.validatedObject):u.validatedObject),Ot(u.errors,r)}_extractKnownObjectFields(t,r){let n={};for(let[o,i]of Object.
|
|
205
|
+
entries(t))Object.hasOwn(r.structure,o)&&N(n,o,i);return n}_mergeKnownAndPassthroughObjectFields(t,r,n){let o={};for(let i of Object.
|
|
206
|
+
keys(t)){if(!Object.hasOwn(r.structure,i)){N(o,i,t[i]);continue}Object.hasOwn(n,i)&&N(o,i,n[i])}for(let[i,s]of Object.entries(
|
|
207
|
+
n))Object.hasOwn(o,i)||N(o,i,s);return o}_validateObjectValues(t,r,n,o,i,s){let a=r[n],c={...a},u={};N(r,n,c);for(let d of Object.
|
|
208
|
+
keys(a)){let p=tt(t,d);if(this._fieldToBeSkipped(p,i))continue;let g=c[d];if(g===void 0){s.rejectExplicitUndefined?this.
|
|
209
|
+
_mergeErrors(u,this._singleErrorMap(this._typeError(p).errorObject)):delete c[d];continue}if(o.kind==="schema"){let l=o.
|
|
210
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,g,Rt(i,p));N(c,d,l.validatedObject),this._mergeErrors(
|
|
211
|
+
u,Ot(l.errors,p));continue}let h=this._normalizeAndValidateValue(o.definition,g,p,c,d,a,i,this._buildArrayItemSettings(o.
|
|
212
|
+
definition,s));this._mergeErrors(u,h)}return u}_validateArrayItems(t,r,n,o,i,s){let a=r[n],c=a.slice(),u={};N(r,n,c);for(let d=0;d<
|
|
213
|
+
c.length;d++){let p=tt(t,d);if(this._fieldToBeSkipped(p,i))continue;if(!Object.hasOwn(a,d)||c[d]===void 0){s.rejectExplicitUndefined?
|
|
214
|
+
this._mergeErrors(u,this._singleErrorMap(this._typeError(p).errorObject)):delete c[d];continue}if(o.kind==="schema"){let h=o.
|
|
215
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[d],Rt(i,p));N(c,d,h.validatedObject),this._mergeErrors(
|
|
216
|
+
u,Ot(h.errors,p));continue}let g=this._normalizeAndValidateValue(o.definition,c[d],p,c,d,a,i,this._buildArrayItemSettings(
|
|
217
|
+
o.definition,s));this._mergeErrors(u,g)}return u}_validateField(t,r,n,o,i){if(!Object.hasOwn(this.structure,t))return{};
|
|
218
|
+
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&&
|
|
219
|
+
s.required&&(!a||u)&&!this._paramToBeSkipped("required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"\
|
|
220
|
+
Field is required",params:{}}):a?u?i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(t).errorObject):{}:this.
|
|
218
221
|
_normalizeAndValidateValue(s,c,t,n,t,r,o,i):{}}_validateWithOperation(t,r,n,o){this._assertSupportedOptions(o);let i={},
|
|
219
|
-
s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,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
|
-
|
|
224
|
-
_mergeErrors(i,
|
|
225
|
-
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of
|
|
226
|
-
let
|
|
227
|
-
c,t[c],r,a,n,o,
|
|
228
|
-
hasOwn(this.structure,t))return{};let c=this.structure[t],
|
|
229
|
-
let
|
|
230
|
-
a)&&this._mergeErrors(h,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),
|
|
231
|
-
c.defaultTo!==void 0){let
|
|
232
|
-
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(h,
|
|
233
|
-
length===0&&
|
|
234
|
-
a).errorObject):{};let
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let
|
|
239
|
-
|
|
240
|
-
|
|
222
|
+
s={...n},a=this._buildOperationSettings(t,r,n);for(let c of Object.keys(n))Object.hasOwn(this.structure,c)||N(i,c,{field:c,
|
|
223
|
+
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let u=this._validateField(
|
|
224
|
+
c,n,s,o,a);this._mergeErrors(i,u)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
225
|
+
this.structure[c].defaultTo!==void 0){let u=this.structure[c],d=typeof u.defaultTo=="function"?u.defaultTo():u.defaultTo,
|
|
226
|
+
p=this._normalizeDefault(u,d,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
227
|
+
_mergeErrors(i,p.errors),Object.keys(p.errors).length>0)continue;N(s,c,p.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
228
|
+
_buildOperationResult(n,s,a),errors:i}}_validateSelectedTree(t,r,n,o,i=""){let s={},a={};for(let c of Nc(Object.keys(t))){
|
|
229
|
+
let u=kc(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${u}".`);let d=this._validateSelectedField(
|
|
230
|
+
c,t[c],r,a,n,o,u);this._mergeErrors(s,d)}return{validatedObject:a,errors:s}}_validateSelectedField(t,r,n,o,i,s,a){if(!Object.
|
|
231
|
+
hasOwn(this.structure,t))return{};let c=this.structure[t],u=r.self===!0,d=Ac(r);if(this._fieldToBeSkipped(a,i))return{};
|
|
232
|
+
let p=Object.hasOwn(n,t),g=n[t],h={};if(!p){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("required",i.skipParams,
|
|
233
|
+
a)&&this._mergeErrors(h,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),u&&s.applyDefaults&&
|
|
234
|
+
c.defaultTo!==void 0){let f=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,m=this._normalizeDefault(c,f,{fieldPath:a,
|
|
235
|
+
currentObject:o,containerKey:t,objectBeforeCast:n,options:i,settings:s});this._mergeErrors(h,m.errors),Object.keys(m.errors).
|
|
236
|
+
length===0&&N(o,t,m.value)}return h}if(g===void 0)return u&&s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
237
|
+
a).errorObject):{};let l={[t]:g};if(u){let f=this._normalizeAndValidateValue(c,g,a,l,t,n,i,s);return Object.hasOwn(l,t)&&
|
|
238
|
+
l[t]!==void 0?N(o,t,l[t]):l[t]===null&&N(o,t,null),f}if(!d)return{};let w=this._castValue(c,g,a,l,t,n,i,s);if(Object.keys(
|
|
239
|
+
w.errors).length>0)return w.errors;if(!w.shouldContinue)return{};let _=this._validateSelectedDescendants(c,r.children,a,
|
|
240
|
+
l,t,i,s);return on(l[t])&&N(o,t,l[t]),_}_validateSelectedDescendants(t,r,n,o,i,s,a){if(t.type==="object"){let c=this._resolveObjectFieldMode(
|
|
241
|
+
n,t);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let u=o[i];if(!Q(
|
|
242
|
+
u))return{};let d=c.schema._validateSelectedTree(r,u,Rt(s,n),{...a,defaultedFields:new Set});return N(o,i,d.validatedObject),
|
|
243
|
+
Ot(d.errors,n)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(n,t);if(!c)throw new Error(`Schema path "${n}" d\
|
|
241
244
|
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
|
-
h,s))continue;if(!Object.hasOwn(
|
|
246
|
-
if(
|
|
247
|
-
let
|
|
248
|
-
this._mergeErrors(
|
|
249
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
250
|
-
this._mergeErrors(
|
|
251
|
-
o.definition,
|
|
252
|
-
continue}if(!
|
|
253
|
-
|
|
254
|
-
s,
|
|
245
|
+
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(t,r,n,o,i,s,a){let c=[],u=r[n],
|
|
246
|
+
d={};N(r,n,c);for(let p of Nc(Object.keys(i))){if(!/^[0-9]+$/.test(p))throw new Error(`Schema path "${tt(t,p)}" is inval\
|
|
247
|
+
id because array segments must use numeric indexes.`);let g=Number(p),h=tt(t,g),l=i[p],w=l.self===!0,_=Ac(l);if(this._fieldToBeSkipped(
|
|
248
|
+
h,s))continue;if(!Object.hasOwn(u,g)){w&&a.rejectExplicitUndefined&&N(d,h,this._typeError(h).errorObject);continue}let f=u[g];
|
|
249
|
+
if(f===void 0){w&&a.rejectExplicitUndefined&&N(d,h,this._typeError(h).errorObject);continue}if(o.kind==="schema"){if(w){
|
|
250
|
+
let v=o.schema._validateWithOperation("replace",o.schema.operations.replace,f,Rt(s,h));on(v.validatedObject)&&N(c,g,v.validatedObject),
|
|
251
|
+
this._mergeErrors(d,Ot(v.errors,h));continue}if(!_)continue;let S=o.schema._validateSelectedTree(l.children,f,Rt(s,h),{...a,
|
|
252
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});on(S.validatedObject)&&N(c,g,S.validatedObject),
|
|
253
|
+
this._mergeErrors(d,Ot(S.errors,h));continue}let m=this._buildArrayItemSettings(o.definition,a),y=[f];if(w){let S=this._normalizeAndValidateValue(
|
|
254
|
+
o.definition,f,h,y,0,u,s,m);Object.hasOwn(y,0)&&y[0]!==void 0?N(c,g,y[0]):y[0]===null&&N(c,g,null),this._mergeErrors(d,S);
|
|
255
|
+
continue}if(!_)continue;let E=this._castValue(o.definition,f,h,y,0,u,s,m);if(Object.keys(E.errors).length>0){this._mergeErrors(
|
|
256
|
+
d,E.errors);continue}if(!E.shouldContinue)continue;let T=this._validateSelectedDescendants(o.definition,l.children,h,y,0,
|
|
257
|
+
s,m);on(y[0])&&N(c,g,y[0]),this._mergeErrors(d,T)}return d}validateWith(t,r,n={}){if(!Object.hasOwn(this.operations,t))throw new Error(
|
|
255
258
|
`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=
|
|
257
|
-
_resolvePathValidationRequest(n),c=this._validateSelectedTree(
|
|
259
|
+
t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=ci(t),{operationName:i,operation:s,validationOptions:a}=this.
|
|
260
|
+
_resolvePathValidationRequest(n),c=this._validateSelectedTree(Cc([t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:Zg(
|
|
258
261
|
c.validatedObject,o),errors:c.errors}}validatePaths(t,r,n={}){if(this._assertPlainObjectInput("validatePaths",r),!Array.
|
|
259
262
|
isArray(t)||t.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
260
|
-
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(
|
|
263
|
+
operation:i,validationOptions:s}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(Cc(t),r,s,this.
|
|
261
264
|
_buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.keys(this.operations)){if(t in this)throw new Error(
|
|
262
265
|
`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
|
|
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]&&
|
|
268
|
-
t",
|
|
269
|
-
-1<t.indexOf(
|
|
270
|
-
|
|
271
|
-
null)return
|
|
266
|
+
return Ic(this,t)}getFieldDefinitions(){return si.has(this)||si.set(this,ii(this.structure)),si.get(this)}getFieldDefinition(t){
|
|
267
|
+
if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-empty string.");let r=ui(this,ci(t.trim()));
|
|
268
|
+
return r===null?null:ii(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);return!r||typeof r.messages!="object"||r.
|
|
269
|
+
messages===null?Object.freeze({}):ii(r.messages)}cleanup(t,r){let n={};for(let o of Object.keys(t))Object.hasOwn(this.structure,
|
|
270
|
+
o)&&this.structure[o][r]&&N(n,o,t[o]);return n}}});var IP,iy,OP,sy,ay,Mc,cy,Dc,Vc,Uc=b(()=>{({parse:IP,stringify:iy}=JSON),{keys:OP}=Object,sy=String,ay="string",Mc="objec\
|
|
271
|
+
t",cy=(e,t)=>t,Dc=(e,t,r)=>{let n=sy(t.push(r)-1);return e.set(r,n),n},Vc=(e,t,r)=>{let n=t&&typeof t===Mc?(d,p)=>d===""||
|
|
272
|
+
-1<t.indexOf(d)?p:void 0:t||cy,o=new Map,i=[],s=[],a=+Dc(o,i,n.call({"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=iy(i[a++],
|
|
273
|
+
u,r);return"["+s.join(",")+"]";function u(d,p){if(c)return c=!c,p;let g=n.call(this,d,p);switch(typeof g){case Mc:if(g===
|
|
274
|
+
null)return g;case ay:return o.get(g)||Dc(o,i,g)}return g}}});function fy(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Bc(e){if(typeof e==
|
|
272
275
|
"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
|
|
276
|
+
"string"){let t=e.trim();if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function di(e,t){
|
|
274
277
|
if(Object.is(e,t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&
|
|
275
278
|
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(!
|
|
279
|
+
e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!di(e[o],t[o]))return!1;return!0}if(e===
|
|
277
280
|
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
|
|
280
|
-
no","n","off"]);
|
|
281
|
+
keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!di(e[o],t[o]))return!1;
|
|
282
|
+
return!0}var ly,dy,py,zc,Gc=b(()=>{Uc();en();Jo();vt();ly=new Set(["true","1","yes","y","on"]),dy=new Set(["false","0","\
|
|
283
|
+
no","n","off"]);py={install(e){let{addType:t,addValidator:r}=e;t("none",n=>n.value),t("file",n=>{let o=n.value;o==null&&
|
|
281
284
|
n.throwTypeError();let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?
|
|
282
285
|
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
286
|
mber"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),t("blob",n=>n.value),
|
|
284
|
-
t("number",n=>{let o=
|
|
285
|
-
!Number.isInteger(o))&&n.throwTypeError(),o}),t("epochMilliseconds",n=>{let o=
|
|
286
|
-
o}),t("epochSeconds",n=>{let o=
|
|
287
|
-
n.fieldName);return
|
|
288
|
-
"time",n=>{let o=
|
|
289
|
-
type==="array"&&!Array.isArray(n.value)?[n.value]:n.value),t("object",n=>(
|
|
290
|
-
rialize",n=>{try{return JSON.stringify(n.value)}catch{try{return
|
|
287
|
+
t("number",n=>{let o=Bc(n.value);return o===null&&n.throwTypeError(),o}),t("integer",n=>{let o=Bc(n.value);return(o===null||
|
|
288
|
+
!Number.isInteger(o))&&n.throwTypeError(),o}),t("epochMilliseconds",n=>{let o=Yo(n.value,864e13);return o===null&&n.throwTypeError(),
|
|
289
|
+
o}),t("epochSeconds",n=>{let o=Yo(n.value,864e10);return o===null&&n.throwTypeError(),o}),t("dateTime",n=>{let o=nr(n.definition,
|
|
290
|
+
n.fieldName);return yc(n.value,o)||n.throwTypeError(),n.value}),t("date",n=>(hc(n.value)||n.throwTypeError(),n.value)),t(
|
|
291
|
+
"time",n=>{let o=nr(n.definition,n.fieldName);return gc(n.value,o)||n.throwTypeError(),n.value}),t("array",n=>n.definition.
|
|
292
|
+
type==="array"&&!Array.isArray(n.value)?[n.value]:n.value),t("object",n=>(Q(n.value)||n.throwTypeError(),n.value)),t("se\
|
|
293
|
+
rialize",n=>{try{return JSON.stringify(n.value)}catch{try{return Vc(n.value)}catch{n.throwTypeError()}}}),t("boolean",n=>{
|
|
291
294
|
if(typeof n.value=="boolean")return n.value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;
|
|
292
295
|
n.throwTypeError()}if(typeof n.value=="bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.
|
|
293
296
|
value=="string"){let o=String(n.definition.stringFalseWhen||"false").trim().toLowerCase(),i=String(n.definition.stringTrueWhen||
|
|
294
|
-
"true").trim().toLowerCase(),s=n.value.trim().toLowerCase(),a=new Set([...
|
|
297
|
+
"true").trim().toLowerCase(),s=n.value.trim().toLowerCase(),a=new Set([...dy,o]),c=new Set([...ly,i]);if(a.has(s))return!1;
|
|
295
298
|
if(c.has(s))return!0}n.throwTypeError()}),t("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>
|
|
296
299
|
0)return n.value;n.throwTypeError()}if(typeof n.value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))
|
|
297
300
|
return Number(n.value);n.throwTypeError()}if(typeof n.value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();
|
|
298
301
|
let i=Number(o);return Number.isSafeInteger(i)||n.throwTypeError(),i}n.throwTypeError()}),r("minLength",n=>{n.value!==void 0&&
|
|
299
302
|
n.definition.type==="string"&&n.value.toString&&n.value.toString().length<n.parameterValue&&n.throwParamError("MIN_LENGT\
|
|
300
303
|
H",`Length must be at least ${n.parameterValue} characters.`,{min:n.parameterValue,actual:n.value.toString().length})}),
|
|
301
|
-
r("min",n=>{n.value!==void 0&&
|
|
304
|
+
r("min",n=>{n.value!==void 0&&Tt(n.definition)&&typeof n.value=="number"&&n.value<n.parameterValue&&n.throwParamError("M\
|
|
302
305
|
IN_VALUE",`Value must be at least ${n.parameterValue}.`,{min:n.parameterValue,actual:n.value})}),r("maxLength",n=>{n.value!==
|
|
303
306
|
void 0&&n.definition.type==="string"&&n.value.toString&&n.value.toString().length>n.parameterValue&&n.throwParamError("M\
|
|
304
307
|
AX_LENGTH",`Length must be no more than ${n.parameterValue} characters.`,{max:n.parameterValue,actual:n.value.toString().
|
|
305
|
-
length})}),r("max",n=>{n.value!==void 0&&
|
|
308
|
+
length})}),r("max",n=>{n.value!==void 0&&Tt(n.definition)&&typeof n.value=="number"&&n.value>n.parameterValue&&n.throwParamError(
|
|
306
309
|
"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=>
|
|
310
|
+
isArray(n.parameterValue))throw new Error(`Enum for ${n.fieldName} must be an array.`);n.parameterValue.some(i=>di(i,n.value))||
|
|
308
311
|
n.throwParamError("ENUM_VALUE","Value must match one of the allowed enum values.",{allowed:n.parameterValue})}),r("patte\
|
|
309
312
|
rn",n=>{if(n.value===void 0||n.definition.type!=="string"||typeof n.value!="string")return;let o=n.parameterValue,i=o instanceof
|
|
310
313
|
RegExp?new RegExp(o.source,o.flags):typeof o=="string"?new RegExp(o):null;if(!i)throw new Error(`Pattern for ${n.fieldName}\
|
|
@@ -312,7 +315,7 @@ RegExp?new RegExp(o.source,o.flags):typeof o=="string"?new RegExp(o):null;if(!i)
|
|
|
312
315
|
{pattern:i.source})}),r("strictBoolean",n=>{if(n.parameterValue){if(n.definition.type!=="boolean")throw new Error(`stric\
|
|
313
316
|
tBoolean can only be used on boolean fields (${n.fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("\
|
|
314
317
|
STRICT_BOOLEAN","Value must be a boolean.")}}),r("validator",n=>{if(typeof n.parameterValue!="function")throw new Error(
|
|
315
|
-
`Validator for ${n.fieldName} must be a function.`);let o=n.parameterValue(n.value,n.object,n);if(
|
|
318
|
+
`Validator for ${n.fieldName} must be a function.`);let o=n.parameterValue(n.value,n.object,n);if(fy(o))throw new Error(
|
|
316
319
|
`Custom validator for "${n.fieldName}" must be synchronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FA\
|
|
317
320
|
ILED",o)}),r("uppercase",n=>{if(typeof n.value=="string")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value==
|
|
318
321
|
"string")return n.value.toLowerCase()}),r("length",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);
|
|
@@ -325,135 +328,138 @@ ms.`,{max:n.parameterValue,actual:n.value.length})}),r("notEmpty",n=>{n.paramete
|
|
|
325
328
|
""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r("unsigned",()=>{}),r("precision",()=>{}),
|
|
326
329
|
r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.type!=="dateTime")throw new Error(
|
|
327
330
|
`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r("nullable",()=>{}),r("nullOnEmpty",
|
|
328
|
-
()=>{}),r("defaultTo",()=>{})}},
|
|
329
|
-
if(typeof r!="function")throw new Error(`Validator handler for '${t}' must be a function.`);
|
|
330
|
-
create(null);for(let[r,n]of Object.entries(e))
|
|
331
|
-
"Plugin must have an install method.");e.install(t)}function
|
|
332
|
-
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
333
|
-
typeof e!="object"&&typeof e!="function")return null;let t=
|
|
331
|
+
()=>{}),r("defaultTo",()=>{})}},zc=py});var Fc=b(()=>{or()});function my(e,t,r){if(typeof r!="function")throw new Error(`Type handler for '${t}' must be a function.`);N(e,t,r)}function hy(e,t,r){
|
|
332
|
+
if(typeof r!="function")throw new Error(`Validator handler for '${t}' must be a function.`);N(e,t,r)}function un(e={}){let t=Object.
|
|
333
|
+
create(null);for(let[r,n]of Object.entries(e))N(t,r,n);return t}function Hc(e,t){if(typeof e.install!="function")throw new Error(
|
|
334
|
+
"Plugin must have an install method.");e.install(t)}function qc(e,t,r){Yc.set(e,t),Jc.set(e,r),Object.defineProperty(e,Kc,
|
|
335
|
+
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function gy(e){if(!e||
|
|
336
|
+
typeof e!="object"&&typeof e!="function")return null;let t=Yc.get(e),r=Jc.get(e);if(t&&r)return{types:t,validators:r};let n=e[Kc];
|
|
334
337
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
335
338
|
typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.validators=="object"&&typeof e.create=="fu\
|
|
336
339
|
nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
|
|
337
|
-
validators}:null}function
|
|
338
|
-
entries(t)){if(Object.hasOwn(e,n)&&e[n]!==o){if(
|
|
339
|
-
factories with conflicting ${r} "${n}".`)}
|
|
340
|
-
types:
|
|
341
|
-
"Factory sources must be schema instances or schema factories created by json-rest-schema.");
|
|
342
|
-
validators,"validator")}return{types:o,validators:i}}function
|
|
343
|
-
e),o=
|
|
344
|
-
i.addValidator=(s,a)=>{
|
|
345
|
-
let a=
|
|
346
|
-
addType(s,a)},addValidator:(s,a)=>{
|
|
347
|
-
new WeakMap,
|
|
348
|
-
`${t} must match ${
|
|
340
|
+
validators}:null}function yy(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function Wc(e,t,r){for(let[n,o]of Object.
|
|
341
|
+
entries(t)){if(Object.hasOwn(e,n)&&e[n]!==o){if(cn.has(o))continue;if(!cn.has(e[n]))throw new Error(`Cannot merge schema\
|
|
342
|
+
factories with conflicting ${r} "${n}".`)}N(e,n,o)}}function wy(e,t,r){let n=yy(r).filter(Boolean);if(n.length<1)return{
|
|
343
|
+
types:un(e),validators:un(t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=gy(s);if(!a)throw new Error(
|
|
344
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");Wc(o,a.types,"type"),Wc(i,a.
|
|
345
|
+
validators,"validator")}return{types:o,validators:i}}function Xc({types:e={},validators:t={},installCore:r=!0}={}){let n=un(
|
|
346
|
+
e),o=un(t),i=(s,a={})=>{let c=new At(s,n,o,a.operations);return qc(c,n,o),c};return qc(i,n,o),i.addType=(s,a)=>{my(n,s,a)},
|
|
347
|
+
i.addValidator=(s,a)=>{hy(o,s,a)},i.use=s=>{Hc(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
|
|
348
|
+
let a=wy(n,o,s);return Xc({types:a.types,validators:a.validators,installCore:!1})},r&&Hc(zc,{addType:(s,a)=>{cn.add(a),i.
|
|
349
|
+
addType(s,a)},addValidator:(s,a)=>{cn.add(a),i.addValidator(s,a)}}),i}var Yc,Jc,Kc,cn,L,rt=b(()=>{Lc();Gc();Fc();or();Yc=
|
|
350
|
+
new WeakMap,Jc=new WeakMap,Kc=Symbol.for("json-rest-schema.registry-metadata"),cn=new WeakSet;L=Xc({installCore:!0})});var WP,Zc=b(()=>{rt();U();WP=Object.freeze({schema:L({}),mode:"replace"})});var Qc=b(()=>{U();oc();Xr();Zc()});function Ey(e){return String(e||"").trim().toLowerCase()}function pi(e,t){let r=Ey(e);if(!eu.test(r))throw new TypeError(
|
|
351
|
+
`${t} must match ${eu.toString()}.`);return r}function ln(e,t){if(e==null)return Object.freeze({});if(!H(e))throw new TypeError(
|
|
349
352
|
`${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
|
-
o||"").trim();if(!
|
|
353
|
+
o||"").trim();if(!by.test(s))throw new TypeError(`${t} local name "${s}" must be a JavaScript identifier.`);let a=pi(i,`${t}\
|
|
351
354
|
.${s}`);if(n.has(a))throw new TypeError(`${t} declares capability "${a}" more than once.`);n.add(a),r[s]=a}return Object.
|
|
352
|
-
freeze(r)}function
|
|
355
|
+
freeze(r)}function Sy(e,t,r){if(e==null)return Object.freeze({});if(!H(e))throw new TypeError(`${r}.hints must be an obj\
|
|
353
356
|
ect mapping required capability ids to what to register.`);let n=new Set(Object.values(t)),o={};for(let[i,s]of Object.entries(
|
|
354
|
-
e)){let a=
|
|
357
|
+
e)){let a=pi(i,`${r}.hints key`);if(!n.has(a))throw new TypeError(`${r}.hints names "${a}", which the provider does not \
|
|
355
358
|
require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${r}.hints["${a}"] must be the text that says what to r\
|
|
356
|
-
egister.`);o[a]=s.trim()}return Object.freeze(o)}function
|
|
359
|
+
egister.`);o[a]=s.trim()}return Object.freeze(o)}function vy(e){let t=new Map;for(let[r,n]of Object.entries(e))for(let o of Object.
|
|
357
360
|
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
|
-
|
|
369
|
-
|
|
361
|
+
r)}}function Ty(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(
|
|
362
|
+
o==="provides"?`Provider "${e}" cannot late-require capability "${n}" that it provides.`:`Provider "${e}" names capabili\
|
|
363
|
+
ty "${n}" under both late and ${o}.`)}function fi(e,t){if(e==null)return null;if(typeof e!="function")throw new TypeError(
|
|
364
|
+
`${t} must be a function when provided.`);return e}function dn({id:e,requires:t={},optional:r={},late:n={},provides:o={},
|
|
365
|
+
hints:i={},setup:s,boot:a=null,shutdown:c=null}={}){let u=pi(e,"Provider id"),d=ln(t,`${u}.requires`),p=ln(r,`${u}.optio\
|
|
366
|
+
nal`),g=ln(n,`${u}.late`),h=ln(o,`${u}.provides`);vy({requires:d,optional:p,late:g,provides:h}),Ty(u,g,{provides:h,requires:d,
|
|
367
|
+
optional:p});let l=fi(s,`${u}.setup`);if(!l)throw new TypeError(`${u}.setup is required.`);return Object.freeze({id:u,requires:d,
|
|
368
|
+
optional:p,late:g,provides:h,hints:Sy(i,{...d,...g},u),setup:l,boot:fi(a,`${u}.boot`),shutdown:fi(c,`${u}.shutdown`)})}var eu,
|
|
369
|
+
by,mi=b(()=>{U();eu=/^[a-z][a-z0-9_.-]*$/u,by=/^[A-Za-z_$][A-Za-z0-9_$]*$/u});var tu,ru=b(()=>{tu="public"});var nu=b(()=>{});var iu=b(()=>{U()});var Iy,su,au=b(()=>{nu();iu();Iy="/api",su=`${Iy}/bootstrap`});function hi(){let e=[],t=new Set,r=!1;function n({id:a,order:c=0,contribute:u}={}){if(r)throw new Error("Bootstrap regis\
|
|
370
|
+
tration is closed after the first payload is resolved.");let d=F(a);if(!d)throw new TypeError("Bootstrap contributor id \
|
|
371
|
+
is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${d}" requires contribute().`);if(t.has(
|
|
372
|
+
d))throw new Error(`Bootstrap contributor "${d}" is duplicated.`);return t.add(d),e.push(Object.freeze({id:d,order:Number.
|
|
373
|
+
isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){r=!0;let c={},u=e.map((d,p)=>({entry:d,index:p})).sort(
|
|
374
|
+
(d,p)=>d.entry.order-p.entry.order||d.index-p.index).map(({entry:d})=>d);for(let d of u){let p=await d.contribute(Object.
|
|
375
|
+
freeze({...H(a)?a:{},payload:Object.freeze({...c})}));c={...c,...H(p)?p:{}}}return Object.freeze(c)}function i(){return Object.
|
|
370
376
|
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
|
|
372
|
-
untime.bootstrap"},setup({http:e}){let t=
|
|
377
|
+
return s}var gi=b(()=>{U()});var Oy,cu=b(()=>{mi();ru();au();gi();Oy=dn({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"r\
|
|
378
|
+
untime.bootstrap"},setup({http:e}){let t=hi();return e.router.register("GET",su,{auth:tu,meta:{tags:["bootstrap"],summary:"\
|
|
373
379
|
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
|
|
380
|
+
{bootstrap:t}}})});function Ry(e){if(!H(e))throw new TypeError("Event listener must be an object.");let t=String(e.id||"").trim();if(!t)throw new TypeError(
|
|
375
381
|
"Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
|
|
376
382
|
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
|
|
383
|
+
unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function Ay(e){if(!H(e))throw new TypeError(
|
|
378
384
|
"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
|
|
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=
|
|
385
|
+
required.");return Object.freeze({...e,type:t})}function yi(){let e=[],t=new Set;function r(s){let a=Ry(s);if(t.has(a.id))
|
|
386
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=Ay(s);
|
|
381
387
|
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
|
|
388
|
+
freeze(e.map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var wi=b(()=>{U()});var Py,uu=b(()=>{mi();wi();Py=dn({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:yi()}}})});var Ve=b(()=>{Xr();nc();Qc();cu();gi();uu();wi()});var lu=b(()=>{});function du(e,t={}){let{missingStatus:r=404}=t,n=e?.errors?.[0]?.code||e?.code||"";return n==="vibe64_session_not_found"?
|
|
383
389
|
r:n.startsWith("vibe64_invalid")?400:n==="vibe64_command_requires_terminal"||n==="vibe64_agent_write_mode_busy"||n==="vi\
|
|
384
390
|
be64_agent_attachment_session_unavailable"||n==="vibe64_project_not_selected"||n==="vibe64_project_not_ready"||n==="vibe\
|
|
385
391
|
64_project_source_lock_timeout"||n==="vibe64_development_database_scope_busy"||n==="vibe64_project_session_policy_lock_t\
|
|
386
392
|
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
|
|
388
|
-
|
|
389
|
-
if(!
|
|
390
|
-
let n=String(t.value||"").trim(),o=r===
|
|
391
|
-
64_preview_identity_selector_missing");if(r===
|
|
392
|
-
nvalid.","vibe64_preview_identity_email_invalid");if(r!==
|
|
393
|
-
alid.":"Preview identity user id is invalid.",r===
|
|
394
|
-
er_id_invalid");return{type:r,value:o}}function
|
|
395
|
-
t,"subject"))throw
|
|
396
|
-
ct_unsupported");let r=String(t.operation||
|
|
397
|
-
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===
|
|
398
|
-
|
|
399
|
-
guest","you"]),
|
|
400
|
-
function
|
|
401
|
-
command failed.",{code:t,params:n})}function
|
|
402
|
-
targetHref:n=""}=t,o=
|
|
403
|
-
"Application preview identity target must use HTTP.");return{operation:o.operation,protocol:
|
|
404
|
-
operation===
|
|
393
|
+
tup_running"?409:e?.ok===!1?400:200}var fu=b(()=>{});function ve(e,t,r={}){let{status:n=du({ok:!1,code:t}),...o}=r;return new ie(n,e,{...o,code:t})}var le=b(()=>{Ve();U();lu();
|
|
394
|
+
fu()});import Cy from"node:crypto";function Ny(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=String(t.type||"").trim();
|
|
395
|
+
if(!Jr.includes(r))throw ve("Preview identity selector type is invalid.","vibe64_preview_identity_selector_type_invalid");
|
|
396
|
+
let n=String(t.value||"").trim(),o=r===tr?n.toLowerCase():n;if(!o)throw ve("Preview identity selector is missing.","vibe\
|
|
397
|
+
64_preview_identity_selector_missing");if(r===tr&&(!o.includes("@")||o.length>320))throw ve("Preview identity email is i\
|
|
398
|
+
nvalid.","vibe64_preview_identity_email_invalid");if(r!==tr&&o.length>256)throw ve(r===Yr?"Preview identity login is inv\
|
|
399
|
+
alid.":"Preview identity user id is invalid.",r===Yr?"vibe64_preview_identity_login_invalid":"vibe64_preview_identity_us\
|
|
400
|
+
er_id_invalid");return{type:r,value:o}}function gu(e={}){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};if(Object.hasOwn(
|
|
401
|
+
t,"subject"))throw ve("Preview identity login requires an explicit application selector.","vibe64_preview_identity_subje\
|
|
402
|
+
ct_unsupported");let r=String(t.operation||_e).trim();if(![_e,Pt].includes(r))throw ve("Preview identity operation is in\
|
|
403
|
+
valid.","vibe64_preview_identity_operation_invalid");return{operation:r,...r===_e?{selector:Ny(t.selector)}:{}}}var WC,_e,
|
|
404
|
+
Pt,pu,mu,hu,YC,_i=b(()=>{rc();le();WC=Cy.randomBytes(32),_e="login-as",Pt="logout",pu="selector",mu=new Set(["default","\
|
|
405
|
+
guest","you"]),hu=32,YC=Object.freeze(["projectScope","sessionSourceRoot","sessionId","targetHref","terminalSessionId"])});var ar,bi=b(()=>{ar="vibe64_preview_token"});import{randomUUID as jy}from"node:crypto";import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as yu}from"@local/vibe64-genesis/server";
|
|
406
|
+
function Ct(e="",t="vibe64_preview_identity_command_failed",r=502,n={}){return new ie(r,e||"Application preview identity\
|
|
407
|
+
command failed.",{code:t,params:n})}function ky(e={}){return{kind:pu,selector:e.selector}}function _u(e={},t={}){let{requestId:r=jy(),
|
|
408
|
+
targetHref:n=""}=t,o=gu(e),i=String(n||"").trim(),s=new URL(i);if(!["http:","https:"].includes(s.protocol))throw new Error(
|
|
409
|
+
"Application preview identity target must use HTTP.");return{operation:o.operation,protocol:yu,requestId:String(r),...o.
|
|
410
|
+
operation===_e?{subject:ky(o)}:{},target:{href:s.toString(),origin:s.origin}}}function $y(e=[]){if(!Array.isArray(e))throw Ct(
|
|
405
411
|
"Application preview identity command returned invalid cookies.","vibe64_preview_identity_command_cookies_invalid");let t=e;
|
|
406
|
-
if(t.length>
|
|
412
|
+
if(t.length>Ei)throw Ct("Application preview identity command returned too many cookies.","vibe64_preview_identity_comma\
|
|
407
413
|
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)>
|
|
409
|
-
test(o))throw
|
|
410
|
-
_cookie_invalid",502,{cookie:n+1});return o})}function
|
|
414
|
+
0,s)).trim();if(!o||Buffer.byteLength(o)>Si||/[\r\n]/u.test(o)||s<1||!xy.test(a)||a===cr||a.startsWith(`${cr}_`)||/(?:^|;)\s*domain\s*=/iu.
|
|
415
|
+
test(o))throw Ct(`Application preview identity command returned invalid cookie ${n+1}.`,"vibe64_preview_identity_command\
|
|
416
|
+
_cookie_invalid",502,{cookie:n+1});return o})}function Ly(e=null){if(!e||typeof e!="object"||Array.isArray(e))return null;
|
|
411
417
|
let t={displayName:String(e.displayName||e.name||"").trim().slice(0,256),email:String(e.email||"").trim().toLowerCase().
|
|
412
418
|
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
|
|
414
|
-
requestId:n=""}=t;if(!e||typeof e!="object"||Array.isArray(e))throw
|
|
415
|
-
valid JSON.","vibe64_preview_identity_command_json_invalid");if(e.protocol!==
|
|
416
|
-
typeof e.ok!="boolean")throw
|
|
417
|
-
eview_identity_command_response_invalid");let o
|
|
419
|
+
e.username||"").trim().slice(0,256)};return Object.values(t).some(Boolean)?t:null}function My(e={},t={}){let{operation:r=_e,
|
|
420
|
+
requestId:n=""}=t;if(!e||typeof e!="object"||Array.isArray(e))throw Ct("Application preview identity command returned in\
|
|
421
|
+
valid JSON.","vibe64_preview_identity_command_json_invalid");if(e.protocol!==yu||String(e.requestId||"")!==String(n||"")||
|
|
422
|
+
typeof e.ok!="boolean")throw Ct("Application preview identity command returned an invalid protocol response.","vibe64_pr\
|
|
423
|
+
eview_identity_command_response_invalid");let o=$y(e.setCookie);if(e.ok===!1){let a=Number(e.statusCode);return{code:String(
|
|
418
424
|
e.code||"vibe64_preview_identity_application_rejected").trim().slice(0,128),error:String(e.error||"Application preview i\
|
|
419
425
|
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===
|
|
426
|
+
a>=400&&a<600?a:400}}let i=r===Pt||e.signedOut===!0,s=i?null:Ly(e.identity);if(o.length<1||!i&&!s)throw Ct("Application \
|
|
421
427
|
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
|
|
423
|
-
512*1024,
|
|
428
|
+
ing");return{identity:s,ok:!0,setCookie:o,signedOut:i,statusCode:200}}var wu,Ei,Si,cr,xy,rN,bu=b(()=>{Ve();_i();bi();wu=
|
|
429
|
+
512*1024,Ei=64,Si=16*1024,cr=ar,xy=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u;rN=Object.freeze({normalizePreviewIdentityCommandResponse:My})});var Eu=b(()=>{});function Su(e=""){return By.find(t=>t.pattern.test(String(e)))?.kind||""}function Fy(e){if(!je(e)||e.startsWith("/")||e.
|
|
424
430
|
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
|
-
it","request-limit","size-limit","target-exited","session-ended","error"]),
|
|
429
|
-
1024*1024,
|
|
430
|
-
proxyRequestLines:2e4,interactions:500,bufferedBytesPerProcess:64
|
|
431
|
-
1024,indexBytes:4
|
|
432
|
-
60*1e3}),
|
|
431
|
+
modules")}var Dy,iN,Vy,Uy,Tu,ur,sN,aN,cN,By,zy,Gy,fn,je,vu,uN,lN,Iu=b(()=>{Dy="vibe64.usage-trace.v1",iN=Object.freeze({
|
|
432
|
+
directory:"VIBE64_USAGE_RECORDING_DIR",sourceRoot:"VIBE64_USAGE_SOURCE_ROOT",targetKind:"VIBE64_USAGE_TARGET_KIND"}),Vy=
|
|
433
|
+
Object.freeze(["starting","recording","stopping","stopped","failed","unavailable"]),Uy=Object.freeze(["person","time-lim\
|
|
434
|
+
it","request-limit","size-limit","target-exited","session-ended","error"]),Tu=Object.freeze(["nodejs","python","php"]),ur=
|
|
435
|
+
1024*1024,sN=Object.freeze({durationMs:600*1e3,capturedRequests:2e3,hitsBytesPerProcess:16*ur,hitsBytesPerRecording:32*ur,
|
|
436
|
+
proxyRequestLines:2e4,interactions:500,bufferedBytesPerProcess:64*ur,flushIntervalMs:1e3,flushEntries:2e3,traceLineBytes:64*
|
|
437
|
+
1024,indexBytes:4*ur,plumbingShare:.8,plumbingMinimumRequests:3}),aN=Object.freeze({maxRecordings:10,maxBytes:64*ur,maxAgeMs:10080*
|
|
438
|
+
60*1e3}),cN=Object.freeze(["click","enter","submit"]),By=Object.freeze([Object.freeze({kind:"request",pattern:/^r_[0-9]{6}$/u}),
|
|
433
439
|
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})]),
|
|
435
|
-
isSafeInteger(e)&&e>=0,
|
|
436
|
-
e.column)&&e.column>0;
|
|
437
|
-
e.pid)&&e.pid>0&&
|
|
438
|
-
function:e=>
|
|
439
|
-
e.kind&&
|
|
440
|
-
e.kind)),hits:e=>
|
|
441
|
-
(t[1]===null||Number.isSafeInteger(t[1])&&t[1]>0)),diagnostic:e=>
|
|
442
|
-
e.reason)}),
|
|
443
|
-
return
|
|
440
|
+
freeze({kind:"background",pattern:/^bg_[0-9]+$/u})]),zy=/^sha256:[0-9a-f]{64}$/u,Gy=Object.freeze(["ready","idle"]);fn=e=>Number.
|
|
441
|
+
isSafeInteger(e)&&e>=0,je=e=>typeof e=="string"&&e.length>0,vu=e=>!!e&&Number.isSafeInteger(e.line)&&e.line>0&&Number.isSafeInteger(
|
|
442
|
+
e.column)&&e.column>0;uN=Object.freeze({header:e=>e.schema===Dy&&Tu.includes(e.runtime)&&je(e.runtimeVersion)&&Number.isSafeInteger(
|
|
443
|
+
e.pid)&&e.pid>0&&je(e.startedAt),tracer:e=>Gy.includes(e.state),file:e=>fn(e.fileIndex)&&Fy(e.path)&&zy.test(e.hash||""),
|
|
444
|
+
function:e=>fn(e.functionIndex)&&fn(e.fileIndex)&&typeof e.name=="string"&&vu(e.start)&&vu(e.end),scope:e=>Su(e.scope)===
|
|
445
|
+
e.kind&&je(e.startedAt)&&(e.endedAt===void 0||je(e.endedAt))&&(e.label===void 0||je(e.label)&&["local-request","run"].includes(
|
|
446
|
+
e.kind)),hits:e=>Su(e.scope)!==""&&Array.isArray(e.counts)&&e.counts.every(t=>Array.isArray(t)&&t.length===2&&fn(t[0])&&
|
|
447
|
+
(t[1]===null||Number.isSafeInteger(t[1])&&t[1]>0)),diagnostic:e=>je(e.code)&&(e.path===void 0||je(e.path)),truncated:e=>je(
|
|
448
|
+
e.reason)}),lN=Object.freeze({USAGE_RECORDING_STATES:Vy,USAGE_RECORDING_STOP_REASONS:Uy,USAGE_TRACER_RUNTIMES:Tu})});function Hy(e=""){try{let t=new URL(e),r=t.protocol==="https:",n=t.port||(r?"443":"80");return`${r?"__Host-":""}${Ou}_${n}`}catch{
|
|
449
|
+
return Ou}}function qy(e="",t={}){let{proxyOrigin:r="",targetOrigin:n=""}=t,o=String(e||"").trim();if(!o||!r||!n)return o;
|
|
444
450
|
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=
|
|
451
|
+
i.pathname,s.search=Wy(i.search),s.hash=i.hash,s.toString())}catch{return o}}function Wy(e=""){let t=String(e||"");if(!t||
|
|
446
452
|
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
|
-
|
|
451
|
-
11",
|
|
452
|
-
73/"}),
|
|
453
|
-
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),
|
|
454
|
-
user_not_found",error:"No active user has that email.",statusCode:404,setCookie:[]}),
|
|
455
|
-
entity-command",title:"Preview identity command protocol",exampleRequest:
|
|
456
|
-
identity command protocol (\`${
|
|
453
|
+
s=i<0?o:o.slice(0,i);return Yy(s)!==ar});return n.length>0?`?${n.join("&")}`:""}function Yy(e=""){try{return decodeURIComponent(
|
|
454
|
+
String(e||"").replace(/\+/gu," "))}catch{return String(e||"")}}var Ou,Ru,wN,Au=b(()=>{Eu();Iu();bi();Ou=ar,Ru=/^vibe64-launch-[a-f0-9]{12}$/u;
|
|
455
|
+
wN=Object.freeze({previewTokenCookieName:Hy,proxiedLocation:qy})});import{VIBE64_PREVIEW_IDENTITY_COMMAND_PROTOCOL as pn}from"@local/vibe64-genesis/server";var vi,Pu,Ti,Cu,Nu,ju,xu,ku=b(()=>{
|
|
456
|
+
_i();bu();Au();vi=e=>JSON.stringify(e,null,2),Pu=Jr.map(e=>`\`${e}\``).join(", "),Ti="6f1c2a7e-3d4b-4c55-9a10-2b7d8e9f0a\
|
|
457
|
+
11",Cu=_u({operation:_e,selector:{type:"email",value:"admin@example.com"}},{requestId:Ti,targetHref:"http://127.0.0.1:51\
|
|
458
|
+
73/"}),Nu=Object.freeze({protocol:pn,requestId:Ti,ok:!0,setCookie:["app_session=abc123; Path=/; HttpOnly; SameSite=Lax"],
|
|
459
|
+
identity:{displayName:"Admin",email:"admin@example.com",userId:"1"}}),ju=Object.freeze({protocol:pn,requestId:Ti,ok:!1,code:"\
|
|
460
|
+
user_not_found",error:"No active user has that email.",statusCode:404,setCookie:[]}),xu=Object.freeze([{name:"preview-id\
|
|
461
|
+
entity-command",title:"Preview identity command protocol",exampleRequest:Cu,exampleResponses:[Nu,ju],text:()=>`# Preview\
|
|
462
|
+
identity command protocol (\`${pn}\`)
|
|
457
463
|
|
|
458
464
|
An application-owned executable, declared under an Outputs web target's \`#### Preview identity\` block (grammar: \`vibe64-\
|
|
459
465
|
helper spec outputs\`), that signs the Preview browser in as an existing application account or signs it out. Vibe64 neve\
|
|
@@ -466,52 +472,52 @@ nd creates or clears its own normal browser session.
|
|
|
466
472
|
adds only the Enabled and Secret names, not the project's Env values, so the command loads the application's own configu\
|
|
467
473
|
ration itself (for example its generated environment file). For an enabled run the declared Enabled environment name is \
|
|
468
474
|
\`true\` and the Secret environment name holds a fresh per-run secret. Keep the exchange disabled unless both are present;\
|
|
469
|
-
it is a development-preview control, never a
|
|
470
|
-
- stdin: one JSON request line. stdout: one JSON response (at most ${
|
|
475
|
+
it is a development-preview control, never a sign-in API of a published application.
|
|
476
|
+
- stdin: one JSON request line. stdout: one JSON response (at most ${wu} bytes). Exit 0 after writing the response; a no\
|
|
471
477
|
n-zero exit or timeout fails the exchange. Write diagnostics to stderr.
|
|
472
478
|
- Use the same database and configuration as the server behind \`target.origin\` (for a test target, its test database).
|
|
473
479
|
- A JSKIT application's executable can call \`runManagedPreviewIdentityCommand\` from \`@jskit-ai/auth-web/server/managedPr\
|
|
474
480
|
eviewIdentity\`. Pass it the application's environment, this protocol and the Preview's launch hostnames, since it reads \
|
|
475
481
|
no environment on its own and its defaults are JSKIT's neutral protocol and loopback only: \`runManagedPreviewIdentityCom\
|
|
476
|
-
mand({ env: process.env, protocol: "${
|
|
482
|
+
mand({ env: process.env, protocol: "${pn}", localHostnames: [${Ru}] })\`.
|
|
477
483
|
|
|
478
484
|
## Request
|
|
479
485
|
|
|
480
|
-
- \`operation\`: \`${
|
|
486
|
+
- \`operation\`: \`${_e}\` or \`${Pt}\`.
|
|
481
487
|
- \`protocol\`, \`requestId\`: echo both in the response.
|
|
482
|
-
- \`subject\` (${
|
|
488
|
+
- \`subject\` (${_e} only): \`{"kind":"selector","selector":{"type":\u2026,"value":\u2026}}\` with type ${Pu}. Email val\
|
|
483
489
|
ues arrive lowercased.
|
|
484
490
|
- \`target\`: \`{"href","origin"}\` of the application page the cookies are for.
|
|
485
491
|
|
|
486
492
|
\`\`\`json
|
|
487
|
-
${
|
|
493
|
+
${vi(Cu)}
|
|
488
494
|
\`\`\`
|
|
489
495
|
|
|
490
496
|
## Response
|
|
491
497
|
|
|
492
498
|
- Always: \`protocol\`, the same \`requestId\`, boolean \`ok\`, and \`setCookie\`: an array of complete Set-Cookie header values\
|
|
493
|
-
(at most ${
|
|
499
|
+
(at most ${Ei}, each at most ${Si} bytes, no line breaks, no \`Domain\` attribute, never named \`${cr}\` or \`${cr}_*\`)\
|
|
494
500
|
.
|
|
495
|
-
- \`ok: true\`: at least one cookie. For ${
|
|
496
|
-
\`, \`username\`. For ${
|
|
501
|
+
- \`ok: true\`: at least one cookie. For ${_e}, \`identity\` with at least one of \`displayName\`, \`email\`, \`login\`, \`userId\
|
|
502
|
+
\`, \`username\`. For ${Pt} (or \`"signedOut": true\`), the cookies that clear the session.
|
|
497
503
|
- \`ok: false\`: \`code\` (at most 128 characters), \`error\` (a person-readable reason, at most 2000), \`statusCode\` 400 throu\
|
|
498
504
|
gh 599 (default 400), optional \`signedOut\`, and \`setCookie\` (may be empty).
|
|
499
505
|
|
|
500
506
|
\`\`\`json
|
|
501
|
-
${
|
|
507
|
+
${vi(Nu)}
|
|
502
508
|
\`\`\`
|
|
503
509
|
|
|
504
510
|
\`\`\`json
|
|
505
|
-
${
|
|
511
|
+
${vi(ju)}
|
|
506
512
|
\`\`\`
|
|
507
513
|
`},{name:"preview-identities",title:"Managed app identities",text:()=>`# Managed app identities
|
|
508
514
|
|
|
509
515
|
The ordered list of named existing application accounts that Preview and managed Playwright can sign in as through the a\
|
|
510
516
|
pplication's Preview identity command (\`vibe64-helper spec preview-identity-command\`).
|
|
511
517
|
|
|
512
|
-
- Each entry has a \`name\`, a selector \`type\` (${
|
|
513
|
-
e, start with a lowercase letter and use at most 64 lowercase letters, digits, \`_\` or \`-\`; ${[...
|
|
514
|
-
join(", ")} are reserved. At most ${
|
|
518
|
+
- Each entry has a \`name\`, a selector \`type\` (${Pu}) and the application's \`value\` for that account. Names are uniqu\
|
|
519
|
+
e, start with a lowercase letter and use at most 64 lowercase letters, digits, \`_\` or \`-\`; ${[...mu].map(e=>`\`${e}\``).
|
|
520
|
+
join(", ")} are reserved. At most ${hu} entries; the first is the default.
|
|
515
521
|
- Entries are selectors only, never passwords. A saved entry does not prove that the account exists or can reach a page:\
|
|
516
522
|
verify the selected account's actual Preview access.
|
|
517
523
|
- Read the list and the Stack's declared types with \`vibe64-helper preview identities\`; \`vibe64-helper preview status\` s\
|
|
@@ -530,503 +536,754 @@ Entry shape:
|
|
|
530
536
|
\`\`\`json
|
|
531
537
|
{"name":"admin","type":"email","value":"admin@example.com"}
|
|
532
538
|
\`\`\`
|
|
533
|
-
`}])});var
|
|
534
|
-
function
|
|
535
|
-
cts:",...
|
|
536
|
-
`)}async function
|
|
539
|
+
`}])});var Lu={};zo(Lu,{__testables:()=>Qy,runAgentSpecCli:()=>Zy});import{readFile as Ky}from"node:fs/promises";import{VIBE64_GENESIS_AGENT_SPECS as Xy}from"@local/vibe64-genesis/server/agentSpecs";
|
|
540
|
+
function $u(){let e=Math.max(...mn.map(({name:t})=>t.length));return["Usage: vibe64 spec <name>","","Vibe64-owned contra\
|
|
541
|
+
cts:",...mn.map(({name:t,title:r})=>` ${t.padEnd(e)} ${r}`)].join(`
|
|
542
|
+
`)}async function Zy(e=[],{write:t=n=>process.stdout.write(`${n.trimEnd()}
|
|
537
543
|
`),writeError:r=n=>process.stderr.write(`${n.trimEnd()}
|
|
538
|
-
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t(
|
|
544
|
+
`)}={}){let[n]=e;if(!n||n==="--help"||n==="-h")return t($u()),0;let o=e.length===1&&mn.find(i=>i.name===n);return o?(t(await o.
|
|
539
545
|
text()),0):(r(`Unknown Vibe64 spec: ${e.join(" ")}.
|
|
540
546
|
|
|
541
|
-
${
|
|
542
|
-
freeze([...
|
|
543
|
-
e",text:()=>
|
|
544
|
-
e)
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
e
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
[
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
e
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
$
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
if(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
"
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
{
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
"
|
|
689
|
-
|
|
690
|
-
{
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
return
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
let
|
|
721
|
-
|
|
722
|
-
e
|
|
723
|
-
if(
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
"
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
if(
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
let
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
"
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
"
|
|
547
|
+
${$u()}`),2)}var Jy,mn,Qy,Mu=b(()=>{tc();ku();Jy=new URL("./../server/lib/agentSpecCli.js",import.meta.url).href,mn=Object.
|
|
548
|
+
freeze([...Xy,...xu,...ec,{name:"training-content",title:"Teaching content format for vibe64 training validate and bundl\
|
|
549
|
+
e",text:()=>Ky(new URL("../../docs/training-content.md",Jy),"utf8")}]);Qy=Object.freeze({VIBE64_AGENT_SPECS:mn})});var Du=b(()=>{});import{lstat as ew,readdir as tw}from"node:fs/promises";import lr from"node:path";async function Ii(e){if(!lr.isAbsolute(
|
|
550
|
+
e||"")||lr.resolve(e)===lr.parse(e).root)throw new Error("Project state inventory requires an absolute, non-root system \
|
|
551
|
+
directory.");let t=lr.join(e,hn),r;try{if(!(await ew(t)).isDirectory())throw new Error("Project state inventory requires\
|
|
552
|
+
a regular projects directory.");r=await tw(t,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}if(r.some(
|
|
553
|
+
n=>n.isSymbolicLink()))throw new Error("Project state inventory contains a symbolic link. Inspect it before upgrading.");
|
|
554
|
+
return r.filter(n=>n.isDirectory()).map(n=>lr.join(t,n.name)).sort()}var hn,Ue=b(()=>{le();Du();U();hn="projects"});var Ri=z((VN,Bu)=>{"use strict";var dr=e=>e&&typeof e.message=="string",Oi=e=>{if(!e)return;let t=e.cause;if(typeof t=="\
|
|
555
|
+
function"){let r=e.cause();return dr(r)?r:void 0}else return dr(t)?t:void 0},Vu=(e,t)=>{if(!dr(e))return"";let r=e.stack||
|
|
556
|
+
"";if(t.has(e))return r+`
|
|
557
|
+
causes have become circular...`;let n=Oi(e);return n?(t.add(e),r+`
|
|
558
|
+
caused by: `+Vu(n,t)):r},rw=e=>Vu(e,new Set),Uu=(e,t,r)=>{if(!dr(e))return"";let n=r?"":e.message||"";if(t.has(e))return n+
|
|
559
|
+
": ...";let o=Oi(e);if(o){t.add(e);let i=typeof e.cause=="function";return n+(i?"":": ")+Uu(o,t,i)}else return n},nw=e=>Uu(
|
|
560
|
+
e,new Set);Bu.exports={isErrorLike:dr,getErrorCause:Oi,stackWithCauses:rw,messageWithCauses:nw}});var Ai=z((UN,Gu)=>{"use strict";var ow=Symbol("circular-ref-tag"),gn=Symbol("pino-raw-err-ref"),zu=Object.create({},{type:{
|
|
561
|
+
enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,
|
|
562
|
+
value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[gn]},
|
|
563
|
+
set:function(e){this[gn]=e}}});Object.defineProperty(zu,gn,{writable:!0,value:{}});Gu.exports={pinoErrProto:zu,pinoErrorSymbols:{
|
|
564
|
+
seen:ow,rawSymbol:gn}}});var qu=z((BN,Hu)=>{"use strict";Hu.exports=Ci;var{messageWithCauses:iw,stackWithCauses:sw,isErrorLike:Fu}=Ri(),{pinoErrProto:aw,
|
|
565
|
+
pinoErrorSymbols:cw}=Ai(),{seen:Pi}=cw,{toString:uw}=Object.prototype;function Ci(e){if(!Fu(e))return e;e[Pi]=void 0;let t=Object.
|
|
566
|
+
create(aw);t.type=uw.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,t.message=iw(e),t.stack=sw(e),Array.
|
|
567
|
+
isArray(e.errors)&&(t.aggregateErrors=e.errors.map(r=>Ci(r)));for(let r in e)if(t[r]===void 0){let n=e[r];Fu(n)?r!=="cau\
|
|
568
|
+
se"&&!Object.prototype.hasOwnProperty.call(n,Pi)&&(t[r]=Ci(n)):t[r]=n}return delete e[Pi],t.raw=e,t}});var Yu=z((zN,Wu)=>{"use strict";Wu.exports=wn;var{isErrorLike:Ni}=Ri(),{pinoErrProto:lw,pinoErrorSymbols:dw}=Ai(),{seen:yn}=dw,
|
|
569
|
+
{toString:fw}=Object.prototype;function wn(e){if(!Ni(e))return e;e[yn]=void 0;let t=Object.create(lw);t.type=fw.call(e.constructor)===
|
|
570
|
+
"[object Function]"?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=
|
|
571
|
+
e.errors.map(r=>wn(r))),Ni(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,yn)&&(t.cause=wn(e.cause));for(let r in e)
|
|
572
|
+
if(t[r]===void 0){let n=e[r];Ni(n)?Object.prototype.hasOwnProperty.call(n,yn)||(t[r]=wn(n)):t[r]=n}return delete e[yn],t.
|
|
573
|
+
raw=e,t}});var Zu=z((GN,Xu)=>{"use strict";Xu.exports={mapHttpRequest:pw,reqSerializer:Ku};var ji=Symbol("pino-raw-req-ref"),Ju=Object.
|
|
574
|
+
create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,
|
|
575
|
+
value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,
|
|
576
|
+
writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},
|
|
577
|
+
raw:{enumerable:!1,get:function(){return this[ji]},set:function(e){this[ji]=e}}});Object.defineProperty(Ju,ji,{writable:!0,
|
|
578
|
+
value:{}});function Ku(e){let t=e.info||e.socket,r=Object.create(Ju);if(r.id=typeof e.id=="function"?e.id():e.id||(e.info?
|
|
579
|
+
e.info.id:void 0),r.method=e.method,e.originalUrl)r.url=e.originalUrl;else{let n=e.path;r.url=typeof n=="string"?n:e.url?
|
|
580
|
+
e.url.path||e.url:void 0}return e.query&&(r.query=e.query),e.params&&(r.params=e.params),r.headers=e.headers,r.remoteAddress=
|
|
581
|
+
t&&t.remoteAddress,r.remotePort=t&&t.remotePort,r.raw=e.raw||e,r}function pw(e){return{req:Ku(e)}}});var rl=z((FN,tl)=>{"use strict";tl.exports={mapHttpResponse:mw,resSerializer:el};var xi=Symbol("pino-raw-res-ref"),Qu=Object.
|
|
582
|
+
create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,
|
|
583
|
+
get:function(){return this[xi]},set:function(e){this[xi]=e}}});Object.defineProperty(Qu,xi,{writable:!0,value:{}});function el(e){
|
|
584
|
+
let t=Object.create(Qu);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,
|
|
585
|
+
t.raw=e,t}function mw(e){return{res:el(e)}}});var $i=z((HN,nl)=>{"use strict";var ki=qu(),hw=Yu(),_n=Zu(),bn=rl();nl.exports={err:ki,errWithCause:hw,mapHttpRequest:_n.
|
|
586
|
+
mapHttpRequest,mapHttpResponse:bn.mapHttpResponse,req:_n.reqSerializer,res:bn.resSerializer,wrapErrorSerializer:function(t){
|
|
587
|
+
return t===ki?t:function(n){return t(ki(n))}},wrapRequestSerializer:function(t){return t===_n.reqSerializer?t:function(n){
|
|
588
|
+
return t(_n.reqSerializer(n))}},wrapResponseSerializer:function(t){return t===bn.resSerializer?t:function(n){return t(bn.
|
|
589
|
+
resSerializer(n))}}}});var Li=z((qN,ol)=>{"use strict";function gw(e,t){return t}ol.exports=function(){let t=Error.prepareStackTrace;Error.prepareStackTrace=
|
|
590
|
+
gw;let r=new Error().stack;if(Error.prepareStackTrace=t,!Array.isArray(r))return;let n=r.slice(2),o=[];for(let i of n)i&&
|
|
591
|
+
o.push(i.getFileName());return o}});var ll=z((WN,ul)=>{"use strict";function Mi(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(
|
|
592
|
+
e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=Mi(e[r]);return t}if(typeof e=="object"){let t=Object.
|
|
593
|
+
create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Mi(e[r]));return t}return e}
|
|
594
|
+
function il(e){let t=[],r="",n=!1,o=!1,i="";for(let s=0;s<e.length;s++){let a=e[s];!n&&a==="."?r&&(t.push(r),r=""):a==="\
|
|
595
|
+
["?(r&&(t.push(r),r=""),n=!0):a==="]"&&n?(t.push(r),r="",n=!1,o=!1):(a==='"'||a==="'")&&n?o?a===i?(o=!1,i=""):r+=a:(o=!0,
|
|
596
|
+
i=a):r+=a}return r&&t.push(r),t}function sl(e,t,r){let n=e;for(let i=0;i<t.length-1;i++){let s=t[i];if(typeof n!="object"||
|
|
597
|
+
n===null||!(s in n)||typeof n[s]!="object"||n[s]===null)return!1;n=n[s]}let o=t[t.length-1];if(o==="*"){if(Array.isArray(
|
|
598
|
+
n))for(let i=0;i<n.length;i++)n[i]=r;else if(typeof n=="object"&&n!==null)for(let i in n)Object.prototype.hasOwnProperty.
|
|
599
|
+
call(n,i)&&(n[i]=r)}else typeof n=="object"&&n!==null&&o in n&&Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=r);return!0}
|
|
600
|
+
function al(e,t){let r=e;for(let o=0;o<t.length-1;o++){let i=t[o];if(typeof r!="object"||r===null||!(i in r)||typeof r[i]!=
|
|
601
|
+
"object"||r[i]===null)return!1;r=r[i]}let n=t[t.length-1];if(n==="*"){if(Array.isArray(r))for(let o=0;o<r.length;o++)r[o]=
|
|
602
|
+
void 0;else if(typeof r=="object"&&r!==null)for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]}else typeof r==
|
|
603
|
+
"object"&&r!==null&&n in r&&Object.prototype.hasOwnProperty.call(r,n)&&delete r[n];return!0}var En=Symbol("PATH_NOT_FOUN\
|
|
604
|
+
D");function yw(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||r===null||!(n in r))return En;r=r[n]}return r}
|
|
605
|
+
function ww(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||r===null)return;r=r[n]}return r}function _w(e,t,r,n=!1){
|
|
606
|
+
for(let o of t){let i=il(o);if(i.includes("*"))cl(e,i,r,o,n);else if(n)al(e,i);else{let s=yw(e,i);if(s===En)continue;let a=typeof r==
|
|
607
|
+
"function"?r(s,i):r;sl(e,i,a)}}}function cl(e,t,r,n,o=!1){let i=t.indexOf("*");if(i===t.length-1){let s=t.slice(0,-1),a=e;
|
|
608
|
+
for(let c of s){if(a==null||typeof a!="object"||a===null)return;a=a[c]}if(Array.isArray(a))if(o)for(let c=0;c<a.length;c++)
|
|
609
|
+
a[c]=void 0;else for(let c=0;c<a.length;c++){let u=[...s,c.toString()],d=typeof r=="function"?r(a[c],u):r;a[c]=d}else if(typeof a==
|
|
610
|
+
"object"&&a!==null)if(o){let c=[];for(let u in a)Object.prototype.hasOwnProperty.call(a,u)&&c.push(u);for(let u of c)delete a[u]}else
|
|
611
|
+
for(let c in a){let u=[...s,c],d=typeof r=="function"?r(a[c],u):r;a[c]=d}}else bw(e,t,r,i,n,o)}function bw(e,t,r,n,o,i=!1){
|
|
612
|
+
let s=t.slice(0,n),a=t.slice(n+1),c=[];function u(d,p){if(p===s.length){if(Array.isArray(d))for(let g=0;g<d.length;g++)c[p]=
|
|
613
|
+
g.toString(),u(d[g],p+1);else if(typeof d=="object"&&d!==null)for(let g in d)c[p]=g,u(d[g],p+1)}else if(p<s.length){let g=s[p];
|
|
614
|
+
d&&typeof d=="object"&&d!==null&&g in d&&(c[p]=g,u(d[g],p+1))}else if(a.includes("*"))cl(d,a,typeof r=="function"?(h,l)=>{
|
|
615
|
+
let w=[...c.slice(0,p),...l];return r(h,w)}:r,o,i);else if(i)al(d,a);else{let g=typeof r=="function"?r(ww(d,a),[...c.slice(
|
|
616
|
+
0,p),...a]):r;sl(d,a,g)}}if(s.length===0)u(e,0);else{let d=e;for(let p=0;p<s.length;p++){let g=s[p];if(d==null||typeof d!=
|
|
617
|
+
"object"||d===null)return;d=d[g],c[p]=g}d!=null&&u(d,s.length)}}function Ew(e){if(e.length===0)return null;let t=new Map;
|
|
618
|
+
for(let r of e){let n=il(r),o=t;for(let i=0;i<n.length;i++){let s=n[i];o.has(s)||o.set(s,new Map),o=o.get(s)}}return t}function Sw(e,t){
|
|
619
|
+
if(!t)return e;function r(n,o,i=0){if(!o||o.size===0||n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(
|
|
620
|
+
n.getTime());if(Array.isArray(n)){let a=[];for(let c=0;c<n.length;c++){let u=c.toString();o.has(u)||o.has("*")?a[c]=r(n[c],
|
|
621
|
+
o.get(u)||o.get("*")):a[c]=n[c]}return a}let s=Object.create(Object.getPrototypeOf(n));for(let a in n)Object.prototype.hasOwnProperty.
|
|
622
|
+
call(n,a)&&(o.has(a)||o.has("*")?s[a]=r(n[a],o.get(a)||o.get("*")):s[a]=n[a]);return s}return r(e,t)}function vw(e){if(typeof e!=
|
|
623
|
+
"string")throw new Error("Paths must be (non-empty) strings");if(e==="")throw new Error("Invalid redaction path ()");if(e.
|
|
624
|
+
includes(".."))throw new Error(`Invalid redaction path (${e})`);if(e.includes(","))throw new Error(`Invalid redaction pa\
|
|
625
|
+
th (${e})`);let t=0,r=!1,n="";for(let o=0;o<e.length;o++){let i=e[o];if((i==='"'||i==="'")&&t>0)r?i===n&&(r=!1,n=""):(r=
|
|
626
|
+
!0,n=i);else if(i==="["&&!r)t++;else if(i==="]"&&!r&&(t--,t<0))throw new Error(`Invalid redaction path (${e})`)}if(t!==0)
|
|
627
|
+
throw new Error(`Invalid redaction path (${e})`)}function Tw(e){if(!Array.isArray(e))throw new TypeError("paths must be \
|
|
628
|
+
an array");for(let t of e)vw(t)}function Iw(e={}){let{paths:t=[],censor:r="[REDACTED]",serialize:n=JSON.stringify,strict:o=!0,
|
|
629
|
+
remove:i=!1}=e;Tw(t);let s=Ew(t);return function(c){if(o&&(c===null||typeof c!="object")&&(c==null||typeof c!="object"))
|
|
630
|
+
return n?n(c):c;let u=Sw(c,s),d=c,p=r;return typeof r=="function"&&(p=r),_w(u,t,p,i),n===!1?(u.restore=function(){return Mi(
|
|
631
|
+
d)},u):typeof n=="function"?n(u):JSON.stringify(u)}}ul.exports=Iw});var Nt=z((YN,dl)=>{"use strict";var Ow=Symbol("pino.setLevel"),Rw=Symbol("pino.getLevel"),Aw=Symbol("pino.levelVal"),Pw=Symbol(
|
|
632
|
+
"pino.levelComp"),Cw=Symbol("pino.useLevelLabels"),Nw=Symbol("pino.useOnlyCustomLevels"),jw=Symbol("pino.mixin"),xw=Symbol(
|
|
633
|
+
"pino.lsCache"),kw=Symbol("pino.chindings"),$w=Symbol("pino.asJson"),Lw=Symbol("pino.write"),Mw=Symbol("pino.redactFmt"),
|
|
634
|
+
Dw=Symbol("pino.time"),Vw=Symbol("pino.timeSliceIndex"),Uw=Symbol("pino.stream"),Bw=Symbol("pino.stringify"),zw=Symbol("\
|
|
635
|
+
pino.stringifySafe"),Gw=Symbol("pino.stringifiers"),Fw=Symbol("pino.end"),Hw=Symbol("pino.formatOpts"),qw=Symbol("pino.m\
|
|
636
|
+
essageKey"),Ww=Symbol("pino.errorKey"),Yw=Symbol("pino.nestedKey"),Jw=Symbol("pino.nestedKeyStr"),Kw=Symbol("pino.mixinM\
|
|
637
|
+
ergeStrategy"),Xw=Symbol("pino.msgPrefix"),Zw=Symbol("pino.wildcardFirst"),Qw=Symbol.for("pino.serializers"),e_=Symbol.for(
|
|
638
|
+
"pino.formatters"),t_=Symbol.for("pino.hooks"),r_=Symbol.for("pino.metadata");dl.exports={setLevelSym:Ow,getLevelSym:Rw,
|
|
639
|
+
levelValSym:Aw,levelCompSym:Pw,useLevelLabelsSym:Cw,mixinSym:jw,lsCacheSym:xw,chindingsSym:kw,asJsonSym:$w,writeSym:Lw,serializersSym:Qw,
|
|
640
|
+
redactFmtSym:Mw,timeSym:Dw,timeSliceIndexSym:Vw,streamSym:Uw,stringifySym:Bw,stringifySafeSym:zw,stringifiersSym:Gw,endSym:Fw,
|
|
641
|
+
formatOptsSym:Hw,messageKeySym:qw,errorKeySym:Ww,nestedKeySym:Yw,wildcardFirstSym:Zw,needsMetadataGsym:r_,useOnlyCustomLevelsSym:Nw,
|
|
642
|
+
formattersSym:e_,hooksSym:t_,nestedKeyStrSym:Jw,mixinMergeStrategySym:Kw,msgPrefixSym:Xw}});var Vi=z((JN,hl)=>{"use strict";var fl=ll(),{redactFmtSym:n_,wildcardFirstSym:Sn}=Nt(),Di=/[^.[\]]+|\[([^[\]]*?)\]/g,pl="\
|
|
643
|
+
[Redacted]",ml=!1;function o_(e,t){let{paths:r,censor:n,remove:o}=i_(e),i=r.reduce((c,u)=>{Di.lastIndex=0;let d=Di.exec(
|
|
644
|
+
u),p=Di.exec(u),g=d[1]!==void 0?d[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):d[0];if(g==="*"&&(g=Sn),p===null)return c[g]=
|
|
645
|
+
null,c;if(c[g]===null)return c;let{index:h}=p,l=`${u.substr(h,u.length-1)}`;return c[g]=c[g]||[],g!==Sn&&c[g].length===0&&
|
|
646
|
+
c[g].push(...c[Sn]||[]),g===Sn&&Object.keys(c).forEach(function(w){c[w]&&c[w].push(l)}),c[g].push(l),c},{}),s={[n_]:fl({
|
|
647
|
+
paths:r,censor:n,serialize:t,strict:ml,remove:o})},a=(...c)=>t(typeof n=="function"?n(...c):n);return[...Object.keys(i),
|
|
648
|
+
...Object.getOwnPropertySymbols(i)].reduce((c,u)=>{if(i[u]===null)c[u]=d=>a(d,[u]);else{let d=typeof n=="function"?(p,g)=>n(
|
|
649
|
+
p,[u,...g]):n;c[u]=fl({paths:i[u],censor:d,serialize:t,strict:ml,remove:o})}return c},s)}function i_(e){if(Array.isArray(
|
|
650
|
+
e))return e={paths:e,censor:pl},e;let{paths:t,censor:r=pl,remove:n}=e;if(Array.isArray(t)===!1)throw Error("pino \u2013 redac\
|
|
651
|
+
t must contain an array of strings");return n===!0&&(r=void 0),{paths:t,censor:r,remove:n}}hl.exports=o_});var wl=z((KN,yl)=>{"use strict";var s_=()=>"",a_=()=>`,"time":${Date.now()}`,c_=()=>`,"time":${Math.round(Date.now()/1e3)}`,
|
|
652
|
+
u_=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,l_=1000000n,gl=1000000000n,d_=BigInt(Date.now())*l_,f_=process.
|
|
653
|
+
hrtime.bigint(),p_=()=>{let e=process.hrtime.bigint()-f_,t=d_+e,r=t/gl,n=t%gl,o=Number(r*1000n+n/1000000n),i=new Date(o),
|
|
654
|
+
s=i.getUTCFullYear(),a=(i.getUTCMonth()+1).toString().padStart(2,"0"),c=i.getUTCDate().toString().padStart(2,"0"),u=i.getUTCHours().
|
|
655
|
+
toString().padStart(2,"0"),d=i.getUTCMinutes().toString().padStart(2,"0"),p=i.getUTCSeconds().toString().padStart(2,"0");
|
|
656
|
+
return`,"time":"${s}-${a}-${c}T${u}:${d}:${p}.${n.toString().padStart(9,"0")}Z"`};yl.exports={nullTime:s_,epochTime:a_,unixTime:c_,
|
|
657
|
+
isoTime:u_,isoTimeNano:p_}});var bl=z((XN,_l)=>{"use strict";function m_(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}_l.exports=h_;function h_(e,t,r){
|
|
658
|
+
var n=r&&r.stringify||m_,o=1;if(typeof e=="object"&&e!==null){var i=t.length+o;if(i===1)return e;var s=new Array(i);s[0]=
|
|
659
|
+
n(e);for(var a=1;a<i;a++)s[a]=n(t[a]);return s.join(" ")}if(typeof e!="string")return e;var c=t.length;if(c===0)return e;
|
|
660
|
+
for(var u="",d=1-o,p=-1,g=e&&e.length||0,h=0;h<g;){if(e.charCodeAt(h)===37&&h+1<g){switch(p=p>-1?p:0,e.charCodeAt(h+1)){case 100:case 102:
|
|
661
|
+
if(d>=c||t[d]==null)break;p<h&&(u+=e.slice(p,h)),u+=Number(t[d]),p=h+2,h++;break;case 105:if(d>=c||t[d]==null)break;p<h&&
|
|
662
|
+
(u+=e.slice(p,h)),u+=Math.floor(Number(t[d])),p=h+2,h++;break;case 79:case 111:case 106:if(d>=c||t[d]===void 0)break;p<h&&
|
|
663
|
+
(u+=e.slice(p,h));var l=typeof t[d];if(l==="string"){u+="'"+t[d]+"'",p=h+2,h++;break}if(l==="function"){u+=t[d].name||"<\
|
|
664
|
+
anonymous>",p=h+2,h++;break}u+=n(t[d]),p=h+2,h++;break;case 115:if(d>=c)break;p<h&&(u+=e.slice(p,h)),u+=String(t[d]),p=h+
|
|
665
|
+
2,h++;break;case 37:p<h&&(u+=e.slice(p,h)),u+="%",p=h+2,h++,d--;break}++d}++h}return p===-1?e:(p<g&&(u+=e.slice(p)),u)}});var Bi=z((ZN,Ui)=>{"use strict";if(typeof SharedArrayBuffer<"u"&&typeof Atomics<"u"){let t=function(r){if((r>0&&r<1/0)===
|
|
666
|
+
!1)throw typeof r!="number"&&typeof r!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a \
|
|
667
|
+
number that is greater than 0 but less than Infinity");Atomics.wait(e,0,0,Number(r))},e=new Int32Array(new SharedArrayBuffer(
|
|
668
|
+
4));Ui.exports=t}else{let e=function(t){if((t>0&&t<1/0)===!1)throw typeof t!="number"&&typeof t!="bigint"?TypeError("sle\
|
|
669
|
+
ep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");let n=Date.
|
|
670
|
+
now()+Number(t);for(;n>Date.now(););};Ui.exports=e}});var Al=z((QN,Rl)=>{"use strict";var q=X("fs"),g_=X("events"),y_=X("util").inherits,El=X("path"),Gi=Bi(),w_=X("assert"),vn=100,
|
|
671
|
+
Tn=Buffer.allocUnsafe(0),__=16*1024,Sl="buffer",vl="utf8",[b_,E_]=(process.versions.node||"0.0").split(".").map(Number),
|
|
672
|
+
S_=b_>=22&&E_>=7;function Tl(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(i,s){if(i){t._reopening=
|
|
673
|
+
!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount("error")>0&&t.emit("error",i)}):t.emit("erro\
|
|
674
|
+
r",i);return}let a=t._reopening;t.fd=s,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.
|
|
675
|
+
emit("ready")):t.emit("ready"),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():a&&process.
|
|
676
|
+
nextTick(()=>t.emit("drain")))}let n=t.append?"a":"w",o=t.mode;if(t.sync)try{t.mkdir&&q.mkdirSync(El.dirname(e),{recursive:!0});
|
|
677
|
+
let i=q.openSync(e,n,o);r(null,i)}catch(i){throw r(i),i}else t.mkdir?q.mkdir(El.dirname(e),{recursive:!0},i=>{if(i)return r(
|
|
678
|
+
i);q.open(e,n,o,r)}):q.open(e,n,o,r)}function be(e){if(!(this instanceof be))return new be(e);let{fd:t,dest:r,minLength:n,
|
|
679
|
+
maxLength:o,maxWrite:i,periodicFlush:s,sync:a,append:c=!0,mkdir:u,retryEAGAIN:d,fsync:p,contentMode:g,mode:h}=e||{};t=t||
|
|
680
|
+
r,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=
|
|
681
|
+
!1,this._flushPending=!1,this._hwm=Math.max(n||0,16387),this.file=null,this.destroyed=!1,this.minLength=n||0,this.maxLength=
|
|
682
|
+
o||0,this.maxWrite=i||__,this._periodicFlush=s||0,this._periodicFlushTimer=void 0,this.sync=a||!1,this.writable=!0,this.
|
|
683
|
+
_fsync=p||!1,this.append=c||!1,this.mode=h,this.retryEAGAIN=d||(()=>!0),this.mkdir=u||!1;let l,w;if(g===Sl)this._writingBuf=
|
|
684
|
+
Tn,this.write=I_,this.flush=R_,this.flushSync=P_,this._actualWrite=N_,l=()=>q.writeSync(this.fd,this._writingBuf),w=()=>q.
|
|
685
|
+
write(this.fd,this._writingBuf,this.release);else if(g===void 0||g===vl)this._writingBuf="",this.write=T_,this.flush=O_,
|
|
686
|
+
this.flushSync=A_,this._actualWrite=C_,l=()=>Buffer.isBuffer(this._writingBuf)?q.writeSync(this.fd,this._writingBuf):q.writeSync(
|
|
687
|
+
this.fd,this._writingBuf,"utf8"),w=()=>Buffer.isBuffer(this._writingBuf)?q.write(this.fd,this._writingBuf,this.release):
|
|
688
|
+
q.write(this.fd,this._writingBuf,"utf8",this.release);else throw new Error(`SonicBoom supports "${vl}" and "${Sl}", but \
|
|
689
|
+
passed ${g}`);if(typeof t=="number")this.fd=t,process.nextTick(()=>this.emit("ready"));else if(typeof t=="string")Tl(t,this);else
|
|
690
|
+
throw new Error("SonicBoom supports only file descriptors and files");if(this.minLength>=this.maxWrite)throw new Error(`\
|
|
691
|
+
minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(_,f)=>{if(_){if((_.code==="EAGAIN"||_.code===
|
|
692
|
+
"EBUSY")&&this.retryEAGAIN(_,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{Gi(vn),this.release(
|
|
693
|
+
void 0,0)}catch(E){this.release(E)}else setTimeout(w,vn);else this._writing=!1,this.emit("error",_);return}this.emit("wr\
|
|
694
|
+
ite",f);let m=zi(this._writingBuf,this._len,f);if(this._len=m.len,this._writingBuf=m.writingBuf,this._writingBuf.length){
|
|
695
|
+
if(!this.sync){w();return}try{do{let E=l(),T=zi(this._writingBuf,this._len,E);this._len=T.len,this._writingBuf=T.writingBuf}while(this.
|
|
696
|
+
_writingBuf.length)}catch(E){this.release(E);return}}this._fsync&&q.fsyncSync(this.fd);let y=this._len;this._reopening?(this.
|
|
697
|
+
_writing=!1,this._reopening=!1,this.reopen()):y>this.minLength?this._actualWrite():this._ending?y>0?this._actualWrite():
|
|
698
|
+
(this._writing=!1,In(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.
|
|
699
|
+
nextTick(v_,this)):this.emit("drain"))},this.on("newListener",function(_){_==="drain"&&(this._asyncDrainScheduled=!1)}),
|
|
700
|
+
this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.
|
|
701
|
+
unref())}function zi(e,t,r){return typeof e=="string"&&(e=Buffer.from(e)),t=Math.max(t-r,0),e=e.subarray(r),{writingBuf:e,
|
|
702
|
+
len:t}}function v_(e){e.listenerCount("drain")>0&&(e._asyncDrainScheduled=!1,e.emit("drain"))}y_(be,g_);function Il(e,t){
|
|
703
|
+
return e.length===0?Tn:e.length===1?e[0]:Buffer.concat(e,t)}function T_(e){if(this.destroyed)throw new Error("SonicBoom \
|
|
704
|
+
destroyed");e=""+e;let t=Buffer.byteLength(e),r=this._len+t,n=this._bufs;return this.maxLength&&r>this.maxLength?(this.emit(
|
|
705
|
+
"drop",e),this._len<this._hwm):(n.length===0||Buffer.byteLength(n[n.length-1])+t>this.maxWrite?n.push(e):n[n.length-1]+=
|
|
706
|
+
e,this._len=r,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function I_(e){if(this.
|
|
707
|
+
destroyed)throw new Error("SonicBoom destroyed");let t=this._len+e.length,r=this._bufs,n=this._lens;return this.maxLength&&
|
|
708
|
+
t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(r.length===0||n[n.length-1]+e.length>this.maxWrite?(r.push([
|
|
709
|
+
e]),n.push(e.length)):(r[r.length-1].push(e),n[n.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&
|
|
710
|
+
this._actualWrite(),this._len<this._hwm)}function Ol(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=
|
|
711
|
+
!1,e();else try{q.fsync(this.fd,n=>{this._flushPending=!1,e(n)})}catch(n){e(n)}this.off("error",r)},r=n=>{this._flushPending=
|
|
712
|
+
!1,e(n),this.off("drain",t)};this.once("drain",t),this.once("error",r)}function O_(e){if(e!=null&&typeof e!="function")throw new Error(
|
|
713
|
+
"flush cb must be a function");if(this.destroyed){let t=new Error("SonicBoom destroyed");if(e){e(t);return}throw t}if(this.
|
|
714
|
+
minLength<=0){e?.();return}e&&Ol.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(""),this._actualWrite())}
|
|
715
|
+
function R_(e){if(e!=null&&typeof e!="function")throw new Error("flush cb must be a function");if(this.destroyed){let t=new Error(
|
|
716
|
+
"SonicBoom destroyed");if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&Ol.call(this,e),!this._writing&&(this.
|
|
717
|
+
_bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}be.prototype.reopen=function(e){if(this.
|
|
718
|
+
destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.reopen(e)});return}if(this.
|
|
719
|
+
_ending)return;if(!this.file)throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if(e&&
|
|
720
|
+
(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once("ready",()=>{t!==this.fd&&q.close(t,r=>{if(r)
|
|
721
|
+
return this.emit("error",r)})}),Tl(this.file,this)};be.prototype.end=function(){if(this.destroyed)throw new Error("Sonic\
|
|
722
|
+
Boom destroyed");if(this._opening){this.once("ready",()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&
|
|
723
|
+
(this._len>0&&this.fd>=0?this._actualWrite():In(this)))};function A_(){if(this.destroyed)throw new Error("SonicBoom dest\
|
|
724
|
+
royed");if(this.fd<0)throw new Error("sonic boom is not ready yet");!this._writing&&this._writingBuf.length>0&&(this._bufs.
|
|
725
|
+
unshift(this._writingBuf),this._writingBuf="");let e="";for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);
|
|
726
|
+
try{let t=Buffer.isBuffer(e)?q.writeSync(this.fd,e):q.writeSync(this.fd,e,"utf8"),r=zi(e,this._len,t);e=r.writingBuf,this.
|
|
727
|
+
_len=r.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code==="EAGAIN"||t.code==="EBUSY")&&!this.retryEAGAIN(t,e.length,
|
|
728
|
+
this._len-e.length))throw t;Gi(vn)}}try{q.fsyncSync(this.fd)}catch{}}function P_(){if(this.destroyed)throw new Error("So\
|
|
729
|
+
nicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");!this._writing&&this._writingBuf.length>
|
|
730
|
+
0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=Tn);let e=Tn;for(;this._bufs.length||e.length;){e.length<=0&&
|
|
731
|
+
(e=Il(this._bufs[0],this._lens[0]));try{let t=q.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.
|
|
732
|
+
length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code==="EAGAIN"||t.code==="EBUSY")&&!this.retryEAGAIN(
|
|
733
|
+
t,e.length,this._len-e.length))throw t;Gi(vn)}}}be.prototype.destroy=function(){this.destroyed||In(this)};function C_(){
|
|
734
|
+
let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||"",
|
|
735
|
+
this.sync)try{let t=Buffer.isBuffer(this._writingBuf)?q.writeSync(this.fd,this._writingBuf):q.writeSync(this.fd,this._writingBuf,
|
|
736
|
+
"utf8");e(null,t)}catch(t){e(t)}else q.write(this.fd,this._writingBuf,e)}function N_(){let e=this.release;if(this._writing=
|
|
737
|
+
!0,this._writingBuf=this._writingBuf.length?this._writingBuf:Il(this._bufs.shift(),this._lens.shift()),this.sync)try{let t=q.
|
|
738
|
+
writeSync(this.fd,this._writingBuf);e(null,t)}catch(t){e(t)}else S_&&(this._writingBuf=Buffer.from(this._writingBuf)),q.
|
|
739
|
+
write(this.fd,this._writingBuf,e)}function In(e){if(e.fd===-1){e.once("ready",In.bind(null,e));return}e._periodicFlushTimer!==
|
|
740
|
+
void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],w_(typeof e.fd=="number",`sonic.fd mus\
|
|
741
|
+
t be a number, got ${typeof e.fd}`);try{q.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?q.close(e.fd,r):r()}function r(n){
|
|
742
|
+
if(n){e.emit("error",n);return}e._ending&&!e._writing&&e.emit("finish"),e.emit("close")}}be.SonicBoom=be;be.default=be;Rl.
|
|
743
|
+
exports=be});var Fi=z((ej,xl)=>{"use strict";var Ee={exit:[],beforeExit:[]},Pl={exit:k_,beforeExit:$_},jt;function j_(){jt===void 0&&
|
|
744
|
+
(jt=new FinalizationRegistry(L_))}function x_(e){Ee[e].length>0||process.on(e,Pl[e])}function Cl(e){Ee[e].length>0||(process.
|
|
745
|
+
removeListener(e,Pl[e]),Ee.exit.length===0&&Ee.beforeExit.length===0&&(jt=void 0))}function k_(){Nl("exit")}function $_(){
|
|
746
|
+
Nl("beforeExit")}function Nl(e){for(let t of Ee[e]){let r=t.deref(),n=t.fn;r!==void 0&&n(r,e)}Ee[e]=[]}function L_(e){for(let t of[
|
|
747
|
+
"exit","beforeExit"]){let r=Ee[t].indexOf(e);Ee[t].splice(r,r+1),Cl(t)}}function jl(e,t,r){if(t===void 0)throw new Error(
|
|
748
|
+
"the object can't be undefined");x_(e);let n=new WeakRef(t);n.fn=r,j_(),jt.register(t,n),Ee[e].push(n)}function M_(e,t){
|
|
749
|
+
jl("exit",e,t)}function D_(e,t){jl("beforeExit",e,t)}function V_(e){if(jt!==void 0){jt.unregister(e);for(let t of["exit",
|
|
750
|
+
"beforeExit"])Ee[t]=Ee[t].filter(r=>{let n=r.deref();return n&&n!==e}),Cl(t)}}xl.exports={register:M_,registerBeforeExit:D_,
|
|
751
|
+
unregister:V_}});var kl=z((tj,U_)=>{U_.exports={name:"thread-stream",version:"4.2.0",description:"A streaming way to send data to a Node.\
|
|
752
|
+
js Worker Thread",main:"index.js",types:"index.d.ts",engines:{node:">=20"},dependencies:{"real-require":"^1.0.0"},devDependencies:{
|
|
753
|
+
"@types/node":"^25.0.2","@yao-pkg/pkg":"^6.0.0",borp:"^1.0.0",desm:"^1.3.0",eslint:"^9.39.1",fastbench:"^1.0.1",neostandard:"\
|
|
754
|
+
^0.13.0","pino-elasticsearch":"^9.0.0","sonic-boom":"^5.0.0","ts-node":"^10.8.0",typescript:"~5.7.3"},scripts:{build:"ts\
|
|
755
|
+
c --noEmit",lint:"eslint",test:'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mj\
|
|
756
|
+
s}"',"test:ci":'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:yarn":'npm run transpi\
|
|
757
|
+
le && borp --pattern "test/*.test.js"',transpile:"sh ./test/ts/transpile.sh"},repository:{type:"git",url:"git+https://gi\
|
|
758
|
+
thub.com/mcollina/thread-stream.git"},keywords:["worker","thread","threads","stream"],author:"Matteo Collina <hello@matt\
|
|
759
|
+
eocollina.com>",license:"MIT",bugs:{url:"https://github.com/mcollina/thread-stream/issues"},homepage:"https://github.com\
|
|
760
|
+
/mcollina/thread-stream#readme"}});var Ll=z((rj,$l)=>{"use strict";function B_(e,t,r,n,o){let i=n===1/0?1/0:Date.now()+n,s=()=>{let a=Atomics.load(e,t);if(a===
|
|
761
|
+
r){o(null,"ok");return}if(i!==1/0&&Date.now()>i){o(null,"timed-out");return}let c=i===1/0?1e4:Math.min(1e4,Math.max(1,i-
|
|
762
|
+
Date.now())),u=Atomics.waitAsync(e,t,a,c);u.async?u.value.then(s):setImmediate(s)};s()}function z_(e,t,r,n,o){let i=n===
|
|
763
|
+
1/0?1/0:Date.now()+n,s=()=>{if(Atomics.load(e,t)!==r){o(null,"ok");return}if(i!==1/0&&Date.now()>i){o(null,"timed-out");
|
|
764
|
+
return}let c=i===1/0?1e4:Math.min(1e4,Math.max(1,i-Date.now())),u=Atomics.waitAsync(e,t,r,c);u.async?u.value.then(d=>{if(d===
|
|
765
|
+
"ok"){o(null,"ok");return}s()}):setImmediate(s)};s()}$l.exports={wait:B_,waitDiff:z_}});var Dl=z((nj,Ml)=>{"use strict";Ml.exports={WRITE_INDEX:4,READ_INDEX:8,SEQ_INDEX:2}});var Kl=z((oj,Jl)=>{"use strict";var{version:G_}=kl(),{EventEmitter:F_}=X("events"),{Worker:H_}=X("worker_threads"),{join:q_}=X("path"),
|
|
766
|
+
{pathToFileURL:W_}=X("url"),{wait:Y_}=Ll(),{WRITE_INDEX:xe,READ_INDEX:nt,SEQ_INDEX:Hi}=Dl(),J_=X("buffer"),K_=X("assert"),
|
|
767
|
+
I=Symbol("kImpl"),X_=J_.constants.MAX_STRING_LENGTH;function Vl(){}function Ji(e,t){Atomics.add(e[I].state,Hi,1),t(),Atomics.
|
|
768
|
+
add(e[I].state,Hi,1),Atomics.notify(e[I].state,Hi)}function Ul(e){Ji(e,()=>{Atomics.store(e[I].state,nt,0),Atomics.store(
|
|
769
|
+
e[I].state,xe,0)})}var fr=class{constructor(t){this._value=t}deref(){return this._value}},On=class{register(){}unregister(){}},
|
|
770
|
+
Z_=process.env.NODE_V8_COVERAGE?On:global.FinalizationRegistry||On,Q_=process.env.NODE_V8_COVERAGE?fr:global.WeakRef||fr,
|
|
771
|
+
Bl=new Z_(e=>{e.exited||e.terminate()});function eb(e,t){let{filename:r,workerData:n}=t,i=("__bundlerPathsOverrides"in globalThis?
|
|
772
|
+
globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||q_(__dirname,"lib","worker.js"),s=new H_(i,{...t.workerOpts,
|
|
773
|
+
name:t.workerOpts?.name||"thread-stream",trackUnmanagedFds:!1,workerData:{filename:r.indexOf("file://")===0?r:W_(r).href,
|
|
774
|
+
dataBuf:e[I].dataBuf,stateBuf:e[I].stateBuf,workerData:{$context:{threadStreamVersion:G_},...n}}});return s.stream=new fr(
|
|
775
|
+
e),s.on("message",tb),s.on("exit",Fl),Bl.register(e,s),s}function zl(e){K_(!e[I].sync),e[I].needDrain&&(e[I].needDrain=!1,
|
|
776
|
+
e.emit("drain"))}function Gl(e){for(;;){let t=Atomics.load(e[I].state,xe),r=e[I].data.length-t;if(r>0){if(e[I].bufLen===
|
|
777
|
+
0){e[I].flushing=!1,e[I].ending?Ki(e):e[I].needDrain&&process.nextTick(zl,e);return}Wl(e,r,Vl);continue}if(r===0){if(t===
|
|
778
|
+
0&&e[I].bufLen===0)return;Rn(e,()=>{e.destroyed||(Ul(e),Gl(e))});return}he(e,new Error("overwritten"));return}}function tb(e){
|
|
779
|
+
let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}if(e?.code!=null)switch(e.code){case"REA\
|
|
780
|
+
DY":this.stream=new Q_(t),Rn(t,()=>{t[I].ready=!0,t.emit("ready")});break;case"ERROR":he(t,e.err);break;case"EVENT":Array.
|
|
781
|
+
isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case"FLUSHED":{if(e.context!=="thread-stream"){he(t,
|
|
782
|
+
new Error("this should not happen: "+e.code));break}let r=t[I].flushCallbacks.get(e.id);r&&(t[I].flushCallbacks.delete(e.
|
|
783
|
+
id),process.nextTick(r));break}case"WARNING":process.emitWarning(e.err);break;default:he(t,new Error("this should not ha\
|
|
784
|
+
ppen: "+e.code))}}function Fl(e){let t=this.stream.deref();t!==void 0&&(Bl.unregister(t),t.worker.exited=!0,t.worker.off(
|
|
785
|
+
"exit",Fl),he(t,e!==0?new Error("the worker thread exited"):null))}var Wi=class extends F_{constructor(t={}){if(super(),
|
|
786
|
+
t.bufferSize<4)throw new Error("bufferSize must at least fit a 4-byte utf-8 char");this[I]={},this[I].stateBuf=new SharedArrayBuffer(
|
|
787
|
+
128),this[I].state=new Int32Array(this[I].stateBuf),this[I].dataBuf=new SharedArrayBuffer(t.bufferSize||4*1024*1024),this[I].
|
|
788
|
+
data=Buffer.from(this[I].dataBuf),this[I].sync=t.sync||!1,this[I].ending=!1,this[I].ended=!1,this[I].needDrain=!1,this[I].
|
|
789
|
+
destroyed=!1,this[I].flushing=!1,this[I].ready=!1,this[I].finished=!1,this[I].errored=null,this[I].closed=!1,this[I].buf=
|
|
790
|
+
[],this[I].bufHead=0,this[I].bufLen=0,this[I].flushCallbacks=new Map,this[I].nextFlushId=0,this.worker=eb(this,t),this.on(
|
|
791
|
+
"message",(r,n)=>{this.worker.postMessage(r,n)})}write(t){let r=Buffer.isBuffer(t)?t:Buffer.from(t);if(this[I].destroyed)
|
|
792
|
+
return Yi(this,new Error("the worker has exited")),!1;if(this[I].ending)return Yi(this,new Error("the worker is ending")),
|
|
793
|
+
!1;if(this[I].flushing&&this[I].bufLen+r.length>=X_)try{qi(this),this[I].flushing=!0}catch(n){return he(this,n),!1}if(this[I].
|
|
794
|
+
buf.push(r),this[I].bufLen+=r.length,this[I].sync)try{return qi(this),!0}catch(n){return he(this,n),!1}return this[I].flushing||
|
|
795
|
+
(this[I].flushing=!0,setImmediate(Gl,this)),this[I].needDrain=this[I].data.length-this[I].bufLen-Atomics.load(this[I].state,
|
|
796
|
+
xe)<=0,!this[I].needDrain}end(){this[I].destroyed||(this[I].ending=!0,Ki(this))}flush(t){t=typeof t=="function"?t:Vl,Hl(
|
|
797
|
+
this,r=>{if(r){process.nextTick(t,r);return}ql(this,t)})}flushSync(){this[I].destroyed||(qi(this),Yl(this))}unref(){this.
|
|
798
|
+
worker.unref()}ref(){this.worker.ref()}get ready(){return this[I].ready}get destroyed(){return this[I].destroyed}get closed(){
|
|
799
|
+
return this[I].closed}get writable(){return!this[I].destroyed&&!this[I].ending}get writableEnded(){return this[I].ending}get writableFinished(){
|
|
800
|
+
return this[I].finished}get writableNeedDrain(){return this[I].needDrain}get writableObjectMode(){return!1}get writableErrored(){
|
|
801
|
+
return this[I].errored}};function Hl(e,t){if(e[I].destroyed){process.nextTick(t,new Error("the worker has exited"));return}
|
|
802
|
+
if(!e[I].sync&&(e[I].flushing||e[I].bufLen>0)){setImmediate(Hl,e,t);return}Rn(e,t)}function Rn(e,t){let r=Atomics.load(e[I].
|
|
803
|
+
state,xe);Y_(e[I].state,nt,r,1/0,(n,o)=>{if(n){he(e,n),t(n);return}if(o!=="ok"){Rn(e,t);return}t()})}function ql(e,t){if(e[I].
|
|
804
|
+
destroyed){process.nextTick(t,new Error("the worker has exited"));return}if(!e[I].ready){let n=()=>{i(),ql(e,t)},o=()=>{
|
|
805
|
+
i(),process.nextTick(t,new Error("the worker has exited"))},i=()=>{e.off("ready",n),e.off("close",o)};e.once("ready",n),
|
|
806
|
+
e.once("close",o);return}let r=++e[I].nextFlushId;e[I].flushCallbacks.set(r,t);try{e.worker.postMessage({code:"FLUSH",context:"\
|
|
807
|
+
thread-stream",id:r})}catch(n){e[I].flushCallbacks.delete(r),he(e,n),process.nextTick(t,n)}}function rb(e,t){let r=e[I].
|
|
808
|
+
flushCallbacks;if(r.size===0)return;let n=t||new Error("the worker has exited");for(let o of r.values())process.nextTick(
|
|
809
|
+
o,n);r.clear()}function Yi(e,t){setImmediate(()=>{e.emit("error",t)})}function he(e,t){e[I].destroyed||(e[I].destroyed=!0,
|
|
810
|
+
rb(e,t),t&&(e[I].errored=t,Yi(e,t)),e.worker.exited?setImmediate(()=>{e[I].closed=!0,e.emit("close")}):e.worker.terminate().
|
|
811
|
+
catch(()=>{}).then(()=>{e[I].closed=!0,e.emit("close")}))}function Wl(e,t,r){let o=Atomics.load(e[I].state,xe),i=t;for(;i>
|
|
812
|
+
0&&e[I].bufLen!==0;){let s=e[I].bufHead,a=e[I].buf[s];if(a.length<=i){a.copy(e[I].data,o),o+=a.length,i-=a.length,e[I].bufLen-=
|
|
813
|
+
a.length,e[I].bufHead=s+1,e[I].bufHead===e[I].buf.length?(e[I].buf.length=0,e[I].bufHead=0):e[I].bufHead>=1024&&e[I].bufHead*
|
|
814
|
+
2>=e[I].buf.length&&(e[I].buf.splice(0,e[I].bufHead),e[I].bufHead=0);continue}a.copy(e[I].data,o,0,i),e[I].buf[s]=a.subarray(
|
|
815
|
+
i),e[I].bufLen-=i,o+=i,i=0}return Ji(e,()=>{Atomics.store(e[I].state,xe,o)}),r(),!0}function Ki(e){if(!(e[I].ended||!e[I].
|
|
816
|
+
ending||e[I].flushing)){e[I].ended=!0;try{e.flushSync();let t=Atomics.load(e[I].state,nt);Ji(e,()=>{Atomics.store(e[I].state,
|
|
817
|
+
xe,-1)});let r=0;for(;t!==-1;){if(Atomics.wait(e[I].state,nt,t,1e3),t=Atomics.load(e[I].state,nt),t===-2){he(e,new Error(
|
|
818
|
+
"end() failed"));return}if(++r===10){he(e,new Error("end() took too long (10s)"));return}}process.nextTick(()=>{e[I].finished=
|
|
819
|
+
!0,e.emit("finish")})}catch(t){he(e,t)}}}function qi(e){let t=()=>{e[I].ending?Ki(e):e[I].needDrain&&process.nextTick(zl,
|
|
820
|
+
e)};for(e[I].flushing=!1;e[I].bufLen!==0;){let r=Atomics.load(e[I].state,xe),n=e[I].data.length-r;if(n===0){Yl(e),Ul(e);
|
|
821
|
+
continue}else if(n<0)throw new Error("overwritten");Wl(e,n,t)}}function Yl(e){if(e[I].flushing)throw new Error("unable t\
|
|
822
|
+
o flush while flushing");let t=Atomics.load(e[I].state,xe),r=0;for(;;){let n=Atomics.load(e[I].state,nt);if(n===-2)throw Error(
|
|
823
|
+
"_flushSync failed");if(n!==t)Atomics.wait(e[I].state,nt,n,1e3);else break;if(++r===10)throw new Error("_flushSync took \
|
|
824
|
+
too long (10s)")}}Jl.exports=Wi});var Qi=z((ij,Ql)=>{"use strict";var{createRequire:nb}=X("module"),{existsSync:ob}=X("node:fs"),ib=Li(),{join:Xi,isAbsolute:Zl,
|
|
825
|
+
sep:sb}=X("node:path"),{fileURLToPath:ab}=X("node:url"),cb=Bi(),Zi=Fi(),ub=Kl();function lb(e){Zi.register(e,hb),Zi.registerBeforeExit(
|
|
826
|
+
e,gb),e.on("close",function(){Zi.unregister(e)})}function db(){let e=process.execArgv;for(let t=0;t<e.length;t++){let r=e[t];
|
|
827
|
+
if(r==="--import"||r==="--require"||r==="-r"||r.startsWith("--import=")||r.startsWith("--require=")||r.startsWith("-r="))
|
|
828
|
+
return!0}return!1}function fb(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let r=[],n=!1;for(let o=0;o<
|
|
829
|
+
t.length;o++){let i=t[o];if(i==="--require"||i==="-r"||i==="--import"){let s=t[o+1];if(s&&Xl(s)){n=!0,o++;continue}r.push(
|
|
830
|
+
i),s&&(r.push(s),o++);continue}if(i.startsWith("--require=")||i.startsWith("-r=")||i.startsWith("--import=")){let s=i.slice(
|
|
831
|
+
i.indexOf("=")+1);if(Xl(s)){n=!0;continue}}r.push(i)}return n?r.join(" "):e}function Xl(e){let t=pb(e);if(!t)return!1;let r=t;
|
|
832
|
+
if(r.startsWith("file://"))try{r=ab(r)}catch{return!1}return Zl(r)&&!ob(r)}function pb(e){let t=e[0],r=e[e.length-1];return t===
|
|
833
|
+
'"'&&r==='"'||t==="'"&&r==="'"?e.slice(1,-1):e}function mb(e,t,r,n,o){if(!r.execArgv&&db()&&X.main===void 0&&(r={...r,execArgv:[]}),
|
|
834
|
+
!r.env&&process.env.NODE_OPTIONS){let c=fb(process.env.NODE_OPTIONS);c!==process.env.NODE_OPTIONS&&(r={...r,env:{...process.
|
|
835
|
+
env,NODE_OPTIONS:c}})}r={...r,name:o};let i=new ub({filename:e,workerData:t,workerOpts:r,sync:n});i.on("ready",s),i.on("\
|
|
836
|
+
close",function(){process.removeListener("exit",a)}),process.on("exit",a);function s(){process.removeListener("exit",a),
|
|
837
|
+
i.unref(),r.autoEnd!==!1&&lb(i)}function a(){i.closed||(i.flushSync(),cb(100),i.end())}return i}function hb(e){e.ref(),e.
|
|
838
|
+
flushSync(),e.end(),e.once("close",function(){e.unref()})}function gb(e){e.flushSync()}function yb(e){let{pipeline:t,targets:r,
|
|
839
|
+
levels:n,dedupe:o,worker:i={},caller:s=ib(),sync:a=!1}=e,c={...e.options},u=typeof s=="string"?[s]:s,d=typeof globalThis==
|
|
840
|
+
"object"&&Object.prototype.hasOwnProperty.call(globalThis,"__bundlerPathsOverrides")&&globalThis.__bundlerPathsOverrides&&
|
|
841
|
+
typeof globalThis.__bundlerPathsOverrides=="object"?globalThis.__bundlerPathsOverrides:Object.create(null),p=e.target;if(p&&
|
|
842
|
+
r)throw new Error("only one of target or targets can be specified");r?(p=d["pino-worker"]||Xi(__dirname,"worker.js"),c.targets=
|
|
843
|
+
r.filter(l=>l.target).map(l=>({...l,target:h(l.target)})),c.pipelines=r.filter(l=>l.pipeline).map(l=>l.pipeline.map(w=>({
|
|
844
|
+
...w,level:l.level,target:h(w.target)})))):t&&(p=d["pino-worker"]||Xi(__dirname,"worker.js"),c.pipelines=[t.map(l=>({...l,
|
|
845
|
+
target:h(l.target)}))]),n&&(c.levels=n),o&&(c.dedupe=o),c.pinoWillSendConfig=!0;let g=r||t?"pino.transport":p;return mb(
|
|
846
|
+
h(p),c,i,a,g);function h(l){if(l=d[l]||l,Zl(l)||l.indexOf("file://")===0)return l;if(l==="pino/file")return Xi(__dirname,
|
|
847
|
+
"..","file.js");let w;for(let _ of u)try{let f=_==="node:repl"?process.cwd()+sb:_;w=nb(f).resolve(l);break}catch{continue}
|
|
848
|
+
if(!w)throw new Error(`unable to determine transport target for "${l}"`);return w}}Ql.exports=yb});var Cn=z((aj,fd)=>{"use strict";var wb=X("node:diagnostics_channel"),ed=bl(),{mapHttpRequest:_b,mapHttpResponse:bb}=$i(),
|
|
849
|
+
ts=Al(),td=Fi(),{lsCacheSym:Eb,chindingsSym:sd,writeSym:rd,serializersSym:ad,formatOptsSym:nd,endSym:Sb,stringifiersSym:cd,
|
|
850
|
+
stringifySym:ud,stringifySafeSym:rs,wildcardFirstSym:ld,nestedKeySym:vb,formattersSym:dd,messageKeySym:Tb,errorKeySym:Ib,
|
|
851
|
+
nestedKeyStrSym:Ob,msgPrefixSym:An}=Nt(),{isMainThread:Rb}=X("worker_threads"),Ab=Qi(),[Pb]=process.versions.node.split(
|
|
852
|
+
".").map(e=>Number(e)),od=wb.tracingChannel("pino_asJson"),es=Pb>=25?e=>JSON.stringify(e):Nb;function xt(){}function Cb(e,t){
|
|
853
|
+
if(!t)return r;return function(...o){t.call(this,o,r,e)};function r(n,...o){if(typeof n=="object"){let i=n;n!==null&&(n.
|
|
854
|
+
method&&n.headers&&n.socket?n=_b(n):typeof n.setHeader=="function"&&(n=bb(n)));let s;i===null&&o.length===0?s=[null]:(i=
|
|
855
|
+
o.shift(),s=o),typeof this[An]=="string"&&i!==void 0&&i!==null&&(i=this[An]+i),this[rd](n,ed(i,s,this[nd]),e)}else{let i=n===
|
|
856
|
+
void 0?o.shift():n;typeof this[An]=="string"&&i!==void 0&&i!==null&&(i=this[An]+i),this[rd](null,ed(i,o,this[nd]),e)}}}function Nb(e){
|
|
857
|
+
let t="",r=0,n=!1,o=255,i=e.length;if(i>100)return JSON.stringify(e);for(var s=0;s<i&&o>=32;s++)o=e.charCodeAt(s),(o===34||
|
|
858
|
+
o===92)&&(t+=e.slice(r,s)+"\\",r=s,n=!0);return n?t+=e.slice(r):t=e,o<32?JSON.stringify(e):'"'+t+'"'}function jb(e,t,r,n){
|
|
859
|
+
if(od.hasSubscribers===!1)return id.call(this,e,t,r,n);let o={instance:this,arguments};return od.traceSync(id,o,this,e,t,
|
|
860
|
+
r,n)}function id(e,t,r,n){let o=this[ud],i=this[rs],s=this[cd],a=this[Sb],c=this[sd],u=this[ad],d=this[dd],p=this[Tb],g=this[Ib],
|
|
861
|
+
h=this[Eb][r]+n;h=h+c;let l;d.log&&(e=d.log(e));let w=s[ld],_="";for(let m in e)if(l=e[m],Object.prototype.hasOwnProperty.
|
|
862
|
+
call(e,m)&&l!==void 0){u[m]?l=u[m](l):m===g&&u.err&&(l=u.err(l));let y=s[m]||w;switch(typeof l){case"undefined":case"fun\
|
|
863
|
+
ction":continue;case"number":Number.isFinite(l)===!1&&(l=null);case"boolean":y&&(l=y(l));break;case"string":l=(y||es)(l);
|
|
864
|
+
break;default:l=(y||o)(l,i)}if(l===void 0)continue;let E=es(m);_+=","+E+":"+l}let f="";if(t!==void 0){l=u[p]?u[p](t):t;let m=s[p]||
|
|
865
|
+
w;switch(typeof l){case"function":break;case"number":Number.isFinite(l)===!1&&(l=null);case"boolean":m&&(l=m(l)),f=',"'+
|
|
866
|
+
p+'":'+l;break;case"string":l=(m||es)(l),f=',"'+p+'":'+l;break;default:l=(m||o)(l,i),f=',"'+p+'":'+l}}return this[vb]&&_?
|
|
867
|
+
h+this[Ob]+_.slice(1)+"}"+f+a:h+_+f+a}function xb(e,t){let r,n=e[sd],o=e[ud],i=e[rs],s=e[cd],a=s[ld],c=e[ad],u=e[dd].bindings;
|
|
868
|
+
t=u(t);for(let d in t)if(r=t[d],((d.length<5||d!=="level"&&d!=="serializers"&&d!=="formatters"&&d!=="customLevels")&&t.hasOwnProperty(
|
|
869
|
+
d)&&r!==void 0)===!0){if(r=c[d]?c[d](r):r,r=(s[d]||a||o)(r,i),r===void 0)continue;n+=',"'+d+'":'+r}return n}function kb(e){
|
|
870
|
+
return e.write!==e.constructor.prototype.write}function Pn(e){let t=new ts(e);return t.on("error",r),!e.sync&&Rb&&(td.register(
|
|
871
|
+
t,$b),t.on("close",function(){td.unregister(t)})),t;function r(n){if(n.code==="EPIPE"){t.write=xt,t.end=xt,t.flushSync=xt,
|
|
872
|
+
t.destroy=xt;return}t.removeListener("error",r),t.emit("error",n)}}function $b(e,t){e.destroyed||(t==="beforeExit"?(e.flush(),
|
|
873
|
+
e.on("drain",function(){e.end()})):e.flushSync())}function Lb(e){return function(r,n,o={},i){if(typeof o=="string")i=Pn(
|
|
874
|
+
{dest:o}),o={};else if(typeof i=="string"){if(o&&o.transport)throw Error("only one of option.transport or stream can be \
|
|
875
|
+
specified");i=Pn({dest:i})}else if(o instanceof ts||o.writable||o._writableState)i=o,o={};else if(o.transport){if(o.transport instanceof
|
|
876
|
+
ts||o.transport.writable||o.transport._writableState)throw Error("option.transport do not allow stream, please pass to o\
|
|
877
|
+
ption directly. e.g. pino(transport)");if(o.transport.targets&&o.transport.targets.length&&o.formatters&&typeof o.formatters.
|
|
878
|
+
level=="function")throw Error("option.transport.targets do not allow custom level formatters");let c;o.customLevels&&(c=
|
|
879
|
+
o.useOnlyCustomLevels?o.customLevels:Object.assign({},o.levels,o.customLevels)),i=Ab({caller:n,...o.transport,levels:c})}
|
|
880
|
+
if(o=Object.assign({},e,o),o.serializers=Object.assign({},e.serializers,o.serializers),o.formatters=Object.assign({},e.formatters,
|
|
881
|
+
o.formatters),o.prettyPrint)throw new Error("prettyPrint option is no longer supported, see the pino-pretty package (htt\
|
|
882
|
+
ps://github.com/pinojs/pino-pretty)");let{enabled:s,onChild:a}=o;return s===!1&&(o.level="silent"),a||(o.onChild=xt),i||
|
|
883
|
+
(kb(process.stdout)?i=process.stdout:i=Pn({fd:process.stdout.fd||1})),{opts:o,stream:i}}}function Mb(e,t){try{return JSON.
|
|
884
|
+
stringify(e)}catch{try{return(t||this[rs])(e)}catch{return'"[unable to serialize, circular reference is too complex to a\
|
|
885
|
+
nalyze]"'}}}function Db(e,t,r){return{level:e,bindings:t,log:r}}function Vb(e){let t=Number(e);return typeof e=="string"&&
|
|
886
|
+
Number.isFinite(t)?t:e===void 0?1:e}fd.exports={noop:xt,buildSafeSonicBoom:Pn,asChindings:xb,asJson:jb,genLog:Cb,createArgsNormalizer:Lb,
|
|
887
|
+
stringify:Mb,buildFormatters:Db,normalizeDestFileDescriptor:Vb}});var Nn=z((cj,pd)=>{var Ub={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},Bb={ASC:"ASC",DESC:"DESC"};pd.exports={DEFAULT_LEVELS:Ub,
|
|
888
|
+
SORTING_ORDER:Bb}});var is=z((uj,yd)=>{"use strict";var{lsCacheSym:zb,levelValSym:ns,useOnlyCustomLevelsSym:Gb,streamSym:Fb,formattersSym:Hb,
|
|
889
|
+
hooksSym:qb,levelCompSym:md}=Nt(),{noop:Wb,genLog:ot}=Cn(),{DEFAULT_LEVELS:Te,SORTING_ORDER:hd}=Nn(),gd={fatal:e=>{let t=ot(
|
|
890
|
+
Te.fatal,e);return function(...r){let n=this[Fb];if(t.call(this,...r),typeof n.flushSync=="function")try{n.flushSync()}catch{}}},
|
|
891
|
+
error:e=>ot(Te.error,e),warn:e=>ot(Te.warn,e),info:e=>ot(Te.info,e),debug:e=>ot(Te.debug,e),trace:e=>ot(Te.trace,e)},os=Object.
|
|
892
|
+
keys(Te).reduce((e,t)=>(e[Te[t]]=t,e),{}),Yb=Object.keys(os).reduce((e,t)=>(e[t]='{"level":'+Number(t),e),{});function Jb(e){
|
|
893
|
+
let t=e[Hb].level,{labels:r}=e.levels,n={};for(let o in r){let i=t(r[o],Number(o));n[o]=JSON.stringify(i).slice(0,-1)}return e[zb]=
|
|
894
|
+
n,e}function Kb(e,t){if(t)return!1;switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return!0;default:
|
|
895
|
+
return!1}}function Xb(e){let{labels:t,values:r}=this.levels;if(typeof e=="number"){if(t[e]===void 0)throw Error("unknown\
|
|
896
|
+
level value"+e);e=t[e]}if(r[e]===void 0)throw Error("unknown level "+e);let n=this[ns],o=this[ns]=r[e],i=this[Gb],s=this[md],
|
|
897
|
+
a=this[qb].logMethod;for(let c in r){if(s(r[c],o)===!1){this[c]=Wb;continue}this[c]=Kb(c,i)?gd[c](a):ot(r[c],a)}this.emit(
|
|
898
|
+
"level-change",e,o,t[n],n,this)}function Zb(e){let{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""}function Qb(e){
|
|
899
|
+
let{values:t}=this.levels,r=t[e];return r!==void 0&&this[md](r,this[ns])}function eE(e,t,r){return e===hd.DESC?t<=r:t>=r}
|
|
900
|
+
function tE(e){return typeof e=="string"?eE.bind(null,e):e}function rE(e=null,t=!1){let r=e?Object.keys(e).reduce((i,s)=>(i[e[s]]=
|
|
901
|
+
s,i),{}):null,n=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:os,r),o=Object.assign(Object.
|
|
902
|
+
create(Object.prototype,{silent:{value:1/0}}),t?null:Te,e);return{labels:n,values:o}}function nE(e,t,r){if(typeof e=="nu\
|
|
903
|
+
mber"){if(![].concat(Object.keys(t||{}).map(i=>t[i]),r?[]:Object.keys(os).map(i=>+i),1/0).includes(e))throw Error(`defau\
|
|
904
|
+
lt level:${e} must be included in custom levels`);return}let n=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),
|
|
905
|
+
r?null:Te,t);if(!(e in n))throw Error(`default level:${e} must be included in custom levels`)}function oE(e,t){let{labels:r,
|
|
906
|
+
values:n}=e;for(let o in t){if(o in n)throw Error("levels cannot be overridden");if(t[o]in r)throw Error("pre-existing l\
|
|
907
|
+
evel values cannot be used for new levels")}}function iE(e){if(typeof e!="function"&&!(typeof e=="string"&&Object.values(
|
|
908
|
+
hd).includes(e)))throw new Error('Levels comparison should be one of "ASC", "DESC" or "function" type')}yd.exports={initialLsCache:Yb,
|
|
909
|
+
genLsCache:Jb,levelMethods:gd,getLevel:Zb,setLevel:Xb,isLevelEnabled:Qb,mappings:rE,assertNoLevelCollisions:oE,assertDefaultLevelFound:nE,
|
|
910
|
+
genLevelComparison:tE,assertLevelComparison:iE}});var ss=z((lj,wd)=>{"use strict";wd.exports={version:"10.3.1"}});var Od=z((fj,Id)=>{"use strict";var{EventEmitter:sE}=X("node:events"),{lsCacheSym:aE,levelValSym:cE,setLevelSym:cs,getLevelSym:_d,
|
|
911
|
+
chindingsSym:xn,mixinSym:uE,asJsonSym:Ed,writeSym:lE,mixinMergeStrategySym:dE,timeSym:fE,timeSliceIndexSym:pE,streamSym:Sd,
|
|
912
|
+
serializersSym:it,formattersSym:pr,errorKeySym:mE,messageKeySym:hE,useOnlyCustomLevelsSym:gE,needsMetadataGsym:yE,redactFmtSym:wE,
|
|
913
|
+
stringifySym:_E,formatOptsSym:bE,stringifiersSym:EE,msgPrefixSym:us,hooksSym:SE}=Nt(),{getLevel:vE,setLevel:TE,isLevelEnabled:IE,
|
|
914
|
+
mappings:OE,initialLsCache:RE,genLsCache:AE,assertNoLevelCollisions:PE}=is(),{asChindings:ls,asJson:CE,buildFormatters:as,
|
|
915
|
+
stringify:bd,noop:vd}=Cn(),{version:NE}=ss(),jE=Vi(),xE=class{},Td={constructor:xE,child:kE,bindings:$E,setBindings:LE,flush:VE,
|
|
916
|
+
isLevelEnabled:IE,version:NE,get level(){return this[_d]()},set level(e){this[cs](e)},get levelVal(){return this[cE]},set levelVal(e){
|
|
917
|
+
throw Error("levelVal is read-only")},get msgPrefix(){return this[us]},get[Symbol.toStringTag](){return"Pino"},[aE]:RE,[lE]:DE,
|
|
918
|
+
[Ed]:CE,[_d]:vE,[cs]:TE};Object.setPrototypeOf(Td,sE.prototype);Id.exports=function(){return Object.create(Td)};var jn=e=>e;
|
|
919
|
+
function kE(e,t){if(!e)throw Error("missing bindings for child Pino");let r=this[it],n=this[pr],o=Object.create(this);if(t==
|
|
920
|
+
null)return o[pr].bindings!==jn&&(o[pr]=as(n.level,jn,n.log)),o[xn]=ls(o,e),this.onChild!==vd&&this.onChild(o),o;if(t.hasOwnProperty(
|
|
921
|
+
"serializers")===!0){o[it]=Object.create(null);for(let u in r)o[it][u]=r[u];let a=Object.getOwnPropertySymbols(r);for(var i=0;i<
|
|
922
|
+
a.length;i++){let u=a[i];o[it][u]=r[u]}for(let u in t.serializers)o[it][u]=t.serializers[u];let c=Object.getOwnPropertySymbols(
|
|
923
|
+
t.serializers);for(var s=0;s<c.length;s++){let u=c[s];o[it][u]=t.serializers[u]}}else o[it]=r;if(t.hasOwnProperty("forma\
|
|
924
|
+
tters")){let{level:a,bindings:c,log:u}=t.formatters;o[pr]=as(a||n.level,c||jn,u||n.log)}else o[pr]=as(n.level,jn,n.log);
|
|
925
|
+
if(t.hasOwnProperty("customLevels")===!0&&(PE(this.levels,t.customLevels),o.levels=OE(t.customLevels,o[gE]),AE(o)),typeof t.
|
|
926
|
+
redact=="object"&&t.redact!==null||Array.isArray(t.redact)){o.redact=t.redact;let a=jE(o.redact,bd),c={stringify:a[wE]};
|
|
927
|
+
o[_E]=bd,o[EE]=a,o[bE]=c}if(typeof t.msgPrefix=="string"&&(o[us]=(this[us]||"")+t.msgPrefix),o[xn]=ls(o,e),t.level!==void 0&&
|
|
928
|
+
t.level!==this.level||t.hasOwnProperty("customLevels")){let a=t.level||this.level;o[cs](a)}return this.onChild(o),o}function $E(){
|
|
929
|
+
let t=`{${this[xn].substr(1)}}`,r=JSON.parse(t);return delete r.pid,delete r.hostname,r}function LE(e){let t=ls(this,e);
|
|
930
|
+
this[xn]=t}function ME(e,t){return Object.assign(t,e)}function DE(e,t,r){let n=this[fE](),o=this[uE],i=this[mE],s=this[hE],
|
|
931
|
+
a=this[dE]||ME,c,u=this[SE].streamWrite;e==null?c={}:e instanceof Error?(c={[i]:e},t===void 0&&(t=e.message)):(c=e,t===void 0&&
|
|
932
|
+
e[s]===void 0&&e[i]&&(t=e[i].message)),o&&(c=a(c,o(c,r,this)));let d=this[Ed](c,t,r,n),p=this[Sd];p[yE]===!0&&(p.lastLevel=
|
|
933
|
+
r,p.lastObj=c,p.lastMsg=t,p.lastTime=n.slice(this[pE]),p.lastLogger=this),p.write(u?u(d):d)}function VE(e){if(e!=null&&typeof e!=
|
|
934
|
+
"function")throw Error("callback must be a function");let t=this[Sd];typeof t.flush=="function"?t.flush(e||vd):e&&e()}});var Cd=z((ms,Pd)=>{"use strict";var{hasOwnProperty:mr}=Object.prototype,at=ps();at.configure=ps;at.stringify=at;at.default=
|
|
935
|
+
at;ms.stringify=at;ms.configure=ps;Pd.exports=at;var UE=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function Be(e){return e.
|
|
936
|
+
length<5e3&&!UE.test(e)?`"${e}"`:JSON.stringify(e)}function ds(e,t){if(e.length>200||t)return e.sort(t);for(let r=1;r<e.
|
|
937
|
+
length;r++){let n=e[r],o=r;for(;o!==0&&e[o-1]>n;)e[o]=e[o-1],o--;e[o]=n}return e}var BE=Object.getOwnPropertyDescriptor(
|
|
938
|
+
Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function fs(e){return BE.call(e)!==void 0&&
|
|
939
|
+
e.length!==0}function Rd(e,t,r){e.length<r&&(r=e.length);let n=t===","?"":" ",o=`"0":${n}${e[0]}`;for(let i=1;i<r;i++)o+=
|
|
940
|
+
`${t}"${i}":${n}${e[i]}`;return o}function zE(e){if(mr.call(e,"circularValue")){let t=e.circularValue;if(typeof t=="stri\
|
|
941
|
+
ng")return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw new TypeError("Converting cir\
|
|
942
|
+
cular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null o\
|
|
943
|
+
r undefined')}return'"[Circular]"'}function GE(e){let t;if(mr.call(e,"deterministic")&&(t=e.deterministic,typeof t!="boo\
|
|
944
|
+
lean"&&typeof t!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator fun\
|
|
945
|
+
ction');return t===void 0?!0:t}function FE(e,t){let r;if(mr.call(e,t)&&(r=e[t],typeof r!="boolean"))throw new TypeError(
|
|
946
|
+
`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function Ad(e,t){let r;if(mr.call(e,t)){if(r=e[t],
|
|
947
|
+
typeof r!="number")throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw new TypeError(
|
|
948
|
+
`The "${t}" argument must be an integer`);if(r<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?
|
|
949
|
+
1/0:r}function st(e){return e===1?"1 item":`${e} items`}function HE(e){let t=new Set;for(let r of e)(typeof r=="string"||
|
|
950
|
+
typeof r=="number")&&t.add(String(r));return t}function qE(e){if(mr.call(e,"strict")){let t=e.strict;if(typeof t!="boole\
|
|
951
|
+
an")throw new TypeError('The "strict" argument must be of type boolean');if(t)return r=>{let n=`Object can not safely be\
|
|
952
|
+
stringified. Received type ${typeof r}`;throw typeof r!="function"&&(n+=` (${r.toString()})`),new Error(n)}}}function ps(e){
|
|
953
|
+
e={...e};let t=qE(e);t&&(e.bigint===void 0&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));let r=zE(e),n=FE(
|
|
954
|
+
e,"bigint"),o=GE(e),i=typeof o=="function"?o:void 0,s=Ad(e,"maximumDepth"),a=Ad(e,"maximumBreadth");function c(h,l,w,_,f,m){
|
|
955
|
+
let y=l[h];switch(typeof y=="object"&&y!==null&&typeof y.toJSON=="function"&&(y=y.toJSON(h)),y=_.call(l,h,y),typeof y){case"\
|
|
956
|
+
string":return Be(y);case"object":{if(y===null)return"null";if(w.indexOf(y)!==-1)return r;let E="",T=",",S=m;if(Array.isArray(
|
|
957
|
+
y)){if(y.length===0)return"[]";if(s<w.length+1)return'"[Array]"';w.push(y),f!==""&&(m+=f,E+=`
|
|
958
|
+
${m}`,T=`,
|
|
959
|
+
${m}`);let P=Math.min(y.length,a),C=0;for(;C<P-1;C++){let Y=c(String(C),y,w,_,f,m);E+=Y!==void 0?Y:"null",E+=T}let D=c(String(
|
|
960
|
+
C),y,w,_,f,m);if(E+=D!==void 0?D:"null",y.length-1>a){let Y=y.length-a-1;E+=`${T}"... ${st(Y)} not stringified"`}return f!==
|
|
961
|
+
""&&(E+=`
|
|
962
|
+
${S}`),w.pop(),`[${E}]`}let v=Object.keys(y),R=v.length;if(R===0)return"{}";if(s<w.length+1)return'"[Object]"';let O="",
|
|
963
|
+
A="";f!==""&&(m+=f,T=`,
|
|
964
|
+
${m}`,O=" ");let $=Math.min(R,a);o&&!fs(y)&&(v=ds(v,i)),w.push(y);for(let P=0;P<$;P++){let C=v[P],D=c(C,y,w,_,f,m);D!==void 0&&
|
|
965
|
+
(E+=`${A}${Be(C)}:${O}${D}`,A=T)}if(R>a){let P=R-a;E+=`${A}"...":${O}"${st(P)} not stringified"`,A=T}return f!==""&&A.length>
|
|
966
|
+
1&&(E=`
|
|
967
|
+
${m}${E}
|
|
968
|
+
${S}`),w.pop(),`{${E}}`}case"number":return isFinite(y)?String(y):t?t(y):"null";case"boolean":return y===!0?"true":"fals\
|
|
969
|
+
e";case"undefined":return;case"bigint":if(n)return String(y);default:return t?t(y):void 0}}function u(h,l,w,_,f,m){switch(typeof l==
|
|
970
|
+
"object"&&l!==null&&typeof l.toJSON=="function"&&(l=l.toJSON(h)),typeof l){case"string":return Be(l);case"object":{if(l===
|
|
971
|
+
null)return"null";if(w.indexOf(l)!==-1)return r;let y=m,E="",T=",";if(Array.isArray(l)){if(l.length===0)return"[]";if(s<
|
|
972
|
+
w.length+1)return'"[Array]"';w.push(l),f!==""&&(m+=f,E+=`
|
|
973
|
+
${m}`,T=`,
|
|
974
|
+
${m}`);let R=Math.min(l.length,a),O=0;for(;O<R-1;O++){let $=u(String(O),l[O],w,_,f,m);E+=$!==void 0?$:"null",E+=T}let A=u(
|
|
975
|
+
String(O),l[O],w,_,f,m);if(E+=A!==void 0?A:"null",l.length-1>a){let $=l.length-a-1;E+=`${T}"... ${st($)} not stringified\
|
|
976
|
+
"`}return f!==""&&(E+=`
|
|
977
|
+
${y}`),w.pop(),`[${E}]`}w.push(l);let S="";f!==""&&(m+=f,T=`,
|
|
978
|
+
${m}`,S=" ");let v="";for(let R of _){let O=u(R,l[R],w,_,f,m);O!==void 0&&(E+=`${v}${Be(R)}:${S}${O}`,v=T)}return f!==""&&
|
|
979
|
+
v.length>1&&(E=`
|
|
980
|
+
${m}${E}
|
|
981
|
+
${y}`),w.pop(),`{${E}}`}case"number":return isFinite(l)?String(l):t?t(l):"null";case"boolean":return l===!0?"true":"fals\
|
|
982
|
+
e";case"undefined":return;case"bigint":if(n)return String(l);default:return t?t(l):void 0}}function d(h,l,w,_,f){switch(typeof l){case"\
|
|
983
|
+
string":return Be(l);case"object":{if(l===null)return"null";if(typeof l.toJSON=="function"){if(l=l.toJSON(h),typeof l!="\
|
|
984
|
+
object")return d(h,l,w,_,f);if(l===null)return"null"}if(w.indexOf(l)!==-1)return r;let m=f;if(Array.isArray(l)){if(l.length===
|
|
985
|
+
0)return"[]";if(s<w.length+1)return'"[Array]"';w.push(l),f+=_;let O=`
|
|
986
|
+
${f}`,A=`,
|
|
987
|
+
${f}`,$=Math.min(l.length,a),P=0;for(;P<$-1;P++){let D=d(String(P),l[P],w,_,f);O+=D!==void 0?D:"null",O+=A}let C=d(String(
|
|
988
|
+
P),l[P],w,_,f);if(O+=C!==void 0?C:"null",l.length-1>a){let D=l.length-a-1;O+=`${A}"... ${st(D)} not stringified"`}return O+=
|
|
989
|
+
`
|
|
990
|
+
${m}`,w.pop(),`[${O}]`}let y=Object.keys(l),E=y.length;if(E===0)return"{}";if(s<w.length+1)return'"[Object]"';f+=_;let T=`\
|
|
991
|
+
,
|
|
992
|
+
${f}`,S="",v="",R=Math.min(E,a);fs(l)&&(S+=Rd(l,T,a),y=y.slice(l.length),R-=l.length,v=T),o&&(y=ds(y,i)),w.push(l);for(let O=0;O<
|
|
993
|
+
R;O++){let A=y[O],$=d(A,l[A],w,_,f);$!==void 0&&(S+=`${v}${Be(A)}: ${$}`,v=T)}if(E>a){let O=E-a;S+=`${v}"...": "${st(O)}\
|
|
994
|
+
not stringified"`,v=T}return v!==""&&(S=`
|
|
995
|
+
${f}${S}
|
|
996
|
+
${m}`),w.pop(),`{${S}}`}case"number":return isFinite(l)?String(l):t?t(l):"null";case"boolean":return l===!0?"true":"fals\
|
|
997
|
+
e";case"undefined":return;case"bigint":if(n)return String(l);default:return t?t(l):void 0}}function p(h,l,w){switch(typeof l){case"\
|
|
998
|
+
string":return Be(l);case"object":{if(l===null)return"null";if(typeof l.toJSON=="function"){if(l=l.toJSON(h),typeof l!="\
|
|
999
|
+
object")return p(h,l,w);if(l===null)return"null"}if(w.indexOf(l)!==-1)return r;let _="",f=l.length!==void 0;if(f&&Array.
|
|
1000
|
+
isArray(l)){if(l.length===0)return"[]";if(s<w.length+1)return'"[Array]"';w.push(l);let S=Math.min(l.length,a),v=0;for(;v<
|
|
1001
|
+
S-1;v++){let O=p(String(v),l[v],w);_+=O!==void 0?O:"null",_+=","}let R=p(String(v),l[v],w);if(_+=R!==void 0?R:"null",l.length-
|
|
1002
|
+
1>a){let O=l.length-a-1;_+=`,"... ${st(O)} not stringified"`}return w.pop(),`[${_}]`}let m=Object.keys(l),y=m.length;if(y===
|
|
1003
|
+
0)return"{}";if(s<w.length+1)return'"[Object]"';let E="",T=Math.min(y,a);f&&fs(l)&&(_+=Rd(l,",",a),m=m.slice(l.length),T-=
|
|
1004
|
+
l.length,E=","),o&&(m=ds(m,i)),w.push(l);for(let S=0;S<T;S++){let v=m[S],R=p(v,l[v],w);R!==void 0&&(_+=`${E}${Be(v)}:${R}`,
|
|
1005
|
+
E=",")}if(y>a){let S=y-a;_+=`${E}"...":"${st(S)} not stringified"`}return w.pop(),`{${_}}`}case"number":return isFinite(
|
|
1006
|
+
l)?String(l):t?t(l):"null";case"boolean":return l===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(
|
|
1007
|
+
l);default:return t?t(l):void 0}}function g(h,l,w){if(arguments.length>1){let _="";if(typeof w=="number"?_=" ".repeat(Math.
|
|
1008
|
+
min(w,10)):typeof w=="string"&&(_=w.slice(0,10)),l!=null){if(typeof l=="function")return c("",{"":h},[],l,_,"");if(Array.
|
|
1009
|
+
isArray(l))return u("",h,[],HE(l),_,"")}if(_.length!==0)return d("",h,[],_,"")}return p("",h,[])}return g}});var kd=z((pj,xd)=>{"use strict";var hs=Symbol.for("pino.metadata"),{DEFAULT_LEVELS:jd}=Nn(),WE=jd.info;function YE(e,t){
|
|
1010
|
+
e=e||[],t=t||{dedupe:!1};let r=Object.create(jd);r.silent=1/0,t.levels&&typeof t.levels=="object"&&Object.keys(t.levels).
|
|
1011
|
+
forEach(p=>{r[p]=t.levels[p]});let n={write:o,add:a,remove:c,emit:i,flushSync:s,end:u,minLevel:0,lastId:0,streams:[],clone:d,
|
|
1012
|
+
[hs]:!0,streamLevels:r};return Array.isArray(e)?e.forEach(a,n):a.call(n,e),e=null,n;function o(p){let g,h=this.lastLevel,
|
|
1013
|
+
{streams:l}=this,w=0,_;for(let f=JE(l.length,t.dedupe);XE(f,l.length,t.dedupe);f=KE(f,t.dedupe))if(g=l[f],g.level<=h){if(w!==
|
|
1014
|
+
0&&w!==g.level)break;if(_=g.stream,_[hs]){let{lastTime:m,lastMsg:y,lastObj:E,lastLogger:T}=this;_.lastLevel=h,_.lastTime=
|
|
1015
|
+
m,_.lastMsg=y,_.lastObj=E,_.lastLogger=T}_.write(p),t.dedupe&&(w=g.level)}else if(!t.dedupe)break}function i(...p){for(let{
|
|
1016
|
+
stream:g}of this.streams)typeof g.emit=="function"&&g.emit(...p)}function s(){for(let{stream:p}of this.streams)typeof p.
|
|
1017
|
+
flushSync=="function"&&p.flushSync()}function a(p){if(!p)return n;let g=typeof p.write=="function"||p.stream,h=p.write?p:
|
|
1018
|
+
p.stream;if(!g)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");let{streams:l,
|
|
1019
|
+
streamLevels:w}=this,_;typeof p.levelVal=="number"?_=p.levelVal:typeof p.level=="string"?_=w[p.level]:typeof p.level=="n\
|
|
1020
|
+
umber"?_=p.level:_=WE;let f={stream:h,level:_,levelVal:void 0,id:++n.lastId};return l.unshift(f),l.sort(Nd),this.minLevel=
|
|
1021
|
+
l[0].level,n}function c(p){let{streams:g}=this,h=g.findIndex(l=>l.id===p);return h>=0&&(g.splice(h,1),g.sort(Nd),this.minLevel=
|
|
1022
|
+
g.length>0?g[0].level:-1),n}function u(){for(let{stream:p}of this.streams)typeof p.flushSync=="function"&&p.flushSync(),
|
|
1023
|
+
p.end()}function d(p){let g=new Array(this.streams.length);for(let h=0;h<g.length;h++)g[h]={level:p,stream:this.streams[h].
|
|
1024
|
+
stream};return{write:o,add:a,remove:c,minLevel:p,streams:g,clone:d,emit:i,flushSync:s,[hs]:!0}}}function Nd(e,t){return e.
|
|
1025
|
+
level-t.level}function JE(e,t){return t?e-1:0}function KE(e,t){return t?e-1:e+1}function XE(e,t,r){return r?e>=0:e<t}xd.
|
|
1026
|
+
exports=YE});var Yd=z((mj,ge)=>{"use strict";var ZE=X("node:os"),zd=$i(),QE=Li(),eS=Vi(),Gd=wl(),tS=Od(),Fd=Nt(),{configure:rS}=Cd(),
|
|
1027
|
+
{assertDefaultLevelFound:nS,mappings:Hd,genLsCache:oS,genLevelComparison:iS,assertLevelComparison:sS}=is(),{DEFAULT_LEVELS:qd,
|
|
1028
|
+
SORTING_ORDER:aS}=Nn(),{createArgsNormalizer:cS,asChindings:uS,buildSafeSonicBoom:$d,buildFormatters:lS,stringify:gs,normalizeDestFileDescriptor:Ld,
|
|
1029
|
+
noop:dS}=Cn(),{version:fS}=ss(),{chindingsSym:Md,redactFmtSym:pS,serializersSym:Dd,timeSym:mS,timeSliceIndexSym:hS,streamSym:gS,
|
|
1030
|
+
stringifySym:Vd,stringifySafeSym:ys,stringifiersSym:Ud,setLevelSym:yS,endSym:wS,formatOptsSym:_S,messageKeySym:bS,errorKeySym:ES,
|
|
1031
|
+
nestedKeySym:SS,mixinSym:vS,levelCompSym:TS,useOnlyCustomLevelsSym:IS,formattersSym:Bd,hooksSym:OS,nestedKeyStrSym:RS,mixinMergeStrategySym:AS,
|
|
1032
|
+
msgPrefixSym:PS}=Fd,{epochTime:Wd,nullTime:CS}=Gd,{pid:NS}=process,jS=ZE.hostname(),xS=zd.err,kS={level:"info",levelComparison:aS.
|
|
1033
|
+
ASC,levels:qd,messageKey:"msg",errorKey:"err",nestedKey:null,enabled:!0,base:{pid:NS,hostname:jS},serializers:Object.assign(
|
|
1034
|
+
Object.create(null),{err:xS}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),
|
|
1035
|
+
hooks:{logMethod:void 0,streamWrite:void 0},timestamp:Wd,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,
|
|
1036
|
+
depthLimit:5,edgeLimit:100},$S=cS(kS),LS=Object.assign(Object.create(null),zd);function ws(...e){let t={},{opts:r,stream:n}=$S(
|
|
1037
|
+
t,QE(),...e);r.level&&typeof r.level=="string"&&qd[r.level.toLowerCase()]!==void 0&&(r.level=r.level.toLowerCase());let{
|
|
1038
|
+
redact:o,crlf:i,serializers:s,timestamp:a,messageKey:c,errorKey:u,nestedKey:d,base:p,name:g,level:h,customLevels:l,levelComparison:w,
|
|
1039
|
+
mixin:_,mixinMergeStrategy:f,useOnlyCustomLevels:m,formatters:y,hooks:E,depthLimit:T,edgeLimit:S,onChild:v,msgPrefix:R}=r,
|
|
1040
|
+
O=rS({maximumDepth:T,maximumBreadth:S}),A=lS(y.level,y.bindings,y.log),$=gs.bind({[ys]:O}),P=o?eS(o,$):{},C=o?{stringify:P[pS]}:
|
|
1041
|
+
{stringify:$},D="}"+(i?`\r
|
|
1042
|
+
`:`
|
|
1043
|
+
`),Y=uS.bind(null,{[Md]:"",[Dd]:s,[Ud]:P,[Vd]:gs,[ys]:O,[Bd]:A}),ae="";p!==null&&(g===void 0?ae=Y(p):ae=Y(Object.assign(
|
|
1044
|
+
{},p,{name:g})));let Qe=a instanceof Function?a:a?Wd:CS,ce=Qe().indexOf(":")+1;if(m&&!l)throw Error("customLevels is req\
|
|
1045
|
+
uired if useOnlyCustomLevels is set true");if(_&&typeof _!="function")throw Error(`Unknown mixin type "${typeof _}" - ex\
|
|
1046
|
+
pected "function"`);if(R&&typeof R!="string")throw Error(`Unknown msgPrefix type "${typeof R}" - expected "string"`);nS(
|
|
1047
|
+
h,l,m);let me=Hd(l,m);typeof n.emit=="function"&&n.emit("message",{code:"PINO_CONFIG",config:{levels:me,messageKey:c,errorKey:u}}),
|
|
1048
|
+
sS(w);let Uo=iS(w);return Object.assign(t,{levels:me,[TS]:Uo,[IS]:m,[gS]:n,[mS]:Qe,[hS]:ce,[Vd]:gs,[ys]:O,[Ud]:P,[wS]:D,
|
|
1049
|
+
[_S]:C,[bS]:c,[ES]:u,[SS]:d,[RS]:d?`,${JSON.stringify(d)}:{`:"",[Dd]:s,[vS]:_,[AS]:f,[Md]:ae,[Bd]:A,[OS]:E,silent:dS,onChild:v,
|
|
1050
|
+
[PS]:R}),Object.setPrototypeOf(t,tS()),oS(t),t[yS](h),t}ge.exports=ws;ge.exports.destination=(e=process.stdout.fd)=>typeof e==
|
|
1051
|
+
"object"?(e.dest=Ld(e.dest||process.stdout.fd),$d(e)):$d({dest:Ld(e),minLength:0});ge.exports.transport=Qi();ge.exports.
|
|
1052
|
+
multistream=kd();ge.exports.levels=Hd();ge.exports.stdSerializers=LS;ge.exports.stdTimeFunctions=Object.assign({},Gd);ge.
|
|
1053
|
+
exports.symbols=Fd;ge.exports.version=fS;ge.exports.default=ws;ge.exports.pino=ws});function Kd(e="",t=kn){let r=String(e||"").trim().toLowerCase();return MS.includes(r)?r:t}function DS(e="info",t=kn){let r=Kd(
|
|
1054
|
+
e,""),n=Kd(t,kn);return!r||n==="silent"?!1:Jd[r]>=Jd[n]}var kn,MS,Jd,hj,Xd=b(()=>{kn="warn",MS=Object.freeze(["fatal","e\
|
|
1055
|
+
rror","warn","info","debug","trace","silent"]),Jd=Object.freeze({trace:10,debug:20,info:30,warn:40,error:50,fatal:60,silent:1/0});
|
|
1056
|
+
hj=Object.freeze({isVibe64LogLevelEnabled:DS})});function Zd(e="",t="vibe64.operational_event"){return String(e||"").trim().replace(/[^a-zA-Z0-9_.:-]+/gu,"_").replace(/^_+|_+$/gu,
|
|
1057
|
+
"")||t}function HS(e=""){return US.test(String(e||""))}function $n(e=""){return String(e||"").replace(zS,`$1$2${hr}`).replace(
|
|
1058
|
+
GS,`$1 ${hr}`).replace(BS,`$1$2${hr}`).replace(FS,`$1${hr}@`)}function gr(e,t={}){let{field:r="",seen:n=new WeakSet}=t;return HS(
|
|
1059
|
+
r)?hr:typeof e=="string"?$n(e):!e||typeof e!="object"?e:n.has(e)?"[circular]":(n.add(e),e instanceof Error?{code:String(
|
|
1060
|
+
e.code||""),message:$n(e.message),name:String(e.name||"Error"),...Array.isArray(e.errors)?{errors:e.errors.map(o=>gr(o,{
|
|
1061
|
+
seen:n}))}:{},...e.cause!==void 0?{cause:gr(e.cause,{seen:n})}:{}}:Array.isArray(e)?e.map(o=>gr(o,{seen:n})):Object.fromEntries(
|
|
1062
|
+
Object.entries(e).map(([o,i])=>[o,gr(i,{field:o,seen:n})])))}function qS(e={}){let t=e&&typeof e=="object"&&!Array.isArray(
|
|
1063
|
+
e)?e:{};return gr({...t,component:Zd(t.component,"vibe64"),event:Zd(t.event,"vibe64.operational_event")})}var VS,_j,hr,US,
|
|
1064
|
+
BS,zS,GS,FS,bj,Qd=b(()=>{VS=pg(Yd(),1);Xd();_j=Object.freeze(["req.headers.authorization","req.headers.cookie","req.head\
|
|
1065
|
+
ers['set-cookie']","res.headers['set-cookie']","*.authorization","*.cookie","*.credential","*.credentials","*.databaseUr\
|
|
1066
|
+
l","*.database_url","*.dsn","*.password","*.secret","*.token","*.apiToken","*.api_token","*.apiKey","*.api_key","*.acces\
|
|
1067
|
+
sToken","*.access_token","*.refreshToken","*.refresh_token"]),hr="[redacted]",US=/(?:authorization|password|passphrase|token|secret|credential|api[_-]?key|api[_-]?token|access[_-]?token|refresh[_-]?token|database[_-]?url|dsn)/iu,
|
|
1068
|
+
BS=/\b((?:DATABASE[_-]?URL|DSN)|(?:[A-Za-z_][A-Za-z0-9_-]*?)?(?:PASSWORD|PASS|PASSPHRASE|TOKEN|SECRET|CREDENTIAL|API[_-]?KEY|API[_-]?TOKEN|ACCESS[_-]?TOKEN|REFRESH[_-]?TOKEN|DSN)[A-Za-z0-9_-]*)\b(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu,
|
|
1069
|
+
zS=/\b(authorization|proxy-authorization)\b(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|(?:Bearer|Basic)\s+[^\s,;]+|[^\s,;]+)/giu,GS=/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/giu,
|
|
1070
|
+
FS=/\b([a-z][a-z0-9+.-]*:\/\/)([^/@\s:]+):([^/@\s]+)@/giu;bj=Object.freeze({operationalLogFields:qS})});import{AsyncLocalStorage as WS}from"node:async_hooks";function tf(){let e=ef.getStore()||null;if(e?.[_s]&&!e[_s].active())
|
|
1071
|
+
throw Object.assign(new Error("Practice access ended with its owning callback. Read the saved lesson again."),{code:"vib\
|
|
1072
|
+
e64_practice_scope_expired"});return e}var ef,_s,kt=b(()=>{Ve();ef=new WS,_s=Symbol("Vibe64 server practice scope")});import Ln from"node:path";import bs from"node:process";import YS from"node:os";function rf(e,t){let r=String(e||"").trim();
|
|
1073
|
+
return Ln.resolve(r||t||bs.cwd())}function nf({env:e,home:t=YS.homedir(),platform:r=bs.platform}){let n=t||bs.cwd();if(r===
|
|
1074
|
+
"darwin")return rf(Ln.join(n,"Library","Application Support","Vibe64"));let o=String(e.XDG_STATE_HOME||"").trim();return rf(
|
|
1075
|
+
Ln.join(o||Ln.join(n,".local","state"),"vibe64"))}var Es,Mn=b(()=>{Es="VIBE64_SYSTEM_ROOT"});var of,$t=b(()=>{le();Ve();of="vibe64_practice_project_deleted"});import{randomUUID as JS}from"node:crypto";import{chmod as KS,mkdir as XS,rename as ZS,rm as QS,writeFile as ev}from"node:fs/promises";
|
|
1076
|
+
import Ss from"node:path";async function sf(e,t,r={}){let{directoryMode:n,fileMode:o}=r,i=Ss.dirname(e);await XS(i,{recursive:!0,
|
|
1077
|
+
mode:n});let s=Ss.join(i,`.${Ss.basename(e)}.${process.pid}.${JS()}.tmp`);try{await ev(s,t,{encoding:"utf8",flag:"wx",mode:o}),
|
|
1078
|
+
o!==void 0&&await KS(s,o),await ZS(s,e)}finally{await QS(s,{force:!0})}}async function Dn(e,t,r={}){await sf(e,`${JSON.stringify(
|
|
1079
|
+
t,null,2)}
|
|
1080
|
+
`,r)}var yr=b(()=>{});var Vn=b(()=>{yr();le();U()});function Ie(){return globalThis[tv]||rv}var tv,rv,ke=b(()=>{tv=Symbol.for("vibe64.hostProfile"),rv=Object.freeze({runtimePackRoot:"",
|
|
1081
|
+
sharedCacheRoot:"",execHelperPath:"",sharedGroupAccess:!1})});var Xj,Un=b(()=>{yr();le();Ue();ke();U();Xj=Object.freeze(["repository","branch","path","baseCommit","canonicalCommit"])});import{execFile as ov}from"node:child_process";import{readFile as iv}from"node:fs/promises";import vs from"node:os";import sv from"node:path";
|
|
1082
|
+
import{promisify as av}from"node:util";function cf(e=""){let t=F(e);if(!t||t.includes("/")||t.includes("\\")||t.includes(
|
|
1083
|
+
":")){let r=new Error("A valid OS username is required.");throw r.code="vibe64_invalid_os_username",r}return t}function uf([
|
|
827
1084
|
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
1085
|
s)||!Number.isSafeInteger(a)?null:{displayName:String(n||"").split(",")[0],gid:a,home:String(o||""),shell:String(i||""),
|
|
829
|
-
uid:s,username:String(e||"")}}function
|
|
830
|
-
t[3],t[4],t[5],t[6]])}function
|
|
831
|
-
split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);o&&(r[o[1]]=o[2].trim())}return
|
|
832
|
-
dir,r.shell])}).filter(Boolean)}async function
|
|
833
|
-
string"?n:n?.stdout)||"")}function
|
|
834
|
-
env.USER||process.env.LOGNAME),o=
|
|
1086
|
+
uid:s,username:String(e||"")}}function Ts(e=""){let t=String(e||"").trim().split(":");return t.length<7?null:uf([t[0],t[2],
|
|
1087
|
+
t[3],t[4],t[5],t[6]])}function uv(e=""){return String(e||"").split(/\r?\n[\t ]*\r?\n/u).map(t=>{let r={};for(let n of t.
|
|
1088
|
+
split(/\r?\n/u)){let o=/^\s*([a-z]+):\s?(.*)$/u.exec(n);o&&(r[o[1]]=o[2].trim())}return uf([r.name,r.uid,r.gid,r.gecos,r.
|
|
1089
|
+
dir,r.shell])}).filter(Boolean)}async function af(e,t,r){let n=await e(t,r,{encoding:"utf8"});return String((typeof n=="\
|
|
1090
|
+
string"?n:n?.stdout)||"")}function wr({homedir:e=vs.homedir,userInfo:t=vs.userInfo}={}){let r=t(),n=F(r?.username||process.
|
|
1091
|
+
env.USER||process.env.LOGNAME),o=sv.resolve(String(r?.homedir||e()||""));return{displayName:String(r?.username||n),gid:Number.
|
|
835
1092
|
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
|
|
1093
|
+
async function Bn(e="",{execFileFn:t=cv,platform:r=process.platform,readFileFn:n=iv,userInfo:o=vs.userInfo}={}){let i=cf(
|
|
837
1094
|
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(
|
|
840
|
-
n"){let a=
|
|
841
|
-
s=
|
|
842
|
-
nd: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var
|
|
843
|
-
isSafeInteger(t)&&t>=0?t:null}function
|
|
844
|
-
t);if(!r||!n)return!1;let o=
|
|
845
|
-
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function
|
|
846
|
-
([t,r])=>[
|
|
847
|
-
[e]){let o=
|
|
848
|
-
isFinite(t)?t:0}function
|
|
849
|
-
return{displayName:
|
|
850
|
-
|
|
851
|
-
username,USER:r.username,XDG_CACHE_HOME:
|
|
852
|
-
join(r.home,".local","share")}}function
|
|
853
|
-
getuid=="function"?process.getuid():null}}var
|
|
854
|
-
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:
|
|
855
|
-
let h=
|
|
856
|
-
`)).trim();return{code:
|
|
857
|
-
Number(s):null,signal:
|
|
858
|
-
ct"&&!Array.isArray(
|
|
859
|
-
|
|
860
|
-
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}var
|
|
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
|
|
1095
|
+
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 p=(await n(
|
|
1096
|
+
"/etc/passwd","utf8").catch(()=>"")).split(/\r?\n/u).map(Ts).find(g=>g?.username===i);if(p)return p}}let s;if(r==="darwi\
|
|
1097
|
+
n"){let a=wr({userInfo:o});if(a.username===i)return a;[s]=uv(await af(t,"dscacheutil",["-q","user","-a","name",i]))}else
|
|
1098
|
+
s=Ts((await af(t,"getent",["passwd",i])).split(/\r?\n/u)[0]);if(!s||s.username!==i){let a=new Error(`OS user was not fou\
|
|
1099
|
+
nd: ${i}`);throw a.code="vibe64_os_user_not_found",a}return s}var cv,ix,zn=b(()=>{U();cv=av(ov);ix=Object.freeze({parsePasswdLine:Ts})});var lf=b(()=>{zn();U()});import Gn from"node:path";function j(e=""){return String(e??"").trim()}function Is(e=null){let t=Number(e);return Number.
|
|
1100
|
+
isSafeInteger(t)&&t>=0?t:null}function x(e=""){let t=j(e);return t?Gn.resolve(t):""}function ze(e="",t=""){let r=x(e),n=x(
|
|
1101
|
+
t);if(!r||!n)return!1;let o=Gn.relative(r,n);return o!==".."&&!o.startsWith(`..${Gn.sep}`)&&!Gn.isAbsolute(o)}function ee(e={}){
|
|
1102
|
+
return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ye(e={}){return Object.fromEntries(Object.entries(ee(e)).map(
|
|
1103
|
+
([t,r])=>[j(t),String(r??"")]).filter(([t])=>!!t))}function ct(e=[]){let t=[],r=new Set;for(let n of Array.isArray(e)?e:
|
|
1104
|
+
[e]){let o=j(n);!o||r.has(o)||(r.add(o),t.push(o))}return t}function Lt(e){let t=Date.parse(String(e||"").trim());return Number.
|
|
1105
|
+
isFinite(t)?t:0}function $e(...e){for(let t of e){let r=j(t);if(r)return r}return""}var K=b(()=>{});import lv from"node:os";import Os from"node:path";function Rs(e={}){let t=j(e.username),r=x(e.home||(t?`/home/${t}`:lv.homedir()));
|
|
1106
|
+
return{displayName:j(e.displayName||t),gid:Is(e.gid),home:r,shell:j(e.shell),uid:Is(e.uid),username:t}}function As(){return Rs(
|
|
1107
|
+
wr())}async function Ps(e="",t={}){return Rs(await Bn(e,t))}function _r(e={},t={}){let r=Rs(e);return{...t,HOME:r.home,LOGNAME:r.
|
|
1108
|
+
username,USER:r.username,XDG_CACHE_HOME:Os.join(r.home,".cache"),XDG_CONFIG_HOME:Os.join(r.home,".config"),XDG_DATA_HOME:Os.
|
|
1109
|
+
join(r.home,".local","share")}}function df(){return{gid:typeof process.getgid=="function"?process.getgid():null,uid:typeof process.
|
|
1110
|
+
getuid=="function"?process.getuid():null}}var Mt=b(()=>{zn();K()});function dv(e=0){let t=Number(e);return Number.isSafeInteger(t)?t:1}function br({code:e="",error:t="",exitCode:r=0,ok:n=null,
|
|
1111
|
+
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:u="",timedOut:d=!1,execution:p=null,retryable:g=null}={}){
|
|
1112
|
+
let h=dv(r),l=String(u||""),w=String(c||""),_=String(o||[l,w].filter(Boolean).join(`
|
|
1113
|
+
`)).trim();return{code:j(e),error:j(t),exitCode:h,ok:n===null?h===0:n===!0,output:_,pid:Number.isSafeInteger(Number(s))?
|
|
1114
|
+
Number(s):null,signal:j(a),stderr:w,stdout:l,...i==="base64"?{outputEncoding:i}:{},timedOut:d===!0,...p&&typeof p=="obje\
|
|
1115
|
+
ct"&&!Array.isArray(p)?{execution:p}:{},...typeof g=="boolean"?{retryable:g}:{}}}function te(e="",t="vibe64_command_fail\
|
|
1116
|
+
ed",r={}){let n=j(e)||"Vibe64 command failed.";return br({...r,code:t,error:n,exitCode:1,ok:!1,output:j(r.output)||n,stderr:r.
|
|
1117
|
+
stderr??(r.outputEncoding==="base64"?Buffer.from(n).toString("base64"):n),stdout:r.stdout??""})}var ut=b(()=>{K()});import{spawn as fv}from"node:child_process";import{statSync as pv}from"node:fs";import mv from"node:path";import{StringDecoder as hv}from"node:string_decoder";
|
|
1118
|
+
import{stripVTControlCharacters as gv}from"node:util";function hf(e){return e.replaceAll(_v,t=>{if(pf[t]!==void 0)return pf[t];
|
|
1119
|
+
let r=t.codePointAt(0);return r<=65535?`\\u${r.toString(16).padStart(4,"0")}`:`\\U${r.toString(16)}`})}function bv(e){return gv(
|
|
863
1120
|
e).split(`
|
|
864
|
-
`).map(
|
|
865
|
-
`)}function
|
|
866
|
-
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function
|
|
867
|
-
return r;try{if(!
|
|
1121
|
+
`).map(hf).join(`
|
|
1122
|
+
`)}function Ev(e,t){return[e,...t].map(r=>{let n=hf(String(r));return wv.test(n)?n:process.platform==="win32"?`"${n.replaceAll(
|
|
1123
|
+
'"','""')}"`:`'${n.replaceAll("'","'\\''")}'`}).join(" ")}function Sv(e,t){let r=String(e?.message??e);if(t===process.cwd())
|
|
1124
|
+
return r;try{if(!pv(t).isDirectory())return`The "cwd" option is not a directory: ${t}.
|
|
868
1125
|
${r}`}catch(n){return`The "cwd" option is invalid: ${t}.
|
|
869
1126
|
${n.message}
|
|
870
|
-
${r}`}return r}function
|
|
1127
|
+
${r}`}return r}function vv(e){let t=e.forcefullyTerminated?` and was forcefully terminated after ${mf} milliseconds`:"";
|
|
871
1128
|
if(e.timedOut)return`Command timed out after ${e.timeout} milliseconds${t}`;if(e.maxBuffer)return`Command's ${e.maxBuffer.
|
|
872
1129
|
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
|
|
1130
|
+
ed with ${e.spawnError.code}${t}`;if(e.signal){let r=yv[e.signal];return`Command was killed with ${e.signal}${r?` (${r})`:
|
|
1131
|
+
""}`}return e.exitCode!==void 0?`Command failed with exit code ${e.exitCode}`:"Command failed"}function Tv(e){let t=e.spawnError?
|
|
1132
|
+
bv(Sv(e.spawnError,e.cwd)):e.maxBuffer?"maxBuffer exceeded":"";return`${vv(e)}: ${e.commandLine}${t?`
|
|
1133
|
+
${t}`:""}`}function Cs(e,t){let r=new hv(e),n=[],o=0,i=!1;return{write(s){if(i)return!1;let a=r.write(s);return o+a.length>
|
|
877
1134
|
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
|
-
i=!0}return n.join("")}}}function
|
|
879
|
-
utf8",timeout:c=0}={}){let
|
|
880
|
-
|
|
881
|
-
h={commandLine:
|
|
882
|
-
|
|
883
|
-
()=>{!
|
|
884
|
-
{limit:
|
|
885
|
-
on("data",
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
shortMessage:
|
|
890
|
-
once("close",
|
|
1135
|
+
i=!0}return n.join("")}}}function gf(e,t,{cwd:r="",env:n={},input:o=void 0,maxBuffer:i=ff,onOutput:s=null,outputEncoding:a="\
|
|
1136
|
+
utf8",timeout:c=0}={}){let u=Number.isSafeInteger(i)&&i>0?i:ff,d={all:Cs(a,u*2),stderr:Cs(a,u),stdout:Cs(a,u)},p=o!=null,
|
|
1137
|
+
g=fv(e,t,{cwd:r||void 0,detached:process.platform!=="win32",env:n,stdio:[p?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),
|
|
1138
|
+
h={commandLine:Ev(e,t),cwd:mv.resolve(r||"."),forcefullyTerminated:!1,maxBuffer:null,spawnError:null,timedOut:!1,timeout:c},
|
|
1139
|
+
l=!1,w=null,_=()=>{};g.on("error",T=>{h.spawnError||=T,g.pid===void 0&&_()});let f=()=>{l||!g.kill("SIGTERM")||w||(w=setTimeout(
|
|
1140
|
+
()=>{!l&&g.kill("SIGKILL")&&(h.forcefullyTerminated=!0)},mf))},m=(T,S)=>v=>{if(d.all.write(v),d[T].write(v)||(h.maxBuffer||=
|
|
1141
|
+
{limit:u,stream:T,unit:"characters"},S.destroy()),typeof s=="function")try{s(String(v||""))}catch{}};g.stdout&&g.stdout.
|
|
1142
|
+
on("data",m("stdout",g.stdout)),g.stderr&&g.stderr.on("data",m("stderr",g.stderr)),p&&g.stdin&&(g.stdin.on("error",()=>{}),
|
|
1143
|
+
g.stdin.end(o));let y=c>0?setTimeout(()=>{h.timedOut=!0,f()},c):null;return{completion:new Promise(T=>{_=(S,v)=>{if(l)return;
|
|
1144
|
+
l=!0,clearTimeout(y),clearTimeout(w);let R=h.spawnError?{}:{exitCode:typeof S=="number"&&S>=0?S:void 0,signal:v||void 0},
|
|
1145
|
+
O=h.spawnError||h.timedOut||h.maxBuffer||R.exitCode!==0;T({all:d.all.text(),code:h.spawnError?.code,exitCode:R.exitCode,
|
|
1146
|
+
shortMessage:O?Tv({...h,...R}):"",signal:R.signal,stderr:d.stderr.text(),stdout:d.stdout.text(),timedOut:h.timedOut})},g.
|
|
1147
|
+
once("close",_)}),kill:T=>g.kill(T),pid:g.pid}}var ff,mf,yv,wv,_v,pf,yf=b(()=>{ff=1e8,mf=5e3,yv=Object.freeze({SIGABRT:"\
|
|
891
1148
|
Aborted",SIGALRM:"Timeout or timer",SIGHUP:"Terminal closed",SIGINT:"User interruption with CTRL-C",SIGKILL:"Forced term\
|
|
892
1149
|
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"),
|
|
895
|
-
import
|
|
896
|
-
let t=
|
|
897
|
-
t.once("exit",()=>{
|
|
1150
|
+
Termination",SIGUSR1:"Application-specific signal",SIGUSR2:"Application-specific signal"}),wv=/^[\w./-]+$/u,_v=new RegExp(
|
|
1151
|
+
"\\p{Separator}|\\p{Other}","gu"),pf=Object.freeze({" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"})});import{spawn as bf}from"node:child_process";import{mkdir as Ov,open as Rv,readdir as Av,readFile as Pv}from"node:fs/promises";
|
|
1152
|
+
import Cv from"node:path";import{fileURLToPath as Nv}from"node:url";function $v(e){if(process.platform!=="win32"){if(!Se){
|
|
1153
|
+
let t=bf(process.execPath,[kv],{cwd:"/",detached:!0,stdio:["pipe","ignore","ignore"]});t.once("error",()=>{Se===t&&(Se=null)}),
|
|
1154
|
+
t.once("exit",()=>{Se===t&&(Se=null)}),t.stdin.on("error",()=>{}),t.unref(),t.stdin.unref(),Se=t;for(let r of lt.values())
|
|
898
1155
|
r.scopeEmpty!==!0&&r.pid!==e&&t.stdin.write(`+${r.pid}
|
|
899
|
-
`)}
|
|
900
|
-
`)}}function
|
|
901
|
-
`),![...
|
|
902
|
-
dirname(e),{recursive:!0}),
|
|
903
|
-
!0,i(s))};e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function
|
|
904
|
-
try{o=await
|
|
905
|
-
detached:!0,env:n,stdio:i});await
|
|
906
|
-
s.pid)),s.once("exit",()=>{!
|
|
907
|
-
s.unref(),
|
|
1156
|
+
`)}Se.stdin.write(`+${e}
|
|
1157
|
+
`)}}function Lv(e){Se&&(Se.stdin.write(`-${e}
|
|
1158
|
+
`),![...lt.values()].some(t=>t.scopeEmpty!==!0)&&(Se.stdin.end(),Se=null))}async function Mv(e=""){return e?(await Ov(Cv.
|
|
1159
|
+
dirname(e),{recursive:!0}),Rv(e,"w",384)):null}async function Dv(e){return new Promise((t,r)=>{let n=!1,o=(i,s)=>{n||(n=
|
|
1160
|
+
!0,i(s))};e.once("spawn",()=>o(t)),e.once("error",i=>o(r,i))})}async function Ef(e={},t={}){let{cwd:r="",env:n={}}=t,o=null;
|
|
1161
|
+
try{o=await Mv(e.logPath);let i=o?["ignore",o.fd,o.fd]:["ignore","ignore","ignore"],s=bf(e.command,e.args,{cwd:r||void 0,
|
|
1162
|
+
detached:!0,env:n,stdio:i});await Dv(s);let a=e.execution?.id||"";return a&&(lt.set(a,{child:s,pid:Number(s.pid)}),$v(Number(
|
|
1163
|
+
s.pid)),s.once("exit",()=>{!Fn(s.pid)&<.has(a)&&(lt.set(a,{child:s,pid:Number(s.pid),scopeEmpty:!0}),Lv(Number(s.pid)))})),
|
|
1164
|
+
s.unref(),br({execution:e.execution,exitCode:0,ok:!0,output:"Detached command started.",pid:s.pid})}catch(i){return te(i?.
|
|
908
1165
|
message||"Detached command failed to start.",i?.code||"vibe64_command_detached_failed",{execution:e.execution})}finally{
|
|
909
|
-
await o?.close().catch(()=>null)}}function
|
|
910
|
-
platform==="win32"){let r=[...
|
|
911
|
-
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function
|
|
912
|
-
return process.platform==="win32"?[...
|
|
913
|
-
!0}catch(r){if(r?.code==="ESRCH")return!1;throw r}}async function
|
|
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
|
|
916
|
-
s+2).split(" ");Number(a[2])!==r||a[0]==="Z"||n.push({command:i.slice(i.indexOf("(")+1,s),pid:Number(o)})}return n}async function
|
|
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,
|
|
921
|
-
|
|
922
|
-
outputEncoding:
|
|
923
|
-
if(
|
|
924
|
-
maxBuffer:a,onOutput:c,outputEncoding:
|
|
925
|
-
|
|
926
|
-
i.id,h),
|
|
927
|
-
|
|
928
|
-
re_timed_out":
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if(!await(
|
|
932
|
-
"The command finished",
|
|
933
|
-
`${
|
|
934
|
-
outputEncoding:
|
|
935
|
-
|
|
936
|
-
execution:
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
and",args:s=[]}={}){return gc({args:Array.isArray(s)?s.map(a=>String(a)):[],command:t,cwd:r,env:n,gid:e.user?.gid,home:e.
|
|
1166
|
+
await o?.close().catch(()=>null)}}function Fn(e=null){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;if(process.
|
|
1167
|
+
platform==="win32"){let r=[...lt.values()].find(n=>n.pid===t);return r?.child?.exitCode===null&&r?.child?.signalCode===null}
|
|
1168
|
+
try{return process.kill(-t,0),!0}catch(r){return r?.code==="EPERM"}}function wf(e=null,t="SIGTERM"){if(!Fn(e))return!1;try{
|
|
1169
|
+
return process.platform==="win32"?[...lt.values()].find(n=>n.pid===Number(e))?.child?.kill(t):process.kill(-Number(e),t),
|
|
1170
|
+
!0}catch(r){if(r?.code==="ESRCH")return!1;throw r}}async function Sf(e=null,t=10){let r=Number(e);if(process.platform!==
|
|
1171
|
+
"linux"||!Number.isSafeInteger(r)||r<=0)return[];let n=[];for(let o of await Av("/proc").catch(()=>[])){if(n.length>=t)break;
|
|
1172
|
+
if(!/^\d+$/u.test(o))continue;let i=await Pv(`/proc/${o}/stat`,"utf8").catch(()=>""),s=i.lastIndexOf(")"),a=s<0?[]:i.slice(
|
|
1173
|
+
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 _f(e=null,t=0){
|
|
1174
|
+
let r=Date.now()+Math.max(0,Number(t)||0);for(;Fn(e)&&Date.now()<r;)await new Promise(n=>setTimeout(n,25));return!Fn(e)}
|
|
1175
|
+
async function Hn(e=null,t={}){let{killTimeoutMs:r=xv,termTimeoutMs:n=jv}=t;wf(e,"SIGTERM");let o=await _f(e,n);return o||
|
|
1176
|
+
(wf(e,"SIGKILL"),o=await _f(e,r)),o}var Iv,lt,jv,xv,kv,Se,Er=b(()=>{ut();Iv=new URL("./../node_modules/@local/vibe64-exe\
|
|
1177
|
+
cution/src/server/engines/detached.js",import.meta.url).href,lt=new Map,jv=3e3,xv=1e3,kv=Nv(new URL("./detachedReaper.js",
|
|
1178
|
+
Iv)),Se=null});async function Sr(e="",t=[],r={}){let{cwd:n="",env:o={},execution:i=null,input:s=void 0,maxBuffer:a=void 0,onOutput:c=null,
|
|
1179
|
+
outputEncoding:u="utf8",signal:d=null,timeout:p=15e3}=r,g,h,l,w=null,_=Promise.withResolvers(),f=()=>{l||=h(),l.then(_.resolve)};
|
|
1180
|
+
if(d?.aborted)return te("Command cancelled.","vibe64_command_cancelled",{execution:i});try{let E=gf(e,t,{cwd:n,env:o,input:s,
|
|
1181
|
+
maxBuffer:a,onOutput:c,outputEncoding:u,timeout:p});w=Number(E.pid);let T;h=()=>{if(!T){let R;process.platform!=="win32"?
|
|
1182
|
+
R=Hn(w).catch(()=>!1):(E.kill("SIGKILL"),R=E.completion.then(()=>!0)),T=R.then(O=>(O||(T=null),O))}return T},i?.id&&vf.set(
|
|
1183
|
+
i.id,h),d?.addEventListener("abort",f,{once:!0}),d?.aborted&&f();let S=await Promise.race([E.completion,_.promise.then(R=>R?
|
|
1184
|
+
E.completion:{exitCode:1})]),v=typeof S.exitCode=="number"?S.exitCode:1;g=br({code:S.timedOut===!0?"vibe64_command_captu\
|
|
1185
|
+
re_timed_out":S.code?"vibe64_command_capture_failed":"",error:v===0?"":S.shortMessage,exitCode:v,output:S.all||(v===0?"":
|
|
1186
|
+
S.shortMessage),outputEncoding:u,signal:S.signal,stderr:S.stderr,stdout:S.stdout,timedOut:S.timedOut===!0,execution:i})}catch(E){
|
|
1187
|
+
g=te(E.message,"vibe64_command_capture_failed",{execution:i,outputEncoding:u})}finally{d?.removeEventListener("abort",f)}
|
|
1188
|
+
if(!await(l||h?.()||!0)){let E=await Sf(w),T=g?.timedOut?"The command timed out":d?.aborted?"The command was cancelled":
|
|
1189
|
+
"The command finished",S=E.length?`: ${E.map(v=>`${v.command} (pid ${v.pid})`).join(", ")} still running`:"";return{...te(
|
|
1190
|
+
`${T}, and its execution scope did not become empty${S}.`,"vibe64_execution_drain_failed",{execution:i,output:g?.output,
|
|
1191
|
+
outputEncoding:u,signal:g?.signal,stderr:g?.stderr,stdout:g?.stdout,timedOut:g?.timedOut}),remainingProcesses:E}}i?.id&&
|
|
1192
|
+
vf.delete(i.id);let y=i&&{...i,state:"finished"};return d?.aborted?te("Command cancelled.","vibe64_command_cancelled",{...g,
|
|
1193
|
+
execution:y,outputEncoding:u}):y?{...g,execution:y}:g}var vf,vr=b(()=>{ut();yf();Er();vf=new Map});function Ns(e=""){let t=String(e||"").trim()||Ie().execHelperPath;if(!t){let r=new Error("This computer has no helper fo\
|
|
1194
|
+
r running commands as another user.");throw r.code="vibe64_exec_helper_unavailable",r}return t}function Tf(e={}){return{
|
|
1195
|
+
...e,schema:Vv,schemaVersion:Uv}}function qn({actor:e={},command:t="",cwd:r="",env:n={},input:o,operation:i="vibe64-comm\
|
|
1196
|
+
and",args:s=[]}={}){return Tf({args:Array.isArray(s)?s.map(a=>String(a)):[],command:t,cwd:r,env:n,gid:e.user?.gid,home:e.
|
|
941
1197
|
user?.home,inputBase64:o==null?"":Buffer.isBuffer(o)?o.toString("base64"):Buffer.from(String(o)).toString("base64"),operation:i,
|
|
942
|
-
uid:e.user?.uid,username:e.user?.username})}function
|
|
1198
|
+
uid:e.user?.uid,username:e.user?.username})}function Tr(e={}){return e.mode==="pty"&&e.envPolicy==="auth"&&!["assistant",
|
|
943
1199
|
"codex"].includes(e.purpose)?"account-auth-terminal":e.purpose==="codex"&&e.mode==="capture"&&e.envPolicy==="auth"||e.purpose===
|
|
944
1200
|
"codex"&&e.mode==="detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"?"codex-app-server":e.mode===
|
|
945
1201
|
"detached"&&e.execution?.kind==="assistant"&&e.execution?.lifecycle==="service"&&["opencode-catalog","opencode-server"].
|
|
946
1202
|
includes(e.execution?.operationId)||e.mode==="capture"&&e.execution?.kind==="assistant"&&e.execution?.operationId==="ope\
|
|
947
1203
|
ncode-catalog"?"opencode-app-server":e.purpose==="account"?"account-status":e.purpose==="github"?"github-workflow-comman\
|
|
948
1204
|
d":e.purpose==="github-api"?"github-api-command":e.purpose==="workspace-cache"?"workspace-cache-command":e.purpose==="he\
|
|
949
|
-
alth"?"health-status":"vibe64-command"}async function
|
|
950
|
-
utf8",runCapture:i=
|
|
1205
|
+
alth"?"health-status":"vibe64-command"}async function js(e={},{env:t,helperPath:r="",maxBuffer:n=void 0,outputEncoding:o="\
|
|
1206
|
+
utf8",runCapture:i=Sr,signal:s=null,timeout:a=15e3}){let c={env:t,input:`${JSON.stringify(e)}
|
|
951
1207
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
952
|
-
udo",["-n",
|
|
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
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
let
|
|
959
|
-
|
|
1208
|
+
udo",["-n",Ns(r),"execute"],c)}var Vv,Uv,Wn=b(()=>{vr();ke();Vv="vibe64.exec-helper.payload",Uv=1});import{createRequire as zv}from"node:module";var Bv,Vx,If=b(()=>{Bv=new URL("./../node_modules/@jskit-ai/kernel/server/s\
|
|
1209
|
+
upport/symlinkSafeRequire.js",import.meta.url).href,Vx=zv(Bv)});var Hx,qx,Wx,Yx,Of=b(()=>{U();Hx=Object.freeze(["bundled","dev_server"]),qx=Object.freeze(["capacitor"]),Wx=Object.freeze(
|
|
1210
|
+
{callbackPath:"/auth/login",customScheme:"",appLinkDomains:Object.freeze([])}),Yx=Object.freeze({packageName:"",minSdk:26,
|
|
1211
|
+
targetSdk:35,versionCode:1,versionName:"1.0.0"})});var Rf=b(()=>{U();Of()});var xs=b(()=>{});var ks=b(()=>{});var Af=b(()=>{xs();U();ks()});function Ge(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e);for(let r of Object.getOwnPropertyNames(
|
|
1212
|
+
e))Ge(e[r],t);return Object.freeze(e)}var Ir=b(()=>{});var Pf=b(()=>{});var mk,hk,Cf=b(()=>{Ir();U();Pf();xs();mk=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),hk=Object.
|
|
1213
|
+
freeze(["capabilities","kind","metadata","migrations","runtime","vite"])});var $s=b(()=>{U()});import Hv from"node:child_process";import{constants as Ls}from"node:fs";import{open as qv}from"node:fs/promises";import Ms from"node:path";
|
|
1214
|
+
function Ds(e="",t=Vs){let r=new Error(e||"Exclusive file lock failed.");return r.code=t,r}function Nf(e="",t="path",r=Vs){
|
|
1215
|
+
let n=String(e||"").trim();if(!n||!Ms.isAbsolute(n)||Ms.normalize(n)!==n)throw Ds(`${t} must be a normalized absolute pa\
|
|
1216
|
+
th.`,r);return n}function Yv(e,t){return new Promise((r,n)=>{let o=Hv.spawn("/usr/bin/flock",["--exclusive","--nonblock",
|
|
960
1217
|
"3"],{cwd:t,env:{PATH:"/usr/bin:/bin"},stdio:["ignore","ignore","pipe",e]}),i="";o.stderr.on("data",s=>{i=`${i}${String(
|
|
961
|
-
s||"")}`.slice(-4096)}),o.once("error",n),o.once("close",s=>r({status:s,stderr:i.trim()}))})}async function
|
|
962
|
-
errorCode:r=
|
|
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
|
|
966
|
-
lock_failed",
|
|
967
|
-
session?.metadata?.session_git_command_actor_user_key)}async function
|
|
968
|
-
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await
|
|
969
|
-
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:
|
|
1218
|
+
s||"")}`.slice(-4096)}),o.once("error",n),o.once("close",s=>r({status:s,stderr:i.trim()}))})}async function Dt(e="",{cwd:t="",
|
|
1219
|
+
errorCode:r=Vs}={}){let n=Nf(e,"lockPath",r),o=t?Nf(t,"cwd",r):Ms.dirname(n),i=await qv(n,Ls.O_CREAT|Ls.O_NOFOLLOW|Ls.O_RDWR,
|
|
1220
|
+
432),s;try{s=await Yv(i.fd,o)}catch(c){throw await i.close().catch(()=>null),Ds(c?.message||String(c||"Exclusive file lo\
|
|
1221
|
+
ck failed."),r)}if(s.status!==0){if(await i.close(),s.status===Wv)return null;throw Ds(`Exclusive file lock process fail\
|
|
1222
|
+
ed${s.stderr?`: ${s.stderr}`:"."}`,r)}let a=!1;return async()=>{a||(a=!0,await i.close())}}var Vs,Wv,jf=b(()=>{Vs="file_\
|
|
1223
|
+
lock_failed",Wv=1});var Jv,Tk,xf=b(()=>{Jv="jskit-client-build",Tk=new RegExp(`<meta name="${Jv}" content="([0-9a-f]+)"`,"u")});import Xv from"node:path";var Ck,kf=b(()=>{xf();$s();Ck=Xv.join("dist","index.html")});var Yn=b(()=>{If();Rf();Af();ks();Cf();$s();jf();kf()});var $f=b(()=>{Yn()});function Zv(e={}){return $e(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
1224
|
+
session?.metadata?.session_git_command_actor_user_key)}async function Lf(e={}){let t=j(e.actor)||"daemon";if(t==="app"&&
|
|
1225
|
+
e.applicationAccount)return{actor:t,applicationAccount:!0,credentialScope:t,requiresRealUser:!1,user:await Ps(e.applicationAccount)};
|
|
1226
|
+
if(t==="daemon"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:As()};let r=Zv(e);if(!r){let n=new Error(
|
|
970
1227
|
"A user key is required for real-user command execution.");throw n.code="vibe64_command_actor_user_required",n}return{actor:t,
|
|
971
|
-
credentialScope:"user",requiresRealUser:!0,user:await
|
|
972
|
-
user?.gid}function
|
|
973
|
-
if(!e.requiresRealUser)return;let n=
|
|
1228
|
+
credentialScope:"user",requiresRealUser:!0,user:await Ps(r)}}var Mf=b(()=>{K();Mt()});import Df from"node:path";function Vt(e={}){let t=df();return t.uid===null||t.gid===null||t.uid===e.user?.uid&&t.gid===e.
|
|
1229
|
+
user?.gid}function Us(){return!!Ie().execHelperPath}function Jn(e={}){return e.requiresRealUser?Us()||!Vt(e):!1}function Vf(e={},t={},r=""){
|
|
1230
|
+
if(!e.requiresRealUser)return;let n=x(t.session?.sourceRoot||t.session?.sourcePath),o=x(r);if(!n||!o||!ze(n,o))return;let i=new Error(
|
|
974
1231
|
"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
|
-
mand_managed_source_real_user_forbidden",i}function
|
|
976
|
-
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&
|
|
977
|
-
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var
|
|
978
|
-
|
|
1232
|
+
mand_managed_source_real_user_forbidden",i}function Uf(e={},t={}){let r=x(e.user?.home),n=x(t.HOME),o=x(t.VIBE64_CREDENTIAL_HOME);
|
|
1233
|
+
if(!(!e.requiresRealUser&&o&&n===o)&&r&&n&&Df.resolve(r)!==Df.resolve(n)){let i=new Error("Command HOME does not match t\
|
|
1234
|
+
he resolved actor home.");throw i.code="vibe64_command_home_actor_mismatch",i}}var Kn=b(()=>{Mt();ke();K()});function Xn(...e){let t={};for(let r of e){let n=ye(r);for(let o of Or)n[o]!==void 0&&(t[o]=n[o])}return t}var Or,Zn=b(()=>{
|
|
1235
|
+
K();Or=Object.freeze(["DATABASE_URL","DB_CLIENT","DB_DATABASE","DB_HOST","DB_NAME","DB_PASSWORD","DB_PORT","DB_USER","DB\
|
|
979
1236
|
_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
|
|
982
|
-
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function
|
|
983
|
-
o
|
|
1237
|
+
R","VIBE64_MYSQL_USER"])});import{spawn as Qv,spawnSync as eT}from"node:child_process";import{createHash as tT}from"node:crypto";import{statSync as Wf}from"node:fs";
|
|
1238
|
+
import{stat as Yf}from"node:fs/promises";import Qn from"node:path";function zf(e="",t="vibe64"){return j(e).toLowerCase().
|
|
1239
|
+
replace(/[^a-z0-9-]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,63)||t}function oT(...e){for(let t of e){let r=ee(t),n=ee(r.
|
|
1240
|
+
user),o=$e(r.name,r.userName,r.user_name,r.gitUserName,r.git_user_name,n.name,n.userName,n.user_name),i=$e(r.email,r.userEmail,
|
|
984
1241
|
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
|
|
986
|
-
t.login,t.username),n
|
|
987
|
-
committerName:r,source:"github"}}function
|
|
988
|
-
authorEmail:`${r}@${n}${
|
|
989
|
-
fallback"}}function
|
|
990
|
-
isDirectory()?t:""}catch{return""}}async function
|
|
991
|
-
t:""}function
|
|
992
|
-
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=
|
|
993
|
-
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:
|
|
994
|
-
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?
|
|
995
|
-
null}}function
|
|
1242
|
+
committerEmail:i,committerName:o,source:"configured"}}return null}function iT(e={}){let t=ee(e),r=$e(t.name,t.displayName,
|
|
1243
|
+
t.login,t.username),n=$e(t.email,t.publicEmail,t.verifiedEmail);return!r||!n?null:{authorEmail:n,authorName:r,committerEmail:n,
|
|
1244
|
+
committerName:r,source:"github"}}function sT({workspace:e="",userKey:t=""}={}){let r=zf(t,"user"),n=zf(e,"local");return{
|
|
1245
|
+
authorEmail:`${r}@${n}${Bf}`,authorName:`${r} via Vibe64`,committerEmail:`vibe64@${n}${Bf}`,committerName:"Vibe64",source:"\
|
|
1246
|
+
fallback"}}function Bs(e=""){let t=j(e);return t&&Qn.isAbsolute(t)?t:""}function Gf(e=""){let t=Bs(e);try{return t&&Wf(t).
|
|
1247
|
+
isDirectory()?t:""}catch{return""}}async function Ff(e=""){let t=Bs(e);return t&&await Yf(t).then(r=>r.isDirectory(),()=>!1)?
|
|
1248
|
+
t:""}function Xf(e=""){let t={};for(let r of String(e||"").split(`
|
|
1249
|
+
`)){let n=/^user\.(name|email)(?: (.*))?$/iu.exec(r);n&&(t[n[1].toLowerCase()]=j(n[2]))}return t}function Zf(e,t){return{
|
|
1250
|
+
...e?{cwd:e}:{},env:t,stdio:["ignore","pipe","ignore"],timeout:rT}}function Hf(e,t){let r=eT("git",Jf,{...Zf(e,t),encoding:"\
|
|
1251
|
+
utf8"});return r.error||r.signal?{transient:!0,values:null}:{transient:!1,values:r.status===0||r.status===1?Xf(r.stdout):
|
|
1252
|
+
null}}function qf(e,t){return new Promise(r=>{let n="",o=!1,i=a=>{o||(o=!0,r(a))},s=Qv("git",Jf,Zf(e,t));s.stdout.setEncoding(
|
|
996
1253
|
"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
|
-
values:null}:{transient:!1,values:a===0||a===1?
|
|
998
|
-
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function
|
|
999
|
-
env.PATH||e.PATH}}function
|
|
1000
|
-
e.HOME),r=
|
|
1001
|
-
g"):""].filter(Boolean)}async function
|
|
1002
|
-
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function
|
|
1003
|
-
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}function
|
|
1004
|
-
([o],[i])=>o<i?-1:o>i?1:0);return
|
|
1005
|
-
await
|
|
1006
|
-
function
|
|
1007
|
-
values:o.values}}function
|
|
1008
|
-
r&&
|
|
1009
|
-
read).values;let a={expiresAt:i+
|
|
1010
|
-
a&&
|
|
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([
|
|
1014
|
-
typeof t!="object"?null:
|
|
1015
|
-
null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function
|
|
1016
|
-
project:r={},session:n={}}){let o=
|
|
1017
|
-
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||
|
|
1018
|
-
let i=
|
|
1019
|
-
t.VIBE64_RUNTIME_NAMESPACE),userKey
|
|
1020
|
-
LOGNAME)})}async function
|
|
1021
|
-
{})||
|
|
1022
|
-
return
|
|
1023
|
-
ME",
|
|
1024
|
-
"--get-regexp","^user\\.(name|email)$"],
|
|
1254
|
+
values:null}:{transient:!1,values:a===0||a===1?Xf(n):null}))})}function Qf(e=null){return!e?.name||!e?.email?null:{authorEmail:e.
|
|
1255
|
+
email,authorName:e.name,committerEmail:e.email,committerName:e.name,source:"git-config"}}function ep(e={}){return{...e,PATH:process.
|
|
1256
|
+
env.PATH||e.PATH}}function tp(e={}){if(Object.hasOwn(e,"GIT_CONFIG_GLOBAL"))return[String(e.GIT_CONFIG_GLOBAL)];let t=Bs(
|
|
1257
|
+
e.HOME),r=j(e.XDG_CONFIG_HOME)||(t?Qn.join(t,".config"):"");return[r?Qn.join(r,"git","config"):"",t?Qn.join(t,".gitconfi\
|
|
1258
|
+
g"):""].filter(Boolean)}async function aT(e={}){return(await Promise.all(tp(e).map(r=>Yf(r).then(n=>`${n.ino}:${n.size}:${n.
|
|
1259
|
+
mtimeMs}:${n.ctimeMs}`,()=>"missing")))).join("|")}function cT(e={}){return tp(e).map(t=>{try{let r=Wf(t);return`${r.ino}\
|
|
1260
|
+
:${r.size}:${r.mtimeMs}:${r.ctimeMs}`}catch{return"missing"}}).join("|")}function rp(e,t,r){let n=Object.entries(r).sort(
|
|
1261
|
+
([o],[i])=>o<i?-1:o>i?1:0);return tT("sha256").update(JSON.stringify([e,t,n])).digest("hex")}async function uT(e,t,r){let n=e?
|
|
1262
|
+
await qf(e,r):null;if(n?.values)return n;let o=await qf(t,r);return{transient:!!(n?.transient||o.transient),values:o.values}}
|
|
1263
|
+
function lT(e,t,r){let n=e?Hf(e,r):null;if(n?.values)return n;let o=Hf(t,r);return{transient:!!(n?.transient||o.transient),
|
|
1264
|
+
values:o.values}}function np(e,t,r){let n=dt.get(e);if(n&&n.revision===t&&n.expiresAt>r)return n;for(let[o,i]of dt)i.expiresAt<=
|
|
1265
|
+
r&&dt.delete(o);return null}async function dT(e,t,r){let n=rp(e,t,r),o=await aT(r),i=Date.now(),s=np(n,o,i);if(s)return(await s.
|
|
1266
|
+
read).values;let a={expiresAt:i+Kf,read:uT(e,t,r),revision:o};dt.set(n,a);let c=await a.read;return c.transient?dt.get(n)===
|
|
1267
|
+
a&&dt.delete(n):a.values=c.values,c.values}function fT(e,t,r){let n=rp(e,t,r),o=cT(r),i=Date.now(),s=np(n,o,i);if(s&&Object.
|
|
1268
|
+
hasOwn(s,"values"))return s.values;let a=lT(e,t,r);return a.transient||dt.set(n,{expiresAt:i+Kf,read:Promise.resolve(a),
|
|
1269
|
+
revision:o,values:a.values}),a.values}async function pT({cwd:e="",env:t=null}={}){if(!t||typeof t!="object")return null;
|
|
1270
|
+
let[r,n]=await Promise.all([Ff(e),Ff(t.HOME)]);return Qf(await dT(r,n,ep(t)))}function mT({cwd:e="",env:t=null}={}){return!t||
|
|
1271
|
+
typeof t!="object"?null:Qf(fT(Gf(e),Gf(t.HOME),ep(t)))}function hT(e={}){let t=ee(e),r=j(t.name),n=j(t.email);return!r||
|
|
1272
|
+
!n?null:{authorEmail:n,authorName:r,committerEmail:n,committerName:r,source:"git-config"}}function op({env:e,personGitIdentity:t=null,
|
|
1273
|
+
project:r={},session:n={}}){let o=ee(n.metadata);return oT(r.gitIdentity,r.config?.git,n.gitIdentity,o.git_identity,{name:e.
|
|
1274
|
+
VIBE64_GIT_USER_NAME,email:e.VIBE64_GIT_USER_EMAIL})||hT(t)}function ip({actor:e={},env:t,project:r={},session:n={},userKey:o=""}){
|
|
1275
|
+
let i=ee(n.metadata);return iT(r.githubUser||n.githubUser||i.github_user)||sT({workspace:$e(r.workspace,t.VIBE64_WORKSPACE,
|
|
1276
|
+
t.VIBE64_RUNTIME_NAMESPACE),userKey:$e(o,e.user?.username,t.VIBE64_GIT_USER_KEY,t.VIBE64_USER_KEY,t.VIBE64_USER,t.USER,t.
|
|
1277
|
+
LOGNAME)})}async function gT(e){return op(e)||await pT(e.gitConfig||{})||ip(e)}function yT(e){return op(e)||mT(e.gitConfig||
|
|
1278
|
+
{})||ip(e)}function sp(e){return{[pt]:e.authorEmail,[ft]:e.authorName,[ht]:e.committerEmail,[mt]:e.committerName}}async function ap(e){
|
|
1279
|
+
return sp(await gT(e))}function cp(e){return sp(yT(e))}var ft,pt,mt,ht,Bf,rT,Jf,Kf,nT,dt,Ut=b(()=>{K();ft="GIT_AUTHOR_NA\
|
|
1280
|
+
ME",pt="GIT_AUTHOR_EMAIL",mt="GIT_COMMITTER_NAME",ht="GIT_COMMITTER_EMAIL",Bf=".users.vibe64.invalid",rT=2e3,Jf=["config",
|
|
1281
|
+
"--get-regexp","^user\\.(name|email)$"],Kf=3e4,nT=['git config --global user.name "Your Name"','git config --global user\
|
|
1025
1282
|
.email "you@example.com"'].join(`
|
|
1026
|
-
`);
|
|
1027
|
-
|
|
1028
|
-
let e=
|
|
1029
|
-
|
|
1283
|
+
`);dt=new Map});import zs from"node:path";function re({root:e=""}={}){return x(e||Ie().runtimePackRoot)}function Fs(e=""){let t=re();return(t?
|
|
1284
|
+
Bt[j(e)]?.binDirs||[]:[]).map(n=>zs.join(t,n))}function up(){let e=re();return e?[zs.join(e,"guard-bin")]:[]}function Hs(){
|
|
1285
|
+
let e=re();return e?[zs.join(e,"policy-bin")]:[]}function wT(e=""){let t=j(e);return[...Bt[t]?.managedCommands||[]]}var Bt,
|
|
1286
|
+
Gs,b0,Oe=b(()=>{K();ke();Bt=Object.freeze({awsebcli:{binDirs:["awsebcli/bin"],managedCommands:["eb"]},bubblewrap:{binDirs:[
|
|
1030
1287
|
"bubblewrap/bin"],managedCommands:[]},bun:{binDirs:["bun/bin"],dependencyFiles:["package.json","bun.lock","bun.lockb","p\
|
|
1031
1288
|
ackage-lock.json"],managedCommands:["bun"]},composer:{binDirs:["composer/bin"],dependencyFiles:["composer.json","compose\
|
|
1032
1289
|
r.lock"],managedCommands:["composer"]},cpp:{binDirs:["cpp/bin"],dependencyFiles:["CMakeLists.txt","vcpkg.json","vcpkg-co\
|
|
@@ -1055,277 +1312,279 @@ tor-clis/lib/node_modules/opencode-ai/package.json"],managedCommands:["claude","
|
|
|
1055
1312
|
in"],managedCommands:["php"]},playwright:{binDirs:["playwright/bin"],identityPaths:["playwright/runtime.env","playwright\
|
|
1056
1313
|
/browsers"],managedCommands:["playwright"]},postgresql:{binDirs:["postgresql/bin"],managedCommands:["initdb","pg_ctl","p\
|
|
1057
1314
|
g_isready","postgres","psql"]},ripgrep:{binDirs:["ripgrep/bin"],managedCommands:[]},sqlite:{binDirs:["sqlite/bin"],managedCommands:[
|
|
1058
|
-
"sqlite3"]}}),
|
|
1059
|
-
ubblewrap","bun","php","composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);
|
|
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=
|
|
1065
|
-
{[
|
|
1066
|
-
ATH",
|
|
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,...
|
|
1315
|
+
"sqlite3"]}}),Gs=Object.freeze(["operator-clis","node26","git","gh","mysql","mariadb","postgresql","sqlite","ripgrep","b\
|
|
1316
|
+
ubblewrap","bun","php","composer","awsebcli","cpp","python","ruby","go","java","kotlin","csharp","rust","playwright"]);b0=
|
|
1317
|
+
Object.freeze({runtimePackManagedCommands:wT})});import{readFileSync as _T}from"node:fs";import lp from"node:path";function vT({runtimePackRoot:e=""}={}){let t=re({root:e});
|
|
1318
|
+
if(!t)return"";let r=lp.join(t,dp,ET),n;try{n=_T(r,"utf8")}catch(i){if(i?.code==="ENOENT")return"";throw i}let o=n.split(
|
|
1319
|
+
/\r?\n/u).filter(i=>i.startsWith("playwright_version=")).map(i=>i.slice(19).trim());if(o.length!==1||!ST.test(o[0]))throw new Error(
|
|
1320
|
+
`Invalid managed Playwright runtime manifest: ${r}.`);return o[0]}function fp({runtimePackRoot:e=""}={}){let t=re({root:e}),
|
|
1321
|
+
r=x(Ie().sharedCacheRoot),n=vT({runtimePackRoot:t});return{...r?{[eo]:r}:{},...t?{[Rr]:lp.join(t,dp,bT),[qs]:"1"}:{},...n?
|
|
1322
|
+
{[Ws]:n}:{}}}var eo,Rr,qs,Ws,dp,bT,ET,ST,Ar=b(()=>{K();ke();Oe();eo="VIBE64_SHARED_CACHE_ROOT",Rr="PLAYWRIGHT_BROWSERS_P\
|
|
1323
|
+
ATH",qs="PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD",Ws="VIBE64_PLAYWRIGHT_VERSION",dp="playwright",bT="browsers",ET="runtime.env",
|
|
1324
|
+
ST=/^\d+\.\d+\.\d+$/u});function zt(e={}){for(let t of Object.keys(ye(e)))if(TT.has(t)||t.startsWith("XDG_")){let r=new Error(`Vibe64 command ca\
|
|
1325
|
+
llers cannot provide execution policy env: ${t}.`);throw r.code="vibe64_command_env_policy_reserved",r}}function to(e={},t={}){
|
|
1326
|
+
let{envPolicy:r="session"}=t,n=ye(e);zt(n);let o=Object.fromEntries(Object.entries(n).filter(([i])=>!IT.has(i)));return r===
|
|
1327
|
+
"deployment"?o:{...o,...Xn(n)}}var TT,IT,ro=b(()=>{K();Zn();Ut();Ar();TT=new Set(["HOME","LOGNAME","PATH","TMPDIR","USER",
|
|
1071
1328
|
"VIBE64_EXECUTION_ID","VIBE64_MANAGED_EXECUTION_REQUIRED","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIM\
|
|
1072
|
-
E_DIR"]),
|
|
1073
|
-
credentialHome||{},n=
|
|
1329
|
+
E_DIR"]),IT=new Set([...Or,pt,ft,ht,mt,Rr,qs,Ws,eo])});function OT(e=""){let t=x(e);return t==="/home"||t.startsWith("/home/")}function pp({actor:e={},request:t={}}={}){let r=t.
|
|
1330
|
+
credentialHome||{},n=x(r.home);if(!n)return{};let o=x(e.user?.home);if(e.requiresRealUser&&o&&n!==o){let a=new Error("Co\
|
|
1074
1331
|
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&&
|
|
1076
|
-
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=
|
|
1077
|
-
return{...
|
|
1078
|
-
configRoot)?{XDG_CONFIG_HOME:
|
|
1079
|
-
r.stateRoot)}:{}}}var
|
|
1080
|
-
isAbsolute(o))continue;let i=
|
|
1332
|
+
_mismatch",a}if(!e.requiresRealUser&&OT(n)&&o&&!ze(o,n)){let a=new Error("A /home credential directory requires a matchi\
|
|
1333
|
+
ng real-user actor.");throw a.code="vibe64_command_credential_home_real_user_required",a}let i=j(r.username||e.user?.username);
|
|
1334
|
+
return{..._r({home:n,username:i},{VIBE64_CREDENTIAL_HOME:n}),...x(r.cacheRoot)?{XDG_CACHE_HOME:x(r.cacheRoot)}:{},...x(r.
|
|
1335
|
+
configRoot)?{XDG_CONFIG_HOME:x(r.configRoot)}:{},...x(r.dataRoot)?{XDG_DATA_HOME:x(r.dataRoot)}:{},...x(r.stateRoot)?{XDG_STATE_HOME:x(
|
|
1336
|
+
r.stateRoot)}:{}}}var mp=b(()=>{Mt();K()});import hp from"node:path";function CT(e=[]){let t=new Set,r=[];for(let n of Array.isArray(e)?e:[e]){let o=j(n);if(!o||!hp.
|
|
1337
|
+
isAbsolute(o))continue;let i=hp.resolve(o);t.has(i)||(t.add(i),r.push(i))}return r}function Pr(e={},t=[]){let r={...e&&typeof e==
|
|
1081
1338
|
"object"&&!Array.isArray(e)?e:{}},n=Number.parseInt(String(r.GIT_CONFIG_COUNT||"0"),10),o=Number.isSafeInteger(n)&&n>=0?
|
|
1082
|
-
n:0;for(let i of Array.isArray(t)?t:[]){let s=
|
|
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
|
|
1086
|
-
return
|
|
1087
|
-
var
|
|
1088
|
-
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),
|
|
1089
|
-
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),
|
|
1339
|
+
n:0;for(let i of Array.isArray(t)?t:[]){let s=j(i?.key);s&&(r[`GIT_CONFIG_KEY_${o}`]=s,r[`GIT_CONFIG_VALUE_${o}`]=String(
|
|
1340
|
+
i?.value??""),o+=1)}return r.GIT_CONFIG_COUNT=String(o),r}function gp(e=[]){return CT(e).map(t=>({key:"safe.directory",value:t}))}
|
|
1341
|
+
function yp(e={},t=[]){return Pr(e,gp(t))}function NT(e=[]){return gp(e).flatMap(t=>["-c",`${t.key}=${t.value}`])}function Ys(){
|
|
1342
|
+
return{GH_PROMPT_DISABLED:"1",GIT_PAGER:"cat",GIT_TERMINAL_PROMPT:"0",PAGER:"cat"}}function Js(e={}){return Pr(e,RT)}function jT(e={}){
|
|
1343
|
+
return Pr(e,AT)}function xT(e={}){return Pr(e,PT)}function wp(e={}){return jT(Js(e))}function _p(e={}){return xT(Js(e))}
|
|
1344
|
+
var RT,AT,PT,D0,bp=b(()=>{K();RT=Object.freeze([{key:"url.https://github.com/.insteadOf",value:"git@github.com:"},{key:"\
|
|
1345
|
+
url.https://github.com/.insteadOf",value:"ssh://git@github.com/"}]),AT=Object.freeze([{key:"credential.https://github.co\
|
|
1346
|
+
m.helper",value:"!/usr/bin/env gh auth git-credential"}]),PT=Object.freeze([{key:"credential.https://github.com.helper",
|
|
1090
1347
|
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
|
-
()=>{
|
|
1098
|
-
function
|
|
1099
|
-
t)}catch{return!1}})}function
|
|
1100
|
-
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function
|
|
1101
|
-
if(!
|
|
1102
|
-
n=
|
|
1103
|
-
n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",".bun/bin"].map(o=>
|
|
1104
|
-
let e=["/opt/homebrew","/usr/local"];return[...
|
|
1105
|
-
[...
|
|
1106
|
-
t=>[...
|
|
1107
|
-
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return
|
|
1108
|
-
i=>
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
t
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1348
|
+
D0=Object.freeze({applyGitConfigEntriesToEnv:Pr,githubSshToHttpsGitEnv:Js,gitSafeDirectoryArgs:NT})});function $T(e={}){if(!e.gitAuthToken){let t=new Error("Token-backed GitHub transport requires a gitAuthToken.");throw t.
|
|
1349
|
+
code="vibe64_command_git_auth_token_required",t}return _p({...Ys(),GIT_TERMINAL_PROMPT:"0",[kT]:e.gitAuthToken})}function Ep({
|
|
1350
|
+
request:e={}}={}){let t={GIT_TERMINAL_PROMPT:"0"},r=t;return e.gitTransport==="github-token"?r=$T(e):(e.gitTransport==="\
|
|
1351
|
+
github-https"||e.purpose==="github")&&(r=wp({...t,...Ys()})),yp(r,e.gitSafeDirectories||[])}var kT,Sp=b(()=>{bp();kT="VI\
|
|
1352
|
+
BE64_GIT_AUTH_TOKEN"});import vp from"node:path";function Tp({env:e={}}={}){return re()?x(e[Ks])||(x(e.HOME)?vp.join(x(e.HOME),".local"):""):""}
|
|
1353
|
+
function Ip(e={}){let t=Tp(e);return t?{[Ks]:t}:{}}function Op(e={}){let t=Tp(e);return t?[vp.join(t,"bin")]:[]}var Ks,Xs=b(
|
|
1354
|
+
()=>{K();Oe();Ks="NPM_CONFIG_PREFIX"});import{existsSync as LT,readdirSync as MT}from"node:fs";import DT from"node:os";import Fe from"node:path";import no from"node:process";
|
|
1355
|
+
function Cr(e=""){return String(e||"").split(":").map(j).filter(Boolean)}function Ap(e=[]){return e.filter(t=>{try{return LT(
|
|
1356
|
+
t)}catch{return!1}})}function Rp(e="",t=/^$/u){try{return MT(e).filter(r=>t.test(r)).sort((r,n)=>Number(/\d+/u.exec(n)?.[0]||
|
|
1357
|
+
0)-Number(/\d+/u.exec(r)?.[0]||0))}catch{return[]}}function VT(e){if(re())return[];let t=String(e.HOME||DT.homedir()||"");
|
|
1358
|
+
if(!Fe.isAbsolute(t))return[];let r=Fe.isAbsolute(String(e.XDG_DATA_HOME||""))?e.XDG_DATA_HOME:Fe.join(t,".local/share"),
|
|
1359
|
+
n=Fe.isAbsolute(String(e.MISE_DATA_DIR||""))?e.MISE_DATA_DIR:Fe.join(r,"mise");return Ap([Fe.join(t,".local/bin"),Fe.join(
|
|
1360
|
+
n,"shims"),...[".claude/local",".opencode/bin",".cargo/bin",".bun/bin"].map(o=>Fe.join(t,o))])}function UT(){if(re())return[];
|
|
1361
|
+
let e=["/opt/homebrew","/usr/local"];return[...Cr(no.env.PATH),...no.platform==="darwin"?["/opt/homebrew/bin"]:[],...Ap(
|
|
1362
|
+
[...Rp("/usr/lib/postgresql",/^\d+$/u).slice(0,1).map(t=>`/usr/lib/postgresql/${t}/bin`),...no.platform==="darwin"?e.flatMap(
|
|
1363
|
+
t=>[...Rp(`${t}/opt`,/^postgresql@\d+$/u).slice(0,1).map(r=>`${t}/opt/${r}/bin`),`${t}/opt/mariadb/bin`]):[]])]}function Pp({
|
|
1364
|
+
env:e,existingPath:t="",inheritedPath:r="",runtimes:n=[],shimDirs:o=[]}){return ct([...Cr(o.join(":")),...Hs(),...n.flatMap(
|
|
1365
|
+
i=>Fs(i)),...up(),...Cr(t||(r?"":e.PATH)),...VT(no.env),...Cr(r),...UT(),...Cr(Nr)]).join(":")}var Nr,oo=b(()=>{K();Oe();
|
|
1366
|
+
Nr="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"});import BT from"node:path";function FT(e={}){return e.envPolicy==="deployment"||e.purpose==="deployment"||e.applicationAccount?
|
|
1367
|
+
{}:{APP_ENV:"development"}}function HT(e={}){return e.purpose==="preview"?{NODE_ENV:"development"}:{}}function qT(e={}){
|
|
1368
|
+
return Object.fromEntries(Object.entries(e&&typeof e=="object"&&!Array.isArray(e)?e:{}).map(([t,r])=>[String(t||"").trim(),
|
|
1369
|
+
String(r??"")]).filter(([t])=>t&&!zT.has(t)&&!GT.has(t)&&!t.startsWith("GIT_")&&!t.startsWith("GH_")&&!t.startsWith("XDG\
|
|
1370
|
+
_")))}function Zs(e={}){return e.envPolicy==="deployment"?[e.project?.deploymentEnv,e.project?.deployment?.env]:[e.project?.
|
|
1371
|
+
runtimeConfigEnv,e.project?.databaseEnv]}function WT(e={}){return Zs(e).reduce((t,r)=>e.envPolicy==="deployment"?(zt(r),
|
|
1372
|
+
{...t,...ye(r)}):{...t,...to(r,e)},{})}function YT(e={},t={}){return t.envPolicy==="deployment"?[]:t.envPolicy==="projec\
|
|
1373
|
+
t"?Zs(t):[e,...Zs(t),t.project?.databaseEnv,t.session?.databaseEnv]}function Cp({actor:e={},baseEnv:t,localPath:r="",request:n={}}){
|
|
1374
|
+
let o=Array.isArray(n.runtimes)?n.runtimes.join(":"):"",i=fp(),s=to(n.env,n),a=String(t.XDG_RUNTIME_DIR||"").trim(),c={..._r(
|
|
1375
|
+
e.user,qT(t)),...Vt(e)&&BT.isAbsolute(a)?{XDG_RUNTIME_DIR:a}:{},...HT(n),...Xn(...YT(t,n)),...WT(n),...Ep({actor:e,request:n}),
|
|
1376
|
+
...s,...pp({actor:e,request:n}),...i,...FT(n)},u={...c,...Ip({env:c}),VIBE64_DECLARED_RUNTIMES:o},d=Pp({env:u,existingPath:[
|
|
1377
|
+
...Op({env:u}),u.PATH].filter(Boolean).join(":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.shimDirs||[]});return{...u,
|
|
1378
|
+
PATH:d,...re()?{}:{VIBE64_TOOL_PATH:d}}}function Np({actor:e={},baseEnv:t,request:r={}},n){return{actor:e,env:t,gitConfig:{
|
|
1379
|
+
cwd:r.cwd,env:n},personGitIdentity:r.personGitIdentity,project:r.project,session:r.session,userKey:r.userKey}}async function jp(e){
|
|
1380
|
+
let t=Cp(e);return{...t,...await ap(Np(e,t))}}function Qs(e){let t=Cp(e);return{...t,...e.resolvedGitIdentityEnv||cp(Np(
|
|
1381
|
+
e,t))}}var zT,GT,ea=b(()=>{Kn();Mt();Zn();ro();Zn();mp();Sp();Ut();Ut();Ar();Xs();oo();Oe();K();zT=new Set([...Or,pt,ft,
|
|
1382
|
+
ht,mt,"HOME","LOGNAME","PATH","USER","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_RUNTIME_DIR"]),GT=new Set([
|
|
1383
|
+
"APP_ENV","NODE_ENV"])});import{Buffer as JT}from"node:buffer";function kp(){return{code:"terminal_session_not_found",error:"Terminal session not\
|
|
1384
|
+
found.",ok:!1}}function He(e=""){return String(e||"default").trim()||"default"}function ao(e){let t=String(e||""),r=t.length;
|
|
1385
|
+
for(let n=0;n<KT&&(r=t.lastIndexOf(`
|
|
1386
|
+
`,r-1),!(r<0));n+=1);return r>=0&&(t=t.slice(r+1)),t.length>xp&&(t=t.slice(t.length-xp)),t}function jr(e={}){return e.status===
|
|
1387
|
+
"running"||e.status==="closing"}function ta(e={}){return jr(e)||e.status==="exited"}function Lp(e,t){try{return t(qe(e))===
|
|
1388
|
+
!0}catch{return!1}}function ZT(e=0){let t=Math.floor(Number(e||0));return Number.isFinite(t)&&t>0?t:0}function QT(e="",t={}){
|
|
1389
|
+
let{outputLimit:r=0}=t,n=String(e||""),o=ZT(r);return!o||n.length<=o?{output:n,outputTruncated:!1}:{output:n.slice(n.length-
|
|
1390
|
+
o),outputTruncated:!0}}function qe(e,t={}){let r=QT(e.output,t);return{ok:!0,closeError:e.closeError||"",cols:e.cols||io,
|
|
1132
1391
|
createdAt:e.createdAt||"",id:e.id,commandPreview:e.commandPreview,exitCode:e.exitCode,inputVersion:e.inputVersion||0,lastInputAt:e.
|
|
1133
1392
|
lastInputAt||"",lastInputBytes:e.lastInputBytes||0,lastOutputAt:e.lastOutputAt||"",lastOutputBytes:e.lastOutputBytes||0,
|
|
1134
1393
|
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),
|
|
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"}),
|
|
1142
|
-
0)+1,e.lastOutputAt=new Date().toISOString(),e.lastOutputBytes=r)}function
|
|
1143
|
-
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function
|
|
1144
|
-
e||"Terminal PTY error.");return{code:t,message:r}}function
|
|
1394
|
+
so,status:e.status}}function Mp(e=""){return JT.byteLength(String(e||""),"utf8")}function xr(e=0){let t=Math.floor(Number(
|
|
1395
|
+
e));return!Number.isFinite(t)||t<0?0:Math.min(t,XT)}function eI(e={}){return Math.max(Lt(e.lastSubscriberDetachedAt),Lt(
|
|
1396
|
+
e.lastInputAt),Lt(e.lastOutputAt),Lt(e.createdAt))}function ra(e={},t=Date.now()){if(e.subscribers?.size)return 0;let r=eI(
|
|
1397
|
+
e);return r>0?Math.max(0,Number(t)-r):0}function co(e={}){e.detachedCleanupTimer&&(clearTimeout(e.detachedCleanupTimer),
|
|
1398
|
+
e.detachedCleanupTimer=null)}var xp,KT,io,so,y$,XT,w$,$p,Gt=b(()=>{K();xp=256*1024,KT=300,io=100,so=28,y$=600*1e3,XT=1440*
|
|
1399
|
+
60*1e3,w$=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "});$p=new Map});function Dp(e,t={}){return!e||!t||typeof t!="object"||Array.isArray(t)?qe(e):(e.metadata={...e.metadata||{},...t},Re(e,{
|
|
1400
|
+
metadata:e.metadata,type:"metadata"}),qe(e))}function Vp(e,t=""){let r=Mp(t);r<1||(e.outputVersion=Number(e.outputVersion||
|
|
1401
|
+
0)+1,e.lastOutputAt=new Date().toISOString(),e.lastOutputBytes=r)}function Re(e,t){if(e?.subscribers?.size)for(let r of[
|
|
1402
|
+
...e.subscribers])try{r(t)}catch{e.subscribers.delete(r)}}function tI(e){let t=String(e?.code||""),r=String(e?.message||
|
|
1403
|
+
e||"Terminal PTY error.");return{code:t,message:r}}function Up(e,t){if(!e)return;let r=tI(t);e.lastWriteErrorAt=new Date().
|
|
1145
1404
|
toISOString(),e.lastWriteErrorCode=r.code,e.lastWriteError=r.message,console.warn("Vibe64 terminal PTY write error.",{code:r.
|
|
1146
|
-
code,id:e.id,metadata:e.metadata||{},message:r.message,namespace:e.namespace||""}),
|
|
1147
|
-
error"})}function
|
|
1405
|
+
code,id:e.id,metadata:e.metadata||{},message:r.message,namespace:e.namespace||""}),Re(e,{code:r.code,error:r.message,type:"\
|
|
1406
|
+
error"})}function Bp(e){let t=e?.terminal?._writeStream;!t||typeof t.on!="function"||t.on("error",r=>{Up(e,r)})}function zp(e,t,r=t){
|
|
1148
1407
|
let n=`\r
|
|
1149
1408
|
[studio] ${r}\r
|
|
1150
|
-
`;e.closeError=t,e.output=
|
|
1409
|
+
`;e.closeError=t,e.output=ao(`${e.output}${n}`),Re(e,{chunk:n,type:"output"}),Re(e,{error:t,type:"error"})}async function Gp(e,{
|
|
1151
1410
|
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
|
|
1411
|
+
s?.message||s||`${o}.`),c=s instanceof Error?s:new Error(a);return c.code||=t,zp(e,a,`${o}: ${a}`),c}}function gt(e,t){let r=`${String(
|
|
1153
1412
|
t?.code||"terminal_cleanup_failed")}:${String(t?.message||"")}`;return e.reportedLifecycleFailures||=new Set,e.reportedLifecycleFailures.
|
|
1154
|
-
has(r)||(e.reportedLifecycleFailures.add(r)
|
|
1413
|
+
has(r)||(e.reportedLifecycleFailures.add(r),zp(e,String(t?.message||t||"Terminal cleanup failed."))),t}function uo(e,t=[]){
|
|
1155
1414
|
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(()=>
|
|
1415
|
+
"").startsWith("terminal_exit_"))?"terminal_exit_unverified":"terminal_cleanup_failed",r.terminalSessionId=e.id,r}function rI(e,t){
|
|
1416
|
+
return e.stopHookCompletion||(e.stopHookCompletion=Promise.resolve().then(()=>Gp(e,{code:"terminal_stop_hook_failed",flag:"\
|
|
1158
1417
|
stopHookStarted",hook:"onStop",label:"Terminal stop failed",payload:{id:e.id,output:e.output,reason:t,status:e.status}}))),
|
|
1159
|
-
e.stopHookCompletion}function
|
|
1418
|
+
e.stopHookCompletion}function na(e,t){return e.closeHookCompletion||(e.closeHookCompletion=Promise.resolve().then(()=>Gp(
|
|
1160
1419
|
e,{code:"terminal_close_hook_failed",flag:"closeHookStarted",hook:"onClose",label:"Terminal finalization failed",payload:{
|
|
1161
|
-
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function
|
|
1162
|
-
"exited"&&(e.status="exited",
|
|
1163
|
-
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await
|
|
1420
|
+
exitCode:e.exitCode,id:e.id,output:e.output,reason:t,status:e.status}}))),e.closeHookCompletion}function oa(e){e.status!==
|
|
1421
|
+
"exited"&&(e.status="exited",Re(e,{closeError:e.closeError||"",exitCode:e.exitCode,status:e.status,type:"status"}))}function ia(e){
|
|
1422
|
+
return e.scopeDrainCompletion||(e.scopeDrainCompletion=(async()=>{if(process.platform!=="win32"&&!await Hn(e.terminal.pid)){
|
|
1164
1423
|
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
|
|
1166
|
-
|
|
1424
|
+
t}})(),e.scopeDrainCompletion.catch(()=>null)),e.scopeDrainCompletion}async function Fp(e){try{await e.scopeDrainCompletion}catch(t){
|
|
1425
|
+
gt(e,t)}try{await Promise.all([na(e,e.stopReason||"exit"),e.stopHookCompletion])}catch(t){gt(e,t)}oa(e)}async function sa(e,t="\
|
|
1167
1426
|
stop"){if(!e||e.processExited)return{failures:[]};e.stopReason||=String(t||"stop"),e.status==="running"&&(e.status="clos\
|
|
1168
|
-
ing",
|
|
1427
|
+
ing",Re(e,{exitCode:e.exitCode,status:e.status,type:"status"}));let r=[];if(rI(e,e.stopReason),!e.processExited&&!e.killStarted){
|
|
1169
1428
|
e.killStarted=!0;try{e.terminal.kill()}catch(n){e.killStarted=!1;let o=n instanceof Error?n:new Error(String(n||"Termina\
|
|
1170
|
-
l process could not be killed."));o.code||="terminal_kill_failed",r.push(
|
|
1171
|
-
n))}return{failures:r}}var
|
|
1172
|
-
ok:!1}:null}var
|
|
1173
|
-
e.delete(r);let n=
|
|
1174
|
-
filter(r=>r.startsWith(t))}function
|
|
1175
|
-
o=[];for(let i of n){let s=
|
|
1176
|
-
()=>{
|
|
1177
|
-
let n=Math.max(0,r-
|
|
1178
|
-
let{namespace:r="default"}=t,n=
|
|
1179
|
-
let s=[];if(
|
|
1180
|
-
s.push(
|
|
1181
|
-
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&
|
|
1182
|
-
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(
|
|
1183
|
-
o.closePromise===i&&(o.closePromise=null)}}async function
|
|
1184
|
-
if(!
|
|
1185
|
-
r.id,{namespace:t})}}}var
|
|
1186
|
-
filter:e,namespacePrefix:t}){return
|
|
1429
|
+
l process could not be killed."));o.code||="terminal_kill_failed",r.push(gt(e,o))}}try{await ia(e)}catch(n){r.push(gt(e,
|
|
1430
|
+
n))}return{failures:r}}var aa=b(()=>{Er();Gt()});function oI(e="default"){return nI.get(He(e))||null}function Hp(e="default"){let t=oI(e);return t?{code:t.code,error:t.error,
|
|
1431
|
+
ok:!1}:null}var nI,qp=b(()=>{Gt();nI=new Map});function Ft(e){return yt.get(He(e))||$p}function Wp(e){let t=He(e);return yt.has(t)||yt.set(t,new Map),yt.get(t)}function Yp(e,t,r){
|
|
1432
|
+
e.delete(r);let n=He(t);e.size<1&&yt.get(n)===e&&yt.delete(n)}function iI(e=""){let t=String(e||"");return[...yt.keys()].
|
|
1433
|
+
filter(r=>r.startsWith(t))}function lo({namespace:e="",namespacePrefix:t="",runningOnly:r=!1}={}){let n=e?[He(e)]:iI(t),
|
|
1434
|
+
o=[];for(let i of n){let s=Ft(i);for(let a of s.values())r&&!jr(a)||o.push({namespace:i,session:a})}return o}var yt,ca=b(
|
|
1435
|
+
()=>{Gt();yt=new Map});function fo(e={},t="default"){if(co(e),!ta(e)||e.subscribers?.size)return;let r=xr(e.detachedIdleTimeoutMs);if(r<1)return;
|
|
1436
|
+
let n=Math.max(0,r-ra(e));e.detachedCleanupTimer=setTimeout(()=>{e.detachedCleanupTimer=null,sI({namespace:t})},n)}async function ua(e,t={}){
|
|
1437
|
+
let{namespace:r="default"}=t,n=Ft(r),o=n.get(e);if(!o)return{ok:!0,closed:!1};if(o.closePromise)return o.closePromise;let i=(async()=>{
|
|
1438
|
+
let s=[];if(co(o),!o.processExited){let u=await sa(o,"close");if(u.failures.length)throw uo(o,u.failures)}try{await o.exitCompletion}catch(u){
|
|
1439
|
+
s.push(gt(o,u))}try{await o.scopeDrainCompletion}catch(u){s.push(gt(o,u))}let c=(await Promise.all([o.stopHookCompletion,
|
|
1440
|
+
o.closeHookCompletion])).filter(Boolean);if(o.processExited&&oa(o),s.length>0)throw uo(o,[...s,...c]);return Yp(n,r,e),{
|
|
1441
|
+
ok:!0,closed:!0,...c.length>0?{cleanupErrors:c.map(u=>String(u?.message||u))}:{}}})();o.closePromise=i;try{return await i}finally{
|
|
1442
|
+
o.closePromise===i&&(o.closePromise=null)}}async function sI({namespace:e}){for(let{namespace:t,session:r}of lo({namespace:e})){
|
|
1443
|
+
if(!ta(r)||r.subscribers?.size)continue;let n=xr(r.detachedIdleTimeoutMs);if(!(n<1)){if(ra(r)<n){fo(r,t);continue}await ua(
|
|
1444
|
+
r.id,{namespace:t})}}}var la=b(()=>{K();aa();ca();Gt()});import cI from"node:crypto";import{createRequire as uI}from"node:module";function da(){}function lI(){return!0}function fI({
|
|
1445
|
+
filter:e,namespacePrefix:t}){return lo({namespacePrefix:t,runningOnly:!0}).filter(r=>Lp(r.session,e)).length}function Jp({
|
|
1187
1446
|
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(
|
|
1190
|
-
if(
|
|
1191
|
-
t",error:`Terminal limit reached (${
|
|
1192
|
-
env:
|
|
1193
|
-
env:
|
|
1194
|
-
|
|
1195
|
-
cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:
|
|
1196
|
-
toISOString(),metadata:
|
|
1447
|
+
runningLimitFilter:u=lI,onClose:d=da,onOutput:p=da,onStop:g=da,reuseRunning:h=!1,detachedIdleTimeoutMs:l=0}){let w=Hp(a);
|
|
1448
|
+
if(w)return w;let _=Ft(a),f=cI.randomUUID(),m=typeof h=="function"?h:()=>!!h,y=h?[..._.values()].find(D=>jr(D)&&m(D)):null;
|
|
1449
|
+
if(y)return qe(y);let E=Number(i||0),T=c||a;if(E>0&&fI({filter:u,namespacePrefix:T})>=E)return{ok:!1,code:"terminal_limi\
|
|
1450
|
+
t",error:`Terminal limit reached (${E}).`};let S=typeof o=="function"?o({id:f,namespace:a}):o,v=typeof e=="function"?e({
|
|
1451
|
+
env:S,id:f,namespace:a}):e,R=typeof r=="function"?r({args:v,env:S,id:f,namespace:a}):r,O=typeof s=="function"?s({args:v,
|
|
1452
|
+
env:S,id:f,namespace:a}):s,A=dI("node-pty").spawn(t,v,{cols:io,cwd:n,env:ee(S),name:"xterm-color",rows:so}),$,P=new Promise(
|
|
1453
|
+
D=>{$=D}),C={id:f,closeHookCompletion:null,closePromise:null,commandPreview:R,cols:io,createdAt:new Date().toISOString(),
|
|
1454
|
+
cwd:n,detachedCleanupTimer:null,detachedIdleTimeoutMs:xr(l),exitCompletion:P,exitCode:null,lastSubscriberAttachedAt:"",lastSubscriberDetachedAt:new Date().
|
|
1455
|
+
toISOString(),metadata:O&&typeof O=="object"&&!Array.isArray(O)?O:{},onClose:d,onStop:g,inputVersion:0,lastInputAt:"",lastInputBytes:0,
|
|
1197
1456
|
lastOutputAt:"",lastOutputBytes:0,lastWriteError:"",lastWriteErrorAt:"",lastWriteErrorCode:"",output:"",outputVersion:0,
|
|
1198
|
-
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion
|
|
1199
|
-
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:
|
|
1200
|
-
|
|
1201
|
-
session:
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
execution/src/server/engines/terminalSessions.js",import.meta.url).href;
|
|
1207
|
-
function
|
|
1208
|
-
r real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=
|
|
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:
|
|
1213
|
-
`,{mode:384}),["-n",
|
|
1214
|
-
command:e.command,cwd:n,env:a}}async function
|
|
1215
|
-
{},{onClose:a=
|
|
1216
|
-
commandPreview:s.commandPreview,cwd:
|
|
1217
|
-
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async
|
|
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
|
|
1225
|
-
id Vibe64 command request.");return r.code=t,r}function
|
|
1226
|
-
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function
|
|
1227
|
-
mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw
|
|
1457
|
+
processExited:!1,killStarted:!1,reportedLifecycleFailures:new Set,resolveExitCompletion:$,rows:so,status:"running",stopHookCompletion:null,
|
|
1458
|
+
scopeDrainCompletion:null,namespace:a,subscribers:new Set,terminal:A};return Bp(C),A.onData(D=>{Vp(C,D),C.output=ao(C.output+
|
|
1459
|
+
D),Re(C,{chunk:D,lastOutputAt:C.lastOutputAt,outputVersion:C.outputVersion,type:"output"});try{p({chunk:D,output:C.output,
|
|
1460
|
+
session:qe(C),updateMetadata(Y){return Dp(C,Y)}})}catch(Y){let ae=String(Y?.message||Y||"Terminal output hook failed.");
|
|
1461
|
+
Re(C,{error:ae,type:"error"})}fo(C,a)}),A.onExit(({exitCode:D})=>{C.processExited=!0,C.exitCode=D,C.status="closing",ia(
|
|
1462
|
+
C),Re(C,{exitCode:D,status:C.status,type:"status"}),na(C,C.stopReason||"exit"),C.resolveExitCompletion(),Fp(C)}),Wp(a).set(
|
|
1463
|
+
f,C),fo(C,a),pI(f,{namespace:a})}function pI(e,t={}){let{namespace:r="default",outputLimit:n=0}=t,i=Ft(r).get(e);return i?
|
|
1464
|
+
qe(i,{outputLimit:n}):kp()}var aI,dI,Kp=b(()=>{K();Gt();aa();qp();la();ca();aI=new URL("./../node_modules/@local/vibe64-\
|
|
1465
|
+
execution/src/server/engines/terminalSessions.js",import.meta.url).href;dI=uI(aI)});import{randomUUID as mI}from"node:crypto";import{mkdirSync as hI,writeFileSync as gI}from"node:fs";import fa from"node:path";
|
|
1466
|
+
function yI(){}function wI(e=""){let t=String(e||"").trim();if(!t){let n=new Error("A helper payload root is required fo\
|
|
1467
|
+
r real-user PTY execution.");throw n.code="vibe64_command_pty_helper_payload_root_required",n}let r=fa.join(fa.resolve(t),
|
|
1468
|
+
"exec-helper-payloads");return hI(r,{mode:448,recursive:!0}),fa.join(r,`${process.pid}-${Date.now()}-${mI()}.json`)}function _I(e,t){
|
|
1469
|
+
let{actor:r,cwd:n,env:o,resolveEnv:i}=t,s=e.terminal||{},a=e.envFactory?i:o;return Jn(r)?{args:(c={})=>{let u=wI(s.helperPayloadRoot),
|
|
1470
|
+
d=typeof e.args=="function"?e.args(c):e.args,p=qn({actor:r,args:d,command:e.command,cwd:n,env:typeof a=="function"?a(c):
|
|
1471
|
+
a,input:e.input,operation:Tr(e)});return gI(u,`${JSON.stringify(p)}
|
|
1472
|
+
`,{mode:384}),["-n",Ns(),"execute",u]},command:"sudo",cwd:s.helperPayloadRoot,env:{PATH:process.env.PATH||Nr}}:{args:e.args,
|
|
1473
|
+
command:e.command,cwd:n,env:a}}async function Zp(e={},t={}){let{actor:r,cwd:n,env:o,resolveEnv:i}=t;try{let s=e.terminal||
|
|
1474
|
+
{},{onClose:a=yI}=s,c=e.execution?.id||"",u=_I(e,{actor:r,cwd:n,env:o,resolveEnv:i}),d=Jp({args:u.args,command:u.command,
|
|
1475
|
+
commandPreview:s.commandPreview,cwd:u.cwd,detachedIdleTimeoutMs:s.detachedIdleTimeoutMs,env:u.env,maxRunning:s.maxRunning,
|
|
1476
|
+
metadata:s.metadata,namespace:s.namespace,namespaceLimitPrefix:s.namespaceLimitPrefix,onClose:async p=>{try{await a(p)}finally{
|
|
1477
|
+
c&&Xp.set(c,{id:p.id,namespace:s.namespace,scopeEmpty:!0})}},onOutput:s.onOutput,onStop:s.onStop,reuseRunning:s.reuseRunning,
|
|
1478
|
+
runningLimitFilter:s.runningLimitFilter});return d?.ok===!0&&c&&Xp.set(c,{id:d.id,namespace:s.namespace}),d?.ok===!0?{...d,
|
|
1479
|
+
execution:e.execution}:d}catch(s){return te(s?.message||"Vibe64 PTY command failed.",s?.code||"vibe64_command_pty_failed",
|
|
1480
|
+
{execution:e.execution})}}var Xp,pa=b(()=>{ut();oo();Kp();la();Wn();Kn();Xp=new Map});import{realpathSync as Qp}from"node:fs";function bI(e=""){return x(e||process.cwd())}function em(e="",t={}){let{allowedRoots:r=[],
|
|
1481
|
+
resolveLinks:n=!0}=t,o=bI(e),i=(Array.isArray(r)?r:[r]).map(x).filter(Boolean);if(i.length===0)return o;let s=i.filter(c=>ze(
|
|
1482
|
+
c,o));if(s.length>0){if(!n)return o;let c=Qp(o);if(s.some(u=>ze(Qp(u),c)))return c}let a=new Error("Vibe64 command cwd i\
|
|
1483
|
+
s outside the allowed roots.");throw a.code="vibe64_command_cwd_outside_allowed_roots",a}var tm=b(()=>{K()});import{randomUUID as EI}from"node:crypto";function se(e="",t="vibe64_command_request_invalid"){let r=new Error(e||"Inval\
|
|
1484
|
+
id Vibe64 command request.");return r.code=t,r}function We(e="",t=[],r="",n="value"){let o=j(e)||r;if(!t.includes(o))throw se(
|
|
1485
|
+
`Unsupported Vibe64 command ${n}: ${o||"(empty)"}.`,`vibe64_command_${n}_unsupported`);return o}function xI(e=[],t={}){let{
|
|
1486
|
+
mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw se("Function-valued command args are only supported for \
|
|
1228
1487
|
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
|
|
1232
|
-
let t=
|
|
1233
|
-
maxRunning:t.maxRunning,metadata:t.metadata,namespace:
|
|
1234
|
-
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function
|
|
1235
|
-
let t=
|
|
1236
|
-
gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?Number(t.gid??t.hostGid):null,home:r,scope:
|
|
1237
|
-
uid:Number.isSafeInteger(Number(t.uid??t.hostUid))?Number(t.uid??t.hostUid):null,username:
|
|
1238
|
-
t.userKey)}:{}}function
|
|
1239
|
-
capture",purpose:t="terminal"}={}){return t==="preview"?"preview":e==="pty"?"terminal":"job"}function
|
|
1240
|
-
if(!t)return"";if(!/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,254}[A-Za-z0-9])?$/u.test(t))throw
|
|
1241
|
-
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function
|
|
1242
|
-
purpose:o="terminal",session:i={}}=t,s=
|
|
1243
|
-
|
|
1244
|
-
throw
|
|
1245
|
-
s.ownerId||i.sessionId);if(c==="service"&&!
|
|
1246
|
-
_owner_required");let
|
|
1247
|
-
lityKey","environment"].includes(
|
|
1248
|
-
"")||!["development","test","
|
|
1249
|
-
|
|
1250
|
-
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:
|
|
1251
|
-
id:
|
|
1252
|
-
projectSlug:
|
|
1253
|
-
"string"||!/^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/iu.test(e))throw
|
|
1254
|
-
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function
|
|
1255
|
-
e)?
|
|
1256
|
-
imes"),n=
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
"Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=
|
|
1260
|
-
{mode:n}),s=
|
|
1261
|
-
Vibe64 runtime: ${
|
|
1262
|
-
"";if(typeof
|
|
1263
|
-
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw
|
|
1264
|
-
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let
|
|
1265
|
-
"";if(typeof
|
|
1266
|
-
pp"))throw
|
|
1267
|
-
ding_preload_invalid");let
|
|
1268
|
-
ure"))throw
|
|
1269
|
-
let h=t.sandboxAllowances??[];if(!Array.isArray(h)||h.some(
|
|
1270
|
-
h).size!==h.length||h.length>0&&!
|
|
1271
|
-
vibe64_command_sandbox_allowances_invalid");return{actor:
|
|
1272
|
-
t.allowedRoots),args:
|
|
1273
|
-
envPolicy:
|
|
1274
|
-
{mode:n,project:c,purpose:s,session:
|
|
1275
|
-
t.gitSafeDirectories),personGitIdentity:{email:
|
|
1276
|
-
t.gitTransport,
|
|
1277
|
-
maxBuffer:Number.isSafeInteger(Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):
|
|
1278
|
-
onOutput=="function"?t.onOutput:null,outputEncoding:
|
|
1279
|
-
runtimes:a,session:
|
|
1280
|
-
Number(t.timeout))&&Number(t.timeout)>0?Number(t.timeout):15e3,usageRecordingPreload:
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
loyment","health","workspace-cache","source"]),
|
|
1284
|
-
base64"]),
|
|
1285
|
-
"github-token"]),
|
|
1286
|
-
["finite","interactive","service"]),
|
|
1287
|
-
ce","terminal"]);
|
|
1288
|
-
()=>{
|
|
1289
|
-
function
|
|
1290
|
-
push(
|
|
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
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=
|
|
1298
|
-
|
|
1299
|
-
e.mode==="detached"?r.requiresRealUser&&(!
|
|
1300
|
-
|
|
1301
|
-
{...await
|
|
1302
|
-
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:
|
|
1488
|
+
function kI(e={},t={}){let{mode:r="capture"}=t;if(typeof e=="function"){if(r!=="pty")throw se("Function-valued command e\
|
|
1489
|
+
nv is only supported for PTY commands.","vibe64_command_env_function_requires_pty");return{env:{},envFactory:e}}let n=ye(
|
|
1490
|
+
e);return zt(n),{env:n,envFactory:null}}function ma(e=[]){return(Array.isArray(e)?e:[e]).map(x).filter(Boolean)}function $I(e={}){
|
|
1491
|
+
let t=ee(e);return{commandPreview:t.commandPreview,detachedIdleTimeoutMs:t.detachedIdleTimeoutMs,helperPayloadRoot:x(t.helperPayloadRoot),
|
|
1492
|
+
maxRunning:t.maxRunning,metadata:t.metadata,namespace:j(t.namespace),namespaceLimitPrefix:j(t.namespaceLimitPrefix),onClose:t.
|
|
1493
|
+
onClose,onOutput:t.onOutput,onStop:t.onStop,reuseRunning:t.reuseRunning,runningLimitFilter:t.runningLimitFilter}}function LI(e={}){
|
|
1494
|
+
let t=ee(e),r=x(t.home||t.toolHomeSource);return r?{cacheRoot:x(t.cacheRoot),configRoot:x(t.configRoot),dataRoot:x(t.dataRoot),
|
|
1495
|
+
gid:Number.isSafeInteger(Number(t.gid??t.hostGid))?Number(t.gid??t.hostGid):null,home:r,scope:j(t.scope),stateRoot:x(t.stateRoot),
|
|
1496
|
+
uid:Number.isSafeInteger(Number(t.uid??t.hostUid))?Number(t.uid??t.hostUid):null,username:j(t.username||t.ownerUserKey||
|
|
1497
|
+
t.userKey)}:{}}function MI(e="capture"){return e==="detached"?"service":e==="pty"?"interactive":"finite"}function DI({mode:e="\
|
|
1498
|
+
capture",purpose:t="terminal"}={}){return t==="preview"?"preview":e==="pty"?"terminal":"job"}function Ht(e=""){let t=j(e);
|
|
1499
|
+
if(!t)return"";if(!/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,254}[A-Za-z0-9])?$/u.test(t))throw se(`Invalid Vibe64 execution ide\
|
|
1500
|
+
ntifier: ${t}.`,"vibe64_execution_identifier_invalid");return t}function nm(e={},t={}){let{mode:r="capture",project:n={},
|
|
1501
|
+
purpose:o="terminal",session:i={}}=t,s=ee(e),a=We(s.kind,PI,DI({mode:r,purpose:o}),"execution_kind"),c=We(s.lifecycle,CI,
|
|
1502
|
+
MI(r),"execution_lifecycle");if(r==="detached"&&c!=="service"||r==="pty"&&c!=="interactive"||r==="capture"&&c!=="finite")
|
|
1503
|
+
throw se(`Execution lifecycle ${c} is incompatible with command mode ${r}.`,"vibe64_execution_lifecycle_incompatible");let u=Ht(
|
|
1504
|
+
s.ownerId||i.sessionId);if(c==="service"&&!u)throw se("Service execution requires a durable owner id.","vibe64_execution\
|
|
1505
|
+
_owner_required");let d=s.resourceProfile;if(d!=null&&(!d||typeof d!="object"||Object.keys(d).some(p=>!["key","compatibi\
|
|
1506
|
+
lityKey","environment"].includes(p))||!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(d.key||"")||!/^[a-f0-9]{64}$/u.test(d.compatibilityKey||
|
|
1507
|
+
"")||!["development","test","staging"].includes(d.environment)))throw se("Invalid activity resource profile identity.","\
|
|
1508
|
+
vibe64_resource_profile_invalid");return Object.freeze({...d?{resourceProfile:Object.freeze({...d})}:{},controlGenerationId:Ht(
|
|
1509
|
+
s.controlGenerationId),...s.workflowId===void 0||s.workflowId===null||s.workflowId===""?{}:{workflowId:VI(s.workflowId)},
|
|
1510
|
+
id:EI(),kind:a,label:j(s.label),lifecycle:c,operationId:Ht(s.operationId),ownerId:u,parentExecutionId:Ht(s.parentExecutionId),
|
|
1511
|
+
projectSlug:Ht(s.projectSlug||n.slug||n.projectSlug),sessionId:Ht(s.sessionId||i.sessionId)})}function VI(e){if(typeof e!=
|
|
1512
|
+
"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 se("Execution req\
|
|
1513
|
+
uires a valid managed workflow id.","vibe64_workflow_id_invalid");return e.toLowerCase()}function UI(e=""){return jI.has(
|
|
1514
|
+
e)?Gs:[]}function rm(e={},t=""){return Object.prototype.hasOwnProperty.call(e,t)}function BI(e={},t=""){let r=rm(e,"runt\
|
|
1515
|
+
imes"),n=rm(e,"runtime");if(!r&&!n)return ct(UI(t));let o=r?e.runtimes:e.runtime;return ct((Array.isArray(o)?o:[o]).map(
|
|
1516
|
+
j).filter(Boolean))}function om(e={}){let t=ee(e),r=j(t.command);if(!r)throw se("A command is required.","vibe64_command\
|
|
1517
|
+
_required");let n=We(t.mode,II,"capture","mode");if(t.signal!=null&&(!(t.signal instanceof AbortSignal)||n!=="capture"))
|
|
1518
|
+
throw se("Cancellation signals require a finite capture command.","vibe64_command_signal_invalid");let o=ye(t.baseEnv),i=kI(
|
|
1519
|
+
t.env,{mode:n}),s=We(t.purpose,TI,"terminal","purpose"),a=BI(t,s);for(let l of a)if(!Object.hasOwn(Bt,l))throw se(`Unsup\
|
|
1520
|
+
ported Vibe64 runtime: ${l}.`,"vibe64_command_runtime_unsupported");let c=ee(t.project),u=ee(t.session),d=t.releaseEnvironmentFile??
|
|
1521
|
+
"";if(typeof d!="string"||d&&(!d.startsWith("/")||/[\r\n\0]/u.test(d)||n!=="capture"||t.actor!=="app"||t.envPolicy!=="de\
|
|
1522
|
+
ployment"||Object.keys(i.env).length||i.envFactory||Object.keys(o).length))throw se("Release environment files require a\
|
|
1523
|
+
finite application deployment command without caller Env.","vibe64_command_release_environment_invalid");let p=t.usageRecordingPreload??
|
|
1524
|
+
"";if(typeof p!="string"||p&&(!p.startsWith("/")||/[\s"'\\\0]/u.test(p)||!["preview","output"].includes(s)||t.actor==="a\
|
|
1525
|
+
pp"))throw se("A usage recording preload belongs only to a Preview or Output target launch.","vibe64_command_usage_recor\
|
|
1526
|
+
ding_preload_invalid");let g=t.applicationAccount??"";if(typeof g!="string"||g&&(!vI.test(g)||t.actor!=="app"||n!=="capt\
|
|
1527
|
+
ure"))throw se("Application accounts run only finite application commands.","vibe64_command_application_account_invalid");
|
|
1528
|
+
let h=t.sandboxAllowances??[];if(!Array.isArray(h)||h.some(l=>typeof l!="string"||!/^[a-z][a-z0-9-]*$/u.test(l))||new Set(
|
|
1529
|
+
h).size!==h.length||h.length>0&&!g)throw se("Sandbox allowances belong only to an application account's own commands.","\
|
|
1530
|
+
vibe64_command_sandbox_allowances_invalid");return{actor:We(t.actor,SI,"daemon","actor"),applicationAccount:g,allowedRoots:ma(
|
|
1531
|
+
t.allowedRoots),args:xI(t.args,{mode:n}),baseEnv:o,command:r,cwd:x(t.cwd||process.cwd()),env:i.env,envFactory:i.envFactory,
|
|
1532
|
+
envPolicy:We(t.envPolicy,RI,"session","env_policy"),releaseEnvironmentFile:d,sandboxAllowances:[...h],execution:nm(t.execution,
|
|
1533
|
+
{mode:n,project:c,purpose:s,session:u}),credentialHome:LI(t.credentialHome),gitAuthToken:j(t.gitAuthToken),gitSafeDirectories:ma(
|
|
1534
|
+
t.gitSafeDirectories),personGitIdentity:{email:j(t.personGitIdentity?.email),name:j(t.personGitIdentity?.name)},gitTransport:We(
|
|
1535
|
+
t.gitTransport,AI,"none","git_transport"),inheritProcessEnv:!d&&t.inheritProcessEnv!==!1,input:t.input,logPath:x(t.logPath),
|
|
1536
|
+
maxBuffer:Number.isSafeInteger(Number(t.maxBuffer))&&Number(t.maxBuffer)>0?Number(t.maxBuffer):NI,mode:n,onOutput:typeof t.
|
|
1537
|
+
onOutput=="function"?t.onOutput:null,outputEncoding:We(t.outputEncoding,OI,"utf8","output_encoding"),project:c,purpose:s,
|
|
1538
|
+
runtimes:a,session:u,signal:t.signal??null,shimDirs:ma(t.shimDirs),terminal:$I(t.terminal),timeout:Number.isSafeInteger(
|
|
1539
|
+
Number(t.timeout))&&Number(t.timeout)>0?Number(t.timeout):15e3,usageRecordingPreload:p,userKey:j(t.userKey)}}var SI,vI,TI,
|
|
1540
|
+
II,OI,RI,AI,PI,CI,NI,jI,yL,im=b(()=>{K();ro();Oe();SI=Object.freeze(["daemon","owner-user","named-user","app"]),vI=/^[a-z_][a-z0-9_-]{0,31}$/u,
|
|
1541
|
+
TI=Object.freeze(["account","assistant","terminal","codex","github","github-api","source-editor","preview","output","dep\
|
|
1542
|
+
loyment","health","workspace-cache","source"]),II=Object.freeze(["capture","pty","detached"]),OI=Object.freeze(["utf8","\
|
|
1543
|
+
base64"]),RI=Object.freeze(["session","project","preview","auth","deployment"]),AI=Object.freeze(["none","github-https",
|
|
1544
|
+
"github-token"]),PI=Object.freeze(["assistant","browser","control","job","preview","service","terminal"]),CI=Object.freeze(
|
|
1545
|
+
["finite","interactive","service"]),NI=1e3*1e3*100,jI=new Set(["assistant","codex","deployment","output","preview","sour\
|
|
1546
|
+
ce","terminal"]);yL=Object.freeze({normalizeExecutionDescriptor:nm})});function ha(){return zI}function po(e){return["1","true"].includes(String(e[sm]||"").trim().toLowerCase())}var zI,sm,mo=b(
|
|
1547
|
+
()=>{vr();Er();pa();ut();zI=null,sm="VIBE64_MANAGED_EXECUTION_REQUIRED"});import{realpathSync as am,statSync as FI}from"node:fs";import Ye from"node:path";import{fileURLToPath as HI}from"node:url";
|
|
1548
|
+
function qI(e){let t=[Ye.resolve(Ye.dirname(e),"../../../vibe64-usage-recording/runtime/node")];for(let r=Ye.dirname(e);t.
|
|
1549
|
+
push(Ye.join(r,"node_modules/@local/vibe64-usage-recording/runtime/node")),Ye.dirname(r)!==r;r=Ye.dirname(r));return t.flatMap(
|
|
1550
|
+
r=>{try{return[am(r)]}catch{return[]}})}function cm(e="",t=HI(GI)){try{if(Ye.resolve(e)===e&&am(e)===e&&FI(e).isFile()&&
|
|
1551
|
+
qI(t).some(r=>e.startsWith(`${r}${Ye.sep}`)))return`--import=${e}`}catch{}throw Object.assign(new Error("The usage recor\
|
|
1552
|
+
der is not part of this Vibe64 installation."),{code:"vibe64_usage_recording_preload_invalid"})}var GI,um=b(()=>{GI=new URL(
|
|
1553
|
+
"./../node_modules/@local/vibe64-execution/src/server/usageRecordingPreload.js",import.meta.url).href});function lm(e){return e.releaseEnvironmentFile?te("Release environment execution requires a managed host.","vibe64_relea\
|
|
1554
|
+
se_environment_unavailable",{execution:e.execution}):e.applicationAccount?te("Application account execution requires a m\
|
|
1555
|
+
anaged host.","vibe64_application_account_unavailable",{execution:e.execution}):null}async function WI(e,t={}){let{actor:r,
|
|
1556
|
+
cwd:n,env:o,requiresHelper:i,resolveEnv:s}=t,a=lm(e);if(a)return a;if(e.usageRecordingPreload){let c=cm(e.usageRecordingPreload),
|
|
1557
|
+
u=s;o={...o,NODE_OPTIONS:c},s=d=>({...u(d),NODE_OPTIONS:c})}return e.mode==="pty"?Zp(e,{actor:r,cwd:n,env:o,resolveEnv:s}):
|
|
1558
|
+
e.mode==="detached"?r.requiresRealUser&&(!Vt(r)||i)?te("Detached real-user command execution is unsupported when the hel\
|
|
1559
|
+
per is required.","vibe64_command_detached_real_user_unsupported",{execution:e.execution}):Ef(e,{actor:r,cwd:n,env:o}):i?
|
|
1560
|
+
{...await js(qn({actor:r,args:e.args,command:e.command,cwd:n,env:o,input:e.input,operation:Tr(e)}),{env:process.env,maxBuffer:e.
|
|
1561
|
+
maxBuffer,outputEncoding:e.outputEncoding,signal:e.signal,timeout:e.timeout}),execution:e.execution}:Sr(e.command,e.args,
|
|
1303
1562
|
{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
|
|
1305
|
-
|
|
1306
|
-
...t.baseEnv}:{...t.baseEnv},o=(
|
|
1307
|
-
r),
|
|
1308
|
-
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),
|
|
1309
|
-
|
|
1310
|
-
args=="function"?t.args(
|
|
1311
|
-
...t,env:t.envFactory(
|
|
1312
|
-
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:
|
|
1313
|
-
(s?
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,
|
|
1318
|
-
6e4,
|
|
1319
|
-
e||"").trim();return
|
|
1320
|
-
function
|
|
1321
|
-
r)&&
|
|
1322
|
-
"darwin"&&
|
|
1323
|
-
"brew"&&!o&&["git","cpp"].includes(
|
|
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
|
-
|
|
1563
|
+
signal:e.signal,timeout:e.timeout})}async function qt(e={}){let t=null;try{if(t=om(e),t.signal?.aborted)return te("Comma\
|
|
1564
|
+
nd cancelled.","vibe64_command_cancelled",{execution:t.execution});let r=await Lf(t),n=t.inheritProcessEnv?{...process.env,
|
|
1565
|
+
...t.baseEnv}:{...t.baseEnv},o=(f={})=>({...f,VIBE64_EXECUTION_ID:t.execution.id}),i=ha(),s=po(n)||po(process.env),a=Jn(
|
|
1566
|
+
r),u=!(!!i||s||Us())&&Vt(r)?[n.PATH,process.env.PATH].filter(Boolean).join(":"):"",d=o(await jp({actor:r,baseEnv:n,localPath:u,
|
|
1567
|
+
request:t.releaseEnvironmentFile?{...t,project:{},session:{}}:t})),p=Object.fromEntries([pt,ft,ht,mt].map(f=>[f,d[f]]));
|
|
1568
|
+
Uf(r,d);let g=em(t.cwd,{allowedRoots:t.allowedRoots,resolveLinks:!t.applicationAccount});Vf(r,t,g);let h=(f={})=>typeof t.
|
|
1569
|
+
args=="function"?t.args(f):t.args,l=(f={})=>o(t.envFactory?Qs({actor:r,baseEnv:n,localPath:u,resolvedGitIdentityEnv:p,request:{
|
|
1570
|
+
...t,env:t.envFactory(f),envFactory:null}}):d),w=(f=t,m={})=>WI(f,{actor:r,cwd:g,env:d,requiresHelper:a,resolveEnv:l,...m});
|
|
1571
|
+
if(i)return await i.runCommand(t,{actor:r,baseEnv:n,cwd:g,env:d,resolveArgs:h,resolveEnv:l,runLocal:w});let _=lm(t);return _||
|
|
1572
|
+
(s?te("Managed execution safety is unavailable. Vibe64 did not start this work.","vibe64_managed_execution_provider_unav\
|
|
1573
|
+
ailable",{execution:t.execution,retryable:!1}):w())}catch(r){return te(r?.message||"Vibe64 command failed.",r?.code||"vi\
|
|
1574
|
+
be64_command_failed",{execution:t?.execution})}}var ho=b(()=>{Mf();ea();Ut();vr();Wn();Er();pa();tm();Kn();im();ut();mo();
|
|
1575
|
+
um()});import{fileURLToPath as JI}from"node:url";var YI,YL,JL,KL,XL,dm=b(()=>{ke();YI=new URL("./../node_modules/@local/vibe64-\
|
|
1576
|
+
execution/src/server/gitTurnCheckpoint.js",import.meta.url).href,YL=JI(new URL("./gitTurnCheckpointCommand.js",YI)),JL=15*
|
|
1577
|
+
6e4,KL=512*1024*1024,XL=1024*1024*1024});var eM,fm=b(()=>{K();eM=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"])});var pm=b(()=>{});import{existsSync as KI}from"node:fs";import go from"node:path";import mm from"node:process";function ga(e=""){let t=String(
|
|
1578
|
+
e||"").trim();return ZI[t]||t}function gm({platform:e=mm.platform,aptGet:t=!1}={}){return e==="darwin"?"brew":t?"apt":""}
|
|
1579
|
+
function QI(e,t=Nr){return[...String(e.PATH||"").split(go.delimiter),...String(t||"").split(go.delimiter)].some(r=>go.isAbsolute(
|
|
1580
|
+
r)&&KI(go.join(r,"apt-get")))}function wo({env:e,platform:t=mm.platform,systemPath:r}){return gm({platform:t,aptGet:t!==
|
|
1581
|
+
"darwin"&&QI(e,r)})}function _o(e="",t={}){let{family:r="",mise:n=!1,xcode:o=!0}=t,i=yo[ga(e)];if(!i)return null;if(r===
|
|
1582
|
+
"brew"&&!o&&["git","cpp"].includes(ga(e)))return{command:"xcode-select --install",sudo:!1,note:""};let s=i.any||i[r]||"";
|
|
1583
|
+
if(!s&&i.mise&&(s=n?`mise use -g ${i.mise}`:`${XI} && ~/.local/bin/mise use -g ${i.mise}`),!s)return null;let a=s.startsWith(
|
|
1584
|
+
"sudo ")||r==="apt"&&s.includes("--with-deps");return{command:s,sudo:a,note:a?hm:""}}var hm,XI,aM,yo,ZI,cM,kr=b(()=>{oo();
|
|
1585
|
+
hm="You'll be asked for your computer password. Nothing shows while you type.",XI="curl -fsSL https://mise.run | sh",aM=
|
|
1327
1586
|
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"}),
|
|
1587
|
+
https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),yo=Object.freeze({claude:{
|
|
1329
1588
|
name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://claude.ai/i\
|
|
1330
1589
|
nstall.sh | bash"},codex:{name:"Codex",run:[["codex"]],guideUrl:"https://github.com/openai/codex",any:"curl -fsSL https:\
|
|
1331
1590
|
//chatgpt.com/codex/install.sh | sh"},opencode:{name:"opencode",run:[["opencode"]],guideUrl:"https://opencode.ai/docs/",
|
|
@@ -1349,17 +1608,17 @@ rl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -fsSL https
|
|
|
1349
1608
|
ild tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/install_ruby\
|
|
1350
1609
|
_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"sudo apt i\
|
|
1351
1610
|
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
|
|
1611
|
+
brew install pkg-config libyaml openssl@3 gmp"}}),ZI=Object.freeze({composer:"php"});cM=Object.freeze({SUDO_NOTE:hm,localToolFamily:gm})});function ym({env:e,platform:t,systemPath:r}){return _o("git",{family:wo({env:e,platform:t,systemPath:r})})?.command||""}
|
|
1612
|
+
function eO(e={}){return[e.error,e.stderr,e.output].filter(Boolean).join(`
|
|
1613
|
+
`)}function tO(e,t){let r=eO(e);if(/spawn(?:Sync)? git ENOENT|(?:^|\s)git: (?:command )?not found/mu.test(r)){let n=ym(t);
|
|
1355
1614
|
return{code:"vibe64_git_missing",installCommand:n,message:n?`Git isn't installed on this computer. Install it with: ${n}`:
|
|
1356
1615
|
"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:
|
|
1616
|
+
{code:"vibe64_git_too_old",installCommand:ym(t),message:"This Git is too old for Vibe64. Update Git to version 2.28 or n\
|
|
1358
1617
|
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
1618
|
test(r)?{code:"vibe64_git_signing_failed",installCommand:"",message:"Your Git is set to sign every commit, and signing d\
|
|
1360
1619
|
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",
|
|
1620
|
+
s and is unlocked, then try again."}:null}var dM,wm=b(()=>{kr();dM=Object.freeze({describeGitFailure:tO})});var ya=b(()=>{});import _m from"node:path";function oO(e=""){return e?_m.join(_m.dirname(e),bm):""}var bm,Em,nO,gM,yM,Sm=b(()=>{ya();bm="\
|
|
1621
|
+
backups.git",Em="vibe64-atomic",nO=`backup_canonical_ref() {
|
|
1363
1622
|
vibe64_backup_repository="$1"
|
|
1364
1623
|
vibe64_source_repository="$2"
|
|
1365
1624
|
vibe64_source_ref="$3"
|
|
@@ -1377,13 +1636,13 @@ r "$vibe64_backup_repository" rev-parse --verify "$vibe64_backup_ref"
|
|
|
1377
1636
|
' "$vibe64_source_ref" >&2
|
|
1378
1637
|
return 1
|
|
1379
1638
|
fi
|
|
1380
|
-
}`,
|
|
1639
|
+
}`,gM=`#!/bin/sh
|
|
1381
1640
|
set -eu
|
|
1382
1641
|
|
|
1383
1642
|
zero_object=0000000000000000000000000000000000000000
|
|
1384
1643
|
git_dir="$(git rev-parse --absolute-git-dir)"
|
|
1385
1644
|
repository_root="$(dirname "$git_dir")"
|
|
1386
|
-
backup_repository="$repository_root/${
|
|
1645
|
+
backup_repository="$repository_root/${bm}"
|
|
1387
1646
|
if [ -L "$repository_root" ] || [ -L "$backup_repository" ] || [ -L "$repository_root/mutation.lock" ]; then
|
|
1388
1647
|
printf '[vibe64] Canonical repository storage must not use symlinked role paths.
|
|
1389
1648
|
' >&2
|
|
@@ -1392,7 +1651,7 @@ fi
|
|
|
1392
1651
|
exec 8>"$repository_root/mutation.lock"
|
|
1393
1652
|
flock -x 8
|
|
1394
1653
|
|
|
1395
|
-
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${
|
|
1654
|
+
if [ "\${GIT_PUSH_OPTION_COUNT:-0}" != "1" ] || [ "\${GIT_PUSH_OPTION_0:-}" != "${Em}" ]; then
|
|
1396
1655
|
printf '[vibe64] Canonical repository pushes must use the Vibe64 atomic mutation path.
|
|
1397
1656
|
' >&2
|
|
1398
1657
|
exit 1
|
|
@@ -1403,7 +1662,7 @@ if [ "$(git --git-dir "$backup_repository" rev-parse --is-bare-repository 2>/dev
|
|
|
1403
1662
|
exit 1
|
|
1404
1663
|
fi
|
|
1405
1664
|
|
|
1406
|
-
${
|
|
1665
|
+
${nO}
|
|
1407
1666
|
|
|
1408
1667
|
updates_file="$(mktemp "$repository_root/.pre-receive.XXXXXX")"
|
|
1409
1668
|
cleanup_updates_file() {
|
|
@@ -1451,8 +1710,8 @@ while read -r old_object _new_object ref_name; do
|
|
|
1451
1710
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
1452
1711
|
fi
|
|
1453
1712
|
done <"$updates_file"
|
|
1454
|
-
`;
|
|
1455
|
-
wserWorkerSource.js",import.meta.url).href});var
|
|
1713
|
+
`;yM=Object.freeze({CANONICAL_REPOSITORY_PUSH_OPTION:Em,canonicalRepositoryBackupPath:oO})});var vm=b(()=>{Ar();Oe()});var wa=b(()=>{});var Tm=b(()=>{});var Im=b(()=>{});var _a=b(()=>{});var AM,Om=b(()=>{Tm();Im();_a();AM=new URL("./../node_modules/@local/vibe64-execution/src/server/runtime/agentPreviewBro\
|
|
1714
|
+
wserWorkerSource.js",import.meta.url).href});var sO,Rm=b(()=>{sO=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms\
|
|
1456
1715
|
>]"," vibe64-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [\
|
|
1457
1716
|
--json]"," vibe64-helper preview open <path> [--json]"," vibe64-helper preview inspect-url"," vibe64-helper preview s\
|
|
1458
1717
|
creenshot [--output <path>]"," vibe64-helper preview browser ensure"," vibe64-helper preview browser eval < playwright\
|
|
@@ -1495,328 +1754,710 @@ ical preview server for the configured primary application.","Do not start a dup
|
|
|
1495
1754
|
er port.","A distinct secondary application explicitly requested by the user, such as a reference app, may run separatel\
|
|
1496
1755
|
y without replacing this preview."].join(`
|
|
1497
1756
|
`)+`
|
|
1498
|
-
`});var
|
|
1499
|
-
-execution/src/server/conversationExecution.js",import.meta.url).href,
|
|
1757
|
+
`});var Am=b(()=>{});import{fileURLToPath as dO}from"node:url";var lO,VM,Pm=b(()=>{ho();mo();ke();lO=new URL("./../node_modules/@local/vibe64\
|
|
1758
|
+
-execution/src/server/conversationExecution.js",import.meta.url).href,VM=dO(new URL("./engines/stdioBridge.js",lO))});var HM,Cm=b(()=>{ho();kr();Oe();HM=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$nam\
|
|
1500
1759
|
e" 2>/dev/null) || continue'," case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /us\
|
|
1501
1760
|
r/bin/*) continue ;; esac; fi',` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
1502
|
-
`)});var
|
|
1503
|
-
any:n}=
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1761
|
+
`)});var fO,Nm=b(()=>{kr();Oe();fO=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,
|
|
1762
|
+
any:n}=yo[e];return[e,Object.freeze({name:t,guideUrl:r,install:n})]})))});import{execFile as pO}from"node:child_process";import{promisify as mO}from"node:util";var ZM,jm=b(()=>{ZM=mO(pO)});var ba=b(()=>{zn();lf();Mt();Wn();$f();ho();vr();ut();mo();dm();ea();fm();pm();ro();Xs();Ut();wm();ya();Sm();K();Ar();ke();
|
|
1763
|
+
Oe();vm();wa();Om();_a();Rm();Am();Pm();kr();Cm();Nm();jm();wa()});var Ea=b(()=>{le()});import xm from"node:path";function yO(e=""){let t=St(e);return t?xm.join(xm.resolve(t),hO,gO):""}var hO,gO,q4,km=b(()=>{
|
|
1764
|
+
yr();le();U();hO="runtime",gO="open.json";q4=Object.freeze({projectRuntimeOpenStatePath:yO})});var $r=b(()=>{ba();le();$t();Ea();Vn();Un();km();Ue();Mn();Ve()});var Vm=b(()=>{le();$t();kt();Vn();Un();Ue();$r()});var Bm=b(()=>{le();kt();Ue();$r()});var Fm=b(()=>{le();$t();kt();Ea();Vn();Un();Ue();$r()});var Hm=b(()=>{le();kt();Mn();Ue();$t();Vm();Bm();Fm();$r()});var qm=b(()=>{});var Wm,NO,jO,xV,kV,Ym=b(()=>{qm();Wm="vibe64_learning_mode_project",NO="You're in Learn mode. Press L to go back to your\
|
|
1765
|
+
projects.",jO="This is a practice project. Press L to switch to Learn.",xV=Object.freeze({on:!1,currentAttemptId:"",lessonCode:"",
|
|
1766
|
+
practiceSlug:""}),kV=Object.freeze({LEARNING_MODE_PROJECT_MESSAGE:NO,PRACTICE_PROJECT_MODE_MESSAGE:jO})});var Jm=b(()=>{});var Km,Xm=b(()=>{Ve();Jm();Km="vibe64_team_ai_required"});function Zm(){return String(tf()?.projectRuntimeRoot||"").trim()}var eU,Qm=b(()=>{Hm();le();$t();Ym();Xm();kt();eU=Object.
|
|
1767
|
+
freeze({vibe64_invalid_project_slug:422,vibe64_project_route_unavailable:404,[Wm]:403,[Km]:403,vibe64_project_path_not_accessible:404,
|
|
1768
|
+
[of]:404,vibe64_project_path_not_directory:409,vibe64_project_path_symlink:409})});import{appendFile as xO,mkdir as kO,readdir as $O,rename as LO,stat as eh,unlink as MO}from"node:fs/promises";import Lr from"node:path";
|
|
1769
|
+
function Ta(e,t){let r=Lr.join(e,va);return Object.freeze({current:Lr.join(r,`${t}.jsonl`),directory:r,previous:Lr.join(
|
|
1770
|
+
r,`${t}.1.jsonl`)})}function Sa(e){if(typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;
|
|
1771
|
+
if(typeof e!="string")return;let t=$n(e).replace(/\s+/gu," ").trim();if(t)return t.length>th?`${t.slice(0,th-1)}\u2026`:
|
|
1772
|
+
t}function FO(e,t){let r=Sa(e?.kind),n=Sa(e?.event);if(!Mr.includes(r)||!n)return null;let o={at:t.toISOString(),kind:r,
|
|
1773
|
+
event:n},i=0;for(let[s,a]of Object.entries(e)){if(s==="kind"||s==="event"||s==="at"||!GO.test(s))continue;let c=Sa(a);if(c!==
|
|
1774
|
+
void 0&&(o[s]=c,++i>=BO))break}return`${JSON.stringify(o)}
|
|
1775
|
+
`}function HO({fileBytes:e=DO,retentionMs:t=VO,now:r=Date.now}={}){let n=new Map,o=new Map,i=new Set;function s(l,w){let _=`${l}\
|
|
1776
|
+
|
|
1777
|
+
${w}`,f=n.get(_);if(f?n.delete(_):f={paths:Ta(l,w),projectRuntimeRoot:l,sessionId:w,lines:[],queuedLength:0,size:null,pending:null},
|
|
1778
|
+
n.set(_,f),n.size>rh)for(let[m,y]of n){if(n.size<=rh)break;y.pending||n.delete(m)}return f}async function a(l){let w=r()-
|
|
1779
|
+
t,_=await $O(l).catch(()=>[]),f=new Map;for(let m of n.values())f.set(m.paths.current,m),f.set(m.paths.previous,m);for(let m of _){
|
|
1780
|
+
if(!m.endsWith(".jsonl"))continue;let y=Lr.join(l,m),E=f.get(y),T=await eh(y).catch(()=>null);!T?.isFile()||T.mtimeMs>=w||
|
|
1781
|
+
E?.pending||(await MO(y).catch(()=>{}),E&&(E.size=null))}}function c(l){let w=o.get(l)||0;if(r()-w<UO)return;o.set(l,r());
|
|
1782
|
+
let _=a(l).finally(()=>i.delete(_));i.add(_)}async function u(l){let{lines:w}=l;if(l.lines=[],l.queuedLength=0,!w.length)
|
|
1783
|
+
return;let _=w.join(""),f=Buffer.byteLength(_);if(f>e){let m=w.length-1,y=Buffer.byteLength(w[m]);for(;m>0&&y+Buffer.byteLength(
|
|
1784
|
+
w[m-1])<=e;)y+=Buffer.byteLength(w[--m]);_=w.slice(m).join(""),f=y}try{l.size===null&&(await kO(l.paths.directory,{recursive:!0,
|
|
1785
|
+
mode:448}),l.size=(await eh(l.paths.current).catch(()=>null))?.size||0),c(l.paths.directory),l.size>0&&l.size+f>e&&(await LO(
|
|
1786
|
+
l.paths.current,l.paths.previous).catch(m=>{if(m?.code!=="ENOENT")throw m}),l.size=0),await xO(l.paths.current,_,{encoding:"\
|
|
1787
|
+
utf8",mode:384}),l.size+=f}catch{l.size=null}}function d(l){l.pending||(l.pending=new Promise(w=>{setImmediate(()=>{u(l).
|
|
1788
|
+
finally(()=>{l.pending=null,l.lines.length&&d(l),w()})})}))}function p(l,w,_={}){try{let f=String(_.projectRuntimeRoot??
|
|
1789
|
+
Zm()??"").trim(),m=String(l||"").trim();if(!Lr.isAbsolute(f)||!zO.test(m))return!1;let y=FO(w,new Date(r()));if(!y)return!1;
|
|
1790
|
+
let E=s(f,m);if(E.lines.push(y),E.queuedLength+=y.length,E.queuedLength>2*e){let T=0;for(;E.queuedLength>e&&T<E.lines.length-
|
|
1791
|
+
1;)E.queuedLength-=E.lines[T++].length;E.lines.splice(0,T)}return d(E),!0}catch{return!1}}function g(l){let w=0;for(let _ of[
|
|
1792
|
+
...n.values()])p(_.sessionId,l,{projectRuntimeRoot:_.projectRuntimeRoot})&&(w+=1);return w}async function h(){for(;i.size||
|
|
1793
|
+
[...n.values()].some(l=>l.pending);)await Promise.all([...i,...[...n.values()].map(l=>l.pending)])}return Object.freeze(
|
|
1794
|
+
{flush:h,record:p,recordForActiveSessions:g})}var va,DO,VO,Mr,UO,th,BO,rh,zO,GO,sU,nh=b(()=>{Qd();Qm();va="timeline",DO=
|
|
1795
|
+
1024*1024,VO=336*60*60*1e3,Mr=Object.freeze(["turn","conversation","process","connection","request","server"]),UO=1440*60*
|
|
1796
|
+
1e3,th=200,BO=24,rh=256,zO=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u,GO=/^[a-z][A-Za-z0-9]{0,39}$/u;sU=HO()});var dh={};zo(dh,{describeTimelineEvent:()=>uh,listSessionTimelines:()=>Ia,readSessionTimeline:()=>lh,runSessionTimelineCli:()=>sR});
|
|
1797
|
+
import{readdir as qO,readFile as WO,stat as YO}from"node:fs/promises";import Eo from"node:path";import oh from"node:process";
|
|
1798
|
+
import{parseArgs as JO}from"node:util";function eR(e){let t=Math.round(Number(e)/1e3);if(t<120)return`${t} s`;let r=Math.
|
|
1799
|
+
round(t/60);return r<120?`${r} min`:`${Math.round(r/60)} h`}function uh(e){let t=[];if((e.method||e.route)&&t.push(`${e.
|
|
1800
|
+
method||""} ${e.route||""}`.trim()),e.chat||e.conversation){let n=QO[e.chat]||e.chat||"conversation";t.push(e.conversation?
|
|
1801
|
+
`${n} ${e.conversation}`:n)}for(let[n,o]of ch){let i=e[n]===void 0||e[n]===""?"":o(e[n]);i&&t.push(i)}for(let[n,o]of Object.
|
|
1802
|
+
entries(e))tR.has(n)||t.push(`${n}=${o}`);let r=ZO[`${e.kind}.${e.event}`]||`${e.kind} ${e.event}`;return`${e.at} ${r}${t.
|
|
1803
|
+
length?` (${t.join("; ")})`:""}`}function Dr(e){return Object.assign(new Error(e),{usage:!0})}function sh(e,t,r){if(e===
|
|
1804
|
+
void 0)return null;let n=KO.exec(String(e).trim());if(n)return t-Number(n[1])*XO[n[2]];let o=Date.parse(String(e));if(Number.
|
|
1805
|
+
isNaN(o))throw Dr(`${r} needs an ISO time or a time back from now such as 30m: ${e}`);return o}function rR(e){if(e===void 0)
|
|
1806
|
+
return null;let t=String(e).split(",").map(n=>n.trim()).filter(Boolean),r=t.filter(n=>!Mr.includes(n));if(!t.length||r.length)
|
|
1807
|
+
throw Dr(`--kind takes ${Mr.join(", ")}; not ${r.join(", ")||"nothing"}.`);return new Set(t)}function nR(e,{env:t,now:r}){
|
|
1808
|
+
let n;try{n=JO({args:e,allowPositionals:!0,options:{help:{type:"boolean"},json:{type:"boolean"},kind:{type:"string"},project:{
|
|
1809
|
+
type:"string"},since:{type:"string"},"state-root":{type:"string"},until:{type:"string"}}})}catch(c){throw Dr(c.message)}
|
|
1810
|
+
let{positionals:o,values:i}=n;if(o.length>1)throw Dr("Name one session at most.");let s=o[0]||"";if(s&&!ah.test(s))throw Dr(
|
|
1811
|
+
`Not a session id: ${s}`);let a=String(i["state-root"]||t[Es]||"").trim()||nf({env:t});return Object.freeze({help:i.help===
|
|
1812
|
+
!0,json:i.json===!0,kinds:rR(i.kind),project:String(i.project||"").trim(),sessionId:s,since:sh(i.since,r,"--since"),stateRoot:Eo.
|
|
1813
|
+
resolve(a),until:sh(i.until,r,"--until")})}async function Ia(e){let t=new Map;for(let r of await Ii(e)){let n=Eo.join(r,
|
|
1814
|
+
va);for(let o of await qO(n).catch(()=>[])){let i=o.replace(/(\.1)?\.jsonl$/u,"");if(i===o||!ah.test(i))continue;let s=await YO(
|
|
1815
|
+
Eo.join(n,o)).catch(()=>null);if(!s?.isFile())continue;let a=`${r}
|
|
1816
|
+
${i}`,c=t.get(a)||{project:Eo.basename(r),projectRuntimeRoot:r,sessionId:i,bytes:0,updatedMs:0};c.bytes+=s.size,c.updatedMs=
|
|
1817
|
+
Math.max(c.updatedMs,s.mtimeMs),t.set(a,c)}}return[...t.values()].sort((r,n)=>n.updatedMs-r.updatedMs)}async function lh(e,t,{
|
|
1818
|
+
since:r=null,until:n=null,kinds:o=null}={}){let i=Ta(e,t),s=[];for(let a of[i.previous,i.current]){let c=await WO(a,"utf\
|
|
1819
|
+
8").catch(u=>{if(u?.code==="ENOENT")return"";throw u});for(let u of c.split(`
|
|
1820
|
+
`)){if(!u.trim())continue;let d;try{d=JSON.parse(u)}catch{continue}let p=Date.parse(d?.at);Number.isNaN(p)||r!==null&&p<
|
|
1821
|
+
r||n!==null&&p>=n||o&&!o.has(d.kind)||s.push(d)}}return s}function Je(e,t){e.write(`${t}
|
|
1822
|
+
`)}async function oR(e,t){let n=(await Ia(e.stateRoot)).filter(o=>!e.project||o.project===e.project);for(let o of n){let i=new Date(
|
|
1823
|
+
o.updatedMs).toISOString();e.json?Je(t,JSON.stringify({project:o.project,session:o.sessionId,bytes:o.bytes,updatedAt:i})):
|
|
1824
|
+
Je(t,`${i} ${o.project} ${o.sessionId} ${Math.ceil(o.bytes/1024)} KB`)}return!n.length&&!e.json&&Je(t,`No session time\
|
|
1825
|
+
lines under ${e.stateRoot}.`),0}async function iR(e,t,r){let n=(await Ia(e.stateRoot)).filter(a=>a.sessionId===e.sessionId&&
|
|
1826
|
+
(!e.project||a.project===e.project));if(n.length!==1)return Je(r,n.length?`Session ${e.sessionId} is in several projects\
|
|
1827
|
+
(${n.map(({project:a})=>a).join(", ")}); add --project NAME.`:`No timeline for session ${e.sessionId} under ${e.stateRoot}\
|
|
1828
|
+
. Run vibe64 timeline to list them.`),1;let[{project:o,projectRuntimeRoot:i}]=n,s=await lh(i,e.sessionId,e);for(let a of s)
|
|
1829
|
+
Je(t,e.json?JSON.stringify({project:o,session:e.sessionId,...a}):uh(a));return!s.length&&!e.json&&Je(t,"No events in tha\
|
|
1830
|
+
t window."),0}async function sR(e,{env:t,stdout:r=oh.stdout,stderr:n=oh.stderr,now:o=Date.now()}){let i;try{i=nR(e,{env:t,
|
|
1831
|
+
now:o})}catch(s){return Je(n,`${s.message}
|
|
1832
|
+
|
|
1833
|
+
${ih}`),2}if(i.help)return r.write(ih),0;try{return i.sessionId?await iR(i,r,n):await oR(i,r)}catch(s){return Je(n,`vibe\
|
|
1834
|
+
64 timeline could not read ${i.stateRoot}: ${s.message}`),1}}var ih,ah,KO,XO,ZO,QO,ch,tR,fh=b(()=>{Ue();nh();Mn();ih=`Us\
|
|
1835
|
+
age: vibe64 timeline [SESSION] [options]
|
|
1836
|
+
|
|
1837
|
+
Without SESSION, lists the sessions that have a timeline, most recent first.
|
|
1838
|
+
With SESSION, prints what happened in that session, oldest first.
|
|
1839
|
+
|
|
1840
|
+
Options:
|
|
1841
|
+
--since TIME only events at or after TIME: an ISO time, or a time back
|
|
1842
|
+
from now such as 90s, 30m, 2h or 7d
|
|
1843
|
+
--until TIME only events before TIME
|
|
1844
|
+
--kind KINDS only these kinds, separated by commas:
|
|
1845
|
+
${Mr.join(", ")}
|
|
1846
|
+
--project NAME the project folder, when several projects have SESSION
|
|
1847
|
+
--state-root DIR the Vibe64 state folder (default: $${Es}, else
|
|
1848
|
+
this user's own, such as ~/.local/state/vibe64)
|
|
1849
|
+
--json one JSON object per line, for tools
|
|
1850
|
+
--help show this help
|
|
1851
|
+
`,ah=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u,KO=/^(\d+(?:\.\d+)?)(s|m|h|d)$/u,XO=Object.freeze({s:1e3,m:6e4,h:36e5,d:864e5}),
|
|
1852
|
+
ZO=Object.freeze({"turn.started":"Turn started","turn.steered":"Message added to the running turn","turn.refused":"Messa\
|
|
1853
|
+
ge not sent","turn.running":"Turn running","turn.finished":"Turn finished","turn.failed":"Turn failed","turn.interrupted":"\
|
|
1854
|
+
Turn interrupted","turn.cancelled":"Turn cancelled","turn.timed-out":"Turn stopped at its deadline","turn.observation-lo\
|
|
1855
|
+
st":"Vibe64 lost sight of the turn","turn.ended":"Turn ended","turn.cancel-requested":"Cancel requested","turn.stop-requ\
|
|
1856
|
+
ested":"Stop requested","conversation.created":"Conversation created","conversation.deleted":"Conversation deleted","con\
|
|
1857
|
+
versation.closed":"Conversation closed","conversation.engine-session-closed":"AI engine session closed","conversation.ta\
|
|
1858
|
+
sk-started":"AI task started","conversation.task-closed":"AI task closed","process.started":"AI engine process started",
|
|
1859
|
+
"process.start-failed":"AI engine process could not start","process.exited":"AI engine process exited","process.stopped":"\
|
|
1860
|
+
AI engine process stopped by Vibe64","connection.connected":"Browser tab connected","connection.reconnected":"Browser ta\
|
|
1861
|
+
b reconnected","connection.disconnected":"Browser tab disconnected","connection.left":"Browser tab left the session","re\
|
|
1862
|
+
quest.failed":"Request failed","server.stopping":"Vibe64 server stopping"}),QO=Object.freeze({"ai-task":"AI task window",
|
|
1863
|
+
colleague:"Colleague",main:"Main chat",temporary:"temporary chat"});ch=Object.freeze([["engine",e=>`engine ${e}`],["turn",
|
|
1864
|
+
e=>`turn ${e}`],["thread",e=>`thread ${e}`],["message",e=>`message ${e}`],["operation",e=>`${e}`],["execution",e=>`proce\
|
|
1865
|
+
ss ${e}`],["pid",e=>`pid ${e}`],["exitCode",e=>`exit code ${e}`],["signal",e=>`signal ${e}`],["taskLimit",e=>e?"it reach\
|
|
1866
|
+
ed its task limit":""],["tab",e=>`tab ${e}`],["user",e=>`user ${e}`],["by",e=>`asked by ${e}`],["offlineMs",e=>`after ${eR(
|
|
1867
|
+
e)} offline`],["reason",e=>`reason: ${e}`],["status",e=>`status ${e}`],["state",e=>`state ${e}`],["ok",e=>e===!1?"it did\
|
|
1868
|
+
not succeed":""],["code",e=>`code ${e}`],["error",e=>`error: ${e}`],["trigger",e=>`via ${e}`]]),tR=new Set(["at","kind",
|
|
1869
|
+
"event","chat","conversation","method","route","project","session",...ch.map(([e])=>e)])});function So(e){return!!e&&typeof e=="object"&&lR.every(t=>typeof e[t]=="function")}function mh(e=null,{defaultMode:t="cr\
|
|
1870
|
+
eate",context:r="schema definition.mode"}={}){let n=ue(e),o=F(t).toLowerCase()||"create",i=Object.prototype.hasOwnProperty.
|
|
1871
|
+
call(n,"mode")?F(n.mode).toLowerCase():"";if(!i)return o;if(!aR.has(i))throw new TypeError(`${r} must be one of: create,\
|
|
1872
|
+
replace, patch.`);return i}function hh(e=null,t=""){let r=F(t);if(!r)return{};let n=ue(e);return So(n.schema)?ue(n.schema.
|
|
1873
|
+
getFieldMessages(r)):{}}function dR(e=null,t=""){let r=F(t).split(".").filter(Boolean);return r.length<2?{}:(r.pop(),hh(
|
|
1874
|
+
e,r.join(".")))}function ph(e,t){let r=t?e[t]:void 0;if(typeof r=="string"){let i=F(r);return i?{message:i}:null}if(!H(r))
|
|
1875
|
+
return null;let n=F(r.message);if(!n)return null;let o=F(r.code);return o?{message:n,code:o,params:ue(r.params)}:{message:n}}
|
|
1876
|
+
function fR(e,t,r=null){let n=F(t?.code).toUpperCase(),o=cR[n]||{},i=ue(t?.params),s=hh(r,e),a=n==="FIELD_NOT_ALLOWED"&&
|
|
1877
|
+
Object.keys(s).length<1?dR(r,e):s,c=ph(a,o.messageKey)||ph(a,"default");if(c)return c.code?{message:c.message,code:c.code,
|
|
1878
|
+
params:{...i,...c.params}}:{message:c.message};let u=F(t?.message);if(u)return o.code?{message:u,code:o.code,params:i}:{
|
|
1879
|
+
message:u};let d=F(t?.code);return d?{message:d}:{...uR,params:{}}}function Oa(e={},t=null){let r=ue(e),n={},o={};for(let[
|
|
1880
|
+
i,s]of Object.entries(r)){let a=F(i);if(!a)continue;if(typeof s=="string"){n[a]=s;continue}let{message:c,code:u,params:d}=fR(
|
|
1881
|
+
a,s,t);n[a]=c,u&&(o[a]={code:u,params:d})}return{fieldErrors:n,fieldErrorCodes:o}}var aR,cR,uR,lR,Ra=b(()=>{U();aR=new Set(
|
|
1882
|
+
["create","replace","patch"]),cR=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},
|
|
1883
|
+
TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",
|
|
1884
|
+
code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},
|
|
1885
|
+
MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kern\
|
|
1886
|
+
el.validation.field.minItems"},MAX_ITEMS:{messageKey:"maxItems",code:"kernel.validation.field.maxItems"},MIN_VALUE:{messageKey:"\
|
|
1887
|
+
min",code:"kernel.validation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxValue"},PATTERN:{
|
|
1888
|
+
messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.validation.field\
|
|
1889
|
+
.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{
|
|
1890
|
+
messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{
|
|
1891
|
+
messageKey:"default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validati\
|
|
1892
|
+
on.field.notEmpty"}}),uR=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),lR=Object.freeze(["c\
|
|
1893
|
+
reate","replace","patch","toJsonSchema"])});function pR(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&(Object.prototype.hasOwnProperty.call(e,"schema")||Object.
|
|
1894
|
+
prototype.hasOwnProperty.call(e,"mode"))}function vo(e,{context:t="schema definition",defaultMode:r=""}={}){if(e==null)return null;
|
|
1895
|
+
if(!pR(e))throw new TypeError(`${t} must be a schema definition object.`);let n=ue(e);if(!Object.prototype.hasOwnProperty.
|
|
1896
|
+
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!So(n.schema))throw new TypeError(`${t}.schema must \
|
|
1897
|
+
be a json-rest-schema schema instance.`);let o={schema:n.schema},i=F(r).toLowerCase();return o.mode=mh(n,{defaultMode:i||
|
|
1898
|
+
"patch",context:`${t}.mode`}),Object.freeze(o)}function Aa(e,t,{context:r="schema definition",defaultMode:n=""}={}){let o=vo(
|
|
1899
|
+
e,{context:r,defaultMode:n});return o?o.schema[o.mode](t):null}var Vr=b(()=>{U();Ra()});var gh=b(()=>{rt();U();Ir();Vr()});var yh=b(()=>{rt();Ir();Vr()});var mR,hR,wh=b(()=>{rt();mR=L({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),hR=Object.
|
|
1900
|
+
freeze({schema:mR,mode:"patch"})});var _h,gR,bh=b(()=>{_h=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),
|
|
1901
|
+
gR=Object.freeze({..._h,nullable:!0})});var Eh=b(()=>{U()});function vh({message:e=Sh,fieldErrors:t=null,fieldErrorCodes:r=null,errors:n=null,cause:o,statusCode:i=null}={}){let s=new Error(
|
|
1902
|
+
e,o?{cause:o}:void 0);if(e===Sh&&(s.messageCode="kernel.validation.schemaFailed",s.messageParams={}),Number.isInteger(i)&&
|
|
1903
|
+
i>=400&&i<=599&&(s.statusCode=i),H(t)){let a=H(r)&&Object.keys(r).length>0?r:null;s.fieldErrors=t,a&&(s.fieldErrorCodes=
|
|
1904
|
+
a),s.details={...s.details||{},fieldErrors:t,...a?{fieldErrorCodes:a}:{}}}else n!=null&&(s.details={...s.details||{},errors:n});
|
|
1905
|
+
return s}function Pa(e,t,{phase:r="input",context:n="schema definition",statusCode:o=null}={}){if(e==null)return t;let i=Aa(
|
|
1906
|
+
e,t,{defaultMode:r==="output"?"replace":"patch",context:n}),{fieldErrors:s,fieldErrorCodes:a}=Oa(i.errors,e);if(Object.keys(
|
|
1907
|
+
s).length>0)throw vh({fieldErrors:s,fieldErrorCodes:a,statusCode:o});return i.validatedObject??t}var Sh,Th=b(()=>{U();Vr();
|
|
1908
|
+
Sh="Schema validation failed."});var VU,Ih=b(()=>{U();VU=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.val\
|
|
1909
|
+
idation.type"},{keyword:"minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.max\
|
|
1910
|
+
Length"},{keyword:"minimum",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"\
|
|
1911
|
+
exclusiveMinimum",code:"kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusi\
|
|
1912
|
+
veMaximum"},{keyword:"multipleOf",code:"kernel.validation.multipleOf"},{keyword:"pattern",code:"kernel.validation.patter\
|
|
1913
|
+
n"},{keyword:"format",code:"kernel.validation.format"},{keyword:"enum",code:"kernel.validation.enum"},{keyword:"const",code:"\
|
|
1914
|
+
kernel.validation.const"},{keyword:"minItems",code:"kernel.validation.minItems"},{keyword:"maxItems",code:"kernel.valida\
|
|
1915
|
+
tion.maxItems"},{keyword:"additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems",code:"kernel\
|
|
1916
|
+
.validation.uniqueItems"},{keyword:"minProperties",code:"kernel.validation.minProperties"},{keyword:"maxProperties",code:"\
|
|
1917
|
+
kernel.validation.maxProperties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"\
|
|
1918
|
+
propertyNames",code:"kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",
|
|
1919
|
+
code:"kernel.validation.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].
|
|
1920
|
+
map(({keyword:e,code:t})=>[e,t]))});var Oh,Ca,yR,wR,Rh=b(()=>{rt();Ir();Oh="^[1-9][0-9]*$",Ca=Ge({type:"string",minLength:1,pattern:Oh}),yR=Ge({...Ca,nullable:!0}),
|
|
1921
|
+
wR=Ge({schema:L({recordId:{...Ca,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record\
|
|
1922
|
+
id must be a canonical positive integer string."}}}}),mode:"patch"})});var Ah=b(()=>{U()});var To=b(()=>{rt();Go();gh();yh();wh();bh();Eh();Ra();Vr();Th();Ih();Rh();Ah()});import{isDeepStrictEqual as _R}from"node:util";function Oo(e,t){let r=IR.get(e?.schemaVersion)||Ch;return we(r,e,t)}function we(e,t,r){
|
|
1923
|
+
let n=Pa({schema:e,mode:"create"},t,{context:r});if(!_R(t,n))throw new Error(`${r}: unknown fields or noncanonical value\
|
|
1924
|
+
s.`);return n}var k,B,W,Io,bR,ER,Ph,Ch,SR,Nh,vR,TR,IR,Ae,Ro,Ao,jh,Wt=b(()=>{To();k={type:"string",required:!0,noTrim:!0,
|
|
1925
|
+
minLength:1,maxLength:256},B={...k,maxLength:64},W=(e,t=100)=>({type:"array",required:!0,maxLength:t,items:e,validator:r=>Array.
|
|
1926
|
+
isArray(r)&&r.length>t?`Expected at most ${t} items.`:void 0}),Io={type:"integer",required:!0,enum:[1]},bR=W(L({code:B}),
|
|
1927
|
+
24),ER=L({id:B,kind:{...k,enum:["answer","practical"]},required:{type:"boolean",required:!0},rubric:k,evidence:{type:"ob\
|
|
1928
|
+
ject",required:!1,schema:L({producer:{...k,enum:["workspace","colleague","exercise","code"]},operation:B,check:{...B,required:!1},
|
|
1929
|
+
explanationRequired:{type:"boolean",required:!1},files:{...W(k,8),required:!1,minLength:1}})}}),Ph={code:B,title:k,prerequisites:bR,
|
|
1930
|
+
estimatedMinutes:{type:"integer",required:!0,min:1,max:180},visuals:W(L({id:B,descriptor:k}),12),exercise:{type:"object",
|
|
1931
|
+
required:!1,schema:L({kind:{...k,enum:["bundled"]},source:k,reuse:{...k,enum:["attempt","sequence"]},sequenceId:{...B,required:!1},
|
|
1932
|
+
sequenceMode:{...k,required:!1,enum:["create","continue"]}})},checks:{...W(L({id:B,file:k,assets:{...W(k,32),required:!1},
|
|
1933
|
+
kind:{...k,required:!1,enum:["response","code"]},timeoutSeconds:{type:"integer",required:!1,min:1,max:60}}),12),required:!1},
|
|
1934
|
+
appRoutes:{...W(L({method:{...k,enum:["POST","PUT","PATCH","DELETE"]},path:{...k,maxLength:128,pattern:"^/[A-Za-z0-9._~:\
|
|
1935
|
+
/-]*$"}}),16),required:!1}},Ch=L({schemaVersion:Io,...Ph,document:k,assessments:W(ER,32)}),SR=L({id:B,title:k,body:k,required:{
|
|
1936
|
+
type:"boolean",required:!0},visual:{type:"object",required:!1,schema:L({id:B,play:{...W(L({name:B,parameters:{type:"obje\
|
|
1937
|
+
ct",required:!0}}),16),required:!1}})},guide:{type:"object",required:!1,schema:L({target:B,navigate:{type:"boolean",required:!1},
|
|
1938
|
+
filePath:{...k,required:!1,maxLength:512},caption:{...k,required:!1}})},check:{type:"object",required:!0,schema:L({kind:{
|
|
1939
|
+
...k,enum:["auto","choice","review","self","fact","none"]},check:{...B,required:!1},fact:{...B,required:!1},files:{...W(
|
|
1940
|
+
k,8),required:!1},question:{...k,required:!1,maxLength:2e3},options:{...W(k,8),required:!1},answer:{...W({type:"integer",
|
|
1941
|
+
required:!0,min:0,max:7},8),required:!1},rubric:{...k,required:!1,maxLength:600},evidence:{...W({...k,enum:["changes","c\
|
|
1942
|
+
onversation"]},2),required:!1}})}}),Nh={...Ph,notes:{...k,required:!1},steps:W(SR,32)},vR=L({schemaVersion:{type:"intege\
|
|
1943
|
+
r",required:!0,enum:[2]},...Nh}),TR=L({schemaVersion:{type:"integer",required:!0,enum:[3]},...Nh,stage:{...k,enum:["stud\
|
|
1944
|
+
io","project"]}}),IR=new Map([[1,Ch],[2,vR],[3,TR]]),Ae=e=>e?.schemaVersion===2||e?.schemaVersion===3;Ro=L({schemaVersion:Io,
|
|
1945
|
+
topicId:B,domainId:B,title:k,status:{...k,enum:["preview","released"]},outline:k,prerequisites:W(L({topicId:B}),24),lessons:W(
|
|
1946
|
+
L({code:B,descriptor:k,status:{...k,enum:["draft","published"]},required:{type:"boolean",required:!0}}),64),places:{...W(
|
|
1947
|
+
B,64),required:!1},activities:{...W(B,64),required:!1},facts:{...W(B,64),required:!1}}),Ao=L({schemaVersion:Io,courseId:B,
|
|
1948
|
+
title:k,release:k,status:{...k,enum:["preview","released"]},topics:W(L({topicId:B,release:k}),32),orientation:{...B,required:!1}}),
|
|
1949
|
+
jh=L({schemaVersion:Io,id:B,title:k,svg:k,controller:k,assets:{...W(k,32),required:!1},initialState:B,states:W(B,32),description:{
|
|
1950
|
+
...k,maxLength:2e3},commands:W(L({name:B,parameters:W(L({name:B,required:{type:"boolean",required:!0},maxLength:{type:"i\
|
|
1951
|
+
nteger",required:!0,min:1,max:256}}),8),completionState:B,description:{...k,maxLength:2e3}}),32)})});function de(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_VOCABULARY_INVALID"})}function NR(e){if(!H(e)||!Me.
|
|
1952
|
+
test(e.id||""))throw de("A place needs a lowercase id.");let t=`Place ${e.id}`;if(!$h(e.label))throw de(`${t} needs a la\
|
|
1953
|
+
bel.`);if(!OR.has(e.scope))throw de(`${t} scope is studio or project.`);let r=e.who??"everyone";if(!RR.has(r))throw de(`${t}\
|
|
1954
|
+
who is everyone or owner.`);let n=e.open??null;if(n!==null){let i=Object.keys(n||{}).sort().join(",");if(!(i==="pane"||
|
|
1955
|
+
i==="databaseView,pane"?e.scope==="project"&&Me.test(n.pane):i==="route"?e.scope==="studio"&&typeof n.route=="string"&&/^\/app(?:\/[a-z0-9-]+)*$/u.
|
|
1956
|
+
test(n.route):i==="learning"&&n.learning===!0))throw de(`${t} opens a project pane, a studio /app route, Courses, or not\
|
|
1957
|
+
hing.`)}if(!Array.isArray(e.steps)||!e.steps.length||e.steps.length>6||e.steps.some(i=>!Me.test(i?.id||"")||!$h(i.label))||
|
|
1958
|
+
e.steps.at(-1).id!==e.id)throw de(`${t} needs 1 to 6 labelled steps ending with itself.`);let o=e.shown??(n?.pane?[{pane:n.
|
|
1959
|
+
pane,...n.databaseView?{databaseView:n.databaseView}:{}}]:n?.route?[{route:n.route}]:[]);if(!Array.isArray(o)||o.some(i=>!H(
|
|
1960
|
+
i)||!Object.keys(i).length))throw de(`${t} shown is a list of page focus matchers.`);if(e.event!==void 0&&!Me.test(e.event))
|
|
1961
|
+
throw de(`${t} event is a lowercase activity name.`);return Object.freeze({id:e.id,label:e.label,scope:e.scope,who:r,open:n&&
|
|
1962
|
+
Object.freeze({...n}),steps:Object.freeze(e.steps.map(i=>J(i.id,i.label))),shown:Object.freeze(o.map(i=>Object.freeze({...i}))),
|
|
1963
|
+
...e.event?{event:e.event}:{}})}function jR(e){if(!H(e)||!Me.test(e.id||""))throw de("An activity needs a lowercase id.");
|
|
1964
|
+
if(!Me.test(e.event||""))throw de(`Activity ${e.id} needs its page activity event.`);if(e.place!==void 0&&!Me.test(e.place))
|
|
1965
|
+
throw de(`Activity ${e.id} place is a place id.`);return Object.freeze({id:e.id,event:e.event,...e.place?{place:e.place}:
|
|
1966
|
+
{}})}function ja(){return!1}function ka({places:e=AR,activities:t=PR,facts:r=CR}={}){let n=new Map,o=new Map,i=new Set,s=(h,l)=>JSON.
|
|
1967
|
+
stringify(h)===JSON.stringify(l);function a({places:h=[],activities:l=[],facts:w=[]}={}){let _=h.map(NR),f=l.map(jR);for(let m of[
|
|
1968
|
+
..._,...f])if(n.has(m.id)&&!s(n.get(m.id),m)||o.has(m.id)&&!s(o.get(m.id),m)||_.includes(m)&&o.has(m.id)||f.includes(m)&&
|
|
1969
|
+
n.has(m.id))throw de(`${m.id} is already registered with another meaning.`);for(let m of w)if(!Me.test(m||""))throw de("\
|
|
1970
|
+
A fact needs a lowercase id.");for(let m of _)n.set(m.id,m);for(let m of f)o.set(m.id,m);for(let m of w)i.add(m)}a({places:e,
|
|
1971
|
+
activities:t,facts:r});function c(h){return n.get(h)||null}function u(h){return o.get(h)||null}function d(h){return i.has(
|
|
1972
|
+
h)}function p(){return[...n.values()]}function g(){return new Set([...[...o.values()].map(h=>h.event),...[...n.values()].
|
|
1973
|
+
filter(h=>h.event).map(h=>h.event)])}return Object.freeze({register:a,place:c,activity:u,hasFact:d,places:p,events:g,declared:ja,
|
|
1974
|
+
declaredPlace:ja,declaredActivity:ja})}function Po({places:e=[],activities:t=[],facts:r=[]}={}){let n=ka(),o=new Set(n.places().
|
|
1975
|
+
map(p=>p.id));for(let p of[...e,...t,...r])if(!Me.test(p||""))throw de(`Declared name ${p} is not a lowercase id.`);let i=new Set(
|
|
1976
|
+
e.filter(p=>!o.has(p))),s=new Set(t.filter(p=>!n.activity(p)));function a(p){return i.has(p)}function c(p){return s.has(
|
|
1977
|
+
p)}function u(p){return a(p)||c(p)}function d(p){return n.hasFact(p)||r.includes(p)}return Object.freeze({register:n.register,
|
|
1978
|
+
place:n.place,activity:n.activity,hasFact:d,places:n.places,events:n.events,declared:u,declaredPlace:a,declaredActivity:c})}
|
|
1979
|
+
function Ke(e,t,r){return new ie(422,e,{code:t,params:r})}function Lh(e={},t=wt){let r=typeof e.target=="string"?t.place(
|
|
1980
|
+
e.target):null,n=!r&&t.declaredPlace(e.target);if(!r&&!n){let c=t.places().map(u=>u.id).join(", ");throw Ke(`Use one of \
|
|
1981
|
+
this installation's guide places: ${c}.`,"VIBE64_TRAINING_GUIDE_INVALID",{places:c})}let o=e.target,i=e.navigate??!1,s=e.
|
|
1982
|
+
highlight??!0;if(typeof i!="boolean"||typeof s!="boolean")throw Ke("navigate and highlight are booleans.","VIBE64_TRAINI\
|
|
1983
|
+
NG_GUIDE_FLAGS_INVALID");if(!i&&!s)throw Ke("Point at the place (highlight) or open it (navigate); this request does nei\
|
|
1984
|
+
ther.","VIBE64_TRAINING_GUIDE_ACTION_MISSING");if(i&&o==="dashboard")throw Ke("Dashboard has no single view to open. Poi\
|
|
1985
|
+
nt at it, or open one Dashboard section such as files or database-erd.","VIBE64_TRAINING_GUIDE_DASHBOARD_UNOPENABLE");if(i&&
|
|
1986
|
+
r&&!xR(r))throw Ke(`${r.label} has no view to open; point at it instead.`,"VIBE64_TRAINING_GUIDE_PLACE_UNOPENABLE",{place:r.
|
|
1987
|
+
label});let a={target:o,navigate:i,highlight:s};if(e.filePath!==void 0){if(o!=="files")throw Ke("filePath is only for th\
|
|
1988
|
+
e files place.","VIBE64_TRAINING_GUIDE_FILE_PATH_MISPLACED");if(typeof e.filePath!="string"||!$a.test(e.filePath))throw Ke(
|
|
1989
|
+
"Use a relative practice project file path without '..'.","VIBE64_TRAINING_GUIDE_FILE_PATH_INVALID");a.filePath=e.filePath}
|
|
1990
|
+
if(e.caption!==void 0){if(typeof e.caption!="string"||!e.caption.trim()||e.caption.length>xa)throw Ke(`Use a caption of \
|
|
1991
|
+
1 to ${xa} characters.`,"VIBE64_TRAINING_GUIDE_CAPTION_INVALID",{limit:xa});a.caption=e.caption.trim()}return a}function Mh(e,t={},r=wt){
|
|
1992
|
+
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\
|
|
1993
|
+
ring"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}function kR(e,t=wt){let r=new Set,n=new Set,o=new Set;
|
|
1994
|
+
for(let i of Array.isArray(e?.beats)?e.beats:[]){if(i.kind==="check")continue;let s=t.activity(i.target);s||t.declaredActivity(
|
|
1995
|
+
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?.
|
|
1996
|
+
kind==="fact"&&o.add(e.check.fact),{places:[...r],activities:[...n],facts:[...o]}}var Me,OR,RR,J,xh,Le,kh,Na,AR,PR,CR,$h,
|
|
1997
|
+
wt,$a,xa,xR,SB,Co=b(()=>{Xr();U();Me=/^[a-z][a-z0-9-]{0,63}$/u,OR=new Set(["studio","project"]),RR=new Set(["everyone","\
|
|
1998
|
+
owner"]),J=(e,t)=>Object.freeze({id:e,label:t}),xh=J("preview","Preview"),Le=J("dashboard","Dashboard"),kh=J("database",
|
|
1999
|
+
"Database"),Na=J("account-menu","Account menu"),AR=[{id:"preview",label:"Preview",scope:"project",open:{pane:"preview"},
|
|
2000
|
+
steps:[xh]},{id:"dashboard",label:"Dashboard",scope:"project",open:null,steps:[Le]},{id:"database-erd",label:"ERD",scope:"\
|
|
2001
|
+
project",open:{pane:"database",databaseView:"erd"},steps:[Le,kh,J("database-erd","ERD")]},{id:"database-data",label:"Dat\
|
|
2002
|
+
a",scope:"project",open:{pane:"database",databaseView:"data"},steps:[Le,kh,J("database-data","Data")]},{id:"files",label:"\
|
|
2003
|
+
Files",scope:"project",open:{pane:"files"},steps:[Le,J("files","Files")]},{id:"changes",label:"Current changes",scope:"p\
|
|
2004
|
+
roject",open:{pane:"changes"},steps:[Le,J("changes","Current changes")]},{id:"git-log",label:"Git log",scope:"project",open:{
|
|
2005
|
+
pane:"repository"},steps:[Le,J("git-log","Git log")]},{id:"session-info",label:"Session info",scope:"project",open:{pane:"\
|
|
2006
|
+
session"},steps:[Le,J("session-info","Session info")]},{id:"architecture",label:"Architecture",scope:"project",open:{pane:"\
|
|
2007
|
+
system"},steps:[Le,J("architecture","Architecture")]},{id:"publish",label:"Publish",scope:"project",open:{pane:"publish"},
|
|
2008
|
+
steps:[Le,J("publish","Publish")]},{id:"chat",label:"Coding chat",scope:"project",open:null,shown:[{pane:"chat"},{chatVisible:!0}],
|
|
2009
|
+
steps:[J("chat","Coding chat")]},{id:"save",label:"Save",scope:"project",open:null,event:"saved",steps:[J("save","Save")]},
|
|
2010
|
+
{id:"reload-preview",label:"Reload preview",scope:"project",open:null,event:"preview-reloaded",steps:[xh,J("reload-previ\
|
|
2011
|
+
ew","Reload preview")]},{id:"learning",label:"Learning",scope:"studio",open:{learning:!0},shown:[],event:"learn-toggled",
|
|
2012
|
+
steps:[J("learning","Learning")]},{id:"lesson",label:"Lesson",scope:"studio",open:null,shown:[{pane:"lesson"}],steps:[J(
|
|
2013
|
+
"lesson","Lesson")]},{id:"lesson-bar",label:"Lesson step bar",scope:"studio",open:null,steps:[J("lesson-bar","Lesson ste\
|
|
2014
|
+
p bar")]},{id:"courses",label:"Courses",scope:"studio",open:null,shown:[{learningOpen:!0}],steps:[J("courses","Courses")]},
|
|
2015
|
+
{id:"colleague",label:"Colleague",scope:"studio",open:null,event:"colleague-opened",steps:[J("colleague","Colleague")]},
|
|
2016
|
+
{id:"account-menu",label:"Account menu",scope:"studio",open:null,steps:[Na]},{id:"account-settings",label:"Account setti\
|
|
2017
|
+
ngs",scope:"studio",open:null,steps:[Na,J("account-settings","Account settings")]},{id:"ai-setup",label:"AI setup",scope:"\
|
|
2018
|
+
studio",open:null,steps:[Na,J("ai-setup","AI setup")]}],PR=[{id:"send-message",event:"message-sent",place:"chat"},{id:"a\
|
|
2019
|
+
gent-finished",event:"agent-finished"},{id:"file-opened",event:"file-opened",place:"files"},{id:"app-pressed",event:"app\
|
|
2020
|
+
-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],CR=["ai-ready"];$h=
|
|
2021
|
+
e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;wt=ka({facts:[]});$a=/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\u0000-\u001f\\]{1,512}$/u,
|
|
2022
|
+
xa=256;xR=e=>!!e?.open;SB=Object.freeze({createLearningVocabulary:ka,lessonStepNeeds:kR})});function fe(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_BEATS_INVALID"})}function zR(e,t,r){let n=DR.exec(
|
|
2023
|
+
e);if(!n)throw fe(`beat ${t} must read "<show|do|check> <target>: <text>".`);let[,o,i,s,a=""]=n,c=`beat ${t} (${o} ${i})`;
|
|
2024
|
+
if(o==="check"&&i==="review"){if(a.trim()||s!==void 0)throw fe(`${c} takes no text: the bar shows the step's check.rubri\
|
|
2025
|
+
c.`);return{kind:o,target:i,text:""}}if(!a.trim())throw fe(`${c} needs its text after the colon.`);let u={kind:o,target:i,
|
|
2026
|
+
text:a.trim()};if(s!==void 0&&!(o==="do"&&i==="file-opened"))throw fe(`${c} takes no argument; only do file-opened names\
|
|
2027
|
+
a path.`);if(o==="show"&&!BR(i,r))throw fe(`${c} names an unknown place.`);if(o==="do"&&!UR(i,r))throw fe(`${c} names n\
|
|
2028
|
+
othing the learner can do or be at.`);if(o==="check"&&!La[i])throw fe(`${c} must be check auto, review, done or fact.`);
|
|
2029
|
+
if(s!==void 0){if(!$a.test(s))throw fe(`${c} needs a relative practice project file path without '..'.`);u.path=s}let d=i===
|
|
2030
|
+
"send-message"?LR:$R;if(u.text.length>d)throw fe(`${c} text is longer than ${d} characters.`);if(i==="send-message"){let p=[
|
|
2031
|
+
...u.text.matchAll(VR)].map(g=>g[1].trim());if(p.length!==1||!p[0]||p[0].length>Vh)throw fe(`${c} needs exactly one quot\
|
|
2032
|
+
ed prompt of at most ${Vh} characters.`);u.prompt=p[0]}return u}function No(e,t=wt){let r=String(e??""),n=MR.exec(r);if(!n)
|
|
2033
|
+
return{body:r,beats:null};let o=r.slice(n.index+n[0].length),i=/^```[ \t]*$/mu.exec(o);if(!i)throw fe("the beats block i\
|
|
2034
|
+
s not closed with ```.");if(o.slice(i.index+i[0].length).trim())throw fe("the beats block must end the step text.");let s=o.
|
|
2035
|
+
slice(0,i.index).split(`
|
|
2036
|
+
`).map(u=>u.trim()).filter(Boolean);if(!s.length||s.length>Dh)throw fe(`a beats block holds 1 to ${Dh} beats.`);let a=s.
|
|
2037
|
+
map((u,d)=>zR(u,d+1,t)),c=a.filter(u=>u.kind==="check");if(c.length>1||c.length&&a.at(-1).kind!=="check")throw fe("a ste\
|
|
2038
|
+
p has at most one check beat, and it is the last.");return{body:r.slice(0,n.index).replace(/\s+$/u,`
|
|
2039
|
+
`),beats:a}}function GR(e,t=wt){if(!e||e.kind==="check")return"";let r=t.activity(e.target);return r?r.place||"":e.target}
|
|
2040
|
+
function Uh(e,t=wt){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(GR(e,t));return r?r.
|
|
2041
|
+
scope==="project":!t.declared(e.target)}var Dh,$R,Vh,LR,La,MR,DR,VR,UR,BR,Ma=b(()=>{Co();Dh=8,$R=160,Vh=500,LR=600,La=Object.
|
|
2042
|
+
freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),MR=/^```beats[ \t]*$/mu,DR=/^(show|do|check)[ \t]+([a-z][a-z-]*)(?:[ \t]+([^:]+?))?[ \t]*(?::[ \t]*(.*))?$/u,
|
|
2043
|
+
VR=/["“]([^"“”]+)["”]/gu;UR=(e,t)=>!!(t.activity(e)||t.place(e)?.event||Mh(e,{},t)!==null||t.declared(e)),BR=(e,t)=>!!(t.
|
|
2044
|
+
place(e)||t.declaredPlace(e))});import{createHash as FR}from"node:crypto";function ne(e){return FR("sha256").update(e).digest("hex")}var Yt=b(()=>{});import{lstat as HR,readFile as qR,readdir as WR,realpath as Bh}from"node:fs/promises";import pe from"node:path";function Pe(e,t,r){
|
|
2045
|
+
let n=new Set;for(let o of e){let i=t?o[t]:o;if(!jo(i)||n.has(i))throw new Error(`${r}: invalid or duplicate ID ${i}.`);
|
|
2046
|
+
n.add(i)}return n}function V(e){return Array.isArray(e)?`[${e.map(V).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(
|
|
2047
|
+
e).sort().map(t=>`${JSON.stringify(t)}:${V(e[t])}`).join(",")}}`:JSON.stringify(e)}function Gh(e,t){let r=e.get(t.path);
|
|
2048
|
+
if(r&&(r.sha256!==t.sha256||r.bytes!==t.bytes))throw new Error(`Source changed between lesson snapshots: ${t.path}. Vali\
|
|
2049
|
+
date and retry.`);e.set(t.path,t)}function _t(e){let t=new Map;for(let r of e)for(let n of r.files)Gh(t,n);return[...t.values()]}
|
|
2050
|
+
async function YR(e){let t=await Bh(e);async function r(i,s=t){if(typeof i!="string"||!i||i.includes("\\")||pe.isAbsolute(
|
|
2051
|
+
i))throw new Error(`Invalid topic-relative path: ${i}.`);let a=pe.resolve(s,i),c=pe.relative(t,a);if(c===".."||c.startsWith(
|
|
2052
|
+
`..${pe.sep}`)||pe.isAbsolute(c))throw new Error(`Path escapes topic: ${i}.`);if(await Bh(a)!==a)throw new Error(`Symlin\
|
|
2053
|
+
k content is not supported: ${i}.`);return{filename:a,relative:c.split(pe.sep).join("/")}}async function n(i,s=t){let a=await r(
|
|
2054
|
+
i,s),c=await HR(a.filename);if(!c.isFile()||c.size>1024*1024)throw new Error(`Expected a regular file of at most 1 MiB: ${a.
|
|
2055
|
+
relative}.`);return{...a,bytes:await qR(a.filename)}}async function o(i,s=t){let a=await n(i,s);return{...a,value:JSON.parse(
|
|
2056
|
+
a.bytes.toString("utf8"))}}return Object.freeze({root:t,resolve:r,read:n,json:o})}function JR(e){let t=new Map(e.map(i=>[
|
|
2057
|
+
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;
|
|
2058
|
+
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(
|
|
2059
|
+
i),r.add(i)}for(let i of e)o(i.code)}function KR(e,t,r,n){r(t);let o=t.bytes.toString("utf8");Pe(e.assessments,"id","Ass\
|
|
2060
|
+
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.
|
|
2061
|
+
id}"></a>$`,"mu").test(o)||a!==i.id)throw new Error(`Missing explicit rubric anchor for ${i.id}.`);if(i.kind==="practica\
|
|
2062
|
+
l"&&!i.evidence)throw new Error(`Practical assessment ${i.id} needs an evidence producer.`);if(i.kind==="answer"&&i.evidence)
|
|
2063
|
+
throw new Error(`Answer assessment ${i.id} uses its admitted answer, not a practical producer.`);if(i.evidence?.check&&!n.
|
|
2064
|
+
has(i.evidence.check))throw new Error(`Unknown check for ${i.id}.`);if(i.evidence?.producer==="exercise"&&(!e.exercise||
|
|
2065
|
+
!i.evidence.check))throw new Error(`Exercise assessment ${i.id} needs its declared exercise and check.`);if(i.evidence?.
|
|
2066
|
+
check&&!["exercise","code"].includes(i.evidence.producer))throw new Error(`Only exercise or code evidence runs a declare\
|
|
2067
|
+
d check: ${i.id}.`);let u=(e.checks||[]).find(d=>d.id===i.evidence?.check)?.kind||"response";if(i.evidence?.producer==="\
|
|
2068
|
+
code"){if(!e.exercise||!i.evidence.check||u!=="code"||!i.evidence.files?.length)throw new Error(`Code assessment ${i.id}\
|
|
2069
|
+
needs its declared exercise, files and a code check.`)}else if(i.evidence?.files||i.evidence?.check&&u==="code")throw new Error(
|
|
2070
|
+
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function XR(e,t,r,n,o,i){let s=a=>{throw new Error(
|
|
2071
|
+
`Lesson ${n}: ${a}`)};e.schemaVersion===3&&e.stage==="project"&&!e.exercise&&s("a project lesson needs its exercise (a p\
|
|
2072
|
+
ractice project)."),e.steps.length||s("needs at least one step."),Pe(e.steps,"id","Steps"),e.steps.some(a=>a.required)||
|
|
2073
|
+
s("needs a required step.");for(let a of e.steps){let c=`step ${a.id}`;if(a.visual){let h=t.get(a.visual.id);h||s(`${c} \
|
|
2074
|
+
shows undeclared visual ${a.visual.id}.`);for(let l of a.visual.play||[]){let w=h.commands.find(f=>f.name===l.name);w||s(
|
|
2075
|
+
`${c} plays undeclared command ${l.name}.`);let _=l.parameters;(!_||typeof _!="object"||Array.isArray(_))&&s(`${c} comma\
|
|
2076
|
+
nd ${l.name} needs a parameters object.`);for(let[f,m]of Object.entries(_)){let y=w.parameters.find(E=>E.name===f);y||s(
|
|
2077
|
+
`${c} command ${l.name} has undeclared parameter ${f}.`),(typeof m!="string"||m.length>y.maxLength)&&s(`${c} command ${l.
|
|
2078
|
+
name} parameter ${f} must be a string of at most ${y.maxLength} characters.`)}for(let f of w.parameters)f.required&&!Object.
|
|
2079
|
+
hasOwn(_,f.name)&&s(`${c} command ${l.name} needs parameter ${f.name}.`)}}if(a.guide){let{caption:h,...l}=a.guide;try{Lh(
|
|
2080
|
+
l,i)}catch(w){s(`${c} guide: ${w.message}`)}i.place(a.guide.target)?.scope==="project"&&!e.exercise&&s(`${c} guide ${a.guide.
|
|
2081
|
+
target} needs the lesson's exercise (a practice project).`)}let u=null;try{({beats:u}=No(o.get(a.body),i))}catch(h){s(`${c}\
|
|
2082
|
+
beats: ${h.message}`)}if(u){a.guide&&s(`${c} has both beats and a guide; its beats replace the guide.`);let h=u.find(w=>w.
|
|
2083
|
+
kind==="check");h&&La[h.target]!==a.check.kind&&s(`${c} beat check ${h.target} does not match its ${a.check.kind} check.`);
|
|
2084
|
+
let l=u.find(w=>Uh(w,i));l&&!e.exercise&&s(`${c} beat ${l.kind} ${l.target} needs the lesson's exercise (a practice proj\
|
|
2085
|
+
ect).`)}let d=a.check,p={auto:["check","files"],choice:["question","options","answer"],review:["rubric","evidence"],fact:[
|
|
2086
|
+
"fact"],self:[],none:[]}[d.kind],g=Object.keys(d).filter(h=>h!=="kind"&&!p.includes(h));if(g.length&&s(`${c} ${d.kind} c\
|
|
2087
|
+
heck cannot declare ${g.join(", ")}.`),d.kind==="none"&&a.required&&s(`${c} has no check and cannot be required.`),d.kind===
|
|
2088
|
+
"fact"&&(e.schemaVersion!==3&&s(`${c} fact check needs lesson format 3.`),(!d.fact||!i.hasFact(d.fact))&&s(`${c} checks \
|
|
2089
|
+
an unknown fact; declare a host's fact in the topic's facts.`)),d.kind==="auto"){(!d.check||!r.has(d.check))&&s(`${c} na\
|
|
2090
|
+
mes an unknown check.`),e.exercise||s(`${c} runs a declared check and needs the lesson's exercise.`);let h=e.checks.find(
|
|
2091
|
+
w=>w.id===d.check),l=d.files||[];(h.kind==="code"?l.length<1||l.length>8:l.length)&&s(`${c} ${h.kind==="code"?"code chec\
|
|
2092
|
+
k needs 1-8 exercise files":"names files, but only a code check edits files"}.`)}if(d.kind==="review"){d.rubric?.trim()||
|
|
2093
|
+
s(`${c} review needs its rubric.`),e.exercise||s(`${c} reviews practice work and needs the lesson's exercise.`);let h=d.
|
|
2094
|
+
evidence||["changes"];(h[0]!=="changes"||h.length>2||h.length===2&&h[1]!=="conversation")&&s(`${c} review evidence is ["\
|
|
2095
|
+
changes"] or ["changes", "conversation"].`)}if(d.kind==="choice"){let{question:h,options:l,answer:w}=d;(!h||!l||!w)&&s(`${c}\
|
|
2096
|
+
choice needs question, options and answer.`),(l.length<2||l.length>8)&&s(`${c} choice needs 2-8 options.`),(!w.length||
|
|
2097
|
+
new Set(w).size!==w.length||w.some(_=>_>=l.length))&&s(`${c} choice answer must list unique option indexes within its op\
|
|
2098
|
+
tions.`)}}}async function ZR(e,t,{authoring:r,installed:n,vocabulary:o}){let i=await e.json(t.descriptor),s=Oo(i.value,t.
|
|
2099
|
+
code);if(s.code!==t.code)throw new Error(`Lesson code mismatch: ${t.code}.`);if(r&&s.schemaVersion!==3)throw new Error(`\
|
|
2100
|
+
Lesson ${t.code} uses retired lesson format ${s.schemaVersion}. Author it in format 3 with steps and its stage.`);let a=pe.
|
|
2101
|
+
dirname(i.filename),c=new Map;function u(f){if(Gh(c,{path:f.relative,sha256:ne(f.bytes),bytes:f.bytes.length}),c.size>512||
|
|
2102
|
+
[...c.values()].reduce((m,y)=>m+y.bytes,0)>32*1024*1024)throw new Error(`Lesson ${t.code} exceeds bundle limits.`)}u(i);
|
|
2103
|
+
let d=new Set,p=new Map;Pe(s.prerequisites,"code","Lesson prerequisites");let g=Pe(s.checks||[],"id","Checks");for(let f of s.
|
|
2104
|
+
checks||[]){u(await e.read(f.file,a));for(let m of f.assets||[])u(await e.read(m,a))}if(s.schemaVersion===1&&KR(s,await e.
|
|
2105
|
+
read(s.document,a),u,g),Ae(s))for(let f of[s.notes,...new Set(s.steps.map(m=>m.body))]){if(f===void 0)continue;let m=await e.
|
|
2106
|
+
read(f,a);u(m),d.add(m.relative),p.set(f,m.bytes.toString("utf8"))}if(s.appRoutes&&!s.exercise)throw new Error(`Lesson ${t.
|
|
2107
|
+
code} can declare app routes only with its exercise.`);let h=new Set;for(let f of s.appRoutes||[]){if(f.path!=="/"&&!f.path.
|
|
2108
|
+
slice(1).split("/").every(y=>y===":id"||/^[A-Za-z0-9._~-]+$/u.test(y)))throw new Error(`Invalid app route path for ${t.code}\
|
|
2109
|
+
: ${f.path}.`);let m=`${f.method} ${f.path}`;if(h.has(m))throw new Error(`Lesson ${t.code} has a duplicate app route: ${m}\
|
|
2110
|
+
.`);h.add(m)}for(let f of s.checks||[])if(f.timeoutSeconds!==void 0&&f.kind!=="code")throw new Error(`Only a code check \
|
|
2111
|
+
declares a timeout: ${f.id}.`);if(s.schemaVersion===1&&!s.assessments.some(f=>f.required))throw new Error(`Lesson ${t.code}\
|
|
2112
|
+
needs a required assessment.`);Pe(s.visuals,"id","Visuals");let l=new Map;for(let f of s.visuals){let m=await e.json(f.
|
|
2113
|
+
descriptor,a),y=we(jh,m.value,f.id);if(y.id!==f.id)throw new Error(`Visual ID mismatch: ${f.id}.`);let E=Pe(y.states,null,
|
|
2114
|
+
"Visual states");if(!E.has(y.initialState))throw new Error(`Unknown initial visual state: ${y.initialState}.`);Pe(y.commands,
|
|
2115
|
+
"name","Visual commands");for(let S of y.commands)if(Pe(S.parameters,"name","Command parameters"),S.completionState!=="u\
|
|
2116
|
+
nchanged"&&!E.has(S.completionState))throw new Error(`Unknown completion state: ${S.name}.`);u(m),l.set(y.id,y);let T=pe.
|
|
2117
|
+
dirname(m.filename);for(let S of[y.svg,y.controller,...y.assets||[]]){let v=await e.read(S,T);u(v),d.add(v.relative)}}if(s.
|
|
2118
|
+
exercise){let f=s.exercise;if(f.reuse==="sequence"){if(!f.sequenceId||!f.sequenceMode)throw new Error(`Invalid exercise \
|
|
2119
|
+
sequence for ${t.code}.`)}else if(f.sequenceId||f.sequenceMode)throw new Error(`Invalid exercise sequence for ${t.code}.`);
|
|
2120
|
+
if(f.sequenceId&&!jo(f.sequenceId))throw new Error("Invalid exercise sequence ID.");let m=await e.resolve(f.source,a);async function y(T){
|
|
2121
|
+
for(let S of(await WR(T,{withFileTypes:!0})).sort((v,R)=>v.name<R.name?-1:v.name>R.name?1:0)){if(zh.has(S.name))continue;
|
|
2122
|
+
let v=pe.relative(e.root,pe.join(T,S.name)),R=await e.resolve(v);if(S.isDirectory())await y(R.filename);else{let O=await e.
|
|
2123
|
+
read(v);u(O),d.add(O.relative)}}}await y(m.filename);let E=s.schemaVersion===1?s.assessments.map(T=>[`Code assessment ${T.
|
|
2124
|
+
id}`,T.evidence?.files||[]]):s.steps.map(T=>[`Code step ${T.id}`,T.check.files||[]]);for(let[T,S]of E){for(let v of S){let R=v.
|
|
2125
|
+
split("/");if(v.includes("\\")||pe.posix.isAbsolute(v)||R.some(O=>!O||O==="."||O===".."||zh.has(O))||!c.has(m.relative?`${m.
|
|
2126
|
+
relative}/${v}`:v))throw new Error(`${T} names a file outside its bundled exercise: ${v}.`)}if(new Set(S).size!==S.length)
|
|
2127
|
+
throw new Error(`${T} repeats a declared file.`)}}let w="";if(Ae(s))try{XR(s,l,g,t.code,p,o)}catch(f){if(!n)throw f;w=f.
|
|
2128
|
+
message}let _={schemaVersion:1,code:s.code,files:[...c.values()].sort((f,m)=>f.path<m.path?-1:f.path>m.path?1:0)};return{
|
|
2129
|
+
lesson:s,manifest:_,hash:ne(V(_)),descriptorPath:i.relative,served:d,...w?{problem:w}:{}}}async function bt(e,t={}){let{
|
|
2130
|
+
authoring:r=!1,installed:n=!1}=t,o=await YR(e),i=await o.json("package.json");if(!/^learn-[a-z0-9-]+$/u.test(i.value.name||
|
|
2131
|
+
"")||!/^\d+\.\d+\.\d+$/u.test(i.value.version||""))throw new Error("Topic package needs a learn- name and an exact relea\
|
|
2132
|
+
se version.");let s=we(Ro,i.value.vibe64Training,"Topic");if(!jo(s.topicId)||!jo(s.domainId))throw new Error("Invalid to\
|
|
2133
|
+
pic or domain ID.");let a=await o.read(s.outline);if(Pe(s.lessons,"code","Lessons"),Pe(s.prerequisites,"topicId","Topic \
|
|
2134
|
+
prerequisites"),!s.lessons.length)throw new Error("A topic needs lessons.");if(s.status==="released"&&s.lessons.some(l=>l.
|
|
2135
|
+
required&&l.status!=="published"))throw new Error("A released topic contains required draft lessons.");let c=Po(s),u=[],
|
|
2136
|
+
d=new Set;for(let l of s.lessons){let{served:w,..._}=await ZR(o,l,{authoring:r,installed:n,vocabulary:c});for(let f of w)
|
|
2137
|
+
d.add(f);u.push({..._,status:l.status,required:l.required})}for(let{descriptorPath:l,lesson:w}of u)if(Ae(w)&&d.has(l))throw new Error(
|
|
2138
|
+
`Lesson ${w.code} descriptor cannot also be a step body, notes, visual or exercise file.`);JR(u.map(l=>l.lesson));for(let[
|
|
2139
|
+
l,w]of u.entries())for(let{code:_}of w.lesson.prerequisites){let f=u.findIndex(m=>m.lesson.code===_);if(f>=l)throw new Error(
|
|
2140
|
+
`Prerequisite ${_} must precede ${w.lesson.code}.`);if(w.status==="published"&&u[f].status!=="published")throw new Error(
|
|
2141
|
+
`Published lesson ${w.lesson.code} requires draft ${_}.`)}let p=new Map;for(let{lesson:l,descriptorPath:w,status:_}of u){
|
|
2142
|
+
if(l.exercise?.reuse!=="sequence")continue;let f=(await o.resolve(l.exercise.source,pe.dirname(pe.join(o.root,w)))).relative,
|
|
2143
|
+
m=p.get(l.exercise.sequenceId);if(l.exercise.sequenceMode==="create"){if(m)throw new Error(`Invalid create/continue sequ\
|
|
2144
|
+
ence: ${l.code}.`);p.set(l.exercise.sequenceId,{source:f,status:_})}else if(!m||m.source!==f||_==="published"&&m.status!==
|
|
2145
|
+
"published")throw new Error(`Invalid create/continue sequence: ${l.code}.`)}let g=[i,a].map(l=>({path:l.relative,sha256:ne(
|
|
2146
|
+
l.bytes),bytes:l.bytes.length})),h={schemaVersion:1,topic:s,release:i.value.version,files:g,lessons:u.map(({lesson:l,hash:w,
|
|
2147
|
+
status:_,required:f})=>({code:l.code,hash:w,status:_,required:f}))};return _t([h,...u.map(l=>l.manifest)]),{topic:s,release:i.
|
|
2148
|
+
value.version,bundles:u,topicManifest:h,topicHash:ne(V(h))}}var zh,jo,Jt=b(()=>{Wt();Co();Ma();Yt();zh=new Set([".git","\
|
|
2149
|
+
node_modules",".genesis"]),jo=e=>/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u.test(e)});import{realpath as Fh}from"node:fs/promises";async function Ur(e){let t=await Fh(e),r=async(c,u="utf8",d={})=>{let{input:p,
|
|
2150
|
+
maxBuffer:g=1024*1024}=d,h=await qt({actor:"daemon",allowedRoots:[t],args:["-C",t,...c],command:"git",cwd:t,envPolicy:"p\
|
|
2151
|
+
roject",gitSafeDirectories:[t],input:p,maxBuffer:g,mode:"capture",outputEncoding:u,purpose:"source",runtimes:["git"],timeout:6e4});
|
|
2152
|
+
if(h.ok!==!0)throw Object.assign(new Error(h.error||"Git could not read the pinned topic."),{code:h.code});return u==="b\
|
|
2153
|
+
ase64"?Buffer.from(h.stdout,"base64"):h.stdout.trim()};if(await Fh(await r(["rev-parse","--show-toplevel"]))!==t)throw new Error(
|
|
1509
2154
|
"Choose the topic repository root.");let n=await r(["rev-parse","HEAD"]);if(await r(["status","--porcelain","--untracked\
|
|
1510
|
-
-files=all"]))throw new Error("Commit the topic content before generating a pinned course manifest.");let o=await
|
|
2155
|
+
-files=all"]))throw new Error("Commit the topic content before generating a pinned course manifest.");let o=await bt(t),
|
|
1511
2156
|
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
2157
|
if(!s)throw new Error("Topic package needs its canonical https://github.com/<owner>/learn-<topic>.git repository URL.");
|
|
1513
|
-
let a=
|
|
1514
|
-
byteLength(a[
|
|
1515
|
-
c,
|
|
1516
|
-
h=0;for(let
|
|
1517
|
-
h,
|
|
1518
|
-
`Topic input differs from its pinned commit: ${
|
|
1519
|
-
a while reading the pinned topic.");c=
|
|
2158
|
+
let a=_t([o.topicManifest,...o.bundles.map(c=>c.manifest)]);for(let c=0;c<a.length;){let u=c,d=0;do d+=a[u].bytes+Buffer.
|
|
2159
|
+
byteLength(a[u].path)+128,u+=1;while(u<a.length&&d+a[u].bytes+Buffer.byteLength(a[u].path)+128<=1024*1024);let p=a.slice(
|
|
2160
|
+
c,u),g=await r(["cat-file","--batch","-Z"],"base64",{input:p.map(l=>`${n}:${l.path}\0`).join(""),maxBuffer:2*1024*1024}),
|
|
2161
|
+
h=0;for(let l of p){let w=g.indexOf(0,h),_=w<0?null:/^(?:[a-f0-9]{40}|[a-f0-9]{64}) blob (0|[1-9][0-9]*)$/u.exec(g.subarray(
|
|
2162
|
+
h,w).toString("ascii")),f=_?Number(_[1]):-1,m=w+1+f;if(f!==l.bytes||g[m]!==0||ne(g.subarray(w+1,m))!==l.sha256)throw new Error(
|
|
2163
|
+
`Topic input differs from its pinned commit: ${l.path}.`);h=m+1}if(h!==g.length)throw new Error("Unexpected trailing dat\
|
|
2164
|
+
a while reading the pinned topic.");c=u}if(await r(["rev-parse","HEAD"])!==n||await r(["status","--porcelain","--untrack\
|
|
1520
2165
|
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
|
|
2166
|
+
release:o.release,repository:s,commit:n,topicManifest:o.topicManifest,topicHash:o.topicHash}}function Br(e,t){let r=we(Ao,
|
|
1522
2167
|
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
2168
|
"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(
|
|
2169
|
+
throw new Error(`Duplicate course topic: ${i.topicId}.`);n.add(i.topicId);let s=t.filter(d=>d.topicId===i.topicId&&d.release===
|
|
1525
2170
|
i.release);if(s.length!==1)throw new Error(`Resolve exactly one pinned topic release: ${i.topicId}@${i.release}.`);let a=s[0];
|
|
1526
2171
|
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
2172
|
`Topic requires a repository and immutable commit: ${i.topicId}.`);let c=a.topicManifest;if(!c||c.schemaVersion!==1||c.topic?.
|
|
1528
|
-
topicId!==i.topicId||c.release!==i.release||
|
|
1529
|
-
topicId}.`);if(
|
|
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(
|
|
2173
|
+
topicId!==i.topicId||c.release!==i.release||ne(V(c))!==a.topicHash)throw new Error(`Topic manifest identity mismatch: ${i.
|
|
2174
|
+
topicId}.`);if(we(Ro,c.topic,i.topicId),r.status==="released"&&c.topic.status!=="released")throw new Error(`Released cou\
|
|
2175
|
+
rse requires a released topic: ${i.topicId}.`);let u=c.topic.lessons;if(!Array.isArray(u)||!u.length||!Array.isArray(c.lessons)||
|
|
2176
|
+
u.length!==c.lessons.length)throw new Error(`Incomplete whole-topic inventory: ${i.topicId}.`);for(let[d,p]of u.entries()){
|
|
2177
|
+
let g=c.lessons[d];if(g.code!==p.code||g.status!==p.status||g.required!==p.required||!/^[a-f0-9]{64}$/u.test(g.hash||""))
|
|
2178
|
+
throw new Error(`Changed whole-topic order or lesson identity: ${i.topicId}.`);if(r.status==="released"&&g.required&&g.status!==
|
|
2179
|
+
"published")throw new Error(`Released course includes required draft: ${g.code}.`)}return{topicId:i.topicId,release:i.release,
|
|
2180
|
+
repository:a.repository,commit:a.commit,manifestHash:a.topicHash,lessons:c.lessons.map(d=>({...d}))}});if(r.orientation!==
|
|
1536
2181
|
void 0&&!o.some(i=>i.lessons.some(s=>s.code===r.orientation&&s.status==="published")))throw new Error(`Course orientatio\
|
|
1537
2182
|
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
|
|
1539
|
-
return
|
|
1540
|
-
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var
|
|
1541
|
-
return
|
|
1542
|
-
e}function
|
|
1543
|
-
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!
|
|
2183
|
+
status:r.status,topics:o}}var xo=b(()=>{ba();Jt();Wt();Yt()});function Kt(e,t,r){let{statusCode:n,cause:o,...i}=r,s=new ie(n,e,{...i,code:t});return o&&(s.cause=o),s}function ko(e,t,r=409,n={}){
|
|
2184
|
+
return Kt(e,t,{...n,statusCode:r})}function Ce(e,t,r,n){return Kt(e,t,{statusCode:r,cause:n})}function Da(e,t,r){return Object.
|
|
2185
|
+
assign(new Error(e,r?{cause:r}:void 0),{code:t})}var zB,$o=b(()=>{Ve();zB=128*1024});var Hh=b(()=>{});import{lstat as QR,readFile as eA,readdir as tA,realpath as rA}from"node:fs/promises";import G from"node:path";function Va(e){
|
|
2186
|
+
return Ae(e)?{...e,steps:e.steps.map(t=>{if(t.check.kind!=="choice")return t;let{answer:r,...n}=t.check;return{...t,check:n}})}:
|
|
2187
|
+
e}function Et(e,t={}){let r=we(oA,e,"Installed topic pin");if(!Xe.test(r.topicId)||!Ua.test(r.commit)||r.topicId!==(t.topicId??
|
|
2188
|
+
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!nA.test(r.repository)||!Gr.test(r.topicHash))
|
|
1544
2189
|
throw new Error("Installed pin does not match the requested topic, commit or canonical source identity.");if(r.topicHash!==
|
|
1545
|
-
(t.topicHash??r.topicHash))throw new Error("Installed topic differs from the trusted course or attempt pin.");return r}async function
|
|
1546
|
-
let r=await
|
|
2190
|
+
(t.topicHash??r.topicHash))throw new Error("Installed topic differs from the trusted course or attempt pin.");return r}async function Fr(e,t){
|
|
2191
|
+
let r=await QR(e);if(r.isSymbolicLink()||await rA(e)!==e)throw new Error("Installed content cannot use symlink or direct\
|
|
1547
2192
|
ory aliases.");if(t?!r.isDirectory():!r.isFile())throw new Error(`Installed content needs a regular ${t?"directory":"fil\
|
|
1548
|
-
e"}.`);return r}async function
|
|
1549
|
-
limit.`);let n=await
|
|
1550
|
-
let t=[],r=0;async function n(o){await
|
|
1551
|
-
"Installed snapshot exceeds 65536 directory entries.");let s=
|
|
1552
|
-
t.push(
|
|
1553
|
-
function
|
|
1554
|
-
te server-owned system root.");let r=
|
|
1555
|
-
title}") cannot be taught by this version of Vibe64: ${
|
|
1556
|
-
fixed release.`,"VIBE64_TRAINING_LESSON_UNUSABLE",422,{params:{lessonCode:
|
|
1557
|
-
problem}})}async function i(
|
|
1558
|
-
topicId:
|
|
1559
|
-
"Choose a valid topic ID and its exact 40-character lowercase Git commit.");if(typeof
|
|
1560
|
-
"Provide the trusted 64-character topic hash from the course or saved attempt.");let
|
|
1561
|
-
return
|
|
1562
|
-
topicId:
|
|
1563
|
-
r,
|
|
1564
|
-
topicHash:
|
|
1565
|
-
|
|
1566
|
-
topicManifest,lessons:
|
|
1567
|
-
required:
|
|
1568
|
-
anged from its source files.");if(
|
|
1569
|
-
"Installed topic identity differs from its pin.");let
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
"Installed source changed during reading.");if(JSON.parse(
|
|
1573
|
-
repository}.git`)throw new Error("Installed package repository URL differs from its canonical pin.");return{pin:
|
|
1574
|
-
let
|
|
1575
|
-
o install that exact revision.`:`Pinned teaching content ${
|
|
1576
|
-
he verified snapshot.`,{cause:
|
|
1577
|
-
async function c({pin:
|
|
1578
|
-
|
|
1579
|
-
ecorded installed file.");let
|
|
1580
|
-
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:
|
|
1581
|
-
topicId:
|
|
1582
|
-
test(
|
|
1583
|
-
"Choose an exact pinned topic and lesson identity.");try{let
|
|
1584
|
-
|
|
1585
|
-
"utf8")),{topicId:
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
lessons.find(
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
import
|
|
1637
|
-
throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function
|
|
1638
|
-
relative(e,t);return!r||r!==".."&&!r.startsWith(`..${
|
|
1639
|
-
await
|
|
2193
|
+
e"}.`);return r}async function Xt(e,t){if((await Fr(e,!1)).size>t)throw new Error(`Installed file exceeds its ${t}-byte \
|
|
2194
|
+
limit.`);let n=await eA(e);if(n.length>t)throw new Error(`Installed file exceeds its ${t}-byte limit.`);return n}async function iA(e){
|
|
2195
|
+
let t=[],r=0;async function n(o){await Fr(o,!0);for(let i of await tA(o,{withFileTypes:!0})){if(++r>65536)throw new Error(
|
|
2196
|
+
"Installed snapshot exceeds 65536 directory entries.");let s=G.join(o,i.name);i.isDirectory()?await n(s):(await Fr(s,!1),
|
|
2197
|
+
t.push(G.relative(e,s).split(G.sep).join("/")))}}return await n(e),t.sort()}function Hr({systemRoot:e}){return aA(e,sA)}
|
|
2198
|
+
function aA(e,t){if(typeof e!="string"||!e||!G.isAbsolute(e))throw new Error("Installed teaching content needs an absolu\
|
|
2199
|
+
te server-owned system root.");let r=G.resolve(e),n=new Map;function o(f){return ko(`Lesson ${f.lesson.code} ("${f.lesson.
|
|
2200
|
+
title}") cannot be taught by this version of Vibe64: ${f.problem} Update the course in Courses, or ask its authors for a\
|
|
2201
|
+
fixed release.`,"VIBE64_TRAINING_LESSON_UNUSABLE",422,{params:{lessonCode:f.lesson.code,lessonTitle:f.lesson.title,problem:f.
|
|
2202
|
+
problem}})}async function i(f={}){let m=await s(f);return{...m,bundles:m.bundles.map(y=>({...y,lesson:Va(y.lesson)}))}}async function s({
|
|
2203
|
+
topicId:f,commit:m,topicHash:y}={}){if(typeof f!="string"||typeof m!="string"||!Xe.test(f)||!Ua.test(m))throw new Error(
|
|
2204
|
+
"Choose a valid topic ID and its exact 40-character lowercase Git commit.");if(typeof y!="string"||!Gr.test(y))throw new Error(
|
|
2205
|
+
"Provide the trusted 64-character topic hash from the course or saved attempt.");let E=JSON.stringify([f,m,y]),T=n.get(E);
|
|
2206
|
+
return T||(T=a({topicId:f,commit:m,topicHash:y}).finally(()=>n.delete(E)),n.set(E,T)),structuredClone(await T)}async function a({
|
|
2207
|
+
topicId:f,commit:m,topicHash:y}){try{let E=G.join(r,"training"),T=G.join(E,"content"),S=G.join(T,f),v=G.join(S,m);for(let ce of[
|
|
2208
|
+
r,E,T,S,v])await Fr(ce,!0);let R=Et(JSON.parse((await Xt(G.join(v,"pin.json"),4096)).toString("utf8")),{topicId:f,commit:m,
|
|
2209
|
+
topicHash:y}),O=JSON.parse((await Xt(G.join(v,"bundle.json"),32*1024*1024)).toString("utf8")),A=G.join(v,"files"),$=await iA(
|
|
2210
|
+
A),P=await bt(A,{installed:!0}),C={schemaVersion:1,topic:P.topic,release:P.release,topicHash:P.topicHash,topicManifest:P.
|
|
2211
|
+
topicManifest,lessons:P.bundles.map(({lesson:ce,hash:me,status:Uo,required:ig,manifest:sg})=>({code:ce.code,hash:me,status:Uo,
|
|
2212
|
+
required:ig,manifest:sg}))};if(V(O)!==V(C))throw new Error("Installed bundle is incomplete, reordered, unsupported or ch\
|
|
2213
|
+
anged from its source files.");if(P.topic.topicId!==R.topicId||P.release!==R.release||P.topicHash!==R.topicHash)throw new Error(
|
|
2214
|
+
"Installed topic identity differs from its pin.");let D=_t([P.topicManifest,...P.bundles.map(ce=>ce.manifest)]);if(V($)!==
|
|
2215
|
+
V(D.map(ce=>ce.path).sort()))throw new Error("Installed snapshot has missing or unrecorded files.");let Y=await Xt(G.join(
|
|
2216
|
+
A,"package.json"),1024*1024),ae=D.find(ce=>ce.path==="package.json");if(Y.length!==ae.bytes||ne(Y)!==ae.sha256)throw new Error(
|
|
2217
|
+
"Installed source changed during reading.");if(JSON.parse(Y.toString("utf8")).repository?.url!==`https://github.com/${R.
|
|
2218
|
+
repository}.git`)throw new Error("Installed package repository URL differs from its canonical pin.");return{pin:R,...P}}catch(E){
|
|
2219
|
+
let T=["ENOENT","ENOTDIR"].includes(E.code),S=new Error(T?`Pinned teaching content ${f}@${m} is missing. Ask the owner t\
|
|
2220
|
+
o install that exact revision.`:`Pinned teaching content ${f}@${m} is invalid: ${E.message} Ask the owner to reinstall t\
|
|
2221
|
+
he verified snapshot.`,{cause:E});throw S.code=T?"VIBE64_TRAINING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",S}}
|
|
2222
|
+
async function c({pin:f,manifest:m},y,E){let T=G.join(r,"training","content",f.topicId,f.commit,"files"),S=G.resolve(T,y,
|
|
2223
|
+
E),v=G.relative(T,S).split(G.sep).join("/"),R=m.files.find(A=>A.path===v);if(!R)throw new Error("Lesson requested an unr\
|
|
2224
|
+
ecorded installed file.");let O=await Xt(S,1024*1024);if(O.length!==R.bytes||ne(O)!==R.sha256)throw new Error("Installed\
|
|
2225
|
+
lesson changed while reading. Ask the owner to reinstall the verified snapshot.");return{path:v,bytes:O}}async function u({
|
|
2226
|
+
topicId:f,commit:m,topicHash:y,lessonCode:E,lessonHash:T}={}){if(typeof f!="string"||!Xe.test(f)||typeof m!="string"||!Ua.
|
|
2227
|
+
test(m)||typeof y!="string"||!Gr.test(y)||typeof E!="string"||!Xe.test(E)||typeof T!="string"||!Gr.test(T))throw new Error(
|
|
2228
|
+
"Choose an exact pinned topic and lesson identity.");try{let S=G.join(r,"training"),v=G.join(S,"content"),R=G.join(v,f),
|
|
2229
|
+
O=G.join(R,m);for(let me of[r,S,v,R,O])await Fr(me,!0);let A=Et(JSON.parse((await Xt(G.join(O,"pin.json"),4096)).toString(
|
|
2230
|
+
"utf8")),{topicId:f,commit:m,topicHash:y}),$=JSON.parse((await Xt(G.join(O,"bundle.json"),32*1024*1024)).toString("utf8")),
|
|
2231
|
+
P=$.topicManifest;if(!P||ne(V(P))!==y||P.topic.topicId!==f||P.release!==A.release)throw new Error("Installed topic manif\
|
|
2232
|
+
est differs from the trusted identity.");let C=P.lessons.find(me=>me.code===E),D=P.topic.lessons.find(me=>me.code===E),Y=$.
|
|
2233
|
+
lessons.find(me=>me.code===E);if(!C||!D||!Y||C.hash!==T||ne(V(Y.manifest))!==T)throw new Error("Installed lesson manifes\
|
|
2234
|
+
t differs from the trusted content hash.");if(!t(C.status))throw new Error(`Lesson ${E} is draft and cannot be taught. C\
|
|
2235
|
+
hoose a published lesson.`);let ae={pin:A,manifest:Y.manifest,hash:T,descriptorPath:D.descriptor},Qe=await c(ae,".",D.descriptor),
|
|
2236
|
+
ce=Oo(JSON.parse(Qe.bytes.toString("utf8")),E);if(ce.code!==E)throw new Error("Installed lesson descriptor identity chan\
|
|
2237
|
+
ged.");return{...ae,lesson:Va(ce)}}catch(S){let v=new Error(`Pinned teaching identity ${f}@${m} is invalid: ${S.message}\
|
|
2238
|
+
Ask the owner to restore the exact snapshot.`,{cause:S});throw v.code=["ENOENT","ENOTDIR"].includes(S.code)?"VIBE64_TRA\
|
|
2239
|
+
INING_CONTENT_MISSING":"VIBE64_TRAINING_CONTENT_INVALID",v}}async function d(f={}){let m=await p(f);return{...m,lesson:Va(
|
|
2240
|
+
m.lesson)}}async function p({topicId:f,commit:m,topicHash:y,lessonCode:E,lessonHash:T}={}){if(typeof E!="string"||typeof T!=
|
|
2241
|
+
"string"||!Xe.test(E)||!Gr.test(T))throw new Error("Choose a declared lesson code and its exact 64-character lowercase c\
|
|
2242
|
+
ontent hash.");let S=await s({topicId:f,commit:m,topicHash:y}),v=S.bundles.find(O=>O.lesson.code===E);if(!v)throw new Error(
|
|
2243
|
+
`Lesson ${E} is not declared in this pinned topic.`);if(!t(v.status))throw new Error(`Lesson ${E} is draft and cannot be\
|
|
2244
|
+
taught. Choose a published lesson.`);if(v.hash!==T)throw new Error(`Lesson ${E} content hash changed. Resume its exact \
|
|
2245
|
+
pinned revision or explicitly start a new attempt.`);if(v.problem)throw o(v);let R=Object.fromEntries(["places","activit\
|
|
2246
|
+
ies","facts"].map(O=>[O,[...S.topic[O]||[]]]));return{pin:S.pin,lesson:v.lesson,manifest:v.manifest,hash:v.hash,descriptorPath:v.
|
|
2247
|
+
descriptorPath,declarations:R}}async function g(f={}){let m=await d(f),y=G.dirname(m.descriptorPath);async function E(O){
|
|
2248
|
+
let A=await c(m,y,O);return{path:A.path,text:A.bytes.toString("utf8")}}let T=[];for(let O of m.lesson.visuals){let A=await E(
|
|
2249
|
+
O.descriptor);T.push({id:O.id,descriptorPath:A.path,visual:JSON.parse(A.text)})}if(Ae(m.lesson)){let O=Po(m.declarations),
|
|
2250
|
+
A=[];for(let $ of m.lesson.steps){let{body:P,beats:C}=No((await E($.body)).text,O);A.push({...$,bodyText:P,...C?{beats:C}:
|
|
2251
|
+
{}})}return{...m,steps:A,...m.lesson.notes===void 0?{}:{notesText:(await E(m.lesson.notes)).text},visuals:T}}if(m.lesson.
|
|
2252
|
+
schemaVersion!==1)throw new Error(`Lesson ${m.lesson.code} uses an unsupported format.`);let S=await E(m.lesson.document),
|
|
2253
|
+
v=m.lesson.assessments.map(O=>({id:O.id,reference:O.rubric,position:new RegExp(`^<a id="${O.id}"></a>$`,"mu").exec(S.text).
|
|
2254
|
+
index})).sort((O,A)=>O.position-A.position),R=v.map((O,A)=>({id:O.id,reference:O.reference,text:S.text.slice(O.position,
|
|
2255
|
+
v[A+1]?.position??S.text.length)}));return{...m,document:S,rubrics:R,visuals:T}}async function h({stepId:f,...m}={}){if(typeof f!=
|
|
2256
|
+
"string"||!Xe.test(f))throw new Error("Choose a declared step ID.");let{pin:y,lesson:E,hash:T}=await p(m);if(!Ae(E))throw new Error(
|
|
2257
|
+
`Lesson ${E.code} has no steps.`);let S=E.steps.find(v=>v.id===f);if(!S)throw new Error(`Step ${f} is not declared in th\
|
|
2258
|
+
is pinned lesson.`);if(S.check.kind!=="choice")throw new Error(`Step ${f} is not a choice step.`);return{pin:y,lessonCode:E.
|
|
2259
|
+
code,lessonHash:T,stepId:f,answer:[...S.check.answer]}}async function l({topicId:f,commit:m,topicHash:y,lessonCode:E,lessonHash:T,
|
|
2260
|
+
visualId:S}={}){if(typeof S!="string"||!Xe.test(S))throw new Error("Choose a declared visual ID.");let v=await g({topicId:f,
|
|
2261
|
+
commit:m,topicHash:y,lessonCode:E,lessonHash:T}),R=v.visuals.find(C=>C.id===S);if(!R)throw Kt(`Visual ${S} is not declar\
|
|
2262
|
+
ed in this pinned lesson.`,"VIBE64_TRAINING_VISUAL_UNDECLARED",{statusCode:400,params:{visualId:S}});let O=G.dirname(R.descriptorPath),
|
|
2263
|
+
A=await c(v,O,R.visual.svg),$=await c(v,O,R.visual.controller),P=[];for(let C of R.visual.assets||[])P.push(await c(v,O,
|
|
2264
|
+
C));return{pin:v.pin,lessonCode:v.lesson.code,lessonHash:v.hash,...R,svg:A,controller:$,assets:P}}async function w({topicId:f,
|
|
2265
|
+
commit:m,topicHash:y,lessonCode:E,lessonHash:T,checkId:S}={}){if(typeof S!="string"||!Xe.test(S))throw new Error("Choose\
|
|
2266
|
+
a declared check ID.");let v=await g({topicId:f,commit:m,topicHash:y,lessonCode:E,lessonHash:T}),R=v.lesson.checks?.find(
|
|
2267
|
+
P=>P.id===S);if(!R)throw new Error(`Check ${S} is not declared in this pinned lesson.`);let O=G.dirname(v.descriptorPath),
|
|
2268
|
+
A=await c(v,O,R.file),$=[];for(let P of R.assets||[])$.push(await c(v,O,P));return{pin:v.pin,lessonCode:v.lesson.code,lessonHash:v.
|
|
2269
|
+
hash,check:R,file:A,assets:$}}async function _({topicId:f,commit:m,topicHash:y,lessonCode:E,lessonHash:T,metadataOnly:S=!1,
|
|
2270
|
+
admissionOnly:v=!1}={}){if(v===!0&&S!==!0)throw new TypeError("Admission reads cannot supply exercise content.");let O=await(v===
|
|
2271
|
+
!0?u:S===!0?d:g)({topicId:f,commit:m,topicHash:y,lessonCode:E,lessonHash:T}),A=O.lesson.exercise;if(!A)throw Object.assign(
|
|
2272
|
+
new Error(`Lesson ${E} has no declared bundled exercise.`),{code:"VIBE64_TRAINING_EXERCISE_MISSING"});let $=G.posix.join(
|
|
2273
|
+
G.posix.dirname(O.descriptorPath),A.source),P={pin:O.pin,lessonCode:O.lesson.code,lessonHash:O.hash,exercise:A,sourcePath:$};
|
|
2274
|
+
if(S===!0)return P;let C=$==="."?"":`${$}/`,D=[];for(let Y of O.manifest.files){if(!Y.path.startsWith(C))continue;let ae=Y.
|
|
2275
|
+
path.slice(C.length),Qe=await c(O,$,ae);D.push({path:ae,bytes:Qe.bytes})}return{...P,files:D}}return Object.freeze({readTopic:i,
|
|
2276
|
+
readLesson:g,readAdmissionIdentity:u,readVisual:l,readCheck:w,readExercise:_,readChoiceAnswer:h})}var Xe,Ua,Gr,nA,zr,oA,
|
|
2277
|
+
sA,Ba=b(()=>{To();Jt();Wt();Ma();Co();Hh();Yt();$o();Xe=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,Ua=/^[a-f0-9]{40}$/u,Gr=/^[a-f0-9]{64}$/u,
|
|
2278
|
+
nA=/^[a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+$/u,zr={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},oA=L({
|
|
2279
|
+
schemaVersion:{type:"integer",required:!0,enum:[1]},topicId:{...zr,maxLength:64},release:zr,repository:zr,commit:{...zr,
|
|
2280
|
+
maxLength:40},topicHash:{...zr,maxLength:64}});sA=e=>e==="published"});import{randomUUID as cA}from"node:crypto";import{lstat as uA,mkdir as Ga,realpath as lA,rename as dA,rm as fA,writeFile as pA}from"node:fs/promises";
|
|
2281
|
+
import oe from"node:path";function qh(e,t){if(typeof e!="string"||!oe.isAbsolute(e)||oe.resolve(e)!==e||e===oe.parse(e).
|
|
2282
|
+
root)throw new Error(`${t} must be a normalized absolute, non-root server-owned directory.`);return e}function Wh(e,t){let r=oe.
|
|
2283
|
+
relative(e,t);return!r||r!==".."&&!r.startsWith(`..${oe.sep}`)&&!oe.isAbsolute(r)}async function Ne(e,t,r=!0){let n;try{
|
|
2284
|
+
n=await uA(e)}catch(o){if(r&&o.code==="ENOENT")return null;throw o}if(n.isSymbolicLink()||await lA(e)!==e)throw new Error(
|
|
1640
2285
|
"Training installation cannot use symlink or directory aliases.");if(t?!n.isDirectory():!n.isFile())throw new Error(`Tra\
|
|
1641
2286
|
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=
|
|
1644
|
-
code!=="EEXIST")throw t}await
|
|
1645
|
-
pshot conflicts with the approved owner pin. Keep existing content and check the exact source revision.")}async function
|
|
1646
|
-
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await
|
|
1647
|
-
commit:i,topicHash:s},t)}function
|
|
1648
|
-
sourceRoot:o,pin:i}={}){let s={...
|
|
1649
|
-
throw new Error("Trusted topic source must be separate from the training installation namespace.");let c=
|
|
1650
|
-
|
|
1651
|
-
await
|
|
1652
|
-
s)).pin,s);else{if(!h)throw new Error("Trusted topic source is missing. Prepare the approved local repository
|
|
1653
|
-
|
|
1654
|
-
is being installed. Retry after the current owner operation finishes.","VIBE64_TRAINING_INSTALL_BUSY");let
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
"content",s.topicId);await
|
|
1658
|
-
await
|
|
1659
|
-
`,{flag:"wx",mode:384}),await
|
|
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 ow(e,t,r={}){let{directoryMode:n,fileMode:o}=r,i=Oi.dirname(e);await ew(i,{recursive:!0,
|
|
1664
|
-
mode:n});let s=Oi.join(i,`.${Oi.basename(e)}.${process.pid}.${Qg()}.tmp`);try{await nw(s,t,{encoding:"utf8",flag:"wx",mode:o}),
|
|
1665
|
-
o!==void 0&&await Zg(s,o),await tw(s,e)}finally{await rw(s,{force:!0})}}async function ku(e,t,r={}){await ow(e,`${JSON.stringify(
|
|
1666
|
-
t,null,2)}
|
|
1667
|
-
`,r)}var xu=g(()=>{});import{lstat as iw,mkdir as sw,readFile as aw,realpath as cw}from"node:fs/promises";import Le from"node:path";function Ri(e){
|
|
2287
|
+
aining installation lock must be an unaliased empty regular file; inspect it before retrying.");return n}async function Lo(e,t=!1){
|
|
2288
|
+
let r=oe.dirname(e);return r!==e&&await Lo(r,t),Ne(e,!0,t)}async function mA(e){try{await Ga(e,{mode:448})}catch(t){if(t.
|
|
2289
|
+
code!=="EEXIST")throw t}await Ne(e,!0,!1)}function Mo(e,t){if(V(e)!==V(t))throw new Error("Topic source or installed sna\
|
|
2290
|
+
pshot conflicts with the approved owner pin. Keep existing content and check the exact source revision.")}async function za(e,t){
|
|
2291
|
+
let{topicId:r,release:n,repository:o,commit:i,topicHash:s}=await Ur(e);Mo({schemaVersion:1,topicId:r,release:n,repository:o,
|
|
2292
|
+
commit:i,topicHash:s},t)}function Yh({systemRoot:e}){let t=qh(e,"Training system root"),r=Hr({systemRoot:t});async function n({
|
|
2293
|
+
sourceRoot:o,pin:i}={}){let s={...Et(i)};qh(o,"Trusted topic source root");let a=oe.join(t,"training");if(Wh(o,a)||Wh(a,
|
|
2294
|
+
o))throw new Error("Trusted topic source must be separate from the training installation namespace.");let c=oe.join(a,"c\
|
|
2295
|
+
ontent"),u=oe.join(c,s.topicId),d=oe.join(u,s.commit),p=oe.join(a,".install-locks"),g=oe.join(p,`${s.topicId}-${s.commit}\
|
|
2296
|
+
.lock`);await Lo(t);let h=await Lo(o,!0);for(let f of[a,c,u,p])await Ne(f,!0);if(await Ne(g,!1),await Ne(d,!0))Mo((await r.
|
|
2297
|
+
readTopic(s)).pin,s);else{if(!h)throw new Error("Trusted topic source is missing. Prepare the approved local repository \
|
|
2298
|
+
before installing its pin.");await za(o,s)}for(let f of[a,c,u,p])await mA(f);let w=await Dt(g);if(!w)throw ko("This topi\
|
|
2299
|
+
c revision is being installed. Retry after the current owner operation finishes.","VIBE64_TRAINING_INSTALL_BUSY");let _;
|
|
2300
|
+
try{await Ne(g,!1,!1);for(let T of[t,a,c,u,p])await Ne(T,!0,!1);if(await Ne(d,!0)){let T=await r.readTopic(s);return Mo(
|
|
2301
|
+
T.pin,s),{installed:!1,...T}}await Lo(o),await za(o,s);let f=oe.join(a,`.install-${cA()}`);await Ga(f,{mode:448}),_=f;let m=oe.
|
|
2302
|
+
join(_,"training","content",s.topicId);await Ga(m,{recursive:!0,mode:448});let y=oe.join(m,s.commit);if(await Fa(["bundl\
|
|
2303
|
+
e",o,y],{write(){}}),await za(o,s),await pA(oe.join(y,"pin.json"),`${V(s)}
|
|
2304
|
+
`,{flag:"wx",mode:384}),await Hr({systemRoot:_}).readTopic(s),await Ne(u,!0,!1),await Ne(d,!0))throw new Error("The dest\
|
|
2305
|
+
ination appeared during installation. Keep it unchanged and retry the verified pin.");await dA(y,d);let E=await r.readTopic(
|
|
2306
|
+
s);return Mo(E.pin,s),{installed:!0,...E}}finally{try{_&&await fA(_,{recursive:!0,force:!0})}finally{await w()}}}return Object.
|
|
2307
|
+
freeze({installTopic:n})}var Jh=b(()=>{Yn();xo();Ha();Jt();$o();Ba()});import{lstat as hA,mkdir as gA,readFile as yA,realpath as wA}from"node:fs/promises";import Ze from"node:path";function Wa(e){
|
|
1668
2308
|
if(!Number.isSafeInteger(e)||e<0)throw new Error("Supply the expected revision from a fresh installed catalogue read.")}
|
|
1669
|
-
function
|
|
1670
|
-
"Installed catalogue needs a canonical absolute, non-root server-owned system root.");let t=
|
|
1671
|
-
t,"catalogue.json"),n=
|
|
1672
|
-
|
|
1673
|
-
"ENOENT")continue;throw
|
|
1674
|
-
nlink!==1))throw new Error("Installed catalogue paths must be canonical directories and unaliased regular files.");if(
|
|
1675
|
-
e&&(
|
|
1676
|
-
; do not unlink it.")}return{rootExists:
|
|
1677
|
-
|
|
1678
|
-
le topic in order.");let
|
|
1679
|
-
repository:
|
|
1680
|
-
"Installed topic identity differs from the approved course lock.");
|
|
1681
|
-
topic.title});for(let
|
|
1682
|
-
lesson.title});
|
|
1683
|
-
topicManifest,topicHash:
|
|
1684
|
-
differs from the complete installed topic inventory. Regenerate and review its exact release.");return{lessonTitles:
|
|
1685
|
-
async function a({includeLessonTitles:
|
|
1686
|
-
ires an explicit Boolean read option.");try{let{catalogueStat:
|
|
1687
|
-
if(
|
|
1688
|
-
"Installed catalogue exceeds its 1 MiB limit.");let
|
|
1689
|
-
length&&
|
|
1690
|
-
for(let
|
|
1691
|
-
e contains duplicate course releases.");
|
|
1692
|
-
topicTitles:
|
|
2309
|
+
function Ya({systemRoot:e}){if(typeof e!="string"||!Ze.isAbsolute(e)||Ze.resolve(e)!==e||e===Ze.parse(e).root)throw new Error(
|
|
2310
|
+
"Installed catalogue needs a canonical absolute, non-root server-owned system root.");let t=Ze.join(e,"training"),r=Ze.join(
|
|
2311
|
+
t,"catalogue.json"),n=Ze.join(t,"catalogue.lock"),o=Hr({systemRoot:e});async function i(){let _=[t];for(let y=e;_.unshift(
|
|
2312
|
+
y),y!==Ze.dirname(y);y=Ze.dirname(y));let f=!1,m=null;for(let y of[..._,r,n]){let E;try{E=await hA(y)}catch(S){if(S.code===
|
|
2313
|
+
"ENOENT")continue;throw S}let T=y!==r&&y!==n;if(E.isSymbolicLink()||await wA(y)!==y||(T?!E.isDirectory():!E.isFile()||E.
|
|
2314
|
+
nlink!==1))throw new Error("Installed catalogue paths must be canonical directories and unaliased regular files.");if(y===
|
|
2315
|
+
e&&(f=!0),y===r&&(m=E),y===n&&E.size!==0)throw new Error("Installed catalogue lock contains unexplained data. Inspect it\
|
|
2316
|
+
; do not unlink it.")}return{rootExists:f,catalogueStat:m}}async function s(_){let f=_.lock.topics;if(!Array.isArray(f)||
|
|
2317
|
+
f.length!==_.course.topics.length||f.length>32)throw new Error("The approved course lock must contain every selected who\
|
|
2318
|
+
le topic in order.");let m=[],y=[],E=[];for(let S of f){let v=Et({schemaVersion:1,topicId:S?.topicId,release:S?.release,
|
|
2319
|
+
repository:S?.repository,commit:S?.commit,topicHash:S?.manifestHash}),R=await o.readTopic(v);if(V(R.pin)!==V(v))throw new Error(
|
|
2320
|
+
"Installed topic identity differs from the approved course lock.");E.push({topicId:v.topicId,release:v.release,title:R.topicManifest.
|
|
2321
|
+
topic.title});for(let O of R.bundles)y.push({topicId:v.topicId,topicRelease:v.release,code:O.lesson.code,hash:O.hash,title:O.
|
|
2322
|
+
lesson.title});m.push({topicId:R.pin.topicId,release:R.release,repository:R.pin.repository,commit:R.pin.commit,topicManifest:R.
|
|
2323
|
+
topicManifest,topicHash:R.topicHash})}let T=Br(_.course,m);if(V(_.lock)!==V(T))throw new Error("The approved course lock\
|
|
2324
|
+
differs from the complete installed topic inventory. Regenerate and review its exact release.");return{lessonTitles:y,topicTitles:E}}
|
|
2325
|
+
async function a({includeLessonTitles:_=!1}={}){if(typeof _!="boolean")throw new TypeError("Lesson title projection requ\
|
|
2326
|
+
ires an explicit Boolean read option.");try{let{catalogueStat:f}=await i();if(!f)return{schemaVersion:1,revision:0,courses:[]};
|
|
2327
|
+
if(f.size>qa)throw new Error("Installed catalogue exceeds its 1 MiB limit.");let m=await yA(r);if(m.length>qa)throw new Error(
|
|
2328
|
+
"Installed catalogue exceeds its 1 MiB limit.");let y=we(_A,JSON.parse(m.toString("utf8")),"Installed catalogue");if(y.courses.
|
|
2329
|
+
length&&y.revision<1)throw new Error("Installed catalogue revision conflicts with its course inventory.");let E=new Set;
|
|
2330
|
+
for(let T of y.courses){let S=`${T.course.courseId}@${T.course.release}`;if(E.has(S))throw new Error("Installed catalogu\
|
|
2331
|
+
e contains duplicate course releases.");E.add(S);let{lessonTitles:v,topicTitles:R}=await s(T);_&&Object.assign(T,{lessonTitles:v,
|
|
2332
|
+
topicTitles:R})}return y}catch(f){throw Da(`Installed catalogue is invalid: ${f.message} Keep existing state and ask the\
|
|
1693
2333
|
owner to restore the exact approved catalogue or pinned content. No automatic repair was performed.`,"VIBE64_TRAINING_C\
|
|
1694
|
-
ATALOGUE_INVALID",
|
|
1695
|
-
tem root before changing the catalogue.");try{await
|
|
1696
|
-
n);if(!
|
|
1697
|
-
NING_CATALOGUE_BUSY",409);return
|
|
1698
|
-
rent revision before deliberately retrying this enablement change.","VIBE64_TRAINING_CATALOGUE_REVISION_CONFLICT",409)}async function
|
|
1699
|
-
if(
|
|
1700
|
-
ritten.");let
|
|
1701
|
-
`)>
|
|
1702
|
-
fileMode:384})}catch(
|
|
2334
|
+
ATALOGUE_INVALID",f)}}async function c(){let{rootExists:_}=await i();if(!_)throw new Error("Prepare the server-owned sys\
|
|
2335
|
+
tem root before changing the catalogue.");try{await gA(t,{mode:448})}catch(m){if(m.code!=="EEXIST")throw m}await i();let f=await Dt(
|
|
2336
|
+
n);if(!f)throw Ce("Installed catalogue is being updated. Retry after the current owner operation finishes.","VIBE64_TRAI\
|
|
2337
|
+
NING_CATALOGUE_BUSY",409);return f}function u(_,f){if(_.revision!==f)throw Ce("Installed catalogue changed. Read its cur\
|
|
2338
|
+
rent revision before deliberately retrying this enablement change.","VIBE64_TRAINING_CATALOGUE_REVISION_CONFLICT",409)}async function d(_,f){
|
|
2339
|
+
if(_.revision===Number.MAX_SAFE_INTEGER)throw new Error("Installed catalogue reached its revision limit. No change was w\
|
|
2340
|
+
ritten.");let m={..._,revision:_.revision+1};if(Buffer.byteLength(`${JSON.stringify(m,null,2)}
|
|
2341
|
+
`)>qa)throw new Error("Installed catalogue exceeds its 1 MiB limit. No change was written.");try{await Dn(r,m,{directoryMode:448,
|
|
2342
|
+
fileMode:384})}catch(y){throw Da("Catalogue save was not confirmed; atomic rename may already have succeeded. Read the c\
|
|
1703
2343
|
urrent catalogue before deliberately retrying. Do not assume the course changed or remained unchanged.","VIBE64_TRAINING\
|
|
1704
|
-
_CATALOGUE_SAVE_UNCONFIRMED",
|
|
1705
|
-
|
|
1706
|
-
try{let
|
|
1707
|
-
|
|
2344
|
+
_CATALOGUE_SAVE_UNCONFIRMED",y)}return{revision:m.revision,entry:f,changed:!0}}async function p({course:_,lock:f,expectedRevision:m}={}){
|
|
2345
|
+
Wa(m);let y=structuredClone(we(Kh,{course:_,lock:f,enabled:!0},"Approved installed course"));await a(),await s(y);let E=await c();
|
|
2346
|
+
try{let T=await a();u(T,m),await s(y);let S=T.courses.find(v=>v.course.courseId===y.course.courseId&&v.course.release===
|
|
2347
|
+
y.course.release);if(S){if(V(S.course)!==V(y.course)||V(S.lock)!==V(y.lock))throw Ce("This installed course release is i\
|
|
1708
2348
|
mmutable. Resume its approved pin or publish and approve a different course release.","VIBE64_TRAINING_COURSE_RELEASE_CO\
|
|
1709
|
-
NFLICT",409);return
|
|
1710
|
-
|
|
1711
|
-
e-course to free a place; no release was removed.");return
|
|
1712
|
-
courseId:
|
|
1713
|
-
string"||!/^\d+\.\d+\.\d+$/u.test(
|
|
1714
|
-
t release.`);if(!(await a()).courses.some(
|
|
1715
|
-
is not installed in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_MISSING",404);let
|
|
1716
|
-
try{let
|
|
2349
|
+
NFLICT",409);return S.enabled?{revision:T.revision,entry:S,changed:!1}:(S.enabled=!0,await d(T,S))}if(T.courses.length>=
|
|
2350
|
+
qr)throw new Error("Installed catalogue reached its 16 course-release limit. Remove a release with vibe64 training remov\
|
|
2351
|
+
e-course to free a place; no release was removed.");return T.courses.push(y),await d(T,y)}finally{await E()}}async function g({
|
|
2352
|
+
courseId:_,release:f,expectedRevision:m},y){if(Wa(m),typeof _!="string"||!/^[a-z][a-z0-9-]{0,63}$/u.test(_)||typeof f!="\
|
|
2353
|
+
string"||!/^\d+\.\d+\.\d+$/u.test(f))throw new Error(`${y?"Remove":"Disable"} an exact installed course ID and three-par\
|
|
2354
|
+
t release.`);if(!(await a()).courses.some(S=>S.course.courseId===_&&S.course.release===f))throw Ce("This course release \
|
|
2355
|
+
is not installed in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_MISSING",404);let T=await c();
|
|
2356
|
+
try{let S=await a();u(S,m);let v=S.courses.find(R=>R.course.courseId===_&&R.course.release===f);if(!v)throw Ce("This cou\
|
|
1717
2357
|
rse release is no longer in the catalogue. Read the current catalogue before retrying.","VIBE64_TRAINING_COURSE_REMOVED",
|
|
1718
|
-
404);return
|
|
1719
|
-
entry:
|
|
1720
|
-
|
|
1721
|
-
E64_TRAINING_COURSE_NAME_INVALID",400);if(!Array.isArray(
|
|
1722
|
-
release}`)).size!==
|
|
1723
|
-
cs for the course.","VIBE64_TRAINING_COURSE_TOPICS_INVALID",400);let
|
|
1724
|
-
status==="released").flatMap(
|
|
1725
|
-
release);if(
|
|
1726
|
-
choose an installed topic.`,"VIBE64_TRAINING_COURSE_TOPIC_UNAVAILABLE",404);let
|
|
1727
|
-
topicId
|
|
1728
|
-
pin.topicId,release:
|
|
1729
|
-
topicHash})}let
|
|
1730
|
-
slice(0,48).replace(/-+$/u,"")||
|
|
1731
|
-
topicId,release:
|
|
1732
|
-
ourse with this name already exists. Choose another name.","VIBE64_TRAINING_COURSE_EXISTS",409);if(!
|
|
1733
|
-
|
|
1734
|
-
_LIMIT",{statusCode:409,params:{limit:
|
|
1735
|
-
enableCourse:
|
|
1736
|
-
|
|
1737
|
-
type:"boolean",required:!0}}),
|
|
1738
|
-
min:0,max:Number.MAX_SAFE_INTEGER},courses:
|
|
1739
|
-
import
|
|
1740
|
-
"install-topic"){let[,c,
|
|
1741
|
-
pic-directory> <system-root>");let
|
|
1742
|
-
schemaVersion:1,topicId:
|
|
1743
|
-
{sourceRoot:
|
|
1744
|
-
urses"){if(e.length!==2||!e[1])throw new Error("Usage: vibe64 training installed-courses <system-root>");let c=await
|
|
1745
|
-
{systemRoot:
|
|
1746
|
-
le-course","remove-course"].includes(e[0])){let[c,
|
|
1747
|
-
"")||!Number.isSafeInteger(Number(
|
|
2358
|
+
404);return y?(S.courses=S.courses.filter(R=>R!==v),await d(S,v)):v.enabled?(v.enabled=!1,await d(S,v)):{revision:S.revision,
|
|
2359
|
+
entry:v,changed:!1}}finally{await T()}}let h=_=>g(_,!1),l=_=>g(_,!0);async function w({title:_,topics:f,expectedRevision:m}){
|
|
2360
|
+
Wa(m);let y=typeof _=="string"?_.trim():"";if(!y||y.length>120)throw Ce("Name the course with 1 to 120 characters.","VIB\
|
|
2361
|
+
E64_TRAINING_COURSE_NAME_INVALID",400);if(!Array.isArray(f)||!f.length||f.length>32||new Set(f.map(A=>`${A?.topicId}@${A?.
|
|
2362
|
+
release}`)).size!==f.length||new Set(f.map(A=>A?.topicId)).size!==f.length)throw Ce("Choose 1 to 32 different whole topi\
|
|
2363
|
+
cs for the course.","VIBE64_TRAINING_COURSE_TOPICS_INVALID",400);let E=await a(),T=E.courses.filter(A=>A.enabled&&A.course.
|
|
2364
|
+
status==="released").flatMap(A=>A.lock.topics),S=[];for(let A of f){let $=T.find(C=>C.topicId===A.topicId&&C.release===A.
|
|
2365
|
+
release);if(!$)throw Ce(`Topic ${A.topicId}@${A.release} is not part of an enabled released course. Refresh courses and \
|
|
2366
|
+
choose an installed topic.`,"VIBE64_TRAINING_COURSE_TOPIC_UNAVAILABLE",404);let P=await o.readTopic(Et({schemaVersion:1,
|
|
2367
|
+
topicId:$.topicId,release:$.release,repository:$.repository,commit:$.commit,topicHash:$.manifestHash}));S.push({topicId:P.
|
|
2368
|
+
pin.topicId,release:P.release,repository:P.pin.repository,commit:P.pin.commit,topicManifest:P.topicManifest,topicHash:P.
|
|
2369
|
+
topicHash})}let R={schemaVersion:1,courseId:`custom-${y.toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"").
|
|
2370
|
+
slice(0,48).replace(/-+$/u,"")||ne(y).slice(0,12)}`,title:y,release:"1.0.0",status:"released",topics:f.map(A=>({topicId:A.
|
|
2371
|
+
topicId,release:A.release}))},O=E.courses.find(A=>A.course.courseId===R.courseId);if(O&&V(O.course)!==V(R))throw Ce("A c\
|
|
2372
|
+
ourse with this name already exists. Choose another name.","VIBE64_TRAINING_COURSE_EXISTS",409);if(!O&&E.courses.length>=
|
|
2373
|
+
qr)throw Kt(`This installation already has ${qr} course releases. No course was created.`,"VIBE64_TRAINING_COURSE_CREATE\
|
|
2374
|
+
_LIMIT",{statusCode:409,params:{limit:qr}});return p({course:R,lock:Br(R,S),expectedRevision:m})}return Object.freeze({readCatalogue:a,
|
|
2375
|
+
enableCourse:p,disableCourse:h,removeCourse:l,createCourse:w})}var qr,qa,Kh,_A,Xh=b(()=>{To();Yn();yr();xo();Jt();Wt();Ba();
|
|
2376
|
+
$o();Yt();qr=16,qa=1024*1024,Kh=L({course:{type:"object",required:!0,schema:Ao},lock:{type:"object",required:!0},enabled:{
|
|
2377
|
+
type:"boolean",required:!0}}),_A=L({schemaVersion:{type:"integer",required:!0,enum:[1]},revision:{type:"integer",required:!0,
|
|
2378
|
+
min:0,max:Number.MAX_SAFE_INTEGER},courses:W(Kh,qr)})});var eg={};zo(eg,{runTrainingCli:()=>Fa});import{mkdir as Zh,readFile as Do,realpath as Zt,rename as bA,rm as Qh,writeFile as Ja}from"node:fs/promises";
|
|
2379
|
+
import Z from"node:path";import{randomUUID as EA}from"node:crypto";async function Fa(e,{write:t=r=>console.log(r)}={}){if(e[0]===
|
|
2380
|
+
"install-topic"){let[,c,u]=e;if(e.length!==3||!c||!u)throw new Error("Usage: vibe64 training install-topic <committed-to\
|
|
2381
|
+
pic-directory> <system-root>");let d=await Zt(c),{topicId:p,release:g,repository:h,commit:l,topicHash:w}=await Ur(d),_={
|
|
2382
|
+
schemaVersion:1,topicId:p,release:g,repository:h,commit:l,topicHash:w},f=await Yh({systemRoot:Z.resolve(u)}).installTopic(
|
|
2383
|
+
{sourceRoot:d,pin:_});return t(JSON.stringify({ok:!0,installed:f.installed,pin:f.pin},null,2)),0}if(e[0]==="installed-co\
|
|
2384
|
+
urses"){if(e.length!==2||!e[1])throw new Error("Usage: vibe64 training installed-courses <system-root>");let c=await Ya(
|
|
2385
|
+
{systemRoot:Z.resolve(e[1])}).readCatalogue();return t(JSON.stringify({ok:!0,...c},null,2)),0}if(["enable-course","disab\
|
|
2386
|
+
le-course","remove-course"].includes(e[0])){let[c,u,d,p,g]=e;if(e.length!==5||!u||!d||!p||!/^(0|[1-9][0-9]*)$/u.test(g||
|
|
2387
|
+
"")||!Number.isSafeInteger(Number(g)))throw new Error(c==="enable-course"?"Usage: vibe64 training enable-course <course.\
|
|
1748
2388
|
json> <course.lock.json> <system-root> <expected-revision>":`Usage: vibe64 training ${c} <courseId> <release> <system-ro\
|
|
1749
|
-
ot> <expected-revision>`);let h=
|
|
1750
|
-
parse(await
|
|
1751
|
-
urse":"disableCourse"]({courseId:
|
|
1752
|
-
"publish-manifest"){let[,c,...
|
|
1753
|
-
n> <committed-topic-directory...>");let
|
|
1754
|
-
|
|
1755
|
-
let
|
|
1756
|
-
sep}`)&&
|
|
1757
|
-
|
|
1758
|
-
`,{flag:"wx"}),await
|
|
1759
|
-
status,lockPath:
|
|
2389
|
+
ot> <expected-revision>`);let h=Ya({systemRoot:Z.resolve(p)}),l=Number(g),w=c==="enable-course"?await h.enableCourse({course:JSON.
|
|
2390
|
+
parse(await Do(u,"utf8")),lock:JSON.parse(await Do(d,"utf8")),expectedRevision:l}):await h[c==="remove-course"?"removeCo\
|
|
2391
|
+
urse":"disableCourse"]({courseId:u,release:d,expectedRevision:l});return t(JSON.stringify({ok:!0,...w},null,2)),0}if(e[0]===
|
|
2392
|
+
"publish-manifest"){let[,c,...u]=e;if(!c||!u.length)throw new Error("Usage: vibe64 training publish-manifest <course.jso\
|
|
2393
|
+
n> <committed-topic-directory...>");let d=await Zt(c),p=Z.join(await Zt(Z.dirname(Z.resolve(c))),"course.lock.json");if(p===
|
|
2394
|
+
d||Z.basename(c)==="course.lock.json")throw new Error("Course lock output must not replace its input course descriptor.");
|
|
2395
|
+
let g=JSON.parse(await Do(d,"utf8")),h=[];for(let _ of u){let f=await Zt(_),m=Z.relative(f,p);if(!m||!m.startsWith(`..${Z.
|
|
2396
|
+
sep}`)&&m!==".."&&!Z.isAbsolute(m))throw new Error("Course lock output must be outside every pinned source topic.");await bt(
|
|
2397
|
+
f,{authoring:!0}),h.push(await Ur(f))}let l=Br(g,h),w=`${p}.tmp-${EA()}`;try{await Ja(w,`${V(l)}
|
|
2398
|
+
`,{flag:"wx"}),await bA(w,p)}finally{await Qh(w,{force:!0})}return t(JSON.stringify({ok:!0,courseId:l.courseId,status:l.
|
|
2399
|
+
status,lockPath:p,topics:l.topics.length},null,2)),0}let[r,n,o]=e;if(!["validate","bundle"].includes(r)||!n||r==="bundle"&&
|
|
1760
2400
|
!o||e.length!==(r==="bundle"?3:2))throw new Error("Usage: vibe64 training validate <topic-directory> | bundle <topic-dir\
|
|
1761
|
-
ectory> <new-output-directory>");let i=await
|
|
1762
|
-
release:s.release,topicHash:s.topicHash,topicManifest:s.topicManifest,lessons:s.bundles.map(({lesson:c,hash:
|
|
1763
|
-
manifest:
|
|
1764
|
-
|
|
1765
|
-
"Bundle output must be outside the source topic.");await
|
|
1766
|
-
for(let
|
|
1767
|
-
path}. Validate and retry.`);let
|
|
1768
|
-
await
|
|
1769
|
-
`,{flag:"wx"})}catch(
|
|
1770
|
-
status:s.topic.status,lessons:s.bundles.map(({lesson:c,hash:
|
|
1771
|
-
schemaVersion,...c.stage?{stage:c.stage}:{},...
|
|
1772
|
-
|
|
1773
|
-
import
|
|
1774
|
-
resolve(String(e||""));try{return t(r)}catch{return r}}function
|
|
1775
|
-
return n
|
|
1776
|
-
return`'${String(e).replaceAll("'","'\\''")}'`}function
|
|
1777
|
-
"${String(e).replaceAll('"','\\"')}"`}function
|
|
1778
|
-
...t}={}){return
|
|
1779
|
-
env,osReleaseText:t=
|
|
1780
|
-
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function
|
|
1781
|
-
return[
|
|
1782
|
-
title:o=`Vibe64 - ${
|
|
2401
|
+
ectory> <new-output-directory>");let i=await Zt(n),s=await bt(i,{authoring:r==="validate"}),a={schemaVersion:1,topic:s.topic,
|
|
2402
|
+
release:s.release,topicHash:s.topicHash,topicManifest:s.topicManifest,lessons:s.bundles.map(({lesson:c,hash:u,status:d,required:p,
|
|
2403
|
+
manifest:g})=>({code:c.code,hash:u,status:d,required:p,manifest:g}))};if(r==="bundle"){let c=Z.resolve(o),u=Z.join(await Zt(
|
|
2404
|
+
Z.dirname(c)),Z.basename(c)),d=Z.relative(i,u);if(!d||!d.startsWith(`..${Z.sep}`)&&d!==".."&&!Z.isAbsolute(d))throw new Error(
|
|
2405
|
+
"Bundle output must be outside the source topic.");await Zh(u);try{let p=_t([s.topicManifest,...s.bundles.map(g=>g.manifest)]);
|
|
2406
|
+
for(let g of p){let h=await Do(Z.join(i,g.path));if(ne(h)!==g.sha256)throw new Error(`Source changed during bundling: ${g.
|
|
2407
|
+
path}. Validate and retry.`);let l=Z.join(u,"files",g.path);await Zh(Z.dirname(l),{recursive:!0}),await Ja(l,h,{flag:"wx"})}
|
|
2408
|
+
await Ja(Z.join(u,"bundle.json"),`${V(a)}
|
|
2409
|
+
`,{flag:"wx"})}catch(p){throw await Qh(u,{recursive:!0,force:!0}),p}}return t(JSON.stringify({ok:!0,topicId:s.topic.topicId,
|
|
2410
|
+
status:s.topic.status,lessons:s.bundles.map(({lesson:c,hash:u,status:d})=>({code:c.code,hash:u,status:d,schemaVersion:c.
|
|
2411
|
+
schemaVersion,...c.stage?{stage:c.stage}:{},...Ae(c)?{steps:c.steps.length}:{}}))},null,2)),0}var Ha=b(()=>{Jt();Wt();xo();
|
|
2412
|
+
Jh();Xh();Yt()});import{spawn as tg}from"node:child_process";import{readFileSync as vA}from"node:fs";import{release as Vo}from"node:os";import M from"node:process";
|
|
2413
|
+
import Wr from"node:path";import{fileURLToPath as TA}from"node:url";import{realpathSync as mg}from"node:fs";import hg from"node:path";import gg from"node:process";function Xa(e,t){let r=hg.
|
|
2414
|
+
resolve(String(e||""));try{return t(r)}catch{return r}}function Za({entrypointPath:e,argv:t=gg.argv,realpath:r=mg}){let n=t[1];
|
|
2415
|
+
return n?Xa(n,r)===Xa(e,r):!1}var SA=new URL("./run.js",import.meta.url).href,rg=TA(SA),ng=Wr.dirname(rg),er=Wr.join(ng,"server.js");function Qt(e=""){
|
|
2416
|
+
return`'${String(e).replaceAll("'","'\\''")}'`}function IA(e=""){return JSON.stringify(String(e))}function Ka(e=""){return`\
|
|
2417
|
+
"${String(e).replaceAll('"','\\"')}"`}function OA(e="",t=[]){return[Ka(e),...t.map(r=>Ka(r))].join(" ")}function RA({entrypointPath:e=rg,
|
|
2418
|
+
...t}={}){return Za({entrypointPath:e,...t})}function og(e=M.cwd()){return Wr.basename(e)||"target"}function AA({env:e=M.
|
|
2419
|
+
env,osReleaseText:t=Vo(),platform:r=M.platform}={}){return r!=="linux"?!1:String(e.WSL_DISTRO_NAME||e.WSL_INTEROP||"").trim()?
|
|
2420
|
+
!0:/\bmicrosoft\b|\bwsl\b/iu.test(String(t||""))}function PA({nodePath:e=M.execPath,serverPath:t=er,serverArgs:r=[]}={}){
|
|
2421
|
+
return[Qt(e),Qt(t),...r.map(n=>Qt(n))].join(" ")}function CA({cwd:e=M.cwd(),nodePath:t=M.execPath,serverArgs:r=[],serverPath:n=er,
|
|
2422
|
+
title:o=`Vibe64 - ${Wr.basename(M.cwd())||"target"}`}={}){return["finish_vibe64_terminal() {",' status="$1"',' message\
|
|
1783
2423
|
="$2"',' if [ "$status" -ne 0 ]; then',` printf '\\n%s Exit status %s. Press Enter to close this terminal...' "$messa\
|
|
1784
|
-
ge" "$status"`," IFS= read -r _"," fi",' exit "$status"',"}",`cd ${
|
|
1785
|
-
n',' finish_vibe64_terminal "$status" "Vibe64 could not enter the target directory."',"fi",`printf '\\033]0;%s\\007' ${
|
|
1786
|
-
o)}`,
|
|
1787
|
-
`)}function
|
|
1788
|
-
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",
|
|
1789
|
-
cwd:e=
|
|
1790
|
-
return[{command:"wt.exe",args:["new-window","--title",n,"wsl.exe",...o]},{command:"cmd.exe",args:["/d","/c",`start ${
|
|
1791
|
-
n)} ${
|
|
1792
|
-
platform,serverArgs:i=[],serverPath:s=
|
|
1793
|
-
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${
|
|
2424
|
+
ge" "$status"`," IFS= read -r _"," fi",' exit "$status"',"}",`cd ${Qt(e)}`,"status=$?",'if [ "$status" -ne 0 ]; the\
|
|
2425
|
+
n',' finish_vibe64_terminal "$status" "Vibe64 could not enter the target directory."',"fi",`printf '\\033]0;%s\\007' ${Qt(
|
|
2426
|
+
o)}`,PA({nodePath:t,serverArgs:r,serverPath:n}),'finish_vibe64_terminal "$?" "Vibe64 server exited."'].join(`
|
|
2427
|
+
`)}function NA(e=""){return`printf %s ${Buffer.from(String(e||""),"utf8").toString("base64")} | base64 -d | bash`}function jA({
|
|
2428
|
+
distroName:e="",shellScript:t=""}={}){let r=String(e||"").trim();return[...r?["-d",r]:[],"--","bash","-lc",NA(t)]}function xA({
|
|
2429
|
+
cwd:e=M.cwd(),env:t=M.env,shellScript:r="",title:n=`Vibe64 - ${og(e)}`}={}){let o=jA({distroName:t.WSL_DISTRO_NAME,shellScript:r});
|
|
2430
|
+
return[{command:"wt.exe",args:["new-window","--title",n,"wsl.exe",...o]},{command:"cmd.exe",args:["/d","/c",`start ${Ka(
|
|
2431
|
+
n)} ${OA("wsl.exe",o)}`]}]}function kA({cwd:e=M.cwd(),env:t=M.env,nodePath:r=M.execPath,osReleaseText:n=Vo(),platform:o=M.
|
|
2432
|
+
platform,serverArgs:i=[],serverPath:s=er}={}){let a=`Vibe64 - ${og(e)}`,c=CA({cwd:e,nodePath:r,serverArgs:i,serverPath:s,
|
|
2433
|
+
title:a});if(o==="darwin")return[{command:"osascript",args:["-e",['tell application "Terminal"',"activate",`do script ${IA(
|
|
1794
2434
|
c)}`,"end tell"].join(`
|
|
1795
|
-
`)]}];let
|
|
2435
|
+
`)]}];let u=[t.TERMINAL?{command:t.TERMINAL,args:["-e","bash","-lc",c]}:null,{command:"x-terminal-emulator",args:["-e","\
|
|
1796
2436
|
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 ${
|
|
1798
|
-
{env:t,osReleaseText:n,platform:o})?[...
|
|
1799
|
-
(n,o)=>{let i=
|
|
1800
|
-
cwd:e=
|
|
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=
|
|
2437
|
+
xfce4-terminal",args:["--command",`bash -lc ${Qt(c)}`]},{command:"xterm",args:["-e","bash","-lc",c]}].filter(Boolean);return AA(
|
|
2438
|
+
{env:t,osReleaseText:n,platform:o})?[...xA({cwd:e,env:t,shellScript:c,title:a}),...u]:u}function $A(e,t=[],r={}){return new Promise(
|
|
2439
|
+
(n,o)=>{let i=tg(e,t,{...r,detached:!0,stdio:"ignore"});i.once("error",o),i.once("spawn",()=>{i.unref(),n(i)})})}async function LA({
|
|
2440
|
+
cwd:e=M.cwd(),env:t=M.env,nodePath:r=M.execPath,osReleaseText:n=Vo(),platform:o=M.platform,serverArgs:i=[],serverPath:s=er}={}){
|
|
2441
|
+
let a=kA({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),c=[];for(let u of a)try{return await $A(
|
|
2442
|
+
u.command,u.args,{cwd:e,env:t}),u}catch(d){c.push(d)}throw new AggregateError(c,"No supported terminal emulator could be\
|
|
2443
|
+
started.")}async function MA({cwd:e=M.cwd(),env:t=M.env,nodePath:r=M.execPath,serverArgs:n=[],serverPath:o=er}={}){let i=tg(
|
|
2444
|
+
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);
|
|
2445
|
+
return}s(Number(c||0))})})}function DA(e=Wr.join(ng,"..","package.json")){try{return/^\D*(\d+)/u.exec(String(JSON.parse(
|
|
2446
|
+
vA(e,"utf8")).engines?.node||""))?.[1]||""}catch{return""}}function VA(e=M.platform){return`https://github.com/mobily-en\
|
|
2447
|
+
terprises/vibe64/blob/main/docs/colleague-usage/${e==="darwin"?"set-up-macos":"set-up-linux"}.md`}function UA({platform:e=M.
|
|
2448
|
+
platform,nodeVersion:t=M.versions.node,requiredMajor:r=DA()}={}){if(e==="win32")return["Vibe64 runs on Windows inside WS\
|
|
1809
2449
|
L2 (Ubuntu), not in PowerShell or Command Prompt.","Step by step: https://github.com/mobily-enterprises/vibe64/blob/main\
|
|
1810
2450
|
/docs/colleague-usage/set-up-windows.md"].join(`
|
|
1811
2451
|
`);let n=String(t||"").split(".")[0];return r&&n!==r?[`Vibe64 needs Node.js ${r}; this is Node.js ${t}.`,`To install it \
|
|
1812
2452
|
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=
|
|
2453
|
+
en a new terminal and run npx vibe64 again:",`${VA(e)}#nodejs-and-mise`].join(`
|
|
2454
|
+
`):""}async function BA({cwd:e=M.cwd(),env:t=M.env,nodePath:r=M.execPath,osReleaseText:n=Vo(),platform:o=M.platform,serverArgs:i=M.
|
|
2455
|
+
argv.slice(2),serverPath:s=er}={}){try{return await LA({cwd:e,env:t,nodePath:r,osReleaseText:n,platform:o,serverArgs:i,serverPath:s}),
|
|
1816
2456
|
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(
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
2457
|
+
in this terminal instead.`),MA({cwd:e,env:t,nodePath:r,serverArgs:i,serverPath:s})}}if(RA()){let e={spec:()=>Promise.resolve().then(()=>(Mu(),Lu)).
|
|
2458
|
+
then(({runAgentSpecCli:n})=>n(M.argv.slice(3))),timeline:()=>Promise.resolve().then(()=>(fh(),dh)).then(({runSessionTimelineCli:n})=>n(
|
|
2459
|
+
M.argv.slice(3),{env:M.env})),training:()=>Promise.resolve().then(()=>(Ha(),eg)).then(({runTrainingCli:n})=>n(M.argv.slice(
|
|
2460
|
+
3)))},t=UA();t&&(console.error(t),M.exit(1)),(Object.hasOwn(e,M.argv[2])?e[M.argv[2]]():BA()).then(n=>{M.exitCode=n}).catch(
|
|
2461
|
+
n=>{console.error("Failed to run Vibe64:",n),M.exitCode=1})}export{er as SERVER_ENTRYPOINT,RA as isDirectCliExecution,AA as isWslEnvironment,LA as launchInNewTerminal,UA as launcherProblem,
|
|
2462
|
+
Qt as quoteShellArg,BA as runLauncher,PA as serverShellCommand,og as targetNameFromCwd,kA as terminalLaunchCandidates,CA as terminalShellScript,
|
|
2463
|
+
jA as wslServerCommandArgs,xA as wslTerminalLaunchCandidates};
|