vibe64 0.1.63 → 0.1.65
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/upgrade-state.js +3597 -3590
- package/dist/assets/{GithubBrowserTabs-DEq5_tSs.js → GithubBrowserTabs-D21Nl3QI.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-CrQ9aolO.js → LocalDatabaseServer-POxY1K1U.js} +1 -1
- package/dist/assets/{SelectField-RGWl_ms9.js → SelectField-Dezd0B3y.js} +1 -1
- package/dist/assets/{ShellOutlet-CdjsJfg9.js → ShellOutlet-DfF9vsWA.js} +1 -1
- package/dist/assets/{StudioErrorNotice-CCT_T6mT.js → StudioErrorNotice-vDR4qneB.js} +1 -1
- package/dist/assets/{VAutocomplete-BnpXAJGa.js → VAutocomplete-NpBcbYkR.js} +1 -1
- package/dist/assets/VBtn-Com1gNEe.js +1 -0
- package/dist/assets/{VCard-BFqQSnAE.js → VCard-DY_DdI8Z.js} +1 -1
- package/dist/assets/{VCheckbox-BK0ss4F4.js → VCheckbox-CkezAf4Z.js} +1 -1
- package/dist/assets/{VCheckboxBtn-DDlYJnth.js → VCheckboxBtn-8g4R-c2w.js} +1 -1
- package/dist/assets/{VChip-D2IukBZw.js → VChip-tORFnf7z.js} +1 -1
- package/dist/assets/{VDialog-BCIrX462.js → VDialog-CapFiCqp.js} +1 -1
- package/dist/assets/{VExpansionPanels-BHw1Id_o.js → VExpansionPanels-B6U2XdWH.js} +1 -1
- package/dist/assets/{VMenu-Bql3E6DV.js → VMenu-CO6B6LWk.js} +1 -1
- package/dist/assets/{VOverlay-EPzW7eVB.js → VOverlay-CrfaXCOL.js} +1 -1
- package/dist/assets/{VRadioGroup-CL3HTmyT.js → VRadioGroup-BrPW6foD.js} +1 -1
- package/dist/assets/{VRow-Dz87sIhY.js → VRow-DHETsEMn.js} +1 -1
- package/dist/assets/{VSelect-Ch00dyiM.js → VSelect-gYJ6qrBP.js} +1 -1
- package/dist/assets/{VSheet-D5wAuyc2.js → VSheet-_Grtwpfz.js} +1 -1
- package/dist/assets/{VSkeletonLoader-Bl9P5wdh.js → VSkeletonLoader-CQXCEJsR.js} +1 -1
- package/dist/assets/VSpacer-VLYDmg7o.js +1 -0
- package/dist/assets/{VSwitch-DftK1EyR.js → VSwitch-ffi-Y2TU.js} +1 -1
- package/dist/assets/{VTable-DHazU0Xx.js → VTable-Cver5Vl3.js} +1 -1
- package/dist/assets/{VTextField-B9R7EIjg.js → VTextField-DP6b7Qaf.js} +1 -1
- package/dist/assets/{VTextarea-CMgyRNk-.js → VTextarea-7mdIF4I0.js} +1 -1
- package/dist/assets/{VToolbar-C8ydxLzq.js → VToolbar-CYz3lneF.js} +1 -1
- package/dist/assets/{Vibe64AsyncModuleState-9bN0_H45.js → Vibe64AsyncModuleState-CO1rMrtD.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-Bbgu_IRu.js → Vibe64AuthSettingsButton-I3ufyScN.js} +1 -1
- package/dist/assets/{Vibe64ConversationLog-MGFaNVSu.js → Vibe64ConversationLog-C04oOQ2g.js} +1 -1
- package/dist/assets/{Vibe64DashboardPageHeader-xfRLZ94G.js → Vibe64DashboardPageHeader-CobvMlFm.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-i01oU7QS.js → Vibe64DashboardShell-BbrOUmRD.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-BqOIE7at.js → Vibe64DatabaseWorkspace-VPEM2o1v.js} +1 -1
- package/dist/assets/{Vibe64DestinationButton-CdyyK9tj.js → Vibe64DestinationButton-B4Zz4a7J.js} +1 -1
- package/dist/assets/{Vibe64FileArea-B8_Tqtgv.js → Vibe64FileArea-C_nC2bPk.js} +1 -1
- package/dist/assets/{Vibe64OutputControls-eaoCQsYn.js → Vibe64OutputControls-DTO3Fw3x.js} +1 -1
- package/dist/assets/{Vibe64RepositoryWorkspace-CoSH_5qZ.js → Vibe64RepositoryWorkspace-B8xcCOvL.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-Dt1EY-Qo.js → Vibe64SessionFiles-Cb9Mxsyq.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-D5-abooo.js → Vibe64SessionSourceEditor-CVQ3NRjh.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-CyuufVBB.js → Vibe64UiStoryboardView-BV4JFgcZ.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-CaLRMl-0.js → Vibe64UnavailableSessions-DGQAxYE-.js} +1 -1
- package/dist/assets/{_pageId_-M5CNslNQ.js → _pageId_-CkG15vv4.js} +1 -1
- package/dist/assets/{_sessionId_-jSlkZQLV.js → _sessionId_-Bka3RUmK.js} +1 -1
- package/dist/assets/{_slug_-ClQKNEA9.js → _slug_-7Oo7pGKn.js} +6 -6
- package/dist/assets/{_slug_-CZmGS16g.css → _slug_-BaxjtsgP.css} +1 -1
- package/dist/assets/{access-BqnqYSZR.js → access-Xo3unxGO.js} +1 -1
- package/dist/assets/{app-D7V6OMMB.js → app-B0spNegd.js} +1 -1
- package/dist/assets/assistantRouting-B9cub38g.js +3 -0
- package/dist/assets/{changes-odK1bV6J.js → changes-DFv4tuoO.js} +1 -1
- package/dist/assets/{client-P5LOKvwh.js → client-BjMjS6lX.js} +2 -2
- package/dist/assets/{client-rknXpZ1o.js → client-CVuXqm4b.js} +1 -1
- package/dist/assets/{client-BRcncaFt.js → client-CevjVK2b.js} +1 -1
- package/dist/assets/{client-DwF9Q0VQ.js → client-DR0w56e8.js} +2 -2
- package/dist/assets/{client-BLY6SeL-.js → client-Dlg1kjjO.js} +1 -1
- package/dist/assets/contracts-CNUMi5L0.js +3 -0
- package/dist/assets/{conversation-BMyk8R_u.css → conversation-DReMq0MF.css} +1 -1
- package/dist/assets/{conversation-BoB7Drme.js → conversation-OkWbkHjm.js} +3 -3
- package/dist/assets/{dashboard-D6JkBdZg.js → dashboard-CAca9MQn.js} +1 -1
- package/dist/assets/{english-definitions-CwCZ8VJ-.js → english-definitions-BtX8KA5g.js} +1 -1
- package/dist/assets/env-DrNyBVkB.js +1 -0
- package/dist/assets/{env-CCUgAwiV.css → env-i_R_LXlE.css} +1 -1
- package/dist/assets/errorMessageHelpers-B49LyMJi.js +1 -0
- package/dist/assets/{fileTypes-2k5HCkMT.js → fileTypes-iPZyrJA1.js} +1 -1
- package/dist/assets/{health-B9ZoQC78.js → health-B5yTW5Tt.js} +1 -1
- package/dist/assets/{history-IBqZqdSL.js → history-S3anp6xg.js} +1 -1
- package/dist/assets/{i18n-BkxO7BMl.js → i18n-DQPYjuW7.js} +1 -1
- package/dist/assets/{index-Ctygjyf8.css → index-DSyb-mRJ.css} +1 -1
- package/dist/assets/{index-DAareKn3.js → index-JBqyg0mr.js} +3 -3
- package/dist/assets/{integrations-BBMdyyMq.js → integrations-C7dj7el_.js} +1 -1
- package/dist/assets/{issues-DwUO1HjX.js → issues-OkV4v4GX.js} +1 -1
- package/dist/assets/{layout-B_cpKP4k.js → layout-DMZV-nbg.js} +1 -1
- package/dist/assets/{lazy-vXRXMwYF.js → lazy-mtFmsnct.js} +1 -1
- package/dist/assets/{learning-DAIqaO0B.js → learning-lW9nBGjT.js} +1 -1
- package/dist/assets/{pages-DoUMcieZ.js → pages-shOT9IVe.js} +1 -1
- package/dist/assets/{project-files-DilujZdI.js → project-files-D_K1N0JF.js} +1 -1
- package/dist/assets/{publish-KZQ_gdoN.js → publish-Bxe4ZCqe.js} +1 -1
- package/dist/assets/{pull-requests-BB3CAadu.js → pull-requests-CQvk0TeH.js} +1 -1
- package/dist/assets/{repository-B90tiuN6.js → repository-CI2CqDwF.js} +1 -1
- package/dist/assets/{session-B5MoHBVk.js → session-FRkCCzYt.js} +1 -1
- package/dist/assets/{settings-DdbhtNHb.js → settings-DIVrFrs4.js} +1 -1
- package/dist/assets/{useArchivedVibe64Sessions-B_pM75gN.js → useArchivedVibe64Sessions-BkWrTOzg.js} +1 -1
- package/dist/assets/useAssistantAttachments-DqlNFiha.js +2 -0
- package/dist/assets/useCommand-D-MIMmhp.js +1 -0
- package/dist/assets/useEndpointResource-DZTjr9gg.js +1 -0
- package/dist/assets/useUiFeedback-BU4NyMq8.js +1 -0
- package/dist/assets/{useVibe64ConversationLog-Ch0ZbnCG.js → useVibe64ConversationLog-BADhWyNY.js} +2 -2
- package/dist/assets/{useVibe64Learning-DiLAIKbI.js → useVibe64Learning-CbsI-XHB.js} +1 -1
- package/dist/assets/{useVibe64SessionData-COsXmbMm.js → useVibe64SessionData-DvFvAJC-.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-CKBC-ZJw.js → useVibe64SessionSelection-BukDTAxb.js} +1 -1
- package/dist/assets/vibe64RepositoryRealtime-CRAyGyRD.css +1 -0
- package/dist/assets/vibe64RepositoryRealtime-DX2DEqIz.js +1 -0
- package/dist/assets/{vibe64SavedEnvValues-CU_SdjKx.js → vibe64SavedEnvValues-CgfMvj_h.js} +1 -1
- package/dist/assets/{vibe64SessionFocus-C0LfHXbF.js → vibe64SessionFocus-CzuP3qPT.js} +1 -1
- package/dist/index.html +37 -37
- package/docs/colleague-usage/ai-tasks.md +7 -0
- package/docs/colleague-usage/coding-agent-goal-pause.md +7 -6
- package/docs/colleague-usage/coding-agent-goals.md +44 -30
- package/docs/colleague-usage/coding-agents.md +22 -8
- package/docs/colleague-usage/development-env.md +37 -5
- package/docs/colleague-usage/project-messages.md +4 -1
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +11 -1
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +7 -5
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/kernel/package.json +1 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-core/package.json +1 -0
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +671 -572
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +480 -479
- package/node_modules/@local/vibe64-genesis/src/server/index.js +22 -21
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +103 -102
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +790 -740
- package/package.json +14 -14
- package/server.bundle.mjs +40248 -40119
- package/dist/assets/VBtn-2vbH580C.js +0 -1
- package/dist/assets/VSpacer-GgPR_AzN.js +0 -1
- package/dist/assets/assistantRouting-BS0ZW5Ki.js +0 -3
- package/dist/assets/contracts-CCZaLqSE.js +0 -1
- package/dist/assets/env-CIy7uwLb.js +0 -1
- package/dist/assets/errorMessageHelpers-BjIt31kK.js +0 -1
- package/dist/assets/useAssistantAttachments-BkYZckgz.js +0 -2
- package/dist/assets/useCommand-CNDe8gM-.js +0 -1
- package/dist/assets/useEndpointResource-CmMwteuX.js +0 -1
- package/dist/assets/useUiFeedback-CWb6o71Z.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-BIXVm4u9.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-rnWlv9jw.css +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var
|
|
5
|
-
enumerable:!(r=
|
|
3
|
+
var Yi=Object.create;var Zn=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var Qi=Object.getOwnPropertyNames;var ea=Object.getPrototypeOf,ta=Object.prototype.hasOwnProperty;var M=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){
|
|
4
|
+
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var ra=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qi(e))!ta.call(t,o)&&o!==n&&Zn(t,o,{get:()=>e[o],
|
|
5
|
+
enumerable:!(r=Zi(e,o))||r.enumerable});return t};var ce=(t,e,n)=>(n=t!=null?Yi(ea(t)):{},ra(e||!t||!t.__esModule?Zn(n,"default",{value:t,enumerable:!0}):n,t));var te=$((Im,so)=>{"use strict";var no=["nodebuffer","arraybuffer","fragments"],oo=typeof Blob<"u";oo&&no.push("blob");so.
|
|
6
6
|
exports={BINARY_TYPES:no,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:oo,
|
|
7
7
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
8
|
-
"websocket"),NOOP:()=>{}}});var Ye=$((
|
|
8
|
+
"websocket"),NOOP:()=>{}}});var Ye=$((Sm,_t)=>{"use strict";var{EMPTY_BUFFER:va}=te(),gr=Buffer[Symbol.species];function wa(t,e){if(t.length===0)return va;
|
|
9
9
|
if(t.length===1)return t[0];let n=Buffer.allocUnsafe(e),r=0;for(let o=0;o<t.length;o++){let s=t[o];n.set(s,r),r+=s.length}
|
|
10
10
|
return r<e?new gr(n.buffer,n.byteOffset,r):n}function io(t,e,n,r,o){for(let s=0;s<o;s++)n[r+s]=t[s]^e[s&3]}function ao(t,e){
|
|
11
|
-
for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function
|
|
11
|
+
for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function ya(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
|
|
12
12
|
t.byteOffset+t.length)}function vr(t){if(vr.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
|
|
13
|
-
e=new gr(t):ArrayBuffer.isView(t)?e=new gr(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),vr.readOnly=!1),e}
|
|
14
|
-
{concat:
|
|
15
|
-
exports.mask=function(e,n,r,o,s){s<48?io(e,n,r,o,s):t.mask(e,n,r,o,s)},
|
|
16
|
-
n):t.unmask(e,n)}}catch{}});var lo=$((
|
|
13
|
+
e=new gr(t):ArrayBuffer.isView(t)?e=new gr(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),vr.readOnly=!1),e}_t.exports=
|
|
14
|
+
{concat:wa,mask:io,toArrayBuffer:ya,toBuffer:vr,unmask:ao};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=M("bufferutil");_t.
|
|
15
|
+
exports.mask=function(e,n,r,o,s){s<48?io(e,n,r,o,s):t.mask(e,n,r,o,s)},_t.exports.unmask=function(e,n){e.length<32?ao(e,
|
|
16
|
+
n):t.unmask(e,n)}}catch{}});var lo=$((xm,uo)=>{"use strict";var co=Symbol("kDone"),wr=Symbol("kRun"),yr=class{constructor(e){this[co]=()=>{this.pending--,
|
|
17
17
|
this[wr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[wr]()}[wr](){if(this.pending!==
|
|
18
|
-
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[co])}}};uo.exports=yr});var Re=$((
|
|
18
|
+
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[co])}}};uo.exports=yr});var Re=$((Tm,ho)=>{"use strict";var Ze=M("zlib"),po=Ye(),Ia=lo(),{kStatusCode:fo}=te(),Sa=Buffer[Symbol.species],xa=Buffer.
|
|
19
19
|
from([0,0,255,255]),At=Symbol("permessage-deflate"),re=Symbol("total-length"),Ee=Symbol("callback"),ue=Symbol("buffers"),
|
|
20
|
-
Oe=Symbol("error"),
|
|
20
|
+
Oe=Symbol("error"),Ct,Ir=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this.
|
|
21
21
|
_options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=
|
|
22
|
-
null,this._inflate=null,this.params=null,!
|
|
23
|
-
10;
|
|
22
|
+
null,this._inflate=null,this.params=null,!Ct){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
|
|
23
|
+
10;Ct=new Ia(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
|
|
24
24
|
(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.
|
|
25
25
|
serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=
|
|
26
26
|
this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=
|
|
@@ -44,40 +44,40 @@ y a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;i
|
|
|
44
44
|
"${r}": ${o}`)}else if(r==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`I\
|
|
45
45
|
nvalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){
|
|
46
46
|
if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);
|
|
47
|
-
n[r]=o})}),e}decompress(e,n,r){
|
|
47
|
+
n[r]=o})}),e}decompress(e,n,r){Ct.add(o=>{this._decompress(e,n,(s,i)=>{o(),r(s,i)})})}compress(e,n,r){Ct.add(o=>{this._compress(
|
|
48
48
|
e,n,(s,i)=>{o(),r(s,i)})})}_decompress(e,n,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_\
|
|
49
49
|
window_bits`,i=typeof this.params[s]!="number"?Ze.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Ze.createInflateRaw(
|
|
50
50
|
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[At]=this,this._inflate[re]=0,this._inflate[ue]=[],this.
|
|
51
|
-
_inflate.on("error",ba),this._inflate.on("data",mo)}this._inflate[Ee]=r,this._inflate.write(e),n&&this._inflate.write(
|
|
51
|
+
_inflate.on("error",ba),this._inflate.on("data",mo)}this._inflate[Ee]=r,this._inflate.write(e),n&&this._inflate.write(xa),
|
|
52
52
|
this._inflate.flush(()=>{let s=this._inflate[Oe];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=po.concat(
|
|
53
53
|
this._inflate[ue],this._inflate[re]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
|
|
54
54
|
(this._inflate[re]=0,this._inflate[ue]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(e,n,r){
|
|
55
55
|
let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
|
|
56
56
|
Ze.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Ze.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
|
|
57
|
-
this._deflate[re]=0,this._deflate[ue]=[],this._deflate.on("data",
|
|
58
|
-
flush(Ze.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=po.concat(this._deflate[ue],this._deflate[re]);n&&(s=new
|
|
57
|
+
this._deflate[re]=0,this._deflate[ue]=[],this._deflate.on("data",Ta)}this._deflate[Ee]=r,this._deflate.write(e),this._deflate.
|
|
58
|
+
flush(Ze.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=po.concat(this._deflate[ue],this._deflate[re]);n&&(s=new Sa(s.
|
|
59
59
|
buffer,s.byteOffset,s.length-4)),this._deflate[Ee]=null,this._deflate[re]=0,this._deflate[ue]=[],n&&this.params[`${o}_no\
|
|
60
|
-
_context_takeover`]&&this._deflate.reset(),r(null,s)})}};ho.exports=Ir;function
|
|
60
|
+
_context_takeover`]&&this._deflate.reset(),r(null,s)})}};ho.exports=Ir;function Ta(t){this[ue].push(t),this[re]+=t.length}
|
|
61
61
|
function mo(t){if(this[re]+=t.length,this[At]._maxPayload<1||this[re]<=this[At]._maxPayload){this[ue].push(t);return}this[Oe]=
|
|
62
62
|
new RangeError("Max payload size exceeded"),this[Oe].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Oe][fo]=1009,this.removeListener(
|
|
63
63
|
"data",mo),this.reset()}function ba(t){if(this[At]._inflate=null,this[Oe]){this[Ee](this[Oe]);return}t[fo]=1007,this[Ee](
|
|
64
|
-
t)}});var Pe=$((
|
|
64
|
+
t)}});var Pe=$((bm,Et)=>{"use strict";var{isUtf8:go}=M("buffer"),{hasBlob:_a}=te(),Ca=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
65
65
|
0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
66
|
-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function
|
|
66
|
+
1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Aa(t){return t>=
|
|
67
67
|
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Sr(t){let e=t.length,n=0;for(;n<e;)if((t[n]&128)===
|
|
68
68
|
0)n++;else if((t[n]&224)===192){if(n+1===e||(t[n+1]&192)!==128||(t[n]&254)===192)return!1;n+=2}else if((t[n]&240)===224){
|
|
69
69
|
if(n+2>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||t[n]===224&&(t[n+1]&224)===128||t[n]===237&&(t[n+1]&224)===160)return!1;
|
|
70
70
|
n+=3}else if((t[n]&248)===240){if(n+3>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||(t[n+3]&192)!==128||t[n]===240&&(t[n+1]&
|
|
71
|
-
240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function
|
|
71
|
+
240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function Ea(t){return _a&&typeof t=="o\
|
|
72
72
|
bject"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]===
|
|
73
|
-
"Blob"||t[Symbol.toStringTag]==="File")}Et.exports={isBlob:
|
|
73
|
+
"Blob"||t[Symbol.toStringTag]==="File")}Et.exports={isBlob:Ea,isValidStatusCode:Aa,isValidUTF8:Sr,tokenChars:Ca};if(go)Et.
|
|
74
74
|
exports.isValidUTF8=function(t){return t.length<24?Sr(t):go(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=M("utf-8-validate");
|
|
75
|
-
Et.exports.isValidUTF8=function(e){return e.length<32?Sr(e):t(e)}}catch{}});var
|
|
76
|
-
{concat:xr,toArrayBuffer:
|
|
77
|
-
So=2,xo=3,
|
|
78
|
-
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||
|
|
75
|
+
Et.exports.isValidUTF8=function(e){return e.length<32?Sr(e):t(e)}}catch{}});var Cr=$((_m,To)=>{"use strict";var{Writable:Oa}=M("stream"),vo=Re(),{BINARY_TYPES:Ra,EMPTY_BUFFER:wo,kStatusCode:Pa,kWebSocket:ka}=te(),
|
|
76
|
+
{concat:xr,toArrayBuffer:Ma,unmask:Na}=Ye(),{isValidStatusCode:ja,isValidUTF8:yo}=Pe(),Ot=Buffer[Symbol.species],G=0,Io=1,
|
|
77
|
+
So=2,xo=3,Tr=4,br=5,Rt=6,_r=class extends Oa{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
|
|
78
|
+
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Ra[0],this._extensions=e.extensions||{},this._isServer=
|
|
79
79
|
!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|
|
|
80
|
-
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[
|
|
80
|
+
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ka]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
|
|
81
81
|
!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=
|
|
82
82
|
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=G}_write(e,n,r){
|
|
83
83
|
if(this._opcode===8&&this._state==G)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
|
|
@@ -87,8 +87,8 @@ _buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return thi
|
|
|
87
87
|
e,r.length-e),new Ot(r.buffer,r.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let r=this._buffers[0],o=n.length-e;e>=r.length?
|
|
88
88
|
n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),o),this._buffers[0]=new Ot(r.buffer,r.byteOffset+
|
|
89
89
|
e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case G:this.getInfo(e);
|
|
90
|
-
break;case Io:this.getPayloadLength16(e);break;case So:this.getPayloadLength64(e);break;case xo:this.getMask();break;case
|
|
91
|
-
this.getData(e);break;case
|
|
90
|
+
break;case Io:this.getPayloadLength16(e);break;case So:this.getPayloadLength64(e);break;case xo:this.getMask();break;case Tr:
|
|
91
|
+
this.getData(e);break;case br:case Rt:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
|
|
92
92
|
2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be\
|
|
93
93
|
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let r=(n[0]&64)===64;if(r&&!this._extensions[vo.extensionName]){
|
|
94
94
|
let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(n[0]&
|
|
@@ -111,44 +111,44 @@ createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",
|
|
|
111
111
|
_LENGTH");e(o);return}this._payloadLength=r*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&
|
|
112
112
|
this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>
|
|
113
113
|
0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(n);return}
|
|
114
|
-
this._masked?this._state=xo:this._state=
|
|
115
|
-
4),this._state=
|
|
114
|
+
this._masked?this._state=xo:this._state=Tr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
|
|
115
|
+
4),this._state=Tr}getData(e){let n=wo;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
|
|
116
116
|
return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
|
|
117
|
-
|
|
117
|
+
Na(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
|
|
118
118
|
let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this.
|
|
119
|
-
_compressed){this._state=
|
|
119
|
+
_compressed){this._state=br,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
|
|
120
120
|
push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[vo.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return n(
|
|
121
121
|
o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(
|
|
122
122
|
RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(i);return}this._fragments.push(s)}
|
|
123
123
|
this.dataMessage(n),this._state===G&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=G;return}let n=this._messageLength,
|
|
124
124
|
r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=
|
|
125
|
-
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=xr(r,n):this._binaryType==="arraybuffer"?o=
|
|
125
|
+
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=xr(r,n):this._binaryType==="arraybuffer"?o=Ma(xr(r,n)):this.
|
|
126
126
|
_binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=G):(this._state=
|
|
127
127
|
Rt,setImmediate(()=>{this.emit("message",o,!0),this._state=G,this.startLoop(e)}))}else{let o=xr(r,n);if(!this._skipUTF8Validation&&
|
|
128
|
-
!yo(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===
|
|
128
|
+
!yo(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===br||
|
|
129
129
|
this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=G):(this._state=Rt,setImmediate(()=>{this.emit("mess\
|
|
130
130
|
age",o,!1),this._state=G,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
|
|
131
|
-
emit("conclude",1005,wo),this.end();else{let r=e.readUInt16BE(0);if(!
|
|
131
|
+
emit("conclude",1005,wo),this.end();else{let r=e.readUInt16BE(0);if(!ja(r)){let s=this.createError(RangeError,`invalid s\
|
|
132
132
|
tatus code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new Ot(e.buffer,e.byteOffset+2,e.length-2);if(!this.
|
|
133
133
|
_skipUTF8Validation&&!yo(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}
|
|
134
134
|
this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=G;return}this._allowSynchronousEvents?(this.emit(this._opcode===
|
|
135
135
|
9?"ping":"pong",e),this._state=G):(this._state=Rt,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
|
|
136
136
|
G,this.startLoop(n)}))}createError(e,n,r,o,s){this._loop=!1,this._errored=!0;let i=new e(r?`Invalid WebSocket frame: ${n}`:
|
|
137
|
-
n);return Error.captureStackTrace(i,this.createError),i.code=s,i[
|
|
138
|
-
|
|
139
|
-
"kByteLength")
|
|
137
|
+
n);return Error.captureStackTrace(i,this.createError),i.code=s,i[Pa]=o,i}};To.exports=_r});var Or=$((Am,Co)=>{"use strict";var{Duplex:Cm}=M("stream"),{randomFillSync:Da}=M("crypto"),{types:{isUint8Array:za}}=M("util"),
|
|
138
|
+
bo=Re(),{EMPTY_BUFFER:La,kWebSocket:Ua,NOOP:Fa}=te(),{isBlob:ke,isValidStatusCode:qa}=Pe(),{mask:_o,toBuffer:ve}=Ye(),W=Symbol(
|
|
139
|
+
"kByteLength"),$a=Buffer.alloc(4),Pt=8*1024,we,Me=Pt,Z=0,Ba=1,Ha=2,Ar=class t{constructor(e,n,r){this._extensions=n||{},
|
|
140
140
|
r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this.
|
|
141
|
-
_bufferedBytes=0,this._queue=[],this._state=Z,this.onerror=
|
|
142
|
-
(r=n.maskBuffer
|
|
141
|
+
_bufferedBytes=0,this._queue=[],this._state=Z,this.onerror=Fa,this[Ua]=void 0}static frame(e,n){let r,o=!1,s=2,i=!1;n.mask&&
|
|
142
|
+
(r=n.maskBuffer||$a,n.generateMask?n.generateMask(r):(Me===Pt&&(we===void 0&&(we=Buffer.alloc(Pt)),Da(we,0,Pt),Me=0),r[0]=
|
|
143
143
|
we[Me++],r[1]=we[Me++],r[2]=we[Me++],r[3]=we[Me++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!n.mask||
|
|
144
144
|
i)&&n[W]!==void 0?a=n[W]:(e=Buffer.from(e),a=e.length):(a=e.length,o=n.mask&&n.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
|
|
145
145
|
a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(d[0]|=64),d[1]=c,
|
|
146
146
|
c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),n.mask?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=
|
|
147
|
-
r[2],d[s-1]=r[3],i?[d,e]:o?(
|
|
148
|
-
if(typeof e!="number"||!
|
|
147
|
+
r[2],d[s-1]=r[3],i?[d,e]:o?(_o(e,r,d,s,a),[d]):(_o(e,r,e,0,a),[d,e])):[d,e]}close(e,n,r,o){let s;if(e===void 0)s=La;else{
|
|
148
|
+
if(typeof e!="number"||!qa(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.
|
|
149
149
|
length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let a=Buffer.byteLength(n);if(a>123)throw new RangeError("The m\
|
|
150
150
|
essage must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(e,0),typeof n=="string")s.write(
|
|
151
|
-
n,2);else if(
|
|
151
|
+
n,2);else if(za(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[W]:s.
|
|
152
152
|
length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==
|
|
153
153
|
Z?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(t.frame(s,i),o)}ping(e,n,r){let o,s;if(typeof e=="string"?(o=Buffer.
|
|
154
154
|
byteLength(e),s=!1):ke(e)?(o=e.size,s=!1):(e=ve(e),o=e.length,s=ve.readOnly),o>125)throw new RangeError("The data size m\
|
|
@@ -158,24 +158,24 @@ this._state!==Z?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,
|
|
|
158
158
|
string"?(o=Buffer.byteLength(e),s=!1):ke(e)?(o=e.size,s=!1):(e=ve(e),o=e.length,s=ve.readOnly),o>125)throw new RangeError(
|
|
159
159
|
"The data size must not be greater than 125 bytes");let i={[W]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this.
|
|
160
160
|
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};ke(e)?this._state!==Z?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(
|
|
161
|
-
e,!1,i,r):this._state!==Z?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}send(e,n,r){let o=this._extensions[
|
|
161
|
+
e,!1,i,r):this._state!==Z?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}send(e,n,r){let o=this._extensions[bo.
|
|
162
162
|
extensionName],s=n.binary?2:1,i=n.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):ke(e)?(a=e.size,c=!1):(e=
|
|
163
163
|
ve(e),a=e.length,c=ve.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_contex\
|
|
164
164
|
t_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),n.fin&&(this._firstFragment=
|
|
165
165
|
!0);let d={[W]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
|
|
166
166
|
ke(e)?this._state!==Z?this.enqueue([this.getBlobData,e,this._compress,d,r]):this.getBlobData(e,this._compress,d,r):this.
|
|
167
167
|
_state!==Z?this.enqueue([this.dispatch,e,this._compress,d,r]):this.dispatch(e,this._compress,d,r)}getBlobData(e,n,r,o){this.
|
|
168
|
-
_bufferedBytes+=r[W],this._state=
|
|
168
|
+
_bufferedBytes+=r[W],this._state=Ha,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was \
|
|
169
169
|
closed while the blob was being read");process.nextTick(Er,this,a,o);return}this._bufferedBytes-=r[W];let i=ve(s);n?this.
|
|
170
|
-
dispatch(i,n,r,o):(this._state=Z,this.sendFrame(t.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(
|
|
171
|
-
if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[
|
|
172
|
-
|
|
170
|
+
dispatch(i,n,r,o):(this._state=Z,this.sendFrame(t.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(Va,this,s,o)})}dispatch(e,n,r,o){
|
|
171
|
+
if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[bo.extensionName];this._bufferedBytes+=r[W],this._state=
|
|
172
|
+
Ba,s.compress(e,r.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
|
|
173
173
|
pressed");Er(this,c,o);return}this._bufferedBytes-=r[W],this._state=Z,r.readOnly=!1,this.sendFrame(t.frame(a,r),o),this.
|
|
174
174
|
dequeue()})}dequeue(){for(;this._state===Z&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][W],
|
|
175
175
|
Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][W],this._queue.push(e)}sendFrame(e,n){e.length===
|
|
176
176
|
2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.write(e[0],
|
|
177
|
-
n)}};
|
|
178
|
-
length-1];typeof s=="function"&&s(e)}}function
|
|
177
|
+
n)}};Co.exports=Ar;function Er(t,e,n){typeof n=="function"&&n(e);for(let r=0;r<t._queue.length;r++){let o=t._queue[r],s=o[o.
|
|
178
|
+
length-1];typeof s=="function"&&s(e)}}function Va(t,e,n){Er(t,e,n),t.onerror(e)}});var jo=$((Em,No)=>{"use strict";var{kForOnEventAttribute:Qe,kListener:Rr}=te(),Ao=Symbol("kCode"),Eo=Symbol("kData"),Oo=Symbol(
|
|
179
179
|
"kError"),Ro=Symbol("kMessage"),Po=Symbol("kReason"),Ne=Symbol("kTarget"),ko=Symbol("kType"),Mo=Symbol("kWasClean"),ne=class{constructor(e){
|
|
180
180
|
this[Ne]=null,this[ko]=e}get target(){return this[Ne]}get type(){return this[ko]}};Object.defineProperty(ne.prototype,"t\
|
|
181
181
|
arget",{enumerable:!0});Object.defineProperty(ne.prototype,"type",{enumerable:!0});var ye=class extends ne{constructor(e,n={}){
|
|
@@ -186,14 +186,14 @@ an",{enumerable:!0});var je=class extends ne{constructor(e,n={}){super(e),this[O
|
|
|
186
186
|
n.message===void 0?"":n.message}get error(){return this[Oo]}get message(){return this[Ro]}};Object.defineProperty(je.prototype,
|
|
187
187
|
"error",{enumerable:!0});Object.defineProperty(je.prototype,"message",{enumerable:!0});var et=class extends ne{constructor(e,n={}){
|
|
188
188
|
super(e),this[Eo]=n.data===void 0?null:n.data}get data(){return this[Eo]}};Object.defineProperty(et.prototype,"data",{enumerable:!0});
|
|
189
|
-
var
|
|
189
|
+
var Ga={addEventListener(t,e,n={}){for(let o of this.listeners(t))if(!n[Qe]&&o[Rr]===e&&!o[Qe])return;let r;if(t==="mess\
|
|
190
190
|
age")r=function(s,i){let a=new et("message",{data:i?s:s.toString()});a[Ne]=this,kt(e,this,a)};else if(t==="close")r=function(s,i){
|
|
191
191
|
let a=new ye("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Ne]=this,kt(
|
|
192
192
|
e,this,a)};else if(t==="error")r=function(s){let i=new je("error",{error:s,message:s.message});i[Ne]=this,kt(e,this,i)};else if(t===
|
|
193
193
|
"open")r=function(){let s=new ne("open");s[Ne]=this,kt(e,this,s)};else return;r[Qe]=!!n[Qe],r[Rr]=e,n.once?this.once(t,r):
|
|
194
194
|
this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Rr]===e&&!n[Qe]){this.removeListener(t,n);break}}};
|
|
195
|
-
No.exports={CloseEvent:ye,ErrorEvent:je,Event:ne,EventTarget:
|
|
196
|
-
t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Mt=$((
|
|
195
|
+
No.exports={CloseEvent:ye,ErrorEvent:je,Event:ne,EventTarget:Ga,MessageEvent:et};function kt(t,e,n){typeof t=="object"&&
|
|
196
|
+
t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Mt=$((Om,Do)=>{"use strict";var{tokenChars:tt}=Pe();function ee(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function Wa(t){
|
|
197
197
|
let e=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,p=-1,m=0;for(;m<t.length;m++)if(d=t.charCodeAt(
|
|
198
198
|
m),i===void 0)if(p===-1&&tt[d]===1)c===-1&&(c=m);else if(m!==0&&(d===32||d===9))p===-1&&c!==-1&&(p=m);else if(d===59||d===
|
|
199
199
|
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);p===-1&&(p=m);let v=t.slice(c,p);d===44?(ee(e,
|
|
@@ -208,13 +208,13 @@ d===9))p===-1&&(p=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Un
|
|
|
208
208
|
(p=m);let v=t.slice(c,p);r&&(v=v.replace(/\\/g,""),r=!1),ee(n,a,v),d===44&&(ee(e,i,n),n=Object.create(null),i=void 0),a=
|
|
209
209
|
void 0,c=p=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
|
|
210
210
|
"Unexpected end of input");p===-1&&(p=m);let l=t.slice(c,p);return i===void 0?ee(e,l,n):(a===void 0?ee(n,l,!0):r?ee(n,a,
|
|
211
|
-
l.replace(/\\/g,"")):ee(n,a,l),ee(e,i,n)),e}function
|
|
211
|
+
l.replace(/\\/g,"")):ee(n,a,l),ee(e,i,n)),e}function Ka(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(
|
|
212
212
|
n)||(n=[n]),n.map(r=>[e].concat(Object.keys(r).map(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}\
|
|
213
|
-
=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Do.exports={format:
|
|
214
|
-
{Duplex:
|
|
215
|
-
EMPTY_BUFFER:Nt,GUID:
|
|
216
|
-
removeEventListener:
|
|
217
|
-
NG","OPEN","CLOSING","CLOSED"],
|
|
213
|
+
=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Do.exports={format:Ka,parse:Wa}});var zt=$((km,Ko)=>{"use strict";var Ja=M("events"),Xa=M("https"),Ya=M("http"),Uo=M("net"),Za=M("tls"),{randomBytes:Qa,createHash:ec}=M("crypto"),
|
|
214
|
+
{Duplex:Rm,Readable:Pm}=M("stream"),{URL:Pr}=M("url"),le=Re(),tc=Cr(),rc=Or(),{isBlob:nc}=Pe(),{BINARY_TYPES:zo,CLOSE_TIMEOUT:oc,
|
|
215
|
+
EMPTY_BUFFER:Nt,GUID:sc,kForOnEventAttribute:kr,kListener:ic,kStatusCode:ac,kWebSocket:L,NOOP:Fo}=te(),{EventTarget:{addEventListener:cc,
|
|
216
|
+
removeEventListener:dc}}=jo(),{format:uc,parse:lc}=Mt(),{toBuffer:pc}=Ye(),qo=Symbol("kAborted"),Mr=[8,13],oe=["CONNECTI\
|
|
217
|
+
NG","OPEN","CLOSING","CLOSED"],fc=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,k=class t extends Ja{constructor(e,n,r){super(),this.
|
|
218
218
|
_binaryType=zo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Nt,this._closeTimer=
|
|
219
219
|
null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=
|
|
220
220
|
null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?
|
|
@@ -223,11 +223,11 @@ r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set b
|
|
|
223
223
|
e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+
|
|
224
224
|
this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){
|
|
225
225
|
return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){
|
|
226
|
-
return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,n,r){let o=new
|
|
226
|
+
return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,n,r){let o=new tc(
|
|
227
227
|
{allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,
|
|
228
228
|
maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),
|
|
229
|
-
s=new
|
|
230
|
-
o.on("conclude",
|
|
229
|
+
s=new rc(e,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[L]=this,s[L]=this,e[L]=this,
|
|
230
|
+
o.on("conclude",gc),o.on("drain",vc),o.on("error",wc),o.on("message",yc),o.on("ping",Ic),o.on("pong",Sc),s.onerror=xc,e.
|
|
231
231
|
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",Vo),e.on("data",Dt),e.on(
|
|
232
232
|
"end",Go),e.on("error",Wo),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
|
|
233
233
|
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[le.extensionName]&&this._extensions[le.extensionName].
|
|
@@ -256,59 +256,59 @@ k.prototype,"OPEN",{enumerable:!0,value:oe.indexOf("OPEN")});Object.defineProper
|
|
|
256
256
|
k,"CLOSED",{enumerable:!0,value:oe.indexOf("CLOSED")});Object.defineProperty(k.prototype,"CLOSED",{enumerable:!0,value:oe.
|
|
257
257
|
indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
|
|
258
258
|
defineProperty(k.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(k.prototype,
|
|
259
|
-
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[kr])return e[
|
|
259
|
+
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[kr])return e[ic];return null},set(e){for(let n of this.
|
|
260
260
|
listeners(t))if(n[kr]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[kr]:!0})}})});k.
|
|
261
|
-
prototype.addEventListener=
|
|
262
|
-
autoPong:!0,closeTimeout:
|
|
261
|
+
prototype.addEventListener=cc;k.prototype.removeEventListener=dc;Ko.exports=k;function $o(t,e,n,r){let o={allowSynchronousEvents:!0,
|
|
262
|
+
autoPong:!0,closeTimeout:oc,protocolVersion:Mr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
|
|
263
263
|
perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,
|
|
264
264
|
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Mr.includes(
|
|
265
265
|
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Mr.join(
|
|
266
266
|
", ")})`);let s;if(e instanceof Pr)s=e;else try{s=new Pr(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol===
|
|
267
267
|
"http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),t._url=s.href;let i=s.protocol==="wss:",a=s.protocol===
|
|
268
268
|
"ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws\
|
|
269
|
-
+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let
|
|
270
|
-
c);if(t._redirects===0)throw
|
|
271
|
-
v;if(o.createConnection=o.createConnection||(i?mc
|
|
269
|
+
+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let T=new SyntaxError(
|
|
270
|
+
c);if(t._redirects===0)throw T;jt(t,T);return}let d=i?443:80,p=Qa(16).toString("base64"),m=i?Xa.request:Ya.request,l=new Set,
|
|
271
|
+
v;if(o.createConnection=o.createConnection||(i?hc:mc),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
|
|
272
272
|
startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec\
|
|
273
273
|
-WebSocket-Key":p,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
|
|
274
|
-
(v=new le({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=
|
|
275
|
-
offer()})),n.length){for(let
|
|
276
|
-
uplicated subprotocol was specified");l.add(
|
|
274
|
+
(v=new le({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=uc({[le.extensionName]:v.
|
|
275
|
+
offer()})),n.length){for(let T of n){if(typeof T!="string"||!fc.test(T)||l.has(T))throw new SyntaxError("An invalid or d\
|
|
276
|
+
uplicated subprotocol was specified");l.add(T)}o.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(o.origin&&(o.protocolVersion<
|
|
277
277
|
13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}\
|
|
278
|
-
:${s.password}`),a){let
|
|
279
|
-
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let
|
|
280
|
-
headers:{}},
|
|
281
|
-
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!
|
|
282
|
-
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,
|
|
278
|
+
:${s.password}`),a){let T=o.path.split(":");o.socketPath=T[0],o.path=T[1]}let x;if(o.followRedirects){if(t._redirects===
|
|
279
|
+
0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?o.socketPath:s.host;let T=r&&r.headers;if(r={...r,
|
|
280
|
+
headers:{}},T)for(let[O,P]of Object.entries(T))r.headers[O.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let T=a?
|
|
281
|
+
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!T||
|
|
282
|
+
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,T||delete o.headers.host,o.auth=void 0)}
|
|
283
283
|
o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),x=t._req=m(o),
|
|
284
284
|
t._redirects&&t.emit("redirect",t.url,x)}else x=t._req=m(o);o.timeout&&x.on("timeout",()=>{B(t,x,"Opening handshake has \
|
|
285
|
-
timed out")}),x.on("error",
|
|
285
|
+
timed out")}),x.on("error",T=>{x===null||x[qo]||(x=t._req=null,jt(t,T))}),x.on("response",T=>{let O=T.headers.location,P=T.
|
|
286
286
|
statusCode;if(O&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){B(t,x,"Maximum redirects exceeded");
|
|
287
287
|
return}x.abort();let j;try{j=new Pr(O,e)}catch{let U=new SyntaxError(`Invalid URL: ${O}`);jt(t,U);return}$o(t,j,n,r)}else
|
|
288
|
-
t.emit("unexpected-response",x,
|
|
289
|
-
emit("upgrade",
|
|
290
|
-
"websocket"){B(t,O,"Invalid Upgrade header");return}let D=
|
|
291
|
-
socket-accept"]!==D){B(t,O,"Invalid Sec-WebSocket-Accept header");return}let U=
|
|
288
|
+
t.emit("unexpected-response",x,T)||B(t,x,`Unexpected server response: ${T.statusCode}`)}),x.on("upgrade",(T,O,P)=>{if(t.
|
|
289
|
+
emit("upgrade",T),t.readyState!==k.CONNECTING)return;x=t._req=null;let j=T.headers.upgrade;if(j===void 0||j.toLowerCase()!==
|
|
290
|
+
"websocket"){B(t,O,"Invalid Upgrade header");return}let D=ec("sha1").update(p+sc).digest("base64");if(T.headers["sec-web\
|
|
291
|
+
socket-accept"]!==D){B(t,O,"Invalid Sec-WebSocket-Accept header");return}let U=T.headers["sec-websocket-protocol"],J;if(U!==
|
|
292
292
|
void 0?l.size?l.has(U)||(J="Server sent an invalid subprotocol"):J="Server sent a subprotocol but none was requested":l.
|
|
293
|
-
size&&(J="Server sent no subprotocol"),J){B(t,O,J);return}U&&(t._protocol=U);let H=
|
|
293
|
+
size&&(J="Server sent no subprotocol"),J){B(t,O,J);return}U&&(t._protocol=U);let H=T.headers["sec-websocket-extensions"];
|
|
294
294
|
if(H!==void 0){if(!v){B(t,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let q;
|
|
295
|
-
try{q=
|
|
295
|
+
try{q=lc(H)}catch{B(t,O,"Invalid Sec-WebSocket-Extensions header");return}let ae=Object.keys(q);if(ae.length!==1||ae[0]!==
|
|
296
296
|
le.extensionName){B(t,O,"Server indicated an extension that was not requested");return}try{v.accept(q[le.extensionName])}catch{
|
|
297
297
|
B(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[le.extensionName]=v}t.setSocket(O,P,{allowSynchronousEvents:o.
|
|
298
298
|
allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
|
|
299
299
|
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(x,t):x.end()}function jt(t,e){t._readyState=
|
|
300
|
-
k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function
|
|
301
|
-
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Uo.isIP(t.host)?"":t.host),
|
|
300
|
+
k.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function mc(t){return t.path=t.socketPath,Uo.connect(t)}function hc(t){
|
|
301
|
+
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Uo.isIP(t.host)?"":t.host),Za.connect(t)}function B(t,e,n){
|
|
302
302
|
t._readyState=k.CLOSING;let r=new Error(n);Error.captureStackTrace(r,B),e.setHeader?(e[qo]=!0,e.abort(),e.socket&&!e.socket.
|
|
303
303
|
destroyed&&e.socket.destroy(),process.nextTick(jt,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("clo\
|
|
304
|
-
se",t.emitClose.bind(t)))}function Nr(t,e,n){if(e){let r=
|
|
304
|
+
se",t.emitClose.bind(t)))}function Nr(t,e,n){if(e){let r=nc(e)?e.size:pc(e).length;t._socket?t._sender._bufferedBytes+=r:
|
|
305
305
|
t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${oe[t.readyState]})`);process.
|
|
306
|
-
nextTick(n,r)}}function
|
|
307
|
-
(n._socket.removeListener("data",Dt),process.nextTick(Bo,n._socket),t===1005?n.close():n.close(t,e))}function
|
|
308
|
-
t.isPaused||t._socket.resume()}function
|
|
309
|
-
process.nextTick(Bo,e._socket),e.close(t[
|
|
310
|
-
emitClose()}function
|
|
311
|
-
Fo),e.emit("ping",t)}function
|
|
306
|
+
nextTick(n,r)}}function gc(t,e){let n=this[L];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[L]!==void 0&&
|
|
307
|
+
(n._socket.removeListener("data",Dt),process.nextTick(Bo,n._socket),t===1005?n.close():n.close(t,e))}function vc(){let t=this[L];
|
|
308
|
+
t.isPaused||t._socket.resume()}function wc(t){let e=this[L];e._socket[L]!==void 0&&(e._socket.removeListener("data",Dt),
|
|
309
|
+
process.nextTick(Bo,e._socket),e.close(t[ac])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Lo(){this[L].
|
|
310
|
+
emitClose()}function yc(t,e){this[L].emit("message",t,e)}function Ic(t){let e=this[L];e._autoPong&&e.pong(t,!this._isServer,
|
|
311
|
+
Fo),e.emit("ping",t)}function Sc(t){this[L].emit("pong",t)}function Bo(t){t.resume()}function xc(t){let e=this[L];e.readyState!==
|
|
312
312
|
k.CLOSED&&(e.readyState===k.OPEN&&(e._readyState=k.CLOSING,Ho(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
|
|
313
313
|
e.emit("error",t)))}function Ho(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Vo(){
|
|
314
314
|
let t=this[L];if(this.removeListener("close",Vo),this.removeListener("data",Dt),this.removeListener("end",Go),t._readyState=
|
|
@@ -317,9 +317,9 @@ length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._
|
|
|
317
317
|
t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
|
|
318
318
|
"error",Lo),t._receiver.on("finish",Lo))}function Dt(t){this[L]._receiver.write(t)||this.pause()}function Go(){let t=this[L];
|
|
319
319
|
t._readyState=k.CLOSING,t._receiver.end(),this.end()}function Wo(){let t=this[L];this.removeListener("error",Wo),this.on(
|
|
320
|
-
"error",Fo),t&&(t._readyState=k.CLOSING,this.destroy())}});var Zo=$((
|
|
320
|
+
"error",Fo),t&&(t._readyState=k.CLOSING,this.destroy())}});var Zo=$((Nm,Yo)=>{"use strict";var Mm=zt(),{Duplex:Tc}=M("stream");function Jo(t){t.emit("close")}function bc(){!this.destroyed&&
|
|
321
321
|
this._writableState.finished&&this.destroy()}function Xo(t){this.removeListener("error",Xo),this.destroy(),this.listenerCount(
|
|
322
|
-
"error")===0&&this.emit("error",t)}function
|
|
322
|
+
"error")===0&&this.emit("error",t)}function _c(t,e){let n=!0,r=new Tc({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
|
|
323
323
|
return t.on("message",function(s,i){let a=!i&&r._readableState.objectMode?s.toString():s;r.push(a)||t.pause()}),t.once("\
|
|
324
324
|
error",function(s){r.destroyed||(n=!1,r.destroy(s))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(o,s){
|
|
325
325
|
if(t.readyState===t.CLOSED){s(o),process.nextTick(Jo,r);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
|
|
@@ -327,21 +327,21 @@ lose",function(){i||s(o),process.nextTick(Jo,r)}),n&&t.terminate()},r._final=fun
|
|
|
327
327
|
t.once("open",function(){r._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),r._readableState.
|
|
328
328
|
endEmitted&&r.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},
|
|
329
329
|
r._write=function(o,s,i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(o,s,i)});return}t.send(o,i)},
|
|
330
|
-
r.on("end",bc),r.on("error",Xo),r}Yo.exports=
|
|
330
|
+
r.on("end",bc),r.on("error",Xo),r}Yo.exports=_c});var jr=$((jm,Qo)=>{"use strict";var{tokenChars:Cc}=Pe();function Ac(t){let e=new Set,n=-1,r=-1,o=0;for(o;o<t.length;o++){
|
|
331
331
|
let i=t.charCodeAt(o);if(r===-1&&Cc[i]===1)n===-1&&(n=o);else if(o!==0&&(i===32||i===9))r===-1&&n!==-1&&(r=o);else if(i===
|
|
332
332
|
44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let a=t.slice(n,r);if(e.has(a))throw new SyntaxError(
|
|
333
333
|
`The "${a}" subprotocol is duplicated`);e.add(a),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
|
|
334
334
|
if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=t.slice(n,o);if(e.has(s))throw new SyntaxError(
|
|
335
|
-
`The "${s}" subprotocol is duplicated`);return e.add(s),e}Qo.exports={parse:
|
|
336
|
-
Ie=Re(),
|
|
335
|
+
`The "${s}" subprotocol is duplicated`);return e.add(s),e}Qo.exports={parse:Ac}});var is=$((zm,ss)=>{"use strict";var Ec=M("events"),Lt=M("http"),{Duplex:Dm}=M("stream"),{createHash:Oc}=M("crypto"),es=Mt(),
|
|
336
|
+
Ie=Re(),Rc=jr(),Pc=zt(),{CLOSE_TIMEOUT:kc,GUID:Mc,kWebSocket:Nc}=te(),jc=/^[+/0-9A-Za-z]{22}==$/,ts=0,rs=1,os=2,Dr=class extends Ec{constructor(e,n){
|
|
337
337
|
if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*
|
|
338
|
-
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:
|
|
339
|
-
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:
|
|
338
|
+
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:kc,verifyClient:null,
|
|
339
|
+
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Pc,...e},e.port==null&&!e.server&&!e.noServer||
|
|
340
340
|
e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server"\
|
|
341
341
|
, or "noServer" options must be specified');if(e.port!=null?(this._server=Lt.createServer((r,o)=>{let s=Lt.STATUS_CODES[426];
|
|
342
342
|
o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(e.port,e.host,e.
|
|
343
343
|
backlog,n)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=
|
|
344
|
-
|
|
344
|
+
Dc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(
|
|
345
345
|
o,s,i,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=
|
|
346
346
|
!1),this.options=e,this._state=ts}address(){if(this.options.noServer)throw new Error('The server is operating in "noServ\
|
|
347
347
|
er" mode');return this._server?this._server.address():null}close(e){if(this._state===os){e&&this.once("close",()=>{e(new Error(
|
|
@@ -352,19 +352,19 @@ _server;this._removeListeners(),this._removeListeners=this._server=null,n.close(
|
|
|
352
352
|
options.path){let n=e.url.indexOf("?");if((n!==-1?e.url.slice(0,n):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,n,r,o){
|
|
353
353
|
n.on("error",ns);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
|
|
354
354
|
"GET"){Se(this,e,n,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Se(this,e,n,400,"Inva\
|
|
355
|
-
lid Upgrade header");return}if(s===void 0||!
|
|
355
|
+
lid Upgrade header");return}if(s===void 0||!jc.test(s)){Se(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}
|
|
356
356
|
if(a!==13&&a!==8){Se(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
|
|
357
|
-
if(!this.shouldHandle(e)){nt(n,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=
|
|
357
|
+
if(!this.shouldHandle(e)){nt(n,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=Rc.parse(
|
|
358
358
|
c)}catch{Se(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],m={};
|
|
359
359
|
if(this.options.perMessageDeflate&&p!==void 0){let l=new Ie({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
|
|
360
360
|
options.maxPayload});try{let v=es.parse(p);v[Ie.extensionName]&&(l.accept(v[Ie.extensionName]),m[Ie.extensionName]=l)}catch{
|
|
361
361
|
Se(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let l={
|
|
362
362
|
origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.
|
|
363
|
-
options.verifyClient.length===2){this.options.verifyClient(l,(v,x,
|
|
363
|
+
options.verifyClient.length===2){this.options.verifyClient(l,(v,x,T,O)=>{if(!v)return nt(n,x||401,T,O);this.completeUpgrade(
|
|
364
364
|
m,s,d,e,n,r,o)});return}if(!this.options.verifyClient(l))return nt(n,401)}this.completeUpgrade(m,s,d,e,n,r,o)}completeUpgrade(e,n,r,o,s,i,a){
|
|
365
|
-
if(!s.readable||!s.writable)return s.destroy();if(s[
|
|
365
|
+
if(!s.readable||!s.writable)return s.destroy();if(s[Nc])throw new Error("server.handleUpgrade() was called more than onc\
|
|
366
366
|
e with the same socket, possibly due to a misconfiguration");if(this._state>ts)return nt(s,503);let d=["HTTP/1.1 101 Swi\
|
|
367
|
-
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${
|
|
367
|
+
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Oc("sha1").update(n+Mc).digest("ba\
|
|
368
368
|
se64")}`],p=new this.options.WebSocket(null,void 0,this.options);if(r.size){let m=this.options.handleProtocols?this.options.
|
|
369
369
|
handleProtocols(r,o):r.values().next().value;m&&(d.push(`Sec-WebSocket-Protocol: ${m}`),p._protocol=m)}if(e[Ie.extensionName]){
|
|
370
370
|
let m=e[Ie.extensionName].params,l=es.format({[Ie.extensionName]:[m]});d.push(`Sec-WebSocket-Extensions: ${l}`),p._extensions=
|
|
@@ -373,7 +373,7 @@ e}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
|
373
373
|
`)),s.removeListener("error",ns),p.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
|
|
374
374
|
options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.
|
|
375
375
|
options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on("close",()=>{this.clients.delete(p),this._shouldEmitClose&&
|
|
376
|
-
!this.clients.size&&process.nextTick(rt,this)})),a(p,o)}};ss.exports=Dr;function
|
|
376
|
+
!this.clients.size&&process.nextTick(rt,this)})),a(p,o)}};ss.exports=Dr;function Dc(t,e){for(let n of Object.keys(e))t.on(
|
|
377
377
|
n,e[n]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function rt(t){t._state=os,t.emit("close")}
|
|
378
378
|
function ns(){this.destroy()}function nt(t,e,n,r){n=n||Lt.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/htm\
|
|
379
379
|
l","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Lt.STATUS_CODES[e]}\r
|
|
@@ -382,114 +382,114 @@ l","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(
|
|
|
382
382
|
\r
|
|
383
383
|
`+n)}function Se(t,e,n,r,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,Se),t.emit(
|
|
384
384
|
"wsClientError",i,n,e)}else nt(n,r,o,s)}});function I(t){return String(t??"").trim()}function yt(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||
|
|
385
|
-
e===null}var
|
|
385
|
+
e===null}var Vp=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function C(t,{fallback:e=""}={}){return String(t||"").trim()||e}function A(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function V(t,{fallback:e=0}={}){let n=Number(t);return!Number.isInteger(n)||n<1?e:n}var Wp=Object.freeze({interrupted:Object.freeze({text:"Stopped.",messageCode:"assistant.turn.stopped"}),failed:Object.freeze(
|
|
386
386
|
{text:"Assistant stopped with an error.",messageCode:"assistant.turn.failed"})});function It(t){return A(t)?{...t}:{}}var N=class extends Error{constructor(e,n,r={}){super(n,r.cause===void 0?void 0:{cause:r.cause}),this.name="AppError",this.
|
|
387
387
|
status=Number(e)||500,this.statusCode=this.status,this.code=r.code||"APP_ERROR",this.params=It(r.params),r.messageCode&&
|
|
388
388
|
(this.messageCode=String(r.messageCode),this.messageParams=It(r.messageParams)),this.details=r.details,this.headers=r.headers||
|
|
389
|
-
{}}};var
|
|
389
|
+
{}}};var Tf=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
|
|
390
390
|
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var F=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
391
|
-
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),
|
|
392
|
-
F.COMPLETED,F.FAILED,F.INTERRUPTED,F.TIMED_OUT]),
|
|
393
|
-
let{stdout:e}=await
|
|
391
|
+
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),Rf=new Set(Object.values(F)),Pf=new Set([F.CANCELLED,
|
|
392
|
+
F.COMPLETED,F.FAILED,F.INTERRUPTED,F.TIMED_OUT]),kf=new Set([F.ACTIVE,F.FINALIZING,F.STARTING]);import{execFile as oa}from"node:child_process";import{readFile as fr,readdir as sa}from"node:fs/promises";import{setTimeout as eo}from"node:timers/promises";import{promisify as ia}from"node:util";var aa=ia(oa);async function ca(t){
|
|
393
|
+
let{stdout:e}=await aa("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function Tt({runtimeTokenEnvironmentName:t="\
|
|
394
394
|
JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION_COMMAND_HASH",label:n="Native",unavailableCode:r="\
|
|
395
|
-
native_process_identity_unavailable",platform:o=process.platform,ps:s=
|
|
395
|
+
native_process_identity_unavailable",platform:o=process.platform,ps:s=ca}={}){let a=o==="darwin"?100:25,c=1,d=Object.freeze(
|
|
396
396
|
{linux:"linux-proc",darwin:"darwin"}),p=d[o]||"",m=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),l=Object.freeze(
|
|
397
397
|
{ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});function v(w={}){return!!(Number.
|
|
398
398
|
isSafeInteger(Number(w.pid))&&Number(w.pid)>0&&D(w.processIdentity)&&[m.RUNNING,m.STOPPED].includes(w.processState))}function x(w){
|
|
399
|
-
let u=Number(w);if(!Number.isSafeInteger(u)||u<=0)return!1;try{return process.kill(u,0),!0}catch{return!1}}function
|
|
399
|
+
let u=Number(w);if(!Number.isSafeInteger(u)||u<=0)return!1;try{return process.kill(u,0),!0}catch{return!1}}function T(w){
|
|
400
400
|
let u=Number(w);if(!Number.isSafeInteger(u)||u<=0)return!1;if(process.platform==="win32")return x(u);try{return process.
|
|
401
401
|
kill(-u,0),!0}catch{return!1}}function O(w,u){let f=Number(w),h=process.platform==="win32"?f:-f;try{return process.kill(
|
|
402
402
|
h,u),!0}catch(g){if(!["ESRCH","EPERM"].includes(String(g?.code||"")))throw g;return!1}}function P(w=""){let u=String(w||
|
|
403
403
|
""),f=u.lastIndexOf(")");if(f<0)return null;let h=u.slice(f+1).trim().split(/\s+/u),g=String(h[0]||""),y=Number(h[1]),S=Number(
|
|
404
|
-
h[2]),
|
|
405
|
-
test(
|
|
404
|
+
h[2]),b=String(h[19]||"");return!/^[A-Z]$/u.test(g)||!Number.isSafeInteger(y)||y<0||!Number.isSafeInteger(S)||S<=0||!/^\d+$/u.
|
|
405
|
+
test(b)?null:{parentPid:y,processGroupId:S,startTimeTicks:b,state:g}}function j(w={}){let u=A(w)?w:{};return{commandHash:I(
|
|
406
406
|
u.commandHash),platform:I(u.platform),runtimeToken:I(u.runtimeToken),startTimeTicks:I(u.startTimeTicks),version:Number(u.
|
|
407
407
|
version||0)}}function D(w={}){let u=j(w);return!!(u.version===c&&Object.values(d).includes(u.platform)&&/^[a-f0-9]{12}$/u.
|
|
408
408
|
test(u.commandHash)&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(u.runtimeToken)&&/^\d+$/u.
|
|
409
409
|
test(u.startTimeTicks))}function U(w=[],u=""){let f=w.find(h=>h.startsWith(`${u}=`));return f?f.slice(u.length+1):""}async function J(){
|
|
410
|
-
let w=[],u=await
|
|
410
|
+
let w=[],u=await sa("/proc",{withFileTypes:!0}).catch(()=>[]);for(let f of u){if(!f.isDirectory()||!/^\d+$/u.test(f.name))
|
|
411
411
|
continue;let h=Number(f.name),g=await fr(`/proc/${f.name}/stat`,"utf8").catch(()=>""),y=P(g);if(!y||y.state==="Z")continue;
|
|
412
|
-
let S=null,
|
|
413
|
-
S.toString("utf8").split("\0"):[];w.push({...y,commandHash:U(R,e),environmentReadable:
|
|
412
|
+
let S=null,b=!0;try{S=await fr(`/proc/${f.name}/environ`)}catch(E){if(String(E?.code||"")==="ENOENT")continue;b=!1}let R=b?
|
|
413
|
+
S.toString("utf8").split("\0"):[];w.push({...y,commandHash:U(R,e),environmentReadable:b,pid:h,runtimeToken:U(R,t)})}return w}
|
|
414
414
|
let H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function q(w=""){let u=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.
|
|
415
|
-
exec(String(w).trim()),f=u?H.indexOf(u[1]):-1;if(f<0)return"";let[,,h,g,y,S,
|
|
415
|
+
exec(String(w).trim()),f=u?H.indexOf(u[1]):-1;if(f<0)return"";let[,,h,g,y,S,b]=u.map(Number);return String(Date.UTC(b,f,
|
|
416
416
|
h,g,y,S)/1e3)}function ae(w=""){let u=new Map;for(let f of String(w).split(`
|
|
417
417
|
`)){let h=/^\s*(\d+) (.*)$/u.exec(f);h&&u.set(Number(h[1]),h[2])}return u}function me(w,u){if(w===void 0||!u?.startsWith(
|
|
418
418
|
w))return null;let f=u.slice(w.length).split(/\s+/u).filter(h=>/^[^=\s]+=/u.test(h));return f.length?f:null}async function We(){
|
|
419
419
|
let w=process.getuid(),u=["-x","-U",String(w),"-ww","-o","pid=,command="],[f,h,g]=await Promise.all([s(["-ax","-o","pid=\
|
|
420
|
-
,pgid=,uid=,stat=,lstart="]),s(u),s(["-E",...u])]),y=ae(h),S=ae(g),
|
|
420
|
+
,pgid=,uid=,stat=,lstart="]),s(u),s(["-E",...u])]),y=ae(h),S=ae(g),b=[];for(let R of String(f).split(`
|
|
421
421
|
`)){let E=/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+[\d:]{8}\s+\d{4})\s*$/u.exec(R);if(!E||E[4].startsWith(
|
|
422
|
-
"Z"))continue;let X=Number(E[1]),Y=Number(E[3])===w?me(y.get(X),S.get(X)):null;
|
|
423
|
-
pid:X,processGroupId:Number(E[2]),runtimeToken:U(Y||[],t),startTimeTicks:q(E[5])})}return
|
|
422
|
+
"Z"))continue;let X=Number(E[1]),Y=Number(E[3])===w?me(y.get(X),S.get(X)):null;b.push({commandHash:U(Y||[],e),environmentReadable:!!Y,
|
|
423
|
+
pid:X,processGroupId:Number(E[2]),runtimeToken:U(Y||[],t),startTimeTicks:q(E[5])})}return b}function ht(w){let u=Object.
|
|
424
424
|
values(l).includes(w?.status)?w.status:l.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(w?.processGroupIds)?
|
|
425
425
|
w.processGroupIds:[]).map(Number).filter(f=>Number.isSafeInteger(f)&&f>0))],status:u}}async function gt(w={}){if(!v(w))return{
|
|
426
426
|
processGroupIds:[],status:l.INVALID};if(w.processState===m.STOPPED)return{processGroupIds:[],status:l.ABSENT};let u=w.processIdentity,
|
|
427
427
|
f=u.platform!==p?null:o==="darwin"?await We().catch(()=>null):await J();if(!f)return{processGroupIds:[],status:l.AMBIGUOUS};
|
|
428
428
|
let h=Number(w.pid),g=f.filter(({processGroupId:E})=>E===h),y=[],S=g.some(({environmentReadable:E})=>!E);for(let E of f)
|
|
429
|
-
E.environmentReadable&&E.runtimeToken===u.runtimeToken&&E.commandHash===u.commandHash&&y.push(E);let
|
|
430
|
-
h);if(
|
|
431
|
-
status:l.AMBIGUOUS}:{processGroupIds:[],status:g.length>0||
|
|
432
|
-
for(let E of R)if(f.filter(Y=>Y.processGroupId===E).some(Y=>!Y.environmentReadable||!y.some(({pid:
|
|
429
|
+
E.environmentReadable&&E.runtimeToken===u.runtimeToken&&E.commandHash===u.commandHash&&y.push(E);let b=y.find(({pid:E})=>E===
|
|
430
|
+
h);if(b&&b.startTimeTicks!==u.startTimeTicks)return{processGroupIds:[],status:l.AMBIGUOUS};if(y.length===0)return S?{processGroupIds:[],
|
|
431
|
+
status:l.AMBIGUOUS}:{processGroupIds:[],status:g.length>0||T(h)?l.MISMATCH:l.ABSENT};let R=[...new Set(y.map(({processGroupId:E})=>E))];
|
|
432
|
+
for(let E of R)if(f.filter(Y=>Y.processGroupId===E).some(Y=>!Y.environmentReadable||!y.some(({pid:Xi})=>Xi===Y.pid)))return{
|
|
433
433
|
processGroupIds:[],status:l.AMBIGUOUS};return g.some(E=>!y.some(({pid:X})=>X===E.pid))?{processGroupIds:[],status:l.AMBIGUOUS}:
|
|
434
434
|
{processGroupIds:R,status:l.EXACT}}async function he(w={},u={}){let f=u.processIdentityInspector??gt;return ht(await f(w))}
|
|
435
435
|
async function vt(w={},u={},f=0){let h=Date.now()+f,g=await he(w,u);for(;Date.now()<h&&g.status===l.EXACT;)await eo(100),
|
|
436
|
-
g=await he(w,u);return g}async function
|
|
436
|
+
g=await he(w,u);return g}async function Ce(w={},u={}){let f=V(u.processIdentitySettleTimeoutMs,{fallback:1e3}),h=V(u.processIdentitySettlePollMs,
|
|
437
437
|
{fallback:a}),g=Date.now()+f,y=await he(w,u);for(;y.status===l.AMBIGUOUS&&Date.now()<g;)await eo(Math.min(h,Math.max(1,g-
|
|
438
|
-
Date.now()))),y=await he(w,u);return y}async function wt(w={},u="SIGTERM",f={}){let h=f.signalProcessGroup??O,g=await
|
|
438
|
+
Date.now()))),y=await he(w,u);return y}async function wt(w={},u="SIGTERM",f={}){let h=f.signalProcessGroup??O,g=await Ce(
|
|
439
439
|
w,f);if(g.status!==l.EXACT)return{inspection:g,signaledProcessGroups:[]};let y=Number(w.pid),S=[...g.processGroupIds.filter(
|
|
440
|
-
R=>R!==y),...g.processGroupIds.filter(R=>R===y)],
|
|
441
|
-
l.MISMATCH)return{inspection:E,signaledProcessGroups:
|
|
442
|
-
E.processGroupIds.includes(R)&&(h(R,u),
|
|
440
|
+
R=>R!==y),...g.processGroupIds.filter(R=>R===y)],b=[];for(let R of S){let E=await Ce(w,f);if(E.status===l.ABSENT||E.status===
|
|
441
|
+
l.MISMATCH)return{inspection:E,signaledProcessGroups:b};if(E.status!==l.EXACT)return{inspection:E,signaledProcessGroups:b};
|
|
442
|
+
E.processGroupIds.includes(R)&&(h(R,u),b.push(R))}return{inspection:await Ce(w,f),signaledProcessGroups:b}}async function ar(w={},u={}){
|
|
443
443
|
if(!v(w))return{identityStatus:l.INVALID,processExitVerified:!1,stopped:!1};if(w.processState===m.STOPPED&&w.processExitVerifiedAt)
|
|
444
|
-
return{alreadyStopped:!0,identityStatus:l.ABSENT,processExitVerified:!0,stopped:!1};let f=await
|
|
444
|
+
return{alreadyStopped:!0,identityStatus:l.ABSENT,processExitVerified:!0,stopped:!1};let f=await Ce(w,u);if(f.status===l.
|
|
445
445
|
ABSENT||f.status===l.MISMATCH)return{identityStatus:f.status,processExitVerified:!0,stopped:!1};if(f.status!==l.EXACT)return{
|
|
446
446
|
identityStatus:f.status,processExitVerified:!1,stopped:!1};let h=await wt(w,"SIGTERM",u);if(h.inspection.status===l.AMBIGUOUS)
|
|
447
447
|
return{identityStatus:h.inspection.status,processExitVerified:!1,signaledProcessGroups:h.signaledProcessGroups,stopped:!1};
|
|
448
|
-
let g=await vt(w,u,V(u.termTimeoutMs,{fallback:3e3})),y=[...h.signaledProcessGroups];if(g.status===l.EXACT){let
|
|
449
|
-
w,"SIGKILL",u);if(y=[...new Set([...y,...
|
|
448
|
+
let g=await vt(w,u,V(u.termTimeoutMs,{fallback:3e3})),y=[...h.signaledProcessGroups];if(g.status===l.EXACT){let b=await wt(
|
|
449
|
+
w,"SIGKILL",u);if(y=[...new Set([...y,...b.signaledProcessGroups])],b.inspection.status===l.AMBIGUOUS)return{identityStatus:b.
|
|
450
450
|
inspection.status,processExitVerified:!1,signaledProcessGroups:y,stopped:!1};g=await vt(w,u,V(u.killTimeoutMs,{fallback:1e3}))}
|
|
451
|
-
let S=[l.ABSENT,l.MISMATCH].includes(g.status);return{descendantProcessGroups:y.filter(
|
|
451
|
+
let S=[l.ABSENT,l.MISMATCH].includes(g.status);return{descendantProcessGroups:y.filter(b=>b!==Number(w.pid)),identityStatus:g.
|
|
452
452
|
status,pid:Number(w.pid),processExitVerified:S,signaledProcessGroups:y,stopped:S&&y.length>0}}async function cr(w){if(o!==
|
|
453
453
|
"darwin")return P(await fr(`/proc/${w}/stat`,"utf8").catch(()=>""));let u=String(await s(["-o","pgid=,lstart=","-p",String(
|
|
454
454
|
w)]).catch(()=>"")),f=/^\s*(\d+)\s+(.+?)\s*$/u.exec(u);return f?{processGroupId:Number(f[1]),startTimeTicks:q(f[2])}:null}
|
|
455
455
|
async function dr({commandHash:w="",pid:u=null,reportedIdentity:f=null,runtimeToken:h=""}={}){let g=I(w),y=I(h),S=j(f);if(D(
|
|
456
|
-
S)&&S.commandHash===g&&S.runtimeToken===y)return S;let
|
|
457
|
-
startTimeTicks||R.processGroupId!==
|
|
456
|
+
S)&&S.commandHash===g&&S.runtimeToken===y)return S;let b=Number(u),R=p&&Number.isSafeInteger(b)&&b>0?await cr(b):null;if(!R?.
|
|
457
|
+
startTimeTicks||R.processGroupId!==b){let E=new Error(`${n} process identity could not be captured.`);throw E.code=r,E}return{
|
|
458
458
|
commandHash:g,platform:p,runtimeToken:y,startTimeTicks:R.startTimeTicks,version:c}}return Object.freeze({normalize:j,isValid:D,
|
|
459
|
-
normalizeInspection:ht,capture:dr,inspect:he,stop:ar,isProcessAlive:x})}import{execFile as
|
|
459
|
+
normalizeInspection:ht,capture:dr,inspect:he,stop:ar,isProcessAlive:x})}import{execFile as ua}from"node:child_process";import{promisify as la}from"node:util";var Kf=Object.freeze(["plugins","apps","daemon_auto_start"]);var Jf=Object.freeze([[".tmp",/^(?:plugins(?:$|[.-])|git-|bundled-marketplaces$)/u],["cache",/^(?:remote_plugin_catalog|codex_apps_tools|codex_apps_server_info|codex_app_directory|bundled_plugin_exclusions)$/u]]);var tm=la(ua);function ge(t=""){return Array.from(String(t)).some(e=>{let n=e.codePointAt(0);return n<=31||n===127})}var bt=(t,e,n,r={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(n),...r}),pa=Object.freeze([Object.freeze(
|
|
460
460
|
{id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
|
|
461
|
-
webSearch:!1,models:Object.freeze([
|
|
462
|
-
|
|
461
|
+
webSearch:!1,models:Object.freeze([bt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
|
|
462
|
+
bt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai-\
|
|
463
463
|
coding-plan",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
|
|
464
|
-
webSearch:!1,models:Object.freeze([
|
|
464
|
+
webSearch:!1,models:Object.freeze([bt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),
|
|
465
465
|
Object.freeze({id:"zai",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
|
|
466
|
-
webSearch:!1,models:Object.freeze([
|
|
467
|
-
deepseek:Je("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":Je("zai-coding-plan").baseUrl,zai:Je("zai").baseUrl});var mr=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),
|
|
468
|
-
UNREACHABLE:"unreachable"}),
|
|
466
|
+
webSearch:!1,models:Object.freeze([bt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function Je(t){return pa.find(e=>e.id===t)||null}var am=32*1024*1024,cm=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
|
|
467
|
+
deepseek:Je("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":Je("zai-coding-plan").baseUrl,zai:Je("zai").baseUrl});var mr=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),wm=Tt();var hr=Object.freeze({UNIX:"unix"});var ma=process.platform==="linux"?107:103,to=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
468
|
+
UNREACHABLE:"unreachable"}),ha=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
|
|
469
469
|
SUSPECT:"suspect"}),Xe=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),ro=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
|
|
470
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
471
|
-
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var
|
|
472
|
-
|
|
470
|
+
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var ga=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
|
|
471
|
+
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var zc=ce(Zo(),1),Lc=ce(Mt(),1),Uc=ce(Re(),1),Fc=ce(Cr(),1),qc=ce(Or(),1),$c=ce(jr(),1),Bc=ce(zt(),1),Hc=ce(is(),1);var Lg=32*1024,Ug=2*1024*1024;var Gt=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
472
|
+
av=new Set(Object.values(Gt)),cv=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
|
|
473
473
|
jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
474
|
-
|
|
474
|
+
dv=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),uv=Object.freeze(["accountIde\
|
|
475
475
|
ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
|
|
476
|
-
Hash","terminalEnvHash","toolHomeSource","transport"]),
|
|
476
|
+
Hash","terminalEnvHash","toolHomeSource","transport"]),lv=Object.freeze(["userAgent"]);import hd from"node:path";var gd=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
477
477
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
478
478
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
479
479
|
ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
|
|
480
|
-
"unified_exec_zsh_fork","view_image"]);function
|
|
481
|
-
values(t))
|
|
480
|
+
"unified_exec_zsh_fork","view_image"]);function _s(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.
|
|
481
|
+
values(t))_s(e);return Object.freeze(t)}function vd(t="",e={}){let n=new Error(I(t)||"Codex cannot prove the helper exec\
|
|
482
482
|
ution policy.");n.code="codex_policy_unenforceable",n.details=Object.freeze({...e});for(let[r,o]of Object.entries(n.details))
|
|
483
|
-
["code","details","message","name"].includes(r)||(n[r]=o);return n}function
|
|
484
|
-
.151.0",disabledFeatures:n=
|
|
483
|
+
["code","details","message","name"].includes(r)||(n[r]=o);return n}function wd({clientName:t="jskit",minimumVersion:e="0\
|
|
484
|
+
.151.0",disabledFeatures:n=gd,limits:{userAgentMaxLength:r=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
|
|
485
485
|
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:p=256*1024,hookResponseMaxBytes:m=512*
|
|
486
|
-
1024}={},createError:l=
|
|
486
|
+
1024}={},createError:l=vd}={}){let v=new WeakSet;function x(u,f,h){let g=0;try{g=Buffer.byteLength(JSON.stringify(u),"ut\
|
|
487
487
|
f8")}catch{throw l(`Codex helper execution received an invalid ${h}.`)}if(g>f)throw l(`Codex helper execution received a\
|
|
488
|
-
n oversized ${h}.`)}function
|
|
488
|
+
n oversized ${h}.`)}function T(u){if(typeof u?.currentConnectionGeneration!="function")throw l("Codex helper execution c\
|
|
489
489
|
annot verify the app-server connection generation.");let f=u.currentConnectionGeneration();if(!Number.isSafeInteger(f)||
|
|
490
490
|
f<=0)throw l("Codex helper execution found no active app-server connection.");return f}async function O(u){if(typeof u?.
|
|
491
491
|
currentHelperExecutionContext!="function")throw l("Codex helper execution requires its dedicated isolated provider.");let f=await u.
|
|
492
|
-
currentHelperExecutionContext(),h=I(f?.cwd),g=I(f?.accountIdentitySignature);if(f?.executionMode!=="helper"||!h||!
|
|
492
|
+
currentHelperExecutionContext(),h=I(f?.cwd),g=I(f?.accountIdentitySignature);if(f?.executionMode!=="helper"||!h||!hd.isAbsolute(
|
|
493
493
|
h)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw l("Codex helper runtime isolation could not be verified.");return Object.freeze(
|
|
494
494
|
{accountIdentitySignature:g,cwd:h,executionMode:"helper"})}function P(u=""){let f=I(u).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
|
|
495
495
|
if(!f)return null;let h=f.slice(1).map(g=>Number.parseInt(g,10));return h.every(Number.isSafeInteger)?h:null}function j(u=""){
|
|
@@ -497,7 +497,7 @@ let f=I(u);if(!f||f.length>r||ge(f))return null;let h=`${t}/`;if(!f.startsWith(h
|
|
|
497
497
|
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?P(g[1]):null}function D(u){if(typeof u?.currentServerInfo!=
|
|
498
498
|
"function")throw l("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
|
|
499
499
|
let f=I(u.currentServerInfo()?.userAgent),h=j(f);if(!h)throw l("Codex helper execution received an unrecognised app-serv\
|
|
500
|
-
er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),y=P(e),S=h.findIndex((
|
|
500
|
+
er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),y=P(e),S=h.findIndex((b,R)=>b!==y[R]);if(S!==
|
|
501
501
|
-1&&h[S]<y[S])throw l(`Codex helper execution requires app-server ${e} or newer; current version is ${g}. Update Codex a\
|
|
502
502
|
nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function U(u=null){if(!yt(
|
|
503
503
|
u?.config))throw l("Codex helper execution could not read the effective app-server configuration.");let f=u.config.mcp_servers;
|
|
@@ -508,24 +508,24 @@ ceived an oversized or invalid MCP server inventory.");return h.sort()}function
|
|
|
508
508
|
"Codex helper execution received an unexpected hook inventory.");let h=u.data[0];if(I(h?.cwd)!==f||I(h?.cwd).length>d||!Array.
|
|
509
509
|
isArray(h.hooks)||!Array.isArray(h.errors)||h.hooks.length>a||h.errors.length>c)throw l("Codex helper execution received\
|
|
510
510
|
an incomplete hook inventory.");if(h.errors.length>0)throw l("Codex helper execution cannot continue while hook discove\
|
|
511
|
-
ry has errors.",{hookErrorCount:h.errors.length});let g=h.hooks.map(S=>{let
|
|
512
|
-
X=I(S?.sourcePath);if(!
|
|
511
|
+
ry has errors.",{hookErrorCount:h.errors.length});let g=h.hooks.map(S=>{let b=I(S?.key),R=I(S?.currentHash),E=I(S?.handlerType),
|
|
512
|
+
X=I(S?.sourcePath);if(!b||[b,R,E,X].some(Y=>Y.length>d||ge(Y)))throw l("Codex helper execution found an invalid hook inv\
|
|
513
513
|
entory entry.");if(S?.isManaged===!0&&S?.enabled===!0)throw l("Codex helper execution cannot disable a managed hook.");return{
|
|
514
|
-
currentHash:R,enabled:S?.enabled===!0,handlerType:E,isManaged:S?.isManaged===!0,key:
|
|
515
|
-
localeCompare(
|
|
514
|
+
currentHash:R,enabled:S?.enabled===!0,handlerType:E,isManaged:S?.isManaged===!0,key:b,sourcePath:X}}).sort((S,b)=>S.key.
|
|
515
|
+
localeCompare(b.key)),y=JSON.stringify(g);if(y.length>p)throw l("Codex helper execution received an oversized hook inven\
|
|
516
516
|
tory.");return{fingerprint:y,hookKeys:g.filter(S=>!S.isManaged).map(S=>S.key)}}function H({effort:u="",summary:f="",hookKeys:h=[],
|
|
517
|
-
mcpServerNames:g=[]}={}){let y={features:Object.fromEntries(n.map(
|
|
518
|
-
|
|
517
|
+
mcpServerNames:g=[]}={}){let y={features:Object.fromEntries(n.map(b=>[b,!1])),hooks:{state:Object.fromEntries(h.map(b=>[
|
|
518
|
+
b,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
|
|
519
519
|
include_permissions_instructions:!1,...u?{model_reasoning_effort:u}:{},...f?{model_reasoning_summary:f}:{},mcp_servers:Object.
|
|
520
|
-
fromEntries(g.map(
|
|
520
|
+
fromEntries(g.map(b=>[b,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
|
|
521
521
|
mcp:{enabled:!1},skills:{enabled:!1}},project_doc_max_bytes:0,shell_environment_policy:{inherit:"none",set:{}},skills:{include_instructions:!1},
|
|
522
|
-
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},S=
|
|
523
|
-
S),S}function q(u,f,h,{effort:g="",summary:y=""}={}){let S=U(u),
|
|
524
|
-
summary:y,hookKeys:
|
|
522
|
+
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},S=_s(y);return v.add(
|
|
523
|
+
S),S}function q(u,f,h,{effort:g="",summary:y=""}={}){let S=U(u),b=J(f,h);return{mcpServerNames:S,hookState:b,config:H({effort:g,
|
|
524
|
+
summary:y,hookKeys:b.hookKeys,mcpServerNames:S})}}async function ae(u,{effort:f="",summary:h=""}={}){if(D(u),typeof u?.readConfig!=
|
|
525
525
|
"function"||typeof u?.listHooks!="function")throw l("Codex helper execution cannot inventory configuration and hooks.");
|
|
526
|
-
let g=await O(u),y=
|
|
527
|
-
cted during helper policy verification.");let
|
|
528
|
-
cted during helper policy verification.");let{mcpServerNames:R,hookState:E,config:X}=q(S,
|
|
526
|
+
let g=await O(u),y=T(u),S=await u.readConfig({cwd:g.cwd,includeLayers:!1});if(T(u)!==y)throw l("Codex app-server reconne\
|
|
527
|
+
cted during helper policy verification.");let b=await u.listHooks([g.cwd]);if(T(u)!==y)throw l("Codex app-server reconne\
|
|
528
|
+
cted during helper policy verification.");let{mcpServerNames:R,hookState:E,config:X}=q(S,b,g.cwd,{effort:f,summary:h});return Object.
|
|
529
529
|
freeze({accountIdentitySignature:g.accountIdentitySignature,config:X,connectionGeneration:y,executionCwd:g.cwd,hookFingerprint:E.
|
|
530
530
|
fingerprint,hookKeys:Object.freeze([...E.hookKeys]),mcpServerNames:Object.freeze([...R])})}function me(u=null,f=null){return u?.
|
|
531
531
|
accountIdentitySignature===f?.accountIdentitySignature&&u?.connectionGeneration===f?.connectionGeneration&&u?.executionCwd===
|
|
@@ -541,212 +541,182 @@ await ht({error:S,provider:u,threadId:g})}}async function he(u,f){if(typeof u?.s
|
|
|
541
541
|
h.settings),y=I(g?.id);if(!y)throw l("Codex app-server did not return a helper thread id.");return gt(u,h.enforcement,g,
|
|
542
542
|
y,"starting")}async function vt(u,f,h){if(typeof u?.resumeThread!="function"||typeof u?.deleteThread!="function")throw l(
|
|
543
543
|
"Codex helper execution cannot safely resume and clean up its app-server thread.");let g=I(f);if(!g)throw l("Codex helpe\
|
|
544
|
-
r resume requires a controller-owned thread id.");let y=await h(),S=y.enforcement,
|
|
545
|
-
u,S,
|
|
544
|
+
r resume requires a controller-owned thread id.");let y=await h(),S=y.enforcement,b=await u.resumeThread(g,y.settings);return gt(
|
|
545
|
+
u,S,b,g,"resuming")}function Ce(u){return v.has(u)}function wt({configResult:u,hookResult:f,workdir:h,effort:g="",summary:y=""}){
|
|
546
546
|
return q(u,f,h,{effort:g,summary:y}).config}function ar({approvalPolicy:u,baseInstructions:f,config:h,cwd:g,effectiveSettings:y,
|
|
547
|
-
sandbox:S,systemPrompt:
|
|
547
|
+
sandbox:S,systemPrompt:b}){return{allowProviderModelFallback:!1,approvalPolicy:u,baseInstructions:f,config:h,cwd:g,systemPrompt:b||
|
|
548
548
|
null,dynamicTools:[],environments:[],model:y.model,runtimeWorkspaceRoots:[],sandbox:S,selectedCapabilityRoots:[]}}function cr(u,f){
|
|
549
549
|
return{...u,sessionStartSource:"startup",threadSource:f}}function dr(u){return{approvalPolicy:u.approvalPolicy,baseInstructions:u.
|
|
550
550
|
baseInstructions,config:u.config,cwd:u.cwd,systemPrompt:u.systemPrompt,model:u.model,runtimeWorkspaceRoots:u.runtimeWorkspaceRoots,
|
|
551
551
|
sandbox:u.sandbox}}function w({approvalPolicy:u,cwd:f,effectiveSettings:h,outputSchema:g}){let y={approvalPolicy:u,cwd:f,
|
|
552
552
|
environments:[],model:h.model,outputSchema:g,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
|
|
553
553
|
none"};return h.request.reasoning&&(y.effort=h.thinking),y}return Object.freeze({assertCompatibility:D,executionContext:O,
|
|
554
|
-
inspect:ae,configuration:wt,hasConfiguration:
|
|
555
|
-
start:he,resume:vt})}var
|
|
554
|
+
inspect:ae,configuration:wt,hasConfiguration:Ce,threadSettings:ar,threadStartSettings:cr,threadResumeSettings:dr,turnSettings:w,
|
|
555
|
+
start:he,resume:vt})}var Nv=wd();var rI=Object.freeze({PROVIDER_FAILURE:"provider_failure",RESPONSE_DELIVERY_FAILURE:"response_delivery_failure",SERVICE_RESTART:"\
|
|
556
556
|
service_restart",USER_CANCELLED:"user_cancelled",CONTROL_RECONFIGURATION:"control_reconfiguration",INTERRUPTED:"interrup\
|
|
557
|
-
ted"});var
|
|
557
|
+
ted"});var vI=Number.MAX_SAFE_INTEGER;var zd=(Number(process.env.AGENT_REPLY_MINUTES)||15)*60*1e3;function en(t){return{stoppedShort:`(Check from ${t}: your reply ended by saying what you'd do next, and then stopped, s\
|
|
558
558
|
o the person is left waiting. Carry on now with your tools and finish the job, then reply with the result. If you can't,\
|
|
559
559
|
say plainly why.)`,markup:`(Check from ${t}: your last message contained raw markup, such as a tool call written out as\
|
|
560
560
|
text or special tokens, so nothing in it ran and the person can't read it. Carry on now: call the tools properly to do \
|
|
561
561
|
what's left, then reply in plain words.)`,unsupported:e=>`(Check from ${t}: your reply says ${e.map(n=>`"${n}"`).join(",\
|
|
562
562
|
")}, but no tool in this reply did that, so it hasn't happened. Do it now with the right tool, or answer again without \
|
|
563
563
|
saying it's done.)`,resumed:"(This reply was interrupted part-way, when the server running it stopped. Your steps so far\
|
|
564
|
-
are above and what they did stays done. Carry on from where you got to, without redoing them, and finish the job.)"}}var
|
|
564
|
+
are above and what they did stays done. Carry on from where you got to, without redoing them, and finish the job.)"}}var UI=["You check an assistant's reply against a record of what its tools did while writing that reply.","List each sta\
|
|
565
565
|
tement in the reply that says something was done in this reply (made, saved, sent, attached, added, changed, deleted, bo\
|
|
566
566
|
oked, set up, fixed, run, tested) that the record doesn't support.","A claim is supported if a tool call and its answer \
|
|
567
567
|
in the record show it happened. Ignore plans, offers, questions, advice, facts about the person, things said to have hap\
|
|
568
568
|
pened earlier in the conversation, and descriptions of what a file or app contains.",'Reply with JSON only: {"unsupporte\
|
|
569
569
|
d": ["short quote of each unsupported claim"]}, with [] when every claim is supported.'].join(`
|
|
570
|
-
`);var
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
I(p)?m&&(l.messageCode=m):l.messageCode="assistant.codex.helperAuthUnavailable",l.messageCode&&(l.messageParams={}),l}function o(d,{
|
|
577
|
-
label:p="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw r(`${t}cod\
|
|
578
|
-
ex_helper_auth_invalid`,`${p} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",p=""){return`\
|
|
579
|
-
sha256:${Us("sha256").update(`${e}\0`,"utf8").update(I(d),"utf8").update("\0","utf8").update(String(p||""),"utf8").digest(
|
|
580
|
-
"hex")}`}function i(d=""){return Us("sha256").update(`${n}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){
|
|
581
|
-
let p=null;try{p=await Tu(d,"r");let m=await p.stat();if(!m.isFile()||m.size>cn)throw r(`${t}codex_helper_auth_invalid`,
|
|
582
|
-
"The selected Codex authentication record is invalid. Reconnect Codex and retry.",{messageCode:"assistant.codex.authReco\
|
|
583
|
-
rdInvalid"});let l=Buffer.alloc(cn+1),v=0;for(;v<l.length;){let{bytesRead:b}=await p.read(l,v,l.length-v,null);if(b===0)
|
|
584
|
-
break;v+=b}if(v>cn)throw r(`${t}codex_helper_auth_invalid`,"The selected Codex authentication record is too large. Recon\
|
|
585
|
-
nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let x=JSON.parse(l.subarray(0,v).toString("ut\
|
|
586
|
-
f8"));if(!A(x))throw new Error("invalid authentication record");return x}catch(m){throw m?.code?.startsWith?.(`${t}codex\
|
|
587
|
-
_helper_auth_`)?m:r(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. Rec\
|
|
588
|
-
onnect Codex and retry.",{messageCode:"assistant.codex.authRecordUnreadable"})}finally{await p?.close().catch(()=>null)}}
|
|
589
|
-
async function c(d={}){let p=I(d.toolHomeSource);if(!p||!Fs.isAbsolute(p))throw r(`${t}codex_helper_auth_unavailable`,"T\
|
|
590
|
-
he selected Codex account is unavailable. Reconnect Codex and retry.",{messageCode:"assistant.codex.accountUnavailable"});
|
|
591
|
-
let m=await a(Fs.join(p,".codex","auth.json")),l=I(m.auth_mode).toLowerCase();if(l==="chatgpt"){let v=A(m.tokens)?m.tokens:
|
|
592
|
-
{},x=o(v.account_id,{label:"Codex account identity",maxLength:qs}),b=o(v.access_token,{label:"Codex access token",maxLength:Cu}),
|
|
593
|
-
O=v.chatgpt_plan_type??v.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:_u});return Object.freeze(
|
|
594
|
-
{accessToken:b,accountId:x,authMode:"chatgpt",identitySignature:s("chatgpt",x),planType:P,secretSignature:i(b)})}if(["ap\
|
|
595
|
-
ikey","api_key"].includes(l)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:Au});return Object.freeze({apiKey:v,
|
|
596
|
-
authMode:"apiKey",identitySignature:s("apiKey",v),secretSignature:i(v)})}throw r(`${t}codex_helper_auth_invalid`,"The se\
|
|
597
|
-
lected Codex authentication mode is unsupported. Reconnect Codex and retry.",{messageCode:"assistant.codex.authModeUnsup\
|
|
598
|
-
ported"})}return Object.freeze({error:r,identitySignature:s,readRecord:a,readSelected:c})}var Xb=Object.freeze({label:"Checking the Codex sign-in",operationId:"codex-auth-preflight"});var nT=dn().error;var AT=4*1024*1024;var zC=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
599
|
-
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
600
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var BC=2*1024*1024,HC=32*1024*1024,VC=2*1024*1024;function z(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
601
|
-
zu(e)}function zu(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function pn(t){return t!==null&&typeof t=="object"&&z(t.structure)&&z(t.operations)&&typeof t.validateWith=="function"&&
|
|
602
|
-
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Kt(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
603
|
-
let{items:n}=e;if(pn(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
|
|
604
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function lt(t,e){
|
|
605
|
-
if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(pn(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!=
|
|
570
|
+
`);var lS=64*1024;var Qd="the app",wS=en(Qd);var IS=16*1024*1024;function z(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
571
|
+
eu(e)}function eu(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function on(t){return t!==null&&typeof t=="object"&&z(t.structure)&&z(t.operations)&&typeof t.validateWith=="function"&&
|
|
572
|
+
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Wt(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
573
|
+
let{items:n}=e;if(on(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
|
|
574
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function dt(t,e){
|
|
575
|
+
if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(on(n))return{kind:"schema",schema:n};if(!z(n)||typeof n.type!=
|
|
606
576
|
"string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
|
|
607
|
-
t.`);return{kind:"definition",definition:n}}function
|
|
577
|
+
t.`);return{kind:"definition",definition:n}}function Kt(t,e){let n=Object.hasOwn(e,"schema"),r=Object.hasOwn(e,"values"),
|
|
608
578
|
o=Object.hasOwn(e,"additionalProperties");if(n&&r)throw new Error(`Object field "${t}" cannot define both schema and val\
|
|
609
579
|
ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
|
|
610
580
|
if(r&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
|
|
611
|
-
s: true.`);if(n){if(!
|
|
612
|
-
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:
|
|
613
|
-
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ue(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}function
|
|
581
|
+
s: true.`);if(n){if(!on(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
|
|
582
|
+
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:dt(
|
|
583
|
+
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ue(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}function sn(t,e=""){
|
|
614
584
|
if(z(t))for(let[n,r]of Object.entries(t)){if(!z(r))continue;let o=e?`${e}.${n}`:n;for(let s of["minItems","maxItems"]){if(!Object.
|
|
615
585
|
hasOwn(r,s))continue;let i=r[s];if(r.type!=="array"||!Number.isInteger(i)||i<0)throw new Error(`Field "${o}" ${s} must b\
|
|
616
586
|
e a non-negative integer on an array field.`)}if(r.minItems>r.maxItems)throw new Error(`Field "${o}" minItems (${r.minItems}\
|
|
617
|
-
) is above its maxItems (${r.maxItems}).`);r.type==="array"&&z(r.items)&&typeof r.items.type=="string"&&
|
|
618
|
-
o)}}var
|
|
619
|
-
|
|
620
|
-
$`,
|
|
621
|
-
))?${
|
|
622
|
-
0)}function
|
|
623
|
-
1&&o<=12&&s>=1&&s<=
|
|
624
|
-
`temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function
|
|
625
|
-
t.length<=e}function
|
|
626
|
-
if(typeof t!="string")return!1;let n=
|
|
627
|
-
let n=
|
|
628
|
-
"":`(?:\\.\\d{1,${t}})?`}function
|
|
629
|
-
return`^${
|
|
630
|
-
test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var
|
|
631
|
-
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function
|
|
632
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
633
|
-
let o=n?
|
|
587
|
+
) is above its maxItems (${r.maxItems}).`);r.type==="array"&&z(r.items)&&typeof r.items.type=="string"&&sn({"[]":r.items},
|
|
588
|
+
o)}}var an="^(?:0|-?[1-9]\\d*)$",Ms="\\d{4}",Ns="0[1-9]|1[0-2]",js="0[1-9]|[12]\\d|3[01]",Ds="[01]\\d|2[0-3]",Fe="[0-5]\\d",
|
|
589
|
+
Jt=`(?:${Ds}):${Fe}`,zs=`(?:Z|[+-](?:${Ds}):${Fe})`,Ls=`(${Ms})-(${Ns})-(${js})`,Us=`${Ms}-(?:${Ns})-(?:${js})`,Fs=`^${Us}\
|
|
590
|
+
$`,tu=new RegExp(`^${Ls}$`),ru=new RegExp(`^${Jt}(?::${Fe}(?:\\.(\\d+))?)?$`),nu=new RegExp(`^${Ls}T${Jt}:${Fe}(?:\\.(\\d+\
|
|
591
|
+
))?${zs}$`),ou=new RegExp(an),su=[31,28,31,30,31,30,31,31,30,31,30,31];function iu(t){return t%4===0&&(t%100!==0||t%400===
|
|
592
|
+
0)}function au(t,e){return e===2?iu(t)?29:28:su[e-1]}function qs(t,e,n){let r=Number(t),o=Number(e),s=Number(n);return o>=
|
|
593
|
+
1&&o<=12&&s>=1&&s<=au(r,o)}function ut(t,e){let n=t.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(
|
|
594
|
+
`temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function $s(t,e){return t===void 0?!0:e===void 0||
|
|
595
|
+
t.length<=e}function Bs(t){if(typeof t!="string")return!1;let e=tu.exec(t);return e!==null&&qs(e[1],e[2],e[3])}function Hs(t,e){
|
|
596
|
+
if(typeof t!="string")return!1;let n=ru.exec(t);return n!==null&&$s(n[1],e)}function Vs(t,e){if(typeof t!="string")return!1;
|
|
597
|
+
let n=nu.exec(t);return n===null?!1:qs(n[1],n[2],n[3])&&$s(n[4],e)}function Gs(t){return t===void 0?"(?:\\.\\d+)?":t===0?
|
|
598
|
+
"":`(?:\\.\\d{1,${t}})?`}function Ws(t,e){let n=ut(t,e);return`^${Jt}(?::${Fe}${Gs(n)})?$`}function Ks(t,e){let n=ut(t,e);
|
|
599
|
+
return`^${Us}T${Jt}:${Fe}${Gs(n)}${zs}$`}function cn(t,e){let n;if(typeof t=="number")n=t;else if(typeof t=="string"&&ou.
|
|
600
|
+
test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var cu=new Set(["__proto__","prototype","constructor"]);function _(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0})}function du(t,e){if(cu.
|
|
601
|
+
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function uu(t){return typeof t!="string"?t:t.replace(
|
|
602
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function dn(t,e,{normalize:n=!1,allowEmpty:r=!1}={}){
|
|
603
|
+
let o=n?uu(t):t;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${e}() expects a non-empty \
|
|
634
604
|
dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
|
|
635
|
-
for(let i of s)
|
|
636
|
-
|
|
637
|
-
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:
|
|
638
|
-
none:()=>({type:
|
|
605
|
+
for(let i of s)du(i,e);return s}var lu="http://json-schema.org/draft-07/schema#",fe="x-json-rest-schema",un=["object","array","string","number","boolean"],
|
|
606
|
+
ln=Symbol("json-rest-schema.exportContext"),pu=["true","1","yes","y","on"],fu=["false","0","no","n","off"];function Js(t){
|
|
607
|
+
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:an}]}}function Te(t,e){return{[fe]:{[t]:e}}}var mu={
|
|
608
|
+
none:()=>({type:un}),blob:()=>({type:un}),serialize:()=>({type:un}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
639
609
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
640
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
641
|
-
type:"string",format:"date-time",pattern:
|
|
642
|
-
fieldName:e})=>({type:"string",pattern:
|
|
643
|
-
let e=new Set([...
|
|
610
|
+
eger","string"]}),epochMilliseconds:()=>Js(864e13),epochSeconds:()=>Js(864e10),dateTime:({definition:t,fieldName:e})=>({
|
|
611
|
+
type:"string",format:"date-time",pattern:Ks(t,e)}),date:()=>({type:"string",format:"date",pattern:Fs}),time:({definition:t,
|
|
612
|
+
fieldName:e})=>({type:"string",pattern:Ws(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
|
|
613
|
+
let e=new Set([...pu,String(t.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...fu,String(t.stringFalseWhen||
|
|
644
614
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...n,...e]}]}},
|
|
645
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
615
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},hu={minLength:({definition:t,parameterValue:e})=>t.
|
|
646
616
|
type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
|
|
647
617
|
definition:t,parameterValue:e})=>Ue(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ue(t)?{maximum:e}:null,pattern:({
|
|
648
618
|
definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
|
|
649
619
|
enum:t}),minItems:({definition:t,parameterValue:e})=>t.type==="array"?{minItems:e}:null,maxItems:({definition:t,parameterValue:e})=>t.
|
|
650
620
|
type==="array"?{maxItems:e}:null,notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({
|
|
651
|
-
parameterValue:t})=>t?
|
|
652
|
-
null,length:({parameterValue:t})=>
|
|
653
|
-
null,precision:({parameterValue:t})=>
|
|
654
|
-
parameterValue:t})=>
|
|
655
|
-
defaultTo:()=>null};function
|
|
656
|
-
"object"&&!Array.isArray(r)&&!Array.isArray(o)){
|
|
621
|
+
parameterValue:t})=>t?Te("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Te("transforms",{lowercase:!0}):
|
|
622
|
+
null,length:({parameterValue:t})=>Te("transforms",{length:t}),unsigned:({parameterValue:t})=>t?Te("metadata",{unsigned:!0}):
|
|
623
|
+
null,precision:({parameterValue:t})=>Te("metadata",{precision:t}),scale:({parameterValue:t})=>Te("metadata",{scale:t}),temporalPrecision:({
|
|
624
|
+
parameterValue:t})=>Te("metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
|
|
625
|
+
defaultTo:()=>null};function hn(t,e){for(let n of Object.keys(e)){let r=e[n],o=t[n];if(r&&o&&typeof r=="object"&&typeof o==
|
|
626
|
+
"object"&&!Array.isArray(r)&&!Array.isArray(o)){hn(o,r);continue}t[n]=r}}function gu(t,e){if(!e||typeof e!="object"||Array.
|
|
657
627
|
isArray(e))throw new Error("JSON Schema export hooks must return an object or null.");for(let n of Object.keys(e)){if(n===
|
|
658
|
-
fe&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){
|
|
659
|
-
t[n]=e[n]}}function
|
|
660
|
-
1?t:{anyOf:r}}function
|
|
661
|
-
let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=
|
|
662
|
-
`Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function
|
|
663
|
-
hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=
|
|
628
|
+
fe&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){hn(t[n],e[n]);continue}
|
|
629
|
+
t[n]=e[n]}}function vu(t,e){let r=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return r.length===
|
|
630
|
+
1?t:{anyOf:r}}function wu(t,e){if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);
|
|
631
|
+
let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=mu[e.type];if(!r)throw new Error(
|
|
632
|
+
`Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function yu(t,e,n){if(!Object.
|
|
633
|
+
hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=hu[e];
|
|
664
634
|
if(o)return o;throw new Error(`Validator '${e}' on field '${n}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
665
|
-
hook.`)}function
|
|
666
|
-
`Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
667
|
-
void 0&&e.operation!==void 0){let n=
|
|
635
|
+
hook.`)}function Xs(t){if(t===void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(
|
|
636
|
+
`Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function Iu(t,e={}){if(e.mode!==
|
|
637
|
+
void 0&&e.operation!==void 0){let n=Xs(e.mode);if(n!==e.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
668
638
|
s: mode '${n}' does not match operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))
|
|
669
|
-
throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return
|
|
639
|
+
throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return Xs(e.mode)}function Su(t,e={}){
|
|
670
640
|
if(e.operationName!==void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};
|
|
671
|
-
let n=
|
|
672
|
-
e,
|
|
673
|
-
t[
|
|
674
|
-
"_").replace(/^_+|_+$/g,"")||"operation"}function
|
|
675
|
-
function
|
|
676
|
-
n&&s.operation===r&&s.additionalProperties===o)||null}function
|
|
677
|
-
return t.nextDefinitionId+=1,r}function
|
|
641
|
+
let n=Iu(t,e);return{operationName:n,operation:t.operations[n]}}function xu(t={}){let e={...t};return Object.defineProperty(
|
|
642
|
+
e,ln,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function Yt(t={}){return t[ln]?
|
|
643
|
+
t[ln]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function Tu(t){return String(t).replace(/[^a-zA-Z0-9]+/g,
|
|
644
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function pn(t){return z(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}
|
|
645
|
+
function Xt(t){return pn(t)?{allOf:[t]}:t}function bu(t,e,n,r,o){return t.nodes.find(s=>s.schema===e&&s.operationName===
|
|
646
|
+
n&&s.operation===r&&s.additionalProperties===o)||null}function _u(t,e){let n=Tu(e),r=`SchemaNode_${t.nextDefinitionId}_${n}`;
|
|
647
|
+
return t.nextDefinitionId+=1,r}function Ys(t,e,n,r,o,{root:s=!1}={}){let i=Yt(e),a=bu(i,t,n,r,o);if(a)return s&&(a.pointer=
|
|
678
648
|
"#",i.rootNode=a),a;let c={schema:t,operationName:n,operation:r,additionalProperties:o,status:"new",definitionName:s?null:
|
|
679
|
-
|
|
680
|
-
if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=
|
|
681
|
-
ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=
|
|
682
|
-
return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function
|
|
683
|
-
let s=
|
|
684
|
-
referenceBacked:e}}function
|
|
649
|
+
_u(i,n),pointer:s?"#":null};return s?i.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function Zs(t,e){
|
|
650
|
+
if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=Yt(e);t.status="build\
|
|
651
|
+
ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=Cu(t.schema,e,t.operationName,t.operation,t.additionalProperties);
|
|
652
|
+
return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function gn(t,e,n,r,o=!1){
|
|
653
|
+
let s=Yt(e),i=Ys(t,e,n,r,o);return s.rootNode===i?{$ref:"#"}:Zs(i,e)}function lt(t,{referenceBacked:e=!1}={}){return{schema:t,
|
|
654
|
+
referenceBacked:e}}function Cu(t,e,n,r,o=!1){let s={},i=[];for(let[c,d]of Object.entries(t.structure))_(s,c,vn(t,c,d,e,n,
|
|
685
655
|
r)),r.enforceRequired&&d.required===!0&&i.push(c);let a={type:"object",properties:s,additionalProperties:o};return i.length>
|
|
686
|
-
0&&(a.required=i),a}function
|
|
656
|
+
0&&(a.required=i),a}function Au(t,e,n,r,o,s){let i=Wt(e,n);if(!i)return null;if(i.kind==="schema")return{...Xt(gn(i.schema,
|
|
687
657
|
r,"replace",i.schema.operations.replace,!1)),[fe]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
|
|
688
|
-
"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return
|
|
689
|
-
let i=
|
|
658
|
+
"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return vn(t,`${e}[]`,n.items,r,a,c)}function Eu(t,e,n,r,o,s){
|
|
659
|
+
let i=dt(e,n);if(!i)return null;if(i.kind==="schema")return{...Xt(gn(i.schema,r,"replace",i.schema.operations.replace,!1)),
|
|
690
660
|
[fe]:{castType:"object"}};let a=i.definition.type==="object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="re\
|
|
691
|
-
place"?t.operations.replace:s;return
|
|
692
|
-
e,n);if(a.kind==="nested")return
|
|
693
|
-
"opaque")return
|
|
694
|
-
t,e,n,r,o,s)})}let i=
|
|
661
|
+
place"?t.operations.replace:s;return vn(t,`${e}.*`,i.definition,r,a,c)}function Ou(t,e,n,r,o,s){if(n.type==="object"){let a=Kt(
|
|
662
|
+
e,n);if(a.kind==="nested")return lt(gn(a.schema,r,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
663
|
+
"opaque")return lt({type:"object",additionalProperties:!0});if(a.kind==="map")return lt({type:"object",additionalProperties:Eu(
|
|
664
|
+
t,e,n,r,o,s)})}let i=wu(t,n)({schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r});if(!i||typeof i!="object"||
|
|
695
665
|
Array.isArray(i))throw new Error(`Type '${n.type}' on field '${e}' returned an invalid JSON Schema fragment.`);if(n.type===
|
|
696
|
-
"array"){let a=
|
|
697
|
-
function
|
|
698
|
-
|
|
699
|
-
continue;let v=
|
|
700
|
-
c[fe]&&(
|
|
701
|
-
let m=
|
|
666
|
+
"array"){let a=Au(t,e,n,r,o,s);if(a)return lt({...i,items:a},{referenceBacked:pn(i)})}return lt(i,{referenceBacked:pn(i)})}
|
|
667
|
+
function vn(t,e,n,r,o,s){let i={schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r},a=Ou(t,e,n,r,o,s),c=a.referenceBacked?
|
|
668
|
+
Xt(a.schema):{...a.schema},d={castType:n.type};for(let l of Object.keys(n)){if(l==="type"||!Object.hasOwn(t.validators,l))
|
|
669
|
+
continue;let v=yu(t,l,e);if(!v)continue;let x=v({...i,parameterName:l,parameterValue:n[l],fieldSchema:{...c}});x&&gu(c,x)}
|
|
670
|
+
c[fe]&&(hn(d,c[fe]),delete c[fe]);let p=[];n.nullable===!0&&p.push({type:"null"}),n.nullOnEmpty===!0&&p.push({const:""});
|
|
671
|
+
let m=Xt(vu(c,p));if(n.defaultTo!==void 0&&s.applyDefaults)if(typeof n.defaultTo!="function"){let l=t._normalizeDefault(
|
|
702
672
|
n,n.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},options:{},settings:t._buildOperationSettings(
|
|
703
673
|
o,s,{})});if(Object.keys(l.errors).length>0){let v=Object.values(l.errors)[0];throw new Error(`defaultTo for "${e}" is i\
|
|
704
|
-
nvalid (${v.code}).`)}m.default=l.value}else d.defaults={providedByFunction:!0};return m[fe]=d,m}function
|
|
705
|
-
e),{operationName:r,operation:o}=
|
|
706
|
-
o,s,{root:!0}),c={$schema:
|
|
707
|
-
Be}function
|
|
708
|
-
.${String(e)}`}function
|
|
709
|
-
startsWith(n)?t.slice(n.length):null}function qe(t,e){let n={};for(let r of Object.values(t)){let o=
|
|
710
|
-
{...r,field:o})}return n}function
|
|
711
|
-
o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||
|
|
712
|
-
return e}function
|
|
713
|
-
function
|
|
674
|
+
nvalid (${v.code}).`)}m.default=l.value}else d.defaults={providedByFunction:!0};return m[fe]=d,m}function Qs(t,e={}){let n=xu(
|
|
675
|
+
e),{operationName:r,operation:o}=Su(t,n),s=n.additionalProperties===void 0?!1:n.additionalProperties,i=Yt(n),a=Ys(t,n,r,
|
|
676
|
+
o,s,{root:!0}),c={$schema:lu,...Zs(a,n)};return Object.keys(i.definitions).length>0&&(c.definitions=i.definitions),c}function ei(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Tn(t){return t instanceof
|
|
677
|
+
Be}function Ru(){return{self:!1,children:{}}}function ti(t){return Object.keys(t.children).length>0}function be(t,e){return`${t}\
|
|
678
|
+
.${String(e)}`}function ai(t,e){return t===""?String(e):be(t,e)}function ri(t,e){if(t===e)return"";let n=`${e}.`;return t.
|
|
679
|
+
startsWith(n)?t.slice(n.length):null}function qe(t,e){let n={};for(let r of Object.values(t)){let o=be(e,r.field);_(n,o,
|
|
680
|
+
{...r,field:o})}return n}function Sn(t){return dn(t,"validatePath")}function ni(t){let e={};for(let n of t){let r=Sn(n),
|
|
681
|
+
o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||_(o,i,Ru()),s===r.length-1&&(o[i].self=!0),o=o[i].children}}
|
|
682
|
+
return e}function Pu(t,e){let n=t;for(let r of e){if(n==null||typeof n!="object"||!Object.hasOwn(n,r))return;n=n[r]}return n}
|
|
683
|
+
function Zt(t){return t===null?!0:Array.isArray(t)||z(t)?Object.keys(t).length>0:t!==void 0}function oi(t){return[...t].
|
|
714
684
|
sort((e,n)=>{let r=/^[0-9]+$/.test(e),o=/^[0-9]+$/.test(n);return r&&o?Number(e)-Number(n):r?-1:o?1:e.localeCompare(n)})}
|
|
715
|
-
function
|
|
685
|
+
function ku(t){return/^[0-9]+$/.test(t)}function Mu(t,e=new WeakMap){if(e.has(t))return e.get(t);let n=Object.create(Be.
|
|
716
686
|
prototype);return e.set(t,n),n.structure=null,n.types=t.types,n.validators=t.validators,n.operations=t.operations,n.structure=
|
|
717
|
-
|
|
718
|
-
"object")return t;if(
|
|
687
|
+
er(Qt(t.structure,e)),n._installOperationMethods(),Object.freeze(n)}function Qt(t,e=new WeakMap){if(t===null||typeof t!=
|
|
688
|
+
"object")return t;if(Tn(t))return Mu(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let r=new RegExp(
|
|
719
689
|
t.source,t.flags);return r.lastIndex=t.lastIndex,r}if(e.has(t))return e.get(t);if(Array.isArray(t)){let r=[];e.set(t,r);
|
|
720
|
-
for(let o of t)r.push(
|
|
721
|
-
o,e));return n}function
|
|
722
|
-
isArray(t))for(let n of t)
|
|
723
|
-
return
|
|
724
|
-
if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=
|
|
725
|
-
function
|
|
726
|
-
n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.length<1)return null;let[s,...i]=n;if(!
|
|
727
|
-
let a=
|
|
728
|
-
function $e(t,e){let n={...t};if(Array.isArray(t.skipFields)){let r=t.skipFields.map(o=>
|
|
690
|
+
for(let o of t)r.push(Qt(o,e));return r}if(!z(t))return t;let n={};e.set(t,n);for(let[r,o]of Object.entries(t))_(n,r,Qt(
|
|
691
|
+
o,e));return n}function er(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Tn(t))return t;if(e.add(t),Array.
|
|
692
|
+
isArray(t))for(let n of t)er(n,e);else for(let n of Reflect.ownKeys(t))er(t[n],e);return Object.freeze(t)}function wn(t){
|
|
693
|
+
return er(Qt(t))}var yn=new WeakMap;function xn(t,e,n=""){if(!Tn(t)||!Array.isArray(e)||e.length<1)return null;let[r,...o]=e;
|
|
694
|
+
if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=ai(n,r);return ci(t,s,o,i)}
|
|
695
|
+
function ci(t,e,n,r){if(e?.type==="object"){let o=t._resolveObjectFieldMode(r,e);return o.kind!=="nested"?null:xn(o.schema,
|
|
696
|
+
n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.length<1)return null;let[s,...i]=n;if(!ku(s))return null;
|
|
697
|
+
let a=be(r,s);return o.kind==="schema"?i.length<1?null:xn(o.schema,i,a):i.length<1?o.definition:ci(t,o.definition,i,a)}return null}
|
|
698
|
+
function $e(t,e){let n={...t};if(Array.isArray(t.skipFields)){let r=t.skipFields.map(o=>ri(o,e)).filter(o=>o!==null&&o!==
|
|
729
699
|
"");r.length>0?n.skipFields=r:delete n.skipFields}if(z(t.skipParams)){let r={};for(let[o,s]of Object.entries(t.skipParams)){
|
|
730
|
-
let i=
|
|
700
|
+
let i=ri(o,e);i===null||i===""||_(r,i,s)}Object.keys(r).length>0?n.skipParams=r:delete n.skipParams}return n}var Nu=Object.
|
|
731
701
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
732
702
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
733
703
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
734
|
-
function
|
|
735
|
-
", ")}.`)}function
|
|
736
|
-
must define ${n} as a boolean.`)}function
|
|
737
|
-
eration "${t}" must be an object.`);return
|
|
738
|
-
pplyDefaults"),
|
|
704
|
+
function si(t,e,n,r){let o=e[n];if(!r.includes(o))throw new Error(`Operation "${t}" must define ${n} as one of: ${r.join(
|
|
705
|
+
", ")}.`)}function In(t,e,n,r=!0){let o=e[n];if(!(o===void 0&&!r)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
|
|
706
|
+
must define ${n} as a boolean.`)}function ju(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
|
|
707
|
+
eration "${t}" must be an object.`);return si(t,e,"targetFields",["schema","input"]),In(t,e,"enforceRequired"),In(t,e,"a\
|
|
708
|
+
pplyDefaults"),si(t,e,"outputFields",["validated","input"]),In(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
|
|
739
709
|
targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
|
|
740
|
-
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function
|
|
710
|
+
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function Du(t={}){if(typeof t!="object"||t===null||Array.
|
|
741
711
|
isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[n,r]of Object.entries(
|
|
742
|
-
|
|
743
|
-
null);for(let[n,r]of Object.entries(t))
|
|
744
|
-
delete e.mode,e}var Be=class{constructor(e,n,r,o={}){
|
|
745
|
-
operations=
|
|
712
|
+
Nu))_(e,n,r);for(let[n,r]of Object.entries(t))_(e,n,ju(n,r));return Object.freeze(e)}function ii(t){let e=Object.create(
|
|
713
|
+
null);for(let[n,r]of Object.entries(t))_(e,n,r);return Object.freeze(e)}function zu(t){let e={...t};return delete e.operation,
|
|
714
|
+
delete e.mode,e}var Be=class{constructor(e,n,r,o={}){sn(e),this.structure=e,this.types=ii(n),this.validators=ii(r),this.
|
|
715
|
+
operations=Du(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could\
|
|
746
716
|
not be cast to the required type.")}_paramError(e,n,r,o={}){let s=new Error(r);return s.errorObject={field:e,code:n,message:r,
|
|
747
717
|
params:o},s}_paramToBeSkipped(e,n,r){return typeof n!="object"||n===null?!1:!!(Array.isArray(n[r])&&n[r].includes(e))}_fieldToBeSkipped(e,n){
|
|
748
|
-
return Array.isArray(n.skipFields)&&n.skipFields.includes(e)}_mergeErrors(e,n){for(let[r,o]of Object.entries(n))
|
|
749
|
-
let n={};return
|
|
718
|
+
return Array.isArray(n.skipFields)&&n.skipFields.includes(e)}_mergeErrors(e,n){for(let[r,o]of Object.entries(n))_(e,r,o)}_singleErrorMap(e){
|
|
719
|
+
let n={};return _(n,e.field,e),n}_assertSupportedOptions(e={}){if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("U\
|
|
750
720
|
nsupported validation option `onlyObjectValues`. Call `patch()` directly.");if(Object.hasOwn(e,"mode"))throw new Error("\
|
|
751
721
|
Unsupported validation option `mode`. Call `validateWith()` or an operation method directly.");if(Object.hasOwn(e,"opera\
|
|
752
722
|
tion"))throw new Error("Unsupported validation option `operation`. Call `validateWith()` or an operation method directly\
|
|
@@ -757,124 +727,124 @@ isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(!z(n))thro
|
|
|
757
727
|
ct input.`)}_resolvePathValidationRequest(e={}){let n=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
|
|
758
728
|
hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
759
729
|
oth are provided.");if(!Object.hasOwn(this.operations,n))throw new Error(`Unknown operation "${n}".`);let r=this.operations[n];
|
|
760
|
-
return{operationName:n,operation:r,validationOptions:
|
|
730
|
+
return{operationName:n,operation:r,validationOptions:zu(e)}}_buildOperationResult(e,n,r){let o={};for(let s of r.outputFieldNames){
|
|
761
731
|
if(!Object.hasOwn(this.structure,s))continue;let i=r.isFieldPresent(s);(n[s]!==void 0||i&&e[s]===null||r.defaultedFields.
|
|
762
|
-
has(s))&&(!i&&!r.defaultedFields.has(s)||
|
|
763
|
-
return
|
|
732
|
+
has(s))&&(!i&&!r.defaultedFields.has(s)||_(o,s,n[s]))}return o}_resolveObjectFieldMode(e,n){return Kt(e,n)}_resolveArrayItemsConfig(e,n){
|
|
733
|
+
return Wt(e,n)}_resolveObjectValuesConfig(e,n){return dt(e,n)}_buildArrayItemSettings(e,n){return e.type==="object"&&Object.
|
|
764
734
|
hasOwn(e,"schema")?{...n,operationName:"replace",operation:this.operations.replace}:n}_castValue(e,n,r,o,s,i,a,c){let d=e.
|
|
765
735
|
nullable===!0||a.nullable===!0,p=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
|
|
766
|
-
`No casting function for type: ${e.type}`);let m=this.types[e.type];if(n===null)return d?(
|
|
736
|
+
`No casting function for type: ${e.type}`);let m=this.types[e.type];if(n===null)return d?(_(o,s,null),{errors:{},shouldContinue:!1}):
|
|
767
737
|
{errors:this._singleErrorMap({field:r,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
768
|
-
if(n===""&&p)return
|
|
738
|
+
if(n===""&&p)return _(o,s,null),{errors:{},shouldContinue:!1};let l={schema:this,definition:e,value:n,fieldName:r,object:o,
|
|
769
739
|
objectBeforeCast:i,valueBeforeCast:n,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
770
|
-
nullable:d||p,nullOnEmpty:p},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(v,x,
|
|
771
|
-
r,v,x,
|
|
740
|
+
nullable:d||p,nullOnEmpty:p},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(v,x,T)=>{throw this._paramError(
|
|
741
|
+
r,v,x,T)}};try{let v=m(l);if(ei(v))throw new Error(`Type handler for "${e.type}" must be synchronous.`);v!==void 0&&(_(o,
|
|
772
742
|
s,v),l.value=v)}catch(v){if(v.errorObject)return{errors:this._singleErrorMap(v.errorObject),shouldContinue:!1};throw v}return{
|
|
773
743
|
errors:{},context:l,shouldContinue:!0}}_runFieldValidators(e,n,r,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
|
|
774
744
|
_paramToBeSkipped(a,i.skipParams,n)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
|
|
775
|
-
a,s.parameterValue=e[a];let d=c(s);if(
|
|
776
|
-
(
|
|
745
|
+
a,s.parameterValue=e[a];let d=c(s);if(ei(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
|
|
746
|
+
(_(r,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,n,r,o,s,i,a,c){
|
|
777
747
|
let d=this._castValue(e,n,r,o,s,i,a,c);if(Object.keys(d.errors).length>0)return d.errors;if(!d.shouldContinue)return{};let{
|
|
778
748
|
context:p}=d,m=this._validateNestedValue(e,r,o,s,a,c);return Object.keys(m).length>0?m:(p.value=o[s],this._runFieldValidators(
|
|
779
749
|
e,r,o,s,p,a))}_normalizeDefault(e,n,{fieldPath:r,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
|
|
780
|
-
let d={...o};return
|
|
750
|
+
let d={...o};return _(d,s,n),{errors:this._normalizeAndValidateValue(e,n,r,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,n,r,o,s,i){
|
|
781
751
|
if(e.type==="object"){let c=this._resolveObjectFieldMode(n,e);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
782
752
|
c,n,r,o,s,i):c.kind==="map"?this._validateObjectValues(n,r,o,c.valuesConfig,s,i):{}}if(e.type!=="array")return{};let a=this.
|
|
783
753
|
_resolveArrayItemsConfig(n,e);return a?this._validateArrayItems(n,r,o,a,s,i):{}}_validateNestedObjectSchema(e,n,r,o,s,i){
|
|
784
754
|
let a=r[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
|
|
785
|
-
i.operationName,i.operation,c,$e(s,n));return
|
|
755
|
+
i.operationName,i.operation,c,$e(s,n));return _(r,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
786
756
|
a,e.schema,d.validatedObject):d.validatedObject),qe(d.errors,n)}_extractKnownObjectFields(e,n){let r={};for(let[o,s]of Object.
|
|
787
|
-
entries(e))Object.hasOwn(n.structure,o)&&
|
|
788
|
-
keys(e)){if(!Object.hasOwn(n.structure,s)){
|
|
789
|
-
r))Object.hasOwn(o,s)||
|
|
790
|
-
keys(a)){let m=
|
|
757
|
+
entries(e))Object.hasOwn(n.structure,o)&&_(r,o,s);return r}_mergeKnownAndPassthroughObjectFields(e,n,r){let o={};for(let s of Object.
|
|
758
|
+
keys(e)){if(!Object.hasOwn(n.structure,s)){_(o,s,e[s]);continue}Object.hasOwn(r,s)&&_(o,s,r[s])}for(let[s,i]of Object.entries(
|
|
759
|
+
r))Object.hasOwn(o,s)||_(o,s,i);return o}_validateObjectValues(e,n,r,o,s,i){let a=n[r],c={...a},d={};_(n,r,c);for(let p of Object.
|
|
760
|
+
keys(a)){let m=be(e,p);if(this._fieldToBeSkipped(m,s))continue;let l=c[p];if(l===void 0){i.rejectExplicitUndefined?this.
|
|
791
761
|
_mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[p];continue}if(o.kind==="schema"){let x=o.
|
|
792
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,l,$e(s,m));
|
|
762
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,l,$e(s,m));_(c,p,x.validatedObject),this._mergeErrors(
|
|
793
763
|
d,qe(x.errors,m));continue}let v=this._normalizeAndValidateValue(o.definition,l,m,c,p,a,s,this._buildArrayItemSettings(o.
|
|
794
|
-
definition,i));this._mergeErrors(d,v)}return d}_validateArrayItems(e,n,r,o,s,i){let a=n[r],c=a.slice(),d={};
|
|
795
|
-
c.length;p++){let m=
|
|
764
|
+
definition,i));this._mergeErrors(d,v)}return d}_validateArrayItems(e,n,r,o,s,i){let a=n[r],c=a.slice(),d={};_(n,r,c);for(let p=0;p<
|
|
765
|
+
c.length;p++){let m=be(e,p);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(a,p)||c[p]===void 0){i.rejectExplicitUndefined?
|
|
796
766
|
this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[p];continue}if(o.kind==="schema"){let v=o.
|
|
797
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[p],$e(s,m));
|
|
767
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[p],$e(s,m));_(c,p,v.validatedObject),this._mergeErrors(
|
|
798
768
|
d,qe(v.errors,m));continue}let l=this._normalizeAndValidateValue(o.definition,c[p],m,c,p,a,s,this._buildArrayItemSettings(
|
|
799
769
|
o.definition,i));this._mergeErrors(d,l)}return d}_validateField(e,n,r,o,s){if(!Object.hasOwn(this.structure,e))return{};
|
|
800
770
|
let i=this.structure[e];if(this._fieldToBeSkipped(e,o))return{};let a=s.isFieldPresent(e),c=n[e],d=c===void 0;return s.enforceRequired&&
|
|
801
771
|
i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
|
|
802
772
|
Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
|
|
803
773
|
_normalizeAndValidateValue(i,c,e,r,e,n,o,s):{}}_validateWithOperation(e,n,r,o){this._assertSupportedOptions(o);let s={},
|
|
804
|
-
i={...r},a=this._buildOperationSettings(e,n,r);for(let c of Object.keys(r))Object.hasOwn(this.structure,c)||
|
|
774
|
+
i={...r},a=this._buildOperationSettings(e,n,r);for(let c of Object.keys(r))Object.hasOwn(this.structure,c)||_(s,c,{field:c,
|
|
805
775
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
|
|
806
776
|
c,r,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
807
777
|
this.structure[c].defaultTo!==void 0){let d=this.structure[c],p=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
|
|
808
778
|
m=this._normalizeDefault(d,p,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:r,options:o,settings:a});if(this.
|
|
809
|
-
_mergeErrors(s,m.errors),Object.keys(m.errors).length>0)continue;
|
|
810
|
-
_buildOperationResult(r,i,a),errors:s}}_validateSelectedTree(e,n,r,o,s=""){let i={},a={};for(let c of
|
|
811
|
-
let d=
|
|
779
|
+
_mergeErrors(s,m.errors),Object.keys(m.errors).length>0)continue;_(i,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
780
|
+
_buildOperationResult(r,i,a),errors:s}}_validateSelectedTree(e,n,r,o,s=""){let i={},a={};for(let c of oi(Object.keys(e))){
|
|
781
|
+
let d=ai(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let p=this._validateSelectedField(
|
|
812
782
|
c,e[c],n,a,r,o,d);this._mergeErrors(i,p)}return{validatedObject:a,errors:i}}_validateSelectedField(e,n,r,o,s,i,a){if(!Object.
|
|
813
|
-
hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,p=
|
|
783
|
+
hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,p=ti(n);if(this._fieldToBeSkipped(a,s))return{};
|
|
814
784
|
let m=Object.hasOwn(r,e),l=r[e],v={};if(!m){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
|
|
815
785
|
a)&&this._mergeErrors(v,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
|
|
816
786
|
c.defaultTo!==void 0){let P=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,j=this._normalizeDefault(c,P,{fieldPath:a,
|
|
817
787
|
currentObject:o,containerKey:e,objectBeforeCast:r,options:s,settings:i});this._mergeErrors(v,j.errors),Object.keys(j.errors).
|
|
818
|
-
length===0&&
|
|
788
|
+
length===0&&_(o,e,j.value)}return v}if(l===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
819
789
|
a).errorObject):{};let x={[e]:l};if(d){let P=this._normalizeAndValidateValue(c,l,a,x,e,r,s,i);return Object.hasOwn(x,e)&&
|
|
820
|
-
x[e]!==void 0?
|
|
821
|
-
|
|
822
|
-
x,e,s,i);return
|
|
790
|
+
x[e]!==void 0?_(o,e,x[e]):x[e]===null&&_(o,e,null),P}if(!p)return{};let T=this._castValue(c,l,a,x,e,r,s,i);if(Object.keys(
|
|
791
|
+
T.errors).length>0)return T.errors;if(!T.shouldContinue)return{};let O=this._validateSelectedDescendants(c,n.children,a,
|
|
792
|
+
x,e,s,i);return Zt(x[e])&&_(o,e,x[e]),O}_validateSelectedDescendants(e,n,r,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
823
793
|
r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested field selection.`);let d=o[s];if(!z(
|
|
824
|
-
d))return{};let p=c.schema._validateSelectedTree(n,d,$e(i,r),{...a,defaultedFields:new Set});return
|
|
794
|
+
d))return{};let p=c.schema._validateSelectedTree(n,d,$e(i,r),{...a,defaultedFields:new Set});return _(o,s,p.validatedObject),
|
|
825
795
|
qe(p.errors,r)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(r,e);if(!c)throw new Error(`Schema path "${r}" d\
|
|
826
796
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(r,o,s,c,n,i,a)}throw new Error(
|
|
827
797
|
`Schema path "${r}" does not support nested field selection.`)}_validateSelectedArrayItems(e,n,r,o,s,i,a){let c=[],d=n[r],
|
|
828
|
-
p={};
|
|
829
|
-
id because array segments must use numeric indexes.`);let l=Number(m),v=
|
|
830
|
-
v,i))continue;if(!Object.hasOwn(d,l)){
|
|
831
|
-
if(P===void 0){
|
|
832
|
-
let q=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,$e(i,v));
|
|
798
|
+
p={};_(n,r,c);for(let m of oi(Object.keys(s))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${be(e,m)}" is inval\
|
|
799
|
+
id because array segments must use numeric indexes.`);let l=Number(m),v=be(e,l),x=s[m],T=x.self===!0,O=ti(x);if(this._fieldToBeSkipped(
|
|
800
|
+
v,i))continue;if(!Object.hasOwn(d,l)){T&&a.rejectExplicitUndefined&&_(p,v,this._typeError(v).errorObject);continue}let P=d[l];
|
|
801
|
+
if(P===void 0){T&&a.rejectExplicitUndefined&&_(p,v,this._typeError(v).errorObject);continue}if(o.kind==="schema"){if(T){
|
|
802
|
+
let q=o.schema._validateWithOperation("replace",o.schema.operations.replace,P,$e(i,v));Zt(q.validatedObject)&&_(c,l,q.validatedObject),
|
|
833
803
|
this._mergeErrors(p,qe(q.errors,v));continue}if(!O)continue;let H=o.schema._validateSelectedTree(x.children,P,$e(i,v),{...a,
|
|
834
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
835
|
-
this._mergeErrors(p,qe(H.errors,v));continue}let j=this._buildArrayItemSettings(o.definition,a),D=[P];if(
|
|
836
|
-
o.definition,P,v,D,0,d,i,j);Object.hasOwn(D,0)&&D[0]!==void 0?
|
|
804
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Zt(H.validatedObject)&&_(c,l,H.validatedObject),
|
|
805
|
+
this._mergeErrors(p,qe(H.errors,v));continue}let j=this._buildArrayItemSettings(o.definition,a),D=[P];if(T){let H=this._normalizeAndValidateValue(
|
|
806
|
+
o.definition,P,v,D,0,d,i,j);Object.hasOwn(D,0)&&D[0]!==void 0?_(c,l,D[0]):D[0]===null&&_(c,l,null),this._mergeErrors(p,H);
|
|
837
807
|
continue}if(!O)continue;let U=this._castValue(o.definition,P,v,D,0,d,i,j);if(Object.keys(U.errors).length>0){this._mergeErrors(
|
|
838
808
|
p,U.errors);continue}if(!U.shouldContinue)continue;let J=this._validateSelectedDescendants(o.definition,x.children,v,D,0,
|
|
839
|
-
i,j);
|
|
809
|
+
i,j);Zt(D[0])&&_(c,l,D[0]),this._mergeErrors(p,J)}return p}validateWith(e,n,r={}){if(!Object.hasOwn(this.operations,e))throw new Error(
|
|
840
810
|
`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,n),this._validateWithOperation(
|
|
841
|
-
e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=
|
|
842
|
-
_resolvePathValidationRequest(r),c=this._validateSelectedTree(
|
|
811
|
+
e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=Sn(e),{operationName:s,operation:i,validationOptions:a}=this.
|
|
812
|
+
_resolvePathValidationRequest(r),c=this._validateSelectedTree(ni([e]),n,a,this._buildOperationSettings(s,i,n));return{validatedValue:Pu(
|
|
843
813
|
c.validatedObject,o),errors:c.errors}}validatePaths(e,n,r={}){if(this._assertPlainObjectInput("validatePaths",n),!Array.
|
|
844
814
|
isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
845
|
-
operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(
|
|
815
|
+
operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(ni(e),n,i,this.
|
|
846
816
|
_buildOperationSettings(o,s,n))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
|
|
847
817
|
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(n,r={})=>this.validateWith(e,n,r)}}toJsonSchema(e={}){
|
|
848
|
-
return
|
|
849
|
-
if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=
|
|
850
|
-
return n===null?null:
|
|
851
|
-
messages===null?Object.freeze({}):
|
|
852
|
-
o)&&this.structure[o][n]&&
|
|
853
|
-
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=
|
|
854
|
-
m;let l=r.call(this,p,m);switch(typeof l){case
|
|
855
|
-
"object"||typeof t=="function")&&typeof t.then=="function"}function
|
|
818
|
+
return Qs(this,e)}getFieldDefinitions(){return yn.has(this)||yn.set(this,wn(this.structure)),yn.get(this)}getFieldDefinition(e){
|
|
819
|
+
if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=xn(this,Sn(e.trim()));
|
|
820
|
+
return n===null?null:wn(n)}getFieldMessages(e){let n=this.getFieldDefinition(e);return!n||typeof n.messages!="object"||n.
|
|
821
|
+
messages===null?Object.freeze({}):wn(n.messages)}cleanup(e,n){let r={};for(let o of Object.keys(e))Object.hasOwn(this.structure,
|
|
822
|
+
o)&&this.structure[o][n]&&_(r,o,e[o]);return r}};var{parse:GS,stringify:Lu}=JSON,{keys:WS}=Object,Uu=String,Fu="string";var di="object",qu=(t,e)=>e;var ui=(t,e,n)=>{let r=Uu(e.push(n)-1);return t.set(n,r),r};var li=(t,e,n)=>{let r=e&&typeof e===di?(p,m)=>p===""||-1<e.indexOf(p)?m:void 0:e||qu,o=new Map,s=[],i=[],a=+ui(o,s,r.call(
|
|
823
|
+
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=Lu(s[a++],d,n);return"["+i.join(",")+"]";function d(p,m){if(c)return c=!c,
|
|
824
|
+
m;let l=r.call(this,p,m);switch(typeof l){case di:if(l===null)return l;case Fu:return o.get(l)||ui(o,s,l)}return l}};var Bu=new Set(["true","1","yes","y","on"]),Hu=new Set(["false","0","no","n","off"]);function Vu(t){return t!==null&&(typeof t==
|
|
825
|
+
"object"||typeof t=="function")&&typeof t.then=="function"}function pi(t){if(typeof t=="number")return Number.isFinite(t)?
|
|
856
826
|
t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
|
|
857
|
-
if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function
|
|
827
|
+
if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function bn(t,e){if(Object.is(t,e))return!0;
|
|
858
828
|
if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
|
|
859
829
|
source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
|
|
860
|
-
e.length)return!1;for(let o=0;o<t.length;o++)if(!
|
|
830
|
+
e.length)return!1;for(let o=0;o<t.length;o++)if(!bn(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
|
|
861
831
|
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let n=Object.keys(t),r=Object.keys(
|
|
862
|
-
e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!
|
|
832
|
+
e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!bn(t[o],e[o]))return!1;return!0}var Gu={install(t){
|
|
863
833
|
let{addType:e,addValidator:n}=t;e("none",r=>r.value),e("file",r=>{let o=r.value;o==null&&r.throwTypeError();let s=typeof o;
|
|
864
834
|
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),
|
|
865
835
|
e("string",r=>{let o=r.value;if(o==null)return"";let s=typeof o;if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();
|
|
866
|
-
return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=
|
|
867
|
-
null&&r.throwTypeError(),o}),e("integer",r=>{let o=
|
|
868
|
-
o}),e("epochMilliseconds",r=>{let o=
|
|
869
|
-
r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=
|
|
870
|
-
value,o)||r.throwTypeError(),r.value}),e("date",r=>(
|
|
871
|
-
r.fieldName);return
|
|
836
|
+
return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=pi(r.value);return o===
|
|
837
|
+
null&&r.throwTypeError(),o}),e("integer",r=>{let o=pi(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
|
|
838
|
+
o}),e("epochMilliseconds",r=>{let o=cn(r.value,864e13);return o===null&&r.throwTypeError(),o}),e("epochSeconds",r=>{let o=cn(
|
|
839
|
+
r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=ut(r.definition,r.fieldName);return Vs(r.
|
|
840
|
+
value,o)||r.throwTypeError(),r.value}),e("date",r=>(Bs(r.value)||r.throwTypeError(),r.value)),e("time",r=>{let o=ut(r.definition,
|
|
841
|
+
r.fieldName);return Hs(r.value,o)||r.throwTypeError(),r.value}),e("array",r=>r.definition.type==="array"&&!Array.isArray(
|
|
872
842
|
r.value)?[r.value]:r.value),e("object",r=>(z(r.value)||r.throwTypeError(),r.value)),e("serialize",r=>{try{return JSON.stringify(
|
|
873
|
-
r.value)}catch{try{return
|
|
843
|
+
r.value)}catch{try{return li(r.value)}catch{r.throwTypeError()}}}),e("boolean",r=>{if(typeof r.value=="boolean")return r.
|
|
874
844
|
value;if(typeof r.value=="number"){if(r.value===1)return!0;if(r.value===0)return!1;r.throwTypeError()}if(typeof r.value==
|
|
875
845
|
"bigint"){if(r.value===1n)return!0;if(r.value===0n)return!1;r.throwTypeError()}if(typeof r.value=="string"){let o=String(
|
|
876
846
|
r.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(r.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
877
|
-
i=r.value.trim().toLowerCase(),a=new Set([...
|
|
847
|
+
i=r.value.trim().toLowerCase(),a=new Set([...Hu,o]),c=new Set([...Bu,s]);if(a.has(i))return!1;if(c.has(i))return!0}r.throwTypeError()}),
|
|
878
848
|
e("id",r=>{if(typeof r.value=="number"){if(Number.isSafeInteger(r.value)&&r.value>0)return r.value;r.throwTypeError()}if(typeof r.
|
|
879
849
|
value=="bigint"){if(r.value>0n&&r.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(r.value);r.throwTypeError()}if(typeof r.
|
|
880
850
|
value=="string"){let o=r.value.trim();/^[1-9][0-9]*$/.test(o)||r.throwTypeError();let s=Number(o);return Number.isSafeInteger(
|
|
@@ -887,7 +857,7 @@ r.value.toString().length>r.parameterValue&&r.throwParamError("MAX_LENGTH",`Leng
|
|
|
887
857
|
characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&Ue(r.definition)&&
|
|
888
858
|
typeof r.value=="number"&&r.value>r.parameterValue&&r.throwParamError("MAX_VALUE",`Value must be no more than ${r.parameterValue}\
|
|
889
859
|
.`,{max:r.parameterValue,actual:r.value})}),n("enum",r=>{if(!Array.isArray(r.parameterValue))throw new Error(`Enum for ${r.
|
|
890
|
-
fieldName} must be an array.`);r.parameterValue.some(s=>
|
|
860
|
+
fieldName} must be an array.`);r.parameterValue.some(s=>bn(s,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
|
|
891
861
|
one of the allowed enum values.",{allowed:r.parameterValue})}),n("pattern",r=>{if(r.value===void 0||r.definition.type!==
|
|
892
862
|
"string"||typeof r.value!="string")return;let o=r.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
893
863
|
"string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${r.fieldName} must be a string or RegExp.`);s.test(r.value)||
|
|
@@ -895,7 +865,7 @@ r.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
895
865
|
parameterValue){if(r.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${r.
|
|
896
866
|
fieldName}).`);typeof r.valueBeforeCast!="boolean"&&r.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),n(
|
|
897
867
|
"validator",r=>{if(typeof r.parameterValue!="function")throw new Error(`Validator for ${r.fieldName} must be a function.`);
|
|
898
|
-
let o=r.parameterValue(r.value,r.object,r);if(
|
|
868
|
+
let o=r.parameterValue(r.value,r.object,r);if(Vu(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
|
|
899
869
|
ronous.`);typeof o=="string"&&r.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),n("uppercase",r=>{if(typeof r.value=="str\
|
|
900
870
|
ing")return r.value.toUpperCase()}),n("lowercase",r=>{if(typeof r.value=="string")return r.value.toLowerCase()}),n("leng\
|
|
901
871
|
th",r=>{if(typeof r.value=="string")return r.value.substr(0,r.parameterValue);Number.isInteger(Number(r.valueBeforeCast))&&
|
|
@@ -907,61 +877,61 @@ r.throwParamError("MAX_ITEMS",`Must have no more than ${r.parameterValue} items.
|
|
|
907
877
|
n("notEmpty",r=>{r.parameterValue&&typeof r.value=="string"&&r.value===""&&r.throwParamError("NOT_EMPTY","Field cannot b\
|
|
908
878
|
e empty.")}),n("required",()=>{}),n("unsigned",()=>{}),n("precision",()=>{}),n("scale",()=>{}),n("temporalPrecision",r=>{
|
|
909
879
|
if(r.definition.type!=="time"&&r.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
|
|
910
|
-
e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},
|
|
911
|
-
if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);
|
|
912
|
-
"function")throw new Error(`Validator handler for '${e}' must be a function.`);
|
|
913
|
-
null);for(let[n,r]of Object.entries(t))
|
|
914
|
-
"Plugin must have an install method.");t.install(e)}function
|
|
915
|
-
{value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
916
|
-
typeof t!="object"&&typeof t!="function")return null;let e=
|
|
880
|
+
e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},fi=Gu;var vi=new WeakMap,wi=new WeakMap,yi=Symbol.for("json-rest-schema.registry-metadata"),tr=new WeakSet;function Wu(t,e,n){
|
|
881
|
+
if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);_(t,e,n)}function Ku(t,e,n){if(typeof n!=
|
|
882
|
+
"function")throw new Error(`Validator handler for '${e}' must be a function.`);_(t,e,n)}function rr(t={}){let e=Object.create(
|
|
883
|
+
null);for(let[n,r]of Object.entries(t))_(e,n,r);return e}function mi(t,e){if(typeof t.install!="function")throw new Error(
|
|
884
|
+
"Plugin must have an install method.");t.install(e)}function hi(t,e,n){vi.set(t,e),wi.set(t,n),Object.defineProperty(t,yi,
|
|
885
|
+
{value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function Ju(t){if(!t||
|
|
886
|
+
typeof t!="object"&&typeof t!="function")return null;let e=vi.get(t),n=wi.get(t);if(e&&n)return{types:e,validators:n};let r=t[yi];
|
|
917
887
|
return r&&typeof r.getTypes=="function"&&typeof r.getValidators=="function"?{types:r.getTypes(),validators:r.getValidators()}:
|
|
918
888
|
typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
|
|
919
889
|
nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
|
|
920
|
-
validators}:null}function
|
|
921
|
-
entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(
|
|
922
|
-
factories with conflicting ${n} "${r}".`)}
|
|
923
|
-
types:
|
|
924
|
-
"Factory sources must be schema instances or schema factories created by json-rest-schema.");
|
|
925
|
-
validators,"validator")}return{types:o,validators:s}}function
|
|
926
|
-
t),o=
|
|
927
|
-
s.addValidator=(i,a)=>{
|
|
928
|
-
let a=
|
|
929
|
-
addType(i,a)},addValidator:(i,a)=>{
|
|
930
|
-
function
|
|
890
|
+
validators}:null}function Xu(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function gi(t,e,n){for(let[r,o]of Object.
|
|
891
|
+
entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(tr.has(o))continue;if(!tr.has(t[r]))throw new Error(`Cannot merge schema\
|
|
892
|
+
factories with conflicting ${n} "${r}".`)}_(t,r,o)}}function Yu(t,e,n){let r=Xu(n).filter(Boolean);if(r.length<1)return{
|
|
893
|
+
types:rr(t),validators:rr(e)};let o=Object.create(null),s=Object.create(null);for(let i of r){let a=Ju(i);if(!a)throw new Error(
|
|
894
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");gi(o,a.types,"type"),gi(s,a.
|
|
895
|
+
validators,"validator")}return{types:o,validators:s}}function Ii({types:t={},validators:e={},installCore:n=!0}={}){let r=rr(
|
|
896
|
+
t),o=rr(e),s=(i,a={})=>{let c=new Be(i,r,o,a.operations);return hi(c,r,o),c};return hi(s,r,o),s.addType=(i,a)=>{Wu(r,i,a)},
|
|
897
|
+
s.addValidator=(i,a)=>{Ku(o,i,a)},s.use=i=>{mi(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{
|
|
898
|
+
let a=Yu(r,o,i);return Ii({types:a.types,validators:a.validators,installCore:!1})},n&&mi(fi,{addType:(i,a)=>{tr.add(a),s.
|
|
899
|
+
addType(i,a)},addValidator:(i,a)=>{tr.add(a),s.addValidator(i,a)}}),s}var Q=Ii({installCore:!0});var mx=Object.freeze({schema:Q({}),mode:"replace"});var Si=/^[a-z][a-z0-9_.-]*$/u,Qu=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function el(t){return String(t||"").trim().toLowerCase()}
|
|
900
|
+
function An(t,e){let n=el(t);if(!Si.test(n))throw new TypeError(`${e} must match ${Si.toString()}.`);return n}function _n(t,e){
|
|
931
901
|
if(t==null)return Object.freeze({});if(!A(t))throw new TypeError(`${e} must be an object mapping local names to capabili\
|
|
932
|
-
ty ids.`);let n={},r=new Set;for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!
|
|
933
|
-
`${e} local name "${i}" must be a JavaScript identifier.`);let a=
|
|
934
|
-
declares capability "${a}" more than once.`);r.add(a),n[i]=a}return Object.freeze(n)}function
|
|
902
|
+
ty ids.`);let n={},r=new Set;for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!Qu.test(i))throw new TypeError(
|
|
903
|
+
`${e} local name "${i}" must be a JavaScript identifier.`);let a=An(s,`${e}.${i}`);if(r.has(a))throw new TypeError(`${e}\
|
|
904
|
+
declares capability "${a}" more than once.`);r.add(a),n[i]=a}return Object.freeze(n)}function tl(t,e,n){if(t==null)return Object.
|
|
935
905
|
freeze({});if(!A(t))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
|
|
936
|
-
r.`);let r=new Set(Object.values(e)),o={};for(let[s,i]of Object.entries(t)){let a=
|
|
906
|
+
r.`);let r=new Set(Object.values(e)),o={};for(let[s,i]of Object.entries(t)){let a=An(s,`${n}.hints key`);if(!r.has(a))throw new TypeError(
|
|
937
907
|
`${n}.hints names "${a}", which the provider does not require.`);if(typeof i!="string"||!i.trim())throw new TypeError(`${n}\
|
|
938
|
-
.hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function
|
|
908
|
+
.hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function rl(t){let e=new Map;
|
|
939
909
|
for(let[n,r]of Object.entries(t))for(let o of Object.keys(r)){if(e.has(o))throw new TypeError(`Provider local name "${o}\
|
|
940
|
-
" is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function
|
|
941
|
-
throw new TypeError(`${e} must be a function when provided.`);return t}function
|
|
942
|
-
hints:o={},setup:s,boot:i=null,shutdown:a=null}={}){let c=
|
|
943
|
-
nal`),m=
|
|
944
|
-
`${c}.setup is required.`);return Object.freeze({id:c,requires:d,optional:p,provides:m,hints:
|
|
945
|
-
`${c}.boot`),shutdown:
|
|
946
|
-
tration is closed after the first payload is resolved.");let p=
|
|
910
|
+
" is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function Cn(t,e){if(t==null)return null;if(typeof t!="function")
|
|
911
|
+
throw new TypeError(`${e} must be a function when provided.`);return t}function nr({id:t,requires:e={},optional:n={},provides:r={},
|
|
912
|
+
hints:o={},setup:s,boot:i=null,shutdown:a=null}={}){let c=An(t,"Provider id"),d=_n(e,`${c}.requires`),p=_n(n,`${c}.optio\
|
|
913
|
+
nal`),m=_n(r,`${c}.provides`);rl({requires:d,optional:p,provides:m});let l=Cn(s,`${c}.setup`);if(!l)throw new TypeError(
|
|
914
|
+
`${c}.setup is required.`);return Object.freeze({id:c,requires:d,optional:p,provides:m,hints:tl(o,d,c),setup:l,boot:Cn(i,
|
|
915
|
+
`${c}.boot`),shutdown:Cn(a,`${c}.shutdown`)})}var xi="public";var nl="/api",Ti=`${nl}/bootstrap`;function On(){let t=[],e=new Set,n=!1;function r({id:a,order:c=0,contribute:d}={}){if(n)throw new Error("Bootstrap regis\
|
|
916
|
+
tration is closed after the first payload is resolved.");let p=C(a);if(!p)throw new TypeError("Bootstrap contributor id \
|
|
947
917
|
is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${p}" requires contribute().`);if(e.has(
|
|
948
918
|
p))throw new Error(`Bootstrap contributor "${p}" is duplicated.`);return e.add(p),t.push(Object.freeze({id:p,order:Number.
|
|
949
919
|
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){n=!0;let c={},d=t.map((p,m)=>({entry:p,index:m})).sort(
|
|
950
920
|
(p,m)=>p.entry.order-m.entry.order||p.index-m.index).map(({entry:p})=>p);for(let p of d){let m=await p.contribute(Object.
|
|
951
921
|
freeze({...A(a)?a:{},payload:Object.freeze({...c})}));c={...c,...A(m)?m:{}}}return Object.freeze(c)}function s(){return Object.
|
|
952
922
|
freeze({sealed:n,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:r,resolve:o,diagnostics:s});
|
|
953
|
-
return i}var
|
|
954
|
-
let e=
|
|
955
|
-
async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});function
|
|
923
|
+
return i}var ol=nr({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:t}){
|
|
924
|
+
let e=On();return t.router.register("GET",Ti,{auth:xi,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
|
|
925
|
+
async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});function sl(t){if(!A(t))throw new TypeError("Event listener must be an object.");let e=String(t.id||"").trim();if(!e)throw new TypeError(
|
|
956
926
|
"Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(`Event listener "${e}" requires han\
|
|
957
927
|
dle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event listener "${e}" matches must be a f\
|
|
958
|
-
unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function
|
|
928
|
+
unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function il(t){if(!A(t))throw new TypeError(
|
|
959
929
|
"Published event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is\
|
|
960
|
-
required.");return Object.freeze({...t,type:e})}function
|
|
961
|
-
throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function r(i){let a=
|
|
930
|
+
required.");return Object.freeze({...t,type:e})}function Rn(){let t=[],e=new Set;function n(i){let a=sl(i);if(e.has(a.id))
|
|
931
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function r(i){let a=il(i);
|
|
962
932
|
for(let c of t)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
963
|
-
freeze(t.map(i=>i.id))})}let s=Object.freeze({register:n,publish:r,diagnostics:o});return s}var
|
|
964
|
-
t))
|
|
933
|
+
freeze(t.map(i=>i.id))})}let s=Object.freeze({register:n,publish:r,diagnostics:o});return s}var al=nr({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:Rn()}}});function _e(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let n of Object.getOwnPropertyNames(
|
|
934
|
+
t))_e(t[n],e);return Object.freeze(t)}var sT=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},TYPE_CAST_FAILED:{messageKey:"\
|
|
965
935
|
default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",code:"kernel.validation.field\
|
|
966
936
|
.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},MAX_LENGTH:{messageKey:"maxL\
|
|
967
937
|
ength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kernel.validation.field.minItems"},
|
|
@@ -971,10 +941,10 @@ code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kern
|
|
|
971
941
|
messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"valida\
|
|
972
942
|
tor",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"\
|
|
973
943
|
default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validation.field.not\
|
|
974
|
-
Empty"}}),
|
|
975
|
-
ace","patch","toJsonSchema"]);var
|
|
976
|
-
mode:"patch"});var
|
|
977
|
-
{...
|
|
944
|
+
Empty"}}),iT=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),aT=Object.freeze(["create","repl\
|
|
945
|
+
ace","patch","toJsonSchema"]);var ll=Q({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),pl=Object.freeze({schema:ll,
|
|
946
|
+
mode:"patch"});var _i=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),fl=Object.freeze(
|
|
947
|
+
{..._i,nullable:!0});var kT=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
|
|
978
948
|
minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.maxLength"},{keyword:"minimu\
|
|
979
949
|
m",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"exclusiveMinimum",code:"\
|
|
980
950
|
kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusiveMaximum"},{keyword:"mu\
|
|
@@ -986,32 +956,62 @@ additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems
|
|
|
986
956
|
perties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"propertyNames",code:"\
|
|
987
957
|
kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",code:"kernel.validat\
|
|
988
958
|
ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:t,code:e})=>[
|
|
989
|
-
t,e]));var
|
|
990
|
-
...
|
|
991
|
-
itive integer string."}}}}),mode:"patch"});var
|
|
992
|
-
execute:"assistant_action_execute"}),
|
|
959
|
+
t,e]));var Ci="^[1-9][0-9]*$",Pn=_e({type:"string",minLength:1,pattern:Ci}),hl=_e({...Pn,nullable:!0}),gl=_e({schema:Q({recordId:{
|
|
960
|
+
...Pn,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
|
|
961
|
+
itive integer string."}}}}),mode:"patch"});var Ai=20,yl=32*1024,Ei=48*1024,kn=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
962
|
+
execute:"assistant_action_execute"}),Mn=Object.freeze({type:"object",additionalProperties:!0}),Il=Object.freeze({type:"o\
|
|
993
963
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
994
964
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
995
965
|
ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
|
|
996
|
-
limit:{type:"integer",minimum:1,maximum:
|
|
997
|
-
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:
|
|
966
|
+
limit:{type:"integer",minimum:1,maximum:Ai,description:"Maximum compact matches to return."}}}),Sl=Object.freeze({type:"\
|
|
967
|
+
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Ai,items:{
|
|
998
968
|
type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
|
|
999
969
|
tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
|
|
1000
|
-
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),
|
|
1001
|
-
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),
|
|
970
|
+
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),xl=Object.freeze({type:"object",additionalProperties:!1,required:[
|
|
971
|
+
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),Tl=Object.
|
|
1002
972
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
|
|
1003
973
|
chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
|
|
1004
|
-
string"},inputSchema:
|
|
1005
|
-
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:
|
|
974
|
+
string"},inputSchema:Mn,outputSchema:Mn}}),bl=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
975
|
+
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Mn}}),_l=Object.
|
|
1006
976
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
1007
|
-
g"},version:{type:"integer",minimum:1},result:{}}}),
|
|
977
|
+
g"},version:{type:"integer",minimum:1},result:{}}}),Oi=Object.freeze([Object.freeze({name:kn.search,description:"Discove\
|
|
1008
978
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
1009
979
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
1010
|
-
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:
|
|
1011
|
-
outputSchema:
|
|
1012
|
-
e action before executing it.",parameters:
|
|
1013
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:
|
|
1014
|
-
|
|
980
|
+
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:Il,
|
|
981
|
+
outputSchema:Sl}),Object.freeze({name:kn.contract,description:"Load the exact input and output contract for one availabl\
|
|
982
|
+
e action before executing it.",parameters:xl,outputSchema:Tl}),Object.freeze({name:kn.execute,description:"Execute one a\
|
|
983
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:bl,outputSchema:_l})]);var Rb=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var u_=new Error("A later Stop or turn superseded this Claude frame.");var kl=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
|
|
984
|
+
attachments:!1,tools:!1,nativeTools:!1});var fC=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
985
|
+
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
986
|
+
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),mC=Object.freeze({});var BC=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexRuntime.js",import.meta.url).href;import{createHash as Di}from"node:crypto";import{open as Yl}from"node:fs/promises";import zi from"node:path";var zn=1024*1024,Zl=256*1024,Li=512,Ql=128,ep=16*1024;function Ln({errorPrefix:t="",identityNamespace:e="codex-account-v\
|
|
987
|
+
1",secretNamespace:n="codex-auth-secret-v1"}={}){function r(d="",p="",{messageCode:m}={}){let l=new Error(I(p)||"Codex h\
|
|
988
|
+
elper authentication is unavailable. Reconnect Codex and retry.");return l.code=I(d)||`${t}codex_helper_auth_unavailable`,
|
|
989
|
+
I(p)?m&&(l.messageCode=m):l.messageCode="assistant.codex.helperAuthUnavailable",l.messageCode&&(l.messageParams={}),l}function o(d,{
|
|
990
|
+
label:p="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw r(`${t}cod\
|
|
991
|
+
ex_helper_auth_invalid`,`${p} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",p=""){return`\
|
|
992
|
+
sha256:${Di("sha256").update(`${e}\0`,"utf8").update(I(d),"utf8").update("\0","utf8").update(String(p||""),"utf8").digest(
|
|
993
|
+
"hex")}`}function i(d=""){return Di("sha256").update(`${n}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){
|
|
994
|
+
let p=null;try{p=await Yl(d,"r");let m=await p.stat();if(!m.isFile()||m.size>zn)throw r(`${t}codex_helper_auth_invalid`,
|
|
995
|
+
"The selected Codex authentication record is invalid. Reconnect Codex and retry.",{messageCode:"assistant.codex.authReco\
|
|
996
|
+
rdInvalid"});let l=Buffer.alloc(zn+1),v=0;for(;v<l.length;){let{bytesRead:T}=await p.read(l,v,l.length-v,null);if(T===0)
|
|
997
|
+
break;v+=T}if(v>zn)throw r(`${t}codex_helper_auth_invalid`,"The selected Codex authentication record is too large. Recon\
|
|
998
|
+
nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let x=JSON.parse(l.subarray(0,v).toString("ut\
|
|
999
|
+
f8"));if(!A(x))throw new Error("invalid authentication record");return x}catch(m){throw m?.code?.startsWith?.(`${t}codex\
|
|
1000
|
+
_helper_auth_`)?m:r(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. Rec\
|
|
1001
|
+
onnect Codex and retry.",{messageCode:"assistant.codex.authRecordUnreadable"})}finally{await p?.close().catch(()=>null)}}
|
|
1002
|
+
async function c(d={}){let p=I(d.toolHomeSource);if(!p||!zi.isAbsolute(p))throw r(`${t}codex_helper_auth_unavailable`,"T\
|
|
1003
|
+
he selected Codex account is unavailable. Reconnect Codex and retry.",{messageCode:"assistant.codex.accountUnavailable"});
|
|
1004
|
+
let m=await a(zi.join(p,".codex","auth.json")),l=I(m.auth_mode).toLowerCase();if(l==="chatgpt"){let v=A(m.tokens)?m.tokens:
|
|
1005
|
+
{},x=o(v.account_id,{label:"Codex account identity",maxLength:Li}),T=o(v.access_token,{label:"Codex access token",maxLength:Zl}),
|
|
1006
|
+
O=v.chatgpt_plan_type??v.plan_type,P=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:Ql});return Object.freeze(
|
|
1007
|
+
{accessToken:T,accountId:x,authMode:"chatgpt",identitySignature:s("chatgpt",x),planType:P,secretSignature:i(T)})}if(["ap\
|
|
1008
|
+
ikey","api_key"].includes(l)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:ep});return Object.freeze({apiKey:v,
|
|
1009
|
+
authMode:"apiKey",identitySignature:s("apiKey",v),secretSignature:i(v)})}throw r(`${t}codex_helper_auth_invalid`,"The se\
|
|
1010
|
+
lected Codex authentication mode is unsupported. Reconnect Codex and retry.",{messageCode:"assistant.codex.authModeUnsup\
|
|
1011
|
+
ported"})}return Object.freeze({error:r,identitySignature:s,readRecord:a,readSelected:c})}var uA=Object.freeze({label:"Checking the Codex sign-in",operationId:"codex-auth-preflight"});var vA=Ln().error;var qA=4*1024*1024;var YE=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
1012
|
+
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
1013
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var nO=2*1024*1024,oO=32*1024*1024,sO=2*1024*1024;var SR=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var AR=256*1024;var ER=2*1024*1024;var OR=Oi.map(({name:t,description:e,parameters:n})=>({type:"function",function:{name:t,description:e,parameters:n}}));var sP=Object.freeze({});var vP=Object.freeze([]);var Cp=Object.freeze({resolve(){throw new N(400,"File attachments are not configured for this conversation.",{code:"conv\
|
|
1014
|
+
ersation_attachments_not_configured",messageCode:"assistant.conversation.attachmentsNotConfigured"})}});var CP=Object.freeze([{message:"This conversation exceeds the configured API history limit. Start another conversation o\
|
|
1015
1015
|
r increase the limit.",messageCode:"assistant.conversation.apiHistoryLimit"},{message:"The model reached its output toke\
|
|
1016
1016
|
n limit before completing the answer. Increase maxOutputTokens in the conversation limits.",messageCode:"assistant.conve\
|
|
1017
1017
|
rsation.outputTokenLimit"},{message:"The model stream ended without confirming its application tool calls.",messageCode:"\
|
|
@@ -1030,21 +1030,21 @@ t be saved. Restore storage access and retry saving.",messageCode:"assistant.con
|
|
|
1030
1030
|
Conversation progress could not be saved. Restore access to its storage before continuing.",messageCode:"assistant.conve\
|
|
1031
1031
|
rsation.progressUnsaved"},{message:"The conversation request exceeded its time limit.",messageCode:"assistant.conversati\
|
|
1032
1032
|
on.requestTimedOut"},{message:"Work stopped.",messageCode:"assistant.conversation.workStopped"},{message:"Stopped by use\
|
|
1033
|
-
r.",messageCode:"assistant.conversation.stoppedByUser"}]);var Ve=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var
|
|
1034
|
-
type:"string",maxLength:Ve.toolName,required:!1},arguments:{type:"string",maxLength:Ve.arguments,required:!1}}),
|
|
1033
|
+
r.",messageCode:"assistant.conversation.stoppedByUser"}]);var Ve=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var pk=Q({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:Ve.text,required:!1},toolName:{
|
|
1034
|
+
type:"string",maxLength:Ve.toolName,required:!1},arguments:{type:"string",maxLength:Ve.arguments,required:!1}}),fk={type:"\
|
|
1035
1035
|
object",additionalProperties:!1,required:["kind","text","toolName","arguments"],properties:{kind:{type:"string",enum:["r\
|
|
1036
1036
|
eply","tool"]},text:{type:"string",maxLength:Ve.text,description:"The final reply, or a brief progress sentence for the \
|
|
1037
1037
|
first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:Ve.toolName},arguments:{type:"\
|
|
1038
|
-
string",maxLength:Ve.arguments}}};var
|
|
1039
|
-
readInstructions:e=
|
|
1038
|
+
string",maxLength:Ve.arguments}}};var fM=Object.freeze({});function Dp(){throw new TypeError("Hook delivery requires an instruction resolver.")}function Kn({resolveConversation:t,
|
|
1039
|
+
readInstructions:e=Dp}){if(typeof t!="function")throw new TypeError("Conversation hook delivery requires a binding resol\
|
|
1040
1040
|
ver.");return async function(r){if(r.scope!=="session")return{kind:"unclaimed"};let o=await t(r);if(!o)return{kind:"uncl\
|
|
1041
1041
|
aimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError("Unknown con\
|
|
1042
1042
|
versation instruction delivery mode.");let s=await e(o,r);if(typeof s!="string"||!s.trim())throw new TypeError("Managed \
|
|
1043
|
-
conversation instructions are unavailable.");return{kind:"delivery",text:s}}}var
|
|
1043
|
+
conversation instructions are unavailable.");return{kind:"delivery",text:s}}}var gM=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
1044
1044
|
allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
1045
1045
|
test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
|
|
1046
|
-
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as
|
|
1047
|
-
"managedPreview"]),
|
|
1046
|
+
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as zp}from"node:fs/promises";import Jn from"node:path";function ir(t){return String(t||"").trim()}var Lp=Object.freeze(["main","temporary"]),Gi=Object.freeze(["managedDatabaseRefresh","managedEnvironment","managedGit",
|
|
1047
|
+
"managedPreview"]),Wi=Object.freeze(["managedPages"]),Up=64*1024,KM=Object.freeze(["When user input is necessary, ask no\
|
|
1048
1048
|
more than three concise, high-impact questions at once.","Put multiple questions on separate lines as `[1] Question`, `\
|
|
1049
1049
|
[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answers:` and a short bullet list dir\
|
|
1050
1050
|
ectly beneath its own question, before the next one; never collect several questions' answers into one trailing list.","\
|
|
@@ -1057,7 +1057,7 @@ Possible answers:
|
|
|
1057
1057
|
[2] Tell the main agent before changes?
|
|
1058
1058
|
Possible answers:
|
|
1059
1059
|
- Yes, tell main first
|
|
1060
|
-
- No, proceed independently`]),
|
|
1060
|
+
- No, proceed independently`]),JM=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
|
|
1061
1061
|
start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
|
|
1062
1062
|
nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
|
|
1063
1063
|
ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
|
|
@@ -1117,7 +1117,7 @@ waits for cleanup/restoration; retry if cleanup needs attention. Never kill test
|
|
|
1117
1117
|
exit alone does not prove tests stopped. Recheck status before reporting a busy blocker.","If a managed command reports \
|
|
1118
1118
|
kernel task denials or a resource incident, report the blocker with its diagnostic and incident ID and ask the platform \
|
|
1119
1119
|
operator to inspect that evidence before retrying; never raise test timeouts or weaken assertions to work around a proce\
|
|
1120
|
-
ss/thread limit. A generic browser timeout without resource evidence does not establish a platform cause."])
|
|
1120
|
+
ss/thread limit. A generic browser timeout without resource evidence does not establish a platform cause."]),XM=Object.freeze(
|
|
1121
1121
|
['Pages: `vibe64-helper pages publish <file.html|folder> [--title "Title"]` publishes an HTML page (one file, or a folde\
|
|
1122
1122
|
r with index.html and its own scripts, styles, data and images) that everyone with access to this project can open from \
|
|
1123
1123
|
Vibe64\'s Pages list; `vibe64-helper pages update <page-id> <file.html|folder>` gives a page a new version under the same\
|
|
@@ -1139,34 +1139,35 @@ e data; use --prompt only when gathering it needs judgement.","Before making a p
|
|
|
1139
1139
|
hen a page about the same subject already exists, update it instead of making a new one.","Do not offer pages for quick \
|
|
1140
1140
|
answers, code changes, or documents that belong in the repository. Offer at most once per topic; do not nag.","Everyone \
|
|
1141
1141
|
with access to the project can open a page: never put secrets in one, or anything not every project member should see."]),
|
|
1142
|
-
|
|
1142
|
+
YM=Object.freeze(["Each managed shell command receives current development Env from Vibe64, including declared resource \
|
|
1143
1143
|
bindings; use them in ordinary commands. Do not build environment injection or copy managed credentials into source. Res\
|
|
1144
1144
|
ource provisioning and application migrations remain separate preparation steps.","Use `vibe64-helper env status [develo\
|
|
1145
1145
|
pment|production|all]` to inspect configured key names without revealing values.","Pipe an available value to `vibe64-he\
|
|
1146
|
-
lper env set <development|production> <KEY> [--secret]`;
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
"utf8")>1024))throw new TypeError(
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
"Vibe64 ephemeral context
|
|
1168
|
-
|
|
1169
|
-
|
|
1146
|
+
lper env set <development|production> <KEY> [--secret]`; it drops the one final newline that `echo` or a generator print\
|
|
1147
|
+
s and stores every other character exactly. Never put values in arguments, logs, or repository files. Use empty stdin on\
|
|
1148
|
+
ly when the user requested an empty value. The host decides whose session may change production values; when it refuses,\
|
|
1149
|
+
report its message instead of retrying.","When the person refers to a saved key, account or accounts hub, run `vibe64-h\
|
|
1150
|
+
elper env saved` (names, descriptions and fields, never values) and link the matching field to the variable the applicat\
|
|
1151
|
+
ion reads with `vibe64-helper env link <development|production> <KEY> <saved-id> <field-id>` instead of asking for the v\
|
|
1152
|
+
alue.","Keep development and production values separate. Never invent credentials, copy a value between scopes without e\
|
|
1153
|
+
xplicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected scope and k\
|
|
1154
|
+
ey names, never their values, and claim success only when the command succeeded.","Store a secret the application needs \
|
|
1155
|
+
generated (such as an application key) by generating it with the framework's own generator and piping it to `vibe64-help\
|
|
1156
|
+
er env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file from Env."]);
|
|
1157
|
+
function Xn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object.`);return t}function mt(t,e,n){
|
|
1158
|
+
let r=new Set(e),o=Object.keys(t).filter(s=>!r.has(s));if(o.length>0)throw new TypeError(`${n} contains unsupported fiel\
|
|
1159
|
+
ds: ${o.join(", ")}.`)}function Fp(t){if(mt(t,["conversationKind","scope","session","hostGuidance"],"Vibe64 session cont\
|
|
1160
|
+
ext"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,"utf8")>1024))throw new TypeError(
|
|
1161
|
+
"Vibe64 host guidance must be bounded text supplied by the host.");if(!Lp.includes(t.conversationKind))throw new TypeError(
|
|
1162
|
+
"Vibe64 session context has an unknown conversationKind.");let e=Xn(t.session,"Vibe64 session capabilities");mt(e,[...Gi,
|
|
1163
|
+
...Wi],"Vibe64 session capabilities");let n=Object.fromEntries(Gi.map(r=>{if(typeof e[r]!="boolean")throw new TypeError(
|
|
1164
|
+
`Vibe64 session capability ${r} must be boolean.`);return[r,e[r]]}));for(let r of Wi){if(e[r]!==void 0&&typeof e[r]!="bo\
|
|
1165
|
+
olean")throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);e[r]===!0&&(n[r]=!0)}return{conversationKind:t.
|
|
1166
|
+
conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:n}}function qp(t){mt(t,["sco\
|
|
1167
|
+
pe","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").trim();if(!e||e.length>Up)throw new TypeError(
|
|
1168
|
+
"Vibe64 ephemeral context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function $p(t){if(t.
|
|
1169
|
+
scope==="session")return Fp(t);if(t.scope==="ephemeral")return qp(t);throw new TypeError("The Vibe64 driver supports ses\
|
|
1170
|
+
sion and ephemeral scopes only.")}async function Ki(t={},{readRegistry:e=zp,workdir:n=""}={}){let r=Xn(t,"Vibe64 host resolver request");if(mt(r,["data","\
|
|
1170
1171
|
providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(r.scope))throw new TypeError(
|
|
1171
1172
|
"The Vibe64 host resolver scope must be session or turn.");if(r.scope==="turn")return null;let o=Xn(r.data,"Vibe64 host \
|
|
1172
1173
|
resolver data");mt(o,["registryPath"],"Vibe64 host resolver data");let s=ir(o.registryPath);if(!Jn.isAbsolute(s))throw new TypeError(
|
|
@@ -1176,7 +1177,7 @@ if(r.parentSessionIds!==void 0&&(!Array.isArray(r.parentSessionIds)||r.parentSes
|
|
|
1176
1177
|
l=>typeof l!="string"||!l.trim())))throw new TypeError("Invalid native conversation ancestry.");let p=[c,...r.parentSessionIds||
|
|
1177
1178
|
[]].filter(Boolean).map(l=>a.find(v=>ir(v?.upstreamSessionId)===l)).find(Boolean),m=p?.promptContext;if(!m)return null;if(n&&
|
|
1178
1179
|
p.workdir&&Jn.resolve(n)!==Jn.resolve(p.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
1179
|
-
t directory.");return
|
|
1180
|
-
tion input exceeds 256 KiB.");var
|
|
1181
|
-
process.stdout.write(await t(
|
|
1182
|
-
native"}:null});process.stdout.write(JSON.stringify(await t(
|
|
1180
|
+
t directory.");return $p(m)}var Yn="";for await(let t of process.stdin)if(Yn+=t,Buffer.byteLength(Yn)>256*1024)throw new Error("Conversation instruc\
|
|
1181
|
+
tion input exceeds 256 KiB.");var Ji=JSON.parse(Yn);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1182
|
+
process.stdout.write(await t(Ji))}else{let t=Kn({resolveConversation:async e=>await Ki(e,{workdir:process.cwd()})?{delivery:"\
|
|
1183
|
+
native"}:null});process.stdout.write(JSON.stringify(await t(Ji)))}
|